From: labbott@redhat.com (Laura Abbott)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC][PATCH 3/3] staging: ion: Add dma_map/dma_unmap calls to dma_buf calls
Date: Wed, 25 May 2016 12:48:04 -0700 [thread overview]
Message-ID: <1464205684-5587-4-git-send-email-labbott@redhat.com> (raw)
In-Reply-To: <1464205684-5587-1-git-send-email-labbott@redhat.com>
The .map_dma_buf/.unmap_dma_buf function calls are designed for buffer
users to perform DMA accesses. Ion doesn't call into the lower DMA
layer currently. This may leave mapping incomplete for devices with
more complex topologies (e.g. IOMMUs). Add the appropriate dma_map
calls to the dma_buf call backs.
Signed-off-by: Laura Abbott <labbott@redhat.com>
---
drivers/staging/android/ion/ion.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index 2096592..52dbea4 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -980,7 +980,18 @@ static struct sg_table *ion_map_dma_buf(struct dma_buf_attachment *attachment,
struct dma_buf *dmabuf = attachment->dmabuf;
struct ion_buffer *buffer = dmabuf->priv;
+ /* Necessary but not sufficient: This is for userspace */
ion_buffer_sync_for_device(buffer, attachment->dev, direction);
+
+ /* The rest of this is for the standard mappings */
+ buffer->sg_table->nents = dma_map_sg(attachment->dev,
+ buffer->sg_table->sgl,
+ buffer->sg_table->orig_nents,
+ direction);
+
+ if (!buffer->sg_table->nents)
+ return ERR_PTR(-EIO);
+
return buffer->sg_table;
}
@@ -988,6 +999,7 @@ static void ion_unmap_dma_buf(struct dma_buf_attachment *attachment,
struct sg_table *table,
enum dma_data_direction direction)
{
+ dma_unmap_sg(attachment->dev, table->sgl, table->nents, direction);
}
static int ion_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
--
2.5.5
prev parent reply other threads:[~2016-05-25 19:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-25 19:48 [RFC][PATCH 0/3] Clean up Ion mapping/caching Laura Abbott
2016-05-25 19:48 ` [RFC][PATCH 1/3] staging: ion: Move away from the DMA APIs for cache flushing Laura Abbott
2016-05-26 9:58 ` Liviu Dudau
2016-05-26 10:59 ` Russell King - ARM Linux
2016-05-26 12:06 ` Christoph Hellwig
2016-06-03 1:57 ` [Linaro-mm-sig] " Li, Xiaoquan
2016-05-25 19:48 ` [RFC][PATCH 2/3] staging: ion: Add support for syncing with DMA_BUF_IOCTL_SYNC Laura Abbott
2016-05-25 19:48 ` Laura Abbott [this message]
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=1464205684-5587-4-git-send-email-labbott@redhat.com \
--to=labbott@redhat.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).