aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amdfalconx86/recipes-kernel/linux/linux-yocto/0431-drm-amdgpu-cleanup-ctx_mgr-init-fini.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-amdfalconx86/recipes-kernel/linux/linux-yocto/0431-drm-amdgpu-cleanup-ctx_mgr-init-fini.patch')
-rw-r--r--meta-amdfalconx86/recipes-kernel/linux/linux-yocto/0431-drm-amdgpu-cleanup-ctx_mgr-init-fini.patch122
1 files changed, 122 insertions, 0 deletions
diff --git a/meta-amdfalconx86/recipes-kernel/linux/linux-yocto/0431-drm-amdgpu-cleanup-ctx_mgr-init-fini.patch b/meta-amdfalconx86/recipes-kernel/linux/linux-yocto/0431-drm-amdgpu-cleanup-ctx_mgr-init-fini.patch
new file mode 100644
index 00000000..237bbcbc
--- /dev/null
+++ b/meta-amdfalconx86/recipes-kernel/linux/linux-yocto/0431-drm-amdgpu-cleanup-ctx_mgr-init-fini.patch
@@ -0,0 +1,122 @@
+From efd4ccb59a4acb8b85835d6b053362dbacee40f9 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Christian=20K=C3=B6nig?= <christian.koenig@amd.com>
+Date: Tue, 4 Aug 2015 16:20:31 +0200
+Subject: [PATCH 0431/1050] drm/amdgpu: cleanup ctx_mgr init/fini
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: Christian König <christian.koenig@amd.com>
+Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
+---
+ drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 ++--
+ drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 40 +++++++++++++++++++--------------
+ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 8 ++-----
+ 3 files changed, 27 insertions(+), 25 deletions(-)
+
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+index eadbe79..0cd776a 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+@@ -1038,8 +1038,6 @@ int amdgpu_ctx_alloc(struct amdgpu_device *adev, struct amdgpu_fpriv *fpriv,
+ int amdgpu_ctx_free(struct amdgpu_device *adev, struct amdgpu_fpriv *fpriv,
+ uint32_t id);
+
+-void amdgpu_ctx_fini(struct amdgpu_fpriv *fpriv);
+-
+ struct amdgpu_ctx *amdgpu_ctx_get(struct amdgpu_fpriv *fpriv, uint32_t id);
+ int amdgpu_ctx_put(struct amdgpu_ctx *ctx);
+
+@@ -1051,6 +1049,8 @@ struct fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx,
+ int amdgpu_ctx_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *filp);
+
++void amdgpu_ctx_mgr_init(struct amdgpu_ctx_mgr *mgr);
++void amdgpu_ctx_mgr_fini(struct amdgpu_ctx_mgr *mgr);
+
+ /*
+ * file private structure
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
+index 6766ead..3c353375b 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
+@@ -182,23 +182,6 @@ static int amdgpu_ctx_query(struct amdgpu_device *adev,
+ return 0;
+ }
+
+-void amdgpu_ctx_fini(struct amdgpu_fpriv *fpriv)
+-{
+- struct idr *idp;
+- struct amdgpu_ctx *ctx;
+- uint32_t id;
+- struct amdgpu_ctx_mgr *mgr = &fpriv->ctx_mgr;
+- idp = &mgr->ctx_handles;
+-
+- idr_for_each_entry(idp,ctx,id) {
+- if (kref_put(&ctx->refcount, amdgpu_ctx_do_release) != 1)
+- DRM_ERROR("ctx %p is still alive\n", ctx);
+- }
+-
+- idr_destroy(&mgr->ctx_handles);
+- mutex_destroy(&mgr->lock);
+-}
+-
+ int amdgpu_ctx_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *filp)
+ {
+@@ -330,3 +313,26 @@ struct fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx,
+
+ return fence;
+ }
++
++void amdgpu_ctx_mgr_init(struct amdgpu_ctx_mgr *mgr)
++{
++ mutex_init(&mgr->lock);
++ idr_init(&mgr->ctx_handles);
++}
++
++void amdgpu_ctx_mgr_fini(struct amdgpu_ctx_mgr *mgr)
++{
++ struct amdgpu_ctx *ctx;
++ struct idr *idp;
++ uint32_t id;
++
++ idp = &mgr->ctx_handles;
++
++ idr_for_each_entry(idp, ctx, id) {
++ if (kref_put(&ctx->refcount, amdgpu_ctx_do_release) != 1)
++ DRM_ERROR("ctx %p is still alive\n", ctx);
++ }
++
++ idr_destroy(&mgr->ctx_handles);
++ mutex_destroy(&mgr->lock);
++}
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+index 53da3d8..7226def 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+@@ -527,10 +527,7 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
+ mutex_init(&fpriv->bo_list_lock);
+ idr_init(&fpriv->bo_list_handles);
+
+- /* init context manager */
+- mutex_init(&fpriv->ctx_mgr.lock);
+- idr_init(&fpriv->ctx_mgr.ctx_handles);
+- fpriv->ctx_mgr.adev = adev;
++ amdgpu_ctx_mgr_init(&fpriv->ctx_mgr);
+
+ file_priv->driver_priv = fpriv;
+
+@@ -571,8 +568,7 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
+ idr_destroy(&fpriv->bo_list_handles);
+ mutex_destroy(&fpriv->bo_list_lock);
+
+- /* release context */
+- amdgpu_ctx_fini(fpriv);
++ amdgpu_ctx_mgr_fini(&fpriv->ctx_mgr);
+
+ kfree(fpriv);
+ file_priv->driver_priv = NULL;
+--
+1.9.1
+