mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 19:08:57 +09:00
drm/msm: Switch idr_lock to spinlock
[ Upstream commite4f020c6a0] Needed to idr_preload() which returns with preemption disabled. Signed-off-by: Rob Clark <robdclark@chromium.org> Patchwork: https://patchwork.freedesktop.org/patch/527846/ Link: https://lore.kernel.org/r/20230320144356.803762-11-robdclark@gmail.com Stable-dep-of:1b5d0ddcb3("drm/msm: Disallow submit with fence id 0") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
d722661362
commit
3398e8b283
@@ -932,13 +932,11 @@ static int wait_fence(struct msm_gpu_submitqueue *queue, uint32_t fence_id,
|
|||||||
* retired, so if the fence is not found it means there is nothing
|
* retired, so if the fence is not found it means there is nothing
|
||||||
* to wait for
|
* to wait for
|
||||||
*/
|
*/
|
||||||
ret = mutex_lock_interruptible(&queue->idr_lock);
|
spin_lock(&queue->idr_lock);
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
fence = idr_find(&queue->fence_idr, fence_id);
|
fence = idr_find(&queue->fence_idr, fence_id);
|
||||||
if (fence)
|
if (fence)
|
||||||
fence = dma_fence_get_rcu(fence);
|
fence = dma_fence_get_rcu(fence);
|
||||||
mutex_unlock(&queue->idr_lock);
|
spin_unlock(&queue->idr_lock);
|
||||||
|
|
||||||
if (!fence)
|
if (!fence)
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -72,9 +72,9 @@ void __msm_gem_submit_destroy(struct kref *kref)
|
|||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
if (submit->fence_id) {
|
if (submit->fence_id) {
|
||||||
mutex_lock(&submit->queue->idr_lock);
|
spin_lock(&submit->queue->idr_lock);
|
||||||
idr_remove(&submit->queue->fence_idr, submit->fence_id);
|
idr_remove(&submit->queue->fence_idr, submit->fence_id);
|
||||||
mutex_unlock(&submit->queue->idr_lock);
|
spin_unlock(&submit->queue->idr_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
dma_fence_put(submit->user_fence);
|
dma_fence_put(submit->user_fence);
|
||||||
@@ -866,7 +866,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
|
|||||||
|
|
||||||
submit->nr_cmds = i;
|
submit->nr_cmds = i;
|
||||||
|
|
||||||
mutex_lock(&queue->idr_lock);
|
spin_lock(&queue->idr_lock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If using userspace provided seqno fence, validate that the id
|
* If using userspace provided seqno fence, validate that the id
|
||||||
@@ -876,7 +876,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
|
|||||||
*/
|
*/
|
||||||
if ((args->flags & MSM_SUBMIT_FENCE_SN_IN) &&
|
if ((args->flags & MSM_SUBMIT_FENCE_SN_IN) &&
|
||||||
idr_find(&queue->fence_idr, args->fence)) {
|
idr_find(&queue->fence_idr, args->fence)) {
|
||||||
mutex_unlock(&queue->idr_lock);
|
spin_unlock(&queue->idr_lock);
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@@ -910,7 +910,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
|
|||||||
INT_MAX, GFP_KERNEL);
|
INT_MAX, GFP_KERNEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&queue->idr_lock);
|
spin_unlock(&queue->idr_lock);
|
||||||
|
|
||||||
if (submit->fence_id < 0) {
|
if (submit->fence_id < 0) {
|
||||||
ret = submit->fence_id;
|
ret = submit->fence_id;
|
||||||
|
|||||||
@@ -500,7 +500,7 @@ struct msm_gpu_submitqueue {
|
|||||||
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;
|
||||||
struct mutex idr_lock;
|
struct spinlock idr_lock;
|
||||||
struct mutex lock;
|
struct mutex lock;
|
||||||
struct kref ref;
|
struct kref ref;
|
||||||
struct drm_sched_entity *entity;
|
struct drm_sched_entity *entity;
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx,
|
|||||||
*id = queue->id;
|
*id = queue->id;
|
||||||
|
|
||||||
idr_init(&queue->fence_idr);
|
idr_init(&queue->fence_idr);
|
||||||
mutex_init(&queue->idr_lock);
|
spin_lock_init(&queue->idr_lock);
|
||||||
mutex_init(&queue->lock);
|
mutex_init(&queue->lock);
|
||||||
|
|
||||||
list_add_tail(&queue->node, &ctx->submitqueues);
|
list_add_tail(&queue->node, &ctx->submitqueues);
|
||||||
|
|||||||
Reference in New Issue
Block a user