mirror of
https://github.com/armbian/linux-cix.git
synced 2026-01-06 12:30:45 -08:00
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 ...
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#include <xen/arm/page-coherent.h>
|
||||
@@ -271,11 +271,7 @@ static void __init free_highpages(void)
|
||||
void __init mem_init(void)
|
||||
{
|
||||
#ifdef CONFIG_ARM_LPAE
|
||||
if (swiotlb_force == SWIOTLB_FORCE ||
|
||||
max_pfn > arm_dma_pfn_limit)
|
||||
swiotlb_init(1);
|
||||
else
|
||||
swiotlb_force = SWIOTLB_NO_FORCE;
|
||||
swiotlb_init(max_pfn > arm_dma_pfn_limit, SWIOTLB_VERBOSE);
|
||||
#endif
|
||||
|
||||
set_max_mapnr(pfn_to_page(max_pfn) - mem_map);
|
||||
|
||||
@@ -23,22 +23,20 @@
|
||||
#include <asm/xen/hypercall.h>
|
||||
#include <asm/xen/interface.h>
|
||||
|
||||
unsigned long xen_get_swiotlb_free_pages(unsigned int order)
|
||||
static gfp_t xen_swiotlb_gfp(void)
|
||||
{
|
||||
phys_addr_t base;
|
||||
gfp_t flags = __GFP_NOWARN|__GFP_KSWAPD_RECLAIM;
|
||||
u64 i;
|
||||
|
||||
for_each_mem_range(i, &base, NULL) {
|
||||
if (base < (phys_addr_t)0xffffffff) {
|
||||
if (IS_ENABLED(CONFIG_ZONE_DMA32))
|
||||
flags |= __GFP_DMA32;
|
||||
else
|
||||
flags |= __GFP_DMA;
|
||||
break;
|
||||
return __GFP_DMA32;
|
||||
return __GFP_DMA;
|
||||
}
|
||||
}
|
||||
return __get_free_pages(flags, order);
|
||||
|
||||
return GFP_KERNEL;
|
||||
}
|
||||
|
||||
static bool hypercall_cflush = false;
|
||||
@@ -118,23 +116,6 @@ bool xen_arch_need_swiotlb(struct device *dev,
|
||||
!dev_is_dma_coherent(dev));
|
||||
}
|
||||
|
||||
int xen_create_contiguous_region(phys_addr_t pstart, unsigned int order,
|
||||
unsigned int address_bits,
|
||||
dma_addr_t *dma_handle)
|
||||
{
|
||||
if (!xen_initial_domain())
|
||||
return -EINVAL;
|
||||
|
||||
/* we assume that dom0 is mapped 1:1 for now */
|
||||
*dma_handle = pstart;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void xen_destroy_contiguous_region(phys_addr_t pstart, unsigned int order)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static int __init xen_mm_init(void)
|
||||
{
|
||||
struct gnttab_cache_flush cflush;
|
||||
@@ -143,10 +124,13 @@ static int __init xen_mm_init(void)
|
||||
if (!xen_swiotlb_detect())
|
||||
return 0;
|
||||
|
||||
rc = xen_swiotlb_init();
|
||||
/* we can work with the default swiotlb */
|
||||
if (rc < 0 && rc != -EEXIST)
|
||||
return rc;
|
||||
if (!io_tlb_default_mem.nslabs) {
|
||||
rc = swiotlb_init_late(swiotlb_size_or_default(),
|
||||
xen_swiotlb_gfp(), NULL);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
}
|
||||
|
||||
cflush.op = 0;
|
||||
cflush.a.dev_bus_addr = 0;
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#include <xen/arm/page-coherent.h>
|
||||
@@ -451,11 +451,7 @@ void __init bootmem_init(void)
|
||||
*/
|
||||
void __init mem_init(void)
|
||||
{
|
||||
if (swiotlb_force == SWIOTLB_FORCE ||
|
||||
max_pfn > PFN_DOWN(arm64_dma_phys_limit))
|
||||
swiotlb_init(1);
|
||||
else if (!xen_swiotlb_detect())
|
||||
swiotlb_force = SWIOTLB_NO_FORCE;
|
||||
swiotlb_init(max_pfn > PFN_DOWN(arm64_dma_phys_limit), SWIOTLB_VERBOSE);
|
||||
|
||||
/* this will put all unused low memory onto the freelists */
|
||||
memblock_free_all();
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#ifndef _ASM_IA64_IOMMU_TABLE_H
|
||||
#define _ASM_IA64_IOMMU_TABLE_H
|
||||
|
||||
#define IOMMU_INIT_POST(_detect)
|
||||
|
||||
#endif /* _ASM_IA64_IOMMU_TABLE_H */
|
||||
@@ -437,9 +437,7 @@ mem_init (void)
|
||||
if (iommu_detected)
|
||||
break;
|
||||
#endif
|
||||
#ifdef CONFIG_SWIOTLB
|
||||
swiotlb_init(1);
|
||||
#endif
|
||||
swiotlb_init(true, SWIOTLB_VERBOSE);
|
||||
} while (0);
|
||||
|
||||
#ifdef CONFIG_FLATMEM
|
||||
|
||||
@@ -186,15 +186,12 @@ phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
|
||||
return daddr;
|
||||
}
|
||||
|
||||
char *octeon_swiotlb;
|
||||
|
||||
void __init plat_swiotlb_setup(void)
|
||||
{
|
||||
phys_addr_t start, end;
|
||||
phys_addr_t max_addr;
|
||||
phys_addr_t addr_size;
|
||||
size_t swiotlbsize;
|
||||
unsigned long swiotlb_nslabs;
|
||||
u64 i;
|
||||
|
||||
max_addr = 0;
|
||||
@@ -236,15 +233,7 @@ void __init plat_swiotlb_setup(void)
|
||||
if (OCTEON_IS_OCTEON2() && max_addr >= 0x100000000ul)
|
||||
swiotlbsize = 64 * (1<<20);
|
||||
#endif
|
||||
swiotlb_nslabs = swiotlbsize >> IO_TLB_SHIFT;
|
||||
swiotlb_nslabs = ALIGN(swiotlb_nslabs, IO_TLB_SEGSIZE);
|
||||
swiotlbsize = swiotlb_nslabs << IO_TLB_SHIFT;
|
||||
|
||||
octeon_swiotlb = memblock_alloc_low(swiotlbsize, PAGE_SIZE);
|
||||
if (!octeon_swiotlb)
|
||||
panic("%s: Failed to allocate %zu bytes align=%lx\n",
|
||||
__func__, swiotlbsize, PAGE_SIZE);
|
||||
|
||||
if (swiotlb_init_with_tbl(octeon_swiotlb, swiotlb_nslabs, 1) == -ENOMEM)
|
||||
panic("Cannot allocate SWIOTLB buffer");
|
||||
swiotlb_adjust_size(swiotlbsize);
|
||||
swiotlb_init(true, SWIOTLB_VERBOSE);
|
||||
}
|
||||
|
||||
@@ -24,5 +24,5 @@ phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
|
||||
|
||||
void __init plat_swiotlb_setup(void)
|
||||
{
|
||||
swiotlb_init(1);
|
||||
swiotlb_init(true, SWIOTLB_VERBOSE);
|
||||
}
|
||||
|
||||
@@ -664,7 +664,7 @@ static int __init octeon_pci_setup(void)
|
||||
|
||||
/* BAR1 movable regions contiguous to cover the swiotlb */
|
||||
octeon_bar1_pci_phys =
|
||||
virt_to_phys(octeon_swiotlb) & ~((1ull << 22) - 1);
|
||||
io_tlb_default_mem.start & ~((1ull << 22) - 1);
|
||||
|
||||
for (index = 0; index < 32; index++) {
|
||||
union cvmx_pci_bar1_indexx bar1_index;
|
||||
|
||||
@@ -10,5 +10,5 @@
|
||||
|
||||
void __init plat_swiotlb_setup(void)
|
||||
{
|
||||
swiotlb_init(1);
|
||||
swiotlb_init(true, SWIOTLB_VERBOSE);
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@ static inline bool is_secure_guest(void)
|
||||
return mfmsr() & MSR_S;
|
||||
}
|
||||
|
||||
void __init svm_swiotlb_init(void);
|
||||
|
||||
void dtl_cache_ctor(void *addr);
|
||||
#define get_dtl_cache_ctor() (is_secure_guest() ? dtl_cache_ctor : NULL)
|
||||
|
||||
@@ -27,8 +25,6 @@ static inline bool is_secure_guest(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline void svm_swiotlb_init(void) {}
|
||||
|
||||
#define get_dtl_cache_ctor() NULL
|
||||
|
||||
#endif /* CONFIG_PPC_SVM */
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <linux/swiotlb.h>
|
||||
|
||||
extern unsigned int ppc_swiotlb_enable;
|
||||
extern unsigned int ppc_swiotlb_flags;
|
||||
|
||||
#ifdef CONFIG_SWIOTLB
|
||||
void swiotlb_detect_4g(void);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <asm/swiotlb.h>
|
||||
|
||||
unsigned int ppc_swiotlb_enable;
|
||||
unsigned int ppc_swiotlb_flags;
|
||||
|
||||
void __init swiotlb_detect_4g(void)
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <linux/suspend.h>
|
||||
#include <linux/dma-direct.h>
|
||||
|
||||
#include <asm/swiotlb.h>
|
||||
#include <asm/machdep.h>
|
||||
#include <asm/rtas.h>
|
||||
#include <asm/kasan.h>
|
||||
@@ -248,10 +249,7 @@ void __init mem_init(void)
|
||||
* back to to-down.
|
||||
*/
|
||||
memblock_set_bottom_up(true);
|
||||
if (is_secure_guest())
|
||||
svm_swiotlb_init();
|
||||
else
|
||||
swiotlb_init(0);
|
||||
swiotlb_init(ppc_swiotlb_enable, ppc_swiotlb_flags);
|
||||
#endif
|
||||
|
||||
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
|
||||
|
||||
@@ -849,9 +849,6 @@ static void __init pSeries_setup_arch(void)
|
||||
}
|
||||
|
||||
ppc_md.pcibios_root_bridge_prepare = pseries_root_bridge_prepare;
|
||||
|
||||
if (swiotlb_force == SWIOTLB_FORCE)
|
||||
ppc_swiotlb_enable = 1;
|
||||
}
|
||||
|
||||
static void pseries_panic(char *str)
|
||||
|
||||
@@ -28,7 +28,7 @@ static int __init init_svm(void)
|
||||
* need to use the SWIOTLB buffer for DMA even if dma_capable() says
|
||||
* otherwise.
|
||||
*/
|
||||
swiotlb_force = SWIOTLB_FORCE;
|
||||
ppc_swiotlb_flags |= SWIOTLB_ANY | SWIOTLB_FORCE;
|
||||
|
||||
/* Share the SWIOTLB buffer with the host. */
|
||||
swiotlb_update_mem_attributes();
|
||||
@@ -37,30 +37,6 @@ static int __init init_svm(void)
|
||||
}
|
||||
machine_early_initcall(pseries, init_svm);
|
||||
|
||||
/*
|
||||
* Initialize SWIOTLB. Essentially the same as swiotlb_init(), except that it
|
||||
* can allocate the buffer anywhere in memory. Since the hypervisor doesn't have
|
||||
* any addressing limitation, we don't need to allocate it in low addresses.
|
||||
*/
|
||||
void __init svm_swiotlb_init(void)
|
||||
{
|
||||
unsigned char *vstart;
|
||||
unsigned long bytes, io_tlb_nslabs;
|
||||
|
||||
io_tlb_nslabs = (swiotlb_size_or_default() >> IO_TLB_SHIFT);
|
||||
io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
|
||||
|
||||
bytes = io_tlb_nslabs << IO_TLB_SHIFT;
|
||||
|
||||
vstart = memblock_alloc(PAGE_ALIGN(bytes), PAGE_SIZE);
|
||||
if (vstart && !swiotlb_init_with_tbl(vstart, io_tlb_nslabs, false))
|
||||
return;
|
||||
|
||||
|
||||
memblock_free(vstart, PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT));
|
||||
panic("SVM: Cannot allocate SWIOTLB buffer");
|
||||
}
|
||||
|
||||
int set_memory_encrypted(unsigned long addr, int numpages)
|
||||
{
|
||||
if (!cc_platform_has(CC_ATTR_MEM_ENCRYPT))
|
||||
|
||||
@@ -120,13 +120,7 @@ void __init mem_init(void)
|
||||
BUG_ON(!mem_map);
|
||||
#endif /* CONFIG_FLATMEM */
|
||||
|
||||
#ifdef CONFIG_SWIOTLB
|
||||
if (swiotlb_force == SWIOTLB_FORCE ||
|
||||
max_pfn > PFN_DOWN(dma32_phys_limit))
|
||||
swiotlb_init(1);
|
||||
else
|
||||
swiotlb_force = SWIOTLB_NO_FORCE;
|
||||
#endif
|
||||
swiotlb_init(max_pfn > PFN_DOWN(dma32_phys_limit), SWIOTLB_VERBOSE);
|
||||
memblock_free_all();
|
||||
|
||||
print_vm_layout();
|
||||
|
||||
@@ -185,8 +185,7 @@ static void pv_init(void)
|
||||
return;
|
||||
|
||||
/* make sure bounce buffers are shared */
|
||||
swiotlb_force = SWIOTLB_FORCE;
|
||||
swiotlb_init(1);
|
||||
swiotlb_init(true, SWIOTLB_FORCE | SWIOTLB_VERBOSE);
|
||||
swiotlb_update_mem_attributes();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,18 +2,6 @@
|
||||
#ifndef _ASM_X86_DMA_MAPPING_H
|
||||
#define _ASM_X86_DMA_MAPPING_H
|
||||
|
||||
/*
|
||||
* IOMMU interface. See Documentation/core-api/dma-api-howto.rst and
|
||||
* Documentation/core-api/dma-api.rst for documentation.
|
||||
*/
|
||||
|
||||
#include <linux/scatterlist.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/swiotlb.h>
|
||||
|
||||
extern int iommu_merge;
|
||||
extern int panic_on_overflow;
|
||||
|
||||
extern const struct dma_map_ops *dma_ops;
|
||||
|
||||
static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user