Skip to content

Commit 3f306ea

Browse files
committed
Merge tag 'dma-mapping-5.19-2022-05-25' of git://git.infradead.org/users/hch/dma-mapping
Pull dma-mapping updates from Christoph Hellwig: - don't over-decrypt memory (Robin Murphy) - takes min align mask into account for the swiotlb max mapping size (Tianyu Lan) - use GFP_ATOMIC in dma-debug (Mikulas Patocka) - fix DMA_ATTR_NO_KERNEL_MAPPING on xen/arm (me) - don't fail on highmem CMA pages in dma_direct_alloc_pages (me) - cleanup swiotlb initialization and share more code with swiotlb-xen (me, Stefano Stabellini) * tag 'dma-mapping-5.19-2022-05-25' of git://git.infradead.org/users/hch/dma-mapping: (23 commits) dma-direct: don't over-decrypt memory swiotlb: max mapping size takes min align mask into account swiotlb: use the right nslabs-derived sizes in swiotlb_init_late swiotlb: use the right nslabs value in swiotlb_init_remap swiotlb: don't panic when the swiotlb buffer can't be allocated dma-debug: change allocation mode from GFP_NOWAIT to GFP_ATIOMIC dma-direct: don't fail on highmem CMA pages in dma_direct_alloc_pages swiotlb-xen: fix DMA_ATTR_NO_KERNEL_MAPPING on arm x86: remove cruft from <asm/dma-mapping.h> swiotlb: remove swiotlb_init_with_tbl and swiotlb_init_late_with_tbl swiotlb: merge swiotlb-xen initialization into swiotlb swiotlb: provide swiotlb_init variants that remap the buffer swiotlb: pass a gfp_mask argument to swiotlb_init_late swiotlb: add a SWIOTLB_ANY flag to lift the low memory restriction swiotlb: make the swiotlb_init interface more useful x86: centralize setting SWIOTLB_FORCE when guest memory encryption is enabled x86: remove the IOMMU table infrastructure MIPS/octeon: use swiotlb_init instead of open coding it arm/xen: don't check for xen_initial_domain() in xen_create_contiguous_region swiotlb: rename swiotlb_late_init_with_default_size ...
2 parents fbe86da + 4a37f3d commit 3f306ea

56 files changed

Lines changed: 319 additions & 983 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

arch/arm/include/asm/xen/page-coherent.h

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

arch/arm/mm/init.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,7 @@ static void __init free_highpages(void)
271271
void __init mem_init(void)
272272
{
273273
#ifdef CONFIG_ARM_LPAE
274-
if (swiotlb_force == SWIOTLB_FORCE ||
275-
max_pfn > arm_dma_pfn_limit)
276-
swiotlb_init(1);
277-
else
278-
swiotlb_force = SWIOTLB_NO_FORCE;
274+
swiotlb_init(max_pfn > arm_dma_pfn_limit, SWIOTLB_VERBOSE);
279275
#endif
280276

281277
set_max_mapnr(pfn_to_page(max_pfn) - mem_map);

arch/arm/xen/mm.c

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,20 @@
2323
#include <asm/xen/hypercall.h>
2424
#include <asm/xen/interface.h>
2525

26-
unsigned long xen_get_swiotlb_free_pages(unsigned int order)
26+
static gfp_t xen_swiotlb_gfp(void)
2727
{
2828
phys_addr_t base;
29-
gfp_t flags = __GFP_NOWARN|__GFP_KSWAPD_RECLAIM;
3029
u64 i;
3130

3231
for_each_mem_range(i, &base, NULL) {
3332
if (base < (phys_addr_t)0xffffffff) {
3433
if (IS_ENABLED(CONFIG_ZONE_DMA32))
35-
flags |= __GFP_DMA32;
36-
else
37-
flags |= __GFP_DMA;
38-
break;
34+
return __GFP_DMA32;
35+
return __GFP_DMA;
3936
}
4037
}
41-
return __get_free_pages(flags, order);
38+
39+
return GFP_KERNEL;
4240
}
4341

4442
static bool hypercall_cflush = false;
@@ -118,23 +116,6 @@ bool xen_arch_need_swiotlb(struct device *dev,
118116
!dev_is_dma_coherent(dev));
119117
}
120118

