nv50_fifo.c 14.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
/*
 * Copyright (C) 2007 Ben Skeggs.
 * All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice (including the
 * next paragraph) shall be included in all copies or substantial
 * portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 */

#include "drmP.h"
#include "drm.h"
#include "nouveau_drv.h"
30
#include "nouveau_ramht.h"
31 32

static void
B
Ben Skeggs 已提交
33
nv50_fifo_playlist_update(struct drm_device *dev)
34 35
{
	struct drm_nouveau_private *dev_priv = dev->dev_private;
B
Ben Skeggs 已提交
36
	struct nouveau_fifo_engine *pfifo = &dev_priv->engine.fifo;
37
	struct nouveau_gpuobj *cur;
38 39 40 41
	int i, nr;

	NV_DEBUG(dev, "\n");

B
Ben Skeggs 已提交
42 43
	cur = pfifo->playlist[pfifo->cur_playlist];
	pfifo->cur_playlist = !pfifo->cur_playlist;
44 45 46

	/* We never schedule channel 0 or 127 */
	for (i = 1, nr = 0; i < 127; i++) {
47 48
		if (dev_priv->channels.ptr[i] &&
		    dev_priv->channels.ptr[i]->ramfc) {
49
			nv_wo32(cur, (nr * 4), i);
50 51
			nr++;
		}
52
	}
53
	dev_priv->engine.instmem.flush(dev);
54

55
	nv_wr32(dev, 0x32f4, cur->vinst >> 12);
56 57 58 59
	nv_wr32(dev, 0x32ec, nr);
	nv_wr32(dev, 0x2500, 0x101);
}

B
Ben Skeggs 已提交
60 61
static void
nv50_fifo_channel_enable(struct drm_device *dev, int channel)
62 63
{
	struct drm_nouveau_private *dev_priv = dev->dev_private;
64
	struct nouveau_channel *chan = dev_priv->channels.ptr[channel];
65 66 67 68
	uint32_t inst;

	NV_DEBUG(dev, "ch%d\n", channel);

B
Ben Skeggs 已提交
69
	if (dev_priv->chipset == 0x50)
70
		inst = chan->ramfc->vinst >> 12;
71
	else
72
		inst = chan->ramfc->vinst >> 8;
73

B
Ben Skeggs 已提交
74 75
	nv_wr32(dev, NV50_PFIFO_CTX_TABLE(channel), inst |
		     NV50_PFIFO_CTX_TABLE_CHANNEL_ENABLED);
76 77 78
}

static void
B
Ben Skeggs 已提交
79
nv50_fifo_channel_disable(struct drm_device *dev, int channel)
80 81 82 83
{
	struct drm_nouveau_private *dev_priv = dev->dev_private;
	uint32_t inst;

B
Ben Skeggs 已提交
84
	NV_DEBUG(dev, "ch%d\n", channel);
85

B
Ben Skeggs 已提交
86
	if (dev_priv->chipset == 0x50)
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
		inst = NV50_PFIFO_CTX_TABLE_INSTANCE_MASK_G80;
	else
		inst = NV50_PFIFO_CTX_TABLE_INSTANCE_MASK_G84;
	nv_wr32(dev, NV50_PFIFO_CTX_TABLE(channel), inst);
}

static void
nv50_fifo_init_reset(struct drm_device *dev)
{
	uint32_t pmc_e = NV_PMC_ENABLE_PFIFO;

	NV_DEBUG(dev, "\n");

	nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) & ~pmc_e);
	nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) |  pmc_e);
}

static void
nv50_fifo_init_intr(struct drm_device *dev)
{
	NV_DEBUG(dev, "\n");

109
	nouveau_irq_register(dev, 8, nv04_fifo_isr);
110 111 112 113 114 115 116 117 118 119 120 121 122
	nv_wr32(dev, NV03_PFIFO_INTR_0, 0xFFFFFFFF);
	nv_wr32(dev, NV03_PFIFO_INTR_EN_0, 0xFFFFFFFF);
}

