Skip to content

RFC Memory and GPIO QOMification

Peter Crosthwaite qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest25 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/25qdev: Implement named GPIOshw/core/qdev.c include/hw/qdev-core.h qdev-monitor.c +1 more+117 -240 replies
2/25memory: Simplify mr_add_subregion() if-elsememory.c+1 -70 replies
3/25memory: Coreify subregion add functionalitymemory.c+12 -60 replies
4/25memory: MemoryRegion: QOMifyinclude/exec/memory.h memory.c+42 -190 replies
5/25memory: MemoryRegion: Add contained flaginclude/exec/memory.h memory.c+6 -40 replies
6/25memory: MemoryRegion: Add container and addr propsmemory.c+54 -00 replies
7/25memory: MemoryRegion: factor out memory region re-addermemory.c+16 -120 replies
8/25memory: MemoryRegion: Add may-overlap and priority propsinclude/exec/memory.h memory.c+58 -21 reply
9/25memory: MemoryRegion: Add size propertymemory.c+38 -00 replies
10/25exec: Parent root MRs to the machineexec.c+4 -00 replies
11/25irq: Slim conversion of qemu_irq to QOM [WIP]hw/core/irq.c include/hw/irq.h+43 -33 replies
12/25qdev: gpio: Don't allow name share between I and Ohw/core/qdev.c+2 -00 replies
13/25qdev: gpio: Register GPIO inputs as child objectshw/core/qdev.c+10 -00 replies
14/25qdev: gpio: Register GPIO outputs as QOM linkshw/core/qdev.c+12 -00 replies
15/25qdev: gpio: Re-impement qdev_connect_gpio QOM stylehw/core/qdev.c+4 -30 replies
16/25qom: object_property_set/get: Add child recursionqom/object.c+25 -20 replies
17/25sysbus: Use TYPE_DEVICE GPIO functionalityhw/core/sysbus.c include/hw/sysbus.h+6 -211 reply
18/25sysbus: Rework sysbus_mmio_map to use mr QOMificationhw/core/sysbus.c include/hw/sysbus.h+15 -250 replies
19/25sysbus: Setup memory regions as dynamic propshw/core/sysbus.c include/hw/sysbus.h+18 -150 replies
20/25sysbus: Enable hotplug.hw/core/sysbus.c+0 -70 replies
21/25microblaze: s3adsp: Expand UART creatorhw/microblaze/petalogix_s3adsp1800_mmu.c+4 -20 replies
22/25microblaze: s3adsp: Parent devices with sane nameshw/microblaze/petalogix_s3adsp1800_mmu.c+8 -00 replies
23/25timer: xilinx_timer: Convert to realize()hw/timer/xilinx_timer.c+12 -80 replies
24/25timer: xilinx_timer: init MMIO ASAPhw/timer/xilinx_timer.c+5 -30 replies
25/25TEST: microblaze: s3adsp: Remove timerhw/microblaze/petalogix_s3adsp1800_mmu.c+2 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [Qemu-devel] [RFC v1 00/25] Memory and GPIO QOMification

Hi All,

This series is my Memory and GPIO qomification as promised. This was discussed at length on the KVM call 2014-05-13.

This is the preview RFC designed to show the capability of the full solution. There are many parts to this that stand in their own right and the merge would be done in smaller chunks (E.G. Memory and GPIO works can go separately).

Theres some Microblaze stuff at the back of the series, leading to an example of sysbus hotplug.

Some patches are already on list. I put those at the front of the series.

Only build tested for microblaze. There's some periphery build issues for fully configured builds that i'll figure should we get some conceptual level acceptance of this whole idea.

configure --target-list=microblaze-softmmu

to play with it.

Contents:

QOMify Memory regions. So they are added as child objects to devices. Devices can do this explicitly in instance_init, or sysbus can handle it - sysbus_init_mmio parents the memory region to the device to transparently convert all existing devs to compliance.

This prepares support for the Memory heirachy work. Machines can create memory regions matching the bus architectures. Masters and slaves can gen hand these to devices as proper Links.

The address and container (the memory region containing this one as a subregion) of memory regions are QOM properties, of type integer and link resp. Setting the properties does the memory_region_add_subregion().

