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.18-1' of git://git.infradead.org/users/hch/dma-mapping

Pull more dma-mapping updates from Christoph Hellwig:

- fix a regression in dma remap handling vs AMD memory encryption (me)

- finally kill off the legacy PCI DMA API (Christophe JAILLET)

* tag 'dma-mapping-5.18-1' of git://git.infradead.org/users/hch/dma-mapping:
dma-mapping: move pgprot_decrypted out of dma_pgprot
PCI/doc: cleanup references to the legacy PCI DMA API
PCI: Remove the deprecated "pci-dma-compat.h" API

+16 -142
+7 -7
Documentation/PCI/pci.rst
··· 278 278 on systems where System RAM exists above 4G _physical_ address. 279 279 280 280 Drivers for all PCI-X and PCIe compliant devices must call 281 - pci_set_dma_mask() as they are 64-bit DMA devices. 281 + set_dma_mask() as they are 64-bit DMA devices. 282 282 283 283 Similarly, drivers must also "register" this capability if the device 284 - can directly address "consistent memory" in System RAM above 4G physical 285 - address by calling pci_set_consistent_dma_mask(). 284 + can directly address "coherent memory" in System RAM above 4G physical 285 + address by calling dma_set_coherent_mask(). 286 286 Again, this includes drivers for all PCI-X and PCIe compliant devices. 287 287 Many 64-bit "PCI" devices (before PCI-X) and some PCI-X devices are 288 288 64-bit DMA capable for payload ("streaming") data but not control 289 - ("consistent") data. 289 + ("coherent") data. 290 290 291 291 292 292 Setup shared control data 293 293 ------------------------- 294 - Once the DMA masks are set, the driver can allocate "consistent" (a.k.a. shared) 294 + Once the DMA masks are set, the driver can allocate "coherent" (a.k.a. shared) 295 295 memory. See Documentation/core-api/dma-api.rst for a full description of 296 296 the DMA APIs. This section is just a reminder that it needs to be done 297 297 before enabling DMA on the device. ··· 367 367 - Disable the device from generating IRQs 368 368 - Release the IRQ (free_irq()) 369 369 - Stop all DMA activity 370 - - Release DMA buffers (both streaming and consistent) 370 + - Release DMA buffers (both streaming and coherent) 371 371 - Unregister from other subsystems (e.g. scsi or netdev) 372 372 - Disable device from responding to MMIO/IO Port addresses 373 373 - Release MMIO/IO Port resource(s) ··· 420 420 I.e. unmap data buffers and return buffers to "upstream" 421 421 owners if there is one. 422 422 423 - Then clean up "consistent" buffers which contain the control data. 423 + Then clean up "coherent" buffers which contain the control data. 424 424 425 425 See Documentation/core-api/dma-api.rst for details on unmapping interfaces. 426 426
-129
include/linux/pci-dma-compat.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* include this file if the platform implements the dma_ DMA Mapping API 3 - * and wants to provide the pci_ DMA Mapping API in terms of it */ 4 - 5 - #ifndef _ASM_GENERIC_PCI_DMA_COMPAT_H 6 - #define _ASM_GENERIC_PCI_DMA_COMPAT_H 7 - 8 - #include <linux/dma-mapping.h> 9 - 10 - /* This defines the direction arg to the DMA mapping routines. */ 11 - #define PCI_DMA_BIDIRECTIONAL DMA_BIDIRECTIONAL 12 - #define PCI_DMA_TODEVICE DMA_TO_DEVICE 13 - #define PCI_DMA_FROMDEVICE DMA_FROM_DEVICE 14 - #define PCI_DMA_NONE DMA_NONE 15 - 16 - static inline void * 17 - pci_alloc_consistent(struct pci_dev *hwdev, size_t size, 18 - dma_addr_t *dma_handle) 19 - { 20 - return dma_alloc_coherent(&hwdev->dev, size, dma_handle, GFP_ATOMIC); 21 - } 22 - 23 - static inline void * 24 - pci_zalloc_consistent(struct pci_dev *hwdev, size_t size, 25 - dma_addr_t *dma_handle) 26 - { 27 - return dma_alloc_coherent(&hwdev->dev, size, dma_handle, GFP_ATOMIC); 28 - } 29 - 30 - static inline void 31 - pci_free_consistent(struct pci_dev *hwdev, size_t size, 32 - void *vaddr, dma_addr_t dma_handle) 33 - { 34 - dma_free_coherent(&hwdev->dev, size, vaddr, dma_handle); 35 - } 36 - 37 - static inline dma_addr_t 38 - pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction) 39 - { 40 - return dma_map_single(&hwdev->dev, ptr, size, (enum dma_data_direction)direction); 41 - } 42 - 43 - static inline void 44 - pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr, 45 - size_t size, int direction) 46 - { 47 - dma_unmap_single(&hwdev->dev, dma_addr, size, (enum dma_data_direction)direction); 48 - } 49 - 50 - static inline dma_addr_t 51 - pci_map_page(struct pci_dev *hwdev, struct page *page, 52 - unsigned long offset, size_t size, int direction) 53 - { 54 - return dma_map_page(&hwdev->dev, page, offset, size, (enum dma_data_direction)direction); 55 - } 56 - 57 - static inline void 58 - pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address, 59 - size_t size, int direction) 60 - { 61 - dma_unmap_page(&hwdev->dev, dma_address, size, (enum dma_data_direction)direction); 62 - } 63 - 64 - static inline int 65 - pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg, 66 - int nents, int direction) 67 - { 68 - return dma_map_sg(&hwdev->dev, sg, nents, (enum dma_data_direction)direction); 69 - } 70 - 71 - static inline void 72 - pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg, 73 - int nents, int direction) 74 - { 75 - dma_unmap_sg(&hwdev->dev, sg, nents, (enum dma_data_direction)direction); 76 - } 77 - 78 - static inline void 79 - pci_dma_sync_single_for_cpu(struct pci_dev *hwdev, dma_addr_t dma_handle, 80 - size_t size, int direction) 81 - { 82 - dma_sync_single_for_cpu(&hwdev->dev, dma_handle, size, (enum dma_data_direction)direction); 83 - } 84 - 85 - static inline void 86 - pci_dma_sync_single_for_device(struct pci_dev *hwdev, dma_addr_t dma_handle, 87 - size_t size, int direction) 88 - { 89 - dma_sync_single_for_device(&hwdev->dev, dma_handle, size, (enum dma_data_direction)direction); 90 - } 91 - 92 - static inline void 93 - pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sg, 94 - int nelems, int direction) 95 - { 96 - dma_sync_sg_for_cpu(&hwdev->dev, sg, nelems, (enum dma_data_direction)direction); 97 - } 98 - 99 - static inline void 100 - pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sg, 101 - int nelems, int direction) 102 - { 103 - dma_sync_sg_for_device(&hwdev->dev, sg, nelems, (enum dma_data_direction)direction); 104 - } 105 - 106 - static inline int 107 - pci_dma_mapping_error(struct pci_dev *pdev, dma_addr_t dma_addr) 108 - { 109 - return dma_mapping_error(&pdev->dev, dma_addr); 110 - } 111 - 112 - #ifdef CONFIG_PCI 113 - static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask) 114 - { 115 - return dma_set_mask(&dev->dev, mask); 116 - } 117 - 118 - static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask) 119 - { 120 - return dma_set_coherent_mask(&dev->dev, mask); 121 - } 122 - #else 123 - static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask) 124 - { return -EIO; } 125 - static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask) 126 - { return -EIO; } 127 - #endif 128 - 129 - #endif
+1 -2
include/linux/pci.h
··· 2473 2473 void pci_uevent_ers(struct pci_dev *pdev, enum pci_ers_result err_type); 2474 2474 #endif 2475 2475 2476 - /* Provide the legacy pci_dma_* API */ 2477 - #include <linux/pci-dma-compat.h> 2476 + #include <linux/dma-mapping.h> 2478 2477 2479 2478 #define pci_printk(level, pdev, fmt, arg...) \ 2480 2479 dev_printk(level, &(pdev)->dev, fmt, ##arg)
+8 -2
kernel/dma/direct.c
··· 277 277 } 278 278 279 279 if (remap) { 280 + pgprot_t prot = dma_pgprot(dev, PAGE_KERNEL, attrs); 281 + 282 + if (force_dma_unencrypted(dev)) 283 + prot = pgprot_decrypted(prot); 284 + 280 285 /* remove any dirty cache lines on the kernel alias */ 281 286 arch_dma_prep_coherent(page, size); 282 287 283 288 /* create a coherent mapping */ 284 - ret = dma_common_contiguous_remap(page, size, 285 - dma_pgprot(dev, PAGE_KERNEL, attrs), 289 + ret = dma_common_contiguous_remap(page, size, prot, 286 290 __builtin_return_address(0)); 287 291 if (!ret) 288 292 goto out_free_pages; ··· 539 535 int ret = -ENXIO; 540 536 541 537 vma->vm_page_prot = dma_pgprot(dev, vma->vm_page_prot, attrs); 538 + if (force_dma_unencrypted(dev)) 539 + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); 542 540 543 541 if (dma_mmap_from_dev_coherent(dev, vma, cpu_addr, size, &ret)) 544 542 return ret;
-2
kernel/dma/mapping.c
··· 407 407 */ 408 408 pgprot_t dma_pgprot(struct device *dev, pgprot_t prot, unsigned long attrs) 409 409 { 410 - if (force_dma_unencrypted(dev)) 411 - prot = pgprot_decrypted(prot); 412 410 if (dev_is_dma_coherent(dev)) 413 411 return prot; 414 412 #ifdef CONFIG_ARCH_HAS_DMA_WRITE_COMBINE