x86/apic updates for v3.20
Linus,
Please pull the latest x86-apic-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-apic-for-linus
# HEAD: ba360f887a4130b06c55eb93bcb4ae373b262a1c x86, init: Fix UP boot regression on x86_64
Continued fallout of the conversion of the x86 IRQ code to the hierarchical irqdomain framework: more cleanups, simplifications, memory allocation behavior enhancements, mainly in the interrupt remapping and APIC code.
out-of-topic modifications in x86-apic-for-linus:
---------------------------------------------------
drivers/iommu/amd_iommu.c # c392f56c9460: iommu/irq_remapping: Kill fu
drivers/iommu/amd_iommu_init.c # 3f4cb7c06484: iommu/amd: Fix irq remapping
# 7fa1c842caca: iommu/irq_remapping: Change
# c392f56c9460: iommu/irq_remapping: Kill fu
# 84d0779304b5: iommu/amd: Check for irq-rem
drivers/iommu/amd_iommu_proto.h # c392f56c9460: iommu/irq_remapping: Kill fu
drivers/iommu/intel_irq_remapping.c# 7fa1c842caca: iommu/irq_remapping: Change
# c392f56c9460: iommu/irq_remapping: Kill fu
# 13d09b6603df: iommu/vt-d: Allow IR works i
# 69cf1d8a1286: iommu/vt-d: Allocate IRQ rem
# 2966d9566beb: iommu/vt-d: Prepare for kill
# e3a981d61d15: iommu/vt-d: Convert allocati
# 11190302400d: iommu/vt-d: Move iommu prepa
drivers/iommu/irq_remapping.c # e901176046e6: iommu/irq_remapping: Normail
# 7fa1c842caca: iommu/irq_remapping: Change
# 30969e34ae6e: iommu/irq_remapping: Refine
# c392f56c9460: iommu/irq_remapping: Kill fu
# a1dafe857db5: iommu, x86: Restructure setu
drivers/iommu/irq_remapping.h # 7fa1c842caca: iommu/irq_remapping: Change
# c392f56c9460: iommu/irq_remapping: Kill fu include/linux/smp.h # 30b8b0066caf: init: Get rid of x86isms
Thanks,
Ingo
------------------>
Jiang Liu (12):
x86/apic: Panic if kernel doesn't support x2apic but BIOS has enabled x2apic x86/apic: Kill useless variable x2apic_enabled in function enable_IR_x2apic() x86/apic: Correctly detect X2APIC status in function enable_IR() x86/apic: Refine enable_IR_x2apic() and related functions x86/apic: Handle XAPIC remap mode proper.
iommu/vt-d: Prepare for killing function irq_remapping_supported() iommu/vt-d: Allow IR works in XAPIC mode though CPU works in X2APIC mode x86/apic: Only disable CPU x2apic mode when necessary iommu/irq_remapping: Kill function irq_remapping_supported() and related code iommu/irq_remapping: Refine function irq_remapping_prepare() for maintenance iommu/irq_remapping: Change variable disable_irq_remap to be static iommu/irq_remapping: Normailize the way to detect whether IR is enabled
Joerg Roedel (2):
iommu/vt-d: Allocate IRQ remapping data structures only for all IOMMUs iommu/amd: Check for irq-remap support amd_iommu_prepare()
Thomas Gleixner (30):
iommu, x86: Restructure setup of the irq remapping feature iommu/vt-d: Move iommu preparatory allocations to irq_remap_ops.prepare iommu/vt-d: Convert allocations to GFP_KERNEL
x86/apic: Clear stale x2apic mode
x86/apic: Avoid open coded x2apic detection
x86/apic: Make x2apic_mode depend on CONFIG_X86_X2APIC
x86/apic: Move x2apic code to one place
x86/ioapic: Check x2apic really
x86/apic: Make disable x2apic work really
x86/apic: Check x2apic early
x86/x2apic: Move code in conditional region
x86/x2apic: Clarify remapping mode for x2apic enablement x86/x2apic: Add proper state tracking
x86/x2apic: Disable x2apic from nox2apic setup
x86/x2apic: Split enable and setup function
x86/x2apic: Use state information for disable
x86/smpboot: Move smpboot inlines to code
x86/ioapic: Provide stub functions for IOAPIC%3Dn
x86/ioapic: Add proper checks to setp/enable_IO_APIC()
x86/apic: Sanitize ioapic handling
x86/smpboot: Cleanup ioapic handling
x86/apic: Move apic_init_uniprocessor code
init: Get rid of x86isms
x86/smpboot: Move apic init code to apic.c
x86/smpboot: Sanitize uniprocessor init
x86/apic: Reuse apic_bsp_setup() for UP APIC setup
x86: Consolidate boot cpu timer setup
x86/acpi: Make acpi_[un]register_gsi_ioapic() depend on CONFIG_X86_LOCAL_APIC iommu/amd: Fix irq remapping detection logic
x86, init: Fix UP boot regression on x86_64
arch/x86/Kconfig | 4 + arch/x86/include/asm/apic.h | 58 ++--- arch/x86/include/asm/io_apic.h | 5 + arch/x86/include/asm/irq_remapping.h | 4 - arch/x86/include/asm/smpboot_hooks.h | 68 ------ arch/x86/kernel/acpi/boot.c | 2 + arch/x86/kernel/apic/apic.c | 456 ++++++++++++++++++----------------- arch/x86/kernel/apic/io_apic.c | 13 +- arch/x86/kernel/cpu/common.c | 2 +- arch/x86/kernel/smpboot.c | 113 +++++---- drivers/iommu/amd_iommu.c | 1 - drivers/iommu/amd_iommu_init.c | 15 +- drivers/iommu/amd_iommu_proto.h | 1 - drivers/iommu/intel_irq_remapping.c | 96 ++++---- drivers/iommu/irq_remapping.c | 74 ++---- drivers/iommu/irq_remapping.h | 5 - include/linux/smp.h | 7 + init/main.c | 13 - 18 files changed, 436 insertions(+), 501 deletions(-) delete mode 100644 arch/x86/include/asm/smpboot_hooks.h
arch/x86/Kconfig +4 -0
@@ -855,6 +855,10 @@ config SCHED_MC source "kernel/Kconfig.preempt" +config UP_LATE_INIT + def_bool y + depends on !SMP && X86_LOCAL_APIC + config X86_UP_APIC bool "Local APIC support on uniprocessors" depends on X86_32 && !SMP && !X86_32_NON_STANDARD && !PCI_MSI
arch/x86/include/asm/apic.h +20 -38
96 lines not on this page · raw message
arch/x86/include/asm/io_apic.h +5 -0
@@ -279,6 +279,11 @@ static inline void disable_ioapic_support(void) { }#define native_ioapic_set_affinity NULL#define native_setup_ioapic_entry NULL#define native_eoi_ioapic_pin NULL + +static inline void setup_IO_APIC (void ) { } +static inline void enable_IO_APIC (void ) { } +static inline void setup_ioapic_dest (void ) { } +#endif #endif /* _ASM_X86_IO_APIC_H */
arch/x86/include/asm/irq_remapping.h +0 -4
@@ -33,8 +33,6 @@ struct irq_cfg;#ifdef CONFIG_IRQ_REMAP -extern void setup_irq_remapping_ops (void ); -extern int irq_remapping_supported (void );extern void set_irq_remapping_broken (void );extern int irq_remapping_prepare (void );extern int irq_remapping_enable (void );
@@ -60,8 +58,6 @@ void irq_remap_modify_chip_defaults(struct irq_chip *chip);#else /* CONFIG_IRQ_REMAP */ -static inline void setup_irq_remapping_ops (void ) { } -static inline int irq_remapping_supported (void ) {return 0 ; }static inline void set_irq_remapping_broken (void ) { }static inline int irq_remapping_prepare (void ) {return -ENODEV ; }static inline int irq_remapping_enable (void ) {return -ENODEV ; }
arch/x86/include/asm/smpboot_hooks.h deleted +0 -68
68 lines not on this page · raw message
arch/x86/kernel/acpi/boot.c +2 -0
@@ -653,6 +653,7 @@ static int acpi_register_gsi_pic(struct device *dev, u32 gsi,return gsi; } +#ifdef CONFIG_X86_LOCAL_APIC static int acpi_register_gsi_ioapic (struct device *dev,u32 gsi,int trigger,int polarity) {
@@ -675,6 +676,7 @@ static void acpi_unregister_gsi_ioapic(u32 gsi)mutex_unlock (&acpi_ioapic_lock); #endif } +#endif int (*__acpi_register_gsi)(struct device *dev,u32 gsi,int trigger,int polarity) = acpi_register_gsi_pic;
arch/x86/kernel/apic/apic.c +239 -217
557 lines not on this page · raw message
arch/x86/kernel/apic/io_apic.c +8 -5
@@ -1507,7 +1507,10 @@ void __init enable_IO_APIC(void)int i8259_apic, i8259_pin;int apic, pin; -if (!nr_legacy_irqs ()) +if (skip_ioapic_setup) + nr_ioapics =0 ; + +if (!nr_legacy_irqs () || !nr_ioapics)return ;for_each_ioapic_pin (apic, pin) {
@@ -2295,7 +2298,7 @@ static inline void __init check_timer(void) }local_irq_disable ();apic_printk (APIC_QUIET ,KERN_INFO "..... failed :(.\n" ); -if (x2apic_preenabled) +if (apic_is_x2apic_enabled ())apic_printk (APIC_QUIET ,KERN_INFO "Perhaps problem with the pre-enabled x2apic mode\n" "Try booting with x2apic and interrupt-remapping disabled in the bios.\n" );
@@ -2373,9 +2376,9 @@ void __init setup_IO_APIC(void) {int ioapic; -/* -* calling enable_IO_APIC() is moved to setup_local_APIC for BP -*/ +if (skip_ioapic_setup || !nr_ioapics) +return ; + io_apic_irqs =nr_legacy_irqs () ? ~PIC_IRQS : ~0UL ;apic_printk (APIC_VERBOSE ,"ENABLING IO-APIC IRQs\n" );
arch/x86/kernel/cpu/common.c +1 -1
@@ -1332,7 +1332,7 @@ void cpu_init(void)barrier ();x86_configure_nx (); -enable_x2apic (); +x2apic_setup ();/* * set up and load the per-CPU TSS
arch/x86/kernel/smpboot.c +67 -46
189 lines not on this page · raw message
drivers/iommu/amd_iommu.c +0 -1
@@ -4284,7 +4284,6 @@ static int alloc_hpet_msi(unsigned int irq, unsigned int id) }struct irq_remap_ops amd_iommu_irq_ops = { - .supported = amd_iommu_supported, .prepare = amd_iommu_prepare, .enable = amd_iommu_enable, .disable = amd_iommu_disable,
drivers/iommu/amd_iommu_init.c +7 -8
@@ -2014,9 +2014,6 @@ static bool detect_ivrs(void)/* Make sure ACS will be enabled during PCI probe */ pci_request_acs (); -if (!disable_irq_remap) - amd_iommu_irq_remap = true; -return true; }
@@ -2123,12 +2120,14 @@ static int __init iommu_go_to_state(enum iommu_init_state state)#ifdef CONFIG_IRQ_REMAP int __init amd_iommu_prepare (void ) { -return iommu_go_to_state (IOMMU_ACPI_FINISHED ); -} +int ret; -int __init amd_iommu_supported (void ) -{ -return amd_iommu_irq_remap ?1 :0 ; + amd_iommu_irq_remap = true; + + ret =iommu_go_to_state (IOMMU_ACPI_FINISHED ); +if (ret) +return ret; +return amd_iommu_irq_remap ?0 : -ENODEV ; }int __init amd_iommu_enable (void )
drivers/iommu/amd_iommu_proto.h +0 -1
@@ -33,7 +33,6 @@ extern void amd_iommu_init_notifier(void);extern void amd_iommu_init_api (void );/* Needed for interrupt remapping */ -extern int amd_iommu_supported (void );extern int amd_iommu_prepare (void );extern int amd_iommu_enable (void );extern void amd_iommu_disable (void );
drivers/iommu/intel_irq_remapping.c +51 -45
172 lines not on this page · raw message
drivers/iommu/irq_remapping.c +25 -49
163 lines not on this page · raw message
drivers/iommu/irq_remapping.h +0 -5
@@ -31,16 +31,12 @@ struct cpumask;struct pci_dev ;struct msi_msg ; -extern int disable_irq_remap;extern int irq_remap_broken;extern int disable_sourceid_checking;extern int no_x2apic_optout;extern int irq_remapping_enabled;struct irq_remap_ops { -/* Check whether Interrupt Remapping is supported */ -int (*supported)(void ); -/* Initializes hardware and makes it ready for remapping interrupts */ int (*prepare)(void );
@@ -89,7 +85,6 @@ extern struct irq_remap_ops amd_iommu_irq_ops;#else /* CONFIG_IRQ_REMAP */ #define irq_remapping_enabled 0 -#define disable_irq_remap 1#define irq_remap_broken 0#endif /* CONFIG_IRQ_REMAP */
include/linux/smp.h +7 -0
@@ -151,6 +151,13 @@ smp_call_function_any(const struct cpumask *mask, smp_call_func_t func,static inline void kick_all_cpus_sync (void ) { }static inline void wake_up_all_idle_cpus (void ) { } +#ifdef CONFIG_UP_LATE_INIT +extern void __init up_late_init (void ); +static inline void smp_init (void ) {up_late_init (); } +#else +static inline void smp_init (void ) { } +#endif +#endif /* !SMP */ /*
init/main.c +0 -13
@@ -87,10 +87,6 @@#include <asm/sections.h> #include <asm/cacheflush.h> -#ifdef CONFIG_X86_LOCAL_APIC -#include <asm/smp.h> -#endif -static int kernel_init (void *);extern void init_IRQ (void );
@@ -351,15 +347,6 @@ __setup("rdinit=", rdinit_setup);#ifndef CONFIG_SMP static const unsigned int setup_max_cpus =NR_CPUS ; -#ifdef CONFIG_X86_LOCAL_APIC -static void __init smp_init (void ) -{ -APIC_init_uniprocessor (); -} -#else -#define smp_init () do { } while (0) -#endif -static inline void setup_nr_cpu_ids (void ) { }static inline void smp_prepare_cpus (unsigned int maxcpus) { }#endif
Quoted 4 lines · Ingo Molnar
Please pull the latest x86-apic-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gitx86-apic-for-linus
Just a heads-up: I'm currently bisecting my Chromebook Pixel no longer suspending cleanly, and it *seems* to be narrowing down on the apic changes (the scheduler changes are also in play, but they would seem less likely).
I'll update as I know more, but if somebody goes "ahh, xyzzy might matter for suspend/resume", then that might be worth it. Any ideas?
(The exact suspend failure is that it locks up at the end of the suspend somewhere, and never actually shuts down the machine)
Linus
Quoted 11 lines · Linus Torvalds
Quoted 4 lines · Ingo Molnar
Please pull the latest x86-apic-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gitx86-apic-for-linusJust a heads-up: I'm currently bisecting my Chromebook Pixel no longer suspending cleanly, and it *seems* to be narrowing down on the apic changes (the scheduler changes are also in play, but they would seem less likely).
Quoted 5 lines
I'll update as I know more, but if somebody goes "ahh, xyzzy might matter for suspend/resume", then that might be worth it. Any ideas?
(The exact suspend failure is that it locks up at the end of the suspend somewhere, and never actually shuts down the machine)
FWIW, I have a revert in my tree which is related to broken suspend. Commits to revert are e06bf91b59d3 and 37d11391c2de in this order.
I'll be sending a pull request with that tomorrow.
Rafael
Quoted 5 lines · Rafael J. Wysocki
FWIW, I have a revert in my tree which is related to broken suspend. Commits to revert are
e06bf91b59d3and37d11391c2dein this order.I'll be sending a pull request with that tomorrow.
It's neither of those for me. It's:
5fcee53ce705d49c766f8a302c7e93bdfc33c124 is the first bad commit commit 5fcee53ce705d49c766f8a302c7e93bdfc33c124
Author: Jiang Liu <[email protected]>
Date: Wed Jan 7 15:31:38 2015 +0800
x86/apic: Only disable CPU x2apic mode when necessary
according to my bisect.
Jiang, Joerg - that commit seems to cause a lockup at suspend time for me. Now, I haven't verified by reverting it from top-of-git yet, but the bisection seemed to be pretty stable. I'll try the revert next (it doesn't revert cleanly, but I can undo it by hand).
Any ideas? The Pixel Chromebook does have an odd and often broken BIOS/firmware thing, but it *used* to suspend and resume very reliably once we got around its insane TPM thing.
Linus
Quoted 5 lines · Linus Torvalds
Jiang, Joerg - that commit seems to cause a lockup at suspend time for me. Now, I haven't verified by reverting it from top-of-git yet, but the bisection seemed to be pretty stable. I'll try the revert next (it doesn't revert cleanly, but I can undo it by hand).
Confirmed. Reverting 5fcee53ce705 make the pixel suspend cleanly again.
Linus
Quoted 9 lines · Linus Torvalds
Quoted 5 lines · Linus Torvalds
Jiang, Joerg - that commit seems to cause a lockup at suspend time for me. Now, I haven't verified by reverting it from top-of-git yet, but the bisection seemed to be pretty stable. I'll try the revert next (it doesn't revert cleanly, but I can undo it by hand).
Confirmed. Reverting
5fcee53ce705make the pixel suspend cleanly again.
Hi Linus,
Sorry for the trouble. Seems there are conflicts between x2apic
and suspend on Chromebook. With commit 5fcee53ce705 applied, x2apic may be enabled on Chromebook, which in turn may cause suspend failure. Could you please help to revert the change first? I will try to find a Chromebook laptop and do more investigation.
Regards!
Gerry
Quoted 3 lines
Linus
Joerg Roedel
maintainerQuoted 3 lines · Linus Torvalds
Any ideas? The Pixel Chromebook does have an odd and often broken BIOS/firmware thing, but it *used* to suspend and resume very reliably once we got around its insane TPM thing.
Hmm, looking at the patch and the surrounding code my guess is that x2apic gets enabled now with 5fcee53ce705 on your Chromebook Pixel at boot, which causes the suspend issue later for other reasons.
So the condition should rather look like this to keep x2apic disabled like before:
arch/x86/kernel/apic/apic.c +2 -2
@@ -1580,8 +1580,8 @@ static __init void try_to_enable_x2apic(int remap_mode)* under KVM */ if (max_physical_apicid >255 || - (IS_ENABLED (CONFIG_HYPERVISOR_GUEST ) && - !hypervisor_x2apic_available ())) { + !(IS_ENABLED (CONFIG_HYPERVISOR_GUEST ) && +hypervisor_x2apic_available ())) {pr_info ("x2apic: IRQ remapping doesn't support X2APIC mode\n" );x2apic_disable ();return ;
Another solution would be to just revert 5fcee53ce705. This code is not in any fast-path, so we can live well without that optimization.
Joerg
Quoted 3 lines · Joerg Roedel
So the condition should rather look like this to keep x2apic disabled like before:
Yes, this works for me too.
Quoted 16 lines
arch/x86/kernel/apic/apic.c +2
-2@@ -1580,8 +1580,8 @@ static __init void try_to_enable_x2apic(int remap_mode)* under KVM */ if (max_physical_apicid >255 || - (IS_ENABLED (CONFIG_HYPERVISOR_GUEST ) && - !hypervisor_x2apic_available ())) { + !(IS_ENABLED (CONFIG_HYPERVISOR_GUEST ) && +hypervisor_x2apic_available ())) {pr_info ("x2apic: IRQ remapping doesn't support X2APIC mode\n" );x2apic_disable ();return ;
Quoted 2 lines
Another solution would be to just revert
5fcee53ce705. This code is not in any fast-path, so we can live well without that optimization.
Jiang, preferences? Revert, or fix like the above?
Linus
Quoted 23 lines · Linus Torvalds
Quoted 3 lines · Joerg Roedel
So the condition should rather look like this to keep x2apic disabled like before:
Yes, this works for me too.
Quoted 16 lines
arch/x86/kernel/apic/apic.c +2
-2@@ -1580,8 +1580,8 @@ static __init void try_to_enable_x2apic(int remap_mode)* under KVM */ if (max_physical_apicid >255 || - (IS_ENABLED (CONFIG_HYPERVISOR_GUEST ) && - !hypervisor_x2apic_available ())) { + !(IS_ENABLED (CONFIG_HYPERVISOR_GUEST ) && +hypervisor_x2apic_available ())) {pr_info ("x2apic: IRQ remapping doesn't support X2APIC mode\n" );x2apic_disable ();return ;
Quoted 4 lines
Quoted 2 lines
Another solution would be to just revert
5fcee53ce705. This code is not in any fast-path, so we can live well without that optimization.Jiang, preferences? Revert, or fix like the above?
Hi Linus,
I think reverting is better.
The IS_ENABLED(CONFIG_HYPERVISOR_GUEST) optimization doesn't
give us much, but it makes the code a little complex. Regards!
Gerry
Quoted 8 lines
Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 17 lines · Joerg Roedel
Quoted 3 lines · Linus Torvalds
Any ideas? The Pixel Chromebook does have an odd and often broken BIOS/firmware thing, but it *used* to suspend and resume very reliably once we got around its insane TPM thing.
Hmm, looking at the patch and the surrounding code my guess is that x2apic gets enabled now with
5fcee53ce705on your Chromebook Pixel at boot, which causes the suspend issue later for other reasons.So the condition should rather look like this to keep x2apic disabled like before:
arch/x86/kernel/apic/apic.c +0
-0
arch/x86/kernel/apic/apic.c static __init void try_to_enable_x2apic(int remap_mode) · line 1587
Quoted 10 lines
arch/x86/kernel/apic/apic.c +2
-2@@ -1580,8 +1580,8 @@ static __init void try_to_enable_x2apic(int remap_mode)* under KVM */ if (max_physical_apicid >255 || - (IS_ENABLED (CONFIG_HYPERVISOR_GUEST ) && - !hypervisor_x2apic_available ())) { + !(IS_ENABLED (CONFIG_HYPERVISOR_GUEST ) && +hypervisor_x2apic_available ())) {pr_info ("x2apic: IRQ remapping doesn't support X2APIC mode\n" );x2apic_disable ();return ;
Indeed!
Quoted 3 lines
Another solution would be to just revert
5fcee53ce705. This code is not in any fast-path, so we can live well without that optimization.
Agreed.
Thanks,
Ingo