[PATCH 01/11] drm/amdgpu: Move jpeg ras block init to ras sw_init

Zhou1, Tao Tao.Zhou1 at amd.com
Mon Mar 6 06:26:54 UTC 2023



> -----Original Message-----
> From: Zhang, Hawking <Hawking.Zhang at amd.com>
> Sent: Monday, March 6, 2023 10:32 AM
> To: amd-gfx at lists.freedesktop.org; Zhou1, Tao <Tao.Zhou1 at amd.com>; Yang,
> Stanley <Stanley.Yang at amd.com>; Li, Candice <Candice.Li at amd.com>; Chai,
> Thomas <YiPeng.Chai at amd.com>
> Cc: Zhang, Hawking <Hawking.Zhang at amd.com>
> Subject: [PATCH 01/11] drm/amdgpu: Move jpeg ras block init to ras sw_init
> 
> Initialize jpeg ras block only when jpeg ip block supports ras features. Driver
> queries ras capabilities after early_init, ras block init needs to be moved to
> sw_int.
> 
> Signed-off-by: Hawking Zhang <Hawking.Zhang at amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c | 29 ++++++++++++++++--------
> drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h |  2 +-
>  drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c   | 10 ++++++--
>  drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c   | 10 ++++++--
>  4 files changed, 36 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c
> index 8f472517d181..74695161cf1b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c
> @@ -235,19 +235,28 @@ int amdgpu_jpeg_process_poison_irq(struct
> amdgpu_device *adev,
>  	return 0;
>  }
> 
> -void jpeg_set_ras_funcs(struct amdgpu_device *adev)
> +int amdgpu_jpeg_ras_sw_init(struct amdgpu_device *adev)
>  {
> +	int err;
> +	struct amdgpu_jpeg_ras *ras;
> +
>  	if (!adev->jpeg.ras)
> -		return;
> +		return 0;
> 
> -	amdgpu_ras_register_ras_block(adev, &adev->jpeg.ras->ras_block);
> +	ras = adev->jpeg.ras;
> +	err = amdgpu_ras_register_ras_block(adev, &ras->ras_block);
> +	if (err) {
> +		dev_err(adev->dev, "Failed to register jpeg ras block!\n");
> +		return err;
> +	}
> 
> -	strcpy(adev->jpeg.ras->ras_block.ras_comm.name, "jpeg");
> -	adev->jpeg.ras->ras_block.ras_comm.block =
> AMDGPU_RAS_BLOCK__JPEG;
> -	adev->jpeg.ras->ras_block.ras_comm.type =
> AMDGPU_RAS_ERROR__POISON;
> -	adev->jpeg.ras_if = &adev->jpeg.ras->ras_block.ras_comm;
> +	strcpy(ras->ras_block.ras_comm.name, "jpeg");
> +	ras->ras_block.ras_comm.block = AMDGPU_RAS_BLOCK__JPEG;
> +	ras->ras_block.ras_comm.type = AMDGPU_RAS_ERROR__POISON;
> +	adev->jpeg.ras_if = &ras->ras_block.ras_comm;
> 
> -	/* If don't define special ras_late_init function, use default ras_late_init
> */
> -	if (!adev->jpeg.ras->ras_block.ras_late_init)
> -		adev->jpeg.ras->ras_block.ras_late_init =
> amdgpu_ras_block_late_init;
> +	if (!ras->ras_block.ras_late_init)
> +		ras->ras_block.ras_late_init = amdgpu_ras_block_late_init;
> +
> +	return 0;
>  }
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h
> index e8ca3e32ad52..0ca76f0f23e9 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h
> @@ -72,6 +72,6 @@ int amdgpu_jpeg_dec_ring_test_ib(struct amdgpu_ring
> *ring, long timeout);  int amdgpu_jpeg_process_poison_irq(struct
> amdgpu_device *adev,
>  				struct amdgpu_irq_src *source,
>  				struct amdgpu_iv_entry *entry);
> -void jpeg_set_ras_funcs(struct amdgpu_device *adev);
> +int amdgpu_jpeg_ras_sw_init(struct amdgpu_device *adev);
> 
>  #endif /*__AMDGPU_JPEG_H__*/
> diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c
> b/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c
> index f2b743a93915..7400ed1449e3 100644
> --- a/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c
> +++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c
> @@ -138,6 +138,14 @@ static int jpeg_v2_5_sw_init(void *handle)
>  		adev->jpeg.inst[i].external.jpeg_pitch =
> SOC15_REG_OFFSET(JPEG, i, mmUVD_JPEG_PITCH);
>  	}
> 
> +	if (amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__JPEG)) {

[Tao] can we move the check into xxx_ras_sw_init?

> +		r = amdgpu_jpeg_ras_sw_init(adev);
> +		if (r) {
> +			dev_err(adev->dev, "Failed to initialize jpeg ras
> block!\n");
> +			return r;
> +		}
> +	}
> +
>  	return 0;
>  }
> 
> @@ -806,6 +814,4 @@ static void jpeg_v2_5_set_ras_funcs(struct
> amdgpu_device *adev)
>  	default:
>  		break;
>  	}
> -
> -	jpeg_set_ras_funcs(adev);
>  }
> diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c
> b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c
> index 3beb731b2ce5..f9f682336b3a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c
> @@ -113,6 +113,14 @@ static int jpeg_v4_0_sw_init(void *handle)
>  	adev->jpeg.internal.jpeg_pitch =
> regUVD_JPEG_PITCH_INTERNAL_OFFSET;
>  	adev->jpeg.inst->external.jpeg_pitch = SOC15_REG_OFFSET(JPEG, 0,
> regUVD_JPEG_PITCH);
> 
> +	if (amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__JPEG)) {
> +		r = amdgpu_jpeg_ras_sw_init(adev);
> +		if (r) {
> +			dev_err(adev->dev, "Failed to initialize jpeg ras
> block!\n");
> +			return r;
> +		}
> +	}
> +
>  	return 0;
>  }
> 
> @@ -685,6 +693,4 @@ static void jpeg_v4_0_set_ras_funcs(struct
> amdgpu_device *adev)
>  	default:
>  		break;
>  	}
> -
> -	jpeg_set_ras_funcs(adev);
>  }
> --
> 2.17.1



More information about the amd-gfx mailing list