Skip to content

Commit bb8e15d

Browse files
Kefeng Wangrobherring
authored andcommitted
of: iommu: make of_iommu_init() postcore_initcall_sync
The of_iommu_init() is called multiple times by arch code, make it postcore_initcall_sync, then we can drop relevant calls fully. Note, the IOMMUs should have a chance to perform some basic initialisation before we start adding masters to them. So postcore_initcall_sync is good choice, it ensures of_iommu_init() called before of_platform_populate. Acked-by: Rich Felker <dalias@libc.org> Tested-by: Marek Szyprowski <m.szyprowski@samsung.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Marek Szyprowski <m.szyprowski@samsung.com> Cc: Rich Felker <dalias@libc.org> Cc: Rob Herring <robh+dt@kernel.org> Cc: Robin Murphy <robin.murphy@arm.com> Cc: Will Deacon <will.deacon@arm.com> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> Acked-by: Joerg Roedel <jroedel@suse.de> Signed-off-by: Rob Herring <robh@kernel.org>
1 parent 5edb564 commit bb8e15d

File tree

5 files changed

+4
-9
lines changed

5 files changed

+4
-9
lines changed

arch/arm/kernel/setup.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <linux/bootmem.h>
2020
#include <linux/seq_file.h>
2121
#include <linux/screen_info.h>
22-
#include <linux/of_iommu.h>
2322
#include <linux/of_platform.h>
2423
#include <linux/init.h>
2524
#include <linux/kexec.h>
@@ -903,7 +902,6 @@ static int __init customize_machine(void)
903902
* machine from the device tree, if no callback is provided,
904903
* otherwise we would always need an init_machine callback.
905904
*/
906-
of_iommu_init();
907905
if (machine_desc->init_machine)
908906
machine_desc->init_machine();
909907
#ifdef CONFIG_OF

arch/arm64/kernel/setup.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#include <linux/fs.h>
4040
#include <linux/proc_fs.h>
4141
#include <linux/memblock.h>
42-
#include <linux/of_iommu.h>
4342
#include <linux/of_fdt.h>
4443
#include <linux/of_platform.h>
4544
#include <linux/efi.h>
@@ -305,7 +304,6 @@ void __init setup_arch(char **cmdline_p)
305304
static int __init arm64_device_init(void)
306305
{
307306
if (of_have_populated_dt()) {
308-
of_iommu_init();
309307
of_platform_populate(NULL, of_default_bus_match_table,
310308
NULL, NULL);
311309
} else if (acpi_disabled) {

arch/sh/boards/of-generic.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <linux/of.h>
1212
#include <linux/of_platform.h>
1313
#include <linux/of_fdt.h>
14-
#include <linux/of_iommu.h>
1514
#include <linux/clocksource.h>
1615
#include <linux/irqchip.h>
1716
#include <linux/clk-provider.h>
@@ -185,7 +184,6 @@ static int __init sh_of_device_init(void)
185184
{
186185
pr_info("SH generic board support: populating platform devices\n");
187186
if (of_have_populated_dt()) {
188-
of_iommu_init();
189187
of_platform_populate(NULL, of_default_bus_match_table,
190188
NULL, NULL);
191189
} else {

drivers/iommu/of_iommu.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ const struct iommu_ops *of_iommu_configure(struct device *dev,
174174
return NULL;
175175
}
176176

177-
void __init of_iommu_init(void)
177+
static int __init of_iommu_init(void)
178178
{
179179
struct device_node *np;
180180
const struct of_device_id *match, *matches = &__iommu_of_table;
@@ -186,4 +186,7 @@ void __init of_iommu_init(void)
186186
pr_err("Failed to initialise IOMMU %s\n",
187187
of_node_full_name(np));
188188
}
189+
190+
return 0;
189191
}
192+
postcore_initcall_sync(of_iommu_init);

include/linux/of_iommu.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ extern int of_get_dma_window(struct device_node *dn, const char *prefix,
1111
int index, unsigned long *busno, dma_addr_t *addr,
1212
size_t *size);
1313

14-
extern void of_iommu_init(void);
1514
extern const struct iommu_ops *of_iommu_configure(struct device *dev,
1615
struct device_node *master_np);
1716

@@ -24,7 +23,6 @@ static inline int of_get_dma_window(struct device_node *dn, const char *prefix,
2423
return -EINVAL;
2524
}
2625

27-
static inline void of_iommu_init(void) { }
2826
static inline const struct iommu_ops *of_iommu_configure(struct device *dev,
2927
struct device_node *master_np)
3028
{

0 commit comments

Comments
 (0)