Subject: Re: [PATCH 1/1] drm/amdgpu: adopt to hmm_range_register API change

From: Jason Gunthorpe <[email-masked]>
Date: Wed, 3 Jul 2019 14:10:04 +0000

On Wed, Jul 03, 2019 at 01:55:08AM +0000, Kuehling, Felix wrote:
> From: Philip Yang <[email-masked]>
> 
> In order to pass mirror instead of mm to hmm_range_register, we need
> pass bo instead of ttm to amdgpu_ttm_tt_get_user_pages because mirror
> is part of amdgpu_mn structure, which is accessible from bo.
> 
> Signed-off-by: Philip Yang <[email-masked]>
> Reviewed-by: Felix Kuehling <[email-masked]>
> Signed-off-by: Felix Kuehling <[email-masked]>
> CC: Stephen Rothwell <[email-masked]>
> CC: Jason Gunthorpe <[email-masked]>
> CC: Dave Airlie <[email-masked]>
> CC: Alex Deucher <[email-masked]>
> ---
>  drivers/gpu/drm/Kconfig                          |  1 -
>  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c |  5 ++---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c           |  2 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c          |  3 +--
>  drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c           |  8 ++++++++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_mn.h           |  5 +++++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c          | 12 ++++++++++--
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h          |  5 +++--
>  8 files changed, 30 insertions(+), 11 deletions(-)

This is too big to use as a conflict resolution, what you could do is
apply the majority of the patch on top of your tree as-is (ie keep
using the old hmm_range_register), then the conflict resolution for
the updated AMD GPU tree can be a simple one line change:

 -	hmm_range_register(range, mm, start,
 +	hmm_range_register(range, mirror, start,
  			   start + ttm->num_pages * PAGE_SIZE, PAGE_SHIFT);

Which is trivial for everone to deal with, and solves the problem.

This is probably a much better option than rebasing the AMD gpu tree.

> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c
> index 623f56a1485f..80e40898a507 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c
> @@ -398,6 +398,14 @@ struct amdgpu_mn *amdgpu_mn_get(struct amdgpu_device *adev,
>  	return ERR_PTR(r);
>  }
>  
> +struct hmm_mirror *amdgpu_mn_get_mirror(struct amdgpu_mn *amn)
> +{
> +	if (!amn)
> +		return NULL;
> +
> +	return &amn->mirror;
> +}

I think it is better make the struct amdgpu_mn public rather than add
this wrapper.

Jason