Skip to contentSkip to conversation

of: Set the DMA mask to 64 bits when dma_addr_t is 64-bits

PATCH Superseded Laura Abbott 2 participants 3 messages Apr 26, 2013 Device tree

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 of: Set the DMA mask to 64 bits when dma_addr_t is 64-bits

Currently, of_platform_device_create_pdata always sets the coherent DMA mask to 32 bits. On ARM systems without CONFIG_ZONE_DMA, arm_dma_limit gets set to ~0 or 0xFFFFFFFFFFFFFFFF on LPAE based systems. Since arm_dma_limit represents the smallest dma_mask on the system, the default of 32 bits prevents any dma_coherent allocation from succeeding unless clients manually set the dma mask first. Rather than make every client on an LPAE system set the mask, set the mask to a 64 bit value on systems with 64-bit dma addresses.

---
 drivers/of/platform.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/of/platform.c +4 -0
index 0970505..c669ab4 100644
@@ -214,7 +214,11 @@ struct platform_device *of_platform_device_create_pdata(
 #if defined(CONFIG_MICROBLAZE)
 	dev->archdata.dma_mask = 0xffffffffUL;
 #endif
+#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
+	dev->dev.coherent_dma_mask = DMA_BIT_MASK(64);
+#else
 	dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
+#endif
 	dev->dev.bus = &platform_bus_type;
 	dev->dev.platform_data = platform_data;
 
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#1 lore raw

PATCH v2 1/1 of: Set the DMA mask to 64 bits when dma_addr_t is 64-bits

Quoted 20 lines · Laura Abbott

Currently, of_platform_device_create_pdata always sets the coherent DMA mask to 32 bits. On ARM systems without CONFIG_ZONE_DMA, arm_dma_limit gets set to ~0 or 0xFFFFFFFFFFFFFFFF on LPAE based systems. Since arm_dma_limit represents the smallest dma_mask on the system, the default of 32 bits prevents any dma_coherent allocation from succeeding unless clients manually set the dma mask first. Rather than make every client on an LPAE system set the mask, set the mask to a 64 bit value on systems with 64-bit dma addresses.

---
 drivers/of/platform.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/of/platform.c +0 -0
index 0970505..c669ab4 100644

drivers/of/platform.c struct platform_device *of_platform_device_create_pdata( · line 221

Quoted 8 lines
drivers/of/platform.c +4 -0
@@ -214,7 +214,11 @@ struct platform_device *of_platform_device_create_pdata(
 #if defined(CONFIG_MICROBLAZE)
 	dev->archdata.dma_mask = 0xffffffffUL;
 #endif
+#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
+	dev->dev.coherent_dma_mask = DMA_BIT_MASK(64);
+#else
 	dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
+#endif

How about "DMA_BIT_MASK(sizeof(dma_addr_t) * 8))" and avoid the ifdef.

Rob

#2 lore raw

PATCH v2 1/1 of: Set the DMA mask to 64 bits when dma_addr_t is 64-bits

Quoted 16 lines · Rob Herring
Quoted 15 lines · Laura Abbott

Currently, of_platform_device_create_pdata always sets the coherent DMA mask to 32 bits. On ARM systems without CONFIG_ZONE_DMA, arm_dma_limit gets set to ~0 or 0xFFFFFFFFFFFFFFFF on LPAE based systems. Since arm_dma_limit represents the smallest dma_mask on the system, the default of 32 bits prevents any dma_coherent allocation from succeeding unless clients manually set the dma mask first. Rather than make every client on an LPAE system set the mask, set the mask to a 64 bit value on systems with 64-bit dma addresses.

---
  drivers/of/platform.c |    4 ++++
  1 files changed, 4 insertions(+), 0 deletions(-)
Quoted 16 lines

drivers/of/platform.c struct platform_device *of_platform_device_create_pdata( · line 221

Quoted 13 lines
drivers/of/platform.c +4 -0
index 0970505..c669ab4 100644
@@ -214,7 +214,11 @@ struct platform_device *of_platform_device_create_pdata(
  #if defined(CONFIG_MICROBLAZE)
  	dev->archdata.dma_mask = 0xffffffffUL;
  #endif
+#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
+	dev->dev.coherent_dma_mask = DMA_BIT_MASK(64);
+#else
  	dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
+#endif

How about "DMA_BIT_MASK(sizeof(dma_addr_t) * 8))" and avoid the ifdef.

Sounds good.

Quoted 2 lines

Rob

Thanks,
Laura

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation