Re: [RFC PATCH 09/77] dtc: Introduce mark_local_phandles()
David Gibson <[email protected]> Thu, 15 Jan 2026 11:48:44 +1100
| Newsgroups | org.kernel.vger.devicetree-spec,org.kernel.vger.devicetree-compiler,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <aWg5bD4zWYAQOYai@zatzit> |
On Mon, Jan 12, 2026 at 03:18:59PM +0100, Herve Codina wrote: > In order to have the new FDT_REF_LOCAL tag present in a dtb, the phandle > reference needs to be identify as a local reference. > > This is the purpose of mark_local_phandles(). > > It identifies a phandle reference as a local reference when this > reference points to a local node. > > With that node, the related FDT_REF_LOCAL tag is set in the dtb. I dislike caching redundant information (whether the ref is local) - it's an opportunity for them to get out of sync and cause bugs. Is there a strong case that you can't just determine whether it's local only when you actually go to use it? > > Signed-off-by: Herve Codina <[email protected]> > --- > dtc.c | 1 + > dtc.h | 1 + > livetree.c | 26 ++++++++++++++++++++++++++ > 3 files changed, 28 insertions(+) > > diff --git a/dtc.c b/dtc.c > index 88f03ff..d0b4de3 100644 > --- a/dtc.c > +++ b/dtc.c > @@ -334,6 +334,7 @@ int main(int argc, char *argv[]) > } > > update_phandles_ref(dti); > + mark_local_phandles(dti); > > process_checks(force, dti); > > diff --git a/dtc.h b/dtc.h > index 351fe41..08c9f07 100644 > --- a/dtc.h > +++ b/dtc.h > @@ -346,6 +346,7 @@ void generate_fixups_tree(struct dt_info *dti, const char *name); > void generate_local_fixups_tree(struct dt_info *dti, const char *name); > > void update_phandles_ref(struct dt_info *dti); > +void mark_local_phandles(struct dt_info *dti); > > /* Checks */ > > diff --git a/livetree.c b/livetree.c > index 9e30a63..2a0a7ed 100644 > --- a/livetree.c > +++ b/livetree.c > @@ -1196,3 +1196,29 @@ void update_phandles_ref(struct dt_info *dti) > { > update_phandles_ref_internal(dti, dti->dt); > } > + > +static void mark_local_phandles_internal(struct dt_info *dti, > + struct node *node) > +{ > + struct node *c; > + struct property *prop; > + struct marker *m; > + struct node *refnode; > + > + for_each_property(node, prop) { > + m = prop->val.markers; > + for_each_marker_of_type(m, REF_PHANDLE) { > + refnode = get_node_by_ref(dti->dt, m->ref); > + if (refnode) > + m->is_local = true; > + } > + } > + > + for_each_child(node, c) > + mark_local_phandles_internal(dti, c); > +} > + > +void mark_local_phandles(struct dt_info *dti) > +{ > + mark_local_phandles_internal(dti, dti->dt); > +} > -- > 2.52.0 > > -- 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
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmloOWsACgkQzQJF27ox 2GcFfw/+Nsn3pI1ST2XQbBW2xgzUYTiG/z9E2JHPz0AF+6DZyXT1UobX5vFZmwL+ s+ZBDqGJJFTdMC9H7ezKUYDPHDZX9b17YBfvuVZRKSB4M3Yb8bU9ql0W/fRh58Uw V1t5aoXsAaYP4Mximc2a6k/cmApHVRFlUR1HXZl4aYYtUCHiSQQaRWfoR5rg0RvM RnN3ab9cCtQz+lpG1Gny/vJblajJGquOursa08k/RcYyrhb3wwzU4RZPsFKO9Mep SGD3CtYY5VBIGxOSYSYKxf0I31iE6Oj3BGjkEnxYIkBDWaGLTUA0JSdIkqFg6Clo ORM5YuKmxVDkm5Tn1ZEeL0e58QKafV+ojwBYSI/aif3PnlfNopyaiPukqfROQUB3 TyH2bJrhTe8uzqT7G6gnNA+24GJLNGd5gY8d2K14HuE4Sua+7PneR0ZcZHYC4N91 pDrF82RpdfnGotL25PpLRW9hc6Nc0vjnyraiZ/XYUq3fuo7kQNwUS800WXZyKC2V yGptRoW3hg/89qM6XT2QPHM67XRw4QfED6albURo9uNyP4vq8DUjjWa4f/AJv7as U0aZE3zJ2mLgLB9haj23gP4YuzCnsSES2WvwUK2yG71M50n889CYL5FIA80JzHko DNjodMVHVwItNg63wxKgo3Na33vTVyEMJIAup+QOZ2D1sVsXBlI= =G1sL -----END PGP SIGNATURE-----