Skip to contentSkip to conversation

include/hw/pci include/hw/cxl: Clean up includes

PATCH In review Markus Armbruster 4 participants 17 messages Dec 22, 2022 – Feb 15, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover include/hw/pci include/hw/cxl: Clean up includes

Back in 2016, we discussed[1] rules for headers, and these were generally liked:

1. Have a carefully curated header that's included everywhere first. We got that already thanks to Peter: osdep.h.

2. Headers should normally include everything they need beyond osdep.h. If exceptions are needed for some reason, they must be documented in the header. If all that's needed from a header is typedefs, put those into qemu/typedefs.h instead of including the header.

3. Cyclic inclusion is forbidden.

After this series, include/hw/pci and include/hw/cxl conform to these rules.

It is based on

[PATCH v2 0/3] block: Clean up includes
[PATCH v3 0/5] coroutine: Clean up includes

v2:
* Rebased
* PATCH 1: Actually breaks an inclusion loop; commit message rephrased accordingly
* PATCH 2: New [Jonathan]
* PATCH 5: tests/qtest/fuzz/generic_fuzz.c fixed [Michael]
* PATCH 6: Inclusion of cxl_pci.h into cxl_cdat_h kept, commit message adjusted [Jonathan]

[1] Message-ID: <[email protected]>

    https://lists.nongnu.org/archive/html/qemu-devel/2016-03/msg03345.html

Based-on: <[email protected]>

Markus Armbruster (7):
include/hw/pci: Break inclusion loop pci_bridge.h and cxl.h include/hw/cxl: Move typedef PXBDev to cxl.h, and put it to use include/hw/cxl: Include hw/cxl/*.h where needed include/hw/pci: Clean up a few things checkpatch.pl would flag include/hw/pci: Split pci_device.h off pci.h include/hw/pci: Include hw/pci/pci.h where needed include/hw/cxl: Break inclusion loop cxl_pci.h and cxl_cdat_h

 hw/alpha/alpha_sys.h                |   1 -
 hw/display/ati_int.h                |   2 +-
 hw/display/qxl.h                    |   3 +-
 hw/ide/ahci_internal.h              |   2 +-
 hw/net/vmxnet3_defs.h               |   2 +-
 hw/nvme/nvme.h                      |   2 +-
 hw/rdma/rdma_utils.h                |   1 -
 hw/rdma/vmw/pvrdma.h                |   2 +-
 hw/scsi/mptsas.h                    |   2 +-
 hw/usb/hcd-ehci.h                   |   3 +-
 hw/usb/hcd-uhci.h                   |   2 +-
 hw/usb/hcd-xhci-pci.h               |   1 +
 hw/vfio/pci.h                       |   2 +-
 hw/xen/xen_pt.h                     |   1 -
 include/hw/acpi/piix4.h             |   2 +-
 include/hw/arm/allwinner-a10.h      |   1 +
 include/hw/cxl/cxl.h                |   5 +-
 include/hw/cxl/cxl_cdat.h           |   1 +
 include/hw/cxl/cxl_component.h      |   1 +
 include/hw/cxl/cxl_device.h         |   2 +
 include/hw/cxl/cxl_pci.h            |   3 -
 include/hw/i386/ich9.h              |   4 -
 include/hw/i386/x86-iommu.h         |   1 -
 include/hw/ide/pci.h                |   2 +-
 include/hw/isa/vt82c686.h           |   1 -
 include/hw/misc/macio/macio.h       |   2 +-
 include/hw/pci-host/designware.h    |   3 -
 include/hw/pci-host/gpex.h          |   2 +-
 include/hw/pci-host/i440fx.h        |   2 +-
 include/hw/pci-host/ls7a.h          |   2 -
 include/hw/pci-host/pnv_phb3.h      |   2 -
 include/hw/pci-host/pnv_phb4.h      |   3 +-
 include/hw/pci-host/q35.h           |   2 +-
 include/hw/pci-host/sabre.h         |   2 +-
 include/hw/pci-host/xilinx-pcie.h   |   1 -
 include/hw/pci/msi.h                |   2 +-
 include/hw/pci/pci.h                | 341 ---------------------------
 include/hw/pci/pci_bridge.h         |   3 +-
 include/hw/pci/pci_device.h         | 350 ++++++++++++++++++++++++++++
 include/hw/pci/pcie.h               |   1 -
 include/hw/pci/pcie_port.h          |   1 +
 include/hw/pci/pcie_sriov.h         |   2 +
 include/hw/pci/shpc.h               |   2 +-
 include/hw/remote/iohub.h           |   2 +-
 include/hw/remote/proxy.h           |   2 +-
 include/hw/sd/sdhci.h               |   2 +-
 include/hw/southbridge/piix.h       |   3 +-
 include/hw/virtio/virtio-scsi.h     |   1 -
 include/hw/xen/xen_common.h         |   2 +-
 hw/acpi/erst.c                      |   2 +-
 hw/alpha/pci.c                      |   1 +
 hw/alpha/typhoon.c                  |   2 +-
 hw/audio/ac97.c                     |   2 +-
 hw/audio/es1370.c                   |   2 +-
 hw/audio/via-ac97.c                 |   2 +-
 hw/char/serial-pci-multi.c          |   2 +-
 hw/char/serial-pci.c                |   2 +-
 hw/core/qdev-properties-system.c    |   1 +
 hw/display/bochs-display.c          |   2 +-
 hw/display/cirrus_vga.c             |   2 +-
 hw/display/sm501.c                  |   2 +-
 hw/display/vga-pci.c                |   2 +-
 hw/display/vmware_vga.c             |   2 +-
 hw/i386/acpi-build.c                |   2 +-
 hw/i386/xen/xen_pvdevice.c          |   2 +-
 hw/ipack/tpci200.c                  |   2 +-
 hw/ipmi/pci_ipmi_bt.c               |   2 +-
 hw/ipmi/pci_ipmi_kcs.c              |   2 +-
 hw/isa/i82378.c                     |   2 +-
 hw/mips/gt64xxx_pci.c               |   2 +-
 hw/misc/pci-testdev.c               |   2 +-
 hw/misc/pvpanic-pci.c               |   2 +-
 hw/net/can/can_kvaser_pci.c         |   2 +-
 hw/net/can/can_mioe3680_pci.c       |   2 +-
 hw/net/can/can_pcm3680_pci.c        |   2 +-
 hw/net/can/ctucan_pci.c             |   2 +-
 hw/net/e1000.c                      |   2 +-
 hw/net/e1000x_common.c              |   2 +-
 hw/net/eepro100.c                   |   2 +-
 hw/net/ne2000-pci.c                 |   2 +-
 hw/net/net_tx_pkt.c                 |   2 +-
 hw/net/pcnet-pci.c                  |   2 +-
 hw/net/rocker/rocker.c              |   2 +-
 hw/net/rocker/rocker_desc.c         |   2 +-
 hw/net/rtl8139.c                    |   2 +-
 hw/net/sungem.c                     |   2 +-
 hw/net/sunhme.c                     |   2 +-
 hw/net/tulip.c                      |   2 +-
 hw/net/virtio-net.c                 |   2 +-
 hw/pci-bridge/i82801b11.c           |   2 +-
 hw/pci-bridge/pci_expander_bridge.c |   1 -
 hw/pci-host/bonito.c                |   2 +-
 hw/pci-host/dino.c                  |   2 +-
 hw/pci-host/grackle.c               |   2 +-
 hw/pci-host/mv64361.c               |   2 +-
 hw/pci-host/ppce500.c               |   2 +-
 hw/pci-host/raven.c                 |   2 +-
 hw/pci-host/sh_pci.c                |   2 +-
 hw/pci-host/uninorth.c              |   2 +-
 hw/pci-host/versatile.c             |   2 +-
 hw/pci/pci-hmp-cmds.c               |   1 +
 hw/pci/pcie_host.c                  |   2 +-
 hw/pci/pcie_sriov.c                 |   2 +-
 hw/pci/slotid_cap.c                 |   2 +-
 hw/ppc/ppc440_pcix.c                |   2 +-
 hw/ppc/ppc4xx_pci.c                 |   2 +-
 hw/ppc/spapr_pci_vfio.c             |   1 +
 hw/rdma/rdma_utils.c                |   1 +
 hw/s390x/s390-pci-inst.c            |   1 +
 hw/scsi/esp-pci.c                   |   2 +-
 hw/scsi/lsi53c895a.c                |   2 +-
 hw/scsi/virtio-scsi.c               |   1 +
 hw/smbios/smbios.c                  |   1 +
 hw/usb/hcd-ohci-pci.c               |   2 +-
 hw/watchdog/wdt_i6300esb.c          |   2 +-
 tests/qtest/fuzz/generic_fuzz.c     |   1 +
 ui/util.c                           |   2 +-
 117 files changed, 455 insertions(+), 455 deletions(-)
 create mode 100644 include/hw/pci/pci_device.h
Signature · 1 line
2.38.1
#1 lore raw

PATCH v2 1/7 include/hw/pci: Break inclusion loop pci_bridge.h and cxl.h

hw/pci/pci_bridge.h and hw/cxl/cxl.h include each other.

Fortunately, breaking the loop is merely a matter of deleting unnecessary includes from headers, and adding them back in places where they are now missing.

---
 hw/alpha/alpha_sys.h              | 1 -
 hw/rdma/rdma_utils.h              | 1 -
 hw/rdma/vmw/pvrdma.h              | 1 -
 hw/usb/hcd-ehci.h                 | 1 -
 hw/xen/xen_pt.h                   | 1 -
 include/hw/cxl/cxl.h              | 1 -
 include/hw/cxl/cxl_cdat.h         | 1 +
 include/hw/cxl/cxl_device.h       | 1 +
 include/hw/cxl/cxl_pci.h          | 2 --
 include/hw/i386/ich9.h            | 4 ----
 include/hw/i386/x86-iommu.h       | 1 -
 include/hw/isa/vt82c686.h         | 1 -
 include/hw/pci-host/designware.h  | 3 ---
 include/hw/pci-host/i440fx.h      | 2 +-
 include/hw/pci-host/ls7a.h        | 2 --
 include/hw/pci-host/pnv_phb3.h    | 2 --
 include/hw/pci-host/pnv_phb4.h    | 3 +--
 include/hw/pci-host/xilinx-pcie.h | 1 -
 include/hw/pci/pcie.h             | 1 -
 include/hw/virtio/virtio-scsi.h   | 1 -
 hw/alpha/pci.c                    | 1 +
 hw/alpha/typhoon.c                | 2 +-
 hw/i386/acpi-build.c              | 2 +-
 hw/pci-bridge/i82801b11.c         | 2 +-
 hw/rdma/rdma_utils.c              | 1 +
 hw/scsi/virtio-scsi.c             | 1 +
 26 files changed, 10 insertions(+), 30 deletions(-)
hw/alpha/alpha_sys.h +0 -1
index 2263e821da..a303c58438 100644
@@ -5,7 +5,6 @@
 
 #include "target/alpha/cpu-qom.h"
 #include "hw/pci/pci.h"
-#include "hw/pci/pci_host.h"
 #include "hw/boards.h"
 #include "hw/intc/i8259.h"
 
hw/rdma/rdma_utils.h +0 -1
index 0c6414e7e0..54e4f56edd 100644
@@ -18,7 +18,6 @@
 #define RDMA_UTILS_H
 
 #include "qemu/error-report.h"
-#include "hw/pci/pci.h"
 #include "sysemu/dma.h"
 
 #define rdma_error_report(fmt, ...) \
hw/rdma/vmw/pvrdma.h +0 -1
index d08965d3e2..0caf95ede8 100644
@@ -18,7 +18,6 @@
 
 #include "qemu/units.h"
 #include "qemu/notify.h"
-#include "hw/pci/pci.h"
 #include "hw/pci/msix.h"
 #include "chardev/char-fe.h"
 #include "hw/net/vmxnet3_defs.h"
hw/usb/hcd-ehci.h +0 -1
index a173707d9b..4d4b2830b7 100644
@@ -23,7 +23,6 @@
 #include "sysemu/dma.h"
 #include "hw/pci/pci.h"
 #include "hw/sysbus.h"
-#include "qom/object.h"
 
 #ifndef EHCI_DEBUG
 #define EHCI_DEBUG   0
hw/xen/xen_pt.h +0 -1
index e7c4316a7d..cf10fc7bbf 100644
@@ -2,7 +2,6 @@
 #define XEN_PT_H
 
 #include "hw/xen/xen_common.h"
-#include "hw/pci/pci.h"
 #include "xen-host-pci-device.h"
 #include "qom/object.h"
 
include/hw/cxl/cxl.h +0 -1
index 38e0e271d5..5129557bee 100644
@@ -13,7 +13,6 @@
 
 #include "qapi/qapi-types-machine.h"
 #include "qapi/qapi-visit-machine.h"
-#include "hw/pci/pci_bridge.h"
 #include "hw/pci/pci_host.h"
 #include "cxl_pci.h"
 #include "cxl_component.h"
include/hw/cxl/cxl_cdat.h +1 -0
index e9eda00142..7f67638685 100644
@@ -11,6 +11,7 @@
 #define CXL_CDAT_H
 
 #include "hw/cxl/cxl_pci.h"
+#include "hw/pci/pcie_doe.h"
 
 /*
  * Reference:
include/hw/cxl/cxl_device.h +1 -0
index 449b0edfe9..fd475b947b 100644
@@ -10,6 +10,7 @@
 #ifndef CXL_DEVICE_H
 #define CXL_DEVICE_H
 
+#include "hw/pci/pci.h"
 #include "hw/register.h"
 
 /*
include/hw/cxl/cxl_pci.h +0 -2
index 3cb79eca1e..aca14845ab 100644
@@ -11,8 +11,6 @@
 #define CXL_PCI_H
 
 #include "qemu/compiler.h"
-#include "hw/pci/pci.h"
-#include "hw/pci/pcie.h"
 #include "hw/cxl/cxl_cdat.h"
 
 #define CXL_VENDOR_ID 0x1e98
include/hw/i386/ich9.h +0 -4
index 23ee8e371b..222781e8b9 100644
@@ -5,12 +5,8 @@
 #include "hw/sysbus.h"
 #include "hw/i386/pc.h"
 #include "hw/isa/apm.h"
-#include "hw/pci/pci.h"
-#include "hw/pci/pcie_host.h"
-#include "hw/pci/pci_bridge.h"
 #include "hw/acpi/acpi.h"
 #include "hw/acpi/ich9.h"
-#include "hw/pci/pci_bus.h"
 #include "qom/object.h"
 
 void ich9_lpc_set_irq(void *opaque, int irq_num, int level);
include/hw/i386/x86-iommu.h +0 -1
index 7637edb430..8d8d53b18b 100644
@@ -21,7 +21,6 @@
 #define HW_I386_X86_IOMMU_H
 
 #include "hw/sysbus.h"
-#include "hw/pci/pci.h"
 #include "hw/pci/msi.h"
 #include "qom/object.h"
 
include/hw/isa/vt82c686.h +0 -1
index eaa07881c5..e273cd38dc 100644
@@ -1,7 +1,6 @@
 #ifndef HW_VT82C686_H
 #define HW_VT82C686_H
 
-#include "hw/pci/pci.h"
 
 #define TYPE_VT82C686B_ISA "vt82c686b-isa"
 #define TYPE_VT82C686B_USB_UHCI "vt82c686b-usb-uhci"
include/hw/pci-host/designware.h +0 -3
index 6d9b51ae67..908f3d946b 100644
@@ -22,9 +22,6 @@
 #define DESIGNWARE_H
 
 #include "hw/sysbus.h"
-#include "hw/pci/pci.h"
-#include "hw/pci/pci_bus.h"
-#include "hw/pci/pcie_host.h"
 #include "hw/pci/pci_bridge.h"
 #include "qom/object.h"
 
include/hw/pci-host/i440fx.h +1 -1
index d02bf1ed6b..fc93e22732 100644
@@ -11,7 +11,7 @@
 #ifndef HW_PCI_I440FX_H
 #define HW_PCI_I440FX_H
 
-#include "hw/pci/pci_bus.h"
+#include "hw/pci/pci.h"
 #include "hw/pci-host/pam.h"
 #include "qom/object.h"
 
include/hw/pci-host/ls7a.h +0 -2
index df7fa55a30..b27db8e2ca 100644
@@ -8,8 +8,6 @@
 #ifndef HW_LS7A_H
 #define HW_LS7A_H
 
-#include "hw/pci/pci.h"
-#include "hw/pci/pcie_host.h"
 #include "hw/pci-host/pam.h"
 #include "qemu/units.h"
 #include "qemu/range.h"
include/hw/pci-host/pnv_phb3.h +0 -2
index 4854f6d2f6..f791ebda9b 100644
@@ -10,8 +10,6 @@
 #ifndef PCI_HOST_PNV_PHB3_H
 #define PCI_HOST_PNV_PHB3_H
 
-#include "hw/pci/pcie_host.h"
-#include "hw/pci/pcie_port.h"
 #include "hw/ppc/xics.h"
 #include "qom/object.h"
 #include "hw/pci-host/pnv_phb.h"
include/hw/pci-host/pnv_phb4.h +1 -2
index 50d4faa001..d9cea3f952 100644
@@ -10,8 +10,7 @@
 #ifndef PCI_HOST_PNV_PHB4_H
 #define PCI_HOST_PNV_PHB4_H
 
-#include "hw/pci/pcie_host.h"
-#include "hw/pci/pcie_port.h"
+#include "hw/pci/pci_bus.h"
 #include "hw/ppc/xive.h"
 #include "qom/object.h"
 
include/hw/pci-host/xilinx-pcie.h +0 -1
index 89be88d87f..e1b3c1c280 100644
@@ -21,7 +21,6 @@
 #define HW_XILINX_PCIE_H
 
 #include "hw/sysbus.h"
-#include "hw/pci/pci.h"
 #include "hw/pci/pci_bridge.h"
 #include "hw/pci/pcie_host.h"
 #include "qom/object.h"
include/hw/pci/pcie.h +0 -1
index 698d3de851..798a262a0a 100644
@@ -26,7 +26,6 @@
 #include "hw/pci/pcie_aer.h"
 #include "hw/pci/pcie_sriov.h"
 #include "hw/hotplug.h"
-#include "hw/pci/pcie_doe.h"
 
 typedef enum {
     /* for attention and power indicator */
