mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	drm/amd/amdgpu: remove redundant host to psp cmd buf allocations
Signed-off-by: Candice Li <candice.li@amd.com> Reviewed-by: John Clements <john.clements@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
		
							parent
							
								
									733ee71ae0
								
							
						
					
					
						commit
						4fb9307154
					
				
					 1 changed files with 66 additions and 161 deletions
				
			
		| 
						 | 
					@ -251,6 +251,12 @@ static int psp_sw_init(void *handle)
 | 
				
			||||||
	struct psp_runtime_boot_cfg_entry boot_cfg_entry;
 | 
						struct psp_runtime_boot_cfg_entry boot_cfg_entry;
 | 
				
			||||||
	struct psp_memory_training_context *mem_training_ctx = &psp->mem_train_ctx;
 | 
						struct psp_memory_training_context *mem_training_ctx = &psp->mem_train_ctx;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						psp->cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 | 
				
			||||||
 | 
						if (!psp->cmd) {
 | 
				
			||||||
 | 
							DRM_ERROR("Failed to allocate memory to command buffer!\n");
 | 
				
			||||||
 | 
							ret = -ENOMEM;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!amdgpu_sriov_vf(adev)) {
 | 
						if (!amdgpu_sriov_vf(adev)) {
 | 
				
			||||||
		ret = psp_init_microcode(psp);
 | 
							ret = psp_init_microcode(psp);
 | 
				
			||||||
		if (ret) {
 | 
							if (ret) {
 | 
				
			||||||
| 
						 | 
					@ -313,25 +319,30 @@ static int psp_sw_init(void *handle)
 | 
				
			||||||
static int psp_sw_fini(void *handle)
 | 
					static int psp_sw_fini(void *handle)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 | 
						struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 | 
				
			||||||
 | 
						struct psp_context *psp = &adev->psp;
 | 
				
			||||||
 | 
						struct psp_gfx_cmd_resp *cmd = psp->cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	psp_memory_training_fini(&adev->psp);
 | 
						psp_memory_training_fini(psp);
 | 
				
			||||||
	if (adev->psp.sos_fw) {
 | 
						if (psp->sos_fw) {
 | 
				
			||||||
		release_firmware(adev->psp.sos_fw);
 | 
							release_firmware(psp->sos_fw);
 | 
				
			||||||
		adev->psp.sos_fw = NULL;
 | 
							psp->sos_fw = NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (adev->psp.asd_fw) {
 | 
						if (psp->asd_fw) {
 | 
				
			||||||
		release_firmware(adev->psp.asd_fw);
 | 
							release_firmware(psp->asd_fw);
 | 
				
			||||||
		adev->psp.asd_fw = NULL;
 | 
							psp->asd_fw = NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (adev->psp.ta_fw) {
 | 
						if (psp->ta_fw) {
 | 
				
			||||||
		release_firmware(adev->psp.ta_fw);
 | 
							release_firmware(psp->ta_fw);
 | 
				
			||||||
		adev->psp.ta_fw = NULL;
 | 
							psp->ta_fw = NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (adev->asic_type == CHIP_NAVI10 ||
 | 
						if (adev->asic_type == CHIP_NAVI10 ||
 | 
				
			||||||
	    adev->asic_type == CHIP_SIENNA_CICHLID)
 | 
						    adev->asic_type == CHIP_SIENNA_CICHLID)
 | 
				
			||||||
		psp_sysfs_fini(adev);
 | 
							psp_sysfs_fini(adev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						kfree(cmd);
 | 
				
			||||||
 | 
						cmd = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -489,6 +500,8 @@ static void psp_prep_tmr_cmd_buf(struct psp_context *psp,
 | 
				
			||||||
	uint32_t size = amdgpu_bo_size(tmr_bo);
 | 
						uint32_t size = amdgpu_bo_size(tmr_bo);
 | 
				
			||||||
	uint64_t tmr_pa = amdgpu_gmc_vram_pa(adev, tmr_bo);
 | 
						uint64_t tmr_pa = amdgpu_gmc_vram_pa(adev, tmr_bo);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						memset(cmd, 0, sizeof(struct psp_gfx_cmd_resp));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (amdgpu_sriov_vf(psp->adev))
 | 
						if (amdgpu_sriov_vf(psp->adev))
 | 
				
			||||||
		cmd->cmd_id = GFX_CMD_ID_SETUP_VMR;
 | 
							cmd->cmd_id = GFX_CMD_ID_SETUP_VMR;
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
| 
						 | 
					@ -504,6 +517,8 @@ static void psp_prep_tmr_cmd_buf(struct psp_context *psp,
 | 
				
			||||||
static void psp_prep_load_toc_cmd_buf(struct psp_gfx_cmd_resp *cmd,
 | 
					static void psp_prep_load_toc_cmd_buf(struct psp_gfx_cmd_resp *cmd,
 | 
				
			||||||
				      uint64_t pri_buf_mc, uint32_t size)
 | 
									      uint64_t pri_buf_mc, uint32_t size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						memset(cmd, 0, sizeof(struct psp_gfx_cmd_resp));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd->cmd_id = GFX_CMD_ID_LOAD_TOC;
 | 
						cmd->cmd_id = GFX_CMD_ID_LOAD_TOC;
 | 
				
			||||||
	cmd->cmd.cmd_load_toc.toc_phy_addr_lo = lower_32_bits(pri_buf_mc);
 | 
						cmd->cmd.cmd_load_toc.toc_phy_addr_lo = lower_32_bits(pri_buf_mc);
 | 
				
			||||||
	cmd->cmd.cmd_load_toc.toc_phy_addr_hi = upper_32_bits(pri_buf_mc);
 | 
						cmd->cmd.cmd_load_toc.toc_phy_addr_hi = upper_32_bits(pri_buf_mc);
 | 
				
			||||||
| 
						 | 
					@ -515,11 +530,8 @@ static int psp_load_toc(struct psp_context *psp,
 | 
				
			||||||
			uint32_t *tmr_size)
 | 
								uint32_t *tmr_size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	struct psp_gfx_cmd_resp *cmd;
 | 
						struct psp_gfx_cmd_resp *cmd = psp->cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 | 
					 | 
				
			||||||
	if (!cmd)
 | 
					 | 
				
			||||||
		return -ENOMEM;
 | 
					 | 
				
			||||||
	/* Copy toc to psp firmware private buffer */
 | 
						/* Copy toc to psp firmware private buffer */
 | 
				
			||||||
	psp_copy_fw(psp, psp->toc.start_addr, psp->toc.size_bytes);
 | 
						psp_copy_fw(psp, psp->toc.start_addr, psp->toc.size_bytes);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -529,7 +541,7 @@ static int psp_load_toc(struct psp_context *psp,
 | 
				
			||||||
				 psp->fence_buf_mc_addr);
 | 
									 psp->fence_buf_mc_addr);
 | 
				
			||||||
	if (!ret)
 | 
						if (!ret)
 | 
				
			||||||
		*tmr_size = psp->cmd_buf_mem->resp.tmr_size;
 | 
							*tmr_size = psp->cmd_buf_mem->resp.tmr_size;
 | 
				
			||||||
	kfree(cmd);
 | 
					
 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -586,7 +598,7 @@ static bool psp_skip_tmr(struct psp_context *psp)
 | 
				
			||||||
static int psp_tmr_load(struct psp_context *psp)
 | 
					static int psp_tmr_load(struct psp_context *psp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	struct psp_gfx_cmd_resp *cmd;
 | 
						struct psp_gfx_cmd_resp *cmd = psp->cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* For Navi12 and CHIP_SIENNA_CICHLID SRIOV, do not set up TMR.
 | 
						/* For Navi12 and CHIP_SIENNA_CICHLID SRIOV, do not set up TMR.
 | 
				
			||||||
	 * Already set up by host driver.
 | 
						 * Already set up by host driver.
 | 
				
			||||||
| 
						 | 
					@ -594,10 +606,6 @@ static int psp_tmr_load(struct psp_context *psp)
 | 
				
			||||||
	if (amdgpu_sriov_vf(psp->adev) && psp_skip_tmr(psp))
 | 
						if (amdgpu_sriov_vf(psp->adev) && psp_skip_tmr(psp))
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 | 
					 | 
				
			||||||
	if (!cmd)
 | 
					 | 
				
			||||||
		return -ENOMEM;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	psp_prep_tmr_cmd_buf(psp, cmd, psp->tmr_mc_addr, psp->tmr_bo);
 | 
						psp_prep_tmr_cmd_buf(psp, cmd, psp->tmr_mc_addr, psp->tmr_bo);
 | 
				
			||||||
	DRM_INFO("reserve 0x%lx from 0x%llx for PSP TMR\n",
 | 
						DRM_INFO("reserve 0x%lx from 0x%llx for PSP TMR\n",
 | 
				
			||||||
		 amdgpu_bo_size(psp->tmr_bo), psp->tmr_mc_addr);
 | 
							 amdgpu_bo_size(psp->tmr_bo), psp->tmr_mc_addr);
 | 
				
			||||||
| 
						 | 
					@ -605,14 +613,14 @@ static int psp_tmr_load(struct psp_context *psp)
 | 
				
			||||||
	ret = psp_cmd_submit_buf(psp, NULL, cmd,
 | 
						ret = psp_cmd_submit_buf(psp, NULL, cmd,
 | 
				
			||||||
				 psp->fence_buf_mc_addr);
 | 
									 psp->fence_buf_mc_addr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kfree(cmd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void psp_prep_tmr_unload_cmd_buf(struct psp_context *psp,
 | 
					static void psp_prep_tmr_unload_cmd_buf(struct psp_context *psp,
 | 
				
			||||||
				        struct psp_gfx_cmd_resp *cmd)
 | 
									        struct psp_gfx_cmd_resp *cmd)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						memset(cmd, 0, sizeof(struct psp_gfx_cmd_resp));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (amdgpu_sriov_vf(psp->adev))
 | 
						if (amdgpu_sriov_vf(psp->adev))
 | 
				
			||||||
		cmd->cmd_id = GFX_CMD_ID_DESTROY_VMR;
 | 
							cmd->cmd_id = GFX_CMD_ID_DESTROY_VMR;
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
| 
						 | 
					@ -622,11 +630,7 @@ static void psp_prep_tmr_unload_cmd_buf(struct psp_context *psp,
 | 
				
			||||||
static int psp_tmr_unload(struct psp_context *psp)
 | 
					static int psp_tmr_unload(struct psp_context *psp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	struct psp_gfx_cmd_resp *cmd;
 | 
						struct psp_gfx_cmd_resp *cmd = psp->cmd;
 | 
				
			||||||
 | 
					 | 
				
			||||||
	cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 | 
					 | 
				
			||||||
	if (!cmd)
 | 
					 | 
				
			||||||
		return -ENOMEM;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	psp_prep_tmr_unload_cmd_buf(psp, cmd);
 | 
						psp_prep_tmr_unload_cmd_buf(psp, cmd);
 | 
				
			||||||
	DRM_INFO("free PSP TMR buffer\n");
 | 
						DRM_INFO("free PSP TMR buffer\n");
 | 
				
			||||||
| 
						 | 
					@ -634,8 +638,6 @@ static int psp_tmr_unload(struct psp_context *psp)
 | 
				
			||||||
	ret = psp_cmd_submit_buf(psp, NULL, cmd,
 | 
						ret = psp_cmd_submit_buf(psp, NULL, cmd,
 | 
				
			||||||
				 psp->fence_buf_mc_addr);
 | 
									 psp->fence_buf_mc_addr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kfree(cmd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -660,7 +662,9 @@ int psp_get_fw_attestation_records_addr(struct psp_context *psp,
 | 
				
			||||||
					uint64_t *output_ptr)
 | 
										uint64_t *output_ptr)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	struct psp_gfx_cmd_resp *cmd;
 | 
						struct psp_gfx_cmd_resp *cmd = psp->cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						memset(cmd, 0, sizeof(struct psp_gfx_cmd_resp));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!output_ptr)
 | 
						if (!output_ptr)
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
| 
						 | 
					@ -668,10 +672,6 @@ int psp_get_fw_attestation_records_addr(struct psp_context *psp,
 | 
				
			||||||
	if (amdgpu_sriov_vf(psp->adev))
 | 
						if (amdgpu_sriov_vf(psp->adev))
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 | 
					 | 
				
			||||||
	if (!cmd)
 | 
					 | 
				
			||||||
		return -ENOMEM;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cmd->cmd_id = GFX_CMD_ID_GET_FW_ATTESTATION;
 | 
						cmd->cmd_id = GFX_CMD_ID_GET_FW_ATTESTATION;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = psp_cmd_submit_buf(psp, NULL, cmd,
 | 
						ret = psp_cmd_submit_buf(psp, NULL, cmd,
 | 
				
			||||||
| 
						 | 
					@ -682,8 +682,6 @@ int psp_get_fw_attestation_records_addr(struct psp_context *psp,
 | 
				
			||||||
			      ((uint64_t)cmd->resp.uresp.fwar_db_info.fwar_db_addr_hi << 32);
 | 
								      ((uint64_t)cmd->resp.uresp.fwar_db_info.fwar_db_addr_hi << 32);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kfree(cmd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -733,14 +731,14 @@ static int psp_rl_load(struct amdgpu_device *adev)
 | 
				
			||||||
	struct psp_context *psp = &adev->psp;
 | 
						struct psp_context *psp = &adev->psp;
 | 
				
			||||||
	struct psp_gfx_cmd_resp *cmd = psp->cmd;
 | 
						struct psp_gfx_cmd_resp *cmd = psp->cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						memset(cmd, 0, sizeof(struct psp_gfx_cmd_resp));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!is_psp_fw_valid(psp->rl))
 | 
						if (!is_psp_fw_valid(psp->rl))
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	memset(psp->fw_pri_buf, 0, PSP_1_MEG);
 | 
						memset(psp->fw_pri_buf, 0, PSP_1_MEG);
 | 
				
			||||||
	memcpy(psp->fw_pri_buf, psp->rl.start_addr, psp->rl.size_bytes);
 | 
						memcpy(psp->fw_pri_buf, psp->rl.start_addr, psp->rl.size_bytes);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	memset(cmd, 0, sizeof(struct psp_gfx_cmd_resp));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cmd->cmd_id = GFX_CMD_ID_LOAD_IP_FW;
 | 
						cmd->cmd_id = GFX_CMD_ID_LOAD_IP_FW;
 | 
				
			||||||
	cmd->cmd.cmd_load_ip_fw.fw_phy_addr_lo = lower_32_bits(psp->fw_pri_mc_addr);
 | 
						cmd->cmd.cmd_load_ip_fw.fw_phy_addr_lo = lower_32_bits(psp->fw_pri_mc_addr);
 | 
				
			||||||
	cmd->cmd.cmd_load_ip_fw.fw_phy_addr_hi = upper_32_bits(psp->fw_pri_mc_addr);
 | 
						cmd->cmd.cmd_load_ip_fw.fw_phy_addr_hi = upper_32_bits(psp->fw_pri_mc_addr);
 | 
				
			||||||
| 
						 | 
					@ -753,6 +751,8 @@ static int psp_rl_load(struct amdgpu_device *adev)
 | 
				
			||||||
static void psp_prep_asd_load_cmd_buf(struct psp_gfx_cmd_resp *cmd,
 | 
					static void psp_prep_asd_load_cmd_buf(struct psp_gfx_cmd_resp *cmd,
 | 
				
			||||||
				uint64_t asd_mc, uint32_t size)
 | 
									uint64_t asd_mc, uint32_t size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						memset(cmd, 0, sizeof(struct psp_gfx_cmd_resp));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd->cmd_id = GFX_CMD_ID_LOAD_ASD;
 | 
						cmd->cmd_id = GFX_CMD_ID_LOAD_ASD;
 | 
				
			||||||
	cmd->cmd.cmd_load_ta.app_phy_addr_lo = lower_32_bits(asd_mc);
 | 
						cmd->cmd.cmd_load_ta.app_phy_addr_lo = lower_32_bits(asd_mc);
 | 
				
			||||||
	cmd->cmd.cmd_load_ta.app_phy_addr_hi = upper_32_bits(asd_mc);
 | 
						cmd->cmd.cmd_load_ta.app_phy_addr_hi = upper_32_bits(asd_mc);
 | 
				
			||||||
| 
						 | 
					@ -766,7 +766,7 @@ static void psp_prep_asd_load_cmd_buf(struct psp_gfx_cmd_resp *cmd,
 | 
				
			||||||
static int psp_asd_load(struct psp_context *psp)
 | 
					static int psp_asd_load(struct psp_context *psp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	struct psp_gfx_cmd_resp *cmd;
 | 
						struct psp_gfx_cmd_resp *cmd = psp->cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* If PSP version doesn't match ASD version, asd loading will be failed.
 | 
						/* If PSP version doesn't match ASD version, asd loading will be failed.
 | 
				
			||||||
	 * add workaround to bypass it for sriov now.
 | 
						 * add workaround to bypass it for sriov now.
 | 
				
			||||||
| 
						 | 
					@ -775,10 +775,6 @@ static int psp_asd_load(struct psp_context *psp)
 | 
				
			||||||
	if (amdgpu_sriov_vf(psp->adev) || !psp->asd_ucode_size)
 | 
						if (amdgpu_sriov_vf(psp->adev) || !psp->asd_ucode_size)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 | 
					 | 
				
			||||||
	if (!cmd)
 | 
					 | 
				
			||||||
		return -ENOMEM;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	psp_copy_fw(psp, psp->asd_start_addr, psp->asd_ucode_size);
 | 
						psp_copy_fw(psp, psp->asd_start_addr, psp->asd_ucode_size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	psp_prep_asd_load_cmd_buf(cmd, psp->fw_pri_mc_addr,
 | 
						psp_prep_asd_load_cmd_buf(cmd, psp->fw_pri_mc_addr,
 | 
				
			||||||
| 
						 | 
					@ -791,14 +787,14 @@ static int psp_asd_load(struct psp_context *psp)
 | 
				
			||||||
		psp->asd_context.session_id = cmd->resp.session_id;
 | 
							psp->asd_context.session_id = cmd->resp.session_id;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kfree(cmd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void psp_prep_ta_unload_cmd_buf(struct psp_gfx_cmd_resp *cmd,
 | 
					static void psp_prep_ta_unload_cmd_buf(struct psp_gfx_cmd_resp *cmd,
 | 
				
			||||||
				       uint32_t session_id)
 | 
									       uint32_t session_id)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						memset(cmd, 0, sizeof(struct psp_gfx_cmd_resp));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd->cmd_id = GFX_CMD_ID_UNLOAD_TA;
 | 
						cmd->cmd_id = GFX_CMD_ID_UNLOAD_TA;
 | 
				
			||||||
	cmd->cmd.cmd_unload_ta.session_id = session_id;
 | 
						cmd->cmd.cmd_unload_ta.session_id = session_id;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -806,7 +802,7 @@ static void psp_prep_ta_unload_cmd_buf(struct psp_gfx_cmd_resp *cmd,
 | 
				
			||||||
static int psp_asd_unload(struct psp_context *psp)
 | 
					static int psp_asd_unload(struct psp_context *psp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	struct psp_gfx_cmd_resp *cmd;
 | 
						struct psp_gfx_cmd_resp *cmd = psp->cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (amdgpu_sriov_vf(psp->adev))
 | 
						if (amdgpu_sriov_vf(psp->adev))
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
| 
						 | 
					@ -814,10 +810,6 @@ static int psp_asd_unload(struct psp_context *psp)
 | 
				
			||||||
	if (!psp->asd_context.asd_initialized)
 | 
						if (!psp->asd_context.asd_initialized)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 | 
					 | 
				
			||||||
	if (!cmd)
 | 
					 | 
				
			||||||
		return -ENOMEM;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	psp_prep_ta_unload_cmd_buf(cmd, psp->asd_context.session_id);
 | 
						psp_prep_ta_unload_cmd_buf(cmd, psp->asd_context.session_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = psp_cmd_submit_buf(psp, NULL, cmd,
 | 
						ret = psp_cmd_submit_buf(psp, NULL, cmd,
 | 
				
			||||||
| 
						 | 
					@ -825,14 +817,14 @@ static int psp_asd_unload(struct psp_context *psp)
 | 
				
			||||||
	if (!ret)
 | 
						if (!ret)
 | 
				
			||||||
		psp->asd_context.asd_initialized = false;
 | 
							psp->asd_context.asd_initialized = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kfree(cmd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void psp_prep_reg_prog_cmd_buf(struct psp_gfx_cmd_resp *cmd,
 | 
					static void psp_prep_reg_prog_cmd_buf(struct psp_gfx_cmd_resp *cmd,
 | 
				
			||||||
		uint32_t id, uint32_t value)
 | 
							uint32_t id, uint32_t value)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						memset(cmd, 0, sizeof(struct psp_gfx_cmd_resp));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd->cmd_id = GFX_CMD_ID_PROG_REG;
 | 
						cmd->cmd_id = GFX_CMD_ID_PROG_REG;
 | 
				
			||||||
	cmd->cmd.cmd_setup_reg_prog.reg_value = value;
 | 
						cmd->cmd.cmd_setup_reg_prog.reg_value = value;
 | 
				
			||||||
	cmd->cmd.cmd_setup_reg_prog.reg_id = id;
 | 
						cmd->cmd.cmd_setup_reg_prog.reg_id = id;
 | 
				
			||||||
| 
						 | 
					@ -841,22 +833,17 @@ static void psp_prep_reg_prog_cmd_buf(struct psp_gfx_cmd_resp *cmd,
 | 
				
			||||||
int psp_reg_program(struct psp_context *psp, enum psp_reg_prog_id reg,
 | 
					int psp_reg_program(struct psp_context *psp, enum psp_reg_prog_id reg,
 | 
				
			||||||
		uint32_t value)
 | 
							uint32_t value)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct psp_gfx_cmd_resp *cmd = NULL;
 | 
						struct psp_gfx_cmd_resp *cmd = psp->cmd;
 | 
				
			||||||
	int ret = 0;
 | 
						int ret = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (reg >= PSP_REG_LAST)
 | 
						if (reg >= PSP_REG_LAST)
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 | 
					 | 
				
			||||||
	if (!cmd)
 | 
					 | 
				
			||||||
		return -ENOMEM;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	psp_prep_reg_prog_cmd_buf(cmd, reg, value);
 | 
						psp_prep_reg_prog_cmd_buf(cmd, reg, value);
 | 
				
			||||||
	ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr);
 | 
						ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr);
 | 
				
			||||||
	if (ret)
 | 
						if (ret)
 | 
				
			||||||
		DRM_ERROR("PSP failed to program reg id %d", reg);
 | 
							DRM_ERROR("PSP failed to program reg id %d", reg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kfree(cmd);
 | 
					 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -866,6 +853,8 @@ static void psp_prep_ta_load_cmd_buf(struct psp_gfx_cmd_resp *cmd,
 | 
				
			||||||
				     uint64_t ta_shared_mc,
 | 
									     uint64_t ta_shared_mc,
 | 
				
			||||||
				     uint32_t ta_shared_size)
 | 
									     uint32_t ta_shared_size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						memset(cmd, 0, sizeof(struct psp_gfx_cmd_resp));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd->cmd_id				= GFX_CMD_ID_LOAD_TA;
 | 
						cmd->cmd_id				= GFX_CMD_ID_LOAD_TA;
 | 
				
			||||||
	cmd->cmd.cmd_load_ta.app_phy_addr_lo 	= lower_32_bits(ta_bin_mc);
 | 
						cmd->cmd.cmd_load_ta.app_phy_addr_lo 	= lower_32_bits(ta_bin_mc);
 | 
				
			||||||
	cmd->cmd.cmd_load_ta.app_phy_addr_hi	= upper_32_bits(ta_bin_mc);
 | 
						cmd->cmd.cmd_load_ta.app_phy_addr_hi	= upper_32_bits(ta_bin_mc);
 | 
				
			||||||
| 
						 | 
					@ -897,6 +886,8 @@ static void psp_prep_ta_invoke_cmd_buf(struct psp_gfx_cmd_resp *cmd,
 | 
				
			||||||
				       uint32_t ta_cmd_id,
 | 
									       uint32_t ta_cmd_id,
 | 
				
			||||||
				       uint32_t session_id)
 | 
									       uint32_t session_id)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						memset(cmd, 0, sizeof(struct psp_gfx_cmd_resp));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd->cmd_id				= GFX_CMD_ID_INVOKE_CMD;
 | 
						cmd->cmd_id				= GFX_CMD_ID_INVOKE_CMD;
 | 
				
			||||||
	cmd->cmd.cmd_invoke_cmd.session_id	= session_id;
 | 
						cmd->cmd.cmd_invoke_cmd.session_id	= session_id;
 | 
				
			||||||
	cmd->cmd.cmd_invoke_cmd.ta_cmd_id	= ta_cmd_id;
 | 
						cmd->cmd.cmd_invoke_cmd.ta_cmd_id	= ta_cmd_id;
 | 
				
			||||||
| 
						 | 
					@ -907,35 +898,25 @@ static int psp_ta_invoke(struct psp_context *psp,
 | 
				
			||||||
		  uint32_t session_id)
 | 
							  uint32_t session_id)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	struct psp_gfx_cmd_resp *cmd;
 | 
						struct psp_gfx_cmd_resp *cmd = psp->cmd;
 | 
				
			||||||
 | 
					 | 
				
			||||||
	cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 | 
					 | 
				
			||||||
	if (!cmd)
 | 
					 | 
				
			||||||
		return -ENOMEM;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	psp_prep_ta_invoke_cmd_buf(cmd, ta_cmd_id, session_id);
 | 
						psp_prep_ta_invoke_cmd_buf(cmd, ta_cmd_id, session_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = psp_cmd_submit_buf(psp, NULL, cmd,
 | 
						ret = psp_cmd_submit_buf(psp, NULL, cmd,
 | 
				
			||||||
				 psp->fence_buf_mc_addr);
 | 
									 psp->fence_buf_mc_addr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kfree(cmd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int psp_xgmi_load(struct psp_context *psp)
 | 
					static int psp_xgmi_load(struct psp_context *psp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	struct psp_gfx_cmd_resp *cmd;
 | 
						struct psp_gfx_cmd_resp *cmd = psp->cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * TODO: bypass the loading in sriov for now
 | 
						 * TODO: bypass the loading in sriov for now
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 | 
					 | 
				
			||||||
	if (!cmd)
 | 
					 | 
				
			||||||
		return -ENOMEM;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	psp_copy_fw(psp, psp->ta_xgmi_start_addr, psp->ta_xgmi_ucode_size);
 | 
						psp_copy_fw(psp, psp->ta_xgmi_start_addr, psp->ta_xgmi_ucode_size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	psp_prep_ta_load_cmd_buf(cmd,
 | 
						psp_prep_ta_load_cmd_buf(cmd,
 | 
				
			||||||
| 
						 | 
					@ -952,15 +933,13 @@ static int psp_xgmi_load(struct psp_context *psp)
 | 
				
			||||||
		psp->xgmi_context.session_id = cmd->resp.session_id;
 | 
							psp->xgmi_context.session_id = cmd->resp.session_id;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kfree(cmd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int psp_xgmi_unload(struct psp_context *psp)
 | 
					static int psp_xgmi_unload(struct psp_context *psp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	struct psp_gfx_cmd_resp *cmd;
 | 
						struct psp_gfx_cmd_resp *cmd = psp->cmd;
 | 
				
			||||||
	struct amdgpu_device *adev = psp->adev;
 | 
						struct amdgpu_device *adev = psp->adev;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* XGMI TA unload currently is not supported on Arcturus/Aldebaran A+A */
 | 
						/* XGMI TA unload currently is not supported on Arcturus/Aldebaran A+A */
 | 
				
			||||||
| 
						 | 
					@ -972,17 +951,11 @@ static int psp_xgmi_unload(struct psp_context *psp)
 | 
				
			||||||
	 * TODO: bypass the unloading in sriov for now
 | 
						 * TODO: bypass the unloading in sriov for now
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 | 
					 | 
				
			||||||
	if (!cmd)
 | 
					 | 
				
			||||||
		return -ENOMEM;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	psp_prep_ta_unload_cmd_buf(cmd, psp->xgmi_context.session_id);
 | 
						psp_prep_ta_unload_cmd_buf(cmd, psp->xgmi_context.session_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = psp_cmd_submit_buf(psp, NULL, cmd,
 | 
						ret = psp_cmd_submit_buf(psp, NULL, cmd,
 | 
				
			||||||
				 psp->fence_buf_mc_addr);
 | 
									 psp->fence_buf_mc_addr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kfree(cmd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1202,7 +1175,7 @@ static int psp_ras_init_shared_buf(struct psp_context *psp)
 | 
				
			||||||
static int psp_ras_load(struct psp_context *psp)
 | 
					static int psp_ras_load(struct psp_context *psp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	struct psp_gfx_cmd_resp *cmd;
 | 
						struct psp_gfx_cmd_resp *cmd = psp->cmd;
 | 
				
			||||||
	struct ta_ras_shared_memory *ras_cmd;
 | 
						struct ta_ras_shared_memory *ras_cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
| 
						 | 
					@ -1211,10 +1184,6 @@ static int psp_ras_load(struct psp_context *psp)
 | 
				
			||||||
	if (amdgpu_sriov_vf(psp->adev))
 | 
						if (amdgpu_sriov_vf(psp->adev))
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 | 
					 | 
				
			||||||
	if (!cmd)
 | 
					 | 
				
			||||||
		return -ENOMEM;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	psp_copy_fw(psp, psp->ta_ras_start_addr, psp->ta_ras_ucode_size);
 | 
						psp_copy_fw(psp, psp->ta_ras_start_addr, psp->ta_ras_ucode_size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ras_cmd = (struct ta_ras_shared_memory *)psp->ras.ras_shared_buf;
 | 
						ras_cmd = (struct ta_ras_shared_memory *)psp->ras.ras_shared_buf;
 | 
				
			||||||
| 
						 | 
					@ -1245,15 +1214,13 @@ static int psp_ras_load(struct psp_context *psp)
 | 
				
			||||||
	if (ret || ras_cmd->ras_status)
 | 
						if (ret || ras_cmd->ras_status)
 | 
				
			||||||
		amdgpu_ras_fini(psp->adev);
 | 
							amdgpu_ras_fini(psp->adev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kfree(cmd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int psp_ras_unload(struct psp_context *psp)
 | 
					static int psp_ras_unload(struct psp_context *psp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	struct psp_gfx_cmd_resp *cmd;
 | 
						struct psp_gfx_cmd_resp *cmd = psp->cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * TODO: bypass the unloading in sriov for now
 | 
						 * TODO: bypass the unloading in sriov for now
 | 
				
			||||||
| 
						 | 
					@ -1261,17 +1228,11 @@ static int psp_ras_unload(struct psp_context *psp)
 | 
				
			||||||
	if (amdgpu_sriov_vf(psp->adev))
 | 
						if (amdgpu_sriov_vf(psp->adev))
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 | 
					 | 
				
			||||||
	if (!cmd)
 | 
					 | 
				
			||||||
		return -ENOMEM;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	psp_prep_ta_unload_cmd_buf(cmd, psp->ras.session_id);
 | 
						psp_prep_ta_unload_cmd_buf(cmd, psp->ras.session_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = psp_cmd_submit_buf(psp, NULL, cmd,
 | 
						ret = psp_cmd_submit_buf(psp, NULL, cmd,
 | 
				
			||||||
			psp->fence_buf_mc_addr);
 | 
								psp->fence_buf_mc_addr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kfree(cmd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1512,7 +1473,7 @@ static int psp_hdcp_init_shared_buf(struct psp_context *psp)
 | 
				
			||||||
static int psp_hdcp_load(struct psp_context *psp)
 | 
					static int psp_hdcp_load(struct psp_context *psp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	struct psp_gfx_cmd_resp *cmd;
 | 
						struct psp_gfx_cmd_resp *cmd = psp->cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * TODO: bypass the loading in sriov for now
 | 
						 * TODO: bypass the loading in sriov for now
 | 
				
			||||||
| 
						 | 
					@ -1520,10 +1481,6 @@ static int psp_hdcp_load(struct psp_context *psp)
 | 
				
			||||||
	if (amdgpu_sriov_vf(psp->adev))
 | 
						if (amdgpu_sriov_vf(psp->adev))
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 | 
					 | 
				
			||||||
	if (!cmd)
 | 
					 | 
				
			||||||
		return -ENOMEM;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	psp_copy_fw(psp, psp->ta_hdcp_start_addr,
 | 
						psp_copy_fw(psp, psp->ta_hdcp_start_addr,
 | 
				
			||||||
		    psp->ta_hdcp_ucode_size);
 | 
							    psp->ta_hdcp_ucode_size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1541,8 +1498,6 @@ static int psp_hdcp_load(struct psp_context *psp)
 | 
				
			||||||
		mutex_init(&psp->hdcp_context.mutex);
 | 
							mutex_init(&psp->hdcp_context.mutex);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kfree(cmd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
static int psp_hdcp_initialize(struct psp_context *psp)
 | 
					static int psp_hdcp_initialize(struct psp_context *psp)
 | 
				
			||||||
| 
						 | 
					@ -1577,7 +1532,7 @@ static int psp_hdcp_initialize(struct psp_context *psp)
 | 
				
			||||||
static int psp_hdcp_unload(struct psp_context *psp)
 | 
					static int psp_hdcp_unload(struct psp_context *psp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	struct psp_gfx_cmd_resp *cmd;
 | 
						struct psp_gfx_cmd_resp *cmd = psp->cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * TODO: bypass the unloading in sriov for now
 | 
						 * TODO: bypass the unloading in sriov for now
 | 
				
			||||||
| 
						 | 
					@ -1585,16 +1540,10 @@ static int psp_hdcp_unload(struct psp_context *psp)
 | 
				
			||||||
	if (amdgpu_sriov_vf(psp->adev))
 | 
						if (amdgpu_sriov_vf(psp->adev))
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 | 
					 | 
				
			||||||
	if (!cmd)
 | 
					 | 
				
			||||||
		return -ENOMEM;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	psp_prep_ta_unload_cmd_buf(cmd, psp->hdcp_context.session_id);
 | 
						psp_prep_ta_unload_cmd_buf(cmd, psp->hdcp_context.session_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr);
 | 
						ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kfree(cmd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1663,7 +1612,7 @@ static int psp_dtm_init_shared_buf(struct psp_context *psp)
 | 
				
			||||||
static int psp_dtm_load(struct psp_context *psp)
 | 
					static int psp_dtm_load(struct psp_context *psp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	struct psp_gfx_cmd_resp *cmd;
 | 
						struct psp_gfx_cmd_resp *cmd = psp->cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * TODO: bypass the loading in sriov for now
 | 
						 * TODO: bypass the loading in sriov for now
 | 
				
			||||||
| 
						 | 
					@ -1671,10 +1620,6 @@ static int psp_dtm_load(struct psp_context *psp)
 | 
				
			||||||
	if (amdgpu_sriov_vf(psp->adev))
 | 
						if (amdgpu_sriov_vf(psp->adev))
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 | 
					 | 
				
			||||||
	if (!cmd)
 | 
					 | 
				
			||||||
		return -ENOMEM;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	psp_copy_fw(psp, psp->ta_dtm_start_addr, psp->ta_dtm_ucode_size);
 | 
						psp_copy_fw(psp, psp->ta_dtm_start_addr, psp->ta_dtm_ucode_size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	psp_prep_ta_load_cmd_buf(cmd,
 | 
						psp_prep_ta_load_cmd_buf(cmd,
 | 
				
			||||||
| 
						 | 
					@ -1691,8 +1636,6 @@ static int psp_dtm_load(struct psp_context *psp)
 | 
				
			||||||
		mutex_init(&psp->dtm_context.mutex);
 | 
							mutex_init(&psp->dtm_context.mutex);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kfree(cmd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1728,7 +1671,7 @@ static int psp_dtm_initialize(struct psp_context *psp)
 | 
				
			||||||
static int psp_dtm_unload(struct psp_context *psp)
 | 
					static int psp_dtm_unload(struct psp_context *psp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	struct psp_gfx_cmd_resp *cmd;
 | 
						struct psp_gfx_cmd_resp *cmd = psp->cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * TODO: bypass the unloading in sriov for now
 | 
						 * TODO: bypass the unloading in sriov for now
 | 
				
			||||||
| 
						 | 
					@ -1736,16 +1679,10 @@ static int psp_dtm_unload(struct psp_context *psp)
 | 
				
			||||||
	if (amdgpu_sriov_vf(psp->adev))
 | 
						if (amdgpu_sriov_vf(psp->adev))
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 | 
					 | 
				
			||||||
	if (!cmd)
 | 
					 | 
				
			||||||
		return -ENOMEM;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	psp_prep_ta_unload_cmd_buf(cmd, psp->dtm_context.session_id);
 | 
						psp_prep_ta_unload_cmd_buf(cmd, psp->dtm_context.session_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr);
 | 
						ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kfree(cmd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1814,11 +1751,7 @@ static int psp_rap_init_shared_buf(struct psp_context *psp)
 | 
				
			||||||
static int psp_rap_load(struct psp_context *psp)
 | 
					static int psp_rap_load(struct psp_context *psp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	struct psp_gfx_cmd_resp *cmd;
 | 
						struct psp_gfx_cmd_resp *cmd = psp->cmd;
 | 
				
			||||||
 | 
					 | 
				
			||||||
	cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 | 
					 | 
				
			||||||
	if (!cmd)
 | 
					 | 
				
			||||||
		return -ENOMEM;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	psp_copy_fw(psp, psp->ta_rap_start_addr, psp->ta_rap_ucode_size);
 | 
						psp_copy_fw(psp, psp->ta_rap_start_addr, psp->ta_rap_ucode_size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1836,26 +1769,18 @@ static int psp_rap_load(struct psp_context *psp)
 | 
				
			||||||
		mutex_init(&psp->rap_context.mutex);
 | 
							mutex_init(&psp->rap_context.mutex);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kfree(cmd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int psp_rap_unload(struct psp_context *psp)
 | 
					static int psp_rap_unload(struct psp_context *psp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	struct psp_gfx_cmd_resp *cmd;
 | 
						struct psp_gfx_cmd_resp *cmd = psp->cmd;
 | 
				
			||||||
 | 
					 | 
				
			||||||
	cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 | 
					 | 
				
			||||||
	if (!cmd)
 | 
					 | 
				
			||||||
		return -ENOMEM;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	psp_prep_ta_unload_cmd_buf(cmd, psp->rap_context.session_id);
 | 
						psp_prep_ta_unload_cmd_buf(cmd, psp->rap_context.session_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr);
 | 
						ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kfree(cmd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1980,11 +1905,7 @@ static int psp_securedisplay_init_shared_buf(struct psp_context *psp)
 | 
				
			||||||
static int psp_securedisplay_load(struct psp_context *psp)
 | 
					static int psp_securedisplay_load(struct psp_context *psp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	struct psp_gfx_cmd_resp *cmd;
 | 
						struct psp_gfx_cmd_resp *cmd = psp->cmd;
 | 
				
			||||||
 | 
					 | 
				
			||||||
	cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 | 
					 | 
				
			||||||
	if (!cmd)
 | 
					 | 
				
			||||||
		return -ENOMEM;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	memset(psp->fw_pri_buf, 0, PSP_1_MEG);
 | 
						memset(psp->fw_pri_buf, 0, PSP_1_MEG);
 | 
				
			||||||
	memcpy(psp->fw_pri_buf, psp->ta_securedisplay_start_addr, psp->ta_securedisplay_ucode_size);
 | 
						memcpy(psp->fw_pri_buf, psp->ta_securedisplay_start_addr, psp->ta_securedisplay_ucode_size);
 | 
				
			||||||
| 
						 | 
					@ -2005,25 +1926,18 @@ static int psp_securedisplay_load(struct psp_context *psp)
 | 
				
			||||||
	mutex_init(&psp->securedisplay_context.mutex);
 | 
						mutex_init(&psp->securedisplay_context.mutex);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
failed:
 | 
					failed:
 | 
				
			||||||
	kfree(cmd);
 | 
					 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int psp_securedisplay_unload(struct psp_context *psp)
 | 
					static int psp_securedisplay_unload(struct psp_context *psp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	struct psp_gfx_cmd_resp *cmd;
 | 
						struct psp_gfx_cmd_resp *cmd = psp->cmd;
 | 
				
			||||||
 | 
					 | 
				
			||||||
	cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 | 
					 | 
				
			||||||
	if (!cmd)
 | 
					 | 
				
			||||||
		return -ENOMEM;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	psp_prep_ta_unload_cmd_buf(cmd, psp->securedisplay_context.session_id);
 | 
						psp_prep_ta_unload_cmd_buf(cmd, psp->securedisplay_context.session_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr);
 | 
						ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kfree(cmd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2577,10 +2491,6 @@ static int psp_load_fw(struct amdgpu_device *adev)
 | 
				
			||||||
		goto skip_memalloc;
 | 
							goto skip_memalloc;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	psp->cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 | 
					 | 
				
			||||||
	if (!psp->cmd)
 | 
					 | 
				
			||||||
		return -ENOMEM;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (amdgpu_sriov_vf(adev)) {
 | 
						if (amdgpu_sriov_vf(adev)) {
 | 
				
			||||||
		ret = amdgpu_bo_create_kernel(adev, PSP_1_MEG, PSP_1_MEG,
 | 
							ret = amdgpu_bo_create_kernel(adev, PSP_1_MEG, PSP_1_MEG,
 | 
				
			||||||
						AMDGPU_GEM_DOMAIN_VRAM,
 | 
											AMDGPU_GEM_DOMAIN_VRAM,
 | 
				
			||||||
| 
						 | 
					@ -2734,9 +2644,6 @@ static int psp_hw_fini(void *handle)
 | 
				
			||||||
	amdgpu_bo_free_kernel(&psp->cmd_buf_bo, &psp->cmd_buf_mc_addr,
 | 
						amdgpu_bo_free_kernel(&psp->cmd_buf_bo, &psp->cmd_buf_mc_addr,
 | 
				
			||||||
			      (void **)&psp->cmd_buf_mem);
 | 
								      (void **)&psp->cmd_buf_mem);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kfree(psp->cmd);
 | 
					 | 
				
			||||||
	psp->cmd = NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2900,17 +2807,15 @@ int psp_gpu_reset(struct amdgpu_device *adev)
 | 
				
			||||||
int psp_rlc_autoload_start(struct psp_context *psp)
 | 
					int psp_rlc_autoload_start(struct psp_context *psp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	struct psp_gfx_cmd_resp *cmd;
 | 
						struct psp_gfx_cmd_resp *cmd = psp->cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 | 
						memset(cmd, 0, sizeof(struct psp_gfx_cmd_resp));
 | 
				
			||||||
	if (!cmd)
 | 
					 | 
				
			||||||
		return -ENOMEM;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cmd->cmd_id = GFX_CMD_ID_AUTOLOAD_RLC;
 | 
						cmd->cmd_id = GFX_CMD_ID_AUTOLOAD_RLC;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = psp_cmd_submit_buf(psp, NULL, cmd,
 | 
						ret = psp_cmd_submit_buf(psp, NULL, cmd,
 | 
				
			||||||
				 psp->fence_buf_mc_addr);
 | 
									 psp->fence_buf_mc_addr);
 | 
				
			||||||
	kfree(cmd);
 | 
					
 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue