Re: [RFC PATCH 07/77] livetree: Improve get_node_by_phandle()
Herve Codina <[email protected]> Fri, 16 Jan 2026 11:52:54 +0100
| Newsgroups | org.kernel.vger.devicetree-spec,org.kernel.vger.devicetree-compiler,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel |
|---|---|
| Organization | Bootlin |
| Message-ID | <[email protected]> |
Hi David, On Thu, 15 Jan 2026 11:41:32 +1100 David Gibson <[email protected]> wrote: > On Mon, Jan 12, 2026 at 03:18:57PM +0100, Herve Codina wrote: > > get_node_by_phandle() allows to get a node based on its phandle value. > > It checks the phandle value against value available in internal node > > structure. > > > > This internal phandle value is updated during process_check() and so, > > get_node_by_phandle() cannot give correct results before the > > process_check() call. > > > > Improve get_node_by_phandle() to look at node phandle properties when > > the internal phandle value is not valid. > > > > This allows to return a correct matching node even if process_check() > > was not called yet. > > > > With the recently introduced FDT_REF_LOCAL dtb tag, this will be needed > > to update internal phandle references before the call to process_check(). > > Indeed, this tag allows to identify phandles and internal references > > need to be updated based on the phandle value before the > > process_check() call. > > Having two entirely different paths for get_node_by_phandle() is > really ugly. > > I suspect a better approach would be to special case updates to the > internal phandle field as we parse the phandle properties, rather than > doing it as a batch during the checks. Doing that when we parse the property will be quite complex. Indeed, when we parse a dts, the node internal object is not yet created when the property is parsed. What I think could be done is to set the phandle field just after the parsing of input (dts or dtb). In current implementation this is done by process_check() when fixup_phandle_references() is called. This fixup_phandle_references() call should be removed from process_check() and called right after the input parsing. I you are ok with that, I can propose something in the next iteration. Best regards, Hervé