xref: /OK3568_Linux_fs/kernel/drivers/rknpu/include/rknpu_mem.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) Rockchip Electronics Co.Ltd
4  * Author: Felix Zeng <felix.zeng@rock-chips.com>
5  */
6 
7 #ifndef __LINUX_RKNPU_MEM_H
8 #define __LINUX_RKNPU_MEM_H
9 
10 #include <linux/mm_types.h>
11 #include <linux/version.h>
12 
13 /*
14  * rknpu DMA buffer structure.
15  *
16  * @flags: indicate memory type to allocated buffer and cache attribute.
17  * @size: size requested from user, in bytes and this size is aligned
18  *	in page unit.
19  * @kv_addr: kernel virtual address to allocated memory region.
20  * @dma_addr: bus address(accessed by dma) to allocated memory region.
21  *	- this address could be physical address without IOMMU and
22  *	device address with IOMMU.
23  * @pages: Array of backing pages.
24  * @sgt: Imported sg_table.
25  * @dmabuf: buffer for this attachment.
26  * @owner: Is this memory internally allocated.
27  */
28 struct rknpu_mem_object {
29 	unsigned long flags;
30 	unsigned long size;
31 	void __iomem *kv_addr;
32 	dma_addr_t dma_addr;
33 	struct page **pages;
34 	struct sg_table *sgt;
35 	struct dma_buf *dmabuf;
36 	struct list_head head;
37 	unsigned int owner;
38 };
39 
40 int rknpu_mem_create_ioctl(struct rknpu_device *rknpu_dev, unsigned long data,
41 			   struct file *file);
42 int rknpu_mem_destroy_ioctl(struct rknpu_device *rknpu_dev, unsigned long data,
43 			    struct file *file);
44 int rknpu_mem_sync_ioctl(struct rknpu_device *rknpu_dev, unsigned long data);
45 
46 #endif
47