1*cf65a0f6SChristoph Hellwig // SPDX-License-Identifier: GPL-2.0 2*cf65a0f6SChristoph Hellwig /* 3*cf65a0f6SChristoph Hellwig * arch-independent dma-mapping routines 4*cf65a0f6SChristoph Hellwig * 5*cf65a0f6SChristoph Hellwig * Copyright (c) 2006 SUSE Linux Products GmbH 6*cf65a0f6SChristoph Hellwig * Copyright (c) 2006 Tejun Heo <teheo@suse.de> 7*cf65a0f6SChristoph Hellwig */ 8*cf65a0f6SChristoph Hellwig 9*cf65a0f6SChristoph Hellwig #include <linux/acpi.h> 10*cf65a0f6SChristoph Hellwig #include <linux/dma-mapping.h> 11*cf65a0f6SChristoph Hellwig #include <linux/export.h> 12*cf65a0f6SChristoph Hellwig #include <linux/gfp.h> 13*cf65a0f6SChristoph Hellwig #include <linux/of_device.h> 14*cf65a0f6SChristoph Hellwig #include <linux/slab.h> 15*cf65a0f6SChristoph Hellwig #include <linux/vmalloc.h> 16*cf65a0f6SChristoph Hellwig 17*cf65a0f6SChristoph Hellwig /* 18*cf65a0f6SChristoph Hellwig * Managed DMA API 19*cf65a0f6SChristoph Hellwig */ 20*cf65a0f6SChristoph Hellwig struct dma_devres { 21*cf65a0f6SChristoph Hellwig size_t size; 22*cf65a0f6SChristoph Hellwig void *vaddr; 23*cf65a0f6SChristoph Hellwig dma_addr_t dma_handle; 24*cf65a0f6SChristoph Hellwig unsigned long attrs; 25*cf65a0f6SChristoph Hellwig }; 26*cf65a0f6SChristoph Hellwig 27*cf65a0f6SChristoph Hellwig static void dmam_release(struct device *dev, void *res) 28*cf65a0f6SChristoph Hellwig { 29*cf65a0f6SChristoph Hellwig struct dma_devres *this = res; 30*cf65a0f6SChristoph Hellwig 31*cf65a0f6SChristoph Hellwig dma_free_attrs(dev, this->size, this->vaddr, this->dma_handle, 32*cf65a0f6SChristoph Hellwig this->attrs); 33*cf65a0f6SChristoph Hellwig } 34*cf65a0f6SChristoph Hellwig 35*cf65a0f6SChristoph Hellwig static int dmam_match(struct device *dev, void *res, void *match_data) 36*cf65a0f6SChristoph Hellwig { 37*cf65a0f6SChristoph Hellwig struct dma_devres *this = res, *match = match_data; 38*cf65a0f6SChristoph Hellwig 39*cf65a0f6SChristoph Hellwig if (this->vaddr == match->vaddr) { 40*cf65a0f6SChristoph Hellwig WARN_ON(this->size != match->size || 41*cf65a0f6SChristoph Hellwig this->dma_handle != match->dma_handle); 42*cf65a0f6SChristoph Hellwig return 1; 43*cf65a0f6SChristoph Hellwig } 44*cf65a0f6SChristoph Hellwig return 0; 45*cf65a0f6SChristoph Hellwig } 46*cf65a0f6SChristoph Hellwig 47*cf65a0f6SChristoph Hellwig /** 48*cf65a0f6SChristoph Hellwig * dmam_alloc_coherent - Managed dma_alloc_coherent() 49*cf65a0f6SChristoph Hellwig * @dev: Device to allocate coherent memory for 50*cf65a0f6SChristoph Hellwig * @size: Size of allocation 51*cf65a0f6SChristoph Hellwig * @dma_handle: Out argument for allocated DMA handle 52*cf65a0f6SChristoph Hellwig * @gfp: Allocation flags 53*cf65a0f6SChristoph Hellwig * 54*cf65a0f6SChristoph Hellwig * Managed dma_alloc_coherent(). Memory allocated using this function 55*cf65a0f6SChristoph Hellwig * will be automatically released on driver detach. 56*cf65a0f6SChristoph Hellwig * 57*cf65a0f6SChristoph Hellwig * RETURNS: 58*cf65a0f6SChristoph Hellwig * Pointer to allocated memory on success, NULL on failure. 59*cf65a0f6SChristoph Hellwig */ 60*cf65a0f6SChristoph Hellwig void *dmam_alloc_coherent(struct device *dev, size_t size, 61*cf65a0f6SChristoph Hellwig dma_addr_t *dma_handle, gfp_t gfp) 62*cf65a0f6SChristoph Hellwig { 63*cf65a0f6SChristoph Hellwig struct dma_devres *dr; 64*cf65a0f6SChristoph Hellwig void *vaddr; 65*cf65a0f6SChristoph Hellwig 66*cf65a0f6SChristoph Hellwig dr = devres_alloc(dmam_release, sizeof(*dr), gfp); 67*cf65a0f6SChristoph Hellwig if (!dr) 68*cf65a0f6SChristoph Hellwig return NULL; 69*cf65a0f6SChristoph Hellwig 70*cf65a0f6SChristoph Hellwig vaddr = dma_alloc_coherent(dev, size, dma_handle, gfp); 71*cf65a0f6SChristoph Hellwig if (!vaddr) { 72*cf65a0f6SChristoph Hellwig devres_free(dr); 73*cf65a0f6SChristoph Hellwig return NULL; 74*cf65a0f6SChristoph Hellwig } 75*cf65a0f6SChristoph Hellwig 76*cf65a0f6SChristoph Hellwig dr->vaddr = vaddr; 77*cf65a0f6SChristoph Hellwig dr->dma_handle = *dma_handle; 78*cf65a0f6SChristoph Hellwig dr->size = size; 79*cf65a0f6SChristoph Hellwig 80*cf65a0f6SChristoph Hellwig devres_add(dev, dr); 81*cf65a0f6SChristoph Hellwig 82*cf65a0f6SChristoph Hellwig return vaddr; 83*cf65a0f6SChristoph Hellwig } 84*cf65a0f6SChristoph Hellwig EXPORT_SYMBOL(dmam_alloc_coherent); 85*cf65a0f6SChristoph Hellwig 86*cf65a0f6SChristoph Hellwig /** 87*cf65a0f6SChristoph Hellwig * dmam_free_coherent - Managed dma_free_coherent() 88*cf65a0f6SChristoph Hellwig * @dev: Device to free coherent memory for 89*cf65a0f6SChristoph Hellwig * @size: Size of allocation 90*cf65a0f6SChristoph Hellwig * @vaddr: Virtual address of the memory to free 91*cf65a0f6SChristoph Hellwig * @dma_handle: DMA handle of the memory to free 92*cf65a0f6SChristoph Hellwig * 93*cf65a0f6SChristoph Hellwig * Managed dma_free_coherent(). 94*cf65a0f6SChristoph Hellwig */ 95*cf65a0f6SChristoph Hellwig void dmam_free_coherent(struct device *dev, size_t size, void *vaddr, 96*cf65a0f6SChristoph Hellwig dma_addr_t dma_handle) 97*cf65a0f6SChristoph Hellwig { 98*cf65a0f6SChristoph Hellwig struct dma_devres match_data = { size, vaddr, dma_handle }; 99*cf65a0f6SChristoph Hellwig 100*cf65a0f6SChristoph Hellwig dma_free_coherent(dev, size, vaddr, dma_handle); 101*cf65a0f6SChristoph Hellwig WARN_ON(devres_destroy(dev, dmam_release, dmam_match, &match_data)); 102*cf65a0f6SChristoph Hellwig } 103*cf65a0f6SChristoph Hellwig EXPORT_SYMBOL(dmam_free_coherent); 104*cf65a0f6SChristoph Hellwig 105*cf65a0f6SChristoph Hellwig /** 106*cf65a0f6SChristoph Hellwig * dmam_alloc_attrs - Managed dma_alloc_attrs() 107*cf65a0f6SChristoph Hellwig * @dev: Device to allocate non_coherent memory for 108*cf65a0f6SChristoph Hellwig * @size: Size of allocation 109*cf65a0f6SChristoph Hellwig * @dma_handle: Out argument for allocated DMA handle 110*cf65a0f6SChristoph Hellwig * @gfp: Allocation flags 111*cf65a0f6SChristoph Hellwig * @attrs: Flags in the DMA_ATTR_* namespace. 112*cf65a0f6SChristoph Hellwig * 113*cf65a0f6SChristoph Hellwig * Managed dma_alloc_attrs(). Memory allocated using this function will be 114*cf65a0f6SChristoph Hellwig * automatically released on driver detach. 115*cf65a0f6SChristoph Hellwig * 116*cf65a0f6SChristoph Hellwig * RETURNS: 117*cf65a0f6SChristoph Hellwig * Pointer to allocated memory on success, NULL on failure. 118*cf65a0f6SChristoph Hellwig */ 119*cf65a0f6SChristoph Hellwig void *dmam_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle, 120*cf65a0f6SChristoph Hellwig gfp_t gfp, unsigned long attrs) 121*cf65a0f6SChristoph Hellwig { 122*cf65a0f6SChristoph Hellwig struct dma_devres *dr; 123*cf65a0f6SChristoph Hellwig void *vaddr; 124*cf65a0f6SChristoph Hellwig 125*cf65a0f6SChristoph Hellwig dr = devres_alloc(dmam_release, sizeof(*dr), gfp); 126*cf65a0f6SChristoph Hellwig if (!dr) 127*cf65a0f6SChristoph Hellwig return NULL; 128*cf65a0f6SChristoph Hellwig 129*cf65a0f6SChristoph Hellwig vaddr = dma_alloc_attrs(dev, size, dma_handle, gfp, attrs); 130*cf65a0f6SChristoph Hellwig if (!vaddr) { 131*cf65a0f6SChristoph Hellwig devres_free(dr); 132*cf65a0f6SChristoph Hellwig return NULL; 133*cf65a0f6SChristoph Hellwig } 134*cf65a0f6SChristoph Hellwig 135*cf65a0f6SChristoph Hellwig dr->vaddr = vaddr; 136*cf65a0f6SChristoph Hellwig dr->dma_handle = *dma_handle; 137*cf65a0f6SChristoph Hellwig dr->size = size; 138*cf65a0f6SChristoph Hellwig dr->attrs = attrs; 139*cf65a0f6SChristoph Hellwig 140*cf65a0f6SChristoph Hellwig devres_add(dev, dr); 141*cf65a0f6SChristoph Hellwig 142*cf65a0f6SChristoph Hellwig return vaddr; 143*cf65a0f6SChristoph Hellwig } 144*cf65a0f6SChristoph Hellwig EXPORT_SYMBOL(dmam_alloc_attrs); 145*cf65a0f6SChristoph Hellwig 146*cf65a0f6SChristoph Hellwig #ifdef CONFIG_HAVE_GENERIC_DMA_COHERENT 147*cf65a0f6SChristoph Hellwig 148*cf65a0f6SChristoph Hellwig static void dmam_coherent_decl_release(struct device *dev, void *res) 149*cf65a0f6SChristoph Hellwig { 150*cf65a0f6SChristoph Hellwig dma_release_declared_memory(dev); 151*cf65a0f6SChristoph Hellwig } 152*cf65a0f6SChristoph Hellwig 153*cf65a0f6SChristoph Hellwig /** 154*cf65a0f6SChristoph Hellwig * dmam_declare_coherent_memory - Managed dma_declare_coherent_memory() 155*cf65a0f6SChristoph Hellwig * @dev: Device to declare coherent memory for 156*cf65a0f6SChristoph Hellwig * @phys_addr: Physical address of coherent memory to be declared 157*cf65a0f6SChristoph Hellwig * @device_addr: Device address of coherent memory to be declared 158*cf65a0f6SChristoph Hellwig * @size: Size of coherent memory to be declared 159*cf65a0f6SChristoph Hellwig * @flags: Flags 160*cf65a0f6SChristoph Hellwig * 161*cf65a0f6SChristoph Hellwig * Managed dma_declare_coherent_memory(). 162*cf65a0f6SChristoph Hellwig * 163*cf65a0f6SChristoph Hellwig * RETURNS: 164*cf65a0f6SChristoph Hellwig * 0 on success, -errno on failure. 165*cf65a0f6SChristoph Hellwig */ 166*cf65a0f6SChristoph Hellwig int dmam_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr, 167*cf65a0f6SChristoph Hellwig dma_addr_t device_addr, size_t size, int flags) 168*cf65a0f6SChristoph Hellwig { 169*cf65a0f6SChristoph Hellwig void *res; 170*cf65a0f6SChristoph Hellwig int rc; 171*cf65a0f6SChristoph Hellwig 172*cf65a0f6SChristoph Hellwig res = devres_alloc(dmam_coherent_decl_release, 0, GFP_KERNEL); 173*cf65a0f6SChristoph Hellwig if (!res) 174*cf65a0f6SChristoph Hellwig return -ENOMEM; 175*cf65a0f6SChristoph Hellwig 176*cf65a0f6SChristoph Hellwig rc = dma_declare_coherent_memory(dev, phys_addr, device_addr, size, 177*cf65a0f6SChristoph Hellwig flags); 178*cf65a0f6SChristoph Hellwig if (!rc) 179*cf65a0f6SChristoph Hellwig devres_add(dev, res); 180*cf65a0f6SChristoph Hellwig else 181*cf65a0f6SChristoph Hellwig devres_free(res); 182*cf65a0f6SChristoph Hellwig 183*cf65a0f6SChristoph Hellwig return rc; 184*cf65a0f6SChristoph Hellwig } 185*cf65a0f6SChristoph Hellwig EXPORT_SYMBOL(dmam_declare_coherent_memory); 186*cf65a0f6SChristoph Hellwig 187*cf65a0f6SChristoph Hellwig /** 188*cf65a0f6SChristoph Hellwig * dmam_release_declared_memory - Managed dma_release_declared_memory(). 189*cf65a0f6SChristoph Hellwig * @dev: Device to release declared coherent memory for 190*cf65a0f6SChristoph Hellwig * 191*cf65a0f6SChristoph Hellwig * Managed dmam_release_declared_memory(). 192*cf65a0f6SChristoph Hellwig */ 193*cf65a0f6SChristoph Hellwig void dmam_release_declared_memory(struct device *dev) 194*cf65a0f6SChristoph Hellwig { 195*cf65a0f6SChristoph Hellwig WARN_ON(devres_destroy(dev, dmam_coherent_decl_release, NULL, NULL)); 196*cf65a0f6SChristoph Hellwig } 197*cf65a0f6SChristoph Hellwig EXPORT_SYMBOL(dmam_release_declared_memory); 198*cf65a0f6SChristoph Hellwig 199*cf65a0f6SChristoph Hellwig #endif 200*cf65a0f6SChristoph Hellwig 201*cf65a0f6SChristoph Hellwig /* 202*cf65a0f6SChristoph Hellwig * Create scatter-list for the already allocated DMA buffer. 203*cf65a0f6SChristoph Hellwig */ 204*cf65a0f6SChristoph Hellwig int dma_common_get_sgtable(struct device *dev, struct sg_table *sgt, 205*cf65a0f6SChristoph Hellwig void *cpu_addr, dma_addr_t handle, size_t size) 206*cf65a0f6SChristoph Hellwig { 207*cf65a0f6SChristoph Hellwig struct page *page = virt_to_page(cpu_addr); 208*cf65a0f6SChristoph Hellwig int ret; 209*cf65a0f6SChristoph Hellwig 210*cf65a0f6SChristoph Hellwig ret = sg_alloc_table(sgt, 1, GFP_KERNEL); 211*cf65a0f6SChristoph Hellwig if (unlikely(ret)) 212*cf65a0f6SChristoph Hellwig return ret; 213*cf65a0f6SChristoph Hellwig 214*cf65a0f6SChristoph Hellwig sg_set_page(sgt->sgl, page, PAGE_ALIGN(size), 0); 215*cf65a0f6SChristoph Hellwig return 0; 216*cf65a0f6SChristoph Hellwig } 217*cf65a0f6SChristoph Hellwig EXPORT_SYMBOL(dma_common_get_sgtable); 218*cf65a0f6SChristoph Hellwig 219*cf65a0f6SChristoph Hellwig /* 220*cf65a0f6SChristoph Hellwig * Create userspace mapping for the DMA-coherent memory. 221*cf65a0f6SChristoph Hellwig */ 222*cf65a0f6SChristoph Hellwig int dma_common_mmap(struct device *dev, struct vm_area_struct *vma, 223*cf65a0f6SChristoph Hellwig void *cpu_addr, dma_addr_t dma_addr, size_t size) 224*cf65a0f6SChristoph Hellwig { 225*cf65a0f6SChristoph Hellwig int ret = -ENXIO; 226*cf65a0f6SChristoph Hellwig #ifndef CONFIG_ARCH_NO_COHERENT_DMA_MMAP 227*cf65a0f6SChristoph Hellwig unsigned long user_count = vma_pages(vma); 228*cf65a0f6SChristoph Hellwig unsigned long count = PAGE_ALIGN(size) >> PAGE_SHIFT; 229*cf65a0f6SChristoph Hellwig unsigned long off = vma->vm_pgoff; 230*cf65a0f6SChristoph Hellwig 231*cf65a0f6SChristoph Hellwig vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 232*cf65a0f6SChristoph Hellwig 233*cf65a0f6SChristoph Hellwig if (dma_mmap_from_dev_coherent(dev, vma, cpu_addr, size, &ret)) 234*cf65a0f6SChristoph Hellwig return ret; 235*cf65a0f6SChristoph Hellwig 236*cf65a0f6SChristoph Hellwig if (off < count && user_count <= (count - off)) 237*cf65a0f6SChristoph Hellwig ret = remap_pfn_range(vma, vma->vm_start, 238*cf65a0f6SChristoph Hellwig page_to_pfn(virt_to_page(cpu_addr)) + off, 239*cf65a0f6SChristoph Hellwig user_count << PAGE_SHIFT, 240*cf65a0f6SChristoph Hellwig vma->vm_page_prot); 241*cf65a0f6SChristoph Hellwig #endif /* !CONFIG_ARCH_NO_COHERENT_DMA_MMAP */ 242*cf65a0f6SChristoph Hellwig 243*cf65a0f6SChristoph Hellwig return ret; 244*cf65a0f6SChristoph Hellwig } 245*cf65a0f6SChristoph Hellwig EXPORT_SYMBOL(dma_common_mmap); 246*cf65a0f6SChristoph Hellwig 247*cf65a0f6SChristoph Hellwig #ifdef CONFIG_MMU 248*cf65a0f6SChristoph Hellwig static struct vm_struct *__dma_common_pages_remap(struct page **pages, 249*cf65a0f6SChristoph Hellwig size_t size, unsigned long vm_flags, pgprot_t prot, 250*cf65a0f6SChristoph Hellwig const void *caller) 251*cf65a0f6SChristoph Hellwig { 252*cf65a0f6SChristoph Hellwig struct vm_struct *area; 253*cf65a0f6SChristoph Hellwig 254*cf65a0f6SChristoph Hellwig area = get_vm_area_caller(size, vm_flags, caller); 255*cf65a0f6SChristoph Hellwig if (!area) 256*cf65a0f6SChristoph Hellwig return NULL; 257*cf65a0f6SChristoph Hellwig 258*cf65a0f6SChristoph Hellwig if (map_vm_area(area, prot, pages)) { 259*cf65a0f6SChristoph Hellwig vunmap(area->addr); 260*cf65a0f6SChristoph Hellwig return NULL; 261*cf65a0f6SChristoph Hellwig } 262*cf65a0f6SChristoph Hellwig 263*cf65a0f6SChristoph Hellwig return area; 264*cf65a0f6SChristoph Hellwig } 265*cf65a0f6SChristoph Hellwig 266*cf65a0f6SChristoph Hellwig /* 267*cf65a0f6SChristoph Hellwig * remaps an array of PAGE_SIZE pages into another vm_area 268*cf65a0f6SChristoph Hellwig * Cannot be used in non-sleeping contexts 269*cf65a0f6SChristoph Hellwig */ 270*cf65a0f6SChristoph Hellwig void *dma_common_pages_remap(struct page **pages, size_t size, 271*cf65a0f6SChristoph Hellwig unsigned long vm_flags, pgprot_t prot, 272*cf65a0f6SChristoph Hellwig const void *caller) 273*cf65a0f6SChristoph Hellwig { 274*cf65a0f6SChristoph Hellwig struct vm_struct *area; 275*cf65a0f6SChristoph Hellwig 276*cf65a0f6SChristoph Hellwig area = __dma_common_pages_remap(pages, size, vm_flags, prot, caller); 277*cf65a0f6SChristoph Hellwig if (!area) 278*cf65a0f6SChristoph Hellwig return NULL; 279*cf65a0f6SChristoph Hellwig 280*cf65a0f6SChristoph Hellwig area->pages = pages; 281*cf65a0f6SChristoph Hellwig 282*cf65a0f6SChristoph Hellwig return area->addr; 283*cf65a0f6SChristoph Hellwig } 284*cf65a0f6SChristoph Hellwig 285*cf65a0f6SChristoph Hellwig /* 286*cf65a0f6SChristoph Hellwig * remaps an allocated contiguous region into another vm_area. 287*cf65a0f6SChristoph Hellwig * Cannot be used in non-sleeping contexts 288*cf65a0f6SChristoph Hellwig */ 289*cf65a0f6SChristoph Hellwig 290*cf65a0f6SChristoph Hellwig void *dma_common_contiguous_remap(struct page *page, size_t size, 291*cf65a0f6SChristoph Hellwig unsigned long vm_flags, 292*cf65a0f6SChristoph Hellwig pgprot_t prot, const void *caller) 293*cf65a0f6SChristoph Hellwig { 294*cf65a0f6SChristoph Hellwig int i; 295*cf65a0f6SChristoph Hellwig struct page **pages; 296*cf65a0f6SChristoph Hellwig struct vm_struct *area; 297*cf65a0f6SChristoph Hellwig 298*cf65a0f6SChristoph Hellwig pages = kmalloc(sizeof(struct page *) << get_order(size), GFP_KERNEL); 299*cf65a0f6SChristoph Hellwig if (!pages) 300*cf65a0f6SChristoph Hellwig return NULL; 301*cf65a0f6SChristoph Hellwig 302*cf65a0f6SChristoph Hellwig for (i = 0; i < (size >> PAGE_SHIFT); i++) 303*cf65a0f6SChristoph Hellwig pages[i] = nth_page(page, i); 304*cf65a0f6SChristoph Hellwig 305*cf65a0f6SChristoph Hellwig area = __dma_common_pages_remap(pages, size, vm_flags, prot, caller); 306*cf65a0f6SChristoph Hellwig 307*cf65a0f6SChristoph Hellwig kfree(pages); 308*cf65a0f6SChristoph Hellwig 309*cf65a0f6SChristoph Hellwig if (!area) 310*cf65a0f6SChristoph Hellwig return NULL; 311*cf65a0f6SChristoph Hellwig return area->addr; 312*cf65a0f6SChristoph Hellwig } 313*cf65a0f6SChristoph Hellwig 314*cf65a0f6SChristoph Hellwig /* 315*cf65a0f6SChristoph Hellwig * unmaps a range previously mapped by dma_common_*_remap 316*cf65a0f6SChristoph Hellwig */ 317*cf65a0f6SChristoph Hellwig void dma_common_free_remap(void *cpu_addr, size_t size, unsigned long vm_flags) 318*cf65a0f6SChristoph Hellwig { 319*cf65a0f6SChristoph Hellwig struct vm_struct *area = find_vm_area(cpu_addr); 320*cf65a0f6SChristoph Hellwig 321*cf65a0f6SChristoph Hellwig if (!area || (area->flags & vm_flags) != vm_flags) { 322*cf65a0f6SChristoph Hellwig WARN(1, "trying to free invalid coherent area: %p\n", cpu_addr); 323*cf65a0f6SChristoph Hellwig return; 324*cf65a0f6SChristoph Hellwig } 325*cf65a0f6SChristoph Hellwig 326*cf65a0f6SChristoph Hellwig unmap_kernel_range((unsigned long)cpu_addr, PAGE_ALIGN(size)); 327*cf65a0f6SChristoph Hellwig vunmap(cpu_addr); 328*cf65a0f6SChristoph Hellwig } 329*cf65a0f6SChristoph Hellwig #endif 330*cf65a0f6SChristoph Hellwig 331*cf65a0f6SChristoph Hellwig /* 332*cf65a0f6SChristoph Hellwig * enables DMA API use for a device 333*cf65a0f6SChristoph Hellwig */ 334*cf65a0f6SChristoph Hellwig int dma_configure(struct device *dev) 335*cf65a0f6SChristoph Hellwig { 336*cf65a0f6SChristoph Hellwig if (dev->bus->dma_configure) 337*cf65a0f6SChristoph Hellwig return dev->bus->dma_configure(dev); 338*cf65a0f6SChristoph Hellwig return 0; 339*cf65a0f6SChristoph Hellwig } 340*cf65a0f6SChristoph Hellwig 341*cf65a0f6SChristoph Hellwig void dma_deconfigure(struct device *dev) 342*cf65a0f6SChristoph Hellwig { 343*cf65a0f6SChristoph Hellwig of_dma_deconfigure(dev); 344*cf65a0f6SChristoph Hellwig acpi_dma_deconfigure(dev); 345*cf65a0f6SChristoph Hellwig } 346