Commit 451d7400a34cb679369e337d67f0238ed410f484
Committed by
Ingo Molnar
1 parent
ee664a9252
Exists in
master
and in
7 other branches
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>
Showing 5 changed files with 39 additions and 34 deletions Side-by-side Diff
arch/sparc/Kconfig
arch/sparc/include/asm/dma-mapping.h
... | ... | @@ -32,8 +32,11 @@ |
32 | 32 | dma_addr_t *dma_handle, gfp_t flag) |
33 | 33 | { |
34 | 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 | |
39 | 42 | static inline void dma_free_coherent(struct device *dev, size_t size, |
... | ... | @@ -41,6 +44,7 @@ |
41 | 44 | { |
42 | 45 | struct dma_map_ops *ops = get_dma_ops(dev); |
43 | 46 | |
47 | + debug_dma_free_coherent(dev, size, cpu_addr, dma_handle); | |
44 | 48 | ops->free_coherent(dev, size, cpu_addr, dma_handle); |
45 | 49 | } |
46 | 50 |
arch/sparc/kernel/Makefile
arch/sparc/kernel/dma.c
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 | 1 | #include <linux/kernel.h> |
7 | 2 | #include <linux/module.h> |
8 | 3 | #include <linux/dma-mapping.h> |
9 | -#include <linux/scatterlist.h> | |
10 | -#include <linux/mm.h> | |
4 | +#include <linux/dma-debug.h> | |
11 | 5 | |
12 | -#ifdef CONFIG_PCI | |
13 | -#include <linux/pci.h> | |
14 | -#endif | |
6 | +#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 15) | |
15 | 7 | |
16 | -/* | |
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 | - */ | |
22 | -int dma_supported(struct device *dev, u64 mask) | |
8 | +static int __init dma_init(void) | |
23 | 9 | { |
24 | -#ifdef CONFIG_PCI | |
25 | - if (dev->bus == &pci_bus_type) | |
26 | - return 1; | |
27 | -#endif | |
10 | + dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES); | |
28 | 11 | return 0; |
29 | 12 | } |
30 | -EXPORT_SYMBOL(dma_supported); | |
31 | - | |
32 | -int 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 | -} | |
40 | -EXPORT_SYMBOL(dma_set_mask); | |
13 | +fs_initcall(dma_init); |
arch/sparc/kernel/ioport.c
... | ... | @@ -654,6 +654,33 @@ |
654 | 654 | |
655 | 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 | + */ | |
663 | +int 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 | +} | |
671 | +EXPORT_SYMBOL(dma_supported); | |
672 | + | |
673 | +int 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 | +} | |
681 | +EXPORT_SYMBOL(dma_set_mask); | |
682 | + | |
683 | + | |
657 | 684 | #ifdef CONFIG_PROC_FS |
658 | 685 | |
659 | 686 | static int |