Skip to content

Commit 0b466dc

Browse files
icklejnikula
authored andcommitted
drm/i915: Mark uneven memory banks on gen4 desktop as unknown swizzling
We have varied reports of swizzling corruption on gen4 desktop, and confirmation that one at least is triggered by uneven memory banks (L-shaped memory). The implication is that the swizzling varies between the paired channels and the remainder of memory on the single channel. As the object then has unpredictable swizzling (it will vary depending on exact page allocation and may even change during the object's lifetime as the pages are replaced), we have to report to userspace that the swizzling is unknown. However, some existing userspace is buggy when it meets an unknown swizzling configuration and so we need to tell another white lie and mark the swizzling as NONE but report it as UNKNOWN through the extended get-tiling-ioctl. See commit 5eb3e5a Author: Chris Wilson <chris@chris-wilson.co.uk> Date: Sun Jun 28 09:19:26 2015 +0100 drm/i915: Declare the swizzling unknown for L-shaped configurations for the previous example where we found that telling the truth to userspace just ends up in a world of hurt. Also since we don't truly know what the swizzling is on the pages, we need to keep them pinned to prevent swapping as the reports also suggest that some gen4 devices have previously undetected bit17 swizzling. v2: Combine unknown + quirk patches to prevent userspace ever seeing unknown swizzling through the normal get-tiling-ioctl. Also use the same path for the existing uneven bank detection for mobile gen4. Reported-by: Matti Hämäläinen <ccr@tnsp.org> Tested-by: Matti Hämäläinen <ccr@tnsp.org> References: https://bugs.freedesktop.org/show_bug.cgi?id=90725 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Matti Hämäläinen <ccr@tnsp.org> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Jani Nikula <jani.nikula@intel.com> Cc: stable@vger.kernel.org Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/1447927085-31726-1-git-send-email-chris@chris-wilson.co.uk Signed-off-by: Jani Nikula <jani.nikula@intel.com>
1 parent 1ec2183 commit 0b466dc

1 file changed

Lines changed: 27 additions & 9 deletions

File tree

drivers/gpu/drm/i915/i915_gem_fence.c

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -642,11 +642,10 @@ i915_gem_detect_bit_6_swizzle(struct drm_device *dev)
642642
}
643643

644644
/* check for L-shaped memory aka modified enhanced addressing */
645-
if (IS_GEN4(dev)) {
646-
uint32_t ddc2 = I915_READ(DCC2);
647-
648-
if (!(ddc2 & DCC2_MODIFIED_ENHANCED_DISABLE))
649-
dev_priv->quirks |= QUIRK_PIN_SWIZZLED_PAGES;
645+
if (IS_GEN4(dev) &&
646+
!(I915_READ(DCC2) & DCC2_MODIFIED_ENHANCED_DISABLE)) {
647+
swizzle_x = I915_BIT_6_SWIZZLE_UNKNOWN;
648+
swizzle_y = I915_BIT_6_SWIZZLE_UNKNOWN;
650649
}
651650

652651
if (dcc == 0xffffffff) {
@@ -675,16 +674,35 @@ i915_gem_detect_bit_6_swizzle(struct drm_device *dev)
675674
* matching, which was the case for the swizzling required in
676675
* the table above, or from the 1-ch value being less than
677676
* the minimum size of a rank.
677+
*
678+
* Reports indicate that the swizzling actually
679+
* varies depending upon page placement inside the
680+
* channels, i.e. we see swizzled pages where the
681+
* banks of memory are paired and unswizzled on the
682+
* uneven portion, so leave that as unknown.
678683
*/
679-
if (I915_READ16(C0DRB3) != I915_READ16(C1DRB3)) {
680-
swizzle_x = I915_BIT_6_SWIZZLE_NONE;
681-
swizzle_y = I915_BIT_6_SWIZZLE_NONE;
682-
} else {
684+
if (I915_READ16(C0DRB3) == I915_READ16(C1DRB3)) {
683685
swizzle_x = I915_BIT_6_SWIZZLE_9_10;
684686
swizzle_y = I915_BIT_6_SWIZZLE_9;
685687
}
686688
}
687689

690+
if (swizzle_x == I915_BIT_6_SWIZZLE_UNKNOWN ||
691+
swizzle_y == I915_BIT_6_SWIZZLE_UNKNOWN) {
692+
/* Userspace likes to explode if it sees unknown swizzling,
693+
* so lie. We will finish the lie when reporting through
694+
* the get-tiling-ioctl by reporting the physical swizzle
695+
* mode as unknown instead.
696+
*
697+
* As we don't strictly know what the swizzling is, it may be
698+
* bit17 dependent, and so we need to also prevent the pages
699+
* from being moved.
700+
*/
701+
dev_priv->quirks |= QUIRK_PIN_SWIZZLED_PAGES;
702+
swizzle_x = I915_BIT_6_SWIZZLE_NONE;
703+
swizzle_y = I915_BIT_6_SWIZZLE_NONE;
704+
}
705+
688706
dev_priv->mm.bit_6_swizzle_x = swizzle_x;
689707
dev_priv->mm.bit_6_swizzle_y = swizzle_y;
690708
}

0 commit comments

Comments
 (0)