From: "Koenig, Christian" Subject: Re: [PATCH] drm/amdgpu/psp: keep TMR in visible vram region for SRIOV Date: Wed, 28 Aug 2019 11:08:45 +0000 Message-ID: <85324125-c6dd-4f93-807f-04ff0ee7c815@email.android.com> References: <1566984335-14830-1-git-send-email-tianci.yin@amd.com>, <45fe6586-a53a-6f02-0e5f-b6224b159e12@gmail.com>, Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1195708386==" Return-path: In-Reply-To: Content-Language: de-DE List-Id: Discussion list for AMD gfx List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org Sender: "amd-gfx" To: "Yin, Tianci (Rico)" Cc: "Xu, Feifei" , "Xiao, Jack" , "Zhang, Hawking" , "amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org" , "Ma, Le" --===============1195708386== Content-Language: de-DE Content-Type: multipart/alternative; boundary="_000_85324125c6dd4f93807f04ff0ee7c815emailandroidcom_" --_000_85324125c6dd4f93807f04ff0ee7c815emailandroidcom_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable That's irrelevant in this case. CPU mapping's are destroyed automatically w= hen the BO is freed. Giving the CPU pointer to the free function is only for extra checking that= we can't access it anymore. Christian. Am 28.08.2019 13:05 schrieb "Yin, Tianci (Rico)" : Might be better to use a local variable for the CPU pointer instead of duplicating the calling parameters. Local variable can't be used in cleaner. ________________________________ From: Christian K=F6nig Sent: Wednesday, August 28, 2019 17:57 To: Yin, Tianci (Rico) ; amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org = Cc: Xu, Feifei ; Ma, Le ; Xiao, Jack ; Zhang, Hawking Subject: Re: [PATCH] drm/amdgpu/psp: keep TMR in visible vram region for SR= IOV Am 28.08.19 um 11:25 schrieb Tianci Yin: > From: "Tianci.Yin" > > Fix compute ring test failure in sriov scenario. > > Signed-off-by: Tianci.Yin > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 14 ++++++++++---- > drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 1 + > 2 files changed, 11 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/am= d/amdgpu/amdgpu_psp.c > index 9f7cc5b..92c68c9 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c > @@ -261,9 +261,15 @@ static int psp_tmr_init(struct psp_context *psp) > } > } > > - ret =3D amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE, > - AMDGPU_GEM_DOMAIN_VRAM, > - &psp->tmr_bo, &psp->tmr_mc_addr, NULL= ); > + psp->tmr_buf =3D NULL; > + if (!amdgpu_sriov_vf(psp->adev)) > + ret =3D amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TM= R_SIZE, > + AMDGPU_GEM_DOMAIN_VRAM, > + &psp->tmr_bo, &psp->tmr_mc_ad= dr, NULL); > + else > + ret =3D amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TM= R_SIZE, > + AMDGPU_GEM_DOMAIN_VRAM, > + &psp->tmr_bo, &psp->tmr_mc_ad= dr, &psp->tmr_buf); Might be better to use a local variable for the CPU pointer instead of duplicating the calling parameters. BTW: How did you solved the stolen_vga_memory problem I pointed out in the original patch set? Christian. > > return ret; > } > @@ -1216,7 +1222,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, NULL); > + amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_bu= f); > 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/am= d/amdgpu/amdgpu_psp.h > index bc0947f..b73d4aa 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h > @@ -171,6 +171,7 @@ 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; --_000_85324125c6dd4f93807f04ff0ee7c815emailandroidcom_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
That's irrelevant in this case. CPU mapping's are destroy= ed automatically when the BO is freed.

Giving the CPU pointer to the free function is only for e= xtra checking that we can't access it anymore.

Christian.

Am 28.08.2019 13:05 schrieb "Yin, Tianci (R= ico)" <Tianci.Yin-5C7GfCeVMHo@public.gmane.org>:
Might be better to use a lo= cal variable for the CPU pointer instead of
duplicating the calling par= ameters.

Local variable can't be used in cleaner.




