return ERR_PTR(PTR_ERR(table));
}
buffer->sg_table = table;
- if (buffer->flags & ION_FLAG_CACHED) {
+ if (buffer->flags & ION_FLAG_CACHED &&
+ !(buffer->flags & ION_FLAG_CACHED_NEEDS_SYNC)) {
for_each_sg(buffer->sg_table->sgl, sg, buffer->sg_table->nents,
i) {
if (sg_dma_len(sg) == PAGE_SIZE)
pr_debug("%s: syncing for device %s\n", __func__,
dev ? dev_name(dev) : "null");
- if (!(buffer->flags & ION_FLAG_CACHED))
+ if (!(buffer->flags & ION_FLAG_CACHED) ||
+ (buffer->flags & ION_FLAG_CACHED_NEEDS_SYNC))
return;
mutex_lock(&buffer->lock);
return -EINVAL;
}
- if (buffer->flags & ION_FLAG_CACHED) {
+ if (buffer->flags & ION_FLAG_CACHED &&
+ !(buffer->flags & ION_FLAG_CACHED_NEEDS_SYNC)) {
vma->vm_private_data = buffer;
vma->vm_ops = &ion_vma_ops;
ion_vm_open(vma);
- } else {
- vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
- mutex_lock(&buffer->lock);
- /* now map it to userspace */
- ret = buffer->heap->ops->map_user(buffer->heap, buffer, vma);
- mutex_unlock(&buffer->lock);
+ return 0;
}
+ if (!(buffer->flags & ION_FLAG_CACHED))
+ vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
+
+ mutex_lock(&buffer->lock);
+ /* now map it to userspace */
+ ret = buffer->heap->ops->map_user(buffer->heap, buffer, vma);
+ mutex_unlock(&buffer->lock);
+
if (ret)
pr_err("%s: failure mapping buffer to userspace\n",
__func__);
return -EINVAL;
}
buffer = dmabuf->priv;
- ion_buffer_sync_for_device(buffer, NULL, DMA_BIDIRECTIONAL);
+
+ dma_sync_sg_for_device(NULL, buffer->sg_table->sgl,
+ buffer->sg_table->nents, DMA_BIDIRECTIONAL);
dma_buf_put(dmabuf);
return 0;
}