static void
nv50_fifo_init_context_table(struct drm_device *dev)
{
	struct drm_nouveau_private *dev_priv = dev->dev_private;
	int i;

	NV_DEBUG(dev, "\n");

	for (i = 0; i < NV50_PFIFO_CTX_TABLE__SIZE; i++) {
123
		if (dev_priv->channels.ptr[i])
B
Ben Skeggs 已提交
124
			nv50_fifo_channel_enable(dev, i);
125
		else
B
Ben Skeggs 已提交
126
			nv50_fifo_channel_disable(dev, i);
127 128
	}

B
Ben Skeggs 已提交
129
	nv50_fifo_playlist_update(dev);
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
}

static void
nv50_fifo_init_regs__nv(struct drm_device *dev)
{
	NV_DEBUG(dev, "\n");

	nv_wr32(dev, 0x250c, 0x6f3cfc34);
}

static void
nv50_fifo_init_regs(struct drm_device *dev)
{
	NV_DEBUG(dev, "\n");

	nv_wr32(dev, 0x2500, 0);
	nv_wr32(dev, 0x3250, 0);
	nv_wr32(dev, 0x3220, 0);
	nv_wr32(dev, 0x3204, 0);
	nv_wr32(dev, 0x3210, 0);
	nv_wr32(dev, 0x3270, 0);

	/* Enable dummy channels setup by nv50_instmem.c */
B
Ben Skeggs 已提交
153 154
	nv50_fifo_channel_enable(dev, 0);
	nv50_fifo_channel_enable(dev, 127);
155 156 157 158 159 160
}

int
nv50_fifo_init(struct drm_device *dev)
{
	struct drm_nouveau_private *dev_priv = dev->dev_private;
B
Ben Skeggs 已提交
161
	struct nouveau_fifo_engine *pfifo = &dev_priv->engine.fifo;
162 163 164 165
	int ret;

	NV_DEBUG(dev, "\n");

B
Ben Skeggs 已提交
166 167
	if (pfifo->playlist[0]) {
		pfifo->cur_playlist = !pfifo->cur_playlist;
168 169 170
		goto just_reset;
	}

171 172 173
	ret = nouveau_gpuobj_new(dev, NULL, 128*4, 0x1000,
				 NVOBJ_FLAG_ZERO_ALLOC,
				 &pfifo->playlist[0]);
174
	if (ret) {
B
Ben Skeggs 已提交
175
		NV_ERROR(dev, "error creating playlist 0: %d\n", ret);
176 177 178
		return ret;
	}

179 180 181
	ret = nouveau_gpuobj_new(dev, NULL, 128*4, 0x1000,
				 NVOBJ_FLAG_ZERO_ALLOC,
				 &pfifo->playlist[1]);
182
	if (ret) {
183
		nouveau_gpuobj_ref(NULL, &pfifo->playlist[0]);
B
Ben Skeggs 已提交
184
		NV_ERROR(dev, "error creating playlist 1: %d\n", ret);
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
		return ret;
	}

just_reset:
	nv50_fifo_init_reset(dev);
	nv50_fifo_init_intr(dev);
	nv50_fifo_init_context_table(dev);
	nv50_fifo_init_regs__nv(dev);
	nv50_fifo_init_regs(dev);
	dev_priv->engine.fifo.enable(dev);
	dev_priv->engine.fifo.reassign(dev, true);

	return 0;
}

void
nv50_fifo_takedown(struct drm_device *dev)
{
	struct drm_nouveau_private *dev_priv = dev->dev_private;
B
Ben Skeggs 已提交
204
	struct nouveau_fifo_engine *pfifo = &dev_priv->engine.fifo;
205 206 207

	NV_DEBUG(dev, "\n");

B
Ben Skeggs 已提交
208
	if (!pfifo->playlist[0])
209 210
		return;

211 212 213
	nv_wr32(dev, 0x2140, 0x00000000);
	nouveau_irq_unregister(dev, 8);

214 215
	nouveau_gpuobj_ref(NULL, &pfifo->playlist[0]);
	nouveau_gpuobj_ref(NULL, &pfifo->playlist[1]);
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
}

