Subject: linux-next: manual merge of the drm-misc tree with the amdgpu tree

From: Stephen Rothwell <[email-masked]>
Date: Tue, 21 May 2019 10:38:15 +1000

Hi all,

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

  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

between commit:

  56965ce261af ("drm/amdgpu: cancel late_init_work before gpu reset")

from the amdgpu tree and commit:

  1d721ed679db ("drm/amdgpu: Avoid HW reset if guilty job already signaled.")

from the drm-misc tree.

I fixed it up (I think - 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.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index c9024f92e203,b9371ec5e04f..000000000000
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@@ -3614,28 -3538,27 +3595,28 @@@ int amdgpu_device_gpu_recover(struct am
  
  	dev_info(adev->dev, "GPU reset begin!\n");
  
 +	cancel_delayed_work_sync(&adev->late_init_work);
+ 	hive = amdgpu_get_xgmi_hive(adev, false);
  
  	/*
- 	 * In case of XGMI hive disallow concurrent resets to be triggered
- 	 * by different nodes. No point also since the one node already executing
- 	 * reset will also reset all the other nodes in the hive.
+ 	 * Here we trylock to avoid chain of resets executing from
+ 	 * either trigger by jobs on different adevs in XGMI hive or jobs on
+ 	 * different schedulers for same device while this TO handler is running.
+ 	 * We always reset all schedulers for device and all devices for XGMI
+ 	 * hive so that should take care of them too.
  	 */
- 	hive = amdgpu_get_xgmi_hive(adev, 0);
- 	if (hive && adev->gmc.xgmi.num_physical_nodes > 1 &&
- 	    !mutex_trylock(&hive->reset_lock))
+ 
+ 	if (hive && !mutex_trylock(&hive->reset_lock)) {
+ 		DRM_INFO("Bailing on TDR for s_job:%llx, hive: %llx as another already in progress",
+ 			 job->base.id, hive->hive_id);
  		return 0;
+ 	}
  
  	/* Start with adev pre asic reset first for soft reset check.*/
- 	amdgpu_device_lock_adev(adev);
- 	r = amdgpu_device_pre_asic_reset(adev,
- 					 job,
- 					 &need_full_reset);
- 	if (r) {
- 		/*TODO Should we stop ?*/
- 		DRM_ERROR("GPU pre asic reset failed with err, %d for drm dev, %s ",
- 			  r, adev->ddev->unique);
- 		adev->asic_reset_res = r;
+ 	if (!amdgpu_device_lock_adev(adev, !hive)) {
+ 		DRM_INFO("Bailing on TDR for s_job:%llx, as another already in progress",
+ 					 job->base.id);
+ 		return 0;
  	}
  
  	/* Build list of devices to reset */