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