int
nv50_fifo_channel_id(struct drm_device *dev)
{
	return nv_rd32(dev, NV03_PFIFO_CACHE1_PUSH1) &
			NV50_PFIFO_CACHE1_PUSH1_CHID_MASK;
}

int
nv50_fifo_create_context(struct nouveau_channel *chan)
{
	struct drm_device *dev = chan->dev;
	struct drm_nouveau_private *dev_priv = dev->dev_private;
	struct nouveau_gpuobj *ramfc = NULL;
231
	unsigned long flags;
232 233 234 235
	int ret;

	NV_DEBUG(dev, "ch%d\n", chan->id);

B
Ben Skeggs 已提交
236
	if (dev_priv->chipset == 0x50) {
237 238
		ret = nouveau_gpuobj_new_fake(dev, chan->ramin->pinst,
					      chan->ramin->vinst, 0x100,
239
					      NVOBJ_FLAG_ZERO_ALLOC |
240
					      NVOBJ_FLAG_ZERO_FREE,
241 242 243 244
					      &chan->ramfc);
		if (ret)
			return ret;

245 246 247
		ret = nouveau_gpuobj_new_fake(dev, chan->ramin->pinst + 0x0400,
					      chan->ramin->vinst + 0x0400,
					      4096, 0, &chan->cache);
248 249 250
		if (ret)
			return ret;
	} else {
251 252 253
		ret = nouveau_gpuobj_new(dev, chan, 0x100, 256,
					 NVOBJ_FLAG_ZERO_ALLOC |
					 NVOBJ_FLAG_ZERO_FREE, &chan->ramfc);
254 255 256
		if (ret)
			return ret;

257 258
		ret = nouveau_gpuobj_new(dev, chan, 4096, 1024,
					 0, &chan->cache);
259 260 261
		if (ret)
			return ret;
	}
262
	ramfc = chan->ramfc;
263

264 265 266 267 268
	chan->user = ioremap(pci_resource_start(dev->pdev, 0) +
			     NV50_USER(chan->id), PAGE_SIZE);
	if (!chan->user)
		return -ENOMEM;

269 270
	spin_lock_irqsave(&dev_priv->context_switch_lock, flags);

271
	nv_wo32(ramfc, 0x48, chan->pushbuf->cinst >> 4);
272
	nv_wo32(ramfc, 0x80, ((chan->ramht->bits - 9) << 27) |
273
			     (4 << 24) /* SEARCH_FULL */ |
274
			     (chan->ramht->gpuobj->cinst >> 4));
275 276 277 278 279 280 281 282
	nv_wo32(ramfc, 0x44, 0x2101ffff);
	nv_wo32(ramfc, 0x60, 0x7fffffff);
	nv_wo32(ramfc, 0x40, 0x00000000);
	nv_wo32(ramfc, 0x7c, 0x30000001);
	nv_wo32(ramfc, 0x78, 0x00000000);
	nv_wo32(ramfc, 0x3c, 0x403f6078);
	nv_wo32(ramfc, 0x50, chan->pushbuf_base + chan->dma.ib_base * 4);
	nv_wo32(ramfc, 0x54, drm_order(chan->dma.ib_max + 1) << 16);
283

B
Ben Skeggs 已提交
284
	if (dev_priv->chipset != 0x50) {
285 286
		nv_wo32(chan->ramin, 0, chan->id);
		nv_wo32(chan->ramin, 4, chan->ramfc->vinst >> 8);
287

288 289
		nv_wo32(ramfc, 0x88, chan->cache->vinst >> 10);
		nv_wo32(ramfc, 0x98, chan->ramin->vinst >> 12);
290 291
	}

292
	dev_priv->engine.instmem.flush(dev);
293

B
Ben Skeggs 已提交
294 295
	nv50_fifo_channel_enable(dev, chan->id);
	nv50_fifo_playlist_update(dev);
296
	spin_unlock_irqrestore(&dev_priv->context_switch_lock, flags);
297 298 299 300 301 302 303
	return 0;
}

