Skip to content

Commit 4ebcb11

Browse files
hkallweitJakub Kicinski
authored andcommitted
r8169: fix jumbo packet handling on resume from suspend
Mariusz reported that invalid packets are sent after resume from suspend if jumbo packets are active. It turned out that his BIOS resets chip settings to non-jumbo on resume. Most chip settings are re-initialized on resume from suspend by calling rtl_hw_start(), so let's add configuring jumbo to this function. There's nothing wrong with the commit marked as fixed, it's just the first one where the patch applies cleanly. Fixes: 7366016 ("r8169: read common register for PCI commit") Reported-by: Mariusz Bialonczyk <[email protected]> Tested-by: Mariusz Bialonczyk <[email protected]> Signed-off-by: Heiner Kallweit <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 70c2655 commit 4ebcb11

File tree

1 file changed

+11
-24
lines changed

1 file changed

+11
-24
lines changed

drivers/net/ethernet/realtek/r8169_main.c

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4146,6 +4146,14 @@ static void rtl_hw_jumbo_disable(struct rtl8169_private *tp)
41464146
rtl_lock_config_regs(tp);
41474147
}
41484148

4149+
static void rtl_jumbo_config(struct rtl8169_private *tp, int mtu)
4150+
{
4151+
if (mtu > ETH_DATA_LEN)
4152+
rtl_hw_jumbo_enable(tp);
4153+
else
4154+
rtl_hw_jumbo_disable(tp);
4155+
}
4156+
41494157
DECLARE_RTL_COND(rtl_chipcmd_cond)
41504158
{
41514159
return RTL_R8(tp, ChipCmd) & CmdReset;
@@ -4442,11 +4450,6 @@ static void rtl8168g_set_pause_thresholds(struct rtl8169_private *tp,
44424450
static void rtl_hw_start_8168bb(struct rtl8169_private *tp)
44434451
{
44444452
RTL_W8(tp, Config3, RTL_R8(tp, Config3) & ~Beacon_en);
4445-
4446-
if (tp->dev->mtu <= ETH_DATA_LEN) {
4447-
rtl_tx_performance_tweak(tp, PCI_EXP_DEVCTL_READRQ_4096B |
4448-
PCI_EXP_DEVCTL_NOSNOOP_EN);
4449-
}
44504453
}
44514454

44524455
static void rtl_hw_start_8168bef(struct rtl8169_private *tp)
@@ -4462,9 +4465,6 @@ static void __rtl_hw_start_8168cp(struct rtl8169_private *tp)
44624465

44634466
RTL_W8(tp, Config3, RTL_R8(tp, Config3) & ~Beacon_en);
44644467

4465-
if (tp->dev->mtu <= ETH_DATA_LEN)
4466-
rtl_tx_performance_tweak(tp, PCI_EXP_DEVCTL_READRQ_4096B);
4467-
44684468
rtl_disable_clock_request(tp);
44694469
}
44704470

@@ -4490,9 +4490,6 @@ static void rtl_hw_start_8168cp_2(struct rtl8169_private *tp)
44904490
rtl_set_def_aspm_entry_latency(tp);
44914491

44924492
RTL_W8(tp, Config3, RTL_R8(tp, Config3) & ~Beacon_en);
4493-
4494-
if (tp->dev->mtu <= ETH_DATA_LEN)
4495-
rtl_tx_performance_tweak(tp, PCI_EXP_DEVCTL_READRQ_4096B);
44964493
}
44974494

44984495
static void rtl_hw_start_8168cp_3(struct rtl8169_private *tp)
@@ -4503,9 +4500,6 @@ static void rtl_hw_start_8168cp_3(struct rtl8169_private *tp)
45034500

45044501
/* Magic. */
45054502
RTL_W8(tp, DBG_REG, 0x20);
4506-
4507-
if (tp->dev->mtu <= ETH_DATA_LEN)
4508-
rtl_tx_performance_tweak(tp, PCI_EXP_DEVCTL_READRQ_4096B);
45094503
}
45104504

45114505
static void rtl_hw_start_8168c_1(struct rtl8169_private *tp)
@@ -4611,9 +4605,6 @@ static void rtl_hw_start_8168e_1(struct rtl8169_private *tp)
46114605

46124606
rtl_ephy_init(tp, e_info_8168e_1);
46134607

4614-
if (tp->dev->mtu <= ETH_DATA_LEN)
4615-
rtl_tx_performance_tweak(tp, PCI_EXP_DEVCTL_READRQ_4096B);
4616-
46174608
rtl_disable_clock_request(tp);
46184609

46194610
/* Reset tx FIFO pointer */
@@ -4636,9 +4627,6 @@ static void rtl_hw_start_8168e_2(struct rtl8169_private *tp)
46364627

46374628
rtl_ephy_init(tp, e_info_8168e_2);
46384629

4639-
if (tp->dev->mtu <= ETH_DATA_LEN)
4640-
rtl_tx_performance_tweak(tp, PCI_EXP_DEVCTL_READRQ_4096B);
4641-
46424630
rtl_eri_write(tp, 0xc0, ERIAR_MASK_0011, 0x0000);
46434631
rtl_eri_write(tp, 0xb8, ERIAR_MASK_0011, 0x0000);
46444632
rtl_set_fifo_size(tp, 0x10, 0x10, 0x02, 0x06);
@@ -5485,6 +5473,8 @@ static void rtl_hw_start(struct rtl8169_private *tp)
54855473
rtl_set_rx_tx_desc_registers(tp);
54865474
rtl_lock_config_regs(tp);
54875475

5476+
rtl_jumbo_config(tp, tp->dev->mtu);
5477+
54885478
/* Initially a 10 us delay. Turned it into a PCI commit. - FR */
54895479
RTL_R16(tp, CPlusCmd);
54905480
RTL_W8(tp, ChipCmd, CmdTxEnb | CmdRxEnb);
@@ -5498,10 +5488,7 @@ static int rtl8169_change_mtu(struct net_device *dev, int new_mtu)
54985488
{
54995489
struct rtl8169_private *tp = netdev_priv(dev);
55005490

5501-
if (new_mtu > ETH_DATA_LEN)
5502-
rtl_hw_jumbo_enable(tp);
5503-
else
5504-
rtl_hw_jumbo_disable(tp);
5491+
rtl_jumbo_config(tp, new_mtu);
55055492

55065493
dev->mtu = new_mtu;
55075494
netdev_update_features(dev);

0 commit comments

Comments
 (0)