[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAyq3SZ33K4Ot8OgZnv1-CR5mJt0wNaPC55CMXMzpjbhBgiYOg@mail.gmail.com>
Date: Fri, 7 Nov 2025 16:28:23 +0800
From: Cheng Ming Lin <linchengming884@...il.com>
To: Miquel Raynal <miquel.raynal@...tlin.com>
Cc: richard@....at, chengzhihao1@...wei.com, vigneshr@...com,
linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org,
alvinzhou@...c.com.tw, leoyu@...c.com.tw,
Cheng Ming Lin <chengminglin@...c.com.tw>
Subject: Re: [PATCH 1/1] mtd: ubi: skip programming unused bits in ubi headers
Hi Miquel,
Miquel Raynal <miquel.raynal@...tlin.com> 於 2025年11月7日 週五 下午4:23寫道:
>
> Hello,
>
> >> > + if (ubi->vid_hdr_shift)
> >> > + memset((char *)p, 0xFF, ubi->vid_hdr_alsize - UBI_VID_HDR_SIZE);
> >> > + else
> >> > + memset((char *)p + UBI_VID_HDR_SIZE, 0xFF, ubi->vid_hdr_alsize - UBI_VID_HDR_SIZE);
> >>
> >> Here I am reaching the limits of my UBI knowledge, so I would prefer
> >> Richard to (in)validate what I am saying, but AFAIU, the VID header can
> >> be literally anywhere in the page, not just at the start or end of a
> >> subpage, so in the vid_hdr_shift I would expect some extra maths to
> >> happen, no?
> >
> > I understand your point now. If the VID header is not guaranteed to be
> > at the start or end of a subpage, then yes, my current logic needs to be
> > reworked to cover that case.
>
> I don't know if this is easy to do, but maybe you can memset the whole
> buffer before filling it. That would avoid the need to know where the
> VID header will be.
At this point I have two possible directions.
The first approach is to keep doing it in two parts, like:
memset((char *)p, 0xFF, ubi->vid_hdr_shift);
memset((char *)p + ubi->vid_hdr_shift + UBI_VID_HDR_SIZE, 0xFF,
ubi->vid_hdr_alsize - (ubi->vid_hdr_shift + UBI_VID_HDR_SIZE));
The second approach would be to modify ubi_init_vid_buf() in ubi/ubi.h,
so that its memset fills the buffer with 0xFF from the beginning.
The second one is cleaner, but ubi_init_vid_buf() is not always called
before ubi_io_write_vid_hdr(), so I am checking right now whether this
would affect other paths.
>
> Thanks,
> Miquèl
Thanks,
Cheng Ming Lin
Powered by blists - more mailing lists