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 intel_gt; 16 struct i915_pxp_component; 17 struct drm_i915_private; 18 19 /** 20 * struct intel_pxp - pxp state 21 */ 22 struct intel_pxp { 23 /** 24 * @ctrl_gt: poiner to the tile that owns the controls for PXP subsystem assets that 25 * the VDBOX, the KCR engine (and GSC CS depending on the platform) 26 */ 27 struct intel_gt *ctrl_gt; 28 29 /** 30 * @pxp_component: i915_pxp_component struct of the bound mei_pxp 31 * module. Only set and cleared inside component bind/unbind functions, 32 * which are protected by &tee_mutex. 33 */ 34 struct i915_pxp_component *pxp_component; 35 36 /* @dev_link: Enforce module relationship for power management ordering. */ 37 struct device_link *dev_link; 38 /** 39 * @pxp_component_added: track if the pxp component has been added. 40 * Set and cleared in tee init and fini functions respectively. 41 */ 42 bool pxp_component_added; 43 44 /** @ce: kernel-owned context used for PXP operations */ 45 struct intel_context *ce; 46 47 /** @arb_mutex: protects arb session start */ 48 struct mutex arb_mutex; 49 /** 50 * @arb_is_valid: tracks arb session status. 51 * After a teardown, the arb session can still be in play on the HW 52 * even if the keys are gone, so we can't rely on the HW state of the 53 * session to know if it's valid and need to track the status in SW. 54 */ 55 bool arb_is_valid; 56 57 /** 58 * @key_instance: tracks which key instance we're on, so we can use it 59 * to determine if an object was created using the current key or a 60 * previous one. 61 */ 62 u32 key_instance; 63 64 /** @tee_mutex: protects the tee channel binding and messaging. */ 65 struct mutex tee_mutex; 66 67 /** @stream_cmd: LMEM obj used to send stream PXP commands to the GSC */ 68 struct { 69 struct drm_i915_gem_object *obj; /* contains PXP command memory */ 70 void *vaddr; /* virtual memory for PXP command */ 71 } stream_cmd; 72 73 /** 74 * @hw_state_invalidated: if the HW perceives an attack on the integrity 75 * of the encryption it will invalidate the keys and expect SW to 76 * re-initialize the session. We keep track of this state to make sure 77 * we only re-start the arb session when required. 78 */ 79 bool hw_state_invalidated; 80 81 /** @irq_enabled: tracks the status of the kcr irqs */ 82 bool irq_enabled; 83 /** 84 * @termination: tracks the status of a pending termination. Only 85 * re-initialized under gt->irq_lock and completed in &session_work. 86 */ 87 struct completion termination; 88 89 /** @session_work: worker that manages session events. */ 90 struct work_struct session_work; 91 /** @session_events: pending session events, protected with gt->irq_lock. */ 92 u32 session_events; 93 #define PXP_TERMINATION_REQUEST BIT(0) 94 #define PXP_TERMINATION_COMPLETE BIT(1) 95 #define PXP_INVAL_REQUIRED BIT(2) 96 }; 97 98 #endif /* __INTEL_PXP_TYPES_H__ */ 99