From patchwork Wed Jun 8 06:59:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Rui Y" X-Patchwork-Id: 9163467 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9ACEB6088F for ; Wed, 8 Jun 2016 07:17:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BE7328376 for ; Wed, 8 Jun 2016 07:17:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8028828395; Wed, 8 Jun 2016 07:17:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B61628376 for ; Wed, 8 Jun 2016 07:17:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161210AbcFHHQh (ORCPT ); Wed, 8 Jun 2016 03:16:37 -0400 Received: from mga02.intel.com ([134.134.136.20]:3590 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752903AbcFHHQg (ORCPT ); Wed, 8 Jun 2016 03:16:36 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP; 08 Jun 2016 00:16:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,437,1459839600"; d="scan'208";a="997583952" Received: from wr-optiplex-9010.xa.intel.com ([10.238.71.86]) by fmsmga002.fm.intel.com with ESMTP; 08 Jun 2016 00:16:33 -0700 From: Rui Wang To: tglx@linutronix.de, rjw@rjwysocki.net, tony.luck@intel.com, bhelgaas@google.com Cc: linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, rui.y.wang@intel.com Subject: [PATCH V2 2/3] x86/ioapic: Fix wrong pointers in ioapic_setup_resources() Date: Wed, 8 Jun 2016 14:59:52 +0800 Message-Id: <1465369193-4816-3-git-send-email-rui.y.wang@intel.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1465369193-4816-1-git-send-email-rui.y.wang@intel.com> References: <1465369193-4816-1-git-send-email-rui.y.wang@intel.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On a 4-socket brickland, hot-removing one ioapic is fine. Hot-removing the 2nd one causes panic in mp_unregister_ioapic() while calling release_resource(). It is because the iomem_res pointer has already been released when removing the first ioapic. Fix it by assigning the correct pointers to ioapics[i].iomem_res in ioapic_setup_resources(). To explain the use of &res[num] here: res is assigned to ioapic_resources, and later in ioapic_insert_resources() we do struct resource *r = ioapic_resources; for_each_ioapic(i) { insert_resource(&iomem_resource, r); r++; } Here r is treated as an arry of struct resource, and the r++ ensures that each element of the array is inserted separately. Thus we should call release_resouce() on each element at &res[num]. Signed-off-by: Rui Wang --- arch/x86/kernel/apic/io_apic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index 84e33ff..446702e 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -2588,8 +2588,8 @@ static struct resource * __init ioapic_setup_resources(void) res[num].flags = IORESOURCE_MEM | IORESOURCE_BUSY; snprintf(mem, IOAPIC_RESOURCE_NAME_SIZE, "IOAPIC %u", i); mem += IOAPIC_RESOURCE_NAME_SIZE; + ioapics[i].iomem_res = &res[num]; num++; - ioapics[i].iomem_res = res; } ioapic_resources = res;