]> git.ipfire.org Git - thirdparty/qemu.git/commit
hw/riscv/virt.c: do create_fdt() earlier, add finalize_fdt()
authorDaniel Henrique Barboza <dbarboza@ventanamicro.com>
Fri, 10 Nov 2023 17:25:59 +0000 (14:25 -0300)
committerMichael Tokarev <mjt@tls.msk.ru>
Wed, 29 Nov 2023 13:15:22 +0000 (16:15 +0300)
commit9ac76067abf74f8dc12f7c9ef2acb0df543ebcbb
treedb218a021b9e11d94edfaca073eea9932e6b5d49
parent8d0b8fead4c85addce1b0fa6132c9c8fc08fe06e
hw/riscv/virt.c: do create_fdt() earlier, add finalize_fdt()

Commit 49554856f0 fixed a problem, where TPM devices were not appearing
in the FDT, by delaying the FDT creation up until virt_machine_done().
This create a side effect (see gitlab #1925) - devices that need access
to the '/chosen' FDT node during realize() stopped working because, at
that point, we don't have a FDT.

This happens because our FDT creation is monolithic, but it doesn't need
to be. We can add the needed FDT components for realize() time and, at
the same time, do another FDT round where we account for dynamic sysbus
devices.  In other words, the problem fixed by 49554856f0 could also be
fixed by postponing only create_fdt_sockets() and its dependencies,
leaving everything else from create_fdt() to be done during init().

Split the FDT creation in two parts:

- create_fdt(), now moved back to virt_machine_init(), will create FDT
  nodes that doesn't depend on additional (dynamic) devices from the
  sysbus;

- a new finalize_fdt() step is added, where create_fdt_sockets() and
  friends is executed, accounting for the dynamic sysbus devices that
  were added during realize().

This will make both use cases happy: TPM devices are still working as
intended, and devices such as 'guest-loader' have a FDT to work on
during realize().

Fixes: 49554856f0 ("riscv: Generate devicetree only after machine initialization is complete")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1925
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20231110172559.73209-1-dbarboza@ventanamicro.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
(cherry picked from commit 7a87ba8956e59bec8cc4677c6aa5141e4c023a7d)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
hw/riscv/virt.c