All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dfu: dfu_sf: Read the SPI flash in 16 MiB chunks
@ 2021-09-14  3:26 Marek Vasut
  2021-09-14  9:31 ` Lukasz Majewski
  2021-10-26 13:34 ` Tom Rini
  0 siblings, 2 replies; 5+ messages in thread
From: Marek Vasut @ 2021-09-14  3:26 UTC (permalink / raw)
  To: u-boot; +Cc: Marek Vasut, Lukasz Majewski

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 <marex@denx.de>
Cc: Lukasz Majewski <lukma@denx.de>
---
 drivers/dfu/dfu_sf.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/dfu/dfu_sf.c b/drivers/dfu/dfu_sf.c
index 7e64ab772f0..b72493ced86 100644
--- a/drivers/dfu/dfu_sf.c
+++ b/drivers/dfu/dfu_sf.c
@@ -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)
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] dfu: dfu_sf: Read the SPI flash in 16 MiB chunks
  2021-09-14  3:26 [PATCH] dfu: dfu_sf: Read the SPI flash in 16 MiB chunks Marek Vasut
@ 2021-09-14  9:31 ` Lukasz Majewski
  2021-10-22 22:34   ` Marek Vasut
  2021-10-26 13:34 ` Tom Rini
  1 sibling, 1 reply; 5+ messages in thread
From: Lukasz Majewski @ 2021-09-14  9:31 UTC (permalink / raw)
  To: Marek Vasut; +Cc: u-boot

[-- Attachment #1: Type: text/plain, Size: 1505 bytes --]

On Tue, 14 Sep 2021 05:26:51 +0200
Marek Vasut <marex@denx.de> 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 <marex@denx.de>
> Cc: Lukasz Majewski <lukma@denx.de>
> ---
>  drivers/dfu/dfu_sf.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dfu/dfu_sf.c b/drivers/dfu/dfu_sf.c
> index 7e64ab772f0..b72493ced86 100644
> --- a/drivers/dfu/dfu_sf.c
> +++ b/drivers/dfu/dfu_sf.c
> @@ -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)

Reviewed-by: Lukasz Majewski <lukma@denx.de>


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: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] dfu: dfu_sf: Read the SPI flash in 16 MiB chunks
  2021-09-14  9:31 ` Lukasz Majewski
@ 2021-10-22 22:34   ` Marek Vasut
  2021-10-25  6:30     ` Lukasz Majewski
  0 siblings, 1 reply; 5+ messages in thread
From: Marek Vasut @ 2021-10-22 22:34 UTC (permalink / raw)
  To: Lukasz Majewski; +Cc: u-boot, Tom Rini

On 9/14/21 11:31 AM, Lukasz Majewski wrote:
> On Tue, 14 Sep 2021 05:26:51 +0200
> Marek Vasut <marex@denx.de> 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 <marex@denx.de>
>> Cc: Lukasz Majewski <lukma@denx.de>
>> ---
>>   drivers/dfu/dfu_sf.c | 14 ++++++++++++--
>>   1 file changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/dfu/dfu_sf.c b/drivers/dfu/dfu_sf.c
>> index 7e64ab772f0..b72493ced86 100644
>> --- a/drivers/dfu/dfu_sf.c
>> +++ b/drivers/dfu/dfu_sf.c
>> @@ -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)
> 
> Reviewed-by: Lukasz Majewski <lukma@denx.de>

Is there going to be a PR with this or shall Tom pick it directly, since 
it is just one patch ?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] dfu: dfu_sf: Read the SPI flash in 16 MiB chunks
  2021-10-22 22:34   ` Marek Vasut
@ 2021-10-25  6:30     ` Lukasz Majewski
  0 siblings, 0 replies; 5+ messages in thread
From: Lukasz Majewski @ 2021-10-25  6:30 UTC (permalink / raw)
  To: Marek Vasut, Tom Rini; +Cc: u-boot

[-- Attachment #1: Type: text/plain, Size: 1842 bytes --]

Hi Marek,

> On 9/14/21 11:31 AM, Lukasz Majewski wrote:
> > On Tue, 14 Sep 2021 05:26:51 +0200
> > Marek Vasut <marex@denx.de> 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 <marex@denx.de>
> >> Cc: Lukasz Majewski <lukma@denx.de>
> >> ---
> >>   drivers/dfu/dfu_sf.c | 14 ++++++++++++--
> >>   1 file changed, 12 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/dfu/dfu_sf.c b/drivers/dfu/dfu_sf.c
> >> index 7e64ab772f0..b72493ced86 100644
> >> --- a/drivers/dfu/dfu_sf.c
> >> +++ b/drivers/dfu/dfu_sf.c
> >> @@ -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)  
> > 
> > Reviewed-by: Lukasz Majewski <lukma@denx.de>  
> 
> 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: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] dfu: dfu_sf: Read the SPI flash in 16 MiB chunks
  2021-09-14  3:26 [PATCH] dfu: dfu_sf: Read the SPI flash in 16 MiB chunks Marek Vasut
  2021-09-14  9:31 ` Lukasz Majewski
@ 2021-10-26 13:34 ` Tom Rini
  1 sibling, 0 replies; 5+ messages in thread
From: Tom Rini @ 2021-10-26 13:34 UTC (permalink / raw)
  To: Marek Vasut; +Cc: u-boot, Lukasz Majewski

[-- Attachment #1: Type: text/plain, Size: 381 bytes --]

On Tue, Sep 14, 2021 at 05:26:51AM +0200, Marek Vasut 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 <marex@denx.de>
> Cc: Lukasz Majewski <lukma@denx.de>
> Reviewed-by: Lukasz Majewski <lukma@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-10-26 13:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-14  3:26 [PATCH] dfu: dfu_sf: Read the SPI flash in 16 MiB chunks Marek Vasut
2021-09-14  9:31 ` Lukasz Majewski
2021-10-22 22:34   ` Marek Vasut
2021-10-25  6:30     ` Lukasz Majewski
2021-10-26 13:34 ` Tom Rini

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.