void
nv50_fifo_destroy_context(struct nouveau_channel *chan)
{
	struct drm_device *dev = chan->dev;
304 305
	struct drm_nouveau_private *dev_priv = dev->dev_private;
	struct nouveau_fifo_engine *pfifo = &dev_priv->engine.fifo;
306
	struct nouveau_gpuobj *ramfc = NULL;
307
	unsigned long flags;
308 309 310

	NV_DEBUG(dev, "ch%d\n", chan->id);

311 312 313 314 315 316 317 318 319 320
	spin_lock_irqsave(&dev_priv->context_switch_lock, flags);
	pfifo->reassign(dev, false);

	/* Unload the context if it's the currently active one */
	if (pfifo->channel_id(dev) == chan->id) {
		pfifo->disable(dev);
		pfifo->unload_context(dev);
		pfifo->enable(dev);
	}

321
	/* This will ensure the channel is seen as disabled. */
322 323
	nouveau_gpuobj_ref(chan->ramfc, &ramfc);
	nouveau_gpuobj_ref(NULL, &chan->ramfc);
B
Ben Skeggs 已提交
324
	nv50_fifo_channel_disable(dev, chan->id);
325 326 327

	/* Dummy channel, also used on ch 127 */
	if (chan->id == 0)
B
Ben Skeggs 已提交
328 329
		nv50_fifo_channel_disable(dev, 127);
	nv50_fifo_playlist_update(dev);
330

331 332 333 334
	pfifo->reassign(dev, true);
	spin_unlock_irqrestore(&dev_priv->context_switch_lock, flags);

	/* Free the channel resources */
335 336 337 338
	if (chan->user) {
		iounmap(chan->user);
		chan->user = NULL;
	}
339 340
	nouveau_gpuobj_ref(NULL, &ramfc);
	nouveau_gpuobj_ref(NULL, &chan->cache);
341 342 343 344 345 346 347
}

