Skip to contentSkip to conversation

of/address: Add of_iomap_nocache

PATCH Superseded David Brown 6 participants 12 messages Aug 4, 2011

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

PATCH 1/1 of/address: Add of_iomap_nocache

Add uncached mappings from devicetree nodes similar to regular io mappings.

---
 drivers/of/address.c       |   19 +++++++++++++++++++
 include/linux/of_address.h |    1 +
 2 files changed, 20 insertions(+), 0 deletions(-)
drivers/of/address.c +19 -0
index 72c33fb..9bee7f8 100644
@@ -613,3 +613,22 @@ void __iomem *of_iomap(struct device_node *np, int index)
 	return ioremap(res.start, resource_size(&res));
 }
 EXPORT_SYMBOL(of_iomap);
+
+/**
+ * of_iomap_nocache - Maps the memory mapped IO for a given
+ *                    device_node, using ioremap_nocache.
+ * @device:	the device whose io range will be mapped
+ * @index:	index of the io range
+ *
+ * Returns a pointer to the mapped memory
+ */
+void __iomem *of_iomap_nocache(struct device_node *np, int index)
+{
+	struct resource res;
+
+	if (of_address_to_resource(np, index, &res))
+		return NULL;
+
+	return ioremap_nocache(res.start, 1 + res.end - res.start);
+}
+EXPORT_SYMBOL(of_iomap_nocache);
include/linux/of_address.h +1 -0
index 3118623..3ce1277 100644
@@ -12,6 +12,7 @@ extern struct device_node *of_find_matching_node_by_address(
 					const struct of_device_id *matches,
 					u64 base_address);
 extern void __iomem *of_iomap(struct device_node *device, int index);
+extern void __iomem *of_iomap_nocache(struct device_node *device, int index);
 
 /* Extract an address from a device, returns the region size and
  * the address space flags too. The PCI version uses a BAR number
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#2 lore raw
Quoted 9 lines · David Miller

From: David Brown <[email protected]>
Date: Thu, 4 Aug 2011 02:53:49 -0700

Quoted 4 lines

Add uncached mappings from devicetree nodes similar to regular io mappings.

You'll need to add a sparc implementation.

Sparc just defines ioremap_nocache to ioremap, so is that really needed?

Rob

#3 lore raw
Quoted 4 lines · Rob Herring
Quoted 3 lines · David Miller

From: David Brown <[email protected]>
Date: Thu, 4 Aug 2011 02:53:49 -0700

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Add uncached mappings from devicetree nodes similar to regular io mappings.

You'll need to add a sparc implementation.

Sparc just defines ioremap_nocache to ioremap, so is that really needed?

The first version of my patch only defines the new function in a file compiled on non-SPARC targets.

David

Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#4 lore raw
In reply to Rob Herring

From: Rob Herring <[email protected]>
Date: Thu, 04 Aug 2011 10:52:58 -0500

Quoted 12 lines · David Miller
Quoted 9 lines

From: David Brown <[email protected]>
Date: Thu, 4 Aug 2011 02:53:49 -0700

Quoted 4 lines

Add uncached mappings from devicetree nodes similar to regular io mappings.

You'll need to add a sparc implementation.

Sparc just defines ioremap_nocache to ioremap, so is that really needed?

Yes because if someone uses this of_iomap_nocache() in a driver the sparc build is going to fail, we need as least the define to make it equal to of_iomap() as David did in his follow-on patch.

#5 lore raw

PATCH v2 1/1 of/address: Add of_iomap_nocache

In reply to David Brown

Add uncached mappings from devicetree nodes similar to regular io mappings.

SPARC is coherent, so there this call is the same as regular of_iomap.

---
v2 - Add implementation for SPARC

 drivers/of/address.c       |   19 +++++++++++++++++++
 include/linux/of_address.h |   10 ++++++++++
 2 files changed, 29 insertions(+), 0 deletions(-)
drivers/of/address.c +19 -0
index 72c33fb..9bee7f8 100644
@@ -613,3 +613,22 @@ void __iomem *of_iomap(struct device_node *np, int index)
 	return ioremap(res.start, resource_size(&res));
 }
 EXPORT_SYMBOL(of_iomap);
+
+/**
+ * of_iomap_nocache - Maps the memory mapped IO for a given
+ *                    device_node, using ioremap_nocache.
+ * @device:	the device whose io range will be mapped
+ * @index:	index of the io range
+ *
+ * Returns a pointer to the mapped memory
+ */
+void __iomem *of_iomap_nocache(struct device_node *np, int index)
+{
+	struct resource res;
+
+	if (of_address_to_resource(np, index, &res))
+		return NULL;
+
+	return ioremap_nocache(res.start, 1 + res.end - res.start);
+}
+EXPORT_SYMBOL(of_iomap_nocache);
include/linux/of_address.h +10 -0
index 3118623..0e4734b 100644
@@ -13,6 +13,16 @@ extern struct device_node *of_find_matching_node_by_address(
 					u64 base_address);
 extern void __iomem *of_iomap(struct device_node *device, int index);
 
