Skip to content

Commit 17774a5

Browse files
committed
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 460d6c4 commit 17774a5

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
@@ -207,6 +207,7 @@ struct ion_dma_buf_attachment {
207207
struct device *dev;
208208
struct sg_table *table;
209209
struct list_head list;
210+
bool no_map;
210211
};
211212

212213
static int ion_dma_buf_attach(struct dma_buf *dmabuf,
@@ -226,6 +227,9 @@ static int ion_dma_buf_attach(struct dma_buf *dmabuf,
226227
return -ENOMEM;
227228
}
228229

230+
if (buffer->heap->type == ION_HEAP_TYPE_UNMAPPED)
231+
a->no_map = true;
232+
229233
a->table = table;
230234
a->dev = attachment->dev;
231235
INIT_LIST_HEAD(&a->list);
@@ -261,6 +265,9 @@ static struct sg_table *ion_map_dma_buf(struct dma_buf_attachment *attachment,
261265

262266
table = a->table;
263267

268+
if (a->no_map)
269+
return table;
270+
264271
if (!dma_map_sg(attachment->dev, table->sgl, table->nents,
265272
direction))
266273
return ERR_PTR(-ENOMEM);
@@ -272,6 +279,11 @@ static void ion_unmap_dma_buf(struct dma_buf_attachment *attachment,
272279
struct sg_table *table,
273280
enum dma_data_direction direction)
274281
{
282+
struct ion_dma_buf_attachment *a = attachment->priv;
283+
284+
if (a->no_map)
285+
return;
286+
275287
dma_unmap_sg(attachment->dev, table->sgl, table->nents, direction);
276288
}
277289

0 commit comments

Comments
 (0)