Bug 58005 - [DRI2] race between compositor and clients when using SwapBuffer exchanges
Summary: [DRI2] race between compositor and clients when using SwapBuffer exchanges
Status: RESOLVED WONTFIX
Alias: None
Product: xorg
Classification: Unclassified
Component: Driver/intel (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: low normal
Assignee: Chris Wilson
QA Contact: Intel GFX Bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-08 04:29 UTC by walch.martin
Modified: 2013-02-21 19:40 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
/var/log/Xorg.0.log (51.01 KB, text/plain)
2012-12-08 04:29 UTC, walch.martin
no flags Details
dmesg > dmesg (150.40 KB, text/plain)
2012-12-08 04:29 UTC, walch.martin
no flags Details
/etc/X11/xorg.conf (2.80 KB, text/plain)
2012-12-08 04:30 UTC, walch.martin
no flags Details
xrandr --verbose > "xrandr --verbose" (7.32 KB, text/plain)
2012-12-08 04:31 UTC, walch.martin
no flags Details
intel_reg_dumper > intel_reg_dumper (13.41 KB, text/plain)
2012-12-08 04:33 UTC, walch.martin
no flags Details
cat /sys/devices/pci0000:00/0000:00:02.0/rom > vbios.dump (64.00 KB, application/octet-stream)
2012-12-08 04:33 UTC, walch.martin
no flags Details

Description walch.martin 2012-12-08 04:29:05 UTC
Created attachment 71171 [details]
/var/log/Xorg.0.log

System environment: 
 -- chipset: G45 
 -- system architecture: x86_64
 -- xf86-video-intel: 2.20.15
 -- xserver: 1.13.0
 -- mesa: 9.0.1
 -- libdrm: 2.4.40
 -- kernel: 3.5.7-gentoo-gnu
 -- Linux distribution: Gentoo
 -- Machine or mobo model: Asus P5Q-EM
 -- Display connector: DVI

Reproduce steps:
Start X with SNA enabled, run warzone2100 and start a single player game in fullscreen mode. Everything except the ground is flickering.

Additional info:
With UXA, there is no flickering.
Comment 1 walch.martin 2012-12-08 04:29:53 UTC
Created attachment 71172 [details]
dmesg > dmesg
Comment 2 walch.martin 2012-12-08 04:30:39 UTC
Created attachment 71173 [details]
/etc/X11/xorg.conf
Comment 3 walch.martin 2012-12-08 04:31:24 UTC
Created attachment 71174 [details]
xrandr --verbose > "xrandr --verbose"
Comment 4 walch.martin 2012-12-08 04:33:04 UTC
Created attachment 71175 [details]
intel_reg_dumper > intel_reg_dumper

executed while in fullscreen mode, running warzone2100
Comment 5 walch.martin 2012-12-08 04:33:45 UTC
Created attachment 71176 [details]
cat /sys/devices/pci0000:00/0000:00:02.0/rom > vbios.dump
Comment 6 Chris Wilson 2012-12-08 08:30:32 UTC
Are you using a compositor with an unredirected fullscreen GL game? Sounds like you're hitting the dri2 bugs...
Comment 7 Chris Wilson 2012-12-08 09:59:48 UTC
If it is the bug I'm thinking of:

diff --git a/src/sna/sna_dri.c b/src/sna/sna_dri.c
index 6976143..fb2840f 100644
--- a/src/sna/sna_dri.c
+++ b/src/sna/sna_dri.c
@@ -1160,6 +1160,8 @@ can_exchange(struct sna * sna,
        WindowPtr win = (WindowPtr)draw;
        PixmapPtr pixmap;
 
+       return false;
+
        if (front->format != back->format) {
                DBG(("%s: no, format mismatch, front = %d, back = %d\n",
                     __FUNCTION__, front->format, back->format));

should hide it.
Comment 8 walch.martin 2012-12-08 12:54:12 UTC
(In reply to comment #6)
> Are you using a compositor with an unredirected fullscreen GL game? Sounds
> like you're hitting the dri2 bugs...

Yes, I am using KDE/KWin with desktop effects mode. With effects turned off, everything is fine.

(In reply to comment #7)
> diff --git a/src/sna/sna_dri.c b/src/sna/sna_dri.c

Yes, when applying this patch, and turning desktop effects on again, the flickering is also gone.

So, where should this be fixed? Is this the right place to complain about this bug?
Comment 9 Chris Wilson 2012-12-08 16:35:01 UTC
The root cause is a race condition between the compositor and client sharing the DRI2 buffers. Ultimately, we need to fix the protocol to close the race.
Comment 10 Chris Wilson 2012-12-10 23:23:55 UTC
As no one has reviewed my xorg patches to reduce the race, time to hack the ddx:

commit 162e9a2bfc693db186aa481551cf76b3dc5ee55c
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Mon Dec 10 23:11:48 2012 +0000

    sna/dri: Disable name exchanges for SwapBuffers
    
    The DRI2 protocol is inherently racy. Fortuituously, this can be swept
    under the carpet by forcing the serialisation between the DRI2 clients
    by using a blit for the SwapBuffers.
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=58005
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Comment 11 walch.martin 2012-12-11 11:57:46 UTC
Thank you for fixing. It works fine that way.

I suppose you want to have this fixed in a clean way. So I leave this bug report open.
Comment 12 Chris Wilson 2013-02-21 19:40:56 UTC
Ok, cannot be fixed inside the DRI2 protocol. Hopefully we will get this right for DRI3.

commit b0c83b77d0226cbaf6115eed5d0e2cc8a40ac51d
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Feb 21 19:37:51 2013 +0000

    sna/dri: Eradicate the DRI2 name exchange mechanism
    
    Thinking about the compositor <-> server <-> client inter-exchange
    demonstrates that we cannot prevent the client rendering into the
    source texture being show by the compositor. That is a subject for DRI3.
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>


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.