WINE, i915 or i965 & intel_do_flush_locked

Recently, while debugging a WINE based application for a friend, who is by far not a Linux neophyte — I started seeing:

"intel_do_flush_locked failed: Input/output error"

on the CLI, as well as:

[ 366.415824] [drm:i915_hangcheck_elapsed] *ERROR* Hangcheck timer elapsed... GPU hung
[ 366.415847] [drm:i915_wait_request] *ERROR* i915_wait_request returns -11 (awaiting 77445 at 77442, next 77446)
[ 366.564710] [drm:i915_hangcheck_elapsed] *ERROR* Hangcheck timer elapsed... GPU hung
[ 366.564711] [drm:i915_wait_request] *ERROR* i915_wait_request returns -11 (awaiting 77471 at 77467, next 77472)

In the /var/log/Xorg.0.log file.

The only new thing was an upgrade from Ubuntu 10.04LTS to 12.04LTS a few months earlier, which was completely stock, aside from the WINE PPA being used, which was more a leftover from one the original machine had been installed some years ago with 8.04LTS.

… and this was the first time this particular issue had occurred.

They were using the WINE PPA already, so the copy of WINE was already up-to-date, although the program had no issues running between WINE 1.0 and 1.4, so I wasn’t terribly concerned that upgrading to 1.5.x would have anything to do with it.

Having tried numerous i965 related tweaks on the web, then finding that I was not alone in the issue — I investigated the alternative ways of fixing the problem.

The xorg-edgers PPA made little difference, with an updated driver and MESA installation — there was a longer period before the application crashed, but it still crashed after a few minutes, better than the standard 12.04 repository (as of 2012-11-28) where the application would crash immediately though.

The x-swat/x-updates PPA (the “more stable” version of the PPA above) was slightly better, WINE at least created the virtual desktop window before the messages started appearing, we called that “progress” and went looking for things specific to the code available in that repository.

Using i965 Frame Buffer Compression in the GRUB configuration made no difference, but this time other things on the desktop (GNOME Shell) started restarting intermittently before we’d even got to the terminal window in order to start WINE.

According to the PowerSavingTweaks page, Frame Buffer Compression (FBC) does:

Framebuffer compression reduces the memory bandwidth on screen refereshes and depending on the image in the framebuffer can reduce power consumption. … Some users report this breaks when using Unity 3D.

I thought we may be having issues because it was an older motherboard, a 1.3Ghz Celeron CPU board with 4GiB of RAM — possibly a Power Management thing too, Indeed, reverting the i915_enable_rc6 fix by changing the /etc/default/grub file to:

i915.i915_enable_rc6=0

“fixed” the problem even further, with the bug taking 5-6x longer to manifest (a period of minutes) itself.

Next, purging the xorg-edgers PPA and adding the Backported X / Kernel code from the q-lts-quantal PPA seemed to start off well, but within minutes offered a slightly different error:

"intel_do_flush_locked failed: No space left on device" 

( Which also appeared when we simply tried booting the machine from a 12.10 installer image and testing the issue there. )

Still annoying and quite unusable for day-to-day operations, so we purged that with the ppa-purge utility and re-re-replaced the xorg-edgers PPA but we found Oibaf’s “Updated and Optimized Graphics Drivers” which had an even newer (and arguably, more well tested, if these forums are to be believed) MESA and llvmpipe code, which, was about the last-gasp of a solution, the application in question was, after all a 2D educational program from the late 1990′s, running in a Win95-based WINE instance with no prior tweaking or modifification, so I thought: “*why would it need an updated 3D library?” … but, having found the mailing list and with the PPA page suggesting:

To force the use of gallium llvmpipe software render:
$ LIBGL_ALWAYS_SOFTWARE=1 glxgears -info

I installed the libgl1-mesa-dri-experimental package, then ran the obligitory “sudo apt-get update && apt-get dist-upgrade which pulled in MESA and llvmpipe and a bunch of other updates, rebooted and ran:

$ LIBGL_ALWAYS_SOFTWARE=1 wine /path/to/executable

… and up came the application, which happily wombled along for three hours while we drank scotch and celebrated.

In the end, the best working combination, for those having issues with WINE applications in Ubuntu 12.04 or 12.10 with these hangcheck bugs, was to use the software renderer available from the Oibaf PPA repository and turning OFF the rc6 power-saving fix in Ubuntu, in combination with the code in the xorg-edgers PPA (as of 2012-11-28).

So, the rub (if your Google-fu takes you here directly) to get this to work (on Ubuntu 12.04 and 12.10):

# add-apt-repository ppa:ubuntu-x-swat/x-updates
# add-apt-repository ppa:oibaf/graphics-drivers
# apt-get update && apt-get dist-upgrade
# sed -i -e 's/"quiet splash"/"quiet splash i915.i915_enable_rc6=0"/g' /etc/default/grub
# update-grub

( of course, add a “cp /etc/default/grub /etc/default/grub.backup if you’d like to backup your GRUB configuration :) )

… reboot, and then try your application – Milage May Vary(tm) but it works really well on older i915 hardware here.

If of course, you’d like to revert this, ppa-purge the two repositories and restore your GRUB configuration and you’re back to scratch.