include/hw/virtio/virtio-scsi.h +0 -1
index a36aad9c86..37b75e15e3 100644
@@ -20,7 +20,6 @@
 #define VIRTIO_SCSI_SENSE_SIZE 0
 #include "standard-headers/linux/virtio_scsi.h"
 #include "hw/virtio/virtio.h"
-#include "hw/pci/pci.h"
 #include "hw/scsi/scsi.h"
 #include "chardev/char-fe.h"
 #include "sysemu/iothread.h"
hw/alpha/pci.c +1 -0
index 72251fcdf0..7c18297177 100644
@@ -7,6 +7,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "hw/pci/pci_host.h"
 #include "alpha_sys.h"
 #include "qemu/log.h"
 #include "trace.h"
hw/alpha/typhoon.c +1 -1
index bd39c8ca86..49a80550c5 100644
@@ -10,10 +10,10 @@
 #include "qemu/module.h"
 #include "qemu/units.h"
 #include "qapi/error.h"
+#include "hw/pci/pci_host.h"
 #include "cpu.h"
 #include "hw/irq.h"
 #include "alpha_sys.h"
-#include "qom/object.h"
 
 
 #define TYPE_TYPHOON_PCI_HOST_BRIDGE "typhoon-pcihost"
hw/i386/acpi-build.c +1 -1
index aa15b11cde..127c4e2d50 100644
@@ -27,7 +27,7 @@
 #include "acpi-common.h"
 #include "qemu/bitmap.h"
 #include "qemu/error-report.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_bridge.h"
 #include "hw/cxl/cxl.h"
 #include "hw/core/cpu.h"
 #include "target/i386/cpu.h"
hw/pci-bridge/i82801b11.c +1 -1
index d9f224818b..f3b4a14611 100644
@@ -42,7 +42,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_bridge.h"
 #include "migration/vmstate.h"
 #include "qemu/module.h"
 #include "hw/i386/ich9.h"
hw/rdma/rdma_utils.c +1 -0
index 5a7ef63ad2..77008552f4 100644
@@ -14,6 +14,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "hw/pci/pci.h"
 #include "trace.h"
 #include "rdma_utils.h"
 
