[v4,27/27] drm/amd: Optimize SRIOV switch/case for PSP microcode load

Message ID 20230103221852.22813-28-mario.limonciello@amd.com
State New
Headers
Series Recover from failure to probe GPU |

Commit Message

Mario Limonciello Jan. 3, 2023, 10:18 p.m. UTC
  Now that IP version decoding is used, a number of case statements
can be combined.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v3->v4:
 * New patch

 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
  

Comments

Christian König Jan. 4, 2023, 1:18 p.m. UTC | #1
Am 03.01.23 um 23:18 schrieb Mario Limonciello:
> Now that IP version decoding is used, a number of case statements
> can be combined.
>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>

This patch can probably be pushed as small cleanup independent of the 
previous patches.

In general I usually suggest to push those separately to make the patch 
set concentrate on the real changes at hand.

Anyway this patch here is Reviewed-by: Christian König 
<christian.koenig@amd.com>

Regards,
Christian.

> ---
> v3->v4:
>   * New patch
>
>   drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 8 +-------
>   1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> index f45362dd8228..83e253b5d928 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> @@ -132,14 +132,8 @@ static int psp_init_sriov_microcode(struct psp_context *psp)
>   
>   	switch (adev->ip_versions[MP0_HWIP][0]) {
>   	case IP_VERSION(9, 0, 0):
> -		adev->virt.autoload_ucode_id = AMDGPU_UCODE_ID_CP_MEC2;
> -		ret = psp_init_cap_microcode(psp, ucode_prefix);
> -		break;
> -	case IP_VERSION(11, 0, 9):
> -		adev->virt.autoload_ucode_id = AMDGPU_UCODE_ID_CP_MEC2;
> -		ret = psp_init_cap_microcode(psp, ucode_prefix);
> -		break;
>   	case IP_VERSION(11, 0, 7):
> +	case IP_VERSION(11, 0, 9):
>   		adev->virt.autoload_ucode_id = AMDGPU_UCODE_ID_CP_MEC2;
>   		ret = psp_init_cap_microcode(psp, ucode_prefix);
>   		break;
  
Mario Limonciello Jan. 4, 2023, 3:42 p.m. UTC | #2
[Public]



> -----Original Message-----
> From: Christian König <ckoenig.leichtzumerken@gmail.com>
> Sent: Wednesday, January 4, 2023 07:18
> To: Limonciello, Mario <Mario.Limonciello@amd.com>; Deucher, Alexander
> <Alexander.Deucher@amd.com>; linux-kernel@vger.kernel.org
> Cc: Pan, Xinhui <Xinhui.Pan@amd.com>; Lazar, Lijo <Lijo.Lazar@amd.com>;
> Javier Martinez Canillas <javierm@redhat.com>; dri-
> devel@lists.freedesktop.org; amd-gfx@lists.freedesktop.org; Daniel Vetter
> <daniel@ffwll.ch>; Carlos Soriano Sanchez <csoriano@redhat.com>; David
> Airlie <airlied@gmail.com>; Koenig, Christian <Christian.Koenig@amd.com>
> Subject: Re: [PATCH v4 27/27] drm/amd: Optimize SRIOV switch/case for PSP
> microcode load
> 
> Am 03.01.23 um 23:18 schrieb Mario Limonciello:
> > Now that IP version decoding is used, a number of case statements
> > can be combined.
> >
> > Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> 
> This patch can probably be pushed as small cleanup independent of the
> previous patches.
> 
> In general I usually suggest to push those separately to make the patch
> set concentrate on the real changes at hand.
> 
> Anyway this patch here is Reviewed-by: Christian König
> <christian.koenig@amd.com>
> 

Thanks!
This optimization is only possible because of earlier changes in the series.
Will add your tag for v5.

> Regards,
> Christian.
> 
> > ---
> > v3->v4:
> >   * New patch
> >
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 8 +-------
> >   1 file changed, 1 insertion(+), 7 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> > index f45362dd8228..83e253b5d928 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> > @@ -132,14 +132,8 @@ static int psp_init_sriov_microcode(struct
> psp_context *psp)
> >
> >   	switch (adev->ip_versions[MP0_HWIP][0]) {
> >   	case IP_VERSION(9, 0, 0):
> > -		adev->virt.autoload_ucode_id =
> AMDGPU_UCODE_ID_CP_MEC2;
> > -		ret = psp_init_cap_microcode(psp, ucode_prefix);
> > -		break;
> > -	case IP_VERSION(11, 0, 9):
> > -		adev->virt.autoload_ucode_id =
> AMDGPU_UCODE_ID_CP_MEC2;
> > -		ret = psp_init_cap_microcode(psp, ucode_prefix);
> > -		break;
> >   	case IP_VERSION(11, 0, 7):
> > +	case IP_VERSION(11, 0, 9):
> >   		adev->virt.autoload_ucode_id =
> AMDGPU_UCODE_ID_CP_MEC2;
> >   		ret = psp_init_cap_microcode(psp, ucode_prefix);
> >   		break;
  

Patch

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index f45362dd8228..83e253b5d928 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -132,14 +132,8 @@  static int psp_init_sriov_microcode(struct psp_context *psp)
 
 	switch (adev->ip_versions[MP0_HWIP][0]) {
 	case IP_VERSION(9, 0, 0):
-		adev->virt.autoload_ucode_id = AMDGPU_UCODE_ID_CP_MEC2;
-		ret = psp_init_cap_microcode(psp, ucode_prefix);
-		break;
-	case IP_VERSION(11, 0, 9):
-		adev->virt.autoload_ucode_id = AMDGPU_UCODE_ID_CP_MEC2;
-		ret = psp_init_cap_microcode(psp, ucode_prefix);
-		break;
 	case IP_VERSION(11, 0, 7):
+	case IP_VERSION(11, 0, 9):
 		adev->virt.autoload_ucode_id = AMDGPU_UCODE_ID_CP_MEC2;
 		ret = psp_init_cap_microcode(psp, ucode_prefix);
 		break;