xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/
@ 2020-07-04 14:49 Philippe Mathieu-Daudé
  2020-07-04 14:49 ` [PATCH 01/26] hw/arm/sbsa-ref: Remove unused 'hw/usb.h' header Philippe Mathieu-Daudé
                   ` (26 more replies)
  0 siblings, 27 replies; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

Hi,

This is the second time I try to replace a magic typename string
by a constant, and Zoltan warns me this is counter productive as
"hw/usb.h" pulls in an insane amount of code.

Time to give the usb subsystem some love and move forward.

This series can be decomposed as follow:

 1-2:    preliminary machine cleanups (arm/ppc)
 3-13:   usb related headers cleanups
 14-15:  usb quirks cleanup
 16-18:  refactor usb_get_dev_path() to add usb_get_port_path()
 19:     let spapr use usb_get_port_path() to make USBDevice opaque
 20:     extract the public USB API (for machine/board/soc)
 21:     make the older "usb.h" internal to hw/usb/
 22-25:  use TYPENAME definitions
 26:     cover dwc2 in MAINTAINERS

Please review.

Phil.

Philippe Mathieu-Daudé (26):
  hw/arm/sbsa-ref: Remove unused 'hw/usb.h' header
  hw/ppc/sam460ex: Add missing 'hw/pci/pci.h' header
  hw/usb: Remove unused VM_USB_HUB_SIZE definition
  hw/usb: Reduce 'exec/memory.h' inclusion
  hw/usb/desc: Add missing header
  hw/usb/hcd-dwc2: Remove unnecessary includes
  hw/usb/hcd-dwc2: Restrict some headers to source
  hw/usb/hcd-dwc2: Restrict 'dwc2-regs.h' scope
  hw/usb/hcd-ehci: Remove unnecessary include
  hw/usb/hcd-ehci: Move few definitions from header to source
  hw/usb/hcd-xhci: Add missing header
  hw/usb/hcd-musb: Restrict header scope
  hw/usb/desc: Reduce some declarations scope
  hw/usb/quirks: Rename included source with '.inc.c' suffix
  hw/usb: Add new 'usb-quirks.h' local header
  hw/usb/bus: Simplify usb_get_dev_path()
  hw/usb/bus: Rename usb_get_dev_path() as usb_get_full_dev_path()
  hw/usb/bus: Add usb_get_port_path()
  hw/ppc/spapr: Use usb_get_port_path()
  hw/usb: Introduce "hw/usb/usb.h" public API
  hw/usb: Move internal API to local 'usb-internal.h' header
  hw/usb/usb-hcd: Use OHCI type definitions
  hw/usb/usb-hcd: Use EHCI type definitions
  hw/usb/usb-hcd: Use UHCI type definitions
  hw/usb/usb-hcd: Use XHCI type definitions
  MAINTAINERS: Cover dwc-hsotg (dwc2) USB host controller emulation

 hw/usb/desc.h                             | 11 +++++
 {include/hw => hw}/usb/dwc2-regs.h        |  0
 hw/usb/hcd-dwc2.h                         |  5 +-
 hw/usb/hcd-ehci.h                         | 24 +---------
 {include/hw => hw}/usb/hcd-musb.h         |  2 +
 hw/usb/hcd-ohci.h                         |  4 +-
 hw/usb/hcd-xhci.h                         |  4 +-
 include/hw/usb.h => hw/usb/usb-internal.h | 50 ++-----------------
 hw/usb/usb-quirks.h                       | 27 +++++++++++
 include/hw/usb/chipidea.h                 |  2 +-
 include/hw/usb/usb-hcd.h                  | 36 ++++++++++++++
 include/hw/usb/usb.h                      | 58 +++++++++++++++++++++++
 chardev/baum.c                            |  2 +-
 hw/arm/allwinner-a10.c                    |  2 +-
 hw/arm/allwinner-h3.c                     | 10 ++--
 hw/arm/exynos4210.c                       |  2 +-
 hw/arm/pxa2xx.c                           |  3 +-
 hw/arm/realview.c                         |  3 +-
 hw/arm/sbsa-ref.c                         |  4 +-
 hw/arm/versatilepb.c                      |  3 +-
 hw/arm/xilinx_zynq.c                      |  2 +-
 hw/display/sm501.c                        |  3 +-
 hw/i386/pc.c                              |  2 +-
 hw/i386/pc_piix.c                         |  5 +-
 hw/i386/pc_q35.c                          | 15 +++---
 hw/isa/piix4.c                            |  3 +-
 hw/mips/fuloong2e.c                       |  5 +-
 hw/ppc/mac_newworld.c                     |  5 +-
 hw/ppc/mac_oldworld.c                     |  3 +-
 hw/ppc/sam460ex.c                         |  6 ++-
 hw/ppc/spapr.c                            | 13 +++--
 hw/sh4/r2d.c                              |  2 +-
 hw/usb/bus.c                              | 40 +++++++++-------
 hw/usb/chipidea.c                         |  1 +
 hw/usb/combined-packet.c                  |  2 +-
 hw/usb/core.c                             |  2 +-
 hw/usb/desc-msos.c                        |  2 +-
 hw/usb/desc.c                             |  3 +-
 hw/usb/dev-audio.c                        |  2 +-
 hw/usb/dev-hid.c                          |  2 +-
 hw/usb/dev-hub.c                          |  2 +-
 hw/usb/dev-mtp.c                          |  2 +-
 hw/usb/dev-network.c                      |  2 +-
 hw/usb/dev-serial.c                       |  2 +-
 hw/usb/dev-smartcard-reader.c             |  2 +-
 hw/usb/dev-storage.c                      |  2 +-
 hw/usb/dev-uas.c                          |  2 +-
 hw/usb/dev-wacom.c                        |  2 +-
 hw/usb/hcd-dwc2.c                         |  8 ++--
 hw/usb/hcd-ehci-sysbus.c                  |  1 +
 hw/usb/hcd-ehci.c                         | 13 ++++-
 hw/usb/hcd-musb.c                         |  4 +-
 hw/usb/hcd-ohci-pci.c                     |  4 +-
 hw/usb/hcd-ohci.c                         |  1 -
 hw/usb/hcd-uhci.c                         | 21 ++++----
 hw/usb/hcd-xhci-nec.c                     |  3 +-
 hw/usb/hcd-xhci.c                         |  2 +-
 hw/usb/host-libusb.c                      |  2 +-
 hw/usb/host-stub.c                        |  2 +-
 hw/usb/libhw.c                            |  2 +-
 hw/usb/quirks.c                           |  5 +-
 hw/usb/{quirks.h => quirks.inc.c}         |  5 --
 hw/usb/redirect.c                         |  3 +-
 hw/usb/tusb6010.c                         |  4 +-
 hw/usb/xen-usb.c                          |  2 +-
 monitor/misc.c                            |  2 +-
 softmmu/vl.c                              |  2 +-
 MAINTAINERS                               |  7 ++-
 68 files changed, 294 insertions(+), 185 deletions(-)
 rename {include/hw => hw}/usb/dwc2-regs.h (100%)
 rename {include/hw => hw}/usb/hcd-musb.h (98%)
 rename include/hw/usb.h => hw/usb/usb-internal.h (92%)
 create mode 100644 hw/usb/usb-quirks.h
 create mode 100644 include/hw/usb/usb-hcd.h
 create mode 100644 include/hw/usb/usb.h
 rename hw/usb/{quirks.h => quirks.inc.c} (99%)

-- 
2.21.3



^ permalink raw reply	[flat|nested] 63+ messages in thread

* [PATCH 01/26] hw/arm/sbsa-ref: Remove unused 'hw/usb.h' header
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-06 16:49   ` Alistair Francis
  2020-07-04 14:49 ` [PATCH 02/26] hw/ppc/sam460ex: Add missing 'hw/pci/pci.h' header Philippe Mathieu-Daudé
                   ` (25 subsequent siblings)
  26 siblings, 1 reply; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

This file doesn't access anything from "hw/usb.h", remove its
inclusion.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/sbsa-ref.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
index e40c868a82..021e7c1b8b 100644
--- a/hw/arm/sbsa-ref.c
+++ b/hw/arm/sbsa-ref.c
@@ -38,7 +38,6 @@
 #include "hw/loader.h"
 #include "hw/pci-host/gpex.h"
 #include "hw/qdev-properties.h"
-#include "hw/usb.h"
 #include "hw/char/pl011.h"
 #include "net/net.h"
 
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 02/26] hw/ppc/sam460ex: Add missing 'hw/pci/pci.h' header
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
  2020-07-04 14:49 ` [PATCH 01/26] hw/arm/sbsa-ref: Remove unused 'hw/usb.h' header Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-06 16:50   ` Alistair Francis
  2020-07-04 14:49 ` [PATCH 03/26] hw/usb: Remove unused VM_USB_HUB_SIZE definition Philippe Mathieu-Daudé
                   ` (24 subsequent siblings)
  26 siblings, 1 reply; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

This file uses pci_create_simple() and PCI_DEVFN() which are both
declared in "hw/pci/pci.h". This include is indirectly included
by an USB header. As we want to reduce the USB header inclusions
later, include the PCI header now, to avoid later:

  hw/ppc/sam460ex.c:397:5: error: implicit declaration of function ‘pci_create_simple’; did you mean ‘sysbus_create_simple’? [-Werror=implicit-function-declaration]
    397 |     pci_create_simple(pci_bus, PCI_DEVFN(6, 0), "sm501");
        |     ^~~~~~~~~~~~~~~~~
        |     sysbus_create_simple
  hw/ppc/sam460ex.c:397:5: error: nested extern declaration of ‘pci_create_simple’ [-Werror=nested-externs]
  hw/ppc/sam460ex.c:397:32: error: implicit declaration of function ‘PCI_DEVFN’ [-Werror=implicit-function-declaration]
    397 |     pci_create_simple(pci_bus, PCI_DEVFN(6, 0), "sm501");
        |                                ^~~~~~~~~
  hw/ppc/sam460ex.c:397:32: error: nested extern declaration of ‘PCI_DEVFN’ [-Werror=nested-externs]

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/ppc/sam460ex.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
index 1a106a68de..fae970b142 100644
--- a/hw/ppc/sam460ex.c
+++ b/hw/ppc/sam460ex.c
@@ -38,6 +38,7 @@
 #include "hw/usb/hcd-ehci.h"
 #include "hw/ppc/fdt.h"
 #include "hw/qdev-properties.h"
+#include "hw/pci/pci.h"
 
 #include <libfdt.h>
 
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 03/26] hw/usb: Remove unused VM_USB_HUB_SIZE definition
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
  2020-07-04 14:49 ` [PATCH 01/26] hw/arm/sbsa-ref: Remove unused 'hw/usb.h' header Philippe Mathieu-Daudé
  2020-07-04 14:49 ` [PATCH 02/26] hw/ppc/sam460ex: Add missing 'hw/pci/pci.h' header Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-06 16:51   ` Alistair Francis
  2020-07-04 14:49 ` [PATCH 04/26] hw/usb: Reduce 'exec/memory.h' inclusion Philippe Mathieu-Daudé
                   ` (23 subsequent siblings)
  26 siblings, 1 reply; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

Commit a5d2f7273c ("qdev/usb: make qemu aware of usb busses")
removed the last use of VM_USB_HUB_SIZE, 11 years ago. Time
to drop it.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/hw/usb.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/include/hw/usb.h b/include/hw/usb.h
index e29a37635b..4f04a1a879 100644
--- a/include/hw/usb.h
+++ b/include/hw/usb.h
@@ -470,10 +470,6 @@ void usb_generic_async_ctrl_complete(USBDevice *s, USBPacket *p);
 void hmp_info_usbhost(Monitor *mon, const QDict *qdict);
 bool usb_host_dev_is_scsi_storage(USBDevice *usbdev);
 
-/* usb ports of the VM */
-
-#define VM_USB_HUB_SIZE 8
-
 /* usb-bus.c */
 
 #define TYPE_USB_BUS "usb-bus"
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 04/26] hw/usb: Reduce 'exec/memory.h' inclusion
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2020-07-04 14:49 ` [PATCH 03/26] hw/usb: Remove unused VM_USB_HUB_SIZE definition Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-06 16:52   ` Alistair Francis
  2020-07-04 14:49 ` [PATCH 05/26] hw/usb/desc: Add missing header Philippe Mathieu-Daudé
                   ` (22 subsequent siblings)
  26 siblings, 1 reply; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

"exec/memory.h" is only required by "hw/usb/hcd-musb.h".
Include it there directly.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/hw/usb.h          | 1 -
 include/hw/usb/hcd-musb.h | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/hw/usb.h b/include/hw/usb.h
index 4f04a1a879..15b2ef300a 100644
--- a/include/hw/usb.h
+++ b/include/hw/usb.h
@@ -25,7 +25,6 @@
  * THE SOFTWARE.
  */
 
-#include "exec/memory.h"
 #include "hw/qdev-core.h"
 #include "qemu/iov.h"
 #include "qemu/queue.h"
diff --git a/include/hw/usb/hcd-musb.h b/include/hw/usb/hcd-musb.h
index c874b9f292..ec3ee5c4b0 100644
--- a/include/hw/usb/hcd-musb.h
+++ b/include/hw/usb/hcd-musb.h
@@ -13,6 +13,8 @@
 #ifndef HW_USB_MUSB_H
 #define HW_USB_MUSB_H
 
+#include "exec/memory.h"
+
 enum musb_irq_source_e {
     musb_irq_suspend = 0,
     musb_irq_resume,
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 05/26] hw/usb/desc: Add missing header
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2020-07-04 14:49 ` [PATCH 04/26] hw/usb: Reduce 'exec/memory.h' inclusion Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-06 16:55   ` Alistair Francis
  2020-07-04 14:49 ` [PATCH 06/26] hw/usb/hcd-dwc2: Remove unnecessary includes Philippe Mathieu-Daudé
                   ` (21 subsequent siblings)
  26 siblings, 1 reply; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

This header uses the USBPacket and USBDevice types which are
forward declared in "hw/usb.h".

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/usb/desc.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/usb/desc.h b/hw/usb/desc.h
index 4d81c68e0e..92594fbe29 100644
--- a/hw/usb/desc.h
+++ b/hw/usb/desc.h
@@ -2,6 +2,7 @@
 #define QEMU_HW_USB_DESC_H
 
 #include <wchar.h>
+#include "hw/usb.h"
 
 /* binary representation */
 typedef struct USBDescriptor {
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 06/26] hw/usb/hcd-dwc2: Remove unnecessary includes
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2020-07-04 14:49 ` [PATCH 05/26] hw/usb/desc: Add missing header Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-06 16:54   ` Alistair Francis
  2020-07-06 23:28   ` Paul Zimmerman
  2020-07-04 14:49 ` [PATCH 07/26] hw/usb/hcd-dwc2: Restrict some headers to source Philippe Mathieu-Daudé
                   ` (20 subsequent siblings)
  26 siblings, 2 replies; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

"qemu/error-report.h" and "qemu/main-loop.h" are not used.
Remove them.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/usb/hcd-dwc2.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/hw/usb/hcd-dwc2.c b/hw/usb/hcd-dwc2.c
index 72cbd051f3..590e75b455 100644
--- a/hw/usb/hcd-dwc2.c
+++ b/hw/usb/hcd-dwc2.c
@@ -39,8 +39,6 @@
 #include "migration/vmstate.h"
 #include "trace.h"
 #include "qemu/log.h"
-#include "qemu/error-report.h"
-#include "qemu/main-loop.h"
 #include "hw/qdev-properties.h"
 
 #define USB_HZ_FS       12000000
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 07/26] hw/usb/hcd-dwc2: Restrict some headers to source
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2020-07-04 14:49 ` [PATCH 06/26] hw/usb/hcd-dwc2: Remove unnecessary includes Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-06 16:54   ` Alistair Francis
  2020-07-06 23:27   ` Paul Zimmerman
  2020-07-04 14:49 ` [PATCH 08/26] hw/usb/hcd-dwc2: Restrict 'dwc2-regs.h' scope Philippe Mathieu-Daudé
                   ` (19 subsequent siblings)
  26 siblings, 2 replies; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

The header "usb/hcd-dwc2.h" doesn't need to include "qemu/timer.h",
"sysemu/dma.h", "hw/irq.h" (the types required are forward declared).
Include them in the source file which is the only one requiring the
function declarations.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/usb/hcd-dwc2.h | 3 ---
 hw/usb/hcd-dwc2.c | 3 +++
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/usb/hcd-dwc2.h b/hw/usb/hcd-dwc2.h
index 4ba809a07b..2adf0f53c7 100644
--- a/hw/usb/hcd-dwc2.h
+++ b/hw/usb/hcd-dwc2.h
@@ -19,11 +19,8 @@
 #ifndef HW_USB_DWC2_H
 #define HW_USB_DWC2_H
 
-#include "qemu/timer.h"
-#include "hw/irq.h"
 #include "hw/sysbus.h"
 #include "hw/usb.h"
-#include "sysemu/dma.h"
 
 #define DWC2_MMIO_SIZE      0x11000
 
diff --git a/hw/usb/hcd-dwc2.c b/hw/usb/hcd-dwc2.c
index 590e75b455..ccf05d0823 100644
--- a/hw/usb/hcd-dwc2.c
+++ b/hw/usb/hcd-dwc2.c
@@ -36,8 +36,11 @@
 #include "qapi/error.h"
 #include "hw/usb/dwc2-regs.h"
 #include "hw/usb/hcd-dwc2.h"
+#include "hw/irq.h"
+#include "sysemu/dma.h"
 #include "migration/vmstate.h"
 #include "trace.h"
+#include "qemu/timer.h"
 #include "qemu/log.h"
 #include "hw/qdev-properties.h"
 
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 08/26] hw/usb/hcd-dwc2: Restrict 'dwc2-regs.h' scope
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2020-07-04 14:49 ` [PATCH 07/26] hw/usb/hcd-dwc2: Restrict some headers to source Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-06 16:47   ` Alistair Francis
  2020-07-06 23:29   ` Paul Zimmerman
  2020-07-04 14:49 ` [PATCH 09/26] hw/usb/hcd-ehci: Remove unnecessary include Philippe Mathieu-Daudé
                   ` (18 subsequent siblings)
  26 siblings, 2 replies; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

We only use these register definitions in files under the
hw/usb/ directory. Keep that header local by moving it there.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 {include/hw => hw}/usb/dwc2-regs.h | 0
 hw/usb/hcd-dwc2.c                  | 2 +-
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename {include/hw => hw}/usb/dwc2-regs.h (100%)

diff --git a/include/hw/usb/dwc2-regs.h b/hw/usb/dwc2-regs.h
similarity index 100%
rename from include/hw/usb/dwc2-regs.h
rename to hw/usb/dwc2-regs.h
diff --git a/hw/usb/hcd-dwc2.c b/hw/usb/hcd-dwc2.c
index ccf05d0823..252b60ef65 100644
--- a/hw/usb/hcd-dwc2.c
+++ b/hw/usb/hcd-dwc2.c
@@ -34,7 +34,6 @@
 #include "qemu/osdep.h"
 #include "qemu/units.h"
 #include "qapi/error.h"
-#include "hw/usb/dwc2-regs.h"
 #include "hw/usb/hcd-dwc2.h"
 #include "hw/irq.h"
 #include "sysemu/dma.h"
@@ -43,6 +42,7 @@
 #include "qemu/timer.h"
 #include "qemu/log.h"
 #include "hw/qdev-properties.h"
+#include "dwc2-regs.h"
 
 #define USB_HZ_FS       12000000
 #define USB_HZ_HS       96000000
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 09/26] hw/usb/hcd-ehci: Remove unnecessary include
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
                   ` (7 preceding siblings ...)
  2020-07-04 14:49 ` [PATCH 08/26] hw/usb/hcd-dwc2: Restrict 'dwc2-regs.h' scope Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-06 16:56   ` Alistair Francis
  2020-07-04 14:49 ` [PATCH 10/26] hw/usb/hcd-ehci: Move few definitions from header to source Philippe Mathieu-Daudé
                   ` (17 subsequent siblings)
  26 siblings, 1 reply; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

As "qemu/main-loop.h" is not used, remove it.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/usb/hcd-ehci.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index 1495e8f7fa..256fb91e0c 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -34,7 +34,6 @@
 #include "migration/vmstate.h"
 #include "trace.h"
 #include "qemu/error-report.h"
-#include "qemu/main-loop.h"
 #include "sysemu/runstate.h"
 
 #define FRAME_TIMER_FREQ 1000
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 10/26] hw/usb/hcd-ehci: Move few definitions from header to source
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
                   ` (8 preceding siblings ...)
  2020-07-04 14:49 ` [PATCH 09/26] hw/usb/hcd-ehci: Remove unnecessary include Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-06 17:00   ` Alistair Francis
  2020-07-04 14:49 ` [PATCH 11/26] hw/usb/hcd-xhci: Add missing header Philippe Mathieu-Daudé
                   ` (16 subsequent siblings)
  26 siblings, 1 reply; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

Move definitions only useful for hcd-ehci.c to this source file.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/usb/hcd-ehci.h | 11 -----------
 hw/usb/hcd-ehci.c | 12 ++++++++++++
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h
index 57b38cfc05..4577f5e31d 100644
--- a/hw/usb/hcd-ehci.h
+++ b/hw/usb/hcd-ehci.h
@@ -24,17 +24,6 @@
 #include "hw/pci/pci.h"
 #include "hw/sysbus.h"
 
-#ifndef EHCI_DEBUG
-#define EHCI_DEBUG   0
-#endif
-
-#if EHCI_DEBUG
-#define DPRINTF printf
-#else
-#define DPRINTF(...)
-#endif
-
-#define MMIO_SIZE        0x1000
 #define CAPA_SIZE        0x10
 
 #define NB_PORTS         6        /* Max. Number of downstream ports */
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index 256fb91e0c..a0beee527c 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -36,6 +36,18 @@
 #include "qemu/error-report.h"
 #include "sysemu/runstate.h"
 
+#ifndef EHCI_DEBUG
+#define EHCI_DEBUG   0
+#endif
+
+#if EHCI_DEBUG
+#define DPRINTF printf
+#else
+#define DPRINTF(...)
+#endif
+
+#define MMIO_SIZE        0x1000
+
 #define FRAME_TIMER_FREQ 1000
 #define FRAME_TIMER_NS   (NANOSECONDS_PER_SECOND / FRAME_TIMER_FREQ)
 #define UFRAME_TIMER_NS  (FRAME_TIMER_NS / 8)
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 11/26] hw/usb/hcd-xhci: Add missing header
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
                   ` (9 preceding siblings ...)
  2020-07-04 14:49 ` [PATCH 10/26] hw/usb/hcd-ehci: Move few definitions from header to source Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-06 16:57   ` Alistair Francis
  2020-07-04 14:49 ` [PATCH 12/26] hw/usb/hcd-musb: Restrict header scope Philippe Mathieu-Daudé
                   ` (15 subsequent siblings)
  26 siblings, 1 reply; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

This header uses the USBPort type which is forward declared
by "hw/usb.h".

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/usb/hcd-xhci.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/usb/hcd-xhci.h b/hw/usb/hcd-xhci.h
index 946af51fc2..8edbdc2c3e 100644
--- a/hw/usb/hcd-xhci.h
+++ b/hw/usb/hcd-xhci.h
@@ -22,6 +22,8 @@
 #ifndef HW_USB_HCD_XHCI_H
 #define HW_USB_HCD_XHCI_H
 
+#include "hw/usb.h"
+
 #define TYPE_XHCI "base-xhci"
 #define TYPE_NEC_XHCI "nec-usb-xhci"
 #define TYPE_QEMU_XHCI "qemu-xhci"
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 12/26] hw/usb/hcd-musb: Restrict header scope
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
                   ` (10 preceding siblings ...)
  2020-07-04 14:49 ` [PATCH 11/26] hw/usb/hcd-xhci: Add missing header Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-06 16:58   ` Alistair Francis
  2020-07-04 14:49 ` [PATCH 13/26] hw/usb/desc: Reduce some declarations scope Philippe Mathieu-Daudé
                   ` (14 subsequent siblings)
  26 siblings, 1 reply; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

"hcd-musb.h" is only required by USB device implementions.
As we keep these implementations in the hw/usb/ directory,
move the header there.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 {include/hw => hw}/usb/hcd-musb.h | 0
 hw/usb/hcd-musb.c                 | 2 +-
 hw/usb/tusb6010.c                 | 2 +-
 3 files changed, 2 insertions(+), 2 deletions(-)
 rename {include/hw => hw}/usb/hcd-musb.h (100%)

diff --git a/include/hw/usb/hcd-musb.h b/hw/usb/hcd-musb.h
similarity index 100%
rename from include/hw/usb/hcd-musb.h
rename to hw/usb/hcd-musb.h
diff --git a/hw/usb/hcd-musb.c b/hw/usb/hcd-musb.c
index 85f5ff5bd4..b8d8766a4a 100644
--- a/hw/usb/hcd-musb.c
+++ b/hw/usb/hcd-musb.c
@@ -23,9 +23,9 @@
 #include "qemu/osdep.h"
 #include "qemu/timer.h"
 #include "hw/usb.h"
-#include "hw/usb/hcd-musb.h"
 #include "hw/irq.h"
 #include "hw/hw.h"
+#include "hcd-musb.h"
 
 /* Common USB registers */
 #define MUSB_HDRC_FADDR		0x00	/* 8-bit */
diff --git a/hw/usb/tusb6010.c b/hw/usb/tusb6010.c
index 27eb28d3e4..9f9b81b09d 100644
--- a/hw/usb/tusb6010.c
+++ b/hw/usb/tusb6010.c
@@ -23,11 +23,11 @@
 #include "qemu/module.h"
 #include "qemu/timer.h"
 #include "hw/usb.h"
-#include "hw/usb/hcd-musb.h"
 #include "hw/arm/omap.h"
 #include "hw/hw.h"
 #include "hw/irq.h"
 #include "hw/sysbus.h"
+#include "hcd-musb.h"
 
 #define TYPE_TUSB6010 "tusb6010"
 #define TUSB(obj) OBJECT_CHECK(TUSBState, (obj), TYPE_TUSB6010)
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 13/26] hw/usb/desc: Reduce some declarations scope
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
                   ` (11 preceding siblings ...)
  2020-07-04 14:49 ` [PATCH 12/26] hw/usb/hcd-musb: Restrict header scope Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-06 17:00   ` Alistair Francis
  2020-07-04 14:49 ` [PATCH 14/26] hw/usb/quirks: Rename included source with '.inc.c' suffix Philippe Mathieu-Daudé
                   ` (13 subsequent siblings)
  26 siblings, 1 reply; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

USBDescString is forward-declared. Only bus.c uses the
usb_device_get_product_desc() and usb_device_get_usb_desc()
function. Move all that to the "desc.h" header to reduce
the big "hw/usb.h" header a bit.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/usb/desc.h    | 10 ++++++++++
 include/hw/usb.h | 10 ----------
 hw/usb/bus.c     |  1 +
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/hw/usb/desc.h b/hw/usb/desc.h
index 92594fbe29..4bf6966c4b 100644
--- a/hw/usb/desc.h
+++ b/hw/usb/desc.h
@@ -242,4 +242,14 @@ int usb_desc_get_descriptor(USBDevice *dev, USBPacket *p,
 int usb_desc_handle_control(USBDevice *dev, USBPacket *p,
         int request, int value, int index, int length, uint8_t *data);
 
+const char *usb_device_get_product_desc(USBDevice *dev);
+
+const USBDesc *usb_device_get_usb_desc(USBDevice *dev);
+
+struct USBDescString {
+    uint8_t index;
+    char *str;
+    QLIST_ENTRY(USBDescString) next;
+};
+
 #endif /* QEMU_HW_USB_DESC_H */
diff --git a/include/hw/usb.h b/include/hw/usb.h
index 15b2ef300a..18f1349bdc 100644
--- a/include/hw/usb.h
+++ b/include/hw/usb.h
@@ -192,12 +192,6 @@ typedef struct USBDescOther USBDescOther;
 typedef struct USBDescString USBDescString;
 typedef struct USBDescMSOS USBDescMSOS;
 
-struct USBDescString {
-    uint8_t index;
-    char *str;
-    QLIST_ENTRY(USBDescString) next;
-};
-
 #define USB_MAX_ENDPOINTS  15
 #define USB_MAX_INTERFACES 16
 
@@ -555,10 +549,6 @@ int usb_device_alloc_streams(USBDevice *dev, USBEndpoint **eps, int nr_eps,
                              int streams);
 void usb_device_free_streams(USBDevice *dev, USBEndpoint **eps, int nr_eps);
 
-const char *usb_device_get_product_desc(USBDevice *dev);
-
-const USBDesc *usb_device_get_usb_desc(USBDevice *dev);
-
 /* quirks.c */
 
 /* In bulk endpoints are streaming data sources (iow behave like isoc eps) */
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 957559b18d..111c3af7c1 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -9,6 +9,7 @@
 #include "monitor/monitor.h"
 #include "trace.h"
 #include "qemu/cutils.h"
+#include "desc.h"
 
 static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent);
 
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 14/26] hw/usb/quirks: Rename included source with '.inc.c' suffix
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
                   ` (12 preceding siblings ...)
  2020-07-04 14:49 ` [PATCH 13/26] hw/usb/desc: Reduce some declarations scope Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-06 17:02   ` Alistair Francis
  2020-07-04 14:49 ` [PATCH 15/26] hw/usb: Add new 'usb-quirks.h' local header Philippe Mathieu-Daudé
                   ` (12 subsequent siblings)
  26 siblings, 1 reply; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

This file is not a header, but contains source code which is
included and compiled once. We use the '.inc.c' suffix in few
other cases in the repository. Follow the same convention with
this file.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/usb/quirks.c                   | 2 +-
 hw/usb/{quirks.h => quirks.inc.c} | 5 -----
 2 files changed, 1 insertion(+), 6 deletions(-)
 rename hw/usb/{quirks.h => quirks.inc.c} (99%)

diff --git a/hw/usb/quirks.c b/hw/usb/quirks.c
index 23ea7a23ea..655b36f2d5 100644
--- a/hw/usb/quirks.c
+++ b/hw/usb/quirks.c
@@ -13,7 +13,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "quirks.h"
+#include "quirks.inc.c"
 #include "hw/usb.h"
 
 static bool usb_id_match(const struct usb_device_id *ids,
diff --git a/hw/usb/quirks.h b/hw/usb/quirks.inc.c
similarity index 99%
rename from hw/usb/quirks.h
rename to hw/usb/quirks.inc.c
index 50ef2f9c2e..004b228aba 100644
--- a/hw/usb/quirks.h
+++ b/hw/usb/quirks.inc.c
@@ -12,9 +12,6 @@
  * (at your option) any later version.
  */
 
-#ifndef HW_USB_QUIRKS_H
-#define HW_USB_QUIRKS_H
-
 /* 1 on 1 copy of linux/drivers/usb/serial/ftdi_sio_ids.h */
 #include "quirks-ftdi-ids.h"
 /* 1 on 1 copy of linux/drivers/usb/serial/pl2303.h */
@@ -915,5 +912,3 @@ static const struct usb_device_id usbredir_ftdi_serial_ids[] = {
 
 #undef USB_DEVICE
 #undef USB_DEVICE_AND_INTERFACE_INFO
-
-#endif
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 15/26] hw/usb: Add new 'usb-quirks.h' local header
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
                   ` (13 preceding siblings ...)
  2020-07-04 14:49 ` [PATCH 14/26] hw/usb/quirks: Rename included source with '.inc.c' suffix Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-06 17:45   ` Alistair Francis
  2020-07-04 14:49 ` [PATCH 16/26] hw/usb/bus: Simplify usb_get_dev_path() Philippe Mathieu-Daudé
                   ` (11 subsequent siblings)
  26 siblings, 1 reply; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

Only redirect.c consumes the quirks API. Reduce the big "hw/usb.h"
header by moving the quirks related declaration into their own
header. As nothing out of hw/usb/ requires it, keep it local.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/usb/usb-quirks.h | 27 +++++++++++++++++++++++++++
 include/hw/usb.h    | 11 -----------
 hw/usb/quirks.c     |  1 +
 hw/usb/redirect.c   |  1 +
 4 files changed, 29 insertions(+), 11 deletions(-)
 create mode 100644 hw/usb/usb-quirks.h

diff --git a/hw/usb/usb-quirks.h b/hw/usb/usb-quirks.h
new file mode 100644
index 0000000000..542889efc4
--- /dev/null
+++ b/hw/usb/usb-quirks.h
@@ -0,0 +1,27 @@
+/*
+ * USB quirk handling
+ *
+ * Copyright (c) 2012 Red Hat, Inc.
+ *
+ * Red Hat Authors:
+ * Hans de Goede <hdegoede@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef HW_USB_QUIRKS_H
+#define HW_USB_QUIRKS_H
+
+/* In bulk endpoints are streaming data sources (iow behave like isoc eps) */
+#define USB_QUIRK_BUFFER_BULK_IN        0x01
+/* Bulk pkts in FTDI format, need special handling when combining packets */
+#define USB_QUIRK_IS_FTDI               0x02
+
+int usb_get_quirks(uint16_t vendor_id, uint16_t product_id,
+                   uint8_t interface_class, uint8_t interface_subclass,
+                   uint8_t interface_protocol);
+
+#endif
diff --git a/include/hw/usb.h b/include/hw/usb.h
index 18f1349bdc..8c3bc920ff 100644
--- a/include/hw/usb.h
+++ b/include/hw/usb.h
@@ -549,15 +549,4 @@ int usb_device_alloc_streams(USBDevice *dev, USBEndpoint **eps, int nr_eps,
                              int streams);
 void usb_device_free_streams(USBDevice *dev, USBEndpoint **eps, int nr_eps);
 
-/* quirks.c */
-
-/* In bulk endpoints are streaming data sources (iow behave like isoc eps) */
-#define USB_QUIRK_BUFFER_BULK_IN	0x01
-/* Bulk pkts in FTDI format, need special handling when combining packets */
-#define USB_QUIRK_IS_FTDI		0x02
-
-int usb_get_quirks(uint16_t vendor_id, uint16_t product_id,
-                   uint8_t interface_class, uint8_t interface_subclass,
-                   uint8_t interface_protocol);
-
 #endif
diff --git a/hw/usb/quirks.c b/hw/usb/quirks.c
index 655b36f2d5..b0d0f87e35 100644
--- a/hw/usb/quirks.c
+++ b/hw/usb/quirks.c
@@ -15,6 +15,7 @@
 #include "qemu/osdep.h"
 #include "quirks.inc.c"
 #include "hw/usb.h"
+#include "usb-quirks.h"
 
 static bool usb_id_match(const struct usb_device_id *ids,
                          uint16_t vendor_id, uint16_t product_id,
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 417a60a2e6..4c5925a039 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -45,6 +45,7 @@
 #include "hw/usb.h"
 #include "migration/qemu-file-types.h"
 #include "migration/vmstate.h"
+#include "usb-quirks.h"
 
 /* ERROR is defined below. Remove any previous definition. */
 #undef ERROR
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 16/26] hw/usb/bus: Simplify usb_get_dev_path()
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
                   ` (14 preceding siblings ...)
  2020-07-04 14:49 ` [PATCH 15/26] hw/usb: Add new 'usb-quirks.h' local header Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-06 17:46   ` Alistair Francis
  2020-07-04 14:49 ` [PATCH 17/26] hw/usb/bus: Rename usb_get_dev_path() as usb_get_full_dev_path() Philippe Mathieu-Daudé
                   ` (10 subsequent siblings)
  26 siblings, 1 reply; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

Simplify usb_get_dev_path() a bit.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/usb/bus.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 111c3af7c1..f8901e822c 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -580,19 +580,18 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)
 static char *usb_get_dev_path(DeviceState *qdev)
 {
     USBDevice *dev = USB_DEVICE(qdev);
-    DeviceState *hcd = qdev->parent_bus->parent;
-    char *id = NULL;
 
     if (dev->flags & (1 << USB_DEV_FLAG_FULL_PATH)) {
-        id = qdev_get_dev_path(hcd);
-    }
-    if (id) {
-        char *ret = g_strdup_printf("%s/%s", id, dev->port->path);
-        g_free(id);
-        return ret;
-    } else {
-        return g_strdup(dev->port->path);
+        DeviceState *hcd = qdev->parent_bus->parent;
+        char *id = qdev_get_dev_path(hcd);
+
+        if (id) {
+            char *ret = g_strdup_printf("%s/%s", id, dev->port->path);
+            g_free(id);
+            return ret;
+        }
     }
+    return g_strdup(dev->port->path);
 }
 
 static char *usb_get_fw_dev_path(DeviceState *qdev)
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 17/26] hw/usb/bus: Rename usb_get_dev_path() as usb_get_full_dev_path()
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
                   ` (15 preceding siblings ...)
  2020-07-04 14:49 ` [PATCH 16/26] hw/usb/bus: Simplify usb_get_dev_path() Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-06 17:46   ` Alistair Francis
  2020-07-04 14:49 ` [PATCH 18/26] hw/usb/bus: Add usb_get_port_path() Philippe Mathieu-Daudé
                   ` (9 subsequent siblings)
  26 siblings, 1 reply; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

If the device has USB_DEV_FLAG_FULL_PATH set, usb_get_dev_path()
returns the full port path. Rename the function accordingly.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/usb/bus.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index f8901e822c..fad8194bf5 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -13,7 +13,7 @@
 
 static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent);
 
-static char *usb_get_dev_path(DeviceState *dev);
+static char *usb_get_full_dev_path(DeviceState *dev);
 static char *usb_get_fw_dev_path(DeviceState *qdev);
 static void usb_qdev_unrealize(DeviceState *qdev);
 
@@ -33,7 +33,7 @@ static void usb_bus_class_init(ObjectClass *klass, void *data)
     HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
 
     k->print_dev = usb_bus_dev_print;
-    k->get_dev_path = usb_get_dev_path;
+    k->get_dev_path = usb_get_full_dev_path;
     k->get_fw_dev_path = usb_get_fw_dev_path;
     hc->unplug = qdev_simple_device_unplug_cb;
 }
@@ -577,7 +577,7 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)
                    dev->attached ? ", attached" : "");
 }
 
