Skip to contentSkip to conversation

MIPS: VZ: Only include loongson_regs.h for CPU_LOONGSON64

PATCH In review Huacai Chen 7 participants 13 messages Aug 8, 2020 – Aug 22, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MIPS: VZ: Only include loongson_regs.h for CPU_LOONGSON64

Only Loongson64 platform has and needs loongson_regs.h, including it unconditionally will cause build errors.

Fixes 7f2a83f1c2a941ebfee5 ("KVM: MIPS: Add CPUCFG emulation for Loongson-3")
---
 arch/mips/kvm/vz.c | 2 ++
 1 file changed, 2 insertions(+)
arch/mips/kvm/vz.c +2 -0
index 3932f76..a474578 100644
@@ -29,7 +29,9 @@
 #include <linux/kvm_host.h>
 
 #include "interrupt.h"
+#ifdef CONFIG_CPU_LOONGSON64
 #include "loongson_regs.h"
+#endif
 
 #include "trace.h"
 
Signature · 1 line
2.7.0
#1 lore raw
Quoted 16 lines · Huacai Chen

Only Loongson64 platform has and needs loongson_regs.h, including it unconditionally will cause build errors.

Fixes 7f2a83f1c2a941ebfee5 ("KVM: MIPS: Add CPUCFG emulation for Loongson-3")
---
 arch/mips/kvm/vz.c | 2 ++
 1 file changed, 2 insertions(+)
arch/mips/kvm/vz.c +0 -0
index 3932f76..a474578 100644

arch/mips/kvm/vz.c line 34

Quoted 6 lines
arch/mips/kvm/vz.c +2 -0
@@ -29,7 +29,9 @@
 #include <linux/kvm_host.h>
 
 #include "interrupt.h"
+#ifdef CONFIG_CPU_LOONGSON64
 #include "loongson_regs.h"
+#endif

The fix for this should be in the .h file, no #ifdef should be needed in a .c file.

thanks,

greg k-h

#2 lore raw
Quoted 19 lines · Greg KH
Quoted 18 lines · Huacai Chen

Only Loongson64 platform has and needs loongson_regs.h, including it unconditionally will cause build errors.

Fixes 7f2a83f1c2a941ebfee5 ("KVM: MIPS: Add CPUCFG emulation for Loongson-3")
---
  arch/mips/kvm/vz.c | 2 ++
  1 file changed, 2 insertions(+)
arch/mips/kvm/vz.c +0 -0
index 3932f76..a474578 100644
@@ -29,7 +29,9 @@
  #include <linux/kvm_host.h>
 
Quoted 6 lines

arch/mips/kvm/vz.c line 34

Quoted 4 lines
arch/mips/kvm/vz.c +2 -0
  #include "interrupt.h"
+#ifdef CONFIG_CPU_LOONGSON64
  #include "loongson_regs.h"
+#endif

The fix for this should be in the .h file, no #ifdef should be needed in a .c file.

The header file can only be reached when CONFIG_CPU_LOONGSON64 is selected... Otherwise the include path of this file won't be a part of CFLAGS.

Thanks.

- Jiaxun

Quoted 4 lines

thanks,

greg k-h

#3 lore raw
Quoted 28 lines · Jiaxun Yang
Quoted 12 lines · Greg KH
Quoted 11 lines · Huacai Chen

Only Loongson64 platform has and needs loongson_regs.h, including it unconditionally will cause build errors.

Fixes 7f2a83f1c2a941ebfee5 ("KVM: MIPS: Add CPUCFG emulation for Loongson-3")
---
  arch/mips/kvm/vz.c | 2 ++
  1 file changed, 2 insertions(+)
Quoted 12 lines

arch/mips/kvm/vz.c line 33

Quoted 10 lines
arch/mips/kvm/vz.c +2 -0
index 3932f76..a474578 100644
@@ -29,7 +29,9 @@
  #include <linux/kvm_host.h>
  #include "interrupt.h"
+#ifdef CONFIG_CPU_LOONGSON64
  #include "loongson_regs.h"
+#endif

The fix for this should be in the .h file, no #ifdef should be needed in a .c file.

Quoted 3 lines

The header file can only be reached when CONFIG_CPU_LOONGSON64 is selected...
Otherwise the include path of this file won't be a part of CFLAGS.

