Skip to contentSkip to conversation

Bug#609538: r8169: long delay during resume

DISCUSSION Ben Hutchings 3 participants 5 messages Jan 11, 2011 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 16 lines · Jarek Kamiński

Package: linux-2.6
Version: 2.6.37-1~experimental.1
Severity: normal
File: /lib/modules/2.6.37-trunk-amd64/kernel/drivers/net/r8169.ko
Tags: upstream

Hi.

2.6.37 introduces regression in r8169. During every resume I get ~20 seconds delay:

Jan 10 13:57:15 rocket kernel: [36458.257780] ata1.00: configured for UDMA/100
Jan 10 13:57:15 rocket kernel: [36517.738421] r8169 0000:13:00.0: eth0: unable to apply firmware patch
Jan 10 13:57:15 rocket kernel: [36517.739859] PM: resume of devices complete after 61177.644 msecs
Jan 10 13:57:15 rocket kernel: [36517.740258] PM: Finishing wakeup.
Jan 10 13:57:15 rocket kernel: [36517.740259] Restarting tasks ... done.
Quoted 4 lines

Bisecting leads to commit bca03d5f32c8ee9b5cfa1d32640a63fded6cb3c0 (r8169: remove the firmware of RTL8111D.). Further debugging showed, that firmware.agent is not called at all, I guess that udev is not working before "Restarting tasks".

Right, only the kernel is running then.

Quoted 2 lines

Either r8169 tries to load firmware too early, or it should keep it loaded in memory for use during resume.

It should. But an earlier version of this patch was also in Debian's 2.6.36 so it would have had the same problem.

Ben.

Quoted 2 lines

The problem persist no matter if I have firmware-realtek installed, or not.

Signature · 2 lines
Ben Hutchings
Once a job is fouled up, anything done to improve it makes it worse.
#2 lore raw

W dniu 11.01.2011 06:49, Ben Hutchings pisze:

Quoted 12 lines · Jarek Kamiński
Quoted 11 lines

Package: linux-2.6
Version: 2.6.37-1~experimental.1

2.6.37 introduces regression in r8169. During every resume I get ~20 seconds delay:

Jan 10 13:57:15 rocket kernel: [36458.257780] ata1.00: configured for UDMA/100
Jan 10 13:57:15 rocket kernel: [36517.738421] r8169 0000:13:00.0: eth0: unable to apply firmware patch
Jan 10 13:57:15 rocket kernel: [36517.739859] PM: resume of devices complete after 61177.644 msecs
Jan 10 13:57:15 rocket kernel: [36517.740258] PM: Finishing wakeup.
Jan 10 13:57:15 rocket kernel: [36517.740259] Restarting tasks ... done.
Quoted 8 lines
Quoted 5 lines

Bisecting leads to commit bca03d5f32c8ee9b5cfa1d32640a63fded6cb3c0 (r8169: remove the firmware of RTL8111D.).

Either r8169 tries to load firmware too early, or it should keep it loaded in memory for use during resume.

It should. But an earlier version of this patch was also in Debian's 2.6.36 so it would have had the same problem.

The last 2.6.36 I've tried was 2.6.36-1~experimental.1, I've then passsed and returned to 2.6.32 for unrelated problems. I think it wasn't affected, but I can re-check it and/or test later 2.6.36 versions if it may help.

Sorry if my information was misleading.

Signature · 1 line
pozdr(); // Jarek
#3 lore raw

Jarek Kamiński <[email protected]> :
[...]

Quoted 4 lines

The last 2.6.36 I've tried was 2.6.36-1~experimental.1, I've then passsed and returned to 2.6.32 for unrelated problems. I think it wasn't affected, but I can re-check it and/or test later 2.6.36 versions if it may help.

The patch below against 2.6.37-git + davem's pending fixes (see
http://marc.info/?l=linux-netdev&m=129448910825754) should help.

Can you give it a try ?

r8169: keep firmware in memory.

The firmware agent is not available during resume.

It will help with http://bugs.debian.org/609538 but it will not avoid the 60 seconds delay when there is no firmware.

---
 drivers/net/r8169.c |   43 +++++++++++++++++++++++++++++++------------
 1 files changed, 31 insertions(+), 12 deletions(-)
drivers/net/r8169.c +31 -12
index dd758cd..7e2f01c 100644
@@ -554,6 +554,8 @@ struct rtl8169_private {
 	struct mii_if_info mii;
 	struct rtl8169_counters counters;
 	u32 saved_wolopts;
+
+	const struct firmware *fw;
 };
 
 MODULE_AUTHOR("Realtek and the Linux r8169 crew <[email protected]>");
@@ -1668,6 +1670,29 @@ rtl_phy_write_fw(struct rtl8169_private *tp, const struct firmware *fw)
 	}
 }
 
