Skip to content

Commit d6bf74d

Browse files
aalteresRadhakrishna Sripada
authored andcommitted
drm/i915/pxp: Add GSC-CS back-end resource init and cleanup
For MTL, the PXP back-end transport uses the GSC engine to submit HECI packets through the HW to the GSC firmware for PXP arb session management. This submission uses a non-priveleged batch buffer, a buffer for the command packet and of course a context targeting the GSC-CS. Thus for MTL, we need to allocate and free a set of execution submission resources for the management of the arbitration session. Lets start with the context creation first since that object and its usage is very straight-forward. We'll add the buffer allocation and freeing later when we introduce the gsccs' send-message function. Do this one time allocation of gsccs specific resources in a new gsccs source file with intel_pxp_gsccs_init / fini functions and hook them up from the PXP front-end. Signed-off-by: Alan Previn <alan.previn.teres.alexis@intel.com> Reviewed-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> Signed-off-by: Radhakrishna Sripada <radhakrishna.sripada@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230511231738.1077674-2-alan.previn.teres.alexis@intel.com
1 parent 9275277 commit d6bf74d

6 files changed

Lines changed: 117 additions & 6 deletions

File tree

drivers/gpu/drm/i915/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ i915-y += \
339339
i915-$(CONFIG_DRM_I915_PXP) += \
340340
pxp/intel_pxp_cmd.o \
341341
pxp/intel_pxp_debugfs.o \
342+
pxp/intel_pxp_gsccs.o \
342343
pxp/intel_pxp_irq.o \
343344
pxp/intel_pxp_pm.o \
344345
pxp/intel_pxp_session.o

drivers/gpu/drm/i915/pxp/intel_pxp.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "i915_drv.h"
1313

1414
#include "intel_pxp.h"
15+
#include "intel_pxp_gsccs.h"
1516
#include "intel_pxp_irq.h"
1617
#include "intel_pxp_session.h"
1718
#include "intel_pxp_tee.h"
@@ -132,7 +133,10 @@ static void pxp_init_full(struct intel_pxp *pxp)
132133
if (ret)
133134
return;
134135

135-
ret = intel_pxp_tee_component_init(pxp);
136+
if (HAS_ENGINE(pxp->ctrl_gt, GSC0))
137+
ret = intel_pxp_gsccs_init(pxp);
138+
else
139+
ret = intel_pxp_tee_component_init(pxp);
136140
if (ret)
137141
goto out_context;
138142

