Release 4.14 arch/x86/kernel/pci-swiotlb.c
// SPDX-License-Identifier: GPL-2.0
/* Glue code to lib/swiotlb.c */
#include <linux/pci.h>
#include <linux/cache.h>
#include <linux/init.h>
#include <linux/swiotlb.h>
#include <linux/bootmem.h>
#include <linux/dma-mapping.h>
#include <linux/mem_encrypt.h>
#include <asm/iommu.h>
#include <asm/swiotlb.h>
#include <asm/dma.h>
#include <asm/xen/swiotlb-xen.h>
#include <asm/iommu_table.h>
int swiotlb __read_mostly;
void *x86_swiotlb_alloc_coherent(struct device *hwdev, size_t size,
dma_addr_t *dma_handle, gfp_t flags,
unsigned long attrs)
{
void *vaddr;
/*
* Don't print a warning when the first allocation attempt fails.
* swiotlb_alloc_coherent() will print a warning when the DMA
* memory allocation ultimately failed.
*/
flags |= __GFP_NOWARN;
vaddr = dma_generic_alloc_coherent(hwdev, size, dma_handle, flags,
attrs);
if (vaddr)
return vaddr;
return swiotlb_alloc_coherent(hwdev, size, dma_handle, flags);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
FUJITA Tomonori | 57 | 83.82% | 1 | 25.00% |
Joerg Roedel | 5 | 7.35% | 1 | 25.00% |
Andrzej Pietrasiewicz | 4 | 5.88% | 1 | 25.00% |
Krzysztof Kozlowski | 2 | 2.94% | 1 | 25.00% |
Total | 68 | 100.00% | 4 | 100.00% |
void x86_swiotlb_free_coherent(struct device *dev, size_t size,
void *vaddr, dma_addr_t dma_addr,
unsigned long attrs)
{
if (is_swiotlb_buffer(dma_to_phys(dev, dma_addr)))
swiotlb_free_coherent(dev, size, vaddr, dma_addr);
else
dma_generic_free_coherent(dev, size, vaddr, dma_addr, attrs);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andrzej Pietrasiewicz | 33 | 54.10% | 1 | 33.33% |
Akinobu Mita | 26 | 42.62% | 1 | 33.33% |
Krzysztof Kozlowski | 2 | 3.28% | 1 | 33.33% |
Total | 61 | 100.00% | 3 | 100.00% |
static const struct dma_map_ops swiotlb_dma_ops = {
.mapping_error = swiotlb_dma_mapping_error,
.alloc = x86_swiotlb_alloc_coherent,
.free = x86_swiotlb_free_coherent,
.sync_single_for_cpu = swiotlb_sync_single_for_cpu,
.sync_single_for_device = swiotlb_sync_single_for_device,
.sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
.sync_sg_for_device = swiotlb_sync_sg_for_device,
.map_sg = swiotlb_map_sg_attrs,
.unmap_sg = swiotlb_unmap_sg_attrs,
.map_page = swiotlb_map_page,
.unmap_page = swiotlb_unmap_page,
.dma_supported = NULL,
};
/*
* pci_swiotlb_detect_override - set swiotlb to 1 if necessary
*
* This returns non-zero if we are forced to use swiotlb (by the boot
* option).
*/
int __init pci_swiotlb_detect_override(void)
{
if (swiotlb_force == SWIOTLB_FORCE)
swiotlb = 1;
return swiotlb;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Konrad Rzeszutek Wilk | 12 | 57.14% | 1 | 16.67% |
Muli Ben-Yehuda | 4 | 19.05% | 1 | 16.67% |
Geert Uytterhoeven | 3 | 14.29% | 2 | 33.33% |
Jan Beulich | 1 | 4.76% | 1 | 16.67% |
FUJITA Tomonori | 1 | 4.76% | 1 | 16.67% |
Total | 21 | 100.00% | 6 | 100.00% |
IOMMU_INIT_FINISH(pci_swiotlb_detect_override,
pci_xen_swiotlb_detect,
pci_swiotlb_init,
pci_swiotlb_late_init);
/*
* If 4GB or more detected (and iommu=off not set) or if SME is active
* then set swiotlb to 1 and return 1.
*/
int __init pci_swiotlb_detect_4gb(void)
{
/* don't initialize swiotlb if iommu=off (no_iommu=1) */
#ifdef CONFIG_X86_64
if (!no_iommu && max_possible_pfn > MAX_DMA32_PFN)
swiotlb = 1;
#endif
/*
* If SME is active then swiotlb will be set to 1 so that bounce
* buffers are allocated and used for devices that do not support
* the addressing range required for the encryption mask.
*/
if (sme_active())
swiotlb = 1;
return swiotlb;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Tom Lendacky | 10 | 25.00% | 1 | 14.29% |
Muli Ben-Yehuda | 8 | 20.00% | 1 | 14.29% |
Konrad Rzeszutek Wilk | 8 | 20.00% | 1 | 14.29% |
Andi Kleen | 5 | 12.50% | 1 | 14.29% |
Jeremy Fitzhardinge | 5 | 12.50% | 1 | 14.29% |
FUJITA Tomonori | 3 | 7.50% | 1 | 14.29% |
Igor Mammedov | 1 | 2.50% | 1 | 14.29% |
Total | 40 | 100.00% | 7 | 100.00% |
IOMMU_INIT(pci_swiotlb_detect_4gb,
pci_swiotlb_detect_override,
pci_swiotlb_init,
pci_swiotlb_late_init);
void __init pci_swiotlb_init(void)
{
if (swiotlb) {
swiotlb_init(0);
dma_ops = &swiotlb_dma_ops;
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Muli Ben-Yehuda | 13 | 54.17% | 1 | 25.00% |
FUJITA Tomonori | 11 | 45.83% | 3 | 75.00% |
Total | 24 | 100.00% | 4 | 100.00% |
void __init pci_swiotlb_late_init(void)
{
/* An IOMMU turned us off. */
if (!swiotlb)
swiotlb_free();
else {
printk(KERN_INFO "PCI-DMA: "
"Using software bounce buffering for IO (SWIOTLB)\n");
swiotlb_print_info();
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Konrad Rzeszutek Wilk | 30 | 100.00% | 1 | 100.00% |
Total | 30 | 100.00% | 1 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Muli Ben-Yehuda | 97 | 25.66% | 1 | 3.70% |
FUJITA Tomonori | 87 | 23.02% | 7 | 25.93% |
Konrad Rzeszutek Wilk | 79 | 20.90% | 2 | 7.41% |
Andrzej Pietrasiewicz | 40 | 10.58% | 1 | 3.70% |
Akinobu Mita | 26 | 6.88% | 1 | 3.70% |
Tom Lendacky | 14 | 3.70% | 1 | 3.70% |
Jeremy Fitzhardinge | 11 | 2.91% | 2 | 7.41% |
Andi Kleen | 5 | 1.32% | 1 | 3.70% |
Joerg Roedel | 5 | 1.32% | 1 | 3.70% |
Krzysztof Kozlowski | 4 | 1.06% | 1 | 3.70% |
Geert Uytterhoeven | 3 | 0.79% | 2 | 7.41% |
Greg Kroah-Hartman | 1 | 0.26% | 1 | 3.70% |
Jan Beulich | 1 | 0.26% | 1 | 3.70% |
Jaswinder Singh Rajput | 1 | 0.26% | 1 | 3.70% |
Paul Gortmaker | 1 | 0.26% | 1 | 3.70% |
Bart Van Assche | 1 | 0.26% | 1 | 3.70% |
Igor Mammedov | 1 | 0.26% | 1 | 3.70% |
Rolf Eike Beer | 1 | 0.26% | 1 | 3.70% |
Total | 378 | 100.00% | 27 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.