qom: Make composition-tree parenting mandatory
Subsystems (11)
cover qom: Make composition-tree parenting mandatory
Motivation
----------
Markus observed [1] that a device reaching realize without a composition-tree parent is a modeling bug, and that the /machine/unattached container that catches such devices today is a bug attractor rather than a safety net: it hides the fact that nobody decided "what is part of what", and it gives the object an unstable, implementation-defined QOM path that is useless for qom-get/qom-set and for management tools that want to address board-created devices.
This series makes composition-tree parenting mandatory. After it, device_set_realized() errors on a device with no parent, memory_region_do_init() asserts that a named region has an owner, qdev_connect_gpio_out_named() asserts that the pin being wired has a parent, and /machine/unattached is deleted. Every board-created object has a stable, human-chosen path.
[1] https://lore.kernel.org/qemu-devel/[email protected]/
Approach
--------
Rather than add a parallel "parented" API and migrate callers over years, each creation helper is converted in a single rename->reintroduce
pair: a tree-wide Coccinelle rename of foo() to foo_orphan(), followed immediately by a patch that reintroduces foo() with a leading (Object *parent, const char *id, ...) signature. The tree builds after every patch and never carries two spellings of the same helper.
The bulk of the series then converts *_orphan() call sites to the parented form, one hw/ subdirectory per patch. Most of those commits carry a per-callsite table in the commit message giving the chosen parent expression, the chosen child name, and the one-line reason ("board init -> machine", "realize of X -> X", ...); the smaller ones carry a prose summary of the same. Those tables are the substance the RFC is asking maintainers to review: the mechanical part is trivial, the modeling decisions are not.
Some hw/arm commit messages carry wide per-callsite tables that exceed 76 columns; please view with a fixed-width, non-wrapping mail reader.
Once no *_orphan() callers remain the _orphan variants are deleted, the enforcement checks are armed, and /machine/unattached is removed.
Series shape
------------
001-009 core API: object_new_child(); rename->reintroduce for
qdev_new, sysbus_create_*, pci_new*, isa_new*,
i2c_slave_*, ssi/usb/sd/adb/virtio/hda/aux/spapr-vio,
cpu_create
010-082 hw/*: convert *_orphan() call sites to the parented form,
one subdirectory per patch, each with a per-callsite
reasoning table (or prose summary) in the commit message
083-088 delete the qdev/sysbus/pci/isa/i2c/ssi/usb/cpu *_orphan()
creator variants
089-107 memory: give the remaining owner==NULL memory regions an
owner, then assert on owner==NULL for named regions 108-116 irq: rename->reintroduce qemu_allocate_irq*() with an
owner and name; convert callers; delete _orphan variants
117-130 parent the remaining non-device singletons and per-device
helper objects (main-system-bus, accel, reset container, per-MR helpers, per-devfn IOMMU objects, board-created CPUs, ...)
131-132 arm the enforcement checks and delete /machine/unattached
133-134 docs/devel/qom.rst: parenting contract; MAINTAINERS
The Coccinelle scripts used for the rename steps are included under scripts/coccinelle/qom-parent/ and referenced from the corresponding commit messages.
Not converted in this series
----------------------------
A handful of long-lived objects are deliberately left path-less for now, each for a specific lifecycle reason called out in the relevant commit message:
* TYPE_MIGRATION is a TYPE_DEVICE that is never realized, per the upstream comment "TODO make this TYPE_OBJECT once QOM provides -global for objects". Parenting it under /machine trips the qdev_assert_realized_properly() walk. It can move under /machine once it becomes a plain TYPE_OBJECT.
* RamDiscardManager is unref'd from memory_region_finalize() itself, so making it a child<> of the MR would use-after-free during MR teardown.
* TPM backends and VFIO IOMMU containers are user-configurable and dynamically created; they belong under /objects/<id> or a dedicated /machine/vfio container respectively, and are best handled in a follow-up on top of this series.
* QIOChannel* and per-mapping virtio-shmem objects remain path-less by design (transient, refcounted, no stable identity).
Verification
------------
* The tree builds for 20 softmmu targets after every patch.
* Every machine type across those targets was smoke-tested with "-M <machine> -S"; none abort on the new assertions.
* "info qom-tree" on q35 and on aarch64 virt shows no /machine/unattached node after the final patch.
* grep -r 'machine_get_container("unattached")' returns no hits.
AI-assistance disclosure (docs/devel/code-provenance.rst)
----------------------------------------------------------
Every patch in this series was produced with AI assistance and reviewed by the human submitter. Each commit carries an
trailer following the format documented in the Linux kernel's Documentation/process/coding-assistants.rst. The tree-wide rename patches are Coccinelle-equivalent mechanical transforms; the per-callsite parent/name choices in the hw/* commits are the AI-assisted modeling decisions this RFC is asking maintainers to review.
QEMU's current policy in docs/devel/code-provenance.rst is to decline AI-generated contributions absent an explicit exception. This RFC is therefore posted to open that discussion: I am requesting an exception for this series (or, if the community prefers, will reauthor the parts the policy requires) and will not post a non-RFC v1 until that is resolved on qemu-devel. The Signed-off-by DCO certification is mine as the human reviewer taking full responsibility for the contribution.
Alexander Graf (134):
qom: Introduce object_new_child()
qdev: Rename qdev_new()/qdev_try_new() to *_orphan()
qdev: Reintroduce qdev_new() with a mandatory QOM parent
sysbus: Make sysbus_create_simple()/_varargs() take a QOM parent
pci: Make pci_new*()/pci_create_simple*() take a QOM parent
isa: Make isa_new()/isa_try_new()/isa_create_simple() take a QOM
parent
i2c: Make i2c_slave_new()/i2c_slave_create_simple() take a QOM parent ssi, usb: Make bus-layer creators take a QOM parent
cpu: Make cpu_create() take a QOM parent
hw/avr: Give onboard devices a QOM parent
hw/tricore: Give onboard devices a QOM parent
hw/xtensa: Give onboard devices a QOM parent
hw/alpha: Give onboard devices a QOM parent
hw/nitro: Give onboard devices a QOM parent
hw/vmapple: Give onboard devices a QOM parent
hw/hppa: Give onboard devices a QOM parent
hw/microblaze: Give onboard devices a QOM parent
hw/sh4: Give onboard devices a QOM parent
hw/s390x: Give onboard devices a QOM parent
hw/or1k: Give onboard devices a QOM parent
hw/loongarch: Give onboard devices a QOM parent
hw/intc: Give onboard devices a QOM parent
hw/pci-host: Give onboard devices a QOM parent
hw/core: Give onboard devices a QOM parent
hw/remote: Give onboard devices a QOM parent
hw/ufs: Give onboard devices a QOM parent
hw/nvme: Give onboard devices a QOM parent
hw/vfio: Give onboard devices a QOM parent
hw/mem: Give onboard devices a QOM parent
hw/cxl: Give onboard devices a QOM parent
hw/hexagon: Give onboard devices a QOM parent
hw/xen: Give onboard devices a QOM parent
hw/display: Give onboard devices a QOM parent
hw/nvram: Give onboard devices a QOM parent
hw/dma: Give onboard devices a QOM parent
hw/misc: Give onboard devices a QOM parent
hw/scsi: Give onboard devices a QOM parent
hw/net: Give onboard devices a QOM parent
hw/ide: Give onboard devices a QOM parent
hw/i3c: Give onboard devices a QOM parent
hw/pci-bridge: Give onboard devices a QOM parent hw/sparc64: Give onboard devices a QOM parent
hw/sparc: Give onboard devices a QOM parent
hw/m68k: Give onboard devices a QOM parent
hw/rtc: Give onboard devices a QOM parent
hw/i2c: Give onboard devices a QOM parent
hw/block: Give onboard devices a QOM parent
hw/char: Give onboard devices a QOM parent
hw/isa: Give onboard devices a QOM parent
hw/pci: Give onboard devices a QOM parent
hw/riscv: Give onboard devices a QOM parent
hw/mips: Give onboard devices a QOM parent
hw/i386: Give onboard devices a QOM parent
hw/ppc: Give onboard devices a QOM parent
hw/pci, hw/isa: Give VGA and slot-NIC helpers a QOM parent hw/arm/virt: Give onboard devices a QOM parent hw/arm/sbsa-ref: Give onboard devices a QOM parent hw/arm/xilinx-zynq: Give onboard devices a QOM parent hw/arm/xlnx-versal, xlnx-zynqmp: Give onboard devices a QOM parent hw/arm/realview, integratorcp: Give onboard devices a QOM parent hw/arm/npcm: Give onboard devices a QOM parent hw/arm/versatile, vexpress: Give onboard devices a QOM parent hw/arm/stellaris, musicpal: Give onboard devices a QOM parent hw/arm/exynos: Give onboard devices a QOM parent hw/arm/allwinner: Give onboard devices a QOM parent hw/arm/strongarm: Give onboard devices a QOM parent hw/arm/omap: Give onboard devices a QOM parent hw/arm/mps2: Give onboard devices a QOM parent
hw/arm/imx: Give onboard devices a QOM parent
hw/arm/misc: Give onboard devices a QOM parent hw/arm/aspeed: Give onboard devices a QOM parent (part 1) hw/arm/aspeed: Give onboard devices a QOM parent (part 2) hw/nvram/at24c: Give at24c_eeprom_init() a QOM parent hw/i386/pc: Give pcspk a QOM parent
hw/timer, hw/net: Give i8254 and isa-ne2000 helpers a QOM parent hw/misc/unimp: Give create_unimplemented_device() a QOM parent hw/usb: Give -usbdevice and auto-hub devices a QOM parent hw/audio: Give -audio model= devices a QOM parent
hw/xen: Give xenstore-driven backend devices a QOM parent hw/nitro: Give the vsock bridge a QOM parent
hw/isa: Give the isabus-bridge a QOM parent
net, target/mips: Give -nic and CPU-with-clock helpers a QOM parent usb, ssi, i2c: Remove *_orphan() creator variants
isa: Remove *_orphan() creator variants
pci: Remove *_orphan() creator variants
cpu: Remove cpu_create_orphan()
sysbus: Remove *_orphan() creator variants
qdev: Remove qdev_new_orphan() and qdev_try_new_orphan()
memory: Accept non-device owners in memory_region_init_ram() hw/misc-boards: Give memory regions an explicit owner hw/mips: Give memory regions an explicit owner
hw/riscv: Give memory regions an explicit owner
hw/i386: Give memory regions an explicit owner
hw/arm: Give memory regions an explicit owner hw/arm/omap1: Give memory regions an explicit owner hw/sh4: Give memory regions an explicit owner
hw/m68k: Give memory regions an explicit owner
hw/ppc: Give memory regions an explicit owner
hw/tricore: Give memory regions an explicit owner hw/xtensa: Give memory regions an explicit owner hw/display: Give memory regions an explicit owner hw/arm/omap: Give lcdc and dma memory regions an explicit owner hw/char: Give parallel and htif memory regions an explicit owner hw/remote: Give memory regions an explicit owner
system, backends: Give named memory regions an explicit owner hw/ide: Let ide_init_ioport() take an explicit owner
memory: Require an owner for named memory regions
irq: Rename qemu_allocate_irq*() and friends to *_orphan()
irq: Reintroduce qemu_allocate_irq*() with a mandatory owner and name hw/pci, hw/usb, system: Give allocated IRQs an owner and name hw/i386, hw/xen: Give allocated IRQs an owner and name hw/arm: Give allocated IRQs an owner and name
hw/xtensa: Give allocated IRQs an owner and name
hw: Give allocated IRQs an owner and name
hw/core: Parent GPIO input IRQs and embedded IRQState via QOM
irq: Delete the *_orphan() IRQ allocation variants
sysbus: Parent main-system-bus directly under /machine
accel: Parent the accelerator singleton under /machine hw/core/reset: Give the root reset container and legacy shims a QOM
path
system: Parent per-MR helper objects under their owner hw/virtio, hw/display: Parent per-device helper objects hw/i386/amd_iommu: Parent internally-created AMDVI-PCI under the IOMMU hw/s390x, hw/remote: Parent per-devfn IOMMU objects hw/pci-host/raven: Parent the OR-IRQ under the host bridge hw/arm/mps2: Parent the OR-IRQ gates under the machine hw/arm/digic: Parent the DIGIC SoC under the machine hw/microblaze: Parent the CPU under the machine
hw: Pair object_initialize_child() with plain realize()
hw: Parent board-created CPUs under the machine hw/pci-host/versatile: Use object_initialize_child() for pci_dev docs, qapi, scripts, iotests: Update /machine/unattached path
references
qom: Delete /machine/unattached and error on unparented realize docs/devel/qom: Document the composition-tree parenting contract
MAINTAINERS: Add scripts/coccinelle/qom-parent/ under QOM
MAINTAINERS | 1 + accel/accel-system.c | 4 +- backends/igvm.c | 6 +- bsd-user/main.c | 3 +- docs/devel/qom.rst | 96 +++++++ docs/devel/s390-cpu-topology.rst | 2 +- docs/system/cpu-hotplug.rst | 4 +- hw/alpha/alpha_sys.h | 3 +- hw/alpha/dp264.c | 16 +- hw/alpha/typhoon.c | 10 +- hw/arm/allwinner-a10.c | 4 +- hw/arm/allwinner-h3.c | 34 ++- hw/arm/allwinner-r40.c | 4 +- hw/arm/armsse.c | 13 +- hw/arm/aspeed.c | 39 +-- hw/arm/aspeed_ast1040_evb.c | 6 +- hw/arm/aspeed_ast10x0_evb.c | 12 +- hw/arm/aspeed_ast2400_palmetto.c | 8 +- hw/arm/aspeed_ast2400_quanta-q71l.c | 18 +- hw/arm/aspeed_ast2400_supermicrox11.c | 8 +- hw/arm/aspeed_ast2500_evb.c | 7 +- hw/arm/aspeed_ast2500_g220a.c | 11 +- hw/arm/aspeed_ast2500_romulus.c | 3 +- hw/arm/aspeed_ast2500_supermicro-x11spi.c | 8 +- hw/arm/aspeed_ast2500_tiogapass.c | 13 +- hw/arm/aspeed_ast2500_witherspoon.c | 34 +-- hw/arm/aspeed_ast2500_yosemitev2.c | 13 +- hw/arm/aspeed_ast2600_anacapa.c | 51 ++-- hw/arm/aspeed_ast2600_bletchley.c | 33 ++- hw/arm/aspeed_ast2600_catalina.c | 99 +++---- hw/arm/aspeed_ast2600_evb.c | 7 +- hw/arm/aspeed_ast2600_fby35.c | 20 +- hw/arm/aspeed_ast2600_fuji.c | 111 ++++---- hw/arm/aspeed_ast2600_gb200nvl.c | 24 +- hw/arm/aspeed_ast2600_rainier.c | 188 ++++++++------ hw/arm/aspeed_ast27x0-fc.c | 9 +- hw/arm/aspeed_ast27x0_evb.c | 3 +- hw/arm/aspeed_soc_common.c | 14 +- hw/arm/bananapi_m2u.c | 6 +- hw/arm/collie.c | 6 +- hw/arm/cubieboard.c | 6 +- hw/arm/digic_boards.c | 5 +- hw/arm/exynos4210.c | 70 ++--- hw/arm/exynos4_boards.c | 15 +- hw/arm/fsl-imx25.c | 2 +- hw/arm/fsl-imx31.c | 2 +- hw/arm/fsl-imx6.c | 7 +- hw/arm/fsl-imx6ul.c | 37 +-- hw/arm/fsl-imx7.c | 41 +-- hw/arm/fsl-imx8mm.c | 2 +- hw/arm/fsl-imx8mp.c | 2 +- hw/arm/imx25_pdk.c | 6 +- hw/arm/imx8mm-evk.c | 6 +- hw/arm/imx8mp-evk.c | 6 +- hw/arm/integratorcp.c | 56 ++-- hw/arm/kzm.c | 6 +- hw/arm/max78000_soc.c | 107 ++++---- hw/arm/max78000fthr.c | 5 +- hw/arm/mcimx6ul-evk.c | 4 +- hw/arm/mcimx7d-sabre.c | 4 +- hw/arm/mps2-tz.c | 27 +- hw/arm/mps2.c | 91 ++++--- hw/arm/mps3r.c | 20 +- hw/arm/msf2-soc.c | 24 +- hw/arm/msf2-som.c | 12 +- hw/arm/musca.c | 4 +- hw/arm/musicpal.c | 50 ++-- hw/arm/netduino2.c | 5 +- hw/arm/netduinoplus2.c | 5 +- hw/arm/npcm7xx.c | 95 +++---- hw/arm/npcm7xx_boards.c | 117 +++++---- hw/arm/npcm8xx.c | 147 +++++------ hw/arm/npcm8xx_boards.c | 19 +- hw/arm/nrf51_soc.c | 4 +- hw/arm/olimex-stm32-h405.c | 5 +- hw/arm/omap1.c | 244 ++++++++++-------- hw/arm/omap_sx1.c | 20 +- hw/arm/orangepi.c | 4 +- hw/arm/raspi.c | 4 +- hw/arm/realview.c | 113 ++++---- hw/arm/sabrelite.c | 5 +- hw/arm/sbsa-ref.c | 76 +++--- hw/arm/stellaris.c | 99 ++++--- hw/arm/stm32f100_soc.c | 62 ++--- hw/arm/stm32f205_soc.c | 2 +- hw/arm/stm32f405_soc.c | 88 +++---- hw/arm/stm32l4x5_soc.c | 88 +++---- hw/arm/stm32vldiscovery.c | 5 +- hw/arm/strongarm.c | 27 +- hw/arm/strongarm.h | 2 +- hw/arm/versatilepb.c | 85 +++--- hw/arm/vexpress.c | 87 ++++--- hw/arm/virt.c | 97 +++---- hw/arm/xilinx_zynq.c | 160 ++++++------ hw/arm/xlnx-versal-virt.c | 5 +- hw/arm/xlnx-versal.c | 197 ++++++-------- hw/arm/xlnx-zcu102.c | 14 +- hw/arm/xlnx-zynqmp.c | 8 +- hw/audio/intel-hda.c | 4 +- hw/audio/model.c | 5 +- hw/avr/atmega.c | 24 +- hw/block/fdc-sysbus.c | 13 +- hw/block/fdc.c | 4 +- hw/block/pflash_cfi01.c | 6 +- hw/block/pflash_cfi02.c | 6 +- hw/block/xen-block.c | 5 +- hw/char/diva-gsp.c | 3 +- hw/char/exynos4210_uart.c | 6 +- hw/char/mcf_uart.c | 11 +- hw/char/mchp_pfsoc_mmuart.c | 4 +- hw/char/omap_uart.c | 4 +- hw/char/parallel-isa.c | 10 +- hw/char/parallel.c | 5 +- hw/char/pl011.c | 6 +- hw/char/riscv_htif.c | 5 +- hw/char/serial-isa.c | 11 +- hw/char/serial-mm.c | 6 +- hw/char/sifive_uart.c | 8 +- hw/char/spapr_vty.c | 6 +- hw/char/xen_console.c | 7 +- hw/core/cpu-common.c | 6 +- hw/core/gpio.c | 24 +- hw/core/irq.c | 38 +-- hw/core/null-machine.c | 2 +- hw/core/qdev-user.c | 6 +- hw/core/qdev.c | 39 ++- hw/core/reset.c | 13 +- hw/core/sysbus.c | 22 +- hw/cxl/cxl-host.c | 9 +- hw/display/cg3.c | 2 +- hw/display/g364fb.c | 2 +- hw/display/macfb.c | 2 +- hw/display/omap_lcdc.c | 5 +- hw/display/sii9022.c | 2 +- hw/display/sm501.c | 6 +- hw/display/vhost-user-gpu.c | 12 +- hw/display/virtio-gpu-gl.c | 2 +- hw/display/vmware_vga.c | 2 +- hw/display/xlnx_dp.c | 14 +- hw/dma/i8257.c | 10 +- hw/dma/omap_dma.c | 9 +- hw/dma/rc4030.c | 7 +- hw/hexagon/hexagon_dsp.c | 21 +- hw/hexagon/virt.c | 29 +-- hw/hppa/machine.c | 96 ++++--- hw/i2c/aspeed_i2c.c | 4 +- hw/i2c/core.c | 22 +- hw/i2c/smbus_eeprom.c | 11 +- hw/i386/amd_iommu.c | 3 +- hw/i386/isapc.c | 17 +- hw/i386/kvm/clock.c | 4 +- hw/i386/kvm/clock.h | 2 +- hw/i386/kvm/i8259.c | 8 +- hw/i386/kvm/xen-stubs.c | 2 +- hw/i386/kvm/xen_evtchn.c | 6 +- hw/i386/kvm/xen_evtchn.h | 3 +- hw/i386/kvm/xen_gnttab.c | 6 +- hw/i386/kvm/xen_gnttab.h | 2 +- hw/i386/kvm/xen_overlay.c | 6 +- hw/i386/kvm/xen_overlay.h | 2 +- hw/i386/kvm/xen_primary_console.c | 5 +- hw/i386/kvm/xen_primary_console.h | 2 +- hw/i386/kvm/xen_xenstore.c | 5 +- hw/i386/kvm/xen_xenstore.h | 2 +- hw/i386/microvm.c | 34 +-- hw/i386/nitro_enclave.c | 9 +- hw/i386/pc.c | 96 +++---- hw/i386/pc_piix.c | 28 +- hw/i386/pc_q35.c | 42 +-- hw/i386/pc_sysfw.c | 16 +- hw/i386/sgx.c | 5 +- hw/i386/x86-common.c | 33 ++- hw/i386/x86-cpu.c | 4 +- hw/i386/xen/xen-hvm.c | 12 +- hw/i386/xen/xen-pvh.c | 5 +- hw/i386/xen/xen_pvdevice.c | 2 +- hw/i3c/core.c | 19 +- hw/ide/ahci.c | 2 +- hw/ide/ide-bus.c | 5 +- hw/ide/ide-internal.h | 2 +- hw/ide/ioport.c | 37 ++- hw/ide/isa.c | 9 +- hw/ide/pci.c | 2 +- hw/ide/piix.c | 2 +- hw/intc/apic_common.c | 3 +- hw/intc/exynos4210_gic.c | 4 +- hw/intc/i8259.c | 6 +- hw/intc/i8259_common.c | 7 +- hw/intc/riscv_aclint.c | 16 +- hw/intc/riscv_aplic.c | 13 +- hw/intc/riscv_imsic.c | 7 +- hw/intc/s390_flic.c | 12 +- hw/intc/sh_intc.c | 21 +- hw/intc/sifive_plic.c | 7 +- hw/ipack/ipack.c | 11 +- hw/ipmi/ipmi_bt.c | 2 +- hw/ipmi/ipmi_kcs.c | 2 +- hw/isa/i82378.c | 13 +- hw/isa/isa-bus.c | 44 ++-- hw/isa/isa-superio.c | 25 +- hw/isa/lpc_ich9.c | 2 +- hw/isa/piix.c | 4 +- hw/isa/vt82c686.c | 7 +- hw/loongarch/virt.c | 56 ++-- hw/m68k/an5206.c | 13 +- hw/m68k/mcf5206.c | 8 +- hw/m68k/mcf5208.c | 32 ++- hw/m68k/mcf_intc.c | 7 +- hw/m68k/next-cube.c | 26 +- hw/m68k/q800.c | 28 +- hw/m68k/virt.c | 25 +- hw/mem/sparse-mem.c | 6 +- hw/microblaze/petalogix_ml605_mmu.c | 40 ++- hw/microblaze/petalogix_s3adsp1800_mmu.c | 27 +- hw/microblaze/xlnx-zynqmp-pmu.c | 4 +- hw/mips/boston.c | 32 +-- hw/mips/cps.c | 5 +- hw/mips/fuloong2e.c | 24 +- hw/mips/jazz.c | 73 +++--- hw/mips/loongson3_virt.c | 40 +-- hw/mips/malta.c | 49 ++-- hw/mips/mips_int.c | 2 +- hw/misc/empty_slot.c | 7 +- hw/misc/led.c | 15 +- hw/misc/macio/macio.c | 2 +- hw/misc/sifive_e_prci.c | 6 +- hw/misc/sifive_test.c | 6 +- hw/net/can/can_kvaser_pci.c | 2 +- hw/net/imx_fec.c | 4 +- hw/net/lan9118.c | 10 +- hw/net/smc91c111.c | 6 +- hw/net/spapr_llan.c | 6 +- hw/net/xen_nic.c | 5 +- hw/nitro/machine.c | 11 +- hw/nitro/nitro-vsock-bus.c | 9 +- hw/nubus/nubus-virtio-mmio.c | 2 +- hw/nvme/ctrl.c | 2 +- hw/nvram/eeprom_at24c.c | 12 +- hw/nvram/fw_cfg.c | 16 +- hw/or1k/or1k-sim.c | 25 +- hw/or1k/virt.c | 43 +-- hw/pci-bridge/pci_expander_bridge.c | 13 +- hw/pci-host/articia.c | 6 +- hw/pci-host/astro.c | 8 +- hw/pci-host/bonito.c | 28 +- hw/pci-host/grackle.c | 2 +- hw/pci-host/gt64120.c | 5 +- hw/pci-host/i440fx.c | 2 +- hw/pci-host/mv64361.c | 4 +- hw/pci-host/pnv_phb.c | 5 +- hw/pci-host/pnv_phb3.c | 3 +- hw/pci-host/pnv_phb3_msi.c | 3 +- hw/pci-host/pnv_phb4.c | 3 +- hw/pci-host/pnv_phb4_pec.c | 3 +- hw/pci-host/ppc4xx_pci.c | 2 +- hw/pci-host/ppce500.c | 2 +- hw/pci-host/raven.c | 6 +- hw/pci-host/sabre.c | 12 +- hw/pci-host/sh_pci.c | 3 +- hw/pci-host/uninorth.c | 11 +- hw/pci-host/versatile.c | 3 +- hw/pci/pci.c | 60 +++-- hw/pci/pcie_sriov.c | 3 +- hw/ppc/amigaone.c | 24 +- hw/ppc/e500.c | 70 ++--- hw/ppc/mac_newworld.c | 58 +++-- hw/ppc/mac_oldworld.c | 32 +-- hw/ppc/pegasos.c | 22 +- hw/ppc/pnv.c | 33 +-- hw/ppc/pnv_bmc.c | 4 +- hw/ppc/pnv_lpc.c | 6 +- hw/ppc/pnv_psi.c | 6 +- hw/ppc/ppc440.h | 2 +- hw/ppc/ppc440_bamboo.c | 17 +- hw/ppc/ppc440_uc.c | 10 +- hw/ppc/ppc4xx_sdram.c | 34 +-- hw/ppc/prep.c | 50 ++-- hw/ppc/sam460ex.c | 72 +++--- hw/ppc/spapr.c | 37 +-- hw/ppc/spapr_irq.c | 6 +- hw/ppc/spapr_vio.c | 6 +- hw/ppc/virtex_ml507.c | 23 +- hw/remote/iommu.c | 5 +- hw/remote/machine.c | 6 +- hw/remote/memory.c | 3 +- hw/remote/vfio-user-obj.c | 2 +- hw/riscv/aia.c | 12 +- hw/riscv/aia.h | 3 +- hw/riscv/boston-aia.c | 31 ++- hw/riscv/cps.c | 14 +- hw/riscv/k230.c | 127 ++++----- hw/riscv/microblaze-v-generic.c | 51 ++-- hw/riscv/microchip_pfsoc.c | 90 +++---- hw/riscv/opentitan.c | 52 ++-- hw/riscv/shakti_c.c | 8 +- hw/riscv/sifive_e.c | 25 +- hw/riscv/sifive_u.c | 39 +-- hw/riscv/spike.c | 8 +- hw/riscv/tt_atlantis.c | 17 +- hw/riscv/virt.c | 57 ++-- hw/riscv/xiangshan_kmh.c | 20 +- hw/rtc/ls7a_rtc.c | 2 +- hw/rtc/mc146818rtc.c | 6 +- hw/rtc/sun4v-rtc.c | 6 +- hw/s390x/ap-bridge.c | 6 +- hw/s390x/css-bridge.c | 7 +- hw/s390x/s390-pci-bus.c | 12 +- hw/s390x/s390-virtio-ccw.c | 41 ++- hw/scsi/esp-pci.c | 2 +- hw/scsi/lasi_ncr710.c | 8 +- hw/scsi/lasi_ncr710.h | 4 +- hw/scsi/ncr53c710.c | 15 +- hw/scsi/ncr53c710.h | 7 +- hw/scsi/scsi-bus.c | 5 +- hw/scsi/spapr_vscsi.c | 6 +- hw/sh4/r2d.c | 38 +-- hw/sh4/sh7750.c | 35 +-- hw/sparc/leon3.c | 27 +- hw/sparc/sun4m.c | 167 ++++++------ hw/sparc64/niagara.c | 20 +- hw/sparc64/sparc64.c | 3 +- hw/sparc64/sun4u.c | 69 ++--- hw/ssi/ssi.c | 7 +- hw/timer/arm_timer.c | 6 +- hw/timer/sh_timer.c | 9 +- hw/tricore/tc27x_soc.c | 77 +++--- hw/tricore/tricore_testboard.c | 19 +- hw/ufs/lu.c | 5 +- hw/usb/bus.c | 15 +- hw/usb/dev-serial.c | 3 +- hw/usb/vt82c686-uhci-pci.c | 4 +- hw/vfio/igd.c | 5 +- hw/virtio/virtio-mem.c | 5 +- hw/vmapple/vmapple.c | 66 ++--- hw/xen/xen-bus.c | 5 +- hw/xen/xen-legacy-backend.c | 5 +- hw/xen/xen-pvh-common.c | 26 +- hw/xen/xen_pt_graphics.c | 3 +- hw/xtensa/mx_pic.c | 8 +- hw/xtensa/pic_cpu.c | 5 +- hw/xtensa/sim.c | 15 +- hw/xtensa/virt.c | 4 +- hw/xtensa/xtensa_memory.c | 5 +- hw/xtensa/xtensa_memory.h | 3 +- hw/xtensa/xtfpga.c | 51 ++-- include/hw/arm/aspeed.h | 6 +- include/hw/arm/aspeed_soc.h | 3 +- include/hw/arm/exynos4210.h | 2 +- include/hw/arm/omap.h | 11 +- include/hw/block/fdc.h | 5 +- include/hw/block/flash.h | 4 +- include/hw/char/mchp_pfsoc_mmuart.h | 2 +- include/hw/char/parallel.h | 5 +- include/hw/char/pl011.h | 2 +- include/hw/char/riscv_htif.h | 3 +- include/hw/char/serial-isa.h | 2 +- include/hw/char/serial-mm.h | 2 +- include/hw/char/sifive_uart.h | 4 +- include/hw/core/cpu.h | 11 +- include/hw/core/irq.h | 27 +- include/hw/core/qdev.h | 50 ++-- include/hw/core/sysbus.h | 29 ++- include/hw/i2c/i2c.h | 29 ++- include/hw/i2c/smbus_eeprom.h | 5 +- include/hw/i386/pc.h | 6 +- include/hw/i386/vmport.h | 5 - include/hw/i386/x86.h | 7 +- include/hw/i3c/i3c.h | 9 +- include/hw/ide/isa.h | 3 +- include/hw/intc/i8259.h | 4 +- include/hw/intc/riscv_aclint.h | 6 +- include/hw/intc/riscv_aplic.h | 5 +- include/hw/intc/riscv_imsic.h | 3 +- include/hw/intc/sifive_plic.h | 3 +- include/hw/isa/i8259_internal.h | 3 +- include/hw/isa/isa.h | 11 +- include/hw/m68k/mcf.h | 7 +- include/hw/mem/sparse-mem.h | 2 +- include/hw/mips/mips.h | 5 +- include/hw/misc/empty_slot.h | 3 +- include/hw/misc/sifive_e_prci.h | 2 +- include/hw/misc/sifive_test.h | 2 +- include/hw/misc/unimp.h | 9 +- include/hw/net/lan9118.h | 2 +- include/hw/net/ne2000-isa.h | 8 +- include/hw/net/smc91c111.h | 2 +- include/hw/nitro/nitro-vsock-bus.h | 2 +- include/hw/nvram/eeprom_at24c.h | 6 +- include/hw/pci/pci.h | 19 +- include/hw/ppc/pnv.h | 2 +- include/hw/ppc/spapr_vio.h | 8 +- include/hw/rtc/mc146818rtc.h | 2 +- include/hw/rtc/sun4v-rtc.h | 2 +- include/hw/sh4/sh.h | 3 +- include/hw/sh4/sh_intc.h | 3 +- include/hw/ssi/ssi.h | 3 +- include/hw/timer/i8254.h | 13 +- include/hw/timer/tmu012.h | 3 +- include/hw/usb/usb.h | 13 +- include/hw/xen/xen.h | 2 +- include/hw/xtensa/mx_pic.h | 4 +- include/net/net.h | 5 +- include/qom/object.h | 25 ++ linux-user/main.c | 6 +- net/net.c | 10 +- qapi/block-core.json | 12 +- qapi/block.json | 2 +- qapi/machine.json | 12 +- qapi/qom.json | 4 +- qom/object.c | 13 + scripts/arm_processor_error.py | 3 +- .../qom-parent/cpu-create-orphan.cocci | 13 + .../qom-parent/i2c-slave-new-orphan.cocci | 18 ++ .../coccinelle/qom-parent/irq-rename.cocci | 14 + .../qom-parent/isa-new-orphan.cocci | 23 ++ .../qom-parent/pci-new-orphan.cocci | 28 ++ .../qom-parent/qdev-new-orphan.cocci | 18 ++ .../qom-parent/ssi-usb-orphan.cocci | 18 ++ .../qom-parent/sysbus-create-orphan.cocci | 18 ++ scripts/qmp_helper.py | 2 +- stubs/xen-hw-stub.c | 2 +- system/ioport.c | 12 +- system/memory.c | 23 +- system/physmem.c | 4 +- system/qdev-monitor.c | 2 +- system/qtest.c | 2 +- system/ram-block-attributes.c | 7 +- system/vl.c | 3 +- target/mips/cpu.c | 5 +- target/mips/cpu.h | 3 +- target/xtensa/cpu.c | 11 - target/xtensa/cpu.h | 2 - tests/qemu-iotests/172.out | 72 +++--- tests/qemu-iotests/186.out | 10 +- tests/qemu-iotests/common.filter | 2 +- tests/qtest/fuzz/generic_fuzz.c | 2 +- tests/unit/test-qdev-global-props.c | 17 +- tests/unit/test-qdev.c | 12 +- 438 files changed, 4515 insertions(+), 3784 deletions(-) create mode 100644 scripts/coccinelle/qom-parent/cpu-create-orphan.cocci create mode 100644 scripts/coccinelle/qom-parent/i2c-slave-new-orphan.cocci create mode 100644 scripts/coccinelle/qom-parent/irq-rename.cocci create mode 100644 scripts/coccinelle/qom-parent/isa-new-orphan.cocci create mode 100644 scripts/coccinelle/qom-parent/pci-new-orphan.cocci create mode 100644 scripts/coccinelle/qom-parent/qdev-new-orphan.cocci create mode 100644 scripts/coccinelle/qom-parent/ssi-usb-orphan.cocci create mode 100644 scripts/coccinelle/qom-parent/sysbus-create-orphan.cocci
Signature · 1 line
2.47.1
RFC PATCH 1/134 qom: Introduce object_new_child()
We already have two ways of creating a QOM object with a parent set from birth: object_initialize_child() for objects embedded in the parent struct, and object_new_with_props() for heap-allocated objects that also want a list of string properties applied. What we do not have is the plain heap-allocated dual of object_initialize_child():
create the object, add it as a child<> of a given parent under a given name, and hand the reference to the parent.
Board and composite-device code that heap-allocates children today therefore either open-codes object_new()+object_property_add_child() +object_unref(), or skips the parenting step entirely and lets device_set_realized() dump the object into /machine/unattached.
Add object_new_child(parent, id, typename) as that missing primitive. The reference created by object_new() is transferred to the parent's child<> property, so on return the sole reference is held by @parent and the caller does not need to unref. Later patches build the qdev and per-bus creation helpers on top of this.
--- include/qom/object.h | 25 +++++++++++++++++++++++++ qom/object.c | 13 +++++++++++++ 2 files changed, 38 insertions(+)
include/qom/object.h +25 -0
@@ -632,6 +632,31 @@ Object *object_new_with_class(ObjectClass *klass);*/ Object *object_new (const char *typename); +/** +* object_new_child: +* @parent: the QOM composition-tree parent +* @id: the child<> property name; the object's canonical QOM path +* becomes @parent's path plus "/" plus @id +* @typename: the name of the type of the object to instantiate +* +* Create a heap-allocated object and immediately add it to the QOM +* composition tree as a child of @parent. +* +* This is the heap-allocated dual of object_initialize_child(): use +* this when the child is a pointer member of the parent, and use +* object_initialize_child() when the child is embedded in the parent +* struct. See also object_new_with_props() for the variant that +* additionally sets a list of properties. +* +* The reference returned by object_new() is transferred to the child<> +* property of @parent, so the object has a reference count of 1 held +* by @parent, and the caller does not need to unref. +* +* Returns: the newly allocated, instantiated and parented object. +*/ +Object *object_new_child (Object *parent,const char *id, +const char *typename); +/** * object_new_with_props: * @typename: The name of the type of the object to instantiate.
qom/object.c +13 -0
@@ -718,6 +718,19 @@ Object *object_new(const char *typename)return object_new_with_type (ti); } +Object *object_new_child (Object *parent,const char *id, +const char *typename) +{ +Object *obj; + +g_assert (parent); +g_assert (id); + + obj =object_new (typename); +object_property_add_child (parent, id, obj); +object_unref (obj); +return obj; +} Object *object_new_with_props(const char *typename, Object *parent,
Signature · 1 line
2.47.1
Re: [RFC PATCH 001/134] qom: Introduce object_new_child()
Quoted 19 lines · Alexander Graf
We already have two ways of creating a QOM object with a parent set from birth:
object_initialize_child()for objects embedded in the parent struct, andobject_new_with_props()for heap-allocated objects that also want a list of string properties applied. What we do not have is the plain heap-allocated dual ofobject_initialize_child():
create the object, add it as a child<> of a given parent under a given name, and hand the reference to the parent.Board and composite-device code that heap-allocates children today therefore either open-codes object_new()+object_property_add_child() +object_unref(), or skips the parenting step entirely and lets
device_set_realized()dump the object into /machine/unattached.Add
object_new_child(parent, id, typename)as that missing primitive. The reference created byobject_new()is transferred to the parent's child<> property, so on return the sole reference is held by @parent and the caller does not need to unref. Later patches build the qdev and per-bus creation helpers on top of this.
Quoted 3 lines
Suggested-by Markus Armbruster <[email protected]>Assisted-by Kiro
QEMU does not currently permit contributions assisted by AI coding tools.
There is an open discussion about altering the policy but that is not conclude with agreement yet.
Quoted 69 lines
Signed-off-by Alexander Graf <[email protected]>--- include/qom/object.h | 25 +++++++++++++++++++++++++ qom/object.c | 13 +++++++++++++ 2 files changed, 38 insertions(+)include/qom/object.h +25
-0@@ -632,6 +632,31 @@ Object *object_new_with_class(ObjectClass *klass);*/ Object *object_new (const char *typename); +/** +* object_new_child: +* @parent: the QOM composition-tree parent +* @id: the child<> property name; the object's canonical QOM path +* becomes @parent's path plus "/" plus @id +* @typename: the name of the type of the object to instantiate +* +* Create a heap-allocated object and immediately add it to the QOM +* composition tree as a child of @parent. +* +* This is the heap-allocated dual of object_initialize_child(): use +* this when the child is a pointer member of the parent, and use +* object_initialize_child() when the child is embedded in the parent +* struct. See also object_new_with_props() for the variant that +* additionally sets a list of properties. +* +* The reference returned by object_new() is transferred to the child<> +* property of @parent, so the object has a reference count of 1 held +* by @parent, and the caller does not need to unref. +* +* Returns: the newly allocated, instantiated and parented object. +*/ +Object *object_new_child (Object *parent,const char *id, +const char *typename); +/** * object_new_with_props: * @typename: The name of the type of the object to instantiate. qom/object.c +13
-0@@ -718,6 +718,19 @@ Object *object_new(const char *typename)return object_new_with_type (ti); } +Object *object_new_child (Object *parent,const char *id, +const char *typename) +{ +Object *obj; + +g_assert (parent); +g_assert (id); + + obj =object_new (typename); +object_property_add_child (parent, id, obj); +object_unref (obj); +return obj; +} Object *object_new_with_props(const char *typename, Object *parent,Signature · 1 line
2.47.1
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
Re: [RFC PATCH 001/134] qom: Introduce object_new_child()
Quoted 20 lines · Daniel P. Berrangé
Quoted 19 lines · Alexander Graf
We already have two ways of creating a QOM object with a parent set from birth:
object_initialize_child()for objects embedded in the parent struct, andobject_new_with_props()for heap-allocated objects that also want a list of string properties applied. What we do not have is the plain heap-allocated dual ofobject_initialize_child():
create the object, add it as a child<> of a given parent under a given name, and hand the reference to the parent.Board and composite-device code that heap-allocates children today therefore either open-codes object_new()+object_property_add_child() +object_unref(), or skips the parenting step entirely and lets
device_set_realized()dump the object into /machine/unattached.Add
object_new_child(parent, id, typename)as that missing primitive. The reference created byobject_new()is transferred to the parent's child<> property, so on return the sole reference is held by @parent and the caller does not need to unref. Later patches build the qdev and per-bus creation helpers on top of this.
Quoted 8 lines
Quoted 3 lines
Suggested-by Markus Armbruster <[email protected]>Assisted-by KiroQEMU does not currently permit contributions assisted by AI coding tools.
There is an open discussion about altering the policy but that is not conclude with agreement yet.
Yup, which is why I called out exactly that in the cover letter too. Is is also the main reason that this patch set is RFC :).
This set is a follow-up from a request by Markus to fix up the QOM parent hierarchy. I said that I (and probably nobody else in CC) had the dedicated time to perform that conversion by hand. And if we "distribute" the work, then IMHO it will just never get done.
But I could easily leave an AI running on the side to get it done. This is so that we can see whether we want to 1/ change our AI stance or 2/ get inspired by the AI code and have someone else redo it by hand or 3/ leave it be and continue living with the QOM tech debt.
Alex
Re: [RFC PATCH 001/134] qom: Introduce object_new_child()
In reply to Alexander GrafQuoted 19 lines · Alexander Graf
We already have two ways of creating a QOM object with a parent set from birth:
object_initialize_child()for objects embedded in the parent struct, andobject_new_with_props()for heap-allocated objects that also want a list of string properties applied. What we do not have is the plain heap-allocated dual ofobject_initialize_child():
create the object, add it as a child<> of a given parent under a given name, and hand the reference to the parent.Board and composite-device code that heap-allocates children today therefore either open-codes object_new()+object_property_add_child() +object_unref(), or skips the parenting step entirely and lets
device_set_realized()dump the object into /machine/unattached.Add
object_new_child(parent, id, typename)as that missing primitive. The reference created byobject_new()is transferred to the parent's child<> property, so on return the sole reference is held by @parent and the caller does not need to unref. Later patches build the qdev and per-bus creation helpers on top of this.
Quoted 8 lines
Suggested-by Markus Armbruster <[email protected]>Assisted-by KiroSigned-off-by Alexander Graf <[email protected]>--- include/qom/object.h | 25 +++++++++++++++++++++++++ qom/object.c | 13 +++++++++++++ 2 files changed, 38 insertions(+)
qom/object.c Object *object_new(const char *typename) · line 727
Quoted 7 lines
qom/object.c +7
-0+Object *object_new_child (Object *parent,const char *id, +const char *typename) +{ +Object *obj; + +g_assert (parent); +g_assert (id);
Of course, typename can't be null either.
But it reminds me that gcc and llvm have attributes nonnull and returns_nonnull; we should be using those, both for their Werror and documentation values.
r~
Re: [RFC PATCH 001/134] qom: Introduce object_new_child()
Quoted 32 lines · Richard Henderson
Quoted 19 lines · Alexander Graf
We already have two ways of creating a QOM object with a parent set from birth:
object_initialize_child()for objects embedded in the parent struct, andobject_new_with_props()for heap-allocated objects that also want a list of string properties applied. What we do not have is the plain heap-allocated dual ofobject_initialize_child():
create the object, add it as a child<> of a given parent under a given name, and hand the reference to the parent.Board and composite-device code that heap-allocates children today therefore either open-codes object_new()+object_property_add_child() +object_unref(), or skips the parenting step entirely and lets
device_set_realized()dump the object into /machine/unattached.Add
object_new_child(parent, id, typename)as that missing primitive. The reference created byobject_new()is transferred to the parent's child<> property, so on return the sole reference is held by @parent and the caller does not need to unref. Later patches build the qdev and per-bus creation helpers on top of this.Quoted 8 lines
Suggested-by Markus Armbruster <[email protected]>Assisted-by KiroSigned-off-by Alexander Graf <[email protected]>--- include/qom/object.h | 25 +++++++++++++++++++++++++ qom/object.c | 13 +++++++++++++ 2 files changed, 38 insertions(+)Reviewed-by Richard Henderson <[email protected]>
Quoted 9 lines
qom/object.c Object *object_new(const char *typename) · line 727
Quoted 7 lines
qom/object.c +7
-0+Object *object_new_child (Object *parent,const char *id, +const char *typename) +{ +Object *obj; + +g_assert (parent); +g_assert (id);Of course, typename can't be null either.
These asserts are of the "not very useful" kind, as well -- if either of these are NULL we're going to crash pretty quickly, and then the debugger backtrace will point you at your programming error. Asserts are most useful when they turn non-obvious bugs into obvious bugs or turn "happens a long time later than when the problem is" bugs into "happens very close to when the problem is". bugs.
-- PMM
Re: [RFC PATCH 001/134] qom: Introduce object_new_child()
Quoted 44 lines · Peter Maydell
Quoted 32 lines · Richard Henderson
Quoted 19 lines · Alexander Graf
We already have two ways of creating a QOM object with a parent set from birth:
object_initialize_child()for objects embedded in the parent struct, andobject_new_with_props()for heap-allocated objects that also want a list of string properties applied. What we do not have is the plain heap-allocated dual ofobject_initialize_child():
create the object, add it as a child<> of a given parent under a given name, and hand the reference to the parent.Board and composite-device code that heap-allocates children today therefore either open-codes object_new()+object_property_add_child() +object_unref(), or skips the parenting step entirely and lets
device_set_realized()dump the object into /machine/unattached.Add
object_new_child(parent, id, typename)as that missing primitive. The reference created byobject_new()is transferred to the parent's child<> property, so on return the sole reference is held by @parent and the caller does not need to unref. Later patches build the qdev and per-bus creation helpers on top of this.Quoted 8 lines
Suggested-by Markus Armbruster <[email protected]>Assisted-by KiroSigned-off-by Alexander Graf <[email protected]>--- include/qom/object.h | 25 +++++++++++++++++++++++++ qom/object.c | 13 +++++++++++++ 2 files changed, 38 insertions(+)Reviewed-by Richard Henderson <[email protected]>Quoted 9 lines
qom/object.c Object *object_new(const char *typename) · line 727
Quoted 7 lines
qom/object.c +7
-0+Object *object_new_child (Object *parent,const char *id, +const char *typename) +{ +Object *obj; + +g_assert (parent); +g_assert (id);Of course, typename can't be null either.
Quoted 7 lines
These asserts are of the "not very useful" kind, as well -- if either of these are NULL we're going to crash pretty quickly, and then the debugger backtrace will point you at your programming error. Asserts are most useful when they turn non-obvious bugs into obvious bugs or turn "happens a long time later than when the problem is" bugs into "happens very close to when the problem is". bugs.
For the 'id', we ought to call id_wellformed, and report an error if it fails, which implies an "Error **errp" arg for this method too.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
Re: [RFC PATCH 001/134] qom: Introduce object_new_child()
Quoted 24 lines · Daniel P. Berrangé
Quoted 14 lines · Peter Maydell
Quoted 11 lines · Richard Henderson
qom/object.c Object *object_new(const char *typename) · line 727
Quoted 7 lines · Alexander Graf
qom/object.c +7
-0+Object *object_new_child (Object *parent,const char *id, +const char *typename) +{ +Object *obj; + +g_assert (parent); +g_assert (id);Of course, typename can't be null either.
Quoted 7 lines
These asserts are of the "not very useful" kind, as well -- if either of these are NULL we're going to crash pretty quickly, and then the debugger backtrace will point you at your programming error. Asserts are most useful when they turn non-obvious bugs into obvious bugs or turn "happens a long time later than when the problem is" bugs into "happens very close to when the problem is". bugs.
Quoted 3 lines
For the 'id', we ought to call
id_wellformed, and report an error if it fails, which implies an "Error **errp" arg for this method too.
That would be a programming error, which we should assert() on if we want to check it. Adding an Error* argument just for that would be forcing all the (many many) callsites to add extra error handling code for a can't-happen case. QOM error-handling boilerplate is bad enough already.
-- PMM
Re: [RFC PATCH 001/134] qom: Introduce object_new_child()
In reply to Richard HendersonQuoted 41 lines · Richard Henderson
Quoted 19 lines · Alexander Graf
We already have two ways of creating a QOM object with a parent set from birth:
object_initialize_child()for objects embedded in the parent struct, andobject_new_with_props()for heap-allocated objects that also want a list of string properties applied. What we do not have is the plain heap-allocated dual ofobject_initialize_child():
create the object, add it as a child<> of a given parent under a given name, and hand the reference to the parent.Board and composite-device code that heap-allocates children today therefore either open-codes object_new()+object_property_add_child() +object_unref(), or skips the parenting step entirely and lets
device_set_realized()dump the object into /machine/unattached.Add
object_new_child(parent, id, typename)as that missing primitive. The reference created byobject_new()is transferred to the parent's child<> property, so on return the sole reference is held by @parent and the caller does not need to unref. Later patches build the qdev and per-bus creation helpers on top of this.Quoted 8 lines
Suggested-by Markus Armbruster <[email protected]>Assisted-by KiroSigned-off-by Alexander Graf <[email protected]>---
include/qom/object.h| 25 +++++++++++++++++++++++++ qom/object.c | 13 +++++++++++++2 files changed, 38 insertions(+)Reviewed-by Richard Henderson <[email protected]>qom/object.c Object *object_new(const char *typename) · line 727
Quoted 7 lines
qom/object.c +7
-0+Object *object_new_child (Object *parent,const char *id, + const char *typename) +{ + Object *obj; + + g_assert(parent); + g_assert(id);Of course, typename can't be null either.
Quoted 1 line
But it reminds me that gcc and llvm have attributes nonnull and
returns_nonnull; we should be using those, both for their Werror and documentation values.
'nonnull' attribute is not useful at runtime, and the odd of writing code with NULL argument are low.
'returns_nonnull' is a hint to optimizers and don't help protecting us from bad code / pattern.
OTOH the one I find useful is 'warn_unused'.
RFC PATCH 2/134 qdev: Rename qdev_new()/qdev_try_new() to *_orphan()
In reply to Alexander Grafqdev_new() creates a device on the heap without a QOM parent. If the caller does not add one before realize, device_set_realized() dumps the device into /machine/unattached with an unstable canonical path.
We want the short spelling qdev_new() to be the one that gets parenting right by construction. As a first step, rename the current functions to qdev_new_orphan() and qdev_try_new_orphan() tree-wide so that a subsequent commit can reintroduce qdev_new() with a mandatory (parent, id, type) signature.
Purely mechanical, generated by
spatch --sp-file scripts/coccinelle/qom-parent/qdev-new-orphan.cocci \
--in-place --include-headers --dir .
or equivalently
git ls-files '*.[ch]' '*.[ch].inc' '*.rst' '*.py' | \
grep -v '^subprojects/' | \
xargs sed -i 's/\bqdev_try_new\b/qdev_try_new_orphan/g;
s/\bqdev_new\b/qdev_new_orphan/g'No functional change.
--- hw/alpha/typhoon.c | 2 +- hw/arm/aspeed.c | 2 +- hw/arm/aspeed_soc_common.c | 4 +- hw/arm/bananapi_m2u.c | 2 +- hw/arm/cubieboard.c | 2 +- hw/arm/exynos4210.c | 12 ++-- hw/arm/imx25_pdk.c | 2 +- hw/arm/imx8mm-evk.c | 2 +- hw/arm/imx8mp-evk.c | 2 +- hw/arm/integratorcp.c | 8 +-- hw/arm/max78000fthr.c | 2 +- hw/arm/mcimx6ul-evk.c | 2 +- hw/arm/mcimx7d-sabre.c | 2 +- hw/arm/mps2-tz.c | 4 +- hw/arm/mps2.c | 4 +- hw/arm/msf2-som.c | 4 +- hw/arm/musicpal.c | 6 +- hw/arm/netduino2.c | 2 +- hw/arm/netduinoplus2.c | 2 +- hw/arm/npcm7xx_boards.c | 4 +- hw/arm/npcm8xx_boards.c | 2 +- hw/arm/olimex-stm32-h405.c | 2 +- hw/arm/omap1.c | 12 ++-- hw/arm/orangepi.c | 2 +- hw/arm/raspi.c | 2 +- hw/arm/realview.c | 18 ++--- hw/arm/sabrelite.c | 2 +- hw/arm/sbsa-ref.c | 20 +++--- hw/arm/stellaris.c | 20 +++--- hw/arm/stm32vldiscovery.c | 2 +- hw/arm/strongarm.c | 4 +- hw/arm/versatilepb.c | 14 ++-- hw/arm/vexpress.c | 14 ++-- hw/arm/virt.c | 24 +++---- hw/arm/xilinx_zynq.c | 26 +++---- hw/arm/xlnx-versal-virt.c | 2 +- hw/arm/xlnx-versal.c | 70 +++++++++---------- hw/arm/xlnx-zcu102.c | 6 +- hw/arm/xlnx-zynqmp.c | 2 +- hw/audio/intel-hda.c | 2 +- hw/audio/model.c | 2 +- hw/avr/atmega.c | 2 +- hw/block/fdc-sysbus.c | 4 +- hw/block/fdc.c | 2 +- hw/block/pflash_cfi01.c | 2 +- hw/block/pflash_cfi02.c | 2 +- hw/block/xen-block.c | 2 +- hw/char/exynos4210_uart.c | 2 +- hw/char/mcf_uart.c | 2 +- hw/char/mchp_pfsoc_mmuart.c | 2 +- hw/char/pl011.c | 2 +- hw/char/serial-mm.c | 2 +- hw/char/sifive_uart.c | 2 +- hw/char/spapr_vty.c | 2 +- hw/char/xen_console.c | 2 +- hw/core/qdev.c | 4 +- hw/core/sysbus.c | 2 +- hw/cxl/cxl-host.c | 2 +- hw/display/sm501.c | 2 +- hw/display/xlnx_dp.c | 4 +- hw/dma/rc4030.c | 2 +- hw/hexagon/hexagon_dsp.c | 4 +- hw/hexagon/virt.c | 6 +- hw/hppa/machine.c | 12 ++-- hw/i2c/core.c | 2 +- hw/i2c/smbus_eeprom.c | 2 +- hw/i386/microvm.c | 6 +- hw/i386/nitro_enclave.c | 4 +- hw/i386/pc.c | 2 +- hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 2 +- hw/i386/pc_sysfw.c | 2 +- hw/i386/sgx.c | 2 +- hw/i386/x86-common.c | 6 +- hw/i3c/core.c | 2 +- hw/ide/ide-bus.c | 2 +- hw/intc/exynos4210_gic.c | 2 +- hw/intc/riscv_aclint.c | 4 +- hw/intc/riscv_aplic.c | 2 +- hw/intc/riscv_imsic.c | 2 +- hw/intc/s390_flic.c | 4 +- hw/intc/sifive_plic.c | 2 +- hw/isa/isa-bus.c | 6 +- hw/loongarch/virt.c | 18 ++--- hw/m68k/an5206.c | 2 +- hw/m68k/mcf_intc.c | 2 +- hw/m68k/next-cube.c | 2 +- hw/m68k/q800.c | 4 +- hw/m68k/virt.c | 10 +-- hw/mem/sparse-mem.c | 2 +- hw/microblaze/petalogix_ml605_mmu.c | 12 ++-- hw/microblaze/petalogix_s3adsp1800_mmu.c | 8 +-- hw/mips/boston.c | 4 +- hw/mips/jazz.c | 12 ++-- hw/mips/loongson3_virt.c | 6 +- hw/mips/malta.c | 4 +- hw/misc/empty_slot.c | 2 +- hw/misc/led.c | 2 +- hw/misc/sifive_e_prci.c | 2 +- hw/misc/sifive_test.c | 2 +- hw/net/lan9118.c | 2 +- hw/net/smc91c111.c | 2 +- hw/net/spapr_llan.c | 2 +- hw/net/xen_nic.c | 2 +- hw/nitro/machine.c | 4 +- hw/nitro/nitro-vsock-bus.c | 2 +- hw/nvme/ctrl.c | 2 +- hw/nvram/fw_cfg.c | 4 +- hw/or1k/or1k-sim.c | 6 +- hw/or1k/virt.c | 8 +-- hw/pci-bridge/pci_expander_bridge.c | 4 +- hw/pci-host/astro.c | 2 +- hw/pci-host/bonito.c | 2 +- hw/pci-host/pnv_phb4_pec.c | 2 +- hw/pci/pci.c | 2 +- hw/ppc/amigaone.c | 2 +- hw/ppc/e500.c | 22 +++--- hw/ppc/mac_newworld.c | 18 ++--- hw/ppc/mac_oldworld.c | 8 +-- hw/ppc/pnv.c | 4 +- hw/ppc/pnv_bmc.c | 2 +- hw/ppc/ppc440_bamboo.c | 4 +- hw/ppc/prep.c | 4 +- hw/ppc/sam460ex.c | 16 ++--- hw/ppc/spapr.c | 4 +- hw/ppc/spapr_irq.c | 2 +- hw/ppc/spapr_vio.c | 2 +- hw/ppc/virtex_ml507.c | 6 +- hw/remote/machine.c | 2 +- hw/riscv/boston-aia.c | 4 +- hw/riscv/microblaze-v-generic.c | 14 ++-- hw/riscv/microchip_pfsoc.c | 2 +- hw/riscv/sifive_u.c | 4 +- hw/riscv/virt.c | 8 +-- hw/rtc/sun4v-rtc.c | 2 +- hw/s390x/ap-bridge.c | 2 +- hw/s390x/css-bridge.c | 2 +- hw/s390x/s390-pci-bus.c | 2 +- hw/s390x/s390-virtio-ccw.c | 6 +- hw/scsi/lasi_ncr710.c | 2 +- hw/scsi/ncr53c710.c | 4 +- hw/scsi/scsi-bus.c | 2 +- hw/scsi/spapr_vscsi.c | 2 +- hw/sh4/r2d.c | 6 +- hw/sh4/sh7750.c | 4 +- hw/sparc/leon3.c | 10 +-- hw/sparc/sun4m.c | 38 +++++----- hw/sparc64/sun4u.c | 14 ++-- hw/ssi/ssi.c | 2 +- hw/tricore/tricore_testboard.c | 2 +- hw/ufs/lu.c | 2 +- hw/usb/bus.c | 4 +- hw/usb/dev-serial.c | 2 +- hw/vmapple/vmapple.c | 20 +++--- hw/xen/xen-bus.c | 2 +- hw/xen/xen-legacy-backend.c | 2 +- hw/xen/xen-pvh-common.c | 2 +- hw/xtensa/virt.c | 2 +- hw/xtensa/xtfpga.c | 2 +- include/hw/core/qdev.h | 14 ++-- include/hw/i2c/i2c.h | 2 +- include/hw/misc/unimp.h | 2 +- include/hw/ssi/ssi.h | 2 +- include/hw/usb/usb.h | 2 +- migration/migration.c | 2 +- net/net.c | 4 +- .../qom-parent/qdev-new-orphan.cocci | 18 +++++ system/qdev-monitor.c | 2 +- target/mips/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- 170 files changed, 459 insertions(+), 441 deletions(-) create mode 100644 scripts/coccinelle/qom-parent/qdev-new-orphan.cocci
hw/alpha/typhoon.c +1 -1
@@ -830,7 +830,7 @@ PCIBus *typhoon_init(MemoryRegion *ram, qemu_irq *p_isa_irq,PCIBus *b;int i; - dev =qdev_new (TYPE_TYPHOON_PCI_HOST_BRIDGE ); + dev =qdev_new_orphan (TYPE_TYPHOON_PCI_HOST_BRIDGE ); s =TYPHOON_PCI_HOST_BRIDGE (dev); phb =PCI_HOST_BRIDGE (dev);
hw/arm/aspeed.c +1 -1
@@ -90,7 +90,7 @@ static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo, bool emmc,if (!dinfo) {return ; } - card =qdev_new (emmc ?TYPE_EMMC :TYPE_SD_CARD ); + card =qdev_new_orphan (emmc ?TYPE_EMMC :TYPE_SD_CARD );/* * Force the boot properties of the eMMC device only when the
hw/arm/aspeed_soc_common.c +2 -2
@@ -81,7 +81,7 @@ bool aspeed_soc_dram_init(AspeedSoCState *s, Error **errp)* SoC has. */ if (ram_size < max_ram_size) { -DeviceState *dev =qdev_new (TYPE_UNIMPLEMENTED_DEVICE ); +DeviceState *dev =qdev_new_orphan (TYPE_UNIMPLEMENTED_DEVICE );qdev_prop_set_string (dev,"name" ,"ram-empty" );qdev_prop_set_uint64 (dev,"size" , max_ram_size - ram_size);
@@ -128,7 +128,7 @@ void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype,DriveInfo *dinfo =drive_get (IF_MTD ,0 , unit0 + i);DeviceState *dev; - dev =qdev_new (flashtype); + dev =qdev_new_orphan (flashtype);if (dinfo) {qdev_prop_set_drive (dev,"drive" ,blk_by_legacy_dinfo (dinfo)); }
hw/arm/bananapi_m2u.c +1 -1
@@ -50,7 +50,7 @@ static void mmc_attach_drive(AwR40State *s, AwSdHostState *mmc, int unit,exit (1 ); } - carddev =qdev_new (TYPE_SD_CARD ); + carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev, bus, &error_fatal);
hw/arm/cubieboard.c +1 -1
@@ -89,7 +89,7 @@ static void cubieboard_init(MachineState *machine) bus =qdev_get_child_bus (DEVICE (a10),"sd-bus" );/* Plug in SD card */ - carddev =qdev_new (TYPE_SD_CARD ); + carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev, bus, &error_fatal);
hw/arm/exynos4210.c +6 -6
@@ -519,7 +519,7 @@ static DeviceState *pl330_create(uint32_t base, OrIRQState *orgate,DeviceState *dev;int i; - dev =qdev_new ("pl330" ); + dev =qdev_new_orphan ("pl330" );object_property_set_link (OBJECT (dev),"memory" ,OBJECT (get_system_memory ()), &error_fatal);
@@ -687,7 +687,7 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) NULL);/* Multi Core Timer */ - dev =qdev_new ("exynos4210.mct" ); + dev =qdev_new_orphan ("exynos4210.mct" ); busdev =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (busdev, &error_fatal);for (n =0 ; n <4 ; n++) {
@@ -713,7 +713,7 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) i2c_irq = s->irq_table[exynos4210_get_irq (EXYNOS4210_HDMI_INTG ,1 )]; } - dev =qdev_new ("exynos4210.i2c" ); + dev =qdev_new_orphan ("exynos4210.i2c" ); busdev =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (busdev, &error_fatal);sysbus_connect_irq (busdev,0 , i2c_irq);
@@ -757,7 +757,7 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)* public datasheet which is very similar (implementing * MMC Specification Version 4.0 being the only difference noted) */ - dev =qdev_new (TYPE_S3C_SDHCI ); + dev =qdev_new_orphan (TYPE_S3C_SDHCI );qdev_prop_set_uint64 (dev,"capareg" ,EXYNOS4210_SDHCI_CAPABILITIES ); busdev =SYS_BUS_DEVICE (dev);
@@ -767,14 +767,14 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) di =drive_get (IF_SD ,0 , n); blk = di ?blk_by_legacy_dinfo (di) :NULL ; - carddev =qdev_new (TYPE_SD_CARD ); + carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive (carddev,"drive" , blk);qdev_realize_and_unref (carddev,qdev_get_child_bus (dev,"sd-bus" ), &error_fatal); }/*** Display controller (FIMD) ***/ - dev =qdev_new ("exynos4210.fimd" ); + dev =qdev_new_orphan ("exynos4210.fimd" );object_property_set_link (OBJECT (dev),"framebuffer-memory" ,OBJECT (system_mem), &error_fatal); busdev =SYS_BUS_DEVICE (dev);
hw/arm/imx25_pdk.c +1 -1
@@ -127,7 +127,7 @@ static void imx25_pdk_init(MachineState *machine) di =drive_get (IF_SD ,0 , i); blk = di ?blk_by_legacy_dinfo (di) :NULL ; bus =qdev_get_child_bus (DEVICE (&s->soc.esdhc[i]),"sd-bus" ); - carddev =qdev_new (TYPE_SD_CARD ); + carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev, bus, &error_fatal); }
hw/arm/imx8mm-evk.c +1 -1
@@ -97,7 +97,7 @@ static void imx8mm_evk_init(MachineState *machine) blk =blk_by_legacy_dinfo (di); bus =qdev_get_child_bus (DEVICE (&s->usdhc[i]),"sd-bus" ); - carddev =qdev_new (TYPE_SD_CARD ); + carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev, bus, &error_fatal); }
hw/arm/imx8mp-evk.c +1 -1
@@ -110,7 +110,7 @@ static void imx8mp_evk_init(MachineState *machine) blk =blk_by_legacy_dinfo (di); bus =qdev_get_child_bus (DEVICE (&s->soc.usdhc[i]),"sd-bus" ); - carddev =qdev_new (TYPE_SD_CARD ); + carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev, bus, &error_fatal); }
hw/arm/integratorcp.c +4 -4
@@ -621,7 +621,7 @@ static void integratorcp_init(MachineState *machine) 0, ram_size);memory_region_add_subregion (address_space_mem,0x80000000 , ram_alias); - dev =qdev_new (TYPE_INTEGRATOR_CM ); + dev =qdev_new_orphan (TYPE_INTEGRATOR_CM );qdev_prop_set_uint32 (dev,"memsz" , ram_size >>20 );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map ((SysBusDevice *)dev,0 ,0x10000000 );
@@ -654,14 +654,14 @@ static void integratorcp_init(MachineState *machine)if (dinfo) {DeviceState *card; - card =qdev_new (TYPE_SD_CARD ); + card =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (card,"drive" ,blk_by_legacy_dinfo (dinfo), &error_fatal);qdev_realize_and_unref (card,qdev_get_child_bus (dev,"sd-bus" ), &error_fatal); } - dev =qdev_new ("pl041" ); + dev =qdev_new_orphan ("pl041" );if (machine->audiodev) {qdev_prop_set_string (dev,"audiodev" , machine->audiodev); }
@@ -673,7 +673,7 @@ static void integratorcp_init(MachineState *machine)smc91c111_init (0xc8000000 , pic[27 ]); } - dev =qdev_new ("pl110" ); + dev =qdev_new_orphan ("pl110" );object_property_set_link (OBJECT (dev),"framebuffer-memory" ,OBJECT (address_space_mem), &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/arm/max78000fthr.c +1 -1
@@ -26,7 +26,7 @@ static void max78000_init(MachineState *machine) sysclk =clock_new (OBJECT (machine),"SYSCLK" );clock_set_hz (sysclk,SYSCLK_FRQ ); - dev =qdev_new (TYPE_MAX78000_SOC ); + dev =qdev_new_orphan (TYPE_MAX78000_SOC );object_property_add_child (OBJECT (machine),"soc" ,OBJECT (dev));qdev_connect_clock_in (dev,"sysclk" , sysclk);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/arm/mcimx6ul-evk.c +1 -1
@@ -59,7 +59,7 @@ static void mcimx6ul_evk_init(MachineState *machine) di =drive_get (IF_SD ,0 , i); blk = di ?blk_by_legacy_dinfo (di) :NULL ; bus =qdev_get_child_bus (DEVICE (&s->usdhc[i]),"sd-bus" ); - carddev =qdev_new (TYPE_SD_CARD ); + carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev, bus, &error_fatal); }
hw/arm/mcimx7d-sabre.c +1 -1
@@ -59,7 +59,7 @@ static void mcimx7d_sabre_init(MachineState *machine) di =drive_get (IF_SD ,0 , i); blk = di ?blk_by_legacy_dinfo (di) :NULL ; bus =qdev_get_child_bus (DEVICE (&s->usdhc[i]),"sd-bus" ); - carddev =qdev_new (TYPE_SD_CARD ); + carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev, bus, &error_fatal); }
hw/arm/mps2-tz.c +2 -2
@@ -508,7 +508,7 @@ static MemoryRegion *make_eth_dev(MPS2TZMachineState *mms, void *opaque,/* In hardware this is a LAN9220; the LAN9118 is software compatible * except that it doesn't support the checksum-offload feature. */ - mms->lan9118 =qdev_new (TYPE_LAN9118 ); + mms->lan9118 =qdev_new_orphan (TYPE_LAN9118 );qemu_configure_nic_device (mms->lan9118, true,NULL ); s =SYS_BUS_DEVICE (mms->lan9118);
@@ -535,7 +535,7 @@ static MemoryRegion *make_eth_usb(MPS2TZMachineState *mms, void *opaque,* In hardware this is a LAN9220; the LAN9118 is software compatible * except that it doesn't support the checksum-offload feature. */ - mms->lan9118 =qdev_new (TYPE_LAN9118 ); + mms->lan9118 =qdev_new_orphan (TYPE_LAN9118 );qemu_configure_nic_device (mms->lan9118, true,NULL ); s =SYS_BUS_DEVICE (mms->lan9118);
hw/arm/mps2.c +2 -2
@@ -299,7 +299,7 @@ static void mps2_common_init(MachineState *machine) rxovrint =qdev_get_gpio_in (orgate_dev, i *2 +1 ); } - dev =qdev_new (TYPE_CMSDK_APB_UART ); + dev =qdev_new_orphan (TYPE_CMSDK_APB_UART ); s =SYS_BUS_DEVICE (dev);qdev_prop_set_chr (dev,"chardev" ,serial_hd (i));qdev_prop_set_uint32 (dev,"pclk-frq" ,SYSCLK_FRQ );
@@ -343,7 +343,7 @@ static void mps2_common_init(MachineState *machine)qdev_connect_gpio_out (txrx_orgate_dev,0 ,qdev_get_gpio_in (armv7m, uart_txrx_irqno[i])); - dev =qdev_new (TYPE_CMSDK_APB_UART ); + dev =qdev_new_orphan (TYPE_CMSDK_APB_UART ); s =SYS_BUS_DEVICE (dev);qdev_prop_set_chr (dev,"chardev" ,serial_hd (i));qdev_prop_set_uint32 (dev,"pclk-frq" ,SYSCLK_FRQ );
hw/arm/msf2-som.c +2 -2
@@ -59,7 +59,7 @@ static void emcraft_sf2_s2s010_init(MachineState *machine) &error_fatal);memory_region_add_subregion (sysmem,DDR_BASE_ADDRESS , ddr); - dev =qdev_new (TYPE_MSF2_SOC ); + dev =qdev_new_orphan (TYPE_MSF2_SOC );object_property_add_child (OBJECT (machine),"soc" ,OBJECT (dev));qdev_prop_set_string (dev,"part-name" ,"M2S010" );qdev_prop_set_uint64 (dev,"eNVM-size" ,M2S010_ENVM_SIZE );
@@ -83,7 +83,7 @@ static void emcraft_sf2_s2s010_init(MachineState *machine)/* Attach SPI flash to SPI0 controller */ spi_bus =qdev_get_child_bus (dev,"spi0" ); - spi_flash =qdev_new ("s25sl12801" );/* Spansion S25FL128SDPBHICO */ + spi_flash =qdev_new_orphan ("s25sl12801" );/* Spansion S25FL128SDPBHICO */ qdev_prop_set_uint8 (spi_flash,"spansion-cr2nv" ,0x8 );if (dinfo) { qdev_prop_set_drive_err(spi_flash, "drive",
hw/arm/musicpal.c +3 -3
@@ -1249,7 +1249,7 @@ static void musicpal_init(MachineState *machine) qdev_get_gpio_in(pic, MP_TIMER4_IRQ), NULL);/* Logically OR both UART IRQs together */ - uart_orgate =qdev_new (TYPE_OR_IRQ ); + uart_orgate =qdev_new_orphan (TYPE_OR_IRQ );object_property_set_int (OBJECT (uart_orgate),"num-lines" ,2 , &error_fatal);qdev_realize_and_unref (uart_orgate,NULL , &error_fatal); qdev_connect_gpio_out(uart_orgate, 0,
@@ -1288,7 +1288,7 @@ static void musicpal_init(MachineState *machine) }sysbus_create_simple (TYPE_MV88W8618_FLASHCFG ,MP_FLASHCFG_BASE ,NULL ); - dev =qdev_new (TYPE_MV88W8618_ETH ); + dev =qdev_new_orphan (TYPE_MV88W8618_ETH );qemu_configure_nic_device (dev, true,"mv88w8618" );object_property_set_link (OBJECT (dev),"dma-memory" ,OBJECT (get_system_memory ()), &error_fatal);
@@ -1333,7 +1333,7 @@ static void musicpal_init(MachineState *machine) }i2c_slave_realize_and_unref (wm8750_dev, i2c, &error_abort); - dev =qdev_new (TYPE_MV88W8618_AUDIO ); + dev =qdev_new_orphan (TYPE_MV88W8618_AUDIO ); s =SYS_BUS_DEVICE (dev);object_property_set_link (OBJECT (dev),"wm8750" ,OBJECT (wm8750_dev),NULL );
hw/arm/netduino2.c +1 -1
@@ -44,7 +44,7 @@ static void netduino2_init(MachineState *machine) sysclk =clock_new (OBJECT (machine),"SYSCLK" );clock_set_hz (sysclk,SYSCLK_FRQ ); - dev =qdev_new (TYPE_STM32F205_SOC ); + dev =qdev_new_orphan (TYPE_STM32F205_SOC );object_property_add_child (OBJECT (machine),"soc" ,OBJECT (dev));qdev_connect_clock_in (dev,"sysclk" , sysclk);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/arm/netduinoplus2.c +1 -1
@@ -44,7 +44,7 @@ static void netduinoplus2_init(MachineState *machine) sysclk =clock_new (OBJECT (machine),"SYSCLK" );clock_set_hz (sysclk,SYSCLK_FRQ ); - dev =qdev_new (TYPE_STM32F405_SOC ); + dev =qdev_new_orphan (TYPE_STM32F405_SOC );object_property_add_child (OBJECT (machine),"soc" ,OBJECT (dev));qdev_connect_clock_in (dev,"sysclk" , sysclk);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/arm/npcm7xx_boards.c +2 -2
@@ -84,7 +84,7 @@ static void npcm7xx_connect_flash(NPCM7xxFIUState *fiu, int cs_no,DeviceState *flash;qemu_irq flash_cs; - flash =qdev_new (flash_type); + flash =qdev_new_orphan (flash_type);if (dinfo) {qdev_prop_set_drive (flash,"drive" ,blk_by_legacy_dinfo (dinfo)); }
@@ -113,7 +113,7 @@ static void sdhci_attach_drive(SDHCIState *sdhci, int unit)exit (1 ); } -DeviceState *carddev =qdev_new (TYPE_SD_CARD ); +DeviceState *carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev, bus, &error_fatal); }
hw/arm/npcm8xx_boards.c +1 -1
@@ -61,7 +61,7 @@ static void npcm8xx_connect_flash(NPCM7xxFIUState *fiu, int cs_no,DeviceState *flash;qemu_irq flash_cs; - flash =qdev_new (flash_type); + flash =qdev_new_orphan (flash_type);if (dinfo) {qdev_prop_set_drive (flash,"drive" ,blk_by_legacy_dinfo (dinfo)); }
hw/arm/olimex-stm32-h405.c +1 -1
@@ -47,7 +47,7 @@ static void olimex_stm32_h405_init(MachineState *machine) sysclk =clock_new (OBJECT (machine),"SYSCLK" );clock_set_hz (sysclk,SYSCLK_FRQ ); - dev =qdev_new (TYPE_STM32F405_SOC ); + dev =qdev_new_orphan (TYPE_STM32F405_SOC );object_property_add_child (OBJECT (machine),"soc" ,OBJECT (dev));qdev_connect_clock_in (dev,"sysclk" , sysclk);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/arm/omap1.c +6 -6
@@ -3763,7 +3763,7 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *dram,omap_clkm_init (system_memory,0xfffece00 ,0xe1008000 , s); - s->ih[0 ] =qdev_new ("omap-intc" ); + s->ih[0 ] =qdev_new_orphan ("omap-intc" );qdev_prop_set_uint32 (s->ih[0 ],"size" ,0x100 );omap_intc_set_iclk (OMAP_INTC (s->ih[0 ]),omap_findclk (s,"arminth_ck" )); busdev =SYS_BUS_DEVICE (s->ih[0 ]);
@@ -3773,7 +3773,7 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *dram,sysbus_connect_irq (busdev,1 ,qdev_get_gpio_in (DEVICE (s->cpu),ARM_CPU_FIQ ));sysbus_mmio_map (busdev,0 ,0xfffecb00 ); - s->ih[1 ] =qdev_new ("omap-intc" ); + s->ih[1 ] =qdev_new_orphan ("omap-intc" );qdev_prop_set_uint32 (s->ih[1 ],"size" ,0x800 );omap_intc_set_iclk (OMAP_INTC (s->ih[1 ]),omap_findclk (s,"arminth_ck" )); busdev =SYS_BUS_DEVICE (s->ih[1 ]);
@@ -3876,7 +3876,7 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *dram,warn_report ("missing SecureDigital device" ); } - s->mmc =qdev_new (TYPE_OMAP_MMC ); + s->mmc =qdev_new_orphan (TYPE_OMAP_MMC );sysbus_realize_and_unref (SYS_BUS_DEVICE (s->mmc), &error_fatal);omap_mmc_set_clk (s->mmc,omap_findclk (s,"mmc_ck" ));
@@ -3888,7 +3888,7 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *dram, qdev_get_gpio_in(s->ih[1], OMAP_INT_OQN));if (dinfo) { -DeviceState *card =qdev_new (TYPE_SD_CARD ); +DeviceState *card =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (card,"drive" ,blk_by_legacy_dinfo (dinfo), &error_fatal); qdev_realize_and_unref(card, qdev_get_child_bus(s->mmc, "sd-bus"),
@@ -3900,7 +3900,7 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *dram,qdev_get_gpio_in (s->ih[1 ],OMAP_INT_MPUIO ), omap_findclk(s, "clk32-kHz")); - s->gpio =qdev_new ("omap-gpio" ); + s->gpio =qdev_new_orphan ("omap-gpio" );omap_gpio_set_clk (OMAP1_GPIO (s->gpio),omap_findclk (s,"arm_gpio_ck" ));sysbus_realize_and_unref (SYS_BUS_DEVICE (s->gpio), &error_fatal); sysbus_connect_irq(SYS_BUS_DEVICE(s->gpio), 0,
@@ -3917,7 +3917,7 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *dram, s->pwt =omap_pwt_init (system_memory,0xfffb6000 ,omap_findclk (s,"armxor_ck" )); - s->i2c[0 ] =qdev_new ("omap_i2c" ); + s->i2c[0 ] =qdev_new_orphan ("omap_i2c" );qdev_prop_set_uint8 (s->i2c[0 ],"revision" ,0x11 );omap_i2c_set_fclk (OMAP_I2C (s->i2c[0 ]),omap_findclk (s,"mpuper_ck" )); busdev =SYS_BUS_DEVICE (s->i2c[0 ]);
hw/arm/orangepi.c +1 -1
@@ -85,7 +85,7 @@ static void orangepi_init(MachineState *machine) bus =qdev_get_child_bus (DEVICE (h3),"sd-bus" );/* Plug in SD card */ - carddev =qdev_new (TYPE_SD_CARD ); + carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev, bus, &error_fatal);
hw/arm/raspi.c +1 -1
@@ -283,7 +283,7 @@ void raspi_base_machine_init(MachineState *machine,error_report ("No SD bus found in SOC object" );exit (1 ); } - carddev =qdev_new (TYPE_SD_CARD ); + carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev, bus, &error_fatal);
hw/arm/realview.c +9 -9
@@ -61,7 +61,7 @@ static const int realview_board_id[] = {static void split_irq_from_named (DeviceState *src,const char * outname,qemu_irq out1,qemu_irq out2) { -DeviceState *splitter =qdev_new (TYPE_SPLIT_IRQ ); +DeviceState *splitter =qdev_new_orphan (TYPE_SPLIT_IRQ );qdev_prop_set_uint32 (splitter,"num-lines" ,2 );
@@ -180,7 +180,7 @@ static void realview_init(MachineState *machine, } sys_id = is_pb ?0x01780500 :0xc1400400 ; - sysctl =qdev_new ("realview_sysctl" ); + sysctl =qdev_new_orphan ("realview_sysctl" );qdev_prop_set_uint32 (sysctl,"sys_id" , sys_id);qdev_prop_set_uint32 (sysctl,"proc_id" , proc_id);sysbus_realize_and_unref (SYS_BUS_DEVICE (sysctl), &error_fatal);
@@ -188,10 +188,10 @@ static void realview_init(MachineState *machine,if (is_mpcore) {if (is_pb) { - dev =qdev_new (TYPE_A9MPCORE_PRIV ); + dev =qdev_new_orphan (TYPE_A9MPCORE_PRIV );qdev_prop_set_uint32 (dev,"num-irq" ,GIC_EXT_IRQS +GIC_INTERNAL ); }else { - dev =qdev_new ("realview_mpcore" ); + dev =qdev_new_orphan ("realview_mpcore" ); }qdev_prop_set_uint32 (dev,"num-cpu" , smp_cpus); busdev =SYS_BUS_DEVICE (dev);
@@ -212,7 +212,7 @@ static void realview_init(MachineState *machine, pic[n] =qdev_get_gpio_in (dev, n); } - pl041 =qdev_new ("pl041" ); + pl041 =qdev_new_orphan ("pl041" );qdev_prop_set_uint32 (pl041,"nc_fifo_depth" ,512 );if (machine->audiodev) {qdev_prop_set_string (pl041,"audiodev" , machine->audiodev);
@@ -230,7 +230,7 @@ static void realview_init(MachineState *machine,pl011_create (0x1000c000 , pic[15 ],serial_hd (3 ));/* DMA controller is optional, apparently. */ - dev =qdev_new ("pl081" ); + dev =qdev_new_orphan ("pl081" );object_property_set_link (OBJECT (dev),"downstream" ,OBJECT (sysmem), &error_fatal); busdev =SYS_BUS_DEVICE (dev);
@@ -245,7 +245,7 @@ static void realview_init(MachineState *machine,sysbus_create_simple ("pl061" ,0x10014000 , pic[7 ]); gpio2 =sysbus_create_simple ("pl061" ,0x10015000 , pic[8 ]); - dev =qdev_new ("pl111" ); + dev =qdev_new_orphan ("pl111" );object_property_set_link (OBJECT (dev),"framebuffer-memory" ,OBJECT (sysmem), &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -271,7 +271,7 @@ static void realview_init(MachineState *machine,if (dinfo) {DeviceState *card; - card =qdev_new (TYPE_SD_CARD ); + card =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (card,"drive" ,blk_by_legacy_dinfo (dinfo), &error_fatal); qdev_realize_and_unref(card, qdev_get_child_bus(dev, "sd-bus"),
@@ -281,7 +281,7 @@ static void realview_init(MachineState *machine,sysbus_create_simple ("pl031" ,0x10017000 , pic[10 ]);if (!is_pb) { - dev =qdev_new ("realview_pci" ); + dev =qdev_new_orphan ("realview_pci" ); busdev =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (busdev, &error_fatal);sysbus_mmio_map (busdev,0 ,0x10019000 );/* PCI controller registers */
hw/arm/sabrelite.c +1 -1
@@ -96,7 +96,7 @@ static void sabrelite_init(MachineState *machine)qemu_irq cs_line;DriveInfo *dinfo =drive_get (IF_MTD ,0 ,0 ); - flash_dev =qdev_new ("sst25vf016b" ); + flash_dev =qdev_new_orphan ("sst25vf016b" );if (dinfo) { qdev_prop_set_drive_err(flash_dev, "drive", blk_by_legacy_dinfo(dinfo),
hw/arm/sbsa-ref.c +10 -10
@@ -296,7 +296,7 @@ static PFlashCFI01 *sbsa_flash_create1(SBSAMachineState *sms,* Create a single flash device. We use the same parameters as * the flash devices on the Versatile Express board. */ -DeviceState *dev =qdev_new (TYPE_PFLASH_CFI01 ); +DeviceState *dev =qdev_new_orphan (TYPE_PFLASH_CFI01 );qdev_prop_set_uint64 (dev,"sector-length" ,SBSA_FLASH_SECTOR_SIZE );qdev_prop_set_uint8 (dev,"width" ,4 );
@@ -421,7 +421,7 @@ static void create_its(SBSAMachineState *sms)const char *itsclass =its_class_name ();DeviceState *dev; - dev =qdev_new (itsclass); + dev =qdev_new_orphan (itsclass);object_property_set_link (OBJECT (dev),"parent-gicv3" ,OBJECT (sms->gic), &error_abort);
@@ -440,7 +440,7 @@ static void create_gic(SBSAMachineState *sms, MemoryRegion *mem) gictype =gicv3_class_name (); - sms->gic =qdev_new (gictype); + sms->gic =qdev_new_orphan (gictype);qdev_prop_set_uint32 (sms->gic,"revision" ,3 );qdev_prop_set_uint32 (sms->gic,"num-cpu" , smp_cpus);/*
@@ -522,7 +522,7 @@ static void create_uart(const SBSAMachineState *sms, int uart, {hwaddr base = sbsa_ref_memmap[uart].base;int irq = sbsa_ref_irqmap[uart]; -DeviceState *dev =qdev_new (TYPE_PL011 ); +DeviceState *dev =qdev_new_orphan (TYPE_PL011 );SysBusDevice *s =SYS_BUS_DEVICE (dev);qdev_prop_set_chr (dev,"chardev" , chr);
@@ -544,7 +544,7 @@ static void create_wdt(const SBSAMachineState *sms) {hwaddr rbase = sbsa_ref_memmap[SBSA_GWDT_REFRESH ].base;hwaddr cbase = sbsa_ref_memmap[SBSA_GWDT_CONTROL ].base; -DeviceState *dev =qdev_new (TYPE_WDT_SBSA ); +DeviceState *dev =qdev_new_orphan (TYPE_WDT_SBSA );SysBusDevice *s =SYS_BUS_DEVICE (dev);int irq = sbsa_ref_irqmap[SBSA_GWDT_WS0 ];
@@ -590,7 +590,7 @@ static void create_ahci(const SBSAMachineState *sms)DriveInfo *hd[NUM_SATA_PORTS ];SysbusAHCIState *sysahci; - dev =qdev_new ("sysbus-ahci" ); + dev =qdev_new_orphan ("sysbus-ahci" );qdev_prop_set_uint32 (dev,"num-ports" ,NUM_SATA_PORTS );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 , base);
@@ -605,7 +605,7 @@ static void create_xhci(const SBSAMachineState *sms) {hwaddr base = sbsa_ref_memmap[SBSA_XHCI ].base;int irq = sbsa_ref_irqmap[SBSA_XHCI ]; -DeviceState *dev =qdev_new (TYPE_XHCI_SYSBUS ); +DeviceState *dev =qdev_new_orphan (TYPE_XHCI_SYSBUS );qdev_prop_set_uint32 (dev,"slots" ,XHCI_MAXSLOTS );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -622,7 +622,7 @@ static void create_smmu(const SBSAMachineState *sms, PCIBus *bus,DeviceState *dev;int i; - dev =qdev_new (TYPE_ARM_SMMUV3 ); + dev =qdev_new_orphan (TYPE_ARM_SMMUV3 );object_property_set_str (OBJECT (dev),"stage" ,"nested" , &error_abort); object_property_set_link(OBJECT(dev), "primary-bus", OBJECT(bus),
@@ -658,7 +658,7 @@ static void create_pcie(SBSAMachineState *sms,PCIHostState *pci;int i; - dev =qdev_new (TYPE_GPEX_HOST ); + dev =qdev_new_orphan (TYPE_GPEX_HOST );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);/* Map ECAM space */
@@ -712,7 +712,7 @@ static void *sbsa_ref_dtb(const struct arm_boot_info *binfo, int *fdt_size)static void create_secure_ec (MemoryRegion *mem) {hwaddr base = sbsa_ref_memmap[SBSA_SECURE_EC ].base; -DeviceState *dev =qdev_new ("sbsa-ec" ); +DeviceState *dev =qdev_new_orphan ("sbsa-ec" );SysBusDevice *s =SYS_BUS_DEVICE (dev); memory_region_add_subregion(mem, base,
hw/arm/stellaris.c +10 -10
@@ -1096,7 +1096,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)* Create the system-registers object early, because we will * need its sysclk output. */ - ssys_dev =qdev_new (TYPE_STELLARIS_SYS ); + ssys_dev =qdev_new_orphan (TYPE_STELLARIS_SYS );object_property_add_child (soc_container,"sys" ,OBJECT (ssys_dev));/*
@@ -1123,7 +1123,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)qdev_prop_set_uint32 (ssys_dev,"dc4" , board->dc4);sysbus_realize_and_unref (SYS_BUS_DEVICE (ssys_dev), &error_fatal); - armv7m =qdev_new (TYPE_ARMV7M ); + armv7m =qdev_new_orphan (TYPE_ARMV7M );object_property_add_child (soc_container,"v7m" ,OBJECT (armv7m));qdev_prop_set_uint32 (armv7m,"num-irq" ,NUM_IRQ_LINES );qdev_prop_set_uint8 (armv7m,"num-prio-bits" ,NUM_PRIO_BITS );
@@ -1157,7 +1157,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)if (DEV_CAP (2 ,GPTM (i))) {SysBusDevice *sbd; - dev =qdev_new (TYPE_STELLARIS_GPTM ); + dev =qdev_new_orphan (TYPE_STELLARIS_GPTM ); sbd =SYS_BUS_DEVICE (dev);object_property_add_child (soc_container,"gptm[*]" ,OBJECT (dev)); qdev_connect_clock_in(dev, "clk",
@@ -1172,7 +1172,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) }if (DEV_CAP (1 ,WDT )) { - dev =qdev_new (TYPE_LUMINARY_WATCHDOG ); + dev =qdev_new_orphan (TYPE_LUMINARY_WATCHDOG );object_property_add_child (soc_container,"wdg" ,OBJECT (dev));qdev_connect_clock_in (dev,"WDOGCLK" ,qdev_get_clock_out (ssys_dev,"SYSCLK" ));
@@ -1216,7 +1216,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)if (DEV_CAP (2 ,UART (i))) {SysBusDevice *sbd; - dev =qdev_new ("pl011_luminary" ); + dev =qdev_new_orphan ("pl011_luminary" );object_property_add_child (soc_container,"uart[*]" ,OBJECT (dev)); sbd =SYS_BUS_DEVICE (dev);qdev_prop_set_chr (dev,"chardev" ,serial_hd (i));
@@ -1304,18 +1304,18 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) dinfo =drive_get (IF_SD ,0 ,0 ); blk = dinfo ?blk_by_legacy_dinfo (dinfo) :NULL ; - carddev =qdev_new (TYPE_SD_CARD_SPI ); + carddev =qdev_new_orphan (TYPE_SD_CARD_SPI );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev,qdev_get_child_bus (sddev,"sd-bus" ), &error_fatal); - ssddev =qdev_new ("ssd0323" ); + ssddev =qdev_new_orphan ("ssd0323" );object_property_add_child (OBJECT (ms),"oled" ,OBJECT (ssddev));qdev_prop_set_uint8 (ssddev,"cs" ,1 );qdev_realize_and_unref (ssddev, bus, &error_fatal); - gpio_d_splitter =qdev_new (TYPE_SPLIT_IRQ ); + gpio_d_splitter =qdev_new_orphan (TYPE_SPLIT_IRQ );object_property_add_child (OBJECT (ms),"splitter" ,OBJECT (gpio_d_splitter));qdev_prop_set_uint32 (gpio_d_splitter,"num-lines" ,2 );
@@ -1337,7 +1337,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)if (DEV_CAP (4 ,EMAC )) {DeviceState *enet; - enet =qdev_new ("stellaris_enet" ); + enet =qdev_new_orphan ("stellaris_enet" );object_property_add_child (soc_container,"enet" ,OBJECT (enet));if (nd) {qdev_set_nic_properties (enet, nd);
@@ -1357,7 +1357,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) };DeviceState *gpad; - gpad =qdev_new (TYPE_STELLARIS_GAMEPAD ); + gpad =qdev_new_orphan (TYPE_STELLARIS_GAMEPAD );object_property_add_child (OBJECT (ms),"gamepad" ,OBJECT (gpad));for (i =0 ; i <ARRAY_SIZE (gpad_keycode); i++) {qlist_append_int (gpad_keycode_list, gpad_keycode[i]);
hw/arm/stm32vldiscovery.c +1 -1
@@ -47,7 +47,7 @@ static void stm32vldiscovery_init(MachineState *machine) sysclk =clock_new (OBJECT (machine),"SYSCLK" );clock_set_hz (sysclk,SYSCLK_FRQ ); - dev =qdev_new (TYPE_STM32F100_SOC ); + dev =qdev_new_orphan (TYPE_STM32F100_SOC );object_property_add_child (OBJECT (machine),"soc" ,OBJECT (dev));qdev_connect_clock_in (dev,"sysclk" , sysclk);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/arm/strongarm.c +2 -2
@@ -646,7 +646,7 @@ static DeviceState *strongarm_gpio_init(hwaddr base,DeviceState *dev;int i; - dev =qdev_new (TYPE_STRONGARM_GPIO ); + dev =qdev_new_orphan (TYPE_STRONGARM_GPIO );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 , base);
@@ -1642,7 +1642,7 @@ StrongARMState *sa1110_init(const char *cpu_type) s->ppc =sysbus_create_varargs (TYPE_STRONGARM_PPC ,0x90060000 ,NULL );for (i =0 ; sa_serial[i].io_base; i++) { -DeviceState *dev =qdev_new (TYPE_STRONGARM_UART ); +DeviceState *dev =qdev_new_orphan (TYPE_STRONGARM_UART );qdev_prop_set_chr (dev,"chardev" ,serial_hd (i));sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0,
hw/arm/versatilepb.c +7 -7
@@ -226,7 +226,7 @@ static void versatile_init(MachineState *machine, int board_id)/* SDRAM at address zero. */ memory_region_add_subregion (sysmem,0 , machine->ram); - sysctl =qdev_new ("realview_sysctl" ); + sysctl =qdev_new_orphan ("realview_sysctl" );qdev_prop_set_uint32 (sysctl,"sys_id" ,0x41007004 );qdev_prop_set_uint32 (sysctl,"proc_id" ,0x02000000 );sysbus_realize_and_unref (SYS_BUS_DEVICE (sysctl), &error_fatal);
@@ -248,7 +248,7 @@ static void versatile_init(MachineState *machine, int board_id)sysbus_create_simple ("pl050_keyboard" ,0x10006000 , sic[3 ]);sysbus_create_simple ("pl050_mouse" ,0x10007000 , sic[4 ]); - dev =qdev_new ("versatile_pci" ); + dev =qdev_new_orphan ("versatile_pci" ); busdev =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (busdev, &error_fatal);sysbus_mmio_map (busdev,0 ,0x10001000 );/* PCI controller regs */
@@ -284,7 +284,7 @@ static void versatile_init(MachineState *machine, int board_id)pl011_create (0x101f3000 , pic[14 ],serial_hd (2 ));pl011_create (0x10009000 , sic[6 ],serial_hd (3 )); - dev =qdev_new ("pl080" ); + dev =qdev_new_orphan ("pl080" );object_property_set_link (OBJECT (dev),"downstream" ,OBJECT (sysmem), &error_fatal); busdev =SYS_BUS_DEVICE (dev);
@@ -302,7 +302,7 @@ static void versatile_init(MachineState *machine, int board_id)/* The versatile/PB actually has a modified Color LCD controller that includes hardware cursor support from the PL111. */ - dev =qdev_new ("pl110_versatile" ); + dev =qdev_new_orphan ("pl110_versatile" );object_property_set_link (OBJECT (dev),"framebuffer-memory" ,OBJECT (sysmem), &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -317,7 +317,7 @@ static void versatile_init(MachineState *machine, int board_id)if (dinfo) {DeviceState *card; - card =qdev_new (TYPE_SD_CARD ); + card =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (card,"drive" ,blk_by_legacy_dinfo (dinfo), &error_fatal); qdev_realize_and_unref(card, qdev_get_child_bus(dev, "sd-bus"),
@@ -329,7 +329,7 @@ static void versatile_init(MachineState *machine, int board_id)if (dinfo) {DeviceState *card; - card =qdev_new (TYPE_SD_CARD ); + card =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (card,"drive" ,blk_by_legacy_dinfo (dinfo), &error_fatal); qdev_realize_and_unref(card, qdev_get_child_bus(dev, "sd-bus"),
@@ -344,7 +344,7 @@ static void versatile_init(MachineState *machine, int board_id)i2c_slave_create_simple (i2c,"ds1338" ,0x68 );/* Add PL041 AACI Interface to the LM4549 codec */ - pl041 =qdev_new ("pl041" ); + pl041 =qdev_new_orphan ("pl041" );qdev_prop_set_uint32 (pl041,"nc_fifo_depth" ,512 );if (machine->audiodev) {qdev_prop_set_string (pl041,"audiodev" , machine->audiodev);
hw/arm/vexpress.c +7 -7
@@ -241,7 +241,7 @@ static void init_cpus(MachineState *ms, const char *cpu_type,* this must happen after the CPUs are created because a15mpcore_priv * wires itself up to the CPU's generic_timer gpio out lines. */ - dev =qdev_new (privdev); + dev =qdev_new_orphan (privdev);qdev_prop_set_uint32 (dev,"num-cpu" , smp_cpus);qdev_prop_set_uint32 (dev,"num-irq" ,GIC_EXT_IRQS +GIC_INTERNAL ); busdev =SYS_BUS_DEVICE (dev);
@@ -301,7 +301,7 @@ static void a9_daughterboard_init(VexpressMachineState *vms,/* Daughterboard peripherals : 0x10020000 .. 0x20000000 */ /* 0x10020000 PL111 CLCD (daughterboard) */ - dev =qdev_new ("pl111" ); + dev =qdev_new_orphan ("pl111" );object_property_set_link (OBJECT (dev),"framebuffer-memory" ,OBJECT (sysmem), &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -517,7 +517,7 @@ static void vexpress_modify_dtb(const struct arm_boot_info *info, void *fdt)static PFlashCFI01 *ve_pflash_cfi01_register (hwaddr base,const char *name,DriveInfo *di) { -DeviceState *dev =qdev_new (TYPE_PFLASH_CFI01 ); +DeviceState *dev =qdev_new_orphan (TYPE_PFLASH_CFI01 );if (di) {qdev_prop_set_drive (dev,"drive" ,blk_by_legacy_dinfo (di));
@@ -592,7 +592,7 @@ static void vexpress_common_init(MachineState *machine) sys_id =0x1190f500 ; - sysctl =qdev_new ("realview_sysctl" ); + sysctl =qdev_new_orphan ("realview_sysctl" );qdev_prop_set_uint32 (sysctl,"sys_id" , sys_id);qdev_prop_set_uint32 (sysctl,"proc_id" , daughterboard->proc_id);
@@ -614,7 +614,7 @@ static void vexpress_common_init(MachineState *machine)/* VE_SP810: not modelled */ /* VE_SERIALPCI: not modelled */ - pl041 =qdev_new ("pl041" ); + pl041 =qdev_new_orphan ("pl041" );qdev_prop_set_uint32 (pl041,"nc_fifo_depth" ,512 );if (machine->audiodev) {qdev_prop_set_string (pl041,"audiodev" , machine->audiodev);
@@ -633,7 +633,7 @@ static void vexpress_common_init(MachineState *machine)if (dinfo) {DeviceState *card; - card =qdev_new (TYPE_SD_CARD ); + card =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (card,"drive" ,blk_by_legacy_dinfo (dinfo), &error_fatal); qdev_realize_and_unref(card, qdev_get_child_bus(dev, "sd-bus"),
@@ -659,7 +659,7 @@ static void vexpress_common_init(MachineState *machine)/* VE_COMPACTFLASH: not modelled */ - dev =qdev_new ("pl111" ); + dev =qdev_new_orphan ("pl111" );object_property_set_link (OBJECT (dev),"framebuffer-memory" ,OBJECT (sysmem), &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/arm/virt.c +12 -12
@@ -1082,7 +1082,7 @@ static inline DeviceState *create_acpi_ged(VirtMachineState *vms) event |=ACPI_GED_NVDIMM_HOTPLUG_EVT ; } - dev =qdev_new (TYPE_ACPI_GED ); + dev =qdev_new_orphan (TYPE_ACPI_GED );qdev_prop_set_uint32 (dev,"ged-event" , event);object_property_set_link (OBJECT (dev),"bus" ,OBJECT (vms->bus), &error_abort); sbdev =SYS_BUS_DEVICE (dev);
@@ -1120,7 +1120,7 @@ static void create_its(VirtMachineState *vms)return ; } - dev =qdev_new (its_class_name ()); + dev =qdev_new_orphan (its_class_name ());object_property_set_link (OBJECT (dev),"parent-gicv3" ,OBJECT (vms->gic), &error_abort);
@@ -1137,7 +1137,7 @@ static void create_v2m(VirtMachineState *vms)int irq = vms->irqmap[VIRT_GIC_V2M ];DeviceState *dev; - dev =qdev_new ("arm-gicv2m" ); + dev =qdev_new_orphan ("arm-gicv2m" );qdev_prop_set_uint32 (dev,"base-spi" , irq);qdev_prop_set_uint32 (dev,"num-spi" ,NUM_GICV2M_SPIS );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -1225,7 +1225,7 @@ static void create_gicv5(VirtMachineState *vms, MemoryRegion *mem)const char *gictype =gicv5_class_name ();QList *cpulist =qlist_new (), *iaffidlist =qlist_new (); - vms->gic =qdev_new (gictype); + vms->gic =qdev_new_orphan (gictype);qdev_prop_set_uint32 (vms->gic,"spi-range" ,NUM_IRQS ); object_property_set_link(OBJECT(vms->gic), "sysmem", OBJECT(mem),
@@ -1356,7 +1356,7 @@ static void create_gicv2(VirtMachineState *vms, MemoryRegion *mem)exit (1 ); } - vms->gic =qdev_new (gic_class_name ()); + vms->gic =qdev_new_orphan (gic_class_name ());qdev_prop_set_uint32 (vms->gic,"revision" ,2 );qdev_prop_set_uint32 (vms->gic,"num-cpu" , smp_cpus);/*
@@ -1412,7 +1412,7 @@ static void create_gicv3(VirtMachineState *vms, MemoryRegion *mem)exit (1 ); } - vms->gic =qdev_new (gicv3_class_name ()); + vms->gic =qdev_new_orphan (gicv3_class_name ());qdev_prop_set_uint32 (vms->gic,"revision" , revision);qdev_prop_set_uint32 (vms->gic,"num-cpu" , smp_cpus);/*
@@ -1509,7 +1509,7 @@ static void create_uart(const VirtMachineState *vms, int uart,int irq = vms->irqmap[uart];const char compat[] ="arm,pl011\0arm,primecell" ;const char clocknames[] ="uartclk\0apb_pclk" ; -DeviceState *dev =qdev_new (TYPE_PL011 ); +DeviceState *dev =qdev_new_orphan (TYPE_PL011 );SysBusDevice *s =SYS_BUS_DEVICE (dev);MachineState *ms =MACHINE (vms);
@@ -1670,7 +1670,7 @@ static void create_gpio_devices(const VirtMachineState *vms, int gpio,SysBusDevice *s;MachineState *ms =MACHINE (vms); - pl061_dev =qdev_new ("pl061" ); + pl061_dev =qdev_new_orphan ("pl061" );/* Pull lines down to 0 if not driven by the PL061 */ qdev_prop_set_uint8 (pl061_dev,"pullups" ,0 );qdev_prop_set_uint8 (pl061_dev,"pulldowns" ,0xff );
@@ -1786,7 +1786,7 @@ static PFlashCFI01 *virt_flash_create1(VirtMachineState *vms,* Create a single flash device. We use the same parameters as * the flash devices on the Versatile Express board. */ -DeviceState *dev =qdev_new (TYPE_PFLASH_CFI01 ); +DeviceState *dev =qdev_new_orphan (TYPE_PFLASH_CFI01 );qdev_prop_set_uint64 (dev,"sector-length" ,VIRT_FLASH_SECTOR_SIZE );qdev_prop_set_uint8 (dev,"width" ,4 );
@@ -2069,7 +2069,7 @@ static void create_smmu(const VirtMachineState *vms, PCIBus *bus)return ; } - dev =qdev_new (TYPE_ARM_SMMUV3 ); + dev =qdev_new_orphan (TYPE_ARM_SMMUV3 );if (!vmc->no_nested_smmu) {object_property_set_str (OBJECT (dev),"stage" ,"nested" , &error_fatal);
@@ -2162,7 +2162,7 @@ static void create_pcie(VirtMachineState *vms)MachineState *ms =MACHINE (vms);MachineClass *mc =MACHINE_GET_CLASS (ms); - dev =qdev_new (TYPE_GPEX_HOST ); + dev =qdev_new_orphan (TYPE_GPEX_HOST );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); ecam_id =VIRT_ECAM_ID (vms->highmem_ecam);
@@ -2290,7 +2290,7 @@ static void create_platform_bus(VirtMachineState *vms)int i;MemoryRegion *sysmem =get_system_memory (); - dev =qdev_new (TYPE_PLATFORM_BUS_DEVICE ); + dev =qdev_new_orphan (TYPE_PLATFORM_BUS_DEVICE ); dev->id =g_strdup (TYPE_PLATFORM_BUS_DEVICE );qdev_prop_set_uint32 (dev,"num_irqs" ,PLATFORM_BUS_NUM_IRQS );qdev_prop_set_uint32 (dev,"mmio_size" , vms->memmap[VIRT_PLATFORM_BUS ].size);
hw/arm/xilinx_zynq.c +13 -13
@@ -110,7 +110,7 @@ static void gem_init(uint32_t base, qemu_irq irq)DeviceState *dev;SysBusDevice *s; - dev =qdev_new (TYPE_CADENCE_GEM ); + dev =qdev_new_orphan (TYPE_CADENCE_GEM );qemu_configure_nic_device (dev, true,NULL );object_property_set_int (OBJECT (dev),"phy-addr" ,7 , &error_abort); s =SYS_BUS_DEVICE (dev);
@@ -131,7 +131,7 @@ static inline int zynq_init_spi_flashes(uint32_t base_addr, qemu_irq irq,int num_busses = is_qspi ?NUM_QSPI_BUSSES :1 ;int num_ss = is_qspi ?NUM_QSPI_FLASHES :NUM_SPI_FLASHES ; - dev =qdev_new (is_qspi ?"xlnx.ps7-qspi" :"xlnx.ps7-spi" ); + dev =qdev_new_orphan (is_qspi ?"xlnx.ps7-qspi" :"xlnx.ps7-spi" );qdev_prop_set_uint8 (dev,"num-txrx-bytes" , is_qspi ?4 :1 );qdev_prop_set_uint8 (dev,"num-ss-bits" , num_ss);qdev_prop_set_uint8 (dev,"num-busses" , num_busses);
@@ -152,7 +152,7 @@ static inline int zynq_init_spi_flashes(uint32_t base_addr, qemu_irq irq,for (j =0 ; j < num_ss; ++j) {DriveInfo *dinfo =drive_get (IF_MTD ,0 , unit++); - flash_dev =qdev_new ("n25q128" ); + flash_dev =qdev_new_orphan ("n25q128" );if (dinfo) { qdev_prop_set_drive_err(flash_dev, "drive", blk_by_legacy_dinfo(dinfo),
@@ -195,7 +195,7 @@ static void ddr_ctrl_init(uint32_t base)DeviceState *dev;SysBusDevice *busdev; - dev =qdev_new ("zynq.ddr-ctlr" ); + dev =qdev_new_orphan ("zynq.ddr-ctlr" ); busdev =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (busdev, &error_fatal);sysbus_mmio_map (busdev,0 , base);
@@ -256,13 +256,13 @@ static void zynq_init(MachineState *machine)clock_set_hz (zynq_machine->ps_clk,PS_CLK_FREQUENCY );/* Create slcr, keep a pointer to connect clocks */ - slcr =qdev_new ("xilinx-zynq_slcr" ); + slcr =qdev_new_orphan ("xilinx-zynq_slcr" );qdev_connect_clock_in (slcr,"ps_clk" , zynq_machine->ps_clk);qdev_prop_set_uint8 (slcr,"boot-mode" , zynq_machine->boot_mode);sysbus_realize_and_unref (SYS_BUS_DEVICE (slcr), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (slcr),0 ,0xF8000000 ); - dev =qdev_new (TYPE_A9MPCORE_PRIV ); + dev =qdev_new_orphan (TYPE_A9MPCORE_PRIV );qdev_prop_set_uint32 (dev,"num-cpu" , smp_cpus);qdev_prop_set_uint32 (dev,"num-irq" ,GIC_EXT_IRQS +GIC_INTERNAL ); busdev =SYS_BUS_DEVICE (dev);
@@ -290,7 +290,7 @@ static void zynq_init(MachineState *machine)sysbus_create_simple (TYPE_CHIPIDEA ,0xE0002000 , pic[53 -GIC_INTERNAL ]);sysbus_create_simple (TYPE_CHIPIDEA ,0xE0003000 , pic[76 -GIC_INTERNAL ]); - dev =qdev_new (TYPE_CADENCE_UART ); + dev =qdev_new_orphan (TYPE_CADENCE_UART ); busdev =SYS_BUS_DEVICE (dev);qdev_prop_set_chr (dev,"chardev" ,serial_hd (0 )); qdev_connect_clock_in(dev, "refclk",
@@ -298,7 +298,7 @@ static void zynq_init(MachineState *machine)sysbus_realize_and_unref (busdev, &error_fatal);sysbus_mmio_map (busdev,0 ,0xE0000000 );sysbus_connect_irq (busdev,0 , pic[59 -GIC_INTERNAL ]); - dev =qdev_new (TYPE_CADENCE_UART ); + dev =qdev_new_orphan (TYPE_CADENCE_UART ); busdev =SYS_BUS_DEVICE (dev);qdev_prop_set_chr (dev,"chardev" ,serial_hd (1 )); qdev_connect_clock_in(dev, "refclk",
@@ -329,7 +329,7 @@ static void zynq_init(MachineState *machine)* - SDIO Specification Version 2.0 * - MMC Specification Version 3.31 */ - dev =qdev_new (TYPE_SYSBUS_SDHCI ); + dev =qdev_new_orphan (TYPE_SYSBUS_SDHCI );qdev_prop_set_uint8 (dev,"sd-spec-version" ,2 );qdev_prop_set_uint64 (dev,"capareg" ,ZYNQ_SDHCI_CAPABILITIES );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -338,18 +338,18 @@ static void zynq_init(MachineState *machine) di =drive_get (IF_SD ,0 , n); blk = di ?blk_by_legacy_dinfo (di) :NULL ; - carddev =qdev_new (TYPE_SD_CARD ); + carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev,qdev_get_child_bus (dev,"sd-bus" ), &error_fatal); } - dev =qdev_new (TYPE_ZYNQ_XADC ); + dev =qdev_new_orphan (TYPE_ZYNQ_XADC );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,0xF8007100 );sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , pic[39 -GIC_INTERNAL ]); - dev =qdev_new ("pl330" ); + dev =qdev_new_orphan ("pl330" );object_property_set_link (OBJECT (dev),"memory" ,OBJECT (address_space_mem), &error_fatal);
@@ -372,7 +372,7 @@ static void zynq_init(MachineState *machine)sysbus_connect_irq (busdev, n +1 , pic[dma_irqs[n] -GIC_INTERNAL ]); } - dev =qdev_new ("xlnx.ps7-dev-cfg" ); + dev =qdev_new_orphan ("xlnx.ps7-dev-cfg" ); busdev =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (busdev, &error_fatal);sysbus_connect_irq (busdev,0 , pic[40 -GIC_INTERNAL ]);
hw/arm/xlnx-versal-virt.c +1 -1
@@ -143,7 +143,7 @@ static void create_virtio_regions(VersalVirt *s)qemu_irq pic_irq; pic_irq =versal_get_reserved_irq (&s->soc, i, &dtb_irq); - dev =qdev_new ("virtio-mmio" ); + dev =qdev_new_orphan ("virtio-mmio" );object_property_add_child (OBJECT (s),"virtio-mmio[*]" ,OBJECT (dev));sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , pic_irq);
hw/arm/xlnx-versal.c +35 -35
259 lines not on this page · raw message
hw/arm/xlnx-zcu102.c +3 -3
@@ -187,7 +187,7 @@ static void xlnx_zcu102_init(MachineState *machine)error_report ("No SD bus found for SD card %d" , i);exit (1 ); } - carddev =qdev_new (TYPE_SD_CARD ); + carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev, bus, &error_fatal); }
@@ -202,7 +202,7 @@ static void xlnx_zcu102_init(MachineState *machine) spi_bus =qdev_get_child_bus (DEVICE (&s->soc), bus_name);g_free (bus_name); - flash_dev =qdev_new ("sst25wf080" ); + flash_dev =qdev_new_orphan ("sst25wf080" );if (dinfo) {qdev_prop_set_drive_err (flash_dev,"drive" ,blk_by_legacy_dinfo (dinfo), &error_fatal);
@@ -226,7 +226,7 @@ static void xlnx_zcu102_init(MachineState *machine) spi_bus =qdev_get_child_bus (DEVICE (&s->soc), bus_name);g_free (bus_name); - flash_dev =qdev_new ("n25q512a11" ); + flash_dev =qdev_new_orphan ("n25q512a11" );if (dinfo) {qdev_prop_set_drive_err (flash_dev,"drive" ,blk_by_legacy_dinfo (dinfo), &error_fatal);
hw/arm/xlnx-zynqmp.c +1 -1
@@ -365,7 +365,7 @@ static void xlnx_zynqmp_create_unimp_mmio(XlnxZynqMPState *s)for (nr =0 ; nr <ARRAY_SIZE (unimp_areas); nr++) {const struct UnimpInfo *info = &unimp_areas[nr]; -DeviceState *dev =qdev_new (TYPE_UNIMPLEMENTED_DEVICE ); +DeviceState *dev =qdev_new_orphan (TYPE_UNIMPLEMENTED_DEVICE );SysBusDevice *sbd =SYS_BUS_DEVICE (dev);assert (info->name && info->base && info->size >0 );
hw/audio/intel-hda.c +1 -1
@@ -1313,7 +1313,7 @@ static void intel_hda_and_codec_init(const char *audiodev) intel_hda =qdev_device_add_from_qdict (props, false, &error_fatal); hdabus =QLIST_FIRST (&intel_hda->child_bus); - codec =qdev_new ("hda-duplex" ); + codec =qdev_new_orphan ("hda-duplex" );qdev_prop_set_string (codec,"audiodev" , audiodev);qdev_realize_and_unref (codec, hdabus, &error_fatal);object_unref (intel_hda);
hw/audio/model.c +1 -1
@@ -110,7 +110,7 @@ void audio_model_init(void) }if (c->typename) { -DeviceState *dev =qdev_new (c->typename); +DeviceState *dev =qdev_new_orphan (c->typename);BusState *bus =qdev_find_default_bus (DEVICE_GET_CLASS (dev), &error_fatal);qdev_prop_set_string (dev,"audiodev" , audiodev_id);qdev_realize_and_unref (dev, bus, &error_fatal);
hw/avr/atmega.c +1 -1
@@ -284,7 +284,7 @@ static void atmega_realize(DeviceState *dev, Error **errp)* 0x20 - 0x5f: I/O memory * 0x60 - 0xff: Extended I/O */ - s->io =qdev_new (TYPE_UNIMPLEMENTED_DEVICE ); + s->io =qdev_new_orphan (TYPE_UNIMPLEMENTED_DEVICE );qdev_prop_set_string (s->io,"name" ,"I/O" );qdev_prop_set_uint64 (s->io,"size" , mc->io_size);sysbus_realize_and_unref (SYS_BUS_DEVICE (s->io), &error_fatal);
hw/block/fdc-sysbus.c +2 -2
@@ -102,7 +102,7 @@ void fdctrl_init_sysbus(qemu_irq irq, hwaddr mmio_base, DriveInfo **fds)SysBusDevice *sbd;FDCtrlSysBus *sys; - dev =qdev_new ("sysbus-fdc" ); + dev =qdev_new_orphan ("sysbus-fdc" ); sys =SYSBUS_FDC (dev); sbd =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (sbd, &error_fatal);
@@ -118,7 +118,7 @@ void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base,DeviceState *dev;FDCtrlSysBus *sys; - dev =qdev_new ("sun-fdtwo" ); + dev =qdev_new_orphan ("sun-fdtwo" );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); sys =SYSBUS_FDC (dev);sysbus_connect_irq (SYS_BUS_DEVICE (sys),0 , irq);
hw/block/fdc.c +1 -1
@@ -2329,7 +2329,7 @@ void fdctrl_init_drives(FloppyBus *bus, DriveInfo **fds)for (i =0 ; i <MAX_FD ; i++) {if (fds[i]) { - dev =qdev_new ("floppy" ); + dev =qdev_new_orphan ("floppy" );qdev_prop_set_uint32 (dev,"unit" , i);qdev_prop_set_enum (dev,"drive-type" ,FLOPPY_DRIVE_TYPE_AUTO ); qdev_prop_set_drive_err(dev, "drive", blk_by_legacy_dinfo(fds[i]),
hw/block/pflash_cfi01.c +1 -1
@@ -958,7 +958,7 @@ PFlashCFI01 *pflash_cfi01_register(hwaddr base, uint16_t id2, uint16_t id3, int be) { - DeviceState *dev = qdev_new(TYPE_PFLASH_CFI01); + DeviceState *dev = qdev_new_orphan(TYPE_PFLASH_CFI01);if (blk) {qdev_prop_set_drive (dev,"drive" , blk);
hw/block/pflash_cfi02.c +1 -1
@@ -1005,7 +1005,7 @@ PFlashCFI02 *pflash_cfi02_register(hwaddr base, uint16_t unlock_addr1, int be) { -DeviceState *dev =qdev_new (TYPE_PFLASH_CFI02 ); +DeviceState *dev =qdev_new_orphan (TYPE_PFLASH_CFI02 );if (blk) {qdev_prop_set_drive (dev,"drive" , blk);
hw/block/xen-block.c +1 -1
@@ -1074,7 +1074,7 @@ static void xen_block_device_create(XenBackendInstance *backend, goto fail; } - xendev =XEN_DEVICE (qdev_new (type)); + xendev =XEN_DEVICE (qdev_new_orphan (type)); blockdev =XEN_BLOCK_DEVICE (xendev); if (!object_property_set_str(OBJECT(xendev), "vdev", vdev,
hw/char/exynos4210_uart.c +1 -1
@@ -659,7 +659,7 @@ DeviceState *exynos4210_uart_create(hwaddr addr,DeviceState *dev;SysBusDevice *bus; - dev =qdev_new (TYPE_EXYNOS4210_UART ); + dev =qdev_new_orphan (TYPE_EXYNOS4210_UART );qdev_prop_set_chr (dev,"chardev" , chr);qdev_prop_set_uint32 (dev,"channel" , channel);
hw/char/mcf_uart.c +1 -1
@@ -351,7 +351,7 @@ DeviceState *mcf_uart_create(qemu_irq irq, Chardev *chrdrv) {DeviceState *dev; - dev =qdev_new (TYPE_MCF_UART ); + dev =qdev_new_orphan (TYPE_MCF_UART );if (chrdrv) {qdev_prop_set_chr (dev,"chardev" , chrdrv); }
hw/char/mchp_pfsoc_mmuart.c +1 -1
@@ -150,7 +150,7 @@ MchpPfSoCMMUartState *mchp_pfsoc_mmuart_create(MemoryRegion *sysmem,hwaddr base, qemu_irq irq, Chardev *chr) { - DeviceState *dev = qdev_new(TYPE_MCHP_PFSOC_UART); + DeviceState *dev = qdev_new_orphan(TYPE_MCHP_PFSOC_UART);SysBusDevice *sbd =SYS_BUS_DEVICE (dev);qdev_prop_set_chr (dev,"chardev" , chr);
hw/char/pl011.c +1 -1
@@ -38,7 +38,7 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr)DeviceState *dev;SysBusDevice *s; - dev =qdev_new ("pl011" ); + dev =qdev_new_orphan ("pl011" ); s =SYS_BUS_DEVICE (dev);qdev_prop_set_chr (dev,"chardev" , chr);sysbus_realize_and_unref (s, &error_fatal);
hw/char/serial-mm.c +1 -1
@@ -99,7 +99,7 @@ SerialMM *serial_mm_init(MemoryRegion *address_space, qemu_irq irq, int baudbase, Chardev *chr, enum device_endian end) { - SerialMM *smm = SERIAL_MM(qdev_new(TYPE_SERIAL_MM)); + SerialMM *smm = SERIAL_MM(qdev_new_orphan(TYPE_SERIAL_MM));MemoryRegion *mr;qdev_prop_set_uint8 (DEVICE (smm),"regshift" , regshift);
hw/char/sifive_uart.c +1 -1
@@ -399,7 +399,7 @@ SiFiveUARTState *sifive_uart_create(MemoryRegion *address_space, hwaddr base,DeviceState *dev;SysBusDevice *s; - dev =qdev_new ("riscv.sifive.uart" ); + dev =qdev_new_orphan ("riscv.sifive.uart" ); s =SYS_BUS_DEVICE (dev);qdev_prop_set_chr (dev,"chardev" , chr);sysbus_realize_and_unref (s, &error_fatal);
hw/char/spapr_vty.c +1 -1
@@ -158,7 +158,7 @@ void spapr_vty_create(SpaprVioBus *bus, Chardev *chardev) {DeviceState *dev; - dev =qdev_new ("spapr-vty" ); + dev =qdev_new_orphan ("spapr-vty" );qdev_prop_set_chr (dev,"chardev" , chardev);qdev_realize_and_unref (dev, &bus->bus, &error_fatal); }
hw/char/xen_console.c +1 -1
@@ -562,7 +562,7 @@ static void xen_console_device_create(XenBackendInstance *backend, goto fail; } - xendev =XEN_DEVICE (qdev_new (TYPE_XEN_CONSOLE_DEVICE )); + xendev =XEN_DEVICE (qdev_new_orphan (TYPE_XEN_CONSOLE_DEVICE )); con =XEN_CONSOLE_DEVICE (xendev); con->dev = number;
hw/core/qdev.c +2 -2
@@ -145,12 +145,12 @@ bool qdev_set_parent_bus(DeviceState *dev, BusState *bus, Error **errp)return true; } -DeviceState *qdev_new (const char *name) +DeviceState *qdev_new_orphan (const char *name) {return DEVICE (object_new (name)); } -DeviceState *qdev_try_new (const char *name) +DeviceState *qdev_try_new_orphan (const char *name) {ObjectClass *oc =module_object_class_by_name (name);if (!oc) {
hw/core/sysbus.c +1 -1
@@ -218,7 +218,7 @@ DeviceState *sysbus_create_varargs(const char *name,qemu_irq irq;int n; - dev =qdev_new (name); + dev =qdev_new_orphan (name); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);if (addr != (hwaddr)-1 ) {
hw/cxl/cxl-host.c +1 -1
@@ -26,7 +26,7 @@ static void cxl_fixed_memory_window_config(CXLFixedMemoryWindowOptions *object, int index, Error **errp) {ERRP_GUARD (); -DeviceState *dev =qdev_new (TYPE_CXL_FMW ); +DeviceState *dev =qdev_new_orphan (TYPE_CXL_FMW );CXLFixedWindow *fw =CXL_FMW (dev);strList *target;int i;
hw/display/sm501.c +1 -1
@@ -1910,7 +1910,7 @@ static void sm501_init(SM501State *s, DeviceState *dev,/* i2c */ s->i2c_bus =i2c_init_bus (dev,"sm501.i2c" );/* ddc */ -I2CDDCState *ddc =I2CDDC (qdev_new (TYPE_I2CDDC )); +I2CDDCState *ddc =I2CDDC (qdev_new_orphan (TYPE_I2CDDC ));i2c_slave_set_address (I2C_SLAVE (ddc),0x50 );qdev_realize_and_unref (DEVICE (ddc),BUS (s->i2c_bus), &error_abort);
hw/display/xlnx_dp.c +2 -2
@@ -1346,11 +1346,11 @@ static void xlnx_dp_init(Object *obj)* child properties of this device, we can drop the reference we * hold to them, leaving the child-property as the only reference. */ - s->dpcd =DPCD (qdev_new ("dpcd" )); + s->dpcd =DPCD (qdev_new_orphan ("dpcd" ));object_property_add_child (OBJECT (s),"dpcd" ,OBJECT (s->dpcd));object_unref (s->dpcd); - s->edid =I2CDDC (qdev_new ("i2c-ddc" )); + s->edid =I2CDDC (qdev_new_orphan ("i2c-ddc" ));i2c_slave_set_address (I2C_SLAVE (s->edid),0x50 );object_property_add_child (OBJECT (s),"edid" ,OBJECT (s->edid));object_unref (s->edid);
hw/dma/rc4030.c +1 -1
@@ -747,7 +747,7 @@ DeviceState *rc4030_init(rc4030_dma **dmas, IOMMUMemoryRegion **dma_mr) {DeviceState *dev; - dev =qdev_new (TYPE_RC4030 ); + dev =qdev_new_orphan (TYPE_RC4030 );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); *dmas =rc4030_allocate_dmas (dev,4 );
hw/hexagon/hexagon_dsp.c +2 -2
@@ -131,14 +131,14 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev, machine->ram_size, &error_fatal);memory_region_add_subregion (address_space,0x0 , &hms->ram); - glob_regs_dev =qdev_new (TYPE_HEXAGON_GLOBALREG ); + glob_regs_dev =qdev_new_orphan (TYPE_HEXAGON_GLOBALREG );object_property_add_child (OBJECT (machine),"global-regs" ,OBJECT (glob_regs_dev));qdev_prop_set_uint64 (glob_regs_dev,"config-table-addr" , m_cfg->cfgbase);qdev_prop_set_uint32 (glob_regs_dev,"dsp-rev" , rev);sysbus_realize_and_unref (SYS_BUS_DEVICE (glob_regs_dev), &error_fatal); - tlb_dev =qdev_new (TYPE_HEXAGON_TLB ); + tlb_dev =qdev_new_orphan (TYPE_HEXAGON_TLB );object_property_add_child (OBJECT (machine),"tlb" ,OBJECT (tlb_dev));qdev_prop_set_uint32 (tlb_dev,"num-entries" , m_cfg->cfgtable.jtlb_size_entries);
hw/hexagon/virt.c +3 -3
@@ -129,7 +129,7 @@ static void fdt_add_uart(const HexagonVirtMachineState *vms, int uart,DeviceState *dev;SysBusDevice *s; - dev =qdev_new (TYPE_PL011 ); + dev =qdev_new_orphan (TYPE_PL011 ); s =SYS_BUS_DEVICE (dev);qdev_prop_set_chr (dev,"chardev" ,serial_hd (0 ));qdev_connect_clock_in (dev,"clk" , vms->apb_clk);
@@ -268,13 +268,13 @@ static void virt_init(MachineState *ms) &vms->parent_obj.cfgtable_rom);fdt_add_hvx (vms, m_cfg); - gsregs_dev =qdev_new (TYPE_HEXAGON_GLOBALREG ); + gsregs_dev =qdev_new_orphan (TYPE_HEXAGON_GLOBALREG );object_property_add_child (OBJECT (ms),"global-regs" ,OBJECT (gsregs_dev));qdev_prop_set_uint64 (gsregs_dev,"config-table-addr" , m_cfg->cfgbase);qdev_prop_set_uint32 (gsregs_dev,"dsp-rev" , v68_rev);sysbus_realize_and_unref (SYS_BUS_DEVICE (gsregs_dev), &error_fatal); - tlb_dev =qdev_new (TYPE_HEXAGON_TLB ); + tlb_dev =qdev_new_orphan (TYPE_HEXAGON_TLB );object_property_add_child (OBJECT (ms),"tlb" ,OBJECT (tlb_dev));qdev_prop_set_uint32 (tlb_dev,"num-entries" , m_cfg->cfgtable.jtlb_size_entries);
hw/hppa/machine.c +6 -6
@@ -265,7 +265,7 @@ static LasiState *lasi_init(void) {DeviceState *dev; - dev =qdev_new (TYPE_LASI_CHIP ); + dev =qdev_new_orphan (TYPE_LASI_CHIP );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);return LASI_CHIP (dev);
@@ -275,7 +275,7 @@ static DinoState *dino_init(MemoryRegion *addr_space) {DeviceState *dev; - dev =qdev_new (TYPE_DINO_PCI_HOST_BRIDGE ); + dev =qdev_new_orphan (TYPE_DINO_PCI_HOST_BRIDGE );object_property_set_link (OBJECT (dev),"memory-as" ,OBJECT (addr_space), &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -411,7 +411,7 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus, lasi_dev = hpm->lasi_dev;if (lasi_dev && machine->enable_graphics && vga_interface_type !=VGA_NONE ) { - dev =qdev_new ("artist" ); + dev =qdev_new_orphan ("artist" ); s =SYS_BUS_DEVICE (dev);bool disabled =object_property_get_bool (OBJECT (dev),"disable" ,NULL );if (!disabled) {
@@ -614,7 +614,7 @@ static void machine_HP_715_init(MachineState *machine) parallel_hds[0]);/* PS/2 Keyboard/Mouse */ - dev =qdev_new (TYPE_LASIPS2 ); + dev =qdev_new_orphan (TYPE_LASIPS2 );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 ,qdev_get_gpio_in (lasi_dev,LASI_IRQ_PS2KBD_HPA ));
@@ -706,7 +706,7 @@ static void machine_HP_B160L_init(MachineState *machine) parallel_hds[0]);/* PS/2 Keyboard/Mouse */ - dev =qdev_new (TYPE_LASIPS2 ); + dev =qdev_new_orphan (TYPE_LASIPS2 );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 ,qdev_get_gpio_in (lasi_dev,LASI_IRQ_PS2KBD_HPA ));
@@ -733,7 +733,7 @@ static AstroState *astro_init(void) {DeviceState *dev; - dev =qdev_new (TYPE_ASTRO_CHIP ); + dev =qdev_new_orphan (TYPE_ASTRO_CHIP );object_property_set_int (OBJECT (dev),"phys-addr-bits" ,hppa_phys_addr_bits (&cpu[0 ]->env), &error_abort);
hw/i2c/core.c +1 -1
@@ -368,7 +368,7 @@ I2CSlave *i2c_slave_new(const char *name, uint8_t addr) {DeviceState *dev; - dev =qdev_new (name); + dev =qdev_new_orphan (name);qdev_prop_set_uint8 (dev,"address" , addr);return I2C_SLAVE (dev); }
hw/i2c/smbus_eeprom.c +1 -1
@@ -164,7 +164,7 @@ void smbus_eeprom_init_one(I2CBus *smbus, uint8_t address, uint8_t *eeprom_buf) {DeviceState *dev; - dev =qdev_new (TYPE_SMBUS_EEPROM ); + dev =qdev_new_orphan (TYPE_SMBUS_EEPROM );qdev_prop_set_uint8 (dev,"address" , address);/* FIXME: use an array of byte or block backend property? */ SMBUS_EEPROM (dev)->init_data = eeprom_buf;
hw/i386/microvm.c +3 -3
@@ -108,7 +108,7 @@ static void create_gpex(MicrovmMachineState *mms)DeviceState *dev;int i; - dev =qdev_new (TYPE_GPEX_HOST ); + dev =qdev_new_orphan (TYPE_GPEX_HOST );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);/* Map only the first size_ecam bytes of ECAM space */
@@ -204,7 +204,7 @@ static void microvm_devices_init(MicrovmMachineState *mms)/* Optional and legacy devices */ if (x86_machine_is_acpi_enabled (x86ms)) { -DeviceState *dev =qdev_new (TYPE_ACPI_GED ); +DeviceState *dev =qdev_new_orphan (TYPE_ACPI_GED );qdev_prop_set_uint32 (dev,"ged-event" ,ACPI_GED_PWR_DOWN_EVT );sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,GED_MMIO_BASE );
@@ -216,7 +216,7 @@ static void microvm_devices_init(MicrovmMachineState *mms) }if (x86_machine_is_acpi_enabled (x86ms) &&machine_usb (MACHINE (mms))) { -DeviceState *dev =qdev_new (TYPE_XHCI_SYSBUS ); +DeviceState *dev =qdev_new_orphan (TYPE_XHCI_SYSBUS );qdev_prop_set_uint32 (dev,"intrs" ,1 );qdev_prop_set_uint32 (dev,"slots" ,XHCI_MAXSLOTS );qdev_prop_set_uint32 (dev,"p2" ,8 );
hw/i386/nitro_enclave.c +2 -2
@@ -46,7 +46,7 @@ static BusState *find_free_virtio_mmio_bus(void)static void vhost_user_vsock_init (NitroEnclaveMachineState *nems) { -DeviceState *dev =qdev_new (TYPE_VHOST_USER_VSOCK ); +DeviceState *dev =qdev_new_orphan (TYPE_VHOST_USER_VSOCK );VHostUserVSock *vsock =VHOST_USER_VSOCK (dev);BusState *bus;
@@ -75,7 +75,7 @@ static void vhost_user_vsock_init(NitroEnclaveMachineState *nems)static void virtio_nsm_init (NitroEnclaveMachineState *nems) { -DeviceState *dev =qdev_new (TYPE_VIRTIO_NSM ); +DeviceState *dev =qdev_new_orphan (TYPE_VIRTIO_NSM );VirtIONSM *vnsm =VIRTIO_NSM (dev);BusState *bus =find_free_virtio_mmio_bus ();
hw/i386/pc.c +1 -1
@@ -1065,7 +1065,7 @@ void pc_basic_device_init(struct PCMachineState *pcms,if (pcms->hpet_enabled) {qemu_irq rtc_irq; - hpet =qdev_try_new (TYPE_HPET ); + hpet =qdev_try_new_orphan (TYPE_HPET );if (!hpet) {error_report ("couldn't create HPET device" );exit (1 );
hw/i386/pc_piix.c +1 -1
@@ -193,7 +193,7 @@ static void pc_init1(MachineState *machine, const char *pci_type) pci_memory =g_new (MemoryRegion,1 );memory_region_init (pci_memory,NULL ,"pci" ,UINT64_MAX ); - phb =OBJECT (qdev_new (TYPE_I440FX_PCI_HOST_BRIDGE )); + phb =OBJECT (qdev_new_orphan (TYPE_I440FX_PCI_HOST_BRIDGE ));object_property_add_child (OBJECT (machine),"i440fx" , phb);object_property_set_link (phb,PCI_HOST_PROP_RAM_MEM ,OBJECT (ram_memory), &error_fatal);
hw/i386/pc_q35.c +1 -1
@@ -199,7 +199,7 @@ static void pc_q35_init(MachineState *machine) }/* create pci host bus */ - phb =OBJECT (qdev_new (TYPE_Q35_HOST_DEVICE )); + phb =OBJECT (qdev_new_orphan (TYPE_Q35_HOST_DEVICE )); pci_hole64_size = object_property_get_uint(phb, PCI_HOST_PROP_PCI_HOLE64_SIZE,
hw/i386/pc_sysfw.c +1 -1
@@ -79,7 +79,7 @@ static PFlashCFI01 *pc_pflash_create(PCMachineState *pcms,const char *name, const char *alias_prop_name) { - DeviceState *dev = qdev_new(TYPE_PFLASH_CFI01); + DeviceState *dev = qdev_new_orphan(TYPE_PFLASH_CFI01);qdev_prop_set_uint64 (dev,"sector-length" ,FLASH_SECTOR_SIZE );qdev_prop_set_uint8 (dev,"width" ,1 );
hw/i386/sgx.c +1 -1
@@ -311,7 +311,7 @@ void pc_machine_init_sgx_epc(PCMachineState *pcms) &sgx_epc->mr);for (list = x86ms->sgx_epc_list; list; list = list->next) { -DeviceState *dev =qdev_new (TYPE_SGX_EPC ); +DeviceState *dev =qdev_new_orphan (TYPE_SGX_EPC );/* set the memdev link with memory backend */ object_property_parse(OBJECT(dev), SGX_EPC_MEMDEV_PROP,
hw/i386/x86-common.c +3 -3
@@ -505,9 +505,9 @@ void ioapic_init_gsi(GSIState *gsi_state, Object *parent)assert (parent);if (kvm_ioapic_in_kernel ()) { - dev =qdev_new (TYPE_KVM_IOAPIC ); + dev =qdev_new_orphan (TYPE_KVM_IOAPIC ); }else { - dev =qdev_new (TYPE_IOAPIC ); + dev =qdev_new_orphan (TYPE_IOAPIC ); }object_property_add_child (parent,"ioapic" ,OBJECT (dev)); d =SYS_BUS_DEVICE (dev);
@@ -525,7 +525,7 @@ DeviceState *ioapic_init_secondary(GSIState *gsi_state)SysBusDevice *d;unsigned int i; - dev =qdev_new (TYPE_IOAPIC ); + dev =qdev_new_orphan (TYPE_IOAPIC ); d =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (d, &error_fatal);sysbus_mmio_map (d,0 ,IO_APIC_SECONDARY_ADDRESS );
hw/i3c/core.c +1 -1
@@ -547,7 +547,7 @@ I3CTarget *i3c_target_new(const char *name, uint8_t addr, uint8_t dcr, {DeviceState *dev; - dev =qdev_new (name); + dev =qdev_new_orphan (name);qdev_prop_set_uint8 (dev,"static-address" , addr);qdev_prop_set_uint8 (dev,"dcr" , dcr);qdev_prop_set_uint8 (dev,"bcr" , bcr);
hw/ide/ide-bus.c +1 -1
@@ -75,7 +75,7 @@ IDEDevice *ide_bus_create_drive(IDEBus *bus, int unit, DriveInfo *drive) {DeviceState *dev; - dev =qdev_new (drive->media_cd ?"ide-cd" :"ide-hd" ); + dev =qdev_new_orphan (drive->media_cd ?"ide-cd" :"ide-hd" );qdev_prop_set_uint32 (dev,"unit" , unit);qdev_prop_set_drive_err (dev,"drive" ,blk_by_legacy_dinfo (drive), &error_fatal);
hw/intc/exynos4210_gic.c +1 -1
@@ -60,7 +60,7 @@ static void exynos4210_gic_realize(DeviceState *dev, Error **errp)uint32_t n = s->num_cpu;uint32_t i; - s->gic =qdev_new ("arm_gic" ); + s->gic =qdev_new_orphan ("arm_gic" );qdev_prop_set_uint32 (s->gic,"num-cpu" , s->num_cpu);qdev_prop_set_uint32 (s->gic,"num-irq" ,EXYNOS4210_GIC_NIRQ ); gicbusdev =SYS_BUS_DEVICE (s->gic);
hw/intc/riscv_aclint.c +2 -2
@@ -369,7 +369,7 @@ DeviceState *riscv_aclint_mtimer_create(hwaddr addr, hwaddr size, bool provide_rdtime) {int i; -DeviceState *dev =qdev_new (TYPE_RISCV_ACLINT_MTIMER ); +DeviceState *dev =qdev_new_orphan (TYPE_RISCV_ACLINT_MTIMER );RISCVAclintMTimerState *s =RISCV_ACLINT_MTIMER (dev);assert (num_harts <=RISCV_ACLINT_MAX_HARTS );
@@ -552,7 +552,7 @@ DeviceState *riscv_aclint_swi_create(hwaddr addr, uint32_t hartid_base, uint32_t num_harts, bool sswi) { int i; -DeviceState *dev =qdev_new (TYPE_RISCV_ACLINT_SWI ); +DeviceState *dev =qdev_new_orphan (TYPE_RISCV_ACLINT_SWI );assert (num_harts <=RISCV_ACLINT_MAX_HARTS );assert (!(addr &0x3 ));
hw/intc/riscv_aplic.c +1 -1
@@ -1113,7 +1113,7 @@ DeviceState *riscv_aplic_create(hwaddr addr, hwaddr size, uint32_t hartid_base, uint32_t num_harts, uint32_t num_sources, uint32_t iprio_bits, bool msimode, bool mmode, DeviceState *parent) { - DeviceState *dev = qdev_new(TYPE_RISCV_APLIC); + DeviceState *dev = qdev_new_orphan(TYPE_RISCV_APLIC);uint32_t i;assert (num_harts <APLIC_MAX_IDC );
hw/intc/riscv_imsic.c +1 -1
@@ -474,7 +474,7 @@ type_init(riscv_imsic_register_types)DeviceState *riscv_imsic_create (hwaddr addr,uint32_t hartid,bool mmode,uint32_t num_pages,uint32_t num_ids) { -DeviceState *dev =qdev_new (TYPE_RISCV_IMSIC ); +DeviceState *dev =qdev_new_orphan (TYPE_RISCV_IMSIC );CPUState *cpu =cpu_by_arch_id (hartid);uint32_t i;
hw/intc/s390_flic.c +2 -2
@@ -62,11 +62,11 @@ void s390_flic_init(void)DeviceState *dev;if (kvm_enabled ()) { - dev =qdev_new (TYPE_KVM_S390_FLIC ); + dev =qdev_new_orphan (TYPE_KVM_S390_FLIC );object_property_add_child (qdev_get_machine (),TYPE_KVM_S390_FLIC ,OBJECT (dev)); }else { - dev =qdev_new (TYPE_QEMU_S390_FLIC ); + dev =qdev_new_orphan (TYPE_QEMU_S390_FLIC );object_property_add_child (qdev_get_machine (),TYPE_QEMU_S390_FLIC ,OBJECT (dev)); }
hw/intc/sifive_plic.c +1 -1
@@ -481,7 +481,7 @@ DeviceState *sifive_plic_create(hwaddr addr, char *hart_config, uint32_t enable_stride, uint32_t context_base, uint32_t context_stride, uint32_t aperture_size) { - DeviceState *dev = qdev_new(TYPE_SIFIVE_PLIC); + DeviceState *dev = qdev_new_orphan(TYPE_SIFIVE_PLIC);int i;SiFivePLICState *plic;
hw/isa/isa-bus.c +3 -3
@@ -59,7 +59,7 @@ ISABus *isa_bus_new(DeviceState *dev, MemoryRegion* address_space,return NULL ; }if (!dev) { - bridge =qdev_new ("isabus-bridge" ); + bridge =qdev_new_orphan ("isabus-bridge" ); dev = bridge; }
@@ -155,12 +155,12 @@ int isa_register_portio_list(ISADevice *dev,ISADevice *isa_new (const char *name) { -return ISA_DEVICE (qdev_new (name)); +return ISA_DEVICE (qdev_new_orphan (name)); }ISADevice *isa_try_new (const char *name) { -return ISA_DEVICE (qdev_try_new (name)); +return ISA_DEVICE (qdev_try_new_orphan (name)); }ISADevice *isa_create_simple (ISABus *bus,const char *name)
hw/loongarch/virt.c +9 -9
@@ -150,7 +150,7 @@ static PFlashCFI01 *virt_flash_create1(LoongArchVirtMachineState *lvms,const char *name, const char *alias_prop_name) { - DeviceState *dev = qdev_new(TYPE_PFLASH_CFI01); + DeviceState *dev = qdev_new_orphan(TYPE_PFLASH_CFI01);qdev_prop_set_uint64 (dev,"sector-length" ,VIRT_FLASH_SECTOR_SIZE );qdev_prop_set_uint8 (dev,"width" ,4 );
@@ -295,7 +295,7 @@ static DeviceState *create_acpi_ged(DeviceState *pch_pic, event |=ACPI_GED_CPU_HOTPLUG_EVT ; } - dev =qdev_new (TYPE_ACPI_GED ); + dev =qdev_new_orphan (TYPE_ACPI_GED );qdev_prop_set_uint32 (dev,"ged-event" , event);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -322,7 +322,7 @@ static DeviceState *create_platform_bus(DeviceState *pch_pic)int i, irq;MemoryRegion *sysmem =get_system_memory (); - dev =qdev_new (TYPE_PLATFORM_BUS_DEVICE ); + dev =qdev_new_orphan (TYPE_PLATFORM_BUS_DEVICE ); dev->id =g_strdup (TYPE_PLATFORM_BUS_DEVICE );qdev_prop_set_uint32 (dev,"num_irqs" ,VIRT_PLATFORM_BUS_NUM_IRQS );qdev_prop_set_uint32 (dev,"mmio_size" ,VIRT_PLATFORM_BUS_SIZE );
@@ -400,7 +400,7 @@ static void virt_devices_init(DeviceState *pch_pic,hwaddr mmio_base, mmio_size;int i, irq; - gpex_dev =qdev_new (TYPE_GPEX_HOST ); + gpex_dev =qdev_new_orphan (TYPE_GPEX_HOST ); d =SYS_BUS_DEVICE (gpex_dev);sysbus_realize_and_unref (d, &error_fatal); pci_bus =PCI_HOST_BRIDGE (gpex_dev)->bus;
@@ -601,20 +601,20 @@ static void virt_irq_init(LoongArchVirtMachineState *lvms)*/ /* Create IPI device */ - ipi =qdev_new (TYPE_LOONGARCH_IPI ); + ipi =qdev_new_orphan (TYPE_LOONGARCH_IPI ); lvms->ipi = ipi;sysbus_realize_and_unref (SYS_BUS_DEVICE (ipi), &error_fatal);/* Create DINTC device*/ if (virt_has_dmsi (lvms)) { - dintc =qdev_new (TYPE_LOONGARCH_DINTC ); + dintc =qdev_new_orphan (TYPE_LOONGARCH_DINTC ); lvms->dintc = dintc;sysbus_realize_and_unref (SYS_BUS_DEVICE (dintc), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dintc),0 ,VIRT_DINTC_BASE ); }/* Create EXTIOI device */ - extioi =qdev_new (TYPE_LOONGARCH_EXTIOI ); + extioi =qdev_new_orphan (TYPE_LOONGARCH_EXTIOI ); lvms->extioi = extioi;if (virt_is_veiointc_enabled (lvms)) {qdev_prop_set_bit (extioi,"has-virtualization-extension" , true);
@@ -622,13 +622,13 @@ static void virt_irq_init(LoongArchVirtMachineState *lvms)sysbus_realize_and_unref (SYS_BUS_DEVICE (extioi), &error_fatal);virt_cpu_irq_init (lvms); - pch_pic =qdev_new (TYPE_LOONGARCH_PIC ); + pch_pic =qdev_new_orphan (TYPE_LOONGARCH_PIC ); num =VIRT_PCH_PIC_IRQ_NUM ;qdev_prop_set_uint32 (pch_pic,"pch_pic_irq_num" , num); d =SYS_BUS_DEVICE (pch_pic);sysbus_realize_and_unref (d, &error_fatal); - pch_msi =qdev_new (TYPE_LOONGARCH_PCH_MSI ); + pch_msi =qdev_new_orphan (TYPE_LOONGARCH_PCH_MSI ); start = num; num =EXTIOI_IRQS - start;qdev_prop_set_uint32 (pch_msi,"msi_irq_base" , start);
hw/m68k/an5206.c +1 -1
@@ -25,7 +25,7 @@ static void mcf5206_init(M68kCPU *cpu, MemoryRegion *sysmem, uint32_t base)DeviceState *dev;SysBusDevice *s; - dev =qdev_new (TYPE_MCF5206_MBAR ); + dev =qdev_new_orphan (TYPE_MCF5206_MBAR );object_property_set_link (OBJECT (dev),"m68k-cpu" ,OBJECT (cpu), &error_abort); s =SYS_BUS_DEVICE (dev);
hw/m68k/mcf_intc.c +1 -1
@@ -211,7 +211,7 @@ DeviceState *mcf_intc_init(MemoryRegion *sysmem, hwaddr base, M68kCPU *cpu) {DeviceState *dev; - dev =qdev_new (TYPE_MCF_INTC ); + dev =qdev_new_orphan (TYPE_MCF_INTC );object_property_set_link (OBJECT (dev),"m68k-cpu" ,OBJECT (cpu), &error_abort);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/m68k/next-cube.c +1 -1
@@ -1272,7 +1272,7 @@ static void next_cube_init(MachineState *machine) env->sr =0x2700 ;/* Peripheral Controller */ - pcdev =qdev_new (TYPE_NEXT_PC ); + pcdev =qdev_new_orphan (TYPE_NEXT_PC );object_property_set_link (OBJECT (pcdev),"cpu" ,OBJECT (cpu), &error_abort);sysbus_realize_and_unref (SYS_BUS_DEVICE (pcdev), &error_fatal);
hw/m68k/q800.c +2 -2
@@ -355,9 +355,9 @@ static void q800_machine_init(MachineState *machine) "auxmode", 0)); adb_bus =qdev_get_child_bus (DEVICE (&m->via1),"adb.0" ); - dev =qdev_new (TYPE_ADB_KEYBOARD ); + dev =qdev_new_orphan (TYPE_ADB_KEYBOARD );qdev_realize_and_unref (dev, adb_bus, &error_fatal); - dev =qdev_new (TYPE_ADB_MOUSE ); + dev =qdev_new_orphan (TYPE_ADB_MOUSE );qdev_realize_and_unref (dev, adb_bus, &error_fatal);/* VIA 2 */
hw/m68k/virt.c +5 -5
@@ -155,7 +155,7 @@ static void virt_init(MachineState *machine)/* IRQ Controller */ - irqc_dev =qdev_new (TYPE_M68K_IRQC ); + irqc_dev =qdev_new_orphan (TYPE_M68K_IRQC );object_property_set_link (OBJECT (irqc_dev),"m68k-cpu" ,OBJECT (cpu), &error_abort);sysbus_realize_and_unref (SYS_BUS_DEVICE (irqc_dev), &error_fatal);
@@ -169,7 +169,7 @@ static void virt_init(MachineState *machine)*/ io_base =VIRT_GF_PIC_MMIO_BASE ;for (i =0 ; i <VIRT_GF_PIC_NB ; i++) { - pic_dev[i] =qdev_new (TYPE_GOLDFISH_PIC ); + pic_dev[i] =qdev_new_orphan (TYPE_GOLDFISH_PIC ); sysbus =SYS_BUS_DEVICE (pic_dev[i]);qdev_prop_set_uint8 (pic_dev[i],"index" , i);sysbus_realize_and_unref (sysbus, &error_fatal);
@@ -183,7 +183,7 @@ static void virt_init(MachineState *machine)/* goldfish-rtc */ io_base =VIRT_GF_RTC_MMIO_BASE ;for (i =0 ; i <VIRT_GF_RTC_NB ; i++) { - dev =qdev_new (TYPE_GOLDFISH_RTC ); + dev =qdev_new_orphan (TYPE_GOLDFISH_RTC );qdev_prop_set_bit (dev,"big-endian" , true); sysbus =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (sysbus, &error_fatal);
@@ -194,7 +194,7 @@ static void virt_init(MachineState *machine) }/* goldfish-tty */ - dev =qdev_new (TYPE_GOLDFISH_TTY ); + dev =qdev_new_orphan (TYPE_GOLDFISH_TTY ); sysbus =SYS_BUS_DEVICE (dev);qdev_prop_set_chr (dev,"chardev" ,serial_hd (0 ));sysbus_realize_and_unref (sysbus, &error_fatal);
@@ -208,7 +208,7 @@ static void virt_init(MachineState *machine)/* virtio-mmio */ io_base =VIRT_VIRTIO_MMIO_BASE ;for (i =0 ; i <128 ; i++) { - dev =qdev_new (TYPE_VIRTIO_MMIO ); + dev =qdev_new_orphan (TYPE_VIRTIO_MMIO );qdev_prop_set_bit (dev,"force-legacy" , false); sysbus =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (sysbus, &error_fatal);
hw/mem/sparse-mem.c +1 -1
@@ -108,7 +108,7 @@ MemoryRegion *sparse_mem_init(uint64_t addr, uint64_t length) {DeviceState *dev; - dev =qdev_new (TYPE_SPARSE_MEM ); + dev =qdev_new_orphan (TYPE_SPARSE_MEM );qdev_prop_set_uint64 (dev,"baseaddr" , addr);qdev_prop_set_uint64 (dev,"length" , length);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/microblaze/petalogix_ml605_mmu.c +6 -6
@@ -110,7 +110,7 @@ petalogix_ml605_init(MachineState *machine) 64 * KiB, 2, 0x89, 0x18, 0x0000, 0x0, 0); - dev =qdev_new ("xlnx.xps-intc" ); + dev =qdev_new_orphan ("xlnx.xps-intc" );qdev_prop_set_enum (dev,"endianness" ,ENDIAN_MODE_LITTLE );qdev_prop_set_uint32 (dev,"kind-of-intr" ,1 <<TIMER_IRQ );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -126,7 +126,7 @@ petalogix_ml605_init(MachineState *machine) DEVICE_LITTLE_ENDIAN);/* 2 timers at irq 2 @ 100 Mhz. */ - dev =qdev_new ("xlnx.xps-timer" ); + dev =qdev_new_orphan ("xlnx.xps-timer" );qdev_prop_set_enum (dev,"endianness" ,ENDIAN_MODE_LITTLE );qdev_prop_set_uint32 (dev,"one-timer-only" ,0 );qdev_prop_set_uint32 (dev,"clock-frequency" ,100 *1000000 );
@@ -135,8 +135,8 @@ petalogix_ml605_init(MachineState *machine)sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , irq[TIMER_IRQ ]);/* axi ethernet and dma initialization. */ - eth0 =qdev_new ("xlnx.axi-ethernet" ); - dma =qdev_new ("xlnx.axi-dma" ); + eth0 =qdev_new_orphan ("xlnx.axi-ethernet" ); + dma =qdev_new_orphan ("xlnx.axi-dma" );/* FIXME: attach to the sysbus instead */ object_property_add_child (qdev_get_machine (),"xilinx-eth" ,OBJECT (eth0));
@@ -174,7 +174,7 @@ petalogix_ml605_init(MachineState *machine) {SSIBus *spi; - dev =qdev_new ("xlnx.xps-spi" ); + dev =qdev_new_orphan ("xlnx.xps-spi" );qdev_prop_set_enum (dev,"endianness" ,ENDIAN_MODE_LITTLE );qdev_prop_set_uint8 (dev,"num-ss-bits" ,NUM_SPI_FLASHES ); busdev =SYS_BUS_DEVICE (dev);
@@ -188,7 +188,7 @@ petalogix_ml605_init(MachineState *machine) dinfo =drive_get (IF_MTD ,0 , i);qemu_irq cs_line; - dev =qdev_new ("n25q128" ); + dev =qdev_new_orphan ("n25q128" );if (dinfo) { qdev_prop_set_drive_err(dev, "drive", blk_by_legacy_dinfo(dinfo),
hw/microblaze/petalogix_s3adsp1800_mmu.c +4 -4
@@ -107,7 +107,7 @@ petalogix_s3adsp1800_init(MachineState *machine) dinfo ?blk_by_legacy_dinfo (dinfo) :NULL , 64 * KiB, 1, 0x89, 0x18, 0x0000, 0x0, 1); - dev =qdev_new ("xlnx.xps-intc" ); + dev =qdev_new_orphan ("xlnx.xps-intc" );qdev_prop_set_enum (dev,"endianness" , endianness);qdev_prop_set_uint32 (dev,"kind-of-intr" ,1 <<ETHLITE_IRQ |1 <<UARTLITE_IRQ );
@@ -119,7 +119,7 @@ petalogix_s3adsp1800_init(MachineState *machine) irq[i] =qdev_get_gpio_in (dev, i); } - dev =qdev_new (TYPE_XILINX_UARTLITE ); + dev =qdev_new_orphan (TYPE_XILINX_UARTLITE );qdev_prop_set_enum (dev,"endianness" , endianness);qdev_prop_set_chr (dev,"chardev" ,serial_hd (0 ));sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -127,7 +127,7 @@ petalogix_s3adsp1800_init(MachineState *machine)sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , irq[UARTLITE_IRQ ]);/* 2 timers at irq 2 @ 62 Mhz. */ - dev =qdev_new ("xlnx.xps-timer" ); + dev =qdev_new_orphan ("xlnx.xps-timer" );qdev_prop_set_enum (dev,"endianness" , endianness);qdev_prop_set_uint32 (dev,"one-timer-only" ,0 );qdev_prop_set_uint32 (dev,"clock-frequency" ,62 *1000000 );
@@ -135,7 +135,7 @@ petalogix_s3adsp1800_init(MachineState *machine)sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,TIMER_BASEADDR );sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , irq[TIMER_IRQ ]); - dev =qdev_new ("xlnx.xps-ethernetlite" ); + dev =qdev_new_orphan ("xlnx.xps-ethernetlite" );qdev_prop_set_enum (dev,"endianness" , endianness);qemu_configure_nic_device (dev, true,NULL );qdev_prop_set_uint32 (dev,"tx-ping-pong" ,0 );
hw/mips/boston.c +2 -2
@@ -432,7 +432,7 @@ xilinx_pcie_init(MemoryRegion *sys_mem, uint32_t bus_nr,DeviceState *dev;MemoryRegion *cfg, *mmio; - dev =qdev_new (TYPE_XILINX_PCIE_HOST ); + dev =qdev_new_orphan (TYPE_XILINX_PCIE_HOST );qdev_prop_set_uint32 (dev,"bus_nr" , bus_nr);qdev_prop_set_uint64 (dev,"cfg_base" , cfg_base);
@@ -688,7 +688,7 @@ static void boston_mach_init(MachineState *machine)exit (1 ); } - dev =qdev_new (TYPE_BOSTON ); + dev =qdev_new_orphan (TYPE_BOSTON );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); s =BOSTON (dev);
hw/mips/jazz.c +6 -6
@@ -127,7 +127,7 @@ static void mips_jazz_init_net(IOMMUMemoryRegion *rc4030_dma_mr,return ; } - dev =qdev_new ("dp8393x" ); + dev =qdev_new_orphan ("dp8393x" );qdev_set_nic_properties (dev, nd);qdev_prop_set_uint8 (dev,"it_shift" ,2 );qdev_prop_set_bit (dev,"big_endian" ,TARGET_BIG_ENDIAN );
@@ -296,7 +296,7 @@ static void mips_jazz_init(MachineState *machine,/* Video card */ switch (jazz_model) {case JAZZ_MAGNUM : - dev =qdev_new ("sysbus-g364" ); + dev =qdev_new_orphan ("sysbus-g364" ); sysbus =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (sysbus, &error_fatal);sysbus_mmio_map (sysbus,0 ,0x60080000 );
@@ -313,7 +313,7 @@ static void mips_jazz_init(MachineState *machine, }break ;case JAZZ_PICA61 : - dev =qdev_new (TYPE_VGA_MMIO ); + dev =qdev_new_orphan (TYPE_VGA_MMIO );qdev_prop_set_uint8 (dev,"it_shift" ,0 ); sysbus =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (sysbus, &error_fatal);
@@ -329,7 +329,7 @@ static void mips_jazz_init(MachineState *machine,mips_jazz_init_net (rc4030_dma_mr, rc4030, dp8393x_prom);/* SCSI adapter */ - dev =qdev_new (TYPE_SYSBUS_ESP ); + dev =qdev_new_orphan (TYPE_SYSBUS_ESP ); sysbus_esp =SYSBUS_ESP (dev); esp = &sysbus_esp->esp; esp->dma_memory_read = rc4030_dma_read;
@@ -359,7 +359,7 @@ static void mips_jazz_init(MachineState *machine,memory_region_add_subregion (address_space,0x80004000 , rtc);/* Keyboard (i8042) */ - i8042 =I8042_MMIO (qdev_new (TYPE_I8042_MMIO )); + i8042 =I8042_MMIO (qdev_new_orphan (TYPE_I8042_MMIO ));qdev_prop_set_uint64 (DEVICE (i8042),"mask" ,1 );qdev_prop_set_uint32 (DEVICE (i8042),"size" ,0x1000 );sysbus_realize_and_unref (SYS_BUS_DEVICE (i8042), &error_fatal);
@@ -389,7 +389,7 @@ static void mips_jazz_init(MachineState *machine,/* FIXME: missing Jazz sound at 0x8000c000, rc4030[2] */ /* NVRAM */ - dev =qdev_new ("ds1225y" ); + dev =qdev_new_orphan ("ds1225y" ); sysbus =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (sysbus, &error_fatal);sysbus_mmio_map (sysbus,0 ,0x80009000 );
hw/mips/loongson3_virt.c +3 -3
@@ -424,7 +424,7 @@ static inline void loongson3_virt_devices_init(MachineState *machine,MachineClass *mc =MACHINE_GET_CLASS (machine);LoongsonMachineState *s =LOONGSON_MACHINE (machine); - dev =qdev_new (TYPE_GPEX_HOST ); + dev =qdev_new_orphan (TYPE_GPEX_HOST );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); pci_bus =PCI_HOST_BRIDGE (dev)->bus;
@@ -519,7 +519,7 @@ static void mips_loongson3_virt_init(MachineState *machine)memory_region_init (iocsr,OBJECT (machine),"loongson3.iocsr" ,UINT32_MAX ); - ipi =qdev_new (TYPE_LOONGSON_IPI ); + ipi =qdev_new_orphan (TYPE_LOONGSON_IPI );qdev_prop_set_uint32 (ipi,"num-cpu" , machine->smp.cpus);sysbus_realize_and_unref (SYS_BUS_DEVICE (ipi), &error_fatal); memory_region_add_subregion(iocsr, SMP_IPI_MAILBOX,
@@ -527,7 +527,7 @@ static void mips_loongson3_virt_init(MachineState *machine)memory_region_add_subregion (iocsr,MAIL_SEND_ADDR ,sysbus_mmio_get_region (SYS_BUS_DEVICE (ipi),1 )); - liointc =qdev_new ("loongson.liointc" ); + liointc =qdev_new_orphan ("loongson.liointc" );sysbus_realize_and_unref (SYS_BUS_DEVICE (liointc), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (liointc),0 , virt_memmap[VIRT_LIOINTC ].base);
hw/mips/malta.c +2 -2
@@ -1098,7 +1098,7 @@ void mips_malta_init(MachineState *machine)PCIDevice *piix4;DeviceState *dev; - s =MIPS_MALTA (qdev_new (TYPE_MIPS_MALTA )); + s =MIPS_MALTA (qdev_new_orphan (TYPE_MIPS_MALTA ));sysbus_realize_and_unref (SYS_BUS_DEVICE (s), &error_fatal);/* create CPU */
@@ -1226,7 +1226,7 @@ void mips_malta_init(MachineState *machine)stl_p (memory_region_get_ram_ptr (bios_copy) +0x10 ,0x00000420 );/* Northbridge */ - dev =qdev_new ("gt64120" ); + dev =qdev_new_orphan ("gt64120" );qdev_prop_set_bit (dev,"cpu-little-endian" , !TARGET_BIG_ENDIAN );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); pci_bus =PCI_BUS (qdev_get_child_bus (dev,"pci" ));
hw/misc/empty_slot.c +1 -1
@@ -58,7 +58,7 @@ void empty_slot_init(const char *name, hwaddr addr, uint64_t slot_size)/* Only empty slots larger than 0 byte need handling. */ DeviceState *dev; - dev =qdev_new (TYPE_EMPTY_SLOT ); + dev =qdev_new_orphan (TYPE_EMPTY_SLOT );qdev_prop_set_uint64 (dev,"size" , slot_size);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/misc/led.c +1 -1
@@ -141,7 +141,7 @@ LEDState *led_create_simple(Object *parentobj, g_autofree char *name = NULL;DeviceState *dev; - dev =qdev_new (TYPE_LED ); + dev =qdev_new_orphan (TYPE_LED );qdev_prop_set_bit (dev,"gpio-active-high" , gpio_polarity ==GPIO_POLARITY_ACTIVE_HIGH );qdev_prop_set_string (dev,"color" , led_color_name[color]);
hw/misc/sifive_e_prci.c +1 -1
@@ -117,7 +117,7 @@ type_init(sifive_e_prci_register_types)*/ DeviceState *sifive_e_prci_create (hwaddr addr) { -DeviceState *dev =qdev_new (TYPE_SIFIVE_E_PRCI ); +DeviceState *dev =qdev_new_orphan (TYPE_SIFIVE_E_PRCI );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 , addr);return dev;
hw/misc/sifive_test.c +1 -1
@@ -97,7 +97,7 @@ type_init(sifive_test_register_types)*/ DeviceState *sifive_test_create (hwaddr addr) { -DeviceState *dev =qdev_new (TYPE_SIFIVE_TEST ); +DeviceState *dev =qdev_new_orphan (TYPE_SIFIVE_TEST );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 , addr);return dev;
hw/net/lan9118.c +1 -1
@@ -1339,7 +1339,7 @@ void lan9118_init(uint32_t base, qemu_irq irq)DeviceState *dev;SysBusDevice *s; - dev =qdev_new (TYPE_LAN9118 ); + dev =qdev_new_orphan (TYPE_LAN9118 );qemu_configure_nic_device (dev, true,NULL ); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);
hw/net/smc91c111.c +1 -1
@@ -954,7 +954,7 @@ void smc91c111_init(uint32_t base, qemu_irq irq)DeviceState *dev;SysBusDevice *s; - dev =qdev_new (TYPE_SMC91C111 ); + dev =qdev_new_orphan (TYPE_SMC91C111 );qemu_configure_nic_device (dev, true,NULL ); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);
hw/net/spapr_llan.c +1 -1
@@ -371,7 +371,7 @@ void spapr_vlan_create(SpaprVioBus *bus, NICInfo *nd) {DeviceState *dev; - dev =qdev_new ("spapr-vlan" ); + dev =qdev_new_orphan ("spapr-vlan" );qdev_set_nic_properties (dev, nd);
hw/net/xen_nic.c +1 -1
@@ -619,7 +619,7 @@ static void xen_net_device_create(XenBackendInstance *backend, goto fail; } - xendev =XEN_DEVICE (qdev_new (TYPE_XEN_NET_DEVICE )); + xendev =XEN_DEVICE (qdev_new_orphan (TYPE_XEN_NET_DEVICE )); net =XEN_NET_DEVICE (xendev); net->dev = number;
hw/nitro/machine.c +2 -2
@@ -197,7 +197,7 @@ static void nitro_machine_init(MachineState *machine)NitroVsockBridge *bridge =nitro_vsock_bridge_create ();/* Nitro Enclaves require a heartbeat device. Provide one. */ -qdev_realize (qdev_new (TYPE_NITRO_HEARTBEAT ), +qdev_realize (qdev_new_orphan (TYPE_NITRO_HEARTBEAT ),BUS (&bridge->bus), &error_fatal);/*
@@ -209,7 +209,7 @@ static void nitro_machine_init(MachineState *machine)Chardev *chr =serial_hd (0 );if (chr) { -DeviceState *dev =qdev_new (TYPE_NITRO_SERIAL_VSOCK ); +DeviceState *dev =qdev_new_orphan (TYPE_NITRO_SERIAL_VSOCK );qdev_prop_set_chr (dev,"chardev" , chr);qdev_realize (dev,BUS (&bridge->bus), &error_fatal);
hw/nitro/nitro-vsock-bus.c +1 -1
@@ -48,7 +48,7 @@ void nitro_vsock_bridge_start_enclave(NitroVsockBridge *bridge,NitroVsockBridge *nitro_vsock_bridge_create (void ) { -DeviceState *dev =qdev_new (TYPE_NITRO_VSOCK_BRIDGE ); +DeviceState *dev =qdev_new_orphan (TYPE_NITRO_VSOCK_BRIDGE );qdev_set_id (dev,g_strdup ("nitro-vsock" ), &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/nvme/ctrl.c +1 -1
@@ -9556,7 +9556,7 @@ static int nvme_init_subsys(NvmeCtrl *n, Error **errp)int cntlid;if (!n->subsys) { -DeviceState *dev =qdev_new (TYPE_NVME_SUBSYS ); +DeviceState *dev =qdev_new_orphan (TYPE_NVME_SUBSYS );qdev_prop_set_string (dev,"nqn" , n->params.serial);
hw/nvram/fw_cfg.c +2 -2
@@ -1029,7 +1029,7 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, AddressSpace *dma_as)assert (dma_as); - dev =qdev_new (TYPE_FW_CFG_IO ); + dev =qdev_new_orphan (TYPE_FW_CFG_IO );object_property_add_child (OBJECT (qdev_get_machine ()),TYPE_FW_CFG ,OBJECT (dev));
@@ -1061,7 +1061,7 @@ static FWCfgState *fw_cfg_init_mem_internal(hwaddr ctl_addr,FWCfgState *s;bool dma_requested = dma_addr && dma_as; - dev =qdev_new (TYPE_FW_CFG_MEM ); + dev =qdev_new_orphan (TYPE_FW_CFG_MEM );qdev_prop_set_uint32 (dev,"data_width" , data_width);if (!dma_requested) {qdev_prop_set_bit (dev,"dma_enabled" , false);
hw/or1k/or1k-sim.c +3 -3
@@ -186,7 +186,7 @@ static void openrisc_sim_net_init(Or1ksimState *state, hwaddr base, hwaddr size, s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);if (num_cpus >1 ) { -DeviceState *splitter =qdev_new (TYPE_SPLIT_IRQ ); +DeviceState *splitter =qdev_new_orphan (TYPE_SPLIT_IRQ );qdev_prop_set_uint32 (splitter,"num-lines" , num_cpus);qdev_realize_and_unref (splitter,NULL , &error_fatal);for (i =0 ; i < num_cpus; i++) {
@@ -221,7 +221,7 @@ static void openrisc_sim_ompic_init(Or1ksimState *state, hwaddr base,char *nodename;int i; - dev =qdev_new ("or1k-ompic" ); + dev =qdev_new_orphan ("or1k-ompic" );qdev_prop_set_uint32 (dev,"num-cpus" , num_cpus); s =SYS_BUS_DEVICE (dev);
@@ -254,7 +254,7 @@ static void openrisc_sim_serial_init(Or1ksimState *state, hwaddr base,int i;if (num_cpus >1 ) { -DeviceState *splitter =qdev_new (TYPE_SPLIT_IRQ ); +DeviceState *splitter =qdev_new_orphan (TYPE_SPLIT_IRQ );qdev_prop_set_uint32 (splitter,"num-lines" , num_cpus);qdev_realize_and_unref (splitter,NULL , &error_fatal);for (i =0 ; i < num_cpus; i++) {
hw/or1k/virt.c +4 -4
@@ -110,7 +110,7 @@ static qemu_irq get_per_cpu_irq(OpenRISCCPU *cpus[], int num_cpus, int irq_pin)int i;if (num_cpus >1 ) { -DeviceState *splitter =qdev_new (TYPE_SPLIT_IRQ ); +DeviceState *splitter =qdev_new_orphan (TYPE_SPLIT_IRQ );qdev_prop_set_uint32 (splitter,"num-lines" , num_cpus);qdev_realize_and_unref (splitter,NULL , &error_fatal);for (i =0 ; i < num_cpus; i++) {
@@ -206,7 +206,7 @@ static void openrisc_virt_ompic_init(OR1KVirtState *state, hwaddr base,char *nodename;int i; - dev =qdev_new ("or1k-ompic" ); + dev =qdev_new_orphan ("or1k-ompic" );qdev_prop_set_uint32 (dev,"num-cpus" , num_cpus); s =SYS_BUS_DEVICE (dev);
@@ -379,7 +379,7 @@ static void openrisc_virt_pcie_init(OR1KVirtState *state,qemu_irq pcie_irq;int i; - dev =qdev_new (TYPE_GPEX_HOST ); + dev =qdev_new_orphan (TYPE_GPEX_HOST );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);/* Map ECAM space. */
@@ -451,7 +451,7 @@ static void openrisc_virt_virtio_init(OR1KVirtState *state, hwaddr base,qemu_irq virtio_irq =get_per_cpu_irq (cpus, num_cpus, irq_pin);/* VirtIO MMIO devices */ - dev =qdev_new (TYPE_VIRTIO_MMIO ); + dev =qdev_new_orphan (TYPE_VIRTIO_MMIO );qdev_prop_set_bit (dev,"force-legacy" , false); sysbus =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (sysbus, &error_fatal);
hw/pci-bridge/pci_expander_bridge.c +2 -2
@@ -359,7 +359,7 @@ static bool pxb_dev_realize_common(PCIDevice *dev, enum BusType type, dev_name = dev->qdev.id; } - ds =qdev_new (type ==CXL ?TYPE_PXB_CXL_HOST :TYPE_PXB_HOST ); + ds =qdev_new_orphan (type ==CXL ?TYPE_PXB_CXL_HOST :TYPE_PXB_HOST );if (type ==PCIE ) { bus =pci_root_bus_new (ds, dev_name,NULL ,NULL ,0 ,TYPE_PXB_PCIE_BUS ); }else if (type ==CXL ) {
@@ -368,7 +368,7 @@ static bool pxb_dev_realize_common(PCIDevice *dev, enum BusType type,PXB_CXL_DEV (dev)->cxl_host_bridge =PXB_CXL_HOST (ds); }else { bus =pci_root_bus_new (ds,"pxb-internal" ,NULL ,NULL ,0 ,TYPE_PXB_BUS ); - bds =qdev_new ("pci-bridge" ); + bds =qdev_new_orphan ("pci-bridge" ); bds->id =g_strdup (dev_name);qdev_prop_set_uint8 (bds,PCI_BRIDGE_DEV_PROP_CHASSIS_NR , pxb->bus_nr);qdev_prop_set_bit (bds,PCI_BRIDGE_DEV_PROP_SHPC , false);
hw/pci-host/astro.c +1 -1
@@ -521,7 +521,7 @@ static ElroyState *elroy_init(int num) {DeviceState *dev; - dev =qdev_new (TYPE_ELROY_PCI_HOST_BRIDGE ); + dev =qdev_new_orphan (TYPE_ELROY_PCI_HOST_BRIDGE ); dev->id =g_strdup_printf ("elroy%d" , num);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/pci-host/bonito.c +1 -1
@@ -741,7 +741,7 @@ PCIBus *bonito_init(qemu_irq *pic)PCIBonitoState *s;PCIDevice *d; - dev =qdev_new (TYPE_BONITO_PCI_HOST_BRIDGE ); + dev =qdev_new_orphan (TYPE_BONITO_PCI_HOST_BRIDGE ); phb =PCI_HOST_BRIDGE (dev); pcihost =BONITO_PCI_HOST_BRIDGE (dev); pcihost->pic = pic;
hw/pci-host/pnv_phb4_pec.c +1 -1
@@ -180,7 +180,7 @@ static PnvPHB *pnv_pec_default_phb_realize(PnvPhb4PecState *pec,int stack_no, Error **errp) { - PnvPHB *phb = PNV_PHB(qdev_new(TYPE_PNV_PHB)); + PnvPHB *phb = PNV_PHB(qdev_new_orphan(TYPE_PNV_PHB));int phb_id =pnv_phb4_pec_get_phb_id (pec, stack_no);object_property_add_child (OBJECT (pec),"phb[*]" ,OBJECT (phb));
hw/pci/pci.c +1 -1
@@ -2393,7 +2393,7 @@ static PCIDevice *pci_new_internal(int devfn, bool multifunction, {DeviceState *dev; - dev =qdev_new (name); + dev =qdev_new_orphan (name);qdev_prop_set_int32 (dev,"addr" , devfn);qdev_prop_set_bit (dev,"multifunction" , multifunction);return PCI_DEVICE (dev);
hw/ppc/amigaone.c +1 -1
@@ -302,7 +302,7 @@ static void amigaone_init(MachineState *machine) }/* nvram */ - dev =qdev_new (TYPE_A1_NVRAM ); + dev =qdev_new_orphan (TYPE_A1_NVRAM ); di =drive_get (IF_MTD ,0 ,0 );if (di) {qdev_prop_set_drive (dev,"drive" ,blk_by_legacy_dinfo (di));
hw/ppc/e500.c +11 -11
@@ -815,7 +815,7 @@ static DeviceState *ppce500_init_mpic_qemu(PPCE500MachineState *pms,unsigned int smp_cpus = machine->smp.cpus;const PPCE500MachineClass *pmc =PPCE500_MACHINE_GET_CLASS (pms); - dev =qdev_new (TYPE_OPENPIC ); + dev =qdev_new_orphan (TYPE_OPENPIC );object_property_add_child (OBJECT (machine),"pic" ,OBJECT (dev));qdev_prop_set_uint32 (dev,"model" , pmc->mpic_version);qdev_prop_set_uint32 (dev,"nb_cpus" , smp_cpus);
@@ -840,7 +840,7 @@ static DeviceState *ppce500_init_mpic_kvm(const PPCE500MachineClass *pmc,DeviceState *dev;CPUState *cs; - dev =qdev_new (TYPE_KVM_OPENPIC ); + dev =qdev_new_orphan (TYPE_KVM_OPENPIC );qdev_prop_set_uint32 (dev,"model" , pmc->mpic_version);if (!sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), errp)) {
@@ -993,7 +993,7 @@ void ppce500_init(MachineState *machine)/* Register Memory */ memory_region_add_subregion (address_space_mem,0 , machine->ram); - dev =qdev_new ("e500-ccsr" ); + dev =qdev_new_orphan ("e500-ccsr" ); s =SYS_BUS_DEVICE (dev);object_property_add_child (OBJECT (machine),"e500-ccsr" ,OBJECT (dev));sysbus_realize_and_unref (s, &error_fatal);
@@ -1018,7 +1018,7 @@ void ppce500_init(MachineState *machine) }/* I2C */ - dev =qdev_new ("mpc-i2c" ); + dev =qdev_new_orphan ("mpc-i2c" ); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);sysbus_connect_irq (s,0 ,qdev_get_gpio_in (mpicdev,MPC8544_I2C_IRQ ));
@@ -1029,7 +1029,7 @@ void ppce500_init(MachineState *machine)/* eSDHC */ if (pmc->has_esdhc) { - dev =qdev_new (TYPE_UNIMPLEMENTED_DEVICE ); + dev =qdev_new_orphan (TYPE_UNIMPLEMENTED_DEVICE );qdev_prop_set_string (dev,"name" ,"esdhc" );qdev_prop_set_uint64 (dev,"size" ,MPC85XX_ESDHC_REGS_SIZE ); s =SYS_BUS_DEVICE (dev);
@@ -1037,7 +1037,7 @@ void ppce500_init(MachineState *machine)memory_region_add_subregion (ccsr_addr_space,MPC85XX_ESDHC_REGS_OFFSET ,sysbus_mmio_get_region (s,0 )); - dev =qdev_new (TYPE_FSL_ESDHC_BE ); + dev =qdev_new_orphan (TYPE_FSL_ESDHC_BE ); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);sysbus_connect_irq (s,0 ,qdev_get_gpio_in (mpicdev,MPC85XX_ESDHC_IRQ ));
@@ -1046,14 +1046,14 @@ void ppce500_init(MachineState *machine) }/* General Utility device */ - dev =qdev_new ("mpc8544-guts" ); + dev =qdev_new_orphan ("mpc8544-guts" ); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);memory_region_add_subregion (ccsr_addr_space,MPC8544_UTIL_OFFSET ,sysbus_mmio_get_region (s,0 ));/* PCI */ - dev =qdev_new ("e500-pcihost" ); + dev =qdev_new_orphan ("e500-pcihost" );object_property_add_child (OBJECT (machine),"pci-host" ,OBJECT (dev));qdev_prop_set_uint32 (dev,"first_slot" , pmc->pci_first_slot);qdev_prop_set_uint32 (dev,"first_pin_irq" , pci_irq_nrs[0 ]);
@@ -1081,7 +1081,7 @@ void ppce500_init(MachineState *machine)if (pmc->has_mpc8xxx_gpio) {qemu_irq poweroff_irq; - dev =qdev_new ("mpc8xxx_gpio" ); + dev =qdev_new_orphan ("mpc8xxx_gpio" ); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);sysbus_connect_irq (s,0 ,qdev_get_gpio_in (mpicdev,MPC8XXX_GPIO_IRQ ));
@@ -1094,7 +1094,7 @@ void ppce500_init(MachineState *machine) }/* Platform Bus Device */ - dev =qdev_new (TYPE_PLATFORM_BUS_DEVICE ); + dev =qdev_new_orphan (TYPE_PLATFORM_BUS_DEVICE ); dev->id =g_strdup (TYPE_PLATFORM_BUS_DEVICE );qdev_prop_set_uint32 (dev,"num_irqs" , pmc->platform_bus_num_irqs);qdev_prop_set_uint32 (dev,"mmio_size" , pmc->platform_bus_size);
@@ -1136,7 +1136,7 @@ void ppce500_init(MachineState *machine)exit (1 ); } - dev =qdev_new (TYPE_PFLASH_CFI01 ); + dev =qdev_new_orphan (TYPE_PFLASH_CFI01 );qdev_prop_set_drive (dev,"drive" , blk);qdev_prop_set_uint32 (dev,"num-blocks" , size / sector_len);qdev_prop_set_uint64 (dev,"sector-length" , sector_len);
hw/ppc/mac_newworld.c +9 -9
@@ -286,7 +286,7 @@ static void ppc_core99_init(MachineState *machine) }/* UniN init */ - s =SYS_BUS_DEVICE (qdev_new (TYPE_UNI_NORTH )); + s =SYS_BUS_DEVICE (qdev_new_orphan (TYPE_UNI_NORTH ));sysbus_realize_and_unref (s, &error_fatal);memory_region_add_subregion (get_system_memory (),0xf8000000 ,sysbus_mmio_get_region (s,0 ));
@@ -295,7 +295,7 @@ static void ppc_core99_init(MachineState *machine) machine_arch =ARCH_MAC99_U3 ;/* 970 gets a U3 bus */ /* Uninorth AGP bus */ - uninorth_pci_dev =qdev_new (TYPE_U3_AGP_HOST_BRIDGE ); + uninorth_pci_dev =qdev_new_orphan (TYPE_U3_AGP_HOST_BRIDGE ); s =SYS_BUS_DEVICE (uninorth_pci_dev);sysbus_realize_and_unref (s, &error_fatal);sysbus_mmio_map (s,0 ,0xf0800000 );
@@ -310,14 +310,14 @@ static void ppc_core99_init(MachineState *machine) machine_arch =ARCH_MAC99 ;/* Use values found on a real PowerMac */ /* Uninorth AGP bus */ - uninorth_agp_dev =qdev_new (TYPE_UNI_NORTH_AGP_HOST_BRIDGE ); + uninorth_agp_dev =qdev_new_orphan (TYPE_UNI_NORTH_AGP_HOST_BRIDGE ); s =SYS_BUS_DEVICE (uninorth_agp_dev);sysbus_realize_and_unref (s, &error_fatal);sysbus_mmio_map (s,0 ,0xf0800000 );sysbus_mmio_map (s,1 ,0xf0c00000 );/* Uninorth internal bus */ - uninorth_internal_dev =qdev_new ( + uninorth_internal_dev =qdev_new_orphan (TYPE_UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE ); s =SYS_BUS_DEVICE (uninorth_internal_dev);sysbus_realize_and_unref (s, &error_fatal);
@@ -325,7 +325,7 @@ static void ppc_core99_init(MachineState *machine)sysbus_mmio_map (s,1 ,0xf4c00000 );/* Uninorth main bus - this must be last to make it the default */ - uninorth_pci_dev =qdev_new (TYPE_UNI_NORTH_PCI_HOST_BRIDGE ); + uninorth_pci_dev =qdev_new_orphan (TYPE_UNI_NORTH_PCI_HOST_BRIDGE );qdev_prop_set_uint32 (uninorth_pci_dev,"ofw-addr" ,0xf2000000 ); s =SYS_BUS_DEVICE (uninorth_pci_dev);sysbus_realize_and_unref (s, &error_fatal);
@@ -408,10 +408,10 @@ static void ppc_core99_init(MachineState *machine) } adb_bus =qdev_get_child_bus (dev,"adb.0" ); - dev =qdev_new (TYPE_ADB_KEYBOARD ); + dev =qdev_new_orphan (TYPE_ADB_KEYBOARD );qdev_realize_and_unref (dev, adb_bus, &error_fatal); - dev =qdev_new (TYPE_ADB_MOUSE ); + dev =qdev_new_orphan (TYPE_ADB_MOUSE );qdev_realize_and_unref (dev, adb_bus, &error_fatal); }
@@ -453,7 +453,7 @@ static void ppc_core99_init(MachineState *machine)move the NVRAM out of ROM again for KVM */ nvram_addr =0xFFE00000 ; } - dev =qdev_new (TYPE_MACIO_NVRAM ); + dev =qdev_new_orphan (TYPE_MACIO_NVRAM );qdev_prop_set_uint32 (dev,"size" ,MACIO_NVRAM_SIZE );qdev_prop_set_uint32 (dev,"it_shift" ,1 );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -462,7 +462,7 @@ static void ppc_core99_init(MachineState *machine)pmac_format_nvram_partition (nvr,MACIO_NVRAM_SIZE );/* No PCI init: the BIOS will do it */ - dev =qdev_new (TYPE_FW_CFG_MEM ); + dev =qdev_new_orphan (TYPE_FW_CFG_MEM ); fw_cfg =FW_CFG (dev);qdev_prop_set_uint32 (dev,"data_width" ,1 );qdev_prop_set_bit (dev,"dma_enabled" , false);
hw/ppc/mac_oldworld.c +4 -4
@@ -212,7 +212,7 @@ static void ppc_heathrow_init(MachineState *machine) }/* Grackle PCI host bridge */ - grackle_dev =qdev_new (TYPE_GRACKLE_PCI_HOST_BRIDGE ); + grackle_dev =qdev_new_orphan (TYPE_GRACKLE_PCI_HOST_BRIDGE );qdev_prop_set_uint32 (grackle_dev,"ofw-addr" ,0x80000000 ); s =SYS_BUS_DEVICE (grackle_dev);sysbus_realize_and_unref (s, &error_fatal);
@@ -279,9 +279,9 @@ static void ppc_heathrow_init(MachineState *machine)/* MacIO CUDA/ADB */ dev =DEVICE (object_resolve_path_component (macio,"cuda" )); adb_bus =qdev_get_child_bus (dev,"adb.0" ); - dev =qdev_new (TYPE_ADB_KEYBOARD ); + dev =qdev_new_orphan (TYPE_ADB_KEYBOARD );qdev_realize_and_unref (dev, adb_bus, &error_fatal); - dev =qdev_new (TYPE_ADB_MOUSE ); + dev =qdev_new_orphan (TYPE_ADB_MOUSE );qdev_realize_and_unref (dev, adb_bus, &error_fatal);if (machine_usb (machine)) {
@@ -303,7 +303,7 @@ static void ppc_heathrow_init(MachineState *machine)/* No PCI init: the BIOS will do it */ - dev =qdev_new (TYPE_FW_CFG_MEM ); + dev =qdev_new_orphan (TYPE_FW_CFG_MEM ); fw_cfg =FW_CFG (dev);qdev_prop_set_uint32 (dev,"data_width" ,1 );qdev_prop_set_bit (dev,"dma_enabled" , false);
hw/ppc/pnv.c +2 -2
@@ -1127,7 +1127,7 @@ static void pnv_init(MachineState *machine)/* * Create our simple PNOR device */ - dev =qdev_new (TYPE_PNV_PNOR ); + dev =qdev_new_orphan (TYPE_PNV_PNOR ); pnor =drive_get (IF_MTD ,0 ,0 );if (!pnor &&defaults_enabled ()) { fw_filename =qemu_find_file (QEMU_FILE_TYPE_BIOS ,PNOR_FILE_NAME );
@@ -1269,7 +1269,7 @@ static void pnv_init(MachineState *machine) pnv->chips = g_new0(PnvChip *, pnv->num_chips);for (i =0 ; i < pnv->num_chips; i++) {char chip_name[32 ]; -Object *chip =OBJECT (qdev_new (chip_typename)); +Object *chip =OBJECT (qdev_new_orphan (chip_typename));uint64_t chip_ram_size =pnv_chip_get_ram_size (pnv, i); pnv->chips[i] =PNV_CHIP (chip);
hw/ppc/pnv_bmc.c +1 -1
@@ -299,7 +299,7 @@ IPMIBmc *pnv_bmc_create(PnvPnor *pnor) {DeviceState *dev; - dev =qdev_new (TYPE_IPMI_BMC_SIMULATOR ); + dev =qdev_new_orphan (TYPE_IPMI_BMC_SIMULATOR );qdev_realize (dev,NULL , &error_fatal);pnv_bmc_set_pnor (IPMI_BMC (dev), pnor);
hw/ppc/ppc440_bamboo.c +2 -2
@@ -162,7 +162,7 @@ static void bamboo_init(MachineState *machine)ppc_dcr_init (env,NULL ,NULL );/* interrupt controller */ - uicdev =qdev_new (TYPE_PPC_UIC ); + uicdev =qdev_new_orphan (TYPE_PPC_UIC );ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (uicdev), cpu, &error_fatal);object_unref (OBJECT (uicdev)); uicsbd =SYS_BUS_DEVICE (uicdev);
@@ -172,7 +172,7 @@ static void bamboo_init(MachineState *machine) qdev_get_gpio_in(DEVICE(cpu), PPC40x_INPUT_CINT));/* SDRAM controller */ - dev =qdev_new (TYPE_PPC4xx_SDRAM_DDR); + dev =qdev_new_orphan (TYPE_PPC4xx_SDRAM_DDR);object_property_set_link (OBJECT (dev),"dram" ,OBJECT (machine->ram), &error_abort);ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (dev), cpu, &error_fatal);
hw/ppc/prep.c +2 -2
@@ -289,7 +289,7 @@ static void ibm_40p_init(MachineState *machine)g_free (filename);/* PCI host */ - dev =qdev_new ("raven-pcihost" ); + dev =qdev_new_orphan ("raven-pcihost" ); pcihost =SYS_BUS_DEVICE (dev);object_property_add_child (qdev_get_machine (),"raven" ,OBJECT (dev));sysbus_realize_and_unref (pcihost, &error_fatal);
@@ -363,7 +363,7 @@ static void ibm_40p_init(MachineState *machine) }/* Prepare firmware configuration for OpenBIOS */ - dev =qdev_new (TYPE_FW_CFG_MEM ); + dev =qdev_new_orphan (TYPE_FW_CFG_MEM ); fw_cfg =FW_CFG (dev);qdev_prop_set_uint32 (dev,"data_width" ,1 );qdev_prop_set_bit (dev,"dma_enabled" , false);
hw/ppc/sam460ex.c +8 -8
@@ -275,7 +275,7 @@ static void sam460ex_init(MachineState *machine)ppc_dcr_init (env,NULL ,NULL );/* PLB arbitrer */ - dev =qdev_new (TYPE_PPC4xx_PLB); + dev =qdev_new_orphan (TYPE_PPC4xx_PLB);ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (dev), cpu, &error_fatal);object_unref (OBJECT (dev));
@@ -291,7 +291,7 @@ static void sam460ex_init(MachineState *machine)*/ const int input_ints[] = {-1 ,30 ,10 ,16 }; - uic[i] =qdev_new (TYPE_PPC_UIC ); + uic[i] =qdev_new_orphan (TYPE_PPC_UIC );qdev_prop_set_uint32 (uic[i],"dcr-base" ,0xc0 + i *0x10 );ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (uic[i]), cpu, &error_fatal);object_unref (OBJECT (uic[i]));
@@ -321,7 +321,7 @@ static void sam460ex_init(MachineState *machine)error_report ("Memory below 64 MiB is not supported" );exit (1 ); } - dev =qdev_new (TYPE_PPC4xx_SDRAM_DDR2); + dev =qdev_new_orphan (TYPE_PPC4xx_SDRAM_DDR2);object_property_set_link (OBJECT (dev),"dram" ,OBJECT (machine->ram), &error_abort);/*
@@ -351,7 +351,7 @@ static void sam460ex_init(MachineState *machine) qdev_get_gpio_in(uic[0], 3));/* External bus controller */ - dev =qdev_new (TYPE_PPC4xx_EBC); + dev =qdev_new_orphan (TYPE_PPC4xx_EBC);ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (dev), cpu, &error_fatal);object_unref (OBJECT (dev));
@@ -365,7 +365,7 @@ static void sam460ex_init(MachineState *machine)ppc4xx_sdr_init (env);/* MAL */ - dev =qdev_new (TYPE_PPC4xx_MAL); + dev =qdev_new_orphan (TYPE_PPC4xx_MAL);qdev_prop_set_uint8 (dev,"txc-num" ,4 );qdev_prop_set_uint8 (dev,"rxc-num" ,16 );ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (dev), cpu, &error_fatal);
@@ -389,7 +389,7 @@ static void sam460ex_init(MachineState *machine)/* USB */ sysbus_create_simple (TYPE_PPC4xx_EHCI,0x4bffd0400 ,qdev_get_gpio_in (uic[2 ],29 )); - dev =qdev_new ("sysbus-ohci" ); + dev =qdev_new_orphan ("sysbus-ohci" );qdev_prop_set_string (dev,"masterbus" ,"usb-bus.0" );qdev_prop_set_uint32 (dev,"num-ports" ,6 ); sbdev =SYS_BUS_DEVICE (dev);
@@ -402,13 +402,13 @@ static void sam460ex_init(MachineState *machine)usb_create_simple (usb_bus,"usb-mouse" );/* PCIe buses */ - dev =qdev_new (TYPE_PPC460EX_PCIE_HOST ); + dev =qdev_new_orphan (TYPE_PPC460EX_PCIE_HOST );qdev_prop_set_int32 (dev,"busnum" ,0 );qdev_prop_set_int32 (dev,"dcrn-base" ,PCIE0_DCRN_BASE );object_property_set_link (OBJECT (dev),"cpu" ,OBJECT (cpu), &error_abort);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); - dev =qdev_new (TYPE_PPC460EX_PCIE_HOST ); + dev =qdev_new_orphan (TYPE_PPC460EX_PCIE_HOST );qdev_prop_set_int32 (dev,"busnum" ,1 );qdev_prop_set_int32 (dev,"dcrn-base" ,PCIE1_DCRN_BASE );object_property_set_link (OBJECT (dev),"cpu" ,OBJECT (cpu), &error_abort);
hw/ppc/spapr.c +2 -2
@@ -1885,7 +1885,7 @@ static void spapr_machine_reset(MachineState *machine, ResetType type)static void spapr_create_nvram (SpaprMachineState *spapr) { -DeviceState *dev =qdev_new ("spapr-nvram" ); +DeviceState *dev =qdev_new_orphan ("spapr-nvram" );DriveInfo *dinfo =drive_get (IF_PFLASH ,0 ,0 );if (dinfo) {
@@ -2799,7 +2799,7 @@ static PCIHostState *spapr_create_default_phb(void) {DeviceState *dev; - dev =qdev_new (TYPE_SPAPR_PCI_HOST_BRIDGE ); + dev =qdev_new_orphan (TYPE_SPAPR_PCI_HOST_BRIDGE );qdev_prop_set_uint32 (dev,"index" ,0 );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/ppc/spapr_irq.c +1 -1
@@ -312,7 +312,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp)DeviceState *dev;int i; - dev =qdev_new (TYPE_SPAPR_XIVE ); + dev =qdev_new_orphan (TYPE_SPAPR_XIVE );qdev_prop_set_uint32 (dev,"nr-irqs" ,SPAPR_NR_XIRQS +SPAPR_IRQ_NR_IPIS );/* * 8 XIVE END structures per CPU. One for each available
hw/ppc/spapr_vio.c +1 -1
@@ -564,7 +564,7 @@ SpaprVioBus *spapr_vio_bus_init(void)DeviceState *dev;/* Create bridge device */ - dev =qdev_new (TYPE_SPAPR_VIO_BRIDGE ); + dev =qdev_new_orphan (TYPE_SPAPR_VIO_BRIDGE );/* Create bus on bridge device */ qbus =qbus_new (TYPE_SPAPR_VIO_BUS , dev,"spapr-vio" );
hw/ppc/virtex_ml507.c +3 -3
@@ -84,7 +84,7 @@ static PowerPCCPU *ppc440_init_xilinx(const char *cpu_type, uint32_t sysclk)ppc_dcr_init (env,NULL ,NULL );/* interrupt controller */ - uicdev =qdev_new (TYPE_PPC_UIC ); + uicdev =qdev_new_orphan (TYPE_PPC_UIC );ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (uicdev), cpu, &error_fatal);object_unref (OBJECT (uicdev)); uicsbd =SYS_BUS_DEVICE (uicdev);
@@ -218,7 +218,7 @@ static void virtex_init(MachineState *machine) 64 * KiB, 1, 0x89, 0x18, 0x0000, 0x0, 1); cpu_irq =qdev_get_gpio_in (DEVICE (cpu), PPC40x_INPUT_INT); - dev =qdev_new ("xlnx.xps-intc" ); + dev =qdev_new_orphan ("xlnx.xps-intc" );qdev_prop_set_enum (dev,"endianness" ,ENDIAN_MODE_BIG );qdev_prop_set_uint32 (dev,"kind-of-intr" ,0 );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -232,7 +232,7 @@ static void virtex_init(MachineState *machine) 115200, serial_hd(0), DEVICE_LITTLE_ENDIAN);/* 2 timers at irq 2 @ 62 Mhz. */ - dev =qdev_new ("xlnx.xps-timer" ); + dev =qdev_new_orphan ("xlnx.xps-timer" );qdev_prop_set_enum (dev,"endianness" ,ENDIAN_MODE_BIG );qdev_prop_set_uint32 (dev,"one-timer-only" ,0 );qdev_prop_set_uint32 (dev,"clock-frequency" ,62 *1000000 );
hw/remote/machine.c +1 -1
@@ -39,7 +39,7 @@ static void remote_machine_init(MachineState *machine) pci_memory =g_new (MemoryRegion,1 );memory_region_init (pci_memory,NULL ,"pci" ,UINT64_MAX ); - rem_host =REMOTE_PCIHOST (qdev_new (TYPE_REMOTE_PCIHOST )); + rem_host =REMOTE_PCIHOST (qdev_new_orphan (TYPE_REMOTE_PCIHOST )); rem_host->mr_pci_mem = pci_memory; rem_host->mr_sys_mem = system_memory;
hw/riscv/boston-aia.c +2 -2
@@ -305,7 +305,7 @@ xilinx_pcie_init(MemoryRegion *sys_mem, uint32_t bus_nr,DeviceState *dev;MemoryRegion *cfg, *mmio; - dev =qdev_new (TYPE_XILINX_PCIE_HOST ); + dev =qdev_new_orphan (TYPE_XILINX_PCIE_HOST );qdev_prop_set_uint32 (dev,"bus_nr" , bus_nr);qdev_prop_set_uint64 (dev,"cfg_base" , cfg_base);
@@ -352,7 +352,7 @@ static void boston_mach_init(MachineState *machine)exit (1 ); } - dev =qdev_new (TYPE_MIPS_BOSTON_AIA ); + dev =qdev_new_orphan (TYPE_MIPS_BOSTON_AIA );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); s =BOSTON (dev);
hw/riscv/microblaze-v-generic.c +7 -7
@@ -79,7 +79,7 @@ static void mb_v_generic_init(MachineState *machine) ram_size, &error_fatal);memory_region_add_subregion (sysmem, ddr_base, phys_ram); - dev =qdev_new ("xlnx.xps-intc" ); + dev =qdev_new_orphan ("xlnx.xps-intc" );qdev_prop_set_enum (dev,"endianness" ,ENDIAN_MODE_LITTLE );qdev_prop_set_uint32 (dev,"kind-of-intr" ,1 <<UARTLITE_IRQ );
@@ -92,7 +92,7 @@ static void mb_v_generic_init(MachineState *machine) }/* Uartlite */ - dev =qdev_new (TYPE_XILINX_UARTLITE ); + dev =qdev_new_orphan (TYPE_XILINX_UARTLITE );qdev_prop_set_enum (dev,"endianness" ,ENDIAN_MODE_LITTLE );qdev_prop_set_chr (dev,"chardev" ,serial_hd (0 ));sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -105,7 +105,7 @@ static void mb_v_generic_init(MachineState *machine) DEVICE_LITTLE_ENDIAN);/* 2 timers at irq 0 @ 100 Mhz. */ - dev =qdev_new ("xlnx.xps-timer" ); + dev =qdev_new_orphan ("xlnx.xps-timer" );qdev_prop_set_enum (dev,"endianness" ,ENDIAN_MODE_LITTLE );qdev_prop_set_uint32 (dev,"one-timer-only" ,0 );qdev_prop_set_uint32 (dev,"clock-frequency" ,100000000 );
@@ -114,7 +114,7 @@ static void mb_v_generic_init(MachineState *machine)sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , irq[TIMER_IRQ ]);/* 2 timers at irq 3 @ 100 Mhz. */ - dev =qdev_new ("xlnx.xps-timer" ); + dev =qdev_new_orphan ("xlnx.xps-timer" );qdev_prop_set_enum (dev,"endianness" ,ENDIAN_MODE_LITTLE );qdev_prop_set_uint32 (dev,"one-timer-only" ,0 );qdev_prop_set_uint32 (dev,"clock-frequency" ,100000000 );
@@ -123,7 +123,7 @@ static void mb_v_generic_init(MachineState *machine)sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , irq[TIMER_IRQ2 ]);/* Emaclite */ - dev =qdev_new ("xlnx.xps-ethernetlite" ); + dev =qdev_new_orphan ("xlnx.xps-ethernetlite" );qdev_prop_set_enum (dev,"endianness" ,ENDIAN_MODE_LITTLE );qemu_configure_nic_device (dev, true,NULL );qdev_prop_set_uint32 (dev,"tx-ping-pong" ,0 );
@@ -133,8 +133,8 @@ static void mb_v_generic_init(MachineState *machine)sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , irq[ETHLITE_IRQ ]);/* axi ethernet and dma initialization. */ - eth0 =qdev_new ("xlnx.axi-ethernet" ); - dma =qdev_new ("xlnx.axi-dma" ); + eth0 =qdev_new_orphan ("xlnx.axi-ethernet" ); + dma =qdev_new_orphan ("xlnx.axi-dma" );/* FIXME: attach to the sysbus instead */ object_property_add_child (qdev_get_machine (),"xilinx-eth" ,OBJECT (eth0));
hw/riscv/microchip_pfsoc.c +1 -1
@@ -580,7 +580,7 @@ static void microchip_icicle_kit_machine_init(MachineState *machine)/* Attach an SD card */ if (dinfo) {CadenceSDHCIState *sdhci = &(s->soc.sdhci); -DeviceState *card =qdev_new (TYPE_SD_CARD ); +DeviceState *card =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (card,"drive" ,blk_by_legacy_dinfo (dinfo), &error_fatal);
hw/riscv/sifive_u.c +2 -2
@@ -593,7 +593,7 @@ static void sifive_u_machine_init(MachineState *machine) sizeof(reset_vec), kernel_entry);/* Connect an SPI flash to SPI0 */ - flash_dev =qdev_new ("is25wp256" ); + flash_dev =qdev_new_orphan ("is25wp256" ); dinfo =drive_get (IF_MTD ,0 ,0 );if (dinfo) { qdev_prop_set_drive_err(flash_dev, "drive",
@@ -613,7 +613,7 @@ static void sifive_u_machine_init(MachineState *machine) dinfo =drive_get (IF_SD ,0 ,0 ); blk = dinfo ?blk_by_legacy_dinfo (dinfo) :NULL ; - card_dev =qdev_new (TYPE_SD_CARD_SPI ); + card_dev =qdev_new_orphan (TYPE_SD_CARD_SPI );qdev_prop_set_drive_err (card_dev,"drive" , blk, &error_fatal); qdev_realize_and_unref(card_dev, qdev_get_child_bus(sd_dev, "sd-bus"),
hw/riscv/virt.c +4 -4
@@ -126,7 +126,7 @@ static PFlashCFI01 *virt_flash_create1(RISCVVirtState *s,* Create a single flash device. We use the same parameters as * the flash devices on the ARM virt board. */ -DeviceState *dev =qdev_new (TYPE_PFLASH_CFI01 ); +DeviceState *dev =qdev_new_orphan (TYPE_PFLASH_CFI01 );qdev_prop_set_uint64 (dev,"sector-length" ,VIRT_FLASH_SECTOR_SIZE );qdev_prop_set_uint8 (dev,"width" ,4 );
@@ -1051,7 +1051,7 @@ static inline DeviceState *gpex_pcie_init(MemoryRegion *sys_mem,qemu_irq irq;int i; - dev =qdev_new (TYPE_GPEX_HOST ); + dev =qdev_new_orphan (TYPE_GPEX_HOST );/* Set GPEX object properties for the virt machine */ object_property_set_uint(OBJECT(dev), PCI_HOST_ECAM_BASE,
@@ -1143,7 +1143,7 @@ static void create_platform_bus(RISCVVirtState *s, DeviceState *irqchip)int i;MemoryRegion *sysmem =get_system_memory (); - dev =qdev_new (TYPE_PLATFORM_BUS_DEVICE ); + dev =qdev_new_orphan (TYPE_PLATFORM_BUS_DEVICE ); dev->id =g_strdup (TYPE_PLATFORM_BUS_DEVICE );qdev_prop_set_uint32 (dev,"num_irqs" ,VIRT_PLATFORM_BUS_NUM_IRQS );qdev_prop_set_uint32 (dev,"mmio_size" , s->memmap[VIRT_PLATFORM_BUS ].size);
@@ -1509,7 +1509,7 @@ static void virt_machine_init(MachineState *machine) }if (virt_is_iommu_sys_enabled (s)) { -DeviceState *iommu_sys =qdev_new (TYPE_RISCV_IOMMU_SYS ); +DeviceState *iommu_sys =qdev_new_orphan (TYPE_RISCV_IOMMU_SYS ); object_property_set_uint(OBJECT(iommu_sys), "addr", s->memmap[VIRT_IOMMU_SYS].base,
hw/rtc/sun4v-rtc.c +1 -1
@@ -57,7 +57,7 @@ void sun4v_rtc_init(hwaddr addr)DeviceState *dev;SysBusDevice *s; - dev =qdev_new (TYPE_SUN4V_RTC ); + dev =qdev_new_orphan (TYPE_SUN4V_RTC ); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);
hw/s390x/ap-bridge.c +1 -1
@@ -49,7 +49,7 @@ void s390_init_ap(void) }/* Create bridge device */ - dev =qdev_new (TYPE_AP_BRIDGE ); + dev =qdev_new_orphan (TYPE_AP_BRIDGE );object_property_add_child (qdev_get_machine (),TYPE_AP_BRIDGE ,OBJECT (dev));sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/s390x/css-bridge.c +1 -1
@@ -92,7 +92,7 @@ VirtualCssBus *virtual_css_bus_init(void)DeviceState *dev;/* Create bridge device */ - dev =qdev_new (TYPE_VIRTUAL_CSS_BRIDGE ); + dev =qdev_new_orphan (TYPE_VIRTUAL_CSS_BRIDGE );object_property_add_child (qdev_get_machine (),TYPE_VIRTUAL_CSS_BRIDGE ,OBJECT (dev));
hw/s390x/s390-pci-bus.c +1 -1
@@ -967,7 +967,7 @@ static S390PCIBusDevice *s390_pci_device_new(S390pciState *s,Error *local_err =NULL ;DeviceState *dev; - dev =qdev_try_new (TYPE_S390_PCI_DEVICE ); + dev =qdev_try_new_orphan (TYPE_S390_PCI_DEVICE );if (!dev) {error_setg (errp,"zPCI device could not be created" );return NULL ;
hw/s390x/s390-virtio-ccw.c +3 -3
@@ -253,7 +253,7 @@ static void s390_create_sclpconsole(SCLPDevice *sclp,BusState *ev_fac_bus =sclp_get_event_facility_bus (ef);DeviceState *dev; - dev =qdev_new (type); + dev =qdev_new_orphan (type);object_property_add_child (OBJECT (ef), type,OBJECT (dev));qdev_prop_set_chr (dev,"chardev" , chardev);qdev_realize_and_unref (dev, ev_fac_bus, &error_fatal);
@@ -265,7 +265,7 @@ static void s390_create_sclpcpi(SCLPDevice *sclp)BusState *ev_fac_bus =sclp_get_event_facility_bus (ef);DeviceState *dev; - dev =qdev_new (TYPE_SCLP_EVENT_CPI ); + dev =qdev_new_orphan (TYPE_SCLP_EVENT_CPI );object_property_add_child (OBJECT (ef),"sclpcpi" ,OBJECT (dev));qdev_realize_and_unref (dev, ev_fac_bus, &error_fatal); }
@@ -309,7 +309,7 @@ static void ccw_init(MachineState *machine) machine->firmware ?:"s390-ccw.img" , true); - dev =qdev_new (TYPE_S390_PCI_HOST_BRIDGE ); + dev =qdev_new_orphan (TYPE_S390_PCI_HOST_BRIDGE );object_property_add_child (qdev_get_machine (),TYPE_S390_PCI_HOST_BRIDGE ,OBJECT (dev));sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/scsi/lasi_ncr710.c +1 -1
@@ -231,7 +231,7 @@ DeviceState *lasi_ncr710_init(MemoryRegion *addr_space, hwaddr hpa,LasiNCR710State *s;SysBusDevice *sbd; - dev =qdev_new (TYPE_LASI_NCR710 ); + dev =qdev_new_orphan (TYPE_LASI_NCR710 ); s =LASI_NCR710 (dev); sbd =SYS_BUS_DEVICE (dev); s->lasi_irq = irq;
hw/scsi/ncr53c710.c +2 -2
@@ -2376,7 +2376,7 @@ DeviceState *ncr710_device_create_sysbus(hwaddr addr, qemu_irq irq)DeviceState *dev;SysBusDevice *sysbus; - dev =qdev_new (TYPE_SYSBUS_NCR710_SCSI ); + dev =qdev_new_orphan (TYPE_SYSBUS_NCR710_SCSI ); sysbus =SYS_BUS_DEVICE (dev);qdev_realize_and_unref (dev,NULL , &error_abort);
@@ -2394,7 +2394,7 @@ DeviceState *ncr53c710_init(MemoryRegion *address_space, hwaddr addr,/* trace_ncr710_device_init(addr); */ - dev =qdev_new (TYPE_SYSBUS_NCR710_SCSI ); + dev =qdev_new_orphan (TYPE_SYSBUS_NCR710_SCSI ); sysbus =SYS_BUS_DEVICE (dev);qdev_realize_and_unref (dev,NULL , &error_abort);
hw/scsi/scsi-bus.c +1 -1
@@ -445,7 +445,7 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk, driver ="scsi-hd" ; } } - dev =qdev_new (driver); + dev =qdev_new_orphan (driver); name =g_strdup_printf ("legacy[%d]" , unit);object_property_add_child (OBJECT (bus), name,OBJECT (dev));g_free (name);
hw/scsi/spapr_vscsi.c +1 -1
@@ -1235,7 +1235,7 @@ void spapr_vscsi_create(SpaprVioBus *bus) {DeviceState *dev; - dev =qdev_new ("spapr-vscsi" ); + dev =qdev_new_orphan ("spapr-vscsi" );qdev_realize_and_unref (dev, &bus->bus, &error_fatal);scsi_bus_legacy_handle_cmdline (&VIO_SPAPR_VSCSI_DEVICE (dev)->bus);
hw/sh4/r2d.c +3 -3
@@ -266,7 +266,7 @@ static void r2d_init(MachineState *machine) s =sh7750_init (cpu, address_space_mem); fpga =r2d_fpga_init (address_space_mem,0x04000000 ,sh7750_irl (s)); - dev =qdev_new ("sh_pci" ); + dev =qdev_new_orphan ("sh_pci" ); busdev =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (busdev, &error_fatal); pci_bus =PCI_BUS (qdev_get_child_bus (dev,"pci" ));
@@ -277,7 +277,7 @@ static void r2d_init(MachineState *machine)sysbus_connect_irq (busdev,2 , &fpga->irq[PCI_INTC ]);sysbus_connect_irq (busdev,3 , &fpga->irq[PCI_INTD ]); - dev =qdev_new ("sysbus-sm501" ); + dev =qdev_new_orphan ("sysbus-sm501" ); busdev =SYS_BUS_DEVICE (dev);qdev_prop_set_uint32 (dev,"vram-size" ,SM501_VRAM_SIZE );qdev_prop_set_uint64 (dev,"dma-offset" ,0x10000000 );
@@ -289,7 +289,7 @@ static void r2d_init(MachineState *machine)/* onboard CF (True IDE mode, Master only). */ dinfo =drive_get (IF_IDE ,0 ,0 ); - dev =qdev_new ("mmio-ide" ); + dev =qdev_new_orphan ("mmio-ide" ); busdev =SYS_BUS_DEVICE (dev);sysbus_connect_irq (busdev,0 , &fpga->irq[CF_IDE ]);qdev_prop_set_uint32 (dev,"shift" ,1 );
hw/sh4/sh7750.c +2 -2
@@ -762,7 +762,7 @@ SH7750State *sh7750_init(SuperHCPU *cpu, MemoryRegion *sysmem) cpu->env.intc_handle = &s->intc;/* SCI */ - dev =qdev_new (TYPE_SH_SERIAL ); + dev =qdev_new_orphan (TYPE_SH_SERIAL ); dev->id =g_strdup ("sci" );qdev_prop_set_chr (dev,"chardev" ,serial_hd (0 )); sb =SYS_BUS_DEVICE (dev);
@@ -779,7 +779,7 @@ SH7750State *sh7750_init(SuperHCPU *cpu, MemoryRegion *sysmem)qdev_connect_gpio_out_named (dev,"tei" ,0 , s->intc.irqs[SCI1_TEI ]);/* SCIF */ - dev =qdev_new (TYPE_SH_SERIAL ); + dev =qdev_new_orphan (TYPE_SH_SERIAL ); dev->id =g_strdup ("scif" );qdev_prop_set_chr (dev,"chardev" ,serial_hd (1 ));qdev_prop_set_uint8 (dev,"features" ,SH_SERIAL_FEAT_SCIF );
hw/sparc/leon3.c +5 -5
@@ -292,14 +292,14 @@ static void leon3_generic_hw_init(MachineState *machine)qemu_register_reset (leon3_cpu_reset, &reset_info->info[i]); } - ahb_pnp =GRLIB_AHB_PNP (qdev_new (TYPE_GRLIB_AHB_PNP )); + ahb_pnp =GRLIB_AHB_PNP (qdev_new_orphan (TYPE_GRLIB_AHB_PNP ));sysbus_realize_and_unref (SYS_BUS_DEVICE (ahb_pnp), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (ahb_pnp),0 ,LEON3_AHB_PNP_OFFSET );grlib_ahb_pnp_add_entry (ahb_pnp,0 ,0 ,GRLIB_VENDOR_GAISLER ,GRLIB_LEON3_DEV ,GRLIB_AHB_MASTER ,GRLIB_CPU_AREA ); - apb_pnp =GRLIB_APB_PNP (qdev_new (TYPE_GRLIB_APB_PNP )); + apb_pnp =GRLIB_APB_PNP (qdev_new_orphan (TYPE_GRLIB_APB_PNP ));sysbus_realize_and_unref (SYS_BUS_DEVICE (apb_pnp), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (apb_pnp),0 ,LEON3_APB_PNP_OFFSET ); grlib_ahb_pnp_add_entry(ahb_pnp, LEON3_APB_PNP_OFFSET, 0xFFF,
@@ -307,7 +307,7 @@ static void leon3_generic_hw_init(MachineState *machine) GRLIB_AHB_SLAVE, GRLIB_AHBMEM_AREA);/* Allocate IRQ manager */ - irqmpdev =qdev_new (TYPE_GRLIB_IRQMP ); + irqmpdev =qdev_new_orphan (TYPE_GRLIB_IRQMP );object_property_set_int (OBJECT (irqmpdev),"ncpus" , machine->smp.cpus, &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (irqmpdev), &error_fatal);
@@ -406,7 +406,7 @@ static void leon3_generic_hw_init(MachineState *machine) }/* Allocate timers */ - dev =qdev_new (TYPE_GRLIB_GPTIMER ); + dev =qdev_new_orphan (TYPE_GRLIB_GPTIMER );qdev_prop_set_uint32 (dev,"nr-timers" ,LEON3_TIMER_COUNT );qdev_prop_set_uint32 (dev,"frequency" ,CPU_CLK );qdev_prop_set_uint32 (dev,"irq-line" ,LEON3_TIMER_IRQ );
@@ -423,7 +423,7 @@ static void leon3_generic_hw_init(MachineState *machine) 0, LEON3_TIMER_IRQ, GRLIB_APBIO_AREA);/* Allocate uart */ - dev =qdev_new (TYPE_GRLIB_APB_UART ); + dev =qdev_new_orphan (TYPE_GRLIB_APB_UART );qdev_prop_set_chr (dev,"chrdev" ,serial_hd (0 ));sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,LEON3_UART_OFFSET );
hw/sparc/sun4m.c +19 -19
@@ -280,7 +280,7 @@ static void *iommu_init(hwaddr addr, uint32_t version, qemu_irq irq)DeviceState *dev;SysBusDevice *s; - dev =qdev_new (TYPE_SUN4M_IOMMU ); + dev =qdev_new_orphan (TYPE_SUN4M_IOMMU );qdev_prop_set_uint32 (dev,"version" , version); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);
@@ -302,7 +302,7 @@ static void *sparc32_dma_init(hwaddr dma_base,SysBusPCNetState *lance;NICInfo *nd =qemu_find_nic_info ("lance" , true,NULL ); - dma =qdev_new (TYPE_SPARC32_DMA ); + dma =qdev_new_orphan (TYPE_SPARC32_DMA ); espdma =SPARC32_ESPDMA_DEVICE (object_resolve_path_component (OBJECT (dma),"espdma" ));
@@ -347,7 +347,7 @@ static DeviceState *slavio_intctl_init(hwaddr addr,SysBusDevice *s;unsigned int i, j; - dev =qdev_new ("slavio_intctl" ); + dev =qdev_new_orphan ("slavio_intctl" ); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);
@@ -376,7 +376,7 @@ static void slavio_timer_init_all(hwaddr addr, qemu_irq master_irq,SysBusDevice *s;unsigned int i; - dev =qdev_new ("slavio_timer" ); + dev =qdev_new_orphan ("slavio_timer" );qdev_prop_set_uint32 (dev,"num_cpus" , num_cpus); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);
@@ -414,7 +414,7 @@ static void slavio_misc_init(hwaddr base,DeviceState *dev;SysBusDevice *s; - dev =qdev_new ("slavio_misc" ); + dev =qdev_new_orphan ("slavio_misc" ); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);if (base) {
@@ -451,7 +451,7 @@ static void ecc_init(hwaddr base, qemu_irq irq, uint32_t version)DeviceState *dev;SysBusDevice *s; - dev =qdev_new ("eccmemctl" ); + dev =qdev_new_orphan ("eccmemctl" );qdev_prop_set_uint32 (dev,"version" , version); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);
@@ -467,7 +467,7 @@ static void apc_init(hwaddr power_base, qemu_irq cpu_halt)DeviceState *dev;SysBusDevice *s; - dev =qdev_new ("apc" ); + dev =qdev_new_orphan ("apc" ); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);/* Power management (APC) XXX: not a Slavio device */
@@ -481,7 +481,7 @@ static void tcx_init(hwaddr addr, qemu_irq irq, int vram_size, int width,DeviceState *dev;SysBusDevice *s; - dev =qdev_new ("sun-tcx" ); + dev =qdev_new_orphan ("sun-tcx" );
Lines of this file are not shown. View the raw message.
scripts/coccinelle/qom-parent/qdev-new-orphan.cocci new file +18 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.47.1
Part of the diff is not shown here. View the raw message.
Re: [RFC PATCH 002/134] qdev: Rename qdev_new()/qdev_try_new() to *_orphan()
Quoted 198 lines · Alexander Graf
qdev_new()creates a device on the heap without a QOM parent. If the caller does not add one before realize,device_set_realized()dumps the device into /machine/unattached with an unstable canonical path.We want the short spelling
qdev_new()to be the one that gets parenting right by construction. As a first step, rename the current functions toqdev_new_orphan()andqdev_try_new_orphan()tree-wide so that a subsequent commit can reintroduceqdev_new()with a mandatory (parent, id, type) signature.Purely mechanical, generated by
spatch --sp-file
scripts/coccinelle/qom-parent/qdev-new-orphan.cocci\
--in-place --include-headers --dir .or equivalently
git ls-files '*.[ch]' '*.[ch].inc' '*.rst' '*.py' | \ grep -v '^subprojects/' | \ xargs sed -i 's/\bqdev_try_new\b/qdev_try_new_orphan/g; s/\bqdev_new\b/qdev_new_orphan/g'No functional change.
Assisted-by KiroSigned-off-by Alexander Graf <[email protected]>--- hw/alpha/typhoon.c | 2 +- hw/arm/aspeed.c | 2 +- hw/arm/aspeed_soc_common.c | 4 +- hw/arm/bananapi_m2u.c | 2 +- hw/arm/cubieboard.c | 2 +- hw/arm/exynos4210.c | 12 ++-- hw/arm/imx25_pdk.c | 2 +- hw/arm/imx8mm-evk.c | 2 +- hw/arm/imx8mp-evk.c | 2 +- hw/arm/integratorcp.c | 8 +-- hw/arm/max78000fthr.c | 2 +- hw/arm/mcimx6ul-evk.c | 2 +- hw/arm/mcimx7d-sabre.c | 2 +- hw/arm/mps2-tz.c | 4 +- hw/arm/mps2.c | 4 +- hw/arm/msf2-som.c | 4 +- hw/arm/musicpal.c | 6 +- hw/arm/netduino2.c | 2 +- hw/arm/netduinoplus2.c | 2 +- hw/arm/npcm7xx_boards.c | 4 +- hw/arm/npcm8xx_boards.c | 2 +- hw/arm/olimex-stm32-h405.c | 2 +- hw/arm/omap1.c | 12 ++-- hw/arm/orangepi.c | 2 +- hw/arm/raspi.c | 2 +- hw/arm/realview.c | 18 ++--- hw/arm/sabrelite.c | 2 +- hw/arm/sbsa-ref.c | 20 +++--- hw/arm/stellaris.c | 20 +++--- hw/arm/stm32vldiscovery.c | 2 +- hw/arm/strongarm.c | 4 +- hw/arm/versatilepb.c | 14 ++-- hw/arm/vexpress.c | 14 ++-- hw/arm/virt.c | 24 +++---- hw/arm/xilinx_zynq.c | 26 +++---- hw/arm/xlnx-versal-virt.c | 2 +- hw/arm/xlnx-versal.c | 70 +++++++++---------- hw/arm/xlnx-zcu102.c | 6 +- hw/arm/xlnx-zynqmp.c | 2 +- hw/audio/intel-hda.c | 2 +- hw/audio/model.c | 2 +- hw/avr/atmega.c | 2 +- hw/block/fdc-sysbus.c | 4 +- hw/block/fdc.c | 2 +- hw/block/pflash_cfi01.c | 2 +- hw/block/pflash_cfi02.c | 2 +- hw/block/xen-block.c | 2 +- hw/char/exynos4210_uart.c | 2 +- hw/char/mcf_uart.c | 2 +- hw/char/mchp_pfsoc_mmuart.c | 2 +- hw/char/pl011.c | 2 +- hw/char/serial-mm.c | 2 +- hw/char/sifive_uart.c | 2 +- hw/char/spapr_vty.c | 2 +- hw/char/xen_console.c | 2 +- hw/core/qdev.c | 4 +- hw/core/sysbus.c | 2 +- hw/cxl/cxl-host.c | 2 +- hw/display/sm501.c | 2 +- hw/display/xlnx_dp.c | 4 +- hw/dma/rc4030.c | 2 +- hw/hexagon/hexagon_dsp.c | 4 +- hw/hexagon/virt.c | 6 +- hw/hppa/machine.c | 12 ++-- hw/i2c/core.c | 2 +- hw/i2c/smbus_eeprom.c | 2 +- hw/i386/microvm.c | 6 +- hw/i386/nitro_enclave.c | 4 +- hw/i386/pc.c | 2 +- hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 2 +- hw/i386/pc_sysfw.c | 2 +- hw/i386/sgx.c | 2 +- hw/i386/x86-common.c | 6 +- hw/i3c/core.c | 2 +- hw/ide/ide-bus.c | 2 +- hw/intc/exynos4210_gic.c | 2 +- hw/intc/riscv_aclint.c | 4 +- hw/intc/riscv_aplic.c | 2 +- hw/intc/riscv_imsic.c | 2 +- hw/intc/s390_flic.c | 4 +- hw/intc/sifive_plic.c | 2 +- hw/isa/isa-bus.c | 6 +- hw/loongarch/virt.c | 18 ++--- hw/m68k/an5206.c | 2 +- hw/m68k/mcf_intc.c | 2 +- hw/m68k/next-cube.c | 2 +- hw/m68k/q800.c | 4 +- hw/m68k/virt.c | 10 +-- hw/mem/sparse-mem.c | 2 +- hw/microblaze/petalogix_ml605_mmu.c | 12 ++-- hw/microblaze/petalogix_s3adsp1800_mmu.c | 8 +-- hw/mips/boston.c | 4 +- hw/mips/jazz.c | 12 ++-- hw/mips/loongson3_virt.c | 6 +- hw/mips/malta.c | 4 +- hw/misc/empty_slot.c | 2 +- hw/misc/led.c | 2 +- hw/misc/sifive_e_prci.c | 2 +- hw/misc/sifive_test.c | 2 +- hw/net/lan9118.c | 2 +- hw/net/smc91c111.c | 2 +- hw/net/spapr_llan.c | 2 +- hw/net/xen_nic.c | 2 +- hw/nitro/machine.c | 4 +- hw/nitro/nitro-vsock-bus.c | 2 +- hw/nvme/ctrl.c | 2 +- hw/nvram/fw_cfg.c | 4 +- hw/or1k/or1k-sim.c | 6 +- hw/or1k/virt.c | 8 +-- hw/pci-bridge/pci_expander_bridge.c | 4 +- hw/pci-host/astro.c | 2 +- hw/pci-host/bonito.c | 2 +- hw/pci-host/pnv_phb4_pec.c | 2 +- hw/pci/pci.c | 2 +- hw/ppc/amigaone.c | 2 +- hw/ppc/e500.c | 22 +++--- hw/ppc/mac_newworld.c | 18 ++--- hw/ppc/mac_oldworld.c | 8 +-- hw/ppc/pnv.c | 4 +- hw/ppc/pnv_bmc.c | 2 +- hw/ppc/ppc440_bamboo.c | 4 +- hw/ppc/prep.c | 4 +- hw/ppc/sam460ex.c | 16 ++--- hw/ppc/spapr.c | 4 +- hw/ppc/spapr_irq.c | 2 +- hw/ppc/spapr_vio.c | 2 +- hw/ppc/virtex_ml507.c | 6 +- hw/remote/machine.c | 2 +- hw/riscv/boston-aia.c | 4 +- hw/riscv/microblaze-v-generic.c | 14 ++-- hw/riscv/microchip_pfsoc.c | 2 +- hw/riscv/sifive_u.c | 4 +- hw/riscv/virt.c | 8 +-- hw/rtc/sun4v-rtc.c | 2 +- hw/s390x/ap-bridge.c | 2 +- hw/s390x/css-bridge.c | 2 +- hw/s390x/s390-pci-bus.c | 2 +- hw/s390x/s390-virtio-ccw.c | 6 +- hw/scsi/lasi_ncr710.c | 2 +- hw/scsi/ncr53c710.c | 4 +- hw/scsi/scsi-bus.c | 2 +- hw/scsi/spapr_vscsi.c | 2 +- hw/sh4/r2d.c | 6 +- hw/sh4/sh7750.c | 4 +- hw/sparc/leon3.c | 10 +-- hw/sparc/sun4m.c | 38 +++++----- hw/sparc64/sun4u.c | 14 ++-- hw/ssi/ssi.c | 2 +- hw/tricore/tricore_testboard.c | 2 +- hw/ufs/lu.c | 2 +- hw/usb/bus.c | 4 +- hw/usb/dev-serial.c | 2 +- hw/vmapple/vmapple.c | 20 +++--- hw/xen/xen-bus.c | 2 +- hw/xen/xen-legacy-backend.c | 2 +- hw/xen/xen-pvh-common.c | 2 +- hw/xtensa/virt.c | 2 +- hw/xtensa/xtfpga.c | 2 +- include/hw/core/qdev.h | 14 ++-- include/hw/i2c/i2c.h | 2 +- include/hw/misc/unimp.h | 2 +- include/hw/ssi/ssi.h | 2 +- include/hw/usb/usb.h | 2 +- migration/migration.c | 2 +- net/net.c | 4 +- .../qom-parent/qdev-new-orphan.cocci | 18 +++++ system/qdev-monitor.c | 2 +- target/mips/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- 170 files changed, 459 insertions(+), 441 deletions(-)
Quoted 1 line
create mode 100644
scripts/coccinelle/qom-parent/qdev-new-orphan.cocci
RFC PATCH 3/134 qdev: Reintroduce qdev_new() with a mandatory QOM parent
In reply to Alexander GrafThe previous commit vacated the qdev_new()/qdev_try_new() names. Reintroduce them with the signature we actually want:
DeviceState *qdev_new(Object *parent, const char *id,
const char *type);
which is the qdev-layer, heap-allocated dual of object_initialize_child(): the returned device is created and immediately added to the QOM composition tree as a child of @parent under @id.
Refcount contract: the initial reference is transferred to the child<> property of @parent, so on return the caller does not hold a reference. Pair with qdev_realize() (not qdev_realize_and_unref()), matching object_initialize_child()'s convention.
qdev_new_orphan() remains for callers that set the parent themselves before realize (notably qdev_device_add(), which parents under /machine/peripheral via qdev_set_id()). Later patches convert the remaining orphan callers subsystem by subsystem.
--- hw/core/qdev.c | 19 +++++++++++++++++++ include/hw/core/qdev.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+)
hw/core/qdev.c +19 -0
@@ -145,6 +145,25 @@ bool qdev_set_parent_bus(DeviceState *dev, BusState *bus, Error **errp)return true; } +DeviceState *qdev_new (Object *parent,const char *id,const char *type) +{ +return DEVICE (object_new_child (parent, id, type)); +} + +DeviceState *qdev_try_new (Object *parent,const char *id,const char *type) +{ +ObjectClass *oc =module_object_class_by_name (type); +Object *obj; + +if (!oc) { +return NULL ; + } + obj =object_new_with_class (oc); +object_property_add_child (parent, id, obj); +object_unref (obj); +return DEVICE (obj); +} +DeviceState *qdev_new_orphan (const char *name) {return DEVICE (object_new (name));
include/hw/core/qdev.h +34 -0
@@ -406,6 +406,40 @@ struct BusState {/*** Board API. This should go away once we have a machine config file. ***/ +/** +* qdev_new: Create a device and parent it in the QOM composition tree +* @parent: the QOM parent (usually the machine or containing device) +* @id: child<> property name; the device's canonical QOM path becomes +* @parent's path plus "/" plus @id +* @type: device type to create (we assert() that this type exists) +* +* Heap-allocated counterpart to object_initialize_child(). This +* allocates and initializes the device state and immediately adds it +* as a child of @parent, ready for the caller to set properties and +* then realize. +* +* The reference count of the returned device is 1, held by @parent's +* child<> property. The caller therefore does not hold a reference +* and pairs this with qdev_realize() (NOT qdev_realize_and_unref()). +* +* Return: a derived DeviceState, owned by @parent. +*/ +DeviceState *qdev_new (Object *parent,const char *id,const char *type); + +/** +* qdev_try_new: Try to create a parented device on the heap +* @parent: the QOM parent +* @id: child<> property name +* @type: device type to create +* +* This is like qdev_new(), except it returns %NULL when @type does +* not exist, rather than asserting. +* +* Return: a derived DeviceState owned by @parent, or NULL if @type +* does not exist. +*/ +DeviceState *qdev_try_new (Object *parent,const char *id,const char *type); +/** * qdev_new_orphan: Create a device on the heap * @name: device type to create (we assert() that this type exists)
Signature · 1 line
2.47.1
Re: [RFC PATCH 003/134] qdev: Reintroduce qdev_new() with a mandatory QOM parent
Quoted 21 lines · Alexander Graf
The previous commit vacated the qdev_new()/qdev_try_new() names. Reintroduce them with the signature we actually want:
DeviceState *qdev_new(Object *parent, const char *id,
const char *type);which is the qdev-layer, heap-allocated dual of
object_initialize_child(): the returned device is created and immediately added to the QOM composition tree as a child of @parent under @id.Refcount contract: the initial reference is transferred to the child<> property of @parent, so on return the caller does not hold a reference. Pair with
qdev_realize()(notqdev_realize_and_unref()), matching object_initialize_child()'s convention.
qdev_new_orphan()remains for callers that set the parent themselves before realize (notablyqdev_device_add(), which parents under /machine/peripheral viaqdev_set_id()). Later patches convert the remaining orphan callers subsystem by subsystem.
Quoted 7 lines
Suggested-by Markus Armbruster <[email protected]>Assisted-by KiroSigned-off-by Alexander Graf <[email protected]>--- hw/core/qdev.c | 19 +++++++++++++++++++ include/hw/core/qdev.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+)
RFC PATCH 4/134 sysbus: Make sysbus_create_simple()/_varargs() take a QOM parent
In reply to Alexander GrafSysbus is by far the largest producer of orphaned onboard devices:
of the ~1180 unparented device creation sites in the tree, well over half go through sysbus_create_simple(), sysbus_create_varargs(), or qdev_new_orphan()+sysbus_realize_and_unref() open-coded.
Apply the same rename-and-reintroduce treatment as qdev_new():
mechanically rename the existing helpers to *_orphan() and reintroduce the short names with a leading (parent, id, ...) pair that plumbs down to the new qdev_new(). The parented versions call sysbus_realize() (not _and_unref) since the child<> property already holds the sole reference.
The mechanical rename part is generated by
spatch --sp-file \
scripts/coccinelle/qom-parent/sysbus-create-orphan.cocci \
--in-place --include-headers --dir .or equivalently
git ls-files '*.[ch]' '*.[ch].inc' '*.rst' '*.py' | \
grep -v '^subprojects/' | \
xargs sed -i \
's/\bsysbus_create_simple\b/sysbus_create_simple_orphan/g;
s/\bsysbus_create_varargs\b/sysbus_create_varargs_orphan/g'--- hw/arm/allwinner-h3.c | 16 ++++----- hw/arm/collie.c | 2 +- hw/arm/exynos4210.c | 14 ++++---- hw/arm/fsl-imx6.c | 2 +- hw/arm/integratorcp.c | 18 +++++----- hw/arm/mps2.c | 6 ++-- hw/arm/musicpal.c | 18 +++++----- hw/arm/npcm7xx.c | 2 +- hw/arm/realview.c | 24 ++++++------- hw/arm/sbsa-ref.c | 6 ++-- hw/arm/stellaris.c | 8 ++--- hw/arm/strongarm.c | 10 +++--- hw/arm/versatilepb.c | 28 +++++++-------- hw/arm/vexpress.c | 20 +++++------ hw/arm/virt.c | 8 ++--- hw/arm/xilinx_zynq.c | 10 +++--- hw/core/sysbus.c | 35 ++++++++++++++++++- hw/i386/kvm/clock.c | 2 +- hw/i386/kvm/xen_evtchn.c | 2 +- hw/i386/kvm/xen_gnttab.c | 2 +- hw/i386/kvm/xen_overlay.c | 2 +- hw/i386/kvm/xen_primary_console.c | 2 +- hw/i386/kvm/xen_xenstore.c | 2 +- hw/i386/microvm.c | 2 +- hw/intc/apic_common.c | 2 +- hw/loongarch/virt.c | 2 +- hw/m68k/next-cube.c | 4 +-- hw/m68k/virt.c | 2 +- hw/mips/jazz.c | 2 +- hw/mips/loongson3_virt.c | 2 +- hw/or1k/virt.c | 2 +- hw/ppc/amigaone.c | 2 +- hw/ppc/e500.c | 2 +- hw/ppc/pegasos.c | 4 +-- hw/ppc/ppc440_bamboo.c | 2 +- hw/ppc/sam460ex.c | 8 ++--- hw/riscv/virt.c | 4 +-- hw/sparc/sun4m.c | 2 +- hw/vmapple/vmapple.c | 4 +-- hw/xen/xen-pvh-common.c | 2 +- include/hw/core/sysbus.h | 32 ++++++++++++++--- .../qom-parent/sysbus-create-orphan.cocci | 18 ++++++++++ 42 files changed, 206 insertions(+), 131 deletions(-) create mode 100644 scripts/coccinelle/qom-parent/sysbus-create-orphan.cocci
hw/arm/allwinner-h3.c +8 -8
@@ -379,29 +379,29 @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp) qdev_get_gpio_in(DEVICE(&s->gic), AW_H3_GIC_SPI_EMAC));/* Universal Serial Bus */ -sysbus_create_simple (TYPE_AW_H3_EHCI , s->memmap[AW_H3_DEV_EHCI0 ], +sysbus_create_simple_orphan (TYPE_AW_H3_EHCI , s->memmap[AW_H3_DEV_EHCI0 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_EHCI0 )); -sysbus_create_simple (TYPE_AW_H3_EHCI , s->memmap[AW_H3_DEV_EHCI1 ], +sysbus_create_simple_orphan (TYPE_AW_H3_EHCI , s->memmap[AW_H3_DEV_EHCI1 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_EHCI1 )); -sysbus_create_simple (TYPE_AW_H3_EHCI , s->memmap[AW_H3_DEV_EHCI2 ], +sysbus_create_simple_orphan (TYPE_AW_H3_EHCI , s->memmap[AW_H3_DEV_EHCI2 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_EHCI2 )); -sysbus_create_simple (TYPE_AW_H3_EHCI , s->memmap[AW_H3_DEV_EHCI3 ], +sysbus_create_simple_orphan (TYPE_AW_H3_EHCI , s->memmap[AW_H3_DEV_EHCI3 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_EHCI3 )); -sysbus_create_simple ("sysbus-ohci" , s->memmap[AW_H3_DEV_OHCI0 ], +sysbus_create_simple_orphan ("sysbus-ohci" , s->memmap[AW_H3_DEV_OHCI0 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_OHCI0 )); -sysbus_create_simple ("sysbus-ohci" , s->memmap[AW_H3_DEV_OHCI1 ], +sysbus_create_simple_orphan ("sysbus-ohci" , s->memmap[AW_H3_DEV_OHCI1 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_OHCI1 )); -sysbus_create_simple ("sysbus-ohci" , s->memmap[AW_H3_DEV_OHCI2 ], +sysbus_create_simple_orphan ("sysbus-ohci" , s->memmap[AW_H3_DEV_OHCI2 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_OHCI2 )); -sysbus_create_simple ("sysbus-ohci" , s->memmap[AW_H3_DEV_OHCI3 ], +sysbus_create_simple_orphan ("sysbus-ohci" , s->memmap[AW_H3_DEV_OHCI3 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_OHCI3 ));
hw/arm/collie.c +1 -1
@@ -64,7 +64,7 @@ static void collie_init(MachineState *machine) FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0); } -sysbus_create_simple ("scoop" ,0x40800000 ,NULL ); +sysbus_create_simple_orphan ("scoop" ,0x40800000 ,NULL ); collie_binfo.board_id =0x208 ;arm_load_kernel (cms->sa1110->cpu, machine, &collie_binfo);
hw/arm/exynos4210.c +7 -7
@@ -600,7 +600,7 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) }/* Cache controller */ -sysbus_create_simple ("l2x0" ,EXYNOS4210_L2X0_BASE_ADDR ,NULL ); +sysbus_create_simple_orphan ("l2x0" ,EXYNOS4210_L2X0_BASE_ADDR ,NULL );/* External GIC */ qdev_prop_set_uint32 (DEVICE (&s->ext_gic),"num-cpu" ,EXYNOS4210_NCPUS );
@@ -667,13 +667,13 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)* The only reason of existence at the moment is that secondary CPU boot * loader uses PMU INFORM5 register as a holding pen. */ -sysbus_create_simple ("exynos4210.pmu" ,EXYNOS4210_PMU_BASE_ADDR ,NULL ); +sysbus_create_simple_orphan ("exynos4210.pmu" ,EXYNOS4210_PMU_BASE_ADDR ,NULL ); -sysbus_create_simple ("exynos4210.clk" ,EXYNOS4210_CLK_BASE_ADDR ,NULL ); -sysbus_create_simple ("exynos4210.rng" ,EXYNOS4210_RNG_BASE_ADDR ,NULL ); +sysbus_create_simple_orphan ("exynos4210.clk" ,EXYNOS4210_CLK_BASE_ADDR ,NULL ); +sysbus_create_simple_orphan ("exynos4210.rng" ,EXYNOS4210_RNG_BASE_ADDR ,NULL );/* PWM */ - sysbus_create_varargs("exynos4210.pwm", EXYNOS4210_PWM_BASE_ADDR, + sysbus_create_varargs_orphan("exynos4210.pwm", EXYNOS4210_PWM_BASE_ADDR, s->irq_table[exynos4210_get_irq(22, 0)], s->irq_table[exynos4210_get_irq(22, 1)], s->irq_table[exynos4210_get_irq(22, 2)],
@@ -681,7 +681,7 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) s->irq_table[exynos4210_get_irq (22 ,4 )], NULL);/* RTC */ -sysbus_create_varargs ("exynos4210.rtc" ,EXYNOS4210_RTC_BASE_ADDR , +sysbus_create_varargs_orphan ("exynos4210.rtc" ,EXYNOS4210_RTC_BASE_ADDR , s->irq_table[exynos4210_get_irq (23 ,0 )], s->irq_table[exynos4210_get_irq (23 ,1 )],NULL );
@@ -784,7 +784,7 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)sysbus_connect_irq (busdev, n, s->irq_table[exynos4210_get_irq (11 , n)]); } -sysbus_create_simple (TYPE_EXYNOS4210_EHCI ,EXYNOS4210_EHCI_BASE_ADDR , +sysbus_create_simple_orphan (TYPE_EXYNOS4210_EHCI ,EXYNOS4210_EHCI_BASE_ADDR , s->irq_table[exynos4210_get_irq (28 ,3 )]);/*** DMA controllers ***/
hw/arm/fsl-imx6.c +1 -1
@@ -168,7 +168,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) }/* L2 cache controller */ -sysbus_create_simple ("l2x0" ,FSL_IMX6_PL310_ADDR ,NULL ); +sysbus_create_simple_orphan ("l2x0" ,FSL_IMX6_PL310_ADDR ,NULL );if (!sysbus_realize (SYS_BUS_DEVICE (&s->ccm), errp)) {return ;
hw/arm/integratorcp.c +9 -9
@@ -626,26 +626,26 @@ static void integratorcp_init(MachineState *machine)sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map ((SysBusDevice *)dev,0 ,0x10000000 ); - dev =sysbus_create_varargs (TYPE_INTEGRATOR_PIC ,0x14000000 , + dev =sysbus_create_varargs_orphan (TYPE_INTEGRATOR_PIC ,0x14000000 ,qdev_get_gpio_in (DEVICE (cpu),ARM_CPU_IRQ ),qdev_get_gpio_in (DEVICE (cpu),ARM_CPU_FIQ ),NULL );for (i =0 ; i <32 ; i++) { pic[i] =qdev_get_gpio_in (dev, i); } - sic =sysbus_create_simple (TYPE_INTEGRATOR_PIC ,0xca000000 , pic[26 ]); -sysbus_create_varargs ("integrator_pit" ,0x13000000 , + sic =sysbus_create_simple_orphan (TYPE_INTEGRATOR_PIC ,0xca000000 , pic[26 ]); +sysbus_create_varargs_orphan ("integrator_pit" ,0x13000000 , pic[5 ], pic[6 ], pic[7 ],NULL ); -sysbus_create_simple ("pl031" ,0x15000000 , pic[8 ]); +sysbus_create_simple_orphan ("pl031" ,0x15000000 , pic[8 ]);pl011_create (0x16000000 , pic[1 ],serial_hd (0 ));pl011_create (0x17000000 , pic[2 ],serial_hd (1 )); - icp =sysbus_create_simple (TYPE_ICP_CONTROL_REGS ,0xcb000000 , + icp =sysbus_create_simple_orphan (TYPE_ICP_CONTROL_REGS ,0xcb000000 ,qdev_get_gpio_in (sic,3 )); -sysbus_create_simple ("pl050_keyboard" ,0x18000000 , pic[3 ]); -sysbus_create_simple ("pl050_mouse" ,0x19000000 , pic[4 ]); -sysbus_create_simple (TYPE_INTEGRATOR_DEBUG ,0x1a000000 ,0 ); +sysbus_create_simple_orphan ("pl050_keyboard" ,0x18000000 , pic[3 ]); +sysbus_create_simple_orphan ("pl050_mouse" ,0x19000000 , pic[4 ]); +sysbus_create_simple_orphan (TYPE_INTEGRATOR_DEBUG ,0x1a000000 ,0 ); - dev =sysbus_create_varargs ("pl181" ,0x1c000000 , pic[23 ], pic[24 ],NULL ); + dev =sysbus_create_varargs_orphan ("pl181" ,0x1c000000 , pic[23 ], pic[24 ],NULL );qdev_connect_gpio_out_named (dev,"card-read-only" ,0 ,qdev_get_gpio_in_named (icp,ICP_GPIO_MMC_WPROT ,0 )); qdev_connect_gpio_out_named(dev, "card-inserted", 0,
hw/arm/mps2.c +3 -3
@@ -416,7 +416,7 @@ static void mps2_common_init(MachineState *machine)qdev_prop_set_uint32 (DEVICE (&mms->fpgaio),"prescale-clk" ,25000000 );sysbus_realize (SYS_BUS_DEVICE (&mms->fpgaio), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (&mms->fpgaio),0 ,0x40028000 ); -sysbus_create_simple (TYPE_PL022 ,0x40025000 ,/* External ADC */ +sysbus_create_simple_orphan (TYPE_PL022 ,0x40025000 ,/* External ADC */ qdev_get_gpio_in (armv7m,22 ));for (i =0 ; i <2 ; i++) {static const int spi_irqno[] = {11 ,24 };
@@ -435,7 +435,7 @@ static void mps2_common_init(MachineState *machine)qdev_connect_gpio_out (orgate_dev,0 ,qdev_get_gpio_in (armv7m, spi_irqno[i]));for (j =0 ; j <2 ; j++) { -sysbus_create_simple (TYPE_PL022 , spibase[2 * i + j], +sysbus_create_simple_orphan (TYPE_PL022 , spibase[2 * i + j],qdev_get_gpio_in (orgate_dev, j)); } }
@@ -446,7 +446,7 @@ static void mps2_common_init(MachineState *machine) 0x4002a000}; /* Shield1 */DeviceState *dev; - dev =sysbus_create_simple (TYPE_ARM_SBCON_I2C , i2cbase[i],NULL ); + dev =sysbus_create_simple_orphan (TYPE_ARM_SBCON_I2C , i2cbase[i],NULL );if (i <2 ) {/* * internal-only bus: mark it full to avoid user-created
hw/arm/musicpal.c +9 -9
@@ -1240,9 +1240,9 @@ static void musicpal_init(MachineState *machine) &error_fatal);memory_region_add_subregion (address_space_mem,MP_SRAM_BASE , sram); - pic =sysbus_create_simple (TYPE_MV88W8618_PIC ,MP_PIC_BASE , + pic =sysbus_create_simple_orphan (TYPE_MV88W8618_PIC ,MP_PIC_BASE ,qdev_get_gpio_in (DEVICE (cpu),ARM_CPU_IRQ )); - sysbus_create_varargs(TYPE_MV88W8618_PIT, MP_PIT_BASE, + sysbus_create_varargs_orphan(TYPE_MV88W8618_PIT, MP_PIT_BASE, qdev_get_gpio_in(pic, MP_TIMER1_IRQ), qdev_get_gpio_in(pic, MP_TIMER2_IRQ), qdev_get_gpio_in(pic, MP_TIMER3_IRQ),
@@ -1286,7 +1286,7 @@ static void musicpal_init(MachineState *machine)2 ,0x00BF ,0x236D ,0x0000 ,0x0000 , 0x5555, 0x2AAA, 0); } -sysbus_create_simple (TYPE_MV88W8618_FLASHCFG ,MP_FLASHCFG_BASE ,NULL ); +sysbus_create_simple_orphan (TYPE_MV88W8618_FLASHCFG ,MP_FLASHCFG_BASE ,NULL ); dev =qdev_new_orphan (TYPE_MV88W8618_ETH );qemu_configure_nic_device (dev, true,"mv88w8618" );
@@ -1297,17 +1297,17 @@ static void musicpal_init(MachineState *machine)sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 ,qdev_get_gpio_in (pic,MP_ETH_IRQ )); -sysbus_create_simple ("mv88w8618_wlan" ,MP_WLAN_BASE ,NULL ); +sysbus_create_simple_orphan ("mv88w8618_wlan" ,MP_WLAN_BASE ,NULL ); -sysbus_create_simple (TYPE_MUSICPAL_MISC ,MP_MISC_BASE ,NULL ); +sysbus_create_simple_orphan (TYPE_MUSICPAL_MISC ,MP_MISC_BASE ,NULL ); - dev =sysbus_create_simple (TYPE_MUSICPAL_GPIO ,MP_GPIO_BASE , + dev =sysbus_create_simple_orphan (TYPE_MUSICPAL_GPIO ,MP_GPIO_BASE ,qdev_get_gpio_in (pic,MP_GPIO_IRQ )); - i2c_dev =sysbus_create_simple (TYPE_GPIO_I2C ,-1 ,NULL ); + i2c_dev =sysbus_create_simple_orphan (TYPE_GPIO_I2C ,-1 ,NULL ); i2c = (I2CBus *)qdev_get_child_bus (i2c_dev,"i2c" ); - lcd_dev =sysbus_create_simple (TYPE_MUSICPAL_LCD ,MP_LCD_BASE ,NULL ); - key_dev =sysbus_create_simple (TYPE_MUSICPAL_KEY ,-1 ,NULL ); + lcd_dev =sysbus_create_simple_orphan (TYPE_MUSICPAL_LCD ,MP_LCD_BASE ,NULL ); + key_dev =sysbus_create_simple_orphan (TYPE_MUSICPAL_KEY ,-1 ,NULL );/* I2C read data */ qdev_connect_gpio_out(i2c_dev, 0,
hw/arm/npcm7xx.c +1 -1
@@ -521,7 +521,7 @@ static void npcm7xx_realize(DeviceState *dev, Error **errp) }/* L2 cache controller */ -sysbus_create_simple ("l2x0" ,NPCM7XX_L2C_BA ,NULL ); +sysbus_create_simple_orphan ("l2x0" ,NPCM7XX_L2C_BA ,NULL );/* System Global Control Registers (GCR). Can fail due to user input. */ object_property_set_int(OBJECT(&s->gcr), "disabled-modules",
hw/arm/realview.c +12 -12
@@ -200,13 +200,13 @@ static void realview_init(MachineState *machine,for (n =0 ; n < smp_cpus; n++) {sysbus_connect_irq (busdev, n, cpu_irq[n]); } -sysbus_create_varargs ("l2x0" , periphbase +0x2000 ,NULL ); +sysbus_create_varargs_orphan ("l2x0" , periphbase +0x2000 ,NULL );/* Both A9 and 11MPCore put the GIC CPU i/f at base + 0x100 */ realview_binfo.gic_cpu_if_addr = periphbase +0x100 ; }else {uint32_t gic_addr = is_pb ?0x1e000000 :0x10040000 ;/* For now just create the nIRQ GIC, and ignore the others. */ - dev =sysbus_create_simple (TYPE_REALVIEW_GIC , gic_addr, cpu_irq[0 ]); + dev =sysbus_create_simple_orphan (TYPE_REALVIEW_GIC , gic_addr, cpu_irq[0 ]); }for (n =0 ; n <GIC_EXT_IRQS ; n++) { pic[n] =qdev_get_gpio_in (dev, n);
@@ -221,8 +221,8 @@ static void realview_init(MachineState *machine,sysbus_mmio_map (SYS_BUS_DEVICE (pl041),0 ,0x10004000 );sysbus_connect_irq (SYS_BUS_DEVICE (pl041),0 , pic[19 ]); -sysbus_create_simple ("pl050_keyboard" ,0x10006000 , pic[20 ]); -sysbus_create_simple ("pl050_mouse" ,0x10007000 , pic[21 ]); +sysbus_create_simple_orphan ("pl050_keyboard" ,0x10006000 , pic[20 ]); +sysbus_create_simple_orphan ("pl050_mouse" ,0x10007000 , pic[21 ]);pl011_create (0x10009000 , pic[12 ],serial_hd (0 ));pl011_create (0x1000a000 , pic[13 ],serial_hd (1 ));
@@ -238,12 +238,12 @@ static void realview_init(MachineState *machine,sysbus_mmio_map (busdev,0 ,0x10030000 );sysbus_connect_irq (busdev,0 , pic[24 ]); -sysbus_create_simple ("sp804" ,0x10011000 , pic[4 ]); -sysbus_create_simple ("sp804" ,0x10012000 , pic[5 ]); +sysbus_create_simple_orphan ("sp804" ,0x10011000 , pic[4 ]); +sysbus_create_simple_orphan ("sp804" ,0x10012000 , pic[5 ]); -sysbus_create_simple ("pl061" ,0x10013000 , pic[6 ]); -sysbus_create_simple ("pl061" ,0x10014000 , pic[7 ]); - gpio2 =sysbus_create_simple ("pl061" ,0x10015000 , pic[8 ]); +sysbus_create_simple_orphan ("pl061" ,0x10013000 , pic[6 ]); +sysbus_create_simple_orphan ("pl061" ,0x10014000 , pic[7 ]); + gpio2 =sysbus_create_simple_orphan ("pl061" ,0x10015000 , pic[8 ]); dev =qdev_new_orphan ("pl111" ); object_property_set_link(OBJECT(dev), "framebuffer-memory",
@@ -252,7 +252,7 @@ static void realview_init(MachineState *machine,sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,0x10020000 );sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , pic[23 ]); - dev =sysbus_create_varargs ("pl181" ,0x10005000 , pic[17 ], pic[18 ],NULL ); + dev =sysbus_create_varargs_orphan ("pl181" ,0x10005000 , pic[17 ], pic[18 ],NULL );/* Wire up MMC card detect and read-only signals. These have * to go to both the PL061 GPIO and the sysctl register. * Note that the PL181 orders these lines (readonly,inserted)
@@ -278,7 +278,7 @@ static void realview_init(MachineState *machine, &error_fatal); } -sysbus_create_simple ("pl031" ,0x10017000 , pic[10 ]); +sysbus_create_simple_orphan ("pl031" ,0x10017000 , pic[10 ]);if (!is_pb) { dev =qdev_new_orphan ("realview_pci" );
@@ -319,7 +319,7 @@ static void realview_init(MachineState *machine,pci_init_nic_devices (pci_bus,"rtl8139" ); } - dev =sysbus_create_simple (TYPE_ARM_SBCON_I2C ,0x10002000 ,NULL ); + dev =sysbus_create_simple_orphan (TYPE_ARM_SBCON_I2C ,0x10002000 ,NULL ); i2c = (I2CBus *)qdev_get_child_bus (dev,"i2c" );i2c_slave_create_simple (i2c,"ds1338" ,0x68 );
hw/arm/sbsa-ref.c +3 -3
@@ -537,7 +537,7 @@ static void create_rtc(const SBSAMachineState *sms)hwaddr base = sbsa_ref_memmap[SBSA_RTC ].base;int irq = sbsa_ref_irqmap[SBSA_RTC ]; -sysbus_create_simple ("pl031" , base,qdev_get_gpio_in (sms->gic, irq)); +sysbus_create_simple_orphan ("pl031" , base,qdev_get_gpio_in (sms->gic, irq)); }static void create_wdt (const SBSAMachineState *sms)
@@ -572,10 +572,10 @@ static void create_gpio(const SBSAMachineState *sms)hwaddr base = sbsa_ref_memmap[SBSA_GPIO ].base;int irq = sbsa_ref_irqmap[SBSA_GPIO ]; - pl061_dev =sysbus_create_simple ("pl061" , base, + pl061_dev =sysbus_create_simple_orphan ("pl061" , base,qdev_get_gpio_in (sms->gic, irq)); - gpio_key_dev =sysbus_create_simple ("gpio-key" ,-1 , + gpio_key_dev =sysbus_create_simple_orphan ("gpio-key" ,-1 ,qdev_get_gpio_in (pl061_dev,3 ));/* connect powerdown request */
hw/arm/stellaris.c +4 -4
@@ -1143,7 +1143,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)sysbus_connect_irq (SYS_BUS_DEVICE (ssys_dev),0 ,qdev_get_gpio_in (nvic,28 ));if (DEV_CAP (1 ,ADC )) { - dev = sysbus_create_varargs(TYPE_STELLARIS_ADC, 0x40038000, + dev = sysbus_create_varargs_orphan(TYPE_STELLARIS_ADC, 0x40038000, qdev_get_gpio_in(nvic, 14), qdev_get_gpio_in(nvic, 15), qdev_get_gpio_in(nvic, 16),
@@ -1189,7 +1189,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)for (i =0 ; i <NUM_GPIO ; i++) {if (DEV_CAP (4 ,GPIO (i))) { - gpio_dev[i] =sysbus_create_simple ("pl061_luminary" , gpio_addr[i], + gpio_dev[i] =sysbus_create_simple_orphan ("pl061_luminary" , gpio_addr[i],qdev_get_gpio_in (nvic, gpio_irq[i]));for (j =0 ; j <8 ; j++) {
@@ -1201,7 +1201,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)for (i =0 ; i <NUM_I2C ; i++) {if (DEV_CAP (2 ,I2C (i))) { - i2c_dev[i] =sysbus_create_simple (TYPE_STELLARIS_I2C , i2c_addr[i], + i2c_dev[i] =sysbus_create_simple_orphan (TYPE_STELLARIS_I2C , i2c_addr[i],qdev_get_gpio_in (nvic, i2c_irq[i])); }
@@ -1226,7 +1226,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) } }if (DEV_CAP (2 ,SSI )) { - dev =sysbus_create_simple ("pl022" ,0x40008000 , + dev =sysbus_create_simple_orphan ("pl022" ,0x40008000 ,qdev_get_gpio_in (nvic,7 ));if (board->peripherals &BP_OLED_SSI ) {void *bus;
hw/arm/strongarm.c +5 -5
@@ -1622,24 +1622,24 @@ StrongARMState *sa1110_init(const char *cpu_type) s->cpu =ARM_CPU (cpu_create (cpu_type)); - s->pic =sysbus_create_varargs ("strongarm_pic" ,0x90050000 , + s->pic =sysbus_create_varargs_orphan ("strongarm_pic" ,0x90050000 ,qdev_get_gpio_in (DEVICE (s->cpu),ARM_CPU_IRQ ),qdev_get_gpio_in (DEVICE (s->cpu),ARM_CPU_FIQ ),NULL ); -sysbus_create_varargs ("pxa25x-timer" ,0x90000000 , +sysbus_create_varargs_orphan ("pxa25x-timer" ,0x90000000 ,qdev_get_gpio_in (s->pic,SA_PIC_OSTC0 ),qdev_get_gpio_in (s->pic,SA_PIC_OSTC1 ),qdev_get_gpio_in (s->pic,SA_PIC_OSTC2 ),qdev_get_gpio_in (s->pic,SA_PIC_OSTC3 ),NULL ); -sysbus_create_simple (TYPE_STRONGARM_RTC ,0x90010000 , +sysbus_create_simple_orphan (TYPE_STRONGARM_RTC ,0x90010000 ,qdev_get_gpio_in (s->pic,SA_PIC_RTC_ALARM )); s->gpio =strongarm_gpio_init (0x90040000 , s->pic); - s->ppc =sysbus_create_varargs (TYPE_STRONGARM_PPC ,0x90060000 ,NULL ); + s->ppc =sysbus_create_varargs_orphan (TYPE_STRONGARM_PPC ,0x90060000 ,NULL );for (i =0 ; sa_serial[i].io_base; i++) {DeviceState *dev =qdev_new_orphan (TYPE_STRONGARM_UART );
@@ -1651,7 +1651,7 @@ StrongARMState *sa1110_init(const char *cpu_type) qdev_get_gpio_in(s->pic, sa_serial[i].irq)); } - s->ssp =sysbus_create_varargs (TYPE_STRONGARM_SSP ,0x80070000 , + s->ssp =sysbus_create_varargs_orphan (TYPE_STRONGARM_SSP ,0x80070000 ,qdev_get_gpio_in (s->pic,SA_PIC_SSP ),NULL ); s->ssp_bus = (SSIBus *)qdev_get_child_bus (s->ssp,"ssi" );
hw/arm/versatilepb.c +14 -14
@@ -232,21 +232,21 @@ static void versatile_init(MachineState *machine, int board_id)sysbus_realize_and_unref (SYS_BUS_DEVICE (sysctl), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (sysctl),0 ,0x10000000 ); - dev =sysbus_create_varargs ("pl190" ,0x10140000 , + dev =sysbus_create_varargs_orphan ("pl190" ,0x10140000 ,qdev_get_gpio_in (DEVICE (cpu),ARM_CPU_IRQ ),qdev_get_gpio_in (DEVICE (cpu),ARM_CPU_FIQ ),NULL );for (n =0 ; n <32 ; n++) { pic[n] =qdev_get_gpio_in (dev, n); } - dev =sysbus_create_simple (TYPE_VERSATILE_PB_SIC ,0x10003000 ,NULL ); + dev =sysbus_create_simple_orphan (TYPE_VERSATILE_PB_SIC ,0x10003000 ,NULL );for (n =0 ; n <32 ; n++) {sysbus_connect_irq (SYS_BUS_DEVICE (dev), n, pic[n]); sic[n] =qdev_get_gpio_in (dev, n); } -sysbus_create_simple ("pl050_keyboard" ,0x10006000 , sic[3 ]); -sysbus_create_simple ("pl050_mouse" ,0x10007000 , sic[4 ]); +sysbus_create_simple_orphan ("pl050_keyboard" ,0x10006000 , sic[3 ]); +sysbus_create_simple_orphan ("pl050_mouse" ,0x10007000 , sic[4 ]); dev =qdev_new_orphan ("versatile_pci" ); busdev =SYS_BUS_DEVICE (dev);
@@ -292,13 +292,13 @@ static void versatile_init(MachineState *machine, int board_id)sysbus_mmio_map (busdev,0 ,0x10130000 );sysbus_connect_irq (busdev,0 , pic[17 ]); -sysbus_create_simple ("sp804" ,0x101e2000 , pic[4 ]); -sysbus_create_simple ("sp804" ,0x101e3000 , pic[5 ]); +sysbus_create_simple_orphan ("sp804" ,0x101e2000 , pic[4 ]); +sysbus_create_simple_orphan ("sp804" ,0x101e3000 , pic[5 ]); -sysbus_create_simple ("pl061" ,0x101e4000 , pic[6 ]); -sysbus_create_simple ("pl061" ,0x101e5000 , pic[7 ]); -sysbus_create_simple ("pl061" ,0x101e6000 , pic[8 ]); -sysbus_create_simple ("pl061" ,0x101e7000 , pic[9 ]); +sysbus_create_simple_orphan ("pl061" ,0x101e4000 , pic[6 ]); +sysbus_create_simple_orphan ("pl061" ,0x101e5000 , pic[7 ]); +sysbus_create_simple_orphan ("pl061" ,0x101e6000 , pic[8 ]); +sysbus_create_simple_orphan ("pl061" ,0x101e7000 , pic[9 ]);/* The versatile/PB actually has a modified Color LCD controller that includes hardware cursor support from the PL111. */
@@ -312,7 +312,7 @@ static void versatile_init(MachineState *machine, int board_id)/* Wire up the mux control signals from the SYS_CLCD register */ qdev_connect_gpio_out (sysctl,0 ,qdev_get_gpio_in (dev,0 )); - dev =sysbus_create_varargs ("pl181" ,0x10005000 , sic[22 ], sic[1 ],NULL ); + dev =sysbus_create_varargs_orphan ("pl181" ,0x10005000 , sic[22 ], sic[1 ],NULL ); dinfo =drive_get (IF_SD ,0 ,0 );if (dinfo) {DeviceState *card;
@@ -324,7 +324,7 @@ static void versatile_init(MachineState *machine, int board_id) &error_fatal); } - dev =sysbus_create_varargs ("pl181" ,0x1000b000 , sic[23 ], sic[2 ],NULL ); + dev =sysbus_create_varargs_orphan ("pl181" ,0x1000b000 , sic[23 ], sic[2 ],NULL ); dinfo =drive_get (IF_SD ,0 ,1 );if (dinfo) {DeviceState *card;
@@ -337,9 +337,9 @@ static void versatile_init(MachineState *machine, int board_id) }/* Add PL031 Real Time Clock. */ -sysbus_create_simple ("pl031" ,0x101e8000 , pic[10 ]); +sysbus_create_simple_orphan ("pl031" ,0x101e8000 , pic[10 ]); - dev =sysbus_create_simple (TYPE_ARM_SBCON_I2C ,0x10002000 ,NULL ); + dev =sysbus_create_simple_orphan (TYPE_ARM_SBCON_I2C ,0x10002000 ,NULL ); i2c = (I2CBus *)qdev_get_child_bus (dev,"i2c" );i2c_slave_create_simple (i2c,"ds1338" ,0x68 );
hw/arm/vexpress.c +10 -10
@@ -313,7 +313,7 @@ static void a9_daughterboard_init(VexpressMachineState *vms,/* 0x100e1000 PL354 Static Memory Controller */ /* 0x100e2000 System Configuration Controller */ -sysbus_create_simple ("sp804" ,0x100e4000 , pic[48 ]); +sysbus_create_simple_orphan ("sp804" ,0x100e4000 , pic[48 ]);/* 0x100e5000 SP805 Watchdog module */ /* 0x100e6000 BP147 TrustZone Protection Controller */ /* 0x100e9000 PL301 'Fast' AXI matrix */
@@ -321,7 +321,7 @@ static void a9_daughterboard_init(VexpressMachineState *vms,/* 0x100ec000 TrustZone Address Space Controller */ /* 0x10200000 CoreSight debug APB */ /* 0x1e00a000 PL310 L2 Cache Controller */ -sysbus_create_varargs ("l2x0" ,0x1e00a000 ,NULL ); +sysbus_create_varargs_orphan ("l2x0" ,0x1e00a000 ,NULL ); }/* Voltage values for SYS_CFG_VOLT daughterboard registers;
@@ -623,7 +623,7 @@ static void vexpress_common_init(MachineState *machine)sysbus_mmio_map (SYS_BUS_DEVICE (pl041),0 , map[VE_PL041 ]);sysbus_connect_irq (SYS_BUS_DEVICE (pl041),0 , pic[11 ]); - dev =sysbus_create_varargs ("pl181" , map[VE_MMCI ], pic[9 ], pic[10 ],NULL ); + dev =sysbus_create_varargs_orphan ("pl181" , map[VE_MMCI ], pic[9 ], pic[10 ],NULL );/* Wire up MMC card detect and read-only signals */ qdev_connect_gpio_out_named (dev,"card-read-only" ,0 ,qdev_get_gpio_in (sysctl,ARM_SYSCTL_GPIO_MMC_WPROT ));
@@ -640,22 +640,22 @@ static void vexpress_common_init(MachineState *machine) &error_fatal); } -sysbus_create_simple ("pl050_keyboard" , map[VE_KMI0 ], pic[12 ]); -sysbus_create_simple ("pl050_mouse" , map[VE_KMI1 ], pic[13 ]); +sysbus_create_simple_orphan ("pl050_keyboard" , map[VE_KMI0 ], pic[12 ]); +sysbus_create_simple_orphan ("pl050_mouse" , map[VE_KMI1 ], pic[13 ]);pl011_create (map[VE_UART0 ], pic[5 ],serial_hd (0 ));pl011_create (map[VE_UART1 ], pic[6 ],serial_hd (1 ));pl011_create (map[VE_UART2 ], pic[7 ],serial_hd (2 ));pl011_create (map[VE_UART3 ], pic[8 ],serial_hd (3 )); -sysbus_create_simple ("sp804" , map[VE_TIMER01 ], pic[2 ]); -sysbus_create_simple ("sp804" , map[VE_TIMER23 ], pic[3 ]); +sysbus_create_simple_orphan ("sp804" , map[VE_TIMER01 ], pic[2 ]); +sysbus_create_simple_orphan ("sp804" , map[VE_TIMER23 ], pic[3 ]); - dev =sysbus_create_simple (TYPE_ARM_SBCON_I2C , map[VE_SERIALDVI ],NULL ); + dev =sysbus_create_simple_orphan (TYPE_ARM_SBCON_I2C , map[VE_SERIALDVI ],NULL ); i2c = (I2CBus *)qdev_get_child_bus (dev,"i2c" );i2c_slave_create_simple (i2c,"sii9022" ,0x39 ); -sysbus_create_simple ("pl031" , map[VE_RTC ], pic[4 ]);/* RTC */ +sysbus_create_simple_orphan ("pl031" , map[VE_RTC ], pic[4 ]);/* RTC */ /* VE_COMPACTFLASH: not modelled */
@@ -706,7 +706,7 @@ static void vexpress_common_init(MachineState *machine)* no backend is created the transport will just sit harmlessly idle. */ for (i =0 ; i <NUM_VIRTIO_TRANSPORTS ; i++) { -sysbus_create_simple ("virtio-mmio" , map[VE_VIRTIO ] +0x200 * i, +sysbus_create_simple_orphan ("virtio-mmio" , map[VE_VIRTIO ] +0x200 * i, pic[40 + i]); }
hw/arm/virt.c +4 -4
@@ -1561,7 +1561,7 @@ static void create_rtc(const VirtMachineState *vms)const char compat[] ="arm,pl031\0arm,primecell" ;MachineState *ms =MACHINE (vms); -sysbus_create_simple ("pl031" , base,qdev_get_gpio_in (vms->gic, irq)); +sysbus_create_simple_orphan ("pl031" , base,qdev_get_gpio_in (vms->gic, irq)); nodename =g_strdup_printf ("/pl031@%" PRIx64, base);qemu_fdt_add_subnode (ms->fdt, nodename);
@@ -1606,7 +1606,7 @@ static void virt_generic_error_req(Notifier *n, void *opaque)static void create_gpio_keys (char *fdt,DeviceState *pl061_dev,uint32_t phandle) { - gpio_key_dev =sysbus_create_simple ("gpio-key" ,-1 , + gpio_key_dev =sysbus_create_simple_orphan ("gpio-key" ,-1 ,qdev_get_gpio_in (pl061_dev,GPIO_PIN_POWER_BUTTON ));
@@ -1631,7 +1631,7 @@ static void create_secure_gpio_pwr(char *fdt, DeviceState *pl061_dev,DeviceState *gpio_pwr_dev;/* gpio-pwr */ - gpio_pwr_dev =sysbus_create_simple ("gpio-pwr" ,-1 ,NULL ); + gpio_pwr_dev =sysbus_create_simple_orphan ("gpio-pwr" ,-1 ,NULL );/* connect secure pl061 to gpio-pwr */ qdev_connect_gpio_out(pl061_dev, SECURE_GPIO_RESET,
@@ -1746,7 +1746,7 @@ static void create_virtio_devices(const VirtMachineState *vms)int irq = vms->irqmap[VIRT_MMIO ] + i;hwaddr base = vms->memmap[VIRT_MMIO ].base + i * size; -sysbus_create_simple ("virtio-mmio" , base, +sysbus_create_simple_orphan ("virtio-mmio" , base,qdev_get_gpio_in (vms->gic, irq)); }
hw/arm/xilinx_zynq.c +5 -5
@@ -269,7 +269,7 @@ static void zynq_init(MachineState *machine)sysbus_realize_and_unref (busdev, &error_fatal);sysbus_mmio_map (busdev,0 ,MPCORE_PERIPHBASE ); zynq_binfo.gic_cpu_if_addr =MPCORE_PERIPHBASE +0x100 ; -sysbus_create_varargs ("l2x0" ,MPCORE_PERIPHBASE +0x2000 ,NULL ); +sysbus_create_varargs_orphan ("l2x0" ,MPCORE_PERIPHBASE +0x2000 ,NULL );for (n =0 ; n < smp_cpus; n++) {/* See "hw/intc/arm_gic.h" for the IRQ line association */ DeviceState *cpudev =DEVICE (zynq_machine->cpu[n]);
@@ -287,8 +287,8 @@ static void zynq_init(MachineState *machine) n =zynq_init_spi_flashes (0xE0007000 , pic[81 -GIC_INTERNAL ], false, n); n =zynq_init_spi_flashes (0xE000D000 , pic[51 -GIC_INTERNAL ], true, n); -sysbus_create_simple (TYPE_CHIPIDEA ,0xE0002000 , pic[53 -GIC_INTERNAL ]); -sysbus_create_simple (TYPE_CHIPIDEA ,0xE0003000 , pic[76 -GIC_INTERNAL ]); +sysbus_create_simple_orphan (TYPE_CHIPIDEA ,0xE0002000 , pic[53 -GIC_INTERNAL ]); +sysbus_create_simple_orphan (TYPE_CHIPIDEA ,0xE0003000 , pic[76 -GIC_INTERNAL ]); dev =qdev_new_orphan (TYPE_CADENCE_UART ); busdev =SYS_BUS_DEVICE (dev);
@@ -307,9 +307,9 @@ static void zynq_init(MachineState *machine)sysbus_mmio_map (busdev,0 ,0xE0001000 );sysbus_connect_irq (busdev,0 , pic[82 -GIC_INTERNAL ]); -sysbus_create_varargs ("cadence_ttc" ,0xF8001000 , +sysbus_create_varargs_orphan ("cadence_ttc" ,0xF8001000 , pic[42 -GIC_INTERNAL ], pic[43 -GIC_INTERNAL ], pic[44 -GIC_INTERNAL ],NULL ); -sysbus_create_varargs ("cadence_ttc" ,0xF8002000 , +sysbus_create_varargs_orphan ("cadence_ttc" ,0xF8002000 , pic[69 -GIC_INTERNAL ], pic[70 -GIC_INTERNAL ], pic[71 -GIC_INTERNAL ],NULL );ddr_ctrl_init (0xF8006000 );
hw/core/sysbus.c +34 -1
@@ -209,7 +209,40 @@ static void sysbus_device_realize(DeviceState *dev, Error **errp) { } -DeviceState *sysbus_create_varargs (const char *name, +static void sysbus_create_tail (SysBusDevice *s,hwaddr addr,va_list va) +{ +qemu_irq irq; +int n; + +if (addr != (hwaddr)-1 ) { +sysbus_mmio_map (s,0 , addr); + } + n =0 ; +while (1 ) { + irq =va_arg (va, qemu_irq); +if (!irq) { +break ; + } +sysbus_connect_irq (s, n, irq); + n++; + } +} + +DeviceState *sysbus_create_varargs (Object *parent,const char *id, +const char *type,hwaddr addr, ...) +{ +DeviceState *dev; +va_list va; + + dev =qdev_new (parent, id, type); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal); +va_start (va, addr); +sysbus_create_tail (SYS_BUS_DEVICE (dev), addr, va); +va_end (va); +return dev; +} + +DeviceState *sysbus_create_varargs_orphan (const char *name,hwaddr addr, ...) {DeviceState *dev;
hw/i386/kvm/clock.c +1 -1
@@ -377,7 +377,7 @@ void kvmclock_create(bool create_always)if (create_always || cpu->env.features[FEAT_KVM ] & (CPUID_KVM_CLOCK |CPUID_KVM_CLOCK2 )) { -sysbus_create_simple (TYPE_KVM_CLOCK ,-1 ,NULL ); +sysbus_create_simple_orphan (TYPE_KVM_CLOCK ,-1 ,NULL ); } }
hw/i386/kvm/xen_evtchn.c +1 -1
@@ -306,7 +306,7 @@ static void gsi_assert_bh(void *opaque)void xen_evtchn_create (unsigned int nr_gsis,qemu_irq *system_gsis) { -XenEvtchnState *s =XEN_EVTCHN (sysbus_create_simple (TYPE_XEN_EVTCHN , +XenEvtchnState *s =XEN_EVTCHN (sysbus_create_simple_orphan (TYPE_XEN_EVTCHN ,-1 ,NULL ));int i;
hw/i386/kvm/xen_gnttab.c +1 -1
@@ -152,7 +152,7 @@ static const TypeInfo xen_gnttab_info = {void xen_gnttab_create (void ) { - xen_gnttab_singleton =XEN_GNTTAB (sysbus_create_simple (TYPE_XEN_GNTTAB , + xen_gnttab_singleton =XEN_GNTTAB (sysbus_create_simple_orphan (TYPE_XEN_GNTTAB ,-1 ,NULL )); }
hw/i386/kvm/xen_overlay.c +1 -1
@@ -169,7 +169,7 @@ static const TypeInfo xen_overlay_info = {void xen_overlay_create (void ) { - xen_overlay_singleton =XEN_OVERLAY (sysbus_create_simple (TYPE_XEN_OVERLAY , + xen_overlay_singleton =XEN_OVERLAY (sysbus_create_simple_orphan (TYPE_XEN_OVERLAY ,-1 ,NULL ));/* If xen_domid wasn't explicitly set, at least make sure it isn't zero. */
hw/i386/kvm/xen_primary_console.c +1 -1
@@ -84,7 +84,7 @@ static const TypeInfo xen_primary_console_info = {void xen_primary_console_create (void ) { -DeviceState *dev =sysbus_create_simple (TYPE_XEN_PRIMARY_CONSOLE ,-1 ,NULL ); +DeviceState *dev =sysbus_create_simple_orphan (TYPE_XEN_PRIMARY_CONSOLE ,-1 ,NULL );trace_xen_primary_console_create ();
hw/i386/kvm/xen_xenstore.c +1 -1
@@ -276,7 +276,7 @@ static const TypeInfo xen_xenstore_info = {void xen_xenstore_create (void ) { -DeviceState *dev =sysbus_create_simple (TYPE_XEN_XENSTORE ,-1 ,NULL ); +DeviceState *dev =sysbus_create_simple_orphan (TYPE_XEN_XENSTORE ,-1 ,NULL ); xen_xenstore_singleton =XEN_XENSTORE (dev);
hw/i386/microvm.c +1 -1
@@ -197,7 +197,7 @@ static void microvm_devices_init(MicrovmMachineState *mms) }for (i =0 ; i < mms->virtio_num_transports; i++) { -sysbus_create_simple ("virtio-mmio" , +sysbus_create_simple_orphan ("virtio-mmio" ,VIRTIO_MMIO_BASE + i *512 , x86ms->gsi[mms->virtio_irq_base + i]); }
hw/intc/apic_common.c +1 -1
@@ -282,7 +282,7 @@ static void apic_common_realize(DeviceState *dev, Error **errp)/* Note: We need at least 1M to map the VAPIC option ROM */ if (!vapic && s->vapic_control &VAPIC_ENABLE_MASK && current_machine->ram_size >=1024 *1024 ) { - vapic =sysbus_create_simple ("kvmvapic" ,-1 ,NULL ); + vapic =sysbus_create_simple_orphan ("kvmvapic" ,-1 ,NULL ); } s->vapic = vapic;if (apic_report_tpr_access && info->enable_tpr_reporting) {
hw/loongarch/virt.c +1 -1
@@ -485,7 +485,7 @@ static void virt_devices_init(DeviceState *pch_pic,* Create some unimplemented devices to emulate this. */ create_unimplemented_device ("pci-dma-cfg" ,0x1001041c ,0x4 ); -sysbus_create_simple ("ls7a_rtc" ,VIRT_RTC_REG_BASE , +sysbus_create_simple_orphan ("ls7a_rtc" ,VIRT_RTC_REG_BASE ,qdev_get_gpio_in (pch_pic,VIRT_RTC_IRQ -VIRT_GSI_BASE ));
hw/m68k/next-cube.c +2 -2
@@ -1280,7 +1280,7 @@ static void next_cube_init(MachineState *machine)memory_region_add_subregion (sysmem,0x04000000 , machine->ram);/* Framebuffer */ -sysbus_create_simple (TYPE_NEXTFB ,0x0B000000 ,NULL ); +sysbus_create_simple_orphan (TYPE_NEXTFB ,0x0B000000 ,NULL );/* MMIO */ sysbus_mmio_map (SYS_BUS_DEVICE (pcdev),0 ,0x02005000 );
@@ -1319,7 +1319,7 @@ static void next_cube_init(MachineState *machine)memory_region_add_subregion (sysmem,0x820c0000 , &m->bmapm2);/* KBD */ -sysbus_create_simple (TYPE_NEXTKBD ,0x0200e000 ,NULL ); +sysbus_create_simple_orphan (TYPE_NEXTKBD ,0x0200e000 ,NULL );/* Load ROM here */ memory_region_init_rom (&m->rom,NULL ,"next.rom" ,0x20000 , &error_fatal);
hw/m68k/virt.c +1 -1
@@ -202,7 +202,7 @@ static void virt_init(MachineState *machine)sysbus_connect_irq (sysbus,0 ,PIC_GPIO (VIRT_GF_TTY_IRQ_BASE ));/* virt controller */ - dev =sysbus_create_simple (TYPE_VIRT_CTRL ,VIRT_CTRL_MMIO_BASE , + dev =sysbus_create_simple_orphan (TYPE_VIRT_CTRL ,VIRT_CTRL_MMIO_BASE ,PIC_GPIO (VIRT_CTRL_IRQ_BASE ));/* virtio-mmio */
hw/mips/jazz.c +1 -1
@@ -395,7 +395,7 @@ static void mips_jazz_init(MachineState *machine,sysbus_mmio_map (sysbus,0 ,0x80009000 );/* LED indicator */ -sysbus_create_simple ("jazz-led" ,0x8000f000 ,NULL ); +sysbus_create_simple_orphan ("jazz-led" ,0x8000f000 ,NULL );g_free (dmas); }
hw/mips/loongson3_virt.c +1 -1
@@ -536,7 +536,7 @@ static void mips_loongson3_virt_init(MachineState *machine)qdev_get_gpio_in (liointc,UART_IRQ ),115200 ,serial_hd (0 ), DEVICE_LITTLE_ENDIAN); -sysbus_create_simple ("goldfish_rtc" , virt_memmap[VIRT_RTC ].base, +sysbus_create_simple_orphan ("goldfish_rtc" , virt_memmap[VIRT_RTC ].base,qdev_get_gpio_in (liointc,RTC_IRQ )); cpuclk =clock_new (OBJECT (machine),"cpu-refclk" );
hw/or1k/virt.c +1 -1
@@ -300,7 +300,7 @@ static void openrisc_virt_rtc_init(OR1KVirtState *state, hwaddr base,qemu_irq rtc_irq =get_per_cpu_irq (cpus, num_cpus, irq_pin);/* Goldfish RTC */ -sysbus_create_simple (TYPE_GOLDFISH_RTC , base, rtc_irq); +sysbus_create_simple_orphan (TYPE_GOLDFISH_RTC , base, rtc_irq);/* Goldfish RTC FDT */ nodename =g_strdup_printf ("/soc/rtc@%" HWADDR_PRIx, base);
hw/ppc/amigaone.c +1 -1
@@ -329,7 +329,7 @@ static void amigaone_init(MachineState *machine) }/* Articia S */ - dev =sysbus_create_simple (TYPE_ARTICIA ,ARTICIA_ADDR ,NULL ); + dev =sysbus_create_simple_orphan (TYPE_ARTICIA ,ARTICIA_ADDR ,NULL ); i2c_bus =I2C_BUS (qdev_get_child_bus (dev,"smbus" ));if (machine->ram_size >512 * MiB) {
hw/ppc/e500.c +1 -1
@@ -1076,7 +1076,7 @@ void ppce500_init(MachineState *machine) }/* Register spinning region */ -sysbus_create_simple ("e500-spin" , pmc->spin_base,NULL ); +sysbus_create_simple_orphan ("e500-spin" , pmc->spin_base,NULL );if (pmc->has_mpc8xxx_gpio) {qemu_irq poweroff_irq;
hw/ppc/pegasos.c +2 -2
@@ -218,7 +218,7 @@ static void pegasos_init(MachineState *machine)MemoryRegion *pci_mem, *mr;/* Articia S */ - pm->nb =DEVICE (sysbus_create_simple (TYPE_ARTICIA ,0xfe000000 ,NULL )); + pm->nb =DEVICE (sysbus_create_simple_orphan (TYPE_ARTICIA ,0xfe000000 ,NULL )); pci_mem =sysbus_mmio_get_region (SYS_BUS_DEVICE (pm->nb),1 ); mr =g_new (MemoryRegion,1 ); memory_region_init_alias(mr, OBJECT(pm->nb), "pci-mem-low", pci_mem,
@@ -233,7 +233,7 @@ static void pegasos_init(MachineState *machine) }case PEGASOS2 :/* Marvell Discovery II system controller */ - pm->nb =DEVICE (sysbus_create_simple (TYPE_MV64361 ,-1 , + pm->nb =DEVICE (sysbus_create_simple_orphan (TYPE_MV64361 ,-1 ,qdev_get_gpio_in (DEVICE (pm->cpu), PPC6xx_INPUT_INT))); pci_bus =mv64361_get_pci_bus (pm->nb,1 );break ;
hw/ppc/ppc440_bamboo.c +1 -1
@@ -183,7 +183,7 @@ static void bamboo_init(MachineState *machine)ppc4xx_sdram_ddr_enable (PPC4xx_SDRAM_DDR (dev));/* PCI */ - dev = sysbus_create_varargs(TYPE_PPC4xx_PCI_HOST, PPC440EP_PCI_CONFIG, + dev = sysbus_create_varargs_orphan(TYPE_PPC4xx_PCI_HOST, PPC440EP_PCI_CONFIG, qdev_get_gpio_in(uicdev, pci_irq_nrs[0]), qdev_get_gpio_in(uicdev, pci_irq_nrs[1]), qdev_get_gpio_in(uicdev, pci_irq_nrs[2]),
hw/ppc/sam460ex.c +4 -4
@@ -336,7 +336,7 @@ static void sam460ex_init(MachineState *machine)ppc4xx_sdram_ddr2_enable (PPC4xx_SDRAM_DDR2 (dev));/* IIC controllers and devices */ - dev =sysbus_create_simple (TYPE_PPC4xx_I2C,0x4ef600700 , + dev =sysbus_create_simple_orphan (TYPE_PPC4xx_I2C,0x4ef600700 ,qdev_get_gpio_in (uic[0 ],2 )); i2c =PPC4xx_I2C (dev)->bus;/* SPD EEPROM on RAM module */
@@ -347,7 +347,7 @@ static void sam460ex_init(MachineState *machine)/* RTC */ i2c_slave_create_simple (i2c,"m41t80" ,0x68 ); - dev =sysbus_create_simple (TYPE_PPC4xx_I2C,0x4ef600800 , + dev =sysbus_create_simple_orphan (TYPE_PPC4xx_I2C,0x4ef600800 ,qdev_get_gpio_in (uic[0 ],3 ));/* External bus controller */
@@ -387,7 +387,7 @@ static void sam460ex_init(MachineState *machine) l2cache_ram);/* USB */ -sysbus_create_simple (TYPE_PPC4xx_EHCI,0x4bffd0400 , +sysbus_create_simple_orphan (TYPE_PPC4xx_EHCI,0x4bffd0400 ,qdev_get_gpio_in (uic[2 ],29 )); dev =qdev_new_orphan ("sysbus-ohci" );qdev_prop_set_string (dev,"masterbus" ,"usb-bus.0" );
@@ -416,7 +416,7 @@ static void sam460ex_init(MachineState *machine)/* PCI bus */ /* All PCI irqs are connected to the same UIC pin (cf. UBoot source) */ - dev =sysbus_create_simple (TYPE_PPC440_PCIX_HOST ,0xc0ec00000 , + dev =sysbus_create_simple_orphan (TYPE_PPC440_PCIX_HOST ,0xc0ec00000 ,qdev_get_gpio_in (uic[1 ],0 ));sysbus_mmio_map (SYS_BUS_DEVICE (dev),1 ,0xc08000000 ); pci_bus =PCI_BUS (qdev_get_child_bus (dev,"pci.0" ));
hw/riscv/virt.c +2 -2
@@ -1474,7 +1474,7 @@ static void virt_machine_init(MachineState *machine)/* VirtIO MMIO devices */ for (i =0 ; i <VIRTIO_COUNT ; i++) { -sysbus_create_simple ("virtio-mmio" , +sysbus_create_simple_orphan ("virtio-mmio" , s->memmap[VIRT_VIRTIO ].base + i * s->memmap[VIRT_VIRTIO ].size,qdev_get_gpio_in (virtio_irqchip,VIRTIO_IRQ + i)); }
@@ -1487,7 +1487,7 @@ static void virt_machine_init(MachineState *machine)0 ,qdev_get_gpio_in (mmio_irqchip,UART0_IRQ ),399193 , serial_hd(0), DEVICE_LITTLE_ENDIAN); -sysbus_create_simple ("goldfish_rtc" , s->memmap[VIRT_RTC ].base, +sysbus_create_simple_orphan ("goldfish_rtc" , s->memmap[VIRT_RTC ].base,qdev_get_gpio_in (mmio_irqchip,RTC_IRQ ));for (i =0 ; i <ARRAY_SIZE (s->flash); i++) {
hw/sparc/sun4m.c +1 -1
@@ -1018,7 +1018,7 @@ static void sun4m_hw_init(MachineState *machine) slavio_irq[30], fdc_tc);if (hwdef->cs_base) { -sysbus_create_simple ("sun-CS4231" , hwdef->cs_base, +sysbus_create_simple_orphan ("sun-CS4231" , hwdef->cs_base, slavio_irq[5 ]); }
hw/vmapple/vmapple.c +2 -2
@@ -305,7 +305,7 @@ static void create_rtc(const VMAppleMachineState *vms)hwaddr base = vms->memmap[VMAPPLE_RTC ].base;int irq = vms->irqmap[VMAPPLE_RTC ]; -sysbus_create_simple ("pl031" , base,qdev_get_gpio_in (vms->gic, irq)); +sysbus_create_simple_orphan ("pl031" , base,qdev_get_gpio_in (vms->gic, irq)); }static DeviceState *gpio_key_dev;
@@ -331,7 +331,7 @@ static void create_gpio_devices(const VMAppleMachineState *vms, int gpio,sysbus_realize_and_unref (s, &error_fatal);memory_region_add_subregion (mem, base,sysbus_mmio_get_region (s,0 ));sysbus_connect_irq (s,0 ,qdev_get_gpio_in (vms->gic, irq)); - gpio_key_dev =sysbus_create_simple ("gpio-key" ,-1 , + gpio_key_dev =sysbus_create_simple_orphan ("gpio-key" ,-1 ,qdev_get_gpio_in (pl061_dev,3 )); }
hw/xen/xen-pvh-common.c +1 -1
@@ -173,7 +173,7 @@ static void xen_create_virtio_mmio_devices(XenPVHMachineState *s)qemu_irq irq =qemu_allocate_irq (xen_set_irq,NULL , s->cfg.virtio_mmio_irq_base + i); -sysbus_create_simple ("virtio-mmio" , base, irq); +sysbus_create_simple_orphan ("virtio-mmio" , base, irq); trace_xen_create_virtio_mmio_devices(i, s->cfg.virtio_mmio_irq_base + i,
include/hw/core/sysbus.h +28 -4
@@ -91,15 +91,39 @@ bool sysbus_realize_and_unref(SysBusDevice *dev, Error **errp);/* Call func for every dynamically created sysbus device in the system */ void foreach_dynamic_sysbus_device (FindSysbusDeviceFunc *func,void *opaque); -/* Legacy helper function for creating devices. */ -DeviceState *sysbus_create_varargs (const char *name, +/** +* sysbus_create_varargs: Create, parent and realize a sysbus device +* @parent: the QOM parent (usually the machine or containing device) +* @id: child<> property name +* @type: sysbus device type to create +* @addr: MMIO region 0 address, or -1 for none +* @...: NULL-terminated list of qemu_irq to connect +* +* Create a sysbus device via qdev_new(@parent, @id, @type), realize +* it, optionally map MMIO region 0 at @addr, and connect the given +* IRQs. The returned device is owned by @parent. +*/ +DeviceState *sysbus_create_varargs (Object *parent,const char *id, +const char *type,hwaddr addr, ...); + +static inline DeviceState *sysbus_create_simple (Object *parent, +const char *id, +const char *type, +hwaddr addr, +qemu_irq irq) +{ +return sysbus_create_varargs (parent, id, type, addr, irq,NULL ); +} + +/* Legacy helper function for creating unparented devices. */ +DeviceState *sysbus_create_varargs_orphan (const char *name,hwaddr addr, ...); -static inline DeviceState *sysbus_create_simple (const char *name, +static inline DeviceState *sysbus_create_simple_orphan (const char *name,hwaddr addr,qemu_irq irq) { -return sysbus_create_varargs (name, addr, irq,NULL ); +return sysbus_create_varargs_orphan (name, addr, irq,NULL ); }#endif /* HW_SYSBUS_H */
scripts/coccinelle/qom-parent/sysbus-create-orphan.cocci new file +18 -0
@@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// +// Rename sysbus_create_simple()/sysbus_create_varargs() to *_orphan() +// so that the short names can be reintroduced with a mandatory +// (parent, id, ...) signature. +// +// spatch --sp-file scripts/coccinelle/qom-parent/sysbus-create-orphan.cocci \ +// --in-place --include-headers --dir . + +@@ +@@ +- sysbus_create_simple ++ sysbus_create_simple_orphan + +@@ +@@ +- sysbus_create_varargs ++ sysbus_create_varargs_orphan
Signature · 1 line
2.47.1
Re: [RFC PATCH 004/134] sysbus: Make sysbus_create_simple()/_varargs() take a QOM parent
Quoted 91 lines · Alexander Graf
Sysbus is by far the largest producer of orphaned onboard devices:
of the ~1180 unparented device creation sites in the tree, well over half go throughsysbus_create_simple(),sysbus_create_varargs(), or qdev_new_orphan()+sysbus_realize_and_unref() open-coded.Apply the same rename-and-reintroduce treatment as
qdev_new():
mechanically rename the existing helpers to*_orphan()and reintroduce the short names with a leading (parent, id, ...) pair that plumbs down to the newqdev_new(). The parented versions callsysbus_realize()(not_and_unref) since the child<> property already holds the sole reference.The mechanical rename part is generated by
spatch --sp-file \ scripts/coccinelle/qom-parent/sysbus-create-orphan.cocci \ --in-place --include-headers --dir .or equivalently
git ls-files '*.[ch]' '*.[ch].inc' '*.rst' '*.py' | \ grep -v '^subprojects/' | \ xargs sed -i \ 's/\bsysbus_create_simple\b/sysbus_create_simple_orphan/g; s/\bsysbus_create_varargs\b/sysbus_create_varargs_orphan/g'Assisted-by KiroSigned-off-by Alexander Graf <[email protected]>--- hw/arm/allwinner-h3.c | 16 ++++----- hw/arm/collie.c | 2 +- hw/arm/exynos4210.c | 14 ++++---- hw/arm/fsl-imx6.c | 2 +- hw/arm/integratorcp.c | 18 +++++----- hw/arm/mps2.c | 6 ++-- hw/arm/musicpal.c | 18 +++++----- hw/arm/npcm7xx.c | 2 +- hw/arm/realview.c | 24 ++++++------- hw/arm/sbsa-ref.c | 6 ++-- hw/arm/stellaris.c | 8 ++--- hw/arm/strongarm.c | 10 +++--- hw/arm/versatilepb.c | 28 +++++++-------- hw/arm/vexpress.c | 20 +++++------ hw/arm/virt.c | 8 ++--- hw/arm/xilinx_zynq.c | 10 +++--- hw/core/sysbus.c | 35 ++++++++++++++++++- hw/i386/kvm/clock.c | 2 +- hw/i386/kvm/xen_evtchn.c | 2 +- hw/i386/kvm/xen_gnttab.c | 2 +- hw/i386/kvm/xen_overlay.c | 2 +- hw/i386/kvm/xen_primary_console.c | 2 +- hw/i386/kvm/xen_xenstore.c | 2 +- hw/i386/microvm.c | 2 +- hw/intc/apic_common.c | 2 +- hw/loongarch/virt.c | 2 +- hw/m68k/next-cube.c | 4 +-- hw/m68k/virt.c | 2 +- hw/mips/jazz.c | 2 +- hw/mips/loongson3_virt.c | 2 +- hw/or1k/virt.c | 2 +- hw/ppc/amigaone.c | 2 +- hw/ppc/e500.c | 2 +- hw/ppc/pegasos.c | 4 +-- hw/ppc/ppc440_bamboo.c | 2 +- hw/ppc/sam460ex.c | 8 ++--- hw/riscv/virt.c | 4 +-- hw/sparc/sun4m.c | 2 +- hw/vmapple/vmapple.c | 4 +-- hw/xen/xen-pvh-common.c | 2 +- include/hw/core/sysbus.h | 32 ++++++++++++++--- .../qom-parent/sysbus-create-orphan.cocci | 18 ++++++++++ 42 files changed, 206 insertions(+), 131 deletions(-)create mode 100644
scripts/coccinelle/qom-parent/sysbus-create-orphan.cocciinclude/hw/core/sysbus.h +6
-2@@ -91,15 +91,39 @@ bool sysbus_realize_and_unref(SysBusDevice *dev, Error **errp);/* Call func for every dynamically created sysbus device in the system */ void foreach_dynamic_sysbus_device (FindSysbusDeviceFunc *func,void *opaque); -/* Legacy helper function for creating devices. */ -DeviceState *sysbus_create_varargs(const char *name, +/** +* sysbus_create_varargs: Create, parent and realize a sysbus device +* @parent: the QOM parent (usually the machine or containing device) +* @id: child<> property name +* @type: sysbus device type to create +* @addr: MMIO region 0 address, or -1 for none
include/hw/core/sysbus.h bool sysbus_realize_and_unref(SysBusDevice *dev, Error **errp); · line 109
Quoted 10 lines
include/hw/core/sysbus.h +10
-0+* @...: NULL-terminated list of qemu_irq to connect +* +* Create a sysbus device via qdev_new(@parent, @id, @type), realize +* it, optionally map MMIO region 0 at @addr, and connect the given +* IRQs. The returned device is owned by @parent. +*/ +DeviceState *sysbus_create_varargs (Object *parent,const char *id, +const char *type,hwaddr addr, ...); + +static inline DeviceState *sysbus_create_simple(Object *parent,
Both are legacy. Updating the doc:
Quoted 11 lines
include/hw/core/sysbus.h +10
-0+const char *id, + const char *type, + hwaddr addr, + qemu_irq irq) +{ + return sysbus_create_varargs(parent, id, type, addr, irq, NULL); +} + +/* Legacy helper function for creating unparented devices. */ +DeviceState *sysbus_create_varargs_orphan (const char *name,hwaddr addr, ...);
RFC PATCH 5/134 pci: Make pci_new*()/pci_create_simple*() take a QOM parent
In reply to Alexander GrafSame rename-and-reintroduce treatment as qdev_new() and sysbus_create_*(): mechanically rename the four PCI creation helpers to *_orphan() and reintroduce the short names with a leading (parent, id, ...) pair.
The parented pci_create_simple*() variants call qdev_realize() (not pci_realize_and_unref()) since the child<> property already holds the sole reference.
The mechanical rename part is generated by
spatch --sp-file scripts/coccinelle/qom-parent/pci-new-orphan.cocci \
--in-place --include-headers --dir .
or equivalently
git ls-files '*.[ch]' '*.[ch].inc' '*.rst' '*.py' | \
grep -v '^subprojects/' | \
xargs sed -i \
's/\bpci_create_simple_multifunction\b/&_orphan/g;
s/\bpci_create_simple\b/&_orphan/g;
s/\bpci_new_multifunction\b/&_orphan/g;
s/\bpci_new\b/&_orphan/g'--- hw/alpha/dp264.c | 4 +- hw/arm/realview.c | 4 +- hw/arm/sbsa-ref.c | 2 +- hw/arm/versatilepb.c | 4 +- hw/hppa/machine.c | 8 +-- hw/i386/pc.c | 2 +- hw/i386/pc_piix.c | 4 +- hw/i386/pc_q35.c | 10 +-- hw/mips/boston.c | 2 +- hw/mips/fuloong2e.c | 4 +- hw/mips/loongson3_virt.c | 2 +- hw/mips/malta.c | 2 +- hw/pci-host/articia.c | 4 +- hw/pci-host/bonito.c | 2 +- hw/pci-host/grackle.c | 2 +- hw/pci-host/gt64120.c | 2 +- hw/pci-host/i440fx.c | 2 +- hw/pci-host/mv64361.c | 2 +- hw/pci-host/pnv_phb.c | 2 +- hw/pci-host/ppc4xx_pci.c | 2 +- hw/pci-host/ppce500.c | 2 +- hw/pci-host/raven.c | 2 +- hw/pci-host/sabre.c | 6 +- hw/pci-host/sh_pci.c | 2 +- hw/pci-host/uninorth.c | 8 +-- hw/pci/pci.c | 65 +++++++++++++++---- hw/pci/pcie_sriov.c | 2 +- hw/ppc/amigaone.c | 2 +- hw/ppc/mac_newworld.c | 4 +- hw/ppc/mac_oldworld.c | 4 +- hw/ppc/pegasos.c | 2 +- hw/ppc/prep.c | 4 +- hw/ppc/sam460ex.c | 4 +- hw/ppc/spapr.c | 2 +- hw/riscv/boston-aia.c | 2 +- hw/sparc64/sun4u.c | 8 +-- hw/vfio/igd.c | 2 +- hw/xen/xen_pt_graphics.c | 2 +- include/hw/pci/pci.h | 18 +++-- .../qom-parent/pci-new-orphan.cocci | 28 ++++++++ 40 files changed, 157 insertions(+), 78 deletions(-) create mode 100644 scripts/coccinelle/qom-parent/pci-new-orphan.cocci
hw/alpha/dp264.c +2 -2
@@ -110,7 +110,7 @@ static void clipper_init(MachineState *machine)* Importantly, we need to provide a PCI device node for it, otherwise * some operating systems won't notice there's an ISA bus to configure. */ - i82378_dev =DEVICE (pci_create_simple (pci_bus,PCI_DEVFN (7 ,0 ),"i82378" )); + i82378_dev =DEVICE (pci_create_simple_orphan (pci_bus,PCI_DEVFN (7 ,0 ),"i82378" )); isa_bus =ISA_BUS (qdev_get_child_bus (i82378_dev,"isa.0" ));/* Connect the ISA PIC to the Typhoon IRQ used for ISA interrupts. */
@@ -129,7 +129,7 @@ static void clipper_init(MachineState *machine)isa_create_simple (isa_bus,TYPE_SMC37C669_SUPERIO );/* IDE disk setup. */ - pci_dev =pci_create_simple (pci_bus,-1 ,"cmd646-ide" ); + pci_dev =pci_create_simple_orphan (pci_bus,-1 ,"cmd646-ide" );pci_ide_create_devs (pci_dev);/* Load PALcode. Given that this is not "real" cpu palcode,
hw/arm/realview.c +2 -2
@@ -297,11 +297,11 @@ static void realview_init(MachineState *machine,sysbus_connect_irq (busdev,3 , pic[51 ]); pci_bus = (PCIBus *)qdev_get_child_bus (dev,"pci" );if (machine_usb (machine)) { -pci_create_simple (pci_bus,-1 ,"pci-ohci" ); +pci_create_simple_orphan (pci_bus,-1 ,"pci-ohci" ); } n =drive_get_max_bus (IF_SCSI );while (n >=0 ) { - dev =DEVICE (pci_create_simple (pci_bus,-1 ,"lsi53c895a" )); + dev =DEVICE (pci_create_simple_orphan (pci_bus,-1 ,"lsi53c895a" ));lsi53c8xx_handle_legacy_cmdline (dev); n--; }
hw/arm/sbsa-ref.c +1 -1
@@ -695,7 +695,7 @@ static void create_pcie(SBSAMachineState *sms,pci_init_nic_devices (pci->bus, mc->default_nic); -pci_create_simple (pci->bus,-1 ,"bochs-display" ); +pci_create_simple_orphan (pci->bus,-1 ,"bochs-display" );create_smmu (sms, pci->bus, sysmem, secure_sysmem); }
hw/arm/versatilepb.c +2 -2
@@ -270,11 +270,11 @@ static void versatile_init(MachineState *machine, int board_id)pci_init_nic_devices (pci_bus,"rtl8139" );if (machine_usb (machine)) { -pci_create_simple (pci_bus,-1 ,"pci-ohci" ); +pci_create_simple_orphan (pci_bus,-1 ,"pci-ohci" ); } n =drive_get_max_bus (IF_SCSI );while (n >=0 ) { - dev =DEVICE (pci_create_simple (pci_bus,-1 ,"lsi53c895a" )); + dev =DEVICE (pci_create_simple_orphan (pci_bus,-1 ,"lsi53c895a" ));lsi53c8xx_handle_legacy_cmdline (dev); n--; }
hw/hppa/machine.c +4 -4
@@ -428,7 +428,7 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,if (pci_bus &&hppa_is_pa20 (&cpu[0 ]->env)) {/* BMC board: HP Diva GSP PCI card */ - pci_dev =pci_new_multifunction (PCI_DEVFN (2 ,0 ),"diva-gsp" ); + pci_dev =pci_new_multifunction_orphan (PCI_DEVFN (2 ,0 ),"diva-gsp" );if (!lasi_dev) {/* bind default keyboard/serial to Diva card */ qdev_prop_set_chr (DEVICE (pci_dev),"chardev1" ,serial_hd (0 ));
@@ -443,7 +443,7 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,if (!lasi_dev && machine->enable_graphics &&defaults_enabled ()) {USBBus *usb_bus; -pci_create_simple (pci_bus,-1 ,"pci-ohci" ); +pci_create_simple_orphan (pci_bus,-1 ,"pci-ohci" ); usb_bus =USB_BUS (object_resolve_type_unambiguous (TYPE_USB_BUS , &error_abort));usb_create_simple (usb_bus,"usb-kbd" );
@@ -721,7 +721,7 @@ static void machine_HP_B160L_init(MachineState *machine)/* SCSI disk setup. */ if (drive_get_max_bus (IF_SCSI ) >=0 ) { - dev =DEVICE (pci_create_simple (pci_bus,-1 ,"lsi53c895a" )); + dev =DEVICE (pci_create_simple_orphan (pci_bus,-1 ,"lsi53c895a" ));lsi53c8xx_handle_legacy_cmdline (dev); }
@@ -773,7 +773,7 @@ static void machine_HP_C3700_init(MachineState *machine)/* SCSI disk setup. */ if (drive_get_max_bus (IF_SCSI ) >=0 ) { -DeviceState *dev =DEVICE (pci_create_simple (pci_bus,-1 ,"lsi53c895a" )); +DeviceState *dev =DEVICE (pci_create_simple_orphan (pci_bus,-1 ,"lsi53c895a" ));lsi53c8xx_handle_legacy_cmdline (dev); }
hw/i386/pc.c +1 -1
@@ -1104,7 +1104,7 @@ void pc_basic_device_init(struct PCMachineState *pcms,xen_gnttab_create ();xen_xenstore_create ();if (pcms->pcibus) { -pci_create_simple (pcms->pcibus,-1 ,"xen-platform" ); +pci_create_simple_orphan (pcms->pcibus,-1 ,"xen-platform" ); }xen_bus_init (); }
hw/i386/pc_piix.c +2 -2
@@ -236,7 +236,7 @@ static void pc_init1(MachineState *machine, const char *pci_type) gsi_state =pc_gsi_create (&x86ms->gsi, true); - pci_dev =pci_new_multifunction (-1 , pcms->south_bridge); + pci_dev =pci_new_multifunction_orphan (-1 , pcms->south_bridge);object_property_set_bool (OBJECT (pci_dev),"has-usb" ,machine_usb (machine), &error_abort); object_property_set_bool(OBJECT(pci_dev), "has-acpi",
@@ -384,7 +384,7 @@ static void pc_xen_hvm_init(MachineState *machine) : TYPE_I440FX_PCI_DEVICE);xen_igd_reserve_slot (pcms->pcibus); - pci_create_simple(pcms->pcibus, -1, "xen-platform"); + pci_create_simple_orphan(pcms->pcibus, -1, "xen-platform"); }#endif
hw/i386/pc_q35.c +5 -5
@@ -114,12 +114,12 @@ static int ehci_create_ich9_with_companions(PCIBus *bus, int slot)return -1 ; } - ehci =pci_new_multifunction (PCI_DEVFN (slot,7 ), name); + ehci =pci_new_multifunction_orphan (PCI_DEVFN (slot,7 ), name);pci_realize_and_unref (ehci, bus, &error_fatal); usbbus =QLIST_FIRST (&ehci->qdev.child_bus);for (i =0 ; i <3 ; i++) { - uhci =pci_new_multifunction (PCI_DEVFN (slot, comp[i].func), + uhci =pci_new_multifunction_orphan (PCI_DEVFN (slot, comp[i].func), comp[i].name);qdev_prop_set_string (&uhci->qdev,"masterbus" , usbbus->name);qdev_prop_set_uint32 (&uhci->qdev,"firstport" , comp[i].port);
@@ -235,7 +235,7 @@ static void pc_q35_init(MachineState *machine) gsi_state =pc_gsi_create (&x86ms->gsi, true);/* create ISA bus */ - lpc =pci_new_multifunction (PCI_DEVFN (ICH9_LPC_DEV ,ICH9_LPC_FUNC ), + lpc =pci_new_multifunction_orphan (PCI_DEVFN (ICH9_LPC_DEV ,ICH9_LPC_FUNC ),TYPE_ICH9_LPC_DEVICE ); lpc_dev =DEVICE (lpc); qdev_prop_set_bit(lpc_dev, "smm-enabled",
@@ -290,7 +290,7 @@ static void pc_q35_init(MachineState *machine)AHCIPCIState *ich9;/* ahci and SATA device, for q35 1 ahci controller is built-in */ - pdev =pci_create_simple_multifunction (pcms->pcibus, + pdev =pci_create_simple_multifunction_orphan (pcms->pcibus,PCI_DEVFN (ICH9_SATA1_DEV ,ICH9_SATA1_FUNC ),"ich9-ahci" );
@@ -311,7 +311,7 @@ static void pc_q35_init(MachineState *machine)PCIDevice *smb;/* TODO: Populate SPD eeprom data. */ - smb =pci_create_simple_multifunction (pcms->pcibus, + smb =pci_create_simple_multifunction_orphan (pcms->pcibus,PCI_DEVFN (ICH9_SMB_DEV ,ICH9_SMB_FUNC ),TYPE_ICH9_SMB_DEVICE );
hw/mips/boston.c +1 -1
@@ -769,7 +769,7 @@ static void boston_mach_init(MachineState *machine)qemu_chr_fe_set_handlers (&s->lcd_display,NULL ,NULL , boston_lcd_event,NULL , s,NULL , true); - pdev =pci_create_simple_multifunction (&PCI_BRIDGE (&pcie2->root)->sec_bus, + pdev =pci_create_simple_multifunction_orphan (&PCI_BRIDGE (&pcie2->root)->sec_bus,PCI_DEVFN (0 ,0 ),TYPE_ICH9_AHCI ); ich9 =ICH9_AHCI (pdev);g_assert (ARRAY_SIZE (hd) == ich9->ahci.ports);
hw/mips/fuloong2e.c +2 -2
@@ -286,7 +286,7 @@ static void mips_fuloong2e_init(MachineState *machine) pci_bus =bonito_init ((qemu_irq *)&(env->irq[2 ]));/* South bridge -> IP5 */ - pci_dev =pci_new_multifunction (PCI_DEVFN (FULOONG2E_VIA_SLOT ,0 ), + pci_dev =pci_new_multifunction_orphan (PCI_DEVFN (FULOONG2E_VIA_SLOT ,0 ),TYPE_VT82C686B_ISA );/* Set properties on individual devices before realizing the south bridge */
@@ -312,7 +312,7 @@ static void mips_fuloong2e_init(MachineState *machine)/* GPU */ if (vga_interface_type !=VGA_NONE ) { vga_interface_created = true; - pci_dev =pci_new (-1 ,"ati-vga" ); + pci_dev =pci_new_orphan (-1 ,"ati-vga" ); dev =DEVICE (pci_dev);qdev_prop_set_uint32 (dev,"vgamem_mb" ,16 );qdev_prop_set_uint16 (dev,"x-device-id" ,0x5159 );
hw/mips/loongson3_virt.c +1 -1
@@ -465,7 +465,7 @@ static inline void loongson3_virt_devices_init(MachineState *machine,if (defaults_enabled () &&object_class_by_name ("pci-ohci" )) {USBBus *usb_bus; -pci_create_simple (pci_bus,-1 ,"pci-ohci" ); +pci_create_simple_orphan (pci_bus,-1 ,"pci-ohci" ); usb_bus =USB_BUS (object_resolve_type_unambiguous (TYPE_USB_BUS , &error_abort));usb_create_simple (usb_bus,"usb-kbd" );
hw/mips/malta.c +1 -1
@@ -1233,7 +1233,7 @@ void mips_malta_init(MachineState *machine)pci_bus_map_irqs (pci_bus, malta_pci_slot_get_pirq);/* Southbridge */ - piix4 =pci_new_multifunction (PIIX4_PCI_DEVFN ,TYPE_PIIX4_PCI_DEVICE ); + piix4 =pci_new_multifunction_orphan (PIIX4_PCI_DEVFN ,TYPE_PIIX4_PCI_DEVICE );qdev_prop_set_uint32 (DEVICE (piix4),"smb_io_base" ,0x1100 );pci_realize_and_unref (piix4, pci_bus, &error_fatal); isa_bus =ISA_BUS (qdev_get_child_bus (DEVICE (piix4),"isa.0" ));
hw/pci-host/articia.c +2 -2
@@ -185,10 +185,10 @@ static void articia_realize(DeviceState *dev, Error **errp) h->bus =pci_register_root_bus (dev,NULL , articia_pcihost_set_irq, amigaone_pcihost_bus0_map_irq, dev, &s->mem, &s->io,PCI_DEVFN (8 ,0 ),4 ,TYPE_PCI_BUS ); - pdev =pci_create_simple_multifunction (h->bus,PCI_DEVFN (0 ,0 ), + pdev =pci_create_simple_multifunction_orphan (h->bus,PCI_DEVFN (0 ,0 ),TYPE_ARTICIA_PCI_HOST );ARTICIA_PCI_HOST (pdev)->as = s; -pci_create_simple (h->bus,PCI_DEVFN (0 ,1 ),TYPE_ARTICIA_PCI_BRIDGE ); +pci_create_simple_orphan (h->bus,PCI_DEVFN (0 ,1 ),TYPE_ARTICIA_PCI_BRIDGE );sysbus_init_mmio (SYS_BUS_DEVICE (dev), &s->reg);sysbus_init_mmio (SYS_BUS_DEVICE (dev), &s->mem);
hw/pci-host/bonito.c +1 -1
@@ -747,7 +747,7 @@ PCIBus *bonito_init(qemu_irq *pic) pcihost->pic = pic;sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); - d =pci_new (PCI_DEVFN (0 ,0 ),TYPE_PCI_BONITO ); + d =pci_new_orphan (PCI_DEVFN (0 ,0 ),TYPE_PCI_BONITO ); s =PCI_BONITO (d); s->pcihost = pcihost; pcihost->pci_dev = s;
hw/pci-host/grackle.c +1 -1
@@ -60,7 +60,7 @@ static void grackle_realize(DeviceState *dev, Error **errp) &s->pci_io, 0, 4, TYPE_PCI_BUS); -pci_create_simple (phb->bus,0 ,"grackle" ); +pci_create_simple_orphan (phb->bus,0 ,"grackle" ); }static void grackle_init (Object *obj)
hw/pci-host/gt64120.c +1 -1
@@ -1204,7 +1204,7 @@ static void gt64120_realize(DeviceState *dev, Error **errp)get_system_io (), PCI_DEVFN(18, 0), TYPE_PCI_BUS); -pci_create_simple (phb->bus,PCI_DEVFN (0 ,0 ),"gt64120_pci" ); +pci_create_simple_orphan (phb->bus,PCI_DEVFN (0 ,0 ),"gt64120_pci" );memory_region_init_io (&phb->conf_mem,OBJECT (phb), &pci_host_conf_le_ops, s,"pci-conf-idx" ,4 );
hw/pci-host/i440fx.c +1 -1
@@ -282,7 +282,7 @@ static void i440fx_pcihost_realize(DeviceState *dev, Error **errp) s->io_memory, 0, TYPE_PCI_BUS); phb->bus = b; - d =pci_create_simple (b,0 , s->pci_type); + d =pci_create_simple_orphan (b,0 , s->pci_type); f =I440FX_PCI_DEVICE (d); range_set_bounds(&s->pci_hole, s->below_4g_mem_size,
hw/pci-host/mv64361.c +1 -1
@@ -94,7 +94,7 @@ static void mv64361_pcihost_realize(DeviceState *dev, Error **errp) pci_swizzle_map_irq_fn, dev, &s->mem, &s->io, 0, 4, TYPE_PCI_BUS);g_free (name); -pci_create_simple (h->bus,0 ,TYPE_MV64361_PCI_BRIDGE ); +pci_create_simple_orphan (h->bus,0 ,TYPE_MV64361_PCI_BRIDGE );qdev_init_gpio_out (dev, s->irq,ARRAY_SIZE (s->irq)); }
hw/pci-host/pnv_phb.c +1 -1
@@ -167,7 +167,7 @@ static void pnv_phb_realize(DeviceState *dev, Error **errp) }if (defaults_enabled ()) { -PCIDevice *root =pci_new (PCI_DEVFN (0 ,0 ),TYPE_PNV_PHB_ROOT_PORT ); +PCIDevice *root =pci_new_orphan (PCI_DEVFN (0 ,0 ),TYPE_PNV_PHB_ROOT_PORT );pci_realize_and_unref (root, pci->bus, errp); }
hw/pci-host/ppc4xx_pci.c +1 -1
@@ -332,7 +332,7 @@ static void ppc4xx_pcihost_realize(DeviceState *dev, Error **errp) TYPE_PCI_BUS); h->bus = b; -pci_create_simple (b,0 , TYPE_PPC4xx_HOST_BRIDGE); +pci_create_simple_orphan (b,0 , TYPE_PPC4xx_HOST_BRIDGE);/* XXX split into 2 memory regions, one for config space, one for regs */ memory_region_init (&s->container,OBJECT (s),"pci-container" ,PCI_ALL_SIZE );
hw/pci-host/ppce500.c +1 -1
@@ -473,7 +473,7 @@ static void e500_pcihost_realize(DeviceState *dev, Error **errp)address_space_init (&s->bm_as, &s->bm,"pci-bm" );pci_setup_iommu (b, &ppce500_iommu_ops, s); -pci_create_simple (b,0 ,TYPE_PPC_E500_PCI_BRIDGE ); +pci_create_simple_orphan (b,0 ,TYPE_PPC_E500_PCI_BRIDGE );memory_region_init (&s->container,OBJECT (h),"pci-container" ,PCIE500_ALL_SIZE ); memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_be_ops, h,
hw/pci-host/raven.c +1 -1
@@ -281,7 +281,7 @@ static void raven_pcihost_realizefn(DeviceState *d, Error **errp) "pci-intack", 1);memory_region_add_subregion (address_space_mem,0xbffffff0 , &s->pci_intack); -pci_create_simple (h->bus,PCI_DEVFN (0 ,0 ),TYPE_RAVEN_PCI_DEVICE ); +pci_create_simple_orphan (h->bus,PCI_DEVFN (0 ,0 ),TYPE_RAVEN_PCI_DEVICE );address_space_init (&s->bm_as, &s->bm,"raven-bm" );pci_setup_iommu (h->bus, &raven_iommu_ops, s);
hw/pci-host/sabre.c +3 -3
@@ -383,7 +383,7 @@ static void sabre_realize(DeviceState *dev, Error **errp) &s->pci_ioport, 0, 0x40, TYPE_PCI_BUS); -pci_create_simple (phb->bus,0 ,TYPE_SABRE_PCI_DEVICE ); +pci_create_simple_orphan (phb->bus,0 ,TYPE_SABRE_PCI_DEVICE );/* IOMMU */ memory_region_add_subregion_overlap(&s->sabre_config, 0x200,
@@ -391,12 +391,12 @@ static void sabre_realize(DeviceState *dev, Error **errp)pci_setup_iommu (phb->bus, &sabre_iommu_ops, s->iommu);/* APB secondary busses */ - pci_dev =pci_new_multifunction (PCI_DEVFN (1 ,0 ),TYPE_SIMBA_PCI_BRIDGE ); + pci_dev =pci_new_multifunction_orphan (PCI_DEVFN (1 ,0 ),TYPE_SIMBA_PCI_BRIDGE ); s->bridgeB =PCI_BRIDGE (pci_dev);pci_bridge_map_irq (s->bridgeB,"pciB" , pci_simbaB_map_irq);pci_realize_and_unref (pci_dev, phb->bus, &error_fatal); - pci_dev =pci_new_multifunction (PCI_DEVFN (1 ,1 ),TYPE_SIMBA_PCI_BRIDGE ); + pci_dev =pci_new_multifunction_orphan (PCI_DEVFN (1 ,1 ),TYPE_SIMBA_PCI_BRIDGE ); s->bridgeA =PCI_BRIDGE (pci_dev);pci_bridge_map_irq (s->bridgeA,"pciA" , pci_simbaA_map_irq);pci_realize_and_unref (pci_dev, phb->bus, &error_fatal);
hw/pci-host/sh_pci.c +1 -1
@@ -142,7 +142,7 @@ static void sh_pcic_host_realize(DeviceState *dev, Error **errp)sysbus_init_mmio (sbd, &s->memconfig_a7);memory_region_add_subregion (get_system_memory (),0xfe240000 , &s->isa); - s->dev =pci_create_simple (phb->bus,PCI_DEVFN (0 ,0 ),"sh_pci_host" ); + s->dev =pci_create_simple_orphan (phb->bus,PCI_DEVFN (0 ,0 ),"sh_pci_host" ); }static void sh_pcic_pci_realize (PCIDevice *d,Error **errp)
hw/pci-host/uninorth.c +4 -4
@@ -126,7 +126,7 @@ static void pci_unin_main_realize(DeviceState *dev, Error **errp) &s->pci_io, PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); -pci_create_simple (h->bus,PCI_DEVFN (11 ,0 ),"uni-north-pci" ); +pci_create_simple_orphan (h->bus,PCI_DEVFN (11 ,0 ),"uni-north-pci" );/* * DEC 21154 bridge was unused for many years, this comment is
@@ -176,7 +176,7 @@ static void pci_u3_agp_realize(DeviceState *dev, Error **errp) &s->pci_io, PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); -pci_create_simple (h->bus,PCI_DEVFN (11 ,0 ),"u3-agp" ); +pci_create_simple_orphan (h->bus,PCI_DEVFN (11 ,0 ),"u3-agp" ); }static void pci_u3_agp_init (Object *obj)
@@ -220,7 +220,7 @@ static void pci_unin_agp_realize(DeviceState *dev, Error **errp) &s->pci_io, PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); -pci_create_simple (h->bus,PCI_DEVFN (11 ,0 ),"uni-north-agp" ); +pci_create_simple_orphan (h->bus,PCI_DEVFN (11 ,0 ),"uni-north-agp" ); }static void pci_unin_agp_init (Object *obj)
@@ -253,7 +253,7 @@ static void pci_unin_internal_realize(DeviceState *dev, Error **errp) &s->pci_io, PCI_DEVFN(14, 0), 4, TYPE_PCI_BUS); -pci_create_simple (h->bus,PCI_DEVFN (14 ,0 ),"uni-north-internal-pci" ); +pci_create_simple_orphan (h->bus,PCI_DEVFN (14 ,0 ),"uni-north-internal-pci" ); }static void pci_unin_internal_init (Object *obj)
hw/pci/pci.c +53 -12
104 lines not on this page · raw message
hw/pci/pcie_sriov.c +1 -1
@@ -171,7 +171,7 @@ bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, dev->exp.sriov_pf.vf = g_new(PCIDevice *, total_vfs);for (uint16_t i =0 ; i < total_vfs; i++) { -PCIDevice *vf =pci_new (devfn, vfname); +PCIDevice *vf =pci_new_orphan (devfn, vfname); vf->exp.sriov_vf.pf = dev; vf->exp.sriov_vf.vf_number = i;
hw/ppc/amigaone.c +1 -1
@@ -355,7 +355,7 @@ static void amigaone_init(MachineState *machine) pci_bus =PCI_BUS (qdev_get_child_bus (dev,"pci.0" ));/* VIA VT82c686B South Bridge (multifunction PCI device) */ - via =OBJECT (pci_create_simple_multifunction (pci_bus,PCI_DEVFN (7 ,0 ), + via =OBJECT (pci_create_simple_multifunction_orphan (pci_bus,PCI_DEVFN (7 ,0 ),TYPE_VT82C686B_ISA )); object_property_add_alias(OBJECT(machine), "rtc-time", object_resolve_path_component(via, "rtc"),
hw/ppc/mac_newworld.c +2 -2
@@ -348,7 +348,7 @@ static void ppc_core99_init(MachineState *machine) pci_bus =PCI_HOST_BRIDGE (uninorth_pci_dev)->bus;/* MacIO */ - macio =OBJECT (pci_new (-1 ,TYPE_NEWWORLD_MACIO )); + macio =OBJECT (pci_new_orphan (-1 ,TYPE_NEWWORLD_MACIO )); dev =DEVICE (macio);qdev_prop_set_uint64 (dev,"frequency" , tbfreq);qdev_prop_set_bit (dev,"has-pmu" , has_pmu);
@@ -416,7 +416,7 @@ static void ppc_core99_init(MachineState *machine) }if (machine->usb) { -pci_create_simple (pci_bus,-1 ,"pci-ohci" ); +pci_create_simple_orphan (pci_bus,-1 ,"pci-ohci" );/* U3 needs to use USB for input because Linux doesn't support via-cuda on PPC64 */
hw/ppc/mac_oldworld.c +2 -2
@@ -229,7 +229,7 @@ static void ppc_heathrow_init(MachineState *machine) pci_bus =PCI_HOST_BRIDGE (grackle_dev)->bus;/* MacIO */ - macio =OBJECT (pci_new (PCI_DEVFN (16 ,0 ),TYPE_OLDWORLD_MACIO )); + macio =OBJECT (pci_new_orphan (PCI_DEVFN (16 ,0 ),TYPE_OLDWORLD_MACIO ));qdev_prop_set_uint64 (DEVICE (macio),"frequency" , tbfreq); dev =DEVICE (object_resolve_path_component (macio,"escc" ));
@@ -285,7 +285,7 @@ static void ppc_heathrow_init(MachineState *machine)qdev_realize_and_unref (dev, adb_bus, &error_fatal);if (machine_usb (machine)) { -pci_create_simple (pci_bus,-1 ,"pci-ohci" ); +pci_create_simple_orphan (pci_bus,-1 ,"pci-ohci" ); }if (!graphic_width) {
hw/ppc/pegasos.c +1 -1
@@ -241,7 +241,7 @@ static void pegasos_init(MachineState *machine)/* VIA VT8231 South Bridge (multifunction PCI device) */ devfn =PCI_DEVFN (pm->type ==PEGASOS1 ?7 :12 ,0 ); - pm->sb =DEVICE (pci_new_multifunction (devfn,TYPE_VT8231_ISA )); + pm->sb =DEVICE (pci_new_multifunction_orphan (devfn,TYPE_VT8231_ISA )); via =OBJECT (pm->sb);/* Set properties on individual devices before realizing the south bridge */
hw/ppc/prep.c +2 -2
@@ -300,7 +300,7 @@ static void ibm_40p_init(MachineState *machine) }/* PCI -> ISA bridge */ - i82378_dev =DEVICE (pci_new (PCI_DEVFN (11 ,0 ),"i82378" )); + i82378_dev =DEVICE (pci_new_orphan (PCI_DEVFN (11 ,0 ),"i82378" ));qdev_realize_and_unref (i82378_dev,BUS (pci_bus), &error_fatal);qdev_connect_gpio_out (i82378_dev,0 ,qdev_get_gpio_in (DEVICE (cpu), PPC6xx_INPUT_INT));
@@ -350,7 +350,7 @@ static void ibm_40p_init(MachineState *machine)qdev_prop_set_uint32 (dev,"config" ,12 );isa_realize_and_unref (isa_dev, isa_bus, &error_fatal); - dev =DEVICE (pci_create_simple (pci_bus,PCI_DEVFN (1 ,0 ),"lsi53c810" )); + dev =DEVICE (pci_create_simple_orphan (pci_bus,PCI_DEVFN (1 ,0 ),"lsi53c810" ));lsi53c8xx_handle_legacy_cmdline (dev);qdev_connect_gpio_out (dev,0 ,qdev_get_gpio_in (i82378_dev,13 ));
hw/ppc/sam460ex.c +2 -2
@@ -422,14 +422,14 @@ static void sam460ex_init(MachineState *machine) pci_bus =PCI_BUS (qdev_get_child_bus (dev,"pci.0" ));/* PCI devices */ -pci_create_simple (pci_bus,PCI_DEVFN (6 ,0 ),"sm501" ); +pci_create_simple_orphan (pci_bus,PCI_DEVFN (6 ,0 ),"sm501" );/* * SoC has a single SATA port but we don't emulate that * However, firmware and usual clients have driver for SiI311x * PCI SATA card so add one for convenience by default */ if (defaults_enabled ()) { -PCIIDEState *s =PCI_IDE (pci_create_simple (pci_bus,-1 ,"sii3112" )); +PCIIDEState *s =PCI_IDE (pci_create_simple_orphan (pci_bus,-1 ,"sii3112" ));DriveInfo *di; di =drive_get_by_index (IF_IDE ,0 );
hw/ppc/spapr.c +1 -1
@@ -3075,7 +3075,7 @@ static void spapr_machine_init(MachineState *machine) }if (machine->usb) { -pci_create_simple (phb->bus,-1 ,"nec-usb-xhci" ); +pci_create_simple_orphan (phb->bus,-1 ,"nec-usb-xhci" );if (has_vga) {USBBus *usb_bus;
hw/riscv/boston-aia.c +1 -1
@@ -418,7 +418,7 @@ static void boston_mach_init(MachineState *machine)qemu_chr_fe_set_handlers (&s->lcd_display,NULL ,NULL , boston_lcd_event,NULL , s,NULL , true); - pdev =pci_create_simple_multifunction (&PCI_BRIDGE (&pcie2->root)->sec_bus, + pdev =pci_create_simple_multifunction_orphan (&PCI_BRIDGE (&pcie2->root)->sec_bus,PCI_DEVFN (0 ,0 ),TYPE_ICH9_AHCI ); ich9 =ICH9_AHCI (pdev);g_assert (ARRAY_SIZE (hd) == ich9->ahci.ports);
hw/sparc64/sun4u.c +4 -4
@@ -599,7 +599,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem,pci_bus_set_slot_reserved_mask (pci_busA,0xfffffff1 );pci_bus_set_slot_reserved_mask (pci_busB,0xfffffff0 ); - ebus =pci_new_multifunction (PCI_DEVFN (1 ,0 ),TYPE_EBUS ); + ebus =pci_new_multifunction_orphan (PCI_DEVFN (1 ,0 ),TYPE_EBUS );qdev_prop_set_uint64 (DEVICE (ebus),"console-serial-base" , hwdef->console_serial_base);pci_realize_and_unref (ebus, pci_busA, &error_fatal);
@@ -618,7 +618,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem,switch (vga_interface_type) {case VGA_STD : -pci_create_simple (pci_busA,PCI_DEVFN (2 ,0 ),"VGA" ); +pci_create_simple_orphan (pci_busA,PCI_DEVFN (2 ,0 ),"VGA" ); vga_interface_created = true;break ;case VGA_NONE :
@@ -632,7 +632,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem, nd =qemu_find_nic_info (mc->default_nic, true,NULL );if (nd) { - pci_dev =pci_new_multifunction (PCI_DEVFN (1 ,1 ), mc->default_nic); + pci_dev =pci_new_multifunction_orphan (PCI_DEVFN (1 ,1 ), mc->default_nic); dev = &pci_dev->qdev;qdev_set_nic_properties (dev, nd);pci_realize_and_unref (pci_dev, pci_busA, &error_fatal);
@@ -648,7 +648,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem,qemu_macaddr_default_if_unset (&macaddr); } - pci_dev =pci_new (PCI_DEVFN (3 ,0 ),"cmd646-ide" ); + pci_dev =pci_new_orphan (PCI_DEVFN (3 ,0 ),"cmd646-ide" );qdev_prop_set_uint32 (&pci_dev->qdev,"secondary" ,1 );pci_realize_and_unref (pci_dev, pci_busA, &error_fatal);pci_ide_create_devs (pci_dev);
hw/vfio/igd.c +1 -1
@@ -334,7 +334,7 @@ static int vfio_pci_igd_lpc_init(VFIOPCIDevice *vdev, lpc_bridge =pci_find_device (pci_device_root_bus (pdev),0 ,PCI_DEVFN (0x1f ,0 ));if (!lpc_bridge) { - lpc_bridge =pci_create_simple (pci_device_root_bus (pdev), + lpc_bridge =pci_create_simple_orphan (pci_device_root_bus (pdev),PCI_DEVFN (0x1f ,0 ),"vfio-pci-igd-lpc-bridge" ); }
hw/xen/xen_pt_graphics.c +1 -1
@@ -399,7 +399,7 @@ void xen_igd_passthrough_isa_bridge_create(XenPCIPassthroughState *s, }/* Currently IGD drivers always need to access PCH by 1f.0. */ - bridge_dev =pci_create_simple (bus,PCI_DEVFN (0x1f ,0 ), + bridge_dev =pci_create_simple_orphan (bus,PCI_DEVFN (0x1f ,0 ),"igd-passthrough-isa-bridge" );/*
include/hw/pci/pci.h +14 -4
@@ -1088,13 +1088,23 @@ pci_set_quad_by_mask(uint8_t *config, uint64_t mask, uint64_t reg)pci_set_quad (config, (~mask & val) | (mask & rval)); } -PCIDevice *pci_new_multifunction (int devfn,const char *name); -PCIDevice *pci_new (int devfn,const char *name); +PCIDevice *pci_new_multifunction (Object *parent,const char *id, +int devfn,const char *type); +PCIDevice *pci_new (Object *parent,const char *id, +int devfn,const char *type); +PCIDevice *pci_create_simple_multifunction (Object *parent,const char *id, +PCIBus *bus,int devfn, +const char *type); +PCIDevice *pci_create_simple (Object *parent,const char *id, +PCIBus *bus,int devfn,const char *type); + +PCIDevice *pci_new_multifunction_orphan (int devfn,const char *name); +PCIDevice *pci_new_orphan (int devfn,const char *name);bool pci_realize_and_unref (PCIDevice *dev,PCIBus *bus,Error **errp); -PCIDevice *pci_create_simple_multifunction (PCIBus *bus,int devfn, +PCIDevice *pci_create_simple_multifunction_orphan (PCIBus *bus,int devfn,const char *name); -PCIDevice *pci_create_simple (PCIBus *bus,int devfn,const char *name); +PCIDevice *pci_create_simple_orphan (PCIBus *bus,int devfn,const char *name);void lsi53c8xx_handle_legacy_cmdline (DeviceState *lsi_dev);
scripts/coccinelle/qom-parent/pci-new-orphan.cocci new file +28 -0
@@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// +// Rename pci_new*/pci_create_simple*() to *_orphan() so that the +// short names can be reintroduced with a mandatory (parent, id, ...) +// signature. +// +// spatch --sp-file scripts/coccinelle/qom-parent/pci-new-orphan.cocci \ +// --in-place --include-headers --dir . + +@@ +@@ +- pci_new_multifunction ++ pci_new_multifunction_orphan + +@@ +@@ +- pci_new ++ pci_new_orphan + +@@ +@@ +- pci_create_simple_multifunction ++ pci_create_simple_multifunction_orphan + +@@ +@@ +- pci_create_simple ++ pci_create_simple_orphan
Signature · 1 line
2.47.1
RFC PATCH 6/134 isa: Make isa_new()/isa_try_new()/isa_create_simple() take a QOM parent
In reply to Alexander GrafSame rename-and-reintroduce treatment as the qdev, sysbus and PCI
layers: mechanically rename the three ISA creation helpers to *_orphan() and reintroduce the short names with a leading (parent, id, ...) pair.
The parented isa_create_simple() calls qdev_realize() (not isa_realize_and_unref()) since the child<> property already holds the sole reference.
The mechanical rename part is generated by
spatch --sp-file scripts/coccinelle/qom-parent/isa-new-orphan.cocci \
--in-place --include-headers --dir .
or equivalently
git ls-files '*.[ch]' '*.[ch].inc' '*.rst' '*.py' | \
grep -v '^subprojects/' | \
xargs sed -i \
's/\bisa_create_simple\b/&_orphan/g;
s/\bisa_try_new\b/&_orphan/g;
s/\bisa_new\b/&_orphan/g'--- hw/alpha/dp264.c | 2 +- hw/char/parallel-isa.c | 2 +- hw/char/serial-isa.c | 2 +- hw/dma/i8257.c | 4 +-- hw/i386/isapc.c | 2 +- hw/i386/pc.c | 12 ++++---- hw/ide/isa.c | 2 +- hw/intc/i8259_common.c | 2 +- hw/isa/i82378.c | 4 +-- hw/isa/isa-bus.c | 30 +++++++++++++++---- hw/isa/isa-superio.c | 10 +++---- hw/mips/jazz.c | 2 +- hw/mips/malta.c | 2 +- hw/ppc/pnv.c | 2 +- hw/ppc/prep.c | 12 ++++---- hw/rtc/mc146818rtc.c | 2 +- hw/sparc64/sun4u.c | 4 +-- include/hw/i386/vmport.h | 2 +- include/hw/isa/isa.h | 10 +++++-- include/hw/net/ne2000-isa.h | 2 +- include/hw/timer/i8254.h | 4 +-- .../qom-parent/isa-new-orphan.cocci | 23 ++++++++++++++ 22 files changed, 91 insertions(+), 46 deletions(-) create mode 100644 scripts/coccinelle/qom-parent/isa-new-orphan.cocci
hw/alpha/dp264.c +1 -1
@@ -126,7 +126,7 @@ static void clipper_init(MachineState *machine)pci_init_nic_devices (pci_bus, mc->default_nic);/* Super I/O */ -isa_create_simple (isa_bus,TYPE_SMC37C669_SUPERIO ); +isa_create_simple_orphan (isa_bus,TYPE_SMC37C669_SUPERIO );/* IDE disk setup. */ pci_dev =pci_create_simple_orphan (pci_bus,-1 ,"cmd646-ide" );
hw/char/parallel-isa.c +1 -1
@@ -22,7 +22,7 @@ static void parallel_init(ISABus *bus, int index, Chardev *chr)DeviceState *dev;ISADevice *isadev; - isadev =isa_new (TYPE_ISA_PARALLEL ); + isadev =isa_new_orphan (TYPE_ISA_PARALLEL ); dev =DEVICE (isadev);qdev_prop_set_uint32 (dev,"index" , index);qdev_prop_set_chr (dev,"chardev" , chr);
hw/char/serial-isa.c +1 -1
@@ -165,7 +165,7 @@ static void serial_isa_init(ISABus *bus, int index, Chardev *chr)DeviceState *dev;ISADevice *isadev; - isadev =isa_new (TYPE_ISA_SERIAL ); + isadev =isa_new_orphan (TYPE_ISA_SERIAL ); dev =DEVICE (isadev);qdev_prop_set_uint32 (dev,"index" , index);qdev_prop_set_chr (dev,"chardev" , chr);
hw/dma/i8257.c +2 -2
@@ -651,7 +651,7 @@ void i8257_dma_init(Object *parent, ISABus *bus, bool high_page_enable)ISADevice *isa1, *isa2;DeviceState *d; - isa1 =isa_new (TYPE_I8257 ); + isa1 =isa_new_orphan (TYPE_I8257 );object_property_add_child (parent,"dma[*]" ,OBJECT (isa1)); d =DEVICE (isa1);qdev_prop_set_int32 (d,"base" ,0x00 );
@@ -660,7 +660,7 @@ void i8257_dma_init(Object *parent, ISABus *bus, bool high_page_enable)qdev_prop_set_int32 (d,"dshift" ,0 );isa_realize_and_unref (isa1, bus, &error_fatal); - isa2 =isa_new (TYPE_I8257 ); + isa2 =isa_new_orphan (TYPE_I8257 );object_property_add_child (parent,"dma[*]" ,OBJECT (isa2)); d =DEVICE (isa2);qdev_prop_set_int32 (d,"base" ,0xc0 );
hw/i386/isapc.c +1 -1
@@ -112,7 +112,7 @@ static void pc_init_isa(MachineState *machine) &error_abort);isa_bus_register_input_irqs (isa_bus, x86ms->gsi); - x86ms->rtc =isa_new (TYPE_MC146818_RTC ); + x86ms->rtc =isa_new_orphan (TYPE_MC146818_RTC );qdev_prop_set_int32 (DEVICE (x86ms->rtc),"base_year" ,2000 );isa_realize_and_unref (x86ms->rtc, isa_bus, &error_fatal); irq = object_property_get_uint(OBJECT(x86ms->rtc), "irq",
hw/i386/pc.c +6 -6
@@ -998,7 +998,7 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, }if (create_fdctrl) {#ifdef CONFIG_FDC_ISA -ISADevice *fdc =isa_new (TYPE_ISA_FDC ); +ISADevice *fdc =isa_new_orphan (TYPE_ISA_FDC );if (fdc) {isa_realize_and_unref (fdc, isa_bus, &error_fatal);isa_fdc_init_drives (fdc, fd);
@@ -1014,10 +1014,10 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl,return ; } - i8042 =isa_create_simple (isa_bus,TYPE_I8042 ); + i8042 =isa_create_simple_orphan (isa_bus,TYPE_I8042 );if (!no_vmport) { -isa_create_simple (isa_bus,TYPE_VMPORT ); - vmmouse =isa_try_new ("vmmouse" ); +isa_create_simple_orphan (isa_bus,TYPE_VMPORT ); + vmmouse =isa_try_new_orphan ("vmmouse" ); }else { vmmouse =NULL ; }
@@ -1026,7 +1026,7 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, &error_abort);isa_realize_and_unref (vmmouse, isa_bus, &error_fatal); } - port92 =isa_create_simple (isa_bus,TYPE_PORT92 ); + port92 =isa_create_simple_orphan (isa_bus,TYPE_PORT92 ); a20_line =qemu_allocate_irqs (handle_a20_line_change, first_cpu,2 ); qdev_connect_gpio_out_named(DEVICE(i8042),
@@ -1639,7 +1639,7 @@ static void pc_machine_initfn(Object *obj) pcms->default_bus_bypass_iommu = false;pc_system_flash_create (pcms); - pcms->pcspk =isa_new (TYPE_PC_SPEAKER ); + pcms->pcspk =isa_new_orphan (TYPE_PC_SPEAKER );object_property_add_alias (OBJECT (pcms),"pcspk-audiodev" ,OBJECT (pcms->pcspk),"audiodev" );if (pcmc->pci_enabled) {
hw/ide/isa.c +1 -1
@@ -84,7 +84,7 @@ ISADevice *isa_ide_init(ISABus *bus, int iobase, int iobase2, int irqnum,ISADevice *isadev;ISAIDEState *s; - isadev =isa_new (TYPE_ISA_IDE ); + isadev =isa_new_orphan (TYPE_ISA_IDE ); dev =DEVICE (isadev);qdev_prop_set_uint32 (dev,"iobase" , iobase);qdev_prop_set_uint32 (dev,"iobase2" , iobase2);
hw/intc/i8259_common.c +1 -1
@@ -94,7 +94,7 @@ ISADevice *i8259_init_chip(const char *name, ISABus *bus, bool master)DeviceState *dev;ISADevice *isadev; - isadev =isa_new (name); + isadev =isa_new_orphan (name); dev =DEVICE (isadev);qdev_prop_set_uint32 (dev,"iobase" , master ?0x20 :0xa0 );qdev_prop_set_uint32 (dev,"elcr_addr" , master ?0x4d0 :0x4d1 );
hw/isa/i82378.c +2 -2
@@ -103,14 +103,14 @@ static void i82378_realize(PCIDevice *pci, Error **errp) pit =i8254_pit_init (isabus,0x40 ,0 ,NULL );/* speaker */ - pcspk =isa_new (TYPE_PC_SPEAKER ); + pcspk =isa_new_orphan (TYPE_PC_SPEAKER );object_property_set_link (OBJECT (pcspk),"pit" ,OBJECT (pit), &error_fatal);if (!isa_realize_and_unref (pcspk, isabus, errp)) {return ; }/* 2 82C37 (dma) */ -isa_create_simple (isabus,"i82374" ); +isa_create_simple_orphan (isabus,"i82374" ); }static void i82378_init (Object *obj)
hw/isa/isa-bus.c +24 -6
@@ -153,21 +153,39 @@ int isa_register_portio_list(ISADevice *dev,return 0 ; } -ISADevice *isa_new (const char *name) +ISADevice *isa_new (Object *parent,const char *id,const char *type) +{ +return ISA_DEVICE (qdev_new (parent, id, type)); +} + +ISADevice *isa_try_new (Object *parent,const char *id,const char *type) +{ +return ISA_DEVICE (qdev_try_new (parent, id, type)); +} + +ISADevice *isa_create_simple (Object *parent,const char *id, +ISABus *bus,const char *type) +{ +ISADevice *dev =isa_new (parent, id, type); +qdev_realize (DEVICE (dev),BUS (bus), &error_fatal); +return dev; +} + +ISADevice *isa_new_orphan (const char *name) {return ISA_DEVICE (qdev_new_orphan (name)); } -ISADevice *isa_try_new (const char *name) +ISADevice *isa_try_new_orphan (const char *name) {return ISA_DEVICE (qdev_try_new_orphan (name)); } -ISADevice *isa_create_simple (ISABus *bus,const char *name) +ISADevice *isa_create_simple_orphan (ISABus *bus,const char *name) {ISADevice *dev; - dev =isa_new (name); + dev =isa_new_orphan (name);isa_realize_and_unref (dev, bus, &error_fatal);return dev; }
@@ -187,12 +205,12 @@ ISADevice *isa_vga_init(ISABus *bus) vga_interface_created = true;switch (vga_interface_type) {case VGA_CIRRUS : -return isa_create_simple (bus,"isa-cirrus-vga" ); +return isa_create_simple_orphan (bus,"isa-cirrus-vga" );case VGA_QXL :error_report ("%s: qxl: no PCI bus" , __func__);return NULL ;case VGA_STD : -return isa_create_simple (bus,"isa-vga" ); +return isa_create_simple_orphan (bus,"isa-vga" );case VGA_VMWARE :error_report ("%s: vmware_vga: no PCI bus" , __func__);return NULL ;
hw/isa/isa-superio.c +5 -5
@@ -54,7 +54,7 @@ static void isa_superio_realize(DeviceState *dev, Error **errp) }else { name =g_strdup_printf ("parallel%d" , i); } - isa =isa_new (TYPE_ISA_PARALLEL ); + isa =isa_new_orphan (TYPE_ISA_PARALLEL ); d =DEVICE (isa);qdev_prop_set_uint32 (d,"index" , i);if (k->parallel.get_iobase) {
@@ -93,7 +93,7 @@ static void isa_superio_realize(DeviceState *dev, Error **errp) }else { name =g_strdup_printf ("serial%d" , i); } - isa =isa_new (TYPE_ISA_SERIAL ); + isa =isa_new_orphan (TYPE_ISA_SERIAL ); d =DEVICE (isa);qdev_prop_set_uint32 (d,"index" , i);if (k->serial.get_iobase) {
@@ -120,7 +120,7 @@ static void isa_superio_realize(DeviceState *dev, Error **errp)assert (k->floppy.count <=1 );if (k->floppy.count && (!k->floppy.is_enabled || k->floppy.is_enabled (sio,0 ))) { - isa =isa_new (TYPE_ISA_FDC ); + isa =isa_new_orphan (TYPE_ISA_FDC ); d =DEVICE (isa);if (k->floppy.get_iobase) {qdev_prop_set_uint32 (d,"iobase" , k->floppy.get_iobase (sio,0 ));
@@ -144,14 +144,14 @@ static void isa_superio_realize(DeviceState *dev, Error **errp) }/* Keyboard, mouse */ - isa =isa_new (TYPE_I8042 ); + isa =isa_new_orphan (TYPE_I8042 );object_property_add_child (OBJECT (sio),TYPE_I8042 ,OBJECT (isa));isa_realize_and_unref (isa, bus, &error_fatal); sio->kbc = isa;/* IDE */ if (k->ide.count && (!k->ide.is_enabled || k->ide.is_enabled (sio,0 ))) { - isa =isa_new ("isa-ide" ); + isa =isa_new_orphan ("isa-ide" ); d =DEVICE (isa);if (k->ide.get_iobase) {qdev_prop_set_uint32 (d,"iobase" , k->ide.get_iobase (sio,0 ));
hw/mips/jazz.c +1 -1
@@ -289,7 +289,7 @@ static void mips_jazz_init(MachineState *machine,isa_bus_register_input_irqs (isa_bus, i8259);i8257_dma_init (OBJECT (rc4030), isa_bus,0 ); pit =i8254_pit_init (isa_bus,0x40 ,0 ,NULL ); - pcspk =isa_new (TYPE_PC_SPEAKER ); + pcspk =isa_new_orphan (TYPE_PC_SPEAKER );object_property_set_link (OBJECT (pcspk),"pit" ,OBJECT (pit), &error_fatal);isa_realize_and_unref (pcspk, isa_bus, &error_fatal);
hw/mips/malta.c +1 -1
@@ -1253,7 +1253,7 @@ void mips_malta_init(MachineState *machine)g_free (smbus_eeprom_buf);/* Super I/O: SMS FDC37M817 */ -isa_create_simple (isa_bus,TYPE_FDC37M81X_SUPERIO ); +isa_create_simple_orphan (isa_bus,TYPE_FDC37M81X_SUPERIO );/* Network card */ network_init (pci_bus);
hw/ppc/pnv.c +1 -1
@@ -1010,7 +1010,7 @@ static bool pnv_match_cpu(const char *default_type, const char *cpu_type)static void pnv_ipmi_bt_init (ISABus *bus,IPMIBmc *bmc,uint32_t irq) { -ISADevice *dev =isa_new ("isa-ipmi-bt" ); +ISADevice *dev =isa_new_orphan ("isa-ipmi-bt" );object_property_set_link (OBJECT (dev),"bmc" ,OBJECT (bmc), &error_fatal);object_property_set_int (OBJECT (dev),"irq" , irq, &error_fatal);
hw/ppc/prep.c +6 -6
@@ -309,20 +309,20 @@ static void ibm_40p_init(MachineState *machine) isa_bus =ISA_BUS (qdev_get_child_bus (i82378_dev,"isa.0" ));/* system control ports */ - isa_dev =isa_new ("prep-systemio" ); + isa_dev =isa_new_orphan ("prep-systemio" ); dev =DEVICE (isa_dev);qdev_prop_set_uint32 (dev,"ibm-planar-id" ,0xfc );qdev_prop_set_uint32 (dev,"equipment" ,0xc0 );isa_realize_and_unref (isa_dev, isa_bus, &error_fatal);/* Memory controller */ - isa_dev =isa_new ("rs6000-mc" ); + isa_dev =isa_new_orphan ("rs6000-mc" ); dev =DEVICE (isa_dev);qdev_prop_set_uint32 (dev,"ram-size" , machine->ram_size);isa_realize_and_unref (isa_dev, isa_bus, &error_fatal);/* RTC */ - isa_dev =isa_new (TYPE_MC146818_RTC ); + isa_dev =isa_new_orphan (TYPE_MC146818_RTC ); dev =DEVICE (isa_dev);qdev_prop_set_int32 (dev,"base_year" ,1900 );isa_realize_and_unref (isa_dev, isa_bus, &error_fatal);
@@ -334,9 +334,9 @@ static void ibm_40p_init(MachineState *machine)/* add some more devices */ if (defaults_enabled ()) { - m48t59 =NVRAM (isa_create_simple (isa_bus,"isa-m48t59" )); + m48t59 =NVRAM (isa_create_simple_orphan (isa_bus,"isa-m48t59" )); - isa_dev =isa_new ("cs4231a" ); + isa_dev =isa_new_orphan ("cs4231a" ); dev =DEVICE (isa_dev);qdev_prop_set_uint32 (dev,"iobase" ,0x830 );qdev_prop_set_uint32 (dev,"irq" ,10 );
@@ -345,7 +345,7 @@ static void ibm_40p_init(MachineState *machine) }isa_realize_and_unref (isa_dev, isa_bus, &error_fatal); - isa_dev =isa_new ("pc87312" ); + isa_dev =isa_new_orphan ("pc87312" ); dev =DEVICE (isa_dev);qdev_prop_set_uint32 (dev,"config" ,12 );isa_realize_and_unref (isa_dev, isa_bus, &error_fatal);
hw/rtc/mc146818rtc.c +1 -1
@@ -930,7 +930,7 @@ MC146818RtcState *mc146818_rtc_init(ISABus *bus, int base_year,ISADevice *isadev;MC146818RtcState *s; - isadev =isa_new (TYPE_MC146818_RTC ); + isadev =isa_new_orphan (TYPE_MC146818_RTC ); dev =DEVICE (isadev); s =MC146818_RTC (isadev);qdev_prop_set_int32 (dev,"base_year" , base_year);
hw/sparc64/sun4u.c +2 -2
@@ -329,13 +329,13 @@ static void ebus_realize(PCIDevice *pci_dev, Error **errp)parallel_hds_isa_init (s->isa_bus,MAX_PARALLEL_PORTS );/* Keyboard */ -isa_create_simple (s->isa_bus,TYPE_I8042 ); +isa_create_simple_orphan (s->isa_bus,TYPE_I8042 );/* Floppy */ for (i =0 ; i <MAX_FD ; i++) { fd[i] =drive_get (IF_FLOPPY ,0 , i); } - isa_dev =isa_new (TYPE_ISA_FDC ); + isa_dev =isa_new_orphan (TYPE_ISA_FDC ); dev =DEVICE (isa_dev);qdev_prop_set_uint32 (dev,"dma" ,-1 );isa_realize_and_unref (isa_dev, s->isa_bus, &error_fatal);
include/hw/i386/vmport.h +1 -1
@@ -20,7 +20,7 @@ typedef enum {static inline void vmport_init (ISABus *bus) { -isa_create_simple (bus,TYPE_VMPORT ); +isa_create_simple_orphan (bus,TYPE_VMPORT ); }void vmport_register (VMPortCommand command,VMPortReadFunc *func,void *opaque);
include/hw/isa/isa.h +7 -3
@@ -80,10 +80,14 @@ IsaDma *isa_bus_get_dma(ISABus *bus, int nchan);* Return IRQ @irqnum from the PIC associated on ISA @bus. */ qemu_irq isa_bus_get_irq (ISABus *bus,unsigned irqnum); -ISADevice *isa_new (const char *name); -ISADevice *isa_try_new (const char *name); +ISADevice *isa_new (Object *parent,const char *id,const char *type); +ISADevice *isa_try_new (Object *parent,const char *id,const char *type); +ISADevice *isa_create_simple (Object *parent,const char *id, +ISABus *bus,const char *type); +ISADevice *isa_new_orphan (const char *name); +ISADevice *isa_try_new_orphan (const char *name);bool isa_realize_and_unref (ISADevice *dev,ISABus *bus,Error **errp); -ISADevice *isa_create_simple (ISABus *bus,const char *name); +ISADevice *isa_create_simple_orphan (ISABus *bus,const char *name);ISADevice *isa_vga_init (ISABus *bus);
include/hw/net/ne2000-isa.h +1 -1
@@ -22,7 +22,7 @@ static inline ISADevice *isa_ne2000_init(ISABus *bus, int base, int irq, {ISADevice *d; - d =isa_try_new (TYPE_ISA_NE2000 ); + d =isa_try_new_orphan (TYPE_ISA_NE2000 );if (d) {DeviceState *dev =DEVICE (d);
include/hw/timer/i8254.h +2 -2
@@ -51,7 +51,7 @@ static inline ISADevice *i8254_pit_init(ISABus *bus, int base, int isa_irq,DeviceState *dev;ISADevice *d; - d =isa_new (TYPE_I8254 ); + d =isa_new_orphan (TYPE_I8254 ); dev =DEVICE (d);qdev_prop_set_uint32 (dev,"iobase" , base);isa_realize_and_unref (d, bus, &error_fatal);
@@ -67,7 +67,7 @@ static inline ISADevice *kvm_pit_init(ISABus *bus, int base)DeviceState *dev;ISADevice *d; - d =isa_new (TYPE_KVM_I8254 ); + d =isa_new_orphan (TYPE_KVM_I8254 ); dev =DEVICE (d);qdev_prop_set_uint32 (dev,"iobase" , base);isa_realize_and_unref (d, bus, &error_fatal);
scripts/coccinelle/qom-parent/isa-new-orphan.cocci new file +23 -0
@@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// +// Rename isa_new()/isa_try_new()/isa_create_simple() to *_orphan() +// so that the short names can be reintroduced with a mandatory +// (parent, id, ...) signature. +// +// spatch --sp-file scripts/coccinelle/qom-parent/isa-new-orphan.cocci \ +// --in-place --include-headers --dir . + +@@ +@@ +- isa_new ++ isa_new_orphan + +@@ +@@ +- isa_try_new ++ isa_try_new_orphan + +@@ +@@ +- isa_create_simple ++ isa_create_simple_orphan
Signature · 1 line
2.47.1
RFC PATCH 7/134 i2c: Make i2c_slave_new()/i2c_slave_create_simple() take a QOM parent
In reply to Alexander GrafSame rename-and-reintroduce treatment as the qdev, sysbus, PCI and ISA layers: mechanically rename the two I2C-slave creation helpers to *_orphan() and reintroduce the short names with a leading (parent, id, ...) pair.
The parented i2c_slave_create_simple() calls qdev_realize() (not i2c_slave_realize_and_unref()) since the child<> property already holds the sole reference.
The mechanical rename part is generated by
spatch --sp-file \
scripts/coccinelle/qom-parent/i2c-slave-new-orphan.cocci \
--in-place --include-headers --dir .or equivalently
git ls-files '*.[ch]' '*.[ch].inc' '*.rst' '*.py' | \
grep -v '^subprojects/' | \
xargs sed -i \
's/\bi2c_slave_create_simple\b/&_orphan/g;
s/\bi2c_slave_new\b/&_orphan/g'--- hw/arm/aspeed.c | 4 +- hw/arm/aspeed_ast1040_evb.c | 2 +- hw/arm/aspeed_ast10x0_evb.c | 2 +- hw/arm/aspeed_ast2400_palmetto.c | 4 +- hw/arm/aspeed_ast2400_quanta-q71l.c | 12 ++-- hw/arm/aspeed_ast2400_supermicrox11.c | 4 +- hw/arm/aspeed_ast2500_evb.c | 2 +- hw/arm/aspeed_ast2500_g220a.c | 6 +- hw/arm/aspeed_ast2500_romulus.c | 2 +- hw/arm/aspeed_ast2500_supermicro-x11spi.c | 4 +- hw/arm/aspeed_ast2500_tiogapass.c | 6 +- hw/arm/aspeed_ast2500_witherspoon.c | 16 ++--- hw/arm/aspeed_ast2500_yosemitev2.c | 6 +- hw/arm/aspeed_ast2600_anacapa.c | 26 ++++----- hw/arm/aspeed_ast2600_bletchley.c | 20 +++---- hw/arm/aspeed_ast2600_catalina.c | 58 +++++++++---------- hw/arm/aspeed_ast2600_evb.c | 2 +- hw/arm/aspeed_ast2600_fby35.c | 10 ++-- hw/arm/aspeed_ast2600_fuji.c | 40 ++++++------- hw/arm/aspeed_ast2600_gb200nvl.c | 12 ++-- hw/arm/aspeed_ast2600_rainier.c | 46 +++++++-------- hw/arm/aspeed_ast27x0-fc.c | 2 +- hw/arm/aspeed_ast27x0_evb.c | 2 +- hw/arm/bananapi_m2u.c | 2 +- hw/arm/cubieboard.c | 2 +- hw/arm/musicpal.c | 2 +- hw/arm/npcm7xx_boards.c | 42 +++++++------- hw/arm/npcm8xx_boards.c | 2 +- hw/arm/realview.c | 2 +- hw/arm/stellaris.c | 2 +- hw/arm/versatilepb.c | 2 +- hw/arm/vexpress.c | 2 +- hw/display/sii9022.c | 2 +- hw/i2c/aspeed_i2c.c | 2 +- hw/i2c/core.c | 26 ++++++++- hw/i3c/core.c | 2 +- hw/nvram/eeprom_at24c.c | 2 +- hw/ppc/e500.c | 2 +- hw/ppc/pnv.c | 4 +- hw/ppc/sam460ex.c | 2 +- hw/riscv/tt_atlantis.c | 4 +- include/hw/arm/aspeed.h | 4 +- include/hw/i2c/i2c.h | 38 ++++++++++-- .../qom-parent/i2c-slave-new-orphan.cocci | 18 ++++++ 44 files changed, 260 insertions(+), 192 deletions(-) create mode 100644 scripts/coccinelle/qom-parent/i2c-slave-new-orphan.cocci
hw/arm/aspeed.c +2 -2
@@ -253,13 +253,13 @@ static void aspeed_machine_init(MachineState *machine)void aspeed_create_pca9552 (AspeedSoCState *soc,int bus_id,int addr) { -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c, bus_id), +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c, bus_id),TYPE_PCA9552 , addr); }I2CSlave *aspeed_create_pca9554 (AspeedSoCState *soc,int bus_id,int addr) { -return i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c, bus_id), +return i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c, bus_id),TYPE_PCA9554 , addr); }
hw/arm/aspeed_ast1040_evb.c +1 -1
@@ -55,7 +55,7 @@ static void ast1040_evb_i2c_init(AspeedMachineState *bmc)uint8_t *eeprom_buf =g_malloc0 (256 );smbus_eeprom_init_one (aspeed_i2c_get_bus (&soc->i2c,0 ),0x50 , eeprom_buf); -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,1 ),"tmp105" ,0x4d ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,1 ),"tmp105" ,0x4d ); } static void aspeed_machine_ast1040_evb_class_init(ObjectClass *oc,
hw/arm/aspeed_ast10x0_evb.c +1 -1
@@ -73,7 +73,7 @@ static void ast1030_evb_i2c_init(AspeedMachineState *bmc)smbus_eeprom_init_one (aspeed_i2c_get_bus (&soc->i2c,0 ),0x50 , eeprom_buf);/* U11 LM75 connects to SDA/SCL Group 2 by default */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,1 ),"tmp105" ,0x4d ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,1 ),"tmp105" ,0x4d ); } static void aspeed_minibmc_machine_ast1030_evb_class_init(ObjectClass *oc,
hw/arm/aspeed_ast2400_palmetto.c +2 -2
@@ -37,13 +37,13 @@ static void palmetto_bmc_i2c_init(AspeedMachineState *bmc)* The palmetto platform expects a ds3231 RTC but a ds1338 is * enough to provide basic RTC features. Alarms will be missing */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,0 ),"ds1338" ,0x68 ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,0 ),"ds1338" ,0x68 );smbus_eeprom_init_one (aspeed_i2c_get_bus (&soc->i2c,0 ),0x50 , eeprom_buf);/* add a TMP423 temperature sensor */ - dev =DEVICE (i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,2 ), + dev =DEVICE (i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,2 ),"tmp423" ,0x4c ));object_property_set_int (OBJECT (dev),"temperature0" ,31000 , &error_abort);object_property_set_int (OBJECT (dev),"temperature1" ,28000 , &error_abort);
hw/arm/aspeed_ast2400_quanta-q71l.c +6 -6
@@ -33,21 +33,21 @@ static void quanta_q71l_bmc_i2c_init(AspeedMachineState *bmc)* The quanta-q71l platform expects tmp75s which are compatible with * tmp105s. */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,1 ),"tmp105" ,0x4c ); -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,1 ),"tmp105" ,0x4e ); -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,1 ),"tmp105" ,0x4f ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,1 ),"tmp105" ,0x4c ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,1 ),"tmp105" ,0x4e ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,1 ),"tmp105" ,0x4f );/* TODO: i2c-1: Add baseboard FRU eeprom@54 24c64 */ /* TODO: i2c-1: Add Frontpanel FRU eeprom@57 24c64 */ /* TODO: Add Memory Riser i2c mux and eeproms. */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,2 ),"pca9546" ,0x74 ); -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,2 ),"pca9548" ,0x77 ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,2 ),"pca9546" ,0x74 ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,2 ),"pca9548" ,0x77 );/* TODO: i2c-3: Add BIOS FRU eeprom@56 24c64 */ /* i2c-7 */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,7 ),"pca9546" ,0x70 ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,7 ),"pca9546" ,0x70 );/* - i2c@0: pmbus@59 */ /* - i2c@1: pmbus@58 */ /* - i2c@2: pmbus@58 */
hw/arm/aspeed_ast2400_supermicrox11.c +2 -2
@@ -37,13 +37,13 @@ static void supermicrox11_bmc_i2c_init(AspeedMachineState *bmc)* The palmetto platform expects a ds3231 RTC but a ds1338 is * enough to provide basic RTC features. Alarms will be missing */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,0 ),"ds1338" ,0x68 ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,0 ),"ds1338" ,0x68 );smbus_eeprom_init_one (aspeed_i2c_get_bus (&soc->i2c,0 ),0x50 , eeprom_buf);/* add a TMP423 temperature sensor */ - dev =DEVICE (i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,2 ), + dev =DEVICE (i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,2 ),"tmp423" ,0x4c ));object_property_set_int (OBJECT (dev),"temperature0" ,31000 , &error_abort);object_property_set_int (OBJECT (dev),"temperature1" ,28000 , &error_abort);
hw/arm/aspeed_ast2500_evb.c +1 -1
@@ -34,7 +34,7 @@ static void ast2500_evb_i2c_init(AspeedMachineState *bmc) eeprom_buf);/* The AST2500 EVB expects a LM75 but a TMP105 is compatible */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,7 ), +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,7 ),TYPE_TMP105 ,0x4d ); }
hw/arm/aspeed_ast2500_g220a.c +3 -3
@@ -32,19 +32,19 @@ static void g220a_bmc_i2c_init(AspeedMachineState *bmc)AspeedSoCState *soc = bmc->soc;DeviceState *dev; - dev =DEVICE (i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,3 ), + dev =DEVICE (i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,3 ),"emc1413" ,0x4c ));object_property_set_int (OBJECT (dev),"temperature0" ,31000 , &error_abort);object_property_set_int (OBJECT (dev),"temperature1" ,28000 , &error_abort);object_property_set_int (OBJECT (dev),"temperature2" ,20000 , &error_abort); - dev =DEVICE (i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,12 ), + dev =DEVICE (i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,12 ),"emc1413" ,0x4c ));object_property_set_int (OBJECT (dev),"temperature0" ,31000 , &error_abort);object_property_set_int (OBJECT (dev),"temperature1" ,28000 , &error_abort);object_property_set_int (OBJECT (dev),"temperature2" ,20000 , &error_abort); - dev =DEVICE (i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,13 ), + dev =DEVICE (i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,13 ),"emc1413" ,0x4c ));object_property_set_int (OBJECT (dev),"temperature0" ,31000 , &error_abort);object_property_set_int (OBJECT (dev),"temperature1" ,28000 , &error_abort);
hw/arm/aspeed_ast2500_romulus.c +1 -1
@@ -30,7 +30,7 @@ static void romulus_bmc_i2c_init(AspeedMachineState *bmc)* The romulus board expects Epson RX8900 I2C RTC but a ds1338 is * good enough */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,11 ),"ds1338" ,0x32 ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,11 ),"ds1338" ,0x32 ); } static void aspeed_machine_romulus_class_init(ObjectClass *oc,
hw/arm/aspeed_ast2500_supermicro-x11spi.c +2 -2
@@ -33,13 +33,13 @@ static void supermicro_x11spi_bmc_i2c_init(AspeedMachineState *bmc)* The palmetto platform expects a ds3231 RTC but a ds1338 is * enough to provide basic RTC features. Alarms will be missing */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,0 ),"ds1338" ,0x68 ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,0 ),"ds1338" ,0x68 );smbus_eeprom_init_one (aspeed_i2c_get_bus (&soc->i2c,0 ),0x50 , eeprom_buf);/* add a TMP423 temperature sensor */ - dev =DEVICE (i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,2 ), + dev =DEVICE (i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,2 ),"tmp423" ,0x4c ));object_property_set_int (OBJECT (dev),"temperature0" ,31000 , &error_abort);object_property_set_int (OBJECT (dev),"temperature1" ,28000 , &error_abort);
hw/arm/aspeed_ast2500_tiogapass.c +3 -3
@@ -55,9 +55,9 @@ static void tiogapass_bmc_i2c_init(AspeedMachineState *bmc)at24c_eeprom_init_rom (aspeed_i2c_get_bus (&soc->i2c,6 ),0x54 ,128 * KiB, tiogapass_bmc_fruid, tiogapass_bmc_fruid_len);/* TMP421 */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,8 ),"tmp421" ,0x1f ); -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,6 ),"tmp421" ,0x4f ); -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,6 ),"tmp421" ,0x4e ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,8 ),"tmp421" ,0x1f ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,6 ),"tmp421" ,0x4f ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,6 ),"tmp421" ,0x4e ); } static void aspeed_machine_tiogapass_class_init(ObjectClass *oc,
hw/arm/aspeed_ast2500_witherspoon.c +8 -8
@@ -44,7 +44,7 @@ static void witherspoon_bmc_i2c_init(AspeedMachineState *bmc)LEDState *led;/* Bus 3: TODO bmp280@77 */ - dev =DEVICE (i2c_slave_new (TYPE_PCA9552 ,0x60 )); + dev =DEVICE (i2c_slave_new_orphan (TYPE_PCA9552 ,0x60 ));qdev_prop_set_string (dev,"description" ,"pca1" ); i2c_slave_realize_and_unref(I2C_SLAVE(dev), aspeed_i2c_get_bus(&soc->i2c, 3),
@@ -58,24 +58,24 @@ static void witherspoon_bmc_i2c_init(AspeedMachineState *bmc)qdev_connect_gpio_out (dev, pca1_leds[i].gpio_id,qdev_get_gpio_in (DEVICE (led),0 )); } -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,3 ),"dps310" ,0x76 ); -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,3 ),"max31785" ,0x52 ); -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,4 ),"tmp423" ,0x4c ); -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,5 ),"tmp423" ,0x4c ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,3 ),"dps310" ,0x76 ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,3 ),"max31785" ,0x52 ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,4 ),"tmp423" ,0x4c ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,5 ),"tmp423" ,0x4c );/* The Witherspoon expects a TMP275 but a TMP105 is compatible */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,9 ),TYPE_TMP105 , +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,9 ),TYPE_TMP105 ,0x4a );/* * The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is * good enough */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,11 ),"ds1338" ,0x32 ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,11 ),"ds1338" ,0x32 );smbus_eeprom_init_one (aspeed_i2c_get_bus (&soc->i2c,11 ),0x51 , eeprom_buf); - dev =DEVICE (i2c_slave_new (TYPE_PCA9552 ,0x60 )); + dev =DEVICE (i2c_slave_new_orphan (TYPE_PCA9552 ,0x60 ));qdev_prop_set_string (dev,"description" ,"pca0" ); i2c_slave_realize_and_unref(I2C_SLAVE(dev), aspeed_i2c_get_bus(&soc->i2c, 11),
hw/arm/aspeed_ast2500_yosemitev2.c +3 -3
@@ -55,9 +55,9 @@ static void yosemitev2_bmc_i2c_init(AspeedMachineState *bmc)at24c_eeprom_init_rom (aspeed_i2c_get_bus (&soc->i2c,8 ),0x51 ,128 * KiB, yosemitev2_bmc_fruid, yosemitev2_bmc_fruid_len);/* TMP421 */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,11 ),"tmp421" ,0x1f ); -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,9 ),"tmp421" ,0x4e ); -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,9 ),"tmp421" ,0x4f ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,11 ),"tmp421" ,0x1f ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,9 ),"tmp421" ,0x4e ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,9 ),"tmp421" ,0x4f ); }
hw/arm/aspeed_ast2600_anacapa.c +13 -13
@@ -237,17 +237,17 @@ static void anacapa_bmc_i2c_init(AspeedMachineState *bmc)/* eeprom@50 */ at24c_eeprom_init (i2c[0 ],0x50 ,256 * KiB);/* i2c-mux@70 */ -i2c_slave_create_simple (i2c[0 ],TYPE_PCA9546 ,0x70 ); +i2c_slave_create_simple_orphan (i2c[0 ],TYPE_PCA9546 ,0x70 );/* &i2c1 */ /* eeprom@50 */ at24c_eeprom_init (i2c[1 ],0x50 ,256 * KiB);/* i2c-mux@70 (PCA9546) — 4 channels, empty */ -i2c_slave_create_simple (i2c[1 ],TYPE_PCA9546 ,0x70 ); +i2c_slave_create_simple_orphan (i2c[1 ],TYPE_PCA9546 ,0x70 );/* &i2c4 */ /* i2c-mux@70 (PCA9548) */ -i2c_slave_create_simple (i2c[4 ],TYPE_PCA9548 ,0x70 ); +i2c_slave_create_simple_orphan (i2c[4 ],TYPE_PCA9548 ,0x70 );/* &i2c6 */ /* eeprom@50 */
@@ -256,15 +256,15 @@ static void anacapa_bmc_i2c_init(AspeedMachineState *bmc)/* &i2c8 */ /* i2c-mux@72 (PCA9546) */ - i2c_mux =i2c_slave_create_simple (i2c[8 ],TYPE_PCA9546 ,0x72 ); + i2c_mux =i2c_slave_create_simple_orphan (i2c[8 ],TYPE_PCA9546 ,0x72 );/* i2c8mux ch0 */ /* adc128d818@1f — no model */ /* pca9555@22 */ -i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,0 ), +i2c_slave_create_simple_orphan (pca954x_i2c_get_bus (i2c_mux,0 ),TYPE_PCA9552 ,0x22 );/* pca9555@24 */ -i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,0 ), +i2c_slave_create_simple_orphan (pca954x_i2c_get_bus (i2c_mux,0 ),TYPE_PCA9552 ,0x24 );/* eeprom@50 */ at24c_eeprom_init_rom(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 16 * KiB,
@@ -272,10 +272,10 @@ static void anacapa_bmc_i2c_init(AspeedMachineState *bmc)/* i2c8mux ch1 */ /* pca9555@22 */ -i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,1 ), +i2c_slave_create_simple_orphan (pca954x_i2c_get_bus (i2c_mux,1 ),TYPE_PCA9552 ,0x22 );/* pca9555@24 */ -i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,1 ), +i2c_slave_create_simple_orphan (pca954x_i2c_get_bus (i2c_mux,1 ),TYPE_PCA9552 ,0x24 );/* eeprom@50 */ at24c_eeprom_init_rom(pca954x_i2c_get_bus(i2c_mux, 1), 0x50, 16 * KiB,
@@ -291,11 +291,11 @@ static void anacapa_bmc_i2c_init(AspeedMachineState *bmc)/* &i2c10 */ /* i2c-mux@71 (PCA9548) */ - i2c_mux =i2c_slave_create_simple (i2c[10 ],TYPE_PCA9548 ,0x71 ); + i2c_mux =i2c_slave_create_simple_orphan (i2c[10 ],TYPE_PCA9548 ,0x71 );/* i2c10mux ch5 */ /* pca9555@22*/ -i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,5 ), +i2c_slave_create_simple_orphan (pca954x_i2c_get_bus (i2c_mux,5 ),TYPE_PCA9552 ,0x22 );/* eeprom@52 */ at24c_eeprom_init_rom(pca954x_i2c_get_bus(i2c_mux, 5), 0x52, 32 * KiB,
@@ -303,13 +303,13 @@ static void anacapa_bmc_i2c_init(AspeedMachineState *bmc)/* &i2c11 */ /* i2c-mux@71 (PCA9548) */ - i2c_mux =i2c_slave_create_simple (i2c[11 ],TYPE_PCA9548 ,0x71 ); + i2c_mux =i2c_slave_create_simple_orphan (i2c[11 ],TYPE_PCA9548 ,0x71 );/* i2c11mux ch0-ch4 — empty */ /* i2c11mux ch5 */ /* pca9555@22 */ -i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,5 ), +i2c_slave_create_simple_orphan (pca954x_i2c_get_bus (i2c_mux,5 ),TYPE_PCA9552 ,0x22 );/* eeprom@52 */ at24c_eeprom_init_rom(pca954x_i2c_get_bus(i2c_mux, 5), 0x52, 32 * KiB,
@@ -317,7 +317,7 @@ static void anacapa_bmc_i2c_init(AspeedMachineState *bmc)/* &i2c13 */ /* i2c-mux@70 (PCA9548) */ - i2c_mux =i2c_slave_create_simple (i2c[13 ],TYPE_PCA9548 ,0x70 ); + i2c_mux =i2c_slave_create_simple_orphan (i2c[13 ],TYPE_PCA9548 ,0x70 );/* i2c13mux ch3 */ /* adc128d818@1f - no model */
hw/arm/aspeed_ast2600_bletchley.c +10 -10
@@ -35,35 +35,35 @@ static void bletchley_bmc_i2c_init(AspeedMachineState *bmc)for (int i =0 ; i <6 ; i++) {/* Missing model: ti,ina230 @ 0x45 */ /* Missing model: mps,mp5023 @ 0x40 */ -i2c_slave_create_simple (i2c[i],TYPE_TMP421 ,0x4f ); +i2c_slave_create_simple_orphan (i2c[i],TYPE_TMP421 ,0x4f );/* Missing model: nxp,pca9539 @ 0x76, but PCA9552 works enough */ -i2c_slave_create_simple (i2c[i],TYPE_PCA9552 ,0x76 ); -i2c_slave_create_simple (i2c[i],TYPE_PCA9552 ,0x67 ); +i2c_slave_create_simple_orphan (i2c[i],TYPE_PCA9552 ,0x76 ); +i2c_slave_create_simple_orphan (i2c[i],TYPE_PCA9552 ,0x67 );/* Missing model: fsc,fusb302 @ 0x22 */ }/* Bus 6 */ at24c_eeprom_init (i2c[6 ],0x56 ,65536 );/* Missing model: nxp,pcf85263 @ 0x51 , but ds1338 works enough */ -i2c_slave_create_simple (i2c[6 ],"ds1338" ,0x51 ); +i2c_slave_create_simple_orphan (i2c[6 ],"ds1338" ,0x51 );/* Bus 7 */ at24c_eeprom_init (i2c[7 ],0x54 ,65536 );/* Bus 9 */ -i2c_slave_create_simple (i2c[9 ],TYPE_TMP421 ,0x4f ); +i2c_slave_create_simple_orphan (i2c[9 ],TYPE_TMP421 ,0x4f );/* Bus 10 */ -i2c_slave_create_simple (i2c[10 ],TYPE_TMP421 ,0x4f ); +i2c_slave_create_simple_orphan (i2c[10 ],TYPE_TMP421 ,0x4f );/* Missing model: ti,hdc1080 @ 0x40 */ -i2c_slave_create_simple (i2c[10 ],TYPE_PCA9552 ,0x67 ); +i2c_slave_create_simple_orphan (i2c[10 ],TYPE_PCA9552 ,0x67 );/* Bus 12 */ /* Missing model: adi,adm1278 @ 0x11 */ -i2c_slave_create_simple (i2c[12 ],TYPE_TMP421 ,0x4c ); -i2c_slave_create_simple (i2c[12 ],TYPE_TMP421 ,0x4d ); -i2c_slave_create_simple (i2c[12 ],TYPE_PCA9552 ,0x67 ); +i2c_slave_create_simple_orphan (i2c[12 ],TYPE_TMP421 ,0x4c ); +i2c_slave_create_simple_orphan (i2c[12 ],TYPE_TMP421 ,0x4d ); +i2c_slave_create_simple_orphan (i2c[12 ],TYPE_PCA9552 ,0x67 ); } static void aspeed_machine_bletchley_class_init(ObjectClass *oc,
hw/arm/aspeed_ast2600_catalina.c +29 -29
151 lines not on this page · raw message
hw/arm/aspeed_ast2600_evb.c +1 -1
@@ -27,7 +27,7 @@ static void ast2600_evb_i2c_init(AspeedMachineState *bmc) eeprom_buf);/* LM75 is compatible with TMP105 driver */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,8 ), +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,8 ),TYPE_TMP105 ,0x4d ); }
hw/arm/aspeed_ast2600_fby35.c +5 -5
@@ -102,12 +102,12 @@ static void fby35_i2c_init(AspeedMachineState *bmc) i2c[i] =aspeed_i2c_get_bus (&soc->i2c, i); } -i2c_slave_create_simple (i2c[2 ],TYPE_LM75 ,0x4f ); -i2c_slave_create_simple (i2c[8 ],TYPE_TMP421 ,0x1f ); +i2c_slave_create_simple_orphan (i2c[2 ],TYPE_LM75 ,0x4f ); +i2c_slave_create_simple_orphan (i2c[8 ],TYPE_TMP421 ,0x1f );/* Hotswap controller is actually supposed to be mp5920 or ltc4282. */ -i2c_slave_create_simple (i2c[11 ],"adm1272" ,0x44 ); -i2c_slave_create_simple (i2c[12 ],TYPE_LM75 ,0x4e ); -i2c_slave_create_simple (i2c[12 ],TYPE_LM75 ,0x4f ); +i2c_slave_create_simple_orphan (i2c[11 ],"adm1272" ,0x44 ); +i2c_slave_create_simple_orphan (i2c[12 ],TYPE_LM75 ,0x4e ); +i2c_slave_create_simple_orphan (i2c[12 ],TYPE_LM75 ,0x4f );at24c_eeprom_init (i2c[4 ],0x51 ,128 * KiB);at24c_eeprom_init (i2c[6 ],0x51 ,128 * KiB);
hw/arm/aspeed_ast2600_fuji.c +20 -20
@@ -27,7 +27,7 @@static void get_pca9548_channels (I2CBus *bus,uint8_t mux_addr,I2CBus **channels) { -I2CSlave *mux =i2c_slave_create_simple (bus,"pca9548" , mux_addr); +I2CSlave *mux =i2c_slave_create_simple_orphan (bus,"pca9548" , mux_addr);for (int i =0 ; i <8 ; i++) { channels[i] =pca954x_i2c_get_bus (mux, i); }
@@ -57,8 +57,8 @@ static void fuji_bmc_i2c_init(AspeedMachineState *bmc)get_pca9548_channels (i2c[40 + i],0x76 , &i2c[80 + i *8 ]); } -i2c_slave_create_simple (i2c[17 ],TYPE_LM75 ,0x4c ); -i2c_slave_create_simple (i2c[17 ],TYPE_LM75 ,0x4d ); +i2c_slave_create_simple_orphan (i2c[17 ],TYPE_LM75 ,0x4c ); +i2c_slave_create_simple_orphan (i2c[17 ],TYPE_LM75 ,0x4d );/* * EEPROM 24c64 size is 64Kbits or 8 Kbytes
@@ -68,33 +68,33 @@ static void fuji_bmc_i2c_init(AspeedMachineState *bmc)at24c_eeprom_init (i2c[20 ],0x50 ,256 );at24c_eeprom_init (i2c[22 ],0x52 ,256 ); -i2c_slave_create_simple (i2c[3 ],TYPE_LM75 ,0x48 ); -i2c_slave_create_simple (i2c[3 ],TYPE_LM75 ,0x49 ); -i2c_slave_create_simple (i2c[3 ],TYPE_LM75 ,0x4a ); -i2c_slave_create_simple (i2c[3 ],TYPE_TMP422 ,0x4c ); +i2c_slave_create_simple_orphan (i2c[3 ],TYPE_LM75 ,0x48 ); +i2c_slave_create_simple_orphan (i2c[3 ],TYPE_LM75 ,0x49 ); +i2c_slave_create_simple_orphan (i2c[3 ],TYPE_LM75 ,0x4a ); +i2c_slave_create_simple_orphan (i2c[3 ],TYPE_TMP422 ,0x4c );at24c_eeprom_init (i2c[8 ],0x51 ,8 * KiB); -i2c_slave_create_simple (i2c[8 ],TYPE_LM75 ,0x4a ); +i2c_slave_create_simple_orphan (i2c[8 ],TYPE_LM75 ,0x4a ); -i2c_slave_create_simple (i2c[50 ],TYPE_LM75 ,0x4c ); +i2c_slave_create_simple_orphan (i2c[50 ],TYPE_LM75 ,0x4c );at24c_eeprom_init (i2c[50 ],0x52 ,8 * KiB); -i2c_slave_create_simple (i2c[51 ],TYPE_TMP75 ,0x48 ); -i2c_slave_create_simple (i2c[52 ],TYPE_TMP75 ,0x49 ); +i2c_slave_create_simple_orphan (i2c[51 ],TYPE_TMP75 ,0x48 ); +i2c_slave_create_simple_orphan (i2c[52 ],TYPE_TMP75 ,0x49 ); -i2c_slave_create_simple (i2c[59 ],TYPE_TMP75 ,0x48 ); -i2c_slave_create_simple (i2c[60 ],TYPE_TMP75 ,0x49 ); +i2c_slave_create_simple_orphan (i2c[59 ],TYPE_TMP75 ,0x48 ); +i2c_slave_create_simple_orphan (i2c[60 ],TYPE_TMP75 ,0x49 );at24c_eeprom_init (i2c[65 ],0x53 ,8 * KiB); -i2c_slave_create_simple (i2c[66 ],TYPE_TMP75 ,0x49 ); -i2c_slave_create_simple (i2c[66 ],TYPE_TMP75 ,0x48 ); +i2c_slave_create_simple_orphan (i2c[66 ],TYPE_TMP75 ,0x49 ); +i2c_slave_create_simple_orphan (i2c[66 ],TYPE_TMP75 ,0x48 );at24c_eeprom_init (i2c[68 ],0x52 ,8 * KiB);at24c_eeprom_init (i2c[69 ],0x52 ,8 * KiB);at24c_eeprom_init (i2c[70 ],0x52 ,8 * KiB);at24c_eeprom_init (i2c[71 ],0x52 ,8 * KiB);at24c_eeprom_init (i2c[73 ],0x53 ,8 * KiB); -i2c_slave_create_simple (i2c[74 ],TYPE_TMP75 ,0x49 ); -i2c_slave_create_simple (i2c[74 ],TYPE_TMP75 ,0x48 ); +i2c_slave_create_simple_orphan (i2c[74 ],TYPE_TMP75 ,0x49 ); +i2c_slave_create_simple_orphan (i2c[74 ],TYPE_TMP75 ,0x48 );at24c_eeprom_init (i2c[76 ],0x52 ,8 * KiB);at24c_eeprom_init (i2c[77 ],0x52 ,8 * KiB);at24c_eeprom_init (i2c[78 ],0x52 ,8 * KiB);
@@ -103,9 +103,9 @@ static void fuji_bmc_i2c_init(AspeedMachineState *bmc)for (int i =0 ; i <8 ; i++) {at24c_eeprom_init (i2c[81 + i *8 ],0x56 ,64 * KiB); -i2c_slave_create_simple (i2c[82 + i *8 ],TYPE_TMP75 ,0x48 ); -i2c_slave_create_simple (i2c[83 + i *8 ],TYPE_TMP75 ,0x4b ); -i2c_slave_create_simple (i2c[84 + i *8 ],TYPE_TMP75 ,0x4a ); +i2c_slave_create_simple_orphan (i2c[82 + i *8 ],TYPE_TMP75 ,0x48 ); +i2c_slave_create_simple_orphan (i2c[83 + i *8 ],TYPE_TMP75 ,0x4b ); +i2c_slave_create_simple_orphan (i2c[84 + i *8 ],TYPE_TMP75 ,0x4a ); } }
hw/arm/aspeed_ast2600_gb200nvl.c +6 -6
@@ -54,12 +54,12 @@ static void gb200nvl_bmc_i2c_init(AspeedMachineState *bmc)aspeed_create_pca9554 (soc,4 ,0x21 );/* Mux I2c Expanders */ -i2c_slave_create_simple (i2c[5 ],"pca9546" ,0x71 ); -i2c_slave_create_simple (i2c[5 ],"pca9546" ,0x72 ); -i2c_slave_create_simple (i2c[5 ],"pca9546" ,0x73 ); -i2c_slave_create_simple (i2c[5 ],"pca9546" ,0x75 ); -i2c_slave_create_simple (i2c[5 ],"pca9546" ,0x76 ); -i2c_slave_create_simple (i2c[5 ],"pca9546" ,0x77 ); +i2c_slave_create_simple_orphan (i2c[5 ],"pca9546" ,0x71 ); +i2c_slave_create_simple_orphan (i2c[5 ],"pca9546" ,0x72 ); +i2c_slave_create_simple_orphan (i2c[5 ],"pca9546" ,0x73 ); +i2c_slave_create_simple_orphan (i2c[5 ],"pca9546" ,0x75 ); +i2c_slave_create_simple_orphan (i2c[5 ],"pca9546" ,0x76 ); +i2c_slave_create_simple_orphan (i2c[5 ],"pca9546" ,0x77 );/* Bus 10 */ dev =DEVICE (aspeed_create_pca9554 (soc,9 ,0x20 ));
hw/arm/aspeed_ast2600_rainier.c +23 -23
96 lines not on this page · raw message
hw/arm/aspeed_ast27x0-fc.c +1 -1
@@ -109,7 +109,7 @@ static bool ast2700fc_ca35_init(MachineState *machine, Error **errp)/* * AST2700 EVB has a LM75 temperature sensor on I2C bus 0 at address 0x4d. */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,0 ),"tmp105" ,0x4d ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,0 ),"tmp105" ,0x4d );aspeed_board_init_flashes (&soc->fmc,AST2700FC_FMC_MODEL ,2 ,0 );aspeed_board_init_flashes (&soc->spi[0 ],AST2700FC_SPI_MODEL ,1 ,2 );
hw/arm/aspeed_ast27x0_evb.c +1 -1
@@ -24,7 +24,7 @@ static void ast2700_evb_i2c_init(AspeedMachineState *bmc)AspeedSoCState *soc = bmc->soc;/* LM75 is compatible with TMP105 driver */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,0 ), +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,0 ),TYPE_TMP105 ,0x4d ); }
hw/arm/bananapi_m2u.c +1 -1
@@ -114,7 +114,7 @@ static void bpim2u_init(MachineState *machine)/* Connect AXP221 */ i2c =I2C_BUS (qdev_get_child_bus (DEVICE (&r40->i2c0),"i2c" )); -i2c_slave_create_simple (i2c,"axp221_pmu" ,0x34 ); +i2c_slave_create_simple_orphan (i2c,"axp221_pmu" ,0x34 );/* SDRAM */ memory_region_add_subregion(get_system_memory(),
hw/arm/cubieboard.c +1 -1
@@ -81,7 +81,7 @@ static void cubieboard_init(MachineState *machine)/* Connect AXP 209 */ i2c =I2C_BUS (qdev_get_child_bus (DEVICE (&a10->i2c0),"i2c" )); -i2c_slave_create_simple (i2c,"axp209_pmu" ,0x34 ); +i2c_slave_create_simple_orphan (i2c,"axp209_pmu" ,0x34 );/* Retrieve SD bus */ di =drive_get (IF_SD ,0 ,0 );
hw/arm/musicpal.c +1 -1
@@ -1327,7 +1327,7 @@ static void musicpal_init(MachineState *machine)qdev_connect_gpio_out (key_dev, i,qdev_get_gpio_in (dev, i +15 )); } - wm8750_dev =i2c_slave_new (TYPE_WM8750 ,MP_WM_ADDR ); + wm8750_dev =i2c_slave_new_orphan (TYPE_WM8750 ,MP_WM_ADDR );if (machine->audiodev) {qdev_prop_set_string (DEVICE (wm8750_dev),"audiodev" , machine->audiodev); }
hw/arm/npcm7xx_boards.c +21 -21
80 lines not on this page · raw message
hw/arm/npcm8xx_boards.c +1 -1
@@ -159,7 +159,7 @@ static void npcm8xx_connect_pwm_fan(NPCM8xxState *soc, SplitIRQ *splitter,static void npcm845_evb_i2c_init (NPCM8xxState *soc) {/* tmp100 temperature sensor on SVB, tmp105 is compatible */ -i2c_slave_create_simple (npcm8xx_i2c_get_bus (soc,6 ),"tmp105" ,0x48 ); +i2c_slave_create_simple_orphan (npcm8xx_i2c_get_bus (soc,6 ),"tmp105" ,0x48 ); }static void npcm845_evb_fan_init (NPCM8xxMachine *machine,NPCM8xxState *soc)
hw/arm/realview.c +1 -1
@@ -321,7 +321,7 @@ static void realview_init(MachineState *machine, dev =sysbus_create_simple_orphan (TYPE_ARM_SBCON_I2C ,0x10002000 ,NULL ); i2c = (I2CBus *)qdev_get_child_bus (dev,"i2c" ); -i2c_slave_create_simple (i2c,"ds1338" ,0x68 ); +i2c_slave_create_simple_orphan (i2c,"ds1338" ,0x68 );/* Memory map for RealView Emulation Baseboard: */ /* 0x10000000 System registers. */
hw/arm/stellaris.c +1 -1
@@ -1209,7 +1209,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)if (board->peripherals &BP_OLED_I2C ) {I2CBus *bus = (I2CBus *)qdev_get_child_bus (i2c_dev[0 ],"i2c" ); -i2c_slave_create_simple (bus,"ssd0303" ,0x3d ); +i2c_slave_create_simple_orphan (bus,"ssd0303" ,0x3d ); }for (i =0 ; i <NUM_UART ; i++) {
hw/arm/versatilepb.c +1 -1
@@ -341,7 +341,7 @@ static void versatile_init(MachineState *machine, int board_id) dev =sysbus_create_simple_orphan (TYPE_ARM_SBCON_I2C ,0x10002000 ,NULL ); i2c = (I2CBus *)qdev_get_child_bus (dev,"i2c" ); -i2c_slave_create_simple (i2c,"ds1338" ,0x68 ); +i2c_slave_create_simple_orphan (i2c,"ds1338" ,0x68 );/* Add PL041 AACI Interface to the LM4549 codec */ pl041 =qdev_new_orphan ("pl041" );
hw/arm/vexpress.c +1 -1
@@ -653,7 +653,7 @@ static void vexpress_common_init(MachineState *machine) dev =sysbus_create_simple_orphan (TYPE_ARM_SBCON_I2C , map[VE_SERIALDVI ],NULL ); i2c = (I2CBus *)qdev_get_child_bus (dev,"i2c" ); -i2c_slave_create_simple (i2c,"sii9022" ,0x39 ); +i2c_slave_create_simple_orphan (i2c,"sii9022" ,0x39 );sysbus_create_simple_orphan ("pl031" , map[VE_RTC ], pic[4 ]);/* RTC */
hw/display/sii9022.c +1 -1
@@ -164,7 +164,7 @@ static void sii9022_realize(DeviceState *dev, Error **errp)I2CBus *bus; bus =I2C_BUS (qdev_get_parent_bus (dev)); -i2c_slave_create_simple (bus,TYPE_I2CDDC ,0x50 ); +i2c_slave_create_simple_orphan (bus,TYPE_I2CDDC ,0x50 ); }static void sii9022_class_init (ObjectClass *klass,const void *data)
hw/i2c/aspeed_i2c.c +1 -1
@@ -1518,7 +1518,7 @@ static void aspeed_i2c_bus_realize(DeviceState *dev, Error **errp)sysbus_init_irq (SYS_BUS_DEVICE (dev), &s->irq); s->bus =i2c_init_bus (dev, s->name); - s->slave =i2c_slave_create_simple (s->bus,TYPE_ASPEED_I2C_BUS_SLAVE , + s->slave =i2c_slave_create_simple_orphan (s->bus,TYPE_ASPEED_I2C_BUS_SLAVE ,0xff ); memory_region_init_io(&s->mr, OBJECT(s), &aspeed_i2c_bus_ops,
hw/i2c/core.c +23 -3
@@ -364,7 +364,7 @@ const VMStateDescription vmstate_i2c_slave = { } }; -I2CSlave *i2c_slave_new (const char *name,uint8_t addr) +I2CSlave *i2c_slave_new_orphan (const char *name,uint8_t addr) {DeviceState *dev;
@@ -373,14 +373,34 @@ I2CSlave *i2c_slave_new(const char *name, uint8_t addr)return I2C_SLAVE (dev); } +I2CSlave *i2c_slave_new (Object *parent,const char *id, +const char *type,uint8_t addr) +{ +DeviceState *dev; + + dev =qdev_new (parent, id, type); +qdev_prop_set_uint8 (dev,"address" , addr); +return I2C_SLAVE (dev); +} + +I2CSlave *i2c_slave_create_simple (Object *parent,const char *id, +I2CBus *bus,const char *type, +uint8_t addr) +{ +I2CSlave *dev =i2c_slave_new (parent, id, type, addr); + +qdev_realize (DEVICE (dev),BUS (bus), &error_abort); +return dev; +} +bool i2c_slave_realize_and_unref (I2CSlave *dev,I2CBus *bus,Error **errp) {return qdev_realize_and_unref (&dev->qdev, &bus->qbus, errp); } -I2CSlave *i2c_slave_create_simple (I2CBus *bus,const char *name,uint8_t addr) +I2CSlave *i2c_slave_create_simple_orphan (I2CBus *bus,const char *name,uint8_t addr) { -I2CSlave *dev =i2c_slave_new (name, addr); +I2CSlave *dev =i2c_slave_new_orphan (name, addr);i2c_slave_realize_and_unref (dev, bus, &error_abort);
hw/i3c/core.c +1 -1
@@ -623,7 +623,7 @@ void legacy_i2c_end_transfer(I3CBus *bus)I2CSlave *legacy_i2c_device_create_simple (I3CBus *bus,const char *name,uint8_t addr) { -I2CSlave *dev =i2c_slave_new (name, addr); +I2CSlave *dev =i2c_slave_new_orphan (name, addr);i2c_slave_realize_and_unref (dev, bus->i2c_bus, &error_abort);return dev;
hw/nvram/eeprom_at24c.c +1 -1
@@ -148,7 +148,7 @@ I2CSlave *at24c_eeprom_init_rom(I2CBus *bus, uint8_t address, uint32_t rom_size, {EEPROMState *s; - s =AT24C_EE (i2c_slave_new (TYPE_AT24C_EE , address)); + s =AT24C_EE (i2c_slave_new_orphan (TYPE_AT24C_EE , address));qdev_prop_set_uint32 (DEVICE (s),"rom-size" , rom_size);
hw/ppc/e500.c +1 -1
@@ -1025,7 +1025,7 @@ void ppce500_init(MachineState *machine)memory_region_add_subregion (ccsr_addr_space,MPC8544_I2C_REGS_OFFSET ,sysbus_mmio_get_region (s,0 )); i2c =I2C_BUS (qdev_get_child_bus (dev,"i2c" )); -i2c_slave_create_simple (i2c,"ds1338" ,RTC_REGS_OFFSET ); +i2c_slave_create_simple_orphan (i2c,"ds1338" ,RTC_REGS_OFFSET );/* eSDHC */ if (pmc->has_esdhc) {
hw/ppc/pnv.c +2 -2
@@ -2825,7 +2825,7 @@ static void pnv_rainier_i2c_init(PnvMachineState *pnv)* Add a PCA9552 I2C device for PCIe hotplug control * to engine 2, bus 1, address 0x63 */ -I2CSlave *dev =i2c_slave_create_simple (chip10->i2c[2 ].busses[1 ], +I2CSlave *dev =i2c_slave_create_simple_orphan (chip10->i2c[2 ].busses[1 ],"pca9552" ,0x63 );/*
@@ -2843,7 +2843,7 @@ static void pnv_rainier_i2c_init(PnvMachineState *pnv)* Add a PCA9554 I2C device for cable card presence detection * to engine 2, bus 1, address 0x25 */ -i2c_slave_create_simple (chip10->i2c[2 ].busses[1 ],"pca9554" ,0x25 ); +i2c_slave_create_simple_orphan (chip10->i2c[2 ].busses[1 ],"pca9554" ,0x25 ); } }
hw/ppc/sam460ex.c +1 -1
@@ -345,7 +345,7 @@ static void sam460ex_init(MachineState *machine) spd_data[20 ] =4 ;/* SO-DIMM module */ smbus_eeprom_init_one (i2c,0x50 , spd_data);/* RTC */ -i2c_slave_create_simple (i2c,"m41t80" ,0x68 ); +i2c_slave_create_simple_orphan (i2c,"m41t80" ,0x68 ); dev =sysbus_create_simple_orphan (TYPE_PPC4xx_I2C,0x4ef600800 ,qdev_get_gpio_in (uic[0 ],3 ));
hw/riscv/tt_atlantis.c +2 -2
@@ -575,8 +575,8 @@ static void tt_atlantis_machine_init(MachineState *machine) }/* I2C peripherals: qemu specific */ -i2c_slave_create_simple (i2c_get_bus (s,0 ),"ds1338" ,0x6f ); -i2c_slave_create_simple (i2c_get_bus (s,4 ),"tmp105" ,0x48 ); +i2c_slave_create_simple_orphan (i2c_get_bus (s,0 ),"ds1338" ,0x6f ); +i2c_slave_create_simple_orphan (i2c_get_bus (s,4 ),"tmp105" ,0x48 );/* Load or create device tree */ if (machine->dtb) {
include/hw/arm/aspeed.h +2 -2
@@ -83,7 +83,7 @@ void aspeed_machine_class_init_cpus_defaults(MachineClass *mc);* * Create and attach a PCA9552 LED controller device to the specified I2C bus * of the given Aspeed SoC. The device is instantiated using -* i2c_slave_create_simple() with the PCA9552 device type. +* i2c_slave_create_simple_orphan() with the PCA9552 device type. */ void aspeed_create_pca9552 (AspeedSoCState *soc,int bus_id,int addr);
@@ -95,7 +95,7 @@ void aspeed_create_pca9552(AspeedSoCState *soc, int bus_id, int addr);* * Create and attach a PCA9554 I/O expander to the specified I2C bus * of the given Aspeed SoC. The device is created via -* i2c_slave_create_simple() and returned as an #I2CSlave pointer. +* i2c_slave_create_simple_orphan() and returned as an #I2CSlave pointer. * * Returns: a pointer to the newly created #I2CSlave instance. */
include/hw/i2c/i2c.h +34 -4
@@ -163,7 +163,20 @@ bool i2c_scan_bus(I2CBus *bus, uint8_t address, bool broadcast,* properties to be set. Type @name must exist. The device still * needs to be realized. See qdev-core.h. */ -I2CSlave *i2c_slave_new (const char *name,uint8_t addr); +I2CSlave *i2c_slave_new_orphan (const char *name,uint8_t addr); + +/** +* Create a parented I2C slave device on the heap. +* @parent: the QOM parent +* @id: child<> property name +* @type: I2C slave device type name +* @addr: I2C address of the slave when put on a bus +* +* Like i2c_slave_new_orphan(), but the returned device is owned by +* @parent's child<> property. Pair with qdev_realize(). +*/ +I2CSlave *i2c_slave_new (Object *parent,const char *id, +const char *type,uint8_t addr);/** * Create and realize an I2C slave device on the heap.
@@ -174,7 +187,24 @@ I2CSlave *i2c_slave_new(const char *name, uint8_t addr);* Create the device state structure, initialize it, put it on the * specified @bus, and drop the reference to it (the device is realized). */ -I2CSlave *i2c_slave_create_simple (I2CBus *bus,const char *name,uint8_t addr); +I2CSlave *i2c_slave_create_simple_orphan (I2CBus *bus,const char *name, +uint8_t addr); + +/** +* Create, parent and realize an I2C slave device on the heap. +* @parent: the QOM parent +* @id: child<> property name +* @bus: I2C bus to put it on +* @type: I2C slave device type name +* @addr: I2C address of the slave when put on a bus +* +* Create the device state structure, add it as a child of @parent, +* put it on the specified @bus and realize it. The returned device +* is owned by @parent. +*/ +I2CSlave *i2c_slave_create_simple (Object *parent,const char *id, +I2CBus *bus,const char *type, +uint8_t addr);/** * Realize and drop a reference an I2C slave device
@@ -189,10 +219,10 @@ I2CSlave *i2c_slave_create_simple(I2CBus *bus, const char *name, uint8_t addr);* reference to it. * * This function is useful if you have created @dev via qdev_new_orphan(), -* i2c_slave_new() or i2c_slave_try_new() (which take a reference to +* i2c_slave_new_orphan() or i2c_slave_try_new() (which take a reference to * the device it returns to you), so that you can set properties on it * before realizing it. If you don't need to set properties then -* i2c_slave_create_simple() is probably better (as it does the create, +* i2c_slave_create_simple_orphan() is probably better (as it does the create, * init and realize in one step). * * If you are embedding the I2C slave into another QOM device and
scripts/coccinelle/qom-parent/i2c-slave-new-orphan.cocci new file +18 -0
@@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// +// Rename i2c_slave_new()/i2c_slave_create_simple() to *_orphan() +// so that the short names can be reintroduced with a mandatory +// (parent, id, ...) signature. +// +// spatch --sp-file scripts/coccinelle/qom-parent/i2c-slave-new-orphan.cocci \ +// --in-place --include-headers --dir . + +@@ +@@ +- i2c_slave_new ++ i2c_slave_new_orphan + +@@ +@@ +- i2c_slave_create_simple ++ i2c_slave_create_simple_orphan
Signature · 1 line
2.47.1
RFC PATCH 8/134 ssi, usb: Make bus-layer creators take a QOM parent
In reply to Alexander GrafApply the rename-and-reintroduce treatment to the remaining bus-layer helpers that wrap qdev_new_orphan():
ssi_create_peripheral() -> ssi_create_peripheral_orphan()
usb_create_simple() -> usb_create_simple_orphan()
and reintroduce the short names with a leading (parent, id, ...) pair. Also add a usb_new(parent, id, type) helper for callers that need to set properties before realize.
sd-bus, apple-desktop-bus, HDA, aux-bus and spapr-vio have no bus- layer creation wrapper: their onboard devices are open-coded via qdev_new_orphan() at each call site and will be converted directly to qdev_new(parent, id, type) in the per-subdirectory conversion patches.
The mechanical rename part is generated by
spatch --sp-file scripts/coccinelle/qom-parent/ssi-usb-orphan.cocci \
--in-place --include-headers --dir .
or equivalently
git ls-files '*.[ch]' '*.[ch].inc' '*.rst' '*.py' | \
grep -v '^subprojects/' | \
xargs sed -i \
's/\bssi_create_peripheral\b/&_orphan/g;
s/\busb_create_simple\b/&_orphan/g'--- hw/arm/stellaris.c | 2 +- hw/hppa/machine.c | 4 ++-- hw/mips/loongson3_virt.c | 4 ++-- hw/ppc/mac_newworld.c | 4 ++-- hw/ppc/sam460ex.c | 4 ++-- hw/ppc/spapr.c | 4 ++-- hw/riscv/sifive_u.c | 2 +- hw/sh4/r2d.c | 2 +- hw/ssi/ssi.c | 11 ++++++++++- hw/vmapple/vmapple.c | 4 ++-- include/hw/ssi/ssi.h | 6 ++++-- include/hw/usb/usb.h | 18 +++++++++++++++++- .../coccinelle/qom-parent/ssi-usb-orphan.cocci | 18 ++++++++++++++++++ 13 files changed, 64 insertions(+), 19 deletions(-) create mode 100644 scripts/coccinelle/qom-parent/ssi-usb-orphan.cocci
hw/arm/stellaris.c +1 -1
@@ -1300,7 +1300,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)* - Make the ssd0323 OLED controller chipselect active-low */ bus =qdev_get_child_bus (dev,"ssi" ); - sddev =ssi_create_peripheral (bus,"ssi-sd" ); + sddev =ssi_create_peripheral_orphan (bus,"ssi-sd" ); dinfo =drive_get (IF_SD ,0 ,0 ); blk = dinfo ?blk_by_legacy_dinfo (dinfo) :NULL ;
hw/hppa/machine.c +2 -2
@@ -446,8 +446,8 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,pci_create_simple_orphan (pci_bus,-1 ,"pci-ohci" ); usb_bus =USB_BUS (object_resolve_type_unambiguous (TYPE_USB_BUS , &error_abort)); -usb_create_simple (usb_bus,"usb-kbd" ); -usb_create_simple (usb_bus,"usb-mouse" ); +usb_create_simple_orphan (usb_bus,"usb-kbd" ); +usb_create_simple_orphan (usb_bus,"usb-mouse" ); }/* register power switch emulation */
hw/mips/loongson3_virt.c +2 -2
@@ -468,8 +468,8 @@ static inline void loongson3_virt_devices_init(MachineState *machine,pci_create_simple_orphan (pci_bus,-1 ,"pci-ohci" ); usb_bus =USB_BUS (object_resolve_type_unambiguous (TYPE_USB_BUS , &error_abort)); -usb_create_simple (usb_bus,"usb-kbd" ); -usb_create_simple (usb_bus,"usb-tablet" ); +usb_create_simple_orphan (usb_bus,"usb-kbd" ); +usb_create_simple_orphan (usb_bus,"usb-tablet" ); }pci_init_nic_devices (pci_bus, mc->default_nic);
hw/ppc/mac_newworld.c +2 -2
@@ -425,8 +425,8 @@ static void ppc_core99_init(MachineState *machine) usb_bus =USB_BUS (object_resolve_type_unambiguous (TYPE_USB_BUS , &error_abort)); -usb_create_simple (usb_bus,"usb-kbd" ); -usb_create_simple (usb_bus,"usb-mouse" ); +usb_create_simple_orphan (usb_bus,"usb-kbd" ); +usb_create_simple_orphan (usb_bus,"usb-mouse" ); } }
hw/ppc/sam460ex.c +2 -2
@@ -398,8 +398,8 @@ static void sam460ex_init(MachineState *machine)sysbus_connect_irq (sbdev,0 ,qdev_get_gpio_in (uic[2 ],30 )); usb_bus =USB_BUS (object_resolve_type_unambiguous (TYPE_USB_BUS , &error_abort)); -usb_create_simple (usb_bus,"usb-kbd" ); -usb_create_simple (usb_bus,"usb-mouse" ); +usb_create_simple_orphan (usb_bus,"usb-kbd" ); +usb_create_simple_orphan (usb_bus,"usb-mouse" );/* PCIe buses */ dev =qdev_new_orphan (TYPE_PPC460EX_PCIE_HOST );
hw/ppc/spapr.c +2 -2
@@ -3082,8 +3082,8 @@ static void spapr_machine_init(MachineState *machine) usb_bus =USB_BUS (object_resolve_type_unambiguous (TYPE_USB_BUS , &error_abort)); -usb_create_simple (usb_bus,"usb-kbd" ); -usb_create_simple (usb_bus,"usb-mouse" ); +usb_create_simple_orphan (usb_bus,"usb-kbd" ); +usb_create_simple_orphan (usb_bus,"usb-mouse" ); } }
hw/riscv/sifive_u.c +1 -1
@@ -606,7 +606,7 @@ static void sifive_u_machine_init(MachineState *machine)sysbus_connect_irq (SYS_BUS_DEVICE (&s->soc.spi0),1 , flash_cs);/* Connect an SD card to SPI2 */ - sd_dev =ssi_create_peripheral (s->soc.spi2.spi,"ssi-sd" ); + sd_dev =ssi_create_peripheral_orphan (s->soc.spi2.spi,"ssi-sd" ); sd_cs =qdev_get_gpio_in_named (sd_dev,SSI_GPIO_CS ,0 );sysbus_connect_irq (SYS_BUS_DEVICE (&s->soc.spi2),1 , sd_cs);
hw/sh4/r2d.c +1 -1
@@ -320,7 +320,7 @@ static void r2d_init(MachineState *machine)/* USB keyboard */ usb_bus =USB_BUS (object_resolve_type_unambiguous (TYPE_USB_BUS , &error_abort)); -usb_create_simple (usb_bus,"usb-kbd" ); +usb_create_simple_orphan (usb_bus,"usb-kbd" );/* Todo: register on board registers */ memset (&boot_params,0 ,sizeof (boot_params));
hw/ssi/ssi.c +10 -1
@@ -138,7 +138,16 @@ bool ssi_realize_and_unref(DeviceState *dev, SSIBus *bus, Error **errp)return qdev_realize_and_unref (dev, &bus->parent_obj, errp); } -DeviceState *ssi_create_peripheral (SSIBus *bus,const char *name) +DeviceState *ssi_create_peripheral (Object *parent,const char *id, +SSIBus *bus,const char *type) +{ +DeviceState *dev =qdev_new (parent, id, type); + +qdev_realize (dev,BUS (bus), &error_fatal); +return dev; +} + +DeviceState *ssi_create_peripheral_orphan (SSIBus *bus,const char *name) {DeviceState *dev =qdev_new_orphan (name);
hw/vmapple/vmapple.c +2 -2
@@ -425,8 +425,8 @@ static void create_pcie(VMAppleMachineState *vms) usb_bus =USB_BUS (object_resolve_type_unambiguous (TYPE_USB_BUS , &error_fatal)); -usb_create_simple (usb_bus,"usb-kbd" ); -usb_create_simple (usb_bus,"usb-tablet" ); +usb_create_simple_orphan (usb_bus,"usb-kbd" ); +usb_create_simple_orphan (usb_bus,"usb-tablet" ); } }
include/hw/ssi/ssi.h +4 -2
@@ -81,7 +81,9 @@ extern const VMStateDescription vmstate_ssi_peripheral; .offset = vmstate_offset_value(_state, _field, SSIPeripheral), \ } -DeviceState *ssi_create_peripheral (SSIBus *bus,const char *name); +DeviceState *ssi_create_peripheral (Object *parent,const char *id, +SSIBus *bus,const char *type); +DeviceState *ssi_create_peripheral_orphan (SSIBus *bus,const char *name);/** * ssi_realize_and_unref: realize and unref an SSI peripheral * @dev: SSI peripheral to realize
@@ -95,7 +97,7 @@ DeviceState *ssi_create_peripheral(SSIBus *bus, const char *name);* This function is useful if you have created @dev via qdev_new_orphan() * (which takes a reference to the device it returns to you), so that * you can set properties on it before realizing it. If you don't need -* to set properties then ssi_create_peripheral() is probably better (as it +* to set properties then ssi_create_peripheral_orphan() is probably better (as it * does the create, init and realize in one step). * * If you are embedding the SSI peripheral into another QOM device and
include/hw/usb/usb.h +17 -1
@@ -584,7 +584,23 @@ static inline bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **erreturn qdev_realize_and_unref (&dev->qdev, &bus->qbus, errp); } -static inline USBDevice *usb_create_simple (USBBus *bus,const char *name) +static inline USBDevice *usb_new (Object *parent,const char *id, +const char *type) +{ +return USB_DEVICE (qdev_new (parent, id, type)); +} + +static inline USBDevice *usb_create_simple (Object *parent,const char *id, +USBBus *bus,const char *type) +{ +USBDevice *dev =usb_new (parent, id, type); + +qdev_realize (DEVICE (dev),BUS (bus), &error_abort); +return dev; +} + +static inline USBDevice *usb_create_simple_orphan (USBBus *bus, +const char *name) {USBDevice *dev =USB_DEVICE (qdev_new_orphan (name));
scripts/coccinelle/qom-parent/ssi-usb-orphan.cocci new file +18 -0
@@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// +// Rename ssi_create_peripheral()/usb_create_simple() to *_orphan() +// so that the short names can be reintroduced with a mandatory +// (parent, id, ...) signature. +// +// spatch --sp-file scripts/coccinelle/qom-parent/ssi-usb-orphan.cocci \ +// --in-place --include-headers --dir . + +@@ +@@ +- ssi_create_peripheral ++ ssi_create_peripheral_orphan + +@@ +@@ +- usb_create_simple ++ usb_create_simple_orphan
Signature · 1 line
2.47.1
RFC PATCH 9/134 cpu: Make cpu_create() take a QOM parent
In reply to Alexander GrafCPUs are the single largest source of orphans in /machine/unattached because virtually every board that isn't SoC-based creates them via cpu_create(), which calls object_new() with no parent. This is also where the user-visible garbage in query-cpus-fast comes from: qom_path reads /machine/unattached/device[N] instead of /machine/cpu[N].
Apply the same rename-and-reintroduce treatment: mechanically rename cpu_create() to cpu_create_orphan() and reintroduce cpu_create() with a leading (parent, id, ...) pair built on object_new_child(). On realize failure the parented variant unparents (rather than unrefs) since the sole reference is held by the parent.
The mechanical rename part is generated by
spatch --sp-file \
scripts/coccinelle/qom-parent/cpu-create-orphan.cocci \
--in-place --include-headers --dir .or equivalently
git ls-files '*.[ch]' '*.[ch].inc' '*.rst' '*.py' | \
grep -v '^subprojects/' | \
xargs sed -i 's/\bcpu_create\b/cpu_create_orphan/g'--- bsd-user/main.c | 2 +- hw/alpha/dp264.c | 2 +- hw/arm/musicpal.c | 2 +- hw/arm/omap1.c | 2 +- hw/arm/strongarm.c | 2 +- hw/core/cpu-common.c | 14 +++++++++++++- hw/core/null-machine.c | 2 +- hw/hppa/machine.c | 2 +- hw/m68k/an5206.c | 2 +- hw/m68k/mcf5208.c | 2 +- hw/m68k/next-cube.c | 2 +- hw/m68k/virt.c | 2 +- hw/or1k/or1k-sim.c | 2 +- hw/or1k/virt.c | 2 +- hw/ppc/amigaone.c | 2 +- hw/ppc/mac_newworld.c | 2 +- hw/ppc/mac_oldworld.c | 2 +- hw/ppc/pegasos.c | 2 +- hw/ppc/ppc440_bamboo.c | 2 +- hw/ppc/prep.c | 2 +- hw/ppc/sam460ex.c | 2 +- hw/ppc/virtex_ml507.c | 2 +- hw/sh4/r2d.c | 2 +- hw/tricore/tricore_testboard.c | 2 +- hw/xtensa/sim.c | 2 +- hw/xtensa/xtfpga.c | 2 +- include/hw/core/cpu.h | 15 ++++++++++++++- linux-user/main.c | 4 ++-- .../coccinelle/qom-parent/cpu-create-orphan.cocci | 13 +++++++++++++ 29 files changed, 67 insertions(+), 29 deletions(-) create mode 100644 scripts/coccinelle/qom-parent/cpu-create-orphan.cocci
bsd-user/main.c +1 -1
@@ -475,7 +475,7 @@ int main(int argc, char **argv)set_preferred_target_page_bits (ctz32 (host_page_size));finalize_target_page_bits (); - cpu =cpu_create (cpu_type); + cpu =cpu_create_orphan (cpu_type); env =cpu_env (cpu);cpu_reset (cpu); thread_cpu = cpu;
hw/alpha/dp264.c +1 -1
@@ -65,7 +65,7 @@ static void clipper_init(MachineState *machine)/* Create up to 4 cpus. */ memset (cpus,0 ,sizeof (cpus));for (i =0 ; i < smp_cpus; ++i) { - cpus[i] =ALPHA_CPU (cpu_create (machine->cpu_type)); + cpus[i] =ALPHA_CPU (cpu_create_orphan (machine->cpu_type)); }/*
hw/arm/musicpal.c +1 -1
@@ -1232,7 +1232,7 @@ static void musicpal_init(MachineState *machine)exit (EXIT_FAILURE ); } - cpu =ARM_CPU (cpu_create (machine->cpu_type)); + cpu =ARM_CPU (cpu_create_orphan (machine->cpu_type));memory_region_add_subregion (address_space_mem,0 , machine->ram);
hw/arm/omap1.c +1 -1
@@ -3749,7 +3749,7 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *dram,MemoryRegion *system_memory =get_system_memory ();/* Core */ - s->cpu =ARM_CPU (cpu_create (cpu_type)); + s->cpu =ARM_CPU (cpu_create_orphan (cpu_type)); s->sdram_size =memory_region_size (dram); s->sram_size =OMAP15XX_SRAM_SIZE ;
hw/arm/strongarm.c +1 -1
@@ -1620,7 +1620,7 @@ StrongARMState *sa1110_init(const char *cpu_type)exit (1 ); } - s->cpu =ARM_CPU (cpu_create (cpu_type)); + s->cpu =ARM_CPU (cpu_create_orphan (cpu_type)); s->pic = sysbus_create_varargs_orphan("strongarm_pic", 0x90050000, qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_IRQ),
hw/core/cpu-common.c +13 -1
@@ -56,7 +56,19 @@ bool cpu_exists(int64_t id)return !!cpu_by_arch_id (id); } -CPUState *cpu_create (const char *typename) +CPUState *cpu_create (Object *parent,const char *id,const char *typename) +{ +Error *err =NULL ; +CPUState *cpu =CPU (object_new_child (parent, id, typename)); +if (!qdev_realize (DEVICE (cpu),NULL , &err)) { +error_report_err (err); +object_unparent (OBJECT (cpu)); +exit (EXIT_FAILURE ); + } +return cpu; +} + +CPUState *cpu_create_orphan (const char *typename) {Error *err =NULL ;CPUState *cpu =CPU (object_new (typename));
hw/core/null-machine.c +1 -1
@@ -25,7 +25,7 @@ static void machine_none_init(MachineState *mch)/* Initialize CPU (if user asked for it) */ if (mch->cpu_type) { - cpu =cpu_create (mch->cpu_type); + cpu =cpu_create_orphan (mch->cpu_type);if (!cpu) {error_report ("Unable to initialize CPU" );exit (1 );
hw/hppa/machine.c +1 -1
@@ -298,7 +298,7 @@ static TranslateFn *machine_HP_common_init_cpus(MachineState *machine)/* Create CPUs. */ for (unsigned int i =0 ; i < smp_cpus; i++) { - cpu[i] =HPPA_CPU (cpu_create (machine->cpu_type)); + cpu[i] =HPPA_CPU (cpu_create_orphan (machine->cpu_type)); }/* Initialize memory */
hw/m68k/an5206.c +1 -1
@@ -46,7 +46,7 @@ static void an5206_init(MachineState *machine)MemoryRegion *address_space_mem =get_system_memory ();MemoryRegion *sram =g_new (MemoryRegion,1 ); - cpu =M68K_CPU (cpu_create (machine->cpu_type)); + cpu =M68K_CPU (cpu_create_orphan (machine->cpu_type)); env = &cpu->env;/* Initialize CPU registers. */
hw/m68k/mcf5208.c +1 -1
@@ -288,7 +288,7 @@ static void mcf5208evb_init(MachineState *machine)MemoryRegion *sram =g_new (MemoryRegion,1 );DeviceState *intc; - cpu =M68K_CPU (cpu_create (machine->cpu_type)); + cpu =M68K_CPU (cpu_create_orphan (machine->cpu_type)); env = &cpu->env;/* Initialize CPU registers. */
hw/m68k/next-cube.c +1 -1
@@ -1260,7 +1260,7 @@ static void next_cube_init(MachineState *machine)DeviceState *pcdev;/* Initialize the cpu core */ - cpu =M68K_CPU (cpu_create (machine->cpu_type)); + cpu =M68K_CPU (cpu_create_orphan (machine->cpu_type));if (!cpu) {error_report ("Unable to find m68k CPU definition" );exit (1 );
hw/m68k/virt.c +1 -1
@@ -145,7 +145,7 @@ static void virt_init(MachineState *machine) reset_info =g_new0 (ResetInfo,1 );/* init CPUs */ - cpu =M68K_CPU (cpu_create (machine->cpu_type)); + cpu =M68K_CPU (cpu_create_orphan (machine->cpu_type)); reset_info->cpu = cpu;qemu_register_reset (main_cpu_reset, reset_info);
hw/or1k/or1k-sim.c +1 -1
@@ -299,7 +299,7 @@ static void openrisc_sim_init(MachineState *machine)assert (smp_cpus >=1 && smp_cpus <=OR1KSIM_CPUS_MAX );for (n =0 ; n < smp_cpus; n++) { - cpus[n] =OPENRISC_CPU (cpu_create (machine->cpu_type)); + cpus[n] =OPENRISC_CPU (cpu_create_orphan (machine->cpu_type));if (cpus[n] ==NULL ) {fprintf (stderr,"Unable to find CPU definition!\n" );exit (1 );
hw/or1k/virt.c +1 -1
@@ -481,7 +481,7 @@ static void openrisc_virt_init(MachineState *machine)assert (smp_cpus >=1 && smp_cpus <=VIRT_CPUS_MAX );for (n =0 ; n < smp_cpus; n++) { - cpus[n] =OPENRISC_CPU (cpu_create (machine->cpu_type)); + cpus[n] =OPENRISC_CPU (cpu_create_orphan (machine->cpu_type));if (cpus[n] ==NULL ) {fprintf (stderr,"Unable to find CPU definition!\n" );exit (1 );
hw/ppc/amigaone.c +1 -1
@@ -279,7 +279,7 @@ static void amigaone_init(MachineState *machine)struct boot_info *bi =NULL ;/* init CPU */ - cpu =POWERPC_CPU (cpu_create (machine->cpu_type)); + cpu =POWERPC_CPU (cpu_create_orphan (machine->cpu_type)); env = &cpu->env;if (PPC_INPUT (env) != PPC_FLAGS_INPUT_6xx) {error_report ("Incompatible CPU, only 6xx bus supported" );
hw/ppc/mac_newworld.c +1 -1
@@ -159,7 +159,7 @@ static void ppc_core99_init(MachineState *machine)/* init CPUs */ for (i =0 ; i < machine->smp.cpus; i++) { - cpu =POWERPC_CPU (cpu_create (machine->cpu_type)); + cpu =POWERPC_CPU (cpu_create_orphan (machine->cpu_type)); env = &cpu->env;/* Set time-base frequency to 100 Mhz */
hw/ppc/mac_oldworld.c +1 -1
@@ -111,7 +111,7 @@ static void ppc_heathrow_init(MachineState *machine)/* init CPUs */ for (i =0 ; i < machine->smp.cpus; i++) { - cpu =POWERPC_CPU (cpu_create (machine->cpu_type)); + cpu =POWERPC_CPU (cpu_create_orphan (machine->cpu_type)); env = &cpu->env;/* Set time-base frequency to 16.6 Mhz */
hw/ppc/pegasos.c +1 -1
@@ -163,7 +163,7 @@ static void pegasos_init(MachineState *machine)uint8_t *spd_data;/* init CPU */ - pm->cpu =POWERPC_CPU (cpu_create (machine->cpu_type)); + pm->cpu =POWERPC_CPU (cpu_create_orphan (machine->cpu_type)); env = &pm->cpu->env;if (PPC_INPUT (env) != PPC_FLAGS_INPUT_6xx) {error_report ("Incompatible CPU, only 6xx bus supported" );
hw/ppc/ppc440_bamboo.c +1 -1
@@ -148,7 +148,7 @@ static void bamboo_init(MachineState *machine)exit (EXIT_FAILURE ); } - cpu =POWERPC_CPU (cpu_create (machine->cpu_type)); + cpu =POWERPC_CPU (cpu_create_orphan (machine->cpu_type)); env = &cpu->env;if (env->mmu_model !=POWERPC_MMU_BOOKE ) {
hw/ppc/prep.c +1 -1
@@ -257,7 +257,7 @@ static void ibm_40p_init(MachineState *machine) }/* init CPU */ - cpu =POWERPC_CPU (cpu_create (machine->cpu_type)); + cpu =POWERPC_CPU (cpu_create_orphan (machine->cpu_type)); env = &cpu->env;if (PPC_INPUT (env) != PPC_FLAGS_INPUT_6xx) {error_report ("only 6xx bus is supported on this machine" );
hw/ppc/sam460ex.c +1 -1
@@ -260,7 +260,7 @@ static void sam460ex_init(MachineState *machine)uint8_t *spd_data;int success; - cpu =POWERPC_CPU (cpu_create (machine->cpu_type)); + cpu =POWERPC_CPU (cpu_create_orphan (machine->cpu_type)); env = &cpu->env;if (env->mmu_model !=POWERPC_MMU_BOOKE ) {error_report ("Only MMU model BookE is supported by this machine." );
hw/ppc/virtex_ml507.c +1 -1
@@ -76,7 +76,7 @@ static PowerPCCPU *ppc440_init_xilinx(const char *cpu_type, uint32_t sysclk)DeviceState *uicdev;SysBusDevice *uicsbd; - cpu =POWERPC_CPU (cpu_create (cpu_type)); + cpu =POWERPC_CPU (cpu_create_orphan (cpu_type)); env = &cpu->env;ppc_booke_timers_init (cpu, sysclk,0 /* no flags */ );
hw/sh4/r2d.c +1 -1
@@ -251,7 +251,7 @@ static void r2d_init(MachineState *machine)USBBus *usb_bus;r2d_fpga_t *fpga; - cpu =SUPERH_CPU (cpu_create (machine->cpu_type)); + cpu =SUPERH_CPU (cpu_create_orphan (machine->cpu_type)); env = &cpu->env; reset_info =g_new0 (ResetData,1 );
hw/tricore/tricore_testboard.c +1 -1
@@ -67,7 +67,7 @@ static void tricore_testboard_init(MachineState *machine, int board_id)MemoryRegion *pcp_data =g_new (MemoryRegion,1 );MemoryRegion *pcp_text =g_new (MemoryRegion,1 ); - cpu =TRICORE_CPU (cpu_create (machine->cpu_type)); + cpu =TRICORE_CPU (cpu_create_orphan (machine->cpu_type)); env = &cpu->env;memory_region_init_ram (ext_cram,NULL ,"powerlink_ext_c.ram" ,2 * MiB, &error_fatal);
hw/xtensa/sim.c +1 -1
@@ -63,7 +63,7 @@ XtensaCPU *xtensa_sim_common_init(MachineState *machine)int n;for (n =0 ; n < machine->smp.cpus; n++) { - cpu =XTENSA_CPU (cpu_create (machine->cpu_type)); + cpu =XTENSA_CPU (cpu_create_orphan (machine->cpu_type)); env = &cpu->env; env->sregs[PRID ] = n;
hw/xtensa/xtfpga.c +1 -1
@@ -250,7 +250,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine)for (n =0 ; n < smp_cpus; n++) {CPUXtensaState *cenv =NULL ; - cpu =XTENSA_CPU (cpu_create (machine->cpu_type)); + cpu =XTENSA_CPU (cpu_create_orphan (machine->cpu_type)); cenv = &cpu->env;if (!env) { env = cenv;
include/hw/core/cpu.h +14 -1
@@ -846,13 +846,26 @@ char *cpu_model_from_type(const char *typename);/** * cpu_create: +* @parent: the QOM parent (usually the machine or SoC container) +* @id: child<> property name, e.g. "cpu[0]" or "cpu[*]" +* @typename: the CPU type +* +* Instantiates a CPU as a child of @parent under @id and realizes it. +* The returned CPU is owned by @parent. +* +* Returns: A #CPUState. Failure to realize is fatal. +*/ +CPUState *cpu_create (Object *parent,const char *id,const char *typename); + +/** +* cpu_create_orphan: * @typename: The CPU type. * * Instantiates a CPU and realizes the CPU. * * Returns: A #CPUState or %NULL if an error occurred. */ -CPUState *cpu_create (const char *typename); +CPUState *cpu_create_orphan (const char *typename);/** * parse_cpu_option:
linux-user/main.c +2 -2
@@ -237,7 +237,7 @@ void init_task_state(TaskState *ts)CPUArchState *cpu_copy (CPUArchState *env) {CPUState *cpu =env_cpu (env); -CPUState *new_cpu =cpu_create (cpu_type); +CPUState *new_cpu =cpu_create_orphan (cpu_type);CPUArchState *new_env =cpu_env (new_cpu);CPUBreakpoint *bp;
@@ -819,7 +819,7 @@ int main(int argc, char **argv, char **envp)set_preferred_target_page_bits (ctz32 (host_page_size));finalize_target_page_bits (); - cpu =cpu_create (cpu_type); + cpu =cpu_create_orphan (cpu_type); env =cpu_env (cpu);cpu_reset (cpu); thread_cpu = cpu;
scripts/coccinelle/qom-parent/cpu-create-orphan.cocci new file +13 -0
@@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// +// Rename cpu_create() to cpu_create_orphan() so that the short +// name can be reintroduced with a mandatory (parent, id, type) +// signature. +// +// spatch --sp-file scripts/coccinelle/qom-parent/cpu-create-orphan.cocci \ +// --in-place --include-headers --dir . + +@@ +@@ +- cpu_create ++ cpu_create_orphan
Signature · 1 line
2.47.1
RFC PATCH 10/134 hw/avr: Give onboard devices a QOM parent
In reply to Alexander GrafConvert the *_orphan() device-creation calls in hw/avr to the new parented API introduced earlier in this series, so every onboard device gets a stable path in the composition tree instead of landing in /machine/unattached with an unstable device[N] name.
The parent for each device is the object that owns its lifetime: the machine for board-created devices, the containing device for composite children. Names follow existing QOM conventions.
Per-site rationale (reviewers: dispute the modeling here):
file:line | parent | name | rationale atmega.c:287 | OBJECT(dev) | "io" | unimplemented I/O placeholder is a fixed child of the Atmega SoC; SoC realize() creates it, SoC owns it
--- hw/avr/atmega.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/avr/atmega.c +2 -2
@@ -284,10 +284,10 @@ static void atmega_realize(DeviceState *dev, Error **errp)* 0x20 - 0x5f: I/O memory * 0x60 - 0xff: Extended I/O */ - s->io =qdev_new_orphan (TYPE_UNIMPLEMENTED_DEVICE ); + s->io =qdev_new (OBJECT (dev),"io" ,TYPE_UNIMPLEMENTED_DEVICE );qdev_prop_set_string (s->io,"name" ,"I/O" );qdev_prop_set_uint64 (s->io,"size" , mc->io_size); -sysbus_realize_and_unref (SYS_BUS_DEVICE (s->io), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (s->io), &error_fatal);sysbus_mmio_map_overlap (SYS_BUS_DEVICE (s->io),0 ,OFFSET_DATA ,-1234 );/* Power Reduction */
Signature · 1 line
2.47.1
Re: [RFC PATCH 010/134] hw/avr: Give onboard devices a QOM parent
Quoted 14 lines · Alexander Graf
Convert the
*_orphan()device-creation calls in hw/avr to the new parented API introduced earlier in this series, so every onboard device gets a stable path in the composition tree instead of landing in /machine/unattached with an unstable device[N] name.The parent for each device is the object that owns its lifetime: the machine for board-created devices, the containing device for composite children. Names follow existing QOM conventions.
Per-site rationale (reviewers: dispute the modeling here):
file:line | parent | name | rationale atmega.c:287 | OBJECT(dev) | "io" | unimplemented I/O placeholder is a fixed child of the Atmega SoC; SoC realize() creates it, SoC owns it
Quoted 6 lines
Assisted-by KiroSigned-off-by Alexander Graf <[email protected]>--- hw/avr/atmega.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
RFC PATCH 11/134 hw/tricore: Give onboard devices a QOM parent
In reply to Alexander GrafConvert the *_orphan() device-creation calls in hw/tricore to the new parented API introduced earlier in this series, so every onboard device gets a stable path in the composition tree instead of landing in /machine/unattached with an unstable device[N] name.
The parent for each device is the object that owns its lifetime: the machine for board-created devices, the containing device for composite children. Names follow existing QOM conventions.
Per-site rationale (reviewers: dispute the modeling here):
file:line | parent | name | rationale tricore_testboard.c:70 | OBJECT(machine) | "cpu" | single CPU created by board init(); machine owns it tricore_testboard.c:92 | OBJECT(machine) | "testdevice" | onboard test device created by board init()
--- hw/tricore/tricore_testboard.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
hw/tricore/tricore_testboard.c +5 -2
@@ -55,6 +55,7 @@ static void tricore_load_kernel(CPUTriCoreState *env)static void tricore_testboard_init (MachineState *machine,int board_id) { +Object *mo =OBJECT (machine);TriCoreCPU *cpu;CPUTriCoreState *env;TriCoreTestDeviceState *test_dev;
@@ -67,7 +68,7 @@ static void tricore_testboard_init(MachineState *machine, int board_id)MemoryRegion *pcp_data =g_new (MemoryRegion,1 );MemoryRegion *pcp_text =g_new (MemoryRegion,1 ); - cpu =TRICORE_CPU (cpu_create_orphan (machine->cpu_type)); + cpu =TRICORE_CPU (cpu_create (mo,"cpu" , machine->cpu_type)); env = &cpu->env;memory_region_init_ram (ext_cram,NULL ,"powerlink_ext_c.ram" ,2 * MiB, &error_fatal);
@@ -89,7 +90,9 @@ static void tricore_testboard_init(MachineState *machine, int board_id)memory_region_add_subregion (sysmem,0xf0050000 , pcp_data);memory_region_add_subregion (sysmem,0xf0060000 , pcp_text); - test_dev =TRICORE_TESTDEVICE (qdev_new_orphan (TYPE_TRICORE_TESTDEVICE )); + test_dev =TRICORE_TESTDEVICE (qdev_new (mo,"testdevice" , +TYPE_TRICORE_TESTDEVICE )); +sysbus_realize (SYS_BUS_DEVICE (test_dev), &error_fatal);memory_region_add_subregion (sysmem,0xf0000000 , &test_dev->iomem);
Signature · 1 line
2.47.1
RFC PATCH 12/134 hw/xtensa: Give onboard devices a QOM parent
In reply to Alexander GrafConvert the *_orphan() device-creation calls in hw/xtensa to the new parented API introduced earlier in this series, so every onboard device gets a stable path in the composition tree instead of landing in /machine/unattached with an unstable device[N] name.
The parent for each device is the object that owns its lifetime: the machine for board-created devices, the containing device for composite children. Names follow existing QOM conventions.
Per-site rationale (reviewers: dispute the modeling here):
file:line | parent | name | rationale sim.c:66 | OBJECT(machine) | "cpu[*]" | SMP CPUs created by board init(); machine owns them virt.c:64 | OBJECT(ms) | "pcie" | GPEX PCIe host is a fixed onboard device of the virt machine; create_pcie() already receives MachineState xtfpga.c:176 | OBJECT(machine) | "flash" | onboard CFI flash; thread an Object *parent argument through the static xtfpga_flash_init() helper from board init() xtfpga.c:253 | OBJECT(machine) | "cpu[*]" | SMP CPUs created by board init()
--- hw/xtensa/sim.c | 2 +- hw/xtensa/virt.c | 4 ++-- hw/xtensa/xtfpga.c | 13 ++++++++----- 3 files changed, 11 insertions(+), 8 deletions(-)
hw/xtensa/sim.c +1 -1
@@ -63,7 +63,7 @@ XtensaCPU *xtensa_sim_common_init(MachineState *machine)int n;for (n =0 ; n < machine->smp.cpus; n++) { - cpu =XTENSA_CPU (cpu_create_orphan (machine->cpu_type)); + cpu =XTENSA_CPU (cpu_create (OBJECT (machine),"cpu[*]" , machine->cpu_type)); env = &cpu->env; env->sregs[PRID ] = n;
hw/xtensa/virt.c +2 -2
@@ -61,8 +61,8 @@ static void create_pcie(MachineState *ms, CPUXtensaState *env, int irq_base,qemu_irq *extints;int i; - dev =qdev_new_orphan (TYPE_GPEX_HOST ); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); + dev =qdev_new (OBJECT (ms),"pcie" ,TYPE_GPEX_HOST ); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);/* Map only the first size_ecam bytes of ECAM space. */ ecam_alias =g_new0 (MemoryRegion,1 );
hw/xtensa/xtfpga.c +8 -5
@@ -168,12 +168,13 @@ static void xtfpga_net_init(MemoryRegion *address_space,memory_region_add_subregion (address_space, buffers, ram); } -static PFlashCFI01 *xtfpga_flash_init (MemoryRegion *address_space, +static PFlashCFI01 *xtfpga_flash_init (Object *parent, +MemoryRegion *address_space,const XtfpgaBoardDesc *board,DriveInfo *dinfo,int be) {SysBusDevice *s; -DeviceState *dev =qdev_new_orphan (TYPE_PFLASH_CFI01 ); +DeviceState *dev =qdev_new (parent,"flash" ,TYPE_PFLASH_CFI01 );qdev_prop_set_drive (dev,"drive" ,blk_by_legacy_dinfo (dinfo)); qdev_prop_set_uint32(dev, "num-blocks",
@@ -183,7 +184,7 @@ static PFlashCFI01 *xtfpga_flash_init(MemoryRegion *address_space,qdev_prop_set_bit (dev,"big-endian" , be);qdev_prop_set_string (dev,"name" ,"xtfpga.io.flash" ); s =SYS_BUS_DEVICE (dev); -sysbus_realize_and_unref (s, &error_fatal); +sysbus_realize (s, &error_fatal);memory_region_add_subregion (address_space, board->flash->base,sysbus_mmio_get_region (s,0 ));return PFLASH_CFI01 (dev);
@@ -250,7 +251,8 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine)for (n =0 ; n < smp_cpus; n++) {CPUXtensaState *cenv =NULL ; - cpu =XTENSA_CPU (cpu_create_orphan (machine->cpu_type)); + cpu =XTENSA_CPU (cpu_create (OBJECT (machine),"cpu[*]" , + machine->cpu_type)); cenv = &cpu->env;if (!env) { env = cenv;
@@ -315,7 +317,8 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) dinfo =drive_get (IF_PFLASH ,0 ,0 );if (dinfo) { - flash =xtfpga_flash_init (system_io, board, dinfo,TARGET_BIG_ENDIAN ); + flash =xtfpga_flash_init (OBJECT (machine), system_io, board, dinfo, +TARGET_BIG_ENDIAN ); }/* Use presence of kernel file name as 'boot from SRAM' switch. */
Signature · 1 line
2.47.1
RFC PATCH 13/134 hw/alpha: Give onboard devices a QOM parent
In reply to Alexander GrafConvert the *_orphan() device-creation calls in hw/alpha to the new parented API introduced earlier in this series, so every onboard device gets a stable path in the composition tree instead of landing in /machine/unattached with an unstable device[N] name.
The parent for each device is the object that owns its lifetime: the machine for board-created devices, the containing device for composite children. Names follow existing QOM conventions.
Per-site rationale (reviewers: dispute the modeling here):
file:line | parent | name | rationale dp264.c:68 | OBJECT(machine) | "cpu[*]" | SMP CPUs created by board init() dp264.c:113 | OBJECT(machine) | "isa-bridge" | i82378 PCI-ISA bridge is a fixed onboard device; the machine owns it dp264.c:129 | OBJECT(machine) | "sio" | SMC37C669 Super-I/O is a fixed onboard device dp264.c:132 | OBJECT(machine) | "ide" | CMD646 IDE controller is a fixed onboard device typhoon.c:833 | OBJECT(machine) | "typhoon" | Typhoon PCI host bridge is a fixed chipset of the DP264 board; thread an Object *parent argument through typhoon_init() from clipper_init()
--- hw/alpha/alpha_sys.h | 3 ++- hw/alpha/dp264.c | 12 +++++++----- hw/alpha/typhoon.c | 6 +++--- 3 files changed, 12 insertions(+), 9 deletions(-)
hw/alpha/alpha_sys.h +2 -1
@@ -9,7 +9,8 @@#include "hw/intc/i8259.h" -PCIBus *typhoon_init (MemoryRegion *,qemu_irq *,qemu_irq *,AlphaCPU *[4 ], +PCIBus *typhoon_init (Object *parent,MemoryRegion *, +qemu_irq *,qemu_irq *,AlphaCPU *[4 ],pci_map_irq_fn ,uint8_t devfn_min);/* alpha_pci.c. */
hw/alpha/dp264.c +7 -5
@@ -49,6 +49,7 @@ static void clipper_init(MachineState *machine)const char *kernel_cmdline = machine->kernel_cmdline;const char *initrd_filename = machine->initrd_filename;MachineClass *mc =MACHINE_GET_CLASS (machine); +Object *mo =OBJECT (machine);AlphaCPU *cpus[4 ];PCIBus *pci_bus;PCIDevice *pci_dev;
@@ -65,7 +66,7 @@ static void clipper_init(MachineState *machine)/* Create up to 4 cpus. */ memset (cpus,0 ,sizeof (cpus));for (i =0 ; i < smp_cpus; ++i) { - cpus[i] =ALPHA_CPU (cpu_create_orphan (machine->cpu_type)); + cpus[i] =ALPHA_CPU (cpu_create (mo,"cpu[*]" , machine->cpu_type)); }/*
@@ -86,7 +87,7 @@ static void clipper_init(MachineState *machine)* Init the chipset. Because we're using CLIPPER IRQ mappings, * the minimum PCI device IdSel is 1. */ - pci_bus =typhoon_init (machine->ram, &isa_irq, &rtc_irq, cpus, + pci_bus =typhoon_init (mo, machine->ram, &isa_irq, &rtc_irq, cpus, clipper_pci_map_irq,PCI_DEVFN (1 ,0 ));/*
@@ -110,7 +111,8 @@ static void clipper_init(MachineState *machine)* Importantly, we need to provide a PCI device node for it, otherwise * some operating systems won't notice there's an ISA bus to configure. */ - i82378_dev =DEVICE (pci_create_simple_orphan (pci_bus,PCI_DEVFN (7 ,0 ),"i82378" )); + i82378_dev =DEVICE (pci_create_simple (mo,"isa-bridge" , pci_bus, +PCI_DEVFN (7 ,0 ),"i82378" )); isa_bus =ISA_BUS (qdev_get_child_bus (i82378_dev,"isa.0" ));/* Connect the ISA PIC to the Typhoon IRQ used for ISA interrupts. */
@@ -126,10 +128,10 @@ static void clipper_init(MachineState *machine)pci_init_nic_devices (pci_bus, mc->default_nic);/* Super I/O */ -isa_create_simple_orphan (isa_bus,TYPE_SMC37C669_SUPERIO ); +isa_create_simple (mo,"sio" , isa_bus,TYPE_SMC37C669_SUPERIO );/* IDE disk setup. */ - pci_dev =pci_create_simple_orphan (pci_bus,-1 ,"cmd646-ide" ); + pci_dev =pci_create_simple (mo,"ide" , pci_bus,-1 ,"cmd646-ide" );pci_ide_create_devs (pci_dev);/* Load PALcode. Given that this is not "real" cpu palcode,
hw/alpha/typhoon.c +3 -3
@@ -819,7 +819,7 @@ static void typhoon_alarm_timer(void *opaque)cpu_interrupt (CPU (s->cchip.cpu[cpu]),CPU_INTERRUPT_TIMER ); } -PCIBus *typhoon_init (MemoryRegion *ram,qemu_irq *p_isa_irq, +PCIBus *typhoon_init (Object *parent,MemoryRegion *ram,qemu_irq *p_isa_irq,qemu_irq *p_rtc_irq,AlphaCPU *cpus[4 ],pci_map_irq_fn sys_map_irq,uint8_t devfn_min) {
@@ -830,7 +830,7 @@ PCIBus *typhoon_init(MemoryRegion *ram, qemu_irq *p_isa_irq,PCIBus *b;int i; - dev =qdev_new_orphan (TYPE_TYPHOON_PCI_HOST_BRIDGE ); + dev =qdev_new (parent,"typhoon" ,TYPE_TYPHOON_PCI_HOST_BRIDGE ); s =TYPHOON_PCI_HOST_BRIDGE (dev); phb =PCI_HOST_BRIDGE (dev);
@@ -894,7 +894,7 @@ PCIBus *typhoon_init(MemoryRegion *ram, qemu_irq *p_isa_irq, &s->pchip.reg_mem, &s->pchip.reg_io, devfn_min, 64, TYPE_PCI_BUS); phb->bus = b; -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);/* Host memory as seen from the PCI side, via the IOMMU. */ memory_region_init_iommu(&s->pchip.iommu, sizeof(s->pchip.iommu),
Signature · 1 line
2.47.1
RFC PATCH 14/134 hw/nitro: Give onboard devices a QOM parent
In reply to Alexander GrafConvert the *_orphan() device-creation calls in hw/nitro to the new parented API introduced earlier in this series, so every onboard device gets a stable path in the composition tree instead of landing in /machine/unattached with an unstable device[N] name.
The parent for each device is the object that owns its lifetime: the machine for board-created devices, the containing device for composite children. Names follow existing QOM conventions.
Per-site rationale (reviewers: dispute the modeling here):
file:line | parent | name | rationale machine.c:200 | OBJECT(bridge) | "heartbeat" | onboard heartbeat is a fixed child of the vsock bridge it plugs into; bridge owns its lifetime machine.c:212 | OBJECT(bridge) | "serial" | debug-mode serial-over-vsock is a fixed child of the same bridge nitro-vsock-bus.c:51 | ORPHAN-JUSTIFIED| - | bridge is parented immediately after via qdev_set_id() to /machine/peripheral/nitro-vsock; keep the orphan creator here
--- hw/nitro/machine.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
hw/nitro/machine.c +5 -4
@@ -195,10 +195,11 @@ static void nitro_machine_init(MachineState *machine)if (defaults_enabled ()) {NitroVsockBridge *bridge =nitro_vsock_bridge_create (); +DeviceState *dev;/* Nitro Enclaves require a heartbeat device. Provide one. */ -qdev_realize (qdev_new_orphan (TYPE_NITRO_HEARTBEAT ), -BUS (&bridge->bus), &error_fatal); + dev =qdev_new (OBJECT (bridge),"heartbeat" ,TYPE_NITRO_HEARTBEAT ); +qdev_realize (dev,BUS (&bridge->bus), &error_fatal);/* * In debug mode, Nitro Enclaves expose the guest's serial output via
@@ -209,8 +210,8 @@ static void nitro_machine_init(MachineState *machine)Chardev *chr =serial_hd (0 );if (chr) { -DeviceState *dev =qdev_new_orphan (TYPE_NITRO_SERIAL_VSOCK ); - + dev =qdev_new (OBJECT (bridge),"serial" , +TYPE_NITRO_SERIAL_VSOCK );qdev_prop_set_chr (dev,"chardev" , chr);qdev_realize (dev,BUS (&bridge->bus), &error_fatal); }
Signature · 1 line
2.47.1
Re: [RFC PATCH 014/134] hw/nitro: Give onboard devices a QOM parent
Quoted 16 lines · Alexander Graf
Convert the
*_orphan()device-creation calls in hw/nitro to the new parented API introduced earlier in this series, so every onboard device gets a stable path in the composition tree instead of landing in /machine/unattached with an unstable device[N] name.The parent for each device is the object that owns its lifetime: the machine for board-created devices, the containing device for composite children. Names follow existing QOM conventions.
Per-site rationale (reviewers: dispute the modeling here):
file:line | parent | name | rationale machine.c:200 | OBJECT(bridge) | "heartbeat" | onboard heartbeat is a fixed child of the vsock bridge it plugs into; bridge owns its lifetime machine.c:212 | OBJECT(bridge) | "serial" | debug-mode serial-over-vsock is a fixed child of the same bridge nitro-vsock-bus.c:51 | ORPHAN-JUSTIFIED| - | bridge is parented immediately after via qdev_set_id() to /machine/peripheral/nitro-vsock; keep the orphan creator here
Quoted 6 lines
Assisted-by KiroSigned-off-by Alexander Graf <[email protected]>--- hw/nitro/machine.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
RFC PATCH 15/134 hw/vmapple: Give onboard devices a QOM parent
In reply to Alexander GrafConvert the *_orphan() device-creation calls in hw/vmapple to the new parented API introduced earlier in this series, so every onboard device gets a stable path in the composition tree instead of landing in /machine/unattached with an unstable device[N] name.
The parent for each device is the object that owns its lifetime: the machine for board-created devices, the containing device for composite children. Names follow existing QOM conventions.
Per-site rationale (reviewers: dispute the modeling here):
hw/vmapple/vmapple.c:158 | OBJECT(vms) | "bdif" | board-init helper receives VMAppleMachineState *vms; single instance hw/vmapple/vmapple.c:172 | OBJECT(vms) | "pvpanic" | board-init helper receives vms; single instance hw/vmapple/vmapple.c:187 | OBJECT(vms) | "cfg" | board-init helper receives vms; single instance hw/vmapple/vmapple.c:212 | OBJECT(vms) | "gfx" | board-init helper receives vms; single instance hw/vmapple/vmapple.c:225 | OBJECT(vms) | "aes" | board-init helper receives vms; single instance hw/vmapple/vmapple.c:246 | OBJECT(vms) | "gic" | board-init helper receives vms; single instance hw/vmapple/vmapple.c:293 | OBJECT(vms) | "uart" | board-init helper receives vms (const dropped); single instance hw/vmapple/vmapple.c:308 | OBJECT(vms) | "rtc" | board-init helper receives vms (const dropped); single instance hw/vmapple/vmapple.c:326 | OBJECT(vms) | "gpio" | board-init helper receives vms (const dropped); single instance hw/vmapple/vmapple.c:334 | OBJECT(vms) | "gpio-key" | board-init helper receives vms; single instance hw/vmapple/vmapple.c:387 | OBJECT(vms) | "pcie" | board-init helper receives vms; single GPEX host hw/vmapple/vmapple.c:423 | OBJECT(vms) | "xhci" | board-init helper receives vms; single XHCI controller hw/vmapple/vmapple.c:428 | OBJECT(usb_controller) | "usb-kbd" | lifetime owned by the XHCI controller it plugs into hw/vmapple/vmapple.c:429 | OBJECT(usb_controller) | "usb-tablet" | lifetime owned by the XHCI controller it plugs into
--- hw/vmapple/vmapple.c | 59 +++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 28 deletions(-)
hw/vmapple/vmapple.c +31 -28
@@ -155,25 +155,25 @@ static void create_bdif(VMAppleMachineState *vms, MemoryRegion *mem) }/* PV backdoor device */ - bdif =qdev_new_orphan (TYPE_VMAPPLE_BDIF ); + bdif =qdev_new (OBJECT (vms),"bdif" ,TYPE_VMAPPLE_BDIF ); bdif_sb =SYS_BUS_DEVICE (bdif);sysbus_mmio_map (bdif_sb,0 , vms->memmap[VMAPPLE_BDOOR ].base);qdev_prop_set_drive (DEVICE (bdif),"aux" ,blk_by_legacy_dinfo (di_aux));qdev_prop_set_drive (DEVICE (bdif),"root" ,blk_by_legacy_dinfo (di_root)); -sysbus_realize_and_unref (bdif_sb, &error_fatal); +sysbus_realize (bdif_sb, &error_fatal); }static void create_pvpanic (VMAppleMachineState *vms,MemoryRegion *mem) {SysBusDevice *pvpanic; - vms->pvpanic =qdev_new_orphan (TYPE_PVPANIC_MMIO_DEVICE ); + vms->pvpanic =qdev_new (OBJECT (vms),"pvpanic" ,TYPE_PVPANIC_MMIO_DEVICE ); pvpanic =SYS_BUS_DEVICE (vms->pvpanic);sysbus_mmio_map (pvpanic,0 , vms->memmap[VMAPPLE_PVPANIC ].base); -sysbus_realize_and_unref (pvpanic, &error_fatal); +sysbus_realize (pvpanic, &error_fatal); } static bool create_cfg(VMAppleMachineState *vms, MemoryRegion *mem,
@@ -184,7 +184,7 @@ static bool create_cfg(VMAppleMachineState *vms, MemoryRegion *mem,MachineState *machine =MACHINE (vms);uint32_t rnd =1 ; - vms->cfg =qdev_new_orphan (TYPE_VMAPPLE_CFG ); + vms->cfg =qdev_new (OBJECT (vms),"cfg" ,TYPE_VMAPPLE_CFG ); cfg =SYS_BUS_DEVICE (vms->cfg);sysbus_mmio_map (cfg,0 , vms->memmap[VMAPPLE_CONFIG ].base);
@@ -195,7 +195,7 @@ static bool create_cfg(VMAppleMachineState *vms, MemoryRegion *mem,qdev_prop_set_uint64 (vms->cfg,"ram-size" , machine->ram_size);qdev_prop_set_uint32 (vms->cfg,"rnd" , rnd); -if (!sysbus_realize_and_unref (cfg, errp)) { +if (!sysbus_realize (cfg, errp)) {error_prepend (errp,"Error creating vmapple cfg device: " );return false; }
@@ -209,12 +209,12 @@ static void create_gfx(VMAppleMachineState *vms, MemoryRegion *mem)int irq_iosfc = vms->irqmap[VMAPPLE_APV_IOSFC ];SysBusDevice *gfx; - gfx =SYS_BUS_DEVICE (qdev_new_orphan ("apple-gfx-mmio" )); + gfx =SYS_BUS_DEVICE (qdev_new (OBJECT (vms),"gfx" ,"apple-gfx-mmio" ));sysbus_mmio_map (gfx,0 , vms->memmap[VMAPPLE_APV_GFX ].base);sysbus_mmio_map (gfx,1 , vms->memmap[VMAPPLE_APV_IOSFC ].base);sysbus_connect_irq (gfx,0 ,qdev_get_gpio_in (vms->gic, irq_gfx));sysbus_connect_irq (gfx,1 ,qdev_get_gpio_in (vms->gic, irq_iosfc)); -sysbus_realize_and_unref (gfx, &error_fatal); +sysbus_realize (gfx, &error_fatal); }static void create_aes (VMAppleMachineState *vms,MemoryRegion *mem)
@@ -222,11 +222,11 @@ static void create_aes(VMAppleMachineState *vms, MemoryRegion *mem)int irq = vms->irqmap[VMAPPLE_AES_1 ];SysBusDevice *aes; - aes =SYS_BUS_DEVICE (qdev_new_orphan (TYPE_APPLE_AES )); + aes =SYS_BUS_DEVICE (qdev_new (OBJECT (vms),"aes" ,TYPE_APPLE_AES ));sysbus_mmio_map (aes,0 , vms->memmap[VMAPPLE_AES_1 ].base);sysbus_mmio_map (aes,1 , vms->memmap[VMAPPLE_AES_2 ].base);sysbus_connect_irq (aes,0 ,qdev_get_gpio_in (vms->gic, irq)); -sysbus_realize_and_unref (aes, &error_fatal); +sysbus_realize (aes, &error_fatal); }static int arm_gic_ppi_index (int cpu_nr,int ppi_index)
@@ -243,7 +243,7 @@ static void create_gic(VMAppleMachineState *vms, MemoryRegion *mem)int i;unsigned int smp_cpus = ms->smp.cpus; - vms->gic =qdev_new_orphan (gicv3_class_name ()); + vms->gic =qdev_new (OBJECT (vms),"gic" ,gicv3_class_name ());qdev_prop_set_uint32 (vms->gic,"revision" ,3 );qdev_prop_set_uint32 (vms->gic,"num-cpu" , smp_cpus);/*
@@ -261,7 +261,7 @@ static void create_gic(VMAppleMachineState *vms, MemoryRegion *mem)qdev_prop_set_array (vms->gic,"redist-region-count" , redist_region_count); gicbusdev =SYS_BUS_DEVICE (vms->gic); -sysbus_realize_and_unref (gicbusdev, &error_fatal); +sysbus_realize (gicbusdev, &error_fatal);sysbus_mmio_map (gicbusdev,0 , vms->memmap[VMAPPLE_GIC_DIST ].base);sysbus_mmio_map (gicbusdev,1 , vms->memmap[VMAPPLE_GIC_REDIST ].base);
@@ -285,27 +285,28 @@ static void create_gic(VMAppleMachineState *vms, MemoryRegion *mem) } } -static void create_uart (const VMAppleMachineState *vms,int uart, +static void create_uart (VMAppleMachineState *vms,int uart,MemoryRegion *mem,Chardev *chr) {hwaddr base = vms->memmap[uart].base;int irq = vms->irqmap[uart]; -DeviceState *dev =qdev_new_orphan (TYPE_PL011 ); +DeviceState *dev =qdev_new (OBJECT (vms),"uart" ,TYPE_PL011 );SysBusDevice *s =SYS_BUS_DEVICE (dev);qdev_prop_set_chr (dev,"chardev" , chr); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);memory_region_add_subregion (mem, base,sysbus_mmio_get_region (s,0 ));sysbus_connect_irq (s,0 ,qdev_get_gpio_in (vms->gic, irq)); } -static void create_rtc (const VMAppleMachineState *vms) +static void create_rtc (VMAppleMachineState *vms) {hwaddr base = vms->memmap[VMAPPLE_RTC ].base;int irq = vms->irqmap[VMAPPLE_RTC ]; -sysbus_create_simple_orphan ("pl031" , base,qdev_get_gpio_in (vms->gic, irq)); +sysbus_create_simple (OBJECT (vms),"rtc" ,"pl031" , base, +qdev_get_gpio_in (vms->gic, irq)); }static DeviceState *gpio_key_dev;
@@ -315,7 +316,7 @@ static void vmapple_powerdown_req(Notifier *n, void *opaque)qemu_set_irq (qdev_get_gpio_in (gpio_key_dev,0 ),1 ); } -static void create_gpio_devices (const VMAppleMachineState *vms,int gpio, +static void create_gpio_devices (VMAppleMachineState *vms,int gpio,MemoryRegion *mem) {DeviceState *pl061_dev;
@@ -323,16 +324,16 @@ static void create_gpio_devices(const VMAppleMachineState *vms, int gpio,int irq = vms->irqmap[gpio];SysBusDevice *s; - pl061_dev =qdev_new_orphan ("pl061" ); + pl061_dev =qdev_new (OBJECT (vms),"gpio" ,"pl061" );/* Pull lines down to 0 if not driven by the PL061 */ qdev_prop_set_uint8 (pl061_dev,"pullups" ,0 );qdev_prop_set_uint8 (pl061_dev,"pulldowns" ,0xff ); s =SYS_BUS_DEVICE (pl061_dev); -sysbus_realize_and_unref (s, &error_fatal); +sysbus_realize (s, &error_fatal);memory_region_add_subregion (mem, base,sysbus_mmio_get_region (s,0 ));sysbus_connect_irq (s,0 ,qdev_get_gpio_in (vms->gic, irq)); - gpio_key_dev =sysbus_create_simple_orphan ("gpio-key" ,-1 , -qdev_get_gpio_in (pl061_dev,3 )); + gpio_key_dev =sysbus_create_simple (OBJECT (vms),"gpio-key" ,"gpio-key" , +-1 ,qdev_get_gpio_in (pl061_dev,3 )); } static void vmapple_firmware_init(VMAppleMachineState *vms,
@@ -384,9 +385,9 @@ static void create_pcie(VMAppleMachineState *vms)DeviceState *usb_controller;USBBus *usb_bus; - dev =qdev_new_orphan (TYPE_GPEX_HOST ); + dev =qdev_new (OBJECT (vms),"pcie" ,TYPE_GPEX_HOST );qdev_prop_set_uint32 (dev,"num-irqs" ,GPEX_NUM_IRQS ); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);/* Map only the first size_ecam bytes of ECAM space */ ecam_reg =sysbus_mmio_get_region (SYS_BUS_DEVICE (dev),0 );
@@ -420,13 +421,15 @@ static void create_pcie(VMAppleMachineState *vms) }if (defaults_enabled ()) { - usb_controller =qdev_new_orphan (TYPE_QEMU_XHCI ); -qdev_realize_and_unref (usb_controller,BUS (pci->bus), &error_fatal); + usb_controller =qdev_new (OBJECT (vms),"xhci" ,TYPE_QEMU_XHCI ); +qdev_realize (usb_controller,BUS (pci->bus), &error_fatal); usb_bus =USB_BUS (object_resolve_type_unambiguous (TYPE_USB_BUS , &error_fatal)); -usb_create_simple_orphan (usb_bus,"usb-kbd" ); -usb_create_simple_orphan (usb_bus,"usb-tablet" ); +usb_create_simple (OBJECT (usb_controller),"usb-kbd" , usb_bus, +"usb-kbd" ); +usb_create_simple (OBJECT (usb_controller),"usb-tablet" , usb_bus, +"usb-tablet" ); } }
Signature · 1 line
2.47.1
RFC PATCH 16/134 hw/hppa: Give onboard devices a QOM parent
In reply to Alexander GrafConvert the *_orphan() device-creation calls in hw/hppa to the new parented API introduced earlier in this series, so every onboard device gets a stable path in the composition tree instead of landing in /machine/unattached with an unstable device[N] name.
The parent for each device is the object that owns its lifetime: the machine for board-created devices, the containing device for composite children. Names follow existing QOM conventions.
Per-site rationale (reviewers: dispute the modeling here):
hw/hppa/machine.c:268 | OBJECT(machine) | "lasi" | lasi_init() static helper called from board init; thread Object *parent from caller hw/hppa/machine.c:278 | OBJECT(machine) | "dino" | dino_init() static helper called from board init; thread Object *parent from caller hw/hppa/machine.c:301 | OBJECT(machine) | "cpu[*]" | board init CPU creation loop; auto-index child of machine hw/hppa/machine.c:414 | OBJECT(machine) | "artist" | board init tail; on-board Artist graphics owned by machine hw/hppa/machine.c:431 | OBJECT(machine) | "diva-gsp" | board init tail; on-board Diva GSP PCI card owned by machine hw/hppa/machine.c:446 | OBJECT(machine) | "ohci" | board init tail; on-board OHCI USB controller owned by machine hw/hppa/machine.c:449 | OBJECT(pci_dev) | "usb-kbd" | USB keyboard is child of the OHCI controller it plugs into hw/hppa/machine.c:450 | OBJECT(pci_dev) | "usb-mouse" | USB mouse is child of the OHCI controller it plugs into hw/hppa/machine.c:617 | OBJECT(machine) | "lasips2" | HP 715 board init; on-board Lasi PS/2 controller hw/hppa/machine.c:709 | OBJECT(machine) | "lasips2" | HP B160L board init; on-board Lasi PS/2 controller hw/hppa/machine.c:724 | OBJECT(machine) | "scsi" | HP B160L board init; on-board LSI SCSI HBA hw/hppa/machine.c:736 | OBJECT(machine) | "astro" | astro_init() static helper called from board init; thread Object *parent from caller hw/hppa/machine.c:776 | OBJECT(machine) | "scsi" | HP C3700 board init; on-board LSI SCSI HBA
--- hw/hppa/machine.c | 60 ++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 27 deletions(-)
hw/hppa/machine.c +33 -27
@@ -261,24 +261,24 @@ static FWCfgState *create_fw_cfg(MachineState *ms, PCIBus *pci_bus,return fw_cfg; } -static LasiState *lasi_init (void ) +static LasiState *lasi_init (Object *parent) {DeviceState *dev; - dev =qdev_new_orphan (TYPE_LASI_CHIP ); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); + dev =qdev_new (parent,"lasi" ,TYPE_LASI_CHIP ); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);return LASI_CHIP (dev); } -static DinoState *dino_init (MemoryRegion *addr_space) +static DinoState *dino_init (Object *parent,MemoryRegion *addr_space) {DeviceState *dev; - dev =qdev_new_orphan (TYPE_DINO_PCI_HOST_BRIDGE ); + dev =qdev_new (parent,"dino" ,TYPE_DINO_PCI_HOST_BRIDGE );object_property_set_link (OBJECT (dev),"memory-as" ,OBJECT (addr_space), &error_fatal); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);return DINO_PCI_HOST_BRIDGE (dev); }
@@ -298,7 +298,8 @@ static TranslateFn *machine_HP_common_init_cpus(MachineState *machine)/* Create CPUs. */ for (unsigned int i =0 ; i < smp_cpus; i++) { - cpu[i] =HPPA_CPU (cpu_create_orphan (machine->cpu_type)); + cpu[i] =HPPA_CPU (cpu_create (OBJECT (machine),"cpu[*]" , + machine->cpu_type)); }/* Initialize memory */
@@ -411,11 +412,11 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus, lasi_dev = hpm->lasi_dev;if (lasi_dev && machine->enable_graphics && vga_interface_type !=VGA_NONE ) { - dev =qdev_new_orphan ("artist" ); + dev =qdev_new (OBJECT (machine),"artist" ,"artist" ); s =SYS_BUS_DEVICE (dev);bool disabled =object_property_get_bool (OBJECT (dev),"disable" ,NULL );if (!disabled) { -sysbus_realize_and_unref (s, &error_fatal); +sysbus_realize (s, &error_fatal); vga_interface_created = true;sysbus_mmio_map (s,0 ,translate (NULL ,LASI_GFX_HPA ));sysbus_mmio_map (s,1 ,translate (NULL ,ARTIST_FB_ADDR ));
@@ -428,7 +429,8 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,if (pci_bus &&hppa_is_pa20 (&cpu[0 ]->env)) {/* BMC board: HP Diva GSP PCI card */ - pci_dev =pci_new_multifunction_orphan (PCI_DEVFN (2 ,0 ),"diva-gsp" ); + pci_dev =pci_new_multifunction (OBJECT (machine),"diva-gsp" , +PCI_DEVFN (2 ,0 ),"diva-gsp" );if (!lasi_dev) {/* bind default keyboard/serial to Diva card */ qdev_prop_set_chr (DEVICE (pci_dev),"chardev1" ,serial_hd (0 ));
@@ -436,18 +438,19 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,qdev_prop_set_chr (DEVICE (pci_dev),"chardev3" ,serial_hd (2 ));qdev_prop_set_chr (DEVICE (pci_dev),"chardev4" ,serial_hd (3 )); } -pci_realize_and_unref (pci_dev, pci_bus, &error_fatal); +qdev_realize (DEVICE (pci_dev),BUS (pci_bus), &error_fatal); }/* create USB OHCI controller for USB keyboard & mouse on Astro machines */ if (!lasi_dev && machine->enable_graphics &&defaults_enabled ()) {USBBus *usb_bus; -pci_create_simple_orphan (pci_bus,-1 ,"pci-ohci" ); + pci_dev =pci_create_simple (OBJECT (machine),"ohci" , pci_bus,-1 , +"pci-ohci" ); usb_bus =USB_BUS (object_resolve_type_unambiguous (TYPE_USB_BUS , &error_abort)); -usb_create_simple_orphan (usb_bus,"usb-kbd" ); -usb_create_simple_orphan (usb_bus,"usb-mouse" ); +usb_create_simple (OBJECT (pci_dev),"usb-kbd" , usb_bus,"usb-kbd" ); +usb_create_simple (OBJECT (pci_dev),"usb-mouse" , usb_bus,"usb-mouse" ); }/* register power switch emulation */
@@ -597,7 +600,7 @@ static void machine_HP_715_init(MachineState *machine)assert (isa_bus);/* Init Lasi chip */ - lasi_dev =DEVICE (lasi_init ()); + lasi_dev =DEVICE (lasi_init (OBJECT (machine))); hpm->lasi_dev = lasi_dev; memory_region_add_subregion(addr_space, translate(NULL, LASI_HPA_715), sysbus_mmio_get_region(
@@ -614,8 +617,8 @@ static void machine_HP_715_init(MachineState *machine) parallel_hds[0]);/* PS/2 Keyboard/Mouse */ - dev =qdev_new_orphan (TYPE_LASIPS2 ); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); + dev =qdev_new (OBJECT (machine),"lasips2" ,TYPE_LASIPS2 ); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 ,qdev_get_gpio_in (lasi_dev,LASI_IRQ_PS2KBD_HPA )); memory_region_add_subregion(addr_space,
@@ -672,14 +675,14 @@ static void machine_HP_B160L_init(MachineState *machine) }/* Init Lasi chip */ - lasi_dev =DEVICE (lasi_init ()); + lasi_dev =DEVICE (lasi_init (OBJECT (machine))); hpm->lasi_dev = lasi_dev;memory_region_add_subregion (addr_space,translate (NULL ,LASI_HPA ),sysbus_mmio_get_region (SYS_BUS_DEVICE (lasi_dev),0 ));/* Init Dino (PCI host bus chip). */ - dino_dev =DEVICE (dino_init (addr_space)); + dino_dev =DEVICE (dino_init (OBJECT (machine), addr_space));memory_region_add_subregion (addr_space,translate (NULL ,DINO_HPA ),sysbus_mmio_get_region (SYS_BUS_DEVICE (dino_dev),0 ));
@@ -706,8 +709,8 @@ static void machine_HP_B160L_init(MachineState *machine) parallel_hds[0]);/* PS/2 Keyboard/Mouse */ - dev =qdev_new_orphan (TYPE_LASIPS2 ); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); + dev =qdev_new (OBJECT (machine),"lasips2" ,TYPE_LASIPS2 ); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 ,qdev_get_gpio_in (lasi_dev,LASI_IRQ_PS2KBD_HPA )); memory_region_add_subregion(addr_space,
@@ -721,7 +724,8 @@ static void machine_HP_B160L_init(MachineState *machine)/* SCSI disk setup. */ if (drive_get_max_bus (IF_SCSI ) >=0 ) { - dev =DEVICE (pci_create_simple_orphan (pci_bus,-1 ,"lsi53c895a" )); + dev =DEVICE (pci_create_simple (OBJECT (machine),"scsi" , pci_bus,-1 , +"lsi53c895a" ));lsi53c8xx_handle_legacy_cmdline (dev); }
@@ -729,15 +733,15 @@ static void machine_HP_B160L_init(MachineState *machine)machine_HP_common_init_tail (machine, pci_bus, translate); } -static AstroState *astro_init (void ) +static AstroState *astro_init (Object *parent) {DeviceState *dev; - dev =qdev_new_orphan (TYPE_ASTRO_CHIP ); + dev =qdev_new (parent,"astro" ,TYPE_ASTRO_CHIP );object_property_set_int (OBJECT (dev),"phys-addr-bits" ,hppa_phys_addr_bits (&cpu[0 ]->env), &error_abort); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);return ASTRO_CHIP (dev); }
@@ -763,7 +767,7 @@ static void machine_HP_C3700_init(MachineState *machine) }/* Init Astro and the Elroys (PCI host bus chips). */ - astro =astro_init (); + astro =astro_init (OBJECT (machine)); astro_dev =DEVICE (astro); memory_region_add_subregion(addr_space, translate(NULL, ASTRO_HPA), sysbus_mmio_get_region(
@@ -773,7 +777,9 @@ static void machine_HP_C3700_init(MachineState *machine)/* SCSI disk setup. */ if (drive_get_max_bus (IF_SCSI ) >=0 ) { -DeviceState *dev =DEVICE (pci_create_simple_orphan (pci_bus,-1 ,"lsi53c895a" )); +DeviceState *dev =DEVICE (pci_create_simple (OBJECT (machine),"scsi" , + pci_bus,-1 , +"lsi53c895a" ));lsi53c8xx_handle_legacy_cmdline (dev); }
Signature · 1 line
2.47.1
RFC PATCH 17/134 hw/microblaze: Give onboard devices a QOM parent
In reply to Alexander GrafConvert the *_orphan() device-creation calls in hw/microblaze to the new parented API introduced earlier in this series, so every onboard device gets a stable path in the composition tree instead of landing in /machine/unattached with an unstable device[N] name.
The parent for each device is the object that owns its lifetime: the machine for board-created devices, the containing device for composite children. Names follow existing QOM conventions.
Per-site rationale (reviewers: dispute the modeling here):
hw/microblaze/petalogix_ml605_mmu.c:113 | OBJECT(machine) | "intc" | board init(); single XPS interrupt controller owned by machine hw/microblaze/petalogix_ml605_mmu.c:129 | OBJECT(machine) | "timer" | board init(); single XPS timer block owned by machine hw/microblaze/petalogix_ml605_mmu.c:138 | OBJECT(machine) | "xilinx-eth" | board init(); keep existing child name; drop now-redundant object_property_add_child() hw/microblaze/petalogix_ml605_mmu.c:139 | OBJECT(machine) | "xilinx-dma" | board init(); keep existing child name; drop now-redundant object_property_add_child() hw/microblaze/petalogix_ml605_mmu.c:177 | OBJECT(machine) | "spi" | board init(); single XPS SPI controller owned by machine hw/microblaze/petalogix_ml605_mmu.c:191 | OBJECT(machine) | "spi-flash[*]" | board init(); NUM_SPI_FLASHES instances in loop, auto-index; plugged onto SPI bus but lifetime-owned by machine hw/microblaze/petalogix_s3adsp1800_mmu.c:110 | OBJECT(machine) | "intc" | board init(); single XPS interrupt controller owned by machine hw/microblaze/petalogix_s3adsp1800_mmu.c:122 | OBJECT(machine) | "uart" | board init(); single Xilinx uartlite owned by machine hw/microblaze/petalogix_s3adsp1800_mmu.c:130 | OBJECT(machine) | "timer" | board init(); single XPS timer block owned by machine hw/microblaze/petalogix_s3adsp1800_mmu.c:138 | OBJECT(machine) | "eth" | board init(); single XPS ethernetlite owned by machine
--- hw/microblaze/petalogix_ml605_mmu.c | 28 ++++++++++-------------- hw/microblaze/petalogix_s3adsp1800_mmu.c | 16 +++++++------- 2 files changed, 20 insertions(+), 24 deletions(-)
hw/microblaze/petalogix_ml605_mmu.c +12 -16
@@ -110,10 +110,10 @@ petalogix_ml605_init(MachineState *machine) 64 * KiB, 2, 0x89, 0x18, 0x0000, 0x0, 0); - dev =qdev_new_orphan ("xlnx.xps-intc" ); + dev =qdev_new (OBJECT (machine),"intc" ,"xlnx.xps-intc" );qdev_prop_set_enum (dev,"endianness" ,ENDIAN_MODE_LITTLE );qdev_prop_set_uint32 (dev,"kind-of-intr" ,1 <<TIMER_IRQ ); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,INTC_BASEADDR );sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 ,qdev_get_gpio_in (DEVICE (cpu),MB_CPU_IRQ ));
@@ -126,21 +126,17 @@ petalogix_ml605_init(MachineState *machine) DEVICE_LITTLE_ENDIAN);/* 2 timers at irq 2 @ 100 Mhz. */ - dev =qdev_new_orphan ("xlnx.xps-timer" ); + dev =qdev_new (OBJECT (machine),"timer" ,"xlnx.xps-timer" );qdev_prop_set_enum (dev,"endianness" ,ENDIAN_MODE_LITTLE );qdev_prop_set_uint32 (dev,"one-timer-only" ,0 );qdev_prop_set_uint32 (dev,"clock-frequency" ,100 *1000000 ); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,TIMER_BASEADDR );sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , irq[TIMER_IRQ ]);/* axi ethernet and dma initialization. */ - eth0 =qdev_new_orphan ("xlnx.axi-ethernet" ); - dma =qdev_new_orphan ("xlnx.axi-dma" ); - -/* FIXME: attach to the sysbus instead */ -object_property_add_child (qdev_get_machine (),"xilinx-eth" ,OBJECT (eth0)); -object_property_add_child (qdev_get_machine (),"xilinx-dma" ,OBJECT (dma)); + eth0 =qdev_new (OBJECT (machine),"xilinx-eth" ,"xlnx.axi-ethernet" ); + dma =qdev_new (OBJECT (machine),"xilinx-dma" ,"xlnx.axi-dma" ); ds =object_property_get_link (OBJECT (dma),"axistream-connected-target" ,NULL );
@@ -153,7 +149,7 @@ petalogix_ml605_init(MachineState *machine) &error_abort);object_property_set_link (OBJECT (eth0),"axistream-control-connected" , cs, &error_abort); -sysbus_realize_and_unref (SYS_BUS_DEVICE (eth0), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (eth0), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (eth0),0 ,AXIENET_BASEADDR );sysbus_connect_irq (SYS_BUS_DEVICE (eth0),0 , irq[AXIENET_IRQ ]);
@@ -166,7 +162,7 @@ petalogix_ml605_init(MachineState *machine) &error_abort);object_property_set_link (OBJECT (dma),"axistream-control-connected" , cs, &error_abort); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dma), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (dma), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dma),0 ,AXIDMA_BASEADDR );sysbus_connect_irq (SYS_BUS_DEVICE (dma),0 , irq[AXIDMA_IRQ0 ]);sysbus_connect_irq (SYS_BUS_DEVICE (dma),1 , irq[AXIDMA_IRQ1 ]);
@@ -174,11 +170,11 @@ petalogix_ml605_init(MachineState *machine) {SSIBus *spi; - dev =qdev_new_orphan ("xlnx.xps-spi" ); + dev =qdev_new (OBJECT (machine),"spi" ,"xlnx.xps-spi" );qdev_prop_set_enum (dev,"endianness" ,ENDIAN_MODE_LITTLE );qdev_prop_set_uint8 (dev,"num-ss-bits" ,NUM_SPI_FLASHES ); busdev =SYS_BUS_DEVICE (dev); -sysbus_realize_and_unref (busdev, &error_fatal); +sysbus_realize (busdev, &error_fatal);sysbus_mmio_map (busdev,0 ,SPI_BASEADDR );sysbus_connect_irq (busdev,0 , irq[SPI_IRQ ]);
@@ -188,14 +184,14 @@ petalogix_ml605_init(MachineState *machine) dinfo =drive_get (IF_MTD ,0 , i);qemu_irq cs_line; - dev =qdev_new_orphan ("n25q128" ); + dev =qdev_new (OBJECT (machine),"spi-flash[*]" ,"n25q128" );if (dinfo) {qdev_prop_set_drive_err (dev,"drive" ,blk_by_legacy_dinfo (dinfo), &error_fatal); }qdev_prop_set_uint8 (dev,"cs" , i); -qdev_realize_and_unref (dev,BUS (spi), &error_fatal); +qdev_realize (dev,BUS (spi), &error_fatal); cs_line =qdev_get_gpio_in_named (dev,SSI_GPIO_CS ,0 );sysbus_connect_irq (busdev, i+1 , cs_line);
hw/microblaze/petalogix_s3adsp1800_mmu.c +8 -8
@@ -107,11 +107,11 @@ petalogix_s3adsp1800_init(MachineState *machine) dinfo ?blk_by_legacy_dinfo (dinfo) :NULL , 64 * KiB, 1, 0x89, 0x18, 0x0000, 0x0, 1); - dev =qdev_new_orphan ("xlnx.xps-intc" ); + dev =qdev_new (OBJECT (machine),"intc" ,"xlnx.xps-intc" );qdev_prop_set_enum (dev,"endianness" , endianness);qdev_prop_set_uint32 (dev,"kind-of-intr" ,1 <<ETHLITE_IRQ |1 <<UARTLITE_IRQ ); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,INTC_BASEADDR );sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 ,qdev_get_gpio_in (DEVICE (cpu),MB_CPU_IRQ ));
@@ -119,28 +119,28 @@ petalogix_s3adsp1800_init(MachineState *machine) irq[i] =qdev_get_gpio_in (dev, i); } - dev =qdev_new_orphan (TYPE_XILINX_UARTLITE ); + dev =qdev_new (OBJECT (machine),"uart" ,TYPE_XILINX_UARTLITE );qdev_prop_set_enum (dev,"endianness" , endianness);qdev_prop_set_chr (dev,"chardev" ,serial_hd (0 )); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,UARTLITE_BASEADDR );sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , irq[UARTLITE_IRQ ]);/* 2 timers at irq 2 @ 62 Mhz. */ - dev =qdev_new_orphan ("xlnx.xps-timer" ); + dev =qdev_new (OBJECT (machine),"timer" ,"xlnx.xps-timer" );qdev_prop_set_enum (dev,"endianness" , endianness);qdev_prop_set_uint32 (dev,"one-timer-only" ,0 );qdev_prop_set_uint32 (dev,"clock-frequency" ,62 *1000000 ); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,TIMER_BASEADDR );sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , irq[TIMER_IRQ ]); - dev =qdev_new_orphan ("xlnx.xps-ethernetlite" ); + dev =qdev_new (OBJECT (machine),"eth" ,"xlnx.xps-ethernetlite" );qdev_prop_set_enum (dev,"endianness" , endianness);qemu_configure_nic_device (dev, true,NULL );qdev_prop_set_uint32 (dev,"tx-ping-pong" ,0 );qdev_prop_set_uint32 (dev,"rx-ping-pong" ,0 ); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,ETHLITE_BASEADDR );sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , irq[ETHLITE_IRQ ]);
Signature · 1 line
2.47.1
RFC PATCH 18/134 hw/sh4: Give onboard devices a QOM parent
In reply to Alexander GrafConvert the *_orphan() device-creation calls in hw/sh4 to the new parented API introduced earlier in this series, so every onboard device gets a stable path in the composition tree instead of landing in /machine/unattached with an unstable device[N] name.
The parent for each device is the object that owns its lifetime: the machine for board-created devices, the containing device for composite children. Names follow existing QOM conventions.
Per-site rationale (reviewers: dispute the modeling here):
hw/sh4/r2d.c:254 | cpu_create | OBJECT(machine) | "cpu" | board init: single CPU owned by machine hw/sh4/r2d.c:269 | qdev_new | OBJECT(machine) | "pci-host" | board init: SH PCI host bridge owned by machine hw/sh4/r2d.c:280 | qdev_new | OBJECT(machine) | "sm501" | board init: on-board SM501 companion chip owned by machine hw/sh4/r2d.c:292 | qdev_new | OBJECT(machine) | "ide" | board init: on-board CF/IDE controller owned by machine hw/sh4/r2d.c:323 | usb_create_simple | OBJECT(BUS(usb_bus)->parent) | "usb-kbd" | keyboard hangs off the SM501 OHCI controller that owns the USB bus hw/sh4/sh7750.c:765 | qdev_new | parent | "sci" | SoC helper: threaded Object *parent from board; on-chip SCI UART hw/sh4/sh7750.c:782 | qdev_new | parent | "scif" | SoC helper: threaded Object *parent from board; on-chip SCIF UART
--- hw/sh4/r2d.c | 20 +++++++++++--------- hw/sh4/sh7750.c | 11 ++++++----- include/hw/sh4/sh.h | 3 ++- 3 files changed, 19 insertions(+), 15 deletions(-)
hw/sh4/r2d.c +11 -9
@@ -251,7 +251,8 @@ static void r2d_init(MachineState *machine)USBBus *usb_bus;r2d_fpga_t *fpga; - cpu =SUPERH_CPU (cpu_create_orphan (machine->cpu_type)); + cpu =SUPERH_CPU (cpu_create (OBJECT (machine),"cpu" , + machine->cpu_type)); env = &cpu->env; reset_info =g_new0 (ResetData,1 );
@@ -263,12 +264,12 @@ static void r2d_init(MachineState *machine)memory_region_init_ram (sdram,NULL ,"r2d.sdram" ,SDRAM_SIZE , &error_fatal);memory_region_add_subregion (address_space_mem,SDRAM_BASE , sdram);/* Register peripherals */ - s =sh7750_init (cpu, address_space_mem); + s =sh7750_init (OBJECT (machine), cpu, address_space_mem); fpga =r2d_fpga_init (address_space_mem,0x04000000 ,sh7750_irl (s)); - dev =qdev_new_orphan ("sh_pci" ); + dev =qdev_new (OBJECT (machine),"pci-host" ,"sh_pci" ); busdev =SYS_BUS_DEVICE (dev); -sysbus_realize_and_unref (busdev, &error_fatal); +sysbus_realize (busdev, &error_fatal); pci_bus =PCI_BUS (qdev_get_child_bus (dev,"pci" ));sysbus_mmio_map (busdev,0 ,P4ADDR (0x1e200000 ));sysbus_mmio_map (busdev,1 ,A7ADDR (0x1e200000 ));
@@ -277,23 +278,23 @@ static void r2d_init(MachineState *machine)sysbus_connect_irq (busdev,2 , &fpga->irq[PCI_INTC ]);sysbus_connect_irq (busdev,3 , &fpga->irq[PCI_INTD ]); - dev =qdev_new_orphan ("sysbus-sm501" ); + dev =qdev_new (OBJECT (machine),"sm501" ,"sysbus-sm501" ); busdev =SYS_BUS_DEVICE (dev);qdev_prop_set_uint32 (dev,"vram-size" ,SM501_VRAM_SIZE );qdev_prop_set_uint64 (dev,"dma-offset" ,0x10000000 );qdev_prop_set_chr (dev,"chardev" ,serial_hd (2 )); -sysbus_realize_and_unref (busdev, &error_fatal); +sysbus_realize (busdev, &error_fatal);sysbus_mmio_map (busdev,0 ,0x10000000 );sysbus_mmio_map (busdev,1 ,0x13e00000 );sysbus_connect_irq (busdev,0 , &fpga->irq[SM501 ]);/* onboard CF (True IDE mode, Master only). */ dinfo =drive_get (IF_IDE ,0 ,0 ); - dev =qdev_new_orphan ("mmio-ide" ); + dev =qdev_new (OBJECT (machine),"ide" ,"mmio-ide" ); busdev =SYS_BUS_DEVICE (dev);sysbus_connect_irq (busdev,0 , &fpga->irq[CF_IDE ]);qdev_prop_set_uint32 (dev,"shift" ,1 ); -sysbus_realize_and_unref (busdev, &error_fatal); +sysbus_realize (busdev, &error_fatal);sysbus_mmio_map (busdev,0 ,0x14001000 );sysbus_mmio_map (busdev,1 ,0x1400080c );mmio_ide_init_drives (dev, dinfo,NULL );
@@ -320,7 +321,8 @@ static void r2d_init(MachineState *machine)/* USB keyboard */ usb_bus =USB_BUS (object_resolve_type_unambiguous (TYPE_USB_BUS , &error_abort)); -usb_create_simple_orphan (usb_bus,"usb-kbd" ); +usb_create_simple (OBJECT (BUS (usb_bus)->parent),"usb-kbd" , + usb_bus,"usb-kbd" );/* Todo: register on board registers */ memset (&boot_params,0 ,sizeof (boot_params));
hw/sh4/sh7750.c +6 -5
@@ -710,7 +710,8 @@ static const MemoryRegionOps sh7750_mmct_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; -SH7750State *sh7750_init (SuperHCPU *cpu,MemoryRegion *sysmem) +SH7750State *sh7750_init (Object *parent,SuperHCPU *cpu, +MemoryRegion *sysmem) {SH7750State *s;DeviceState *dev;
@@ -762,11 +763,11 @@ SH7750State *sh7750_init(SuperHCPU *cpu, MemoryRegion *sysmem) cpu->env.intc_handle = &s->intc;/* SCI */ - dev =qdev_new_orphan (TYPE_SH_SERIAL ); + dev =qdev_new (parent,"sci" ,TYPE_SH_SERIAL ); dev->id =g_strdup ("sci" );qdev_prop_set_chr (dev,"chardev" ,serial_hd (0 )); sb =SYS_BUS_DEVICE (dev); -sysbus_realize_and_unref (sb, &error_fatal); +sysbus_realize (sb, &error_fatal);sysbus_mmio_map (sb,0 ,0xffe00000 ); alias =g_malloc (sizeof (*alias)); mr =sysbus_mmio_get_region (sb,0 );
@@ -779,12 +780,12 @@ SH7750State *sh7750_init(SuperHCPU *cpu, MemoryRegion *sysmem)qdev_connect_gpio_out_named (dev,"tei" ,0 , s->intc.irqs[SCI1_TEI ]);/* SCIF */ - dev =qdev_new_orphan (TYPE_SH_SERIAL ); + dev =qdev_new (parent,"scif" ,TYPE_SH_SERIAL ); dev->id =g_strdup ("scif" );qdev_prop_set_chr (dev,"chardev" ,serial_hd (1 ));qdev_prop_set_uint8 (dev,"features" ,SH_SERIAL_FEAT_SCIF ); sb =SYS_BUS_DEVICE (dev); -sysbus_realize_and_unref (sb, &error_fatal); +sysbus_realize (sb, &error_fatal);sysbus_mmio_map (sb,0 ,0xffe80000 ); alias =g_malloc (sizeof (*alias)); mr =sysbus_mmio_get_region (sb,0 );
include/hw/sh4/sh.h +2 -1
@@ -36,7 +36,8 @@/* sh7750.c */ struct SH7750State ; -struct SH7750State *sh7750_init (SuperHCPU *cpu,MemoryRegion *sysmem); +struct SH7750State *sh7750_init (Object *parent,SuperHCPU *cpu, +MemoryRegion *sysmem);#define TYPE_SH_SERIAL "sh-serial"#define SH_SERIAL_FEAT_SCIF (1 << 0)
Signature · 1 line
2.47.1
RFC PATCH 19/134 hw/s390x: Give onboard devices a QOM parent
In reply to Alexander GrafConvert the *_orphan() device-creation calls in hw/s390x to the new parented API introduced earlier in this series, so every onboard device gets a stable path in the composition tree instead of landing in /machine/unattached with an unstable device[N] name.
The parent for each device is the object that owns its lifetime: the machine for board-created devices, the containing device for composite children. Names follow existing QOM conventions.
Per-site rationale (reviewers: dispute the modeling here):
file:line | parent | name | rationale ap-bridge.c:52 | qdev_get_machine() | TYPE_AP_BRIDGE | already parented via object_property_add_child(); collapse into qdev_new() and keep the same name for QOM-path stability css-bridge.c:95 | qdev_get_machine() | TYPE_VIRTUAL_CSS_BRIDGE | already parented via object_property_add_child(); collapse into qdev_new() s390-pci-bus.c:970 | OBJECT(s) | "zpci[*]" | auto-created zPCI companion for a hot-plugged PCI device; the S390pciState host bridge owns it; auto-index name s390-virtio-ccw.c:256 | OBJECT(ef) | type | already parented to the SCLP event facility; collapse into qdev_new() and keep the type-derived name s390-virtio-ccw.c:268 | OBJECT(ef) | "sclpcpi" | already parented; collapse into qdev_new() s390-virtio-ccw.c:312 | OBJECT(machine) | TYPE_S390_PCI_HOST_BRIDGE | already parented to machine; collapse into qdev_new() with the same name
--- hw/s390x/ap-bridge.c | 6 ++---- hw/s390x/css-bridge.c | 7 +++---- hw/s390x/s390-pci-bus.c | 4 ++-- hw/s390x/s390-virtio-ccw.c | 17 +++++++---------- 4 files changed, 14 insertions(+), 20 deletions(-)
hw/s390x/ap-bridge.c +2 -4
@@ -49,10 +49,8 @@ void s390_init_ap(void) }/* Create bridge device */ - dev =qdev_new_orphan (TYPE_AP_BRIDGE ); -object_property_add_child (qdev_get_machine (),TYPE_AP_BRIDGE , -OBJECT (dev)); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); + dev =qdev_new (qdev_get_machine (),TYPE_AP_BRIDGE ,TYPE_AP_BRIDGE ); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);/* Create bus on bridge device */ bus =qbus_new (TYPE_AP_BUS , dev,TYPE_AP_BUS );
hw/s390x/css-bridge.c +3 -4
@@ -92,9 +92,8 @@ VirtualCssBus *virtual_css_bus_init(void)DeviceState *dev;/* Create bridge device */ - dev =qdev_new_orphan (TYPE_VIRTUAL_CSS_BRIDGE ); -object_property_add_child (qdev_get_machine (),TYPE_VIRTUAL_CSS_BRIDGE , -OBJECT (dev)); + dev =qdev_new (qdev_get_machine (),TYPE_VIRTUAL_CSS_BRIDGE , +TYPE_VIRTUAL_CSS_BRIDGE );/* Create bus on bridge device */ bus =qbus_new (TYPE_VIRTUAL_CSS_BUS , dev,"virtual-css" );
@@ -102,7 +101,7 @@ VirtualCssBus *virtual_css_bus_init(void)/* Enable hotplugging */ qbus_set_hotplug_handler (bus,OBJECT (dev)); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);css_register_io_adapters (CSS_IO_ADAPTER_VIRTIO , true, false,0 , &error_abort);
hw/s390x/s390-pci-bus.c +2 -2
@@ -967,7 +967,7 @@ static S390PCIBusDevice *s390_pci_device_new(S390pciState *s,Error *local_err =NULL ;DeviceState *dev; - dev =qdev_try_new_orphan (TYPE_S390_PCI_DEVICE ); + dev =qdev_try_new (OBJECT (s),"zpci[*]" ,TYPE_S390_PCI_DEVICE );if (!dev) {error_setg (errp,"zPCI device could not be created" );return NULL ;
@@ -979,7 +979,7 @@ static S390PCIBusDevice *s390_pci_device_new(S390pciState *s, "zPCI device could not be created: ");return NULL ; } -if (!qdev_realize_and_unref (dev,BUS (s->bus), &local_err)) { +if (!qdev_realize (dev,BUS (s->bus), &local_err)) {object_unparent (OBJECT (dev));error_propagate_prepend (errp, local_err,"zPCI device could not be created: " );
hw/s390x/s390-virtio-ccw.c +7 -10
@@ -253,10 +253,9 @@ static void s390_create_sclpconsole(SCLPDevice *sclp,BusState *ev_fac_bus =sclp_get_event_facility_bus (ef);DeviceState *dev; - dev =qdev_new_orphan (type); -object_property_add_child (OBJECT (ef), type,OBJECT (dev)); + dev =qdev_new (OBJECT (ef), type, type);qdev_prop_set_chr (dev,"chardev" , chardev); -qdev_realize_and_unref (dev, ev_fac_bus, &error_fatal); +qdev_realize (dev, ev_fac_bus, &error_fatal); }static void s390_create_sclpcpi (SCLPDevice *sclp)
@@ -265,9 +264,8 @@ static void s390_create_sclpcpi(SCLPDevice *sclp)BusState *ev_fac_bus =sclp_get_event_facility_bus (ef);DeviceState *dev; - dev =qdev_new_orphan (TYPE_SCLP_EVENT_CPI ); -object_property_add_child (OBJECT (ef),"sclpcpi" ,OBJECT (dev)); -qdev_realize_and_unref (dev, ev_fac_bus, &error_fatal); + dev =qdev_new (OBJECT (ef),"sclpcpi" ,TYPE_SCLP_EVENT_CPI ); +qdev_realize (dev, ev_fac_bus, &error_fatal); }static void ccw_init (MachineState *machine)
@@ -309,10 +307,9 @@ static void ccw_init(MachineState *machine) machine->firmware ?:"s390-ccw.img" , true); - dev =qdev_new_orphan (TYPE_S390_PCI_HOST_BRIDGE ); -object_property_add_child (qdev_get_machine (),TYPE_S390_PCI_HOST_BRIDGE , -OBJECT (dev)); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); + dev =qdev_new (OBJECT (machine),TYPE_S390_PCI_HOST_BRIDGE , +TYPE_S390_PCI_HOST_BRIDGE ); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);s390_enable_css_support (s390_cpu_addr2state (0 ));
Signature · 1 line
2.47.1
RFC PATCH 20/134 hw/or1k: Give onboard devices a QOM parent
In reply to Alexander GrafConvert the *_orphan() device-creation calls in hw/or1k to the new parented API introduced earlier in this series, so every onboard device gets a stable path in the composition tree instead of landing in /machine/unattached with an unstable device[N] name.
The parent for each device is the object that owns its lifetime: the machine for board-created devices, the containing device for composite children. Names follow existing QOM conventions.
Per-site rationale (reviewers: dispute the modeling here):
hw/or1k/or1k-sim.c:189 | OBJECT(state) | "irq-splitter[*]" | board-init helper receives Or1ksimState; auto-index (net + serial share the pool) hw/or1k/or1k-sim.c:224 | OBJECT(state) | "ompic" | board-init helper receives Or1ksimState; single OMPIC per machine hw/or1k/or1k-sim.c:257 | OBJECT(state) | "irq-splitter[*]" | board-init helper receives Or1ksimState; auto-index alongside net splitter hw/or1k/or1k-sim.c:302 | OBJECT(machine) | "cpu[*]" | MachineClass.init(); auto-index over smp_cpus hw/or1k/virt.c:113 | parent | "irq-splitter[*]" | static helper had no parent-capable arg; add Object *parent first arg, thread OBJECT(state) from all callers; auto-index (serial+rtc+virtio*N) hw/or1k/virt.c:209 | OBJECT(state) | "ompic" | board-init helper receives OR1KVirtState; single OMPIC hw/or1k/virt.c:303 | OBJECT(state) | "rtc" | board-init helper receives OR1KVirtState; single Goldfish RTC hw/or1k/virt.c:382 | OBJECT(state) | "pcie" | board-init helper receives OR1KVirtState; single GPEX host hw/or1k/virt.c:454 | OBJECT(state) | "virtio-mmio[*]" | board-init helper receives OR1KVirtState; called VIRTIO_COUNT times, auto-index hw/or1k/virt.c:484 | OBJECT(machine) | "cpu[*]" | MachineClass.init(); auto-index over smp_cpus
--- hw/or1k/or1k-sim.c | 17 ++++++++++------- hw/or1k/virt.c | 37 ++++++++++++++++++++++--------------- 2 files changed, 32 insertions(+), 22 deletions(-)
hw/or1k/or1k-sim.c +10 -7
@@ -186,9 +186,10 @@ static void openrisc_sim_net_init(Or1ksimState *state, hwaddr base, hwaddr size, s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);if (num_cpus >1 ) { -DeviceState *splitter =qdev_new_orphan (TYPE_SPLIT_IRQ ); +DeviceState *splitter =qdev_new (OBJECT (state),"irq-splitter[*]" , +TYPE_SPLIT_IRQ );qdev_prop_set_uint32 (splitter,"num-lines" , num_cpus); -qdev_realize_and_unref (splitter,NULL , &error_fatal); +qdev_realize (splitter,NULL , &error_fatal);for (i =0 ; i < num_cpus; i++) {qdev_connect_gpio_out (splitter, i,get_cpu_irq (cpus, i, irq_pin)); }
@@ -221,11 +222,11 @@ static void openrisc_sim_ompic_init(Or1ksimState *state, hwaddr base,char *nodename;int i; - dev =qdev_new_orphan ("or1k-ompic" ); + dev =qdev_new (OBJECT (state),"ompic" ,"or1k-ompic" );qdev_prop_set_uint32 (dev,"num-cpus" , num_cpus); s =SYS_BUS_DEVICE (dev); -sysbus_realize_and_unref (s, &error_fatal); +sysbus_realize (s, &error_fatal);for (i =0 ; i < num_cpus; i++) {sysbus_connect_irq (s, i,get_cpu_irq (cpus, i, irq_pin)); }
@@ -254,9 +255,10 @@ static void openrisc_sim_serial_init(Or1ksimState *state, hwaddr base,int i;if (num_cpus >1 ) { -DeviceState *splitter =qdev_new_orphan (TYPE_SPLIT_IRQ ); +DeviceState *splitter =qdev_new (OBJECT (state),"irq-splitter[*]" , +TYPE_SPLIT_IRQ );qdev_prop_set_uint32 (splitter,"num-lines" , num_cpus); -qdev_realize_and_unref (splitter,NULL , &error_fatal); +qdev_realize (splitter,NULL , &error_fatal);for (i =0 ; i < num_cpus; i++) {qdev_connect_gpio_out (splitter, i,get_cpu_irq (cpus, i, irq_pin)); }
@@ -299,7 +301,8 @@ static void openrisc_sim_init(MachineState *machine)assert (smp_cpus >=1 && smp_cpus <=OR1KSIM_CPUS_MAX );for (n =0 ; n < smp_cpus; n++) { - cpus[n] =OPENRISC_CPU (cpu_create_orphan (machine->cpu_type)); + cpus[n] =OPENRISC_CPU (cpu_create (OBJECT (machine),"cpu[*]" , + machine->cpu_type));if (cpus[n] ==NULL ) {fprintf (stderr,"Unable to find CPU definition!\n" );exit (1 );
hw/or1k/virt.c +22 -15
@@ -105,14 +105,16 @@ static qemu_irq get_cpu_irq(OpenRISCCPU *cpus[], int cpunum, int irq_pin)return qdev_get_gpio_in_named (DEVICE (cpus[cpunum]),"IRQ" , irq_pin); } -static qemu_irq get_per_cpu_irq (OpenRISCCPU *cpus[],int num_cpus,int irq_pin) +static qemu_irq get_per_cpu_irq (Object *parent,OpenRISCCPU *cpus[], +int num_cpus,int irq_pin) {int i;if (num_cpus >1 ) { -DeviceState *splitter =qdev_new_orphan (TYPE_SPLIT_IRQ ); +DeviceState *splitter =qdev_new (parent,"irq-splitter[*]" , +TYPE_SPLIT_IRQ );qdev_prop_set_uint32 (splitter,"num-lines" , num_cpus); -qdev_realize_and_unref (splitter,NULL , &error_fatal); +qdev_realize (splitter,NULL , &error_fatal);for (i =0 ; i < num_cpus; i++) {qdev_connect_gpio_out (splitter, i,get_cpu_irq (cpus, i, irq_pin)); }
@@ -206,11 +208,11 @@ static void openrisc_virt_ompic_init(OR1KVirtState *state, hwaddr base,char *nodename;int i; - dev =qdev_new_orphan ("or1k-ompic" ); + dev =qdev_new (OBJECT (state),"ompic" ,"or1k-ompic" );qdev_prop_set_uint32 (dev,"num-cpus" , num_cpus); s =SYS_BUS_DEVICE (dev); -sysbus_realize_and_unref (s, &error_fatal); +sysbus_realize (s, &error_fatal);for (i =0 ; i < num_cpus; i++) {sysbus_connect_irq (s, i,get_cpu_irq (cpus, i, irq_pin)); }
@@ -233,7 +235,8 @@ static void openrisc_virt_serial_init(OR1KVirtState *state, hwaddr base, {void *fdt = state->fdt;char *nodename; -qemu_irq serial_irq =get_per_cpu_irq (cpus, num_cpus, irq_pin); +qemu_irq serial_irq =get_per_cpu_irq (OBJECT (state), cpus, num_cpus, + irq_pin);serial_mm_init (get_system_memory (), base,0 , serial_irq,115200 ,serial_hd (0 ),DEVICE_BIG_ENDIAN );
@@ -297,10 +300,12 @@ static void openrisc_virt_rtc_init(OR1KVirtState *state, hwaddr base, {void *fdt = state->fdt;char *nodename; -qemu_irq rtc_irq =get_per_cpu_irq (cpus, num_cpus, irq_pin); +qemu_irq rtc_irq =get_per_cpu_irq (OBJECT (state), cpus, num_cpus, + irq_pin);/* Goldfish RTC */ -sysbus_create_simple_orphan (TYPE_GOLDFISH_RTC , base, rtc_irq); +sysbus_create_simple (OBJECT (state),"rtc" ,TYPE_GOLDFISH_RTC , base, + rtc_irq);/* Goldfish RTC FDT */ nodename =g_strdup_printf ("/soc/rtc@%" HWADDR_PRIx, base);
@@ -379,8 +384,8 @@ static void openrisc_virt_pcie_init(OR1KVirtState *state,qemu_irq pcie_irq;int i; - dev =qdev_new_orphan (TYPE_GPEX_HOST ); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); + dev =qdev_new (OBJECT (state),"pcie" ,TYPE_GPEX_HOST ); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);/* Map ECAM space. */ alias =g_new0 (MemoryRegion,1 );
@@ -410,7 +415,7 @@ static void openrisc_virt_pcie_init(OR1KVirtState *state,/* Connect IRQ lines. */ for (i =0 ; i <PCI_NUM_PINS ; i++) { - pcie_irq =get_per_cpu_irq (cpus, num_cpus, irq_base + i); + pcie_irq =get_per_cpu_irq (OBJECT (state), cpus, num_cpus, irq_base + i);sysbus_connect_irq (SYS_BUS_DEVICE (dev), i, pcie_irq);gpex_set_irq_num (GPEX_HOST (dev), i, irq_base + i);
@@ -448,13 +453,14 @@ static void openrisc_virt_virtio_init(OR1KVirtState *state, hwaddr base,char *nodename;DeviceState *dev;SysBusDevice *sysbus; -qemu_irq virtio_irq =get_per_cpu_irq (cpus, num_cpus, irq_pin); +qemu_irq virtio_irq =get_per_cpu_irq (OBJECT (state), cpus, num_cpus, + irq_pin);/* VirtIO MMIO devices */ - dev =qdev_new_orphan (TYPE_VIRTIO_MMIO ); + dev =qdev_new (OBJECT (state),"virtio-mmio[*]" ,TYPE_VIRTIO_MMIO );qdev_prop_set_bit (dev,"force-legacy" , false); sysbus =SYS_BUS_DEVICE (dev); -sysbus_realize_and_unref (sysbus, &error_fatal); +sysbus_realize (sysbus, &error_fatal);sysbus_connect_irq (sysbus,0 , virtio_irq);sysbus_mmio_map (sysbus,0 , base);
@@ -481,7 +487,8 @@ static void openrisc_virt_init(MachineState *machine)assert (smp_cpus >=1 && smp_cpus <=VIRT_CPUS_MAX );for (n =0 ; n < smp_cpus; n++) { - cpus[n] =OPENRISC_CPU (cpu_create_orphan (machine->cpu_type)); + cpus[n] =OPENRISC_CPU (cpu_create (OBJECT (machine),"cpu[*]" , + machine->cpu_type));if (cpus[n] ==NULL ) {fprintf (stderr,"Unable to find CPU definition!\n" );exit (1 );
Signature · 1 line
2.47.1
RFC PATCH 21/134 hw/loongarch: Give onboard devices a QOM parent
In reply to Alexander GrafConvert the *_orphan() device-creation calls in hw/loongarch to the new parented API introduced earlier in this series, so every onboard device gets a stable path in the composition tree instead of landing in /machine/unattached with an unstable device[N] name.
The parent for each device is the object that owns its lifetime: the machine for board-created devices, the containing device for composite children. Names follow existing QOM conventions.
Per-site rationale (reviewers: dispute the modeling here):
file:line | creator | parent | name | rationale
hw/loongarch/virt.c:153 | qdev_new | OBJECT(lvms) | name | board-init helper already receives lvms + child name; drop redundant object_property_add_child() hw/loongarch/virt.c:298 | qdev_new | OBJECT(lvms) | "acpi-ged" | board-init helper receives LoongArchVirtMachineState *lvms hw/loongarch/virt.c:325 | qdev_new | parent | "platform-bus" | static helper w/o parent ptr; add Object *parent first arg, thread OBJECT(lvms) from caller hw/loongarch/virt.c:403 | qdev_new | OBJECT(lvms) | "pci-host" | board-init helper receives lvms hw/loongarch/virt.c:488 | sysbus_create_simple | OBJECT(lvms) | "rtc" | board-init helper receives lvms hw/loongarch/virt.c:604 | qdev_new | OBJECT(lvms) | "ipi" | virt_irq_init() receives lvms hw/loongarch/virt.c:610 | qdev_new | OBJECT(lvms) | "dintc" | virt_irq_init() receives lvms hw/loongarch/virt.c:617 | qdev_new | OBJECT(lvms) | "extioi" | virt_irq_init() receives lvms hw/loongarch/virt.c:625 | qdev_new | OBJECT(lvms) | "pch-pic" | virt_irq_init() receives lvms hw/loongarch/virt.c:631 | qdev_new | OBJECT(lvms) | "pch-msi" | virt_irq_init() receives lvms
--- hw/loongarch/virt.c | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-)
hw/loongarch/virt.c +21 -22
@@ -150,7 +150,7 @@ static PFlashCFI01 *virt_flash_create1(LoongArchVirtMachineState *lvms,const char *name, const char *alias_prop_name) { - DeviceState *dev = qdev_new_orphan(TYPE_PFLASH_CFI01); + DeviceState *dev = qdev_new(OBJECT(lvms), name, TYPE_PFLASH_CFI01);qdev_prop_set_uint64 (dev,"sector-length" ,VIRT_FLASH_SECTOR_SIZE );qdev_prop_set_uint8 (dev,"width" ,4 );
@@ -161,7 +161,6 @@ static PFlashCFI01 *virt_flash_create1(LoongArchVirtMachineState *lvms,qdev_prop_set_uint16 (dev,"id2" ,0x00 );qdev_prop_set_uint16 (dev,"id3" ,0x00 );qdev_prop_set_string (dev,"name" , name); -object_property_add_child (OBJECT (lvms), name,OBJECT (dev));object_property_add_alias (OBJECT (lvms), alias_prop_name,OBJECT (dev),"drive" );return PFLASH_CFI01 (dev);
@@ -191,7 +190,7 @@ static void virt_flash_map1(PFlashCFI01 *flash,assert (real_size /VIRT_FLASH_SECTOR_SIZE <=UINT32_MAX );qdev_prop_set_uint32 (dev,"num-blocks" , real_size /VIRT_FLASH_SECTOR_SIZE ); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);memory_region_add_subregion (sysmem, base,sysbus_mmio_get_region (SYS_BUS_DEVICE (dev),0 )); }
@@ -295,9 +294,9 @@ static DeviceState *create_acpi_ged(DeviceState *pch_pic, event |=ACPI_GED_CPU_HOTPLUG_EVT ; } - dev =qdev_new_orphan (TYPE_ACPI_GED ); + dev =qdev_new (OBJECT (lvms),"acpi-ged" ,TYPE_ACPI_GED );qdev_prop_set_uint32 (dev,"ged-event" , event); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);/* ged event */ sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,VIRT_GED_EVT_ADDR );
@@ -315,18 +314,18 @@ static DeviceState *create_acpi_ged(DeviceState *pch_pic,return dev; } -static DeviceState *create_platform_bus (DeviceState *pch_pic) +static DeviceState *create_platform_bus (Object *parent,DeviceState *pch_pic) {DeviceState *dev;SysBusDevice *sysbus;int i, irq;MemoryRegion *sysmem =get_system_memory (); - dev =qdev_new_orphan (TYPE_PLATFORM_BUS_DEVICE ); + dev =qdev_new (parent,"platform-bus" ,TYPE_PLATFORM_BUS_DEVICE ); dev->id =g_strdup (TYPE_PLATFORM_BUS_DEVICE );qdev_prop_set_uint32 (dev,"num_irqs" ,VIRT_PLATFORM_BUS_NUM_IRQS );qdev_prop_set_uint32 (dev,"mmio_size" ,VIRT_PLATFORM_BUS_SIZE ); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal); sysbus =SYS_BUS_DEVICE (dev);for (i =0 ; i <VIRT_PLATFORM_BUS_NUM_IRQS ; i++) {
@@ -400,9 +399,9 @@ static void virt_devices_init(DeviceState *pch_pic,hwaddr mmio_base, mmio_size;int i, irq; - gpex_dev =qdev_new_orphan (TYPE_GPEX_HOST ); + gpex_dev =qdev_new (OBJECT (lvms),"pci-host" ,TYPE_GPEX_HOST ); d =SYS_BUS_DEVICE (gpex_dev); -sysbus_realize_and_unref (d, &error_fatal); +sysbus_realize (d, &error_fatal); pci_bus =PCI_HOST_BRIDGE (gpex_dev)->bus; lvms->gpex.pio.base =VIRT_PCI_IO_BASE ; lvms->gpex.pio.size =VIRT_PCI_IO_SIZE ;
@@ -485,14 +484,14 @@ static void virt_devices_init(DeviceState *pch_pic,* Create some unimplemented devices to emulate this. */ create_unimplemented_device ("pci-dma-cfg" ,0x1001041c ,0x4 ); -sysbus_create_simple_orphan ("ls7a_rtc" ,VIRT_RTC_REG_BASE , +sysbus_create_simple (OBJECT (lvms),"rtc" ,"ls7a_rtc" ,VIRT_RTC_REG_BASE ,qdev_get_gpio_in (pch_pic,VIRT_RTC_IRQ -VIRT_GSI_BASE ));/* acpi ged */ lvms->acpi_ged =create_acpi_ged (pch_pic, lvms);/* platform bus */ - lvms->platform_bus_dev =create_platform_bus (pch_pic); + lvms->platform_bus_dev =create_platform_bus (OBJECT (lvms), pch_pic); }static void virt_cpu_irq_init (LoongArchVirtMachineState *lvms)
@@ -601,40 +600,40 @@ static void virt_irq_init(LoongArchVirtMachineState *lvms)*/ /* Create IPI device */ - ipi =qdev_new_orphan (TYPE_LOONGARCH_IPI ); + ipi =qdev_new (OBJECT (lvms),"ipi" ,TYPE_LOONGARCH_IPI ); lvms->ipi = ipi; -sysbus_realize_and_unref (SYS_BUS_DEVICE (ipi), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (ipi), &error_fatal);/* Create DINTC device*/ if (virt_has_dmsi (lvms)) { - dintc =qdev_new_orphan (TYPE_LOONGARCH_DINTC ); + dintc =qdev_new (OBJECT (lvms),"dintc" ,TYPE_LOONGARCH_DINTC ); lvms->dintc = dintc; -sysbus_realize_and_unref (SYS_BUS_DEVICE (dintc), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (dintc), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dintc),0 ,VIRT_DINTC_BASE ); }/* Create EXTIOI device */ - extioi =qdev_new_orphan (TYPE_LOONGARCH_EXTIOI ); + extioi =qdev_new (OBJECT (lvms),"extioi" ,TYPE_LOONGARCH_EXTIOI ); lvms->extioi = extioi;if (virt_is_veiointc_enabled (lvms)) {qdev_prop_set_bit (extioi,"has-virtualization-extension" , true); } -sysbus_realize_and_unref (SYS_BUS_DEVICE (extioi), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (extioi), &error_fatal);virt_cpu_irq_init (lvms); - pch_pic =qdev_new_orphan (TYPE_LOONGARCH_PIC ); + pch_pic =qdev_new (OBJECT (lvms),"pch-pic" ,TYPE_LOONGARCH_PIC ); num =VIRT_PCH_PIC_IRQ_NUM ;qdev_prop_set_uint32 (pch_pic,"pch_pic_irq_num" , num); d =SYS_BUS_DEVICE (pch_pic); -sysbus_realize_and_unref (d, &error_fatal); +sysbus_realize (d, &error_fatal); - pch_msi =qdev_new_orphan (TYPE_LOONGARCH_PCH_MSI ); + pch_msi =qdev_new (OBJECT (lvms),"pch-msi" ,TYPE_LOONGARCH_PCH_MSI ); start = num; num =EXTIOI_IRQS - start;qdev_prop_set_uint32 (pch_msi,"msi_irq_base" , start);qdev_prop_set_uint32 (pch_msi,"msi_irq_num" , num); d =SYS_BUS_DEVICE (pch_msi); -sysbus_realize_and_unref (d, &error_fatal); +sysbus_realize (d, &error_fatal);sysbus_mmio_map (d,0 ,VIRT_PCH_MSI_ADDR_LOW );if (kvm_irqchip_in_kernel ()) {
Signature · 1 line
2.47.1
RFC PATCH 22/134 hw/intc: Give onboard devices a QOM parent
In reply to Alexander GrafConvert the *_orphan() device-creation calls in hw/intc to the new parented API introduced earlier in this series, so every onboard device gets a stable path in the composition tree instead of landing in /machine/unattached with an unstable device[N] name.
The parent for each device is the object that owns its lifetime: the machine for board-created devices, the containing device for composite children. Names follow existing QOM conventions.
Per-site rationale (reviewers: dispute the modeling here):
hw/intc/apic_common.c:285 | sysbus_create_simple | qdev_get_machine() | "kvmvapic" | function-static singleton shared by all per-CPU APICs; cannot belong to any single APIC, so parent to the machine hw/intc/exynos4210_gic.c:63 | qdev_new | OBJECT(dev) | "gic" | inside exynos4210_gic_realize(); inner GIC is a component of the composite Exynos GIC devicehw/intc/i8259_common.c:97 | isa_new | Object *parent (new arg) | "i8259[*]" | i8259_init_chip() is a helper with no parent-capable arg; thread Object *parent through i8259_init()/kvm_i8259_init() and their callers; two chips per parent so auto-index
hw/intc/riscv_aclint.c:372 | qdev_new | Object *parent (new arg) | "aclint-mtimer[*]" | riscv_aclint_mtimer_create() helper; parent threaded from board/SoC callers; per-socket instances so auto-index hw/intc/riscv_aclint.c:555 | qdev_new | Object *parent (new arg) | "aclint-swi[*]" | riscv_aclint_swi_create() helper; parent threaded from board/SoC callers; per-socket M/S-SWI so auto-index hw/intc/riscv_aplic.c:1116 | qdev_new | Object *parent (new arg) | "aplic[*]" | riscv_aplic_create() helper; existing DeviceState *parent (APLIC hierarchy) renamed to aplic_parent to avoid clash; multiple M/S instances so auto-index hw/intc/riscv_imsic.c:477 | qdev_new | Object *parent (new arg) | "imsic[*]" | riscv_imsic_create() helper; parent threaded from board/SoC callers; per-hart M/S instances so auto-index hw/intc/s390_flic.c:65 | qdev_new | qdev_get_machine() | TYPE_KVM_S390_FLIC | already followed by object_property_add_child(machine, ...); collapse into parented qdev_new() and drop the redundant add_child hw/intc/s390_flic.c:69 | qdev_new | qdev_get_machine() | TYPE_QEMU_S390_FLIC | same as above; collapse into parented qdev_new() and drop the redundant add_child
hw/intc/sifive_plic.c:484 | qdev_new | Object *parent (new arg) | "plic[*]" | sifive_plic_create() helper; parent threaded from board/SoC callers; per-socket instances so auto-index
--- hw/hppa/machine.c | 8 ++++---- hw/i386/isapc.c | 2 +- hw/i386/kvm/i8259.c | 6 +++--- hw/i386/microvm.c | 2 +- hw/i386/pc.c | 6 +++--- hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 2 +- hw/intc/apic_common.c | 3 ++- hw/intc/exynos4210_gic.c | 4 ++-- hw/intc/i8259.c | 6 +++--- hw/intc/i8259_common.c | 7 ++++--- hw/intc/riscv_aclint.c | 16 ++++++++++------ hw/intc/riscv_aplic.c | 13 +++++++------ hw/intc/riscv_imsic.c | 7 ++++--- hw/intc/s390_flic.c | 12 +++++------- hw/intc/sifive_plic.c | 7 ++++--- hw/isa/i82378.c | 2 +- hw/isa/piix.c | 2 +- hw/isa/vt82c686.c | 2 +- hw/mips/jazz.c | 2 +- hw/riscv/aia.c | 12 +++++++----- hw/riscv/aia.h | 3 ++- hw/riscv/cps.c | 9 +++++---- hw/riscv/k230.c | 12 +++++++----- hw/riscv/microchip_pfsoc.c | 7 ++++--- hw/riscv/shakti_c.c | 8 +++++--- hw/riscv/sifive_e.c | 7 ++++--- hw/riscv/sifive_u.c | 7 ++++--- hw/riscv/spike.c | 4 ++-- hw/riscv/tt_atlantis.c | 6 ++++-- hw/riscv/virt.c | 27 +++++++++++++++++---------- hw/riscv/xiangshan_kmh.c | 18 ++++++++++-------- include/hw/i386/pc.h | 2 +- include/hw/intc/i8259.h | 4 ++-- include/hw/intc/riscv_aclint.h | 6 ++++-- include/hw/intc/riscv_aplic.h | 5 +++-- include/hw/intc/riscv_imsic.h | 3 ++- include/hw/intc/sifive_plic.h | 3 ++- include/hw/isa/i8259_internal.h | 3 ++- 39 files changed, 146 insertions(+), 111 deletions(-)
hw/hppa/machine.c +4 -4
@@ -97,7 +97,7 @@ static const MemoryRegionOps hppa_pci_ignore_ops = { }, }; -static ISABus *hppa_isa_bus (hwaddr addr) +static ISABus *hppa_isa_bus (Object *parent,hwaddr addr) {ISABus *isa_bus;qemu_irq *isa_irqs;
@@ -110,7 +110,7 @@ static ISABus *hppa_isa_bus(hwaddr addr) isa_bus =isa_bus_new (NULL ,get_system_memory (), isa_region, &error_abort); - isa_irqs =i8259_init (isa_bus,NULL ); + isa_irqs =i8259_init (parent, isa_bus,NULL );isa_bus_register_input_irqs (isa_bus, isa_irqs);return isa_bus;
@@ -596,7 +596,7 @@ static void machine_HP_715_init(MachineState *machine) }/* Create ISA bus, needed for PS/2 kbd/mouse port emulation */ - isa_bus =hppa_isa_bus (translate (NULL ,IDE_HPA )); + isa_bus =hppa_isa_bus (OBJECT (machine),translate (NULL ,IDE_HPA ));assert (isa_bus);/* Init Lasi chip */
@@ -690,7 +690,7 @@ static void machine_HP_B160L_init(MachineState *machine)assert (pci_bus);/* Create ISA bus, needed for PS/2 kbd/mouse port emulation */ - isa_bus =hppa_isa_bus (translate (NULL ,IDE_HPA )); + isa_bus =hppa_isa_bus (OBJECT (machine),translate (NULL ,IDE_HPA ));assert (isa_bus);/* Serial ports: Lasi and Dino use a 7.272727 MHz clock. */
hw/i386/isapc.c +1 -1
@@ -123,7 +123,7 @@ static void pc_init_isa(MachineState *machine) pcms->hpet_enabled = false;if (x86ms->pic ==ON_OFF_AUTO_ON || x86ms->pic ==ON_OFF_AUTO_AUTO ) { -pc_i8259_create (isa_bus, gsi_state->i8259_irq); +pc_i8259_create (OBJECT (machine), isa_bus, gsi_state->i8259_irq); }if (tcg_enabled ()) {
hw/i386/kvm/i8259.c +3 -3
@@ -131,10 +131,10 @@ static void kvm_pic_realize(DeviceState *dev, Error **errp) kpc->parent_realize (dev, errp); } -qemu_irq *kvm_i8259_init (ISABus *bus) +qemu_irq *kvm_i8259_init (Object *parent,ISABus *bus) { -i8259_init_chip (TYPE_KVM_I8259 , bus, true); -i8259_init_chip (TYPE_KVM_I8259 , bus, false); +i8259_init_chip (parent,TYPE_KVM_I8259 , bus, true); +i8259_init_chip (parent,TYPE_KVM_I8259 , bus, false);return qemu_allocate_irqs (kvm_pic_set_irq,NULL ,ISA_NUM_IRQS ); }
hw/i386/microvm.c +1 -1
@@ -251,7 +251,7 @@ static void microvm_devices_init(MicrovmMachineState *mms)if (x86ms->pic ==ON_OFF_AUTO_ON || x86ms->pic ==ON_OFF_AUTO_AUTO ) {qemu_irq *i8259; - i8259 =i8259_init (isa_bus,x86_allocate_cpu_irq ()); + i8259 =i8259_init (OBJECT (mms), isa_bus,x86_allocate_cpu_irq ());for (i =0 ; i <ISA_NUM_IRQS ; i++) { gsi_state->i8259_irq[i] = i8259[i]; }
hw/i386/pc.c +3 -3
@@ -1159,16 +1159,16 @@ void pc_nic_init(PCMachineClass *pcmc, ISABus *isa_bus, PCIBus *pci_bus) } } -void pc_i8259_create (ISABus *isa_bus,qemu_irq *i8259_irqs) +void pc_i8259_create (Object *parent,ISABus *isa_bus,qemu_irq *i8259_irqs) {qemu_irq *i8259;if (kvm_pic_in_kernel ()) { - i8259 =kvm_i8259_init (isa_bus); + i8259 =kvm_i8259_init (parent, isa_bus); }else if (xen_enabled ()) { i8259 =xen_interrupt_controller_init (); }else { - i8259 =i8259_init (isa_bus,x86_allocate_cpu_irq ()); + i8259 =i8259_init (parent, isa_bus,x86_allocate_cpu_irq ()); }for (size_t i =0 ; i <ISA_NUM_IRQS ; i++) {
hw/i386/pc_piix.c +1 -1
@@ -281,7 +281,7 @@ static void pc_init1(MachineState *machine, const char *pci_type)if (x86ms->pic ==ON_OFF_AUTO_ON || x86ms->pic ==ON_OFF_AUTO_AUTO ) { -pc_i8259_create (isa_bus, gsi_state->i8259_irq); +pc_i8259_create (OBJECT (machine), isa_bus, gsi_state->i8259_irq); }ioapic_init_gsi (gsi_state, phb);
hw/i386/pc_q35.c +1 -1
@@ -272,7 +272,7 @@ static void pc_q35_init(MachineState *machine) isa_bus =ISA_BUS (qdev_get_child_bus (lpc_dev,"isa.0" ));if (x86ms->pic ==ON_OFF_AUTO_ON || x86ms->pic ==ON_OFF_AUTO_AUTO ) { -pc_i8259_create (isa_bus, gsi_state->i8259_irq); +pc_i8259_create (OBJECT (machine), isa_bus, gsi_state->i8259_irq); }ioapic_init_gsi (gsi_state,OBJECT (phb));
hw/intc/apic_common.c +2 -1
@@ -282,7 +282,8 @@ static void apic_common_realize(DeviceState *dev, Error **errp)/* Note: We need at least 1M to map the VAPIC option ROM */ if (!vapic && s->vapic_control &VAPIC_ENABLE_MASK && current_machine->ram_size >=1024 *1024 ) { - vapic =sysbus_create_simple_orphan ("kvmvapic" ,-1 ,NULL ); + vapic =sysbus_create_simple (qdev_get_machine (),"kvmvapic" , +"kvmvapic" ,-1 ,NULL ); } s->vapic = vapic;if (apic_report_tpr_access && info->enable_tpr_reporting) {
hw/intc/exynos4210_gic.c +2 -2
@@ -60,11 +60,11 @@ static void exynos4210_gic_realize(DeviceState *dev, Error **errp)uint32_t n = s->num_cpu;uint32_t i; - s->gic =qdev_new_orphan ("arm_gic" ); + s->gic =qdev_new (obj,"gic" ,"arm_gic" );qdev_prop_set_uint32 (s->gic,"num-cpu" , s->num_cpu);qdev_prop_set_uint32 (s->gic,"num-irq" ,EXYNOS4210_GIC_NIRQ ); gicbusdev =SYS_BUS_DEVICE (s->gic); -sysbus_realize_and_unref (gicbusdev, &error_fatal); +sysbus_realize (gicbusdev, &error_fatal);/* Pass through outbound IRQ lines from the GIC */ sysbus_pass_irq (sbd, gicbusdev);
hw/intc/i8259.c +3 -3
@@ -401,7 +401,7 @@ static void pic_realize(DeviceState *dev, Error **errp) pc->parent_realize (dev, errp); } -qemu_irq *i8259_init (ISABus *bus,qemu_irq parent_irq_in) +qemu_irq *i8259_init (Object *parent,ISABus *bus,qemu_irq parent_irq_in) {qemu_irq *irq_set;DeviceState *dev;
@@ -410,7 +410,7 @@ qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq_in) irq_set =g_new0 (qemu_irq,ISA_NUM_IRQS ); - isadev =i8259_init_chip (TYPE_I8259 , bus, true); + isadev =i8259_init_chip (parent,TYPE_I8259 , bus, true); dev =DEVICE (isadev);qdev_connect_gpio_out (dev,0 , parent_irq_in);
@@ -420,7 +420,7 @@ qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq_in) isa_pic =PIC_COMMON (dev); - isadev =i8259_init_chip (TYPE_I8259 , bus, false); + isadev =i8259_init_chip (parent,TYPE_I8259 , bus, false); dev =DEVICE (isadev);qdev_connect_gpio_out (dev,0 , irq_set[2 ]);
hw/intc/i8259_common.c +4 -3
@@ -89,18 +89,19 @@ static void pic_common_realize(DeviceState *dev, Error **errp)qdev_set_legacy_instance_id (dev, s->iobase,1 ); } -ISADevice *i8259_init_chip (const char *name,ISABus *bus,bool master) +ISADevice *i8259_init_chip (Object *parent,const char *name,ISABus *bus, +bool master) {DeviceState *dev;ISADevice *isadev; - isadev =isa_new_orphan (name); + isadev =isa_new (parent,"i8259[*]" , name); dev =DEVICE (isadev);qdev_prop_set_uint32 (dev,"iobase" , master ?0x20 :0xa0 );qdev_prop_set_uint32 (dev,"elcr_addr" , master ?0x4d0 :0x4d1 );qdev_prop_set_uint8 (dev,"elcr_mask" , master ?0xf8 :0xde );qdev_prop_set_bit (dev,"master" , master); -isa_realize_and_unref (isadev, bus, &error_fatal); +qdev_realize (dev,BUS (bus), &error_fatal);return isadev; }
hw/intc/riscv_aclint.c +10 -6
@@ -363,13 +363,15 @@ static const TypeInfo riscv_aclint_mtimer_info = {/* * Create ACLINT MTIMER device. */ -DeviceState *riscv_aclint_mtimer_create (hwaddr addr,hwaddr size, +DeviceState *riscv_aclint_mtimer_create (Object *parent, +hwaddr addr,hwaddr size,uint32_t hartid_base,uint32_t num_harts,uint32_t timecmp_base,uint32_t time_base,uint32_t timebase_freq,bool provide_rdtime) {int i; -DeviceState *dev =qdev_new_orphan (TYPE_RISCV_ACLINT_MTIMER ); +DeviceState *dev =qdev_new (parent,"aclint-mtimer[*]" , +TYPE_RISCV_ACLINT_MTIMER );RISCVAclintMTimerState *s =RISCV_ACLINT_MTIMER (dev);assert (num_harts <=RISCV_ACLINT_MAX_HARTS );
@@ -383,7 +385,7 @@ DeviceState *riscv_aclint_mtimer_create(hwaddr addr, hwaddr size,qdev_prop_set_uint32 (dev,"time-base" , time_base);qdev_prop_set_uint32 (dev,"aperture-size" , size);qdev_prop_set_uint32 (dev,"timebase-freq" , timebase_freq); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 , addr);for (i =0 ; i < num_harts; i++) {
@@ -548,11 +550,13 @@ static const TypeInfo riscv_aclint_swi_info = {/* * Create ACLINT [M|S]SWI device. */ -DeviceState *riscv_aclint_swi_create (hwaddr addr,uint32_t hartid_base, +DeviceState *riscv_aclint_swi_create (Object *parent,hwaddr addr, +uint32_t hartid_base,uint32_t num_harts,bool sswi) {int i; -DeviceState *dev =qdev_new_orphan (TYPE_RISCV_ACLINT_SWI ); +DeviceState *dev =qdev_new (parent,"aclint-swi[*]" , +TYPE_RISCV_ACLINT_SWI );assert (num_harts <=RISCV_ACLINT_MAX_HARTS );assert (!(addr &0x3 ));
@@ -560,7 +564,7 @@ DeviceState *riscv_aclint_swi_create(hwaddr addr, uint32_t hartid_base,qdev_prop_set_uint32 (dev,"hartid-base" , hartid_base);qdev_prop_set_uint32 (dev,"num-harts" , num_harts);qdev_prop_set_uint32 (dev,"sswi" , sswi ? true : false); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 , addr);for (i =0 ; i < num_harts; i++) {
hw/intc/riscv_aplic.c +7 -6
@@ -1109,11 +1109,12 @@ void riscv_aplic_add_child(DeviceState *parent, DeviceState *child)/* * Create APLIC device. */ -DeviceState *riscv_aplic_create (hwaddr addr,hwaddr size, +DeviceState *riscv_aplic_create (Object *parent,hwaddr addr,hwaddr size,uint32_t hartid_base,uint32_t num_harts,uint32_t num_sources, -uint32_t iprio_bits,bool msimode,bool mmode,DeviceState *parent) +uint32_t iprio_bits,bool msimode,bool mmode, +DeviceState *aplic_parent) { -DeviceState *dev =qdev_new_orphan (TYPE_RISCV_APLIC ); +DeviceState *dev =qdev_new (parent,"aplic[*]" ,TYPE_RISCV_APLIC );uint32_t i;assert (num_harts <APLIC_MAX_IDC );
@@ -1130,11 +1131,11 @@ DeviceState *riscv_aplic_create(hwaddr addr, hwaddr size,qdev_prop_set_bit (dev,"msimode" , msimode);qdev_prop_set_bit (dev,"mmode" , mmode); -if (parent) { -riscv_aplic_add_child (parent, dev); +if (aplic_parent) { +riscv_aplic_add_child (aplic_parent, dev); } -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);if (riscv_use_emulated_aplic (msimode)) {sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 , addr);
hw/intc/riscv_imsic.c +4 -3
@@ -471,10 +471,11 @@ type_init(riscv_imsic_register_types)/* * Create IMSIC device. */ -DeviceState *riscv_imsic_create (hwaddr addr,uint32_t hartid,bool mmode, +DeviceState *riscv_imsic_create (Object *parent,hwaddr addr, +uint32_t hartid,bool mmode,uint32_t num_pages,uint32_t num_ids) { -DeviceState *dev =qdev_new_orphan (TYPE_RISCV_IMSIC ); +DeviceState *dev =qdev_new (parent,"imsic[*]" ,TYPE_RISCV_IMSIC );CPUState *cpu =cpu_by_arch_id (hartid);uint32_t i;
@@ -493,7 +494,7 @@ DeviceState *riscv_imsic_create(hwaddr addr, uint32_t hartid, bool mmode,qdev_prop_set_uint32 (dev,"num-pages" , num_pages);qdev_prop_set_uint32 (dev,"num-irqs" , num_ids +1 ); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 , addr);if (!kvm_irqchip_in_kernel ()) {
hw/intc/s390_flic.c +5 -7
@@ -62,15 +62,13 @@ void s390_flic_init(void)DeviceState *dev;if (kvm_enabled ()) { - dev =qdev_new_orphan (TYPE_KVM_S390_FLIC ); -object_property_add_child (qdev_get_machine (),TYPE_KVM_S390_FLIC , -OBJECT (dev)); + dev =qdev_new (qdev_get_machine (),TYPE_KVM_S390_FLIC , +TYPE_KVM_S390_FLIC ); }else { - dev =qdev_new_orphan (TYPE_QEMU_S390_FLIC ); -object_property_add_child (qdev_get_machine (),TYPE_QEMU_S390_FLIC , -OBJECT (dev)); + dev =qdev_new (qdev_get_machine (),TYPE_QEMU_S390_FLIC , +TYPE_QEMU_S390_FLIC ); } -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal); } static int qemu_s390_register_io_adapter(S390FLICState *fs, uint32_t id,
hw/intc/sifive_plic.c +4 -3
@@ -473,7 +473,8 @@ type_init(sifive_plic_register_types)/* * Create PLIC device. */ -DeviceState *sifive_plic_create(hwaddr addr, char *hart_config, +DeviceState *sifive_plic_create(Object *parent, hwaddr addr, + char *hart_config, uint32_t num_harts, uint32_t hartid_base, uint32_t num_sources, uint32_t num_priorities, uint32_t priority_base,
@@ -481,7 +482,7 @@ DeviceState *sifive_plic_create(hwaddr addr, char *hart_config, uint32_t enable_stride, uint32_t context_base, uint32_t context_stride, uint32_t aperture_size) { - DeviceState *dev = qdev_new_orphan(TYPE_SIFIVE_PLIC); + DeviceState *dev = qdev_new(parent, "plic[*]", TYPE_SIFIVE_PLIC);int i;SiFivePLICState *plic;
@@ -498,7 +499,7 @@ DeviceState *sifive_plic_create(hwaddr addr, char *hart_config,qdev_prop_set_uint32 (dev,"context-base" , context_base);qdev_prop_set_uint32 (dev,"context-stride" , context_stride);qdev_prop_set_uint32 (dev,"aperture-size" , aperture_size); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 , addr); plic =SIFIVE_PLIC (dev);
hw/isa/i82378.c +1 -1
@@ -94,7 +94,7 @@ static void i82378_realize(PCIDevice *pci, Error **errp)*/ /* 2 82C59 (irq) */ - s->isa_irqs_in =i8259_init (isabus, + s->isa_irqs_in =i8259_init (OBJECT (pci), isabus,qemu_allocate_irq (i82378_request_out0_irq, s,0 ));isa_bus_register_input_irqs (isabus, s->isa_irqs_in);
hw/isa/piix.c +1 -1
@@ -319,7 +319,7 @@ static void pci_piix_realize(PCIDevice *dev, const char *uhci_type,qemu_init_irq_child (OBJECT (dev),"i8259-irq" , &d->i8259_irq, piix_request_i8259_irq, d,0 ); - i8259 =i8259_init (isa_bus, &d->i8259_irq); + i8259 =i8259_init (OBJECT (dev), isa_bus, &d->i8259_irq);for (size_t i =0 ; i <ISA_NUM_IRQS ; i++) { d->isa_irqs_in[i] = i8259[i];
hw/isa/vt82c686.c +1 -1
@@ -730,7 +730,7 @@ static void via_isa_realize(PCIDevice *d, Error **errp)return ; } - s->isa_irqs_in =i8259_init (isa_bus, &s->i8259_irq); + s->isa_irqs_in =i8259_init (OBJECT (d), isa_bus, &s->i8259_irq);isa_bus_register_input_irqs (isa_bus, s->isa_irqs_in);i8254_pit_init (isa_bus,0x40 ,0 ,NULL );i8257_dma_init (OBJECT (d), isa_bus,0 );
hw/mips/jazz.c +1 -1
@@ -285,7 +285,7 @@ static void mips_jazz_init(MachineState *machine, isa_bus =isa_bus_new (NULL , isa_mem, isa_io, &error_abort);/* ISA devices */ - i8259 =i8259_init (isa_bus, env->irq[4 ]); + i8259 =i8259_init (OBJECT (machine), isa_bus, env->irq[4 ]);isa_bus_register_input_irqs (isa_bus, i8259);i8257_dma_init (OBJECT (rc4030), isa_bus,0 ); pit =i8254_pit_init (isa_bus,0x40 ,0 ,NULL );
hw/riscv/aia.c +7 -5
@@ -24,7 +24,8 @@ uint32_t imsic_num_bits(uint32_t count)return ret; } -DeviceState *riscv_create_aia(bool msimode, int aia_guests, +DeviceState *riscv_create_aia(Object *parent, + bool msimode, int aia_guests, uint32_t m_imsic_stride, uint16_t num_sources, const MemMapEntry *aplic_m,
@@ -48,7 +49,7 @@ DeviceState *riscv_create_aia(bool msimode, int aia_guests,/* Per-socket M-level IMSICs */ addr = imsic_m->base + socket * (1U <<IMSIC_MMIO_GROUP_MIN_SHIFT );for (i =0 ; i < hart_count; i++) { -riscv_imsic_create (addr + i * m_imsic_stride, +riscv_imsic_create (parent, addr + i * m_imsic_stride, base_hartid + i, true,1 , num_msis); }
@@ -58,7 +59,8 @@ DeviceState *riscv_create_aia(bool msimode, int aia_guests, guest_bits =imsic_num_bits (aia_guests +1 ); addr = imsic_s->base + socket * (1U <<IMSIC_MMIO_GROUP_MIN_SHIFT );for (i =0 ; i < hart_count; i++) { -riscv_imsic_create (addr + i *IMSIC_HART_SIZE (guest_bits), +riscv_imsic_create (parent, + addr + i *IMSIC_HART_SIZE (guest_bits), base_hartid + i, false,1 + aia_guests, num_msis); }
@@ -66,7 +68,7 @@ DeviceState *riscv_create_aia(bool msimode, int aia_guests,if (!kvm_enabled ()) {/* Per-socket M-level APLIC */ - aplic_m_dev = riscv_aplic_create(aplic_m->base + + aplic_m_dev = riscv_aplic_create(parent, aplic_m->base + socket * aplic_m->size, aplic_m->size, (msimode) ? 0 : base_hartid,
@@ -77,7 +79,7 @@ DeviceState *riscv_create_aia(bool msimode, int aia_guests, }/* Per-socket S-level APLIC */ - aplic_s_dev = riscv_aplic_create(aplic_s->base + + aplic_s_dev = riscv_aplic_create(parent, aplic_s->base + socket * aplic_s->size, aplic_s->size, (msimode) ? 0 : base_hartid,
hw/riscv/aia.h +2 -1
@@ -13,7 +13,8 @@uint32_t imsic_num_bits (uint32_t count); -DeviceState *riscv_create_aia(bool msimode, int aia_guests, +DeviceState *riscv_create_aia(Object *parent, + bool msimode, int aia_guests, uint32_t m_imsic_stride, uint16_t num_sources, const MemMapEntry *aplic_m,
hw/riscv/cps.c +5 -4
@@ -135,14 +135,15 @@ static void riscv_cps_realize(DeviceState *dev, Error **errp)for (i =0 ; i < num_of_clusters; i++) {uint64_t cm_base =GLOBAL_CM_BASE + (CM_SIZE * i);uint32_t hartid_base = i <<MHARTID_CLUSTER_SHIFT ; - s->aplic =riscv_aplic_create (cm_base +AIA_PLIC_M_OFFSET , + s->aplic =riscv_aplic_create (OBJECT (dev), + cm_base +AIA_PLIC_M_OFFSET ,AIA_PLIC_M_SIZE , hartid_base,/* hartid_base */ MAX_HARTS ,/* num_harts */ APLIC_NUM_SOURCES ,APLIC_NUM_PRIO_BITS , false, true,NULL ); - riscv_aplic_create(cm_base + AIA_PLIC_S_OFFSET, + riscv_aplic_create(OBJECT(dev), cm_base + AIA_PLIC_S_OFFSET, AIA_PLIC_S_SIZE, hartid_base, /* hartid_base */ MAX_HARTS, /* num_harts */
@@ -151,9 +152,9 @@ static void riscv_cps_realize(DeviceState *dev, Error **errp) false, false, s->aplic);/* PLIC changes msi_nonbroken to ture. We revert the change. */ msi_nonbroken = false; -riscv_aclint_swi_create (cm_base +AIA_CLINT_OFFSET , +riscv_aclint_swi_create (OBJECT (dev), cm_base +AIA_CLINT_OFFSET , hartid_base,MAX_HARTS , false); - riscv_aclint_mtimer_create(cm_base + AIA_CLINT_OFFSET + + riscv_aclint_mtimer_create(OBJECT(dev), cm_base + AIA_CLINT_OFFSET + RISCV_ACLINT_SWI_SIZE, RISCV_ACLINT_DEFAULT_MTIMER_SIZE, hartid_base,
hw/riscv/k230.c +7 -5
@@ -117,7 +117,8 @@ static void k230_soc_init(Object *obj) memmap[K230_DEV_BOOTROM].base); } -static DeviceState *k230_create_plic (int base_hartid,int hartid_count) +static DeviceState *k230_create_plic (Object *parent,int base_hartid, +int hartid_count) { g_autofree char *plic_hart_config = NULL;
@@ -125,7 +126,7 @@ static DeviceState *k230_create_plic(int base_hartid, int hartid_count) plic_hart_config =riscv_plic_hart_config_string (hartid_count);/* Per-socket PLIC */ - return sifive_plic_create(memmap[K230_DEV_PLIC].base, + return sifive_plic_create(parent, memmap[K230_DEV_PLIC].base, plic_hart_config, hartid_count, base_hartid, K230_PLIC_NUM_SOURCES, K230_PLIC_NUM_PRIORITIES,
@@ -174,12 +175,13 @@ static void k230_soc_realize(DeviceState *dev, Error **errp) &s->bootrom);/* PLIC */ - s->c908_plic =k230_create_plic (C908_CPU_HARTID , c908_cpus); + s->c908_plic =k230_create_plic (OBJECT (dev),C908_CPU_HARTID , c908_cpus);/* CLINT */ -riscv_aclint_swi_create (memmap[K230_DEV_CLINT ].base, +riscv_aclint_swi_create (OBJECT (dev), memmap[K230_DEV_CLINT ].base,C908_CPU_HARTID , c908_cpus, false); - riscv_aclint_mtimer_create(memmap[K230_DEV_CLINT].base + 0x4000, + riscv_aclint_mtimer_create(OBJECT(dev), + memmap[K230_DEV_CLINT].base + 0x4000, RISCV_ACLINT_DEFAULT_MTIMER_SIZE, C908_CPU_HARTID, c908_cpus, RISCV_ACLINT_DEFAULT_MTIMECMP,
hw/riscv/microchip_pfsoc.c +4 -3
@@ -250,9 +250,9 @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp) memmap[MICROCHIP_PFSOC_BUSERR_UNIT4].size);/* CLINT */ -riscv_aclint_swi_create (memmap[MICROCHIP_PFSOC_CLINT ].base, +riscv_aclint_swi_create (OBJECT (dev), memmap[MICROCHIP_PFSOC_CLINT ].base,0 , ms->smp.cpus, false); - riscv_aclint_mtimer_create( + riscv_aclint_mtimer_create(OBJECT(dev), memmap[MICROCHIP_PFSOC_CLINT].base + RISCV_ACLINT_SWI_SIZE, RISCV_ACLINT_DEFAULT_MTIMER_SIZE, 0, ms->smp.cpus, RISCV_ACLINT_DEFAULT_MTIMECMP, RISCV_ACLINT_DEFAULT_MTIME,
@@ -281,7 +281,8 @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp) plic_hart_config =riscv_plic_hart_config_string (ms->smp.cpus);/* PLIC */ - s->plic = sifive_plic_create(memmap[MICROCHIP_PFSOC_PLIC].base, + s->plic = sifive_plic_create(OBJECT(dev), + memmap[MICROCHIP_PFSOC_PLIC].base, plic_hart_config, ms->smp.cpus, 0, MICROCHIP_PFSOC_PLIC_NUM_SOURCES, MICROCHIP_PFSOC_PLIC_NUM_PRIORITIES,
hw/riscv/shakti_c.c +5 -3
@@ -115,7 +115,8 @@ static void shakti_c_soc_state_realize(DeviceState *dev, Error **errp)sysbus_realize (SYS_BUS_DEVICE (&sss->cpus), &error_abort); - sss->plic = sifive_plic_create(shakti_c_memmap[SHAKTI_C_PLIC].base, + sss->plic = sifive_plic_create(OBJECT(dev), + shakti_c_memmap[SHAKTI_C_PLIC].base, (char *)SHAKTI_C_PLIC_HART_CONFIG, ms->smp.cpus, 0, SHAKTI_C_PLIC_NUM_SOURCES, SHAKTI_C_PLIC_NUM_PRIORITIES,
@@ -127,9 +128,10 @@ static void shakti_c_soc_state_realize(DeviceState *dev, Error **errp)SHAKTI_C_PLIC_CONTEXT_STRIDE , shakti_c_memmap[SHAKTI_C_PLIC].size); -riscv_aclint_swi_create (shakti_c_memmap[SHAKTI_C_CLINT ].base, +riscv_aclint_swi_create (OBJECT (dev), shakti_c_memmap[SHAKTI_C_CLINT ].base,0 ,1 , false); - riscv_aclint_mtimer_create(shakti_c_memmap[SHAKTI_C_CLINT].base + + riscv_aclint_mtimer_create(OBJECT(dev), + shakti_c_memmap[SHAKTI_C_CLINT].base + RISCV_ACLINT_SWI_SIZE, RISCV_ACLINT_DEFAULT_MTIMER_SIZE, 0, 1, RISCV_ACLINT_DEFAULT_MTIMECMP, RISCV_ACLINT_DEFAULT_MTIME,
hw/riscv/sifive_e.c +4 -3
@@ -214,7 +214,7 @@ static void sifive_e_soc_realize(DeviceState *dev, Error **errp) memmap[SIFIVE_E_DEV_MROM].base, &s->mask_rom);/* MMIO */ - s->plic = sifive_plic_create(memmap[SIFIVE_E_DEV_PLIC].base, + s->plic = sifive_plic_create(OBJECT(dev), memmap[SIFIVE_E_DEV_PLIC].base, (char *)SIFIVE_E_PLIC_HART_CONFIG, ms->smp.cpus, 0, SIFIVE_E_PLIC_NUM_SOURCES, SIFIVE_E_PLIC_NUM_PRIORITIES,
@@ -225,9 +225,10 @@ static void sifive_e_soc_realize(DeviceState *dev, Error **errp)SIFIVE_E_PLIC_CONTEXT_BASE ,SIFIVE_E_PLIC_CONTEXT_STRIDE , memmap[SIFIVE_E_DEV_PLIC].size); -riscv_aclint_swi_create (memmap[SIFIVE_E_DEV_CLINT ].base, +riscv_aclint_swi_create (OBJECT (dev), memmap[SIFIVE_E_DEV_CLINT ].base,0 , ms->smp.cpus, false); - riscv_aclint_mtimer_create(memmap[SIFIVE_E_DEV_CLINT].base + + riscv_aclint_mtimer_create(OBJECT(dev), + memmap[SIFIVE_E_DEV_CLINT].base + RISCV_ACLINT_SWI_SIZE, RISCV_ACLINT_DEFAULT_MTIMER_SIZE, 0, ms->smp.cpus, RISCV_ACLINT_DEFAULT_MTIMECMP, RISCV_ACLINT_DEFAULT_MTIME,
hw/riscv/sifive_u.c +4 -3
@@ -771,7 +771,7 @@ static void sifive_u_soc_realize(DeviceState *dev, Error **errp) plic_hart_config =riscv_plic_hart_config_string (ms->smp.cpus);/* MMIO */ - s->plic = sifive_plic_create(memmap[SIFIVE_U_DEV_PLIC].base, + s->plic = sifive_plic_create(OBJECT(dev), memmap[SIFIVE_U_DEV_PLIC].base, plic_hart_config, ms->smp.cpus, 0, SIFIVE_U_PLIC_NUM_SOURCES, SIFIVE_U_PLIC_NUM_PRIORITIES,
@@ -787,9 +787,10 @@ static void sifive_u_soc_realize(DeviceState *dev, Error **errp) serial_hd(0), qdev_get_gpio_in(DEVICE(s->plic), SIFIVE_U_UART0_IRQ));sifive_uart_create (system_memory, memmap[SIFIVE_U_DEV_UART1 ].base,serial_hd (1 ),qdev_get_gpio_in (DEVICE (s->plic),SIFIVE_U_UART1_IRQ )); -riscv_aclint_swi_create (memmap[SIFIVE_U_DEV_CLINT ].base,0 , +riscv_aclint_swi_create (OBJECT (dev), memmap[SIFIVE_U_DEV_CLINT ].base,0 , ms->smp.cpus, false); - riscv_aclint_mtimer_create(memmap[SIFIVE_U_DEV_CLINT].base + + riscv_aclint_mtimer_create(OBJECT(dev), + memmap[SIFIVE_U_DEV_CLINT].base + RISCV_ACLINT_SWI_SIZE, RISCV_ACLINT_DEFAULT_MTIMER_SIZE, 0, ms->smp.cpus, RISCV_ACLINT_DEFAULT_MTIMECMP, RISCV_ACLINT_DEFAULT_MTIME,
hw/riscv/spike.c +2 -2
@@ -163,10 +163,10 @@ static void spike_board_init(MachineState *machine)sysbus_realize (SYS_BUS_DEVICE (&s->soc[i]), &error_fatal);/* Core Local Interruptor (timer and IPI) for each socket */ -riscv_aclint_swi_create ( +riscv_aclint_swi_create (OBJECT (machine), memmap[SPIKE_CLINT ].base + i * memmap[SPIKE_CLINT ].size, base_hartid, hart_count, false); - riscv_aclint_mtimer_create( + riscv_aclint_mtimer_create(OBJECT(machine), memmap[SPIKE_CLINT].base + i * memmap[SPIKE_CLINT].size + RISCV_ACLINT_SWI_SIZE, RISCV_ACLINT_DEFAULT_MTIMER_SIZE, base_hartid, hart_count,
hw/riscv/tt_atlantis.c +4 -2
@@ -494,7 +494,8 @@ static void tt_atlantis_machine_init(MachineState *machine) &error_abort);sysbus_realize (SYS_BUS_DEVICE (&s->soc), &error_fatal); - s->irqchip = riscv_create_aia(true, TT_IRQCHIP_GUESTS, + s->irqchip = riscv_create_aia(OBJECT(machine), + true, TT_IRQCHIP_GUESTS, TT_IRQCHIP_MIMSIC_STRIDE, TT_IRQCHIP_NUM_SOURCES, &s->memmap[TT_ATL_MAPLIC],
@@ -505,7 +506,8 @@ static void tt_atlantis_machine_init(MachineState *machine)TT_IRQCHIP_NUM_MSIS , TT_IRQCHIP_NUM_PRIO_BITS); - riscv_aclint_mtimer_create(s->memmap[TT_ATL_ACLINT].base, + riscv_aclint_mtimer_create(OBJECT(machine), + s->memmap[TT_ATL_ACLINT].base, TT_ACLINT_MTIME_SIZE, 0, hart_count, TT_ACLINT_MTIMECMP,
hw/riscv/virt.c +17 -10
@@ -1115,7 +1115,8 @@ static FWCfgState *create_fw_cfg(const MachineState *ms, hwaddr base)return fw_cfg; } -static DeviceState *virt_create_plic (const MemMapEntry *memmap,int socket, +static DeviceState *virt_create_plic (Object *parent, +const MemMapEntry *memmap,int socket,int base_hartid,int hart_count) { g_autofree char *plic_hart_config = NULL;
@@ -1124,7 +1125,7 @@ static DeviceState *virt_create_plic(const MemMapEntry *memmap, int socket, plic_hart_config =riscv_plic_hart_config_string (hart_count);/* Per-socket PLIC */ - return sifive_plic_create( + return sifive_plic_create(parent, memmap[VIRT_PLIC].base + socket * memmap[VIRT_PLIC].size, plic_hart_config, hart_count, base_hartid, VIRT_IRQCHIP_NUM_SOURCES,
@@ -1357,7 +1358,8 @@ static void virt_machine_init(MachineState *machine)if (virt_aclint_allowed () && s->have_aclint) {if (s->aia_type ==VIRT_AIA_TYPE_APLIC_IMSIC ) {/* Per-socket ACLINT MTIMER */ - riscv_aclint_mtimer_create(s->memmap[VIRT_CLINT].base + + riscv_aclint_mtimer_create(OBJECT(machine), + s->memmap[VIRT_CLINT].base + i * RISCV_ACLINT_DEFAULT_MTIMER_SIZE, RISCV_ACLINT_DEFAULT_MTIMER_SIZE, base_hartid, hart_count,
@@ -1366,10 +1368,12 @@ static void virt_machine_init(MachineState *machine) RISCV_ACLINT_DEFAULT_TIMEBASE_FREQ, true); }else {/* Per-socket ACLINT MSWI, MTIMER, and SSWI */ -riscv_aclint_swi_create (s->memmap[VIRT_CLINT ].base + +riscv_aclint_swi_create (OBJECT (machine), + s->memmap[VIRT_CLINT ].base + i * s->memmap[VIRT_CLINT ].size, base_hartid, hart_count, false); - riscv_aclint_mtimer_create(s->memmap[VIRT_CLINT].base + + riscv_aclint_mtimer_create(OBJECT(machine), + s->memmap[VIRT_CLINT].base + i * s->memmap[VIRT_CLINT].size + RISCV_ACLINT_SWI_SIZE, RISCV_ACLINT_DEFAULT_MTIMER_SIZE,
@@ -1377,16 +1381,18 @@ static void virt_machine_init(MachineState *machine)RISCV_ACLINT_DEFAULT_MTIMECMP ,RISCV_ACLINT_DEFAULT_MTIME , RISCV_ACLINT_DEFAULT_TIMEBASE_FREQ, true); -riscv_aclint_swi_create (s->memmap[VIRT_ACLINT_SSWI ].base + +riscv_aclint_swi_create (OBJECT (machine), + s->memmap[VIRT_ACLINT_SSWI ].base + i * s->memmap[VIRT_ACLINT_SSWI ].size, base_hartid, hart_count, true); } }else if (tcg_enabled ()) {/* Per-socket SiFive CLINT */ -riscv_aclint_swi_create ( +riscv_aclint_swi_create (OBJECT (machine), s->memmap[VIRT_CLINT ].base + i * s->memmap[VIRT_CLINT ].size, base_hartid, hart_count, false); - riscv_aclint_mtimer_create(s->memmap[VIRT_CLINT].base + + riscv_aclint_mtimer_create(OBJECT(machine), + s->memmap[VIRT_CLINT].base + i * s->memmap[VIRT_CLINT].size + RISCV_ACLINT_SWI_SIZE, RISCV_ACLINT_DEFAULT_MTIMER_SIZE, base_hartid, hart_count, RISCV_ACLINT_DEFAULT_MTIMECMP, RISCV_ACLINT_DEFAULT_MTIME,
@@ -1395,10 +1401,11 @@ static void virt_machine_init(MachineState *machine)/* Per-socket interrupt controller */ if (s->aia_type ==VIRT_AIA_TYPE_NONE ) { - s->irqchip[i] =virt_create_plic (s->memmap, i, + s->irqchip[i] =virt_create_plic (OBJECT (machine), s->memmap, i, base_hartid, hart_count); }else { - s->irqchip[i] = riscv_create_aia(s->aia_type == VIRT_AIA_TYPE_APLIC_IMSIC, + s->irqchip[i] = riscv_create_aia(OBJECT(machine), + s->aia_type == VIRT_AIA_TYPE_APLIC_IMSIC, s->aia_guests, IMSIC_HART_SIZE(0), s->num_sources,
hw/riscv/xiangshan_kmh.c +10 -8
@@ -55,7 +55,8 @@ static const MemMapEntry xiangshan_kmh_memmap[] = { [XIANGSHAN_KMH_DRAM] = { 0x80000000, 0x0 }, }; -static DeviceState *xiangshan_kmh_create_aia (uint32_t num_harts) +static DeviceState *xiangshan_kmh_create_aia (Object *parent, +uint32_t num_harts) {int i;const MemMapEntry *memmap = xiangshan_kmh_memmap;
@@ -65,27 +66,27 @@ static DeviceState *xiangshan_kmh_create_aia(uint32_t num_harts)/* M-level IMSICs */ addr = memmap[XIANGSHAN_KMH_IMSIC_M ].base;for (i =0 ; i < num_harts; i++) { -riscv_imsic_create (addr + i *IMSIC_HART_SIZE (0 ), i, true, +riscv_imsic_create (parent, addr + i *IMSIC_HART_SIZE (0 ), i, true,1 ,XIANGSHAN_KMH_IMSIC_NUM_IDS ); }/* S-level IMSICs */ addr = memmap[XIANGSHAN_KMH_IMSIC_S ].base;for (i =0 ; i < num_harts; i++) { -riscv_imsic_create (addr + +riscv_imsic_create (parent, addr + i *IMSIC_HART_SIZE (XIANGSHAN_KMH_IMSIC_GUEST_BITS ), i, false,1 +XIANGSHAN_KMH_IMSIC_GUEST_BITS ,XIANGSHAN_KMH_IMSIC_NUM_IDS ); }/* M-level APLIC */ - aplic_m =riscv_aplic_create (memmap[XIANGSHAN_KMH_APLIC_M ].base, + aplic_m =riscv_aplic_create (parent, memmap[XIANGSHAN_KMH_APLIC_M ].base, memmap[XIANGSHAN_KMH_APLIC_M ].size,0 ,0 ,XIANGSHAN_KMH_APLIC_NUM_SOURCES ,1 , true, true,NULL );/* S-level APLIC */ -riscv_aplic_create (memmap[XIANGSHAN_KMH_APLIC_S ].base, +riscv_aplic_create (parent, memmap[XIANGSHAN_KMH_APLIC_S ].base, memmap[XIANGSHAN_KMH_APLIC_S ].size,0 ,0 ,XIANGSHAN_KMH_APLIC_NUM_SOURCES ,1 , true, false, aplic_m);
@@ -108,7 +109,7 @@ static void xiangshan_kmh_soc_realize(DeviceState *dev, Error **errp)sysbus_realize (SYS_BUS_DEVICE (&s->cpus), &error_fatal);/* AIA */ - s->irqchip =xiangshan_kmh_create_aia (num_harts); + s->irqchip =xiangshan_kmh_create_aia (OBJECT (dev), num_harts);/* UART */ serial_mm_init(system_memory, memmap[XIANGSHAN_KMH_UART0].base, 2,
@@ -116,9 +117,10 @@ static void xiangshan_kmh_soc_realize(DeviceState *dev, Error **errp) 115200, serial_hd(0), DEVICE_LITTLE_ENDIAN);/* CLINT */ -riscv_aclint_swi_create (memmap[XIANGSHAN_KMH_CLINT ].base, +riscv_aclint_swi_create (OBJECT (dev), memmap[XIANGSHAN_KMH_CLINT ].base,0 , num_harts, false); - riscv_aclint_mtimer_create(memmap[XIANGSHAN_KMH_CLINT].base + + riscv_aclint_mtimer_create(OBJECT(dev), + memmap[XIANGSHAN_KMH_CLINT].base + RISCV_ACLINT_SWI_SIZE, RISCV_ACLINT_DEFAULT_MTIMER_SIZE, 0, num_harts, RISCV_ACLINT_DEFAULT_MTIMECMP,
include/hw/i386/pc.h +1 -1
@@ -191,7 +191,7 @@ void pc_basic_device_init(struct PCMachineState *pcms, uint32_t hpet_irqs);void pc_nic_init (PCMachineClass *pcmc,ISABus *isa_bus,PCIBus *pci_bus); -void pc_i8259_create (ISABus *isa_bus,qemu_irq *i8259_irqs); +void pc_i8259_create (Object *parent,ISABus *isa_bus,qemu_irq *i8259_irqs);/* port92.c */ #define PORT92_A20_LINE "a20"
include/hw/intc/i8259.h +2 -2
@@ -14,8 +14,8 @@ extern PICCommonState *isa_pic;* connect its output to @parent_irq_in, * return an (allocated) array of 16 input IRQs. */ -qemu_irq *i8259_init (ISABus *bus,qemu_irq parent_irq_in); -qemu_irq *kvm_i8259_init (ISABus *bus); +qemu_irq *i8259_init (Object *parent,ISABus *bus,qemu_irq parent_irq_in); +qemu_irq *kvm_i8259_init (Object *parent,ISABus *bus);int pic_get_output (PICCommonState *s);int pic_read_irq (PICCommonState *s);
include/hw/intc/riscv_aclint.h +4 -2
@@ -46,7 +46,8 @@ typedef struct RISCVAclintMTimerState {qemu_irq *timer_irqs; } RISCVAclintMTimerState; -DeviceState *riscv_aclint_mtimer_create (hwaddr addr,hwaddr size, +DeviceState *riscv_aclint_mtimer_create (Object *parent, +hwaddr addr,hwaddr size,uint32_t hartid_base,uint32_t num_harts,uint32_t timecmp_base,uint32_t time_base,uint32_t timebase_freq,bool provide_rdtime);
@@ -68,7 +69,8 @@ typedef struct RISCVAclintSwiState {qemu_irq *soft_irqs; } RISCVAclintSwiState; -DeviceState *riscv_aclint_swi_create (hwaddr addr,uint32_t hartid_base, +DeviceState *riscv_aclint_swi_create (Object *parent,hwaddr addr, +uint32_t hartid_base,uint32_t num_harts,bool sswi);enum {
include/hw/intc/riscv_aplic.h +3 -2
@@ -80,8 +80,9 @@ bool riscv_is_kvm_aia_aplic_imsic(bool msimode);bool riscv_use_emulated_aplic (bool msimode);void riscv_aplic_set_kvm_msicfgaddr (RISCVAPLICState *aplic,hwaddr addr); -DeviceState *riscv_aplic_create (hwaddr addr,hwaddr size, +DeviceState *riscv_aplic_create (Object *parent,hwaddr addr,hwaddr size,uint32_t hartid_base,uint32_t num_harts,uint32_t num_sources, -uint32_t iprio_bits,bool msimode,bool mmode,DeviceState *parent); +uint32_t iprio_bits,bool msimode,bool mmode, +DeviceState *aplic_parent);#endif
include/hw/intc/riscv_imsic.h +2 -1
@@ -62,7 +62,8 @@ struct RISCVIMSICState { uint32_t num_irqs; }; -DeviceState *riscv_imsic_create (hwaddr addr,uint32_t hartid,bool mmode, +DeviceState *riscv_imsic_create (Object *parent,hwaddr addr, +uint32_t hartid,bool mmode,uint32_t num_pages,uint32_t num_ids);#endif
include/hw/intc/sifive_plic.h +2 -1
@@ -76,7 +76,8 @@ struct SiFivePLICState {qemu_irq *s_external_irqs; }; -DeviceState *sifive_plic_create(hwaddr addr, char *hart_config, +DeviceState *sifive_plic_create(Object *parent, hwaddr addr, + char *hart_config, uint32_t num_harts, uint32_t hartid_base, uint32_t num_sources, uint32_t num_priorities, uint32_t priority_base,
include/hw/isa/i8259_internal.h +2 -1
@@ -71,7 +71,8 @@ struct PICCommonState { };void pic_reset_common (PICCommonState *s); -ISADevice *i8259_init_chip (const char *name,ISABus *bus,bool master); +ISADevice *i8259_init_chip (Object *parent,const char *name,ISABus *bus, +bool master);void pic_stat_update_irq (int irq,int level);#endif /* QEMU_I8259_INTERNAL_H */
Signature · 1 line
2.47.1