Skip to content

Commit

Permalink
x86: remove the IOMMU table infrastructure
Browse files Browse the repository at this point in the history
The IOMMU table tries to separate the different IOMMUs into different
backends, but actually requires various cross calls.

Rewrite the code to do the generic swiotlb/swiotlb-xen setup directly
in pci-dma.c and then just call into the IOMMU drivers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tested-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
  • Loading branch information
Christoph Hellwig committed Apr 18, 2022
1 parent f39f8d0 commit 78013ea
Show file tree
Hide file tree
Showing 21 changed files with 110 additions and 459 deletions.
7 changes: 0 additions & 7 deletions arch/ia64/include/asm/iommu_table.h

This file was deleted.

1 change: 0 additions & 1 deletion arch/x86/include/asm/dma-mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include <linux/scatterlist.h>
#include <asm/io.h>
#include <asm/swiotlb.h>

extern int iommu_merge;
extern int panic_on_overflow;
Expand Down
5 changes: 2 additions & 3 deletions arch/x86/include/asm/gart.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extern int gart_iommu_aperture_disabled;
extern void early_gart_iommu_check(void);
extern int gart_iommu_init(void);
extern void __init gart_parse_options(char *);
extern int gart_iommu_hole_init(void);
void gart_iommu_hole_init(void);

#else
#define gart_iommu_aperture 0
Expand All @@ -51,9 +51,8 @@ static inline void early_gart_iommu_check(void)
static inline void gart_parse_options(char *options)
{
}
static inline int gart_iommu_hole_init(void)
static inline void gart_iommu_hole_init(void)
{
return -ENODEV;
}
#endif

Expand Down
6 changes: 6 additions & 0 deletions arch/x86/include/asm/iommu.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
extern int force_iommu, no_iommu;
extern int iommu_detected;

#ifdef CONFIG_SWIOTLB
extern bool x86_swiotlb_enable;
#else
#define x86_swiotlb_enable false
#endif

/* 10 seconds */
#define DMAR_OPERATION_TIMEOUT ((cycles_t) tsc_khz*10*1000)

Expand Down
102 changes: 0 additions & 102 deletions arch/x86/include/asm/iommu_table.h

This file was deleted.

30 changes: 0 additions & 30 deletions arch/x86/include/asm/swiotlb.h

This file was deleted.

2 changes: 0 additions & 2 deletions arch/x86/include/asm/xen/swiotlb-xen.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
#define _ASM_X86_SWIOTLB_XEN_H

#ifdef CONFIG_SWIOTLB_XEN
extern int __init pci_xen_swiotlb_detect(void);
extern int pci_xen_swiotlb_init_late(void);
#else
#define pci_xen_swiotlb_detect NULL
static inline int pci_xen_swiotlb_init_late(void) { return -ENXIO; }
#endif

Expand Down
2 changes: 0 additions & 2 deletions arch/x86/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ obj-y += bootflag.o e820.o
obj-y += pci-dma.o quirks.o topology.o kdebugfs.o
obj-y += alternative.o i8253.o hw_breakpoint.o
obj-y += tsc.o tsc_msr.o io_delay.o rtc.o
obj-y += pci-iommu_table.o
obj-y += resource.o
obj-y += irqflags.o
obj-y += static_call.o
Expand Down Expand Up @@ -134,7 +133,6 @@ obj-$(CONFIG_PCSPKR_PLATFORM) += pcspeaker.o

obj-$(CONFIG_X86_CHECK_BIOS_CORRUPTION) += check.o

obj-$(CONFIG_SWIOTLB) += pci-swiotlb.o
obj-$(CONFIG_OF) += devicetree.o
obj-$(CONFIG_UPROBES) += uprobes.o

Expand Down
5 changes: 1 addition & 4 deletions arch/x86/kernel/amd_gart_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@
#include <asm/iommu.h>
#include <asm/gart.h>
#include <asm/set_memory.h>
#include <asm/swiotlb.h>
#include <asm/dma.h>
#include <asm/amd_nb.h>
#include <asm/x86_init.h>
#include <asm/iommu_table.h>

static unsigned long iommu_bus_base; /* GART remapping area (physical) */
static unsigned long iommu_size; /* size of remapping area bytes */
Expand Down Expand Up @@ -808,7 +806,7 @@ int __init gart_iommu_init(void)
flush_gart();
dma_ops = &gart_dma_ops;
x86_platform.iommu_shutdown = gart_iommu_shutdown;
swiotlb = 0;
x86_swiotlb_enable = false;

return 0;
}
Expand Down Expand Up @@ -842,4 +840,3 @@ void __init gart_parse_options(char *p)
}
}
}
IOMMU_INIT_POST(gart_iommu_hole_init);
14 changes: 5 additions & 9 deletions arch/x86/kernel/aperture_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ void __init early_gart_iommu_check(void)

static int __initdata printed_gart_size_msg;

int __init gart_iommu_hole_init(void)
void __init gart_iommu_hole_init(void)
{
u32 agp_aper_base = 0, agp_aper_order = 0;
u32 aper_size, aper_alloc = 0, aper_order = 0, last_aper_order = 0;
Expand All @@ -401,11 +401,11 @@ int __init gart_iommu_hole_init(void)
int i, node;

if (!amd_gart_present())
return -ENODEV;
return;

if (gart_iommu_aperture_disabled || !fix_aperture ||
!early_pci_allowed())
return -ENODEV;
return;

pr_info("Checking aperture...\n");

Expand Down Expand Up @@ -491,10 +491,8 @@ int __init gart_iommu_hole_init(void)
* and fixed up the northbridge
*/
exclude_from_core(last_aper_base, last_aper_order);

return 1;
}
return 0;
return;
}

if (!fallback_aper_force) {
Expand Down Expand Up @@ -527,7 +525,7 @@ int __init gart_iommu_hole_init(void)
panic("Not enough memory for aperture");
}
} else {
return 0;
return;
}

/*
Expand Down Expand Up @@ -561,6 +559,4 @@ int __init gart_iommu_hole_init(void)
}

set_up_gart_resume(aper_order, aper_alloc);

return 1;
}
Loading

0 comments on commit 78013ea

Please sign in to comment.