• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: MIT */
2 #ifndef __NVKM_GPUOBJ_H__
3 #define __NVKM_GPUOBJ_H__
4 #include <core/memory.h>
5 #include <core/mm.h>
6 
7 #define NVOBJ_FLAG_ZERO_ALLOC 0x00000001
8 #define NVOBJ_FLAG_HEAP       0x00000004
9 
10 struct nvkm_gpuobj {
11 	union {
12 		const struct nvkm_gpuobj_func *func;
13 		const struct nvkm_gpuobj_func *ptrs;
14 	};
15 	struct nvkm_gpuobj *parent;
16 	struct nvkm_memory *memory;
17 	struct nvkm_mm_node *node;
18 
19 	u64 addr;
20 	u32 size;
21 	struct nvkm_mm heap;
22 
23 	void __iomem *map;
24 };
25 
26 struct nvkm_gpuobj_func {
27 	void *(*acquire)(struct nvkm_gpuobj *);
28 	void (*release)(struct nvkm_gpuobj *);
29 	u32 (*rd32)(struct nvkm_gpuobj *, u32 offset);
30 	void (*wr32)(struct nvkm_gpuobj *, u32 offset, u32 data);
31 	int (*map)(struct nvkm_gpuobj *, u64 offset, struct nvkm_vmm *,
32 		   struct nvkm_vma *, void *argv, u32 argc);
33 };
34 
35 int nvkm_gpuobj_new(struct nvkm_device *, u32 size, int align, bool zero,
36 		    struct nvkm_gpuobj *parent, struct nvkm_gpuobj **);
37 void nvkm_gpuobj_del(struct nvkm_gpuobj **);
38 int nvkm_gpuobj_wrap(struct nvkm_memory *, struct nvkm_gpuobj **);
39 void nvkm_gpuobj_memcpy_to(struct nvkm_gpuobj *dst, u32 dstoffset, void *src,
40 			   u32 length);
41 void nvkm_gpuobj_memcpy_from(void *dst, struct nvkm_gpuobj *src, u32 srcoffset,
42 			     u32 length);
43 #endif
44