diff mbox series

[LEDE-DEV] ar71xx: fix flash fast read for flash chips > 16 MB

Message ID 20180222191323.9101-2-dontmind@freeshell.org
State Rejected
Headers show
Series [LEDE-DEV] ar71xx: fix flash fast read for flash chips > 16 MB | expand

Commit Message

Christian Beier Feb. 22, 2018, 7:13 p.m. UTC
From: Christian Beier <cb@shoutrlabs.com>

SPI fast flash read only is supported on devices using 3-byte-addressing.
As chips bigger than 16MB use 4-byte-addressing, reading fails with
-EOPNOTSUPP.

This commit sets the fast flash read callback spi->master->spi_flash_read
to NULL for chips that use 4-byte-addressing.

Fixes https://bugs.openwrt.org/index.php?do=details&task_id=1376.

Signed-off-by: Christian Beier <cb@shoutrlabs.com>
---
 ...-m25p80-disable-fast-flash-read-for-4b-addressing.patch | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
 create mode 100644 target/linux/ar71xx/patches-4.9/415-mtd-m25p80-disable-fast-flash-read-for-4b-addressing.patch

Comments

Rafał Miłecki Feb. 23, 2018, 8:40 a.m. UTC | #1
On 22 February 2018 at 20:13, Christian Beier <dontmind@freeshell.org> wrote:
> From: Christian Beier <cb@shoutrlabs.com>
>
> SPI fast flash read only is supported on devices using 3-byte-addressing.
> As chips bigger than 16MB use 4-byte-addressing, reading fails with
> -EOPNOTSUPP.
>
> This commit sets the fast flash read callback spi->master->spi_flash_read
> to NULL for chips that use 4-byte-addressing.
>
> Fixes https://bugs.openwrt.org/index.php?do=details&task_id=1376.
>
> Signed-off-by: Christian Beier <cb@shoutrlabs.com>

Can you send this patch to the MTD mailing list, please?

Why adding it to the ar71xx target only?
Felix Fietkau Feb. 23, 2018, 8:50 a.m. UTC | #2
On 2018-02-23 09:40, Rafał Miłecki wrote:
> On 22 February 2018 at 20:13, Christian Beier <dontmind@freeshell.org> wrote:
>> From: Christian Beier <cb@shoutrlabs.com>
>>
>> SPI fast flash read only is supported on devices using 3-byte-addressing.
>> As chips bigger than 16MB use 4-byte-addressing, reading fails with
>> -EOPNOTSUPP.
>>
>> This commit sets the fast flash read callback spi->master->spi_flash_read
>> to NULL for chips that use 4-byte-addressing.
>>
>> Fixes https://bugs.openwrt.org/index.php?do=details&task_id=1376.
>>
>> Signed-off-by: Christian Beier <cb@shoutrlabs.com>
> 
> Can you send this patch to the MTD mailing list, please?
> 
> Why adding it to the ar71xx target only?
I think this is the wrong place to fix it, the ath79 spi driver should
be changed instead.

- Felix
Christian Beier Feb. 23, 2018, 3:22 p.m. UTC | #3
Am Fri, 23 Feb 2018 09:40:54 +0100
schrieb Rafał Miłecki <zajec5@gmail.com>:

> On 22 February 2018 at 20:13, Christian Beier <dontmind@freeshell.org> wrote:
> > From: Christian Beier <cb@shoutrlabs.com>
> >
> > SPI fast flash read only is supported on devices using 3-byte-addressing.
> > As chips bigger than 16MB use 4-byte-addressing, reading fails with
> > -EOPNOTSUPP.
> >
> > This commit sets the fast flash read callback spi->master->spi_flash_read
> > to NULL for chips that use 4-byte-addressing.
> >
> > Fixes https://bugs.openwrt.org/index.php?do=details&task_id=1376.
> >
> > Signed-off-by: Christian Beier <cb@shoutrlabs.com>  
> 
> Can you send this patch to the MTD mailing list, please?

