linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 0/3] PCIe Host request to reserve IOVA
@ 2019-05-03 14:05 Srinath Mannam
  2019-05-03 14:05 ` [PATCH v6 1/3] PCI: Add dma_ranges window list Srinath Mannam
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Srinath Mannam @ 2019-05-03 14:05 UTC (permalink / raw)
  To: Bjorn Helgaas, Robin Murphy, Joerg Roedel, Lorenzo Pieralisi,
	Eric Auger, poza, Ray Jui
  Cc: bcm-kernel-feedback-list, linux-pci, iommu, linux-kernel, Srinath Mannam

This patch set will reserve IOVA addresses for DMA memory holes.

The IPROC host controller allows only a few ranges of physical address
as inbound PCI addresses which are listed through dma-ranges DT property.
Added dma_ranges list field of PCI host bridge structure to hold these
allowed inbound address ranges in sorted order.

Process this list and reserve IOVA addresses that are not present in its
resource entries (ie DMA memory holes) to prevent allocating IOVA
addresses that cannot be allocated as inbound addresses.

This patch set is based on Linux-5.1-rc3.

Changes from v5:
  - Addressed Robin Murphy, Lorenzo review comments.
    - Error handling in dma ranges list processing.
    - Used commit messages given by Lorenzo to all patches.

Changes from v4:
  - Addressed Bjorn, Robin Murphy and Auger Eric review comments.
    - Commit message modification.
    - Change DMA_BIT_MASK to "~(dma_addr_t)0".

Changes from v3:
  - Addressed Robin Murphy review comments.
    - pcie-iproc: parse dma-ranges and make sorted resource list.
    - dma-iommu: process list and reserve gaps between entries

Changes from v2:
  - Patch set rebased to Linux-5.0-rc2

Changes from v1:
  - Addressed Oza review comments.

Srinath Mannam (3):
  PCI: Add dma_ranges window list
  iommu/dma: Reserve IOVA for PCIe inaccessible DMA address
  PCI: iproc: Add sorted dma ranges resource entries to host bridge

 drivers/iommu/dma-iommu.c           | 35 ++++++++++++++++++++++++++---
 drivers/pci/controller/pcie-iproc.c | 44 ++++++++++++++++++++++++++++++++++++-
 drivers/pci/probe.c                 |  3 +++
 include/linux/pci.h                 |  1 +
 4 files changed, 79 insertions(+), 4 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v6 1/3] PCI: Add dma_ranges window list
  2019-05-03 14:05 [PATCH v6 0/3] PCIe Host request to reserve IOVA Srinath Mannam
@ 2019-05-03 14:05 ` Srinath Mannam
  2019-05-03 14:05 ` [PATCH v6 2/3] iommu/dma: Reserve IOVA for PCIe inaccessible DMA address Srinath Mannam
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Srinath Mannam @ 2019-05-03 14:05 UTC (permalink / raw)
  To: Bjorn Helgaas, Robin Murphy, Joerg Roedel, Lorenzo Pieralisi,
	Eric Auger, poza, Ray Jui
  Cc: bcm-kernel-feedback-list, linux-pci, iommu, linux-kernel, Srinath Mannam

Add a dma_ranges field in PCI host bridge structure to hold resource
entries list of memory regions in sorted order representing memory
ranges that can be accessed through DMA transactions.

Based-on-patch-by: Oza Pawandeep <oza.oza@broadcom.com>
Signed-off-by: Srinath Mannam <srinath.mannam@broadcom.com>
[lorenzo.pieralisi@arm.com: updated commit log]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Oza Pawandeep <poza@codeaurora.org>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/probe.c | 3 +++
 include/linux/pci.h | 1 +
 2 files changed, 4 insertions(+)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 7e12d01..72563c1 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -595,6 +595,7 @@ struct pci_host_bridge *pci_alloc_host_bridge(size_t priv)
 		return NULL;
 
 	INIT_LIST_HEAD(&bridge->windows);
+	INIT_LIST_HEAD(&bridge->dma_ranges);
 	bridge->dev.release = pci_release_host_bridge_dev;
 
 	/*
@@ -623,6 +624,7 @@ struct pci_host_bridge *devm_pci_alloc_host_bridge(struct device *dev,
 		return NULL;
 
 	INIT_LIST_HEAD(&bridge->windows);
+	INIT_LIST_HEAD(&bridge->dma_ranges);
 	bridge->dev.release = devm_pci_release_host_bridge_dev;
 
 	return bridge;
@@ -632,6 +634,7 @@ EXPORT_SYMBOL(devm_pci_alloc_host_bridge);
 void pci_free_host_bridge(struct pci_host_bridge *bridge)
 {
 	pci_free_resource_list(&bridge->windows);
+	pci_free_resource_list(&bridge->dma_ranges);
 
 	kfree(bridge);
 }
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 7744821..bba0a29 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -490,6 +490,7 @@ struct pci_host_bridge {
 	void		*sysdata;
 	int		busnr;
 	struct list_head windows;	/* resource_entry */
+	struct list_head dma_ranges;	/* dma ranges resource list */
 	u8 (*swizzle_irq)(struct pci_dev *, u8 *); /* Platform IRQ swizzler */
 	int (*map_irq)(const struct pci_dev *, u8, u8);
 	void (*release_fn)(struct pci_host_bridge *);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v6 2/3] iommu/dma: Reserve IOVA for PCIe inaccessible DMA address
  2019-05-03 14:05 [PATCH v6 0/3] PCIe Host request to reserve IOVA Srinath Mannam
  2019-05-03 14:05 ` [PATCH v6 1/3] PCI: Add dma_ranges window list Srinath Mannam
