mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 08:39:59 +07:00
5248eb12fe
Add generic helper dmabuf ops for dma heaps, so we can reduce the amount of duplicative code for the exported dmabufs. This code is an evolution of the Android ION implementation, so thanks to its original authors and maintainters: Rebecca Schultz Zavin, Colin Cross, Laura Abbott, and others! Cc: Laura Abbott <labbott@redhat.com> Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org> Cc: Sumit Semwal <sumit.semwal@linaro.org> Cc: Liam Mark <lmark@codeaurora.org> Cc: Pratik Patel <pratikp@codeaurora.org> Cc: Brian Starkey <Brian.Starkey@arm.com> Cc: Vincent Donnefort <Vincent.Donnefort@arm.com> Cc: Sudipto Paul <Sudipto.Paul@arm.com> Cc: Andrew F. Davis <afd@ti.com> Cc: Christoph Hellwig <hch@infradead.org> Cc: Chenbo Feng <fengc@google.com> Cc: Alistair Strachan <astrachan@google.com> Cc: Hridya Valsaraju <hridya@google.com> Cc: Sandeep Patil <sspatil@google.com> Cc: Hillf Danton <hdanton@sina.com> Cc: Dave Airlie <airlied@gmail.com> Cc: dri-devel@lists.freedesktop.org Reviewed-by: Benjamin Gaignard <benjamin.gaignard@linaro.org> Reviewed-by: Brian Starkey <brian.starkey@arm.com> Acked-by: Sandeep Patil <sspatil@android.com> Acked-by: Laura Abbott <labbott@redhat.com> Tested-by: Ayan Kumar Halder <ayan.halder@arm.com> Signed-off-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org> Link: https://patchwork.freedesktop.org/patch/msgid/20191203172641.66642-3-john.stultz@linaro.org
54 lines
1.4 KiB
C
54 lines
1.4 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* DMABUF Heaps helper code
|
|
*
|
|
* Copyright (C) 2011 Google, Inc.
|
|
* Copyright (C) 2019 Linaro Ltd.
|
|
*/
|
|
|
|
#ifndef _HEAP_HELPERS_H
|
|
#define _HEAP_HELPERS_H
|
|
|
|
#include <linux/dma-heap.h>
|
|
#include <linux/list.h>
|
|
|
|
/**
|
|
* struct heap_helper_buffer - helper buffer metadata
|
|
* @heap: back pointer to the heap the buffer came from
|
|
* @dmabuf: backing dma-buf for this buffer
|
|
* @size: size of the buffer
|
|
* @priv_virt pointer to heap specific private value
|
|
* @lock mutext to protect the data in this structure
|
|
* @vmap_cnt count of vmap references on the buffer
|
|
* @vaddr vmap'ed virtual address
|
|
* @pagecount number of pages in the buffer
|
|
* @pages list of page pointers
|
|
* @attachments list of device attachments
|
|
*
|
|
* @free heap callback to free the buffer
|
|
*/
|
|
struct heap_helper_buffer {
|
|
struct dma_heap *heap;
|
|
struct dma_buf *dmabuf;
|
|
size_t size;
|
|
|
|
void *priv_virt;
|
|
struct mutex lock;
|
|
int vmap_cnt;
|
|
void *vaddr;
|
|
pgoff_t pagecount;
|
|
struct page **pages;
|
|
struct list_head attachments;
|
|
|
|
void (*free)(struct heap_helper_buffer *buffer);
|
|
};
|
|
|
|
void init_heap_helper_buffer(struct heap_helper_buffer *buffer,
|
|
void (*free)(struct heap_helper_buffer *));
|
|
|
|
struct dma_buf *heap_helper_export_dmabuf(struct heap_helper_buffer *buffer,
|
|
int fd_flags);
|
|
|
|
extern const struct dma_buf_ops heap_helper_ops;
|
|
#endif /* _HEAP_HELPERS_H */
|