aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2013-02-13 18:37:35 -0500
committerBen Skeggs <bskeggs@redhat.com>2013-02-20 01:00:52 -0500
commitbba9852feedf3d38f963278e07bdd3db622090b9 (patch)
treea7a62aee22165a817c43caccabf14940bdfdf820
parenta34caf78f26bda63869471cb3f46f354f4658758 (diff)
drm/nv84-/fence: abstract class emit/sync functions to virt+sequence
Now can be used to operate on any buffer mapped into the GPU virtual address and not just the main inter-channel sync buffer. Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_fence.h5
-rw-r--r--drivers/gpu/drm/nouveau/nv84_fence.c58
-rw-r--r--drivers/gpu/drm/nouveau/nvc0_fence.c40
3 files changed, 53 insertions, 50 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.h b/drivers/gpu/drm/nouveau/nouveau_fence.h
index 2324911fc4c3..f1f0c6dfc3e8 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fence.h
+++ b/drivers/gpu/drm/nouveau/nouveau_fence.h
@@ -39,7 +39,9 @@ struct nouveau_fence_priv {
39 void (*resume)(struct nouveau_drm *); 39 void (*resume)(struct nouveau_drm *);
40 int (*context_new)(struct nouveau_channel *); 40 int (*context_new)(struct nouveau_channel *);
41 void (*context_del)(struct nouveau_channel *); 41 void (*context_del)(struct nouveau_channel *);
42 int (*emit32)(struct nouveau_channel *, u64, u32);
42 int (*emit)(struct nouveau_fence *); 43 int (*emit)(struct nouveau_fence *);
44 int (*sync32)(struct nouveau_channel *, u64, u32);
43 int (*sync)(struct nouveau_fence *, struct nouveau_channel *, 45 int (*sync)(struct nouveau_fence *, struct nouveau_channel *,
44 struct nouveau_channel *); 46 struct nouveau_channel *);
45 u32 (*read)(struct nouveau_channel *); 47 u32 (*read)(struct nouveau_channel *);
@@ -84,6 +86,9 @@ struct nv84_fence_priv {
84}; 86};
85 87
86u64 nv84_fence_crtc(struct nouveau_channel *, int); 88u64 nv84_fence_crtc(struct nouveau_channel *, int);
89int nv84_fence_emit(struct nouveau_fence *);
90int nv84_fence_sync(struct nouveau_fence *, struct nouveau_channel *,
91 struct nouveau_channel *);
87u32 nv84_fence_read(struct nouveau_channel *); 92u32 nv84_fence_read(struct nouveau_channel *);
88int nv84_fence_context_new(struct nouveau_channel *); 93int nv84_fence_context_new(struct nouveau_channel *);
89void nv84_fence_context_del(struct nouveau_channel *); 94void nv84_fence_context_del(struct nouveau_channel *);
diff --git a/drivers/gpu/drm/nouveau/nv84_fence.c b/drivers/gpu/drm/nouveau/nv84_fence.c
index 58c2401b18ff..8a80ad7c0cf5 100644
--- a/drivers/gpu/drm/nouveau/nv84_fence.c
+++ b/drivers/gpu/drm/nouveau/nv84_fence.c
@@ -42,54 +42,62 @@ nv84_fence_crtc(struct nouveau_channel *chan, int crtc)
42} 42}
43 43
44static int 44static int
45nv84_fence_emit(struct nouveau_fence *fence) 45nv84_fence_emit32(struct nouveau_channel *chan, u64 virtual, u32 sequence)
46{ 46{
47 struct nouveau_channel *chan = fence->channel; 47 int ret = RING_SPACE(chan, 8);
48 struct nv84_fence_chan *fctx = chan->fence;
49 struct nouveau_fifo_chan *fifo = (void *)chan->object;
50 u64 addr = fctx->vma.offset + fifo->chid * 16;
51 int ret;
52
53 ret = RING_SPACE(chan, 8);
54 if (ret == 0) { 48 if (ret == 0) {
55 BEGIN_NV04(chan, 0, NV11_SUBCHAN_DMA_SEMAPHORE, 1); 49 BEGIN_NV04(chan, 0, NV11_SUBCHAN_DMA_SEMAPHORE, 1);
56 OUT_RING (chan, chan->vram); 50 OUT_RING (chan, chan->vram);
57 BEGIN_NV04(chan, 0, NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH, 5); 51 BEGIN_NV04(chan, 0, NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH, 5);
58 OUT_RING (chan, upper_32_bits(addr)); 52 OUT_RING (chan, upper_32_bits(virtual));
59 OUT_RING (chan, lower_32_bits(addr)); 53 OUT_RING (chan, lower_32_bits(virtual));
60 OUT_RING (chan, fence->sequence); 54 OUT_RING (chan, sequence);
61 OUT_RING (chan, NV84_SUBCHAN_SEMAPHORE_TRIGGER_WRITE_LONG); 55 OUT_RING (chan, NV84_SUBCHAN_SEMAPHORE_TRIGGER_WRITE_LONG);
62 OUT_RING (chan, 0x00000000); 56 OUT_RING (chan, 0x00000000);
63 FIRE_RING (chan); 57 FIRE_RING (chan);
64 } 58 }
65
66 return ret; 59 return ret;
67} 60}
68 61
69static int 62static int
70nv84_fence_sync(struct nouveau_fence *fence, 63nv84_fence_sync32(struct nouveau_channel *chan, u64 virtual, u32 sequence)
71 struct nouveau_channel *prev, struct nouveau_channel *chan)
72{ 64{
73 struct nv84_fence_chan *fctx = chan->fence; 65 int ret = RING_SPACE(chan, 7);
74 struct nouveau_fifo_chan *fifo = (void *)prev->object;
75 u64 addr = fctx->vma.offset + fifo->chid * 16;
76 int ret;
77
78 ret = RING_SPACE(chan, 7);
79 if (ret == 0) { 66 if (ret == 0) {
80 BEGIN_NV04(chan, 0, NV11_SUBCHAN_DMA_SEMAPHORE, 1); 67 BEGIN_NV04(chan, 0, NV11_SUBCHAN_DMA_SEMAPHORE, 1);
81 OUT_RING (chan, chan->vram); 68 OUT_RING (chan, chan->vram);
82 BEGIN_NV04(chan, 0, NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH, 4); 69 BEGIN_NV04(chan, 0, NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH, 4);
83 OUT_RING (chan, upper_32_bits(addr)); 70 OUT_RING (chan, upper_32_bits(virtual));
84 OUT_RING (chan, lower_32_bits(addr)); 71 OUT_RING (chan, lower_32_bits(virtual));
85 OUT_RING (chan, fence->sequence); 72 OUT_RING (chan, sequence);
86 OUT_RING (chan, NV84_SUBCHAN_SEMAPHORE_TRIGGER_ACQUIRE_GEQUAL); 73 OUT_RING (chan, NV84_SUBCHAN_SEMAPHORE_TRIGGER_ACQUIRE_GEQUAL);
87 FIRE_RING (chan); 74 FIRE_RING (chan);
88 } 75 }
89
90 return ret; 76 return ret;
91} 77}
92 78
79int
80nv84_fence_emit(struct nouveau_fence *fence)
81{
82 struct nouveau_channel *chan = fence->channel;
83 struct nv84_fence_priv *priv = chan->drm->fence;
84 struct nv84_fence_chan *fctx = chan->fence;
85 struct nouveau_fifo_chan *fifo = (void *)chan->object;
86 u64 addr = fctx->vma.offset + fifo->chid * 16;
87 return priv->base.emit32(chan, addr, fence->sequence);
88}
89
90int
91nv84_fence_sync(struct nouveau_fence *fence,
92 struct nouveau_channel *prev, struct nouveau_channel *chan)
93{
94 struct nv84_fence_priv *priv = chan->drm->fence;
95 struct nv84_fence_chan *fctx = chan->fence;
96 struct nouveau_fifo_chan *fifo = (void *)prev->object;
97 u64 addr = fctx->vma.offset + fifo->chid * 16;
98 return priv->base.sync32(chan, addr, fence->sequence);
99}
100
93u32 101u32
94nv84_fence_read(struct nouveau_channel *chan) 102nv84_fence_read(struct nouveau_channel *chan)
95{ 103{
@@ -205,7 +213,9 @@ nv84_fence_create(struct nouveau_drm *drm)
205 priv->base.resume = nv84_fence_resume; 213 priv->base.resume = nv84_fence_resume;
206 priv->base.context_new = nv84_fence_context_new; 214 priv->base.context_new = nv84_fence_context_new;
207 priv->base.context_del = nv84_fence_context_del; 215 priv->base.context_del = nv84_fence_context_del;
216 priv->base.emit32 = nv84_fence_emit32;
208 priv->base.emit = nv84_fence_emit; 217 priv->base.emit = nv84_fence_emit;
218 priv->base.sync32 = nv84_fence_sync32;
209 priv->base.sync = nv84_fence_sync; 219 priv->base.sync = nv84_fence_sync;
210 priv->base.read = nv84_fence_read; 220 priv->base.read = nv84_fence_read;
211 221
diff --git a/drivers/gpu/drm/nouveau/nvc0_fence.c b/drivers/gpu/drm/nouveau/nvc0_fence.c
index e4c4ead24805..8213f7de92fa 100644
--- a/drivers/gpu/drm/nouveau/nvc0_fence.c
+++ b/drivers/gpu/drm/nouveau/nvc0_fence.c
@@ -35,48 +35,34 @@
35#include "nv50_display.h" 35#include "nv50_display.h"
36 36
37static int 37static int
38nvc0_fence_emit(struct nouveau_fence *fence) 38nvc0_fence_emit32(struct nouveau_channel *chan, u64 virtual, u32 sequence)
39{ 39{
40 struct nouveau_channel *chan = fence->channel; 40 int ret = RING_SPACE(chan, 6);
41 struct nv84_fence_chan *fctx = chan->fence;
42 struct nouveau_fifo_chan *fifo = (void *)chan->object;
43 u64 addr = fctx->vma.offset + fifo->chid * 16;
44 int ret;
45
46 ret = RING_SPACE(chan, 6);
47 if (ret == 0) { 41 if (ret == 0) {
48 BEGIN_NVC0(chan, 0, NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH, 5); 42 BEGIN_NVC0(chan, 0, NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH, 5);
49 OUT_RING (chan, upper_32_bits(addr)); 43 OUT_RING (chan, upper_32_bits(virtual));
50 OUT_RING (chan, lower_32_bits(addr)); 44 OUT_RING (chan, lower_32_bits(virtual));
51 OUT_RING (chan, fence->sequence); 45 OUT_RING (chan, sequence);
52 OUT_RING (chan, NV84_SUBCHAN_SEMAPHORE_TRIGGER_WRITE_LONG); 46 OUT_RING (chan, NV84_SUBCHAN_SEMAPHORE_TRIGGER_WRITE_LONG);
53 OUT_RING (chan, 0x00000000); 47 OUT_RING (chan, 0x00000000);
54 FIRE_RING (chan); 48 FIRE_RING (chan);
55 } 49 }
56
57 return ret; 50 return ret;
58} 51}
59 52
60static int 53static int
61nvc0_fence_sync(struct nouveau_fence *fence, 54nvc0_fence_sync32(struct nouveau_channel *chan, u64 virtual, u32 sequence)
62 struct nouveau_channel *prev, struct nouveau_channel *chan)
63{ 55{
64 struct nv84_fence_chan *fctx = chan->fence; 56 int ret = RING_SPACE(chan, 5);
65 struct nouveau_fifo_chan *fifo = (void *)prev->object;
66 u64 addr = fctx->vma.offset + fifo->chid * 16;
67 int ret;
68
69 ret = RING_SPACE(chan, 5);
70 if (ret == 0) { 57 if (ret == 0) {
71 BEGIN_NVC0(chan, 0, NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH, 4); 58 BEGIN_NVC0(chan, 0, NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH, 4);
72 OUT_RING (chan, upper_32_bits(addr)); 59 OUT_RING (chan, upper_32_bits(virtual));
73 OUT_RING (chan, lower_32_bits(addr)); 60 OUT_RING (chan, lower_32_bits(virtual));
74 OUT_RING (chan, fence->sequence); 61 OUT_RING (chan, sequence);
75 OUT_RING (chan, NV84_SUBCHAN_SEMAPHORE_TRIGGER_ACQUIRE_GEQUAL | 62 OUT_RING (chan, NV84_SUBCHAN_SEMAPHORE_TRIGGER_ACQUIRE_GEQUAL |
76 NVC0_SUBCHAN_SEMAPHORE_TRIGGER_YIELD); 63 NVC0_SUBCHAN_SEMAPHORE_TRIGGER_YIELD);
77 FIRE_RING (chan); 64 FIRE_RING (chan);
78 } 65 }
79
80 return ret; 66 return ret;
81} 67}
82 68
@@ -96,8 +82,10 @@ nvc0_fence_create(struct nouveau_drm *drm)
96 priv->base.resume = nv84_fence_resume; 82 priv->base.resume = nv84_fence_resume;
97 priv->base.context_new = nv84_fence_context_new; 83 priv->base.context_new = nv84_fence_context_new;
98 priv->base.context_del = nv84_fence_context_del; 84 priv->base.context_del = nv84_fence_context_del;
99 priv->base.emit = nvc0_fence_emit; 85 priv->base.emit32 = nvc0_fence_emit32;
100 priv->base.sync = nvc0_fence_sync; 86 priv->base.emit = nv84_fence_emit;
87 priv->base.sync32 = nvc0_fence_sync32;
88 priv->base.sync = nv84_fence_sync;
101 priv->base.read = nv84_fence_read; 89 priv->base.read = nv84_fence_read;
102 90
103 init_waitqueue_head(&priv->base.waiting); 91 init_waitqueue_head(&priv->base.waiting);