Skip to contentSkip to conversation

drm/i915: Don't enable hwmon for selftests

PATCH In review Ashutosh Dixit 4 participants 9 messages Apr 10, 2024 – Apr 13, 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.

---
 drivers/gpu/drm/i915/i915_driver.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_driver.c +14 -2
index 9ee902d5b72c..6fa6d2c8109f 100644
@@ -94,6 +94,7 @@
 #include "i915_memcpy.h"
 #include "i915_perf.h"
 #include "i915_query.h"
+#include "i915_selftest.h"
 #include "i915_suspend.h"
 #include "i915_switcheroo.h"
 #include "i915_sysfs.h"
@@ -589,6 +590,15 @@ static void i915_driver_hw_remove(struct drm_i915_private *dev_priv)
 		pci_disable_msi(pdev);
 }
 
+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
+}
+
 /**
  * i915_driver_register - register the driver with the rest of the system
  * @dev_priv: device private
@@ -624,7 +634,8 @@ static void i915_driver_register(struct drm_i915_private *dev_priv)
 
 	intel_pxp_debugfs_register(dev_priv->pxp);
 
-	i915_hwmon_register(dev_priv);
+	if (!is_selftest())
+		i915_hwmon_register(dev_priv);
 
 	intel_display_driver_register(dev_priv);
 
@@ -660,7 +671,8 @@ static void i915_driver_unregister(struct drm_i915_private *dev_priv)
 	for_each_gt(gt, dev_priv, i)
 		intel_gt_driver_unregister(gt);
 
-	i915_hwmon_unregister(dev_priv);
+	if (!is_selftest())
+		i915_hwmon_unregister(dev_priv);
 
 	i915_perf_unregister(dev_priv);
 	i915_pmu_unregister(dev_priv);
Signature · 1 line
2.41.0
#1 lore raw
Quoted 5 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.

This will resolve this CI issue for now and give us time to study the issue further. If this is not acceptable in the main tree, we could consider merging this to the topic/core-for-CI branch as a temporary fix to eliminate noise in CI due to this issue.

Regards,
Ashutosh

Reviewed-by on v1 1/1
#2 lore raw
In reply to Ashutosh Dixit
Quoted 5 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.

LGTM.

Quoted 52 lines
---
  drivers/gpu/drm/i915/i915_driver.c | 16 ++++++++++++++--
  1 file changed, 14 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_driver.c +14 -2
index 9ee902d5b72c..6fa6d2c8109f 100644
@@ -94,6 +94,7 @@
  #include "i915_memcpy.h"
  #include "i915_perf.h"
  #include "i915_query.h"
+#include "i915_selftest.h"
  #include "i915_suspend.h"
  #include "i915_switcheroo.h"
  #include "i915_sysfs.h"
@@ -589,6 +590,15 @@ static void i915_driver_hw_remove(struct drm_i915_private *dev_priv)
  		pci_disable_msi(pdev);
  }
 
+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
+}
+
  /**
   * i915_driver_register - register the driver with the rest of the system
   * @dev_priv: device private
@@ -624,7 +634,8 @@ static void i915_driver_register(struct drm_i915_private *dev_priv)
 
  	intel_pxp_debugfs_register(dev_priv->pxp);
 
-	i915_hwmon_register(dev_priv);
+	if (!is_selftest())
+		i915_hwmon_register(dev_priv);
 
  	intel_display_driver_register(dev_priv);
 
@@ -660,7 +671,8 @@ static void i915_driver_unregister(struct drm_i915_private *dev_priv)
  	for_each_gt(gt, dev_priv, i)
  		intel_gt_driver_unregister(gt);
 
-	i915_hwmon_unregister(dev_priv);
+	if (!is_selftest())
+		i915_hwmon_unregister(dev_priv);
 
  	i915_perf_unregister(dev_priv);
  	i915_pmu_unregister(dev_priv);
#3 lore raw

✗ Fi.CI.BAT: failure for drm/i915: Don't enable hwmon for selftests

In reply to Ashutosh Dixit
== Series Details ==

== Series Details ==

Series: drm/i915: Don't enable hwmon for selftests
URL : https://patchwork.freedesktop.org/series/132243/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_14552 -> Patchwork_132243v1
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_132243v1 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes
introduced in Patchwork_132243v1, please notify your bug team ([email protected]) to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v1/index.html

Participating hosts (37 -> 36)
------------------------------

Additional (3): bat-kbl-2 fi-rkl-11600 fi-cfl-8109u
Missing (4): fi-kbl-7567u bat-dg2-11 fi-bsw-n3050 bat-arls-3

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in Patchwork_132243v1:

### IGT changes ###

#### Possible regressions ####

* igt@i915_selftest@live@execlists:
- fi-bsw-nick: [PASS][1] -> [ABORT][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14552/fi-bsw-nick/igt@i915_selftest@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v1/fi-bsw-nick/igt@i915_selftest@[email protected]

* igt@i915_selftest@live@gem_contexts:
- bat-arls-2: [PASS][3] -> [ABORT][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14552/bat-arls-2/igt@i915_selftest@live@gem_contexts.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v1/bat-arls-2/igt@i915_selftest@live@gem_contexts.html

* igt@i915_selftest@live@hangcheck:
- bat-adlp-6: [PASS][5] -> [INCOMPLETE][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14552/bat-adlp-6/igt@i915_selftest@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v1/bat-adlp-6/igt@i915_selftest@[email protected]

Known issues
------------

Here are the changes found in Patchwork_132243v1 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@debugfs_test@basic-hwmon:
- fi-rkl-11600: NOTRUN -> [SKIP][7] ([i915#9318])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v1/fi-rkl-11600/igt@[email protected]

* igt@fbdev@info:
- bat-kbl-2: NOTRUN -> [SKIP][8] ([i915#1849])
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v1/bat-kbl-2/igt@[email protected]

* igt@gem_huc_copy@huc-copy:
- fi-cfl-8109u: NOTRUN -> [SKIP][9] ([i915#2190])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v1/fi-cfl-8109u/igt@[email protected]
- fi-rkl-11600: NOTRUN -> [SKIP][10] ([i915#2190])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v1/fi-rkl-11600/igt@[email protected]

* igt@gem_lmem_swapping@parallel-random-engines:
- bat-kbl-2: NOTRUN -> [SKIP][11] +39 other tests skip
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v1/bat-kbl-2/igt@[email protected]
- fi-rkl-11600: NOTRUN -> [SKIP][12] ([i915#4613]) +3 other tests skip
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v1/fi-rkl-11600/igt@[email protected]

* igt@gem_lmem_swapping@verify-random:
- fi-cfl-8109u: NOTRUN -> [SKIP][13] ([i915#4613]) +3 other tests skip
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v1/fi-cfl-8109u/igt@[email protected]

* igt@gem_tiled_pread_basic:
- fi-rkl-11600: NOTRUN -> [SKIP][14] ([i915#3282])
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v1/fi-rkl-11600/igt@gem_tiled_pread_basic.html

* igt@i915_selftest@live@migrate:
- bat-arls-2: [PASS][15] -> [DMESG-WARN][16] ([i915#10677])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14552/bat-arls-2/igt@i915_selftest@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v1/bat-arls-2/igt@i915_selftest@[email protected]

* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy:
- fi-rkl-11600: NOTRUN -> [SKIP][17] ([i915#4103]) +1 other test skip
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v1/fi-rkl-11600/igt@[email protected]

* igt@kms_dsc@dsc-basic:
- fi-rkl-11600: NOTRUN -> [SKIP][18] ([i915#3555] / [i915#3840])
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v1/fi-rkl-11600/igt@[email protected]

* igt@kms_force_connector_basic@force-load-detect:
- fi-rkl-11600: NOTRUN -> [SKIP][19]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v1/fi-rkl-11600/igt@[email protected]

* igt@kms_pm_backlight@basic-brightness:
- fi-rkl-11600: NOTRUN -> [SKIP][20] ([i915#5354])
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v1/fi-rkl-11600/igt@[email protected]
- fi-cfl-8109u: NOTRUN -> [SKIP][21] +11 other tests skip
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v1/fi-cfl-8109u/igt@[email protected]

* igt@kms_psr@psr-sprite-plane-onoff:
- fi-rkl-11600: NOTRUN -> [SKIP][22] ([i915#1072] / [i915#9732]) +3 other tests skip
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v1/fi-rkl-11600/igt@[email protected]

* igt@kms_setmode@basic-clone-single-crtc:
- fi-rkl-11600: NOTRUN -> [SKIP][23] ([i915#3555])
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v1/fi-rkl-11600/igt@[email protected]

* igt@prime_vgem@basic-read:
- fi-rkl-11600: NOTRUN -> [SKIP][24] ([i915#3291] / [i915#3708]) +2 other tests skip
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v1/fi-rkl-11600/igt@[email protected]

#### Possible fixes ####

* igt@gem_lmem_swapping@basic@lmem0:
- bat-dg2-9: [FAIL][25] ([i915#10378]) -> [PASS][26]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14552/bat-dg2-9/igt@gem_lmem_swapping@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v1/bat-dg2-9/igt@gem_lmem_swapping@[email protected]

* igt@i915_selftest@live@gt_contexts:
- bat-dg2-8: [ABORT][27] ([i915#10366]) -> [PASS][28]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14552/bat-dg2-8/igt@i915_selftest@live@gt_contexts.html
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v1/bat-dg2-8/igt@i915_selftest@live@gt_contexts.html

[i915#10366]: https://gitlab.freedesktop.org/drm/intel/issues/10366
[i915#10378]: https://gitlab.freedesktop.org/drm/intel/issues/10378
[i915#10677]: https://gitlab.freedesktop.org/drm/intel/issues/10677
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#1849]: https://gitlab.freedesktop.org/drm/intel/issues/1849
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#3282]: https://gitlab.freedesktop.org/drm/intel/issues/3282
[i915#3291]: https://gitlab.freedesktop.org/drm/intel/issues/3291
[i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
[i915#3708]: https://gitlab.freedesktop.org/drm/intel/issues/3708
[i915#3840]: https://gitlab.freedesktop.org/drm/intel/issues/3840
[i915#4103]: https://gitlab.freedesktop.org/drm/intel/issues/4103
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#5354]: https://gitlab.freedesktop.org/drm/intel/issues/5354
[i915#9318]: https://gitlab.freedesktop.org/drm/intel/issues/9318
[i915#9732]: https://gitlab.freedesktop.org/drm/intel/issues/9732

Build changes
-------------

* Linux: CI_DRM_14552 -> Patchwork_132243v1

CI-20190529: 20190529
CI_DRM_14552: 057ec21a54cddd595a7725fa8731eb4c5bd5abff @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7803: 9669a17ae56f1dcd22ba4c5cb39b3cd334a46862 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_132243v1: 057ec21a54cddd595a7725fa8731eb4c5bd5abff @ git://anongit.freedesktop.org/gfx-ci/linux

### Linux commits

43517b108fcc drm/i915: Don't enable hwmon for selftests

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v1/index.html

#4 lore raw
In reply to Ashutosh Dixit
Quoted 5 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.

Why are we adding duct tape instead of fixing it properly?

Quoted 54 lines
---
 drivers/gpu/drm/i915/i915_driver.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_driver.c +14 -2
index 9ee902d5b72c..6fa6d2c8109f 100644
@@ -94,6 +94,7 @@
 #include "i915_memcpy.h"
 #include "i915_perf.h"
 #include "i915_query.h"
+#include "i915_selftest.h"
 #include "i915_suspend.h"
 #include "i915_switcheroo.h"
 #include "i915_sysfs.h"
@@ -589,6 +590,15 @@ static void i915_driver_hw_remove(struct drm_i915_private *dev_priv)
 		pci_disable_msi(pdev);
 }
 
+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
+}
+
 /**
  * i915_driver_register - register the driver with the rest of the system
  * @dev_priv: device private
@@ -624,7 +634,8 @@ static void i915_driver_register(struct drm_i915_private *dev_priv)
 
 	intel_pxp_debugfs_register(dev_priv->pxp);
 
-	i915_hwmon_register(dev_priv);
+	if (!is_selftest())
+		i915_hwmon_register(dev_priv);
 
 	intel_display_driver_register(dev_priv);
 
@@ -660,7 +671,8 @@ static void i915_driver_unregister(struct drm_i915_private *dev_priv)
 	for_each_gt(gt, dev_priv, i)
 		intel_gt_driver_unregister(gt);
 
-	i915_hwmon_unregister(dev_priv);
+	if (!is_selftest())
+		i915_hwmon_unregister(dev_priv);
 
 	i915_perf_unregister(dev_priv);
 	i915_pmu_unregister(dev_priv);
Signature · 1 line
2.41.0
Signature · 2 lines
Ville Syrjälä
Intel
#5 lore raw
Quoted 9 lines · Ville Syrjälä
Quoted 5 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.

Why are we adding duct tape instead of fixing it properly?

Yeah pretty much what I said here myself:

https://patchwork.freedesktop.org/patch/588585/?series=132243&rev=1#comment_1071014

The issue has been difficult to root-cause. My last effort can be seen here:

https://patchwork.freedesktop.org/patch/584859/?series=131630&rev=1#comment_1067888

Though Badal went further and saw that occasionaly the memory would get freed first and hwmon would get unregistered as much as 2 seconds later, which will cause the crash if anyone touched hwmon sysfs in those final 2 seconds. So not sure what is causing that 2 second delay.

I am not sure if it is worth root-causing further. I am pretty sure if we get rid of the devm_ stuff, that will fix the issue too. So if this patch is not acceptable, we could just go that route (get rid of devm_ in hwmon).

Thanks.
--
Ashutosh

Quoted 58 lines
Quoted 53 lines
---
 drivers/gpu/drm/i915/i915_driver.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_driver.c +14 -3
index 9ee902d5b72c..6fa6d2c8109f 100644
@@ -94,6 +94,7 @@
 #include "i915_memcpy.h"
 #include "i915_perf.h"
 #include "i915_query.h"
+#include "i915_selftest.h"
 #include "i915_suspend.h"
 #include "i915_switcheroo.h"
 #include "i915_sysfs.h"
@@ -589,6 +590,15 @@ static void i915_driver_hw_remove(struct drm_i915_private *dev_priv)
 		pci_disable_msi(pdev);
 }
 
+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
+}
+
 /**
  * i915_driver_register - register the driver with the rest of the system
  * @dev_priv: device private
@@ -624,7 +634,8 @@ static void i915_driver_register(struct drm_i915_private *dev_priv)
 
 	intel_pxp_debugfs_register(dev_priv->pxp);
 
-	i915_hwmon_register(dev_priv);
+	if (!is_selftest())
+		i915_hwmon_register(dev_priv);
 
 	intel_display_driver_register(dev_priv);
 
@@ -660,7 +671,8 @@ static void i915_driver_unregister(struct drm_i915_private *dev_priv)
 	for_each_gt(gt, dev_priv, i)
 		intel_gt_driver_unregister(gt);
 
-	i915_hwmon_unregister(dev_priv);
+	if (!is_selftest())
+		i915_hwmon_unregister(dev_priv);
 
 	i915_perf_unregister(dev_priv);
 	i915_pmu_unregister(dev_priv);
--
Quoted 1 line

2.41.0

--
Ville Syrjälä
Intel

#6 lore raw
Quoted 15 lines · Ashutosh
Quoted 9 lines · Ville Syrjälä
Quoted 5 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.

Why are we adding duct tape instead of fixing it properly?

Yeah pretty much what I said here myself:

https://patchwork.freedesktop.org/patch/588585/?series=132243&rev=1#comment_1071014

Quoted 8 lines

The issue has been difficult to root-cause. My last effort can be seen here:

https://patchwork.freedesktop.org/patch/584859/?series=131630&rev=1#comment_1067888

Though Badal went further and saw that occasionaly the memory would get freed first and hwmon would get unregistered as much as 2 seconds later, which will cause the crash if anyone touched hwmon sysfs in those final 2 seconds. So not sure what is causing that 2 second delay.

Sounds like someone holding a sysfs file/etc. open. Should be trivial to do that by hand and see what happens.

Quoted 67 lines

I am not sure if it is worth root-causing further. I am pretty sure if we get rid of the devm_ stuff, that will fix the issue too. So if this patch is not acceptable, we could just go that route (get rid of devm_ in hwmon).

Thanks.
--
Ashutosh

Quoted 58 lines
Quoted 53 lines
---
 drivers/gpu/drm/i915/i915_driver.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_driver.c +14 -3
index 9ee902d5b72c..6fa6d2c8109f 100644
@@ -94,6 +94,7 @@
 #include "i915_memcpy.h"
 #include "i915_perf.h"
 #include "i915_query.h"
+#include "i915_selftest.h"
 #include "i915_suspend.h"
 #include "i915_switcheroo.h"
 #include "i915_sysfs.h"
@@ -589,6 +590,15 @@ static void i915_driver_hw_remove(struct drm_i915_private *dev_priv)
 		pci_disable_msi(pdev);
 }
 
+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
+}
+
 /**
  * i915_driver_register - register the driver with the rest of the system
  * @dev_priv: device private
@@ -624,7 +634,8 @@ static void i915_driver_register(struct drm_i915_private *dev_priv)
 
 	intel_pxp_debugfs_register(dev_priv->pxp);
 
-	i915_hwmon_register(dev_priv);
+	if (!is_selftest())
+		i915_hwmon_register(dev_priv);
 
 	intel_display_driver_register(dev_priv);
 
@@ -660,7 +671,8 @@ static void i915_driver_unregister(struct drm_i915_private *dev_priv)
 	for_each_gt(gt, dev_priv, i)
 		intel_gt_driver_unregister(gt);
 
-	i915_hwmon_unregister(dev_priv);
+	if (!is_selftest())
+		i915_hwmon_unregister(dev_priv);
 
 	i915_perf_unregister(dev_priv);
 	i915_pmu_unregister(dev_priv);
--
Quoted 1 line

2.41.0

--
Ville Syrjälä
Intel

Signature · 2 lines
Ville Syrjälä
Intel
#7 lore raw
Quoted 21 lines · Ville Syrjälä
Quoted 19 lines · Ashutosh
Quoted 9 lines · Ville Syrjälä
Quoted 5 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.

Why are we adding duct tape instead of fixing it properly?

Yeah pretty much what I said here myself:

https://patchwork.freedesktop.org/patch/588585/?series=132243&rev=1#comment_1071014

The issue has been difficult to root-cause. My last effort can be seen here:

https://patchwork.freedesktop.org/patch/584859/?series=131630&rev=1#comment_1067888

Quoted 7 lines
Quoted 4 lines

Though Badal went further and saw that occasionaly the memory would get freed first and hwmon would get unregistered as much as 2 seconds later, which will cause the crash if anyone touched hwmon sysfs in those final 2 seconds. So not sure what is causing that 2 second delay.

Sounds like someone holding a sysfs file/etc. open. Should be trivial to do that by hand and see what happens.

I checked this out. We see the memory being released before hwmon even when we don't access the sysfs, so it has norhing to do with holding a sysfs file open. Holding a sysfs file open also takes a reference on the module which will prevent the module from being unloaded, which is also what we don't see.

So the reordering seems to be happening in devres itself occasionally for some reason.

So anyway, I have submitted a new patch getting rid of devm and freeing everything explicitly and verified that that fixes the issue:

https://patchwork.freedesktop.org/series/132400/

I have also update https://patchwork.freedesktop.org/series/132400/ with more details.

Regards,
Ashutosh

Quoted 69 lines
Quoted 65 lines

I am not sure if it is worth root-causing further. I am pretty sure if we get rid of the devm_ stuff, that will fix the issue too. So if this patch is not acceptable, we could just go that route (get rid of devm_ in hwmon).

Quoted 58 lines
Quoted 53 lines
---
 drivers/gpu/drm/i915/i915_driver.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_driver.c +14 -3
index 9ee902d5b72c..6fa6d2c8109f 100644
@@ -94,6 +94,7 @@
 #include "i915_memcpy.h"
 #include "i915_perf.h"
 #include "i915_query.h"
+#include "i915_selftest.h"
 #include "i915_suspend.h"
 #include "i915_switcheroo.h"
 #include "i915_sysfs.h"
@@ -589,6 +590,15 @@ static void i915_driver_hw_remove(struct drm_i915_private *dev_priv)
 		pci_disable_msi(pdev);
 }
 
+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
+}
+
 /**
  * i915_driver_register - register the driver with the rest of the system
  * @dev_priv: device private
@@ -624,7 +634,8 @@ static void i915_driver_register(struct drm_i915_private *dev_priv)
 
 	intel_pxp_debugfs_register(dev_priv->pxp);
 
-	i915_hwmon_register(dev_priv);
+	if (!is_selftest())
+		i915_hwmon_register(dev_priv);
 
 	intel_display_driver_register(dev_priv);
 
@@ -660,7 +671,8 @@ static void i915_driver_unregister(struct drm_i915_private *dev_priv)
 	for_each_gt(gt, dev_priv, i)
 		intel_gt_driver_unregister(gt);
 
-	i915_hwmon_unregister(dev_priv);
+	if (!is_selftest())
+		i915_hwmon_unregister(dev_priv);
 
 	i915_perf_unregister(dev_priv);
 	i915_pmu_unregister(dev_priv);
--
Quoted 1 line

2.41.0

--
Ville Syrjälä
Intel

--
Ville Syrjälä
Intel

#8 lore raw
Quoted 40 lines · Ashutosh
Quoted 21 lines · Ville Syrjälä
Quoted 19 lines · Ashutosh
Quoted 9 lines · Ville Syrjälä
Quoted 5 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.

Why are we adding duct tape instead of fixing it properly?

Yeah pretty much what I said here myself:

https://patchwork.freedesktop.org/patch/588585/?series=132243&rev=1#comment_1071014

The issue has been difficult to root-cause. My last effort can be seen here:

https://patchwork.freedesktop.org/patch/584859/?series=131630&rev=1#comment_1067888

Quoted 7 lines
Quoted 4 lines

Though Badal went further and saw that occasionaly the memory would get freed first and hwmon would get unregistered as much as 2 seconds later, which will cause the crash if anyone touched hwmon sysfs in those final 2 seconds. So not sure what is causing that 2 second delay.

Sounds like someone holding a sysfs file/etc. open. Should be trivial to do that by hand and see what happens.

I checked this out. We see the memory being released before hwmon even when we don't access the sysfs, so it has norhing to do with holding a sysfs file open. Holding a sysfs file open also takes a reference on the module which will prevent the module from being unloaded, which is also what we don't see.

So the reordering seems to be happening in devres itself occasionally for some reason.

Quoted 7 lines

So anyway, I have submitted a new patch getting rid of devm and freeing everything explicitly and verified that that fixes the issue:

https://patchwork.freedesktop.org/series/132400/

I have also update https://patchwork.freedesktop.org/series/132400/ with more details.

Sorry I meant: https://gitlab.freedesktop.org/drm/intel/-/issues/10366