The patch fixes/works around something added by OpenWRT, so the MTD mailing
list probably isn't the right place? I am referring to
https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=target/linux/ar71xx/patches-4.9/461-spi-ath79-add-fast-flash-read.patch
which added in support for spi_flash_read() in the first place. That code is not
present in mainline Linux AFAICT.

> 
> Why adding it to the ar71xx target only?

Mainly because mentioned 461-spi-ath79-add-fast-flash-read.patch exists in the
ar71xx subdir.
Christian Beier Feb. 23, 2018, 3:59 p.m. UTC | #4
Am Fri, 23 Feb 2018 09:50:35 +0100
schrieb Felix Fietkau <nbd@nbd.name>:

> On 2018-02-23 09:40, Rafał Miłecki wrote:
> > On 22 February 2018 at 20:13, Christian Beier <dontmind@freeshell.org>
> > wrote:  
> >> From: Christian Beier <cb@shoutrlabs.com>
> >>
> >> SPI fast flash read only is supported on devices using 3-byte-addressing.
> >> As chips bigger than 16MB use 4-byte-addressing, reading fails with
> >> -EOPNOTSUPP.
> >>
> >> This commit sets the fast flash read callback spi->master->spi_flash_read
> >> to NULL for chips that use 4-byte-addressing.
> >>
> >> Fixes https://bugs.openwrt.org/index.php?do=details&task_id=1376.
> >>
> >> Signed-off-by: Christian Beier <cb@shoutrlabs.com>  
> > 
> > Can you send this patch to the MTD mailing list, please?
> > 
> > Why adding it to the ar71xx target only?  
> I think this is the wrong place to fix it, the ath79 spi driver should
> be changed instead.

Yeah, OK. That's actually what I asked in the initial mail of this thread ;-).
I just don't know how to access any address width or size or sector size/count
info from within spi-ath79.c (as it seems to be on a higher layer than
m25p80.c/spi-nor.c).

Can you provide me with some hints on how this could be done, Felix? I'd be
happy to whip up another patch then.

Extending spi_flash_read() to work with 4-byte addressing is beyond my
knowledge of kernel intrinsics :-/

Cheers,

   Christian
Felix Fietkau Feb. 23, 2018, 4:35 p.m. UTC | #5
On 2018-02-23 16:59, Christian Beier wrote:
> Am Fri, 23 Feb 2018 09:50:35 +0100
> schrieb Felix Fietkau <nbd@nbd.name>:
> 
>> On 2018-02-23 09:40, Rafał Miłecki wrote:
>> > On 22 February 2018 at 20:13, Christian Beier <dontmind@freeshell.org>
>> > wrote:  
>> >> From: Christian Beier <cb@shoutrlabs.com>
>> >>
>> >> SPI fast flash read only is supported on devices using 3-byte-addressing.
>> >> As chips bigger than 16MB use 4-byte-addressing, reading fails with
>> >> -EOPNOTSUPP.
>> >>
>> >> This commit sets the fast flash read callback spi->master->spi_flash_read
>> >> to NULL for chips that use 4-byte-addressing.
>> >>
>> >> Fixes https://bugs.openwrt.org/index.php?do=details&task_id=1376.
>> >>
>> >> Signed-off-by: Christian Beier <cb@shoutrlabs.com>  
>> > 
>> > Can you send this patch to the MTD mailing list, please?
>> > 
>> > Why adding it to the ar71xx target only?  
>> I think this is the wrong place to fix it, the ath79 spi driver should
>> be changed instead.
> 
> Yeah, OK. That's actually what I asked in the initial mail of this thread ;-).
> I just don't know how to access any address width or size or sector size/count
> info from within spi-ath79.c (as it seems to be on a higher layer than
> m25p80.c/spi-nor.c).
> 
> Can you provide me with some hints on how this could be done, Felix? I'd be
> happy to whip up another patch then.
> 
> Extending spi_flash_read() to work with 4-byte addressing is beyond my
> knowledge of kernel intrinsics :-/
I've prepared a patch (which I intend to send upstream once it's tested)
and put it in my staging tree:
https://git.openwrt.org/e4d8c2892b9708c2719dcd96c7d92c3cac07eb39
Please test it.

Thanks,

- Felix
Christian Beier Feb. 26, 2018, 2:57 p.m. UTC | #6
Am Fri, 23 Feb 2018 17:35:17 +0100
schrieb Felix Fietkau <nbd@nbd.name>:

> On 2018-02-23 16:59, Christian Beier wrote:
> > Am Fri, 23 Feb 2018 09:50:35 +0100
> > schrieb Felix Fietkau <nbd@nbd.name>:
> >   
> >> On 2018-02-23 09:40, Rafał Miłecki wrote:  
> >> > On 22 February 2018 at 20:13, Christian Beier <dontmind@freeshell.org>
> >> > wrote:    
> >> >> From: Christian Beier <cb@shoutrlabs.com>
> >> >>
> >> >> SPI fast flash read only is supported on devices using
> >> >> 3-byte-addressing. As chips bigger than 16MB use 4-byte-addressing,
> >> >> reading fails with -EOPNOTSUPP.
> >> >>
> >> >> This commit sets the fast flash read callback
> >> >> spi->master->spi_flash_read to NULL for chips that use
> >> >> 4-byte-addressing.
> >> >>
> >> >> Fixes https://bugs.openwrt.org/index.php?do=details&task_id=1376.
> >> >>
> >> >> Signed-off-by: Christian Beier <cb@shoutrlabs.com>    
> >> > 
> >> > Can you send this patch to the MTD mailing list, please?
> >> > 
> >> > Why adding it to the ar71xx target only?    
> >> I think this is the wrong place to fix it, the ath79 spi driver should
> >> be changed instead.  
> > 
> > Yeah, OK. That's actually what I asked in the initial mail of this
> > thread ;-). I just don't know how to access any address width or size or
> > sector size/count info from within spi-ath79.c (as it seems to be on a
> > higher layer than m25p80.c/spi-nor.c).
> > 
> > Can you provide me with some hints on how this could be done, Felix? I'd be
> > happy to whip up another patch then.
> > 
> > Extending spi_flash_read() to work with 4-byte addressing is beyond my
> > knowledge of kernel intrinsics :-/  
> I've prepared a patch (which I intend to send upstream once it's tested)
> and put it in my staging tree:
> https://git.openwrt.org/e4d8c2892b9708c2719dcd96c7d92c3cac07eb39
> Please test it.
 
Works!

Thanks,

   Christian
diff mbox series

Patch

diff --git a/target/linux/ar71xx/patches-4.9/415-mtd-m25p80-disable-fast-flash-read-for-4b-addressing.patch b/target/linux/ar71xx/patches-4.9/415-mtd-m25p80-disable-fast-flash-read-for-4b-addressing.patch
new file mode 100644
index 0000000000..048f50cbcd
--- /dev/null
+++ b/target/linux/ar71xx/patches-4.9/415-mtd-m25p80-disable-fast-flash-read-for-4b-addressing.patch
@@ -0,0 +1,14 @@ 
+diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
+index 1343e5d..1e89067 100644
+--- a/drivers/mtd/devices/m25p80.c
++++ b/drivers/mtd/devices/m25p80.c
+@@ -245,6 +245,9 @@ static int m25p_probe(struct spi_device *spi)
+ 	if (ret)
+ 		return ret;
+ 
++	if (nor->addr_width > 3)
++		spi->master->spi_flash_read = NULL;
++
+ 	return mtd_device_parse_register(&nor->mtd,
+ 			data ? data->part_probes : NULL,
+ 			&ppdata,