]> Git Repo - linux.git/blob - drivers/gpu/drm/i915/pxp/intel_pxp_pm.c
Linux 6.14-rc3
[linux.git] / drivers / gpu / drm / i915 / pxp / intel_pxp_pm.c
1 // SPDX-License-Identifier: MIT
2 /*
3  * Copyright(c) 2020 Intel Corporation.
4  */
5
6 #include "i915_drv.h"
7
8 #include "intel_pxp.h"
9 #include "intel_pxp_irq.h"
10 #include "intel_pxp_pm.h"
11 #include "intel_pxp_session.h"
12 #include "intel_pxp_types.h"
13
14 void intel_pxp_suspend_prepare(struct intel_pxp *pxp)
15 {
16         if (!intel_pxp_is_enabled(pxp))
17                 return;
18
19         intel_pxp_end(pxp);
20
21         intel_pxp_invalidate(pxp);
22 }
23
24 void intel_pxp_suspend(struct intel_pxp *pxp)
25 {
26         intel_wakeref_t wakeref;
27
28         if (!intel_pxp_is_enabled(pxp))
29                 return;
30
31         with_intel_runtime_pm(&pxp->ctrl_gt->i915->runtime_pm, wakeref) {
32                 intel_pxp_fini_hw(pxp);
33                 pxp->hw_state_invalidated = false;
34         }
35 }
36
37 static void _pxp_resume(struct intel_pxp *pxp, bool take_wakeref)
38 {
39         intel_wakeref_t wakeref;
40
41         if (!intel_pxp_is_enabled(pxp))
42                 return;
43
44         /*
45          * The PXP component gets automatically unbound when we go into S3 and
46          * re-bound after we come out, so in that scenario we can defer the
47          * hw init to the bind call.
48          * NOTE: GSC-CS backend doesn't rely on components.
49          */
50         if (!HAS_ENGINE(pxp->ctrl_gt, GSC0) && !pxp->pxp_component)
51                 return;
52
53         if (take_wakeref)
54                 wakeref = intel_runtime_pm_get(&pxp->ctrl_gt->i915->runtime_pm);
55         intel_pxp_init_hw(pxp);
56         if (take_wakeref)
57                 intel_runtime_pm_put(&pxp->ctrl_gt->i915->runtime_pm, wakeref);
58 }
59
60 void intel_pxp_resume_complete(struct intel_pxp *pxp)
61 {
62         _pxp_resume(pxp, true);
63 }
64
65 void intel_pxp_runtime_resume(struct intel_pxp *pxp)
66 {
67         _pxp_resume(pxp, false);
68 }
69
70 void intel_pxp_runtime_suspend(struct intel_pxp *pxp)
71 {
72         if (!intel_pxp_is_enabled(pxp))
73                 return;
74
75         pxp->arb_is_valid = false;
76
77         intel_pxp_fini_hw(pxp);
78
79         pxp->hw_state_invalidated = false;
80 }
This page took 0.034157 seconds and 4 git commands to generate.