Skip to contentSkip to conversation

drm/i915: Don't enable hwmon for selftests

PATCH In review Ashutosh Dixit 2 participants 3 messages Apr 10, 2024

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

PATCH 1/1 drm/i915: Don't enable hwmon for selftests

There are no hwmon selftests so there is no need to enable hwmon for selftests. So enable hwmon only for real driver load.

v2: Move the logic inside i915_hwmon.c

---
 drivers/gpu/drm/i915/i915_hwmon.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_hwmon.c +11 -1
index 8c3f443c8347..511ba9be4de5 100644
@@ -10,6 +10,7 @@
 #include "i915_drv.h"
 #include "i915_hwmon.h"
 #include "i915_reg.h"
+#include "i915_selftest.h"
 #include "intel_mchbar_regs.h"
 #include "intel_pcode.h"
 #include "gt/intel_gt.h"
@@ -778,6 +779,15 @@ hwm_get_preregistration_info(struct drm_i915_private *i915)
 	}
 }
 
+static bool is_selftest(void)
+{
+#if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
+	return i915_selftest.live || i915_selftest.perf || i915_selftest.mock;
+#else
+	return false;
+#endif
+}
+
 void i915_hwmon_register(struct drm_i915_private *i915)
 {
 	struct device *dev = i915->drm.dev;
@@ -789,7 +799,7 @@ void i915_hwmon_register(struct drm_i915_private *i915)
 	int i;
 
 	/* hwmon is available only for dGfx */
-	if (!IS_DGFX(i915))
+	if (!IS_DGFX(i915) || is_selftest())
 		return;
 
 	hwmon = devm_kzalloc(dev, sizeof(*hwmon), GFP_KERNEL);
Signature · 1 line
2.41.0
#1 lore raw
Quoted 25 lines · Ashutosh Dixit

There are no hwmon selftests so there is no need to enable hwmon for selftests. So enable hwmon only for real driver load.

v2: Move the logic inside i915_hwmon.c

---
  drivers/gpu/drm/i915/i915_hwmon.c | 12 +++++++++++-
  1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_hwmon.c +1 -0
index 8c3f443c8347..511ba9be4de5 100644
@@ -10,6 +10,7 @@
  #include "i915_drv.h"
  #include "i915_hwmon.h"
  #include "i915_reg.h"
+#include "i915_selftest.h"
  #include "intel_mchbar_regs.h"
  #include "intel_pcode.h"
  #include "gt/intel_gt.h"
@@ -778,6 +779,15 @@ hwm_get_preregistration_info(struct drm_i915_private *i915)
  	}

drivers/gpu/drm/i915/i915_hwmon.c hwm_get_preregistration_info(struct drm_i915_private *i915) · line 789

Quoted 10 lines
drivers/gpu/drm/i915/i915_hwmon.c +8 -0
  }
 
+static bool is_selftest(void)
+{
+#if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
+	return i915_selftest.live || i915_selftest.perf || i915_selftest.mock;
+#else
+	return false;
+#endif
+}

I think you moved this function here as this is only used in i915_hwmon.c. In case if somewhere else this function is needed then I suggest to move this function to i915_selftest.h as inline function.

Regards,
Badal

Quoted 13 lines
drivers/gpu/drm/i915/i915_hwmon.c +2 -1
+
  void i915_hwmon_register(struct drm_i915_private *i915)
  {
  	struct device *dev = i915->drm.dev;
@@ -789,7 +799,7 @@ void i915_hwmon_register(struct drm_i915_private *i915)
  	int i;
 
  	/* hwmon is available only for dGfx */
-	if (!IS_DGFX(i915))
+	if (!IS_DGFX(i915) || is_selftest())
  		return;
 
  	hwmon = devm_kzalloc(dev, sizeof(*hwmon), GFP_KERNEL);
#2 lore raw
Quoted 10 lines · Badal

drivers/gpu/drm/i915/i915_hwmon.c hwm_get_preregistration_info(struct drm_i915_private *i915) · line 789

Quoted 7 lines
drivers/gpu/drm/i915/i915_hwmon.c +6 -0
+#if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
+	return i915_selftest.live || i915_selftest.perf || i915_selftest.mock;
+#else
+	return false;
+#endif
+}

I think you moved this function here as this is only used in i915_hwmon.c. In case if somewhere else this function is needed then I suggest to move this function to i915_selftest.h as inline function.

Thanks, done in v3.