All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Rob Herring <robh@kernel.org>
Cc: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>,
	devicetree-compiler@vger.kernel.org
Subject: Re: [PATCH] checks: Warn about overlapping reserved-memory ranges
Date: Wed, 7 Oct 2026 15:58:49 +1100	[thread overview]
Message-ID: <asXRewO5DieggXrA@gractus.seuss> (raw)
In-Reply-To: <CAL_Jsq+niOW2c2ueTmTOwJ6EinFRHbJfKKDAjwxMwMP6drjP9g@mail.gmail.com>

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

On Thu, Oct 01, 2026 at 11:13:05AM -0500, Rob Herring wrote:
> On Wed, Sep 23, 2026 at 12:51 PM Bjorn Andersson
> <bjorn.andersson@oss.qualcomm.com> wrote:
> >
> > Static /reserved-memory entries associate physical address ranges with
> > particular purposes and properties. While not explicitly prohibited,
> > overlapping ranges commonly indicate an incorrect address or size and
> > may assign the same memory conflicting attributes. Dtc currently
> > provides no diagnostic for this type of mistake.
> >
> > Check every non-empty reg range under available reserved-memory children
> > and report overlaps. Add tests covering overlapping and adjacent ranges,
> > as well as unavailable, zero-sized, and dynamically allocated regions.
> 
> This issue is not just reserved memory, but any address really. 2 h/w
> nodes pointing to the same range points to a binding design problem.
> That gets a bit more complex to find since it might not be at the same
> level within the same subtree.

So.. that's kind of true, but I think we can examine it a bit more
closely.

One way to do the test would be to check for any overlaps between
either 'reg' properties or between the parent address parts of
'ranges' properties.  That works, and is sufficient when there are no
overlaps between either devices, or address ranges delegated to a
daughter bus via a bridge.  I suspect that's true in enough cases to
be useful as is.

Things get more complicated in cases where a large address range is
passed through a bridge - most often the entire bus address space
using an empty 'ranges' - but the range isn't exclusively delegated to
the subordinate bus.  That only makes sense with certain sorts of
bridge, but is also moderately common.

Perhaps this would be workable:

1st draft:
  * Check for overlaps between reg properties within a single parent
  * Check for overlaps in parent range between 'ranges' properties
    within a single parent (ignore empty 'ranges' nodes)
2nd draft:
  * Check for overlaps between 'reg' and 'ranges' parent range, still
    ignoring empty 'ranges' nodes
3rd draft:
  * When checking a single parent node, don't just check direct
    children, but also indirect descendents via nodes with empty
    'ranges'


> A check for that has been on my todo
> for a long time. I did have AI write something for me a while back
> that seemed to work. It also functioned as a DT to memory map tool
> given you check the entire address space. I'll try to find it...
> 
> Rob
> 

-- 
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:[~2026-10-07  4:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23 17:50 [PATCH] checks: Warn about overlapping reserved-memory ranges Bjorn Andersson
2026-09-25 17:03 ` Herve Codina
2026-09-30  9:44   ` David Gibson
2026-09-30 11:45     ` Herve Codina
2026-10-01  1:31       ` David Gibson
2026-09-30 10:09 ` David Gibson
2026-10-01 16:13 ` Rob Herring
2026-10-07  4:58   ` David Gibson [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=asXRewO5DieggXrA@gractus.seuss \
    --to=david@gibson.dropbear.id.au \
    --cc=bjorn.andersson@oss.qualcomm.com \
    --cc=devicetree-compiler@vger.kernel.org \
    --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 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.