Linux MIPS Architecture development
 help / color / mirror / Atom feed
* Correct way to set coherent_dma_mask on a non-pci device?
@ 2008-07-08 17:40 Steve Brown
  2008-07-08 17:55 ` Michael Buesch
  0 siblings, 1 reply; 3+ messages in thread
From: Steve Brown @ 2008-07-08 17:40 UTC (permalink / raw)
  To: linux-mips; +Cc: Michael Buesch

There appears to be no function like pci_set_consistent_dma_mask to set 
the coherent mask for a non-pci device.

What is the "proper" way to set it?

The context for the question is a recent change to ssb_dma_set_mask() in 
drivers/ssb/main.c that removed the somewhat fragile, direct 
manipulation of dma_mask and coherent_dma_mask in favor of a call to 
dma_set_mask().

Thanks,
Steve

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Correct way to set coherent_dma_mask on a non-pci device?
  2008-07-08 17:40 Correct way to set coherent_dma_mask on a non-pci device? Steve Brown
@ 2008-07-08 17:55 ` Michael Buesch
  2008-07-10 17:38   ` Steve Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Buesch @ 2008-07-08 17:55 UTC (permalink / raw)
  To: sbrown; +Cc: linux-mips

On Tuesday 08 July 2008 19:40:06 Steve Brown wrote:
> There appears to be no function like pci_set_consistent_dma_mask to set 
> the coherent mask for a non-pci device.
> 
> What is the "proper" way to set it?
> 
> The context for the question is a recent change to ssb_dma_set_mask() in 
> drivers/ssb/main.c that removed the somewhat fragile, direct 
> manipulation of dma_mask and coherent_dma_mask in favor of a call to 
> dma_set_mask().

Note that SSB devices use the dma_*** API for doing DMA remappings.
So it uses dma_set_mask() for setting the mask.

-- 
Greetings Michael.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Correct way to set coherent_dma_mask on a non-pci device?
  2008-07-08 17:55 ` Michael Buesch
@ 2008-07-10 17:38   ` Steve Brown
  0 siblings, 0 replies; 3+ messages in thread
From: Steve Brown @ 2008-07-10 17:38 UTC (permalink / raw)
  To: linux-mips; +Cc: Michael Buesch

[-- Attachment #1: Type: text/plain, Size: 876 bytes --]

Michael Buesch wrote:
> On Tuesday 08 July 2008 19:40:06 Steve Brown wrote:
>   
>> There appears to be no function like pci_set_consistent_dma_mask to set 
>> the coherent mask for a non-pci device.
>>
>> What is the "proper" way to set it?
>>
>> The context for the question is a recent change to ssb_dma_set_mask() in 
>> drivers/ssb/main.c that removed the somewhat fragile, direct 
>> manipulation of dma_mask and coherent_dma_mask in favor of a call to 
>> dma_set_mask().
>>     
>
> Note that SSB devices use the dma_*** API for doing DMA remappings.
> So it uses dma_set_mask() for setting the mask.
>
>   
I can't find any dma_*** routine that references coherent_dma_mask. It 
looks like dma_set_mask() doesn't handle the case where the device 
doesn't support coherent dma (CONFIG_DMA_NONCOHERENT=y).

Would this be the correct patch to handle that case?
 
Steve


[-- Attachment #2: 170-dma_set_mask.patch --]
[-- Type: text/plain, Size: 860 bytes --]

diff --git a/include/asm-mips/dma-mapping.h b/include/asm-mips/dma-mapping.h
index 230b3f1..8da4107 100644
--- a/include/asm-mips/dma-mapping.h
+++ b/include/asm-mips/dma-mapping.h
@@ -1,8 +1,9 @@
 #ifndef _ASM_DMA_MAPPING_H
 #define _ASM_DMA_MAPPING_H
 
-#include <asm/scatterlist.h>
+#include <linux/scatterlist.h>
 #include <asm/cache.h>
+#include <dma-coherence.h>
 
 void *dma_alloc_noncoherent(struct device *dev, size_t size,
 			   dma_addr_t *dma_handle, gfp_t flag);
@@ -48,7 +49,11 @@ extern int dma_supported(struct device *dev, u64 mask);
 static inline int
 dma_set_mask(struct device *dev, u64 mask)
 {
-	if(!dev->dma_mask || !dma_supported(dev, mask))
+	if(!dma_supported(dev, mask))
+		return -EIO;
+	if(!plat_device_is_coherent(dev))
+		dev->dma_mask = &dev->coherent_dma_mask;
+	if(!dev->dma_mask)
 		return -EIO;
 
 	*dev->dma_mask = mask;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-07-10 17:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-08 17:40 Correct way to set coherent_dma_mask on a non-pci device? Steve Brown
2008-07-08 17:55 ` Michael Buesch
2008-07-10 17:38   ` Steve Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox