[PATCH 1/3] drm/amd: Fix handling of amdgpu.runpm on systems with BOCO

Lazar, Lijo lijo.lazar at amd.com
Wed Nov 29 10:49:58 UTC 2023



On 11/29/2023 12:22 AM, Mario Limonciello wrote:
> On products that support both BOCO and BACO it should be possible
> to override the BOCO detection and force BACO by amdgpu.runpm=1 but
> this doesn't work today.
> 
> Adjust the logic used in amdgpu_driver_load_kms() to make sure that
> module parameters are looked at first and only use automatic policies
> in the -1 or -2 cases.
> 
> Signed-off-by: Mario Limonciello <mario.limonciello at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 80 +++++++++++++++----------
>   1 file changed, 48 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index b5ebafd4a3ad..29381da08fd5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -121,6 +121,53 @@ void amdgpu_register_gpu_instance(struct amdgpu_device *adev)
>   	mutex_unlock(&mgpu_info.mutex);
>   }
>   
> +static void amdgpu_driver_set_runtime_pm_mode(struct amdgpu_device *adev)
> +{
> +	struct drm_device *dev = adev_to_drm(adev);
> +
> +	adev->pm.rpm_mode = AMDGPU_RUNPM_NONE;
> +
> +	switch (amdgpu_runtime_pm) {
> +	case -1:
> +	case -2:
> +		break;
> +	case 0:
> +	default:
> +		return;
> +	case 1:
> +		if (amdgpu_device_supports_baco(dev))
> +			adev->pm.rpm_mode = AMDGPU_RUNPM_BACO;
> +		else
> +			dev_err(adev->dev, "BACO is not supported on this ASIC\n");
> +		return;
> +	case 2:
> +		// TODO: adjust plumbing to be able to pull PP table to check MACO support as well
> +		if (amdgpu_device_supports_baco(dev))
> +			adev->pm.rpm_mode = AMDGPU_RUNPM_BACO;
> +		else
> +			dev_err(adev->dev, "BAMACO is not supported on this ASIC\n");
> +		return;
> +	}
> +
> +	if (amdgpu_device_supports_px(dev)) {
> +		adev->pm.rpm_mode = AMDGPU_RUNPM_PX;
> +		dev_info(adev->dev, "Using ATPX for runtime pm\n");
> +	} else if (amdgpu_device_supports_boco(dev)) {
> +		adev->pm.rpm_mode = AMDGPU_RUNPM_BOCO;
> +		dev_info(adev->dev, "Using BOCO for runtime pm\n");
> +	} else if (amdgpu_device_supports_baco(dev)) {
> +		if (adev->asic_type == CHIP_VEGA10) {
> +			/* enable BACO as runpm mode if noretry=0 */
> +			if (!adev->gmc.noretry)
> +				adev->pm.rpm_mode = AMDGPU_RUNPM_BACO;
> +		} else {
> +			adev->pm.rpm_mode = AMDGPU_RUNPM_BACO;

On VG20/ARCT, older logic doesn't use BACO as runpm mode unless forced. 
This logic breaks it.

Thanks,
Lijo
> +		}
> +		if (adev->pm.rpm_mode == AMDGPU_RUNPM_BACO)
> +			dev_info(adev->dev, "Using BACO for runtime pm\n");
> +	}
> +}
> +
>   /**
>    * amdgpu_driver_load_kms - Main load function for KMS.
>    *
> @@ -149,38 +196,7 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags)
>   		goto out;
>   	}
>   
> -	adev->pm.rpm_mode = AMDGPU_RUNPM_NONE;
> -	if (amdgpu_device_supports_px(dev) &&
> -	    (amdgpu_runtime_pm != 0)) { /* enable PX as runtime mode */
> -		adev->pm.rpm_mode = AMDGPU_RUNPM_PX;
> -		dev_info(adev->dev, "Using ATPX for runtime pm\n");
> -	} else if (amdgpu_device_supports_boco(dev) &&
> -		   (amdgpu_runtime_pm != 0)) { /* enable boco as runtime mode */
> -		adev->pm.rpm_mode = AMDGPU_RUNPM_BOCO;
> -		dev_info(adev->dev, "Using BOCO for runtime pm\n");
> -	} else if (amdgpu_device_supports_baco(dev) &&
> -		   (amdgpu_runtime_pm != 0)) {
> -		switch (adev->asic_type) {
> -		case CHIP_VEGA20:
> -		case CHIP_ARCTURUS:
> -			/* enable BACO as runpm mode if runpm=1 */
> -			if (amdgpu_runtime_pm > 0)
> -				adev->pm.rpm_mode = AMDGPU_RUNPM_BACO;
> -			break;
> -		case CHIP_VEGA10:
> -			/* enable BACO as runpm mode if noretry=0 */
> -			if (!adev->gmc.noretry)
> -				adev->pm.rpm_mode = AMDGPU_RUNPM_BACO;
> -			break;
> -		default:
> -			/* enable BACO as runpm mode on CI+ */
> -			adev->pm.rpm_mode = AMDGPU_RUNPM_BACO;
> -			break;
> -		}
> -
> -		if (adev->pm.rpm_mode == AMDGPU_RUNPM_BACO)
> -			dev_info(adev->dev, "Using BACO for runtime pm\n");
> -	}
> +	amdgpu_driver_set_runtime_pm_mode(adev);
>   
>   	/* Call ACPI methods: require modeset init
>   	 * but failure is not fatal



More information about the amd-gfx mailing list