drm/amdkfd: Move dma unmapping after TLB flush
[linux-2.6-microblaze.git] / drivers / gpu / drm / amd / amdkfd / kfd_chardev.c
index bd762f6..f6d4748 100644 (file)
@@ -1432,17 +1432,21 @@ static int kfd_ioctl_unmap_memory_from_gpu(struct file *filep,
                        goto sync_memory_failed;
                }
        }
-       mutex_unlock(&p->mutex);
 
-       if (flush_tlb) {
-               /* Flush TLBs after waiting for the page table updates to complete */
-               for (i = 0; i < args->n_devices; i++) {
-                       peer_pdd = kfd_process_device_data_by_id(p, devices_arr[i]);
-                       if (WARN_ON_ONCE(!peer_pdd))
-                               continue;
+       /* Flush TLBs after waiting for the page table updates to complete */
+       for (i = 0; i < args->n_devices; i++) {
+               peer_pdd = kfd_process_device_data_by_id(p, devices_arr[i]);
+               if (WARN_ON_ONCE(!peer_pdd))
+                       continue;
+               if (flush_tlb)
                        kfd_flush_tlb(peer_pdd, TLB_FLUSH_HEAVYWEIGHT);
-               }
+
+               /* Remove dma mapping after tlb flush to avoid IO_PAGE_FAULT */
+               amdgpu_amdkfd_gpuvm_dmaunmap_mem(mem, peer_pdd->drm_priv);
        }
+
+       mutex_unlock(&p->mutex);
+
        kfree(devices_arr);
 
        return 0;