diff mbox series

[RFC,PATCH-for-5.0] hw/pci-host: Add Kconfig selector for IGD PCIe pass-through

Message ID 20191122172201.11456-1-philmd@redhat.com
State New
Headers show
Series [RFC,PATCH-for-5.0] hw/pci-host: Add Kconfig selector for IGD PCIe pass-through | expand

Commit Message

Philippe Mathieu-Daudé Nov. 22, 2019, 5:22 p.m. UTC
Introduce a kconfig selector to allow builds without Intel
Integrated Graphics Device GPU PCIe passthrough.
We keep the default as enabled.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
RFC because to be able to use the Kconfig-generated
"config-devices.h" header we have to move this device
out of $common-obj and build i440fx.o on a per-target
basis, which is not optimal...
---
 hw/pci-host/i440fx.c      | 9 ++++++++-
 hw/vfio/pci-quirks.c      | 6 ++++++
 hw/pci-host/Kconfig       | 5 +++++
 hw/pci-host/Makefile.objs | 2 +-
 4 files changed, 20 insertions(+), 2 deletions(-)

Comments

Thomas Huth Nov. 22, 2019, 6:03 p.m. UTC | #1
On 22/11/2019 18.22, Philippe Mathieu-Daudé wrote:
> Introduce a kconfig selector to allow builds without Intel
> Integrated Graphics Device GPU PCIe passthrough.
> We keep the default as enabled.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> RFC because to be able to use the Kconfig-generated
> "config-devices.h" header we have to move this device
> out of $common-obj and build i440fx.o on a per-target
> basis, which is not optimal...

IMHO you should move the code out of i440fx.o and into a separate file
if possible. That's hopefully cleaner than #ifdeffing here, and you
hopefully only need to move the new code into "obj-" and can keep
i440fx.o in common-obj.

 Thomas
Philippe Mathieu-Daudé Nov. 22, 2019, 6:58 p.m. UTC | #2
On 11/22/19 7:03 PM, Thomas Huth wrote:
> On 22/11/2019 18.22, Philippe Mathieu-Daudé wrote:
>> Introduce a kconfig selector to allow builds without Intel
>> Integrated Graphics Device GPU PCIe passthrough.
>> We keep the default as enabled.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>> RFC because to be able to use the Kconfig-generated
>> "config-devices.h" header we have to move this device
>> out of $common-obj and build i440fx.o on a per-target
>> basis, which is not optimal...
> 
> IMHO you should move the code out of i440fx.o and into a separate file
> if possible. That's hopefully cleaner than #ifdeffing here, and you
> hopefully only need to move the new code into "obj-" and can keep
> i440fx.o in common-obj.

Correct. I wanted to try a surgical patch first ;)
no-reply@patchew.org Nov. 22, 2019, 8:26 p.m. UTC | #3
Patchew URL: https://patchew.org/QEMU/20191122172201.11456-1-philmd@redhat.com/



Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1
=== TEST SCRIPT END ===

  LINK    aarch64-softmmu/qemu-system-aarch64
hw/vfio/pci.o: In function `vfio_realize':
/tmp/qemu-test/src/hw/vfio/pci.c:2949: undefined reference to `vfio_pci_igd_opregion_init'
collect2: error: ld returned 1 exit status
make[1]: *** [qemu-system-x86_64] Error 1
make: *** [x86_64-softmmu/all] Error 2
make: *** Waiting for unfinished jobs....
hw/vfio/pci.o: In function `vfio_realize':
/tmp/qemu-test/src/hw/vfio/pci.c:2949: undefined reference to `vfio_pci_igd_opregion_init'
collect2: error: ld returned 1 exit status
make[1]: *** [qemu-system-aarch64] Error 1
make: *** [aarch64-softmmu/all] Error 2
Traceback (most recent call last):
  File "./tests/docker/docker.py", line 662, in <module>
    sys.exit(main())
---
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=57b8f6e005964f0cb505a02139414e88', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-o78ntsrk/src/docker-src.2019-11-22-15.23.40.28372:/var/tmp/qemu:z,ro', 'qemu:centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2.
filter=--filter=label=com.qemu.instance.uuid=57b8f6e005964f0cb505a02139414e88
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-o78ntsrk/src'
make: *** [docker-run-test-quick@centos7] Error 2

real    2m36.282s
user    0m7.884s


The full log is available at
http://patchew.org/logs/20191122172201.11456-1-philmd@redhat.com/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
Paolo Bonzini Nov. 23, 2019, 9:56 a.m. UTC | #4
On 22/11/19 18:34, Alex Williamson wrote:
> +config INTEL_IGD_PASSTHROUGH
> +    default y

If it's "default y", it need not be "implied".  It probably shouldn't be
"default y", since it's I440FX-specific.

Paolo

> +    bool
> +
>  config PREP_PCI
>      bool
>      select PCI
> @@ -32,6 +36,7 @@ config PCI_I440FX
>      bool
>      select PCI
>      select PAM
> +    imply INTEL_IGD_PASSTHROUGH
>
diff mbox series

