aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_dma.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2012-04-12 05:27:01 -0400
committerDave Airlie <airlied@redhat.com>2012-04-12 05:27:01 -0400
commiteffbc4fd8e37e41d6f2bb6bcc611c14b4fbdcf9b (patch)
tree8bc2a6a2116f1031b0033bf1a8f9fbe92201c5c1 /drivers/gpu/drm/i915/i915_dma.c
parent6a7068b4ef17dfb9de3191321f1adc91fa1659ca (diff)
parentec34a01de31128e5c08e5f05c47f4a787f45a33c (diff)
Merge branch 'drm-intel-next' of git://people.freedesktop.org/~danvet/drm-intel into drm-core-next
Daniel Vetter wrote First pull request for 3.5-next, slightly large than usual because new things kept coming in since the last pull for 3.4. Highlights: - first batch of hw enablement for vlv (Jesse et al) and hsw (Eugeni). pci ids are not yet added, and there's still quite a few patches to merge (mostly modesetting). To make QA easier I've decided to merge this stuff in pieces. - loads of cleanups and prep patches spurred by the above. Especially vlv is a real frankenstein chip, but also hsw is stretching our driver's code design. Expect more to come in this area for 3.5. - more gmbus fixes, cleanups and improvements by Daniel Kurtz. Again, there are more patches needed (and some already queued up), but I wanted to split this a bit for better testing. - pwrite/pread rework and retuning. This series has been in the works for a few months already and a lot of i-g-t tests have been created for it. Now it's finally ready to be merged. Note that one patch in this series touches include/pagemap.h, that patch is acked-by akpm. - reduce mappable pressure and relocation throughput improvements from Chris. - mmap offset exhaustion mitigation by Chris Wilson. - a start at figuring out which codepaths in our messy dri1/ums+gem/kms driver we actually need to support by bailing out of unsupported case. The driver now refuses to load without kms on gen6+ and disallows a few ioctls that userspace never used in certain cases. More of this will definitely come. - More decoupling of global gtt and ppgtt. - Improved dual-link lvds detection by Takashi Iwai. - Shut up the compiler + plus fix the fallout (Ben) - Inverted panel brightness handling (mostly Acer manages to break things in this way). - Small fixlets and adjustements and some minor things to help debugging. Regression-wise QA reported quite a few issues on ivb, but all of them turned out to be hw stability issues which are already fixed in drm-intel-fixes (QA runs the nightly regression tests on -next alone, without -fixes automatically merged in). There's still one issue open on snb, it looks like occlusion query writes are not quite as cache coherent as we've expected. With some of the pwrite adjustements we can now reliably hit this. Kernel workaround for it is in the works." * 'drm-intel-next' of git://people.freedesktop.org/~danvet/drm-intel: (101 commits) drm/i915: VCS is not the last ring drm/i915: Add a dual link lvds quirk for MacBook Pro 8,2 drm/i915: make quirks more verbose drm/i915: dump the DMA fetch addr register on pre-gen6 drm/i915/sdvo: Include YRPB as an additional TV output type drm/i915: disallow gem init ioctl on ilk drm/i915: refuse to load on gen6+ without kms drm/i915: extract gt interrupt handler drm/i915: use render gen to switch ring irq functions drm/i915: rip out old HWSTAM missed irq WA for vlv drm/i915: open code gen6+ ring irqs drm/i915: ring irq cleanups drm/i915: add SFUSE_STRAP registers for digital port detection drm/i915: add WM_LINETIME registers drm/i915: add WRPLL clocks drm/i915: add LCPLL control registers drm/i915: add SSC offsets for SBI access drm/i915: add port clock selection support for HSW drm/i915: add S PLL control drm/i915: add PIXCLK_GATE register ... Conflicts: drivers/char/agp/intel-agp.h drivers/char/agp/intel-gtt.c drivers/gpu/drm/i915/i915_debugfs.c
Diffstat (limited to 'drivers/gpu/drm/i915/i915_dma.c')
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c85
1 files changed, 52 insertions, 33 deletions
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 785f67f963ef..652f43f00ef2 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -26,6 +26,8 @@
26 * 26 *
27 */ 27 */
28 28
29#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
30
29#include "drmP.h" 31#include "drmP.h"
30#include "drm.h" 32#include "drm.h"
31#include "drm_crtc_helper.h" 33#include "drm_crtc_helper.h"
@@ -43,6 +45,7 @@
43#include <linux/slab.h> 45#include <linux/slab.h>
44#include <linux/module.h> 46#include <linux/module.h>
45#include <acpi/video.h> 47#include <acpi/video.h>
48#include <asm/pat.h>
46 49
47static void i915_write_hws_pga(struct drm_device *dev) 50static void i915_write_hws_pga(struct drm_device *dev)
48{ 51{
@@ -787,6 +790,9 @@ static int i915_getparam(struct drm_device *dev, void *data,
787 case I915_PARAM_HAS_LLC: 790 case I915_PARAM_HAS_LLC:
788 value = HAS_LLC(dev); 791 value = HAS_LLC(dev);
789 break; 792 break;
793 case I915_PARAM_HAS_ALIASING_PPGTT:
794 value = dev_priv->mm.aliasing_ppgtt ? 1 : 0;
795 break;
790 default: 796 default:
791 DRM_DEBUG_DRIVER("Unknown parameter %d\n", 797 DRM_DEBUG_DRIVER("Unknown parameter %d\n",
792 param->param); 798 param->param);
@@ -1158,14 +1164,14 @@ static void i915_switcheroo_set_state(struct pci_dev *pdev, enum vga_switcheroo_
1158 struct drm_device *dev = pci_get_drvdata(pdev); 1164 struct drm_device *dev = pci_get_drvdata(pdev);
1159 pm_message_t pmm = { .event = PM_EVENT_SUSPEND }; 1165 pm_message_t pmm = { .event = PM_EVENT_SUSPEND };
1160 if (state == VGA_SWITCHEROO_ON) { 1166 if (state == VGA_SWITCHEROO_ON) {
1161 printk(KERN_INFO "i915: switched on\n"); 1167 pr_info("switched on\n");
1162 dev->switch_power_state = DRM_SWITCH_POWER_CHANGING; 1168 dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
1163 /* i915 resume handler doesn't set to D0 */ 1169 /* i915 resume handler doesn't set to D0 */
1164 pci_set_power_state(dev->pdev, PCI_D0); 1170 pci_set_power_state(dev->pdev, PCI_D0);
1165 i915_resume(dev); 1171 i915_resume(dev);
1166 dev->switch_power_state = DRM_SWITCH_POWER_ON; 1172 dev->switch_power_state = DRM_SWITCH_POWER_ON;
1167 } else { 1173 } else {
1168 printk(KERN_ERR "i915: switched off\n"); 1174 pr_err("switched off\n");
1169 dev->switch_power_state = DRM_SWITCH_POWER_CHANGING; 1175 dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
1170 i915_suspend(dev, pmm); 1176 i915_suspend(dev, pmm);
1171 dev->switch_power_state = DRM_SWITCH_POWER_OFF; 1177 dev->switch_power_state = DRM_SWITCH_POWER_OFF;
@@ -1216,10 +1222,8 @@ static int i915_load_gem_init(struct drm_device *dev)
1216 /* PPGTT pdes are stolen from global gtt ptes, so shrink the 1222 /* PPGTT pdes are stolen from global gtt ptes, so shrink the
1217 * aperture accordingly when using aliasing ppgtt. */ 1223 * aperture accordingly when using aliasing ppgtt. */
1218 gtt_size -= I915_PPGTT_PD_ENTRIES*PAGE_SIZE; 1224 gtt_size -= I915_PPGTT_PD_ENTRIES*PAGE_SIZE;
1219 /* For paranoia keep the guard page in between. */
1220 gtt_size -= PAGE_SIZE;
1221 1225
1222 i915_gem_do_init(dev, 0, mappable_size, gtt_size); 1226 i915_gem_init_global_gtt(dev, 0, mappable_size, gtt_size);
1223 1227
1224 ret = i915_gem_init_aliasing_ppgtt(dev); 1228 ret = i915_gem_init_aliasing_ppgtt(dev);
1225 if (ret) { 1229 if (ret) {
@@ -1237,7 +1241,8 @@ static int i915_load_gem_init(struct drm_device *dev)
1237 * should be enough to keep any prefetching inside of the 1241 * should be enough to keep any prefetching inside of the
1238 * aperture. 1242 * aperture.
1239 */ 1243 */
1240 i915_gem_do_init(dev, 0, mappable_size, gtt_size - PAGE_SIZE); 1244 i915_gem_init_global_gtt(dev, 0, mappable_size,
1245 gtt_size);
1241 } 1246 }
1242 1247
1243 ret = i915_gem_init_hw(dev); 1248 ret = i915_gem_init_hw(dev);
@@ -1931,6 +1936,29 @@ ips_ping_for_i915_load(void)
1931 } 1936 }
1932} 1937}
1933 1938
1939static void
1940i915_mtrr_setup(struct drm_i915_private *dev_priv, unsigned long base,
1941 unsigned long size)
1942{
1943 dev_priv->mm.gtt_mtrr = -1;
1944
1945#if defined(CONFIG_X86_PAT)
1946 if (cpu_has_pat)
1947 return;
1948#endif
1949
1950 /* Set up a WC MTRR for non-PAT systems. This is more common than
1951 * one would think, because the kernel disables PAT on first
1952 * generation Core chips because WC PAT gets overridden by a UC
1953 * MTRR if present. Even if a UC MTRR isn't present.
1954 */
1955 dev_priv->mm.gtt_mtrr = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
1956 if (dev_priv->mm.gtt_mtrr < 0) {
1957 DRM_INFO("MTRR allocation failed. Graphics "
1958 "performance may suffer.\n");
1959 }
1960}
1961
1934/** 1962/**
1935 * i915_driver_load - setup chip and create an initial config 1963 * i915_driver_load - setup chip and create an initial config
1936 * @dev: DRM device 1964 * @dev: DRM device
@@ -1945,8 +1973,16 @@ ips_ping_for_i915_load(void)
1945int i915_driver_load(struct drm_device *dev, unsigned long flags) 1973int i915_driver_load(struct drm_device *dev, unsigned long flags)
1946{ 1974{
1947 struct drm_i915_private *dev_priv; 1975 struct drm_i915_private *dev_priv;
1976 struct intel_device_info *info;
1948 int ret = 0, mmio_bar; 1977 int ret = 0, mmio_bar;
1949 uint32_t agp_size; 1978 uint32_t aperture_size;
1979
1980 info = (struct intel_device_info *) flags;
1981
1982 /* Refuse to load on gen6+ without kms enabled. */
1983 if (info->gen >= 6 && !drm_core_check_feature(dev, DRIVER_MODESET))
1984 return -ENODEV;
1985
1950 1986
1951 /* i915 has 4 more counters */ 1987 /* i915 has 4 more counters */
1952 dev->counters += 4; 1988 dev->counters += 4;
@@ -1961,7 +1997,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1961 1997
1962 dev->dev_private = (void *)dev_priv; 1998 dev->dev_private = (void *)dev_priv;
1963 dev_priv->dev = dev; 1999 dev_priv->dev = dev;
1964 dev_priv->info = (struct intel_device_info *) flags; 2000 dev_priv->info = info;
1965 2001
1966 if (i915_get_bridge_dev(dev)) { 2002 if (i915_get_bridge_dev(dev)) {
1967 ret = -EIO; 2003 ret = -EIO;
@@ -2000,27 +2036,16 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
2000 goto out_rmmap; 2036 goto out_rmmap;
2001 } 2037 }
2002 2038
2003 agp_size = dev_priv->mm.gtt->gtt_mappable_entries << PAGE_SHIFT; 2039 aperture_size = dev_priv->mm.gtt->gtt_mappable_entries << PAGE_SHIFT;
2004 2040
2005 dev_priv->mm.gtt_mapping = 2041 dev_priv->mm.gtt_mapping =
2006 io_mapping_create_wc(dev->agp->base, agp_size); 2042 io_mapping_create_wc(dev->agp->base, aperture_size);
2007 if (dev_priv->mm.gtt_mapping == NULL) { 2043 if (dev_priv->mm.gtt_mapping == NULL) {
2008 ret = -EIO; 2044 ret = -EIO;
2009 goto out_rmmap; 2045 goto out_rmmap;
2010 } 2046 }
2011 2047
2012 /* Set up a WC MTRR for non-PAT systems. This is more common than 2048 i915_mtrr_setup(dev_priv, dev->agp->base, aperture_size);
2013 * one would think, because the kernel disables PAT on first
2014 * generation Core chips because WC PAT gets overridden by a UC
2015 * MTRR if present. Even if a UC MTRR isn't present.
2016 */
2017 dev_priv->mm.gtt_mtrr = mtrr_add(dev->agp->base,
2018 agp_size,
2019 MTRR_TYPE_WRCOMB, 1);
2020 if (dev_priv->mm.gtt_mtrr < 0) {
2021 DRM_INFO("MTRR allocation failed. Graphics "
2022 "performance may suffer.\n");
2023 }
2024 2049
2025 /* The i915 workqueue is primarily used for batched retirement of 2050 /* The i915 workqueue is primarily used for batched retirement of
2026 * requests (and thus managing bo) once the task has been completed 2051 * requests (and thus managing bo) once the task has been completed
@@ -2272,7 +2297,7 @@ int i915_driver_open(struct drm_device *dev, struct drm_file *file)
2272 * mode setting case, we want to restore the kernel's initial mode (just 2297 * mode setting case, we want to restore the kernel's initial mode (just
2273 * in case the last client left us in a bad state). 2298 * in case the last client left us in a bad state).
2274 * 2299 *
2275 * Additionally, in the non-mode setting case, we'll tear down the AGP 2300 * Additionally, in the non-mode setting case, we'll tear down the GTT
2276 * and DMA structures, since the kernel won't be using them, and clea 2301 * and DMA structures, since the kernel won't be using them, and clea
2277 * up any GEM state. 2302 * up any GEM state.
2278 */ 2303 */
@@ -2350,16 +2375,10 @@ struct drm_ioctl_desc i915_ioctls[] = {
2350 2375
2351int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); 2376int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
2352 2377
2353/** 2378/*
2354 * Determine if the device really is AGP or not. 2379 * This is really ugly: Because old userspace abused the linux agp interface to
2355 * 2380 * manage the gtt, we need to claim that all intel devices are agp. For
2356 * All Intel graphics chipsets are treated as AGP, even if they are really 2381 * otherwise the drm core refuses to initialize the agp support code.
2357 * PCI-e.
2358 *
2359 * \param dev The device to be tested.
2360 *
2361 * \returns
2362 * A value of 1 is always retured to indictate every i9x5 is AGP.
2363 */ 2382 */
2364int i915_driver_device_is_agp(struct drm_device * dev) 2383int i915_driver_device_is_agp(struct drm_device * dev)
2365{ 2384{