diff mbox series

[v4,2/7] usb/hcd-xhci: Move qemu-xhci device to hcd-xhci-pci.c

Message ID 1598642380-27817-3-git-send-email-sai.pavan.boddu@xilinx.com
State New
Headers show
Series None | expand

Commit Message

Sai Pavan Boddu Aug. 28, 2020, 7:19 p.m. UTC
Move pci specific devices to new file. This set the environment to move all
pci specific hooks in hcd-xhci.c to hcd-xhci-pci.c.

Signed-off-by: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>
---
 hw/usb/Kconfig        |  6 +++++
 hw/usb/Makefile.objs  |  1 +
 hw/usb/hcd-xhci-pci.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/usb/hcd-xhci.c     | 41 ++------------------------------
 hw/usb/hcd-xhci.h     |  3 +++
 5 files changed, 78 insertions(+), 39 deletions(-)
 create mode 100644 hw/usb/hcd-xhci-pci.c

Comments

Sai Pavan Boddu Sept. 2, 2020, 6:26 p.m. UTC | #1
Hi Philippe,

> -----Original Message-----

> From: Philippe Mathieu-Daudé <philmd@redhat.com>

> Sent: Tuesday, September 1, 2020 10:08 PM

> To: Sai Pavan Boddu <saipava@xilinx.com>; Peter Maydell

> <peter.maydell@linaro.org>; Markus Armbruster <armbru@redhat.com>;

> 'Marc-André Lureau' <marcandre.lureau@redhat.com>; Paolo Bonzini

> <pbonzini@redhat.com>; Gerd Hoffmann <kraxel@redhat.com>; Edgar

> Iglesias <edgari@xilinx.com>; Francisco Eduardo Iglesias

> <figlesia@xilinx.com>

> Cc: qemu-devel@nongnu.org; Alistair Francis <alistair.francis@wdc.com>;

> Eduardo Habkost <ehabkost@redhat.com>; Ying Fang

> <fangying1@huawei.com>; Vikram Garhwal <fnuv@xilinx.com>; Paul

> Zimmerman <pauldzim@gmail.com>

> Subject: Re: [PATCH v4 2/7] usb/hcd-xhci: Move qemu-xhci device to hcd-

> xhci-pci.c

> 

> On 8/28/20 9:19 PM, Sai Pavan Boddu wrote:

> > Move pci specific devices to new file. This set the environment to

> > move all pci specific hooks in hcd-xhci.c to hcd-xhci-pci.c.

> >

> > Signed-off-by: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>

> > ---

> >  hw/usb/Kconfig        |  6 +++++

> >  hw/usb/Makefile.objs  |  1 +

> >  hw/usb/hcd-xhci-pci.c | 66

> +++++++++++++++++++++++++++++++++++++++++++++++++++

> >  hw/usb/hcd-xhci.c     | 41 ++------------------------------

> >  hw/usb/hcd-xhci.h     |  3 +++

> >  5 files changed, 78 insertions(+), 39 deletions(-)  create mode

> > 100644 hw/usb/hcd-xhci-pci.c

> >

> > diff --git a/hw/usb/Kconfig b/hw/usb/Kconfig index d4d8c37..d9965c1

> > 100644

> > --- a/hw/usb/Kconfig

> > +++ b/hw/usb/Kconfig

> > @@ -36,6 +36,12 @@ config USB_XHCI

> >      depends on PCI

> >      select USB

> >

> > +config USB_XHCI_PCI

> > +    bool

> > +    default y if PCI_DEVICES

> > +    depends on PCI

> > +    select USB_XHCI

> > +

> >  config USB_XHCI_NEC

> >      bool

> >      default y if PCI_DEVICES

> > diff --git a/hw/usb/Makefile.objs b/hw/usb/Makefile.objs index

> > e342ff5..029b040 100644

> > --- a/hw/usb/Makefile.objs

> > +++ b/hw/usb/Makefile.objs

> > @@ -11,6 +11,7 @@ common-obj-$(CONFIG_USB_EHCI_PCI) += hcd-ehci-

> pci.o

