Bug 110551 - iwlwifi: dvm: cannot turn off wifi LED
Summary: iwlwifi: dvm: cannot turn off wifi LED
Status: CLOSED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: network-wireless (show other bugs)
Hardware: Intel Linux
: P1 normal
Assignee: DO NOT USE - assign "network-wireless-intel" component instead
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-08 21:56 UTC by Hubert Tarasiuk
Modified: 2016-01-25 07:43 UTC (History)
3 users (show)

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


Attachments
0001-iwlwifi-allow-led-turn-off-in-iwl-dvm-module.patch (965 bytes, text/x-patch)
2016-01-13 22:31 UTC, Hubert Tarasiuk
Details
0001-iwlwifi-allow-led-turn-off-in-iwl-dvm-module.patch (999 bytes, text/x-patch)
2016-01-13 22:33 UTC, Hubert Tarasiuk
Details
signature.asc (474 bytes, application/pgp-signature)
2016-01-13 22:33 UTC, Hubert Tarasiuk
Details
0001-iwlwifi-dvm-handle-zero-brightness-for-wifi-LED.patch (1.47 KB, text/x-patch)
2016-01-24 09:44 UTC, Hubert Tarasiuk
Details
signature.asc (474 bytes, application/pgp-signature)
2016-01-24 09:44 UTC, Hubert Tarasiuk
Details
0001-iwlwifi-dvm-handle-zero-brightness-for-wifi-LED.patch (1.47 KB, text/x-patch)
2016-01-24 10:07 UTC, Hubert Tarasiuk
Details
signature.asc (474 bytes, application/pgp-signature)
2016-01-24 10:07 UTC, Hubert Tarasiuk
Details
0001-iwlwifi-dvm-handle-zero-brightness-for-wifi-LED.patch (1.26 KB, text/x-patch)
2016-01-24 10:32 UTC, Hubert Tarasiuk
Details
signature.asc (474 bytes, application/pgp-signature)
2016-01-24 10:32 UTC, Hubert Tarasiuk
Details

Description Hubert Tarasiuk 2016-01-08 21:56:44 UTC
It is not possible to turn of the wifi indicator LED using sysfs or using module parameter.
The bug for sysfs can be resolved by the following patch. Handling 'led_mode=3' needs another simple patch in led.c:iwl_leds_init.

This is my first bug report for Linux kernel. Let me know if this is the wrong place or if you need any more information.



From 132afdea768bea0a5dc0f46417b261138b9b0286 Mon Sep 17 00:00:00 2001
From: Hubert Tarasiuk <hubert.tarasiuk@gmail.com>
Date: Mon, 4 Jan 2016 23:45:18 +0100
Subject: [PATCH] iwlwifi: allow led turn off in iwl dvm module

---
 drivers/net/wireless/iwlwifi/dvm/led.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/iwlwifi/dvm/led.c b/drivers/net/wireless/iwlwifi/dvm/led.c
index ca4d669..218617a 100644
--- a/drivers/net/wireless/iwlwifi/dvm/led.c
+++ b/drivers/net/wireless/iwlwifi/dvm/led.c
@@ -154,11 +154,14 @@ static void iwl_led_brightness_set(struct led_classdev *led_cdev,
 {
 	struct iwl_priv *priv = container_of(led_cdev, struct iwl_priv, led);
 	unsigned long on = 0;
+	unsigned long off = 0;
 
 	if (brightness > 0)
 		on = IWL_LED_SOLID;
+	else
+		off = IWL_LED_SOLID;
 
-	iwl_led_cmd(priv, on, 0);
+	iwl_led_cmd(priv, on, off);
 }
 
 static int iwl_led_blink_set(struct led_classdev *led_cdev,
-- 
2.6.4
Comment 1 Emmanuel Grumbach 2016-01-12 06:58:42 UTC
Your bug is fine, but I'd prefer if you'd send the patch :)

you can send it to me and CC linux-wireless@vger.kernel.org

thanks.
Comment 2 Hubert Tarasiuk 2016-01-13 22:31:31 UTC
Created attachment 199591 [details]
0001-iwlwifi-allow-led-turn-off-in-iwl-dvm-module.patch

Hi Emmanuel,

Actually to properly handle led_mode=3 option is not as easy as it seems.
Even if I initially turn of the LED in case of led_mode=3, it still gets
turned on after doing
# ifconfig wlan0 down && ifconfig wlan0 up

Maybe if I have more time later I can investigate further on how to avoid
this behaviour. (the LED trigger is set to none according to sysfs) Or you
have an idea on how to stop this behaviour?

Otherwise I would suggest that you apply the patch that I posted on
bugzilla (attached) that fixes sysfs handling. It is then easy to keep the
LED on or off as desired using simple shell scripts.

Thank you,
Hubert

On Tue, Jan 12, 2016 at 7:58 AM, <bugzilla-daemon@bugzilla.kernel.org>
 wrote:

> https://bugzilla.kernel.org/show_bug.cgi?id=110551
>
> --- Comment #1 from Emmanuel Grumbach <emmanuel.grumbach@intel.com> ---
> Your bug is fine, but I'd prefer if you'd send the patch :)
>
> you can send it to me and CC linux-wireless@vger.kernel.org
>
> thanks.
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.
> You reported the bug.
>
>
Comment 3 Hubert Tarasiuk 2016-01-13 22:33:51 UTC
Created attachment 199601 [details]
0001-iwlwifi-allow-led-turn-off-in-iwl-dvm-module.patch

