Re: [RFC] mtd: ubi: skip programming unused bits in ubi headers

From: Richard Weinberger
Date: Tue Aug 12 2025 - 02:57:28 EST


----- Ursprüngliche Mail -----
> Von: "Cheng Ming Lin" <linchengming884@xxxxxxxxx>
> An: "richard" <richard@xxxxxx>, "chengzhihao1" <chengzhihao1@xxxxxxxxxx>, "Miquel Raynal" <miquel.raynal@xxxxxxxxxxx>,
> "Vignesh Raghavendra" <vigneshr@xxxxxx>, "linux-mtd" <linux-mtd@xxxxxxxxxxxxxxxxxxx>, "linux-kernel"
> <linux-kernel@xxxxxxxxxxxxxxx>
> CC: "Alvin Zhou" <alvinzhou@xxxxxxxxxxx>, leoyu@xxxxxxxxxxx, "Cheng Ming Lin" <chengminglin@xxxxxxxxxxx>
> Gesendet: Dienstag, 12. August 2025 07:19:49
> Betreff: [RFC] mtd: ubi: skip programming unused bits in ubi headers

> From: Cheng Ming Lin <chengminglin@xxxxxxxxxxx>
>
> This patch prevents unnecessary programming of bits in ec_hdr and
> vid_hdr that are not used or read during normal UBI operation. These
> unused bits are typically already set to 1 in erased flash and do not
> need to be explicitly programmed to 0 if they are not used.
>
> Programming such unused areas offers no functional benefit and may
> result in unnecessary flash wear, reducing the overall lifetime of the
> device. By skipping these writes, we preserve the flash state as much
> as possible and minimize wear caused by redundant operations.

We talk about programming a single (sub)page, right?

> This change ensures that only necessary fields are written when
> preparing UBI headers, improving flash efficiency without affecting
> functionality.

I have been told that writing 0xFF bytes to NAND should be avoided.
This is also why UBI initializes them to 0x00.

Do you have data which proves the opposite?

Thanks,
//richard