1 #ifndef __NVKM_ENGCTX_H__
2 #define __NVKM_ENGCTX_H__
3 #include <core/gpuobj.h>
4 
5 #include <subdev/mmu.h>
6 
7 #define NV_ENGCTX_(eng,var) (NV_ENGCTX_CLASS | ((var) << 8) | (eng))
8 #define NV_ENGCTX(name,var)  NV_ENGCTX_(NVDEV_ENGINE_##name, (var))
9 
10 struct nvkm_engctx {
11 	struct nvkm_gpuobj gpuobj;
12 	struct nvkm_vma vma;
13 	struct list_head head;
14 	unsigned long save;
15 	u64 addr;
16 };
17 
18 static inline struct nvkm_engctx *
nv_engctx(void * obj)19 nv_engctx(void *obj)
20 {
21 #if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA
22 	if (unlikely(!nv_iclass(obj, NV_ENGCTX_CLASS)))
23 		nv_assert("BAD CAST -> NvEngCtx, %08x", nv_hclass(obj));
24 #endif
25 	return obj;
26 }
27 
28 #define nvkm_engctx_create(p,e,c,g,s,a,f,d)                                 \
29 	nvkm_engctx_create_((p), (e), (c), (g), (s), (a), (f),              \
30 			       sizeof(**d), (void **)d)
31 
32 int  nvkm_engctx_create_(struct nvkm_object *, struct nvkm_object *,
33 			    struct nvkm_oclass *, struct nvkm_object *,
34 			    u32 size, u32 align, u32 flags,
35 			    int length, void **data);
36 void nvkm_engctx_destroy(struct nvkm_engctx *);
37 int  nvkm_engctx_init(struct nvkm_engctx *);
38 int  nvkm_engctx_fini(struct nvkm_engctx *, bool suspend);
39 
40 int  _nvkm_engctx_ctor(struct nvkm_object *, struct nvkm_object *,
41 			  struct nvkm_oclass *, void *, u32,
42 			  struct nvkm_object **);
43 void _nvkm_engctx_dtor(struct nvkm_object *);
44 int  _nvkm_engctx_init(struct nvkm_object *);
45 int  _nvkm_engctx_fini(struct nvkm_object *, bool suspend);
46 #define _nvkm_engctx_rd32 _nvkm_gpuobj_rd32
47 #define _nvkm_engctx_wr32 _nvkm_gpuobj_wr32
48 
49 struct nvkm_object *nvkm_engctx_get(struct nvkm_engine *, u64 addr);
50 void nvkm_engctx_put(struct nvkm_object *);
51 #endif
52