Skip to contentSkip to conversation

Context isolation uAPI fixes

PATCH New Adrian Larumbe 2 participants 4 messages Jul 29, 2022 – Aug 1, 2022

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

cover Context isolation uAPI fixes

This patch series addresses the concerns in
https://gitlab.freedesktop.org/drm/intel/-/issues/4264

Parallel work has be done on IGT to test changes in the kernel driver:
https://lists.freedesktop.org/archives/igt-dev/2022-May/041600.html

Test-with: [email protected]

Adrian Larumbe (2):
drm/i915: Change semantics of context isolation reporting to UM drm/i915: force getparam ioctl return bool for HAS_CONTEXT_ISOLATION

 drivers/gpu/drm/i915/gt/intel_engine_user.c | 14 ++++++++++++++
 drivers/gpu/drm/i915/gt/intel_engine_user.h |  1 +
 drivers/gpu/drm/i915/i915_getparam.c        |  2 +-
 include/uapi/drm/i915_drm.h                 |  4 ----
 4 files changed, 16 insertions(+), 5 deletions(-)
Signature · 1 line
2.37.0
#1 lore raw

PATCH 1/2 drm/i915: Change semantics of context isolation reporting to UM

I915_PARAM_HAS_CONTEXT_ISOLATION was already being used as a boolean by both Iris and Vulkan , and stood for the guarantee that, when creating a new context, it would not contain register state from preexisting ones.

However, the actual param ioctl was returning a bitmask for the engines in which isolation is supported, and IGT gem_ctx_isolation was exploiting this wrong semantics when making decisions about which engines support it.

This is a uAPI documentation change that precedes the actual change in the getparam ioctl.

---
 include/uapi/drm/i915_drm.h | 4 ----
 1 file changed, 4 deletions(-)
include/uapi/drm/i915_drm.h +0 -4
index 094f6e377793..09adb7ea01d1 100644
@@ -692,10 +692,6 @@ typedef struct drm_i915_irq_wait {
  * supports) that all state set by this context will not leak to any other
  * context.
  *
- * As not every engine across every gen support contexts, the returned
- * value reports the support of context isolation for individual engines by
- * returning a bitmask of each engine class set to true if that class supports
- * isolation.
  */
 #define I915_PARAM_HAS_CONTEXT_ISOLATION 50
 
Signature · 1 line
2.37.0
#2 lore raw

PATCH 2/2 drm/i915: force getparam ioctl return bool for HAS_CONTEXT_ISOLATION

In reply to Adrian Larumbe

In a previous commit, the uAPI documentation for this param was updated to reflect the actual usage expected by Iris. Now make sure the driver does indeed return a boolean value rather than an engine bitmask.

---
 drivers/gpu/drm/i915/gt/intel_engine_user.c | 14 ++++++++++++++
 drivers/gpu/drm/i915/gt/intel_engine_user.h |  1 +
 drivers/gpu/drm/i915/i915_getparam.c        |  2 +-
 3 files changed, 16 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/intel_engine_user.c +14 -0
index 46a174f8aa00..7bdee1c9d940 100644
@@ -306,3 +306,17 @@ unsigned int intel_engines_has_context_isolation(struct drm_i915_private *i915)
 
 	return which;
 }
+
+bool engines_context_isolated(struct drm_i915_private *i915)
+{
+	struct intel_engine_cs *engine;
+
+	if (!DRIVER_CAPS(i915)->has_logical_contexts)
+		return false;
+
+	for_each_uabi_engine(engine, i915)
+		if (!engine->default_state)
+			return false;
+
+	return true;
+}
drivers/gpu/drm/i915/gt/intel_engine_user.h +1 -0
index 3dc7e8ab9fbc..760167db07d5 100644
@@ -15,6 +15,7 @@ struct intel_engine_cs *
 intel_engine_lookup_user(struct drm_i915_private *i915, u8 class, u8 instance);
 
 unsigned int intel_engines_has_context_isolation(struct drm_i915_private *i915);
+bool engines_context_isolated(struct drm_i915_private *i915);
 
 void intel_engine_add_user(struct intel_engine_cs *engine);
 void intel_engines_driver_register(struct drm_i915_private *i915);
drivers/gpu/drm/i915/i915_getparam.c +1 -1
index 6fd15b39570c..dd31cc00c529 100644
@@ -145,7 +145,7 @@ int i915_getparam_ioctl(struct drm_device *dev, void *data,
 		value = 1;
 		break;
 	case I915_PARAM_HAS_CONTEXT_ISOLATION:
-		value = intel_engines_has_context_isolation(i915);
+		value = engines_context_isolated(i915);
 		break;
 	case I915_PARAM_SLICE_MASK:
 		/* Not supported from Xe_HP onward; use topology queries */
Signature · 1 line
2.37.0