Ejemplo n.º 1
0
void ddl_fw_release(struct ddl_buf_addr *dram_base)
{
	void *cookie = dram_base->pil_cookie;
	if (res_trk_is_cp_enabled() &&
		res_trk_check_for_sec_session()) {
		res_trk_close_secure_session();
		if (IS_ERR_OR_NULL(cookie)) {
			pr_err("Invalid params");
		return;
	}
	if (res_trk_enable_footswitch()) {
		pr_err("Failed to enable footswitch");
		return;
	}
	if (res_trk_enable_iommu_clocks()) {
		res_trk_disable_footswitch();
		pr_err("Failed to enable iommu clocks\n");
		return;
	}
	pil_put(cookie);
	if (res_trk_disable_iommu_clocks())
		pr_err("Failed to disable iommu clocks\n");
	if (res_trk_disable_footswitch())
		pr_err("Failed to disable footswitch\n");
	} else {
	if (res_trk_check_for_sec_session())
		res_trk_close_secure_session();
		res_trk_release_fw_addr();
	}
}
int res_trk_close_secure_session()
{
	int rc;
	if (res_trk_check_for_sec_session() == 1 &&
		resource_context.sec_clk_heap) {
		pr_err("Unsecuring....\n");
		mutex_lock(&resource_context.secure_lock);
		rc = res_trk_enable_iommu_clocks();
		if (rc) {
			pr_err("IOMMU clock enabled failed while close\n");
			goto error_close;
		}
		msm_ion_unsecure_heap(ION_HEAP(resource_context.cmd_mem_type));
		msm_ion_unsecure_heap(ION_HEAP(resource_context.memtype));

		if (resource_context.vidc_platform_data->secure_wb_heap)
			msm_ion_unsecure_heap(ION_HEAP(ION_CP_WB_HEAP_ID));

		res_trk_disable_iommu_clocks();
		resource_context.sec_clk_heap = 0;
		mutex_unlock(&resource_context.secure_lock);
	}
	return 0;
error_close:
	mutex_unlock(&resource_context.secure_lock);
	return rc;
}
Ejemplo n.º 3
0
u32 ddl_fw_init(struct ddl_buf_addr *dram_base)
{
	u8 *dest_addr;
	dest_addr = DDL_GET_ALIGNED_VITUAL(*dram_base);
	DDL_MSG_LOW("FW Addr / FW Size : %x/%d", (u32)vidc_video_codec_fw,
		vidc_video_codec_fw_size);
	if (res_trk_check_for_sec_session() && res_trk_is_cp_enabled()) {
		if (res_trk_enable_footswitch()) {
			pr_err("Failed to enable footswitch");
			return false;
		}
		if (res_trk_enable_iommu_clocks()) {
			res_trk_disable_footswitch();
			pr_err("Failed to enable iommu clocks\n");
			return false;
		}
		dram_base->pil_cookie = pil_get("vidc");
		if (res_trk_disable_iommu_clocks())
			pr_err("Failed to disable iommu clocks\n");
		if (IS_ERR_OR_NULL(dram_base->pil_cookie)) {
			res_trk_disable_footswitch();
			pr_err("pil_get failed\n");
			return false;
		}
	} else {
		if (vidc_video_codec_fw_size > dram_base->buffer_size ||
				!vidc_video_codec_fw)
			return false;
		memcpy(dest_addr, vidc_video_codec_fw,
				vidc_video_codec_fw_size);
	}
	return true;
}
Ejemplo n.º 4
0
int res_trk_open_secure_session()
{
	int rc, memtype;
	if (!res_trk_check_for_sec_session()) {
		pr_err("Secure sessions are not active\n");
		return -EINVAL;
	}
	mutex_lock(&resource_context.secure_lock);
	if (!resource_context.sec_clk_heap) {
	
		pr_err("Securing...\n");
		rc = res_trk_enable_iommu_clocks();
		if (rc) {
			pr_err("IOMMU clock enabled failed while open");
			goto error_open;
		}

		memtype = ION_HEAP(resource_context.memtype);
		rc = msm_ion_secure_heap(memtype);
		if (rc) {
			pr_err("ION heap secure failed heap id %d rc %d\n",
				   resource_context.memtype, rc);
			goto disable_iommu_clks;
		}
		memtype = ION_HEAP(resource_context.cmd_mem_type);
		rc = msm_ion_secure_heap(memtype);
		if (rc) {
			pr_err("ION heap secure failed heap id %d rc %d\n",
				   resource_context.cmd_mem_type, rc);
			goto unsecure_memtype_heap;
		}
		if (resource_context.vidc_platform_data->secure_wb_heap) {
			memtype = ION_HEAP(ION_CP_WB_HEAP_ID);
			rc = msm_ion_secure_heap(memtype);
			if (rc) {
				pr_err("WB_HEAP_ID secure failed rc %d\n", rc);
				goto unsecure_cmd_heap;
			}
		}
		resource_context.sec_clk_heap = 1;
		
		res_trk_disable_iommu_clocks();
	}
	mutex_unlock(&resource_context.secure_lock);
	return 0;
unsecure_cmd_heap:
	msm_ion_unsecure_heap(ION_HEAP(resource_context.cmd_mem_type));
unsecure_memtype_heap:
	msm_ion_unsecure_heap(ION_HEAP(resource_context.memtype));
disable_iommu_clks:
	res_trk_disable_iommu_clocks();
error_open:
	resource_context.sec_clk_heap = 0;
	mutex_unlock(&resource_context.secure_lock);
	return rc;
}
Ejemplo n.º 5
0
int res_trk_close_secure_session()
{
	int rc;
	mutex_lock(&resource_context.secure_lock);
	rc = res_trk_enable_iommu_clocks();
	if (rc) {
		pr_err("IOMMU clock enabled failed while close");
		goto error_close;
	}
	msm_ion_unsecure_heap(ION_HEAP(resource_context.memtype));
	msm_ion_unsecure_heap(ION_HEAP(resource_context.cmd_mem_type));
	res_trk_disable_iommu_clocks();
	resource_context.secure_session = 0;
	mutex_unlock(&resource_context.secure_lock);
	return 0;
error_close:
	mutex_unlock(&resource_context.secure_lock);
	return rc;
}
Ejemplo n.º 6
0
int res_trk_open_secure_session()
{
	int rc;

	if (res_trk_check_for_sec_session() == 1) {
		mutex_lock(&resource_context.secure_lock);
		pr_err("Securing...\n");
		rc = res_trk_enable_iommu_clocks();
		if (rc) {
			pr_err("IOMMU clock enabled failed while open");
			goto error_open;
		}
		msm_ion_secure_heap(ION_HEAP(resource_context.memtype));
		msm_ion_secure_heap(ION_HEAP(resource_context.cmd_mem_type));
		res_trk_disable_iommu_clocks();
		mutex_unlock(&resource_context.secure_lock);
	}
	return 0;
error_open:
	mutex_unlock(&resource_context.secure_lock);
	return rc;
}
Ejemplo n.º 7
0
int res_trk_open_secure_session()
{
	int rc;
	mutex_lock(&resource_context.secure_lock);
	if (resource_context.secure_session) {
		pr_err("Secure session already open");
		rc = -EBUSY;
		goto error_open;
	}
	resource_context.secure_session = 1;
	rc = res_trk_enable_iommu_clocks();
	if (rc) {
		pr_err("IOMMU clock enabled failed while open");
		goto error_open;
	}
	msm_ion_secure_heap(ION_HEAP(resource_context.memtype));
	msm_ion_secure_heap(ION_HEAP(resource_context.cmd_mem_type));
	res_trk_disable_iommu_clocks();
	mutex_unlock(&resource_context.secure_lock);
	return 0;
error_open:
	mutex_unlock(&resource_context.secure_lock);
	return rc;
}