drm/amdkfd: Fix kernel-queue wrapping bugs
authorYong Zhao <yong.zhao@amd.com>
Wed, 20 Sep 2017 22:10:21 +0000 (18:10 -0400)
committerOded Gabbay <oded.gabbay@gmail.com>
Wed, 20 Sep 2017 22:10:21 +0000 (18:10 -0400)
commitcb1d9967461cdf3b6aac6317c8d954a14f842571
tree50bfb10a76331b899b285ba803f7c03c8090545c
parentb22666febf6fc67776d49782057fe4dd06f41552
drm/amdkfd: Fix kernel-queue wrapping bugs

Avoid intermediate negative numbers when doing calculations with a mix
of signed and unsigned variables where implicit conversions can lead
to unexpected results.

When kernel queue buffer wraps around to 0, we need to check that rptr
won't be overwritten by the new packet.

Signed-off-by: Yong Zhao <yong.zhao@amd.com>
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c