int
nv50_fifo_load_context(struct nouveau_channel *chan)
{
	struct drm_device *dev = chan->dev;
	struct drm_nouveau_private *dev_priv = dev->dev_private;
348 349
	struct nouveau_gpuobj *ramfc = chan->ramfc;
	struct nouveau_gpuobj *cache = chan->cache;
350 351 352 353
	int ptr, cnt;

	NV_DEBUG(dev, "ch%d\n", chan->id);

354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388
	nv_wr32(dev, 0x3330, nv_ro32(ramfc, 0x00));
	nv_wr32(dev, 0x3334, nv_ro32(ramfc, 0x04));
	nv_wr32(dev, 0x3240, nv_ro32(ramfc, 0x08));
	nv_wr32(dev, 0x3320, nv_ro32(ramfc, 0x0c));
	nv_wr32(dev, 0x3244, nv_ro32(ramfc, 0x10));
	nv_wr32(dev, 0x3328, nv_ro32(ramfc, 0x14));
	nv_wr32(dev, 0x3368, nv_ro32(ramfc, 0x18));
	nv_wr32(dev, 0x336c, nv_ro32(ramfc, 0x1c));
	nv_wr32(dev, 0x3370, nv_ro32(ramfc, 0x20));
	nv_wr32(dev, 0x3374, nv_ro32(ramfc, 0x24));
	nv_wr32(dev, 0x3378, nv_ro32(ramfc, 0x28));
	nv_wr32(dev, 0x337c, nv_ro32(ramfc, 0x2c));
	nv_wr32(dev, 0x3228, nv_ro32(ramfc, 0x30));
	nv_wr32(dev, 0x3364, nv_ro32(ramfc, 0x34));
	nv_wr32(dev, 0x32a0, nv_ro32(ramfc, 0x38));
	nv_wr32(dev, 0x3224, nv_ro32(ramfc, 0x3c));
	nv_wr32(dev, 0x324c, nv_ro32(ramfc, 0x40));
	nv_wr32(dev, 0x2044, nv_ro32(ramfc, 0x44));
	nv_wr32(dev, 0x322c, nv_ro32(ramfc, 0x48));
	nv_wr32(dev, 0x3234, nv_ro32(ramfc, 0x4c));
	nv_wr32(dev, 0x3340, nv_ro32(ramfc, 0x50));
	nv_wr32(dev, 0x3344, nv_ro32(ramfc, 0x54));
	nv_wr32(dev, 0x3280, nv_ro32(ramfc, 0x58));
	nv_wr32(dev, 0x3254, nv_ro32(ramfc, 0x5c));
	nv_wr32(dev, 0x3260, nv_ro32(ramfc, 0x60));
	nv_wr32(dev, 0x3264, nv_ro32(ramfc, 0x64));
	nv_wr32(dev, 0x3268, nv_ro32(ramfc, 0x68));
	nv_wr32(dev, 0x326c, nv_ro32(ramfc, 0x6c));
	nv_wr32(dev, 0x32e4, nv_ro32(ramfc, 0x70));
	nv_wr32(dev, 0x3248, nv_ro32(ramfc, 0x74));
	nv_wr32(dev, 0x2088, nv_ro32(ramfc, 0x78));
	nv_wr32(dev, 0x2058, nv_ro32(ramfc, 0x7c));
	nv_wr32(dev, 0x2210, nv_ro32(ramfc, 0x80));

	cnt = nv_ro32(ramfc, 0x84);
389 390
	for (ptr = 0; ptr < cnt; ptr++) {
		nv_wr32(dev, NV40_PFIFO_CACHE1_METHOD(ptr),
391
			nv_ro32(cache, (ptr * 8) + 0));
392
		nv_wr32(dev, NV40_PFIFO_CACHE1_DATA(ptr),
393
			nv_ro32(cache, (ptr * 8) + 4));
394
	}
395 396
	nv_wr32(dev, NV03_PFIFO_CACHE1_PUT, cnt << 2);
	nv_wr32(dev, NV03_PFIFO_CACHE1_GET, 0);
397 398

	/* guessing that all the 0x34xx regs aren't on NV50 */
B
Ben Skeggs 已提交
399
	if (dev_priv->chipset != 0x50) {
400 401 402 403 404
		nv_wr32(dev, 0x340c, nv_ro32(ramfc, 0x88));
		nv_wr32(dev, 0x3400, nv_ro32(ramfc, 0x8c));
		nv_wr32(dev, 0x3404, nv_ro32(ramfc, 0x90));
		nv_wr32(dev, 0x3408, nv_ro32(ramfc, 0x94));
		nv_wr32(dev, 0x3410, nv_ro32(ramfc, 0x98));
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422
	}

	nv_wr32(dev, NV03_PFIFO_CACHE1_PUSH1, chan->id | (1<<16));
	return 0;
}

