drm/amdgpu: Remove duplicate code in gfx_v9_0.c
Subsystems (2)
PATCH 1/2 drm/amdgpu: Remove duplicate code in gfx_v9_0.c
There are no any logical changes here.
1. if kcq can be enabled via kiq, we don't need to do kiq ring test.
2. amdgpu_ring_test_ring function can be used to sync the ring complete, remove the duplicate code.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 72 ++++++----------------------------- 1 file changed, 12 insertions(+), 60 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +12 -60
@@ -2610,7 +2610,6 @@ static void gfx_v9_0_kiq_setting(struct amdgpu_ring *ring)static int gfx_v9_0_kiq_kcq_enable (struct amdgpu_device *adev) {struct amdgpu_ring *kiq_ring = &adev->gfx.kiq.ring; -uint32_t scratch, tmp =0 ;uint64_t queue_mask =0 ;int r, i;
@@ -2629,17 +2628,10 @@ static int gfx_v9_0_kiq_kcq_enable(struct amdgpu_device *adev) queue_mask |= (1ull << i); } - r =amdgpu_gfx_scratch_get (adev, &scratch); -if (r) { -DRM_ERROR ("Failed to get scratch reg (%d).\n" , r); -return r; - } -WREG32 (scratch,0xCAFEDEAD ); - - r =amdgpu_ring_alloc (kiq_ring, (7 * adev->gfx.num_compute_rings) +11 ); + kiq_ring->ready = true; + r =amdgpu_ring_alloc (kiq_ring, (7 * adev->gfx.num_compute_rings) +8 );if (r) {DRM_ERROR ("Failed to lock KIQ (%d).\n" , r); -amdgpu_gfx_scratch_free (adev, scratch);return r; }
@@ -2676,24 +2668,12 @@ static int gfx_v9_0_kiq_kcq_enable(struct amdgpu_device *adev)amdgpu_ring_write (kiq_ring,lower_32_bits (wptr_addr));amdgpu_ring_write (kiq_ring,upper_32_bits (wptr_addr)); } -/* write to scratch for completion */ -amdgpu_ring_write (kiq_ring,PACKET3 (PACKET3_SET_UCONFIG_REG ,1 )); -amdgpu_ring_write (kiq_ring, (scratch -PACKET3_SET_UCONFIG_REG_START )); -amdgpu_ring_write (kiq_ring,0xDEADBEEF ); -amdgpu_ring_commit (kiq_ring); -for (i =0 ; i < adev->usec_timeout; i++) { - tmp =RREG32 (scratch); -if (tmp ==0xDEADBEEF ) -break ; -DRM_UDELAY (1 ); - } -if (i >= adev->usec_timeout) { -DRM_ERROR ("KCQ enable failed (scratch(0x%04X)=0x%08X)\n" , - scratch, tmp); - r = -EINVAL ; + r =amdgpu_ring_test_ring (kiq_ring); +if (r) { +DRM_ERROR ("KCQ enable failed\n" ); + kiq_ring->ready = false; } -amdgpu_gfx_scratch_free (adev, scratch);return r; }
@@ -3132,12 +3112,6 @@ static int gfx_v9_0_cp_resume(struct amdgpu_device *adev)return r; } - ring = &adev->gfx.kiq.ring; - ring->ready = true; - r =amdgpu_ring_test_ring (ring); -if (r) - ring->ready = false; -for (i =0 ; i < adev->gfx.num_compute_rings; i++) { ring = &adev->gfx.compute_ring[i];
@@ -3188,21 +3162,11 @@ static int gfx_v9_0_hw_init(void *handle)static int gfx_v9_0_kcq_disable (struct amdgpu_ring *kiq_ring,struct amdgpu_ring *ring) { -struct amdgpu_device *adev = kiq_ring->adev; -uint32_t scratch, tmp =0 ; -int r, i; - - r =amdgpu_gfx_scratch_get (adev, &scratch); -if (r) { -DRM_ERROR ("Failed to get scratch reg (%d).\n" , r); -return r; - } -WREG32 (scratch,0xCAFEDEAD ); +int r; - r =amdgpu_ring_alloc (kiq_ring,10 ); + r =amdgpu_ring_alloc (kiq_ring,6 );if (r) {DRM_ERROR ("Failed to lock KIQ (%d).\n" , r); -amdgpu_gfx_scratch_free (adev, scratch);return r; }
@@ -3217,23 +3181,11 @@ static int gfx_v9_0_kcq_disable(struct amdgpu_ring *kiq_ring,struct amdgpu_ringamdgpu_ring_write (kiq_ring,0 );amdgpu_ring_write (kiq_ring,0 );amdgpu_ring_write (kiq_ring,0 ); -/* write to scratch for completion */ -amdgpu_ring_write (kiq_ring,PACKET3 (PACKET3_SET_UCONFIG_REG ,1 )); -amdgpu_ring_write (kiq_ring, (scratch -PACKET3_SET_UCONFIG_REG_START )); -amdgpu_ring_write (kiq_ring,0xDEADBEEF ); -amdgpu_ring_commit (kiq_ring); -for (i =0 ; i < adev->usec_timeout; i++) { - tmp =RREG32 (scratch); -if (tmp ==0xDEADBEEF ) -break ; -DRM_UDELAY (1 ); - } -if (i >= adev->usec_timeout) { -DRM_ERROR ("KCQ disabled failed (scratch(0x%04X)=0x%08X)\n" , scratch, tmp); - r = -EINVAL ; - } -amdgpu_gfx_scratch_free (adev, scratch); + r =amdgpu_ring_test_ring (kiq_ring); +if (r) +DRM_ERROR ("KCQ disable failed\n" ); +return r; }
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1534498407-19950-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org
PATCH 2/2 drm/amdgpu: Refine gfx_v9_0_kcq_disable function
Send all kcq unmap_queue packets and then wait for complete.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +16 -17
@@ -3160,28 +3160,29 @@ static int gfx_v9_0_hw_init(void *handle)return r; } -static int gfx_v9_0_kcq_disable (struct amdgpu_ring *kiq_ring,struct amdgpu_ring *ring) +static int gfx_v9_0_kcq_disable (struct amdgpu_device *adev) { -int r; +int r, i; +struct amdgpu_ring *kiq_ring = &adev->gfx.kiq.ring; - r =amdgpu_ring_alloc (kiq_ring,6 ); -if (r) { + r =amdgpu_ring_alloc (kiq_ring,6 * adev->gfx.num_compute_rings); +if (r)DRM_ERROR ("Failed to lock KIQ (%d).\n" , r); -return r; - } -/* unmap queues */ -amdgpu_ring_write (kiq_ring,PACKET3 (PACKET3_UNMAP_QUEUES ,4 )); -amdgpu_ring_write (kiq_ring,/* Q_sel: 0, vmid: 0, engine: 0, num_Q: 1 */ +for (i =0 ; i < adev->gfx.num_compute_rings; i++) { +struct amdgpu_ring *ring = &adev->gfx.compute_ring[i]; + +amdgpu_ring_write (kiq_ring,PACKET3 (PACKET3_UNMAP_QUEUES ,4 )); +amdgpu_ring_write (kiq_ring,/* Q_sel: 0, vmid: 0, engine: 0, num_Q: 1 */ PACKET3_UNMAP_QUEUES_ACTION (1 ) |/* RESET_QUEUES */ PACKET3_UNMAP_QUEUES_QUEUE_SEL (0 ) |PACKET3_UNMAP_QUEUES_ENGINE_SEL (0 ) |PACKET3_UNMAP_QUEUES_NUM_QUEUES (1 )); -amdgpu_ring_write (kiq_ring,PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET0 (ring->doorbell_index)); -amdgpu_ring_write (kiq_ring,0 ); -amdgpu_ring_write (kiq_ring,0 ); -amdgpu_ring_write (kiq_ring,0 ); - +amdgpu_ring_write (kiq_ring,PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET0 (ring->doorbell_index)); +amdgpu_ring_write (kiq_ring,0 ); +amdgpu_ring_write (kiq_ring,0 ); +amdgpu_ring_write (kiq_ring,0 ); + } r =amdgpu_ring_test_ring (kiq_ring);if (r)DRM_ERROR ("KCQ disable failed\n" );
@@ -3192,14 +3193,12 @@ static int gfx_v9_0_kcq_disable(struct amdgpu_ring *kiq_ring,struct amdgpu_ringstatic int gfx_v9_0_hw_fini (void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; -int i;amdgpu_irq_put (adev, &adev->gfx.priv_reg_irq,0 );amdgpu_irq_put (adev, &adev->gfx.priv_inst_irq,0 );/* disable KCQ to avoid CPC touch memory not valid anymore */ -for (i =0 ; i < adev->gfx.num_compute_rings; i++) -gfx_v9_0_kcq_disable (&adev->gfx.kiq.ring, &adev->gfx.compute_ring[i]); +gfx_v9_0_kcq_disable (adev);if (amdgpu_sriov_vf (adev)) {gfx_v9_0_cp_gfx_enable (adev, false);
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1534498407-19950-2-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org
Alex Deucher
Reviewed-byRe: [PATCH 2/2] drm/amdgpu: Refine gfx_v9_0_kcq_disable function
Quoted 5 lines · Rex Zhu
Send all kcq
unmap_queuepackets and then wait for complete.Signed-off-by Rex Zhu <[email protected]>
This series and the gfx8 series are:
Longer term, we may want to dynamically map and umap compute queues as part of scheduling compute work to deal with things like priorities and cu masking the the mqds, but that is a future enhancement.
Alex
Quoted 71 lines
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +16
-18@@ -3160,28 +3160,29 @@ static int gfx_v9_0_hw_init(void *handle)return r; } -static int gfx_v9_0_kcq_disable (struct amdgpu_ring *kiq_ring,struct amdgpu_ring *ring) +static int gfx_v9_0_kcq_disable (struct amdgpu_device *adev) { -int r; +int r, i; +struct amdgpu_ring *kiq_ring = &adev->gfx.kiq.ring; - r =amdgpu_ring_alloc (kiq_ring,6 ); -if (r) { + r =amdgpu_ring_alloc (kiq_ring,6 * adev->gfx.num_compute_rings); +if (r)DRM_ERROR ("Failed to lock KIQ (%d).\n" , r); -return r; - } -/* unmap queues */ -amdgpu_ring_write (kiq_ring,PACKET3 (PACKET3_UNMAP_QUEUES ,4 )); -amdgpu_ring_write (kiq_ring,/* Q_sel: 0, vmid: 0, engine: 0, num_Q: 1 */ +for (i =0 ; i < adev->gfx.num_compute_rings; i++) { +struct amdgpu_ring *ring = &adev->gfx.compute_ring[i]; + +amdgpu_ring_write (kiq_ring,PACKET3 (PACKET3_UNMAP_QUEUES ,4 )); +amdgpu_ring_write (kiq_ring,/* Q_sel: 0, vmid: 0, engine: 0, num_Q: 1 */ PACKET3_UNMAP_QUEUES_ACTION (1 ) |/* RESET_QUEUES */ PACKET3_UNMAP_QUEUES_QUEUE_SEL (0 ) |PACKET3_UNMAP_QUEUES_ENGINE_SEL (0 ) |PACKET3_UNMAP_QUEUES_NUM_QUEUES (1 )); -amdgpu_ring_write (kiq_ring,PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET0 (ring->doorbell_index)); -amdgpu_ring_write (kiq_ring,0 ); -amdgpu_ring_write (kiq_ring,0 ); -amdgpu_ring_write (kiq_ring,0 ); - +amdgpu_ring_write (kiq_ring,PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET0 (ring->doorbell_index)); +amdgpu_ring_write (kiq_ring,0 ); +amdgpu_ring_write (kiq_ring,0 ); +amdgpu_ring_write (kiq_ring,0 ); + } r =amdgpu_ring_test_ring (kiq_ring);if (r)DRM_ERROR ("KCQ disable failed\n" );@@ -3192,14 +3193,12 @@ static int gfx_v9_0_kcq_disable(struct amdgpu_ring *kiq_ring,struct amdgpu_ringstatic int gfx_v9_0_hw_fini (void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; -int i;amdgpu_irq_put (adev, &adev->gfx.priv_reg_irq,0 );amdgpu_irq_put (adev, &adev->gfx.priv_inst_irq,0 );/* disable KCQ to avoid CPC touch memory not valid anymore */ -for (i =0 ; i < adev->gfx.num_compute_rings; i++) -gfx_v9_0_kcq_disable (&adev->gfx.kiq.ring, &adev->gfx.compute_ring[i]); +gfx_v9_0_kcq_disable (adev);if (amdgpu_sriov_vf (adev)) {gfx_v9_0_cp_gfx_enable (adev, false); --1.9.1
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CADnq5_N4iHPVqzpATcROiwu0S3YF=E2YOBGSSp+--KCkKuh0eg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
RE: [PATCH 2/2] drm/amdgpu: Refine gfx_v9_0_kcq_disable function
Quoted 13 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Saturday, August 18, 2018 1:26 AM
To: Zhu, Rex <[email protected]>
Cc: amd-gfx list <[email protected]>
Subject: Re: [PATCH 2/2] drm/amdgpu: Refinegfx_v9_0_kcq_disablefunctionQuoted 3 lines · Rex Zhu
Send all kcq
unmap_queuepackets and then wait for complete.
Quoted 8 lines
Quoted 1 line
Signed-off-by Rex Zhu <[email protected]>This series and the gfx8 series are:
Reviewed-by Alex Deucher <[email protected]>Longer term, we may want to dynamically map and umap compute queues as part of scheduling compute work to deal with things like priorities and cu masking the the mqds, but that is a future enhancement.
Can we add a backend function in ring_funcs table for unmap_queue.
Rex
Quoted 49 lines
Alex
Quoted 23 lines
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +3
-3@@ -3160,28 +3160,29 @@ static int gfx_v9_0_hw_init(void *handle)return r; } -static int gfx_v9_0_kcq_disable (struct amdgpu_ring *kiq_ring,struct amdgpu_ring *ring) +static int gfx_v9_0_kcq_disable (struct amdgpu_device *adev) { -int r; +int r, i; +struct amdgpu_ring *kiq_ring = &adev->gfx.kiq.ring; - r =amdgpu_ring_alloc (kiq_ring,6 );drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static int gfx_v9_0_hw_init(void *handle) · line 3176
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2
-6-if (r) { + r =amdgpu_ring_alloc (kiq_ring,6 * adev->gfx.num_compute_rings); +if (r)DRM_ERROR ("Failed to lock KIQ (%d).\n" , r); -return r; - } -/* unmap queues */ -amdgpu_ring_write (kiq_ring,PACKET3 (PACKET3_UNMAP_QUEUES ,4 )); - amdgpu_ring_write(kiq_ring, /* Q_sel: 0, vmid: 0, engine: 0, num_Q: 1*/
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static int gfx_v9_0_hw_init(void *handle)
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +4
-0+for (i =0 ; i < adev->gfx.num_compute_rings; i++) { +struct amdgpu_ring *ring = &adev->gfx.compute_ring[i]; + + amdgpu_ring_write(kiq_ring,
PACKET3(PACKET3_UNMAP_QUEUES, 4));drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static int gfx_v9_0_hw_init(void *handle) · line 3179
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2
-0+ amdgpu_ring_write(kiq_ring, /* Q_sel: 0, vmid: 0, + engine: 0, num_Q: 1 */ PACKET3_UNMAP_QUEUES_ACTION(1) | /*
RESET_QUEUES*/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static int gfx_v9_0_hw_init(void *handle)
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0
-1PACKET3_UNMAP_QUEUES_QUEUE_SEL (0 ) |PACKET3_UNMAP_QUEUES_ENGINE_SEL (0 ) | PACKET3_UNMAP_QUEUES_NUM_QUEUES(1)); - amdgpu_ring_write(kiq_ring,
Quoted 38 lines
PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET0(ring->doorbell_index));drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static int gfx_v9_0_hw_init(void *handle)
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1
-4-amdgpu_ring_write (kiq_ring,0 ); -amdgpu_ring_write (kiq_ring,0 ); -amdgpu_ring_write (kiq_ring,0 ); - + amdgpu_ring_write(kiq_ring,
PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET0(ring->doorbell_index));Quoted 31 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +5
-0+amdgpu_ring_write (kiq_ring,0 ); +amdgpu_ring_write (kiq_ring,0 ); +amdgpu_ring_write (kiq_ring,0 ); + } r =amdgpu_ring_test_ring (kiq_ring);if (r) DRM_ERROR("KCQ disable failed\n"); @@ -3192,14 +3193,12 @@ static int gfx_v9_0_kcq_disable(struct amdgpu_ring*kiq_ring,struct
amdgpu_ringstatic int gfx_v9_0_hw_fini(void*handle) { struct amdgpu_device *adev = (struct amdgpu_device *)handle;drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0
-3-int i;amdgpu_irq_put (adev, &adev->gfx.priv_reg_irq,0 );amdgpu_irq_put (adev, &adev->gfx.priv_inst_irq,0 );/* disable KCQ to avoid CPC touch memory not valid anymore */ -for (i =0 ; i < adev->gfx.num_compute_rings; i++) - gfx_v9_0_kcq_disable(&adev->gfx.kiq.ring, &adev-gfx.compute_ring[i]);
+gfx_v9_0_kcq_disable(adev);if (amdgpu_sriov_vf(adev)) { gfx_v9_0_cp_gfx_enable(adev, false);--
1.9.1_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx