Skip to contentSkip to conversation

hw/pci-bridge: fix build with CONFIG_CXL disabled

PATCH In review Daniel P. Berrangé 2 participants 5 messages Sep 28 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

v2 cover hw/pci-bridge: fix build with CONFIG_CXL disabled

See patch 2 for the details

Changed in v2:

* Instead of using CONFIG_CXL in pci_expander_bridge.c split the file in two and conditionalize in meson.build

Daniel P. Berrangé (2):
hw/arm: remove pci-bridge/pci_expander_bridge.h from virt.c hw/pci-bridge: split CXL PXB into separate file

 hw/arm/virt.c                                 |   1 -
 hw/cxl/cxl-host.c                             |   2 +-
 hw/pci-bridge/meson.build                     |   4 +-
 hw/pci-bridge/pci_expander_bridge.c           | 194 +----------------
 hw/pci-bridge/pci_expander_bridge_common.h    |  29 +++
 hw/pci-bridge/pci_expander_bridge_cxl.c       | 201 ++++++++++++++++++
 hw/pci-bridge/pci_expander_bridge_stubs.c     |  14 --
 ...der_bridge.h => pci_expander_bridge_cxl.h} |   0
 8 files changed, 242 insertions(+), 203 deletions(-)
 create mode 100644 hw/pci-bridge/pci_expander_bridge_common.h
 create mode 100644 hw/pci-bridge/pci_expander_bridge_cxl.c
 delete mode 100644 hw/pci-bridge/pci_expander_bridge_stubs.c
 rename include/hw/pci-bridge/{pci_expander_bridge.h => pci_expander_bridge_cxl.h} (100%)
Signature · 1 line
2.55.0
#1 lore raw

PATCH v2 1/2 hw/arm: remove pci-bridge/pci_expander_bridge.h from virt.c

This include is redundant as the function is declares is not referenced.

---
 hw/arm/virt.c | 1 -
 1 file changed, 1 deletion(-)
hw/arm/virt.c +0 -1
index 3eecf094bcc..a570832fc0e 100644
@@ -58,7 +58,6 @@
 #include "qemu/module.h"
 #include "hw/pci/pci_bus.h"
 #include "hw/pci-host/gpex.h"
-#include "hw/pci-bridge/pci_expander_bridge.h"
 #include "hw/virtio/virtio-pci.h"
 #include "hw/core/sysbus-fdt.h"
 #include "hw/core/platform-bus.h"
Signature · 1 line
2.55.0
#3 lore raw

PATCH v2 2/2 hw/pci-bridge: split CXL PXB into separate file

In reply to Daniel P. Berrangé

If CONFIG_CXL=n is added to the Kconfig, the build fails to link the PXB device:

/usr/bin/ld.bfd: libsystem.a.p/hw_pci-bridge_pci_expander_bridge.c.o: in function `pxb_cxl_realize':
/home/berrange/src/virt/qemu/build/../hw/pci-bridge/pci_expander_bridge.c:202:(.text+0x330): undefined reference to cxl_component_register_block_init' /usr/bin/ld.bfd: libsystem.a.p/hw_pci-bridge_pci_expander_bridge.c.o: in function pxb_cxl_dev_reset':
/home/berrange/src/virt/qemu/build/../hw/pci-bridge/pci_expander_bridge.c:309:(.text+0x768): undefined reference to `cxl_component_register_init_common'

We cannot use CONFIG_CXL in pci_expander_bridge.c because the identifier is poisoned. Instead the CXL pieces must be split off into a separate source file which can be conditionally built.

With this change, the stubs file is no longer required, since the code referencing the stub was already protected by CONFIG_CXL.

