[Intel-gfx] [PATCH 13/45] drm/i915: Convert inconsistent static engine tables into an init error

Chris Wilson chris at chris-wilson.co.uk
Thu Apr 25 09:19:32 UTC 2019


Remove the modification of the "constant" device info by promoting the
inconsistent intel_engine static table into an initialisation error.
Now, if we add a new engine into the device_info, we must first add that
engine information into the intel_engines.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/gt/intel_engine_cs.c | 28 ++++++++---------------
 1 file changed, 9 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
index 65cdd0c4accc..862cf1040f88 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
@@ -356,15 +356,14 @@ void intel_engines_cleanup(struct drm_i915_private *i915)
  */
 int intel_engines_init_mmio(struct drm_i915_private *i915)
 {
-	struct intel_device_info *device_info = mkwrite_device_info(i915);
-	const unsigned int engine_mask = INTEL_INFO(i915)->engine_mask;
-	unsigned int mask = 0;
 	unsigned int i;
 	int err;
 
-	WARN_ON(engine_mask == 0);
-	WARN_ON(engine_mask &
-		GENMASK(BITS_PER_TYPE(mask) - 1, I915_NUM_ENGINES));
+	/* We always presume we have at least RCS available for later probing */
+	if (GEM_WARN_ON(!HAS_ENGINE(i915, RCS0))) {
+		err = -ENODEV;
+		goto cleanup;
+	}
 
 	if (i915_inject_load_failure())
 		return -ENODEV;
@@ -376,25 +375,16 @@ int intel_engines_init_mmio(struct drm_i915_private *i915)
 		err = intel_engine_setup(i915, i);
 		if (err)
 			goto cleanup;
-
-		mask |= BIT(i);
 	}
 
-	/*
-	 * Catch failures to update intel_engines table when the new engines
-	 * are added to the driver by a warning and disabling the forgotten
-	 * engines.
-	 */
-	if (WARN_ON(mask != engine_mask))
-		device_info->engine_mask = mask;
-
-	/* We always presume we have at least RCS available for later probing */
-	if (WARN_ON(!HAS_ENGINE(i915, RCS0))) {
+	/* Catch failures to update intel_engines table for new engines. */
+	if (GEM_WARN_ON(INTEL_INFO(i915)->engine_mask >> i)) {
 		err = -ENODEV;
 		goto cleanup;
 	}
 
-	RUNTIME_INFO(i915)->num_engines = hweight32(mask);
+	RUNTIME_INFO(i915)->num_engines =
+		hweight32(INTEL_INFO(i915)->engine_mask);
 
 	i915_check_and_clear_faults(i915);
 
-- 
2.20.1



More information about the Intel-gfx mailing list