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

From: Mark Brown <[email-masked]>
Date: Mon, 30 Oct 2017 18:26:23 +0000

Hi Dave,

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

  drivers/gpu/drm/amd/scheduler/gpu_scheduler.c

between commit:

  c94501279bb191c ("Revert "drm/amdgpu: discard commands of killed processes"")

from Linus' tree (it even made it into -rc6 over a week ago!) and the
fixes it explicitly identifies from the drm 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/scheduler/gpu_scheduler.c
index 38cea6fb25a8,e4d3b4ec4e92..000000000000
--- a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
+++ b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
@@@ -208,14 -209,34 +209,35 @@@ void amd_sched_entity_fini(struct amd_g
  
  	if (!amd_sched_entity_is_initialized(sched, entity))
  		return;
 +
  	/**
  	 * The client will not queue more IBs during this fini, consume existing
 -	 * queued IBs or discard them on SIGKILL
 +	 * queued IBs
  	*/
- 	wait_event(sched->job_scheduled, amd_sched_entity_is_idle(entity));
+ 	if ((current->flags & PF_SIGNALED) && current->exit_code == SIGKILL)
+ 		r = -ERESTARTSYS;
+ 	else
+ 		r = wait_event_killable(sched->job_scheduled,
+ 					amd_sched_entity_is_idle(entity));
+ 	amd_sched_entity_set_rq(entity, NULL);
+ 	if (r) {
+ 		struct amd_sched_job *job;
+ 
+ 		/* Park the kernel for a moment to make sure it isn't processing
+ 		 * our enity.
+ 		 */
+ 		kthread_park(sched->thread);
+ 		kthread_unpark(sched->thread);
+ 		while (kfifo_out(&entity->job_queue, &job, sizeof(job))) {
+ 			struct amd_sched_fence *s_fence = job->s_fence;
+ 			amd_sched_fence_scheduled(s_fence);
+ 			dma_fence_set_error(&s_fence->finished, -ESRCH);
+ 			amd_sched_fence_finished(s_fence);
+ 			dma_fence_put(&s_fence->finished);
+ 			sched->ops->free_job(job);
+ 		}
  
- 	amd_sched_rq_remove_entity(rq, entity);
+ 	}
  	kfifo_free(&entity->job_queue);
  }