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

Commit 123f6748 authored by Liam Mark's avatar Liam Mark
Browse files

staging: android: ion: Ensure ION supports concurrent CMO requests



ION userspace clients can request cache maintenance on an ION buffer at
any time using the DMA_BUF_IOCTL_SYNC IOCTL.

Ensure that the ION buffer is not in the process of being detached, dma
mapped or dma unmapped when client requested cache maintenance is carried
out.

Change-Id: I8d414af02dbfe8f6e81e0d518f9819b574a8da9f
Signed-off-by: default avatarLiam Mark <lmark@codeaurora.org>
parent cb57e6b4
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -311,8 +311,8 @@ static void ion_dma_buf_detatch(struct dma_buf *dmabuf,
	struct ion_dma_buf_attachment *a = attachment->priv;
	struct ion_buffer *buffer = dmabuf->priv;

	free_duped_table(a->table);
	mutex_lock(&buffer->lock);
	free_duped_table(a->table);
	list_del(&a->list);
	mutex_unlock(&buffer->lock);

@@ -335,6 +335,7 @@ static struct sg_table *ion_map_dma_buf(struct dma_buf_attachment *attachment,
	    !hlos_accessible_buffer(buffer))
		map_attrs |= DMA_ATTR_SKIP_CPU_SYNC;

	mutex_lock(&buffer->lock);
	if (map_attrs & DMA_ATTR_SKIP_CPU_SYNC)
		trace_ion_dma_map_cmo_skip(attachment->dev,
					   attachment->dmabuf->name,
@@ -364,6 +365,7 @@ static struct sg_table *ion_map_dma_buf(struct dma_buf_attachment *attachment,
		return ERR_PTR(-ENOMEM);

	a->dma_mapped = true;
	mutex_unlock(&buffer->lock);
	return table;
}

@@ -380,6 +382,7 @@ static void ion_unmap_dma_buf(struct dma_buf_attachment *attachment,
	    !hlos_accessible_buffer(buffer))
		map_attrs |= DMA_ATTR_SKIP_CPU_SYNC;

	mutex_lock(&buffer->lock);
	if (map_attrs & DMA_ATTR_SKIP_CPU_SYNC)
		trace_ion_dma_unmap_cmo_skip(attachment->dev,
					     attachment->dmabuf->name,
@@ -404,6 +407,7 @@ static void ion_unmap_dma_buf(struct dma_buf_attachment *attachment,
		dma_unmap_sg_attrs(attachment->dev, table->sgl, table->nents,
				   direction, map_attrs);
	a->dma_mapped = false;
	mutex_unlock(&buffer->lock);
}

void ion_pages_sync_for_device(struct device *dev, struct page *page,