linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: robin.murphy@arm.com (Robin Murphy)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 5/7] iommu/dma: Respect bus DMA limit for IOVAs
Date: Mon, 23 Jul 2018 23:16:10 +0100	[thread overview]
Message-ID: <d370670edae9c9c537a5280c5e7c96bf3ec7ed8f.1532382222.git.robin.murphy@arm.com> (raw)
In-Reply-To: <cover.1532382222.git.robin.murphy@arm.com>

Take the new bus limit into account (when present) for IOVA allocations,
to accommodate those SoCs which integrate off-the-shelf IP blocks with
narrower interconnects such that the link between a device output and an
IOMMU input can truncate DMA addresses to even fewer bits than the
native size of either block's interface would imply.

Eventually it might make sense for the DMA core to apply this constraint
up-front in dma_set_mask() and friends, but for now this seems like the
least risky approach.

CC: Joerg Roedel <joro@8bytes.org>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---

Bonus question: Now that we're collecing DMA API code in kernel/dma/
do we want to reevaluate dma-iommu? On the one hand it's the bulk of a
dma_ops implementation so should perhaps move, but on the other it's
entirely IOMMU-specific code so should perhaps stay where it is... :/

 drivers/iommu/dma-iommu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index ddcbbdb5d658..511ff9a1d6d9 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -367,6 +367,9 @@ static dma_addr_t iommu_dma_alloc_iova(struct iommu_domain *domain,
 	if (iova_len < (1 << (IOVA_RANGE_CACHE_MAX_SIZE - 1)))
 		iova_len = roundup_pow_of_two(iova_len);
 
+	if (dev->bus_dma_mask)
+		dma_limit &= dev->bus_dma_mask;
+
 	if (domain->geometry.force_aperture)
 		dma_limit = min(dma_limit, domain->geometry.aperture_end);
 
-- 
2.17.1.dirty

  parent reply	other threads:[~2018-07-23 22:16 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-23 22:16 [PATCH v2 0/7] Stop losing firmware-set DMA masks Robin Murphy
2018-07-23 22:16 ` [PATCH v2 1/7] ACPI/IORT: Support address size limit for root complexes Robin Murphy
2018-07-23 22:16 ` [PATCH v2 2/7] dma-mapping: Generalise dma_32bit_limit flag Robin Murphy
2018-07-25 11:29   ` Christoph Hellwig
2018-07-27 17:45   ` Grygorii Strashko
2018-07-27 20:11     ` Robin Murphy
2018-07-27 20:41       ` Grygorii Strashko
2018-07-23 22:16 ` [PATCH v2 3/7] ACPI/IORT: Set bus DMA mask as appropriate Robin Murphy
2018-07-25 11:29   ` Christoph Hellwig
2018-07-25 13:16   ` Lorenzo Pieralisi
2018-07-23 22:16 ` [PATCH v2 4/7] of/device: " Robin Murphy
2018-07-25 11:30   ` Christoph Hellwig
2018-07-23 22:16 ` Robin Murphy [this message]
2018-07-26  8:58   ` [PATCH v2 5/7] iommu/dma: Respect bus DMA limit for IOVAs Christoph Hellwig
2018-07-23 22:16 ` [PATCH v2 6/7] ACPI/IORT: Don't set default coherent DMA mask Robin Murphy
2018-07-25 15:27   ` Lorenzo Pieralisi
2018-07-25 15:43     ` Robin Murphy
2018-07-23 22:16 ` [PATCH v2 7/7] OF: " Robin Murphy
2018-07-26 23:52   ` Grygorii Strashko
2018-07-27  0:22     ` Grygorii Strashko
2018-07-27 11:36       ` Robin Murphy
2018-07-27 17:34         ` Grygorii Strashko
2018-07-27 19:46           ` Robin Murphy
2018-07-27 18:13         ` Russell King - ARM Linux
2018-07-27 18:45           ` Grygorii Strashko
2018-07-27 20:42             ` Robin Murphy
2018-07-27 19:29           ` Robin Murphy
2018-07-25 11:31 ` [PATCH v2 0/7] Stop losing firmware-set DMA masks Christoph Hellwig
2018-07-25 12:11   ` Joerg Roedel
2018-07-25 12:12   ` Robin Murphy
2018-07-25 12:17     ` Will Deacon
2018-07-25 13:58   ` Ard Biesheuvel
2018-07-26  9:00 ` Christoph Hellwig
2018-07-26 23:45 ` Grygorii Strashko
2018-07-27 10:55   ` Robin Murphy
2018-07-27 17:22     ` Grygorii Strashko
2018-07-29 12:32 ` Arnd Bergmann
2018-07-31 11:24   ` Robin Murphy
2018-08-06 10:01     ` Arnd Bergmann
2018-08-06 12:13       ` Christoph Hellwig
2018-08-06 12:13         ` Arnd Bergmann

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=d370670edae9c9c537a5280c5e7c96bf3ec7ed8f.1532382222.git.robin.murphy@arm.com \
    --to=robin.murphy@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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).