hw/scsi/virtio-scsi.c +1 -0
index 6f6e2e32ba..2b649ca976 100644
@@ -22,6 +22,7 @@
 #include "qemu/iov.h"
 #include "qemu/module.h"
 #include "sysemu/block-backend.h"
+#include "sysemu/dma.h"
 #include "hw/qdev-properties.h"
 #include "hw/scsi/scsi.h"
 #include "scsi/constants.h"
Signature · 1 line
2.38.1
#2 lore raw

PATCH v2 2/7 include/hw/cxl: Move typedef PXBDev to cxl.h, and put it to use

In reply to Markus Armbruster

hw/cxl/cxl.h uses the PXBDev structure tag instead of the typedef name. The typedef name is defined in hw/pci/pci_bridge.h. Its inclusion was dropped in the previous commit to break an inclusion loop.

Move the typedef to hw/cxl/cxl.h, and use it there. Delete an extra typedef in hw/pci-bridge/pci_expander_bridge.c.

---
 include/hw/cxl/cxl.h                | 4 +++-
 include/hw/pci/pci_bridge.h         | 1 -
 hw/pci-bridge/pci_expander_bridge.c | 1 -
 3 files changed, 3 insertions(+), 3 deletions(-)
include/hw/cxl/cxl.h +3 -1
index 5129557bee..b161be59b7 100644
@@ -23,10 +23,12 @@
 
 #define CXL_WINDOW_MAX 10
 
+typedef struct PXBDev PXBDev;
+
 typedef struct CXLFixedWindow {
     uint64_t size;
     char **targets;
-    struct PXBDev *target_hbs[8];
+    PXBDev *target_hbs[8];
     uint8_t num_targets;
     uint8_t enc_int_ways;
     uint8_t enc_int_gran;
include/hw/pci/pci_bridge.h +0 -1
index ca6caf487e..58a3fb0c2c 100644
@@ -97,7 +97,6 @@ struct PXBDev {
     } cxl;
 };
 
-typedef struct PXBDev PXBDev;
 #define TYPE_PXB_CXL_DEVICE "pxb-cxl"
 DECLARE_INSTANCE_CHECKER(PXBDev, PXB_CXL_DEV,
                          TYPE_PXB_CXL_DEVICE)
hw/pci-bridge/pci_expander_bridge.c +0 -1
index c9e817aa58..870d9bab11 100644
@@ -50,7 +50,6 @@ struct PXBBus {
 };
 
 #define TYPE_PXB_DEVICE "pxb"
-typedef struct PXBDev PXBDev;
 DECLARE_INSTANCE_CHECKER(PXBDev, PXB_DEV,
                          TYPE_PXB_DEVICE)
 
Signature · 1 line
2.38.1
#3 lore raw

PATCH v2 3/7 include/hw/cxl: Include hw/cxl/*.h where needed

In reply to Markus Armbruster

hw/cxl/cxl_component.h needs CDATObject from hw/cxl/cxl_cdat.h.

hw/cxl/cxl_device.h needs CXLComponentState from
hw/cxl/cxl_component.h.

---
 include/hw/cxl/cxl_component.h | 1 +
 include/hw/cxl/cxl_device.h    | 1 +
 2 files changed, 2 insertions(+)
include/hw/cxl/cxl_component.h +1 -0
index 34075cfb72..5dca21e95b 100644
@@ -18,6 +18,7 @@
 #include "qemu/compiler.h"
 #include "qemu/range.h"
 #include "qemu/typedefs.h"
+#include "hw/cxl/cxl_cdat.h"
 #include "hw/register.h"
 #include "qapi/error.h"
 
include/hw/cxl/cxl_device.h +1 -0
index fd475b947b..3f91969db0 100644
@@ -10,6 +10,7 @@
 #ifndef CXL_DEVICE_H
 #define CXL_DEVICE_H
 
+#include "hw/cxl/cxl_component.h"
 #include "hw/pci/pci.h"
 #include "hw/register.h"
 
Signature · 1 line
2.38.1
#4 lore raw

PATCH v2 4/7 include/hw/pci: Clean up a few things checkpatch.pl would flag

In reply to Markus Armbruster

Fix a few style violations so that checkpatch.pl won't complain when I move this code.

---
 include/hw/pci/pci.h | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
include/hw/pci/pci.h +10 -7
index 954f260f84..5ca2a9df58 100644
@@ -284,8 +284,10 @@ struct PCIDevice {
     /* PCI config space */
     uint8_t *config;
 
-    /* Used to enable config checks on load. Note that writable bits are
-     * never checked even if set in cmask. */
+    /*
+     * Used to enable config checks on load. Note that writable bits are
+     * never checked even if set in cmask.
+     */
     uint8_t *cmask;
 
     /* Used to implement R/W bytes */
@@ -299,10 +301,11 @@ struct PCIDevice {
 
     /* the following fields are read only */
     int32_t devfn;
-    /* Cached device to fetch requester ID from, to avoid the PCI
-     * tree walking every time we invoke PCI request (e.g.,
-     * MSI). For conventional PCI root complex, this field is
-     * meaningless. */
+    /*
+     * Cached device to fetch requester ID from, to avoid the PCI tree
+     * walking every time we invoke PCI request (e.g., MSI). For
+     * conventional PCI root complex, this field is meaningless.
+     */
     PCIReqIDCache requester_id_cache;
     char name[64];
     PCIIORegion io_regions[PCI_NUM_REGIONS];
@@ -943,7 +946,7 @@ extern const VMStateDescription vmstate_pci_device;
     .name       = (stringify(_field)),                               \
     .size       = sizeof(PCIDevice),                                 \
     .vmsd       = &vmstate_pci_device,                               \
-    .flags      = VMS_STRUCT|VMS_POINTER,                            \
+    .flags      = VMS_STRUCT | VMS_POINTER,                          \
     .offset     = vmstate_offset_pointer(_state, _field, PCIDevice), \
 }
 
Signature · 1 line
2.38.1
#5 lore raw

PATCH v2 5/7 include/hw/pci: Split pci_device.h off pci.h

In reply to Markus Armbruster

PCIDeviceClass and PCIDevice are defined in pci.h. Many users of the header don't actually need them. Similar structs live in their own
headers: PCIBusClass and PCIBus in pci_bus.h, PCIBridge in pci_bridge.h, PCIHostBridgeClass and PCIHostState in pci_host.h, PCIExpressHost in pcie_host.h, and PCIERootPortClass, PCIEPort, and PCIESlot in pcie_port.h.

Move PCIDeviceClass and PCIDeviceClass to new pci_device.h, along with the code that needs them. Adjust include directives.

This also enables the next commit.

---
 hw/display/ati_int.h             |   2 +-
 hw/display/qxl.h                 |   3 +-
 hw/ide/ahci_internal.h           |   2 +-
 hw/net/vmxnet3_defs.h            |   2 +-
 hw/nvme/nvme.h                   |   2 +-
 hw/rdma/vmw/pvrdma.h             |   1 +
 hw/scsi/mptsas.h                 |   2 +-
 hw/usb/hcd-ehci.h                |   2 +-
 hw/usb/hcd-uhci.h                |   2 +-
 hw/usb/hcd-xhci-pci.h            |   1 +
 hw/vfio/pci.h                    |   2 +-
 include/hw/acpi/piix4.h          |   2 +-
 include/hw/arm/allwinner-a10.h   |   1 +
 include/hw/cxl/cxl_device.h      |   2 +-
 include/hw/ide/pci.h             |   2 +-
 include/hw/misc/macio/macio.h    |   2 +-
 include/hw/pci-host/gpex.h       |   2 +-
 include/hw/pci-host/i440fx.h     |   2 +-
 include/hw/pci-host/q35.h        |   2 +-
 include/hw/pci-host/sabre.h      |   2 +-
 include/hw/pci/msi.h             |   2 +-
 include/hw/pci/pci.h             | 344 ------------------------------
 include/hw/pci/pci_bridge.h      |   2 +-
 include/hw/pci/pci_device.h      | 350 +++++++++++++++++++++++++++++++
 include/hw/pci/pcie_port.h       |   1 +
 include/hw/pci/shpc.h            |   2 +-
 include/hw/remote/iohub.h        |   2 +-
 include/hw/remote/proxy.h        |   2 +-
 include/hw/sd/sdhci.h            |   2 +-
 include/hw/southbridge/piix.h    |   3 +-
 include/hw/xen/xen_common.h      |   2 +-
 hw/acpi/erst.c                   |   2 +-
 hw/audio/ac97.c                  |   2 +-
 hw/audio/es1370.c                |   2 +-
 hw/audio/via-ac97.c              |   2 +-
 hw/char/serial-pci-multi.c       |   2 +-
 hw/char/serial-pci.c             |   2 +-
 hw/core/qdev-properties-system.c |   1 +
 hw/display/bochs-display.c       |   2 +-
 hw/display/cirrus_vga.c          |   2 +-
 hw/display/sm501.c               |   2 +-
 hw/display/vga-pci.c             |   2 +-
 hw/display/vmware_vga.c          |   2 +-
 hw/i386/xen/xen_pvdevice.c       |   2 +-
 hw/ipack/tpci200.c               |   2 +-
 hw/ipmi/pci_ipmi_bt.c            |   2 +-
 hw/ipmi/pci_ipmi_kcs.c           |   2 +-
 hw/isa/i82378.c                  |   2 +-
 hw/mips/gt64xxx_pci.c            |   2 +-
 hw/misc/pci-testdev.c            |   2 +-
 hw/misc/pvpanic-pci.c            |   2 +-
 hw/net/can/can_kvaser_pci.c      |   2 +-
 hw/net/can/can_mioe3680_pci.c    |   2 +-
 hw/net/can/can_pcm3680_pci.c     |   2 +-
 hw/net/can/ctucan_pci.c          |   2 +-
 hw/net/e1000.c                   |   2 +-
 hw/net/e1000x_common.c           |   2 +-
 hw/net/eepro100.c                |   2 +-
 hw/net/ne2000-pci.c              |   2 +-
 hw/net/net_tx_pkt.c              |   2 +-
 hw/net/pcnet-pci.c               |   2 +-
 hw/net/rocker/rocker.c           |   2 +-
 hw/net/rocker/rocker_desc.c      |   2 +-
 hw/net/rtl8139.c                 |   2 +-
 hw/net/sungem.c                  |   2 +-
 hw/net/sunhme.c                  |   2 +-
 hw/net/tulip.c                   |   2 +-
 hw/net/virtio-net.c              |   2 +-
 hw/pci-host/bonito.c             |   2 +-
 hw/pci-host/dino.c               |   2 +-
 hw/pci-host/grackle.c            |   2 +-
 hw/pci-host/mv64361.c            |   2 +-
 hw/pci-host/ppce500.c            |   2 +-
 hw/pci-host/raven.c              |   2 +-
 hw/pci-host/sh_pci.c             |   2 +-
 hw/pci-host/uninorth.c           |   2 +-
 hw/pci-host/versatile.c          |   2 +-
 hw/pci/pci-hmp-cmds.c            |   1 +
 hw/pci/pcie_host.c               |   2 +-
 hw/pci/pcie_sriov.c              |   2 +-
 hw/pci/slotid_cap.c              |   2 +-
 hw/ppc/ppc440_pcix.c             |   2 +-
 hw/ppc/ppc4xx_pci.c              |   2 +-
 hw/ppc/spapr_pci_vfio.c          |   1 +
 hw/rdma/rdma_utils.c             |   2 +-
 hw/s390x/s390-pci-inst.c         |   1 +
 hw/scsi/esp-pci.c                |   2 +-
 hw/scsi/lsi53c895a.c             |   2 +-
 hw/smbios/smbios.c               |   1 +
 hw/usb/hcd-ohci-pci.c            |   2 +-
 hw/watchdog/wdt_i6300esb.c       |   2 +-
 tests/qtest/fuzz/generic_fuzz.c  |   1 +
 ui/util.c                        |   2 +-
 93 files changed, 441 insertions(+), 427 deletions(-)
 create mode 100644 include/hw/pci/pci_device.h
