diff options
Diffstat (limited to 'drivers/gpu/drm/i915/i915_dma.c')
-rw-r--r-- | drivers/gpu/drm/i915/i915_dma.c | 85 |
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 | ||
47 | static void i915_write_hws_pga(struct drm_device *dev) | 50 | static 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 | ||
1939 | static void | ||
1940 | i915_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) | |||
1945 | int i915_driver_load(struct drm_device *dev, unsigned long flags) | 1973 | int 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 | ||
2351 | int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); | 2376 | int 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 | */ |
2364 | int i915_driver_device_is_agp(struct drm_device * dev) | 2383 | int i915_driver_device_is_agp(struct drm_device * dev) |
2365 | { | 2384 | { |