[Intel-gfx] [PATCH 2/4] drm/i915: BUG() if we can't lookup_power_well()

Paulo Zanoni paulo.r.zanoni at intel.com
Wed Aug 8 22:16:12 UTC 2018


None of the current lookup_power_well() callers are actually checking
for NULL return values, they all just use the pointer right away.
Replacing these theoretical segfaults with BUG()s at least makes our
code a little more explicit to the reader.

We can only hit this NULL/BUG() condition if we try to lookup a power
well that isn't defined on a given platform. If that ever happens, we
have to fix our code, making it lookup the correct power well. Because
of this, I don't think it's worth trying to implement error checking
in every caller. Improving our CI system will be a better use of our
time once a bug is found in the wild.

Cc: Imre Deak <imre.deak at intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni at intel.com>
---
 drivers/gpu/drm/i915/intel_runtime_pm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_runtime_pm.c b/drivers/gpu/drm/i915/intel_runtime_pm.c
index e0947f662361..2fdb1f4125c2 100644
--- a/drivers/gpu/drm/i915/intel_runtime_pm.c
+++ b/drivers/gpu/drm/i915/intel_runtime_pm.c
@@ -1120,7 +1120,8 @@ lookup_power_well(struct drm_i915_private *dev_priv,
 			return power_well;
 	}
 
-	return NULL;
+	/* Tried to lookup a power well that doesn't exist for the platform. */
+	BUG();
 }
 
 #define BITS_SET(val, bits) (((val) & (bits)) == (bits))
-- 
2.14.4



More information about the Intel-gfx mailing list