From: Nate Watterson <nwatters@codeaurora.org>
To: robin.murphy@arm.com, Joerg Roedel <joro@8bytes.org>,
iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org
Cc: shankerd@codeaurora.org, Nate Watterson <nwatters@codeaurora.org>
Subject: [PATCH] iommu/dma: Setup iova_domain granule for IOMMU_DMA_MSI cookies
Date: Thu, 13 Apr 2017 04:55:15 -0400 [thread overview]
Message-ID: <1492073715-7811-1-git-send-email-nwatters@codeaurora.org> (raw)
Currently, the __iommu_dma_{map/free} functions call iova_{offset/align}
making them unsuitable for use with iommu_domains having an IOMMU_DMA_MSI
cookie since the cookie's iova_domain member, iovad, is uninitialized.
Now that iommu_dma_get_msi_page() calls __iommu_dma_map() regardless
of cookie type, failures are being seen when mapping MSI target
addresses for devices attached to UNMANAGED domains. To work around
this issue, the iova_domain granule for IOMMU_DMA_MSI cookies is
initialized to the value returned by cookie_msi_granule().
Fixes: a44e6657585b ("iommu/dma: Clean up MSI IOVA allocation")
Signed-off-by: Nate Watterson <nwatters@codeaurora.org>
---
drivers/iommu/dma-iommu.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 8348f366..d7b0816 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -127,6 +127,16 @@ int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base)
cookie->msi_iova = base;
domain->iova_cookie = cookie;
+
+ /*
+ * Setup granule for compatibility with __iommu_dma_{alloc/free} and
+ * add a compile time check to ensure that writing granule won't
+ * clobber msi_iova.
+ */
+ cookie->iovad.granule = cookie_msi_granule(cookie);
+ BUILD_BUG_ON(offsetof(struct iova_domain, granule) <
+ sizeof(cookie->msi_iova));
+
return 0;
}
EXPORT_SYMBOL(iommu_get_msi_cookie);
--
Qualcomm Datacenter Technologies, Inc. on behalf of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux
Foundation Collaborative Project.
next reply other threads:[~2017-04-13 8:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-13 8:55 Nate Watterson [this message]
2017-04-13 11:21 ` [PATCH] iommu/dma: Setup iova_domain granule for IOMMU_DMA_MSI cookies Robin Murphy
2017-04-13 14:29 ` Shanker Donthineni
2017-05-04 13:32 ` Bharat Bhushan
2017-04-13 19:38 ` Nate Watterson
2017-05-16 19:55 ` Auger Eric
2017-05-16 20:07 ` Nate Watterson
2017-05-16 20:20 ` Auger Eric
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=1492073715-7811-1-git-send-email-nwatters@codeaurora.org \
--to=nwatters@codeaurora.org \
--cc=iommu@lists.linux-foundation.org \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=shankerd@codeaurora.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).