From: Yuntao Wang <yuntao.wang@linux.dev>
To: robh@kernel.org
Cc: akpm@linux-foundation.org, bhe@redhat.com,
catalin.marinas@arm.com, changyuanl@google.com,
chenzhou10@huawei.com, devicetree@vger.kernel.org,
geert+renesas@glider.be, graf@amazon.com, james.morse@arm.com,
linux-kernel@vger.kernel.org, rppt@kernel.org,
saravanak@google.com, takahiro.akashi@linaro.org,
thunder.leizhen@huawei.com, yuntao.wang@linux.dev
Subject: Re: [PATCH 00/10] of/fdt: Some bug fixes and cleanups
Date: Fri, 14 Nov 2025 00:00:20 +0800 [thread overview]
Message-ID: <20251113160020.227664-1-yuntao.wang@linux.dev> (raw)
In-Reply-To: <20251112205551.GC2155854-robh@kernel.org>
On Wed, 12 Nov 2025 14:55:51 -0600, Rob Herring <robh@kernel.org> wrote:
> On Wed, Nov 12, 2025 at 10:35:10PM +0800, Yuntao Wang wrote:
> > This patch series fixes several bugs related to dt_root_addr_cells and
> > dt_root_size_cells, and performs some cleanup.
> >
> > Links to the previous related patches:
> >
> > https://lore.kernel.org/lkml/CAL_JsqJxar7z+VcBXwPTw5-Et2oC9bQmH_CtMtKhoo_-=zN2XQ@mail.gmail.com/
> >
> > Yuntao Wang (10):
> > of/fdt: Introduce dt_root_addr_size_cells() and
> > dt_root_addr_size_bytes()
> > of/reserved_mem: Use dt_root_addr_size_bytes() instead of open-coding
> > it
> > of/reserved_mem: Use dt_root_addr_size_bytes() instead of open-coding
> > it
> > of/reserved_mem: Use dt_root_addr_size_bytes() instead of open-coding
> > it
>
> Your aim in writing subjects should be to write something that is unique
> for every commit in the past or future. Because you can never make the
> same change twice, right? (I'm excluding 'fix typos/spelling' type
> commits). Certainly the same subject in one series is never right.
>
> > of/fdt: Use dt_root_addr_size_bytes() instead of open-coding it
> > of/fdt: Fix the len check in early_init_dt_check_for_elfcorehdr()
> > of/fdt: Fix the len check in
> > early_init_dt_check_for_usable_mem_range()
> > of/fdt: Use dt_root_addr_size_bytes() instead of open-coding it
>
> This is not what I meant. We have multiple copies of this where only
> the property name changes:
>
> prop = of_get_flat_dt_prop(node, "linux,elfcorehdr", &len);
> if (!prop || (len < (dt_root_addr_cells + dt_root_size_cells)))
> return;
>
> elfcorehdr_addr = dt_mem_next_cell(dt_root_addr_cells, &prop);
> elfcorehdr_size = dt_mem_next_cell(dt_root_size_cells, &prop);
>
> Instead, add a function something like this:
>
> static void early_init_dt_read_address(unsigned long node, const char
> *prop, u64 *addr, u64*size)
> {
> prop = of_get_flat_dt_prop(node, prop, &len);
> if (!prop || (len < (dt_root_addr_cells + dt_root_size_cells)))
> return;
>
> *addr = dt_mem_next_cell(dt_root_addr_cells, &prop);
> *size = dt_mem_next_cell(dt_root_size_cells, &prop);
> }
>
> Then we only have the length checks in one place.
>
>
> That still leaves the cases with more than 1 entry open coded. So
> instead, to cover that case to something like this:
>
> const __be32 *of_get_flat_dt_address_prop(unsigned long node, const char
> *propname, int *len)
> {
> prop = of_get_flat_dt_prop(node, propname, &len);
> if (!prop || (*len % (dt_root_addr_cells + dt_root_size_cells))) {
> *len = 0;
> return NULL;
> }
>
> *len /= (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32);
> return prop;
> }
>
> And then a user would look something like this:
>
> prop = of_get_flat_dt_address(node, "linux,usable-memory-range", &len);
> for (i = 0; i < len; i++) {
> of_read_address_idx(prop, i, &addr, &size);
> ...
> }
>
> Here 'len' is number of addr+size entries.
>
> And the simple case of reading 1 entry could be just:
>
> of_read_address_idx(of_get_flat_dt_address(node, "linux,elfcorehdr", NULL), 0, &addr, &size);
>
> Rob
Hi Rob,
The link to the new patch series:
https://lore.kernel.org/linux-devicetree/20251113155104.226617-1-yuntao.wang@linux.dev/t/
Thanks,
Yuntao
prev parent reply other threads:[~2025-11-13 16:00 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-12 14:35 [PATCH 00/10] of/fdt: Some bug fixes and cleanups Yuntao Wang
2025-11-12 14:35 ` [PATCH 01/10] of/fdt: Introduce dt_root_addr_size_cells() and dt_root_addr_size_bytes() Yuntao Wang
2025-11-12 16:25 ` Geert Uytterhoeven
2025-11-12 14:35 ` [PATCH 02/10] of/reserved_mem: Use dt_root_addr_size_bytes() instead of open-coding it Yuntao Wang
2025-11-12 16:28 ` Geert Uytterhoeven
2025-11-12 14:35 ` [PATCH 03/10] " Yuntao Wang
2025-11-12 16:29 ` Geert Uytterhoeven
2025-11-12 14:35 ` [PATCH 04/10] " Yuntao Wang
2025-11-12 16:30 ` Geert Uytterhoeven
2025-11-13 14:21 ` kernel test robot
2025-11-13 23:46 ` kernel test robot
2025-11-12 14:35 ` [PATCH 05/10] of/fdt: " Yuntao Wang
2025-11-12 16:32 ` Geert Uytterhoeven
2025-11-12 14:35 ` [PATCH 06/10] of/fdt: Fix the len check in early_init_dt_check_for_elfcorehdr() Yuntao Wang
2025-11-12 14:35 ` [PATCH 07/10] of/fdt: Fix the len check in early_init_dt_check_for_usable_mem_range() Yuntao Wang
2025-11-12 16:47 ` Geert Uytterhoeven
2025-11-12 14:35 ` [PATCH 08/10] of/fdt: Use dt_root_addr_size_bytes() instead of open-coding it Yuntao Wang
2025-11-12 16:33 ` Geert Uytterhoeven
2025-11-12 14:35 ` [PATCH 09/10] of/fdt: Fix incorrect use of dt_root_addr_cells in early_init_dt_check_kho() Yuntao Wang
2025-11-12 16:54 ` Geert Uytterhoeven
2025-11-12 14:35 ` [PATCH 10/10] of/address: Remove the incorrect and misleading comment Yuntao Wang
2025-11-12 16:56 ` Geert Uytterhoeven
2025-11-12 20:07 ` Rob Herring
2025-11-12 20:08 ` Rob Herring
2025-11-12 20:55 ` [PATCH 00/10] of/fdt: Some bug fixes and cleanups Rob Herring
2025-11-13 16:00 ` Yuntao Wang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251113160020.227664-1-yuntao.wang@linux.dev \
--to=yuntao.wang@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=bhe@redhat.com \
--cc=catalin.marinas@arm.com \
--cc=changyuanl@google.com \
--cc=chenzhou10@huawei.com \
--cc=devicetree@vger.kernel.org \
--cc=geert+renesas@glider.be \
--cc=graf@amazon.com \
--cc=james.morse@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=rppt@kernel.org \
--cc=saravanak@google.com \
--cc=takahiro.akashi@linaro.org \
--cc=thunder.leizhen@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).