| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| From: "Isaac J. Manjarres" <isaacm@codeaurora.org> |
| Date: Wed, 19 Jun 2019 15:37:12 -0700 |
| Subject: ANDROID: dma-buf: Add support to get flags associated with a buffer |
| |
| Allow kernel clients to get the flags associated with a buffer |
| that is wrapped by a dma-buf. This information can be used to |
| communicate the type of memory associated with the |
| buffer(e.g. uncached vs cached memory). |
| |
| [CPNOTE: 06/07/21] Lee: Pinged the bug for the upstream plan |
| |
| Bug: 133508579 |
| Test: ion-unit-tests |
| Change-Id: I82eab8beb738b258616c22a01080615d7ffb6ad5 |
| Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org> |
| Signed-off-by: Sandeep Patil <sspatil@google.com> |
| Signed-off-by: Lee Jones <joneslee@google.com> |
| --- |
| drivers/dma-buf/dma-buf.c | 14 ++++++++++++++ |
| include/linux/dma-buf.h | 15 +++++++++++++++ |
| 2 files changed, 29 insertions(+) |
| |
| diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c |
| --- a/drivers/dma-buf/dma-buf.c |
| +++ b/drivers/dma-buf/dma-buf.c |
| @@ -1499,6 +1499,20 @@ void dma_buf_vunmap(struct dma_buf *dmabuf, struct iosys_map *map) |
| } |
| EXPORT_SYMBOL_NS_GPL(dma_buf_vunmap, DMA_BUF); |
| |
| +int dma_buf_get_flags(struct dma_buf *dmabuf, unsigned long *flags) |
| +{ |
| + int ret = 0; |
| + |
| + if (WARN_ON(!dmabuf) || !flags) |
| + return -EINVAL; |
| + |
| + if (dmabuf->ops->get_flags) |
| + ret = dmabuf->ops->get_flags(dmabuf, flags); |
| + |
| + return ret; |
| +} |
| +EXPORT_SYMBOL_GPL(dma_buf_get_flags); |
| + |
| #ifdef CONFIG_DEBUG_FS |
| static int dma_buf_debug_show(struct seq_file *s, void *unused) |
| { |
| diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h |
| --- a/include/linux/dma-buf.h |
| +++ b/include/linux/dma-buf.h |
| @@ -342,6 +342,20 @@ struct dma_buf_ops { |
| |
| int (*vmap)(struct dma_buf *dmabuf, struct iosys_map *map); |
| void (*vunmap)(struct dma_buf *dmabuf, struct iosys_map *map); |
| + |
| + /** |
| + * @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 *dmabuf, unsigned long *flags); |
| }; |
| |
| /** |
| @@ -698,4 +712,5 @@ int dma_buf_mmap(struct dma_buf *, struct vm_area_struct *, |
| unsigned long); |
| int dma_buf_vmap(struct dma_buf *dmabuf, struct iosys_map *map); |
| void dma_buf_vunmap(struct dma_buf *dmabuf, struct iosys_map *map); |
| +int dma_buf_get_flags(struct dma_buf *dmabuf, unsigned long *flags); |
| #endif /* __DMA_BUF_H__ */ |