ArchLinux: looking good

It’s been approximately two years since I changed to using Ubuntu for my desktop needs. Before, I was using Mac OS, but I was getting increasingly annoyed with it and the direction it was heading for, specially since Leopard and was released.

I have learnt a lot with Ubuntu, and I think they’re doing a great work for popularising Linux as an environment anyone can use. But I am also a very picky person, and I am getting weary of the bloat that comes with each new version. I don’t consider them incompetent (far from it), but they are trying to please too many people and therefore including lots of stuff I don’t use. Probably I have got past the Linux-newbie level and should move to something a bit more advanced where I could change every thing as I pleased.

(more…)

Fixing the Netgear WPN311 system freezes in Ubuntu

We had this long-time problem with the Netgear WPN311 wireless cards which seemed to go and come back intermittently with each kernel revision: if we used intensively the wireless, the computer would freeze. As in totally frozen (you couldn’t even go back to a console and restart the X or something from there).

With Ubuntu 9.10 and the 2.6.31 kernel, the problem seemed semi-stable and only appeared if we used packet-crazy software such as bittorrent at high speeds, but at least we could connect to internet. Mr doob, a brave soul, updated his computer to Ubuntu 10.4 pretty much as soon as it was released, and got all the worse for that: the wireless card would freeze the computer almost every 20 minutes, and even worse, without any pattern such as “using a lot the internet” or “using bittorrent”. He ended up using another computer which a different wireless chipset, but that’s an expensive fix!

After I upgraded my computer hardware-wise I felt it was the time to risk it and upgrade it software-wise too. Mr doob warned me that I would be regretting this move later on, but I couldn’t stand the envy each time I went to his computer and saw the nicer shiny interface he had in 10.4, while I was still using 9.10 and a lot of outdated applications. Yes, one can use PPA’s for that, but it’s a bit tedious to install a PPA for every single program you want to update :D

So after carefully considering all the bug reports about the ath5k driver, I dared to update the system.

And as expected, a mere 15-20 minutes after the system had been updated and restarted, it froze.

None of the solutions out there seemed to make much sense, except for one which suggested a patch to the ath5k driver. This is how I applied the solution to the latest version of Ubuntu:

Download the source for the latest kernel:

sudo apt-get install linux-source-2.6.32

It ends up downloading a .bz2 file into /usr/src. To uncompress it:

cd /usr/src
sudo tar -xvjf linux-source-2.6.32.tar
cd linux-source-2.6.32

The patch expects the files to be in drivers/net/wireless/ but it seems they have been moved around since then. Now they are in drivers/net/wireless/ath/ath5k (note the extra /ath/).

I took a look at the files, and noticed that the patch hadn’t been applied to the kernel, even if the patch was almost two years old already.

So I manually applied the patch to the files (it was easy, just around 10 lines of code). Here’s how it should be done, green lines are new lines (additions), red lines are deleted things:

base.c

