Initialize ring schedulers before using them, very early in the amdgpu boot,
at PCI probe time, specifically at frame-buffer dumb-create at fill-buffer.

This was discovered by using dynamic scheduler run-queues, which showed that
amdgpu was using a scheduler before calling drm_sched_init(), and the only
reason it was working was because sched_rq[] was statically allocated in the
scheduler structure. However, the scheduler structure had _not_ been
initialized.

When switching to dynamically allocated run-queues, this lack of
initialization was causing an oops and a blank screen at boot up. This patch
fixes this amdgpu bug.

This patch depends on the "drm/sched: Convert the GPU scheduler to variable
number of run-queues" patch, as that patch prevents subsequent scheduler
initialization if a scheduler has already been initialized.

Cc: Christian König <christian.koe...@amd.com>
Cc: Alex Deucher <alexander.deuc...@amd.com>
Cc: Felix Kuehling <felix.kuehl...@amd.com>
Cc: AMD Graphics <amd-gfx@lists.freedesktop.org>
Signed-off-by: Luben Tuikov <luben.tui...@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 4e51dce3aab5d6..575ef7e1e30fd4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -60,6 +60,7 @@
 #include "amdgpu_atomfirmware.h"
 #include "amdgpu_res_cursor.h"
 #include "bif/bif_4_1_d.h"
+#include "amdgpu_reset.h"
 
 MODULE_IMPORT_NS(DMA_BUF);
 
@@ -2059,6 +2060,19 @@ void amdgpu_ttm_set_buffer_funcs_status(struct 
amdgpu_device *adev, bool enable)
 
                ring = adev->mman.buffer_funcs_ring;
                sched = &ring->sched;
+
+               r = drm_sched_init(sched, &amdgpu_sched_ops,
+                                  DRM_SCHED_PRIORITY_COUNT,
+                                  ring->num_hw_submission, 0,
+                                  adev->sdma_timeout, adev->reset_domain->wq,
+                                  ring->sched_score, ring->name,
+                                  adev->dev);
+               if (r) {
+                       drm_err(adev, "%s: couldn't initialize ring:%s 
error:%d\n",
+                               __func__, ring->name, r);
+                       return;
+               }
+
                r = drm_sched_entity_init(&adev->mman.high_pr,
                                          DRM_SCHED_PRIORITY_KERNEL, &sched,
                                          1, NULL);

base-commit: 05d3ef8bba77c1b5f98d941d8b2d4aeab8118ef1
prerequisite-patch-id: c52673df9b6fc9ee001d6261c7ac107b618912a0
-- 
2.42.0

Reply via email to