Commit 451d7400 authored by FUJITA Tomonori's avatar FUJITA Tomonori Committed by Ingo Molnar

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: default avatarFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Tested-by: default avatarRobert Reif <reif@earthlink.net>
Acked-by: default avatarDavid 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: default avatarIngo Molnar <mingo@elte.hu>
parent ee664a92
...@@ -26,6 +26,7 @@ config SPARC ...@@ -26,6 +26,7 @@ config SPARC
select RTC_CLASS select RTC_CLASS
select RTC_DRV_M48T59 select RTC_DRV_M48T59
select HAVE_DMA_ATTRS select HAVE_DMA_ATTRS
select HAVE_DMA_API_DEBUG
config SPARC32 config SPARC32
def_bool !64BIT def_bool !64BIT
......
...@@ -32,8 +32,11 @@ static inline void *dma_alloc_coherent(struct device *dev, size_t size, ...@@ -32,8 +32,11 @@ static inline void *dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t flag) dma_addr_t *dma_handle, gfp_t flag)
{ {
struct dma_map_ops *ops = get_dma_ops(dev); struct dma_map_ops *ops = get_dma_ops(dev);
void *cpu_addr;
return ops->alloc_coherent(dev, size, dma_handle, flag); cpu_addr = ops->alloc_coherent(dev, size, dma_handle, flag);
debug_dma_alloc_coherent(dev, size, *dma_handle, cpu_addr);
return cpu_addr;
} }
static inline void dma_free_coherent(struct device *dev, size_t size, static 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,6 +44,7 @@ static inline void dma_free_coherent(struct device *dev, size_t size,
{ {
struct dma_map_ops *ops = get_dma_ops(dev); struct dma_map_ops *ops = get_dma_ops(dev);
debug_dma_free_coherent(dev, size, cpu_addr, dma_handle);
ops->free_coherent(dev, size, cpu_addr, dma_handle); ops->free_coherent(dev, size, cpu_addr, dma_handle);
} }
......
...@@ -61,7 +61,7 @@ obj-$(CONFIG_SPARC64_SMP) += cpumap.o ...@@ -61,7 +61,7 @@ obj-$(CONFIG_SPARC64_SMP) += cpumap.o
obj-$(CONFIG_SPARC32) += devres.o obj-$(CONFIG_SPARC32) += devres.o
devres-y := ../../../kernel/irq/devres.o devres-y := ../../../kernel/irq/devres.o
obj-$(CONFIG_SPARC32) += dma.o obj-y += dma.o
obj-$(CONFIG_SPARC32_PCI) += pcic.o obj-$(CONFIG_SPARC32_PCI) += pcic.o
......
/* dma.c: PCI and SBUS DMA accessors for 32-bit sparc.
*
* Copyright (C) 2008 David S. Miller <davem@davemloft.net>
*/
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/scatterlist.h> #include <linux/dma-debug.h>
#include <linux/mm.h>
#ifdef CONFIG_PCI #define PREALLOC_DMA_DEBUG_ENTRIES (1 << 15)
#include <linux/pci.h>
#endif
/* static int __init dma_init(void)
* Return whether the given PCI device DMA address mask can be
* supported properly. For example, if your device can only drive the
* low 24-bits during PCI bus mastering, then you would pass
* 0x00ffffff as the mask to this function.
*/
int dma_supported(struct device *dev, u64 mask)
{ {
#ifdef CONFIG_PCI dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
if (dev->bus == &pci_bus_type)
return 1;
#endif
return 0; return 0;
} }
EXPORT_SYMBOL(dma_supported); fs_initcall(dma_init);
int dma_set_mask(struct device *dev, u64 dma_mask)
{
#ifdef CONFIG_PCI
if (dev->bus == &pci_bus_type)
return pci_set_dma_mask(to_pci_dev(dev), dma_mask);
#endif
return -EOPNOTSUPP;
}
EXPORT_SYMBOL(dma_set_mask);
...@@ -654,6 +654,33 @@ EXPORT_SYMBOL(pci32_dma_ops); ...@@ -654,6 +654,33 @@ EXPORT_SYMBOL(pci32_dma_ops);
#endif /* CONFIG_PCI */ #endif /* CONFIG_PCI */
/*
* Return whether the given PCI device DMA address mask can be
* supported properly. For example, if your device can only drive the
* low 24-bits during PCI bus mastering, then you would pass
* 0x00ffffff as the mask to this function.
*/
int dma_supported(struct device *dev, u64 mask)
{
#ifdef CONFIG_PCI
if (dev->bus == &pci_bus_type)
return 1;
#endif
return 0;
}
EXPORT_SYMBOL(dma_supported);
int dma_set_mask(struct device *dev, u64 dma_mask)
{
#ifdef CONFIG_PCI
if (dev->bus == &pci_bus_type)
return pci_set_dma_mask(to_pci_dev(dev), dma_mask);
#endif
return -EOPNOTSUPP;
}
EXPORT_SYMBOL(dma_set_mask);
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
static int static int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment