blob: d32e58b66a7558049c7ad9e6dd6e0a6a24d8f902 [file] [log] [blame]
Ben Skeggsd375e7d52012-04-30 13:30:00 +10001#ifndef __NOUVEAU_FENCE_H__
2#define __NOUVEAU_FENCE_H__
3
Chris Wilsonf54d1862016-10-25 13:00:45 +01004#include <linux/dma-fence.h>
Maarten Lankhorst29ba89b2014-01-09 11:03:11 +01005#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 {
Chris Wilsonf54d1862016-10-25 13:00:45 +010011 struct dma_fence base;
Maarten Lankhorst29ba89b2014-01-09 11:03:11 +010012
Ben Skeggsd375e7d52012-04-30 13:30:00 +100013 struct list_head head;
Ben Skeggsd375e7d52012-04-30 13:30:00 +100014
Maarten Lankhorst0ec5f022014-12-01 19:11:06 +100015 struct nouveau_channel __rcu *channel;
Ben Skeggsd375e7d52012-04-30 13:30:00 +100016 unsigned long timeout;
Ben Skeggsd375e7d52012-04-30 13:30:00 +100017};
18
Ben Skeggs264ce192013-02-14 13:43:21 +100019int nouveau_fence_new(struct nouveau_channel *, bool sysmem,
20 struct nouveau_fence **);
Ben Skeggsd375e7d52012-04-30 13:30:00 +100021void nouveau_fence_unref(struct nouveau_fence **);
22
23int nouveau_fence_emit(struct nouveau_fence *, struct nouveau_channel *);
24bool nouveau_fence_done(struct nouveau_fence *);
Chris Wilsonf54d1862016-10-25 13:00:45 +010025void nouveau_fence_work(struct dma_fence *, void (*)(void *), void *);
Ben Skeggsd375e7d52012-04-30 13:30:00 +100026int nouveau_fence_wait(struct nouveau_fence *, bool lazy, bool intr);
Maarten Lankhorste3be4c22014-09-16 11:15:07 +020027int nouveau_fence_sync(struct nouveau_bo *, struct nouveau_channel *, bool exclusive, bool intr);
Ben Skeggsd375e7d52012-04-30 13:30:00 +100028
Ben Skeggs5e120f62012-04-30 13:55:29 +100029struct nouveau_fence_chan {
Maarten Lankhorst29ba89b2014-01-09 11:03:11 +010030 spinlock_t lock;
Maarten Lankhorst15a996b2014-09-29 10:06:18 +020031 struct kref fence_ref;
32
Ben Skeggs5e120f62012-04-30 13:55:29 +100033 struct list_head pending;
Ben Skeggsf589be82012-07-22 11:55:54 +100034 struct list_head flip;
35
Ben Skeggs827520c2013-02-14 13:20:17 +100036 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
Ben Skeggs5e120f62012-04-30 13:55:29 +100043 u32 sequence;
Maarten Lankhorst29ba89b2014-01-09 11:03:11 +010044 u32 context;
Maarten Lankhorst15a996b2014-09-29 10:06:18 +020045 char name[32];
Maarten Lankhorst29ba89b2014-01-09 11:03:11 +010046
47 struct nvif_notify notify;
Maarten Lankhorst0ec5f022014-12-01 19:11:06 +100048 int notify_ref, dead;
Ben Skeggs5e120f62012-04-30 13:55:29 +100049};
50
51struct nouveau_fence_priv {
Ben Skeggsebb945a2012-07-20 08:17:34 +100052 void (*dtor)(struct nouveau_drm *);
53 bool (*suspend)(struct nouveau_drm *);
54 void (*resume)(struct nouveau_drm *);
Ben Skeggse193b1d2012-07-19 10:51:42 +100055 int (*context_new)(struct nouveau_channel *);
56 void (*context_del)(struct nouveau_channel *);
Ben Skeggse18c0802013-01-31 14:57:33 +100057
Christian König76bf0db2016-06-01 15:10:02 +020058 u32 contexts;
59 u64 context_base;
Ben Skeggse18c0802013-01-31 14:57:33 +100060 bool uevent;
Ben Skeggs5e120f62012-04-30 13:55:29 +100061};
62
Ben Skeggsebb945a2012-07-20 08:17:34 +100063#define nouveau_fence(drm) ((struct nouveau_fence_priv *)(drm)->fence)
64
Maarten Lankhorst29ba89b2014-01-09 11:03:11 +010065void nouveau_fence_context_new(struct nouveau_channel *, struct nouveau_fence_chan *);
Ben Skeggs5e120f62012-04-30 13:55:29 +100066void nouveau_fence_context_del(struct nouveau_fence_chan *);
Maarten Lankhorst15a996b2014-09-29 10:06:18 +020067void nouveau_fence_context_free(struct nouveau_fence_chan *);
Ben Skeggs5e120f62012-04-30 13:55:29 +100068
Ben Skeggsebb945a2012-07-20 08:17:34 +100069int nv04_fence_create(struct nouveau_drm *);
Ben Skeggs5e120f62012-04-30 13:55:29 +100070int nv04_fence_mthd(struct nouveau_channel *, u32, u32, u32);
71
Ben Skeggsf589be82012-07-22 11:55:54 +100072int nv10_fence_emit(struct nouveau_fence *);
73int nv17_fence_sync(struct nouveau_fence *, struct nouveau_channel *,
74 struct nouveau_channel *);
75u32 nv10_fence_read(struct nouveau_channel *);
76void nv10_fence_context_del(struct nouveau_channel *);
Ben Skeggsebb945a2012-07-20 08:17:34 +100077void nv10_fence_destroy(struct nouveau_drm *);
78int nv10_fence_create(struct nouveau_drm *);
Ben Skeggs60e5cb72013-02-14 12:59:36 +100079
80int nv17_fence_create(struct nouveau_drm *);
Marcin Slusarzf20ebd02012-12-25 18:13:22 +010081void nv17_fence_resume(struct nouveau_drm *drm);
Ben Skeggsf589be82012-07-22 11:55:54 +100082
Ben Skeggsebb945a2012-07-20 08:17:34 +100083int nv50_fence_create(struct nouveau_drm *);
84int nv84_fence_create(struct nouveau_drm *);
85int nvc0_fence_create(struct nouveau_drm *);
Ben Skeggsf589be82012-07-22 11:55:54 +100086
Ben Skeggs898a2b32015-08-20 14:54:18 +100087int nouveau_flip_complete(struct nvif_notify *);
Ben Skeggs5e120f62012-04-30 13:55:29 +100088
Ben Skeggsa34caf72013-02-14 09:28:37 +100089struct nv84_fence_chan {
90 struct nouveau_fence_chan base;
Ben Skeggs24e83752017-11-01 03:56:19 +100091 struct nouveau_vma *vma;
Ben Skeggsa34caf72013-02-14 09:28:37 +100092};
93
94struct nv84_fence_priv {
95 struct nouveau_fence_priv base;
96 struct nouveau_bo *bo;
97 u32 *suspend;
Ben Skeggs96692b02016-12-14 09:52:39 +100098 struct mutex mutex;
Ben Skeggsa34caf72013-02-14 09:28:37 +100099};
100
Ben Skeggsa34caf72013-02-14 09:28:37 +1000101int nv84_fence_context_new(struct nouveau_channel *);
Ben Skeggsa34caf72013-02-14 09:28:37 +1000102
Ben Skeggsd375e7d52012-04-30 13:30:00 +1000103#endif