All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dfu: dfu_mtd: set max_buf_size to erasesize also for NOR devices
@ 2021-03-04 16:47 Patrick Delaunay
  2021-04-20 10:24 ` [Uboot-stm32] " Patrice CHOTARD
  0 siblings, 1 reply; 5+ messages in thread
From: Patrick Delaunay @ 2021-03-04 16:47 UTC (permalink / raw)
  To: u-boot

For NOR devices the logical DFU buffer size is the sector_size,
as it is done in dfu_sf.c or in spi/sf_mtd.c
(sf_mtd_info.erasesize = flash->sector_size)

For NAND the DFU size was already limited to erasesize as
has_pages = true.

So the mtd dfu backend can use this erasesize for all the MTD devices,
NOR and NAND with dfu->max_buf_size = mtd->erasesize

This difference was initially copied from MTD command, where
data is fully available in RAM without size limitation.

This patch avoids to have many sector write in dfu_mtd.c at the end
of the DFU transfer and avoids issues with USB timeout or WATCHDOG.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
---

 drivers/dfu/dfu_mtd.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/dfu/dfu_mtd.c b/drivers/dfu/dfu_mtd.c
index ca67585a7e..7efb3cbd79 100644
--- a/drivers/dfu/dfu_mtd.c
+++ b/drivers/dfu/dfu_mtd.c
@@ -252,7 +252,6 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char *s)
 {
 	char *st;
 	struct mtd_info *mtd;
-	bool has_pages;
 	int ret, part;
 
 	mtd = get_mtd_device_nm(devstr);
@@ -262,9 +261,7 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char *s)
 
 	dfu->dev_type = DFU_DEV_MTD;
 	dfu->data.mtd.info = mtd;
-
-	has_pages = mtd->type == MTD_NANDFLASH || mtd->type == MTD_MLCNANDFLASH;
-	dfu->max_buf_size = has_pages ? mtd->erasesize : 0;
+	dfu->max_buf_size = mtd->erasesize;
 
 	st = strsep(&s, " ");
 	if (!strcmp(st, "raw")) {
-- 
2.17.1

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

* [Uboot-stm32] [PATCH] dfu: dfu_mtd: set max_buf_size to erasesize also for NOR devices
  2021-03-04 16:47 [PATCH] dfu: dfu_mtd: set max_buf_size to erasesize also for NOR devices Patrick Delaunay
@ 2021-04-20 10:24 ` Patrice CHOTARD
  2021-06-04 16:59   ` Patrick DELAUNAY
  2021-06-18  8:10   ` Patrice CHOTARD
  0 siblings, 2 replies; 5+ messages in thread
From: Patrice CHOTARD @ 2021-04-20 10:24 UTC (permalink / raw)
  To: u-boot

Hi Patrick

