From: Rob Herring <robh@kernel.org>
To: Saravana Kannan <saravanak@google.com>
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] of: Add missing locking to of_(bus_)?n_(size|addr)_cells()
Date: Tue, 4 Jun 2024 11:08:09 -0500 [thread overview]
Message-ID: <20240604160809.GA1060206-robh@kernel.org> (raw)
In-Reply-To: <20240530-dt-interrupt-map-fix-v1-2-2331d8732f08@kernel.org>
On Thu, May 30, 2024 at 08:03:28PM -0500, Rob Herring (Arm) wrote:
> When accessing parent/child/sibling pointers the DT spinlock needs to
> be held. The of_(bus_)?n_(size|addr)_cells() functions are missing that
> when walking up the parent nodes. In reality, it rarely matters as most
> nodes are static.
>
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> ---
> drivers/of/base.c | 18 ++++++++----------
> 1 file changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 20603d3c9931..61fff13bbee5 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -91,8 +91,8 @@ int of_bus_n_addr_cells(struct device_node *np)
> {
> u32 cells;
>
> - for (; np; np = np->parent)
> - if (!of_property_read_u32(np, "#address-cells", &cells))
> + for_each_parent_of_node_scoped(parent, np)
> + if (!of_property_read_u32(parent, "#address-cells", &cells))
> return cells;
>
> /* No #address-cells property for the root node */
> @@ -101,10 +101,9 @@ int of_bus_n_addr_cells(struct device_node *np)
>
> int of_n_addr_cells(struct device_node *np)
> {
> - if (np->parent)
> - np = np->parent;
This isn't going to work... This drops of_n_addr_cells working for the
root node. Callers wanting to get root node's properties need to use the
of_bus_n variant instead, so those callers will have to be checked and
fixed first.
Rob
next prev parent reply other threads:[~2024-06-04 16:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-31 1:03 [PATCH 0/3] of: Reimplement of_(bus_)?n_(size|addr)_cells() Rob Herring (Arm)
2024-05-31 1:03 ` [PATCH 1/3] of: Add an iterator to walk up parent nodes Rob Herring (Arm)
2024-05-31 1:03 ` [PATCH 2/3] of: Add missing locking to of_(bus_)?n_(size|addr)_cells() Rob Herring (Arm)
2024-06-04 16:08 ` Rob Herring [this message]
2024-05-31 1:03 ` [PATCH 3/3] of/irq: Use of_bus_n_addr_cells() to retrieve "#address-cells" Rob Herring (Arm)
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=20240604160809.GA1060206-robh@kernel.org \
--to=robh@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=saravanak@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.