Skip to content

Commit

Permalink
Revert "drm/amdgpu: move buffer funcs setting up a level"
Browse files Browse the repository at this point in the history
Revert submission 1033322

Reason for revert: Breaks GPU reset
Reverted Changes:
I518055d36:drm/amdgpu: drop setting buffer funcs in sdma442
I3161b3ba3:drm/amdgpu: fix buffer funcs setting order on susp...
If96a48811:drm/amdklc: fix a intree build error.
I370135be6:drm/sched: Don't disturb the entity when in RR-mod...
I051ca6e0b:drm/sched: Move free worker re-queuing out of the ...
I25fb2785c:drm/sched: Rename drm_sched_get_cleanup_job to be ...
I666125051:drm/sched: Rename drm_sched_run_job_queue_if_ready...
I9a32472a9:drm/sched: Rename drm_sched_free_job_queue to be m...
I4c2c9bed1:drm/sched: Re-queue run job worker when drm_sched_...
Ie513a85c7:drm/sched: Drain all entities in DRM sched run job...
I855c12a4e:drm/sched: Split free_job into own work item
I7a116284b:drm/sched: Convert drm scheduler to use a work que...
Iffc1aa4cd:drm/amdgpu: move buffer funcs setting up a level
I3753e9dd4:drm/sched: Convert the GPU scheduler to variable n...

Change-Id: I42d1cd81481794841d26543d22f383b85ffe7a03
  • Loading branch information
kentrussell committed Apr 10, 2024
1 parent 2a91b91 commit cf8e343
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 19 deletions.
15 changes: 0 additions & 15 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -2849,9 +2849,6 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
if (r)
goto init_failed;

if (adev->mman.buffer_funcs_ring->sched.ready)
amdgpu_ttm_set_buffer_funcs_status(adev, true);

/* Don't init kfd if whole hive need to be reset during init */
if (!adev->gmc.xgmi.pending_reset) {
kgd2kfd_init_zone_device(adev);
Expand Down Expand Up @@ -3450,8 +3447,6 @@ int amdgpu_device_ip_suspend(struct amdgpu_device *adev)
amdgpu_virt_request_full_gpu(adev, false);
}

amdgpu_ttm_set_buffer_funcs_status(adev, false);

r = amdgpu_device_ip_suspend_phase1(adev);
if (r)
return r;
Expand Down Expand Up @@ -3641,9 +3636,6 @@ static int amdgpu_device_ip_resume(struct amdgpu_device *adev)

r = amdgpu_device_ip_resume_phase2(adev);

if (adev->mman.buffer_funcs_ring->sched.ready)
amdgpu_ttm_set_buffer_funcs_status(adev, true);

return r;
}

Expand Down Expand Up @@ -4451,8 +4443,6 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev)
/* disable ras feature must before hw fini */
amdgpu_ras_pre_fini(adev);

amdgpu_ttm_set_buffer_funcs_status(adev, false);

amdgpu_device_ip_fini_early(adev);

amdgpu_irq_fini_hw(adev);
Expand Down Expand Up @@ -4628,8 +4618,6 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)

amdgpu_ras_suspend(adev);

amdgpu_ttm_set_buffer_funcs_status(adev, false);

amdgpu_device_ip_suspend_phase1(adev);

if (!adev->in_s0ix)
Expand Down Expand Up @@ -5390,9 +5378,6 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,
if (r)
goto out;

if (tmp_adev->mman.buffer_funcs_ring->sched.ready)
amdgpu_ttm_set_buffer_funcs_status(tmp_adev, true);

if (vram_lost)
amdgpu_device_fill_reset_magic(tmp_adev);

Expand Down
21 changes: 21 additions & 0 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,27 @@ int amdgpu_sdma_init_microcode(struct amdgpu_device *adev,
return err;
}

void amdgpu_sdma_unset_buffer_funcs_helper(struct amdgpu_device *adev)
{
struct amdgpu_ring *sdma;
int i;

for (i = 0; i < adev->sdma.num_instances; i++) {
if (adev->sdma.has_page_queue) {
sdma = &adev->sdma.instance[i].page;
if (adev->mman.buffer_funcs_ring == sdma) {
amdgpu_ttm_set_buffer_funcs_status(adev, false);
break;
}
}
sdma = &adev->sdma.instance[i].ring;
if (adev->mman.buffer_funcs_ring == sdma) {
amdgpu_ttm_set_buffer_funcs_status(adev, false);
break;
}
}
}

