Skip to content

Commit 974f83e

Browse files
Christoph Hellwigaegl
authored andcommitted
ia64: rework iommu probing
ia64 currently organizes the iommu probing along machves, which isn't very helpful. Instead just try to probe for Intel IOMMUs in mem_init as they are properly described in ACPI and if none was found initialize the swiotlb buffer. The HP SBA handling is then only done delayed when the actual hardware is probed. Only in the case that we actually found usable IOMMUs we then set up the DMA ops and free the not needed swiotlb buffer. This scheme gets rid of the need for the dma_init machvec operation, and the dig_vtd machvec. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lkml.kernel.org/r/20190813072514.23299-24-hch@lst.de Signed-off-by: Tony Luck <tony.luck@intel.com>
1 parent 16567ca commit 974f83e

14 files changed

Lines changed: 40 additions & 151 deletions

File tree

‎arch/ia64/Kconfig‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,6 @@ config IA64_DIG
146146
bool "DIG-compliant"
147147
select SWIOTLB
148148

149-
config IA64_DIG_VTD
150-
bool "DIG+Intel+IOMMU"
151-
select INTEL_IOMMU
152-
select PCI_MSI
153-
154149
config IA64_HP_ZX1
155150
bool "HP-zx1/sx1000"
156151
help

‎arch/ia64/Makefile‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ head-y := arch/ia64/kernel/head.o
5151
libs-y += arch/ia64/lib/
5252
core-y += arch/ia64/kernel/ arch/ia64/mm/
5353
core-$(CONFIG_IA64_DIG) += arch/ia64/dig/
54-
core-$(CONFIG_IA64_DIG_VTD) += arch/ia64/dig/
5554
core-$(CONFIG_IA64_GENERIC) += arch/ia64/dig/
5655
core-$(CONFIG_IA64_HP_ZX1) += arch/ia64/dig/
5756
core-$(CONFIG_IA64_SGI_UV) += arch/ia64/uv/

‎arch/ia64/dig/Makefile‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,4 @@
77
#
88

99
obj-y := setup.o
10-
ifeq ($(CONFIG_INTEL_IOMMU), y)
11-
obj-$(CONFIG_IA64_GENERIC) += machvec.o machvec_vtd.o
12-
else
1310
obj-$(CONFIG_IA64_GENERIC) += machvec.o
14-
endif
15-

‎arch/ia64/dig/machvec_vtd.c‎

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

‎arch/ia64/hp/common/sba_iommu.c‎

Lines changed: 28 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <linux/iommu-helper.h>
3636
#include <linux/dma-mapping.h>
3737
#include <linux/prefetch.h>
38+
#include <linux/swiotlb.h>
3839

3940
#include <asm/delay.h> /* ia64_get_itc() */
4041
#include <asm/io.h>
@@ -43,8 +44,6 @@
4344

4445
#include <asm/acpi-ext.h>
4546

46-
extern int swiotlb_late_init_with_default_size (size_t size);
47-
4847
#define PFX "IOC: "
4948

5049
/*
@@ -2056,27 +2055,33 @@ static int __init acpi_sba_ioc_init_acpi(void)
20562055
/* This has to run before acpi_scan_init(). */
20572056
arch_initcall(acpi_sba_ioc_init_acpi);
20582057

2058+
static int sba_dma_supported (struct device *dev, u64 mask)
2059+
{
2060+
/* make sure it's at least 32bit capable */
2061+
return ((mask & 0xFFFFFFFFUL) == 0xFFFFFFFFUL);
2062+
}
2063+
2064+
static const struct dma_map_ops sba_dma_ops = {
2065+
.alloc = sba_alloc_coherent,
2066+
.free = sba_free_coherent,
2067+
.map_page = sba_map_page,
2068+
.unmap_page = sba_unmap_page,
2069+
.map_sg = sba_map_sg_attrs,
2070+
.unmap_sg = sba_unmap_sg_attrs,
2071+
.dma_supported = sba_dma_supported,
2072+
};
2073+
20592074
static int __init
20602075
sba_init(void)
20612076
{
2062-
if (!ia64_platform_is("hpzx1"))
2063-
return 0;
2064-
2065-
#if defined(CONFIG_IA64_GENERIC)
2066-
/* If we are booting a kdump kernel, the sba_iommu will
2067-
* cause devices that were not shutdown properly to MCA
2068-
* as soon as they are turned back on. Our only option for
2069-
* a successful kdump kernel boot is to use the swiotlb.
2077+
/*
2078+
* If we are booting a kdump kernel, the sba_iommu will cause devices
2079+
* that were not shutdown properly to MCA as soon as they are turned
2080+
* back on. Our only option for a successful kdump kernel boot is to
2081+
* use swiotlb.
20702082
*/
2071-
if (is_kdump_kernel()) {
2072-
dma_ops = NULL;
2073-
if (swiotlb_late_init_with_default_size(64 * (1<<20)) != 0)
2074-
panic("Unable to initialize software I/O TLB:"
2075-
" Try machvec=dig boot option");
2076-
machvec_init("dig");
2083+
if (is_kdump_kernel())
20772084
return 0;
2078-
}
2079-
#endif
20802085

20812086
/*
20822087
* ioc_found should be populated by the acpi_sba_ioc_handler's .attach()
@@ -2085,29 +2090,19 @@ sba_init(void)
20852090
while (ioc_found)
20862091
acpi_sba_ioc_add(ioc_found);
20872092

2088-
if (!ioc_list) {
2089-
#ifdef CONFIG_IA64_GENERIC
2090-
/*
2091-
* If we didn't find something sba_iommu can claim, we
2092-
* need to setup the swiotlb and switch to the dig machvec.
2093-
*/
2094-
dma_ops = NULL;
2095-
if (swiotlb_late_init_with_default_size(64 * (1<<20)) != 0)
2096-
panic("Unable to find SBA IOMMU or initialize "
2097-
"software I/O TLB: Try machvec=dig boot option");
2098-
machvec_init("dig");
2099-
#else
2100-
panic("Unable to find SBA IOMMU: Try a generic or DIG kernel");
2101-
#endif
2093+
if (!ioc_list)
21022094
return 0;
2103-
}
21042095

21052096
{
21062097
struct pci_bus *b = NULL;
21072098
while ((b = pci_find_next_bus(b)) != NULL)
21082099
sba_connect_bus(b);
21092100
}
21102101

2102+
/* no need for swiotlb with the iommu */
2103+
swiotlb_exit();
2104+
dma_ops = &sba_dma_ops;
2105+
21112106
#ifdef CONFIG_PROC_FS
21122107
ioc_proc_init();
21132108
#endif
@@ -2123,12 +2118,6 @@ nosbagart(char *str)
21232118
return 1;
21242119
}
21252120

2126-
static int sba_dma_supported (struct device *dev, u64 mask)
2127-
{
2128-
/* make sure it's at least 32bit capable */
2129-
return ((mask & 0xFFFFFFFFUL) == 0xFFFFFFFFUL);
2130-
}
2131-
21322121
__setup("nosbagart", nosbagart);
21332122

21342123
static int __init
@@ -2153,18 +2142,3 @@ sba_page_override(char *str)
21532142
}
21542143

21552144
__setup("sbapagesize=",sba_page_override);
2156-
2157-
const struct dma_map_ops sba_dma_ops = {
2158-
.alloc = sba_alloc_coherent,
2159-
.free = sba_free_coherent,
2160-
.map_page = sba_map_page,
2161-
.unmap_page = sba_unmap_page,
2162-
.map_sg = sba_map_sg_attrs,
2163-
.unmap_sg = sba_unmap_sg_attrs,
2164-
.dma_supported = sba_dma_supported,
2165-
};
2166-
2167-
void sba_dma_init(void)
2168-
{
2169-
dma_ops = &sba_dma_ops;
2170-
}

