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);