* [PATCH v2 1/6] hw/i386/x86: Let ioapic_init_gsi() take parent as pointer
2024-02-24 13:58 [PATCH v2 0/6] Simplify initialization of PC machines Bernhard Beschow
@ 2024-02-24 13:58 ` Bernhard Beschow
2024-02-26 8:27 ` Philippe Mathieu-Daudé
2024-02-26 8:54 ` Zhao Liu
2024-02-24 13:58 ` [PATCH v2 2/6] hw/i386/pc: Rename "bus" attribute to "pcibus" Bernhard Beschow
` (6 subsequent siblings)
7 siblings, 2 replies; 18+ messages in thread
From: Bernhard Beschow @ 2024-02-24 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: Ani Sinha, Michael S. Tsirkin, Philippe Mathieu-Daudé,
Eduardo Habkost, Marcel Apfelbaum, Richard Henderson,
Paolo Bonzini, Paul Durrant, Igor Mammedov, Jason Wang,
David Woodhouse, Sergio Lopez, Bernhard Beschow
Rather than taking a QOM name which has to be resolved, let's pass the parent
directly as pointer. This simplifies the code.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/i386/x86.h | 2 +-
hw/i386/microvm.c | 2 +-
hw/i386/pc_piix.c | 7 +++----
hw/i386/pc_q35.c | 2 +-
hw/i386/x86.c | 7 +++----
5 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h
index 8e306db7bb..4dc30dcb4d 100644
--- a/include/hw/i386/x86.h
+++ b/include/hw/i386/x86.h
@@ -139,7 +139,7 @@ typedef struct GSIState {
qemu_irq x86_allocate_cpu_irq(void);
void gsi_handler(void *opaque, int n, int level);
-void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);
+void ioapic_init_gsi(GSIState *gsi_state, Object *parent);
DeviceState *ioapic_init_secondary(GSIState *gsi_state);
/* pc_sysfw.c */
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
index ca55aecc3b..61a772dfe6 100644
--- a/hw/i386/microvm.c
+++ b/hw/i386/microvm.c
@@ -175,7 +175,7 @@ static void microvm_devices_init(MicrovmMachineState *mms)
&error_abort);
isa_bus_register_input_irqs(isa_bus, x86ms->gsi);
- ioapic_init_gsi(gsi_state, "machine");
+ ioapic_init_gsi(gsi_state, OBJECT(mms));
if (ioapics > 1) {
x86ms->ioapic2 = ioapic_init_secondary(gsi_state);
}
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index ec7c07b362..7724396ead 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -107,6 +107,7 @@ static void pc_init1(MachineState *machine,
X86MachineState *x86ms = X86_MACHINE(machine);
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *system_io = get_system_io();
+ Object *phb = NULL;
PCIBus *pci_bus = NULL;
ISABus *isa_bus;
Object *piix4_pm = NULL;
@@ -189,8 +190,6 @@ static void pc_init1(MachineState *machine,
}
if (pcmc->pci_enabled) {
- Object *phb;
-
pci_memory = g_new(MemoryRegion, 1);
memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
rom_memory = pci_memory;
@@ -303,8 +302,8 @@ static void pc_init1(MachineState *machine,
pc_i8259_create(isa_bus, gsi_state->i8259_irq);
}
- if (pcmc->pci_enabled) {
- ioapic_init_gsi(gsi_state, "i440fx");
+ if (phb) {
+ ioapic_init_gsi(gsi_state, phb);
}
if (tcg_enabled()) {
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 53fb3db26d..c89ff63579 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -263,7 +263,7 @@ static void pc_q35_init(MachineState *machine)
pc_i8259_create(isa_bus, gsi_state->i8259_irq);
}
- ioapic_init_gsi(gsi_state, "q35");
+ ioapic_init_gsi(gsi_state, OBJECT(phb));
if (tcg_enabled()) {
x86_register_ferr_irq(x86ms->gsi[13]);
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 684dce90e9..807e09bcdb 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -640,20 +640,19 @@ void gsi_handler(void *opaque, int n, int level)
}
}
-void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name)
+void ioapic_init_gsi(GSIState *gsi_state, Object *parent)
{
DeviceState *dev;
SysBusDevice *d;
unsigned int i;
- assert(parent_name);
+ assert(parent);
if (kvm_ioapic_in_kernel()) {
dev = qdev_new(TYPE_KVM_IOAPIC);
} else {
dev = qdev_new(TYPE_IOAPIC);
}
- object_property_add_child(object_resolve_path(parent_name, NULL),
- "ioapic", OBJECT(dev));
+ object_property_add_child(parent, "ioapic", OBJECT(dev));
d = SYS_BUS_DEVICE(dev);
sysbus_realize_and_unref(d, &error_fatal);
sysbus_mmio_map(d, 0, IO_APIC_DEFAULT_ADDRESS);
--
2.44.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v2 1/6] hw/i386/x86: Let ioapic_init_gsi() take parent as pointer
2024-02-24 13:58 ` [PATCH v2 1/6] hw/i386/x86: Let ioapic_init_gsi() take parent as pointer Bernhard Beschow
@ 2024-02-26 8:27 ` Philippe Mathieu-Daudé
2024-02-26 8:54 ` Zhao Liu
1 sibling, 0 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-02-26 8:27 UTC (permalink / raw)
To: Bernhard Beschow, qemu-devel
Cc: Ani Sinha, Michael S. Tsirkin, Eduardo Habkost, Marcel Apfelbaum,
Richard Henderson, Paolo Bonzini, Paul Durrant, Igor Mammedov,
Jason Wang, David Woodhouse, Sergio Lopez
On 24/2/24 14:58, Bernhard Beschow wrote:
> Rather than taking a QOM name which has to be resolved, let's pass the parent
> directly as pointer. This simplifies the code.
>
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> include/hw/i386/x86.h | 2 +-
> hw/i386/microvm.c | 2 +-
> hw/i386/pc_piix.c | 7 +++----
> hw/i386/pc_q35.c | 2 +-
> hw/i386/x86.c | 7 +++----
> 5 files changed, 9 insertions(+), 11 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 1/6] hw/i386/x86: Let ioapic_init_gsi() take parent as pointer
2024-02-24 13:58 ` [PATCH v2 1/6] hw/i386/x86: Let ioapic_init_gsi() take parent as pointer Bernhard Beschow
2024-02-26 8:27 ` Philippe Mathieu-Daudé
@ 2024-02-26 8:54 ` Zhao Liu
1 sibling, 0 replies; 18+ messages in thread
From: Zhao Liu @ 2024-02-26 8:54 UTC (permalink / raw)
To: Bernhard Beschow
Cc: qemu-devel, Ani Sinha, Michael S. Tsirkin,
Philippe Mathieu-Daudé, Eduardo Habkost, Marcel Apfelbaum,
Richard Henderson, Paolo Bonzini, Paul Durrant, Igor Mammedov,
Jason Wang, David Woodhouse, Sergio Lopez
On Sat, Feb 24, 2024 at 02:58:46PM +0100, Bernhard Beschow wrote:
> Date: Sat, 24 Feb 2024 14:58:46 +0100
> From: Bernhard Beschow <shentey@gmail.com>
> Subject: [PATCH v2 1/6] hw/i386/x86: Let ioapic_init_gsi() take parent as
> pointer
> X-Mailer: git-send-email 2.44.0
>
> Rather than taking a QOM name which has to be resolved, let's pass the parent
> directly as pointer. This simplifies the code.
>
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> include/hw/i386/x86.h | 2 +-
> hw/i386/microvm.c | 2 +-
> hw/i386/pc_piix.c | 7 +++----
> hw/i386/pc_q35.c | 2 +-
> hw/i386/x86.c | 7 +++----
> 5 files changed, 9 insertions(+), 11 deletions(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
>
> diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h
> index 8e306db7bb..4dc30dcb4d 100644
> --- a/include/hw/i386/x86.h
> +++ b/include/hw/i386/x86.h
> @@ -139,7 +139,7 @@ typedef struct GSIState {
>
> qemu_irq x86_allocate_cpu_irq(void);
> void gsi_handler(void *opaque, int n, int level);
> -void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);
> +void ioapic_init_gsi(GSIState *gsi_state, Object *parent);
> DeviceState *ioapic_init_secondary(GSIState *gsi_state);
>
> /* pc_sysfw.c */
> diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
> index ca55aecc3b..61a772dfe6 100644
> --- a/hw/i386/microvm.c
> +++ b/hw/i386/microvm.c
> @@ -175,7 +175,7 @@ static void microvm_devices_init(MicrovmMachineState *mms)
> &error_abort);
> isa_bus_register_input_irqs(isa_bus, x86ms->gsi);
>
> - ioapic_init_gsi(gsi_state, "machine");
> + ioapic_init_gsi(gsi_state, OBJECT(mms));
> if (ioapics > 1) {
> x86ms->ioapic2 = ioapic_init_secondary(gsi_state);
> }
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index ec7c07b362..7724396ead 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -107,6 +107,7 @@ static void pc_init1(MachineState *machine,
> X86MachineState *x86ms = X86_MACHINE(machine);
> MemoryRegion *system_memory = get_system_memory();
> MemoryRegion *system_io = get_system_io();
> + Object *phb = NULL;
> PCIBus *pci_bus = NULL;
> ISABus *isa_bus;
> Object *piix4_pm = NULL;
> @@ -189,8 +190,6 @@ static void pc_init1(MachineState *machine,
> }
>
> if (pcmc->pci_enabled) {
> - Object *phb;
> -
> pci_memory = g_new(MemoryRegion, 1);
> memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
> rom_memory = pci_memory;
> @@ -303,8 +302,8 @@ static void pc_init1(MachineState *machine,
> pc_i8259_create(isa_bus, gsi_state->i8259_irq);
> }
>
> - if (pcmc->pci_enabled) {
> - ioapic_init_gsi(gsi_state, "i440fx");
> + if (phb) {
> + ioapic_init_gsi(gsi_state, phb);
> }
>
> if (tcg_enabled()) {
> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
> index 53fb3db26d..c89ff63579 100644
> --- a/hw/i386/pc_q35.c
> +++ b/hw/i386/pc_q35.c
> @@ -263,7 +263,7 @@ static void pc_q35_init(MachineState *machine)
> pc_i8259_create(isa_bus, gsi_state->i8259_irq);
> }
>
> - ioapic_init_gsi(gsi_state, "q35");
> + ioapic_init_gsi(gsi_state, OBJECT(phb));
>
> if (tcg_enabled()) {
> x86_register_ferr_irq(x86ms->gsi[13]);
> diff --git a/hw/i386/x86.c b/hw/i386/x86.c
> index 684dce90e9..807e09bcdb 100644
> --- a/hw/i386/x86.c
> +++ b/hw/i386/x86.c
> @@ -640,20 +640,19 @@ void gsi_handler(void *opaque, int n, int level)
> }
> }
>
> -void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name)
> +void ioapic_init_gsi(GSIState *gsi_state, Object *parent)
> {
> DeviceState *dev;
> SysBusDevice *d;
> unsigned int i;
>
> - assert(parent_name);
> + assert(parent);
> if (kvm_ioapic_in_kernel()) {
> dev = qdev_new(TYPE_KVM_IOAPIC);
> } else {
> dev = qdev_new(TYPE_IOAPIC);
> }
> - object_property_add_child(object_resolve_path(parent_name, NULL),
> - "ioapic", OBJECT(dev));
> + object_property_add_child(parent, "ioapic", OBJECT(dev));
> d = SYS_BUS_DEVICE(dev);
> sysbus_realize_and_unref(d, &error_fatal);
> sysbus_mmio_map(d, 0, IO_APIC_DEFAULT_ADDRESS);
> --
> 2.44.0
>
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 2/6] hw/i386/pc: Rename "bus" attribute to "pcibus"
2024-02-24 13:58 [PATCH v2 0/6] Simplify initialization of PC machines Bernhard Beschow
2024-02-24 13:58 ` [PATCH v2 1/6] hw/i386/x86: Let ioapic_init_gsi() take parent as pointer Bernhard Beschow
@ 2024-02-24 13:58 ` Bernhard Beschow
2024-02-26 8:26 ` Philippe Mathieu-Daudé
2024-02-26 8:56 ` Zhao Liu
2024-02-24 13:58 ` [PATCH v2 3/6] hw/i386/pc_{piix, q35}: Eliminate local pci_bus/pci_host variables Bernhard Beschow
` (5 subsequent siblings)
7 siblings, 2 replies; 18+ messages in thread
From: Bernhard Beschow @ 2024-02-24 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: Ani Sinha, Michael S. Tsirkin, Philippe Mathieu-Daudé,
Eduardo Habkost, Marcel Apfelbaum, Richard Henderson,
Paolo Bonzini, Paul Durrant, Igor Mammedov, Jason Wang,
David Woodhouse, Sergio Lopez, Bernhard Beschow
The attribute is of type PCIBus; reflect that in the name. It will also make the
next change more intuitive.
Suggested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
include/hw/i386/pc.h | 2 +-
hw/i386/acpi-build.c | 2 +-
hw/i386/amd_iommu.c | 2 +-
hw/i386/intel_iommu.c | 2 +-
hw/i386/kvm/xen_evtchn.c | 2 +-
hw/i386/pc.c | 8 ++++----
hw/i386/pc_piix.c | 6 +++---
hw/i386/pc_q35.c | 2 +-
hw/i386/x86-iommu.c | 2 +-
9 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index e88468131a..27834043c3 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -31,7 +31,7 @@ typedef struct PCMachineState {
Notifier machine_done;
/* Pointers to devices and objects: */
- PCIBus *bus;
+ PCIBus *pcibus;
I2CBus *smbus;
PFlashCFI01 *flash[2];
ISADevice *pcspk;
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index d3ce96dd9f..cd3f2d0148 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1556,7 +1556,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
}
crs_range_set_init(&crs_range_set);
- bus = PC_MACHINE(machine)->bus;
+ bus = PC_MACHINE(machine)->pcibus;
if (bus) {
QLIST_FOREACH(bus, &bus->child, sibling) {
uint8_t bus_num = pci_bus_num(bus);
diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
index 7329553ad3..6d4fde72f9 100644
--- a/hw/i386/amd_iommu.c
+++ b/hw/i386/amd_iommu.c
@@ -1584,7 +1584,7 @@ static void amdvi_sysbus_realize(DeviceState *dev, Error **errp)
MachineState *ms = MACHINE(qdev_get_machine());
PCMachineState *pcms = PC_MACHINE(ms);
X86MachineState *x86ms = X86_MACHINE(ms);
- PCIBus *bus = pcms->bus;
+ PCIBus *bus = pcms->pcibus;
s->iotlb = g_hash_table_new_full(amdvi_uint64_hash,
amdvi_uint64_equal, g_free, g_free);
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index cf933189d3..cc8e59674e 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -4183,7 +4183,7 @@ static void vtd_realize(DeviceState *dev, Error **errp)
MachineState *ms = MACHINE(qdev_get_machine());
PCMachineState *pcms = PC_MACHINE(ms);
X86MachineState *x86ms = X86_MACHINE(ms);
- PCIBus *bus = pcms->bus;
+ PCIBus *bus = pcms->pcibus;
IntelIOMMUState *s = INTEL_IOMMU_DEVICE(dev);
X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(s);
diff --git a/hw/i386/kvm/xen_evtchn.c b/hw/i386/kvm/xen_evtchn.c
index 0171ef6d59..a5052c0ea3 100644
--- a/hw/i386/kvm/xen_evtchn.c
+++ b/hw/i386/kvm/xen_evtchn.c
@@ -371,7 +371,7 @@ static int set_callback_pci_intx(XenEvtchnState *s, uint64_t param)
return 0;
}
- pdev = pci_find_device(pcms->bus, bus, devfn);
+ pdev = pci_find_device(pcms->pcibus, bus, devfn);
if (!pdev) {
return 0;
}
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index f8eb684a49..353edeb2ea 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -675,7 +675,7 @@ void pc_machine_done(Notifier *notifier, void *data)
PCMachineState, machine_done);
X86MachineState *x86ms = X86_MACHINE(pcms);
- cxl_hook_up_pxb_registers(pcms->bus, &pcms->cxl_devices_state,
+ cxl_hook_up_pxb_registers(pcms->pcibus, &pcms->cxl_devices_state,
&error_fatal);
if (pcms->cxl_devices_state.is_enabled) {
@@ -685,7 +685,7 @@ void pc_machine_done(Notifier *notifier, void *data)
/* set the number of CPUs */
x86_rtc_set_cpus_count(x86ms->rtc, x86ms->boot_cpus);
- fw_cfg_add_extra_pci_roots(pcms->bus, x86ms->fw_cfg);
+ fw_cfg_add_extra_pci_roots(pcms->pcibus, x86ms->fw_cfg);
acpi_setup();
if (x86ms->fw_cfg) {
@@ -1250,8 +1250,8 @@ void pc_basic_device_init(struct PCMachineState *pcms,
xen_evtchn_create(IOAPIC_NUM_PINS, gsi);
xen_gnttab_create();
xen_xenstore_create();
- if (pcms->bus) {
- pci_create_simple(pcms->bus, -1, "xen-platform");
+ if (pcms->pcibus) {
+ pci_create_simple(pcms->pcibus, -1, "xen-platform");
}
xen_bus_init();
xen_be_init();
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 7724396ead..3393b93007 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -216,7 +216,7 @@ static void pc_init1(MachineState *machine,
pci_bus_map_irqs(pci_bus,
xen_enabled() ? xen_pci_slot_get_pirq
: pc_pci_slot_get_pirq);
- pcms->bus = pci_bus;
+ pcms->pcibus = pci_bus;
hole64_size = object_property_get_uint(phb,
PCI_HOST_PROP_PCI_HOLE64_SIZE,
@@ -480,8 +480,8 @@ static void pc_xen_hvm_init(MachineState *machine)
}
pc_xen_hvm_init_pci(machine);
- xen_igd_reserve_slot(pcms->bus);
- pci_create_simple(pcms->bus, -1, "xen-platform");
+ xen_igd_reserve_slot(pcms->pcibus);
+ pci_create_simple(pcms->pcibus, -1, "xen-platform");
}
#endif
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index c89ff63579..734d9bedb2 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -217,7 +217,7 @@ static void pc_q35_init(MachineState *machine)
/* pci */
host_bus = PCI_BUS(qdev_get_child_bus(DEVICE(phb), "pcie.0"));
- pcms->bus = host_bus;
+ pcms->pcibus = host_bus;
/* irq lines */
gsi_state = pc_gsi_create(&x86ms->gsi, true);
diff --git a/hw/i386/x86-iommu.c b/hw/i386/x86-iommu.c
index 726e9e1d16..60af896225 100644
--- a/hw/i386/x86-iommu.c
+++ b/hw/i386/x86-iommu.c
@@ -101,7 +101,7 @@ static void x86_iommu_realize(DeviceState *dev, Error **errp)
QLIST_INIT(&x86_iommu->iec_notifiers);
bool irq_all_kernel = kvm_irqchip_in_kernel() && !kvm_irqchip_is_split();
- if (!pcms || !pcms->bus) {
+ if (!pcms || !pcms->pcibus) {
error_setg(errp, "Machine-type '%s' not supported by IOMMU",
mc->name);
return;
--
2.44.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v2 2/6] hw/i386/pc: Rename "bus" attribute to "pcibus"
2024-02-24 13:58 ` [PATCH v2 2/6] hw/i386/pc: Rename "bus" attribute to "pcibus" Bernhard Beschow
@ 2024-02-26 8:26 ` Philippe Mathieu-Daudé
2024-02-26 8:56 ` Zhao Liu
1 sibling, 0 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-02-26 8:26 UTC (permalink / raw)
To: Bernhard Beschow, qemu-devel
Cc: Ani Sinha, Michael S. Tsirkin, Eduardo Habkost, Marcel Apfelbaum,
Richard Henderson, Paolo Bonzini, Paul Durrant, Igor Mammedov,
Jason Wang, David Woodhouse, Sergio Lopez
On 24/2/24 14:58, Bernhard Beschow wrote:
> The attribute is of type PCIBus; reflect that in the name. It will also make the
> next change more intuitive.
>
> Suggested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
> ---
> include/hw/i386/pc.h | 2 +-
> hw/i386/acpi-build.c | 2 +-
> hw/i386/amd_iommu.c | 2 +-
> hw/i386/intel_iommu.c | 2 +-
> hw/i386/kvm/xen_evtchn.c | 2 +-
> hw/i386/pc.c | 8 ++++----
> hw/i386/pc_piix.c | 6 +++---
> hw/i386/pc_q35.c | 2 +-
> hw/i386/x86-iommu.c | 2 +-
> 9 files changed, 14 insertions(+), 14 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 2/6] hw/i386/pc: Rename "bus" attribute to "pcibus"
2024-02-24 13:58 ` [PATCH v2 2/6] hw/i386/pc: Rename "bus" attribute to "pcibus" Bernhard Beschow
2024-02-26 8:26 ` Philippe Mathieu-Daudé
@ 2024-02-26 8:56 ` Zhao Liu
1 sibling, 0 replies; 18+ messages in thread
From: Zhao Liu @ 2024-02-26 8:56 UTC (permalink / raw)
To: Bernhard Beschow
Cc: qemu-devel, Ani Sinha, Michael S. Tsirkin,
Philippe Mathieu-Daudé, Eduardo Habkost, Marcel Apfelbaum,
Richard Henderson, Paolo Bonzini, Paul Durrant, Igor Mammedov,
Jason Wang, David Woodhouse, Sergio Lopez
On Sat, Feb 24, 2024 at 02:58:47PM +0100, Bernhard Beschow wrote:
> Date: Sat, 24 Feb 2024 14:58:47 +0100
> From: Bernhard Beschow <shentey@gmail.com>
> Subject: [PATCH v2 2/6] hw/i386/pc: Rename "bus" attribute to "pcibus"
> X-Mailer: git-send-email 2.44.0
>
> The attribute is of type PCIBus; reflect that in the name. It will also make the
> next change more intuitive.
>
> Suggested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
> ---
> include/hw/i386/pc.h | 2 +-
> hw/i386/acpi-build.c | 2 +-
> hw/i386/amd_iommu.c | 2 +-
> hw/i386/intel_iommu.c | 2 +-
> hw/i386/kvm/xen_evtchn.c | 2 +-
> hw/i386/pc.c | 8 ++++----
> hw/i386/pc_piix.c | 6 +++---
> hw/i386/pc_q35.c | 2 +-
> hw/i386/x86-iommu.c | 2 +-
> 9 files changed, 14 insertions(+), 14 deletions(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
>
> diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
> index e88468131a..27834043c3 100644
> --- a/include/hw/i386/pc.h
> +++ b/include/hw/i386/pc.h
> @@ -31,7 +31,7 @@ typedef struct PCMachineState {
> Notifier machine_done;
>
> /* Pointers to devices and objects: */
> - PCIBus *bus;
> + PCIBus *pcibus;
> I2CBus *smbus;
> PFlashCFI01 *flash[2];
> ISADevice *pcspk;
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index d3ce96dd9f..cd3f2d0148 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -1556,7 +1556,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> }
>
> crs_range_set_init(&crs_range_set);
> - bus = PC_MACHINE(machine)->bus;
> + bus = PC_MACHINE(machine)->pcibus;
> if (bus) {
> QLIST_FOREACH(bus, &bus->child, sibling) {
> uint8_t bus_num = pci_bus_num(bus);
> diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
> index 7329553ad3..6d4fde72f9 100644
> --- a/hw/i386/amd_iommu.c
> +++ b/hw/i386/amd_iommu.c
> @@ -1584,7 +1584,7 @@ static void amdvi_sysbus_realize(DeviceState *dev, Error **errp)
> MachineState *ms = MACHINE(qdev_get_machine());
> PCMachineState *pcms = PC_MACHINE(ms);
> X86MachineState *x86ms = X86_MACHINE(ms);
> - PCIBus *bus = pcms->bus;
> + PCIBus *bus = pcms->pcibus;
>
> s->iotlb = g_hash_table_new_full(amdvi_uint64_hash,
> amdvi_uint64_equal, g_free, g_free);
> diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
> index cf933189d3..cc8e59674e 100644
> --- a/hw/i386/intel_iommu.c
> +++ b/hw/i386/intel_iommu.c
> @@ -4183,7 +4183,7 @@ static void vtd_realize(DeviceState *dev, Error **errp)
> MachineState *ms = MACHINE(qdev_get_machine());
> PCMachineState *pcms = PC_MACHINE(ms);
> X86MachineState *x86ms = X86_MACHINE(ms);
> - PCIBus *bus = pcms->bus;
> + PCIBus *bus = pcms->pcibus;
> IntelIOMMUState *s = INTEL_IOMMU_DEVICE(dev);
> X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(s);
>
> diff --git a/hw/i386/kvm/xen_evtchn.c b/hw/i386/kvm/xen_evtchn.c
> index 0171ef6d59..a5052c0ea3 100644
> --- a/hw/i386/kvm/xen_evtchn.c
> +++ b/hw/i386/kvm/xen_evtchn.c
> @@ -371,7 +371,7 @@ static int set_callback_pci_intx(XenEvtchnState *s, uint64_t param)
> return 0;
> }
>
> - pdev = pci_find_device(pcms->bus, bus, devfn);
> + pdev = pci_find_device(pcms->pcibus, bus, devfn);
> if (!pdev) {
> return 0;
> }
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index f8eb684a49..353edeb2ea 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -675,7 +675,7 @@ void pc_machine_done(Notifier *notifier, void *data)
> PCMachineState, machine_done);
> X86MachineState *x86ms = X86_MACHINE(pcms);
>
> - cxl_hook_up_pxb_registers(pcms->bus, &pcms->cxl_devices_state,
> + cxl_hook_up_pxb_registers(pcms->pcibus, &pcms->cxl_devices_state,
> &error_fatal);
>
> if (pcms->cxl_devices_state.is_enabled) {
> @@ -685,7 +685,7 @@ void pc_machine_done(Notifier *notifier, void *data)
> /* set the number of CPUs */
> x86_rtc_set_cpus_count(x86ms->rtc, x86ms->boot_cpus);
>
> - fw_cfg_add_extra_pci_roots(pcms->bus, x86ms->fw_cfg);
> + fw_cfg_add_extra_pci_roots(pcms->pcibus, x86ms->fw_cfg);
>
> acpi_setup();
> if (x86ms->fw_cfg) {
> @@ -1250,8 +1250,8 @@ void pc_basic_device_init(struct PCMachineState *pcms,
> xen_evtchn_create(IOAPIC_NUM_PINS, gsi);
> xen_gnttab_create();
> xen_xenstore_create();
> - if (pcms->bus) {
> - pci_create_simple(pcms->bus, -1, "xen-platform");
> + if (pcms->pcibus) {
> + pci_create_simple(pcms->pcibus, -1, "xen-platform");
> }
> xen_bus_init();
> xen_be_init();
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index 7724396ead..3393b93007 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -216,7 +216,7 @@ static void pc_init1(MachineState *machine,
> pci_bus_map_irqs(pci_bus,
> xen_enabled() ? xen_pci_slot_get_pirq
> : pc_pci_slot_get_pirq);
> - pcms->bus = pci_bus;
> + pcms->pcibus = pci_bus;
>
> hole64_size = object_property_get_uint(phb,
> PCI_HOST_PROP_PCI_HOLE64_SIZE,
> @@ -480,8 +480,8 @@ static void pc_xen_hvm_init(MachineState *machine)
> }
>
> pc_xen_hvm_init_pci(machine);
> - xen_igd_reserve_slot(pcms->bus);
> - pci_create_simple(pcms->bus, -1, "xen-platform");
> + xen_igd_reserve_slot(pcms->pcibus);
> + pci_create_simple(pcms->pcibus, -1, "xen-platform");
> }
> #endif
>
> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
> index c89ff63579..734d9bedb2 100644
> --- a/hw/i386/pc_q35.c
> +++ b/hw/i386/pc_q35.c
> @@ -217,7 +217,7 @@ static void pc_q35_init(MachineState *machine)
>
> /* pci */
> host_bus = PCI_BUS(qdev_get_child_bus(DEVICE(phb), "pcie.0"));
> - pcms->bus = host_bus;
> + pcms->pcibus = host_bus;
>
> /* irq lines */
> gsi_state = pc_gsi_create(&x86ms->gsi, true);
> diff --git a/hw/i386/x86-iommu.c b/hw/i386/x86-iommu.c
> index 726e9e1d16..60af896225 100644
> --- a/hw/i386/x86-iommu.c
> +++ b/hw/i386/x86-iommu.c
> @@ -101,7 +101,7 @@ static void x86_iommu_realize(DeviceState *dev, Error **errp)
> QLIST_INIT(&x86_iommu->iec_notifiers);
> bool irq_all_kernel = kvm_irqchip_in_kernel() && !kvm_irqchip_is_split();
>
> - if (!pcms || !pcms->bus) {
> + if (!pcms || !pcms->pcibus) {
> error_setg(errp, "Machine-type '%s' not supported by IOMMU",
> mc->name);
> return;
> --
> 2.44.0
>
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 3/6] hw/i386/pc_{piix, q35}: Eliminate local pci_bus/pci_host variables
2024-02-24 13:58 [PATCH v2 0/6] Simplify initialization of PC machines Bernhard Beschow
2024-02-24 13:58 ` [PATCH v2 1/6] hw/i386/x86: Let ioapic_init_gsi() take parent as pointer Bernhard Beschow
2024-02-24 13:58 ` [PATCH v2 2/6] hw/i386/pc: Rename "bus" attribute to "pcibus" Bernhard Beschow
@ 2024-02-24 13:58 ` Bernhard Beschow
2024-02-26 9:00 ` Zhao Liu
2024-02-24 13:58 ` [PATCH v2 4/6] hw/i386/pc: Remove unneeded class attribute "kvmclock_enabled" Bernhard Beschow
` (4 subsequent siblings)
7 siblings, 1 reply; 18+ messages in thread
From: Bernhard Beschow @ 2024-02-24 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: Ani Sinha, Michael S. Tsirkin, Philippe Mathieu-Daudé,
Eduardo Habkost, Marcel Apfelbaum, Richard Henderson,
Paolo Bonzini, Paul Durrant, Igor Mammedov, Jason Wang,
David Woodhouse, Sergio Lopez, Bernhard Beschow
There is no advantage in having these local variables which 1/ needlessly have
different identifiers in both machines and 2/ which are redundant to pcms->bus
which is almost as short.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/i386/pc_piix.c | 14 ++++++--------
hw/i386/pc_q35.c | 16 +++++++---------
2 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 3393b93007..814d24326d 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -108,7 +108,6 @@ static void pc_init1(MachineState *machine,
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *system_io = get_system_io();
Object *phb = NULL;
- PCIBus *pci_bus = NULL;
ISABus *isa_bus;
Object *piix4_pm = NULL;
qemu_irq smi_irq;
@@ -212,11 +211,10 @@ static void pc_init1(MachineState *machine,
&error_fatal);
sysbus_realize_and_unref(SYS_BUS_DEVICE(phb), &error_fatal);
- pci_bus = PCI_BUS(qdev_get_child_bus(DEVICE(phb), "pci.0"));
- pci_bus_map_irqs(pci_bus,
+ pcms->pcibus = PCI_BUS(qdev_get_child_bus(DEVICE(phb), "pci.0"));
+ pci_bus_map_irqs(pcms->pcibus,
xen_enabled() ? xen_pci_slot_get_pirq
: pc_pci_slot_get_pirq);
- pcms->pcibus = pci_bus;
hole64_size = object_property_get_uint(phb,
PCI_HOST_PROP_PCI_HOLE64_SIZE,
@@ -261,7 +259,7 @@ static void pc_init1(MachineState *machine,
for (i = 0; i < ISA_NUM_IRQS; i++) {
qdev_connect_gpio_out_named(dev, "isa-irqs", i, x86ms->gsi[i]);
}
- pci_realize_and_unref(pci_dev, pci_bus, &error_fatal);
+ pci_realize_and_unref(pci_dev, pcms->pcibus, &error_fatal);
if (xen_enabled()) {
pci_device_set_intx_routing_notifier(
@@ -273,7 +271,7 @@ static void pc_init1(MachineState *machine,
* connected to the IOAPIC directly.
* These additional routes can be discovered through ACPI.
*/
- pci_bus_irqs(pci_bus, xen_intx_set_irq, pci_dev,
+ pci_bus_irqs(pcms->pcibus, xen_intx_set_irq, pci_dev,
XEN_IOAPIC_NUM_PIRQS);
}
@@ -310,7 +308,7 @@ static void pc_init1(MachineState *machine,
x86_register_ferr_irq(x86ms->gsi[13]);
}
- pc_vga_init(isa_bus, pcmc->pci_enabled ? pci_bus : NULL);
+ pc_vga_init(isa_bus, pcmc->pci_enabled ? pcms->pcibus : NULL);
assert(pcms->vmport != ON_OFF_AUTO__MAX);
if (pcms->vmport == ON_OFF_AUTO_AUTO) {
@@ -321,7 +319,7 @@ static void pc_init1(MachineState *machine,
pc_basic_device_init(pcms, isa_bus, x86ms->gsi, rtc_state, true,
0x4);
- pc_nic_init(pcmc, isa_bus, pci_bus);
+ pc_nic_init(pcmc, isa_bus, pcms->pcibus);
#ifdef CONFIG_IDE_ISA
if (!pcmc->pci_enabled) {
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 734d9bedb2..2fa4efb52f 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -122,7 +122,6 @@ static void pc_q35_init(MachineState *machine)
PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
X86MachineState *x86ms = X86_MACHINE(machine);
Object *phb;
- PCIBus *host_bus;
PCIDevice *lpc;
DeviceState *lpc_dev;
ISADevice *rtc_state;
@@ -216,8 +215,7 @@ static void pc_q35_init(MachineState *machine)
sysbus_realize_and_unref(SYS_BUS_DEVICE(phb), &error_fatal);
/* pci */
- host_bus = PCI_BUS(qdev_get_child_bus(DEVICE(phb), "pcie.0"));
- pcms->pcibus = host_bus;
+ pcms->pcibus = PCI_BUS(qdev_get_child_bus(DEVICE(phb), "pcie.0"));
/* irq lines */
gsi_state = pc_gsi_create(&x86ms->gsi, true);
@@ -231,7 +229,7 @@ static void pc_q35_init(MachineState *machine)
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);
+ pci_realize_and_unref(lpc, pcms->pcibus, &error_fatal);
rtc_state = ISA_DEVICE(object_resolve_path_component(OBJECT(lpc), "rtc"));
@@ -283,7 +281,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(host_bus,
+ pdev = pci_create_simple_multifunction(pcms->pcibus,
PCI_DEVFN(ICH9_SATA1_DEV,
ICH9_SATA1_FUNC),
"ich9-ahci");
@@ -297,14 +295,14 @@ static void pc_q35_init(MachineState *machine)
if (machine_usb(machine)) {
/* Should we create 6 UHCI according to ich9 spec? */
- ehci_create_ich9_with_companions(host_bus, 0x1d);
+ ehci_create_ich9_with_companions(pcms->pcibus, 0x1d);
}
if (pcms->smbus_enabled) {
PCIDevice *smb;
/* TODO: Populate SPD eeprom data. */
- smb = pci_create_simple_multifunction(host_bus,
+ smb = pci_create_simple_multifunction(pcms->pcibus,
PCI_DEVFN(ICH9_SMB_DEV,
ICH9_SMB_FUNC),
TYPE_ICH9_SMB_DEVICE);
@@ -316,8 +314,8 @@ static void pc_q35_init(MachineState *machine)
pc_cmos_init(pcms, rtc_state);
/* the rest devices to which pci devfn is automatically assigned */
- pc_vga_init(isa_bus, host_bus);
- pc_nic_init(pcmc, isa_bus, host_bus);
+ pc_vga_init(isa_bus, pcms->pcibus);
+ pc_nic_init(pcmc, isa_bus, pcms->pcibus);
if (machine->nvdimms_state->is_enabled) {
nvdimm_init_acpi_state(machine->nvdimms_state, system_io,
--
2.44.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v2 3/6] hw/i386/pc_{piix, q35}: Eliminate local pci_bus/pci_host variables
2024-02-24 13:58 ` [PATCH v2 3/6] hw/i386/pc_{piix, q35}: Eliminate local pci_bus/pci_host variables Bernhard Beschow
@ 2024-02-26 9:00 ` Zhao Liu
0 siblings, 0 replies; 18+ messages in thread
From: Zhao Liu @ 2024-02-26 9:00 UTC (permalink / raw)
To: Bernhard Beschow
Cc: qemu-devel, Ani Sinha, Michael S. Tsirkin,
Philippe Mathieu-Daudé, Eduardo Habkost, Marcel Apfelbaum,
Richard Henderson, Paolo Bonzini, Paul Durrant, Igor Mammedov,
Jason Wang, David Woodhouse, Sergio Lopez
On Sat, Feb 24, 2024 at 02:58:48PM +0100, Bernhard Beschow wrote:
> Date: Sat, 24 Feb 2024 14:58:48 +0100
> From: Bernhard Beschow <shentey@gmail.com>
> Subject: [PATCH v2 3/6] hw/i386/pc_{piix, q35}: Eliminate local
> pci_bus/pci_host variables
> X-Mailer: git-send-email 2.44.0
>
> There is no advantage in having these local variables which 1/ needlessly have
> different identifiers in both machines and 2/ which are redundant to pcms->bus
> which is almost as short.
>
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> hw/i386/pc_piix.c | 14 ++++++--------
> hw/i386/pc_q35.c | 16 +++++++---------
> 2 files changed, 13 insertions(+), 17 deletions(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
>
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index 3393b93007..814d24326d 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -108,7 +108,6 @@ static void pc_init1(MachineState *machine,
> MemoryRegion *system_memory = get_system_memory();
> MemoryRegion *system_io = get_system_io();
> Object *phb = NULL;
> - PCIBus *pci_bus = NULL;
> ISABus *isa_bus;
> Object *piix4_pm = NULL;
> qemu_irq smi_irq;
> @@ -212,11 +211,10 @@ static void pc_init1(MachineState *machine,
> &error_fatal);
> sysbus_realize_and_unref(SYS_BUS_DEVICE(phb), &error_fatal);
>
> - pci_bus = PCI_BUS(qdev_get_child_bus(DEVICE(phb), "pci.0"));
> - pci_bus_map_irqs(pci_bus,
> + pcms->pcibus = PCI_BUS(qdev_get_child_bus(DEVICE(phb), "pci.0"));
> + pci_bus_map_irqs(pcms->pcibus,
> xen_enabled() ? xen_pci_slot_get_pirq
> : pc_pci_slot_get_pirq);
> - pcms->pcibus = pci_bus;
>
> hole64_size = object_property_get_uint(phb,
> PCI_HOST_PROP_PCI_HOLE64_SIZE,
> @@ -261,7 +259,7 @@ static void pc_init1(MachineState *machine,
> for (i = 0; i < ISA_NUM_IRQS; i++) {
> qdev_connect_gpio_out_named(dev, "isa-irqs", i, x86ms->gsi[i]);
> }
> - pci_realize_and_unref(pci_dev, pci_bus, &error_fatal);
> + pci_realize_and_unref(pci_dev, pcms->pcibus, &error_fatal);
>
> if (xen_enabled()) {
> pci_device_set_intx_routing_notifier(
> @@ -273,7 +271,7 @@ static void pc_init1(MachineState *machine,
> * connected to the IOAPIC directly.
> * These additional routes can be discovered through ACPI.
> */
> - pci_bus_irqs(pci_bus, xen_intx_set_irq, pci_dev,
> + pci_bus_irqs(pcms->pcibus, xen_intx_set_irq, pci_dev,
> XEN_IOAPIC_NUM_PIRQS);
> }
>
> @@ -310,7 +308,7 @@ static void pc_init1(MachineState *machine,
> x86_register_ferr_irq(x86ms->gsi[13]);
> }
>
> - pc_vga_init(isa_bus, pcmc->pci_enabled ? pci_bus : NULL);
> + pc_vga_init(isa_bus, pcmc->pci_enabled ? pcms->pcibus : NULL);
>
> assert(pcms->vmport != ON_OFF_AUTO__MAX);
> if (pcms->vmport == ON_OFF_AUTO_AUTO) {
> @@ -321,7 +319,7 @@ static void pc_init1(MachineState *machine,
> pc_basic_device_init(pcms, isa_bus, x86ms->gsi, rtc_state, true,
> 0x4);
>
> - pc_nic_init(pcmc, isa_bus, pci_bus);
> + pc_nic_init(pcmc, isa_bus, pcms->pcibus);
>
> #ifdef CONFIG_IDE_ISA
> if (!pcmc->pci_enabled) {
> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
> index 734d9bedb2..2fa4efb52f 100644
> --- a/hw/i386/pc_q35.c
> +++ b/hw/i386/pc_q35.c
> @@ -122,7 +122,6 @@ static void pc_q35_init(MachineState *machine)
> PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
> X86MachineState *x86ms = X86_MACHINE(machine);
> Object *phb;
> - PCIBus *host_bus;
> PCIDevice *lpc;
> DeviceState *lpc_dev;
> ISADevice *rtc_state;
> @@ -216,8 +215,7 @@ static void pc_q35_init(MachineState *machine)
> sysbus_realize_and_unref(SYS_BUS_DEVICE(phb), &error_fatal);
>
> /* pci */
> - host_bus = PCI_BUS(qdev_get_child_bus(DEVICE(phb), "pcie.0"));
> - pcms->pcibus = host_bus;
> + pcms->pcibus = PCI_BUS(qdev_get_child_bus(DEVICE(phb), "pcie.0"));
>
> /* irq lines */
> gsi_state = pc_gsi_create(&x86ms->gsi, true);
> @@ -231,7 +229,7 @@ static void pc_q35_init(MachineState *machine)
> 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);
> + pci_realize_and_unref(lpc, pcms->pcibus, &error_fatal);
>
> rtc_state = ISA_DEVICE(object_resolve_path_component(OBJECT(lpc), "rtc"));
>
> @@ -283,7 +281,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(host_bus,
> + pdev = pci_create_simple_multifunction(pcms->pcibus,
> PCI_DEVFN(ICH9_SATA1_DEV,
> ICH9_SATA1_FUNC),
> "ich9-ahci");
> @@ -297,14 +295,14 @@ static void pc_q35_init(MachineState *machine)
>
> if (machine_usb(machine)) {
> /* Should we create 6 UHCI according to ich9 spec? */
> - ehci_create_ich9_with_companions(host_bus, 0x1d);
> + ehci_create_ich9_with_companions(pcms->pcibus, 0x1d);
> }
>
> if (pcms->smbus_enabled) {
> PCIDevice *smb;
>
> /* TODO: Populate SPD eeprom data. */
> - smb = pci_create_simple_multifunction(host_bus,
> + smb = pci_create_simple_multifunction(pcms->pcibus,
> PCI_DEVFN(ICH9_SMB_DEV,
> ICH9_SMB_FUNC),
> TYPE_ICH9_SMB_DEVICE);
> @@ -316,8 +314,8 @@ static void pc_q35_init(MachineState *machine)
> pc_cmos_init(pcms, rtc_state);
>
> /* the rest devices to which pci devfn is automatically assigned */
> - pc_vga_init(isa_bus, host_bus);
> - pc_nic_init(pcmc, isa_bus, host_bus);
> + pc_vga_init(isa_bus, pcms->pcibus);
> + pc_nic_init(pcmc, isa_bus, pcms->pcibus);
>
> if (machine->nvdimms_state->is_enabled) {
> nvdimm_init_acpi_state(machine->nvdimms_state, system_io,
> --
> 2.44.0
>
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 4/6] hw/i386/pc: Remove unneeded class attribute "kvmclock_enabled"
2024-02-24 13:58 [PATCH v2 0/6] Simplify initialization of PC machines Bernhard Beschow
` (2 preceding siblings ...)
2024-02-24 13:58 ` [PATCH v2 3/6] hw/i386/pc_{piix, q35}: Eliminate local pci_bus/pci_host variables Bernhard Beschow
@ 2024-02-24 13:58 ` Bernhard Beschow
2024-02-25 16:32 ` Philippe Mathieu-Daudé
` (2 more replies)
2024-02-24 13:58 ` [PATCH v2 5/6] hw/i386/pc: Populate RTC attribute directly Bernhard Beschow
` (3 subsequent siblings)
7 siblings, 3 replies; 18+ messages in thread
From: Bernhard Beschow @ 2024-02-24 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: Ani Sinha, Michael S. Tsirkin, Philippe Mathieu-Daudé,
Eduardo Habkost, Marcel Apfelbaum, Richard Henderson,
Paolo Bonzini, Paul Durrant, Igor Mammedov, Jason Wang,
David Woodhouse, Sergio Lopez, Bernhard Beschow, Thomas Huth
PCMachineClass introduces the attribute into the class hierarchy and sets it to
true. There is no sub class overriding the attribute. Commit 30d2a17b46e9
"hw/i386: Remove the deprecated machines 0.12 up to 0.15" removed the last
overrides of this attribute. The attribute is now unneeded and can be removed.
Fixes: 30d2a17b46e9 "hw/i386: Remove the deprecated machines 0.12 up to 0.15"
Cc: Thomas Huth <thuth@redhat.com>
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
include/hw/i386/pc.h | 1 -
hw/i386/pc.c | 1 -
hw/i386/pc_piix.c | 2 +-
3 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 27834043c3..4bb1899602 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -92,7 +92,6 @@ struct PCMachineClass {
/* Device configuration: */
bool pci_enabled;
- bool kvmclock_enabled;
const char *default_south_bridge;
/* Compat options: */
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 353edeb2ea..a80f809b83 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1799,7 +1799,6 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
pcmc->smbios_uuid_encoded = true;
pcmc->gigabyte_align = true;
pcmc->has_reserved_memory = true;
- pcmc->kvmclock_enabled = true;
pcmc->enforce_aligned_dimm = true;
pcmc->enforce_amd_1tb_hole = true;
/* BIOS ACPI tables: 128K. Other BIOS datastructures: less than 4K reported
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 814d24326d..49d5d48db9 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -184,7 +184,7 @@ static void pc_init1(MachineState *machine,
pc_machine_init_sgx_epc(pcms);
x86_cpus_init(x86ms, pcmc->default_cpu_version);
- if (kvm_enabled() && pcmc->kvmclock_enabled) {
+ if (kvm_enabled()) {
kvmclock_create(pcmc->kvmclock_create_always);
}
--
2.44.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v2 4/6] hw/i386/pc: Remove unneeded class attribute "kvmclock_enabled"
2024-02-24 13:58 ` [PATCH v2 4/6] hw/i386/pc: Remove unneeded class attribute "kvmclock_enabled" Bernhard Beschow
@ 2024-02-25 16:32 ` Philippe Mathieu-Daudé
2024-02-26 6:14 ` Thomas Huth
2024-02-26 9:07 ` Zhao Liu
2 siblings, 0 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-02-25 16:32 UTC (permalink / raw)
To: Bernhard Beschow, qemu-devel
Cc: Ani Sinha, Michael S. Tsirkin, Eduardo Habkost, Marcel Apfelbaum,
Richard Henderson, Paolo Bonzini, Paul Durrant, Igor Mammedov,
Jason Wang, David Woodhouse, Sergio Lopez, Thomas Huth
On 24/2/24 14:58, Bernhard Beschow wrote:
> PCMachineClass introduces the attribute into the class hierarchy and sets it to
> true. There is no sub class overriding the attribute. Commit 30d2a17b46e9
> "hw/i386: Remove the deprecated machines 0.12 up to 0.15" removed the last
> overrides of this attribute. The attribute is now unneeded and can be removed.
>
> Fixes: 30d2a17b46e9 "hw/i386: Remove the deprecated machines 0.12 up to 0.15"
> Cc: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
> ---
> include/hw/i386/pc.h | 1 -
> hw/i386/pc.c | 1 -
> hw/i386/pc_piix.c | 2 +-
> 3 files changed, 1 insertion(+), 3 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 4/6] hw/i386/pc: Remove unneeded class attribute "kvmclock_enabled"
2024-02-24 13:58 ` [PATCH v2 4/6] hw/i386/pc: Remove unneeded class attribute "kvmclock_enabled" Bernhard Beschow
2024-02-25 16:32 ` Philippe Mathieu-Daudé
@ 2024-02-26 6:14 ` Thomas Huth
2024-02-26 9:07 ` Zhao Liu
2 siblings, 0 replies; 18+ messages in thread
From: Thomas Huth @ 2024-02-26 6:14 UTC (permalink / raw)
To: Bernhard Beschow, qemu-devel
Cc: Ani Sinha, Michael S. Tsirkin, Philippe Mathieu-Daudé,
Eduardo Habkost, Marcel Apfelbaum, Richard Henderson,
Paolo Bonzini, Paul Durrant, Igor Mammedov, Jason Wang,
David Woodhouse, Sergio Lopez
On 24/02/2024 14.58, Bernhard Beschow wrote:
> PCMachineClass introduces the attribute into the class hierarchy and sets it to
> true. There is no sub class overriding the attribute. Commit 30d2a17b46e9
> "hw/i386: Remove the deprecated machines 0.12 up to 0.15" removed the last
> overrides of this attribute. The attribute is now unneeded and can be removed.
>
> Fixes: 30d2a17b46e9 "hw/i386: Remove the deprecated machines 0.12 up to 0.15"
> Cc: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
> ---
> include/hw/i386/pc.h | 1 -
> hw/i386/pc.c | 1 -
> hw/i386/pc_piix.c | 2 +-
> 3 files changed, 1 insertion(+), 3 deletions(-)
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 4/6] hw/i386/pc: Remove unneeded class attribute "kvmclock_enabled"
2024-02-24 13:58 ` [PATCH v2 4/6] hw/i386/pc: Remove unneeded class attribute "kvmclock_enabled" Bernhard Beschow
2024-02-25 16:32 ` Philippe Mathieu-Daudé
2024-02-26 6:14 ` Thomas Huth
@ 2024-02-26 9:07 ` Zhao Liu
2 siblings, 0 replies; 18+ messages in thread
From: Zhao Liu @ 2024-02-26 9:07 UTC (permalink / raw)
To: Bernhard Beschow
Cc: qemu-devel, Ani Sinha, Michael S. Tsirkin,
Philippe Mathieu-Daudé, Eduardo Habkost, Marcel Apfelbaum,
Richard Henderson, Paolo Bonzini, Paul Durrant, Igor Mammedov,
Jason Wang, David Woodhouse, Sergio Lopez, Thomas Huth
On Sat, Feb 24, 2024 at 02:58:49PM +0100, Bernhard Beschow wrote:
> Date: Sat, 24 Feb 2024 14:58:49 +0100
> From: Bernhard Beschow <shentey@gmail.com>
> Subject: [PATCH v2 4/6] hw/i386/pc: Remove unneeded class attribute
> "kvmclock_enabled"
> X-Mailer: git-send-email 2.44.0
>
> PCMachineClass introduces the attribute into the class hierarchy and sets it to
> true. There is no sub class overriding the attribute. Commit 30d2a17b46e9
> "hw/i386: Remove the deprecated machines 0.12 up to 0.15" removed the last
> overrides of this attribute. The attribute is now unneeded and can be removed.
>
> Fixes: 30d2a17b46e9 "hw/i386: Remove the deprecated machines 0.12 up to 0.15"
> Cc: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
> ---
> include/hw/i386/pc.h | 1 -
> hw/i386/pc.c | 1 -
> hw/i386/pc_piix.c | 2 +-
> 3 files changed, 1 insertion(+), 3 deletions(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
>
> diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
> index 27834043c3..4bb1899602 100644
> --- a/include/hw/i386/pc.h
> +++ b/include/hw/i386/pc.h
> @@ -92,7 +92,6 @@ struct PCMachineClass {
>
> /* Device configuration: */
> bool pci_enabled;
> - bool kvmclock_enabled;
> const char *default_south_bridge;
>
> /* Compat options: */
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 353edeb2ea..a80f809b83 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -1799,7 +1799,6 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
> pcmc->smbios_uuid_encoded = true;
> pcmc->gigabyte_align = true;
> pcmc->has_reserved_memory = true;
> - pcmc->kvmclock_enabled = true;
> pcmc->enforce_aligned_dimm = true;
> pcmc->enforce_amd_1tb_hole = true;
> /* BIOS ACPI tables: 128K. Other BIOS datastructures: less than 4K reported
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index 814d24326d..49d5d48db9 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -184,7 +184,7 @@ static void pc_init1(MachineState *machine,
> pc_machine_init_sgx_epc(pcms);
> x86_cpus_init(x86ms, pcmc->default_cpu_version);
>
> - if (kvm_enabled() && pcmc->kvmclock_enabled) {
> + if (kvm_enabled()) {
> kvmclock_create(pcmc->kvmclock_create_always);
> }
>
> --
> 2.44.0
>
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 5/6] hw/i386/pc: Populate RTC attribute directly
2024-02-24 13:58 [PATCH v2 0/6] Simplify initialization of PC machines Bernhard Beschow
` (3 preceding siblings ...)
2024-02-24 13:58 ` [PATCH v2 4/6] hw/i386/pc: Remove unneeded class attribute "kvmclock_enabled" Bernhard Beschow
@ 2024-02-24 13:58 ` Bernhard Beschow
2024-02-26 9:11 ` Zhao Liu
2024-02-24 13:58 ` [PATCH v2 6/6] hw/i386/pc: Inline pc_cmos_init() into pc_cmos_init_late() and remove it Bernhard Beschow
` (2 subsequent siblings)
7 siblings, 1 reply; 18+ messages in thread
From: Bernhard Beschow @ 2024-02-24 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: Ani Sinha, Michael S. Tsirkin, Philippe Mathieu-Daudé,
Eduardo Habkost, Marcel Apfelbaum, Richard Henderson,
Paolo Bonzini, Paul Durrant, Igor Mammedov, Jason Wang,
David Woodhouse, Sergio Lopez, Bernhard Beschow
Both the piix and the q35 machines introduce an rtc_state variable and defer the
initialization of the X86MachineState::rtc attribute to pc_cmos_init(). Resolve
this complication which makes pc_cmos_init() do what it says on the tin.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/i386/pc.c | 8 --------
hw/i386/pc_piix.c | 15 +++++++--------
hw/i386/pc_q35.c | 7 +++----
3 files changed, 10 insertions(+), 20 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index a80f809b83..880e95de26 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -611,14 +611,6 @@ void pc_cmos_init(PCMachineState *pcms,
mc146818rtc_set_cmos_data(s, 0x5c, val >> 8);
mc146818rtc_set_cmos_data(s, 0x5d, val >> 16);
- object_property_add_link(OBJECT(pcms), "rtc_state",
- TYPE_ISA_DEVICE,
- (Object **)&x86ms->rtc,
- object_property_allow_set_link,
- OBJ_PROP_LINK_STRONG);
- object_property_set_link(OBJECT(pcms), "rtc_state", OBJECT(s),
- &error_abort);
-
set_boot_dev(s, MACHINE(pcms)->boot_config.order, &error_fatal);
val = 0;
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 49d5d48db9..ce6aad758d 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -112,7 +112,6 @@ static void pc_init1(MachineState *machine,
Object *piix4_pm = NULL;
qemu_irq smi_irq;
GSIState *gsi_state;
- ISADevice *rtc_state;
MemoryRegion *ram_memory;
MemoryRegion *pci_memory = NULL;
MemoryRegion *rom_memory = system_memory;
@@ -276,8 +275,8 @@ static void pc_init1(MachineState *machine,
}
isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(pci_dev), "isa.0"));
- rtc_state = ISA_DEVICE(object_resolve_path_component(OBJECT(pci_dev),
- "rtc"));
+ x86ms->rtc = ISA_DEVICE(object_resolve_path_component(OBJECT(pci_dev),
+ "rtc"));
piix4_pm = object_resolve_path_component(OBJECT(pci_dev), "pm");
dev = DEVICE(object_resolve_path_component(OBJECT(pci_dev), "ide"));
pci_ide_create_devs(PCI_DEVICE(dev));
@@ -288,9 +287,9 @@ static void pc_init1(MachineState *machine,
&error_abort);
isa_bus_register_input_irqs(isa_bus, x86ms->gsi);
- rtc_state = isa_new(TYPE_MC146818_RTC);
- qdev_prop_set_int32(DEVICE(rtc_state), "base_year", 2000);
- isa_realize_and_unref(rtc_state, isa_bus, &error_fatal);
+ x86ms->rtc = isa_new(TYPE_MC146818_RTC);
+ qdev_prop_set_int32(DEVICE(x86ms->rtc), "base_year", 2000);
+ isa_realize_and_unref(x86ms->rtc, isa_bus, &error_fatal);
i8257_dma_init(OBJECT(machine), isa_bus, 0);
pcms->hpet_enabled = false;
@@ -316,7 +315,7 @@ static void pc_init1(MachineState *machine,
}
/* init basic PC hardware */
- pc_basic_device_init(pcms, isa_bus, x86ms->gsi, rtc_state, true,
+ pc_basic_device_init(pcms, isa_bus, x86ms->gsi, x86ms->rtc, true,
0x4);
pc_nic_init(pcmc, isa_bus, pcms->pcibus);
@@ -343,7 +342,7 @@ static void pc_init1(MachineState *machine,
}
#endif
- pc_cmos_init(pcms, rtc_state);
+ pc_cmos_init(pcms, x86ms->rtc);
if (piix4_pm) {
smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0);
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 2fa4efb52f..e0b3f55a02 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -124,7 +124,6 @@ static void pc_q35_init(MachineState *machine)
Object *phb;
PCIDevice *lpc;
DeviceState *lpc_dev;
- ISADevice *rtc_state;
MemoryRegion *system_memory = get_system_memory();
MemoryRegion *system_io = get_system_io();
MemoryRegion *pci_memory = g_new(MemoryRegion, 1);
@@ -231,7 +230,7 @@ static void pc_q35_init(MachineState *machine)
}
pci_realize_and_unref(lpc, pcms->pcibus, &error_fatal);
- rtc_state = ISA_DEVICE(object_resolve_path_component(OBJECT(lpc), "rtc"));
+ x86ms->rtc = ISA_DEVICE(object_resolve_path_component(OBJECT(lpc), "rtc"));
object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
TYPE_HOTPLUG_HANDLER,
@@ -273,7 +272,7 @@ static void pc_q35_init(MachineState *machine)
}
/* init basic PC hardware */
- pc_basic_device_init(pcms, isa_bus, x86ms->gsi, rtc_state, !mc->no_floppy,
+ pc_basic_device_init(pcms, isa_bus, x86ms->gsi, x86ms->rtc, !mc->no_floppy,
0xff0104);
if (pcms->sata_enabled) {
@@ -311,7 +310,7 @@ static void pc_q35_init(MachineState *machine)
smbus_eeprom_init(pcms->smbus, 8, NULL, 0);
}
- pc_cmos_init(pcms, rtc_state);
+ pc_cmos_init(pcms, x86ms->rtc);
/* the rest devices to which pci devfn is automatically assigned */
pc_vga_init(isa_bus, pcms->pcibus);
--
2.44.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v2 5/6] hw/i386/pc: Populate RTC attribute directly
2024-02-24 13:58 ` [PATCH v2 5/6] hw/i386/pc: Populate RTC attribute directly Bernhard Beschow
@ 2024-02-26 9:11 ` Zhao Liu
0 siblings, 0 replies; 18+ messages in thread
From: Zhao Liu @ 2024-02-26 9:11 UTC (permalink / raw)
To: Bernhard Beschow
Cc: qemu-devel, Ani Sinha, Michael S. Tsirkin,
Philippe Mathieu-Daudé, Eduardo Habkost, Marcel Apfelbaum,
Richard Henderson, Paolo Bonzini, Paul Durrant, Igor Mammedov,
Jason Wang, David Woodhouse, Sergio Lopez
On Sat, Feb 24, 2024 at 02:58:50PM +0100, Bernhard Beschow wrote:
> Date: Sat, 24 Feb 2024 14:58:50 +0100
> From: Bernhard Beschow <shentey@gmail.com>
> Subject: [PATCH v2 5/6] hw/i386/pc: Populate RTC attribute directly
> X-Mailer: git-send-email 2.44.0
>
> Both the piix and the q35 machines introduce an rtc_state variable and defer the
> initialization of the X86MachineState::rtc attribute to pc_cmos_init(). Resolve
> this complication which makes pc_cmos_init() do what it says on the tin.
>
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> hw/i386/pc.c | 8 --------
> hw/i386/pc_piix.c | 15 +++++++--------
> hw/i386/pc_q35.c | 7 +++----
> 3 files changed, 10 insertions(+), 20 deletions(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
>
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index a80f809b83..880e95de26 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -611,14 +611,6 @@ void pc_cmos_init(PCMachineState *pcms,
> mc146818rtc_set_cmos_data(s, 0x5c, val >> 8);
> mc146818rtc_set_cmos_data(s, 0x5d, val >> 16);
>
> - object_property_add_link(OBJECT(pcms), "rtc_state",
> - TYPE_ISA_DEVICE,
> - (Object **)&x86ms->rtc,
> - object_property_allow_set_link,
> - OBJ_PROP_LINK_STRONG);
> - object_property_set_link(OBJECT(pcms), "rtc_state", OBJECT(s),
> - &error_abort);
> -
> set_boot_dev(s, MACHINE(pcms)->boot_config.order, &error_fatal);
>
> val = 0;
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index 49d5d48db9..ce6aad758d 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -112,7 +112,6 @@ static void pc_init1(MachineState *machine,
> Object *piix4_pm = NULL;
> qemu_irq smi_irq;
> GSIState *gsi_state;
> - ISADevice *rtc_state;
> MemoryRegion *ram_memory;
> MemoryRegion *pci_memory = NULL;
> MemoryRegion *rom_memory = system_memory;
> @@ -276,8 +275,8 @@ static void pc_init1(MachineState *machine,
> }
>
> isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(pci_dev), "isa.0"));
> - rtc_state = ISA_DEVICE(object_resolve_path_component(OBJECT(pci_dev),
> - "rtc"));
> + x86ms->rtc = ISA_DEVICE(object_resolve_path_component(OBJECT(pci_dev),
> + "rtc"));
> piix4_pm = object_resolve_path_component(OBJECT(pci_dev), "pm");
> dev = DEVICE(object_resolve_path_component(OBJECT(pci_dev), "ide"));
> pci_ide_create_devs(PCI_DEVICE(dev));
> @@ -288,9 +287,9 @@ static void pc_init1(MachineState *machine,
> &error_abort);
> isa_bus_register_input_irqs(isa_bus, x86ms->gsi);
>
> - rtc_state = isa_new(TYPE_MC146818_RTC);
> - qdev_prop_set_int32(DEVICE(rtc_state), "base_year", 2000);
> - isa_realize_and_unref(rtc_state, isa_bus, &error_fatal);
> + x86ms->rtc = isa_new(TYPE_MC146818_RTC);
> + qdev_prop_set_int32(DEVICE(x86ms->rtc), "base_year", 2000);
> + isa_realize_and_unref(x86ms->rtc, isa_bus, &error_fatal);
>
> i8257_dma_init(OBJECT(machine), isa_bus, 0);
> pcms->hpet_enabled = false;
> @@ -316,7 +315,7 @@ static void pc_init1(MachineState *machine,
> }
>
> /* init basic PC hardware */
> - pc_basic_device_init(pcms, isa_bus, x86ms->gsi, rtc_state, true,
> + pc_basic_device_init(pcms, isa_bus, x86ms->gsi, x86ms->rtc, true,
> 0x4);
>
> pc_nic_init(pcmc, isa_bus, pcms->pcibus);
> @@ -343,7 +342,7 @@ static void pc_init1(MachineState *machine,
> }
> #endif
>
> - pc_cmos_init(pcms, rtc_state);
> + pc_cmos_init(pcms, x86ms->rtc);
>
> if (piix4_pm) {
> smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0);
> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
> index 2fa4efb52f..e0b3f55a02 100644
> --- a/hw/i386/pc_q35.c
> +++ b/hw/i386/pc_q35.c
> @@ -124,7 +124,6 @@ static void pc_q35_init(MachineState *machine)
> Object *phb;
> PCIDevice *lpc;
> DeviceState *lpc_dev;
> - ISADevice *rtc_state;
> MemoryRegion *system_memory = get_system_memory();
> MemoryRegion *system_io = get_system_io();
> MemoryRegion *pci_memory = g_new(MemoryRegion, 1);
> @@ -231,7 +230,7 @@ static void pc_q35_init(MachineState *machine)
> }
> pci_realize_and_unref(lpc, pcms->pcibus, &error_fatal);
>
> - rtc_state = ISA_DEVICE(object_resolve_path_component(OBJECT(lpc), "rtc"));
> + x86ms->rtc = ISA_DEVICE(object_resolve_path_component(OBJECT(lpc), "rtc"));
>
> object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
> TYPE_HOTPLUG_HANDLER,
> @@ -273,7 +272,7 @@ static void pc_q35_init(MachineState *machine)
> }
>
> /* init basic PC hardware */
> - pc_basic_device_init(pcms, isa_bus, x86ms->gsi, rtc_state, !mc->no_floppy,
> + pc_basic_device_init(pcms, isa_bus, x86ms->gsi, x86ms->rtc, !mc->no_floppy,
> 0xff0104);
>
> if (pcms->sata_enabled) {
> @@ -311,7 +310,7 @@ static void pc_q35_init(MachineState *machine)
> smbus_eeprom_init(pcms->smbus, 8, NULL, 0);
> }
>
> - pc_cmos_init(pcms, rtc_state);
> + pc_cmos_init(pcms, x86ms->rtc);
>
> /* the rest devices to which pci devfn is automatically assigned */
> pc_vga_init(isa_bus, pcms->pcibus);
> --
> 2.44.0
>
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 6/6] hw/i386/pc: Inline pc_cmos_init() into pc_cmos_init_late() and remove it
2024-02-24 13:58 [PATCH v2 0/6] Simplify initialization of PC machines Bernhard Beschow
` (4 preceding siblings ...)
2024-02-24 13:58 ` [PATCH v2 5/6] hw/i386/pc: Populate RTC attribute directly Bernhard Beschow
@ 2024-02-24 13:58 ` Bernhard Beschow
2024-02-24 14:15 ` [PATCH v2 0/6] Simplify initialization of PC machines Bernhard Beschow
2024-02-26 17:42 ` Philippe Mathieu-Daudé
7 siblings, 0 replies; 18+ messages in thread
From: Bernhard Beschow @ 2024-02-24 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: Ani Sinha, Michael S. Tsirkin, Philippe Mathieu-Daudé,
Eduardo Habkost, Marcel Apfelbaum, Richard Henderson,
Paolo Bonzini, Paul Durrant, Igor Mammedov, Jason Wang,
David Woodhouse, Sergio Lopez, Bernhard Beschow
Now that pc_cmos_init() doesn't populate the X86MachineState::rtc attribute any
longer, its duties can be merged into pc_cmos_init_late() which is called within
machine_done notifier. This frees pc_piix and pc_q35 from explicit CMOS
initialization.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
include/hw/i386/pc.h | 2 --
hw/i386/pc.c | 10 ----------
hw/i386/pc_piix.c | 2 --
hw/i386/pc_q35.c | 2 --
4 files changed, 16 deletions(-)
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 4bb1899602..2b7c53d619 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -178,8 +178,6 @@ void pc_basic_device_init(struct PCMachineState *pcms,
ISADevice *rtc_state,
bool create_fdctrl,
uint32_t hpet_irqs);
-void pc_cmos_init(PCMachineState *pcms,
- ISADevice *s);
void pc_nic_init(PCMachineClass *pcmc, ISABus *isa_bus, PCIBus *pci_bus);
void pc_i8259_create(ISABus *isa_bus, qemu_irq *i8259_irqs);
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 880e95de26..fad4c54512 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -567,14 +567,6 @@ static void pc_cmos_init_late(PCMachineState *pcms)
mc146818rtc_set_cmos_data(s, 0x39, val);
pc_cmos_init_floppy(s, pc_find_fdc0());
-}
-
-void pc_cmos_init(PCMachineState *pcms,
- ISADevice *rtc)
-{
- int val;
- X86MachineState *x86ms = X86_MACHINE(pcms);
- MC146818RtcState *s = MC146818_RTC(rtc);
/* various important CMOS locations needed by PC/Bochs bios */
@@ -617,8 +609,6 @@ void pc_cmos_init(PCMachineState *pcms,
val |= 0x02; /* FPU is there */
val |= 0x04; /* PS/2 mouse installed */
mc146818rtc_set_cmos_data(s, REG_EQUIPMENT_BYTE, val);
-
- /* hard drives and FDC are handled by pc_cmos_init_late() */
}
static void handle_a20_line_change(void *opaque, int irq, int level)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index ce6aad758d..637f4d38be 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -342,8 +342,6 @@ static void pc_init1(MachineState *machine,
}
#endif
- pc_cmos_init(pcms, x86ms->rtc);
-
if (piix4_pm) {
smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0);
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index e0b3f55a02..df0a5f934c 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -310,8 +310,6 @@ static void pc_q35_init(MachineState *machine)
smbus_eeprom_init(pcms->smbus, 8, NULL, 0);
}
- pc_cmos_init(pcms, x86ms->rtc);
-
/* the rest devices to which pci devfn is automatically assigned */
pc_vga_init(isa_bus, pcms->pcibus);
pc_nic_init(pcmc, isa_bus, pcms->pcibus);
--
2.44.0
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v2 0/6] Simplify initialization of PC machines
2024-02-24 13:58 [PATCH v2 0/6] Simplify initialization of PC machines Bernhard Beschow
` (5 preceding siblings ...)
2024-02-24 13:58 ` [PATCH v2 6/6] hw/i386/pc: Inline pc_cmos_init() into pc_cmos_init_late() and remove it Bernhard Beschow
@ 2024-02-24 14:15 ` Bernhard Beschow
2024-02-26 17:42 ` Philippe Mathieu-Daudé
7 siblings, 0 replies; 18+ messages in thread
From: Bernhard Beschow @ 2024-02-24 14:15 UTC (permalink / raw)
To: qemu-devel
Cc: Ani Sinha, Michael S. Tsirkin, Philippe Mathieu-Daudé,
Eduardo Habkost, Marcel Apfelbaum, Richard Henderson,
Paolo Bonzini, Paul Durrant, Igor Mammedov, Jason Wang,
David Woodhouse, Sergio Lopez
Am 24. Februar 2024 13:58:45 UTC schrieb Bernhard Beschow <shentey@gmail.com>:
>The series aims to simplify the initialization process of all PC-based machines
>
>by streamlining redundant code.
>
>
>
>Since I haven't seen patches on the list so far for folding CMOS data
>
>generation into pc.c, which frees all PC machines from performing this duty
>
>explicitly, I've appended this cleanup as the last two patches.
>
>
>
>Testing done:
>
>* `make check`
>
The `boot-order-test` actually fails. We'd have to ignore the last patch for now.
Best regards,
Bernhard
>* `make check-avocado`
>
>* I'm sending this series from within a VM containing these changes.
>
>
>
>v2:
>
>* Rebase onto master, leaving only patches 1, 3, and 5
>
>* Patch 2: Rename "bus" attribute to "pcibus" (Phil)
>
>* Patch 4: Spotted while rebasing
>
>* Patch 6: New patch possible after [1]
>
>
>
>Best regards,
>
>Bernhard
>
>
>
>[1]
>
>https://patchew.org/QEMU/20240221211626.48190-1-philmd@linaro.org/20240221211626
>
>.48190-10-philmd@linaro.org/
>
>
>
>Bernhard Beschow (6):
>
> hw/i386/x86: Let ioapic_init_gsi() take parent as pointer
>
> hw/i386/pc: Rename "bus" attribute to "pcibus"
>
> hw/i386/pc_{piix,q35}: Eliminate local pci_bus/pci_host variables
>
> hw/i386/pc: Remove unneeded class attribute "kvmclock_enabled"
>
> hw/i386/pc: Populate RTC attribute directly
>
> hw/i386/pc: Inline pc_cmos_init() into pc_cmos_init_late() and remove
>
> it
>
>
>
> include/hw/i386/pc.h | 5 +----
>
> include/hw/i386/x86.h | 2 +-
>
> hw/i386/acpi-build.c | 2 +-
>
> hw/i386/amd_iommu.c | 2 +-
>
> hw/i386/intel_iommu.c | 2 +-
>
> hw/i386/kvm/xen_evtchn.c | 2 +-
>
> hw/i386/microvm.c | 2 +-
>
> hw/i386/pc.c | 27 ++++----------------------
>
> hw/i386/pc_piix.c | 42 +++++++++++++++++-----------------------
>
> hw/i386/pc_q35.c | 25 ++++++++++--------------
>
> hw/i386/x86-iommu.c | 2 +-
>
> hw/i386/x86.c | 7 +++----
>
> 12 files changed, 43 insertions(+), 77 deletions(-)
>
>
>
>-- >
>2.44.0
>
>
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 0/6] Simplify initialization of PC machines
2024-02-24 13:58 [PATCH v2 0/6] Simplify initialization of PC machines Bernhard Beschow
` (6 preceding siblings ...)
2024-02-24 14:15 ` [PATCH v2 0/6] Simplify initialization of PC machines Bernhard Beschow
@ 2024-02-26 17:42 ` Philippe Mathieu-Daudé
7 siblings, 0 replies; 18+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-02-26 17:42 UTC (permalink / raw)
To: Bernhard Beschow, qemu-devel
Cc: Ani Sinha, Michael S. Tsirkin, Eduardo Habkost, Marcel Apfelbaum,
Richard Henderson, Paolo Bonzini, Paul Durrant, Igor Mammedov,
Jason Wang, David Woodhouse, Sergio Lopez
On 24/2/24 14:58, Bernhard Beschow wrote:
> The series aims to simplify the initialization process of all PC-based machines
> by streamlining redundant code.
> Bernhard Beschow (6):
> hw/i386/x86: Let ioapic_init_gsi() take parent as pointer
> hw/i386/pc: Rename "bus" attribute to "pcibus"
> hw/i386/pc_{piix,q35}: Eliminate local pci_bus/pci_host variables
> hw/i386/pc: Remove unneeded class attribute "kvmclock_enabled"
> hw/i386/pc: Populate RTC attribute directly
Patches 1-5 queued, thanks!
^ permalink raw reply [flat|nested] 18+ messages in thread