Skip to contentSkip to conversation

staging: tidspbridge: fix ioremap() usage

PATCH New Felipe Contreras 5 participants 13 messages Oct 10, 2010 – Oct 11, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover staging: tidspbridge: fix ioremap() usage

Now we truly reserve the memory so that the kernel doesn't map it.

Unfortunately, the ARM architecture code doesn't provide a good way to do this, so I had to modify it a bit.

Felipe Contreras (3):
arm: mm: allow boards to fiddle with meminfo
omap: dsp: fix ioremap() usage
staging: tidspbridge: remove memory consistency from TODO list

 arch/arm/include/asm/mach/arch.h         |    2 +-
 arch/arm/mm/init.c                       |    7 +++--
 arch/arm/plat-omap/common.c              |   43 +++++++++++++++++++++++++++--
 arch/arm/plat-omap/devices.c             |   30 ---------------------
 arch/arm/plat-omap/include/plat/common.h |    3 +-
 arch/arm/plat-omap/include/plat/dsp.h    |    6 ----
 drivers/staging/tidspbridge/TODO         |    1 -
 7 files changed, 47 insertions(+), 45 deletions(-)
Signature · 1 line
1.7.3.1.2.g7fe2b
#1 lore raw

PATCH 1/3 arm: mm: allow boards to fiddle with meminfo

So that they can reserve some memory.

---
 arch/arm/include/asm/mach/arch.h |    2 +-
 arch/arm/mm/init.c               |    7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)
arch/arm/include/asm/mach/arch.h +1 -1
index 8a0dd18..408e4d5 100644
@@ -38,7 +38,7 @@ struct machine_desc {
 	void			(*fixup)(struct machine_desc *,
 					 struct tag *, char **,
 					 struct meminfo *);
-	void			(*reserve)(void);/* reserve mem blocks	*/
+	void			(*reserve)(struct meminfo *);/* reserve mem blocks	*/
 	void			(*map_io)(void);/* IO mapping function	*/
 	void			(*init_irq)(void);
 	struct sys_timer	*timer;		/* system tick timer	*/
arch/arm/mm/init.c +4 -3
index 7185b00..4b5c117 100644
@@ -272,8 +272,6 @@ void __init arm_memblock_init(struct meminfo *mi, struct machine_desc *mdesc)
 	int i;
 
 	memblock_init();
-	for (i = 0; i < mi->nr_banks; i++)
-		memblock_add(mi->bank[i].start, mi->bank[i].size);
 
 	/* Register the kernel text, kernel data and initrd with memblock. */
 #ifdef CONFIG_XIP_KERNEL
@@ -295,7 +293,10 @@ void __init arm_memblock_init(struct meminfo *mi, struct machine_desc *mdesc)
 
 	/* reserve any platform specific memblock areas */
 	if (mdesc->reserve)
-		mdesc->reserve();
+		mdesc->reserve(mi);
+
+	for (i = 0; i < mi->nr_banks; i++)
+		memblock_add(mi->bank[i].start, mi->bank[i].size);
 
 	memblock_analyze();
 	memblock_dump_all();
Signature · 1 line
1.7.3.1.2.g7fe2b
#2 lore raw

PATCH 1/3 arm: mm: allow boards to fiddle with meminfo

Quoted 35 lines · Felipe Contreras

So that they can reserve some memory.

---
 arch/arm/include/asm/mach/arch.h |    2 +-
 arch/arm/mm/init.c               |    7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)
