From patchwork Fri Apr 12 22:44:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 2438391 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 45A67DFE76 for ; Fri, 12 Apr 2013 22:46:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755991Ab3DLWqK (ORCPT ); Fri, 12 Apr 2013 18:46:10 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:47460 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753193Ab3DLWqG (ORCPT ); Fri, 12 Apr 2013 18:46:06 -0400 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r3CMixKv000352 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 12 Apr 2013 22:45:00 GMT Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r3CMixK6023081 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 12 Apr 2013 22:44:59 GMT Received: from abhmt115.oracle.com (abhmt115.oracle.com [141.146.116.67]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r3CMixlf023076; Fri, 12 Apr 2013 22:44:59 GMT Received: from linux-siqj.site (/10.132.126.191) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 12 Apr 2013 15:44:59 -0700 From: Yinghai Lu To: Bjorn Helgaas , Ram Pai Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Yinghai Lu Subject: [PATCH v4 26/29] PCI: Assign/update resource to addon_res Date: Fri, 12 Apr 2013 15:44:40 -0700 Message-Id: <1365806683-26717-27-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1365806683-26717-1-git-send-email-yinghai@kernel.org> References: <1365806683-26717-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 Extend pci_update_resource to check resno and call addon resources ops to update bar for it. Signed-off-by: Yinghai Lu --- drivers/pci/setup-res.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index 94ef232..6a85dcf 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -35,7 +35,7 @@ void pci_update_resource(struct pci_dev *dev, int resno) u32 new, check, mask; int reg; enum pci_bar_type type; - struct resource *res = dev->resource + resno; + struct resource *res = pci_dev_resource_n(dev, resno); /* * Ignore resources for unimplemented BARs and unused resource slots @@ -52,6 +52,21 @@ void pci_update_resource(struct pci_dev *dev, int resno) if (res->flags & IORESOURCE_PCI_FIXED) return; + if (resno >= PCI_NUM_RESOURCES) { + struct pci_dev_addon_resource *addon_res; + + addon_res = to_pci_dev_addon_resource(res); + reg = addon_res->reg_addr; + if (addon_res->ops) { + addon_res->ops->write(dev, res, reg); + return; + } + } else + reg = pci_resource_bar(dev, resno, &type); + + if (!reg) + return; + pcibios_resource_to_bus(dev, ®ion, res); new = region.start | (res->flags & PCI_REGION_FLAG_MASK); @@ -60,9 +75,6 @@ void pci_update_resource(struct pci_dev *dev, int resno) else mask = (u32)PCI_BASE_ADDRESS_MEM_MASK; - reg = pci_resource_bar(dev, resno, &type); - if (!reg) - return; if (type != pci_bar_unknown) { if (!(res->flags & IORESOURCE_ROM_ENABLE)) return; @@ -286,7 +298,7 @@ int pci_assign_resource(struct pci_dev *dev, int resno) if (!ret) { res->flags &= ~IORESOURCE_STARTALIGN; dev_info(&dev->dev, "BAR %d: assigned %pR\n", resno, res); - if (resno < PCI_BRIDGE_RESOURCES) + if (!is_pci_bridge_resource_idx(resno)) pci_update_resource(dev, resno); } return ret; @@ -311,7 +323,7 @@ int pci_reassign_resource(struct pci_dev *dev, int resno, resource_size_t addsiz if (!ret) { res->flags &= ~IORESOURCE_STARTALIGN; dev_info(&dev->dev, "BAR %d: reassigned %pR\n", resno, res); - if (resno < PCI_BRIDGE_RESOURCES) + if (!is_pci_bridge_resource_idx(resno)) pci_update_resource(dev, resno); } return ret;