All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][MIPS] add DMA declare coherent memory support
@ 2009-11-04  7:41 Yoichi Yuasa
  2009-11-04  9:44 ` Ralf Baechle
  0 siblings, 1 reply; 5+ messages in thread
From: Yoichi Yuasa @ 2009-11-04  7:41 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: yuasa, linux-mips


ohci-sm501 driver require dma_declare_coherent_memory().
It is used to driver's local memory allocation with dma_alloc_coherent().

This patch works without problem on TANBAC TB0287(VR4131 + SM501).

Signed-off-by: Yoichi Yuasa <yuasa@linux-mips.org>
---
 arch/mips/Kconfig                   |    1 +
 arch/mips/include/asm/dma-mapping.h |    3 +--
 arch/mips/mm/dma-default.c          |    7 +++++++
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 03bd56a..687a438 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -3,6 +3,7 @@ config MIPS
 	default y
 	select HAVE_IDE
 	select HAVE_OPROFILE
+	select HAVE_GENERIC_DMA_COHERENT
 	select HAVE_ARCH_KGDB
 	# Horrible source of confusion.  Die, die, die ...
 	select EMBEDDED
diff --git a/arch/mips/include/asm/dma-mapping.h b/arch/mips/include/asm/dma-mapping.h
index d16afdd..808e303 100644
--- a/arch/mips/include/asm/dma-mapping.h
+++ b/arch/mips/include/asm/dma-mapping.h
@@ -3,6 +3,7 @@
 
 #include <asm/scatterlist.h>
 #include <asm/cache.h>
+#include <asm-generic/dma-coherent.h>
 
 void *dma_alloc_noncoherent(struct device *dev, size_t size,
 			   dma_addr_t *dma_handle, gfp_t flag);
@@ -73,7 +74,6 @@ extern int dma_is_consistent(struct device *dev, dma_addr_t dma_addr);
 extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
 	       enum dma_data_direction direction);
 
-#if 0
 #define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
 
 extern int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
@@ -81,6 +81,5 @@ extern int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
 extern void dma_release_declared_memory(struct device *dev);
 extern void * dma_mark_declared_memory_occupied(struct device *dev,
 	dma_addr_t device_addr, size_t size);
-#endif
 
 #endif /* _ASM_DMA_MAPPING_H */
diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index 7e48e76..32b43bd 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -90,6 +90,9 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
 {
 	void *ret;
 
+	if (dma_alloc_from_coherent(dev, size, dma_handle, &ret))
+		return ret;
+
 	gfp = massage_gfp_flags(dev, gfp);
 
 	ret = (void *) __get_free_pages(gfp, get_order(size));
@@ -121,8 +124,12 @@ EXPORT_SYMBOL(dma_free_noncoherent);
 void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
 	dma_addr_t dma_handle)
 {
+	int order = get_order(size);
 	unsigned long addr = (unsigned long) vaddr;
 
+	if (dma_release_from_coherent(dev, order, vaddr))
+		return;
+
 	plat_unmap_dma_mem(dev, dma_handle, size, DMA_BIDIRECTIONAL);
 
 	if (!plat_device_is_coherent(dev))
-- 
1.6.5.2

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

* Re: [PATCH][MIPS] add DMA declare coherent memory support
  2009-11-04  7:41 [PATCH][MIPS] add DMA declare coherent memory support Yoichi Yuasa
@ 2009-11-04  9:44 ` Ralf Baechle
  0 siblings, 0 replies; 5+ messages in thread
From: Ralf Baechle @ 2009-11-04  9:44 UTC (permalink / raw)
  To: Yoichi Yuasa; +Cc: linux-mips

On Wed, Nov 04, 2009 at 04:41:04PM +0900, Yoichi Yuasa wrote:

> ohci-sm501 driver require dma_declare_coherent_memory().
> It is used to driver's local memory allocation with dma_alloc_coherent().
> 
> This patch works without problem on TANBAC TB0287(VR4131 + SM501).

I already had a modified version of this patch queued up for 2.6.33.  I'll
move that patch into the main tree and change the comment to make it
clear that this is a required fix.

Thanks,

  Ralf

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

* Re: [PATCH][MIPS] add DMA declare coherent memory support
  2009-06-03 15:31 ` Thomas Bogendoerfer
@ 2009-06-05  3:03   ` Yuasa Yoichi
  0 siblings, 0 replies; 5+ messages in thread
From: Yuasa Yoichi @ 2009-06-05  3:03 UTC (permalink / raw)
  To: Thomas Bogendoerfer; +Cc: Ralf Baechle, linux-mips

Hi,

2009/6/4 Thomas Bogendoerfer <tsbogend@alpha.franken.de>:
> On Thu, Jun 04, 2009 at 12:16:04AM +0900, Yoichi Yuasa wrote:
>>
>> Signed-off-by: Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
>
> a little bit more description what this is all about would be quite
> helpful. I also see a problem as there is at least one MIPS machine
> (SGI IP28), which doesn't support coherent memory (at least not without
> playing dirty games with the memory controller, which in return makes
> the machine slow).

