Skip to content

Commit

Permalink
r8169: fix handling ether_clk
Browse files Browse the repository at this point in the history
Petr reported that system freezes on r8169 driver load on a system
using ether_clk. The original change was done under the assumption
that the clock isn't needed for basic operations like chip register
access. But obviously that was wrong.
Therefore effectively revert the original change, and in addition
leave the clock active when suspending and WoL is enabled. Chip may
not be able to process incoming packets otherwise.

Fixes: 9f0b54c ("r8169: move switching optional clock on/off to pll power functions")
Reported-by: Petr Tesarik <[email protected]>
Tested-by: Petr Tesarik <[email protected]>
Signed-off-by: Heiner Kallweit <[email protected]>
Reviewed-by: Hans de Goede <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
hkallweit authored and davem330 committed Oct 1, 2020
1 parent a59cf61 commit bb13a80
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions drivers/net/ethernet/realtek/r8169_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2239,14 +2239,10 @@ static void rtl_pll_power_down(struct rtl8169_private *tp)
default:
break;
}

clk_disable_unprepare(tp->clk);
}

static void rtl_pll_power_up(struct rtl8169_private *tp)
{
clk_prepare_enable(tp->clk);

switch (tp->mac_version) {
case RTL_GIGA_MAC_VER_25 ... RTL_GIGA_MAC_VER_33:
case RTL_GIGA_MAC_VER_37:
Expand Down Expand Up @@ -4826,29 +4822,39 @@ static void rtl8169_net_suspend(struct rtl8169_private *tp)

#ifdef CONFIG_PM

static int rtl8169_net_resume(struct rtl8169_private *tp)
{
rtl_rar_set(tp, tp->dev->dev_addr);

if (tp->TxDescArray)
rtl8169_up(tp);

netif_device_attach(tp->dev);

return 0;
}

static int __maybe_unused rtl8169_suspend(struct device *device)
{
struct rtl8169_private *tp = dev_get_drvdata(device);

rtnl_lock();
rtl8169_net_suspend(tp);
if (!device_may_wakeup(tp_to_dev(tp)))
clk_disable_unprepare(tp->clk);
rtnl_unlock();

return 0;
}

static int rtl8169_resume(struct device *device)
static int __maybe_unused rtl8169_resume(struct device *device)
{
struct rtl8169_private *tp = dev_get_drvdata(device);

rtl_rar_set(tp, tp->dev->dev_addr);

if (tp->TxDescArray)
rtl8169_up(tp);
if (!device_may_wakeup(tp_to_dev(tp)))
clk_prepare_enable(tp->clk);

netif_device_attach(tp->dev);

return 0;
return rtl8169_net_resume(tp);
}

static int rtl8169_runtime_suspend(struct device *device)
Expand All @@ -4874,7 +4880,7 @@ static int rtl8169_runtime_resume(struct device *device)

__rtl8169_set_wol(tp, tp->saved_wolopts);

return rtl8169_resume(device);
return rtl8169_net_resume(tp);
}

static int rtl8169_runtime_idle(struct device *device)
Expand Down

0 comments on commit bb13a80

Please sign in to comment.