Re: [PATCH 2/2] UBI: support per-device wear-leveling threshold

From: Zhihao Cheng

Date: Wed Jul 22 2026 - 23:04:57 EST


在 2026/7/23 10:02, Ran Hongyun 写道:
The UBI wear-leveling threshold (CONFIG_MTD_UBI_WL_THRESHOLD) is
currently a compile-time constant shared by all UBI devices. When a
single kernel image must support multiple NAND flashes with different
erase lifetimes, one global threshold cannot suit all devices.

Add a per-device configurable wl_threshold parameter:

- UAPI: add __s32 wl_threshold to struct ubi_attach_req, carved
from the existing padding.

- Module parameter: ubi.mtd gains a new optional token
"wl_threshold":
ubi.mtd=0,0,0,0,0,0,256 ubi.mtd=1,0,0,0,0,0,4096

0 means "use the kernel default", the accepted range is
2-65536.

Signed-off-by: Ran Hongyun <ranhongyun1@xxxxxxxxxx>
---
drivers/mtd/ubi/build.c | 43 ++++++++++++++++++++++++++++++------
drivers/mtd/ubi/cdev.c | 2 +-
drivers/mtd/ubi/fastmap-wl.c | 8 +++----
drivers/mtd/ubi/ubi.h | 21 +++++++++++++++++-
drivers/mtd/ubi/wl.c | 39 ++++++++------------------------
include/uapi/mtd/ubi-user.h | 10 ++++++++-
6 files changed, 79 insertions(+), 44 deletions(-)


Reviewed-by: Zhihao Cheng <chengzhihao1@xxxxxxxxxx>