hw/display/ati_int.h +1 -1
index 8acb9c7466..e8d3c7af75 100644
@@ -10,7 +10,7 @@
 #define ATI_INT_H
 
 #include "qemu/timer.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/i2c/bitbang_i2c.h"
 #include "vga_int.h"
 #include "qom/object.h"
hw/display/qxl.h +1 -2
index 7894bd5134..cd82c7a6fe 100644
@@ -1,8 +1,7 @@
 #ifndef HW_QXL_H
 #define HW_QXL_H
 
-
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "vga_int.h"
 #include "qemu/thread.h"
 
hw/ide/ahci_internal.h +1 -1
index 109de9e2d1..303fcd7235 100644
@@ -26,7 +26,7 @@
 
 #include "hw/ide/ahci.h"
 #include "hw/ide/internal.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 
 #define AHCI_MEM_BAR_SIZE         0x1000
 #define AHCI_MAX_PORTS            32
hw/net/vmxnet3_defs.h +1 -1
index 71440509ca..64034af6d5 100644
@@ -19,7 +19,7 @@
 
 #include "net/net.h"
 #include "hw/net/vmxnet3.h"
-#include "qom/object.h"
+#include "hw/pci/pci_device.h"
 
 #define TYPE_VMXNET3 "vmxnet3"
 typedef struct VMXNET3State VMXNET3State;
hw/nvme/nvme.h +1 -1
index 7adf042ec3..16da27a69b 100644
@@ -19,7 +19,7 @@
 #define HW_NVME_NVME_H
 
 #include "qemu/uuid.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/block/block.h"
 
 #include "block/nvme.h"
hw/rdma/vmw/pvrdma.h +1 -0
index 0caf95ede8..4cbc10c980 100644
@@ -19,6 +19,7 @@
 #include "qemu/units.h"
 #include "qemu/notify.h"
 #include "hw/pci/msix.h"
+#include "hw/pci/pci_device.h"
 #include "chardev/char-fe.h"
 #include "hw/net/vmxnet3_defs.h"
 
hw/scsi/mptsas.h +1 -1
index c046497db7..04e97ce3af 100644
@@ -2,7 +2,7 @@
 #define MPTSAS_H
 
 #include "mpi.h"
-#include "qom/object.h"
+#include "hw/pci/pci_device.h"
 
 #define MPTSAS_NUM_PORTS 8
 #define MPTSAS_MAX_FRAMES 2048     /* Firmware limit at 65535 */
hw/usb/hcd-ehci.h +1 -1
index 4d4b2830b7..2cd821f49e 100644
@@ -21,7 +21,7 @@
 #include "qemu/timer.h"
 #include "hw/usb.h"
 #include "sysemu/dma.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/sysbus.h"
 
 #ifndef EHCI_DEBUG
hw/usb/hcd-uhci.h +1 -1
index c85ab7868e..5843af504a 100644
@@ -30,7 +30,7 @@
 
 #include "exec/memory.h"
 #include "qemu/timer.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/usb.h"
 
 typedef struct UHCIQueue UHCIQueue;
hw/usb/hcd-xhci-pci.h +1 -0
index c193f79443..08f70ce97c 100644
@@ -24,6 +24,7 @@
 #ifndef HW_USB_HCD_XHCI_PCI_H
 #define HW_USB_HCD_XHCI_PCI_H
 
+#include "hw/pci/pci_device.h"
 #include "hw/usb.h"
 #include "hcd-xhci.h"
 
hw/vfio/pci.h +1 -1
index 7c236a52f4..177abcc8fb 100644
@@ -13,7 +13,7 @@
 #define HW_VFIO_VFIO_PCI_H
 
 #include "exec/memory.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/vfio/vfio-common.h"
 #include "qemu/event_notifier.h"
 #include "qemu/queue.h"
include/hw/acpi/piix4.h +1 -1
index 32686a75c5..be1f8ea80e 100644
@@ -22,7 +22,7 @@
 #ifndef HW_ACPI_PIIX4_H
 #define HW_ACPI_PIIX4_H
 
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/acpi/acpi.h"
 #include "hw/acpi/cpu_hotplug.h"
 #include "hw/acpi/memory_hotplug.h"
include/hw/arm/allwinner-a10.h +1 -0
index a76dc7b84d..f9240ffa64 100644
@@ -4,6 +4,7 @@
 #include "qemu/error-report.h"
 #include "hw/char/serial.h"
 #include "hw/arm/boot.h"
+#include "hw/pci/pci_device.h"
 #include "hw/timer/allwinner-a10-pit.h"
 #include "hw/intc/allwinner-a10-pic.h"
 #include "hw/net/allwinner_emac.h"
include/hw/cxl/cxl_device.h +1 -1
index 3f91969db0..250adf18b2 100644
@@ -11,7 +11,7 @@
 #define CXL_DEVICE_H
 
 #include "hw/cxl/cxl_component.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/register.h"
 
 /*
include/hw/ide/pci.h +1 -1
index d8384e1c42..2a6284acac 100644
@@ -2,7 +2,7 @@
 #define HW_IDE_PCI_H
 
 #include "hw/ide/internal.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "qom/object.h"
 
 #define BM_STATUS_DMAING 0x01
include/hw/misc/macio/macio.h +1 -1
index 95d30a1745..86df2c2b60 100644
@@ -27,7 +27,7 @@
 #define MACIO_H
 
 #include "hw/char/escc.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/ide/internal.h"
 #include "hw/intc/heathrow_pic.h"
 #include "hw/misc/macio/cuda.h"
include/hw/pci-host/gpex.h +1 -1
index fcf8b63820..b0240bd768 100644
@@ -22,7 +22,7 @@
 
 #include "exec/hwaddr.h"
 #include "hw/sysbus.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/pci/pcie_host.h"
 #include "qom/object.h"
 
include/hw/pci-host/i440fx.h +1 -1
index fc93e22732..bf57216c78 100644
@@ -11,7 +11,7 @@
 #ifndef HW_PCI_I440FX_H
 #define HW_PCI_I440FX_H
 
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/pci-host/pam.h"
 #include "qom/object.h"
 
include/hw/pci-host/q35.h +1 -1
index ab989698ef..e89329c51e 100644
@@ -22,7 +22,7 @@
 #ifndef HW_Q35_H
 #define HW_Q35_H
 
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/pci/pcie_host.h"
 #include "hw/pci-host/pam.h"
 #include "qemu/units.h"
include/hw/pci-host/sabre.h +1 -1
index 01190241bb..d12de84ea2 100644
@@ -1,7 +1,7 @@
 #ifndef HW_PCI_HOST_SABRE_H
 #define HW_PCI_HOST_SABRE_H
 
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/pci/pci_host.h"
 #include "hw/sparc/sun4u_iommu.h"
 #include "qom/object.h"
include/hw/pci/msi.h +1 -1
index 58aa576215..ee8ee469a6 100644
@@ -21,7 +21,7 @@
 #ifndef QEMU_MSI_H
 #define QEMU_MSI_H
 
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 
 struct MSIMessage {
     uint64_t address;
include/hw/pci/pci.h +0 -344

380 lines not on this page · raw message

include/hw/pci/pci_bridge.h +1 -1
index 58a3fb0c2c..63a7521567 100644
@@ -26,7 +26,7 @@
 #ifndef QEMU_PCI_BRIDGE_H
 #define QEMU_PCI_BRIDGE_H
 
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/pci/pci_bus.h"
 #include "hw/cxl/cxl.h"
 #include "qom/object.h"
include/hw/pci/pci_device.h new file +350 -0

350 lines not on this page · raw message

include/hw/pci/pcie_port.h +1 -0
index d9b5d07504..fd484afb30 100644
@@ -23,6 +23,7 @@
 
 #include "hw/pci/pci_bridge.h"
 #include "hw/pci/pci_bus.h"
+#include "hw/pci/pci_device.h"
 #include "qom/object.h"
 
 #define TYPE_PCIE_PORT "pcie-port"
include/hw/pci/shpc.h +1 -1
index d5683b7399..89c7a3b7fa 100644
@@ -3,7 +3,7 @@
 
 #include "exec/memory.h"
 #include "hw/hotplug.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "migration/vmstate.h"
 
 struct SHPCDevice {
include/hw/remote/iohub.h +1 -1
index 0bf98e0d78..6a8444f9a9 100644
@@ -11,7 +11,7 @@
 #ifndef REMOTE_IOHUB_H
 #define REMOTE_IOHUB_H
 
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "qemu/event_notifier.h"
 #include "qemu/thread-posix.h"
 #include "hw/remote/mpqemu-link.h"
include/hw/remote/proxy.h +1 -1
index 741def71f1..0cfd9665be 100644
@@ -9,7 +9,7 @@
 #ifndef PROXY_H
 #define PROXY_H
 
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "io/channel.h"
 #include "hw/remote/proxy-memory-listener.h"
 #include "qemu/event_notifier.h"
include/hw/sd/sdhci.h +1 -1
index a989fca3b2..6cd2822f1d 100644
@@ -25,7 +25,7 @@
 #ifndef SDHCI_H
 #define SDHCI_H
 
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/sysbus.h"
 #include "hw/sd/sd.h"
 #include "qom/object.h"
include/hw/southbridge/piix.h +1 -2
index 2693778b23..0bf48e936d 100644
@@ -12,8 +12,7 @@
 #ifndef HW_SOUTHBRIDGE_PIIX_H
 #define HW_SOUTHBRIDGE_PIIX_H
 
-#include "hw/pci/pci.h"
-#include "qom/object.h"
+#include "hw/pci/pci_device.h"
 
 /* PIRQRC[A:D]: PIRQx Route Control Registers */
 #define PIIX_PIRQCA 0x60
