diff options
Diffstat (limited to 'meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/0797-drm-amdgpu-SEM-some-modification-on-SEM-logic.patch')
-rw-r--r-- | meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/0797-drm-amdgpu-SEM-some-modification-on-SEM-logic.patch | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/0797-drm-amdgpu-SEM-some-modification-on-SEM-logic.patch b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/0797-drm-amdgpu-SEM-some-modification-on-SEM-logic.patch new file mode 100644 index 00000000..49cac13b --- /dev/null +++ b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/0797-drm-amdgpu-SEM-some-modification-on-SEM-logic.patch @@ -0,0 +1,113 @@ +From da6b156014ba0303d1be6ad93180d0bbb3f64dac Mon Sep 17 00:00:00 2001 +From: Monk Liu <Monk.Liu@amd.com> +Date: Tue, 11 Apr 2017 17:11:39 +0800 +Subject: [PATCH 0797/4131] drm/amdgpu/SEM:some modification on SEM logic + +1):Cannot del list on sem->list in sem_free + +because you don't have this operation go under the protection +of sem_lock + +no reason to del list in sem_free, sem_add_cs will do it, and +even cs_ioctl is never called after sem_wait, it doesn't harm to +leave this list in there. + +2):In sem_wait, should get the kref of sem otherwise a sem_desctory +followed by will kill the sem and make all reference to sem invalid +pointer. + +should also put the sem in sem_add_cs() to balance the kref. +And should also put the sem in ctx_do_release to balance the kref +of those sem which only do the sem_wait but without cs_submit following. + +Change-Id: If3a5ac4757b8acb716cad57ceb60d96d0ff108e0 +Signed-off-by: Monk Liu <Monk.Liu@amd.com> +Reviewed-by: Chunming Zhou <david1.zhou@amd.com> + + Conflicts: + drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 17 +++++++++++++---- + drivers/gpu/drm/amd/amdgpu/amdgpu_sem.c | 5 +++-- + drivers/gpu/drm/amd/amdgpu/amdgpu_sem.h | 1 + + 3 files changed, 17 insertions(+), 6 deletions(-) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +index 6a2a1ce..0f84e4d 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +@@ -87,11 +87,20 @@ static void amdgpu_ctx_fini(struct amdgpu_ctx *ctx) + if (!adev) + return; + +- for (i = 0; i < AMDGPU_MAX_RINGS; ++i) +- for (j = 0; j < amdgpu_sched_jobs; ++j) { ++ for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { ++ struct amdgpu_sem *sem, *tmp; ++ ++ mutex_lock(&ctx->rings[i].sem_lock); ++ /* release all the reset inserted SEM here */ ++ list_for_each_entry_safe(sem, tmp, &ctx->rings[i].sem_list, list) ++ amdgpu_sem_put(sem); ++ ++ mutex_unlock(&ctx->rings[i].sem_lock); ++ mutex_destroy(&ctx->rings[i].sem_lock); ++ ++ for (j = 0; j < amdgpu_sched_jobs; ++j) + dma_fence_put(ctx->rings[i].fences[j]); +- mutex_destroy(&ctx->rings[i].sem_lock); +- } ++ } + kfree(ctx->fences); + ctx->fences = NULL; + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sem.c +index 6d60e7b..fab6164 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sem.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sem.c +@@ -55,7 +55,6 @@ static void amdgpu_sem_free(struct kref *kref) + struct amdgpu_sem *sem = container_of( + kref, struct amdgpu_sem, kref); + +- list_del(&sem->list); + kref_put(&sem->base->kref, amdgpu_sem_core_free); + kfree(sem); + } +@@ -66,7 +65,7 @@ static inline void amdgpu_sem_get(struct amdgpu_sem *sem) + kref_get(&sem->kref); + } + +-static inline void amdgpu_sem_put(struct amdgpu_sem *sem) ++void amdgpu_sem_put(struct amdgpu_sem *sem) + { + if (sem) + kref_put(&sem->kref, amdgpu_sem_free); +@@ -375,6 +374,7 @@ static int amdgpu_sem_cring_add(struct amdgpu_fpriv *fpriv, + mutex_lock(&ctx->rings[out_ring->idx].sem_lock); + list_add(&sem->list, &ctx->rings[out_ring->idx].sem_list); + mutex_unlock(&ctx->rings[out_ring->idx].sem_lock); ++ amdgpu_sem_get(sem); + + err: + amdgpu_ctx_put(ctx); +@@ -401,6 +401,7 @@ int amdgpu_sem_add_cs(struct amdgpu_ctx *ctx, struct amdgpu_ring *ring, + sem->base->fence = NULL; + mutex_unlock(&sem->base->lock); + list_del_init(&sem->list); ++ amdgpu_sem_put(sem); + } + err: + mutex_unlock(&ctx->rings[ring->idx].sem_lock); +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sem.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_sem.h +index 40854ff..6a62729 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sem.h ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sem.h +@@ -47,4 +47,5 @@ struct amdgpu_sem { + struct list_head list; + }; + ++void amdgpu_sem_put(struct amdgpu_sem *sem); + #endif /* _LINUX_AMDGPU_SEM_H */ +-- +2.7.4 + |