Created attachment 84421[details]
Xorg.log of the driver with corruption
Yeah, it looks weird for driver corruption, but it happens with commit ed40a7c3de3bbb178278c05907e59239712b98b6 and not with commit 4486ae2d829781e32652bce84c08e63ee1960bf0.

Created attachment 84422[details]
Xorg.log of the driver with corruption on Haswell
It just happened to me on Haswell with the 2.21.15 driver while scrolling in a gmail text box with the arrow keys. I reverted to 4486ae2d829781e32652bce84c08e63ee1960bf0 and it stopped happening on the Haswell machine, too.

I am running KDE 4.11.
Yes, I am seeing a bunch of random identical black boxes on Haswell as well.
The boxes persist relative to the page and scroll with it. They go away when focus switches to another window, and new ones appear when scrolling the text again.

Created attachment 84545[details]
Xorg.0.log
I have the same problem as the OP in firefox.
I'm using Awesome WM and an Ivy Bridge laptop with Arch Linux (testing).
This started to happen after the following packages are updated:
* mesa (9.1.6-1 -> 9.2.0rc2-1)
* mesa-libgl (9.1.6-1 -> 9.2.0rc2-1)
* intel-dri (9.1.6-1 -> 9.2.0rc2-1)
* linux (3.10.7-1 -> 3.10.9-1)
* xf86-video-intel (2.21.14-2 -> 2.21.15-1)
Arch Linux now set sna as default and I'm using it. I will try to test with the commit reverted.
IIRC I had this type of corruption sometime on the (long) past, I think I switched back to uxa and after some time I come back to sna and its gone.

My suspicion is that this is a missing render flush, since that is all the effect the patch should have had (use existing render operations more often).
I've just pushed a patch to expose a debug variable in src/sna/gen7_render.c, if you can please recompile the DDX with this little change:
diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c
index ff2ddb7..244bf17 100644
--- a/src/sna/gen7_render.c
+++ b/src/sna/gen7_render.c
@@ -45,7 +45,7 @@
#include "gen4_source.h"
#include "gen4_vertex.h"
-#define ALWAYS_FLUSH 0
+#define ALWAYS_FLUSH 1
#define NO_COMPOSITE 0
#define NO_COMPOSITE_SPANS 0
that should test the simple flushing theory. (There are more complicated flushing theories! ;-)

I can't reproduce this anymore even with #define ALWAYS_FLUSH 0 . I bisected to see which commit fixed it, and it looks like it was the one right after the 2.21.15 release. This doesn't happen anymore as of:
509e7aaf8446f568e133e1b450ea13f73e9b366b sna/gen7: Prefer the render ring for more operations

Hmm, we mask the problem once again. I'm not sure if this caused the troublesome operation to move back to the blt ring, or if it made more operations move over to the render ring. At any rate, it should like an inter-ring flushing issue - or a malformed command.

I am encountering this issue on a Lenovo X230 under Arch Linux with all the latest updates. It was consistent on some pages (Facebook, for example) but didn't seem to occur on some others. Disabling hardware acceleration in Firefox did nothing. However, switching from SNA to UXA seems to have made the issue go away completely. I hope that information is helpful to someone.

If you are not tracking the kernel rcs and the xf86-video-intel snapshots, you are not testing the related fixes to this bug. Confirmation of this bug on 3.12-rc2 and 2.99.903 would be much appreciated.

The current theory is that it is associated with the reuse of the staging upload buffers. I would try testing with different values for
#define DBG_NO_UPLOAD_CACHE
#define DBG_NO_UPLOAD_ACTIVE
#define DBG_NO_MAP_UPLOAD
in src/sna/kgem.c and see if any of those prevent the corruption.

I can confirm this also occurs on the Iris Pro 5200 GPU as well.
Kernel 3.11.2-1 Arch Linux
Intel 2.21.15-1
Mesa 9.2.0-2
It also appears to effect some games running opengl. The symptoms are similar black or other colored artifacts on screen.

I just used the test from comment 11 with git 7284e7f with kernel 3.11.4 on a Haswell i7-4770S. I can easily reproduce it with ALWAYS_FLUSH 0, but I cannot reproduce it with ALWAYS_FLUSH 1. It must be a missing render flush.

There was a nasty crash bug introduced somewhere between git 8980870 and 7284e7f that I'm seeing with Firefox now. It takes down the X server. I'm bisecting to see which commit did it, and I'll file another bug.

Another step.
commit 55e0f4502657078a666761277bbac56a98b3780c
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date: Mon Oct 7 11:56:23 2013 +0100
sna/gen7: Rename debug option ALWAYS_FLUSH to ALWAYS_INVALIDATE
gives ALWAYS_FLUSH, ALWAYS_INVALIDATE, ALWAYS_STALL to play with. Can you please play around with those options and see which masks the bug?

