Saturday, 28 July 2012

Catalyst driver problems on Fedora

Both AMD and NVIDIA have a less-than-ideal graphics driver offering. Many of us are forced to use their proprietary binary drivers due to marked performance issues and feature limitations in alternative open-source offerings.

With proprietary drivers comes pain, as driver release schedules don't necessarily match up with kernel or xserver release schedules, and module incompatibilities post-upgrade often cause post-reboot soft crashes, kernel panics and headaches in general.

I've posted most of this before, but with further kernel updates causing problems for people, it seemed a good time to combine everything into one post.

I upgraded my kernel, and after rebooting my system hangs on a black screen


/var/log/Xorg.0.log
You need to install the latest Catalyst driver and/or recompile the fglrx module. Before you can do this, you first need to get to a shell; and, as usual, the following triage procedure for doing so applies. Keep going until you get a friendly login prompt.

1. Try switching to another tty with Ctrl + Alt + F[1..12].

2. Alt + PrintScrn + R, then retry the above.

3. You'll need to reboot.
i) Do so the soft way, waiting a couple of seconds in between each alpha key: Alt + PrintScrn + [R,E,I,S,U,B] 
ii) If that doesn't work, you'll have to do so the hard way - with the power button.

4. At the GRUB prompt, press 'e' to enter edit mode. Locate the kernel line beginning with 'linux'*. If 'rhgb' is present, delete it (this will show the textual output of the boot process, and is useful for debugging). In its place, add 'single' (this boots to single user mode, i.e. a shell). When done, press F10. This should dump you at a shell.

5. If even that has failed, your problems are likely more serious than an incompatible module. You're going to need an installation disc to boot into rescue mode, mount your drive, and continue your investigations there.

Once you have a shell, you're in business. Check the /var/log/Xorg.0.log logfile to confirm there was a problem with your fglrx driver. Locate your fglrx installation file, which will be named something like 'amd-driver-installer-12-6-x86.x86_64.run'. Ideally, you will use the newest version available. Run it:

# chmod +x amd-driver-installer-12-6-x86.x86_64.run
# ./amd-driver-installer-12-6-x86.x86_64.run

You may need to use the --force flag to overwrite the previous installation.

Install as usual. If there are no errors, reboot. If there are, check the logfile at the location provided.

The fglrx installation error log contains
"error: ‘cpu_possible_map’ undeclared (first use in this function)"

/usr/share/ati/fglrx-install.log
This is a known issue which still isn't fixed. A patch has been made available. If you're using the patch application, direct it towards /usr/lib/modules/fglrx/build_mod. If you don't have internet access on the box, the quickest solution IMHO is to literally apply the patch manually (given its small size).

To do so, edit the /usr/lib/modules/fglrx/build_mod/firegl_public.c file. Search for the first instance of 'i387' and add this line beneath (line 190):

#include <asm/fpu-internal.h>

Search for the first instance of 'FN_FIREGL_KAS', and replace the line beneath with (line 4160):

for_each_possible_cpu(p)

Edit the /usr/lib/modules/fglrx/build_mod/kcl_ioctl.c file. Search for the first instance of 'to allocated' and add this line beneath (line 220):

DEFINE_PER_CPU(unsigned long, old_rsp);

After saving those files, rebuild and install the fglrx module:

# cd /usr/lib/modules/fglrx/build_mod
# ./make.sh
# cd ..
# ./make_install.sh

Finally, test that you can load your fglrx module with

# modprobe fglrx
# lsmod | grep fglrx

Reboot.

I've rebooted back into Fedora, but my multi-monitor configuration is awry

Use the AMD Catalyst Control Center (sic) in administrative mode.

"AMD Catalyst Control Center (Administrative)" fails to open

Run this instead**:

$ sudo amdcccle


My HDTV shows large black borders around the edges

See my AMD Catalyst: Fixing Underscan post for some background info, but you should just need to run this and reboot:

$ sudo amdconfig --set-pcs-val=MCIL,DigitalHDTVDefaultUnderscan,0

There's an ugly "AMD Testing use only" watermark permanently placed on the bottom of each monitor

You can upgrade/downgrade to the latest release (i.e. non-beta) driver, or run Kano's script which I've reproduced below (and tweaked slightly for use on Fedora):

#!/bin/sh
DRIVER=/usr/lib64/xorg/modules/drivers/fglrx_drv.so

cp $DRIVER ${DRIVER}.original

for x in $(objdump -d $DRIVER|awk '/call/&&/EnableLogo/{print "\\x"$2"\\x"$3"\\x"$4"\\x"$5"\\x"$6}'); do

    sed -i "s/$x/\x90\x90\x90\x90\x90/g" $DRIVER

done



* As you already know, Linux is just the kernel. Much of the rest of the OS is based on the recursively-named GNU utils. 

** Unpolitically correct, I know, but it "just works" across all desktop environments and has never caused me a problem with amdcccle in particular. If anybody knows of a gksudo/gnomesu equivalent package in the Fedora repos, I'd be grateful to hear of it. The administrative menu entry for amdcccle calls amdxdg-su -c amdcccle, but this doesn't work for me (under xfce at least, it fails with "no graphical method available"). ATI bug report. Ubuntu bug report.