[PATCH 5/6 V2][SRU][Lunar] r8169: disable ASPM during NAPI poll

Koba Ko koba.ko at canonical.com
Mon Jun 5 03:27:10 UTC 2023


From: Heiner Kallweit <hkallweit1 at gmail.com>

BugLink: https://bugs.launchpad.net/bugs/1946433 

Several chip versions have problems with ASPM, what may result in
rx_missed errors or tx timeouts. The root cause isn't known but
experience shows that disabling ASPM during NAPI poll can avoid
these problems.

Suggested-by: Kai-Heng Feng <kai.heng.feng at canonical.com>
Reviewed-by: Simon Horman <simon.horman at corigine.com>
Tested-by: Kai-Heng Feng <kai.heng.feng at canonical.com>
Tested-by: Holger Hoffstätte <holger at applied-asynchrony.com>
Signed-off-by: Heiner Kallweit <hkallweit1 at gmail.com>
Signed-off-by: David S. Miller <davem at davemloft.net>
(cherry picked from commit e1ed3e4d91112027b90c7ee61479141b3f948e6a)
Signed-off-by: Koba Ko <koba.ko at canonical.com>
---
 drivers/net/ethernet/realtek/r8169_main.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index 82faa171fa0c6..f3e8d6fe56919 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -4577,6 +4577,10 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance)
 	}
 
 	if (napi_schedule_prep(&tp->napi)) {
+		rtl_unlock_config_regs(tp);
+		rtl_hw_aspm_clkreq_enable(tp, false);
+		rtl_lock_config_regs(tp);
+
 		rtl_irq_disable(tp);
 		__napi_schedule(&tp->napi);
 	}
@@ -4615,9 +4619,14 @@ static int rtl8169_poll(struct napi_struct *napi, int budget)
 
 	work_done = rtl_rx(dev, tp, budget);
 
-	if (work_done < budget && napi_complete_done(napi, work_done))
+	if (work_done < budget && napi_complete_done(napi, work_done)) {
 		rtl_irq_enable(tp);
 
+		rtl_unlock_config_regs(tp);
+		rtl_hw_aspm_clkreq_enable(tp, true);
+		rtl_lock_config_regs(tp);
+	}
+
 	return work_done;
 }
 
-- 
2.25.1




More information about the kernel-team mailing list