From patchwork Fri Jan 21 05:38:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 1582386 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=KQp4FN48; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linux-fsi-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jg7V24k1Vz9t2p for ; Fri, 21 Jan 2022 16:39:06 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Jg7Ty6JK4z30Qt for ; Fri, 21 Jan 2022 16:39:02 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=KQp4FN48; dkim-atps=neutral X-Original-To: linux-fsi@lists.ozlabs.org Delivered-To: linux-fsi@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::731; helo=mail-qk1-x731.google.com; envelope-from=joel.stan@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=KQp4FN48; dkim-atps=neutral Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Jg7Ts0ykHz30Ch for ; Fri, 21 Jan 2022 16:38:55 +1100 (AEDT) Received: by mail-qk1-x731.google.com with SMTP id d24so8791239qkk.5 for ; Thu, 20 Jan 2022 21:38:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MgTQTKYizbMiiJlg9iRgZhRLZdDPUF/UqTzCTAQB8AY=; b=KQp4FN48Jpzb9vgthzu7wq2uhq9EG3YHg9UcchoJxRywIATwgEIGR6tqptig3oNUve 9qAF5MZqX41V+d8vJes5cKZlyqoWUNB5gJuqk4hxI7PLtKIz5zyxDuyi0ipYaX7lTNo1 SKJYRH2gM8IzixBINjvXEpZ0a5JXpsqzEhCHw4W0KKbM302CweBG4Qo+gIyNeuBrvvIp 8WU9nE9v55/9uqndptmHoyOYgeTVs5BWpyEanl+I1BTUAkJl1KGbl+wVJEw2AmsTW2dx r9pSIeYiVwpZxFzbmRdAbcvt3533fyGHKklnEBlPTMPj/JdthQC15zzu3TREvAdViA2h /bMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=MgTQTKYizbMiiJlg9iRgZhRLZdDPUF/UqTzCTAQB8AY=; b=B1jEMMvSpw1mGwB0dvZcceRKSLQorl+CAuKx05LGSAPDx9sy3TMCudPfdtDNRDFKOJ VxvUhyNQbY0WTkYDjDCOkJYEAejRwOOYaiXTtenR65ZgDL7MYzX06CRklo/vbXfN2XSO xm/f2Bd0ABnZAzWshRQ0ChyolY68oTbf1MMWVEIVwrMmpVCnEA3EC7hUiBp59AzbTeLC h+0VX5YWyrHuvp3B4pOfQd7uVLBXyOa9xwAK2x0rh3PgPMosp89rCc1dxNlNUzcnCTvd gRGZ2g7eo/5zgPIhfzt+iwh72PwRL+Uawwv4Qt0iqslf4hsRwZXIBzvoqCQ8sEAruJPf YL0w== X-Gm-Message-State: AOAM533DCJWc32hEPdV5ymL23cGPOZqv6z+Prqt5TUx5Q2c89mlJB5Op WHdVCZjhiAMOtTvR+naDIQGuMEeLaMk= X-Google-Smtp-Source: ABdhPJzBSZ6cTE3B8BmQhwjqVfT8yC1FupKpLo1++LBeO4qhGj50pbFfhWJBK4tFXJqTVs98kD0vuA== X-Received: by 2002:a05:620a:20d8:: with SMTP id f24mr1683474qka.96.1642743532830; Thu, 20 Jan 2022 21:38:52 -0800 (PST) Received: from localhost.localdomain ([45.124.203.14]) by smtp.gmail.com with ESMTPSA id y17sm2607169qtw.0.2022.01.20.21.38.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jan 2022 21:38:52 -0800 (PST) From: Joel Stanley To: Jeremy Kerr , Alistar Popple , Eddie James , Amitay Isaacs Subject: [PATCH v3 1/2] fsi: sbefifo: Use specified value of start of response timeout Date: Fri, 21 Jan 2022 16:08:15 +1030 Message-Id: <20220121053816.82253-2-joel@jms.id.au> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220121053816.82253-1-joel@jms.id.au> References: <20220121053816.82253-1-joel@jms.id.au> MIME-Version: 1.0 X-BeenThere: linux-fsi@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-fsi@lists.ozlabs.org Errors-To: linux-fsi-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "linux-fsi" From: Amitay Isaacs For some of the chip-ops where sbe needs to collect trace information, sbe can take a long time (>30s) to respond. Currently these chip-ops will timeout as the start of response timeout defaults to 10s. Instead of default value, use specified value. The require timeout value will be set using ioctl. Signed-off-by: Amitay Isaacs Signed-off-by: Joel Stanley Reviewed-by: Eddie James --- drivers/fsi/fsi-sbefifo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/fsi/fsi-sbefifo.c b/drivers/fsi/fsi-sbefifo.c index 52328adef643..1e9b326e8f67 100644 --- a/drivers/fsi/fsi-sbefifo.c +++ b/drivers/fsi/fsi-sbefifo.c @@ -125,6 +125,7 @@ struct sbefifo { bool dead; bool async_ffdc; bool timed_out; + u32 timeout_start_rsp_ms; }; struct sbefifo_user { @@ -549,7 +550,7 @@ static int sbefifo_read_response(struct sbefifo *sbefifo, struct iov_iter *respo dev_vdbg(dev, "reading response, buflen = %zd\n", iov_iter_count(response)); - timeout = msecs_to_jiffies(SBEFIFO_TIMEOUT_START_RSP); + timeout = msecs_to_jiffies(sbefifo->timeout_start_rsp_ms); for (;;) { /* Grab FIFO status (this will handle parity errors) */ rc = sbefifo_wait(sbefifo, false, &status, timeout); @@ -972,6 +973,7 @@ static int sbefifo_probe(struct device *dev) sbefifo->fsi_dev = fsi_dev; dev_set_drvdata(dev, sbefifo); mutex_init(&sbefifo->lock); + sbefifo->timeout_start_rsp_ms = SBEFIFO_TIMEOUT_START_RSP; /* * Try cleaning up the FIFO. If this fails, we still register the From patchwork Fri Jan 21 05:38:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 1582385 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=AFDRxD4K; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linux-fsi-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jg7V133mhz9t2p for ; Fri, 21 Jan 2022 16:39:05 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Jg7V11mFCz30Pf for ; Fri, 21 Jan 2022 16:39:05 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=AFDRxD4K; dkim-atps=neutral X-Original-To: linux-fsi@lists.ozlabs.org Delivered-To: linux-fsi@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::82f; helo=mail-qt1-x82f.google.com; envelope-from=joel.stan@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=AFDRxD4K; dkim-atps=neutral Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Jg7Tv6Krwz2ynt for ; Fri, 21 Jan 2022 16:38:59 +1100 (AEDT) Received: by mail-qt1-x82f.google.com with SMTP id w6so8912353qtk.4 for ; Thu, 20 Jan 2022 21:38:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aAAjcbMGSfL+ONrTTuf3PGqmWSdgQ+wWZZ+GAzxN19Y=; b=AFDRxD4KSiEmsFxkbegWggpnP7XEfoiBH4Se3tS9WTgRK8Lbj6wcD/Trmsj9nLMayq wn7R7We7IuvIS9jDgBHr9SiGGa+4F4SpsM0KxgJdQPEIBfikqUnqTrFa0Bq4o8tm7Q/5 Z1jKn0p7Nr+VUxzgQHaBB0DZSpnE+Atr28N31Fu/K3z08xS848QM5ay71r6UFPNatgtw qEOZhXLYnTrbRnPqcXQBfflDi69Y/+1G7GhMDscw1GTmPnCUTZGTE+7CdA7q+uUZJiOg 91SpJ8hWuCspmLFKILWLyJlDWIsWZohYKI1RQnD0fZTE3GA4y4vL20KZiBLZi7J4t3gk a7KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=aAAjcbMGSfL+ONrTTuf3PGqmWSdgQ+wWZZ+GAzxN19Y=; b=XpGmVbIYBxFE0n6NZWRZCNBh78qPMsqsbrVlFxYdZBGKBQiBy2bOt5YerVgkeQZMZq Pp25X/d76n75i9t5W9RBck4Cw61q3jlFCWQD3cCuEXCKL55l/yhiQ46Z9Bfz4XrXJ2GO 3nnvy6CW9WIp3wcG7uIeBuoUzJPMxTVM5MbOBSjnJDNIvlxXLn6a5cwRujG3O71wMARs foDoP0FMOwqqu+beyV3iTXXbIiWib98nuY6t4Urp+QlcpqcykCOigpHUPalKjrmfkVgn 9l0QJfeR7b2PNkiG42W+uqzDUN0tGnwuKsBIVFqGM0YYo/7JfyC9rKt1tuSM2hbvAHqN k7SQ== X-Gm-Message-State: AOAM531aFIyLSf70AvKBHEeDUOHuDrbXGHNJrfsnaNbDtY9oMoXRN9ya CZ3gCZA41zJg8v81UaPNKns= X-Google-Smtp-Source: ABdhPJx1i2+IsbzcSIY3h0DecqKpQVtqGLmonyUfXtGyRkQpXghCg5k6zwKgutiBsmrwnO56D3ZjQw== X-Received: by 2002:ac8:1186:: with SMTP id d6mr2159010qtj.192.1642743536985; Thu, 20 Jan 2022 21:38:56 -0800 (PST) Received: from localhost.localdomain ([45.124.203.14]) by smtp.gmail.com with ESMTPSA id y17sm2607169qtw.0.2022.01.20.21.38.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jan 2022 21:38:56 -0800 (PST) From: Joel Stanley To: Jeremy Kerr , Alistar Popple , Eddie James , Amitay Isaacs Subject: [PATCH v3 2/2] fsi: sbefifo: Implement FSI_SBEFIFO_READ_TIMEOUT_SECONDS ioctl Date: Fri, 21 Jan 2022 16:08:16 +1030 Message-Id: <20220121053816.82253-3-joel@jms.id.au> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220121053816.82253-1-joel@jms.id.au> References: <20220121053816.82253-1-joel@jms.id.au> MIME-Version: 1.0 X-BeenThere: linux-fsi@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-fsi@lists.ozlabs.org Errors-To: linux-fsi-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "linux-fsi" From: Amitay Isaacs FSI_SBEFIFO_READ_TIMEOUT_SECONDS ioctl sets the read timeout (in seconds) for the response received by sbefifo device from sbe. The timeout affects only the read operation on current sbefifo device fd. Certain SBE operations can take long time to complete and the default timeout of 10 seconds might not be sufficient to start receiving response from SBE. In such cases, allow the timeout to be set to the maximum of 120 seconds. The kernel does not contain the definition of the various SBE operations, so we must expose an interface to userspace to set the timeout for the given operation. Signed-off-by: Amitay Isaacs Signed-off-by: Joel Stanley Reviewed-by: Eddie James --- v3: - Clarify why this is an ioctl and not hardcoded in the kernel - Add seconds to the name --- drivers/fsi/fsi-sbefifo.c | 49 +++++++++++++++++++++++++++++++++++++++ include/uapi/linux/fsi.h | 14 +++++++++++ 2 files changed, 63 insertions(+) diff --git a/drivers/fsi/fsi-sbefifo.c b/drivers/fsi/fsi-sbefifo.c index 1e9b326e8f67..f52a912cdf16 100644 --- a/drivers/fsi/fsi-sbefifo.c +++ b/drivers/fsi/fsi-sbefifo.c @@ -32,6 +32,8 @@ #include #include +#include + /* * The SBEFIFO is a pipe-like FSI device for communicating with * the self boot engine on POWER processors. @@ -134,6 +136,7 @@ struct sbefifo_user { void *cmd_page; void *pending_cmd; size_t pending_len; + u32 read_timeout_ms; }; static DEFINE_MUTEX(sbefifo_ffdc_mutex); @@ -796,6 +799,7 @@ static int sbefifo_user_open(struct inode *inode, struct file *file) return -ENOMEM; } mutex_init(&user->file_lock); + user->read_timeout_ms = SBEFIFO_TIMEOUT_START_RSP; return 0; } @@ -838,7 +842,9 @@ static ssize_t sbefifo_user_read(struct file *file, char __user *buf, rc = mutex_lock_interruptible(&sbefifo->lock); if (rc) goto bail; + sbefifo->timeout_start_rsp_ms = user->read_timeout_ms; rc = __sbefifo_submit(sbefifo, user->pending_cmd, cmd_len, &resp_iter); + sbefifo->timeout_start_rsp_ms = SBEFIFO_TIMEOUT_START_RSP; mutex_unlock(&sbefifo->lock); if (rc < 0) goto bail; @@ -928,12 +934,55 @@ static int sbefifo_user_release(struct inode *inode, struct file *file) return 0; } +static int sbefifo_read_timeout(struct sbefifo_user *user, void __user *argp) +{ + struct device *dev = &user->sbefifo->dev; + u32 timeout; + + if (get_user(timeout, (__u32 __user *)argp)) + return -EFAULT; + + if (timeout == 0) { + user->read_timeout_ms = SBEFIFO_TIMEOUT_START_RSP; + dev_dbg(dev, "Timeout reset to %d\n", user->read_timeout_ms); + return 0; + } + + if (timeout < 10 || timeout > 120) + return -EINVAL; + + user->read_timeout_ms = timeout * 1000; /* user timeout is in sec */ + + dev_dbg(dev, "Timeout set to %d\n", user->read_timeout_ms); + + return 0; +} + +static long sbefifo_user_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + struct sbefifo_user *user = file->private_data; + int rc = -ENOTTY; + + if (!user) + return -EINVAL; + + mutex_lock(&user->file_lock); + switch (cmd) { + case FSI_SBEFIFO_READ_TIMEOUT_SECONDS: + rc = sbefifo_read_timeout(user, (void __user *)arg); + break; + } + mutex_unlock(&user->file_lock); + return rc; +} + static const struct file_operations sbefifo_fops = { .owner = THIS_MODULE, .open = sbefifo_user_open, .read = sbefifo_user_read, .write = sbefifo_user_write, .release = sbefifo_user_release, + .unlocked_ioctl = sbefifo_user_ioctl, }; static void sbefifo_free(struct device *dev) diff --git a/include/uapi/linux/fsi.h b/include/uapi/linux/fsi.h index da577ecd90e7..b2f1977378c7 100644 --- a/include/uapi/linux/fsi.h +++ b/include/uapi/linux/fsi.h @@ -55,4 +55,18 @@ struct scom_access { #define FSI_SCOM_WRITE _IOWR('s', 0x02, struct scom_access) #define FSI_SCOM_RESET _IOW('s', 0x03, __u32) +/* + * /dev/sbefifo* ioctl interface + */ + +/** + * FSI_SBEFIFO_READ_TIMEOUT sets the read timeout for response from SBE. + * + * The read timeout is specified in seconds. The minimum value of read + * timeout is 10 seconds (default) and the maximum value of read timeout is + * 120 seconds. A read timeout of 0 will reset the value to the default of + * (10 seconds). + */ +#define FSI_SBEFIFO_READ_TIMEOUT_SECONDS _IOW('s', 0x00, __u32) + #endif /* _UAPI_LINUX_FSI_H */