cregit-Linux how code gets into the kernel

Release 4.18 arch/x86/kernel/pci-dma.c

Directory: arch/x86/kernel
// SPDX-License-Identifier: GPL-2.0
#include <linux/dma-direct.h>
#include <linux/dma-debug.h>
#include <linux/dmar.h>
#include <linux/export.h>
#include <linux/bootmem.h>
#include <linux/gfp.h>
#include <linux/pci.h>

#include <asm/proto.h>
#include <asm/dma.h>
#include <asm/iommu.h>
#include <asm/gart.h>
#include <asm/calgary.h>
#include <asm/x86_init.h>
#include <asm/iommu_table.h>


static bool disable_dac_quirk __read_mostly;


const struct dma_map_ops *dma_ops = &dma_direct_ops;
EXPORT_SYMBOL(dma_ops);

#ifdef CONFIG_IOMMU_DEBUG

int panic_on_overflow __read_mostly = 1;

int force_iommu __read_mostly = 1;
#else

int panic_on_overflow __read_mostly = 0;

int force_iommu __read_mostly = 0;
#endif


int iommu_merge __read_mostly = 0;


int no_iommu __read_mostly;
/* Set this to 1 if there is a HW IOMMU in the system */

int iommu_detected __read_mostly = 0;

/*
 * This variable becomes 1 if iommu=pt is passed on the kernel command line.
 * If this variable is 1, IOMMU implementations do no DMA translation for
 * devices and allow every device to access to whole physical memory. This is
 * useful if a user wants to use an IOMMU only for KVM device assignment to
 * guests and not for driver dma translation.
 */

int iommu_pass_through __read_mostly;

extern struct iommu_table_entry __iommu_table[], __iommu_table_end[];

/* Dummy device used for NULL arguments (normally ISA). */

struct device x86_dma_fallback_dev = {
	.init_name = "fallback device",
	.coherent_dma_mask = ISA_DMA_BIT_MASK,
	.dma_mask = &x86_dma_fallback_dev.coherent_dma_mask,
};
EXPORT_SYMBOL(x86_dma_fallback_dev);


void __init pci_iommu_alloc(void) { struct iommu_table_entry *p; sort_iommu_table(__iommu_table, __iommu_table_end); check_iommu_entries(__iommu_table, __iommu_table_end); for (p = __iommu_table; p < __iommu_table_end; p++) { if (p && p->detect && p->detect() > 0) { p->flags |= IOMMU_DETECTED; if (p->early_init) p->early_init(); if (p->flags & IOMMU_FINISH_IF_DETECTED) break; } } }

Contributors

PersonTokensPropCommitsCommitProp
Konrad Rzeszutek Wilk7183.53%240.00%
Glauber de Oliveira Costa89.41%120.00%
FUJITA Tomonori67.06%240.00%
Total85100.00%5100.00%


bool arch_dma_alloc_attrs(struct device **dev) { if (!*dev) *dev = &x86_dma_fallback_dev; if (!is_device_dma_capable(*dev)) return false; return true; }

Contributors

PersonTokensPropCommitsCommitProp
Denys Vlasenko2052.63%133.33%
Ville Syrjälä1231.58%133.33%
Christoph Hellwig615.79%133.33%
Total38100.00%3100.00%

