Commit 0875dc9e authored by Chunming Zhou's avatar Chunming Zhou Committed by Alex Deucher

drm/amdgpu: block scheduler when gpu reset

Signed-off-by: default avatarChunming Zhou <David1.Zhou@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent eafc9c27
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
* Alex Deucher * Alex Deucher
* Jerome Glisse * Jerome Glisse
*/ */
#include <linux/kthread.h>
#include <linux/console.h> #include <linux/console.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/debugfs.h> #include <linux/debugfs.h>
...@@ -1895,6 +1896,14 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev) ...@@ -1895,6 +1896,14 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)
atomic_inc(&adev->gpu_reset_counter); atomic_inc(&adev->gpu_reset_counter);
/* block scheduler */
for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
struct amdgpu_ring *ring = adev->rings[i];
if (!ring)
continue;
kthread_park(ring->sched.thread);
}
/* block TTM */ /* block TTM */
resched = ttm_bo_lock_delayed_workqueue(&adev->mman.bdev); resched = ttm_bo_lock_delayed_workqueue(&adev->mman.bdev);
...@@ -1928,7 +1937,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev) ...@@ -1928,7 +1937,7 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)
struct amdgpu_ring *ring = adev->rings[i]; struct amdgpu_ring *ring = adev->rings[i];
if (!ring) if (!ring)
continue; continue;
kthread_unpark(ring->sched.thread);
amdgpu_ring_restore(ring, ring_sizes[i], ring_data[i]); amdgpu_ring_restore(ring, ring_sizes[i], ring_data[i]);
ring_sizes[i] = 0; ring_sizes[i] = 0;
ring_data[i] = NULL; ring_data[i] = NULL;
...@@ -1946,10 +1955,12 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev) ...@@ -1946,10 +1955,12 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)
} else { } else {
amdgpu_fence_driver_force_completion(adev); amdgpu_fence_driver_force_completion(adev);
for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
if (adev->rings[i]) if (adev->rings[i]) {
kthread_unpark(adev->rings[i]->sched.thread);
kfree(ring_data[i]); kfree(ring_data[i]);
} }
} }
}
drm_helper_resume_force_mode(adev->ddev); drm_helper_resume_force_mode(adev->ddev);
......
...@@ -476,6 +476,16 @@ static void amd_sched_process_job(struct fence *f, struct fence_cb *cb) ...@@ -476,6 +476,16 @@ static void amd_sched_process_job(struct fence *f, struct fence_cb *cb)
wake_up_interruptible(&sched->wake_up_worker); wake_up_interruptible(&sched->wake_up_worker);
} }
static bool amd_sched_blocked(struct amd_gpu_scheduler *sched)
{
if (kthread_should_park()) {
kthread_parkme();
return true;
}
return false;
}
static int amd_sched_main(void *param) static int amd_sched_main(void *param)
{ {
struct sched_param sparam = {.sched_priority = 1}; struct sched_param sparam = {.sched_priority = 1};
...@@ -485,13 +495,14 @@ static int amd_sched_main(void *param) ...@@ -485,13 +495,14 @@ static int amd_sched_main(void *param)
sched_setscheduler(current, SCHED_FIFO, &sparam); sched_setscheduler(current, SCHED_FIFO, &sparam);
while (!kthread_should_stop()) { while (!kthread_should_stop()) {
struct amd_sched_entity *entity; struct amd_sched_entity *entity = NULL;
struct amd_sched_fence *s_fence; struct amd_sched_fence *s_fence;
struct amd_sched_job *sched_job; struct amd_sched_job *sched_job;
struct fence *fence; struct fence *fence;
wait_event_interruptible(sched->wake_up_worker, wait_event_interruptible(sched->wake_up_worker,
(entity = amd_sched_select_entity(sched)) || (!amd_sched_blocked(sched) &&
(entity = amd_sched_select_entity(sched))) ||
kthread_should_stop()); kthread_should_stop());
if (!entity) if (!entity)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment