Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/gt: Hold RPM wakelock during PXP suspend

selftest --r live shows failure in suspend tests when
RPM wakelock is not acquired during suspend.

This changes addresses below error :
<4> [154.177535] RPM wakelock ref not held during HW access
<4> [154.177575] WARNING: CPU: 4 PID: 5772 at
drivers/gpu/drm/i915/intel_runtime_pm.h:113
fwtable_write32+0x240/0x320 [i915]
<4> [154.177974] Modules linked in: i915(+) vgem drm_shmem_helper
fuse snd_hda_codec_hdmi snd_hda_codec_realtek snd_hda_codec_generic
ledtrig_audio mei_hdcp mei_pxp x86_pkg_temp_thermal coretemp
crct10dif_pclmul crc32_pclmul ghash_clmulni_intel snd_intel_dspcfg
snd_hda_codec snd_hwdep igc snd_hda_core ttm mei_me ptp
snd_pcm prime_numbers mei i2c_i801 pps_core i2c_smbus intel_lpss_pci
btusb btrtl btbcm btintel bluetooth ecdh_generic ecc [last unloaded: i915]
<4> [154.178143] CPU: 4 PID: 5772 Comm: i915_selftest Tainted: G
U 5.15.0-rc6-CI-Patchwork_21432+ #1
<4> [154.178154] Hardware name: ASUS System Product Name/TUF GAMING
Z590-PLUS WIFI, BIOS 0811 04/06/2021
<4> [154.178160] RIP: 0010:fwtable_write32+0x240/0x320 [i915]
<4> [154.178604] Code: 15 7b e1 0f 0b e9 34 fe ff ff 80 3d a9 89 31
00 00 0f 85 31 fe ff ff 48 c7 c7 88 9e 4f a0 c6 05 95 89 31 00 01 e8
c0 15 7b e1 <0f> 0b e9 17 fe ff ff 8b 05 0f 83 58 e2 85 c0 0f 85 8d
00 00 00 48
<4> [154.178614] RSP: 0018:ffffc900016279f0 EFLAGS: 00010286
<4> [154.178626] RAX: 0000000000000000 RBX: ffff888204fe0ee0
RCX: 0000000000000001
<4> [154.178634] RDX: 0000000080000001 RSI: ffffffff823142b5
RDI: 00000000ffffffff
<4> [154.178641] RBP: 00000000000320f0 R08: 0000000000000000
R09: c0000000ffffcd5a
<4> [154.178647] R10: 00000000000f8c90 R11: ffffc90001627808
R12: 0000000000000000
<4> [154.178654] R13: 0000000040000000 R14: ffffffffa04d12e0
R15: 0000000000000000
<4> [154.178660] FS: 00007f7390aa4c00(0000) GS:ffff88844f000000(0000)
knlGS:0000000000000000
<4> [154.178669] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
<4> [154.178675] CR2: 000055bc40595028 CR3: 0000000204474005
CR4: 0000000000770ee0
<4> [154.178682] PKRU: 55555554
<4> [154.178687] Call Trace:
<4> [154.178706] intel_pxp_fini_hw+0x23/0x30 [i915]
<4> [154.179284] intel_pxp_suspend+0x1f/0x30 [i915]
<4> [154.179807] live_gt_resume+0x5b/0x90 [i915]

Changes since V2 :
- Remove boolean in intel_pxp_runtime_preapre for
non-pxp configs. Solves build error
Changes since V2 :
- Open-code intel_pxp_runtime_suspend - Daniele
- Remove boolean in intel_pxp_runtime_preapre - Daniele
Changes since V1 :
- split the HW access parts in gt_suspend_late - Daniele
- Remove default PXP configs

Signed-off-by: Tejas Upadhyay <tejaskumarx.surendrakumar.upadhyay@intel.com>
Reviewed-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Fixes: 0cfab4cb3c4e ("drm/i915/pxp: Enable PXP power management")
Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211117060321.3729343-1-tejaskumarx.surendrakumar.upadhyay@intel.com
(cherry picked from commit d22d446f7a1ccd0db8c138749dde601388b2327d)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

authored by

Tejas Upadhyay and committed by
Rodrigo Vivi
b8d84368 13605725

+46 -17
+4 -3
drivers/gpu/drm/i915/gt/intel_gt_pm.c
··· 301 301 user_forcewake(gt, true); 302 302 wait_for_suspend(gt); 303 303 304 - intel_pxp_suspend(&gt->pxp, false); 304 + intel_pxp_suspend_prepare(&gt->pxp); 305 305 } 306 306 307 307 static suspend_state_t pm_suspend_target(void) ··· 326 326 GEM_BUG_ON(gt->awake); 327 327 328 328 intel_uc_suspend(&gt->uc); 329 + intel_pxp_suspend(&gt->pxp); 329 330 330 331 /* 331 332 * On disabling the device, we want to turn off HW access to memory ··· 354 353 355 354 void intel_gt_runtime_suspend(struct intel_gt *gt) 356 355 { 357 - intel_pxp_suspend(&gt->pxp, true); 356 + intel_pxp_runtime_suspend(&gt->pxp); 358 357 intel_uc_runtime_suspend(&gt->uc); 359 358 360 359 GT_TRACE(gt, "\n"); ··· 372 371 if (ret) 373 372 return ret; 374 373 375 - intel_pxp_resume(&gt->pxp); 374 + intel_pxp_runtime_resume(&gt->pxp); 376 375 377 376 return 0; 378 377 }
+26 -11
drivers/gpu/drm/i915/pxp/intel_pxp_pm.c
··· 7 7 #include "intel_pxp_irq.h" 8 8 #include "intel_pxp_pm.h" 9 9 #include "intel_pxp_session.h" 10 + #include "i915_drv.h" 10 11 11 - void intel_pxp_suspend(struct intel_pxp *pxp, bool runtime) 12 + void intel_pxp_suspend_prepare(struct intel_pxp *pxp) 12 13 { 13 14 if (!intel_pxp_is_enabled(pxp)) 14 15 return; 15 16 16 17 pxp->arb_is_valid = false; 17 18 18 - /* 19 - * Contexts using protected objects keep a runtime PM reference, so we 20 - * can only runtime suspend when all of them have been either closed 21 - * or banned. Therefore, there is no need to invalidate in that 22 - * scenario. 23 - */ 24 - if (!runtime) 25 - intel_pxp_invalidate(pxp); 19 + intel_pxp_invalidate(pxp); 20 + } 26 21 27 - intel_pxp_fini_hw(pxp); 22 + void intel_pxp_suspend(struct intel_pxp *pxp) 23 + { 24 + intel_wakeref_t wakeref; 28 25 29 - pxp->hw_state_invalidated = false; 26 + if (!intel_pxp_is_enabled(pxp)) 27 + return; 28 + 29 + with_intel_runtime_pm(&pxp_to_gt(pxp)->i915->runtime_pm, wakeref) { 30 + intel_pxp_fini_hw(pxp); 31 + pxp->hw_state_invalidated = false; 32 + } 30 33 } 31 34 32 35 void intel_pxp_resume(struct intel_pxp *pxp) ··· 46 43 return; 47 44 48 45 intel_pxp_init_hw(pxp); 46 + } 47 + 48 + void intel_pxp_runtime_suspend(struct intel_pxp *pxp) 49 + { 50 + if (!intel_pxp_is_enabled(pxp)) 51 + return; 52 + 53 + pxp->arb_is_valid = false; 54 + 55 + intel_pxp_fini_hw(pxp); 56 + 57 + pxp->hw_state_invalidated = false; 49 58 }
+16 -3
drivers/gpu/drm/i915/pxp/intel_pxp_pm.h
··· 9 9 #include "intel_pxp_types.h" 10 10 11 11 #ifdef CONFIG_DRM_I915_PXP 12 - void intel_pxp_suspend(struct intel_pxp *pxp, bool runtime); 12 + void intel_pxp_suspend_prepare(struct intel_pxp *pxp); 13 + void intel_pxp_suspend(struct intel_pxp *pxp); 13 14 void intel_pxp_resume(struct intel_pxp *pxp); 15 + void intel_pxp_runtime_suspend(struct intel_pxp *pxp); 14 16 #else 15 - static inline void intel_pxp_suspend(struct intel_pxp *pxp, bool runtime) 17 + static inline void intel_pxp_suspend_prepare(struct intel_pxp *pxp) 18 + { 19 + } 20 + 21 + static inline void intel_pxp_suspend(struct intel_pxp *pxp) 16 22 { 17 23 } 18 24 19 25 static inline void intel_pxp_resume(struct intel_pxp *pxp) 20 26 { 21 27 } 22 - #endif 23 28 29 + static inline void intel_pxp_runtime_suspend(struct intel_pxp *pxp) 30 + { 31 + } 32 + #endif 33 + static inline void intel_pxp_runtime_resume(struct intel_pxp *pxp) 34 + { 35 + intel_pxp_resume(pxp); 36 + } 24 37 #endif /* __INTEL_PXP_PM_H__ */