diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/nv.c')
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/nv.c | 261 | 
1 files changed, 187 insertions, 74 deletions
| diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu/nv.c index c625c5d8ed89..d54af7f8801b 100644 --- a/drivers/gpu/drm/amd/amdgpu/nv.c +++ b/drivers/gpu/drm/amd/amdgpu/nv.c @@ -25,6 +25,8 @@  #include <linux/module.h>  #include <linux/pci.h> +#include <drm/amdgpu_drm.h> +  #include "amdgpu.h"  #include "amdgpu_atombios.h"  #include "amdgpu_ih.h" @@ -32,7 +34,6 @@  #include "amdgpu_vce.h"  #include "amdgpu_ucode.h"  #include "amdgpu_psp.h" -#include "amdgpu_smu.h"  #include "atom.h"  #include "amd_pcie.h" @@ -65,6 +66,184 @@  static const struct amd_ip_funcs nv_common_ip_funcs; +/* Navi */ +static const struct amdgpu_video_codec_info nv_video_codecs_encode_array[] = +{ +	{ +		.codec_type = AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC, +		.max_width = 4096, +		.max_height = 2304, +		.max_pixels_per_frame = 4096 * 2304, +		.max_level = 0, +	}, +	{ +		.codec_type = AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_HEVC, +		.max_width = 4096, +		.max_height = 2304, +		.max_pixels_per_frame = 4096 * 2304, +		.max_level = 0, +	}, +}; + +static const struct amdgpu_video_codecs nv_video_codecs_encode = +{ +	.codec_count = ARRAY_SIZE(nv_video_codecs_encode_array), +	.codec_array = nv_video_codecs_encode_array, +}; + +/* Navi1x */ +static const struct amdgpu_video_codec_info nv_video_codecs_decode_array[] = +{ +	{ +		.codec_type = AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG2, +		.max_width = 4096, +		.max_height = 4096, +		.max_pixels_per_frame = 4096 * 4096, +		.max_level = 3, +	}, +	{ +		.codec_type = AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4, +		.max_width = 4096, +		.max_height = 4096, +		.max_pixels_per_frame = 4096 * 4096, +		.max_level = 5, +	}, +	{ +		.codec_type = AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC, +		.max_width = 4096, +		.max_height = 4096, +		.max_pixels_per_frame = 4096 * 4096, +		.max_level = 52, +	}, +	{ +		.codec_type = AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VC1, +		.max_width = 4096, +		.max_height = 4096, +		.max_pixels_per_frame = 4096 * 4096, +		.max_level = 4, +	}, +	{ +		.codec_type = AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_HEVC, +		.max_width = 8192, +		.max_height = 4352, +		.max_pixels_per_frame = 8192 * 4352, +		.max_level = 186, +	}, +	{ +		.codec_type = AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_JPEG, +		.max_width = 4096, +		.max_height = 4096, +		.max_pixels_per_frame = 4096 * 4096, +		.max_level = 0, +	}, +	{ +		.codec_type = AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VP9, +		.max_width = 8192, +		.max_height = 4352, +		.max_pixels_per_frame = 8192 * 4352, +		.max_level = 0, +	}, +}; + +static const struct amdgpu_video_codecs nv_video_codecs_decode = +{ +	.codec_count = ARRAY_SIZE(nv_video_codecs_decode_array), +	.codec_array = nv_video_codecs_decode_array, +}; + +/* Sienna Cichlid */ +static const struct amdgpu_video_codec_info sc_video_codecs_decode_array[] = +{ +	{ +		.codec_type = AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG2, +		.max_width = 4096, +		.max_height = 4096, +		.max_pixels_per_frame = 4096 * 4096, +		.max_level = 3, +	}, +	{ +		.codec_type = AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4, +		.max_width = 4096, +		.max_height = 4096, +		.max_pixels_per_frame = 4096 * 4096, +		.max_level = 5, +	}, +	{ +		.codec_type = AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC, +		.max_width = 4096, +		.max_height = 4096, +		.max_pixels_per_frame = 4096 * 4096, +		.max_level = 52, +	}, +	{ +		.codec_type = AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VC1, +		.max_width = 4096, +		.max_height = 4096, +		.max_pixels_per_frame = 4096 * 4096, +		.max_level = 4, +	}, +	{ +		.codec_type = AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_HEVC, +		.max_width = 8192, +		.max_height = 4352, +		.max_pixels_per_frame = 8192 * 4352, +		.max_level = 186, +	}, +	{ +		.codec_type = AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_JPEG, +		.max_width = 4096, +		.max_height = 4096, +		.max_pixels_per_frame = 4096 * 4096, +		.max_level = 0, +	}, +	{ +		.codec_type = AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VP9, +		.max_width = 8192, +		.max_height = 4352, +		.max_pixels_per_frame = 8192 * 4352, +		.max_level = 0, +	}, +	{ +		.codec_type = AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_AV1, +		.max_width = 8192, +		.max_height = 4352, +		.max_pixels_per_frame = 8192 * 4352, +		.max_level = 0, +	}, +}; + +static const struct amdgpu_video_codecs sc_video_codecs_decode = +{ +	.codec_count = ARRAY_SIZE(sc_video_codecs_decode_array), +	.codec_array = sc_video_codecs_decode_array, +}; + +static int nv_query_video_codecs(struct amdgpu_device *adev, bool encode, +				 const struct amdgpu_video_codecs **codecs) +{ +	switch (adev->asic_type) { +	case CHIP_SIENNA_CICHLID: +	case CHIP_NAVY_FLOUNDER: +	case CHIP_DIMGREY_CAVEFISH: +	case CHIP_VANGOGH: +		if (encode) +			*codecs = &nv_video_codecs_encode; +		else +			*codecs = &sc_video_codecs_decode; +		return 0; +	case CHIP_NAVI10: +	case CHIP_NAVI14: +	case CHIP_NAVI12: +		if (encode) +			*codecs = &nv_video_codecs_encode; +		else +			*codecs = &nv_video_codecs_decode; +		return 0; +	default: +		return -EINVAL; +	} +} +  /*   * Indirect registers accessor   */ @@ -304,44 +483,6 @@ static int nv_read_register(struct amdgpu_device *adev, u32 se_num,  	return -EINVAL;  } -static int nv_asic_mode1_reset(struct amdgpu_device *adev) -{ -	u32 i; -	int ret = 0; - -	amdgpu_atombios_scratch_regs_engine_hung(adev, true); - -	/* disable BM */ -	pci_clear_master(adev->pdev); - -	amdgpu_device_cache_pci_state(adev->pdev); - -	if (amdgpu_dpm_is_mode1_reset_supported(adev)) { -		dev_info(adev->dev, "GPU smu mode1 reset\n"); -		ret = amdgpu_dpm_mode1_reset(adev); -	} else { -		dev_info(adev->dev, "GPU psp mode1 reset\n"); -		ret = psp_gpu_reset(adev); -	} - -	if (ret) -		dev_err(adev->dev, "GPU mode1 reset failed\n"); -	amdgpu_device_load_pci_state(adev->pdev); - -	/* wait for asic to come out of reset */ -	for (i = 0; i < adev->usec_timeout; i++) { -		u32 memsize = adev->nbio.funcs->get_memsize(adev); - -		if (memsize != 0xffffffff) -			break; -		udelay(1); -	} - -	amdgpu_atombios_scratch_regs_engine_hung(adev, false); - -	return ret; -} -  static int nv_asic_mode2_reset(struct amdgpu_device *adev)  {  	u32 i; @@ -374,21 +515,9 @@ static int nv_asic_mode2_reset(struct amdgpu_device *adev)  	return ret;  } -static bool nv_asic_supports_baco(struct amdgpu_device *adev) -{ -	struct smu_context *smu = &adev->smu; - -	if (smu_baco_is_support(smu)) -		return true; -	else -		return false; -} -  static enum amd_reset_method  nv_asic_reset_method(struct amdgpu_device *adev)  { -	struct smu_context *smu = &adev->smu; -  	if (amdgpu_reset_method == AMD_RESET_METHOD_MODE1 ||  	    amdgpu_reset_method == AMD_RESET_METHOD_MODE2 ||  	    amdgpu_reset_method == AMD_RESET_METHOD_BACO || @@ -407,7 +536,7 @@ nv_asic_reset_method(struct amdgpu_device *adev)  	case CHIP_DIMGREY_CAVEFISH:  		return AMD_RESET_METHOD_MODE1;  	default: -		if (smu_baco_is_support(smu)) +		if (amdgpu_dpm_is_baco_supported(adev))  			return AMD_RESET_METHOD_BACO;  		else  			return AMD_RESET_METHOD_MODE1; @@ -417,11 +546,6 @@ nv_asic_reset_method(struct amdgpu_device *adev)  static int nv_asic_reset(struct amdgpu_device *adev)  {  	int ret = 0; -	struct smu_context *smu = &adev->smu; - -	/* skip reset on vangogh for now */ -	if (adev->asic_type == CHIP_VANGOGH) -		return 0;  	switch (nv_asic_reset_method(adev)) {  	case AMD_RESET_METHOD_PCI: @@ -430,13 +554,7 @@ static int nv_asic_reset(struct amdgpu_device *adev)  		break;  	case AMD_RESET_METHOD_BACO:  		dev_info(adev->dev, "BACO reset\n"); - -		ret = smu_baco_enter(smu); -		if (ret) -			return ret; -		ret = smu_baco_exit(smu); -		if (ret) -			return ret; +		ret = amdgpu_dpm_baco_reset(adev);  		break;  	case AMD_RESET_METHOD_MODE2:  		dev_info(adev->dev, "MODE2 reset\n"); @@ -444,7 +562,7 @@ static int nv_asic_reset(struct amdgpu_device *adev)  		break;  	default:  		dev_info(adev->dev, "MODE1 reset\n"); -		ret = nv_asic_mode1_reset(adev); +		ret = amdgpu_device_mode1_reset(adev);  		break;  	} @@ -483,8 +601,7 @@ static void nv_program_aspm(struct amdgpu_device *adev)  	if (amdgpu_aspm != 1)  		return; -	if ((adev->asic_type >= CHIP_SIENNA_CICHLID) && -	    !(adev->flags & AMD_IS_APU) && +	if (!(adev->flags & AMD_IS_APU) &&  	    (adev->nbio.funcs->program_aspm))  		adev->nbio.funcs->program_aspm(adev); @@ -816,12 +933,7 @@ static int nv_update_umd_stable_pstate(struct amdgpu_device *adev,  	if (adev->gfx.funcs->update_perfmon_mgcg)  		adev->gfx.funcs->update_perfmon_mgcg(adev, !enter); -	/* -	 * The ASPM function is not fully enabled and verified on -	 * Navi yet. Temporarily skip this until ASPM enabled. -	 */ -	if ((adev->asic_type >= CHIP_SIENNA_CICHLID) && -	    !(adev->flags & AMD_IS_APU) && +	if (!(adev->flags & AMD_IS_APU) &&  	    (adev->nbio.funcs->enable_aspm))  		adev->nbio.funcs->enable_aspm(adev, !enter); @@ -844,9 +956,10 @@ static const struct amdgpu_asic_funcs nv_asic_funcs =  	.need_full_reset = &nv_need_full_reset,  	.need_reset_on_init = &nv_need_reset_on_init,  	.get_pcie_replay_count = &nv_get_pcie_replay_count, -	.supports_baco = &nv_asic_supports_baco, +	.supports_baco = &amdgpu_dpm_is_baco_supported,  	.pre_asic_init = &nv_pre_asic_init,  	.update_umd_stable_pstate = &nv_update_umd_stable_pstate, +	.query_video_codecs = &nv_query_video_codecs,  };  static int nv_common_early_init(void *handle) | 
