Bug 12637 - eeepc_laptop module ignores eeepc wifi bios status on 701
Summary: eeepc_laptop module ignores eeepc wifi bios status on 701
Status: RESOLVED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: Input Devices (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: drivers_input-devices
URL:
Keywords:
: 12638 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-02-06 02:07 UTC by Davide Rao
Modified: 2009-04-05 20:18 UTC (History)
6 users (show)

See Also:
Kernel Version: 2.8.28.2
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Davide Rao 2009-02-06 02:07:42 UTC
Latest working kernel version:none (not avalible prior to 2.6.28 without external sources)
Earliest failing kernel version:2.6.28
Distribution:Slackware 12.1
Hardware Environment:Asus eeepc 701
Software Environment:gcc (GCC) 4.2.3, glibc-2.7-i486-10
Problem Description: on the eeepc 701 when eeepc_laptop module loaded the eeepc wifi (ath5k) device gets turned on regardles whether bios says it should be off.

Steps to reproduce:Turn wifi off from bios. compile kernel with eeepc_laptop as module (and dependencies .... ath5k module is not necessary for reproducing the problem) boot kernel and go see the status of the device from /sys/class/rfkill/rfkill<x>/state (where x is most likely 0) ... you might also notice that the blue led is on anyway without looking in /sys.
Comment 1 Alexey Dobriyan 2009-02-06 11:12:20 UTC
*** Bug 12638 has been marked as a duplicate of this bug. ***
Comment 2 Davide Rao 2009-02-13 00:10:58 UTC
Can someone alt least tell me hot to make the module behavior so that wifi is always NOT TURNED ON on module loading ... or a module parameter that would do the same thing ?

It seems a really stupid thing to have to give extra intelligence to toggle script so that it can detect whether the wifi is on because of a kernel bug .... or even worse change the rc scripts so that they turn off wifi after loading eeepc-laptop module.

I also see that there has been some eeepc-laptop module work in the current kernel changelog .... but nothing directly relevant to this bug.
Comment 3 Matthew Garrett 2009-02-13 04:01:46 UTC
c9ddf8fede1271bde0a512fa94f77c4cb1ef4040

    Error out if rfkill registration fails, and also set the default system state
    appropriately on boot
Comment 4 Davide Rao 2009-02-13 07:23:47 UTC
c9ddf8fede1271bde0a512fa94f77c4cb1ef4040 ... git ? (sorry for my ignorance)
Comment 5 Nicolas Bigaouette 2009-02-13 07:29:00 UTC
Yes :)
http://patchwork.kernel.org/patch/5997/
http://groups.google.com/group/linux.kernel/msg/3a59c38d527ce01e
You could try it to see if its working.
Comment 6 Davide Rao 2009-02-16 02:57:07 UTC
Applied patch: http://patchwork.kernel.org/patch/5997/

Seems to work ... device is off at boot and gets turned on when I press the Fn+F2 button.
Have not checked if it gets turned on on boot when bios says it should be on ... but even if it did non it would not be so disturming as having it on when bios says it should be off.

Once loaded the ath5k module .... any subsequent unload and reload still gives :
Failed to wakeup MAc Chip

But this may be irrelevant to eeepc_laptop.
Comment 7 Davide Rao 2009-02-18 10:58:40 UTC
Just incase anyone is intrested:
I found out that ther is better chance of being able to turn of and on again the ath5k if the toggle script does not remove the hotplug modules .
...
...
case $STATUS in
  1)
    [ $(ps -e |grep -c "dhcpcd") -ge 1 ] && dhcpcd -k ath0
    ifconfig ath0 down
    [ $(ps -e |grep -c "wpa_supplicant") -ge 1 ] && killall wpa_supplicant
    sleep 0.2
    rmmod ath5k
    sleep 0.2
    rmmod mac80211
    sleep 0.2
#    rmmod pciehp
#    sleep 0.2
#    rmmod pci_hotplug
#    sleep 0.2
    [ -f $CTLF ] && echo 0 > $CTLF
  ;;
...
...
Comment 8 Bob Copeland 2009-04-01 14:16:35 UTC
It's because eeepc does rfkill by disconnecting the pci-e bus, so as far as ath5k knows, the device is *gone*.
Comment 9 Davide Rao 2009-04-02 16:47:55 UTC
Well if you notice I'm doing the rfkill stuff after having remover ath5k module ... not sit if what you claim is applicable.
I'm also removing the hotplug modules and reloading them before reinsertion (trough rfkill) ... so the hotplug stuff should not even know about the ath5k being previously turned off .... but Murphy is allways around.