@ 2019-05-03 14:05 ` Srinath Mannam
  2019-05-03 14:05 ` [PATCH v6 3/3] PCI: iproc: Add sorted dma ranges resource entries to host bridge Srinath Mannam
  2019-05-03 15:53 ` [PATCH v6 0/3] PCIe Host request to reserve IOVA Lorenzo Pieralisi
  3 siblings, 0 replies; 9+ messages in thread
From: Srinath Mannam @ 2019-05-03 14:05 UTC (permalink / raw)
  To: Bjorn Helgaas, Robin Murphy, Joerg Roedel, Lorenzo Pieralisi,
	Eric Auger, poza, Ray Jui
  Cc: bcm-kernel-feedback-list, linux-pci, iommu, linux-kernel, Srinath Mannam

The dma_ranges list field of PCI host bridge structure has resource
entries in sorted order representing address ranges allowed for DMA
transfers.

Process the list and reserve IOVA addresses that are not present in its
resource entries (ie DMA memory holes) to prevent allocating IOVA
addresses that cannot be accessed by PCI devices.

Based-on-patch-by: Oza Pawandeep <oza.oza@broadcom.com>
Signed-off-by: Srinath Mannam <srinath.mannam@broadcom.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Oza Pawandeep <poza@codeaurora.org>
Acked-by: Robin Murphy <robin.murphy@arm.com>
---
 drivers/iommu/dma-iommu.c | 35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 77aabe6..954ae11 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -206,12 +206,13 @@ static int cookie_init_hw_msi_region(struct iommu_dma_cookie *cookie,
 	return 0;
 }
 
-static void iova_reserve_pci_windows(struct pci_dev *dev,
+static int iova_reserve_pci_windows(struct pci_dev *dev,
 		struct iova_domain *iovad)
 {
 	struct pci_host_bridge *bridge = pci_find_host_bridge(dev->bus);
 	struct resource_entry *window;
 	unsigned long lo, hi;
+	phys_addr_t start = 0, end;
 
 	resource_list_for_each_entry(window, &bridge->windows) {
 		if (resource_type(window->res) != IORESOURCE_MEM)
@@ -221,6 +222,31 @@ static void iova_reserve_pci_windows(struct pci_dev *dev,
 		hi = iova_pfn(iovad, window->res->end - window->offset);
 		reserve_iova(iovad, lo, hi);
 	}
+
+	/* Get reserved DMA windows from host bridge */
+	resource_list_for_each_entry(window, &bridge->dma_ranges) {
+		end = window->res->start - window->offset;
+resv_iova:
+		if (end > start) {
+			lo = iova_pfn(iovad, start);
+			hi = iova_pfn(iovad, end);
+			reserve_iova(iovad, lo, hi);
+		} else {
+			/* dma_ranges list should be sorted */
+			dev_err(&dev->dev, "Failed to reserve IOVA\n");
+			return -EINVAL;
+		}
+
+		start = window->res->end - window->offset + 1;
+		/* If window is last entry */
+		if (window->node.next == &bridge->dma_ranges &&
+		    end != ~(dma_addr_t)0) {
+			end = ~(dma_addr_t)0;
+			goto resv_iova;
+		}
+	}
+
+	return 0;
 }
 
 static int iova_reserve_iommu_regions(struct device *dev,
@@ -232,8 +258,11 @@ static int iova_reserve_iommu_regions(struct device *dev,
 	LIST_HEAD(resv_regions);
 	int ret = 0;
 
-	if (dev_is_pci(dev))
-		iova_reserve_pci_windows(to_pci_dev(dev), iovad);
+	if (dev_is_pci(dev)) {
+		ret = iova_reserve_pci_windows(to_pci_dev(dev), iovad);
+		if (ret)
+			return ret;
+	}
 
 	iommu_get_resv_regions(dev, &resv_regions);
 	list_for_each_entry(region, &resv_regions, list) {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v6 3/3] PCI: iproc: Add sorted dma ranges resource entries to host bridge
  2019-05-03 14:05 [PATCH v6 0/3] PCIe Host request to reserve IOVA Srinath Mannam
  2019-05-03 14:05 ` [PATCH v6 1/3] PCI: Add dma_ranges window list Srinath Mannam
  2019-05-03 14:05 ` [PATCH v6 2/3] iommu/dma: Reserve IOVA for PCIe inaccessible DMA address Srinath Mannam
@ 2019-05-03 14:05 ` Srinath Mannam
  2019-05-06 21:12   ` Bjorn Helgaas
  2019-05-03 15:53 ` [PATCH v6 0/3] PCIe Host request to reserve IOVA Lorenzo Pieralisi
  3 siblings, 1 reply; 9+ messages in thread
