diff options
-rw-r--r-- | arch/x86/kernel/amd_iommu.c | 48 | ||||
-rw-r--r-- | drivers/base/iommu.c | 26 | ||||
-rw-r--r-- | include/linux/iommu.h | 20 |
3 files changed, 2 insertions, 92 deletions
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c index 0e068c9ca5f5..d8da9988edd9 100644 --- a/arch/x86/kernel/amd_iommu.c +++ b/arch/x86/kernel/amd_iommu.c | |||
@@ -2506,52 +2506,6 @@ static int amd_iommu_attach_device(struct iommu_domain *dom, | |||
2506 | return ret; | 2506 | return ret; |
2507 | } | 2507 | } |
2508 | 2508 | ||
2509 | static int amd_iommu_map_range(struct iommu_domain *dom, | ||
2510 | unsigned long iova, phys_addr_t paddr, | ||
2511 | size_t size, int iommu_prot) | ||
2512 | { | ||
2513 | struct protection_domain *domain = dom->priv; | ||
2514 | unsigned long i, npages = iommu_num_pages(paddr, size, PAGE_SIZE); | ||
2515 | int prot = 0; | ||
2516 | int ret; | ||
2517 | |||
2518 | if (iommu_prot & IOMMU_READ) | ||
2519 | prot |= IOMMU_PROT_IR; | ||
2520 | if (iommu_prot & IOMMU_WRITE) | ||
2521 | prot |= IOMMU_PROT_IW; | ||
2522 | |||
2523 | iova &= PAGE_MASK; | ||
2524 | paddr &= PAGE_MASK; | ||
2525 | |||
2526 | for (i = 0; i < npages; ++i) { | ||
2527 | ret = iommu_map_page(domain, iova, paddr, prot, PAGE_SIZE); | ||
2528 | if (ret) | ||
2529 | return ret; | ||
2530 | |||
2531 | iova += PAGE_SIZE; | ||
2532 | paddr += PAGE_SIZE; | ||
2533 | } | ||
2534 | |||
2535 | return 0; | ||
2536 | } | ||
2537 | |||
2538 | static void amd_iommu_unmap_range(struct iommu_domain *dom, | ||
2539 | unsigned long iova, size_t size) | ||
2540 | { | ||
2541 | |||
2542 | struct protection_domain *domain = dom->priv; | ||
2543 | unsigned long i, npages = iommu_num_pages(iova, size, PAGE_SIZE); | ||
2544 | |||
2545 | iova &= PAGE_MASK; | ||
2546 | |||
2547 | for (i = 0; i < npages; ++i) { | ||
2548 | iommu_unmap_page(domain, iova, PAGE_SIZE); | ||
2549 | iova += PAGE_SIZE; | ||
2550 | } | ||
2551 | |||
2552 | iommu_flush_tlb_pde(domain); | ||
2553 | } | ||
2554 | |||
2555 | static int amd_iommu_map(struct iommu_domain *dom, unsigned long iova, | 2509 | static int amd_iommu_map(struct iommu_domain *dom, unsigned long iova, |
2556 | phys_addr_t paddr, int gfp_order, int iommu_prot) | 2510 | phys_addr_t paddr, int gfp_order, int iommu_prot) |
2557 | { | 2511 | { |
@@ -2616,8 +2570,6 @@ static struct iommu_ops amd_iommu_ops = { | |||
2616 | .detach_dev = amd_iommu_detach_device, | 2570 | .detach_dev = amd_iommu_detach_device, |
2617 | .map = amd_iommu_map, | 2571 | .map = amd_iommu_map, |
2618 | .unmap = amd_iommu_unmap, | 2572 | .unmap = amd_iommu_unmap, |
2619 | .map_range = amd_iommu_map_range, | ||
2620 | .unmap_range = amd_iommu_unmap_range, | ||
2621 | .iova_to_phys = amd_iommu_iova_to_phys, | 2573 | .iova_to_phys = amd_iommu_iova_to_phys, |
2622 | .domain_has_cap = amd_iommu_domain_has_cap, | 2574 | .domain_has_cap = amd_iommu_domain_has_cap, |
2623 | }; | 2575 | }; |
diff --git a/drivers/base/iommu.c b/drivers/base/iommu.c index 55d37e4609eb..6e6b6a11b3ce 100644 --- a/drivers/base/iommu.c +++ b/drivers/base/iommu.c | |||
@@ -80,20 +80,6 @@ void iommu_detach_device(struct iommu_domain *domain, struct device *dev) | |||
80 | } | 80 | } |
81 | EXPORT_SYMBOL_GPL(iommu_detach_device); | 81 | EXPORT_SYMBOL_GPL(iommu_detach_device); |
82 | 82 | ||
83 | int iommu_map_range(struct iommu_domain *domain, unsigned long iova, | ||
84 | phys_addr_t paddr, size_t size, int prot) | ||
85 | { | ||
86 | return iommu_ops->map_range(domain, iova, paddr, size, prot); | ||
87 | } | ||
88 | EXPORT_SYMBOL_GPL(iommu_map_range); | ||
89 | |||
90 | void iommu_unmap_range(struct iommu_domain *domain, unsigned long iova, | ||
91 | size_t size) | ||
92 | { | ||
93 | iommu_ops->unmap_range(domain, iova, size); | ||
94 | } | ||
95 | EXPORT_SYMBOL_GPL(iommu_unmap_range); | ||
96 | |||
97 | phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, | 83 | phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, |
98 | unsigned long iova) | 84 | unsigned long iova) |
99 | { | 85 | { |
@@ -119,10 +105,7 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova, | |||
119 | 105 | ||
120 | BUG_ON((iova | paddr) & invalid_mask); | 106 | BUG_ON((iova | paddr) & invalid_mask); |
121 | 107 | ||
122 | if (iommu_ops->map) | 108 | return iommu_ops->map(domain, iova, paddr, gfp_order, prot); |
123 | return iommu_ops->map(domain, iova, paddr, gfp_order, prot); | ||
124 | |||
125 | return iommu_ops->map_range(domain, iova, paddr, size, prot); | ||
126 | } | 109 | } |
127 | EXPORT_SYMBOL_GPL(iommu_map); | 110 | EXPORT_SYMBOL_GPL(iommu_map); |
128 | 111 | ||
@@ -136,11 +119,6 @@ int iommu_unmap(struct iommu_domain *domain, unsigned long iova, int gfp_order) | |||
136 | 119 | ||
137 | BUG_ON(iova & invalid_mask); | 120 | BUG_ON(iova & invalid_mask); |
138 | 121 | ||
139 | if (iommu_ops->unmap) | 122 | return iommu_ops->unmap(domain, iova, gfp_order); |
140 | return iommu_ops->unmap(domain, iova, gfp_order); | ||
141 | |||
142 | iommu_ops->unmap_range(domain, iova, size); | ||
143 | |||
144 | return gfp_order; | ||
145 | } | 123 | } |
146 | EXPORT_SYMBOL_GPL(iommu_unmap); | 124 | EXPORT_SYMBOL_GPL(iommu_unmap); |
diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 5a7a3d888dac..be22ad83689c 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h | |||
@@ -40,10 +40,6 @@ struct iommu_ops { | |||
40 | phys_addr_t paddr, int gfp_order, int prot); | 40 | phys_addr_t paddr, int gfp_order, int prot); |
41 | int (*unmap)(struct iommu_domain *domain, unsigned long iova, | 41 | int (*unmap)(struct iommu_domain *domain, unsigned long iova, |
42 | int gfp_order); | 42 | int gfp_order); |
43 | int (*map_range)(struct iommu_domain *domain, unsigned long iova, | ||
44 | phys_addr_t paddr, size_t size, int prot); | ||
45 | void (*unmap_range)(struct iommu_domain *domain, unsigned long iova, | ||
46 | size_t size); | ||
47 | phys_addr_t (*iova_to_phys)(struct iommu_domain *domain, | 43 | phys_addr_t (*iova_to_phys)(struct iommu_domain *domain, |
48 | unsigned long iova); | 44 | unsigned long iova); |
49 | int (*domain_has_cap)(struct iommu_domain *domain, | 45 | int (*domain_has_cap)(struct iommu_domain *domain, |
@@ -60,10 +56,6 @@ extern int iommu_attach_device(struct iommu_domain *domain, | |||
60 | struct device *dev); | 56 | struct device *dev); |
61 | extern void iommu_detach_device(struct iommu_domain *domain, | 57 | extern void iommu_detach_device(struct iommu_domain *domain, |
62 | struct device *dev); | 58 | struct device *dev); |
63 | extern int iommu_map_range(struct iommu_domain *domain, unsigned long iova, | ||
64 | phys_addr_t paddr, size_t size, int prot); | ||
65 | extern void iommu_unmap_range(struct iommu_domain *domain, unsigned long iova, | ||
66 | size_t size); | ||
67 | extern int iommu_map(struct iommu_domain *domain, unsigned long iova, | 59 | extern int iommu_map(struct iommu_domain *domain, unsigned long iova, |
68 | phys_addr_t paddr, int gfp_order, int prot); | 60 | phys_addr_t paddr, int gfp_order, int prot); |
69 | extern int iommu_unmap(struct iommu_domain *domain, unsigned long iova, | 61 | extern int iommu_unmap(struct iommu_domain *domain, unsigned long iova, |
@@ -104,18 +96,6 @@ static inline void iommu_detach_device(struct iommu_domain *domain, | |||
104 | { | 96 | { |
105 | } | 97 | } |
106 | 98 | ||
107 | static inline int iommu_map_range(struct iommu_domain *domain, | ||
108 | unsigned long iova, phys_addr_t paddr, | ||
109 | size_t size, int prot) | ||
110 | { | ||
111 | return -ENODEV; | ||
112 | } | ||
113 | |||
114 | static inline void iommu_unmap_range(struct iommu_domain *domain, | ||
115 | unsigned long iova, size_t size) | ||
116 | { | ||
117 | } | ||
118 | |||
119 | static inline int iommu_map(struct iommu_domain *domain, unsigned long iova, | 99 | static inline int iommu_map(struct iommu_domain *domain, unsigned long iova, |
120 | phys_addr_t paddr, int gfp_order, int prot) | 100 | phys_addr_t paddr, int gfp_order, int prot) |
121 | { | 101 | { |