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

Commit 2e9a2a91 authored by Abhijith Desai's avatar Abhijith Desai
Browse files

msm: mdss: Update smmu map/unmap and buffer length calculations



Update the buffer length calculation, smmu map and unmap to
be inline with updated iommu interface implementations.

Change-Id: I17cc467564c01e0e3e314eef6945c4129a61dc62
Signed-off-by: default avatarAbhijith Desai <desaia@codeaurora.org>
parent 28591143
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -941,9 +941,6 @@ static int mdss_mdp_put_img(struct mdss_mdp_img_data *data, bool rotator,
		if (data->mapped) {
			domain = mdss_smmu_get_domain_type(data->flags,
				rotator);
			mdss_smmu_unmap_dma_buf(data->srcp_table,
						domain, dir,
						data->srcp_dma_buf);
			data->mapped = false;
		}
		if (!data->skip_detach) {
@@ -1021,11 +1018,16 @@ static int mdss_mdp_get_img(struct msmfb_data *img,
			data->srcp_attachment =
				mdss_smmu_dma_buf_attach(data->srcp_dma_buf,
							 dev, domain);
			if (IS_ERR(data->srcp_attachment)) {
			if (IS_ERR_OR_NULL(data->srcp_attachment)) {
				ret = PTR_ERR(data->srcp_attachment);
				pr_err("error during dma buf attach\n");
				goto err_put;
			}


			data->srcp_attachment->dma_map_attrs |=
					DMA_ATTR_DELAYED_UNMAP;

			data->srcp_table =
				dma_buf_map_attachment(data->srcp_attachment,
				mdss_smmu_dma_data_direction(dir));
+17 −11
Original line number Diff line number Diff line
@@ -210,8 +210,10 @@ static int mdss_smmu_attach_v2(struct mdss_data_type *mdata)
				pr_debug("iommu v2 domain[%i] attached\n", i);
			}
		} else {
			pr_err("iommu device not attached for domain[%d]\n", i);
			return -ENODEV;
			/* Possible that target does not support secure cb */
			pr_debug("iommu device not present for domain[%d]\n",
							 i);
			return 0;
		}
	}

@@ -288,23 +290,27 @@ static int mdss_smmu_map_dma_buf_v2(struct dma_buf *dma_buf,
		struct sg_table *table, int domain, dma_addr_t *iova,
		unsigned long *size, int dir)
{
	int rc;
	struct mdss_smmu_client *mdss_smmu = mdss_smmu_get_cb(domain);
	struct scatterlist *sg;
	unsigned int i;

	if (!mdss_smmu) {
		pr_err("not able to get smmu context\n");
		return -EINVAL;
	}
	ATRACE_BEGIN("map_buffer");
	rc = msm_dma_map_sg_lazy(mdss_smmu->dev, table->sgl, table->nents, dir,
		dma_buf);
	if (rc != table->nents) {
		pr_err("dma map sg failed\n");
		return -ENOMEM;

	if (!table || !table->sgl) {
		pr_err("Invalid table and scattergather list for dma buf\n");
		return -EINVAL;
	}
	ATRACE_END("map_buffer");

	ATRACE_BEGIN("map_buffer");
	*iova = table->sgl->dma_address;
	*size = sg_dma_len(table->sgl);

	*size = 0;
	for_each_sg(table->sgl, sg, table->nents, i)
		*size += sg->length;
	ATRACE_END("map_buffer");
	return 0;
}