From: Srinath Mannam @ 2019-05-03 14:05 UTC (permalink / raw)
  To: Bjorn Helgaas, Robin Murphy, Joerg Roedel, Lorenzo Pieralisi,
	Eric Auger, poza, Ray Jui
  Cc: bcm-kernel-feedback-list, linux-pci, iommu, linux-kernel, Srinath Mannam

The IPROC host controller allows only a subset of physical address space
as target of inbound PCI memory transactions addresses.

PCIe devices memory transactions targeting memory regions that
are not allowed for inbound transactions in the host controller
are rejected by the host controller and cannot reach the upstream
buses.

Firmware device tree description defines the DMA ranges that are
addressable by devices DMA transactions; parse the device tree
dma-ranges property and add its ranges to the PCI host bridge dma_ranges
list; the iova_reserve_pci_windows() call in the driver will reserve the
IOVA address ranges that are not addressable (ie memory holes in the
dma-ranges set) so that they are not allocated to PCI devices for DMA
transfers.

All allowed address ranges are listed in dma-ranges DT parameter.

Example:

dma-ranges = < \
  0x43000000 0x00 0x80000000 0x00 0x80000000 0x00 0x80000000 \
  0x43000000 0x08 0x00000000 0x08 0x00000000 0x08 0x00000000 \
  0x43000000 0x80 0x00000000 0x80 0x00000000 0x40 0x00000000>

In the above example of dma-ranges, memory address from

0x0 - 0x80000000,
0x100000000 - 0x800000000,
0x1000000000 - 0x8000000000 and
0x10000000000 - 0xffffffffffffffff.

are not allowed to be used as inbound addresses.

