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 void intel_pxp_resume_complete(struct intel_pxp *pxp)
38 {
39 	if (!intel_pxp_is_enabled(pxp))
40 		return;
41 
42 	/*
43 	 * The PXP component gets automatically unbound when we go into S3 and
44 	 * re-bound after we come out, so in that scenario we can defer the
45 	 * hw init to the bind call.
46 	 * NOTE: GSC-CS backend doesn't rely on components.
47 	 */
48 	if (!HAS_ENGINE(pxp->ctrl_gt, GSC0) && !pxp->pxp_component)
49 		return;
50 
51 	intel_pxp_init_hw(pxp);
52 }
53 
54 void intel_pxp_runtime_suspend(struct intel_pxp *pxp)
55 {
56 	if (!intel_pxp_is_enabled(pxp))
57 		return;
58 
59 	pxp->arb_is_valid = false;
60 
61 	intel_pxp_fini_hw(pxp);
62 
63 	pxp->hw_state_invalidated = false;
64 }
65