On Fri, 22 Nov 2019 18:22:01 +0100
Philippe Mathieu-Daudé <phi...@redhat.com> 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é <phi...@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(-)
> 
> 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 */
>  }
>  

Note that this IGD thing has nothing to do with the one below in vfio
code.  AIUI, the one above is specific to Xen and very unfortunately
named and placed to seem more generic than it is.  vfio IGD
*assignment* (not passthrough) has no dependency on this, so please
don't link them together.  Thanks,

Alex

>  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


Reply via email to