Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/xe/pxp: Add GSC session initialization support

A session is initialized (i.e. started) by sending a message to the GSC.
The initialization will be triggered when a user opts-in to using PXP;
the interface for that is coming in a follow-up patch in the series.

v2: clean up error messages, use new ARB define (John)

Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: John Harrison <John.C.Harrison@Intel.com>
Reviewed-by: John Harrison <John.C.Harrison@Intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250129174140.948829-7-daniele.ceraolospurio@intel.com

+69
+21
drivers/gpu/drm/xe/abi/gsc_pxp_commands_abi.h
··· 51 51 } __packed; 52 52 53 53 #define PXP43_CMDID_INVALIDATE_STREAM_KEY 0x00000007 54 + #define PXP43_CMDID_INIT_SESSION 0x00000036 54 55 #define PXP43_CMDID_NEW_HUC_AUTH 0x0000003F /* MTL+ */ 55 56 56 57 /* PXP-Input-Packet: HUC Auth-only */ ··· 64 63 /* PXP-Output-Packet: HUC Load and Authentication or Auth-only */ 65 64 struct pxp43_huc_auth_out { 66 65 struct pxp_cmd_header header; 66 + } __packed; 67 + 68 + /* PXP-Input-Packet: Init PXP session */ 69 + struct pxp43_create_arb_in { 70 + struct pxp_cmd_header header; 71 + /* header.stream_id fields for vesion 4.3 of Init PXP session: */ 72 + #define PXP43_INIT_SESSION_VALID BIT(0) 73 + #define PXP43_INIT_SESSION_APPTYPE BIT(1) 74 + #define PXP43_INIT_SESSION_APPID GENMASK(17, 2) 75 + u32 protection_mode; 76 + #define PXP43_INIT_SESSION_PROTECTION_ARB 0x2 77 + u32 sub_session_id; 78 + u32 init_flags; 79 + u32 rsvd[12]; 80 + } __packed; 81 + 82 + /* PXP-Input-Packet: Init PXP session */ 83 + struct pxp43_create_arb_out { 84 + struct pxp_cmd_header header; 85 + u32 rsvd[8]; 67 86 } __packed; 68 87 69 88 /* PXP-Input-Packet: Invalidate Stream Key */
+47
drivers/gpu/drm/xe/xe_pxp_submit.c
··· 16 16 #include "xe_gt.h" 17 17 #include "xe_lrc.h" 18 18 #include "xe_map.h" 19 + #include "xe_pxp.h" 19 20 #include "xe_pxp_types.h" 20 21 #include "xe_sched_job.h" 21 22 #include "xe_vm.h" ··· 487 486 } 488 487 489 488 xe_gsc_poison_header(xe, &gsc_res->msg_in, 0); 489 + 490 + return ret; 491 + } 492 + 493 + /** 494 + * xe_pxp_submit_session_init - submits a PXP GSC session initialization 495 + * @gsc_res: the pxp client resources 496 + * @id: the session to initialize 497 + * 498 + * Submit a message to the GSC FW to initialize (i.e. start) a PXP session. 499 + * 500 + * Returns 0 if the submission is successful, an errno value otherwise. 501 + */ 502 + int xe_pxp_submit_session_init(struct xe_pxp_gsc_client_resources *gsc_res, u32 id) 503 + { 504 + struct xe_device *xe = gsc_res->vm->xe; 505 + struct pxp43_create_arb_in msg_in = {0}; 506 + struct pxp43_create_arb_out msg_out = {0}; 507 + int ret; 508 + 509 + msg_in.header.api_version = PXP_APIVER(4, 3); 510 + msg_in.header.command_id = PXP43_CMDID_INIT_SESSION; 511 + msg_in.header.stream_id = (FIELD_PREP(PXP43_INIT_SESSION_APPID, id) | 512 + FIELD_PREP(PXP43_INIT_SESSION_VALID, 1) | 513 + FIELD_PREP(PXP43_INIT_SESSION_APPTYPE, 0)); 514 + msg_in.header.buffer_len = sizeof(msg_in) - sizeof(msg_in.header); 515 + 516 + if (id == DRM_XE_PXP_HWDRM_DEFAULT_SESSION) 517 + msg_in.protection_mode = PXP43_INIT_SESSION_PROTECTION_ARB; 518 + 519 + ret = gsccs_send_message(gsc_res, &msg_in, sizeof(msg_in), 520 + &msg_out, sizeof(msg_out)); 521 + if (ret) { 522 + drm_err(&xe->drm, "Failed to init PXP session %u (%pe)\n", id, ERR_PTR(ret)); 523 + } else if (msg_out.header.status != 0) { 524 + ret = -EIO; 525 + 526 + if (is_fw_err_platform_config(msg_out.header.status)) 527 + drm_info_once(&xe->drm, 528 + "Failed to init PXP session %u due to BIOS/SOC, s=0x%x(%s)\n", 529 + id, msg_out.header.status, 530 + fw_err_to_string(msg_out.header.status)); 531 + else 532 + drm_dbg(&xe->drm, "Failed to init PXP session %u, s=0x%x\n", 533 + id, msg_out.header.status); 534 + } 490 535 491 536 return ret; 492 537 }
+1
drivers/gpu/drm/xe/xe_pxp_submit.h
··· 14 14 int xe_pxp_allocate_execution_resources(struct xe_pxp *pxp); 15 15 void xe_pxp_destroy_execution_resources(struct xe_pxp *pxp); 16 16 17 + int xe_pxp_submit_session_init(struct xe_pxp_gsc_client_resources *gsc_res, u32 id); 17 18 int xe_pxp_submit_session_termination(struct xe_pxp *pxp, u32 id); 18 19 int xe_pxp_submit_session_invalidation(struct xe_pxp_gsc_client_resources *gsc_res, 19 20 u32 id);