int amdgpu_sdma_ras_sw_init(struct amdgpu_device *adev)
{
int err = 0;
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ int amdgpu_sdma_init_microcode(struct amdgpu_device *adev, u32 instance,
bool duplicate);
void amdgpu_sdma_destroy_inst_ctx(struct amdgpu_device *adev,
bool duplicate);
void amdgpu_sdma_unset_buffer_funcs_helper(struct amdgpu_device *adev);
int amdgpu_sdma_ras_sw_init(struct amdgpu_device *adev);

#endif
5 changes: 5 additions & 0 deletions drivers/gpu/drm/amd/amdgpu/cik_sdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ static void cik_sdma_gfx_stop(struct amdgpu_device *adev)
u32 rb_cntl;
int i;

amdgpu_sdma_unset_buffer_funcs_helper(adev);

for (i = 0; i < adev->sdma.num_instances; i++) {
rb_cntl = RREG32(mmSDMA0_GFX_RB_CNTL + sdma_offsets[i]);
rb_cntl &= ~SDMA0_GFX_RB_CNTL__RB_ENABLE_MASK;
Expand Down Expand Up @@ -496,6 +498,9 @@ static int cik_sdma_gfx_resume(struct amdgpu_device *adev)
r = amdgpu_ring_test_helper(ring);
if (r)
return r;

if (adev->mman.buffer_funcs_ring == ring)
amdgpu_ttm_set_buffer_funcs_status(adev, true);
}

return 0;
Expand Down
5 changes: 5 additions & 0 deletions drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ static void sdma_v2_4_gfx_stop(struct amdgpu_device *adev)
u32 rb_cntl, ib_cntl;
int i;

amdgpu_sdma_unset_buffer_funcs_helper(adev);

for (i = 0; i < adev->sdma.num_instances; i++) {
rb_cntl = RREG32(mmSDMA0_GFX_RB_CNTL + sdma_offsets[i]);
rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_ENABLE, 0);
Expand Down Expand Up @@ -470,6 +472,9 @@ static int sdma_v2_4_gfx_resume(struct amdgpu_device *adev)
r = amdgpu_ring_test_helper(ring);
if (r)
return r;

if (adev->mman.buffer_funcs_ring == ring)
amdgpu_ttm_set_buffer_funcs_status(adev, true);
}

return 0;
Expand Down
5 changes: 5 additions & 0 deletions drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,8 @@ static void sdma_v3_0_gfx_stop(struct amdgpu_device *adev)
u32 rb_cntl, ib_cntl;
int i;

amdgpu_sdma_unset_buffer_funcs_helper(adev);

for (i = 0; i < adev->sdma.num_instances; i++) {
rb_cntl = RREG32(mmSDMA0_GFX_RB_CNTL + sdma_offsets[i]);
rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_ENABLE, 0);
Expand Down Expand Up @@ -744,6 +746,9 @@ static int sdma_v3_0_gfx_resume(struct amdgpu_device *adev)
r = amdgpu_ring_test_helper(ring);
if (r)
return r;

if (adev->mman.buffer_funcs_ring == ring)
amdgpu_ttm_set_buffer_funcs_status(adev, true);
}

return 0;
Expand Down
16 changes: 15 additions & 1 deletion drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,8 @@ static void sdma_v4_0_gfx_enable(struct amdgpu_device *adev, bool enable)
u32 rb_cntl, ib_cntl;
int i;

amdgpu_sdma_unset_buffer_funcs_helper(adev);

for (i = 0; i < adev->sdma.num_instances; i++) {
rb_cntl = RREG32_SDMA(i, mmSDMA0_GFX_RB_CNTL);
rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_ENABLE, enable ? 1 : 0);
Expand Down Expand Up @@ -911,6 +913,8 @@ static void sdma_v4_0_page_stop(struct amdgpu_device *adev)
u32 rb_cntl, ib_cntl;
int i;

amdgpu_sdma_unset_buffer_funcs_helper(adev);

for (i = 0; i < adev->sdma.num_instances; i++) {
rb_cntl = RREG32_SDMA(i, mmSDMA0_PAGE_RB_CNTL);
rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_PAGE_RB_CNTL,
Expand Down Expand Up @@ -1399,7 +1403,13 @@ static int sdma_v4_0_start(struct amdgpu_device *adev)
r = amdgpu_ring_test_helper(page);
if (r)
return r;

if (adev->mman.buffer_funcs_ring == page)
amdgpu_ttm_set_buffer_funcs_status(adev, true);
}

if (adev->mman.buffer_funcs_ring == ring)
amdgpu_ttm_set_buffer_funcs_status(adev, true);
}

return r;
Expand Down Expand Up @@ -1912,8 +1922,11 @@ static int sdma_v4_0_hw_fini(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
int i;

if (amdgpu_sriov_vf(adev))
if (amdgpu_sriov_vf(adev)) {
/* disable the scheduler for SDMA */
amdgpu_sdma_unset_buffer_funcs_helper(adev);
return 0;
}

if (amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__SDMA)) {
for (i = 0; i < adev->sdma.num_instances; i++) {
Expand Down Expand Up @@ -1952,6 +1965,7 @@ static int sdma_v4_0_resume(void *handle)
if (adev->in_s0ix) {
sdma_v4_0_enable(adev, true);
sdma_v4_0_gfx_enable(adev, true);
amdgpu_ttm_set_buffer_funcs_status(adev, true);
return 0;
}

Expand Down
10 changes: 9 additions & 1 deletion drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,8 @@ static void sdma_v5_0_gfx_stop(struct amdgpu_device *adev)
u32 rb_cntl, ib_cntl;
int i;

amdgpu_sdma_unset_buffer_funcs_helper(adev);

for (i = 0; i < adev->sdma.num_instances; i++) {
rb_cntl = RREG32_SOC15_IP(GC, sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_CNTL));
rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_ENABLE, 0);
Expand Down Expand Up @@ -823,6 +825,9 @@ static int sdma_v5_0_gfx_resume(struct amdgpu_device *adev)
r = amdgpu_ring_test_helper(ring);
if (r)
return r;

if (adev->mman.buffer_funcs_ring == ring)
amdgpu_ttm_set_buffer_funcs_status(adev, true);
}

