[PATCH] drm/i915: rework reading pipe disable fuses

Lucas De Marchi lucas.demarchi at intel.com
Fri Jun 21 23:33:42 UTC 2019


This prepare for us to have possibly more than 3 pipes. I didn't want to
continue the previous approach since the check for "are the disabled
pipes the last ones" poses a combinatory explosion. We need that check
because in several places of the code we have that assumption. If that
ever becomes false in a new HW, other parts of the code would have to
change.

So now we first consider all pipes disabled and mark those that are
enabled.  Then it's a simple matter of checking if we have at least one
pipe and that all the enabled ones are the first pipes.

v2: also check if we have at least 1 pipe enabled as the comment states

Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
---
 drivers/gpu/drm/i915/intel_device_info.c | 43 ++++++++++--------------
 1 file changed, 18 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_device_info.c b/drivers/gpu/drm/i915/intel_device_info.c
index 7135d8dc32a7..11a755fa90bf 100644
--- a/drivers/gpu/drm/i915/intel_device_info.c
+++ b/drivers/gpu/drm/i915/intel_device_info.c
@@ -929,35 +929,28 @@ void intel_device_info_runtime_init(struct drm_i915_private *dev_priv)
 		}
 	} else if (HAS_DISPLAY(dev_priv) && INTEL_GEN(dev_priv) >= 9) {
 		u32 dfsm = I915_READ(SKL_DFSM);
-		u8 disabled_mask = 0;
-		bool invalid;
-		int num_bits;
-
-		if (dfsm & SKL_DFSM_PIPE_A_DISABLE)
-			disabled_mask |= BIT(PIPE_A);
-		if (dfsm & SKL_DFSM_PIPE_B_DISABLE)
-			disabled_mask |= BIT(PIPE_B);
-		if (dfsm & SKL_DFSM_PIPE_C_DISABLE)
-			disabled_mask |= BIT(PIPE_C);
-
-		num_bits = hweight8(disabled_mask);
-
-		switch (disabled_mask) {
-		case BIT(PIPE_A):
-		case BIT(PIPE_B):
-		case BIT(PIPE_A) | BIT(PIPE_B):
-		case BIT(PIPE_A) | BIT(PIPE_C):
-			invalid = true;
-			break;
-		default:
-			invalid = false;
-		}
+		u8 disabled_mask = -1;
+		int num_enabled;
+
+		if (!(dfsm & SKL_DFSM_PIPE_A_DISABLE))
+			disabled_mask &= ~BIT(PIPE_A);
+		if (!(dfsm & SKL_DFSM_PIPE_B_DISABLE))
+			disabled_mask &= ~BIT(PIPE_B);
+		if (!(dfsm & SKL_DFSM_PIPE_C_DISABLE))
+			disabled_mask &= ~BIT(PIPE_C);
+
+		num_enabled = hweight8(~disabled_mask);
 
-		if (num_bits > info->num_pipes || invalid)
+		/*
+		 * At least one pipe should be enabled and if there are disabled
+		 * pipes, they should be the last ones, not in the middle
+		 */
+		if (!num_enabled || num_enabled > info->num_pipes ||
+		    __ffs(disabled_mask) != num_enabled)
 			DRM_ERROR("invalid pipe fuse configuration: 0x%x\n",
 				  disabled_mask);
 		else
-			info->num_pipes -= num_bits;
+			info->num_pipes = num_enabled;
 	}
 
 	/* Initialize slice/subslice/EU info */
-- 
2.21.0



More information about the Intel-gfx-trybot mailing list