@@ -165,9 +169,12 @@ static struct intel_gt *find_gt_for_required_protected_content(struct drm_i915_p
165169
/*
166170
* For MTL onwards, PXP-controller-GT needs to have a valid GSC engine
167171
* on the media GT. NOTE: if we have a media-tile with a GSC-engine,
168-
* the VDBOX is already present so skip that check
172+
* the VDBOX is already present so skip that check. We also have to
173+
* ensure the GSC and HUC firmware are coming online
169174
*/
170-
if (i915->media_gt && HAS_ENGINE(i915->media_gt, GSC0))
175+
if (i915->media_gt && HAS_ENGINE(i915->media_gt, GSC0) &&
176+
intel_uc_fw_is_loadable(&i915->media_gt->uc.gsc.fw) &&
177+
intel_uc_fw_is_loadable(&i915->media_gt->uc.huc.fw))
171178
return i915->media_gt;
172179

173180
/*
@@ -207,7 +214,9 @@ int intel_pxp_init(struct drm_i915_private *i915)
207214
if (!i915->pxp)
208215
return -ENOMEM;
209216

217+
/* init common info used by all feature-mode usages*/
210218
i915->pxp->ctrl_gt = gt;
219+
mutex_init(&i915->pxp->tee_mutex);
211220

212221
/*
213222
* If full PXP feature is not available but HuC is loaded by GSC on pre-MTL
@@ -229,7 +238,10 @@ void intel_pxp_fini(struct drm_i915_private *i915)
229238

230239
i915->pxp->arb_is_valid = false;
231240

232-
intel_pxp_tee_component_fini(i915->pxp);
241+
if (HAS_ENGINE(i915->pxp->ctrl_gt, GSC0))
242+
intel_pxp_gsccs_fini(i915->pxp);
243+
else
244+
intel_pxp_tee_component_fini(i915->pxp);
233245

234246
destroy_vcs_context(i915->pxp);
235247

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// SPDX-License-Identifier: MIT
2+
/*
3+
* Copyright(c) 2023 Intel Corporation.
4+
*/
5+
6+
#include "gem/i915_gem_internal.h"
7+
8+
#include "gt/intel_context.h"
9+
10+
#include "i915_drv.h"
11+
#include "intel_pxp_cmd_interface_43.h"
12+
#include "intel_pxp_gsccs.h"
13+
#include "intel_pxp_types.h"
14+
15+
static void
16+
gsccs_destroy_execution_resource(struct intel_pxp *pxp)
17+
{
18+
struct gsccs_session_resources *exec_res = &pxp->gsccs_res;
19+
20+
if (exec_res->ce)
21+
intel_context_put(exec_res->ce);
22+
23+
memset(exec_res, 0, sizeof(*exec_res));
24+
}
25+
26+
static int
27+
gsccs_allocate_execution_resource(struct intel_pxp *pxp)
28+
{
29+
struct intel_gt *gt = pxp->ctrl_gt;
30+
struct gsccs_session_resources *exec_res = &pxp->gsccs_res;
31+
struct intel_engine_cs *engine = gt->engine[GSC0];
32+
struct intel_context *ce;
33+
34+
/*
35+
* First, ensure the GSC engine is present.
36+
* NOTE: Backend would only be called with the correct gt.
37+
*/
38+
if (!engine)
39+
return -ENODEV;
40+
41+
/* Finally, create an intel_context to be used during the submission */
42+
ce = intel_context_create(engine);
43+
if (IS_ERR(ce)) {
44+
drm_err(&gt->i915->drm, "Failed creating gsccs backend ctx\n");
45+
return PTR_ERR(ce);
46+
}
47+
48+
i915_vm_put(ce->vm);
49+
ce->vm = i915_vm_get(pxp->ctrl_gt->vm);
50+
exec_res->ce = ce;
51+
52+
return 0;
53+
}
54+
55+
void intel_pxp_gsccs_fini(struct intel_pxp *pxp)
56+
{
57+
gsccs_destroy_execution_resource(pxp);
58+
}
59+
60+
int intel_pxp_gsccs_init(struct intel_pxp *pxp)
61+
{
62+
return gsccs_allocate_execution_resource(pxp);
63+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* SPDX-License-Identifier: MIT */
2+
/*
3+
* Copyright(c) 2022, Intel Corporation. All rights reserved.
4+
*/
5+
6+
#ifndef __INTEL_PXP_GSCCS_H__
7+
#define __INTEL_PXP_GSCCS_H__
8+
9+
#include <linux/types.h>
10+
11+
struct intel_pxp;
12+
13+
#ifdef CONFIG_DRM_I915_PXP
14+
void intel_pxp_gsccs_fini(struct intel_pxp *pxp);
15+
int intel_pxp_gsccs_init(struct intel_pxp *pxp);
16+
17+
#else
18+
static inline void intel_pxp_gsccs_fini(struct intel_pxp *pxp)
19+
{
20+
}
21+
22+
static inline int intel_pxp_gsccs_init(struct intel_pxp *pxp)
23+
{
24+
return 0;
25+
}
26+
27+
#endif
28+
29+
#endif /*__INTEL_PXP_GSCCS_H__ */

drivers/gpu/drm/i915/pxp/intel_pxp_tee.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,6 @@ int intel_pxp_tee_component_init(struct intel_pxp *pxp)
284284
struct intel_gt *gt = pxp->ctrl_gt;
285285
struct drm_i915_private *i915 = gt->i915;
286286

287-
mutex_init(&pxp->tee_mutex);
288-
289287
ret = alloc_streaming_command(pxp);
290288
if (ret)
291289
return ret;

drivers/gpu/drm/i915/pxp/intel_pxp_types.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ struct intel_pxp {
2626
*/
2727
struct intel_gt *ctrl_gt;
2828

29+
/**
30+
* @gsccs_res: resources for request submission for platforms that have a GSC engine.
31+
*/
32+
struct gsccs_session_resources {
33+
u64 host_session_handle; /* used by firmware to link commands to sessions */
34+
struct intel_context *ce; /* context for gsc command submission */
35+
} gsccs_res;
36+
2937
/**
3038
* @pxp_component: i915_pxp_component struct of the bound mei_pxp
3139
* module. Only set and cleared inside component bind/unbind functions,

0 commit comments

Comments
 (0)