drm/amdgpu/gfx8: wait for completion in KIQ init
Subsystems (2)
PATCH 1/4 drm/amdgpu/gfx8: wait for completion in KIQ init
We need to make sure the various init sequences submitted to KIQ complete before testing the rings.
--- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 88 +++++++++++++++++++++++++++++++---- 1 file changed, 78 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +78 -10
@@ -4626,9 +4626,25 @@ static void gfx_v8_0_kiq_setting(struct amdgpu_ring *ring)WREG32 (mmRLC_CP_SCHEDULERS, tmp); } -static void gfx_v8_0_kiq_enable (struct amdgpu_ring *ring) +static int gfx_v8_0_kiq_enable (struct amdgpu_ring *ring) { -amdgpu_ring_alloc (ring,8 ); +struct amdgpu_device *adev = 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 ); + + r =amdgpu_ring_alloc (ring,11 ); +if (r) { +DRM_ERROR ("Failed to lock KIQ (%d).\n" , r); +amdgpu_gfx_scratch_free (adev, scratch); +return r; + }/* set resources */ amdgpu_ring_write (ring,PACKET3 (PACKET3_SET_RESOURCES ,6 ));amdgpu_ring_write (ring,0 );/* vmid_mask:0 queue_type:0 (KIQ) */
@@ -4638,20 +4654,53 @@ static void gfx_v8_0_kiq_enable(struct amdgpu_ring *ring)amdgpu_ring_write (ring,0 );/* gws mask hi */ amdgpu_ring_write (ring,0 );/* oac mask */ amdgpu_ring_write (ring,0 );/* gds heap base:0, gds heap size:0 */ +/* write to scratch for completion */ +amdgpu_ring_write (ring,PACKET3 (PACKET3_SET_UCONFIG_REG ,1 )); +amdgpu_ring_write (ring, (scratch -PACKET3_SET_UCONFIG_REG_START )); +amdgpu_ring_write (ring,0xDEADBEEF );amdgpu_ring_commit (ring); -udelay (50 ); + +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 ("KIQ enable failed (scratch(0x%04X)=0x%08X)\n" , + scratch, tmp); + r = -EINVAL ; + } +amdgpu_gfx_scratch_free (adev, scratch); + +return r; } -static void gfx_v8_0_map_queue_enable (struct amdgpu_ring *kiq_ring, -struct amdgpu_ring *ring) +static int gfx_v8_0_map_queue_enable (struct amdgpu_ring *kiq_ring, +struct amdgpu_ring *ring) {struct amdgpu_device *adev = kiq_ring->adev;uint64_t mqd_addr, wptr_addr; +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 ); mqd_addr =amdgpu_bo_gpu_offset (ring->mqd_obj); wptr_addr = adev->wb.gpu_addr + (ring->wptr_offs *4 ); -amdgpu_ring_alloc (kiq_ring,8 ); + r =amdgpu_ring_alloc (kiq_ring,11 ); +if (r) { +DRM_ERROR ("Failed to lock KIQ (%d).\n" , r); +amdgpu_gfx_scratch_free (adev, scratch); +return r; + } +/* map queues */ amdgpu_ring_write (kiq_ring,PACKET3 (PACKET3_MAP_QUEUES ,5 ));/* Q_sel:0, vmid:0, vidmem: 1, engine:0, num_Q:1*/ amdgpu_ring_write (kiq_ring,0x21010000 );
@@ -4663,8 +4712,26 @@ static void gfx_v8_0_map_queue_enable(struct amdgpu_ring *kiq_ring,amdgpu_ring_write (kiq_ring,upper_32_bits (mqd_addr));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); -udelay (50 ); + +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 %d enable failed (scratch(0x%04X)=0x%08X)\n" , + ring->idx, scratch, tmp); + r = -EINVAL ; + } +amdgpu_gfx_scratch_free (adev, scratch); + +return r; }static int gfx_v8_0_mqd_init (struct amdgpu_ring *ring)
@@ -4883,6 +4950,7 @@ static int gfx_v8_0_kiq_init_queue(struct amdgpu_ring *ring)struct vi_mqd *mqd = ring->mqd_ptr;bool is_kiq = (ring->funcs->type ==AMDGPU_RING_TYPE_KIQ );int mqd_idx =AMDGPU_MAX_COMPUTE_RINGS ; +int r;if (is_kiq) {gfx_v8_0_kiq_setting (&kiq->ring);
@@ -4921,11 +4989,11 @@ static int gfx_v8_0_kiq_init_queue(struct amdgpu_ring *ring) }if (is_kiq) -gfx_v8_0_kiq_enable (ring); + r =gfx_v8_0_kiq_enable (ring);else -gfx_v8_0_map_queue_enable (&kiq->ring, ring); + r =gfx_v8_0_map_queue_enable (&kiq->ring, ring); -return 0 ; +return r; }static int gfx_v8_0_kiq_resume (struct amdgpu_device *adev)
Signature · 6 lines
2.5.5 _______________________________________________ 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): 1490817377-1644-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org
PATCH 2/4 drm/amdgpu: split gfx_v8_0_kiq_init_queue into two
One for KIQ and one for the KCQ. This simplifies the logic and allows for future optimizations.
--- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 62 +++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 21 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +41 -21
@@ -4946,25 +4946,18 @@ static int gfx_v8_0_kiq_init_register(struct amdgpu_ring *ring)static int gfx_v8_0_kiq_init_queue (struct amdgpu_ring *ring) {struct amdgpu_device *adev = ring->adev; -struct amdgpu_kiq *kiq = &adev->gfx.kiq;struct vi_mqd *mqd = ring->mqd_ptr; -bool is_kiq = (ring->funcs->type ==AMDGPU_RING_TYPE_KIQ );int mqd_idx =AMDGPU_MAX_COMPUTE_RINGS ;int r; -if (is_kiq) { -gfx_v8_0_kiq_setting (&kiq->ring); - }else { - mqd_idx = ring - &adev->gfx.compute_ring[0 ]; - } +gfx_v8_0_kiq_setting (ring);if (!adev->gfx.in_reset && !adev->gfx.in_suspend) {memset ((void *)mqd,0 ,sizeof (*mqd));mutex_lock (&adev->srbm_mutex);vi_srbm_select (adev, ring->me, ring->pipe, ring->queue,0 );gfx_v8_0_mqd_init (ring); -if (is_kiq) -gfx_v8_0_kiq_init_register (ring); +gfx_v8_0_kiq_init_register (ring);vi_srbm_select (adev,0 ,0 ,0 ,0 );mutex_unlock (&adev->srbm_mutex);
@@ -4979,19 +4972,46 @@ static int gfx_v8_0_kiq_init_queue(struct amdgpu_ring *ring) ring->wptr =0 ;amdgpu_ring_clear_ring (ring); -if (is_kiq) { -mutex_lock (&adev->srbm_mutex); -vi_srbm_select (adev, ring->me, ring->pipe, ring->queue,0 ); -gfx_v8_0_kiq_init_register (ring); -vi_srbm_select (adev,0 ,0 ,0 ,0 ); -mutex_unlock (&adev->srbm_mutex); - } +mutex_lock (&adev->srbm_mutex); +vi_srbm_select (adev, ring->me, ring->pipe, ring->queue,0 ); +gfx_v8_0_kiq_init_register (ring); +vi_srbm_select (adev,0 ,0 ,0 ,0 ); +mutex_unlock (&adev->srbm_mutex); } -if (is_kiq) - r =gfx_v8_0_kiq_enable (ring); -else - r =gfx_v8_0_map_queue_enable (&kiq->ring, ring); + r =gfx_v8_0_kiq_enable (ring); + +return r; +} + +static int gfx_v8_0_kcq_init_queue (struct amdgpu_ring *ring) +{ +struct amdgpu_device *adev = ring->adev; +struct vi_mqd *mqd = ring->mqd_ptr; +int mqd_idx = ring - &adev->gfx.compute_ring[0 ]; +int r; + +if (!adev->gfx.in_reset && !adev->gfx.in_suspend) { +memset ((void *)mqd,0 ,sizeof (*mqd)); +mutex_lock (&adev->srbm_mutex); +vi_srbm_select (adev, ring->me, ring->pipe, ring->queue,0 ); +gfx_v8_0_mqd_init (ring); +vi_srbm_select (adev,0 ,0 ,0 ,0 ); +mutex_unlock (&adev->srbm_mutex); + +if (adev->gfx.mec.mqd_backup[mqd_idx]) +memcpy (adev->gfx.mec.mqd_backup[mqd_idx], mqd,sizeof (*mqd)); + }else {/* for GPU_RESET case */ +/* reset MQD to a clean status */ +if (adev->gfx.mec.mqd_backup[mqd_idx]) +memcpy (mqd, adev->gfx.mec.mqd_backup[mqd_idx],sizeof (*mqd)); + +/* reset ring buffer */ + ring->wptr =0 ; +amdgpu_ring_clear_ring (ring); + } + + r =gfx_v8_0_map_queue_enable (&kiq->ring, ring);return r; }
@@ -5034,7 +5054,7 @@ static int gfx_v8_0_kiq_resume(struct amdgpu_device *adev) goto done; r =amdgpu_bo_kmap (ring->mqd_obj, &ring->mqd_ptr);if (!r) { - r =gfx_v8_0_kiq_init_queue (ring); + r =gfx_v8_0_kcq_init_queue (ring);amdgpu_bo_kunmap (ring->mqd_obj); ring->mqd_ptr =NULL ; }
Signature · 6 lines
2.5.5 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/4 drm/amdgpu/gfx8: wait once for all KCQs to be created
In reply to a message not in the archiveRather than waiting for each queue.
--- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 57 +++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +31 -26
@@ -4676,11 +4676,9 @@ static int gfx_v8_0_kiq_enable(struct amdgpu_ring *ring)return r; } -static int gfx_v8_0_map_queue_enable (struct amdgpu_ring *kiq_ring, -struct amdgpu_ring *ring) +static int gfx_v8_0_map_queues_enable (struct amdgpu_device *adev) { -struct amdgpu_device *adev = kiq_ring->adev; -uint64_t mqd_addr, wptr_addr; +struct amdgpu_ring *kiq_ring = &adev->gfx.kiq.ring;uint32_t scratch, tmp =0 ;int r, i;
@@ -4691,27 +4689,30 @@ static int gfx_v8_0_map_queue_enable(struct amdgpu_ring *kiq_ring, }WREG32 (scratch,0xCAFEDEAD ); - mqd_addr =amdgpu_bo_gpu_offset (ring->mqd_obj); - wptr_addr = adev->wb.gpu_addr + (ring->wptr_offs *4 ); - - r =amdgpu_ring_alloc (kiq_ring,11 ); + r =amdgpu_ring_alloc (kiq_ring, (8 * adev->gfx.num_compute_rings) +3 );if (r) {DRM_ERROR ("Failed to lock KIQ (%d).\n" , r);amdgpu_gfx_scratch_free (adev, scratch);return r; } -/* map queues */ -amdgpu_ring_write (kiq_ring,PACKET3 (PACKET3_MAP_QUEUES ,5 )); -/* Q_sel:0, vmid:0, vidmem: 1, engine:0, num_Q:1*/ -amdgpu_ring_write (kiq_ring,0x21010000 ); -amdgpu_ring_write (kiq_ring, (ring->doorbell_index <<2 ) | - (ring->queue <<26 ) | - (ring->pipe <<29 ) | - ((ring->me ==1 ?0 :1 ) <<31 ));/* doorbell */ -amdgpu_ring_write (kiq_ring,lower_32_bits (mqd_addr)); -amdgpu_ring_write (kiq_ring,upper_32_bits (mqd_addr)); -amdgpu_ring_write (kiq_ring,lower_32_bits (wptr_addr)); -amdgpu_ring_write (kiq_ring,upper_32_bits (wptr_addr)); +for (i =0 ; i < adev->gfx.num_compute_rings; i++) { +struct amdgpu_ring *ring = &adev->gfx.compute_ring[i]; +uint64_t mqd_addr =amdgpu_bo_gpu_offset (ring->mqd_obj); +uint64_t wptr_addr = adev->wb.gpu_addr + (ring->wptr_offs *4 ); + +/* map queues */ +amdgpu_ring_write (kiq_ring,PACKET3 (PACKET3_MAP_QUEUES ,5 )); +/* Q_sel:0, vmid:0, vidmem: 1, engine:0, num_Q:1*/ +amdgpu_ring_write (kiq_ring,0x21010000 ); +amdgpu_ring_write (kiq_ring, (ring->doorbell_index <<2 ) | + (ring->queue <<26 ) | + (ring->pipe <<29 ) | + ((ring->me ==1 ?0 :1 ) <<31 ));/* doorbell */ +amdgpu_ring_write (kiq_ring,lower_32_bits (mqd_addr)); +amdgpu_ring_write (kiq_ring,upper_32_bits (mqd_addr)); +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 ));
@@ -4725,8 +4726,8 @@ static int gfx_v8_0_map_queue_enable(struct amdgpu_ring *kiq_ring,DRM_UDELAY (1 ); }if (i >= adev->usec_timeout) { -DRM_ERROR ("KCQ %d enable failed (scratch(0x%04X)=0x%08X)\n" , - ring->idx, scratch, tmp); +DRM_ERROR ("KCQ enable failed (scratch(0x%04X)=0x%08X)\n" , + scratch, tmp); r = -EINVAL ; }amdgpu_gfx_scratch_free (adev, scratch);
@@ -4989,7 +4990,6 @@ static int gfx_v8_0_kcq_init_queue(struct amdgpu_ring *ring)struct amdgpu_device *adev = ring->adev;struct vi_mqd *mqd = ring->mqd_ptr;int mqd_idx = ring - &adev->gfx.compute_ring[0 ]; -int r;if (!adev->gfx.in_reset && !adev->gfx.in_suspend) {memset ((void *)mqd,0 ,sizeof (*mqd));
@@ -5011,9 +5011,7 @@ static int gfx_v8_0_kcq_init_queue(struct amdgpu_ring *ring)amdgpu_ring_clear_ring (ring); } - r =gfx_v8_0_map_queue_enable (&kiq->ring, ring); - -return r; +return 0 ; }static int gfx_v8_0_kiq_resume (struct amdgpu_device *adev)
@@ -5061,7 +5059,14 @@ static int gfx_v8_0_kiq_resume(struct amdgpu_device *adev)amdgpu_bo_unreserve (ring->mqd_obj);if (r) goto done; + } + r =gfx_v8_0_map_queues_enable (adev); +if (r) + goto done; + +for (i =0 ; i < adev->gfx.num_compute_rings; i++) { + ring = &adev->gfx.compute_ring[i]; ring->ready = true; r =amdgpu_ring_test_ring (ring);if (r)
Signature · 6 lines
2.5.5 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/4 drm/amdgpu/gfx8: move SET_RESOURCES into the same command stream
In reply to a message not in the archiveAs the KCQ setup. This way we only have to wait once for the entire MEC.
--- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 87 +++++++++-------------------------- 1 file changed, 23 insertions(+), 64 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +23 -64
@@ -4626,57 +4626,7 @@ static void gfx_v8_0_kiq_setting(struct amdgpu_ring *ring)WREG32 (mmRLC_CP_SCHEDULERS, tmp); } -static int gfx_v8_0_kiq_enable (struct amdgpu_ring *ring) -{ -struct amdgpu_device *adev = 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 ); - - r =amdgpu_ring_alloc (ring,11 ); -if (r) { -DRM_ERROR ("Failed to lock KIQ (%d).\n" , r); -amdgpu_gfx_scratch_free (adev, scratch); -return r; - } -/* set resources */ -amdgpu_ring_write (ring,PACKET3 (PACKET3_SET_RESOURCES ,6 )); -amdgpu_ring_write (ring,0 );/* vmid_mask:0 queue_type:0 (KIQ) */ -amdgpu_ring_write (ring,0x000000FF );/* queue mask lo */ -amdgpu_ring_write (ring,0 );/* queue mask hi */ -amdgpu_ring_write (ring,0 );/* gws mask lo */ -amdgpu_ring_write (ring,0 );/* gws mask hi */ -amdgpu_ring_write (ring,0 );/* oac mask */ -amdgpu_ring_write (ring,0 );/* gds heap base:0, gds heap size:0 */ -/* write to scratch for completion */ -amdgpu_ring_write (ring,PACKET3 (PACKET3_SET_UCONFIG_REG ,1 )); -amdgpu_ring_write (ring, (scratch -PACKET3_SET_UCONFIG_REG_START )); -amdgpu_ring_write (ring,0xDEADBEEF ); -amdgpu_ring_commit (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 ("KIQ enable failed (scratch(0x%04X)=0x%08X)\n" , - scratch, tmp); - r = -EINVAL ; - } -amdgpu_gfx_scratch_free (adev, scratch); - -return r; -} - -static int gfx_v8_0_map_queues_enable (struct amdgpu_device *adev) +static int gfx_v8_0_kiq_kcq_enable (struct amdgpu_device *adev) {struct amdgpu_ring *kiq_ring = &adev->gfx.kiq.ring;uint32_t scratch, tmp =0 ;
@@ -4689,12 +4639,21 @@ static int gfx_v8_0_map_queues_enable(struct amdgpu_device *adev) }WREG32 (scratch,0xCAFEDEAD ); - r =amdgpu_ring_alloc (kiq_ring, (8 * adev->gfx.num_compute_rings) +3 ); + r =amdgpu_ring_alloc (kiq_ring, (8 * adev->gfx.num_compute_rings) +11 );if (r) {DRM_ERROR ("Failed to lock KIQ (%d).\n" , r);amdgpu_gfx_scratch_free (adev, scratch);return r; } +/* set resources */ +amdgpu_ring_write (kiq_ring,PACKET3 (PACKET3_SET_RESOURCES ,6 )); +amdgpu_ring_write (kiq_ring,0 );/* vmid_mask:0 queue_type:0 (KIQ) */ +amdgpu_ring_write (kiq_ring,0x000000FF );/* queue mask lo */ +amdgpu_ring_write (kiq_ring,0 );/* queue mask hi */ +amdgpu_ring_write (kiq_ring,0 );/* gws mask lo */ +amdgpu_ring_write (kiq_ring,0 );/* gws mask hi */ +amdgpu_ring_write (kiq_ring,0 );/* oac mask */ +amdgpu_ring_write (kiq_ring,0 );/* gds heap base:0, gds heap size:0 */ for (i =0 ; i < adev->gfx.num_compute_rings; i++) {struct amdgpu_ring *ring = &adev->gfx.compute_ring[i];uint64_t mqd_addr =amdgpu_bo_gpu_offset (ring->mqd_obj);
@@ -4949,7 +4908,6 @@ static int gfx_v8_0_kiq_init_queue(struct amdgpu_ring *ring)struct amdgpu_device *adev = ring->adev;struct vi_mqd *mqd = ring->mqd_ptr;int mqd_idx =AMDGPU_MAX_COMPUTE_RINGS ; -int r;gfx_v8_0_kiq_setting (ring);
@@ -4980,9 +4938,7 @@ static int gfx_v8_0_kiq_init_queue(struct amdgpu_ring *ring)mutex_unlock (&adev->srbm_mutex); } - r =gfx_v8_0_kiq_enable (ring); - -return r; +return 0 ; }static int gfx_v8_0_kcq_init_queue (struct amdgpu_ring *ring)
@@ -5037,13 +4993,6 @@ static int gfx_v8_0_kiq_resume(struct amdgpu_device *adev)if (r) goto done; - ring->ready = true; - r =amdgpu_ring_test_ring (ring); -if (r) { - ring->ready = false; - goto done; - } -for (i =0 ; i < adev->gfx.num_compute_rings; i++) { ring = &adev->gfx.compute_ring[i];
@@ -5061,10 +5010,20 @@ static int gfx_v8_0_kiq_resume(struct amdgpu_device *adev) goto done; } - r =gfx_v8_0_map_queues_enable (adev); + r =gfx_v8_0_kiq_kcq_enable (adev);if (r) goto done; +/* Test KIQ */ + ring = &adev->gfx.kiq.ring; + ring->ready = true; + r =amdgpu_ring_test_ring (ring); +if (r) { + ring->ready = false; + goto done; + } + +/* Test KCQs */ for (i =0 ; i < adev->gfx.num_compute_rings; i++) { ring = &adev->gfx.compute_ring[i]; ring->ready = true;
Signature · 6 lines
2.5.5 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
Reviewed-byAm 29.03.2017 um 21:56 schrieb Alex Deucher:
Quoted 4 lines
We need to make sure the various init sequences submitted to KIQ complete before testing the rings.
Signed-off-by Alex Deucher <[email protected]>
Quoted 135 lines
--- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 88 +++++++++++++++++++++++++++++++---- 1 file changed, 78 insertions(+), 10 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +75
-8@@ -4626,9 +4626,25 @@ static void gfx_v8_0_kiq_setting(struct amdgpu_ring *ring)WREG32 (mmRLC_CP_SCHEDULERS, tmp); } -static void gfx_v8_0_kiq_enable (struct amdgpu_ring *ring) +static int gfx_v8_0_kiq_enable (struct amdgpu_ring *ring) { -amdgpu_ring_alloc (ring,8 ); +struct amdgpu_device *adev = 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 ); + + r =amdgpu_ring_alloc (ring,11 ); +if (r) { +DRM_ERROR ("Failed to lock KIQ (%d).\n" , r); +amdgpu_gfx_scratch_free (adev, scratch); +return r; + }/* set resources */ amdgpu_ring_write (ring,PACKET3 (PACKET3_SET_RESOURCES ,6 ));amdgpu_ring_write (ring,0 );/* vmid_mask:0 queue_type:0 (KIQ) */ @@ -4638,20 +4654,53 @@ static void gfx_v8_0_kiq_enable(struct amdgpu_ring *ring)amdgpu_ring_write (ring,0 );/* gws mask hi */ amdgpu_ring_write (ring,0 );/* oac mask */ amdgpu_ring_write (ring,0 );/* gds heap base:0, gds heap size:0 */ +/* write to scratch for completion */ +amdgpu_ring_write (ring,PACKET3 (PACKET3_SET_UCONFIG_REG ,1 )); +amdgpu_ring_write (ring, (scratch -PACKET3_SET_UCONFIG_REG_START )); +amdgpu_ring_write (ring,0xDEADBEEF );amdgpu_ring_commit (ring); -udelay (50 ); + +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 ("KIQ enable failed (scratch(0x%04X)=0x%08X)\n" , + scratch, tmp); + r = -EINVAL ; + } +amdgpu_gfx_scratch_free (adev, scratch); + +return r; } -static void gfx_v8_0_map_queue_enable (struct amdgpu_ring *kiq_ring, -struct amdgpu_ring *ring) +static int gfx_v8_0_map_queue_enable (struct amdgpu_ring *kiq_ring, +struct amdgpu_ring *ring) {struct amdgpu_device *adev = kiq_ring->adev;uint64_t mqd_addr, wptr_addr; +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 ); mqd_addr =amdgpu_bo_gpu_offset (ring->mqd_obj); wptr_addr = adev->wb.gpu_addr + (ring->wptr_offs *4 ); -amdgpu_ring_alloc (kiq_ring,8 ); + r =amdgpu_ring_alloc (kiq_ring,11 ); +if (r) { +DRM_ERROR ("Failed to lock KIQ (%d).\n" , r); +amdgpu_gfx_scratch_free (adev, scratch); +return r; + } +/* map queues */ amdgpu_ring_write (kiq_ring,PACKET3 (PACKET3_MAP_QUEUES ,5 ));/* Q_sel:0, vmid:0, vidmem: 1, engine:0, num_Q:1*/ amdgpu_ring_write (kiq_ring,0x21010000 );@@ -4663,8 +4712,26 @@ static void gfx_v8_0_map_queue_enable(struct amdgpu_ring *kiq_ring,amdgpu_ring_write (kiq_ring,upper_32_bits (mqd_addr));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); -udelay (50 ); + +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 %d enable failed (scratch(0x%04X)=0x%08X)\n" , + ring->idx, scratch, tmp); + r = -EINVAL ; + } +amdgpu_gfx_scratch_free (adev, scratch); + +return r; }static int gfx_v8_0_mqd_init (struct amdgpu_ring *ring)@@ -4883,6 +4950,7 @@ static int gfx_v8_0_kiq_init_queue(struct amdgpu_ring *ring)struct vi_mqd *mqd = ring->mqd_ptr;bool is_kiq = (ring->funcs->type ==AMDGPU_RING_TYPE_KIQ );int mqd_idx =AMDGPU_MAX_COMPUTE_RINGS ; +int r;if (is_kiq) {gfx_v8_0_kiq_setting (&kiq->ring);@@ -4921,11 +4989,11 @@ static int gfx_v8_0_kiq_init_queue(struct amdgpu_ring *ring) }if (is_kiq) -gfx_v8_0_kiq_enable (ring);
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c static int gfx_v8_0_kiq_init_queue(struct amdgpu_ring *ring) · line 4999
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +3
-2+ r =gfx_v8_0_kiq_enable (ring); else -gfx_v8_0_map_queue_enable (&kiq->ring, ring); + r =gfx_v8_0_map_queue_enable (&kiq->ring, ring); -return 0 ; +return r; }static int gfx_v8_0_kiq_resume (struct amdgpu_device *adev)
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx