mirror of
https://github.com/torvalds/linux.git
synced 2024-11-18 10:01:43 +00:00
57c8a661d9
Move remaining definitions and declarations from include/linux/bootmem.h into include/linux/memblock.h and remove the redundant header. The includes were replaced with the semantic patch below and then semi-automated removal of duplicated '#include <linux/memblock.h> @@ @@ - #include <linux/bootmem.h> + #include <linux/memblock.h> [sfr@canb.auug.org.au: dma-direct: fix up for the removal of linux/bootmem.h] Link: http://lkml.kernel.org/r/20181002185342.133d1680@canb.auug.org.au [sfr@canb.auug.org.au: powerpc: fix up for removal of linux/bootmem.h] Link: http://lkml.kernel.org/r/20181005161406.73ef8727@canb.auug.org.au [sfr@canb.auug.org.au: x86/kaslr, ACPI/NUMA: fix for linux/bootmem.h removal] Link: http://lkml.kernel.org/r/20181008190341.5e396491@canb.auug.org.au Link: http://lkml.kernel.org/r/1536927045-23536-30-git-send-email-rppt@linux.vnet.ibm.com Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au> Acked-by: Michal Hocko <mhocko@suse.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Chris Zankel <chris@zankel.net> Cc: "David S. Miller" <davem@davemloft.net> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Greentime Hu <green.hu@gmail.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Guan Xuetao <gxt@pku.edu.cn> Cc: Ingo Molnar <mingo@redhat.com> Cc: "James E.J. Bottomley" <jejb@parisc-linux.org> Cc: Jonas Bonn <jonas@southpole.se> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Ley Foon Tan <lftan@altera.com> Cc: Mark Salter <msalter@redhat.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Matt Turner <mattst88@gmail.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Michal Simek <monstr@monstr.eu> Cc: Palmer Dabbelt <palmer@sifive.com> Cc: Paul Burton <paul.burton@mips.com> Cc: Richard Kuo <rkuo@codeaurora.org> Cc: Richard Weinberger <richard@nod.at> Cc: Rich Felker <dalias@libc.org> Cc: Russell King <linux@armlinux.org.uk> Cc: Serge Semin <fancer.lancer@gmail.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Tony Luck <tony.luck@intel.com> Cc: Vineet Gupta <vgupta@synopsys.com> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
197 lines
4.6 KiB
C
197 lines
4.6 KiB
C
// 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/memblock.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.
|
|
* It is also possible to disable by default in kernel config, and enable with
|
|
* iommu=nopt at boot time.
|
|
*/
|
|
#ifdef CONFIG_IOMMU_DEFAULT_PASSTHROUGH
|
|
int iommu_pass_through __read_mostly = 1;
|
|
#else
|
|
int iommu_pass_through __read_mostly;
|
|
#endif
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
|
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;
|
|
if (!strncmp(p, "nopt", 4))
|
|
iommu_pass_through = 0;
|
|
|
|
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;
|
|
}
|
|
early_param("iommu", iommu_setup);
|
|
|
|
static int __init pci_iommu_init(void)
|
|
{
|
|
struct iommu_table_entry *p;
|
|
|
|
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;
|
|
}
|
|
/* 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.bus_dma_mask = DMA_BIT_MASK(32);
|
|
return 0;
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_VIA, PCI_ANY_ID,
|
|
PCI_CLASS_BRIDGE_PCI, 8, via_no_dac);
|
|
#endif
|