diff options
author | Christian König <christian.koenig@amd.com> | 2015-08-04 10:20:31 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2015-08-17 16:51:00 -0400 |
commit | efd4ccb59a4acb8b85835d6b053362dbacee40f9 (patch) | |
tree | 6718cb4d186aa13c1daf45ec3afa8ae0154cc75e | |
parent | 34cb581a7d99401cad0e1c43b528690885435f5b (diff) |
drm/amdgpu: cleanup ctx_mgr init/fini
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 40 | ||||
-rw-r--r-- | 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 eadbe792c8aa..0cd776a55f05 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, | |||
1038 | int amdgpu_ctx_free(struct amdgpu_device *adev, struct amdgpu_fpriv *fpriv, | 1038 | int amdgpu_ctx_free(struct amdgpu_device *adev, struct amdgpu_fpriv *fpriv, |
1039 | uint32_t id); | 1039 | uint32_t id); |
1040 | 1040 | ||
1041 | void amdgpu_ctx_fini(struct amdgpu_fpriv *fpriv); | ||
1042 | |||
1043 | struct amdgpu_ctx *amdgpu_ctx_get(struct amdgpu_fpriv *fpriv, uint32_t id); | 1041 | struct amdgpu_ctx *amdgpu_ctx_get(struct amdgpu_fpriv *fpriv, uint32_t id); |
1044 | int amdgpu_ctx_put(struct amdgpu_ctx *ctx); | 1042 | int amdgpu_ctx_put(struct amdgpu_ctx *ctx); |
1045 | 1043 | ||
@@ -1051,6 +1049,8 @@ struct fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx, | |||
1051 | int amdgpu_ctx_ioctl(struct drm_device *dev, void *data, | 1049 | int amdgpu_ctx_ioctl(struct drm_device *dev, void *data, |
1052 | struct drm_file *filp); | 1050 | struct drm_file *filp); |
1053 | 1051 | ||
1052 | void amdgpu_ctx_mgr_init(struct amdgpu_ctx_mgr *mgr); | ||
1053 | void amdgpu_ctx_mgr_fini(struct amdgpu_ctx_mgr *mgr); | ||
1054 | 1054 | ||
1055 | /* | 1055 | /* |
1056 | * file private structure | 1056 | * file private structure |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c index 6766ead31c4d..3c353375b228 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, | |||
182 | return 0; | 182 | return 0; |
183 | } | 183 | } |
184 | 184 | ||
185 | void amdgpu_ctx_fini(struct amdgpu_fpriv *fpriv) | ||
186 | { | ||
187 | struct idr *idp; | ||
188 | struct amdgpu_ctx *ctx; | ||
189 | uint32_t id; | ||
190 | struct amdgpu_ctx_mgr *mgr = &fpriv->ctx_mgr; | ||
191 | idp = &mgr->ctx_handles; | ||
192 | |||
193 | idr_for_each_entry(idp,ctx,id) { | ||
194 | if (kref_put(&ctx->refcount, amdgpu_ctx_do_release) != 1) | ||
195 | DRM_ERROR("ctx %p is still alive\n", ctx); | ||
196 | } | ||
197 | |||
198 | idr_destroy(&mgr->ctx_handles); | ||
199 | mutex_destroy(&mgr->lock); | ||
200 | } | ||
201 | |||
202 | int amdgpu_ctx_ioctl(struct drm_device *dev, void *data, | 185 | int amdgpu_ctx_ioctl(struct drm_device *dev, void *data, |
203 | struct drm_file *filp) | 186 | struct drm_file *filp) |
204 | { | 187 | { |
@@ -330,3 +313,26 @@ struct fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx, | |||
330 | 313 | ||
331 | return fence; | 314 | return fence; |
332 | } | 315 | } |
316 | |||
317 | void amdgpu_ctx_mgr_init(struct amdgpu_ctx_mgr *mgr) | ||
318 | { | ||
319 | mutex_init(&mgr->lock); | ||
320 | idr_init(&mgr->ctx_handles); | ||
321 | } | ||
322 | |||
323 | void amdgpu_ctx_mgr_fini(struct amdgpu_ctx_mgr *mgr) | ||
324 | { | ||
325 | struct amdgpu_ctx *ctx; | ||
326 | struct idr *idp; | ||
327 | uint32_t id; | ||
328 | |||
329 | idp = &mgr->ctx_handles; | ||
330 | |||
331 | idr_for_each_entry(idp, ctx, id) { | ||
332 | if (kref_put(&ctx->refcount, amdgpu_ctx_do_release) != 1) | ||
333 | DRM_ERROR("ctx %p is still alive\n", ctx); | ||
334 | } | ||
335 | |||
336 | idr_destroy(&mgr->ctx_handles); | ||
337 | mutex_destroy(&mgr->lock); | ||
338 | } | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c index 53da3d8a868c..7226def4e8fb 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) | |||
527 | mutex_init(&fpriv->bo_list_lock); | 527 | mutex_init(&fpriv->bo_list_lock); |
528 | idr_init(&fpriv->bo_list_handles); | 528 | idr_init(&fpriv->bo_list_handles); |
529 | 529 | ||
530 | /* init context manager */ | 530 | amdgpu_ctx_mgr_init(&fpriv->ctx_mgr); |
531 | mutex_init(&fpriv->ctx_mgr.lock); | ||
532 | idr_init(&fpriv->ctx_mgr.ctx_handles); | ||
533 | fpriv->ctx_mgr.adev = adev; | ||
534 | 531 | ||
535 | file_priv->driver_priv = fpriv; | 532 | file_priv->driver_priv = fpriv; |
536 | 533 | ||
@@ -571,8 +568,7 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev, | |||
571 | idr_destroy(&fpriv->bo_list_handles); | 568 | idr_destroy(&fpriv->bo_list_handles); |
572 | mutex_destroy(&fpriv->bo_list_lock); | 569 | mutex_destroy(&fpriv->bo_list_lock); |
573 | 570 | ||
574 | /* release context */ | 571 | amdgpu_ctx_mgr_fini(&fpriv->ctx_mgr); |
575 | amdgpu_ctx_fini(fpriv); | ||
576 | 572 | ||
577 | kfree(fpriv); | 573 | kfree(fpriv); |
578 | file_priv->driver_priv = NULL; | 574 | file_priv->driver_priv = NULL; |