All of lore.kernel.org
 help / color / mirror / Atom feed
From: "S, Shirish" <Shirish.S-5C7GfCeVMHo@public.gmane.org>
To: "Deucher,
	Alexander" <Alexander.Deucher-5C7GfCeVMHo@public.gmane.org>,
	"Koenig,
	Christian" <Christian.Koenig-5C7GfCeVMHo@public.gmane.org>,
	"Grodzovsky,
	Andrey" <Andrey.Grodzovsky-5C7GfCeVMHo@public.gmane.org>
Cc: "amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org"
	<amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>,
	"S, Shirish" <Shirish.S-5C7GfCeVMHo@public.gmane.org>
Subject: [PATCH] drm/amdgpu: guard ib scheduling while in reset
Date: Thu, 24 Oct 2019 10:58:21 +0000	[thread overview]
Message-ID: <1571914692-9430-1-git-send-email-shirish.s@amd.com> (raw)

[Why]
Upon GPU reset, kernel cleans up already submitted jobs
via drm_sched_cleanup_jobs.
This schedules ib's via drm_sched_main()->run_job, leading to
race condition of rings being ready or not, since during reset
rings may be suspended.

[How]
make GPU reset's amdgpu_device_ip_resume_phase2() &
amdgpu_ib_schedule() in amdgpu_job_run() mutually exclusive.

