drm/xe/pxp: Clarify PXP queue creation behavior if PXP is not ready

JIRA: https://issues.redhat.com/browse/RHEL-75952

commit a2fd22f51aad28c8dd1aee0d9ad6871f85131b29
Author: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Date:   Thu May 22 15:54:04 2025 -0700

    drm/xe/pxp: Clarify PXP queue creation behavior if PXP is not ready

    [ Upstream commit 69a58ef4fa77759b0e0c2f79834fa51b00a50c0b ]

    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: 72d479601d67 ("drm/xe/pxp/uapi: Add userspace and LRC support for PXP-using queues")
    Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
    Cc: John Harrison <John.C.Harrison@Intel.com>
    Cc: José Roberto de Souza <jose.souza@intel.com>
    Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
    Reviewed-by: John Harrison <John.C.Harrison@Intel.com>
    Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Link: https://lore.kernel.org/r/20250522225401.3953243-7-daniele.ceraolospurio@intel.com
    (cherry picked from commit 21784ca96025b62d95b670b7639ad70ddafa69b8)
    Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

Signed-off-by: Robert Foss <rfoss@redhat.com>
This commit is contained in:
Robert Foss 2025-07-08 16:20:43 +02:00
parent e7bed7ab09
commit 234edb6f28
No known key found for this signature in database
GPG Key ID: 3EFD900F76D1D784
2 changed files with 11 additions and 2 deletions

View File

@ -541,10 +541,14 @@ int xe_pxp_exec_queue_add(struct xe_pxp *pxp, struct xe_exec_queue *q)
*/ */
xe_pm_runtime_get(pxp->xe); xe_pm_runtime_get(pxp->xe);
if (!pxp_prerequisites_done(pxp)) { /* get_readiness_status() returns 0 for in-progress and 1 for done */
ret = -EBUSY; ret = xe_pxp_get_readiness_status(pxp);
if (ret <= 0) {
if (!ret)
ret = -EBUSY;
goto out; goto out;
} }
ret = 0;
wait_for_idle: wait_for_idle:
/* /*

View File

@ -1206,6 +1206,11 @@ struct drm_xe_vm_bind {
* there is no need to explicitly set that. When a queue of type * there is no need to explicitly set that. When a queue of type
* %DRM_XE_PXP_TYPE_HWDRM is created, the PXP default HWDRM session * %DRM_XE_PXP_TYPE_HWDRM is created, the PXP default HWDRM session
* (%XE_PXP_HWDRM_DEFAULT_SESSION) will be started, if isn't already running. * (%XE_PXP_HWDRM_DEFAULT_SESSION) will be started, if isn't already running.
* The user is expected to query the PXP status via the query ioctl (see
* %DRM_XE_DEVICE_QUERY_PXP_STATUS) and to wait for PXP to be ready before
* attempting to create a queue with this property. When a queue is created
* before PXP is ready, the ioctl will return -EBUSY if init is still in
* progress or -EIO if init failed.
* Given that going into a power-saving state kills PXP HWDRM sessions, * Given that going into a power-saving state kills PXP HWDRM sessions,
* runtime PM will be blocked while queues of this type are alive. * runtime PM will be blocked while queues of this type are alive.
* All PXP queues will be killed if a PXP invalidation event occurs. * All PXP queues will be killed if a PXP invalidation event occurs.