Based-on-patch-by: Oza Pawandeep <oza.oza@broadcom.com>
Signed-off-by: Srinath Mannam <srinath.mannam@broadcom.com>
[lorenzo.pieralisi@arm.com: updated commit log]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Oza Pawandeep <poza@codeaurora.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
---
 drivers/pci/controller/pcie-iproc.c | 44 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/controller/pcie-iproc.c b/drivers/pci/controller/pcie-iproc.c
index c20fd6b..94ba5c0 100644
--- a/drivers/pci/controller/pcie-iproc.c
+++ b/drivers/pci/controller/pcie-iproc.c
@@ -1146,11 +1146,43 @@ 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);
 
 	/* Get the dma-ranges from DT */
 	ret = of_pci_dma_range_parser_init(&parser, pcie->dev->of_node);
@@ -1158,13 +1190,23 @@ static int iproc_pcie_map_dma_ranges(struct iproc_pcie *pcie)
 		return ret;
 
 	for_each_of_pci_range(&parser, &range) {
+		ret = iproc_pcie_add_dma_range(pcie->dev,
+					       &resources,
+					       &range);
+		if (ret)
+			goto out;
 		/* Each range entry corresponds to an inbound mapping region */
 		ret = iproc_pcie_setup_ib(pcie, &range, IPROC_PCIE_IB_MAP_MEM);
 		if (ret)
-			return ret;
+			goto out;
 	}
 
+	list_splice_init(&resources, &host->dma_ranges);
+
 	return 0;
+out:
+	pci_free_resource_list(&resources);
+	return ret;
 }
 
 static int iproce_pcie_get_msi(struct iproc_pcie *pcie,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v6 0/3] PCIe Host request to reserve IOVA
  2019-05-03 14:05 [PATCH v6 0/3] PCIe Host request to reserve IOVA Srinath Mannam
                   ` (2 preceding siblings ...)
  2019-05-03 14:05 ` [PATCH v6 3/3] PCI: iproc: Add sorted dma ranges resource entries to host bridge Srinath Mannam
@ 2019-05-03 15:53 ` Lorenzo Pieralisi
  2019-05-03 16:06   ` Srinath Mannam
  3 siblings, 1 reply; 9+ messages in thread
From: Lorenzo Pieralisi @ 2019-05-03 15:53 UTC (permalink / raw)
  To: Srinath Mannam
  Cc: Bjorn Helgaas, Robin Murphy, Joerg Roedel, Eric Auger, poza,
	Ray Jui, bcm-kernel-feedback-list, linux-pci, iommu,
	linux-kernel

On Fri, May 03, 2019 at 07:35:31PM +0530, Srinath Mannam wrote:
> This patch set will reserve IOVA addresses for DMA memory holes.
> 
> The IPROC host controller allows only a few ranges of physical address
> as inbound PCI addresses which are listed through dma-ranges DT property.
> Added dma_ranges list field of PCI host bridge structure to hold these
> allowed inbound address ranges in sorted order.
> 
> Process this list and reserve IOVA addresses that are not present in its
> resource entries (ie DMA memory holes) to prevent allocating IOVA
> addresses that cannot be allocated as inbound addresses.
> 
> This patch set is based on Linux-5.1-rc3.
> 
> Changes from v5:
>   - Addressed Robin Murphy, Lorenzo review comments.
>     - Error handling in dma ranges list processing.
>     - Used commit messages given by Lorenzo to all patches.
> 
> Changes from v4:
>   - Addressed Bjorn, Robin Murphy and Auger Eric review comments.
>     - Commit message modification.
>     - Change DMA_BIT_MASK to "~(dma_addr_t)0".
> 
> Changes from v3:
>   - Addressed Robin Murphy review comments.
>     - pcie-iproc: parse dma-ranges and make sorted resource list.
>     - dma-iommu: process list and reserve gaps between entries
> 
> Changes from v2:
>   - Patch set rebased to Linux-5.0-rc2
> 
> Changes from v1:
>   - Addressed Oza review comments.
> 
> Srinath Mannam (3):
>   PCI: Add dma_ranges window list
>   iommu/dma: Reserve IOVA for PCIe inaccessible DMA address
>   PCI: iproc: Add sorted dma ranges resource entries to host bridge
> 
>  drivers/iommu/dma-iommu.c           | 35 ++++++++++++++++++++++++++---
>  drivers/pci/controller/pcie-iproc.c | 44 ++++++++++++++++++++++++++++++++++++-
>  drivers/pci/probe.c                 |  3 +++
>  include/linux/pci.h                 |  1 +
>  4 files changed, 79 insertions(+), 4 deletions(-)