The root Memory Region is parented the machine in exec.c. This give the Memory Region a canonical path.

Sysbus IRQ are abandoned completely and re-implemented as named GPIOs. The sysbus irq API remains and makes this transition behind-the-scenes.

GPIOs are QOMified. qemu_allocate_irqs does the object_new() etc. IRQ inputs are then added as child objects of the instantiating device. Handled by qemu_init_gpio_in_named(). gpio_outs are setup as links. qdev_connect_gpio_out does the linkage.

QOM is patched to allow setting of a device's child's properties from a ref to the parent. Best illustrated by example (see below).

Anyways without a single patch to the command line interface, HMP, QMP, or implementing any machine specific hotplug or adding any new special busses, this works:

-device xlnx.xps-timer,\
sysbus-mr-0/container=/machine/sysmem,\
sysbus-mr-0/addr=0x83c00000,\
sysbus-irq-0=/machine/intc/unnamed-gpio-0

All the other ways to create devices should just work, this is not a command line specific feature.

Note, I edited my machine model to sanitize the canonical path of the interrupt controller.

hw/microblaze/petalogix_s3adsp1800_mmu.c +2 -0
@@ -97,6 +97,8 @@ petalogix_s3adsp1800_init(QEMUMachineInitArgs *args)
                           1, 0x89, 0x18, 0x0000, 0x0, 1);
 
     dev = qdev_create(NULL, "xlnx.xps-intc");
+    object_property_add_child(qdev_get_machine(), "intc", OBJECT(dev),
+                              &error_abort);
 

But you could have done the whole /machine/unattached/... ugliness too. If you name the irq inputs in the intc with my named GPIO series stuff the unnamed-gpio ugliness goes away too. If you throw away sysbus and do the memory-regions and IRQs naming the child objects properly the ugly sysbus names can de dispensed with too. But thats a big tree-wide to name everything properly.

Andreas Färber (1):
irq: Slim conversion of qemu_irq to QOM [WIP]

Peter Crosthwaite (24):
qdev: Implement named GPIOs
memory: Simplify mr_add_subregion() if-else
memory: Coreify subregion add functionality
memory: MemoryRegion: QOMify
memory: MemoryRegion: Add contained flag
memory: MemoryRegion: Add container and addr props
memory: MemoryRegion: factor out memory region re-adder
memory: MemoryRegion: Add may-overlap and priority props
memory: MemoryRegion: Add size property
exec: Parent root MRs to the machine
qdev: gpio: Don't allow name share between I and O
qdev: gpio: Register GPIO inputs as child objects
qdev: gpio: Register GPIO outputs as QOM links
qdev: gpio: Re-impement qdev_connect_gpio QOM style
qom: object_property_set/get: Add child recursion
sysbus: Use TYPE_DEVICE GPIO functionality
sysbus: Rework sysbus_mmio_map to use mr QOMification
sysbus: Setup memory regions as dynamic props
sysbus: Enable hotplug.
microblaze: s3adsp: Expand UART creator
microblaze: s3adsp: Parent devices with sane names
timer: xilinx_timer: Convert to realize()
timer: xilinx_timer: init MMIO ASAP
TEST: microblaze: s3adsp: Remove timer

 exec.c                                   |   4 +
 hw/core/irq.c                            |  44 +++++-
 hw/core/qdev.c                           | 107 +++++++++++--
 hw/core/sysbus.c                         |  85 ++++------
 hw/microblaze/petalogix_s3adsp1800_mmu.c |  16 +-
 hw/timer/xilinx_timer.c                  |  26 ++--
 include/exec/memory.h                    |   9 +-
 include/hw/irq.h                         |   2 +
 include/hw/qdev-core.h                   |  24 ++-
 include/hw/sysbus.h                      |  12 +-
 memory.c                                 | 258 +++++++++++++++++++++++++------
 qdev-monitor.c                           |  16 +-
 qom/object.c                             |  27 +++-
 qtest.c                                  |  19 ++-
 14 files changed, 500 insertions(+), 149 deletions(-)
Signature · 1 line
1.9.3.1.ga73a6ad