Bug 95069 - [DRI2][PRIME] display black window when enable GPU offloading
Summary: [DRI2][PRIME] display black window when enable GPU offloading
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Driver/intel (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Chris Wilson
QA Contact: Intel GFX Bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-22 15:12 UTC by Qiang Yu
Modified: 2018-02-07 03:36 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Xorg log (42.88 KB, text/plain)
2016-04-22 15:12 UTC, Qiang Yu
no flags Details
Fallback to std DRI2CopyRegion when DRI2UpdatePrime fails (2.02 KB, patch)
2016-04-25 16:10 UTC, Chris Wilson
no flags Details | Splinter Review

Description Qiang Yu 2016-04-22 15:12:24 UTC
Created attachment 123154 [details]
Xorg log

Laptop: DELL
OS: Ubuntu 16.04
CPU + iGPU: Intel i5-6300U
dGPU: AMD R5 M255

Reproduce:
fresh install Ubuntu 16.04
$ DRI_PRIME=1 glxgears
the output window is black. change focus to other window will make
the window content.

But two situation works fine:
1. use modesetting DDX for intel iGPU
2. recompile Intel DDX with "--enable-debug=full"

GDB into DDX:
in sna_share_pixmap_backing(), priv->pinned is set, so return FALSE.
But when I step through sna_pixmap_move_to_gpu(), the priv->pinned is
not set. It seems some race condition happens.
Comment 1 Chris Wilson 2016-04-22 15:15:17 UTC
Try with just:

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 48dcb58..1e9546d 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -1098,6 +1098,8 @@ static unsigned small_copy(const RegionRec *region)
 }
 
 #ifdef CREATE_PIXMAP_USAGE_SHARED
+#undef DBG
+#define DBG(x) ErrorF x
 static Bool
 sna_share_pixmap_backing(PixmapPtr pixmap, ScreenPtr slave, void **fd_handle)
 {
@@ -1290,6 +1292,8 @@ sna_create_pixmap_shared(struct sna *sna, ScreenPtr screen,
 
        return pixmap;
 }
+#undef DBG
+#define DBG(x)
 #endif
 
 static PixmapPtr sna_create_pixmap(ScreenPtr screen,
Comment 2 Qiang Yu 2016-04-25 03:04:23 UTC
Hi Chris, I tried this patch and still fail.
ADD info:
the pinned flag of pixmap is PIN_DRI2.
Comment 3 Qiang Yu 2016-04-25 03:13:34 UTC
I catch the xtrace of glxgears, when I change focus, it will get invalidateBuffers event
and get buffer again, the content shows. But I can't find why at the begging the pixmap
is get pinned first and the sequence can change with fast/slow DDX.

000:>:10ae2: Event DRI2-InvalidateBuffers(103) drawable=0x03600002
000:>:10ae2: Event DRI2-BufferSwapComplete(102) drawable=0x00000002 ust_hi=56623106 ust_lo=0 msc_hi=0 msc_lo=0 sbc_hi=0 sbc_lo=34143
000:>:0ae1:32: Reply to SwapBuffers: swap_hi=0 swap_lo=34143
000:>:0ae2:32: Reply to GetInputFocus: revert-to=Parent(0x02) focus=0x0380000b
000:<:10ae3: 20: DRI2-Request(153,7): GetBuffersWithFormat drawable=0x03600002 attachments={attachment=BackLeft(0x00000001) format=0x00000018};
000:>:0ae3:52: Reply to GetBuffersWithFormat: width=300 height=300 buffers={attachment=BackLeft(0x00000001) name=0x00000004 pitch=1280 cpp=4 flags=0x00000000};
Comment 4 Chris Wilson 2016-04-25 05:52:37 UTC
(In reply to Qiang Yu from comment #3)
> I catch the xtrace of glxgears, when I change focus, it will get
> invalidateBuffers event
> and get buffer again, the content shows. But I can't find why at the begging
> the pixmap
> is get pinned first and the sequence can change with fast/slow DDX.

It depends upon a race with a client. I have an old patch for -ati to handle DRI2UpdatePrime failure.
Comment 5 Chris Wilson 2016-04-25 05:52:45 UTC
(In reply to Qiang Yu from comment #3)
> I catch the xtrace of glxgears, when I change focus, it will get
> invalidateBuffers event
> and get buffer again, the content shows. But I can't find why at the begging
> the pixmap
> is get pinned first and the sequence can change with fast/slow DDX.

It depends upon a race with a client. I have an old patch for -ati to handle DRI2UpdatePrime failure.
Comment 6 Qiang Yu 2016-04-25 14:43:05 UTC
Seem the race condition is between glxgears and compiz:
if the compiz call DRI2GetBufferWithFormat before first time glxgears
call DRI2SwapBuffer, the pixmap is pinned with PIN_DRI2.
Comment 7 Qiang Yu 2016-04-25 14:51:32 UTC
Hi Chris, where is your patch? I can try it.
Comment 8 Chris Wilson 2016-04-25 16:10:18 UTC
Created attachment 123250 [details] [review]
Fallback to std DRI2CopyRegion when DRI2UpdatePrime fails
Comment 9 Qiang Yu 2016-04-27 02:25:59 UTC
(In reply to Chris Wilson from comment #8)
> Created attachment 123250 [details] [review] [review]
> Fallback to std DRI2CopyRegion when DRI2UpdatePrime fails

Hi Chris, this patch makes the amdgpu ddx crash.
Also I think this is not the root cause of my problem.
The root cause is why Intel DDX allocated pixmap gets
pinned before DRI2UpdatePrime by compiz.
Comment 10 Chris Wilson 2016-04-27 05:27:22 UTC
(In reply to Qiang Yu from comment #9)
> Hi Chris, this patch makes the amdgpu ddx crash.
> Also I think this is not the root cause of my problem.
> The root cause is why Intel DDX allocated pixmap gets
> pinned before DRI2UpdatePrime by compiz.

It's handling user request and we do not have the api to change the backing bo once assigned. (DRI2InvalidateDrawable). Don't blame the driver for being correct.
Comment 11 Qiang Yu 2016-04-27 05:36:24 UTC
(In reply to Chris Wilson from comment #10)
> (In reply to Qiang Yu from comment #9)
> > Hi Chris, this patch makes the amdgpu ddx crash.
> > Also I think this is not the root cause of my problem.
> > The root cause is why Intel DDX allocated pixmap gets
> > pinned before DRI2UpdatePrime by compiz.
> 
> It's handling user request and we do not have the api to change the backing
> bo once assigned. (DRI2InvalidateDrawable). Don't blame the driver for being
> correct.

You mean the client side should handle this problem?
Or XServer?
Comment 12 Qiang Yu 2016-06-13 01:31:57 UTC
Finally it comes out the problem of Mesa not handling the
DRI2InvalidateBuffers event after SharePixmapToSlave().
https://patchwork.freedesktop.org/patch/92533/

Thanks for your help, Chris.
Comment 13 Qiang Yu 2018-02-07 03:36:36 UTC
Fixed by Michel in Mesa.


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.