That sounds like you should fix up the path of this file in the #include line as well :)

maintainer
#4 lore raw
Quoted 12 lines · Greg KH
Quoted 12 lines
Quoted 12 lines

arch/mips/kvm/vz.c line 33

Quoted 10 lines
arch/mips/kvm/vz.c +2 -0
index 3932f76..a474578 100644
@@ -29,7 +29,9 @@
  #include <linux/kvm_host.h>
  #include "interrupt.h"
+#ifdef CONFIG_CPU_LOONGSON64
  #include "loongson_regs.h"
+#endif

The fix for this should be in the .h file, no #ifdef should be needed in a .c file.

Quoted 6 lines
Quoted 3 lines

The header file can only be reached when CONFIG_CPU_LOONGSON64 is selected...
Otherwise the include path of this file won't be a part of CFLAGS.

That sounds like you should fix up the path of this file in the #include line as well :)

There is more #ifdef CONFIG_CPU_LOONGSON64 in arch/mips/kvm/vz.c, and more #include "loongson_regs.h" in arch/mips. So while I agree with Greg that this idiom is quite unusual, it seems to be the expected way to use this header. I queued the patch.

Paolo

maintainer
#5 lore raw
Quoted 16 lines · Paolo Bonzini
Quoted 15 lines · Greg KH
Quoted 15 lines
Quoted 4 lines
Quoted 4 lines
arch/mips/kvm/vz.c +0 -0
index 3932f76..a474578 100644
Quoted 8 lines

arch/mips/kvm/vz.c line 33

Quoted 6 lines
arch/mips/kvm/vz.c +2 -0
@@ -29,7 +29,9 @@
  #include <linux/kvm_host.h>
  #include "interrupt.h"
+#ifdef CONFIG_CPU_LOONGSON64
  #include "loongson_regs.h"
+#endif

The fix for this should be in the .h file, no #ifdef should be needed in a .c file.

The header file can only be reached when CONFIG_CPU_LOONGSON64 is selected...
Otherwise the include path of this file won't be a part of CFLAGS.

Quoted 8 lines
Quoted 3 lines

That sounds like you should fix up the path of this file in the #include line as well :)

There is more #ifdef CONFIG_CPU_LOONGSON64 in arch/mips/kvm/vz.c, and more #include "loongson_regs.h" in arch/mips. So while I agree with Greg that this idiom is quite unusual, it seems to be the expected way to use this header. I queued the patch.

Where is that header coming from anyway? I can't find it in the tree, nor anything that would generate it.

Signature · 2 lines
Thanks,
Sasha
maintainer
#6 lore raw
Quoted 21 lines · Sasha Levin
Quoted 20 lines · Paolo Bonzini
Quoted 18 lines · Greg KH
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
arch/mips/kvm/vz.c +0 -0
index 3932f76..a474578 100644
Quoted 8 lines

arch/mips/kvm/vz.c line 33

Quoted 6 lines
arch/mips/kvm/vz.c +2 -0
@@ -29,7 +29,9 @@
 #include <linux/kvm_host.h>
 #include "interrupt.h"
+#ifdef CONFIG_CPU_LOONGSON64
 #include "loongson_regs.h"
+#endif

The fix for this should be in the .h file, no #ifdef should be needed in a .c file.

Quoted 3 lines

The header file can only be reached when CONFIG_CPU_LOONGSON64 is selected...
Otherwise the include path of this file won't be a part of CFLAGS.

That sounds like you should fix up the path of this file in the #include line as well :)

Quoted 7 lines
Quoted 4 lines

There is more #ifdef CONFIG_CPU_LOONGSON64 in arch/mips/kvm/vz.c, and more #include "loongson_regs.h" in arch/mips. So while I agree with Greg that this idiom is quite unusual, it seems to be the expected way to use this header. I queued the patch.

Where is that header coming from anyway? I can't find it in the tree, nor anything that would generate it.

Woops, nevermind - sorry for the noise.

Signature · 2 lines
Thanks,
Sasha
#7 lore raw
In reply to Paolo Bonzini
Quoted 16 lines · Paolo Bonzini
Quoted 15 lines · Greg KH
Quoted 15 lines
Quoted 4 lines
Quoted 4 lines
arch/mips/kvm/vz.c +0 -0
index 3932f76..a474578 100644
Quoted 8 lines