+#ifndef SPARC
+extern void __iomem *of_iomap_nocache(struct device_node *device, int index);
+#else
+static inline void __iomem *of_iomap_nocache(struct device_node *device,
+		int index)
+{
+	return of_iomap(device, index);
+}
+#endif
+
 /* Extract an address from a device, returns the region size and
  * the address space flags too. The PCI version uses a BAR number
  * instead of an absolute index
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#7 lore raw
Quoted 6 lines · David Miller

From: David Brown <[email protected]>
Date: Thu,  4 Aug 2011 03:36:36 -0700

Quoted 3 lines

Add uncached mappings from devicetree nodes similar to regular io mappings.

Quoted 6 lines
Quoted 4 lines

SPARC is coherent, so there this call is the same as regular of_iomap.

Okay, I'll pick it up when I see patches that use it.

g.

#8 lore raw
In reply to David Brown
Quoted 49 lines · David Brown

Add uncached mappings from devicetree nodes similar to regular io mappings.

SPARC is coherent, so there this call is the same as regular of_iomap.

---
v2 - Add implementation for SPARC

drivers/of/address.c       |   19 +++++++++++++++++++
include/linux/of_address.h |   10 ++++++++++
2 files changed, 29 insertions(+), 0 deletions(-)
drivers/of/address.c +19 -0
index 72c33fb..9bee7f8 100644
@@ -613,3 +613,22 @@ void __iomem *of_iomap(struct device_node *np, int index)
 	return ioremap(res.start, resource_size(&res));
 }
 EXPORT_SYMBOL(of_iomap);
+
+/**
+ * of_iomap_nocache - Maps the memory mapped IO for a given
+ *                    device_node, using ioremap_nocache.
+ * @device:	the device whose io range will be mapped
+ * @index:	index of the io range
+ *
+ * Returns a pointer to the mapped memory
+ */
+void __iomem *of_iomap_nocache(struct device_node *np, int index)
+{
+	struct resource res;
+
+	if (of_address_to_resource(np, index, &res))
+		return NULL;
+
+	return ioremap_nocache(res.start, 1 + res.end - res.start);
+}
+EXPORT_SYMBOL(of_iomap_nocache);
include/linux/of_address.h +0 -0
index 3118623..0e4734b 100644
@@ -13,6 +13,16 @@ extern struct device_node *of_find_matching_node_by_address(
 					u64 base_address);
 extern void __iomem *of_iomap(struct device_node *device, int index);
 

