diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c')
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 181 | 
1 files changed, 180 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c index 222d3d7ea076..9546adc8a76f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c @@ -23,6 +23,7 @@   *   */ +#include <linux/firmware.h>  #include "amdgpu.h"  #include "amdgpu_gfx.h"  #include "amdgpu_rlc.h" @@ -477,7 +478,7 @@ int amdgpu_gfx_disable_kcq(struct amdgpu_device *adev)  		kiq->pmf->kiq_unmap_queues(kiq_ring, &adev->gfx.compute_ring[i],  					   RESET_QUEUES, 0, 0); -	if (adev->gfx.kiq.ring.sched.ready) +	if (adev->gfx.kiq.ring.sched.ready && !adev->job_hang)  		r = amdgpu_ring_test_helper(kiq_ring);  	spin_unlock(&adev->gfx.kiq.ring_lock); @@ -610,6 +611,45 @@ unlock:  	mutex_unlock(&adev->gfx.gfx_off_mutex);  } +int amdgpu_set_gfx_off_residency(struct amdgpu_device *adev, bool value) +{ +	int r = 0; + +	mutex_lock(&adev->gfx.gfx_off_mutex); + +	r = amdgpu_dpm_set_residency_gfxoff(adev, value); + +	mutex_unlock(&adev->gfx.gfx_off_mutex); + +	return r; +} + +int amdgpu_get_gfx_off_residency(struct amdgpu_device *adev, u32 *value) +{ +	int r = 0; + +	mutex_lock(&adev->gfx.gfx_off_mutex); + +	r = amdgpu_dpm_get_residency_gfxoff(adev, value); + +	mutex_unlock(&adev->gfx.gfx_off_mutex); + +	return r; +} + +int amdgpu_get_gfx_off_entrycount(struct amdgpu_device *adev, u64 *value) +{ +	int r = 0; + +	mutex_lock(&adev->gfx.gfx_off_mutex); + +	r = amdgpu_dpm_get_entrycount_gfxoff(adev, value); + +	mutex_unlock(&adev->gfx.gfx_off_mutex); + +	return r; +} +  int amdgpu_get_gfx_off_status(struct amdgpu_device *adev, uint32_t *value)  { @@ -826,3 +866,142 @@ int amdgpu_gfx_get_num_kcq(struct amdgpu_device *adev)  	}  	return amdgpu_num_kcq;  } + +void amdgpu_gfx_cp_init_microcode(struct amdgpu_device *adev, +				  uint32_t ucode_id) +{ +	const struct gfx_firmware_header_v1_0 *cp_hdr; +	const struct gfx_firmware_header_v2_0 *cp_hdr_v2_0; +	struct amdgpu_firmware_info *info = NULL; +	const struct firmware *ucode_fw; +	unsigned int fw_size; + +	switch (ucode_id) { +	case AMDGPU_UCODE_ID_CP_PFP: +		cp_hdr = (const struct gfx_firmware_header_v1_0 *) +			adev->gfx.pfp_fw->data; +		adev->gfx.pfp_fw_version = +			le32_to_cpu(cp_hdr->header.ucode_version); +		adev->gfx.pfp_feature_version = +			le32_to_cpu(cp_hdr->ucode_feature_version); +		ucode_fw = adev->gfx.pfp_fw; +		fw_size = le32_to_cpu(cp_hdr->header.ucode_size_bytes); +		break; +	case AMDGPU_UCODE_ID_CP_RS64_PFP: +		cp_hdr_v2_0 = (const struct gfx_firmware_header_v2_0 *) +			adev->gfx.pfp_fw->data; +		adev->gfx.pfp_fw_version = +			le32_to_cpu(cp_hdr_v2_0->header.ucode_version); +		adev->gfx.pfp_feature_version = +			le32_to_cpu(cp_hdr_v2_0->ucode_feature_version); +		ucode_fw = adev->gfx.pfp_fw; +		fw_size = le32_to_cpu(cp_hdr_v2_0->ucode_size_bytes); +		break; +	case AMDGPU_UCODE_ID_CP_RS64_PFP_P0_STACK: +	case AMDGPU_UCODE_ID_CP_RS64_PFP_P1_STACK: +		cp_hdr_v2_0 = (const struct gfx_firmware_header_v2_0 *) +			adev->gfx.pfp_fw->data; +		ucode_fw = adev->gfx.pfp_fw; +		fw_size = le32_to_cpu(cp_hdr_v2_0->data_size_bytes); +		break; +	case AMDGPU_UCODE_ID_CP_ME: +		cp_hdr = (const struct gfx_firmware_header_v1_0 *) +			adev->gfx.me_fw->data; +		adev->gfx.me_fw_version = +			le32_to_cpu(cp_hdr->header.ucode_version); +		adev->gfx.me_feature_version = +			le32_to_cpu(cp_hdr->ucode_feature_version); +		ucode_fw = adev->gfx.me_fw; +		fw_size = le32_to_cpu(cp_hdr->header.ucode_size_bytes); +		break; +	case AMDGPU_UCODE_ID_CP_RS64_ME: +		cp_hdr_v2_0 = (const struct gfx_firmware_header_v2_0 *) +			adev->gfx.me_fw->data; +		adev->gfx.me_fw_version = +			le32_to_cpu(cp_hdr_v2_0->header.ucode_version); +		adev->gfx.me_feature_version = +			le32_to_cpu(cp_hdr_v2_0->ucode_feature_version); +		ucode_fw = adev->gfx.me_fw; +		fw_size = le32_to_cpu(cp_hdr_v2_0->ucode_size_bytes); +		break; +	case AMDGPU_UCODE_ID_CP_RS64_ME_P0_STACK: +	case AMDGPU_UCODE_ID_CP_RS64_ME_P1_STACK: +		cp_hdr_v2_0 = (const struct gfx_firmware_header_v2_0 *) +			adev->gfx.me_fw->data; +		ucode_fw = adev->gfx.me_fw; +		fw_size = le32_to_cpu(cp_hdr_v2_0->data_size_bytes); +		break; +	case AMDGPU_UCODE_ID_CP_CE: +		cp_hdr = (const struct gfx_firmware_header_v1_0 *) +			adev->gfx.ce_fw->data; +		adev->gfx.ce_fw_version = +			le32_to_cpu(cp_hdr->header.ucode_version); +		adev->gfx.ce_feature_version = +			le32_to_cpu(cp_hdr->ucode_feature_version); +		ucode_fw = adev->gfx.ce_fw; +		fw_size = le32_to_cpu(cp_hdr->header.ucode_size_bytes); +		break; +	case AMDGPU_UCODE_ID_CP_MEC1: +		cp_hdr = (const struct gfx_firmware_header_v1_0 *) +			adev->gfx.mec_fw->data; +		adev->gfx.mec_fw_version = +			le32_to_cpu(cp_hdr->header.ucode_version); +		adev->gfx.mec_feature_version = +			le32_to_cpu(cp_hdr->ucode_feature_version); +		ucode_fw = adev->gfx.mec_fw; +		fw_size = le32_to_cpu(cp_hdr->header.ucode_size_bytes) - +			  le32_to_cpu(cp_hdr->jt_size) * 4; +		break; +	case AMDGPU_UCODE_ID_CP_MEC1_JT: +		cp_hdr = (const struct gfx_firmware_header_v1_0 *) +			adev->gfx.mec_fw->data; +		ucode_fw = adev->gfx.mec_fw; +		fw_size = le32_to_cpu(cp_hdr->jt_size) * 4; +		break; +	case AMDGPU_UCODE_ID_CP_MEC2: +		cp_hdr = (const struct gfx_firmware_header_v1_0 *) +			adev->gfx.mec2_fw->data; +		adev->gfx.mec2_fw_version = +			le32_to_cpu(cp_hdr->header.ucode_version); +		adev->gfx.mec2_feature_version = +			le32_to_cpu(cp_hdr->ucode_feature_version); +		ucode_fw = adev->gfx.mec2_fw; +		fw_size = le32_to_cpu(cp_hdr->header.ucode_size_bytes) - +			  le32_to_cpu(cp_hdr->jt_size) * 4; +		break; +	case AMDGPU_UCODE_ID_CP_MEC2_JT: +		cp_hdr = (const struct gfx_firmware_header_v1_0 *) +			adev->gfx.mec2_fw->data; +		ucode_fw = adev->gfx.mec2_fw; +		fw_size = le32_to_cpu(cp_hdr->jt_size) * 4; +		break; +	case AMDGPU_UCODE_ID_CP_RS64_MEC: +		cp_hdr_v2_0 = (const struct gfx_firmware_header_v2_0 *) +			adev->gfx.mec_fw->data; +		adev->gfx.mec_fw_version = +			le32_to_cpu(cp_hdr_v2_0->header.ucode_version); +		adev->gfx.mec_feature_version = +			le32_to_cpu(cp_hdr_v2_0->ucode_feature_version); +		ucode_fw = adev->gfx.mec_fw; +		fw_size = le32_to_cpu(cp_hdr_v2_0->ucode_size_bytes); +		break; +	case AMDGPU_UCODE_ID_CP_RS64_MEC_P0_STACK: +	case AMDGPU_UCODE_ID_CP_RS64_MEC_P1_STACK: +	case AMDGPU_UCODE_ID_CP_RS64_MEC_P2_STACK: +	case AMDGPU_UCODE_ID_CP_RS64_MEC_P3_STACK: +		cp_hdr_v2_0 = (const struct gfx_firmware_header_v2_0 *) +			adev->gfx.mec_fw->data; +		ucode_fw = adev->gfx.mec_fw; +		fw_size = le32_to_cpu(cp_hdr_v2_0->data_size_bytes); +		break; +	default: +		break; +	} + +	if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) { +		info = &adev->firmware.ucode[ucode_id]; +		info->ucode_id = ucode_id; +		info->fw = ucode_fw; +		adev->firmware.fw_size += ALIGN(fw_size, PAGE_SIZE); +	} +}  |