|
6 | 6 | #include "gem/i915_gem_internal.h" |
7 | 7 |
|
8 | 8 | #include "gt/intel_context.h" |
| 9 | +#include "gt/uc/intel_gsc_fw.h" |
9 | 10 | #include "gt/uc/intel_gsc_uc_heci_cmd_submit.h" |
10 | 11 |
|
11 | 12 | #include "i915_drv.h" |
| 13 | +#include "intel_pxp_cmd_interface_42.h" |
12 | 14 | #include "intel_pxp_cmd_interface_43.h" |
13 | 15 | #include "intel_pxp_gsccs.h" |
14 | 16 | #include "intel_pxp_types.h" |
15 | 17 |
|
| 18 | +static bool |
| 19 | +is_fw_err_platform_config(u32 type) |
| 20 | +{ |
| 21 | + switch (type) { |
| 22 | + case PXP_STATUS_ERROR_API_VERSION: |
| 23 | + case PXP_STATUS_PLATFCONFIG_KF1_NOVERIF: |
| 24 | + case PXP_STATUS_PLATFCONFIG_KF1_BAD: |
| 25 | + return true; |
| 26 | + default: |
| 27 | + break; |
| 28 | + } |
| 29 | + return false; |
| 30 | +} |
| 31 | + |
| 32 | +static const char * |
| 33 | +fw_err_to_string(u32 type) |
| 34 | +{ |
| 35 | + switch (type) { |
| 36 | + case PXP_STATUS_ERROR_API_VERSION: |
| 37 | + return "ERR_API_VERSION"; |
| 38 | + case PXP_STATUS_NOT_READY: |
| 39 | + return "ERR_NOT_READY"; |
| 40 | + case PXP_STATUS_PLATFCONFIG_KF1_NOVERIF: |
| 41 | + case PXP_STATUS_PLATFCONFIG_KF1_BAD: |
| 42 | + return "ERR_PLATFORM_CONFIG"; |
| 43 | + default: |
| 44 | + break; |
| 45 | + } |
| 46 | + return NULL; |
| 47 | +} |
| 48 | + |
16 | 49 | static int |
17 | 50 | gsccs_send_message(struct intel_pxp *pxp, |
18 | 51 | void *msg_in, size_t msg_in_size, |
@@ -152,6 +185,103 @@ gsccs_send_message_retry_complete(struct intel_pxp *pxp, |
152 | 185 | return ret; |
153 | 186 | } |
154 | 187 |
|
| 188 | +bool intel_pxp_gsccs_is_ready_for_sessions(struct intel_pxp *pxp) |
| 189 | +{ |
| 190 | + /* |
| 191 | + * GSC-fw loading, HuC-fw loading, HuC-fw authentication and |
| 192 | + * GSC-proxy init flow (requiring an mei component driver) |
| 193 | + * must all occur first before we can start requesting for PXP |
| 194 | + * sessions. Checking for completion on HuC authentication and |
| 195 | + * gsc-proxy init flow (the last set of dependencies that |
| 196 | + * are out of order) will suffice. |
| 197 | + */ |
| 198 | + if (intel_huc_is_authenticated(&pxp->ctrl_gt->uc.huc) && |
| 199 | + intel_gsc_uc_fw_proxy_init_done(&pxp->ctrl_gt->uc.gsc)) |
| 200 | + return true; |
| 201 | + |
| 202 | + return false; |
| 203 | +} |
| 204 | + |
| 205 | +int intel_pxp_gsccs_create_session(struct intel_pxp *pxp, |
| 206 | + int arb_session_id) |
| 207 | +{ |
| 208 | + struct drm_i915_private *i915 = pxp->ctrl_gt->i915; |
| 209 | + struct pxp43_create_arb_in msg_in = {0}; |
| 210 | + struct pxp43_create_arb_out msg_out = {0}; |
| 211 | + int ret; |
| 212 | + |
| 213 | + msg_in.header.api_version = PXP_APIVER(4, 3); |
| 214 | + msg_in.header.command_id = PXP43_CMDID_INIT_SESSION; |
| 215 | + msg_in.header.stream_id = (FIELD_PREP(PXP43_INIT_SESSION_APPID, arb_session_id) | |
| 216 | + FIELD_PREP(PXP43_INIT_SESSION_VALID, 1) | |
| 217 | + FIELD_PREP(PXP43_INIT_SESSION_APPTYPE, 0)); |
| 218 | + msg_in.header.buffer_len = sizeof(msg_in) - sizeof(msg_in.header); |
| 219 | + msg_in.protection_mode = PXP43_INIT_SESSION_PROTECTION_ARB; |
| 220 | + |
| 221 | + ret = gsccs_send_message_retry_complete(pxp, |
| 222 | + &msg_in, sizeof(msg_in), |
| 223 | + &msg_out, sizeof(msg_out), NULL); |
| 224 | + if (ret) { |
| 225 | + drm_err(&i915->drm, "Failed to init session %d, ret=[%d]\n", arb_session_id, ret); |
| 226 | + } else if (msg_out.header.status != 0) { |
| 227 | + if (is_fw_err_platform_config(msg_out.header.status)) { |
| 228 | + drm_info_once(&i915->drm, |
| 229 | + "PXP init-session-%d failed due to BIOS/SOC:0x%08x:%s\n", |
| 230 | + arb_session_id, msg_out.header.status, |
| 231 | + fw_err_to_string(msg_out.header.status)); |
| 232 | + } else { |
| 233 | + drm_dbg(&i915->drm, "PXP init-session-%d failed 0x%08x:%st:\n", |
| 234 | + arb_session_id, msg_out.header.status, |
| 235 | + fw_err_to_string(msg_out.header.status)); |
| 236 | + drm_dbg(&i915->drm, " cmd-detail: ID=[0x%08x],API-Ver-[0x%08x]\n", |
| 237 | + msg_in.header.command_id, msg_in.header.api_version); |
| 238 | + } |
| 239 | + } |
| 240 | + |
| 241 | + return ret; |
| 242 | +} |
| 243 | + |
| 244 | +void intel_pxp_gsccs_end_arb_fw_session(struct intel_pxp *pxp, u32 session_id) |
| 245 | +{ |
| 246 | + struct drm_i915_private *i915 = pxp->ctrl_gt->i915; |
| 247 | + struct pxp42_inv_stream_key_in msg_in = {0}; |
| 248 | + struct pxp42_inv_stream_key_out msg_out = {0}; |
| 249 | + int ret = 0; |
| 250 | + |
| 251 | + /* |
| 252 | + * Stream key invalidation reuses the same version 4.2 input/output |
| 253 | + * command format but firmware requires 4.3 API interaction |
| 254 | + */ |
| 255 | + msg_in.header.api_version = PXP_APIVER(4, 3); |
| 256 | + msg_in.header.command_id = PXP42_CMDID_INVALIDATE_STREAM_KEY; |
| 257 | + msg_in.header.buffer_len = sizeof(msg_in) - sizeof(msg_in.header); |
| 258 | + |
| 259 | + msg_in.header.stream_id = FIELD_PREP(PXP_CMDHDR_EXTDATA_SESSION_VALID, 1); |
| 260 | + msg_in.header.stream_id |= FIELD_PREP(PXP_CMDHDR_EXTDATA_APP_TYPE, 0); |
| 261 | + msg_in.header.stream_id |= FIELD_PREP(PXP_CMDHDR_EXTDATA_SESSION_ID, session_id); |
| 262 | + |
| 263 | + ret = gsccs_send_message_retry_complete(pxp, |
| 264 | + &msg_in, sizeof(msg_in), |
| 265 | + &msg_out, sizeof(msg_out), NULL); |
| 266 | + if (ret) { |
| 267 | + drm_err(&i915->drm, "Failed to inv-stream-key-%u, ret=[%d]\n", |
| 268 | + session_id, ret); |
| 269 | + } else if (msg_out.header.status != 0) { |
| 270 | + if (is_fw_err_platform_config(msg_out.header.status)) { |
| 271 | + drm_info_once(&i915->drm, |
| 272 | + "PXP inv-stream-key-%u failed due to BIOS/SOC :0x%08x:%s\n", |
| 273 | + session_id, msg_out.header.status, |
| 274 | + fw_err_to_string(msg_out.header.status)); |
| 275 | + } else { |
| 276 | + drm_dbg(&i915->drm, "PXP inv-stream-key-%u failed 0x%08x:%s:\n", |
| 277 | + session_id, msg_out.header.status, |
| 278 | + fw_err_to_string(msg_out.header.status)); |
| 279 | + drm_dbg(&i915->drm, " cmd-detail: ID=[0x%08x],API-Ver-[0x%08x]\n", |
| 280 | + msg_in.header.command_id, msg_in.header.api_version); |
| 281 | + } |
| 282 | + } |
| 283 | +} |
| 284 | + |
155 | 285 | static void |
156 | 286 | gsccs_cleanup_fw_host_session_handle(struct intel_pxp *pxp) |
157 | 287 | { |
|
0 commit comments