blob: 943b0b17b1fc760296eccea9b409f03696a644fc [file] [log] [blame]
Ben Skeggsd375e7d52012-04-30 13:30:00 +10001#ifndef __NOUVEAU_FENCE_H__
2#define __NOUVEAU_FENCE_H__
3
Maarten Lankhorst29ba89b2014-01-09 11:03:11 +01004#include <linux/fence.h>
5#include <nvif/notify.h>
6
Ben Skeggsebb945a2012-07-20 08:17:34 +10007struct nouveau_drm;
Maarten Lankhorst29ba89b2014-01-09 11:03:11 +01008struct nouveau_bo;
Ben Skeggsebb945a2012-07-20 08:17:34 +10009
Ben Skeggsd375e7d52012-04-30 13:30:00 +100010struct nouveau_fence {
Maarten Lankhorst29ba89b2014-01-09 11:03:11 +010011 struct fence base;
12
Ben Skeggsd375e7d52012-04-30 13:30:00 +100013 struct list_head head;
Ben Skeggsd375e7d52012-04-30 13:30:00 +100014
Ben Skeggs264ce192013-02-14 13:43:21 +100015 bool sysmem;
16
Ben Skeggsd375e7d52012-04-30 13:30:00 +100017 struct nouveau_channel *channel;
18 unsigned long timeout;
Ben Skeggsd375e7d52012-04-30 13:30:00 +100019};
20
Ben Skeggs264ce192013-02-14 13:43:21 +100021int nouveau_fence_new(struct nouveau_channel *, bool sysmem,
22 struct nouveau_fence **);
Ben Skeggsd375e7d52012-04-30 13:30:00 +100023void nouveau_fence_unref(struct nouveau_fence **);
24
25int nouveau_fence_emit(struct nouveau_fence *, struct nouveau_channel *);
26bool nouveau_fence_done(struct nouveau_fence *);
Maarten Lankhorstf2c24b82014-04-02 17:14:48 +020027void nouveau_fence_work(struct fence *, void (*)(void *), void *);
Ben Skeggsd375e7d52012-04-30 13:30:00 +100028int nouveau_fence_wait(struct nouveau_fence *, bool lazy, bool intr);
Maarten Lankhorste3be4c22014-09-16 11:15:07 +020029int nouveau_fence_sync(struct nouveau_bo *, struct nouveau_channel *, bool exclusive, bool intr);
Ben Skeggsd375e7d52012-04-30 13:30:00 +100030
Ben Skeggs5e120f62012-04-30 13:55:29 +100031struct nouveau_fence_chan {
Maarten Lankhorst29ba89b2014-01-09 11:03:11 +010032 spinlock_t lock;
Maarten Lankhorst15a996b2014-09-29 10:06:18 +020033 struct kref fence_ref;
34
Ben Skeggs5e120f62012-04-30 13:55:29 +100035 struct list_head pending;
Ben Skeggsf589be82012-07-22 11:55:54 +100036 struct list_head flip;
37
Ben Skeggs827520c2013-02-14 13:20:17 +100038 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
Ben Skeggs5e120f62012-04-30 13:55:29 +100045 u32 sequence;
Maarten Lankhorst29ba89b2014-01-09 11:03:11 +010046 u32 context;
Maarten Lankhorst15a996b2014-09-29 10:06:18 +020047 char name[32];
Maarten Lankhorst29ba89b2014-01-09 11:03:11 +010048
49 struct nvif_notify notify;
50 int notify_ref;
Ben Skeggs5e120f62012-04-30 13:55:29 +100051};
52
53struct nouveau_fence_priv {
Ben Skeggsebb945a2012-07-20 08:17:34 +100054 void (*dtor)(struct nouveau_drm *);
55 bool (*suspend)(struct nouveau_drm *);
56 void (*resume)(struct nouveau_drm *);
Ben Skeggse193b1d2012-07-19 10:51:42 +100057 int (*context_new)(struct nouveau_channel *);
58 void (*context_del)(struct nouveau_channel *);
Ben Skeggse18c0802013-01-31 14:57:33 +100059
Maarten Lankhorst29ba89b2014-01-09 11:03:11 +010060 u32 contexts, context_base;
Ben Skeggse18c0802013-01-31 14:57:33 +100061 bool uevent;
Ben Skeggs5e120f62012-04-30 13:55:29 +100062};
63
Ben Skeggsebb945a2012-07-20 08:17:34 +100064#define nouveau_fence(drm) ((struct nouveau_fence_priv *)(drm)->fence)
65
Maarten Lankhorst29ba89b2014-01-09 11:03:11 +010066void nouveau_fence_context_new(struct nouveau_channel *, struct nouveau_fence_chan *);
Ben Skeggs5e120f62012-04-30 13:55:29 +100067void nouveau_fence_context_del(struct nouveau_fence_chan *);
Maarten Lankhorst15a996b2014-09-29 10:06:18 +020068void nouveau_fence_context_free(struct nouveau_fence_chan *);
Ben Skeggs5e120f62012-04-30 13:55:29 +100069
Ben Skeggsebb945a2012-07-20 08:17:34 +100070int nv04_fence_create(struct nouveau_drm *);
Ben Skeggs5e120f62012-04-30 13:55:29 +100071int nv04_fence_mthd(struct nouveau_channel *, u32, u32, u32);
72
Ben Skeggsf589be82012-07-22 11:55:54 +100073int 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 *);
Ben Skeggsebb945a2012-07-20 08:17:34 +100078void nv10_fence_destroy(struct nouveau_drm *);
79int nv10_fence_create(struct nouveau_drm *);
Ben Skeggs60e5cb72013-02-14 12:59:36 +100080
81int nv17_fence_create(struct nouveau_drm *);
Marcin Slusarzf20ebd02012-12-25 18:13:22 +010082void nv17_fence_resume(struct nouveau_drm *drm);
Ben Skeggsf589be82012-07-22 11:55:54 +100083
Ben Skeggsebb945a2012-07-20 08:17:34 +100084int nv50_fence_create(struct nouveau_drm *);
85int nv84_fence_create(struct nouveau_drm *);
86int nvc0_fence_create(struct nouveau_drm *);
Ben Skeggsf589be82012-07-22 11:55:54 +100087
88int nouveau_flip_complete(void *chan);
Ben Skeggs5e120f62012-04-30 13:55:29 +100089
Ben Skeggsa34caf72013-02-14 09:28:37 +100090struct nv84_fence_chan {
91 struct nouveau_fence_chan base;
92 struct nouveau_vma vma;
Ben Skeggs264ce192013-02-14 13:43:21 +100093 struct nouveau_vma vma_gart;
Ben Skeggsa34caf72013-02-14 09:28:37 +100094 struct nouveau_vma dispc_vma[4];
95};
96
97struct nv84_fence_priv {
98 struct nouveau_fence_priv base;
99 struct nouveau_bo *bo;
Ben Skeggs264ce192013-02-14 13:43:21 +1000100 struct nouveau_bo *bo_gart;
Ben Skeggsa34caf72013-02-14 09:28:37 +1000101 u32 *suspend;
102};
103
104u64 nv84_fence_crtc(struct nouveau_channel *, int);
Ben Skeggsa34caf72013-02-14 09:28:37 +1000105int nv84_fence_context_new(struct nouveau_channel *);
Ben Skeggsa34caf72013-02-14 09:28:37 +1000106
Ben Skeggsd375e7d52012-04-30 13:30:00 +1000107#endif