Chris
Testing on i5-4200U, kernel 3.12-rc4, mesa 9.2.0 and git xf86-intel-drivers mentioned in comment #36
First compiling exactly from git for a baseline. Black rectangles persist, however it seems that they are varying in height (where before I think they were all uniform height).
Compiling with only ALWAYS_INVALIDATE set the problem is masked
Compiling with only ALWAYS_FLUSH set the problem is also masked
Compiling with only ALWAYS_STALL the problem is present.
HTH and thanks

Yay, the patch in comment #42 works for me (on setup listed in coment #37). Thanks for all the perseverance Chris!
To be clear I did not set any #define's to 1 as it was stated before that it just hides the problem.

Spoke too soon, it seems to be manifesting in a new way. I'll attach a screenshot. Now the text in my URL bar and tab titles is missing small sections. If I hover/click the regions to force a refresh, the text comes back sporadically, but also goes away as redraws occur.

Let me know what happens. I'm not convinced by that patch yet, it will force a flush in between most operations (as we switch surfaces almost constantly). So it may be fixing things accidentally, and just reducing the frequency of the corruption (a blank square in the glyph string pixmap would explain the "new behaviour").

It still happens with the patch from comment 48, but not with the one from comment 42. I still haven't seen the corruption from comment 45. That comment 42 patch probably is an accidental fix. Have you been able to reproduce it?

In case it helps figure out where the problem is, I haven't been able to reproduce this on my ivb laptop (i7-3820QM) since the commit after 2.21.15 (509e7aa). It only happens on hsw (i7-4770S) for me now.

I've updated to xf86-video-intel 33be42bf509b6d57face6b8d99d72dd5f6c90900 with 3.12-rc6 and the problem persists, and I can no longer apply the patch from comment #42. What do you recommend for short/long term options?

I find that scrolling via tapping the up/down arrow keys on any wikipedia page aggravates it. In case it is relevant, in firefox I have "smooth scrolling" and "hardware acceleration" checked, and "autoscrolling" unchecked (preferences->advanced tab).

Hmm, just hit an oddity on gen6 that seems relevant to this bug:
commit 82e6d41c2f4f343bd1854d3d8ee4b624b5d68971
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date: Thu Oct 31 13:35:59 2013 +0000
sna/gen6: Tweak flush around CC state changes
In order to fix some font corruption, it appears that we need an extra
flush in the Sandybridge pipeline when we change the CC stage and the
render cache is dirty. We previously triggered a full pipeline stall
for this case.

I'm trying it now. I haven't seen the bug yet with the patch, but I can't reproduce it reliably without the patch with 82e6d41 git either (but I have seen it with 82e6d41). I will report back if I see it happen again with the patch.

It seems that when you turn KDE's desktop effects off (alt-shift-f12 to toggle) the problem becomes far far more rare. I always have the default effects turned on, but on a whim I just switched them off and it was harder to make the boxes appear.

Seeing this myself on Haswell / Gentoo. Most often happens on StackExchange sites with code elements. The corruption is not just black boxes, those are just the things you see first. There are also squashed/blank characters and their missing bits an pieces reappear in other places on the screen. You can see this (if only a little) in the existing screenshot, I can provide another if it helps any.
I'll test the patches next... thanks for your efforts.

(In reply to comment #74)
> That made the problem disappear for me at least :) Thank you very very much
> for hunting this down!
Thanks for the feedback, is anyone still seeing the black boxes? A couple more positive responses and I'll mark this closed for the time being.

I might have spoken too early.
If it's not a bug of my window manager (fluxbox) that somehow surfaced the moment I updated my xf86-video-intel, what I am seeing now instead is entire windows appearing where they shouldn't be.
For example I have urxvt open, then I close it. The next second it reappears, then disappears, then reappears, so effectively it "blinks" on and off. Does that even make any sense?
In fluxbox I have a clock in the lower right corner that includes seconds, so it updates every second. The window disappearing and reappearing happens exactly at the same time, so it seems to be related somehow.
Apart from urxvt I also had this happen with Anki, and gmpc. One time it started when I clicked a button in Anki, then gmpc started "blinking", but the button I clicked stayed where it was and appeared in the middle of the "gmpc" window where it doesn't belong.
I can't reliably reproduce this as of yet, it happened only two or three times since the time I wrote my last comment...

(In reply to comment #78)
> (In reply to comment #77)
> > I might have spoken too early.
>
> The only thing I can say for sure is that that is an entirely different
> phenomenon.
Sorry for spamming :)
It seems indeed to be a different issue. I'm seeing the same thing in 2.99.906 - along with the black boxes. It might've been in 2.99.905, just not as extreme.
So your black box fix is good and I'll have to hunt whatever issue I'm having separately.

Thank you for fixing this bug. It was easy to repro on Haswell with Firefox and sometimes I'd have up to 50 of these 8x4 rectangles on the screen at once! It just hit Arch testing today and I'm happy it is gone.

i am running KDE 4.13.3 on kubuntu 14.04.1 on lenovo G-500 with intel HD 4000
when i use Firefox or other browser or even other place of kubuntu like dolphin or somewhere see black box corruption on screen . i attach screen shot and Xorg log. Andrei Cristian Petcu say this bug fixed . but i have still it .