diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/base/iommu.c | 2 | ||||
-rw-r--r-- | drivers/pci/intel-iommu.c | 50 |
2 files changed, 34 insertions, 18 deletions
diff --git a/drivers/base/iommu.c b/drivers/base/iommu.c index 5e039d4f877c..c2d1eed90376 100644 --- a/drivers/base/iommu.c +++ b/drivers/base/iommu.c | |||
@@ -31,7 +31,7 @@ void register_iommu(struct iommu_ops *ops) | |||
31 | iommu_ops = ops; | 31 | iommu_ops = ops; |
32 | } | 32 | } |
33 | 33 | ||
34 | bool iommu_found() | 34 | bool iommu_found(void) |
35 | { | 35 | { |
36 | return iommu_ops != NULL; | 36 | return iommu_ops != NULL; |
37 | } | 37 | } |
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c index ef167b8b047d..49402c399232 100644 --- a/drivers/pci/intel-iommu.c +++ b/drivers/pci/intel-iommu.c | |||
@@ -2124,11 +2124,13 @@ error: | |||
2124 | return 0; | 2124 | return 0; |
2125 | } | 2125 | } |
2126 | 2126 | ||
2127 | dma_addr_t intel_map_single(struct device *hwdev, phys_addr_t paddr, | 2127 | static dma_addr_t intel_map_page(struct device *dev, struct page *page, |
2128 | size_t size, int dir) | 2128 | unsigned long offset, size_t size, |
2129 | enum dma_data_direction dir, | ||
2130 | struct dma_attrs *attrs) | ||
2129 | { | 2131 | { |
2130 | return __intel_map_single(hwdev, paddr, size, dir, | 2132 | return __intel_map_single(dev, page_to_phys(page) + offset, size, |
2131 | to_pci_dev(hwdev)->dma_mask); | 2133 | dir, to_pci_dev(dev)->dma_mask); |
2132 | } | 2134 | } |
2133 | 2135 | ||
2134 | static void flush_unmaps(void) | 2136 | static void flush_unmaps(void) |
@@ -2192,8 +2194,9 @@ static void add_unmap(struct dmar_domain *dom, struct iova *iova) | |||
2192 | spin_unlock_irqrestore(&async_umap_flush_lock, flags); | 2194 | spin_unlock_irqrestore(&async_umap_flush_lock, flags); |
2193 | } | 2195 | } |
2194 | 2196 | ||
2195 | void intel_unmap_single(struct device *dev, dma_addr_t dev_addr, size_t size, | 2197 | static void intel_unmap_page(struct device *dev, dma_addr_t dev_addr, |
2196 | int dir) | 2198 | size_t size, enum dma_data_direction dir, |
2199 | struct dma_attrs *attrs) | ||
2197 | { | 2200 | { |
2198 | struct pci_dev *pdev = to_pci_dev(dev); | 2201 | struct pci_dev *pdev = to_pci_dev(dev); |
2199 | struct dmar_domain *domain; | 2202 | struct dmar_domain *domain; |
@@ -2237,8 +2240,14 @@ void intel_unmap_single(struct device *dev, dma_addr_t dev_addr, size_t size, | |||
2237 | } | 2240 | } |
2238 | } | 2241 | } |
2239 | 2242 | ||
2240 | void *intel_alloc_coherent(struct device *hwdev, size_t size, | 2243 | static void intel_unmap_single(struct device *dev, dma_addr_t dev_addr, size_t size, |
2241 | dma_addr_t *dma_handle, gfp_t flags) | 2244 | int dir) |
2245 | { | ||
2246 | intel_unmap_page(dev, dev_addr, size, dir, NULL); | ||
2247 | } | ||
2248 | |||
2249 | static void *intel_alloc_coherent(struct device *hwdev, size_t size, | ||
2250 | dma_addr_t *dma_handle, gfp_t flags) | ||
2242 | { | 2251 | { |
2243 | void *vaddr; | 2252 | void *vaddr; |
2244 | int order; | 2253 | int order; |
@@ -2261,8 +2270,8 @@ void *intel_alloc_coherent(struct device *hwdev, size_t size, | |||
2261 | return NULL; | 2270 | return NULL; |
2262 | } | 2271 | } |
2263 | 2272 | ||
2264 | void intel_free_coherent(struct device *hwdev, size_t size, void *vaddr, | 2273 | static void intel_free_coherent(struct device *hwdev, size_t size, void *vaddr, |
2265 | dma_addr_t dma_handle) | 2274 | dma_addr_t dma_handle) |
2266 | { | 2275 | { |
2267 | int order; | 2276 | int order; |
2268 | 2277 | ||
@@ -2275,8 +2284,9 @@ void intel_free_coherent(struct device *hwdev, size_t size, void *vaddr, | |||
2275 | 2284 | ||
2276 | #define SG_ENT_VIRT_ADDRESS(sg) (sg_virt((sg))) | 2285 | #define SG_ENT_VIRT_ADDRESS(sg) (sg_virt((sg))) |
2277 | 2286 | ||
2278 | void intel_unmap_sg(struct device *hwdev, struct scatterlist *sglist, | 2287 | static void intel_unmap_sg(struct device *hwdev, struct scatterlist *sglist, |
2279 | int nelems, int dir) | 2288 | int nelems, enum dma_data_direction dir, |
2289 | struct dma_attrs *attrs) | ||
2280 | { | 2290 | { |
2281 | int i; | 2291 | int i; |
2282 | struct pci_dev *pdev = to_pci_dev(hwdev); | 2292 | struct pci_dev *pdev = to_pci_dev(hwdev); |
@@ -2333,8 +2343,8 @@ static int intel_nontranslate_map_sg(struct device *hddev, | |||
2333 | return nelems; | 2343 | return nelems; |
2334 | } | 2344 | } |
2335 | 2345 | ||
2336 | int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, int nelems, | 2346 | static int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, int nelems, |
2337 | int dir) | 2347 | enum dma_data_direction dir, struct dma_attrs *attrs) |
2338 | { | 2348 | { |
2339 | void *addr; | 2349 | void *addr; |
2340 | int i; | 2350 | int i; |
@@ -2414,13 +2424,19 @@ int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, int nelems, | |||
2414 | return nelems; | 2424 | return nelems; |
2415 | } | 2425 | } |
2416 | 2426 | ||
2417 | static struct dma_mapping_ops intel_dma_ops = { | 2427 | static int intel_mapping_error(struct device *dev, dma_addr_t dma_addr) |
2428 | { | ||
2429 | return !dma_addr; | ||
2430 | } | ||
2431 | |||
2432 | struct dma_map_ops intel_dma_ops = { | ||
2418 | .alloc_coherent = intel_alloc_coherent, | 2433 | .alloc_coherent = intel_alloc_coherent, |
2419 | .free_coherent = intel_free_coherent, | 2434 | .free_coherent = intel_free_coherent, |
2420 | .map_single = intel_map_single, | ||
2421 | .unmap_single = intel_unmap_single, | ||
2422 | .map_sg = intel_map_sg, | 2435 | .map_sg = intel_map_sg, |
2423 | .unmap_sg = intel_unmap_sg, | 2436 | .unmap_sg = intel_unmap_sg, |
2437 | .map_page = intel_map_page, | ||
2438 | .unmap_page = intel_unmap_page, | ||
2439 | .mapping_error = intel_mapping_error, | ||
2424 | }; | 2440 | }; |
2425 | 2441 | ||
2426 | static inline int iommu_domain_cache_init(void) | 2442 | static inline int iommu_domain_cache_init(void) |