From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752842AbbKWHrD (ORCPT ); Mon, 23 Nov 2015 02:47:03 -0500 Received: from mx2.suse.de ([195.135.220.15]:59747 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751280AbbKWHrB (ORCPT ); Mon, 23 Nov 2015 02:47:01 -0500 To: Linux Kernel Mailing List , the arch/x86 maintainers , Thomas Gleixner , "H. Peter Anvin" , Ingo Molnar , Borislav Petkov From: Juergen Gross Subject: lapic_suspend/lapic_resume wrong? Message-ID: <5652C472.1010201@suse.com> Date: Mon, 23 Nov 2015 08:46:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050803020006040300030209" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a multi-part message in MIME format. --------------050803020006040300030209 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Hi, while trying to find the reason for a hanging kernel during resume handling I found a strange inconsistency in arch/x86/kernel/apic/apic.c regarding usage of config options. Attached patch addresses this, no test done as I'm not sure whether this is a correct approach. Can you have a look at it, please? Juergen --------------050803020006040300030209 Content-Type: text/x-patch; name="lapic.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="lapic.patch" diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index 2f69e3b..bc06c9d 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -2270,6 +2270,7 @@ static struct { unsigned int apic_tmict; unsigned int apic_tdcr; unsigned int apic_thmr; + unsigned int apic_cmci; } apic_pm_state; static int lapic_suspend(void) @@ -2299,6 +2300,10 @@ static int lapic_suspend(void) if (maxlvt >= 5) apic_pm_state.apic_thmr = apic_read(APIC_LVTTHMR); #endif +#ifdef CONFIG_X86_MCE_INTEL + if (maxlvt >= 6) + apic_pm_state.apic_cmci = apic_read(APIC_LVTCMCI); +#endif local_irq_save(flags); disable_local_APIC(); @@ -2355,10 +2360,14 @@ static void lapic_resume(void) apic_write(APIC_SPIV, apic_pm_state.apic_spiv); apic_write(APIC_LVT0, apic_pm_state.apic_lvt0); apic_write(APIC_LVT1, apic_pm_state.apic_lvt1); -#if defined(CONFIG_X86_MCE_INTEL) +#if defined(CONFIG_X86_THERMAL_VECTOR) if (maxlvt >= 5) apic_write(APIC_LVTTHMR, apic_pm_state.apic_thmr); #endif +#if defined(CONFIG_X86_MCE_INTEL) + if (maxlvt >= 6) + apic_write(APIC_LVTCMCI, apic_pm_state.apic_cmci); +#endif if (maxlvt >= 4) apic_write(APIC_LVTPC, apic_pm_state.apic_lvtpc); apic_write(APIC_LVTT, apic_pm_state.apic_lvtt); diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c index 849500e..524c221 100644 --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #endif #include @@ -420,7 +421,7 @@ static int __must_check xen_allocate_irq_gsi(unsigned gsi) return xen_allocate_irq_dynamic(); /* Legacy IRQ descriptors are already allocated by the arch. */ - if (gsi < NR_IRQS_LEGACY) + if (gsi < nr_legacy_irqs()) irq = gsi; else irq = irq_alloc_desc_at(gsi, -1); @@ -446,7 +447,7 @@ static void xen_free_irq(unsigned irq) kfree(info); /* Legacy IRQ descriptors are managed by the arch. */ - if (irq < NR_IRQS_LEGACY) + if (irq < nr_legacy_irqs()) return; irq_free_desc(irq); --------------050803020006040300030209--