mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xiaobing Luo <luoxiaobing0926@gmail.com>
To: richard@nod.at, miquel.raynal@bootlin.com, vigneshr@ti.com,
	mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com
Cc: linux-mtd@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-kernel@vger.kernel.org,
	Xiaobing Luo <luoxiaobing0926@gmail.com>
Subject: [PATCH] ubi: fastmap: Reserve PEBs and init fm_work when fastmap is used.
Date: Tue, 11 Apr 2023 15:46:34 +0000	[thread overview]
Message-ID: <20230411154634.149350-1-luoxiaobing0926@gmail.com> (raw)

Don't reserve the two fastmap PEBs when fastmap is disabled, then we can
use the two PEBs in small ubi device.
And don't init the fm_work when fastmap is disabled.

Signed-off-by: Xiaobing Luo <luoxiaobing0926@gmail.com>
---
 drivers/mtd/ubi/build.c      | 3 ++-
 drivers/mtd/ubi/fastmap-wl.c | 2 +-
 drivers/mtd/ubi/wl.c         | 6 +++++-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index ad025b2ee417..a98a717b0e66 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -1120,7 +1120,8 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
 		kthread_stop(ubi->bgt_thread);
 
 #ifdef CONFIG_MTD_UBI_FASTMAP
-	cancel_work_sync(&ubi->fm_work);
+	if (!ubi->fm_disabled)
+		cancel_work_sync(&ubi->fm_work);
 #endif
 	ubi_debugfs_exit_dev(ubi);
 	uif_close(ubi);
diff --git a/drivers/mtd/ubi/fastmap-wl.c b/drivers/mtd/ubi/fastmap-wl.c
index 863f571f1adb..b3df17a782c7 100644
--- a/drivers/mtd/ubi/fastmap-wl.c
+++ b/drivers/mtd/ubi/fastmap-wl.c
@@ -344,7 +344,7 @@ static struct ubi_wl_entry *get_peb_for_wl(struct ubi_device *ubi)
 		/* We cannot update the fastmap here because this
 		 * function is called in atomic context.
 		 * Let's fail here and refill/update it as soon as possible. */
-		if (!ubi->fm_work_scheduled) {
+		if (!ubi->fm_work_scheduled && !ubi->fm_disabled) {
 			ubi->fm_work_scheduled = 1;
 			schedule_work(&ubi->fm_work);
 		}
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 26a214f016c1..8906db89808f 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -1908,7 +1908,11 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai)
 	ubi_assert(ubi->good_peb_count == found_pebs);
 
 	reserved_pebs = WL_RESERVED_PEBS;
-	ubi_fastmap_init(ubi, &reserved_pebs);
+
+#ifdef CONFIG_MTD_UBI_FASTMAP
+	if (!ubi->fm_disabled)
+		ubi_fastmap_init(ubi, &reserved_pebs);
+#endif
 
 	if (ubi->avail_pebs < reserved_pebs) {
 		ubi_err(ubi, "no enough physical eraseblocks (%d, need %d)",
-- 
2.34.1


             reply	other threads:[~2023-04-11 15:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-11 15:46 Xiaobing Luo [this message]
2023-04-12  1:53 ` Zhihao Cheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230411154634.149350-1-luoxiaobing0926@gmail.com \
    --to=luoxiaobing0926@gmail.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®