Skip to content

Commit c61d525

Browse files
RealtekNICgregkh
authored andcommitted
r8169: add handling DASH when DASH is disabled
commit 0ab0c45 upstream. For devices that support DASH, even DASH is disabled, there may still exist a default firmware that will influence device behavior. So driver needs to handle DASH for devices that support DASH, no matter the DASH status is. This patch also prepares for "fix network lost after resume on DASH systems". Fixes: ee7a1be ("r8169:call "rtl8168_driver_start" "rtl8168_driver_stop" only when hardware dash function is enabled") Cc: [email protected] Signed-off-by: ChunHao Lin <[email protected]> Reviewed-by: Heiner Kallweit <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a512609 commit c61d525

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

drivers/net/ethernet/realtek/r8169_main.c

Lines changed: 25 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 ||
@@ -4875,7 +4888,7 @@ static int rtl8169_runtime_idle(struct device *device)
48754888
{
48764889
struct rtl8169_private *tp = dev_get_drvdata(device);
48774890

4878-
if (tp->dash_type != RTL_DASH_NONE)
4891+
if (tp->dash_enabled)
48794892
return -EBUSY;
48804893

48814894
if (!netif_running(tp->dev) || !netif_carrier_ok(tp->dev))
@@ -4901,8 +4914,7 @@ static void rtl_shutdown(struct pci_dev *pdev)
49014914
/* Restore original MAC address */
49024915
rtl_rar_set(tp, tp->dev->perm_addr);
49034916

4904-
if (system_state == SYSTEM_POWER_OFF &&
4905-
tp->dash_type == RTL_DASH_NONE) {
4917+
if (system_state == SYSTEM_POWER_OFF && !tp->dash_enabled) {
49064918
pci_wake_from_d3(pdev, tp->saved_wolopts);
49074919
pci_set_power_state(pdev, PCI_D3hot);
49084920
}
@@ -5260,7 +5272,8 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
52605272
rc = pci_disable_link_state(pdev, PCIE_LINK_STATE_L1);
52615273
tp->aspm_manageable = !rc;
52625274

5263-
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);
52645277

52655278
tp->cp_cmd = RTL_R16(tp, CPlusCmd) & CPCMD_MASK;
52665279

@@ -5331,7 +5344,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
53315344
/* configure chip for default features */
53325345
rtl8169_set_features(dev, dev->features);
53335346

5334-
if (tp->dash_type == RTL_DASH_NONE) {
5347+
if (!tp->dash_enabled) {
53355348
rtl_set_d3_pll_down(tp, true);
53365349
} else {
53375350
rtl_set_d3_pll_down(tp, false);
@@ -5371,7 +5384,8 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
53715384
"ok" : "ko");
53725385

53735386
if (tp->dash_type != RTL_DASH_NONE) {
5374-
netdev_info(dev, "DASH enabled\n");
5387+
netdev_info(dev, "DASH %s\n",
5388+
tp->dash_enabled ? "enabled" : "disabled");
53755389
rtl8168_driver_start(tp);
53765390
}
53775391

0 commit comments

Comments
 (0)