diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/soc15.c')
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/soc15.c | 153 | 
1 files changed, 64 insertions, 89 deletions
| diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c index 8e1640bc07af..317803f6a561 100644 --- a/drivers/gpu/drm/amd/amdgpu/soc15.c +++ b/drivers/gpu/drm/amd/amdgpu/soc15.c @@ -67,7 +67,9 @@  #include "vce_v4_0.h"  #include "vcn_v1_0.h"  #include "vcn_v2_0.h" +#include "jpeg_v2_0.h"  #include "vcn_v2_5.h" +#include "jpeg_v2_5.h"  #include "dce_virtual.h"  #include "mxgpu_ai.h"  #include "amdgpu_smu.h" @@ -477,56 +479,18 @@ static int soc15_asic_mode1_reset(struct amdgpu_device *adev)  	return ret;  } -static int soc15_asic_get_baco_capability(struct amdgpu_device *adev, bool *cap) -{ -	if (is_support_sw_smu(adev)) { -		struct smu_context *smu = &adev->smu; - -		*cap = smu_baco_is_support(smu); -		return 0; -	} else { -		void *pp_handle = adev->powerplay.pp_handle; -		const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; - -		if (!pp_funcs || !pp_funcs->get_asic_baco_capability) { -			*cap = false; -			return -ENOENT; -		} - -		return pp_funcs->get_asic_baco_capability(pp_handle, cap); -	} -} -  static int soc15_asic_baco_reset(struct amdgpu_device *adev)  {  	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev); +	int ret = 0;  	/* avoid NBIF got stuck when do RAS recovery in BACO reset */  	if (ras && ras->supported)  		adev->nbio.funcs->enable_doorbell_interrupt(adev, false); -	dev_info(adev->dev, "GPU BACO reset\n"); - -	if (is_support_sw_smu(adev)) { -		struct smu_context *smu = &adev->smu; - -		if (smu_baco_reset(smu)) -			return -EIO; -	} else { -		void *pp_handle = adev->powerplay.pp_handle; -		const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; - -		if (!pp_funcs ||!pp_funcs->get_asic_baco_state ||!pp_funcs->set_asic_baco_state) -			return -ENOENT; - -		/* enter BACO state */ -		if (pp_funcs->set_asic_baco_state(pp_handle, 1)) -			return -EIO; - -		/* exit BACO state */ -		if (pp_funcs->set_asic_baco_state(pp_handle, 0)) -			return -EIO; -	} +	ret = amdgpu_dpm_baco_reset(adev); +	if (ret) +		return ret;  	/* re-enable doorbell interrupt after BACO exit */  	if (ras && ras->supported) @@ -535,21 +499,11 @@ static int soc15_asic_baco_reset(struct amdgpu_device *adev)  	return 0;  } -static int soc15_mode2_reset(struct amdgpu_device *adev) -{ -	if (is_support_sw_smu(adev)) -		return smu_mode2_reset(&adev->smu); -	if (!adev->powerplay.pp_funcs || -	    !adev->powerplay.pp_funcs->asic_reset_mode_2) -		return -ENOENT; - -	return adev->powerplay.pp_funcs->asic_reset_mode_2(adev->powerplay.pp_handle); -} -  static enum amd_reset_method  soc15_asic_reset_method(struct amdgpu_device *adev)  { -	bool baco_reset; +	bool baco_reset = false; +	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);  	switch (adev->asic_type) {  	case CHIP_RAVEN: @@ -557,23 +511,21 @@ soc15_asic_reset_method(struct amdgpu_device *adev)  		return AMD_RESET_METHOD_MODE2;  	case CHIP_VEGA10:  	case CHIP_VEGA12: -		soc15_asic_get_baco_capability(adev, &baco_reset); +	case CHIP_ARCTURUS: +		baco_reset = amdgpu_dpm_is_baco_supported(adev);  		break;  	case CHIP_VEGA20:  		if (adev->psp.sos_fw_version >= 0x80067) -			soc15_asic_get_baco_capability(adev, &baco_reset); -		else -			baco_reset = false; -		if (baco_reset) { -			struct amdgpu_hive_info *hive = amdgpu_get_xgmi_hive(adev, 0); -			struct amdgpu_ras *ras = amdgpu_ras_get_context(adev); +			baco_reset = amdgpu_dpm_is_baco_supported(adev); -			if (hive || (ras && ras->supported)) -				baco_reset = false; -		} +		/* +		 * 1. PMFW version > 0x284300: all cases use baco +		 * 2. PMFW version <= 0x284300: only sGPU w/o RAS use baco +		 */ +		if ((ras && ras->supported) && adev->pm.fw_version <= 0x283400) +			baco_reset = false;  		break;  	default: -		baco_reset = false;  		break;  	} @@ -591,7 +543,7 @@ static int soc15_asic_reset(struct amdgpu_device *adev)  				amdgpu_inc_vram_lost(adev);  			return soc15_asic_baco_reset(adev);  		case AMD_RESET_METHOD_MODE2: -			return soc15_mode2_reset(adev); +			return amdgpu_dpm_mode2_reset(adev);  		default:  			if (!adev->in_suspend)  				amdgpu_inc_vram_lost(adev); @@ -599,6 +551,22 @@ static int soc15_asic_reset(struct amdgpu_device *adev)  	}  } +static bool soc15_supports_baco(struct amdgpu_device *adev) +{ +	switch (adev->asic_type) { +	case CHIP_VEGA10: +	case CHIP_VEGA12: +	case CHIP_ARCTURUS: +		return amdgpu_dpm_is_baco_supported(adev); +	case CHIP_VEGA20: +		if (adev->psp.sos_fw_version >= 0x80067) +			return amdgpu_dpm_is_baco_supported(adev); +		return false; +	default: +		return false; +	} +} +  /*static int soc15_set_uvd_clock(struct amdgpu_device *adev, u32 clock,  			u32 cntl_reg, u32 status_reg)  { @@ -709,9 +677,9 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev)  	}  	if (adev->asic_type == CHIP_VEGA20 || adev->asic_type == CHIP_ARCTURUS) -		adev->df_funcs = &df_v3_6_funcs; +		adev->df.funcs = &df_v3_6_funcs;  	else -		adev->df_funcs = &df_v1_7_funcs; +		adev->df.funcs = &df_v1_7_funcs;  	adev->rev_id = soc15_get_rev_id(adev);  	adev->nbio.funcs->detect_hw_virt(adev); @@ -746,11 +714,11 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev)  		}  		amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block);  		amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block); -		if (!amdgpu_sriov_vf(adev)) { -			if (is_support_sw_smu(adev)) +		if (is_support_sw_smu(adev)) { +			if (!amdgpu_sriov_vf(adev))  				amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block); -			else -				amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); +		} else { +			amdgpu_device_ip_block_add(adev, &pp_smu_ip_block);  		}  		if (adev->enable_virtual_display || amdgpu_sriov_vf(adev))  			amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); @@ -798,11 +766,16 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev)  			amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block);  		amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block);  		amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block); -		if (!amdgpu_sriov_vf(adev)) -			amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block); +		amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block); -		if (unlikely(adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT)) +		if (amdgpu_sriov_vf(adev)) { +			if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) +				amdgpu_device_ip_block_add(adev, &vcn_v2_5_ip_block); +		} else {  			amdgpu_device_ip_block_add(adev, &vcn_v2_5_ip_block); +		} +		if (!amdgpu_sriov_vf(adev)) +			amdgpu_device_ip_block_add(adev, &jpeg_v2_5_ip_block);  		break;  	case CHIP_RENOIR:  		amdgpu_device_ip_block_add(adev, &vega10_common_ip_block); @@ -810,8 +783,7 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev)  		amdgpu_device_ip_block_add(adev, &vega10_ih_ip_block);  		if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP))  			amdgpu_device_ip_block_add(adev, &psp_v12_0_ip_block); -		if (is_support_sw_smu(adev)) -			amdgpu_device_ip_block_add(adev, &smu_v12_0_ip_block); +		amdgpu_device_ip_block_add(adev, &smu_v12_0_ip_block);  		amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block);  		amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block);  		if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) @@ -821,6 +793,7 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev)                          amdgpu_device_ip_block_add(adev, &dm_ip_block);  #endif  		amdgpu_device_ip_block_add(adev, &vcn_v2_0_ip_block); +		amdgpu_device_ip_block_add(adev, &jpeg_v2_0_ip_block);  		break;  	default:  		return -EINVAL; @@ -999,6 +972,7 @@ static const struct amdgpu_asic_funcs soc15_asic_funcs =  	.get_pcie_usage = &soc15_get_pcie_usage,  	.need_reset_on_init = &soc15_need_reset_on_init,  	.get_pcie_replay_count = &soc15_get_pcie_replay_count, +	.supports_baco = &soc15_supports_baco,  };  static const struct amdgpu_asic_funcs vega20_asic_funcs = @@ -1007,6 +981,7 @@ static const struct amdgpu_asic_funcs vega20_asic_funcs =  	.read_bios_from_rom = &soc15_read_bios_from_rom,  	.read_register = &soc15_read_register,  	.reset = &soc15_asic_reset, +	.reset_method = &soc15_asic_reset_method,  	.set_vga_state = &soc15_vga_set_state,  	.get_xclk = &soc15_get_xclk,  	.set_uvd_clocks = &soc15_set_uvd_clocks, @@ -1019,7 +994,7 @@ static const struct amdgpu_asic_funcs vega20_asic_funcs =  	.get_pcie_usage = &vega20_get_pcie_usage,  	.need_reset_on_init = &soc15_need_reset_on_init,  	.get_pcie_replay_count = &soc15_get_pcie_replay_count, -	.reset_method = &soc15_asic_reset_method +	.supports_baco = &soc15_supports_baco,  };  static int soc15_common_early_init(void *handle) @@ -1145,9 +1120,7 @@ static int soc15_common_early_init(void *handle)  				AMD_CG_SUPPORT_SDMA_LS |  				AMD_CG_SUPPORT_VCN_MGCG; -			adev->pg_flags = AMD_PG_SUPPORT_SDMA | -				AMD_PG_SUPPORT_VCN | -				AMD_PG_SUPPORT_VCN_DPG; +			adev->pg_flags = AMD_PG_SUPPORT_SDMA | AMD_PG_SUPPORT_VCN;  		} else if (adev->pdev->device == 0x15d8) {  			adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |  				AMD_CG_SUPPORT_GFX_MGLS | @@ -1190,9 +1163,7 @@ static int soc15_common_early_init(void *handle)  				AMD_CG_SUPPORT_SDMA_LS |  				AMD_CG_SUPPORT_VCN_MGCG; -			adev->pg_flags = AMD_PG_SUPPORT_SDMA | -				AMD_PG_SUPPORT_VCN | -				AMD_PG_SUPPORT_VCN_DPG; +			adev->pg_flags = AMD_PG_SUPPORT_SDMA | AMD_PG_SUPPORT_VCN;  		}  		break;  	case CHIP_ARCTURUS: @@ -1208,7 +1179,9 @@ static int soc15_common_early_init(void *handle)  			AMD_CG_SUPPORT_SDMA_LS |  			AMD_CG_SUPPORT_MC_MGCG |  			AMD_CG_SUPPORT_MC_LS | -			AMD_CG_SUPPORT_IH_CG; +			AMD_CG_SUPPORT_IH_CG | +			AMD_CG_SUPPORT_VCN_MGCG | +			AMD_CG_SUPPORT_JPEG_MGCG;  		adev->pg_flags = 0;  		adev->external_rev_id = adev->rev_id + 0x32;  		break; @@ -1229,12 +1202,14 @@ static int soc15_common_early_init(void *handle)  				 AMD_CG_SUPPORT_HDP_LS |  				 AMD_CG_SUPPORT_ROM_MGCG |  				 AMD_CG_SUPPORT_VCN_MGCG | +				 AMD_CG_SUPPORT_JPEG_MGCG |  				 AMD_CG_SUPPORT_IH_CG |  				 AMD_CG_SUPPORT_ATHUB_LS |  				 AMD_CG_SUPPORT_ATHUB_MGCG |  				 AMD_CG_SUPPORT_DF_MGCG;  		adev->pg_flags = AMD_PG_SUPPORT_SDMA |  				 AMD_PG_SUPPORT_VCN | +				 AMD_PG_SUPPORT_JPEG |  				 AMD_PG_SUPPORT_VCN_DPG;  		adev->external_rev_id = adev->rev_id + 0x91;  		break; @@ -1272,7 +1247,7 @@ static int soc15_common_sw_init(void *handle)  	if (amdgpu_sriov_vf(adev))  		xgpu_ai_mailbox_add_irq_id(adev); -	adev->df_funcs->sw_init(adev); +	adev->df.funcs->sw_init(adev);  	return 0;  } @@ -1282,7 +1257,7 @@ static int soc15_common_sw_fini(void *handle)  	struct amdgpu_device *adev = (struct amdgpu_device *)handle;  	amdgpu_nbio_ras_fini(adev); -	adev->df_funcs->sw_fini(adev); +	adev->df.funcs->sw_fini(adev);  	return 0;  } @@ -1503,7 +1478,7 @@ static int soc15_common_set_clockgating_state(void *handle,  				state == AMD_CG_STATE_GATE ? true : false);  		soc15_update_rom_medium_grain_clock_gating(adev,  				state == AMD_CG_STATE_GATE ? true : false); -		adev->df_funcs->update_medium_grain_clock_gating(adev, +		adev->df.funcs->update_medium_grain_clock_gating(adev,  				state == AMD_CG_STATE_GATE ? true : false);  		break;  	case CHIP_RAVEN: @@ -1561,7 +1536,7 @@ static void soc15_common_get_clockgating_state(void *handle, u32 *flags)  	if (!(data & CGTT_ROM_CLK_CTRL0__SOFT_OVERRIDE0_MASK))  		*flags |= AMD_CG_SUPPORT_ROM_MGCG; -	adev->df_funcs->get_clockgating_state(adev, flags); +	adev->df.funcs->get_clockgating_state(adev, flags);  }  static int soc15_common_set_powergating_state(void *handle, |