Skip to content

Commit 6e954e2

Browse files
etienne-lmsjenswi-linaro
authored andcommitted
staging:ion: add a no-map property to ion dmabuf attachment
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]>
1 parent 7e7a654 commit 6e954e2

File tree

1 file changed

+12
-0
lines changed
  • drivers/staging/android/ion

1 file changed

+12
-0
lines changed

drivers/staging/android/ion/ion.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ struct ion_dma_buf_attachment {
218218
struct device *dev;
219219
struct sg_table *table;
220220
struct list_head list;
221+
bool no_map;
221222
};
222223

223224
static int ion_dma_buf_attach(struct dma_buf *dmabuf, struct device *dev,
@@ -237,6 +238,9 @@ static int ion_dma_buf_attach(struct dma_buf *dmabuf, struct device *dev,
237238
return -ENOMEM;
238239
}
239240

241+
if (buffer->heap->type == ION_HEAP_TYPE_UNMAPPED)
242+
a->no_map = true;
243+
240244
a->table = table;
241245
a->dev = dev;
242246
INIT_LIST_HEAD(&a->list);
@@ -274,6 +278,9 @@ static struct sg_table *ion_map_dma_buf(struct dma_buf_attachment *attachment,
274278

275279
table = a->table;
276280

281+
if (a->no_map)
282+
return table;
283+
277284
if (!dma_map_sg(attachment->dev, table->sgl, table->nents,
278285
direction)){
279286
ret = -ENOMEM;
@@ -290,6 +297,11 @@ static void ion_unmap_dma_buf(struct dma_buf_attachment *attachment,
290297
struct sg_table *table,
291298
enum dma_data_direction direction)
292299
{
300+
struct ion_dma_buf_attachment *a = attachment->priv;
301+
302+
if (a->no_map)
303+
return;
304+
293305
dma_unmap_sg(attachment->dev, table->sgl, table->nents, direction);
294306
}
295307

0 commit comments

Comments
 (0)