drm/nouveau: start culling unused code
[linux-2.6-block.git] / drivers / gpu / drm / nouveau / nouveau_drv.c
index 9a36f5f39b06447d5fce8ff6a17163eda7a41331..666c178c6022d252c77d7e3dc2440bc61eeef606 100644 (file)
 #include "nouveau_hw.h"
 #include "nouveau_fb.h"
 #include "nouveau_fbcon.h"
+#include "nouveau_fence.h"
 #include "nouveau_pm.h"
-#include "nouveau_fifo.h"
 #include "nv50_display.h"
 
 #include "drm_pciids.h"
 
-MODULE_PARM_DESC(agpmode, "AGP mode (0 to disable AGP)");
-int nouveau_agpmode = -1;
-module_param_named(agpmode, nouveau_agpmode, int, 0400);
-
 MODULE_PARM_DESC(modeset, "Enable kernel modesetting");
 int nouveau_modeset = -1;
 module_param_named(modeset, nouveau_modeset, int, 0400);
 
-MODULE_PARM_DESC(vbios, "Override default VBIOS location");
-char *nouveau_vbios;
-module_param_named(vbios, nouveau_vbios, charp, 0400);
-
-MODULE_PARM_DESC(vram_pushbuf, "Force DMA push buffers to be in VRAM");
-int nouveau_vram_pushbuf;
-module_param_named(vram_pushbuf, nouveau_vram_pushbuf, int, 0400);
-
 MODULE_PARM_DESC(vram_notify, "Force DMA notifiers to be in VRAM");
 int nouveau_vram_notify = 0;
 module_param_named(vram_notify, nouveau_vram_notify, int, 0400);
@@ -79,14 +67,6 @@ MODULE_PARM_DESC(ignorelid, "Ignore ACPI lid status");
 int nouveau_ignorelid = 0;
 module_param_named(ignorelid, nouveau_ignorelid, int, 0400);
 
-MODULE_PARM_DESC(noaccel, "Disable all acceleration");
-int nouveau_noaccel = -1;
-module_param_named(noaccel, nouveau_noaccel, int, 0400);
-
-MODULE_PARM_DESC(nofbaccel, "Disable fbcon acceleration");
-int nouveau_nofbaccel = 0;
-module_param_named(nofbaccel, nouveau_nofbaccel, int, 0400);
-
 MODULE_PARM_DESC(force_post, "Force POST");
 int nouveau_force_post = 0;
 module_param_named(force_post, nouveau_force_post, int, 0400);
@@ -107,13 +87,6 @@ MODULE_PARM_DESC(tv_norm, "Default TV norm.\n"
 char *nouveau_tv_norm;
 module_param_named(tv_norm, nouveau_tv_norm, charp, 0400);
 
-MODULE_PARM_DESC(reg_debug, "Register access debug bitmask:\n"
-               "\t\t0x1 mc, 0x2 video, 0x4 fb, 0x8 extdev,\n"
-               "\t\t0x10 crtc, 0x20 ramdac, 0x40 vgacrtc, 0x80 rmvio,\n"
-               "\t\t0x100 vgaattr, 0x200 EVO (G80+)");
-int nouveau_reg_debug;
-module_param_named(reg_debug, nouveau_reg_debug, int, 0600);
-
 MODULE_PARM_DESC(perflvl, "Performance level (default: boot)");
 char *nouveau_perflvl;
 module_param_named(perflvl, nouveau_perflvl, charp, 0400);
@@ -139,31 +112,15 @@ int nouveau_fbpercrtc;
 module_param_named(fbpercrtc, nouveau_fbpercrtc, int, 0400);
 #endif
 
-static struct pci_device_id pciidlist[] = {
-       {
-               PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID),
-               .class = PCI_BASE_CLASS_DISPLAY << 16,
-               .class_mask  = 0xff << 16,
-       },
-       {
-               PCI_DEVICE(PCI_VENDOR_ID_NVIDIA_SGS, PCI_ANY_ID),
-               .class = PCI_BASE_CLASS_DISPLAY << 16,
-               .class_mask  = 0xff << 16,
-       },
-       {}
-};
-
-MODULE_DEVICE_TABLE(pci, pciidlist);
-
 static struct drm_driver driver;
 
-static int __devinit
+int __devinit
 nouveau_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        return drm_get_pci_dev(pdev, ent, &driver);
 }
 
-static void
+void
 nouveau_pci_remove(struct pci_dev *pdev)
 {
        struct drm_device *dev = pci_get_drvdata(pdev);
@@ -175,25 +132,11 @@ int
 nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state)
 {
        struct drm_device *dev = pci_get_drvdata(pdev);
-       struct drm_nouveau_private *dev_priv = dev->dev_private;
-       struct nouveau_instmem_engine *pinstmem = &dev_priv->engine.instmem;
-       struct nouveau_fifo_priv *pfifo = nv_engine(dev, NVOBJ_ENGINE_FIFO);
-       struct nouveau_channel *chan;
        struct drm_crtc *crtc;
-       int ret, i, e;
-
-       if (pm_state.event == PM_EVENT_PRETHAW)
-               return 0;
-
-       if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
-               return 0;
 
        NV_INFO(dev, "Disabling display...\n");
        nouveau_display_fini(dev);
 
-       NV_INFO(dev, "Disabling fbcon...\n");
-       nouveau_fbcon_set_suspend(dev, 1);
-
        NV_INFO(dev, "Unpinning framebuffer(s)...\n");
        list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
                struct nouveau_framebuffer *nouveau_fb;
@@ -212,115 +155,23 @@ nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state)
                nouveau_bo_unpin(nv_crtc->cursor.nvbo);
        }
 
-       NV_INFO(dev, "Evicting buffers...\n");
-       ttm_bo_evict_mm(&dev_priv->ttm.bdev, TTM_PL_VRAM);
-
-       NV_INFO(dev, "Idling channels...\n");
-       for (i = 0; i < (pfifo ? pfifo->channels : 0); i++) {
-               chan = dev_priv->channels.ptr[i];
-
-               if (chan && chan->pushbuf_bo)
-                       nouveau_channel_idle(chan);
-       }
-
-       for (e = NVOBJ_ENGINE_NR - 1; e >= 0; e--) {
-               if (!dev_priv->eng[e])
-                       continue;
-
-               ret = dev_priv->eng[e]->fini(dev, e, true);
-               if (ret) {
-                       NV_ERROR(dev, "... engine %d failed: %d\n", e, ret);
-                       goto out_abort;
-               }
-       }
-
-       ret = pinstmem->suspend(dev);
-       if (ret) {
-               NV_ERROR(dev, "... failed: %d\n", ret);
-               goto out_abort;
-       }
-
-       NV_INFO(dev, "Suspending GPU objects...\n");
-       ret = nouveau_gpuobj_suspend(dev);
-       if (ret) {
-               NV_ERROR(dev, "... failed: %d\n", ret);
-               pinstmem->resume(dev);
-               goto out_abort;
-       }
-
-       NV_INFO(dev, "And we're gone!\n");
-       pci_save_state(pdev);
-       if (pm_state.event == PM_EVENT_SUSPEND) {
-               pci_disable_device(pdev);
-               pci_set_power_state(pdev, PCI_D3hot);
-       }
-
        return 0;
-
-out_abort:
-       NV_INFO(dev, "Re-enabling acceleration..\n");
-       for (e = e + 1; e < NVOBJ_ENGINE_NR; e++) {
-               if (dev_priv->eng[e])
-                       dev_priv->eng[e]->init(dev, e);
-       }
-       return ret;
 }
 
 int
 nouveau_pci_resume(struct pci_dev *pdev)
 {
        struct drm_device *dev = pci_get_drvdata(pdev);
-       struct nouveau_fifo_priv *pfifo = nv_engine(dev, NVOBJ_ENGINE_FIFO);
-       struct drm_nouveau_private *dev_priv = dev->dev_private;
-       struct nouveau_engine *engine = &dev_priv->engine;
        struct drm_crtc *crtc;
-       int ret, i;
+       int ret;
 
-       if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
-               return 0;
-
-       NV_INFO(dev, "We're back, enabling device...\n");
-       pci_set_power_state(pdev, PCI_D0);
-       pci_restore_state(pdev);
-       if (pci_enable_device(pdev))
-               return -1;
-       pci_set_master(dev->pdev);
-
-       /* Make sure the AGP controller is in a consistent state */
-       if (dev_priv->gart_info.type == NOUVEAU_GART_AGP)
-               nouveau_mem_reset_agp(dev);
-
-       /* Make the CRTCs accessible */
-       engine->display.early_init(dev);
-
-       NV_INFO(dev, "POSTing device...\n");
        ret = nouveau_run_vbios_init(dev);
        if (ret)
                return ret;
 
-       if (dev_priv->gart_info.type == NOUVEAU_GART_AGP) {
-               ret = nouveau_mem_init_agp(dev);
-               if (ret) {
-                       NV_ERROR(dev, "error reinitialising AGP: %d\n", ret);
-                       return ret;
-               }
-       }
-
-       NV_INFO(dev, "Restoring GPU objects...\n");
-       nouveau_gpuobj_resume(dev);
-
-       NV_INFO(dev, "Reinitialising engines...\n");
-       engine->instmem.resume(dev);
-       engine->mc.init(dev);
-       engine->timer.init(dev);
-       engine->fb.init(dev);
-       for (i = 0; i < NVOBJ_ENGINE_NR; i++) {
-               if (dev_priv->eng[i])
-                       dev_priv->eng[i]->init(dev, i);
-       }
-
        nouveau_irq_postinstall(dev);
 
+#if 0
        /* Re-write SKIPS, they'll have been lost over the suspend */
        if (nouveau_vram_pushbuf) {
                struct nouveau_channel *chan;
@@ -335,6 +186,7 @@ nouveau_pci_resume(struct pci_dev *pdev)
                                nouveau_bo_wr32(chan->pushbuf_bo, i, 0);
                }
        }
