hw: Strengthen SysBus & QBus API
v4 cover hw: Strengthen SysBus & QBus API
Missing review: 4, 12
Since v1:
- Addressed Zoltan review comments
- Addressed Mark suggestion
- Added R-b tags
Hi,
This series ensure following is called *before* a
device is realized:
- qbus_new()
- sysbus_init_mmio()
- qdev_init_gpio_in_named_with_opaque()
and these are called *after* it is:
- sysbus_mmio_map()
- sysbus_connect_irq(),
- qdev_connect_gpio_out()
- qdev_connect_gpio_out_named()
Patches from v2 enforcing these checks will be posted in a separate series.
Philippe Mathieu-Daudé (12):
hw/ide/ich9: Use AHCIPCIState typedef
hw/rx/rx62n: Reduce inclusion of 'qemu/units.h' hw/rx/rx62n: Only call qdev_get_gpio_in() when necessary hw/i386/q35: Realize LPC PCI function before accessing it hw/ppc/prep: Realize ISA bridge before accessing it hw/misc/macio: Realize IDE controller before accessing it hw/sh4/r2d: Realize IDE controller before accessing it hw/sparc/sun4m: Realize DMA controller before accessing it hw/sparc/leon3: Realize GRLIB IRQ controller before accessing it hw/sparc/leon3: Pass DeviceState opaque argument to leon3_set_pil_in() hw/sparc/leon3: Initialize GPIO before realizing CPU devices hw/sparc64/cpu: Initialize GPIO before realizing CPU devices
include/hw/rx/rx62n.h | 2 -- hw/i386/pc_q35.c | 6 +++--- hw/ide/ich.c | 6 +++--- hw/misc/macio/macio.c | 9 ++++++--- hw/ppc/prep.c | 2 +- hw/rx/rx-gdbsim.c | 1 + hw/rx/rx62n.c | 17 +++++++++-------- hw/sh4/r2d.c | 2 +- hw/sparc/leon3.c | 17 ++++++++--------- hw/sparc/sun4m.c | 7 +++++-- hw/sparc64/sparc64.c | 4 +++- 11 files changed, 40 insertions(+), 33 deletions(-)
Signature · 1 line
2.41.0
PATCH v4 1/12 hw/ide/ich9: Use AHCIPCIState typedef
QEMU coding style recommend using structure typedefs:
https://www.qemu.org/docs/master/devel/style.html#typedefs
--- hw/ide/ich.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/ide/ich.c +3 -3
@@ -99,14 +99,14 @@ static void pci_ich9_reset(DeviceState *dev)static void pci_ich9_ahci_init (Object *obj) { -struct AHCIPCIState *d =ICH9_AHCI (obj); +AHCIPCIState *d =ICH9_AHCI (obj);ahci_init (&d->ahci,DEVICE (obj)); }static void pci_ich9_ahci_realize (PCIDevice *dev,Error **errp) { -struct AHCIPCIState *d; +AHCIPCIState *d;int sata_cap_offset;uint8_t *sata_cap; d =ICH9_AHCI (dev);
@@ -154,7 +154,7 @@ static void pci_ich9_ahci_realize(PCIDevice *dev, Error **errp)static void pci_ich9_uninit (PCIDevice *dev) { -struct AHCIPCIState *d; +AHCIPCIState *d; d =ICH9_AHCI (dev);msi_uninit (dev);
Signature · 1 line
2.41.0
PATCH v4 4/12 hw/i386/q35: Realize LPC PCI function before accessing it
In reply to Philippe Mathieu-DaudéWe should not wire IRQs on unrealized device.
--- hw/i386/pc_q35.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/i386/pc_q35.c +3 -3
@@ -248,13 +248,13 @@ static void pc_q35_init(MachineState *machine)/* create ISA bus */ lpc =pci_new_multifunction (PCI_DEVFN (ICH9_LPC_DEV ,ICH9_LPC_FUNC ),TYPE_ICH9_LPC_DEVICE ); -qdev_prop_set_bit (DEVICE (lpc),"smm-enabled" , -x86_machine_is_smm_enabled (x86ms)); lpc_dev =DEVICE (lpc); +qdev_prop_set_bit (lpc_dev,"smm-enabled" , +x86_machine_is_smm_enabled (x86ms)); +pci_realize_and_unref (lpc, host_bus, &error_fatal);for (i =0 ; i <IOAPIC_NUM_PINS ; i++) {qdev_connect_gpio_out_named (lpc_dev,ICH9_GPIO_GSI , i, x86ms->gsi[i]); } -pci_realize_and_unref (lpc, host_bus, &error_fatal); rtc_state =ISA_DEVICE (object_resolve_path_component (OBJECT (lpc),"rtc" ));
Signature · 1 line
2.41.0
PATCH v4 6/12 hw/misc/macio: Realize IDE controller before accessing it
In reply to Philippe Mathieu-DaudéWe should not wire IRQs on unrealized device.
--- hw/misc/macio/macio.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
hw/misc/macio/macio.c +6 -3
@@ -123,14 +123,17 @@ static bool macio_realize_ide(MacIOState *s, MACIOIDEState *ide, {SysBusDevice *sbd =SYS_BUS_DEVICE (ide); -sysbus_connect_irq (sbd,0 , irq0); -sysbus_connect_irq (sbd,1 , irq1);qdev_prop_set_uint32 (DEVICE (ide),"channel" , dmaid);object_property_set_link (OBJECT (ide),"dbdma" ,OBJECT (&s->dbdma), &error_abort);macio_ide_register_dma (ide); +if (!qdev_realize (DEVICE (ide),BUS (&s->macio_bus), errp)) { +return false; + } +sysbus_connect_irq (sbd,0 , irq0); +sysbus_connect_irq (sbd,1 , irq1); -return qdev_realize (DEVICE (ide),BUS (&s->macio_bus), errp); +return true; }static void macio_oldworld_realize (PCIDevice *d,Error **errp)
Signature · 1 line
2.41.0
PATCH v4 2/12 hw/rx/rx62n: Reduce inclusion of 'qemu/units.h'
In reply to Philippe Mathieu-Daudé"qemu/units.h" is not used in the "hw/rx/rx62n.h" header, include it in the source where it is.
--- include/hw/rx/rx62n.h | 1 - hw/rx/rx-gdbsim.c | 1 + hw/rx/rx62n.c | 1 + 3 files changed, 2 insertions(+), 1 deletion(-)
include/hw/rx/rx62n.h +0 -1
@@ -29,7 +29,6 @@#include "hw/timer/renesas_tmr.h" #include "hw/timer/renesas_cmt.h" #include "hw/char/renesas_sci.h" -#include "qemu/units.h" #include "qom/object.h" #define TYPE_RX62N_MCU "rx62n-mcu"
hw/rx/rx-gdbsim.c +1 -0
@@ -20,6 +20,7 @@#include "qemu/cutils.h" #include "qemu/error-report.h" #include "qemu/guest-random.h" +#include "qemu/units.h" #include "qapi/error.h" #include "hw/loader.h" #include "hw/rx/rx62n.h"
hw/rx/rx62n.c +1 -0
@@ -23,6 +23,7 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/error-report.h" +#include "qemu/units.h" #include "hw/rx/rx62n.h" #include "hw/loader.h" #include "hw/sysbus.h"
Signature · 1 line
2.41.0
PATCH v4 5/12 hw/ppc/prep: Realize ISA bridge before accessing it
In reply to Philippe Mathieu-DaudéWe should not wire IRQs on unrealized device.
--- hw/ppc/prep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/prep.c +1 -1
@@ -278,9 +278,9 @@ static void ibm_40p_init(MachineState *machine)/* PCI -> ISA bridge */ i82378_dev =DEVICE (pci_new (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)); -qdev_realize_and_unref (i82378_dev,BUS (pci_bus), &error_fatal);sysbus_connect_irq (pcihost,0 ,qdev_get_gpio_in (i82378_dev,15 )); isa_bus =ISA_BUS (qdev_get_child_bus (i82378_dev,"isa.0" ));
Signature · 1 line
2.41.0
PATCH v4 10/12 hw/sparc/leon3: Pass DeviceState opaque argument to leon3_set_pil_in()
In reply to Philippe Mathieu-DaudéBy passing a DeviceState context to a QDev IRQ handler, we can simplify and use qdev_init_gpio_in_named() instead of qdev_init_gpio_in_named_with_opaque().
--- hw/sparc/leon3.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
hw/sparc/leon3.c +4 -6
@@ -175,9 +175,10 @@ static void leon3_irq_ack(CPUSPARCState *env, int intno)*/ static void leon3_set_pil_in (void *opaque,int n,int level) { -CPUSPARCState *env = opaque; +DeviceState *cpu = opaque; +CPUState *cs =CPU (cpu); +CPUSPARCState *env =cpu_env (cs);uint32_t pil_in = level; -CPUState *cs;assert (env !=NULL );
@@ -193,7 +194,6 @@ static void leon3_set_pil_in(void *opaque, int n, int level) env->interrupt_index =TT_EXTINT | i;if (old_interrupt != env->interrupt_index) { - cs =env_cpu (env);trace_leon3_set_irq (i);cpu_interrupt (cs,CPU_INTERRUPT_HARD ); }
@@ -201,7 +201,6 @@ static void leon3_set_pil_in(void *opaque, int n, int level) } } }else if (!env->pil_in && (env->interrupt_index & ~15 ) ==TT_EXTINT ) { - cs =env_cpu (env);trace_leon3_reset_irq (env->interrupt_index &15 ); env->interrupt_index =0 ;cpu_reset_interrupt (cs,CPU_INTERRUPT_HARD );
@@ -261,8 +260,7 @@ static void leon3_generic_hw_init(MachineState *machine)/* Allocate IRQ manager */ irqmpdev =qdev_new (TYPE_GRLIB_IRQMP ); -qdev_init_gpio_in_named_with_opaque (DEVICE (cpu), leon3_set_pil_in, - env,"pil" ,1 ); +qdev_init_gpio_in_named (DEVICE (cpu), leon3_set_pil_in,"pil" ,1 );sysbus_realize_and_unref (SYS_BUS_DEVICE (irqmpdev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (irqmpdev),0 ,LEON3_IRQMP_OFFSET ); qdev_connect_gpio_out_named(irqmpdev, "grlib-irq", 0,
Signature · 1 line
2.41.0
PATCH v4 12/12 hw/sparc64/cpu: Initialize GPIO before realizing CPU devices
In reply to Philippe Mathieu-DaudéInline cpu_create() in order to callqdev_init_gpio_in_named_with_opaque()
before the CPU is realized.
--- hw/sparc64/sparc64.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/sparc64/sparc64.c +3 -1
@@ -24,6 +24,7 @@#include "qemu/osdep.h" +#include "qapi/error.h" #include "cpu.h" #include "hw/boards.h" #include "hw/sparc/sparc64.h"
@@ -271,9 +272,10 @@ SPARCCPU *sparc64_cpu_devinit(const char *cpu_type, uint64_t prom_addr)uint32_t stick_frequency =100 *1000000 ;uint32_t hstick_frequency =100 *1000000 ; - cpu =SPARC_CPU (cpu_create (cpu_type)); + cpu =SPARC_CPU (object_new (cpu_type));qdev_init_gpio_in_named (DEVICE (cpu), sparc64_cpu_set_ivec_irq,"ivec-irq" ,IVEC_MAX ); +qdev_realize (DEVICE (cpu),NULL , &error_fatal); env = &cpu->env; env->tick = cpu_timer_create("tick", cpu, tick_irq,
Signature · 1 line
2.41.0
PATCH v4 3/12 hw/rx/rx62n: Only call qdev_get_gpio_in() when necessary
In reply to Philippe Mathieu-DaudéInstead of filling an array of all the possible IRQs, only call qdev_get_gpio_in() when an IRQ is used. Remove the array from RX62NState. Doing so we avoid calling qdev_get_gpio_in() on an unrealized device.
--- include/hw/rx/rx62n.h | 1 - hw/rx/rx62n.c | 16 ++++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-)
include/hw/rx/rx62n.h +0 -1
@@ -67,7 +67,6 @@ struct RX62NState {MemoryRegion iomem2;MemoryRegion iomem3;MemoryRegion c_flash; -qemu_irq irq[NR_IRQS ];/* Input Clock (XTAL) frequency */ uint32_t xtal_freq_hz;
hw/rx/rx62n.c +8 -8
@@ -148,14 +148,11 @@ static void register_icu(RX62NState *s)qlist_append_int (trigger_level, levelirq[i]); }qdev_prop_set_array (DEVICE (icu),"trigger-level" , trigger_level); - -for (i =0 ; i <NR_IRQS ; i++) { - s->irq[i] =qdev_get_gpio_in (DEVICE (icu), i); - }sysbus_realize (icu, &error_abort); +sysbus_connect_irq (icu,0 ,qdev_get_gpio_in (DEVICE (&s->cpu),RX_CPU_IRQ ));sysbus_connect_irq (icu,1 ,qdev_get_gpio_in (DEVICE (&s->cpu),RX_CPU_FIR )); -sysbus_connect_irq (icu,2 , s->irq[SWI ]); +sysbus_connect_irq (icu,2 ,qdev_get_gpio_in (DEVICE (&s->icu),SWI ));sysbus_mmio_map (icu,0 ,RX62N_ICU_BASE ); }
@@ -172,7 +169,8 @@ static void register_tmr(RX62NState *s, int unit) irqbase =RX62N_TMR_IRQ +TMR_NR_IRQ * unit;for (i =0 ; i <TMR_NR_IRQ ; i++) { -sysbus_connect_irq (tmr, i, s->irq[irqbase + i]); +sysbus_connect_irq (tmr, i, +qdev_get_gpio_in (DEVICE (&s->icu), irqbase + i)); }sysbus_mmio_map (tmr,0 ,RX62N_TMR_BASE + unit *0x10 ); }
@@ -190,7 +188,8 @@ static void register_cmt(RX62NState *s, int unit) irqbase =RX62N_CMT_IRQ +CMT_NR_IRQ * unit;for (i =0 ; i <CMT_NR_IRQ ; i++) { -sysbus_connect_irq (cmt, i, s->irq[irqbase + i]); +sysbus_connect_irq (cmt, i, +qdev_get_gpio_in (DEVICE (&s->icu), irqbase + i)); }sysbus_mmio_map (cmt,0 ,RX62N_CMT_BASE + unit *0x10 ); }
@@ -209,7 +208,8 @@ static void register_sci(RX62NState *s, int unit) irqbase =RX62N_SCI_IRQ +SCI_NR_IRQ * unit;for (i =0 ; i <SCI_NR_IRQ ; i++) { -sysbus_connect_irq (sci, i, s->irq[irqbase + i]); +sysbus_connect_irq (sci, i, +qdev_get_gpio_in (DEVICE (&s->icu), irqbase + i)); }sysbus_mmio_map (sci,0 ,RX62N_SCI_BASE + unit *0x08 ); }
Signature · 1 line
2.41.0
PATCH v4 7/12 hw/sh4/r2d: Realize IDE controller before accessing it
In reply to Philippe Mathieu-DaudéWe should not wire IRQs on unrealized device.
--- hw/sh4/r2d.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/sh4/r2d.c +1 -1
@@ -285,9 +285,9 @@ static void r2d_init(MachineState *machine) dinfo =drive_get (IF_IDE ,0 ,0 ); dev =qdev_new ("mmio-ide" ); busdev =SYS_BUS_DEVICE (dev); -sysbus_connect_irq (busdev,0 , irq[CF_IDE ]);qdev_prop_set_uint32 (dev,"shift" ,1 );sysbus_realize_and_unref (busdev, &error_fatal); +sysbus_connect_irq (busdev,0 , irq[CF_IDE ]);sysbus_mmio_map (busdev,0 ,0x14001000 );sysbus_mmio_map (busdev,1 ,0x1400080c );mmio_ide_init_drives (dev, dinfo,NULL );
Signature · 1 line
2.41.0
PATCH v4 8/12 hw/sparc/sun4m: Realize DMA controller before accessing it
In reply to Philippe Mathieu-DaudéWe should not wire IRQs on unrealized device.
--- hw/sparc/sun4m.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
hw/sparc/sun4m.c +5 -2
@@ -312,13 +312,11 @@ static void *sparc32_dma_init(hwaddr dma_base, dma =qdev_new (TYPE_SPARC32_DMA ); espdma =SPARC32_ESPDMA_DEVICE (object_resolve_path_component (OBJECT (dma),"espdma" )); -sysbus_connect_irq (SYS_BUS_DEVICE (espdma),0 , espdma_irq); esp =SYSBUS_ESP (object_resolve_path_component (OBJECT (espdma),"esp" )); ledma =SPARC32_LEDMA_DEVICE (object_resolve_path_component (OBJECT (dma),"ledma" )); -sysbus_connect_irq (SYS_BUS_DEVICE (ledma),0 , ledma_irq); lance =SYSBUS_PCNET (object_resolve_path_component (OBJECT (ledma),"lance" ));
@@ -332,6 +330,11 @@ static void *sparc32_dma_init(hwaddr dma_base, }sysbus_realize_and_unref (SYS_BUS_DEVICE (dma), &error_fatal); + +sysbus_connect_irq (SYS_BUS_DEVICE (espdma),0 , espdma_irq); + +sysbus_connect_irq (SYS_BUS_DEVICE (ledma),0 , ledma_irq); +sysbus_mmio_map (SYS_BUS_DEVICE (dma),0 , dma_base);sysbus_mmio_map (SYS_BUS_DEVICE (esp),0 , esp_base);
Signature · 1 line
2.41.0
PATCH v4 9/12 hw/sparc/leon3: Realize GRLIB IRQ controller before accessing it
In reply to Philippe Mathieu-DaudéWe should not wire IRQs on unrealized device.
--- hw/sparc/leon3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/sparc/leon3.c +2 -2
@@ -263,10 +263,10 @@ static void leon3_generic_hw_init(MachineState *machine) irqmpdev =qdev_new (TYPE_GRLIB_IRQMP );qdev_init_gpio_in_named_with_opaque (DEVICE (cpu), leon3_set_pil_in, env,"pil" ,1 ); -qdev_connect_gpio_out_named (irqmpdev,"grlib-irq" ,0 , -qdev_get_gpio_in_named (DEVICE (cpu),"pil" ,0 ));sysbus_realize_and_unref (SYS_BUS_DEVICE (irqmpdev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (irqmpdev),0 ,LEON3_IRQMP_OFFSET ); +qdev_connect_gpio_out_named (irqmpdev,"grlib-irq" ,0 , +qdev_get_gpio_in_named (DEVICE (cpu),"pil" ,0 )); env->irq_manager = irqmpdev; env->qemu_irq_ack = leon3_irq_manager; grlib_apb_pnp_add_entry(apb_pnp, LEON3_IRQMP_OFFSET, 0xFFF,
Signature · 1 line
2.41.0
PATCH v4 11/12 hw/sparc/leon3: Initialize GPIO before realizing CPU devices
In reply to Philippe Mathieu-DaudéInline cpu_create() in order to callqdev_init_gpio_in_named_with_opaque()
before the CPU is realized.
--- hw/sparc/leon3.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
hw/sparc/leon3.c +3 -2
@@ -233,7 +233,9 @@ static void leon3_generic_hw_init(MachineState *machine)APBPnp *apb_pnp;/* Init CPU */ - cpu =SPARC_CPU (cpu_create (machine->cpu_type)); + cpu =SPARC_CPU (object_new (machine->cpu_type)); +qdev_init_gpio_in_named (DEVICE (cpu), leon3_set_pil_in,"pil" ,1 ); +qdev_realize (DEVICE (cpu),NULL , &error_fatal); env = &cpu->env;cpu_sparc_set_id (env,0 );
@@ -260,7 +262,6 @@ static void leon3_generic_hw_init(MachineState *machine)/* Allocate IRQ manager */ irqmpdev =qdev_new (TYPE_GRLIB_IRQMP ); -qdev_init_gpio_in_named (DEVICE (cpu), leon3_set_pil_in,"pil" ,1 );sysbus_realize_and_unref (SYS_BUS_DEVICE (irqmpdev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (irqmpdev),0 ,LEON3_IRQMP_OFFSET ); qdev_connect_gpio_out_named(irqmpdev, "grlib-irq", 0,
Signature · 1 line
2.41.0
Re: [PATCH v4 04/12] hw/i386/q35: Realize LPC PCI function before accessing it
In reply to Philippe Mathieu-DaudéQuoted 17 lines · Philippe Mathieu-Daudé
We should not wire IRQs on unrealized device.
Signed-off-by Philippe Mathieu-Daudé <[email protected]> > ---hw/i386/pc_q35.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)hw/i386/pc_q35.c +0
-2@@ -248,13 +248,13 @@ static void pc_q35_init(MachineState *machine)/* create ISA bus */ lpc =pci_new_multifunction (PCI_DEVFN (ICH9_LPC_DEV ,ICH9_LPC_FUNC ),TYPE_ICH9_LPC_DEVICE ); -qdev_prop_set_bit (DEVICE (lpc),"smm-enabled" , -x86_machine_is_smm_enabled (x86ms)); lpc_dev =DEVICE (lpc);
hw/i386/pc_q35.c static void pc_q35_init(MachineState *machine) · line 260
Quoted 10 lines
hw/i386/pc_q35.c +3
-1+qdev_prop_set_bit (lpc_dev,"smm-enabled" , +x86_machine_is_smm_enabled (x86ms)); +pci_realize_and_unref (lpc, host_bus, &error_fatal);for (i =0 ; i <IOAPIC_NUM_PINS ; i++) {qdev_connect_gpio_out_named (lpc_dev,ICH9_GPIO_GSI , i, x86ms->gsi[i]); } -pci_realize_and_unref (lpc, host_bus, &error_fatal); rtc_state =ISA_DEVICE (object_resolve_path_component (OBJECT (lpc),"rtc" ));
Re: [PATCH v4 12/12] hw/sparc64/cpu: Initialize GPIO before realizing CPU devices
In reply to Philippe Mathieu-DaudéQuoted 25 lines · Philippe Mathieu-Daudé
Inline
cpu_create()in order to callqdev_init_gpio_in_named_with_opaque()
before the CPU is realized.Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Peter Maydell <[email protected]>Reviewed-by Mark Cave-Ayland <[email protected]>--- hw/sparc64/sparc64.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)hw/sparc64/sparc64.c +1
-0@@ -24,6 +24,7 @@#include "qemu/osdep.h" +#include "qapi/error.h" #include "cpu.h" #include "hw/boards.h" #include "hw/sparc/sparc64.h" @@ -271,9 +272,10 @@ SPARCCPU *sparc64_cpu_devinit(const char *cpu_type, uint64_t prom_addr)uint32_t stick_frequency =100 *1000000 ;
hw/sparc64/sparc64.c SPARCCPU *sparc64_cpu_devinit(const char *cpu_type, uint64_t prom_addr) · line 281
Quoted 10 lines
hw/sparc64/sparc64.c +2
-1uint32_t hstick_frequency =100 *1000000 ; - cpu =SPARC_CPU (cpu_create (cpu_type)); + cpu =SPARC_CPU (object_new (cpu_type));qdev_init_gpio_in_named (DEVICE (cpu), sparc64_cpu_set_ivec_irq,"ivec-irq" ,IVEC_MAX ); +qdev_realize (DEVICE (cpu),NULL , &error_fatal); env = &cpu->env; env->tick = cpu_timer_create("tick", cpu, tick_irq,
Quoted 5 lines · Philippe Mathieu-Daudé
Philippe Mathieu-Daudé (12):
hw/ide/ich9: Use AHCIPCIState typedef hw/rx/rx62n: Reduce inclusion of 'qemu/units.h' hw/rx/rx62n: Only callqdev_get_gpio_in()when necessary hw/i386/q35: Realize LPC PCI function before accessing it
Quoted 8 lines
hw/ppc/prep: Realize ISA bridge before accessing it hw/misc/macio: Realize IDE controller before accessing it hw/sh4/r2d: Realize IDE controller before accessing it hw/sparc/sun4m: Realize DMA controller before accessing it hw/sparc/leon3: Realize GRLIB IRQ controller before accessing it hw/sparc/leon3: Pass DeviceState opaque argument to
leon3_set_pil_in()hw/sparc/leon3: Initialize GPIO before realizing CPU devices hw/sparc64/cpu: Initialize GPIO before realizing CPU devices
r~
Re: [PATCH v4 04/12] hw/i386/q35: Realize LPC PCI function before accessing it
In reply to Philippe Mathieu-DaudéQuoted 3 lines · Philippe Mathieu-Daudé
We should not wire IRQs on unrealized device.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 26 lines
---
hw/i386/pc_q35.c| 6 +++---1 file changed, 3 insertions(+), 3 deletions(-)hw/i386/pc_q35.c +3
-3@@ -248,13 +248,13 @@ static void pc_q35_init(MachineState *machine)/* create ISA bus */ lpc =pci_new_multifunction (PCI_DEVFN (ICH9_LPC_DEV ,ICH9_LPC_FUNC ),TYPE_ICH9_LPC_DEVICE ); -qdev_prop_set_bit (DEVICE (lpc),"smm-enabled" , -x86_machine_is_smm_enabled (x86ms)); lpc_dev =DEVICE (lpc); +qdev_prop_set_bit (lpc_dev,"smm-enabled" , +x86_machine_is_smm_enabled (x86ms)); +pci_realize_and_unref (lpc, host_bus, &error_fatal);for (i =0 ; i <IOAPIC_NUM_PINS ; i++) {qdev_connect_gpio_out_named (lpc_dev,ICH9_GPIO_GSI , i, x86ms->gsi[i]); } -pci_realize_and_unref (lpc, host_bus, &error_fatal); rtc_state =ISA_DEVICE (object_resolve_path_component (OBJECT (lpc),"rtc" ));
Re: [PATCH v4 06/12] hw/misc/macio: Realize IDE controller before accessing it
In reply to Philippe Mathieu-DaudéQuoted 4 lines · Philippe Mathieu-Daudé
We should not wire IRQs on unrealized device.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Mark Cave-Ayland <[email protected]>
Quoted 30 lines
---
hw/misc/macio/macio.c| 9 ++++++---1 file changed, 6 insertions(+), 3 deletions(-)hw/misc/macio/macio.c +6
-3@@ -123,14 +123,17 @@ static bool macio_realize_ide(MacIOState *s, MACIOIDEState *ide, {SysBusDevice *sbd =SYS_BUS_DEVICE (ide); -sysbus_connect_irq (sbd,0 , irq0); -sysbus_connect_irq (sbd,1 , irq1);qdev_prop_set_uint32 (DEVICE (ide),"channel" , dmaid);object_property_set_link (OBJECT (ide),"dbdma" ,OBJECT (&s->dbdma), &error_abort);macio_ide_register_dma (ide); +if (!qdev_realize (DEVICE (ide),BUS (&s->macio_bus), errp)) { +return false; + } +sysbus_connect_irq (sbd,0 , irq0); +sysbus_connect_irq (sbd,1 , irq1); -return qdev_realize (DEVICE (ide),BUS (&s->macio_bus), errp); +return true; }static void macio_oldworld_realize (PCIDevice *d,Error **errp)
Re: [PATCH v4 10/12] hw/sparc/leon3: Pass DeviceState opaque argument to leon3_set_pil_in()
In reply to Philippe Mathieu-DaudéQuoted 44 lines · Philippe Mathieu-Daudé
By passing a DeviceState context to a QDev IRQ handler, we can simplify and use
qdev_init_gpio_in_named()instead ofqdev_init_gpio_in_named_with_opaque().Suggested-by Mark Cave-Ayland <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/sparc/leon3.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)hw/sparc/leon3.c +3
-4@@ -175,9 +175,10 @@ static void leon3_irq_ack(CPUSPARCState *env, int intno)*/ static void leon3_set_pil_in (void *opaque,int n,int level) { -CPUSPARCState *env = opaque; +DeviceState *cpu = opaque; +CPUState *cs =CPU (cpu); +CPUSPARCState *env =cpu_env (cs);uint32_t pil_in = level; -CPUState *cs;assert (env !=NULL );@@ -193,7 +194,6 @@ static void leon3_set_pil_in(void *opaque, int n, int level) env->interrupt_index =TT_EXTINT | i;if (old_interrupt != env->interrupt_index) { - cs =env_cpu (env);trace_leon3_set_irq (i);cpu_interrupt (cs,CPU_INTERRUPT_HARD ); }@@ -201,7 +201,6 @@ static void leon3_set_pil_in(void *opaque, int n, int level) } } }else if (!env->pil_in && (env->interrupt_index & ~15 ) ==TT_EXTINT ) { - cs =env_cpu (env);trace_leon3_reset_irq (env->interrupt_index &15 ); env->interrupt_index =0 ;cpu_reset_interrupt (cs,CPU_INTERRUPT_HARD );
hw/sparc/leon3.c static void leon3_generic_hw_init(MachineState *machine) · line 266
Quoted 9 lines
hw/sparc/leon3.c +1
-2@@ -261,8 +260,7 @@ static void leon3_generic_hw_init(MachineState *machine)/* Allocate IRQ manager */ irqmpdev =qdev_new (TYPE_GRLIB_IRQMP ); -qdev_init_gpio_in_named_with_opaque (DEVICE (cpu), leon3_set_pil_in, - env,"pil" ,1 ); +qdev_init_gpio_in_named (DEVICE (cpu), leon3_set_pil_in,"pil" ,1 );sysbus_realize_and_unref (SYS_BUS_DEVICE (irqmpdev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (irqmpdev),0 ,LEON3_IRQMP_OFFSET ); qdev_connect_gpio_out_named(irqmpdev, "grlib-irq", 0,
ATB,
Mark.
Re: [PATCH v4 11/12] hw/sparc/leon3: Initialize GPIO before realizing CPU devices
In reply to Philippe Mathieu-DaudéQuoted 3 lines · Philippe Mathieu-Daudé
Inline
cpu_create()in order to callqdev_init_gpio_in_named_with_opaque()
before the CPU is realized.
Note that with the previous new patch included in the series, qdev_init_gpio_in_named_with_opaque() should be replaced by qdev_init_gpio_in_named() in the commit message above instead.
Quoted 23 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Peter Maydell <[email protected]>Reviewed-by Mark Cave-Ayland <[email protected]>--- hw/sparc/leon3.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)hw/sparc/leon3.c +3
-1@@ -233,7 +233,9 @@ static void leon3_generic_hw_init(MachineState *machine)APBPnp *apb_pnp;/* Init CPU */ - cpu =SPARC_CPU (cpu_create (machine->cpu_type)); + cpu =SPARC_CPU (object_new (machine->cpu_type)); +qdev_init_gpio_in_named (DEVICE (cpu), leon3_set_pil_in,"pil" ,1 ); +qdev_realize (DEVICE (cpu),NULL , &error_fatal); env = &cpu->env;cpu_sparc_set_id (env,0 );
hw/sparc/leon3.c static void leon3_generic_hw_init(MachineState *machine) · line 267
Quoted 7 lines
hw/sparc/leon3.c +0
-1@@ -260,7 +262,6 @@ static void leon3_generic_hw_init(MachineState *machine)/* Allocate IRQ manager */ irqmpdev =qdev_new (TYPE_GRLIB_IRQMP ); -qdev_init_gpio_in_named (DEVICE (cpu), leon3_set_pil_in,"pil" ,1 );sysbus_realize_and_unref (SYS_BUS_DEVICE (irqmpdev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (irqmpdev),0 ,LEON3_IRQMP_OFFSET ); qdev_connect_gpio_out_named(irqmpdev, "grlib-irq", 0,
ATB,
Mark.
Quoted 5 lines · Philippe Mathieu-Daudé
Philippe Mathieu-Daudé (12):
hw/ide/ich9: Use AHCIPCIState typedef hw/rx/rx62n: Reduce inclusion of 'qemu/units.h' hw/rx/rx62n: Only callqdev_get_gpio_in()when necessary hw/i386/q35: Realize LPC PCI function before accessing it
Quoted 8 lines
hw/ppc/prep: Realize ISA bridge before accessing it hw/misc/macio: Realize IDE controller before accessing it hw/sh4/r2d: Realize IDE controller before accessing it hw/sparc/sun4m: Realize DMA controller before accessing it hw/sparc/leon3: Realize GRLIB IRQ controller before accessing it hw/sparc/leon3: Pass DeviceState opaque argument to
leon3_set_pil_in()hw/sparc/leon3: Initialize GPIO before realizing CPU devices hw/sparc64/cpu: Initialize GPIO before realizing CPU devices
Patches 2-8,12 queued.
Re: [PATCH v4 07/12] hw/sh4/r2d: Realize IDE controller before accessing it
In reply to Philippe Mathieu-DaudéQuoted 14 lines · Philippe Mathieu-Daudé
We should not wire IRQs on unrealized device.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Peter Maydell <[email protected]>Reviewed-by Yoshinori Sato <[email protected]>--- hw/sh4/r2d.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/sh4/r2d.c +0
-0
hw/sh4/r2d.c static void r2d_init(MachineState *machine) · line 293
Quoted 10 lines
hw/sh4/r2d.c +1
-1@@ -285,9 +285,9 @@ static void r2d_init(MachineState *machine) dinfo =drive_get (IF_IDE ,0 ,0 ); dev =qdev_new ("mmio-ide" ); busdev =SYS_BUS_DEVICE (dev); -sysbus_connect_irq (busdev,0 , irq[CF_IDE ]);qdev_prop_set_uint32 (dev,"shift" ,1 );sysbus_realize_and_unref (busdev, &error_fatal); +sysbus_connect_irq (busdev,0 , irq[CF_IDE ]);sysbus_mmio_map (busdev,0 ,0x14001000 );sysbus_mmio_map (busdev,1 ,0x1400080c );mmio_ide_init_drives (dev, dinfo,NULL );
Should we pick this up for stable-9.0 & -9.1 series?
Thanks,
/mjt
Re: [PATCH v4 07/12] hw/sh4/r2d: Realize IDE controller before accessing it
Am 22. Oktober 2024 14:53:31 UTC schrieb Michael Tokarev <[email protected]>:
Quoted 19 lines · Philippe Mathieu-Daudé
Quoted 18 lines
We should not wire IRQs on unrealized device.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Peter Maydell <[email protected]>Reviewed-by Yoshinori Sato <[email protected]>--- hw/sh4/r2d.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/sh4/r2d.c +0
-1@@ -285,9 +285,9 @@ static void r2d_init(MachineState *machine) dinfo =drive_get (IF_IDE ,0 ,0 ); dev =qdev_new ("mmio-ide" ); busdev =SYS_BUS_DEVICE (dev); -sysbus_connect_irq (busdev,0 , irq[CF_IDE ]);
Quoted 8 lines
hw/sh4/r2d.c static void r2d_init(MachineState *machine) · line 293
Quoted 6 lines
hw/sh4/r2d.c +1
-0qdev_prop_set_uint32 (dev,"shift" ,1 );sysbus_realize_and_unref (busdev, &error_fatal); +sysbus_connect_irq (busdev,0 , irq[CF_IDE ]);sysbus_mmio_map (busdev,0 ,0x14001000 );sysbus_mmio_map (busdev,1 ,0x1400080c );mmio_ide_init_drives (dev, dinfo,NULL );Should we pick this up for stable-9.0 & -9.1 series?
IMO yes, because it fixes a regression.
Best regards,
Bernhard
Quoted 4 lines
Thanks,
/mjt