930b9c7f22496dd045526ffe74b03082475dbf7c
[sfrench/cifs-2.6.git] / drivers / gpu / drm / etnaviv / etnaviv_cmdbuf.h
1 /*
2  * Copyright (C) 2017 Etnaviv Project
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 2 as published by
6  * the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
11  * more details.
12  *
13  * You should have received a copy of the GNU General Public License along with
14  * this program.  If not, see <http://www.gnu.org/licenses/>.
15  */
16
17 #ifndef __ETNAVIV_CMDBUF_H__
18 #define __ETNAVIV_CMDBUF_H__
19
20 #include <linux/types.h>
21
22 struct etnaviv_gpu;
23 struct etnaviv_cmdbuf_suballoc;
24 struct etnaviv_perfmon_request;
25
26 struct etnaviv_cmdbuf {
27         /* suballocator this cmdbuf is allocated from */
28         struct etnaviv_cmdbuf_suballoc *suballoc;
29         /* user context key, must be unique between all active users */
30         struct etnaviv_file_private *ctx;
31         /* cmdbuf properties */
32         int suballoc_offset;
33         void *vaddr;
34         u32 size;
35         u32 user_size;
36         /* fence after which this buffer is to be disposed */
37         struct dma_fence *fence;
38         /* target exec state */
39         u32 exec_state;
40         /* per GPU in-flight list */
41         struct list_head node;
42         /* BOs attached to this command buffer */
43         unsigned int nr_bos;
44         struct etnaviv_vram_mapping *bo_map[0];
45 };
46
47 struct etnaviv_cmdbuf_suballoc *
48 etnaviv_cmdbuf_suballoc_new(struct etnaviv_gpu * gpu);
49 void etnaviv_cmdbuf_suballoc_destroy(struct etnaviv_cmdbuf_suballoc *suballoc);
50
51 struct etnaviv_cmdbuf *
52 etnaviv_cmdbuf_new(struct etnaviv_cmdbuf_suballoc *suballoc, u32 size,
53                    size_t nr_bos);
54 void etnaviv_cmdbuf_free(struct etnaviv_cmdbuf *cmdbuf);
55
56 u32 etnaviv_cmdbuf_get_va(struct etnaviv_cmdbuf *buf);
57 dma_addr_t etnaviv_cmdbuf_get_pa(struct etnaviv_cmdbuf *buf);
58
59 #endif /* __ETNAVIV_CMDBUF_H__ */