aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2009-08-09 22:53:17 -0400
committerIngo Molnar <mingo@elte.hu>2009-08-10 03:35:00 -0400
commit451d7400a34cb679369e337d67f0238ed410f484 (patch)
tree75dc26e88fa60609503ccb6426b3cdbd441615d5
parentee664a9252d24ef10317d1bba8fc8f4c6495b36c (diff)
sparc: Add CONFIG_DMA_API_DEBUG support
All we need to do for CONFIG_DMA_API_DEBUG support is call dma_debug_init() in DMA code common for SPARC32 and SPARC64. Now SPARC32 uses two dma_map_ops structures for pci and sbus so there is not much dma stuff for SPARC32 in kernel/dma.c. kernel/ioport.c also includes dma stuff for SPARC32. So let's put all the dma stuff for SPARC32 in kernel/ioport.c and make kernel/dma.c common for SPARC32 and SPARC64. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Tested-by: Robert Reif <reif@earthlink.net> Acked-by: David S. Miller <davem@davemloft.net> Cc: tony.luck@intel.com Cc: fenghua.yu@intel.com LKML-Reference: <1249872797-1314-9-git-send-email-fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--arch/sparc/Kconfig1
-rw-r--r--arch/sparc/include/asm/dma-mapping.h6
-rw-r--r--arch/sparc/kernel/Makefile2
-rw-r--r--arch/sparc/kernel/dma.c37
-rw-r--r--arch/sparc/kernel/ioport.c27
5 files changed, 39 insertions, 34 deletions
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 5f2df99645c9..233cff53a623 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -26,6 +26,7 @@ config SPARC
26 select RTC_CLASS 26 select RTC_CLASS
27 select RTC_DRV_M48T59 27 select RTC_DRV_M48T59
28 select HAVE_DMA_ATTRS 28 select HAVE_DMA_ATTRS
29 select HAVE_DMA_API_DEBUG
29 30
30config SPARC32 31config SPARC32
31 def_bool !64BIT 32 def_bool !64BIT
diff --git a/arch/sparc/include/asm/dma-mapping.h b/arch/sparc/include/asm/dma-mapping.h
index 2677818dc781..5a8c308e2b5c 100644
--- a/arch/sparc/include/asm/dma-mapping.h
+++ b/arch/sparc/include/asm/dma-mapping.h
@@ -32,8 +32,11 @@ static inline void *dma_alloc_coherent(struct device *dev, size_t size,
32 dma_addr_t *dma_handle, gfp_t flag) 32 dma_addr_t *dma_handle, gfp_t flag)
33{ 33{
34 struct dma_map_ops *ops = get_dma_ops(dev); 34 struct dma_map_ops *ops = get_dma_ops(dev);
35 void *cpu_addr;
35 36
36 return ops->alloc_coherent(dev, size, dma_handle, flag); 37 cpu_addr = ops->alloc_coherent(dev, size, dma_handle, flag);
38 debug_dma_alloc_coherent(dev, size, *dma_handle, cpu_addr);
39 return cpu_addr;
37} 40}
38 41
39static inline void dma_free_coherent(struct device *dev, size_t size, 42static inline void dma_free_coherent(struct device *dev, size_t size,
@@ -41,6 +44,7 @@ static inline void dma_free_coherent(struct device *dev, size_t size,
41{ 44{
42 struct dma_map_ops *ops = get_dma_ops(dev); 45 struct dma_map_ops *ops = get_dma_ops(dev);
43 46
47 debug_dma_free_coherent(dev, size, cpu_addr, dma_handle);
44 ops->free_coherent(dev, size, cpu_addr, dma_handle); 48 ops->free_coherent(dev, size, cpu_addr, dma_handle);
45} 49}
46 50
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index 475ce4696acd..29b88a580661 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -61,7 +61,7 @@ obj-$(CONFIG_SPARC64_SMP) += cpumap.o
61obj-$(CONFIG_SPARC32) += devres.o 61obj-$(CONFIG_SPARC32) += devres.o
62devres-y := ../../../kernel/irq/devres.o 62devres-y := ../../../kernel/irq/devres.o
63 63
64obj-$(CONFIG_SPARC32) += dma.o 64obj-y += dma.o
65 65
66obj-$(CONFIG_SPARC32_PCI) += pcic.o 66obj-$(CONFIG_SPARC32_PCI) += pcic.o
67 67
diff --git a/arch/sparc/kernel/dma.c b/arch/sparc/kernel/dma.c
index b2fa3127f605..e1ba8ee21b9a 100644
--- a/arch/sparc/kernel/dma.c
+++ b/arch/sparc/kernel/dma.c
@@ -1,40 +1,13 @@
1/* dma.c: PCI and SBUS DMA accessors for 32-bit sparc.
2 *
3 * Copyright (C) 2008 David S. Miller <davem@davemloft.net>
4 */
5
6#include <linux/kernel.h> 1#include <linux/kernel.h>
7#include <linux/module.h> 2#include <linux/module.h>
8#include <linux/dma-mapping.h> 3#include <linux/dma-mapping.h>
9#include <linux/scatterlist.h> 4#include <linux/dma-debug.h>
10#include <linux/mm.h>
11 5
12#ifdef CONFIG_PCI 6#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 15)
13#include <linux/pci.h>
14#endif
15 7
16/* 8static int __init dma_init(void)
17 * Return whether the given PCI device DMA address mask can be
18 * supported properly. For example, if your device can only drive the
19 * low 24-bits during PCI bus mastering, then you would pass
20 * 0x00ffffff as the mask to this function.
21 */
22int dma_supported(struct device *dev, u64 mask)
23{ 9{
24#ifdef CONFIG_PCI 10 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
25 if (dev->bus == &pci_bus_type)
26 return 1;
27#endif
28 return 0; 11 return 0;
29} 12}
30EXPORT_SYMBOL(dma_supported); 13fs_initcall(dma_init);
31
32int dma_set_mask(struct device *dev, u64 dma_mask)
33{
34#ifdef CONFIG_PCI
35 if (dev->bus == &pci_bus_type)
36 return pci_set_dma_mask(to_pci_dev(dev), dma_mask);
37#endif
38 return -EOPNOTSUPP;
39}
40EXPORT_SYMBOL(dma_set_mask);
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index 1eb604389655..edbea232c617 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -654,6 +654,33 @@ EXPORT_SYMBOL(pci32_dma_ops);
654 654
655#endif /* CONFIG_PCI */ 655#endif /* CONFIG_PCI */
656 656
657/*
658 * Return whether the given PCI device DMA address mask can be
659 * supported properly. For example, if your device can only drive the
660 * low 24-bits during PCI bus mastering, then you would pass
661 * 0x00ffffff as the mask to this function.
662 */
663int dma_supported(struct device *dev, u64 mask)
664{
665#ifdef CONFIG_PCI
666 if (dev->bus == &pci_bus_type)
667 return 1;
668#endif
669 return 0;
670}
671EXPORT_SYMBOL(dma_supported);
672
673int dma_set_mask(struct device *dev, u64 dma_mask)
674{
675#ifdef CONFIG_PCI
676 if (dev->bus == &pci_bus_type)
677 return pci_set_dma_mask(to_pci_dev(dev), dma_mask);
678#endif
679 return -EOPNOTSUPP;
680}
681EXPORT_SYMBOL(dma_set_mask);
682
683
657#ifdef CONFIG_PROC_FS 684#ifdef CONFIG_PROC_FS
658 685
659static int 686static int