Skip to contentSkip to conversation

drm/xe: Add device flag to indicate SR-IOV support

PATCH New Michal Wajdeczko 2 participants 6 messages Nov 14, 2023 – Nov 15, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 drm/xe: Add device flag to indicate SR-IOV support

The Single Root I/O Virtualization (SR-IOV) extension to the PCI Express (PCIe) specification suite is supported starting from 12th generation of Intel Graphics processors.

Add a device flag that we will use to enable SR-IOV specific code paths and to indicate our readiness to support SR-IOV.

We will enable this flag for the specific platforms once all required changes and additions will be ready and merged.

Bspec: 52391

---
 drivers/gpu/drm/xe/xe_device.h       | 5 +++++
 drivers/gpu/drm/xe/xe_device_types.h | 2 ++
 drivers/gpu/drm/xe/xe_pci.c          | 3 ++-
 3 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_device.h +5 -0
index c4232de40ae0..54694f98c91a 100644
@@ -158,6 +158,11 @@ static inline bool xe_device_has_flat_ccs(struct xe_device *xe)
 	return xe->info.has_flat_ccs;
 }
 
+static inline bool xe_device_has_sriov(struct xe_device *xe)
+{
+	return xe->info.has_sriov;
+}
+
 u32 xe_device_ccs_bytes(struct xe_device *xe, u64 size);
 
 #endif
drivers/gpu/drm/xe/xe_device_types.h +2 -0
index be11cadccbd4..f2ba4f746fa2 100644
@@ -253,6 +253,8 @@ struct xe_device {
 		u8 has_llc:1;
 		/** @has_range_tlb_invalidation: Has range based TLB invalidations */
 		u8 has_range_tlb_invalidation:1;
+		/** @has_sriov: Supports SR-IOV */
+		u8 has_sriov:1;
 		/** @enable_display: display enabled */
 		u8 enable_display:1;
 		/** @bypass_mtcfg: Bypass Multi-Tile configuration from MTCFG register */
drivers/gpu/drm/xe/xe_pci.c +2 -1
index 682ba188e456..c1c8048bbc0f 100644
@@ -60,6 +60,7 @@ struct xe_device_desc {
 	u8 has_heci_gscfi:1;
 
 	u8 has_llc:1;
+	u8 has_sriov:1;
 	u8 bypass_mtcfg:1;
 	u8 supports_mmio_ext:1;
 };
@@ -532,7 +533,6 @@ static void handle_gmdid(struct xe_device *xe,
 	}
 }
 
-
 static int xe_info_init(struct xe_device *xe,
 			const struct xe_device_desc *desc,
 			const struct xe_subplatform_desc *subplatform_desc)
