From 2920b6bde862e98acd0a711ddda0756360d037c5 Mon Sep 17 00:00:00 2001 From: Jon Lin Date: Tue, 3 Jun 2025 16:25:05 +0800 Subject: [PATCH] ubi: Change to fill ec_hdr and vid_hdr redundant space with ff data on rockchip These hdr data is place in first two pages in the front of flash block, most of the data is filled with 0 which may result in 0/1 data unbalance and finally accelerate the data bit flip process. So using ff redundant data pattern for data balancing is more stable for nand devices. Change-Id: I77a9116a4575b94bc6e4da5334db4eaf3d8bcb83 Signed-off-by: Jon Lin --- drivers/mtd/ubi/io.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c index 7115e7f32ed4..f22a38cf42d2 100644 --- a/drivers/mtd/ubi/io.c +++ b/drivers/mtd/ubi/io.c @@ -824,6 +824,14 @@ int ubi_io_write_ec_hdr(struct ubi_device *ubi, int pnum, if (ubi_dbg_power_cut(ubi, POWER_CUT_EC_WRITE)) return -EROFS; + if (IS_ENABLED(CONFIG_ARCH_ROCKCHIP)) { + /* + * All FF data is relatively friendly to the data retention capability of SPI + * Nand devices. + */ + memset((char *)ec_hdr + sizeof(struct ubi_ec_hdr), 0xFF, + ubi->ec_hdr_alsize - sizeof(struct ubi_ec_hdr)); + } err = ubi_io_write(ubi, ec_hdr, pnum, 0, ubi->ec_hdr_alsize); return err; } @@ -1074,6 +1082,14 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum, if (ubi_dbg_power_cut(ubi, POWER_CUT_VID_WRITE)) return -EROFS; + if (IS_ENABLED(CONFIG_ARCH_ROCKCHIP)) { + /* + * All FF data is relatively friendly to the data retention capability of SPI + * Nand devices. + */ + memset((char *)p + sizeof(struct ubi_vid_hdr), 0xFF, + ubi->vid_hdr_alsize - sizeof(struct ubi_vid_hdr)); + } err = ubi_io_write(ubi, p, pnum, ubi->vid_hdr_aloffset, ubi->vid_hdr_alsize); return err;