blob: fb0281ae8f90569508711a5edd275cea064da6df [file] [log] [blame]
Ben Skeggs6ee73862009-12-11 19:24:15 +10001/*
2 * Copyright (C) 2007 Ben Skeggs.
3 * All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial
15 * portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 *
25 */
26
27#include "drmP.h"
28#include "drm.h"
29#include "nouveau_drv.h"
30
Ben Skeggs6ee73862009-12-11 19:24:15 +100031static void
Ben Skeggsac94a342010-07-08 15:28:48 +100032nv50_fifo_playlist_update(struct drm_device *dev)
Ben Skeggs6ee73862009-12-11 19:24:15 +100033{
34 struct drm_nouveau_private *dev_priv = dev->dev_private;
Ben Skeggsac94a342010-07-08 15:28:48 +100035 struct nouveau_fifo_engine *pfifo = &dev_priv->engine.fifo;
Ben Skeggs6ee73862009-12-11 19:24:15 +100036 struct nouveau_gpuobj_ref *cur;
37 int i, nr;
38
39 NV_DEBUG(dev, "\n");
40
Ben Skeggsac94a342010-07-08 15:28:48 +100041 cur = pfifo->playlist[pfifo->cur_playlist];
42 pfifo->cur_playlist = !pfifo->cur_playlist;
Ben Skeggs6ee73862009-12-11 19:24:15 +100043
44 /* We never schedule channel 0 or 127 */
Ben Skeggs6ee73862009-12-11 19:24:15 +100045 for (i = 1, nr = 0; i < 127; i++) {
46 if (dev_priv->fifos[i] && dev_priv->fifos[i]->ramfc)
47 nv_wo32(dev, cur->gpuobj, nr++, i);
48 }
Ben Skeggsf56cb862010-07-08 11:29:10 +100049 dev_priv->engine.instmem.flush(dev);
Ben Skeggs6ee73862009-12-11 19:24:15 +100050
51 nv_wr32(dev, 0x32f4, cur->instance >> 12);
52 nv_wr32(dev, 0x32ec, nr);
53 nv_wr32(dev, 0x2500, 0x101);
54}
55
Ben Skeggsac94a342010-07-08 15:28:48 +100056static void
57nv50_fifo_channel_enable(struct drm_device *dev, int channel)
Ben Skeggs6ee73862009-12-11 19:24:15 +100058{
59 struct drm_nouveau_private *dev_priv = dev->dev_private;
60 struct nouveau_channel *chan = dev_priv->fifos[channel];
61 uint32_t inst;
62
63 NV_DEBUG(dev, "ch%d\n", channel);
64
Ben Skeggsac94a342010-07-08 15:28:48 +100065 if (dev_priv->chipset == 0x50)
Ben Skeggs6ee73862009-12-11 19:24:15 +100066 inst = chan->ramfc->instance >> 12;
67 else
68 inst = chan->ramfc->instance >> 8;
Ben Skeggs6ee73862009-12-11 19:24:15 +100069
Ben Skeggsac94a342010-07-08 15:28:48 +100070 nv_wr32(dev, NV50_PFIFO_CTX_TABLE(channel), inst |
71 NV50_PFIFO_CTX_TABLE_CHANNEL_ENABLED);
Ben Skeggs6ee73862009-12-11 19:24:15 +100072}
73
74static void
Ben Skeggsac94a342010-07-08 15:28:48 +100075nv50_fifo_channel_disable(struct drm_device *dev, int channel)
Ben Skeggs6ee73862009-12-11 19:24:15 +100076{
77 struct drm_nouveau_private *dev_priv = dev->dev_private;
78 uint32_t inst;
79
Ben Skeggsac94a342010-07-08 15:28:48 +100080 NV_DEBUG(dev, "ch%d\n", channel);
Ben Skeggs6ee73862009-12-11 19:24:15 +100081
Ben Skeggsac94a342010-07-08 15:28:48 +100082 if (dev_priv->chipset == 0x50)
Ben Skeggs6ee73862009-12-11 19:24:15 +100083 inst = NV50_PFIFO_CTX_TABLE_INSTANCE_MASK_G80;
84 else
85 inst = NV50_PFIFO_CTX_TABLE_INSTANCE_MASK_G84;
86 nv_wr32(dev, NV50_PFIFO_CTX_TABLE(channel), inst);
Ben Skeggs6ee73862009-12-11 19:24:15 +100087}
88
89static void
90nv50_fifo_init_reset(struct drm_device *dev)
91{
92 uint32_t pmc_e = NV_PMC_ENABLE_PFIFO;
93
94 NV_DEBUG(dev, "\n");
95
96 nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) & ~pmc_e);
97 nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) | pmc_e);
98}
99
100static void
101nv50_fifo_init_intr(struct drm_device *dev)
102{
103 NV_DEBUG(dev, "\n");
104
105 nv_wr32(dev, NV03_PFIFO_INTR_0, 0xFFFFFFFF);
106 nv_wr32(dev, NV03_PFIFO_INTR_EN_0, 0xFFFFFFFF);
107}
108
109static void
110nv50_fifo_init_context_table(struct drm_device *dev)
111{
112 struct drm_nouveau_private *dev_priv = dev->dev_private;
113 int i;
114
115 NV_DEBUG(dev, "\n");
116
117 for (i = 0; i < NV50_PFIFO_CTX_TABLE__SIZE; i++) {
118 if (dev_priv->fifos[i])
Ben Skeggsac94a342010-07-08 15:28:48 +1000119 nv50_fifo_channel_enable(dev, i);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000120 else
Ben Skeggsac94a342010-07-08 15:28:48 +1000121 nv50_fifo_channel_disable(dev, i);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000122 }
123
Ben Skeggsac94a342010-07-08 15:28:48 +1000124 nv50_fifo_playlist_update(dev);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000125}
126
127static void
128nv50_fifo_init_regs__nv(struct drm_device *dev)
129{
130 NV_DEBUG(dev, "\n");
131
132 nv_wr32(dev, 0x250c, 0x6f3cfc34);
133}
134
135static void
136nv50_fifo_init_regs(struct drm_device *dev)
137{
138 NV_DEBUG(dev, "\n");
139
140 nv_wr32(dev, 0x2500, 0);
141 nv_wr32(dev, 0x3250, 0);
142 nv_wr32(dev, 0x3220, 0);
143 nv_wr32(dev, 0x3204, 0);
144 nv_wr32(dev, 0x3210, 0);
145 nv_wr32(dev, 0x3270, 0);
146
147 /* Enable dummy channels setup by nv50_instmem.c */
Ben Skeggsac94a342010-07-08 15:28:48 +1000148 nv50_fifo_channel_enable(dev, 0);
149 nv50_fifo_channel_enable(dev, 127);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000150}
151
152int
153nv50_fifo_init(struct drm_device *dev)
154{
155 struct drm_nouveau_private *dev_priv = dev->dev_private;
Ben Skeggsac94a342010-07-08 15:28:48 +1000156 struct nouveau_fifo_engine *pfifo = &dev_priv->engine.fifo;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000157 int ret;
158
159 NV_DEBUG(dev, "\n");
160
Ben Skeggsac94a342010-07-08 15:28:48 +1000161 if (pfifo->playlist[0]) {
162 pfifo->cur_playlist = !pfifo->cur_playlist;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000163 goto just_reset;
164 }
165
Ben Skeggs6ee73862009-12-11 19:24:15 +1000166 ret = nouveau_gpuobj_new_ref(dev, NULL, NULL, 0, 128*4, 0x1000,
Ben Skeggsac94a342010-07-08 15:28:48 +1000167 NVOBJ_FLAG_ZERO_ALLOC,
168 &pfifo->playlist[0]);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000169 if (ret) {
Ben Skeggsac94a342010-07-08 15:28:48 +1000170 NV_ERROR(dev, "error creating playlist 0: %d\n", ret);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000171 return ret;
172 }
173
174 ret = nouveau_gpuobj_new_ref(dev, NULL, NULL, 0, 128*4, 0x1000,
Ben Skeggsac94a342010-07-08 15:28:48 +1000175 NVOBJ_FLAG_ZERO_ALLOC,
176 &pfifo->playlist[1]);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000177 if (ret) {
Ben Skeggsac94a342010-07-08 15:28:48 +1000178 nouveau_gpuobj_ref_del(dev, &pfifo->playlist[0]);
179 NV_ERROR(dev, "error creating playlist 1: %d\n", ret);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000180 return ret;
181 }
182
183just_reset:
184 nv50_fifo_init_reset(dev);
185 nv50_fifo_init_intr(dev);
186 nv50_fifo_init_context_table(dev);
187 nv50_fifo_init_regs__nv(dev);
188 nv50_fifo_init_regs(dev);
189 dev_priv->engine.fifo.enable(dev);
190 dev_priv->engine.fifo.reassign(dev, true);
191
192 return 0;
193}
194
195void
196nv50_fifo_takedown(struct drm_device *dev)
197{
198 struct drm_nouveau_private *dev_priv = dev->dev_private;
Ben Skeggsac94a342010-07-08 15:28:48 +1000199 struct nouveau_fifo_engine *pfifo = &dev_priv->engine.fifo;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000200
201 NV_DEBUG(dev, "\n");
202
Ben Skeggsac94a342010-07-08 15:28:48 +1000203 if (!pfifo->playlist[0])
Ben Skeggs6ee73862009-12-11 19:24:15 +1000204 return;
205
Ben Skeggsac94a342010-07-08 15:28:48 +1000206 nouveau_gpuobj_ref_del(dev, &pfifo->playlist[0]);
207 nouveau_gpuobj_ref_del(dev, &pfifo->playlist[1]);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000208}
209
210int
211nv50_fifo_channel_id(struct drm_device *dev)
212{
213 return nv_rd32(dev, NV03_PFIFO_CACHE1_PUSH1) &
214 NV50_PFIFO_CACHE1_PUSH1_CHID_MASK;
215}
216
217int
218nv50_fifo_create_context(struct nouveau_channel *chan)
219{
220 struct drm_device *dev = chan->dev;
221 struct drm_nouveau_private *dev_priv = dev->dev_private;
222 struct nouveau_gpuobj *ramfc = NULL;
Maarten Maathuisff9e5272010-02-01 20:58:27 +0100223 unsigned long flags;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000224 int ret;
225
226 NV_DEBUG(dev, "ch%d\n", chan->id);
227
Ben Skeggsac94a342010-07-08 15:28:48 +1000228 if (dev_priv->chipset == 0x50) {
Ben Skeggs6ee73862009-12-11 19:24:15 +1000229 uint32_t ramin_poffset = chan->ramin->gpuobj->im_pramin->start;
230 uint32_t ramin_voffset = chan->ramin->gpuobj->im_backing_start;
231
232 ret = nouveau_gpuobj_new_fake(dev, ramin_poffset, ramin_voffset,
233 0x100, NVOBJ_FLAG_ZERO_ALLOC |
234 NVOBJ_FLAG_ZERO_FREE, &ramfc,
235 &chan->ramfc);
236 if (ret)
237 return ret;
238
239 ret = nouveau_gpuobj_new_fake(dev, ramin_poffset + 0x0400,
240 ramin_voffset + 0x0400, 4096,
241 0, NULL, &chan->cache);
242 if (ret)
243 return ret;
244 } else {
245 ret = nouveau_gpuobj_new_ref(dev, chan, NULL, 0, 0x100, 256,
246 NVOBJ_FLAG_ZERO_ALLOC |
247 NVOBJ_FLAG_ZERO_FREE,
248 &chan->ramfc);
249 if (ret)
250 return ret;
251 ramfc = chan->ramfc->gpuobj;
252
Ben Skeggs134f2482010-01-18 08:33:04 +1000253 ret = nouveau_gpuobj_new_ref(dev, chan, NULL, 0, 4096, 1024,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000254 0, &chan->cache);
255 if (ret)
256 return ret;
257 }
258
Maarten Maathuisff9e5272010-02-01 20:58:27 +0100259 spin_lock_irqsave(&dev_priv->context_switch_lock, flags);
260
Ben Skeggs6ee73862009-12-11 19:24:15 +1000261 nv_wo32(dev, ramfc, 0x48/4, chan->pushbuf->instance >> 4);
Ben Skeggsca6adb82010-07-12 13:45:51 +1000262 nv_wo32(dev, ramfc, 0x80/4, (0 << 27) /* 4KiB */ |
263 (4 << 24) /* SEARCH_FULL */ |
264 (chan->ramht->instance >> 4));
Ben Skeggs6ee73862009-12-11 19:24:15 +1000265 nv_wo32(dev, ramfc, 0x44/4, 0x2101ffff);
266 nv_wo32(dev, ramfc, 0x60/4, 0x7fffffff);
267 nv_wo32(dev, ramfc, 0x40/4, 0x00000000);
268 nv_wo32(dev, ramfc, 0x7c/4, 0x30000001);
269 nv_wo32(dev, ramfc, 0x78/4, 0x00000000);
Ben Skeggs9a391ad2010-02-11 16:37:26 +1000270 nv_wo32(dev, ramfc, 0x3c/4, 0x403f6078);
271 nv_wo32(dev, ramfc, 0x50/4, chan->pushbuf_base +
272 chan->dma.ib_base * 4);
273 nv_wo32(dev, ramfc, 0x54/4, drm_order(chan->dma.ib_max + 1) << 16);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000274
Ben Skeggsac94a342010-07-08 15:28:48 +1000275 if (dev_priv->chipset != 0x50) {
Ben Skeggs6ee73862009-12-11 19:24:15 +1000276 nv_wo32(dev, chan->ramin->gpuobj, 0, chan->id);
277 nv_wo32(dev, chan->ramin->gpuobj, 1,
278 chan->ramfc->instance >> 8);
279
280 nv_wo32(dev, ramfc, 0x88/4, chan->cache->instance >> 10);
281 nv_wo32(dev, ramfc, 0x98/4, chan->ramin->instance >> 12);
282 }
283
Ben Skeggsf56cb862010-07-08 11:29:10 +1000284 dev_priv->engine.instmem.flush(dev);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000285
Ben Skeggsac94a342010-07-08 15:28:48 +1000286 nv50_fifo_channel_enable(dev, chan->id);
287 nv50_fifo_playlist_update(dev);
Maarten Maathuisff9e5272010-02-01 20:58:27 +0100288 spin_unlock_irqrestore(&dev_priv->context_switch_lock, flags);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000289 return 0;
290}
291
292void
293nv50_fifo_destroy_context(struct nouveau_channel *chan)
294{
295 struct drm_device *dev = chan->dev;
Maarten Maathuisa87ff622010-02-01 18:47:52 +0100296 struct nouveau_gpuobj_ref *ramfc = chan->ramfc;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000297
298 NV_DEBUG(dev, "ch%d\n", chan->id);
299
Maarten Maathuisa87ff622010-02-01 18:47:52 +0100300 /* This will ensure the channel is seen as disabled. */
301 chan->ramfc = NULL;
Ben Skeggsac94a342010-07-08 15:28:48 +1000302 nv50_fifo_channel_disable(dev, chan->id);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000303
304 /* Dummy channel, also used on ch 127 */
305 if (chan->id == 0)
Ben Skeggsac94a342010-07-08 15:28:48 +1000306 nv50_fifo_channel_disable(dev, 127);
307 nv50_fifo_playlist_update(dev);
Maarten Maathuisa87ff622010-02-01 18:47:52 +0100308
309 nouveau_gpuobj_ref_del(dev, &ramfc);
310 nouveau_gpuobj_ref_del(dev, &chan->cache);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000311}
312
313int
314nv50_fifo_load_context(struct nouveau_channel *chan)
315{
316 struct drm_device *dev = chan->dev;
317 struct drm_nouveau_private *dev_priv = dev->dev_private;
318 struct nouveau_gpuobj *ramfc = chan->ramfc->gpuobj;
319 struct nouveau_gpuobj *cache = chan->cache->gpuobj;
320 int ptr, cnt;
321
322 NV_DEBUG(dev, "ch%d\n", chan->id);
323
Ben Skeggs6ee73862009-12-11 19:24:15 +1000324 nv_wr32(dev, 0x3330, nv_ro32(dev, ramfc, 0x00/4));
325 nv_wr32(dev, 0x3334, nv_ro32(dev, ramfc, 0x04/4));
326 nv_wr32(dev, 0x3240, nv_ro32(dev, ramfc, 0x08/4));
327 nv_wr32(dev, 0x3320, nv_ro32(dev, ramfc, 0x0c/4));
328 nv_wr32(dev, 0x3244, nv_ro32(dev, ramfc, 0x10/4));
329 nv_wr32(dev, 0x3328, nv_ro32(dev, ramfc, 0x14/4));
330 nv_wr32(dev, 0x3368, nv_ro32(dev, ramfc, 0x18/4));
331 nv_wr32(dev, 0x336c, nv_ro32(dev, ramfc, 0x1c/4));
332 nv_wr32(dev, 0x3370, nv_ro32(dev, ramfc, 0x20/4));
333 nv_wr32(dev, 0x3374, nv_ro32(dev, ramfc, 0x24/4));
334 nv_wr32(dev, 0x3378, nv_ro32(dev, ramfc, 0x28/4));
335 nv_wr32(dev, 0x337c, nv_ro32(dev, ramfc, 0x2c/4));
336 nv_wr32(dev, 0x3228, nv_ro32(dev, ramfc, 0x30/4));
337 nv_wr32(dev, 0x3364, nv_ro32(dev, ramfc, 0x34/4));
338 nv_wr32(dev, 0x32a0, nv_ro32(dev, ramfc, 0x38/4));
339 nv_wr32(dev, 0x3224, nv_ro32(dev, ramfc, 0x3c/4));
340 nv_wr32(dev, 0x324c, nv_ro32(dev, ramfc, 0x40/4));
341 nv_wr32(dev, 0x2044, nv_ro32(dev, ramfc, 0x44/4));
342 nv_wr32(dev, 0x322c, nv_ro32(dev, ramfc, 0x48/4));
343 nv_wr32(dev, 0x3234, nv_ro32(dev, ramfc, 0x4c/4));
344 nv_wr32(dev, 0x3340, nv_ro32(dev, ramfc, 0x50/4));
345 nv_wr32(dev, 0x3344, nv_ro32(dev, ramfc, 0x54/4));
346 nv_wr32(dev, 0x3280, nv_ro32(dev, ramfc, 0x58/4));
347 nv_wr32(dev, 0x3254, nv_ro32(dev, ramfc, 0x5c/4));
348 nv_wr32(dev, 0x3260, nv_ro32(dev, ramfc, 0x60/4));
349 nv_wr32(dev, 0x3264, nv_ro32(dev, ramfc, 0x64/4));
350 nv_wr32(dev, 0x3268, nv_ro32(dev, ramfc, 0x68/4));
351 nv_wr32(dev, 0x326c, nv_ro32(dev, ramfc, 0x6c/4));
352 nv_wr32(dev, 0x32e4, nv_ro32(dev, ramfc, 0x70/4));
353 nv_wr32(dev, 0x3248, nv_ro32(dev, ramfc, 0x74/4));
354 nv_wr32(dev, 0x2088, nv_ro32(dev, ramfc, 0x78/4));
355 nv_wr32(dev, 0x2058, nv_ro32(dev, ramfc, 0x7c/4));
356 nv_wr32(dev, 0x2210, nv_ro32(dev, ramfc, 0x80/4));
357
358 cnt = nv_ro32(dev, ramfc, 0x84/4);
359 for (ptr = 0; ptr < cnt; ptr++) {
360 nv_wr32(dev, NV40_PFIFO_CACHE1_METHOD(ptr),
361 nv_ro32(dev, cache, (ptr * 2) + 0));
362 nv_wr32(dev, NV40_PFIFO_CACHE1_DATA(ptr),
363 nv_ro32(dev, cache, (ptr * 2) + 1));
364 }
Ben Skeggs7fb8ec82010-01-05 09:41:05 +1000365 nv_wr32(dev, NV03_PFIFO_CACHE1_PUT, cnt << 2);
366 nv_wr32(dev, NV03_PFIFO_CACHE1_GET, 0);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000367
368 /* guessing that all the 0x34xx regs aren't on NV50 */
Ben Skeggsac94a342010-07-08 15:28:48 +1000369 if (dev_priv->chipset != 0x50) {
Ben Skeggs6ee73862009-12-11 19:24:15 +1000370 nv_wr32(dev, 0x340c, nv_ro32(dev, ramfc, 0x88/4));
371 nv_wr32(dev, 0x3400, nv_ro32(dev, ramfc, 0x8c/4));
372 nv_wr32(dev, 0x3404, nv_ro32(dev, ramfc, 0x90/4));
373 nv_wr32(dev, 0x3408, nv_ro32(dev, ramfc, 0x94/4));
374 nv_wr32(dev, 0x3410, nv_ro32(dev, ramfc, 0x98/4));
375 }
376
Ben Skeggs6ee73862009-12-11 19:24:15 +1000377 nv_wr32(dev, NV03_PFIFO_CACHE1_PUSH1, chan->id | (1<<16));
378 return 0;
379}
380
381int
382nv50_fifo_unload_context(struct drm_device *dev)
383{
384 struct drm_nouveau_private *dev_priv = dev->dev_private;
385 struct nouveau_fifo_engine *pfifo = &dev_priv->engine.fifo;
386 struct nouveau_gpuobj *ramfc, *cache;
387 struct nouveau_channel *chan = NULL;
388 int chid, get, put, ptr;
389
390 NV_DEBUG(dev, "\n");
391
392 chid = pfifo->channel_id(dev);
Ben Skeggs3c8868d2009-12-16 14:51:13 +1000393 if (chid < 1 || chid >= dev_priv->engine.fifo.channels - 1)
Ben Skeggs6ee73862009-12-11 19:24:15 +1000394 return 0;
395
396 chan = dev_priv->fifos[chid];
397 if (!chan) {
398 NV_ERROR(dev, "Inactive channel on PFIFO: %d\n", chid);
399 return -EINVAL;
400 }
401 NV_DEBUG(dev, "ch%d\n", chan->id);
402 ramfc = chan->ramfc->gpuobj;
403 cache = chan->cache->gpuobj;
404
Ben Skeggs6ee73862009-12-11 19:24:15 +1000405 nv_wo32(dev, ramfc, 0x00/4, nv_rd32(dev, 0x3330));
406 nv_wo32(dev, ramfc, 0x04/4, nv_rd32(dev, 0x3334));
407 nv_wo32(dev, ramfc, 0x08/4, nv_rd32(dev, 0x3240));
408 nv_wo32(dev, ramfc, 0x0c/4, nv_rd32(dev, 0x3320));
409 nv_wo32(dev, ramfc, 0x10/4, nv_rd32(dev, 0x3244));
410 nv_wo32(dev, ramfc, 0x14/4, nv_rd32(dev, 0x3328));
411 nv_wo32(dev, ramfc, 0x18/4, nv_rd32(dev, 0x3368));
412 nv_wo32(dev, ramfc, 0x1c/4, nv_rd32(dev, 0x336c));
413 nv_wo32(dev, ramfc, 0x20/4, nv_rd32(dev, 0x3370));
414 nv_wo32(dev, ramfc, 0x24/4, nv_rd32(dev, 0x3374));
415 nv_wo32(dev, ramfc, 0x28/4, nv_rd32(dev, 0x3378));
416 nv_wo32(dev, ramfc, 0x2c/4, nv_rd32(dev, 0x337c));
417 nv_wo32(dev, ramfc, 0x30/4, nv_rd32(dev, 0x3228));
418 nv_wo32(dev, ramfc, 0x34/4, nv_rd32(dev, 0x3364));
419 nv_wo32(dev, ramfc, 0x38/4, nv_rd32(dev, 0x32a0));
420 nv_wo32(dev, ramfc, 0x3c/4, nv_rd32(dev, 0x3224));
421 nv_wo32(dev, ramfc, 0x40/4, nv_rd32(dev, 0x324c));
422 nv_wo32(dev, ramfc, 0x44/4, nv_rd32(dev, 0x2044));
423 nv_wo32(dev, ramfc, 0x48/4, nv_rd32(dev, 0x322c));
424 nv_wo32(dev, ramfc, 0x4c/4, nv_rd32(dev, 0x3234));
425 nv_wo32(dev, ramfc, 0x50/4, nv_rd32(dev, 0x3340));
426 nv_wo32(dev, ramfc, 0x54/4, nv_rd32(dev, 0x3344));
427 nv_wo32(dev, ramfc, 0x58/4, nv_rd32(dev, 0x3280));
428 nv_wo32(dev, ramfc, 0x5c/4, nv_rd32(dev, 0x3254));
429 nv_wo32(dev, ramfc, 0x60/4, nv_rd32(dev, 0x3260));
430 nv_wo32(dev, ramfc, 0x64/4, nv_rd32(dev, 0x3264));
431 nv_wo32(dev, ramfc, 0x68/4, nv_rd32(dev, 0x3268));
432 nv_wo32(dev, ramfc, 0x6c/4, nv_rd32(dev, 0x326c));
433 nv_wo32(dev, ramfc, 0x70/4, nv_rd32(dev, 0x32e4));
434 nv_wo32(dev, ramfc, 0x74/4, nv_rd32(dev, 0x3248));
435 nv_wo32(dev, ramfc, 0x78/4, nv_rd32(dev, 0x2088));
436 nv_wo32(dev, ramfc, 0x7c/4, nv_rd32(dev, 0x2058));
437 nv_wo32(dev, ramfc, 0x80/4, nv_rd32(dev, 0x2210));
438
439 put = (nv_rd32(dev, NV03_PFIFO_CACHE1_PUT) & 0x7ff) >> 2;
440 get = (nv_rd32(dev, NV03_PFIFO_CACHE1_GET) & 0x7ff) >> 2;
441 ptr = 0;
442 while (put != get) {
443 nv_wo32(dev, cache, ptr++,
444 nv_rd32(dev, NV40_PFIFO_CACHE1_METHOD(get)));
445 nv_wo32(dev, cache, ptr++,
446 nv_rd32(dev, NV40_PFIFO_CACHE1_DATA(get)));
447 get = (get + 1) & 0x1ff;
448 }
449
450 /* guessing that all the 0x34xx regs aren't on NV50 */
Ben Skeggsac94a342010-07-08 15:28:48 +1000451 if (dev_priv->chipset != 0x50) {
Ben Skeggs6ee73862009-12-11 19:24:15 +1000452 nv_wo32(dev, ramfc, 0x84/4, ptr >> 1);
453 nv_wo32(dev, ramfc, 0x88/4, nv_rd32(dev, 0x340c));
454 nv_wo32(dev, ramfc, 0x8c/4, nv_rd32(dev, 0x3400));
455 nv_wo32(dev, ramfc, 0x90/4, nv_rd32(dev, 0x3404));
456 nv_wo32(dev, ramfc, 0x94/4, nv_rd32(dev, 0x3408));
457 nv_wo32(dev, ramfc, 0x98/4, nv_rd32(dev, 0x3410));
458 }
459
Ben Skeggsf56cb862010-07-08 11:29:10 +1000460 dev_priv->engine.instmem.flush(dev);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000461
462 /*XXX: probably reload ch127 (NULL) state back too */
463 nv_wr32(dev, NV03_PFIFO_CACHE1_PUSH1, 127);
464 return 0;
465}
466