Skip to contentSkip to conversation

i915/gvt: Separate the MMIO tracking table from GVT-g

PATCH Superseded Zhi Wang 6 participants 17 messages Mar 25, 2022 – Apr 1, 2022

Subsystems (3)

v7 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Zhi Wang

author reviewer
#0 lore raw

PATCH v7 1/3 i915/gvt: Separate the MMIO tracking table from GVT-g

From: Zhi Wang <[email protected]>

To support the new mdev interfaces and the re-factor patches from Christoph, which moves the GVT-g code into a dedicated module, the GVT-g MMIO tracking table needs to be separated from GVT-g.

v7:

- Keep the marcos of device generation in GVT-g. (Christoph, Jani)

v6:

- Move the mmio_table.c into i915. (Christoph)
- Keep init_device_info and related structures in GVT-g. (Christoph)
- Refine the callbacks of the iterator. (Christoph)
- Move the flags of MMIO register defination to GVT-g. (Chrsitoph)
- Move the mmio block handling to GVT-g.

v5:

- Re-design the mmio table framework. (Christoph)

v4:

- Fix the errors of patch checking scripts.

v3:

- Fix the errors when CONFIG_DRM_I915_WERROR is turned on. (Jani)

v2:

- Implement a mmio table instead of generating it by marco in i915. (Jani)

Cc Christoph Hellwig <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Vivi Rodrigo <[email protected]>
Cc Zhenyu Wang <[email protected]>
Cc Zhi Wang <[email protected]>
---
 drivers/gpu/drm/i915/Makefile               |    2 +-
 drivers/gpu/drm/i915/gvt/gvt.h              |    3 +-
 drivers/gpu/drm/i915/gvt/handlers.c         | 1031 ++-------------
 drivers/gpu/drm/i915/gvt/mmio.h             |    1 -
 drivers/gpu/drm/i915/gvt/reg.h              |    9 +-
 drivers/gpu/drm/i915/intel_gvt.h            |   21 +
 drivers/gpu/drm/i915/intel_gvt_mmio_table.c | 1308 +++++++++++++++++++
 7 files changed, 1476 insertions(+), 899 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_gvt_mmio_table.c
drivers/gpu/drm/i915/Makefile +1 -1
index 9d588d936e3d..cbd1a0a01cda 100644
@@ -320,7 +320,7 @@ i915-$(CONFIG_DRM_I915_SELFTEST) += \
 i915-y += i915_vgpu.o
 
 ifeq ($(CONFIG_DRM_I915_GVT),y)
-i915-y += intel_gvt.o
+i915-y += intel_gvt.o intel_gvt_mmio_table.o
 include $(src)/gvt/Makefile
 endif
 
drivers/gpu/drm/i915/gvt/gvt.h +2 -1
index 0ebffc327528..bfe07c69cfd2 100644
@@ -36,6 +36,7 @@
 #include <uapi/linux/pci_regs.h>
 
 #include "i915_drv.h"
+#include "intel_gvt.h"
 
 #include "debug.h"
 #include "hypercall.h"
