drm/amdgpu: rework resume handling for display (v2)
Subsystems (2)
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: rework resume handling for display (v2)
Split resume into a 3rd step to handle displays when DCC is enabled on DCN 4.0.1. Move display after the buffer funcs have been re-enabled so that the GPU will do the move and properly set the DCC metadata for DCN.
v2: fix fence irq resume ordering
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 45 +++++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +43 -2
@@ -3764,7 +3764,7 @@ static int amdgpu_device_ip_resume_phase1(struct amdgpu_device *adev)* * @adev: amdgpu_device pointer * -* First resume function for hardware IPs. The list of all the hardware +* Second resume function for hardware IPs. The list of all the hardware * IPs that make up the asic is walked and the resume callbacks are run for * all blocks except COMMON, GMC, and IH. resume puts the hardware into a * functional state after a suspend and updates the software state as
@@ -3782,6 +3782,7 @@ static int amdgpu_device_ip_resume_phase2(struct amdgpu_device *adev)if (adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_COMMON || adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_GMC || adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_IH || + adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_DCE || adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_PSP )continue ; r =amdgpu_ip_block_resume (&adev->ip_blocks[i]);
@@ -3792,6 +3793,36 @@ static int amdgpu_device_ip_resume_phase2(struct amdgpu_device *adev)return 0 ; } +/** +* amdgpu_device_ip_resume_phase3 - run resume for hardware IPs +* +* @adev: amdgpu_device pointer +* +* Third resume function for hardware IPs. The list of all the hardware +* IPs that make up the asic is walked and the resume callbacks are run for +* all DCE. resume puts the hardware into a functional state after a suspend +* and updates the software state as necessary. This function is also used +* for restoring the GPU after a GPU reset. +* +* Returns 0 on success, negative error code on failure. +*/ +static int amdgpu_device_ip_resume_phase3 (struct amdgpu_device *adev) +{ +int i, r; + +for (i =0 ; i < adev->num_ip_blocks; i++) { +if (!adev->ip_blocks[i].status.valid || adev->ip_blocks[i].status.hw) +continue ; +if (adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_DCE ) { + r =amdgpu_ip_block_resume (&adev->ip_blocks[i]); +if (r) +return r; + } + } + +return 0 ; +} +/** * amdgpu_device_ip_resume - run resume for hardware IPs *
@@ -3821,6 +3852,13 @@ static int amdgpu_device_ip_resume(struct amdgpu_device *adev)if (adev->mman.buffer_funcs_ring->sched.ready)amdgpu_ttm_set_buffer_funcs_status (adev, true); +if (r) +return r; + +amdgpu_fence_driver_hw_init (adev); + + r =amdgpu_device_ip_resume_phase3 (adev); +return r; }
@@ -4909,7 +4947,6 @@ int amdgpu_device_resume(struct drm_device *dev, bool fbcon)dev_err (adev->dev,"amdgpu_device_ip_resume failed (%d).\n" , r); goto exit; } -amdgpu_fence_driver_hw_init (adev);if (!adev->in_s0ix) { r =amdgpu_amdkfd_resume (adev, adev->in_runpm);
@@ -5489,6 +5526,10 @@ int amdgpu_device_reinit_after_reset(struct amdgpu_reset_context *reset_context)if (tmp_adev->mman.buffer_funcs_ring->sched.ready)amdgpu_ttm_set_buffer_funcs_status (tmp_adev, true); + r =amdgpu_device_ip_resume_phase3 (tmp_adev); +if (r) + goto out; +if (vram_lost)amdgpu_device_fill_reset_magic (tmp_adev);
Signature · 1 line
2.47.0
Am 02.12.24 um 17:52 schrieb Alex Deucher:
Quoted 8 lines
Split resume into a 3rd step to handle displays when DCC is enabled on DCN 4.0.1. Move display after the buffer funcs have been re-enabled so that the GPU will do the move and properly set the DCC metadata for DCN.
v2: fix fence irq resume ordering
Signed-off-by Alex Deucher <[email protected]>
Quoted 95 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 45 +++++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +43
-2@@ -3764,7 +3764,7 @@ static int amdgpu_device_ip_resume_phase1(struct amdgpu_device *adev)* * @adev: amdgpu_device pointer * -* First resume function for hardware IPs. The list of all the hardware +* Second resume function for hardware IPs. The list of all the hardware * IPs that make up the asic is walked and the resume callbacks are run for * all blocks except COMMON, GMC, and IH. resume puts the hardware into a * functional state after a suspend and updates the software state as @@ -3782,6 +3782,7 @@ static int amdgpu_device_ip_resume_phase2(struct amdgpu_device *adev)if (adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_COMMON || adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_GMC || adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_IH || + adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_DCE || adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_PSP )continue ; r =amdgpu_ip_block_resume (&adev->ip_blocks[i]);@@ -3792,6 +3793,36 @@ static int amdgpu_device_ip_resume_phase2(struct amdgpu_device *adev)return 0 ; } +/** +* amdgpu_device_ip_resume_phase3 - run resume for hardware IPs +* +* @adev: amdgpu_device pointer +* +* Third resume function for hardware IPs. The list of all the hardware +* IPs that make up the asic is walked and the resume callbacks are run for +* all DCE. resume puts the hardware into a functional state after a suspend +* and updates the software state as necessary. This function is also used +* for restoring the GPU after a GPU reset. +* +* Returns 0 on success, negative error code on failure. +*/ +static int amdgpu_device_ip_resume_phase3 (struct amdgpu_device *adev) +{ +int i, r; + +for (i =0 ; i < adev->num_ip_blocks; i++) { +if (!adev->ip_blocks[i].status.valid || adev->ip_blocks[i].status.hw) +continue ; +if (adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_DCE ) { + r =amdgpu_ip_block_resume (&adev->ip_blocks[i]); +if (r) +return r; + } + } + +return 0 ; +} +/** * amdgpu_device_ip_resume - run resume for hardware IPs * @@ -3821,6 +3852,13 @@ static int amdgpu_device_ip_resume(struct amdgpu_device *adev)if (adev->mman.buffer_funcs_ring->sched.ready)amdgpu_ttm_set_buffer_funcs_status (adev, true); +if (r) +return r; + +amdgpu_fence_driver_hw_init (adev); + + r =amdgpu_device_ip_resume_phase3 (adev); +return r; }@@ -4909,7 +4947,6 @@ int amdgpu_device_resume(struct drm_device *dev, bool fbcon)dev_err (adev->dev,"amdgpu_device_ip_resume failed (%d).\n" , r); goto exit; } -amdgpu_fence_driver_hw_init (adev);if (!adev->in_s0ix) { r =amdgpu_amdkfd_resume (adev, adev->in_runpm);@@ -5489,6 +5526,10 @@ int amdgpu_device_reinit_after_reset(struct amdgpu_reset_context *reset_context)if (tmp_adev->mman.buffer_funcs_ring->sched.ready)amdgpu_ttm_set_buffer_funcs_status (tmp_adev, true); + r =amdgpu_device_ip_resume_phase3 (tmp_adev); +if (r) + goto out; +if (vram_lost)amdgpu_device_fill_reset_magic (tmp_adev);
Am 02.12.24 um 20:18 schrieb Christian König:
Quoted 5 lines
Am 02.12.24 um 17:52 schrieb Alex Deucher:
Quoted 4 lines
Split resume into a 3rd step to handle displays when DCC is enabled on DCN 4.0.1. Move display after the buffer funcs have been re-enabled so that the GPU will do the move and properly set the DCC metadata for DCN.
BTW: We might want to add a WARN_ON() to the CPU copy path to make sure that we don't try to copy DCC buffers while the SDMA is turned off.
Christian.
Quoted 111 lines
Quoted 4 lines
v2: fix fence irq resume ordering
Signed-off-by Alex Deucher <[email protected]>Reviewed-by Christian König <[email protected]>Quoted 103 lines
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 45 +++++++++++++++++++++-1 file changed, 43 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-1@@ -3764,7 +3764,7 @@ static int amdgpu_device_ip_resume_phase1(struct amdgpu_device *adev) * * @adev: amdgpu_device pointer * - * First resume function for hardware IPs. The list of all thehardware
+ * Second resume function for hardware IPs. The list of all the hardware
* IPs that make up the asic is walked and the resume callbacks are run for
* all blocks except COMMON, GMC, and IH. resume puts the hardware into a
* functional state after a suspend and updates the software state asdrivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -3782,6 +3782,7 @@ static int amdgpu_device_ip_resume_phase2(struct amdgpu_device *adev)if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_COMMON || adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC || adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_IH ||+ adev->ip_blocks[i].version->type ==
AMD_IP_BLOCK_TYPE_DCE||
adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_PSP) continue;
r =amdgpu_ip_block_resume(&adev->ip_blocks[i]);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -3792,6 +3793,36 @@ static int amdgpu_device_ip_resume_phase2(struct amdgpu_device *adev) return 0; }+/**
+ *amdgpu_device_ip_resume_phase3- run resume for hardware IPs
+ *
+ * @adev:amdgpu_devicepointer
+ *
+ * Third resume function for hardware IPs. The list of all the hardware
+ * IPs that make up the asic is walked and the resume callbacks are run for
+ * all DCE. resume puts the hardware into a functional state after a suspend
+ * and updates the software state as necessary. This function is also used
+ * for restoring the GPU after a GPU reset.
+ *
+ * Returns 0 on success, negative error code on failure.
+ */drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6
-0+static int amdgpu_device_ip_resume_phase3 (struct amdgpu_device *adev) +{ + int i, r; + + for (i = 0; i < adev->num_ip_blocks; i++) { + if (!adev->ip_blocks[i].status.valid ||adev->ip_blocks[i].status.hw)
+ continue;
+ if (adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_DCE) {
+ r =amdgpu_ip_block_resume(&adev->ip_blocks[i]); + if (r)
+ return r;
+ }
+ }drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4
-0+ + return 0; +} +/**
*amdgpu_device_ip_resume- run resume for hardware IPs *drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6
-0@@ -3821,6 +3852,13 @@ static int amdgpu_device_ip_resume(struct amdgpu_device *adev) if (adev->mman.buffer_funcs_ring->sched.ready) amdgpu_ttm_set_buffer_funcs_status(adev, true); + if (r) + return r; + + amdgpu_fence_driver_hw_init(adev); + + r = amdgpu_device_ip_resume_phase3(adev); + return r; }@@ -4909,7 +4947,6 @@ int
amdgpu_device_resume(struct drm_device *dev, bool fbcon)dev_err(adev->dev, "amdgpu_device_ip_resume failed (%d).\n", r); goto exit;
}
-amdgpu_fence_driver_hw_init(adev);
if (!adev->in_s0ix) {
r =amdgpu_amdkfd_resume(adev, adev->in_runpm);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-0@@ -5489,6 +5526,10 @@ int amdgpu_device_reinit_after_reset(struct amdgpu_reset_context *reset_context) if (tmp_adev->mman.buffer_funcs_ring->sched.ready)amdgpu_ttm_set_buffer_funcs_status (tmp_adev, true); + r = amdgpu_device_ip_resume_phase3(tmp_adev); + if (r) + goto out; + if (vram_lost) amdgpu_device_fill_reset_magic(tmp_adev);
Zhang, George
Tested-by[Public]
________________________________________
From: amd-gfx <[email protected]> on behalf of Christian König <[email protected]>
Sent: Monday, December 2, 2024 2:19 PM
To: Deucher, Alexander; [email protected]
Subject: Re: [PATCH] drm/amdgpu: rework resume handling for display (v2)
Quoted 8 lines
Am 02.12.24 um 20:18 schrieb Christian König:
Quoted 5 lines
Am 02.12.24 um 17:52 schrieb Alex Deucher:
Quoted 4 lines
Split resume into a 3rd step to handle displays when DCC is enabled on DCN 4.0.1. Move display after the buffer funcs have been re-enabled so that the GPU will do the move and properly set the DCC metadata for DCN.
Quoted 11 lines
BTW: We might want to add a
WARN_ON()to the CPU copy path to make sure that we don't try to copy DCC buffers while the SDMA is turned off.Christian.
Quoted 6 lines
Quoted 4 lines
v2: fix fence irq resume ordering
Signed-off-by Alex Deucher <[email protected]>Reviewed-by Christian König <[email protected]>
Quoted 114 lines
Quoted 113 lines
Quoted 112 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 45 +++++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-1@@ -3764,7 +3764,7 @@ static int amdgpu_device_ip_resume_phase1(struct amdgpu_device *adev) * * @adev: amdgpu_device pointer * - * First resume function for hardware IPs. The list of all thehardware
+ * Second resume function for hardware IPs. The list of all the hardware
* IPs that make up the asic is walked and the resume callbacks are
run for
* all blocks except COMMON, GMC, and IH. resume puts the hardware
into a
* functional state after a suspend and updates the software state asdrivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -3782,6 +3782,7 @@ static int amdgpu_device_ip_resume_phase2(struct amdgpu_device *adev) if (adev->ip_blocks[i].version->type ==
AMD_IP_BLOCK_TYPE_COMMON||adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC || adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_IH || + adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_DCE || adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_PSP) continue; r = amdgpu_ip_block_resume(&adev->ip_blocks[i]);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5
-0@@ -3792,6 +3793,36 @@ static int amdgpu_device_ip_resume_phase2(struct amdgpu_device *adev) return 0; } +/** +* amdgpu_device_ip_resume_phase3 - run resume for hardware IPs +* +* @adev: amdgpu_device pointer +* +* Third resume function for hardware IPs. The list of all the hardware
+ * IPs that make up the asic is walked and the resume callbacks are run for
+ * all DCE. resume puts the hardware into a functional state after a suspend
+ * and updates the software state as necessary. This function is also used
+ * for restoring the GPU after a GPU reset.
+ *
+ * Returns 0 on success, negative error code on failure.
+ */drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6
-0+static int amdgpu_device_ip_resume_phase3 (struct amdgpu_device *adev) +{ +int i, r; + +for (i =0 ; i < adev->num_ip_blocks; i++) { + if (!adev->ip_blocks[i].status.valid ||adev->ip_blocks[i].status.hw)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-0+continue ; + if (adev->ip_blocks[i].version->type ==
AMD_IP_BLOCK_TYPE_DCE) {drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +15
-0+ r =amdgpu_ip_block_resume (&adev->ip_blocks[i]); +if (r) +return r; + } + } + +return 0 ; +} +/** * amdgpu_device_ip_resume - run resume for hardware IPs * @@ -3821,6 +3852,13 @@ static int amdgpu_device_ip_resume(struct amdgpu_device *adev)if (adev->mman.buffer_funcs_ring->sched.ready)amdgpu_ttm_set_buffer_funcs_status (adev, true); + if (r) +return r; + +amdgpu_fence_driver_hw_init (adev); + + r =amdgpu_device_ip_resume_phase3 (adev); +return r; } @@ -4909,7 +4947,6 @@ int amdgpu_device_resume(struct drm_device*dev, bool fbcon)
dev_err(adev->dev, "amdgpu_device_ip_resume failed (%d).\n", r); goto exit; }drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-1-amdgpu_fence_driver_hw_init (adev);if (!adev->in_s0ix) { r =amdgpu_amdkfd_resume (adev, adev->in_runpm);@@ -5489,6 +5526,10 @@ int amdgpu_device_reinit_after_reset(struct amdgpu_reset_context *reset_context)if (tmp_adev->mman.buffer_funcs_ring->sched.ready)amdgpu_ttm_set_buffer_funcs_status (tmp_adev, true); + r =amdgpu_device_ip_resume_phase3 (tmp_adev); +if (r) + goto out; +if (vram_lost)amdgpu_device_fill_reset_magic (tmp_adev);