I have applied the series to pci/iova-dma-ranges, targeting v5.2,
thanks.

Lorenzo

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v6 0/3] PCIe Host request to reserve IOVA
  2019-05-03 15:53 ` [PATCH v6 0/3] PCIe Host request to reserve IOVA Lorenzo Pieralisi
@ 2019-05-03 16:06   ` Srinath Mannam
  0 siblings, 0 replies; 9+ messages in thread
From: Srinath Mannam @ 2019-05-03 16:06 UTC (permalink / raw)
  To: Lorenzo Pieralisi
  Cc: Bjorn Helgaas, Robin Murphy, Joerg Roedel, Eric Auger, poza,
	Ray Jui, BCM Kernel Feedback, linux-pci, iommu,
	Linux Kernel Mailing List

Hi Lorenzo,

Thanks a lot.

Regards,
Srinath.

On Fri, May 3, 2019 at 9:23 PM Lorenzo Pieralisi
<lorenzo.pieralisi@arm.com> wrote:
>
> On Fri, May 03, 2019 at 07:35:31PM +0530, Srinath Mannam wrote:
> > This patch set will reserve IOVA addresses for DMA memory holes.
> >
> > The IPROC host controller allows only a few ranges of physical address
> > as inbound PCI addresses which are listed through dma-ranges DT property.
> > Added dma_ranges list field of PCI host bridge structure to hold these
> > allowed inbound address ranges in sorted order.
> >
> > Process this list and reserve IOVA addresses that are not present in its
> > resource entries (ie DMA memory holes) to prevent allocating IOVA
> > addresses that cannot be allocated as inbound addresses.
> >
> > This patch set is based on Linux-5.1-rc3.
> >
> > Changes from v5:
> >   - Addressed Robin Murphy, Lorenzo review comments.
> >     - Error handling in dma ranges list processing.
> >     - Used commit messages given by Lorenzo to all patches.
> >
> > Changes from v4:
> >   - Addressed Bjorn, Robin Murphy and Auger Eric review comments.
> >     - Commit message modification.
> >     - Change DMA_BIT_MASK to "~(dma_addr_t)0".
> >
> > Changes from v3:
> >   - Addressed Robin Murphy review comments.
> >     - pcie-iproc: parse dma-ranges and make sorted resource list.
> >     - dma-iommu: process list and reserve gaps between entries
> >
> > Changes from v2:
> >   - Patch set rebased to Linux-5.0-rc2
> >
> > Changes from v1:
> >   - Addressed Oza review comments.
> >
> > Srinath Mannam (3):
> >   PCI: Add dma_ranges window list
> >   iommu/dma: Reserve IOVA for PCIe inaccessible DMA address
> >   PCI: iproc: Add sorted dma ranges resource entries to host bridge
> >
> >  drivers/iommu/dma-iommu.c           | 35 ++++++++++++++++++++++++++---
> >  drivers/pci/controller/pcie-iproc.c | 44 ++++++++++++++++++++++++++++++++++++-
> >  drivers/pci/probe.c                 |  3 +++
> >  include/linux/pci.h                 |  1 +
> >  4 files changed, 79 insertions(+), 4 deletions(-)
>
> I have applied the series to pci/iova-dma-ranges, targeting v5.2,
> thanks.
>
> Lorenzo

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v6 3/3] PCI: iproc: Add sorted dma ranges resource entries to host bridge
  2019-05-03 14:05 ` [PATCH v6 3/3] PCI: iproc: Add sorted dma ranges resource entries to host bridge Srinath Mannam
@ 2019-05-06 21:12   ` Bjorn Helgaas
  2019-05-07  9:41     ` Lorenzo Pieralisi
  0 siblings, 1 reply; 9+ messages in thread
From: Bjorn Helgaas @ 2019-05-06 21:12 UTC (permalink / raw)
  To: Srinath Mannam
  Cc: Robin Murphy, Joerg Roedel, Lorenzo Pieralisi, Eric Auger, poza,
	Ray Jui, bcm-kernel-feedback-list, linux-pci, iommu,
	linux-kernel

On Fri, May 03, 2019 at 07:35:34PM +0530, Srinath Mannam wrote:
> The IPROC host controller allows only a subset of physical address space
> as target of inbound PCI memory transactions addresses.
> 
> PCIe devices memory transactions targeting memory regions that
> are not allowed for inbound transactions in the host controller
> are rejected by the host controller and cannot reach the upstream
> buses.
> 
> Firmware device tree description defines the DMA ranges that are
> addressable by devices DMA transactions; parse the device tree
> dma-ranges property and add its ranges to the PCI host bridge dma_ranges
> list; the iova_reserve_pci_windows() call in the driver will reserve the
> IOVA address ranges that are not addressable (ie memory holes in the
> dma-ranges set) so that they are not allocated to PCI devices for DMA
> transfers.
> 
> All allowed address ranges are listed in dma-ranges DT parameter.
> 
> Example:
> 
> dma-ranges = < \
>   0x43000000 0x00 0x80000000 0x00 0x80000000 0x00 0x80000000 \
>   0x43000000 0x08 0x00000000 0x08 0x00000000 0x08 0x00000000 \
>   0x43000000 0x80 0x00000000 0x80 0x00000000 0x40 0x00000000>
> 
> In the above example of dma-ranges, memory address from
> 
> 0x0 - 0x80000000,
> 0x100000000 - 0x800000000,
> 0x1000000000 - 0x8000000000 and
> 0x10000000000 - 0xffffffffffffffff.
> 
> are not allowed to be used as inbound addresses.
> 
> Based-on-patch-by: Oza Pawandeep <oza.oza@broadcom.com>
> Signed-off-by: Srinath Mannam <srinath.mannam@broadcom.com>
> [lorenzo.pieralisi@arm.com: updated commit log]
> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Reviewed-by: Oza Pawandeep <poza@codeaurora.org>
> Reviewed-by: Eric Auger <eric.auger@redhat.com>
> ---
>  drivers/pci/controller/pcie-iproc.c | 44 ++++++++++++++++++++++++++++++++++++-
>  1 file changed, 43 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/controller/pcie-iproc.c b/drivers/pci/controller/pcie-iproc.c
> index c20fd6b..94ba5c0 100644
> --- a/drivers/pci/controller/pcie-iproc.c
> +++ b/drivers/pci/controller/pcie-iproc.c
> @@ -1146,11 +1146,43 @@ 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)

Just FYI, I cherry-picked these commits from Lorenzo's branch to fix
the formatting of this prototype to match the rest of the file, e.g.:

>  static int iproc_pcie_map_dma_ranges(struct iproc_pcie *pcie)
> ...
>  static int iproce_pcie_get_msi(struct iproc_pcie *pcie,

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v6 3/3] PCI: iproc: Add sorted dma ranges resource entries to host bridge
  2019-05-06 21:12   ` Bjorn Helgaas