From: Christian K=F6nig <= ;ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Sent: Wednesday, August 28, 2019 17:57
To: Yin, Tianci (Rico) <Tianci.Yin-5C7GfCeVMHo@public.gmane.org>; amd-gfx-PD4FTy7X32mzQB+pC5nmwQ@public.gmane.org= edesktop.org <amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
Cc: Xu, Feifei <Feifei.Xu-5C7GfCeVMHo@public.gmane.org>; Ma, Le <Le.Ma-5C7GfCeVMHo@public.gmane.org&g= t;; Xiao, Jack <Jack.Xiao-5C7GfCeVMHo@public.gmane.org>; Zhang, Hawking <Hawking.Zhang@= amd.com>
Subject: Re: [PATCH] drm/amdgpu/psp: keep TMR in visible vram region= for SRIOV
 
Am 28.08.19 um 11:25 schrieb Tianci Yin:
> From: "Tianci.Yin" <tianci.yin-5C7GfCeVMHo@public.gmane.org>
>
> Fix compute ring test failure in sriov scenario.
>
> Signed-off-by: Tianci.Yin <tianci.yin-5C7GfCeVMHo@public.gmane.org>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 14 ++= 3;+++++++----
>   drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  1 + >   2 files changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm= /amd/amdgpu/amdgpu_psp.c
> index 9f7cc5b..92c68c9 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> @@ -261,9 +261,15 @@ static int psp_tmr_init(struct psp_context *p= sp)
>            = ;    }
>        }
>  
> -     ret =3D amdgpu_bo_create_kernel(psp->adev= , tmr_size, PSP_TMR_SIZE,
> -           &nb= sp;            =            AMDGPU_GEM_DOM= AIN_VRAM,
> -           &nb= sp;            =            &psp->t= mr_bo, &psp->tmr_mc_addr, NULL);
> +     psp->tmr_buf =3D NULL;
> +     if (!amdgpu_sriov_vf(psp->adev))
> +           = ;  ret =3D amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZ= E,
> +           = ;            &n= bsp;            = ;       AMDGPU_GEM_DOMAIN_VRAM,
> +           = ;            &n= bsp;            = ;       &psp->tmr_bo, &psp->tmr= _mc_addr, NULL);
> +     else
> +           = ;  ret =3D amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZ= E,
> +           = ;            &n= bsp;            = ;       AMDGPU_GEM_DOMAIN_VRAM,
> +           = ;            &n= bsp;            = ;       &psp->tmr_bo, &psp->tmr= _mc_addr, &psp->tmr_buf);

Might be better to use a local variable for the CPU pointer instead of
duplicating the calling parameters.

BTW: How did you solved the stolen_vga_memory problem I pointed out in
the original patch set?

Christian.

>  
>        return ret;
>   }
> @@ -1216,7 +1222,7 @@ static int psp_hw_fini(void *handle)
>  
>        psp_ring_destroy(psp, PSP_RI= NG_TYPE__KM);
>  
> -     amdgpu_bo_free_kernel(&psp->tmr_bo, &= amp;psp->tmr_mc_addr, NULL);
> +     amdgpu_bo_free_kernel(&psp->tmr_b= o, &psp->tmr_mc_addr, &psp->tmr_buf);
>        amdgpu_bo_free_kernel(&p= sp->fw_pri_bo,
>            = ;            &n= bsp;     &psp->fw_pri_mc_addr, &psp->fw_p= ri_buf);
>        amdgpu_bo_free_kernel(&p= sp->fence_buf_bo,
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h b/drivers/gpu/drm= /amd/amdgpu/amdgpu_psp.h
> index bc0947f..b73d4aa 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> @@ -171,6 +171,7 @@ struct psp_context
>        /* tmr buffer */
>        struct amdgpu_bo  =             &nb= sp; *tmr_bo;
>        uint64_t   &n= bsp;            = ;        tmr_mc_addr;
> +     void      =             &nb= sp;         *tmr_buf;
>  
>        /* asd firmware and buffer *= /
>        const struct firmware &= nbsp;         *asd_fw;

--_000_85324125c6dd4f93807f04ff0ee7c815emailandroidcom_-- --===============1195708386== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KYW1kLWdmeCBt YWlsaW5nIGxpc3QKYW1kLWdmeEBsaXN0cy5mcmVlZGVza3RvcC5vcmcKaHR0cHM6Ly9saXN0cy5m cmVlZGVza3RvcC5vcmcvbWFpbG1hbi9saXN0aW5mby9hbWQtZ2Z4 --===============1195708386==--