All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
To: linux@arm.linux.org.uk
Cc: linux-arm-kernel@lists.arm.linux.org.uk,
	linux-omap@vger.kernel.org, h-kanigeri2@ti.com,
	omar.ramirez@ti.com, sakari.ailus@maxwell.research.nokia.com,
	tony@atomide.com
Subject: Re: [PATCH 4/6] omap iommu: simple virtual address space management
Date: Mon, 18 May 2009 09:31:26 +0300 (EEST)	[thread overview]
Message-ID: <20090518.093126.193701587.Hiroshi.DOYU@nokia.com> (raw)
In-Reply-To: <20090516092248.GE15328@n2100.arm.linux.org.uk>

Hi Russell,

From: ext Russell King - ARM Linux <linux@arm.linux.org.uk>
Subject: Re: [PATCH 4/6] omap iommu: simple virtual address space management
Date: Sat, 16 May 2009 11:22:48 +0200

> 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.

Right. In this change for better performance, I have to expose "struct
mem_type" and "get_mem_type()" a bit more as below. Is this change
acceptable, or do you have a better idea?

diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
index 85a49e2..ad1cbc4 100644
--- a/arch/arm/include/asm/io.h
+++ b/arch/arm/include/asm/io.h
@@ -77,8 +77,17 @@ extern void __iounmap(volatile void __iomem *addr);
 /*
  * external interface to remap single page with appropriate type
  */
