FS#37888 - [libdrm] 2.4.49-1 breaks AMD radeon vdpau in xbmc

Attached to Project: Arch Linux
Opened by Ruben Van Boxem (rubenvb) - Saturday, 23 November 2013, 18:36 GMT
Last edited by Andreas Radke (AndyRTR) - Thursday, 20 March 2014, 16:47 GMT
Task Type Bug Report
Category Upstream Bugs
Status Closed
Assigned To Jan de Groot (JGC)
Andreas Radke (AndyRTR)
Laurent Carlier (lordheavy)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 3
Private No

Details

Description:
With libdrm-2.4.47-1, I could enablee VDPAU by adding the following to xbmc's .bashrc:
export LIBVA_DRIVER_NAME=vdpau
export VDPAU_DRIVER=r600

and using the open source Radeon driver. No other settings were used for anything.

Using libdrm-2.4.49-1, playing a video with these exact settings freezes xbmc. The same kind of freeze can be seen when also enabling VAAPI acceleration in xbmc using the old libdrm.

The program vdpauinfo also reflects the absence of working VDPAU support with the new libdrm.

This is using kernel 3.12(.1), and mesa/mesa-libgl/ati-dri 9.2.3.
This task depends upon

Closed by  Andreas Radke (AndyRTR)
Thursday, 20 March 2014, 16:47 GMT
Reason for closing:  Fixed
Comment by Laurent Carlier (lordheavy) - Saturday, 23 November 2013, 21:43 GMT
And with libdrm-2.4.48 ?
Comment by Ruben Van Boxem (rubenvb) - Sunday, 24 November 2013, 15:19 GMT
I missed that update so I built it from the history in libdrm's PKGBUILD git repository. 2.4.48 also exhibits the freezing behavior, so something broke this setup after 2.4.47.

For reference, the GPU is an HD6450:
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Caicos [Radeon HD 6450/7450/8450]
Comment by Jan de Groot (JGC) - Monday, 25 November 2013, 20:12 GMT
Could you bisect this to a git commit upstream?

Also, you might want to revert this commit:
https://projects.archlinux.org/svntogit/packages.git/commit/trunk?h=packages/libdrm&id=0ca3903e9affbee936285d72855f9d73a6e92f4e

If reverting to clang fixes your bug, there's another bug in libdrm that is caused by undefined behaviour in gcc.
Comment by Ruben Van Boxem (rubenvb) - Friday, 29 November 2013, 20:35 GMT
I haven't bisected the sources (might get to that sunday), but I found a new element: before I start xbmc, I need to reinstall the 2.4.47 package. Then, everything works. If I then reboot and start xbmc, it freezes. I used Clang to compile version 2.4.48 (started from the 2.4.47 PKGBUILD).

I'm confused on how reinstalling the package would prevent the freeze from happening though.
Comment by Raul Fernandes (rgfernandes) - Monday, 02 December 2013, 17:58 GMT
There is a fix in git that I think that is for this bug too.
Try the patch I'm sending.
The commit of the patch is:

http://cgit.freedesktop.org/mesa/drm/commit/?id=c8a437f4c76527b3c8385699ccee07f35fe3f166

I had this bug and this patch fixed it to me.
This seems to be the same bug of https://bugs.archlinux.org/task/37903.
Comment by Laurent Carlier (lordheavy) - Tuesday, 03 December 2013, 19:30 GMT
Please try libdrm-2.4.50
Comment by Ruben Van Boxem (rubenvb) - Tuesday, 03 December 2013, 19:30 GMT
I can confirm the patch returns the behavior back to the 2.4.47 state. So the real problem remaining is the following:

1. install libdrm (2.4.47 or the patched 2.4.49). Start xbmc (with aforementioned settings for vdpau through ati-dri). Everything works.

2. reboot. Start xbmc. Freezes on initiation of video playback. Exit xbmc. Reinstall libdrm (2.4.47 or patched 2.4.49). Start xbmc. Everything works.

3. reboot. Start xbmc. Freezes. systemctl restart xbmc. Everything works.

4. reboot. Start xbmc. Restart xbmc. Freezes. Restart xbmc. Everything works.

An xbmc log when the freeze happens:

[snip]
20:05:06 T:140296952198912 NOTICE: CDVDVideoCodecFFmpeg::Open() Creating VDPAU(1920x816, 28)
20:05:15 T:140297713821440 DEBUG: Suspended the Sink
20:05:33 T:140297388422912 DEBUG: Thread Jobworker 140297388422912 terminating (autodelete)
[end of log]

