diff mbox series

drm/i915: Try to guess PCH type even without ISA bridge

Message ID 20201214070113.16177-1-xiong.y.zhang@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915: Try to guess PCH type even without ISA bridge | expand

Commit Message

Zhang, Xiong Y Dec. 14, 2020, 7:01 a.m. UTC
From: Zhenyu Wang <zhenyuw@linux.intel.com>

Some vmm like hyperv and crosvm doesn't supply any ISA bridge to its guest,
when igd passthrough is equipped on these vmm, guest i915 display may
couldn't work as i915 detects pch type as PCH_NONE.

When i915 runs as guest, this patch guess pch type through gpu type even
without ISA bridge.

Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h  |  7 +++++-
 drivers/gpu/drm/i915/intel_pch.c | 37 +++++++++++++++++++++-----------
 2 files changed, 31 insertions(+), 13 deletions(-)

Comments

kernel test robot Dec. 14, 2020, 10:10 a.m. UTC | #1
Hi Xiong,

I love your patch! Perhaps something to improve:

[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on drm-tip/drm-tip v5.10 next-20201211]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Xiong-Zhang/drm-i915-Try-to-guess-PCH-type-even-without-ISA-bridge/20201214-150157
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: i386-randconfig-s002-20201214 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-184-g1b896707-dirty
        # https://github.com/0day-ci/linux/commit/718272991fa5c06a48629bce020ecfbdea006f96
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Xiong-Zhang/drm-i915-Try-to-guess-PCH-type-even-without-ISA-bridge/20201214-150157
        git checkout 718272991fa5c06a48629bce020ecfbdea006f96
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386 

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


"sparse warnings: (new ones prefixed by >>)"
>> drivers/gpu/drm/i915/intel_pch.c:187:6: sparse: sparse: symbol 'intel_detect_pch_virt' was not declared. Should it be static?

Please review and possibly fold the followup patch.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot Dec. 14, 2020, 12:50 p.m. UTC | #2
Hi Xiong,

I love your patch! Perhaps something to improve:

[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on drm-tip/drm-tip v5.10 next-20201211]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Xiong-Zhang/drm-i915-Try-to-guess-PCH-type-even-without-ISA-bridge/20201214-150157
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: x86_64-randconfig-a002-20201214 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project d38205144febf4dc42c9270c6aa3d978f1ef65e1)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # https://github.com/0day-ci/linux/commit/718272991fa5c06a48629bce020ecfbdea006f96
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Xiong-Zhang/drm-i915-Try-to-guess-PCH-type-even-without-ISA-bridge/20201214-150157
        git checkout 718272991fa5c06a48629bce020ecfbdea006f96
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

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

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/i915/intel_pch.c:187:6: warning: no previous prototype for function 'intel_detect_pch_virt' [-Wmissing-prototypes]
   void intel_detect_pch_virt(struct drm_i915_private *dev_priv)
        ^
   drivers/gpu/drm/i915/intel_pch.c:187:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void intel_detect_pch_virt(struct drm_i915_private *dev_priv)
   ^
   static 
   1 warning generated.

vim +/intel_detect_pch_virt +187 drivers/gpu/drm/i915/intel_pch.c

   186	
 > 187	void intel_detect_pch_virt(struct drm_i915_private *dev_priv)
   188	{
   189		unsigned short id;
   190		enum intel_pch pch_type;
   191	
   192		id = intel_virt_detect_pch(dev_priv);
   193		pch_type = intel_pch_type(dev_priv, id);
   194	
   195		/* Sanity check virtual PCH id */
   196		if (drm_WARN_ON(&dev_priv->drm,
   197				id && pch_type == PCH_NONE))
   198			id = 0;
   199	
   200		dev_priv->pch_type = pch_type;
   201		dev_priv->pch_id = id;
   202	}
   203	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 15be8debae54..1e7b1d33708a 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1756,6 +1756,11 @@  tgl_revids_get(struct drm_i915_private *dev_priv)
 #define INTEL_DISPLAY_ENABLED(dev_priv) \
 	(drm_WARN_ON(&(dev_priv)->drm, !HAS_DISPLAY(dev_priv)), !(dev_priv)->params.disable_display)
 
+static inline bool run_as_guest(void)
+{
+	return !hypervisor_is_type(X86_HYPER_NATIVE);
+}
+
 static inline bool intel_vtd_active(void)
 {
 #ifdef CONFIG_INTEL_IOMMU
@@ -1764,7 +1769,7 @@  static inline bool intel_vtd_active(void)
 #endif
 
 	/* Running as a guest, we assume the host is enforcing VT'd */
-	return !hypervisor_is_type(X86_HYPER_NATIVE);
+	return run_as_guest();
 }
 
 static inline bool intel_scanout_needs_vtd_wa(struct drm_i915_private *dev_priv)
diff --git a/drivers/gpu/drm/i915/intel_pch.c b/drivers/gpu/drm/i915/intel_pch.c
index f31c0dabd0cc..ca5989700ecf 100644
--- a/drivers/gpu/drm/i915/intel_pch.c
+++ b/drivers/gpu/drm/i915/intel_pch.c
@@ -184,6 +184,23 @@  intel_virt_detect_pch(const struct drm_i915_private *dev_priv)
 	return id;
 }
 
+void intel_detect_pch_virt(struct drm_i915_private *dev_priv)
+{
+	unsigned short id;
+	enum intel_pch pch_type;
+
+	id = intel_virt_detect_pch(dev_priv);
+	pch_type = intel_pch_type(dev_priv, id);
+
+	/* Sanity check virtual PCH id */
+	if (drm_WARN_ON(&dev_priv->drm,
+			id && pch_type == PCH_NONE))
+		id = 0;
+
+	dev_priv->pch_type = pch_type;
+	dev_priv->pch_id = id;
+}
+
 void intel_detect_pch(struct drm_i915_private *dev_priv)
 {
 	struct pci_dev *pch = NULL;
@@ -221,16 +238,7 @@  void intel_detect_pch(struct drm_i915_private *dev_priv)
 			break;
 		} else if (intel_is_virt_pch(id, pch->subsystem_vendor,
 					     pch->subsystem_device)) {
-			id = intel_virt_detect_pch(dev_priv);
-			pch_type = intel_pch_type(dev_priv, id);
-
-			/* Sanity check virtual PCH id */
-			if (drm_WARN_ON(&dev_priv->drm,
-					id && pch_type == PCH_NONE))
-				id = 0;
-
-			dev_priv->pch_type = pch_type;
-			dev_priv->pch_id = id;
+			intel_detect_pch_virt(dev_priv);
 			break;
 		}
 	}
@@ -246,8 +254,13 @@  void intel_detect_pch(struct drm_i915_private *dev_priv)
 		dev_priv->pch_id = 0;
 	}
 
-	if (!pch)
-		drm_dbg_kms(&dev_priv->drm, "No PCH found.\n");
+	if (!pch) {
+		if (run_as_guest()) {
+			drm_dbg_kms(&dev_priv->drm, "No PCH found in vm, try guess..\n");
+			intel_detect_pch_virt(dev_priv);
+		} else
+			drm_dbg_kms(&dev_priv->drm, "No PCH found.\n");
+	}
 
 	pci_dev_put(pch);
 }