dfu: dfu_sf: Read the SPI flash in 16 MiB chunks
PATCH 1/1 dfu: dfu_sf: Read the SPI flash in 16 MiB chunks
Not all SPI flashes and controllers can do continuous transfer longer than 16 MiB, so perform the DFU read in 16 MiB chunks.
--- drivers/dfu/dfu_sf.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/dfu/dfu_sf.c +12 -2
@@ -24,8 +24,18 @@ static int dfu_get_medium_size_sf(struct dfu_entity *dfu, u64 *size)static int dfu_read_medium_sf (struct dfu_entity *dfu,u64 offset,void *buf,long *len) { -return spi_flash_read (dfu->data.sf.dev, dfu->data.sf.start + offset, - *len, buf); +long seglen = *len; +int ret; + +if (seglen > (16 <<20 )) + seglen = (16 <<20 ); + + ret =spi_flash_read (dfu->data.sf.dev, dfu->data.sf.start + offset, + seglen, buf); +if (!ret) + *len = seglen; + +return ret; }static u64 find_sector (struct dfu_entity *dfu,u64 start,u64 offset)
Signature · 1 line
2.33.0
Quoted 28 lines · On Tue, 14 Sep 2021 05:26:51 +0200 Marek Vasut <[email protected]> wrote:
Not all SPI flashes and controllers can do continuous transfer longer than 16 MiB, so perform the DFU read in 16 MiB chunks.
Signed-off-by Marek Vasut <[email protected]>Cc Lukasz Majewski <[email protected]>--- drivers/dfu/dfu_sf.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)drivers/dfu/dfu_sf.c +0
-0@@ -24,8 +24,18 @@ static int dfu_get_medium_size_sf(struct
dfu_entity*dfu, u64 *size) static intdfu_read_medium_sf(struct dfu_entity *dfu, u64 offset, void *buf, long *len)
{drivers/dfu/dfu_sf.c +0
-1- return spi_flash_read(dfu->data.sf.dev, dfu->data.sf.start +offset,
drivers/dfu/dfu_sf.c +7
-1- *len, buf); +long seglen = *len; +int ret; + +if (seglen > (16 <<20 )) + seglen = (16 <<20 ); + + ret = spi_flash_read(dfu->data.sf.dev, dfu->data.sf.start +offset,
drivers/dfu/dfu_sf.c static int dfu_get_medium_size_sf(struct dfu_entity *dfu, u64 *size) · line 41
Quoted 8 lines
drivers/dfu/dfu_sf.c +5
-0+ seglen, buf); +if (!ret) + *len = seglen; + +return ret; }static u64 find_sector (struct dfu_entity *dfu,u64 start,u64 offset)
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: [email protected]
Quoted 38 lines · Lukasz Majewski
Quoted 35 lines · On Tue, 14 Sep 2021 05:26:51 +0200 Marek Vasut <[email protected]> wrote:
Not all SPI flashes and controllers can do continuous transfer longer than 16 MiB, so perform the DFU read in 16 MiB chunks.
Signed-off-by Marek Vasut <[email protected]>Cc Lukasz Majewski <[email protected]>--- drivers/dfu/dfu_sf.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)drivers/dfu/dfu_sf.c +0
-0@@ -24,8 +24,18 @@ static int dfu_get_medium_size_sf(struct
dfu_entity*dfu, u64 *size) static intdfu_read_medium_sf(struct dfu_entity *dfu, u64 offset, void *buf, long *len)
{drivers/dfu/dfu_sf.c +0
-1- return spi_flash_read(dfu->data.sf.dev, dfu->data.sf.start +offset,
drivers/dfu/dfu_sf.c +7
-1- *len, buf); +long seglen = *len; +int ret; + +if (seglen > (16 <<20 )) + seglen = (16 <<20 ); + + ret = spi_flash_read(dfu->data.sf.dev, dfu->data.sf.start +offset,
drivers/dfu/dfu_sf.c +5
-0+ seglen, buf); +if (!ret) + *len = seglen; + +return ret; }
Quoted 3 lines
Quoted 1 line
static u64
find_sector(struct dfu_entity *dfu, u64 start, u64 offset)Reviewed-by Lukasz Majewski <[email protected]>
Is there going to be a PR with this or shall Tom pick it directly, since it is just one patch ?
Hi Marek,
Quoted 39 lines · Lukasz Majewski
Quoted 38 lines
Quoted 35 lines · On Tue, 14 Sep 2021 05:26:51 +0200 Marek Vasut <[email protected]> wrote:
Not all SPI flashes and controllers can do continuous transfer longer than 16 MiB, so perform the DFU read in 16 MiB chunks.
Signed-off-by Marek Vasut <[email protected]>Cc Lukasz Majewski <[email protected]>--- drivers/dfu/dfu_sf.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)drivers/dfu/dfu_sf.c +0
-0@@ -24,8 +24,18 @@ static int dfu_get_medium_size_sf(struct
dfu_entity*dfu, u64 *size) static intdfu_read_medium_sf(struct dfu_entity *dfu, u64 offset, void *buf, long *len)
{drivers/dfu/dfu_sf.c +0
-1- return spi_flash_read(dfu->data.sf.dev,
dfu->data.sf.start+ offset,drivers/dfu/dfu_sf.c +13
-1- *len, buf); +long seglen = *len; +int ret; + +if (seglen > (16 <<20 )) + seglen = (16 <<20 ); + + ret =spi_flash_read (dfu->data.sf.dev, dfu->data.sf.start + offset, + seglen, buf); +if (!ret) + *len = seglen; + +return ret; }
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
static u64 find_sector(struct
dfu_entity*dfu, u64 start, u64
offset)Reviewed-by Lukasz Majewski <[email protected]>Is there going to be a PR with this or shall Tom pick it directly, since it is just one patch ?
Please, Tom pick it up...
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: [email protected]
Quoted 6 lines · Marek Vasut
Not all SPI flashes and controllers can do continuous transfer longer than 16 MiB, so perform the DFU read in 16 MiB chunks.
Signed-off-by Marek Vasut <[email protected]>Cc Lukasz Majewski <[email protected]>Reviewed-by Lukasz Majewski <[email protected]>
Applied to u-boot/master, thanks!
Signature · 1 line
Tom