summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorOlav Haugan <ohaugan@codeaurora.org>2015-05-28 17:21:45 -0700
committerDavid Keitel <dkeitel@codeaurora.org>2016-03-22 11:04:34 -0700
commit87e6f73b2945cdf049819a8485ef424551513f06 (patch)
tree8b4f602947af5d3eae59690c7e42cc9ed332f76f /include/linux
parent910d8c50d288554e544df49c84e5e8e0e8588eb9 (diff)
iommu: Add support for delayed unmapping of ion/dma_buf buffer
Add new APIs to allow clients to map and unmap dma_buffers created by ION. The call to the unmap API will not actually do the unmapping from the IOMMU. The unmapping will occur when the ION/dma_buf buffer is actually freed. This behavior can be disabled with DMA_ATTR_NO_DELAYED_UNMAP Change-Id: Ic4dbd3b582eb0388020c650cab5fbb1dad67ae81 Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/msm_dma_iommu_mapping.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/include/linux/msm_dma_iommu_mapping.h b/include/linux/msm_dma_iommu_mapping.h
new file mode 100644
index 000000000000..a185578915df
--- /dev/null
+++ b/include/linux/msm_dma_iommu_mapping.h
@@ -0,0 +1,61 @@
+/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _LINUX_MSM_DMA_IOMMU_MAPPING_H
+#define _LINUX_MSM_DMA_IOMMU_MAPPING_H
+
+#include <linux/device.h>
+#include <linux/dma-buf.h>
+#include <linux/scatterlist.h>
+#include <linux/dma-mapping.h>
+
+enum msm_dma_map_attr {
+ MSM_DMA_ATTR_NO_DELAYED_UNMAP = 0x1,
+};
+
+/*
+* This function is not taking a reference to the dma_buf here. It is expected
+* that clients hold reference to the dma_buf until they are done with mapping
+* and unmapping.
+*/
+int msm_dma_map_sg_attrs(struct device *dev, struct scatterlist *sg, int nents,
+ enum dma_data_direction dir, struct dma_buf *dma_buf,
+ int flags);
+
+static inline int msm_dma_map_sg_lazy(struct device *dev,
+ struct scatterlist *sg, int nents,
+ enum dma_data_direction dir,
+ struct dma_buf *dma_buf)
+{
+ return msm_dma_map_sg_attrs(dev, sg, nents, dir, dma_buf, 0);
+}
+
+static inline int msm_dma_map_sg(struct device *dev, struct scatterlist *sg,
+ int nents, enum dma_data_direction dir,
+ struct dma_buf *dma_buf)
+{
+ return msm_dma_map_sg_attrs(dev, sg, nents, dir, dma_buf,
+ MSM_DMA_ATTR_NO_DELAYED_UNMAP);
+}
+
+void msm_dma_unmap_sg(struct device *dev, struct scatterlist *sgl, int nents,
+ enum dma_data_direction dir, struct dma_buf *dma_buf);
+
+
+/*
+ * Below is private function only to be called by framework (ION) and not by
+ * clients.
+ */
+
+void msm_dma_buf_freed(void *buffer);
+
+#endif