aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bo.c3
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_channel.c3
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.h13
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_gem.c9
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_notifier.c1
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_object.c2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_state.c68
7 files changed, 25 insertions, 74 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 1371c77295f2..3ca8343c15df 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -711,8 +711,7 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr,
711 return ret; 711 return ret;
712 712
713 /* Software copy if the card isn't up and running yet. */ 713 /* Software copy if the card isn't up and running yet. */
714 if (dev_priv->init_state != NOUVEAU_CARD_INIT_DONE || 714 if (!dev_priv->channel) {
715 !dev_priv->channel) {
716 ret = ttm_bo_move_memcpy(bo, evict, no_wait_reserve, no_wait_gpu, new_mem); 715 ret = ttm_bo_move_memcpy(bo, evict, no_wait_reserve, no_wait_gpu, new_mem);
717 goto out; 716 goto out;
718 } 717 }
diff --git a/drivers/gpu/drm/nouveau/nouveau_channel.c b/drivers/gpu/drm/nouveau/nouveau_channel.c
index 06555c7cde50..53daeba4581e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_channel.c
+++ b/drivers/gpu/drm/nouveau/nouveau_channel.c
@@ -369,8 +369,6 @@ nouveau_ioctl_fifo_alloc(struct drm_device *dev, void *data,
369 struct nouveau_channel *chan; 369 struct nouveau_channel *chan;
370 int ret; 370 int ret;
371 371
372 NOUVEAU_CHECK_INITIALISED_WITH_RETURN;
373
374 if (dev_priv->engine.graph.accel_blocked) 372 if (dev_priv->engine.graph.accel_blocked)
375 return -ENODEV; 373 return -ENODEV;
376 374
@@ -419,7 +417,6 @@ nouveau_ioctl_fifo_free(struct drm_device *dev, void *data,
419 struct drm_nouveau_channel_free *cfree = data; 417 struct drm_nouveau_channel_free *cfree = data;
420 struct nouveau_channel *chan; 418 struct nouveau_channel *chan;
421 419
422 NOUVEAU_CHECK_INITIALISED_WITH_RETURN;
423 NOUVEAU_GET_USER_CHANNEL_WITH_RETURN(cfree->channel, file_priv, chan); 420 NOUVEAU_GET_USER_CHANNEL_WITH_RETURN(cfree->channel, file_priv, chan);
424 421
425 nouveau_channel_free(chan); 422 nouveau_channel_free(chan);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 4de342f54fd2..afebd32af203 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -492,11 +492,6 @@ enum nouveau_card_type {
492 492
493struct drm_nouveau_private { 493struct drm_nouveau_private {
494 struct drm_device *dev; 494 struct drm_device *dev;
495 enum {
496 NOUVEAU_CARD_INIT_DOWN,
497 NOUVEAU_CARD_INIT_DONE,
498 NOUVEAU_CARD_INIT_FAILED
499 } init_state;
500 495
501 /* the card type, takes NV_* as values */ 496 /* the card type, takes NV_* as values */
502 enum nouveau_card_type card_type; 497 enum nouveau_card_type card_type;
@@ -649,14 +644,6 @@ nouveau_bo_ref(struct nouveau_bo *ref, struct nouveau_bo **pnvbo)
649 return 0; 644 return 0;
650} 645}
651 646
652#define NOUVEAU_CHECK_INITIALISED_WITH_RETURN do { \
653 struct drm_nouveau_private *nv = dev->dev_private; \
654 if (nv->init_state != NOUVEAU_CARD_INIT_DONE) { \
655 NV_ERROR(dev, "called without init\n"); \
656 return -EINVAL; \
657 } \
658} while (0)
659
660#define NOUVEAU_GET_USER_CHANNEL_WITH_RETURN(id, cl, ch) do { \ 647#define NOUVEAU_GET_USER_CHANNEL_WITH_RETURN(id, cl, ch) do { \
661 struct drm_nouveau_private *nv = dev->dev_private; \ 648 struct drm_nouveau_private *nv = dev->dev_private; \
662 if (!nouveau_channel_owner(dev, (cl), (id))) { \ 649 if (!nouveau_channel_owner(dev, (cl), (id))) { \
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 791531bdb2c4..547f2c24c1e7 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -137,8 +137,6 @@ nouveau_gem_ioctl_new(struct drm_device *dev, void *data,
137 uint32_t flags = 0; 137 uint32_t flags = 0;
138 int ret = 0; 138 int ret = 0;
139 139
140 NOUVEAU_CHECK_INITIALISED_WITH_RETURN;
141
142 if (unlikely(dev_priv->ttm.bdev.dev_mapping == NULL)) 140 if (unlikely(dev_priv->ttm.bdev.dev_mapping == NULL))
143 dev_priv->ttm.bdev.dev_mapping = dev_priv->dev->dev_mapping; 141 dev_priv->ttm.bdev.dev_mapping = dev_priv->dev->dev_mapping;
144 142
@@ -580,7 +578,6 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data,
580 struct nouveau_fence *fence = NULL; 578 struct nouveau_fence *fence = NULL;
581 int i, j, ret = 0, do_reloc = 0; 579 int i, j, ret = 0, do_reloc = 0;
582 580
583 NOUVEAU_CHECK_INITIALISED_WITH_RETURN;
584 NOUVEAU_GET_USER_CHANNEL_WITH_RETURN(req->channel, file_priv, chan); 581 NOUVEAU_GET_USER_CHANNEL_WITH_RETURN(req->channel, file_priv, chan);
585 582
586 req->vram_available = dev_priv->fb_aper_free; 583 req->vram_available = dev_priv->fb_aper_free;
@@ -760,8 +757,6 @@ nouveau_gem_ioctl_cpu_prep(struct drm_device *dev, void *data,
760 bool no_wait = !!(req->flags & NOUVEAU_GEM_CPU_PREP_NOWAIT); 757 bool no_wait = !!(req->flags & NOUVEAU_GEM_CPU_PREP_NOWAIT);
761 int ret = -EINVAL; 758 int ret = -EINVAL;
762 759
763 NOUVEAU_CHECK_INITIALISED_WITH_RETURN;
764
765 gem = drm_gem_object_lookup(dev, file_priv, req->handle); 760 gem = drm_gem_object_lookup(dev, file_priv, req->handle);
766 if (!gem) 761 if (!gem)
767 return ret; 762 return ret;
@@ -800,8 +795,6 @@ nouveau_gem_ioctl_cpu_fini(struct drm_device *dev, void *data,
800 struct nouveau_bo *nvbo; 795 struct nouveau_bo *nvbo;
801 int ret = -EINVAL; 796 int ret = -EINVAL;
802 797
803 NOUVEAU_CHECK_INITIALISED_WITH_RETURN;
804
805 gem = drm_gem_object_lookup(dev, file_priv, req->handle); 798 gem = drm_gem_object_lookup(dev, file_priv, req->handle);
806 if (!gem) 799 if (!gem)
807 return ret; 800 return ret;
@@ -827,8 +820,6 @@ nouveau_gem_ioctl_info(struct drm_device *dev, void *data,
827 struct drm_gem_object *gem; 820 struct drm_gem_object *gem;
828 int ret; 821 int ret;
829 822
830 NOUVEAU_CHECK_INITIALISED_WITH_RETURN;
831
832 gem = drm_gem_object_lookup(dev, file_priv, req->handle); 823 gem = drm_gem_object_lookup(dev, file_priv, req->handle);
833 if (!gem) 824 if (!gem)
834 return -EINVAL; 825 return -EINVAL;
diff --git a/drivers/gpu/drm/nouveau/nouveau_notifier.c b/drivers/gpu/drm/nouveau/nouveau_notifier.c
index 32f7fbd7484d..3ec181ff50ce 100644
--- a/drivers/gpu/drm/nouveau/nouveau_notifier.c
+++ b/drivers/gpu/drm/nouveau/nouveau_notifier.c
@@ -184,7 +184,6 @@ nouveau_ioctl_notifier_alloc(struct drm_device *dev, void *data,
184 struct nouveau_channel *chan; 184 struct nouveau_channel *chan;
185 int ret; 185 int ret;
186 186
187 NOUVEAU_CHECK_INITIALISED_WITH_RETURN;
188 NOUVEAU_GET_USER_CHANNEL_WITH_RETURN(na->channel, file_priv, chan); 187 NOUVEAU_GET_USER_CHANNEL_WITH_RETURN(na->channel, file_priv, chan);
189 188
190 ret = nouveau_notifier_alloc(chan, na->handle, na->size, &na->offset); 189 ret = nouveau_notifier_alloc(chan, na->handle, na->size, &na->offset);
diff --git a/drivers/gpu/drm/nouveau/nouveau_object.c b/drivers/gpu/drm/nouveau/nouveau_object.c
index d436c3c7f4f5..5624f37e4c75 100644
--- a/drivers/gpu/drm/nouveau/nouveau_object.c
+++ b/drivers/gpu/drm/nouveau/nouveau_object.c
@@ -1232,7 +1232,6 @@ int nouveau_ioctl_grobj_alloc(struct drm_device *dev, void *data,
1232 struct nouveau_channel *chan; 1232 struct nouveau_channel *chan;
1233 int ret; 1233 int ret;
1234 1234
1235 NOUVEAU_CHECK_INITIALISED_WITH_RETURN;
1236 NOUVEAU_GET_USER_CHANNEL_WITH_RETURN(init->channel, file_priv, chan); 1235 NOUVEAU_GET_USER_CHANNEL_WITH_RETURN(init->channel, file_priv, chan);
1237 1236
1238 if (init->handle == ~0) 1237 if (init->handle == ~0)
@@ -1283,7 +1282,6 @@ int nouveau_ioctl_gpuobj_free(struct drm_device *dev, void *data,
1283 struct nouveau_channel *chan; 1282 struct nouveau_channel *chan;
1284 int ret; 1283 int ret;
1285 1284
1286 NOUVEAU_CHECK_INITIALISED_WITH_RETURN;
1287 NOUVEAU_GET_USER_CHANNEL_WITH_RETURN(objfree->channel, file_priv, chan); 1285 NOUVEAU_GET_USER_CHANNEL_WITH_RETURN(objfree->channel, file_priv, chan);
1288 1286
1289 ret = nouveau_gpuobj_ref_find(chan, objfree->handle, &ref); 1287 ret = nouveau_gpuobj_ref_find(chan, objfree->handle, &ref);
diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c
index 3e241e4a6485..6fd99f10eed6 100644
--- a/drivers/gpu/drm/nouveau/nouveau_state.c
+++ b/drivers/gpu/drm/nouveau/nouveau_state.c
@@ -407,11 +407,6 @@ nouveau_card_init(struct drm_device *dev)
407 struct nouveau_engine *engine; 407 struct nouveau_engine *engine;
408 int ret; 408 int ret;
409 409
410 NV_DEBUG(dev, "prev state = %d\n", dev_priv->init_state);
411
412 if (dev_priv->init_state == NOUVEAU_CARD_INIT_DONE)
413 return 0;
414
415 vga_client_register(dev->pdev, dev, NULL, nouveau_vga_set_decode); 410 vga_client_register(dev->pdev, dev, NULL, nouveau_vga_set_decode);
416 vga_switcheroo_register_client(dev->pdev, nouveau_switcheroo_set_state, 411 vga_switcheroo_register_client(dev->pdev, nouveau_switcheroo_set_state,
417 nouveau_switcheroo_can_switch); 412 nouveau_switcheroo_can_switch);
@@ -421,7 +416,6 @@ nouveau_card_init(struct drm_device *dev)
421 if (ret) 416 if (ret)
422 goto out; 417 goto out;
423 engine = &dev_priv->engine; 418 engine = &dev_priv->engine;
424 dev_priv->init_state = NOUVEAU_CARD_INIT_FAILED;
425 spin_lock_init(&dev_priv->context_switch_lock); 419 spin_lock_init(&dev_priv->context_switch_lock);
426 420
427 /* Parse BIOS tables / Run init tables if card not POSTed */ 421 /* Parse BIOS tables / Run init tables if card not POSTed */
@@ -513,8 +507,6 @@ nouveau_card_init(struct drm_device *dev)
513 if (ret) 507 if (ret)
514 NV_ERROR(dev, "Error %d registering backlight\n", ret); 508 NV_ERROR(dev, "Error %d registering backlight\n", ret);
515 509
516 dev_priv->init_state = NOUVEAU_CARD_INIT_DONE;
517
518 nouveau_fbcon_init(dev); 510 nouveau_fbcon_init(dev);
519 drm_kms_helper_poll_init(dev); 511 drm_kms_helper_poll_init(dev);
520 return 0; 512 return 0;
@@ -559,44 +551,37 @@ static void nouveau_card_takedown(struct drm_device *dev)
559 struct drm_nouveau_private *dev_priv = dev->dev_private; 551 struct drm_nouveau_private *dev_priv = dev->dev_private;
560 struct nouveau_engine *engine = &dev_priv->engine; 552 struct nouveau_engine *engine = &dev_priv->engine;
561 553
562 NV_DEBUG(dev, "prev state = %d\n", dev_priv->init_state); 554 nouveau_backlight_exit(dev);
563
564 if (dev_priv->init_state != NOUVEAU_CARD_INIT_DOWN) {
565 555
566 nouveau_backlight_exit(dev); 556 if (dev_priv->channel) {
567 557 nouveau_channel_free(dev_priv->channel);
568 if (dev_priv->channel) { 558 dev_priv->channel = NULL;
569 nouveau_channel_free(dev_priv->channel); 559 }
570 dev_priv->channel = NULL;
571 }
572
573 if (!nouveau_noaccel) {
574 engine->fifo.takedown(dev);
575 engine->graph.takedown(dev);
576 }
577 engine->fb.takedown(dev);
578 engine->timer.takedown(dev);
579 engine->mc.takedown(dev);
580 560
581 mutex_lock(&dev->struct_mutex); 561 if (!nouveau_noaccel) {
582 ttm_bo_clean_mm(&dev_priv->ttm.bdev, TTM_PL_VRAM); 562 engine->fifo.takedown(dev);
583 ttm_bo_clean_mm(&dev_priv->ttm.bdev, TTM_PL_TT); 563 engine->graph.takedown(dev);
584 mutex_unlock(&dev->struct_mutex); 564 }
585 nouveau_sgdma_takedown(dev); 565 engine->fb.takedown(dev);
566 engine->timer.takedown(dev);
567 engine->mc.takedown(dev);
586 568
587 nouveau_gpuobj_takedown(dev); 569 mutex_lock(&dev->struct_mutex);
588 nouveau_mem_close(dev); 570 ttm_bo_clean_mm(&dev_priv->ttm.bdev, TTM_PL_VRAM);
589 engine->instmem.takedown(dev); 571 ttm_bo_clean_mm(&dev_priv->ttm.bdev, TTM_PL_TT);
572 mutex_unlock(&dev->struct_mutex);
573 nouveau_sgdma_takedown(dev);
590 574
591 drm_irq_uninstall(dev); 575 nouveau_gpuobj_takedown(dev);
576 nouveau_mem_close(dev);
577 engine->instmem.takedown(dev);
592 578
593 nouveau_gpuobj_late_takedown(dev); 579 drm_irq_uninstall(dev);
594 nouveau_bios_takedown(dev);
595 580
596 vga_client_register(dev->pdev, NULL, NULL, NULL); 581 nouveau_gpuobj_late_takedown(dev);
582 nouveau_bios_takedown(dev);
597 583
598 dev_priv->init_state = NOUVEAU_CARD_INIT_DOWN; 584 vga_client_register(dev->pdev, NULL, NULL, NULL);
599 }
600} 585}
601 586
602/* here a client dies, release the stuff that was allocated for its 587/* here a client dies, release the stuff that was allocated for its
@@ -692,7 +677,6 @@ int nouveau_load(struct drm_device *dev, unsigned long flags)
692 dev_priv->dev = dev; 677 dev_priv->dev = dev;
693 678
694 dev_priv->flags = flags & NOUVEAU_FLAGS; 679 dev_priv->flags = flags & NOUVEAU_FLAGS;
695 dev_priv->init_state = NOUVEAU_CARD_INIT_DOWN;
696 680
697 NV_DEBUG(dev, "vendor: 0x%X device: 0x%X class: 0x%X\n", 681 NV_DEBUG(dev, "vendor: 0x%X device: 0x%X class: 0x%X\n",
698 dev->pci_vendor, dev->pci_device, dev->pdev->class); 682 dev->pci_vendor, dev->pci_device, dev->pdev->class);
@@ -840,8 +824,6 @@ int nouveau_ioctl_getparam(struct drm_device *dev, void *data,
840 struct drm_nouveau_private *dev_priv = dev->dev_private; 824 struct drm_nouveau_private *dev_priv = dev->dev_private;
841 struct drm_nouveau_getparam *getparam = data; 825 struct drm_nouveau_getparam *getparam = data;
842 826
843 NOUVEAU_CHECK_INITIALISED_WITH_RETURN;
844
845 switch (getparam->param) { 827 switch (getparam->param) {
846 case NOUVEAU_GETPARAM_CHIPSET_ID: 828 case NOUVEAU_GETPARAM_CHIPSET_ID:
847 getparam->value = dev_priv->chipset; 829 getparam->value = dev_priv->chipset;
@@ -910,8 +892,6 @@ nouveau_ioctl_setparam(struct drm_device *dev, void *data,
910{ 892{
911 struct drm_nouveau_setparam *setparam = data; 893 struct drm_nouveau_setparam *setparam = data;
912 894
913 NOUVEAU_CHECK_INITIALISED_WITH_RETURN;
914
915 switch (setparam->param) { 895 switch (setparam->param) {
916 default: 896 default:
917 NV_ERROR(dev, "unknown parameter %lld\n", setparam->param); 897 NV_ERROR(dev, "unknown parameter %lld\n", setparam->param);