+struct mem_type {
+	unsigned int prot_pte;
+	unsigned int prot_l1;
+	unsigned int prot_sect;
+	unsigned int domain;
+};
+
+const struct mem_type *get_mem_type(unsigned int type);
+
 extern int ioremap_page(unsigned long virt, unsigned long phys,
-			unsigned int mtype);
+			const struct mem_type *mtype);
 
 /*
  * Bad read/write accesses...
diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
index 8441351..0ab75c6 100644
--- a/arch/arm/mm/ioremap.c
+++ b/arch/arm/mm/ioremap.c
@@ -110,15 +110,10 @@ static int remap_area_pages(unsigned long start, unsigned long pfn,
 	return err;
 }
 
-int ioremap_page(unsigned long virt, unsigned long phys, unsigned int mtype)
+int ioremap_page(unsigned long virt, unsigned long phys,
+		 const struct mem_type *mtype)
 {
-	const struct mem_type *type;
-
-	type = get_mem_type(mtype);
-	if (!type)
-		return -EINVAL;
-
-	return remap_area_pages(virt, __phys_to_pfn(phys), PAGE_SIZE, type);
+	return remap_area_pages(virt, __phys_to_pfn(phys), PAGE_SIZE, mtype);
 }
 EXPORT_SYMBOL(ioremap_page);
 
diff --git a/arch/arm/mm/mm.h b/arch/arm/mm/mm.h
index 5d9f539..57f10aa 100644
--- a/arch/arm/mm/mm.h
+++ b/arch/arm/mm/mm.h
@@ -16,15 +16,6 @@ static inline pmd_t *pmd_off_k(unsigned long virt)
 	return pmd_off(pgd_offset_k(virt), virt);
 }
 
-struct mem_type {
-	unsigned int prot_pte;
-	unsigned int prot_l1;
-	unsigned int prot_sect;
-	unsigned int domain;
-};
-
-const struct mem_type *get_mem_type(unsigned int type);
-
 #endif
 
 struct map_desc;
diff --git a/arch/arm/plat-omap/iovmm.c b/arch/arm/plat-omap/iovmm.c
index a539051..020f5af 100644
--- a/arch/arm/plat-omap/iovmm.c
+++ b/arch/arm/plat-omap/iovmm.c
@@ -167,6 +167,11 @@ static void *vmap_sg(const struct sg_table *sgt)
 	unsigned int i;
 	struct scatterlist *sg;
 	struct vm_struct *new;
+	const struct mem_type *mtype;
+
+	mtype = get_mem_type(MT_DEVICE);
+	if (!type)
+		return -EINVAL;
 
 	total = sgtable_len(sgt);
 	if (!total)
@@ -187,7 +192,7 @@ static void *vmap_sg(const struct sg_table *sgt)
 
 		BUG_ON(bytes != PAGE_SIZE);
 
-		err = ioremap_page(va,  pa, MT_DEVICE);
+		err = ioremap_page(va,  pa, mtype);
 		if (err)
 			goto err_out;
 

  reply	other threads:[~2009-05-18  6:32 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-05 12:46 [PATCH 0/6] Initial support for omap iommu driver Hiroshi DOYU
2009-05-05 12:46 ` [PATCH 1/6] omap iommu: tlb and pagetable primitives Hiroshi DOYU
2009-05-05 20:19   ` Kanigeri, Hari
2009-05-06  5:56     ` Hiroshi DOYU
2009-05-05 12:46 ` [PATCH 2/6] omap iommu: omap2 architecture specific functions Hiroshi DOYU
2009-05-06 14:31   ` Kanigeri, Hari
2009-05-07  5:12     ` Hiroshi DOYU
2009-05-07 14:40       ` Kanigeri, Hari
2009-05-05 12:47 ` [PATCH 3/6] omap iommu: omap3 iommu device registration Hiroshi DOYU
2009-05-05 19:32   ` Felipe Contreras
2009-05-06  6:00     ` Hiroshi DOYU
2009-05-07 20:02       ` Felipe Contreras
2009-05-07 20:11         ` [RFC/PATCH 0/3] omap3-iommu: cleanups and remote registration Felipe Contreras
2009-05-07 20:11           ` [RFC/PATCH 1/3] omap3-iommu: reorganize Felipe Contreras
2009-05-07 20:11             ` [RFC/PATCH 2/3] omap3-iommu: split init function into omap_iommu_add Felipe Contreras
2009-05-07 20:11               ` [RFC/PATCH 3/3] omap3-iommu: remote registration Felipe Contreras
2009-05-07 21:14             ` [RFC/PATCH 1/3] omap3-iommu: reorganize Felipe Balbi
2009-05-07 22:16               ` Felipe Contreras
2009-05-08  4:15               ` Hiroshi DOYU
2009-05-07 20:28           ` [RFC/PATCH 0/3] omap3-iommu: cleanups and remote registration Kanigeri, Hari
2009-05-07 20:39             ` Felipe Contreras
2009-05-07 20:54               ` Kanigeri, Hari
2009-05-08  4:14           ` Hiroshi DOYU
2009-05-08  8:04             ` Felipe Contreras
2009-05-07 20:05   ` [PATCH 3/6] omap iommu: omap3 iommu device registration Felipe Contreras
2009-05-08  4:10     ` Hiroshi DOYU
2009-05-08  7:32       ` Felipe Contreras
2009-05-08 17:21         ` Aguirre Rodriguez, Sergio Alberto
2009-05-08 22:27           ` Felipe Contreras
2009-05-16  9:20   ` Russell King - ARM Linux
2009-05-16  9:38     ` Felipe Contreras
2009-05-16  9:54       ` Russell King - ARM Linux
2009-05-16  9:56         ` Felipe Contreras
2009-05-16  9:55     ` Russell King - ARM Linux
2009-05-18  5:36       ` Hiroshi DOYU
2009-05-18  9:39       ` Hiroshi DOYU
2009-05-18 14:26       ` Hiroshi DOYU
2009-05-18 16:43         ` [PATCH] omap3-iommu: reorganize Felipe Contreras
2009-05-19  6:03           ` Hiroshi DOYU
2009-05-19  9:43             ` Felipe Contreras
2009-05-18  5:22     ` [PATCH 3/6] omap iommu: omap3 iommu device registration Hiroshi DOYU
2009-05-05 12:47 ` [PATCH 4/6] omap iommu: simple virtual address space management Hiroshi DOYU
2009-05-16  9:22   ` Russell King - ARM Linux
2009-05-18  6:31     ` Hiroshi DOYU [this message]
2009-05-18 13:10       ` Russell King - ARM Linux
2009-05-05 12:47 ` [PATCH 5/6] omap iommu: entries for Kconfig and Makefile Hiroshi DOYU
2009-05-18 13:36   ` Russell King - ARM Linux
2009-05-05 12:47 ` [PATCH 6/6] omap2 " Hiroshi DOYU
  -- strict thread matches above, loose matches on Subject: below --
2009-01-16  8:37 [PATCH 0/6] arm: omap iommu: add initial support Hiroshi DOYU
2009-01-16  8:37 ` [PATCH 4/6] omap iommu: simple virtual address space management Hiroshi DOYU
2009-01-17 16:57   ` Russell King - ARM Linux
2009-01-27 21:29     ` Hiroshi DOYU

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090518.093126.193701587.Hiroshi.DOYU@nokia.com \
    --to=hiroshi.doyu@nokia.com \
    --cc=h-kanigeri2@ti.com \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=omar.ramirez@ti.com \
    --cc=sakari.ailus@maxwell.research.nokia.com \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.