Using fuser to to Work Around snd-cs46xx Suspend Bug

The kernel module snd-cs46xx contains a bug that makes it unusable after the computer has been suspended using ACPI or APM. At this point, I believe it is the only thing keeping me from 100% enjoyment of my IBM Thinkpad T21. Other IBM/Lenovo Thinkpad models may also use this chip and module, including the 600X, A20m, A20p, A21m, A21p, A22m, A22p, T20, T21, and T22. Probably other systems as well, this is not a Thinkpad-only chipset.

In my T21, the audio chipset is CS4624, and is identified in the following way by lspci:

matthew@anewt:~$ lspci | grep audio
00:05.0 Multimedia audio controller: Cirrus Logic CS 4614/22/24 [CrystalClear SoundFusion Audio Accelerator] (rev 01)

The bug makes the snd-cs46xx module unusable after a resume from suspend. To use the module again, it must be removed and reloaded again (modprobe -r snd-cs46xx, then modprobe snd-cs46xx). This process can be easily automated, unless there is a program using the module. An module that is in-use will be met with an error message.

There has been a purposed work-around/patch by Mark Stosberg on the Ubuntu Launchpad. It would identify processes using the kernel module and kill them. It does not seem to be effective on my Debian Etch system. It seems to utilize a list of applications somewhere in /proc that are using the sound module, but I just do not have that list. The patch was originally included in Mandriva, so perhaps something has simply been lost in translation from distribution to distribution.

Anyhow, I propose I more simple (three lines) code.

Fuser is an application that you probably already have installed on your GNU/Linux system, wheather your use it or not. It identifies applications and users that are accessing certain files on a system, wheather it is a document or a device file. It can use an argument, -k, to kill those processes using the file in question. The command “fuser -k /dev/snd/*” will kill any and all processes using a soundcard on the particular system.

Note that this is why my method is a work-around, and not a fix. Any program: a mixer, media players, or even a web browser, that is using the sound card is killed. You will lose any data that it was using (think unsaved playlists, unsaved game, perhaps the loss of a web browsing session). This would occur anytime you suspend the computer (i.e. shut the lid). If you feel that you can remember to close your audio programs, and reopen them when you resume, this work-around is for you! I have more to say about how programs handle this, later on.

So we have our three commands. In order, the computer must perform these at resume:

  1. fuser -k /dev/snd/*
  2. modprobe -r snd-cs46xx
  3. modprobe snd-cs46xx

Where to put them? Paste those three commands in the file /etc/acpi/resume.d/ and you should be ready to go. Next time you put your computer to sleep, your audio-enabled applications should crash. Yay.

Alternatively, you can create a shell script and store it in some directory in your exectuable path (think /usr/bin or ~/bin). This is the method I have chosen, and it involves manually running the script every time you resume and decide you want sound. It has the added benefit of restarting your mixer application (kmix, for me), because it is user-level, not root. The code for my ~/bin/

  1. #!/bin/sh
  2. fuser -k /dev/snd/*
  3. sudo modprobe -r snd-cs46xx
  4. sudo modprobe snd-cs46xx
  5. kmix

Replace kmix, if you wish, and you may also choose to load xmms or amarok.

My Shared Items

In case anyone out there is interested, I have shared some of my favorite news feeds and items via Google Reader’s Shared Items function. And you can find them here.

SciTE (Or, the best IDE/Text Editor Around)

scite-terminal-output.jpgSo this semester I am taking Java classes at Kennesaw State University. We’ve been using a Java-based text-editor/compiler called jGRASP, which is not bad. But I have found myself, having some familiarity with other text editors, preferring to use Kate or Nano and then manually compile the program.

But I have felt a bit torn: there are not many advantages to useing jGRASP over Kate, but two that I notice (being a novice) are the compile- and run-applet-buttons. Now, Kate does have a great built-in terminal (Konsole), so it is very easy to compile and run programs. But there isn’t a button.

So I asked myself: is there another text editor that has a simple “compile” and/or “run” button? I tried the resource-hungry IDEs, NetBeans and Eclipse, but they just won’t run on my meager laptop with any speed.

But today, I found SciTE. SciTE falls somewhere in between text-editor and IDE. It doesn’t have all of the classes, functions, libraries, and such filled in, or menu-ed, or anything of the sort. It does, however, have a compile-button (and hotkey) and a run-hotkey. Type in your code and press “F7″ to compile *.java and then “F5″ to run the current file.

Of course, built into SciTE is syntax highlighting for all of the major programming and scripting languages, from Ada to YAML. Tabs, an input/output terminal, line-folding, and session-management are all there and functional.scite-langs.jpg

And SciTE is fast. It runs in GTK+, and loads noticeably quicker than QT-based Kate or Java-based JGrasp. Nano does probably beats SciTE in speed, but this is understandable since Nano is ncurses-based, and not graphical.

In short, apt-get install scite. Run scite and be ready to be impressed by my new favorite text editor/IDE.

Goodbye, Sarge

Debian Security has announced that support for Debian 3.1, codename “Sarge” will be ending  on 31 March, 2008. This comes a full year after the release of Debian 4.0 “Etch.”

Etch has made great improvements over Sarge, and Lenny will be making improvements over Etch. Sarge, which included a 2.4 kernel, has been maintained for stability, but is now obsolete. While I know that system administrators all over the world appreciate Debian’s dedication to the older system, it is time to move on and upgrade if they have not already.

I feel a bit of sad about the end of Sarge’s support. Sarge was the first GNU/Linux that I actually installed and used outside of running the live-distros DSL and Knoppix. I was able to successfully install Sarge on my IBM Thinkpad 600 after my decision to switch from Windows 98 to something more modern (that wasn’t Windows XP) and a fruitless attempt at installing NetBSD.

I haven’t run Sarge since Etch was still in testing, though I do still have a “NetInst” installer disc - I never bothered to download an Etch installer. Now I suppose I’ll have to, as it is difficult to go from Sarge to Lenny, which, I hypothesize, will be ready within the year.