Fixes 6e4e3ae936 (hw/cxl/component: Implement host bridge MMIO (8.2.5, table 142))
---
 hw/cxl/cxl-host.c                             |   2 +-
 hw/pci-bridge/meson.build                     |   4 +-
 hw/pci-bridge/pci_expander_bridge.c           | 194 +----------------
 hw/pci-bridge/pci_expander_bridge_common.h    |  29 +++
 hw/pci-bridge/pci_expander_bridge_cxl.c       | 201 ++++++++++++++++++
 hw/pci-bridge/pci_expander_bridge_stubs.c     |  14 --
 ...der_bridge.h => pci_expander_bridge_cxl.h} |   0
 7 files changed, 242 insertions(+), 202 deletions(-)
 create mode 100644 hw/pci-bridge/pci_expander_bridge_common.h
 create mode 100644 hw/pci-bridge/pci_expander_bridge_cxl.c
 delete mode 100644 hw/pci-bridge/pci_expander_bridge_stubs.c
 rename include/hw/pci-bridge/{pci_expander_bridge.h => pci_expander_bridge_cxl.h} (100%)
hw/cxl/cxl-host.c +1 -1
index e279ce5fe3a..cda4dfed50d 100644
@@ -20,7 +20,7 @@
 #include "hw/pci/pci_bridge.h"
 #include "hw/pci/pci_host.h"
 #include "hw/pci/pcie_port.h"
-#include "hw/pci-bridge/pci_expander_bridge.h"
+#include "hw/pci-bridge/pci_expander_bridge_cxl.h"
 
 static void cxl_fixed_memory_window_config(CXLFixedMemoryWindowOptions *object,
                                            int index, Error **errp)
hw/pci-bridge/meson.build +2 -2
index 2e0eb0d2332..aaeef64caaa 100644
@@ -4,8 +4,8 @@ pci_ss.add(when: 'CONFIG_I82801B11', if_true: files('i82801b11.c'))
 pci_ss.add(when: 'CONFIG_IOH3420', if_true: files('ioh3420.c'))
 pci_ss.add(when: 'CONFIG_PCIE_PORT', if_true: files('pcie_root_port.c', 'gen_pcie_root_port.c'))
 pci_ss.add(when: 'CONFIG_PCIE_PCI_BRIDGE', if_true: files('pcie_pci_bridge.c'))
-pci_ss.add(when: 'CONFIG_PXB', if_true: files('pci_expander_bridge.c'),
-                               if_false: files('pci_expander_bridge_stubs.c'))
+pci_ss.add(when: 'CONFIG_PXB', if_true: files('pci_expander_bridge.c'))
+pci_ss.add(when: 'CONFIG_CXL', if_true: files('pci_expander_bridge_cxl.c'))
 pci_ss.add(when: 'CONFIG_XIO3130', if_true: files('xio3130_upstream.c', 'xio3130_downstream.c'))
 pci_ss.add(when: 'CONFIG_CXL', if_true: files('cxl_root_port.c', 'cxl_upstream.c', 'cxl_downstream.c'))
 
hw/pci-bridge/pci_expander_bridge.c +9 -185

273 lines not on this page · raw message

hw/pci-bridge/pci_expander_bridge_common.h new file +29 -0
new file mode 100644
index 00000000000..fc5d1ac8691
@@ -0,0 +1,29 @@
+/*
+ * PCI Expander Bridge Device Emulation Common Code
+ *
+ * Copyright (C) 2015 Red Hat Inc
+ *
+ * Authors:
+ *   Marcel Apfelbaum <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+enum BusType { PCI, PCIE, CXL };
+
+typedef struct PXBBus PXBBus;
+
+struct PXBBus {
+    /*< private >*/
+    PCIBus parent_obj;
+    /*< public >*/
+
+    char bus_path[8];
+};
+
+int pxb_bus_num(PCIBus *bus);
+void pxb_bus_class_init(ObjectClass *class, const void *data);
+bool pxb_dev_realize_common(PCIDevice *dev, enum BusType type,
+                            Error **errp);
+void pxb_dev_exitfn(PCIDevice *pci_dev);
hw/pci-bridge/pci_expander_bridge_cxl.c new file +201 -0

201 lines not on this page · raw message