include/hw/xen/xen_common.h +1 -1
index 77ce17d8a4..9a13a756ae 100644
@@ -15,7 +15,7 @@
 #include "hw/xen/interface/io/xenbus.h"
 
 #include "hw/xen/xen.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/xen/trace.h"
 
 extern xc_interface *xen_xc;
hw/acpi/erst.c +1 -1
index aefcc03ad6..35007d8017 100644
@@ -14,7 +14,7 @@
 #include "hw/qdev-core.h"
 #include "exec/memory.h"
 #include "qom/object.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "qom/object_interfaces.h"
 #include "qemu/error-report.h"
 #include "migration/vmstate.h"
hw/audio/ac97.c +1 -1
index be2dd701a4..364cdfa733 100644
@@ -20,7 +20,7 @@
 #include "qemu/osdep.h"
 #include "hw/audio/soundhw.h"
 #include "audio/audio.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "qemu/module.h"
hw/audio/es1370.c +1 -1
index 6904589814..54cc19a637 100644
@@ -29,7 +29,7 @@
 #include "qemu/osdep.h"
 #include "hw/audio/soundhw.h"
 #include "audio/audio.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "migration/vmstate.h"
 #include "qemu/module.h"
 #include "sysemu/dma.h"
hw/audio/via-ac97.c +1 -1
index 6d556f74fc..d1a856f63d 100644
@@ -11,7 +11,7 @@
 
 #include "qemu/osdep.h"
 #include "hw/isa/vt82c686.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 
 static void via_ac97_realize(PCIDevice *pci_dev, Error **errp)
 {
hw/char/serial-pci-multi.c +1 -1
index 3a9f96c2d1..f18b8dcce5 100644
@@ -31,7 +31,7 @@
 #include "qapi/error.h"
 #include "hw/char/serial.h"
 #include "hw/irq.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/qdev-properties.h"
 #include "hw/qdev-properties-system.h"
 #include "migration/vmstate.h"
hw/char/serial-pci.c +1 -1
index 93d6f99244..801b769aba 100644
@@ -30,7 +30,7 @@
 #include "qemu/module.h"
 #include "hw/char/serial.h"
 #include "hw/irq.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "qom/object.h"
hw/core/qdev-properties-system.c +1 -0
index 97a968f477..54a09fa9ac 100644
@@ -32,6 +32,7 @@
 #include "sysemu/blockdev.h"
 #include "net/net.h"
 #include "hw/pci/pci.h"
+#include "hw/pci/pcie.h"
 #include "util/block-helpers.h"
 
 static bool check_prop_still_unset(Object *obj, const char *name,
hw/display/bochs-display.c +1 -1
index 8ed734b195..e7ec268184 100644
@@ -8,7 +8,7 @@
 #include "qemu/osdep.h"
 #include "qemu/module.h"
 #include "qemu/units.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "hw/display/bochs-vbe.h"
hw/display/cirrus_vga.c +1 -1
index 6e8c747c46..55c32e3e40 100644
@@ -39,7 +39,7 @@
 #include "sysemu/reset.h"
 #include "qapi/error.h"
 #include "trace.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "ui/pixel_ops.h"
hw/display/sm501.c +1 -1
index 663c37e7f2..52e42585af 100644
@@ -32,7 +32,7 @@
 #include "ui/console.h"
 #include "hw/sysbus.h"
 #include "migration/vmstate.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/qdev-properties.h"
 #include "hw/i2c/i2c.h"
 #include "hw/display/i2c-ddc.h"
hw/display/vga-pci.c +1 -1
index df23dbf3a0..b351b8f299 100644
@@ -25,7 +25,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "vga_int.h"
hw/display/vmware_vga.c +1 -1
index 53949d2539..59ae7f74b8 100644
@@ -29,7 +29,7 @@
 #include "qemu/log.h"
 #include "hw/loader.h"
 #include "trace.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "qom/object.h"
hw/i386/xen/xen_pvdevice.c +1 -1
index 1ea95fa601..e62e06622b 100644
@@ -32,7 +32,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qemu/module.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "trace.h"
hw/ipack/tpci200.c +1 -1
index 1f764fc85b..6b3edbf017 100644
@@ -12,7 +12,7 @@
 #include "qemu/units.h"
 #include "hw/ipack/ipack.h"
 #include "hw/irq.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "migration/vmstate.h"
 #include "qemu/bitops.h"
 #include "qemu/module.h"
hw/ipmi/pci_ipmi_bt.c +1 -1
index b6e52730d3..633931b825 100644
@@ -25,7 +25,7 @@
 #include "migration/vmstate.h"
 #include "qapi/error.h"
 #include "hw/ipmi/ipmi_bt.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "qom/object.h"
 
 #define TYPE_PCI_IPMI_BT "pci-ipmi-bt"
hw/ipmi/pci_ipmi_kcs.c +1 -1
index de13418862..1a581413c2 100644
@@ -25,7 +25,7 @@
 #include "migration/vmstate.h"
 #include "qapi/error.h"
 #include "hw/ipmi/ipmi_kcs.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "qom/object.h"
 
 #define TYPE_PCI_IPMI_KCS "pci-ipmi-kcs"
hw/isa/i82378.c +1 -1
index 2a2ff05b93..e3322e03bf 100644
@@ -18,7 +18,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/irq.h"
 #include "hw/intc/i8259.h"
 #include "hw/timer/i8254.h"
hw/mips/gt64xxx_pci.c +1 -1
index 19d0d9889f..164866cf3e 100644
@@ -26,7 +26,7 @@
 #include "qapi/error.h"
 #include "qemu/units.h"
 #include "qemu/log.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/pci/pci_host.h"
 #include "migration/vmstate.h"
 #include "hw/intc/i8259.h"
hw/misc/pci-testdev.c +1 -1
index 03845c8de3..49303134e4 100644
@@ -19,7 +19,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/qdev-properties.h"
 #include "qemu/event_notifier.h"
 #include "qemu/module.h"
hw/misc/pvpanic-pci.c +1 -1
index 99cf7e2041..fbcaa50731 100644
@@ -20,7 +20,7 @@
 #include "migration/vmstate.h"
 #include "hw/misc/pvpanic.h"
 #include "qom/object.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "standard-headers/linux/pvpanic.h"
 
 OBJECT_DECLARE_SIMPLE_TYPE(PVPanicPCIState, PVPANIC_PCI_DEVICE)
hw/net/can/can_kvaser_pci.c +1 -1
index 94b3a534f8..2cd90cef1e 100644
@@ -37,7 +37,7 @@
 #include "qapi/error.h"
 #include "chardev/char.h"
 #include "hw/irq.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "net/can_emu.h"
hw/net/can/can_mioe3680_pci.c +1 -1
index 29dc696f7c..b9918773b3 100644
@@ -33,7 +33,7 @@
 #include "qapi/error.h"
 #include "chardev/char.h"
 #include "hw/irq.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "net/can_emu.h"
hw/net/can/can_pcm3680_pci.c +1 -1
index e8e57f4f33..8ef3e4659c 100644
@@ -33,7 +33,7 @@
 #include "qapi/error.h"
 #include "chardev/char.h"
 #include "hw/irq.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "net/can_emu.h"
hw/net/can/ctucan_pci.c +1 -1
index 50f4ea6cd6..ea079e2af5 100644
@@ -34,7 +34,7 @@
 #include "qapi/error.h"
 #include "chardev/char.h"
 #include "hw/irq.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "net/can_emu.h"
hw/net/e1000.c +1 -1
index e26e0a64c1..7efb8a4c52 100644
@@ -26,7 +26,7 @@
 
 
 #include "qemu/osdep.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "net/eth.h"
hw/net/e1000x_common.c +1 -1
index a8d93870b5..2f43e8cd13 100644
@@ -24,7 +24,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu/units.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "net/net.h"
 
 #include "e1000x_common.h"
hw/net/eepro100.c +1 -1
index 679f52f80f..dc07984ae9 100644
@@ -42,7 +42,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu/units.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "net/net.h"
hw/net/ne2000-pci.c +1 -1
index 9e5d10859a..edc6689d33 100644
@@ -24,7 +24,7 @@
 
 #include "qemu/osdep.h"
 #include "hw/irq.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "ne2000.h"
hw/net/net_tx_pkt.c +1 -1
index 1cb1125d9f..2533ea2700 100644
@@ -21,7 +21,7 @@
 #include "net/checksum.h"
 #include "net/tap.h"
 #include "net/net.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 
 enum {
     NET_TX_PKT_VHDR_FRAG = 0,
hw/net/pcnet-pci.c +1 -1
index 95d27102aa..96a302c141 100644
@@ -29,7 +29,7 @@
 
 #include "qemu/osdep.h"
 #include "hw/irq.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "net/net.h"
hw/net/rocker/rocker.c +1 -1
index 281d43e6cf..cf54ddf49d 100644
@@ -16,7 +16,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/qdev-properties.h"
 #include "hw/qdev-properties-system.h"
 #include "migration/vmstate.h"
hw/net/rocker/rocker_desc.c +1 -1
index 01845f1157..f3068c9250 100644
@@ -16,7 +16,7 @@
 
 #include "qemu/osdep.h"
 #include "net/net.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 
 #include "rocker.h"
 #include "rocker_hw.h"
hw/net/rtl8139.c +1 -1
index 700b1b66b6..5a5aaf868d 100644
@@ -53,7 +53,7 @@
 #include "qemu/osdep.h"
 #include <zlib.h>
 
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "sysemu/dma.h"
hw/net/sungem.c +1 -1
index 3684a4d733..eb01520790 100644
@@ -8,7 +8,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "qemu/log.h"
hw/net/sunhme.c +1 -1
index fc34905f87..1f3d8011ae 100644
@@ -23,7 +23,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "hw/net/mii.h"
hw/net/tulip.c +1 -1
index c2b3b1bdfa..915e5fb595 100644
@@ -9,7 +9,7 @@
 #include "qemu/osdep.h"
 #include "qemu/log.h"
 #include "hw/irq.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/qdev-properties.h"
 #include "hw/nvram/eeprom93xx.h"
 #include "migration/vmstate.h"
hw/net/virtio-net.c +1 -1
index 9cbdfa5547..c3d5451c8d 100644
@@ -42,7 +42,7 @@
 #include "sysemu/sysemu.h"
 #include "trace.h"
 #include "monitor/qdev.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "net_rx_pkt.h"
 #include "hw/virtio/vhost.h"
 #include "sysemu/qtest.h"
hw/pci-host/bonito.c +1 -1
index a57e81e3a9..f04f3ad668 100644
@@ -42,7 +42,7 @@
 #include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/irq.h"
 #include "hw/mips/mips.h"
 #include "hw/pci/pci_host.h"
hw/pci-host/dino.c +1 -1
index f257c24e64..e8eaebca54 100644
@@ -15,7 +15,7 @@
 #include "qemu/units.h"
 #include "qapi/error.h"
 #include "hw/irq.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/pci/pci_bus.h"
 #include "hw/qdev-properties.h"
 #include "hw/pci-host/dino.h"
hw/pci-host/grackle.c +1 -1
index 95945ac0f4..8cf318cb80 100644
@@ -25,7 +25,7 @@
 
 #include "qemu/osdep.h"
 #include "hw/qdev-properties.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/irq.h"
 #include "qapi/error.h"
 #include "qemu/module.h"
hw/pci-host/mv64361.c +1 -1
index cc9c4d6d3b..015b92bd5f 100644
@@ -13,7 +13,7 @@
 #include "qapi/error.h"
 #include "hw/hw.h"
 #include "hw/sysbus.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/pci/pci_host.h"
 #include "hw/irq.h"
 #include "hw/intc/i8259.h"
hw/pci-host/ppce500.c +1 -1
index 89c1b53dd7..568849e930 100644
@@ -19,7 +19,7 @@
 #include "hw/ppc/e500-ccsr.h"
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/pci/pci_host.h"
 #include "qemu/bswap.h"
 #include "qemu/module.h"
hw/pci-host/raven.c +1 -1
index 7a105e4a63..2c96ddf8fe 100644
@@ -28,7 +28,7 @@
 #include "qemu/units.h"
 #include "qemu/log.h"
 #include "qapi/error.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/pci/pci_bus.h"
 #include "hw/pci/pci_host.h"
 #include "hw/qdev-properties.h"
hw/pci-host/sh_pci.c +1 -1
index 719d6ca2a6..77e7bbc65f 100644
@@ -26,7 +26,7 @@
 #include "hw/sysbus.h"
 #include "hw/sh4/sh.h"
 #include "hw/irq.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/pci/pci_host.h"
 #include "qemu/bswap.h"
 #include "qemu/module.h"
hw/pci-host/uninorth.c +1 -1
index 8396c91d59..e3abe3c0f9 100644
@@ -26,7 +26,7 @@
 #include "hw/irq.h"
 #include "hw/qdev-properties.h"
 #include "qemu/module.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/pci/pci_host.h"
 #include "hw/pci-host/uninorth.h"
 #include "trace.h"
hw/pci-host/versatile.c +1 -1
index f66384fa02..0d50ea4cc0 100644
@@ -12,7 +12,7 @@
 #include "hw/sysbus.h"
 #include "migration/vmstate.h"
 #include "hw/irq.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/pci/pci_bus.h"
 #include "hw/pci/pci_host.h"
 #include "hw/qdev-properties.h"
hw/pci/pci-hmp-cmds.c +1 -0
index fb7591d6ab..b09fce9377 100644
@@ -15,6 +15,7 @@
 
 #include "qemu/osdep.h"
 #include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "monitor/hmp.h"
 #include "monitor/monitor.h"
 #include "pci-internal.h"
hw/pci/pcie_host.c +1 -1
index 5abbe83220..3717e1a086 100644
@@ -20,7 +20,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/pci/pcie_host.h"
 #include "qemu/module.h"
 
hw/pci/pcie_sriov.c +1 -1
index 8e3faf1f59..f0bd72e069 100644
@@ -11,7 +11,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/pci/pcie.h"
 #include "hw/pci/pci_bus.h"
 #include "hw/qdev-properties.h"
hw/pci/slotid_cap.c +1 -1
index 36d021b4a6..8372d05d9e 100644
@@ -1,6 +1,6 @@
 #include "qemu/osdep.h"
 #include "hw/pci/slotid_cap.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
 
hw/ppc/ppc440_pcix.c +1 -1
index 788d25514a..f10f93c533 100644
@@ -26,7 +26,7 @@
 #include "hw/irq.h"
 #include "hw/ppc/ppc.h"
 #include "hw/ppc/ppc4xx.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/pci/pci_host.h"
 #include "trace.h"
 #include "qom/object.h"
hw/ppc/ppc4xx_pci.c +1 -1
index 8642b96455..1d4a50fa7c 100644
@@ -29,7 +29,7 @@
 #include "migration/vmstate.h"
 #include "qemu/module.h"
 #include "sysemu/reset.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/pci/pci_host.h"
 #include "trace.h"
 #include "qom/object.h"
hw/ppc/spapr_pci_vfio.c +1 -0
index 2a76b4e0b5..d8aeee0b7e 100644
@@ -22,6 +22,7 @@
 #include "hw/ppc/spapr.h"
 #include "hw/pci-host/spapr.h"
 #include "hw/pci/msix.h"
+#include "hw/pci/pci_device.h"
 #include "hw/vfio/vfio.h"
 #include "qemu/error-report.h"
 
hw/rdma/rdma_utils.c +1 -1
index 77008552f4..c948baf052 100644
@@ -14,7 +14,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "trace.h"
 #include "rdma_utils.h"
 
hw/s390x/s390-pci-inst.c +1 -0
index 9abe95130c..69137e0757 100644
@@ -16,6 +16,7 @@
 #include "exec/memory-internal.h"
 #include "qemu/error-report.h"
 #include "sysemu/hw_accel.h"
+#include "hw/pci/pci_device.h"
 #include "hw/s390x/s390-pci-inst.h"
 #include "hw/s390x/s390-pci-bus.h"
 #include "hw/s390x/s390-pci-kvm.h"
hw/scsi/esp-pci.c +1 -1
index 1792f84cea..2f7f11e70b 100644
@@ -24,7 +24,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/irq.h"
 #include "hw/nvram/eeprom93xx.h"
 #include "hw/scsi/esp.h"
hw/scsi/lsi53c895a.c +1 -1
index 50979640c3..af93557a9a 100644
@@ -16,7 +16,7 @@
 #include "qemu/osdep.h"
 
 #include "hw/irq.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/scsi/scsi.h"
 #include "migration/vmstate.h"
 #include "sysemu/dma.h"
hw/smbios/smbios.c +1 -0
index b4243de735..4869566cf5 100644
@@ -28,6 +28,7 @@
 #include "hw/loader.h"
 #include "hw/boards.h"
 #include "hw/pci/pci_bus.h"
+#include "hw/pci/pci_device.h"
 #include "smbios_build.h"
 
 /* legacy structures and constants for <= 2.0 machines */
hw/usb/hcd-ohci-pci.c +1 -1
index 8e1146b862..6b630d35a7 100644
@@ -23,7 +23,7 @@
 #include "qemu/timer.h"
 #include "hw/usb.h"
 #include "migration/vmstate.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/sysbus.h"
 #include "hw/qdev-dma.h"
 #include "hw/qdev-properties.h"
hw/watchdog/wdt_i6300esb.c +1 -1
index 5693ec6a09..54c167cd35 100644
@@ -24,7 +24,7 @@
 #include "qemu/module.h"
 #include "qemu/timer.h"
 #include "sysemu/watchdog.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "migration/vmstate.h"
 #include "qom/object.h"
 
tests/qtest/fuzz/generic_fuzz.c +1 -0
index afc1d20355..7326f6840b 100644
@@ -24,6 +24,7 @@
 #include "exec/ramblock.h"
 #include "hw/qdev-core.h"
 #include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/boards.h"
 #include "generic_fuzz_configs.h"
 #include "hw/mem/sparse-mem.h"
ui/util.c +1 -1
index 907d60e032..d54bbb74fb 100644
@@ -17,7 +17,7 @@
 
 #include "qemu/osdep.h"
 
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "hw/pci/pci_bus.h"
 #include "qapi/error.h"
 #include "ui/console.h"
Signature · 1 line
2.38.1
#6 lore raw

PATCH v2 6/7 include/hw/pci: Include hw/pci/pci.h where needed

In reply to Markus Armbruster

hw/pci/pcie_sriov.h needs PCI_NUM_REGIONS. Without the previous commit, this would close an inclusion loop: hw/pci/pci.h used to include hw/pci/pcie.h for PCIExpressDevice, which includes pcie_sriov.h for PCIESriovPF, which now includes hw/pci/pci.h for PCI_NUM_REGIONS.

---
 include/hw/pci/pcie_sriov.h | 2 ++
 1 file changed, 2 insertions(+)
include/hw/pci/pcie_sriov.h +2 -0
index 80f5c84e75..96cc743309 100644
@@ -13,6 +13,8 @@
 #ifndef QEMU_PCIE_SRIOV_H
 #define QEMU_PCIE_SRIOV_H
 
+#include "hw/pci/pci.h"
+
 struct PCIESriovPF {
     uint16_t num_vfs;   /* Number of virtual functions created */
     uint8_t vf_bar_type[PCI_NUM_REGIONS];   /* Store type for each VF bar */
Signature · 1 line
2.38.1
#7 lore raw

PATCH v2 7/7 include/hw/cxl: Break inclusion loop cxl_pci.h and cxl_cdat_h

In reply to Markus Armbruster

hw/cxl/cxl_pci.h and hw/cxl/cxl_cdat.h include each other. The former doesn't actually need the latter, so drop that inclusion to break the loop.

---
 include/hw/cxl/cxl_pci.h | 1 -
 1 file changed, 1 deletion(-)
include/hw/cxl/cxl_pci.h +0 -1
index aca14845ab..01e15ed5b4 100644
@@ -11,7 +11,6 @@
 #define CXL_PCI_H
 
 #include "qemu/compiler.h"
-#include "hw/cxl/cxl_cdat.h"
 
 #define CXL_VENDOR_ID 0x1e98
 
Signature · 1 line
2.38.1
#8 lore raw
In reply to Markus Armbruster

Am 22. Dezember 2022 10:03:23 UTC schrieb Markus Armbruster <[email protected]>:

Quoted 6 lines

Back in 2016, we discussed[1] rules for headers, and these were generally liked:

1. Have a carefully curated header that's included everywhere first. We got that already thanks to Peter: osdep.h.

Quoted 6 lines

2. Headers should normally include everything they need beyond osdep.h. If exceptions are needed for some reason, they must be documented in the header. If all that's needed from a header is typedefs, put those into qemu/typedefs.h instead of including the header.

3. Cyclic inclusion is forbidden.

Sounds like these -- useful and sane -- rules belong in QEMU's coding style. What about putting them there for easy reference?

Best regards,
Bernhard

Quoted 151 lines

After this series, include/hw/pci and include/hw/cxl conform to these rules.

It is based on

[PATCH v2 0/3] block: Clean up includes
[PATCH v3 0/5] coroutine: Clean up includes

v2:
* Rebased
* PATCH 1: Actually breaks an inclusion loop; commit message rephrased accordingly
* PATCH 2: New [Jonathan]
* PATCH 5: tests/qtest/fuzz/generic_fuzz.c fixed [Michael]
* PATCH 6: Inclusion of cxl_pci.h into cxl_cdat_h kept, commit message adjusted [Jonathan]

[1] Message-ID: <[email protected]>
https://lists.nongnu.org/archive/html/qemu-devel/2016-03/msg03345.html

Based-on: <[email protected]>

Markus Armbruster (7):
include/hw/pci: Break inclusion loop pci_bridge.h and cxl.h include/hw/cxl: Move typedef PXBDev to cxl.h, and put it to use include/hw/cxl: Include hw/cxl/*.h where needed include/hw/pci: Clean up a few things checkpatch.pl would flag include/hw/pci: Split pci_device.h off pci.h include/hw/pci: Include hw/pci/pci.h where needed include/hw/cxl: Break inclusion loop cxl_pci.h and cxl_cdat_h

hw/alpha/alpha_sys.h                |   1 -
hw/display/ati_int.h                |   2 +-
hw/display/qxl.h                    |   3 +-
hw/ide/ahci_internal.h              |   2 +-
hw/net/vmxnet3_defs.h               |   2 +-
hw/nvme/nvme.h                      |   2 +-
hw/rdma/rdma_utils.h                |   1 -
hw/rdma/vmw/pvrdma.h                |   2 +-
hw/scsi/mptsas.h                    |   2 +-
hw/usb/hcd-ehci.h                   |   3 +-
hw/usb/hcd-uhci.h                   |   2 +-
hw/usb/hcd-xhci-pci.h               |   1 +
hw/vfio/pci.h                       |   2 +-
hw/xen/xen_pt.h                     |   1 -
include/hw/acpi/piix4.h             |   2 +-
include/hw/arm/allwinner-a10.h      |   1 +
include/hw/cxl/cxl.h                |   5 +-
include/hw/cxl/cxl_cdat.h           |   1 +
include/hw/cxl/cxl_component.h      |   1 +
include/hw/cxl/cxl_device.h         |   2 +
include/hw/cxl/cxl_pci.h            |   3 -
include/hw/i386/ich9.h              |   4 -
include/hw/i386/x86-iommu.h         |   1 -
include/hw/ide/pci.h                |   2 +-
include/hw/isa/vt82c686.h           |   1 -
include/hw/misc/macio/macio.h       |   2 +-
include/hw/pci-host/designware.h    |   3 -
include/hw/pci-host/gpex.h          |   2 +-
include/hw/pci-host/i440fx.h        |   2 +-
include/hw/pci-host/ls7a.h          |   2 -
include/hw/pci-host/pnv_phb3.h      |   2 -
include/hw/pci-host/pnv_phb4.h      |   3 +-
include/hw/pci-host/q35.h           |   2 +-
include/hw/pci-host/sabre.h         |   2 +-
include/hw/pci-host/xilinx-pcie.h   |   1 -
include/hw/pci/msi.h                |   2 +-
include/hw/pci/pci.h                | 341 ---------------------------
include/hw/pci/pci_bridge.h         |   3 +-
include/hw/pci/pci_device.h         | 350 ++++++++++++++++++++++++++++
include/hw/pci/pcie.h               |   1 -
include/hw/pci/pcie_port.h          |   1 +
include/hw/pci/pcie_sriov.h         |   2 +
include/hw/pci/shpc.h               |   2 +-
include/hw/remote/iohub.h           |   2 +-
include/hw/remote/proxy.h           |   2 +-
include/hw/sd/sdhci.h               |   2 +-
include/hw/southbridge/piix.h       |   3 +-
include/hw/virtio/virtio-scsi.h     |   1 -
include/hw/xen/xen_common.h         |   2 +-
hw/acpi/erst.c                      |   2 +-
hw/alpha/pci.c                      |   1 +
hw/alpha/typhoon.c                  |   2 +-
hw/audio/ac97.c                     |   2 +-
hw/audio/es1370.c                   |   2 +-
hw/audio/via-ac97.c                 |   2 +-
hw/char/serial-pci-multi.c          |   2 +-
hw/char/serial-pci.c                |   2 +-
hw/core/qdev-properties-system.c    |   1 +
hw/display/bochs-display.c          |   2 +-
hw/display/cirrus_vga.c             |   2 +-
hw/display/sm501.c                  |   2 +-
hw/display/vga-pci.c                |   2 +-
hw/display/vmware_vga.c             |   2 +-
hw/i386/acpi-build.c                |   2 +-
hw/i386/xen/xen_pvdevice.c          |   2 +-
hw/ipack/tpci200.c                  |   2 +-
hw/ipmi/pci_ipmi_bt.c               |   2 +-
hw/ipmi/pci_ipmi_kcs.c              |   2 +-
hw/isa/i82378.c                     |   2 +-
hw/mips/gt64xxx_pci.c               |   2 +-
hw/misc/pci-testdev.c               |   2 +-
hw/misc/pvpanic-pci.c               |   2 +-
hw/net/can/can_kvaser_pci.c         |   2 +-
hw/net/can/can_mioe3680_pci.c       |   2 +-
hw/net/can/can_pcm3680_pci.c        |   2 +-
hw/net/can/ctucan_pci.c             |   2 +-
hw/net/e1000.c                      |   2 +-
hw/net/e1000x_common.c              |   2 +-
hw/net/eepro100.c                   |   2 +-
hw/net/ne2000-pci.c                 |   2 +-
hw/net/net_tx_pkt.c                 |   2 +-
hw/net/pcnet-pci.c                  |   2 +-
hw/net/rocker/rocker.c              |   2 +-
hw/net/rocker/rocker_desc.c         |   2 +-
hw/net/rtl8139.c                    |   2 +-
hw/net/sungem.c                     |   2 +-
hw/net/sunhme.c                     |   2 +-
hw/net/tulip.c                      |   2 +-
hw/net/virtio-net.c                 |   2 +-
hw/pci-bridge/i82801b11.c           |   2 +-
hw/pci-bridge/pci_expander_bridge.c |   1 -
hw/pci-host/bonito.c                |   2 +-
hw/pci-host/dino.c                  |   2 +-
hw/pci-host/grackle.c               |   2 +-
hw/pci-host/mv64361.c               |   2 +-
hw/pci-host/ppce500.c               |   2 +-
hw/pci-host/raven.c                 |   2 +-
hw/pci-host/sh_pci.c                |   2 +-
hw/pci-host/uninorth.c              |   2 +-
hw/pci-host/versatile.c             |   2 +-
hw/pci/pci-hmp-cmds.c               |   1 +
hw/pci/pcie_host.c                  |   2 +-
hw/pci/pcie_sriov.c                 |   2 +-
hw/pci/slotid_cap.c                 |   2 +-
hw/ppc/ppc440_pcix.c                |   2 +-
hw/ppc/ppc4xx_pci.c                 |   2 +-
hw/ppc/spapr_pci_vfio.c             |   1 +
hw/rdma/rdma_utils.c                |   1 +
hw/s390x/s390-pci-inst.c            |   1 +
hw/scsi/esp-pci.c                   |   2 +-
hw/scsi/lsi53c895a.c                |   2 +-
hw/scsi/virtio-scsi.c               |   1 +
hw/smbios/smbios.c                  |   1 +
hw/usb/hcd-ohci-pci.c               |   2 +-
hw/watchdog/wdt_i6300esb.c          |   2 +-
tests/qtest/fuzz/generic_fuzz.c     |   1 +
ui/util.c                           |   2 +-
117 files changed, 455 insertions(+), 455 deletions(-)

create mode 100644 include/hw/pci/pci_device.h

#9 lore raw
Quoted 7 lines · Bernhard Beschow

Am 22. Dezember 2022 10:03:23 UTC schrieb Markus Armbruster <[email protected]>:

Quoted 6 lines

Back in 2016, we discussed[1] rules for headers, and these were generally liked:

1. Have a carefully curated header that's included everywhere first. We got that already thanks to Peter: osdep.h.

Quoted 8 lines
Quoted 6 lines

2. Headers should normally include everything they need beyond osdep.h. If exceptions are needed for some reason, they must be documented in the header. If all that's needed from a header is typedefs, put those into qemu/typedefs.h instead of including the header.

3. Cyclic inclusion is forbidden.

Sounds like these -- useful and sane -- rules belong in QEMU's coding style. What about putting them there for easy reference?

Makes sense. I'll see what I can do. Thanks!

#10 lore raw
Quoted 14 lines · Markus Armbruster
Quoted 12 lines · Bernhard Beschow

Am 22. Dezember 2022 10:03:23 UTC schrieb Markus Armbruster <[email protected]>:

Quoted 11 lines

Back in 2016, we discussed[1] rules for headers, and these were generally liked:

1. Have a carefully curated header that's included everywhere first. We got that already thanks to Peter: osdep.h.

2. Headers should normally include everything they need beyond osdep.h. If exceptions are needed for some reason, they must be documented in the header. If all that's needed from a header is typedefs, put those into qemu/typedefs.h instead of including the header.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

3. Cyclic inclusion is forbidden.

Sounds like these -- useful and sane -- rules belong in QEMU's coding style. What about putting them there for easy reference?

Makes sense. I'll see what I can do. Thanks!

It would be even better if there was e.g. a make target pulling in each header and making sure it's self consistent and no circularity. We could run it e.g. in CI.

Signature · 1 line
MST
#11 lore raw
Quoted 17 lines · Michael S. Tsirkin
Quoted 16 lines · Markus Armbruster
Quoted 14 lines · Bernhard Beschow

Am 22. Dezember 2022 10:03:23 UTC schrieb Markus Armbruster <[email protected]>:

Quoted 12 lines

Back in 2016, we discussed[1] rules for headers, and these were generally liked:

1. Have a carefully curated header that's included everywhere first. We got that already thanks to Peter: osdep.h.

2. Headers should normally include everything they need beyond osdep.h. If exceptions are needed for some reason, they must be documented in the header. If all that's needed from a header is typedefs, put those into qemu/typedefs.h instead of including the header.

3. Cyclic inclusion is forbidden.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Sounds like these -- useful and sane -- rules belong in QEMU's coding style. What about putting them there for easy reference?

Makes sense. I'll see what I can do. Thanks!

It would be even better if there was e.g. a make target pulling in each header and making sure it's self consistent and no circularity. We could run it e.g. in CI.

Yes, that would be nice, but the problem I've been unable to crack is deciding whether a header is supposed to compile target-independently or not. In my manual testing, I use trial and error: if it fails to compile target-independently, compile for all targets. This is s-l-o-w.

The other problem, of course, is coding it up in Meson. I haven't even tried.

#12 lore raw

Am 23. Dezember 2022 05:27:07 UTC schrieb Markus Armbruster <[email protected]>:

Quoted 27 lines
Quoted 17 lines · Michael S. Tsirkin
Quoted 16 lines · Markus Armbruster
Quoted 14 lines · Bernhard Beschow

Am 22. Dezember 2022 10:03:23 UTC schrieb Markus Armbruster <[email protected]>:

Quoted 12 lines

Back in 2016, we discussed[1] rules for headers, and these were generally liked:

1. Have a carefully curated header that's included everywhere first. We got that already thanks to Peter: osdep.h.

2. Headers should normally include everything they need beyond osdep.h. If exceptions are needed for some reason, they must be documented in the header. If all that's needed from a header is typedefs, put those into qemu/typedefs.h instead of including the header.

3. Cyclic inclusion is forbidden.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Sounds like these -- useful and sane -- rules belong in QEMU's coding style. What about putting them there for easy reference?

Makes sense. I'll see what I can do. Thanks!

It would be even better if there was e.g. a make target pulling in each header and making sure it's self consistent and no circularity. We could run it e.g. in CI.

Quoted 7 lines

Yes, that would be nice, but the problem I've been unable to crack is deciding whether a header is supposed to compile target-independently or not. In my manual testing, I use trial and error: if it fails to compile target-independently, compile for all targets. This is s-l-o-w.

The other problem, of course, is coding it up in Meson. I haven't even tried.

There is https://include-what-you-use.org which is a Clang-based tool. Maybe that works?

Best regards,
Bernhard

#13 lore raw
In reply to Markus Armbruster
Quoted 23 lines · Markus Armbruster
Quoted 21 lines · Michael S. Tsirkin
Quoted 19 lines · Markus Armbruster
Quoted 7 lines · Bernhard Beschow

Am 22. Dezember 2022 10:03:23 UTC schrieb Markus Armbruster <[email protected]>:

Quoted 6 lines

Back in 2016, we discussed[1] rules for headers, and these were generally liked:

1. Have a carefully curated header that's included everywhere first. We got that already thanks to Peter: osdep.h.

Quoted 8 lines
Quoted 6 lines

2. Headers should normally include everything they need beyond osdep.h. If exceptions are needed for some reason, they must be documented in the header. If all that's needed from a header is typedefs, put those into qemu/typedefs.h instead of including the header.

3. Cyclic inclusion is forbidden.

Sounds like these -- useful and sane -- rules belong in QEMU's coding style. What about putting them there for easy reference?

Makes sense. I'll see what I can do. Thanks!

Quoted 8 lines
Quoted 3 lines

It would be even better if there was e.g. a make target pulling in each header and making sure it's self consistent and no circularity. We could run it e.g. in CI.

Yes, that would be nice, but the problem I've been unable to crack is deciding whether a header is supposed to compile target-independently or not. In my manual testing, I use trial and error: if it fails to compile target-independently, compile for all targets. This is s-l-o-w.

Yes and it's annoying for developers too.
Do we want to come up with a scheme for target-dependent files? Name them target-X or put in a target/ directory?
We could also write checkpatch rules to disallow including target specific headers in target independent files then.

Quoted 2 lines

The other problem, of course, is coding it up in Meson. I haven't even tried.

#14 lore raw
Quoted 18 lines · Michael S. Tsirkin
Quoted 17 lines · Markus Armbruster
Quoted 15 lines · Michael S. Tsirkin
Quoted 14 lines · Markus Armbruster
Quoted 12 lines · Bernhard Beschow

Am 22. Dezember 2022 10:03:23 UTC schrieb Markus Armbruster <[email protected]>:

Quoted 11 lines

Back in 2016, we discussed[1] rules for headers, and these were generally liked:

1. Have a carefully curated header that's included everywhere first. We got that already thanks to Peter: osdep.h.

2. Headers should normally include everything they need beyond osdep.h. If exceptions are needed for some reason, they must be documented in the header. If all that's needed from a header is typedefs, put those into qemu/typedefs.h instead of including the header.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

3. Cyclic inclusion is forbidden.

Sounds like these -- useful and sane -- rules belong in QEMU's coding style. What about putting them there for easy reference?

Makes sense. I'll see what I can do. Thanks!

Commit f07ceffdf50.

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

It would be even better if there was e.g. a make target pulling in each header and making sure it's self consistent and no circularity. We could run it e.g. in CI.

Yes, that would be nice, but the problem I've been unable to crack is deciding whether a header is supposed to compile target-independently or not. In my manual testing, I use trial and error: if it fails to compile target-independently, compile for all targets. This is s-l-o-w.

To spice things up, we also have headers that provide additional contents in target-dependent context. These need to be tested in both contexts.

Quoted 3 lines

Yes and it's annoying for developers too.
Do we want to come up with a scheme for target-dependent files? Name them target-X or put in a target/ directory?

I'd be in favour. Sadly, I'm not able to push such an effort myself.

Quoted 2 lines

We could also write checkpatch rules to disallow including target specific headers in target independent files then.

Fortunately, that's pretty unlikely to compile :)

Quoted 2 lines
Quoted 2 lines

The other problem, of course, is coding it up in Meson. I haven't even tried.

#15 lore raw
Quoted 32 lines · Markus Armbruster
Quoted 18 lines · Michael S. Tsirkin
Quoted 17 lines · Markus Armbruster
Quoted 15 lines · Michael S. Tsirkin
Quoted 14 lines · Markus Armbruster
Quoted 12 lines · Bernhard Beschow

Am 22. Dezember 2022 10:03:23 UTC schrieb Markus Armbruster <[email protected]>:

Quoted 11 lines

Back in 2016, we discussed[1] rules for headers, and these were generally liked:

1. Have a carefully curated header that's included everywhere first. We got that already thanks to Peter: osdep.h.

2. Headers should normally include everything they need beyond osdep.h. If exceptions are needed for some reason, they must be documented in the header. If all that's needed from a header is typedefs, put those into qemu/typedefs.h instead of including the header.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

3. Cyclic inclusion is forbidden.

Sounds like these -- useful and sane -- rules belong in QEMU's coding style. What about putting them there for easy reference?

Makes sense. I'll see what I can do. Thanks!

Commit f07ceffdf50.

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

It would be even better if there was e.g. a make target pulling in each header and making sure it's self consistent and no circularity. We could run it e.g. in CI.

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

Yes, that would be nice, but the problem I've been unable to crack is deciding whether a header is supposed to compile target-independently or not. In my manual testing, I use trial and error: if it fails to compile target-independently, compile for all targets. This is s-l-o-w.

To spice things up, we also have headers that provide additional contents in target-dependent context. These need to be tested in both contexts.

Do we need to figure a way to get rid of this problem in order to build a single qemu-system binary?

Quoted 13 lines
Quoted 3 lines

Yes and it's annoying for developers too.
Do we want to come up with a scheme for target-dependent files? Name them target-X or put in a target/ directory?

I'd be in favour. Sadly, I'm not able to push such an effort myself.

Quoted 2 lines

We could also write checkpatch rules to disallow including target specific headers in target independent files then.

Fortunately, that's pretty unlikely to compile :)

Quoted 2 lines
Quoted 2 lines

The other problem, of course, is coding it up in Meson. I haven't even tried.

#16 lore raw
Quoted 5 lines · Philippe Mathieu-Daudé
Quoted 4 lines · Markus Armbruster
Quoted 2 lines · Michael S. Tsirkin
Quoted 1 line · Markus Armbruster

"Michael S. Tsirkin" <[email protected]> writes:

[...]

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

It would be even better if there was e.g. a make target pulling in each header and making sure it's self consistent and no circularity. We could run it e.g. in CI.

Yes, that would be nice, but the problem I've been unable to crack is deciding whether a header is supposed to compile target-independently or not. In my manual testing, I use trial and error: if it fails to compile target-independently, compile for all targets. This is s-l-o-w.

Quoted 6 lines
Quoted 3 lines

To spice things up, we also have headers that provide additional contents in target-dependent context. These need to be tested in both contexts.

Do we need to figure a way to get rid of this problem in order to build a single qemu-system binary?

I don't know.