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 f3f686581a90..e7d058aa7b0d 100644 --- a/drivers/pci/intel-iommu.c +++ b/drivers/pci/intel-iommu.c | |||
@@ -2284,11 +2284,13 @@ error: | |||
2284 | return 0; | 2284 | return 0; |
2285 | } | 2285 | } |
2286 | 2286 | ||
2287 | dma_addr_t intel_map_single(struct device *hwdev, phys_addr_t paddr, | 2287 | static dma_addr_t intel_map_page(struct device *dev, struct page *page, |
2288 | size_t size, int dir) | 2288 | unsigned long offset, size_t size, |
2289 | enum dma_data_direction dir, | ||
2290 | struct dma_attrs *attrs) | ||
2289 | { | 2291 | { |
2290 | return __intel_map_single(hwdev, paddr, size, dir, | 2292 | return __intel_map_single(dev, page_to_phys(page) + offset, size, |
2291 | to_pci_dev(hwdev)->dma_mask); | 2293 | dir, to_pci_dev(dev)->dma_mask); |
2292 | } | 2294 | } |
2293 | 2295 | ||
2294 | static void flush_unmaps(void) | 2296 | static void flush_unmaps(void) |
@@ -2352,8 +2354,9 @@ static void add_unmap(struct dmar_domain *dom, struct iova *iova) | |||
2352 | spin_unlock_irqrestore(&async_umap_flush_lock, flags); | 2354 | spin_unlock_irqrestore(&async_umap_flush_lock, flags); |
2353 | } | 2355 | } |
2354 | 2356 | ||
2355 | void intel_unmap_single(struct device *dev, dma_addr_t dev_addr, size_t size, | 2357 | static void intel_unmap_page(struct device *dev, dma_addr_t dev_addr, |
2356 | int dir) | 2358 | size_t size, enum dma_data_direction dir, |
2359 | struct dma_attrs *attrs) | ||
2357 | { | 2360 | { |
2358 | struct pci_dev *pdev = to_pci_dev(dev); | 2361 | struct pci_dev *pdev = to_pci_dev(dev); |
2359 | struct dmar_domain *domain; | 2362 | struct dmar_domain *domain; |
@@ -2397,8 +2400,14 @@ void intel_unmap_single(struct device *dev, dma_addr_t dev_addr, size_t size, | |||
2397 | } | 2400 | } |
2398 | } | 2401 | } |
2399 | 2402 | ||
2400 | void *intel_alloc_coherent(struct device *hwdev, size_t size, | 2403 | static void intel_unmap_single(struct device *dev, dma_addr_t dev_addr, size_t size, |
2401 | dma_addr_t *dma_handle, gfp_t flags) | 2404 | int dir) |
2405 | { | ||
2406 | intel_unmap_page(dev, dev_addr, size, dir, NULL); | ||
2407 | } | ||
2408 | |||
2409 | static void *intel_alloc_coherent(struct device *hwdev, size_t size, | ||
2410 | dma_addr_t *dma_handle, gfp_t flags) | ||
2402 | { | 2411 | { |
2403 | void *vaddr; | 2412 | void *vaddr; |
2404 | int order; | 2413 | int order; |
@@ -2421,8 +2430,8 @@ void *intel_alloc_coherent(struct device *hwdev, size_t size, | |||
2421 | return NULL; | 2430 | return NULL; |
2422 | } | 2431 | } |
2423 | 2432 | ||
2424 | void intel_free_coherent(struct device *hwdev, size_t size, void *vaddr, | 2433 | static void intel_free_coherent(struct device *hwdev, size_t size, void *vaddr, |
2425 | dma_addr_t dma_handle) | 2434 | dma_addr_t dma_handle) |
2426 | { | 2435 | { |
2427 | int order; | 2436 | int order; |
2428 | 2437 | ||
@@ -2435,8 +2444,9 @@ void intel_free_coherent(struct device *hwdev, size_t size, void *vaddr, | |||
2435 | 2444 | ||
2436 | #define SG_ENT_VIRT_ADDRESS(sg) (sg_virt((sg))) | 2445 | #define SG_ENT_VIRT_ADDRESS(sg) (sg_virt((sg))) |
2437 | 2446 | ||
2438 | void intel_unmap_sg(struct device *hwdev, struct scatterlist *sglist, | 2447 | static void intel_unmap_sg(struct device *hwdev, struct scatterlist *sglist, |
2439 | int nelems, int dir) | 2448 | int nelems, enum dma_data_direction dir, |
2449 | struct dma_attrs *attrs) | ||
2440 | { | 2450 | { |
2441 | int i; | 2451 | int i; |
2442 | struct pci_dev *pdev = to_pci_dev(hwdev); | 2452 | struct pci_dev *pdev = to_pci_dev(hwdev); |
@@ -2493,8 +2503,8 @@ static int intel_nontranslate_map_sg(struct device *hddev, | |||
2493 | return nelems; | 2503 | return nelems; |
2494 | } | 2504 | } |
2495 | 2505 | ||
2496 | int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, int nelems, | 2506 | static int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, int nelems, |
2497 | int dir) | 2507 | enum dma_data_direction dir, struct dma_attrs *attrs) |
2498 | { | 2508 | { |
2499 | void *addr; | 2509 | void *addr; |
2500 | int i; | 2510 | int i; |
@@ -2574,13 +2584,19 @@ int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, int nelems, | |||
2574 | return nelems; | 2584 | return nelems; |
2575 | } | 2585 | } |
2576 | 2586 | ||
2577 | static struct dma_mapping_ops intel_dma_ops = { | 2587 | static int intel_mapping_error(struct device *dev, dma_addr_t dma_addr) |
2588 | { | ||
2589 | return !dma_addr; | ||
2590 | } | ||
2591 | |||
2592 | struct dma_map_ops intel_dma_ops = { | ||
2578 | .alloc_coherent = intel_alloc_coherent, | 2593 | .alloc_coherent = intel_alloc_coherent, |
2579 | .free_coherent = intel_free_coherent, | 2594 | .free_coherent = intel_free_coherent, |
2580 | .map_single = intel_map_single, | ||
2581 | .unmap_single = intel_unmap_single, | ||
2582 | .map_sg = intel_map_sg, | 2595 | .map_sg = intel_map_sg, |
2583 | .unmap_sg = intel_unmap_sg, | 2596 | .unmap_sg = intel_unmap_sg, |
2597 | .map_page = intel_map_page, | ||
2598 | .unmap_page = intel_unmap_page, | ||
2599 | .mapping_error = intel_mapping_error, | ||
2584 | }; | 2600 | }; |
2585 | 2601 | ||
2586 | static inline int iommu_domain_cache_init(void) | 2602 | static inline int iommu_domain_cache_init(void) |