Example #1
0
static int ion_cp_change_mem_v2(unsigned int phy_base, unsigned int size,
			      void *data, int lock)
{
	enum cp_mem_usage usage = (enum cp_mem_usage) data;
	unsigned long *chunk_list;
	int nchunks;
	int ret;
	int i;

	if (usage < 0 || usage >= MAX_USAGE)
		return -EINVAL;

	if (!IS_ALIGNED(size, V2_CHUNK_SIZE)) {
		pr_err("%s: heap size is not aligned to %x\n",
			__func__, V2_CHUNK_SIZE);
		return -EINVAL;
	}

	nchunks = size / V2_CHUNK_SIZE;

	chunk_list = allocate_contiguous_ebi(sizeof(unsigned long)*nchunks,
						SZ_4K, 0);
	if (!chunk_list)
		return -ENOMEM;

	for (i = 0; i < nchunks; i++)
		chunk_list[i] = phy_base + i * V2_CHUNK_SIZE;

	ret = ion_cp_change_chunks_state(memory_pool_node_paddr(chunk_list),
					nchunks, V2_CHUNK_SIZE, usage, lock);

	free_contiguous_memory(chunk_list);
	return ret;
}
Example #2
0
static int
msm_buspm_dev_alloc(struct file *filp, struct buspm_alloc_params data)
{
    unsigned long paddr;
    void *vaddr;
    struct msm_buspm_map_dev *dev = filp->private_data;


    if (dev->vaddr)
        msm_buspm_dev_free(filp);


    vaddr = allocate_contiguous_ebi(data.size, PAGE_SIZE, 0);
    paddr = (vaddr) ? memory_pool_node_paddr(vaddr) : 0L;

    if (vaddr == NULL) {
        pr_err("allocation of 0x%x bytes failed", data.size);
        return -ENOMEM;
    }

    dev->vaddr = vaddr;
    dev->paddr = paddr;
    dev->buflen = data.size;
    filp->f_pos = 0;
    pr_debug("virt addr = 0x%p\n", dev->vaddr);
    pr_debug("phys addr = 0x%lx\n", dev->paddr);

    return 0;
}
Example #3
0
int mdss_mdp_alloc_fb_mem(struct msm_fb_data_type *mfd)
{
	int dom;
	void *virt = NULL;
	unsigned long phys = 0;
	size_t size;
	u32 yres = mfd->fbi->var.yres_virtual;

	size = PAGE_ALIGN(mfd->fbi->fix.line_length * yres);

	if (mfd->index == 0) {
		virt = allocate_contiguous_memory(size, MEMTYPE_EBI1, SZ_1M, 0);
		if (!virt) {
			pr_err("unable to alloc fbmem size=%u\n", size);
			return -ENOMEM;
		}
		phys = memory_pool_node_paddr(virt);
		dom = mdss_get_iommu_domain(MDSS_IOMMU_DOMAIN_UNSECURE);
		msm_iommu_map_contig_buffer(phys, dom, 0, size, SZ_4K, 0,
					&mfd->iova);

		pr_debug("allocating %u bytes at %p (%lx phys) for fb %d\n",
			size, virt, phys, mfd->index);
	} else
		size = 0;

	mfd->fbi->screen_base = virt;
	mfd->fbi->fix.smem_start = phys;
	mfd->fbi->fix.smem_len = size;

	return 0;
}