On 3/4/21 5:47 PM, Patrick Delaunay wrote:
> For NOR devices the logical DFU buffer size is the sector_size,
> as it is done in dfu_sf.c or in spi/sf_mtd.c
> (sf_mtd_info.erasesize = flash->sector_size)
> 
> For NAND the DFU size was already limited to erasesize as
> has_pages = true.
> 
> So the mtd dfu backend can use this erasesize for all the MTD devices,
> NOR and NAND with dfu->max_buf_size = mtd->erasesize
> 
> This difference was initially copied from MTD command, where
> data is fully available in RAM without size limitation.
> 
> This patch avoids to have many sector write in dfu_mtd.c at the end
> of the DFU transfer and avoids issues with USB timeout or WATCHDOG.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> ---
> 
>  drivers/dfu/dfu_mtd.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/dfu/dfu_mtd.c b/drivers/dfu/dfu_mtd.c
> index ca67585a7e..7efb3cbd79 100644
> --- a/drivers/dfu/dfu_mtd.c
> +++ b/drivers/dfu/dfu_mtd.c
> @@ -252,7 +252,6 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char *s)
>  {
>  	char *st;
>  	struct mtd_info *mtd;
> -	bool has_pages;
>  	int ret, part;
>  
>  	mtd = get_mtd_device_nm(devstr);
> @@ -262,9 +261,7 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char *s)
>  
>  	dfu->dev_type = DFU_DEV_MTD;
>  	dfu->data.mtd.info = mtd;
> -
> -	has_pages = mtd->type == MTD_NANDFLASH || mtd->type == MTD_MLCNANDFLASH;
> -	dfu->max_buf_size = has_pages ? mtd->erasesize : 0;
> +	dfu->max_buf_size = mtd->erasesize;
>  
>  	st = strsep(&s, " ");
>  	if (!strcmp(st, "raw")) {
> 

Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>

Thanks

Patrice

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

* Re: [Uboot-stm32] [PATCH] dfu: dfu_mtd: set max_buf_size to erasesize also for NOR devices
  2021-04-20 10:24 ` [Uboot-stm32] " Patrice CHOTARD
@ 2021-06-04 16:59   ` Patrick DELAUNAY
  2021-06-07  8:39     ` Lukasz Majewski
  2021-06-18  8:10   ` Patrice CHOTARD
  1 sibling, 1 reply; 5+ messages in thread
From: Patrick DELAUNAY @ 2021-06-04 16:59 UTC (permalink / raw)
  To: Patrice CHOTARD, u-boot, Lukasz Majewski; +Cc: U-Boot STM32, Marek Vasut

Thanks Patrice,

On 4/20/21 12:24 PM, Patrice CHOTARD wrote:
> Hi Patrick
>
> On 3/4/21 5:47 PM, Patrick Delaunay wrote:
>> For NOR devices the logical DFU buffer size is the sector_size,
>> as it is done in dfu_sf.c or in spi/sf_mtd.c
>> (sf_mtd_info.erasesize = flash->sector_size)
>>
>> For NAND the DFU size was already limited to erasesize as
>> has_pages = true.
>>
>> So the mtd dfu backend can use this erasesize for all the MTD devices,
>> NOR and NAND with dfu->max_buf_size = mtd->erasesize
>>
>> This difference was initially copied from MTD command, where
>> data is fully available in RAM without size limitation.
>>
>> This patch avoids to have many sector write in dfu_mtd.c at the end
>> of the DFU transfer and avoids issues with USB timeout or WATCHDOG.
>>
>> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
>> ---
>>
>>   drivers/dfu/dfu_mtd.c | 5 +----
>>   1 file changed, 1 insertion(+), 4 deletions(-)
>>
>> diff --git a/drivers/dfu/dfu_mtd.c b/drivers/dfu/dfu_mtd.c
>> index ca67585a7e..7efb3cbd79 100644
>> --- a/drivers/dfu/dfu_mtd.c
>> +++ b/drivers/dfu/dfu_mtd.c
>> @@ -252,7 +252,6 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char *s)
>>   {
>>   	char *st;
>>   	struct mtd_info *mtd;
>> -	bool has_pages;
>>   	int ret, part;
>>   
>>   	mtd = get_mtd_device_nm(devstr);
>> @@ -262,9 +261,7 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char *s)
>>   
>>   	dfu->dev_type = DFU_DEV_MTD;
>>   	dfu->data.mtd.info = mtd;
>> -
>> -	has_pages = mtd->type == MTD_NANDFLASH || mtd->type == MTD_MLCNANDFLASH;
>> -	dfu->max_buf_size = has_pages ? mtd->erasesize : 0;
>> +	dfu->max_buf_size = mtd->erasesize;
>>   
>>   	st = strsep(&s, " ");
>>   	if (!strcmp(st, "raw")) {
>>
> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
>
> Thanks
>
> Patrice


Lukasz, any remarks on your side?


Can I take this patch in my first STM32 pull request for v2020.10 ?

or a PR is already planed on your side ?

http://patchwork.ozlabs.org/project/uboot/patch/20210304174748.1.I1d824180669d63e22275f082e7ac0fe50c2b8646@changeid/


Regards

Patrick


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

* Re: [Uboot-stm32] [PATCH] dfu: dfu_mtd: set max_buf_size to erasesize also for NOR devices
  2021-06-04 16:59   ` Patrick DELAUNAY
@ 2021-06-07  8:39     ` Lukasz Majewski
  0 siblings, 0 replies; 5+ messages in thread
From: Lukasz Majewski @ 2021-06-07  8:39 UTC (permalink / raw)
  To: Patrick DELAUNAY; +Cc: Patrice CHOTARD, u-boot, U-Boot STM32, Marek Vasut

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

Hi Patrick,

> Thanks Patrice,
> 
> On 4/20/21 12:24 PM, Patrice CHOTARD wrote:
> > Hi Patrick
> >
> > On 3/4/21 5:47 PM, Patrick Delaunay wrote:  
> >> For NOR devices the logical DFU buffer size is the sector_size,
> >> as it is done in dfu_sf.c or in spi/sf_mtd.c
> >> (sf_mtd_info.erasesize = flash->sector_size)
> >>
> >> For NAND the DFU size was already limited to erasesize as
> >> has_pages = true.
> >>
> >> So the mtd dfu backend can use this erasesize for all the MTD
> >> devices, NOR and NAND with dfu->max_buf_size = mtd->erasesize
> >>
> >> This difference was initially copied from MTD command, where
> >> data is fully available in RAM without size limitation.
> >>
> >> This patch avoids to have many sector write in dfu_mtd.c at the end
> >> of the DFU transfer and avoids issues with USB timeout or WATCHDOG.
> >>
> >> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> >> ---
> >>
> >>   drivers/dfu/dfu_mtd.c | 5 +----
> >>   1 file changed, 1 insertion(+), 4 deletions(-)
> >>
> >> diff --git a/drivers/dfu/dfu_mtd.c b/drivers/dfu/dfu_mtd.c
> >> index ca67585a7e..7efb3cbd79 100644
> >> --- a/drivers/dfu/dfu_mtd.c
> >> +++ b/drivers/dfu/dfu_mtd.c
> >> @@ -252,7 +252,6 @@ int dfu_fill_entity_mtd(struct dfu_entity
> >> *dfu, char *devstr, char *s) {
> >>   	char *st;
> >>   	struct mtd_info *mtd;
> >> -	bool has_pages;
> >>   	int ret, part;
> >>   
> >>   	mtd = get_mtd_device_nm(devstr);
> >> @@ -262,9 +261,7 @@ int dfu_fill_entity_mtd(struct dfu_entity
> >> *dfu, char *devstr, char *s) 
> >>   	dfu->dev_type = DFU_DEV_MTD;
> >>   	dfu->data.mtd.info = mtd;
> >> -
> >> -	has_pages = mtd->type == MTD_NANDFLASH || mtd->type ==
> >> MTD_MLCNANDFLASH;
> >> -	dfu->max_buf_size = has_pages ? mtd->erasesize : 0;
> >> +	dfu->max_buf_size = mtd->erasesize;
> >>   
> >>   	st = strsep(&s, " ");
> >>   	if (!strcmp(st, "raw")) {
> >>  
> > Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
> >
> > Thanks
> >
> > Patrice  
> 
> 
> Lukasz, any remarks on your side?
> 
> 
> Can I take this patch in my first STM32 pull request for v2020.10 ?

Please pull it to your tree.

> 
> or a PR is already planed on your side ?
> 
> http://patchwork.ozlabs.org/project/uboot/patch/20210304174748.1.I1d824180669d63e22275f082e7ac0fe50c2b8646@changeid/
> 
> 
> Regards
> 
> Patrick
> 



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: [Uboot-stm32] [PATCH] dfu: dfu_mtd: set max_buf_size to erasesize also for NOR devices
  2021-04-20 10:24 ` [Uboot-stm32] " Patrice CHOTARD
  2021-06-04 16:59   ` Patrick DELAUNAY
@ 2021-06-18  8:10   ` Patrice CHOTARD
  1 sibling, 0 replies; 5+ messages in thread
From: Patrice CHOTARD @ 2021-06-18  8:10 UTC (permalink / raw)
  To: Patrick Delaunay, u-boot; +Cc: U-Boot STM32, Lukasz Majewski



On 4/20/21 12:24 PM, Patrice CHOTARD wrote:
> Hi Patrick
> 
> On 3/4/21 5:47 PM, Patrick Delaunay wrote:
>> For NOR devices the logical DFU buffer size is the sector_size,
>> as it is done in dfu_sf.c or in spi/sf_mtd.c
>> (sf_mtd_info.erasesize = flash->sector_size)
>>
>> For NAND the DFU size was already limited to erasesize as
>> has_pages = true.
>>
>> So the mtd dfu backend can use this erasesize for all the MTD devices,
>> NOR and NAND with dfu->max_buf_size = mtd->erasesize
>>
>> This difference was initially copied from MTD command, where
>> data is fully available in RAM without size limitation.
>>
>> This patch avoids to have many sector write in dfu_mtd.c at the end
>> of the DFU transfer and avoids issues with USB timeout or WATCHDOG.
>>
>> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
>> ---
>>
>>  drivers/dfu/dfu_mtd.c | 5 +----
>>  1 file changed, 1 insertion(+), 4 deletions(-)
>>
>> diff --git a/drivers/dfu/dfu_mtd.c b/drivers/dfu/dfu_mtd.c
>> index ca67585a7e..7efb3cbd79 100644
>> --- a/drivers/dfu/dfu_mtd.c
>> +++ b/drivers/dfu/dfu_mtd.c
>> @@ -252,7 +252,6 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char *s)
>>  {
>>  	char *st;
>>  	struct mtd_info *mtd;
>> -	bool has_pages;
>>  	int ret, part;
>>  
>>  	mtd = get_mtd_device_nm(devstr);
>> @@ -262,9 +261,7 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char *s)
>>  
>>  	dfu->dev_type = DFU_DEV_MTD;
>>  	dfu->data.mtd.info = mtd;
>> -
>> -	has_pages = mtd->type == MTD_NANDFLASH || mtd->type == MTD_MLCNANDFLASH;
>> -	dfu->max_buf_size = has_pages ? mtd->erasesize : 0;
>> +	dfu->max_buf_size = mtd->erasesize;
>>  
>>  	st = strsep(&s, " ");
>>  	if (!strcmp(st, "raw")) {
>>
> 
> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
> 
> Thanks
> 
> Patrice
> 
Applied on u-boot-stm32/next

Thanks

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

end of thread, other threads:[~2021-06-18  8:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-04 16:47 [PATCH] dfu: dfu_mtd: set max_buf_size to erasesize also for NOR devices Patrick Delaunay
2021-04-20 10:24 ` [Uboot-stm32] " Patrice CHOTARD
2021-06-04 16:59   ` Patrick DELAUNAY
2021-06-07  8:39     ` Lukasz Majewski
2021-06-18  8:10   ` Patrice CHOTARD

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.