drm/msm/a6xx: Add a flag to allow preemption to submitqueue_create
authorAntonino Maniscalco <antomani103@gmail.com>
Thu, 3 Oct 2024 16:12:59 +0000 (18:12 +0200)
committerRob Clark <robdclark@chromium.org>
Thu, 3 Oct 2024 20:21:52 +0000 (13:21 -0700)
Some userspace changes are necessary so add a flag for userspace to
advertise support for preemption when creating the submitqueue.

When this flag is not set preemption will not be allowed in the middle
of the submitted IBs therefore mantaining compatibility with older
userspace.

The flag is rejected if preemption is not supported on the target, this
allows userspace to know whether preemption is supported.

Tested-by: Rob Clark <robdclark@gmail.com>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8650-QRD
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-QRD
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8450-HDK
Signed-off-by: Antonino Maniscalco <antomani103@gmail.com>
Patchwork: https://patchwork.freedesktop.org/patch/618028/
Signed-off-by: Rob Clark <robdclark@chromium.org>
drivers/gpu/drm/msm/adreno/a6xx_gpu.c
drivers/gpu/drm/msm/msm_submitqueue.c
include/uapi/drm/msm_drm.h

index be306ae33c088ec7b9fc319b4cae14fd3edb946b..a0ef86987c5f79af1c84754cedbdddbb5e17e674 100644 (file)
@@ -352,8 +352,10 @@ static void a7xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)
        OUT_PKT7(ring, CP_SET_MARKER, 1);
        OUT_RING(ring, 0x101); /* IFPC disable */
 
-       OUT_PKT7(ring, CP_SET_MARKER, 1);
-       OUT_RING(ring, 0x00d); /* IB1LIST start */
+       if (submit->queue->flags & MSM_SUBMITQUEUE_ALLOW_PREEMPT) {
+               OUT_PKT7(ring, CP_SET_MARKER, 1);
+               OUT_RING(ring, 0x00d); /* IB1LIST start */
+       }
 
        /* Submit the commands */
        for (i = 0; i < submit->nr_cmds; i++) {
@@ -384,8 +386,10 @@ static void a7xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)
                        update_shadow_rptr(gpu, ring);
        }
 
-       OUT_PKT7(ring, CP_SET_MARKER, 1);
-       OUT_RING(ring, 0x00e); /* IB1LIST end */
+       if (submit->queue->flags & MSM_SUBMITQUEUE_ALLOW_PREEMPT) {
+               OUT_PKT7(ring, CP_SET_MARKER, 1);
+               OUT_RING(ring, 0x00e); /* IB1LIST end */
+       }
 
        get_stats_counter(ring, REG_A7XX_RBBM_PERFCTR_CP(0),
                rbmemptr_stats(ring, index, cpcycles_end));
index 0e803125a325aa67639406ef413aaeb6a9f08cee..9b3ffca3f3b471f509918edd4a2fdb0f80dfeb06 100644 (file)
@@ -170,6 +170,9 @@ int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx,
        if (!priv->gpu)
                return -ENODEV;
 
+       if (flags & MSM_SUBMITQUEUE_ALLOW_PREEMPT && priv->gpu->nr_rings == 1)
+               return -EINVAL;
+
        ret = msm_gpu_convert_priority(priv->gpu, prio, &ring_nr, &sched_prio);
        if (ret)
                return ret;
index 2377147b6af0b870b0e616af3ca969e0928b8962..b916aab80ddea954b95044a6c1dcb0b4a9a9a480 100644 (file)
@@ -347,7 +347,10 @@ struct drm_msm_gem_madvise {
  * backwards compatibility as a "default" submitqueue
  */
 
-#define MSM_SUBMITQUEUE_FLAGS (0)
+#define MSM_SUBMITQUEUE_ALLOW_PREEMPT  0x00000001
+#define MSM_SUBMITQUEUE_FLAGS              ( \
+               MSM_SUBMITQUEUE_ALLOW_PREEMPT | \
+               0)
 
 /*
  * The submitqueue priority should be between 0 and MSM_PARAM_PRIORITIES-1,