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:
parent
0244adb5c7
commit
2a9e5873f3
2 changed files with 13 additions and 13 deletions
|
@ -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,
|
||||
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_meta *iommu_meta = NULL;
|
||||
int ret = 0;
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
ret = dma_map_sg(dev, sg, nents, dir);
|
||||
ret = dma_map_sg_attrs(dev, sg, nents, dir, attrs);
|
||||
if (ret != nents) {
|
||||
kfree(iommu_map);
|
||||
goto out_unlock;
|
||||
|
@ -243,7 +244,7 @@ out:
|
|||
*/
|
||||
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)
|
||||
struct dma_attrs *attrs)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
@ -262,7 +263,7 @@ int msm_dma_map_sg_attrs(struct device *dev, struct scatterlist *sg, int nents,
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -18,10 +18,6 @@
|
|||
#include <linux/scatterlist.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
|
||||
enum msm_dma_map_attr {
|
||||
MSM_DMA_ATTR_NO_DELAYED_UNMAP = 0x1,
|
||||
};
|
||||
|
||||
#ifdef CONFIG_IOMMU_API
|
||||
/*
|
||||
* 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,
|
||||
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,
|
||||
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);
|
||||
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,
|
||||
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);
|
||||
DEFINE_DMA_ATTRS(attrs);
|
||||
|
||||
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,
|
||||
|
|
Loading…
Add table
Reference in a new issue