Skip to content

overlay: fix child_nodes deserialization in multi-pass lopper invocations#761

Closed
arthokal wants to merge 1 commit into
devicetree-org:masterfrom
arthokal:fix-overlay-deserialize
Closed

overlay: fix child_nodes deserialization in multi-pass lopper invocations#761
arthokal wants to merge 1 commit into
devicetree-org:masterfrom
arthokal:fix-overlay-deserialize

Conversation

@arthokal
Copy link
Copy Markdown
Contributor

@arthokal arthokal commented May 15, 2026

Issue:
When an overlay file with child nodes (e.g., updated_zocl.dtsi containing zyxclmm_drm under &amba_pl) is passed via -i in pass 1, Lopper embeds the overlay data into the output DTS for preservation across passes. In pass 2 (e.g., gen_domain_dts), Lopper crashes at startup while reconstructing the embedded overlay data:

AttributeError: 'collections.OrderedDict' object has no attribute 'append'

Root Cause:
_deserialize_overlay_node() used node.child_nodes.append(child), but child_nodes is an OrderedDict, not a list.

Fix:
Changed to node.child_nodes[child.abs_path] = child with explicit parent assignment, consistent with how child_nodes is managed in tree.py.

Example Lopper command invocations:

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

LOPPER_DTC_FLAGS="-b 0 -@" ./lopper.py -O lopper_out/ -f --enhanced -i lop-a72-imux.dts lopper_out/system-top-no-pl.dts apu_linux.dts -- gen_domain_dts psv_cortexa72_0 linux_dt

@arthokal
Copy link
Copy Markdown
Contributor Author

@onkarharsh, please review.

@onkarharsh
Copy link
Copy Markdown
Contributor

Looks good to me

@zeddii
Copy link
Copy Markdown
Collaborator

zeddii commented May 15, 2026

I need a bit more information. While the commit looks ok, the commit message doesn't carry enough information.

What attribute error ? I assume something is accessing .child, or similar, but that needs to be in the commit message.

What are the lopper command lines used to reproduce the issue, as well as the inputs. Both of those are required, since the overlay selftest are currently passing, and I need to check against those as well as to consider alternate implementations (we may not need the serialization anymore)

…ions

_deserialize_overlay_node() calls append() on node.child_nodes, which is
an OrderedDict, causing:
  AttributeError: 'collections.OrderedDict' object has no attribute 'append'

The issue is observed in a two-pass flow where pass 1 runs
xlnx_overlay_pl_dt with an overlay file containing child nodes (e.g.,
updated_zocl.dtsi with zyxclmm_drm under &amba_pl).

Pass 1 embeds the overlay data into the output DTS via
_serialize_overlay_subtrees.
Pass 2 (gen_domain_dts) crashes at startup when
_deserialize_overlay_subtrees tries to reconstruct the
embedded child nodes.

Fix by using dict-style insertion keyed by abs_path and set child.parent
explicitly, consistent with how child_nodes is managed in tree.py.

Signed-off-by: Aravind Thokala <aravind.thokala@amd.com>
@arthokal arthokal force-pushed the fix-overlay-deserialize branch from 5d1be2d to 7a55feb Compare May 15, 2026 14:25
@arthokal
Copy link
Copy Markdown
Contributor Author

arthokal commented May 15, 2026

Hi @zeddii,

Thank you for reviewing. Commit message and PR description were updated.

Please review.

@zeddii
Copy link
Copy Markdown
Collaborator

zeddii commented May 15, 2026

Thanks @arthokal — fix is correct. I made one small adjustment before merging: rather than setting `child.parent = node` after the recursive call (where the `parent` parameter was passed in but never used inside the function body), I moved it to `node.parent = parent` at the top of `_deserialize_overlay_node`. This establishes the parent backref before any property or child processing, which is more defensive against any code that walks `.parent` during construction. You're still listed as author.

Also added a second commit with self-tests covering the crash path and the invariants the fix depends on:

@zeddii
Copy link
Copy Markdown
Collaborator

zeddii commented May 15, 2026

The reason this slipped through existing tests: all our overlay test fixtures use flat overlay nodes (e.g. `/axi/timer@f1e90000` with only properties, no child nodes), so the `for child_data in data.get("children", [])` loop in `_deserialize_overlay_node` was never entered and the `append()` call was never reached. The new regression tests use a nested node (`zyxclmm_drm` under `amba_pl`) to exercise that path directly.

@zeddii zeddii closed this May 15, 2026
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.

3 participants