xref: /linux/drivers/gpu/drm/i915/pxp/intel_pxp_pm.c (revision 24bce201d79807b668bf9d9e0aca801c5c0d5f78)
1 // SPDX-License-Identifier: MIT
2 /*
3  * Copyright(c) 2020 Intel Corporation.
4  */
5 
6 #include "intel_pxp.h"
7 #include "intel_pxp_irq.h"
8 #include "intel_pxp_pm.h"
9 #include "intel_pxp_session.h"
10 #include "i915_drv.h"
11 
12 void intel_pxp_suspend_prepare(struct intel_pxp *pxp)
13 {
14 	if (!intel_pxp_is_enabled(pxp))
15 		return;
16 
17 	pxp->arb_is_valid = false;
18 
19 	intel_pxp_invalidate(pxp);
20 }
21 
22 void intel_pxp_suspend(struct intel_pxp *pxp)
23 {
24 	intel_wakeref_t wakeref;
25 
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 	}
33 }
34 
35 void intel_pxp_resume(struct intel_pxp *pxp)
36 {
37 	if (!intel_pxp_is_enabled(pxp))
38 		return;
39 
40 	/*
41 	 * The PXP component gets automatically unbound when we go into S3 and
42 	 * re-bound after we come out, so in that scenario we can defer the
43 	 * hw init to the bind call.
44 	 */
45 	if (!pxp->pxp_component)
46 		return;
47 
48 	intel_pxp_init_hw(pxp);
49 }
50 
51 void intel_pxp_runtime_suspend(struct intel_pxp *pxp)
52 {
53 	if (!intel_pxp_is_enabled(pxp))
54 		return;
55 
56 	pxp->arb_is_valid = false;
57 
58 	intel_pxp_fini_hw(pxp);
59 
60 	pxp->hw_state_invalidated = false;
61 }
62