[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <9deed542-bfe7-1b4e-097e-a9f96a036a3c@gmail.com>
Date: Mon, 10 Sep 2018 09:42:45 -0700
From: Florian Fainelli <f.fainelli@...il.com>
To: Kai-Heng Feng <kai.heng.feng@...onical.com>, nic_swsd@...ltek.com
Cc: davem@...emloft.net, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org,
Heiner Kallweit <hkallweit1@...il.com>
Subject: Re: [PATCH] r8169: Clear RTL_FLAG_TASK_*_PENDING when clearing
RTL_FLAG_TASK_ENABLED
On 09/09/2018 11:34 PM, Kai-Heng Feng wrote:
> 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);
bitmap_zero(&tp->wk.,flagsm RTL_FLAG_MAX)
>
> 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);
Likewise.
> +
> rtl_unlock_work(tp);
>
> rtl_pll_power_down(tp);
>
--
Florian
Powered by blists - more mailing lists