Commit 067ecab9 authored by Rob Clark's avatar Rob Clark

drm/msm: Restore error return on invalid fence

When converting to use an idr to map userspace fence seqno values back
to a dma_fence, we lost the error return when userspace passes seqno
that is larger than the last submitted fence.  Restore this check.
Reported-by: default avatarAkhil P Oommen <akhilpo@codeaurora.org>
Fixes: a61acbbe ("drm/msm: Track "seqno" fences by idr")
Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
Reviewed-by: default avatarAkhil P Oommen <akhilpo@codeaurora.org>
Link: https://lore.kernel.org/r/20211111192457.747899-3-robdclark@gmail.comSigned-off-by: default avatarRob Clark <robdclark@chromium.org>
parent ea0006d3
...@@ -973,6 +973,12 @@ static int wait_fence(struct msm_gpu_submitqueue *queue, uint32_t fence_id, ...@@ -973,6 +973,12 @@ static int wait_fence(struct msm_gpu_submitqueue *queue, uint32_t fence_id,
struct dma_fence *fence; struct dma_fence *fence;
int ret; int ret;
if (fence_id > queue->last_fence) {
DRM_ERROR_RATELIMITED("waiting on invalid fence: %u (of %u)\n",
fence_id, queue->last_fence);
return -EINVAL;
}
/* /*
* Map submitqueue scoped "seqno" (which is actually an idr key) * Map submitqueue scoped "seqno" (which is actually an idr key)
* back to underlying dma-fence * back to underlying dma-fence
......
...@@ -904,6 +904,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data, ...@@ -904,6 +904,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
drm_sched_entity_push_job(&submit->base); drm_sched_entity_push_job(&submit->base);
args->fence = submit->fence_id; args->fence = submit->fence_id;
queue->last_fence = submit->fence_id;
msm_reset_syncobjs(syncobjs_to_reset, args->nr_in_syncobjs); msm_reset_syncobjs(syncobjs_to_reset, args->nr_in_syncobjs);
msm_process_post_deps(post_deps, args->nr_out_syncobjs, msm_process_post_deps(post_deps, args->nr_out_syncobjs,
......
...@@ -359,6 +359,8 @@ static inline int msm_gpu_convert_priority(struct msm_gpu *gpu, int prio, ...@@ -359,6 +359,8 @@ static inline int msm_gpu_convert_priority(struct msm_gpu *gpu, int prio,
* @ring_nr: the ringbuffer used by this submitqueue, which is determined * @ring_nr: the ringbuffer used by this submitqueue, which is determined
* by the submitqueue's priority * by the submitqueue's priority
* @faults: the number of GPU hangs associated with this submitqueue * @faults: the number of GPU hangs associated with this submitqueue
* @last_fence: the sequence number of the last allocated fence (for error
* checking)
* @ctx: the per-drm_file context associated with the submitqueue (ie. * @ctx: the per-drm_file context associated with the submitqueue (ie.
* which set of pgtables do submits jobs associated with the * which set of pgtables do submits jobs associated with the
* submitqueue use) * submitqueue use)
...@@ -374,6 +376,7 @@ struct msm_gpu_submitqueue { ...@@ -374,6 +376,7 @@ struct msm_gpu_submitqueue {
u32 flags; u32 flags;
u32 ring_nr; u32 ring_nr;
int faults; int faults;
uint32_t last_fence;
struct msm_file_private *ctx; struct msm_file_private *ctx;
struct list_head node; struct list_head node;
struct idr fence_idr; struct idr fence_idr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment