Skip to content

Commit c2b2e5c

Browse files
committed
Merge branch 'iommu/core' into iommu/next
* iommu/core: docs: iommu: Remove outdated Documentation/userspace-api/iommu.rst iommufd: Use atomic_long_try_cmpxchg() in incr_user_locked_vm() iommu/iova: Add missing MODULE_DESCRIPTION() macro iommu/dma: Prune redundant pgprot arguments iommu: Make iommu_sva_domain_alloc() static
2 parents 710f107 + 2281598 commit c2b2e5c

File tree

8 files changed

+15
-234
lines changed

8 files changed

+15
-234
lines changed

Documentation/userspace-api/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ Devices and I/O
4444
accelerators/ocxl
4545
dma-buf-alloc-exchange
4646
gpio/index
47-
iommu
4847
iommufd
4948
media/index
5049
dcdbas

Documentation/userspace-api/iommu.rst

Lines changed: 0 additions & 209 deletions
This file was deleted.

MAINTAINERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11543,7 +11543,6 @@ L: [email protected]
1154311543
S: Maintained
1154411544
T: git git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git
1154511545
F: Documentation/devicetree/bindings/iommu/
11546-
F: Documentation/userspace-api/iommu.rst
1154711546
F: drivers/iommu/
1154811547
F: include/linux/iommu.h
1154911548
F: include/linux/iova.h

drivers/iommu/dma-iommu.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -939,8 +939,7 @@ static struct page **__iommu_dma_alloc_pages(struct device *dev,
939939
* but an IOMMU which supports smaller pages might not map the whole thing.
940940
*/
941941
static struct page **__iommu_dma_alloc_noncontiguous(struct device *dev,
942-
size_t size, struct sg_table *sgt, gfp_t gfp, pgprot_t prot,
943-
unsigned long attrs)
942+
size_t size, struct sg_table *sgt, gfp_t gfp, unsigned long attrs)
944943
{
945944
struct iommu_domain *domain = iommu_get_dma_domain(dev);
946945
struct iommu_dma_cookie *cookie = domain->iova_cookie;
@@ -1014,15 +1013,14 @@ static struct page **__iommu_dma_alloc_noncontiguous(struct device *dev,
10141013
}
10151014

10161015
static void *iommu_dma_alloc_remap(struct device *dev, size_t size,
1017-
dma_addr_t *dma_handle, gfp_t gfp, pgprot_t prot,
1018-
unsigned long attrs)
1016+
dma_addr_t *dma_handle, gfp_t gfp, unsigned long attrs)
10191017
{
10201018
struct page **pages;
10211019
struct sg_table sgt;
10221020
void *vaddr;
1021+
pgprot_t prot = dma_pgprot(dev, PAGE_KERNEL, attrs);
10231022

1024-
pages = __iommu_dma_alloc_noncontiguous(dev, size, &sgt, gfp, prot,
1025-
attrs);
1023+
pages = __iommu_dma_alloc_noncontiguous(dev, size, &sgt, gfp, attrs);
10261024
if (!pages)
10271025
return NULL;
10281026
*dma_handle = sgt.sgl->dma_address;
@@ -1049,8 +1047,7 @@ static struct sg_table *iommu_dma_alloc_noncontiguous(struct device *dev,
10491047
if (!sh)
10501048
return NULL;
10511049

1052-
sh->pages = __iommu_dma_alloc_noncontiguous(dev, size, &sh->sgt, gfp,
1053-
PAGE_KERNEL, attrs);
1050+
sh->pages = __iommu_dma_alloc_noncontiguous(dev, size, &sh->sgt, gfp, attrs);
10541051
if (!sh->pages) {
10551052
kfree(sh);
10561053
return NULL;
@@ -1619,8 +1616,7 @@ static void *iommu_dma_alloc(struct device *dev, size_t size,
16191616

16201617
if (gfpflags_allow_blocking(gfp) &&
16211618
!(attrs & DMA_ATTR_FORCE_CONTIGUOUS)) {
1622-
return iommu_dma_alloc_remap(dev, size, handle, gfp,
1623-
dma_pgprot(dev, PAGE_KERNEL, attrs), attrs);
1619+
return iommu_dma_alloc_remap(dev, size, handle, gfp, attrs);
16241620
}
16251621

16261622
if (IS_ENABLED(CONFIG_DMA_DIRECT_REMAP) &&

drivers/iommu/iommu-sva.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include "iommu-priv.h"
1111

1212
static DEFINE_MUTEX(iommu_sva_lock);
13+
static struct iommu_domain *iommu_sva_domain_alloc(struct device *dev,
14+
struct mm_struct *mm);
1315

1416
/* Allocate a PASID for the mm within range (inclusive) */
1517
static struct iommu_mm_data *iommu_alloc_mm_data(struct mm_struct *mm, struct device *dev)
@@ -277,8 +279,8 @@ static int iommu_sva_iopf_handler(struct iopf_group *group)
277279
return 0;
278280
}
279281

280-
struct iommu_domain *iommu_sva_domain_alloc(struct device *dev,
281-
struct mm_struct *mm)
282+
static struct iommu_domain *iommu_sva_domain_alloc(struct device *dev,
283+
struct mm_struct *mm)
282284
{
283285
const struct iommu_ops *ops = dev_iommu_ops(dev);
284286
struct iommu_domain *domain;

drivers/iommu/iommufd/pages.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -809,13 +809,14 @@ static int incr_user_locked_vm(struct iopt_pages *pages, unsigned long npages)
809809

810810
lock_limit = task_rlimit(pages->source_task, RLIMIT_MEMLOCK) >>
811811
PAGE_SHIFT;
812+
813+
cur_pages = atomic_long_read(&pages->source_user->locked_vm);
812814
do {
813-
cur_pages = atomic_long_read(&pages->source_user->locked_vm);
814815
new_pages = cur_pages + npages;
815816
if (new_pages > lock_limit)
816817
return -ENOMEM;
817-
} while (atomic_long_cmpxchg(&pages->source_user->locked_vm, cur_pages,
818-
new_pages) != cur_pages);
818+
} while (!atomic_long_try_cmpxchg(&pages->source_user->locked_vm,
819+
&cur_pages, new_pages));
819820
return 0;
820821
}
821822

drivers/iommu/iova.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,4 +1000,5 @@ void iova_cache_put(void)
10001000
EXPORT_SYMBOL_GPL(iova_cache_put);
10011001

10021002
MODULE_AUTHOR("Anil S Keshavamurthy <[email protected]>");
1003+
MODULE_DESCRIPTION("IOMMU I/O Virtual Address management");
10031004
MODULE_LICENSE("GPL");

include/linux/iommu.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,8 +1527,6 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev,
15271527
struct mm_struct *mm);
15281528
void iommu_sva_unbind_device(struct iommu_sva *handle);
15291529
u32 iommu_sva_get_pasid(struct iommu_sva *handle);
1530-
struct iommu_domain *iommu_sva_domain_alloc(struct device *dev,
1531-
struct mm_struct *mm);
15321530
#else
15331531
static inline struct iommu_sva *
15341532
iommu_sva_bind_device(struct device *dev, struct mm_struct *mm)
@@ -1553,12 +1551,6 @@ static inline u32 mm_get_enqcmd_pasid(struct mm_struct *mm)
15531551
}
15541552

15551553
static inline void mm_pasid_drop(struct mm_struct *mm) {}
1556-
1557-
static inline struct iommu_domain *
1558-
iommu_sva_domain_alloc(struct device *dev, struct mm_struct *mm)
1559-
{
1560-
return NULL;
1561-
}
15621554
#endif /* CONFIG_IOMMU_SVA */
15631555

15641556
#ifdef CONFIG_IOMMU_IOPF

0 commit comments

Comments
 (0)