Loading arch/ia64/include/asm/dma-mapping.h +18 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,6 @@ static inline void dma_free_coherent(struct device *dev, size_t size, #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) #define get_dma_ops(dev) platform_dma_get_ops(dev) #define flush_write_buffers() #include <asm-generic/dma-mapping-common.h> Loading @@ -69,6 +68,24 @@ dma_set_mask (struct device *dev, u64 mask) return 0; } static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) { if (!dev->dma_mask) return 0; return addr + size <= *dev->dma_mask; } static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) { return paddr; } static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr) { return daddr; } extern int dma_get_cache_alignment(void); static inline void Loading arch/powerpc/include/asm/dma-mapping.h +23 −0 Original line number Diff line number Diff line Loading @@ -424,6 +424,29 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) #endif } static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) { struct dma_mapping_ops *ops = get_dma_ops(dev); if (ops->addr_needs_map && ops->addr_needs_map(dev, addr, size)) return 0; if (!dev->dma_mask) return 0; return addr + size <= *dev->dma_mask; } static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) { return paddr + get_dma_direct_offset(dev); } static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr) { return daddr - get_dma_direct_offset(dev); } #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) #ifdef CONFIG_NOT_COHERENT_CACHE Loading arch/powerpc/kernel/dma-swiotlb.c +1 −47 Original line number Diff line number Diff line Loading @@ -24,50 +24,12 @@ int swiotlb __read_mostly; unsigned int ppc_swiotlb_enable; void *swiotlb_bus_to_virt(struct device *hwdev, dma_addr_t addr) { unsigned long pfn = PFN_DOWN(swiotlb_bus_to_phys(hwdev, addr)); void *pageaddr = page_address(pfn_to_page(pfn)); if (pageaddr != NULL) return pageaddr + (addr % PAGE_SIZE); return NULL; } dma_addr_t swiotlb_phys_to_bus(struct device *hwdev, phys_addr_t paddr) { return paddr + get_dma_direct_offset(hwdev); } phys_addr_t swiotlb_bus_to_phys(struct device *hwdev, dma_addr_t baddr) { return baddr - get_dma_direct_offset(hwdev); } /* * Determine if an address needs bounce buffering via swiotlb. * Going forward I expect the swiotlb code to generalize on using * a dma_ops->addr_needs_map, and this function will move from here to the * generic swiotlb code. */ int swiotlb_arch_address_needs_mapping(struct device *hwdev, dma_addr_t addr, size_t size) { struct dma_mapping_ops *dma_ops = get_dma_ops(hwdev); BUG_ON(!dma_ops); return dma_ops->addr_needs_map(hwdev, addr, size); } /* * Determine if an address is reachable by a pci device, or if we must bounce. */ static int swiotlb_pci_addr_needs_map(struct device *hwdev, dma_addr_t addr, size_t size) { u64 mask = dma_get_mask(hwdev); dma_addr_t max; struct pci_controller *hose; struct pci_dev *pdev = to_pci_dev(hwdev); Loading @@ -79,16 +41,9 @@ swiotlb_pci_addr_needs_map(struct device *hwdev, dma_addr_t addr, size_t size) if ((addr + size > max) | (addr < hose->dma_window_base_cur)) return 1; return !is_buffer_dma_capable(mask, addr, size); } static int swiotlb_addr_needs_map(struct device *hwdev, dma_addr_t addr, size_t size) { return !is_buffer_dma_capable(dma_get_mask(hwdev), addr, size); return 0; } /* * At the moment, all platforms that use this code only require * swiotlb to be used if we're operating on HIGHMEM. Since Loading @@ -104,7 +59,6 @@ struct dma_mapping_ops swiotlb_dma_ops = { .dma_supported = swiotlb_dma_supported, .map_page = swiotlb_map_page, .unmap_page = swiotlb_unmap_page, .addr_needs_map = swiotlb_addr_needs_map, .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu, .sync_single_range_for_device = swiotlb_sync_single_range_for_device, .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu, Loading arch/sparc/Kconfig +2 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ config SPARC select ARCH_WANT_OPTIONAL_GPIOLIB select RTC_CLASS select RTC_DRV_M48T59 select HAVE_DMA_ATTRS select HAVE_DMA_API_DEBUG config SPARC32 def_bool !64BIT Loading arch/sparc/include/asm/dma-mapping.h +22 −123 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ #include <linux/scatterlist.h> #include <linux/mm.h> #include <linux/dma-debug.h> #define DMA_ERROR_CODE (~(dma_addr_t)0x0) Loading @@ -13,142 +14,40 @@ extern int dma_set_mask(struct device *dev, u64 dma_mask); #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) #define dma_is_consistent(d, h) (1) struct dma_ops { void *(*alloc_coherent)(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t flag); void (*free_coherent)(struct device *dev, size_t size, void *cpu_addr, dma_addr_t dma_handle); dma_addr_t (*map_page)(struct device *dev, struct page *page, unsigned long offset, size_t size, enum dma_data_direction direction); void (*unmap_page)(struct device *dev, dma_addr_t dma_addr, size_t size, enum dma_data_direction direction); int (*map_sg)(struct device *dev, struct scatterlist *sg, int nents, enum dma_data_direction direction); void (*unmap_sg)(struct device *dev, struct scatterlist *sg, int nhwentries, enum dma_data_direction direction); void (*sync_single_for_cpu)(struct device *dev, dma_addr_t dma_handle, size_t size, enum dma_data_direction direction); void (*sync_single_for_device)(struct device *dev, dma_addr_t dma_handle, size_t size, enum dma_data_direction direction); void (*sync_sg_for_cpu)(struct device *dev, struct scatterlist *sg, int nelems, enum dma_data_direction direction); void (*sync_sg_for_device)(struct device *dev, struct scatterlist *sg, int nents, enum dma_data_direction dir); }; extern const struct dma_ops *dma_ops; extern struct dma_map_ops *dma_ops, pci32_dma_ops; extern struct bus_type pci_bus_type; static inline void *dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t flag) { return dma_ops->alloc_coherent(dev, size, dma_handle, flag); } static inline void dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, dma_addr_t dma_handle) { dma_ops->free_coherent(dev, size, cpu_addr, dma_handle); } static inline dma_addr_t dma_map_single(struct device *dev, void *cpu_addr, size_t size, enum dma_data_direction direction) { return dma_ops->map_page(dev, virt_to_page(cpu_addr), (unsigned long)cpu_addr & ~PAGE_MASK, size, direction); } static inline void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, enum dma_data_direction direction) { dma_ops->unmap_page(dev, dma_addr, size, direction); } static inline dma_addr_t dma_map_page(struct device *dev, struct page *page, unsigned long offset, size_t size, enum dma_data_direction direction) { return dma_ops->map_page(dev, page, offset, size, direction); } static inline void dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size, enum dma_data_direction direction) { dma_ops->unmap_page(dev, dma_address, size, direction); } static inline int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, enum dma_data_direction direction) { return dma_ops->map_sg(dev, sg, nents, direction); } static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, enum dma_data_direction direction) static inline struct dma_map_ops *get_dma_ops(struct device *dev) { dma_ops->unmap_sg(dev, sg, nents, direction); } static inline void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size, enum dma_data_direction direction) { dma_ops->sync_single_for_cpu(dev, dma_handle, size, direction); #if defined(CONFIG_SPARC32) && defined(CONFIG_PCI) if (dev->bus == &pci_bus_type) return &pci32_dma_ops; #endif return dma_ops; } static inline void dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size, enum dma_data_direction direction) { if (dma_ops->sync_single_for_device) dma_ops->sync_single_for_device(dev, dma_handle, size, direction); } #include <asm-generic/dma-mapping-common.h> static inline void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems, enum dma_data_direction direction) static inline void *dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t flag) { dma_ops->sync_sg_for_cpu(dev, sg, nelems, direction); } struct dma_map_ops *ops = get_dma_ops(dev); void *cpu_addr; static inline void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems, enum dma_data_direction direction) { if (dma_ops->sync_sg_for_device) dma_ops->sync_sg_for_device(dev, sg, nelems, direction); cpu_addr = ops->alloc_coherent(dev, size, dma_handle, flag); debug_dma_alloc_coherent(dev, size, *dma_handle, cpu_addr); return cpu_addr; } static inline void dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle, unsigned long offset, size_t size, enum dma_data_direction dir) static inline void dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, dma_addr_t dma_handle) { dma_sync_single_for_cpu(dev, dma_handle+offset, size, dir); } struct dma_map_ops *ops = get_dma_ops(dev); static inline void dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle, unsigned long offset, size_t size, enum dma_data_direction dir) { dma_sync_single_for_device(dev, dma_handle+offset, size, dir); debug_dma_free_coherent(dev, size, cpu_addr, dma_handle); ops->free_coherent(dev, size, cpu_addr, dma_handle); } static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) { return (dma_addr == DMA_ERROR_CODE); Loading Loading
arch/ia64/include/asm/dma-mapping.h +18 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,6 @@ static inline void dma_free_coherent(struct device *dev, size_t size, #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) #define get_dma_ops(dev) platform_dma_get_ops(dev) #define flush_write_buffers() #include <asm-generic/dma-mapping-common.h> Loading @@ -69,6 +68,24 @@ dma_set_mask (struct device *dev, u64 mask) return 0; } static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) { if (!dev->dma_mask) return 0; return addr + size <= *dev->dma_mask; } static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) { return paddr; } static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr) { return daddr; } extern int dma_get_cache_alignment(void); static inline void Loading
arch/powerpc/include/asm/dma-mapping.h +23 −0 Original line number Diff line number Diff line Loading @@ -424,6 +424,29 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) #endif } static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) { struct dma_mapping_ops *ops = get_dma_ops(dev); if (ops->addr_needs_map && ops->addr_needs_map(dev, addr, size)) return 0; if (!dev->dma_mask) return 0; return addr + size <= *dev->dma_mask; } static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) { return paddr + get_dma_direct_offset(dev); } static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr) { return daddr - get_dma_direct_offset(dev); } #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) #ifdef CONFIG_NOT_COHERENT_CACHE Loading
arch/powerpc/kernel/dma-swiotlb.c +1 −47 Original line number Diff line number Diff line Loading @@ -24,50 +24,12 @@ int swiotlb __read_mostly; unsigned int ppc_swiotlb_enable; void *swiotlb_bus_to_virt(struct device *hwdev, dma_addr_t addr) { unsigned long pfn = PFN_DOWN(swiotlb_bus_to_phys(hwdev, addr)); void *pageaddr = page_address(pfn_to_page(pfn)); if (pageaddr != NULL) return pageaddr + (addr % PAGE_SIZE); return NULL; } dma_addr_t swiotlb_phys_to_bus(struct device *hwdev, phys_addr_t paddr) { return paddr + get_dma_direct_offset(hwdev); } phys_addr_t swiotlb_bus_to_phys(struct device *hwdev, dma_addr_t baddr) { return baddr - get_dma_direct_offset(hwdev); } /* * Determine if an address needs bounce buffering via swiotlb. * Going forward I expect the swiotlb code to generalize on using * a dma_ops->addr_needs_map, and this function will move from here to the * generic swiotlb code. */ int swiotlb_arch_address_needs_mapping(struct device *hwdev, dma_addr_t addr, size_t size) { struct dma_mapping_ops *dma_ops = get_dma_ops(hwdev); BUG_ON(!dma_ops); return dma_ops->addr_needs_map(hwdev, addr, size); } /* * Determine if an address is reachable by a pci device, or if we must bounce. */ static int swiotlb_pci_addr_needs_map(struct device *hwdev, dma_addr_t addr, size_t size) { u64 mask = dma_get_mask(hwdev); dma_addr_t max; struct pci_controller *hose; struct pci_dev *pdev = to_pci_dev(hwdev); Loading @@ -79,16 +41,9 @@ swiotlb_pci_addr_needs_map(struct device *hwdev, dma_addr_t addr, size_t size) if ((addr + size > max) | (addr < hose->dma_window_base_cur)) return 1; return !is_buffer_dma_capable(mask, addr, size); } static int swiotlb_addr_needs_map(struct device *hwdev, dma_addr_t addr, size_t size) { return !is_buffer_dma_capable(dma_get_mask(hwdev), addr, size); return 0; } /* * At the moment, all platforms that use this code only require * swiotlb to be used if we're operating on HIGHMEM. Since Loading @@ -104,7 +59,6 @@ struct dma_mapping_ops swiotlb_dma_ops = { .dma_supported = swiotlb_dma_supported, .map_page = swiotlb_map_page, .unmap_page = swiotlb_unmap_page, .addr_needs_map = swiotlb_addr_needs_map, .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu, .sync_single_range_for_device = swiotlb_sync_single_range_for_device, .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu, Loading
arch/sparc/Kconfig +2 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ config SPARC select ARCH_WANT_OPTIONAL_GPIOLIB select RTC_CLASS select RTC_DRV_M48T59 select HAVE_DMA_ATTRS select HAVE_DMA_API_DEBUG config SPARC32 def_bool !64BIT Loading
arch/sparc/include/asm/dma-mapping.h +22 −123 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ #include <linux/scatterlist.h> #include <linux/mm.h> #include <linux/dma-debug.h> #define DMA_ERROR_CODE (~(dma_addr_t)0x0) Loading @@ -13,142 +14,40 @@ extern int dma_set_mask(struct device *dev, u64 dma_mask); #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) #define dma_is_consistent(d, h) (1) struct dma_ops { void *(*alloc_coherent)(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t flag); void (*free_coherent)(struct device *dev, size_t size, void *cpu_addr, dma_addr_t dma_handle); dma_addr_t (*map_page)(struct device *dev, struct page *page, unsigned long offset, size_t size, enum dma_data_direction direction); void (*unmap_page)(struct device *dev, dma_addr_t dma_addr, size_t size, enum dma_data_direction direction); int (*map_sg)(struct device *dev, struct scatterlist *sg, int nents, enum dma_data_direction direction); void (*unmap_sg)(struct device *dev, struct scatterlist *sg, int nhwentries, enum dma_data_direction direction); void (*sync_single_for_cpu)(struct device *dev, dma_addr_t dma_handle, size_t size, enum dma_data_direction direction); void (*sync_single_for_device)(struct device *dev, dma_addr_t dma_handle, size_t size, enum dma_data_direction direction); void (*sync_sg_for_cpu)(struct device *dev, struct scatterlist *sg, int nelems, enum dma_data_direction direction); void (*sync_sg_for_device)(struct device *dev, struct scatterlist *sg, int nents, enum dma_data_direction dir); }; extern const struct dma_ops *dma_ops; extern struct dma_map_ops *dma_ops, pci32_dma_ops; extern struct bus_type pci_bus_type; static inline void *dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t flag) { return dma_ops->alloc_coherent(dev, size, dma_handle, flag); } static inline void dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, dma_addr_t dma_handle) { dma_ops->free_coherent(dev, size, cpu_addr, dma_handle); } static inline dma_addr_t dma_map_single(struct device *dev, void *cpu_addr, size_t size, enum dma_data_direction direction) { return dma_ops->map_page(dev, virt_to_page(cpu_addr), (unsigned long)cpu_addr & ~PAGE_MASK, size, direction); } static inline void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, enum dma_data_direction direction) { dma_ops->unmap_page(dev, dma_addr, size, direction); } static inline dma_addr_t dma_map_page(struct device *dev, struct page *page, unsigned long offset, size_t size, enum dma_data_direction direction) { return dma_ops->map_page(dev, page, offset, size, direction); } static inline void dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size, enum dma_data_direction direction) { dma_ops->unmap_page(dev, dma_address, size, direction); } static inline int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, enum dma_data_direction direction) { return dma_ops->map_sg(dev, sg, nents, direction); } static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, enum dma_data_direction direction) static inline struct dma_map_ops *get_dma_ops(struct device *dev) { dma_ops->unmap_sg(dev, sg, nents, direction); } static inline void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size, enum dma_data_direction direction) { dma_ops->sync_single_for_cpu(dev, dma_handle, size, direction); #if defined(CONFIG_SPARC32) && defined(CONFIG_PCI) if (dev->bus == &pci_bus_type) return &pci32_dma_ops; #endif return dma_ops; } static inline void dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size, enum dma_data_direction direction) { if (dma_ops->sync_single_for_device) dma_ops->sync_single_for_device(dev, dma_handle, size, direction); } #include <asm-generic/dma-mapping-common.h> static inline void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems, enum dma_data_direction direction) static inline void *dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t flag) { dma_ops->sync_sg_for_cpu(dev, sg, nelems, direction); } struct dma_map_ops *ops = get_dma_ops(dev); void *cpu_addr; static inline void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems, enum dma_data_direction direction) { if (dma_ops->sync_sg_for_device) dma_ops->sync_sg_for_device(dev, sg, nelems, direction); cpu_addr = ops->alloc_coherent(dev, size, dma_handle, flag); debug_dma_alloc_coherent(dev, size, *dma_handle, cpu_addr); return cpu_addr; } static inline void dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle, unsigned long offset, size_t size, enum dma_data_direction dir) static inline void dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, dma_addr_t dma_handle) { dma_sync_single_for_cpu(dev, dma_handle+offset, size, dir); } struct dma_map_ops *ops = get_dma_ops(dev); static inline void dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle, unsigned long offset, size_t size, enum dma_data_direction dir) { dma_sync_single_for_device(dev, dma_handle+offset, size, dir); debug_dma_free_coherent(dev, size, cpu_addr, dma_handle); ops->free_coherent(dev, size, cpu_addr, dma_handle); } static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) { return (dma_addr == DMA_ERROR_CODE); Loading