All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Don't enable hwmon for selftests
@ 2024-04-10 20:07 Ashutosh Dixit
  2024-04-10 21:40 ` ✗ Fi.CI.SPARSE: warning for drm/i915: Don't enable hwmon for selftests (rev4) Patchwork
  2024-04-10 21:59 ` ✗ Fi.CI.BAT: failure " Patchwork
  0 siblings, 2 replies; 18+ messages in thread
From: Ashutosh Dixit @ 2024-04-10 20:07 UTC (permalink / raw)
  To: intel-gfx; +Cc: Badal Nilawar, Andi Shyti

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
v3: Move is_i915_selftest definition to i915_selftest.h (Badal)
v4: s/is_i915_selftest/is_i915_selftest_module/

Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/10366
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Reviewed-by: Badal Nilawar <badal.nilawar@intel.com>
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_hwmon.c    | 3 ++-
 drivers/gpu/drm/i915/i915_selftest.h | 9 +++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_hwmon.c b/drivers/gpu/drm/i915/i915_hwmon.c
index 8c3f443c8347..86d7cd1ef45e 100644
--- a/drivers/gpu/drm/i915/i915_hwmon.c
+++ b/drivers/gpu/drm/i915/i915_hwmon.c
@@ -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"
@@ -789,7 +790,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_i915_selftest_module())
 		return;
 
 	hwmon = devm_kzalloc(dev, sizeof(*hwmon), GFP_KERNEL);
diff --git a/drivers/gpu/drm/i915/i915_selftest.h b/drivers/gpu/drm/i915/i915_selftest.h
index bdf3e22c0a34..bba3fafaac8d 100644
--- a/drivers/gpu/drm/i915/i915_selftest.h
+++ b/drivers/gpu/drm/i915/i915_selftest.h
@@ -123,6 +123,15 @@ static inline int i915_perf_selftests(struct pci_dev *pdev) { return 0; }
 
 #endif
 
