drm/nv50: fix iommu errors caused by device reading from address 0
[safe/jmp/linux-2.6] / drivers / gpu / drm / nouveau / nouveau_state.c
index c667a11..b02a231 100644 (file)
@@ -376,12 +376,15 @@ out_err:
 static void nouveau_switcheroo_set_state(struct pci_dev *pdev,
                                         enum vga_switcheroo_state state)
 {
+       struct drm_device *dev = pci_get_drvdata(pdev);
        pm_message_t pmm = { .event = PM_EVENT_SUSPEND };
        if (state == VGA_SWITCHEROO_ON) {
                printk(KERN_ERR "VGA switcheroo: switched nouveau on\n");
                nouveau_pci_resume(pdev);
+               drm_kms_helper_poll_enable(dev);
        } else {
                printk(KERN_ERR "VGA switcheroo: switched nouveau off\n");
+               drm_kms_helper_poll_disable(dev);
                nouveau_pci_suspend(pdev, pmm);
        }
 }
@@ -516,8 +519,10 @@ nouveau_card_init(struct drm_device *dev)
 
        dev_priv->init_state = NOUVEAU_CARD_INIT_DONE;
 
-       if (drm_core_check_feature(dev, DRIVER_MODESET))
+       if (drm_core_check_feature(dev, DRIVER_MODESET)) {
                nouveau_fbcon_init(dev);
+               drm_kms_helper_poll_init(dev);
+       }
 
        return 0;
 
@@ -774,29 +779,24 @@ int nouveau_load(struct drm_device *dev, unsigned long flags)
                        return ret;
        }
 
-       /* map larger RAMIN aperture on NV40 cards */
-       dev_priv->ramin  = NULL;
+       /* Map PRAMIN BAR, or on older cards, the aperture withing BAR0 */
        if (dev_priv->card_type >= NV_40) {
                int ramin_bar = 2;
                if (pci_resource_len(dev->pdev, ramin_bar) == 0)
                        ramin_bar = 3;
 
                dev_priv->ramin_size = pci_resource_len(dev->pdev, ramin_bar);
-               dev_priv->ramin = ioremap(
-                               pci_resource_start(dev->pdev, ramin_bar),
+               dev_priv->ramin =
+                       ioremap(pci_resource_start(dev->pdev, ramin_bar),
                                dev_priv->ramin_size);
                if (!dev_priv->ramin) {
-                       NV_ERROR(dev, "Failed to init RAMIN mapping, "
-                                     "limited instance memory available\n");
+                       NV_ERROR(dev, "Failed to PRAMIN BAR");
+                       return -ENOMEM;
                }
-       }
-
-       /* On older cards (or if the above failed), create a map covering
-        * the BAR0 PRAMIN aperture */
-       if (!dev_priv->ramin) {
+       } else {
                dev_priv->ramin_size = 1 * 1024 * 1024;
                dev_priv->ramin = ioremap(mmio_start_offs + NV_RAMIN,
-                                                       dev_priv->ramin_size);
+                                         dev_priv->ramin_size);
                if (!dev_priv->ramin) {
                        NV_ERROR(dev, "Failed to map BAR0 PRAMIN.\n");
                        return -ENOMEM;
@@ -844,6 +844,7 @@ int nouveau_unload(struct drm_device *dev)
        struct drm_nouveau_private *dev_priv = dev->dev_private;
 
        if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+               drm_kms_helper_poll_fini(dev);
                nouveau_fbcon_fini(dev);
                if (dev_priv->card_type >= NV_50)
                        nv50_display_destroy(dev);
@@ -910,6 +911,9 @@ int nouveau_ioctl_getparam(struct drm_device *dev, void *data,
        case NOUVEAU_GETPARAM_VM_VRAM_BASE:
                getparam->value = dev_priv->vm_vram_base;
                break;
+       case NOUVEAU_GETPARAM_PTIMER_TIME:
+               getparam->value = dev_priv->engine.timer.read(dev);
+               break;
        case NOUVEAU_GETPARAM_GRAPH_UNITS:
                /* NV40 and NV50 versions are quite different, but register
                 * address is the same. User is supposed to know the card