iommu: msm: Allow passing dma_attrs for lazy mapping

The msm lazy mapping APIs did not allow to pass in
dma attributes that could be passed to the dma-mapping
driver. This patch allows users to specify dma attributes for the
msm lazy mappings.

Change-Id: I3e4cd2bb99d205dce78083a256f4d444d865f3cc
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
This commit is contained in:
Rohit Vaswani 2015-07-06 16:27:43 -07:00 committed by David Keitel
parent 0244adb5c7
commit 2a9e5873f3
2 changed files with 13 additions and 13 deletions

View file

@ -156,13 +156,14 @@ static void msm_iommu_meta_put(struct msm_iommu_meta *meta);
static inline int __msm_dma_map_sg(struct device *dev, struct scatterlist *sg, static inline int __msm_dma_map_sg(struct device *dev, struct scatterlist *sg,
int nents, enum dma_data_direction dir, int nents, enum dma_data_direction dir,
struct dma_buf *dma_buf, int flags) struct dma_buf *dma_buf,
struct dma_attrs *attrs)
{ {
struct msm_iommu_map *iommu_map; struct msm_iommu_map *iommu_map;
struct msm_iommu_meta *iommu_meta = NULL; struct msm_iommu_meta *iommu_meta = NULL;
int ret = 0; int ret = 0;
bool extra_meta_ref_taken = false; bool extra_meta_ref_taken = false;
bool late_unmap = (flags & MSM_DMA_ATTR_NO_DELAYED_UNMAP) == 0; int late_unmap = !dma_get_attr(DMA_ATTR_NO_DELAYED_UNMAP, attrs);
mutex_lock(&msm_iommu_map_mutex); mutex_lock(&msm_iommu_map_mutex);
iommu_meta = msm_iommu_meta_lookup(dma_buf->priv); iommu_meta = msm_iommu_meta_lookup(dma_buf->priv);
@ -195,7 +196,7 @@ static inline int __msm_dma_map_sg(struct device *dev, struct scatterlist *sg,
goto out_unlock; goto out_unlock;
} }
ret = dma_map_sg(dev, sg, nents, dir); ret = dma_map_sg_attrs(dev, sg, nents, dir, attrs);
if (ret != nents) { if (ret != nents) {
kfree(iommu_map); kfree(iommu_map);
goto out_unlock; goto out_unlock;
@ -243,7 +244,7 @@ out:
*/ */
int msm_dma_map_sg_attrs(struct device *dev, struct scatterlist *sg, int nents, int msm_dma_map_sg_attrs(struct device *dev, struct scatterlist *sg, int nents,
enum dma_data_direction dir, struct dma_buf *dma_buf, enum dma_data_direction dir, struct dma_buf *dma_buf,
int flags) struct dma_attrs *attrs)
{ {
int ret; int ret;
@ -262,7 +263,7 @@ int msm_dma_map_sg_attrs(struct device *dev, struct scatterlist *sg, int nents,
return -EINVAL; return -EINVAL;
} }
ret = __msm_dma_map_sg(dev, sg, nents, dir, dma_buf, flags); ret = __msm_dma_map_sg(dev, sg, nents, dir, dma_buf, attrs);
return ret; return ret;
} }

View file

@ -18,10 +18,6 @@
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
enum msm_dma_map_attr {
MSM_DMA_ATTR_NO_DELAYED_UNMAP = 0x1,
};
#ifdef CONFIG_IOMMU_API #ifdef CONFIG_IOMMU_API
/* /*
* This function is not taking a reference to the dma_buf here. It is expected * This function is not taking a reference to the dma_buf here. It is expected
@ -30,22 +26,25 @@ enum msm_dma_map_attr {
*/ */
int msm_dma_map_sg_attrs(struct device *dev, struct scatterlist *sg, int nents, int msm_dma_map_sg_attrs(struct device *dev, struct scatterlist *sg, int nents,
enum dma_data_direction dir, struct dma_buf *dma_buf, enum dma_data_direction dir, struct dma_buf *dma_buf,
int flags); struct dma_attrs *attrs);
static inline int msm_dma_map_sg_lazy(struct device *dev, static inline int msm_dma_map_sg_lazy(struct device *dev,
struct scatterlist *sg, int nents, struct scatterlist *sg, int nents,
enum dma_data_direction dir, enum dma_data_direction dir,
struct dma_buf *dma_buf) struct dma_buf *dma_buf)
{ {
return msm_dma_map_sg_attrs(dev, sg, nents, dir, dma_buf, 0); return msm_dma_map_sg_attrs(dev, sg, nents, dir, dma_buf, NULL);
} }
static inline int msm_dma_map_sg(struct device *dev, struct scatterlist *sg, static inline int msm_dma_map_sg(struct device *dev, struct scatterlist *sg,
int nents, enum dma_data_direction dir, int nents, enum dma_data_direction dir,
struct dma_buf *dma_buf) struct dma_buf *dma_buf)
{ {
return msm_dma_map_sg_attrs(dev, sg, nents, dir, dma_buf, DEFINE_DMA_ATTRS(attrs);
MSM_DMA_ATTR_NO_DELAYED_UNMAP);
init_dma_attrs(&attrs);
dma_set_attr(DMA_ATTR_NO_DELAYED_UNMAP, &attrs);
return msm_dma_map_sg_attrs(dev, sg, nents, dir, dma_buf, &attrs);
} }
void msm_dma_unmap_sg(struct device *dev, struct scatterlist *sgl, int nents, void msm_dma_unmap_sg(struct device *dev, struct scatterlist *sgl, int nents,