Skip to content

overlay: Resolve phandle fixups in child nodes#765

Open
arthokal wants to merge 1 commit into
devicetree-org:masterfrom
arthokal:overlay-child-fixups
Open

overlay: Resolve phandle fixups in child nodes#765
arthokal wants to merge 1 commit into
devicetree-org:masterfrom
arthokal:overlay-child-fixups

Conversation

@arthokal
Copy link
Copy Markdown
Contributor

Issue:
When user overlay files (passed via -i) contain child nodes with phandle references, those references are silently dropped in the generated pl.dtsi

For example, updated_zocl.dtsi contains:

&amba_pl {                                                                      
        zyxclmm_drm {
                compatible = "xlnx,zocl-versal";
                xlnx,memory-region = <&cma_reserved>,<&ddr_ch1>,<&ddr_ch2>,<&ddr_ch3>;
        };
};

The generated overlay has zyxclmm_drm with xlnx,memory-region missing.

Root Cause:
_unwrap_overlay_tree() in lopper/__init__.py resolves 0xffffffff phandle placeholders (left by dtc plugin compilation) only for direct properties of the __overlay__ node.
Child node properties (like those in zyxclmm_drm) are deep-copied as-is with unresolved 0xffffffff values, which are silently dropped at write time.

Fix:
Instead of iterating properties and searching for matching fixups (inside-out), iterate label_to_fixups and patch nodes directly via ov_tree[path] (outside-in). This resolves phandles across overlay` and all its children in one pass before any copying happens.

Example Lopper command:

LOPPER_DTC_FLAGS="-b 0 -@" ./lopper.py -O outdir -f --enhanced -i /proj/ssw_xhd/drivers/onkarh/to_aravind/updated_zocl.dtsi /proj/ssw_xhd/drivers/onkarh/to_aravind/apu_linux-chosen.dts system-top-no-pl.dts -- xlnx_overlay_pl_dt psv_cortexa72_0 full --firmware-name=gmio_async_xrt.pdi

Phandle fixups (0xffffffff placeholders) were only resolved for direct
properties of the __overlay__ node. Properties on child nodes (e.g.,
xlnx,memory-region in zyxclmm_drm) were deep-copied with unresolved
values, causing them to be silently dropped at write time.

Fix this by iterating label_to_fixups and patching nodes via ov_tree[path]
directly, which resolves fixups across __overlay__ and all its children
in one pass before any copying happens.

Signed-off-by: Aravind Thokala <aravind.thokala@amd.com>
@arthokal
Copy link
Copy Markdown
Contributor Author

@onkarharsh,
Please review.

@zeddii
Copy link
Copy Markdown
Collaborator

zeddii commented May 20, 2026

The current resolution architecture was on purpose and should only be done on write time.

I don't have access to my full setup to test this, as I'm on vacation this week.

Does this change preserve the phandle resolution at write time ? I can't tell from looking at the patch.

Could you also attach some sample inputs and expected outputs ? So I can reproduce and test the issue myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants