diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/soc15.c')
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/soc15.c | 346 | 
1 files changed, 93 insertions, 253 deletions
| diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c index 0fc97c364fd7..0c316a2d42ed 100644 --- a/drivers/gpu/drm/amd/amdgpu/soc15.c +++ b/drivers/gpu/drm/amd/amdgpu/soc15.c @@ -85,6 +85,8 @@  #define mmMP0_MISC_LIGHT_SLEEP_CTRL                                                             0x01ba  #define mmMP0_MISC_LIGHT_SLEEP_CTRL_BASE_IDX                                                    0 +static const struct amd_ip_funcs soc15_common_ip_funcs; +  /* Vega, Raven, Arcturus */  static const struct amdgpu_video_codec_info vega_video_codecs_encode_array[] =  { @@ -154,31 +156,38 @@ static const struct amdgpu_video_codecs rn_video_codecs_decode =  static int soc15_query_video_codecs(struct amdgpu_device *adev, bool encode,  				    const struct amdgpu_video_codecs **codecs)  { -	switch (adev->asic_type) { -	case CHIP_VEGA20: -	case CHIP_VEGA10: -	case CHIP_VEGA12: -		if (encode) -			*codecs = &vega_video_codecs_encode; -		else -			*codecs = &vega_video_codecs_decode; -		return 0; -	case CHIP_RAVEN: -		if (encode) -			*codecs = &vega_video_codecs_encode; -		else -			*codecs = &rv_video_codecs_decode; -		return 0; -	case CHIP_ARCTURUS: -	case CHIP_ALDEBARAN: -	case CHIP_RENOIR: -		if (encode) -			*codecs = &vega_video_codecs_encode; -		else -			*codecs = &rn_video_codecs_decode; -		return 0; -	default: -		return -EINVAL; +	if (adev->ip_versions[VCE_HWIP][0]) { +		switch (adev->ip_versions[VCE_HWIP][0]) { +		case IP_VERSION(4, 0, 0): +		case IP_VERSION(4, 1, 0): +			if (encode) +				*codecs = &vega_video_codecs_encode; +			else +				*codecs = &vega_video_codecs_decode; +			return 0; +		default: +			return -EINVAL; +		} +	} else { +		switch (adev->ip_versions[UVD_HWIP][0]) { +		case IP_VERSION(1, 0, 0): +		case IP_VERSION(1, 0, 1): +			if (encode) +				*codecs = &vega_video_codecs_encode; +			else +				*codecs = &rv_video_codecs_decode; +			return 0; +		case IP_VERSION(2, 5, 0): +		case IP_VERSION(2, 6, 0): +		case IP_VERSION(2, 2, 0): +			if (encode) +				*codecs = &vega_video_codecs_encode; +			else +				*codecs = &rn_video_codecs_decode; +			return 0; +		default: +			return -EINVAL; +		}  	}  } @@ -332,9 +341,11 @@ static u32 soc15_get_xclk(struct amdgpu_device *adev)  {  	u32 reference_clock = adev->clock.spll.reference_freq; -	if (adev->asic_type == CHIP_RENOIR) +	if (adev->ip_versions[MP1_HWIP][0] == IP_VERSION(12, 0, 0) || +	    adev->ip_versions[MP1_HWIP][0] == IP_VERSION(12, 0, 1))  		return 10000; -	if (adev->asic_type == CHIP_RAVEN) +	if (adev->ip_versions[MP1_HWIP][0] == IP_VERSION(10, 0, 0) || +	    adev->ip_versions[MP1_HWIP][0] == IP_VERSION(10, 0, 1))  		return reference_clock / 4;  	return reference_clock; @@ -565,28 +576,29 @@ soc15_asic_reset_method(struct amdgpu_device *adev)  		dev_warn(adev->dev, "Specified reset method:%d isn't supported, using AUTO instead.\n",  				  amdgpu_reset_method); -	switch (adev->asic_type) { -	case CHIP_RAVEN: -	case CHIP_RENOIR: +	switch (adev->ip_versions[MP1_HWIP][0]) { +	case IP_VERSION(10, 0, 0): +	case IP_VERSION(10, 0, 1): +	case IP_VERSION(12, 0, 0): +	case IP_VERSION(12, 0, 1):  		return AMD_RESET_METHOD_MODE2; -	case CHIP_VEGA10: -	case CHIP_VEGA12: -	case CHIP_ARCTURUS: -		baco_reset = amdgpu_dpm_is_baco_supported(adev); -		break; -	case CHIP_VEGA20: -		if (adev->psp.sos.fw_version >= 0x80067) +	case IP_VERSION(9, 0, 0): +	case IP_VERSION(11, 0, 2): +		if (adev->asic_type == CHIP_VEGA20) { +			if (adev->psp.sos.fw_version >= 0x80067) +				baco_reset = amdgpu_dpm_is_baco_supported(adev); +			/* +			 * 1. PMFW version > 0x284300: all cases use baco +			 * 2. PMFW version <= 0x284300: only sGPU w/o RAS use baco +			 */ +			if (ras && adev->ras_enabled && +			    adev->pm.fw_version <= 0x283400) +				baco_reset = false; +		} else {  			baco_reset = amdgpu_dpm_is_baco_supported(adev); - -		/* -		 * 1. PMFW version > 0x284300: all cases use baco -		 * 2. PMFW version <= 0x284300: only sGPU w/o RAS use baco -		 */ -		if (ras && adev->ras_enabled && -		    adev->pm.fw_version <= 0x283400) -			baco_reset = false; +		}  		break; -	case CHIP_ALDEBARAN: +	case IP_VERSION(13, 0, 2):  		 /*  		 * 1.connected to cpu: driver issue mode2 reset  		 * 2.discret gpu: driver issue mode1 reset @@ -629,15 +641,17 @@ 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) +	switch (adev->ip_versions[MP1_HWIP][0]) { +	case IP_VERSION(9, 0, 0): +	case IP_VERSION(11, 0, 2): +		if (adev->asic_type == CHIP_VEGA20) { +			if (adev->psp.sos.fw_version >= 0x80067) +				return amdgpu_dpm_is_baco_supported(adev); +			return false; +		} else {  			return amdgpu_dpm_is_baco_supported(adev); -		return false; +		} +		break;  	default:  		return false;  	} @@ -704,7 +718,7 @@ static void soc15_enable_doorbell_aperture(struct amdgpu_device *adev,  	adev->nbio.funcs->enable_doorbell_selfring_aperture(adev, enable);  } -static const struct amdgpu_ip_block_version vega10_common_ip_block = +const struct amdgpu_ip_block_version vega10_common_ip_block =  {  	.type = AMD_IP_BLOCK_TYPE_COMMON,  	.major = 2, @@ -766,185 +780,6 @@ void soc15_set_virt_ops(struct amdgpu_device *adev)  	soc15_reg_base_init(adev);  } -int soc15_set_ip_blocks(struct amdgpu_device *adev) -{ -	/* for bare metal case */ -	if (!amdgpu_sriov_vf(adev)) -		soc15_reg_base_init(adev); - -	if (adev->flags & AMD_IS_APU) { -		adev->nbio.funcs = &nbio_v7_0_funcs; -		adev->nbio.hdp_flush_reg = &nbio_v7_0_hdp_flush_reg; -	} else if (adev->asic_type == CHIP_VEGA20 || -		   adev->asic_type == CHIP_ARCTURUS || -		   adev->asic_type == CHIP_ALDEBARAN) { -		adev->nbio.funcs = &nbio_v7_4_funcs; -		adev->nbio.hdp_flush_reg = &nbio_v7_4_hdp_flush_reg; -	} else { -		adev->nbio.funcs = &nbio_v6_1_funcs; -		adev->nbio.hdp_flush_reg = &nbio_v6_1_hdp_flush_reg; -	} -	adev->hdp.funcs = &hdp_v4_0_funcs; - -	if (adev->asic_type == CHIP_VEGA20 || -	    adev->asic_type == CHIP_ARCTURUS || -	    adev->asic_type == CHIP_ALDEBARAN) -		adev->df.funcs = &df_v3_6_funcs; -	else -		adev->df.funcs = &df_v1_7_funcs; - -	if (adev->asic_type == CHIP_VEGA20 || -	    adev->asic_type == CHIP_ARCTURUS) -		adev->smuio.funcs = &smuio_v11_0_funcs; -	else if (adev->asic_type == CHIP_ALDEBARAN) -		adev->smuio.funcs = &smuio_v13_0_funcs; -	else -		adev->smuio.funcs = &smuio_v9_0_funcs; - -	adev->rev_id = soc15_get_rev_id(adev); - -	switch (adev->asic_type) { -	case CHIP_VEGA10: -	case CHIP_VEGA12: -	case CHIP_VEGA20: -		amdgpu_device_ip_block_add(adev, &vega10_common_ip_block); -		amdgpu_device_ip_block_add(adev, &gmc_v9_0_ip_block); - -		/* For Vega10 SR-IOV, PSP need to be initialized before IH */ -		if (amdgpu_sriov_vf(adev)) { -			if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) { -				if (adev->asic_type == CHIP_VEGA20) -					amdgpu_device_ip_block_add(adev, &psp_v11_0_ip_block); -				else -					amdgpu_device_ip_block_add(adev, &psp_v3_1_ip_block); -			} -			if (adev->asic_type == CHIP_VEGA20) -				amdgpu_device_ip_block_add(adev, &vega20_ih_ip_block); -			else -				amdgpu_device_ip_block_add(adev, &vega10_ih_ip_block); -		} else { -			if (adev->asic_type == CHIP_VEGA20) -				amdgpu_device_ip_block_add(adev, &vega20_ih_ip_block); -			else -				amdgpu_device_ip_block_add(adev, &vega10_ih_ip_block); -			if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) { -				if (adev->asic_type == CHIP_VEGA20) -					amdgpu_device_ip_block_add(adev, &psp_v11_0_ip_block); -				else -					amdgpu_device_ip_block_add(adev, &psp_v3_1_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 (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); -		} -		if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) -			amdgpu_device_ip_block_add(adev, &amdgpu_vkms_ip_block); -#if defined(CONFIG_DRM_AMD_DC) -		else if (amdgpu_device_has_dc_support(adev)) -			amdgpu_device_ip_block_add(adev, &dm_ip_block); -#endif -		if (!(adev->asic_type == CHIP_VEGA20 && amdgpu_sriov_vf(adev))) { -			amdgpu_device_ip_block_add(adev, &uvd_v7_0_ip_block); -			amdgpu_device_ip_block_add(adev, &vce_v4_0_ip_block); -		} -		break; -	case CHIP_RAVEN: -		amdgpu_device_ip_block_add(adev, &vega10_common_ip_block); -		amdgpu_device_ip_block_add(adev, &gmc_v9_0_ip_block); -		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_v10_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); -		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, &amdgpu_vkms_ip_block); -#if defined(CONFIG_DRM_AMD_DC) -		else if (amdgpu_device_has_dc_support(adev)) -			amdgpu_device_ip_block_add(adev, &dm_ip_block); -#endif -		amdgpu_device_ip_block_add(adev, &vcn_v1_0_ip_block); -		break; -	case CHIP_ARCTURUS: -		amdgpu_device_ip_block_add(adev, &vega10_common_ip_block); -		amdgpu_device_ip_block_add(adev, &gmc_v9_0_ip_block); - -		if (amdgpu_sriov_vf(adev)) { -			if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) -				amdgpu_device_ip_block_add(adev, &psp_v11_0_ip_block); -			amdgpu_device_ip_block_add(adev, &vega20_ih_ip_block); -		} else { -			amdgpu_device_ip_block_add(adev, &vega20_ih_ip_block); -			if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) -				amdgpu_device_ip_block_add(adev, &psp_v11_0_ip_block); -		} - -		if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) -			amdgpu_device_ip_block_add(adev, &amdgpu_vkms_ip_block); -		amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block); -		amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block); -		amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block); - -		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); -		amdgpu_device_ip_block_add(adev, &gmc_v9_0_ip_block); -		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); -		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)) -			amdgpu_device_ip_block_add(adev, &amdgpu_vkms_ip_block); -#if defined(CONFIG_DRM_AMD_DC) -                else if (amdgpu_device_has_dc_support(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; -	case CHIP_ALDEBARAN: -		amdgpu_device_ip_block_add(adev, &vega10_common_ip_block); -		amdgpu_device_ip_block_add(adev, &gmc_v9_0_ip_block); - -		if (amdgpu_sriov_vf(adev)) { -			if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) -				amdgpu_device_ip_block_add(adev, &psp_v13_0_ip_block); -			amdgpu_device_ip_block_add(adev, &vega20_ih_ip_block); -		} else { -			amdgpu_device_ip_block_add(adev, &vega20_ih_ip_block); -			if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) -				amdgpu_device_ip_block_add(adev, &psp_v13_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); - -		amdgpu_device_ip_block_add(adev, &smu_v13_0_ip_block); -		amdgpu_device_ip_block_add(adev, &vcn_v2_6_ip_block); -		amdgpu_device_ip_block_add(adev, &jpeg_v2_6_ip_block); -		break; -	default: -		return -EINVAL; -	} - -	return 0; -} -  static bool soc15_need_full_reset(struct amdgpu_device *adev)  {  	/* change this when we implement soft reset */ @@ -1153,10 +988,13 @@ static int soc15_common_early_init(void *handle)  	adev->se_cac_rreg = &soc15_se_cac_rreg;  	adev->se_cac_wreg = &soc15_se_cac_wreg; - +	adev->rev_id = soc15_get_rev_id(adev);  	adev->external_rev_id = 0xFF; -	switch (adev->asic_type) { -	case CHIP_VEGA10: +	/* TODO: split the GC and PG flags based on the relevant IP version for which +	 * they are relevant. +	 */ +	switch (adev->ip_versions[GC_HWIP][0]) { +	case IP_VERSION(9, 0, 1):  		adev->asic_funcs = &soc15_asic_funcs;  		adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |  			AMD_CG_SUPPORT_GFX_MGLS | @@ -1180,7 +1018,7 @@ static int soc15_common_early_init(void *handle)  		adev->pg_flags = 0;  		adev->external_rev_id = 0x1;  		break; -	case CHIP_VEGA12: +	case IP_VERSION(9, 2, 1):  		adev->asic_funcs = &soc15_asic_funcs;  		adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |  			AMD_CG_SUPPORT_GFX_MGLS | @@ -1203,7 +1041,7 @@ static int soc15_common_early_init(void *handle)  		adev->pg_flags = 0;  		adev->external_rev_id = adev->rev_id + 0x14;  		break; -	case CHIP_VEGA20: +	case IP_VERSION(9, 4, 0):  		adev->asic_funcs = &vega20_asic_funcs;  		adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |  			AMD_CG_SUPPORT_GFX_MGLS | @@ -1226,7 +1064,8 @@ static int soc15_common_early_init(void *handle)  		adev->pg_flags = 0;  		adev->external_rev_id = adev->rev_id + 0x28;  		break; -	case CHIP_RAVEN: +	case IP_VERSION(9, 1, 0): +	case IP_VERSION(9, 2, 2):  		adev->asic_funcs = &soc15_asic_funcs;  		if (adev->rev_id >= 0x8) @@ -1299,7 +1138,7 @@ static int soc15_common_early_init(void *handle)  			adev->pg_flags = AMD_PG_SUPPORT_SDMA | AMD_PG_SUPPORT_VCN;  		}  		break; -	case CHIP_ARCTURUS: +	case IP_VERSION(9, 4, 1):  		adev->asic_funcs = &vega20_asic_funcs;  		adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |  			AMD_CG_SUPPORT_GFX_MGLS | @@ -1318,7 +1157,7 @@ static int soc15_common_early_init(void *handle)  		adev->pg_flags = AMD_PG_SUPPORT_VCN | AMD_PG_SUPPORT_VCN_DPG;  		adev->external_rev_id = adev->rev_id + 0x32;  		break; -	case CHIP_RENOIR: +	case IP_VERSION(9, 3, 0):  		adev->asic_funcs = &soc15_asic_funcs;  		if (adev->apu_flags & AMD_APU_IS_RENOIR) @@ -1349,7 +1188,7 @@ static int soc15_common_early_init(void *handle)  				 AMD_PG_SUPPORT_JPEG |  				 AMD_PG_SUPPORT_VCN_DPG;  		break; -	case CHIP_ALDEBARAN: +	case IP_VERSION(9, 4, 2):  		adev->asic_funcs = &vega20_asic_funcs;  		adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |  			AMD_CG_SUPPORT_GFX_MGLS | @@ -1564,10 +1403,10 @@ static int soc15_common_set_clockgating_state(void *handle,  	if (amdgpu_sriov_vf(adev))  		return 0; -	switch (adev->asic_type) { -	case CHIP_VEGA10: -	case CHIP_VEGA12: -	case CHIP_VEGA20: +	switch (adev->ip_versions[NBIO_HWIP][0]) { +	case IP_VERSION(6, 1, 0): +	case IP_VERSION(6, 2, 0): +	case IP_VERSION(7, 4, 0):  		adev->nbio.funcs->update_medium_grain_clock_gating(adev,  				state == AMD_CG_STATE_GATE);  		adev->nbio.funcs->update_medium_grain_light_sleep(adev, @@ -1583,8 +1422,9 @@ static int soc15_common_set_clockgating_state(void *handle,  		adev->df.funcs->update_medium_grain_clock_gating(adev,  				state == AMD_CG_STATE_GATE);  		break; -	case CHIP_RAVEN: -	case CHIP_RENOIR: +	case IP_VERSION(7, 0, 0): +	case IP_VERSION(7, 0, 1): +	case IP_VERSION(2, 5, 0):  		adev->nbio.funcs->update_medium_grain_clock_gating(adev,  				state == AMD_CG_STATE_GATE);  		adev->nbio.funcs->update_medium_grain_light_sleep(adev, @@ -1596,8 +1436,8 @@ static int soc15_common_set_clockgating_state(void *handle,  		soc15_update_drm_light_sleep(adev,  				state == AMD_CG_STATE_GATE);  		break; -	case CHIP_ARCTURUS: -	case CHIP_ALDEBARAN: +	case IP_VERSION(7, 4, 1): +	case IP_VERSION(7, 4, 4):  		adev->hdp.funcs->update_clock_gating(adev,  				state == AMD_CG_STATE_GATE);  		break; @@ -1619,7 +1459,7 @@ static void soc15_common_get_clockgating_state(void *handle, u32 *flags)  	adev->hdp.funcs->get_clock_gating_state(adev, flags); -	if (adev->asic_type != CHIP_ALDEBARAN) { +	if (adev->ip_versions[MP0_HWIP][0] != IP_VERSION(13, 0, 2)) {  		/* AMD_CG_SUPPORT_DRM_MGCG */  		data = RREG32(SOC15_REG_OFFSET(MP0, 0, mmMP0_MISC_CGTT_CTRL0)); @@ -1645,7 +1485,7 @@ static int soc15_common_set_powergating_state(void *handle,  	return 0;  } -const struct amd_ip_funcs soc15_common_ip_funcs = { +static const struct amd_ip_funcs soc15_common_ip_funcs = {  	.name = "soc15_common",  	.early_init = soc15_common_early_init,  	.late_init = soc15_common_late_init, |