From: Rob Herring <robh@kernel.org>
To: linux-pci@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>,
Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Ray Jui <rjui@broadcom.com>,
bcm-kernel-feedback-list@broadcom.com,
Scott Branden <sbranden@broadcom.com>,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH 10/11] PCI: iproc: Use inbound resources for setup
Date: Tue, 24 Sep 2019 16:46:29 -0500 [thread overview]
Message-ID: <20190924214630.12817-11-robh@kernel.org> (raw)
In-Reply-To: <20190924214630.12817-1-robh@kernel.org>
Now that the helpers provide the inbound resources in the host bridge
'dma_ranges' resource list, convert Broadcom iProc host bridge to use
the resource list to setup the inbound addresses.
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Ray Jui <rjui@broadcom.com>
Cc: Scott Branden <sbranden@broadcom.com>
Cc: bcm-kernel-feedback-list@broadcom.com
Signed-off-by: Rob Herring <robh@kernel.org>
---
drivers/pci/controller/pcie-iproc.c | 63 ++++-------------------------
1 file changed, 8 insertions(+), 55 deletions(-)
diff --git a/drivers/pci/controller/pcie-iproc.c b/drivers/pci/controller/pcie-iproc.c
index 2d457bfdaf66..9ed181050308 100644
--- a/drivers/pci/controller/pcie-iproc.c
+++ b/drivers/pci/controller/pcie-iproc.c
@@ -1122,15 +1122,15 @@ static int iproc_pcie_ib_write(struct iproc_pcie *pcie, int region_idx,
}
static int iproc_pcie_setup_ib(struct iproc_pcie *pcie,
- struct of_pci_range *range,
+ struct resource_entry *entry,
enum iproc_pcie_ib_map_type type)
{
struct device *dev = pcie->dev;
struct iproc_pcie_ib *ib = &pcie->ib;
int ret;
unsigned int region_idx, size_idx;
- u64 axi_addr = range->cpu_addr, pci_addr = range->pci_addr;
- resource_size_t size = range->size;
+ u64 axi_addr = entry->res->start, pci_addr = entry->res->start - entry->offset;
+ resource_size_t size = resource_size(entry->res);
/* iterate through all IARR mapping regions */
for (region_idx = 0; region_idx < ib->nr_regions; region_idx++) {
@@ -1182,66 +1182,19 @@ static int iproc_pcie_setup_ib(struct iproc_pcie *pcie,
return ret;
}
-static int iproc_pcie_add_dma_range(struct device *dev,
- struct list_head *resources,
- struct of_pci_range *range)
-{
- struct resource *res;
- struct resource_entry *entry, *tmp;
- struct list_head *head = resources;
-
- res = devm_kzalloc(dev, sizeof(struct resource), GFP_KERNEL);
- if (!res)
- return -ENOMEM;
-
- resource_list_for_each_entry(tmp, resources) {
- if (tmp->res->start < range->cpu_addr)
- head = &tmp->node;
- }
-
- res->start = range->cpu_addr;
- res->end = res->start + range->size - 1;
-
- entry = resource_list_create_entry(res, 0);
- if (!entry)
- return -ENOMEM;
-
- entry->offset = res->start - range->cpu_addr;
- resource_list_add(entry, head);
-
- return 0;
-}
-
static int iproc_pcie_map_dma_ranges(struct iproc_pcie *pcie)
{
struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie);
- struct of_pci_range range;
- struct of_pci_range_parser parser;
- int ret;
- LIST_HEAD(resources);
+ struct resource_entry *entry;
+ int ret = 0;
- /* Get the dma-ranges from DT */
- ret = of_pci_dma_range_parser_init(&parser, pcie->dev->of_node);
- if (ret)
- return ret;
-
- for_each_of_pci_range(&parser, &range) {
- ret = iproc_pcie_add_dma_range(pcie->dev,
- &resources,
- &range);
- if (ret)
- goto out;
+ resource_list_for_each_entry(entry, &host->dma_ranges) {
/* Each range entry corresponds to an inbound mapping region */
- ret = iproc_pcie_setup_ib(pcie, &range, IPROC_PCIE_IB_MAP_MEM);
+ ret = iproc_pcie_setup_ib(pcie, entry, IPROC_PCIE_IB_MAP_MEM);
if (ret)
- goto out;
+ break;
}
- list_splice_init(&resources, &host->dma_ranges);
-
- return 0;
-out:
- pci_free_resource_list(&resources);
return ret;
}
--
2.20.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-09-24 21:50 UTC|newest]
Thread overview: 46+ 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
2020-01-13 9:56 ` Bharat Kumar Gogada
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 ` Rob Herring [this message]
2019-09-26 8:39 ` [PATCH 10/11] PCI: iproc: " 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=20190924214630.12817-11-robh@kernel.org \
--to=robh@kernel.org \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=bhelgaas@google.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=rjui@broadcom.com \
--cc=sbranden@broadcom.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).