arch/mips/kvm/vz.c line 33

Quoted 6 lines
arch/mips/kvm/vz.c +2 -0
@@ -29,7 +29,9 @@
  #include <linux/kvm_host.h>
  #include "interrupt.h"
+#ifdef CONFIG_CPU_LOONGSON64
  #include "loongson_regs.h"
+#endif

The fix for this should be in the .h file, no #ifdef should be needed in a .c file.

The header file can only be reached when CONFIG_CPU_LOONGSON64 is selected...
Otherwise the include path of this file won't be a part of CFLAGS.

Quoted 8 lines
Quoted 3 lines

That sounds like you should fix up the path of this file in the #include line as well :)

There is more #ifdef CONFIG_CPU_LOONGSON64 in arch/mips/kvm/vz.c, and more #include "loongson_regs.h" in arch/mips. So while I agree with Greg that this idiom is quite unusual, it seems to be the expected way to use this header. I queued the patch.

Or you all could fix it up to work properly like all other #include lines in the kernel source tree. There's no reason mips should be "special" here, right?

thanks,

greg k-h

maintainer
#8 lore raw
Quoted 7 lines · Greg KH
Quoted 4 lines

There is more #ifdef CONFIG_CPU_LOONGSON64 in arch/mips/kvm/vz.c, and more #include "loongson_regs.h" in arch/mips. So while I agree with Greg that this idiom is quite unusual, it seems to be the expected way to use this header. I queued the patch.

Or you all could fix it up to work properly like all other #include lines in the kernel source tree. There's no reason mips should be "special" here, right?

It's not just this #include, there's a couple dozen mach-* directories; changing how they work would be up to the MIPS maintainers (CCed), and it would certainly not be a patch that can be merged in stable@ kernels.

arch/mips/kernel/cpu-probe.c has the same

#ifdef CONFIG_CPU_LOONGSON64
#include <loongson_regs.h>

for example, so apparently they're good with this. So if I don't pick up the patch to fix the build it would be in all likelihood merged by MIPS maintainers. The only difference will be how long the build remains broken and the fact that they need to worry about KVM despite the presence of a specific maintainer.

KVM could of course just #include <asm/mach-loongson64/loongson_regs.h>, which would be found unconditionally. But there is some assembly in the header, so even if it would compile (I didn't check) it seems wrong to include it unconditionally and in fact it would be the only case of a file including <asm/mach-*/*.h> even if it is not compiled for that platform.

Another alternative would be to move CONFIG_CPU_LOONGSON64 code out of arch/mips/kvm/vz.c and include it with obj-$(CONFIG_CPU_LOONGSON64). I'll gladly accept a patch to do that, but I won't write it since I don't have access to the hardware in order to test it. For now, and for the immediate purpose of not breaking the build, when in Rome I'll do as the Romans do.

Paolo

#9 lore raw
Quoted 15 lines · Paolo Bonzini
Quoted 7 lines · Greg KH
Quoted 4 lines

There is more #ifdef CONFIG_CPU_LOONGSON64 in arch/mips/kvm/vz.c, and more #include "loongson_regs.h" in arch/mips. So while I agree with Greg that this idiom is quite unusual, it seems to be the expected way to use this header. I queued the patch.

Or you all could fix it up to work properly like all other #include lines in the kernel source tree. There's no reason mips should be "special" here, right?

It's not just this #include, there's a couple dozen mach-* directories; changing how they work would be up to the MIPS maintainers (CCed), and it would certainly not be a patch that can be merged in stable@ kernels.

arch/mips/kernel/cpu-probe.c has the same

Quoted 8 lines

#ifdef CONFIG_CPU_LOONGSON64
#include <loongson_regs.h>

for example, so apparently they're good with this. So if I don't pick up the patch to fix the build it would be in all likelihood merged by MIPS maintainers. The only difference will be how long the build remains broken and the fact that they need to worry about KVM despite the presence of a specific maintainer.

Ok, fair enough, but in the long-run, this should probably be fixed up "properly" if this arch is still being maintained.

thanks,

greg k-h

#10 lore raw
Quoted 18 lines · Greg KH
Quoted 17 lines · Paolo Bonzini
Quoted 7 lines · Greg KH
Quoted 4 lines

