Skip to contentSkip to conversation

of: set dma_mask to point to coherent_dma_mask

PATCH In review Rob Herring 4 participants 7 messages Oct 30, 2013 – Nov 12, 2013 Device tree

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 of: set dma_mask to point to coherent_dma_mask

From: Rob Herring <[email protected]>

Platform devices created by DT code don't initialize dma_mask pointer to anything. Set it to coherent_dma_mask by default if the architecture code has not set it.

---
I think this is at least part of what is needed to fix dma_mask issue raised by Stefano [1]. Things should work AFAICT with just this, but I suppose the xgmac driver needs to set the mask as well (not relying on the default), but some pointing the dma_mask to a valid value is needed first.

Rob

[1] http://www.mail-archive.com/[email protected]/msg528236.html

 drivers/of/platform.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/of/platform.c +2 -0
index f6dcde2..fce088e 100644
@@ -215,6 +215,8 @@ static struct platform_device *of_platform_device_create_pdata(
 	dev->archdata.dma_mask = 0xffffffffUL;
 #endif
 	dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
+	if (!dev->dev.dma_mask)
+		dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
 	dev->dev.bus = &platform_bus_type;
 	dev->dev.platform_data = platform_data;
 
Signature · 1 line
1.8.1.2
#1 lore raw
Quoted 7 lines · Rob Herring

From: Rob Herring <[email protected]>

Platform devices created by DT code don't initialize dma_mask pointer to anything. Set it to coherent_dma_mask by default if the architecture code has not set it.

I believe this is okay. I haven't done any testing to back up that opinion though.

g.

Quoted 30 lines

---
I think this is at least part of what is needed to fix dma_mask issue raised by Stefano [1]. Things should work AFAICT with just this, but I suppose the xgmac driver needs to set the mask as well (not relying on the default), but some pointing the dma_mask to a valid value is needed first.

Rob

[1] http://www.mail-archive.com/[email protected]/msg528236.html

 drivers/of/platform.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/of/platform.c +2 -0
index f6dcde2..fce088e 100644
@@ -215,6 +215,8 @@ static struct platform_device *of_platform_device_create_pdata(
 	dev->archdata.dma_mask = 0xffffffffUL;
 #endif
 	dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
+	if (!dev->dev.dma_mask)
+		dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
 	dev->dev.bus = &platform_bus_type;
 	dev->dev.platform_data = platform_data;
 
Signature · 1 line
1.8.1.2
#2 lore raw
Quoted 11 lines · Grant Likely
Quoted 7 lines · Rob Herring

From: Rob Herring <rob.herring-bsGFqQB8/[email protected]>

Platform devices created by DT code don't initialize dma_mask pointer to anything. Set it to coherent_dma_mask by default if the architecture code has not set it.

I believe this is okay. I haven't done any testing to back up that opinion though.

Quoted 13 lines
Quoted 13 lines

I think this is at least part of what is needed to fix dma_mask issue raised by Stefano [1]. Things should work AFAICT with just this, but I suppose the xgmac driver needs to set the mask as well (not relying on the default), but some pointing the dma_mask to a valid value is needed first.

Rob

[1] http://www.mail-archive.com/[email protected]/msg528236.html

 drivers/of/platform.c | 2 ++
 1 file changed, 2 insertions(+)
Quoted 13 lines

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

Quoted 13 lines
drivers/of/platform.c +2 -0
index f6dcde2..fce088e 100644
@@ -215,6 +215,8 @@ static struct platform_device *of_platform_device_create_pdata(
 	dev->archdata.dma_mask = 0xffffffffUL;
 #endif
 	dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
+	if (!dev->dev.dma_mask)
+		dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
 	dev->dev.bus = &platform_bus_type;
 	dev->dev.platform_data = platform_data;
 

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

#3 lore raw
Quoted 8 lines · Stefano Stabellini
Quoted 7 lines · Grant Likely
Quoted 6 lines · Rob Herring

From: Rob Herring <rob.herring-bsGFqQB8/[email protected]>

Platform devices created by DT code don't initialize dma_mask pointer to anything. Set it to coherent_dma_mask by default if the architecture code has not set it.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

I believe this is okay. I haven't done any testing to back up that opinion though.

BTW I hope you are planning on sending this upstream soon, because without it I can very easily corrupt my root fs by simply booting the system.

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

I think this is at least part of what is needed to fix dma_mask issue raised by Stefano [1]. Things should work AFAICT with just this, but I suppose the xgmac driver needs to set the mask as well (not relying on the default), but some pointing the dma_mask to a valid value is needed first.

Rob

[1] http://www.mail-archive.com/[email protected]/msg528236.html

 drivers/of/platform.c | 2 ++
 1 file changed, 2 insertions(+)
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
drivers/of/platform.c +0 -0
index f6dcde2..fce088e 100644
@@ -215,6 +215,8 @@ static struct platform_device *of_platform_device_create_pdata(
Quoted 8 lines

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

Quoted 8 lines
drivers/of/platform.c +2 -0
 	dev->archdata.dma_mask = 0xffffffffUL;
 #endif
 	dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
+	if (!dev->dev.dma_mask)
+		dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
 	dev->dev.bus = &platform_bus_type;
 	dev->dev.platform_data = platform_data;
 

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

#4 lore raw
Quoted 11 lines · Stefano Stabellini
Quoted 10 lines · Stefano Stabellini
Quoted 9 lines · Grant Likely
Quoted 7 lines · Rob Herring

From: Rob Herring <rob.herring-bsGFqQB8/[email protected]>

Platform devices created by DT code don't initialize dma_mask pointer to anything. Set it to coherent_dma_mask by default if the architecture code has not set it.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

I believe this is okay. I haven't done any testing to back up that opinion though.

BTW I hope you are planning on sending this upstream soon, because without it I can very easily corrupt my root fs by simply booting the system.

Gah! That's pretty nasty. It is in Rob's for-next branch, but it hasn't
been marked for backporting to stable. Best thing to do here is for
either you or Rob to repost the patch to [email protected] and include the commit id from Rob's tree. It's not upstream yet, but it
will be soon.

How far back in kernel releases do you want the patch backported to?

g.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
In reply to Stefano Stabellini
Quoted 11 lines · Stefano Stabellini
Quoted 10 lines · Stefano Stabellini
Quoted 9 lines · Grant Likely
Quoted 7 lines · Rob Herring

From: Rob Herring <rob.herring-bsGFqQB8/[email protected]>

Platform devices created by DT code don't initialize dma_mask pointer to anything. Set it to coherent_dma_mask by default if the architecture code has not set it.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

I believe this is okay. I haven't done any testing to back up that opinion though.

BTW I hope you are planning on sending this upstream soon, because without it I can very easily corrupt my root fs by simply booting the system.

What's the mechanism for that corruption? Having the DMA mask not set should not cause DMA corruption - that hints at something else being wrong, and that needs to be investigated.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
Quoted 15 lines · Russell King - ARM Linux
Quoted 14 lines · Stefano Stabellini
Quoted 13 lines · Stefano Stabellini
Quoted 11 lines · Grant Likely
Quoted 7 lines · Rob Herring

From: Rob Herring <rob.herring-bsGFqQB8/[email protected]>

Platform devices created by DT code don't initialize dma_mask pointer to anything. Set it to coherent_dma_mask by default if the architecture code has not set it.

I believe this is okay. I haven't done any testing to back up that opinion though.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

BTW I hope you are planning on sending this upstream soon, because without it I can very easily corrupt my root fs by simply booting the system.

What's the mechanism for that corruption? Having the DMA mask not set should not cause DMA corruption - that hints at something else being wrong, and that needs to be investigated.

Russell, you are right.
I went through the swiotlb-xen code and I realized that I missed a map_page call on one of the (usually unused) fallback paths. Thanks!!
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html