Skip to content

lopper: assists: Split Zephyr DTS generation into zephyr_domain_dts assist - #779

Open
dbingi-amd wants to merge 4 commits into
devicetree-org:masterfrom
dbingi-amd:zephyr-lopper
Open

lopper: assists: Split Zephyr DTS generation into zephyr_domain_dts assist#779
dbingi-amd wants to merge 4 commits into
devicetree-org:masterfrom
dbingi-amd:zephyr-lopper

Conversation

@dbingi-amd

Copy link
Copy Markdown
Contributor

• Split Zephyr device-tree generation out of gen_domain_dts into a new zephyr_domain_dts assist.
• gen_domain_dts now handles domain pruning and Linux/baremetal output only; Zephyr logic was removed from it.
• Added zephyr_domain_dts.py for Zephyr-specific transforms, board overlay handling, and related cleanup.
• Registered the new assist in lop-load.dts so Lopper loads it automatically.
• Replaced the old gen_domain_dts {proc} zephyr_dt [board.dts] flow with a separate zephyr_domain_dts {proc} [board.dts] step after domain (and imux) generation.
• Moved optional board overlay input to the second argument of zephyr_domain_dts (previously the third argument on gen_domain_dts).
• Preserved --extra-zephyr-comp support in the Zephyr assist (not in gen_domain_dts).
• Updated Zephyr platform docs, Linux domain-tree docs, and the developer guide to describe the new assist and command examples.
• No intended functional change to generated Zephyr DTS — this is primarily a refactor to separate concerns and simplify maintenance.

@dbingi-amd

Copy link
Copy Markdown
Contributor Author

Hi @kedareswararao,
Please review.

@kedareswararao

Copy link
Copy Markdown
Contributor

@zeddii : Please don't merge this until i approve it may break existing use cases need to cross verify properly before approving

@@ -11,7 +11,6 @@
import sys
import os
import glob

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated change

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of import argparse from gen_domain_dts.py is a direct consequence of this split. It was solely used by _extra_zephyr_comp_paths() (for --extra-zephyr-comp parsing), which has been moved to zephyr_domain_dts.py along with import argparse. No remaining code in gen_domain_dts.py uses argparse, so keeping it would be a dead import.

Comment thread lopper/assists/gen_domain_dts.py Outdated
6. Keeps the status disabled nodes in the final device-tree.
7. Delete the nodes that have an xlnx,ip-name property value mentioned in the linux_ignore_ip_list.

Zephyr device-tree generation uses assist zephyr_domain_dts (run after domain DTS).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to mention this here need to update the https://github.com/devicetree-org/lopper/tree/master/docs/amd/zephyr/source as per latest assist since it's taken care in the commit 2 no need to add this line here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, the line has been removed from the xlnx_generate_domain_dts docstring

# Add cpu0_intc (riscv,cpu-intc) as a child of the CPU node,
# and add the riscv,timer node at root wired to cpu0_intc at IRQ 5.
# Also wire axi_intc to cpu0_intc at IRQ 9 (IRQ_S_EXT).
if linux_dt and match_cpunode.propval('xlnx,ip-name', list)[0] == 'microblaze_riscv':

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated change

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The explicit linux_dt and was removed because the block was moved inside the existing else: branch (line 529), which already implies linux_dt = 1. The old standalone if linux_dt and microblaze_riscv: and the new else: → if microblaze_riscv: produce identical behavior across all cases — no corner case is affected

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be one change per commit if you are doing cleanup means it should be in a separate commit

Comment thread lopper/assists/gen_domain_dts.py Outdated
if node.propval('xlnx,ip-name', list) == ['axi_intc']:
node + LopperProp("interrupts-extended = <&cpu0_intc 9>")
break
for node in sdt.tree['/'].subnodes():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here unrelated change

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block is inside else: (line 529, = linux_dt) and if microblaze_riscv: — the effective guard is still linux_dt AND microblaze_riscv, same as before

Comment thread lopper/assists/zephyr_domain_dts.py Outdated
@@ -0,0 +1,1740 @@
#/*
# * Copyright (C) 2023-2026 Advanced Micro Devices, Inc. All Rights Reserved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2026 is sufficient since it's a new file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the copyright year

Comment thread lopper/assists/zephyr_domain_dts.py Outdated
Zephyr domain DT assist. Invoked after pruned domain DT is available.
Args: options['args'][0] = processor instance (same as gen_domain_dts);
options['args'][1] = optional Zephyr board overlay .dts path.
Optional flag --extra-zephyr-comp <path> may be repeated to merge

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cross check this comment and fix properly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the doc string

@dbingi-amd
dbingi-amd force-pushed the zephyr-lopper branch 3 times, most recently from e1b60d6 to e566888 Compare July 10, 2026 05:18
@dbingi-amd

Copy link
Copy Markdown
Contributor Author

Hi @kedareswararao,

Please review the updated change

Comment thread lopper/assists/gen_domain_dts.py Outdated
mapped_children_nodes.append(node)
continue
elif xlnx_openamp_keep_node(linux_dt, zephyr_dt, node, sdt.tree):
elif xlnx_openamp_keep_node(linux_dt, False, node, sdt.tree):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bentheredonethat : will this change effect open amp assists?
@dbingi-amd : Please check with Ben and test the open amp dts generation use case as well so that nothing will broke due to this change

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbingi-amd @kedareswararao NAK - keep zephyr_dt flag there.

