Skip to content

Commit b5a24e1

Browse files
committed
drm/msm: Add wait-boost support
Add a way for various userspace waits to signal urgency. Signed-off-by: Rob Clark <robdclark@chromium.org> Patchwork: https://patchwork.freedesktop.org/patch/525817/ Link: https://lore.kernel.org/r/20230308155322.344664-14-robdclark@gmail.com
1 parent f8b8487 commit b5a24e1

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

drivers/gpu/drm/msm/msm_drv.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
* - 1.8.0 - Add MSM_BO_CACHED_COHERENT for supported GPUs (a6xx)
4747
* - 1.9.0 - Add MSM_SUBMIT_FENCE_SN_IN
4848
* - 1.10.0 - Add MSM_SUBMIT_BO_NO_IMPLICIT
49+
* - 1.11.0 - Add wait boost (MSM_WAIT_FENCE_BOOST, MSM_PREP_BOOST)
4950
*/
5051
#define MSM_VERSION_MAJOR 1
5152
#define MSM_VERSION_MINOR 10
@@ -899,7 +900,7 @@ static int msm_ioctl_gem_info(struct drm_device *dev, void *data,
899900
}
900901

901902
static int wait_fence(struct msm_gpu_submitqueue *queue, uint32_t fence_id,
902-
ktime_t timeout)
903+
ktime_t timeout, uint32_t flags)
903904
{
904905
struct dma_fence *fence;
905906
int ret;
@@ -927,6 +928,9 @@ static int wait_fence(struct msm_gpu_submitqueue *queue, uint32_t fence_id,
927928
if (!fence)
928929
return 0;
929930

931+
if (flags & MSM_WAIT_FENCE_BOOST)
932+
dma_fence_set_deadline(fence, ktime_get());
933+
930934
ret = dma_fence_wait_timeout(fence, true, timeout_to_jiffies(&timeout));
931935
if (ret == 0) {
932936
ret = -ETIMEDOUT;
@@ -947,8 +951,8 @@ static int msm_ioctl_wait_fence(struct drm_device *dev, void *data,
947951
struct msm_gpu_submitqueue *queue;
948952
int ret;
949953

950-
if (args->pad) {
951-
DRM_ERROR("invalid pad: %08x\n", args->pad);
954+
if (args->flags & ~MSM_WAIT_FENCE_FLAGS) {
955+
DRM_ERROR("invalid flags: %08x\n", args->flags);
952956
return -EINVAL;
953957
}
954958

@@ -959,7 +963,7 @@ static int msm_ioctl_wait_fence(struct drm_device *dev, void *data,
959963
if (!queue)
960964
return -ENOENT;
961965

962-
ret = wait_fence(queue, args->fence, to_ktime(args->timeout));
966+
ret = wait_fence(queue, args->fence, to_ktime(args->timeout), args->flags);
963967

964968
msm_submitqueue_put(queue);
965969

drivers/gpu/drm/msm/msm_gem.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,11 @@ int msm_gem_cpu_prep(struct drm_gem_object *obj, uint32_t op, ktime_t *timeout)
895895
op & MSM_PREP_NOSYNC ? 0 : timeout_to_jiffies(timeout);
896896
long ret;
897897

898+
if (op & MSM_PREP_BOOST) {
899+
dma_resv_set_deadline(obj->resv, dma_resv_usage_rw(write),
900+
ktime_get());
901+
}
902+
898903
ret = dma_resv_wait_timeout(obj->resv, dma_resv_usage_rw(write),
899904
true, remain);
900905
if (ret == 0)

include/uapi/drm/msm_drm.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,13 @@ struct drm_msm_gem_info {
151151
#define MSM_PREP_READ 0x01
152152
#define MSM_PREP_WRITE 0x02
153153
#define MSM_PREP_NOSYNC 0x04
154+
#define MSM_PREP_BOOST 0x08
154155

155-
#define MSM_PREP_FLAGS (MSM_PREP_READ | MSM_PREP_WRITE | MSM_PREP_NOSYNC)
156+
#define MSM_PREP_FLAGS (MSM_PREP_READ | \
157+
MSM_PREP_WRITE | \
158+
MSM_PREP_NOSYNC | \
159+
MSM_PREP_BOOST | \
160+
0)
156161

157162
struct drm_msm_gem_cpu_prep {
158163
__u32 handle; /* in */
@@ -286,6 +291,11 @@ struct drm_msm_gem_submit {
286291

287292
};
288293

294+
#define MSM_WAIT_FENCE_BOOST 0x00000001
295+
#define MSM_WAIT_FENCE_FLAGS ( \
296+
MSM_WAIT_FENCE_BOOST | \
297+
0)
298+
289299
/* The normal way to synchronize with the GPU is just to CPU_PREP on
290300
* a buffer if you need to access it from the CPU (other cmdstream
291301
* submission from same or other contexts, PAGE_FLIP ioctl, etc, all
@@ -295,7 +305,7 @@ struct drm_msm_gem_submit {
295305
*/
296306
struct drm_msm_wait_fence {
297307
__u32 fence; /* in */
298-
__u32 pad;
308+
__u32 flags; /* in, bitmask of MSM_WAIT_FENCE_x */
299309
struct drm_msm_timespec timeout; /* in */
300310
__u32 queueid; /* in, submitqueue id */
301311
};

0 commit comments

Comments
 (0)