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>,
linux-arm-kernel@lists.infradead.org,
Simon Horman <horms@verge.net.au>
Subject: Re: [PATCH 11/11] PCI: rcar: Use inbound resources for setup
Date: Thu, 26 Sep 2019 09:47:19 +0100 [thread overview]
Message-ID: <20190926084718.GA9720@e119886-lin.cambridge.arm.com> (raw)
In-Reply-To: <20190924214630.12817-12-robh@kernel.org>
On Tue, Sep 24, 2019 at 04:46:30PM -0500, Rob Herring wrote:
> Now that the helpers provide the inbound resources in the host bridge
> 'dma_ranges' resource list, convert Renesas R-Car PCIe host bridge to
> use the resource list to setup the inbound addresses.
>
> Cc: Simon Horman <horms@verge.net.au>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
> drivers/pci/controller/pcie-rcar.c | 45 +++++++++++-------------------
> 1 file changed, 16 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/pci/controller/pcie-rcar.c b/drivers/pci/controller/pcie-rcar.c
> index b8d6e86a5539..453c931aaf77 100644
> --- a/drivers/pci/controller/pcie-rcar.c
> +++ b/drivers/pci/controller/pcie-rcar.c
> @@ -1014,16 +1014,16 @@ static int rcar_pcie_get_resources(struct rcar_pcie *pcie)
> }
>
> static int rcar_pcie_inbound_ranges(struct rcar_pcie *pcie,
> - struct of_pci_range *range,
> + struct resource_entry *entry,
> int *index)
> {
> - u64 restype = range->flags;
> - u64 cpu_addr = range->cpu_addr;
> - u64 cpu_end = range->cpu_addr + range->size;
> - u64 pci_addr = range->pci_addr;
> + u64 restype = entry->res->flags;
> + u64 cpu_addr = entry->res->start;
> + u64 cpu_end = entry->res->end;
> + u64 pci_addr = entry->res->start - entry->offset;
> u32 flags = LAM_64BIT | LAR_ENABLE;
> u64 mask;
> - u64 size;
> + u64 size = resource_size(entry->res);
> int idx = *index;
>
> if (restype & IORESOURCE_PREFETCH)
> @@ -1037,9 +1037,7 @@ static int rcar_pcie_inbound_ranges(struct rcar_pcie *pcie,
> unsigned long nr_zeros = __ffs64(cpu_addr);
> u64 alignment = 1ULL << nr_zeros;
>
> - size = min(range->size, alignment);
> - } else {
> - size = range->size;
> + size = min(size, alignment);
> }
AFAICT the (if cpu_addr > 0) is here because the result of __ffs64 is undefined
if no bits are set (according to the comment). However by removing the else
statement we no longer guarantee that nr_zeros is defined.
> /* Hardware supports max 4GiB inbound region */
> size = min(size, 1ULL << 32);
> @@ -1078,30 +1076,19 @@ static int rcar_pcie_inbound_ranges(struct rcar_pcie *pcie,
> return 0;
> }
>
> -static int rcar_pcie_parse_map_dma_ranges(struct rcar_pcie *pcie,
> - struct device_node *np)
> +static int rcar_pcie_parse_map_dma_ranges(struct rcar_pcie *pcie)
> {
> - struct of_pci_range range;
> - struct of_pci_range_parser parser;
> - int index = 0;
> - int err;
> -
> - if (of_pci_dma_range_parser_init(&parser, np))
> - return -EINVAL;
> -
> - /* Get the dma-ranges from DT */
> - for_each_of_pci_range(&parser, &range) {
> - u64 end = range.cpu_addr + range.size - 1;
> -
> - dev_dbg(pcie->dev, "0x%08x 0x%016llx..0x%016llx -> 0x%016llx\n",
> - range.flags, range.cpu_addr, end, range.pci_addr);
> + struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
> + struct resource_entry *entry;
> + int index = 0, err = 0;
>
> - err = rcar_pcie_inbound_ranges(pcie, &range, &index);
> + resource_list_for_each_entry(entry, &bridge->dma_ranges) {
> + err = rcar_pcie_inbound_ranges(pcie, entry, &index);
> if (err)
> - return err;
> + break;
> }
>
> - return 0;
> + return err;
> }
>
> static const struct of_device_id rcar_pcie_of_match[] = {
> @@ -1162,7 +1149,7 @@ static int rcar_pcie_probe(struct platform_device *pdev)
> goto err_unmap_msi_irqs;
> }
>
> - err = rcar_pcie_parse_map_dma_ranges(pcie, dev->of_node);
> + err = rcar_pcie_parse_map_dma_ranges(pcie);
> if (err)
> goto err_clk_disable;
>
> --
> 2.20.1
>
next prev parent reply other threads:[~2019-09-26 8:47 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
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 [this message]
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=20190926084718.GA9720@e119886-lin.cambridge.arm.com \
--to=andrew.murray@arm.com \
--cc=bhelgaas@google.com \
--cc=horms@verge.net.au \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=robh@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).