[PATCH 2/2] drm/amdgpu: use amdgpu_bo_create_kernel_at() to create large TMR for APU

Lang Yu Lang.Yu at amd.com
Thu Jul 27 08:24:28 UTC 2023


On 07/27/ , Christian König wrote:
> Am 27.07.23 um 09:56 schrieb Lang Yu:
> > TMR requires physical contiguous memory, amdgpu_bo_create_kernel()
> > can't satisfy large(>128MB) physical contiguous memory allocation
> > request with default 512MB VRAM on APU.
> > 
> > When requested TMR size > 128MB, use amdgpu_bo_create_kernel_at()
> > to create the TMR BO at offset 64MB.
> 
> Well complete NAK, you have misunderstood what amdgpu_bo_create_kernel_at()
> is doing.

  OK. Either taking over or creating memory area, amdgpu_bo_create series
  functions should satisfy the client's memory request.
  Anyway, amdgpu_bo_create_kernel_at() just works.
  
  Regards,
  Lang

> Regards,
> Christian.
> 
> > 
> > Signed-off-by: Lang Yu <Lang.Yu at amd.com>
> > ---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 42 ++++++++++++++++---------
> >   1 file changed, 28 insertions(+), 14 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> > index 15217e33b51d..2eac82113d34 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> > @@ -783,13 +783,38 @@ static bool psp_boottime_tmr(struct psp_context *psp)
> >   	}
> >   }
> > +static inline int psp_create_tmr_bo(struct psp_context *psp, int tmr_size)
> > +{
> > +	void *tmr_buf;
> > +	void **pptr;
> > +	int ret;
> > +
> > +	if (psp->tmr_bo)
> > +		return 0;
> > +
> > +	pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;
> > +
> > +	if (psp->adev->flags & AMD_IS_APU && tmr_size > 0x8000000)
> > +		ret = amdgpu_bo_create_kernel_at(psp->adev, 0x4000000, tmr_size,
> > +						 &psp->tmr_bo, &psp->tmr_mc_addr,
> > +						 pptr);
> > +	else
> > +		ret = amdgpu_bo_create_kernel(psp->adev, tmr_size,
> > +					      PSP_TMR_ALIGNMENT,
> > +					      AMDGPU_HAS_VRAM(psp->adev) ?
> > +					      AMDGPU_GEM_DOMAIN_VRAM :
> > +					      AMDGPU_GEM_DOMAIN_GTT,
> > +					      &psp->tmr_bo, &psp->tmr_mc_addr,
> > +					      pptr);
> > +
> > +	return ret;
> > +}
> > +
> >   /* Set up Trusted Memory Region */
> >   static int psp_tmr_init(struct psp_context *psp)
> >   {
> >   	int ret = 0;
> >   	int tmr_size;
> > -	void *tmr_buf;
> > -	void **pptr;
> >   	/*
> >   	 * According to HW engineer, they prefer the TMR address be "naturally
> > @@ -813,18 +838,7 @@ static int psp_tmr_init(struct psp_context *psp)
> >   		}
> >   	}
> > -	if (!psp->tmr_bo) {
> > -		pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;
> > -		ret = amdgpu_bo_create_kernel(psp->adev, tmr_size,
> > -					      PSP_TMR_ALIGNMENT,
> > -					      AMDGPU_HAS_VRAM(psp->adev) ?
> > -					      AMDGPU_GEM_DOMAIN_VRAM :
> > -					      AMDGPU_GEM_DOMAIN_GTT,
> > -					      &psp->tmr_bo, &psp->tmr_mc_addr,
> > -					      pptr);
> > -	}
> > -
> > -	return ret;
> > +	return psp_create_tmr_bo(psp, tmr_size);
> >   }
> >   static bool psp_skip_tmr(struct psp_context *psp)
> 


More information about the amd-gfx mailing list