Subject: Re: linux-next: Tree for Sep 30 (i386 non-SMP non-APIC w/ IRQ_DOMAIN: build errors)

From: Marc Zyngier <[email-masked]>
Date: Mon, 03 Oct 2022 19:26:29 +0100

+ Borislav and the x86 mailing list

On Sat, 01 Oct 2022 22:25:37 +0100,
Randy Dunlap <[email-masked]> wrote:
> 
> Hi--
> 
> On 9/30/22 08:47, [email-masked] wrote:
> > Hi all,
> > 
> > Stephen should be back on Monday and normal service resumed.
> > 
> > Changes since 20220929:
> > 
> 
> i386 randconfig:
> 
> # CONFIG_SMP is not set
> # CONFIG_X86_UP_APIC is not set
> CONFIG_IRQ_DOMAIN=y
> CONFIG_IRQ_SIM=y
> CONFIG_IRQ_DOMAIN_HIERARCHY=y
> CONFIG_GENERIC_MSI_IRQ=y
> CONFIG_GENERIC_MSI_IRQ_DOMAIN=y
> 
> 
> (a)
>   CC      drivers/phy/phy-can-transceiver.o
> In file included from ../include/asm-generic/gpio.h:11,
>                  from ../include/linux/gpio.h:62,
>                  from ../drivers/phy/phy-can-transceiver.c:11:
> ../include/linux/gpio/driver.h:31:33: error: field ‘msiinfo’ has incomplete type
>    31 |         msi_alloc_info_t        msiinfo;
>       |

There is plenty of similar issues with drivers/gpio.

This looks like x86 without APIC support lacks a proper definition of
'struct irq_alloc_info'. I can make one up to get things to compile,
but I wonder if that makes any sense the first place.

[warning: anything below only shows that I know nothing about x86]

Can x86 practically deal with MSIs without the APIC? If not, we should
instead find a way to forbid MSIs when APIC isn't selected. Or make
APIC support mandatory.

> 
> (b)
>   CC      arch/x86/kernel/hpet.o
> ../arch/x86/kernel/hpet.c: In function ‘hpet_msi_init’:
> ../arch/x86/kernel/hpet.c:520:46: error: invalid use of incomplete typedef ‘msi_alloc_info_t’ {aka ‘struct irq_alloc_info’}
>   520 |         irq_domain_set_info(domain, virq, arg->hwirq, info->chip, NULL,
>       |                                              ^~
> ../arch/x86/kernel/hpet.c:521:49: error: invalid use of incomplete typedef ‘msi_alloc_info_t’ {aka ‘struct irq_alloc_info’}
>   521 |                             handle_edge_irq, arg->data, "edge");
>       |                                                 ^~
>   CC      fs/jfs/jfs_xtree.o
> ../arch/x86/kernel/hpet.c: In function ‘hpet_create_irq_domain’:
> ../arch/x86/kernel/hpet.c:550:13: error: ‘x86_vector_domain’ undeclared (first use in this function)
>   550 |         if (x86_vector_domain == NULL)
>       |             ^~~~~~~~~~~~~~~~~
> ../arch/x86/kernel/hpet.c:550:13: note: each undeclared identifier is reported only once for each function it appears in
> ../arch/x86/kernel/hpet.c: In function ‘hpet_assign_irq’:
> ../arch/x86/kernel/hpet.c:598:31: error: storage size of ‘info’ isn’t known
>   598 |         struct irq_alloc_info info;
>       |                               ^~~~
> ../arch/x86/kernel/hpet.c:600:9: error: implicit declaration of function ‘init_irq_alloc_info’ [-Werror=implicit-function-declaration]
>   600 |         init_irq_alloc_info(&info, NULL);
>       |         ^~~~~~~~~~~~~~~~~~~
> ../arch/x86/kernel/hpet.c:601:21: error: ‘X86_IRQ_ALLOC_TYPE_HPET’ undeclared (first use in this function)
>   601 |         info.type = X86_IRQ_ALLOC_TYPE_HPET;
>       |                     ^~~~~~~~~~~~~~~~~~~~~~~
> ../arch/x86/kernel/hpet.c:598:31: warning: unused variable ‘info’ [-Wunused-variable]
>   598 |         struct irq_alloc_info info;
>       |                               ^~~~
> ../arch/x86/kernel/hpet.c:607:1: error: control reaches end of non-void function [-Werror=return-type]
>   607 | }
>       | ^

Same question: is HPET usable without the APIC? If so, the MSI part
should probably be guarded by something else.

> 
> 
> (c)
>   CC      kernel/irq/msi.o
> ../kernel/irq/msi.c: In function ‘msi_domain_ops_get_hwirq’:
> ../kernel/irq/msi.c:585:19: error: invalid use of incomplete typedef ‘msi_alloc_info_t’ {aka ‘struct irq_alloc_info’}
>   585 |         return arg->hwirq;
>       |                   ^~
> In file included from ../arch/x86/include/asm/string.h:3,
>                  from ../include/linux/string.h:20,
>                  from ../arch/x86/include/asm/page_32.h:22,
>                  from ../arch/x86/include/asm/page.h:14,
>                  from ../arch/x86/include/asm/thread_info.h:12,
>                  from ../include/linux/thread_info.h:60,
>                  from ../arch/x86/include/asm/preempt.h:7,
>                  from ../include/linux/preempt.h:78,
>                  from ../include/linux/rcupdate.h:27,
>                  from ../include/linux/rculist.h:11,
>                  from ../include/linux/pid.h:5,
>                  from ../include/linux/sched.h:14,
>                  from ../include/linux/ratelimit.h:6,
>                  from ../include/linux/dev_printk.h:16,
>                  from ../include/linux/device.h:15,
>                  from ../kernel/irq/msi.c:12:
> ../kernel/irq/msi.c: In function ‘msi_domain_ops_prepare’:
> ../kernel/irq/msi.c:591:30: error: invalid application of ‘sizeof’ to incomplete type ‘msi_alloc_info_t’ {aka ‘struct irq_alloc_info’}
>   591 |         memset(arg, 0, sizeof(*arg));
>       |                              ^
> ../arch/x86/include/asm/string_32.h:195:52: note: in definition of macro ‘memset’
>   195 | #define memset(s, c, count) __builtin_memset(s, c, count)
>       |                                                    ^~~~~
> ../kernel/irq/msi.c: In function ‘msi_domain_ops_set_desc’:
> ../kernel/irq/msi.c:598:12: error: invalid use of incomplete typedef ‘msi_alloc_info_t’ {aka ‘struct irq_alloc_info’}
>   598 |         arg->desc = desc;
>       |            ^~
> ../kernel/irq/msi.c: In function ‘__msi_domain_alloc_irqs’:
> ../kernel/irq/msi.c:858:9: error: variable ‘arg’ has initializer but incomplete type
>   858 |         msi_alloc_info_t arg = { };
>       |         ^~~~~~~~~~~~~~~~
> ../kernel/irq/msi.c:858:26: error: storage size of ‘arg’ isn’t known
>   858 |         msi_alloc_info_t arg = { };
>       |                          ^~~
> ../kernel/irq/msi.c:858:26: warning: unused variable ‘arg’ [-Wunused-variable]
>   CC      lib/clz_tab.o
> ../kernel/irq/msi.c: In function ‘msi_domain_ops_get_hwirq’:
> ../kernel/irq/msi.c:586:1: error: control reaches end of non-void function [-Werror=return-type]
>   586 | }
>       | ^

This is related to (a).

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.