Patch

diff --git a/hw/pci-host/i440fx.c b/hw/pci-host/i440fx.c
index f27131102d..41e93581f4 100644
--- a/hw/pci-host/i440fx.c
+++ b/hw/pci-host/i440fx.c
@@ -34,6 +34,7 @@ 
 #include "hw/pci-host/pam.h"
 #include "qapi/visitor.h"
 #include "qemu/error-report.h"
+#include "config-devices.h"
 
 /*
  * I440FX chipset data sheet.
@@ -386,6 +387,8 @@  static const TypeInfo i440fx_info = {
     },
 };
 
+#ifdef CONFIG_INTEL_IGD_PASSTHROUGH
+
 /* IGD Passthrough Host Bridge. */
 typedef struct {
     uint8_t offset;
@@ -470,6 +473,8 @@  static const TypeInfo igd_passthrough_i440fx_info = {
     .class_init    = igd_passthrough_i440fx_class_init,
 };
 
+#endif /* CONFIG_INTEL_IGD_PASSTHROUGH */
+
 static const char *i440fx_pcihost_root_bus_path(PCIHostState *host_bridge,
                                                 PCIBus *rootbus)
 {
@@ -514,8 +519,10 @@  static const TypeInfo i440fx_pcihost_info = {
 static void i440fx_register_types(void)
 {
     type_register_static(&i440fx_info);
-    type_register_static(&igd_passthrough_i440fx_info);
     type_register_static(&i440fx_pcihost_info);
+#ifdef CONFIG_INTEL_IGD_PASSTHROUGH
+    type_register_static(&igd_passthrough_i440fx_info);
+#endif /* CONFIG_INTEL_IGD_PASSTHROUGH */
 }
 
 type_init(i440fx_register_types)
diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
index 136f3a9ad6..858148fa39 100644
--- a/hw/vfio/pci-quirks.c
+++ b/hw/vfio/pci-quirks.c
@@ -1166,6 +1166,8 @@  static void vfio_probe_rtl8168_bar2_quirk(VFIOPCIDevice *vdev, int nr)
     trace_vfio_quirk_rtl8168_probe(vdev->vbasedev.name);
 }
 
+#ifdef CONFIG_INTEL_IGD_PASSTHROUGH
+
 /*
  * Intel IGD support
  *
@@ -1811,6 +1813,8 @@  out:
     g_free(lpc);
 }
 
+#endif /* CONFIG_INTEL_IGD_PASSTHROUGH */
+
 /*
  * Common quirk probe entry points.
  */
@@ -1860,7 +1864,9 @@  void vfio_bar_quirk_setup(VFIOPCIDevice *vdev, int nr)
     vfio_probe_nvidia_bar5_quirk(vdev, nr);
     vfio_probe_nvidia_bar0_quirk(vdev, nr);
     vfio_probe_rtl8168_bar2_quirk(vdev, nr);
+#ifdef CONFIG_INTEL_IGD_PASSTHROUGH
     vfio_probe_igd_bar4_quirk(vdev, nr);
+#endif /* CONFIG_INTEL_IGD_PASSTHROUGH */
 }
 
 void vfio_bar_quirk_exit(VFIOPCIDevice *vdev, int nr)
diff --git a/hw/pci-host/Kconfig b/hw/pci-host/Kconfig
index b0aa8351c4..0b7539765a 100644
--- a/hw/pci-host/Kconfig
+++ b/hw/pci-host/Kconfig
@@ -1,6 +1,10 @@ 
 config PAM
     bool
 
+config INTEL_IGD_PASSTHROUGH
+    default y
+    bool
+
 config PREP_PCI
     bool
     select PCI
@@ -32,6 +36,7 @@  config PCI_I440FX
     bool
     select PCI
     select PAM
+    imply INTEL_IGD_PASSTHROUGH
 
 config PCI_EXPRESS_Q35
     bool
diff --git a/hw/pci-host/Makefile.objs b/hw/pci-host/Makefile.objs
index efd752b766..3c925192dd 100644
--- a/hw/pci-host/Makefile.objs
+++ b/hw/pci-host/Makefile.objs
@@ -13,7 +13,7 @@  common-obj-$(CONFIG_VERSATILE_PCI) += versatile.o
 
 common-obj-$(CONFIG_PCI_SABRE) += sabre.o
 common-obj-$(CONFIG_FULONG) += bonito.o
-common-obj-$(CONFIG_PCI_I440FX) += i440fx.o
+obj-$(CONFIG_PCI_I440FX) += i440fx.o
 common-obj-$(CONFIG_PCI_EXPRESS_Q35) += q35.o
 common-obj-$(CONFIG_PCI_EXPRESS_GENERIC_BRIDGE) += gpex.o
 common-obj-$(CONFIG_PCI_EXPRESS_XILINX) += xilinx-pcie.o