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