Skip to contentSkip to conversation

sparc: set a default 32-bit dma mask for OF devices

PATCH In review Christoph Hellwig 2 participants 2 messages Sep 1, 2018 1 message not in the archive SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 sparc: set a default 32-bit dma mask for OF devices

This keeps the historic default behavior for devices without a DMA mask, but removes the warning about a lacking DMA mask for doing DMA without a mask.

---

Had to redo this because the platform_device patch that the previous version dependend on had to be dropped.

 arch/sparc/kernel/of_device_32.c | 4 ++++
 arch/sparc/kernel/of_device_64.c | 3 +++
 2 files changed, 7 insertions(+)
arch/sparc/kernel/of_device_32.c +4 -0
index 3641a294ed54..e4abe9b8f97a 100644
@@ -9,6 +9,7 @@
 #include <linux/irq.h>
 #include <linux/of_device.h>
 #include <linux/of_platform.h>
+#include <linux/dma-mapping.h>
 #include <asm/leon.h>
 #include <asm/leon_amba.h>
 
@@ -381,6 +382,9 @@ static struct platform_device * __init scan_one_device(struct device_node *dp,
 	else
 		dev_set_name(&op->dev, "%08x", dp->phandle);
 
+	op->dev.coherent_dma_mask = DMA_BIT_MASK(32);
+	op->dev.dma_mask = &op->dev.coherent_dma_mask;
+
 	if (of_device_register(op)) {
 		printk("%s: Could not register of device.\n",
 		       dp->full_name);
arch/sparc/kernel/of_device_64.c +3 -0
index 44e4d4435bed..6df6086968c6 100644
@@ -2,6 +2,7 @@
 #include <linux/string.h>
 #include <linux/kernel.h>
 #include <linux/of.h>
+#include <linux/dma-mapping.h>
 #include <linux/init.h>
 #include <linux/export.h>
 #include <linux/mod_devicetable.h>
@@ -675,6 +676,8 @@ static struct platform_device * __init scan_one_device(struct device_node *dp,
 		dev_set_name(&op->dev, "root");
 	else
 		dev_set_name(&op->dev, "%08x", dp->phandle);
+	op->dev.coherent_dma_mask = DMA_BIT_MASK(32);
+	op->dev.dma_mask = &op->dev.coherent_dma_mask;
 
 	if (of_device_register(op)) {
 		printk("%s: Could not register of device.\n",
Signature · 1 line
2.18.0

A message that is not in the archive (sent off-list or not yet received): [email protected]

Tested-by
#2 lore raw
Quoted 6 lines · Christoph Hellwig

This keeps the historic default behavior for devices without a DMA mask, but removes the warning about a lacking DMA mask for doing DMA without a mask.

Quoted 53 lines

---

Had to redo this because the platform_device patch that the previous version dependend on had to be dropped.

  arch/sparc/kernel/of_device_32.c | 4 ++++
  arch/sparc/kernel/of_device_64.c | 3 +++
  2 files changed, 7 insertions(+)
arch/sparc/kernel/of_device_32.c +4 -0
index 3641a294ed54..e4abe9b8f97a 100644
@@ -9,6 +9,7 @@
  #include <linux/irq.h>
  #include <linux/of_device.h>
  #include <linux/of_platform.h>
+#include <linux/dma-mapping.h>
  #include <asm/leon.h>
  #include <asm/leon_amba.h>
 
@@ -381,6 +382,9 @@ static struct platform_device * __init scan_one_device(struct device_node *dp,
  	else
  		dev_set_name(&op->dev, "%08x", dp->phandle);
 
+	op->dev.coherent_dma_mask = DMA_BIT_MASK(32);
+	op->dev.dma_mask = &op->dev.coherent_dma_mask;
+
  	if (of_device_register(op)) {
  		printk("%s: Could not register of device.\n",
  		       dp->full_name);
arch/sparc/kernel/of_device_64.c +3 -0
index 44e4d4435bed..6df6086968c6 100644
@@ -2,6 +2,7 @@
  #include <linux/string.h>
  #include <linux/kernel.h>
  #include <linux/of.h>
+#include <linux/dma-mapping.h>
  #include <linux/init.h>
  #include <linux/export.h>
  #include <linux/mod_devicetable.h>
@@ -675,6 +676,8 @@ static struct platform_device * __init scan_one_device(struct device_node *dp,
  		dev_set_name(&op->dev, "root");
  	else
  		dev_set_name(&op->dev, "%08x", dp->phandle);
+	op->dev.coherent_dma_mask = DMA_BIT_MASK(32);
+	op->dev.dma_mask = &op->dev.coherent_dma_mask;
 
  	if (of_device_register(op)) {
  		printk("%s: Could not register of device.\n",