xref: /linux/drivers/gpu/drm/nouveau/include/nvkm/core/object.h (revision 3a39d672e7f48b8d6b91a09afa4b55352773b4b5)
1 /* SPDX-License-Identifier: MIT */
2 #ifndef __NVKM_OBJECT_H__
3 #define __NVKM_OBJECT_H__
4 #include <core/oclass.h>
5 struct nvkm_event;
6 struct nvkm_gpuobj;
7 struct nvkm_uevent;
8 
9 struct nvkm_object {
10 	const struct nvkm_object_func *func;
11 	struct nvkm_client *client;
12 	struct nvkm_engine *engine;
13 	s32 oclass;
14 	u32 handle;
15 
16 	struct list_head head;
17 	struct list_head tree;
18 	u64 object;
19 	struct rb_node node;
20 };
21 
22 enum nvkm_object_map {
23 	NVKM_OBJECT_MAP_IO,
24 	NVKM_OBJECT_MAP_VA
25 };
26 
27 struct nvkm_object_func {
28 	void *(*dtor)(struct nvkm_object *);
29 	int (*init)(struct nvkm_object *);
30 	int (*fini)(struct nvkm_object *, bool suspend);
31 	int (*mthd)(struct nvkm_object *, u32 mthd, void *data, u32 size);
32 	int (*ntfy)(struct nvkm_object *, u32 mthd, struct nvkm_event **);
33 	int (*map)(struct nvkm_object *, void *argv, u32 argc,
34 		   enum nvkm_object_map *, u64 *addr, u64 *size);
35 	int (*unmap)(struct nvkm_object *);
36 	int (*bind)(struct nvkm_object *, struct nvkm_gpuobj *, int align,
37 		    struct nvkm_gpuobj **);
38 	int (*sclass)(struct nvkm_object *, int index, struct nvkm_oclass *);
39 	int (*uevent)(struct nvkm_object *, void *argv, u32 argc, struct nvkm_uevent *);
40 };
41 
42 void nvkm_object_ctor(const struct nvkm_object_func *,
43 		      const struct nvkm_oclass *, struct nvkm_object *);
44 int nvkm_object_new_(const struct nvkm_object_func *,
45 		     const struct nvkm_oclass *, void *data, u32 size,
46 		     struct nvkm_object **);
47 int nvkm_object_new(const struct nvkm_oclass *, void *data, u32 size,
48 		    struct nvkm_object **);
49 void nvkm_object_del(struct nvkm_object **);
50 void *nvkm_object_dtor(struct nvkm_object *);
51 int nvkm_object_init(struct nvkm_object *);
52 int nvkm_object_fini(struct nvkm_object *, bool suspend);
53 int nvkm_object_mthd(struct nvkm_object *, u32 mthd, void *data, u32 size);
54 int nvkm_object_ntfy(struct nvkm_object *, u32 mthd, struct nvkm_event **);
55 int nvkm_object_map(struct nvkm_object *, void *argv, u32 argc,
56 		    enum nvkm_object_map *, u64 *addr, u64 *size);
57 int nvkm_object_unmap(struct nvkm_object *);
58 int nvkm_object_bind(struct nvkm_object *, struct nvkm_gpuobj *, int align,
59 		     struct nvkm_gpuobj **);
60 
61 bool nvkm_object_insert(struct nvkm_object *);
62 void nvkm_object_remove(struct nvkm_object *);
63 struct nvkm_object *nvkm_object_search(struct nvkm_client *, u64 object,
64 				       const struct nvkm_object_func *);
65 #endif
66