GNU Linux-libre 4.14.303-gnu1
[releases.git] / drivers / gpu / drm / nouveau / include / nvkm / core / gpuobj.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __NVKM_GPUOBJ_H__
3 #define __NVKM_GPUOBJ_H__
4 #include <core/object.h>
5 #include <core/memory.h>
6 #include <core/mm.h>
7 struct nvkm_vma;
8 struct nvkm_vm;
9
10 #define NVOBJ_FLAG_ZERO_ALLOC 0x00000001
11 #define NVOBJ_FLAG_HEAP       0x00000004
12
13 struct nvkm_gpuobj {
14         struct nvkm_object object;
15         const struct nvkm_gpuobj_func *func;
16         struct nvkm_gpuobj *parent;
17         struct nvkm_memory *memory;
18         struct nvkm_mm_node *node;
19
20         u64 addr;
21         u32 size;
22         struct nvkm_mm heap;
23
24         void __iomem *map;
25 };
26
27 struct nvkm_gpuobj_func {
28         void *(*acquire)(struct nvkm_gpuobj *);
29         void (*release)(struct nvkm_gpuobj *);
30         u32 (*rd32)(struct nvkm_gpuobj *, u32 offset);
31         void (*wr32)(struct nvkm_gpuobj *, u32 offset, u32 data);
32 };
33
34 int nvkm_gpuobj_new(struct nvkm_device *, u32 size, int align, bool zero,
35                     struct nvkm_gpuobj *parent, struct nvkm_gpuobj **);
36 void nvkm_gpuobj_del(struct nvkm_gpuobj **);
37 int nvkm_gpuobj_wrap(struct nvkm_memory *, struct nvkm_gpuobj **);
38 int nvkm_gpuobj_map(struct nvkm_gpuobj *, struct nvkm_vm *, u32 access,
39                     struct nvkm_vma *);
40 void nvkm_gpuobj_unmap(struct nvkm_vma *);
41 void nvkm_gpuobj_memcpy_to(struct nvkm_gpuobj *dst, u32 dstoffset, void *src,
42                            u32 length);
43 void nvkm_gpuobj_memcpy_from(void *dst, struct nvkm_gpuobj *src, u32 srcoffset,
44                              u32 length);
45 #endif