Ben Skeggs | d375e7d5 | 2012-04-30 13:30:00 +1000 | [diff] [blame] | 1 | #ifndef __NOUVEAU_FENCE_H__ |
| 2 | #define __NOUVEAU_FENCE_H__ |
| 3 | |
Maarten Lankhorst | 29ba89b | 2014-01-09 11:03:11 +0100 | [diff] [blame] | 4 | #include <linux/fence.h> |
| 5 | #include <nvif/notify.h> |
| 6 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 7 | struct nouveau_drm; |
Maarten Lankhorst | 29ba89b | 2014-01-09 11:03:11 +0100 | [diff] [blame] | 8 | struct nouveau_bo; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 9 | |
Ben Skeggs | d375e7d5 | 2012-04-30 13:30:00 +1000 | [diff] [blame] | 10 | struct nouveau_fence { |
Maarten Lankhorst | 29ba89b | 2014-01-09 11:03:11 +0100 | [diff] [blame] | 11 | struct fence base; |
| 12 | |
Ben Skeggs | d375e7d5 | 2012-04-30 13:30:00 +1000 | [diff] [blame] | 13 | struct list_head head; |
Ben Skeggs | d375e7d5 | 2012-04-30 13:30:00 +1000 | [diff] [blame] | 14 | |
Ben Skeggs | 264ce19 | 2013-02-14 13:43:21 +1000 | [diff] [blame] | 15 | bool sysmem; |
| 16 | |
Ben Skeggs | d375e7d5 | 2012-04-30 13:30:00 +1000 | [diff] [blame] | 17 | struct nouveau_channel *channel; |
| 18 | unsigned long timeout; |
Ben Skeggs | d375e7d5 | 2012-04-30 13:30:00 +1000 | [diff] [blame] | 19 | }; |
| 20 | |
Ben Skeggs | 264ce19 | 2013-02-14 13:43:21 +1000 | [diff] [blame] | 21 | int nouveau_fence_new(struct nouveau_channel *, bool sysmem, |
| 22 | struct nouveau_fence **); |
Ben Skeggs | d375e7d5 | 2012-04-30 13:30:00 +1000 | [diff] [blame] | 23 | void nouveau_fence_unref(struct nouveau_fence **); |
| 24 | |
| 25 | int nouveau_fence_emit(struct nouveau_fence *, struct nouveau_channel *); |
| 26 | bool nouveau_fence_done(struct nouveau_fence *); |
Maarten Lankhorst | f2c24b8 | 2014-04-02 17:14:48 +0200 | [diff] [blame] | 27 | void nouveau_fence_work(struct fence *, void (*)(void *), void *); |
Ben Skeggs | d375e7d5 | 2012-04-30 13:30:00 +1000 | [diff] [blame] | 28 | int nouveau_fence_wait(struct nouveau_fence *, bool lazy, bool intr); |
Maarten Lankhorst | e3be4c2 | 2014-09-16 11:15:07 +0200 | [diff] [blame] | 29 | int nouveau_fence_sync(struct nouveau_bo *, struct nouveau_channel *, bool exclusive, bool intr); |
Ben Skeggs | d375e7d5 | 2012-04-30 13:30:00 +1000 | [diff] [blame] | 30 | |
Ben Skeggs | 5e120f6 | 2012-04-30 13:55:29 +1000 | [diff] [blame] | 31 | struct nouveau_fence_chan { |
Maarten Lankhorst | 29ba89b | 2014-01-09 11:03:11 +0100 | [diff] [blame] | 32 | spinlock_t lock; |
Maarten Lankhorst | 15a996b | 2014-09-29 10:06:18 +0200 | [diff] [blame^] | 33 | struct kref fence_ref; |
| 34 | |
Ben Skeggs | 5e120f6 | 2012-04-30 13:55:29 +1000 | [diff] [blame] | 35 | struct list_head pending; |
Ben Skeggs | f589be8 | 2012-07-22 11:55:54 +1000 | [diff] [blame] | 36 | struct list_head flip; |
| 37 | |
Ben Skeggs | 827520c | 2013-02-14 13:20:17 +1000 | [diff] [blame] | 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 | |
Ben Skeggs | 5e120f6 | 2012-04-30 13:55:29 +1000 | [diff] [blame] | 45 | u32 sequence; |
Maarten Lankhorst | 29ba89b | 2014-01-09 11:03:11 +0100 | [diff] [blame] | 46 | u32 context; |
Maarten Lankhorst | 15a996b | 2014-09-29 10:06:18 +0200 | [diff] [blame^] | 47 | char name[32]; |
Maarten Lankhorst | 29ba89b | 2014-01-09 11:03:11 +0100 | [diff] [blame] | 48 | |
| 49 | struct nvif_notify notify; |
| 50 | int notify_ref; |
Ben Skeggs | 5e120f6 | 2012-04-30 13:55:29 +1000 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | struct nouveau_fence_priv { |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 54 | void (*dtor)(struct nouveau_drm *); |
| 55 | bool (*suspend)(struct nouveau_drm *); |
| 56 | void (*resume)(struct nouveau_drm *); |
Ben Skeggs | e193b1d | 2012-07-19 10:51:42 +1000 | [diff] [blame] | 57 | int (*context_new)(struct nouveau_channel *); |
| 58 | void (*context_del)(struct nouveau_channel *); |
Ben Skeggs | e18c080 | 2013-01-31 14:57:33 +1000 | [diff] [blame] | 59 | |
Maarten Lankhorst | 29ba89b | 2014-01-09 11:03:11 +0100 | [diff] [blame] | 60 | u32 contexts, context_base; |
Ben Skeggs | e18c080 | 2013-01-31 14:57:33 +1000 | [diff] [blame] | 61 | bool uevent; |
Ben Skeggs | 5e120f6 | 2012-04-30 13:55:29 +1000 | [diff] [blame] | 62 | }; |
| 63 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 64 | #define nouveau_fence(drm) ((struct nouveau_fence_priv *)(drm)->fence) |
| 65 | |
Maarten Lankhorst | 29ba89b | 2014-01-09 11:03:11 +0100 | [diff] [blame] | 66 | void nouveau_fence_context_new(struct nouveau_channel *, struct nouveau_fence_chan *); |
Ben Skeggs | 5e120f6 | 2012-04-30 13:55:29 +1000 | [diff] [blame] | 67 | void nouveau_fence_context_del(struct nouveau_fence_chan *); |
Maarten Lankhorst | 15a996b | 2014-09-29 10:06:18 +0200 | [diff] [blame^] | 68 | void nouveau_fence_context_free(struct nouveau_fence_chan *); |
Ben Skeggs | 5e120f6 | 2012-04-30 13:55:29 +1000 | [diff] [blame] | 69 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 70 | int nv04_fence_create(struct nouveau_drm *); |
Ben Skeggs | 5e120f6 | 2012-04-30 13:55:29 +1000 | [diff] [blame] | 71 | int nv04_fence_mthd(struct nouveau_channel *, u32, u32, u32); |
| 72 | |
Ben Skeggs | f589be8 | 2012-07-22 11:55:54 +1000 | [diff] [blame] | 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 *); |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 78 | void nv10_fence_destroy(struct nouveau_drm *); |
| 79 | int nv10_fence_create(struct nouveau_drm *); |
Ben Skeggs | 60e5cb7 | 2013-02-14 12:59:36 +1000 | [diff] [blame] | 80 | |
| 81 | int nv17_fence_create(struct nouveau_drm *); |
Marcin Slusarz | f20ebd0 | 2012-12-25 18:13:22 +0100 | [diff] [blame] | 82 | void nv17_fence_resume(struct nouveau_drm *drm); |
Ben Skeggs | f589be8 | 2012-07-22 11:55:54 +1000 | [diff] [blame] | 83 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 84 | int nv50_fence_create(struct nouveau_drm *); |
| 85 | int nv84_fence_create(struct nouveau_drm *); |
| 86 | int nvc0_fence_create(struct nouveau_drm *); |
Ben Skeggs | f589be8 | 2012-07-22 11:55:54 +1000 | [diff] [blame] | 87 | |
| 88 | int nouveau_flip_complete(void *chan); |
Ben Skeggs | 5e120f6 | 2012-04-30 13:55:29 +1000 | [diff] [blame] | 89 | |
Ben Skeggs | a34caf7 | 2013-02-14 09:28:37 +1000 | [diff] [blame] | 90 | struct nv84_fence_chan { |
| 91 | struct nouveau_fence_chan base; |
| 92 | struct nouveau_vma vma; |
Ben Skeggs | 264ce19 | 2013-02-14 13:43:21 +1000 | [diff] [blame] | 93 | struct nouveau_vma vma_gart; |
Ben Skeggs | a34caf7 | 2013-02-14 09:28:37 +1000 | [diff] [blame] | 94 | struct nouveau_vma dispc_vma[4]; |
| 95 | }; |
| 96 | |
| 97 | struct nv84_fence_priv { |
| 98 | struct nouveau_fence_priv base; |
| 99 | struct nouveau_bo *bo; |
Ben Skeggs | 264ce19 | 2013-02-14 13:43:21 +1000 | [diff] [blame] | 100 | struct nouveau_bo *bo_gart; |
Ben Skeggs | a34caf7 | 2013-02-14 09:28:37 +1000 | [diff] [blame] | 101 | u32 *suspend; |
| 102 | }; |
| 103 | |
| 104 | u64 nv84_fence_crtc(struct nouveau_channel *, int); |
Ben Skeggs | a34caf7 | 2013-02-14 09:28:37 +1000 | [diff] [blame] | 105 | int nv84_fence_context_new(struct nouveau_channel *); |
Ben Skeggs | a34caf7 | 2013-02-14 09:28:37 +1000 | [diff] [blame] | 106 | |
Ben Skeggs | d375e7d5 | 2012-04-30 13:30:00 +1000 | [diff] [blame] | 107 | #endif |