+#endif
 
        nouveau_pm_resume(dev);
 
@@ -415,22 +267,24 @@ static const struct file_operations nouveau_driver_fops = {
        .llseek = noop_llseek,
 };
 
+int nouveau_drm_load(struct drm_device *, unsigned long);
+int nouveau_drm_unload(struct drm_device *);
+int  nouveau_drm_open(struct drm_device *, struct drm_file *);
+void nouveau_drm_preclose(struct drm_device *dev, struct drm_file *);
+void nouveau_drm_postclose(struct drm_device *, struct drm_file *);
+
 static struct drm_driver driver = {
        .driver_features =
                DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_SG |
                DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_GEM |
                DRIVER_MODESET | DRIVER_PRIME,
-       .load = nouveau_load,
+       .load = nouveau_drm_load,
        .firstopen = nouveau_firstopen,
        .lastclose = nouveau_lastclose,
-       .unload = nouveau_unload,
-       .open = nouveau_open,
-       .preclose = nouveau_preclose,
-       .postclose = nouveau_postclose,
-#if defined(CONFIG_DRM_NOUVEAU_DEBUG)
-       .debugfs_init = nouveau_debugfs_init,
-       .debugfs_cleanup = nouveau_debugfs_takedown,
-#endif
+       .unload = nouveau_drm_unload,
+       .open = nouveau_drm_open,
+       .preclose = nouveau_drm_preclose,
+       .postclose = nouveau_drm_postclose,
        .irq_preinstall = nouveau_irq_preinstall,
        .irq_postinstall = nouveau_irq_postinstall,
        .irq_uninstall = nouveau_irq_uninstall,
@@ -467,16 +321,7 @@ static struct drm_driver driver = {
        .patchlevel = DRIVER_PATCHLEVEL,
 };
 
-static struct pci_driver nouveau_pci_driver = {
-               .name = DRIVER_NAME,
-               .id_table = pciidlist,
-               .probe = nouveau_pci_probe,
-               .remove = nouveau_pci_remove,
-               .suspend = nouveau_pci_suspend,
-               .resume = nouveau_pci_resume
-};
-
-static int __init nouveau_init(void)
+int __init nouveau_init(struct pci_driver *pdrv)
 {
        driver.num_ioctls = ARRAY_SIZE(nouveau_ioctls);
 
@@ -493,21 +338,14 @@ static int __init nouveau_init(void)
                return 0;
 
        nouveau_register_dsm_handler();
-       return drm_pci_init(&driver, &nouveau_pci_driver);
+       return drm_pci_init(&driver, pdrv);
 }
 
-static void __exit nouveau_exit(void)
+void __exit nouveau_exit(struct pci_driver *pdrv)
 {
        if (!nouveau_modeset)
                return;
 
-       drm_pci_exit(&driver, &nouveau_pci_driver);
+       drm_pci_exit(&driver, pdrv);
        nouveau_unregister_dsm_handler();
 }
-
-module_init(nouveau_init);
-module_exit(nouveau_exit);
-
-MODULE_AUTHOR(DRIVER_AUTHOR);
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE("GPL and additional rights");