Comment thread lopper/assists/gen_domain_dts.py Outdated
intc_node['#interrupt-cells'] = 1
intc_node + LopperProp("interrupt-controller")
match_cpunode.add(intc_node)
match_cpunode.add(intc_node)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated change

Comment thread lopper/assists/gen_domain_dts.py Outdated
timer_node.name = "timer"
timer_node.label = "int_timer"
timer_node ["compatible"] = "riscv,timer"
timer_node["compatible"] = "riscv,timer"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here unrelated change

@zeddii

zeddii commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Bumping this. A few things are outstanding before this can be considered for merge:

  1. There's an unaddressed NAK from @bentheredonethat ("keep zephyr_dt flag there"), and @kedareswararao's request to check with Ben and test the OpenAMP DTS generation use case — neither has had a follow-up yet.
  2. The PR now conflicts with master and needs a rebase.

@dbingi-amd — could you rebase against the latest master and respond to the outstanding review comments? Note @kedareswararao has also asked to hold merge until they approve.

@zeddii

zeddii commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

This has drifted to CONFLICTING since my last note, so it needs a rebase on master before it can move forward.

Recapping what's still outstanding (unchanged):

  • the NAK from @bentheredonethat (keep the zephyr_dt flag) hasn't been addressed;
  • @kedareswararao is holding pending verification that the split doesn't break existing use cases.

@dbingi-amd — a rebase plus resolving the NAK would get this back to a reviewable state.

Remove the zephyr_dt CLI path and Zephyr-specific generation helpers
from gen_domain_dts so the assist handles domain pruning and
Linux/baremetal output only. linux_dt, baremetal, and zynqmp_fsbl
behaviour is unchanged.
Rename _zephyr_node_must_be_preserved() to _node_must_be_preserved()
and keep it in the domain prune loop. OpenAMP pipelines run
gen_domain_dts before zephyr_domain_dts, so nodes already referenced
from /chosen must survive generic domain pruning — including ipc shm
set by the OpenAMP assist.

Signed-off-by: Bingi Dinesh kumar <[email protected]>
Move Zephyr device-tree generation into a dedicated assist that calls
gen_domain_dts when the input is a full SDT, then applies Zephyr
transforms. Platform lops such as imux remain external -i invocations.
Register the assist in lop-load.dts.

Reuse _node_must_be_preserved from gen_domain_dts during Zephyr-phase
pruning instead of maintaining a separate copy of the preserve logic.
Adjust zephyr_board_dt overlay discovery for the zephyr_domain_dts CLI.
Carry forward the ZynqMP IPI mailbox child handling, MicroBlaze RISC-V
RV32E kconfig generation, and other Zephyr-specific transforms recently
present in gen_domain_dts.

Signed-off-by: Bingi Dinesh kumar <[email protected]>
Point existing Zephyr unit tests at zephyr_domain_dts instead of
gen_domain_dts zephyr_dt. Add IPI mailbox child conversion and
promotion coverage for the VCK190 and ZCU102 cases handled by the new
assist.
Update the OpenAMP Zephyr pipeline sanity step to call
zephyr_domain_dts.

Signed-off-by: Bingi Dinesh kumar <[email protected]>
Replace gen_domain_dts <proc> zephyr_dt examples with
zephyr_domain_dts <proc> [board.dts] in developer-guide.md and the
AMD Zephyr platform guides for Cortex-A78, Cortex-R52, and MicroBlaze
RISC-V. Note in the Linux device-tree chapter that gen_domain_dts
remains the entry point for Linux domain trees.

Signed-off-by: Bingi Dinesh kumar <[email protected]>
@dbingi-amd

dbingi-amd commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

Hi @kedareswararao @bentheredonethat ,

Updated the branch per review feedback — please re-review.

@bentheredonethat — on your NAK: the zephyr_dt flag removed from gen_domain_dts CLI is intentional (step 5 is now zephyr_domain_dts). The openamp … zephyr_dt assist is unchanged. The xlnx_openamp_keep_node(linux_dt, False, …) change in domain prune is correct — that second arg is not the OpenAMP assist flag; it only affects UIO retention during Linux/baremetal prune.

Per your advice:
• Renamed _zephyr_node_must_be_preserved() → _node_must_be_preserved() and kept it in gen_domain_dts (step 4 domain prune), so /chosen refs like zephyr,ipc_shm survive before zephyr_domain_dts runs.
• VEK385 OpenAMP multidomain flow re-tested — pass after this fix.

OpenAMP test flow used (VEK385):

  1. YAML merge — merge OpenAMP/libmetal YAML into SDT
  2. Domain chosen — apply lop-domain-chosen for RPU Zephyr domain
  3. OpenAMP assist — openamp cortexr52_0 zephyr_dt (unchanged by this PR)
  4. Domain prune + imux — gen_domain_dts cortexr52_0 + R52 imux lop (unchanged)
  5. Zephyr DTS — zephyr_domain_dts cortexr52_0 + board overlay (was gen_domain_dts zephyr_dt)

Also ran pytest and lopper_sanity.py --openamp.

OpenAMP plugin extension for mmio-sram ipc nodes can follow separately if you still want that.

@kedareswararao — your feedback addressed: unrelated Linux changes reverted, Zephyr line removed from gen_domain_dts docstring, docs updated under docs/amd/zephyr/source.
Please re-review the updated commits.

Thanks,
Dinesh

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.

4 participants