return 0;
Expand Down Expand Up @@ -1421,8 +1426,11 @@ static int sdma_v5_0_hw_fini(void *handle)
{
struct amdgpu_device *adev = (struct amdgpu_device *)handle;

if (amdgpu_sriov_vf(adev))
if (amdgpu_sriov_vf(adev)) {
/* disable the scheduler for SDMA */
amdgpu_sdma_unset_buffer_funcs_helper(adev);
return 0;
}

sdma_v5_0_ctx_switch_enable(adev, false);
sdma_v5_0_enable(adev, false);
Expand Down
10 changes: 9 additions & 1 deletion drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@ static void sdma_v5_2_gfx_stop(struct amdgpu_device *adev)
u32 rb_cntl, ib_cntl;
int i;

amdgpu_sdma_unset_buffer_funcs_helper(adev);

for (i = 0; i < adev->sdma.num_instances; i++) {
rb_cntl = RREG32_SOC15_IP(GC, sdma_v5_2_get_reg_offset(adev, i, mmSDMA0_GFX_RB_CNTL));
rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_ENABLE, 0);
Expand Down Expand Up @@ -623,6 +625,9 @@ static int sdma_v5_2_gfx_resume(struct amdgpu_device *adev)
r = amdgpu_ring_test_helper(ring);
if (r)
return r;

if (adev->mman.buffer_funcs_ring == ring)
amdgpu_ttm_set_buffer_funcs_status(adev, true);
}

return 0;
Expand Down Expand Up @@ -1279,8 +1284,11 @@ static int sdma_v5_2_hw_fini(void *handle)
{
struct amdgpu_device *adev = (struct amdgpu_device *)handle;

if (amdgpu_sriov_vf(adev))
if (amdgpu_sriov_vf(adev)) {
/* disable the scheduler for SDMA */
amdgpu_sdma_unset_buffer_funcs_helper(adev);
return 0;
}

sdma_v5_2_ctx_switch_enable(adev, false);
sdma_v5_2_enable(adev, false);
Expand Down
10 changes: 9 additions & 1 deletion drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ static void sdma_v6_0_gfx_stop(struct amdgpu_device *adev)
u32 rb_cntl, ib_cntl;
int i;

amdgpu_sdma_unset_buffer_funcs_helper(adev);

for (i = 0; i < adev->sdma.num_instances; i++) {
rb_cntl = RREG32_SOC15_IP(GC, sdma_v6_0_get_reg_offset(adev, i, regSDMA0_QUEUE0_RB_CNTL));
rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_QUEUE0_RB_CNTL, RB_ENABLE, 0);
Expand Down Expand Up @@ -559,6 +561,9 @@ static int sdma_v6_0_gfx_resume(struct amdgpu_device *adev)
r = amdgpu_ring_test_helper(ring);
if (r)
return r;

if (adev->mman.buffer_funcs_ring == ring)
amdgpu_ttm_set_buffer_funcs_status(adev, true);
}

return 0;
Expand Down Expand Up @@ -1303,8 +1308,11 @@ static int sdma_v6_0_hw_fini(void *handle)
{
struct amdgpu_device *adev = (struct amdgpu_device *)handle;

if (amdgpu_sriov_vf(adev))
if (amdgpu_sriov_vf(adev)) {
/* disable the scheduler for SDMA */
amdgpu_sdma_unset_buffer_funcs_helper(adev);
return 0;
}

sdma_v6_0_ctxempty_int_enable(adev, false);
sdma_v6_0_enable(adev, false);
Expand Down
5 changes: 5 additions & 0 deletions drivers/gpu/drm/amd/amdgpu/si_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ static void si_dma_stop(struct amdgpu_device *adev)
u32 rb_cntl;
unsigned i;

amdgpu_sdma_unset_buffer_funcs_helper(adev);

for (i = 0; i < adev->sdma.num_instances; i++) {
/* dma0 */
rb_cntl = RREG32(DMA_RB_CNTL + sdma_offsets[i]);
Expand Down Expand Up @@ -175,6 +177,9 @@ static int si_dma_start(struct amdgpu_device *adev)
r = amdgpu_ring_test_helper(ring);
if (r)
return r;

if (adev->mman.buffer_funcs_ring == ring)
amdgpu_ttm_set_buffer_funcs_status(adev, true);
}

return 0;
Expand Down

0 comments on commit cf8e343

Please sign in to comment.