-static char *usb_get_dev_path(DeviceState *qdev)
+static char *usb_get_full_dev_path(DeviceState *qdev)
 {
     USBDevice *dev = USB_DEVICE(qdev);
 
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 18/26] hw/usb/bus: Add usb_get_port_path()
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
                   ` (16 preceding siblings ...)
  2020-07-04 14:49 ` [PATCH 17/26] hw/usb/bus: Rename usb_get_dev_path() as usb_get_full_dev_path() Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-07  0:07   ` Alistair Francis
  2020-07-04 14:49 ` [PATCH 19/26] hw/ppc/spapr: Use usb_get_port_path() Philippe Mathieu-Daudé
                   ` (8 subsequent siblings)
  26 siblings, 1 reply; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

Refactor usb_get_full_dev_path() to take a 'want_full_path'
argument, and add usb_get_port_path() which returns a short
path.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/hw/usb.h | 10 ++++++++++
 hw/usb/bus.c     | 18 +++++++++++++-----
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/include/hw/usb.h b/include/hw/usb.h
index 8c3bc920ff..7ea502d421 100644
--- a/include/hw/usb.h
+++ b/include/hw/usb.h
@@ -506,6 +506,16 @@ void usb_port_location(USBPort *downstream, USBPort *upstream, int portnr);
 void usb_unregister_port(USBBus *bus, USBPort *port);
 void usb_claim_port(USBDevice *dev, Error **errp);
 void usb_release_port(USBDevice *dev);
+/**
+ * usb_get_port_path:
+ * @dev: the USB device
+ *
+ * The returned data must be released with g_free()
+ * when no longer required.
+ *
+ * Returns: a dynamically allocated pathname.
+ */
+char *usb_get_port_path(USBDevice *dev);
 void usb_device_attach(USBDevice *dev, Error **errp);
 int usb_device_detach(USBDevice *dev);
 void usb_check_attach(USBDevice *dev, Error **errp);
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index fad8194bf5..518e5b94ed 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -577,12 +577,10 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)
                    dev->attached ? ", attached" : "");
 }
 
-static char *usb_get_full_dev_path(DeviceState *qdev)
+static char *usb_get_dev_path(USBDevice *dev, bool want_full_path)
 {
-    USBDevice *dev = USB_DEVICE(qdev);
-
-    if (dev->flags & (1 << USB_DEV_FLAG_FULL_PATH)) {
-        DeviceState *hcd = qdev->parent_bus->parent;
+    if (want_full_path && (dev->flags & (1 << USB_DEV_FLAG_FULL_PATH))) {
+        DeviceState *hcd = DEVICE(dev)->parent_bus->parent;
         char *id = qdev_get_dev_path(hcd);
 
         if (id) {
@@ -594,6 +592,16 @@ static char *usb_get_full_dev_path(DeviceState *qdev)
     return g_strdup(dev->port->path);
 }
 
+static char *usb_get_full_dev_path(DeviceState *qdev)
+{
+    return usb_get_dev_path(USB_DEVICE(qdev), true);
+}
+
+char *usb_get_port_path(USBDevice *dev)
+{
+    return usb_get_dev_path(dev, false);
+}
+
 static char *usb_get_fw_dev_path(DeviceState *qdev)
 {
     USBDevice *dev = USB_DEVICE(qdev);
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 19/26] hw/ppc/spapr: Use usb_get_port_path()
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
                   ` (17 preceding siblings ...)
  2020-07-04 14:49 ` [PATCH 18/26] hw/usb/bus: Add usb_get_port_path() Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-07  0:07   ` Alistair Francis
  2020-07-04 14:49 ` [PATCH 20/26] hw/usb: Introduce "hw/usb/usb.h" public API Philippe Mathieu-Daudé
                   ` (7 subsequent siblings)
  26 siblings, 1 reply; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

