Skip to content

Commit d1da138

Browse files
aalteresRadhakrishna Sripada
authored andcommitted
drm/i915/uapi/pxp: Add a GET_PARAM for PXP
Because of the additional firmware, component-driver and initialization depedencies required on MTL platform before a PXP context can be created, UMD calling for PXP creation as a way to get-caps can take a long time. An actual real world customer stack has seen this happen in the 4-to-8 second range after the kernel starts (which sees MESA's init appear in the middle of this range as the compositor comes up). To avoid unncessary delays experienced by the UMD for get-caps purposes, add a GET_PARAM for I915_PARAM_PXP_SUPPORT. However, some failures can still occur after all the depedencies are met (such as firmware init flow failure, bios configurations or SOC fusing not allowing PXP enablement). Those scenarios will only be known to user space when it attempts creating a PXP context and is documented in the GEM UAPI headers. While making this change, create a helper that is common to both GET_PARAM caller and intel_pxp_start since the latter does similar checks. Signed-off-by: Alan Previn <alan.previn.teres.alexis@intel.com> Reviewed-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> Acked-by: Jordan Justen <jordan.l.justen@intel.com> Signed-off-by: Radhakrishna Sripada <radhakrishna.sripada@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230511231738.1077674-7-alan.previn.teres.alexis@intel.com
1 parent 99afb7c commit d1da138

4 files changed

Lines changed: 49 additions & 7 deletions

File tree

drivers/gpu/drm/i915/i915_getparam.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include "gem/i915_gem_mman.h"
66
#include "gt/intel_engine_user.h"
77

8+
#include "pxp/intel_pxp.h"
9+
810
#include "i915_cmd_parser.h"
911
#include "i915_drv.h"
1012
#include "i915_getparam.h"
@@ -102,6 +104,11 @@ int i915_getparam_ioctl(struct drm_device *dev, void *data,
102104
if (value < 0)
103105
return value;
104106
break;
107+
case I915_PARAM_PXP_STATUS:
108+
value = intel_pxp_get_readiness_status(i915->pxp);
109+
if (value < 0)
110+
return value;
111+
break;
105112
case I915_PARAM_MMAP_GTT_VERSION:
106113
/* Though we've started our numbering from 1, and so class all
107114
* earlier versions as 0, in effect their value is undefined as

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

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -358,23 +358,38 @@ void intel_pxp_end(struct intel_pxp *pxp)
358358
}
359359

360360
/*
361-
* the arb session is restarted from the irq work when we receive the
362-
* termination completion interrupt
361+
* this helper is used by both intel_pxp_start and by
362+
* the GET_PARAM IOCTL that user space calls. Thus, the
363+
* return values here should match the UAPI spec.
363364
*/
364-
int intel_pxp_start(struct intel_pxp *pxp)
365+
int intel_pxp_get_readiness_status(struct intel_pxp *pxp)
365366
{
366-
int ret = 0;
367-
368367
if (!intel_pxp_is_enabled(pxp))
369368
return -ENODEV;
370369

371370
if (HAS_ENGINE(pxp->ctrl_gt, GSC0)) {
372371
if (wait_for(intel_pxp_gsccs_is_ready_for_sessions(pxp), 250))
373-
return -ENXIO;
372+
return 2;
374373
} else {
375374
if (wait_for(pxp_component_bound(pxp), 250))
376-
return -ENXIO;
375+
return 2;
377376
}
377+
return 1;
378+
}
379+
380+
/*
381+
* the arb session is restarted from the irq work when we receive the
382+
* termination completion interrupt
383+
*/
384+
int intel_pxp_start(struct intel_pxp *pxp)
385+
{
386+
int ret = 0;
387+
388+
ret = intel_pxp_get_readiness_status(pxp);
389+
if (ret < 0)
390+
return ret;
391+
else if (ret > 1)
392+
return -EIO; /* per UAPI spec, user may retry later */
378393

379394
mutex_lock(&pxp->arb_mutex);
380395

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ void intel_pxp_fini_hw(struct intel_pxp *pxp);
2626
void intel_pxp_mark_termination_in_progress(struct intel_pxp *pxp);
2727
void intel_pxp_tee_end_arb_fw_session(struct intel_pxp *pxp, u32 arb_session_id);
2828

29+
int intel_pxp_get_readiness_status(struct intel_pxp *pxp);
2930
int intel_pxp_start(struct intel_pxp *pxp);
3031
void intel_pxp_end(struct intel_pxp *pxp);
3132

include/uapi/drm/i915_drm.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,25 @@ typedef struct drm_i915_irq_wait {
771771
*/
772772
#define I915_PARAM_OA_TIMESTAMP_FREQUENCY 57
773773

774+
/*
775+
* Query the status of PXP support in i915.
776+
*
777+
* The query can fail in the following scenarios with the listed error codes:
778+
* -ENODEV = PXP support is not available on the GPU device or in the
779+
* kernel due to missing component drivers or kernel configs.
780+
*
781+
* If the IOCTL is successful, the returned parameter will be set to one of
782+
* the following values:
783+
* 1 = PXP feature is supported and is ready for use.
784+
* 2 = PXP feature is supported but should be ready soon (pending
785+
* initialization of non-i915 system dependencies).
786+
*
787+
* NOTE: When param is supported (positive return values), user space should
788+
* still refer to the GEM PXP context-creation UAPI header specs to be
789+
* aware of possible failure due to system state machine at the time.
790+
*/
791+
#define I915_PARAM_PXP_STATUS 58
792+
774793
/* Must be kept compact -- no holes and well documented */
775794

776795
/**

0 commit comments

Comments
 (0)