Log of identical actions after a systemctl restart xbmc:
[snip]
20:08:37 T:139810916267776 NOTICE: CDVDVideoCodecFFmpeg::Open() Creating VDPAU(1920x816, 28)
20:08:37 T:139812461995968 DEBUG: ------ Window Init (DialogBusy.xml) ------
20:08:37 T:139810916267776 NOTICE: vdp_device = 0x00000001 vdp_st = 0x00000000
20:08:37 T:139810916267776 NOTICE: VDPAU Decoder capabilities:
20:08:37 T:139810916267776 NOTICE: name level macbs width height
20:08:37 T:139810916267776 NOTICE: ------------------------------------
20:08:37 T:139810916267776 NOTICE: MPEG1 16 9216 2048 1152
20:08:37 T:139810916267776 NOTICE: MPEG2_SIMPLE 16 9216 2048 1152
20:08:37 T:139810916267776 NOTICE: MPEG2_MAIN 16 9216 2048 1152
20:08:37 T:139810916267776 NOTICE: H264_BASELINE 16 9216 2048 1152
20:08:37 T:139810916267776 NOTICE: H264_MAIN 16 9216 2048 1152
20:08:37 T:139810916267776 NOTICE: H264_HIGH 16 9216 2048 1152
20:08:37 T:139810916267776 NOTICE: VC1_SIMPLE 16 9216 2048 1152
20:08:37 T:139810916267776 NOTICE: VC1_MAIN 16 9216 2048 1152
20:08:37 T:139810916267776 NOTICE: VC1_ADVANCED 16 9216 2048 1152
20:08:37 T:139810916267776 NOTICE: MPEG4_PART2_ASP 16 9216 2048 1152
20:08:37 T:139810916267776 NOTICE: ------------------------------------
20:08:37 T:139810916267776 NOTICE: Mixer feature: VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION
20:08:37 T:139810916267776 NOTICE: Mixer feature: VDP_VIDEO_MIXER_FEATURE_SHARPNESS
20:08:37 T:139810916267776 NOTICE: CDVDVideoCodecFFmpeg::Open() Using codec: H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (VDPAU acceleration)
20:08:37 T:139810916267776 DEBUG: FactoryCodec - Video: ff-h264_vdpau-vdpau - Opened
20:08:37 T:139810916267776 NOTICE: Creating video thread
[more succes]

GDB backtrace at the moment of the freeze of the relevant xbmc process (I think):
#0 0x00007f809a2b703f in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1 0x00007f809704e0f0 in ?? () from /usr/lib/libX11.so.6
#2 0x00007f809705fc98 in ?? () from /usr/lib/libX11.so.6
#3 0x00007f8091585977 in ?? () from /usr/lib/libxcb.so.1
#4 0x00007f8091585f4e in xcb_send_request () from /usr/lib/libxcb.so.1
#5 0x00007f809179c33d in xcb_dri2_swap_buffers_unchecked () from /usr/lib/libxcb-dri2.so.0
#6 0x00007f80996ae4b7 in ?? () from /usr/lib/libGL.so.1
#7 0x00000000010b2ca7 in CWinSystemX11GL::PresentRenderImpl(std::vector<CDirtyRegion, std::allocator<CDirtyRegion> > const&) ()
#8 0x000000000100d2cf in CRenderSystemGL::PresentRender(std::vector<CDirtyRegion, std::allocator<CDirtyRegion> > const&) ()
#9 0x0000000000ede2d9 in CApplication::Render() ()
#10 0x00000000009b862e in CGUIWindowManager::ProcessRenderLoop(bool) ()
#11 0x00000000009efbb2 in CDVDPlayer::OpenFile(CFileItem const&, CPlayerOptions const&) ()
#12 0x0000000000ee9d82 in CApplication::PlayFile(CFileItem const&, bool) ()
#13 0x0000000000eeae9d in CApplication::PlayMedia(CFileItem const&, int) ()
#14 0x0000000000cddb16 in CBuiltins::Execute(CStdStr<char> const&) ()
#15 0x0000000000eef169 in CApplication::ExecuteXBMCAction(std::string) ()
#16 0x0000000000eeff10 in CApplication::OnMessage(CGUIMessage&) ()
#17 0x00000000009b8df2 in CGUIWindowManager::SendMessage(CGUIMessage&) ()
#18 0x000000000091bb5d in CGUIAction::ExecuteActions(int, int) const ()
#19 0x000000000092455c in CGUIBaseContainer::OnClick(int) ()
#20 0x00000000009b666a in CGUIWindow::OnAction(CAction const&) ()
#21 0x00000000009b927d in CGUIWindowManager::OnAction(CAction const&) ()
#22 0x0000000000eeb620 in CApplication::OnAction(CAction const&) ()
#23 0x0000000000eed0a4 in CApplication::OnKey(CKey const&) ()
#24 0x0000000000eedd64 in CApplication::OnEvent(XBMC_Event&) ()
#25 0x0000000000eba668 in CWinEventsSDL::MessagePump() ()
#26 0x0000000000eeebf4 in CApplication::FrameMove(bool, bool) ()
#27 0x0000000000f7bf62 in CXBApplicationEx::Run() ()
#28 0x0000000000f839b7 in XBMC_Run ()
#29 0x00000000006ad33a in main ()