@@ -578,6 +578,7 @@ static int xe_info_init(struct xe_device *xe,
 	xe->info.graphics_name = graphics_desc->name;
 	xe->info.media_name = media_desc ? media_desc->name : "none";
 	xe->info.has_llc = desc->has_llc;
+	xe->info.has_sriov = desc->has_sriov;
 	xe->info.bypass_mtcfg = desc->bypass_mtcfg;
 	xe->info.supports_mmio_ext = desc->supports_mmio_ext;
 	xe->info.tile_mmio_ext_size = graphics_desc->tile_mmio_ext_size;
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/3 drm/xe: Prepare for running in different SR-IOV modes

We will be adding support for the SR-IOV and driver might be then running, in addition to existing non-virtualized bare-metal mode, also in Physical Function (PF) or Virtual Function (VF) mode.

Since these additional modes require some changes to the driver, define enum flag to represent different SR-IOV modes and add a function where we will detect the actual mode in the runtime.

We start with a forced bare-metal mode as it is sufficient to enable basic functionality and ensures no impact to existing code.

---
 drivers/gpu/drm/xe/Makefile          |  3 ++
 drivers/gpu/drm/xe/xe_device_types.h |  7 ++++
 drivers/gpu/drm/xe/xe_pci.c          |  3 ++
 drivers/gpu/drm/xe/xe_sriov.c        | 55 ++++++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_sriov.h        | 42 +++++++++++++++++++++
 5 files changed, 110 insertions(+)
 create mode 100644 drivers/gpu/drm/xe/xe_sriov.c
 create mode 100644 drivers/gpu/drm/xe/xe_sriov.h
drivers/gpu/drm/xe/Makefile +3 -0
index cb41b4fead08..fbba74d9a330 100644
@@ -123,6 +123,9 @@ xe-y += xe_bb.o \
 # graphics hardware monitoring (HWMON) support
 xe-$(CONFIG_HWMON) += xe_hwmon.o
 
+# graphics virtualization (SR-IOV) support
+xe-y += xe_sriov.o
+
 # i915 Display compat #defines and #includes
 subdir-ccflags-$(CONFIG_DRM_XE_DISPLAY) += \
 	-I$(srctree)/$(src)/display/ext \
drivers/gpu/drm/xe/xe_device_types.h +7 -0
index f2ba4f746fa2..2712905c7a91 100644
@@ -18,6 +18,7 @@
 #include "xe_platform_types.h"
 #include "xe_pt_types.h"
 #include "xe_pmu.h"
+#include "xe_sriov_types.h"
 #include "xe_step_types.h"
 
 #if IS_ENABLED(CONFIG_DRM_XE_DISPLAY)
@@ -299,6 +300,12 @@ struct xe_device {
 		struct ttm_resource_manager sys_mgr;
 	} mem;
 
+	/** @sriov: device level virtualization data */
+	struct {
+		/** @sriov.__mode: SR-IOV mode (Don't access directly!) */
+		enum xe_sriov_mode __mode;
+	} sriov;
+
 	/** @usm: unified memory state */
 	struct {
 		/** @asid: convert a ASID to VM */
drivers/gpu/drm/xe/xe_pci.c +3 -0
index c1c8048bbc0f..3030b223e4a0 100644
@@ -24,6 +24,7 @@
 #include "xe_module.h"
 #include "xe_pci_types.h"
 #include "xe_pm.h"
+#include "xe_sriov.h"
 #include "xe_step.h"
 
 enum toggle_d3cold {
@@ -706,6 +707,8 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	pci_set_master(pdev);
 
+	xe_sriov_probe_early(xe, desc->has_sriov);
+
 	err = xe_info_init(xe, desc, subplatform_desc);
 	if (err)
 		goto err_pci_disable;
drivers/gpu/drm/xe/xe_sriov.c new file +55 -0

55 lines not on this page · raw message

drivers/gpu/drm/xe/xe_sriov.h new file +42 -0

42 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

PATCH 3/3 drm/xe: Print virtualization mode during probe

In reply to Michal Wajdeczko

We already print some basic information about the device, add virtualization information, until we expose that elsewhere.

---
 drivers/gpu/drm/xe/xe_pci.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/xe/xe_pci.c +4 -0
index 3030b223e4a0..cb762c11dd0f 100644
@@ -736,6 +736,10 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		xe_step_name(xe->info.step.display),
 		xe_step_name(xe->info.step.basedie));
 
+	drm_dbg(&xe->drm, "SR-IOV support: %s (mode: %s)\n",
+		str_yes_no(xe_device_has_sriov(xe)),
+		xe_sriov_mode_to_string(xe_device_sriov_mode(xe)));
+
 	err = xe_device_probe(xe);
 	if (err)
 		goto err_pci_disable;
Signature · 1 line
2.25.1
#3 lore raw

[Intel-xe] ✓ CI.Patch_applied: success for series starting with [1/3] drm/xe: Add device flag to indicate SR-IOV support

In reply to Michal Wajdeczko
== Series Details ==

== Series Details ==

Series: series starting with [1/3] drm/xe: Add device flag to indicate SR-IOV support
URL : https://patchwork.freedesktop.org/series/126431/
State : success

== Summary ==

=== Applying kernel patches on branch 'drm-xe-next' with base: === Base commit: 2fe82053d drm/xe/display: Add writing of remapped dpt === git am output follows ===
Applying: drm/xe: Add device flag to indicate SR-IOV support
Applying: drm/xe: Prepare for running in different SR-IOV modes
Applying: drm/xe: Print virtualization mode during probe

#4 lore raw

[Intel-xe] ✗ CI.checkpatch: warning for series starting with [1/3] drm/xe: Add device flag to indicate SR-IOV support

In reply to Michal Wajdeczko
== Series Details ==

== Series Details ==

Series: series starting with [1/3] drm/xe: Add device flag to indicate SR-IOV support
URL : https://patchwork.freedesktop.org/series/126431/
State : warning

== Summary ==

+ KERNEL=/kernel
+ git clone https://gitlab.freedesktop.org/drm/maintainer-tools mt Cloning into 'mt'...
warning: redirecting to https://gitlab.freedesktop.org/drm/maintainer-tools.git/
+ git -C mt rev-list -n1 origin/master 63c2b6b160bca2df6efc7bc4cea6f442097d7854
+ cd /kernel
+ git config --global --add safe.directory /kernel
+ git log -n1
commit 2877ca968a7f3ad555a9881451d96f8f49763b88

Author: Michal Wajdeczko <[email protected]>
Date:   Wed Nov 15 00:05:58 2023 +0100

drm/xe: Print virtualization mode during probe

We already print some basic information about the device, add virtualization information, until we expose that elsewhere.

+ /mt/dim checkpatch 2fe82053d916d09ffcc92bc27294c9eed4e4804b drm-intel
b43f11e2f drm/xe: Add device flag to indicate SR-IOV support
dd84cb348 drm/xe: Prepare for running in different SR-IOV modes
Traceback (most recent call last):
File "scripts/spdxcheck.py", line 6, in <module>
from ply import lex, yacc
ModuleNotFoundError: No module named 'ply'
Traceback (most recent call last):
File "scripts/spdxcheck.py", line 6, in <module>
from ply import lex, yacc
ModuleNotFoundError: No module named 'ply'
-:80: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #80:
new file mode 100644

-:185: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'xe' - possible side-effects? #185: FILE: drivers/gpu/drm/xe/xe_sriov.h:40:
+#define IS_SRIOV(xe) (IS_SRIOV_PF(xe) || IS_SRIOV_VF(xe))

total: 0 errors, 1 warnings, 1 checks, 140 lines checked 2877ca968 drm/xe: Print virtualization mode during probe

#5 lore raw

[Intel-xe] ✗ CI.KUnit: failure for series starting with [1/3] drm/xe: Add device flag to indicate SR-IOV support

In reply to Michal Wajdeczko
== Series Details ==

== Series Details ==

Series: series starting with [1/3] drm/xe: Add device flag to indicate SR-IOV support
URL : https://patchwork.freedesktop.org/series/126431/
State : failure

== Summary ==

+ trap cleanup EXIT
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/xe/.kunitconfig ERROR:root:In file included from ../drivers/gpu/drm/xe/xe_device.h:15,

                 from ../drivers/gpu/drm/xe/xe_bb.c:10:
../drivers/gpu/drm/xe/xe_device_types.h:21:10: fatal error: xe_sriov_types.h: No such file or directory
   21 | #include "xe_sriov_types.h"
      |          ^~~~~~~~~~~~~~~~~~

compilation terminated.
make[7]: *** [../scripts/Makefile.build:243: drivers/gpu/drm/xe/xe_bb.o] Error 1 make[7]: *** Waiting for unfinished jobs....
In file included from ../drivers/gpu/drm/xe/xe_device.h:15,

                 from ../drivers/gpu/drm/xe/tests/xe_pci_test.c:13:
../drivers/gpu/drm/xe/xe_device_types.h:21:10: fatal error: xe_sriov_types.h: No such file or directory
   21 | #include "xe_sriov_types.h"
      |          ^~~~~~~~~~~~~~~~~~

compilation terminated.
make[8]: *** [../scripts/Makefile.build:243: drivers/gpu/drm/xe/tests/xe_pci_test.o] Error 1 make[8]: *** Waiting for unfinished jobs....
In file included from ../drivers/gpu/drm/xe/xe_device.h:15,

                 from ../drivers/gpu/drm/xe/tests/xe_rtp_test.c:16:
../drivers/gpu/drm/xe/xe_device_types.h:21:10: fatal error: xe_sriov_types.h: No such file or directory
   21 | #include "xe_sriov_types.h"
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.
make[8]: *** [../scripts/Makefile.build:243: drivers/gpu/drm/xe/tests/xe_rtp_test.o] Error 1
In file included from ../drivers/gpu/drm/xe/xe_vm_types.h:16,
                 from ../drivers/gpu/drm/xe/xe_bo.h:13,
                 from ../drivers/gpu/drm/xe/xe_bo.c:6:
../drivers/gpu/drm/xe/xe_device_types.h:21:10: fatal error: xe_sriov_types.h: No such file or directory
   21 | #include "xe_sriov_types.h"
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.
make[7]: *** [../scripts/Makefile.build:243: drivers/gpu/drm/xe/xe_bo.o] Error 1
In file included from ../drivers/gpu/drm/xe/xe_device.h:15,
                 from ../drivers/gpu/drm/xe/tests/xe_wa_test.c:11:
../drivers/gpu/drm/xe/xe_device_types.h:21:10: fatal error: xe_sriov_types.h: No such file or directory
   21 | #include "xe_sriov_types.h"
      |          ^~~~~~~~~~~~~~~~~~

compilation terminated.
make[8]: *** [../scripts/Makefile.build:243: drivers/gpu/drm/xe/tests/xe_wa_test.o] Error 1 make[7]: *** [../scripts/Makefile.build:480: drivers/gpu/drm/xe/tests] Error 2 make[6]: *** [../scripts/Makefile.build:480: drivers/gpu/drm/xe] Error 2 make[6]: *** Waiting for unfinished jobs....
make[5]: *** [../scripts/Makefile.build:480: drivers/gpu/drm] Error 2 make[4]: *** [../scripts/Makefile.build:480: drivers/gpu] Error 2
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [../scripts/Makefile.build:480: drivers] Error 2
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [/kernel/Makefile:1913: .] Error 2
make[1]: *** [/kernel/Makefile:234: __sub-make] Error 2
make: *** [Makefile:234: __sub-make] Error 2

[00:16:29] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:

$ make ARCH=um O=.kunit olddefconfig
[00:16:33] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make ARCH=um O=.kunit --jobs=48
+ cleanup
++ stat -c %u:%g /kernel
+ chown -R 1003:1003 /kernel