All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Add WATCHDOG_RESET() in MTD framework and STM32 QSPI driver
@ 2021-01-20 13:42 Patrice Chotard
  2021-01-20 13:42 ` [PATCH 1/4] mtd: spi-nor: Add WATCHDOG_RESET() in spi_nor_core callbacks Patrice Chotard
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Patrice Chotard @ 2021-01-20 13:42 UTC (permalink / raw)
  To: u-boot


In case of large area read/write/erase on spi nor and spi nand,
watchdog may occurs depending on watchdog timeout and MTD device size.
Some of these use-cases has been reproduced with stm32mp157-ev1 board.

To prevent this situation, WATHDOG_RESET() are added at several
location:
  - Add WATCHDOG_RESET() in spi_nor_erase() and spi_nor_write()
  - Add WATCHDOG_RESET() in _stm32_qspi_read_fifo()
  - Add WATCHDOG_RESET() in nanddev_mtd_erase()
  - Add WATCHDOG_RESET() in spinand_mtd_read() and spinand_mtd_erase()


Patrice Chotard (4):
  mtd: spi-nor: Add WATCHDOG_RESET() in spi_nor_core callbacks
  spi: stm32_qspi: Add WATCHDOG_RESET in _stm32_qspi_read_fifo()
  mtd: nand: Add WATCHDOG_RESET() in nanddev_mtd_erase()
  mtd: spinand: Add WATCHDOG_RESET() in spinand_mtd_read/write()

 drivers/mtd/nand/core.c        | 2 ++
 drivers/mtd/nand/spi/core.c    | 3 +++
 drivers/mtd/spi/spi-nor-core.c | 3 +++
 drivers/spi/stm32_qspi.c       | 2 ++
 4 files changed, 10 insertions(+)

-- 
2.17.1

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

* [PATCH 1/4] mtd: spi-nor: Add WATCHDOG_RESET() in spi_nor_core callbacks
  2021-01-20 13:42 [PATCH 0/4] Add WATCHDOG_RESET() in MTD framework and STM32 QSPI driver Patrice Chotard
@ 2021-01-20 13:42 ` Patrice Chotard
  2021-01-27 15:14   ` [Uboot-stm32] " Patrick DELAUNAY
  2021-01-20 13:42 ` [PATCH 2/4] spi: stm32_qspi: Add WATCHDOG_RESET in _stm32_qspi_read_fifo() Patrice Chotard
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 13+ messages in thread
From: Patrice Chotard @ 2021-01-20 13:42 UTC (permalink / raw)
  To: u-boot

In case of big area write/erase on spi nor, watchdog timeout may occurs.
Issue reproduced on stm32mp157c-ev1 with following commands:

sf write 0xC0000000 0 0x3000000
or
sf erase 0 0x1000000

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

 drivers/mtd/spi/spi-nor-core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index eb49a6c11c..51e0613d4c 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -10,6 +10,7 @@
  */
 
 #include <common.h>
+#include <watchdog.h>
 #include <linux/err.h>
 #include <linux/errno.h>
 #include <linux/log2.h>
