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

Zhihao Cheng <[email protected]> Thu, 23 Jul 2026 11:01:06 +0800
Newsgroups gmane.linux.kernel,gmane.linux.drivers.mtd
Message-ID <[email protected]>
鍦 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 <[email protected]>
> ---
>   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 <[email protected]>