There is more #ifdef CONFIG_CPU_LOONGSON64 in arch/mips/kvm/vz.c, and more #include "loongson_regs.h" in arch/mips. So while I agree with Greg that this idiom is quite unusual, it seems to be the expected way to use this header. I queued the patch.

Or you all could fix it up to work properly like all other #include lines in the kernel source tree. There's no reason mips should be "special" here, right?

It's not just this #include, there's a couple dozen mach-* directories; changing how they work would be up to the MIPS maintainers (CCed), and it would certainly not be a patch that can be merged in stable@ kernels.

arch/mips/kernel/cpu-probe.c has the same

#ifdef CONFIG_CPU_LOONGSON64
#include <loongson_regs.h>

Quoted 7 lines
Quoted 5 lines

for example, so apparently they're good with this. So if I don't pick up the patch to fix the build it would be in all likelihood merged by MIPS maintainers. The only difference will be how long the build remains broken and the fact that they need to worry about KVM despite the presence of a specific maintainer.

Ok, fair enough, but in the long-run, this should probably be fixed up "properly" if this arch is still being maintained.

MIPS is using another approach to management machine specified headers. It changes include path per-machine to get ride of the generic one.

I'm a little bit confused about the proper way to do that. I thought the design overall, is just fine.

Should we try to migrate it to another style?

Thanks.

- Jiaxun

Quoted 4 lines

thanks,

greg k-h

#11 lore raw
In reply to Greg KH
Quoted 19 lines · Greg KH
Quoted 18 lines · Paolo Bonzini
Quoted 7 lines · Greg KH
Quoted 4 lines

There is more #ifdef CONFIG_CPU_LOONGSON64 in arch/mips/kvm/vz.c, and more #include "loongson_regs.h" in arch/mips. So while I agree with Greg that this idiom is quite unusual, it seems to be the expected way to use this header. I queued the patch.

Or you all could fix it up to work properly like all other #include lines in the kernel source tree. There's no reason mips should be "special" here, right?

It's not just this #include, there's a couple dozen mach-* directories; changing how they work would be up to the MIPS maintainers (CCed), and it would certainly not be a patch that can be merged in stable@ kernels.

arch/mips/kernel/cpu-probe.c has the same

#ifdef CONFIG_CPU_LOONGSON64
#include <loongson_regs.h>

Quoted 8 lines
Quoted 5 lines

for example, so apparently they're good with this. So if I don't pick up the patch to fix the build it would be in all likelihood merged by MIPS maintainers. The only difference will be how long the build remains broken and the fact that they need to worry about KVM despite the presence of a specific maintainer.

Ok, fair enough, but in the long-run, this should probably be fixed up "properly" if this arch is still being maintained.

I have it on my todo list. My plan is to move stuff out of mach-* directories, which aren't needed there. This should solve issues like the one here.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
#12 lore raw
Quoted 15 lines · Thomas Bogendoerfer
Quoted 15 lines
Quoted 14 lines

It's not just this #include, there's a couple dozen mach-* directories; changing how they work would be up to the MIPS maintainers (CCed), and it would certainly not be a patch that can be merged in stable@ kernels.

arch/mips/kernel/cpu-probe.c has the same

#ifdef CONFIG_CPU_LOONGSON64
#include <loongson_regs.h>

for example, so apparently they're good with this. So if I don't pick up the patch to fix the build it would be in all likelihood merged by MIPS maintainers. The only difference will be how long the build remains broken and the fact that they need to worry about KVM despite the presence of a specific maintainer.

Quoted 5 lines
Quoted 2 lines

Ok, fair enough, but in the long-run, this should probably be fixed up "properly" if this arch is still being maintained.

I have it on my todo list. My plan is to move stuff out of mach-* directories, which aren't needed there. This should solve issues like the one here.

Correct, it looks like another maintainer's oversight.

The asm/mach-<platform>/ directories are there for platform variants of
generic stuff found in asm/mach-generic/. So if something is not there in asm/mach-generic/, then it must not be in any other asm/mach-<plaftorm>/ subdirectory either.

Regular platform headers need to go under asm/<plaftorm>/. Compare
asm/mach-dec/ vs asm/dec/, or asm/mach-sibyte/ vs asm/sibyte/, and so on. So this `loongson_regs.h' piece belongs to asm/loongson64/ rather than asm/mach-loongson64/.

Maciej