> >  common-obj-$(CONFIG_USB_EHCI_SYSBUS) += hcd-ehci-sysbus.o

> >  common-obj-$(CONFIG_USB_XHCI) += hcd-xhci.o

> >  common-obj-$(CONFIG_USB_XHCI_NEC) += hcd-xhci-nec.o

> > +common-obj-$(CONFIG_USB_XHCI_PCI) += hcd-xhci-pci.o

> >  common-obj-$(CONFIG_USB_MUSB) += hcd-musb.o

> >  common-obj-$(CONFIG_USB_DWC2) += hcd-dwc2.o

> >

> > diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c new file

> > mode 100644 index 0000000..1562757

> > --- /dev/null

> > +++ b/hw/usb/hcd-xhci-pci.c

> > @@ -0,0 +1,66 @@

> > +/*

> > + * USB xHCI controller with PCI bus emulation

> > + *

> > + * SPDX-FileCopyrightText: 2011 Securiforest

> > + * SPDX-FileContributor: Hector Martin <hector@marcansoft.com>

> > + * SPDX-sourceInfo: Based on usb-ohci.c, emulates Renesas NEC USB 3.0

> > + * SPDX-FileCopyrightText: 2020 Xilinx

> > + * SPDX-FileContributor: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>

> > + * SPDX-sourceInfo: Moved the pci specific content for hcd-xhci.c to

> > + *                  hcd-xhci-pci.c

> > + *

> > + * This library is free software; you can redistribute it and/or

> > + * modify it under the terms of the GNU Lesser General Public

> > + * License as published by the Free Software Foundation; either

> > + * version 2 of the License, or (at your option) any later version.

> > + *

> > + * This library is distributed in the hope that it will be useful,

> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of

> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

> GNU

> > + * Lesser General Public License for more details.

> > + *

> > + * You should have received a copy of the GNU Lesser General Public

> > + * License along with this library; if not, see

> <http://www.gnu.org/licenses/>.

> > + */

> > +#include "qemu/osdep.h"

> > +#include "hw/pci/pci.h"

> > +#include "hw/qdev-properties.h"

> > +#include "hw/pci/msi.h"

> > +#include "hw/pci/msix.h"

> > +#include "hcd-xhci.h"

> > +#include "trace.h"

> > +#include "qapi/error.h"

> > +

> > +static void qemu_xhci_class_init(ObjectClass *klass, void *data) {

> > +    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);

> > +

> > +    k->vendor_id    = PCI_VENDOR_ID_REDHAT;

> > +    k->device_id    = PCI_DEVICE_ID_REDHAT_XHCI;

> > +    k->revision     = 0x01;

> > +}

> > +

> > +static void qemu_xhci_instance_init(Object *obj) {

> > +    XHCIState *xhci = XHCI(obj);

> > +

> > +    xhci->msi      = ON_OFF_AUTO_OFF;

> > +    xhci->msix     = ON_OFF_AUTO_AUTO;

> > +    xhci->numintrs = MAXINTRS;

> > +    xhci->numslots = MAXSLOTS;

> > +    xhci_set_flag(xhci, XHCI_FLAG_SS_FIRST); }

> > +

> > +static const TypeInfo qemu_xhci_info = {

> > +    .name          = TYPE_QEMU_XHCI,

> > +    .parent        = TYPE_XHCI,

> > +    .class_init    = qemu_xhci_class_init,

> > +    .instance_init = qemu_xhci_instance_init, };

> > +

> > +static void xhci_register_types(void) {

> > +    type_register_static(&qemu_xhci_info);

> > +}

> > +

> > +type_init(xhci_register_types)

> > diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index

> > 2590f7a..b15c53b 100644

> > --- a/hw/usb/hcd-xhci.c

> > +++ b/hw/usb/hcd-xhci.c

> > @@ -23,7 +23,6 @@

> >  #include "qemu/timer.h"

> >  #include "qemu/module.h"

> >  #include "qemu/queue.h"

> > -#include "hw/usb.h"

> >  #include "migration/vmstate.h"

> >  #include "hw/pci/pci.h"

> >  #include "hw/qdev-properties.h"

> > @@ -429,12 +428,12 @@ static const char *ep_state_name(uint32_t state)

> >                         ARRAY_SIZE(ep_state_names));  }

> >

> > -static bool xhci_get_flag(XHCIState *xhci, enum xhci_flags bit)

> > +bool xhci_get_flag(XHCIState *xhci, enum xhci_flags bit)

> >  {

> >      return xhci->flags & (1 << bit);

> >  }

> >

> > -static void xhci_set_flag(XHCIState *xhci, enum xhci_flags bit)

> > +void xhci_set_flag(XHCIState *xhci, enum xhci_flags bit)

> >  {

> >      xhci->flags |= (1 << bit);

> >  }

> > @@ -3692,13 +3691,6 @@ static Property xhci_properties[] = {

> >      DEFINE_PROP_END_OF_LIST(),

> >  };

> >

> > -static void xhci_instance_init(Object *obj) -{

> > -    /* QEMU_PCI_CAP_EXPRESS initialization does not depend on QEMU

> command

> > -     * line, therefore, no need to wait to realize like other devices */

> > -    PCI_DEVICE(obj)->cap_present |= QEMU_PCI_CAP_EXPRESS;

> 

> What happened to this flag?

[Sai Pavan Boddu] During a patch split this has been moved into patch 3/7. I would make these changes come into one patch.

Regards,
Sai Pavan
> 

> > -}

> > -

> >  static void xhci_class_init(ObjectClass *klass, void *data)  {

> >      PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); @@ -3718,7 +3710,6

> > @@ static const TypeInfo xhci_info = {

> >      .parent        = TYPE_PCI_DEVICE,

> >      .instance_size = sizeof(XHCIState),

> >      .class_init    = xhci_class_init,

> > -    .instance_init = xhci_instance_init,

> >      .abstract      = true,

> >      .interfaces = (InterfaceInfo[]) {

> >          { INTERFACE_PCIE_DEVICE },

> > @@ -3727,37 +3718,9 @@ static const TypeInfo xhci_info = {

> >      },

> >  };

> >

> > -static void qemu_xhci_class_init(ObjectClass *klass, void *data) -{

> > -    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);

> > -

> > -    k->vendor_id    = PCI_VENDOR_ID_REDHAT;

> > -    k->device_id    = PCI_DEVICE_ID_REDHAT_XHCI;

> > -    k->revision     = 0x01;

> > -}

> > -

> > -static void qemu_xhci_instance_init(Object *obj) -{

> > -    XHCIState *xhci = XHCI(obj);

> > -

> > -    xhci->msi      = ON_OFF_AUTO_OFF;

> > -    xhci->msix     = ON_OFF_AUTO_AUTO;

> > -    xhci->numintrs = MAXINTRS;

> > -    xhci->numslots = MAXSLOTS;

> > -    xhci_set_flag(xhci, XHCI_FLAG_SS_FIRST);

> > -}

> > -

> > -static const TypeInfo qemu_xhci_info = {

> > -    .name          = TYPE_QEMU_XHCI,

> > -    .parent        = TYPE_XHCI,

> > -    .class_init    = qemu_xhci_class_init,

> > -    .instance_init = qemu_xhci_instance_init,

> > -};

> > -

> >  static void xhci_register_types(void)  {

> >      type_register_static(&xhci_info);

> > -    type_register_static(&qemu_xhci_info);

> >  }

> >

> >  type_init(xhci_register_types)

> > diff --git a/hw/usb/hcd-xhci.h b/hw/usb/hcd-xhci.h index

> > edbd926..dd5fcd4 100644

> > --- a/hw/usb/hcd-xhci.h

> > +++ b/hw/usb/hcd-xhci.h

> > @@ -23,6 +23,7 @@

> >  #define HW_USB_HCD_XHCI_H

> >

> >  #include "sysemu/dma.h"

> > +#include "hw/usb.h"

> >

> >  #define TYPE_XHCI "base-xhci"

> >  #define TYPE_NEC_XHCI "nec-usb-xhci"