EXPORT_SYMBOL(arch_dma_alloc_attrs); /* * See <Documentation/x86/x86_64/boot-options.txt> for the iommu kernel * parameter documentation. */
static __init int iommu_setup(char *p) { iommu_merge = 1; if (!p) return -EINVAL; while (*p) { if (!strncmp(p, "off", 3)) no_iommu = 1; /* gart_parse_options has more force support */ if (!strncmp(p, "force", 5)) force_iommu = 1; if (!strncmp(p, "noforce", 7)) { iommu_merge = 0; force_iommu = 0; } if (!strncmp(p, "biomerge", 8)) { iommu_merge = 1; force_iommu = 1; } if (!strncmp(p, "panic", 5)) panic_on_overflow = 1; if (!strncmp(p, "nopanic", 7)) panic_on_overflow = 0; if (!strncmp(p, "merge", 5)) { iommu_merge = 1; force_iommu = 1; } if (!strncmp(p, "nomerge", 7)) iommu_merge = 0; if (!strncmp(p, "forcesac", 8)) pr_warn("forcesac option ignored.\n"); if (!strncmp(p, "allowdac", 8)) pr_warn("allowdac option ignored.\n"); if (!strncmp(p, "nodac", 5)) pr_warn("nodac option ignored.\n"); if (!strncmp(p, "usedac", 6)) { disable_dac_quirk = true; return 1; } #ifdef CONFIG_SWIOTLB if (!strncmp(p, "soft", 4)) swiotlb = 1; #endif if (!strncmp(p, "pt", 2)) iommu_pass_through = 1; gart_parse_options(p); #ifdef CONFIG_CALGARY_IOMMU if (!strncmp(p, "calgary", 7)) use_calgary = 1; #endif /* CONFIG_CALGARY_IOMMU */ p += strcspn(p, ","); if (*p == ',') ++p; } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Glauber de Oliveira Costa30490.48%228.57%
Fenghua Yu164.76%114.29%
Christoph Hellwig144.17%342.86%
David Woodhouse20.60%114.29%
Total336100.00%7100.00%

early_param("iommu", iommu_setup);
static int __init pci_iommu_init(void) { struct iommu_table_entry *p; #ifdef CONFIG_PCI dma_debug_add_bus(&pci_bus_type); #endif x86_init.iommu.iommu_init(); for (p = __iommu_table; p < __iommu_table_end; p++) { if (p && (p->flags & IOMMU_DETECTED) && p->late_init) p->late_init(); } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Konrad Rzeszutek Wilk3549.30%120.00%
FUJITA Tomonori1318.31%240.00%
Glauber de Oliveira Costa1216.90%120.00%
Joerg Roedel1115.49%120.00%
Total71100.00%5100.00%

/* Must execute after PCI subsystem */ rootfs_initcall(pci_iommu_init); #ifdef CONFIG_PCI /* Many VIA bridges seem to corrupt data for DAC. Disable it here */
static int via_no_dac_cb(struct pci_dev *pdev, void *data) { pdev->dev.dma_32bit_limit = true; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig26100.00%1100.00%
Total26100.00%1100.00%


static void via_no_dac(struct pci_dev *dev) { if (!disable_dac_quirk) { dev_info(&dev->dev, "disabling DAC on VIA PCI bridge\n"); pci_walk_bus(dev->subordinate, via_no_dac_cb, NULL); } }

Contributors

PersonTokensPropCommitsCommitProp
Fenghua Yu2051.28%133.33%
Christoph Hellwig1230.77%133.33%
Björn Helgaas717.95%133.33%
Total39100.00%3100.00%

DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_VIA, PCI_ANY_ID, PCI_CLASS_BRIDGE_PCI, 8, via_no_dac); #endif

Overall Contributors

PersonTokensPropCommitsCommitProp
Glauber de Oliveira Costa43555.27%817.02%
Konrad Rzeszutek Wilk11814.99%24.26%
Christoph Hellwig638.01%612.77%
Fenghua Yu567.12%36.38%
Joerg Roedel273.43%612.77%
Denys Vlasenko243.05%24.26%
FUJITA Tomonori232.92%612.77%
Ville Syrjälä121.52%12.13%
Björn Helgaas70.89%12.13%
Yinghai Lu50.64%12.13%
Tejun Heo30.38%12.13%
David Woodhouse30.38%24.26%
Paul Gortmaker30.38%12.13%
Jan Beulich20.25%12.13%
Bart Van Assche10.13%12.13%
Greg Kroah-Hartman10.13%12.13%
Kay Sievers10.13%12.13%
Paul Bolle10.13%12.13%
Ingo Molnar10.13%12.13%
Justin P. Mattock10.13%12.13%
Huaisheng Ye0.00%00.00%
Total787100.00%47100.00%
Directory: arch/x86/kernel
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.