rfkill hard state after booting
Subsystems (2)
Hi all,
(please cc)
I recently (on a flight) I found out that when I boot with the hard-switch activated, so turning off all wireless activity on my laptop, the state is not correctly announced in /dev/rfkill (reading it with rfkill command, or my own gnome applet). All the devices seem to be in normal state but one.
Here some outputs:
$ cd /sys/class/rfkill $ ls rfkill0@ rfkill1@ rfkill2@ rfkill3@ rfkill4@ rfkill5@ $ cat rfkill?/name sony-wifi sony-bluetooth sony-wwan hso-0 hci0 phy0 $
and the three sony-* are the ones for actually turning on/off the devices, but they showed all soft 0 hard 0 at initial startup. Only phy0 (AFAIR) had hard 1.
After turning off and on again the hard-switch the events were right.
That is all with 2.6.31.
driver iwlagn, Detected Intel Wireless WiFi Link 5100AGN REV=0x54
Best wishes
Norbert
-------------------------------------------------------------------------------
Dr. Norbert Preining <[email protected]> Vienna University of Technology
Debian Developer <[email protected]> Debian TeX Group
gpg DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
LIMERIGG (vb.)
To jar one's leg as the result of the disappearance of a stair which isn't there in the darkness.
--- Douglas Adams, The Meaning of Liff
Quoted 5 lines · Norbert Preining
I recently (on a flight) I found out that when I boot with the hard-switch activated, so turning off all wireless activity on my laptop, the state is not correctly announced in
/dev/rfkill(reading it with rfkill command, or my own gnome applet). All the devices seem to be in normal state but one.
Very strange.
Quoted 13 lines
Here some outputs:
$ cd /sys/class/rfkill $ ls rfkill0@ rfkill1@ rfkill2@ rfkill3@ rfkill4@ rfkill5@ $ cat rfkill?/name sony-wifi sony-bluetooth sony-wwan hso-0 hci0 phy0 $
Quoted 3 lines
and the three sony-* are the ones for actually turning on/off the devices, but they showed all soft 0 hard 0 at initial startup. Only phy0 (AFAIR) had hard 1.
Makes sense. I mean, that phy0 was hard blocked.
Quoted 1 line
After turning off and on again the hard-switch the events were right.
I can't decide where this bug is. I suspect it's in the sony code. Anyone feel responsible for that code?
johannes
Quoted 34 lines · Johannes Berg
Quoted 6 lines · Norbert Preining
I recently (on a flight) I found out that when I boot with the hard-switch activated, so turning off all wireless activity on my laptop, the state is not correctly announced in
/dev/rfkill(reading it with rfkill command, or my own gnome applet). All the devices seem to be in normal state but one.Very strange.
Quoted 13 lines
Here some outputs:
$ cd /sys/class/rfkill $ ls rfkill0@ rfkill1@ rfkill2@ rfkill3@ rfkill4@ rfkill5@ $ cat rfkill?/name sony-wifi sony-bluetooth sony-wwan hso-0 hci0 phy0 $Quoted 4 lines
and the three sony-* are the ones for actually turning on/off the devices, but they showed all soft 0 hard 0 at initial startup. Only phy0 (AFAIR) had hard 1.
Makes sense. I mean, that phy0 was hard blocked.
Quoted 8 lines
Quoted 2 lines
After turning off and on again the hard-switch the events were right.
I can't decide where this bug is. I suspect it's in the sony code. Anyone feel responsible for that code?
johannes
I think it's pretty clear it's in the sony code. It doesn't call set_hw_state() during init. I.e. (completely untested):
drivers/platform/x86/sony-laptop.c +6 -0
@@ -1081,6 +1081,8 @@ static int sony_nc_setup_rfkill(struct acpi_device *device,struct rfkill *rfk;enum rfkill_type type;const char *name; +int result; +bool hwblock;switch (nc_type) {case SONY_WIFI :
@@ -1108,6 +1110,10 @@ static int sony_nc_setup_rfkill(struct acpi_device *device,if (!rfk)return -ENOMEM ; +sony_call_snc_handle (0x124 ,0x200 , &result); + hwblock = !(result &0x1 ); +rfkill_set_hw_state (rfk, hwblock); + err =rfkill_register (rfk);if (err) {rfkill_destroy (rfk);
Quoted 2 lines · Alan Jenkins
I think it's pretty clear it's in the sony code. It doesn't call
set_hw_state()during init. I.e. (completely untested):
Agree, looking at the code this seems reasonable.
Although maybe it should just call sony_nc_rfkill_update() after registering all of them?
johannes
Quoted 7 lines · Johannes Berg
Quoted 3 lines · Alan Jenkins
I think it's pretty clear it's in the sony code. It doesn't call
set_hw_state()during init. I.e. (completely untested):
Quoted 7 lines
Agree, looking at the code this seems reasonable.
Although maybe it should just call
sony_nc_rfkill_update()after registering all of them?johannes
That means the initial "add" uevents etc. will contain wrong values (and then be updated immediately after). Do we care about that? It's unlikely to matter in practice for platform devices which only get loaded at boot-time, but perhaps it would set a bad example.
Regards
Alan
Quoted 7 lines · Alan Jenkins
Quoted 2 lines
Although maybe it should just call
sony_nc_rfkill_update()after registering all of them?That means the initial "add" uevents etc. will contain wrong values (and then be updated immediately after). Do we care about that? It's unlikely to matter in practice for platform devices which only get loaded at boot-time, but perhaps it would set a bad example.
Ah, good point. I was just a little concerned about the logic difference, but I don't really understand the _update() logic.
johannes
PATCH 1/1 sony-laptop: check for rfkill hard block at load time
"I recently (on a flight) I found out that when I boot with the hard-switch activated, so turning off all wireless activity on my laptop, the state is not correctly announced in /dev/rfkill (reading it with rfkill command, or my own gnome applet)...
After turning off and on again the hard-switch the events were right."
We can fix this by querying the firmware at load time and calling rfkill_set_hw_state().
--- drivers/platform/x86/sony-laptop.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/platform/x86/sony-laptop.c +6 -0
@@ -1081,6 +1081,8 @@ static int sony_nc_setup_rfkill(struct acpi_device *device,struct rfkill *rfk;enum rfkill_type type;const char *name; +int result; +bool hwblock;switch (nc_type) {case SONY_WIFI :
@@ -1108,6 +1110,10 @@ static int sony_nc_setup_rfkill(struct acpi_device *device,if (!rfk)return -ENOMEM ; +sony_call_snc_handle (0x124 ,0x200 , &result); + hwblock = !(result &0x1 ); +rfkill_set_hw_state (rfk, hwblock); + err =rfkill_register (rfk);if (err) {rfkill_destroy (rfk);
Signature · 1 line
1.6.3.2
Re: [PATCH] sony-laptop: check for rfkill hard block at load time
Quoted 30 lines · Alan Jenkins
"I recently (on a flight) I found out that when I boot with the hard-switch activated, so turning off all wireless activity on my laptop, the state is not correctly announced in
/dev/rfkill(reading it with rfkill command, or my own gnome applet)...After turning off and on again the hard-switch the events were right."
We can fix this by querying the firmware at load time and calling
rfkill_set_hw_state().Signed-off-by Alan Jenkins <[email protected]>Tested-by Norbert Preining <[email protected]>---
drivers/platform/x86/sony-laptop.c | 6 ++++++1 files changed, 6 insertions(+), 0 deletions(-)drivers/platform/x86/sony-laptop.c +2
-0@@ -1081,6 +1081,8 @@ static int sony_nc_setup_rfkill(struct acpi_device *device, struct rfkill *rfk; enum rfkill_type type; const char *name; + int result; + bool hwblock; switch (nc_type) {case
SONY_WIFI:
drivers/platform/x86/sony-laptop.c static int sony_nc_setup_rfkill(struct acpi_device *device, · line 1113
Quoted 4 lines
drivers/platform/x86/sony-laptop.c +1
-0@@ -1108,6 +1110,10 @@ static int sony_nc_setup_rfkill(struct acpi_device *device, if (!rfk) return -ENOMEM; + sony_call_snc_handle(0x124, 0x200, &result);
Please define these somewhere, don't use magic numbers.
Quoted 16 lines
drivers/platform/x86/sony-laptop.c +3
-1+ hwblock = !(result & 0x1); + rfkill_set_hw_state(rfk, hwblock); + err = rfkill_register(rfk); if (err) { rfkill_destroy(rfk); --1.6.3.2
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Vista: [V]iruses, [I]ntruders, [S]pyware, [T]rojans and [A]dware. :-)
Re: [PATCH] sony-laptop: check for rfkill hard block at load time
Quoted 36 lines · Gábor Stefanik
Quoted 33 lines · Alan Jenkins
"I recently (on a flight) I found out that when I boot with the hard-switch activated, so turning off all wireless activity on my laptop, the state is not correctly announced in
/dev/rfkill(reading it with rfkill command, or my own gnome applet)...After turning off and on again the hard-switch the events were right."
We can fix this by querying the firmware at load time and calling
rfkill_set_hw_state().Signed-off-by Alan Jenkins <[email protected]>Tested-by Norbert Preining <[email protected]>--- drivers/platform/x86/sony-laptop.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)drivers/platform/x86/sony-laptop.c +2
-0@@ -1081,6 +1081,8 @@ static int sony_nc_setup_rfkill(struct acpi_device *device,struct rfkill *rfk;enum rfkill_type type;const char *name; +int result; +bool hwblock;switch (nc_type) {case SONY_WIFI :@@ -1108,6 +1110,10 @@ static int sony_nc_setup_rfkill(struct acpi_device *device,if (!rfk)return -ENOMEM ;
Quoted 5 lines
drivers/platform/x86/sony-laptop.c static int sony_nc_setup_rfkill(struct acpi_device *device, · line 1114
Quoted 2 lines
drivers/platform/x86/sony-laptop.c +1
-0+sony_call_snc_handle (0x124 ,0x200 , &result);Please define these somewhere, don't use magic numbers.
The rfkill functions are all together in the file, it's not that bad. But ok.
There's another bug / missing feature - it doesn't re-read the hard states on resume from suspend.
I'll submit two more patches then. I won't convert all of the magic numbers though. This isn't hardware I know anything about, and "magic numbers" is a good description of some of them -
/* Setup hotkeys */
sony_call_snc_handle(0x0100, 0, &result);
sony_call_snc_handle(0x0101, 0, &result);
sony_call_snc_handle(0x0102, 0x100, &result);
sony_call_snc_handle(0x0127, 0, &result);Others are already sufficiently obvious, and the extra indirection would only serve to obscure
/* Enable all events */
acpi_callsetfunc(sony_nc_acpi_handle, "SN02", 0xffff, &result);Mattia Dongili
maintainerRe: [PATCH] sony-laptop: check for rfkill hard block at load time
Quoted 4 lines · Alan Jenkins
Quoted 3 lines · Gábor Stefanik
On Thu, Sep 24, 2009 at 9:15 PM, Alan Jenkins
<[email protected]> wrote:
...
Quoted 13 lines
Quoted 9 lines
drivers/platform/x86/sony-laptop.c static int sony_nc_setup_rfkill(struct acpi_device *device, · line 1114
Quoted 6 lines
drivers/platform/x86/sony-laptop.c +1
-0@@ -1108,6 +1110,10 @@ static int sony_nc_setup_rfkill(struct acpi_device *device,if (!rfk)return -ENOMEM ; +sony_call_snc_handle (0x124 ,0x200 , &result);Please define these somewhere, don't use magic numbers.
The rfkill functions are all together in the file, it's not that bad. But ok.
Quoted 6 lines
There's another bug / missing feature - it doesn't re-read the hard states on resume from suspend.
I'll submit two more patches then. I won't convert all of the magic numbers though. This isn't hardware I know anything about, and "magic numbers" is a good description of some of them -
right and the whole purpose of them is to hit specific code paths in the DSDT tables. Not sure we would benefit that much from having names for them.
Signature · 2 lines
mattia :wq!
Re: [PATCH] sony-laptop: check for rfkill hard block at load time
In reply to Alan JenkinsQuoted 5 lines · Alan Jenkins
"I recently (on a flight) I found out that when I boot with the hard-switch activated, so turning off all wireless activity on my laptop, the state is not correctly announced in
/dev/rfkill(reading it with rfkill command, or my own gnome applet)...
Quoted 7 lines
After turning off and on again the hard-switch the events were right."
We can fix this by querying the firmware at load time and calling
rfkill_set_hw_state().Signed-off-by Alan Jenkins <[email protected]>Tested-by Norbert Preining <[email protected]>
Looks good, thanks Alan.
Quoted 28 lines
--- drivers/platform/x86/sony-laptop.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)drivers/platform/x86/sony-laptop.c +6
-0@@ -1081,6 +1081,8 @@ static int sony_nc_setup_rfkill(struct acpi_device *device,struct rfkill *rfk;enum rfkill_type type;const char *name; +int result; +bool hwblock;switch (nc_type) {case SONY_WIFI :@@ -1108,6 +1110,10 @@ static int sony_nc_setup_rfkill(struct acpi_device *device,if (!rfk)return -ENOMEM ; +sony_call_snc_handle (0x124 ,0x200 , &result); + hwblock = !(result &0x1 ); +rfkill_set_hw_state (rfk, hwblock); + err =rfkill_register (rfk);if (err) {rfkill_destroy (rfk);
Re: [PATCH] sony-laptop: check for rfkill hard block at load time
In reply to Alan JenkinsQuoted 9 lines · Alan Jenkins
"I recently (on a flight) I found out that when I boot with the hard-switch activated, so turning off all wireless activity on my laptop, the state is not correctly announced in
/dev/rfkill(reading it with rfkill command, or my own gnome applet)...After turning off and on again the hard-switch the events were right."
We can fix this by querying the firmware at load time and calling
rfkill_set_hw_state().
Is it worth trying to get this into a stable release?
Quoted 2 lines
Signed-off-by Alan Jenkins <[email protected]>Tested-by Norbert Preining <[email protected]>
Quoted 33 lines
--- drivers/platform/x86/sony-laptop.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)drivers/platform/x86/sony-laptop.c +6
-0@@ -1081,6 +1081,8 @@ static int sony_nc_setup_rfkill(struct acpi_device *device,struct rfkill *rfk;enum rfkill_type type;const char *name; +int result; +bool hwblock;switch (nc_type) {case SONY_WIFI :@@ -1108,6 +1110,10 @@ static int sony_nc_setup_rfkill(struct acpi_device *device,if (!rfk)return -ENOMEM ; +sony_call_snc_handle (0x124 ,0x200 , &result); + hwblock = !(result &0x1 ); +rfkill_set_hw_state (rfk, hwblock); + err =rfkill_register (rfk);if (err) {rfkill_destroy (rfk);Signature · 1 line
1.6.3.2
Signature · 2 lines
mattia :wq!
Re: [PATCH] sony-laptop: check for rfkill hard block at load time
Quoted 7 lines · Mattia Dongili
Quoted 5 lines · Alan Jenkins
"I recently (on a flight) I found out that when I boot with the hard-switch activated, so turning off all wireless activity on my laptop, the state is not correctly announced in
/dev/rfkill(reading it with rfkill command, or my own gnome applet)...
Quoted 8 lines
Quoted 5 lines
After turning off and on again the hard-switch the events were right."
We can fix this by querying the firmware at load time and calling
rfkill_set_hw_state().Is it worth trying to get this into a stable release?
Sure. It seems to fit, and all we have to do is add a CC to the patch
Quoted 6 lines
Quoted 3 lines
Signed-off-by Alan Jenkins <[email protected]>Tested-by Norbert Preining <[email protected]>Acked-by Mattia Dongili <[email protected]>
Quoted 35 lines
Quoted 35 lines
--- drivers/platform/x86/sony-laptop.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)drivers/platform/x86/sony-laptop.c +6
-0@@ -1081,6 +1081,8 @@ static int sony_nc_setup_rfkill(struct acpi_device *device,struct rfkill *rfk;enum rfkill_type type;const char *name; +int result; +bool hwblock;switch (nc_type) {case SONY_WIFI :@@ -1108,6 +1110,10 @@ static int sony_nc_setup_rfkill(struct acpi_device *device,if (!rfk)return -ENOMEM ; +sony_call_snc_handle (0x124 ,0x200 , &result); + hwblock = !(result &0x1 ); +rfkill_set_hw_state (rfk, hwblock); + err =rfkill_register (rfk);if (err) {rfkill_destroy (rfk);Signature · 1 line
1.6.3.2
drivers/platform/x86/sony-laptop.c static int sony_nc_setup_rfkill(struct acpi_device *device, · line 1116
Quoted 4 lines · Alan Jenkins
drivers/platform/x86/sony-laptop.c +4
-0+sony_call_snc_handle (0x124 ,0x200 , &result); + hwblock = !(result &0x1 ); +rfkill_set_hw_state (rfk, hwblock); +
I confirm that the (full) patch fixed that problem. Thanks!
Best wishes
Norbert
-------------------------------------------------------------------------------
Dr. Norbert Preining <[email protected]> Vienna University of Technology
Debian Developer <[email protected]> Debian TeX Group
gpg DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
GOLANT (adj.)
Blank, sly and faintly embarrassed. Pertaining to the expression seen on the face of someone who has clearly forgotten your name.
--- Douglas Adams, The Meaning of Liff