> > @@ -232,4 +233,6 @@ struct XHCIState {

> >      bool nec_quirks;

> >  };

> >

> > +bool xhci_get_flag(XHCIState *xhci, enum xhci_flags bit); void

> > +xhci_set_flag(XHCIState *xhci, enum xhci_flags bit);

> >  #endif

> >
diff mbox series

Patch

diff --git a/hw/usb/Kconfig b/hw/usb/Kconfig
index d4d8c37..d9965c1 100644
--- a/hw/usb/Kconfig
+++ b/hw/usb/Kconfig
@@ -36,6 +36,12 @@  config USB_XHCI
     depends on PCI
     select USB
 
+config USB_XHCI_PCI
+    bool
+    default y if PCI_DEVICES
+    depends on PCI
+    select USB_XHCI
+
 config USB_XHCI_NEC
     bool
     default y if PCI_DEVICES
diff --git a/hw/usb/Makefile.objs b/hw/usb/Makefile.objs
index e342ff5..029b040 100644
--- a/hw/usb/Makefile.objs
+++ b/hw/usb/Makefile.objs
@@ -11,6 +11,7 @@  common-obj-$(CONFIG_USB_EHCI_PCI) += hcd-ehci-pci.o
 common-obj-$(CONFIG_USB_EHCI_SYSBUS) += hcd-ehci-sysbus.o
 common-obj-$(CONFIG_USB_XHCI) += hcd-xhci.o
 common-obj-$(CONFIG_USB_XHCI_NEC) += hcd-xhci-nec.o
+common-obj-$(CONFIG_USB_XHCI_PCI) += hcd-xhci-pci.o
 common-obj-$(CONFIG_USB_MUSB) += hcd-musb.o
 common-obj-$(CONFIG_USB_DWC2) += hcd-dwc2.o
 
diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c
new file mode 100644
index 0000000..1562757
--- /dev/null
+++ b/hw/usb/hcd-xhci-pci.c
@@ -0,0 +1,66 @@ 
+/*
+ * USB xHCI controller with PCI bus emulation
+ *
+ * SPDX-FileCopyrightText: 2011 Securiforest
+ * SPDX-FileContributor: Hector Martin <hector@marcansoft.com>
+ * SPDX-sourceInfo: Based on usb-ohci.c, emulates Renesas NEC USB 3.0
+ * SPDX-FileCopyrightText: 2020 Xilinx
+ * SPDX-FileContributor: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>
+ * SPDX-sourceInfo: Moved the pci specific content for hcd-xhci.c to
+ *                  hcd-xhci-pci.c
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+#include "qemu/osdep.h"
+#include "hw/pci/pci.h"
+#include "hw/qdev-properties.h"
+#include "hw/pci/msi.h"
+#include "hw/pci/msix.h"
+#include "hcd-xhci.h"
+#include "trace.h"
+#include "qapi/error.h"
+
+static void qemu_xhci_class_init(ObjectClass *klass, void *data)
+{
+    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+
+    k->vendor_id    = PCI_VENDOR_ID_REDHAT;
+    k->device_id    = PCI_DEVICE_ID_REDHAT_XHCI;
+    k->revision     = 0x01;
+}
+
+static void qemu_xhci_instance_init(Object *obj)
+{
+    XHCIState *xhci = XHCI(obj);
+
+    xhci->msi      = ON_OFF_AUTO_OFF;
+    xhci->msix     = ON_OFF_AUTO_AUTO;
+    xhci->numintrs = MAXINTRS;
+    xhci->numslots = MAXSLOTS;
+    xhci_set_flag(xhci, XHCI_FLAG_SS_FIRST);
+}
+
+static const TypeInfo qemu_xhci_info = {
+    .name          = TYPE_QEMU_XHCI,
+    .parent        = TYPE_XHCI,
+    .class_init    = qemu_xhci_class_init,
+    .instance_init = qemu_xhci_instance_init,
+};
+
+static void xhci_register_types(void)
+{
+    type_register_static(&qemu_xhci_info);
+}
+
+type_init(xhci_register_types)
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index 2590f7a..b15c53b 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -23,7 +23,6 @@ 
 #include "qemu/timer.h"
 #include "qemu/module.h"
 #include "qemu/queue.h"
-#include "hw/usb.h"
 #include "migration/vmstate.h"
 #include "hw/pci/pci.h"
 #include "hw/qdev-properties.h"
@@ -429,12 +428,12 @@  static const char *ep_state_name(uint32_t state)
                        ARRAY_SIZE(ep_state_names));
 }
 
-static bool xhci_get_flag(XHCIState *xhci, enum xhci_flags bit)
+bool xhci_get_flag(XHCIState *xhci, enum xhci_flags bit)
 {
     return xhci->flags & (1 << bit);
 }
 
-static void xhci_set_flag(XHCIState *xhci, enum xhci_flags bit)
+void xhci_set_flag(XHCIState *xhci, enum xhci_flags bit)
 {
     xhci->flags |= (1 << bit);
 }
@@ -3692,13 +3691,6 @@  static Property xhci_properties[] = {
     DEFINE_PROP_END_OF_LIST(),
 };
 
-static void xhci_instance_init(Object *obj)
-{
-    /* QEMU_PCI_CAP_EXPRESS initialization does not depend on QEMU command
-     * line, therefore, no need to wait to realize like other devices */
-    PCI_DEVICE(obj)->cap_present |= QEMU_PCI_CAP_EXPRESS;
-}
-
 static void xhci_class_init(ObjectClass *klass, void *data)
 {
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
@@ -3718,7 +3710,6 @@  static const TypeInfo xhci_info = {
     .parent        = TYPE_PCI_DEVICE,
     .instance_size = sizeof(XHCIState),
     .class_init    = xhci_class_init,
-    .instance_init = xhci_instance_init,
     .abstract      = true,
     .interfaces = (InterfaceInfo[]) {
         { INTERFACE_PCIE_DEVICE },
@@ -3727,37 +3718,9 @@  static const TypeInfo xhci_info = {
     },
 };
 
-static void qemu_xhci_class_init(ObjectClass *klass, void *data)
-{
-    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
-
-    k->vendor_id    = PCI_VENDOR_ID_REDHAT;
-    k->device_id    = PCI_DEVICE_ID_REDHAT_XHCI;
-    k->revision     = 0x01;
-}
-
-static void qemu_xhci_instance_init(Object *obj)
-{
-    XHCIState *xhci = XHCI(obj);
-
-    xhci->msi      = ON_OFF_AUTO_OFF;
-    xhci->msix     = ON_OFF_AUTO_AUTO;
-    xhci->numintrs = MAXINTRS;
-    xhci->numslots = MAXSLOTS;
-    xhci_set_flag(xhci, XHCI_FLAG_SS_FIRST);
-}
-
-static const TypeInfo qemu_xhci_info = {
-    .name          = TYPE_QEMU_XHCI,
-    .parent        = TYPE_XHCI,
-    .class_init    = qemu_xhci_class_init,
-    .instance_init = qemu_xhci_instance_init,
-};
-
 static void xhci_register_types(void)
 {
     type_register_static(&xhci_info);
-    type_register_static(&qemu_xhci_info);
 }
 
 type_init(xhci_register_types)
diff --git a/hw/usb/hcd-xhci.h b/hw/usb/hcd-xhci.h
index edbd926..dd5fcd4 100644
--- a/hw/usb/hcd-xhci.h
+++ b/hw/usb/hcd-xhci.h
@@ -23,6 +23,7 @@ 
 #define HW_USB_HCD_XHCI_H
 
 #include "sysemu/dma.h"
+#include "hw/usb.h"
 
 #define TYPE_XHCI "base-xhci"
 #define TYPE_NEC_XHCI "nec-usb-xhci"
@@ -232,4 +233,6 @@  struct XHCIState {
     bool nec_quirks;
 };
 
+bool xhci_get_flag(XHCIState *xhci, enum xhci_flags bit);
+void xhci_set_flag(XHCIState *xhci, enum xhci_flags bit);
 #endif