Commit 0eee6127 authored by Tomas Winkler's avatar Tomas Winkler Committed by John W. Linville

iwlwifi: fix LED stall

This patch fixes LED stall. last_blink_time was updated only if LED command
was sent, causing wrong computation of the througput.
Some code cleanup comes with this patch as well
Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarZhu Yi <yi.zhu@intel.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 9f17b318
...@@ -933,7 +933,7 @@ struct iwl_priv { ...@@ -933,7 +933,7 @@ struct iwl_priv {
#endif #endif
#ifdef CONFIG_IWLWIFI_LEDS #ifdef CONFIG_IWLWIFI_LEDS
struct iwl4965_led led[IWL_LED_TRG_MAX]; struct iwl_led led[IWL_LED_TRG_MAX];
unsigned long last_blink_time; unsigned long last_blink_time;
u8 last_blink_rate; u8 last_blink_rate;
u8 allow_blinking; u8 allow_blinking;
......
...@@ -48,10 +48,21 @@ ...@@ -48,10 +48,21 @@
#define IWL_LED_THRESHOLD (16) #define IWL_LED_THRESHOLD (16)
#define IWL_MAX_BLINK_TBL (10) #define IWL_MAX_BLINK_TBL (10)
#ifdef CONFIG_IWLWIFI_DEBUG
static const char *led_type_str[] = {
__stringify(IWL_LED_TRG_TX),
__stringify(IWL_LED_TRG_RX),
__stringify(IWL_LED_TRG_ASSOC),
__stringify(IWL_LED_TRG_RADIO),
NULL
};
#endif /* CONFIG_IWLWIFI_DEBUG */
static const struct { static const struct {
u16 tpt; u16 tpt;
u8 on_time; u8 on_time;
u8 of_time; u8 off_time;
} blink_tbl[] = } blink_tbl[] =
{ {
{300, 25, 25}, {300, 25, 25},
...@@ -155,21 +166,6 @@ static int iwl4965_led_off_reg(struct iwl_priv *priv, int led_id) ...@@ -155,21 +166,6 @@ static int iwl4965_led_off_reg(struct iwl_priv *priv, int led_id)
return 0; return 0;
} }
/* Set led blink command */
static int iwl4965_led_not_solid(struct iwl_priv *priv, int led_id,
u8 brightness)
{
struct iwl4965_led_cmd led_cmd = {
.id = led_id,
.on = brightness,
.off = brightness,
.interval = IWL_DEF_LED_INTRVL
};
return iwl_send_led_cmd(priv, &led_cmd);
}
/* /*
* brightness call back function for Tx/Rx LED * brightness call back function for Tx/Rx LED
*/ */
...@@ -189,16 +185,18 @@ static int iwl4965_led_associated(struct iwl_priv *priv, int led_id) ...@@ -189,16 +185,18 @@ static int iwl4965_led_associated(struct iwl_priv *priv, int led_id)
/* /*
* brightness call back for association and radio * brightness call back for association and radio
*/ */
static void iwl4965_led_brightness_set(struct led_classdev *led_cdev, static void iwl_led_brightness_set(struct led_classdev *led_cdev,
enum led_brightness brightness) enum led_brightness brightness)
{ {
struct iwl4965_led *led = container_of(led_cdev, struct iwl_led *led = container_of(led_cdev, struct iwl_led, led_dev);
struct iwl4965_led, led_dev);
struct iwl_priv *priv = led->priv; struct iwl_priv *priv = led->priv;
if (test_bit(STATUS_EXIT_PENDING, &priv->status)) if (test_bit(STATUS_EXIT_PENDING, &priv->status))
return; return;
IWL_DEBUG_LED("Led type = %s brightness = %d\n",
led_type_str[led->type], brightness);
switch (brightness) { switch (brightness) {
case LED_FULL: case LED_FULL:
if (led->type == IWL_LED_TRG_ASSOC) if (led->type == IWL_LED_TRG_ASSOC)
...@@ -226,8 +224,7 @@ static void iwl4965_led_brightness_set(struct led_classdev *led_cdev, ...@@ -226,8 +224,7 @@ static void iwl4965_led_brightness_set(struct led_classdev *led_cdev,
/* /*
* Register led class with the system * Register led class with the system
*/ */
static int iwl_leds_register_led(struct iwl_priv *priv, static int iwl_leds_register_led(struct iwl_priv *priv, struct iwl_led *led,
struct iwl4965_led *led,
enum led_type type, u8 set_led, enum led_type type, u8 set_led,
const char *name, char *trigger) const char *name, char *trigger)
{ {
...@@ -235,7 +232,7 @@ static int iwl_leds_register_led(struct iwl_priv *priv, ...@@ -235,7 +232,7 @@ static int iwl_leds_register_led(struct iwl_priv *priv,
int ret; int ret;
led->led_dev.name = name; led->led_dev.name = name;
led->led_dev.brightness_set = iwl4965_led_brightness_set; led->led_dev.brightness_set = iwl_led_brightness_set;
led->led_dev.default_trigger = trigger; led->led_dev.default_trigger = trigger;
led->priv = priv; led->priv = priv;
...@@ -263,12 +260,14 @@ static inline u8 get_blink_rate(struct iwl_priv *priv) ...@@ -263,12 +260,14 @@ static inline u8 get_blink_rate(struct iwl_priv *priv)
{ {
int i; int i;
u8 blink_rate; u8 blink_rate;
u64 current_tpt = priv->tx_stats[2].bytes + priv->rx_stats[2].bytes; u64 current_tpt = priv->tx_stats[2].bytes;
/* FIXME: + priv->rx_stats[2].bytes; */
s64 tpt = current_tpt - priv->led_tpt; s64 tpt = current_tpt - priv->led_tpt;
if (tpt < 0) /* wrapparound */ if (tpt < 0) /* wrapparound */
tpt = -tpt; tpt = -tpt;
IWL_DEBUG_LED("tpt %lld current_tpt %lld\n", tpt, current_tpt);
priv->led_tpt = current_tpt; priv->led_tpt = current_tpt;
if (tpt < IWL_LED_THRESHOLD) { if (tpt < IWL_LED_THRESHOLD) {
...@@ -329,15 +328,13 @@ void iwl_leds_background(struct iwl_priv *priv) ...@@ -329,15 +328,13 @@ void iwl_leds_background(struct iwl_priv *priv)
/* call only if blink rate change */ /* call only if blink rate change */
if (blink_rate != priv->last_blink_rate) { if (blink_rate != priv->last_blink_rate) {
if (blink_rate != IWL_LED_SOLID) { if (blink_rate != IWL_LED_SOLID) {
priv->last_blink_time = jiffies + iwl4965_led_pattern(priv, IWL_LED_LINK, blink_rate);
msecs_to_jiffies(1000);
iwl4965_led_not_solid(priv, IWL_LED_LINK, blink_rate);
} else { } else {
priv->last_blink_time = 0;
iwl4965_led_on(priv, IWL_LED_LINK); iwl4965_led_on(priv, IWL_LED_LINK);
} }
} }
priv->last_blink_time = jiffies;
priv->last_blink_rate = blink_rate; priv->last_blink_rate = blink_rate;
} }
EXPORT_SYMBOL(iwl_leds_background); EXPORT_SYMBOL(iwl_leds_background);
...@@ -362,10 +359,8 @@ int iwl_leds_register(struct iwl_priv *priv) ...@@ -362,10 +359,8 @@ int iwl_leds_register(struct iwl_priv *priv)
priv->led[IWL_LED_TRG_RADIO].led_off = iwl4965_led_off_reg; priv->led[IWL_LED_TRG_RADIO].led_off = iwl4965_led_off_reg;
priv->led[IWL_LED_TRG_RADIO].led_pattern = NULL; priv->led[IWL_LED_TRG_RADIO].led_pattern = NULL;
ret = iwl_leds_register_led(priv, ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_RADIO],
&priv->led[IWL_LED_TRG_RADIO], IWL_LED_TRG_RADIO, 1, name, trigger);
IWL_LED_TRG_RADIO, 1,
name, trigger);
if (ret) if (ret)
goto exit_fail; goto exit_fail;
...@@ -373,10 +368,9 @@ int iwl_leds_register(struct iwl_priv *priv) ...@@ -373,10 +368,9 @@ int iwl_leds_register(struct iwl_priv *priv)
snprintf(name, sizeof(name), "iwl-%s:assoc", snprintf(name, sizeof(name), "iwl-%s:assoc",
wiphy_name(priv->hw->wiphy)); wiphy_name(priv->hw->wiphy));
ret = iwl_leds_register_led(priv, ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_ASSOC],
&priv->led[IWL_LED_TRG_ASSOC], IWL_LED_TRG_ASSOC, 0, name, trigger);
IWL_LED_TRG_ASSOC, 0,
name, trigger);
/* for assoc always turn led on */ /* for assoc always turn led on */
priv->led[IWL_LED_TRG_ASSOC].led_on = iwl4965_led_on_reg; priv->led[IWL_LED_TRG_ASSOC].led_on = iwl4965_led_on_reg;
priv->led[IWL_LED_TRG_ASSOC].led_off = iwl4965_led_on_reg; priv->led[IWL_LED_TRG_ASSOC].led_off = iwl4965_led_on_reg;
...@@ -386,14 +380,11 @@ int iwl_leds_register(struct iwl_priv *priv) ...@@ -386,14 +380,11 @@ int iwl_leds_register(struct iwl_priv *priv)
goto exit_fail; goto exit_fail;
trigger = ieee80211_get_rx_led_name(priv->hw); trigger = ieee80211_get_rx_led_name(priv->hw);
snprintf(name, sizeof(name), "iwl-%s:RX", snprintf(name, sizeof(name), "iwl-%s:RX", wiphy_name(priv->hw->wiphy));
wiphy_name(priv->hw->wiphy));
ret = iwl_leds_register_led(priv, ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_RX],
&priv->led[IWL_LED_TRG_RX], IWL_LED_TRG_RX, 0, name, trigger);
IWL_LED_TRG_RX, 0,
name, trigger);
priv->led[IWL_LED_TRG_RX].led_on = iwl4965_led_associated; priv->led[IWL_LED_TRG_RX].led_on = iwl4965_led_associated;
priv->led[IWL_LED_TRG_RX].led_off = iwl4965_led_associated; priv->led[IWL_LED_TRG_RX].led_off = iwl4965_led_associated;
...@@ -403,12 +394,10 @@ int iwl_leds_register(struct iwl_priv *priv) ...@@ -403,12 +394,10 @@ int iwl_leds_register(struct iwl_priv *priv)
goto exit_fail; goto exit_fail;
trigger = ieee80211_get_tx_led_name(priv->hw); trigger = ieee80211_get_tx_led_name(priv->hw);
snprintf(name, sizeof(name), "iwl-%s:TX", snprintf(name, sizeof(name), "iwl-%s:TX", wiphy_name(priv->hw->wiphy));
wiphy_name(priv->hw->wiphy)); ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_TX],
ret = iwl_leds_register_led(priv, IWL_LED_TRG_TX, 0, name, trigger);
&priv->led[IWL_LED_TRG_TX],
IWL_LED_TRG_TX, 0,
name, trigger);
priv->led[IWL_LED_TRG_TX].led_on = iwl4965_led_associated; priv->led[IWL_LED_TRG_TX].led_on = iwl4965_led_associated;
priv->led[IWL_LED_TRG_TX].led_off = iwl4965_led_associated; priv->led[IWL_LED_TRG_TX].led_off = iwl4965_led_associated;
priv->led[IWL_LED_TRG_TX].led_pattern = iwl4965_led_pattern; priv->led[IWL_LED_TRG_TX].led_pattern = iwl4965_led_pattern;
...@@ -425,7 +414,7 @@ int iwl_leds_register(struct iwl_priv *priv) ...@@ -425,7 +414,7 @@ int iwl_leds_register(struct iwl_priv *priv)
EXPORT_SYMBOL(iwl_leds_register); EXPORT_SYMBOL(iwl_leds_register);
/* unregister led class */ /* unregister led class */
static void iwl_leds_unregister_led(struct iwl4965_led *led, u8 set_led) static void iwl_leds_unregister_led(struct iwl_led *led, u8 set_led)
{ {
if (!led->registered) if (!led->registered)
return; return;
......
...@@ -49,7 +49,7 @@ enum led_type { ...@@ -49,7 +49,7 @@ enum led_type {
}; };
struct iwl4965_led { struct iwl_led {
struct iwl_priv *priv; struct iwl_priv *priv;
struct led_classdev led_dev; struct led_classdev led_dev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment