Bug 79517 - Corruption in Firefox 30 or later
Summary: Corruption in Firefox 30 or later
Status: VERIFIED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Driver/intel (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: Chris Wilson
QA Contact: Intel GFX Bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-01 22:08 UTC by Jan Alexander Steffens (heftig)
Modified: 2014-06-24 20:33 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Only promote an upload to the GPU if there is no CPU damage (2.75 KB, patch)
2014-06-03 08:05 UTC, Chris Wilson
no flags Details | Splinter Review
Slight variation. (2.77 KB, patch)
2014-06-03 09:09 UTC, Chris Wilson
no flags Details | Splinter Review

Description Jan Alexander Steffens (heftig) 2014-06-01 22:08:32 UTC
Arch Linux x86_64
Thinkpad X220t (SNB)
xf86-video-intel ffbe0aa (TearFree enabled)
xorg-server 1.15.1
linux 3.14.5

Reproduced with Firefox 30.0b9 or 31.0a2. Does not happen in 29.0.

1. Navigate to a large image, like
http://upload.wikimedia.org/wikipedia/commons/4/4b/Chicago_-_skyline.JPG

2. Wait for the image to load completely
3. Click the image to zoom 1:1
4. Hit Ctrl++ (Control Plus) to zoom in once
5. Hit Ctrl+0 to reset zoom
6. Scroll vertically, quickly
7. Observe the image corrupting

Corruption does not happen if gfx.xrender.enabled is disabled.

Might be related to bug #79516.
Comment 1 Jan Alexander Steffens (heftig) 2014-06-02 18:35:58 UTC
The first bad commit is 6530141 (sna: Discard active GPU buffers before uploading into them)
Comment 2 Chris Wilson 2014-06-02 18:55:25 UTC
Hmm, that looked safe.
Comment 3 Chris Wilson 2014-06-02 19:35:43 UTC
If you apply

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 2513b8b..fcf354e 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -4556,7 +4556,7 @@ try_upload_tiled_x(PixmapPtr pixmap, RegionRec *region,
                return false;
        }
 
-       if (priv->gpu_damage &&
+       if (priv->gpu_damage && 0 &&
            region_subsumes_damage(region, priv->gpu_damage)) {
                if (UNDO)
                        kgem_bo_undo(&sna->kgem, priv->gpu_bo);

that will disable one chunk of that patch. Does the corruption still occur?
Comment 4 Chris Wilson 2014-06-02 20:14:43 UTC
Idea:

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 2513b8b..18195d8 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -4564,7 +4564,8 @@ try_upload_tiled_x(PixmapPtr pixmap, RegionRec *region,
                        DBG(("%s: discarding dirty pixmap\n", __FUNCTION__));
                        sna_pixmap_free_gpu(sna, priv);
                }
-               replaces = true; /* Mark it all GPU damaged afterwards */
+               replaces = (priv->cpu_damage == NULL ||
+                           region_subsumes_damage(region, priv->cpu_damage));
        }
 
        if (priv->gpu_bo == NULL &&
Comment 5 Jan Alexander Steffens (heftig) 2014-06-03 07:41:52 UTC
The first patch removes the corruption, the second does not.
Comment 6 Jan Alexander Steffens (heftig) 2014-06-03 07:47:14 UTC
Although, with the second patch the corruption looks less severe. Just misplaced parts from other areas of the scrolled image and occasional large black regions.

Unpatched, there are also noisy regions and parts from outside the scrolled area.
Comment 7 Chris Wilson 2014-06-03 08:05:31 UTC
Created attachment 100342 [details] [review]
Only promote an upload to the GPU if there is no CPU damage

Can you test this one? Although it is starting to look like a revert is preferable.
Comment 8 Chris Wilson 2014-06-03 08:07:24 UTC
Scratch that. Silly idea.
Comment 9 Chris Wilson 2014-06-03 09:09:11 UTC
Created attachment 100345 [details] [review]
Slight variation.
Comment 10 Jan Alexander Steffens (heftig) 2014-06-03 09:24:47 UTC
Nope, no luck yet.
Comment 11 Chris Wilson 2014-06-03 12:51:42 UTC
Nothing concrete yet, I am trying to understand my fail before killing it. In the meantime, I've applied some slight tweaks to the neighbouring code paths.

commit 8297c969ae749ef58d259b2ded2231b928efba43
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Tue Jun 3 09:47:27 2014 +0100

    sna: Replace the bo for tiled uploads if not suitable and being replaced
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

commit 1c55d0447dba5bbde5be3903b273e04e3c9d084f
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Tue Jun 3 12:43:51 2014 +0100

    sna: Allow replacements to cancel operations between both bo under a Pixmap
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

commit a82bfb033448eb61bf8cc7f5358be019f0cc28e6
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Tue Jun 3 09:28:24 2014 +0100

    sna: Discard unwanted damage when promoting to a full CPU migration
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.u
Comment 12 Chris Wilson 2014-06-04 21:32:30 UTC
Have you had a chance to see if today's tree changed the frequency / pattern?
Comment 13 Chris Wilson 2014-06-04 21:33:31 UTC
Also comparing drm-intel-nightly would be useful.
Comment 14 Chris Wilson 2014-06-05 11:04:24 UTC
Ah. Should be fixed by:

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index f77b4c6..70211eb 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -4602,6 +4602,10 @@ try_upload_tiled_x(PixmapPtr pixmap, RegionRec *region,
                             kgem_bo_can_map__cpu(&sna->kgem, priv->gpu_bo, true)));
                        sna_pixmap_free_gpu(sna, priv);
                        ignore_cpu = priv->cpu_damage == NULL;
+                       if (priv->ptr)
+                               sna_damage_all(&priv->cpu_damage,
+                                               pixmap->drawable.width,
+                                               pixmap->drawable.height);
                }
        }
Comment 15 Chris Wilson 2014-06-05 13:00:08 UTC
As this patch does do something, https://bugs.freedesktop.org/show_bug.cgi?id=79529#c7 I have gone ahead and pushed it under the assumption that it is indeed the correct fix! Please double check. :)
Comment 16 Jan Alexander Steffens (heftig) 2014-06-05 15:30:12 UTC
Fixed indeed. Thank you.
Comment 17 gedgon 2014-06-22 12:33:04 UTC
(In reply to comment #15)
> Please double check. :)

Unfortunately, I can still reproduce this bug in git master.
Sample image: http://download.tuxfamily.org/glxdock/mediacolor/album3/1403352600_48bf3dcde4.jpg

Screenshot: http://i.imgur.com/cbnRP3r.png
Screencast: http://youtu.be/SJCja1bfeNw
Comment 18 Chris Wilson 2014-06-22 12:38:07 UTC
Probably not the same bug then...
Comment 19 gedgon 2014-06-22 12:50:18 UTC
Darn, bisection pointed at 65301412ecf2d55ab55a2d7faeaa048d4ee8b1d0, then I found this bug report.

What's interesting, it's fine with a image mentioned by Jan, or with Raleigh gtk theme.
Comment 20 gedgon 2014-06-24 20:33:23 UTC
Just want add that this commit...

From 25776547bb7d76010f948769c8c08a7f418b15fd Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris@chris-wilson.co.uk>
Date: Mon, 23 Jun 2014 13:02:51 +0000
Subject: sna: Prefer rendering on the CPU to avoid damage migration

made this corruptions much more subtle.
screenshot: http://i.imgur.com/kJfKzf1.png

Please let me know, if it's indeed a different bug, and I should fill new bug report for better tracking.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.