Blob Blame History Raw
From b4cc2dcc9c7c9cea293d1fa6a7b91876c8f23bdf Mon Sep 17 00:00:00 2001
From: Heiner Kallweit <hkallweit1@gmail.com>
Date: Thu, 22 Nov 2018 21:58:48 +0100
Subject: [PATCH] r8169: Revive default chip version for r8168
Patch-mainline: Never, SLE15-SP2/Leap15.2 specific hack
References: bsc#1173085

This is a partial revert of the upstream commit b4cc2dcc9c7c ("r8169:
remove default chip versions") as a workaround for a regression with
some devices.

RTL8117 isn't supported on 5.3.y kernel r8169 driver while it worked
in the earlier Leap 15.1.  The reason was the commit above and r8169
driver doesn't try to take the default MAC version any longer for the
unknown chip models.

Although the support for RTL8117 itself has been added to the
upstream, its full support seems not too trivial to backport and some
trials failed.  So this is rather a workaround for allowing the
default MAC version assignment to the certain chip again, so that the
driver works like the earlier versions.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

---
 drivers/net/ethernet/realtek/r8169_main.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -2148,7 +2148,8 @@ static void rtl_enable_eee(struct rtl816
 		rtl_set_eee_adv(tp, supported);
 }
 
-static void rtl8169_get_mac_version(struct rtl8169_private *tp)
+static void rtl8169_get_mac_version(struct rtl8169_private *tp,
+				    u8 default_version)
 {
 	/*
 	 * The driver currently handles the 8168Bf and the 8168Be identically
@@ -2254,6 +2255,7 @@ static void rtl8169_get_mac_version(stru
 
 	if (tp->mac_version == RTL_GIGA_MAC_NONE) {
 		dev_err(tp_to_dev(tp), "unknown chip XID %03x\n", reg & 0xfcf);
+		tp->mac_version = default_version;
 	} else if (!tp->supports_gmii) {
 		if (tp->mac_version == RTL_GIGA_MAC_VER_42)
 			tp->mac_version = RTL_GIGA_MAC_VER_43;
@@ -6841,6 +6843,7 @@ static int rtl_init_one(struct pci_dev *
 	struct net_device *dev;
 	int chipset, region;
 	int jumbo_max, rc;
+	u8 default_version;
 
 	dev = devm_alloc_etherdev(&pdev->dev, sizeof (*tp));
 	if (!dev)
@@ -6898,7 +6901,12 @@ static int rtl_init_one(struct pci_dev *
 	tp->mmio_addr = pcim_iomap_table(pdev)[region];
 
 	/* Identify chip attached to board */
-	rtl8169_get_mac_version(tp);
+	/* XXX: ugly hack for allowing some backward compatibility with the
+	 * still unsupported chip version for 5.3.y code (bsc#1173085)
+	 */
+	default_version = (ent->device == 0x8168) ?
+		RTL_GIGA_MAC_VER_11 : RTL_GIGA_MAC_NONE;
+	rtl8169_get_mac_version(tp, default_version);
 	if (tp->mac_version == RTL_GIGA_MAC_NONE)
 		return -ENODEV;