From patchwork Sat Aug 5 06:37:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 798155 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gZ+04Tfl"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xPYyv582Yz9tWL for ; Sat, 5 Aug 2017 16:38:31 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751398AbdHEGi3 (ORCPT ); Sat, 5 Aug 2017 02:38:29 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:36202 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751371AbdHEGi2 (ORCPT ); Sat, 5 Aug 2017 02:38:28 -0400 Received: by mail-pf0-f196.google.com with SMTP id t83so3773187pfj.3; Fri, 04 Aug 2017 23:38:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=VEOzeO/8fsyXCQZoDBLto7PS+U5kV8ImIl8iTrh3rgA=; b=gZ+04TfllEuonVleyZrdbDKXL/zL534xc/ioJuTQzWCNCWt9NbD+JreVoYSjWFyIn5 ZtDVQtPlvhuvj5QWbCySn1LRaQ3CWUMJoqJ06d62gz2Ykt/be48/n5IKBGD7V3bfyXg3 gslVKMpiPKJU3y1LNk0NYLEzaKNpPUSM919rc1YbUZai7YbCF87HJ/kJXaR6nUIGS0nF MU0+Wzi3VdoD8QzfShfY0Q9ZoQW61KqmkAFkRTzFD7p/xCYnreV8W0O94yo79mzOzD3e lm4SKrsQM3WjC+1Bf/f7COLZz6Xy+TyFLL8+SaOohFPQiidFNJo/4lW/OeIDzPFbJmb2 30rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=VEOzeO/8fsyXCQZoDBLto7PS+U5kV8ImIl8iTrh3rgA=; b=TGUiuoJ9XmhZhODaCUXKfgVb6v7vmr7+Y3XT3ElvNQ2Hc+pFywF234nrBb58x/+rmb ru9oBBfnHFwKHeLp3mdWZ8Wux8f84ol+cFjx49Jw+GLd+c/yk7mO6+Ev4yZv9cYVuUQj A1euek9lCm4K6w6g7Tfvfvg0lm62JmhEf7QjygtRN0iVj4UIvVDjcI45gnSGMAs4aUIh gp53ekBi1N2ukLhqFhdUPqB/hd+6FVKFs/QELMFej9Y/fZyNP1i7NTzeQ1UtYNYHenLR 5wxGUSo6S77a9oc0qDIh2AJ1+MQrP10JlsEFuKEmoWAm5x8ZAZJHeWNvVTbAHZgfJfg2 EiIA== X-Gm-Message-State: AIVw1111RKMbNcSY+eYbDlSBgqFk4fO+SUlDFWNxIG7d1w1UyGS9rBN5 ssyoKRQM6rW+UA== X-Received: by 10.98.65.220 with SMTP id g89mr4956530pfd.122.1501915107495; Fri, 04 Aug 2017 23:38:27 -0700 (PDT) Received: from dhcp-whq-twvpn-3-vpnpool-10-159-238-106.vpn.oracle.com (c-69-181-250-163.hsd1.ca.comcast.net. [69.181.250.163]) by smtp.gmail.com with ESMTPSA id j124sm6131387pfc.78.2017.08.04.23.38.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Aug 2017 23:38:27 -0700 (PDT) From: Yinghai Lu To: Bjorn Helgaas Cc: Linus Torvalds , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Yinghai Lu Subject: [PATCH 02/10] PCI: introduce ioport_res/iomem_res for PCI_TEST Date: Fri, 4 Aug 2017 23:37:53 -0700 Message-Id: <20170805063801.15880-3-yinghai@kernel.org> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170805063801.15880-1-yinghai@kernel.org> References: <20170805063801.15880-1-yinghai@kernel.org> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Make every bus to take the pointer to correct iomem_res instead of using iomem_resource directly. So PCI_TEST could use different iomem_res later. Signed-off-by: Yinghai Lu --- drivers/pci/probe.c | 2 ++ drivers/pci/quirks.c | 2 +- drivers/pci/setup-bus.c | 2 +- drivers/pci/setup-res.c | 4 ++-- include/linux/pci.h | 13 +++++++++++++ 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index c31310d..1811016 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -881,6 +881,8 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent, child->msi = parent->msi; child->sysdata = parent->sysdata; child->bus_flags = parent->bus_flags; + child->iomem_res = parent->iomem_res; + child->ioport_res = parent->ioport_res; /* initialize some portions of the bus device, but don't register it * now as the parent is not properly set up yet. diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 6967c6b..dc31098 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -1617,7 +1617,7 @@ static void quirk_alder_ioapic(struct pci_dev *pdev) * not touch this (and it's already covered by the fixmap), so * forcibly insert it into the resource tree */ if (pci_resource_start(pdev, 0) && pci_resource_len(pdev, 0)) - insert_resource(&iomem_resource, &pdev->resource[0]); + insert_resource(iomem_res(pdev->bus), &pdev->resource[0]); /* The next five BARs all seem to be rubbish, so just clean * them out */ diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 958da7d..1c30102 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -805,7 +805,7 @@ static struct resource *find_free_bus_resource(struct pci_bus *bus, struct resource *r; pci_bus_for_each_resource(bus, r, i) { - if (r == &ioport_resource || r == &iomem_resource) + if (r == ioport_res(bus) || r == iomem_res(bus)) continue; if (r && (r->flags & type_mask) == type && !r->parent) return r; diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index 85774b7..43921a4 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -215,9 +215,9 @@ static int pci_revert_fw_address(struct resource *res, struct pci_dev *dev, root = pci_find_parent_resource(dev, res); if (!root) { if (res->flags & IORESOURCE_IO) - root = &ioport_resource; + root = ioport_res(dev->bus); else - root = &iomem_resource; + root = iomem_res(dev->bus); } dev_info(&dev->dev, "BAR %d: trying firmware assignment %pR\n", diff --git a/include/linux/pci.h b/include/linux/pci.h index 4869e66..c58a635 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -524,6 +524,9 @@ struct pci_bus { void *sysdata; /* hook for sys-specific extension */ struct proc_dir_entry *procdir; /* directory entry in /proc/bus/pci */ + struct resource *iomem_res; /* pointer to root iomem_resource */ + struct resource *ioport_res; /* pointer to root ioport_resource */ + unsigned char number; /* bus number */ unsigned char primary; /* number of primary bridge */ unsigned char max_bus_speed; /* enum pci_bus_speed */ @@ -545,6 +548,16 @@ struct pci_bus { #define to_pci_bus(n) container_of(n, struct pci_bus, dev) +static inline struct resource *iomem_res(struct pci_bus *bus) +{ + return bus->iomem_res ? : &iomem_resource; +} + +static inline struct resource *ioport_res(struct pci_bus *bus) +{ + return bus->ioport_res ? : &ioport_resource; +} + /* * Returns true if the PCI bus is root (behind host-PCI bridge), * false otherwise