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

Commit 995b495a authored by Liam Mark's avatar Liam Mark
Browse files

ion: add kernel support to get buffer flags



Allow ION kernel clients to get an ion buffer's flags.
This will allow ION clients to be able to determine if a buffer
is cached, uncached, secure ect.

Change-Id: I5460478e69f28e74906fd298f57dabd9e62c1e1f
Signed-off-by: default avatarLiam Mark <lmark@codeaurora.org>
parent bca90e2f
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -1053,6 +1053,20 @@ void dma_buf_vunmap(struct dma_buf *dmabuf, void *vaddr)
}
EXPORT_SYMBOL_GPL(dma_buf_vunmap);

int dma_buf_get_flags(struct dma_buf *dmabuf, unsigned long *flags)
{
	int ret = 0;

	if (WARN_ON(!dmabuf))
		return -EINVAL;

	if (dmabuf->ops->get_flags)
		ret = dmabuf->ops->get_flags(dmabuf, flags);

	return ret;
}
EXPORT_SYMBOL(dma_buf_get_flags);

#ifdef CONFIG_DEBUG_FS
static int dma_buf_debug_show(struct seq_file *s, void *unused)
{
+10 −0
Original line number Diff line number Diff line
@@ -494,6 +494,15 @@ static int ion_dma_buf_end_cpu_access(struct dma_buf *dmabuf,
	return 0;
}

static int ion_dma_buf_get_flags(struct dma_buf *dmabuf,
				 unsigned long *flags)
{
	struct ion_buffer *buffer = dmabuf->priv;
	*flags = buffer->flags;

	return 0;
}

static const struct dma_buf_ops dma_buf_ops = {
	.map_dma_buf = ion_map_dma_buf,
	.unmap_dma_buf = ion_unmap_dma_buf,
@@ -507,6 +516,7 @@ static const struct dma_buf_ops dma_buf_ops = {
	.unmap_atomic = ion_dma_buf_kunmap,
	.map = ion_dma_buf_kmap,
	.unmap = ion_dma_buf_kunmap,
	.get_flags = ion_dma_buf_get_flags,
};

struct dma_buf *ion_alloc_dmabuf(size_t len, unsigned int heap_id_mask,
+15 −0
Original line number Diff line number Diff line
@@ -250,6 +250,20 @@ struct dma_buf_ops {

	void *(*vmap)(struct dma_buf *);
	void (*vunmap)(struct dma_buf *, void *vaddr);

	/**
	 * @get_flags:
	 *
	 * This is called by dma_buf_get_flags and is used to get the buffer's
	 * flags.
	 * This callback is optional.
	 *
	 * Returns:
	 *
	 * 0 on success or a negative error code on failure. On success flags
	 * will be populated with the buffer's flags.
	 */
	int (*get_flags)(struct dma_buf *, unsigned long *flags);
};

/**
@@ -405,4 +419,5 @@ int dma_buf_mmap(struct dma_buf *, struct vm_area_struct *,
		 unsigned long);
void *dma_buf_vmap(struct dma_buf *);
void dma_buf_vunmap(struct dma_buf *, void *vaddr);
int dma_buf_get_flags(struct dma_buf *dma_buf, unsigned long *flags);
#endif /* __DMA_BUF_H__ */