Some drivers require dma_declare_coherent_memory() (eg.
drivers/usb/host/ohci-sm501.c).
It is used to driver's local memory allocation with dma_alloc_coherent().

Yoichi

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

* Re: [PATCH][MIPS] add DMA declare coherent memory support
  2009-06-03 15:16 Yoichi Yuasa
@ 2009-06-03 15:31 ` Thomas Bogendoerfer
  2009-06-05  3:03   ` Yuasa Yoichi
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Bogendoerfer @ 2009-06-03 15:31 UTC (permalink / raw)
  To: Yoichi Yuasa; +Cc: Ralf Baechle, linux-mips

On Thu, Jun 04, 2009 at 12:16:04AM +0900, Yoichi Yuasa wrote:
> 
> Signed-off-by: Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>

a little bit more description what this is all about would be quite
helpful. I also see a problem as there is at least one MIPS machine
(SGI IP28), which doesn't support coherent memory (at least not without
playing dirty games with the memory controller, which in return makes
the machine slow). 

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessary a
good idea.                                                [ RFC1925, 2.3 ]

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

* [PATCH][MIPS] add DMA declare coherent memory support
@ 2009-06-03 15:16 Yoichi Yuasa
  2009-06-03 15:31 ` Thomas Bogendoerfer
  0 siblings, 1 reply; 5+ messages in thread
From: Yoichi Yuasa @ 2009-06-03 15:16 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: yoichi_yuasa, linux-mips


Signed-off-by: Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>

diff -pruN -X /home/yuasa/Memo/dontdiff linux-orig/arch/mips/Kconfig linux/arch/mips/Kconfig
--- linux-orig/arch/mips/Kconfig	2009-04-21 10:55:44.353177629 +0900
+++ linux/arch/mips/Kconfig	2009-04-21 11:01:02.801170966 +0900
@@ -3,6 +3,7 @@ config MIPS
 	default y
 	select HAVE_IDE
 	select HAVE_OPROFILE
+	select HAVE_GENERIC_DMA_COHERENT
 	select HAVE_ARCH_KGDB
 	# Horrible source of confusion.  Die, die, die ...
 	select EMBEDDED
diff -pruN -X /home/yuasa/Memo/dontdiff linux-orig/arch/mips/include/asm/dma-mapping.h linux/arch/mips/include/asm/dma-mapping.h
--- linux-orig/arch/mips/include/asm/dma-mapping.h	2009-04-21 10:55:44.549177717 +0900
+++ linux/arch/mips/include/asm/dma-mapping.h	2009-04-21 11:19:40.077177611 +0900
@@ -3,6 +3,7 @@
 
 #include <asm/scatterlist.h>
 #include <asm/cache.h>
+#include <asm-generic/dma-coherent.h>
 
 void *dma_alloc_noncoherent(struct device *dev, size_t size,
 			   dma_addr_t *dma_handle, gfp_t flag);
@@ -73,7 +74,6 @@ extern int dma_is_consistent(struct devi
 extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
 	       enum dma_data_direction direction);
 
-#if 0
 #define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
 
 extern int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
@@ -81,6 +81,5 @@ extern int dma_declare_coherent_memory(s
 extern void dma_release_declared_memory(struct device *dev);
 extern void * dma_mark_declared_memory_occupied(struct device *dev,
 	dma_addr_t device_addr, size_t size);
-#endif
 
 #endif /* _ASM_DMA_MAPPING_H */
diff -pruN -X /home/yuasa/Memo/dontdiff linux-orig/arch/mips/mm/dma-default.c linux/arch/mips/mm/dma-default.c
--- linux-orig/arch/mips/mm/dma-default.c	2009-04-21 10:55:46.409177601 +0900
+++ linux/arch/mips/mm/dma-default.c	2009-04-21 11:21:17.061177557 +0900
@@ -89,6 +89,9 @@ void *dma_alloc_coherent(struct device *
 {
 	void *ret;
 
+	if (dma_alloc_from_coherent(dev, size, dma_handle, &ret))
+		return ret;
+
 	gfp = massage_gfp_flags(dev, gfp);
 
 	ret = (void *) __get_free_pages(gfp, get_order(size));
@@ -120,8 +123,12 @@ EXPORT_SYMBOL(dma_free_noncoherent);
 void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
 	dma_addr_t dma_handle)
 {
+	int order = get_order(size);
 	unsigned long addr = (unsigned long) vaddr;
 
+	if (dma_release_from_coherent(dev, order, vaddr))
+		return;
+
 	plat_unmap_dma_mem(dev, dma_handle);
 
 	if (!plat_device_is_coherent(dev))

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

end of thread, other threads:[~2009-11-04  9:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-04  7:41 [PATCH][MIPS] add DMA declare coherent memory support Yoichi Yuasa
2009-11-04  9:44 ` Ralf Baechle
  -- strict thread matches above, loose matches on Subject: below --
2009-06-03 15:16 Yoichi Yuasa
2009-06-03 15:31 ` Thomas Bogendoerfer
2009-06-05  3:03   ` Yuasa Yoichi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.