devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Philipp Zabel <p.zabel@pengutronix.de>
Cc: devicetree-compiler@vger.kernel.org, Rob Herring <robh@kernel.org>
Subject: Re: [PATCH] checks: Relax avoid_unnecessary_addr_size check to allow child ranges properties
Date: Mon, 28 Oct 2024 13:42:01 +1100	[thread overview]
Message-ID: <Zx75-Y1WfBran1nV@zatzit> (raw)
In-Reply-To: <20241025161307.3629901-1-p.zabel@pengutronix.de>

[-- Attachment #1: Type: text/plain, Size: 2746 bytes --]

On Fri, Oct 25, 2024 at 06:13:07PM +0200, Philipp Zabel wrote:
> Do not fail the unnecessary #address-cells/#size-cells check if any
> children of the node have a "ranges" property.

I think this is correct, but I had to think abuot it for a while,
because it's subtler than it looks.

If there is no 'ranges' in the node itself, then the child devices'
address space is not mapped into the parent bus.  Of course, you can
still establish a local address space for them that (e.g.) could be
accessed indirectly via registers in this bridge device.

Having a child device which acts as a bridge from this local address
to another subordinate address space, but no children with any
registers directly on the local bus seems odd... but it is logically
possible.

Given the subtlety, it would be pretty nice to add an explanatory
comment about what this is check for and what some of the edge cases
are.


> Suggested-by: Rob Herring <robh@kernel.org>
> Link: https://lore.kernel.org/all/CAL_JsqKebRL454poAYZ9i=sCsHqGzmocLy0psQcng-79UWJB-A@mail.gmail.com/
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
>  checks.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/checks.c b/checks.c
> index 6e06aeab5503..76fdee2ed030 100644
> --- a/checks.c
> +++ b/checks.c
> @@ -1217,9 +1217,7 @@ WARNING(avoid_default_addr_size, check_avoid_default_addr_size, NULL,
>  static void check_avoid_unnecessary_addr_size(struct check *c, struct dt_info *dti,
>  					      struct node *node)
>  {
> -	struct property *prop;
>  	struct node *child;
> -	bool has_reg = false;
>  
>  	if (!node->parent || node->addr_cells < 0 || node->size_cells < 0)
>  		return;
> @@ -1228,13 +1226,11 @@ static void check_avoid_unnecessary_addr_size(struct check *c, struct dt_info *d
>  		return;
>  
>  	for_each_child(node, child) {
> -		prop = get_property(child, "reg");
> -		if (prop)
> -			has_reg = true;
> +		if (get_property(child, "reg") || get_property(child, "ranges"))
> +			return;
>  	}
>  
> -	if (!has_reg)
> -		FAIL(c, dti, node, "unnecessary #address-cells/#size-cells without \"ranges\", \"dma-ranges\" or child \"reg\" property");
> +	FAIL(c, dti, node, "unnecessary #address-cells/#size-cells without \"ranges\", \"dma-ranges\" or child \"reg\" property");

..also this message needs updating to reference child "ranges" as well.

>  }
>  WARNING(avoid_unnecessary_addr_size, check_avoid_unnecessary_addr_size, NULL, &avoid_default_addr_size);
>  

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2024-10-28  2:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-25 16:13 [PATCH] checks: Relax avoid_unnecessary_addr_size check to allow child ranges properties Philipp Zabel
2024-10-28  2:42 ` David Gibson [this message]
2024-11-04 13:32   ` Philipp Zabel
2024-11-05 23:55     ` David Gibson
2024-11-06 13:23       ` Philipp Zabel
2024-11-06 21:16         ` David Gibson

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=Zx75-Y1WfBran1nV@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=devicetree-compiler@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    /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).