From: Ashish Mhetre <amhetre@nvidia.com>
To: <vdumpa@nvidia.com>, <treding@nvidia.com>, <jonathanh@nvidia.com>,
<swarren@nvidia.com>, <Snikam@nvidia.com>
Cc: <SW-Mobile-Linux-Upstreaming@exchange.nvidia.com>,
<SW-Mobile-Memory-Core@exchange.nvidia.com>,
<linux-tegra@vger.kernel.org>, Ashish Mhetre <amhetre@nvidia.com>
Subject: [PATCH] iommu/dma: Add support for mapping memory as device memory
Date: Tue, 4 Aug 2020 13:22:38 +0530 [thread overview]
Message-ID: <1596527558-22566-1-git-send-email-amhetre@nvidia.com> (raw)
Add DMA_ATTRS_DEVICE_MAP attribute to support mapping memory as device
memory.
Signed-off-by: Ashish Mhetre <amhetre@nvidia.com>
---
drivers/iommu/dma-iommu.c | 3 +++
include/linux/dma-mapping.h | 6 ++++++
2 files changed, 9 insertions(+)
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 65ac889..0e411ef 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -388,6 +388,9 @@ static int dma_info_to_prot(enum dma_data_direction dir, bool coherent,
if (attrs & DMA_ATTR_PRIVILEGED)
prot |= IOMMU_PRIV;
+ if (attrs & DMA_ATTR_DEVICE_MAP)
+ prot |= IOMMU_MMIO;
+
switch (dir) {
case DMA_BIDIRECTIONAL:
return prot | IOMMU_READ | IOMMU_WRITE;
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 330ad58..b0cb1b3 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -68,6 +68,12 @@
#define DMA_ATTR_PRIVILEGED (1UL << 9)
/*
+ * DMA_ATTR_DEVICE_MAP: This specifies DMA-mapping subsystem to map memory
+ * as device memory.
+ */
+#define DMA_ATTR_DEVICE_MAP (1UL << 10)
+
+/*
* A dma_addr_t can hold any valid DMA or bus address for the platform.
* It can be given to a device to use as a DMA source or target. A CPU cannot
* reference a dma_addr_t directly because there may be translation between
--
2.7.4
next reply other threads:[~2020-08-04 7:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-04 7:52 Ashish Mhetre [this message]
2020-08-04 8:56 ` [PATCH] iommu/dma: Add support for mapping memory as device memory Mikko Perttunen
2020-08-04 16:47 ` Krishna Reddy
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=1596527558-22566-1-git-send-email-amhetre@nvidia.com \
--to=amhetre@nvidia.com \
--cc=SW-Mobile-Linux-Upstreaming@exchange.nvidia.com \
--cc=SW-Mobile-Memory-Core@exchange.nvidia.com \
--cc=Snikam@nvidia.com \
--cc=jonathanh@nvidia.com \
--cc=linux-tegra@vger.kernel.org \
--cc=swarren@nvidia.com \
--cc=treding@nvidia.com \
--cc=vdumpa@nvidia.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).