Merge branch 'for-linus-4.7' of git://git.kernel.org/pub/scm/linux/kernel/git/mason...
[linux-2.6-block.git] / drivers / gpu / drm / nouveau / nouveau_fence.h
CommitLineData
d375e7d5
BS
1#ifndef __NOUVEAU_FENCE_H__
2#define __NOUVEAU_FENCE_H__
3
29ba89b2
ML
4#include <linux/fence.h>
5#include <nvif/notify.h>
6
ebb945a9 7struct nouveau_drm;
29ba89b2 8struct nouveau_bo;
ebb945a9 9
d375e7d5 10struct nouveau_fence {
29ba89b2
ML
11 struct fence base;
12
d375e7d5 13 struct list_head head;
d375e7d5 14
264ce192
BS
15 bool sysmem;
16
0ec5f02f 17 struct nouveau_channel __rcu *channel;
d375e7d5 18 unsigned long timeout;
d375e7d5
BS
19};
20
264ce192
BS
21int nouveau_fence_new(struct nouveau_channel *, bool sysmem,
22 struct nouveau_fence **);
d375e7d5
BS
23void nouveau_fence_unref(struct nouveau_fence **);
24
25int nouveau_fence_emit(struct nouveau_fence *, struct nouveau_channel *);
26bool nouveau_fence_done(struct nouveau_fence *);
f2c24b83 27void nouveau_fence_work(struct fence *, void (*)(void *), void *);
d375e7d5 28int nouveau_fence_wait(struct nouveau_fence *, bool lazy, bool intr);
e3be4c23 29int nouveau_fence_sync(struct nouveau_bo *, struct nouveau_channel *, bool exclusive, bool intr);
d375e7d5 30
5e120f6e 31struct nouveau_fence_chan {
29ba89b2 32 spinlock_t lock;
15a996bb
ML
33 struct kref fence_ref;
34
5e120f6e 35 struct list_head pending;
f589be88
BS
36 struct list_head flip;
37
827520ce
BS
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
5e120f6e 45 u32 sequence;
29ba89b2 46 u32 context;
15a996bb 47 char name[32];
29ba89b2
ML
48
49 struct nvif_notify notify;
0ec5f02f 50 int notify_ref, dead;
5e120f6e
BS
51};
52
53struct nouveau_fence_priv {
ebb945a9
BS
54 void (*dtor)(struct nouveau_drm *);
55 bool (*suspend)(struct nouveau_drm *);
56 void (*resume)(struct nouveau_drm *);
e193b1d4
BS
57 int (*context_new)(struct nouveau_channel *);
58 void (*context_del)(struct nouveau_channel *);
e18c080f 59
29ba89b2 60 u32 contexts, context_base;
e18c080f 61 bool uevent;
5e120f6e
BS
62};
63
ebb945a9
BS
64#define nouveau_fence(drm) ((struct nouveau_fence_priv *)(drm)->fence)
65
29ba89b2 66void nouveau_fence_context_new(struct nouveau_channel *, struct nouveau_fence_chan *);
5e120f6e 67void nouveau_fence_context_del(struct nouveau_fence_chan *);
15a996bb 68void nouveau_fence_context_free(struct nouveau_fence_chan *);
5e120f6e 69
ebb945a9 70int nv04_fence_create(struct nouveau_drm *);
5e120f6e
BS
71int nv04_fence_mthd(struct nouveau_channel *, u32, u32, u32);
72
f589be88
BS
73int nv10_fence_emit(struct nouveau_fence *);
74int nv17_fence_sync(struct nouveau_fence *, struct nouveau_channel *,
75 struct nouveau_channel *);
76u32 nv10_fence_read(struct nouveau_channel *);
77void nv10_fence_context_del(struct nouveau_channel *);
ebb945a9
BS
78void nv10_fence_destroy(struct nouveau_drm *);
79int nv10_fence_create(struct nouveau_drm *);
60e5cb79
BS
80
81int nv17_fence_create(struct nouveau_drm *);
f20ebd03 82void nv17_fence_resume(struct nouveau_drm *drm);
f589be88 83
ebb945a9
BS
84int nv50_fence_create(struct nouveau_drm *);
85int nv84_fence_create(struct nouveau_drm *);
86int nvc0_fence_create(struct nouveau_drm *);
f589be88 87
898a2b32 88int nouveau_flip_complete(struct nvif_notify *);
5e120f6e 89
a34caf78
BS
90struct nv84_fence_chan {
91 struct nouveau_fence_chan base;
be83cd4e
BS
92 struct nvkm_vma vma;
93 struct nvkm_vma vma_gart;
94 struct nvkm_vma dispc_vma[4];
a34caf78
BS
95};
96
97struct nv84_fence_priv {
98 struct nouveau_fence_priv base;
99 struct nouveau_bo *bo;
264ce192 100 struct nouveau_bo *bo_gart;
a34caf78
BS
101 u32 *suspend;
102};
103
104u64 nv84_fence_crtc(struct nouveau_channel *, int);
a34caf78 105int nv84_fence_context_new(struct nouveau_channel *);
a34caf78 106
d375e7d5 107#endif