hw/usb/hcd-xhci: Fix xhci-pci devices
cover hw/usb/hcd-xhci: Fix xhci-pci devices
Fix few regressions introduced while introducing xhci-sysbus.
Cleaned a bit code style while here, patches included for 6.0.
Philippe Mathieu-Daudé (5):
hw/usb/hcd-xhci: Make xhci base model abstract hw/usb/Kconfig: Fix USB_XHCI_NEC (depends on USB_XHCI_PCI) hw/usb/hcd-xhci: Rename "base-xhci" as TYPE_XHCI_COMMON hw/usb/hcd-xhci-pci: Use OBJECT_DECLARE_SIMPLE_TYPE() macro hw/usb/hcd-xhci-pci: Rename "pci-xhci" as TYPE_XHCI_PCI_COMMON
hw/usb/hcd-xhci-pci.h | 6 ++---- hw/usb/hcd-xhci.h | 4 +++- include/hw/usb/xhci.h | 1 - hw/usb/hcd-xhci-nec.c | 2 +- hw/usb/hcd-xhci-pci.c | 18 +++++++++--------- hw/usb/hcd-xhci-sysbus.c | 2 +- hw/usb/hcd-xhci.c | 11 ++++++----- hw/usb/Kconfig | 4 +--- 8 files changed, 23 insertions(+), 25 deletions(-)
Signature · 1 line
2.26.2
PATCH 1/5 hw/usb/hcd-xhci: Make xhci base model abstract
The TYPE_XHCI model is abstract and can not be used as it. It is meant to be overloaded by children classes. Restore it as abstract type.
--- hw/usb/hcd-xhci.c | 1 + 1 file changed, 1 insertion(+)
hw/usb/hcd-xhci.c +1 -0
@@ -3595,6 +3595,7 @@ static const TypeInfo xhci_info = { .parent = TYPE_DEVICE, .instance_size = sizeof(XHCIState), .class_init = xhci_class_init, + .abstract = true, };static void xhci_register_types (void )
Signature · 1 line
2.26.2
RE: [PATCH-for-5.2 1/5] hw/usb/hcd-xhci: Make xhci base model abstract
Looks good.
Thanks,
Sai Pavan
Quoted 33 lines
-----Original Message-----
From: Philippe Mathieu-Daudé <[email protected]>
Sent: Saturday, November 7, 2020 4:43 PM
To: [email protected]
Cc: Gerd Hoffmann <[email protected]>; Sai Pavan Boddu <[email protected]>; Philippe Mathieu-Daudé <[email protected]>; Miroslav Rezanina <[email protected]>
Subject: [PATCH-for-5.2 1/5] hw/usb/hcd-xhci: Make xhci base model abstractThe
TYPE_XHCImodel is abstract and can not be used as it.
It is meant to be overloaded by children classes. Restore it as abstract type.Fixes 8ddab8dd3d8 ("usb/hcd-xhci: Split pci wrapper for xhci base model")Reported-by Miroslav Rezanina <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/usb/hcd-xhci.c | 1 + 1 file changed, 1 insertion(+)hw/usb/hcd-xhci.c index renamed from hw/usb/hcd-xhci.c +0
-0
79ce5c4be6c..57b692ad849100644hw/usb/hcd-xhci.c +1
-1@@ -3595,6 +3595,7 @@ static const TypeInfo xhci_info = { .parent = TYPE_DEVICE, .instance_size = sizeof(XHCIState), .class_init = xhci_class_init, + .abstract = true, };static void xhci_register_types (void ) --2.26.2
Re: [PATCH-for-5.2 1/5] hw/usb/hcd-xhci: Make xhci base model abstract
In reply to Philippe Mathieu-DaudéQuoted 3 lines · Philippe Mathieu-Daudé
The
TYPE_XHCImodel is abstract and can not be used as it. It is meant to be overloaded by children classes. Restore it as abstract type.
Breaks "make check".
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))} QTEST_QEMU_IMG=./qemu-img G_TEST_DBUS_DAEMON=/home/kraxel/projects/qemu/tests/dbus-vmstate-daemon.sh QTEST_QEMU_BINARY=./qemu-system-x86_64 tests/qtest/usb-hcd-xhci-test --tap -k **
ERROR:../../qom/object.c:506:object_initialize_with_type: assertion failed: (type->abstract == false)
take care,
Gerd
Re: [PATCH-for-5.2 1/5] hw/usb/hcd-xhci: Make xhci base model abstract
Cc'ing Thomas who wrote the test.
Quoted 10 lines · Gerd Hoffmann
Quoted 3 lines · Philippe Mathieu-Daudé
The
TYPE_XHCImodel is abstract and can not be used as it. It is meant to be overloaded by children classes. Restore it as abstract type.Breaks "make check".
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))} QTEST_QEMU_IMG=./qemu-img G_TEST_DBUS_DAEMON=/home/kraxel/projects/qemu/tests/dbus-vmstate-daemon.sh QTEST_QEMU_BINARY=./qemu-system-x86_64 tests/qtest/usb-hcd-xhci-test --tap -k **
ERROR:../../qom/object.c:506:object_initialize_with_type: assertion failed: (type->abstract== false)
Well I suppose the test was always incorrect but working, and 8ddab8dd3d8 revealed the problem. Testing the correct device should fix the test:
-- >8 --
(quoted diff) +0 -0
b/tests/qtest/usb-hcd-xhci-test.c
index 10ef9d2a91a..09f5ad71158 100644
tests/qtest/usb-hcd-xhci-test.c +1 -1
@@ -18,7 +18,7 @@ static void test_xhci_init(void)static void test_xhci_hotplug (void ) { -usb_test_hotplug (global_qtest,"xhci" ,"1" ,NULL ); +usb_test_hotplug (global_qtest,"nec-usb-xhci" ,"1" ,NULL ); }static void test_usb_uas_hotplug (void )
---
I'll respin including the fix.
Quoted 4 lines
take care,
Gerd
Re: [PATCH-for-5.2 1/5] hw/usb/hcd-xhci: Make xhci base model abstract
tests/qtest/usb-hcd-xhci-test.c static void test_xhci_init(void) · line 22
Quoted 5 lines
static void
test_xhci_hotplug(void)
{tests/qtest/usb-hcd-xhci-test.c +1
-1-usb_test_hotplug (global_qtest,"xhci" ,"1" ,NULL ); +usb_test_hotplug (global_qtest,"nec-usb-xhci" ,"1" ,NULL ); }
Better use qemu-xhci.
I'm wondering how that worked before ...
take care,
Gerd
Re: [PATCH-for-5.2 1/5] hw/usb/hcd-xhci: Make xhci base model abstract
Quoted 8 lines · Gerd Hoffmann
tests/qtest/usb-hcd-xhci-test.c static void test_xhci_init(void) · line 22
Quoted 5 lines
static void
test_xhci_hotplug(void)
{tests/qtest/usb-hcd-xhci-test.c +1
-1-usb_test_hotplug (global_qtest,"xhci" ,"1" ,NULL ); +usb_test_hotplug (global_qtest,"nec-usb-xhci" ,"1" ,NULL ); }Better use qemu-xhci.
I'm wondering how that worked before ...
Per commit b3937683147 ("tests: usb: Generic usb device hotplug") this is the name of the bus, so "xhci" is correct, my patch isn't.
Quoted 4 lines
take care,
Gerd
PATCH 2/5 hw/usb/Kconfig: Fix USB_XHCI_NEC (depends on USB_XHCI_PCI)
In reply to Philippe Mathieu-DaudéSince commit 755fba11fbc and 8ddab8dd3d8 we can not build USB_XHCI_NEC without USB_XHCI_PCI. Correct the Kconfig dependency.
--- hw/usb/Kconfig | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
hw/usb/Kconfig +1 -3
@@ -42,9 +42,7 @@ config USB_XHCI_PCI config USB_XHCI_NEC bool - default y if PCI_DEVICES - depends on PCI - select USB_XHCI + select USB_XHCI_PCI config USB_XHCI_SYSBUS bool
Signature · 1 line
2.26.2
RE: [PATCH-for-5.2 2/5] hw/usb/Kconfig: Fix USB_XHCI_NEC (depends on USB_XHCI_PCI)
Thanks, good fix.
Regards,
Sai Pavan
Quoted 35 lines
-----Original Message-----
From: Philippe Mathieu-Daudé <[email protected]>
Sent: Saturday, November 7, 2020 4:43 PM
To: [email protected]
Cc: Gerd Hoffmann <[email protected]>; Sai Pavan Boddu <[email protected]>; Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH-for-5.2 2/5] hw/usb/Kconfig: FixUSB_XHCI_NEC(depends onUSB_XHCI_PCI)Since commit
755fba11fbcand8ddab8dd3d8we can not buildUSB_XHCI_NECwithoutUSB_XHCI_PCI. Correct theKconfigdependency.Fixes 755fba11fbc ("usb/hcd-xhci: Move qemu-xhci device to hcd-xhci-pci.c")Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/usb/Kconfig | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)hw/usb/Kconfig index renamed from hw/usb/Kconfig +0
-0
a674ce4c542..6a213b04758100644hw/usb/Kconfig +1
-4@@ -42,9 +42,7 @@ config USB_XHCI_PCI config USB_XHCI_NEC bool - default y if PCI_DEVICES - depends on PCI - select USB_XHCI + select USB_XHCI_PCI config USB_XHCI_SYSBUS bool --2.26.2
Re: [PATCH-for-5.2 2/5] hw/usb/Kconfig: Fix USB_XHCI_NEC (depends on USB_XHCI_PCI)
In reply to Philippe Mathieu-DaudéQuoted 3 lines · Philippe Mathieu-Daudé
Since commit
755fba11fbcand8ddab8dd3d8we can not buildUSB_XHCI_NECwithoutUSB_XHCI_PCI. Correct theKconfigdependency.
Fails make check too:
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))} QTEST_QEMU_IMG=./qemu-img G_TEST_DBUS_DAEMON=/home/kraxel/projects/qemu/tests/dbus-vmstate-daemon.sh QTEST_QEMU_BINARY=./qemu-system-ppc64 tests/qtest/device-plug-test --tap -k **
ERROR:../../qom/object.c:711:object_new_with_type: assertion failed: (type != NULL)
take care,
Gerd
PATCH 3/5 hw/usb/hcd-xhci: Rename "base-xhci" as TYPE_XHCI_COMMON
In reply to Philippe Mathieu-DaudéFollow the code base style by using the _COMMON suffix to abstract QOM types.
--- hw/usb/hcd-xhci.h | 4 +++- include/hw/usb/xhci.h | 1 - hw/usb/hcd-xhci-pci.c | 2 +- hw/usb/hcd-xhci-sysbus.c | 2 +- hw/usb/hcd-xhci.c | 10 +++++----- 5 files changed, 10 insertions(+), 9 deletions(-)
hw/usb/hcd-xhci.h +3 -1
@@ -27,7 +27,9 @@#include "hw/usb/xhci.h" #include "sysemu/dma.h" -OBJECT_DECLARE_SIMPLE_TYPE (XHCIState,XHCI ) +#define TYPE_XHCI_COMMON "base-xhci"/* Common to PCI and Sysbus */ + +OBJECT_DECLARE_SIMPLE_TYPE (XHCIState,XHCI_COMMON ) /* Very pessimistic, let's hope it's enough for all cases */#define EV_QUEUE (((3 * 24) + 16) * XHCI_MAXSLOTS)
include/hw/usb/xhci.h +0 -1
@@ -1,7 +1,6 @@#ifndef HW_USB_XHCI_H #define HW_USB_XHCI_H -#define TYPE_XHCI "base-xhci"#define TYPE_NEC_XHCI "nec-usb-xhci"#define TYPE_QEMU_XHCI "qemu-xhci"#define TYPE_XHCI_SYSBUS "sysbus-xhci"
hw/usb/hcd-xhci-pci.c +1 -1
@@ -193,7 +193,7 @@ static void xhci_instance_init(Object *obj)* line, therefore, no need to wait to realize like other devices */ PCI_DEVICE (obj)->cap_present |=QEMU_PCI_CAP_EXPRESS ; -object_initialize_child (obj,"xhci-core" , &s->xhci,TYPE_XHCI ); +object_initialize_child (obj,"xhci-core" , &s->xhci,TYPE_XHCI_COMMON );qdev_alias_all_properties (DEVICE (&s->xhci), obj); }
hw/usb/hcd-xhci-sysbus.c +1 -1
@@ -58,7 +58,7 @@ static void xhci_sysbus_instance_init(Object *obj) {XHCISysbusState *s =XHCI_SYSBUS (obj); -object_initialize_child (obj,"xhci-core" , &s->xhci,TYPE_XHCI ); +object_initialize_child (obj,"xhci-core" , &s->xhci,TYPE_XHCI_COMMON );qdev_alias_all_properties (DEVICE (&s->xhci), obj); object_property_add_link(obj, "dma", TYPE_MEMORY_REGION,
hw/usb/hcd-xhci.c +5 -5
@@ -2637,7 +2637,7 @@ static void xhci_port_reset(XHCIPort *port, bool warm_reset)static void xhci_reset (DeviceState *dev) { -XHCIState *xhci =XHCI (dev); +XHCIState *xhci =XHCI_COMMON (dev);int i;trace_usb_xhci_reset ();
@@ -2891,7 +2891,7 @@ static uint64_t xhci_oper_read(void *ptr, hwaddr reg, unsigned size)static void xhci_oper_write (void *ptr,hwaddr reg,uint64_t val,unsigned size) { -XHCIState *xhci =XHCI (ptr); +XHCIState *xhci =XHCI_COMMON (ptr);trace_usb_xhci_oper_write (reg, val);
@@ -3327,7 +3327,7 @@ static void usb_xhci_realize(DeviceState *dev, Error **errp) {int i; -XHCIState *xhci =XHCI (dev); +XHCIState *xhci =XHCI_COMMON (dev);if (xhci->numintrs >XHCI_MAXINTRS ) { xhci->numintrs =XHCI_MAXINTRS ;
@@ -3381,7 +3381,7 @@ static void usb_xhci_realize(DeviceState *dev, Error **errp)static void usb_xhci_unrealize (DeviceState *dev) {int i; -XHCIState *xhci =XHCI (dev); +XHCIState *xhci =XHCI_COMMON (dev);trace_usb_xhci_exit ();
@@ -3591,7 +3591,7 @@ static void xhci_class_init(ObjectClass *klass, void *data) }static const TypeInfo xhci_info = { - .name =TYPE_XHCI , + .name =TYPE_XHCI_COMMON , .parent =TYPE_DEVICE , .instance_size =sizeof (XHCIState), .class_init = xhci_class_init,
Signature · 1 line
2.26.2
PATCH 4/5 hw/usb/hcd-xhci-pci: Use OBJECT_DECLARE_SIMPLE_TYPE() macro
In reply to Philippe Mathieu-Daudé---
Cc: Eduardo Habkost <[email protected]>
Cc: [email protected]
hw/usb/hcd-xhci-pci.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
hw/usb/hcd-xhci-pci.h +1 -3
@@ -28,9 +28,7 @@#include "hcd-xhci.h" #define TYPE_XHCI_PCI "pci-xhci" -#define XHCI_PCI (obj) \ - OBJECT_CHECK(XHCIPciState, (obj), TYPE_XHCI_PCI) - +OBJECT_DECLARE_SIMPLE_TYPE(XHCIPciState, XHCI_PCI) typedef struct XHCIPciState { /*< private >*/
Signature · 1 line
2.26.2
PATCH 5/5 hw/usb/hcd-xhci-pci: Rename "pci-xhci" as TYPE_XHCI_PCI_COMMON
In reply to Philippe Mathieu-DaudéFollow the code base style by using the _COMMON suffix to abstract QOM types.
--- hw/usb/hcd-xhci-pci.h | 4 ++-- hw/usb/hcd-xhci-nec.c | 2 +- hw/usb/hcd-xhci-pci.c | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-)
hw/usb/hcd-xhci-pci.h +2 -2
@@ -27,8 +27,8 @@#include "hw/usb.h" #include "hcd-xhci.h" -#define TYPE_XHCI_PCI "pci-xhci" -OBJECT_DECLARE_SIMPLE_TYPE(XHCIPciState, XHCI_PCI) +#define TYPE_XHCI_PCI_COMMON "pci-xhci" +OBJECT_DECLARE_SIMPLE_TYPE(XHCIPciState, XHCI_PCI_COMMON) typedef struct XHCIPciState { /*< private >*/
hw/usb/hcd-xhci-nec.c +1 -1
@@ -52,7 +52,7 @@ static void nec_xhci_class_init(ObjectClass *klass, void *data)static const TypeInfo nec_xhci_info = { .name =TYPE_NEC_XHCI , - .parent =TYPE_XHCI_PCI , + .parent =TYPE_XHCI_PCI_COMMON , .class_init = nec_xhci_class_init, };
hw/usb/hcd-xhci-pci.c +8 -8
@@ -80,14 +80,14 @@ static void xhci_pci_intr_raise(XHCIState *xhci, int n, bool level)static void xhci_pci_reset (DeviceState *dev) { -XHCIPciState *s =XHCI_PCI (dev); +XHCIPciState *s =XHCI_PCI_COMMON (dev);device_legacy_reset (DEVICE (&s->xhci)); }static int xhci_pci_vmstate_post_load (void *opaque,int version_id) { -XHCIPciState *s =XHCI_PCI (opaque); +XHCIPciState *s =XHCI_PCI_COMMON (opaque);PCIDevice *pci_dev =PCI_DEVICE (s);int intr;
@@ -105,7 +105,7 @@ static void usb_xhci_pci_realize(struct PCIDevice *dev, Error **errp) {int ret;Error *err =NULL ; -XHCIPciState *s =XHCI_PCI (dev); +XHCIPciState *s =XHCI_PCI_COMMON (dev); dev->config[PCI_CLASS_PROG ] =0x30 ;/* xHCI */ dev->config[PCI_INTERRUPT_PIN ] =0x01 ;/* interrupt pin 1 */
@@ -165,7 +165,7 @@ static void usb_xhci_pci_realize(struct PCIDevice *dev, Error **errp)static void usb_xhci_pci_exit (PCIDevice *dev) { -XHCIPciState *s =XHCI_PCI (dev); +XHCIPciState *s =XHCI_PCI_COMMON (dev);/* destroy msix memory region */ if (dev->msix_table && dev->msix_pba && dev->msix_entry_used) {
@@ -187,7 +187,7 @@ static const VMStateDescription vmstate_xhci_pci = {static void xhci_instance_init (Object *obj) { -XHCIPciState *s =XHCI_PCI (obj); +XHCIPciState *s =XHCI_PCI_COMMON (obj);/* * QEMU_PCI_CAP_EXPRESS initialization does not depend on QEMU command * line, therefore, no need to wait to realize like other devices
@@ -211,7 +211,7 @@ static void xhci_class_init(ObjectClass *klass, void *data) }static const TypeInfo xhci_pci_info = { - .name =TYPE_XHCI_PCI , + .name =TYPE_XHCI_PCI_COMMON , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (XHCIPciState), .class_init = xhci_class_init,
@@ -235,7 +235,7 @@ static void qemu_xhci_class_init(ObjectClass *klass, void *data)static void qemu_xhci_instance_init (Object *obj) { -XHCIPciState *s =XHCI_PCI (obj); +XHCIPciState *s =XHCI_PCI_COMMON (obj);XHCIState *xhci = &s->xhci; s->msi =ON_OFF_AUTO_OFF ;
@@ -247,7 +247,7 @@ static void qemu_xhci_instance_init(Object *obj)static const TypeInfo qemu_xhci_info = { .name =TYPE_QEMU_XHCI , - .parent =TYPE_XHCI_PCI , + .parent =TYPE_XHCI_PCI_COMMON , .class_init = qemu_xhci_class_init, .instance_init = qemu_xhci_instance_init, };
Signature · 1 line
2.26.2