From patchwork Fri Dec 11 05:05:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 7825331 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0CF0A9F1C2 for ; Fri, 11 Dec 2015 05:20:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 27B9D20576 for ; Fri, 11 Dec 2015 05:20:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0E40E20573 for ; Fri, 11 Dec 2015 05:20:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753377AbbLKFMl (ORCPT ); Fri, 11 Dec 2015 00:12:41 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:41826 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753307AbbLKFMj (ORCPT ); Fri, 11 Dec 2015 00:12:39 -0500 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id tBB57H74016062 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 11 Dec 2015 05:07:17 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.13.8/8.13.8) with ESMTP id tBB57E68004866 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 11 Dec 2015 05:07:16 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id tBB57Er7002875; Fri, 11 Dec 2015 05:07:14 GMT Received: from linux-siqj.site (/69.181.250.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 10 Dec 2015 21:07:14 -0800 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 01/60] PCI: Add pci_find_root_bus_resource() Date: Thu, 10 Dec 2015 21:05:57 -0800 Message-Id: <1449810416-2950-2-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: userv0022.oracle.com [156.151.31.74] Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add pci_find_root_bus_resource() to return root bus res for resource. For sparc mem64 support, We need that host bridge window res, 1. we need direct parent for request_resource_conflict() calling in pci_register_legacy_regions(). 2. check if return is NULL to decide if region is valid or not. Convert old pci_find_parent_resource() to pci_find_bus_resource(), and reuse it in pci_find_root_bus_resource(). So we avoid changing pcibios_bus_to_resource(). Signed-off-by: Yinghai Lu --- drivers/pci/pci.c | 36 +++++++++++++++++++++++++----------- include/linux/pci.h | 2 ++ 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 314db8c..c8cae87 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -415,18 +415,9 @@ int pci_find_ht_capability(struct pci_dev *dev, int ht_cap) } EXPORT_SYMBOL_GPL(pci_find_ht_capability); -/** - * pci_find_parent_resource - return resource region of parent bus of given region - * @dev: PCI device structure contains resources to be searched - * @res: child resource record for which parent is sought - * - * For given resource region of given device, return the resource - * region of parent bus the given region is contained in. - */ -struct resource *pci_find_parent_resource(const struct pci_dev *dev, - struct resource *res) +static struct resource *pci_find_bus_resource(const struct pci_bus *bus, + struct resource *res) { - const struct pci_bus *bus = dev->bus; struct resource *r; int i; @@ -456,8 +447,31 @@ struct resource *pci_find_parent_resource(const struct pci_dev *dev, } return NULL; } + +/** + * pci_find_parent_resource - return resource region of parent bus of given region + * @dev: PCI device structure contains resources to be searched + * @res: child resource record for which parent is sought + * + * For given resource region of given device, return the resource + * region of parent bus the given region is contained in. + */ +struct resource *pci_find_parent_resource(const struct pci_dev *dev, + struct resource *res) +{ + return pci_find_bus_resource(dev->bus, res); +} EXPORT_SYMBOL(pci_find_parent_resource); +struct resource *pci_find_root_bus_resource(struct pci_bus *bus, + struct resource *res) +{ + while (bus->parent) + bus = bus->parent; + + return pci_find_bus_resource(bus, res); +} + /** * pci_find_pcie_root_port - return PCIe Root Port * @dev: PCI device to query diff --git a/include/linux/pci.h b/include/linux/pci.h index 6ae25aa..8b3896b 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -792,6 +792,8 @@ void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region, struct resource *res); void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res, struct pci_bus_region *region); +struct resource *pci_find_root_bus_resource(struct pci_bus *bus, + struct resource *res); void pcibios_scan_specific_bus(int busn); struct pci_bus *pci_find_bus(int domain, int busnr); void pci_bus_add_devices(const struct pci_bus *bus);