Fix the Page fault and warning issue when xalloc fails to store
the fence_drv.

Signed-off-by: Arunpravin Paneer Selvam <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
index 76f7babd7a54..ea067b006770 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
@@ -842,12 +842,12 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void 
*data,
                         * have any more space left and crash.
                         */
                        if (fence_drv->fence_drv_xa_ptr) {
-                               r = xa_alloc(fence_drv->fence_drv_xa_ptr, 
&index, fence_drv,
-                                            xa_limit_32b, GFP_KERNEL);
-                               if (r)
-                                       goto free_fences;
-
-                               amdgpu_userq_fence_driver_get(fence_drv);
+                               xa_lock(fence_drv->fence_drv_xa_ptr);
+                               r = __xa_alloc(fence_drv->fence_drv_xa_ptr, 
&index, fence_drv,
+                                              xa_limit_32b, GFP_KERNEL);
+                               xa_unlock(fence_drv->fence_drv_xa_ptr);
+                               if (!r)
+                                       
amdgpu_userq_fence_driver_get(fence_drv);
                        }
 
                        /* Store drm syncobj's gpu va address and value */
-- 
2.25.1

Reply via email to