From patchwork Wed Sep 1 08:56:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Nyekjaer X-Patchwork-Id: 1523003 X-Patchwork-Delegate: richard@nod.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=E5HUsAPg; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=geanix.com header.i=@geanix.com header.a=rsa-sha256 header.s=first header.b=ASSjxemD; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GzzbX5TvSz9sW8 for ; Wed, 1 Sep 2021 19:41:43 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=yiQAN9oILwEmtEB3wB7SEhvRM/vM3dq1DqRGVLYVD+I=; b=E5HUsAPg0kaG5E 3CElUaFwl27+oHMLmqw874flkAj9MTNT4l3CuwpzflfrpKiP1CT30PA82L4qGvMquT9FLKZo08Nex XQMQyrDWH91VEtHOqVyDdWaqnJwdfQag8sB0TGZ31S7IWi0JTJFstuAIrh1wLuxbijOMuc/3vCGdi 8eF7xsu9Ey3MHQDNy9g3gICJhq7WTYPvqRQsjS8QURQFAqkdKgcHkwOnaZ76/bKdb8sUeldHY8VxB 2R9kf2aXLySiCL89oUURS/ZvQaHh9g1a8b/bmA5Ww2vmSP+jsB4eBGi6sD0DGQYciXM0HwNp8NpmC icYVyPyo5zO7LNjSc2pg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mLMjc-004xDl-ML; Wed, 01 Sep 2021 09:40:44 +0000 Received: from first.geanix.com ([116.203.34.67]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mLM31-004h4O-4s for linux-mtd@lists.infradead.org; Wed, 01 Sep 2021 08:56:47 +0000 Received: from zen.. (unknown [185.17.218.86]) by first.geanix.com (Postfix) with ESMTPSA id AA76C440F5F; Wed, 1 Sep 2021 08:56:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=geanix.com; s=first; t=1630486600; bh=TxjzjQtf4bQ+evPXvTO3z5LgUgh5BSHhEV02iklQWMU=; h=From:To:Cc:Subject:Date; b=ASSjxemDoZ/T3V6EMtzKnHSeX3Z5R1hH/nbwbDF157qqVl4dWHCfcUgg4Pzjiax1C w1LwntMqdHiIWZbX9uA9dBydFK5BdTPR47gXea1/0izeFZussiuiMejg9yaVtYqmF8 bRPXkVFpiPEwluXHnM2wmqc7bNeoDRXOqorhXRKZ+CuagXsJbNQwv49WlepSakKxPr sdXUlkIn43/gfgiAHYj5eI23jUwFhSP/duw+gqRkUVe6gmW8BJHaLNiZ22a1cTQxJy AiIj9s/BqlxSTez4rIeBrRoU3ZSisqqMDYBk9InL3vFlvS9zxhSfpZL0MHxR3TbH73 +pu1PPvCZNAMA== From: Sean Nyekjaer To: richard@nod.at, boris.brezillon@bootlin.com, miquel.raynal@bootlin.com Cc: Sean Nyekjaer , linux-mtd@lists.infradead.org Subject: [PATCH] mtd: ubi: io: add retries mtd_write Date: Wed, 1 Sep 2021 10:56:37 +0200 Message-Id: <20210901085637.210572-1-sean@geanix.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-Spam-Status: No, score=-3.1 required=4.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED autolearn=disabled version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on 13e2a5895688 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210901_015643_414424_D833C5E1 X-CRM114-Status: GOOD ( 13.22 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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 [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 --- 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 #include #include +#include #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();