aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/nouveau_state.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_state.c')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_state.c123
1 files changed, 79 insertions, 44 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c
index 989322be3728..ed7757f14083 100644
--- a/drivers/gpu/drm/nouveau/nouveau_state.c
+++ b/drivers/gpu/drm/nouveau/nouveau_state.c
@@ -35,6 +35,8 @@
35#include "nouveau_drv.h" 35#include "nouveau_drv.h"
36#include "nouveau_drm.h" 36#include "nouveau_drm.h"
37#include "nouveau_fbcon.h" 37#include "nouveau_fbcon.h"
38#include "nouveau_ramht.h"
39#include "nouveau_pm.h"
38#include "nv50_display.h" 40#include "nv50_display.h"
39 41
40static void nouveau_stub_takedown(struct drm_device *dev) {} 42static void nouveau_stub_takedown(struct drm_device *dev) {}
@@ -78,7 +80,6 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
78 engine->fifo.disable = nv04_fifo_disable; 80 engine->fifo.disable = nv04_fifo_disable;
79 engine->fifo.enable = nv04_fifo_enable; 81 engine->fifo.enable = nv04_fifo_enable;
80 engine->fifo.reassign = nv04_fifo_reassign; 82 engine->fifo.reassign = nv04_fifo_reassign;
81 engine->fifo.cache_flush = nv04_fifo_cache_flush;
82 engine->fifo.cache_pull = nv04_fifo_cache_pull; 83 engine->fifo.cache_pull = nv04_fifo_cache_pull;
83 engine->fifo.channel_id = nv04_fifo_channel_id; 84 engine->fifo.channel_id = nv04_fifo_channel_id;
84 engine->fifo.create_context = nv04_fifo_create_context; 85 engine->fifo.create_context = nv04_fifo_create_context;
@@ -95,6 +96,9 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
95 engine->gpio.get = NULL; 96 engine->gpio.get = NULL;
96 engine->gpio.set = NULL; 97 engine->gpio.set = NULL;
97 engine->gpio.irq_enable = NULL; 98 engine->gpio.irq_enable = NULL;
99 engine->pm.clock_get = nv04_pm_clock_get;
100 engine->pm.clock_pre = nv04_pm_clock_pre;
101 engine->pm.clock_set = nv04_pm_clock_set;
98 break; 102 break;
99 case 0x10: 103 case 0x10:
100 engine->instmem.init = nv04_instmem_init; 104 engine->instmem.init = nv04_instmem_init;
@@ -130,7 +134,6 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
130 engine->fifo.disable = nv04_fifo_disable; 134 engine->fifo.disable = nv04_fifo_disable;
131 engine->fifo.enable = nv04_fifo_enable; 135 engine->fifo.enable = nv04_fifo_enable;
132 engine->fifo.reassign = nv04_fifo_reassign; 136 engine->fifo.reassign = nv04_fifo_reassign;
133 engine->fifo.cache_flush = nv04_fifo_cache_flush;
134 engine->fifo.cache_pull = nv04_fifo_cache_pull; 137 engine->fifo.cache_pull = nv04_fifo_cache_pull;
135 engine->fifo.channel_id = nv10_fifo_channel_id; 138 engine->fifo.channel_id = nv10_fifo_channel_id;
136 engine->fifo.create_context = nv10_fifo_create_context; 139 engine->fifo.create_context = nv10_fifo_create_context;
@@ -147,6 +150,9 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
147 engine->gpio.get = nv10_gpio_get; 150 engine->gpio.get = nv10_gpio_get;
148 engine->gpio.set = nv10_gpio_set; 151 engine->gpio.set = nv10_gpio_set;
149 engine->gpio.irq_enable = NULL; 152 engine->gpio.irq_enable = NULL;
153 engine->pm.clock_get = nv04_pm_clock_get;
154 engine->pm.clock_pre = nv04_pm_clock_pre;
155 engine->pm.clock_set = nv04_pm_clock_set;
150 break; 156 break;
151 case 0x20: 157 case 0x20:
152 engine->instmem.init = nv04_instmem_init; 158 engine->instmem.init = nv04_instmem_init;
@@ -182,7 +188,6 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
182 engine->fifo.disable = nv04_fifo_disable; 188 engine->fifo.disable = nv04_fifo_disable;
183 engine->fifo.enable = nv04_fifo_enable; 189 engine->fifo.enable = nv04_fifo_enable;
184 engine->fifo.reassign = nv04_fifo_reassign; 190 engine->fifo.reassign = nv04_fifo_reassign;
185 engine->fifo.cache_flush = nv04_fifo_cache_flush;
186 engine->fifo.cache_pull = nv04_fifo_cache_pull; 191 engine->fifo.cache_pull = nv04_fifo_cache_pull;
187 engine->fifo.channel_id = nv10_fifo_channel_id; 192 engine->fifo.channel_id = nv10_fifo_channel_id;
188 engine->fifo.create_context = nv10_fifo_create_context; 193 engine->fifo.create_context = nv10_fifo_create_context;
@@ -199,6 +204,9 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
199 engine->gpio.get = nv10_gpio_get; 204 engine->gpio.get = nv10_gpio_get;
200 engine->gpio.set = nv10_gpio_set; 205 engine->gpio.set = nv10_gpio_set;
201 engine->gpio.irq_enable = NULL; 206 engine->gpio.irq_enable = NULL;
207 engine->pm.clock_get = nv04_pm_clock_get;
208 engine->pm.clock_pre = nv04_pm_clock_pre;
209 engine->pm.clock_set = nv04_pm_clock_set;
202 break; 210 break;
203 case 0x30: 211 case 0x30:
204 engine->instmem.init = nv04_instmem_init; 212 engine->instmem.init = nv04_instmem_init;
@@ -234,7 +242,6 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
234 engine->fifo.disable = nv04_fifo_disable; 242 engine->fifo.disable = nv04_fifo_disable;
235 engine->fifo.enable = nv04_fifo_enable; 243 engine->fifo.enable = nv04_fifo_enable;
236 engine->fifo.reassign = nv04_fifo_reassign; 244 engine->fifo.reassign = nv04_fifo_reassign;
237 engine->fifo.cache_flush = nv04_fifo_cache_flush;
238 engine->fifo.cache_pull = nv04_fifo_cache_pull; 245 engine->fifo.cache_pull = nv04_fifo_cache_pull;
239 engine->fifo.channel_id = nv10_fifo_channel_id; 246 engine->fifo.channel_id = nv10_fifo_channel_id;
240 engine->fifo.create_context = nv10_fifo_create_context; 247 engine->fifo.create_context = nv10_fifo_create_context;
@@ -251,6 +258,11 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
251 engine->gpio.get = nv10_gpio_get; 258 engine->gpio.get = nv10_gpio_get;
252 engine->gpio.set = nv10_gpio_set; 259 engine->gpio.set = nv10_gpio_set;
253 engine->gpio.irq_enable = NULL; 260 engine->gpio.irq_enable = NULL;
261 engine->pm.clock_get = nv04_pm_clock_get;
262 engine->pm.clock_pre = nv04_pm_clock_pre;
263 engine->pm.clock_set = nv04_pm_clock_set;
264 engine->pm.voltage_get = nouveau_voltage_gpio_get;
265 engine->pm.voltage_set = nouveau_voltage_gpio_set;
254 break; 266 break;
255 case 0x40: 267 case 0x40:
256 case 0x60: 268 case 0x60:
@@ -287,7 +299,6 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
287 engine->fifo.disable = nv04_fifo_disable; 299 engine->fifo.disable = nv04_fifo_disable;
288 engine->fifo.enable = nv04_fifo_enable; 300 engine->fifo.enable = nv04_fifo_enable;
289 engine->fifo.reassign = nv04_fifo_reassign; 301 engine->fifo.reassign = nv04_fifo_reassign;
290 engine->fifo.cache_flush = nv04_fifo_cache_flush;
291 engine->fifo.cache_pull = nv04_fifo_cache_pull; 302 engine->fifo.cache_pull = nv04_fifo_cache_pull;
292 engine->fifo.channel_id = nv10_fifo_channel_id; 303 engine->fifo.channel_id = nv10_fifo_channel_id;
293 engine->fifo.create_context = nv40_fifo_create_context; 304 engine->fifo.create_context = nv40_fifo_create_context;
@@ -304,6 +315,12 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
304 engine->gpio.get = nv10_gpio_get; 315 engine->gpio.get = nv10_gpio_get;
305 engine->gpio.set = nv10_gpio_set; 316 engine->gpio.set = nv10_gpio_set;
306 engine->gpio.irq_enable = NULL; 317 engine->gpio.irq_enable = NULL;
318 engine->pm.clock_get = nv04_pm_clock_get;
319 engine->pm.clock_pre = nv04_pm_clock_pre;
320 engine->pm.clock_set = nv04_pm_clock_set;
321 engine->pm.voltage_get = nouveau_voltage_gpio_get;
322 engine->pm.voltage_set = nouveau_voltage_gpio_set;
323 engine->pm.temp_get = nv40_temp_get;
307 break; 324 break;
308 case 0x50: 325 case 0x50:
309 case 0x80: /* gotta love NVIDIA's consistency.. */ 326 case 0x80: /* gotta love NVIDIA's consistency.. */
@@ -358,6 +375,27 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
358 engine->gpio.get = nv50_gpio_get; 375 engine->gpio.get = nv50_gpio_get;
359 engine->gpio.set = nv50_gpio_set; 376 engine->gpio.set = nv50_gpio_set;
360 engine->gpio.irq_enable = nv50_gpio_irq_enable; 377 engine->gpio.irq_enable = nv50_gpio_irq_enable;
378 switch (dev_priv->chipset) {
379 case 0xa3:
380 case 0xa5:
381 case 0xa8:
382 case 0xaf:
383 engine->pm.clock_get = nva3_pm_clock_get;
384 engine->pm.clock_pre = nva3_pm_clock_pre;
385 engine->pm.clock_set = nva3_pm_clock_set;
386 break;
387 default:
388 engine->pm.clock_get = nv50_pm_clock_get;
389 engine->pm.clock_pre = nv50_pm_clock_pre;
390 engine->pm.clock_set = nv50_pm_clock_set;
391 break;
392 }
393 engine->pm.voltage_get = nouveau_voltage_gpio_get;
394 engine->pm.voltage_set = nouveau_voltage_gpio_set;
395 if (dev_priv->chipset >= 0x84)
396 engine->pm.temp_get = nv84_temp_get;
397 else
398 engine->pm.temp_get = nv40_temp_get;
361 break; 399 break;
362 case 0xC0: 400 case 0xC0:
363 engine->instmem.init = nvc0_instmem_init; 401 engine->instmem.init = nvc0_instmem_init;
@@ -437,16 +475,14 @@ static int
437nouveau_card_init_channel(struct drm_device *dev) 475nouveau_card_init_channel(struct drm_device *dev)
438{ 476{
439 struct drm_nouveau_private *dev_priv = dev->dev_private; 477 struct drm_nouveau_private *dev_priv = dev->dev_private;
440 struct nouveau_gpuobj *gpuobj; 478 struct nouveau_gpuobj *gpuobj = NULL;
441 int ret; 479 int ret;
442 480
443 ret = nouveau_channel_alloc(dev, &dev_priv->channel, 481 ret = nouveau_channel_alloc(dev, &dev_priv->channel,
444 (struct drm_file *)-2, 482 (struct drm_file *)-2, NvDmaFB, NvDmaTT);
445 NvDmaFB, NvDmaTT);
446 if (ret) 483 if (ret)
447 return ret; 484 return ret;
448 485
449 gpuobj = NULL;
450 ret = nouveau_gpuobj_dma_new(dev_priv->channel, NV_CLASS_DMA_IN_MEMORY, 486 ret = nouveau_gpuobj_dma_new(dev_priv->channel, NV_CLASS_DMA_IN_MEMORY,
451 0, dev_priv->vram_size, 487 0, dev_priv->vram_size,
452 NV_DMA_ACCESS_RW, NV_DMA_TARGET_VIDMEM, 488 NV_DMA_ACCESS_RW, NV_DMA_TARGET_VIDMEM,
@@ -454,26 +490,25 @@ nouveau_card_init_channel(struct drm_device *dev)
454 if (ret) 490 if (ret)
455 goto out_err; 491 goto out_err;
456 492
457 ret = nouveau_gpuobj_ref_add(dev, dev_priv->channel, NvDmaVRAM, 493 ret = nouveau_ramht_insert(dev_priv->channel, NvDmaVRAM, gpuobj);
458 gpuobj, NULL); 494 nouveau_gpuobj_ref(NULL, &gpuobj);
459 if (ret) 495 if (ret)
460 goto out_err; 496 goto out_err;
461 497
462 gpuobj = NULL;
463 ret = nouveau_gpuobj_gart_dma_new(dev_priv->channel, 0, 498 ret = nouveau_gpuobj_gart_dma_new(dev_priv->channel, 0,
464 dev_priv->gart_info.aper_size, 499 dev_priv->gart_info.aper_size,
465 NV_DMA_ACCESS_RW, &gpuobj, NULL); 500 NV_DMA_ACCESS_RW, &gpuobj, NULL);
466 if (ret) 501 if (ret)
467 goto out_err; 502 goto out_err;
468 503
469 ret = nouveau_gpuobj_ref_add(dev, dev_priv->channel, NvDmaGART, 504 ret = nouveau_ramht_insert(dev_priv->channel, NvDmaGART, gpuobj);
470 gpuobj, NULL); 505 nouveau_gpuobj_ref(NULL, &gpuobj);
471 if (ret) 506 if (ret)
472 goto out_err; 507 goto out_err;
473 508
474 return 0; 509 return 0;
510
475out_err: 511out_err:
476 nouveau_gpuobj_del(dev, &gpuobj);
477 nouveau_channel_free(dev_priv->channel); 512 nouveau_channel_free(dev_priv->channel);
478 dev_priv->channel = NULL; 513 dev_priv->channel = NULL;
479 return ret; 514 return ret;
@@ -534,35 +569,28 @@ nouveau_card_init(struct drm_device *dev)
534 if (ret) 569 if (ret)
535 goto out_display_early; 570 goto out_display_early;
536 571
537 ret = nouveau_mem_detect(dev); 572 nouveau_pm_init(dev);
573
574 ret = nouveau_mem_vram_init(dev);
538 if (ret) 575 if (ret)
539 goto out_bios; 576 goto out_bios;
540 577
541 ret = nouveau_gpuobj_early_init(dev); 578 ret = nouveau_gpuobj_init(dev);
542 if (ret) 579 if (ret)
543 goto out_bios; 580 goto out_vram;
544 581
545 /* Initialise instance memory, must happen before mem_init so we
546 * know exactly how much VRAM we're able to use for "normal"
547 * purposes.
548 */
549 ret = engine->instmem.init(dev); 582 ret = engine->instmem.init(dev);
550 if (ret) 583 if (ret)
551 goto out_gpuobj_early; 584 goto out_gpuobj;
552 585
553 /* Setup the memory manager */ 586 ret = nouveau_mem_gart_init(dev);
554 ret = nouveau_mem_init(dev);
555 if (ret) 587 if (ret)
556 goto out_instmem; 588 goto out_instmem;
557 589
558 ret = nouveau_gpuobj_init(dev);
559 if (ret)
560 goto out_mem;
561
562 /* PMC */ 590 /* PMC */
563 ret = engine->mc.init(dev); 591 ret = engine->mc.init(dev);
564 if (ret) 592 if (ret)
565 goto out_gpuobj; 593 goto out_gart;
566 594
567 /* PGPIO */ 595 /* PGPIO */
568 ret = engine->gpio.init(dev); 596 ret = engine->gpio.init(dev);
@@ -611,9 +639,13 @@ nouveau_card_init(struct drm_device *dev)
611 /* what about PVIDEO/PCRTC/PRAMDAC etc? */ 639 /* what about PVIDEO/PCRTC/PRAMDAC etc? */
612 640
613 if (!engine->graph.accel_blocked) { 641 if (!engine->graph.accel_blocked) {
614 ret = nouveau_card_init_channel(dev); 642 ret = nouveau_fence_init(dev);
615 if (ret) 643 if (ret)
616 goto out_irq; 644 goto out_irq;
645
646 ret = nouveau_card_init_channel(dev);
647 if (ret)
648 goto out_fence;
617 } 649 }
618 650
619 ret = nouveau_backlight_init(dev); 651 ret = nouveau_backlight_init(dev);
@@ -624,6 +656,8 @@ nouveau_card_init(struct drm_device *dev)
624 drm_kms_helper_poll_init(dev); 656 drm_kms_helper_poll_init(dev);
625 return 0; 657 return 0;
626 658
659out_fence:
660 nouveau_fence_fini(dev);
627out_irq: 661out_irq:
628 drm_irq_uninstall(dev); 662 drm_irq_uninstall(dev);
629out_display: 663out_display:
@@ -642,16 +676,16 @@ out_gpio:
642 engine->gpio.takedown(dev); 676 engine->gpio.takedown(dev);
643out_mc: 677out_mc:
644 engine->mc.takedown(dev); 678 engine->mc.takedown(dev);
645out_gpuobj: 679out_gart:
646 nouveau_gpuobj_takedown(dev); 680 nouveau_mem_gart_fini(dev);
647out_mem:
648 nouveau_sgdma_takedown(dev);
649 nouveau_mem_close(dev);
650out_instmem: 681out_instmem:
651 engine->instmem.takedown(dev); 682 engine->instmem.takedown(dev);
652out_gpuobj_early: 683out_gpuobj:
653 nouveau_gpuobj_late_takedown(dev); 684 nouveau_gpuobj_takedown(dev);
685out_vram:
686 nouveau_mem_vram_fini(dev);
654out_bios: 687out_bios:
688 nouveau_pm_fini(dev);
655 nouveau_bios_takedown(dev); 689 nouveau_bios_takedown(dev);
656out_display_early: 690out_display_early:
657 engine->display.late_takedown(dev); 691 engine->display.late_takedown(dev);
@@ -667,7 +701,8 @@ static void nouveau_card_takedown(struct drm_device *dev)
667 701
668 nouveau_backlight_exit(dev); 702 nouveau_backlight_exit(dev);
669 703
670 if (dev_priv->channel) { 704 if (!engine->graph.accel_blocked) {
705 nouveau_fence_fini(dev);
671 nouveau_channel_free(dev_priv->channel); 706 nouveau_channel_free(dev_priv->channel);
672 dev_priv->channel = NULL; 707 dev_priv->channel = NULL;
673 } 708 }
@@ -686,15 +721,15 @@ static void nouveau_card_takedown(struct drm_device *dev)
686 ttm_bo_clean_mm(&dev_priv->ttm.bdev, TTM_PL_VRAM); 721 ttm_bo_clean_mm(&dev_priv->ttm.bdev, TTM_PL_VRAM);
687 ttm_bo_clean_mm(&dev_priv->ttm.bdev, TTM_PL_TT); 722 ttm_bo_clean_mm(&dev_priv->ttm.bdev, TTM_PL_TT);
688 mutex_unlock(&dev->struct_mutex); 723 mutex_unlock(&dev->struct_mutex);
689 nouveau_sgdma_takedown(dev); 724 nouveau_mem_gart_fini(dev);
690 725
691 nouveau_gpuobj_takedown(dev);
692 nouveau_mem_close(dev);
693 engine->instmem.takedown(dev); 726 engine->instmem.takedown(dev);
727 nouveau_gpuobj_takedown(dev);
728 nouveau_mem_vram_fini(dev);
694 729
695 drm_irq_uninstall(dev); 730 drm_irq_uninstall(dev);
696 731
697 nouveau_gpuobj_late_takedown(dev); 732 nouveau_pm_fini(dev);
698 nouveau_bios_takedown(dev); 733 nouveau_bios_takedown(dev);
699 734
700 vga_client_register(dev->pdev, NULL, NULL, NULL); 735 vga_client_register(dev->pdev, NULL, NULL, NULL);
@@ -1057,7 +1092,7 @@ bool nouveau_wait_until(struct drm_device *dev, uint64_t timeout,
1057/* Waits for PGRAPH to go completely idle */ 1092/* Waits for PGRAPH to go completely idle */
1058bool nouveau_wait_for_idle(struct drm_device *dev) 1093bool nouveau_wait_for_idle(struct drm_device *dev)
1059{ 1094{
1060 if (!nv_wait(NV04_PGRAPH_STATUS, 0xffffffff, 0x00000000)) { 1095 if (!nv_wait(dev, NV04_PGRAPH_STATUS, 0xffffffff, 0x00000000)) {
1061 NV_ERROR(dev, "PGRAPH idle timed out with status 0x%08x\n", 1096 NV_ERROR(dev, "PGRAPH idle timed out with status 0x%08x\n",
1062 nv_rd32(dev, NV04_PGRAPH_STATUS)); 1097 nv_rd32(dev, NV04_PGRAPH_STATUS));
1063 return false; 1098 return false;