• Lu Yao's avatar
    x86/msi: Fix compile error caused by CONFIG_GENERIC_MSI_IRQ=y && !CONFIG_X86_LOCAL_APIC · 441ccc35
    Lu Yao authored
    When compiling the x86 kernel, if X86_LOCAL_APIC is not enabled but
    GENERIC_MSI_IRQ is selected in '.config', the following compilation
    error will occur:
    
      include/linux/gpio/driver.h:38:19: error:
        field 'msiinfo' has incomplete type
    
      kernel/irq/msi.c:752:5: error: invalid use of incomplete typedef
        'msi_alloc_info_t' {aka 'struct irq_alloc_info'}
    
      kernel/irq/msi.c:740:1: error: control reaches end of non-void function
    
    This is because file such as 'kernel/irq/msi.c' only depends on
    'GENERIC_MSI_IRQ', and uses 'struct msi_alloc_info_t'. However,
    this struct depends on 'X86_LOCAL_APIC'.
    
    When enable 'GENERIC_MSI_IRQ' or 'X86_LOCAL_APIC' will select
    'IRQ_DOMAIN_HIERARCHY', so exposing this struct using
    'IRQ_DOMAIN_HIERARCHY' rather than 'X86_LOCAL_APIC'.
    
    Under the above conditions, if 'HPET_TIMER' is selected, the following
    compilation error will occur:
    
      arch/x86/kernel/hpet.c:550:13: error: ‘x86_vector_domain’ undeclared
    
      arch/x86/kernel/hpet.c:600:9: error: implicit declaration of
        function ‘init_irq_alloc_info’
    
    This is because 'x86_vector_domain' is defined in 'kernel/apic/vector.c'
    which is compiled only when 'X86_LOCAL_APIC' is enabled. Besides,
    function 'msi_domain_set_affinity' is defined in 'include/linux/msi.h'
    which depends on 'GENERIC_MSI_IRQ'. So use 'X86_LOCAL_APIC' and
    'GENERIC_MSI_IRQ' to expose these code.
    Reported-by: default avatarkernel test robot <lkp@intel.com>
    Signed-off-by: default avatarLu Yao <yaolu@kylinos.cn>
    Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
    Acked-by: default avatarRandy Dunlap <rdunlap@infradead.org>
    Tested-by: default avatarRandy Dunlap <rdunlap@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Link: https://lore.kernel.org/r/20231012032659.323251-1-yaolu@kylinos.cn
    441ccc35
hw_irq.h 3.02 KB