Userspace can either deliberately pass in the too small num_fences, or the
required number can legitimately grow between the two calls to the userq
wait ioctl. In both cases we do not want the emit the kernel warning
backtrace since nothing is wrong with the kernel and userspace will simply
get an errno reported back. So lets simply drop the WARN_ONs.

Signed-off-by: Tvrtko Ursulin <[email protected]>
Fixes: a292fdecd728 ("drm/amdgpu: Implement userqueue signal/wait IOCTL")
Cc: Arunpravin Paneer Selvam <[email protected]>
Cc: Christian König <[email protected]>
Cc: Alex Deucher <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
index 13c5d4462be6..9bec744127d3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
@@ -822,7 +822,7 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void 
*data,
 
                        dma_resv_for_each_fence(&resv_cursor, 
gobj_read[i]->resv,
                                                DMA_RESV_USAGE_READ, fence) {
-                               if (WARN_ON_ONCE(num_fences >= 
wait_info->num_fences)) {
+                               if (num_fences >= wait_info->num_fences) {
                                        r = -EINVAL;
                                        goto free_fences;
                                }
@@ -839,7 +839,7 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void 
*data,
 
                        dma_resv_for_each_fence(&resv_cursor, 
gobj_write[i]->resv,
                                                DMA_RESV_USAGE_WRITE, fence) {
-                               if (WARN_ON_ONCE(num_fences >= 
wait_info->num_fences)) {
+                               if (num_fences >= wait_info->num_fences) {
                                        r = -EINVAL;
                                        goto free_fences;
                                }
@@ -863,7 +863,7 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void 
*data,
                                        goto free_fences;
 
                                dma_fence_unwrap_for_each(f, &iter, fence) {
-                                       if (WARN_ON_ONCE(num_fences >= 
wait_info->num_fences)) {
+                                       if (num_fences >= 
wait_info->num_fences) {
                                                r = -EINVAL;
                                                dma_fence_put(fence);
                                                goto free_fences;
@@ -888,7 +888,7 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void 
*data,
                        if (r)
                                goto free_fences;
 
-                       if (WARN_ON_ONCE(num_fences >= wait_info->num_fences)) {
+                       if (num_fences >= wait_info->num_fences) {
                                r = -EINVAL;
                                dma_fence_put(fence);
                                goto free_fences;
-- 
2.51.1

Reply via email to