[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180910063436.2326-1-kai.heng.feng@canonical.com>
Date: Mon, 10 Sep 2018 14:34:36 +0800
From: Kai-Heng Feng <kai.heng.feng@...onical.com>
To: nic_swsd@...ltek.com
Cc: davem@...emloft.net, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org,
Kai-Heng Feng <kai.heng.feng@...onical.com>,
Heiner Kallweit <hkallweit1@...il.com>
Subject: [PATCH] r8169: Clear RTL_FLAG_TASK_*_PENDING when clearing RTL_FLAG_TASK_ENABLED
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 <hkallweit1@...il.com>
Signed-off-by: Kai-Heng Feng <kai.heng.feng@...onical.com>
---
drivers/net/ethernet/realtek/r8169.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index b08d51bf7a20..20593245ef53 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -6648,6 +6648,7 @@ static int rtl8169_close(struct net_device *dev)
{
struct rtl8169_private *tp = netdev_priv(dev);
struct pci_dev *pdev = tp->pci_dev;
+ int i;
pm_runtime_get_sync(&pdev->dev);
@@ -6655,7 +6656,9 @@ 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 */
+ for (i = 0; i < RTL_FLAG_MAX; i++)
+ clear_bit(i, tp->wk.flags);
rtl8169_down(dev);
rtl_unlock_work(tp);
@@ -6828,6 +6831,7 @@ rtl8169_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
static void rtl8169_net_suspend(struct net_device *dev)
{
struct rtl8169_private *tp = netdev_priv(dev);
+ int i;
if (!netif_running(dev))
return;
@@ -6838,7 +6842,10 @@ 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 */
+ for (i = 0; i < RTL_FLAG_MAX; i++)
+ clear_bit(i, tp->wk.flags);
+
rtl_unlock_work(tp);
rtl_pll_power_down(tp);
--
2.17.1
Powered by blists - more mailing lists