Merge tag 'dma-mapping-4.21' of git://git.infradead.org/users/hch/dma-mapping
Pull DMA mapping updates from Christoph Hellwig: "A huge update this time, but a lot of that is just consolidating or removing code: - provide a common DMA_MAPPING_ERROR definition and avoid indirect calls for dma_map_* error checking - use direct calls for the DMA direct mapping case, avoiding huge retpoline overhead for high performance workloads - merge the swiotlb dma_map_ops into dma-direct - provide a generic remapping DMA consistent allocator for architectures that have devices that perform DMA that is not cache coherent. Based on the existing arm64 implementation and also used for csky now. - improve the dma-debug infrastructure, including dynamic allocation of entries (Robin Murphy) - default to providing chaining scatterlist everywhere, with opt-outs for the few architectures (alpha, parisc, most arm32 variants) that can't cope with it - misc sparc32 dma-related cleanups - remove the dma_mark_clean arch hook used by swiotlb on ia64 and replace it with the generic noncoherent infrastructure - fix the return type of dma_set_max_seg_size (Niklas Söderlund) - move the dummy dma ops for not DMA capable devices from arm64 to common code (Robin Murphy) - ensure dma_alloc_coherent returns zeroed memory to avoid kernel data leaks through userspace. We already did this for most common architectures, but this ensures we do it everywhere. dma_zalloc_coherent has been deprecated and can hopefully be removed after -rc1 with a coccinelle script" * tag 'dma-mapping-4.21' of git://git.infradead.org/users/hch/dma-mapping: (73 commits) dma-mapping: fix inverted logic in dma_supported dma-mapping: deprecate dma_zalloc_coherent dma-mapping: zero memory returned from dma_alloc_* sparc/iommu: fix ->map_sg return value sparc/io-unit: fix ->map_sg return value arm64: default to the direct mapping in get_arch_dma_ops PCI: Remove unused attr variable in pci_dma_configure ia64: only select ARCH_HAS_DMA_COHERENT_TO_PFN if swiotlb is enabled dma-mapping: bypass indirect calls for dma-direct vmd: use the proper dma_* APIs instead of direct methods calls dma-direct: merge swiotlb_dma_ops into the dma_direct code dma-direct: use dma_direct_map_page to implement dma_direct_map_sg dma-direct: improve addressability error reporting swiotlb: remove dma_mark_clean swiotlb: remove SWIOTLB_MAP_ERROR ACPI / scan: Refactor _CCA enforcement dma-mapping: factor out dummy DMA ops dma-mapping: always build the direct mapping code dma-mapping: move dma_cache_sync out of line dma-mapping: move various slow path functions out of line ...
This commit is contained in:
@@ -2,9 +2,7 @@
|
||||
#ifndef ___ASM_SPARC_DMA_MAPPING_H
|
||||
#define ___ASM_SPARC_DMA_MAPPING_H
|
||||
|
||||
#include <linux/scatterlist.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/dma-debug.h>
|
||||
#include <asm/cpu_type.h>
|
||||
|
||||
extern const struct dma_map_ops *dma_ops;
|
||||
|
||||
@@ -14,11 +12,11 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
|
||||
{
|
||||
#ifdef CONFIG_SPARC_LEON
|
||||
if (sparc_cpu_model == sparc_leon)
|
||||
return &dma_direct_ops;
|
||||
return NULL;
|
||||
#endif
|
||||
#if defined(CONFIG_SPARC32) && defined(CONFIG_PCI)
|
||||
if (bus == &pci_bus_type)
|
||||
return &dma_direct_ops;
|
||||
return NULL;
|
||||
#endif
|
||||
return dma_ops;
|
||||
}
|
||||
|
@@ -91,54 +91,10 @@ extern int isa_dma_bridge_buggy;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SPARC32
|
||||
|
||||
/* Routines for data transfer buffers. */
|
||||
struct device;
|
||||
struct scatterlist;
|
||||
|
||||
struct sparc32_dma_ops {
|
||||
__u32 (*get_scsi_one)(struct device *, char *, unsigned long);
|
||||
void (*get_scsi_sgl)(struct device *, struct scatterlist *, int);
|
||||
void (*release_scsi_one)(struct device *, __u32, unsigned long);
|
||||
void (*release_scsi_sgl)(struct device *, struct scatterlist *,int);
|
||||
#ifdef CONFIG_SBUS
|
||||
int (*map_dma_area)(struct device *, dma_addr_t *, unsigned long, unsigned long, int);
|
||||
void (*unmap_dma_area)(struct device *, unsigned long, int);
|
||||
#endif
|
||||
};
|
||||
extern const struct sparc32_dma_ops *sparc32_dma_ops;
|
||||
|
||||
#define mmu_get_scsi_one(dev,vaddr,len) \
|
||||
sparc32_dma_ops->get_scsi_one(dev, vaddr, len)
|
||||
#define mmu_get_scsi_sgl(dev,sg,sz) \
|
||||
sparc32_dma_ops->get_scsi_sgl(dev, sg, sz)
|
||||
#define mmu_release_scsi_one(dev,vaddr,len) \
|
||||
sparc32_dma_ops->release_scsi_one(dev, vaddr,len)
|
||||
#define mmu_release_scsi_sgl(dev,sg,sz) \
|
||||
sparc32_dma_ops->release_scsi_sgl(dev, sg, sz)
|
||||
|
||||
#ifdef CONFIG_SBUS
|
||||
/*
|
||||
* mmu_map/unmap are provided by iommu/iounit; Invalid to call on IIep.
|
||||
*
|
||||
* The mmu_map_dma_area establishes two mappings in one go.
|
||||
* These mappings point to pages normally mapped at 'va' (linear address).
|
||||
* First mapping is for CPU visible address at 'a', uncached.
|
||||
* This is an alias, but it works because it is an uncached mapping.
|
||||
* Second mapping is for device visible address, or "bus" address.
|
||||
* The bus address is returned at '*pba'.
|
||||
*
|
||||
* These functions seem distinct, but are hard to split.
|
||||
* On sun4m, page attributes depend on the CPU type, so we have to
|
||||
* know if we are mapping RAM or I/O, so it has to be an additional argument
|
||||
* to a separate mapping function for CPU visible mappings.
|
||||
*/
|
||||
#define sbus_map_dma_area(dev,pba,va,a,len) \
|
||||
sparc32_dma_ops->map_dma_area(dev, pba, va, a, len)
|
||||
#define sbus_unmap_dma_area(dev,ba,len) \
|
||||
sparc32_dma_ops->unmap_dma_area(dev, ba, len)
|
||||
#endif /* CONFIG_SBUS */
|
||||
|
||||
unsigned long sparc_dma_alloc_resource(struct device *dev, size_t len);
|
||||
bool sparc_dma_free_resource(void *cpu_addr, size_t size);
|
||||
#endif
|
||||
|
||||
#endif /* !(_ASM_SPARC_DMA_H) */
|
||||
|
@@ -254,4 +254,13 @@ extern int leon_ipi_irq;
|
||||
#define _pfn_valid(pfn) ((pfn < last_valid_pfn) && (pfn >= PFN(phys_base)))
|
||||
#define _SRMMU_PTE_PMASK_LEON 0xffffffff
|
||||
|
||||
/*
|
||||
* On LEON PCI Memory space is mapped 1:1 with physical address space.
|
||||
*
|
||||
* I/O space is located at low 64Kbytes in PCI I/O space. The I/O addresses
|
||||
* are converted into CPU addresses to virtual addresses that are mapped with
|
||||
* MMU to the PCI Host PCI I/O space window which are translated to the low
|
||||
* 64Kbytes by the Host controller.
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
@@ -1,9 +1,54 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#ifndef ___ASM_SPARC_PCI_H
|
||||
#define ___ASM_SPARC_PCI_H
|
||||
#if defined(__sparc__) && defined(__arch64__)
|
||||
#include <asm/pci_64.h>
|
||||
|
||||
|
||||
/* Can be used to override the logic in pci_scan_bus for skipping
|
||||
* already-configured bus numbers - to be used for buggy BIOSes
|
||||
* or architectures with incomplete PCI setup by the loader.
|
||||
*/
|
||||
#define pcibios_assign_all_busses() 0
|
||||
|
||||
#define PCIBIOS_MIN_IO 0UL
|
||||
#define PCIBIOS_MIN_MEM 0UL
|
||||
|
||||
#define PCI_IRQ_NONE 0xffffffff
|
||||
|
||||
|
||||
#ifdef CONFIG_SPARC64
|
||||
|
||||
/* PCI IOMMU mapping bypass support. */
|
||||
|
||||
/* PCI 64-bit addressing works for all slots on all controller
|
||||
* types on sparc64. However, it requires that the device
|
||||
* can drive enough of the 64 bits.
|
||||
*/
|
||||
#define PCI64_REQUIRED_MASK (~(u64)0)
|
||||
#define PCI64_ADDR_BASE 0xfffc000000000000UL
|
||||
|
||||
/* Return the index of the PCI controller for device PDEV. */
|
||||
int pci_domain_nr(struct pci_bus *bus);
|
||||
static inline int pci_proc_domain(struct pci_bus *bus)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Platform support for /proc/bus/pci/X/Y mmap()s. */
|
||||
#define HAVE_PCI_MMAP
|
||||
#define arch_can_pci_mmap_io() 1
|
||||
#define HAVE_ARCH_PCI_GET_UNMAPPED_AREA
|
||||
#define get_pci_unmapped_area get_fb_unmapped_area
|
||||
|
||||
#define HAVE_ARCH_PCI_RESOURCE_TO_USER
|
||||
#endif /* CONFIG_SPARC64 */
|
||||
|
||||
#if defined(CONFIG_SPARC64) || defined(CONFIG_LEON_PCI)
|
||||
static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
|
||||
{
|
||||
return PCI_IRQ_NONE;
|
||||
}
|
||||
#else
|
||||
#include <asm/pci_32.h>
|
||||
#endif
|
||||
#include <asm-generic/pci.h>
|
||||
#endif
|
||||
|
||||
#endif /* ___ASM_SPARC_PCI_H */
|
||||
|
@@ -1,41 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#ifndef __SPARC_PCI_H
|
||||
#define __SPARC_PCI_H
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
#include <linux/dma-mapping.h>
|
||||
|
||||
/* Can be used to override the logic in pci_scan_bus for skipping
|
||||
* already-configured bus numbers - to be used for buggy BIOSes
|
||||
* or architectures with incomplete PCI setup by the loader.
|
||||
*/
|
||||
#define pcibios_assign_all_busses() 0
|
||||
|
||||
#define PCIBIOS_MIN_IO 0UL
|
||||
#define PCIBIOS_MIN_MEM 0UL
|
||||
|
||||
#define PCI_IRQ_NONE 0xffffffff
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#ifndef CONFIG_LEON_PCI
|
||||
/* generic pci stuff */
|
||||
#include <asm-generic/pci.h>
|
||||
#else
|
||||
/*
|
||||
* On LEON PCI Memory space is mapped 1:1 with physical address space.
|
||||
*
|
||||
* I/O space is located at low 64Kbytes in PCI I/O space. The I/O addresses
|
||||
* are converted into CPU addresses to virtual addresses that are mapped with
|
||||
* MMU to the PCI Host PCI I/O space window which are translated to the low
|
||||
* 64Kbytes by the Host controller.
|
||||
*/
|
||||
|
||||
static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
|
||||
{
|
||||
return PCI_IRQ_NONE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __SPARC_PCI_H */
|
@@ -1,52 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#ifndef __SPARC64_PCI_H
|
||||
#define __SPARC64_PCI_H
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
#include <linux/dma-mapping.h>
|
||||
|
||||
/* Can be used to override the logic in pci_scan_bus for skipping
|
||||
* already-configured bus numbers - to be used for buggy BIOSes
|
||||
* or architectures with incomplete PCI setup by the loader.
|
||||
*/
|
||||
#define pcibios_assign_all_busses() 0
|
||||
|
||||
#define PCIBIOS_MIN_IO 0UL
|
||||
#define PCIBIOS_MIN_MEM 0UL
|
||||
|
||||
#define PCI_IRQ_NONE 0xffffffff
|
||||
|
||||
/* PCI IOMMU mapping bypass support. */
|
||||
|
||||
/* PCI 64-bit addressing works for all slots on all controller
|
||||
* types on sparc64. However, it requires that the device
|
||||
* can drive enough of the 64 bits.
|
||||
*/
|
||||
#define PCI64_REQUIRED_MASK (~(u64)0)
|
||||
#define PCI64_ADDR_BASE 0xfffc000000000000UL
|
||||
|
||||
/* Return the index of the PCI controller for device PDEV. */
|
||||
|
||||
int pci_domain_nr(struct pci_bus *bus);
|
||||
static inline int pci_proc_domain(struct pci_bus *bus)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Platform support for /proc/bus/pci/X/Y mmap()s. */
|
||||
|
||||
#define HAVE_PCI_MMAP
|
||||
#define arch_can_pci_mmap_io() 1
|
||||
#define HAVE_ARCH_PCI_GET_UNMAPPED_AREA
|
||||
#define get_pci_unmapped_area get_fb_unmapped_area
|
||||
|
||||
static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
|
||||
{
|
||||
return PCI_IRQ_NONE;
|
||||
}
|
||||
|
||||
#define HAVE_ARCH_PCI_RESOURCE_TO_USER
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#endif /* __SPARC64_PCI_H */
|
Reference in New Issue
Block a user