‎arch/ia64/include/asm/acpi.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ static inline const char *acpi_get_sysname (void)
4343
return "uv";
4444
# elif defined (CONFIG_IA64_DIG)
4545
return "dig";
46-
# elif defined(CONFIG_IA64_DIG_VTD)
47-
return "dig_vtd";
4846
# else
4947
# error Unknown platform. Fix acpi.c.
5048
# endif

‎arch/ia64/include/asm/machvec.h‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@
1616
struct device;
1717

1818
typedef void ia64_mv_setup_t (char **);
19-
typedef void ia64_mv_dma_init (void);
2019

2120
extern void machvec_setup (char **);
2221

2322
# if defined (CONFIG_IA64_DIG)
2423
# include <asm/machvec_dig.h>
25-
# elif defined(CONFIG_IA64_DIG_VTD)
26-
# include <asm/machvec_dig_vtd.h>
2724
# elif defined (CONFIG_IA64_HP_ZX1)
2825
# include <asm/machvec_hpzx1.h>
2926
# elif defined (CONFIG_IA64_SGI_UV)
@@ -35,7 +32,6 @@ extern void machvec_setup (char **);
3532
# else
3633
# define ia64_platform_name ia64_mv.name
3734
# define platform_setup ia64_mv.setup
38-
# define platform_dma_init ia64_mv.dma_init
3935
# endif
4036

4137
/* __attribute__((__aligned__(16))) is required to make size of the
@@ -46,14 +42,12 @@ extern void machvec_setup (char **);
4642
struct ia64_machine_vector {
4743
const char *name;
4844
ia64_mv_setup_t *setup;
49-
ia64_mv_dma_init *dma_init;
5045
} __attribute__((__aligned__(16))); /* align attrib? see above comment */
5146

5247
#define MACHVEC_INIT(name) \
5348
{ \
5449
#name, \
5550
platform_setup, \
56-
platform_dma_init, \
5751
}
5852

5953
extern struct ia64_machine_vector ia64_mv;
@@ -64,17 +58,12 @@ extern void machvec_init_from_cmdline(const char *cmdline);
6458
# error Unknown configuration. Update arch/ia64/include/asm/machvec.h.
6559
# endif /* CONFIG_IA64_GENERIC */
6660

67-
extern void swiotlb_dma_init(void);
68-
6961
/*
7062
* Define default versions so we can extend machvec for new platforms without having
7163
* to update the machvec files for all existing platforms.
7264
*/
7365
#ifndef platform_setup
7466
# define platform_setup machvec_setup
7567
#endif
76-
#ifndef platform_dma_init
77-
# define platform_dma_init swiotlb_dma_init
78-
#endif
7968

8069
#endif /* _ASM_IA64_MACHVEC_H */

‎arch/ia64/include/asm/machvec_dig_vtd.h‎

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

‎arch/ia64/include/asm/machvec_hpzx1.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#define _ASM_IA64_MACHVEC_HPZX1_h
44

55
extern ia64_mv_setup_t dig_setup;
6-
extern ia64_mv_dma_init sba_dma_init;
76

87
/*
98
* This stuff has dual use!
@@ -14,6 +13,5 @@ extern ia64_mv_dma_init sba_dma_init;
1413
*/
1514
#define ia64_platform_name "hpzx1"
1615
#define platform_setup dig_setup
17-
#define platform_dma_init sba_dma_init
1816

1917
#endif /* _ASM_IA64_MACHVEC_HPZX1_h */

‎arch/ia64/include/asm/pci.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,4 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
6969
return channel ? isa_irq_to_vector(15) : isa_irq_to_vector(14);
7070
}
7171

72-
#ifdef CONFIG_INTEL_IOMMU
73-
extern void pci_iommu_alloc(void);
74-
#endif
7572
#endif /* _ASM_IA64_PCI_H */

0 commit comments

Comments
 (0)