Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754558AbbLKFTn (ORCPT ); Fri, 11 Dec 2015 00:19:43 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:41877 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753807AbbLKFMs (ORCPT ); Fri, 11 Dec 2015 00:12:48 -0500 From: Yinghai Lu To: Bjorn Helgaas , David Miller , Benjamin Herrenschmidt , Wei Yang , TJ , Yijing Wang , Khalid Aziz Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Yinghai Lu Subject: [PATCH v9 17/60] PCI: Claim fixed resource during remove/rescan path Date: Thu, 10 Dec 2015 21:06:13 -0800 Message-Id: <1449810416-2950-18-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1449810416-2950-1-git-send-email-yinghai@kernel.org> References: <1449810416-2950-1-git-send-email-yinghai@kernel.org> X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1894 Lines: 54 During driver loading kernel will check if resources get reserved. so we need to make sure resources get reserved before pci_bus_add(). On remove/rescan path, we will leave those fixed resource not reserved. In that path, We don't call pcibios_resource_survery() before pci_assign_unassigned_bus_resources(), and that is intentional for us to get new resources for rescan. We do need to use rescan to make device get resource allocated while ignoring BIOS allocate resource. But fixed resources are not allocated via pci_assign_unassigned_bus_resources(), so we need to reserve them explicitly. Signed-off-by: Yinghai Lu --- drivers/pci/quirks.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 3618c06..d45455f 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -323,6 +323,23 @@ static void quirk_s3_64M(struct pci_dev *dev) DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_S3, PCI_DEVICE_ID_S3_868, quirk_s3_64M); DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_S3, PCI_DEVICE_ID_S3_968, quirk_s3_64M); +/* for pci remove and rescan */ +static void quirk_allocate_fixed(struct pci_dev *dev) +{ + int i; + for (i = 0; i < PCI_NUM_RESOURCES; i++) { + struct resource *r = &dev->resource[i]; + + if (r->parent || + !(r->flags & IORESOURCE_PCI_FIXED) || + !(r->flags & (IORESOURCE_IO | IORESOURCE_MEM))) + continue; + + pci_claim_resource(dev, i); + } +} +DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, quirk_allocate_fixed); + static void quirk_io(struct pci_dev *dev, int pos, unsigned size, const char *name) { -- 1.8.4.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/