Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 56c4ebea authored by Rohit Vaswani's avatar Rohit Vaswani Committed by Sathish Ambley
Browse files

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: default avatarRohit Vaswani <rvaswani@codeaurora.org>
parent 7a85a302
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -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;
}
+7 −8
Original line number Diff line number Diff line
@@ -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,