Re-sending as plain-text.


--- Treść przekazanej wiadomości ---
Temat: 	[Bug 110551] iwlwifi: dvm: cannot turn off wifi LED
Data: 	Wed, 13 Jan 2016 23:31:28 +0100
Nadawca: 	Hubert Tarasiuk <hubert.tarasiuk@gmail.com>
Adresat: 	emmanuel.grumbach@intel.com
Kopia: 	linux-wireless@vger.kernel.org, bugzilla-daemon@bugzilla.kernel.org



Hi Emmanuel,

Actually to properly handle led_mode=3 option is not as easy as it seems.
Even if I initially turn of the LED in case of led_mode=3, it still gets
turned on after doing
# ifconfig wlan0 down && ifconfig wlan0 up

Maybe if I have more time later I can investigate further on how to
avoid this behaviour. (the LED trigger is set to none according to
sysfs) Or you have an idea on how to stop this behaviour?

Otherwise I would suggest that you apply the patch that I posted on
bugzilla (attached) that fixes sysfs handling. It is then easy to keep
the LED on or off as desired using simple shell scripts.

Thank you,
Hubert

On Tue, Jan 12, 2016 at 7:58 AM, <bugzilla-daemon@bugzilla.kernel.org
<mailto:bugzilla-daemon@bugzilla.kernel.org>>Â wrote:

    https://bugzilla.kernel.org/show_bug.cgi?id=110551

    --- Comment #1 from Emmanuel Grumbach <emmanuel.grumbach@intel.com
    <mailto:emmanuel.grumbach@intel.com>> ---
    Your bug is fine, but I'd prefer if you'd send the patch :)

    you can send it to me and CCÂ linux-wireless@vger.kernel.org
    <mailto:linux-wireless@vger.kernel.org>

    thanks.

    --
    You are receiving this mail because:
    You are on the CC list for the bug.
    You reported the bug.
Comment 4 Hubert Tarasiuk 2016-01-13 22:33:51 UTC
Created attachment 199611 [details]
signature.asc
Comment 5 Emmanuel Grumbach 2016-01-24 07:05:02 UTC
I can't apply your patch since it has no signed-off.
Comment 6 Hubert Tarasiuk 2016-01-24 09:44:56 UTC
Created attachment 201251 [details]
0001-iwlwifi-dvm-handle-zero-brightness-for-wifi-LED.patch

Attached is signed-off commit.

Also: can you provide some feedback with regard to led_mode=3 issue? I
am concerned about the expected behavior: does that option mean that the
driver does not handle the LED whatsoever, or does it mean that the LED
shall remain off at all times?

Here is from the param description:
> MODULE_PARM_DESC(led_mode, "0=system default, "
>                 "1=On(RF On)/Off(RF Off), 2=blinking, 3=Off (default: 0)");

For me the current behavior appears to be identical with the default
led_mode=0 and with led_mode=1 ie. the LED is on when the interface is
up, and off otherwise.

W dniu 24.01.2016 o 08:05, bugzilla-daemon@bugzilla.kernel.org pisze:
> https://bugzilla.kernel.org/show_bug.cgi?id=110551
> 
> Emmanuel Grumbach <emmanuel.grumbach@intel.com> changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>              Status|NEW                         |NEEDINFO
> 
> --- Comment #5 from Emmanuel Grumbach <emmanuel.grumbach@intel.com> ---
> I can't apply your patch since it has no signed-off.
>
Comment 7 Hubert Tarasiuk 2016-01-24 09:44:57 UTC
Created attachment 201261 [details]
signature.asc
Comment 8 Emmanuel Grumbach 2016-01-24 09:53:44 UTC
I doubt anybody really uses these modes.
I don't have the time to test the led_mode=3 state, but from the code it looks that this should do the trick:

diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/led.c b/drivers/net/wireless/intel/iwlwifi/dvm/led.c
index 1aabb5e..b65d7c4 100644
--- a/drivers/net/wireless/intel/iwlwifi/dvm/led.c
+++ b/drivers/net/wireless/intel/iwlwifi/dvm/led.c
@@ -200,6 +200,8 @@ void iwl_leds_init(struct iwl_priv *priv)
                priv->led.default_trigger =
                        ieee80211_get_radio_led_name(priv->hw);
                break;
+       case IWL_LED_DISABLE:
+               return 0;
        }
 
        ret = led_classdev_register(priv->trans->dev, &priv->led);
Comment 9 Emmanuel Grumbach 2016-01-24 09:54:04 UTC
Want to test and send a combined patch?
Comment 10 Hubert Tarasiuk 2016-01-24 10:07:38 UTC
Created attachment 201271 [details]
0001-iwlwifi-dvm-handle-zero-brightness-for-wifi-LED.patch

Actually I sent you the wrong patch (with a failed attempt to fix the
led_mode issue). Attached is just the fix for sysfs.

> I doubt anybody really uses these modes.
> I don't have the time to test the led_mode=3 state, but from the code it
> looks
> that this should do the trick:

This is already done at the very beginning of the init function:
>       if (mode == IWL_LED_DISABLE) {
>               IWL_INFO(priv, "Led disabled\n");
>               return;
>       }
But it does not work as expected.

Since hardly anyone uses it I suggest that you apply the easy patch for
sysfs at this time (which is sufficient for me as well).

If I feel like digging in the code I might try to fix the led_mode the
other day (but I fear that this might need some Intel-confidential
hardware/firmware specs to figure out - since it currently works
'automagically' even when iwl_leds_init does not set any triggers and
returns immediately).

W dniu 24.01.2016 o 10:54, bugzilla-daemon@bugzilla.kernel.org pisze:
> https://bugzilla.kernel.org/show_bug.cgi?id=110551
> 
> --- Comment #9 from Emmanuel Grumbach <emmanuel.grumbach@intel.com> ---
> Want to test and send a combined patch?
>
Comment 11 Hubert Tarasiuk 2016-01-24 10:07:39 UTC
Created attachment 201281 [details]
signature.asc
Comment 12 Emmanuel Grumbach 2016-01-24 10:15:35 UTC
> 
> This is already done at the very beginning of the init function:
> >     if (mode == IWL_LED_DISABLE) {
> >             IWL_INFO(priv, "Led disabled\n");
> >             return;
> >     }
> But it does not work as expected.

Ah right :)

> 
> Since hardly anyone uses it I suggest that you apply the easy patch for
> sysfs at this time (which is sufficient for me as well).
> 
> If I feel like digging in the code I might try to fix the led_mode the
> other day (but I fear that this might need some Intel-confidential
> hardware/firmware specs to figure out - since it currently works
> 'automagically' even when iwl_leds_init does not set any triggers and
> returns immediately).

I wouldn't be able to find these docs myself :)
Comment 13 Emmanuel Grumbach 2016-01-24 10:16:51 UTC
https://bugzilla.kernel.org/attachment.cgi?id=201271

This one seems to have a fix for the module param as well.
I would much prefer you to send the patch to the wireless mailing list rather than attaching it to this bugzilla.
Comment 14 Hubert Tarasiuk 2016-01-24 10:32:33 UTC
Created attachment 201291 [details]
0001-iwlwifi-dvm-handle-zero-brightness-for-wifi-LED.patch

Attached is the patch for bug 110551.

W dniu 24.01.2016 o 11:16, bugzilla-daemon@bugzilla.kernel.org pisze:
> https://bugzilla.kernel.org/show_bug.cgi?id=110551
> 
> --- Comment #13 from Emmanuel Grumbach <emmanuel.grumbach@intel.com> ---
> https://bugzilla.kernel.org/attachment.cgi?id=201271
> 
> This one seems to have a fix for the module param as well.
> I would much prefer you to send the patch to the wireless mailing list rather
> than attaching it to this bugzilla.
>
Comment 15 Hubert Tarasiuk 2016-01-24 10:32:33 UTC
Created attachment 201301 [details]
signature.asc
Comment 16 Emmanuel Grumbach 2016-01-24 20:21:30 UTC
I applied the patch in our internal repository.
Comment 17 Hubert Tarasiuk 2016-01-25 07:43:58 UTC
Thank you, appreciate it.

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