nouveau_fence.h revision 1.7 1 /* $NetBSD: nouveau_fence.h,v 1.7 2021/12/18 23:45:32 riastradh Exp $ */
2
3 /* SPDX-License-Identifier: MIT */
4 #ifndef __NOUVEAU_FENCE_H__
5 #define __NOUVEAU_FENCE_H__
6
7 #include <linux/dma-fence.h>
8 #include <nvif/notify.h>
9
10 struct nouveau_drm;
11 struct nouveau_bo;
12
13 struct nouveau_fence {
14 struct dma_fence base;
15
16 struct list_head head;
17
18 struct nouveau_channel __rcu *channel;
19 unsigned long timeout;
20 };
21
22 int nouveau_fence_new(struct nouveau_channel *, bool sysmem,
23 struct nouveau_fence **);
24 void nouveau_fence_unref(struct nouveau_fence **);
25
26 int nouveau_fence_emit(struct nouveau_fence *, struct nouveau_channel *);
27 bool nouveau_fence_done(struct nouveau_fence *);
28 int nouveau_fence_wait(struct nouveau_fence *, bool lazy, bool intr);
29 int nouveau_fence_sync(struct nouveau_bo *, struct nouveau_channel *, bool exclusive, bool intr);
30
31 struct nouveau_fence_chan {
32 spinlock_t lock;
33 struct kref fence_ref;
34
35 struct list_head pending;
36 struct list_head flip;
37
38 int (*emit)(struct nouveau_fence *);
39 int (*sync)(struct nouveau_fence *, struct nouveau_channel *,
40 struct nouveau_channel *);
41 u32 (*read)(struct nouveau_channel *);
42 int (*emit32)(struct nouveau_channel *, u64, u32);
43 int (*sync32)(struct nouveau_channel *, u64, u32);
44
45 u32 sequence;
46 u32 context;
47 char name[32];
48
49 struct nvif_notify notify;
50 int notify_ref, dead;
51 };
52
53 struct nouveau_fence_priv {
54 void (*dtor)(struct nouveau_drm *);
55 bool (*suspend)(struct nouveau_drm *);
56 void (*resume)(struct nouveau_drm *);
57 int (*context_new)(struct nouveau_channel *);
58 void (*context_del)(struct nouveau_channel *);
59
60 bool uevent;
61 };
62
63 #define nouveau_fence(drm) ((struct nouveau_fence_priv *)(drm)->fence)
64
65 void nouveau_fence_context_new(struct nouveau_channel *, struct nouveau_fence_chan *);
66 void nouveau_fence_context_del(struct nouveau_fence_chan *);
67 void nouveau_fence_context_free(struct nouveau_fence_chan *);
68 void nouveau_fence_context_kill(struct nouveau_fence_chan *, int error);
69
70 int nv04_fence_create(struct nouveau_drm *);
71 int nv04_fence_mthd(struct nouveau_channel *, u32, u32, u32);
72
73 int nv10_fence_emit(struct nouveau_fence *);
74 int nv17_fence_sync(struct nouveau_fence *, struct nouveau_channel *,
75 struct nouveau_channel *);
76 u32 nv10_fence_read(struct nouveau_channel *);
77 void nv10_fence_context_del(struct nouveau_channel *);
78 void nv10_fence_destroy(struct nouveau_drm *);
79 int nv10_fence_create(struct nouveau_drm *);
80
81 int nv17_fence_create(struct nouveau_drm *);
82 void nv17_fence_resume(struct nouveau_drm *drm);
83
84 int nv50_fence_create(struct nouveau_drm *);
85 int nv84_fence_create(struct nouveau_drm *);
86 int nvc0_fence_create(struct nouveau_drm *);
87
88 struct nv84_fence_chan {
89 struct nouveau_fence_chan base;
90 struct nouveau_vma *vma;
91 };
92
93 struct nv84_fence_priv {
94 struct nouveau_fence_priv base;
95 struct nouveau_bo *bo;
96 u32 *suspend;
97 struct mutex mutex;
98 };
99
100 int nv84_fence_context_new(struct nouveau_channel *);
101
102 #endif
103