[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a6acb300-7333-d3b6-f1c5-f0ad5d6c744b@huawei.com>
Date: Fri, 14 Nov 2025 17:24:56 +0800
From: Zhihao Cheng <chengzhihao1@...wei.com>
To: Cheng Ming Lin <linchengming884@...il.com>, Miquel Raynal
<miquel.raynal@...tlin.com>
CC: <richard@....at>, <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 v2 1/1] mtd: ubi: skip programming unused bits in ubi
headers
在 2025/11/14 16:47, Cheng Ming Lin 写道:
> Hi Miquel,
>
> Miquel Raynal <miquel.raynal@...tlin.com> 於 2025年11月14日 週五 下午4:31寫道:
>>
>> Hi Cheng Ming,
>>
>>> @@ -1150,6 +1152,14 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum,
>>> return -EROFS;
>>> }
>>>
>>> + if (ubi->vid_hdr_shift) {
>>> + 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));
>>> + } else {
>>> + memset((char *)p + UBI_VID_HDR_SIZE, 0xFF, ubi->vid_hdr_alsize - UBI_VID_HDR_SIZE);
>>> + }
>>> +
>>
>> Is it not possible to memset() the buffer before writing the VID header?
>> I haven't found quickly a good place to do that, so in any case,
>
> If we want to memset() the buffer before writing the VID header, one
> possible option is to modify ubi_init_vid_buf() in
> drivers/mtd/ubi/ubi.h.
The ubi_init_vid_buf() is called in many reading processes, the solution
improves flash wearing for write situation, so I think doing memset in
ubi_io_write_vid_hdr() is fine.
>
> Specifically, we could replace the existing
> memset(buf, 0, ubi->vid_hdr_alsize) inside the "if (buf)" block with
> memset(buf, 0xff, ubi->vid_hdr_alsize). After the VID header
> position has been determined, we can then apply a second memset() on
> vidh->hdr to zero-initialize UBI_VID_HDR_SIZE. This approach should
> provide the same effect while ensuring that all fields inside the VID
> header are properly initialized to zero.
>
> Does this make sense to you? If this direction is preferable, I can
> prepare a v3 reflecting this change, and I will also run ubi-tests to
> verify the behavior. Thanks!
>
>>
>> Reviewed-by: Miquel Raynal <miquel.raynal@...tlin.com>
>>
>> Thanks,
>> Miquèl
>
> Thanks,
> Cheng Ming Lin
> .
>
Powered by blists - more mailing lists