Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'dma-mapping-5.10-1' of git://git.infradead.org/users/hch/dma-mapping

Pull dma-mapping fixes from Christoph Hellwig:

- document the new dma_{alloc,free}_pages() API

- two fixups for the dma-mapping.h split

* tag 'dma-mapping-5.10-1' of git://git.infradead.org/users/hch/dma-mapping:
dma-mapping: document dma_{alloc,free}_pages
dma-mapping: move more functions to dma-map-ops.h
ARM/sa1111: add a missing include of dma-map-ops.h

+68 -32
+43 -6
Documentation/core-api/dma-api.rst
··· 519 519 Part II - Non-coherent DMA allocations 520 520 -------------------------------------- 521 521 522 - These APIs allow to allocate pages in the kernel direct mapping that are 523 - guaranteed to be DMA addressable. This means that unlike dma_alloc_coherent, 524 - virt_to_page can be called on the resulting address, and the resulting 525 - struct page can be used for everything a struct page is suitable for. 522 + These APIs allow to allocate pages that are guaranteed to be DMA addressable 523 + by the passed in device, but which need explicit management of memory ownership 524 + for the kernel vs the device. 526 525 527 526 If you don't understand how cache line coherency works between a processor and 528 527 an I/O device, you should not be using this part of the API. ··· 536 537 This routine allocates a region of <size> bytes of consistent memory. It 537 538 returns a pointer to the allocated region (in the processor's virtual address 538 539 space) or NULL if the allocation failed. The returned memory may or may not 539 - be in the kernels direct mapping. Drivers must not call virt_to_page on 540 + be in the kernel direct mapping. Drivers must not call virt_to_page on 540 541 the returned memory region. 541 542 542 543 It also returns a <dma_handle> which may be cast to an unsigned integer the ··· 564 565 Free a region of memory previously allocated using dma_alloc_noncoherent(). 565 566 dev, size and dma_handle and dir must all be the same as those passed into 566 567 dma_alloc_noncoherent(). cpu_addr must be the virtual address returned by 567 - the dma_alloc_noncoherent(). 568 + dma_alloc_noncoherent(). 569 + 570 + :: 571 + 572 + struct page * 573 + dma_alloc_pages(struct device *dev, size_t size, dma_addr_t *dma_handle, 574 + enum dma_data_direction dir, gfp_t gfp) 575 + 576 + This routine allocates a region of <size> bytes of non-coherent memory. It 577 + returns a pointer to first struct page for the region, or NULL if the 578 + allocation failed. The resulting struct page can be used for everything a 579 + struct page is suitable for. 580 + 581 + It also returns a <dma_handle> which may be cast to an unsigned integer the 582 + same width as the bus and given to the device as the DMA address base of 583 + the region. 584 + 585 + The dir parameter specified if data is read and/or written by the device, 586 + see dma_map_single() for details. 587 + 588 + The gfp parameter allows the caller to specify the ``GFP_`` flags (see 589 + kmalloc()) for the allocation, but rejects flags used to specify a memory 590 + zone such as GFP_DMA or GFP_HIGHMEM. 591 + 592 + Before giving the memory to the device, dma_sync_single_for_device() needs 593 + to be called, and before reading memory written by the device, 594 + dma_sync_single_for_cpu(), just like for streaming DMA mappings that are 595 + reused. 596 + 597 + :: 598 + 599 + void 600 + dma_free_pages(struct device *dev, size_t size, struct page *page, 601 + dma_addr_t dma_handle, enum dma_data_direction dir) 602 + 603 + Free a region of memory previously allocated using dma_alloc_pages(). 604 + dev, size and dma_handle and dir must all be the same as those passed into 605 + dma_alloc_noncoherent(). page must be the pointer returned by 606 + dma_alloc_pages(). 568 607 569 608 :: 570 609
+1 -1
arch/arm/common/sa1111.c
··· 22 22 #include <linux/platform_device.h> 23 23 #include <linux/slab.h> 24 24 #include <linux/spinlock.h> 25 - #include <linux/dma-mapping.h> 25 + #include <linux/dma-map-ops.h> 26 26 #include <linux/clk.h> 27 27 #include <linux/io.h> 28 28
+23
include/linux/dma-map-ops.h
··· 203 203 } 204 204 #endif /* CONFIG_DMA_DECLARE_COHERENT */ 205 205 206 + int dma_common_get_sgtable(struct device *dev, struct sg_table *sgt, 207 + void *cpu_addr, dma_addr_t dma_addr, size_t size, 208 + unsigned long attrs); 209 + int dma_common_mmap(struct device *dev, struct vm_area_struct *vma, 210 + void *cpu_addr, dma_addr_t dma_addr, size_t size, 211 + unsigned long attrs); 212 + struct page *dma_common_alloc_pages(struct device *dev, size_t size, 213 + dma_addr_t *dma_handle, enum dma_data_direction dir, gfp_t gfp); 214 + void dma_common_free_pages(struct device *dev, size_t size, struct page *vaddr, 215 + dma_addr_t dma_handle, enum dma_data_direction dir); 216 + 217 + struct page **dma_common_find_pages(void *cpu_addr); 218 + void *dma_common_contiguous_remap(struct page *page, size_t size, pgprot_t prot, 219 + const void *caller); 220 + void *dma_common_pages_remap(struct page **pages, size_t size, pgprot_t prot, 221 + const void *caller); 222 + void dma_common_free_remap(void *cpu_addr, size_t size); 223 + 224 + struct page *dma_alloc_from_pool(struct device *dev, size_t size, 225 + void **cpu_addr, gfp_t flags, 226 + bool (*phys_addr_ok)(struct device *, phys_addr_t, size_t)); 227 + bool dma_free_from_pool(struct device *dev, void *start, size_t size); 228 + 206 229 #ifdef CONFIG_ARCH_HAS_DMA_COHERENCE_H 207 230 #include <asm/dma-coherence.h> 208 231 #elif defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
-24
include/linux/dma-mapping.h
··· 389 389 #define dma_get_sgtable(d, t, v, h, s) dma_get_sgtable_attrs(d, t, v, h, s, 0) 390 390 #define dma_mmap_coherent(d, v, c, h, s) dma_mmap_attrs(d, v, c, h, s, 0) 391 391 392 - extern int dma_common_mmap(struct device *dev, struct vm_area_struct *vma, 393 - void *cpu_addr, dma_addr_t dma_addr, size_t size, 394 - unsigned long attrs); 395 - struct page *dma_common_alloc_pages(struct device *dev, size_t size, 396 - dma_addr_t *dma_handle, enum dma_data_direction dir, gfp_t gfp); 397 - void dma_common_free_pages(struct device *dev, size_t size, struct page *vaddr, 398 - dma_addr_t dma_handle, enum dma_data_direction dir); 399 - struct page **dma_common_find_pages(void *cpu_addr); 400 - void *dma_common_contiguous_remap(struct page *page, size_t size, 401 - pgprot_t prot, const void *caller); 402 - 403 - void *dma_common_pages_remap(struct page **pages, size_t size, 404 - pgprot_t prot, const void *caller); 405 - void dma_common_free_remap(void *cpu_addr, size_t size); 406 - 407 - struct page *dma_alloc_from_pool(struct device *dev, size_t size, 408 - void **cpu_addr, gfp_t flags, 409 - bool (*phys_addr_ok)(struct device *, phys_addr_t, size_t)); 410 - bool dma_free_from_pool(struct device *dev, void *start, size_t size); 411 - 412 - int 413 - dma_common_get_sgtable(struct device *dev, struct sg_table *sgt, void *cpu_addr, 414 - dma_addr_t dma_addr, size_t size, unsigned long attrs); 415 - 416 392 static inline void *dma_alloc_coherent(struct device *dev, size_t size, 417 393 dma_addr_t *dma_handle, gfp_t gfp) 418 394 {
+1 -1
kernel/dma/remap.c
··· 2 2 /* 3 3 * Copyright (c) 2014 The Linux Foundation 4 4 */ 5 - #include <linux/dma-mapping.h> 5 + #include <linux/dma-map-ops.h> 6 6 #include <linux/slab.h> 7 7 #include <linux/vmalloc.h> 8 8