diff --git a/home/sole/Desktop/linux-source-2.6.32/drivers/net/wireless/ath/ath5k/base.c b/driver
index 6313788..db2c785 100644
--- a/home/sole/Desktop/linux-source-2.6.32/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -551,6 +551,7 @@ ath5k_pci_probe(struct pci_dev *pdev,
        sc->opmode = NL80211_IFTYPE_STATION;
        sc->bintval = 1000;
        mutex_init(&sc->lock);
+       spin_lock_init(&sc->restlock);
        spin_lock_init(&sc->rxbuflock);
        spin_lock_init(&sc->txbuflock);
        spin_lock_init(&sc->block);
@@ -2727,6 +2728,7 @@ ath5k_reset(struct ath5k_softc *sc, struct ieee80211_channel *chan)
 {
        struct ath5k_hw *ah = sc->ah;
        int ret;
+       unsigned long flags;
 
        ATH5K_DBG(sc, ATH5K_DEBUG_RESET, "resetting\n");
 
@@ -2738,7 +2740,10 @@ ath5k_reset(struct ath5k_softc *sc, struct ieee80211_channel *chan)
                sc->curchan = chan;
                sc->curband = &sc->sbands[chan->band];
        }
+       spin_lock_irqsave(&sc->restlock, flags);
        ret = ath5k_hw_reset(ah, sc->opmode, sc->curchan, chan != NULL);
+       spin_unlock_irqrestore(&sc->restlock, flags);
+
        if (ret) {
                ATH5K_ERR(sc, "can't reset hardware (%d)\n", ret);
                goto err;

base.h

diff --git a/home/sole/Desktop/linux-source-2.6.32/drivers/net/wireless/ath/ath5k/base.h b/drivers/net
index a28c42f..a0cbf61 100644
--- a/home/sole/Desktop/linux-source-2.6.32/drivers/net/wireless/ath/ath5k/base.h
+++ b/drivers/net/wireless/ath/ath5k/base.h
@@ -162,6 +162,7 @@ struct ath5k_softc {
                                led_on;         /* pin setting for LED on */
 
        struct tasklet_struct   restq;          /* reset tasklet */
+       spinlock_t              restlock;       /* protects reset state */
 
        unsigned int            rxbufsize;      /* rx size based on mtu */
        struct list_head        rxbuf;          /* receive buffer */

And phy.c

diff --git a/home/sole/Desktop/linux-source-2.6.32/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/
index 9d67647..112e8e2 100644
--- a/home/sole/Desktop/linux-source-2.6.32/drivers/net/wireless/ath/ath5k/phy.c
+++ b/drivers/net/wireless/ath/ath5k/phy.c
@@ -578,8 +578,9 @@ int ath5k_hw_rfregs_init(struct ath5k_hw *ah, struct ieee80211_channel *channel,
         * ah->ah_rf_banks based on ah->ah_rf_banks_size
         * we set above */
        if (ah->ah_rf_banks == NULL) {
-               ah->ah_rf_banks = kmalloc(sizeof(u32) * ah->ah_rf_banks_size,
-                                                               GFP_KERNEL);
+               //ah->ah_rf_banks = kmalloc(sizeof(u32) * ah->ah_rf_banks_size,
+               //                                              GFP_KERNEL);
+               ah->ah_rf_banks = kmalloc(sizeof(u32) * ah->ah_rf_banks_size, GFP_ATOMIC);
                if (ah->ah_rf_banks == NULL) {
                        ATH5K_ERR(ah->ah_sc, "out of memory\n");
                        return -ENOMEM;

Then this:

sudo make oldconfig
sudo make

and I let the computer compiling the kernel while I went to sleep, but I forgot to deactivate the wireless and it got frozen again, without completing the compilation.

Next morning, after cursing myself for having forgotten to deactivate the wireless, I rebooted again, but using the previous kernel (selected it from GRUB), just to be safe, and once the wireless had been deactivated, I tried to recompile again. This time it stopped in the middle because there’s an error in one Makefile (I seriously wonder how the Ubuntu guys manage to compile the kernel if it fails like this for them!)

Anyway, I manually applied this patch as well, and restarted the compilation again.

Once it finished, I got the desired new driver module (drivers/net/wireless/ath/ath5k/ath5k.ko) which I wanted to use instead of the existing module. So I backed it up and copied the new one over the old one:

cp /lib/modules/2.6.32-23-generic/kernel/drivers/net/wireless/ath/ath5k/ath5k.ko ~/Desktop
sudo cp /usr/src/linux-source-2.6.32/drivers/net/wireless/ath/ath5k/ath5k.ko /lib/modules/2.6.32-23-generic/kernel/drivers/net/wireless/ath/ath5k/ath5k.ko

and restarted the computer to use the latest kernel (and the new updated module)

I have tested it using bittorrent, amule, youtube, downloading packages from synaptic, all at the same time. So far I haven’t experienced any freeze, and the net speed is normal (if there’s a slowdown, I can’t appreciate it), so I would say the patch fixes this annoying bug.

I wonder why the fix has not been applied to the kernel (after two years!!) but I presume that maybe these cards are not as popular as maybe other wireless chipsets and as such they get less coverage/reports than other bugs. In any case, Bob Copeland (the author of the patch) is my personal hero for at least this month.

Bob, THANKS A LOT FOR THE PATCH!!!

Building a quiet PC

My main computer is a PC I assembled myself two years ago. While I don’t like fixing somebody else’s computer, I quite enjoy fine-tuning mine and learning about it in the process. It is a bit of a beast (for my purposes) with a Quad Core and lots of memory, hard disk bays (I never have enough space!), and etc. I’m quite happy with it but I still consider it a work in progress, specially because of one outstanding problem: NOISE!

BIOS settings

When I first assembled it, the default settings from the motherboard were set to have all the fans spinning at maximum power, and the CPU was set to work at maximum speed as well. It was a bit like having a jet engine under the table. Then I learnt that these things could be configured in the BIOS, and after a BIOS upgrade, I managed to convince the motherboard to behave a little bit more reasonably and slow down both the fans and the CPU, but using the latter “on demand”, which means it can accelerate when the operating system requires more crunching power.

Switching off chassis fans

That improved things a lot, but there was still too much noise for my ears (I like to hear myself think, so to say). I investigated a bit more and found that unless I played 3D games with the computer, which I never do, I really didn’t need to have so many chassis fans working. So I disconnected two of them and the noise went down even further, but it was still quite noticeable.

Replacing noisy fans

I investigated a bit more and found that not all fans are the same. I guess it’s not that surprising if you think about it, but we rarely pay attention to computer fans. They are just there, rotating, and that’s all we know about them. But there’s a lot to be written about fans. The cheapest ones do the job but at the cost of noise and extra energy consumption; the more expensive ones are better engineered, have better airflow and make less noise and consume less energy because they can move more air with slower speeds.

Noctua fan

So once I found about that, I replaced the rear fan (the tower exhaust) with a noctua fan. It is virtually silent, apart from being cream-coloured and having a very strange installation method with rubber ‘screws’ that got on my nerves, but supposedly reduces vibration noise. This improved things a lot, but…

We’ve been experiencing an incredible hot weather for the last days here in London. I mean, 25 degrees! A heatwave! While that’s fine for me (after all, I grew in a place where 38ºC in summer were the norm), it isn’t that nice when you’ve got the computer turned on pretty much 24/7, because the fans are at such hard work that you can know when the computer is doing anything CPU-intensive just by listening to the fan noise.

Better CPU cooler

There were two noise sources in the computer: the CPU fan and the power supply. I didn’t feel like replacing the power supply, and besides, I could perfectly pinpoint the dominant noise source: the CPU fan!

Arctic cooler

It turns out the stock CPU coolers, supplied by Intel, are simply “good enough” to prevent your CPU from melting. But they aren’t really that good efficiency and quietness wise. The sensors reported around 65ºC in the CPU, which seemed a lot to me (as a friend said: you could fry an egg there!!). So I decided it was time for an improvement in that area (either that, or buying a ton of paracetamol for the headaches). I chose the Freezer 7 Pro R2 cooler from Arctic Cooler, mostly because it seemed quite good but also because it wasn’t insanely expensive. And it’s been the best decision this year, I think!


Nice video (not by me), showing how to install it; the default stock CPU cooler is shown as well

Once I installed it and re-plugged everything I had to unplug (because it’s somehow bulky and requires you to make room for it in the motherboard) I couldn’t stop looking at the computer, side panel still not installed just in case, and wondering: but is it really working? Indeed it was! I opened three chrome instances with mrdoob’s javascript experiments while also encoding a video in another program and you could barely hear the fan. It was fantastic!

And not only there is a lot less noise now, but the readings report healthier values from the inside: the CPU reports around ~40ºC now. It’s an amazing drop of temperature: more than 20 degrees!

In a way, it was kind of expectable: the design of this cooler makes way more sense to me, compared to the stock one: instead of expelling air towards the side of the box (which doesn’t quite work that well unless you’ve got one of those tube sleeves for channelling CPU hot air) it uses the fan for moving cold air from the front of the box through the dissipation fins and towards the back of the box. The (silent) chassis rear fan makes the rest. Also, this fan is larger, which makes a lower frequency hum and also moves more air at lower speeds.

And the rest

Both the graphics card and the memory use passive dissipation already, with no moving parts whatsoever, and the hard disk noises don’t bother that much as to replace them with SSD drives, so I’ll leave them for the time being. Oh, and I use the DVD drive like… twice a year? So it really doesn’t make much noise.

At some point I might replace the front fan, which I suspect is the reason of some sporadic humming I can hear, with one of those silent noctua fans. But it’s slightly cumbersome to reach the front panel, and it doesn’t annoy me that much unless I look at it and see its horribly tacky and kitsch blue LED light.

Therefore, there’s only the power supply left. I’d like to get one which is not only quiet and green (energy wise), but is also modular, so that you only connect the SATA/IDE/power cables you really need, and don’t end up with a lot of unused cables hanging from the power supply. But that will probably wait until next year.

Software wise, I am looking into ways to underclock the system, since I don’t really use that much power generally. It seems that at least the graphics card clock and memory can be slowed down, but in my tests the settings I entered were reset to the default speed on each reboot, and besides, I couldn’t notice any difference, so I wonder if the settings really changed anything or not.

On the computer’s CPU front, it is currently set to “On demand”, and there’s a range of speeds I can choose, from 1.60 GHz to 2.4 GHz. I wonder if it could even work at lower speeds but still scale to higher when needed. I’ll have to look into that too :)

“Sorry, technical discussion”

It happened to me several times while at OFFF past week: I was in a conversation with people whom I had just met moments before and the conversation derived into “technical” matters, which is to say mild-core development topics like CSS or HTML5. And then someone looked at me with a mix of pity and embarrassment and excused himself and the others, shoulder-shrugging while muttering Sorry, technical discussion. Like if I couldn’t follow the thread and all that.

It was kind of amusing –because I could indeed follow it–, but it’s also very sad to assume that only because I’m female I can’t follow a “technical” discussion.

It’s also funny that “technical” means “traditionally male-dominated topics”, such as software development. But that is absurd: as any sane person will agree, if you want to excel at a field you have to master the technique, whatever your genre is.

Thus, CSS are as technical as knitting, which is a traditional female-only field, but yet you don’t get to look at the only male caught by accident in the middle of a knitting discussion by passionate female knitters and tell him Sorry, technical discussion. No, it’s more like: Oh dear, women’s things! *giggles*.

I say, stop perpetuating the stereotypes. Keep on talking about your preferred subjects and let your audience decide whether it’s too technical for them or not. But don’t make erroneous judgements, please :-)

More posts...