On 23.10.14 12:10, Eric Auger wrote: > Dear all, > > The goal of this mail is to summarize how dynamic sysbus device tree > nodes were created on ARM with "machvirt dynamic sysbus device > instantiation", > https://lists.gnu.org/archive/html/qemu-devel/2014-09/msg01626.html > and request some advises after commit "hw/arm/boot: load DTB as a ROM > image", which puts into question the current implementation. > > When dynamically instantiating sysbus devices from qemu command line, > the complete device tree cannot be built at machine init. At time we > miss key information about those devices (base address, IRQ binding, ...) > > dynamic sysbus devices are "realized" after the machine init when > parsing "-device" option line. This is at that time the information > about the device are collected. > > The QEMU binding of the devices is performed in the platform_bus > machine_init_done_notifier. Only at that time the base address of the > device and IRQ number are chosen. > > The original idea was to create the dynamic sysbus device tree nodes in > a reset callback (registered through qemu_register_reset). device tree > was fully re-created at that time and new sysbus device nodes were added > too. Finally archi specific load_dtb was called. > > On ppc/e500 this works since load_dtb uses cpu_physical_memory_write. > it was the case on ARM too until recently but commit "hw/arm/boot: load > DTB as a ROM image" changed the arm load_dtb implementation. It now uses > rom_add_blob_fixed. when the reset callback is called rom_load_done() > was called by vl.c and prevents from changing the rom content. Hence > current callback mechanism does not work anymore. > > A solution I foresee to fix the issue: > construct the device tree nodes in one machine_init_done_notifier, > before the rom_load_done is called. I would propose the platform bus > device (hw/core/platform-bus.c in [PATCH v3 0/7] Dynamic sysbus device > allocation support, > http://lists.nongnu.org/archive/html/qemu-devel/2014-09/msg04833.html) > to register another machine_init_done_notifier whose role would be to > initiate the dt upgrade.
The platform bus doesn't have any business in creating device trees. Please do this in your machine file. Alex > I would add a function to the platform bus to > pass an opaque data that allows calling architecture specific dt > implementation in the notifier, if needed (on ARM only). > > I understand reverting to previous cpu_physical_memory_write > implementation on ARM is not the good direction. > > Do you have any comments about the proposed solution, any other suggestion? > > Thanks in advance > > Best Regards > > Eric > > > > >