xref: /linux/drivers/gpu/drm/i915/pxp/intel_pxp_types.h (revision 0be3ff0c)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright(c) 2020, Intel Corporation. All rights reserved.
4  */
5 
6 #ifndef __INTEL_PXP_TYPES_H__
7 #define __INTEL_PXP_TYPES_H__
8 
9 #include <linux/completion.h>
10 #include <linux/mutex.h>
11 #include <linux/types.h>
12 #include <linux/workqueue.h>
13 
14 struct intel_context;
15 struct i915_pxp_component;
16 
17 /**
18  * struct intel_pxp - pxp state
19  */
20 struct intel_pxp {
21 	/**
22 	 * @pxp_component: i915_pxp_component struct of the bound mei_pxp
23 	 * module. Only set and cleared inside component bind/unbind functions,
24 	 * which are protected by &tee_mutex.
25 	 */
26 	struct i915_pxp_component *pxp_component;
27 	/**
28 	 * @pxp_component_added: track if the pxp component has been added.
29 	 * Set and cleared in tee init and fini functions respectively.
30 	 */
31 	bool pxp_component_added;
32 
33 	/** @ce: kernel-owned context used for PXP operations */
34 	struct intel_context *ce;
35 
36 	/** @arb_mutex: protects arb session start */
37 	struct mutex arb_mutex;
38 	/**
39 	 * @arb_is_valid: tracks arb session status.
40 	 * After a teardown, the arb session can still be in play on the HW
41 	 * even if the keys are gone, so we can't rely on the HW state of the
42 	 * session to know if it's valid and need to track the status in SW.
43 	 */
44 	bool arb_is_valid;
45 
46 	/**
47 	 * @key_instance: tracks which key instance we're on, so we can use it
48 	 * to determine if an object was created using the current key or a
49 	 * previous one.
50 	 */
51 	u32 key_instance;
52 
53 	/** @tee_mutex: protects the tee channel binding and messaging. */
54 	struct mutex tee_mutex;
55 
56 	/**
57 	 * @hw_state_invalidated: if the HW perceives an attack on the integrity
58 	 * of the encryption it will invalidate the keys and expect SW to
59 	 * re-initialize the session. We keep track of this state to make sure
60 	 * we only re-start the arb session when required.
61 	 */
62 	bool hw_state_invalidated;
63 
64 	/** @irq_enabled: tracks the status of the kcr irqs */
65 	bool irq_enabled;
66 	/**
67 	 * @termination: tracks the status of a pending termination. Only
68 	 * re-initialized under gt->irq_lock and completed in &session_work.
69 	 */
70 	struct completion termination;
71 
72 	/** @session_work: worker that manages session events. */
73 	struct work_struct session_work;
74 	/** @session_events: pending session events, protected with gt->irq_lock. */
75 	u32 session_events;
76 #define PXP_TERMINATION_REQUEST  BIT(0)
77 #define PXP_TERMINATION_COMPLETE BIT(1)
78 #define PXP_INVAL_REQUIRED       BIT(2)
79 };
80 
81 #endif /* __INTEL_PXP_TYPES_H__ */
82