diff options
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/intel-iommu.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c index 93ed771b3254..05630b44dbfc 100644 --- a/drivers/pci/intel-iommu.c +++ b/drivers/pci/intel-iommu.c | |||
@@ -85,9 +85,31 @@ static struct kmem_cache *iommu_domain_cache; | |||
85 | static struct kmem_cache *iommu_devinfo_cache; | 85 | static struct kmem_cache *iommu_devinfo_cache; |
86 | static struct kmem_cache *iommu_iova_cache; | 86 | static struct kmem_cache *iommu_iova_cache; |
87 | 87 | ||
88 | static inline void *iommu_kmem_cache_alloc(struct kmem_cache *cachep) | ||
89 | { | ||
90 | unsigned int flags; | ||
91 | void *vaddr; | ||
92 | |||
93 | /* trying to avoid low memory issues */ | ||
94 | flags = current->flags & PF_MEMALLOC; | ||
95 | current->flags |= PF_MEMALLOC; | ||
96 | vaddr = kmem_cache_alloc(cachep, GFP_ATOMIC); | ||
97 | current->flags &= (~PF_MEMALLOC | flags); | ||
98 | return vaddr; | ||
99 | } | ||
100 | |||
101 | |||
88 | static inline void *alloc_pgtable_page(void) | 102 | static inline void *alloc_pgtable_page(void) |
89 | { | 103 | { |
90 | return (void *)get_zeroed_page(GFP_ATOMIC); | 104 | unsigned int flags; |
105 | void *vaddr; | ||
106 | |||
107 | /* trying to avoid low memory issues */ | ||
108 | flags = current->flags & PF_MEMALLOC; | ||
109 | current->flags |= PF_MEMALLOC; | ||
110 | vaddr = (void *)get_zeroed_page(GFP_ATOMIC); | ||
111 | current->flags &= (~PF_MEMALLOC | flags); | ||
112 | return vaddr; | ||
91 | } | 113 | } |
92 | 114 | ||
93 | static inline void free_pgtable_page(void *vaddr) | 115 | static inline void free_pgtable_page(void *vaddr) |
@@ -97,7 +119,7 @@ static inline void free_pgtable_page(void *vaddr) | |||
97 | 119 | ||
98 | static inline void *alloc_domain_mem(void) | 120 | static inline void *alloc_domain_mem(void) |
99 | { | 121 | { |
100 | return kmem_cache_alloc(iommu_domain_cache, GFP_ATOMIC); | 122 | return iommu_kmem_cache_alloc(iommu_domain_cache); |
101 | } | 123 | } |
102 | 124 | ||
103 | static inline void free_domain_mem(void *vaddr) | 125 | static inline void free_domain_mem(void *vaddr) |
@@ -107,7 +129,7 @@ static inline void free_domain_mem(void *vaddr) | |||
107 | 129 | ||
108 | static inline void * alloc_devinfo_mem(void) | 130 | static inline void * alloc_devinfo_mem(void) |
109 | { | 131 | { |
110 | return kmem_cache_alloc(iommu_devinfo_cache, GFP_ATOMIC); | 132 | return iommu_kmem_cache_alloc(iommu_devinfo_cache); |
111 | } | 133 | } |
112 | 134 | ||
113 | static inline void free_devinfo_mem(void *vaddr) | 135 | static inline void free_devinfo_mem(void *vaddr) |
@@ -117,7 +139,7 @@ static inline void free_devinfo_mem(void *vaddr) | |||
117 | 139 | ||
118 | struct iova *alloc_iova_mem(void) | 140 | struct iova *alloc_iova_mem(void) |
119 | { | 141 | { |
120 | return kmem_cache_alloc(iommu_iova_cache, GFP_ATOMIC); | 142 | return iommu_kmem_cache_alloc(iommu_iova_cache); |
121 | } | 143 | } |
122 | 144 | ||
123 | void free_iova_mem(struct iova *iova) | 145 | void free_iova_mem(struct iova *iova) |