[PATCH] drm/amdgpu/psp: move TMR to cpu invisible vram region

Koenig, Christian Christian.Koenig at amd.com
Mon Aug 19 08:46:23 UTC 2019


OH, STOP!  Good that we talked about that because that would have caused quite a bunch of trouble.

The case in amdgpu_ttm_init() would break, we intentionally reserve memory at the beginning of the visible space here to avoid problem switching between VBIOS and KMS.

I suggest to first add a dummy pointer to amdgpu_ttm_init() to fix this before you apply this patch.

Regards,
Christian.

Am 19.08.19 um 10:16 schrieb Yin, Tianci (Rico):
Thanks very much Christian!

I scanned the whole code, only two functions pass in NULL cpu_addr,
amdgpu_ttm_init() and gfx_v9_0_ngg_create_buf(),
but the related BOs are not further mapped for cpu access.
so I think this change is safe.


________________________________
From: Christian König <ckoenig.leichtzumerken at gmail.com><mailto:ckoenig.leichtzumerken at gmail.com>
Sent: Monday, August 19, 2019 16:07
To: Yin, Tianci (Rico) <Tianci.Yin at amd.com><mailto:Tianci.Yin at amd.com>; amd-gfx at lists.freedesktop.org<mailto:amd-gfx at lists.freedesktop.org> <amd-gfx at lists.freedesktop.org><mailto:amd-gfx at lists.freedesktop.org>
Cc: Xiao, Jack <Jack.Xiao at amd.com><mailto:Jack.Xiao at amd.com>; Yuan, Xiaojie <Xiaojie.Yuan at amd.com><mailto:Xiaojie.Yuan at amd.com>; Zhang, Hawking <Hawking.Zhang at amd.com><mailto:Hawking.Zhang at amd.com>
Subject: Re: [PATCH] drm/amdgpu/psp: move TMR to cpu invisible vram region

Am 19.08.19 um 10:05 schrieb Tianci Yin:
> From: "Tianci.Yin" <tianci.yin at amd.com><mailto:tianci.yin at amd.com>
>
> so that more visible vram can be available for umd.
>
> Signed-off-by: Tianci.Yin <tianci.yin at amd.com><mailto:tianci.yin at amd.com>

Assuming that you checked that we don't have other users who are using
amdgpu_bo_create_kernel() without a CPU pointer this patch is
Reviewed-by: Christian König <christian.koenig at amd.com><mailto:christian.koenig at amd.com>.

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 5 +++--
>   drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c    | 4 ++--
>   drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h    | 1 -
>   3 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index 1059771..0476790 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -246,8 +246,9 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev,
>        bp.size = size;
>        bp.byte_align = align;
>        bp.domain = domain;
> -     bp.flags = AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
> -             AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
> +     bp.flags = cpu_addr ? AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED
> +             : AMDGPU_GEM_CREATE_NO_CPU_ACCESS;
> +     bp.flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
>        bp.type = ttm_bo_type_kernel;
>        bp.resv = NULL;
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> index 7715c0d..5e7fbbe 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> @@ -264,7 +264,7 @@ static int psp_tmr_init(struct psp_context *psp)
>
>        ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
>                                      AMDGPU_GEM_DOMAIN_VRAM,
> -                                   &psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf);
> +                                   &psp->tmr_bo, &psp->tmr_mc_addr, NULL);
>
>        return ret;
>   }
> @@ -1215,7 +1215,7 @@ static int psp_hw_fini(void *handle)
>
>        psp_ring_destroy(psp, PSP_RING_TYPE__KM);
>
> -     amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf);
> +     amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, NULL);
>        amdgpu_bo_free_kernel(&psp->fw_pri_bo,
>                              &psp->fw_pri_mc_addr, &psp->fw_pri_buf);
>        amdgpu_bo_free_kernel(&psp->fence_buf_bo,
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> index 0029fa2..48b057d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> @@ -172,7 +172,6 @@ struct psp_context
>        /* tmr buffer */
>        struct amdgpu_bo                *tmr_bo;
>        uint64_t                        tmr_mc_addr;
> -     void                            *tmr_buf;
>
>        /* asd firmware and buffer */
>        const struct firmware           *asd_fw;


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20190819/e27f76b0/attachment.html>


More information about the amd-gfx mailing list