[v1] vfio/pci: Refine Intel IGD OpRegion support
diff mbox series

Message ID 20200709173707.29808-1-fred.gao@intel.com
State New
Headers show
Series
  • [v1] vfio/pci: Refine Intel IGD OpRegion support
Related show

Commit Message

Fred Gao July 9, 2020, 5:37 p.m. UTC
Bypass the IGD initialization for Intel's dgfx devices with own expansion
ROM and the host/LPC bridge config space are no longer accessed.

Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
Cc: Xiong Zhang <xiong.y.zhang@intel.com>
Cc: Hang Yuan <hang.yuan@linux.intel.com>
Cc: Stuart Summers <stuart.summers@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Fred Gao <fred.gao@intel.com>
---
 drivers/vfio/pci/vfio_pci.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

kernel test robot July 9, 2020, 11:12 a.m. UTC | #1
Hi Fred,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on vfio/next]
[also build test ERROR on v5.8-rc4 next-20200709]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use  as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Fred-Gao/vfio-pci-Refine-Intel-IGD-OpRegion-support/20200709-174242
base:   https://github.com/awilliam/linux-vfio.git next
config: i386-allyesconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-14) 9.3.0
reproduce (this is a W=1 build):
        # save the attached .config to linux build tree
        make W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

>> drivers/vfio/pci/vfio_pci.c:67:2: error: implicit declaration of function 'INTEL_DG1_IDS'; did you mean 'INTEL_G33_IDS'? [-Werror=implicit-function-declaration]
      67 |  INTEL_DG1_IDS(0),
         |  ^~~~~~~~~~~~~
         |  INTEL_G33_IDS
>> drivers/vfio/pci/vfio_pci.c:67:2: error: initializer element is not constant
   drivers/vfio/pci/vfio_pci.c:67:2: note: (near initialization for 'intel_dgfx_pciids[0].vendor')
>> drivers/vfio/pci/vfio_pci.c:68:2: warning: braces around scalar initializer
      68 |  { }
         |  ^
   drivers/vfio/pci/vfio_pci.c:68:2: note: (near initialization for 'intel_dgfx_pciids[0].device')
   cc1: some warnings being treated as errors

vim +67 drivers/vfio/pci/vfio_pci.c

    64	
    65	/* Intel's dgfx is not IGD, so don't handle them the same way */
    66	static const struct pci_device_id intel_dgfx_pciids[] = {
  > 67		INTEL_DG1_IDS(0),
  > 68		{ }
    69	};
    70	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Alex Williamson July 9, 2020, 3:27 p.m. UTC | #2
On Fri, 10 Jul 2020 01:37:07 +0800
Fred Gao <fred.gao@intel.com> wrote:

> Bypass the IGD initialization for Intel's dgfx devices with own expansion
> ROM and the host/LPC bridge config space are no longer accessed.
> 
> Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
> Cc: Xiong Zhang <xiong.y.zhang@intel.com>
> Cc: Hang Yuan <hang.yuan@linux.intel.com>
> Cc: Stuart Summers <stuart.summers@intel.com>
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> Signed-off-by: Fred Gao <fred.gao@intel.com>
> ---
>  drivers/vfio/pci/vfio_pci.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
> index f634c81998bb..0f4a34849836 100644
> --- a/drivers/vfio/pci/vfio_pci.c
> +++ b/drivers/vfio/pci/vfio_pci.c
> @@ -28,6 +28,8 @@
>  #include <linux/nospec.h>
>  #include <linux/sched/mm.h>
>  
> +#include <drm/i915_pciids.h>
> +
>  #include "vfio_pci_private.h"
>  
>  #define DRIVER_VERSION  "0.2"
> @@ -60,6 +62,12 @@ module_param(enable_sriov, bool, 0644);
>  MODULE_PARM_DESC(enable_sriov, "Enable support for SR-IOV configuration.  Enabling SR-IOV on a PF typically requires support of the userspace PF driver, enabling VFs without such support may result in non-functional VFs or PF.");
>  #endif
>  
> +/* Intel's dgfx is not IGD, so don't handle them the same way */
> +static const struct pci_device_id intel_dgfx_pciids[] = {
> +	INTEL_DG1_IDS(0),
> +	{ }
> +};
> +
>  static inline bool vfio_vga_disabled(void)
>  {
>  #ifdef CONFIG_VFIO_PCI_VGA
> @@ -339,7 +347,8 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev)
>  
>  	if (vfio_pci_is_vga(pdev) &&
>  	    pdev->vendor == PCI_VENDOR_ID_INTEL &&
> -	    IS_ENABLED(CONFIG_VFIO_PCI_IGD)) {
> +	    IS_ENABLED(CONFIG_VFIO_PCI_IGD) &&
> +	    !pci_match_id(intel_dgfx_pciids, pdev)) {
>  		ret = vfio_pci_igd_init(vdev);
>  		if (ret) {
>  			pci_warn(pdev, "Failed to setup Intel IGD regions\n");


Do we need to maintain specific IDs or could we simply test whether the
device is on the root bus to determine if it is integrated or discrete?
A discrete device should be connected to a downstream port rather than
appear on the root bus.  Thanks,

Alex

Patch
diff mbox series

diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index f634c81998bb..0f4a34849836 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -28,6 +28,8 @@ 
 #include <linux/nospec.h>
 #include <linux/sched/mm.h>
 
+#include <drm/i915_pciids.h>
+
 #include "vfio_pci_private.h"
 
 #define DRIVER_VERSION  "0.2"
@@ -60,6 +62,12 @@  module_param(enable_sriov, bool, 0644);
 MODULE_PARM_DESC(enable_sriov, "Enable support for SR-IOV configuration.  Enabling SR-IOV on a PF typically requires support of the userspace PF driver, enabling VFs without such support may result in non-functional VFs or PF.");
 #endif
 
+/* Intel's dgfx is not IGD, so don't handle them the same way */
+static const struct pci_device_id intel_dgfx_pciids[] = {
+	INTEL_DG1_IDS(0),
+	{ }
+};
+
 static inline bool vfio_vga_disabled(void)
 {
 #ifdef CONFIG_VFIO_PCI_VGA
@@ -339,7 +347,8 @@  static int vfio_pci_enable(struct vfio_pci_device *vdev)
 
 	if (vfio_pci_is_vga(pdev) &&
 	    pdev->vendor == PCI_VENDOR_ID_INTEL &&
-	    IS_ENABLED(CONFIG_VFIO_PCI_IGD)) {
+	    IS_ENABLED(CONFIG_VFIO_PCI_IGD) &&
+	    !pci_match_id(intel_dgfx_pciids, pdev)) {
 		ret = vfio_pci_igd_init(vdev);
 		if (ret) {
 			pci_warn(pdev, "Failed to setup Intel IGD regions\n");