Skip to contentSkip to conversation

hw/usb/hcd-xhci: Fix USB_XHCI_NEC device

PATCH In review Philippe Mathieu-Daudé 2 participants 9 messages Nov 9, 2020 – Nov 12, 2020

lore
Share & tools
lore
#0 lore raw

v2 cover hw/usb/hcd-xhci: Fix USB_XHCI_NEC device

Fix a regression since xhci-sysbus introduction.

Since v1:
- Do not declare TYPE_XHCI abstract

Cleaned a bit code style while here, patches included for 6.0.

Supersedes: <[email protected]>

Philippe Mathieu-Daudé (4):
hw/usb/Kconfig: Fix USB_XHCI_NEC (depends on USB_XHCI_PCI) hw/usb/hcd-xhci: Restrict TYPE_XHCI to hw/usb/ 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     |  1 +
 include/hw/usb/xhci.h |  1 -
 hw/usb/hcd-xhci-nec.c |  2 +-
 hw/usb/hcd-xhci-pci.c | 16 ++++++++--------
 hw/usb/Kconfig        |  4 +---
 6 files changed, 13 insertions(+), 17 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH v2 1/4 hw/usb/Kconfig: Fix USB_XHCI_NEC (depends on USB_XHCI_PCI)

Since commit 755fba11fbc and 8ddab8dd3d8 we can not build USB_XHCI_NEC without USB_XHCI_PCI. Correct the Kconfig dependency.

Fixes 755fba11fbc ("usb/hcd-xhci: Move qemu-xhci device to hcd-xhci-pci.c")
---
 hw/usb/Kconfig | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
hw/usb/Kconfig +1 -3
index a674ce4c542..6a213b04758 100644
@@ -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
Reviewed-by on v2 1/4
#2 lore raw

Re: [PATCH-for-5.2 v2 1/4] hw/usb/Kconfig: Fix USB_XHCI_NEC (depends on USB_XHCI_PCI)

Quoted 10 lines · Philippe Mathieu-Daudé

Since commit 755fba11fbc and 8ddab8dd3d8 we can not build USB_XHCI_NEC without USB_XHCI_PCI. Correct the Kconfig dependency.

Fixes 755fba11fbc ("usb/hcd-xhci: Move qemu-xhci device to hcd-xhci-pci.c")
---
 hw/usb/Kconfig | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

r~

#3 lore raw

PATCH v2 2/4 hw/usb/hcd-xhci: Restrict TYPE_XHCI to hw/usb/

In reply to Philippe Mathieu-Daudé

TYPE_XHCI is not a generic device meant to be instantiated by QOM objects outside of hw/usb/. Do not expose the type in public namespace (via include/).

---
 hw/usb/hcd-xhci.h     | 1 +
 include/hw/usb/xhci.h | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)
hw/usb/hcd-xhci.h +1 -0
index ccf50ae28be..f7150a7e12b 100644
@@ -27,6 +27,7 @@
 #include "hw/usb/xhci.h"
 #include "sysemu/dma.h"
 
+#define TYPE_XHCI "base-xhci"
 OBJECT_DECLARE_SIMPLE_TYPE(XHCIState, XHCI)
 
 /* Very pessimistic, let's hope it's enough for all cases */
include/hw/usb/xhci.h +0 -1
index 5c90e1373e5..90b56429199 100644
@@ -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"
Signature · 1 line
2.26.2
Reviewed-by on v2 2/4
#4 lore raw

Re: [PATCH-for-6.0 v2 2/4] hw/usb/hcd-xhci: Restrict TYPE_XHCI to hw/usb/

Quoted 9 lines · Philippe Mathieu-Daudé

TYPE_XHCI is not a generic device meant to be instantiated by QOM objects outside of hw/usb/. Do not expose the type in public namespace (via include/).

---
 hw/usb/hcd-xhci.h     | 1 +
 include/hw/usb/xhci.h | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

r~

#5 lore raw

PATCH v2 3/4 hw/usb/hcd-xhci-pci: Use OBJECT_DECLARE_SIMPLE_TYPE() macro

In reply to Philippe Mathieu-Daudé
---
 hw/usb/hcd-xhci-pci.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
hw/usb/hcd-xhci-pci.h +1 -3
index aa2e890627c..cf9a180caa4 100644
@@ -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
#7 lore raw

PATCH v2 4/4 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
index cf9a180caa4..c862e82d964 100644
@@ -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
index 5707b2cabd1..16b3b46fd59 100644
@@ -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
index b78fcd2bb2d..b4487cce4ba 100644
@@ -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
Reviewed-by on v2 4/4
#8 lore raw

Re: [PATCH-for-6.0 v2 4/4] hw/usb/hcd-xhci-pci: Rename "pci-xhci" as TYPE_XHCI_PCI_COMMON

Quoted 9 lines · 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(-)

r~