hw/sysbus/platform-bus: Introduce TYPE_DYNAMIC_SYS_BUS_DEVICE
cover hw/sysbus/platform-bus: Introduce TYPE_DYNAMIC_SYS_BUS_DEVICE
Some SysBus devices can optionally be dynamically plugged onto the sysbus-platform-bus (then virtual guests are aware of mmio mapping and IRQs via device tree / ACPI rules).
This series makes these devices explicit by having them implement the DYNAMIC_SYS_BUS_DEVICE class, which only sets 'user_creatable' flag to %true but makes the codebase a bit clearer (IMHO, at least now we can grep for DYNAMIC_SYS_BUS_DEVICE).
Philippe Mathieu-Daudé (9):
hw/sysbus: Use sizeof(BusState) in main_system_bus_create() hw/sysbus: Declare QOM types using DEFINE_TYPES() macro hw/sysbus: Introduce TYPE_DYNAMIC_SYS_BUS_DEVICE
hw/vfio: Have VFIO_PLATFORM devices inherit from
DYNAMIC_SYS_BUS_DEVICE
hw/display: Have RAMFB device inherit from DYNAMIC_SYS_BUS_DEVICE hw/i386: Have X86_IOMMU devices inherit from DYNAMIC_SYS_BUS_DEVICE hw/net: Have eTSEC device inherit from DYNAMIC_SYS_BUS_DEVICE hw/tpm: Have TPM TIS sysbus device inherit from DYNAMIC_SYS_BUS_DEVICE hw/xen: Have legacy Xen backend inherit from DYNAMIC_SYS_BUS_DEVICE
include/hw/sysbus.h | 2 ++ include/hw/xen/xen_pvdev.h | 3 +- hw/core/sysbus.c | 53 ++++++++++++++++++++--------------- hw/display/ramfb-standalone.c | 3 +- hw/i386/amd_iommu.c | 2 -- hw/i386/intel_iommu.c | 2 -- hw/i386/x86-iommu.c | 2 +- hw/net/fsl_etsec/etsec.c | 4 +-- hw/tpm/tpm_tis_sysbus.c | 3 +- hw/vfio/amd-xgbe.c | 2 -- hw/vfio/calxeda-xgmac.c | 2 -- hw/vfio/platform.c | 4 +-- hw/xen/xen-legacy-backend.c | 7 ++--- 13 files changed, 42 insertions(+), 47 deletions(-)
Signature · 1 line
2.47.1
PATCH 1/9 hw/sysbus: Use sizeof(BusState) in main_system_bus_create()
Rather than using the obscure system_bus_info.instance_size, directly use sizeof(BusState).
--- hw/core/sysbus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/core/sysbus.c +2 -2
@@ -323,8 +323,8 @@ static void main_system_bus_create(void)* assign main_system_bus before qbus_init() * in order to make "if (bus != sysbus_get_default())" work */ - main_system_bus =g_malloc0 (system_bus_info.instance_size); -qbus_init (main_system_bus, system_bus_info.instance_size, + main_system_bus =g_new0 (BusState,1 ); +qbus_init (main_system_bus,sizeof (BusState),TYPE_SYSTEM_BUS ,NULL ,"main-system-bus" );OBJECT (main_system_bus)->free = g_free; }
Signature · 1 line
2.47.1
Re: [PATCH 1/9] hw/sysbus: Use sizeof(BusState) in main_system_bus_create()
Quoted 7 lines · Philippe Mathieu-Daudé
Rather than using the obscure system_bus_info.instance_size, directly use sizeof(BusState).
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/core/sysbus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Nice.
r~
Re: [PATCH 1/9] hw/sysbus: Use sizeof(BusState) in main_system_bus_create()
In reply to Philippe Mathieu-DaudéQuoted 29 lines · Philippe Mathieu-Daudé
Caution: External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe.
Rather than using the obscure system_bus_info.instance_size, directly use sizeof(BusState).
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/core/sysbus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/core/sysbus.c +2
-3@@ -323,8 +323,8 @@ static void main_system_bus_create(void)* assign main_system_bus before qbus_init() * in order to make "if (bus != sysbus_get_default())" work */ - main_system_bus =g_malloc0 (system_bus_info.instance_size); -qbus_init (main_system_bus, system_bus_info.instance_size, + main_system_bus =g_new0 (BusState,1 ); +qbus_init (main_system_bus,sizeof (BusState),TYPE_SYSTEM_BUS ,NULL ,"main-system-bus" );OBJECT (main_system_bus)->free = g_free; } --2.47.1
PATCH 2/9 hw/sysbus: Declare QOM types using DEFINE_TYPES() macro
In reply to Philippe Mathieu-DaudéWhen multiple QOM types are registered in the same file, it is simpler to use the the DEFINE_TYPES() macro. In particular because type array declared with such macro are easier to review.
--- hw/core/sysbus.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-)
hw/core/sysbus.c +17 -22
@@ -80,13 +80,6 @@ static void system_bus_class_init(ObjectClass *klass, void *data) k->get_fw_dev_path = sysbus_get_fw_dev_path; } -static const TypeInfo system_bus_info = { - .name =TYPE_SYSTEM_BUS , - .parent =TYPE_BUS , - .instance_size =sizeof (BusState), - .class_init = system_bus_class_init, -}; -/* Check whether an IRQ source exists */ bool sysbus_has_irq (SysBusDevice *dev,int n) {
@@ -306,15 +299,6 @@ static void sysbus_device_class_init(ObjectClass *klass, void *data) k->user_creatable = false; } -static const TypeInfo sysbus_device_type_info = { - .name =TYPE_SYS_BUS_DEVICE , - .parent =TYPE_DEVICE , - .instance_size =sizeof (SysBusDevice), - .abstract = true, - .class_size =sizeof (SysBusDeviceClass), - .class_init = sysbus_device_class_init, -}; -static BusState *main_system_bus;static void main_system_bus_create (void )
@@ -337,10 +321,21 @@ BusState *sysbus_get_default(void)return main_system_bus; } -static void sysbus_register_types (void ) -{ -type_register_static (&system_bus_info); -type_register_static (&sysbus_device_type_info); -} +static const TypeInfo sysbus_types[] = { + { + .name =TYPE_SYSTEM_BUS , + .parent =TYPE_BUS , + .instance_size =sizeof (BusState), + .class_init = system_bus_class_init, + }, + { + .name =TYPE_SYS_BUS_DEVICE , + .parent =TYPE_DEVICE , + .instance_size =sizeof (SysBusDevice), + .abstract = true, + .class_size =sizeof (SysBusDeviceClass), + .class_init = sysbus_device_class_init, + }, +}; -type_init (sysbus_register_types) +DEFINE_TYPES (sysbus_types)
Signature · 1 line
2.47.1
Re: [PATCH 2/9] hw/sysbus: Declare QOM types using DEFINE_TYPES() macro
Quoted 9 lines · Philippe Mathieu-Daudé
When multiple QOM types are registered in the same file, it is simpler to use the the
DEFINE_TYPES()macro. In particular because type array declared with such macro are easier to review.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- hw/core/sysbus.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-)
r~
Re: [PATCH 2/9] hw/sysbus: Declare QOM types using DEFINE_TYPES() macro
In reply to Philippe Mathieu-DaudéQuoted 78 lines · Philippe Mathieu-Daudé
Caution: External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe.
When multiple QOM types are registered in the same file, it is simpler to use the the
DEFINE_TYPES()macro. In particular because type array declared with such macro are easier to review.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/core/sysbus.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-)hw/core/sysbus.c +17
-23@@ -80,13 +80,6 @@ static void system_bus_class_init(ObjectClass *klass, void *data) k->get_fw_dev_path = sysbus_get_fw_dev_path; } -static const TypeInfo system_bus_info = { - .name =TYPE_SYSTEM_BUS , - .parent =TYPE_BUS , - .instance_size =sizeof (BusState), - .class_init = system_bus_class_init, -}; -/* Check whether an IRQ source exists */ bool sysbus_has_irq (SysBusDevice *dev,int n) {@@ -306,15 +299,6 @@ static void sysbus_device_class_init(ObjectClass *klass, void *data) k->user_creatable = false; } -static const TypeInfo sysbus_device_type_info = { - .name =TYPE_SYS_BUS_DEVICE , - .parent =TYPE_DEVICE , - .instance_size =sizeof (SysBusDevice), - .abstract = true, - .class_size =sizeof (SysBusDeviceClass), - .class_init = sysbus_device_class_init, -}; -static BusState *main_system_bus;static void main_system_bus_create (void )@@ -337,10 +321,21 @@ BusState *sysbus_get_default(void)return main_system_bus; } -static void sysbus_register_types (void ) -{ -type_register_static (&system_bus_info); -type_register_static (&sysbus_device_type_info); -} +static const TypeInfo sysbus_types[] = { + { + .name =TYPE_SYSTEM_BUS , + .parent =TYPE_BUS , + .instance_size =sizeof (BusState), + .class_init = system_bus_class_init, + }, + { + .name =TYPE_SYS_BUS_DEVICE , + .parent =TYPE_DEVICE , + .instance_size =sizeof (SysBusDevice), + .abstract = true, + .class_size =sizeof (SysBusDeviceClass), + .class_init = sysbus_device_class_init, + }, +}; -type_init (sysbus_register_types) +DEFINE_TYPES (sysbus_types) --2.47.1
Re: [PATCH 2/9] hw/sysbus: Declare QOM types using DEFINE_TYPES() macro
In reply to Philippe Mathieu-DaudéAm 25. Januar 2025 18:13:36 UTC schrieb "Philippe Mathieu-Daudé" <[email protected]>:
Quoted 62 lines
When multiple QOM types are registered in the same file, it is simpler to use the the
DEFINE_TYPES()macro. In particular because type array declared with such macro are easier to review.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
hw/core/sysbus.c| 39 +++++++++++++++++----------------------1 file changed, 17 insertions(+), 22 deletions(-)hw/core/sysbus.c +9
-21@@ -80,13 +80,6 @@ static void system_bus_class_init(ObjectClass *klass, void *data) k->get_fw_dev_path = sysbus_get_fw_dev_path; } -static const TypeInfo system_bus_info = { - .name =TYPE_SYSTEM_BUS , - .parent =TYPE_BUS , - .instance_size =sizeof (BusState), - .class_init = system_bus_class_init, -}; -/* Check whether an IRQ source exists */ bool sysbus_has_irq (SysBusDevice *dev,int n) {@@ -306,15 +299,6 @@ static void sysbus_device_class_init(ObjectClass *klass, void *data) k->user_creatable = false; } -static const TypeInfo sysbus_device_type_info = { - .name =TYPE_SYS_BUS_DEVICE , - .parent =TYPE_DEVICE , - .instance_size =sizeof (SysBusDevice), - .abstract = true, - .class_size =sizeof (SysBusDeviceClass), - .class_init = sysbus_device_class_init, -}; -static BusState *main_system_bus;static void main_system_bus_create (void )@@ -337,10 +321,21 @@ BusState *sysbus_get_default(void)return main_system_bus; } -static void sysbus_register_types (void ) -{ -type_register_static (&system_bus_info); -type_register_static (&sysbus_device_type_info); -} +static const TypeInfo sysbus_types[] = { + { + .name =TYPE_SYSTEM_BUS , + .parent =TYPE_BUS , + .instance_size =sizeof (BusState), + .class_init = system_bus_class_init, + }, + { + .name =TYPE_SYS_BUS_DEVICE ,
hw/core/sysbus.c BusState *sysbus_get_default(void) · line 341
Quoted 10 lines
hw/core/sysbus.c +8
-1+ .parent = TYPE_DEVICE, + .instance_size = sizeof(SysBusDevice), + .abstract = true, + .class_size = sizeof(SysBusDeviceClass), + .class_init = sysbus_device_class_init, + }, +}; -type_init (sysbus_register_types) +DEFINE_TYPES (sysbus_types)
Can now omit the "qom/module.h" include. With that changed:
PATCH 3/9 hw/sysbus: Introduce TYPE_DYNAMIC_SYS_BUS_DEVICE
In reply to Philippe Mathieu-DaudéSome TYPE_SYS_BUS_DEVICEs can be optionally dynamically plugged on the TYPE_PLATFORM_BUS_DEVICE.
Rather than sometimes noting that with comment around the 'user_creatable = true' line in each DeviceRealize handler, introduce an abstract TYPE_DYNAMIC_SYS_BUS_DEVICE class.
--- include/hw/sysbus.h | 2 ++ hw/core/sysbus.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+)
include/hw/sysbus.h +2 -0
@@ -19,6 +19,8 @@ DECLARE_INSTANCE_CHECKER(BusState, SYSTEM_BUS,OBJECT_DECLARE_TYPE (SysBusDevice, SysBusDeviceClass, SYS_BUS_DEVICE) +#define TYPE_DYNAMIC_SYS_BUS_DEVICE "dynamic-sysbus-device" +/** * SysBusDeviceClass: *
hw/core/sysbus.c +14 -0
@@ -321,6 +321,14 @@ BusState *sysbus_get_default(void)return main_system_bus; } +static void dynamic_sysbus_device_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *k =DEVICE_CLASS (klass); + + k->user_creatable = true; + k->hotpluggable = false; +} +static const TypeInfo sysbus_types[] = { { .name =TYPE_SYSTEM_BUS ,
@@ -336,6 +344,12 @@ static const TypeInfo sysbus_types[] = { .class_size = sizeof(SysBusDeviceClass), .class_init = sysbus_device_class_init, }, + { + .name = TYPE_DYNAMIC_SYS_BUS_DEVICE, + .parent = TYPE_SYS_BUS_DEVICE, + .class_init = dynamic_sysbus_device_class_init, + .abstract = true, + } };DEFINE_TYPES (sysbus_types)
Signature · 1 line
2.47.1
Re: [PATCH 3/9] hw/sysbus: Introduce TYPE_DYNAMIC_SYS_BUS_DEVICE
Quoted 7 lines · Philippe Mathieu-Daudé
Some
TYPE_SYS_BUS_DEVICEscan be optionally dynamically plugged on theTYPE_PLATFORM_BUS_DEVICE.
Rather than sometimes noting that with comment around the 'user_creatable= true' line in each DeviceRealize handler, introduce an abstractTYPE_DYNAMIC_SYS_BUS_DEVICEclass.
Quoted 5 lines
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- include/hw/sysbus.h | 2 ++ hw/core/sysbus.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+)
r~
Re: [PATCH 3/9] hw/sysbus: Introduce TYPE_DYNAMIC_SYS_BUS_DEVICE
In reply to Philippe Mathieu-DaudéQuoted 64 lines · Philippe Mathieu-Daudé
Caution: External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe.
Some
TYPE_SYS_BUS_DEVICEscan be optionally dynamically plugged on theTYPE_PLATFORM_BUS_DEVICE.
Rather than sometimes noting that with comment around the 'user_creatable= true' line in each DeviceRealize handler, introduce an abstractTYPE_DYNAMIC_SYS_BUS_DEVICEclass.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/sysbus.h | 2 ++ hw/core/sysbus.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+)include/hw/sysbus.h +2
-0@@ -19,6 +19,8 @@ DECLARE_INSTANCE_CHECKER(BusState, SYSTEM_BUS,OBJECT_DECLARE_TYPE (SysBusDevice, SysBusDeviceClass, SYS_BUS_DEVICE) +#define TYPE_DYNAMIC_SYS_BUS_DEVICE "dynamic-sysbus-device" +/** * SysBusDeviceClass: * hw/core/sysbus.c +14
-1@@ -321,6 +321,14 @@ BusState *sysbus_get_default(void)return main_system_bus; } +static void dynamic_sysbus_device_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *k =DEVICE_CLASS (klass); + + k->user_creatable = true; + k->hotpluggable = false; +} +static const TypeInfo sysbus_types[] = { { .name =TYPE_SYSTEM_BUS ,@@ -336,6 +344,12 @@ static const TypeInfo sysbus_types[] = { .class_size = sizeof(SysBusDeviceClass), .class_init = sysbus_device_class_init, }, + { + .name = TYPE_DYNAMIC_SYS_BUS_DEVICE, + .parent = TYPE_SYS_BUS_DEVICE, + .class_init = dynamic_sysbus_device_class_init, + .abstract = true, + } };DEFINE_TYPES (sysbus_types) --2.47.1
PATCH 4/9 hw/vfio: Have VFIO_PLATFORM devices inherit from DYNAMIC_SYS_BUS_DEVICE
In reply to Philippe Mathieu-DaudéDo not explain why VFIO_PLATFORM devices are user_creatable, have them inherit TYPE_DYNAMIC_SYS_BUS_DEVICE, to explicit they can optionally be plugged on TYPE_PLATFORM_BUS_DEVICE.
--- hw/vfio/amd-xgbe.c | 2 -- hw/vfio/calxeda-xgmac.c | 2 -- hw/vfio/platform.c | 4 +--- 3 files changed, 1 insertion(+), 7 deletions(-)
hw/vfio/amd-xgbe.c +0 -2
@@ -41,8 +41,6 @@ static void vfio_amd_xgbe_class_init(ObjectClass *klass, void *data) &vcxc->parent_realize); dc->desc ="VFIO AMD XGBE" ; dc->vmsd = &vfio_platform_amd_xgbe_vmstate; -/* Supported by TYPE_VIRT_MACHINE */ - dc->user_creatable = true; }static const TypeInfo vfio_amd_xgbe_dev_info = {
hw/vfio/calxeda-xgmac.c +0 -2
@@ -41,8 +41,6 @@ static void vfio_calxeda_xgmac_class_init(ObjectClass *klass, void *data) &vcxc->parent_realize); dc->desc ="VFIO Calxeda XGMAC" ; dc->vmsd = &vfio_platform_calxeda_xgmac_vmstate; -/* Supported by TYPE_VIRT_MACHINE */ - dc->user_creatable = true; }static const TypeInfo vfio_calxeda_xgmac_dev_info = {
hw/vfio/platform.c +1 -3
@@ -672,13 +672,11 @@ static void vfio_platform_class_init(ObjectClass *klass, void *data) dc->desc ="VFIO-based platform device assignment" ; sbc->connect_irq_notifier = vfio_start_irqfd_injection;set_bit (DEVICE_CATEGORY_MISC , dc->categories); -/* Supported by TYPE_VIRT_MACHINE */ - dc->user_creatable = true; }static const TypeInfo vfio_platform_dev_info = { .name =TYPE_VFIO_PLATFORM , - .parent =TYPE_SYS_BUS_DEVICE , + .parent =TYPE_DYNAMIC_SYS_BUS_DEVICE , .instance_size =sizeof (VFIOPlatformDevice), .instance_init = vfio_platform_instance_init, .class_init = vfio_platform_class_init,
Signature · 1 line
2.47.1
Re: [PATCH 4/9] hw/vfio: Have VFIO_PLATFORM devices inherit from DYNAMIC_SYS_BUS_DEVICE
Quoted 3 lines · Philippe Mathieu-Daudé
Do not explain why
VFIO_PLATFORMdevices areuser_creatable, have them inheritTYPE_DYNAMIC_SYS_BUS_DEVICE, to explicit they can optionally be plugged onTYPE_PLATFORM_BUS_DEVICE.
to make it explicit that they can be
r~
PATCH 5/9 hw/display: Have RAMFB device inherit from DYNAMIC_SYS_BUS_DEVICE
In reply to Philippe Mathieu-DaudéBecause the RAM FB device can be optionally plugged on the TYPE_PLATFORM_BUS_DEVICE, have it inherit TYPE_DYNAMIC_SYS_BUS_DEVICE.
--- hw/display/ramfb-standalone.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
hw/display/ramfb-standalone.c +1 -2
@@ -72,13 +72,12 @@ static void ramfb_class_initfn(ObjectClass *klass, void *data) dc->vmsd = &ramfb_dev_vmstate; dc->realize = ramfb_realizefn; dc->desc ="ram framebuffer standalone device" ; - dc->user_creatable = true;device_class_set_props (dc, ramfb_properties); }static const TypeInfo ramfb_info = { .name =TYPE_RAMFB_DEVICE , - .parent =TYPE_SYS_BUS_DEVICE , + .parent =TYPE_DYNAMIC_SYS_BUS_DEVICE , .instance_size =sizeof (RAMFBStandaloneState), .class_init = ramfb_class_initfn, };
Signature · 1 line
2.47.1
Re: [PATCH 5/9] hw/display: Have RAMFB device inherit from DYNAMIC_SYS_BUS_DEVICE
Quoted 7 lines · Philippe Mathieu-Daudé
Because the RAM FB device can be optionally plugged on the
TYPE_PLATFORM_BUS_DEVICE, have it inheritTYPE_DYNAMIC_SYS_BUS_DEVICE.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/display/ramfb-standalone.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
r~
Re: [PATCH 5/9] hw/display: Have RAMFB device inherit from DYNAMIC_SYS_BUS_DEVICE
In reply to Philippe Mathieu-DaudéQuoted 33 lines · Philippe Mathieu-Daudé
Caution: External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe.
Because the RAM FB device can be optionally plugged on the
TYPE_PLATFORM_BUS_DEVICE, have it inheritTYPE_DYNAMIC_SYS_BUS_DEVICE.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/display/ramfb-standalone.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)hw/display/ramfb-standalone.c +1
-3@@ -72,13 +72,12 @@ static void ramfb_class_initfn(ObjectClass *klass, void *data) dc->vmsd = &ramfb_dev_vmstate; dc->realize = ramfb_realizefn; dc->desc ="ram framebuffer standalone device" ; - dc->user_creatable = true;device_class_set_props (dc, ramfb_properties); }static const TypeInfo ramfb_info = { .name =TYPE_RAMFB_DEVICE , - .parent =TYPE_SYS_BUS_DEVICE , + .parent =TYPE_DYNAMIC_SYS_BUS_DEVICE , .instance_size =sizeof (RAMFBStandaloneState), .class_init = ramfb_class_initfn, }; --2.47.1
PATCH 6/9 hw/i386: Have X86_IOMMU devices inherit from DYNAMIC_SYS_BUS_DEVICE
In reply to Philippe Mathieu-DaudéDo not explain why _X86_IOMMU devices are user_creatable, have them inherit TYPE_DYNAMIC_SYS_BUS_DEVICE, to explicit they can optionally be plugged on TYPE_PLATFORM_BUS_DEVICE.
--- hw/i386/amd_iommu.c | 2 -- hw/i386/intel_iommu.c | 2 -- hw/i386/x86-iommu.c | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-)
hw/i386/amd_iommu.c +0 -2
@@ -1687,8 +1687,6 @@ static void amdvi_sysbus_class_init(ObjectClass *klass, void *data) dc->hotpluggable = false; dc_class->realize = amdvi_sysbus_realize; dc_class->int_remap = amdvi_int_remap; -/* Supported by the pc-q35-* machine types */ - dc->user_creatable = true;set_bit (DEVICE_CATEGORY_MISC , dc->categories); dc->desc ="AMD IOMMU (AMD-Vi) DMA Remapping device" ;device_class_set_props (dc, amdvi_properties);
hw/i386/intel_iommu.c +0 -2
@@ -4871,8 +4871,6 @@ static void vtd_class_init(ObjectClass *klass, void *data) dc->hotpluggable = false; x86_class->realize = vtd_realize; x86_class->int_remap = vtd_int_remap; -/* Supported by the pc-q35-* machine types */ - dc->user_creatable = true;set_bit (DEVICE_CATEGORY_MISC , dc->categories); dc->desc ="Intel IOMMU (VT-d) DMA Remapping device" ; }
hw/i386/x86-iommu.c +1 -1
@@ -146,7 +146,7 @@ bool x86_iommu_ir_supported(X86IOMMUState *s)static const TypeInfo x86_iommu_info = { .name =TYPE_X86_IOMMU_DEVICE , - .parent =TYPE_SYS_BUS_DEVICE , + .parent =TYPE_DYNAMIC_SYS_BUS_DEVICE , .instance_size =sizeof (X86IOMMUState), .class_init = x86_iommu_class_init, .class_size =sizeof (X86IOMMUClass),
Signature · 1 line
2.47.1
Re: [PATCH 6/9] hw/i386: Have X86_IOMMU devices inherit from DYNAMIC_SYS_BUS_DEVICE
Quoted 10 lines · Philippe Mathieu-Daudé
Do not explain why
_X86_IOMMUdevices areuser_creatable, have them inheritTYPE_DYNAMIC_SYS_BUS_DEVICE, to explicit they can optionally be plugged onTYPE_PLATFORM_BUS_DEVICE.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- hw/i386/amd_iommu.c | 2 -- hw/i386/intel_iommu.c | 2 -- hw/i386/x86-iommu.c | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-)
r~
Re: [PATCH 6/9] hw/i386: Have X86_IOMMU devices inherit from DYNAMIC_SYS_BUS_DEVICE
In reply to Philippe Mathieu-DaudéThanks phil
Quoted 56 lines · Philippe Mathieu-Daudé
Caution: External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe.
Do not explain why
_X86_IOMMUdevices areuser_creatable, have them inheritTYPE_DYNAMIC_SYS_BUS_DEVICE, to explicit they can optionally be plugged onTYPE_PLATFORM_BUS_DEVICE.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/i386/amd_iommu.c | 2 -- hw/i386/intel_iommu.c | 2 -- hw/i386/x86-iommu.c | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-)hw/i386/amd_iommu.c +0
-2@@ -1687,8 +1687,6 @@ static void amdvi_sysbus_class_init(ObjectClass *klass, void *data) dc->hotpluggable = false; dc_class->realize = amdvi_sysbus_realize; dc_class->int_remap = amdvi_int_remap; -/* Supported by the pc-q35-* machine types */ - dc->user_creatable = true;set_bit (DEVICE_CATEGORY_MISC , dc->categories); dc->desc ="AMD IOMMU (AMD-Vi) DMA Remapping device" ;device_class_set_props (dc, amdvi_properties);hw/i386/intel_iommu.c +0
-2@@ -4871,8 +4871,6 @@ static void vtd_class_init(ObjectClass *klass, void *data) dc->hotpluggable = false; x86_class->realize = vtd_realize; x86_class->int_remap = vtd_int_remap; -/* Supported by the pc-q35-* machine types */ - dc->user_creatable = true;set_bit (DEVICE_CATEGORY_MISC , dc->categories); dc->desc ="Intel IOMMU (VT-d) DMA Remapping device" ; }hw/i386/x86-iommu.c +1
-2@@ -146,7 +146,7 @@ bool x86_iommu_ir_supported(X86IOMMUState *s)static const TypeInfo x86_iommu_info = { .name =TYPE_X86_IOMMU_DEVICE , - .parent =TYPE_SYS_BUS_DEVICE , + .parent =TYPE_DYNAMIC_SYS_BUS_DEVICE , .instance_size =sizeof (X86IOMMUState), .class_init = x86_iommu_class_init, .class_size =sizeof (X86IOMMUClass), --2.47.1
PATCH 7/9 hw/net: Have eTSEC device inherit from DYNAMIC_SYS_BUS_DEVICE
In reply to Philippe Mathieu-DaudéBecause the network eTSEC device can be optionally plugged on the TYPE_PLATFORM_BUS_DEVICE, have it inherit TYPE_DYNAMIC_SYS_BUS_DEVICE.
--- hw/net/fsl_etsec/etsec.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
hw/net/fsl_etsec/etsec.c +1 -3
@@ -425,14 +425,12 @@ static void etsec_class_init(ObjectClass *klass, void *data) dc->realize = etsec_realize;device_class_set_legacy_reset (dc, etsec_reset);device_class_set_props (dc, etsec_properties); -/* Supported by ppce500 machine */ - dc->user_creatable = true; }static const TypeInfo etsec_types[] = { { .name =TYPE_ETSEC_COMMON , - .parent =TYPE_SYS_BUS_DEVICE , + .parent =TYPE_DYNAMIC_SYS_BUS_DEVICE , .instance_size =sizeof (eTSEC), .class_init = etsec_class_init, .instance_init = etsec_instance_init,
Signature · 1 line
2.47.1
Re: [PATCH 7/9] hw/net: Have eTSEC device inherit from DYNAMIC_SYS_BUS_DEVICE
Quoted 7 lines · Philippe Mathieu-Daudé
Because the network eTSEC device can be optionally plugged on the
TYPE_PLATFORM_BUS_DEVICE, have it inheritTYPE_DYNAMIC_SYS_BUS_DEVICE.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/net/fsl_etsec/etsec.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
r~
Re: [PATCH 7/9] hw/net: Have eTSEC device inherit from DYNAMIC_SYS_BUS_DEVICE
In reply to Philippe Mathieu-DaudéQuoted 34 lines · Philippe Mathieu-Daudé
Caution: External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe.
Because the network eTSEC device can be optionally plugged on the
TYPE_PLATFORM_BUS_DEVICE, have it inheritTYPE_DYNAMIC_SYS_BUS_DEVICE.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/net/fsl_etsec/etsec.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)hw/net/fsl_etsec/etsec.c +1
-4@@ -425,14 +425,12 @@ static void etsec_class_init(ObjectClass *klass, void *data) dc->realize = etsec_realize;device_class_set_legacy_reset (dc, etsec_reset);device_class_set_props (dc, etsec_properties); -/* Supported by ppce500 machine */ - dc->user_creatable = true; }static const TypeInfo etsec_types[] = { { .name =TYPE_ETSEC_COMMON , - .parent =TYPE_SYS_BUS_DEVICE , + .parent =TYPE_DYNAMIC_SYS_BUS_DEVICE , .instance_size =sizeof (eTSEC), .class_init = etsec_class_init, .instance_init = etsec_instance_init, --2.47.1
Re: [PATCH 7/9] hw/net: Have eTSEC device inherit from DYNAMIC_SYS_BUS_DEVICE
In reply to Philippe Mathieu-DaudéAm 25. Januar 2025 18:13:41 UTC schrieb "Philippe Mathieu-Daudé" <[email protected]>:
Quoted 4 lines
Because the network eTSEC device can be optionally plugged on the
TYPE_PLATFORM_BUS_DEVICE, have it inheritTYPE_DYNAMIC_SYS_BUS_DEVICE.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 24 lines
---
hw/net/fsl_etsec/etsec.c| 4 +---1 file changed, 1 insertion(+), 3 deletions(-)hw/net/fsl_etsec/etsec.c +1
-3@@ -425,14 +425,12 @@ static void etsec_class_init(ObjectClass *klass, void *data) dc->realize = etsec_realize;device_class_set_legacy_reset (dc, etsec_reset);device_class_set_props (dc, etsec_properties); -/* Supported by ppce500 machine */ - dc->user_creatable = true; }static const TypeInfo etsec_types[] = { { .name =TYPE_ETSEC_COMMON , - .parent =TYPE_SYS_BUS_DEVICE , + .parent =TYPE_DYNAMIC_SYS_BUS_DEVICE , .instance_size =sizeof (eTSEC), .class_init = etsec_class_init, .instance_init = etsec_instance_init,
PATCH 8/9 hw/tpm: Have TPM TIS sysbus device inherit from DYNAMIC_SYS_BUS_DEVICE
In reply to Philippe Mathieu-DaudéBecause the TPM TIS sysbus device can be optionally plugged on the TYPE_PLATFORM_BUS_DEVICE, have it inherit TYPE_DYNAMIC_SYS_BUS_DEVICE.
--- hw/tpm/tpm_tis_sysbus.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
hw/tpm/tpm_tis_sysbus.c +1 -2
@@ -133,7 +133,6 @@ static void tpm_tis_sysbus_class_init(ObjectClass *klass, void *data) dc->vmsd = &vmstate_tpm_tis_sysbus; tc->model =TPM_MODEL_TPM_TIS ; dc->realize = tpm_tis_sysbus_realizefn; - dc->user_creatable = true;device_class_set_legacy_reset (dc, tpm_tis_sysbus_reset); tc->request_completed = tpm_tis_sysbus_request_completed; tc->get_version = tpm_tis_sysbus_get_tpm_version;
@@ -142,7 +141,7 @@ static void tpm_tis_sysbus_class_init(ObjectClass *klass, void *data)static const TypeInfo tpm_tis_sysbus_info = { .name =TYPE_TPM_TIS_SYSBUS , - .parent =TYPE_SYS_BUS_DEVICE , + .parent =TYPE_DYNAMIC_SYS_BUS_DEVICE , .instance_size =sizeof (TPMStateSysBus), .instance_init = tpm_tis_sysbus_initfn, .class_init = tpm_tis_sysbus_class_init,
Signature · 1 line
2.47.1
Re: [PATCH 8/9] hw/tpm: Have TPM TIS sysbus device inherit from DYNAMIC_SYS_BUS_DEVICE
Quoted 7 lines · Philippe Mathieu-Daudé
Because the TPM TIS sysbus device can be optionally plugged on the
TYPE_PLATFORM_BUS_DEVICE, have it inheritTYPE_DYNAMIC_SYS_BUS_DEVICE.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/tpm/tpm_tis_sysbus.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
r~
Re: [PATCH 8/9] hw/tpm: Have TPM TIS sysbus device inherit from DYNAMIC_SYS_BUS_DEVICE
In reply to Philippe Mathieu-DaudéQuoted 35 lines · Philippe Mathieu-Daudé
Caution: External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe.
Because the TPM TIS sysbus device can be optionally plugged on the
TYPE_PLATFORM_BUS_DEVICE, have it inheritTYPE_DYNAMIC_SYS_BUS_DEVICE.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/tpm/tpm_tis_sysbus.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)hw/tpm/tpm_tis_sysbus.c +1
-3@@ -133,7 +133,6 @@ static void tpm_tis_sysbus_class_init(ObjectClass *klass, void *data) dc->vmsd = &vmstate_tpm_tis_sysbus; tc->model =TPM_MODEL_TPM_TIS ; dc->realize = tpm_tis_sysbus_realizefn; - dc->user_creatable = true;device_class_set_legacy_reset (dc, tpm_tis_sysbus_reset); tc->request_completed = tpm_tis_sysbus_request_completed; tc->get_version = tpm_tis_sysbus_get_tpm_version;@@ -142,7 +141,7 @@ static void tpm_tis_sysbus_class_init(ObjectClass *klass, void *data)static const TypeInfo tpm_tis_sysbus_info = { .name =TYPE_TPM_TIS_SYSBUS , - .parent =TYPE_SYS_BUS_DEVICE , + .parent =TYPE_DYNAMIC_SYS_BUS_DEVICE , .instance_size =sizeof (TPMStateSysBus), .instance_init = tpm_tis_sysbus_initfn, .class_init = tpm_tis_sysbus_class_init, --2.47.1
Re: [PATCH 8/9] hw/tpm: Have TPM TIS sysbus device inherit from DYNAMIC_SYS_BUS_DEVICE
In reply to Philippe Mathieu-DaudéQuoted 4 lines · Philippe Mathieu-Daudé
Because the TPM TIS sysbus device can be optionally plugged on the
TYPE_PLATFORM_BUS_DEVICE, have it inheritTYPE_DYNAMIC_SYS_BUS_DEVICE.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 25 lines
--- hw/tpm/tpm_tis_sysbus.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)hw/tpm/tpm_tis_sysbus.c +1
-2@@ -133,7 +133,6 @@ static void tpm_tis_sysbus_class_init(ObjectClass *klass, void *data) dc->vmsd = &vmstate_tpm_tis_sysbus; tc->model =TPM_MODEL_TPM_TIS ; dc->realize = tpm_tis_sysbus_realizefn; - dc->user_creatable = true;device_class_set_legacy_reset (dc, tpm_tis_sysbus_reset); tc->request_completed = tpm_tis_sysbus_request_completed; tc->get_version = tpm_tis_sysbus_get_tpm_version;@@ -142,7 +141,7 @@ static void tpm_tis_sysbus_class_init(ObjectClass *klass, void *data)static const TypeInfo tpm_tis_sysbus_info = { .name =TYPE_TPM_TIS_SYSBUS , - .parent =TYPE_SYS_BUS_DEVICE , + .parent =TYPE_DYNAMIC_SYS_BUS_DEVICE , .instance_size =sizeof (TPMStateSysBus), .instance_init = tpm_tis_sysbus_initfn, .class_init = tpm_tis_sysbus_class_init,
RFC PATCH 9/9 hw/xen: Have legacy Xen backend inherit from DYNAMIC_SYS_BUS_DEVICE
In reply to Philippe Mathieu-DaudéBecause the legacy Xen backend devices can optionally be plugged on the TYPE_PLATFORM_BUS_DEVICE, have it inherit TYPE_DYNAMIC_SYS_BUS_DEVICE. Remove the implicit TYPE_XENSYSDEV instance_size.
Untested, but I'm surprised the legacy devices work because they had a broken instance size (QDev instead of Sysbus...), so accesses of XenLegacyDevice fields were overwritting sysbus ones.
--- include/hw/xen/xen_pvdev.h | 3 ++- hw/xen/xen-legacy-backend.c | 7 ++----- 2 files changed, 4 insertions(+), 6 deletions(-)
include/hw/xen/xen_pvdev.h +2 -1
@@ -32,7 +32,8 @@ struct XenDevOps { };struct XenLegacyDevice { -DeviceState qdev; +SysBusDevice parent_obj; +const char *type;int dom;int dev;
hw/xen/xen-legacy-backend.c +2 -5
@@ -640,16 +640,14 @@ static void xendev_class_init(ObjectClass *klass, void *data)DeviceClass *dc =DEVICE_CLASS (klass);set_bit (DEVICE_CATEGORY_MISC , dc->categories); -/* xen-backend devices can be plugged/unplugged dynamically */ - dc->user_creatable = true; dc->bus_type =TYPE_XENSYSBUS ; }static const TypeInfo xendev_type_info = { .name =TYPE_XENBACKEND , - .parent =TYPE_DEVICE , + .parent =TYPE_DYNAMIC_SYS_BUS_DEVICE , .class_init = xendev_class_init, - .instance_size =sizeof (struct XenLegacyDevice ), + .instance_size =sizeof (XenLegacyDevice), };static void xen_sysbus_class_init (ObjectClass *klass,void *data)
@@ -672,7 +670,6 @@ static const TypeInfo xensysbus_info = {static const TypeInfo xensysdev_info = { .name =TYPE_XENSYSDEV , .parent =TYPE_SYS_BUS_DEVICE , - .instance_size =sizeof (SysBusDevice), };static void xenbe_register_types (void )
Signature · 1 line
2.47.1
PATCH 1/1 hw/*/xen*: Prefer QOM cast for XenLegacyDevice
Makes the code less sensitive regarding changes in the class hierarchy which will be performed in the next patch.
--- hw/usb/xen-usb.c | 6 +++--- hw/xen/xen-legacy-backend.c | 2 +- hw/xen/xen_pvdev.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
hw/usb/xen-usb.c +3 -3
@@ -755,10 +755,10 @@ static void usbback_portid_add(struct usbback_info *usbif, unsigned port, qdict =qdict_new ();qdict_put_str (qdict,"driver" ,"usb-host" ); - tmp =g_strdup_printf ("%s.0" , usbif->xendev.qdev.id); + tmp =g_strdup_printf ("%s.0" ,DEVICE (&usbif->xendev)->id);qdict_put_str (qdict,"bus" , tmp);g_free (tmp); - tmp =g_strdup_printf ("%s-%u" , usbif->xendev.qdev.id, port); + tmp =g_strdup_printf ("%s-%u" ,DEVICE (&usbif->xendev)->id, port);qdict_put_str (qdict,"id" , tmp);g_free (tmp);qdict_put_int (qdict,"port" , port);
@@ -1022,7 +1022,7 @@ static void usbback_alloc(struct XenLegacyDevice *xendev) usbif = container_of(xendev, struct usbback_info, xendev);usb_bus_new (&usbif->bus,sizeof (usbif->bus), &xen_usb_bus_ops, -DEVICE (&xendev->qdev)); +DEVICE (xendev));for (i =0 ; i <USBBACK_MAXPORTS ; i++) { p = &(usbif->ports[i].port); usb_register_port(&usbif->bus, p, usbif, i, &xen_usb_port_ops,
hw/xen/xen-legacy-backend.c +1 -1
@@ -163,7 +163,7 @@ static struct XenLegacyDevice *xen_be_get_xendev(const char *type, int dom,/* init new xendev */ xendev =g_malloc0 (ops->size); -object_initialize (&xendev->qdev, ops->size,TYPE_XENBACKEND ); +object_initialize (xendev, ops->size,TYPE_XENBACKEND );OBJECT (xendev)->free = g_free;qdev_set_id (DEVICE (xendev),g_strdup_printf ("xen-%s-%d" , type, dev), &error_fatal);
hw/xen/xen_pvdev.c +1 -1
@@ -273,7 +273,7 @@ void xen_pv_del_xendev(struct XenLegacyDevice *xendev)QTAILQ_REMOVE (&xendevs, xendev, next); -qdev_unplug (&xendev->qdev,NULL ); +qdev_unplug (DEVICE (xendev),NULL ); }void xen_pv_insert_xendev (struct XenLegacyDevice *xendev)
Signature · 1 line
2.48.1
Re: [PATCH] hw/*/xen*: Prefer QOM cast for XenLegacyDevice
Quoted 9 lines · Bernhard Beschow
Makes the code less sensitive regarding changes in the class hierarchy which will be performed in the next patch.
Signed-off-by Bernhard Beschow <[email protected]>--- hw/usb/xen-usb.c | 6 +++--- hw/xen/xen-legacy-backend.c | 2 +- hw/xen/xen_pvdev.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
Re: [RFC PATCH 9/9] hw/xen: Have legacy Xen backend inherit from DYNAMIC_SYS_BUS_DEVICE
In reply to Philippe Mathieu-DaudéAm 25. Januar 2025 18:13:43 UTC schrieb "Philippe Mathieu-Daudé" <[email protected]>:
Quoted 19 lines
Because the legacy Xen backend devices can optionally be plugged on the
TYPE_PLATFORM_BUS_DEVICE, have it inheritTYPE_DYNAMIC_SYS_BUS_DEVICE. Remove the implicitTYPE_XENSYSDEVinstance_size.Untested, but I'm surprised the legacy devices work because they had a broken instance size (QDev instead of Sysbus...), so accesses of XenLegacyDevice fields were overwritting sysbus ones.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
include/hw/xen/xen_pvdev.h| 3 ++-hw/xen/xen-legacy-backend.c| 7 ++-----2 files changed, 4 insertions(+), 6 deletions(-)include/hw/xen/xen_pvdev.h +0
-0
include/hw/xen/xen_pvdev.h struct XenDevOps { · line 35
Quoted 5 lines
include/hw/xen/xen_pvdev.h +1
-1@@ -32,7 +32,8 @@ struct XenDevOps { };struct XenLegacyDevice { -DeviceState qdev; +SysBusDevice parent_obj;
This then needs sysbus.h rather than qdev-core.h include.
Moreover, the patch in the reply needs to be inserted into the series before this patch.
Both are needed for the patch to compile.
Best regards,
Bernhard
Quoted 35 lines
include/hw/xen/xen_pvdev.h +1
-0+const char *type;int dom;int dev;hw/xen/xen-legacy-backend.c +2
-5@@ -640,16 +640,14 @@ static void xendev_class_init(ObjectClass *klass, void *data)DeviceClass *dc =DEVICE_CLASS (klass);set_bit (DEVICE_CATEGORY_MISC , dc->categories); -/* xen-backend devices can be plugged/unplugged dynamically */ - dc->user_creatable = true; dc->bus_type =TYPE_XENSYSBUS ; }static const TypeInfo xendev_type_info = { .name =TYPE_XENBACKEND , - .parent =TYPE_DEVICE , + .parent =TYPE_DYNAMIC_SYS_BUS_DEVICE , .class_init = xendev_class_init, - .instance_size =sizeof (struct XenLegacyDevice ), + .instance_size =sizeof (XenLegacyDevice), };static void xen_sysbus_class_init (ObjectClass *klass,void *data)@@ -672,7 +670,6 @@ static const TypeInfo xensysbus_info = {static const TypeInfo xensysdev_info = { .name =TYPE_XENSYSDEV , .parent =TYPE_SYS_BUS_DEVICE , - .instance_size =sizeof (SysBusDevice), };static void xenbe_register_types (void )
Re: [RFC PATCH 9/9] hw/xen: Have legacy Xen backend inherit from DYNAMIC_SYS_BUS_DEVICE
Hi Bernhard,
Quoted 28 lines · Bernhard Beschow
Am 25. Januar 2025 18:13:43 UTC schrieb "Philippe Mathieu-Daudé" <[email protected]>:
Quoted 19 lines
Because the legacy Xen backend devices can optionally be plugged on the
TYPE_PLATFORM_BUS_DEVICE, have it inheritTYPE_DYNAMIC_SYS_BUS_DEVICE. Remove the implicitTYPE_XENSYSDEVinstance_size.Untested, but I'm surprised the legacy devices work because they had a broken instance size (QDev instead of Sysbus...), so accesses of XenLegacyDevice fields were overwritting sysbus ones.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
include/hw/xen/xen_pvdev.h| 3 ++-hw/xen/xen-legacy-backend.c| 7 ++-----2 files changed, 4 insertions(+), 6 deletions(-)include/hw/xen/xen_pvdev.h +0
-0include/hw/xen/xen_pvdev.h struct XenDevOps { · line 35
Quoted 5 lines
include/hw/xen/xen_pvdev.h +1
-1@@ -32,7 +32,8 @@ struct XenDevOps { };struct XenLegacyDevice { -DeviceState qdev; +SysBusDevice parent_obj;This then needs
sysbus.hrather thanqdev-core.hinclude.
Quoted 3 lines
Moreover, the patch in the reply needs to be inserted into the series before this patch.
Both are needed for the patch to compile.
Per your reply on patch #7, might I include your
(or R-b)
squashing:
-- >8 --
include/hw/xen/xen_pvdev.h +1 -1
@@ -1,7 +1,7 @@#ifndef QEMU_HW_XEN_PVDEV_H #define QEMU_HW_XEN_PVDEV_H -#include "hw/qdev-core.h" +#include "hw/sysbus.h" #include "hw/xen/xen_backend_ops.h" /* ------------------------------------------------------------- */
---
?
Bernhard Beschow
Reviewed-byRe: [RFC PATCH 9/9] hw/xen: Have legacy Xen backend inherit from DYNAMIC_SYS_BUS_DEVICE
Am 4. Februar 2025 21:25:46 UTC schrieb "Philippe Mathieu-Daudé" <[email protected]>:
Quoted 33 lines
Hi Bernhard,
Quoted 30 lines · Bernhard Beschow
Am 25. Januar 2025 18:13:43 UTC schrieb "Philippe Mathieu-Daudé" <[email protected]>:
Quoted 19 lines
Because the legacy Xen backend devices can optionally be plugged on the
TYPE_PLATFORM_BUS_DEVICE, have it inheritTYPE_DYNAMIC_SYS_BUS_DEVICE. Remove the implicitTYPE_XENSYSDEVinstance_size.Untested, but I'm surprised the legacy devices work because they had a broken instance size (QDev instead of Sysbus...), so accesses of XenLegacyDevice fields were overwritting sysbus ones.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
include/hw/xen/xen_pvdev.h| 3 ++-hw/xen/xen-legacy-backend.c| 7 ++-----2 files changed, 4 insertions(+), 6 deletions(-)include/hw/xen/xen_pvdev.h +0
-0include/hw/xen/xen_pvdev.h struct XenDevOps { · line 35
Quoted 5 lines
include/hw/xen/xen_pvdev.h +1
-1@@ -32,7 +32,8 @@ struct XenDevOps { };struct XenLegacyDevice { -DeviceState qdev; +SysBusDevice parent_obj;This then needs
sysbus.hrather thanqdev-core.hinclude.Moreover, the patch in the reply needs to be inserted into the series before this patch.
Quoted 7 lines
Quoted 1 line
Both are needed for the patch to compile.
Per your reply on patch #7, might I include your
Tested-by Bernhard Beschow <[email protected]>Acked-by Bernhard Beschow <[email protected]>(or R-b)
I only did a compile test and I'm not a Xen maintainer, so I guess above tags don't apply. Right?
Quoted 19 lines
squashing:
-- >8 --
include/hw/xen/xen_pvdev.h +1
-2@@ -1,7 +1,7 @@#ifndef QEMU_HW_XEN_PVDEV_H #define QEMU_HW_XEN_PVDEV_H -#include "hw/qdev-core.h" +#include "hw/sysbus.h" #include "hw/xen/xen_backend_ops.h" /* ------------------------------------------------------------- */ ---
Quoted 1 line
?
With the squash applied:
Re: [RFC PATCH 9/9] hw/xen: Have legacy Xen backend inherit from DYNAMIC_SYS_BUS_DEVICE
Quoted 38 lines · Bernhard Beschow
Am 4. Februar 2025 21:25:46 UTC schrieb "Philippe Mathieu-Daudé" <[email protected]>:
Quoted 35 lines
Hi Bernhard,
Quoted 31 lines · Bernhard Beschow
Am 25. Januar 2025 18:13:43 UTC schrieb "Philippe Mathieu-Daudé" <[email protected]>:
Quoted 19 lines
Because the legacy Xen backend devices can optionally be plugged on the
TYPE_PLATFORM_BUS_DEVICE, have it inheritTYPE_DYNAMIC_SYS_BUS_DEVICE. Remove the implicitTYPE_XENSYSDEVinstance_size.Untested, but I'm surprised the legacy devices work because they had a broken instance size (QDev instead of Sysbus...), so accesses of XenLegacyDevice fields were overwritting sysbus ones.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
include/hw/xen/xen_pvdev.h| 3 ++-hw/xen/xen-legacy-backend.c| 7 ++-----2 files changed, 4 insertions(+), 6 deletions(-)include/hw/xen/xen_pvdev.h +0
-0include/hw/xen/xen_pvdev.h struct XenDevOps { · line 35
Quoted 5 lines
include/hw/xen/xen_pvdev.h +1
-1@@ -32,7 +32,8 @@ struct XenDevOps { };struct XenLegacyDevice { -DeviceState qdev; +SysBusDevice parent_obj;This then needs
sysbus.hrather thanqdev-core.hinclude.Moreover, the patch in the reply needs to be inserted into the series before this patch.
Both are needed for the patch to compile.
Quoted 7 lines
Quoted 5 lines
Per your reply on patch #7, might I include your
Tested-by Bernhard Beschow <[email protected]>Acked-by Bernhard Beschow <[email protected]>(or R-b)
I only did a compile test and I'm not a Xen maintainer, so I guess above tags don't apply. Right?
Indeed, A-b is preferable for maintainers, but its meaning depends.
Xen maintainers have been Cc'ed for 2 weeks. If they report a problem, we can still revert.
Quoted 18 lines
Quoted 18 lines
squashing:
-- >8 --
include/hw/xen/xen_pvdev.h +1
-1@@ -1,7 +1,7 @@#ifndef QEMU_HW_XEN_PVDEV_H #define QEMU_HW_XEN_PVDEV_H -#include "hw/qdev-core.h" +#include "hw/sysbus.h" #include "hw/xen/xen_backend_ops.h"
Quoted 7 lines
Quoted 4 lines
include/hw/xen/xen_pvdev.h +0
-1/* ------------------------------------------------------------- */ ---?
With the squash applied:
Reviewed-by Bernhard Beschow <[email protected]>
Thanks!
Quoted 8 lines · Philippe Mathieu-Daudé
Some SysBus devices can optionally be dynamically plugged onto the sysbus-platform-bus (then virtual guests are aware of mmio mapping and IRQs via device tree / ACPI rules).
This series makes these devices explicit by having them implement the
DYNAMIC_SYS_BUS_DEVICEclass, which only sets 'user_creatable' flag to %true but makes the codebase a bit clearer (IMHO, at least now we can grep forDYNAMIC_SYS_BUS_DEVICE).
I love it. Thank you! This is clearly much more readable than the magical hint swizzling I did :).
Alex
Quoted 3 lines · Philippe Mathieu-Daudé
Some SysBus devices can optionally be dynamically plugged onto the sysbus-platform-bus (then virtual guests are aware of mmio mapping and IRQs via device tree / ACPI rules).
Do we have some sane way to have user-pluggable sysbus devices on arm?
I've played around with that a bit, with the uefi variable service I'm working on. Specifically I'd prefer to *not* have a patch wiring things up in machine type code like this ...
https://lore.kernel.org/qemu-devel/[email protected]/
... and just use 'qemu -device uefi-vars-sysbus' instead.
Something like AcpiDevAmlIfClass but for device tree seems to not exist though. Also apparently AcpiDevAmlIfClass is not used.
take care,
Gerd
Quoted 7 lines · Gerd Hoffmann
Quoted 3 lines · Philippe Mathieu-Daudé
Some SysBus devices can optionally be dynamically plugged onto the sysbus-platform-bus (then virtual guests are aware of mmio mapping and IRQs via device tree / ACPI rules).
Do we have some sane way to have user-pluggable sysbus devices on arm?
The answer in a general sense is "no, because user pluggable sysbus is a weird idea". "sysbus" means "it's wired into a specific bit of the memory map and to specific IRQs, and whoever does that needs to know what IRQs and bits of memory are usable, and the guest OS needs to know it's there". "user-pluggable" means "it's all automatic and the guest can just do some kind of probing for what is or isn't present". All the platform bus stuff is a nasty mess that's working around the things people want to plug in not being clean devices on probeable buses :-( And the platform bus is only supported on the "virt" board, because that's the only one where QEMU is generating its own dtb or ACPI tables where it can tell the guest "hey, there's some device here".
-- PMM
Quoted 9 lines · Peter Maydell
Quoted 7 lines · Gerd Hoffmann
Quoted 3 lines · Philippe Mathieu-Daudé
Some SysBus devices can optionally be dynamically plugged onto the sysbus-platform-bus (then virtual guests are aware of mmio mapping and IRQs via device tree / ACPI rules).
Do we have some sane way to have user-pluggable sysbus devices on arm?
Quoted 13 lines
The answer in a general sense is "no, because user pluggable sysbus is a weird idea". "sysbus" means "it's wired into a specific bit of the memory map and to specific IRQs, and whoever does that needs to know what IRQs and bits of memory are usable, and the guest OS needs to know it's there". "user-pluggable" means "it's all automatic and the guest can just do some kind of probing for what is or isn't present". All the platform bus stuff is a nasty mess that's working around the things people want to plug in not being clean devices on probeable buses :-( And the platform bus is only supported on the "virt" board, because that's the only one where QEMU is generating its own dtb or ACPI tables where it can tell the guest "hey, there's some device here".
There are some SoCs that have memory mapped devices but different versions in the same family have different devices. Either older ones missing some devices or have less USB or network ports while newer SoCs have more of those or they have PCIe instead of PCI. Modelling these could use pluggable sysbus devices so one could add the devices needed for a SoC version without having to write or modify a board code. I think Bernhard's attempt to try creating e500 SoCs from a device tree goes in that direction too. We could also model this by having a SoC that can instantiate devices based on some properties but maybe pluggable devices could be more generic for this. The issue seems to be how to tell the board or SoC where to map it and what IRQ to connect it as this is done by the board and not the device so properties on the device to set these does not really help unless the board can somehow query it and instantiate the devices based on that. Otherwise whatever handles the -device option to create the device would need knowledge about the board. (E.g. the e500 devices are mapped in the CCSR memory region so one can't just use system address space for them.)
Regards,
BALATON Zoltan
Quoted 24 lines · BALATON Zoltan
Quoted 9 lines · Peter Maydell
Quoted 7 lines · Gerd Hoffmann
Quoted 3 lines · Philippe Mathieu-Daudé
Some SysBus devices can optionally be dynamically plugged onto the sysbus-platform-bus (then virtual guests are aware of mmio mapping and IRQs via device tree / ACPI rules).
Do we have some sane way to have user-pluggable sysbus devices on arm?
Quoted 13 lines
The answer in a general sense is "no, because user pluggable sysbus is a weird idea". "sysbus" means "it's wired into a specific bit of the memory map and to specific IRQs, and whoever does that needs to know what IRQs and bits of memory are usable, and the guest OS needs to know it's there". "user-pluggable" means "it's all automatic and the guest can just do some kind of probing for what is or isn't present". All the platform bus stuff is a nasty mess that's working around the things people want to plug in not being clean devices on probeable buses :-( And the platform bus is only supported on the "virt" board, because that's the only one where QEMU is generating its own dtb or ACPI tables where it can tell the guest "hey, there's some device here".
Quoted 1 line
There are some SoCs that have memory mapped devices but different versions in the same family have different devices. Either older ones missing some devices or have less USB or network ports while newer SoCs have more of those or they have PCIe instead of PCI. Modelling these could use pluggable sysbus devices so one could add the devices needed for a SoC version without having to write or modify a board code. I think Bernhard's attempt to try creating e500 SoCs from a device tree goes in that direction too. We could also model this by having a SoC that can instantiate devices based on some properties but maybe pluggable devices could be more generic for this. The issue seems to be how to tell the board or SoC where to map it and what IRQ to connect it as this is done by the board and not the device so properties on the device to set these does not really help unless the board can somehow query it and instantiate the devices based on that. Otherwise whatever handles the -device option to create the device would need knowledge about the board. (E.g. the e500 devices are mapped in the CCSR memory region so one can't just use system address space for them.)
IIRC Bernard's series takes a DTB as input and create the machine matching this DTB.
As Peter explained, sysbus-platform-bus fits TYPE_DYNAMIC_SYS_BUS_DEVICE in free slots, then generates the corresponding ACPI/DTB.
What you describe seems closer to the QEMU Dynamic Machine project, following Damien's idea:
https://lore.kernel.org/qemu-devel/[email protected]/
We are not quite there yet...
Am 28. Januar 2025 15:10:18 UTC schrieb "Philippe Mathieu-Daudé" <[email protected]>:
Quoted 25 lines · BALATON Zoltan
Quoted 24 lines · Peter Maydell
Quoted 22 lines · Gerd Hoffmann
Quoted 7 lines · Philippe Mathieu-Daudé
Quoted 3 lines
Some SysBus devices can optionally be dynamically plugged onto the sysbus-platform-bus (then virtual guests are aware of mmio mapping and IRQs via device tree / ACPI rules).
Do we have some sane way to have user-pluggable sysbus devices on arm?
The answer in a general sense is "no, because user pluggable sysbus is a weird idea". "sysbus" means "it's wired into a specific bit of the memory map and to specific IRQs, and whoever does that needs to know what IRQs and bits of memory are usable, and the guest OS needs to know it's there". "user-pluggable" means "it's all automatic and the guest can just do some kind of probing for what is or isn't present". All the platform bus stuff is a nasty mess that's working around the things people want to plug in not being clean devices on probeable buses :-( And the platform bus is only supported on the "virt" board, because that's the only one where QEMU is generating its own dtb or ACPI tables where it can tell the guest "hey, there's some device here".
Quoted 4 lines
Quoted 1 line
There are some SoCs that have memory mapped devices but different versions in the same family have different devices. Either older ones missing some devices or have less USB or network ports while newer SoCs have more of those or they have PCIe instead of PCI. Modelling these could use pluggable sysbus devices so one could add the devices needed for a SoC version without having to write or modify a board code. I think Bernhard's attempt to try creating e500 SoCs from a device tree goes in that direction too. We could also model this by having a SoC that can instantiate devices based on some properties but maybe pluggable devices could be more generic for this. The issue seems to be how to tell the board or SoC where to map it and what IRQ to connect it as this is done by the board and not the device so properties on the device to set these does not really help unless the board can somehow query it and instantiate the devices based on that. Otherwise whatever handles the -device option to create the device would need knowledge about the board. (E.g. the e500 devices are mapped in the CCSR memory region so one can't just use system address space for them.)
IIRC Bernard's series takes a DTB as input and create the machine matching this DTB.
That's correct. It's still on my todo list to send an RFC. I first wanted to gain some experience implementing a machine in the classic way which I've now done by means of the imx8mp-evk series. Once I clean up the e500-fdt branch I'd send an RFC.
Best regards,
Bernhard
Quoted 8 lines
As Peter explained, sysbus-platform-bus fits
TYPE_DYNAMIC_SYS_BUS_DEVICEin free slots, then generates the corresponding ACPI/DTB.What you describe seems closer to the QEMU Dynamic Machine project, following Damien's idea:
https://lore.kernel.org/qemu-devel/[email protected]/
We are not quite there yet...
Quoted 11 lines · Philippe Mathieu-Daudé
Philippe Mathieu-Daudé (9):
hw/sysbus: Use sizeof(BusState) inmain_system_bus_create()hw/sysbus: Declare QOM types usingDEFINE_TYPES()macro hw/sysbus: IntroduceTYPE_DYNAMIC_SYS_BUS_DEVICE
hw/vfio: HaveVFIO_PLATFORMdevices inherit from
DYNAMIC_SYS_BUS_DEVICE
hw/display: Have RAMFB device inherit fromDYNAMIC_SYS_BUS_DEVICEhw/i386: HaveX86_IOMMUdevices inherit fromDYNAMIC_SYS_BUS_DEVICEhw/net: Have eTSEC device inherit fromDYNAMIC_SYS_BUS_DEVICEhw/tpm: Have TPM TIS sysbus device inherit fromDYNAMIC_SYS_BUS_DEVICEhw/xen: Have legacy Xen backend inherit fromDYNAMIC_SYS_BUS_DEVICE
Series queued (including Bernhard's patch), thanks.