diff mbox series

[1/2] x86: don't include asm/x86_init.h in asm/setup.h

Message ID 20171019105451.2892046-1-arnd@arndb.de
State New
Headers show
Series [1/2] x86: don't include asm/x86_init.h in asm/setup.h | expand

Commit Message

Arnd Bergmann Oct. 19, 2017, 10:53 a.m. UTC
This is a preparation to allow using 'struct timespec64' in the
asm/x86_init.h.  Unfortunately, we can't use a forward declaration
for timespec64 since it is defined as a macro on 64-bit architectures,
and including linux/time64.h breaks compilation of arch/x86/boot/,
which runs in realmode and can't use many of the regular kernel
headers.

As a workaround, I stop including asm/x86_init.h. This works fine
for the realmode boot code since it does not require any of the
x86_init.h contents, and setup.h doesn't either. However, a couple
of other files that do need x86_init.h used to rely on it being
included indirectly, so I have to put an explicit include in there
now.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
 arch/x86/include/asm/setup.h            | 1 -
 arch/x86/kernel/platform-quirks.c       | 1 +
 arch/x86/platform/ce4100/ce4100.c       | 1 +
 arch/x86/platform/intel-mid/intel-mid.c | 1 +
 arch/x86/platform/olpc/olpc.c           | 1 +
 drivers/iommu/dmar.c                    | 1 +
 6 files changed, 5 insertions(+), 1 deletion(-)

-- 
2.9.0

Comments

Ingo Molnar Oct. 20, 2017, 11:11 a.m. UTC | #1
* tip-bot for Arnd Bergmann <tipbot@zytor.com> wrote:

> Commit-ID:  0f5a0f4f062cc19090a87f9eb8cb79c7c2e4db19

> Gitweb:     https://git.kernel.org/tip/0f5a0f4f062cc19090a87f9eb8cb79c7c2e4db19

> Author:     Arnd Bergmann <arnd@arndb.de>

> AuthorDate: Thu, 19 Oct 2017 12:53:02 +0200

> Committer:  Thomas Gleixner <tglx@linutronix.de>

> CommitDate: Thu, 19 Oct 2017 15:41:18 +0200

> 

> x86: Don't include asm/x86_init.h in asm/setup.h

> 

> This is a preparation to allow using 'struct timespec64' in asm/x86_init.h.

> 

> Unfortunately, using a forward declaration for timespec64 is not possible

> since it is defined as a macro on 64-bit architectures, and including

> linux/time64.h breaks compilation of arch/x86/boot/, which runs in realmode

> and can't use many of the regular kernel headers.

> 

> As a workaround, stop including asm/x86_init.h. This works fine for the

> realmode boot code since it does not require any of the x86_init.h

> contents, and setup.h doesn't either.

> 

> However, a couple of other files need x86_init.h and rely on it being

> included indirectly, so add an explicit include in there now.

> 

> [ tglx: Massaged changelog to 'imperative mood' ]

> 

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

> Cc: y2038@lists.linaro.org

> Cc: Joerg Roedel <joro@8bytes.org>

> Cc: iommu@lists.linux-foundation.org

> Link: https://lkml.kernel.org/r/20171019105451.2892046-1-arnd@arndb.de

> 

> ---

>  arch/x86/include/asm/setup.h            | 1 -

>  arch/x86/kernel/platform-quirks.c       | 1 +

>  arch/x86/platform/ce4100/ce4100.c       | 1 +

>  arch/x86/platform/intel-mid/intel-mid.c | 1 +

>  arch/x86/platform/olpc/olpc.c           | 1 +

>  drivers/iommu/dmar.c                    | 1 +

>  6 files changed, 5 insertions(+), 1 deletion(-)

> 

> diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h

> index a65cf54..deed841 100644

> --- a/arch/x86/include/asm/setup.h

> +++ b/arch/x86/include/asm/setup.h

> @@ -27,7 +27,6 @@

>  

>  #ifndef __ASSEMBLY__

>  #include <asm/bootparam.h>

> -#include <asm/x86_init.h>

>  

>  extern u64 relocated_ramdisk;

>  

> diff --git a/arch/x86/kernel/platform-quirks.c b/arch/x86/kernel/platform-quirks.c

> index 502a77d..d900c7b 100644

> --- a/arch/x86/kernel/platform-quirks.c

> +++ b/arch/x86/kernel/platform-quirks.c

> @@ -3,6 +3,7 @@

>  

>  #include <asm/setup.h>

>  #include <asm/bios_ebda.h>

> +#include <asm/x86_init.h>

>  

>  void __init x86_early_init_platform_quirks(void)

>  {

> diff --git a/arch/x86/platform/ce4100/ce4100.c b/arch/x86/platform/ce4100/ce4100.c

> index ce4b067..8851963 100644

> --- a/arch/x86/platform/ce4100/ce4100.c

> +++ b/arch/x86/platform/ce4100/ce4100.c

> @@ -22,6 +22,7 @@

>  #include <asm/io.h>

>  #include <asm/io_apic.h>

>  #include <asm/emergency-restart.h>

> +#include <asm/x86_init.h>

>  

>  /*

>   * The CE4100 platform has an internal 8051 Microcontroller which is

> diff --git a/arch/x86/platform/intel-mid/intel-mid.c b/arch/x86/platform/intel-mid/intel-mid.c

> index 86676ce..c632226 100644

> --- a/arch/x86/platform/intel-mid/intel-mid.c

> +++ b/arch/x86/platform/intel-mid/intel-mid.c

> @@ -35,6 +35,7 @@

>  #include <asm/intel_scu_ipc.h>

>  #include <asm/apb_timer.h>

>  #include <asm/reboot.h>

> +#include <asm/x86_init.h>

>  

>  #include "intel_mid_weak_decls.h"

>  

> diff --git a/arch/x86/platform/olpc/olpc.c b/arch/x86/platform/olpc/olpc.c

> index 7c3077e..11a54f3 100644

> --- a/arch/x86/platform/olpc/olpc.c

> +++ b/arch/x86/platform/olpc/olpc.c

> @@ -26,6 +26,7 @@

>  #include <asm/setup.h>

>  #include <asm/olpc.h>

>  #include <asm/olpc_ofw.h>

> +#include <asm/x86_init.h>

>  

>  struct olpc_platform_t olpc_platform_info;

>  EXPORT_SYMBOL_GPL(olpc_platform_info);

> diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c

> index 57c920c..ca507c5 100644

> --- a/drivers/iommu/dmar.c

> +++ b/drivers/iommu/dmar.c

> @@ -41,6 +41,7 @@

>  #include <linux/iommu.h>

>  #include <asm/irq_remapping.h>

>  #include <asm/iommu_table.h>

> +#include <asm/x86_init.h>

>  

>  #include "irq_remapping.h"


This breaks the IA64 build:

  drivers/iommu/dmar.c:44:26: fatal error: asm/x86_init.h: No such file or directory

Thanks,

	Ingo
Arnd Bergmann Oct. 20, 2017, 11:37 a.m. UTC | #2
On Fri, Oct 20, 2017 at 1:11 PM, Ingo Molnar <mingo@kernel.org> wrote:
>>  #include <asm/iommu_table.h>

>> +#include <asm/x86_init.h>

>>

>>  #include "irq_remapping.h"

>

> This breaks the IA64 build:

>

>   drivers/iommu/dmar.c:44:26: fatal error: asm/x86_init.h: No such file or directory


I've sent a fixup to add an #ifdef around it now. Alternatively, we
could include
it implicitly in asm/iommu_table.h, which would avoid the #ifdef but
seem a little
hacky.

      Arnd
Thomas Gleixner Oct. 20, 2017, 11:41 a.m. UTC | #3
On Fri, 20 Oct 2017, Ingo Molnar wrote:
> * tip-bot for Arnd Bergmann <tipbot@zytor.com> wrote:

> This breaks the IA64 build:

> 

>   drivers/iommu/dmar.c:44:26: fatal error: asm/x86_init.h: No such file or directory


The commits are already removed from x86/timers

Thanks,

	tglx
Thomas Gleixner Oct. 20, 2017, 11:48 a.m. UTC | #4
On Fri, 20 Oct 2017, Arnd Bergmann wrote:
> On Fri, Oct 20, 2017 at 1:11 PM, Ingo Molnar <mingo@kernel.org> wrote:

> >>  #include <asm/iommu_table.h>

> >> +#include <asm/x86_init.h>

> >>

> >>  #include "irq_remapping.h"

> >

> > This breaks the IA64 build:

> >

> >   drivers/iommu/dmar.c:44:26: fatal error: asm/x86_init.h: No such file or directory

> 

> I've sent a fixup to add an #ifdef around it now. Alternatively, we

> could include

> it implicitly in asm/iommu_table.h, which would avoid the #ifdef but

> seem a little

> hacky.


Hrm. Both solutions are ugly. Is there no other way to split stuff up in
those headers (maybe create an extra one).

Thanks,

	tglx
Arnd Bergmann Oct. 20, 2017, 12:09 p.m. UTC | #5
On Fri, Oct 20, 2017 at 1:48 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
> On Fri, 20 Oct 2017, Arnd Bergmann wrote:

>> On Fri, Oct 20, 2017 at 1:11 PM, Ingo Molnar <mingo@kernel.org> wrote:

>> >>  #include <asm/iommu_table.h>

>> >> +#include <asm/x86_init.h>

>> >>

>> >>  #include "irq_remapping.h"

>> >

>> > This breaks the IA64 build:

>> >

>> >   drivers/iommu/dmar.c:44:26: fatal error: asm/x86_init.h: No such file or directory

>>

>> I've sent a fixup to add an #ifdef around it now. Alternatively, we

>> could include

>> it implicitly in asm/iommu_table.h, which would avoid the #ifdef but

>> seem a little

>> hacky.

>

> Hrm. Both solutions are ugly. Is there no other way to split stuff up in

> those headers (maybe create an extra one).


Hmm, looking at it again, I think we can get away without the explicit
include, and rely on asm/pci.h to include x86_init.h.

For some files I had build failures without the explicit include and for
others I added it for consistency. From looking at the source, this
file seems to belong in the second category. If you think that's ok,
I'll do some more build testing without the #include and send a new
version.

Another idea: add an abstraction for the init handler assignment,
see untested patch below.

      Arnd

---
diff --git a/arch/ia64/include/asm/iommu.h b/arch/ia64/include/asm/iommu.h
index 1d1212901ae7..f2ad4a39bafe 100644
--- a/arch/ia64/include/asm/iommu.h
+++ b/arch/ia64/include/asm/iommu.h
@@ -18,4 +18,8 @@ extern int iommu_detected;
 extern void iommu_dma_init(void);
 extern void machvec_init(const char *name);

+static inline void iommu_set_init_handler(int (*init_fn)(void))
+{
+}
+
 #endif
diff --git a/arch/x86/include/asm/iommu.h b/arch/x86/include/asm/iommu.h
index fca144a104e4..09cbbc6beaab 100644
--- a/arch/x86/include/asm/iommu.h
+++ b/arch/x86/include/asm/iommu.h
@@ -1,6 +1,8 @@
 #ifndef _ASM_X86_IOMMU_H
 #define _ASM_X86_IOMMU_H

+#include <asm/x86_init.h>
+
 extern const struct dma_map_ops nommu_dma_ops;
 extern int force_iommu, no_iommu;
 extern int iommu_detected;
@@ -8,6 +10,11 @@ extern int iommu_pass_through;

 int x86_dma_supported(struct device *dev, u64 mask);

+static inline void iommu_set_init_handler(int (*init_fn)(void))
+{
+       x86_init.iommu.iommu_init = init_fn;
+}
+
 /* 10 seconds */
 #define DMAR_OPERATION_TIMEOUT ((cycles_t) tsc_khz*10*1000)

diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 6fe2d0346073..f464aef16a02 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -2781,7 +2781,7 @@ int __init amd_iommu_detect(void)

        amd_iommu_detected = true;
        iommu_detected = 1;
-       x86_init.iommu.iommu_init = amd_iommu_init;
+       iomm_set_init_handler(amd_iommu_init);

        return 1;
 }
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index 1ea7cd537873..b3bcbb07f789 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -905,10 +905,8 @@ int __init detect_intel_iommu(void)
                pci_request_acs();
        }

