aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorAndrey Grodzovsky <andrey.grodzovsky@amd.com>2018-05-30 15:28:52 -0400
committerAlex Deucher <alexander.deucher@amd.com>2018-06-15 13:20:33 -0400
commit48ad368a8a3ab2fd3c2bc2ccccc6e29b1acda1bb (patch)
treeff89a29b752a9a06c7003f8ccd93cc82debf8e8f /drivers/gpu
parent741f01e636b72ff3f81204fd595ac1078907671b (diff)
drm/amdgpu: move amdgpu_ctx_mgr_entity_fini to f_ops flush hook (V4)
With this we can now terminate jobs enqueue into SW queue the moment the task is being killed instead of waiting for last user of drm file to release it. Also stop checking for kref_read(&ctx->refcount) == 1 when calling drm_sched_entity_do_release since other task might still hold a reference to this entity but we don't care since KILL means terminate job submission regardless of what other tasks are doing. v2: Use returned remaining timeout as parameter for the next call. Rebase. v3: Switch to working with jiffies. Streamline remainder TO usage. Rebase. v4: Rebase. Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c14
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c12
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c1
3 files changed, 20 insertions, 7 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
index c5bb36275e93..64b3a1ed04dc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
@@ -449,26 +449,28 @@ void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr)
449 struct amdgpu_ctx *ctx; 449 struct amdgpu_ctx *ctx;
450 struct idr *idp; 450 struct idr *idp;
451 uint32_t id, i; 451 uint32_t id, i;
452 long max_wait = MAX_WAIT_SCHED_ENTITY_Q_EMPTY;
452 453
453 idp = &mgr->ctx_handles; 454 idp = &mgr->ctx_handles;
454 455
456 mutex_lock(&mgr->lock);
455 idr_for_each_entry(idp, ctx, id) { 457 idr_for_each_entry(idp, ctx, id) {
456 458
457 if (!ctx->adev) 459 if (!ctx->adev) {
460 mutex_unlock(&mgr->lock);
458 return; 461 return;
462 }
459 463
460 for (i = 0; i < ctx->adev->num_rings; i++) { 464 for (i = 0; i < ctx->adev->num_rings; i++) {
461 465
462 if (ctx->adev->rings[i] == &ctx->adev->gfx.kiq.ring) 466 if (ctx->adev->rings[i] == &ctx->adev->gfx.kiq.ring)
463 continue; 467 continue;
464 468
465 if (kref_read(&ctx->refcount) == 1) 469 max_wait = drm_sched_entity_do_release(&ctx->adev->rings[i]->sched,
466 drm_sched_entity_do_release(&ctx->adev->rings[i]->sched, 470 &ctx->rings[i].entity, max_wait);
467 &ctx->rings[i].entity);
468 else
469 DRM_ERROR("ctx %p is still alive\n", ctx);
470 } 471 }
471 } 472 }
473 mutex_unlock(&mgr->lock);
472} 474}
473 475
474void amdgpu_ctx_mgr_entity_cleanup(struct amdgpu_ctx_mgr *mgr) 476void amdgpu_ctx_mgr_entity_cleanup(struct amdgpu_ctx_mgr *mgr)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index b0bf2f24da48..a549483032b0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -855,9 +855,21 @@ static const struct dev_pm_ops amdgpu_pm_ops = {
855 .runtime_idle = amdgpu_pmops_runtime_idle, 855 .runtime_idle = amdgpu_pmops_runtime_idle,
856}; 856};
857 857
858static int amdgpu_flush(struct file *f, fl_owner_t id)
859{
860 struct drm_file *file_priv = f->private_data;
861 struct amdgpu_fpriv *fpriv = file_priv->driver_priv;
862
863 amdgpu_ctx_mgr_entity_fini(&fpriv->ctx_mgr);
864
865 return 0;
866}
867
868
858static const struct file_operations amdgpu_driver_kms_fops = { 869static const struct file_operations amdgpu_driver_kms_fops = {
859 .owner = THIS_MODULE, 870 .owner = THIS_MODULE,
860 .open = drm_open, 871 .open = drm_open,
872 .flush = amdgpu_flush,
861 .release = drm_release, 873 .release = drm_release,
862 .unlocked_ioctl = amdgpu_drm_ioctl, 874 .unlocked_ioctl = amdgpu_drm_ioctl,
863 .mmap = amdgpu_mmap, 875 .mmap = amdgpu_mmap,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 91517b166a3b..c472bb53e41d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -930,7 +930,6 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
930 return; 930 return;
931 931
932 pm_runtime_get_sync(dev->dev); 932 pm_runtime_get_sync(dev->dev);
933 amdgpu_ctx_mgr_entity_fini(&fpriv->ctx_mgr);
934 933
935 if (adev->asic_type != CHIP_RAVEN) { 934 if (adev->asic_type != CHIP_RAVEN) {
936 amdgpu_uvd_free_handles(adev, file_priv); 935 amdgpu_uvd_free_handles(adev, file_priv);