aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-03-05 09:52:39 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-03-27 12:13:43 -0400
commit693db1842d864ca2771e881127cdb4d09979758b (patch)
treeb937cd3efa7f6c8ca6304f75fbfc0f4054b2ff24
parent4f770a5bee04566e63f3a826a15c24bccaa124e8 (diff)
drm/i915: Apply alignment restrictions on scanout surfaces for VT-d
From the w/a database: 'To prevent false VT-d type 6 error: The primary display plane must be 256KiB aligned, and require an extra 128 PTEs of padding afterward; The sprites planes must be 128KiB aligned, and require an extra 64 PTEs of padding afterward; The cursors must be 64KiB aligned, and require an extra 2 PTEs of padding afterward.' As we use the same function to pin the primary and sprite planes, we can simply use the more strict requirements for scanouts for both. Instead of using explicit padding PTEs following the scanout objects, we should be able to use the scratch page that is always mapped into the unused PTEs to avoid the VT-d error. References: https://bugs.freedesktop.org/show_bug.cgi?id=59626 References: https://bugs.freedesktop.org/show_bug.cgi?id=59627 References: https://bugs.freedesktop.org/show_bug.cgi?id=59631 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Damien Lespiau <damien.lespiau@intel.com> [danvet: Apply s/vtd_wa/vtd_scanout_wa/ bikeshed since Damien likes it, too.] Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--drivers/gpu/drm/i915/intel_display.c30
-rw-r--r--drivers/gpu/drm/i915/intel_sprite.c5
2 files changed, 34 insertions, 1 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 8f0db8cf6ced..2db50e234c2c 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -1950,6 +1950,15 @@ static void intel_disable_plane(struct drm_i915_private *dev_priv,
1950 intel_wait_for_vblank(dev_priv->dev, pipe); 1950 intel_wait_for_vblank(dev_priv->dev, pipe);
1951} 1951}
1952 1952
1953static bool need_vtd_wa(struct drm_device *dev)
1954{
1955#ifdef CONFIG_INTEL_IOMMU
1956 if (INTEL_INFO(dev)->gen >= 6 && intel_iommu_gfx_mapped)
1957 return true;
1958#endif
1959 return false;
1960}
1961
1953int 1962int
1954intel_pin_and_fence_fb_obj(struct drm_device *dev, 1963intel_pin_and_fence_fb_obj(struct drm_device *dev,
1955 struct drm_i915_gem_object *obj, 1964 struct drm_i915_gem_object *obj,
@@ -1980,6 +1989,14 @@ intel_pin_and_fence_fb_obj(struct drm_device *dev,
1980 BUG(); 1989 BUG();
1981 } 1990 }
1982 1991
1992 /* Note that the w/a also requires 64 PTE of padding following the
1993 * bo. We currently fill all unused PTE with the shadow page and so
1994 * we should always have valid PTE following the scanout preventing
1995 * the VT-d warning.
1996 */
1997 if (need_vtd_wa(dev) && alignment < 256 * 1024)
1998 alignment = 256 * 1024;
1999
1983 dev_priv->mm.interruptible = false; 2000 dev_priv->mm.interruptible = false;
1984 ret = i915_gem_object_pin_to_display_plane(obj, alignment, pipelined); 2001 ret = i915_gem_object_pin_to_display_plane(obj, alignment, pipelined);
1985 if (ret) 2002 if (ret)
@@ -6371,13 +6388,24 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
6371 /* we only need to pin inside GTT if cursor is non-phy */ 6388 /* we only need to pin inside GTT if cursor is non-phy */
6372 mutex_lock(&dev->struct_mutex); 6389 mutex_lock(&dev->struct_mutex);
6373 if (!dev_priv->info->cursor_needs_physical) { 6390 if (!dev_priv->info->cursor_needs_physical) {
6391 unsigned alignment;
6392
6374 if (obj->tiling_mode) { 6393 if (obj->tiling_mode) {
6375 DRM_ERROR("cursor cannot be tiled\n"); 6394 DRM_ERROR("cursor cannot be tiled\n");
6376 ret = -EINVAL; 6395 ret = -EINVAL;
6377 goto fail_locked; 6396 goto fail_locked;
6378 } 6397 }
6379 6398
6380 ret = i915_gem_object_pin_to_display_plane(obj, 0, NULL); 6399 /* Note that the w/a also requires 2 PTE of padding following
6400 * the bo. We currently fill all unused PTE with the shadow
6401 * page and so we should always have valid PTE following the
6402 * cursor preventing the VT-d warning.
6403 */
6404 alignment = 0;
6405 if (need_vtd_wa(dev))
6406 alignment = 64*1024;
6407
6408 ret = i915_gem_object_pin_to_display_plane(obj, alignment, NULL);
6381 if (ret) { 6409 if (ret) {
6382 DRM_ERROR("failed to move cursor bo into the GTT\n"); 6410 DRM_ERROR("failed to move cursor bo into the GTT\n");
6383 goto fail_locked; 6411 goto fail_locked;
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index 6fdd42704533..414d325f28d3 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -522,6 +522,11 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
522 522
523 mutex_lock(&dev->struct_mutex); 523 mutex_lock(&dev->struct_mutex);
524 524
525 /* Note that this will apply the VT-d workaround for scanouts,
526 * which is more restrictive than required for sprites. (The
527 * primary plane requires 256KiB alignment with 64 PTE padding,
528 * the sprite planes only require 128KiB alignment and 32 PTE padding.
529 */
525 ret = intel_pin_and_fence_fb_obj(dev, obj, NULL); 530 ret = intel_pin_and_fence_fb_obj(dev, obj, NULL);
526 if (ret) 531 if (ret)
527 goto out_unlock; 532 goto out_unlock;