diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-02-09 11:15:46 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-02-09 15:25:11 -0500 |
commit | 1d2a314c97ceaf383de8e23cdde46729927d433c (patch) | |
tree | 31df6c81a19d80b3611c39cb17c613561a9f0b0b /drivers/gpu/drm/i915/i915_dma.c | |
parent | 428ccb21b740f603a6a1f08cbe6d935fb3177620 (diff) |
drm/i915: initialization/teardown for the aliasing ppgtt
This just adds the setup and teardown code for the ppgtt PDE and the
last-level pagetables, which are fixed for the entire lifetime, at
least for the moment.
v2: Kill the stray debug printk noted by and improve the pte
definitions as suggested by Chris Wilson.
v3: Clean up the aperture stealing code as noted by Ben Widawsky.
v4: Paint the init code in a more pleasing colour as suggest by Chris
Wilson.
v5: Explain the magic numbers noticed by Ben Widawsky.
Reviewed-by: Ben Widawsky <ben@bwidawsk.net>
Tested-by: Chris Wilson <chris@chris-wilson.co.uk>
Tested-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
Reviewed-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/i915_dma.c')
-rw-r--r-- | drivers/gpu/drm/i915/i915_dma.c | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index dfef9569f2a1..039fbf4fae10 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c | |||
@@ -1196,22 +1196,39 @@ static int i915_load_gem_init(struct drm_device *dev) | |||
1196 | /* Basic memrange allocator for stolen space */ | 1196 | /* Basic memrange allocator for stolen space */ |
1197 | drm_mm_init(&dev_priv->mm.stolen, 0, prealloc_size); | 1197 | drm_mm_init(&dev_priv->mm.stolen, 0, prealloc_size); |
1198 | 1198 | ||
1199 | /* Let GEM Manage all of the aperture. | 1199 | if (HAS_ALIASING_PPGTT(dev)) { |
1200 | * | 1200 | /* PPGTT pdes are stolen from global gtt ptes, so shrink the |
1201 | * However, leave one page at the end still bound to the scratch page. | 1201 | * aperture accordingly when using aliasing ppgtt. */ |
1202 | * There are a number of places where the hardware apparently | 1202 | gtt_size -= I915_PPGTT_PD_ENTRIES*PAGE_SIZE; |
1203 | * prefetches past the end of the object, and we've seen multiple | 1203 | /* For paranoia keep the guard page in between. */ |
1204 | * hangs with the GPU head pointer stuck in a batchbuffer bound | 1204 | gtt_size -= PAGE_SIZE; |
1205 | * at the last page of the aperture. One page should be enough to | 1205 | |
1206 | * keep any prefetching inside of the aperture. | 1206 | i915_gem_do_init(dev, 0, mappable_size, gtt_size); |
1207 | */ | 1207 | |
1208 | i915_gem_do_init(dev, 0, mappable_size, gtt_size - PAGE_SIZE); | 1208 | ret = i915_gem_init_aliasing_ppgtt(dev); |
1209 | if (ret) | ||
1210 | return ret; | ||
1211 | } else { | ||
1212 | /* Let GEM Manage all of the aperture. | ||
1213 | * | ||
1214 | * However, leave one page at the end still bound to the scratch | ||
1215 | * page. There are a number of places where the hardware | ||
1216 | * apparently prefetches past the end of the object, and we've | ||
1217 | * seen multiple hangs with the GPU head pointer stuck in a | ||
1218 | * batchbuffer bound at the last page of the aperture. One page | ||
1219 | * should be enough to keep any prefetching inside of the | ||
1220 | * aperture. | ||
1221 | */ | ||
1222 | i915_gem_do_init(dev, 0, mappable_size, gtt_size - PAGE_SIZE); | ||
1223 | } | ||
1209 | 1224 | ||
1210 | mutex_lock(&dev->struct_mutex); | 1225 | mutex_lock(&dev->struct_mutex); |
1211 | ret = i915_gem_init_hw(dev); | 1226 | ret = i915_gem_init_hw(dev); |
1212 | mutex_unlock(&dev->struct_mutex); | 1227 | mutex_unlock(&dev->struct_mutex); |
1213 | if (ret) | 1228 | if (ret) { |
1229 | i915_gem_cleanup_aliasing_ppgtt(dev); | ||
1214 | return ret; | 1230 | return ret; |
1231 | } | ||
1215 | 1232 | ||
1216 | /* Try to set up FBC with a reasonable compressed buffer size */ | 1233 | /* Try to set up FBC with a reasonable compressed buffer size */ |
1217 | if (I915_HAS_FBC(dev) && i915_powersave) { | 1234 | if (I915_HAS_FBC(dev) && i915_powersave) { |
@@ -1298,6 +1315,7 @@ cleanup_gem: | |||
1298 | mutex_lock(&dev->struct_mutex); | 1315 | mutex_lock(&dev->struct_mutex); |
1299 | i915_gem_cleanup_ringbuffer(dev); | 1316 | i915_gem_cleanup_ringbuffer(dev); |
1300 | mutex_unlock(&dev->struct_mutex); | 1317 | mutex_unlock(&dev->struct_mutex); |
1318 | i915_gem_cleanup_aliasing_ppgtt(dev); | ||
1301 | cleanup_vga_switcheroo: | 1319 | cleanup_vga_switcheroo: |
1302 | vga_switcheroo_unregister_client(dev->pdev); | 1320 | vga_switcheroo_unregister_client(dev->pdev); |
1303 | cleanup_vga_client: | 1321 | cleanup_vga_client: |
@@ -2184,6 +2202,7 @@ int i915_driver_unload(struct drm_device *dev) | |||
2184 | i915_gem_free_all_phys_object(dev); | 2202 | i915_gem_free_all_phys_object(dev); |
2185 | i915_gem_cleanup_ringbuffer(dev); | 2203 | i915_gem_cleanup_ringbuffer(dev); |
2186 | mutex_unlock(&dev->struct_mutex); | 2204 | mutex_unlock(&dev->struct_mutex); |
2205 | i915_gem_cleanup_aliasing_ppgtt(dev); | ||
2187 | if (I915_HAS_FBC(dev) && i915_powersave) | 2206 | if (I915_HAS_FBC(dev) && i915_powersave) |
2188 | i915_cleanup_compression(dev); | 2207 | i915_cleanup_compression(dev); |
2189 | drm_mm_takedown(&dev_priv->mm.stolen); | 2208 | drm_mm_takedown(&dev_priv->mm.stolen); |