linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Herring <robh@kernel.org>
To: Andrew Murray <andrew.murray@arm.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	bcm-kernel-feedback-list@broadcom.com,
	Christoph Hellwig <hch@infradead.org>,
	Gustavo Pimentel <gustavo.pimentel@synopsys.com>,
	Heiko Stuebner <heiko@sntech.de>,
	Hou Zhiqiang <Zhiqiang.Hou@nxp.com>,
	Jingoo Han <jingoohan1@gmail.com>,
	Karthikeyan Mitran <m.karthikeyan@mobiveil.co.in>,
	Ley Foon Tan <lftan@altera.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	linux-mediatek@lists.infradead.org,
	linux-renesas-soc@vger.kernel.org,
	linux-rockchip@lists.infradead.org,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Michal Simek <michal.simek@xilinx.com>,
	Ray Jui <rjui@broadcom.com>,
	rfi@lists.rocketboards.org, Ryder Lee <ryder.lee@mediatek.com>,
	Scott Branden <sbranden@broadcom.com>,
	Shawn Lin <shawn.lin@rock-chips.com>,
	Simon Horman <horms@verge.net.au>,
	Srinath Mannam <srinath.mannam@broadcom.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Toan Le <toan@os.amperecomputing.com>,
	Tom Joseph <tjoseph@cadence.com>, Will Deacon <will@kernel.org>
Subject: [PATCH v3 13/25] PCI: xgene: Use pci_parse_request_of_pci_ranges()
Date: Mon, 28 Oct 2019 11:32:44 -0500	[thread overview]
Message-ID: <20191028163256.8004-14-robh@kernel.org> (raw)
In-Reply-To: <20191028163256.8004-1-robh@kernel.org>

Convert the xgene host bridge to use the common
pci_parse_request_of_pci_ranges().

There's no need to assign the resources to a temporary list first. Just
use bridge->windows directly and remove all the temporary list handling.

Cc: Toan Le <toan@os.amperecomputing.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Andrew Murray <andrew.murray@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Rob Herring <robh@kernel.org>
---
 drivers/pci/controller/pci-xgene.c | 39 +++++++++---------------------
 1 file changed, 11 insertions(+), 28 deletions(-)

diff --git a/drivers/pci/controller/pci-xgene.c b/drivers/pci/controller/pci-xgene.c
index ffda3e8b4742..7d0f0395a479 100644
--- a/drivers/pci/controller/pci-xgene.c
+++ b/drivers/pci/controller/pci-xgene.c
@@ -405,15 +405,13 @@ static void xgene_pcie_setup_cfg_reg(struct xgene_pcie_port *port)
 	xgene_pcie_writel(port, CFGCTL, EN_REG);
 }
 
-static int xgene_pcie_map_ranges(struct xgene_pcie_port *port,
-				 struct list_head *res,
-				 resource_size_t io_base)
+static int xgene_pcie_map_ranges(struct xgene_pcie_port *port)
 {
+	struct pci_host_bridge *bridge = pci_host_bridge_from_priv(port);
 	struct resource_entry *window;
 	struct device *dev = port->dev;
-	int ret;
 
-	resource_list_for_each_entry(window, res) {
+	resource_list_for_each_entry(window, &bridge->windows) {
 		struct resource *res = window->res;
 		u64 restype = resource_type(res);
 
@@ -421,11 +419,9 @@ static int xgene_pcie_map_ranges(struct xgene_pcie_port *port,
 
 		switch (restype) {
 		case IORESOURCE_IO:
-			xgene_pcie_setup_ob_reg(port, res, OMR3BARL, io_base,
+			xgene_pcie_setup_ob_reg(port, res, OMR3BARL,
+						pci_pio_to_address(res->start),
 						res->start - window->offset);
-			ret = devm_pci_remap_iospace(dev, res, io_base);
-			if (ret < 0)
-				return ret;
 			break;
 		case IORESOURCE_MEM:
 			if (res->flags & IORESOURCE_PREFETCH)
@@ -567,8 +563,7 @@ static void xgene_pcie_clear_config(struct xgene_pcie_port *port)
 		xgene_pcie_writel(port, i, 0);
 }
 
-static int xgene_pcie_setup(struct xgene_pcie_port *port, struct list_head *res,
-			    resource_size_t io_base)
+static int xgene_pcie_setup(struct xgene_pcie_port *port)
 {
 	struct device *dev = port->dev;
 	u32 val, lanes = 0, speed = 0;
@@ -580,7 +575,7 @@ static int xgene_pcie_setup(struct xgene_pcie_port *port, struct list_head *res,
 	val = (XGENE_PCIE_DEVICEID << 16) | XGENE_PCIE_VENDORID;
 	xgene_pcie_writel(port, BRIDGE_CFG_0, val);
 
-	ret = xgene_pcie_map_ranges(port, res, io_base);
+	ret = xgene_pcie_map_ranges(port);
 	if (ret)
 		return ret;
 
@@ -607,11 +602,9 @@ static int xgene_pcie_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct device_node *dn = dev->of_node;
 	struct xgene_pcie_port *port;
-	resource_size_t iobase = 0;
 	struct pci_bus *bus, *child;
 	struct pci_host_bridge *bridge;
 	int ret;
-	LIST_HEAD(res);
 
 	bridge = devm_pci_alloc_host_bridge(dev, sizeof(*port));
 	if (!bridge)
@@ -634,20 +627,14 @@ static int xgene_pcie_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	ret = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, &res,
-						    &iobase);
+	ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows, NULL);
 	if (ret)
 		return ret;
 
-	ret = devm_request_pci_bus_resources(dev, &res);
-	if (ret)
-		goto error;
-
-	ret = xgene_pcie_setup(port, &res, iobase);
+	ret = xgene_pcie_setup(port);
 	if (ret)
-		goto error;
+		return ret;
 
-	list_splice_init(&res, &bridge->windows);
 	bridge->dev.parent = dev;
 	bridge->sysdata = port;
 	bridge->busnr = 0;
@@ -657,7 +644,7 @@ static int xgene_pcie_probe(struct platform_device *pdev)
 
 	ret = pci_scan_root_bus_bridge(bridge);
 	if (ret < 0)
-		goto error;
+		return ret;
 
 	bus = bridge->bus;
 
@@ -666,10 +653,6 @@ static int xgene_pcie_probe(struct platform_device *pdev)
 		pcie_bus_configure_settings(child);
 	pci_bus_add_devices(bus);
 	return 0;
-
-error:
-	pci_free_resource_list(&res);
-	return ret;
 }
 
 static const struct of_device_id xgene_pcie_match_table[] = {
-- 
2.20.1


  parent reply	other threads:[~2019-10-28 16:33 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-28 16:32 [PATCH v3 00/25] PCI host resource consolidation Rob Herring
2019-10-28 16:32 ` [PATCH v3 01/25] resource: Add a resource_list_first_type helper Rob Herring
2019-10-28 16:32 ` [PATCH v3 02/25] PCI: Export pci_parse_request_of_pci_ranges() Rob Herring
2019-10-28 16:32 ` [PATCH v3 03/25] PCI: aardvark: Use pci_parse_request_of_pci_ranges() Rob Herring
2019-10-28 16:32 ` [PATCH v3 04/25] PCI: altera: " Rob Herring
2019-10-28 16:32 ` [PATCH v3 05/25] PCI: dwc: " Rob Herring
2019-10-28 16:32 ` [PATCH v3 06/25] PCI: faraday: " Rob Herring
2019-11-03 19:12   ` Linus Walleij
2019-10-28 16:32 ` [PATCH v3 07/25] PCI: iproc: " Rob Herring
2019-10-29 15:58   ` Srinath Mannam
2019-10-29 17:09     ` Florian Fainelli
2019-10-28 16:32 ` [PATCH v3 08/25] PCI: mediatek: " Rob Herring
2019-10-28 16:32 ` [PATCH v3 09/25] PCI: mobiveil: " Rob Herring
2019-10-29  9:00   ` Z.q. Hou
2019-10-28 16:32 ` [PATCH v3 10/25] PCI: rockchip: " Rob Herring
2019-12-05 17:56   ` Enric Balletbo Serra
2019-12-06 13:52     ` Lorenzo Pieralisi
2019-12-06 14:09     ` Lorenzo Pieralisi
2019-12-06 14:59       ` Enric Balletbo Serra
2019-10-28 16:32 ` [PATCH v3 11/25] PCI: rockchip: Drop storing driver private outbound resource data Rob Herring
2019-12-06 15:36   ` Lorenzo Pieralisi
2019-12-10 17:33     ` Enric Balletbo Serra
2019-12-11  9:39       ` Enric Balletbo Serra
2019-10-28 16:32 ` [PATCH v3 12/25] PCI: v3-semi: Use pci_parse_request_of_pci_ranges() Rob Herring
2019-10-28 16:32 ` Rob Herring [this message]
2019-10-28 16:32 ` [PATCH v3 14/25] PCI: xilinx: " Rob Herring
2019-10-28 16:32 ` [PATCH v3 15/25] PCI: xilinx-nwl: " Rob Herring
2019-10-28 16:32 ` [PATCH v3 16/25] PCI: versatile: " Rob Herring
2019-10-28 16:32 ` [PATCH v3 17/25] PCI: versatile: Remove usage of PHYS_OFFSET Rob Herring
2019-10-28 16:32 ` [PATCH v3 18/25] PCI: versatile: Enable COMPILE_TEST Rob Herring
2019-10-28 16:32 ` [PATCH v3 19/25] PCI: of: Add inbound resource parsing to helpers Rob Herring
2019-10-29 11:07   ` Lorenzo Pieralisi
2019-10-29 15:56     ` Srinath Mannam
2019-10-29 17:34       ` Lorenzo Pieralisi
2019-10-30  6:44         ` Srinath Mannam
2019-10-30 11:48           ` Lorenzo Pieralisi
2019-10-30 12:49             ` Robin Murphy
2019-10-30 14:56               ` Lorenzo Pieralisi
2019-10-30 22:18                 ` Rob Herring
2019-10-31 10:09                   ` Lorenzo Pieralisi
2019-10-29 22:12     ` Bjorn Helgaas
2019-10-28 16:32 ` [PATCH v3 20/25] PCI: ftpci100: Use inbound resources for setup Rob Herring
2019-10-28 16:32 ` [PATCH v3 21/25] PCI: v3-semi: " Rob Herring
2019-10-28 16:32 ` [PATCH v3 22/25] PCI: xgene: " Rob Herring
2019-10-28 16:32 ` [PATCH v3 23/25] PCI: iproc: " Rob Herring
2019-10-29 15:59   ` Srinath Mannam
2019-10-28 16:32 ` [PATCH v3 24/25] PCI: rcar: " Rob Herring
2019-10-28 16:32 ` [PATCH v3 25/25] PCI: Make devm_of_pci_get_host_bridge_resources() static Rob Herring
2019-10-31 10:57 ` [PATCH v3 00/25] PCI host resource consolidation Lorenzo Pieralisi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191028163256.8004-14-robh@kernel.org \
    --to=robh@kernel.org \
    --cc=Zhiqiang.Hou@nxp.com \
    --cc=andrew.murray@arm.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=bhelgaas@google.com \
    --cc=gustavo.pimentel@synopsys.com \
    --cc=hch@infradead.org \
    --cc=heiko@sntech.de \
    --cc=horms@verge.net.au \
    --cc=jingoohan1@gmail.com \
    --cc=lftan@altera.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=m.karthikeyan@mobiveil.co.in \
    --cc=matthias.bgg@gmail.com \
    --cc=michal.simek@xilinx.com \
    --cc=rfi@lists.rocketboards.org \
    --cc=rjui@broadcom.com \
    --cc=ryder.lee@mediatek.com \
    --cc=sbranden@broadcom.com \
    --cc=shawn.lin@rock-chips.com \
    --cc=srinath.mannam@broadcom.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=tjoseph@cadence.com \
    --cc=toan@os.amperecomputing.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).