diff options
-rw-r--r-- | Documentation/DMA-API.txt | 10 | ||||
-rw-r--r-- | drivers/pci/pci.c | 7 | ||||
-rw-r--r-- | include/linux/dma-mapping.h | 8 |
3 files changed, 21 insertions, 4 deletions
diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt index 29a48fbae779..0fc5728ed487 100644 --- a/Documentation/DMA-API.txt +++ b/Documentation/DMA-API.txt | |||
@@ -167,6 +167,16 @@ parameters if it is. | |||
167 | 167 | ||
168 | Returns: 0 if successful and a negative error if not. | 168 | Returns: 0 if successful and a negative error if not. |
169 | 169 | ||
170 | int | ||
171 | dma_set_coherent_mask(struct device *dev, u64 mask) | ||
172 | int | ||
173 | pci_set_consistent_dma_mask(struct pci_device *dev, u64 mask) | ||
174 | |||
175 | Checks to see if the mask is possible and updates the device | ||
176 | parameters if it is. | ||
177 | |||
178 | Returns: 0 if successful and a negative error if not. | ||
179 | |||
170 | u64 | 180 | u64 |
171 | dma_get_required_mask(struct device *dev) | 181 | dma_get_required_mask(struct device *dev) |
172 | 182 | ||
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index b2d23d1b0d41..929fd3932032 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -2315,12 +2315,11 @@ pci_set_dma_mask(struct pci_dev *dev, u64 mask) | |||
2315 | int | 2315 | int |
2316 | pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask) | 2316 | pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask) |
2317 | { | 2317 | { |
2318 | if (!pci_dma_supported(dev, mask)) | 2318 | int ret = dma_set_coherent_mask(&dev->dev, mask); |
2319 | return -EIO; | 2319 | if (ret) |
2320 | return ret; | ||
2320 | 2321 | ||
2321 | dev->dev.coherent_dma_mask = mask; | ||
2322 | dev_dbg(&dev->dev, "using %dbit consistent DMA mask\n", fls64(mask)); | 2322 | dev_dbg(&dev->dev, "using %dbit consistent DMA mask\n", fls64(mask)); |
2323 | |||
2324 | return 0; | 2323 | return 0; |
2325 | } | 2324 | } |
2326 | #endif | 2325 | #endif |
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index c5ac9d49cc06..ca32ed78b057 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h | |||
@@ -127,6 +127,14 @@ static inline u64 dma_get_mask(struct device *dev) | |||
127 | return DMA_BIT_MASK(32); | 127 | return DMA_BIT_MASK(32); |
128 | } | 128 | } |
129 | 129 | ||
130 | static inline int dma_set_coherent_mask(struct device *dev, u64 mask) | ||
131 | { | ||
132 | if (!dma_supported(dev, mask)) | ||
133 | return -EIO; | ||
134 | dev->coherent_dma_mask = mask; | ||
135 | return 0; | ||
136 | } | ||
137 | |||
130 | extern u64 dma_get_required_mask(struct device *dev); | 138 | extern u64 dma_get_required_mask(struct device *dev); |
131 | 139 | ||
132 | static inline unsigned int dma_get_max_seg_size(struct device *dev) | 140 | static inline unsigned int dma_get_max_seg_size(struct device *dev) |