mtd: spi-nor: core: Advance erase after the erase cmd has been completed
Subsystems (2)
PATCH 1/2 mtd: spi-nor: core: Advance erase after the erase cmd has been completed
Wait for the erase cmd to complete and then advance the erase.
--- drivers/mtd/spi-nor/core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/mtd/spi-nor/core.c +6 -6
@@ -1618,12 +1618,12 @@ static int spi_nor_erase_multi_sectors(struct spi_nor *nor, u64 addr, u32 len)if (ret) goto destroy_erase_cmd_list; - addr += cmd->size; - cmd->count--; - ret =spi_nor_wait_till_ready (nor);if (ret) goto destroy_erase_cmd_list; + + addr += cmd->size; + cmd->count--; }list_del (&cmd->list);kfree (cmd);
@@ -1704,12 +1704,12 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)if (ret) goto erase_err; - addr += mtd->erasesize; - len -= mtd->erasesize; - ret =spi_nor_wait_till_ready (nor);if (ret) goto erase_err; + + addr += mtd->erasesize; + len -= mtd->erasesize; }/* erase multiple sectors */
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 2/2 mtd: spi-nor: core: Add dbg msg for spi_nor_erase_multi_sectors()
Useful when debugging non-uniform erase.
--- drivers/mtd/spi-nor/core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mtd/spi-nor/core.c +3 -0
@@ -1622,6 +1622,9 @@ static int spi_nor_erase_multi_sectors(struct spi_nor *nor, u64 addr, u32 len)if (ret) goto destroy_erase_cmd_list; +dev_dbg (nor->dev,"erase_cmd->size = 0x%08x, erase_cmd->opcode = 0x%02x, erase_cmd->count = %d\n" , + cmd->size, cmd->opcode, cmd->count); + addr += cmd->size; cmd->count--; }
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 2/2] mtd: spi-nor: core: Add dbg msg for spi_nor_erase_multi_sectors()
Quoted 12 lines · Tudor Ambarus
Useful when debugging non-uniform erase.
Signed-off-by Tudor Ambarus <[email protected]>--- drivers/mtd/spi-nor/core.c | 3 +++ 1 file changed, 3 insertions(+)drivers/mtd/spi-nor/core.c +0
-0
drivers/mtd/spi-nor/core.c static int spi_nor_erase_multi_sectors(struct spi_nor *nor, u64 addr, u32 len) · line 1627
Quoted 6 lines
drivers/mtd/spi-nor/core.c +3
-0@@ -1622,6 +1622,9 @@ static int spi_nor_erase_multi_sectors(struct spi_nor *nor, u64 addr, u32 len)if (ret) goto destroy_erase_cmd_list; +dev_dbg (nor->dev,"erase_cmd->size = 0x%08x, erase_cmd->opcode = 0x%02x, erase_cmd->count = %d\n" , + cmd->size, cmd->opcode, cmd->count); +
I don't like the position of this debug message. This prints cmd->count _after_ the erase is done but _before_ cmd->count is updated. It might end up giving some wrong or misleading information. Can you either move it before the start of the erase or after all the bookkeeping is done?
Quoted 5 lines
drivers/mtd/spi-nor/core.c +0
-0addr += cmd->size; cmd->count--; }Signature · 1 line
2.25.1
Signature · 7 lines
Regards, Pratyush Yadav Texas Instruments Inc. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 2/2] mtd: spi-nor: core: Add dbg msg for spi_nor_erase_multi_sectors()
Quoted 18 lines · Pratyush Yadav
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 15 lines · Tudor Ambarus
Useful when debugging non-uniform erase.
Signed-off-by Tudor Ambarus <[email protected]>--- drivers/mtd/spi-nor/core.c | 3 +++ 1 file changed, 3 insertions(+)drivers/mtd/spi-nor/core.c +0
-0@@ -1622,6 +1622,9 @@ static int spi_nor_erase_multi_sectors(struct spi_nor *nor, u64 addr, u32 len)if (ret) goto destroy_erase_cmd_list;
Quoted 6 lines
drivers/mtd/spi-nor/core.c static int spi_nor_erase_multi_sectors(struct spi_nor *nor, u64 addr, u32 len) · line 1627
Quoted 3 lines
drivers/mtd/spi-nor/core.c +3
-0+dev_dbg (nor->dev,"erase_cmd->size = 0x%08x, erase_cmd->opcode = 0x%02x, erase_cmd->count = %d\n" , + cmd->size, cmd->opcode, cmd->count); +I don't like the position of this debug message. This prints
cmd->count_after_ the erase is done but _before_cmd->countis updated. It might
oh, yes.
Quoted 2 lines
end up giving some wrong or misleading information. Can you either move it before the start of the erase or after all the bookkeeping is done?
Before the start of the erase sounds good, but still inside the while, so that we catch each executed command. And maybe I'll change dev_dbg to dev_vdbg. I'll made my mind before v2.
Cheers,
ta
Quoted 7 lines
Quoted 6 lines
drivers/mtd/spi-nor/core.c +0
-1addr += cmd->size; cmd->count--; } --2.25.1
Quoted 5 lines
--
Regards,
Pratyush Yadav
Texas Instruments Inc.
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Quoted 30 lines · Tudor Ambarus
Wait for the erase cmd to complete and then advance the erase.
Signed-off-by Tudor Ambarus <[email protected]>--- drivers/mtd/spi-nor/core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/mtd/spi-nor/core.c +3
-3@@ -1618,12 +1618,12 @@ static int spi_nor_erase_multi_sectors(struct spi_nor *nor, u64 addr, u32 len)if (ret) goto destroy_erase_cmd_list; - addr += cmd->size; - cmd->count--; - ret =spi_nor_wait_till_ready (nor);if (ret) goto destroy_erase_cmd_list; + + addr += cmd->size; + cmd->count--; }list_del (&cmd->list);kfree (cmd);@@ -1704,12 +1704,12 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)if (ret) goto erase_err;
drivers/mtd/spi-nor/core.c static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) · line 1712
Quoted 10 lines
drivers/mtd/spi-nor/core.c +3
-3- addr += mtd->erasesize; - len -= mtd->erasesize; - ret =spi_nor_wait_till_ready (nor);if (ret) goto erase_err; + + addr += mtd->erasesize; + len -= mtd->erasesize;
Do these changes have any practical benefit? IMO they are worth doing even if there is none but I'm curious what prompted this patch.
Quoted 3 lines
drivers/mtd/spi-nor/core.c +0
-0}/* erase multiple sectors */
Signature · 7 lines
Regards, Pratyush Yadav Texas Instruments Inc. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Quoted 34 lines · Pratyush Yadav
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 31 lines · Tudor Ambarus
Wait for the erase cmd to complete and then advance the erase.
Signed-off-by Tudor Ambarus <[email protected]>--- drivers/mtd/spi-nor/core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/mtd/spi-nor/core.c +3
-3@@ -1618,12 +1618,12 @@ static int spi_nor_erase_multi_sectors(struct spi_nor *nor, u64 addr, u32 len)if (ret) goto destroy_erase_cmd_list; - addr += cmd->size; - cmd->count--; - ret =spi_nor_wait_till_ready (nor);if (ret) goto destroy_erase_cmd_list; + + addr += cmd->size; + cmd->count--; }list_del (&cmd->list);kfree (cmd);@@ -1704,12 +1704,12 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)if (ret) goto erase_err;
Quoted 12 lines
drivers/mtd/spi-nor/core.c static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) · line 1712
Quoted 9 lines
drivers/mtd/spi-nor/core.c +3
-3- addr += mtd->erasesize; - len -= mtd->erasesize; - ret =spi_nor_wait_till_ready (nor);if (ret) goto erase_err; + + addr += mtd->erasesize; + len -= mtd->erasesize;Do these changes have any practical benefit? IMO they are worth doing even if there is none but I'm curious what prompted this patch.
I saw these when reviewing Takahiro's patches. Addr and len were gratuitously updated even when the wait failed. We'll avoid 2 extra ops on the error path. Plus, having them updated before the wait can be misleading for someone that tracks them down with some debug messages. I find the code better structured, and the code will make more sense when it is read, if using this patch.
Quoted 2 lines
Reviewed-by Pratyush Yadav <[email protected]>
Thanks,
ta
Quoted 10 lines
drivers/mtd/spi-nor/core.c static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) · line 1715
Quoted 4 lines
drivers/mtd/spi-nor/core.c +0
-0}/* erase multiple sectors */ --
Regards,
Pratyush Yadav
Texas Instruments Inc.
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/