aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_dma.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/i915/i915_dma.c')
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c94
1 files changed, 59 insertions, 35 deletions
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 99daa896105d..4fa6beb14c77 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -992,6 +992,12 @@ static int i915_getparam(struct drm_device *dev, void *data,
992 case I915_PARAM_HAS_PINNED_BATCHES: 992 case I915_PARAM_HAS_PINNED_BATCHES:
993 value = 1; 993 value = 1;
994 break; 994 break;
995 case I915_PARAM_HAS_EXEC_NO_RELOC:
996 value = 1;
997 break;
998 case I915_PARAM_HAS_EXEC_HANDLE_LUT:
999 value = 1;
1000 break;
995 default: 1001 default:
996 DRM_DEBUG_DRIVER("Unknown parameter %d\n", 1002 DRM_DEBUG_DRIVER("Unknown parameter %d\n",
997 param->param); 1003 param->param);
@@ -1070,7 +1076,7 @@ static int i915_set_status_page(struct drm_device *dev, void *data,
1070 ring->status_page.gfx_addr = hws->addr & (0x1ffff<<12); 1076 ring->status_page.gfx_addr = hws->addr & (0x1ffff<<12);
1071 1077
1072 dev_priv->dri1.gfx_hws_cpu_addr = 1078 dev_priv->dri1.gfx_hws_cpu_addr =
1073 ioremap_wc(dev_priv->mm.gtt_base_addr + hws->addr, 4096); 1079 ioremap_wc(dev_priv->gtt.mappable_base + hws->addr, 4096);
1074 if (dev_priv->dri1.gfx_hws_cpu_addr == NULL) { 1080 if (dev_priv->dri1.gfx_hws_cpu_addr == NULL) {
1075 i915_dma_cleanup(dev); 1081 i915_dma_cleanup(dev);
1076 ring->status_page.gfx_addr = 0; 1082 ring->status_page.gfx_addr = 0;
@@ -1297,19 +1303,21 @@ static int i915_load_modeset_init(struct drm_device *dev)
1297 if (ret) 1303 if (ret)
1298 goto cleanup_vga_switcheroo; 1304 goto cleanup_vga_switcheroo;
1299 1305
1306 ret = drm_irq_install(dev);
1307 if (ret)
1308 goto cleanup_gem_stolen;
1309
1310 /* Important: The output setup functions called by modeset_init need
1311 * working irqs for e.g. gmbus and dp aux transfers. */
1300 intel_modeset_init(dev); 1312 intel_modeset_init(dev);
1301 1313
1302 ret = i915_gem_init(dev); 1314 ret = i915_gem_init(dev);
1303 if (ret) 1315 if (ret)
1304 goto cleanup_gem_stolen; 1316 goto cleanup_irq;
1305
1306 intel_modeset_gem_init(dev);
1307 1317
1308 INIT_WORK(&dev_priv->console_resume_work, intel_console_resume); 1318 INIT_WORK(&dev_priv->console_resume_work, intel_console_resume);
1309 1319
1310 ret = drm_irq_install(dev); 1320 intel_modeset_gem_init(dev);
1311 if (ret)
1312 goto cleanup_gem;
1313 1321
1314 /* Always safe in the mode setting case. */ 1322 /* Always safe in the mode setting case. */
1315 /* FIXME: do pre/post-mode set stuff in core KMS code */ 1323 /* FIXME: do pre/post-mode set stuff in core KMS code */
@@ -1317,7 +1325,25 @@ static int i915_load_modeset_init(struct drm_device *dev)
1317 1325
1318 ret = intel_fbdev_init(dev); 1326 ret = intel_fbdev_init(dev);
1319 if (ret) 1327 if (ret)
1320 goto cleanup_irq; 1328 goto cleanup_gem;
1329
1330 /* Only enable hotplug handling once the fbdev is fully set up. */
1331 intel_hpd_init(dev);
1332
1333 /*
1334 * Some ports require correctly set-up hpd registers for detection to
1335 * work properly (leading to ghost connected connector status), e.g. VGA
1336 * on gm45. Hence we can only set up the initial fbdev config after hpd
1337 * irqs are fully enabled. Now we should scan for the initial config
1338 * only once hotplug handling is enabled, but due to screwed-up locking
1339 * around kms/fbdev init we can't protect the fdbev initial config
1340 * scanning against hotplug events. Hence do this first and ignore the
1341 * tiny window where we will loose hotplug notifactions.
1342 */
1343 intel_fbdev_initial_config(dev);
1344
1345 /* Only enable hotplug handling once the fbdev is fully set up. */
1346 dev_priv->enable_hotplug_processing = true;
1321 1347
1322 drm_kms_helper_poll_init(dev); 1348 drm_kms_helper_poll_init(dev);
1323 1349
@@ -1326,13 +1352,13 @@ static int i915_load_modeset_init(struct drm_device *dev)
1326 1352
1327 return 0; 1353 return 0;
1328 1354
1329cleanup_irq:
1330 drm_irq_uninstall(dev);
1331cleanup_gem: 1355cleanup_gem:
1332 mutex_lock(&dev->struct_mutex); 1356 mutex_lock(&dev->struct_mutex);
1333 i915_gem_cleanup_ringbuffer(dev); 1357 i915_gem_cleanup_ringbuffer(dev);
1334 mutex_unlock(&dev->struct_mutex); 1358 mutex_unlock(&dev->struct_mutex);
1335 i915_gem_cleanup_aliasing_ppgtt(dev); 1359 i915_gem_cleanup_aliasing_ppgtt(dev);
1360cleanup_irq:
1361 drm_irq_uninstall(dev);
1336cleanup_gem_stolen: 1362cleanup_gem_stolen:
1337 i915_gem_cleanup_stolen(dev); 1363 i915_gem_cleanup_stolen(dev);
1338cleanup_vga_switcheroo: 1364cleanup_vga_switcheroo:
@@ -1400,9 +1426,9 @@ static void i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
1400 if (!ap) 1426 if (!ap)
1401 return; 1427 return;
1402 1428
1403 ap->ranges[0].base = dev_priv->mm.gtt->gma_bus_addr; 1429 ap->ranges[0].base = dev_priv->gtt.mappable_base;
1404 ap->ranges[0].size = 1430 ap->ranges[0].size = dev_priv->gtt.mappable_end - dev_priv->gtt.start;
1405 dev_priv->mm.gtt->gtt_mappable_entries << PAGE_SHIFT; 1431
1406 primary = 1432 primary =
1407 pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; 1433 pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
1408 1434
@@ -1516,18 +1542,17 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1516 goto put_gmch; 1542 goto put_gmch;
1517 } 1543 }
1518 1544
1519 aperture_size = dev_priv->mm.gtt->gtt_mappable_entries << PAGE_SHIFT; 1545 aperture_size = dev_priv->gtt.mappable_end;
1520 dev_priv->mm.gtt_base_addr = dev_priv->mm.gtt->gma_bus_addr;
1521 1546
1522 dev_priv->mm.gtt_mapping = 1547 dev_priv->gtt.mappable =
1523 io_mapping_create_wc(dev_priv->mm.gtt_base_addr, 1548 io_mapping_create_wc(dev_priv->gtt.mappable_base,
1524 aperture_size); 1549 aperture_size);
1525 if (dev_priv->mm.gtt_mapping == NULL) { 1550 if (dev_priv->gtt.mappable == NULL) {
1526 ret = -EIO; 1551 ret = -EIO;
1527 goto out_rmmap; 1552 goto out_rmmap;
1528 } 1553 }
1529 1554
1530 i915_mtrr_setup(dev_priv, dev_priv->mm.gtt_base_addr, 1555 i915_mtrr_setup(dev_priv, dev_priv->gtt.mappable_base,
1531 aperture_size); 1556 aperture_size);
1532 1557
1533 /* The i915 workqueue is primarily used for batched retirement of 1558 /* The i915 workqueue is primarily used for batched retirement of
@@ -1580,11 +1605,12 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1580 pci_enable_msi(dev->pdev); 1605 pci_enable_msi(dev->pdev);
1581 1606
1582 spin_lock_init(&dev_priv->irq_lock); 1607 spin_lock_init(&dev_priv->irq_lock);
1583 spin_lock_init(&dev_priv->error_lock); 1608 spin_lock_init(&dev_priv->gpu_error.lock);
1584 spin_lock_init(&dev_priv->rps.lock); 1609 spin_lock_init(&dev_priv->rps.lock);
1585 spin_lock_init(&dev_priv->dpio_lock); 1610 mutex_init(&dev_priv->dpio_lock);
1586 1611
1587 mutex_init(&dev_priv->rps.hw_lock); 1612 mutex_init(&dev_priv->rps.hw_lock);
1613 mutex_init(&dev_priv->modeset_restore_lock);
1588 1614
1589 if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev)) 1615 if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev))
1590 dev_priv->num_pipe = 3; 1616 dev_priv->num_pipe = 3;
@@ -1614,9 +1640,6 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1614 intel_opregion_init(dev); 1640 intel_opregion_init(dev);
1615 acpi_video_register(); 1641 acpi_video_register();
1616 1642
1617 setup_timer(&dev_priv->hangcheck_timer, i915_hangcheck_elapsed,
1618 (unsigned long) dev);
1619
1620 if (IS_GEN5(dev)) 1643 if (IS_GEN5(dev))
1621 intel_gpu_ips_init(dev_priv); 1644 intel_gpu_ips_init(dev_priv);
1622 1645
@@ -1635,15 +1658,15 @@ out_gem_unload:
1635out_mtrrfree: 1658out_mtrrfree:
1636 if (dev_priv->mm.gtt_mtrr >= 0) { 1659 if (dev_priv->mm.gtt_mtrr >= 0) {
1637 mtrr_del(dev_priv->mm.gtt_mtrr, 1660 mtrr_del(dev_priv->mm.gtt_mtrr,
1638 dev_priv->mm.gtt_base_addr, 1661 dev_priv->gtt.mappable_base,
1639 aperture_size); 1662 aperture_size);
1640 dev_priv->mm.gtt_mtrr = -1; 1663 dev_priv->mm.gtt_mtrr = -1;
1641 } 1664 }
1642 io_mapping_free(dev_priv->mm.gtt_mapping); 1665 io_mapping_free(dev_priv->gtt.mappable);
1643out_rmmap: 1666out_rmmap:
1644 pci_iounmap(dev->pdev, dev_priv->regs); 1667 pci_iounmap(dev->pdev, dev_priv->regs);
1645put_gmch: 1668put_gmch:
1646 i915_gem_gtt_fini(dev); 1669 dev_priv->gtt.gtt_remove(dev);
1647put_bridge: 1670put_bridge:
1648 pci_dev_put(dev_priv->bridge_dev); 1671 pci_dev_put(dev_priv->bridge_dev);
1649free_priv: 1672free_priv:
@@ -1673,11 +1696,11 @@ int i915_driver_unload(struct drm_device *dev)
1673 /* Cancel the retire work handler, which should be idle now. */ 1696 /* Cancel the retire work handler, which should be idle now. */
1674 cancel_delayed_work_sync(&dev_priv->mm.retire_work); 1697 cancel_delayed_work_sync(&dev_priv->mm.retire_work);
1675 1698
1676 io_mapping_free(dev_priv->mm.gtt_mapping); 1699 io_mapping_free(dev_priv->gtt.mappable);
1677 if (dev_priv->mm.gtt_mtrr >= 0) { 1700 if (dev_priv->mm.gtt_mtrr >= 0) {
1678 mtrr_del(dev_priv->mm.gtt_mtrr, 1701 mtrr_del(dev_priv->mm.gtt_mtrr,
1679 dev_priv->mm.gtt_base_addr, 1702 dev_priv->gtt.mappable_base,
1680 dev_priv->mm.gtt->gtt_mappable_entries * PAGE_SIZE); 1703 dev_priv->gtt.mappable_end);
1681 dev_priv->mm.gtt_mtrr = -1; 1704 dev_priv->mm.gtt_mtrr = -1;
1682 } 1705 }
1683 1706
@@ -1703,8 +1726,8 @@ int i915_driver_unload(struct drm_device *dev)
1703 } 1726 }
1704 1727
1705 /* Free error state after interrupts are fully disabled. */ 1728 /* Free error state after interrupts are fully disabled. */
1706 del_timer_sync(&dev_priv->hangcheck_timer); 1729 del_timer_sync(&dev_priv->gpu_error.hangcheck_timer);
1707 cancel_work_sync(&dev_priv->error_work); 1730 cancel_work_sync(&dev_priv->gpu_error.work);
1708 i915_destroy_error_state(dev); 1731 i915_destroy_error_state(dev);
1709 1732
1710 if (dev->pdev->msi_enabled) 1733 if (dev->pdev->msi_enabled)
@@ -1723,9 +1746,6 @@ int i915_driver_unload(struct drm_device *dev)
1723 mutex_unlock(&dev->struct_mutex); 1746 mutex_unlock(&dev->struct_mutex);
1724 i915_gem_cleanup_aliasing_ppgtt(dev); 1747 i915_gem_cleanup_aliasing_ppgtt(dev);
1725 i915_gem_cleanup_stolen(dev); 1748 i915_gem_cleanup_stolen(dev);
1726 drm_mm_takedown(&dev_priv->mm.stolen);
1727
1728 intel_cleanup_overlay(dev);
1729 1749
1730 if (!I915_NEED_GFX_HWS(dev)) 1750 if (!I915_NEED_GFX_HWS(dev))
1731 i915_free_hws(dev); 1751 i915_free_hws(dev);
@@ -1738,6 +1758,10 @@ int i915_driver_unload(struct drm_device *dev)
1738 intel_teardown_mchbar(dev); 1758 intel_teardown_mchbar(dev);
1739 1759
1740 destroy_workqueue(dev_priv->wq); 1760 destroy_workqueue(dev_priv->wq);
1761 pm_qos_remove_request(&dev_priv->pm_qos);
1762
1763 if (dev_priv->slab)
1764 kmem_cache_destroy(dev_priv->slab);
1741 1765
1742 pci_dev_put(dev_priv->bridge_dev); 1766 pci_dev_put(dev_priv->bridge_dev);
1743 kfree(dev->dev_private); 1767 kfree(dev->dev_private);