Skip to content

Commit

Permalink
r8169: Clear RTL_FLAG_TASK_*_PENDING when clearing RTL_FLAG_TASK_ENABLED
Browse files Browse the repository at this point in the history
After system suspend, sometimes the r8169 doesn't work when ethernet
cable gets pluggued.

This issue happens because rtl_reset_work() doesn't get called from
rtl8169_runtime_resume(), after system suspend.

In rtl_task(), RTL_FLAG_TASK_* only gets cleared if this condition is
met:
if (!netif_running(dev) ||
    !test_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags))
    ...

If RTL_FLAG_TASK_ENABLED was cleared during system suspend while
RTL_FLAG_TASK_RESET_PENDING was set, the next rtl_schedule_task() won't
schedule task as the flag is still there.

So in addition to clearing RTL_FLAG_TASK_ENABLED, also clears other
flags.

Cc: Heiner Kallweit <[email protected]>
Signed-off-by: Kai-Heng Feng <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
khfeng authored and davem330 committed Sep 12, 2018
1 parent 51dc63e commit 6ad5690
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/net/ethernet/realtek/r8169.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ struct rtl8169_tc_offsets {
};

enum rtl_flag {
RTL_FLAG_TASK_ENABLED,
RTL_FLAG_TASK_ENABLED = 0,
RTL_FLAG_TASK_SLOW_PENDING,
RTL_FLAG_TASK_RESET_PENDING,
RTL_FLAG_MAX
Expand Down Expand Up @@ -6655,7 +6655,8 @@ static int rtl8169_close(struct net_device *dev)
rtl8169_update_counters(tp);

rtl_lock_work(tp);
clear_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags);
/* Clear all task flags */
bitmap_zero(tp->wk.flags, RTL_FLAG_MAX);

rtl8169_down(dev);
rtl_unlock_work(tp);
Expand Down Expand Up @@ -6838,7 +6839,9 @@ static void rtl8169_net_suspend(struct net_device *dev)

rtl_lock_work(tp);
napi_disable(&tp->napi);
clear_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags);
/* Clear all task flags */
bitmap_zero(tp->wk.flags, RTL_FLAG_MAX);

rtl_unlock_work(tp);

rtl_pll_power_down(tp);
Expand Down

0 comments on commit 6ad5690

Please sign in to comment.