Anyway I've been having good success by skipping the hotplug removal so actually as far as what has been discussed so far this bug can be closed.
Comment 10 Bob Copeland 2009-04-02 18:46:31 UTC
Ok, not seeing your whole script I can't say, was just pointing out that if you do things in the wrong order, e.g. load ath5k before the rfkill adds the device back, then ath5k will find no device and won't work.  At present ath5k doesn't register with the rfkill subsystem, but it should.
Comment 11 Davide Rao 2009-04-03 08:24:45 UTC
Did you look at the fragment of the script above ?
I'll strip conditional test to make it an easier read:
    dhcpcd -k ath0
    ifconfig ath0 down
    killall wpa_supplicant
    sleep 0.2
    rmmod ath5k
    sleep 0.2
    rmmod mac80211
    sleep 0.2
#    rmmod pciehp
#    sleep 0.2
#    rmmod pci_hotplug
#    sleep 0.2
    echo 0 > $CTLF #write "0" into the rfkill interface in /sys

$CTLF contains the rfkill sys path to the ath5k device.
What do you mean by: "At present ath5k doesn't
register with the rfkill subsystem, but it should." ?

I can insert and remove the device from the rfkill interface (since at least 2.6.28.5)
Comment 12 Bob Copeland 2009-04-03 12:04:41 UTC
Yes, but you didn't post the 'unkill' part.
Comment 13 Davide Rao 2009-04-05 07:36:58 UTC
As of 2.6.29 apparently the initial issue has been fixed as it's no longer necessary to apply any patches in order to avoid wlan getting turned on with the eeepc_laptop module.

Regarding the toggle script I'm using ... this version has been modified to attempt a workaround for some other troubles with ath5k driver and can correctly turn on and off several times the wifi:

#!/bin/sh
CTLF=/proc/acpi/asus/wlan

if [ -f $CTLF ]
then
  STATUS=$(cat $CTLF)
else
  if [ -e /sys/class/rfkill ]
  then
    for RFKD in $(ls /sys/class/rfkill)
    do
      [ "$(cat /sys/class/rfkill/${RFKD}/name)" = "eeepc-wlan" ] && \
        CTLF=/sys/class/rfkill/${RFKD}/state
    done
    STATUS=$(cat $CTLF)
  else
    STATUS=$(iwconfig 2>&1 |grep -c ath0)
  fi
fi

case $STATUS in
  1) #then it's time to turn off onboard wifi 
    [ $(ps -ef |grep -v grep |grep -c "dhcpcd  *ath0") -ge 1 ] && dhcpcd -k ath0
    ifconfig ath0 down
    [ $(ps -e |grep -c "wpa_supplicant") -ge 1 ] && killall wpa_supplicant && sl
eep 0.2
    rmmod ath5k && sleep 0.2
    rmmod mac80211 && sleep 0.2
    [ -f $CTLF ] && echo 0 > $CTLF
  ;;

  0) #then it's time to turn on onboard wifi 
    [ $(ps -ef |grep -v grep |grep -c "dhcpcd  *ath0") -ge 1 ] && dhcpcd -k ath0
    [ $(ps -e |grep -c "wpa_supplicant") -ge 1 ] && killall wpa_supplicant
    [ $(lsmod |grep -c "^ath5k") -ge 1 ] && rmmod ath5k 
    [ $(lsmod |grep -c pciehp) -eq 0 ] && modprobe pciehp pciehp_force=1 && slee
p 0.2
    [ -f $CTLF ] && echo 1 > $CTLF && sleep 0.2
    modprobe ath5k && sleep 1
    rmmod ath5k && sleep 0.2
    modprobe ath5k && sleep 1 
    ifconfig ath0 down
    wpa_supplicant -B -W -Dwext -iath0 -c/etc/wpa_supplicant.conf
    ifconfig ath0 up
  ;;
 
esac


I'm closing the bug because the initial problems has been fixed since 2.6.29 ... 

Thanks to all that contributed.
Comment 14 Davide Rao 2009-04-05 20:18:56 UTC
I made more changes to the script:
  0) #then it's time to turn on onboard wifi 
    [ $(ps -ef |grep -v grep |grep -c "dhcpcd  *ath0") -ge 1 ] && dhcpcd -k ath0
    [ $(ps -e |grep -c "wpa_supplicant") -ge 1 ] && killall wpa_supplicant
    [ $(lsmod |grep -c "^ath5k") -ge 1 ] && rmmod ath5k 
    [ $(lsmod |grep -c pciehp) -eq 0 ] && modprobe pciehp pciehp_force=1 && sleep 0.2
    [ -f $CTLF ] && echo 1 > $CTLF && sleep 0.2
    modprobe ath5k && sleep 0.2
    ifconfig ath0 down && sleep 0.2
    rmmod ath5k && sleep 0.2
    modprobe ath5k && sleep 3 
    ifconfig ath0 down && sleep 0.2
    wpa_supplicant -B -W -Dwext -iath0 -c/etc/wpa_supplicant.conf && sleep 0.2 
    ifconfig ath0 up
  ;;

Note You need to log in before you can comment on or make changes to this bug.