Re: [PATCH 4/6] omap iommu: simple virtual address space management

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 05, 2009 at 03:47:06PM +0300, Hiroshi DOYU wrote:
> +int ioremap_page(unsigned long virt, unsigned long phys, unsigned int mtype)
> +{
> +	const struct mem_type *type;
> +
> +	type = get_mem_type(mtype);
> +	if (!type)
> +		return -EINVAL;

I think it would make more sense to move this lookup into the caller
for this - you're going to be making quite a lot of calls into
ioremap_page() so you really don't want to be doing the same lookup
every time.

> +/* map 'sglist' to a contiguous mpu virtual area and return 'va' */
> +static void *vmap_sg(const struct sg_table *sgt)
> +{
> +	u32 va;
> +	size_t total;
> +	unsigned int i;
> +	struct scatterlist *sg;
> +	struct vm_struct *new;
> +
> +	total = sgtable_len(sgt);
> +	if (!total)
> +		return ERR_PTR(-EINVAL);
> +
> +	new = __get_vm_area(total, VM_IOREMAP, VMALLOC_START, VMALLOC_END);
> +	if (!new)
> +		return ERR_PTR(-ENOMEM);
> +	va = (u32)new->addr;

In other words, move it here.

> +
> +	for_each_sg(sgt->sgl, sg, sgt->nents, i) {
> +		size_t bytes;
> +		u32 pa;
> +		int err;
> +
> +		pa = sg_phys(sg);
> +		bytes = sg_dma_len(sg);
> +
> +		BUG_ON(bytes != PAGE_SIZE);
> +
> +		err = ioremap_page(va,  pa, MT_DEVICE);
> +		if (err)
> +			goto err_out;
> +
> +		va += bytes;
> +	}
> +
> +	flush_cache_vmap(new->addr, total);
> +	return new->addr;
> +
> +err_out:
> +	WARN_ON(1); /* FIXME: cleanup some mpu mappings */
> +	vunmap(new->addr);
> +	return ERR_PTR(-EAGAIN);
> +}
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux