Skip to content

Commit 63d12cc

Browse files
committed
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
2 parents 5dee872 + 4fe87e8 commit 63d12cc

File tree

5 files changed

+16
-142
lines changed

5 files changed

+16
-142
lines changed

Documentation/PCI/pci.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,20 +278,20 @@ appropriate parameters. In general this allows more efficient DMA
278278
on systems where System RAM exists above 4G _physical_ address.
279279

280280
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.
282282

283283
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().
286286
Again, this includes drivers for all PCI-X and PCIe compliant devices.
287287
Many 64-bit "PCI" devices (before PCI-X) and some PCI-X devices are
288288
64-bit DMA capable for payload ("streaming") data but not control
289-
("consistent") data.
289+
("coherent") data.
290290

291291

292292
Setup shared control data
293293
-------------------------
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)
295295
memory. See Documentation/core-api/dma-api.rst for a full description of
296296
the DMA APIs. This section is just a reminder that it needs to be done
297297
before enabling DMA on the device.
@@ -367,7 +367,7 @@ steps need to be performed:
367367
- Disable the device from generating IRQs
368368
- Release the IRQ (free_irq())
369369
- Stop all DMA activity
370-
- Release DMA buffers (both streaming and consistent)
370+
- Release DMA buffers (both streaming and coherent)
371371
- Unregister from other subsystems (e.g. scsi or netdev)
372372
- Disable device from responding to MMIO/IO Port addresses
373373
- Release MMIO/IO Port resource(s)
@@ -420,7 +420,7 @@ Once DMA is stopped, clean up streaming DMA first.
420420
I.e. unmap data buffers and return buffers to "upstream"
421421
owners if there is one.
422422

423-
Then clean up "consistent" buffers which contain the control data.
423+
Then clean up "coherent" buffers which contain the control data.
424424

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

include/linux/pci-dma-compat.h

Lines changed: 0 additions & 129 deletions
This file was deleted.

include/linux/pci.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2473,8 +2473,7 @@ static inline bool pci_is_thunderbolt_attached(struct pci_dev *pdev)
24732473
void pci_uevent_ers(struct pci_dev *pdev, enum pci_ers_result err_type);
24742474
#endif
24752475

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

24792478
#define pci_printk(level, pdev, fmt, arg...) \
24802479
dev_printk(level, &(pdev)->dev, fmt, ##arg)

kernel/dma/direct.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,16 @@ void *dma_direct_alloc(struct device *dev, size_t size,
277277
}
278278

279279
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+
280285
/* remove any dirty cache lines on the kernel alias */
281286
arch_dma_prep_coherent(page, size);
282287

283288
/* 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,
286290
__builtin_return_address(0));
287291
if (!ret)
288292
goto out_free_pages;
@@ -535,6 +539,8 @@ int dma_direct_mmap(struct device *dev, struct vm_area_struct *vma,
535539
int ret = -ENXIO;
536540

537541
vma->vm_page_prot = dma_pgprot(dev, vma->vm_page_prot, attrs);
542+
if (force_dma_unencrypted(dev))
543+
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
538544

539545
if (dma_mmap_from_dev_coherent(dev, vma, cpu_addr, size, &ret))
540546
return ret;

kernel/dma/mapping.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,6 @@ EXPORT_SYMBOL(dma_get_sgtable_attrs);
407407
*/
408408
pgprot_t dma_pgprot(struct device *dev, pgprot_t prot, unsigned long attrs)
409409
{
410-
if (force_dma_unencrypted(dev))
411-
prot = pgprot_decrypted(prot);
412410
if (dev_is_dma_coherent(dev))
413411
return prot;
414412
#ifdef CONFIG_ARCH_HAS_DMA_WRITE_COMBINE

0 commit comments

Comments
 (0)