* fsl-espi, m25p80 and max_transfer_size / max_message_size
@ 2016-11-14 14:22 Michael Walle
[not found] ` <17913d2dea0200f818af5f42a0b2ed42-QKn5cuLxLXY@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Michael Walle @ 2016-11-14 14:22 UTC (permalink / raw)
To: Heiner Kallweit, Mark Brown, Michal Suchanek
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA, linux-mtd-u79uwXL29TY76Z2rM5mHXA
Hi,
since commit 02a595d5d6e4 (spi: fsl-espi: eliminate spi nor flash read
loop) the fsl-espi is (partly?) broken. Reading 64k from the flash
results in the following error:
fsl_espi ffe110000.spi: message too long, size is 65540 bytes
spi_master spi32766: failed to transfer one message from queue
We are using the m25p80 driver which checks the max_transfer_size. The
fsl-espi driver sets the max_message_size to 64k. As far as I understand
it, a message can contain multiple transfers. The m25p80 uses two
transfers (one 4 byte and one with max_transfer_size, that is 64k) and
thus the message has a total length of 65540 bytes which is too long for
the driver.
I didn't find where the max_message_size is checked and I also don't
know which part is resposible to handle the correct sizes. The m25p80
driver? Should it use spi_max_message_size() instead of
spi_max_transfer_size() ?
For example:
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -172,7 +172,7 @@ static ssize_t m25p80_read(struct spi_nor *nor,
loff_t from, size_t len,
t[1].rx_buf = buf;
t[1].rx_nbits = m25p80_rx_nbits(nor);
- t[1].len = min(len, spi_max_transfer_size(spi) - t[0].len);
+ t[1].len = min(len, spi_max_message_size(spi) - t[0].len);
spi_message_add_tail(&t[1], &m);
ret = spi_sync(spi, &m);
-michael
--
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: fsl-espi, m25p80 and max_transfer_size / max_message_size
[not found] ` <17913d2dea0200f818af5f42a0b2ed42-QKn5cuLxLXY@public.gmane.org>
@ 2016-11-14 19:06 ` Heiner Kallweit
[not found] ` <158a7129-52ca-79b3-69f9-d6de25483e01-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-12-23 15:09 ` Cyrille Pitchen
1 sibling, 1 reply; 5+ messages in thread
From: Heiner Kallweit @ 2016-11-14 19:06 UTC (permalink / raw)
To: Michael Walle, Brian Norris
Cc: Mark Brown, Michal Suchanek, linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-mtd-u79uwXL29TY76Z2rM5mHXA
Am 14.11.2016 um 15:22 schrieb Michael Walle:
> Hi,
>
> since commit 02a595d5d6e4 (spi: fsl-espi: eliminate spi nor flash read loop) the fsl-espi is (partly?) broken. Reading 64k from the flash results in the following error:
> fsl_espi ffe110000.spi: message too long, size is 65540 bytes
> spi_master spi32766: failed to transfer one message from queue
>
> We are using the m25p80 driver which checks the max_transfer_size. The fsl-espi driver sets the max_message_size to 64k. As far as I understand it, a message can contain multiple transfers. The m25p80 uses two transfers (one 4 byte and one with max_transfer_size, that is 64k) and thus the message has a total length of 65540 bytes which is too long for the driver.
>
> I didn't find where the max_message_size is checked and I also don't know which part is resposible to handle the correct sizes. The m25p80 driver? Should it use spi_max_message_size() instead of spi_max_transfer_size() ?
>
Your mail actually doesn't come as a surprise. The patch addressing this scenario is waiting to be applied.
See here: https://www.spinics.net/lists/linux-spi/msg08844.html
Rgds, Heiner
> For example:
> --- a/drivers/mtd/devices/m25p80.c
> +++ b/drivers/mtd/devices/m25p80.c
> @@ -172,7 +172,7 @@ static ssize_t m25p80_read(struct spi_nor *nor, loff_t from, size_t len,
>
> t[1].rx_buf = buf;
> t[1].rx_nbits = m25p80_rx_nbits(nor);
> - t[1].len = min(len, spi_max_transfer_size(spi) - t[0].len);
> + t[1].len = min(len, spi_max_message_size(spi) - t[0].len);
> spi_message_add_tail(&t[1], &m);
>
> ret = spi_sync(spi, &m);
>
> -michael
>
--
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: fsl-espi, m25p80 and max_transfer_size / max_message_size
[not found] ` <158a7129-52ca-79b3-69f9-d6de25483e01-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2016-11-15 10:16 ` Michael Walle
2016-12-21 6:35 ` Heiner Kallweit
1 sibling, 0 replies; 5+ messages in thread
From: Michael Walle @ 2016-11-15 10:16 UTC (permalink / raw)
To: Heiner Kallweit; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA
Am 2016-11-14 20:06, schrieb Heiner Kallweit:
> Am 14.11.2016 um 15:22 schrieb Michael Walle:
>> Hi,
>>
>> since commit 02a595d5d6e4 (spi: fsl-espi: eliminate spi nor flash read
>> loop) the fsl-espi is (partly?) broken. Reading 64k from the flash
>> results in the following error:
>> fsl_espi ffe110000.spi: message too long, size is 65540 bytes
>> spi_master spi32766: failed to transfer one message from queue
>>
>> We are using the m25p80 driver which checks the max_transfer_size. The
>> fsl-espi driver sets the max_message_size to 64k. As far as I
>> understand it, a message can contain multiple transfers. The m25p80
>> uses two transfers (one 4 byte and one with max_transfer_size, that is
>> 64k) and thus the message has a total length of 65540 bytes which is
>> too long for the driver.
>>
>> I didn't find where the max_message_size is checked and I also don't
>> know which part is resposible to handle the correct sizes. The m25p80
>> driver? Should it use spi_max_message_size() instead of
>> spi_max_transfer_size() ?
>>
> Your mail actually doesn't come as a surprise. The patch addressing
> this scenario is waiting to be applied.
> See here: https://www.spinics.net/lists/linux-spi/msg08844.html
>
> Rgds, Heiner
Thanks.
-michael
--
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: fsl-espi, m25p80 and max_transfer_size / max_message_size
[not found] ` <158a7129-52ca-79b3-69f9-d6de25483e01-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-11-15 10:16 ` Michael Walle
@ 2016-12-21 6:35 ` Heiner Kallweit
1 sibling, 0 replies; 5+ messages in thread
From: Heiner Kallweit @ 2016-12-21 6:35 UTC (permalink / raw)
To: Marek Vasut, Cyrille Pitchen
Cc: Michael Walle, linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-mtd-u79uwXL29TY76Z2rM5mHXA
Am 14.11.2016 um 20:06 schrieb Heiner Kallweit:
> Am 14.11.2016 um 15:22 schrieb Michael Walle:
>> Hi,
>>
>> since commit 02a595d5d6e4 (spi: fsl-espi: eliminate spi nor flash read loop) the fsl-espi is (partly?) broken. Reading 64k from the flash results in the following error:
>> fsl_espi ffe110000.spi: message too long, size is 65540 bytes
>> spi_master spi32766: failed to transfer one message from queue
>>
>> We are using the m25p80 driver which checks the max_transfer_size. The fsl-espi driver sets the max_message_size to 64k. As far as I understand it, a message can contain multiple transfers. The m25p80 uses two transfers (one 4 byte and one with max_transfer_size, that is 64k) and thus the message has a total length of 65540 bytes which is too long for the driver.
>>
>> I didn't find where the max_message_size is checked and I also don't know which part is resposible to handle the correct sizes. The m25p80 driver? Should it use spi_max_message_size() instead of spi_max_transfer_size() ?
>>
> Your mail actually doesn't come as a surprise. The patch addressing this scenario is waiting to be applied.
> See here: https://www.spinics.net/lists/linux-spi/msg08844.html
>
> Rgds, Heiner
>
This issue is still open. Can we get the patch at least into 4.10?
--
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: fsl-espi, m25p80 and max_transfer_size / max_message_size
[not found] ` <17913d2dea0200f818af5f42a0b2ed42-QKn5cuLxLXY@public.gmane.org>
2016-11-14 19:06 ` Heiner Kallweit
@ 2016-12-23 15:09 ` Cyrille Pitchen
1 sibling, 0 replies; 5+ messages in thread
From: Cyrille Pitchen @ 2016-12-23 15:09 UTC (permalink / raw)
To: Michael Walle, Heiner Kallweit, Mark Brown, Michal Suchanek
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA, linux-mtd-u79uwXL29TY76Z2rM5mHXA
Hi all,
Le 14/11/2016 à 15:22, Michael Walle a écrit :
> Hi,
>
> since commit 02a595d5d6e4 (spi: fsl-espi: eliminate spi nor flash read
> loop) the fsl-espi is (partly?) broken. Reading 64k from the flash results
> in the following error:
> fsl_espi ffe110000.spi: message too long, size is 65540 bytes
> spi_master spi32766: failed to transfer one message from queue
>
> We are using the m25p80 driver which checks the max_transfer_size. The
> fsl-espi driver sets the max_message_size to 64k. As far as I understand
> it, a message can contain multiple transfers. The m25p80 uses two transfers
> (one 4 byte and one with max_transfer_size, that is 64k) and thus the
> message has a total length of 65540 bytes which is too long for the driver.
>
> I didn't find where the max_message_size is checked and I also don't know
> which part is resposible to handle the correct sizes. The m25p80 driver?
> Should it use spi_max_message_size() instead of spi_max_transfer_size() ?
>
> For example:
> --- a/drivers/mtd/devices/m25p80.c
> +++ b/drivers/mtd/devices/m25p80.c
> @@ -172,7 +172,7 @@ static ssize_t m25p80_read(struct spi_nor *nor, loff_t
> from, size_t len,
>
> t[1].rx_buf = buf;
> t[1].rx_nbits = m25p80_rx_nbits(nor);
> - t[1].len = min(len, spi_max_transfer_size(spi) - t[0].len);
> + t[1].len = min(len, spi_max_message_size(spi) - t[0].len);
> spi_message_add_tail(&t[1], &m);
>
extracted from include/linux/spi/spi:h:
static inline size_t
spi_max_transfer_size(struct spi_device *spi)
{
struct spi_master *master = spi->master;
size_t tr_max = SIZE_MAX;
size_t msg_max = spi_max_message_size(spi);
if (master->max_transfer_size)
tr_max = master->max_transfer_size(spi);
/* transfer size limit must not be greater than messsage size limit */
return min(tr_max, msg_max);
}
So replacing spi_max_transfer_size(spi) by spi_max_transfer_size(spi) is
not a good idea: the max transfer size is always lower than or equal to the
max message size.
However taking the min between:
1/ len
2/ spi_max_transfer_size(spi)
3/ spi_max_message_size(spi) - t[0].len /* the remaining msg size */
makes sense. Hence https://www.spinics.net/lists/linux-spi/msg08844.html
seems to be the right solution.
Best regards,
Cyrille
> ret = spi_sync(spi, &m);
>
> -michael
> --
> 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
>
--
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-12-23 15:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-14 14:22 fsl-espi, m25p80 and max_transfer_size / max_message_size Michael Walle
[not found] ` <17913d2dea0200f818af5f42a0b2ed42-QKn5cuLxLXY@public.gmane.org>
2016-11-14 19:06 ` Heiner Kallweit
[not found] ` <158a7129-52ca-79b3-69f9-d6de25483e01-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-11-15 10:16 ` Michael Walle
2016-12-21 6:35 ` Heiner Kallweit
2016-12-23 15:09 ` Cyrille Pitchen
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).