hw/pci-bridge/pci_expander_bridge_stubs.c deleted +0 -14
deleted file mode 100644
index b35180311f6..00000000000
@@ -1,14 +0,0 @@
-/*
- * SPDX-License-Identifier: GPL-2.0-or-later
- *
- * Stubs for calls made from machines to handle the case where CONFIG_PXB
- * is not enabled.
- */
-#include "qemu/osdep.h"
-#include "qapi/error.h"
-#include "hw/pci/pci.h"
-#include "hw/pci/pci_bus.h"
-#include "hw/pci-bridge/pci_expander_bridge.h"
-#include "hw/cxl/cxl.h"
-
-void pxb_cxl_hook_up_registers(CXLState *state, PCIBus *bus, Error **errp) {};
include/hw/pci-bridge/pci_expander_bridge_cxl.h renamed from include/hw/pci-bridge/pci_expander_bridge.h +0 -0
similarity index 100%
rename from include/hw/pci-bridge/pci_expander_bridge.h
rename to include/hw/pci-bridge/pci_expander_bridge_cxl.h
Signature · 1 line
2.55.0
Reviewed-by on v2 2/2
#4 lore raw

Re: [PATCH v2 2/2] hw/pci-bridge: split CXL PXB into separate file

Quoted 49 lines · Daniel P. Berrangé

If CONFIG_CXL=n is added to the Kconfig, the build fails to link the PXB device:

/usr/bin/ld.bfd: libsystem.a.p/hw_pci-bridge_pci_expander_bridge.c.o: in function `pxb_cxl_realize':
/home/berrange/src/virt/qemu/build/../hw/pci-bridge/pci_expander_bridge.c:202:(.text+0x330): undefined reference to cxl_component_register_block_init' /usr/bin/ld.bfd: libsystem.a.p/hw_pci-bridge_pci_expander_bridge.c.o: in function pxb_cxl_dev_reset':
/home/berrange/src/virt/qemu/build/../hw/pci-bridge/pci_expander_bridge.c:309:(.text+0x768): undefined reference to `cxl_component_register_init_common'

We cannot use CONFIG_CXL in pci_expander_bridge.c because the identifier is poisoned. Instead the CXL pieces must be split off into a separate source file which can be conditionally built.

With this change, the stubs file is no longer required, since the code referencing the stub was already protected by CONFIG_CXL.

Fixes 6e4e3ae936 (hw/cxl/component: Implement host bridge MMIO (8.2.5, table 142))
---
  hw/cxl/cxl-host.c                             |   2 +-
  hw/pci-bridge/meson.build                     |   4 +-
  hw/pci-bridge/pci_expander_bridge.c           | 194 +----------------
  hw/pci-bridge/pci_expander_bridge_common.h    |  29 +++
  hw/pci-bridge/pci_expander_bridge_cxl.c       | 201 ++++++++++++++++++
  hw/pci-bridge/pci_expander_bridge_stubs.c     |  14 --
  ...der_bridge.h => pci_expander_bridge_cxl.h} |   0
  7 files changed, 242 insertions(+), 202 deletions(-)

create mode 100644 hw/pci-bridge/pci_expander_bridge_common.h
create mode 100644 hw/pci-bridge/pci_expander_bridge_cxl.c
delete mode 100644 hw/pci-bridge/pci_expander_bridge_stubs.c
rename include/hw/pci-bridge/{pci_expander_bridge.h => pci_expander_bridge_cxl.h} (100%)

hw/pci-bridge/pci_expander_bridge_common.h new file +10 -0
new file mode 100644
index 00000000000..fc5d1ac8691
@@ -0,0 +1,29 @@
+/*
+ * PCI Expander Bridge Device Emulation Common Code
+ *
+ * Copyright (C) 2015 Red Hat Inc
+ *
+ * Authors:
+ *   Marcel Apfelbaum <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.

hw/pci-bridge/pci_expander_bridge_common.h line 20

Quoted 10 lines
hw/pci-bridge/pci_expander_bridge_common.h new file +10 -0
+ */
+
+enum BusType { PCI, PCIE, CXL };
+
+typedef struct PXBBus PXBBus;
+
+struct PXBBus {
+    /*< private >*/
+    PCIBus parent_obj;
+    /*< public >*/

We updated our coding style to not use these private/public comments anymore. I can remove them if MST is OK to merge via hw-misc tree.

Quoted 3 lines
hw/pci-bridge/pci_expander_bridge_common.h new file +3 -0
+
+    char bus_path[8];
+};