Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1944256lql; Wed, 13 Mar 2024 12:36:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV5tYprJrIG3mzpGCz1Iayxb+xOB8vf+dhHLemavbd9+2yH9ysMkfg5uH+LtjKk8TY85UTAjdpVifp++bar12EwB3WVbCkHlq39Yk7Z7A== X-Google-Smtp-Source: AGHT+IGzMXdqyo2CoscKgnTjpHsbWgoBssToHSz9bUBCWJ+43OJslAd1PVZ3sSq/0vGBb61mgzBk X-Received: by 2002:ad4:40c4:0:b0:690:b2c1:83d6 with SMTP id x4-20020ad440c4000000b00690b2c183d6mr946715qvp.25.1710358567642; Wed, 13 Mar 2024 12:36:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710358567; cv=pass; d=google.com; s=arc-20160816; b=Vgg+PTJUJ/xYUm2/F4Ru9CxCgONGYN3lw31ZTWrAzIe+NGazYf2GiS6Q3sxLTJKYyu mnhgYwHxyDQfY4keIvCGouugn1bYnjoo7PRRiGr0+dGuYky9cqPV1vX3hVAu7lJSH5l5 Xp8f06+kLgV9A3/9ebuq0xhQj4XASu0qigK5h9xWd9qfj1IJrFY6jhHIpRjo7yFbWIrZ PP9GCVMrIjNA222y1y5qXwpWLRIgV5TsU34FZCpdaFFvxkUw+358Rq8xLQw46RcHHDHh vUak7lHoTvogLFdC8E16vxK4Diwgap7im6x3xS8McNV8ymlTMCIZgqXJpRQN0lQ1GxOB DJAw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:message-id:date:references:in-reply-to:subject:cc:to :from:dkim-signature; bh=ysfK4WAuswZZcsrIwKU0dt1AWESgCJqH8JdiLWgpbts=; fh=nul8tJIsDAXJNCuxvfpMc0MjMJByWnRocW0O/JbxmS8=; b=U+ZZhmzoU+Lf3UUDY48MxfBw7D34KmpnhjomT4jsYnJQmTI7ERoFc9yN6QFO/btOG9 rnPmlsBQ2fYcq4LJygZexa0lEXjCe9JXLm5ZX9/emzYqrWiPBOdPaAqsehgCt4jrNasf uCfhxvEkYZ114Hx+T+ngpZjFzxIx2ft3kuYC5UFsSgXlRE8xc3yobcXm60ksel+bJgul EbXMRPLbrnF/V9aMdOU1XpHFojZUo6nLFjTdfyYjamHvWwpG2tRS9N55+djAv05zyicv Mv5LOldLNUNvf21X2DIvSkIKA93J6R/zkBuotF+rAxFhOody9hAGUApbsKGCh/7U0oIl +UDQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P7Y0Qzrf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-102437-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102437-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id gw11-20020a0562140f0b00b0068f5be39eb5si10643677qvb.247.2024.03.13.12.36.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 12:36:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-102437-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P7Y0Qzrf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-102437-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102437-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C8A701C25BC5 for ; Wed, 13 Mar 2024 19:35:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CEC5E56770; Wed, 13 Mar 2024 19:29:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="P7Y0Qzrf" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0333A5644B; Wed, 13 Mar 2024 19:29:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710358149; cv=none; b=PtdU+qi+2LYCD2xh5ZxwoEF8k2ZDewsWfFZpE0VPJMs5rVjabWXO5Xa0mwUBnykI1oKQdWh2t5WE07TSxGln/X1/cS5oV+066cZRaiQ1UykLw0FB4EPe9tIqzmIFXayIYPZQtm79T6ecfOGggnMAZ1hMR4LEtTKbCMgHjfol5kI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710358149; c=relaxed/simple; bh=h9h9UxoZjbTVUIm/ZWHss0y6ukTkc84GVGIvZ6PPHrE=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=PpMLcgAnUy1lisS255IY6tHimL1fMb+ZFrlnwpFmZmlURfSEQ75URUki0TdjwdWveWB082ECbpbjUSb39IxA+FYhyYVi0J6AfqPmGmJ4deyHM2LVu2KMsERgSun2jLSKjLg5DrAYqlUvpS2UJ22uv/WuSRk2oLh1YykDbAfwWpo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=P7Y0Qzrf; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 363BBC433C7; Wed, 13 Mar 2024 19:29:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710358148; bh=h9h9UxoZjbTVUIm/ZWHss0y6ukTkc84GVGIvZ6PPHrE=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=P7Y0Qzrf1TVhSoMmtjUoO2rEIAXU4hs6xy3VoTi3WM1UkJuXd0L1vl3KxzsQbPPm7 /CcBUCR0Neg9vKZwiYyZKPIeiUaO8C3jJj2uFi2PPp4KIPGXBPPyceHTgSyPCM9Qob 3Ph84uN5yf8zhttNIn2M55IZKvLnvsK4CoNWw5z/e0Xja7mChQCdgFQVm0OGu2iU4X jlBfT0/J63XD1hvAwp9u7nj/q6jsVZgs7YxCmNBjwbnxHq5uKh+Ajlb53p0EFW7Wgw 637MMPVO/PVhxudXtLI0EOwXsAhVj7fRsEJVh4kkugw5LCFS0/nmr1KIWv+KnGLSpP fYCYCv6aKrKIA== From: Pratyush Yadav To: Florian Fainelli Cc: Pratyush Yadav , Michael Walle , linux-spi@vger.kernel.org, Mark Brown , Miquel Raynal , Mika Westerberg , "Chia-Lin Kao (AceLan)" , open list Subject: Re: [PATCH] spi: Fix error code checking in spi_mem_exec_op() In-Reply-To: <9420b802-5361-4f47-a069-52c43f5fd253@broadcom.com> (Florian Fainelli's message of "Wed, 13 Mar 2024 11:37:45 -0700") References: <20240313171050.3505620-1-florian.fainelli@broadcom.com> <9420b802-5361-4f47-a069-52c43f5fd253@broadcom.com> Date: Wed, 13 Mar 2024 20:29:05 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Wed, Mar 13 2024, Florian Fainelli wrote: > On 3/13/24 11:28, Pratyush Yadav wrote: >> On Wed, Mar 13 2024, Michael Walle wrote: >> >>> On Wed Mar 13, 2024 at 6:10 PM CET, Florian Fainelli wrote: >>>> After commit cff49d58f57e ("spi: Unify error codes by replacing -ENOTSUPP with >>>> -EOPNOTSUPP"), our SPI NOR flashes would stop probing with the following >>>> visible in the kernel log: >>>> >>>> [ 2.196300] brcmstb_qspi f0440920.qspi: using bspi-mspi mode >>>> [ 2.210295] spi-nor: probe of spi1.0 failed with error -95 >>>> >>>> It turns out that the check in spi_mem_exec_op() was changed to check >>>> for -ENOTSUPP (old error code) or -EOPNOTSUPP (new error code), but this >>>> means that for drivers that were converted, the second condition is now >>>> true, and we stop falling through like we used to. Fix the error to >>>> check for neither error being neither -ENOTSUPP *nor* -EOPNOTSUPP. >>>> >>>> Fixes: cff49d58f57e ("spi: Unify error codes by replacing -ENOTSUPP with -EOPNOTSUPP") >>>> Signed-off-by: Florian Fainelli >>>> Change-Id: I4159811f6c582c4de2143382473d2000b8755872 >>> >>> Ha, thank you! >>> >>> Reviewed-by: Michael Walle >>> >>> FWIW in next, there is commit >>> e63aef9c9121e ("spi: spi-mem: add statistics support to ->exec_op() calls") >>> that probably will conflict with this one. >>> >>> Also, - not for this patch - but with that logic, spi_mem_exec_op() >>> might return EOPNOTSUPP *or* ENOTSUPP, even for drivers which might >>> still return ENOTSUPP, because there is one condition in >>> spi_mem_exec_op() which will always return EOPNOTSUPP. That is >>> somewhat confusing, no? >> I agree. I suppose it would be better to do: >> if (!ret) >> return 0; >> if (ret == -ENOTSUPP || ret == -EOPNOTSUPP) >> return -EOPNOTSUPP; >> > > But with e63aef9c9121e ("spi: spi-mem: add statistics support to ->exec_op() > calls") applied, would not that mean duplicating the statistics gathering, or > were the statistics gathering only intended for when ret == 0? Hmm, I didn't properly understand this. Ignore my suggestion. Your patch does the right thing. In this case we should return ret when: ret is 0 OR when ret is not -EOPNOTSUPP or -ENOTSUPP. So if we get either of the two we _won't_ return and continue forward. From looking at just this, spi_mem_exec_op() only returns -EOPNOTSUPP so far since it has: if (!spi_mem_internal_supports_op(mem, op)) return -EOPNOTSUPP; But then looking further, it has: ret = spi_sync(mem->spi, &msg); if (ret) return ret; spi_sync() can return -ENOTSUPP if it goes via __spi_async(). I suppose we would need to fix that if we want consistent return codes. But that isn't a problem this patch should fix. So with the merge conflict fixed up, Reviewed-by: Pratyush Yadav -- Regards, Pratyush Yadav