Skip to content

Commit

Permalink
Merge tag 'dma-mapping-5.18-1' of git://git.infradead.org/users/hch/d…
Browse files Browse the repository at this point in the history
…ma-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
  • Loading branch information
torvalds committed Apr 3, 2022
2 parents 5dee872 + 4fe87e8 commit 63d12cc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 142 deletions.
14 changes: 7 additions & 7 deletions Documentation/PCI/pci.rst
Original file line number Diff line number Diff line change
Expand Up @@ -278,20 +278,20 @@ appropriate parameters. In general this allows more efficient DMA
on systems where System RAM exists above 4G _physical_ address.

Drivers for all PCI-X and PCIe compliant devices must call
pci_set_dma_mask() as they are 64-bit DMA devices.
set_dma_mask() as they are 64-bit DMA devices.

Similarly, drivers must also "register" this capability if the device
can directly address "consistent memory" in System RAM above 4G physical
address by calling pci_set_consistent_dma_mask().
can directly address "coherent memory" in System RAM above 4G physical
address by calling dma_set_coherent_mask().
Again, this includes drivers for all PCI-X and PCIe compliant devices.
Many 64-bit "PCI" devices (before PCI-X) and some PCI-X devices are
64-bit DMA capable for payload ("streaming") data but not control
("consistent") data.
("coherent") data.


Setup shared control data
-------------------------
Once the DMA masks are set, the driver can allocate "consistent" (a.k.a. shared)
Once the DMA masks are set, the driver can allocate "coherent" (a.k.a. shared)
memory. See Documentation/core-api/dma-api.rst for a full description of
the DMA APIs. This section is just a reminder that it needs to be done
before enabling DMA on the device.
Expand Down Expand Up @@ -367,7 +367,7 @@ steps need to be performed:
- Disable the device from generating IRQs
- Release the IRQ (free_irq())
- Stop all DMA activity
- Release DMA buffers (both streaming and consistent)
- Release DMA buffers (both streaming and coherent)
- Unregister from other subsystems (e.g. scsi or netdev)
- Disable device from responding to MMIO/IO Port addresses
- Release MMIO/IO Port resource(s)
Expand Down Expand Up @@ -420,7 +420,7 @@ Once DMA is stopped, clean up streaming DMA first.
I.e. unmap data buffers and return buffers to "upstream"
owners if there is one.

Then clean up "consistent" buffers which contain the control data.
Then clean up "coherent" buffers which contain the control data.

See Documentation/core-api/dma-api.rst for details on unmapping interfaces.

Expand Down
129 changes: 0 additions & 129 deletions include/linux/pci-dma-compat.h

This file was deleted.

3 changes: 1 addition & 2 deletions include/linux/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -2473,8 +2473,7 @@ static inline bool pci_is_thunderbolt_attached(struct pci_dev *pdev)
void pci_uevent_ers(struct pci_dev *pdev, enum pci_ers_result err_type);
#endif

/* Provide the legacy pci_dma_* API */
#include <linux/pci-dma-compat.h>
#include <linux/dma-mapping.h>

#define pci_printk(level, pdev, fmt, arg...) \
dev_printk(level, &(pdev)->dev, fmt, ##arg)
Expand Down
10 changes: 8 additions & 2 deletions kernel/dma/direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,16 @@ void *dma_direct_alloc(struct device *dev, size_t size,
}

if (remap) {
pgprot_t prot = dma_pgprot(dev, PAGE_KERNEL, attrs);

if (force_dma_unencrypted(dev))
prot = pgprot_decrypted(prot);

/* remove any dirty cache lines on the kernel alias */
arch_dma_prep_coherent(page, size);

/* create a coherent mapping */
ret = dma_common_contiguous_remap(page, size,
dma_pgprot(dev, PAGE_KERNEL, attrs),
ret = dma_common_contiguous_remap(page, size, prot,
__builtin_return_address(0));
if (!ret)
goto out_free_pages;
Expand Down Expand Up @@ -535,6 +539,8 @@ int dma_direct_mmap(struct device *dev, struct vm_area_struct *vma,
int ret = -ENXIO;

vma->vm_page_prot = dma_pgprot(dev, vma->vm_page_prot, attrs);
if (force_dma_unencrypted(dev))
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);

if (dma_mmap_from_dev_coherent(dev, vma, cpu_addr, size, &ret))
return ret;
Expand Down
2 changes: 0 additions & 2 deletions kernel/dma/mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,6 @@ EXPORT_SYMBOL(dma_get_sgtable_attrs);
*/
pgprot_t dma_pgprot(struct device *dev, pgprot_t prot, unsigned long attrs)
{
if (force_dma_unencrypted(dev))
prot = pgprot_decrypted(prot);
if (dev_is_dma_coherent(dev))
return prot;
#ifdef CONFIG_ARCH_HAS_DMA_WRITE_COMBINE
Expand Down

0 comments on commit 63d12cc

Please sign in to comment.