Signed-off-by: Shirish S <shirish.s@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c    | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index f4d9041..7b07a47b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -973,6 +973,7 @@ struct amdgpu_device {
 	bool                            in_gpu_reset;
 	enum pp_mp1_state               mp1_state;
 	struct mutex  lock_reset;
+	struct mutex  lock_ib_sched;
 	struct amdgpu_doorbell_index doorbell_index;
 
 	int asic_reset_res;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 676cad1..63cad74 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2759,6 +2759,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	mutex_init(&adev->virt.vf_errors.lock);
 	hash_init(adev->mn_hash);
 	mutex_init(&adev->lock_reset);
+	mutex_init(&adev->lock_ib_sched);
 	mutex_init(&adev->virt.dpm_mutex);
 	mutex_init(&adev->psp.mutex);
 
@@ -3795,7 +3796,9 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,
 				if (r)
 					return r;
 
+				mutex_lock(&tmp_adev->lock_ib_sched);
 				r = amdgpu_device_ip_resume_phase2(tmp_adev);
+				mutex_unlock(&tmp_adev->lock_ib_sched);
 				if (r)
 					goto out;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
index e1bad99..cd6082d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
@@ -233,8 +233,10 @@ static struct dma_fence *amdgpu_job_run(struct drm_sched_job *sched_job)
 	if (finished->error < 0) {
 		DRM_INFO("Skip scheduling IBs!\n");
 	} else {
+		mutex_lock(&ring->adev->lock_ib_sched);
 		r = amdgpu_ib_schedule(ring, job->num_ibs, job->ibs, job,
 				       &fence);
+		mutex_unlock(&ring->adev->lock_ib_sched);
 		if (r)
 			DRM_ERROR("Error scheduling IBs (%d)\n", r);
 	}
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

WARNING: multiple messages have this Message-ID (diff)
From: "S, Shirish" <Shirish.S@amd.com>
To: "Deucher, Alexander" <Alexander.Deucher@amd.com>,
	"Koenig, Christian" <Christian.Koenig@amd.com>,
	"Grodzovsky, Andrey" <Andrey.Grodzovsky@amd.com>
Cc: "amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>,
	"S, Shirish" <Shirish.S@amd.com>
Subject: [PATCH] drm/amdgpu: guard ib scheduling while in reset
Date: Thu, 24 Oct 2019 10:58:21 +0000	[thread overview]
Message-ID: <1571914692-9430-1-git-send-email-shirish.s@amd.com> (raw)
Message-ID: <20191024105821.tHl2XfaEN3wI3q3f3zuaCFnVBMhPUDIRwJFRkwMZI-s@z> (raw)

[Why]
Upon GPU reset, kernel cleans up already submitted jobs
via drm_sched_cleanup_jobs.
This schedules ib's via drm_sched_main()->run_job, leading to
race condition of rings being ready or not, since during reset
rings may be suspended.

[How]
make GPU reset's amdgpu_device_ip_resume_phase2() &
amdgpu_ib_schedule() in amdgpu_job_run() mutually exclusive.

Signed-off-by: Shirish S <shirish.s@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c    | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index f4d9041..7b07a47b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -973,6 +973,7 @@ struct amdgpu_device {
 	bool                            in_gpu_reset;
 	enum pp_mp1_state               mp1_state;
 	struct mutex  lock_reset;
+	struct mutex  lock_ib_sched;
 	struct amdgpu_doorbell_index doorbell_index;
 
 	int asic_reset_res;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 676cad1..63cad74 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2759,6 +2759,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	mutex_init(&adev->virt.vf_errors.lock);
 	hash_init(adev->mn_hash);
 	mutex_init(&adev->lock_reset);
+	mutex_init(&adev->lock_ib_sched);
 	mutex_init(&adev->virt.dpm_mutex);
 	mutex_init(&adev->psp.mutex);
 
@@ -3795,7 +3796,9 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,
 				if (r)
 					return r;
 
+				mutex_lock(&tmp_adev->lock_ib_sched);
 				r = amdgpu_device_ip_resume_phase2(tmp_adev);
+				mutex_unlock(&tmp_adev->lock_ib_sched);
 				if (r)
 					goto out;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
index e1bad99..cd6082d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
@@ -233,8 +233,10 @@ static struct dma_fence *amdgpu_job_run(struct drm_sched_job *sched_job)
 	if (finished->error < 0) {
 		DRM_INFO("Skip scheduling IBs!\n");
 	} else {
+		mutex_lock(&ring->adev->lock_ib_sched);
 		r = amdgpu_ib_schedule(ring, job->num_ibs, job->ibs, job,
 				       &fence);
+		mutex_unlock(&ring->adev->lock_ib_sched);
 		if (r)
 			DRM_ERROR("Error scheduling IBs (%d)\n", r);
 	}
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

             reply	other threads:[~2019-10-24 10:58 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-24 10:58 S, Shirish [this message]
2019-10-24 10:58 ` [PATCH] drm/amdgpu: guard ib scheduling while in reset S, Shirish
     [not found] ` <1571914692-9430-1-git-send-email-shirish.s-5C7GfCeVMHo@public.gmane.org>
2019-10-24 11:01   ` Christian König
2019-10-24 11:01     ` Christian König
     [not found]     ` <23ea615d-5ef4-d0b3-a0ec-6fae67b102f2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-10-24 15:06       ` Grodzovsky, Andrey
2019-10-24 15:06         ` Grodzovsky, Andrey
     [not found]         ` <f3be329d-d350-c821-00b7-d94858335796-5C7GfCeVMHo@public.gmane.org>
2019-10-24 16:30           ` Christian König
2019-10-24 16:30             ` Christian König
     [not found]             ` <d573688c-0997-1928-0c56-b60a29ff7fde-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-10-25  8:50               ` S, Shirish
2019-10-25  8:50                 ` S, Shirish
     [not found]                 ` <b5e99dc3-5658-7e48-63f7-bf9533f582f8-5C7GfCeVMHo@public.gmane.org>
2019-10-25  8:53                   ` Koenig, Christian
2019-10-25  8:53                     ` Koenig, Christian
     [not found]                     ` <2505c476-9e10-f70e-355c-33765a37d607-5C7GfCeVMHo@public.gmane.org>
2019-10-25  9:22                       ` S, Shirish
2019-10-25  9:22                         ` S, Shirish
     [not found]                         ` <a1c31f37-128f-51b1-f747-fe75d78d4214-5C7GfCeVMHo@public.gmane.org>
2019-10-25  9:26                           ` Koenig, Christian
2019-10-25  9:26                             ` Koenig, Christian
     [not found]                             ` <a9789f76-3ba5-ad71-1507-5eac6f589b82-5C7GfCeVMHo@public.gmane.org>
2019-10-25 10:08                               ` S, Shirish
2019-10-25 10:08                                 ` S, Shirish
     [not found]                                 ` <b9a72ccf-4d71-a2b9-63da-e5c19e9fbba6-5C7GfCeVMHo@public.gmane.org>
2019-10-25 10:32                                   ` Koenig, Christian
2019-10-25 10:32                                     ` Koenig, Christian
2019-10-25 15:35                               ` Grodzovsky, Andrey
2019-10-25 15:35                                 ` Grodzovsky, Andrey
     [not found]                                 ` <971115b1-6208-1dd5-d99f-c9377663a80b-5C7GfCeVMHo@public.gmane.org>
2019-10-25 15:57                                   ` Koenig, Christian
2019-10-25 15:57                                     ` Koenig, Christian
     [not found]                                     ` <2e2ebf73-9a25-5ad2-78e7-07c8b1db1b37-5C7GfCeVMHo@public.gmane.org>
2019-10-25 16:02                                       ` Grodzovsky, Andrey
2019-10-25 16:02                                         ` Grodzovsky, Andrey
     [not found]                                         ` <08e3c44f-5d08-d5f5-bc76-ea9b77032e5a-5C7GfCeVMHo@public.gmane.org>
2019-10-30  8:44                                           ` S, Shirish
2019-10-30  8:44                                             ` S, Shirish
     [not found]                                             ` <1e1d0b06-75ab-160c-a6c7-baede02f1e7d-5C7GfCeVMHo@public.gmane.org>
2019-10-30 14:44                                               ` Grodzovsky, Andrey
2019-10-30 14:44                                                 ` Grodzovsky, Andrey
     [not found]                                                 ` <f5b7aeff-c4ce-fa2f-1390-e8892fa7a964-5C7GfCeVMHo@public.gmane.org>
2019-10-30 14:50                                                   ` Christian König
2019-10-30 14:50                                                     ` Christian König
     [not found]                                                     ` <d73c46e2-ed85-f56e-3a2a-cbf2919d0a3f-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-10-30 14:56                                                       ` Grodzovsky, Andrey
2019-10-30 14:56                                                         ` Grodzovsky, Andrey
     [not found]                                                         ` <d881fbbe-5fb1-ea68-6490-d08d81c865dd-5C7GfCeVMHo@public.gmane.org>
2019-10-30 15:00                                                           ` Koenig, Christian
2019-10-30 15:00                                                             ` Koenig, Christian
     [not found]                                                             ` <90eb8377-82c4-968a-82f0-1409f69c17e5-5C7GfCeVMHo@public.gmane.org>
2019-10-30 15:05                                                               ` Grodzovsky, Andrey
2019-10-30 15:05                                                                 ` Grodzovsky, Andrey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1571914692-9430-1-git-send-email-shirish.s@amd.com \
    --to=shirish.s-5c7gfcevmho@public.gmane.org \
    --cc=Alexander.Deucher-5C7GfCeVMHo@public.gmane.org \
    --cc=Andrey.Grodzovsky-5C7GfCeVMHo@public.gmane.org \
    --cc=Christian.Koenig-5C7GfCeVMHo@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.