[PATCH] drm/amdgpu: move amdgpu_num_kcq handling to a helper

Felix Kuehling felix.kuehling at amd.com
Fri Oct 16 15:57:14 UTC 2020


Am 2020-10-16 um 10:20 a.m. schrieb Alex Deucher:
> Add a helper so we can set per asic default values. Also,
> the module parameter is currently clamped to 8, but clamp it
> per asic just in case some asics have different limits in the
> future. Enable the option on gfx6,7 as well for consistency.
>
> Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

Reviewed-by: Felix Kuehling <Felix.Kuehling at amd.com>


> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  7 -------
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    | 11 +++++++++++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h    |  1 +
>  drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c     |  3 ++-
>  drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c      |  3 ++-
>  drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c      |  3 ++-
>  drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c      |  3 ++-
>  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c      |  3 ++-
>  8 files changed, 22 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index abddcd9dab3d..fb9e61f861e9 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -1374,13 +1374,6 @@ static int amdgpu_device_check_arguments(struct amdgpu_device *adev)
>  
>  	amdgpu_gmc_tmz_set(adev);
>  
> -	if (amdgpu_num_kcq == -1) {
> -		amdgpu_num_kcq = 8;
> -	} else if (amdgpu_num_kcq > 8 || amdgpu_num_kcq < 0) {
> -		amdgpu_num_kcq = 8;
> -		dev_warn(adev->dev, "set kernel compute queue number to 8 due to invalid parameter provided by user\n");
> -	}
> -
>  	amdgpu_gmc_noretry_set(adev);
>  
>  	return 0;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> index 8c9bacfdbc30..e584f48f3b54 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> @@ -804,3 +804,14 @@ void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v)
>  failed_kiq_write:
>  	dev_err(adev->dev, "failed to write reg:%x\n", reg);
>  }
> +
> +int amdgpu_gfx_get_num_kcq(struct amdgpu_device *adev)
> +{
> +	if (amdgpu_num_kcq == -1) {
> +		return 8;
> +	} else if (amdgpu_num_kcq > 8 || amdgpu_num_kcq < 0) {
> +		dev_warn(adev->dev, "set kernel compute queue number to 8 due to invalid parameter provided by user\n");
> +		return 8;
> +	}
> +	return amdgpu_num_kcq;
> +}
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
> index 190753930b11..786eb4aa7314 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
> @@ -393,4 +393,5 @@ int amdgpu_gfx_cp_ecc_error_irq(struct amdgpu_device *adev,
>  				  struct amdgpu_iv_entry *entry);
>  uint32_t amdgpu_kiq_rreg(struct amdgpu_device *adev, uint32_t reg);
>  void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v);
> +int amdgpu_gfx_get_num_kcq(struct amdgpu_device *adev);
>  #endif
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
> index 669c352c27af..b4df472194af 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
> @@ -7406,7 +7406,8 @@ static int gfx_v10_0_early_init(void *handle)
>  		break;
>  	}
>  
> -	adev->gfx.num_compute_rings = amdgpu_num_kcq;
> +	adev->gfx.num_compute_rings = min(amdgpu_gfx_get_num_kcq(adev),
> +					  AMDGPU_MAX_COMPUTE_RINGS);
>  
>  	gfx_v10_0_set_kiq_pm4_funcs(adev);
>  	gfx_v10_0_set_ring_funcs(adev);
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
> index 79c52c7a02e3..671c46ebeced 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
> @@ -3064,7 +3064,8 @@ static int gfx_v6_0_early_init(void *handle)
>  	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
>  
>  	adev->gfx.num_gfx_rings = GFX6_NUM_GFX_RINGS;
> -	adev->gfx.num_compute_rings = GFX6_NUM_COMPUTE_RINGS;
> +	adev->gfx.num_compute_rings = min(amdgpu_gfx_get_num_kcq(adev),
> +					  GFX6_NUM_COMPUTE_RINGS);
>  	adev->gfx.funcs = &gfx_v6_0_gfx_funcs;
>  	adev->gfx.rlc.funcs = &gfx_v6_0_rlc_funcs;
>  	gfx_v6_0_set_ring_funcs(adev);
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
> index 04eaf3a8fddb..cb07bc21dcbe 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
> @@ -4238,7 +4238,8 @@ static int gfx_v7_0_early_init(void *handle)
>  	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
>  
>  	adev->gfx.num_gfx_rings = GFX7_NUM_GFX_RINGS;
> -	adev->gfx.num_compute_rings = AMDGPU_MAX_COMPUTE_RINGS;
> +	adev->gfx.num_compute_rings = min(amdgpu_gfx_get_num_kcq(adev),
> +					  AMDGPU_MAX_COMPUTE_RINGS);
>  	adev->gfx.funcs = &gfx_v7_0_gfx_funcs;
>  	adev->gfx.rlc.funcs = &gfx_v7_0_rlc_funcs;
>  	gfx_v7_0_set_ring_funcs(adev);
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> index 94b7e0531d09..6487ea3cfdd2 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
> @@ -5295,7 +5295,8 @@ static int gfx_v8_0_early_init(void *handle)
>  	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
>  
>  	adev->gfx.num_gfx_rings = GFX8_NUM_GFX_RINGS;
> -	adev->gfx.num_compute_rings = amdgpu_num_kcq;
> +	adev->gfx.num_compute_rings = min(amdgpu_gfx_get_num_kcq(adev),
> +					  AMDGPU_MAX_COMPUTE_RINGS);
>  	adev->gfx.funcs = &gfx_v8_0_gfx_funcs;
>  	gfx_v8_0_set_ring_funcs(adev);
>  	gfx_v8_0_set_irq_funcs(adev);
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> index 2c3224948ea5..d3df4c0441a2 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> @@ -4635,7 +4635,8 @@ static int gfx_v9_0_early_init(void *handle)
>  		adev->gfx.num_gfx_rings = 0;
>  	else
>  		adev->gfx.num_gfx_rings = GFX9_NUM_GFX_RINGS;
> -	adev->gfx.num_compute_rings = amdgpu_num_kcq;
> +	adev->gfx.num_compute_rings = min(amdgpu_gfx_get_num_kcq(adev),
> +					  AMDGPU_MAX_COMPUTE_RINGS);
>  	gfx_v9_0_set_kiq_pm4_funcs(adev);
>  	gfx_v9_0_set_ring_funcs(adev);
>  	gfx_v9_0_set_irq_funcs(adev);


More information about the amd-gfx mailing list