diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2010-08-30 15:23:52 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2010-09-02 00:07:32 -0400 |
commit | 5b6e9ff6deb703b95fb355bb66d86096c1a2df09 (patch) | |
tree | 81d76f282fba415681cda3d1e3690da46c3d17b2 /arch/powerpc | |
parent | cab175f9fa2973f0deb1580fca3c966fe1d3981e (diff) |
powerpc/dma: Add optional platform override of dma_set_mask()
Some platforms may want to override dma_set_mask() to take into
account some specific "features" such as the availability of
a direct-map window in addition to an iommu.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/include/asm/dma-mapping.h | 14 | ||||
-rw-r--r-- | arch/powerpc/include/asm/machdep.h | 3 | ||||
-rw-r--r-- | arch/powerpc/kernel/dma.c | 18 |
3 files changed, 22 insertions, 13 deletions
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h index 8c9c6ad2004e..6d2416a85709 100644 --- a/arch/powerpc/include/asm/dma-mapping.h +++ b/arch/powerpc/include/asm/dma-mapping.h | |||
@@ -127,19 +127,7 @@ static inline int dma_supported(struct device *dev, u64 mask) | |||
127 | return dma_ops->dma_supported(dev, mask); | 127 | return dma_ops->dma_supported(dev, mask); |
128 | } | 128 | } |
129 | 129 | ||
130 | static inline int dma_set_mask(struct device *dev, u64 dma_mask) | 130 | extern int dma_set_mask(struct device *dev, u64 dma_mask); |
131 | { | ||
132 | struct dma_map_ops *dma_ops = get_dma_ops(dev); | ||
133 | |||
134 | if (unlikely(dma_ops == NULL)) | ||
135 | return -EIO; | ||
136 | if (dma_ops->set_dma_mask != NULL) | ||
137 | return dma_ops->set_dma_mask(dev, dma_mask); | ||
138 | if (!dev->dma_mask || !dma_supported(dev, dma_mask)) | ||
139 | return -EIO; | ||
140 | *dev->dma_mask = dma_mask; | ||
141 | return 0; | ||
142 | } | ||
143 | 131 | ||
144 | static inline void *dma_alloc_coherent(struct device *dev, size_t size, | 132 | static inline void *dma_alloc_coherent(struct device *dev, size_t size, |
145 | dma_addr_t *dma_handle, gfp_t flag) | 133 | dma_addr_t *dma_handle, gfp_t flag) |
diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h index adc8e6cdf339..d045b0145537 100644 --- a/arch/powerpc/include/asm/machdep.h +++ b/arch/powerpc/include/asm/machdep.h | |||
@@ -102,6 +102,9 @@ struct machdep_calls { | |||
102 | void (*pci_dma_dev_setup)(struct pci_dev *dev); | 102 | void (*pci_dma_dev_setup)(struct pci_dev *dev); |
103 | void (*pci_dma_bus_setup)(struct pci_bus *bus); | 103 | void (*pci_dma_bus_setup)(struct pci_bus *bus); |
104 | 104 | ||
105 | /* Platform set_dma_mask override */ | ||
106 | int (*dma_set_mask)(struct device *dev, u64 dma_mask); | ||
107 | |||
105 | int (*probe)(void); | 108 | int (*probe)(void); |
106 | void (*setup_arch)(void); /* Optional, may be NULL */ | 109 | void (*setup_arch)(void); /* Optional, may be NULL */ |
107 | void (*init_early)(void); | 110 | void (*init_early)(void); |
diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c index 84d6367ec003..f368c075c90b 100644 --- a/arch/powerpc/kernel/dma.c +++ b/arch/powerpc/kernel/dma.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/memblock.h> | 12 | #include <linux/memblock.h> |
13 | #include <asm/bug.h> | 13 | #include <asm/bug.h> |
14 | #include <asm/abs_addr.h> | 14 | #include <asm/abs_addr.h> |
15 | #include <asm/machdep.h> | ||
15 | 16 | ||
16 | /* | 17 | /* |
17 | * Generic direct DMA implementation | 18 | * Generic direct DMA implementation |
@@ -154,6 +155,23 @@ EXPORT_SYMBOL(dma_direct_ops); | |||
154 | 155 | ||
155 | #define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16) | 156 | #define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16) |
156 | 157 | ||
158 | int dma_set_mask(struct device *dev, u64 dma_mask) | ||
159 | { | ||
160 | struct dma_map_ops *dma_ops = get_dma_ops(dev); | ||
161 | |||
162 | if (ppc_md.dma_set_mask) | ||
163 | return ppc_md.dma_set_mask(dev, dma_mask); | ||
164 | if (unlikely(dma_ops == NULL)) | ||
165 | return -EIO; | ||
166 | if (dma_ops->set_dma_mask != NULL) | ||
167 | return dma_ops->set_dma_mask(dev, dma_mask); | ||
168 | if (!dev->dma_mask || !dma_supported(dev, dma_mask)) | ||
169 | return -EIO; | ||
170 | *dev->dma_mask = dma_mask; | ||
171 | return 0; | ||
172 | } | ||
173 | EXPORT_SYMBOL(dma_set_mask); | ||
174 | |||
157 | static int __init dma_init(void) | 175 | static int __init dma_init(void) |
158 | { | 176 | { |
159 | dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES); | 177 | dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES); |