int
nv50_fifo_unload_context(struct drm_device *dev)
{
	struct drm_nouveau_private *dev_priv = dev->dev_private;
	struct nouveau_fifo_engine *pfifo = &dev_priv->engine.fifo;
	struct nouveau_gpuobj *ramfc, *cache;
	struct nouveau_channel *chan = NULL;
	int chid, get, put, ptr;

	NV_DEBUG(dev, "\n");

	chid = pfifo->channel_id(dev);
423
	if (chid < 1 || chid >= dev_priv->engine.fifo.channels - 1)
424 425
		return 0;

426
	chan = dev_priv->channels.ptr[chid];
427 428 429 430 431
	if (!chan) {
		NV_ERROR(dev, "Inactive channel on PFIFO: %d\n", chid);
		return -EINVAL;
	}
	NV_DEBUG(dev, "ch%d\n", chan->id);
432 433
	ramfc = chan->ramfc;
	cache = chan->cache;
434

435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467
	nv_wo32(ramfc, 0x00, nv_rd32(dev, 0x3330));
	nv_wo32(ramfc, 0x04, nv_rd32(dev, 0x3334));
	nv_wo32(ramfc, 0x08, nv_rd32(dev, 0x3240));
	nv_wo32(ramfc, 0x0c, nv_rd32(dev, 0x3320));
	nv_wo32(ramfc, 0x10, nv_rd32(dev, 0x3244));
	nv_wo32(ramfc, 0x14, nv_rd32(dev, 0x3328));
	nv_wo32(ramfc, 0x18, nv_rd32(dev, 0x3368));
	nv_wo32(ramfc, 0x1c, nv_rd32(dev, 0x336c));
	nv_wo32(ramfc, 0x20, nv_rd32(dev, 0x3370));
	nv_wo32(ramfc, 0x24, nv_rd32(dev, 0x3374));
	nv_wo32(ramfc, 0x28, nv_rd32(dev, 0x3378));
	nv_wo32(ramfc, 0x2c, nv_rd32(dev, 0x337c));
	nv_wo32(ramfc, 0x30, nv_rd32(dev, 0x3228));
	nv_wo32(ramfc, 0x34, nv_rd32(dev, 0x3364));
	nv_wo32(ramfc, 0x38, nv_rd32(dev, 0x32a0));
	nv_wo32(ramfc, 0x3c, nv_rd32(dev, 0x3224));
	nv_wo32(ramfc, 0x40, nv_rd32(dev, 0x324c));
	nv_wo32(ramfc, 0x44, nv_rd32(dev, 0x2044));
	nv_wo32(ramfc, 0x48, nv_rd32(dev, 0x322c));
	nv_wo32(ramfc, 0x4c, nv_rd32(dev, 0x3234));
	nv_wo32(ramfc, 0x50, nv_rd32(dev, 0x3340));
	nv_wo32(ramfc, 0x54, nv_rd32(dev, 0x3344));
	nv_wo32(ramfc, 0x58, nv_rd32(dev, 0x3280));
	nv_wo32(ramfc, 0x5c, nv_rd32(dev, 0x3254));
	nv_wo32(ramfc, 0x60, nv_rd32(dev, 0x3260));
	nv_wo32(ramfc, 0x64, nv_rd32(dev, 0x3264));
	nv_wo32(ramfc, 0x68, nv_rd32(dev, 0x3268));
	nv_wo32(ramfc, 0x6c, nv_rd32(dev, 0x326c));
	nv_wo32(ramfc, 0x70, nv_rd32(dev, 0x32e4));
	nv_wo32(ramfc, 0x74, nv_rd32(dev, 0x3248));
	nv_wo32(ramfc, 0x78, nv_rd32(dev, 0x2088));
	nv_wo32(ramfc, 0x7c, nv_rd32(dev, 0x2058));
	nv_wo32(ramfc, 0x80, nv_rd32(dev, 0x2210));
468 469 470 471 472

	put = (nv_rd32(dev, NV03_PFIFO_CACHE1_PUT) & 0x7ff) >> 2;
	get = (nv_rd32(dev, NV03_PFIFO_CACHE1_GET) & 0x7ff) >> 2;
	ptr = 0;
	while (put != get) {
473 474 475 476
		nv_wo32(cache, ptr + 0,
			nv_rd32(dev, NV40_PFIFO_CACHE1_METHOD(get)));
		nv_wo32(cache, ptr + 4,
			nv_rd32(dev, NV40_PFIFO_CACHE1_DATA(get)));
477
		get = (get + 1) & 0x1ff;
478
		ptr += 8;
479 480 481
	}

	/* guessing that all the 0x34xx regs aren't on NV50 */
B
Ben Skeggs 已提交
482
	if (dev_priv->chipset != 0x50) {
483 484 485 486 487 488
		nv_wo32(ramfc, 0x84, ptr >> 3);
		nv_wo32(ramfc, 0x88, nv_rd32(dev, 0x340c));
		nv_wo32(ramfc, 0x8c, nv_rd32(dev, 0x3400));
		nv_wo32(ramfc, 0x90, nv_rd32(dev, 0x3404));
		nv_wo32(ramfc, 0x94, nv_rd32(dev, 0x3408));
		nv_wo32(ramfc, 0x98, nv_rd32(dev, 0x3410));
489 490
	}

491
	dev_priv->engine.instmem.flush(dev);
492 493 494 495 496 497

	/*XXX: probably reload ch127 (NULL) state back too */
	nv_wr32(dev, NV03_PFIFO_CACHE1_PUSH1, 127);
	return 0;
}

498 499 500 501 502
void
nv50_fifo_tlb_flush(struct drm_device *dev)
{
	nv50_vm_flush(dev, 5);
}