Skip to content

Commit bb13a80

Browse files
hkallweitdavem330
authored andcommitted
r8169: fix handling ether_clk
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 <ptesarik@suse.cz> Tested-by: Petr Tesarik <ptesarik@suse.cz> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a59cf61 commit bb13a80

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

drivers/net/ethernet/realtek/r8169_main.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2239,14 +2239,10 @@ static void rtl_pll_power_down(struct rtl8169_private *tp)
22392239
default:
22402240
break;
22412241
}
2242-
2243-
clk_disable_unprepare(tp->clk);
22442242
}
22452243

22462244
static void rtl_pll_power_up(struct rtl8169_private *tp)
22472245
{
2248-
clk_prepare_enable(tp->clk);
2249-
22502246
switch (tp->mac_version) {
22512247
case RTL_GIGA_MAC_VER_25 ... RTL_GIGA_MAC_VER_33:
22522248
case RTL_GIGA_MAC_VER_37:
@@ -4826,29 +4822,39 @@ static void rtl8169_net_suspend(struct rtl8169_private *tp)
48264822

48274823
#ifdef CONFIG_PM
48284824

4825+
static int rtl8169_net_resume(struct rtl8169_private *tp)
4826+
{
4827+
rtl_rar_set(tp, tp->dev->dev_addr);
4828+
4829+
if (tp->TxDescArray)
4830+
rtl8169_up(tp);
4831+
4832+
netif_device_attach(tp->dev);
4833+
4834+
return 0;
4835+
}
4836+
48294837
static int __maybe_unused rtl8169_suspend(struct device *device)
48304838
{
48314839
struct rtl8169_private *tp = dev_get_drvdata(device);
48324840

48334841
rtnl_lock();
48344842
rtl8169_net_suspend(tp);
4843+
if (!device_may_wakeup(tp_to_dev(tp)))
4844+
clk_disable_unprepare(tp->clk);
48354845
rtnl_unlock();
48364846

48374847
return 0;
48384848
}
48394849

4840-
static int rtl8169_resume(struct device *device)
4850+
static int __maybe_unused rtl8169_resume(struct device *device)
48414851
{
48424852
struct rtl8169_private *tp = dev_get_drvdata(device);
48434853

4844-
rtl_rar_set(tp, tp->dev->dev_addr);
4845-
4846-
if (tp->TxDescArray)
4847-
rtl8169_up(tp);
4854+
if (!device_may_wakeup(tp_to_dev(tp)))
4855+
clk_prepare_enable(tp->clk);
48484856

4849-
netif_device_attach(tp->dev);
4850-
4851-
return 0;
4857+
return rtl8169_net_resume(tp);
48524858
}
48534859

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

48754881
__rtl8169_set_wol(tp, tp->saved_wolopts);
48764882

4877-
return rtl8169_resume(device);
4883+
return rtl8169_net_resume(tp);
48784884
}
48794885

48804886
static int rtl8169_runtime_idle(struct device *device)

0 commit comments

Comments
 (0)