[PATCH v16 04/17] openrisc: Include <linux/cpumask.h> in smp.h

Lyude Paul posted 17 patches 3 days, 21 hours ago
[PATCH v16 04/17] openrisc: Include <linux/cpumask.h> in smp.h
Posted by Lyude Paul 3 days, 21 hours ago
While OpenRISC currently doesn't fail to build upstream, it appears that
include <asm/smp.h> in the right headers is enough to break that -
primarily because OpenRISC's asm/smp.h header doesn't actually provide any
definition for struct cpumask. Which means the only reason we aren't
failing to build kernel is because we've been lucky enough that every spot
including asm/smp.h already has definitions for struct cpumask pulled in.

This became evident when trying to work on a patch series for adding
ref-counted interrupt enable/disables to the kernel, where introducing a
new interrupt_rc.h header suddenly introduced a build error on OpenRISC:

     In file included from include/linux/interrupt_rc.h:17,
                      from include/linux/spinlock.h:60,
                      from include/linux/mmzone.h:8,
                      from include/linux/gfp.h:7,
                      from include/linux/mm.h:7,
                      from arch/openrisc/include/asm/pgalloc.h:20,
                      from arch/openrisc/include/asm/io.h:18,
                      from include/linux/io.h:12,
                      from drivers/irqchip/irq-ompic.c:61:
     arch/openrisc/include/asm/smp.h:21:59: warning: 'struct cpumask'
     declared inside parameter list will not be visible outside of this
     definition or declaration
        21 | extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
           |                                                           ^~~~~~~
     arch/openrisc/include/asm/smp.h:23:54: warning: 'struct cpumask'
     declared inside parameter list will not be visible outside of this
     definition or declaration
        23 | extern void set_smp_cross_call(void (*)(const struct cpumask *, unsigned int));
           |                                                      ^~~~~~~
     drivers/irqchip/irq-ompic.c: In function 'ompic_of_init':
  >> drivers/irqchip/irq-ompic.c:191:28: error: passing argument 1 of
     'set_smp_cross_call' from incompatible pointer type
     [-Werror=incompatible-pointer-types]
       191 |         set_smp_cross_call(ompic_raise_softirq);
           |                            ^~~~~~~~~~~~~~~~~~~
           |                            |
           |                            void (*)(const struct cpumask *, unsigned int)
     arch/openrisc/include/asm/smp.h:23:32: note: expected 'void (*)(const
     struct cpumask *, unsigned int)' but argument is of type 'void
     (*)(const struct cpumask *, unsigned int)'
        23 | extern void set_smp_cross_call(void (*)(const struct cpumask *, unsigned int));

To fix this, let's take an example from the smp.h headers of other
architectures (x86, hexagon, arm64, probably more): just include
linux/cpumask.h at the top.

Signed-off-by: Lyude Paul <lyude@redhat.com>
---
 arch/openrisc/include/asm/smp.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/openrisc/include/asm/smp.h b/arch/openrisc/include/asm/smp.h
index e21d2f12b5b67..0327d8cdae2d0 100644
--- a/arch/openrisc/include/asm/smp.h
+++ b/arch/openrisc/include/asm/smp.h
@@ -9,6 +9,8 @@
 #ifndef __ASM_OPENRISC_SMP_H
 #define __ASM_OPENRISC_SMP_H
 
+#include <linux/cpumask.h>
+
 #include <asm/spr.h>
 #include <asm/spr_defs.h>
 
-- 
2.52.0
Re: [PATCH v16 04/17] openrisc: Include <linux/cpumask.h> in smp.h
Posted by Stafford Horne 3 days, 17 hours ago
On Mon, Dec 15, 2025 at 12:57:51PM -0500, Lyude Paul wrote:
> While OpenRISC currently doesn't fail to build upstream, it appears that
> include <asm/smp.h> in the right headers is enough to break that -
> primarily because OpenRISC's asm/smp.h header doesn't actually provide any
> definition for struct cpumask. Which means the only reason we aren't
> failing to build kernel is because we've been lucky enough that every spot
> including asm/smp.h already has definitions for struct cpumask pulled in.
> 
> This became evident when trying to work on a patch series for adding
> ref-counted interrupt enable/disables to the kernel, where introducing a
> new interrupt_rc.h header suddenly introduced a build error on OpenRISC:
> 
>      In file included from include/linux/interrupt_rc.h:17,
>                       from include/linux/spinlock.h:60,
>                       from include/linux/mmzone.h:8,
>                       from include/linux/gfp.h:7,
>                       from include/linux/mm.h:7,
>                       from arch/openrisc/include/asm/pgalloc.h:20,
>                       from arch/openrisc/include/asm/io.h:18,
>                       from include/linux/io.h:12,
>                       from drivers/irqchip/irq-ompic.c:61:
>      arch/openrisc/include/asm/smp.h:21:59: warning: 'struct cpumask'
>      declared inside parameter list will not be visible outside of this
>      definition or declaration
>         21 | extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
>            |                                                           ^~~~~~~
>      arch/openrisc/include/asm/smp.h:23:54: warning: 'struct cpumask'
>      declared inside parameter list will not be visible outside of this
>      definition or declaration
>         23 | extern void set_smp_cross_call(void (*)(const struct cpumask *, unsigned int));
>            |                                                      ^~~~~~~
>      drivers/irqchip/irq-ompic.c: In function 'ompic_of_init':
>   >> drivers/irqchip/irq-ompic.c:191:28: error: passing argument 1 of
>      'set_smp_cross_call' from incompatible pointer type
>      [-Werror=incompatible-pointer-types]
>        191 |         set_smp_cross_call(ompic_raise_softirq);
>            |                            ^~~~~~~~~~~~~~~~~~~
>            |                            |
>            |                            void (*)(const struct cpumask *, unsigned int)
>      arch/openrisc/include/asm/smp.h:23:32: note: expected 'void (*)(const
>      struct cpumask *, unsigned int)' but argument is of type 'void
>      (*)(const struct cpumask *, unsigned int)'
>         23 | extern void set_smp_cross_call(void (*)(const struct cpumask *, unsigned int));
> 
> To fix this, let's take an example from the smp.h headers of other
> architectures (x86, hexagon, arm64, probably more): just include
> linux/cpumask.h at the top.
> 
> Signed-off-by: Lyude Paul <lyude@redhat.com>
> ---
>  arch/openrisc/include/asm/smp.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/openrisc/include/asm/smp.h b/arch/openrisc/include/asm/smp.h
> index e21d2f12b5b67..0327d8cdae2d0 100644
> --- a/arch/openrisc/include/asm/smp.h
> +++ b/arch/openrisc/include/asm/smp.h
> @@ -9,6 +9,8 @@
>  #ifndef __ASM_OPENRISC_SMP_H
>  #define __ASM_OPENRISC_SMP_H
>  
> +#include <linux/cpumask.h>
> +
>  #include <asm/spr.h>
>  #include <asm/spr_defs.h>

This looks good to me.

Acked-by: Stafford Horne <shorne@gmail.com>