Merge tag 'drm-misc-next-2022-04-07' of git://anongit.freedesktop.org/drm/drm-misc...
[linux-2.6-microblaze.git] / drivers / gpu / drm / amd / amdgpu / amdgpu_object.c
index 9407524..dd6693f 100644 (file)
@@ -1390,6 +1390,14 @@ void amdgpu_bo_fence(struct amdgpu_bo *bo, struct dma_fence *fence,
                     bool shared)
 {
        struct dma_resv *resv = bo->tbo.base.resv;
+       int r;
+
+       r = dma_resv_reserve_fences(resv, 1);
+       if (r) {
+               /* As last resort on OOM we block for the fence */
+               dma_fence_wait(fence, false);
+               return;
+       }
 
        if (shared)
                dma_resv_add_shared_fence(resv, fence);