+static inline bool is_i915_selftest_module(void)
+{
+#if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
+	return i915_selftest.live || i915_selftest.perf || i915_selftest.mock;
+#else
+	return false;
+#endif
+}
+
 /* Using the i915_selftest_ prefix becomes a little unwieldy with the helpers.
  * Instead we use the igt_ shorthand, in reference to the intel-gpu-tools
  * suite of uabi test cases (which includes a test runner for our selftests).
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* ✗ Fi.CI.SPARSE: warning for drm/i915: Don't enable hwmon for selftests (rev4)
  2024-04-10 20:07 [PATCH] drm/i915: Don't enable hwmon for selftests Ashutosh Dixit
@ 2024-04-10 21:40 ` Patchwork
  2024-04-10 21:59 ` ✗ Fi.CI.BAT: failure " Patchwork
  1 sibling, 0 replies; 18+ messages in thread
From: Patchwork @ 2024-04-10 21:40 UTC (permalink / raw)
  To: Ashutosh Dixit; +Cc: intel-gfx

== Series Details ==

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

== Summary ==

Error: dim sparse failed
Sparse version: v0.6.2
Fast mode used, each commit won't be checked separately.



^ permalink raw reply	[flat|nested] 18+ messages in thread

* ✗ Fi.CI.BAT: failure for drm/i915: Don't enable hwmon for selftests (rev4)
  2024-04-10 20:07 [PATCH] drm/i915: Don't enable hwmon for selftests Ashutosh Dixit
  2024-04-10 21:40 ` ✗ Fi.CI.SPARSE: warning for drm/i915: Don't enable hwmon for selftests (rev4) Patchwork
@ 2024-04-10 21:59 ` Patchwork
  1 sibling, 0 replies; 18+ messages in thread
From: Patchwork @ 2024-04-10 21:59 UTC (permalink / raw)
  To: Ashutosh Dixit; +Cc: intel-gfx

[-- Attachment #1: Type: text/plain, Size: 11364 bytes --]

== Series Details ==

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

== Summary ==

CI Bug Log - changes from CI_DRM_14561 -> Patchwork_132243v4
====================================================

Summary
-------

  **FAILURE**

  Serious unknown changes coming with Patchwork_132243v4 absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_132243v4, please notify your bug team (I915-ci-infra@lists.freedesktop.org) 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_132243v4/index.html

Participating hosts (39 -> 38)
------------------------------

  Additional (2): bat-jsl-1 bat-arls-3 
  Missing    (3): bat-dg2-11 bat-atsm-1 fi-snb-2520m 

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

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

### IGT changes ###

#### Possible regressions ####

  * igt@i915_selftest@live@active:
    - bat-jsl-1:          NOTRUN -> [DMESG-FAIL][1]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-jsl-1/igt@i915_selftest@live@active.html

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

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

### IGT changes ###

#### Issues hit ####

  * igt@debugfs_test@basic-hwmon:
    - bat-jsl-1:          NOTRUN -> [SKIP][2] ([i915#9318])
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-jsl-1/igt@debugfs_test@basic-hwmon.html
    - bat-arls-3:         NOTRUN -> [SKIP][3] ([i915#9318])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-arls-3/igt@debugfs_test@basic-hwmon.html

  * igt@gem_huc_copy@huc-copy:
    - bat-jsl-1:          NOTRUN -> [SKIP][4] ([i915#2190])
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-jsl-1/igt@gem_huc_copy@huc-copy.html

  * igt@gem_lmem_swapping@parallel-random-engines:
    - bat-arls-3:         NOTRUN -> [SKIP][5] ([i915#10213]) +3 other tests skip
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-arls-3/igt@gem_lmem_swapping@parallel-random-engines.html

  * igt@gem_lmem_swapping@verify-random:
    - bat-jsl-1:          NOTRUN -> [SKIP][6] ([i915#4613]) +3 other tests skip
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-jsl-1/igt@gem_lmem_swapping@verify-random.html

  * igt@gem_mmap@basic:
    - bat-arls-3:         NOTRUN -> [SKIP][7] ([i915#4083])
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-arls-3/igt@gem_mmap@basic.html

  * igt@gem_render_tiled_blits@basic:
    - bat-arls-3:         NOTRUN -> [SKIP][8] ([i915#10197] / [i915#10211] / [i915#4079])
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-arls-3/igt@gem_render_tiled_blits@basic.html

  * igt@gem_tiled_blits@basic:
    - bat-arls-3:         NOTRUN -> [SKIP][9] ([i915#10196] / [i915#4077]) +2 other tests skip
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-arls-3/igt@gem_tiled_blits@basic.html

  * igt@gem_tiled_pread_basic:
    - bat-arls-3:         NOTRUN -> [SKIP][10] ([i915#10206] / [i915#4079])
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-arls-3/igt@gem_tiled_pread_basic.html

  * igt@i915_pm_rps@basic-api:
    - bat-arls-3:         NOTRUN -> [SKIP][11] ([i915#10209])
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-arls-3/igt@i915_pm_rps@basic-api.html

  * igt@kms_addfb_basic@addfb25-x-tiled-legacy:
    - bat-arls-3:         NOTRUN -> [SKIP][12] ([i915#10200]) +9 other tests skip
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-arls-3/igt@kms_addfb_basic@addfb25-x-tiled-legacy.html

  * igt@kms_cursor_legacy@basic-busy-flip-before-cursor-atomic:
    - bat-arls-3:         NOTRUN -> [SKIP][13] ([i915#10202]) +1 other test skip
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-arls-3/igt@kms_cursor_legacy@basic-busy-flip-before-cursor-atomic.html

  * igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy:
    - bat-jsl-1:          NOTRUN -> [SKIP][14] ([i915#4103]) +1 other test skip
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-jsl-1/igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy.html

  * igt@kms_dsc@dsc-basic:
    - bat-arls-3:         NOTRUN -> [SKIP][15] ([i915#9886])
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-arls-3/igt@kms_dsc@dsc-basic.html
    - bat-jsl-1:          NOTRUN -> [SKIP][16] ([i915#3555] / [i915#9886])
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-jsl-1/igt@kms_dsc@dsc-basic.html

  * igt@kms_force_connector_basic@force-load-detect:
    - bat-arls-3:         NOTRUN -> [SKIP][17] ([i915#10207])
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-arls-3/igt@kms_force_connector_basic@force-load-detect.html
    - bat-jsl-1:          NOTRUN -> [SKIP][18]
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-jsl-1/igt@kms_force_connector_basic@force-load-detect.html

  * igt@kms_pm_backlight@basic-brightness:
    - bat-arls-3:         NOTRUN -> [SKIP][19] ([i915#9812])
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-arls-3/igt@kms_pm_backlight@basic-brightness.html

  * igt@kms_psr@psr-primary-mmap-gtt:
    - bat-arls-3:         NOTRUN -> [SKIP][20] ([i915#9732]) +3 other tests skip
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-arls-3/igt@kms_psr@psr-primary-mmap-gtt.html

  * igt@kms_setmode@basic-clone-single-crtc:
    - bat-jsl-1:          NOTRUN -> [SKIP][21] ([i915#3555])
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-jsl-1/igt@kms_setmode@basic-clone-single-crtc.html
    - bat-arls-3:         NOTRUN -> [SKIP][22] ([i915#10208] / [i915#8809])
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-arls-3/igt@kms_setmode@basic-clone-single-crtc.html

  * igt@prime_vgem@basic-fence-mmap:
    - bat-arls-3:         NOTRUN -> [SKIP][23] ([i915#10196] / [i915#3708] / [i915#4077]) +1 other test skip
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-arls-3/igt@prime_vgem@basic-fence-mmap.html

  * igt@prime_vgem@basic-fence-read:
    - bat-arls-3:         NOTRUN -> [SKIP][24] ([i915#10212] / [i915#3708])
   [24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-arls-3/igt@prime_vgem@basic-fence-read.html

  * igt@prime_vgem@basic-read:
    - bat-arls-3:         NOTRUN -> [SKIP][25] ([i915#10214] / [i915#3708])
   [25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-arls-3/igt@prime_vgem@basic-read.html

  * igt@prime_vgem@basic-write:
    - bat-arls-3:         NOTRUN -> [SKIP][26] ([i915#10216] / [i915#3708])
   [26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-arls-3/igt@prime_vgem@basic-write.html

  
#### Possible fixes ####

  * igt@gem_lmem_swapping@basic@lmem0:
    - bat-dg2-9:          [FAIL][27] ([i915#10378]) -> [PASS][28]
   [27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14561/bat-dg2-9/igt@gem_lmem_swapping@basic@lmem0.html
   [28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-dg2-9/igt@gem_lmem_swapping@basic@lmem0.html

  * igt@i915_selftest@live@gt_mocs:
    - bat-dg2-8:          [ABORT][29] ([i915#10366]) -> [PASS][30]
   [29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14561/bat-dg2-8/igt@i915_selftest@live@gt_mocs.html
   [30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-dg2-8/igt@i915_selftest@live@gt_mocs.html

  * igt@kms_cursor_legacy@basic-flip-after-cursor-legacy:
    - {bat-mtlp-9}:       [DMESG-WARN][31] ([i915#10435] / [i915#9157]) -> [PASS][32]
   [31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14561/bat-mtlp-9/igt@kms_cursor_legacy@basic-flip-after-cursor-legacy.html
   [32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-mtlp-9/igt@kms_cursor_legacy@basic-flip-after-cursor-legacy.html

  * igt@kms_force_connector_basic@force-connector-state:
    - {bat-mtlp-9}:       [DMESG-WARN][33] ([i915#10435]) -> [PASS][34]
   [33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14561/bat-mtlp-9/igt@kms_force_connector_basic@force-connector-state.html
   [34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_132243v4/bat-mtlp-9/igt@kms_force_connector_basic@force-connector-state.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [i915#10196]: https://gitlab.freedesktop.org/drm/intel/issues/10196
  [i915#10197]: https://gitlab.freedesktop.org/drm/intel/issues/10197
  [i915#10200]: https://gitlab.freedesktop.org/drm/intel/issues/10200
  [i915#10202]: https://gitlab.freedesktop.org/drm/intel/issues/10202
  [i915#10206]: https://gitlab.freedesktop.org/drm/intel/issues/10206
  [i915#10207]: https://gitlab.freedesktop.org/drm/intel/issues/10207
  [i915#10208]: https://gitlab.freedesktop.org/drm/intel/issues/10208
  [i915#10209]: https://gitlab.freedesktop.org/drm/intel/issues/10209
  [i915#10211]: https://gitlab.freedesktop.org/drm/intel/issues/10211
  [i915#10212]: https://gitlab.freedesktop.org/drm/intel/issues/10212
  [i915#10213]: https://gitlab.freedesktop.org/drm/intel/issues/10213
  [i915#10214]: https://gitlab.freedesktop.org/drm/intel/issues/10214
  [i915#10216]: https://gitlab.freedesktop.org/drm/intel/issues/10216
  [i915#10366]: https://gitlab.freedesktop.org/drm/intel/issues/10366
  [i915#10378]: https://gitlab.freedesktop.org/drm/intel/issues/10378
  [i915#10435]: https://gitlab.freedesktop.org/drm/intel/issues/10435
  [i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
  [i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
  [i915#3708]: https://gitlab.freedesktop.org/drm/intel/issues/3708
  [i915#4077]: https://gitlab.freedesktop.org/drm/intel/issues/4077
  [i915#4079]: https://gitlab.freedesktop.org/drm/intel/issues/4079
  [i915#4083]: https://gitlab.freedesktop.org/drm/intel/issues/4083
  [i915#4103]: https://gitlab.freedesktop.org/drm/intel/issues/4103
  [i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
  [i915#8809]: https://gitlab.freedesktop.org/drm/intel/issues/8809
  [i915#9157]: https://gitlab.freedesktop.org/drm/intel/issues/9157
  [i915#9318]: https://gitlab.freedesktop.org/drm/intel/issues/9318
  [i915#9732]: https://gitlab.freedesktop.org/drm/intel/issues/9732
  [i915#9812]: https://gitlab.freedesktop.org/drm/intel/issues/9812
  [i915#9886]: https://gitlab.freedesktop.org/drm/intel/issues/9886


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

  * Linux: CI_DRM_14561 -> Patchwork_132243v4

  CI-20190529: 20190529
  CI_DRM_14561: 72c79c9b20ced92d5c10230bb50fca29c9f387f9 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_7804: 7804
  Patchwork_132243v4: 72c79c9b20ced92d5c10230bb50fca29c9f387f9 @ git://anongit.freedesktop.org/gfx-ci/linux


### Linux commits

d7ecc12558fe drm/i915: Don't enable hwmon for selftests

== Logs ==

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

[-- Attachment #2: Type: text/html, Size: 13309 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] drm/i915: Don't enable hwmon for selftests
  2024-04-13  0:35       ` Dixit, Ashutosh
@ 2024-04-13  0:37         ` Dixit, Ashutosh
  0 siblings, 0 replies; 18+ messages in thread
From: Dixit, Ashutosh @ 2024-04-13  0:37 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx, Badal Nilawar, Andi Shyti

On Fri, 12 Apr 2024 17:35:15 -0700, Dixit, Ashutosh wrote:
>
> On Thu, 11 Apr 2024 03:47:13 -0700, Ville Syrjälä wrote:
> >
> > On Wed, Apr 10, 2024 at 10:09:32PM -0700, Dixit, Ashutosh wrote:
> > > On Wed, 10 Apr 2024 04:42:46 -0700, Ville Syrjälä wrote:
> > > >
> > > > On Tue, Apr 09, 2024 at 09:28:55PM -0700, Ashutosh Dixit wrote:
> > > > > There are no hwmon selftests so there is no need to enable hwmon for
> > > > > selftests. So enable hwmon only for real driver load.
> > > > >
> > > > > Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/10366
> > > > > Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
> > > >
> > > > 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.
> >
> > 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.

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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] drm/i915: Don't enable hwmon for selftests
  2024-04-11 10:47     ` Ville Syrjälä
@ 2024-04-13  0:35       ` Dixit, Ashutosh
  2024-04-13  0:37         ` Dixit, Ashutosh
  0 siblings, 1 reply; 18+ messages in thread
From: Dixit, Ashutosh @ 2024-04-13  0:35 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx, Badal Nilawar, Andi Shyti

On Thu, 11 Apr 2024 03:47:13 -0700, Ville Syrjälä wrote:
>
> On Wed, Apr 10, 2024 at 10:09:32PM -0700, Dixit, Ashutosh wrote:
> > On Wed, 10 Apr 2024 04:42:46 -0700, Ville Syrjälä wrote:
> > >
> > > On Tue, Apr 09, 2024 at 09:28:55PM -0700, Ashutosh Dixit wrote:
> > > > There are no hwmon selftests so there is no need to enable hwmon for
> > > > selftests. So enable hwmon only for real driver load.
> > > >
> > > > Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/10366
> > > > Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
> > >
> > > 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.
>
> 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

>
> >
> > 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).
> >
> >
> > > > ---
> > > >  drivers/gpu/drm/i915/i915_driver.c | 16 ++++++++++++++--
> > > >  1 file changed, 14 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
> > > > index 9ee902d5b72c..6fa6d2c8109f 100644
> > > > --- a/drivers/gpu/drm/i915/i915_driver.c
> > > > +++ b/drivers/gpu/drm/i915/i915_driver.c
> > > > @@ -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);
> > > > --
> > > > 2.41.0
> > >
> > > --
> > > Ville Syrjälä
> > > Intel
>
> --
> Ville Syrjälä
> Intel

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] drm/i915: Don't enable hwmon for selftests
  2024-04-11  5:09   ` Dixit, Ashutosh
@ 2024-04-11 10:47     ` Ville Syrjälä
  2024-04-13  0:35       ` Dixit, Ashutosh
  0 siblings, 1 reply; 18+ messages in thread
From: Ville Syrjälä @ 2024-04-11 10:47 UTC (permalink / raw)
  To: Dixit, Ashutosh; +Cc: intel-gfx, Badal Nilawar, Andi Shyti

On Wed, Apr 10, 2024 at 10:09:32PM -0700, Dixit, Ashutosh wrote:
> On Wed, 10 Apr 2024 04:42:46 -0700, Ville Syrjälä wrote:
> >
> > On Tue, Apr 09, 2024 at 09:28:55PM -0700, Ashutosh Dixit wrote:
> > > There are no hwmon selftests so there is no need to enable hwmon for
> > > selftests. So enable hwmon only for real driver load.
> > >
> > > Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/10366
> > > Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
> >
> > 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.

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

> 
> 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
> 
> > > ---
> > >  drivers/gpu/drm/i915/i915_driver.c | 16 ++++++++++++++--
> > >  1 file changed, 14 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
> > > index 9ee902d5b72c..6fa6d2c8109f 100644
> > > --- a/drivers/gpu/drm/i915/i915_driver.c
> > > +++ b/drivers/gpu/drm/i915/i915_driver.c
> > > @@ -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);
> > > --
> > > 2.41.0
> >
> > --
> > Ville Syrjälä
> > Intel

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] drm/i915: Don't enable hwmon for selftests
  2024-04-10 11:42 ` Ville Syrjälä
@ 2024-04-11  5:09   ` Dixit, Ashutosh
  2024-04-11 10:47     ` Ville Syrjälä
  0 siblings, 1 reply; 18+ messages in thread
From: Dixit, Ashutosh @ 2024-04-11  5:09 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx, Badal Nilawar, Andi Shyti

On Wed, 10 Apr 2024 04:42:46 -0700, Ville Syrjälä wrote:
>
> On Tue, Apr 09, 2024 at 09:28:55PM -0700, Ashutosh Dixit wrote:
> > There are no hwmon selftests so there is no need to enable hwmon for
> > selftests. So enable hwmon only for real driver load.
> >
> > Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/10366
> > Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
>
> 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

> > ---
> >  drivers/gpu/drm/i915/i915_driver.c | 16 ++++++++++++++--
> >  1 file changed, 14 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
> > index 9ee902d5b72c..6fa6d2c8109f 100644
> > --- a/drivers/gpu/drm/i915/i915_driver.c
> > +++ b/drivers/gpu/drm/i915/i915_driver.c
> > @@ -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);
> > --
> > 2.41.0
>
> --
> Ville Syrjälä
> Intel

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] drm/i915: Don't enable hwmon for selftests
  2024-04-10 13:53 ` Andi Shyti
@ 2024-04-11  4:59   ` Dixit, Ashutosh
  0 siblings, 0 replies; 18+ messages in thread
From: Dixit, Ashutosh @ 2024-04-11  4:59 UTC (permalink / raw)
  To: Andi Shyti; +Cc: intel-gfx, Badal Nilawar

On Wed, 10 Apr 2024 06:53:15 -0700, Andi Shyti wrote:
>

Hi Andi,

> please use "git format-patch -v 3 ..." which generates subject
> [PATCH v3] ...". Otherwise it gets confusing to see the patch
> that needs to be reviewed.

Sure, sorry!

>
> On Tue, Apr 09, 2024 at 11:05:49PM -0700, Ashutosh Dixit wrote:
> > 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
> > v3: Move is_i915_selftest definition to i915_selftest.h (Badal)
> >
> > Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/10366
> > Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
> > ---
> >  drivers/gpu/drm/i915/i915_hwmon.c    |  3 ++-
> >  drivers/gpu/drm/i915/i915_selftest.h | 10 ++++++++++
> >  2 files changed, 12 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_hwmon.c b/drivers/gpu/drm/i915/i915_hwmon.c
> > index 8c3f443c8347..cf1689333ebf 100644
> > --- a/drivers/gpu/drm/i915/i915_hwmon.c
> > +++ b/drivers/gpu/drm/i915/i915_hwmon.c
> > @@ -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"
> > @@ -789,7 +790,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_i915_selftest())
> >		return;
>
> I wonder if this is the right place to put it or rather place it
> in i915_driver.c and avoid calling i915_hwmon_register() at all.

I thought it was better put it here rather than clutter up common code in
i915_driver.c.

>
> In any case, it's good:
>
> Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>

Thanks.
--
Ashutosh

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] drm/i915: Don't enable hwmon for selftests
  2024-04-10  6:05 [PATCH] drm/i915: Don't enable hwmon for selftests Ashutosh Dixit
  2024-04-10  6:45 ` Nilawar, Badal
@ 2024-04-10 13:53 ` Andi Shyti
  2024-04-11  4:59   ` Dixit, Ashutosh
  1 sibling, 1 reply; 18+ messages in thread
From: Andi Shyti @ 2024-04-10 13:53 UTC (permalink / raw)
  To: Ashutosh Dixit; +Cc: intel-gfx, Badal Nilawar

Hi Ashutosh,

please use "git format-patch -v 3 ..." which generates subject
[PATCH v3] ...". Otherwise it gets confusing to see the patch
that needs to be reviewed.

On Tue, Apr 09, 2024 at 11:05:49PM -0700, Ashutosh Dixit wrote:
> 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
> v3: Move is_i915_selftest definition to i915_selftest.h (Badal)
> 
> Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/10366
> Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_hwmon.c    |  3 ++-
>  drivers/gpu/drm/i915/i915_selftest.h | 10 ++++++++++
>  2 files changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_hwmon.c b/drivers/gpu/drm/i915/i915_hwmon.c
> index 8c3f443c8347..cf1689333ebf 100644
> --- a/drivers/gpu/drm/i915/i915_hwmon.c
> +++ b/drivers/gpu/drm/i915/i915_hwmon.c
> @@ -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"
> @@ -789,7 +790,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_i915_selftest())
>  		return;

I wonder if this is the right place to put it or rather place it
in i915_driver.c and avoid calling i915_hwmon_register() at all.

In any case, it's good:

Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>

Thanks,
Andi

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] drm/i915: Don't enable hwmon for selftests
  2024-04-10  4:28 Ashutosh Dixit
  2024-04-10  4:37 ` Dixit, Ashutosh
  2024-04-10  4:56 ` Nilawar, Badal
@ 2024-04-10 11:42 ` Ville Syrjälä
  2024-04-11  5:09   ` Dixit, Ashutosh
  2 siblings, 1 reply; 18+ messages in thread
From: Ville Syrjälä @ 2024-04-10 11:42 UTC (permalink / raw)
  To: Ashutosh Dixit; +Cc: intel-gfx, Badal Nilawar

On Tue, Apr 09, 2024 at 09:28:55PM -0700, Ashutosh Dixit wrote:
> There are no hwmon selftests so there is no need to enable hwmon for
> selftests. So enable hwmon only for real driver load.
> 
> Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/10366
> Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>

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

> ---
>  drivers/gpu/drm/i915/i915_driver.c | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
> index 9ee902d5b72c..6fa6d2c8109f 100644
> --- a/drivers/gpu/drm/i915/i915_driver.c
> +++ b/drivers/gpu/drm/i915/i915_driver.c
> @@ -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);
> -- 
> 2.41.0

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] drm/i915: Don't enable hwmon for selftests
  2024-04-10  6:05 [PATCH] drm/i915: Don't enable hwmon for selftests Ashutosh Dixit
@ 2024-04-10  6:45 ` Nilawar, Badal
  2024-04-10 13:53 ` Andi Shyti
  1 sibling, 0 replies; 18+ messages in thread
From: Nilawar, Badal @ 2024-04-10  6:45 UTC (permalink / raw)
  To: Ashutosh Dixit, intel-gfx



On 10-04-2024 11:35, Ashutosh Dixit wrote:
> 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
> v3: Move is_i915_selftest definition to i915_selftest.h (Badal)
> 
> Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/10366
> Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
> ---
>   drivers/gpu/drm/i915/i915_hwmon.c    |  3 ++-
>   drivers/gpu/drm/i915/i915_selftest.h | 10 ++++++++++
>   2 files changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_hwmon.c b/drivers/gpu/drm/i915/i915_hwmon.c
> index 8c3f443c8347..cf1689333ebf 100644
> --- a/drivers/gpu/drm/i915/i915_hwmon.c
> +++ b/drivers/gpu/drm/i915/i915_hwmon.c
> @@ -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"
> @@ -789,7 +790,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_i915_selftest())
>   		return;
>   
>   	hwmon = devm_kzalloc(dev, sizeof(*hwmon), GFP_KERNEL);
> diff --git a/drivers/gpu/drm/i915/i915_selftest.h b/drivers/gpu/drm/i915/i915_selftest.h
> index bdf3e22c0a34..19e5076823a7 100644
> --- a/drivers/gpu/drm/i915/i915_selftest.h
> +++ b/drivers/gpu/drm/i915/i915_selftest.h
> @@ -111,6 +111,11 @@ int __i915_subtests(const char *caller,
>   #define I915_SELFTEST_ONLY(x) unlikely(x)
>   #define I915_SELFTEST_EXPORT
>   
> +static inline bool is_i915_selftest(void)
> +{
> +	return i915_selftest.live || i915_selftest.perf || i915_selftest.mock;
> +}
> +
>   #else /* !IS_ENABLED(CONFIG_DRM_I915_SELFTEST) */
>   
>   static inline int i915_mock_selftests(void) { return 0; }
> @@ -121,6 +126,11 @@ static inline int i915_perf_selftests(struct pci_dev *pdev) { return 0; }
>   #define I915_SELFTEST_ONLY(x) 0
>   #define I915_SELFTEST_EXPORT static
>   
> +static inline bool is_i915_selftest(void)
> +{
> +	return false;
> +}
> +
Looks good to me.
Reviewed-by: Badal Nilawar <badal.nilawar@intel.com>
>   #endif
>   
>   /* Using the i915_selftest_ prefix becomes a little unwieldy with the helpers.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] drm/i915: Don't enable hwmon for selftests
  2024-04-10  5:17 ` Nilawar, Badal
@ 2024-04-10  6:06   ` Dixit, Ashutosh
  0 siblings, 0 replies; 18+ messages in thread
From: Dixit, Ashutosh @ 2024-04-10  6:06 UTC (permalink / raw)
  To: Nilawar, Badal; +Cc: intel-gfx

On Tue, 09 Apr 2024 22:17:38 -0700, Nilawar, Badal wrote:
>
> > +#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.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH] drm/i915: Don't enable hwmon for selftests
@ 2024-04-10  6:05 Ashutosh Dixit
  2024-04-10  6:45 ` Nilawar, Badal
  2024-04-10 13:53 ` Andi Shyti
  0 siblings, 2 replies; 18+ messages in thread
From: Ashutosh Dixit @ 2024-04-10  6:05 UTC (permalink / raw)
  To: intel-gfx; +Cc: Badal Nilawar

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
v3: Move is_i915_selftest definition to i915_selftest.h (Badal)

Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/10366
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
 drivers/gpu/drm/i915/i915_hwmon.c    |  3 ++-
 drivers/gpu/drm/i915/i915_selftest.h | 10 ++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_hwmon.c b/drivers/gpu/drm/i915/i915_hwmon.c
index 8c3f443c8347..cf1689333ebf 100644
--- a/drivers/gpu/drm/i915/i915_hwmon.c
+++ b/drivers/gpu/drm/i915/i915_hwmon.c
@@ -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"
@@ -789,7 +790,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_i915_selftest())
 		return;
 
 	hwmon = devm_kzalloc(dev, sizeof(*hwmon), GFP_KERNEL);
diff --git a/drivers/gpu/drm/i915/i915_selftest.h b/drivers/gpu/drm/i915/i915_selftest.h
index bdf3e22c0a34..19e5076823a7 100644
--- a/drivers/gpu/drm/i915/i915_selftest.h
+++ b/drivers/gpu/drm/i915/i915_selftest.h
@@ -111,6 +111,11 @@ int __i915_subtests(const char *caller,
 #define I915_SELFTEST_ONLY(x) unlikely(x)
 #define I915_SELFTEST_EXPORT
 
+static inline bool is_i915_selftest(void)
+{
+	return i915_selftest.live || i915_selftest.perf || i915_selftest.mock;
+}
+
 #else /* !IS_ENABLED(CONFIG_DRM_I915_SELFTEST) */
 
 static inline int i915_mock_selftests(void) { return 0; }