To avoid to access the USBDevice internals, and use the
recently added usb_get_port_path() helper instead.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/ppc/spapr.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index f6f034d039..221d3e7a8c 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3121,7 +3121,8 @@ static char *spapr_get_fw_dev_path(FWPathProvider *p, BusState *bus,
              * We use SRP luns of the form 01000000 | (usb-port << 16) | lun
              * in the top 32 bits of the 64-bit LUN
              */
-            unsigned usb_port = atoi(usb->port->path);
+            g_autofree char *usb_port_path = usb_get_port_path(usb);
+            unsigned usb_port = atoi(usb_port_path);
             unsigned id = 0x1000000 | (usb_port << 16) | d->lun;
             return g_strdup_printf("%s@%"PRIX64, qdev_fw_name(dev),
                                    (uint64_t)id << 32);
@@ -3137,7 +3138,8 @@ static char *spapr_get_fw_dev_path(FWPathProvider *p, BusState *bus,
     if (strcmp("usb-host", qdev_fw_name(dev)) == 0) {
         USBDevice *usbdev = CAST(USBDevice, dev, TYPE_USB_DEVICE);
         if (usb_host_dev_is_scsi_storage(usbdev)) {
-            return g_strdup_printf("storage@%s/disk", usbdev->port->path);
+            g_autofree char *usb_port_path = usb_get_port_path(usbdev);
+            return g_strdup_printf("storage@%s/disk", usb_port_path);
         }
     }
 
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 20/26] hw/usb: Introduce "hw/usb/usb.h" public API
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
                   ` (18 preceding siblings ...)
  2020-07-04 14:49 ` [PATCH 19/26] hw/ppc/spapr: Use usb_get_port_path() Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-04 14:49 ` [PATCH 21/26] hw/usb: Move internal API to local 'usb-internal.h' header Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  26 siblings, 0 replies; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

Only the USB devices require to access the USB internal APIs.

The rest of the code base only wants to consume USB devices
with a generic API. Move the generic declarations to the new
"hw/usb/usb.h" header.

Reported-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/hw/usb.h      | 27 +-------------------
 include/hw/usb/usb.h  | 58 +++++++++++++++++++++++++++++++++++++++++++
 chardev/baum.c        |  2 +-
 hw/i386/pc.c          |  2 +-
 hw/i386/pc_piix.c     |  2 +-
 hw/i386/pc_q35.c      |  2 +-
 hw/ppc/mac_newworld.c |  2 +-
 hw/ppc/sam460ex.c     |  1 +
 hw/ppc/spapr.c        |  2 +-
 hw/sh4/r2d.c          |  2 +-
 hw/usb/host-stub.c    |  2 +-
 monitor/misc.c        |  2 +-
 softmmu/vl.c          |  2 +-
 13 files changed, 70 insertions(+), 36 deletions(-)
 create mode 100644 include/hw/usb/usb.h

diff --git a/include/hw/usb.h b/include/hw/usb.h
index 7ea502d421..2ea5186ea5 100644
--- a/include/hw/usb.h
+++ b/include/hw/usb.h
@@ -26,6 +26,7 @@
  */
 
 #include "hw/qdev-core.h"
+#include "hw/usb/usb.h"
 #include "qemu/iov.h"
 #include "qemu/queue.h"
 
@@ -176,7 +177,6 @@
 typedef struct USBBus USBBus;
 typedef struct USBBusOps USBBusOps;
 typedef struct USBPort USBPort;
-typedef struct USBDevice USBDevice;
 typedef struct USBPacket USBPacket;
 typedef struct USBCombinedPacket USBCombinedPacket;
 typedef struct USBEndpoint USBEndpoint;
@@ -256,9 +256,6 @@ struct USBDevice {
     const USBDescIface  *ifaces[USB_MAX_INTERFACES];
 };
 
-#define TYPE_USB_DEVICE "usb-device"
-#define USB_DEVICE(obj) \
-     OBJECT_CHECK(USBDevice, (obj), TYPE_USB_DEVICE)
 #define USB_DEVICE_CLASS(klass) \
      OBJECT_CLASS_CHECK(USBDeviceClass, (klass), TYPE_USB_DEVICE)
 #define USB_DEVICE_GET_CLASS(obj) \
@@ -459,15 +456,8 @@ void usb_device_reset(USBDevice *dev);
 void usb_wakeup(USBEndpoint *ep, unsigned int stream);
 void usb_generic_async_ctrl_complete(USBDevice *s, USBPacket *p);
 
-/* usb-linux.c */
-void hmp_info_usbhost(Monitor *mon, const QDict *qdict);
-bool usb_host_dev_is_scsi_storage(USBDevice *usbdev);
-
 /* usb-bus.c */
 
-#define TYPE_USB_BUS "usb-bus"
-#define USB_BUS(obj) OBJECT_CHECK(USBBus, (obj), TYPE_USB_BUS)
-
 struct USBBus {
     BusState qbus;
     USBBusOps *ops;
@@ -489,13 +479,8 @@ struct USBBusOps {
 void usb_bus_new(USBBus *bus, size_t bus_size,
                  USBBusOps *ops, DeviceState *host);
 void usb_bus_release(USBBus *bus);
-USBBus *usb_bus_find(int busnr);
 void usb_legacy_register(const char *typename, const char *usbdevice_name,
                          USBDevice *(*usbdevice_init)(const char *params));
-USBDevice *usb_new(const char *name);
-bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp);
-USBDevice *usb_create_simple(USBBus *bus, const char *name);
-USBDevice *usbdevice_create(const char *cmdline);
 void usb_register_port(USBBus *bus, USBPort *port, void *opaque, int index,
                        USBPortOps *ops, int speedmask);
 void usb_register_companion(const char *masterbus, USBPort *ports[],
@@ -506,16 +491,6 @@ void usb_port_location(USBPort *downstream, USBPort *upstream, int portnr);
 void usb_unregister_port(USBBus *bus, USBPort *port);
 void usb_claim_port(USBDevice *dev, Error **errp);
 void usb_release_port(USBDevice *dev);
-/**
- * usb_get_port_path:
- * @dev: the USB device
- *
- * The returned data must be released with g_free()
- * when no longer required.
- *
- * Returns: a dynamically allocated pathname.
- */
-char *usb_get_port_path(USBDevice *dev);
 void usb_device_attach(USBDevice *dev, Error **errp);
 int usb_device_detach(USBDevice *dev);
 void usb_check_attach(USBDevice *dev, Error **errp);
diff --git a/include/hw/usb/usb.h b/include/hw/usb/usb.h
new file mode 100644
index 0000000000..9a13b08503
--- /dev/null
+++ b/include/hw/usb/usb.h
@@ -0,0 +1,58 @@
+/*
+ * QEMU USB API
+ *
+ * Copyright (c) 2005 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#ifndef QEMU_HW_USB_H
+#define QEMU_HW_USB_H
+
+typedef struct USBDevice USBDevice;
+
+#define TYPE_USB_DEVICE "usb-device"
+#define USB_DEVICE(obj) \
+     OBJECT_CHECK(USBDevice, (obj), TYPE_USB_DEVICE)
+
+typedef struct USBBus USBBus;
+
+#define TYPE_USB_BUS "usb-bus"
+#define USB_BUS(obj) OBJECT_CHECK(USBBus, (obj), TYPE_USB_BUS)
+
+USBBus *usb_bus_find(int busnr);
+USBDevice *usb_new(const char *name);
+bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp);
+USBDevice *usb_create_simple(USBBus *bus, const char *name);
+USBDevice *usbdevice_create(const char *cmdline);
+
+/**
+ * usb_get_port_path:
+ * @dev: the USB device
+ *
+ * The returned data must be released with g_free()
+ * when no longer required.
+ *
+ * Returns: a dynamically allocated pathname.
+ */
+char *usb_get_port_path(USBDevice *dev);
+
+void hmp_info_usbhost(Monitor *mon, const QDict *qdict);
+bool usb_host_dev_is_scsi_storage(USBDevice *usbdev);
+
+#endif
diff --git a/chardev/baum.c b/chardev/baum.c
index 9c95e7bc79..fc04bf2e2f 100644
--- a/chardev/baum.c
+++ b/chardev/baum.c
@@ -28,7 +28,7 @@
 #include "qemu/main-loop.h"
 #include "qemu/module.h"
 #include "qemu/timer.h"
-#include "hw/usb.h"
+#include "hw/usb/usb.h"
 #include "ui/console.h"
 #include <brlapi.h>
 #include <brlapi_constants.h>
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 4af9679d03..a890f57ac2 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -83,7 +83,7 @@
 #include "qapi/qapi-visit-common.h"
 #include "qapi/visitor.h"
 #include "hw/core/cpu.h"
-#include "hw/usb.h"
+#include "hw/usb/usb.h"
 #include "hw/i386/intel_iommu.h"
 #include "hw/net/ne2000-isa.h"
 #include "standard-headers/asm-x86/bootparam.h"
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 1d832b2878..4d1de7cfab 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -36,7 +36,7 @@
 #include "hw/firmware/smbios.h"
 #include "hw/pci/pci.h"
 #include "hw/pci/pci_ids.h"
-#include "hw/usb.h"
+#include "hw/usb/usb.h"
 #include "net/net.h"
 #include "hw/ide/pci.h"
 #include "hw/irq.h"
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 047ea8db28..b985f5bea1 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -50,7 +50,7 @@
 #include "hw/firmware/smbios.h"
 #include "hw/ide/pci.h"
 #include "hw/ide/ahci.h"
-#include "hw/usb.h"
+#include "hw/usb/usb.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "sysemu/numa.h"
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index 828c5992ae..7bf69f4a1f 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -69,7 +69,7 @@
 #include "sysemu/kvm.h"
 #include "sysemu/reset.h"
 #include "kvm_ppc.h"
-#include "hw/usb.h"
+#include "hw/usb/usb.h"
 #include "exec/address-spaces.h"
 #include "hw/sysbus.h"
 #include "trace.h"
diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
index fae970b142..781b45e14b 100644
--- a/hw/ppc/sam460ex.c
+++ b/hw/ppc/sam460ex.c
@@ -35,6 +35,7 @@
 #include "hw/char/serial.h"
 #include "hw/i2c/ppc4xx_i2c.h"
 #include "hw/i2c/smbus_eeprom.h"
+#include "hw/usb/usb.h"
 #include "hw/usb/hcd-ehci.h"
 #include "hw/ppc/fdt.h"
 #include "hw/qdev-properties.h"
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 221d3e7a8c..0c0409077f 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -70,7 +70,7 @@
 
 #include "exec/address-spaces.h"
 #include "exec/ram_addr.h"
-#include "hw/usb.h"
+#include "hw/usb/usb.h"
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
 #include "trace.h"
diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
index 443820901d..a39c378855 100644
--- a/hw/sh4/r2d.c
+++ b/hw/sh4/r2d.c
@@ -40,7 +40,7 @@
 #include "hw/ide.h"
 #include "hw/irq.h"
 #include "hw/loader.h"
-#include "hw/usb.h"
+#include "hw/usb/usb.h"
 #include "hw/block/flash.h"
 #include "exec/address-spaces.h"
 
diff --git a/hw/usb/host-stub.c b/hw/usb/host-stub.c
index 538ed29684..11b754892d 100644
--- a/hw/usb/host-stub.c
+++ b/hw/usb/host-stub.c
@@ -32,7 +32,7 @@
 
 #include "qemu/osdep.h"
 #include "ui/console.h"
-#include "hw/usb.h"
+#include "hw/usb/usb.h"
 #include "monitor/monitor.h"
 
 void hmp_info_usbhost(Monitor *mon, const QDict *qdict)
diff --git a/monitor/misc.c b/monitor/misc.c
index 89bb970b00..65c0f887dd 100644
--- a/monitor/misc.c
+++ b/monitor/misc.c
@@ -26,7 +26,7 @@
 #include "monitor-internal.h"
 #include "cpu.h"
 #include "monitor/qdev.h"
-#include "hw/usb.h"
+#include "hw/usb/usb.h"
 #include "hw/pci/pci.h"
 #include "sysemu/watchdog.h"
 #include "hw/loader.h"
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 3e15ee2435..25a13e913e 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -41,7 +41,7 @@
 #include "qemu/error-report.h"
 #include "qemu/sockets.h"
 #include "sysemu/accel.h"
-#include "hw/usb.h"
+#include "hw/usb/usb.h"
 #include "hw/isa/isa.h"
 #include "hw/scsi/scsi.h"
 #include "hw/display/vga.h"
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 21/26] hw/usb: Move internal API to local 'usb-internal.h' header
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
                   ` (19 preceding siblings ...)
  2020-07-04 14:49 ` [PATCH 20/26] hw/usb: Introduce "hw/usb/usb.h" public API Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-04 14:49 ` [PATCH 22/26] hw/usb/usb-hcd: Use OHCI type definitions Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  26 siblings, 0 replies; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

Only the files under hw/usb/ require access to the USB internal
API. Move include/hw/usb.h to hw/usb/usb-internal.h to reduce
its scope.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/usb/desc.h                             | 2 +-
 hw/usb/hcd-dwc2.h                         | 2 +-
 hw/usb/hcd-ehci.h                         | 2 +-
 hw/usb/hcd-ohci.h                         | 2 +-
 hw/usb/hcd-xhci.h                         | 2 +-
 include/hw/usb.h => hw/usb/usb-internal.h | 7 +++----
 hw/usb/bus.c                              | 2 +-
 hw/usb/combined-packet.c                  | 2 +-
 hw/usb/core.c                             | 2 +-
 hw/usb/desc-msos.c                        | 2 +-
 hw/usb/desc.c                             | 3 +--
 hw/usb/dev-audio.c                        | 2 +-
 hw/usb/dev-hid.c                          | 2 +-
 hw/usb/dev-hub.c                          | 2 +-
 hw/usb/dev-mtp.c                          | 2 +-
 hw/usb/dev-network.c                      | 2 +-
 hw/usb/dev-serial.c                       | 2 +-
 hw/usb/dev-smartcard-reader.c             | 2 +-
 hw/usb/dev-storage.c                      | 2 +-
 hw/usb/dev-uas.c                          | 2 +-
 hw/usb/dev-wacom.c                        | 2 +-
 hw/usb/hcd-dwc2.c                         | 1 +
 hw/usb/hcd-musb.c                         | 2 +-
 hw/usb/hcd-ohci-pci.c                     | 2 +-
 hw/usb/hcd-ohci.c                         | 1 -
 hw/usb/hcd-uhci.c                         | 2 +-
 hw/usb/hcd-xhci-nec.c                     | 3 +--
 hw/usb/hcd-xhci.c                         | 2 +-
 hw/usb/host-libusb.c                      | 2 +-
 hw/usb/libhw.c                            | 2 +-
 hw/usb/quirks.c                           | 2 +-
 hw/usb/redirect.c                         | 2 +-
 hw/usb/tusb6010.c                         | 2 +-
 hw/usb/xen-usb.c                          | 2 +-
 MAINTAINERS                               | 1 -
 35 files changed, 35 insertions(+), 39 deletions(-)
 rename include/hw/usb.h => hw/usb/usb-internal.h (99%)

diff --git a/hw/usb/desc.h b/hw/usb/desc.h
index 4bf6966c4b..ee4f042602 100644
--- a/hw/usb/desc.h
+++ b/hw/usb/desc.h
@@ -2,7 +2,7 @@
 #define QEMU_HW_USB_DESC_H
 
 #include <wchar.h>
-#include "hw/usb.h"
+#include "usb-internal.h"
 
 /* binary representation */
 typedef struct USBDescriptor {
diff --git a/hw/usb/hcd-dwc2.h b/hw/usb/hcd-dwc2.h
index 2adf0f53c7..2dfb3f3bc5 100644
--- a/hw/usb/hcd-dwc2.h
+++ b/hw/usb/hcd-dwc2.h
@@ -20,7 +20,7 @@
 #define HW_USB_DWC2_H
 
 #include "hw/sysbus.h"
-#include "hw/usb.h"
+#include "usb-internal.h"
 
 #define DWC2_MMIO_SIZE      0x11000
 
diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h
index 4577f5e31d..337b3ad05c 100644
--- a/hw/usb/hcd-ehci.h
+++ b/hw/usb/hcd-ehci.h
@@ -19,10 +19,10 @@
 #define HW_USB_HCD_EHCI_H
 
 #include "qemu/timer.h"
-#include "hw/usb.h"
 #include "sysemu/dma.h"
 #include "hw/pci/pci.h"
 #include "hw/sysbus.h"
+#include "usb-internal.h"
 
 #define CAPA_SIZE        0x10
 
diff --git a/hw/usb/hcd-ohci.h b/hw/usb/hcd-ohci.h
index 5c8819aedf..771927ea17 100644
--- a/hw/usb/hcd-ohci.h
+++ b/hw/usb/hcd-ohci.h
@@ -22,7 +22,7 @@
 #define HCD_OHCI_H
 
 #include "sysemu/dma.h"
-#include "hw/usb.h"
+#include "usb-internal.h"
 
 /* Number of Downstream Ports on the root hub: */
 #define OHCI_MAX_PORTS 15
diff --git a/hw/usb/hcd-xhci.h b/hw/usb/hcd-xhci.h
index 8edbdc2c3e..f9a3aaceec 100644
--- a/hw/usb/hcd-xhci.h
+++ b/hw/usb/hcd-xhci.h
@@ -22,7 +22,7 @@
 #ifndef HW_USB_HCD_XHCI_H
 #define HW_USB_HCD_XHCI_H
 
-#include "hw/usb.h"
+#include "usb-internal.h"
 
 #define TYPE_XHCI "base-xhci"
 #define TYPE_NEC_XHCI "nec-usb-xhci"
diff --git a/include/hw/usb.h b/hw/usb/usb-internal.h
similarity index 99%
rename from include/hw/usb.h
rename to hw/usb/usb-internal.h
index 2ea5186ea5..ceafb65936 100644
--- a/include/hw/usb.h
+++ b/hw/usb/usb-internal.h
@@ -1,8 +1,5 @@
-#ifndef QEMU_USB_H
-#define QEMU_USB_H
-
 /*
- * QEMU USB API
+ * QEMU USB internal API
  *
  * Copyright (c) 2005 Fabrice Bellard
  *
@@ -24,6 +21,8 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef QEMU_USB_INTERNAL_H
+#define QEMU_USB_INTERNAL_H
 
 #include "hw/qdev-core.h"
 #include "hw/usb/usb.h"
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 518e5b94ed..ba6c48e800 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -1,6 +1,5 @@
 #include "qemu/osdep.h"
 #include "hw/qdev-properties.h"
-#include "hw/usb.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "qemu/module.h"
@@ -9,6 +8,7 @@
 #include "monitor/monitor.h"
 #include "trace.h"
 #include "qemu/cutils.h"
+#include "usb-internal.h"
 #include "desc.h"
 
 static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent);
diff --git a/hw/usb/combined-packet.c b/hw/usb/combined-packet.c
index 5d57e883dc..28e19aad12 100644
--- a/hw/usb/combined-packet.c
+++ b/hw/usb/combined-packet.c
@@ -21,9 +21,9 @@
  */
 #include "qemu/osdep.h"
 #include "qemu/units.h"
-#include "hw/usb.h"
 #include "qemu/iov.h"
 #include "trace.h"
+#include "usb-internal.h"
 
 static void usb_combined_packet_add(USBCombinedPacket *combined, USBPacket *p)
 {
diff --git a/hw/usb/core.c b/hw/usb/core.c
index 5abd128b6b..6fed698d20 100644
--- a/hw/usb/core.c
+++ b/hw/usb/core.c
@@ -24,9 +24,9 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
-#include "hw/usb.h"
 #include "qemu/iov.h"
 #include "trace.h"
+#include "usb-internal.h"
 
 void usb_pick_speed(USBPort *port)
 {
diff --git a/hw/usb/desc-msos.c b/hw/usb/desc-msos.c
index 3a5ad7c8d0..79a8093f3f 100644
--- a/hw/usb/desc-msos.c
+++ b/hw/usb/desc-msos.c
@@ -1,6 +1,6 @@
 #include "qemu/osdep.h"
-#include "hw/usb.h"
 #include "desc.h"
+#include "usb-internal.h"
 
 /*
  * Microsoft OS Descriptors
diff --git a/hw/usb/desc.c b/hw/usb/desc.c
index 8b6eaea407..defb344014 100644
--- a/hw/usb/desc.c
+++ b/hw/usb/desc.c
@@ -1,8 +1,7 @@
 #include "qemu/osdep.h"
-
-#include "hw/usb.h"
 #include "desc.h"
 #include "trace.h"
+#include "usb-internal.h"
 
 /* ------------------------------------------------------------------ */
 
diff --git a/hw/usb/dev-audio.c b/hw/usb/dev-audio.c
index 1371c44f48..1e4d1051f3 100644
--- a/hw/usb/dev-audio.c
+++ b/hw/usb/dev-audio.c
@@ -32,10 +32,10 @@
 #include "qemu/osdep.h"
 #include "qemu/module.h"
 #include "hw/qdev-properties.h"
-#include "hw/usb.h"
 #include "migration/vmstate.h"
 #include "desc.h"
 #include "audio/audio.h"
+#include "usb-internal.h"
 
 static void usb_audio_reinit(USBDevice *dev, unsigned channels);
 
diff --git a/hw/usb/dev-hid.c b/hw/usb/dev-hid.c
index 89f63b698b..59b47272ba 100644
--- a/hw/usb/dev-hid.c
+++ b/hw/usb/dev-hid.c
@@ -25,7 +25,6 @@
 
 #include "qemu/osdep.h"
 #include "ui/console.h"
-#include "hw/usb.h"
 #include "migration/vmstate.h"
 #include "desc.h"
 #include "qapi/error.h"
@@ -33,6 +32,7 @@
 #include "qemu/timer.h"
 #include "hw/input/hid.h"
 #include "hw/qdev-properties.h"
+#include "usb-internal.h"
 
 /* HID interface requests */
 #define GET_REPORT   0xa101
diff --git a/hw/usb/dev-hub.c b/hw/usb/dev-hub.c
index 5f19dd9fb5..b394ae9983 100644
--- a/hw/usb/dev-hub.c
+++ b/hw/usb/dev-hub.c
@@ -27,11 +27,11 @@
 #include "qemu/timer.h"
 #include "trace.h"
 #include "hw/qdev-properties.h"
-#include "hw/usb.h"
 #include "migration/vmstate.h"
 #include "desc.h"
 #include "qemu/error-report.h"
 #include "qemu/module.h"
+#include "usb-internal.h"
 
 #define MAX_PORTS 8
 
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 15a2243101..147e564bea 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -24,10 +24,10 @@
 #include "qemu/filemonitor.h"
 #include "trace.h"
 #include "hw/qdev-properties.h"
-#include "hw/usb.h"
 #include "migration/vmstate.h"
 #include "desc.h"
 #include "qemu/units.h"
+#include "usb-internal.h"
 
 /* ----------------------------------------------------------------------- */
 
diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c
index c69756709b..2e06d74f69 100644
--- a/hw/usb/dev-network.c
+++ b/hw/usb/dev-network.c
@@ -26,7 +26,6 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "hw/qdev-properties.h"
-#include "hw/usb.h"
 #include "migration/vmstate.h"
 #include "desc.h"
 #include "net/net.h"
@@ -37,6 +36,7 @@
 #include "qemu/iov.h"
 #include "qemu/module.h"
 #include "qemu/cutils.h"
+#include "usb-internal.h"
 
 /*#define TRAFFIC_DEBUG*/
 /* Thanks to NetChip Technologies for donating this product ID.
diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c
index 7e50e3ba47..4d3f91a85a 100644
--- a/hw/usb/dev-serial.c
+++ b/hw/usb/dev-serial.c
@@ -14,11 +14,11 @@
 #include "qemu/error-report.h"
 #include "qemu/module.h"
 #include "hw/qdev-properties.h"
-#include "hw/usb.h"
 #include "migration/vmstate.h"
 #include "desc.h"
 #include "chardev/char-serial.h"
 #include "chardev/char-fe.h"
+#include "usb-internal.h"
 
 //#define DEBUG_Serial
 
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index fcfe216594..9602b25a10 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -41,9 +41,9 @@
 #include "qemu/error-report.h"
 #include "qemu/module.h"
 #include "hw/qdev-properties.h"
-#include "hw/usb.h"
 #include "migration/vmstate.h"
 #include "desc.h"
+#include "usb-internal.h"
 
 #include "ccid.h"
 
diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index f5977eb72e..a58c84dffa 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -13,7 +13,6 @@
 #include "qemu/module.h"
 #include "qemu/option.h"
 #include "qemu/config-file.h"
-#include "hw/usb.h"
 #include "desc.h"
 #include "hw/qdev-properties.h"
 #include "hw/scsi/scsi.h"
@@ -22,6 +21,7 @@
 #include "sysemu/block-backend.h"
 #include "qapi/visitor.h"
 #include "qemu/cutils.h"
+#include "usb-internal.h"
 
 //#define DEBUG_MSD
 
diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c
index a3a4d41c07..9dc39f98a2 100644
--- a/hw/usb/dev-uas.c
+++ b/hw/usb/dev-uas.c
@@ -17,12 +17,12 @@
 #include "qemu/main-loop.h"
 #include "qemu/module.h"
 
-#include "hw/usb.h"
 #include "migration/vmstate.h"
 #include "desc.h"
 #include "hw/qdev-properties.h"
 #include "hw/scsi/scsi.h"
 #include "scsi/constants.h"
+#include "usb-internal.h"
 
 /* --------------------------------------------------------------------- */
 
diff --git a/hw/usb/dev-wacom.c b/hw/usb/dev-wacom.c
index 8aba44b8bc..7c162b7f85 100644
--- a/hw/usb/dev-wacom.c
+++ b/hw/usb/dev-wacom.c
@@ -28,10 +28,10 @@
 
 #include "qemu/osdep.h"
 #include "ui/console.h"
-#include "hw/usb.h"
 #include "migration/vmstate.h"
 #include "qemu/module.h"
 #include "desc.h"
+#include "usb-internal.h"
 
 /* Interface requests */
 #define WACOM_GET_REPORT	0x2101
diff --git a/hw/usb/hcd-dwc2.c b/hw/usb/hcd-dwc2.c
index 252b60ef65..47ae18d510 100644
--- a/hw/usb/hcd-dwc2.c
+++ b/hw/usb/hcd-dwc2.c
@@ -43,6 +43,7 @@
 #include "qemu/log.h"
 #include "hw/qdev-properties.h"
 #include "dwc2-regs.h"
+#include "usb-internal.h"
 
 #define USB_HZ_FS       12000000
 #define USB_HZ_HS       96000000
diff --git a/hw/usb/hcd-musb.c b/hw/usb/hcd-musb.c
index b8d8766a4a..bc3efcce65 100644
--- a/hw/usb/hcd-musb.c
+++ b/hw/usb/hcd-musb.c
@@ -22,10 +22,10 @@
  */
 #include "qemu/osdep.h"
 #include "qemu/timer.h"
-#include "hw/usb.h"
 #include "hw/irq.h"
 #include "hw/hw.h"
 #include "hcd-musb.h"
+#include "usb-internal.h"
 
 /* Common USB registers */
 #define MUSB_HDRC_FADDR		0x00	/* 8-bit */
diff --git a/hw/usb/hcd-ohci-pci.c b/hw/usb/hcd-ohci-pci.c
index a7fb1666af..cb6bc55f59 100644
--- a/hw/usb/hcd-ohci-pci.c
+++ b/hw/usb/hcd-ohci-pci.c
@@ -21,7 +21,6 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qemu/timer.h"
-#include "hw/usb.h"
 #include "migration/vmstate.h"
 #include "hw/pci/pci.h"
 #include "hw/sysbus.h"
@@ -29,6 +28,7 @@
 #include "hw/qdev-properties.h"
 #include "trace.h"
 #include "hcd-ohci.h"
+#include "usb-internal.h"
 
 #define TYPE_PCI_OHCI "pci-ohci"
 #define PCI_OHCI(obj) OBJECT_CHECK(OHCIPCIState, (obj), TYPE_PCI_OHCI)
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index 1e6e85e86a..f4a85a8774 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -30,7 +30,6 @@
 #include "qapi/error.h"
 #include "qemu/module.h"
 #include "qemu/timer.h"
-#include "hw/usb.h"
 #include "migration/vmstate.h"
 #include "hw/sysbus.h"
 #include "hw/qdev-dma.h"
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index 37f7beb3fa..1d4dd33b6c 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -27,7 +27,6 @@
  */
 
 #include "qemu/osdep.h"
-#include "hw/usb.h"
 #include "hw/usb/uhci-regs.h"
 #include "migration/vmstate.h"
 #include "hw/pci/pci.h"
@@ -39,6 +38,7 @@
 #include "trace.h"
 #include "qemu/main-loop.h"
 #include "qemu/module.h"
+#include "usb-internal.h"
 
 #define FRAME_TIMER_FREQ 1000
 
diff --git a/hw/usb/hcd-xhci-nec.c b/hw/usb/hcd-xhci-nec.c
index e6a5a22b6d..24c59fa4b0 100644
--- a/hw/usb/hcd-xhci-nec.c
+++ b/hw/usb/hcd-xhci-nec.c
@@ -20,11 +20,10 @@
  */
 
 #include "qemu/osdep.h"
-#include "hw/usb.h"
 #include "qemu/module.h"
 #include "hw/pci/pci.h"
 #include "hw/qdev-properties.h"
-
+#include "usb-internal.h"
 #include "hcd-xhci.h"
 
 static Property nec_xhci_properties[] = {
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index b330e36fe6..a3f6b14681 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"
@@ -33,6 +32,7 @@
 #include "qapi/error.h"
 
 #include "hcd-xhci.h"
+#include "usb-internal.h"
 
 //#define DEBUG_XHCI
 //#define DEBUG_DATA
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index ad7ed8fb0c..615655f2f5 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -50,7 +50,7 @@
 #include "trace.h"
 
 #include "hw/qdev-properties.h"
-#include "hw/usb.h"
+#include "usb-internal.h"
 
 /* ------------------------------------------------------------------------ */
 
diff --git a/hw/usb/libhw.c b/hw/usb/libhw.c
index 9c33a1640f..a8d7f994df 100644
--- a/hw/usb/libhw.c
+++ b/hw/usb/libhw.c
@@ -20,8 +20,8 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
-#include "hw/usb.h"
 #include "sysemu/dma.h"
+#include "usb-internal.h"
 
 int usb_packet_map(USBPacket *p, QEMUSGList *sgl)
 {
diff --git a/hw/usb/quirks.c b/hw/usb/quirks.c
index b0d0f87e35..c427d45f1e 100644
--- a/hw/usb/quirks.c
+++ b/hw/usb/quirks.c
@@ -14,7 +14,7 @@
 
 #include "qemu/osdep.h"
 #include "quirks.inc.c"
-#include "hw/usb.h"
+#include "usb-internal.h"
 #include "usb-quirks.h"
 
 static bool usb_id_match(const struct usb_device_id *ids,
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 4c5925a039..a0c55de7f8 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -42,9 +42,9 @@
 #include <usbredirfilter.h>
 
 #include "hw/qdev-properties.h"
-#include "hw/usb.h"
 #include "migration/qemu-file-types.h"
 #include "migration/vmstate.h"
+#include "usb-internal.h"
 #include "usb-quirks.h"
 
 /* ERROR is defined below. Remove any previous definition. */
diff --git a/hw/usb/tusb6010.c b/hw/usb/tusb6010.c
index 9f9b81b09d..191df38356 100644
--- a/hw/usb/tusb6010.c
+++ b/hw/usb/tusb6010.c
@@ -22,12 +22,12 @@
 #include "qemu/osdep.h"
 #include "qemu/module.h"
 #include "qemu/timer.h"
-#include "hw/usb.h"
 #include "hw/arm/omap.h"
 #include "hw/hw.h"
 #include "hw/irq.h"
 #include "hw/sysbus.h"
 #include "hcd-musb.h"
+#include "usb-internal.h"
 
 #define TYPE_TUSB6010 "tusb6010"
 #define TUSB(obj) OBJECT_CHECK(TUSBState, (obj), TYPE_TUSB6010)
diff --git a/hw/usb/xen-usb.c b/hw/usb/xen-usb.c
index 4d266d7bb4..a6a0b466f9 100644
--- a/hw/usb/xen-usb.c
+++ b/hw/usb/xen-usb.c
@@ -27,12 +27,12 @@
 #include "qemu/main-loop.h"
 #include "qemu/option.h"
 #include "hw/sysbus.h"
-#include "hw/usb.h"
 #include "hw/xen/xen-legacy-backend.h"
 #include "monitor/qdev.h"
 #include "qapi/error.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qstring.h"
+#include "usb-internal.h"
 
 #include "hw/xen/interface/io/usbif.h"
 
diff --git a/MAINTAINERS b/MAINTAINERS
index dec252f38b..2566566d72 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1642,7 +1642,6 @@ F: hw/usb/*
 F: tests/qtest/usb-*-test.c
 F: docs/usb2.txt
 F: docs/usb-storage.txt
-F: include/hw/usb.h
 F: include/hw/usb/
 F: default-configs/usb.mak
 
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 22/26] hw/usb/usb-hcd: Use OHCI type definitions
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
                   ` (20 preceding siblings ...)
  2020-07-04 14:49 ` [PATCH 21/26] hw/usb: Move internal API to local 'usb-internal.h' header Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-04 17:13   ` BALATON Zoltan
  2020-07-05 19:55   ` Niek Linnenbank
  2020-07-04 14:49 ` [PATCH 23/26] hw/usb/usb-hcd: Use EHCI " Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  26 siblings, 2 replies; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

Various machine/board/soc models create OHCI device instances
with the generic QDEV API, and don't need to access USB internals.

Simplify header inclusions by moving the QOM type names into a
simple header, with no need to include other "hw/usb" headers.

Suggested-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/usb/hcd-ohci.h        |  2 +-
 include/hw/usb/usb-hcd.h | 16 ++++++++++++++++
 hw/arm/allwinner-a10.c   |  2 +-
 hw/arm/allwinner-h3.c    |  9 +++++----
 hw/arm/pxa2xx.c          |  3 ++-
 hw/arm/realview.c        |  3 ++-
 hw/arm/versatilepb.c     |  3 ++-
 hw/display/sm501.c       |  3 ++-
 hw/ppc/mac_newworld.c    |  3 ++-
 hw/ppc/mac_oldworld.c    |  3 ++-
 hw/ppc/sam460ex.c        |  3 ++-
 hw/ppc/spapr.c           |  3 ++-
 hw/usb/hcd-ohci-pci.c    |  2 +-
 13 files changed, 40 insertions(+), 15 deletions(-)
 create mode 100644 include/hw/usb/usb-hcd.h

diff --git a/hw/usb/hcd-ohci.h b/hw/usb/hcd-ohci.h
index 771927ea17..6949cf0dab 100644
--- a/hw/usb/hcd-ohci.h
+++ b/hw/usb/hcd-ohci.h
@@ -21,6 +21,7 @@
 #ifndef HCD_OHCI_H
 #define HCD_OHCI_H
 
+#include "hw/usb/usb-hcd.h"
 #include "sysemu/dma.h"
 #include "usb-internal.h"
 
@@ -91,7 +92,6 @@ typedef struct OHCIState {
     void (*ohci_die)(struct OHCIState *ohci);
 } OHCIState;
 
-#define TYPE_SYSBUS_OHCI "sysbus-ohci"
 #define SYSBUS_OHCI(obj) OBJECT_CHECK(OHCISysBusState, (obj), TYPE_SYSBUS_OHCI)
 
 typedef struct {
diff --git a/include/hw/usb/usb-hcd.h b/include/hw/usb/usb-hcd.h
new file mode 100644
index 0000000000..21fdfaf22d
--- /dev/null
+++ b/include/hw/usb/usb-hcd.h
@@ -0,0 +1,16 @@
+/*
+ * QEMU USB HCD types
+ *
+ * Copyright (c) 2020  Philippe Mathieu-Daudé <f4bug@amsat.org>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef HW_USB_HCD_TYPES_H
+#define HW_USB_HCD_TYPES_H
+
+/* OHCI */
+#define TYPE_SYSBUS_OHCI            "sysbus-ohci"
+#define TYPE_PCI_OHCI               "pci-ohci"
+
+#endif
diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
index 52e0d83760..53c24ff602 100644
--- a/hw/arm/allwinner-a10.c
+++ b/hw/arm/allwinner-a10.c
@@ -25,7 +25,7 @@
 #include "hw/misc/unimp.h"
 #include "sysemu/sysemu.h"
 #include "hw/boards.h"
-#include "hw/usb/hcd-ohci.h"
+#include "hw/usb/usb-hcd.h"
 
 #define AW_A10_MMC0_BASE        0x01c0f000
 #define AW_A10_PIC_REG_BASE     0x01c20400
diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
index 8e09468e86..d1d90ffa79 100644
--- a/hw/arm/allwinner-h3.c
+++ b/hw/arm/allwinner-h3.c
@@ -28,6 +28,7 @@
 #include "hw/sysbus.h"
 #include "hw/char/serial.h"
 #include "hw/misc/unimp.h"
+#include "hw/usb/usb-hcd.h"
 #include "hw/usb/hcd-ehci.h"
 #include "hw/loader.h"
 #include "sysemu/sysemu.h"
@@ -381,16 +382,16 @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)
                          qdev_get_gpio_in(DEVICE(&s->gic),
                                           AW_H3_GIC_SPI_EHCI3));
 
-    sysbus_create_simple("sysbus-ohci", s->memmap[AW_H3_OHCI0],
+    sysbus_create_simple(TYPE_SYSBUS_OHCI, s->memmap[AW_H3_OHCI0],
                          qdev_get_gpio_in(DEVICE(&s->gic),
                                           AW_H3_GIC_SPI_OHCI0));
-    sysbus_create_simple("sysbus-ohci", s->memmap[AW_H3_OHCI1],
+    sysbus_create_simple(TYPE_SYSBUS_OHCI, s->memmap[AW_H3_OHCI1],
                          qdev_get_gpio_in(DEVICE(&s->gic),
                                           AW_H3_GIC_SPI_OHCI1));
-    sysbus_create_simple("sysbus-ohci", s->memmap[AW_H3_OHCI2],
+    sysbus_create_simple(TYPE_SYSBUS_OHCI, s->memmap[AW_H3_OHCI2],
                          qdev_get_gpio_in(DEVICE(&s->gic),
                                           AW_H3_GIC_SPI_OHCI2));
-    sysbus_create_simple("sysbus-ohci", s->memmap[AW_H3_OHCI3],
+    sysbus_create_simple(TYPE_SYSBUS_OHCI, s->memmap[AW_H3_OHCI3],
                          qdev_get_gpio_in(DEVICE(&s->gic),
                                           AW_H3_GIC_SPI_OHCI3));
 
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
index f104a33463..27196170f5 100644
--- a/hw/arm/pxa2xx.c
+++ b/hw/arm/pxa2xx.c
@@ -18,6 +18,7 @@
 #include "hw/arm/pxa.h"
 #include "sysemu/sysemu.h"
 #include "hw/char/serial.h"
+#include "hw/usb/usb-hcd.h"
 #include "hw/i2c/i2c.h"
 #include "hw/irq.h"
 #include "hw/qdev-properties.h"
@@ -2196,7 +2197,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,
         s->ssp[i] = (SSIBus *)qdev_get_child_bus(dev, "ssi");
     }
 
-    sysbus_create_simple("sysbus-ohci", 0x4c000000,
+    sysbus_create_simple(TYPE_SYSBUS_OHCI, 0x4c000000,
                          qdev_get_gpio_in(s->pic, PXA2XX_PIC_USBH1));
 
     s->pcmcia[0] = pxa2xx_pcmcia_init(address_space, 0x20000000);
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
index b6c0a1adb9..0aa34bd4c2 100644
--- a/hw/arm/realview.c
+++ b/hw/arm/realview.c
@@ -16,6 +16,7 @@
 #include "hw/net/lan9118.h"
 #include "hw/net/smc91c111.h"
 #include "hw/pci/pci.h"
+#include "hw/usb/usb-hcd.h"
 #include "net/net.h"
 #include "sysemu/sysemu.h"
 #include "hw/boards.h"
@@ -256,7 +257,7 @@ static void realview_init(MachineState *machine,
         sysbus_connect_irq(busdev, 3, pic[51]);
         pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci");
         if (machine_usb(machine)) {
-            pci_create_simple(pci_bus, -1, "pci-ohci");
+            pci_create_simple(pci_bus, -1, TYPE_PCI_OHCI);
         }
         n = drive_get_max_bus(IF_SCSI);
         while (n >= 0) {
diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
index e596b8170f..3e6224dc96 100644
--- a/hw/arm/versatilepb.c
+++ b/hw/arm/versatilepb.c
@@ -17,6 +17,7 @@
 #include "net/net.h"
 #include "sysemu/sysemu.h"
 #include "hw/pci/pci.h"
+#include "hw/usb/usb-hcd.h"
 #include "hw/i2c/i2c.h"
 #include "hw/i2c/arm_sbcon_i2c.h"
 #include "hw/irq.h"
@@ -273,7 +274,7 @@ static void versatile_init(MachineState *machine, int board_id)
         }
     }
     if (machine_usb(machine)) {
-        pci_create_simple(pci_bus, -1, "pci-ohci");
+        pci_create_simple(pci_bus, -1, TYPE_PCI_OHCI);
     }
     n = drive_get_max_bus(IF_SCSI);
     while (n >= 0) {
diff --git a/hw/display/sm501.c b/hw/display/sm501.c
index 9cccc68c35..5f076c841f 100644
--- a/hw/display/sm501.c
+++ b/hw/display/sm501.c
@@ -33,6 +33,7 @@
 #include "hw/sysbus.h"
 #include "migration/vmstate.h"
 #include "hw/pci/pci.h"
+#include "hw/usb/usb-hcd.h"
 #include "hw/qdev-properties.h"
 #include "hw/i2c/i2c.h"
 #include "hw/display/i2c-ddc.h"
@@ -1961,7 +1962,7 @@ static void sm501_realize_sysbus(DeviceState *dev, Error **errp)
     sysbus_init_mmio(sbd, &s->state.mmio_region);
 
     /* bridge to usb host emulation module */
-    usb_dev = qdev_new("sysbus-ohci");
+    usb_dev = qdev_new(TYPE_SYSBUS_OHCI);
     qdev_prop_set_uint32(usb_dev, "num-ports", 2);
     qdev_prop_set_uint64(usb_dev, "dma-offset", s->base);
     sysbus_realize_and_unref(SYS_BUS_DEVICE(usb_dev), &error_fatal);
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index 7bf69f4a1f..3c32c1831b 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -55,6 +55,7 @@
 #include "hw/input/adb.h"
 #include "hw/ppc/mac_dbdma.h"
 #include "hw/pci/pci.h"
+#include "hw/usb/usb-hcd.h"
 #include "net/net.h"
 #include "sysemu/sysemu.h"
 #include "hw/boards.h"
@@ -411,7 +412,7 @@ static void ppc_core99_init(MachineState *machine)
     }
 
     if (machine->usb) {
-        pci_create_simple(pci_bus, -1, "pci-ohci");
+        pci_create_simple(pci_bus, -1, TYPE_PCI_OHCI);
 
         /* U3 needs to use USB for input because Linux doesn't support via-cuda
         on PPC64 */
diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
index f8c204ead7..a429a3e1df 100644
--- a/hw/ppc/mac_oldworld.c
+++ b/hw/ppc/mac_oldworld.c
@@ -37,6 +37,7 @@
 #include "hw/isa/isa.h"
 #include "hw/pci/pci.h"
 #include "hw/pci/pci_host.h"
+#include "hw/usb/usb-hcd.h"
 #include "hw/boards.h"
 #include "hw/nvram/fw_cfg.h"
 #include "hw/char/escc.h"
@@ -301,7 +302,7 @@ static void ppc_heathrow_init(MachineState *machine)
     qdev_realize_and_unref(dev, adb_bus, &error_fatal);
 
     if (machine_usb(machine)) {
-        pci_create_simple(pci_bus, -1, "pci-ohci");
+        pci_create_simple(pci_bus, -1, TYPE_PCI_OHCI);
     }
 
     if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
index 781b45e14b..ac60d17a86 100644
--- a/hw/ppc/sam460ex.c
+++ b/hw/ppc/sam460ex.c
@@ -36,6 +36,7 @@
 #include "hw/i2c/ppc4xx_i2c.h"
 #include "hw/i2c/smbus_eeprom.h"
 #include "hw/usb/usb.h"
+#include "hw/usb/usb-hcd.h"
 #include "hw/usb/hcd-ehci.h"
 #include "hw/ppc/fdt.h"
 #include "hw/qdev-properties.h"
@@ -372,7 +373,7 @@ static void sam460ex_init(MachineState *machine)
 
     /* USB */
     sysbus_create_simple(TYPE_PPC4xx_EHCI, 0x4bffd0400, uic[2][29]);
-    dev = qdev_new("sysbus-ohci");
+    dev = qdev_new(TYPE_SYSBUS_OHCI);
     qdev_prop_set_string(dev, "masterbus", "usb-bus.0");
     qdev_prop_set_uint32(dev, "num-ports", 6);
     sbdev = SYS_BUS_DEVICE(dev);
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 0c0409077f..db1706a66c 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -71,6 +71,7 @@
 #include "exec/address-spaces.h"
 #include "exec/ram_addr.h"
 #include "hw/usb/usb.h"
+#include "hw/usb/usb-hcd.h"
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
 #include "trace.h"
@@ -2958,7 +2959,7 @@ static void spapr_machine_init(MachineState *machine)
 
     if (machine->usb) {
         if (smc->use_ohci_by_default) {
-            pci_create_simple(phb->bus, -1, "pci-ohci");
+            pci_create_simple(phb->bus, -1, TYPE_PCI_OHCI);
         } else {
             pci_create_simple(phb->bus, -1, "nec-usb-xhci");
         }
diff --git a/hw/usb/hcd-ohci-pci.c b/hw/usb/hcd-ohci-pci.c
index cb6bc55f59..14df83ec2e 100644
--- a/hw/usb/hcd-ohci-pci.c
+++ b/hw/usb/hcd-ohci-pci.c
@@ -29,8 +29,8 @@
 #include "trace.h"
 #include "hcd-ohci.h"
 #include "usb-internal.h"
+#include "hw/usb/usb-hcd.h"
 
-#define TYPE_PCI_OHCI "pci-ohci"
 #define PCI_OHCI(obj) OBJECT_CHECK(OHCIPCIState, (obj), TYPE_PCI_OHCI)
 
 typedef struct {
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 23/26] hw/usb/usb-hcd: Use EHCI type definitions
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
                   ` (21 preceding siblings ...)
  2020-07-04 14:49 ` [PATCH 22/26] hw/usb/usb-hcd: Use OHCI type definitions Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-04 17:15   ` BALATON Zoltan
  2020-07-04 14:49 ` [PATCH 24/26] hw/usb/usb-hcd: Use UHCI " Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  26 siblings, 1 reply; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

Various machine/board/soc models create EHCI device instances
with the generic QDEV API, and don't need to access USB internals.

Simplify header inclusions by moving the QOM type names into a
simple header, with no need to include other "hw/usb" headers.

Suggested-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/usb/hcd-ehci.h         | 11 +----------
 include/hw/usb/chipidea.h |  2 +-
 include/hw/usb/usb-hcd.h  | 11 +++++++++++
 hw/arm/allwinner-h3.c     |  1 -
 hw/arm/exynos4210.c       |  2 +-
 hw/arm/sbsa-ref.c         |  3 ++-
 hw/arm/xilinx_zynq.c      |  2 +-
 hw/ppc/sam460ex.c         |  1 -
 hw/usb/chipidea.c         |  1 +
 hw/usb/hcd-ehci-sysbus.c  |  1 +
 10 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h
index 337b3ad05c..da70767409 100644
--- a/hw/usb/hcd-ehci.h
+++ b/hw/usb/hcd-ehci.h
@@ -23,6 +23,7 @@
 #include "hw/pci/pci.h"
 #include "hw/sysbus.h"
 #include "usb-internal.h"
+#include "hw/usb/usb-hcd.h"
 
 #define CAPA_SIZE        0x10
 
@@ -316,7 +317,6 @@ void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp);
 void usb_ehci_unrealize(EHCIState *s, DeviceState *dev);
 void ehci_reset(void *opaque);
 
-#define TYPE_PCI_EHCI "pci-ehci-usb"
 #define PCI_EHCI(obj) OBJECT_CHECK(EHCIPCIState, (obj), TYPE_PCI_EHCI)
 
 typedef struct EHCIPCIState {
@@ -327,15 +327,6 @@ typedef struct EHCIPCIState {
     EHCIState ehci;
 } EHCIPCIState;
 
-
-#define TYPE_SYS_BUS_EHCI "sysbus-ehci-usb"
-#define TYPE_PLATFORM_EHCI "platform-ehci-usb"
-#define TYPE_EXYNOS4210_EHCI "exynos4210-ehci-usb"
-#define TYPE_AW_H3_EHCI "aw-h3-ehci-usb"
-#define TYPE_TEGRA2_EHCI "tegra2-ehci-usb"
-#define TYPE_PPC4xx_EHCI "ppc4xx-ehci-usb"
-#define TYPE_FUSBH200_EHCI "fusbh200-ehci-usb"
-
 #define SYS_BUS_EHCI(obj) \
     OBJECT_CHECK(EHCISysBusState, (obj), TYPE_SYS_BUS_EHCI)
 #define SYS_BUS_EHCI_CLASS(class) \
diff --git a/include/hw/usb/chipidea.h b/include/hw/usb/chipidea.h
index 1ec2e9dbda..28f46291de 100644
--- a/include/hw/usb/chipidea.h
+++ b/include/hw/usb/chipidea.h
@@ -2,6 +2,7 @@
 #define CHIPIDEA_H
 
 #include "hw/usb/hcd-ehci.h"
+#include "hw/usb/usb-hcd.h"
 
 typedef struct ChipideaState {
     /*< private >*/
@@ -10,7 +11,6 @@ typedef struct ChipideaState {
     MemoryRegion iomem[3];
 } ChipideaState;
 
-#define TYPE_CHIPIDEA "usb-chipidea"
 #define CHIPIDEA(obj) OBJECT_CHECK(ChipideaState, (obj), TYPE_CHIPIDEA)
 
 #endif /* CHIPIDEA_H */
diff --git a/include/hw/usb/usb-hcd.h b/include/hw/usb/usb-hcd.h
index 21fdfaf22d..74af3a4533 100644
--- a/include/hw/usb/usb-hcd.h
+++ b/include/hw/usb/usb-hcd.h
@@ -13,4 +13,15 @@
 #define TYPE_SYSBUS_OHCI            "sysbus-ohci"
 #define TYPE_PCI_OHCI               "pci-ohci"
 
+/* EHCI */
+#define TYPE_SYS_BUS_EHCI           "sysbus-ehci-usb"
+#define TYPE_PCI_EHCI               "pci-ehci-usb"
+#define TYPE_PLATFORM_EHCI          "platform-ehci-usb"
+#define TYPE_EXYNOS4210_EHCI        "exynos4210-ehci-usb"
+#define TYPE_AW_H3_EHCI             "aw-h3-ehci-usb"
+#define TYPE_TEGRA2_EHCI            "tegra2-ehci-usb"
+#define TYPE_PPC4xx_EHCI            "ppc4xx-ehci-usb"
+#define TYPE_FUSBH200_EHCI          "fusbh200-ehci-usb"
+#define TYPE_CHIPIDEA               "usb-chipidea"
+
 #endif
diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
index d1d90ffa79..8b7adddc27 100644
--- a/hw/arm/allwinner-h3.c
+++ b/hw/arm/allwinner-h3.c
@@ -29,7 +29,6 @@
 #include "hw/char/serial.h"
 #include "hw/misc/unimp.h"
 #include "hw/usb/usb-hcd.h"
-#include "hw/usb/hcd-ehci.h"
 #include "hw/loader.h"
 #include "sysemu/sysemu.h"
 #include "hw/arm/allwinner-h3.h"
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
index fa639806ec..692fb02159 100644
--- a/hw/arm/exynos4210.c
+++ b/hw/arm/exynos4210.c
@@ -35,7 +35,7 @@
 #include "hw/qdev-properties.h"
 #include "hw/arm/exynos4210.h"
 #include "hw/sd/sdhci.h"
-#include "hw/usb/hcd-ehci.h"
+#include "hw/usb/usb-hcd.h"
 
 #define EXYNOS4210_CHIPID_ADDR         0x10000000
 
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
index 021e7c1b8b..4e4c338ae9 100644
--- a/hw/arm/sbsa-ref.c
+++ b/hw/arm/sbsa-ref.c
@@ -38,6 +38,7 @@
 #include "hw/loader.h"
 #include "hw/pci-host/gpex.h"
 #include "hw/qdev-properties.h"
+#include "hw/usb/usb-hcd.h"
 #include "hw/char/pl011.h"
 #include "net/net.h"
 
@@ -485,7 +486,7 @@ static void create_ehci(const SBSAMachineState *sms)
     hwaddr base = sbsa_ref_memmap[SBSA_EHCI].base;
     int irq = sbsa_ref_irqmap[SBSA_EHCI];
 
-    sysbus_create_simple("platform-ehci-usb", base,
+    sysbus_create_simple(TYPE_PLATFORM_EHCI, base,
                          qdev_get_gpio_in(sms->gic, irq));
 }
 
diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
index ed970273f3..9ccdc03095 100644
--- a/hw/arm/xilinx_zynq.c
+++ b/hw/arm/xilinx_zynq.c
@@ -29,7 +29,7 @@
 #include "hw/loader.h"
 #include "hw/misc/zynq-xadc.h"
 #include "hw/ssi/ssi.h"
-#include "hw/usb/chipidea.h"
+#include "hw/usb/usb-hcd.h"
 #include "qemu/error-report.h"
 #include "hw/sd/sdhci.h"
 #include "hw/char/cadence_uart.h"
diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
index ac60d17a86..3f7cf0d1ae 100644
--- a/hw/ppc/sam460ex.c
+++ b/hw/ppc/sam460ex.c
@@ -37,7 +37,6 @@
 #include "hw/i2c/smbus_eeprom.h"
 #include "hw/usb/usb.h"
 #include "hw/usb/usb-hcd.h"
-#include "hw/usb/hcd-ehci.h"
 #include "hw/ppc/fdt.h"
 #include "hw/qdev-properties.h"
 #include "hw/pci/pci.h"
diff --git a/hw/usb/chipidea.c b/hw/usb/chipidea.c
index 3dcd22ccba..e81f63295e 100644
--- a/hw/usb/chipidea.c
+++ b/hw/usb/chipidea.c
@@ -11,6 +11,7 @@
 
 #include "qemu/osdep.h"
 #include "hw/usb/hcd-ehci.h"
+#include "hw/usb/usb-hcd.h"
 #include "hw/usb/chipidea.h"
 #include "qemu/log.h"
 #include "qemu/module.h"
diff --git a/hw/usb/hcd-ehci-sysbus.c b/hw/usb/hcd-ehci-sysbus.c
index 3730736540..b7debc1934 100644
--- a/hw/usb/hcd-ehci-sysbus.c
+++ b/hw/usb/hcd-ehci-sysbus.c
@@ -18,6 +18,7 @@
 #include "qemu/osdep.h"
 #include "hw/qdev-properties.h"
 #include "hw/usb/hcd-ehci.h"
+#include "hw/usb/usb-hcd.h"
 #include "migration/vmstate.h"
 #include "qemu/module.h"
 
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 24/26] hw/usb/usb-hcd: Use UHCI type definitions
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
                   ` (22 preceding siblings ...)
  2020-07-04 14:49 ` [PATCH 23/26] hw/usb/usb-hcd: Use EHCI " Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-04 17:17   ` BALATON Zoltan
  2020-07-04 14:49 ` [PATCH 25/26] hw/usb/usb-hcd: Use XHCI " Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  26 siblings, 1 reply; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

Various machine/board/soc models create UHCI device instances
with the generic QDEV API, and don't need to access USB internals.

Simplify header inclusions by moving the QOM type names into a
simple header, with no need to include other "hw/usb" headers.

Suggested-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/hw/usb/usb-hcd.h |  6 ++++++
 hw/i386/pc_piix.c        |  3 ++-
 hw/i386/pc_q35.c         | 13 +++++++------
 hw/isa/piix4.c           |  3 ++-
 hw/mips/fuloong2e.c      |  5 +++--
 hw/usb/hcd-uhci.c        | 19 ++++++++++---------
 6 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/include/hw/usb/usb-hcd.h b/include/hw/usb/usb-hcd.h
index 74af3a4533..c9d0a88984 100644
--- a/include/hw/usb/usb-hcd.h
+++ b/include/hw/usb/usb-hcd.h
@@ -24,4 +24,10 @@
 #define TYPE_FUSBH200_EHCI          "fusbh200-ehci-usb"
 #define TYPE_CHIPIDEA               "usb-chipidea"
 
+/* UHCI */
+#define TYPE_PIIX3_USB_UHCI         "piix3-usb-uhci"
+#define TYPE_PIIX4_USB_UHCI         "piix4-usb-uhci"
+#define TYPE_VT82C686B_USB_UHCI     "vt82c686b-usb-uhci"
+#define TYPE_ICH9_USB_UHCI(n)       "ich9-usb-uhci" #n
+
 #endif
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 4d1de7cfab..0024c346c6 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -37,6 +37,7 @@
 #include "hw/pci/pci.h"
 #include "hw/pci/pci_ids.h"
 #include "hw/usb/usb.h"
+#include "hw/usb/usb-hcd.h"
 #include "net/net.h"
 #include "hw/ide/pci.h"
 #include "hw/irq.h"
@@ -275,7 +276,7 @@ static void pc_init1(MachineState *machine,
 #endif
 
     if (pcmc->pci_enabled && machine_usb(machine)) {
-        pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
+        pci_create_simple(pci_bus, piix3_devfn + 2, TYPE_PIIX3_USB_UHCI);
     }
 
     if (pcmc->pci_enabled && x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) {
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index b985f5bea1..a80527e6ed 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -51,6 +51,7 @@
 #include "hw/ide/pci.h"
 #include "hw/ide/ahci.h"
 #include "hw/usb/usb.h"
+#include "hw/usb/usb-hcd.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "sysemu/numa.h"
@@ -68,15 +69,15 @@ struct ehci_companions {
 };
 
 static const struct ehci_companions ich9_1d[] = {
-    { .name = "ich9-usb-uhci1", .func = 0, .port = 0 },
-    { .name = "ich9-usb-uhci2", .func = 1, .port = 2 },
-    { .name = "ich9-usb-uhci3", .func = 2, .port = 4 },
+    { .name = TYPE_ICH9_USB_UHCI(1), .func = 0, .port = 0 },
+    { .name = TYPE_ICH9_USB_UHCI(2), .func = 1, .port = 2 },
+    { .name = TYPE_ICH9_USB_UHCI(3), .func = 2, .port = 4 },
 };
 
 static const struct ehci_companions ich9_1a[] = {
-    { .name = "ich9-usb-uhci4", .func = 0, .port = 0 },
-    { .name = "ich9-usb-uhci5", .func = 1, .port = 2 },
-    { .name = "ich9-usb-uhci6", .func = 2, .port = 4 },
+    { .name = TYPE_ICH9_USB_UHCI(4), .func = 0, .port = 0 },
+    { .name = TYPE_ICH9_USB_UHCI(5), .func = 1, .port = 2 },
+    { .name = TYPE_ICH9_USB_UHCI(6), .func = 2, .port = 4 },
 };
 
 static int ehci_create_ich9_with_companions(PCIBus *bus, int slot)
diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
index f634bcb2d1..e11e5fae21 100644
--- a/hw/isa/piix4.c
+++ b/hw/isa/piix4.c
@@ -29,6 +29,7 @@
 #include "hw/southbridge/piix.h"
 #include "hw/pci/pci.h"
 #include "hw/isa/isa.h"
+#include "hw/usb/usb-hcd.h"
 #include "hw/sysbus.h"
 #include "hw/intc/i8259.h"
 #include "hw/dma/i8257.h"
@@ -255,7 +256,7 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus)
     pci = pci_create_simple(pci_bus, devfn + 1, "piix4-ide");
     pci_ide_create_devs(pci);
 
-    pci_create_simple(pci_bus, devfn + 2, "piix4-usb-uhci");
+    pci_create_simple(pci_bus, devfn + 2, TYPE_PIIX4_USB_UHCI);
     if (smbus) {
         *smbus = piix4_pm_init(pci_bus, devfn + 3, 0x1100,
                                isa_get_irq(NULL, 9), NULL, 0, NULL);
diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c
index 8ca31e5162..b6d33dd2cd 100644
--- a/hw/mips/fuloong2e.c
+++ b/hw/mips/fuloong2e.c
@@ -33,6 +33,7 @@
 #include "hw/mips/mips.h"
 #include "hw/mips/cpudevs.h"
 #include "hw/pci/pci.h"
+#include "hw/usb/usb-hcd.h"
 #include "qemu/log.h"
 #include "hw/loader.h"
 #include "hw/ide/pci.h"
@@ -258,8 +259,8 @@ static void vt82c686b_southbridge_init(PCIBus *pci_bus, int slot, qemu_irq intc,
     dev = pci_create_simple(pci_bus, PCI_DEVFN(slot, 1), "via-ide");
     pci_ide_create_devs(dev);
 
-    pci_create_simple(pci_bus, PCI_DEVFN(slot, 2), "vt82c686b-usb-uhci");
-    pci_create_simple(pci_bus, PCI_DEVFN(slot, 3), "vt82c686b-usb-uhci");
+    pci_create_simple(pci_bus, PCI_DEVFN(slot, 2), TYPE_VT82C686B_USB_UHCI);
+    pci_create_simple(pci_bus, PCI_DEVFN(slot, 3), TYPE_VT82C686B_USB_UHCI);
 
     *i2c_bus = vt82c686b_pm_init(pci_bus, PCI_DEVFN(slot, 4), 0xeee1, NULL);
 
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index 1d4dd33b6c..da078dc3fa 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -39,6 +39,7 @@
 #include "qemu/main-loop.h"
 #include "qemu/module.h"
 #include "usb-internal.h"
+#include "hw/usb/usb-hcd.h"
 
 #define FRAME_TIMER_FREQ 1000
 
@@ -1358,21 +1359,21 @@ static void uhci_data_class_init(ObjectClass *klass, void *data)
 
 static UHCIInfo uhci_info[] = {
     {
-        .name       = "piix3-usb-uhci",
+        .name      = TYPE_PIIX3_USB_UHCI,
         .vendor_id = PCI_VENDOR_ID_INTEL,
         .device_id = PCI_DEVICE_ID_INTEL_82371SB_2,
         .revision  = 0x01,
         .irq_pin   = 3,
         .unplug    = true,
     },{
-        .name      = "piix4-usb-uhci",
+        .name      = TYPE_PIIX4_USB_UHCI,
         .vendor_id = PCI_VENDOR_ID_INTEL,
         .device_id = PCI_DEVICE_ID_INTEL_82371AB_2,
         .revision  = 0x01,
         .irq_pin   = 3,
         .unplug    = true,
     },{
-        .name      = "vt82c686b-usb-uhci",
+        .name      = TYPE_VT82C686B_USB_UHCI,
         .vendor_id = PCI_VENDOR_ID_VIA,
         .device_id = PCI_DEVICE_ID_VIA_UHCI,
         .revision  = 0x01,
@@ -1380,42 +1381,42 @@ static UHCIInfo uhci_info[] = {
         .realize   = usb_uhci_vt82c686b_realize,
         .unplug    = true,
     },{
-        .name      = "ich9-usb-uhci1", /* 00:1d.0 */
+        .name      = TYPE_ICH9_USB_UHCI(1), /* 00:1d.0 */
         .vendor_id = PCI_VENDOR_ID_INTEL,
         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI1,
         .revision  = 0x03,
         .irq_pin   = 0,
         .unplug    = false,
     },{
-        .name      = "ich9-usb-uhci2", /* 00:1d.1 */
+        .name      = TYPE_ICH9_USB_UHCI(2), /* 00:1d.1 */
         .vendor_id = PCI_VENDOR_ID_INTEL,
         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI2,
         .revision  = 0x03,
         .irq_pin   = 1,
         .unplug    = false,
     },{
-        .name      = "ich9-usb-uhci3", /* 00:1d.2 */
+        .name      = TYPE_ICH9_USB_UHCI(3), /* 00:1d.2 */
         .vendor_id = PCI_VENDOR_ID_INTEL,
         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI3,
         .revision  = 0x03,
         .irq_pin   = 2,
         .unplug    = false,
     },{
-        .name      = "ich9-usb-uhci4", /* 00:1a.0 */
+        .name      = TYPE_ICH9_USB_UHCI(4), /* 00:1a.0 */
         .vendor_id = PCI_VENDOR_ID_INTEL,
         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI4,
         .revision  = 0x03,
         .irq_pin   = 0,
         .unplug    = false,
     },{
-        .name      = "ich9-usb-uhci5", /* 00:1a.1 */
+        .name      = TYPE_ICH9_USB_UHCI(5), /* 00:1a.1 */
         .vendor_id = PCI_VENDOR_ID_INTEL,
         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI5,
         .revision  = 0x03,
         .irq_pin   = 1,
         .unplug    = false,
     },{
-        .name      = "ich9-usb-uhci6", /* 00:1a.2 */
+        .name      = TYPE_ICH9_USB_UHCI(6), /* 00:1a.2 */
         .vendor_id = PCI_VENDOR_ID_INTEL,
         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI6,
         .revision  = 0x03,
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 25/26] hw/usb/usb-hcd: Use XHCI type definitions
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
                   ` (23 preceding siblings ...)
  2020-07-04 14:49 ` [PATCH 24/26] hw/usb/usb-hcd: Use UHCI " Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-04 17:19   ` BALATON Zoltan
  2020-07-04 14:49 ` [PATCH 26/26] MAINTAINERS: Cover dwc-hsotg (dwc2) USB host controller emulation Philippe Mathieu-Daudé
  2020-07-13  9:46 ` [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Gerd Hoffmann
  26 siblings, 1 reply; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

Various machine/board/soc models create XHCI device instances
with the generic QDEV API, and don't need to access USB internals.

Simplify header inclusions by moving the QOM type names into a
simple header, with no need to include other "hw/usb" headers.

Suggested-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/usb/hcd-xhci.h        | 2 +-
 include/hw/usb/usb-hcd.h | 3 +++
 hw/ppc/spapr.c           | 2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/hw/usb/hcd-xhci.h b/hw/usb/hcd-xhci.h
index f9a3aaceec..b6c54e38a6 100644
--- a/hw/usb/hcd-xhci.h
+++ b/hw/usb/hcd-xhci.h
@@ -23,9 +23,9 @@
 #define HW_USB_HCD_XHCI_H
 
 #include "usb-internal.h"
+#include "hw/usb/usb-hcd.h"
 
 #define TYPE_XHCI "base-xhci"
-#define TYPE_NEC_XHCI "nec-usb-xhci"
 #define TYPE_QEMU_XHCI "qemu-xhci"
 
 #define XHCI(obj) \
diff --git a/include/hw/usb/usb-hcd.h b/include/hw/usb/usb-hcd.h
index c9d0a88984..56107fca62 100644
--- a/include/hw/usb/usb-hcd.h
+++ b/include/hw/usb/usb-hcd.h
@@ -30,4 +30,7 @@
 #define TYPE_VT82C686B_USB_UHCI     "vt82c686b-usb-uhci"
 #define TYPE_ICH9_USB_UHCI(n)       "ich9-usb-uhci" #n
 
+/* XHCI */
+#define TYPE_NEC_XHCI "nec-usb-xhci"
+
 #endif
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index db1706a66c..d8b3978f24 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2961,7 +2961,7 @@ static void spapr_machine_init(MachineState *machine)
         if (smc->use_ohci_by_default) {
             pci_create_simple(phb->bus, -1, TYPE_PCI_OHCI);
         } else {
-            pci_create_simple(phb->bus, -1, "nec-usb-xhci");
+            pci_create_simple(phb->bus, -1, TYPE_NEC_XHCI);
         }
 
         if (spapr->has_graphics) {
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 26/26] MAINTAINERS: Cover dwc-hsotg (dwc2) USB host controller emulation
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
                   ` (24 preceding siblings ...)
  2020-07-04 14:49 ` [PATCH 25/26] hw/usb/usb-hcd: Use XHCI " Philippe Mathieu-Daudé
@ 2020-07-04 14:49 ` Philippe Mathieu-Daudé
  2020-07-04 16:25   ` Paul Zimmerman
  2020-07-13  9:46 ` [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Gerd Hoffmann
  26 siblings, 1 reply; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 14:49 UTC (permalink / raw)
  To: qemu-devel, BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, Jiaxun Yang,
	Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

Add an section for the dwc2 host controller emulation
introduced in commit 153ef1662c.

Cc: Paul Zimmerman <pauldzim@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 2566566d72..e3f895bc6e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1651,6 +1651,12 @@ M: Samuel Thibault <samuel.thibault@ens-lyon.org>
 S: Maintained
 F: hw/usb/dev-serial.c
 
+USB dwc-hsotg (dwc2)
+M: Gerd Hoffmann <kraxel@redhat.com>
+R: Paul Zimmerman <pauldzim@gmail.com>
+S: Maintained
+F: hw/usb/*dwc2*
+
 VFIO
 M: Alex Williamson <alex.williamson@redhat.com>
 S: Supported
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 63+ messages in thread

* Re: [PATCH 26/26] MAINTAINERS: Cover dwc-hsotg (dwc2) USB host controller emulation
  2020-07-04 14:49 ` [PATCH 26/26] MAINTAINERS: Cover dwc-hsotg (dwc2) USB host controller emulation Philippe Mathieu-Daudé
@ 2020-07-04 16:25   ` Paul Zimmerman
  0 siblings, 0 replies; 63+ messages in thread
From: Paul Zimmerman @ 2020-07-04 16:25 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Jiaxun Yang, BALATON Zoltan, Gerd Hoffmann, Edgar E. Iglesias,
	Huacai Chen, Stefano Stabellini, xen-devel, Yoshinori Sato,
	Richard Henderson, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Marcel Apfelbaum, Anthony Perard,
	Marc-André Lureau, Leif Lindholm, Andrzej Zaborowski,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani, Niek Linnenbank,
	qemu-arm, Samuel Thibault, David Gibson, Radoslaw Biernacki,
	Igor Mitsyanko, Philippe Mathieu-Daudé,
	qemu-ppc, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 911 bytes --]

On Sat, Jul 4, 2020 at 7:50 AM Philippe Mathieu-Daudé <f4bug@amsat.org>
wrote:

> Add an section for the dwc2 host controller emulation
> introduced in commit 153ef1662c.
>
> Cc: Paul Zimmerman <pauldzim@gmail.com>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  MAINTAINERS | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 2566566d72..e3f895bc6e 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1651,6 +1651,12 @@ M: Samuel Thibault <samuel.thibault@ens-lyon.org>
>  S: Maintained
>  F: hw/usb/dev-serial.c
>
> +USB dwc-hsotg (dwc2)
> +M: Gerd Hoffmann <kraxel@redhat.com>
> +R: Paul Zimmerman <pauldzim@gmail.com>
> +S: Maintained
> +F: hw/usb/*dwc2*
> +
>  VFIO
>  M: Alex Williamson <alex.williamson@redhat.com>
>  S: Supported


Acked-by: Paul Zimmerman <pauldzim@gmail.com>


> --
> 2.21.3
>
>

[-- Attachment #2: Type: text/html, Size: 1849 bytes --]

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 22/26] hw/usb/usb-hcd: Use OHCI type definitions
  2020-07-04 14:49 ` [PATCH 22/26] hw/usb/usb-hcd: Use OHCI type definitions Philippe Mathieu-Daudé
@ 2020-07-04 17:13   ` BALATON Zoltan
  2020-07-04 18:09     ` Philippe Mathieu-Daudé
  2020-07-05 19:55   ` Niek Linnenbank
  1 sibling, 1 reply; 63+ messages in thread
From: BALATON Zoltan @ 2020-07-04 17:13 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Jiaxun Yang, Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 11012 bytes --]

On Sat, 4 Jul 2020, Philippe Mathieu-Daudé wrote:
> Various machine/board/soc models create OHCI device instances
> with the generic QDEV API, and don't need to access USB internals.
>
> Simplify header inclusions by moving the QOM type names into a
> simple header, with no need to include other "hw/usb" headers.
>
> Suggested-by: BALATON Zoltan <balaton@eik.bme.hu>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> hw/usb/hcd-ohci.h        |  2 +-
> include/hw/usb/usb-hcd.h | 16 ++++++++++++++++

I wonder if we need a new header for this or these could just go in the 
new public hw/usb/usb.h as machines creating a HCD may also add devices 
(like keyboard/mouse) so probably will need both headers anyway so 
splitting it up may not worth it but I don't really mind, either way.

For sm501 and sam460ex parts:

Reviewed-by: BALATON Zoltan <balaton@eik.bme.hu>

Regards,
BALATON Zoltan

> hw/arm/allwinner-a10.c   |  2 +-
> hw/arm/allwinner-h3.c    |  9 +++++----
> hw/arm/pxa2xx.c          |  3 ++-
> hw/arm/realview.c        |  3 ++-
> hw/arm/versatilepb.c     |  3 ++-
> hw/display/sm501.c       |  3 ++-
> hw/ppc/mac_newworld.c    |  3 ++-
> hw/ppc/mac_oldworld.c    |  3 ++-
> hw/ppc/sam460ex.c        |  3 ++-
> hw/ppc/spapr.c           |  3 ++-
> hw/usb/hcd-ohci-pci.c    |  2 +-
> 13 files changed, 40 insertions(+), 15 deletions(-)
> create mode 100644 include/hw/usb/usb-hcd.h
>
> diff --git a/hw/usb/hcd-ohci.h b/hw/usb/hcd-ohci.h
> index 771927ea17..6949cf0dab 100644
> --- a/hw/usb/hcd-ohci.h
> +++ b/hw/usb/hcd-ohci.h
> @@ -21,6 +21,7 @@
> #ifndef HCD_OHCI_H
> #define HCD_OHCI_H
>
> +#include "hw/usb/usb-hcd.h"
> #include "sysemu/dma.h"
> #include "usb-internal.h"
>
> @@ -91,7 +92,6 @@ typedef struct OHCIState {
>     void (*ohci_die)(struct OHCIState *ohci);
> } OHCIState;
>
> -#define TYPE_SYSBUS_OHCI "sysbus-ohci"
> #define SYSBUS_OHCI(obj) OBJECT_CHECK(OHCISysBusState, (obj), TYPE_SYSBUS_OHCI)
>
> typedef struct {
> diff --git a/include/hw/usb/usb-hcd.h b/include/hw/usb/usb-hcd.h
> new file mode 100644
> index 0000000000..21fdfaf22d
> --- /dev/null
> +++ b/include/hw/usb/usb-hcd.h
> @@ -0,0 +1,16 @@
> +/*
> + * QEMU USB HCD types
> + *
> + * Copyright (c) 2020  Philippe Mathieu-Daudé <f4bug@amsat.org>
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +
> +#ifndef HW_USB_HCD_TYPES_H
> +#define HW_USB_HCD_TYPES_H
> +
> +/* OHCI */
> +#define TYPE_SYSBUS_OHCI            "sysbus-ohci"
> +#define TYPE_PCI_OHCI               "pci-ohci"
> +
> +#endif
> diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
> index 52e0d83760..53c24ff602 100644
> --- a/hw/arm/allwinner-a10.c
> +++ b/hw/arm/allwinner-a10.c
> @@ -25,7 +25,7 @@
> #include "hw/misc/unimp.h"
> #include "sysemu/sysemu.h"
> #include "hw/boards.h"
> -#include "hw/usb/hcd-ohci.h"
> +#include "hw/usb/usb-hcd.h"
>
> #define AW_A10_MMC0_BASE        0x01c0f000
> #define AW_A10_PIC_REG_BASE     0x01c20400
> diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
> index 8e09468e86..d1d90ffa79 100644
> --- a/hw/arm/allwinner-h3.c
> +++ b/hw/arm/allwinner-h3.c
> @@ -28,6 +28,7 @@
> #include "hw/sysbus.h"
> #include "hw/char/serial.h"
> #include "hw/misc/unimp.h"
> +#include "hw/usb/usb-hcd.h"
> #include "hw/usb/hcd-ehci.h"
> #include "hw/loader.h"
> #include "sysemu/sysemu.h"
> @@ -381,16 +382,16 @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)
>                          qdev_get_gpio_in(DEVICE(&s->gic),
>                                           AW_H3_GIC_SPI_EHCI3));
>
> -    sysbus_create_simple("sysbus-ohci", s->memmap[AW_H3_OHCI0],
> +    sysbus_create_simple(TYPE_SYSBUS_OHCI, s->memmap[AW_H3_OHCI0],
>                          qdev_get_gpio_in(DEVICE(&s->gic),
>                                           AW_H3_GIC_SPI_OHCI0));
> -    sysbus_create_simple("sysbus-ohci", s->memmap[AW_H3_OHCI1],
> +    sysbus_create_simple(TYPE_SYSBUS_OHCI, s->memmap[AW_H3_OHCI1],
>                          qdev_get_gpio_in(DEVICE(&s->gic),
>                                           AW_H3_GIC_SPI_OHCI1));
> -    sysbus_create_simple("sysbus-ohci", s->memmap[AW_H3_OHCI2],
> +    sysbus_create_simple(TYPE_SYSBUS_OHCI, s->memmap[AW_H3_OHCI2],
>                          qdev_get_gpio_in(DEVICE(&s->gic),
>                                           AW_H3_GIC_SPI_OHCI2));
> -    sysbus_create_simple("sysbus-ohci", s->memmap[AW_H3_OHCI3],
> +    sysbus_create_simple(TYPE_SYSBUS_OHCI, s->memmap[AW_H3_OHCI3],
>                          qdev_get_gpio_in(DEVICE(&s->gic),
>                                           AW_H3_GIC_SPI_OHCI3));
>
> diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
> index f104a33463..27196170f5 100644
> --- a/hw/arm/pxa2xx.c
> +++ b/hw/arm/pxa2xx.c
> @@ -18,6 +18,7 @@
> #include "hw/arm/pxa.h"
> #include "sysemu/sysemu.h"
> #include "hw/char/serial.h"
> +#include "hw/usb/usb-hcd.h"
> #include "hw/i2c/i2c.h"
> #include "hw/irq.h"
> #include "hw/qdev-properties.h"
> @@ -2196,7 +2197,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,
>         s->ssp[i] = (SSIBus *)qdev_get_child_bus(dev, "ssi");
>     }
>
> -    sysbus_create_simple("sysbus-ohci", 0x4c000000,
> +    sysbus_create_simple(TYPE_SYSBUS_OHCI, 0x4c000000,
>                          qdev_get_gpio_in(s->pic, PXA2XX_PIC_USBH1));
>
>     s->pcmcia[0] = pxa2xx_pcmcia_init(address_space, 0x20000000);
> diff --git a/hw/arm/realview.c b/hw/arm/realview.c
> index b6c0a1adb9..0aa34bd4c2 100644
> --- a/hw/arm/realview.c
> +++ b/hw/arm/realview.c
> @@ -16,6 +16,7 @@
> #include "hw/net/lan9118.h"
> #include "hw/net/smc91c111.h"
> #include "hw/pci/pci.h"
> +#include "hw/usb/usb-hcd.h"
> #include "net/net.h"
> #include "sysemu/sysemu.h"
> #include "hw/boards.h"
> @@ -256,7 +257,7 @@ static void realview_init(MachineState *machine,
>         sysbus_connect_irq(busdev, 3, pic[51]);
>         pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci");
>         if (machine_usb(machine)) {
> -            pci_create_simple(pci_bus, -1, "pci-ohci");
> +            pci_create_simple(pci_bus, -1, TYPE_PCI_OHCI);
>         }
>         n = drive_get_max_bus(IF_SCSI);
>         while (n >= 0) {
> diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
> index e596b8170f..3e6224dc96 100644
> --- a/hw/arm/versatilepb.c
> +++ b/hw/arm/versatilepb.c
> @@ -17,6 +17,7 @@
> #include "net/net.h"
> #include "sysemu/sysemu.h"
> #include "hw/pci/pci.h"
> +#include "hw/usb/usb-hcd.h"
> #include "hw/i2c/i2c.h"
> #include "hw/i2c/arm_sbcon_i2c.h"
> #include "hw/irq.h"
> @@ -273,7 +274,7 @@ static void versatile_init(MachineState *machine, int board_id)
>         }
>     }
>     if (machine_usb(machine)) {
> -        pci_create_simple(pci_bus, -1, "pci-ohci");
> +        pci_create_simple(pci_bus, -1, TYPE_PCI_OHCI);
>     }
>     n = drive_get_max_bus(IF_SCSI);
>     while (n >= 0) {
> diff --git a/hw/display/sm501.c b/hw/display/sm501.c
> index 9cccc68c35..5f076c841f 100644
> --- a/hw/display/sm501.c
> +++ b/hw/display/sm501.c
> @@ -33,6 +33,7 @@
> #include "hw/sysbus.h"
> #include "migration/vmstate.h"
> #include "hw/pci/pci.h"
> +#include "hw/usb/usb-hcd.h"
> #include "hw/qdev-properties.h"
> #include "hw/i2c/i2c.h"
> #include "hw/display/i2c-ddc.h"
> @@ -1961,7 +1962,7 @@ static void sm501_realize_sysbus(DeviceState *dev, Error **errp)
>     sysbus_init_mmio(sbd, &s->state.mmio_region);
>
>     /* bridge to usb host emulation module */
> -    usb_dev = qdev_new("sysbus-ohci");
> +    usb_dev = qdev_new(TYPE_SYSBUS_OHCI);
>     qdev_prop_set_uint32(usb_dev, "num-ports", 2);
>     qdev_prop_set_uint64(usb_dev, "dma-offset", s->base);
>     sysbus_realize_and_unref(SYS_BUS_DEVICE(usb_dev), &error_fatal);
> diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
> index 7bf69f4a1f..3c32c1831b 100644
> --- a/hw/ppc/mac_newworld.c
> +++ b/hw/ppc/mac_newworld.c
> @@ -55,6 +55,7 @@
> #include "hw/input/adb.h"
> #include "hw/ppc/mac_dbdma.h"
> #include "hw/pci/pci.h"
> +#include "hw/usb/usb-hcd.h"
> #include "net/net.h"
> #include "sysemu/sysemu.h"
> #include "hw/boards.h"
> @@ -411,7 +412,7 @@ static void ppc_core99_init(MachineState *machine)
>     }
>
>     if (machine->usb) {
> -        pci_create_simple(pci_bus, -1, "pci-ohci");
> +        pci_create_simple(pci_bus, -1, TYPE_PCI_OHCI);
>
>         /* U3 needs to use USB for input because Linux doesn't support via-cuda
>         on PPC64 */
> diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
> index f8c204ead7..a429a3e1df 100644
> --- a/hw/ppc/mac_oldworld.c
> +++ b/hw/ppc/mac_oldworld.c
> @@ -37,6 +37,7 @@
> #include "hw/isa/isa.h"
> #include "hw/pci/pci.h"
> #include "hw/pci/pci_host.h"
> +#include "hw/usb/usb-hcd.h"
> #include "hw/boards.h"
> #include "hw/nvram/fw_cfg.h"
> #include "hw/char/escc.h"
> @@ -301,7 +302,7 @@ static void ppc_heathrow_init(MachineState *machine)
>     qdev_realize_and_unref(dev, adb_bus, &error_fatal);
>
>     if (machine_usb(machine)) {
> -        pci_create_simple(pci_bus, -1, "pci-ohci");
> +        pci_create_simple(pci_bus, -1, TYPE_PCI_OHCI);
>     }
>
>     if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
> diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
> index 781b45e14b..ac60d17a86 100644
> --- a/hw/ppc/sam460ex.c
> +++ b/hw/ppc/sam460ex.c
> @@ -36,6 +36,7 @@
> #include "hw/i2c/ppc4xx_i2c.h"
> #include "hw/i2c/smbus_eeprom.h"
> #include "hw/usb/usb.h"
> +#include "hw/usb/usb-hcd.h"
> #include "hw/usb/hcd-ehci.h"
> #include "hw/ppc/fdt.h"
> #include "hw/qdev-properties.h"
> @@ -372,7 +373,7 @@ static void sam460ex_init(MachineState *machine)
>
>     /* USB */
>     sysbus_create_simple(TYPE_PPC4xx_EHCI, 0x4bffd0400, uic[2][29]);
> -    dev = qdev_new("sysbus-ohci");
> +    dev = qdev_new(TYPE_SYSBUS_OHCI);
>     qdev_prop_set_string(dev, "masterbus", "usb-bus.0");
>     qdev_prop_set_uint32(dev, "num-ports", 6);
>     sbdev = SYS_BUS_DEVICE(dev);
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 0c0409077f..db1706a66c 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -71,6 +71,7 @@
> #include "exec/address-spaces.h"
> #include "exec/ram_addr.h"
> #include "hw/usb/usb.h"
> +#include "hw/usb/usb-hcd.h"
> #include "qemu/config-file.h"
> #include "qemu/error-report.h"
> #include "trace.h"
> @@ -2958,7 +2959,7 @@ static void spapr_machine_init(MachineState *machine)
>
>     if (machine->usb) {
>         if (smc->use_ohci_by_default) {
> -            pci_create_simple(phb->bus, -1, "pci-ohci");
> +            pci_create_simple(phb->bus, -1, TYPE_PCI_OHCI);
>         } else {
>             pci_create_simple(phb->bus, -1, "nec-usb-xhci");
>         }
> diff --git a/hw/usb/hcd-ohci-pci.c b/hw/usb/hcd-ohci-pci.c
> index cb6bc55f59..14df83ec2e 100644
> --- a/hw/usb/hcd-ohci-pci.c
> +++ b/hw/usb/hcd-ohci-pci.c
> @@ -29,8 +29,8 @@
> #include "trace.h"
> #include "hcd-ohci.h"
> #include "usb-internal.h"
> +#include "hw/usb/usb-hcd.h"
>
> -#define TYPE_PCI_OHCI "pci-ohci"
> #define PCI_OHCI(obj) OBJECT_CHECK(OHCIPCIState, (obj), TYPE_PCI_OHCI)
>
> typedef struct {
>

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 23/26] hw/usb/usb-hcd: Use EHCI type definitions
  2020-07-04 14:49 ` [PATCH 23/26] hw/usb/usb-hcd: Use EHCI " Philippe Mathieu-Daudé
@ 2020-07-04 17:15   ` BALATON Zoltan
  2020-07-05  9:26     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 63+ messages in thread
From: BALATON Zoltan @ 2020-07-04 17:15 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Jiaxun Yang, Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 6623 bytes --]

On Sat, 4 Jul 2020, Philippe Mathieu-Daudé wrote:
> Various machine/board/soc models create EHCI device instances
> with the generic QDEV API, and don't need to access USB internals.
>
> Simplify header inclusions by moving the QOM type names into a
> simple header, with no need to include other "hw/usb" headers.
>
> Suggested-by: BALATON Zoltan <balaton@eik.bme.hu>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> hw/usb/hcd-ehci.h         | 11 +----------
> include/hw/usb/chipidea.h |  2 +-
> include/hw/usb/usb-hcd.h  | 11 +++++++++++
> hw/arm/allwinner-h3.c     |  1 -
> hw/arm/exynos4210.c       |  2 +-
> hw/arm/sbsa-ref.c         |  3 ++-
> hw/arm/xilinx_zynq.c      |  2 +-
> hw/ppc/sam460ex.c         |  1 -
> hw/usb/chipidea.c         |  1 +
> hw/usb/hcd-ehci-sysbus.c  |  1 +
> 10 files changed, 19 insertions(+), 16 deletions(-)
>
> diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h
> index 337b3ad05c..da70767409 100644
> --- a/hw/usb/hcd-ehci.h
> +++ b/hw/usb/hcd-ehci.h
> @@ -23,6 +23,7 @@
> #include "hw/pci/pci.h"
> #include "hw/sysbus.h"
> #include "usb-internal.h"
> +#include "hw/usb/usb-hcd.h"
>
> #define CAPA_SIZE        0x10
>
> @@ -316,7 +317,6 @@ void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp);
> void usb_ehci_unrealize(EHCIState *s, DeviceState *dev);
> void ehci_reset(void *opaque);
>
> -#define TYPE_PCI_EHCI "pci-ehci-usb"
> #define PCI_EHCI(obj) OBJECT_CHECK(EHCIPCIState, (obj), TYPE_PCI_EHCI)
>
> typedef struct EHCIPCIState {
> @@ -327,15 +327,6 @@ typedef struct EHCIPCIState {
>     EHCIState ehci;
> } EHCIPCIState;
>
> -
> -#define TYPE_SYS_BUS_EHCI "sysbus-ehci-usb"
> -#define TYPE_PLATFORM_EHCI "platform-ehci-usb"
> -#define TYPE_EXYNOS4210_EHCI "exynos4210-ehci-usb"
> -#define TYPE_AW_H3_EHCI "aw-h3-ehci-usb"
> -#define TYPE_TEGRA2_EHCI "tegra2-ehci-usb"
> -#define TYPE_PPC4xx_EHCI "ppc4xx-ehci-usb"
> -#define TYPE_FUSBH200_EHCI "fusbh200-ehci-usb"
> -
> #define SYS_BUS_EHCI(obj) \
>     OBJECT_CHECK(EHCISysBusState, (obj), TYPE_SYS_BUS_EHCI)
> #define SYS_BUS_EHCI_CLASS(class) \
> diff --git a/include/hw/usb/chipidea.h b/include/hw/usb/chipidea.h
> index 1ec2e9dbda..28f46291de 100644
> --- a/include/hw/usb/chipidea.h
> +++ b/include/hw/usb/chipidea.h
> @@ -2,6 +2,7 @@
> #define CHIPIDEA_H
>
> #include "hw/usb/hcd-ehci.h"
> +#include "hw/usb/usb-hcd.h"
>
> typedef struct ChipideaState {
>     /*< private >*/
> @@ -10,7 +11,6 @@ typedef struct ChipideaState {
>     MemoryRegion iomem[3];
> } ChipideaState;
>
> -#define TYPE_CHIPIDEA "usb-chipidea"
> #define CHIPIDEA(obj) OBJECT_CHECK(ChipideaState, (obj), TYPE_CHIPIDEA)
>
> #endif /* CHIPIDEA_H */
> diff --git a/include/hw/usb/usb-hcd.h b/include/hw/usb/usb-hcd.h
> index 21fdfaf22d..74af3a4533 100644
> --- a/include/hw/usb/usb-hcd.h
> +++ b/include/hw/usb/usb-hcd.h
> @@ -13,4 +13,15 @@
> #define TYPE_SYSBUS_OHCI            "sysbus-ohci"
> #define TYPE_PCI_OHCI               "pci-ohci"
>
> +/* EHCI */
> +#define TYPE_SYS_BUS_EHCI           "sysbus-ehci-usb"
> +#define TYPE_PCI_EHCI               "pci-ehci-usb"
> +#define TYPE_PLATFORM_EHCI          "platform-ehci-usb"
> +#define TYPE_EXYNOS4210_EHCI        "exynos4210-ehci-usb"
> +#define TYPE_AW_H3_EHCI             "aw-h3-ehci-usb"
> +#define TYPE_TEGRA2_EHCI            "tegra2-ehci-usb"
> +#define TYPE_PPC4xx_EHCI            "ppc4xx-ehci-usb"
> +#define TYPE_FUSBH200_EHCI          "fusbh200-ehci-usb"
> +#define TYPE_CHIPIDEA               "usb-chipidea"
> +
> #endif
> diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
> index d1d90ffa79..8b7adddc27 100644
> --- a/hw/arm/allwinner-h3.c
> +++ b/hw/arm/allwinner-h3.c
> @@ -29,7 +29,6 @@
> #include "hw/char/serial.h"
> #include "hw/misc/unimp.h"
> #include "hw/usb/usb-hcd.h"
> -#include "hw/usb/hcd-ehci.h"
> #include "hw/loader.h"
> #include "sysemu/sysemu.h"
> #include "hw/arm/allwinner-h3.h"
> diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
> index fa639806ec..692fb02159 100644
> --- a/hw/arm/exynos4210.c
> +++ b/hw/arm/exynos4210.c
> @@ -35,7 +35,7 @@
> #include "hw/qdev-properties.h"
> #include "hw/arm/exynos4210.h"
> #include "hw/sd/sdhci.h"
> -#include "hw/usb/hcd-ehci.h"
> +#include "hw/usb/usb-hcd.h"
>
> #define EXYNOS4210_CHIPID_ADDR         0x10000000
>
> diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
> index 021e7c1b8b..4e4c338ae9 100644
> --- a/hw/arm/sbsa-ref.c
> +++ b/hw/arm/sbsa-ref.c
> @@ -38,6 +38,7 @@
> #include "hw/loader.h"
> #include "hw/pci-host/gpex.h"
> #include "hw/qdev-properties.h"
> +#include "hw/usb/usb-hcd.h"
> #include "hw/char/pl011.h"
> #include "net/net.h"
>
> @@ -485,7 +486,7 @@ static void create_ehci(const SBSAMachineState *sms)
>     hwaddr base = sbsa_ref_memmap[SBSA_EHCI].base;
>     int irq = sbsa_ref_irqmap[SBSA_EHCI];
>
> -    sysbus_create_simple("platform-ehci-usb", base,
> +    sysbus_create_simple(TYPE_PLATFORM_EHCI, base,
>                          qdev_get_gpio_in(sms->gic, irq));
> }
>
> diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
> index ed970273f3..9ccdc03095 100644
> --- a/hw/arm/xilinx_zynq.c
> +++ b/hw/arm/xilinx_zynq.c
> @@ -29,7 +29,7 @@
> #include "hw/loader.h"
> #include "hw/misc/zynq-xadc.h"
> #include "hw/ssi/ssi.h"
> -#include "hw/usb/chipidea.h"
> +#include "hw/usb/usb-hcd.h"
> #include "qemu/error-report.h"
> #include "hw/sd/sdhci.h"
> #include "hw/char/cadence_uart.h"
> diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
> index ac60d17a86..3f7cf0d1ae 100644
> --- a/hw/ppc/sam460ex.c
> +++ b/hw/ppc/sam460ex.c
> @@ -37,7 +37,6 @@
> #include "hw/i2c/smbus_eeprom.h"
> #include "hw/usb/usb.h"
> #include "hw/usb/usb-hcd.h"
> -#include "hw/usb/hcd-ehci.h"
> #include "hw/ppc/fdt.h"
> #include "hw/qdev-properties.h"
> #include "hw/pci/pci.h"
> diff --git a/hw/usb/chipidea.c b/hw/usb/chipidea.c
> index 3dcd22ccba..e81f63295e 100644
> --- a/hw/usb/chipidea.c
> +++ b/hw/usb/chipidea.c
> @@ -11,6 +11,7 @@
>
> #include "qemu/osdep.h"
> #include "hw/usb/hcd-ehci.h"
> +#include "hw/usb/usb-hcd.h"
> #include "hw/usb/chipidea.h"
> #include "qemu/log.h"
> #include "qemu/module.h"
> diff --git a/hw/usb/hcd-ehci-sysbus.c b/hw/usb/hcd-ehci-sysbus.c
> index 3730736540..b7debc1934 100644
> --- a/hw/usb/hcd-ehci-sysbus.c
> +++ b/hw/usb/hcd-ehci-sysbus.c
> @@ -18,6 +18,7 @@
> #include "qemu/osdep.h"
> #include "hw/qdev-properties.h"
> #include "hw/usb/hcd-ehci.h"
> +#include "hw/usb/usb-hcd.h"
> #include "migration/vmstate.h"
> #include "qemu/module.h"

Do these last two still need hw/usb/hcd-ehci.h? If so do they get 
hw/usb/usb-hcd.h via that one so do they need to explicitely include it 
again?

Regards,
BALATON Zoltan

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 24/26] hw/usb/usb-hcd: Use UHCI type definitions
  2020-07-04 14:49 ` [PATCH 24/26] hw/usb/usb-hcd: Use UHCI " Philippe Mathieu-Daudé
@ 2020-07-04 17:17   ` BALATON Zoltan
  2020-07-04 18:12     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 63+ messages in thread
From: BALATON Zoltan @ 2020-07-04 17:17 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Jiaxun Yang, Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 8435 bytes --]

On Sat, 4 Jul 2020, Philippe Mathieu-Daudé wrote:
> Various machine/board/soc models create UHCI device instances
> with the generic QDEV API, and don't need to access USB internals.
>
> Simplify header inclusions by moving the QOM type names into a
> simple header, with no need to include other "hw/usb" headers.
>
> Suggested-by: BALATON Zoltan <balaton@eik.bme.hu>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> include/hw/usb/usb-hcd.h |  6 ++++++
> hw/i386/pc_piix.c        |  3 ++-
> hw/i386/pc_q35.c         | 13 +++++++------
> hw/isa/piix4.c           |  3 ++-
> hw/mips/fuloong2e.c      |  5 +++--
> hw/usb/hcd-uhci.c        | 19 ++++++++++---------
> 6 files changed, 30 insertions(+), 19 deletions(-)
>
> diff --git a/include/hw/usb/usb-hcd.h b/include/hw/usb/usb-hcd.h
> index 74af3a4533..c9d0a88984 100644
> --- a/include/hw/usb/usb-hcd.h
> +++ b/include/hw/usb/usb-hcd.h
> @@ -24,4 +24,10 @@
> #define TYPE_FUSBH200_EHCI          "fusbh200-ehci-usb"
> #define TYPE_CHIPIDEA               "usb-chipidea"
>
> +/* UHCI */
> +#define TYPE_PIIX3_USB_UHCI         "piix3-usb-uhci"
> +#define TYPE_PIIX4_USB_UHCI         "piix4-usb-uhci"
> +#define TYPE_VT82C686B_USB_UHCI     "vt82c686b-usb-uhci"
> +#define TYPE_ICH9_USB_UHCI(n)       "ich9-usb-uhci" #n

What is that #n at the end? Looks like a typo. Does it break compilation?

Regards,
BALATON Zoltan

> +
> #endif
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index 4d1de7cfab..0024c346c6 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -37,6 +37,7 @@
> #include "hw/pci/pci.h"
> #include "hw/pci/pci_ids.h"
> #include "hw/usb/usb.h"
> +#include "hw/usb/usb-hcd.h"
> #include "net/net.h"
> #include "hw/ide/pci.h"
> #include "hw/irq.h"
> @@ -275,7 +276,7 @@ static void pc_init1(MachineState *machine,
> #endif
>
>     if (pcmc->pci_enabled && machine_usb(machine)) {
> -        pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
> +        pci_create_simple(pci_bus, piix3_devfn + 2, TYPE_PIIX3_USB_UHCI);
>     }
>
>     if (pcmc->pci_enabled && x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) {
> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
> index b985f5bea1..a80527e6ed 100644
> --- a/hw/i386/pc_q35.c
> +++ b/hw/i386/pc_q35.c
> @@ -51,6 +51,7 @@
> #include "hw/ide/pci.h"
> #include "hw/ide/ahci.h"
> #include "hw/usb/usb.h"
> +#include "hw/usb/usb-hcd.h"
> #include "qapi/error.h"
> #include "qemu/error-report.h"
> #include "sysemu/numa.h"
> @@ -68,15 +69,15 @@ struct ehci_companions {
> };
>
> static const struct ehci_companions ich9_1d[] = {
> -    { .name = "ich9-usb-uhci1", .func = 0, .port = 0 },
> -    { .name = "ich9-usb-uhci2", .func = 1, .port = 2 },
> -    { .name = "ich9-usb-uhci3", .func = 2, .port = 4 },
> +    { .name = TYPE_ICH9_USB_UHCI(1), .func = 0, .port = 0 },
> +    { .name = TYPE_ICH9_USB_UHCI(2), .func = 1, .port = 2 },
> +    { .name = TYPE_ICH9_USB_UHCI(3), .func = 2, .port = 4 },
> };
>
> static const struct ehci_companions ich9_1a[] = {
> -    { .name = "ich9-usb-uhci4", .func = 0, .port = 0 },
> -    { .name = "ich9-usb-uhci5", .func = 1, .port = 2 },
> -    { .name = "ich9-usb-uhci6", .func = 2, .port = 4 },
> +    { .name = TYPE_ICH9_USB_UHCI(4), .func = 0, .port = 0 },
> +    { .name = TYPE_ICH9_USB_UHCI(5), .func = 1, .port = 2 },
> +    { .name = TYPE_ICH9_USB_UHCI(6), .func = 2, .port = 4 },
> };
>
> static int ehci_create_ich9_with_companions(PCIBus *bus, int slot)
> diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
> index f634bcb2d1..e11e5fae21 100644
> --- a/hw/isa/piix4.c
> +++ b/hw/isa/piix4.c
> @@ -29,6 +29,7 @@
> #include "hw/southbridge/piix.h"
> #include "hw/pci/pci.h"
> #include "hw/isa/isa.h"
> +#include "hw/usb/usb-hcd.h"
> #include "hw/sysbus.h"
> #include "hw/intc/i8259.h"
> #include "hw/dma/i8257.h"
> @@ -255,7 +256,7 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus)
>     pci = pci_create_simple(pci_bus, devfn + 1, "piix4-ide");
>     pci_ide_create_devs(pci);
>
> -    pci_create_simple(pci_bus, devfn + 2, "piix4-usb-uhci");
> +    pci_create_simple(pci_bus, devfn + 2, TYPE_PIIX4_USB_UHCI);
>     if (smbus) {
>         *smbus = piix4_pm_init(pci_bus, devfn + 3, 0x1100,
>                                isa_get_irq(NULL, 9), NULL, 0, NULL);
> diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c
> index 8ca31e5162..b6d33dd2cd 100644
> --- a/hw/mips/fuloong2e.c
> +++ b/hw/mips/fuloong2e.c
> @@ -33,6 +33,7 @@
> #include "hw/mips/mips.h"
> #include "hw/mips/cpudevs.h"
> #include "hw/pci/pci.h"
> +#include "hw/usb/usb-hcd.h"
> #include "qemu/log.h"
> #include "hw/loader.h"
> #include "hw/ide/pci.h"
> @@ -258,8 +259,8 @@ static void vt82c686b_southbridge_init(PCIBus *pci_bus, int slot, qemu_irq intc,
>     dev = pci_create_simple(pci_bus, PCI_DEVFN(slot, 1), "via-ide");
>     pci_ide_create_devs(dev);
>
> -    pci_create_simple(pci_bus, PCI_DEVFN(slot, 2), "vt82c686b-usb-uhci");
> -    pci_create_simple(pci_bus, PCI_DEVFN(slot, 3), "vt82c686b-usb-uhci");
> +    pci_create_simple(pci_bus, PCI_DEVFN(slot, 2), TYPE_VT82C686B_USB_UHCI);
> +    pci_create_simple(pci_bus, PCI_DEVFN(slot, 3), TYPE_VT82C686B_USB_UHCI);
>
>     *i2c_bus = vt82c686b_pm_init(pci_bus, PCI_DEVFN(slot, 4), 0xeee1, NULL);
>
> diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
> index 1d4dd33b6c..da078dc3fa 100644
> --- a/hw/usb/hcd-uhci.c
> +++ b/hw/usb/hcd-uhci.c
> @@ -39,6 +39,7 @@
> #include "qemu/main-loop.h"
> #include "qemu/module.h"
> #include "usb-internal.h"
> +#include "hw/usb/usb-hcd.h"
>
> #define FRAME_TIMER_FREQ 1000
>
> @@ -1358,21 +1359,21 @@ static void uhci_data_class_init(ObjectClass *klass, void *data)
>
> static UHCIInfo uhci_info[] = {
>     {
> -        .name       = "piix3-usb-uhci",
> +        .name      = TYPE_PIIX3_USB_UHCI,
>         .vendor_id = PCI_VENDOR_ID_INTEL,
>         .device_id = PCI_DEVICE_ID_INTEL_82371SB_2,
>         .revision  = 0x01,
>         .irq_pin   = 3,
>         .unplug    = true,
>     },{
> -        .name      = "piix4-usb-uhci",
> +        .name      = TYPE_PIIX4_USB_UHCI,
>         .vendor_id = PCI_VENDOR_ID_INTEL,
>         .device_id = PCI_DEVICE_ID_INTEL_82371AB_2,
>         .revision  = 0x01,
>         .irq_pin   = 3,
>         .unplug    = true,
>     },{
> -        .name      = "vt82c686b-usb-uhci",
> +        .name      = TYPE_VT82C686B_USB_UHCI,
>         .vendor_id = PCI_VENDOR_ID_VIA,
>         .device_id = PCI_DEVICE_ID_VIA_UHCI,
>         .revision  = 0x01,
> @@ -1380,42 +1381,42 @@ static UHCIInfo uhci_info[] = {
>         .realize   = usb_uhci_vt82c686b_realize,
>         .unplug    = true,
>     },{
> -        .name      = "ich9-usb-uhci1", /* 00:1d.0 */
> +        .name      = TYPE_ICH9_USB_UHCI(1), /* 00:1d.0 */
>         .vendor_id = PCI_VENDOR_ID_INTEL,
>         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI1,
>         .revision  = 0x03,
>         .irq_pin   = 0,
>         .unplug    = false,
>     },{
> -        .name      = "ich9-usb-uhci2", /* 00:1d.1 */
> +        .name      = TYPE_ICH9_USB_UHCI(2), /* 00:1d.1 */
>         .vendor_id = PCI_VENDOR_ID_INTEL,
>         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI2,
>         .revision  = 0x03,
>         .irq_pin   = 1,
>         .unplug    = false,
>     },{
> -        .name      = "ich9-usb-uhci3", /* 00:1d.2 */
> +        .name      = TYPE_ICH9_USB_UHCI(3), /* 00:1d.2 */
>         .vendor_id = PCI_VENDOR_ID_INTEL,
>         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI3,
>         .revision  = 0x03,
>         .irq_pin   = 2,
>         .unplug    = false,
>     },{
> -        .name      = "ich9-usb-uhci4", /* 00:1a.0 */
> +        .name      = TYPE_ICH9_USB_UHCI(4), /* 00:1a.0 */
>         .vendor_id = PCI_VENDOR_ID_INTEL,
>         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI4,
>         .revision  = 0x03,
>         .irq_pin   = 0,
>         .unplug    = false,
>     },{
> -        .name      = "ich9-usb-uhci5", /* 00:1a.1 */
> +        .name      = TYPE_ICH9_USB_UHCI(5), /* 00:1a.1 */
>         .vendor_id = PCI_VENDOR_ID_INTEL,
>         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI5,
>         .revision  = 0x03,
>         .irq_pin   = 1,
>         .unplug    = false,
>     },{
> -        .name      = "ich9-usb-uhci6", /* 00:1a.2 */
> +        .name      = TYPE_ICH9_USB_UHCI(6), /* 00:1a.2 */
>         .vendor_id = PCI_VENDOR_ID_INTEL,
>         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI6,
>         .revision  = 0x03,
>

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 25/26] hw/usb/usb-hcd: Use XHCI type definitions
  2020-07-04 14:49 ` [PATCH 25/26] hw/usb/usb-hcd: Use XHCI " Philippe Mathieu-Daudé
@ 2020-07-04 17:19   ` BALATON Zoltan
  2020-07-04 18:07     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 63+ messages in thread
From: BALATON Zoltan @ 2020-07-04 17:19 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Jiaxun Yang, Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 2027 bytes --]

On Sat, 4 Jul 2020, Philippe Mathieu-Daudé wrote:
> Various machine/board/soc models create XHCI device instances
> with the generic QDEV API, and don't need to access USB internals.
>
> Simplify header inclusions by moving the QOM type names into a
> simple header, with no need to include other "hw/usb" headers.
>
> Suggested-by: BALATON Zoltan <balaton@eik.bme.hu>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> hw/usb/hcd-xhci.h        | 2 +-
> include/hw/usb/usb-hcd.h | 3 +++
> hw/ppc/spapr.c           | 2 +-
> 3 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/hw/usb/hcd-xhci.h b/hw/usb/hcd-xhci.h
> index f9a3aaceec..b6c54e38a6 100644
> --- a/hw/usb/hcd-xhci.h
> +++ b/hw/usb/hcd-xhci.h
> @@ -23,9 +23,9 @@
> #define HW_USB_HCD_XHCI_H
>
> #include "usb-internal.h"
> +#include "hw/usb/usb-hcd.h"
>
> #define TYPE_XHCI "base-xhci"
> -#define TYPE_NEC_XHCI "nec-usb-xhci"
> #define TYPE_QEMU_XHCI "qemu-xhci"

Why is qemu-xhci left here? Should that be moved to public header too? 
(Maybe no machine adds it but that's a public type too I think.)

Regards.
BALATON Zoltan

> #define XHCI(obj) \
> diff --git a/include/hw/usb/usb-hcd.h b/include/hw/usb/usb-hcd.h
> index c9d0a88984..56107fca62 100644
> --- a/include/hw/usb/usb-hcd.h
> +++ b/include/hw/usb/usb-hcd.h
> @@ -30,4 +30,7 @@
> #define TYPE_VT82C686B_USB_UHCI     "vt82c686b-usb-uhci"
> #define TYPE_ICH9_USB_UHCI(n)       "ich9-usb-uhci" #n
>
> +/* XHCI */
> +#define TYPE_NEC_XHCI "nec-usb-xhci"
> +
> #endif
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index db1706a66c..d8b3978f24 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -2961,7 +2961,7 @@ static void spapr_machine_init(MachineState *machine)
>         if (smc->use_ohci_by_default) {
>             pci_create_simple(phb->bus, -1, TYPE_PCI_OHCI);
>         } else {
> -            pci_create_simple(phb->bus, -1, "nec-usb-xhci");
> +            pci_create_simple(phb->bus, -1, TYPE_NEC_XHCI);
>         }
>
>         if (spapr->has_graphics) {
>

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 25/26] hw/usb/usb-hcd: Use XHCI type definitions
  2020-07-04 17:19   ` BALATON Zoltan
@ 2020-07-04 18:07     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 18:07 UTC (permalink / raw)
  To: BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Jiaxun Yang, Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

On 7/4/20 7:19 PM, BALATON Zoltan wrote:
> On Sat, 4 Jul 2020, Philippe Mathieu-Daudé wrote:
>> Various machine/board/soc models create XHCI device instances
>> with the generic QDEV API, and don't need to access USB internals.
>>
>> Simplify header inclusions by moving the QOM type names into a
>> simple header, with no need to include other "hw/usb" headers.
>>
>> Suggested-by: BALATON Zoltan <balaton@eik.bme.hu>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>> hw/usb/hcd-xhci.h        | 2 +-
>> include/hw/usb/usb-hcd.h | 3 +++
>> hw/ppc/spapr.c           | 2 +-
>> 3 files changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/usb/hcd-xhci.h b/hw/usb/hcd-xhci.h
>> index f9a3aaceec..b6c54e38a6 100644
>> --- a/hw/usb/hcd-xhci.h
>> +++ b/hw/usb/hcd-xhci.h
>> @@ -23,9 +23,9 @@
>> #define HW_USB_HCD_XHCI_H
>>
>> #include "usb-internal.h"
>> +#include "hw/usb/usb-hcd.h"
>>
>> #define TYPE_XHCI "base-xhci"
>> -#define TYPE_NEC_XHCI "nec-usb-xhci"
>> #define TYPE_QEMU_XHCI "qemu-xhci"
> 
> Why is qemu-xhci left here? Should that be moved to public header too?
> (Maybe no machine adds it but that's a public type too I think.)

I don't know because I never used it, but I guess you are right.

> 
> Regards.
> BALATON Zoltan
> 
>> #define XHCI(obj) \
>> diff --git a/include/hw/usb/usb-hcd.h b/include/hw/usb/usb-hcd.h
>> index c9d0a88984..56107fca62 100644
>> --- a/include/hw/usb/usb-hcd.h
>> +++ b/include/hw/usb/usb-hcd.h
>> @@ -30,4 +30,7 @@
>> #define TYPE_VT82C686B_USB_UHCI     "vt82c686b-usb-uhci"
>> #define TYPE_ICH9_USB_UHCI(n)       "ich9-usb-uhci" #n
>>
>> +/* XHCI */
>> +#define TYPE_NEC_XHCI "nec-usb-xhci"
>> +
>> #endif
>> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
>> index db1706a66c..d8b3978f24 100644
>> --- a/hw/ppc/spapr.c
>> +++ b/hw/ppc/spapr.c
>> @@ -2961,7 +2961,7 @@ static void spapr_machine_init(MachineState
>> *machine)
>>         if (smc->use_ohci_by_default) {
>>             pci_create_simple(phb->bus, -1, TYPE_PCI_OHCI);
>>         } else {
>> -            pci_create_simple(phb->bus, -1, "nec-usb-xhci");
>> +            pci_create_simple(phb->bus, -1, TYPE_NEC_XHCI);
>>         }
>>
>>         if (spapr->has_graphics) {
>>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 22/26] hw/usb/usb-hcd: Use OHCI type definitions
  2020-07-04 17:13   ` BALATON Zoltan
@ 2020-07-04 18:09     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 18:09 UTC (permalink / raw)
  To: BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Jiaxun Yang, Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

On 7/4/20 7:13 PM, BALATON Zoltan wrote:
> On Sat, 4 Jul 2020, Philippe Mathieu-Daudé wrote:
>> Various machine/board/soc models create OHCI device instances
>> with the generic QDEV API, and don't need to access USB internals.
>>
>> Simplify header inclusions by moving the QOM type names into a
>> simple header, with no need to include other "hw/usb" headers.
>>
>> Suggested-by: BALATON Zoltan <balaton@eik.bme.hu>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>> hw/usb/hcd-ohci.h        |  2 +-
>> include/hw/usb/usb-hcd.h | 16 ++++++++++++++++
> 
> I wonder if we need a new header for this or these could just go in the
> new public hw/usb/usb.h as machines creating a HCD may also add devices
> (like keyboard/mouse) so probably will need both headers anyway so
> splitting it up may not worth it but I don't really mind, either way.

Hmm the rationale for this choice is: SoC might only instanciate USB HCI
via sysbus/qdev API, without any use of "hw/usb/usb.h". This is the
machine / board that instanciate USB devices and plug them to the HCI on
the SoC.

I can reword better the description.

> 
> For sm501 and sam460ex parts:
> 
> Reviewed-by: BALATON Zoltan <balaton@eik.bme.hu>
> 
> Regards,
> BALATON Zoltan
> 
>> hw/arm/allwinner-a10.c   |  2 +-
>> hw/arm/allwinner-h3.c    |  9 +++++----
>> hw/arm/pxa2xx.c          |  3 ++-
>> hw/arm/realview.c        |  3 ++-
>> hw/arm/versatilepb.c     |  3 ++-
>> hw/display/sm501.c       |  3 ++-
>> hw/ppc/mac_newworld.c    |  3 ++-
>> hw/ppc/mac_oldworld.c    |  3 ++-
>> hw/ppc/sam460ex.c        |  3 ++-
>> hw/ppc/spapr.c           |  3 ++-
>> hw/usb/hcd-ohci-pci.c    |  2 +-
>> 13 files changed, 40 insertions(+), 15 deletions(-)
>> create mode 100644 include/hw/usb/usb-hcd.h
>>
>> diff --git a/hw/usb/hcd-ohci.h b/hw/usb/hcd-ohci.h
>> index 771927ea17..6949cf0dab 100644
>> --- a/hw/usb/hcd-ohci.h
>> +++ b/hw/usb/hcd-ohci.h
>> @@ -21,6 +21,7 @@
>> #ifndef HCD_OHCI_H
>> #define HCD_OHCI_H
>>
>> +#include "hw/usb/usb-hcd.h"
>> #include "sysemu/dma.h"
>> #include "usb-internal.h"
>>
>> @@ -91,7 +92,6 @@ typedef struct OHCIState {
>>     void (*ohci_die)(struct OHCIState *ohci);
>> } OHCIState;
>>
>> -#define TYPE_SYSBUS_OHCI "sysbus-ohci"
>> #define SYSBUS_OHCI(obj) OBJECT_CHECK(OHCISysBusState, (obj),
>> TYPE_SYSBUS_OHCI)
>>
>> typedef struct {
>> diff --git a/include/hw/usb/usb-hcd.h b/include/hw/usb/usb-hcd.h
>> new file mode 100644
>> index 0000000000..21fdfaf22d
>> --- /dev/null
>> +++ b/include/hw/usb/usb-hcd.h
>> @@ -0,0 +1,16 @@
>> +/*
>> + * QEMU USB HCD types
>> + *
>> + * Copyright (c) 2020  Philippe Mathieu-Daudé <f4bug@amsat.org>
>> + *
>> + * SPDX-License-Identifier: GPL-2.0-or-later
>> + */
>> +
>> +#ifndef HW_USB_HCD_TYPES_H
>> +#define HW_USB_HCD_TYPES_H
>> +
>> +/* OHCI */
>> +#define TYPE_SYSBUS_OHCI            "sysbus-ohci"
>> +#define TYPE_PCI_OHCI               "pci-ohci"
>> +
>> +#endif
>> diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
>> index 52e0d83760..53c24ff602 100644
>> --- a/hw/arm/allwinner-a10.c
>> +++ b/hw/arm/allwinner-a10.c
>> @@ -25,7 +25,7 @@
>> #include "hw/misc/unimp.h"
>> #include "sysemu/sysemu.h"
>> #include "hw/boards.h"
>> -#include "hw/usb/hcd-ohci.h"
>> +#include "hw/usb/usb-hcd.h"
>>
>> #define AW_A10_MMC0_BASE        0x01c0f000
>> #define AW_A10_PIC_REG_BASE     0x01c20400
>> diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
>> index 8e09468e86..d1d90ffa79 100644
>> --- a/hw/arm/allwinner-h3.c
>> +++ b/hw/arm/allwinner-h3.c
>> @@ -28,6 +28,7 @@
>> #include "hw/sysbus.h"
>> #include "hw/char/serial.h"
>> #include "hw/misc/unimp.h"
>> +#include "hw/usb/usb-hcd.h"
>> #include "hw/usb/hcd-ehci.h"
>> #include "hw/loader.h"
>> #include "sysemu/sysemu.h"
>> @@ -381,16 +382,16 @@ static void allwinner_h3_realize(DeviceState
>> *dev, Error **errp)
>>                          qdev_get_gpio_in(DEVICE(&s->gic),
>>                                           AW_H3_GIC_SPI_EHCI3));
>>
>> -    sysbus_create_simple("sysbus-ohci", s->memmap[AW_H3_OHCI0],
>> +    sysbus_create_simple(TYPE_SYSBUS_OHCI, s->memmap[AW_H3_OHCI0],
>>                          qdev_get_gpio_in(DEVICE(&s->gic),
>>                                           AW_H3_GIC_SPI_OHCI0));
>> -    sysbus_create_simple("sysbus-ohci", s->memmap[AW_H3_OHCI1],
>> +    sysbus_create_simple(TYPE_SYSBUS_OHCI, s->memmap[AW_H3_OHCI1],
>>                          qdev_get_gpio_in(DEVICE(&s->gic),
>>                                           AW_H3_GIC_SPI_OHCI1));
>> -    sysbus_create_simple("sysbus-ohci", s->memmap[AW_H3_OHCI2],
>> +    sysbus_create_simple(TYPE_SYSBUS_OHCI, s->memmap[AW_H3_OHCI2],
>>                          qdev_get_gpio_in(DEVICE(&s->gic),
>>                                           AW_H3_GIC_SPI_OHCI2));
>> -    sysbus_create_simple("sysbus-ohci", s->memmap[AW_H3_OHCI3],
>> +    sysbus_create_simple(TYPE_SYSBUS_OHCI, s->memmap[AW_H3_OHCI3],
>>                          qdev_get_gpio_in(DEVICE(&s->gic),
>>                                           AW_H3_GIC_SPI_OHCI3));
>>
>> diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
>> index f104a33463..27196170f5 100644
>> --- a/hw/arm/pxa2xx.c
>> +++ b/hw/arm/pxa2xx.c
>> @@ -18,6 +18,7 @@
>> #include "hw/arm/pxa.h"
>> #include "sysemu/sysemu.h"
>> #include "hw/char/serial.h"
>> +#include "hw/usb/usb-hcd.h"
>> #include "hw/i2c/i2c.h"
>> #include "hw/irq.h"
>> #include "hw/qdev-properties.h"
>> @@ -2196,7 +2197,7 @@ PXA2xxState *pxa270_init(MemoryRegion
>> *address_space,
>>         s->ssp[i] = (SSIBus *)qdev_get_child_bus(dev, "ssi");
>>     }
>>
>> -    sysbus_create_simple("sysbus-ohci", 0x4c000000,
>> +    sysbus_create_simple(TYPE_SYSBUS_OHCI, 0x4c000000,
>>                          qdev_get_gpio_in(s->pic, PXA2XX_PIC_USBH1));
>>
>>     s->pcmcia[0] = pxa2xx_pcmcia_init(address_space, 0x20000000);
>> diff --git a/hw/arm/realview.c b/hw/arm/realview.c
>> index b6c0a1adb9..0aa34bd4c2 100644
>> --- a/hw/arm/realview.c
>> +++ b/hw/arm/realview.c
>> @@ -16,6 +16,7 @@
>> #include "hw/net/lan9118.h"
>> #include "hw/net/smc91c111.h"
>> #include "hw/pci/pci.h"
>> +#include "hw/usb/usb-hcd.h"
>> #include "net/net.h"
>> #include "sysemu/sysemu.h"
>> #include "hw/boards.h"
>> @@ -256,7 +257,7 @@ static void realview_init(MachineState *machine,
>>         sysbus_connect_irq(busdev, 3, pic[51]);
>>         pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci");
>>         if (machine_usb(machine)) {
>> -            pci_create_simple(pci_bus, -1, "pci-ohci");
>> +            pci_create_simple(pci_bus, -1, TYPE_PCI_OHCI);
>>         }
>>         n = drive_get_max_bus(IF_SCSI);
>>         while (n >= 0) {
>> diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
>> index e596b8170f..3e6224dc96 100644
>> --- a/hw/arm/versatilepb.c
>> +++ b/hw/arm/versatilepb.c
>> @@ -17,6 +17,7 @@
>> #include "net/net.h"
>> #include "sysemu/sysemu.h"
>> #include "hw/pci/pci.h"
>> +#include "hw/usb/usb-hcd.h"
>> #include "hw/i2c/i2c.h"
>> #include "hw/i2c/arm_sbcon_i2c.h"
>> #include "hw/irq.h"
>> @@ -273,7 +274,7 @@ static void versatile_init(MachineState *machine,
>> int board_id)
>>         }
>>     }
>>     if (machine_usb(machine)) {
>> -        pci_create_simple(pci_bus, -1, "pci-ohci");
>> +        pci_create_simple(pci_bus, -1, TYPE_PCI_OHCI);
>>     }
>>     n = drive_get_max_bus(IF_SCSI);
>>     while (n >= 0) {
>> diff --git a/hw/display/sm501.c b/hw/display/sm501.c
>> index 9cccc68c35..5f076c841f 100644
>> --- a/hw/display/sm501.c
>> +++ b/hw/display/sm501.c
>> @@ -33,6 +33,7 @@
>> #include "hw/sysbus.h"
>> #include "migration/vmstate.h"
>> #include "hw/pci/pci.h"
>> +#include "hw/usb/usb-hcd.h"
>> #include "hw/qdev-properties.h"
>> #include "hw/i2c/i2c.h"
>> #include "hw/display/i2c-ddc.h"
>> @@ -1961,7 +1962,7 @@ static void sm501_realize_sysbus(DeviceState
>> *dev, Error **errp)
>>     sysbus_init_mmio(sbd, &s->state.mmio_region);
>>
>>     /* bridge to usb host emulation module */
>> -    usb_dev = qdev_new("sysbus-ohci");
>> +    usb_dev = qdev_new(TYPE_SYSBUS_OHCI);
>>     qdev_prop_set_uint32(usb_dev, "num-ports", 2);
>>     qdev_prop_set_uint64(usb_dev, "dma-offset", s->base);
>>     sysbus_realize_and_unref(SYS_BUS_DEVICE(usb_dev), &error_fatal);
>> diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
>> index 7bf69f4a1f..3c32c1831b 100644
>> --- a/hw/ppc/mac_newworld.c
>> +++ b/hw/ppc/mac_newworld.c
>> @@ -55,6 +55,7 @@
>> #include "hw/input/adb.h"
>> #include "hw/ppc/mac_dbdma.h"
>> #include "hw/pci/pci.h"
>> +#include "hw/usb/usb-hcd.h"
>> #include "net/net.h"
>> #include "sysemu/sysemu.h"
>> #include "hw/boards.h"
>> @@ -411,7 +412,7 @@ static void ppc_core99_init(MachineState *machine)
>>     }
>>
>>     if (machine->usb) {
>> -        pci_create_simple(pci_bus, -1, "pci-ohci");
>> +        pci_create_simple(pci_bus, -1, TYPE_PCI_OHCI);
>>
>>         /* U3 needs to use USB for input because Linux doesn't support
>> via-cuda
>>         on PPC64 */
>> diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
>> index f8c204ead7..a429a3e1df 100644
>> --- a/hw/ppc/mac_oldworld.c
>> +++ b/hw/ppc/mac_oldworld.c
>> @@ -37,6 +37,7 @@
>> #include "hw/isa/isa.h"
>> #include "hw/pci/pci.h"
>> #include "hw/pci/pci_host.h"
>> +#include "hw/usb/usb-hcd.h"
>> #include "hw/boards.h"
>> #include "hw/nvram/fw_cfg.h"
>> #include "hw/char/escc.h"
>> @@ -301,7 +302,7 @@ static void ppc_heathrow_init(MachineState *machine)
>>     qdev_realize_and_unref(dev, adb_bus, &error_fatal);
>>
>>     if (machine_usb(machine)) {
>> -        pci_create_simple(pci_bus, -1, "pci-ohci");
>> +        pci_create_simple(pci_bus, -1, TYPE_PCI_OHCI);
>>     }
>>
>>     if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
>> diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
>> index 781b45e14b..ac60d17a86 100644
>> --- a/hw/ppc/sam460ex.c
>> +++ b/hw/ppc/sam460ex.c
>> @@ -36,6 +36,7 @@
>> #include "hw/i2c/ppc4xx_i2c.h"
>> #include "hw/i2c/smbus_eeprom.h"
>> #include "hw/usb/usb.h"
>> +#include "hw/usb/usb-hcd.h"
>> #include "hw/usb/hcd-ehci.h"
>> #include "hw/ppc/fdt.h"
>> #include "hw/qdev-properties.h"
>> @@ -372,7 +373,7 @@ static void sam460ex_init(MachineState *machine)
>>
>>     /* USB */
>>     sysbus_create_simple(TYPE_PPC4xx_EHCI, 0x4bffd0400, uic[2][29]);
>> -    dev = qdev_new("sysbus-ohci");
>> +    dev = qdev_new(TYPE_SYSBUS_OHCI);
>>     qdev_prop_set_string(dev, "masterbus", "usb-bus.0");
>>     qdev_prop_set_uint32(dev, "num-ports", 6);
>>     sbdev = SYS_BUS_DEVICE(dev);
>> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
>> index 0c0409077f..db1706a66c 100644
>> --- a/hw/ppc/spapr.c
>> +++ b/hw/ppc/spapr.c
>> @@ -71,6 +71,7 @@
>> #include "exec/address-spaces.h"
>> #include "exec/ram_addr.h"
>> #include "hw/usb/usb.h"
>> +#include "hw/usb/usb-hcd.h"
>> #include "qemu/config-file.h"
>> #include "qemu/error-report.h"
>> #include "trace.h"
>> @@ -2958,7 +2959,7 @@ static void spapr_machine_init(MachineState
>> *machine)
>>
>>     if (machine->usb) {
>>         if (smc->use_ohci_by_default) {
>> -            pci_create_simple(phb->bus, -1, "pci-ohci");
>> +            pci_create_simple(phb->bus, -1, TYPE_PCI_OHCI);
>>         } else {
>>             pci_create_simple(phb->bus, -1, "nec-usb-xhci");
>>         }
>> diff --git a/hw/usb/hcd-ohci-pci.c b/hw/usb/hcd-ohci-pci.c
>> index cb6bc55f59..14df83ec2e 100644
>> --- a/hw/usb/hcd-ohci-pci.c
>> +++ b/hw/usb/hcd-ohci-pci.c
>> @@ -29,8 +29,8 @@
>> #include "trace.h"
>> #include "hcd-ohci.h"
>> #include "usb-internal.h"
>> +#include "hw/usb/usb-hcd.h"
>>
>> -#define TYPE_PCI_OHCI "pci-ohci"
>> #define PCI_OHCI(obj) OBJECT_CHECK(OHCIPCIState, (obj), TYPE_PCI_OHCI)
>>
>> typedef struct {
>>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 24/26] hw/usb/usb-hcd: Use UHCI type definitions
  2020-07-04 17:17   ` BALATON Zoltan
@ 2020-07-04 18:12     ` Philippe Mathieu-Daudé
  2020-07-04 19:44       ` BALATON Zoltan
  0 siblings, 1 reply; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 18:12 UTC (permalink / raw)
  To: BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Jiaxun Yang, Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Eric Blake, Stefano Stabellini, xen-devel, Yoshinori Sato,
	Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Marcel Apfelbaum, Anthony Perard,
	Samuel Thibault, Leif Lindholm, Andrzej Zaborowski,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani, Niek Linnenbank,
	qemu-arm, Marc-André Lureau, Richard Henderson,
	Radoslaw Biernacki, Igor Mitsyanko, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

On 7/4/20 7:17 PM, BALATON Zoltan wrote:
> On Sat, 4 Jul 2020, Philippe Mathieu-Daudé wrote:
>> Various machine/board/soc models create UHCI device instances
>> with the generic QDEV API, and don't need to access USB internals.
>>
>> Simplify header inclusions by moving the QOM type names into a
>> simple header, with no need to include other "hw/usb" headers.
>>
>> Suggested-by: BALATON Zoltan <balaton@eik.bme.hu>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>> include/hw/usb/usb-hcd.h |  6 ++++++
>> hw/i386/pc_piix.c        |  3 ++-
>> hw/i386/pc_q35.c         | 13 +++++++------
>> hw/isa/piix4.c           |  3 ++-
>> hw/mips/fuloong2e.c      |  5 +++--
>> hw/usb/hcd-uhci.c        | 19 ++++++++++---------
>> 6 files changed, 30 insertions(+), 19 deletions(-)
>>
>> diff --git a/include/hw/usb/usb-hcd.h b/include/hw/usb/usb-hcd.h
>> index 74af3a4533..c9d0a88984 100644
>> --- a/include/hw/usb/usb-hcd.h
>> +++ b/include/hw/usb/usb-hcd.h
>> @@ -24,4 +24,10 @@
>> #define TYPE_FUSBH200_EHCI          "fusbh200-ehci-usb"
>> #define TYPE_CHIPIDEA               "usb-chipidea"
>>
>> +/* UHCI */
>> +#define TYPE_PIIX3_USB_UHCI         "piix3-usb-uhci"
>> +#define TYPE_PIIX4_USB_UHCI         "piix4-usb-uhci"
>> +#define TYPE_VT82C686B_USB_UHCI     "vt82c686b-usb-uhci"
>> +#define TYPE_ICH9_USB_UHCI(n)       "ich9-usb-uhci" #n
> 
> What is that #n at the end? Looks like a typo. Does it break compilation?

#n is a C preprocessor feature that expand the 'n' argument to a "n"
string, so:

TYPE_ICH9_USB_UHCI(1) = "ich9-usb-uhci" #1
                      = "ich9-usb-uhci" "1"
                      = "ich9-usb-uhci1"

I'm pretty sure we use that elsewhere. If not, I can add a definition
for each 1 ... 6 typenames.

> 
> Regards,
> BALATON Zoltan
> 
>> +
>> #endif
>> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
>> index 4d1de7cfab..0024c346c6 100644
>> --- a/hw/i386/pc_piix.c
>> +++ b/hw/i386/pc_piix.c
>> @@ -37,6 +37,7 @@
>> #include "hw/pci/pci.h"
>> #include "hw/pci/pci_ids.h"
>> #include "hw/usb/usb.h"
>> +#include "hw/usb/usb-hcd.h"
>> #include "net/net.h"
>> #include "hw/ide/pci.h"
>> #include "hw/irq.h"
>> @@ -275,7 +276,7 @@ static void pc_init1(MachineState *machine,
>> #endif
>>
>>     if (pcmc->pci_enabled && machine_usb(machine)) {
>> -        pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
>> +        pci_create_simple(pci_bus, piix3_devfn + 2,
>> TYPE_PIIX3_USB_UHCI);
>>     }
>>
>>     if (pcmc->pci_enabled &&
>> x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) {
>> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
>> index b985f5bea1..a80527e6ed 100644
>> --- a/hw/i386/pc_q35.c
>> +++ b/hw/i386/pc_q35.c
>> @@ -51,6 +51,7 @@
>> #include "hw/ide/pci.h"
>> #include "hw/ide/ahci.h"
>> #include "hw/usb/usb.h"
>> +#include "hw/usb/usb-hcd.h"
>> #include "qapi/error.h"
>> #include "qemu/error-report.h"
>> #include "sysemu/numa.h"
>> @@ -68,15 +69,15 @@ struct ehci_companions {
>> };
>>
>> static const struct ehci_companions ich9_1d[] = {
>> -    { .name = "ich9-usb-uhci1", .func = 0, .port = 0 },
>> -    { .name = "ich9-usb-uhci2", .func = 1, .port = 2 },
>> -    { .name = "ich9-usb-uhci3", .func = 2, .port = 4 },
>> +    { .name = TYPE_ICH9_USB_UHCI(1), .func = 0, .port = 0 },
>> +    { .name = TYPE_ICH9_USB_UHCI(2), .func = 1, .port = 2 },
>> +    { .name = TYPE_ICH9_USB_UHCI(3), .func = 2, .port = 4 },
>> };
>>
>> static const struct ehci_companions ich9_1a[] = {
>> -    { .name = "ich9-usb-uhci4", .func = 0, .port = 0 },
>> -    { .name = "ich9-usb-uhci5", .func = 1, .port = 2 },
>> -    { .name = "ich9-usb-uhci6", .func = 2, .port = 4 },
>> +    { .name = TYPE_ICH9_USB_UHCI(4), .func = 0, .port = 0 },
>> +    { .name = TYPE_ICH9_USB_UHCI(5), .func = 1, .port = 2 },
>> +    { .name = TYPE_ICH9_USB_UHCI(6), .func = 2, .port = 4 },
>> };
>>
>> static int ehci_create_ich9_with_companions(PCIBus *bus, int slot)
>> diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
>> index f634bcb2d1..e11e5fae21 100644
>> --- a/hw/isa/piix4.c
>> +++ b/hw/isa/piix4.c
>> @@ -29,6 +29,7 @@
>> #include "hw/southbridge/piix.h"
>> #include "hw/pci/pci.h"
>> #include "hw/isa/isa.h"
>> +#include "hw/usb/usb-hcd.h"
>> #include "hw/sysbus.h"
>> #include "hw/intc/i8259.h"
>> #include "hw/dma/i8257.h"
>> @@ -255,7 +256,7 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus
>> **isa_bus, I2CBus **smbus)
>>     pci = pci_create_simple(pci_bus, devfn + 1, "piix4-ide");
>>     pci_ide_create_devs(pci);
>>
>> -    pci_create_simple(pci_bus, devfn + 2, "piix4-usb-uhci");
>> +    pci_create_simple(pci_bus, devfn + 2, TYPE_PIIX4_USB_UHCI);
>>     if (smbus) {
>>         *smbus = piix4_pm_init(pci_bus, devfn + 3, 0x1100,
>>                                isa_get_irq(NULL, 9), NULL, 0, NULL);
>> diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c
>> index 8ca31e5162..b6d33dd2cd 100644
>> --- a/hw/mips/fuloong2e.c
>> +++ b/hw/mips/fuloong2e.c
>> @@ -33,6 +33,7 @@
>> #include "hw/mips/mips.h"
>> #include "hw/mips/cpudevs.h"
>> #include "hw/pci/pci.h"
>> +#include "hw/usb/usb-hcd.h"
>> #include "qemu/log.h"
>> #include "hw/loader.h"
>> #include "hw/ide/pci.h"
>> @@ -258,8 +259,8 @@ static void vt82c686b_southbridge_init(PCIBus
>> *pci_bus, int slot, qemu_irq intc,
>>     dev = pci_create_simple(pci_bus, PCI_DEVFN(slot, 1), "via-ide");
>>     pci_ide_create_devs(dev);
>>
>> -    pci_create_simple(pci_bus, PCI_DEVFN(slot, 2),
>> "vt82c686b-usb-uhci");
>> -    pci_create_simple(pci_bus, PCI_DEVFN(slot, 3),
>> "vt82c686b-usb-uhci");
>> +    pci_create_simple(pci_bus, PCI_DEVFN(slot, 2),
>> TYPE_VT82C686B_USB_UHCI);
>> +    pci_create_simple(pci_bus, PCI_DEVFN(slot, 3),
>> TYPE_VT82C686B_USB_UHCI);
>>
>>     *i2c_bus = vt82c686b_pm_init(pci_bus, PCI_DEVFN(slot, 4), 0xeee1,
>> NULL);
>>
>> diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
>> index 1d4dd33b6c..da078dc3fa 100644
>> --- a/hw/usb/hcd-uhci.c
>> +++ b/hw/usb/hcd-uhci.c
>> @@ -39,6 +39,7 @@
>> #include "qemu/main-loop.h"
>> #include "qemu/module.h"
>> #include "usb-internal.h"
>> +#include "hw/usb/usb-hcd.h"
>>
>> #define FRAME_TIMER_FREQ 1000
>>
>> @@ -1358,21 +1359,21 @@ static void uhci_data_class_init(ObjectClass
>> *klass, void *data)
>>
>> static UHCIInfo uhci_info[] = {
>>     {
>> -        .name       = "piix3-usb-uhci",
>> +        .name      = TYPE_PIIX3_USB_UHCI,
>>         .vendor_id = PCI_VENDOR_ID_INTEL,
>>         .device_id = PCI_DEVICE_ID_INTEL_82371SB_2,
>>         .revision  = 0x01,
>>         .irq_pin   = 3,
>>         .unplug    = true,
>>     },{
>> -        .name      = "piix4-usb-uhci",
>> +        .name      = TYPE_PIIX4_USB_UHCI,
>>         .vendor_id = PCI_VENDOR_ID_INTEL,
>>         .device_id = PCI_DEVICE_ID_INTEL_82371AB_2,
>>         .revision  = 0x01,
>>         .irq_pin   = 3,
>>         .unplug    = true,
>>     },{
>> -        .name      = "vt82c686b-usb-uhci",
>> +        .name      = TYPE_VT82C686B_USB_UHCI,
>>         .vendor_id = PCI_VENDOR_ID_VIA,
>>         .device_id = PCI_DEVICE_ID_VIA_UHCI,
>>         .revision  = 0x01,
>> @@ -1380,42 +1381,42 @@ static UHCIInfo uhci_info[] = {
>>         .realize   = usb_uhci_vt82c686b_realize,
>>         .unplug    = true,
>>     },{
>> -        .name      = "ich9-usb-uhci1", /* 00:1d.0 */
>> +        .name      = TYPE_ICH9_USB_UHCI(1), /* 00:1d.0 */
>>         .vendor_id = PCI_VENDOR_ID_INTEL,
>>         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI1,
>>         .revision  = 0x03,
>>         .irq_pin   = 0,
>>         .unplug    = false,
>>     },{
>> -        .name      = "ich9-usb-uhci2", /* 00:1d.1 */
>> +        .name      = TYPE_ICH9_USB_UHCI(2), /* 00:1d.1 */
>>         .vendor_id = PCI_VENDOR_ID_INTEL,
>>         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI2,
>>         .revision  = 0x03,
>>         .irq_pin   = 1,
>>         .unplug    = false,
>>     },{
>> -        .name      = "ich9-usb-uhci3", /* 00:1d.2 */
>> +        .name      = TYPE_ICH9_USB_UHCI(3), /* 00:1d.2 */
>>         .vendor_id = PCI_VENDOR_ID_INTEL,
>>         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI3,
>>         .revision  = 0x03,
>>         .irq_pin   = 2,
>>         .unplug    = false,
>>     },{
>> -        .name      = "ich9-usb-uhci4", /* 00:1a.0 */
>> +        .name      = TYPE_ICH9_USB_UHCI(4), /* 00:1a.0 */
>>         .vendor_id = PCI_VENDOR_ID_INTEL,
>>         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI4,
>>         .revision  = 0x03,
>>         .irq_pin   = 0,
>>         .unplug    = false,
>>     },{
>> -        .name      = "ich9-usb-uhci5", /* 00:1a.1 */
>> +        .name      = TYPE_ICH9_USB_UHCI(5), /* 00:1a.1 */
>>         .vendor_id = PCI_VENDOR_ID_INTEL,
>>         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI5,
>>         .revision  = 0x03,
>>         .irq_pin   = 1,
>>         .unplug    = false,
>>     },{
>> -        .name      = "ich9-usb-uhci6", /* 00:1a.2 */
>> +        .name      = TYPE_ICH9_USB_UHCI(6), /* 00:1a.2 */
>>         .vendor_id = PCI_VENDOR_ID_INTEL,
>>         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI6,
>>         .revision  = 0x03,
>>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 24/26] hw/usb/usb-hcd: Use UHCI type definitions
  2020-07-04 18:12     ` Philippe Mathieu-Daudé
@ 2020-07-04 19:44       ` BALATON Zoltan
  2020-07-04 19:49         ` Philippe Mathieu-Daudé
  2020-07-05  5:37         ` Paolo Bonzini
  0 siblings, 2 replies; 63+ messages in thread
From: BALATON Zoltan @ 2020-07-04 19:44 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, qemu-devel, Jiaxun Yang,
	Gerd Hoffmann, Huacai Chen, Eric Blake, Stefano Stabellini,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Marcel Apfelbaum, Anthony Perard,
	Samuel Thibault, Leif Lindholm, Andrzej Zaborowski,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani,
	Marc-André Lureau, Niek Linnenbank, qemu-arm, xen-devel,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 10667 bytes --]

On Sat, 4 Jul 2020, Philippe Mathieu-Daudé wrote:
> On 7/4/20 7:17 PM, BALATON Zoltan wrote:
>> On Sat, 4 Jul 2020, Philippe Mathieu-Daudé wrote:
>>> Various machine/board/soc models create UHCI device instances
>>> with the generic QDEV API, and don't need to access USB internals.
>>>
>>> Simplify header inclusions by moving the QOM type names into a
>>> simple header, with no need to include other "hw/usb" headers.
>>>
>>> Suggested-by: BALATON Zoltan <balaton@eik.bme.hu>
>>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>>> ---
>>> include/hw/usb/usb-hcd.h |  6 ++++++
>>> hw/i386/pc_piix.c        |  3 ++-
>>> hw/i386/pc_q35.c         | 13 +++++++------
>>> hw/isa/piix4.c           |  3 ++-
>>> hw/mips/fuloong2e.c      |  5 +++--
>>> hw/usb/hcd-uhci.c        | 19 ++++++++++---------
>>> 6 files changed, 30 insertions(+), 19 deletions(-)
>>>
>>> diff --git a/include/hw/usb/usb-hcd.h b/include/hw/usb/usb-hcd.h
>>> index 74af3a4533..c9d0a88984 100644
>>> --- a/include/hw/usb/usb-hcd.h
>>> +++ b/include/hw/usb/usb-hcd.h
>>> @@ -24,4 +24,10 @@
>>> #define TYPE_FUSBH200_EHCI          "fusbh200-ehci-usb"
>>> #define TYPE_CHIPIDEA               "usb-chipidea"
>>>
>>> +/* UHCI */
>>> +#define TYPE_PIIX3_USB_UHCI         "piix3-usb-uhci"
>>> +#define TYPE_PIIX4_USB_UHCI         "piix4-usb-uhci"
>>> +#define TYPE_VT82C686B_USB_UHCI     "vt82c686b-usb-uhci"
>>> +#define TYPE_ICH9_USB_UHCI(n)       "ich9-usb-uhci" #n
>>
>> What is that #n at the end? Looks like a typo. Does it break compilation?
>
> #n is a C preprocessor feature that expand the 'n' argument to a "n"
> string, so:
>
> TYPE_ICH9_USB_UHCI(1) = "ich9-usb-uhci" #1
>                      = "ich9-usb-uhci" "1"
>                      = "ich9-usb-uhci1"
>
> I'm pretty sure we use that elsewhere. If not, I can add a definition
> for each 1 ... 6 typenames.

No it's OK, no need to list all defines. I just did not notice the macro 
argument that's why I was wondering where it comes from. This seems to be 
used elsewhere at least here:

hw/audio/es1370.c:#define a(n) if (val & CTRL_##n) strcat (buf, " "#n)
hw/audio/es1370.c:#define a(n) if (val & SCTRL_##n) strcat (buf, " "#n)
hw/audio/es1370.c:#define b(n) if (!(val & SCTRL_##n)) strcat (buf, " "#n)

Maybe writing it without the space between "# is clearer as then it looks 
more like it's part of the value.

Regards,
BALATON Zoltan

>>> +
>>> #endif
>>> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
>>> index 4d1de7cfab..0024c346c6 100644
>>> --- a/hw/i386/pc_piix.c
>>> +++ b/hw/i386/pc_piix.c
>>> @@ -37,6 +37,7 @@
>>> #include "hw/pci/pci.h"
>>> #include "hw/pci/pci_ids.h"
>>> #include "hw/usb/usb.h"
>>> +#include "hw/usb/usb-hcd.h"
>>> #include "net/net.h"
>>> #include "hw/ide/pci.h"
>>> #include "hw/irq.h"
>>> @@ -275,7 +276,7 @@ static void pc_init1(MachineState *machine,
>>> #endif
>>>
>>>     if (pcmc->pci_enabled && machine_usb(machine)) {
>>> -        pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
>>> +        pci_create_simple(pci_bus, piix3_devfn + 2,
>>> TYPE_PIIX3_USB_UHCI);
>>>     }
>>>
>>>     if (pcmc->pci_enabled &&
>>> x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) {
>>> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
>>> index b985f5bea1..a80527e6ed 100644
>>> --- a/hw/i386/pc_q35.c
>>> +++ b/hw/i386/pc_q35.c
>>> @@ -51,6 +51,7 @@
>>> #include "hw/ide/pci.h"
>>> #include "hw/ide/ahci.h"
>>> #include "hw/usb/usb.h"
>>> +#include "hw/usb/usb-hcd.h"
>>> #include "qapi/error.h"
>>> #include "qemu/error-report.h"
>>> #include "sysemu/numa.h"
>>> @@ -68,15 +69,15 @@ struct ehci_companions {
>>> };
>>>
>>> static const struct ehci_companions ich9_1d[] = {
>>> -    { .name = "ich9-usb-uhci1", .func = 0, .port = 0 },
>>> -    { .name = "ich9-usb-uhci2", .func = 1, .port = 2 },
>>> -    { .name = "ich9-usb-uhci3", .func = 2, .port = 4 },
>>> +    { .name = TYPE_ICH9_USB_UHCI(1), .func = 0, .port = 0 },
>>> +    { .name = TYPE_ICH9_USB_UHCI(2), .func = 1, .port = 2 },
>>> +    { .name = TYPE_ICH9_USB_UHCI(3), .func = 2, .port = 4 },
>>> };
>>>
>>> static const struct ehci_companions ich9_1a[] = {
>>> -    { .name = "ich9-usb-uhci4", .func = 0, .port = 0 },
>>> -    { .name = "ich9-usb-uhci5", .func = 1, .port = 2 },
>>> -    { .name = "ich9-usb-uhci6", .func = 2, .port = 4 },
>>> +    { .name = TYPE_ICH9_USB_UHCI(4), .func = 0, .port = 0 },
>>> +    { .name = TYPE_ICH9_USB_UHCI(5), .func = 1, .port = 2 },
>>> +    { .name = TYPE_ICH9_USB_UHCI(6), .func = 2, .port = 4 },
>>> };
>>>
>>> static int ehci_create_ich9_with_companions(PCIBus *bus, int slot)
>>> diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
>>> index f634bcb2d1..e11e5fae21 100644
>>> --- a/hw/isa/piix4.c
>>> +++ b/hw/isa/piix4.c
>>> @@ -29,6 +29,7 @@
>>> #include "hw/southbridge/piix.h"
>>> #include "hw/pci/pci.h"
>>> #include "hw/isa/isa.h"
>>> +#include "hw/usb/usb-hcd.h"
>>> #include "hw/sysbus.h"
>>> #include "hw/intc/i8259.h"
>>> #include "hw/dma/i8257.h"
>>> @@ -255,7 +256,7 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus
>>> **isa_bus, I2CBus **smbus)
>>>     pci = pci_create_simple(pci_bus, devfn + 1, "piix4-ide");
>>>     pci_ide_create_devs(pci);
>>>
>>> -    pci_create_simple(pci_bus, devfn + 2, "piix4-usb-uhci");
>>> +    pci_create_simple(pci_bus, devfn + 2, TYPE_PIIX4_USB_UHCI);
>>>     if (smbus) {
>>>         *smbus = piix4_pm_init(pci_bus, devfn + 3, 0x1100,
>>>                                isa_get_irq(NULL, 9), NULL, 0, NULL);
>>> diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c
>>> index 8ca31e5162..b6d33dd2cd 100644
>>> --- a/hw/mips/fuloong2e.c
>>> +++ b/hw/mips/fuloong2e.c
>>> @@ -33,6 +33,7 @@
>>> #include "hw/mips/mips.h"
>>> #include "hw/mips/cpudevs.h"
>>> #include "hw/pci/pci.h"
>>> +#include "hw/usb/usb-hcd.h"
>>> #include "qemu/log.h"
>>> #include "hw/loader.h"
>>> #include "hw/ide/pci.h"
>>> @@ -258,8 +259,8 @@ static void vt82c686b_southbridge_init(PCIBus
>>> *pci_bus, int slot, qemu_irq intc,
>>>     dev = pci_create_simple(pci_bus, PCI_DEVFN(slot, 1), "via-ide");
>>>     pci_ide_create_devs(dev);
>>>
>>> -    pci_create_simple(pci_bus, PCI_DEVFN(slot, 2),
>>> "vt82c686b-usb-uhci");
>>> -    pci_create_simple(pci_bus, PCI_DEVFN(slot, 3),
>>> "vt82c686b-usb-uhci");
>>> +    pci_create_simple(pci_bus, PCI_DEVFN(slot, 2),
>>> TYPE_VT82C686B_USB_UHCI);
>>> +    pci_create_simple(pci_bus, PCI_DEVFN(slot, 3),
>>> TYPE_VT82C686B_USB_UHCI);
>>>
>>>     *i2c_bus = vt82c686b_pm_init(pci_bus, PCI_DEVFN(slot, 4), 0xeee1,
>>> NULL);
>>>
>>> diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
>>> index 1d4dd33b6c..da078dc3fa 100644
>>> --- a/hw/usb/hcd-uhci.c
>>> +++ b/hw/usb/hcd-uhci.c
>>> @@ -39,6 +39,7 @@
>>> #include "qemu/main-loop.h"
>>> #include "qemu/module.h"
>>> #include "usb-internal.h"
>>> +#include "hw/usb/usb-hcd.h"
>>>
>>> #define FRAME_TIMER_FREQ 1000
>>>
>>> @@ -1358,21 +1359,21 @@ static void uhci_data_class_init(ObjectClass
>>> *klass, void *data)
>>>
>>> static UHCIInfo uhci_info[] = {
>>>     {
>>> -        .name       = "piix3-usb-uhci",
>>> +        .name      = TYPE_PIIX3_USB_UHCI,
>>>         .vendor_id = PCI_VENDOR_ID_INTEL,
>>>         .device_id = PCI_DEVICE_ID_INTEL_82371SB_2,
>>>         .revision  = 0x01,
>>>         .irq_pin   = 3,
>>>         .unplug    = true,
>>>     },{
>>> -        .name      = "piix4-usb-uhci",
>>> +        .name      = TYPE_PIIX4_USB_UHCI,
>>>         .vendor_id = PCI_VENDOR_ID_INTEL,
>>>         .device_id = PCI_DEVICE_ID_INTEL_82371AB_2,
>>>         .revision  = 0x01,
>>>         .irq_pin   = 3,
>>>         .unplug    = true,
>>>     },{
>>> -        .name      = "vt82c686b-usb-uhci",
>>> +        .name      = TYPE_VT82C686B_USB_UHCI,
>>>         .vendor_id = PCI_VENDOR_ID_VIA,
>>>         .device_id = PCI_DEVICE_ID_VIA_UHCI,
>>>         .revision  = 0x01,
>>> @@ -1380,42 +1381,42 @@ static UHCIInfo uhci_info[] = {
>>>         .realize   = usb_uhci_vt82c686b_realize,
>>>         .unplug    = true,
>>>     },{
>>> -        .name      = "ich9-usb-uhci1", /* 00:1d.0 */
>>> +        .name      = TYPE_ICH9_USB_UHCI(1), /* 00:1d.0 */
>>>         .vendor_id = PCI_VENDOR_ID_INTEL,
>>>         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI1,
>>>         .revision  = 0x03,
>>>         .irq_pin   = 0,
>>>         .unplug    = false,
>>>     },{
>>> -        .name      = "ich9-usb-uhci2", /* 00:1d.1 */
>>> +        .name      = TYPE_ICH9_USB_UHCI(2), /* 00:1d.1 */
>>>         .vendor_id = PCI_VENDOR_ID_INTEL,
>>>         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI2,
>>>         .revision  = 0x03,
>>>         .irq_pin   = 1,
>>>         .unplug    = false,
>>>     },{
>>> -        .name      = "ich9-usb-uhci3", /* 00:1d.2 */
>>> +        .name      = TYPE_ICH9_USB_UHCI(3), /* 00:1d.2 */
>>>         .vendor_id = PCI_VENDOR_ID_INTEL,
>>>         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI3,
>>>         .revision  = 0x03,
>>>         .irq_pin   = 2,
>>>         .unplug    = false,
>>>     },{
>>> -        .name      = "ich9-usb-uhci4", /* 00:1a.0 */
>>> +        .name      = TYPE_ICH9_USB_UHCI(4), /* 00:1a.0 */
>>>         .vendor_id = PCI_VENDOR_ID_INTEL,
>>>         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI4,
>>>         .revision  = 0x03,
>>>         .irq_pin   = 0,
>>>         .unplug    = false,
>>>     },{
>>> -        .name      = "ich9-usb-uhci5", /* 00:1a.1 */
>>> +        .name      = TYPE_ICH9_USB_UHCI(5), /* 00:1a.1 */
>>>         .vendor_id = PCI_VENDOR_ID_INTEL,
>>>         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI5,
>>>         .revision  = 0x03,
>>>         .irq_pin   = 1,
>>>         .unplug    = false,
>>>     },{
>>> -        .name      = "ich9-usb-uhci6", /* 00:1a.2 */
>>> +        .name      = TYPE_ICH9_USB_UHCI(6), /* 00:1a.2 */
>>>         .vendor_id = PCI_VENDOR_ID_INTEL,
>>>         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI6,
>>>         .revision  = 0x03,
>>>
>
>

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 24/26] hw/usb/usb-hcd: Use UHCI type definitions
  2020-07-04 19:44       ` BALATON Zoltan
@ 2020-07-04 19:49         ` Philippe Mathieu-Daudé
  2020-07-05  5:37         ` Paolo Bonzini
  1 sibling, 0 replies; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-04 19:49 UTC (permalink / raw)
  To: BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, qemu-devel, Jiaxun Yang,
	Gerd Hoffmann, Huacai Chen, Eric Blake, Stefano Stabellini,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Marcel Apfelbaum, Anthony Perard,
	Samuel Thibault, Leif Lindholm, Andrzej Zaborowski,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani,
	Marc-André Lureau, Niek Linnenbank, qemu-arm, xen-devel,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

On 7/4/20 9:44 PM, BALATON Zoltan wrote:
> On Sat, 4 Jul 2020, Philippe Mathieu-Daudé wrote:
>> On 7/4/20 7:17 PM, BALATON Zoltan wrote:
>>> On Sat, 4 Jul 2020, Philippe Mathieu-Daudé wrote:
>>>> Various machine/board/soc models create UHCI device instances
>>>> with the generic QDEV API, and don't need to access USB internals.
>>>>
>>>> Simplify header inclusions by moving the QOM type names into a
>>>> simple header, with no need to include other "hw/usb" headers.
>>>>
>>>> Suggested-by: BALATON Zoltan <balaton@eik.bme.hu>
>>>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>>>> ---
>>>> include/hw/usb/usb-hcd.h |  6 ++++++
>>>> hw/i386/pc_piix.c        |  3 ++-
>>>> hw/i386/pc_q35.c         | 13 +++++++------
>>>> hw/isa/piix4.c           |  3 ++-
>>>> hw/mips/fuloong2e.c      |  5 +++--
>>>> hw/usb/hcd-uhci.c        | 19 ++++++++++---------
>>>> 6 files changed, 30 insertions(+), 19 deletions(-)
>>>>
>>>> diff --git a/include/hw/usb/usb-hcd.h b/include/hw/usb/usb-hcd.h
>>>> index 74af3a4533..c9d0a88984 100644
>>>> --- a/include/hw/usb/usb-hcd.h
>>>> +++ b/include/hw/usb/usb-hcd.h
>>>> @@ -24,4 +24,10 @@
>>>> #define TYPE_FUSBH200_EHCI          "fusbh200-ehci-usb"
>>>> #define TYPE_CHIPIDEA               "usb-chipidea"
>>>>
>>>> +/* UHCI */
>>>> +#define TYPE_PIIX3_USB_UHCI         "piix3-usb-uhci"
>>>> +#define TYPE_PIIX4_USB_UHCI         "piix4-usb-uhci"
>>>> +#define TYPE_VT82C686B_USB_UHCI     "vt82c686b-usb-uhci"
>>>> +#define TYPE_ICH9_USB_UHCI(n)       "ich9-usb-uhci" #n
>>>
>>> What is that #n at the end? Looks like a typo. Does it break
>>> compilation?
>>
>> #n is a C preprocessor feature that expand the 'n' argument to a "n"
>> string, so:
>>
>> TYPE_ICH9_USB_UHCI(1) = "ich9-usb-uhci" #1
>>                      = "ich9-usb-uhci" "1"
>>                      = "ich9-usb-uhci1"
>>
>> I'm pretty sure we use that elsewhere. If not, I can add a definition
>> for each 1 ... 6 typenames.
> 
> No it's OK, no need to list all defines. I just did not notice the macro
> argument that's why I was wondering where it comes from. This seems to
> be used elsewhere at least here:
> 
> hw/audio/es1370.c:#define a(n) if (val & CTRL_##n) strcat (buf, " "#n)
> hw/audio/es1370.c:#define a(n) if (val & SCTRL_##n) strcat (buf, " "#n)
> hw/audio/es1370.c:#define b(n) if (!(val & SCTRL_##n)) strcat (buf, " "#n)
> 
> Maybe writing it without the space between "# is clearer as then it
> looks more like it's part of the value.

Ah clever indeed. Thanks!

> 
> Regards,
> BALATON Zoltan
> 
>>>> +
>>>> #endif
>>>> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
>>>> index 4d1de7cfab..0024c346c6 100644
>>>> --- a/hw/i386/pc_piix.c
>>>> +++ b/hw/i386/pc_piix.c
>>>> @@ -37,6 +37,7 @@
>>>> #include "hw/pci/pci.h"
>>>> #include "hw/pci/pci_ids.h"
>>>> #include "hw/usb/usb.h"
>>>> +#include "hw/usb/usb-hcd.h"
>>>> #include "net/net.h"
>>>> #include "hw/ide/pci.h"
>>>> #include "hw/irq.h"
>>>> @@ -275,7 +276,7 @@ static void pc_init1(MachineState *machine,
>>>> #endif
>>>>
>>>>     if (pcmc->pci_enabled && machine_usb(machine)) {
>>>> -        pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
>>>> +        pci_create_simple(pci_bus, piix3_devfn + 2,
>>>> TYPE_PIIX3_USB_UHCI);
>>>>     }
>>>>
>>>>     if (pcmc->pci_enabled &&
>>>> x86_machine_is_acpi_enabled(X86_MACHINE(pcms))) {
>>>> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
>>>> index b985f5bea1..a80527e6ed 100644
>>>> --- a/hw/i386/pc_q35.c
>>>> +++ b/hw/i386/pc_q35.c
>>>> @@ -51,6 +51,7 @@
>>>> #include "hw/ide/pci.h"
>>>> #include "hw/ide/ahci.h"
>>>> #include "hw/usb/usb.h"
>>>> +#include "hw/usb/usb-hcd.h"
>>>> #include "qapi/error.h"
>>>> #include "qemu/error-report.h"
>>>> #include "sysemu/numa.h"
>>>> @@ -68,15 +69,15 @@ struct ehci_companions {
>>>> };
>>>>
>>>> static const struct ehci_companions ich9_1d[] = {
>>>> -    { .name = "ich9-usb-uhci1", .func = 0, .port = 0 },
>>>> -    { .name = "ich9-usb-uhci2", .func = 1, .port = 2 },
>>>> -    { .name = "ich9-usb-uhci3", .func = 2, .port = 4 },
>>>> +    { .name = TYPE_ICH9_USB_UHCI(1), .func = 0, .port = 0 },
>>>> +    { .name = TYPE_ICH9_USB_UHCI(2), .func = 1, .port = 2 },
>>>> +    { .name = TYPE_ICH9_USB_UHCI(3), .func = 2, .port = 4 },
>>>> };
>>>>
>>>> static const struct ehci_companions ich9_1a[] = {
>>>> -    { .name = "ich9-usb-uhci4", .func = 0, .port = 0 },
>>>> -    { .name = "ich9-usb-uhci5", .func = 1, .port = 2 },
>>>> -    { .name = "ich9-usb-uhci6", .func = 2, .port = 4 },
>>>> +    { .name = TYPE_ICH9_USB_UHCI(4), .func = 0, .port = 0 },
>>>> +    { .name = TYPE_ICH9_USB_UHCI(5), .func = 1, .port = 2 },
>>>> +    { .name = TYPE_ICH9_USB_UHCI(6), .func = 2, .port = 4 },
>>>> };
>>>>
>>>> static int ehci_create_ich9_with_companions(PCIBus *bus, int slot)
>>>> diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
>>>> index f634bcb2d1..e11e5fae21 100644
>>>> --- a/hw/isa/piix4.c
>>>> +++ b/hw/isa/piix4.c
>>>> @@ -29,6 +29,7 @@
>>>> #include "hw/southbridge/piix.h"
>>>> #include "hw/pci/pci.h"
>>>> #include "hw/isa/isa.h"
>>>> +#include "hw/usb/usb-hcd.h"
>>>> #include "hw/sysbus.h"
>>>> #include "hw/intc/i8259.h"
>>>> #include "hw/dma/i8257.h"
>>>> @@ -255,7 +256,7 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus
>>>> **isa_bus, I2CBus **smbus)
>>>>     pci = pci_create_simple(pci_bus, devfn + 1, "piix4-ide");
>>>>     pci_ide_create_devs(pci);
>>>>
>>>> -    pci_create_simple(pci_bus, devfn + 2, "piix4-usb-uhci");
>>>> +    pci_create_simple(pci_bus, devfn + 2, TYPE_PIIX4_USB_UHCI);
>>>>     if (smbus) {
>>>>         *smbus = piix4_pm_init(pci_bus, devfn + 3, 0x1100,
>>>>                                isa_get_irq(NULL, 9), NULL, 0, NULL);
>>>> diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c
>>>> index 8ca31e5162..b6d33dd2cd 100644
>>>> --- a/hw/mips/fuloong2e.c
>>>> +++ b/hw/mips/fuloong2e.c
>>>> @@ -33,6 +33,7 @@
>>>> #include "hw/mips/mips.h"
>>>> #include "hw/mips/cpudevs.h"
>>>> #include "hw/pci/pci.h"
>>>> +#include "hw/usb/usb-hcd.h"
>>>> #include "qemu/log.h"
>>>> #include "hw/loader.h"
>>>> #include "hw/ide/pci.h"
>>>> @@ -258,8 +259,8 @@ static void vt82c686b_southbridge_init(PCIBus
>>>> *pci_bus, int slot, qemu_irq intc,
>>>>     dev = pci_create_simple(pci_bus, PCI_DEVFN(slot, 1), "via-ide");
>>>>     pci_ide_create_devs(dev);
>>>>
>>>> -    pci_create_simple(pci_bus, PCI_DEVFN(slot, 2),
>>>> "vt82c686b-usb-uhci");
>>>> -    pci_create_simple(pci_bus, PCI_DEVFN(slot, 3),
>>>> "vt82c686b-usb-uhci");
>>>> +    pci_create_simple(pci_bus, PCI_DEVFN(slot, 2),
>>>> TYPE_VT82C686B_USB_UHCI);
>>>> +    pci_create_simple(pci_bus, PCI_DEVFN(slot, 3),
>>>> TYPE_VT82C686B_USB_UHCI);
>>>>
>>>>     *i2c_bus = vt82c686b_pm_init(pci_bus, PCI_DEVFN(slot, 4), 0xeee1,
>>>> NULL);
>>>>
>>>> diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
>>>> index 1d4dd33b6c..da078dc3fa 100644
>>>> --- a/hw/usb/hcd-uhci.c
>>>> +++ b/hw/usb/hcd-uhci.c
>>>> @@ -39,6 +39,7 @@
>>>> #include "qemu/main-loop.h"
>>>> #include "qemu/module.h"
>>>> #include "usb-internal.h"
>>>> +#include "hw/usb/usb-hcd.h"
>>>>
>>>> #define FRAME_TIMER_FREQ 1000
>>>>
>>>> @@ -1358,21 +1359,21 @@ static void uhci_data_class_init(ObjectClass
>>>> *klass, void *data)
>>>>
>>>> static UHCIInfo uhci_info[] = {
>>>>     {
>>>> -        .name       = "piix3-usb-uhci",
>>>> +        .name      = TYPE_PIIX3_USB_UHCI,
>>>>         .vendor_id = PCI_VENDOR_ID_INTEL,
>>>>         .device_id = PCI_DEVICE_ID_INTEL_82371SB_2,
>>>>         .revision  = 0x01,
>>>>         .irq_pin   = 3,
>>>>         .unplug    = true,
>>>>     },{
>>>> -        .name      = "piix4-usb-uhci",
>>>> +        .name      = TYPE_PIIX4_USB_UHCI,
>>>>         .vendor_id = PCI_VENDOR_ID_INTEL,
>>>>         .device_id = PCI_DEVICE_ID_INTEL_82371AB_2,
>>>>         .revision  = 0x01,
>>>>         .irq_pin   = 3,
>>>>         .unplug    = true,
>>>>     },{
>>>> -        .name      = "vt82c686b-usb-uhci",
>>>> +        .name      = TYPE_VT82C686B_USB_UHCI,
>>>>         .vendor_id = PCI_VENDOR_ID_VIA,
>>>>         .device_id = PCI_DEVICE_ID_VIA_UHCI,
>>>>         .revision  = 0x01,
>>>> @@ -1380,42 +1381,42 @@ static UHCIInfo uhci_info[] = {
>>>>         .realize   = usb_uhci_vt82c686b_realize,
>>>>         .unplug    = true,
>>>>     },{
>>>> -        .name      = "ich9-usb-uhci1", /* 00:1d.0 */
>>>> +        .name      = TYPE_ICH9_USB_UHCI(1), /* 00:1d.0 */
>>>>         .vendor_id = PCI_VENDOR_ID_INTEL,
>>>>         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI1,
>>>>         .revision  = 0x03,
>>>>         .irq_pin   = 0,
>>>>         .unplug    = false,
>>>>     },{
>>>> -        .name      = "ich9-usb-uhci2", /* 00:1d.1 */
>>>> +        .name      = TYPE_ICH9_USB_UHCI(2), /* 00:1d.1 */
>>>>         .vendor_id = PCI_VENDOR_ID_INTEL,
>>>>         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI2,
>>>>         .revision  = 0x03,
>>>>         .irq_pin   = 1,
>>>>         .unplug    = false,
>>>>     },{
>>>> -        .name      = "ich9-usb-uhci3", /* 00:1d.2 */
>>>> +        .name      = TYPE_ICH9_USB_UHCI(3), /* 00:1d.2 */
>>>>         .vendor_id = PCI_VENDOR_ID_INTEL,
>>>>         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI3,
>>>>         .revision  = 0x03,
>>>>         .irq_pin   = 2,
>>>>         .unplug    = false,
>>>>     },{
>>>> -        .name      = "ich9-usb-uhci4", /* 00:1a.0 */
>>>> +        .name      = TYPE_ICH9_USB_UHCI(4), /* 00:1a.0 */
>>>>         .vendor_id = PCI_VENDOR_ID_INTEL,
>>>>         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI4,
>>>>         .revision  = 0x03,
>>>>         .irq_pin   = 0,
>>>>         .unplug    = false,
>>>>     },{
>>>> -        .name      = "ich9-usb-uhci5", /* 00:1a.1 */
>>>> +        .name      = TYPE_ICH9_USB_UHCI(5), /* 00:1a.1 */
>>>>         .vendor_id = PCI_VENDOR_ID_INTEL,
>>>>         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI5,
>>>>         .revision  = 0x03,
>>>>         .irq_pin   = 1,
>>>>         .unplug    = false,
>>>>     },{
>>>> -        .name      = "ich9-usb-uhci6", /* 00:1a.2 */
>>>> +        .name      = TYPE_ICH9_USB_UHCI(6), /* 00:1a.2 */
>>>>         .vendor_id = PCI_VENDOR_ID_INTEL,
>>>>         .device_id = PCI_DEVICE_ID_INTEL_82801I_UHCI6,
>>>>         .revision  = 0x03,
>>>>
>>
>>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 24/26] hw/usb/usb-hcd: Use UHCI type definitions
  2020-07-04 19:44       ` BALATON Zoltan
  2020-07-04 19:49         ` Philippe Mathieu-Daudé
@ 2020-07-05  5:37         ` Paolo Bonzini
  1 sibling, 0 replies; 63+ messages in thread
From: Paolo Bonzini @ 2020-07-05  5:37 UTC (permalink / raw)
  To: BALATON Zoltan, Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, qemu-devel, Jiaxun Yang,
	Gerd Hoffmann, Huacai Chen, Eric Blake, Stefano Stabellini,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Marcel Apfelbaum, Anthony Perard,
	Samuel Thibault, Leif Lindholm, Andrzej Zaborowski,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani,
	Marc-André Lureau, Niek Linnenbank, qemu-arm, xen-devel,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson

On 04/07/20 21:44, BALATON Zoltan wrote:
> 
> No it's OK, no need to list all defines. I just did not notice the macro
> argument that's why I was wondering where it comes from. This seems to
> be used elsewhere at least here:
> 
> hw/audio/es1370.c:#define a(n) if (val & CTRL_##n) strcat (buf, " "#n)
> hw/audio/es1370.c:#define a(n) if (val & SCTRL_##n) strcat (buf, " "#n)
> hw/audio/es1370.c:#define b(n) if (!(val & SCTRL_##n)) strcat (buf, " "#n)
> 
> Maybe writing it without the space between "# is clearer as then it
> looks more like it's part of the value.

I think keeping the space is better.

The reason is that CTRL_##n pastes together CTRL_ and n, but " "#n is
different:

1) First, it turns n into a string, for example "1"

2) Then, just because there is another string just before, the two are
concatenated, as in "CTRL_" "1".

Paolo



^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 23/26] hw/usb/usb-hcd: Use EHCI type definitions
  2020-07-04 17:15   ` BALATON Zoltan
@ 2020-07-05  9:26     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 63+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-07-05  9:26 UTC (permalink / raw)
  To: BALATON Zoltan
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Jiaxun Yang, Gerd Hoffmann, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

On 7/4/20 7:15 PM, BALATON Zoltan wrote:
> On Sat, 4 Jul 2020, Philippe Mathieu-Daudé wrote:
>> Various machine/board/soc models create EHCI device instances
>> with the generic QDEV API, and don't need to access USB internals.
>>
>> Simplify header inclusions by moving the QOM type names into a
>> simple header, with no need to include other "hw/usb" headers.
>>
>> Suggested-by: BALATON Zoltan <balaton@eik.bme.hu>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>> hw/usb/hcd-ehci.h         | 11 +----------
>> include/hw/usb/chipidea.h |  2 +-
>> include/hw/usb/usb-hcd.h  | 11 +++++++++++
>> hw/arm/allwinner-h3.c     |  1 -
>> hw/arm/exynos4210.c       |  2 +-
>> hw/arm/sbsa-ref.c         |  3 ++-
>> hw/arm/xilinx_zynq.c      |  2 +-
>> hw/ppc/sam460ex.c         |  1 -
>> hw/usb/chipidea.c         |  1 +
>> hw/usb/hcd-ehci-sysbus.c  |  1 +
>> 10 files changed, 19 insertions(+), 16 deletions(-)
>>
>> diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h
>> index 337b3ad05c..da70767409 100644
>> --- a/hw/usb/hcd-ehci.h
>> +++ b/hw/usb/hcd-ehci.h
>> @@ -23,6 +23,7 @@
>> #include "hw/pci/pci.h"
>> #include "hw/sysbus.h"
>> #include "usb-internal.h"
>> +#include "hw/usb/usb-hcd.h"
>>
>> #define CAPA_SIZE        0x10
>>
>> @@ -316,7 +317,6 @@ void usb_ehci_realize(EHCIState *s, DeviceState
>> *dev, Error **errp);
>> void usb_ehci_unrealize(EHCIState *s, DeviceState *dev);
>> void ehci_reset(void *opaque);
>>
>> -#define TYPE_PCI_EHCI "pci-ehci-usb"
>> #define PCI_EHCI(obj) OBJECT_CHECK(EHCIPCIState, (obj), TYPE_PCI_EHCI)
>>
>> typedef struct EHCIPCIState {
>> @@ -327,15 +327,6 @@ typedef struct EHCIPCIState {
>>     EHCIState ehci;
>> } EHCIPCIState;
>>
>> -
>> -#define TYPE_SYS_BUS_EHCI "sysbus-ehci-usb"
>> -#define TYPE_PLATFORM_EHCI "platform-ehci-usb"
>> -#define TYPE_EXYNOS4210_EHCI "exynos4210-ehci-usb"
>> -#define TYPE_AW_H3_EHCI "aw-h3-ehci-usb"
>> -#define TYPE_TEGRA2_EHCI "tegra2-ehci-usb"
>> -#define TYPE_PPC4xx_EHCI "ppc4xx-ehci-usb"
>> -#define TYPE_FUSBH200_EHCI "fusbh200-ehci-usb"
>> -
>> #define SYS_BUS_EHCI(obj) \
>>     OBJECT_CHECK(EHCISysBusState, (obj), TYPE_SYS_BUS_EHCI)
>> #define SYS_BUS_EHCI_CLASS(class) \
>> diff --git a/include/hw/usb/chipidea.h b/include/hw/usb/chipidea.h
>> index 1ec2e9dbda..28f46291de 100644
>> --- a/include/hw/usb/chipidea.h
>> +++ b/include/hw/usb/chipidea.h
>> @@ -2,6 +2,7 @@
>> #define CHIPIDEA_H
>>
>> #include "hw/usb/hcd-ehci.h"
>> +#include "hw/usb/usb-hcd.h"
>>
>> typedef struct ChipideaState {
>>     /*< private >*/
>> @@ -10,7 +11,6 @@ typedef struct ChipideaState {
>>     MemoryRegion iomem[3];
>> } ChipideaState;
>>
>> -#define TYPE_CHIPIDEA "usb-chipidea"
>> #define CHIPIDEA(obj) OBJECT_CHECK(ChipideaState, (obj), TYPE_CHIPIDEA)
>>
>> #endif /* CHIPIDEA_H */
>> diff --git a/include/hw/usb/usb-hcd.h b/include/hw/usb/usb-hcd.h
>> index 21fdfaf22d..74af3a4533 100644
>> --- a/include/hw/usb/usb-hcd.h
>> +++ b/include/hw/usb/usb-hcd.h
>> @@ -13,4 +13,15 @@
>> #define TYPE_SYSBUS_OHCI            "sysbus-ohci"
>> #define TYPE_PCI_OHCI               "pci-ohci"
>>
>> +/* EHCI */
>> +#define TYPE_SYS_BUS_EHCI           "sysbus-ehci-usb"
>> +#define TYPE_PCI_EHCI               "pci-ehci-usb"
>> +#define TYPE_PLATFORM_EHCI          "platform-ehci-usb"
>> +#define TYPE_EXYNOS4210_EHCI        "exynos4210-ehci-usb"
>> +#define TYPE_AW_H3_EHCI             "aw-h3-ehci-usb"
>> +#define TYPE_TEGRA2_EHCI            "tegra2-ehci-usb"
>> +#define TYPE_PPC4xx_EHCI            "ppc4xx-ehci-usb"
>> +#define TYPE_FUSBH200_EHCI          "fusbh200-ehci-usb"
>> +#define TYPE_CHIPIDEA               "usb-chipidea"
>> +
>> #endif
>> diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
>> index d1d90ffa79..8b7adddc27 100644
>> --- a/hw/arm/allwinner-h3.c
>> +++ b/hw/arm/allwinner-h3.c
>> @@ -29,7 +29,6 @@
>> #include "hw/char/serial.h"
>> #include "hw/misc/unimp.h"
>> #include "hw/usb/usb-hcd.h"
>> -#include "hw/usb/hcd-ehci.h"
>> #include "hw/loader.h"
>> #include "sysemu/sysemu.h"
>> #include "hw/arm/allwinner-h3.h"
>> diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
>> index fa639806ec..692fb02159 100644
>> --- a/hw/arm/exynos4210.c
>> +++ b/hw/arm/exynos4210.c
>> @@ -35,7 +35,7 @@
>> #include "hw/qdev-properties.h"
>> #include "hw/arm/exynos4210.h"
>> #include "hw/sd/sdhci.h"
>> -#include "hw/usb/hcd-ehci.h"
>> +#include "hw/usb/usb-hcd.h"
>>
>> #define EXYNOS4210_CHIPID_ADDR         0x10000000
>>
>> diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
>> index 021e7c1b8b..4e4c338ae9 100644
>> --- a/hw/arm/sbsa-ref.c
>> +++ b/hw/arm/sbsa-ref.c
>> @@ -38,6 +38,7 @@
>> #include "hw/loader.h"
>> #include "hw/pci-host/gpex.h"
>> #include "hw/qdev-properties.h"
>> +#include "hw/usb/usb-hcd.h"
>> #include "hw/char/pl011.h"
>> #include "net/net.h"
>>
>> @@ -485,7 +486,7 @@ static void create_ehci(const SBSAMachineState *sms)
>>     hwaddr base = sbsa_ref_memmap[SBSA_EHCI].base;
>>     int irq = sbsa_ref_irqmap[SBSA_EHCI];
>>
>> -    sysbus_create_simple("platform-ehci-usb", base,
>> +    sysbus_create_simple(TYPE_PLATFORM_EHCI, base,
>>                          qdev_get_gpio_in(sms->gic, irq));
>> }
>>
>> diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
>> index ed970273f3..9ccdc03095 100644
>> --- a/hw/arm/xilinx_zynq.c
>> +++ b/hw/arm/xilinx_zynq.c
>> @@ -29,7 +29,7 @@
>> #include "hw/loader.h"
>> #include "hw/misc/zynq-xadc.h"
>> #include "hw/ssi/ssi.h"
>> -#include "hw/usb/chipidea.h"
>> +#include "hw/usb/usb-hcd.h"
>> #include "qemu/error-report.h"
>> #include "hw/sd/sdhci.h"
>> #include "hw/char/cadence_uart.h"
>> diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
>> index ac60d17a86..3f7cf0d1ae 100644
>> --- a/hw/ppc/sam460ex.c
>> +++ b/hw/ppc/sam460ex.c
>> @@ -37,7 +37,6 @@
>> #include "hw/i2c/smbus_eeprom.h"
>> #include "hw/usb/usb.h"
>> #include "hw/usb/usb-hcd.h"
>> -#include "hw/usb/hcd-ehci.h"
>> #include "hw/ppc/fdt.h"
>> #include "hw/qdev-properties.h"
>> #include "hw/pci/pci.h"
>> diff --git a/hw/usb/chipidea.c b/hw/usb/chipidea.c
>> index 3dcd22ccba..e81f63295e 100644
>> --- a/hw/usb/chipidea.c
>> +++ b/hw/usb/chipidea.c
>> @@ -11,6 +11,7 @@
>>
>> #include "qemu/osdep.h"
>> #include "hw/usb/hcd-ehci.h"
>> +#include "hw/usb/usb-hcd.h"
>> #include "hw/usb/chipidea.h"
>> #include "qemu/log.h"
>> #include "qemu/module.h"
>> diff --git a/hw/usb/hcd-ehci-sysbus.c b/hw/usb/hcd-ehci-sysbus.c
>> index 3730736540..b7debc1934 100644
>> --- a/hw/usb/hcd-ehci-sysbus.c
>> +++ b/hw/usb/hcd-ehci-sysbus.c
>> @@ -18,6 +18,7 @@
>> #include "qemu/osdep.h"
>> #include "hw/qdev-properties.h"
>> #include "hw/usb/hcd-ehci.h"
>> +#include "hw/usb/usb-hcd.h"
>> #include "migration/vmstate.h"
>> #include "qemu/module.h"
> 
> Do these last two still need hw/usb/hcd-ehci.h? If so do they get
> hw/usb/usb-hcd.h via that one so do they need to explicitely include it
> again?

chipidea.c implements an HCI, so it uses the hcd-ehci.h internals,
else we get:

usb/chipidea.c:96:5: error: unknown type name ‘EHCIState’
   96 |     EHCIState *ehci = &SYS_BUS_EHCI(obj)->ehci;
      |     ^~~~~~~~~
hw/usb/chipidea.c:152:5: error: unknown type name ‘SysBusEHCIClass’
  152 |     SysBusEHCIClass *sec = SYS_BUS_EHCI_CLASS(klass);
      |     ^~~~~~~~~~~~~~~
hw/usb/chipidea.c:152:28: error: implicit declaration of function
‘SYS_BUS_EHCI_CLASS’ [-Werror=implicit-function-declaration]
  152 |     SysBusEHCIClass *sec = SYS_BUS_EHCI_CLASS(klass);
      |                            ^~~~~~~~~~~~~~~~~~

Similarly with hcd-ehci-sysbus.c:

hw/usb/hcd-ehci-sysbus.c:30:50: error: ‘vmstate_ehci’ undeclared here
(not in a function)
   30 |         VMSTATE_STRUCT(ehci, EHCISysBusState, 2, vmstate_ehci,
EHCIState),
      |                                                  ^~~~~~~~~~~~
hw/usb/hcd-ehci-sysbus.c:45:26: error: implicit declaration of function
‘SYS_BUS_EHCI’; did you mean ‘TYPE_SYS_BUS_EHCI’?
[-Werror=implicit-function-declaration]
   45 |     EHCISysBusState *i = SYS_BUS_EHCI(dev);
      |                          ^~~~~~~~~~~~
      |                          TYPE_SYS_BUS_EHCI
hw/usb/hcd-ehci-sysbus.c:48:5: error: implicit declaration of function
‘usb_ehci_realize’; did you mean ‘usb_ehci_sysbus_realize’?
[-Werror=implicit-function-declaration]
   48 |     usb_ehci_realize(s, dev, errp);
      |     ^~~~~~~~~~~~~~~~
      |     usb_ehci_sysbus_realize
hw/usb/hcd-ehci-sysbus.c:74:5: error: implicit declaration of function
‘usb_ehci_init’ [-Werror=implicit-function-declaration]
   74 |     usb_ehci_init(s, DEVICE(obj));
      |     ^~~~~~~~~~~~~

The idea of "hw/usb/usb-hcd.h" is to keep USB internals opaque to
machine/board/soc using controllers, they just want to use the
devices.

I'll see how to reword the description to make that clearer.

> 
> Regards,
> BALATON Zoltan


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 22/26] hw/usb/usb-hcd: Use OHCI type definitions
  2020-07-04 14:49 ` [PATCH 22/26] hw/usb/usb-hcd: Use OHCI type definitions Philippe Mathieu-Daudé
  2020-07-04 17:13   ` BALATON Zoltan
@ 2020-07-05 19:55   ` Niek Linnenbank
  1 sibling, 0 replies; 63+ messages in thread
From: Niek Linnenbank @ 2020-07-05 19:55 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	QEMU Developers, Jiaxun Yang, BALATON Zoltan, Gerd Hoffmann,
	Edgar E. Iglesias, Huacai Chen, Stefano Stabellini, xen-devel,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Marcel Apfelbaum, Anthony Perard,
	Samuel Thibault, Leif Lindholm, Andrzej Zaborowski,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani, qemu-arm,
	Marc-André Lureau, Richard Henderson, Radoslaw Biernacki,
	Igor Mitsyanko, Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 11178 bytes --]

On Sat, Jul 4, 2020, 16:50 Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:

> Various machine/board/soc models create OHCI device instances
> with the generic QDEV API, and don't need to access USB internals.
>
> Simplify header inclusions by moving the QOM type names into a
> simple header, with no need to include other "hw/usb" headers.
>
> Suggested-by: BALATON Zoltan <balaton@eik.bme.hu>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>

---
>  hw/usb/hcd-ohci.h        |  2 +-
>  include/hw/usb/usb-hcd.h | 16 ++++++++++++++++
>  hw/arm/allwinner-a10.c   |  2 +-
>  hw/arm/allwinner-h3.c    |  9 +++++----
>  hw/arm/pxa2xx.c          |  3 ++-
>  hw/arm/realview.c        |  3 ++-
>  hw/arm/versatilepb.c     |  3 ++-
>  hw/display/sm501.c       |  3 ++-
>  hw/ppc/mac_newworld.c    |  3 ++-
>  hw/ppc/mac_oldworld.c    |  3 ++-
>  hw/ppc/sam460ex.c        |  3 ++-
>  hw/ppc/spapr.c           |  3 ++-
>  hw/usb/hcd-ohci-pci.c    |  2 +-
>  13 files changed, 40 insertions(+), 15 deletions(-)
>  create mode 100644 include/hw/usb/usb-hcd.h
>
> diff --git a/hw/usb/hcd-ohci.h b/hw/usb/hcd-ohci.h
> index 771927ea17..6949cf0dab 100644
> --- a/hw/usb/hcd-ohci.h
> +++ b/hw/usb/hcd-ohci.h
> @@ -21,6 +21,7 @@
>  #ifndef HCD_OHCI_H
>  #define HCD_OHCI_H
>
> +#include "hw/usb/usb-hcd.h"
>  #include "sysemu/dma.h"
>  #include "usb-internal.h"
>
> @@ -91,7 +92,6 @@ typedef struct OHCIState {
>      void (*ohci_die)(struct OHCIState *ohci);
>  } OHCIState;
>
> -#define TYPE_SYSBUS_OHCI "sysbus-ohci"
>  #define SYSBUS_OHCI(obj) OBJECT_CHECK(OHCISysBusState, (obj),
> TYPE_SYSBUS_OHCI)
>
>  typedef struct {
> diff --git a/include/hw/usb/usb-hcd.h b/include/hw/usb/usb-hcd.h
> new file mode 100644
> index 0000000000..21fdfaf22d
> --- /dev/null
> +++ b/include/hw/usb/usb-hcd.h
> @@ -0,0 +1,16 @@
> +/*
> + * QEMU USB HCD types
> + *
> + * Copyright (c) 2020  Philippe Mathieu-Daudé <f4bug@amsat.org>
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +
> +#ifndef HW_USB_HCD_TYPES_H
> +#define HW_USB_HCD_TYPES_H
> +
> +/* OHCI */
> +#define TYPE_SYSBUS_OHCI            "sysbus-ohci"
> +#define TYPE_PCI_OHCI               "pci-ohci"
> +
> +#endif
> diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
> index 52e0d83760..53c24ff602 100644
> --- a/hw/arm/allwinner-a10.c
> +++ b/hw/arm/allwinner-a10.c
> @@ -25,7 +25,7 @@
>  #include "hw/misc/unimp.h"
>  #include "sysemu/sysemu.h"
>  #include "hw/boards.h"
> -#include "hw/usb/hcd-ohci.h"
> +#include "hw/usb/usb-hcd.h"
>
>  #define AW_A10_MMC0_BASE        0x01c0f000
>  #define AW_A10_PIC_REG_BASE     0x01c20400
> diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
> index 8e09468e86..d1d90ffa79 100644
> --- a/hw/arm/allwinner-h3.c
> +++ b/hw/arm/allwinner-h3.c
> @@ -28,6 +28,7 @@
>  #include "hw/sysbus.h"
>  #include "hw/char/serial.h"
>  #include "hw/misc/unimp.h"
> +#include "hw/usb/usb-hcd.h"
>  #include "hw/usb/hcd-ehci.h"
>  #include "hw/loader.h"
>  #include "sysemu/sysemu.h"
> @@ -381,16 +382,16 @@ static void allwinner_h3_realize(DeviceState *dev,
> Error **errp)
>                           qdev_get_gpio_in(DEVICE(&s->gic),
>                                            AW_H3_GIC_SPI_EHCI3));
>
> -    sysbus_create_simple("sysbus-ohci", s->memmap[AW_H3_OHCI0],
> +    sysbus_create_simple(TYPE_SYSBUS_OHCI, s->memmap[AW_H3_OHCI0],
>                           qdev_get_gpio_in(DEVICE(&s->gic),
>                                            AW_H3_GIC_SPI_OHCI0));
> -    sysbus_create_simple("sysbus-ohci", s->memmap[AW_H3_OHCI1],
> +    sysbus_create_simple(TYPE_SYSBUS_OHCI, s->memmap[AW_H3_OHCI1],
>                           qdev_get_gpio_in(DEVICE(&s->gic),
>                                            AW_H3_GIC_SPI_OHCI1));
> -    sysbus_create_simple("sysbus-ohci", s->memmap[AW_H3_OHCI2],
> +    sysbus_create_simple(TYPE_SYSBUS_OHCI, s->memmap[AW_H3_OHCI2],
>                           qdev_get_gpio_in(DEVICE(&s->gic),
>                                            AW_H3_GIC_SPI_OHCI2));
> -    sysbus_create_simple("sysbus-ohci", s->memmap[AW_H3_OHCI3],
> +    sysbus_create_simple(TYPE_SYSBUS_OHCI, s->memmap[AW_H3_OHCI3],
>                           qdev_get_gpio_in(DEVICE(&s->gic),
>                                            AW_H3_GIC_SPI_OHCI3));
>
> diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
> index f104a33463..27196170f5 100644
> --- a/hw/arm/pxa2xx.c
> +++ b/hw/arm/pxa2xx.c
> @@ -18,6 +18,7 @@
>  #include "hw/arm/pxa.h"
>  #include "sysemu/sysemu.h"
>  #include "hw/char/serial.h"
> +#include "hw/usb/usb-hcd.h"
>  #include "hw/i2c/i2c.h"
>  #include "hw/irq.h"
>  #include "hw/qdev-properties.h"
> @@ -2196,7 +2197,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,
>          s->ssp[i] = (SSIBus *)qdev_get_child_bus(dev, "ssi");
>      }
>
> -    sysbus_create_simple("sysbus-ohci", 0x4c000000,
> +    sysbus_create_simple(TYPE_SYSBUS_OHCI, 0x4c000000,
>                           qdev_get_gpio_in(s->pic, PXA2XX_PIC_USBH1));
>
>      s->pcmcia[0] = pxa2xx_pcmcia_init(address_space, 0x20000000);
> diff --git a/hw/arm/realview.c b/hw/arm/realview.c
> index b6c0a1adb9..0aa34bd4c2 100644
> --- a/hw/arm/realview.c
> +++ b/hw/arm/realview.c
> @@ -16,6 +16,7 @@
>  #include "hw/net/lan9118.h"
>  #include "hw/net/smc91c111.h"
>  #include "hw/pci/pci.h"
> +#include "hw/usb/usb-hcd.h"
>  #include "net/net.h"
>  #include "sysemu/sysemu.h"
>  #include "hw/boards.h"
> @@ -256,7 +257,7 @@ static void realview_init(MachineState *machine,
>          sysbus_connect_irq(busdev, 3, pic[51]);
>          pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci");
>          if (machine_usb(machine)) {
> -            pci_create_simple(pci_bus, -1, "pci-ohci");
> +            pci_create_simple(pci_bus, -1, TYPE_PCI_OHCI);
>          }
>          n = drive_get_max_bus(IF_SCSI);
>          while (n >= 0) {
> diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
> index e596b8170f..3e6224dc96 100644
> --- a/hw/arm/versatilepb.c
> +++ b/hw/arm/versatilepb.c
> @@ -17,6 +17,7 @@
>  #include "net/net.h"
>  #include "sysemu/sysemu.h"
>  #include "hw/pci/pci.h"
> +#include "hw/usb/usb-hcd.h"
>  #include "hw/i2c/i2c.h"
>  #include "hw/i2c/arm_sbcon_i2c.h"
>  #include "hw/irq.h"
> @@ -273,7 +274,7 @@ static void versatile_init(MachineState *machine, int
> board_id)
>          }
>      }
>      if (machine_usb(machine)) {
> -        pci_create_simple(pci_bus, -1, "pci-ohci");
> +        pci_create_simple(pci_bus, -1, TYPE_PCI_OHCI);
>      }
>      n = drive_get_max_bus(IF_SCSI);
>      while (n >= 0) {
> diff --git a/hw/display/sm501.c b/hw/display/sm501.c
> index 9cccc68c35..5f076c841f 100644
> --- a/hw/display/sm501.c
> +++ b/hw/display/sm501.c
> @@ -33,6 +33,7 @@
>  #include "hw/sysbus.h"
>  #include "migration/vmstate.h"
>  #include "hw/pci/pci.h"
> +#include "hw/usb/usb-hcd.h"
>  #include "hw/qdev-properties.h"
>  #include "hw/i2c/i2c.h"
>  #include "hw/display/i2c-ddc.h"
> @@ -1961,7 +1962,7 @@ static void sm501_realize_sysbus(DeviceState *dev,
> Error **errp)
>      sysbus_init_mmio(sbd, &s->state.mmio_region);
>
>      /* bridge to usb host emulation module */
> -    usb_dev = qdev_new("sysbus-ohci");
> +    usb_dev = qdev_new(TYPE_SYSBUS_OHCI);
>      qdev_prop_set_uint32(usb_dev, "num-ports", 2);
>      qdev_prop_set_uint64(usb_dev, "dma-offset", s->base);
>      sysbus_realize_and_unref(SYS_BUS_DEVICE(usb_dev), &error_fatal);
> diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
> index 7bf69f4a1f..3c32c1831b 100644
> --- a/hw/ppc/mac_newworld.c
> +++ b/hw/ppc/mac_newworld.c
> @@ -55,6 +55,7 @@
>  #include "hw/input/adb.h"
>  #include "hw/ppc/mac_dbdma.h"
>  #include "hw/pci/pci.h"
> +#include "hw/usb/usb-hcd.h"
>  #include "net/net.h"
>  #include "sysemu/sysemu.h"
>  #include "hw/boards.h"
> @@ -411,7 +412,7 @@ static void ppc_core99_init(MachineState *machine)
>      }
>
>      if (machine->usb) {
> -        pci_create_simple(pci_bus, -1, "pci-ohci");
> +        pci_create_simple(pci_bus, -1, TYPE_PCI_OHCI);
>
>          /* U3 needs to use USB for input because Linux doesn't support
> via-cuda
>          on PPC64 */
> diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
> index f8c204ead7..a429a3e1df 100644
> --- a/hw/ppc/mac_oldworld.c
> +++ b/hw/ppc/mac_oldworld.c
> @@ -37,6 +37,7 @@
>  #include "hw/isa/isa.h"
>  #include "hw/pci/pci.h"
>  #include "hw/pci/pci_host.h"
> +#include "hw/usb/usb-hcd.h"
>  #include "hw/boards.h"
>  #include "hw/nvram/fw_cfg.h"
>  #include "hw/char/escc.h"
> @@ -301,7 +302,7 @@ static void ppc_heathrow_init(MachineState *machine)
>      qdev_realize_and_unref(dev, adb_bus, &error_fatal);
>
>      if (machine_usb(machine)) {
> -        pci_create_simple(pci_bus, -1, "pci-ohci");
> +        pci_create_simple(pci_bus, -1, TYPE_PCI_OHCI);
>      }
>
>      if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
> diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
> index 781b45e14b..ac60d17a86 100644
> --- a/hw/ppc/sam460ex.c
> +++ b/hw/ppc/sam460ex.c
> @@ -36,6 +36,7 @@
>  #include "hw/i2c/ppc4xx_i2c.h"
>  #include "hw/i2c/smbus_eeprom.h"
>  #include "hw/usb/usb.h"
> +#include "hw/usb/usb-hcd.h"
>  #include "hw/usb/hcd-ehci.h"
>  #include "hw/ppc/fdt.h"
>  #include "hw/qdev-properties.h"
> @@ -372,7 +373,7 @@ static void sam460ex_init(MachineState *machine)
>
>      /* USB */
>      sysbus_create_simple(TYPE_PPC4xx_EHCI, 0x4bffd0400, uic[2][29]);
> -    dev = qdev_new("sysbus-ohci");
> +    dev = qdev_new(TYPE_SYSBUS_OHCI);
>      qdev_prop_set_string(dev, "masterbus", "usb-bus.0");
>      qdev_prop_set_uint32(dev, "num-ports", 6);
>      sbdev = SYS_BUS_DEVICE(dev);
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 0c0409077f..db1706a66c 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -71,6 +71,7 @@
>  #include "exec/address-spaces.h"
>  #include "exec/ram_addr.h"
>  #include "hw/usb/usb.h"
> +#include "hw/usb/usb-hcd.h"
>  #include "qemu/config-file.h"
>  #include "qemu/error-report.h"
>  #include "trace.h"
> @@ -2958,7 +2959,7 @@ static void spapr_machine_init(MachineState *machine)
>
>      if (machine->usb) {
>          if (smc->use_ohci_by_default) {
> -            pci_create_simple(phb->bus, -1, "pci-ohci");
> +            pci_create_simple(phb->bus, -1, TYPE_PCI_OHCI);
>          } else {
>              pci_create_simple(phb->bus, -1, "nec-usb-xhci");
>          }
> diff --git a/hw/usb/hcd-ohci-pci.c b/hw/usb/hcd-ohci-pci.c
> index cb6bc55f59..14df83ec2e 100644
> --- a/hw/usb/hcd-ohci-pci.c
> +++ b/hw/usb/hcd-ohci-pci.c
> @@ -29,8 +29,8 @@
>  #include "trace.h"
>  #include "hcd-ohci.h"
>  #include "usb-internal.h"
> +#include "hw/usb/usb-hcd.h"
>
> -#define TYPE_PCI_OHCI "pci-ohci"
>  #define PCI_OHCI(obj) OBJECT_CHECK(OHCIPCIState, (obj), TYPE_PCI_OHCI)
>
>  typedef struct {
> --
> 2.21.3
>
>

[-- Attachment #2: Type: text/html, Size: 14250 bytes --]

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 08/26] hw/usb/hcd-dwc2: Restrict 'dwc2-regs.h' scope
  2020-07-04 14:49 ` [PATCH 08/26] hw/usb/hcd-dwc2: Restrict 'dwc2-regs.h' scope Philippe Mathieu-Daudé
@ 2020-07-06 16:47   ` Alistair Francis
  2020-07-06 23:29   ` Paul Zimmerman
  1 sibling, 0 replies; 63+ messages in thread
From: Alistair Francis @ 2020-07-06 16:47 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel@nongnu.org Developers, BALATON Zoltan, Gerd Hoffmann,
	Edgar E. Iglesias, Huacai Chen, Stefano Stabellini,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Anthony Perard, open list:X86,
	Leif Lindholm, Philippe Mathieu-Daudé,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani,
	Marc-André Lureau, Niek Linnenbank, qemu-arm,
	Samuel Thibault, Richard Henderson, Radoslaw Biernacki,
	Igor Mitsyanko, Paul Zimmerman, open list:New World,
	David Gibson, Paolo Bonzini

On Sat, Jul 4, 2020 at 7:53 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> We only use these register definitions in files under the
> hw/usb/ directory. Keep that header local by moving it there.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  {include/hw => hw}/usb/dwc2-regs.h | 0
>  hw/usb/hcd-dwc2.c                  | 2 +-
>  2 files changed, 1 insertion(+), 1 deletion(-)
>  rename {include/hw => hw}/usb/dwc2-regs.h (100%)
>
> diff --git a/include/hw/usb/dwc2-regs.h b/hw/usb/dwc2-regs.h
> similarity index 100%
> rename from include/hw/usb/dwc2-regs.h
> rename to hw/usb/dwc2-regs.h
> diff --git a/hw/usb/hcd-dwc2.c b/hw/usb/hcd-dwc2.c
> index ccf05d0823..252b60ef65 100644
> --- a/hw/usb/hcd-dwc2.c
> +++ b/hw/usb/hcd-dwc2.c
> @@ -34,7 +34,6 @@
>  #include "qemu/osdep.h"
>  #include "qemu/units.h"
>  #include "qapi/error.h"
> -#include "hw/usb/dwc2-regs.h"
>  #include "hw/usb/hcd-dwc2.h"
>  #include "hw/irq.h"
>  #include "sysemu/dma.h"
> @@ -43,6 +42,7 @@
>  #include "qemu/timer.h"
>  #include "qemu/log.h"
>  #include "hw/qdev-properties.h"
> +#include "dwc2-regs.h"
>
>  #define USB_HZ_FS       12000000
>  #define USB_HZ_HS       96000000
> --
> 2.21.3
>
>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 01/26] hw/arm/sbsa-ref: Remove unused 'hw/usb.h' header
  2020-07-04 14:49 ` [PATCH 01/26] hw/arm/sbsa-ref: Remove unused 'hw/usb.h' header Philippe Mathieu-Daudé
@ 2020-07-06 16:49   ` Alistair Francis
  0 siblings, 0 replies; 63+ messages in thread
From: Alistair Francis @ 2020-07-06 16:49 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel@nongnu.org Developers, BALATON Zoltan, Gerd Hoffmann,
	Edgar E. Iglesias, Huacai Chen, Stefano Stabellini,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Anthony Perard, open list:X86,
	Leif Lindholm, Philippe Mathieu-Daudé,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani,
	Marc-André Lureau, Niek Linnenbank, qemu-arm,
	Samuel Thibault, Richard Henderson, Radoslaw Biernacki,
	Igor Mitsyanko, Paul Zimmerman, open list:New World,
	David Gibson, Paolo Bonzini

On Sat, Jul 4, 2020 at 7:51 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> This file doesn't access anything from "hw/usb.h", remove its
> inclusion.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/arm/sbsa-ref.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
> index e40c868a82..021e7c1b8b 100644
> --- a/hw/arm/sbsa-ref.c
> +++ b/hw/arm/sbsa-ref.c
> @@ -38,7 +38,6 @@
>  #include "hw/loader.h"
>  #include "hw/pci-host/gpex.h"
>  #include "hw/qdev-properties.h"
> -#include "hw/usb.h"
>  #include "hw/char/pl011.h"
>  #include "net/net.h"
>
> --
> 2.21.3
>
>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 02/26] hw/ppc/sam460ex: Add missing 'hw/pci/pci.h' header
  2020-07-04 14:49 ` [PATCH 02/26] hw/ppc/sam460ex: Add missing 'hw/pci/pci.h' header Philippe Mathieu-Daudé
@ 2020-07-06 16:50   ` Alistair Francis
  0 siblings, 0 replies; 63+ messages in thread
From: Alistair Francis @ 2020-07-06 16:50 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel@nongnu.org Developers, BALATON Zoltan, Gerd Hoffmann,
	Edgar E. Iglesias, Huacai Chen, Stefano Stabellini,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Anthony Perard, open list:X86,
	Leif Lindholm, Philippe Mathieu-Daudé,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani,
	Marc-André Lureau, Niek Linnenbank, qemu-arm,
	Samuel Thibault, Richard Henderson, Radoslaw Biernacki,
	Igor Mitsyanko, Paul Zimmerman, open list:New World,
	David Gibson, Paolo Bonzini

On Sat, Jul 4, 2020 at 7:50 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> This file uses pci_create_simple() and PCI_DEVFN() which are both
> declared in "hw/pci/pci.h". This include is indirectly included
> by an USB header. As we want to reduce the USB header inclusions
> later, include the PCI header now, to avoid later:
>
>   hw/ppc/sam460ex.c:397:5: error: implicit declaration of function ‘pci_create_simple’; did you mean ‘sysbus_create_simple’? [-Werror=implicit-function-declaration]
>     397 |     pci_create_simple(pci_bus, PCI_DEVFN(6, 0), "sm501");
>         |     ^~~~~~~~~~~~~~~~~
>         |     sysbus_create_simple
>   hw/ppc/sam460ex.c:397:5: error: nested extern declaration of ‘pci_create_simple’ [-Werror=nested-externs]
>   hw/ppc/sam460ex.c:397:32: error: implicit declaration of function ‘PCI_DEVFN’ [-Werror=implicit-function-declaration]
>     397 |     pci_create_simple(pci_bus, PCI_DEVFN(6, 0), "sm501");
>         |                                ^~~~~~~~~
>   hw/ppc/sam460ex.c:397:32: error: nested extern declaration of ‘PCI_DEVFN’ [-Werror=nested-externs]
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/ppc/sam460ex.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
> index 1a106a68de..fae970b142 100644
> --- a/hw/ppc/sam460ex.c
> +++ b/hw/ppc/sam460ex.c
> @@ -38,6 +38,7 @@
>  #include "hw/usb/hcd-ehci.h"
>  #include "hw/ppc/fdt.h"
>  #include "hw/qdev-properties.h"
> +#include "hw/pci/pci.h"
>
>  #include <libfdt.h>
>
> --
> 2.21.3
>
>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 03/26] hw/usb: Remove unused VM_USB_HUB_SIZE definition
  2020-07-04 14:49 ` [PATCH 03/26] hw/usb: Remove unused VM_USB_HUB_SIZE definition Philippe Mathieu-Daudé
@ 2020-07-06 16:51   ` Alistair Francis
  0 siblings, 0 replies; 63+ messages in thread
From: Alistair Francis @ 2020-07-06 16:51 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel@nongnu.org Developers, BALATON Zoltan, Gerd Hoffmann,
	Edgar E. Iglesias, Huacai Chen, Stefano Stabellini,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Anthony Perard, open list:X86,
	Leif Lindholm, Philippe Mathieu-Daudé,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani,
	Marc-André Lureau, Niek Linnenbank, qemu-arm,
	Samuel Thibault, Richard Henderson, Radoslaw Biernacki,
	Igor Mitsyanko, Paul Zimmerman, open list:New World,
	David Gibson, Paolo Bonzini

On Sat, Jul 4, 2020 at 7:50 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> Commit a5d2f7273c ("qdev/usb: make qemu aware of usb busses")
> removed the last use of VM_USB_HUB_SIZE, 11 years ago. Time
> to drop it.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  include/hw/usb.h | 4 ----
>  1 file changed, 4 deletions(-)
>
> diff --git a/include/hw/usb.h b/include/hw/usb.h
> index e29a37635b..4f04a1a879 100644
> --- a/include/hw/usb.h
> +++ b/include/hw/usb.h
> @@ -470,10 +470,6 @@ void usb_generic_async_ctrl_complete(USBDevice *s, USBPacket *p);
>  void hmp_info_usbhost(Monitor *mon, const QDict *qdict);
>  bool usb_host_dev_is_scsi_storage(USBDevice *usbdev);
>
> -/* usb ports of the VM */
> -
> -#define VM_USB_HUB_SIZE 8
> -
>  /* usb-bus.c */
>
>  #define TYPE_USB_BUS "usb-bus"
> --
> 2.21.3
>
>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 04/26] hw/usb: Reduce 'exec/memory.h' inclusion
  2020-07-04 14:49 ` [PATCH 04/26] hw/usb: Reduce 'exec/memory.h' inclusion Philippe Mathieu-Daudé
@ 2020-07-06 16:52   ` Alistair Francis
  0 siblings, 0 replies; 63+ messages in thread
From: Alistair Francis @ 2020-07-06 16:52 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel@nongnu.org Developers, BALATON Zoltan, Gerd Hoffmann,
	Edgar E. Iglesias, Huacai Chen, Stefano Stabellini,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Anthony Perard, open list:X86,
	Leif Lindholm, Philippe Mathieu-Daudé,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani,
	Marc-André Lureau, Niek Linnenbank, qemu-arm,
	Samuel Thibault, Richard Henderson, Radoslaw Biernacki,
	Igor Mitsyanko, Paul Zimmerman, open list:New World,
	David Gibson, Paolo Bonzini

On Sat, Jul 4, 2020 at 7:52 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> "exec/memory.h" is only required by "hw/usb/hcd-musb.h".
> Include it there directly.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  include/hw/usb.h          | 1 -
>  include/hw/usb/hcd-musb.h | 2 ++
>  2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/include/hw/usb.h b/include/hw/usb.h
> index 4f04a1a879..15b2ef300a 100644
> --- a/include/hw/usb.h
> +++ b/include/hw/usb.h
> @@ -25,7 +25,6 @@
>   * THE SOFTWARE.
>   */
>
> -#include "exec/memory.h"
>  #include "hw/qdev-core.h"
>  #include "qemu/iov.h"
>  #include "qemu/queue.h"
> diff --git a/include/hw/usb/hcd-musb.h b/include/hw/usb/hcd-musb.h
> index c874b9f292..ec3ee5c4b0 100644
> --- a/include/hw/usb/hcd-musb.h
> +++ b/include/hw/usb/hcd-musb.h
> @@ -13,6 +13,8 @@
>  #ifndef HW_USB_MUSB_H
>  #define HW_USB_MUSB_H
>
> +#include "exec/memory.h"
> +
>  enum musb_irq_source_e {
>      musb_irq_suspend = 0,
>      musb_irq_resume,
> --
> 2.21.3
>
>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 06/26] hw/usb/hcd-dwc2: Remove unnecessary includes
  2020-07-04 14:49 ` [PATCH 06/26] hw/usb/hcd-dwc2: Remove unnecessary includes Philippe Mathieu-Daudé
@ 2020-07-06 16:54   ` Alistair Francis
  2020-07-06 23:28   ` Paul Zimmerman
  1 sibling, 0 replies; 63+ messages in thread
From: Alistair Francis @ 2020-07-06 16:54 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel@nongnu.org Developers, BALATON Zoltan, Gerd Hoffmann,
	Edgar E. Iglesias, Huacai Chen, Stefano Stabellini,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Anthony Perard, open list:X86,
	Leif Lindholm, Philippe Mathieu-Daudé,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani,
	Marc-André Lureau, Niek Linnenbank, qemu-arm,
	Samuel Thibault, Richard Henderson, Radoslaw Biernacki,
	Igor Mitsyanko, Paul Zimmerman, open list:New World,
	David Gibson, Paolo Bonzini

On Sat, Jul 4, 2020 at 7:53 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> "qemu/error-report.h" and "qemu/main-loop.h" are not used.
> Remove them.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/usb/hcd-dwc2.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/hw/usb/hcd-dwc2.c b/hw/usb/hcd-dwc2.c
> index 72cbd051f3..590e75b455 100644
> --- a/hw/usb/hcd-dwc2.c
> +++ b/hw/usb/hcd-dwc2.c
> @@ -39,8 +39,6 @@
>  #include "migration/vmstate.h"
>  #include "trace.h"
>  #include "qemu/log.h"
> -#include "qemu/error-report.h"
> -#include "qemu/main-loop.h"
>  #include "hw/qdev-properties.h"
>
>  #define USB_HZ_FS       12000000
> --
> 2.21.3
>
>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 07/26] hw/usb/hcd-dwc2: Restrict some headers to source
  2020-07-04 14:49 ` [PATCH 07/26] hw/usb/hcd-dwc2: Restrict some headers to source Philippe Mathieu-Daudé
@ 2020-07-06 16:54   ` Alistair Francis
  2020-07-06 23:27   ` Paul Zimmerman
  1 sibling, 0 replies; 63+ messages in thread
From: Alistair Francis @ 2020-07-06 16:54 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel@nongnu.org Developers, BALATON Zoltan, Gerd Hoffmann,
	Edgar E. Iglesias, Huacai Chen, Stefano Stabellini,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Anthony Perard, open list:X86,
	Leif Lindholm, Philippe Mathieu-Daudé,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani,
	Marc-André Lureau, Niek Linnenbank, qemu-arm,
	Samuel Thibault, Richard Henderson, Radoslaw Biernacki,
	Igor Mitsyanko, Paul Zimmerman, open list:New World,
	David Gibson, Paolo Bonzini

On Sat, Jul 4, 2020 at 7:52 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> The header "usb/hcd-dwc2.h" doesn't need to include "qemu/timer.h",
> "sysemu/dma.h", "hw/irq.h" (the types required are forward declared).
> Include them in the source file which is the only one requiring the
> function declarations.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/usb/hcd-dwc2.h | 3 ---
>  hw/usb/hcd-dwc2.c | 3 +++
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/hw/usb/hcd-dwc2.h b/hw/usb/hcd-dwc2.h
> index 4ba809a07b..2adf0f53c7 100644
> --- a/hw/usb/hcd-dwc2.h
> +++ b/hw/usb/hcd-dwc2.h
> @@ -19,11 +19,8 @@
>  #ifndef HW_USB_DWC2_H
>  #define HW_USB_DWC2_H
>
> -#include "qemu/timer.h"
> -#include "hw/irq.h"
>  #include "hw/sysbus.h"
>  #include "hw/usb.h"
> -#include "sysemu/dma.h"
>
>  #define DWC2_MMIO_SIZE      0x11000
>
> diff --git a/hw/usb/hcd-dwc2.c b/hw/usb/hcd-dwc2.c
> index 590e75b455..ccf05d0823 100644
> --- a/hw/usb/hcd-dwc2.c
> +++ b/hw/usb/hcd-dwc2.c
> @@ -36,8 +36,11 @@
>  #include "qapi/error.h"
>  #include "hw/usb/dwc2-regs.h"
>  #include "hw/usb/hcd-dwc2.h"
> +#include "hw/irq.h"
> +#include "sysemu/dma.h"
>  #include "migration/vmstate.h"
>  #include "trace.h"
> +#include "qemu/timer.h"
>  #include "qemu/log.h"
>  #include "hw/qdev-properties.h"
>
> --
> 2.21.3
>
>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 05/26] hw/usb/desc: Add missing header
  2020-07-04 14:49 ` [PATCH 05/26] hw/usb/desc: Add missing header Philippe Mathieu-Daudé
@ 2020-07-06 16:55   ` Alistair Francis
  0 siblings, 0 replies; 63+ messages in thread
From: Alistair Francis @ 2020-07-06 16:55 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel@nongnu.org Developers, BALATON Zoltan, Gerd Hoffmann,
	Edgar E. Iglesias, Huacai Chen, Stefano Stabellini,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Anthony Perard, open list:X86,
	Leif Lindholm, Philippe Mathieu-Daudé,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani,
	Marc-André Lureau, Niek Linnenbank, qemu-arm,
	Samuel Thibault, Richard Henderson, Radoslaw Biernacki,
	Igor Mitsyanko, Paul Zimmerman, open list:New World,
	David Gibson, Paolo Bonzini

On Sat, Jul 4, 2020 at 7:52 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> This header uses the USBPacket and USBDevice types which are
> forward declared in "hw/usb.h".
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/usb/desc.h | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/hw/usb/desc.h b/hw/usb/desc.h
> index 4d81c68e0e..92594fbe29 100644
> --- a/hw/usb/desc.h
> +++ b/hw/usb/desc.h
> @@ -2,6 +2,7 @@
>  #define QEMU_HW_USB_DESC_H
>
>  #include <wchar.h>
> +#include "hw/usb.h"
>
>  /* binary representation */
>  typedef struct USBDescriptor {
> --
> 2.21.3
>
>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 09/26] hw/usb/hcd-ehci: Remove unnecessary include
  2020-07-04 14:49 ` [PATCH 09/26] hw/usb/hcd-ehci: Remove unnecessary include Philippe Mathieu-Daudé
@ 2020-07-06 16:56   ` Alistair Francis
  0 siblings, 0 replies; 63+ messages in thread
From: Alistair Francis @ 2020-07-06 16:56 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel@nongnu.org Developers, BALATON Zoltan, Gerd Hoffmann,
	Edgar E. Iglesias, Huacai Chen, Stefano Stabellini,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Anthony Perard, open list:X86,
	Leif Lindholm, Philippe Mathieu-Daudé,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani,
	Marc-André Lureau, Niek Linnenbank, qemu-arm,
	Samuel Thibault, Richard Henderson, Radoslaw Biernacki,
	Igor Mitsyanko, Paul Zimmerman, open list:New World,
	David Gibson, Paolo Bonzini

On Sat, Jul 4, 2020 at 7:55 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> As "qemu/main-loop.h" is not used, remove it.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/usb/hcd-ehci.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
> index 1495e8f7fa..256fb91e0c 100644
> --- a/hw/usb/hcd-ehci.c
> +++ b/hw/usb/hcd-ehci.c
> @@ -34,7 +34,6 @@
>  #include "migration/vmstate.h"
>  #include "trace.h"
>  #include "qemu/error-report.h"
> -#include "qemu/main-loop.h"
>  #include "sysemu/runstate.h"
>
>  #define FRAME_TIMER_FREQ 1000
> --
> 2.21.3
>
>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 11/26] hw/usb/hcd-xhci: Add missing header
  2020-07-04 14:49 ` [PATCH 11/26] hw/usb/hcd-xhci: Add missing header Philippe Mathieu-Daudé
@ 2020-07-06 16:57   ` Alistair Francis
  0 siblings, 0 replies; 63+ messages in thread
From: Alistair Francis @ 2020-07-06 16:57 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel@nongnu.org Developers, BALATON Zoltan, Gerd Hoffmann,
	Edgar E. Iglesias, Huacai Chen, Stefano Stabellini,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Anthony Perard, open list:X86,
	Leif Lindholm, Philippe Mathieu-Daudé,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani,
	Marc-André Lureau, Niek Linnenbank, qemu-arm,
	Samuel Thibault, Richard Henderson, Radoslaw Biernacki,
	Igor Mitsyanko, Paul Zimmerman, open list:New World,
	David Gibson, Paolo Bonzini

On Sat, Jul 4, 2020 at 7:54 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> This header uses the USBPort type which is forward declared
> by "hw/usb.h".
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/usb/hcd-xhci.h | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/hw/usb/hcd-xhci.h b/hw/usb/hcd-xhci.h
> index 946af51fc2..8edbdc2c3e 100644
> --- a/hw/usb/hcd-xhci.h
> +++ b/hw/usb/hcd-xhci.h
> @@ -22,6 +22,8 @@
>  #ifndef HW_USB_HCD_XHCI_H
>  #define HW_USB_HCD_XHCI_H
>
> +#include "hw/usb.h"
> +
>  #define TYPE_XHCI "base-xhci"
>  #define TYPE_NEC_XHCI "nec-usb-xhci"
>  #define TYPE_QEMU_XHCI "qemu-xhci"
> --
> 2.21.3
>
>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 12/26] hw/usb/hcd-musb: Restrict header scope
  2020-07-04 14:49 ` [PATCH 12/26] hw/usb/hcd-musb: Restrict header scope Philippe Mathieu-Daudé
@ 2020-07-06 16:58   ` Alistair Francis
  0 siblings, 0 replies; 63+ messages in thread
From: Alistair Francis @ 2020-07-06 16:58 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel@nongnu.org Developers, BALATON Zoltan, Gerd Hoffmann,
	Edgar E. Iglesias, Huacai Chen, Stefano Stabellini,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Anthony Perard, open list:X86,
	Leif Lindholm, Philippe Mathieu-Daudé,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani,
	Marc-André Lureau, Niek Linnenbank, qemu-arm,
	Samuel Thibault, Richard Henderson, Radoslaw Biernacki,
	Igor Mitsyanko, Paul Zimmerman, open list:New World,
	David Gibson, Paolo Bonzini

On Sat, Jul 4, 2020 at 7:56 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> "hcd-musb.h" is only required by USB device implementions.
> As we keep these implementations in the hw/usb/ directory,
> move the header there.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  {include/hw => hw}/usb/hcd-musb.h | 0
>  hw/usb/hcd-musb.c                 | 2 +-
>  hw/usb/tusb6010.c                 | 2 +-
>  3 files changed, 2 insertions(+), 2 deletions(-)
>  rename {include/hw => hw}/usb/hcd-musb.h (100%)
>
> diff --git a/include/hw/usb/hcd-musb.h b/hw/usb/hcd-musb.h
> similarity index 100%
> rename from include/hw/usb/hcd-musb.h
> rename to hw/usb/hcd-musb.h
> diff --git a/hw/usb/hcd-musb.c b/hw/usb/hcd-musb.c
> index 85f5ff5bd4..b8d8766a4a 100644
> --- a/hw/usb/hcd-musb.c
> +++ b/hw/usb/hcd-musb.c
> @@ -23,9 +23,9 @@
>  #include "qemu/osdep.h"
>  #include "qemu/timer.h"
>  #include "hw/usb.h"
> -#include "hw/usb/hcd-musb.h"
>  #include "hw/irq.h"
>  #include "hw/hw.h"
> +#include "hcd-musb.h"
>
>  /* Common USB registers */
>  #define MUSB_HDRC_FADDR                0x00    /* 8-bit */
> diff --git a/hw/usb/tusb6010.c b/hw/usb/tusb6010.c
> index 27eb28d3e4..9f9b81b09d 100644
> --- a/hw/usb/tusb6010.c
> +++ b/hw/usb/tusb6010.c
> @@ -23,11 +23,11 @@
>  #include "qemu/module.h"
>  #include "qemu/timer.h"
>  #include "hw/usb.h"
> -#include "hw/usb/hcd-musb.h"
>  #include "hw/arm/omap.h"
>  #include "hw/hw.h"
>  #include "hw/irq.h"
>  #include "hw/sysbus.h"
> +#include "hcd-musb.h"
>
>  #define TYPE_TUSB6010 "tusb6010"
>  #define TUSB(obj) OBJECT_CHECK(TUSBState, (obj), TYPE_TUSB6010)
> --
> 2.21.3
>
>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 10/26] hw/usb/hcd-ehci: Move few definitions from header to source
  2020-07-04 14:49 ` [PATCH 10/26] hw/usb/hcd-ehci: Move few definitions from header to source Philippe Mathieu-Daudé
@ 2020-07-06 17:00   ` Alistair Francis
  0 siblings, 0 replies; 63+ messages in thread
From: Alistair Francis @ 2020-07-06 17:00 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel@nongnu.org Developers, BALATON Zoltan, Gerd Hoffmann,
	Edgar E. Iglesias, Huacai Chen, Stefano Stabellini,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Anthony Perard, open list:X86,
	Leif Lindholm, Philippe Mathieu-Daudé,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani,
	Marc-André Lureau, Niek Linnenbank, qemu-arm,
	Samuel Thibault, Richard Henderson, Radoslaw Biernacki,
	Igor Mitsyanko, Paul Zimmerman, open list:New World,
	David Gibson, Paolo Bonzini

On Sat, Jul 4, 2020 at 7:53 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> Move definitions only useful for hcd-ehci.c to this source file.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/usb/hcd-ehci.h | 11 -----------
>  hw/usb/hcd-ehci.c | 12 ++++++++++++
>  2 files changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h
> index 57b38cfc05..4577f5e31d 100644
> --- a/hw/usb/hcd-ehci.h
> +++ b/hw/usb/hcd-ehci.h
> @@ -24,17 +24,6 @@
>  #include "hw/pci/pci.h"
>  #include "hw/sysbus.h"
>
> -#ifndef EHCI_DEBUG
> -#define EHCI_DEBUG   0
> -#endif
> -
> -#if EHCI_DEBUG
> -#define DPRINTF printf
> -#else
> -#define DPRINTF(...)
> -#endif
> -
> -#define MMIO_SIZE        0x1000
>  #define CAPA_SIZE        0x10
>
>  #define NB_PORTS         6        /* Max. Number of downstream ports */
> diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
> index 256fb91e0c..a0beee527c 100644
> --- a/hw/usb/hcd-ehci.c
> +++ b/hw/usb/hcd-ehci.c
> @@ -36,6 +36,18 @@
>  #include "qemu/error-report.h"
>  #include "sysemu/runstate.h"
>
> +#ifndef EHCI_DEBUG
> +#define EHCI_DEBUG   0
> +#endif
> +
> +#if EHCI_DEBUG
> +#define DPRINTF printf
> +#else
> +#define DPRINTF(...)
> +#endif
> +
> +#define MMIO_SIZE        0x1000
> +
>  #define FRAME_TIMER_FREQ 1000
>  #define FRAME_TIMER_NS   (NANOSECONDS_PER_SECOND / FRAME_TIMER_FREQ)
>  #define UFRAME_TIMER_NS  (FRAME_TIMER_NS / 8)
> --
> 2.21.3
>
>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 13/26] hw/usb/desc: Reduce some declarations scope
  2020-07-04 14:49 ` [PATCH 13/26] hw/usb/desc: Reduce some declarations scope Philippe Mathieu-Daudé
@ 2020-07-06 17:00   ` Alistair Francis
  0 siblings, 0 replies; 63+ messages in thread
From: Alistair Francis @ 2020-07-06 17:00 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel@nongnu.org Developers, BALATON Zoltan, Gerd Hoffmann,
	Edgar E. Iglesias, Huacai Chen, Stefano Stabellini,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Anthony Perard, open list:X86,
	Leif Lindholm, Philippe Mathieu-Daudé,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani,
	Marc-André Lureau, Niek Linnenbank, qemu-arm,
	Samuel Thibault, Richard Henderson, Radoslaw Biernacki,
	Igor Mitsyanko, Paul Zimmerman, open list:New World,
	David Gibson, Paolo Bonzini

On Sat, Jul 4, 2020 at 7:59 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> USBDescString is forward-declared. Only bus.c uses the
> usb_device_get_product_desc() and usb_device_get_usb_desc()
> function. Move all that to the "desc.h" header to reduce
> the big "hw/usb.h" header a bit.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/usb/desc.h    | 10 ++++++++++
>  include/hw/usb.h | 10 ----------
>  hw/usb/bus.c     |  1 +
>  3 files changed, 11 insertions(+), 10 deletions(-)
>
> diff --git a/hw/usb/desc.h b/hw/usb/desc.h
> index 92594fbe29..4bf6966c4b 100644
> --- a/hw/usb/desc.h
> +++ b/hw/usb/desc.h
> @@ -242,4 +242,14 @@ int usb_desc_get_descriptor(USBDevice *dev, USBPacket *p,
>  int usb_desc_handle_control(USBDevice *dev, USBPacket *p,
>          int request, int value, int index, int length, uint8_t *data);
>
> +const char *usb_device_get_product_desc(USBDevice *dev);
> +
> +const USBDesc *usb_device_get_usb_desc(USBDevice *dev);
> +
> +struct USBDescString {
> +    uint8_t index;
> +    char *str;
> +    QLIST_ENTRY(USBDescString) next;
> +};
> +
>  #endif /* QEMU_HW_USB_DESC_H */
> diff --git a/include/hw/usb.h b/include/hw/usb.h
> index 15b2ef300a..18f1349bdc 100644
> --- a/include/hw/usb.h
> +++ b/include/hw/usb.h
> @@ -192,12 +192,6 @@ typedef struct USBDescOther USBDescOther;
>  typedef struct USBDescString USBDescString;
>  typedef struct USBDescMSOS USBDescMSOS;
>
> -struct USBDescString {
> -    uint8_t index;
> -    char *str;
> -    QLIST_ENTRY(USBDescString) next;
> -};
> -
>  #define USB_MAX_ENDPOINTS  15
>  #define USB_MAX_INTERFACES 16
>
> @@ -555,10 +549,6 @@ int usb_device_alloc_streams(USBDevice *dev, USBEndpoint **eps, int nr_eps,
>                               int streams);
>  void usb_device_free_streams(USBDevice *dev, USBEndpoint **eps, int nr_eps);
>
> -const char *usb_device_get_product_desc(USBDevice *dev);
> -
> -const USBDesc *usb_device_get_usb_desc(USBDevice *dev);
> -
>  /* quirks.c */
>
>  /* In bulk endpoints are streaming data sources (iow behave like isoc eps) */
> diff --git a/hw/usb/bus.c b/hw/usb/bus.c
> index 957559b18d..111c3af7c1 100644
> --- a/hw/usb/bus.c
> +++ b/hw/usb/bus.c
> @@ -9,6 +9,7 @@
>  #include "monitor/monitor.h"
>  #include "trace.h"
>  #include "qemu/cutils.h"
> +#include "desc.h"
>
>  static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent);
>
> --
> 2.21.3
>
>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 14/26] hw/usb/quirks: Rename included source with '.inc.c' suffix
  2020-07-04 14:49 ` [PATCH 14/26] hw/usb/quirks: Rename included source with '.inc.c' suffix Philippe Mathieu-Daudé
@ 2020-07-06 17:02   ` Alistair Francis
  0 siblings, 0 replies; 63+ messages in thread
From: Alistair Francis @ 2020-07-06 17:02 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel@nongnu.org Developers, BALATON Zoltan, Gerd Hoffmann,
	Edgar E. Iglesias, Huacai Chen, Stefano Stabellini,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Anthony Perard, open list:X86,
	Leif Lindholm, Philippe Mathieu-Daudé,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani,
	Marc-André Lureau, Niek Linnenbank, qemu-arm,
	Samuel Thibault, Richard Henderson, Radoslaw Biernacki,
	Igor Mitsyanko, Paul Zimmerman, open list:New World,
	David Gibson, Paolo Bonzini

On Sat, Jul 4, 2020 at 7:58 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> This file is not a header, but contains source code which is
> included and compiled once. We use the '.inc.c' suffix in few
> other cases in the repository. Follow the same convention with
> this file.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/usb/quirks.c                   | 2 +-
>  hw/usb/{quirks.h => quirks.inc.c} | 5 -----
>  2 files changed, 1 insertion(+), 6 deletions(-)
>  rename hw/usb/{quirks.h => quirks.inc.c} (99%)
>
> diff --git a/hw/usb/quirks.c b/hw/usb/quirks.c
> index 23ea7a23ea..655b36f2d5 100644
> --- a/hw/usb/quirks.c
> +++ b/hw/usb/quirks.c
> @@ -13,7 +13,7 @@
>   */
>
>  #include "qemu/osdep.h"
> -#include "quirks.h"
> +#include "quirks.inc.c"
>  #include "hw/usb.h"
>
>  static bool usb_id_match(const struct usb_device_id *ids,
> diff --git a/hw/usb/quirks.h b/hw/usb/quirks.inc.c
> similarity index 99%
> rename from hw/usb/quirks.h
> rename to hw/usb/quirks.inc.c
> index 50ef2f9c2e..004b228aba 100644
> --- a/hw/usb/quirks.h
> +++ b/hw/usb/quirks.inc.c
> @@ -12,9 +12,6 @@
>   * (at your option) any later version.
>   */
>
> -#ifndef HW_USB_QUIRKS_H
> -#define HW_USB_QUIRKS_H
> -
>  /* 1 on 1 copy of linux/drivers/usb/serial/ftdi_sio_ids.h */
>  #include "quirks-ftdi-ids.h"
>  /* 1 on 1 copy of linux/drivers/usb/serial/pl2303.h */
> @@ -915,5 +912,3 @@ static const struct usb_device_id usbredir_ftdi_serial_ids[] = {
>
>  #undef USB_DEVICE
>  #undef USB_DEVICE_AND_INTERFACE_INFO
> -
> -#endif
> --
> 2.21.3
>
>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 15/26] hw/usb: Add new 'usb-quirks.h' local header
  2020-07-04 14:49 ` [PATCH 15/26] hw/usb: Add new 'usb-quirks.h' local header Philippe Mathieu-Daudé
@ 2020-07-06 17:45   ` Alistair Francis
  0 siblings, 0 replies; 63+ messages in thread
From: Alistair Francis @ 2020-07-06 17:45 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel@nongnu.org Developers, BALATON Zoltan, Gerd Hoffmann,
	Edgar E. Iglesias, Huacai Chen, Stefano Stabellini,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Anthony Perard, open list:X86,
	Leif Lindholm, Philippe Mathieu-Daudé,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani,
	Marc-André Lureau, Niek Linnenbank, qemu-arm,
	Samuel Thibault, Richard Henderson, Radoslaw Biernacki,
	Igor Mitsyanko, Paul Zimmerman, open list:New World,
	David Gibson, Paolo Bonzini

On Sat, Jul 4, 2020 at 7:56 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> Only redirect.c consumes the quirks API. Reduce the big "hw/usb.h"
> header by moving the quirks related declaration into their own
> header. As nothing out of hw/usb/ requires it, keep it local.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/usb/usb-quirks.h | 27 +++++++++++++++++++++++++++
>  include/hw/usb.h    | 11 -----------
>  hw/usb/quirks.c     |  1 +
>  hw/usb/redirect.c   |  1 +
>  4 files changed, 29 insertions(+), 11 deletions(-)
>  create mode 100644 hw/usb/usb-quirks.h
>
> diff --git a/hw/usb/usb-quirks.h b/hw/usb/usb-quirks.h
> new file mode 100644
> index 0000000000..542889efc4
> --- /dev/null
> +++ b/hw/usb/usb-quirks.h
> @@ -0,0 +1,27 @@
> +/*
> + * USB quirk handling
> + *
> + * Copyright (c) 2012 Red Hat, Inc.
> + *
> + * Red Hat Authors:
> + * Hans de Goede <hdegoede@redhat.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + */
> +
> +#ifndef HW_USB_QUIRKS_H
> +#define HW_USB_QUIRKS_H
> +
> +/* In bulk endpoints are streaming data sources (iow behave like isoc eps) */
> +#define USB_QUIRK_BUFFER_BULK_IN        0x01
> +/* Bulk pkts in FTDI format, need special handling when combining packets */
> +#define USB_QUIRK_IS_FTDI               0x02
> +
> +int usb_get_quirks(uint16_t vendor_id, uint16_t product_id,
> +                   uint8_t interface_class, uint8_t interface_subclass,
> +                   uint8_t interface_protocol);
> +
> +#endif
> diff --git a/include/hw/usb.h b/include/hw/usb.h
> index 18f1349bdc..8c3bc920ff 100644
> --- a/include/hw/usb.h
> +++ b/include/hw/usb.h
> @@ -549,15 +549,4 @@ int usb_device_alloc_streams(USBDevice *dev, USBEndpoint **eps, int nr_eps,
>                               int streams);
>  void usb_device_free_streams(USBDevice *dev, USBEndpoint **eps, int nr_eps);
>
> -/* quirks.c */
> -
> -/* In bulk endpoints are streaming data sources (iow behave like isoc eps) */
> -#define USB_QUIRK_BUFFER_BULK_IN       0x01
> -/* Bulk pkts in FTDI format, need special handling when combining packets */
> -#define USB_QUIRK_IS_FTDI              0x02
> -
> -int usb_get_quirks(uint16_t vendor_id, uint16_t product_id,
> -                   uint8_t interface_class, uint8_t interface_subclass,
> -                   uint8_t interface_protocol);
> -
>  #endif
> diff --git a/hw/usb/quirks.c b/hw/usb/quirks.c
> index 655b36f2d5..b0d0f87e35 100644
> --- a/hw/usb/quirks.c
> +++ b/hw/usb/quirks.c
> @@ -15,6 +15,7 @@
>  #include "qemu/osdep.h"
>  #include "quirks.inc.c"
>  #include "hw/usb.h"
> +#include "usb-quirks.h"
>
>  static bool usb_id_match(const struct usb_device_id *ids,
>                           uint16_t vendor_id, uint16_t product_id,
> diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
> index 417a60a2e6..4c5925a039 100644
> --- a/hw/usb/redirect.c
> +++ b/hw/usb/redirect.c
> @@ -45,6 +45,7 @@
>  #include "hw/usb.h"
>  #include "migration/qemu-file-types.h"
>  #include "migration/vmstate.h"
> +#include "usb-quirks.h"
>
>  /* ERROR is defined below. Remove any previous definition. */
>  #undef ERROR
> --
> 2.21.3
>
>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 16/26] hw/usb/bus: Simplify usb_get_dev_path()
  2020-07-04 14:49 ` [PATCH 16/26] hw/usb/bus: Simplify usb_get_dev_path() Philippe Mathieu-Daudé
@ 2020-07-06 17:46   ` Alistair Francis
  0 siblings, 0 replies; 63+ messages in thread
From: Alistair Francis @ 2020-07-06 17:46 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel@nongnu.org Developers, BALATON Zoltan, Gerd Hoffmann,
	Edgar E. Iglesias, Huacai Chen, Stefano Stabellini,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Anthony Perard, open list:X86,
	Leif Lindholm, Philippe Mathieu-Daudé,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani,
	Marc-André Lureau, Niek Linnenbank, qemu-arm,
	Samuel Thibault, Richard Henderson, Radoslaw Biernacki,
	Igor Mitsyanko, Paul Zimmerman, open list:New World,
	David Gibson, Paolo Bonzini

On Sat, Jul 4, 2020 at 8:00 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> Simplify usb_get_dev_path() a bit.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/usb/bus.c | 19 +++++++++----------
>  1 file changed, 9 insertions(+), 10 deletions(-)
>
> diff --git a/hw/usb/bus.c b/hw/usb/bus.c
> index 111c3af7c1..f8901e822c 100644
> --- a/hw/usb/bus.c
> +++ b/hw/usb/bus.c
> @@ -580,19 +580,18 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)
>  static char *usb_get_dev_path(DeviceState *qdev)
>  {
>      USBDevice *dev = USB_DEVICE(qdev);
> -    DeviceState *hcd = qdev->parent_bus->parent;
> -    char *id = NULL;
>
>      if (dev->flags & (1 << USB_DEV_FLAG_FULL_PATH)) {
> -        id = qdev_get_dev_path(hcd);
> -    }
> -    if (id) {
> -        char *ret = g_strdup_printf("%s/%s", id, dev->port->path);
> -        g_free(id);
> -        return ret;
> -    } else {
> -        return g_strdup(dev->port->path);
> +        DeviceState *hcd = qdev->parent_bus->parent;
> +        char *id = qdev_get_dev_path(hcd);
> +
> +        if (id) {
> +            char *ret = g_strdup_printf("%s/%s", id, dev->port->path);
> +            g_free(id);
> +            return ret;
> +        }
>      }
> +    return g_strdup(dev->port->path);
>  }
>
>  static char *usb_get_fw_dev_path(DeviceState *qdev)
> --
> 2.21.3
>
>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 17/26] hw/usb/bus: Rename usb_get_dev_path() as usb_get_full_dev_path()
  2020-07-04 14:49 ` [PATCH 17/26] hw/usb/bus: Rename usb_get_dev_path() as usb_get_full_dev_path() Philippe Mathieu-Daudé
@ 2020-07-06 17:46   ` Alistair Francis
  0 siblings, 0 replies; 63+ messages in thread
From: Alistair Francis @ 2020-07-06 17:46 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel@nongnu.org Developers, BALATON Zoltan, Gerd Hoffmann,
	Edgar E. Iglesias, Huacai Chen, Stefano Stabellini,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Anthony Perard, open list:X86,
	Leif Lindholm, Philippe Mathieu-Daudé,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani,
	Marc-André Lureau, Niek Linnenbank, qemu-arm,
	Samuel Thibault, Richard Henderson, Radoslaw Biernacki,
	Igor Mitsyanko, Paul Zimmerman, open list:New World,
	David Gibson, Paolo Bonzini

On Sat, Jul 4, 2020 at 7:58 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> If the device has USB_DEV_FLAG_FULL_PATH set, usb_get_dev_path()
> returns the full port path. Rename the function accordingly.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/usb/bus.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/hw/usb/bus.c b/hw/usb/bus.c
> index f8901e822c..fad8194bf5 100644
> --- a/hw/usb/bus.c
> +++ b/hw/usb/bus.c
> @@ -13,7 +13,7 @@
>
>  static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent);
>
> -static char *usb_get_dev_path(DeviceState *dev);
> +static char *usb_get_full_dev_path(DeviceState *dev);
>  static char *usb_get_fw_dev_path(DeviceState *qdev);
>  static void usb_qdev_unrealize(DeviceState *qdev);
>
> @@ -33,7 +33,7 @@ static void usb_bus_class_init(ObjectClass *klass, void *data)
>      HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
>
>      k->print_dev = usb_bus_dev_print;
> -    k->get_dev_path = usb_get_dev_path;
> +    k->get_dev_path = usb_get_full_dev_path;
>      k->get_fw_dev_path = usb_get_fw_dev_path;
>      hc->unplug = qdev_simple_device_unplug_cb;
>  }
> @@ -577,7 +577,7 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)
>                     dev->attached ? ", attached" : "");
>  }
>
> -static char *usb_get_dev_path(DeviceState *qdev)
> +static char *usb_get_full_dev_path(DeviceState *qdev)
>  {
>      USBDevice *dev = USB_DEVICE(qdev);
>
> --
> 2.21.3
>
>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 07/26] hw/usb/hcd-dwc2: Restrict some headers to source
  2020-07-04 14:49 ` [PATCH 07/26] hw/usb/hcd-dwc2: Restrict some headers to source Philippe Mathieu-Daudé
  2020-07-06 16:54   ` Alistair Francis
@ 2020-07-06 23:27   ` Paul Zimmerman
  1 sibling, 0 replies; 63+ messages in thread
From: Paul Zimmerman @ 2020-07-06 23:27 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	QEMU Developers, Jiaxun Yang, BALATON Zoltan, Gerd Hoffmann,
	Edgar E. Iglesias, Huacai Chen, Stefano Stabellini, xen-devel,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Marcel Apfelbaum, Anthony Perard,
	Samuel Thibault, Leif Lindholm, Andrzej Zaborowski,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani, Niek Linnenbank,
	qemu-arm, Marc-André Lureau, Richard Henderson,
	Radoslaw Biernacki, Igor Mitsyanko, Philippe Mathieu-Daudé,
	qemu-ppc, David Gibson, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 1451 bytes --]

On Sat, Jul 4, 2020 at 7:50 AM Philippe Mathieu-Daudé <f4bug@amsat.org>
wrote:

> The header "usb/hcd-dwc2.h" doesn't need to include "qemu/timer.h",
> "sysemu/dma.h", "hw/irq.h" (the types required are forward declared).
> Include them in the source file which is the only one requiring the
> function declarations.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  hw/usb/hcd-dwc2.h | 3 ---
>  hw/usb/hcd-dwc2.c | 3 +++
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/hw/usb/hcd-dwc2.h b/hw/usb/hcd-dwc2.h
> index 4ba809a07b..2adf0f53c7 100644
> --- a/hw/usb/hcd-dwc2.h
> +++ b/hw/usb/hcd-dwc2.h
> @@ -19,11 +19,8 @@
>  #ifndef HW_USB_DWC2_H
>  #define HW_USB_DWC2_H
>
> -#include "qemu/timer.h"
> -#include "hw/irq.h"
>  #include "hw/sysbus.h"
>  #include "hw/usb.h"
> -#include "sysemu/dma.h"
>
>  #define DWC2_MMIO_SIZE      0x11000
>
> diff --git a/hw/usb/hcd-dwc2.c b/hw/usb/hcd-dwc2.c
> index 590e75b455..ccf05d0823 100644
> --- a/hw/usb/hcd-dwc2.c
> +++ b/hw/usb/hcd-dwc2.c
> @@ -36,8 +36,11 @@
>  #include "qapi/error.h"
>  #include "hw/usb/dwc2-regs.h"
>  #include "hw/usb/hcd-dwc2.h"
> +#include "hw/irq.h"
> +#include "sysemu/dma.h"
>  #include "migration/vmstate.h"
>  #include "trace.h"
> +#include "qemu/timer.h"
>  #include "qemu/log.h"
>  #include "hw/qdev-properties.h"
>
> --
> 2.21.3
>
>
Reviewed-by: Paul Zimmerman <pauldzim@gmail.com>

[-- Attachment #2: Type: text/html, Size: 2422 bytes --]

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 06/26] hw/usb/hcd-dwc2: Remove unnecessary includes
  2020-07-04 14:49 ` [PATCH 06/26] hw/usb/hcd-dwc2: Remove unnecessary includes Philippe Mathieu-Daudé
  2020-07-06 16:54   ` Alistair Francis
@ 2020-07-06 23:28   ` Paul Zimmerman
  1 sibling, 0 replies; 63+ messages in thread
From: Paul Zimmerman @ 2020-07-06 23:28 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	QEMU Developers, Jiaxun Yang, BALATON Zoltan, Gerd Hoffmann,
	Edgar E. Iglesias, Huacai Chen, Stefano Stabellini, xen-devel,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Marcel Apfelbaum, Anthony Perard,
	Samuel Thibault, Leif Lindholm, Andrzej Zaborowski,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani, Niek Linnenbank,
	qemu-arm, Marc-André Lureau, Richard Henderson,
	Radoslaw Biernacki, Igor Mitsyanko, Philippe Mathieu-Daudé,
	qemu-ppc, David Gibson, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 766 bytes --]

On Sat, Jul 4, 2020 at 7:50 AM Philippe Mathieu-Daudé <f4bug@amsat.org>
wrote:

> "qemu/error-report.h" and "qemu/main-loop.h" are not used.
> Remove them.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  hw/usb/hcd-dwc2.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/hw/usb/hcd-dwc2.c b/hw/usb/hcd-dwc2.c
> index 72cbd051f3..590e75b455 100644
> --- a/hw/usb/hcd-dwc2.c
> +++ b/hw/usb/hcd-dwc2.c
> @@ -39,8 +39,6 @@
>  #include "migration/vmstate.h"
>  #include "trace.h"
>  #include "qemu/log.h"
> -#include "qemu/error-report.h"
> -#include "qemu/main-loop.h"
>  #include "hw/qdev-properties.h"
>
>  #define USB_HZ_FS       12000000
> --
> 2.21.3
>
>
Reviewed-by: Paul Zimmerman <pauldzim@gmail.com>

[-- Attachment #2: Type: text/html, Size: 1692 bytes --]

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 08/26] hw/usb/hcd-dwc2: Restrict 'dwc2-regs.h' scope
  2020-07-04 14:49 ` [PATCH 08/26] hw/usb/hcd-dwc2: Restrict 'dwc2-regs.h' scope Philippe Mathieu-Daudé
  2020-07-06 16:47   ` Alistair Francis
@ 2020-07-06 23:29   ` Paul Zimmerman
  1 sibling, 0 replies; 63+ messages in thread
From: Paul Zimmerman @ 2020-07-06 23:29 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	QEMU Developers, Jiaxun Yang, BALATON Zoltan, Gerd Hoffmann,
	Edgar E. Iglesias, Huacai Chen, Stefano Stabellini, xen-devel,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Marcel Apfelbaum, Anthony Perard,
	Samuel Thibault, Leif Lindholm, Andrzej Zaborowski,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani, Niek Linnenbank,
	qemu-arm, Marc-André Lureau, Richard Henderson,
	Radoslaw Biernacki, Igor Mitsyanko, Philippe Mathieu-Daudé,
	qemu-ppc, David Gibson, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 1297 bytes --]

On Sat, Jul 4, 2020 at 7:50 AM Philippe Mathieu-Daudé <f4bug@amsat.org>
wrote:

> We only use these register definitions in files under the
> hw/usb/ directory. Keep that header local by moving it there.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  {include/hw => hw}/usb/dwc2-regs.h | 0
>  hw/usb/hcd-dwc2.c                  | 2 +-
>  2 files changed, 1 insertion(+), 1 deletion(-)
>  rename {include/hw => hw}/usb/dwc2-regs.h (100%)
>
> diff --git a/include/hw/usb/dwc2-regs.h b/hw/usb/dwc2-regs.h
> similarity index 100%
> rename from include/hw/usb/dwc2-regs.h
> rename to hw/usb/dwc2-regs.h
> diff --git a/hw/usb/hcd-dwc2.c b/hw/usb/hcd-dwc2.c
> index ccf05d0823..252b60ef65 100644
> --- a/hw/usb/hcd-dwc2.c
> +++ b/hw/usb/hcd-dwc2.c
> @@ -34,7 +34,6 @@
>  #include "qemu/osdep.h"
>  #include "qemu/units.h"
>  #include "qapi/error.h"
> -#include "hw/usb/dwc2-regs.h"
>  #include "hw/usb/hcd-dwc2.h"
>  #include "hw/irq.h"
>  #include "sysemu/dma.h"
> @@ -43,6 +42,7 @@
>  #include "qemu/timer.h"
>  #include "qemu/log.h"
>  #include "hw/qdev-properties.h"
> +#include "dwc2-regs.h"
>
>  #define USB_HZ_FS       12000000
>  #define USB_HZ_HS       96000000
> --
> 2.21.3
>
>
Reviewed-by: Paul Zimmerman <pauldzim@gmail.com>

[-- Attachment #2: Type: text/html, Size: 2306 bytes --]

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 18/26] hw/usb/bus: Add usb_get_port_path()
  2020-07-04 14:49 ` [PATCH 18/26] hw/usb/bus: Add usb_get_port_path() Philippe Mathieu-Daudé
@ 2020-07-07  0:07   ` Alistair Francis
  0 siblings, 0 replies; 63+ messages in thread
From: Alistair Francis @ 2020-07-07  0:07 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel@nongnu.org Developers, BALATON Zoltan, Gerd Hoffmann,
	Edgar E. Iglesias, Huacai Chen, Stefano Stabellini,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Anthony Perard, open list:X86,
	Leif Lindholm, Philippe Mathieu-Daudé,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani,
	Marc-André Lureau, Niek Linnenbank, qemu-arm,
	Samuel Thibault, Richard Henderson, Radoslaw Biernacki,
	Igor Mitsyanko, Paul Zimmerman, open list:New World,
	David Gibson, Paolo Bonzini

On Sat, Jul 4, 2020 at 8:00 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> Refactor usb_get_full_dev_path() to take a 'want_full_path'
> argument, and add usb_get_port_path() which returns a short
> path.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  include/hw/usb.h | 10 ++++++++++
>  hw/usb/bus.c     | 18 +++++++++++++-----
>  2 files changed, 23 insertions(+), 5 deletions(-)
>
> diff --git a/include/hw/usb.h b/include/hw/usb.h
> index 8c3bc920ff..7ea502d421 100644
> --- a/include/hw/usb.h
> +++ b/include/hw/usb.h
> @@ -506,6 +506,16 @@ void usb_port_location(USBPort *downstream, USBPort *upstream, int portnr);
>  void usb_unregister_port(USBBus *bus, USBPort *port);
>  void usb_claim_port(USBDevice *dev, Error **errp);
>  void usb_release_port(USBDevice *dev);
> +/**
> + * usb_get_port_path:
> + * @dev: the USB device
> + *
> + * The returned data must be released with g_free()
> + * when no longer required.
> + *
> + * Returns: a dynamically allocated pathname.
> + */
> +char *usb_get_port_path(USBDevice *dev);
>  void usb_device_attach(USBDevice *dev, Error **errp);
>  int usb_device_detach(USBDevice *dev);
>  void usb_check_attach(USBDevice *dev, Error **errp);
> diff --git a/hw/usb/bus.c b/hw/usb/bus.c
> index fad8194bf5..518e5b94ed 100644
> --- a/hw/usb/bus.c
> +++ b/hw/usb/bus.c
> @@ -577,12 +577,10 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)
>                     dev->attached ? ", attached" : "");
>  }
>
> -static char *usb_get_full_dev_path(DeviceState *qdev)
> +static char *usb_get_dev_path(USBDevice *dev, bool want_full_path)
>  {
> -    USBDevice *dev = USB_DEVICE(qdev);
> -
> -    if (dev->flags & (1 << USB_DEV_FLAG_FULL_PATH)) {
> -        DeviceState *hcd = qdev->parent_bus->parent;
> +    if (want_full_path && (dev->flags & (1 << USB_DEV_FLAG_FULL_PATH))) {
> +        DeviceState *hcd = DEVICE(dev)->parent_bus->parent;
>          char *id = qdev_get_dev_path(hcd);
>
>          if (id) {
> @@ -594,6 +592,16 @@ static char *usb_get_full_dev_path(DeviceState *qdev)
>      return g_strdup(dev->port->path);
>  }
>
> +static char *usb_get_full_dev_path(DeviceState *qdev)
> +{
> +    return usb_get_dev_path(USB_DEVICE(qdev), true);
> +}
> +
> +char *usb_get_port_path(USBDevice *dev)
> +{
> +    return usb_get_dev_path(dev, false);
> +}
> +
>  static char *usb_get_fw_dev_path(DeviceState *qdev)
>  {
>      USBDevice *dev = USB_DEVICE(qdev);
> --
> 2.21.3
>
>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 19/26] hw/ppc/spapr: Use usb_get_port_path()
  2020-07-04 14:49 ` [PATCH 19/26] hw/ppc/spapr: Use usb_get_port_path() Philippe Mathieu-Daudé
@ 2020-07-07  0:07   ` Alistair Francis
  0 siblings, 0 replies; 63+ messages in thread
From: Alistair Francis @ 2020-07-07  0:07 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel@nongnu.org Developers, BALATON Zoltan, Gerd Hoffmann,
	Edgar E. Iglesias, Huacai Chen, Stefano Stabellini,
	Yoshinori Sato, Paul Durrant, Magnus Damm, Markus Armbruster,
	Hervé Poussineau, Anthony Perard, open list:X86,
	Leif Lindholm, Philippe Mathieu-Daudé,
	Aleksandar Rikalo, Eduardo Habkost, Alistair Francis,
	Dr. David Alan Gilbert, Beniamino Galvani,
	Marc-André Lureau, Niek Linnenbank, qemu-arm,
	Samuel Thibault, Richard Henderson, Radoslaw Biernacki,
	Igor Mitsyanko, Paul Zimmerman, open list:New World,
	David Gibson, Paolo Bonzini

On Sat, Jul 4, 2020 at 7:59 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> To avoid to access the USBDevice internals, and use the
> recently added usb_get_port_path() helper instead.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/ppc/spapr.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index f6f034d039..221d3e7a8c 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -3121,7 +3121,8 @@ static char *spapr_get_fw_dev_path(FWPathProvider *p, BusState *bus,
>               * We use SRP luns of the form 01000000 | (usb-port << 16) | lun
>               * in the top 32 bits of the 64-bit LUN
>               */
> -            unsigned usb_port = atoi(usb->port->path);
> +            g_autofree char *usb_port_path = usb_get_port_path(usb);
> +            unsigned usb_port = atoi(usb_port_path);
>              unsigned id = 0x1000000 | (usb_port << 16) | d->lun;
>              return g_strdup_printf("%s@%"PRIX64, qdev_fw_name(dev),
>                                     (uint64_t)id << 32);
> @@ -3137,7 +3138,8 @@ static char *spapr_get_fw_dev_path(FWPathProvider *p, BusState *bus,
>      if (strcmp("usb-host", qdev_fw_name(dev)) == 0) {
>          USBDevice *usbdev = CAST(USBDevice, dev, TYPE_USB_DEVICE);
>          if (usb_host_dev_is_scsi_storage(usbdev)) {
> -            return g_strdup_printf("storage@%s/disk", usbdev->port->path);
> +            g_autofree char *usb_port_path = usb_get_port_path(usbdev);
> +            return g_strdup_printf("storage@%s/disk", usb_port_path);
>          }
>      }
>
> --
> 2.21.3
>
>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/
  2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
                   ` (25 preceding siblings ...)
  2020-07-04 14:49 ` [PATCH 26/26] MAINTAINERS: Cover dwc-hsotg (dwc2) USB host controller emulation Philippe Mathieu-Daudé
@ 2020-07-13  9:46 ` Gerd Hoffmann
  26 siblings, 0 replies; 63+ messages in thread
From: Gerd Hoffmann @ 2020-07-13  9:46 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel,
	Jiaxun Yang, BALATON Zoltan, Edgar E. Iglesias, Huacai Chen,
	Stefano Stabellini, xen-devel, Yoshinori Sato, Paul Durrant,
	Magnus Damm, Markus Armbruster, Hervé Poussineau,
	Marcel Apfelbaum, Anthony Perard, Samuel Thibault, Leif Lindholm,
	Andrzej Zaborowski, Aleksandar Rikalo, Eduardo Habkost,
	Alistair Francis, Dr. David Alan Gilbert, Beniamino Galvani,
	Niek Linnenbank, qemu-arm, Marc-André Lureau,
	Richard Henderson, Radoslaw Biernacki, Igor Mitsyanko,
	Philippe Mathieu-Daudé,
	Paul Zimmerman, qemu-ppc, David Gibson, Paolo Bonzini

On Sat, Jul 04, 2020 at 04:49:17PM +0200, Philippe Mathieu-Daudé wrote:
> Hi,
> 
> This is the second time I try to replace a magic typename string
> by a constant, and Zoltan warns me this is counter productive as
> "hw/usb.h" pulls in an insane amount of code.
> 
> Time to give the usb subsystem some love and move forward.
> 
> This series can be decomposed as follow:
> 
>  1-2:    preliminary machine cleanups (arm/ppc)
>  3-13:   usb related headers cleanups
>  14-15:  usb quirks cleanup
>  16-18:  refactor usb_get_dev_path() to add usb_get_port_path()
>  19:     let spapr use usb_get_port_path() to make USBDevice opaque
>  20:     extract the public USB API (for machine/board/soc)
>  21:     make the older "usb.h" internal to hw/usb/
>  22-25:  use TYPENAME definitions
>  26:     cover dwc2 in MAINTAINERS
> 
> Please review.

Looks good overall, I don't fell like squeezing this into 5.1 though.
Can you repost (with the few comments addressed) once 5.2 is open for
development in roughly a month?

thanks,
  Gerd



^ permalink raw reply	[flat|nested] 63+ messages in thread

end of thread, other threads:[~2020-07-13  9:47 UTC | newest]

Thread overview: 63+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
2020-07-04 14:49 ` [PATCH 01/26] hw/arm/sbsa-ref: Remove unused 'hw/usb.h' header Philippe Mathieu-Daudé
2020-07-06 16:49   ` Alistair Francis
2020-07-04 14:49 ` [PATCH 02/26] hw/ppc/sam460ex: Add missing 'hw/pci/pci.h' header Philippe Mathieu-Daudé
2020-07-06 16:50   ` Alistair Francis
2020-07-04 14:49 ` [PATCH 03/26] hw/usb: Remove unused VM_USB_HUB_SIZE definition Philippe Mathieu-Daudé
2020-07-06 16:51   ` Alistair Francis
2020-07-04 14:49 ` [PATCH 04/26] hw/usb: Reduce 'exec/memory.h' inclusion Philippe Mathieu-Daudé
2020-07-06 16:52   ` Alistair Francis
2020-07-04 14:49 ` [PATCH 05/26] hw/usb/desc: Add missing header Philippe Mathieu-Daudé
2020-07-06 16:55   ` Alistair Francis
2020-07-04 14:49 ` [PATCH 06/26] hw/usb/hcd-dwc2: Remove unnecessary includes Philippe Mathieu-Daudé
2020-07-06 16:54   ` Alistair Francis
2020-07-06 23:28   ` Paul Zimmerman
2020-07-04 14:49 ` [PATCH 07/26] hw/usb/hcd-dwc2: Restrict some headers to source Philippe Mathieu-Daudé
2020-07-06 16:54   ` Alistair Francis
2020-07-06 23:27   ` Paul Zimmerman
2020-07-04 14:49 ` [PATCH 08/26] hw/usb/hcd-dwc2: Restrict 'dwc2-regs.h' scope Philippe Mathieu-Daudé
2020-07-06 16:47   ` Alistair Francis
2020-07-06 23:29   ` Paul Zimmerman
2020-07-04 14:49 ` [PATCH 09/26] hw/usb/hcd-ehci: Remove unnecessary include Philippe Mathieu-Daudé
2020-07-06 16:56   ` Alistair Francis
2020-07-04 14:49 ` [PATCH 10/26] hw/usb/hcd-ehci: Move few definitions from header to source Philippe Mathieu-Daudé
2020-07-06 17:00   ` Alistair Francis
2020-07-04 14:49 ` [PATCH 11/26] hw/usb/hcd-xhci: Add missing header Philippe Mathieu-Daudé
2020-07-06 16:57   ` Alistair Francis
2020-07-04 14:49 ` [PATCH 12/26] hw/usb/hcd-musb: Restrict header scope Philippe Mathieu-Daudé
2020-07-06 16:58   ` Alistair Francis
2020-07-04 14:49 ` [PATCH 13/26] hw/usb/desc: Reduce some declarations scope Philippe Mathieu-Daudé
2020-07-06 17:00   ` Alistair Francis
2020-07-04 14:49 ` [PATCH 14/26] hw/usb/quirks: Rename included source with '.inc.c' suffix Philippe Mathieu-Daudé
2020-07-06 17:02   ` Alistair Francis
2020-07-04 14:49 ` [PATCH 15/26] hw/usb: Add new 'usb-quirks.h' local header Philippe Mathieu-Daudé
2020-07-06 17:45   ` Alistair Francis
2020-07-04 14:49 ` [PATCH 16/26] hw/usb/bus: Simplify usb_get_dev_path() Philippe Mathieu-Daudé
2020-07-06 17:46   ` Alistair Francis
2020-07-04 14:49 ` [PATCH 17/26] hw/usb/bus: Rename usb_get_dev_path() as usb_get_full_dev_path() Philippe Mathieu-Daudé
2020-07-06 17:46   ` Alistair Francis
2020-07-04 14:49 ` [PATCH 18/26] hw/usb/bus: Add usb_get_port_path() Philippe Mathieu-Daudé
2020-07-07  0:07   ` Alistair Francis
2020-07-04 14:49 ` [PATCH 19/26] hw/ppc/spapr: Use usb_get_port_path() Philippe Mathieu-Daudé
2020-07-07  0:07   ` Alistair Francis
2020-07-04 14:49 ` [PATCH 20/26] hw/usb: Introduce "hw/usb/usb.h" public API Philippe Mathieu-Daudé
2020-07-04 14:49 ` [PATCH 21/26] hw/usb: Move internal API to local 'usb-internal.h' header Philippe Mathieu-Daudé
2020-07-04 14:49 ` [PATCH 22/26] hw/usb/usb-hcd: Use OHCI type definitions Philippe Mathieu-Daudé
2020-07-04 17:13   ` BALATON Zoltan
2020-07-04 18:09     ` Philippe Mathieu-Daudé
2020-07-05 19:55   ` Niek Linnenbank
2020-07-04 14:49 ` [PATCH 23/26] hw/usb/usb-hcd: Use EHCI " Philippe Mathieu-Daudé
2020-07-04 17:15   ` BALATON Zoltan
2020-07-05  9:26     ` Philippe Mathieu-Daudé
2020-07-04 14:49 ` [PATCH 24/26] hw/usb/usb-hcd: Use UHCI " Philippe Mathieu-Daudé
2020-07-04 17:17   ` BALATON Zoltan
2020-07-04 18:12     ` Philippe Mathieu-Daudé
2020-07-04 19:44       ` BALATON Zoltan
2020-07-04 19:49         ` Philippe Mathieu-Daudé
2020-07-05  5:37         ` Paolo Bonzini
2020-07-04 14:49 ` [PATCH 25/26] hw/usb/usb-hcd: Use XHCI " Philippe Mathieu-Daudé
2020-07-04 17:19   ` BALATON Zoltan
2020-07-04 18:07     ` Philippe Mathieu-Daudé
2020-07-04 14:49 ` [PATCH 26/26] MAINTAINERS: Cover dwc-hsotg (dwc2) USB host controller emulation Philippe Mathieu-Daudé
2020-07-04 16:25   ` Paul Zimmerman
2020-07-13  9:46 ` [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).