arch/arm/include/asm/mach/arch.h +1 -1
index 8a0dd18..408e4d5 100644
@@ -38,7 +38,7 @@ struct machine_desc {
 	void			(*fixup)(struct machine_desc *,
 					 struct tag *, char **,
 					 struct meminfo *);
-	void			(*reserve)(void);/* reserve mem blocks	*/
+	void			(*reserve)(struct meminfo *);/* reserve mem blocks	*/
 	void			(*map_io)(void);/* IO mapping function	*/
 	void			(*init_irq)(void);
 	struct sys_timer	*timer;		/* system tick timer	*/
arch/arm/mm/init.c +0 -2
index 7185b00..4b5c117 100644
@@ -272,8 +272,6 @@ void __init arm_memblock_init(struct meminfo *mi, struct machine_desc *mdesc)
 	int i;
 
 	memblock_init();
-	for (i = 0; i < mi->nr_banks; i++)
-		memblock_add(mi->bank[i].start, mi->bank[i].size);
 
 	/* Register the kernel text, kernel data and initrd with memblock. */
 #ifdef CONFIG_XIP_KERNEL

arch/arm/mm/init.c void __init arm_memblock_init(struct meminfo *mi, struct machine_desc *mdesc) · line 299

Quoted 8 lines
arch/arm/mm/init.c +4 -1
@@ -295,7 +293,10 @@ void __init arm_memblock_init(struct meminfo *mi, struct machine_desc *mdesc)
 
 	/* reserve any platform specific memblock areas */
 	if (mdesc->reserve)
-		mdesc->reserve();
+		mdesc->reserve(mi);
+
+	for (i = 0; i < mi->nr_banks; i++)
+		memblock_add(mi->bank[i].start, mi->bank[i].size);

It is not a good idea to change the ordering here, as we'll now be adding the memory blocks _after_ we've started to make reservations into memblock.

At least the omapfb code wants there to be memory present in memblock when ->reserve is called.

#3 lore raw

PATCH 1/3 arm: mm: allow boards to fiddle with meminfo

Quoted 49 lines · Russell King - ARM Linux
Quoted 36 lines · Felipe Contreras

So that they can reserve some memory.

---
?arch/arm/include/asm/mach/arch.h | ? ?2 +-
?arch/arm/mm/init.c ? ? ? ? ? ? ? | ? ?7 ++++---
?2 files changed, 5 insertions(+), 4 deletions(-)

arch/arm/include/asm/mach/arch.h +1 -1
index 8a0dd18..408e4d5 100644
@@ -38,7 +38,7 @@ struct machine_desc {
 ? ? ? void ? ? ? ? ? ? ? ? ? ?(*fixup)(struct machine_desc *,
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?struct tag *, char **,
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?struct meminfo *);
- ? ? void ? ? ? ? ? ? ? ? ? ?(*reserve)(void);/* reserve mem blocks ?*/
+ ? ? void ? ? ? ? ? ? ? ? ? ?(*reserve)(struct meminfo *);/* reserve mem blocks ? ? ?*/

? ? ? void ? ? ? ? ? ? ? ? ? ?(*map_io)(void);/* IO mapping function ?*/ ? ? ? void ? ? ? ? ? ? ? ? ? ?(*init_irq)(void);
? ? ? struct sys_timer ? ? ? ?*timer; ? ? ? ? /* system tick timer ? ?*/

arch/arm/mm/init.c +0 -2
index 7185b00..4b5c117 100644
@@ -272,8 +272,6 @@ void __init arm_memblock_init(struct meminfo *mi, struct machine_desc *mdesc)
 ? ? ? int i;
 
 ? ? ? memblock_init();
- ? ? for (i = 0; i < mi->nr_banks; i++)
- ? ? ? ? ? ? memblock_add(mi->bank[i].start, mi->bank[i].size);
 

? ? ? /* Register the kernel text, kernel data and initrd with memblock. */ ?#ifdef CONFIG_XIP_KERNEL

arch/arm/mm/init.c +0 -0
@@ -295,7 +293,10 @@ void __init arm_memblock_init(struct meminfo *mi, struct machine_desc *mdesc)
 
Quoted 7 lines

? ? ? /* reserve any platform specific memblock areas */ ? ? ? if (mdesc->reserve)
- ? ? ? ? ? ? mdesc->reserve();
+ ? ? ? ? ? ? mdesc->reserve(mi);
+
+ ? ? for (i = 0; i < mi->nr_banks; i++)
+ ? ? ? ? ? ? memblock_add(mi->bank[i].start, mi->bank[i].size);

It is not a good idea to change the ordering here, as we'll now be adding the memory blocks _after_ we've started to make reservations into memblock.

Quoted 2 lines

At least the omapfb code wants there to be memory present in memblock when ->reserve is called.

True. I initially added a new callback called reserve_mem(), but I thought it would be nicer to avoid adding a new function almost identical to an existing one.

Anyway, what is your suggestion? Can you come up with something else?

Signature · 1 line
Felipe Contreras
#4 lore raw

PATCH 2/3 omap: dsp: fix ioremap() usage

In reply to Felipe Contreras

On commit 309caa9 doing ioremap() became forbidden due tue architectural limitations. Only a single mapping is allowed now, so the mempool must not be part of the memory managed by the kernel.

---
 arch/arm/plat-omap/common.c              |   43 +++++++++++++++++++++++++++--
 arch/arm/plat-omap/devices.c             |   30 ---------------------
 arch/arm/plat-omap/include/plat/common.h |    3 +-
 arch/arm/plat-omap/include/plat/dsp.h    |    6 ----
 4 files changed, 42 insertions(+), 40 deletions(-)
arch/arm/plat-omap/common.c +40 -3
index 57205a4..3fee3ca 100644
@@ -37,7 +37,6 @@
 #include <plat/fpga.h>
 #include <plat/serial.h>
 #include <plat/vram.h>
-#include <plat/dsp.h>
 
 #include <plat/clock.h>
 
@@ -84,11 +83,49 @@ const void *omap_get_var_config(u16 tag, size_t *len)
 }
 EXPORT_SYMBOL(omap_get_var_config);
 
-void __init omap_reserve(void)
+#if defined(CONFIG_TIDSPBRIDGE) || defined(CONFIG_TIDSPBRIDGE_MODULE)
+
+static phys_addr_t omap_dsp_mempool_base;
+
+static void __init omap_dsp_reserve_mem(struct meminfo *mi)
+{
+	phys_addr_t size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE;
+	phys_addr_t addr = ~0;
+	int i;
+
+	if (!size)
+		return;
+
+	for (i = mi->nr_banks - 1; i >= 0; i--)
+		if (mi->bank[i].size >= size) {
+			mi->bank[i].size -= size;
+			addr = mi->bank[i].start + mi->bank[i].size;
+			break;
+		}
+
+	if (addr == ~0) {
+		pr_err("%s: failed to reserve 0x%x bytes\n",
+				__func__, size);
+		return;
+	}
+
+	omap_dsp_mempool_base = addr;
+}
+
+phys_addr_t omap_dsp_get_mempool_base(void)
+{
+	return omap_dsp_mempool_base;
+}
+EXPORT_SYMBOL(omap_dsp_get_mempool_base);
+#else
+static inline void omap_dsp_reserve_mem(struct meminfo *mi) { }
+#endif
+
+void __init omap_reserve(struct meminfo *mi)
 {
 	omapfb_reserve_sdram_memblock();
 	omap_vram_reserve_sdram_memblock();
-	omap_dsp_reserve_sdram_memblock();
+	omap_dsp_reserve_mem(mi);
 }
 
 /*
arch/arm/plat-omap/devices.c +0 -30
index 4c8f9b9..d1920be 100644
@@ -15,7 +15,6 @@
 #include <linux/platform_device.h>
 #include <linux/io.h>
 #include <linux/slab.h>
-#include <linux/memblock.h>
 
 #include <mach/hardware.h>
 #include <asm/mach-types.h>
@@ -273,35 +272,6 @@ static void omap_init_wdt(void)
 static inline void omap_init_wdt(void) {}
 #endif
 
-#if defined(CONFIG_TIDSPBRIDGE) || defined(CONFIG_TIDSPBRIDGE_MODULE)
-
-static phys_addr_t omap_dsp_phys_mempool_base;
-
-void __init omap_dsp_reserve_sdram_memblock(void)
-{
-	phys_addr_t size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE;
-	phys_addr_t paddr;
-
-	if (!size)
-		return;
-
-	paddr = __memblock_alloc_base(size, SZ_1M, MEMBLOCK_REAL_LIMIT);
-	if (!paddr) {
-		pr_err("%s: failed to reserve %x bytes\n",
-				__func__, size);
-		return;
-	}
-
-	omap_dsp_phys_mempool_base = paddr;
-}
-
-phys_addr_t omap_dsp_get_mempool_base(void)
-{
-	return omap_dsp_phys_mempool_base;
-}
-EXPORT_SYMBOL(omap_dsp_get_mempool_base);
-#endif
-
 /*
  * This gets called after board-specific INIT_MACHINE, and initializes most
  * on-chip peripherals accessible on this board (except for few like USB):
arch/arm/plat-omap/include/plat/common.h +2 -1
index 9776b41..3675492 100644
@@ -30,11 +30,12 @@
 #include <plat/i2c.h>
 
 struct sys_timer;
+struct meminfo;
 
 extern void omap_map_common_io(void);
 extern struct sys_timer omap_timer;
 
-extern void omap_reserve(void);
+extern void omap_reserve(struct meminfo *mi);
 
 /*
  * IO bases for various OMAP processors
arch/arm/plat-omap/include/plat/dsp.h +0 -6
index 9c604b3..4e53687 100644
@@ -22,10 +22,4 @@ struct omap_dsp_platform_data {
 	phys_addr_t phys_mempool_size;
 };
 
-#if defined(CONFIG_TIDSPBRIDGE) || defined(CONFIG_TIDSPBRIDGE_MODULE)
-extern void omap_dsp_reserve_sdram_memblock(void);
-#else
-static inline void omap_dsp_reserve_sdram_memblock(void) { }
-#endif
-
 #endif
Signature · 1 line
1.7.3.1.2.g7fe2b
#5 lore raw

PATCH 2/3 omap: dsp: fix ioremap() usage

Quoted 36 lines

-----Original Message-----
From: linux-omap-owner at vger.kernel.org [mailto:linux-omap-owner at vger.kernel.org] On Behalf Of Felipe Contreras
Sent: Sunday, October 10, 2010 11:11 PM
To: linux-arm; linux-omap; Greg KH
Cc: Ramirez Luna, Omar; Russell King; Felipe Contreras
Subject: [PATCH 2/3] omap: dsp: fix ioremap() usage

On commit 309caa9 doing ioremap() became forbidden due tue architectural
limitations. Only a single mapping is allowed now, so the mempool must not be part of the memory managed by the kernel.

---
 arch/arm/plat-omap/common.c              |   43 
+++++++++++++++++++++++++++--
 arch/arm/plat-omap/devices.c             |   30 ---------------------
 arch/arm/plat-omap/include/plat/common.h |    3 +-
 arch/arm/plat-omap/include/plat/dsp.h    |    6 ----
 4 files changed, 42 insertions(+), 40 deletions(-)
arch/arm/plat-omap/common.c +0 -1
index 57205a4..3fee3ca 100644
@@ -37,7 +37,6 @@
 #include <plat/fpga.h>
 #include <plat/serial.h>
 #include <plat/vram.h>
-#include <plat/dsp.h>
 
 #include <plat/clock.h>
 

arch/arm/plat-omap/common.c const void *omap_get_var_config(u16 tag, · line 87

Quoted 6 lines
arch/arm/plat-omap/common.c +1 -1
@@ -84,11 +83,49 @@ const void *omap_get_var_config(u16 tag, 
 size_t *len)
 }
 EXPORT_SYMBOL(omap_get_var_config);
 
-void __init omap_reserve(void)
+#if defined(CONFIG_TIDSPBRIDGE) || defined(CONFIG_TIDSPBRIDGE_MODULE)

[sp] I do understand that dspbridge is the only driver accessing dsp in
the linux-omap; but there are other known drivers - which would need this feature.

Can we use a more generic config option viz. CONFIG_RESERVE_DSPMEM (or something similar) so that code is easily (re)usable.

~sanjeev

[snip]...[snip]

Quoted 2 lines
arch/arm/plat-omap/common.c +1 -0
+
 
#6 lore raw

PATCH 2/3 omap: dsp: fix ioremap() usage

Hi,

Please remove the chunks you are not replying to.

Quoted 6 lines · Sanjeev

arch/arm/plat-omap/common.c const void *omap_get_var_config(u16 tag, size_t *len) · line 86

Quoted 2 lines
arch/arm/plat-omap/common.c +1 -1
-void __init omap_reserve(void)
+#if defined(CONFIG_TIDSPBRIDGE) || defined(CONFIG_TIDSPBRIDGE_MODULE)

[sp] I do understand that dspbridge is the only driver accessing dsp in ? ? the linux-omap; but there are other known drivers - which would need ? ? this feature.

Are you talking about linux-omap the tree? If so, no, the tidspbridge is part of staging, not linux-omap.

If you are trying to say there are other DSP drivers intended for OMAP, then I guess you are referring to dsp-link, which uses it's own tricks for contiguous memory allocation (CMEM).

So, who and how would benefit from this?

Quoted 2 lines

? ? Can we use a more generic config option viz. CONFIG_RESERVE_DSPMEM ? ? (or something similar) so that code is easily (re)usable.

How about CONFIG_OMAP_DSP, and CONFIG_OMAP_DSP_RESERVE_SIZE?

Signature · 1 line
Felipe Contreras
#7 lore raw

PATCH 2/3 omap: dsp: fix ioremap() usage

In reply to Felipe Contreras
Quoted 49 lines

-----Original Message-----
From: linux-omap-owner at vger.kernel.org [mailto:linux-omap-owner at vger.kernel.org] On Behalf Of Felipe Contreras
Sent: Sunday, October 10, 2010 12:41 PM
To: linux-arm; linux-omap; Greg KH
Cc: Ramirez Luna, Omar; Russell King; Felipe Contreras
Subject: [PATCH 2/3] omap: dsp: fix ioremap() usage

On commit 309caa9 doing ioremap() became forbidden due tue architectural limitations. Only a single mapping is allowed now, so the mempool must not be part of the memory managed by the kernel.

---
 arch/arm/plat-omap/common.c              |   43 
+++++++++++++++++++++++++++--
 arch/arm/plat-omap/devices.c             |   30 ---------------------
 arch/arm/plat-omap/include/plat/common.h |    3 +-
 arch/arm/plat-omap/include/plat/dsp.h    |    6 ----
 4 files changed, 42 insertions(+), 40 deletions(-)
(quoted diff) +0 -0

b/arch/arm/plat-omap/common.c index 57205a4..3fee3ca 100644

arch/arm/plat-omap/common.c +8 -2
@@ -37,7 +37,6 @@
 #include <plat/fpga.h>
 #include <plat/serial.h>
 #include <plat/vram.h>
-#include <plat/dsp.h>
 
 #include <plat/clock.h>
 
@@ -84,11 +83,49 @@ const void *omap_get_var_config(u16 tag, 
 size_t *len)  }  EXPORT_SYMBOL(omap_get_var_config);
 
-void __init omap_reserve(void)
+#if defined(CONFIG_TIDSPBRIDGE) || defined(CONFIG_TIDSPBRIDGE_MODULE)
+
+static phys_addr_t omap_dsp_mempool_base;
+
+static void __init omap_dsp_reserve_mem(struct meminfo *mi) {
+	phys_addr_t size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE;
+	phys_addr_t addr = ~0;
+	int i;

arch/arm/plat-omap/common.c const void *omap_get_var_config(u16 tag, · line 102

Quoted 10 lines
arch/arm/plat-omap/common.c +10 -0
+
+	if (!size)
+		return;
+
+	for (i = mi->nr_banks - 1; i >= 0; i--)
+		if (mi->bank[i].size >= size) {
+			mi->bank[i].size -= size;
+			addr = mi->bank[i].start + mi->bank[i].size;
+			break;
+		}

Missing {} in "for" lopp. Even tough you are checking for success inside For loop why check again outside? And also not need to define addr. What do you think about this:

static void __init omap_dsp_reserve_mem(struct meminfo *mi) {
	phys_addr_t size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE;
	int i;

	if (!size)
		return;

	for (i = mi->nr_banks - 1; i >= 0; i--) {
		if (mi->bank[i].size >= size) {
			mi->bank[i].size -= size;
			omap_dsp_mempool_base = 
				mi->bank[i].start + mi->bank[i].size;
			return;
		}
	}
	pr_err("%s: failed to reserve 0x%x bytes\n", __func__, size);
}

Regards,
Fernando.

Quoted 118 lines
arch/arm/plat-omap/common.c +16 -0
+
+	if (addr == ~0) {
+		pr_err("%s: failed to reserve 0x%x bytes\n",
+				__func__, size);
+		return;
+	}
+
+	omap_dsp_mempool_base = addr;
+}
+
+phys_addr_t omap_dsp_get_mempool_base(void) {
+	return omap_dsp_mempool_base;
+}
+EXPORT_SYMBOL(omap_dsp_get_mempool_base);
+#else
+static inline void omap_dsp_reserve_mem(struct meminfo *mi) 

{ } #endif

arch/arm/plat-omap/common.c +3 -1
+
+void __init omap_reserve(struct meminfo *mi)
 {
 	omapfb_reserve_sdram_memblock();
 	omap_vram_reserve_sdram_memblock();
-	omap_dsp_reserve_sdram_memblock();
+	omap_dsp_reserve_mem(mi);
 }
 
 /*
(quoted diff) +0 -0

b/arch/arm/plat-omap/devices.c index 4c8f9b9..d1920be 100644

arch/arm/plat-omap/devices.c +0 -1
@@ -15,7 +15,6 @@
 #include <linux/platform_device.h>
 #include <linux/io.h>
 #include <linux/slab.h>
-#include <linux/memblock.h>
 
 #include <mach/hardware.h>
 #include <asm/mach-types.h>
@@ -273,35 +272,6 @@ static void omap_init_wdt(void)  static 

inline void omap_init_wdt(void) {} #endif

arch/arm/plat-omap/devices.c +0 -28
-#if defined(CONFIG_TIDSPBRIDGE) || defined(CONFIG_TIDSPBRIDGE_MODULE)
-
-static phys_addr_t omap_dsp_phys_mempool_base;
-
-void __init omap_dsp_reserve_sdram_memblock(void)
-{
-	phys_addr_t size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE;
-	phys_addr_t paddr;
-
-	if (!size)
-		return;
-
-	paddr = __memblock_alloc_base(size, SZ_1M, MEMBLOCK_REAL_LIMIT);
-	if (!paddr) {
-		pr_err("%s: failed to reserve %x bytes\n",
-				__func__, size);
-		return;
-	}
-
-	omap_dsp_phys_mempool_base = paddr;
-}
-
-phys_addr_t omap_dsp_get_mempool_base(void) -{
-	return omap_dsp_phys_mempool_base;
-}
-EXPORT_SYMBOL(omap_dsp_get_mempool_base);
-#endif
-
 /*
  * This gets called after board-specific INIT_MACHINE, and 

initializes most
* on-chip peripherals accessible on this board (except for
few like USB):

arch/arm/plat-omap/include/plat/common.h +2 -1
index 9776b41..3675492 100644
@@ -30,11 +30,12 @@
 #include <plat/i2c.h>
 
 struct sys_timer;
+struct meminfo;
 
 extern void omap_map_common_io(void);
 extern struct sys_timer omap_timer;
 
-extern void omap_reserve(void);
+extern void omap_reserve(struct meminfo *mi);
 
 /*
  * IO bases for various OMAP processors diff --git 

a/arch/arm/plat-omap/include/plat/dsp.h
b/arch/arm/plat-omap/include/plat/dsp.h
index 9c604b3..4e53687 100644

arch/arm/plat-omap/include/plat/dsp.h +0 -6
@@ -22,10 +22,4 @@ struct omap_dsp_platform_data {
 	phys_addr_t phys_mempool_size;
 };
 
-#if defined(CONFIG_TIDSPBRIDGE) || defined(CONFIG_TIDSPBRIDGE_MODULE)
-extern void omap_dsp_reserve_sdram_memblock(void);
-#else
-static inline void omap_dsp_reserve_sdram_memblock(void) { } -#endif
-
 #endif
--

1.7.3.1.2.g7fe2b

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo at vger.kernel.org More majordomo info at
http://vger.kernel.org/majordomo-info.html

#8 lore raw

PATCH 2/3 omap: dsp: fix ioremap() usage

Quoted 14 lines · Fernando
Quoted 14 lines
(quoted diff) +14 -0
+#if defined(CONFIG_TIDSPBRIDGE) || defined(CONFIG_TIDSPBRIDGE_MODULE)
+
+static phys_addr_t omap_dsp_mempool_base;
+
+static void __init omap_dsp_reserve_mem(struct meminfo *mi) {
+ ? ? phys_addr_t size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE;
+ ? ? phys_addr_t addr = ~0;
+ ? ? int i;
+
+ ? ? if (!size)
+ ? ? ? ? ? ? return;
+
+ ? ? for (i = mi->nr_banks - 1; i >= 0; i--)
+ ? ? ? ? ? ? if (mi->bank[i].size >= size) {
Quoted 8 lines
Quoted 4 lines

+ ? ? ? ? ? ? ? ? ? ? mi->bank[i].size -= size;
+ ? ? ? ? ? ? ? ? ? ? addr = mi->bank[i].start + mi->bank[i].size;
+ ? ? ? ? ? ? ? ? ? ? break;
+ ? ? ? ? ? ? }

Missing {} in "for" lopp. Even tough you are checking for success inside For loop why check again outside? And also not need to define addr. What do you think about this:

It comes directly from Russell's code:
http://article.gmane.org/gmane.linux.kernel/1046606

But I do prefer to add the braces. Your proposed patch is ok, although I prefer to have the important code at the end of the function, and the error check before that.

Anyway, Russell has come with a different approach, so I have to try that instead.

Cheers.

Signature · 1 line
Felipe Contreras
#9 lore raw

PATCH 3/3 staging: tidspbridge: remove memory consistency from TODO list

In reply to Felipe Contreras

The mempool area is not handled by the kernel any more.

---
 drivers/staging/tidspbridge/TODO |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
drivers/staging/tidspbridge/TODO +0 -1
index 187363f..54f4a29 100644
@@ -13,7 +13,6 @@
 * Audit and clean up header files folder
 * Use kernel coding style
 * checkpatch.pl fixes
-* allocate ext_mem_pool from consistent memory instead of using ioremap
 
 Please send any patches to Greg Kroah-Hartman <[email protected]>
 and Omar Ramirez Luna <[email protected]>.
Signature · 1 line
1.7.3.1.2.g7fe2b
#10 lore raw

PATCH 3/3 staging: tidspbridge: remove memory consistency from TODO list

Quoted 1 line · Felipe Contreras

The mempool area is not handled by the kernel any more.

But tidspbridge still uses ioremap to set up the mapping for RAM, even though it now is outside of the kernel linar mapping.

You should really only use ioremap on MMIO registers, nothing else. These registers are marked as __iomem pointers and can only be passed into functions that talk to the hardware like iowrite32 or writel, but not used like memory.

Please have a look at "sparse", which will warn about address space violations among other things. The tidspbridge driver is full of them, and you should fix the code that sparse warns about, which will also show you all the places where ioremap is used incorrectly.

Arnd

#11 lore raw

PATCH 3/3 staging: tidspbridge: remove memory consistency from TODO list

Quoted 5 lines · Arnd Bergmann
Quoted 1 line · Felipe Contreras

The mempool area is not handled by the kernel any more.

But tidspbridge still uses ioremap to set up the mapping for RAM, even though it now is outside of the kernel linar mapping.

Which is what ioremap() complained about, and how Russell King suggested to solve the issue.

Quoted 7 lines

You should really only use ioremap on MMIO registers, nothing else. These registers are marked as __iomem pointers and can only be passed into functions that talk to the hardware like iowrite32 or writel, but not used like memory.

From [email protected] Sat Oct 9 07:11:57 2010

From: [email protected] ()
Date: Sat, 09 Oct 2010 11:11:57 -0000
Subject: No subject
Message-ID: <[email protected]>

Quoted 4 lines

Please have a look at "sparse", which will warn about address space violations among other things. The tidspbridge driver is full of them, and you should fix the code that sparse warns about, which will also show you all the places where ioremap is used incorrectly.

In one of my branches I moved ioremap() to arch/arm/mach-omap2/dsp.c and if I use sparse there, it gives no warning.

I would prefer to map the memory some other way and make it non-cacheable, but I don't know any other way. Then, if readl/writel are still needed, only ioremap() that area. And finally, and hopefully, do cache flushes instead of requiring consistent memory.

Cheers.

Signature · 1 line
Felipe Contreras
#12 lore raw

PATCH 3/3 staging: tidspbridge: remove memory consistency from TODO list

Quoted 9 lines · Felipe Contreras
Quoted 5 lines · Arnd Bergmann
Quoted 1 line · Felipe Contreras

The mempool area is not handled by the kernel any more.

But tidspbridge still uses ioremap to set up the mapping for RAM, even though it now is outside of the kernel linar mapping.

Which is what ioremap() complained about, and how Russell King suggested to solve the issue.

You are right that this is what Russell asked about, having a single mapping for memory means that you avoid the problems that the warning was put there for and you no longer risk memory corruption. That is good and the changes you did are the important ones.

What I'm arguing is that you still don't use the interface in the way it's designed and things might break again in the future. For instance, I've seen platforms where readl/writel is not a pointer dereference but a hypercall or goes through an indirect index/data register pair. I hope we don't ever get something like this on ARM, but it would still be good to write the code in a more robust way that doesn't mix __iomem tokens with kernel pointers.

Quoted 6 lines
Quoted 4 lines

You should really only use ioremap on MMIO registers, nothing else. These registers are marked as __iomem pointers and can only be passed into functions that talk to the hardware like iowrite32 or writel, but not used like memory.

From what I can see parts of this memory are also used for readl/writel.

In that case, it's worse than I thought ;-)

If you use readl(), it needs to be an __iomem pointer, if you use it by direct dereferences, it must not be __iomem.

Obviously, you need to use ioremap to target the device registers, but I don't see how it could make sense for a communication area in memory.

Quoted 7 lines
Quoted 4 lines

Please have a look at "sparse", which will warn about address space violations among other things. The tidspbridge driver is full of them, and you should fix the code that sparse warns about, which will also show you all the places where ioremap is used incorrectly.

In one of my branches I moved ioremap() to arch/arm/mach-omap2/dsp.c and if I use sparse there, it gives no warning.

I don't see how moving the code around would get rid of an address space warning, unless you play dirty tricks like using __force casts or passing pointers around as integers.

Quoted 4 lines

I would prefer to map the memory some other way and make it non-cacheable, but I don't know any other way. Then, if readl/writel are still needed, only ioremap() that area. And finally, and hopefully, do cache flushes instead of requiring consistent memory.

Yes, that sounds reasonable. Can you use a chunk of regular kernel memory with dma_map_single/dma_sync_single_for_{cpu,device} for this, like normal drivers do?

Arnd