linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marek Vasut <marek.vasut-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Cyrille Pitchen
	<cyrille.pitchen-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>,
	Florian Fainelli
	<f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Kamal Dasu <kamal.dasu-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>,
	Marek Vasut <marex-ynQEQJNshbs@public.gmane.org>
Cc: vigneshr-l0cyMroinI0@public.gmane.org,
	Kamal Dasu <kdasu.kdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Yendapally Reddy Dhananjaya Reddy
	<yendapally.reddy-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>,
	Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/w@public.gmane.org,
	Jon Mason <jon.mason-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>,
	Brian Norris
	<computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH v6, 5/8] mtd: m25p80: Let m25p80_read() fallback to spi transfer
Date: Thu, 1 Dec 2016 16:45:01 +0100	[thread overview]
Message-ID: <3260e7e5-fcf1-599a-e7b4-fd7aaef5be2e@gmail.com> (raw)
In-Reply-To: <a0179d25-71a5-b47f-4272-49aa2a346b54-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>

On 11/29/2016 03:06 PM, Cyrille Pitchen wrote:
> Hi all,
> 
> +Marek
> 
> Le 29/11/2016 à 02:32, Florian Fainelli a écrit :
>> On 10/14/2016 06:17 AM, Cyrille Pitchen wrote:
>>> Le 13/10/2016 à 23:15, Kamal Dasu a écrit :
>>>> On Mon, Oct 10, 2016 at 4:29 AM, Cyrille Pitchen
>>>> <cyrille.pitchen-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org> wrote:
>>>>> Hi all,
>>>>>
>>>>>
>>>>> Le 10/10/2016 à 10:04, Florian Fainelli a écrit :
>>>>>> On 08/24/2016 03:04 PM, Kamal Dasu wrote:
>>>>>>> In m25p80_read() even though spi_flash_read() is supported
>>>>>>> by some drivers, under certain circumstances like unaligned
>>>>>>> buffer, address or address range limitations on certain SoCs
>>>>>>> let it fallback to core spi reads. Such drivers are expected
>>>>>>> to return -EAGAIN so that the m25p80_read() uses standard
>>>>>>> spi transfer.
>>>>>>>
>>>>>>> Signed-off-by: Kamal Dasu <kdasu.kdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>>>>>
>>>>>> MTD folks, any comments on this?
>>>>>>
>>>>>>> ---
>>>>>>>  drivers/mtd/devices/m25p80.c | 11 +++++++++--
>>>>>>>  1 file changed, 9 insertions(+), 2 deletions(-)
>>>>>>>
>>>>>>> diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
>>>>>>> index 9cf7fcd..77c2d2c 100644
>>>>>>> --- a/drivers/mtd/devices/m25p80.c
>>>>>>> +++ b/drivers/mtd/devices/m25p80.c
>>>>>>> @@ -155,9 +155,16 @@ static ssize_t m25p80_read(struct spi_nor *nor, loff_t from, size_t len,
>>>>>>>              msg.data_nbits = m25p80_rx_nbits(nor);
>>>>>>>
>>>>>>>              ret = spi_flash_read(spi, &msg);
>>>>>>> -            if (ret < 0)
>>>>>>> +
>>>>>>> +            if (ret >= 0)
>>>>>>> +                    return msg.retlen;
>>>>>>> +
>>>>>>> +            /*
>>>>>>> +             * some spi master drivers might need to fallback to
>>>>>>> +             * normal spi transfer
>>>>>>> +             */
>>>>>>> +            if (ret != -EAGAIN)
>>>>> I just wonder whether EINVAL would be a better choice.
>>>>
>>>>  spi_flash_read calls the down stream controller driver with all
>>>> params addresses however  accelerated transfer is not possible by the
>>>> controller due to alignment issues, it needs to indicate to m25p call
>>>> to try the normal transfer, hence use of EAGAIN seemed appropriate.
>>>>
>>>>
>>>
>>> Yes, I think I've understood the purpose of this patch. In the example you
>>> gave, the actual implementation of spi_flash_read() works fine with aligned
>>> addresses but doesn't support unaligned addresses. Hence, such unaligned
>>> addresses are invalid argument for spi_flash_read() and we should fall back
>>> to the legacy implementation of m25p80_read().
>>>
>>> My point is just that EINVAL clearly tells that the SPI controller driver
>>> implementation of spi_flash_read() doesn't support the given input
>>> parameters, here an unaligned address, whereas EAGAIN suggests that some
>>> hardware resource is temporarily unavailable and we could call spi_flash_read()
>>> again later. However, in this case, spi_flash_read() would still fail even if
>>> called later.
>>>
>>> That's why I've suggested EINVAL might have been a better choice than EAGAIN,
>>> but honestly it's not a big deal, only a detail. So if most people prefer to
>>> keep EAGAIN, I'm perfectly fine with it! :)
>>>
>>> I don't want my comment to delay the integration of this patch.
>>
>> So what are we going to do now, should Kamal resubmit and
>> s/EGAIN/EINVAL/ or is EAGAIN good enough? If EINVAL needs to be used,
>> which I agree with you seems like a valid error code to return, this
>> does imply changing the Broadcom QSPI driver though... so we have to
>> coordinate the two changes to be merged through the same cycle to avoid
>> regressions.
>>
> 
> Please replace the EAGAIN error code by EINVAL then I agree to merge this
> patch in the github spi-nor tree.
> 
> I know the EAGAIN error code has already been introduced in spi-bcm-qspi.c
> through the spi tree but since currently m25p280.c handles neither EAGAIN
> nor EINVAL as the returned code of spi_flash_read(), I guess no regression
> will be introduced. The feature will work as expected once both the m25p80.c
> and spi-bcm-qspi.c use the very same error code.
> 
> Marek, any comment?

I'm fine with this patch, but a patch for the broadcom controller would
be great.

-- 
Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2016-12-01 15:45 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-24 22:04 [PATCH v6, 0/8] Broadcom stb, and iProc SoC QSPI driver Kamal Dasu
     [not found] ` <1472076269-4731-1-git-send-email-kdasu.kdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-08-24 22:04   ` [PATCH v6, 1/8] spi: Broadcom BRCMSTB, NSP, NS2 SoC bindings Kamal Dasu
     [not found]     ` <1472076269-4731-2-git-send-email-kdasu.kdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-09-14 17:16       ` Applied "spi: Broadcom BRCMSTB, NSP, NS2 SoC bindings" to the spi tree Mark Brown
2016-08-24 22:04   ` [PATCH v6, 2/8] spi: bcm-qspi: Add Broadcom MSPI driver Kamal Dasu
2016-08-24 22:04   ` [PATCH v6, 3/8] spi: brcmstb-qspi: Broadcom settop platform driver Kamal Dasu
     [not found]     ` <1472076269-4731-4-git-send-email-kdasu.kdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-09-14 17:16       ` Applied "spi: brcmstb-qspi: Broadcom settop platform driver" to the spi tree Mark Brown
2016-08-24 22:04   ` [PATCH v6, 4/8] spi: bcm-qspi: Add BSPI spi-nor flash controller driver Kamal Dasu
     [not found]     ` <1472076269-4731-5-git-send-email-kdasu.kdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-09-14 17:16       ` Applied "spi: bcm-qspi: Add BSPI spi-nor flash controller driver" to the spi tree Mark Brown
2016-08-24 22:04   ` [PATCH v6, 5/8] mtd: m25p80: Let m25p80_read() fallback to spi transfer Kamal Dasu
2016-10-10  8:04     ` Florian Fainelli
     [not found]       ` <4b3b3d3e-b3f8-1d5b-65e3-0c37b6a29096-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-10-10  8:29         ` Cyrille Pitchen
2016-10-13 21:15           ` Kamal Dasu
2016-10-14 13:17             ` Cyrille Pitchen
     [not found]               ` <ae2c984e-2bcf-380e-a257-dbe786973af1-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2016-11-29  1:32                 ` Florian Fainelli
     [not found]                   ` <7697b2fa-4660-c791-e891-a22c8bc5390f-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-11-29 14:06                     ` Cyrille Pitchen
     [not found]                       ` <a0179d25-71a5-b47f-4272-49aa2a346b54-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2016-12-01 15:45                         ` Marek Vasut [this message]
     [not found]                           ` <3260e7e5-fcf1-599a-e7b4-fd7aaef5be2e-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-01-20 19:35                             ` Kamal Dasu
2016-08-24 22:04   ` [PATCH v6, 6/8] arm: dts: Add bcm-nsp and bcm958625k support Kamal Dasu
     [not found]     ` <1472076269-4731-7-git-send-email-kdasu.kdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-09-14 20:33       ` Florian Fainelli
2016-08-24 22:04   ` [PATCH v6, 7/8] arm64: dts: Add ns2 SoC support Kamal Dasu
     [not found]     ` <1472076269-4731-8-git-send-email-kdasu.kdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-09-14 20:34       ` Florian Fainelli
2016-08-24 22:04   ` [PATCH v6, 8/8] spi: iproc-qspi: Add Broadcom iProc SoCs support Kamal Dasu
     [not found]     ` <1472076269-4731-9-git-send-email-kdasu.kdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-09-15 17:34       ` Florian Fainelli
2016-09-25  5:59       ` Applied "spi: iproc-qspi: Add Broadcom iProc SoCs support" to the spi tree 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=3260e7e5-fcf1-599a-e7b4-fd7aaef5be2e@gmail.com \
    --to=marek.vasut-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=cyrille.pitchen-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org \
    --cc=f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=jon.mason-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
    --cc=kamal.dasu-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
    --cc=kdasu.kdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=marex-ynQEQJNshbs@public.gmane.org \
    --cc=vigneshr-l0cyMroinI0@public.gmane.org \
    --cc=yendapally.reddy-dY08KVG/lbpWk0Htik3J/w@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).