From: Pratyush Yadav <pratyush@kernel.org>
To: Florian Fainelli <florian.fainelli@broadcom.com>
Cc: Pratyush Yadav <pratyush@kernel.org>,
Michael Walle <mwalle@kernel.org>,
linux-spi@vger.kernel.org, Mark Brown <broonie@kernel.org>,
Miquel Raynal <miquel.raynal@bootlin.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
"Chia-Lin Kao (AceLan)" <acelan.kao@canonical.com>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] spi: Fix error code checking in spi_mem_exec_op()
Date: Wed, 13 Mar 2024 20:29:05 +0100 [thread overview]
Message-ID: <mafs0il1qc4n2.fsf@kernel.org> (raw)
In-Reply-To: <9420b802-5361-4f47-a069-52c43f5fd253@broadcom.com> (Florian Fainelli's message of "Wed, 13 Mar 2024 11:37:45 -0700")
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 <florian.fainelli@broadcom.com>
>>>> Change-Id: I4159811f6c582c4de2143382473d2000b8755872
>>>
>>> Ha, thank you!
>>>
>>> Reviewed-by: Michael Walle <mwalle@kernel.org>
>>>
>>> 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 <pratyush@kernel.org>
--
Regards,
Pratyush Yadav
next prev parent reply other threads:[~2024-03-13 19:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-13 17:10 [PATCH] spi: Fix error code checking in spi_mem_exec_op() Florian Fainelli
2024-03-13 17:33 ` Michael Walle
2024-03-13 17:40 ` Mark Brown
2024-03-13 17:45 ` Florian Fainelli
2024-03-13 19:03 ` Florian Fainelli
2024-03-14 12:58 ` Mark Brown
2024-03-13 18:28 ` Pratyush Yadav
2024-03-13 18:37 ` Florian Fainelli
2024-03-13 19:29 ` Pratyush Yadav [this message]
2024-03-13 19:34 ` Florian Fainelli
2024-03-13 20:06 ` Florian Fainelli
2024-03-13 21:15 ` Pratyush Yadav
2024-03-15 17:13 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=mafs0il1qc4n2.fsf@kernel.org \
--to=pratyush@kernel.org \
--cc=acelan.kao@canonical.com \
--cc=broonie@kernel.org \
--cc=florian.fainelli@broadcom.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=miquel.raynal@bootlin.com \
--cc=mwalle@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.