+static void rtl_release_firmware(struct rtl8169_private *tp)
+{
+	release_firmware(tp->fw);
+	tp->fw = NULL;
+}
+
+static int rtl_apply_firmware(struct rtl8169_private *tp, const char *fw_name)
+{
+	const struct firmware **fw = &tp->fw;
+	int rc = !*fw;
+
+	if (rc) {
+		rc = request_firmware(fw, fw_name, &tp->pci_dev->dev);
+		if (rc < 0)
+			goto out;
+	}
+
+	/* TODO: release firmware once rtl_phy_write_fw signals failures. */
+	rtl_phy_write_fw(tp, *fw);
+out:
+	return rc;
+}
+
 static void rtl8169s_hw_phy_config(struct rtl8169_private *tp)
 {
 	static const struct phy_reg phy_reg_init[] = {
@@ -2041,7 +2066,6 @@ static void rtl8168d_1_hw_phy_config(struct rtl8169_private *tp)
 		{ 0x0d, 0xf880 }
 	};
 	void __iomem *ioaddr = tp->mmio_addr;
-	const struct firmware *fw;
 
 	rtl_writephy_batch(tp, phy_reg_init_0, ARRAY_SIZE(phy_reg_init_0));
 
@@ -2105,11 +2129,8 @@ static void rtl8168d_1_hw_phy_config(struct rtl8169_private *tp)
 
 	rtl_writephy(tp, 0x1f, 0x0005);
 	rtl_writephy(tp, 0x05, 0x001b);
-	if (rtl_readphy(tp, 0x06) == 0xbf00 &&
-	    request_firmware(&fw, FIRMWARE_8168D_1, &tp->pci_dev->dev) == 0) {
-		rtl_phy_write_fw(tp, fw);
-		release_firmware(fw);
-	} else {
+	if ((rtl_readphy(tp, 0x06) != 0xbf00) ||
+	    (rtl_apply_firmware(tp, FIRMWARE_8168D_1) < 0)) {
 		netif_warn(tp, probe, tp->dev, "unable to apply firmware patch\n");
 	}
 
@@ -2159,7 +2180,6 @@ static void rtl8168d_2_hw_phy_config(struct rtl8169_private *tp)
 		{ 0x0d, 0xf880 }
 	};
 	void __iomem *ioaddr = tp->mmio_addr;
-	const struct firmware *fw;
 
 	rtl_writephy_batch(tp, phy_reg_init_0, ARRAY_SIZE(phy_reg_init_0));
 
@@ -2214,11 +2234,8 @@ static void rtl8168d_2_hw_phy_config(struct rtl8169_private *tp)
 
 	rtl_writephy(tp, 0x1f, 0x0005);
 	rtl_writephy(tp, 0x05, 0x001b);
-	if (rtl_readphy(tp, 0x06) == 0xb300 &&
-	    request_firmware(&fw, FIRMWARE_8168D_2, &tp->pci_dev->dev) == 0) {
-		rtl_phy_write_fw(tp, fw);
-		release_firmware(fw);
-	} else {
+	if ((rtl_readphy(tp, 0x06) != 0xb300) ||
+	    (rtl_apply_firmware(tp, FIRMWARE_8168D_2) < 0)) {
 		netif_warn(tp, probe, tp->dev, "unable to apply firmware patch\n");
 	}
 
@@ -4662,6 +4679,8 @@ static int rtl8169_close(struct net_device *dev)
 	tp->TxDescArray = NULL;
 	tp->RxDescArray = NULL;
 
+	rtl_release_firmware(tp);
+
 	pm_runtime_put_sync(&pdev->dev);
 
 	return 0;
Signature · 1 line
1.7.3.4
#4 lore raw

W dniu 11.01.2011 14:25, Francois Romieu pisze:

Quoted 7 lines

Jarek Kamiński <[email protected]> :
[...]

Quoted 4 lines

The last 2.6.36 I've tried was 2.6.36-1~experimental.1, I've then passsed and returned to 2.6.32 for unrelated problems. I think it wasn't affected, but I can re-check it and/or test later 2.6.36 versions if it may help.

Quoted 6 lines

The patch below against 2.6.37-git + davem's pending fixes (see
http://marc.info/?l=linux-netdev&m=129448910825754) should help.

Can you give it a try ?

r8169: keep firmware in memory.

This patch applied against current git tree fixes problem (with firmware installed). However, cherry-picking eee3a96c6368f47df8df5bd4ed1843600652b337 (r8169: delay phy init until device opens.) from net-2.6.git and applying "r8169: keep firmware in memory." still results with
#v+

Jan 11 19:05:18 rocket kernel: [  673.176439] ata1.00: configured for
UDMA/100
Jan 11 19:05:18 rocket kernel: [  731.639054] r8169 0000:13:00.0: eth0:
unable to apply firmware patch
Jan 11 19:05:18 rocket kernel: [  731.640486] PM: resume of devices

complete after 60228.033 msecs
#v-
(I don't fully understand why)

"r8169: delay phy init until device opens." alone also doesn't do the trick.

Signature · 1 line
pozdr(); // Jarek
#5 lore raw

Jarek Kamiński <[email protected]> :
[failure]

/me slaps head

Please check that it works if you add the patch below and I'll merge both for a proper submission.

r8169: I am a clown.

Modifying rtl8169_reset_task() to tolerate firmware changes between close() and open() but this is not high-priority.

drivers/net/r8169.c +2 -2
index 7e2f01c..57fa6bd 100644
@@ -3119,6 +3119,8 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev)
 
 	cancel_delayed_work_sync(&tp->task);
 
+	rtl_release_firmware(tp);
+
 	unregister_netdev(dev);
 
 	if (pci_dev_run_wake(pdev))
@@ -4679,8 +4681,6 @@ static int rtl8169_close(struct net_device *dev)
 	tp->TxDescArray = NULL;
 	tp->RxDescArray = NULL;
 
-	rtl_release_firmware(tp);
-
 	pm_runtime_put_sync(&pdev->dev);
 
 	return 0;
Quoted 1 line

"r8169: delay phy init until device opens." alone also doesn't do the trick.

It was the expected behavior.

Signature · 1 line
Ueimor