Skip to content

Commit 0387d46

Browse files
committed
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
1 parent 3b506d7 commit 0387d46

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

drivers/gpu/drm/xe/abi/gsc_pxp_commands_abi.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ struct pxp_cmd_header {
5151
} __packed;
5252

5353
#define PXP43_CMDID_INVALIDATE_STREAM_KEY 0x00000007
54+
#define PXP43_CMDID_INIT_SESSION 0x00000036
5455
#define PXP43_CMDID_NEW_HUC_AUTH 0x0000003F /* MTL+ */
5556

5657
/* PXP-Input-Packet: HUC Auth-only */
@@ -65,6 +66,26 @@ struct pxp43_huc_auth_out {
6566
struct pxp_cmd_header header;
6667
} __packed;
6768

69+
/* PXP-Input-Packet: Init PXP session */
70+
struct pxp43_create_arb_in {
71+
struct pxp_cmd_header header;
72+
/* header.stream_id fields for vesion 4.3 of Init PXP session: */
73+
#define PXP43_INIT_SESSION_VALID BIT(0)
74+
#define PXP43_INIT_SESSION_APPTYPE BIT(1)
75+
#define PXP43_INIT_SESSION_APPID GENMASK(17, 2)
76+
u32 protection_mode;
77+
#define PXP43_INIT_SESSION_PROTECTION_ARB 0x2
78+
u32 sub_session_id;
79+
u32 init_flags;
80+
u32 rsvd[12];
81+
} __packed;
82+
83+
/* PXP-Input-Packet: Init PXP session */
84+
struct pxp43_create_arb_out {
85+
struct pxp_cmd_header header;
86+
u32 rsvd[8];
87+
} __packed;
88+
6889
/* PXP-Input-Packet: Invalidate Stream Key */
6990
struct pxp43_inv_stream_key_in {
7091
struct pxp_cmd_header header;

drivers/gpu/drm/xe/xe_pxp_submit.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "xe_gt.h"
1717
#include "xe_lrc.h"
1818
#include "xe_map.h"
19+
#include "xe_pxp.h"
1920
#include "xe_pxp_types.h"
2021
#include "xe_sched_job.h"
2122
#include "xe_vm.h"
@@ -490,6 +491,52 @@ static int gsccs_send_message(struct xe_pxp_gsc_client_resources *gsc_res,
490491
return ret;
491492
}
492493

494+
/**
495+
* xe_pxp_submit_session_init - submits a PXP GSC session initialization
496+
* @gsc_res: the pxp client resources
497+
* @id: the session to initialize
498+
*
499+
* Submit a message to the GSC FW to initialize (i.e. start) a PXP session.
500+
*
501+
* Returns 0 if the submission is successful, an errno value otherwise.
502+
*/
503+
int xe_pxp_submit_session_init(struct xe_pxp_gsc_client_resources *gsc_res, u32 id)
504+
{
505+
struct xe_device *xe = gsc_res->vm->xe;
506+
struct pxp43_create_arb_in msg_in = {0};
507+
struct pxp43_create_arb_out msg_out = {0};
508+
int ret;
509+
510+
msg_in.header.api_version = PXP_APIVER(4, 3);
511+
msg_in.header.command_id = PXP43_CMDID_INIT_SESSION;
512+
msg_in.header.stream_id = (FIELD_PREP(PXP43_INIT_SESSION_APPID, id) |
513+
FIELD_PREP(PXP43_INIT_SESSION_VALID, 1) |
514+
FIELD_PREP(PXP43_INIT_SESSION_APPTYPE, 0));
515+
msg_in.header.buffer_len = sizeof(msg_in) - sizeof(msg_in.header);
516+
517+
if (id == DRM_XE_PXP_HWDRM_DEFAULT_SESSION)
518+
msg_in.protection_mode = PXP43_INIT_SESSION_PROTECTION_ARB;
519+
520+
ret = gsccs_send_message(gsc_res, &msg_in, sizeof(msg_in),
521+
&msg_out, sizeof(msg_out));
522+
if (ret) {
523+
drm_err(&xe->drm, "Failed to init PXP session %u (%pe)\n", id, ERR_PTR(ret));
524+
} else if (msg_out.header.status != 0) {
525+
ret = -EIO;
526+
527+
if (is_fw_err_platform_config(msg_out.header.status))
528+
drm_info_once(&xe->drm,
529+
"Failed to init PXP session %u due to BIOS/SOC, s=0x%x(%s)\n",
530+
id, msg_out.header.status,
531+
fw_err_to_string(msg_out.header.status));
532+
else
533+
drm_dbg(&xe->drm, "Failed to init PXP session %u, s=0x%x\n",
534+
id, msg_out.header.status);
535+
}
536+
537+
return ret;
538+
}
539+
493540
/**
494541
* xe_pxp_submit_session_invalidation - submits a PXP GSC invalidation
495542
* @gsc_res: the pxp client resources

drivers/gpu/drm/xe/xe_pxp_submit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ struct xe_pxp_gsc_client_resources;
1414
int xe_pxp_allocate_execution_resources(struct xe_pxp *pxp);
1515
void xe_pxp_destroy_execution_resources(struct xe_pxp *pxp);
1616

17+
int xe_pxp_submit_session_init(struct xe_pxp_gsc_client_resources *gsc_res, u32 id);
1718
int xe_pxp_submit_session_termination(struct xe_pxp *pxp, u32 id);
1819
int xe_pxp_submit_session_invalidation(struct xe_pxp_gsc_client_resources *gsc_res,
1920
u32 id);

0 commit comments

Comments
 (0)