@@ -272,7 +273,7 @@ struct intel_gvt_mmio {
 /* Value of command write of this reg needs to be patched */
 #define F_CMD_WRITE_PATCH	(1 << 8)
 
-	const struct gvt_mmio_block *mmio_block;
+	struct gvt_mmio_block *mmio_block;
 	unsigned int num_mmio_block;
 
 	DECLARE_HASHTABLE(mmio_info_table, INTEL_GVT_MMIO_HASH_BITS);
drivers/gpu/drm/i915/gvt/handlers.c +136 -895

1,376 lines not on this page · raw message

drivers/gpu/drm/i915/gvt/mmio.h +0 -1
index 7c26af39fbfc..bba154e38705 100644
@@ -72,7 +72,6 @@ struct intel_gvt_mmio_info {
 const struct intel_engine_cs *
 intel_gvt_render_mmio_to_engine(struct intel_gvt *gvt, unsigned int reg);
 unsigned long intel_gvt_get_device_type(struct intel_gvt *gvt);
-bool intel_gvt_match_device(struct intel_gvt *gvt, unsigned long device);
 
 int intel_gvt_setup_mmio_info(struct intel_gvt *gvt);
 void intel_gvt_clean_mmio_info(struct intel_gvt *gvt);
drivers/gpu/drm/i915/gvt/reg.h +8 -1
index 7d666d34f9ff..d8216c63c39a 100644
@@ -132,6 +132,13 @@
 #define RING_GFX_MODE(base)	_MMIO((base) + 0x29c)
 #define VF_GUARDBAND		_MMIO(0x83a4)
 
-
 #define BCS_TILE_REGISTER_VAL_OFFSET (0x43*4)
+
+/* XXX FIXME i915 has changed PP_XXX definition */
+#define PCH_PP_STATUS  _MMIO(0xc7200)
+#define PCH_PP_CONTROL _MMIO(0xc7204)
+#define PCH_PP_ON_DELAYS _MMIO(0xc7208)
+#define PCH_PP_OFF_DELAYS _MMIO(0xc720c)
+#define PCH_PP_DIVISOR _MMIO(0xc7210)
+
 #endif
drivers/gpu/drm/i915/intel_gvt.h +21 -0
index d7d3fb6186fd..7665d7cf0bdd 100644
@@ -26,7 +26,17 @@
 
 struct drm_i915_private;
 
+#include <linux/kernel.h>
+
 #ifdef CONFIG_DRM_I915_GVT
+
+struct intel_gvt_mmio_table_iter {
+	struct drm_i915_private *i915;
+	void *data;
+	int (*handle_mmio_cb)(struct intel_gvt_mmio_table_iter *iter,
+			      u32 offset, u32 size);
+};
+
 int intel_gvt_init(struct drm_i915_private *dev_priv);
 void intel_gvt_driver_remove(struct drm_i915_private *dev_priv);
 int intel_gvt_init_device(struct drm_i915_private *dev_priv);
@@ -34,6 +44,7 @@ void intel_gvt_clean_device(struct drm_i915_private *dev_priv);
 int intel_gvt_init_host(void);
 void intel_gvt_sanitize_options(struct drm_i915_private *dev_priv);
 void intel_gvt_resume(struct drm_i915_private *dev_priv);
+int intel_gvt_iterate_mmio_table(struct intel_gvt_mmio_table_iter *iter);
 #else
 static inline int intel_gvt_init(struct drm_i915_private *dev_priv)
 {
@@ -51,6 +62,16 @@ static inline void intel_gvt_sanitize_options(struct drm_i915_private *dev_priv)
 static inline void intel_gvt_resume(struct drm_i915_private *dev_priv)
 {
 }
+
+unsigned long intel_gvt_get_device_type(struct drm_i915_private *i915)
+{
+	return 0;
+}
+
+int intel_gvt_iterate_mmio_table(struct intel_gvt_mmio_table_iter *iter)
+{
+	return 0;
+}
 #endif
 
 #endif /* _INTEL_GVT_H_ */
drivers/gpu/drm/i915/intel_gvt_mmio_table.c new file +1308 -0

1,308 lines not on this page · raw message

Signature · 1 line
2.25.1
author reviewer
#1 lore raw

PATCH v7 2/3 i915/gvt: Save the initial HW state snapshot in i915

Save the initial HW state snapshot in i915 so that the rest code of GVT-g can be moved into a dedicated module while it can still get a clean initial HW state saved at the correct time during the initialization of i915. The futhrer vGPU created by GVT-g will use this HW state as the initial HW state.

v6:

- Remove the reference of intel_gvt_device_info.(Christoph)
- Refine the save_mmio() function. (Christoph)

Cc Christoph Hellwig <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Vivi Rodrigo <[email protected]>
Cc Zhenyu Wang <[email protected]>
Cc Zhi Wang <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.h  |  2 +
 drivers/gpu/drm/i915/intel_gvt.c | 92 +++++++++++++++++++++++++++++++-
 2 files changed, 92 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index 418091484e02..0edc9ecbd403 100644
@@ -429,6 +429,8 @@ struct i915_virtual_gpu {
 	struct mutex lock; /* serialises sending of g2v_notify command pkts */
 	bool active;
 	u32 caps;
+	u32 *initial_mmio;
+	u8 *initial_cfg_space;
 };
 
 struct i915_selftest_stash {
drivers/gpu/drm/i915/intel_gvt.c +90 -2

117 lines not on this page · raw message

Signature · 1 line
2.25.1
author reviewer
#3 lore raw

PATCH v7 3/3 i915/gvt: Use the initial HW state snapshot saved in i915

In reply to Zhi Wang

The code of saving initial HW state snapshot has been moved into i915. Let the GVT-g core logic use that snapshot.

Cc Christoph Hellwig <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Vivi Rodrigo <[email protected]>
Cc Zhenyu Wang <[email protected]>
Cc Zhi Wang <[email protected]>
---
 drivers/gpu/drm/i915/gvt/firmware.c | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/gvt/firmware.c +9 -16
index 1a8274a3f4b1..54fe442238c6 100644
@@ -66,22 +66,16 @@ static struct bin_attribute firmware_attr = {
 	.mmap = NULL,
 };
 
-static int mmio_snapshot_handler(struct intel_gvt *gvt, u32 offset, void *data)
-{
-	*(u32 *)(data + offset) = intel_uncore_read_notrace(gvt->gt->uncore,
-							    _MMIO(offset));
-	return 0;
-}
-
 static int expose_firmware_sysfs(struct intel_gvt *gvt)
 {
 	struct intel_gvt_device_info *info = &gvt->device_info;
-	struct pci_dev *pdev = to_pci_dev(gvt->gt->i915->drm.dev);
+	struct drm_i915_private *i915 = gvt->gt->i915;
+	struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
 	struct gvt_firmware_header *h;
 	void *firmware;
 	void *p;
 	unsigned long size, crc32_start;
-	int i, ret;
+	int ret;
 
 	size = sizeof(*h) + info->mmio_size + info->cfg_space_size;
 	firmware = vzalloc(size);
@@ -99,17 +93,16 @@ static int expose_firmware_sysfs(struct intel_gvt *gvt)
 
 	p = firmware + h->cfg_space_offset;
 
-	for (i = 0; i < h->cfg_space_size; i += 4)
-		pci_read_config_dword(pdev, i, p + i);
-
-	memcpy(gvt->firmware.cfg_space, p, info->cfg_space_size);
+	memcpy(gvt->firmware.cfg_space, i915->vgpu.initial_cfg_space,
+	       info->cfg_space_size);
+	memcpy(p, gvt->firmware.cfg_space, info->cfg_space_size);
 
 	p = firmware + h->mmio_offset;
 
-	/* Take a snapshot of hw mmio registers. */
-	intel_gvt_for_each_tracked_mmio(gvt, mmio_snapshot_handler, p);
+	memcpy(gvt->firmware.mmio, i915->vgpu.initial_mmio,
+	       info->mmio_size);
 
-	memcpy(gvt->firmware.mmio, p, info->mmio_size);
+	memcpy(p, gvt->firmware.mmio, info->mmio_size);
 
 	crc32_start = offsetof(struct gvt_firmware_header, crc32) + 4;
 	h->crc32 = crc32_le(0, firmware + crc32_start, size - crc32_start);
Signature · 1 line
2.25.1
#5 lore raw

[Intel-gfx] ✗ Fi.CI.BUILD: failure for series starting with [v7,1/3] i915/gvt: Separate the MMIO tracking table from GVT-g

In reply to Zhi Wang
== Series Details ==

== Series Details ==

Series: series starting with [v7,1/3] i915/gvt: Separate the MMIO tracking table from GVT-g
URL : https://patchwork.freedesktop.org/series/101803/
State : failure

== Summary ==

CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
DESCEND objtool
CHK include/generated/compile.h
CC [M] drivers/gpu/drm/i915/intel_gvt_mmio_table.o
drivers/gpu/drm/i915/intel_gvt_mmio_table.c: In function ‘iterate_bxt_mmio’:
drivers/gpu/drm/i915/intel_gvt_mmio_table.c:1232:9: error: ‘BXT_DSI_PLL_CTL’ undeclared (first use in this function); did you mean ‘BXT_DE_PLL_CTL’?

  MMIO_D(BXT_DSI_PLL_CTL);
         ^~~~~~~~~~~~~~~
drivers/gpu/drm/i915/intel_gvt_mmio_table.c:35:56: note: in definition of macro ‘MMIO_F’
  ret = iter->handle_mmio_cb(iter, i915_mmio_reg_offset(reg), s); \
                                                        ^~~

drivers/gpu/drm/i915/intel_gvt_mmio_table.c:1232:2: note: in expansion of macro ‘MMIO_D’
MMIO_D(BXT_DSI_PLL_CTL);
^~~~~~
drivers/gpu/drm/i915/intel_gvt_mmio_table.c:1232:9: note: each undeclared identifier is reported only once for each function it appears in

  MMIO_D(BXT_DSI_PLL_CTL);
         ^~~~~~~~~~~~~~~
drivers/gpu/drm/i915/intel_gvt_mmio_table.c:35:56: note: in definition of macro ‘MMIO_F’
  ret = iter->handle_mmio_cb(iter, i915_mmio_reg_offset(reg), s); \
                                                        ^~~

drivers/gpu/drm/i915/intel_gvt_mmio_table.c:1232:2: note: in expansion of macro ‘MMIO_D’
MMIO_D(BXT_DSI_PLL_CTL);
^~~~~~
drivers/gpu/drm/i915/intel_gvt_mmio_table.c:1233:9: error: ‘BXT_DSI_PLL_ENABLE’ undeclared (first use in this function); did you mean ‘BXT_DE_PLL_ENABLE’?

  MMIO_D(BXT_DSI_PLL_ENABLE);
         ^~~~~~~~~~~~~~~~~~
drivers/gpu/drm/i915/intel_gvt_mmio_table.c:35:56: note: in definition of macro ‘MMIO_F’
  ret = iter->handle_mmio_cb(iter, i915_mmio_reg_offset(reg), s); \
                                                        ^~~

drivers/gpu/drm/i915/intel_gvt_mmio_table.c:1233:2: note: in expansion of macro ‘MMIO_D’
MMIO_D(BXT_DSI_PLL_ENABLE);
^~~~~~
scripts/Makefile.build:288: recipe for target 'drivers/gpu/drm/i915/intel_gvt_mmio_table.o' failed make[4]: *** [drivers/gpu/drm/i915/intel_gvt_mmio_table.o] Error 1 scripts/Makefile.build:550: recipe for target 'drivers/gpu/drm/i915' failed make[3]: *** [drivers/gpu/drm/i915] Error 2
scripts/Makefile.build:550: recipe for target 'drivers/gpu/drm' failed
make[2]: *** [drivers/gpu/drm] Error 2
scripts/Makefile.build:550: recipe for target 'drivers/gpu' failed
make[1]: *** [drivers/gpu] Error 2
Makefile:1831: recipe for target 'drivers' failed
make: *** [drivers] Error 2

#6 lore raw
In reply to Zhi Wang
I love your patch! Perhaps something to improve:

Hi Zhi,

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 drm/drm-next next-20220325] [cannot apply to tegra-drm/drm/tegra/for-next airlied/drm-next v5.17] [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/Zhi-Wang/i915-gvt-Separate-the-MMIO-tracking-table-from-GVT-g/20220326-015627
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: x86_64-randconfig-a011 (https://download.01.org/0day-ci/archive/20220326/[email protected]/config)
compiler: gcc-9 (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/8203f91121efdcc910bde0bc4fe5ea678bdaaa5b
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Zhi-Wang/i915-gvt-Separate-the-MMIO-tracking-table-from-GVT-g/20220326-015627
        git checkout 8203f91121efdcc910bde0bc4fe5ea678bdaaa5b
        # save the config file to linux build tree
        mkdir build_dir
        make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/gpu/drm/i915/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/i915/gvt/handlers.c:74:6: warning: no previous prototype for 'intel_gvt_match_device' [-Wmissing-prototypes]

74 | bool intel_gvt_match_device(struct intel_gvt *gvt,
| ^~~~~~~~~~~~~~~~~~~~~~

vim +/intel_gvt_match_device +74 drivers/gpu/drm/i915/gvt/handlers.c

12d14cc43b34706 Zhi Wang 2016-08-30 73

12d14cc43b34706 Zhi Wang 2016-08-30 @74  bool intel_gvt_match_device(struct intel_gvt *gvt,
12d14cc43b34706 Zhi Wang 2016-08-30  75  		unsigned long device)
12d14cc43b34706 Zhi Wang 2016-08-30  76  {
12d14cc43b34706 Zhi Wang 2016-08-30  77  	return intel_gvt_get_device_type(gvt) & device;
12d14cc43b34706 Zhi Wang 2016-08-30  78  }

12d14cc43b34706 Zhi Wang 2016-08-30 79

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp
#7 lore raw
In reply to Zhi Wang
I love your patch! Yet something to improve:

Hi Zhi,

I love your patch! Yet something to improve:

[auto build test ERROR on drm-intel/for-linux-next]
[also build test ERROR on drm-tip/drm-tip drm/drm-next next-20220325] [cannot apply to tegra-drm/drm/tegra/for-next airlied/drm-next v5.17] [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/Zhi-Wang/i915-gvt-Separate-the-MMIO-tracking-table-from-GVT-g/20220326-015627
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: x86_64-randconfig-c002 (https://download.01.org/0day-ci/archive/20220326/[email protected]/config)
compiler: gcc-9 (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0

reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/8203f91121efdcc910bde0bc4fe5ea678bdaaa5b
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Zhi-Wang/i915-gvt-Separate-the-MMIO-tracking-table-from-GVT-g/20220326-015627 git checkout 8203f91121efdcc910bde0bc4fe5ea678bdaaa5b
# save the config file to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/gpu/

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

In file included from drivers/gpu/drm/i915/i915_driver.c:92:

>> drivers/gpu/drm/i915/intel_gvt.h:66:15: error: no previous prototype for 'intel_gvt_get_device_type' [-Werror=missing-prototypes]
      66 | unsigned long intel_gvt_get_device_type(struct drm_i915_private *i915)
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/i915/intel_gvt.h:71:41: error: 'struct intel_gvt_mmio_table_iter' declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
      71 | int intel_gvt_iterate_mmio_table(struct intel_gvt_mmio_table_iter *iter)
         |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/gpu/drm/i915/intel_gvt.h:71:5: error: no previous prototype for 'intel_gvt_iterate_mmio_table' [-Werror=missing-prototypes]

71 | int intel_gvt_iterate_mmio_table(struct intel_gvt_mmio_table_iter *iter)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
--
In file included from drivers/gpu/drm/i915/gvt/gvt.h:39,
from <command-line>:

>> drivers/gpu/drm/i915/intel_gvt.h:66:15: error: no previous prototype for 'intel_gvt_get_device_type' [-Werror=missing-prototypes]
      66 | unsigned long intel_gvt_get_device_type(struct drm_i915_private *i915)
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/i915/intel_gvt.h:71:41: error: 'struct intel_gvt_mmio_table_iter' declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
      71 | int intel_gvt_iterate_mmio_table(struct intel_gvt_mmio_table_iter *iter)
         |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/gpu/drm/i915/intel_gvt.h:71:5: error: no previous prototype for 'intel_gvt_iterate_mmio_table' [-Werror=missing-prototypes]
      71 | int intel_gvt_iterate_mmio_table(struct intel_gvt_mmio_table_iter *iter)
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from drivers/gpu/drm/i915/gvt/gvt.h:43,
                    from <command-line>:
>> drivers/gpu/drm/i915/gvt/mmio.h:74:15: error: conflicting types for 'intel_gvt_get_device_type'
      74 | unsigned long intel_gvt_get_device_type(struct intel_gvt *gvt);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~

In file included from drivers/gpu/drm/i915/gvt/gvt.h:39,
from <command-line>:
drivers/gpu/drm/i915/intel_gvt.h:66:15: note: previous definition of 'intel_gvt_get_device_type' was here
66 | unsigned long intel_gvt_get_device_type(struct drm_i915_private *i915)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

vim +/intel_gvt_get_device_type +66 drivers/gpu/drm/i915/intel_gvt.h

    65	
  > 66	unsigned long intel_gvt_get_device_type(struct drm_i915_private *i915)
    67	{
    68		return 0;
    69	}
    70	
  > 71	int intel_gvt_iterate_mmio_table(struct intel_gvt_mmio_table_iter *iter)
    72	{
    73		return 0;
    74	}
    75	#endif
    76	
Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp
#9 lore raw

Hi Jani and Joonas:

Are you OK with these patches? I noticed I need to change the license of the new file. Will do that when check-in if you are OK with these.

Thanks,
Zhi.

Quoted 12 lines · Christoph Hellwig
Quoted 4 lines · Zhi Wang

v7:

- Keep the marcos of device generation in GVT-g. (Christoph, Jani)

The changelog go under the "---" line (also for the other patches).

Otherwise looks good:

#10 lore raw
Quoted 3 lines · Zhi A

Hi Jani and Joonas:

Are you OK with these patches? I noticed I need to change the license of the new file. Will do that when check-in if you are OK with these.

So I actually ended up testing the patches, and first they fail to compile against current mainline (trivial fix attached), but then the guest (also latest mainline as of today) also hangs during the initialization of th i915 driver on i7-8550U-based Thinkpad. Plain mainline as the host boots fine, but spews a lot of warnings.

Host and guest configs are also attached.

commit 659b61b08dc3c66228a9dd139068bf2ca5096e13

Author: Christoph Hellwig <[email protected]>
Date:   Thu Mar 31 09:17:09 2022 +0200

fix

drivers/gpu/drm/i915/intel_gvt_mmio_table.c +1 -0
index 40b844eb07263..007b965067ea1 100644
@@ -24,6 +24,7 @@
 
 #include "i915_drv.h"
 #include "i915_reg.h"
+#include "display/vlv_dsi_pll_regs.h"
 #include "gt/intel_gt_regs.h"
 #include "intel_mchbar_regs.h"
 #include "i915_pvinfo.h"
#11 lore raw

Hi Chris:

Thanks for the testing. Can you attach the dmesg? I tested mostly on my skylake desktop with some 3D workload.

Thanks,
Zhi.

Quoted 13 lines · Christoph Hellwig
Quoted 3 lines · Zhi A

Hi Jani and Joonas:

Are you OK with these patches? I noticed I need to change the license of the new file. Will do that when check-in if you are OK with these.

So I actually ended up testing the patches, and first they fail to compile against current mainline (trivial fix attached), but then the guest (also latest mainline as of today) also hangs during the initialization of th i915 driver on i7-8550U-based Thinkpad. Plain mainline as the host boots fine, but spews a lot of warnings.

Host and guest configs are also attached.

#12 lore raw
Quoted 3 lines · Zhi A

Hi Chris:

Thanks for the testing. Can you attach the dmesg? I tested mostly on my skylake desktop with some 3D workload.

Sure, I should have done that from the beginning:

[   25.354587] vfio_mdev 6814f392-50ac-4236-ae3d-26d472fd8aae: Adding to iommu group 0
[   25.583015] L1TF CPU bug present and SMT on, data leak possible. See CVE-2018-3646 and https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/l1tf.html for details.
[   26.429492] kvm [2555]: vcpu0, guest rIP: 0xffffffff81003e6e disabled perfctr wrmsr: 0xc2 data 0xffff
[   30.206202] BUG: kernel NULL pointer dereference, address: 0000000000000000
[   30.206206] #PF: supervisor instruction fetch in kernel mode
[   30.206208] #PF: error_code(0x0010) - not-present page
[   30.206209] PGD 0 P4D 0 
[   30.206211] Oops: 0010 [#1] PREEMPT SMP PTI
[   30.206214] CPU: 6 PID: 2565 Comm: qemu-system-x86 Tainted: G            E     5.17.0+ #1292
[   30.206216] Hardware name: LENOVO 20KH006JGE/20KH006JGE, BIOS N23ET62W (1.37 ) 02/19/2019
[   30.206217] RIP: 0010:0x0
[   30.206223] Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6.
[   30.206224] RSP: 0018:ffffa775c3fb3e18 EFLAGS: 00010286
[   30.206226] RAX: 0000000000000000 RBX: ffff90a808bc0000 RCX: 0000000000000004
[   30.206227] RDX: ffffa775c3fb3e80 RSI: 0000000000042300 RDI: ffffa775c40ad000
[   30.206228] RBP: ffffa775c40ad000 R08: 0000000000000001 R09: 0000000000021180
[   30.206230] R10: ffffa775c3fb3e80 R11: ffffa775c3fb3e80 R12: 0000000000000004
[   30.206231] R13: 00000000fd042300 R14: 0000000000042300 R15: ffffa775c40ad008
[   30.206232] FS:  00007fdd9cbfc700(0000) GS:ffff90ab92780000(0000) knlGS:0000000000000000
[   30.206233] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   30.206235] CR2: ffffffffffffffd6 CR3: 00000001c117c002 CR4: 00000000003726e0
[   30.206236] Call Trace:
[   30.206238]  <TASK>
[   30.206239]  intel_vgpu_emulate_mmio_read+0xe9/0x390
[   30.206247]  intel_vgpu_rw.isra.0+0x1a7/0x1e0
[   30.206249]  intel_vgpu_read+0x15c/0x200
[   30.206252]  vfs_read+0x9b/0x190
[   30.206257]  __x64_sys_pread64+0x8d/0xc0
[   30.206259]  do_syscall_64+0x3b/0x90
[   30.206263]  entry_SYSCALL_64_after_hwframe+0x44/0xae
[   30.206266] RIP: 0033:0x7fddb17e41a7
[   30.206268] Code: 08 89 3c 24 48 89 4c 24 18 e8 f5 7b f9 ff 4c 8b 54 24 18 48 8b 54 24 10 41 89 c0 48 8b 74 24 08 8b 3c 24 b8 11 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 31 44 89 c7 48 89 04 24 e8 25 7c f9 ff 48 8b
[   30.206270] RSP: 002b:00007fdd9cbfb2f0 EFLAGS: 00000293 ORIG_RAX: 0000000000000011
[   30.206272] RAX: ffffffffffffffda RBX: 000055ee30d20ed8 RCX: 00007fddb17e41a7
[   30.206273] RDX: 0000000000000004 RSI: 00007fdd9cbfb338 RDI: 000000000000001b
[   30.206274] RBP: 0000000000000004 R08: 0000000000000000 R09: 00000000ffffffff
[   30.206275] R10: 0000000000042300 R11: 0000000000000293 R12: 0000000000042300
[   30.206276] R13: 000055ee30d20df0 R14: 0000000000000004 R15: 0000000000042300
[   30.206278]  </TASK>
[   30.206279] Modules linked in: cmac(E) ctr(E) ccm(E) rfcomm(E) sd_mod(E) sg(E) uvcvideo(E) videobuf2_vmalloc(E) videobuf2_memops(E) videobuf2_v4l2(E) videobuf2_common(E) videodev(E) mc(E) btusb(E) btrtl(E) btbcm(E) btintel(E) uas(E) usb_storage(E) scsi_mod(E) scsi_common(E) bnep(E) snd_hda_codec_hdmi(E) wmi_bmof(E) intel_wmi_thunderbolt(E) joydev(E) bluetooth(E) intel_rapl_msr(E) crc16(E) x86_pkg_temp_thermal(E) jitterentropy_rng(E) intel_powerclamp(E) sha512_generic(E) drbg(E) coretemp(E) ansi_cprng(E) crc32_pclmul(E) ecdh_generic(E) ghash_clmulni_intel(E) ecc(E) aesni_intel(E) libaes(E) crypto_simd(E) iwlmvm(E) snd_soc_skl(E) cryptd(E) snd_soc_hdac_hda(E) mac80211(E) snd_ctl_led(E) snd_hda_ext_core(E) snd_hda_codec_realtek(E) libarc4(E) snd_soc_core(E) snd_hda_codec_generic(E) snd_soc_acpi_intel_match(E) kvm_intel(E) snd_soc_acpi(E) snd_soc_sst_ipc(E) iwlwifi(E) snd_soc_sst_dsp(E) intel_cstate(E) intel_uncore(E) snd_hda_intel(E) serio_raw(E) snd_intel_dspcfg(E) pcspkr(E)
[   30.206314]  snd_hda_codec(E) efi_pstore(E) snd_hwdep(E) tpm_crb(E) processor_thermal_device_pci_legacy(E) snd_hda_core(E) intel_soc_dts_iosf(E) iTCO_wdt(E) iTCO_vendor_support(E) cfg80211(E) processor_thermal_device(E) snd_pcm(E) tpm_tis(E) processor_thermal_rfim(E) thinkpad_acpi(E) watchdog(E) processor_thermal_mbox(E) tpm_tis_core(E) ucsi_acpi(E) nvram(E) mei_me(E) snd_timer(E) processor_thermal_rapl(E) ledtrig_audio(E) intel_pch_thermal(E) tpm(E) intel_rapl_common(E) mei(E) platform_profile(E) typec_ucsi(E) typec(E) rng_core(E) wmi(E) snd(E) battery(E) ac(E) soundcore(E) int3403_thermal(E) rfkill(E) int340x_thermal_zone(E) int3400_thermal(E) evdev(E) acpi_pad(E) acpi_thermal_rel(E) parport_pc(E) ppdev(E) lp(E) parport(E) efivarfs(E) ip_tables(E) x_tables(E) autofs4(E) i2c_designware_platform(E) i2c_designware_core(E) nvme(E) nvme_core(E) t10_pi(E) xhci_pci(E) e1000e(E) crc32c_intel(E) crc64_rocksoft(E) psmouse(E) xhci_hcd(E) ptp(E) i2c_i801(E) crc64(E) pps_core(E) thunderbolt(E)
[   30.206347]  i2c_smbus(E) crc_t10dif(E) usbcore(E) crct10dif_generic(E) intel_lpss_pci(E) crct10dif_pclmul(E) intel_lpss(E) crct10dif_common(E) idma64(E) mfd_core(E) usb_common(E)
[   30.206355] CR2: 0000000000000000
[   30.206356] ---[ end trace 0000000000000000 ]---
[   30.348825] RIP: 0010:0x0
[   30.348839] Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6.
[   30.348840] RSP: 0018:ffffa775c3fb3e18 EFLAGS: 00010286
[   30.348842] RAX: 0000000000000000 RBX: ffff90a808bc0000 RCX: 0000000000000004
[   30.348844] RDX: ffffa775c3fb3e80 RSI: 0000000000042300 RDI: ffffa775c40ad000
[   30.348845] RBP: ffffa775c40ad000 R08: 0000000000000001 R09: 0000000000021180
[   30.348846] R10: ffffa775c3fb3e80 R11: ffffa775c3fb3e80 R12: 0000000000000004
[   30.348847] R13: 00000000fd042300 R14: 0000000000042300 R15: ffffa775c40ad008
[   30.348849] FS:  00007fdd9cbfc700(0000) GS:ffff90ab92780000(0000) knlGS:0000000000000000
[   30.348850] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   30.348851] CR2: ffffffffffffffd6 CR3: 00000001c117c002 CR4: 00000000003726e0
author reviewer
#13 lore raw

Thanks. Let me fix that. :)

Quoted 61 lines · Christoph Hellwig
Quoted 3 lines · Zhi A

Hi Chris:

Thanks for the testing. Can you attach the dmesg? I tested mostly on my skylake desktop with some 3D workload.

Sure, I should have done that from the beginning:

[   25.354587] vfio_mdev 6814f392-50ac-4236-ae3d-26d472fd8aae: Adding to iommu group 0
[   25.583015] L1TF CPU bug present and SMT on, data leak possible. See CVE-2018-3646 and https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/l1tf.html for details.
[   26.429492] kvm [2555]: vcpu0, guest rIP: 0xffffffff81003e6e disabled perfctr wrmsr: 0xc2 data 0xffff
[   30.206202] BUG: kernel NULL pointer dereference, address: 0000000000000000
[   30.206206] #PF: supervisor instruction fetch in kernel mode
[   30.206208] #PF: error_code(0x0010) - not-present page
[   30.206209] PGD 0 P4D 0
[   30.206211] Oops: 0010 [#1] PREEMPT SMP PTI
[   30.206214] CPU: 6 PID: 2565 Comm: qemu-system-x86 Tainted: G            E     5.17.0+ #1292
[   30.206216] Hardware name: LENOVO 20KH006JGE/20KH006JGE, BIOS N23ET62W (1.37 ) 02/19/2019
[   30.206217] RIP: 0010:0x0
[   30.206223] Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6.
[   30.206224] RSP: 0018:ffffa775c3fb3e18 EFLAGS: 00010286
[   30.206226] RAX: 0000000000000000 RBX: ffff90a808bc0000 RCX: 0000000000000004
[   30.206227] RDX: ffffa775c3fb3e80 RSI: 0000000000042300 RDI: ffffa775c40ad000
[   30.206228] RBP: ffffa775c40ad000 R08: 0000000000000001 R09: 0000000000021180
[   30.206230] R10: ffffa775c3fb3e80 R11: ffffa775c3fb3e80 R12: 0000000000000004
[   30.206231] R13: 00000000fd042300 R14: 0000000000042300 R15: ffffa775c40ad008
[   30.206232] FS:  00007fdd9cbfc700(0000) GS:ffff90ab92780000(0000) knlGS:0000000000000000
[   30.206233] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   30.206235] CR2: ffffffffffffffd6 CR3: 00000001c117c002 CR4: 00000000003726e0
[   30.206236] Call Trace:
[   30.206238]  <TASK>
[   30.206239]  intel_vgpu_emulate_mmio_read+0xe9/0x390
[   30.206247]  intel_vgpu_rw.isra.0+0x1a7/0x1e0
[   30.206249]  intel_vgpu_read+0x15c/0x200
[   30.206252]  vfs_read+0x9b/0x190
[   30.206257]  __x64_sys_pread64+0x8d/0xc0
[   30.206259]  do_syscall_64+0x3b/0x90
[   30.206263]  entry_SYSCALL_64_after_hwframe+0x44/0xae
[   30.206266] RIP: 0033:0x7fddb17e41a7
[   30.206268] Code: 08 89 3c 24 48 89 4c 24 18 e8 f5 7b f9 ff 4c 8b 54 24 18 48 8b 54 24 10 41 89 c0 48 8b 74 24 08 8b 3c 24 b8 11 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 31 44 89 c7 48 89 04 24 e8 25 7c f9 ff 48 8b
[   30.206270] RSP: 002b:00007fdd9cbfb2f0 EFLAGS: 00000293 ORIG_RAX: 0000000000000011
[   30.206272] RAX: ffffffffffffffda RBX: 000055ee30d20ed8 RCX: 00007fddb17e41a7
[   30.206273] RDX: 0000000000000004 RSI: 00007fdd9cbfb338 RDI: 000000000000001b
[   30.206274] RBP: 0000000000000004 R08: 0000000000000000 R09: 00000000ffffffff
[   30.206275] R10: 0000000000042300 R11: 0000000000000293 R12: 0000000000042300
[   30.206276] R13: 000055ee30d20df0 R14: 0000000000000004 R15: 0000000000042300
[   30.206278]  </TASK>
[   30.206279] Modules linked in: cmac(E) ctr(E) ccm(E) rfcomm(E) sd_mod(E) sg(E) uvcvideo(E) videobuf2_vmalloc(E) videobuf2_memops(E) videobuf2_v4l2(E) videobuf2_common(E) videodev(E) mc(E) btusb(E) btrtl(E) btbcm(E) btintel(E) uas(E) usb_storage(E) scsi_mod(E) scsi_common(E) bnep(E) snd_hda_codec_hdmi(E) wmi_bmof(E) intel_wmi_thunderbolt(E) joydev(E) bluetooth(E) intel_rapl_msr(E) crc16(E) x86_pkg_temp_thermal(E) jitterentropy_rng(E) intel_powerclamp(E) sha512_generic(E) drbg(E) coretemp(E) ansi_cprng(E) crc32_pclmul(E) ecdh_generic(E) ghash_clmulni_intel(E) ecc(E) aesni_intel(E) libaes(E) crypto_simd(E) iwlmvm(E) snd_soc_skl(E) cryptd(E) snd_soc_hdac_hda(E) mac80211(E) snd_ctl_led(E) snd_hda_ext_core(E) snd_hda_codec_realtek(E) libarc4(E) snd_soc_core(E) snd_hda_codec_generic(E) snd_soc_acpi_intel_match(E) kvm_intel(E) snd_soc_acpi(E) snd_soc_sst_ipc(E) iwlwifi(E) snd_soc_sst_dsp(E) intel_cstate(E) intel_uncore(E) snd_hda_intel(E) serio_raw(E) snd_intel_dspcfg(E) pcspkr(E)
[   30.206314]  snd_hda_codec(E) efi_pstore(E) snd_hwdep(E) tpm_crb(E) processor_thermal_device_pci_legacy(E) snd_hda_core(E) intel_soc_dts_iosf(E) iTCO_wdt(E) iTCO_vendor_support(E) cfg80211(E) processor_thermal_device(E) snd_pcm(E) tpm_tis(E) processor_thermal_rfim(E) thinkpad_acpi(E) watchdog(E) processor_thermal_mbox(E) tpm_tis_core(E) ucsi_acpi(E) nvram(E) mei_me(E) snd_timer(E) processor_thermal_rapl(E) ledtrig_audio(E) intel_pch_thermal(E) tpm(E) intel_rapl_common(E) mei(E) platform_profile(E) typec_ucsi(E) typec(E) rng_core(E) wmi(E) snd(E) battery(E) ac(E) soundcore(E) int3403_thermal(E) rfkill(E) int340x_thermal_zone(E) int3400_thermal(E) evdev(E) acpi_pad(E) acpi_thermal_rel(E) parport_pc(E) ppdev(E) lp(E) parport(E) efivarfs(E) ip_tables(E) x_tables(E) autofs4(E) i2c_designware_platform(E) i2c_designware_core(E) nvme(E) nvme_core(E) t10_pi(E) xhci_pci(E) e1000e(E) crc32c_intel(E) crc64_rocksoft(E) psmouse(E) xhci_hcd(E) ptp(E) i2c_i801(E) crc64(E) pps_core(E) thunderbolt(E)
[   30.206347]  i2c_smbus(E) crc_t10dif(E) usbcore(E) crct10dif_generic(E) intel_lpss_pci(E) crct10dif_pclmul(E) intel_lpss(E) crct10dif_common(E) idma64(E) mfd_core(E) usb_common(E)
[   30.206355] CR2: 0000000000000000
[   30.206356] ---[ end trace 0000000000000000 ]---
[   30.348825] RIP: 0010:0x0
[   30.348839] Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6.
[   30.348840] RSP: 0018:ffffa775c3fb3e18 EFLAGS: 00010286
[   30.348842] RAX: 0000000000000000 RBX: ffff90a808bc0000 RCX: 0000000000000004
[   30.348844] RDX: ffffa775c3fb3e80 RSI: 0000000000042300 RDI: ffffa775c40ad000
[   30.348845] RBP: ffffa775c40ad000 R08: 0000000000000001 R09: 0000000000021180
[   30.348846] R10: ffffa775c3fb3e80 R11: ffffa775c3fb3e80 R12: 0000000000000004
[   30.348847] R13: 00000000fd042300 R14: 0000000000042300 R15: ffffa775c40ad008
[   30.348849] FS:  00007fdd9cbfc700(0000) GS:ffff90ab92780000(0000) knlGS:0000000000000000
[   30.348850] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   30.348851] CR2: ffffffffffffffd6 CR3: 00000001c117c002 CR4: 00000000003726e0
maintainer
#14 lore raw
In reply to Wang, Zhi A
Quoted 4 lines · Zhi A

Hi Jani and Joonas:

Are you OK with these patches? I noticed I need to change the license of the new file. Will do that when check-in if you are OK with these.

Use SPDX license header instead of the full text?

I don't know much about the actual contents, I'll leave that part to others.

Seems that you are dropping const in a number of places where I thought you could perhaps retain it.

Also in drivers/gpu/drm/i915/intel_gvt_mmio_table.c:

#include "gvt.h"

looks bad. It should be "gvt/gvt.h". I realize you can do that because gvt/Makefile has:

ccflags-y += -I $(srctree)/$(src) -I $(srctree)/$(src)/$(GVT_DIR)/

which I think should be removed.

I sent patches fixing this to give you an idea. No need to queue them first, I can rebase them later. But please make sure this builds without the ccflags.

BR,
Jani.

Quoted 18 lines

Thanks,
Zhi.

Quoted 12 lines · Christoph Hellwig
Quoted 4 lines · Zhi Wang

v7:

- Keep the marcos of device generation in GVT-g. (Christoph, Jani)

The changelog go under the "---" line (also for the other patches).

Otherwise looks good:

Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
#15 lore raw

Hi Jani:

Thanks so much for the guidance. :) I included it in the v8 patch. :)

Thanks,
Zhi.

Quoted 53 lines · Jani Nikula
Quoted 4 lines · Zhi A

Hi Jani and Joonas:

Are you OK with these patches? I noticed I need to change the license of the new file. Will do that when check-in if you are OK with these.

Use SPDX license header instead of the full text?

I don't know much about the actual contents, I'll leave that part to others.

Seems that you are dropping const in a number of places where I thought you could perhaps retain it.

Also in drivers/gpu/drm/i915/intel_gvt_mmio_table.c:

#include "gvt.h"

looks bad. It should be "gvt/gvt.h". I realize you can do that because gvt/Makefile has:

ccflags-y += -I $(srctree)/$(src) -I $(srctree)/$(src)/$(GVT_DIR)/

which I think should be removed.

I sent patches fixing this to give you an idea. No need to queue them first, I can rebase them later. But please make sure this builds without the ccflags.

BR,
Jani.

Quoted 18 lines

Thanks,
Zhi.

Quoted 12 lines · Christoph Hellwig
Quoted 4 lines · Zhi Wang

v7:

- Keep the marcos of device generation in GVT-g. (Christoph, Jani)

The changelog go under the "---" line (also for the other patches).

Otherwise looks good:

#16 lore raw

[Intel-gfx] ✗ Fi.CI.BUILD: failure for series starting with [v7,1/3] i915/gvt: Separate the MMIO tracking table from GVT-g (rev2)

In reply to Zhi Wang
== Series Details ==

== Series Details ==

Series: series starting with [v7,1/3] i915/gvt: Separate the MMIO tracking table from GVT-g (rev2)
URL : https://patchwork.freedesktop.org/series/101803/
State : failure

== Summary ==

Applying: i915/gvt: Separate the MMIO tracking table from GVT-g
Using index info to reconstruct a base tree...
A drivers/gpu/drm/i915/intel_gvt_mmio_table.c
Falling back to patching base and 3-way merge...
CONFLICT (modify/delete): drivers/gpu/drm/i915/intel_gvt_mmio_table.c deleted in HEAD and modified in i915/gvt: Separate the MMIO tracking table from GVT-g. Version i915/gvt: Separate the MMIO tracking table from GVT-g of drivers/gpu/drm/i915/intel_gvt_mmio_table.c left in tree.
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 i915/gvt: Separate the MMIO tracking table from GVT-g
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".