include/linux/of_address.h extern struct device_node *of_find_matching_node_by_address( · line 25

Quoted 10 lines
include/linux/of_address.h +10 -0
+#ifndef SPARC
+extern void __iomem *of_iomap_nocache(struct device_node *device, int index);
+#else
+static inline void __iomem *of_iomap_nocache(struct device_node *device,
+		int index)
+{
+	return of_iomap(device, index);
+}
+#endif
+

What about adding an of_iomap_prot() to match ioremap_prot().

- k

#9 lore raw
Quoted 11 lines · Kumar Gala
Quoted 6 lines · David Brown

Add uncached mappings from devicetree nodes similar to regular io mappings.

SPARC is coherent, so there this call is the same as regular of_iomap.

+extern void __iomem *of_iomap_nocache(struct device_node *device, int index);

What about adding an of_iomap_prot() to match ioremap_prot().

It can be done, but I actually have a use for nocache. We can probably add the prot version when first needed.

David

Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#10 lore raw
In reply to David Brown
Quoted 30 lines · David Brown

Add uncached mappings from devicetree nodes similar to regular io mappings.

SPARC is coherent, so there this call is the same as regular of_iomap.

---
v2 - Add implementation for SPARC

  drivers/of/address.c       |   19 +++++++++++++++++++
  include/linux/of_address.h |   10 ++++++++++
  2 files changed, 29 insertions(+), 0 deletions(-)
drivers/of/address.c +8 -0
index 72c33fb..9bee7f8 100644
@@ -613,3 +613,22 @@ void __iomem *of_iomap(struct device_node *np, int index)
  	return ioremap(res.start, resource_size(&res));
  }
  EXPORT_SYMBOL(of_iomap);
+
+/**
+ * of_iomap_nocache - Maps the memory mapped IO for a given
+ *                    device_node, using ioremap_nocache.
+ * @device:	the device whose io range will be mapped
+ * @index:	index of the io range
+ *
+ * Returns a pointer to the mapped memory

drivers/of/address.c void __iomem *of_iomap(struct device_node *np, int index) · line 633

Quoted 10 lines
drivers/of/address.c +10 -0
+ */
+void __iomem *of_iomap_nocache(struct device_node *np, int index)
+{
+	struct resource res;
+
+	if (of_address_to_resource(np, index,&res))
+		return NULL;
+
+	return ioremap_nocache(res.start, 1 + res.end - res.start);
+}

resource_size()?

Quoted 8 lines
drivers/of/address.c +1 -0
+EXPORT_SYMBOL(of_iomap_nocache);
include/linux/of_address.h +0 -0
index 3118623..0e4734b 100644
@@ -13,6 +13,16 @@ extern struct device_node *of_find_matching_node_by_address(
  					u64 base_address);
  extern void __iomem *of_iomap(struct device_node *device, int index);

include/linux/of_address.h extern struct device_node *of_find_matching_node_by_address( · line 24

Quoted 10 lines
include/linux/of_address.h +9 -0
 
+#ifndef SPARC
+extern void __iomem *of_iomap_nocache(struct device_node *device, int index);
+#else
+static inline void __iomem *of_iomap_nocache(struct device_node *device,
+		int index)
+{
+	return of_iomap(device, index);
+}
+#endif

Why is sparc special? It looks like it defines ioremap_nocache() as ioremap() just like powerpc and some others, so shouldn't the normal of_iomap_nocache just work?

-Scott

#11 lore raw
Quoted 6 lines · Scott Wood
Quoted 6 lines
(quoted diff) +2 -0
+#ifndef SPARC
+extern void __iomem *of_iomap_nocache(struct device_node *device, int

index);

include/linux/of_address.h +3 -0
+#else
+static inline void __iomem *of_iomap_nocache(struct device_node *device,
+               int index)
Quoted 8 lines

include/linux/of_address.h extern struct device_node *of_find_matching_node_by_address( · line 24

Quoted 4 lines
include/linux/of_address.h +4 -0
+{
+       return of_iomap(device, index);
+}
+#endif

Why is sparc special?  It looks like it defines ioremap_nocache() as ioremap() just like powerpc and some others, so shouldn't the normal of_iomap_nocache just work?

No, the implementation is completely different. SPARC preparses all the reg properties. Everyone else does not.

g.