Subject: linux-next: manual merge of the amdgpu tree with Linus' tree

From: Mark Brown <[email-masked]>
Date: Mon, 2 Aug 2021 16:10:53 +0100

Hi all,

Today's linux-next merge of the amdgpu tree got a conflict in:

  drivers/gpu/drm/amd/amdkfd/kfd_chardev.c

between commits:

  f5cc09acece4 ("Revert "drm/amdkfd: Add memory sync before TLB flush on unmap"")
  c37387c354c8 ("Revert "drm/amdkfd: Make TLB flush conditional on mapping"")
  5adcd7458a78 ("Revert "drm/amdkfd: Add heavy-weight TLB flush after unmapping"")

from Linus' tree and commits:

  b928ecfbe369 ("Revert "Revert "drm/amdkfd: Add memory sync before TLB flush on unmap""")
  b0228fa4868b ("drm/amdkfd: Only apply heavy-weight TLB flush on Aldebaran")

from the amdgpu tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

diff --cc drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index e48acdd03c1a,86afd37b098d..000000000000
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@@ -1565,10 -1568,29 +1565,33 @@@ static int kfd_ioctl_unmap_memory_from_
  		}
  		args->n_success = i+1;
  	}
++
+ 	mutex_unlock(&p->mutex);
+ 
+ 	if (dev->device_info->asic_family == CHIP_ALDEBARAN) {
+ 		err = amdgpu_amdkfd_gpuvm_sync_memory(dev->kgd,
+ 				(struct kgd_mem *) mem, true);
+ 		if (err) {
+ 			pr_debug("Sync memory failed, wait interrupted by user signal\n");
+ 			goto sync_memory_failed;
+ 		}
+ 
+ 		/* Flush TLBs after waiting for the page table updates to complete */
+ 		for (i = 0; i < args->n_devices; i++) {
+ 			peer = kfd_device_by_id(devices_arr[i]);
+ 			if (WARN_ON_ONCE(!peer))
+ 				continue;
+ 			peer_pdd = kfd_get_process_device_data(peer, p);
+ 			if (WARN_ON_ONCE(!peer_pdd))
+ 				continue;
+ 			kfd_flush_tlb(peer_pdd, TLB_FLUSH_HEAVYWEIGHT);
+ 		}
+ 	}
++
  	kfree(devices_arr);
  
 +	mutex_unlock(&p->mutex);
 +
  	return 0;
  
  bind_process_to_device_failed: