mtd: cfi_cmdset_0002: Use chip_ready() for write on S29GL064N
Subsystems (2)
v3 cover mtd: cfi_cmdset_0002: Use chip_ready() for write on S29GL064N
As pointed out by this bug report [1], the buffered write is now broken on S29GL064N. The reason is that changed the buffered write to use chip_good instead of chip_ready. One way to solve the issue is to revert the change partially to use chip_ready for S29GL064N since the way of least surprise.
[1] https://lore.kernel.org/r/[email protected]/
Tokunori Ikegami (3):
mtd: cfi_cmdset_0002: Add S29GL064N ID definition
mtd: cfi_cmdset_0002: Move and rename
chip_check/chip_ready/chip_good_for_write
mtd: cfi_cmdset_0002: Use chip_ready() for write on S29GL064N
drivers/mtd/chips/cfi_cmdset_0002.c | 89 +++++++++++++++-------------- 1 file changed, 47 insertions(+), 42 deletions(-)
Signature · 1 line
2.32.0
PATCH v3 1/3 mtd: cfi_cmdset_0002: Add S29GL064N ID definition
It is for the model number 01, 02, V1 and V2.
--- drivers/mtd/chips/cfi_cmdset_0002.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/chips/cfi_cmdset_0002.c +2 -1
@@ -48,6 +48,7 @@#define SST49LF040B 0x0050#define SST49LF008A 0x005a#define AT49BV6416 0x00d6 +#define S29GL064N_MN12 0x0c01/* * Status Register bit description. Used by flash devices that don't
@@ -462,7 +463,7 @@ static struct cfi_fixup cfi_fixup_table[] = { { CFI_MFR_AMD, 0x0056, fixup_use_secsi }, { CFI_MFR_AMD, 0x005C, fixup_use_secsi }, { CFI_MFR_AMD, 0x005F, fixup_use_secsi }, - { CFI_MFR_AMD, 0x0c01, fixup_s29gl064n_sectors }, + { CFI_MFR_AMD, S29GL064N_MN12, fixup_s29gl064n_sectors }, { CFI_MFR_AMD, 0x1301, fixup_s29gl064n_sectors }, { CFI_MFR_AMD, 0x1a00, fixup_s29gl032n_sectors }, { CFI_MFR_AMD, 0x1a01, fixup_s29gl032n_sectors },
Signature · 6 lines
2.32.0 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Miquel Raynal
maintainerRe: [PATCH v3 1/3] mtd: cfi_cmdset_0002: Add S29GL064N ID definition
Hi Tokunori,
[email protected] wrote on Wed, 16 Mar 2022 01:56:05 +0900:
Quoted 1 line
It is for the model number 01, 02, V1 and V2.
Please move this change to the end of the series. We do not need to backport this improvement.
Also use the hexadecimal value in your fix (patch 3/3) so that we can apply it easily to older kernels.
Quoted 22 lines
Signed-off-by Tokunori Ikegami <[email protected]>Cc Miquel Raynal <[email protected]>Cc Richard Weinberger <[email protected]>Cc Vignesh Raghavendra <[email protected]>--- drivers/mtd/chips/cfi_cmdset_0002.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/mtd/chips/cfi_cmdset_0002.c +1
-0@@ -48,6 +48,7 @@#define SST49LF040B 0x0050#define SST49LF008A 0x005a#define AT49BV6416 0x00d6 +#define S29GL064N_MN12 0x0c01/* * Status Register bit description. Used by flash devices that don't
drivers/mtd/chips/cfi_cmdset_0002.c static struct cfi_fixup cfi_fixup_table[] = { · line 469
Quoted 8 lines
drivers/mtd/chips/cfi_cmdset_0002.c +1
-1@@ -462,7 +463,7 @@ static struct cfi_fixup cfi_fixup_table[] = { { CFI_MFR_AMD, 0x0056, fixup_use_secsi }, { CFI_MFR_AMD, 0x005C, fixup_use_secsi }, { CFI_MFR_AMD, 0x005F, fixup_use_secsi }, - { CFI_MFR_AMD, 0x0c01, fixup_s29gl064n_sectors }, + { CFI_MFR_AMD, S29GL064N_MN12, fixup_s29gl064n_sectors }, { CFI_MFR_AMD, 0x1301, fixup_s29gl064n_sectors }, { CFI_MFR_AMD, 0x1a00, fixup_s29gl032n_sectors }, { CFI_MFR_AMD, 0x1a01, fixup_s29gl032n_sectors },
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 1/3] mtd: cfi_cmdset_0002: Add S29GL064N ID definition
Hi,
Quoted 10 lines · Miquel Raynal
Hi Tokunori,
[email protected] wrote on Wed, 16 Mar 2022 01:56:05 +0900:
Quoted 1 line
It is for the model number 01, 02, V1 and V2.
Please move this change to the end of the series. We do not need to backport this improvement.
Also use the hexadecimal value in your fix (patch 3/3) so that we can apply it easily to older kernels.
Fixed by the version 4 patches.
Regards,
Ikegami
Quoted 20 lines
Quoted 20 lines
Signed-off-by Tokunori Ikegami <[email protected]>Cc Miquel Raynal <[email protected]>Cc Richard Weinberger <[email protected]>Cc Vignesh Raghavendra <[email protected]>--- drivers/mtd/chips/cfi_cmdset_0002.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/mtd/chips/cfi_cmdset_0002.c +1
-0@@ -48,6 +48,7 @@#define SST49LF040B 0x0050#define SST49LF008A 0x005a#define AT49BV6416 0x00d6 +#define S29GL064N_MN12 0x0c01
Quoted 14 lines
drivers/mtd/chips/cfi_cmdset_0002.c static struct cfi_fixup cfi_fixup_table[] = { · line 469
Quoted 11 lines
drivers/mtd/chips/cfi_cmdset_0002.c +1
-1/* * Status Register bit description. Used by flash devices that don't @@ -462,7 +463,7 @@ static struct cfi_fixup cfi_fixup_table[] = { { CFI_MFR_AMD, 0x0056, fixup_use_secsi }, { CFI_MFR_AMD, 0x005C, fixup_use_secsi }, { CFI_MFR_AMD, 0x005F, fixup_use_secsi }, - { CFI_MFR_AMD, 0x0c01, fixup_s29gl064n_sectors }, + { CFI_MFR_AMD, S29GL064N_MN12, fixup_s29gl064n_sectors }, { CFI_MFR_AMD, 0x1301, fixup_s29gl064n_sectors }, { CFI_MFR_AMD, 0x1a00, fixup_s29gl032n_sectors }, { CFI_MFR_AMD, 0x1a01, fixup_s29gl032n_sectors },Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 2/3 mtd: cfi_cmdset_0002: Move and rename chip_check/chip_ready/chip_good_for_write
In reply to Tokunori IkegamiThis is a preparation patch for the functinal change to fix the issue.
--- drivers/mtd/chips/cfi_cmdset_0002.c | 82 +++++++++++++---------------- 1 file changed, 38 insertions(+), 44 deletions(-)
drivers/mtd/chips/cfi_cmdset_0002.c +38 -44
@@ -802,22 +802,12 @@ static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd)return NULL ; } -/* -* Return true if the chip is ready. -* -* Ready is one of: read mode, query mode, erase-suspend-read mode (in any -* non-suspended sector) and is indicated by no toggle bits toggling. -* -* Note that anything more complicated than checking if no bits are toggling -* (including checking DQ5 for an error status) is tricky to get working -* correctly and is therefore not done (particularly with interleaved chips -* as each chip must be checked independently of the others). -*/ -static int __xipram chip_ready(struct map_info *map, struct flchip *chip, -unsigned long addr) +static int __xipram chip_check(struct map_info *map, struct flchip *chip, +unsigned long addr,map_word *expected) {struct cfi_private *cfi = map->fldrv_priv; -map_word d, t; +map_word oldd, curd; +int ret;if (cfi_use_status_reg (cfi)) {map_word ready =CMD (CFI_SR_DRB );
@@ -827,17 +817,35 @@ static int __xipram chip_ready(struct map_info *map, struct flchip *chip,*/ cfi_send_gen_cmd (0x70 , cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type,NULL ); - d =map_read (map, addr); + curd =map_read (map, addr); -return map_word_andequal (map, d, ready, ready); +return map_word_andequal (map, curd, ready, ready); } - d =map_read (map, addr); - t =map_read (map, addr); + oldd =map_read (map, addr); + curd =map_read (map, addr); + + ret =map_word_equal (map, oldd, curd); -return map_word_equal (map, d, t); +if (!ret || !expected) +return ret; + +return map_word_equal (map, curd, *expected); } +/* +* Return true if the chip is ready. +* +* Ready is one of: read mode, query mode, erase-suspend-read mode (in any +* non-suspended sector) and is indicated by no toggle bits toggling. +* +* Note that anything more complicated than checking if no bits are toggling +* (including checking DQ5 for an error status) is tricky to get working +* correctly and is therefore not done (particularly with interleaved chips +* as each chip must be checked independently of the others). +*/ +#define chip_ready (map, chip, addr) chip_check(map, chip, addr, NULL) +/* * Return true if the chip is ready and has the correct value. *
@@ -856,28 +864,14 @@ static int __xipram chip_ready(struct map_info *map, struct flchip *chip, static int __xipram chip_good(struct map_info *map, struct flchip *chip,unsigned long addr,map_word expected) { -struct cfi_private *cfi = map->fldrv_priv; -map_word oldd, curd; - -if (cfi_use_status_reg (cfi)) { -map_word ready =CMD (CFI_SR_DRB ); - -/* -* For chips that support status register, check device -* ready bit -*/ -cfi_send_gen_cmd (0x70 , cfi->addr_unlock1, chip->start, map, cfi, - cfi->device_type,NULL ); - curd =map_read (map, addr); - -return map_word_andequal (map, curd, ready, ready); - } - - oldd =map_read (map, addr); - curd =map_read (map, addr); +return chip_check (map, chip, addr, &expected); +} -return map_word_equal (map, oldd, curd) && -map_word_equal (map, curd, expected); +static int __xipram chip_good_for_write(struct map_info *map, +struct flchip *chip,unsigned long addr, +map_word expected) +{ +return chip_good (map, chip, addr, expected); }static int get_chip (struct map_info *map,struct flchip *chip,unsigned long adr,int mode)
@@ -1700,7 +1694,7 @@ static int __xipram do_write_oneword_once(struct map_info *map,* "chip_good" to avoid the failure due to scheduling. */ if (time_after (jiffies, timeo) && - !chip_good (map, chip, adr, datum)) { + !chip_good_for_write (map, chip, adr, datum)) {xip_enable (map, chip, adr);printk (KERN_WARNING "MTD %s(): software timeout\n" , __func__);xip_disable (map, chip, adr);
@@ -1708,7 +1702,7 @@ static int __xipram do_write_oneword_once(struct map_info *map,break ; } -if (chip_good (map, chip, adr, datum)) { +if (chip_good_for_write (map, chip, adr, datum)) {if (cfi_check_err_status (map, chip, adr)) ret = -EIO ;break ;
@@ -1980,14 +1974,14 @@ static int __xipram do_write_buffer_wait(struct map_info *map,* "chip_good" to avoid the failure due to scheduling. */ if (time_after (jiffies, timeo) && - !chip_good (map, chip, adr, datum)) { + !chip_good_for_write (map, chip, adr, datum)) {pr_err ("MTD %s(): software timeout, address:0x%.8lx.\n" , __func__, adr); ret = -EIO ;break ; } -if (chip_good (map, chip, adr, datum)) { +if (chip_good_for_write (map, chip, adr, datum)) {if (cfi_check_err_status (map, chip, adr)) ret = -EIO ;break ;
Signature · 6 lines
2.32.0 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Miquel Raynal
maintainerRe: [PATCH v3 2/3] mtd: cfi_cmdset_0002: Move and rename chip_check/chip_ready/chip_good_for_write
Hi Tokunori,
[email protected] wrote on Wed, 16 Mar 2022 01:56:06 +0900:
Quoted 1 line
This is a preparation patch for the functinal change to fix the issue.
functional
Commits are independent "to fix the issue" does not make any sense here, please give more information like "in preparation to a change expected to fix the buffered writes on S29GL..."
Quoted 96 lines
Signed-off-by Tokunori Ikegami <[email protected]>Cc Miquel Raynal <[email protected]>Cc Richard Weinberger <[email protected]>Cc Vignesh Raghavendra <[email protected]>--- drivers/mtd/chips/cfi_cmdset_0002.c | 82 +++++++++++++---------------- 1 file changed, 38 insertions(+), 44 deletions(-)drivers/mtd/chips/cfi_cmdset_0002.c +27
-29@@ -802,22 +802,12 @@ static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd)return NULL ; } -/* -* Return true if the chip is ready. -* -* Ready is one of: read mode, query mode, erase-suspend-read mode (in any -* non-suspended sector) and is indicated by no toggle bits toggling. -* -* Note that anything more complicated than checking if no bits are toggling -* (including checking DQ5 for an error status) is tricky to get working -* correctly and is therefore not done (particularly with interleaved chips -* as each chip must be checked independently of the others). -*/ -static int __xipram chip_ready(struct map_info *map, struct flchip *chip, -unsigned long addr) +static int __xipram chip_check(struct map_info *map, struct flchip *chip, +unsigned long addr,map_word *expected) {struct cfi_private *cfi = map->fldrv_priv; -map_word d, t; +map_word oldd, curd; +int ret;if (cfi_use_status_reg (cfi)) {map_word ready =CMD (CFI_SR_DRB );@@ -827,17 +817,35 @@ static int __xipram chip_ready(struct map_info *map, struct flchip *chip,*/ cfi_send_gen_cmd (0x70 , cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type,NULL ); - d =map_read (map, addr); + curd =map_read (map, addr); -return map_word_andequal (map, d, ready, ready); +return map_word_andequal (map, curd, ready, ready); } - d =map_read (map, addr); - t =map_read (map, addr); + oldd =map_read (map, addr); + curd =map_read (map, addr); + + ret =map_word_equal (map, oldd, curd); -return map_word_equal (map, d, t); +if (!ret || !expected) +return ret; + +return map_word_equal (map, curd, *expected); } +/* +* Return true if the chip is ready. +* +* Ready is one of: read mode, query mode, erase-suspend-read mode (in any +* non-suspended sector) and is indicated by no toggle bits toggling. +* +* Note that anything more complicated than checking if no bits are toggling +* (including checking DQ5 for an error status) is tricky to get working +* correctly and is therefore not done (particularly with interleaved chips +* as each chip must be checked independently of the others). +*/ +#define chip_ready (map, chip, addr) chip_check(map, chip, addr, NULL) +/* * Return true if the chip is ready and has the correct value. * @@ -856,28 +864,14 @@ static int __xipram chip_ready(struct map_info *map, struct flchip *chip, static int __xipram chip_good(struct map_info *map, struct flchip *chip,unsigned long addr,map_word expected) { -struct cfi_private *cfi = map->fldrv_priv; -map_word oldd, curd; - -if (cfi_use_status_reg (cfi)) { -map_word ready =CMD (CFI_SR_DRB ); - -/* -* For chips that support status register, check device -* ready bit -*/
drivers/mtd/chips/cfi_cmdset_0002.c static int __xipram chip_ready(struct map_info *map, struct flchip *chip, · line 867
Quoted 10 lines
drivers/mtd/chips/cfi_cmdset_0002.c +1
-9-cfi_send_gen_cmd (0x70 , cfi->addr_unlock1, chip->start, map, cfi, - cfi->device_type,NULL ); - curd =map_read (map, addr); - -return map_word_andequal (map, curd, ready, ready); - } - - oldd =map_read (map, addr); - curd =map_read (map, addr); +return chip_check (map, chip, addr, &expected);
I must admit that chip_check, chip_good(), chip_ready() are rather poor names, at least they don't bring a lot of information. Is this part of a revert? If yes maybe it would be better to actually revert the patch if it not too complicated? Otherwise I don't really see the point of having chip_good() calling just chip_check()? And creating a macro for chip_ready()?
Quoted 37 lines
drivers/mtd/chips/cfi_cmdset_0002.c +9
-5+} -return map_word_equal (map, oldd, curd) && -map_word_equal (map, curd, expected); +static int __xipram chip_good_for_write(struct map_info *map, +struct flchip *chip,unsigned long addr, +map_word expected) +{ +return chip_good (map, chip, addr, expected); }static int get_chip (struct map_info *map,struct flchip *chip,unsigned long adr,int mode)@@ -1700,7 +1694,7 @@ static int __xipram do_write_oneword_once(struct map_info *map,* "chip_good" to avoid the failure due to scheduling. */ if (time_after (jiffies, timeo) && - !chip_good (map, chip, adr, datum)) { + !chip_good_for_write (map, chip, adr, datum)) {xip_enable (map, chip, adr);printk (KERN_WARNING "MTD %s(): software timeout\n" , __func__);xip_disable (map, chip, adr);@@ -1708,7 +1702,7 @@ static int __xipram do_write_oneword_once(struct map_info *map,break ; } -if (chip_good (map, chip, adr, datum)) { +if (chip_good_for_write (map, chip, adr, datum)) {if (cfi_check_err_status (map, chip, adr)) ret = -EIO ;break ;@@ -1980,14 +1974,14 @@ static int __xipram do_write_buffer_wait(struct map_info *map,* "chip_good" to avoid the failure due to scheduling. */ if (time_after (jiffies, timeo) && - !chip_good (map, chip, adr, datum)) { + !chip_good_for_write (map, chip, adr, datum)) { pr_err("MTD %s(): software timeout, address:0x%.8lx.\n",
drivers/mtd/chips/cfi_cmdset_0002.c static int __xipram do_write_buffer_wait(struct map_info *map, · line 1987
Quoted 10 lines
drivers/mtd/chips/cfi_cmdset_0002.c +1
-1__func__, adr); ret = -EIO ;break ; } -if (chip_good (map, chip, adr, datum)) { +if (chip_good_for_write (map, chip, adr, datum)) {if (cfi_check_err_status (map, chip, adr)) ret = -EIO ;break ;
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH v3 2/3] mtd: cfi_cmdset_0002: Move and rename chip_check/chip_ready/chip_good_for_write
Hi,
Quoted 10 lines · Miquel Raynal
Hi Tokunori,
[email protected] wrote on Wed, 16 Mar 2022 01:56:06 +0900:
Quoted 1 line
This is a preparation patch for the functinal change to fix the issue.
functional
Commits are independent "to fix the issue" does not make any sense here, please give more information like "in preparation to a change expected to fix the buffered writes on S29GL..."
Fixed by the version 4 patches.
Quoted 102 lines
Quoted 102 lines
Signed-off-by Tokunori Ikegami <[email protected]>Cc Miquel Raynal <[email protected]>Cc Richard Weinberger <[email protected]>Cc Vignesh Raghavendra <[email protected]>--- drivers/mtd/chips/cfi_cmdset_0002.c | 82 +++++++++++++---------------- 1 file changed, 38 insertions(+), 44 deletions(-)drivers/mtd/chips/cfi_cmdset_0002.c +27
-35@@ -802,22 +802,12 @@ static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd)return NULL ; } -/* -* Return true if the chip is ready. -* -* Ready is one of: read mode, query mode, erase-suspend-read mode (in any -* non-suspended sector) and is indicated by no toggle bits toggling. -* -* Note that anything more complicated than checking if no bits are toggling -* (including checking DQ5 for an error status) is tricky to get working -* correctly and is therefore not done (particularly with interleaved chips -* as each chip must be checked independently of the others). -*/ -static int __xipram chip_ready(struct map_info *map, struct flchip *chip, -unsigned long addr) +static int __xipram chip_check(struct map_info *map, struct flchip *chip, +unsigned long addr,map_word *expected) {struct cfi_private *cfi = map->fldrv_priv; -map_word d, t; +map_word oldd, curd; +int ret;if (cfi_use_status_reg (cfi)) {map_word ready =CMD (CFI_SR_DRB );@@ -827,17 +817,35 @@ static int __xipram chip_ready(struct map_info *map, struct flchip *chip,*/ cfi_send_gen_cmd (0x70 , cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type,NULL ); - d =map_read (map, addr); + curd =map_read (map, addr); -return map_word_andequal (map, d, ready, ready); +return map_word_andequal (map, curd, ready, ready); } - d =map_read (map, addr); - t =map_read (map, addr); + oldd =map_read (map, addr); + curd =map_read (map, addr); + + ret =map_word_equal (map, oldd, curd); -return map_word_equal (map, d, t); +if (!ret || !expected) +return ret; + +return map_word_equal (map, curd, *expected); } +/* +* Return true if the chip is ready. +* +* Ready is one of: read mode, query mode, erase-suspend-read mode (in any +* non-suspended sector) and is indicated by no toggle bits toggling. +* +* Note that anything more complicated than checking if no bits are toggling +* (including checking DQ5 for an error status) is tricky to get working +* correctly and is therefore not done (particularly with interleaved chips +* as each chip must be checked independently of the others). +*/ +#define chip_ready (map, chip, addr) chip_check(map, chip, addr, NULL) +/* * Return true if the chip is ready and has the correct value. * @@ -856,28 +864,14 @@ static int __xipram chip_ready(struct map_info *map, struct flchip *chip, static int __xipram chip_good(struct map_info *map, struct flchip *chip,unsigned long addr,map_word expected) { -struct cfi_private *cfi = map->fldrv_priv; -map_word oldd, curd; - -if (cfi_use_status_reg (cfi)) { -map_word ready =CMD (CFI_SR_DRB ); - -/* -* For chips that support status register, check device -* ready bit -*/ -cfi_send_gen_cmd (0x70 , cfi->addr_unlock1, chip->start, map, cfi, - cfi->device_type,NULL ); - curd =map_read (map, addr); - -return map_word_andequal (map, curd, ready, ready); - }
Quoted 8 lines
drivers/mtd/chips/cfi_cmdset_0002.c static int __xipram chip_ready(struct map_info *map, struct flchip *chip, · line 867
Quoted 4 lines
drivers/mtd/chips/cfi_cmdset_0002.c +1
-3- - oldd =map_read (map, addr); - curd =map_read (map, addr); +return chip_check (map, chip, addr, &expected);I must admit that
chip_check,chip_good(),chip_ready()are rather poor names, at least they don't bring a lot of information. Is this part of a revert? If yes maybe it would be better to actually revert the patch if it not too complicated? Otherwise I don't really see the point of
No this is not for the revert.
Quoted 2 lines
having
chip_good()calling justchip_check()? And creating a macro forchip_ready()?
Changed chip_good by the version 4 patches as a macro but not a function as same with the chip_ready.
Quoted 43 lines
Quoted 43 lines
drivers/mtd/chips/cfi_cmdset_0002.c +9
-5+} -return map_word_equal (map, oldd, curd) && -map_word_equal (map, curd, expected); +static int __xipram chip_good_for_write(struct map_info *map, +struct flchip *chip,unsigned long addr, +map_word expected) +{ +return chip_good (map, chip, addr, expected); }static int get_chip (struct map_info *map,struct flchip *chip,unsigned long adr,int mode)@@ -1700,7 +1694,7 @@ static int __xipram do_write_oneword_once(struct map_info *map,* "chip_good" to avoid the failure due to scheduling. */ if (time_after (jiffies, timeo) && - !chip_good (map, chip, adr, datum)) { + !chip_good_for_write (map, chip, adr, datum)) {xip_enable (map, chip, adr);printk (KERN_WARNING "MTD %s(): software timeout\n" , __func__);xip_disable (map, chip, adr);@@ -1708,7 +1702,7 @@ static int __xipram do_write_oneword_once(struct map_info *map,break ; } -if (chip_good (map, chip, adr, datum)) { +if (chip_good_for_write (map, chip, adr, datum)) {if (cfi_check_err_status (map, chip, adr)) ret = -EIO ;break ;@@ -1980,14 +1974,14 @@ static int __xipram do_write_buffer_wait(struct map_info *map,* "chip_good" to avoid the failure due to scheduling. */ if (time_after (jiffies, timeo) && - !chip_good (map, chip, adr, datum)) { + !chip_good_for_write (map, chip, adr, datum)) {pr_err ("MTD %s(): software timeout, address:0x%.8lx.\n" , __func__, adr); ret = -EIO ;break ; }
Quoted 8 lines
drivers/mtd/chips/cfi_cmdset_0002.c static int __xipram do_write_oneword_once(struct map_info *map, · line 1708
Quoted 5 lines
drivers/mtd/chips/cfi_cmdset_0002.c +1
-1-if (chip_good (map, chip, adr, datum)) { +if (chip_good_for_write (map, chip, adr, datum)) {if (cfi_check_err_status (map, chip, adr)) ret = -EIO ;break ;Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v3 3/3 mtd: cfi_cmdset_0002: Use chip_ready() for write on S29GL064N
In reply to Tokunori IkegamiAs pointed out by this bug report [1], the buffered write is now broken on S29GL064N. The reason is that changed the buffered write to use chip_good instead of chip_ready. One way to solve the issue is to revert the change partially to use chip_ready for S29GL064N since the way of least surprise.
[1] https://lore.kernel.org/r/[email protected]/
--- drivers/mtd/chips/cfi_cmdset_0002.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/mtd/chips/cfi_cmdset_0002.c +10 -0
@@ -867,10 +867,20 @@ static int __xipram chip_good(struct map_info *map, struct flchip *chip,return chip_check (map, chip, addr, &expected); } +static bool __xipram cfi_use_chip_ready_for_write(struct map_info *map) +{ +struct cfi_private *cfi = map->fldrv_priv; + +return cfi->mfr ==CFI_MFR_AMD && cfi->id ==S29GL064N_MN12 ; +} + static int __xipram chip_good_for_write(struct map_info *map,struct flchip *chip,unsigned long addr,map_word expected) { +if (cfi_use_chip_ready_for_write (map)) +return chip_ready (map, chip, addr); +return chip_good (map, chip, addr, expected); }
Signature · 1 line
2.32.0
Miquel Raynal
maintainerHi Tokunori,
[email protected] wrote on Wed, 16 Mar 2022 01:56:07 +0900:
Quoted 1 line
As pointed out by this bug report [1], the buffered write is now broken on
, buffered writes are now broken
Quoted 2 lines
S29GL064N. The reason is that changed the buffered write to use
chip_goodinstead ofchip_ready.
"This issue comes from a rework which switched from using chip_good() to chip_ready(), because <explain the difference here>."
[please note I am just trying to understand what the root cause is, please rephrase if I'm wrong].
Quoted 2 lines
One way to solve the issue is to revert the change
partially to usechip_readyfor S29GL064N since the way of least surprise.
s/since the way of least surprise//
Quoted 10 lines
[1] https://lore.kernel.org/r/[email protected]/
Fixes dfeae1073583("mtd: cfi_cmdset_0002: Change write buffer to check correct value")Signed-off-by Tokunori Ikegami <[email protected]>Tested-by Ahmad Fatoum <[email protected]>Cc Miquel Raynal <[email protected]>Cc Richard Weinberger <[email protected]>Cc Vignesh Raghavendra <[email protected]>
I think you can get rid of all the above Cc: tags and just copy all 3 of us + the mailing list when sending your v4.
Quoted 2 lines
---
Please also include a Fixes/stable tag in the patch before (2/3) to explain
that both patches are required in order to fix the issue and the current patch alone won't apply.
You should mention that with a nice comment below the three dashes ("---") in patch 2/3 as well.
Quoted 18 lines
drivers/mtd/chips/cfi_cmdset_0002.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/mtd/chips/cfi_cmdset_0002.c +7
-0@@ -867,10 +867,20 @@ static int __xipram chip_good(struct map_info *map, struct flchip *chip,return chip_check (map, chip, addr, &expected); } +static bool __xipram cfi_use_chip_ready_for_write(struct map_info *map) +{ +struct cfi_private *cfi = map->fldrv_priv; + +return cfi->mfr ==CFI_MFR_AMD && cfi->id ==S29GL064N_MN12 ; +} +
drivers/mtd/chips/cfi_cmdset_0002.c static int __xipram chip_good(struct map_info *map, struct flchip *chip, · line 886
Quoted 10 lines
drivers/mtd/chips/cfi_cmdset_0002.c +3
-0static int __xipram chip_good_for_write(struct map_info *map,struct flchip *chip,unsigned long addr,map_word expected) { +if (cfi_use_chip_ready_for_write (map)) +return chip_ready (map, chip, addr); +return chip_good (map, chip, addr, expected); }
This is much more understandable.
Vignesh, perhaps it would be better to provide a way for manufacturers to overload certain callbacks instead of applying quirks like this in the code. But that will come in a second time of course.
Thanks,
Miquèl
Hi,
Quoted 7 lines · Miquel Raynal
Hi Tokunori,
[email protected] wrote on Wed, 16 Mar 2022 01:56:07 +0900:
Quoted 1 line
As pointed out by this bug report [1], the buffered write is now broken on
, buffered writes are now broken
Quoted 7 lines
Quoted 2 lines
S29GL064N. The reason is that changed the buffered write to use
chip_goodinstead ofchip_ready."This issue comes from a rework which switched from using
chip_good()tochip_ready(), because <explain the difference here>."[please note I am just trying to understand what the root cause is, please rephrase if I'm wrong].
Fixed by the version 4 patches.
Quoted 4 lines
Quoted 3 lines
One way to solve the issue is to revert the change
partially to usechip_readyfor S29GL064N since the way of least surprise.s/since the way of least surprise//
Fixed by the version 4 patches.
Quoted 11 lines
Quoted 11 lines
[1] https://lore.kernel.org/r/[email protected]/
Fixes dfeae1073583("mtd: cfi_cmdset_0002: Change write buffer to check correct value")Signed-off-by Tokunori Ikegami <[email protected]>Tested-by Ahmad Fatoum <[email protected]>Cc Miquel Raynal <[email protected]>Cc Richard Weinberger <[email protected]>Cc Vignesh Raghavendra <[email protected]>
Quoted 2 lines
I think you can get rid of all the above Cc: tags and just copy all 3 of us + the mailing list when sending your v4.
Fixed by the version 4 patches.
Quoted 45 lines
Quoted 3 lines
---
Please also include a Fixes/stable tag in the patch before (2/3) to explain
that both patches are required in order to fix the issue and the current patch alone won't apply.You should mention that with a nice comment below the three dashes ("---") in patch 2/3 as well.
Quoted 18 lines
drivers/mtd/chips/cfi_cmdset_0002.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/mtd/chips/cfi_cmdset_0002.c +7
-0@@ -867,10 +867,20 @@ static int __xipram chip_good(struct map_info *map, struct flchip *chip,return chip_check (map, chip, addr, &expected); } +static bool __xipram cfi_use_chip_ready_for_write(struct map_info *map) +{ +struct cfi_private *cfi = map->fldrv_priv; + +return cfi->mfr ==CFI_MFR_AMD && cfi->id ==S29GL064N_MN12 ; +} +drivers/mtd/chips/cfi_cmdset_0002.c static int __xipram chip_good(struct map_info *map, struct flchip *chip, · line 886
Quoted 10 lines
drivers/mtd/chips/cfi_cmdset_0002.c +3
-0static int __xipram chip_good_for_write(struct map_info *map,struct flchip *chip,unsigned long addr,map_word expected) { +if (cfi_use_chip_ready_for_write (map)) +return chip_ready (map, chip, addr); +return chip_good (map, chip, addr, expected); }This is much more understandable.
Vignesh, perhaps it would be better to provide a way for manufacturers to overload certain callbacks instead of applying quirks like this in the code. But that will come in a second time of course.
Thanks,
Miquèl