@ 2019-05-07  9:41     ` Lorenzo Pieralisi
  2019-05-07  9:55       ` Srinath Mannam
  0 siblings, 1 reply; 9+ messages in thread
From: Lorenzo Pieralisi @ 2019-05-07  9:41 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Srinath Mannam, Robin Murphy, Joerg Roedel, Eric Auger, poza,
	Ray Jui, bcm-kernel-feedback-list, linux-pci, iommu,
	linux-kernel

On Mon, May 06, 2019 at 04:12:08PM -0500, Bjorn Helgaas wrote:
> On Fri, May 03, 2019 at 07:35:34PM +0530, Srinath Mannam wrote:
> > The IPROC host controller allows only a subset of physical address space
> > as target of inbound PCI memory transactions addresses.
> > 
> > PCIe devices memory transactions targeting memory regions that
> > are not allowed for inbound transactions in the host controller
> > are rejected by the host controller and cannot reach the upstream
> > buses.
> > 
> > Firmware device tree description defines the DMA ranges that are
> > addressable by devices DMA transactions; parse the device tree
> > dma-ranges property and add its ranges to the PCI host bridge dma_ranges
> > list; the iova_reserve_pci_windows() call in the driver will reserve the
> > IOVA address ranges that are not addressable (ie memory holes in the
> > dma-ranges set) so that they are not allocated to PCI devices for DMA
> > transfers.
> > 
> > All allowed address ranges are listed in dma-ranges DT parameter.
> > 
> > Example:
> > 
> > dma-ranges = < \
> >   0x43000000 0x00 0x80000000 0x00 0x80000000 0x00 0x80000000 \
> >   0x43000000 0x08 0x00000000 0x08 0x00000000 0x08 0x00000000 \
> >   0x43000000 0x80 0x00000000 0x80 0x00000000 0x40 0x00000000>
> > 
> > In the above example of dma-ranges, memory address from
> > 
> > 0x0 - 0x80000000,
> > 0x100000000 - 0x800000000,
> > 0x1000000000 - 0x8000000000 and
> > 0x10000000000 - 0xffffffffffffffff.
> > 
> > are not allowed to be used as inbound addresses.
> > 
> > Based-on-patch-by: Oza Pawandeep <oza.oza@broadcom.com>
> > Signed-off-by: Srinath Mannam <srinath.mannam@broadcom.com>
> > [lorenzo.pieralisi@arm.com: updated commit log]
> > Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> > Reviewed-by: Oza Pawandeep <poza@codeaurora.org>
> > Reviewed-by: Eric Auger <eric.auger@redhat.com>
> > ---
> >  drivers/pci/controller/pcie-iproc.c | 44 ++++++++++++++++++++++++++++++++++++-
> >  1 file changed, 43 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/pci/controller/pcie-iproc.c b/drivers/pci/controller/pcie-iproc.c
> > index c20fd6b..94ba5c0 100644
> > --- a/drivers/pci/controller/pcie-iproc.c
> > +++ b/drivers/pci/controller/pcie-iproc.c
> > @@ -1146,11 +1146,43 @@ 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)
> 
> Just FYI, I cherry-picked these commits from Lorenzo's branch to fix
> the formatting of this prototype to match the rest of the file, e.g.:

Thank you, I noticed too but I forgot to update it before merging
v6 from the list.

Thanks,
Lorenzo

> >  static int iproc_pcie_map_dma_ranges(struct iproc_pcie *pcie)
> > ...
> >  static int iproce_pcie_get_msi(struct iproc_pcie *pcie,

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v6 3/3] PCI: iproc: Add sorted dma ranges resource entries to host bridge
  2019-05-07  9:41     ` Lorenzo Pieralisi
@ 2019-05-07  9:55       ` Srinath Mannam
  0 siblings, 0 replies; 9+ messages in thread
From: Srinath Mannam @ 2019-05-07  9:55 UTC (permalink / raw)
  To: Lorenzo Pieralisi
  Cc: Bjorn Helgaas, Robin Murphy, Joerg Roedel, Eric Auger, poza,
	Ray Jui, BCM Kernel Feedback, linux-pci, iommu,
	Linux Kernel Mailing List

Hi Bjorn,

Thank you.

Regards,
Srinath.

On Tue, May 7, 2019 at 3:11 PM Lorenzo Pieralisi
<lorenzo.pieralisi@arm.com> wrote:
>
> On Mon, May 06, 2019 at 04:12:08PM -0500, Bjorn Helgaas wrote:
> > On Fri, May 03, 2019 at 07:35:34PM +0530, Srinath Mannam wrote:
> > > The IPROC host controller allows only a subset of physical address space
> > > as target of inbound PCI memory transactions addresses.
> > >
> > > PCIe devices memory transactions targeting memory regions that
> > > are not allowed for inbound transactions in the host controller
> > > are rejected by the host controller and cannot reach the upstream
> > > buses.
> > >
> > > Firmware device tree description defines the DMA ranges that are
> > > addressable by devices DMA transactions; parse the device tree
> > > dma-ranges property and add its ranges to the PCI host bridge dma_ranges
> > > list; the iova_reserve_pci_windows() call in the driver will reserve the
> > > IOVA address ranges that are not addressable (ie memory holes in the
> > > dma-ranges set) so that they are not allocated to PCI devices for DMA
> > > transfers.
> > >
> > > All allowed address ranges are listed in dma-ranges DT parameter.
> > >
> > > Example:
> > >
> > > dma-ranges = < \
> > >   0x43000000 0x00 0x80000000 0x00 0x80000000 0x00 0x80000000 \
> > >   0x43000000 0x08 0x00000000 0x08 0x00000000 0x08 0x00000000 \
> > >   0x43000000 0x80 0x00000000 0x80 0x00000000 0x40 0x00000000>
> > >
> > > In the above example of dma-ranges, memory address from
> > >
> > > 0x0 - 0x80000000,
> > > 0x100000000 - 0x800000000,
> > > 0x1000000000 - 0x8000000000 and
> > > 0x10000000000 - 0xffffffffffffffff.
> > >
> > > are not allowed to be used as inbound addresses.
> > >
> > > Based-on-patch-by: Oza Pawandeep <oza.oza@broadcom.com>
> > > Signed-off-by: Srinath Mannam <srinath.mannam@broadcom.com>
> > > [lorenzo.pieralisi@arm.com: updated commit log]
> > > Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> > > Reviewed-by: Oza Pawandeep <poza@codeaurora.org>
> > > Reviewed-by: Eric Auger <eric.auger@redhat.com>
> > > ---
> > >  drivers/pci/controller/pcie-iproc.c | 44 ++++++++++++++++++++++++++++++++++++-
> > >  1 file changed, 43 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/pci/controller/pcie-iproc.c b/drivers/pci/controller/pcie-iproc.c
> > > index c20fd6b..94ba5c0 100644
> > > --- a/drivers/pci/controller/pcie-iproc.c
> > > +++ b/drivers/pci/controller/pcie-iproc.c
> > > @@ -1146,11 +1146,43 @@ 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)
> >
> > Just FYI, I cherry-picked these commits from Lorenzo's branch to fix
> > the formatting of this prototype to match the rest of the file, e.g.:
>
> Thank you, I noticed too but I forgot to update it before merging
> v6 from the list.
>
> Thanks,
> Lorenzo
>
> > >  static int iproc_pcie_map_dma_ranges(struct iproc_pcie *pcie)
> > > ...
> > >  static int iproce_pcie_get_msi(struct iproc_pcie *pcie,

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-05-07  9:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-03 14:05 [PATCH v6 0/3] PCIe Host request to reserve IOVA Srinath Mannam
2019-05-03 14:05 ` [PATCH v6 1/3] PCI: Add dma_ranges window list Srinath Mannam
2019-05-03 14:05 ` [PATCH v6 2/3] iommu/dma: Reserve IOVA for PCIe inaccessible DMA address Srinath Mannam
2019-05-03 14:05 ` [PATCH v6 3/3] PCI: iproc: Add sorted dma ranges resource entries to host bridge Srinath Mannam
2019-05-06 21:12   ` Bjorn Helgaas
2019-05-07  9:41     ` Lorenzo Pieralisi
2019-05-07  9:55       ` Srinath Mannam
2019-05-03 15:53 ` [PATCH v6 0/3] PCIe Host request to reserve IOVA Lorenzo Pieralisi
2019-05-03 16:06   ` Srinath Mannam

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).