-#ifdef CONFIG_X86
        if (!ret)
-               x86_init.iommu.iommu_init = intel_iommu_init;
-#endif
+               iommu_set_init_handler(intel_iommu_init);

        if (dmar_tbl) {
                acpi_put_table(dmar_tbl);
Ingo Molnar Oct. 20, 2017, 12:20 p.m. UTC | #6
* Thomas Gleixner <tglx@linutronix.de> wrote:

> On Fri, 20 Oct 2017, Ingo Molnar wrote:

> > * tip-bot for Arnd Bergmann <tipbot@zytor.com> wrote:

> > This breaks the IA64 build:

> > 

> >   drivers/iommu/dmar.c:44:26: fatal error: asm/x86_init.h: No such file or directory

> 

> The commits are already removed from x86/timers


Ok.

Thanks,

	Ingo
diff mbox series

Patch

diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h
index a65cf544686a..deed84119a22 100644
--- a/arch/x86/include/asm/setup.h
+++ b/arch/x86/include/asm/setup.h
@@ -27,7 +27,6 @@ 
 
 #ifndef __ASSEMBLY__
 #include <asm/bootparam.h>
-#include <asm/x86_init.h>
 
 extern u64 relocated_ramdisk;
 
diff --git a/arch/x86/kernel/platform-quirks.c b/arch/x86/kernel/platform-quirks.c
index 502a77d0adb0..d900c7b176f0 100644
--- a/arch/x86/kernel/platform-quirks.c
+++ b/arch/x86/kernel/platform-quirks.c
@@ -3,6 +3,7 @@ 
 
 #include <asm/setup.h>
 #include <asm/bios_ebda.h>
+#include <asm/x86_init.h>
 
 void __init x86_early_init_platform_quirks(void)
 {
diff --git a/arch/x86/platform/ce4100/ce4100.c b/arch/x86/platform/ce4100/ce4100.c
index ce4b06733c09..885196300927 100644
--- a/arch/x86/platform/ce4100/ce4100.c
+++ b/arch/x86/platform/ce4100/ce4100.c
@@ -22,6 +22,7 @@ 
 #include <asm/io.h>
 #include <asm/io_apic.h>
 #include <asm/emergency-restart.h>
+#include <asm/x86_init.h>
 
 /*
  * The CE4100 platform has an internal 8051 Microcontroller which is
diff --git a/arch/x86/platform/intel-mid/intel-mid.c b/arch/x86/platform/intel-mid/intel-mid.c
index 86676cec99a1..c6322263610a 100644
--- a/arch/x86/platform/intel-mid/intel-mid.c
+++ b/arch/x86/platform/intel-mid/intel-mid.c
@@ -35,6 +35,7 @@ 
 #include <asm/intel_scu_ipc.h>
 #include <asm/apb_timer.h>
 #include <asm/reboot.h>
+#include <asm/x86_init.h>
 
 #include "intel_mid_weak_decls.h"
 
diff --git a/arch/x86/platform/olpc/olpc.c b/arch/x86/platform/olpc/olpc.c
index 7c3077e58fa0..11a54f386911 100644
--- a/arch/x86/platform/olpc/olpc.c
+++ b/arch/x86/platform/olpc/olpc.c
@@ -26,6 +26,7 @@ 
 #include <asm/setup.h>
 #include <asm/olpc.h>
 #include <asm/olpc_ofw.h>
+#include <asm/x86_init.h>
 
 struct olpc_platform_t olpc_platform_info;
 EXPORT_SYMBOL_GPL(olpc_platform_info);
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index 1ea7cd537873..e9304d6247e1 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -41,6 +41,7 @@ 
 #include <linux/iommu.h>
 #include <asm/irq_remapping.h>
 #include <asm/iommu_table.h>
+#include <asm/x86_init.h>
 
 #include "irq_remapping.h"