Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp693307pxb; Tue, 5 Apr 2022 19:03:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLXy/81EJplDl3bNbQZIkyAT7GUlH/cTDfEz0uo8zOs0mnhspcuazxVyUpUZNh+vd8YVtq X-Received: by 2002:a05:6a00:3486:b0:4fa:bb7e:b4c7 with SMTP id cp6-20020a056a00348600b004fabb7eb4c7mr6437388pfb.4.1649210588414; Tue, 05 Apr 2022 19:03:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649210588; cv=none; d=google.com; s=arc-20160816; b=aiYihHErA8VwgBcVgm+cGGdlc24SlB9C+8XmCVvDZ+fHWAvMjrUBMjzLACKvAwN6/C fhV+g7d+cvgjp/dSQYLNUvpXvFbApl53wMKX5mGv2+fHe95I2DoyVwiEKi6nIAN4c6Zk s+l/fNx+CIvG5D7UOVRs4mZKP07peD3xNc0BFfQzqJxrMQh2Fez9Z39SjwdqrAExyYHl XgjTr1FVQy4x6h/Vp+xqdCRjjY8+sBYu99XVwEV//Efv7C9ODmPx28QchCr68xQuyJiE 78yaA/ZqNA21l2hGsyOYDQ8HcTcI3r7pbFdCyZspYnLR6tlt+GH62qI5Fax3YQURxliM PcaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xChiCVM0tp8AuF1THef/H0/dybJ8LKzL6EHzrnSJLuc=; b=eJqo3q3wgIQoON2h0+j5/O+gtEAZaDquGHbizsZ3TyKmro88yiNgE7jK9GcH426mp1 jlXVFQ7kMaHvXoWkFSjo4PMM1viuVF3dszYdYiHjoJvPczWGlec/4SXIWKJfHUGhyQ3i 47YRyxkovxuIDkv4l6SnICtDo6Wq/WxzEwXCQSaMrO0aERPD3/21j/dozHOT5ySJoc1J 4eB2Xf1lWfviqsxmPFLHZuRnc00SVHM3enobkJmKVzjRAjyYakp5ic7Iwc1sQLy1/dgm oSgOlPPJb0VC4IvFNglm1LkB3zFiPz3bacFSRUiUgTQL8IJTdxMD4YdZ4sAwgOnk82p2 F+iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1LLRPp4g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f4-20020a6547c4000000b0039910e47e5bsi9089937pgs.528.2022.04.05.19.02.51; Tue, 05 Apr 2022 19:03:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1LLRPp4g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380530AbiDEMx4 (ORCPT + 99 others); Tue, 5 Apr 2022 08:53:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343802AbiDEJOP (ORCPT ); Tue, 5 Apr 2022 05:14:15 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 825F13DA53; Tue, 5 Apr 2022 02:00:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 35393B81A12; Tue, 5 Apr 2022 09:00:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EF54C385A0; Tue, 5 Apr 2022 09:00:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649149238; bh=5dFCK/bwE+X+xrItH9sMlwXXPJaUtIAhj7mXcM9iEas=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1LLRPp4gfYMklETkqAg+h745PHFvPKw2uUS4oYv09soX9C6H8NgzmKrqT16Pog2kP HXfH4ATRV/R+xJhq+luQFOANuZLkcfDjgZN6lq5FC9BZe57CKzu9PPcHEHYqjz2Lfi 1e6rw5Fp3MKnGHt24dbHj3PWx3V7qnQYDpgA7mQY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Joel Stanley , Eddie James , Sasha Levin Subject: [PATCH 5.16 0645/1017] fsi: scom: Fix error handling Date: Tue, 5 Apr 2022 09:25:58 +0200 Message-Id: <20220405070413.429006117@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joel Stanley [ Upstream commit d46fddd52d11eb6a3a7ed836f9f273e9cf8cd01c ] 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 Link: https://lore.kernel.org/r/20211207033811.518981-2-joel@jms.id.au Signed-off-by: Joel Stanley Signed-off-by: Sasha Levin --- 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); -- 2.34.1