121-
int xen_create_contiguous_region(phys_addr_t pstart, unsigned int order,
122-
unsigned int address_bits,
123-
dma_addr_t *dma_handle)
124-
{
125-
if (!xen_initial_domain())
126-
return -EINVAL;
127-
128-
/* we assume that dom0 is mapped 1:1 for now */
129-
*dma_handle = pstart;
130-
return 0;
131-
}
132-
133-
void xen_destroy_contiguous_region(phys_addr_t pstart, unsigned int order)
134-
{
135-
return;
136-
}
137-
138119
static int __init xen_mm_init(void)
139120
{
140121
struct gnttab_cache_flush cflush;
@@ -143,10 +124,13 @@ static int __init xen_mm_init(void)
143124
if (!xen_swiotlb_detect())
144125
return 0;
145126

146-
rc = xen_swiotlb_init();
147127
/* we can work with the default swiotlb */
148-
if (rc < 0 && rc != -EEXIST)
149-
return rc;
128+
if (!io_tlb_default_mem.nslabs) {
129+
rc = swiotlb_init_late(swiotlb_size_or_default(),
130+
xen_swiotlb_gfp(), NULL);
131+
if (rc < 0)
132+
return rc;
133+
}
150134

151135
cflush.op = 0;
152136
cflush.a.dev_bus_addr = 0;

arch/arm64/include/asm/xen/page-coherent.h

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

arch/arm64/mm/init.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,7 @@ void __init bootmem_init(void)
451451
*/
452452
void __init mem_init(void)
453453
{
454-
if (swiotlb_force == SWIOTLB_FORCE ||
455-
max_pfn > PFN_DOWN(arm64_dma_phys_limit))
456-
swiotlb_init(1);
457-
else if (!xen_swiotlb_detect())
458-
swiotlb_force = SWIOTLB_NO_FORCE;
454+
swiotlb_init(max_pfn > PFN_DOWN(arm64_dma_phys_limit), SWIOTLB_VERBOSE);
459455

460456
/* this will put all unused low memory onto the freelists */
461457
memblock_free_all();

arch/ia64/include/asm/iommu_table.h

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

arch/ia64/mm/init.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,7 @@ mem_init (void)
437437
if (iommu_detected)
438438
break;
439439
#endif
440-
#ifdef CONFIG_SWIOTLB
441-
swiotlb_init(1);
442-
#endif
440+
swiotlb_init(true, SWIOTLB_VERBOSE);
443441
} while (0);
444442

445443
#ifdef CONFIG_FLATMEM

arch/mips/cavium-octeon/dma-octeon.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,12 @@ phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
186186
return daddr;
187187
}
188188

189-
char *octeon_swiotlb;
190-
191189
void __init plat_swiotlb_setup(void)
192190
{
193191
phys_addr_t start, end;
194192
phys_addr_t max_addr;
195193
phys_addr_t addr_size;
196194
size_t swiotlbsize;
197-
unsigned long swiotlb_nslabs;
198195
u64 i;
199196

200197
max_addr = 0;
@@ -236,15 +233,7 @@ void __init plat_swiotlb_setup(void)
236233
if (OCTEON_IS_OCTEON2() && max_addr >= 0x100000000ul)
237234
swiotlbsize = 64 * (1<<20);
238235
#endif
239-
swiotlb_nslabs = swiotlbsize >> IO_TLB_SHIFT;
240-
swiotlb_nslabs = ALIGN(swiotlb_nslabs, IO_TLB_SEGSIZE);
241-
swiotlbsize = swiotlb_nslabs << IO_TLB_SHIFT;
242-
243-
octeon_swiotlb = memblock_alloc_low(swiotlbsize, PAGE_SIZE);
244-
if (!octeon_swiotlb)
245-
panic("%s: Failed to allocate %zu bytes align=%lx\n",
246-
__func__, swiotlbsize, PAGE_SIZE);
247236

248-
if (swiotlb_init_with_tbl(octeon_swiotlb, swiotlb_nslabs, 1) == -ENOMEM)
249-
panic("Cannot allocate SWIOTLB buffer");
237+
swiotlb_adjust_size(swiotlbsize);
238+
swiotlb_init(true, SWIOTLB_VERBOSE);
250239
}

arch/mips/loongson64/dma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
2424

2525
void __init plat_swiotlb_setup(void)
2626
{
27-
swiotlb_init(1);
27+
swiotlb_init(true, SWIOTLB_VERBOSE);
2828
}

arch/mips/pci/pci-octeon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ static int __init octeon_pci_setup(void)
664664

665665
/* BAR1 movable regions contiguous to cover the swiotlb */
666666
octeon_bar1_pci_phys =
667-
virt_to_phys(octeon_swiotlb) & ~((1ull << 22) - 1);
667+
io_tlb_default_mem.start & ~((1ull << 22) - 1);
668668

669669
for (index = 0; index < 32; index++) {
670670
union cvmx_pci_bar1_indexx bar1_index;

0 commit comments

Comments
 (0)