How can restarting xbmc "fix" the issue? Is there any way to get more debug info out of this?
Comment by Ruben Van Boxem (rubenvb) - Tuesday, 03 December 2013, 19:43 GMT
It seems I was mistaken to think this is libdrm's fault. Further investigation reveals that 2.4.48 also "works" as described above.

I don't know where to start looking :-/
Comment by Raul Fernandes (rgfernandes) - Tuesday, 03 December 2013, 21:15 GMT
Ruben,
There are another bug in vdpau that sends invalid frames and causes the freezes.
And it occurs only when using glamor.
I had no time to investigate this, but I know that bug exists.
But for me only a few movies triggers this bug.
Can you test to see if it freezes with all movies or only a few??
The bug in libdrm did exist too but it is fixed now.
Comment by Laurent Carlier (lordheavy) - Saturday, 25 January 2014, 21:21 GMT
What is the status with latest glamor-egl/xf86-video-ati/libdrm packages ?
Comment by Ruben Van Boxem (rubenvb) - Saturday, 25 January 2014, 23:23 GMT
It's still the same as in my previous comments (xf86-video-ati 1.7.2, ati-dri 10.0.2, glamor-egl 0.5.1.r258, xbmc 12.3, libdrm 2.4.52). First run fails, restarting xbmc after the first hang when initiating video playback remedies the issue. I haven't been able to get a backtrace or strace or whatever from xbmc at the point of the hang. XBMC logs aren't helpful either as there is no crash :-(
Comment by Andreas Radke (AndyRTR) - Monday, 27 January 2014, 14:04 GMT
Can you please disable any DRI for testing or remove ati-dri and glmaor-egl to check, if the bug is in libdrm or ati-dri and glamor?

Please also check the 3.13 kernel currently in testing that has many Ati card related improvements.
Comment by Ruben Van Boxem (rubenvb) - Saturday, 01 February 2014, 11:53 GMT
I don't see how I can use xf86-video-ati without ati-dri/glamor-egl, as the former depends on the latter two.

I installed the linux-3.13.1 package from testing manually. All the below is using that kernel. I will attempt to describe and analyze the situation as best I can. I understand issue 3 and 4 are unrelated to the original issue, I can open a nuw bug for them.

I have my HTPC connected to my HiFi, which taps off the sound and sends the video to my TV.

1. If I boot with the receiver off, I can't get any video output until I restart X.
2. If the receiver is on, but the TV is off during boot, turning on the tv gives me video output as expected, but starting playback now crashes xbmc (xbmc_vdpau_glamor.log). After the first crash, consequent playback works. Setting AccelerationMethod in /etc/X11/xorg.conf.d/radeon.conf to e.g. "EXA" also crashes XBMC (xbmc_vdpau_exa.log). I confirmed in Xorg.log that Glamor is not being used in this case.
3. When playing a video using vdpau (after booting with TV on, or after the first restart after the crash), pressing the back button crashes XBMC (xbmc_vdpau_back_button.log)
4. Playback with vdpau enabled has a very irritating sync issue where the top 5% rows are out of sync with the rest of the screen. This causes very noticeable flickers especially with panning shots. I can film this with e.g. my phone if you think it is helpful, but a screenshot is impossible as pausing removes the tear from the image. When vdpau is off in XBMC settings, the issue is much less pronounced but still present (only top 5 or 10 pixel rows show the sync issue).

All these don't happen if I disable vdpau acceleration in the xbmc settings.

My conclusion: it's not fixed in linux 3.13, it's not a glamor issue. I don't know how to disable DRI here and still use xf86-video-ati/libdrm's vdpau driver.
Comment by beeender (beeender) - Thursday, 06 March 2014, 15:52 GMT
i can 100% reproduce freeze issue with a wma video.
Backtrace is the same as
"
GDB backtrace at the moment of the freeze of the relevant xbmc process (I think):
#0 0x00007f809a2b703f in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1 0x00007f809704e0f0 in ?? () from /usr/lib/libX11.so.6
#2 0x00007f809705fc98 in ?? () from /usr/lib/libX11.so.6
#3 0x00007f8091585977 in ?? () from /usr/lib/libxcb.so.1
#4 0x00007f8091585f4e in xcb_send_request () from /usr/lib/libxcb.so.1
....
"
And also tried with downgrading the libdrm, doesn't help.
Comment by Ruben Van Boxem (rubenvb) - Thursday, 20 March 2014, 16:09 GMT
I think I can safely say I am not running into this particular issue anymore. I can boot, start XBMC with VDPAU enabled, and nothing freezes anymore. Something, somewhere, changed so it could work. Let's just hope XBMC Gotham doesn't mess anything up now :-)

Thanks for the help!

Loading...