drm/nouveau/core: have fifo store a unique context identifier at attach time
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / gpu / drm / nouveau / core / include / core / engctx.h
1 #ifndef __NOUVEAU_ENGCTX_H__
2 #define __NOUVEAU_ENGCTX_H__
3
4 #include <core/object.h>
5 #include <core/gpuobj.h>
6
7 #include <subdev/vm.h>
8
9 #define NV_ENGCTX_(eng,var) (NV_ENGCTX_CLASS | ((var) << 8) | (eng))
10 #define NV_ENGCTX(name,var)  NV_ENGCTX_(NVDEV_ENGINE_##name, (var))
11
12 struct nouveau_engctx {
13         struct nouveau_gpuobj base;
14         struct nouveau_vma vma;
15         struct list_head head;
16         u64 addr;
17 };
18
19 static inline struct nouveau_engctx *
20 nv_engctx(void *obj)
21 {
22 #if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA
23         if (unlikely(!nv_iclass(obj, NV_ENGCTX_CLASS)))
24                 nv_assert("BAD CAST -> NvEngCtx, %08x", nv_hclass(obj));
25 #endif
26         return obj;
27 }
28
29 #define nouveau_engctx_create(p,e,c,g,s,a,f,d)                                 \
30         nouveau_engctx_create_((p), (e), (c), (g), (s), (a), (f),              \
31                                sizeof(**d), (void **)d)
32
33 int  nouveau_engctx_create_(struct nouveau_object *, struct nouveau_object *,
34                             struct nouveau_oclass *, struct nouveau_object *,
35                             u32 size, u32 align, u32 flags,
36                             int length, void **data);
37 void nouveau_engctx_destroy(struct nouveau_engctx *);
38 int  nouveau_engctx_init(struct nouveau_engctx *);
39 int  nouveau_engctx_fini(struct nouveau_engctx *, bool suspend);
40
41 void _nouveau_engctx_dtor(struct nouveau_object *);
42 int  _nouveau_engctx_init(struct nouveau_object *);
43 int  _nouveau_engctx_fini(struct nouveau_object *, bool suspend);
44 #define _nouveau_engctx_rd32 _nouveau_gpuobj_rd32
45 #define _nouveau_engctx_wr32 _nouveau_gpuobj_wr32
46
47 struct nouveau_object *
48 nouveau_engctx_lookup(struct nouveau_engine *, u64 addr);
49
50 struct nouveau_handle *
51 nouveau_engctx_lookup_class(struct nouveau_engine *, u64, u16);
52
53 struct nouveau_handle *
54 nouveau_engctx_lookup_vinst(struct nouveau_engine *, u64, u64);
55
56 struct nouveau_handle *
57 nouveau_engctx_lookup_cinst(struct nouveau_engine *, u64, u32);
58
59 void
60 nouveau_engctx_handle_put(struct nouveau_handle *);
61
62 #endif