Skip to content

Commit

Permalink
staging:ion: add a no-map property to ion dmabuf attachment
Browse files Browse the repository at this point in the history
Ion unmapped heap aims at not being mapped. This change prevents
Ion from calling dma-mapping support on dma_buf_attach for buffers
in an unmapped heap.

This change is a bit intrusive in the Ion driver. Maybe there is
another way to deal with the dma-mapping resources used for the
unmapped heap.

Signed-off-by: Etienne Carriere <[email protected]>
  • Loading branch information
etienne-lms authored and jenswi-linaro committed Oct 27, 2017
1 parent 7e7a654 commit 6e954e2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/staging/android/ion/ion.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ struct ion_dma_buf_attachment {
struct device *dev;
struct sg_table *table;
struct list_head list;
bool no_map;
};

static int ion_dma_buf_attach(struct dma_buf *dmabuf, struct device *dev,
Expand All @@ -237,6 +238,9 @@ static int ion_dma_buf_attach(struct dma_buf *dmabuf, struct device *dev,
return -ENOMEM;
}

if (buffer->heap->type == ION_HEAP_TYPE_UNMAPPED)
a->no_map = true;

a->table = table;
a->dev = dev;
INIT_LIST_HEAD(&a->list);
Expand Down Expand Up @@ -274,6 +278,9 @@ static struct sg_table *ion_map_dma_buf(struct dma_buf_attachment *attachment,

table = a->table;

if (a->no_map)
return table;

if (!dma_map_sg(attachment->dev, table->sgl, table->nents,
direction)){
ret = -ENOMEM;
Expand All @@ -290,6 +297,11 @@ static void ion_unmap_dma_buf(struct dma_buf_attachment *attachment,
struct sg_table *table,
enum dma_data_direction direction)
{
struct ion_dma_buf_attachment *a = attachment->priv;

if (a->no_map)
return;

dma_unmap_sg(attachment->dev, table->sgl, table->nents, direction);
}

Expand Down

0 comments on commit 6e954e2

Please sign in to comment.