@@ -121,6 +126,11 @@ static inline int i915_perf_selftests(struct pci_dev *pdev) { return 0; }
 #define I915_SELFTEST_ONLY(x) 0
 #define I915_SELFTEST_EXPORT static
 
+static inline bool is_i915_selftest(void)
+{
+	return false;
+}
+
 #endif
 
 /* Using the i915_selftest_ prefix becomes a little unwieldy with the helpers.
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH] drm/i915: Don't enable hwmon for selftests
  2024-04-10  4:58 Ashutosh Dixit
@ 2024-04-10  5:17 ` Nilawar, Badal
  2024-04-10  6:06   ` Dixit, Ashutosh
  0 siblings, 1 reply; 18+ messages in thread
From: Nilawar, Badal @ 2024-04-10  5:17 UTC (permalink / raw)
  To: Ashutosh Dixit, intel-gfx



On 10-04-2024 10:28, Ashutosh Dixit wrote:
> 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
> 
> Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/10366
> Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
> ---
>   drivers/gpu/drm/i915/i915_hwmon.c | 12 +++++++++++-
>   1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_hwmon.c b/drivers/gpu/drm/i915/i915_hwmon.c
> index 8c3f443c8347..511ba9be4de5 100644
> --- a/drivers/gpu/drm/i915/i915_hwmon.c
> +++ b/drivers/gpu/drm/i915/i915_hwmon.c
> @@ -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
> +}
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
> +
>   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);

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH] drm/i915: Don't enable hwmon for selftests
@ 2024-04-10  4:58 Ashutosh Dixit
  2024-04-10  5:17 ` Nilawar, Badal
  0 siblings, 1 reply; 18+ messages in thread
From: Ashutosh Dixit @ 2024-04-10  4:58 UTC (permalink / raw)
  To: intel-gfx; +Cc: Badal Nilawar

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

Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/10366
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
 drivers/gpu/drm/i915/i915_hwmon.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_hwmon.c b/drivers/gpu/drm/i915/i915_hwmon.c
index 8c3f443c8347..511ba9be4de5 100644
--- a/drivers/gpu/drm/i915/i915_hwmon.c
+++ b/drivers/gpu/drm/i915/i915_hwmon.c
@@ -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);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH] drm/i915: Don't enable hwmon for selftests
  2024-04-10  4:28 Ashutosh Dixit
  2024-04-10  4:37 ` Dixit, Ashutosh
@ 2024-04-10  4:56 ` Nilawar, Badal
  2024-04-10 11:42 ` Ville Syrjälä
  2 siblings, 0 replies; 18+ messages in thread
From: Nilawar, Badal @ 2024-04-10  4:56 UTC (permalink / raw)
  To: Ashutosh Dixit, intel-gfx



On 10-04-2024 09:58, Ashutosh Dixit wrote:
> There are no hwmon selftests so there is no need to enable hwmon for
> selftests. So enable hwmon only for real driver load.
> 
> Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/10366
> Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
LGTM.
Reviewed-by: Badal Nilawar <badal.nilawar@intel.com>
> ---
>   drivers/gpu/drm/i915/i915_driver.c | 16 ++++++++++++++--
>   1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
> index 9ee902d5b72c..6fa6d2c8109f 100644
> --- a/drivers/gpu/drm/i915/i915_driver.c
> +++ b/drivers/gpu/drm/i915/i915_driver.c
> @@ -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);

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] drm/i915: Don't enable hwmon for selftests
  2024-04-10  4:28 Ashutosh Dixit
@ 2024-04-10  4:37 ` Dixit, Ashutosh
  2024-04-10  4:56 ` Nilawar, Badal
  2024-04-10 11:42 ` Ville Syrjälä
  2 siblings, 0 replies; 18+ messages in thread
From: Dixit, Ashutosh @ 2024-04-10  4:37 UTC (permalink / raw)
  To: intel-gfx; +Cc: Badal Nilawar

On Tue, 09 Apr 2024 21:28:55 -0700, Ashutosh Dixit wrote:
>
> There are no hwmon selftests so there is no need to enable hwmon for
> selftests. So enable hwmon only for real driver load.
>
> Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/10366

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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH] drm/i915: Don't enable hwmon for selftests
@ 2024-04-10  4:28 Ashutosh Dixit
  2024-04-10  4:37 ` Dixit, Ashutosh
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Ashutosh Dixit @ 2024-04-10  4:28 UTC (permalink / raw)
  To: intel-gfx; +Cc: Badal Nilawar

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

Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/10366
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
 drivers/gpu/drm/i915/i915_driver.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
index 9ee902d5b72c..6fa6d2c8109f 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -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);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2024-04-13  0:37 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-10 20:07 [PATCH] drm/i915: Don't enable hwmon for selftests Ashutosh Dixit
2024-04-10 21:40 ` ✗ Fi.CI.SPARSE: warning for drm/i915: Don't enable hwmon for selftests (rev4) Patchwork
2024-04-10 21:59 ` ✗ Fi.CI.BAT: failure " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2024-04-10  6:05 [PATCH] drm/i915: Don't enable hwmon for selftests Ashutosh Dixit
2024-04-10  6:45 ` Nilawar, Badal
2024-04-10 13:53 ` Andi Shyti
2024-04-11  4:59   ` Dixit, Ashutosh
2024-04-10  4:58 Ashutosh Dixit
2024-04-10  5:17 ` Nilawar, Badal
2024-04-10  6:06   ` Dixit, Ashutosh
2024-04-10  4:28 Ashutosh Dixit
2024-04-10  4:37 ` Dixit, Ashutosh
2024-04-10  4:56 ` Nilawar, Badal
2024-04-10 11:42 ` Ville Syrjälä
2024-04-11  5:09   ` Dixit, Ashutosh
2024-04-11 10:47     ` Ville Syrjälä
2024-04-13  0:35       ` Dixit, Ashutosh
2024-04-13  0:37         ` Dixit, Ashutosh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.