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

From: Stephen Rothwell <[email-masked]>
Date: Fri, 29 Apr 2022 11:03:29 +1000

Hi all,

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

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

between commit:

  047a1b877ed4 ("dma-buf & drm/amdgpu: remove dma_resv workaround")

from the drm tree and commit:

  3da2c38231a4 ("drm/amdgpu: Free user pages if amdgpu_cs_parser_bos failed")

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.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 01853431249d,67bd506fa141..000000000000
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@@ -636,9 -642,26 +636,21 @@@ static int amdgpu_cs_parser_bos(struct 
  	}
  
  error_validate:
 -	if (r) {
 -		amdgpu_bo_list_for_each_entry(e, p->bo_list) {
 -			dma_fence_chain_free(e->chain);
 -			e->chain = NULL;
 -		}
 +	if (r)
  		ttm_eu_backoff_reservation(&p->ticket, &p->validated);
- out:
 -	}
+ 
+ out_free_user_pages:
+ 	if (r) {
+ 		amdgpu_bo_list_for_each_userptr_entry(e, p->bo_list) {
+ 			struct amdgpu_bo *bo = ttm_to_amdgpu_bo(e->tv.bo);
+ 
+ 			if (!e->user_pages)
+ 				continue;
+ 			amdgpu_ttm_tt_get_user_pages_done(bo->tbo.ttm);
+ 			kvfree(e->user_pages);
+ 			e->user_pages = NULL;
+ 		}
+ 	}
  	return r;
  }