From patchwork Fri Feb 8 19:28:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 2117771 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id A7E46DFE75 for ; Fri, 8 Feb 2013 19:29:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760405Ab3BHT3D (ORCPT ); Fri, 8 Feb 2013 14:29:03 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:33354 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760341Ab3BHT3A (ORCPT ); Fri, 8 Feb 2013 14:29:00 -0500 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r18JSjZg023187 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 8 Feb 2013 19:28:45 GMT Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r18JSifT000405 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 8 Feb 2013 19:28:45 GMT Received: from abhmt112.oracle.com (abhmt112.oracle.com [141.146.116.64]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id r18JSisi010402; Fri, 8 Feb 2013 13:28:44 -0600 Received: from linux-siqj.site (/10.132.127.230) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 08 Feb 2013 11:28:44 -0800 From: Yinghai Lu To: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Bjorn Helgaas , "Rafael J. Wysocki" Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Yinghai Lu Subject: [PATCH v2 25/26] PCI: Disable mem in the ioapic removing path Date: Fri, 8 Feb 2013 11:28:22 -0800 Message-Id: <1360351703-20571-26-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1360351703-20571-1-git-send-email-yinghai@kernel.org> References: <1360351703-20571-1-git-send-email-yinghai@kernel.org> X-Source-IP: acsinet22.oracle.com [141.146.126.238] Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org For physical hot plug should be ok, but for remove/rescan path will need us to disable that. otherwise rescan mmio resource for pci ioapic device will not be sized and allocated, aka skiped. For ioapic_probe:pci_enable_device will not enable the device correctly, and will bail out early. So we can just disable mmio for all removing case, and that will not hurt real hotplug path. Signed-off-by: --- drivers/pci/ioapic.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/pci/ioapic.c b/drivers/pci/ioapic.c index 3c6bbdd..8dacfd0 100644 --- a/drivers/pci/ioapic.c +++ b/drivers/pci/ioapic.c @@ -88,6 +88,17 @@ exit_free: return -ENODEV; } +static void pci_disable_device_mem(struct pci_dev *dev) +{ + u16 pci_command; + + pci_read_config_word(dev, PCI_COMMAND, &pci_command); + if (pci_command & PCI_COMMAND_MEMORY) { + pci_command &= ~PCI_COMMAND_MEMORY; + pci_write_config_word(dev, PCI_COMMAND, pci_command); + } +} + static void ioapic_remove(struct pci_dev *dev) { struct ioapic *ioapic = pci_get_drvdata(dev); @@ -95,6 +106,8 @@ static void ioapic_remove(struct pci_dev *dev) acpi_unregister_ioapic(ioapic->handle, ioapic->gsi_base); pci_release_region(dev, 0); pci_disable_device(dev); + /* need to disable it, otherwise remove/rescan will not work */ + pci_disable_device_mem(dev); kfree(ioapic); }