All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: ubi: io: add retries mtd_write
@ 2021-09-01  8:56 Sean Nyekjaer
  2021-09-20  7:48 ` Sean Nyekjaer
  0 siblings, 1 reply; 2+ messages in thread
From: Sean Nyekjaer @ 2021-09-01  8:56 UTC (permalink / raw)
  To: richard, boris.brezillon, miquel.raynal; +Cc: Sean Nyekjaer, linux-mtd

Fix "Device or resource busy" when resuming from suspend. Sometimes ubi
tries to call mtd_write before the rawnand is resumed.

So add 3 retries to the mtd_write call:
PM: suspend devices took 0.030 seconds
ubi0 warning: ubi_io_write: error -16 while writing 4096 bytes to PEB 1762:94208, written 0 bytes
Disabling non-boot CPUs ...
ubi0 warning: ubi_io_write: error -16 while writing 4096 bytes to PEB 1762:94208, written 0 bytes
ubi0 warning: ubi_io_write: error -16 while writing 4096 bytes to PEB 1762:94208, written 0 bytes
PM: resume devices took 0.110 seconds
OOM killer enabled.
Restarting tasks ... done.
PM: suspend exit

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
---

Some explanation/discussion here:
http://lists.infradead.org/pipermail/linux-mtd/2021-July/087390.html

 drivers/mtd/ubi/io.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index 0e3a76a9e2f8..fc01ee429358 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -89,6 +89,7 @@
 #include <linux/crc32.h>
 #include <linux/err.h>
 #include <linux/slab.h>
+#include <linux/delay.h>
 #include "ubi.h"
 
 static int self_check_not_bad(const struct ubi_device *ubi, int pnum);
@@ -235,7 +236,7 @@ int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset,
 int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
 		 int len)
 {
-	int err;
+	int err, retries = 0;
 	size_t written;
 	loff_t addr;
 
@@ -281,8 +282,16 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
 	}
 
 	addr = (loff_t)pnum * ubi->peb_size + offset;
+retry:
 	err = mtd_write(ubi->mtd, addr, len, &written, buf);
 	if (err) {
+		if (retries++ < UBI_IO_RETRIES) {
+			ubi_warn(ubi, "error %d while writing %d bytes to PEB %d:%d, written %zd bytes",
+				 err, len, pnum, offset, written);
+			mdelay(10); yield();
+			goto retry;
+		}
+
 		ubi_err(ubi, "error %d while writing %d bytes to PEB %d:%d, written %zd bytes",
 			err, len, pnum, offset, written);
 		dump_stack();
-- 
2.33.0


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] mtd: ubi: io: add retries mtd_write
  2021-09-01  8:56 [PATCH] mtd: ubi: io: add retries mtd_write Sean Nyekjaer
@ 2021-09-20  7:48 ` Sean Nyekjaer
  0 siblings, 0 replies; 2+ messages in thread
From: Sean Nyekjaer @ 2021-09-20  7:48 UTC (permalink / raw)
  To: richard, boris.brezillon, miquel.raynal; +Cc: linux-mtd

On Wed, Sep 01, 2021 at 10:56:37AM +0200, Sean Nyekjaer wrote:
> Fix "Device or resource busy" when resuming from suspend. Sometimes ubi
> tries to call mtd_write before the rawnand is resumed.
> 
> So add 3 retries to the mtd_write call:
> PM: suspend devices took 0.030 seconds
> ubi0 warning: ubi_io_write: error -16 while writing 4096 bytes to PEB 1762:94208, written 0 bytes
> Disabling non-boot CPUs ...
> ubi0 warning: ubi_io_write: error -16 while writing 4096 bytes to PEB 1762:94208, written 0 bytes
> ubi0 warning: ubi_io_write: error -16 while writing 4096 bytes to PEB 1762:94208, written 0 bytes
> PM: resume devices took 0.110 seconds
> OOM killer enabled.
> Restarting tasks ... done.
> PM: suspend exit
> 
> Signed-off-by: Sean Nyekjaer <sean@geanix.com>
> ---
> 
> Some explanation/discussion here:
> http://lists.infradead.org/pipermail/linux-mtd/2021-July/087390.html
> 

This is still an issue... Anyway to block ubi from accessing a suspended
rawnand?

Richard do you have an idea to solve this?

/Sean

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

end of thread, other threads:[~2021-09-20  7:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-01  8:56 [PATCH] mtd: ubi: io: add retries mtd_write Sean Nyekjaer
2021-09-20  7:48 ` Sean Nyekjaer

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.