Skip to content

Commit 69a58ef

Browse files
dceraoloThomas Hellström
authored andcommitted
drm/xe/pxp: Clarify PXP queue creation behavior if PXP is not ready
The expected flow of operations when using PXP is to query the PXP status and wait for it to transition to "ready" before attempting to create an exec_queue. This flow is followed by the Mesa driver, but there is no guarantee that an incorrectly coded (or malicious) app will not attempt to create the queue first without querying the status. Therefore, we need to clarify what the expected behavior of the queue creation ioctl is in this scenario. Currently, the ioctl always fails with an -EBUSY code no matter the error, but for consistency it is better to distinguish between "failed to init" (-EIO) and "not ready" (-EBUSY), the same way the query ioctl does. Note that, while this is a change in the return code of an ioctl, the behavior of the ioctl in this particular corner case was not clearly spec'd, so no one should have been relying on it (and we know that Mesa, which is the only known userspace for this, didn't). v2: Minor rework of the doc (Rodrigo) Fixes: 72d4796 ("drm/xe/pxp/uapi: Add userspace and LRC support for PXP-using queues") Signed-off-by: Daniele Ceraolo Spurio <[email protected]> Cc: John Harrison <[email protected]> Cc: José Roberto de Souza <[email protected]> Reviewed-by: José Roberto de Souza <[email protected]> Reviewed-by: John Harrison <[email protected]> Acked-by: Rodrigo Vivi <[email protected]> Link: https://lore.kernel.org/r/[email protected] (cherry picked from commit 21784ca) Signed-off-by: Thomas Hellström <[email protected]>
1 parent 6bf4d56 commit 69a58ef

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

drivers/gpu/drm/xe/xe_pxp.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,10 +541,14 @@ int xe_pxp_exec_queue_add(struct xe_pxp *pxp, struct xe_exec_queue *q)
541541
*/
542542
xe_pm_runtime_get(pxp->xe);
543543

544-
if (!pxp_prerequisites_done(pxp)) {
545-
ret = -EBUSY;
544+
/* get_readiness_status() returns 0 for in-progress and 1 for done */
545+
ret = xe_pxp_get_readiness_status(pxp);
546+
if (ret <= 0) {
547+
if (!ret)
548+
ret = -EBUSY;
546549
goto out;
547550
}
551+
ret = 0;
548552

549553
wait_for_idle:
550554
/*

include/uapi/drm/xe_drm.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,11 @@ struct drm_xe_vm_bind {
12101210
* there is no need to explicitly set that. When a queue of type
12111211
* %DRM_XE_PXP_TYPE_HWDRM is created, the PXP default HWDRM session
12121212
* (%XE_PXP_HWDRM_DEFAULT_SESSION) will be started, if isn't already running.
1213+
* The user is expected to query the PXP status via the query ioctl (see
1214+
* %DRM_XE_DEVICE_QUERY_PXP_STATUS) and to wait for PXP to be ready before
1215+
* attempting to create a queue with this property. When a queue is created
1216+
* before PXP is ready, the ioctl will return -EBUSY if init is still in
1217+
* progress or -EIO if init failed.
12131218
* Given that going into a power-saving state kills PXP HWDRM sessions,
12141219
* runtime PM will be blocked while queues of this type are alive.
12151220
* All PXP queues will be killed if a PXP invalidation event occurs.

0 commit comments

Comments
 (0)