drm/i915/pxp/mtl: intel_pxp_init_hw needs runtime-pm inside pm-complete
authorAlan Previn <alan.previn.teres.alexis@intel.com>
Wed, 2 Aug 2023 19:06:11 +0000 (12:06 -0700)
committerDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Tue, 15 Aug 2023 20:28:13 +0000 (13:28 -0700)
In the case of failed suspend flow or cases where the kernel does not go
into full suspend but goes from suspend_prepare back to resume_complete,
we get called for a pm_complete but without runtime_pm guaranteed.

Thus, ensure we take the runtime_pm when calling intel_pxp_init_hw
from within intel_pxp_resume_complete.

v2: resume_complete and runtime_resume should abstract a common
    helper with different wakeref requirements. (Daniele)

Signed-off-by: Alan Previn <alan.previn.teres.alexis@intel.com>
Reviewed-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230802190611.1639371-1-alan.previn.teres.alexis@intel.com
drivers/gpu/drm/i915/pxp/intel_pxp_pm.c
drivers/gpu/drm/i915/pxp/intel_pxp_pm.h

index 1a04067f61fc7c685a2eb02c582003085241de4a..6dfd24918953a7354a290f259bb610242a3aa266 100644 (file)
@@ -34,8 +34,10 @@ void intel_pxp_suspend(struct intel_pxp *pxp)
        }
 }
 
-void intel_pxp_resume_complete(struct intel_pxp *pxp)
+static void _pxp_resume(struct intel_pxp *pxp, bool take_wakeref)
 {
+       intel_wakeref_t wakeref;
+
        if (!intel_pxp_is_enabled(pxp))
                return;
 
@@ -48,7 +50,21 @@ void intel_pxp_resume_complete(struct intel_pxp *pxp)
        if (!HAS_ENGINE(pxp->ctrl_gt, GSC0) && !pxp->pxp_component)
                return;
 
+       if (take_wakeref)
+               wakeref = intel_runtime_pm_get(&pxp->ctrl_gt->i915->runtime_pm);
        intel_pxp_init_hw(pxp);
+       if (take_wakeref)
+               intel_runtime_pm_put(&pxp->ctrl_gt->i915->runtime_pm, wakeref);
+}
+
+void intel_pxp_resume_complete(struct intel_pxp *pxp)
+{
+       _pxp_resume(pxp, true);
+}
+
+void intel_pxp_runtime_resume(struct intel_pxp *pxp)
+{
+       _pxp_resume(pxp, false);
 }
 
 void intel_pxp_runtime_suspend(struct intel_pxp *pxp)
index 06b46f535b42d499e29bc4b4a236e63b86dcbc7a..8695889b8380882d9ec993d48295d8d0f4bf63dc 100644 (file)
@@ -13,6 +13,7 @@ void intel_pxp_suspend_prepare(struct intel_pxp *pxp);
 void intel_pxp_suspend(struct intel_pxp *pxp);
 void intel_pxp_resume_complete(struct intel_pxp *pxp);
 void intel_pxp_runtime_suspend(struct intel_pxp *pxp);
+void intel_pxp_runtime_resume(struct intel_pxp *pxp);
 #else
 static inline void intel_pxp_suspend_prepare(struct intel_pxp *pxp)
 {
@@ -29,9 +30,9 @@ static inline void intel_pxp_resume_complete(struct intel_pxp *pxp)
 static inline void intel_pxp_runtime_suspend(struct intel_pxp *pxp)
 {
 }
-#endif
+
 static inline void intel_pxp_runtime_resume(struct intel_pxp *pxp)
 {
-       intel_pxp_resume_complete(pxp);
 }
+#endif
 #endif /* __INTEL_PXP_PM_H__ */