From patchwork Tue Dec 7 03:38:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 1564469 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=lrh+UI11; 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)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J7Qxm4F3kz9s3q for ; Tue, 7 Dec 2021 14:38:36 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4J7Qxm1lJ3z2yP5 for ; Tue, 7 Dec 2021 14:38:36 +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=lrh+UI11; 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::536; helo=mail-pg1-x536.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=lrh+UI11; dkim-atps=neutral Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) (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 4J7Qxj3hsJz2xBf for ; Tue, 7 Dec 2021 14:38:32 +1100 (AEDT) Received: by mail-pg1-x536.google.com with SMTP id s137so12471263pgs.5 for ; Mon, 06 Dec 2021 19:38:32 -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=dEomjkO6usZNSsctJD1p6Zcy57WfWwQNo29c7d2e1PI=; b=lrh+UI119wmZYIiv5/pwqnzAFqRWwrQ3oBh2Ht+A9FuMG5oJFf2BQrY02nI7hL++CH C0sZTPx/CO25rXbR2n6rwEKWHot4q2/tKnkY6xYVr+i6ejcgRPSjeHRg4bC3kU3m9ak8 +wW82rZD607s1QjmBk83XxOJQ67JDkSK/4p7zyYkAhddbCWQvnQA9luZgBUPxS0w9Thu SkV3QQcFtF+b4V87z+NeHKbkMhLpOGlNUqjAgPtNV20yJ+n5eqKf/gymM/isZeUbxLRs 4QFzgtu3aoEQaBtTnnG2TYQS8bfJb6yFp7ot9iVZsEEjJ2r5I/0Fw4UEYuuA6WhyBmIG T+vw== 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=dEomjkO6usZNSsctJD1p6Zcy57WfWwQNo29c7d2e1PI=; b=x/7Ppz49zBgBXe+hBDU2rKfvS6AtK7OPBb3IC7FYi6YC4C9KAdjuQKj+KYtjQ39xL8 VTsbqsVviPHxzgk5YccRlXZ2k/gvdyk+GuoM3GT+k+sC+8E538ICdM627XekY87zgH7h 15U+/p/IZzqLJPWnABuQeGAsglp1cVxYY1ZVMvFp53h+i+DwI4legfCbu5FPZwPKGidl eiNQbpsHQ29oDPB/00YLst89Hnbus0qvLJC0nrq4eTMIbWFIhIn83NERaajRMUbXARZA tPXnPkdepFzKXnY9un8Y8vmSLgtzplKPtgkPT6Copz0IRQvD4cvL6ESWaw7WPXsFH7Le 4jMA== X-Gm-Message-State: AOAM5300DWnDAD3V5b0K/T6WYhd0x9AhhL/RoZ/jS1dfBEzdal6J9mDj BG2oVqohlesCC489kBwmM7j+eRB40R6+WicV X-Google-Smtp-Source: ABdhPJwZrWPAvA/NEeGakV91EOY/LMncWnJbcGrVlvuBvQ8lLHzjZXgFzpglWPpfHCy75GKOtyNKig== X-Received: by 2002:a63:6687:: with SMTP id a129mr21428300pgc.477.1638848310524; Mon, 06 Dec 2021 19:38:30 -0800 (PST) Received: from localhost.localdomain ([45.124.203.19]) by smtp.gmail.com with ESMTPSA id n3sm11052865pgc.76.2021.12.06.19.38.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Dec 2021 19:38:29 -0800 (PST) From: Joel Stanley To: Jeremy Kerr , Alistar Popple , Eddie James Subject: [PATCH 1/2] fsi: scom: Fix error handling Date: Tue, 7 Dec 2021 14:08:10 +1030 Message-Id: <20211207033811.518981-2-joel@jms.id.au> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211207033811.518981-1-joel@jms.id.au> References: <20211207033811.518981-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, Dan Carpenter , linux-fsi@lists.ozlabs.org Errors-To: linux-fsi-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "linux-fsi" SCOM error handling is made complex by trying to pass around two bits of information: the function return code, and a status parameter that represents the CFAM error status register. The commit f72ddbe1d7b7 ("fsi: scom: Remove retries") removed the "hidden" retries in the SCOM driver, in preference of allowing the calling code (userspace or driver) to decide how to handle a failed SCOM. However it introduced a bug by attempting to be smart about the return codes that were "errors" and which were ok to fall through to the status register parsing. We get the following errors: - EINVAL or ENXIO, for indirect scoms where the value is invalid - EINVAL, where the size or address is incorrect - EIO or ETIMEOUT, where FSI write failed (aspeed master) - EAGAIN, where the master detected a crc error (GPIO master only) - EBUSY, where the bus is disabled (GPIO master in external mode) In all of these cases we should fail the SCOM read/write and return the error. Thanks to Dan Carpenter for the detailed bug report. Fixes: f72ddbe1d7b7 ("fsi: scom: Remove retries") Link: https://lists.ozlabs.org/pipermail/linux-fsi/2021-November/000235.html Reported-by: Dan Carpenter Signed-off-by: Joel Stanley Reviewed-by: Eddie James --- drivers/fsi/fsi-scom.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/fsi/fsi-scom.c b/drivers/fsi/fsi-scom.c index da1486bb6a14..3b427f7e9027 100644 --- a/drivers/fsi/fsi-scom.c +++ b/drivers/fsi/fsi-scom.c @@ -289,7 +289,7 @@ static int put_scom(struct scom_device *scom, uint64_t value, int rc; rc = raw_put_scom(scom, value, addr, &status); - if (rc == -ENODEV) + if (rc) return rc; rc = handle_fsi2pib_status(scom, status); @@ -308,7 +308,7 @@ static int get_scom(struct scom_device *scom, uint64_t *value, int rc; rc = raw_get_scom(scom, value, addr, &status); - if (rc == -ENODEV) + if (rc) return rc; rc = handle_fsi2pib_status(scom, status); From patchwork Tue Dec 7 03:38:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 1564471 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=d6HVa48W; 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 4J7Qxq0hsWz9s3q for ; Tue, 7 Dec 2021 14:38:39 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4J7Qxp6N9Xz2yP5 for ; Tue, 7 Dec 2021 14:38:38 +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=d6HVa48W; 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::102b; helo=mail-pj1-x102b.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=d6HVa48W; dkim-atps=neutral Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) (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 4J7Qxn1sr2z2xBf for ; Tue, 7 Dec 2021 14:38:37 +1100 (AEDT) Received: by mail-pj1-x102b.google.com with SMTP id np6-20020a17090b4c4600b001a90b011e06so1513143pjb.5 for ; Mon, 06 Dec 2021 19:38:37 -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=hZC9U2jKVDuGs2UUeY7QPzNlMq63gmQj4X8NafYCGHc=; b=d6HVa48Wqm+KA2IPDIC1ZMFLQ0i5eNSB1YLPZ87AUHCmC1+y/o6GL69VEgD7C3gsNU lDnOVtvATEYAIsBDFpfBPVc0TJvRI8IHcL6XjIuwiUuG4ghVXpdpp8dWRrU0v4l7geAF LFIa90vwzZhyxNsWaZZvD8rQzUJrMP4TKQLcIaqctndnE/E29FFT5VjnPVFpIshg6weG NwMHMlEyv38zOzQl/FijI9RGv98sEvR4Jh13WyruuBRXQZ9mQB9g5YaKXPoMf7v3bYQP +wS/YzukRdi6KjHhvbjRxldg6uciwbibb5ojTwyhXXlaABFjXu1FwZUKR4sSJoNI1nVX eRfw== 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=hZC9U2jKVDuGs2UUeY7QPzNlMq63gmQj4X8NafYCGHc=; b=sJT5o7UIaxIjkPbzzjSm5YeCNsP+Tl5x5ebQwhzhrWhvOya2iMSgIuDnHdAAXwLklN A9TSou2B+Sd8yPfszflr3jZJumroqvLX5Cpcv3kWmCFhaOlzOf1SeX/Gb1b2BhF/mEtK LtQnPAhgfltAzRWpSv9q/j97x05AHL36DgatbInkUceiaXnJS2iBRnYVEJr5Weqc+pvJ nF98W4+L683UQoweoapiriuMheiSt3rqxNbneMgjqP2Rom9OoPANMuZTErZ4eKVGkbtF 6mr83Gl4ZBOvo0CLcVPidCcWPVSsRfNBw3tKxc/LvllCI+4mIIAYiWlKZ05ohdG/mR6u j2lQ== X-Gm-Message-State: AOAM5307Eagt9tzAmsTRHrn5mqJwGrRZ4+TPHeCfodYvSPVc/UxVMrw/ eb7Yca2zTYXoabdKErl0nAEzAZBxwgc0lQdC X-Google-Smtp-Source: ABdhPJzoVxIlMCOvxhNtZeJLmhVfUSWj4JcvwOUXLx6L25N67aQzjKxegOiAi3hbGkk7eDbB18hHCg== X-Received: by 2002:a17:90a:ec15:: with SMTP id l21mr3452892pjy.48.1638848314619; Mon, 06 Dec 2021 19:38:34 -0800 (PST) Received: from localhost.localdomain ([45.124.203.19]) by smtp.gmail.com with ESMTPSA id n3sm11052865pgc.76.2021.12.06.19.38.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Dec 2021 19:38:33 -0800 (PST) From: Joel Stanley To: Jeremy Kerr , Alistar Popple , Eddie James Subject: [PATCH 2/2] fsi: scom: Remove retries in indirect scoms Date: Tue, 7 Dec 2021 14:08:11 +1030 Message-Id: <20211207033811.518981-3-joel@jms.id.au> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211207033811.518981-1-joel@jms.id.au> References: <20211207033811.518981-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, Dan Carpenter , linux-fsi@lists.ozlabs.org Errors-To: linux-fsi-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "linux-fsi" In commit f72ddbe1d7b7 ("fsi: scom: Remove retries") the retries were removed from get and put scoms. That patch missed the retires in get and put indirect scom. For the same reason, remove them from the scom driver to allow the caller to decide to retry. This removes the following special case which would have caused the retry code to return early: - if ((ind_data & XSCOM_DATA_IND_COMPLETE) || (err != SCOM_PIB_BLOCKED)) - return 0; I believe this case is handled. Fixes: f72ddbe1d7b7 ("fsi: scom: Remove retries") Signed-off-by: Joel Stanley Reviewed-by: Eddie James --- drivers/fsi/fsi-scom.c | 41 +++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/drivers/fsi/fsi-scom.c b/drivers/fsi/fsi-scom.c index 3b427f7e9027..bcb756dc9866 100644 --- a/drivers/fsi/fsi-scom.c +++ b/drivers/fsi/fsi-scom.c @@ -145,7 +145,7 @@ static int put_indirect_scom_form0(struct scom_device *scom, uint64_t value, uint64_t addr, uint32_t *status) { uint64_t ind_data, ind_addr; - int rc, retries, err = 0; + int rc, err; if (value & ~XSCOM_DATA_IND_DATA) return -EINVAL; @@ -156,19 +156,14 @@ static int put_indirect_scom_form0(struct scom_device *scom, uint64_t value, if (rc || (*status & SCOM_STATUS_ANY_ERR)) return rc; - for (retries = 0; retries < SCOM_MAX_IND_RETRIES; retries++) { - rc = __get_scom(scom, &ind_data, addr, status); - if (rc || (*status & SCOM_STATUS_ANY_ERR)) - return rc; + rc = __get_scom(scom, &ind_data, addr, status); + if (rc || (*status & SCOM_STATUS_ANY_ERR)) + return rc; - err = (ind_data & XSCOM_DATA_IND_ERR_MASK) >> XSCOM_DATA_IND_ERR_SHIFT; - *status = err << SCOM_STATUS_PIB_RESP_SHIFT; - if ((ind_data & XSCOM_DATA_IND_COMPLETE) || (err != SCOM_PIB_BLOCKED)) - return 0; + err = (ind_data & XSCOM_DATA_IND_ERR_MASK) >> XSCOM_DATA_IND_ERR_SHIFT; + *status = err << SCOM_STATUS_PIB_RESP_SHIFT; - msleep(1); - } - return rc; + return 0; } static int put_indirect_scom_form1(struct scom_device *scom, uint64_t value, @@ -188,7 +183,7 @@ static int get_indirect_scom_form0(struct scom_device *scom, uint64_t *value, uint64_t addr, uint32_t *status) { uint64_t ind_data, ind_addr; - int rc, retries, err = 0; + int rc, err; ind_addr = addr & XSCOM_ADDR_DIRECT_PART; ind_data = (addr & XSCOM_ADDR_INDIRECT_PART) | XSCOM_DATA_IND_READ; @@ -196,21 +191,15 @@ static int get_indirect_scom_form0(struct scom_device *scom, uint64_t *value, if (rc || (*status & SCOM_STATUS_ANY_ERR)) return rc; - for (retries = 0; retries < SCOM_MAX_IND_RETRIES; retries++) { - rc = __get_scom(scom, &ind_data, addr, status); - if (rc || (*status & SCOM_STATUS_ANY_ERR)) - return rc; - - err = (ind_data & XSCOM_DATA_IND_ERR_MASK) >> XSCOM_DATA_IND_ERR_SHIFT; - *status = err << SCOM_STATUS_PIB_RESP_SHIFT; - *value = ind_data & XSCOM_DATA_IND_DATA; + rc = __get_scom(scom, &ind_data, addr, status); + if (rc || (*status & SCOM_STATUS_ANY_ERR)) + return rc; - if ((ind_data & XSCOM_DATA_IND_COMPLETE) || (err != SCOM_PIB_BLOCKED)) - return 0; + err = (ind_data & XSCOM_DATA_IND_ERR_MASK) >> XSCOM_DATA_IND_ERR_SHIFT; + *status = err << SCOM_STATUS_PIB_RESP_SHIFT; + *value = ind_data & XSCOM_DATA_IND_DATA; - msleep(1); - } - return rc; + return 0; } static int raw_put_scom(struct scom_device *scom, uint64_t value,