Skip to contentSkip to conversation

drm/amdkfd: fix the wrong no space return while acquires packet buffer

PATCH In review Huang Rui 2 participants 3 messages Mar 19, 2020

Subsystems (3)
lore
Share & tools
lore

Huang Rui

author
#0 lore raw

PATCH 1/1 drm/amdkfd: fix the wrong no space return while acquires packet buffer

The queue buffer index starts from position 0, so the available buffer size which starts from position 0 to rptr should be "rptr" index value. While the packet_size_in_dwords == rptr, the available buffer is just good enough.

---
 drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c +1 -1
index bae7064..4667c8f 100644
@@ -263,7 +263,7 @@ int kq_acquire_packet_buffer(struct kernel_queue *kq,
 		/* make sure after rolling back to position 0, there is
 		 * still enough space.
 		 */
-		if (packet_size_in_dwords >= rptr)
+		if (packet_size_in_dwords > rptr)
 			goto err_no_space;
 
 		/* fill nops, roll back and start at position 0 */
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#1 lore raw
Quoted 18 lines

2020年3月19日 18:51,Huang Rui <[email protected]> 写道:

The queue buffer index starts from position 0, so the available buffer size which starts from position 0 to rptr should be "rptr" index value. While the packet_size_in_dwords == rptr, the available buffer is just good enough.

---
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c +0 -0
index bae7064..4667c8f 100644

drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c int kq_acquire_packet_buffer(struct kernel_queue *kq, · line 266

Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c +1 -1
@@ -263,7 +263,7 @@ int kq_acquire_packet_buffer(struct kernel_queue *kq,
 		/* make sure after rolling back to position 0, there is
 		 * still enough space.
 		 */
-		if (packet_size_in_dwords >= rptr)
+		if (packet_size_in_dwords > rptr)

rptr should always be > wptr unless ring is empty.

say, rptr is 4, packet_size_in_dwords is 4. Then wptr changes from 0 to 4, that is illegal.

Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c +0 -0
 			goto err_no_space;
 
 		/* fill nops, roll back and start at position 0 */
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Cxinhui.pan%40amd.com%7Cdb98cfd84b764e77d20e08d7cbf38dff%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637202119950119907&amp;sdata=mqrl2uooQ95Dns4l6CtmmOBCm%2FqZyw1pX48VA20mlZY%3D&amp;reserved=0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#2 lore raw
Quoted 26 lines · Xinhui
Quoted 18 lines

2020年3月19日 18:51,Huang Rui <[email protected]> 写道:

The queue buffer index starts from position 0, so the available buffer size which starts from position 0 to rptr should be "rptr" index value. While the packet_size_in_dwords == rptr, the available buffer is just good enough.

---
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c +0 -0
index bae7064..4667c8f 100644

drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c int kq_acquire_packet_buffer(struct kernel_queue *kq, · line 266

Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c +1 -1
@@ -263,7 +263,7 @@ int kq_acquire_packet_buffer(struct kernel_queue *kq,
 		/* make sure after rolling back to position 0, there is
 		 * still enough space.
 		 */
-		if (packet_size_in_dwords >= rptr)
+		if (packet_size_in_dwords > rptr)

rptr should always be > wptr unless ring is empty.

Quoted 2 lines

say, rptr is 4, packet_size_in_dwords is 4. Then wptr changes from 0 to 4, that is illegal.

Hey, xinhui, yes. :-)

See the comment "we can only use up to queue_size_dword - 1 dwords", that we cannot use the whole packet slots in the queue, it's to differentiate empty and full cases.

Thanks,
Ray

Quoted 12 lines
Quoted 11 lines
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c +0 -0
 			goto err_no_space;
 
 		/* fill nops, roll back and start at position 0 */
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Cxinhui.pan%40amd.com%7Cdb98cfd84b764e77d20e08d7cbf38dff%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637202119950119907&amp;sdata=mqrl2uooQ95Dns4l6CtmmOBCm%2FqZyw1pX48VA20mlZY%3D&amp;reserved=0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx