linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Murray <andrew.murray@arm.com>
To: Rob Herring <robh@kernel.org>
Cc: linux-pci@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Ryder Lee <ryder.lee@mediatek.com>,
	linux-mediatek@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 03/11] PCI: mediatek: Use pci_parse_request_of_pci_ranges()
Date: Wed, 25 Sep 2019 12:34:27 +0100	[thread overview]
Message-ID: <20190925113427.GT9720@e119886-lin.cambridge.arm.com> (raw)
In-Reply-To: <20190924214630.12817-4-robh@kernel.org>

On Tue, Sep 24, 2019 at 04:46:22PM -0500, Rob Herring wrote:
> Convert Mediatek host bridge to use the common
> pci_parse_request_of_pci_ranges().
> 
> Cc: Ryder Lee <ryder.lee@mediatek.com>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Matthias Brugger <matthias.bgg@gmail.com>
> Cc: linux-mediatek@lists.infradead.org
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
>  drivers/pci/controller/pcie-mediatek.c | 47 ++++++++++----------------
>  1 file changed, 17 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c
> index 80601e1b939e..cea4112b5309 100644
> --- a/drivers/pci/controller/pcie-mediatek.c
> +++ b/drivers/pci/controller/pcie-mediatek.c
> @@ -211,7 +211,6 @@ struct mtk_pcie {
>  	void __iomem *base;
>  	struct clk *free_ck;
>  
> -	struct resource mem;
>  	struct list_head ports;
>  	const struct mtk_pcie_soc *soc;
>  	unsigned int busnr;
> @@ -658,11 +657,23 @@ static int mtk_pcie_setup_irq(struct mtk_pcie_port *port,
>  static int mtk_pcie_startup_port_v2(struct mtk_pcie_port *port)
>  {
>  	struct mtk_pcie *pcie = port->pcie;
> -	struct resource *mem = &pcie->mem;
> +	struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie);
> +	struct resource *mem = NULL;
> +	struct resource_entry *entry;
>  	const struct mtk_pcie_soc *soc = port->pcie->soc;
>  	u32 val;
>  	int err;
>  
> +	resource_list_for_each_entry(entry, &host->windows) {
> +		if (resource_type(entry->res) != IORESOURCE_MEM)
> +			continue;
> +
> +		mem = entry->res;
> +		break;
> +	}
> +	if (!mem)
> +		return -EINVAL;
> +
>  	/* MT7622 platforms need to enable LTSSM and ASPM from PCIe subsys */
>  	if (pcie->base) {
>  		val = readl(pcie->base + PCIE_SYS_CFG_V2);
> @@ -1017,39 +1028,15 @@ static int mtk_pcie_setup(struct mtk_pcie *pcie)
>  	struct mtk_pcie_port *port, *tmp;
>  	struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie);
>  	struct list_head *windows = &host->windows;
> -	struct resource_entry *win, *tmp_win;
> -	resource_size_t io_base;
> +	struct resource *bus;
>  	int err;
>  
> -	err = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff,
> -						    windows, &io_base);
> +	err = pci_parse_request_of_pci_ranges(dev, windows,
> +					      &bus);
>  	if (err)
>  		return err;
>  
> -	err = devm_request_pci_bus_resources(dev, windows);
> -	if (err < 0)
> -		return err;
> -
> -	/* Get the I/O and memory ranges from DT */
> -	resource_list_for_each_entry_safe(win, tmp_win, windows) {
> -		switch (resource_type(win->res)) {
> -		case IORESOURCE_IO:
> -			err = devm_pci_remap_iospace(dev, win->res, io_base);
> -			if (err) {
> -				dev_warn(dev, "error %d: failed to map resource %pR\n",
> -					 err, win->res);
> -				resource_list_destroy_entry(win);
> -			}
> -			break;
> -		case IORESOURCE_MEM:
> -			memcpy(&pcie->mem, win->res, sizeof(*win->res));
> -			pcie->mem.name = "non-prefetchable";

Using pci_parse_request_of_pci_ranges will now guard against using only
prefetchable memory ranges, whereas the existing code didn't do that. Given
that the current DT users all provide a non-prefetchable range I think this is
OK.

Reviewed-by: Andrew murray <andrew.murray@arm.com>

> -			break;
> -		case IORESOURCE_BUS:
> -			pcie->busnr = win->res->start;
> -			break;
> -		}
> -	}
> +	pcie->busnr = bus->start;
>  
>  	for_each_available_child_of_node(node, child) {
>  		int slot;
> -- 
> 2.20.1
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-09-25 11:34 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-24 21:46 [PATCH 00/11] PCI dma-ranges parsing consolidation Rob Herring
2019-09-24 21:46 ` [PATCH 01/11] PCI: aardvark: Use pci_parse_request_of_pci_ranges() Rob Herring
2019-09-25  8:59   ` Thomas Petazzoni
2019-09-25  9:04     ` Andrew Murray
2019-09-24 21:46 ` [PATCH 02/11] PCI: altera: " Rob Herring
2019-09-25 10:24   ` Andrew Murray
2019-09-25 12:33     ` Rob Herring
2019-09-30 15:13       ` Andrew Murray
2019-09-30 17:36         ` Rob Herring
2019-10-15 11:02           ` Lorenzo Pieralisi
2019-10-15 11:17             ` Rob Herring
2019-09-24 21:46 ` [PATCH 03/11] PCI: mediatek: " Rob Herring
2019-09-25 11:34   ` Andrew Murray [this message]
2019-09-24 21:46 ` [PATCH 04/11] PCI: versatile: Enable COMPILE_TEST Rob Herring
2019-09-26  8:12   ` Andrew Murray
2019-09-24 21:46 ` [PATCH 05/11] PCI: versatile: Use pci_parse_request_of_pci_ranges() Rob Herring
2019-09-25 10:37   ` Andrew Murray
2019-09-26 21:44     ` Rob Herring
2019-09-30 15:16       ` Andrew Murray
2019-09-30 16:56       ` Peter Maydell
2019-09-30 19:36         ` Andrew Murray
2019-09-24 21:46 ` [PATCH 06/11] PCI: of: Add inbound resource parsing to helpers Rob Herring
2019-09-25  9:00   ` Thomas Petazzoni
2019-09-26  8:29   ` Andrew Murray
2019-09-26 10:43   ` Gustavo Pimentel
2019-09-27 16:12   ` Jingoo Han
2019-09-27 16:12   ` Jingoo Han
2019-09-24 21:46 ` [PATCH 07/11] PCI: ftpci100: Use inbound resources for setup Rob Herring
2019-09-26  8:39   ` Andrew Murray
2019-09-24 21:46 ` [PATCH 08/11] PCI: v3-semi: " Rob Herring
2019-09-26  8:39   ` Andrew Murray
2019-09-30 22:00   ` Linus Walleij
2019-09-24 21:46 ` [PATCH 09/11] PCI: xgene: " Rob Herring
2019-09-26  8:39   ` Andrew Murray
2019-09-24 21:46 ` [PATCH 10/11] PCI: iproc: " Rob Herring
2019-09-26  8:39   ` Andrew Murray
2019-09-24 21:46 ` [PATCH 11/11] PCI: rcar: " Rob Herring
2019-09-26  8:47   ` Andrew Murray
2019-09-26 12:53     ` Rob Herring
2019-09-26 13:32       ` Andrew Murray
2019-09-26  8:49 ` [PATCH 00/11] PCI dma-ranges parsing consolidation Andrew Murray
2019-09-26 11:20   ` Marc Gonzalez
2019-09-26 13:11     ` Rob Herring
2019-09-26 13:38       ` Andrew Murray
2019-09-26 14:09         ` Marc Gonzalez

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=20190925113427.GT9720@e119886-lin.cambridge.arm.com \
    --to=andrew.murray@arm.com \
    --cc=bhelgaas@google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=matthias.bgg@gmail.com \
    --cc=robh@kernel.org \
    --cc=ryder.lee@mediatek.com \
    /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).