Skip to content

Commit 48c205c

Browse files
committed
Merge branch 'r8169-fix-dash-devices-network-lost-issue'
ChunHao Lin says: ==================== r8169: fix DASH devices network lost issue This series are used to fix network lost issue on systems that support DASH. It has been tested on rtl8168ep and rtl8168fp. ==================== Link: https://lore.kernel.org/r/20231109173400.4573-1-hau@realtek.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 334e90b + 868c3b9 commit 48c205c

1 file changed

Lines changed: 31 additions & 11 deletions

File tree

drivers/net/ethernet/realtek/r8169_main.c

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ struct rtl8169_private {
624624

625625
unsigned supports_gmii:1;
626626
unsigned aspm_manageable:1;
627+
unsigned dash_enabled:1;
627628
dma_addr_t counters_phys_addr;
628629
struct rtl8169_counters *counters;
629630
struct rtl8169_tc_offsets tc_offset;
@@ -1253,14 +1254,26 @@ static bool r8168ep_check_dash(struct rtl8169_private *tp)
12531254
return r8168ep_ocp_read(tp, 0x128) & BIT(0);
12541255
}
12551256

1256-
static enum rtl_dash_type rtl_check_dash(struct rtl8169_private *tp)
1257+
static bool rtl_dash_is_enabled(struct rtl8169_private *tp)
1258+
{
1259+
switch (tp->dash_type) {
1260+
case RTL_DASH_DP:
1261+
return r8168dp_check_dash(tp);
1262+
case RTL_DASH_EP:
1263+
return r8168ep_check_dash(tp);
1264+
default:
1265+
return false;
1266+
}
1267+
}
1268+
1269+
static enum rtl_dash_type rtl_get_dash_type(struct rtl8169_private *tp)
12571270
{
12581271
switch (tp->mac_version) {
12591272
case RTL_GIGA_MAC_VER_28:
12601273
case RTL_GIGA_MAC_VER_31:
1261-
return r8168dp_check_dash(tp) ? RTL_DASH_DP : RTL_DASH_NONE;
1274+
return RTL_DASH_DP;
12621275
case RTL_GIGA_MAC_VER_51 ... RTL_GIGA_MAC_VER_53:
1263-
return r8168ep_check_dash(tp) ? RTL_DASH_EP : RTL_DASH_NONE;
1276+
return RTL_DASH_EP;
12641277
default:
12651278
return RTL_DASH_NONE;
12661279
}
@@ -1453,7 +1466,7 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)
14531466

14541467
device_set_wakeup_enable(tp_to_dev(tp), wolopts);
14551468

1456-
if (tp->dash_type == RTL_DASH_NONE) {
1469+
if (!tp->dash_enabled) {
14571470
rtl_set_d3_pll_down(tp, !wolopts);
14581471
tp->dev->wol_enabled = wolopts ? 1 : 0;
14591472
}
@@ -2512,7 +2525,7 @@ static void rtl_wol_enable_rx(struct rtl8169_private *tp)
25122525

25132526
static void rtl_prepare_power_down(struct rtl8169_private *tp)
25142527
{
2515-
if (tp->dash_type != RTL_DASH_NONE)
2528+
if (tp->dash_enabled)
25162529
return;
25172530

25182531
if (tp->mac_version == RTL_GIGA_MAC_VER_32 ||
@@ -4648,10 +4661,16 @@ static void rtl8169_down(struct rtl8169_private *tp)
46484661
rtl8169_cleanup(tp);
46494662
rtl_disable_exit_l1(tp);
46504663
rtl_prepare_power_down(tp);
4664+
4665+
if (tp->dash_type != RTL_DASH_NONE)
4666+
rtl8168_driver_stop(tp);
46514667
}
46524668

46534669
static void rtl8169_up(struct rtl8169_private *tp)
46544670
{
4671+
if (tp->dash_type != RTL_DASH_NONE)
4672+
rtl8168_driver_start(tp);
4673+
46554674
pci_set_master(tp->pci_dev);
46564675
phy_init_hw(tp->phydev);
46574676
phy_resume(tp->phydev);
@@ -4869,7 +4888,7 @@ static int rtl8169_runtime_idle(struct device *device)
48694888
{
48704889
struct rtl8169_private *tp = dev_get_drvdata(device);
48714890

4872-
if (tp->dash_type != RTL_DASH_NONE)
4891+
if (tp->dash_enabled)
48734892
return -EBUSY;
48744893

48754894
if (!netif_running(tp->dev) || !netif_carrier_ok(tp->dev))
@@ -4895,8 +4914,7 @@ static void rtl_shutdown(struct pci_dev *pdev)
48954914
/* Restore original MAC address */
48964915
rtl_rar_set(tp, tp->dev->perm_addr);
48974916

4898-
if (system_state == SYSTEM_POWER_OFF &&
4899-
tp->dash_type == RTL_DASH_NONE) {
4917+
if (system_state == SYSTEM_POWER_OFF && !tp->dash_enabled) {
49004918
pci_wake_from_d3(pdev, tp->saved_wolopts);
49014919
pci_set_power_state(pdev, PCI_D3hot);
49024920
}
@@ -5254,7 +5272,8 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
52545272
rc = pci_disable_link_state(pdev, PCIE_LINK_STATE_L1);
52555273
tp->aspm_manageable = !rc;
52565274

5257-
tp->dash_type = rtl_check_dash(tp);
5275+
tp->dash_type = rtl_get_dash_type(tp);
5276+
tp->dash_enabled = rtl_dash_is_enabled(tp);
52585277

52595278
tp->cp_cmd = RTL_R16(tp, CPlusCmd) & CPCMD_MASK;
52605279

@@ -5325,7 +5344,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
53255344
/* configure chip for default features */
53265345
rtl8169_set_features(dev, dev->features);
53275346

5328-
if (tp->dash_type == RTL_DASH_NONE) {
5347+
if (!tp->dash_enabled) {
53295348
rtl_set_d3_pll_down(tp, true);
53305349
} else {
53315350
rtl_set_d3_pll_down(tp, false);
@@ -5365,7 +5384,8 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
53655384
"ok" : "ko");
53665385

53675386
if (tp->dash_type != RTL_DASH_NONE) {
5368-
netdev_info(dev, "DASH enabled\n");
5387+
netdev_info(dev, "DASH %s\n",
5388+
tp->dash_enabled ? "enabled" : "disabled");
53695389
rtl8168_driver_start(tp);
53705390
}
53715391

0 commit comments

Comments
 (0)