@@ -557,6 +558,7 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
 	len = instr->len;
 
 	while (len) {
+		WATCHDOG_RESET();
 #ifdef CONFIG_SPI_FLASH_BAR
 		ret = write_bar(nor, addr);
 		if (ret < 0)
@@ -1235,6 +1237,7 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
 	for (i = 0; i < len; ) {
 		ssize_t written;
 		loff_t addr = to + i;
+		WATCHDOG_RESET();
 
 		/*
 		 * If page_size is a power of two, the offset can be quickly
-- 
2.17.1

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

* [PATCH 2/4] spi: stm32_qspi: Add WATCHDOG_RESET in _stm32_qspi_read_fifo()
  2021-01-20 13:42 [PATCH 0/4] Add WATCHDOG_RESET() in MTD framework and STM32 QSPI driver Patrice Chotard
  2021-01-20 13:42 ` [PATCH 1/4] mtd: spi-nor: Add WATCHDOG_RESET() in spi_nor_core callbacks Patrice Chotard
@ 2021-01-20 13:42 ` Patrice Chotard
  2021-01-27 15:15   ` [Uboot-stm32] " Patrick DELAUNAY
  2021-01-20 13:42 ` [PATCH 3/4] mtd: nand: Add WATCHDOG_RESET() in nanddev_mtd_erase() Patrice Chotard
  2021-01-20 13:42 ` [PATCH 4/4] mtd: spinand: Add WATCHDOG_RESET() in spinand_mtd_read/write() Patrice Chotard
  3 siblings, 1 reply; 13+ messages in thread
From: Patrice Chotard @ 2021-01-20 13:42 UTC (permalink / raw)
  To: u-boot

In case of reading large area and memory-map mode is misconfigured
(memory-map size declared lower than the real size of the memory chip)
watchdog can be triggered.

Add WATCHDOG_RESET() in _stm32_qspi_read_fifo to fix it.

Issue reproduced with stm32mp157c-ev1 board and memory map size set to
1, with following command:
sf read 0xC0000000 0 0x4000000

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

 drivers/spi/stm32_qspi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/spi/stm32_qspi.c b/drivers/spi/stm32_qspi.c
index 958c394a1a..c3da17f991 100644
--- a/drivers/spi/stm32_qspi.c
+++ b/drivers/spi/stm32_qspi.c
@@ -11,6 +11,7 @@
 #include <clk.h>
 #include <reset.h>
 #include <spi-mem.h>
+#include <watchdog.h>
 #include <linux/iopoll.h>
 #include <linux/ioport.h>
 #include <linux/sizes.h>
@@ -163,6 +164,7 @@ static int _stm32_qspi_wait_cmd(struct stm32_qspi_priv *priv,
 static void _stm32_qspi_read_fifo(u8 *val, void __iomem *addr)
 {
 	*val = readb(addr);
+	WATCHDOG_RESET();
 }
 
 static void _stm32_qspi_write_fifo(u8 *val, void __iomem *addr)
-- 
2.17.1

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

* [PATCH 3/4] mtd: nand: Add WATCHDOG_RESET() in nanddev_mtd_erase()
  2021-01-20 13:42 [PATCH 0/4] Add WATCHDOG_RESET() in MTD framework and STM32 QSPI driver Patrice Chotard
  2021-01-20 13:42 ` [PATCH 1/4] mtd: spi-nor: Add WATCHDOG_RESET() in spi_nor_core callbacks Patrice Chotard
  2021-01-20 13:42 ` [PATCH 2/4] spi: stm32_qspi: Add WATCHDOG_RESET in _stm32_qspi_read_fifo() Patrice Chotard
@ 2021-01-20 13:42 ` Patrice Chotard
  2021-01-27 15:15   ` [Uboot-stm32] " Patrick DELAUNAY
  2021-01-20 13:42 ` [PATCH 4/4] mtd: spinand: Add WATCHDOG_RESET() in spinand_mtd_read/write() Patrice Chotard
  3 siblings, 1 reply; 13+ messages in thread
From: Patrice Chotard @ 2021-01-20 13:42 UTC (permalink / raw)
  To: u-boot

In case of big area erased on nand, watchdog timeout may occurs.
To fix that, add WATCHDOG_RESET() in nanddev_mtd_erase() to ensure that
watchdog is reset.

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

 drivers/mtd/nand/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mtd/nand/core.c b/drivers/mtd/nand/core.c
index 3abaef23c5..ec11bf44f8 100644
--- a/drivers/mtd/nand/core.c
+++ b/drivers/mtd/nand/core.c
@@ -10,6 +10,7 @@
 #define pr_fmt(fmt)	"nand: " fmt
 
 #include <common.h>
+#include <watchdog.h>
 #ifndef __UBOOT__
 #include <linux/module.h>
 #endif
@@ -162,6 +163,7 @@ int nanddev_mtd_erase(struct mtd_info *mtd, struct erase_info *einfo)
 	nanddev_offs_to_pos(nand, einfo->addr, &pos);
 	nanddev_offs_to_pos(nand, einfo->addr + einfo->len - 1, &last);
 	while (nanddev_pos_cmp(&pos, &last) <= 0) {
+		WATCHDOG_RESET();
 		ret = nanddev_erase(nand, &pos);
 		if (ret) {
 			einfo->fail_addr = nanddev_pos_to_offs(nand, &pos);
-- 
2.17.1

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

* [PATCH 4/4] mtd: spinand: Add WATCHDOG_RESET() in spinand_mtd_read/write()
  2021-01-20 13:42 [PATCH 0/4] Add WATCHDOG_RESET() in MTD framework and STM32 QSPI driver Patrice Chotard
                   ` (2 preceding siblings ...)
  2021-01-20 13:42 ` [PATCH 3/4] mtd: nand: Add WATCHDOG_RESET() in nanddev_mtd_erase() Patrice Chotard
@ 2021-01-20 13:42 ` Patrice Chotard
  2021-01-27 15:19   ` [Uboot-stm32] " Patrick DELAUNAY
  3 siblings, 1 reply; 13+ messages in thread
From: Patrice Chotard @ 2021-01-20 13:42 UTC (permalink / raw)
  To: u-boot

In case of big area read/write on spi nand, watchdog timeout may occurs.
To fix that, add WATCHDOG_RESET() in spinand_mtd_read() and
spinand_mtd_write() to ensure that watchdog is reset.

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

---

 drivers/mtd/nand/spi/core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index cb8ffa3fa9..7f54422c93 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -24,6 +24,7 @@
 #include <errno.h>
 #include <spi.h>
 #include <spi-mem.h>
+#include <watchdog.h>
 #include <linux/mtd/spinand.h>
 #endif
 
@@ -574,6 +575,7 @@ static int spinand_mtd_read(struct mtd_info *mtd, loff_t from,
 #endif
 
 	nanddev_io_for_each_page(nand, from, ops, &iter) {
+		WATCHDOG_RESET();
 		ret = spinand_select_target(spinand, iter.req.pos.target);
 		if (ret)
 			break;
@@ -625,6 +627,7 @@ static int spinand_mtd_write(struct mtd_info *mtd, loff_t to,
 #endif
 
 	nanddev_io_for_each_page(nand, to, ops, &iter) {
+		WATCHDOG_RESET();
 		ret = spinand_select_target(spinand, iter.req.pos.target);
 		if (ret)
 			break;
-- 
2.17.1

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

* [Uboot-stm32] [PATCH 1/4] mtd: spi-nor: Add WATCHDOG_RESET() in spi_nor_core callbacks
  2021-01-20 13:42 ` [PATCH 1/4] mtd: spi-nor: Add WATCHDOG_RESET() in spi_nor_core callbacks Patrice Chotard
@ 2021-01-27 15:14   ` Patrick DELAUNAY
  2021-03-12 12:18     ` Patrice CHOTARD
  0 siblings, 1 reply; 13+ messages in thread
From: Patrick DELAUNAY @ 2021-01-27 15:14 UTC (permalink / raw)
  To: u-boot

Hi Patrice,

On 1/20/21 2:42 PM, Patrice Chotard wrote:
> In case of big area write/erase on spi nor, watchdog timeout may occurs.
> Issue reproduced on stm32mp157c-ev1 with following commands:
>
> sf write 0xC0000000 0 0x3000000
> or
> sf erase 0 0x1000000
>
> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
> ---
>
>   drivers/mtd/spi/spi-nor-core.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
> index eb49a6c11c..51e0613d4c 100644
> --- a/drivers/mtd/spi/spi-nor-core.c
> +++ b/drivers/mtd/spi/spi-nor-core.c
> @@ -10,6 +10,7 @@
>    */
>   
>   #include <common.h>
> +#include <watchdog.h>
>   #include <linux/err.h>
>   #include <linux/errno.h>
>   #include <linux/log2.h>
> @@ -557,6 +558,7 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
>   	len = instr->len;
>   
>   	while (len) {
> +		WATCHDOG_RESET();
>   #ifdef CONFIG_SPI_FLASH_BAR
>   		ret = write_bar(nor, addr);
>   		if (ret < 0)
> @@ -1235,6 +1237,7 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
>   	for (i = 0; i < len; ) {
>   		ssize_t written;
>   		loff_t addr = to + i;
> +		WATCHDOG_RESET();
>   
>   		/*
>   		 * If page_size is a power of two, the offset can be quickly


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

Thanks

Patrick

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

* [Uboot-stm32] [PATCH 2/4] spi: stm32_qspi: Add WATCHDOG_RESET in _stm32_qspi_read_fifo()
  2021-01-20 13:42 ` [PATCH 2/4] spi: stm32_qspi: Add WATCHDOG_RESET in _stm32_qspi_read_fifo() Patrice Chotard
@ 2021-01-27 15:15   ` Patrick DELAUNAY
  2021-03-12 12:18     ` Patrice CHOTARD
  0 siblings, 1 reply; 13+ messages in thread
From: Patrick DELAUNAY @ 2021-01-27 15:15 UTC (permalink / raw)
  To: u-boot

Hi Patrice

On 1/20/21 2:42 PM, Patrice Chotard wrote:
> In case of reading large area and memory-map mode is misconfigured
> (memory-map size declared lower than the real size of the memory chip)
> watchdog can be triggered.
>
> Add WATCHDOG_RESET() in _stm32_qspi_read_fifo to fix it.
>
> Issue reproduced with stm32mp157c-ev1 board and memory map size set to
> 1, with following command:
> sf read 0xC0000000 0 0x4000000
>
> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
> ---
>
>   drivers/spi/stm32_qspi.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/spi/stm32_qspi.c b/drivers/spi/stm32_qspi.c
> index 958c394a1a..c3da17f991 100644
> --- a/drivers/spi/stm32_qspi.c
> +++ b/drivers/spi/stm32_qspi.c
> @@ -11,6 +11,7 @@
>   #include <clk.h>
>   #include <reset.h>
>   #include <spi-mem.h>
> +#include <watchdog.h>
>   #include <linux/iopoll.h>
>   #include <linux/ioport.h>
>   #include <linux/sizes.h>
> @@ -163,6 +164,7 @@ static int _stm32_qspi_wait_cmd(struct stm32_qspi_priv *priv,
>   static void _stm32_qspi_read_fifo(u8 *val, void __iomem *addr)
>   {
>   	*val = readb(addr);
> +	WATCHDOG_RESET();
>   }
>   
>   static void _stm32_qspi_write_fifo(u8 *val, void __iomem *addr)


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

Thanks

Patrick

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

* [Uboot-stm32] [PATCH 3/4] mtd: nand: Add WATCHDOG_RESET() in nanddev_mtd_erase()
  2021-01-20 13:42 ` [PATCH 3/4] mtd: nand: Add WATCHDOG_RESET() in nanddev_mtd_erase() Patrice Chotard
@ 2021-01-27 15:15   ` Patrick DELAUNAY
  2021-03-12 12:19     ` Patrice CHOTARD
  0 siblings, 1 reply; 13+ messages in thread
From: Patrick DELAUNAY @ 2021-01-27 15:15 UTC (permalink / raw)
  To: u-boot

Hi Patrice,

On 1/20/21 2:42 PM, Patrice Chotard wrote:
> In case of big area erased on nand, watchdog timeout may occurs.
> To fix that, add WATCHDOG_RESET() in nanddev_mtd_erase() to ensure that
> watchdog is reset.
>
> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
> ---
>
>   drivers/mtd/nand/core.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/mtd/nand/core.c b/drivers/mtd/nand/core.c
> index 3abaef23c5..ec11bf44f8 100644
> --- a/drivers/mtd/nand/core.c
> +++ b/drivers/mtd/nand/core.c
> @@ -10,6 +10,7 @@
>   #define pr_fmt(fmt)	"nand: " fmt
>   
>   #include <common.h>
> +#include <watchdog.h>
>   #ifndef __UBOOT__
>   #include <linux/module.h>
>   #endif
> @@ -162,6 +163,7 @@ int nanddev_mtd_erase(struct mtd_info *mtd, struct erase_info *einfo)
>   	nanddev_offs_to_pos(nand, einfo->addr, &pos);
>   	nanddev_offs_to_pos(nand, einfo->addr + einfo->len - 1, &last);
>   	while (nanddev_pos_cmp(&pos, &last) <= 0) {
> +		WATCHDOG_RESET();
>   		ret = nanddev_erase(nand, &pos);
>   		if (ret) {
>   			einfo->fail_addr = nanddev_pos_to_offs(nand, &pos);


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

Thanks

Patrick

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

* [Uboot-stm32] [PATCH 4/4] mtd: spinand: Add WATCHDOG_RESET() in spinand_mtd_read/write()
  2021-01-20 13:42 ` [PATCH 4/4] mtd: spinand: Add WATCHDOG_RESET() in spinand_mtd_read/write() Patrice Chotard
@ 2021-01-27 15:19   ` Patrick DELAUNAY
  2021-03-12 12:19     ` Patrice CHOTARD
  0 siblings, 1 reply; 13+ messages in thread
From: Patrick DELAUNAY @ 2021-01-27 15:19 UTC (permalink / raw)
  To: u-boot

Hi,

On 1/20/21 2:42 PM, Patrice Chotard wrote:
> In case of big area read/write on spi nand, watchdog timeout may occurs.
> To fix that, add WATCHDOG_RESET() in spinand_mtd_read() and
> spinand_mtd_write() to ensure that watchdog is reset.
>
> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
>
> ---
>
>   drivers/mtd/nand/spi/core.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
> index cb8ffa3fa9..7f54422c93 100644
> --- a/drivers/mtd/nand/spi/core.c
> +++ b/drivers/mtd/nand/spi/core.c
> @@ -24,6 +24,7 @@
>   #include <errno.h>
>   #include <spi.h>
>   #include <spi-mem.h>
> +#include <watchdog.h>
>   #include <linux/mtd/spinand.h>
>   #endif
>   
> @@ -574,6 +575,7 @@ static int spinand_mtd_read(struct mtd_info *mtd, loff_t from,
>   #endif
>   
>   	nanddev_io_for_each_page(nand, from, ops, &iter) {
> +		WATCHDOG_RESET();
>   		ret = spinand_select_target(spinand, iter.req.pos.target);
>   		if (ret)
>   			break;
> @@ -625,6 +627,7 @@ static int spinand_mtd_write(struct mtd_info *mtd, loff_t to,
>   #endif
>   
>   	nanddev_io_for_each_page(nand, to, ops, &iter) {
> +		WATCHDOG_RESET();
>   		ret = spinand_select_target(spinand, iter.req.pos.target);
>   		if (ret)
>   			break;


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

Thanks

Patrick

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

* [Uboot-stm32] [PATCH 1/4] mtd: spi-nor: Add WATCHDOG_RESET() in spi_nor_core callbacks
  2021-01-27 15:14   ` [Uboot-stm32] " Patrick DELAUNAY
@ 2021-03-12 12:18     ` Patrice CHOTARD
  0 siblings, 0 replies; 13+ messages in thread
From: Patrice CHOTARD @ 2021-03-12 12:18 UTC (permalink / raw)
  To: u-boot

Hi

On 1/27/21 4:14 PM, Patrick DELAUNAY wrote:
> Hi Patrice,
> 
> On 1/20/21 2:42 PM, Patrice Chotard wrote:
>> In case of big area write/erase on spi nor, watchdog timeout may occurs.
>> Issue reproduced on stm32mp157c-ev1 with following commands:
>>
>> sf write 0xC0000000 0 0x3000000
>> or
>> sf erase 0 0x1000000
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
>> ---
>>
>> ? drivers/mtd/spi/spi-nor-core.c | 3 +++
>> ? 1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
>> index eb49a6c11c..51e0613d4c 100644
>> --- a/drivers/mtd/spi/spi-nor-core.c
>> +++ b/drivers/mtd/spi/spi-nor-core.c
>> @@ -10,6 +10,7 @@
>> ?? */
>> ? ? #include <common.h>
>> +#include <watchdog.h>
>> ? #include <linux/err.h>
>> ? #include <linux/errno.h>
>> ? #include <linux/log2.h>
>> @@ -557,6 +558,7 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
>> ????? len = instr->len;
>> ? ????? while (len) {
>> +??????? WATCHDOG_RESET();
>> ? #ifdef CONFIG_SPI_FLASH_BAR
>> ????????? ret = write_bar(nor, addr);
>> ????????? if (ret < 0)
>> @@ -1235,6 +1237,7 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
>> ????? for (i = 0; i < len; ) {
>> ????????? ssize_t written;
>> ????????? loff_t addr = to + i;
>> +??????? WATCHDOG_RESET();
>> ? ????????? /*
>> ?????????? * If page_size is a power of two, the offset can be quickly
> 
> 
> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> 
> Thanks
> 
> Patrick
> 
> 

Applied to u-boot-stm/next

Thanks

Patrice

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

* [Uboot-stm32] [PATCH 2/4] spi: stm32_qspi: Add WATCHDOG_RESET in _stm32_qspi_read_fifo()
  2021-01-27 15:15   ` [Uboot-stm32] " Patrick DELAUNAY
@ 2021-03-12 12:18     ` Patrice CHOTARD
  0 siblings, 0 replies; 13+ messages in thread
From: Patrice CHOTARD @ 2021-03-12 12:18 UTC (permalink / raw)
  To: u-boot

Hi

On 1/27/21 4:15 PM, Patrick DELAUNAY wrote:
> Hi Patrice
> 
> On 1/20/21 2:42 PM, Patrice Chotard wrote:
>> In case of reading large area and memory-map mode is misconfigured
>> (memory-map size declared lower than the real size of the memory chip)
>> watchdog can be triggered.
>>
>> Add WATCHDOG_RESET() in _stm32_qspi_read_fifo to fix it.
>>
>> Issue reproduced with stm32mp157c-ev1 board and memory map size set to
>> 1, with following command:
>> sf read 0xC0000000 0 0x4000000
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
>> ---
>>
>> ? drivers/spi/stm32_qspi.c | 2 ++
>> ? 1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/spi/stm32_qspi.c b/drivers/spi/stm32_qspi.c
>> index 958c394a1a..c3da17f991 100644
>> --- a/drivers/spi/stm32_qspi.c
>> +++ b/drivers/spi/stm32_qspi.c
>> @@ -11,6 +11,7 @@
>> ? #include <clk.h>
>> ? #include <reset.h>
>> ? #include <spi-mem.h>
>> +#include <watchdog.h>
>> ? #include <linux/iopoll.h>
>> ? #include <linux/ioport.h>
>> ? #include <linux/sizes.h>
>> @@ -163,6 +164,7 @@ static int _stm32_qspi_wait_cmd(struct stm32_qspi_priv *priv,
>> ? static void _stm32_qspi_read_fifo(u8 *val, void __iomem *addr)
>> ? {
>> ????? *val = readb(addr);
>> +??? WATCHDOG_RESET();
>> ? }
>> ? ? static void _stm32_qspi_write_fifo(u8 *val, void __iomem *addr)
> 
> 
> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> 
> Thanks
> 
> Patrick
> 
Applied to u-boot-stm/next

Thanks

Patrice

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

* [Uboot-stm32] [PATCH 3/4] mtd: nand: Add WATCHDOG_RESET() in nanddev_mtd_erase()
  2021-01-27 15:15   ` [Uboot-stm32] " Patrick DELAUNAY
@ 2021-03-12 12:19     ` Patrice CHOTARD
  0 siblings, 0 replies; 13+ messages in thread
From: Patrice CHOTARD @ 2021-03-12 12:19 UTC (permalink / raw)
  To: u-boot

Hi

On 1/27/21 4:15 PM, Patrick DELAUNAY wrote:
> Hi Patrice,
> 
> On 1/20/21 2:42 PM, Patrice Chotard wrote:
>> In case of big area erased on nand, watchdog timeout may occurs.
>> To fix that, add WATCHDOG_RESET() in nanddev_mtd_erase() to ensure that
>> watchdog is reset.
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
>> ---
>>
>> ? drivers/mtd/nand/core.c | 2 ++
>> ? 1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/mtd/nand/core.c b/drivers/mtd/nand/core.c
>> index 3abaef23c5..ec11bf44f8 100644
>> --- a/drivers/mtd/nand/core.c
>> +++ b/drivers/mtd/nand/core.c
>> @@ -10,6 +10,7 @@
>> ? #define pr_fmt(fmt)??? "nand: " fmt
>> ? ? #include <common.h>
>> +#include <watchdog.h>
>> ? #ifndef __UBOOT__
>> ? #include <linux/module.h>
>> ? #endif
>> @@ -162,6 +163,7 @@ int nanddev_mtd_erase(struct mtd_info *mtd, struct erase_info *einfo)
>> ????? nanddev_offs_to_pos(nand, einfo->addr, &pos);
>> ????? nanddev_offs_to_pos(nand, einfo->addr + einfo->len - 1, &last);
>> ????? while (nanddev_pos_cmp(&pos, &last) <= 0) {
>> +??????? WATCHDOG_RESET();
>> ????????? ret = nanddev_erase(nand, &pos);
>> ????????? if (ret) {
>> ????????????? einfo->fail_addr = nanddev_pos_to_offs(nand, &pos);
> 
> 
> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> 
> Thanks
> 
> Patrick
> 
Applied to u-boot-stm/next

Thanks

Patrice

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

* [Uboot-stm32] [PATCH 4/4] mtd: spinand: Add WATCHDOG_RESET() in spinand_mtd_read/write()
  2021-01-27 15:19   ` [Uboot-stm32] " Patrick DELAUNAY
@ 2021-03-12 12:19     ` Patrice CHOTARD
  0 siblings, 0 replies; 13+ messages in thread
From: Patrice CHOTARD @ 2021-03-12 12:19 UTC (permalink / raw)
  To: u-boot

Hi

On 1/27/21 4:19 PM, Patrick DELAUNAY wrote:
> Hi,
> 
> On 1/20/21 2:42 PM, Patrice Chotard wrote:
>> In case of big area read/write on spi nand, watchdog timeout may occurs.
>> To fix that, add WATCHDOG_RESET() in spinand_mtd_read() and
>> spinand_mtd_write() to ensure that watchdog is reset.
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
>>
>> ---
>>
>> ? drivers/mtd/nand/spi/core.c | 3 +++
>> ? 1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
>> index cb8ffa3fa9..7f54422c93 100644
>> --- a/drivers/mtd/nand/spi/core.c
>> +++ b/drivers/mtd/nand/spi/core.c
>> @@ -24,6 +24,7 @@
>> ? #include <errno.h>
>> ? #include <spi.h>
>> ? #include <spi-mem.h>
>> +#include <watchdog.h>
>> ? #include <linux/mtd/spinand.h>
>> ? #endif
>> ? @@ -574,6 +575,7 @@ static int spinand_mtd_read(struct mtd_info *mtd, loff_t from,
>> ? #endif
>> ? ????? nanddev_io_for_each_page(nand, from, ops, &iter) {
>> +??????? WATCHDOG_RESET();
>> ????????? ret = spinand_select_target(spinand, iter.req.pos.target);
>> ????????? if (ret)
>> ????????????? break;
>> @@ -625,6 +627,7 @@ static int spinand_mtd_write(struct mtd_info *mtd, loff_t to,
>> ? #endif
>> ? ????? nanddev_io_for_each_page(nand, to, ops, &iter) {
>> +??????? WATCHDOG_RESET();
>> ????????? ret = spinand_select_target(spinand, iter.req.pos.target);
>> ????????? if (ret)
>> ????????????? break;
> 
> 
> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> 
> Thanks
> 
> Patrick
> 
> 
Applied to u-boot-stm/next

Thanks

Patrice

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

end of thread, other threads:[~2021-03-12 12:19 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-20 13:42 [PATCH 0/4] Add WATCHDOG_RESET() in MTD framework and STM32 QSPI driver Patrice Chotard
2021-01-20 13:42 ` [PATCH 1/4] mtd: spi-nor: Add WATCHDOG_RESET() in spi_nor_core callbacks Patrice Chotard
2021-01-27 15:14   ` [Uboot-stm32] " Patrick DELAUNAY
2021-03-12 12:18     ` Patrice CHOTARD
2021-01-20 13:42 ` [PATCH 2/4] spi: stm32_qspi: Add WATCHDOG_RESET in _stm32_qspi_read_fifo() Patrice Chotard
2021-01-27 15:15   ` [Uboot-stm32] " Patrick DELAUNAY
2021-03-12 12:18     ` Patrice CHOTARD
2021-01-20 13:42 ` [PATCH 3/4] mtd: nand: Add WATCHDOG_RESET() in nanddev_mtd_erase() Patrice Chotard
2021-01-27 15:15   ` [Uboot-stm32] " Patrick DELAUNAY
2021-03-12 12:19     ` Patrice CHOTARD
2021-01-20 13:42 ` [PATCH 4/4] mtd: spinand: Add WATCHDOG_RESET() in spinand_mtd_read/write() Patrice Chotard
2021-01-27 15:19   ` [Uboot-stm32] " Patrick DELAUNAY
2021-03-12 12:19     ` 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.