drm/amdgpu: protect kiq overrun
Subsystems (3)
PATCH 1/1 drm/amdgpu: protect kiq overrun
Wait for the oldest sequence on the kiq ring
to be signaled in order to make sure there
will be no kiq overrun.
v2: remove unused the variable and correct
kiq max_sub_num value
--- .../drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c | 6 ++++ .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c | 6 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 30 +++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 3 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 6 ++++ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 6 ++++ drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 7 +++++ drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 7 +++++ 8 files changed, 71 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c +6 -0
@@ -325,6 +325,12 @@ static int kgd_hiq_mqd_load(struct kgd_dev *kgd, void *mqd, mec, pipe, queue_id);spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +pr_err ("critical bug! too many kiq submission\n" ); + goto out_unlock; + } + r =amdgpu_ring_alloc (kiq_ring,7 );if (r) {pr_err ("Failed to alloc KIQ (%d).\n" , r);
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +6 -0
@@ -323,6 +323,12 @@ int kgd_gfx_v9_hiq_mqd_load(struct kgd_dev *kgd, void *mqd, mec, pipe, queue_id);spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +pr_err ("critical bug! too many kiq submissions\n" ); + goto out_unlock; + } + r =amdgpu_ring_alloc (kiq_ring,7 );if (r) {pr_err ("Failed to alloc KIQ (%d).\n" , r);
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +30 -0
@@ -321,6 +321,9 @@ int amdgpu_gfx_kiq_init_ring(struct amdgpu_device *adev, AMDGPU_RING_PRIO_DEFAULT);if (r)dev_warn (adev->dev,"(%d) failed to init kiq ring\n" , r); +else + kiq->max_sub_num = (ring->ring_size /4 ) / + (ring->funcs->align_mask +1 );return r; }
@@ -663,6 +666,21 @@ int amdgpu_gfx_cp_ecc_error_irq(struct amdgpu_device *adev,return 0 ; } +int amdgpu_gfx_kiq_is_avail (struct amdgpu_kiq *kiq) +{ +uint32_t seq =0 ; +signed long r =0 ; + + seq =abs (kiq->ring.fence_drv.sync_seq - kiq->max_sub_num); +if (seq > kiq->max_sub_num) { + r =amdgpu_fence_wait_polling (&kiq->ring, seq, +MAX_KIQ_REG_WAIT ); +return r <1 ? -ETIME :0 ; + } + +return 0 ; +} +uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg) {signed long r, cnt =0 ;
@@ -674,6 +692,12 @@ uint32_t amdgpu_kiq_rreg(struct amdgpu_device *adev, uint32_t reg)BUG_ON (!ring->funcs->emit_rreg);spin_lock_irqsave (&kiq->ring_lock, flags); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq_read; + } +if (amdgpu_device_wb_get (adev, ®_val_offs)) {spin_unlock_irqrestore (&kiq->ring_lock, flags);pr_err ("critical bug! too many kiq readers\n" );
@@ -728,6 +752,12 @@ void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v)BUG_ON (!ring->funcs->emit_wreg);spin_lock_irqsave (&kiq->ring_lock, flags); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq_write; + } +amdgpu_ring_alloc (ring,32 );amdgpu_ring_emit_wreg (ring, reg, v);amdgpu_fence_emit_polling (ring, &seq);
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +3 -0
@@ -103,6 +103,7 @@ struct amdgpu_kiq {struct amdgpu_ring ring;struct amdgpu_irq_src irq;const struct kiq_pm4_funcs *pmf; +uint32_t max_sub_num; };/*
@@ -387,4 +388,6 @@ int amdgpu_gfx_cp_ecc_error_irq(struct amdgpu_device *adev, struct amdgpu_iv_entry *entry);uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg);void amdgpu_kiq_wreg (struct amdgpu_device *adev,uint32_t reg,uint32_t v); + +int amdgpu_gfx_kiq_is_avail (struct amdgpu_kiq *kiq);#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +6 -0
@@ -57,6 +57,12 @@ void amdgpu_virt_kiq_reg_write_reg_wait(struct amdgpu_device *adev,uint32_t seq;spin_lock_irqsave (&kiq->ring_lock, flags); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq; + } +amdgpu_ring_alloc (ring,32 );amdgpu_ring_emit_reg_write_reg_wait (ring, reg0, reg1, ref, mask);
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +6 -0
@@ -4051,6 +4051,12 @@ static uint64_t gfx_v9_0_kiq_read_clock(struct amdgpu_device *adev)BUG_ON (!ring->funcs->emit_rreg);spin_lock_irqsave (&kiq->ring_lock, flags); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq_read; + } +if (amdgpu_device_wb_get (adev, ®_val_offs)) {spin_unlock_irqrestore (&kiq->ring_lock, flags);pr_err ("critical bug! too many kiq readers\n" );
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +7 -0
@@ -423,6 +423,13 @@ static int gmc_v10_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,if (amdgpu_emu_mode ==0 && ring->sched.ready) {spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock (&kiq->ring_lock); +DRM_ERROR ("too many kiq submissions\n" ); +return -ETIME ; + } +/* 2 dwords flush + 8 dwords fence */ amdgpu_ring_alloc (ring, kiq->pmf->invalidate_tlbs_size +8 ); kiq->pmf->kiq_invalidate_tlbs(ring,
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +7 -0
@@ -614,6 +614,13 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, ndw += kiq->pmf->invalidate_tlbs_size;spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock (&kiq->ring_lock); +DRM_ERROR ("critical bug! too many kiq submissions\n" ); +return -ETIME ; + } +/* 2 dwords flush + 8 dwords fence */ amdgpu_ring_alloc (ring, ndw);if (vega20_xgmi_wa)
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
[AMD Official Use Only - Internal Distribution Only]
I think each kiq operation will call ring_alloc for the package space , why not just check whether this allocation is succeed or not ?
Shaoyun.liu
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Yintian Tao
Sent: Wednesday, April 22, 2020 10:50 AM
To: Koenig, Christian <[email protected]>; Liu, Monk <[email protected]>; Kuehling, Felix <[email protected]>
Cc: [email protected]; Tao, Yintian <[email protected]>
Subject: [PATCH] drm/amdgpu: protect kiq overrun
Wait for the oldest sequence on the kiq ring to be signaled in order to make sure there will be no kiq overrun.
v2: remove unused the variable and correct
kiq max_sub_num value
--- .../drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c | 6 ++++ .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c | 6 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 30 +++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 3 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 6 ++++ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 6 ++++ drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 7 +++++ drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 7 +++++ 8 files changed, 71 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c +6 -0
@@ -325,6 +325,12 @@ static int kgd_hiq_mqd_load(struct kgd_dev *kgd, void *mqd, mec, pipe, queue_id);spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +pr_err ("critical bug! too many kiq submission\n" ); + goto out_unlock; + } + r =amdgpu_ring_alloc (kiq_ring,7 );if (r) { pr_err("Failed to alloc KIQ (%d).\n", r); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c
index df841c2ac5e7..fd42c126510f 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +6 -0
@@ -323,6 +323,12 @@ int kgd_gfx_v9_hiq_mqd_load(struct kgd_dev *kgd, void *mqd, mec, pipe, queue_id);spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +pr_err ("critical bug! too many kiq submissions\n" ); + goto out_unlock; + } + r =amdgpu_ring_alloc (kiq_ring,7 );if (r) { pr_err("Failed to alloc KIQ (%d).\n", r); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index a721b0e0ff69..84e66c45df37 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +23 -0
@@ -321,6 +321,9 @@ int amdgpu_gfx_kiq_init_ring(struct amdgpu_device *adev, AMDGPU_RING_PRIO_DEFAULT);if (r)dev_warn (adev->dev,"(%d) failed to init kiq ring\n" , r); +else + kiq->max_sub_num = (ring->ring_size /4 ) / + (ring->funcs->align_mask +1 );return r; }
@@ -663,6 +666,21 @@ int amdgpu_gfx_cp_ecc_error_irq(struct amdgpu_device *adev,return 0 ; } +int amdgpu_gfx_kiq_is_avail (struct amdgpu_kiq *kiq) { +uint32_t seq =0 ; +signed long r =0 ; + + seq =abs (kiq->ring.fence_drv.sync_seq - kiq->max_sub_num); +if (seq > kiq->max_sub_num) { + r =amdgpu_fence_wait_polling (&kiq->ring, seq, +MAX_KIQ_REG_WAIT ); +return r <1 ? -ETIME :0 ; + } + +return 0 ; +} +uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg) {signed long r, cnt =0 ;
@@ -674,6 +692,12 @@ uint32_t amdgpu_kiq_rreg(struct amdgpu_device *adev, uint32_t reg)BUG_ON (!ring->funcs->emit_rreg);spin_lock_irqsave (&kiq->ring_lock, flags); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq_read; + } +if (amdgpu_device_wb_get (adev, ®_val_offs)) {spin_unlock_irqrestore (&kiq->ring_lock, flags); pr_err("critical bug! too many kiq readers\n"); @@ -728,6 +752,12 @@ void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v)
BUG_ON(!ring->funcs->emit_wreg);
spin_lock_irqsave(&kiq->ring_lock, flags);
+ r = amdgpu_gfx_kiq_is_avail(&adev->gfx.kiq);
+ if (r) {
+ spin_unlock_irqrestore(&kiq->ring_lock, flags);
+ goto failed_kiq_write;
+ }
+
amdgpu_ring_alloc(ring, 32);
amdgpu_ring_emit_wreg(ring, reg, v);
amdgpu_fence_emit_polling(ring, &seq); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
index ee698f0246d8..1ee59a927bd9 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +3 -0
@@ -103,6 +103,7 @@ struct amdgpu_kiq {struct amdgpu_ring ring;struct amdgpu_irq_src irq;const struct kiq_pm4_funcs *pmf; +uint32_t max_sub_num; };/*
@@ -387,4 +388,6 @@ int amdgpu_gfx_cp_ecc_error_irq(struct amdgpu_device *adev, struct amdgpu_iv_entry *entry);uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg);void amdgpu_kiq_wreg (struct amdgpu_device *adev,uint32_t reg,uint32_t v); + +int amdgpu_gfx_kiq_is_avail (struct amdgpu_kiq *kiq);#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +6 -0
@@ -57,6 +57,12 @@ void amdgpu_virt_kiq_reg_write_reg_wait(struct amdgpu_device *adev,uint32_t seq;spin_lock_irqsave (&kiq->ring_lock, flags); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq; + } +amdgpu_ring_alloc (ring,32 );amdgpu_ring_emit_reg_write_reg_wait (ring, reg0, reg1, ref, mask);
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +6 -0
@@ -4051,6 +4051,12 @@ static uint64_t gfx_v9_0_kiq_read_clock(struct amdgpu_device *adev)BUG_ON (!ring->funcs->emit_rreg);spin_lock_irqsave (&kiq->ring_lock, flags); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq_read; + } +if (amdgpu_device_wb_get (adev, ®_val_offs)) {spin_unlock_irqrestore (&kiq->ring_lock, flags); pr_err("critical bug! too many kiq readers\n"); diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
index 30b75d79efdb..77d8bc9c0111 100644
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +7 -0
@@ -423,6 +423,13 @@ static int gmc_v10_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,if (amdgpu_emu_mode ==0 && ring->sched.ready) {spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock (&kiq->ring_lock); +DRM_ERROR ("too many kiq submissions\n" ); +return -ETIME ; + } +/* 2 dwords flush + 8 dwords fence */ amdgpu_ring_alloc (ring, kiq->pmf->invalidate_tlbs_size +8 ); kiq->pmf->kiq_invalidate_tlbs(ring,
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +7 -0
@@ -614,6 +614,13 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, ndw += kiq->pmf->invalidate_tlbs_size;spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock (&kiq->ring_lock); +DRM_ERROR ("critical bug! too many kiq submissions\n" ); +return -ETIME ; + } +/* 2 dwords flush + 8 dwords fence */ amdgpu_ring_alloc (ring, ndw);if (vega20_xgmi_wa)
--
2.17.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7CShaoyun.Liu%40amd.com%7C0cd26307c0a149ebe0bd08d7e6cc84b1%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637231638419034830&sdata=rxkhyMutFwbe5Nw%2BeBGiESW9wTdflDUo%2F4xEvbCbR6U%3D&reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
maintainerThe amdgpu_ring_alloc() function checks if the requested number of DW don't exceed the maximum submission size.
It does NOT check if there is enough room on the ring. That would require MMIO access and that is what we want to avoid.
Regards,
Christian.
Am 22.04.20 um 16:54 schrieb Liu, Shaoyun:
Quoted 210 lines
[AMD Official Use Only - Internal Distribution Only]
I think each kiq operation will call
ring_allocfor the package space , why not just check whether this allocation is succeed or not ?Shaoyun.liu
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Yintian Tao
Sent: Wednesday, April 22, 2020 10:50 AM
To: Koenig, Christian <[email protected]>; Liu, Monk <[email protected]>; Kuehling, Felix <[email protected]>
Cc: [email protected]; Tao, Yintian <[email protected]>
Subject: [PATCH] drm/amdgpu: protect kiq overrunWait for the oldest sequence on the kiq ring to be signaled in order to make sure there will be no kiq overrun.
v2: remove unused the variable and correct
kiqmax_sub_numvalueSigned-off-by Yintian Tao <[email protected]>--- .../drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c | 6 ++++ .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c | 6 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 30 +++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 3 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 6 ++++ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 6 ++++ drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 7 +++++ drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 7 +++++ 8 files changed, 71 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c +6
-0@@ -325,6 +325,12 @@ static int kgd_hiq_mqd_load(struct kgd_dev *kgd, void *mqd, mec, pipe, queue_id);spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +pr_err ("critical bug! too many kiq submission\n" ); + goto out_unlock; + } + r =amdgpu_ring_alloc (kiq_ring,7 );if (r) { pr_err("Failed to alloc KIQ (%d).\n", r); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.cindex
df841c2ac5e7..fd42c126510f100644drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +6
-0@@ -323,6 +323,12 @@ int kgd_gfx_v9_hiq_mqd_load(struct kgd_dev *kgd, void *mqd, mec, pipe, queue_id);spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +pr_err ("critical bug! too many kiq submissions\n" ); + goto out_unlock; + } + r =amdgpu_ring_alloc (kiq_ring,7 );if (r) { pr_err("Failed to alloc KIQ (%d).\n", r); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.cindex
a721b0e0ff69..84e66c45df37100644drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +23
-0@@ -321,6 +321,9 @@ int amdgpu_gfx_kiq_init_ring(struct amdgpu_device *adev, AMDGPU_RING_PRIO_DEFAULT);if (r)dev_warn (adev->dev,"(%d) failed to init kiq ring\n" , r); +else + kiq->max_sub_num = (ring->ring_size /4 ) / + (ring->funcs->align_mask +1 );return r; }@@ -663,6 +666,21 @@ int amdgpu_gfx_cp_ecc_error_irq(struct amdgpu_device *adev,return 0 ; } +int amdgpu_gfx_kiq_is_avail (struct amdgpu_kiq *kiq) { +uint32_t seq =0 ; +signed long r =0 ; + + seq =abs (kiq->ring.fence_drv.sync_seq - kiq->max_sub_num); +if (seq > kiq->max_sub_num) { + r =amdgpu_fence_wait_polling (&kiq->ring, seq, +MAX_KIQ_REG_WAIT ); +return r <1 ? -ETIME :0 ; + } + +return 0 ; +} +uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg) {signed long r, cnt =0 ;@@ -674,6 +692,12 @@ uint32_t amdgpu_kiq_rreg(struct amdgpu_device *adev, uint32_t reg)BUG_ON (!ring->funcs->emit_rreg);spin_lock_irqsave (&kiq->ring_lock, flags); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq_read; + } +if (amdgpu_device_wb_get (adev, ®_val_offs)) {spin_unlock_irqrestore (&kiq->ring_lock, flags); pr_err("critical bug! too many kiq readers\n"); @@ -728,6 +752,12 @@ void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v)BUG_ON(!ring->funcs->emit_wreg); spin_lock_irqsave(&kiq->ring_lock, flags);drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +6
-0+ r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq_write; + } +amdgpu_ring_alloc (ring,32 );amdgpu_ring_emit_wreg (ring, reg, v); amdgpu_fence_emit_polling(ring, &seq); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.hindex
ee698f0246d8..1ee59a927bd9100644drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +3
-0@@ -103,6 +103,7 @@ struct amdgpu_kiq {struct amdgpu_ring ring;struct amdgpu_irq_src irq;const struct kiq_pm4_funcs *pmf; +uint32_t max_sub_num; };/* @@ -387,4 +388,6 @@ int amdgpu_gfx_cp_ecc_error_irq(struct amdgpu_device *adev, struct amdgpu_iv_entry *entry);uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg);void amdgpu_kiq_wreg (struct amdgpu_device *adev,uint32_t reg,uint32_t v); + +int amdgpu_gfx_kiq_is_avail (struct amdgpu_kiq *kiq);#endif drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +6
-0@@ -57,6 +57,12 @@ void amdgpu_virt_kiq_reg_write_reg_wait(struct amdgpu_device *adev,uint32_t seq;spin_lock_irqsave (&kiq->ring_lock, flags); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq; + } +amdgpu_ring_alloc (ring,32 );amdgpu_ring_emit_reg_write_reg_wait (ring, reg0, reg1, ref, mask);drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +6
-0@@ -4051,6 +4051,12 @@ static uint64_t gfx_v9_0_kiq_read_clock(struct amdgpu_device *adev)BUG_ON (!ring->funcs->emit_rreg);spin_lock_irqsave (&kiq->ring_lock, flags); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq_read; + } +if (amdgpu_device_wb_get (adev, ®_val_offs)) {spin_unlock_irqrestore (&kiq->ring_lock, flags); pr_err("critical bug! too many kiq readers\n"); diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.cindex
30b75d79efdb..77d8bc9c0111100644drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +7
-0@@ -423,6 +423,13 @@ static int gmc_v10_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,if (amdgpu_emu_mode ==0 && ring->sched.ready) {spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock (&kiq->ring_lock); +DRM_ERROR ("too many kiq submissions\n" ); +return -ETIME ; + } +/* 2 dwords flush + 8 dwords fence */ amdgpu_ring_alloc (ring, kiq->pmf->invalidate_tlbs_size +8 ); kiq->pmf->kiq_invalidate_tlbs(ring,drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +7
-1@@ -614,6 +614,13 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, ndw += kiq->pmf->invalidate_tlbs_size;spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock (&kiq->ring_lock); +DRM_ERROR ("critical bug! too many kiq submissions\n" ); +return -ETIME ; + } +/* 2 dwords flush + 8 dwords fence */ amdgpu_ring_alloc (ring, ndw);if (vega20_xgmi_wa) --2.17.1
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7CShaoyun.Liu%40amd.com%7C0cd26307c0a149ebe0bd08d7e6cc84b1%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637231638419034830&sdata=rxkhyMutFwbe5Nw%2BeBGiESW9wTdflDUo%2F4xEvbCbR6U%3D&reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
[AMD Official Use Only - Internal Distribution Only]
I always has an impression for each submission, once the ring be allocated , before the fence be signed , this ring space will always be reserved . If this can not be guaranteed , it sound a big issue to me . Can't we check the rptr write back to determine the available room in the ring_alloc ?
Regards
Shaoyun.liu
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, April 22, 2020 10:57 AM
To: Liu, Shaoyun <[email protected]>; Tao, Yintian <[email protected]>; Liu, Monk <[email protected]>; Kuehling, Felix <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] drm/amdgpu: protect kiq overrun
The amdgpu_ring_alloc() function checks if the requested number of DW don't exceed the maximum submission size.
It does NOT check if there is enough room on the ring. That would require MMIO access and that is what we want to avoid.
Regards,
Christian.
Am 22.04.20 um 16:54 schrieb Liu, Shaoyun:
Quoted 227 lines
[AMD Official Use Only - Internal Distribution Only]
I think each kiq operation will call
ring_allocfor the package space , why not just check whether this allocation is succeed or not ?Shaoyun.liu
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Yintian Tao
Sent: Wednesday, April 22, 2020 10:50 AM
To: Koenig, Christian <[email protected]>; Liu, Monk <[email protected]>; Kuehling, Felix <[email protected]>
Cc: [email protected]; Tao, Yintian <[email protected]>
Subject: [PATCH] drm/amdgpu: protect kiq overrunWait for the oldest sequence on the kiq ring to be signaled in order to make sure there will be no kiq overrun.
v2: remove unused the variable and correct
kiqmax_sub_numvalueSigned-off-by Yintian Tao <[email protected]>--- .../drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c | 6 ++++ .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c | 6 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 30 +++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 3 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 6 ++++ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 6 ++++ drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 7 +++++ drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 7 +++++ 8 files changed, 71 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c +6
-0@@ -325,6 +325,12 @@ static int kgd_hiq_mqd_load(struct kgd_dev *kgd, void *mqd, mec, pipe, queue_id);spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +pr_err ("critical bug! too many kiq submission\n" ); + goto out_unlock; + } + r =amdgpu_ring_alloc (kiq_ring,7 );if (r) { pr_err("Failed to alloc KIQ (%d).\n", r); diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.cindexdf841c2ac5e7..fd42c126510f100644drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +6
-0@@ -323,6 +323,12 @@ int kgd_gfx_v9_hiq_mqd_load(struct kgd_dev *kgd, void *mqd, mec, pipe, queue_id);spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +pr_err ("critical bug! too many kiq submissions\n" ); + goto out_unlock; + } + r =amdgpu_ring_alloc (kiq_ring,7 );if (r) { pr_err("Failed to alloc KIQ (%d).\n", r); diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
indexa721b0e0ff69..84e66c45df37100644drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +23
-0@@ -321,6 +321,9 @@ int amdgpu_gfx_kiq_init_ring(struct amdgpu_device *adev, AMDGPU_RING_PRIO_DEFAULT);if (r)dev_warn (adev->dev,"(%d) failed to init kiq ring\n" , r); +else + kiq->max_sub_num = (ring->ring_size /4 ) / + (ring->funcs->align_mask +1 );return r; }@@ -663,6 +666,21 @@ int amdgpu_gfx_cp_ecc_error_irq(struct amdgpu_device *adev,return 0 ; } +int amdgpu_gfx_kiq_is_avail (struct amdgpu_kiq *kiq) { +uint32_t seq =0 ; +signed long r =0 ; + + seq =abs (kiq->ring.fence_drv.sync_seq - kiq->max_sub_num); +if (seq > kiq->max_sub_num) { + r =amdgpu_fence_wait_polling (&kiq->ring, seq, +MAX_KIQ_REG_WAIT ); +return r <1 ? -ETIME :0 ; + } + +return 0 ; +} +uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg) {signed long r, cnt =0 ;@@ -674,6 +692,12 @@ uint32_t amdgpu_kiq_rreg(struct amdgpu_device *adev, uint32_t reg)BUG_ON (!ring->funcs->emit_rreg);spin_lock_irqsave (&kiq->ring_lock, flags); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq_read; + } +if (amdgpu_device_wb_get (adev, ®_val_offs)) {spin_unlock_irqrestore (&kiq->ring_lock, flags); pr_err("critical bug! too many kiq readers\n"); @@ -728,6 +752,12 @@ void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v)BUG_ON(!ring->funcs->emit_wreg); spin_lock_irqsave(&kiq->ring_lock, flags);drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +6
-0+ r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq_write; + } +amdgpu_ring_alloc (ring,32 );amdgpu_ring_emit_wreg (ring, reg, v); amdgpu_fence_emit_polling(ring, &seq); diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.hb/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
indexee698f0246d8..1ee59a927bd9100644drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +3
-0@@ -103,6 +103,7 @@ struct amdgpu_kiq {struct amdgpu_ring ring;struct amdgpu_irq_src irq;const struct kiq_pm4_funcs *pmf; +uint32_t max_sub_num; };/* @@ -387,4 +388,6 @@ int amdgpu_gfx_cp_ecc_error_irq(struct amdgpu_device *adev, struct amdgpu_iv_entry *entry);uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg);void amdgpu_kiq_wreg (struct amdgpu_device *adev,uint32_t reg,uint32_t v); + +int amdgpu_gfx_kiq_is_avail (struct amdgpu_kiq *kiq);#endifdrivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +6
-0@@ -57,6 +57,12 @@ void amdgpu_virt_kiq_reg_write_reg_wait(struct amdgpu_device *adev,uint32_t seq;spin_lock_irqsave (&kiq->ring_lock, flags); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq; + } +amdgpu_ring_alloc (ring,32 );amdgpu_ring_emit_reg_write_reg_wait (ring, reg0, reg1, ref, mask);drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +6
-0@@ -4051,6 +4051,12 @@ static uint64_t gfx_v9_0_kiq_read_clock(struct amdgpu_device *adev)BUG_ON (!ring->funcs->emit_rreg);spin_lock_irqsave (&kiq->ring_lock, flags); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq_read; + } +if (amdgpu_device_wb_get (adev, ®_val_offs)) {spin_unlock_irqrestore (&kiq->ring_lock, flags); pr_err("critical bug! too many kiq readers\n"); diff --git
a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.cb/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
index30b75d79efdb..77d8bc9c0111100644drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +7
-0@@ -423,6 +423,13 @@ static int gmc_v10_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, if (amdgpu_emu_mode == 0 && ring->sched.ready) {spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock (&kiq->ring_lock); +DRM_ERROR ("too many kiq submissions\n" ); +return -ETIME ; + } +/* 2 dwords flush + 8 dwords fence */ amdgpu_ring_alloc (ring, kiq->pmf->invalidate_tlbs_size +8 );kiq->pmf->kiq_invalidate_tlbs(ring,
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +7
-1@@ -614,6 +614,13 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, ndw += kiq->pmf->invalidate_tlbs_size;spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock (&kiq->ring_lock); +DRM_ERROR ("critical bug! too many kiq submissions\n" ); +return -ETIME ; + } +/* 2 dwords flush + 8 dwords fence */ amdgpu_ring_alloc (ring, ndw);if (vega20_xgmi_wa) --2.17.1
Quoted 8 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flist
s.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7CSh aoyun.Liu%40amd.com%7C0cd26307c0a149ebe0bd08d7e6cc84b1%7C3dd8961fe4884 e608e11a82d994e183d%7C0%7C0%7C637231638419034830&sdata=rxkhyMutFwb e5Nw%2BeBGiESW9wTdflDUo%2F4xEvbCbR6U%3D&reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
maintainerQuoted 1 line
Can't we check the rptr write back to determine the available room in the
ring_alloc?
We removed that a couple of years ago.
One reason for this is that checking the rptr each time is quite a huge overhead since it is an MMIO register.
The other reason is that the rptr is no longer a secure way of figuring out if an engine has processed all data.
Some engines like the CP are pipelined and the rptr is only the beginning of the pipeline, subsequent pipeline steps might read from the ring buffer again.
If you want to figure out the processing status of ring allocations you need to take a look at the fences.
Regards,
Christian.
Am 22.04.20 um 17:43 schrieb Liu, Shaoyun:
Quoted 248 lines
[AMD Official Use Only - Internal Distribution Only]
I always has an impression for each submission, once the ring be allocated , before the fence be signed , this ring space will always be reserved . If this can not be guaranteed , it sound a big issue to me . Can't we check the rptr write back to determine the available room in the
ring_alloc?Regards
Shaoyun.liu
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, April 22, 2020 10:57 AM
To: Liu, Shaoyun <[email protected]>; Tao, Yintian <[email protected]>; Liu, Monk <[email protected]>; Kuehling, Felix <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] drm/amdgpu: protect kiq overrunThe
amdgpu_ring_alloc()function checks if the requested number of DW don't exceed the maximum submission size.It does NOT check if there is enough room on the ring. That would require MMIO access and that is what we want to avoid.
Regards,
Christian.Am 22.04.20 um 16:54 schrieb Liu, Shaoyun:
Quoted 227 lines
[AMD Official Use Only - Internal Distribution Only]
I think each kiq operation will call
ring_allocfor the package space , why not just check whether this allocation is succeed or not ?Shaoyun.liu
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Yintian Tao
Sent: Wednesday, April 22, 2020 10:50 AM
To: Koenig, Christian <[email protected]>; Liu, Monk <[email protected]>; Kuehling, Felix <[email protected]>
Cc: [email protected]; Tao, Yintian <[email protected]>
Subject: [PATCH] drm/amdgpu: protect kiq overrunWait for the oldest sequence on the kiq ring to be signaled in order to make sure there will be no kiq overrun.
v2: remove unused the variable and correct
kiqmax_sub_numvalueSigned-off-by Yintian Tao <[email protected]>--- .../drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c | 6 ++++ .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c | 6 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 30 +++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 3 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 6 ++++ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 6 ++++ drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 7 +++++ drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 7 +++++ 8 files changed, 71 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c +6
-0@@ -325,6 +325,12 @@ static int kgd_hiq_mqd_load(struct kgd_dev *kgd, void *mqd, mec, pipe, queue_id);spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +pr_err ("critical bug! too many kiq submission\n" ); + goto out_unlock; + } + r =amdgpu_ring_alloc (kiq_ring,7 );if (r) { pr_err("Failed to alloc KIQ (%d).\n", r); diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.cindexdf841c2ac5e7..fd42c126510f100644drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +6
-0@@ -323,6 +323,12 @@ int kgd_gfx_v9_hiq_mqd_load(struct kgd_dev *kgd, void *mqd, mec, pipe, queue_id);spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +pr_err ("critical bug! too many kiq submissions\n" ); + goto out_unlock; + } + r =amdgpu_ring_alloc (kiq_ring,7 );if (r) { pr_err("Failed to alloc KIQ (%d).\n", r); diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
indexa721b0e0ff69..84e66c45df37100644drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +23
-0@@ -321,6 +321,9 @@ int amdgpu_gfx_kiq_init_ring(struct amdgpu_device *adev, AMDGPU_RING_PRIO_DEFAULT);if (r)dev_warn (adev->dev,"(%d) failed to init kiq ring\n" , r); +else + kiq->max_sub_num = (ring->ring_size /4 ) / + (ring->funcs->align_mask +1 );return r; }@@ -663,6 +666,21 @@ int amdgpu_gfx_cp_ecc_error_irq(struct amdgpu_device *adev,return 0 ; } +int amdgpu_gfx_kiq_is_avail (struct amdgpu_kiq *kiq) { +uint32_t seq =0 ; +signed long r =0 ; + + seq =abs (kiq->ring.fence_drv.sync_seq - kiq->max_sub_num); +if (seq > kiq->max_sub_num) { + r =amdgpu_fence_wait_polling (&kiq->ring, seq, +MAX_KIQ_REG_WAIT ); +return r <1 ? -ETIME :0 ; + } + +return 0 ; +} +uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg) {signed long r, cnt =0 ;@@ -674,6 +692,12 @@ uint32_t amdgpu_kiq_rreg(struct amdgpu_device *adev, uint32_t reg)BUG_ON (!ring->funcs->emit_rreg);spin_lock_irqsave (&kiq->ring_lock, flags); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq_read; + } +if (amdgpu_device_wb_get (adev, ®_val_offs)) {spin_unlock_irqrestore (&kiq->ring_lock, flags); pr_err("critical bug! too many kiq readers\n"); @@ -728,6 +752,12 @@ void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v)BUG_ON(!ring->funcs->emit_wreg); spin_lock_irqsave(&kiq->ring_lock, flags);drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +6
-0+ r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq_write; + } +amdgpu_ring_alloc (ring,32 );amdgpu_ring_emit_wreg (ring, reg, v); amdgpu_fence_emit_polling(ring, &seq); diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.hb/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
indexee698f0246d8..1ee59a927bd9100644drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +3
-0@@ -103,6 +103,7 @@ struct amdgpu_kiq {struct amdgpu_ring ring;struct amdgpu_irq_src irq;const struct kiq_pm4_funcs *pmf; +uint32_t max_sub_num; };/* @@ -387,4 +388,6 @@ int amdgpu_gfx_cp_ecc_error_irq(struct amdgpu_device *adev, struct amdgpu_iv_entry *entry);uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg);void amdgpu_kiq_wreg (struct amdgpu_device *adev,uint32_t reg,uint32_t v); + +int amdgpu_gfx_kiq_is_avail (struct amdgpu_kiq *kiq);#endifdrivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +6
-0@@ -57,6 +57,12 @@ void amdgpu_virt_kiq_reg_write_reg_wait(struct amdgpu_device *adev,uint32_t seq;spin_lock_irqsave (&kiq->ring_lock, flags); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq; + } +amdgpu_ring_alloc (ring,32 );amdgpu_ring_emit_reg_write_reg_wait (ring, reg0, reg1, ref, mask);drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +6
-0@@ -4051,6 +4051,12 @@ static uint64_t gfx_v9_0_kiq_read_clock(struct amdgpu_device *adev)BUG_ON (!ring->funcs->emit_rreg);spin_lock_irqsave (&kiq->ring_lock, flags); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq_read; + } +if (amdgpu_device_wb_get (adev, ®_val_offs)) {spin_unlock_irqrestore (&kiq->ring_lock, flags); pr_err("critical bug! too many kiq readers\n"); diff --git
a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.cb/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
index30b75d79efdb..77d8bc9c0111100644drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +7
-0@@ -423,6 +423,13 @@ static int gmc_v10_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, if (amdgpu_emu_mode == 0 && ring->sched.ready) {spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock (&kiq->ring_lock); +DRM_ERROR ("too many kiq submissions\n" ); +return -ETIME ; + } +/* 2 dwords flush + 8 dwords fence */ amdgpu_ring_alloc (ring, kiq->pmf->invalidate_tlbs_size +8 );kiq->pmf->kiq_invalidate_tlbs(ring,drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +7
-1@@ -614,6 +614,13 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, ndw += kiq->pmf->invalidate_tlbs_size;spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock (&kiq->ring_lock); +DRM_ERROR ("critical bug! too many kiq submissions\n" ); +return -ETIME ; + } +/* 2 dwords flush + 8 dwords fence */ amdgpu_ring_alloc (ring, ndw);if (vega20_xgmi_wa) --2.17.1
Quoted 8 lines
Quoted 8 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flist
s.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7CSh aoyun.Liu%40amd.com%7C0cd26307c0a149ebe0bd08d7e6cc84b1%7C3dd8961fe4884 e608e11a82d994e183d%7C0%7C0%7C637231638419034830&sdata=rxkhyMutFwb e5Nw%2BeBGiESW9wTdflDUo%2F4xEvbCbR6U%3D&reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
maintainerAm 22.04.20 um 16:50 schrieb Yintian Tao:
Quoted 6 lines
Wait for the oldest sequence on the kiq ring
to be signaled in order to make sure there
will be no kiq overrun.v2: remove unused the variable and correct
kiqmax_sub_numvalue
First of all this should probably be added to the fence handling code and not the kiq code.
Then you are kind of duplicating some of the functionality we have in the ring handling here. Probably better to avoid this, see amdgpu_fence_driver_init_ring() as well. That's also why I suggested to use the num_fences_mask value.
Regards,
Christian.
Quoted 188 lines
Signed-off-by Yintian Tao <[email protected]>--- .../drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c | 6 ++++ .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c | 6 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 30 +++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 3 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 6 ++++ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 6 ++++ drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 7 +++++ drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 7 +++++ 8 files changed, 71 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c +6
-0@@ -325,6 +325,12 @@ static int kgd_hiq_mqd_load(struct kgd_dev *kgd, void *mqd, mec, pipe, queue_id);spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +pr_err ("critical bug! too many kiq submission\n" ); + goto out_unlock; + } + r =amdgpu_ring_alloc (kiq_ring,7 );if (r) {pr_err ("Failed to alloc KIQ (%d).\n" , r);drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +6
-0@@ -323,6 +323,12 @@ int kgd_gfx_v9_hiq_mqd_load(struct kgd_dev *kgd, void *mqd, mec, pipe, queue_id);spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +pr_err ("critical bug! too many kiq submissions\n" ); + goto out_unlock; + } + r =amdgpu_ring_alloc (kiq_ring,7 );if (r) {pr_err ("Failed to alloc KIQ (%d).\n" , r);drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +30
-0@@ -321,6 +321,9 @@ int amdgpu_gfx_kiq_init_ring(struct amdgpu_device *adev, AMDGPU_RING_PRIO_DEFAULT);if (r)dev_warn (adev->dev,"(%d) failed to init kiq ring\n" , r); +else + kiq->max_sub_num = (ring->ring_size /4 ) / + (ring->funcs->align_mask +1 );return r; }@@ -663,6 +666,21 @@ int amdgpu_gfx_cp_ecc_error_irq(struct amdgpu_device *adev,return 0 ; } +int amdgpu_gfx_kiq_is_avail (struct amdgpu_kiq *kiq) +{ +uint32_t seq =0 ; +signed long r =0 ; + + seq =abs (kiq->ring.fence_drv.sync_seq - kiq->max_sub_num); +if (seq > kiq->max_sub_num) { + r =amdgpu_fence_wait_polling (&kiq->ring, seq, +MAX_KIQ_REG_WAIT ); +return r <1 ? -ETIME :0 ; + } + +return 0 ; +} +uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg) {signed long r, cnt =0 ;@@ -674,6 +692,12 @@ uint32_t amdgpu_kiq_rreg(struct amdgpu_device *adev, uint32_t reg)BUG_ON (!ring->funcs->emit_rreg);spin_lock_irqsave (&kiq->ring_lock, flags); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq_read; + } +if (amdgpu_device_wb_get (adev, ®_val_offs)) {spin_unlock_irqrestore (&kiq->ring_lock, flags);pr_err ("critical bug! too many kiq readers\n" );@@ -728,6 +752,12 @@ void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v)BUG_ON (!ring->funcs->emit_wreg);spin_lock_irqsave (&kiq->ring_lock, flags); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq_write; + } +amdgpu_ring_alloc (ring,32 );amdgpu_ring_emit_wreg (ring, reg, v);amdgpu_fence_emit_polling (ring, &seq);drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +3
-0@@ -103,6 +103,7 @@ struct amdgpu_kiq {struct amdgpu_ring ring;struct amdgpu_irq_src irq;const struct kiq_pm4_funcs *pmf; +uint32_t max_sub_num; };/* @@ -387,4 +388,6 @@ int amdgpu_gfx_cp_ecc_error_irq(struct amdgpu_device *adev, struct amdgpu_iv_entry *entry);uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg);void amdgpu_kiq_wreg (struct amdgpu_device *adev,uint32_t reg,uint32_t v); + +int amdgpu_gfx_kiq_is_avail (struct amdgpu_kiq *kiq);#endif drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +6
-0@@ -57,6 +57,12 @@ void amdgpu_virt_kiq_reg_write_reg_wait(struct amdgpu_device *adev,uint32_t seq;spin_lock_irqsave (&kiq->ring_lock, flags); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq; + } +amdgpu_ring_alloc (ring,32 );amdgpu_ring_emit_reg_write_reg_wait (ring, reg0, reg1, ref, mask);drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +6
-0@@ -4051,6 +4051,12 @@ static uint64_t gfx_v9_0_kiq_read_clock(struct amdgpu_device *adev)BUG_ON (!ring->funcs->emit_rreg);spin_lock_irqsave (&kiq->ring_lock, flags); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq_read; + } +if (amdgpu_device_wb_get (adev, ®_val_offs)) {spin_unlock_irqrestore (&kiq->ring_lock, flags);pr_err ("critical bug! too many kiq readers\n" );drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +7
-0@@ -423,6 +423,13 @@ static int gmc_v10_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,if (amdgpu_emu_mode ==0 && ring->sched.ready) {spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock (&kiq->ring_lock); +DRM_ERROR ("too many kiq submissions\n" ); +return -ETIME ; + } +/* 2 dwords flush + 8 dwords fence */ amdgpu_ring_alloc (ring, kiq->pmf->invalidate_tlbs_size +8 ); kiq->pmf->kiq_invalidate_tlbs(ring,drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0
-0@@ -614,6 +614,13 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, ndw += kiq->pmf->invalidate_tlbs_size;spin_lock (&adev->gfx.kiq.ring_lock);
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, · line 626
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +7
-0+ r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock (&kiq->ring_lock); +DRM_ERROR ("critical bug! too many kiq submissions\n" ); +return -ETIME ; + } +/* 2 dwords flush + 8 dwords fence */ amdgpu_ring_alloc (ring, ndw);if (vega20_xgmi_wa)
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Hi Christian
Ok , I got it. The real max number can be submitted to kiq ring buffer is 1024.
If we use the num_fneces_mask value then the max submission number will be reduced to 512, do you think whether it is ok?
Best Regards
Yintian Tao
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: 2020年4月23日 2:43
To: Tao, Yintian <[email protected]>; Liu, Monk <[email protected]>; Kuehling, Felix <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] drm/amdgpu: protect kiq overrun
Am 22.04.20 um 16:50 schrieb Yintian Tao:
Quoted 5 lines
Wait for the oldest sequence on the kiq ring to be signaled in order to make sure there will be no kiq overrun.
v2: remove unused the variable and correct
kiqmax_sub_numvalue
First of all this should probably be added to the fence handling code and not the kiq code.
Then you are kind of duplicating some of the functionality we have in the ring handling here. Probably better to avoid this, see amdgpu_fence_driver_init_ring() as well. That's also why I suggested to use the num_fences_mask value.
Regards,
Christian.
Quoted 197 lines
Signed-off-by Yintian Tao <[email protected]>--- .../drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c | 6 ++++ .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c | 6 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 30 +++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 3 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 6 ++++ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 6 ++++ drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 7 +++++ drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 7 +++++ 8 files changed, 71 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c +6
-0@@ -325,6 +325,12 @@ static int kgd_hiq_mqd_load(struct kgd_dev *kgd, void *mqd, mec, pipe, queue_id);spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +pr_err ("critical bug! too many kiq submission\n" ); + goto out_unlock; + } + r =amdgpu_ring_alloc (kiq_ring,7 );if (r) { pr_err("Failed to alloc KIQ (%d).\n", r); diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.cindexdf841c2ac5e7..fd42c126510f100644drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +6
-0@@ -323,6 +323,12 @@ int kgd_gfx_v9_hiq_mqd_load(struct kgd_dev *kgd, void *mqd, mec, pipe, queue_id);spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +pr_err ("critical bug! too many kiq submissions\n" ); + goto out_unlock; + } + r =amdgpu_ring_alloc (kiq_ring,7 );if (r) { pr_err("Failed to alloc KIQ (%d).\n", r); diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
indexa721b0e0ff69..84e66c45df37100644drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +23
-0@@ -321,6 +321,9 @@ int amdgpu_gfx_kiq_init_ring(struct amdgpu_device *adev, AMDGPU_RING_PRIO_DEFAULT);if (r)dev_warn (adev->dev,"(%d) failed to init kiq ring\n" , r); +else + kiq->max_sub_num = (ring->ring_size /4 ) / + (ring->funcs->align_mask +1 );return r; }@@ -663,6 +666,21 @@ int amdgpu_gfx_cp_ecc_error_irq(struct amdgpu_device *adev,return 0 ; } +int amdgpu_gfx_kiq_is_avail (struct amdgpu_kiq *kiq) { +uint32_t seq =0 ; +signed long r =0 ; + + seq =abs (kiq->ring.fence_drv.sync_seq - kiq->max_sub_num); +if (seq > kiq->max_sub_num) { + r =amdgpu_fence_wait_polling (&kiq->ring, seq, +MAX_KIQ_REG_WAIT ); +return r <1 ? -ETIME :0 ; + } + +return 0 ; +} +uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg) {signed long r, cnt =0 ;@@ -674,6 +692,12 @@ uint32_t amdgpu_kiq_rreg(struct amdgpu_device *adev, uint32_t reg)BUG_ON (!ring->funcs->emit_rreg);spin_lock_irqsave (&kiq->ring_lock, flags); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq_read; + } +if (amdgpu_device_wb_get (adev, ®_val_offs)) {spin_unlock_irqrestore (&kiq->ring_lock, flags); pr_err("critical bug! too many kiq readers\n"); @@ -728,6 +752,12@@ void
amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v)
BUG_ON(!ring->funcs->emit_wreg);spin_lock_irqsave(&kiq->ring_lock, flags);drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +6
-0+ r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq_write; + } +amdgpu_ring_alloc (ring,32 );amdgpu_ring_emit_wreg (ring, reg, v); amdgpu_fence_emit_polling(ring, &seq); diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.hb/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
indexee698f0246d8..1ee59a927bd9100644drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +3
-0@@ -103,6 +103,7 @@ struct amdgpu_kiq {struct amdgpu_ring ring;struct amdgpu_irq_src irq;const struct kiq_pm4_funcs *pmf; +uint32_t max_sub_num; };/* @@ -387,4 +388,6 @@ int amdgpu_gfx_cp_ecc_error_irq(struct amdgpu_device *adev, struct amdgpu_iv_entry *entry);uint32_t amdgpu_kiq_rreg (struct amdgpu_device *adev,uint32_t reg);void amdgpu_kiq_wreg (struct amdgpu_device *adev,uint32_t reg,uint32_t v); + +int amdgpu_gfx_kiq_is_avail (struct amdgpu_kiq *kiq);#endifdrivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +6
-0@@ -57,6 +57,12 @@ void amdgpu_virt_kiq_reg_write_reg_wait(struct amdgpu_device *adev,uint32_t seq;spin_lock_irqsave (&kiq->ring_lock, flags); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq; + } +amdgpu_ring_alloc (ring,32 );amdgpu_ring_emit_reg_write_reg_wait (ring, reg0, reg1, ref, mask);drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +6
-0@@ -4051,6 +4051,12 @@ static uint64_t gfx_v9_0_kiq_read_clock(struct amdgpu_device *adev)BUG_ON (!ring->funcs->emit_rreg);spin_lock_irqsave (&kiq->ring_lock, flags); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock_irqrestore (&kiq->ring_lock, flags); + goto failed_kiq_read; + } +if (amdgpu_device_wb_get (adev, ®_val_offs)) {spin_unlock_irqrestore (&kiq->ring_lock, flags); pr_err("critical bug! too many kiq readers\n"); diff --git
a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.cb/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
index30b75d79efdb..77d8bc9c0111100644drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +7
-0@@ -423,6 +423,13 @@ static int gmc_v10_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, if (amdgpu_emu_mode == 0 && ring->sched.ready) {spin_lock (&adev->gfx.kiq.ring_lock); + r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock (&kiq->ring_lock); +DRM_ERROR ("too many kiq submissions\n" ); +return -ETIME ; + } +/* 2 dwords flush + 8 dwords fence */ amdgpu_ring_alloc (ring, kiq->pmf->invalidate_tlbs_size +8 );kiq->pmf->kiq_invalidate_tlbs(ring,
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0
-0@@ -614,6 +614,13 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, ndw += kiq->pmf->invalidate_tlbs_size;spin_lock (&adev->gfx.kiq.ring_lock);
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, · line 626
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +7
-0+ r =amdgpu_gfx_kiq_is_avail (&adev->gfx.kiq); +if (r) { +spin_unlock (&kiq->ring_lock); +DRM_ERROR ("critical bug! too many kiq submissions\n" ); +return -ETIME ; + } +/* 2 dwords flush + 8 dwords fence */ amdgpu_ring_alloc (ring, ndw);if (vega20_xgmi_wa)
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx