drm/amdgpu: wrap kiq ring ops with kiq spinlock
Subsystems (2)
PATCH 1/1 drm/amdgpu: wrap kiq ring ops with kiq spinlock
KIQ ring is being operated by kfd as well as amdgpu. KFD is using kiq lock, we should the same from amdgpu side as well.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +8 -2
@@ -467,13 +467,17 @@ int amdgpu_gfx_disable_kcq(struct amdgpu_device *adev)if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues)return -EINVAL ; +spin_lock (&adev->gfx.kiq.ring_lock);if (amdgpu_ring_alloc (kiq_ring, kiq->pmf->unmap_queues_size * - adev->gfx.num_compute_rings)) + adev->gfx.num_compute_rings)) { +spin_unlock (&adev->gfx.kiq.ring_lock);return -ENOMEM ; + }for (i =0 ; i < adev->gfx.num_compute_rings; i++) kiq->pmf->kiq_unmap_queues (kiq_ring, &adev->gfx.compute_ring[i],RESET_QUEUES ,0 ,0 ); +spin_unlock (&adev->gfx.kiq.ring_lock);return amdgpu_ring_test_helper (kiq_ring); }
@@ -518,18 +522,20 @@ int amdgpu_gfx_enable_kcq(struct amdgpu_device *adev)DRM_INFO ("kiq ring mec %d pipe %d q %d\n" , kiq_ring->me, kiq_ring->pipe, kiq_ring->queue); - +spin_lock (&adev->gfx.kiq.ring_lock); r =amdgpu_ring_alloc (kiq_ring, kiq->pmf->map_queues_size * adev->gfx.num_compute_rings + kiq->pmf->set_resources_size);if (r) {DRM_ERROR ("Failed to lock KIQ (%d).\n" , r); +spin_unlock (&adev->gfx.kiq.ring_lock);return r; } kiq->pmf->kiq_set_resources (kiq_ring, queue_mask);for (i =0 ; i < adev->gfx.num_compute_rings; i++) kiq->pmf->kiq_map_queues (kiq_ring, &adev->gfx.compute_ring[i]); +spin_unlock (&adev->gfx.kiq.ring_lock); r =amdgpu_ring_test_helper (kiq_ring);if (r)
Signature · 6 lines
2.30.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
maintainerAm 12.03.21 um 10:49 schrieb Nirmoy Das:
Quoted 3 lines
KIQ ring is being operated by kfd as well as amdgpu. KFD is using kiq lock, we should the same from amdgpu side as well.
Ah, now I knew which functions you mean. This is not strictly necessary because that stuff is only called during bootup and not later on.
Quoted 18 lines
Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +2
-1@@ -467,13 +467,17 @@ int amdgpu_gfx_disable_kcq(struct amdgpu_device *adev)if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues)return -EINVAL ; +spin_lock (&adev->gfx.kiq.ring_lock);if (amdgpu_ring_alloc (kiq_ring, kiq->pmf->unmap_queues_size * - adev->gfx.num_compute_rings)) + adev->gfx.num_compute_rings)) {
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c int amdgpu_gfx_disable_kcq(struct amdgpu_device *adev) · line 482
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +3
-0+spin_unlock (&adev->gfx.kiq.ring_lock);return -ENOMEM ; + }for (i =0 ; i < adev->gfx.num_compute_rings; i++) kiq->pmf->kiq_unmap_queues (kiq_ring, &adev->gfx.compute_ring[i],RESET_QUEUES ,0 ,0 ); +spin_unlock (&adev->gfx.kiq.ring_lock);return amdgpu_ring_test_helper (kiq_ring);
The ring test accesses the ring buffer as well.
Regards,
Christian.
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +2
-1}@@ -518,18 +522,20 @@ int amdgpu_gfx_enable_kcq(struct amdgpu_device *adev)DRM_INFO ("kiq ring mec %d pipe %d q %d\n" , kiq_ring->me, kiq_ring->pipe, kiq_ring->queue); - +spin_lock (&adev->gfx.kiq.ring_lock); r =amdgpu_ring_alloc (kiq_ring, kiq->pmf->map_queues_size * adev->gfx.num_compute_rings + kiq->pmf->set_resources_size);if (r) {DRM_ERROR ("Failed to lock KIQ (%d).\n" , r); +spin_unlock (&adev->gfx.kiq.ring_lock);
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c int amdgpu_gfx_enable_kcq(struct amdgpu_device *adev) · line 541
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-0return r; } kiq->pmf->kiq_set_resources (kiq_ring, queue_mask);for (i =0 ; i < adev->gfx.num_compute_rings; i++) kiq->pmf->kiq_map_queues (kiq_ring, &adev->gfx.compute_ring[i]); +spin_unlock (&adev->gfx.kiq.ring_lock); r =amdgpu_ring_test_helper (kiq_ring);if (r)
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 6 lines · Christian König
Am 12.03.21 um 10:49 schrieb Nirmoy Das:
Quoted 3 lines
KIQ ring is being operated by kfd as well as amdgpu. KFD is using kiq lock, we should the same from amdgpu side as well.
Ah, now I knew which functions you mean. This is not strictly necessary because that stuff is only called during bootup and not later on.
OK, not so serious issue as I was thinking then.
Quoted 21 lines
Quoted 21 lines
Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c| 10 ++++++++--1 file changed, 8 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-0@@ -467,13 +467,17 @@ int amdgpu_gfx_disable_kcq(struct amdgpu_device *adev) if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues) return -EINVAL; + spin_lock(&adev->gfx.kiq.ring_lock);if (amdgpu_ring_alloc(kiq_ring,
kiq->pmf->unmap_queues_size* -adev->gfx.num_compute_rings))
+adev->gfx.num_compute_rings)) {
+spin_unlock(&adev->gfx.kiq.ring_lock);
return-ENOMEM;
Quoted 8 lines
Quoted 6 lines
+ }
for (i = 0; i <adev->gfx.num_compute_rings; i++)kiq->pmf->kiq_unmap_queues(kiq_ring, &adev->gfx.compute_ring[i], RESET_QUEUES, 0, 0);
+spin_unlock(&adev->gfx.kiq.ring_lock);
returnamdgpu_ring_test_helper(kiq_ring);The ring test accesses the ring buffer as well.
Shall I send a v2 ?
Thanks,
Nirmoy
Quoted 18 lines
Regards,
Christian.Quoted 13 lines
}
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -518,18 +522,20 @@ int amdgpu_gfx_enable_kcq(struct amdgpu_device *adev) DRM_INFO("kiq ring mec %d pipe %d q %d\n", kiq_ring->me, kiq_ring->pipe, kiq_ring->queue); - + spin_lock(&adev->gfx.kiq.ring_lock);r =
amdgpu_ring_alloc(kiq_ring, kiq->pmf->map_queues_size * adev->gfx.num_compute_rings + kiq->pmf->set_resources_size);
if (r) {
DRM_ERROR("Failed to lock KIQ (%d).\n", r);
+spin_unlock(&adev->gfx.kiq.ring_lock);
Quoted 9 lines
Quoted 8 lines
return r;
}
kiq->pmf->kiq_set_resources(kiq_ring, queue_mask); for (i = 0; i <adev->gfx.num_compute_rings; i++)kiq->pmf->kiq_map_queues(kiq_ring, &adev->gfx.compute_ring[i]); +spin_unlock(&adev->gfx.kiq.ring_lock);
r =amdgpu_ring_test_helper(kiq_ring);
if (r)
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
maintainerAm 12.03.21 um 11:24 schrieb Nirmoy:
Quoted 44 lines · Christian König
Quoted 6 lines
Am 12.03.21 um 10:49 schrieb Nirmoy Das:
Quoted 3 lines
KIQ ring is being operated by kfd as well as amdgpu. KFD is using kiq lock, we should the same from amdgpu side as well.
Ah, now I knew which functions you mean. This is not strictly necessary because that stuff is only called during bootup and not later on.
OK, not so serious issue as I was thinking then.
Quoted 21 lines
Quoted 21 lines
Signed-off-by Nirmoy Das <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c| 10 ++++++++--1 file changed, 8 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-0@@ -467,13 +467,17 @@ int amdgpu_gfx_disable_kcq(struct amdgpu_device *adev) if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues) return -EINVAL; + spin_lock(&adev->gfx.kiq.ring_lock);if (amdgpu_ring_alloc(kiq_ring,
kiq->pmf->unmap_queues_size* -adev->gfx.num_compute_rings))
+adev->gfx.num_compute_rings)) {
+spin_unlock(&adev->gfx.kiq.ring_lock);
return-ENOMEM;Quoted 8 lines
Quoted 6 lines
+ }
for (i = 0; i <adev->gfx.num_compute_rings; i++)kiq->pmf->kiq_unmap_queues(kiq_ring, &adev->gfx.compute_ring[i], RESET_QUEUES, 0, 0);
+spin_unlock(&adev->gfx.kiq.ring_lock);
returnamdgpu_ring_test_helper(kiq_ring);The ring test accesses the ring buffer as well.
Quoted 1 line
Shall I send a v2 ?
I'm not 100% sure. Please test this with lockdep enabled, if that doesn't raise anything we can probably commit it just to be on the clean side.
Regards,
Christian.
Quoted 34 lines
Thanks,
Nirmoy
Quoted 27 lines
Regards,
Christian.Quoted 21 lines
}
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-1@@ -518,18 +522,20 @@ int amdgpu_gfx_enable_kcq(struct amdgpu_device *adev) DRM_INFO("kiq ring mec %d pipe %d q %d\n", kiq_ring->me, kiq_ring->pipe, kiq_ring->queue); - + spin_lock(&adev->gfx.kiq.ring_lock);r =
amdgpu_ring_alloc(kiq_ring, kiq->pmf->map_queues_size * adev->gfx.num_compute_rings + kiq->pmf->set_resources_size);
if (r) {
DRM_ERROR("Failed to lock KIQ (%d).\n", r);
+spin_unlock(&adev->gfx.kiq.ring_lock);
return r;
}
kiq->pmf->kiq_set_resources(kiq_ring, queue_mask); for (i = 0; i <adev->gfx.num_compute_rings; i++)kiq->pmf->kiq_map_queues(kiq_ring, &adev->gfx.compute_ring[i]); +spin_unlock(&adev->gfx.kiq.ring_lock);
r =amdgpu_ring_test_helper(kiq_ring);
if (r)
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx