Skip to contentSkip to conversation

r8169: add module parameter aspm_en_force

PATCH In review Crag Wang 2 participants 4 messages Mar 24, 2025 – Apr 21, 2025 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

Crag Wang

author
#0 lore raw

PATCH 1/1 r8169: add module parameter aspm_en_force

ASPM is disabled by default and is enabled if the chip register is pre-configured, as explained in #c217ab7.

A module parameter is being added to the driver to allow users to override the default setting. This allows users to opt in and forcefully enable or disable ASPM power-saving mode.

-1: default unset
0: ASPM disabled forcefully
1: ASPM enabled forcefully

---
 drivers/net/ethernet/realtek/r8169_main.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/ethernet/realtek/r8169_main.c +12 -0
index 53e541ddb439..161b2f2edf52 100644
@@ -35,6 +35,10 @@
 #include "r8169.h"
 #include "r8169_firmware.h"
 
+static int aspm_en_force = -1;
+module_param(aspm_en_force, int, 0444);
+MODULE_PARM_DESC(aspm_en_force, "r8169: An integer, set 1 to force enable link ASPM");
+
 #define FIRMWARE_8168D_1	"rtl_nic/rtl8168d-1.fw"
 #define FIRMWARE_8168D_2	"rtl_nic/rtl8168d-2.fw"
 #define FIRMWARE_8168E_1	"rtl_nic/rtl8168e-1.fw"
@@ -5398,6 +5402,14 @@ static void rtl_init_mac_address(struct rtl8169_private *tp)
 /* register is set if system vendor successfully tested ASPM 1.2 */
 static bool rtl_aspm_is_safe(struct rtl8169_private *tp)
 {
+	if (aspm_en_force == 0) {
+		dev_info(tp_to_dev(tp), "ASPM disabled forcefully");
+		return false;
+	} else if (aspm_en_force > 0) {
+		dev_info(tp_to_dev(tp), "ASPM enabled forcefully");
+		return true;
+	}
+
 	if (tp->mac_version >= RTL_GIGA_MAC_VER_61 &&
 	    r8168_mac_ocp_read(tp, 0xc0b2) & 0xf)
 		return true;
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 36 lines · Crag Wang

ASPM is disabled by default and is enabled if the chip register is pre-configured, as explained in #c217ab7.

A module parameter is being added to the driver to allow users to override the default setting. This allows users to opt in and forcefully enable or disable ASPM power-saving mode.

-1: default unset
0: ASPM disabled forcefully
1: ASPM enabled forcefully

---
 drivers/net/ethernet/realtek/r8169_main.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/ethernet/realtek/r8169_main.c +5 -0
index 53e541ddb439..161b2f2edf52 100644
@@ -35,6 +35,10 @@
 #include "r8169.h"
 #include "r8169_firmware.h"
 
+static int aspm_en_force = -1;
+module_param(aspm_en_force, int, 0444);
+MODULE_PARM_DESC(aspm_en_force, "r8169: An integer, set 1 to force enable link ASPM");
+
 #define FIRMWARE_8168D_1	"rtl_nic/rtl8168d-1.fw"
 #define FIRMWARE_8168D_2	"rtl_nic/rtl8168d-2.fw"
 #define FIRMWARE_8168E_1	"rtl_nic/rtl8168e-1.fw"
@@ -5398,6 +5402,14 @@ static void rtl_init_mac_address(struct rtl8169_private *tp)
 /* register is set if system vendor successfully tested ASPM 1.2 */
 static bool rtl_aspm_is_safe(struct rtl8169_private *tp)
 {
+	if (aspm_en_force == 0) {

drivers/net/ethernet/realtek/r8169_main.c static void rtl_init_mac_address(struct rtl8169_private *tp) · line 5415

Quoted 10 lines
drivers/net/ethernet/realtek/r8169_main.c +7 -0
+		dev_info(tp_to_dev(tp), "ASPM disabled forcefully");
+		return false;
+	} else if (aspm_en_force > 0) {
+		dev_info(tp_to_dev(tp), "ASPM enabled forcefully");
+		return true;
+	}
+
 	if (tp->mac_version >= RTL_GIGA_MAC_VER_61 &&
 	    r8168_mac_ocp_read(tp, 0xc0b2) & 0xf)
 		return true;

Adding module parameters is discouraged.
Also note that you have the option already to re-activate ASPM, you can use the standard PCI sysfs attributes under /sys/class/net/<if>/device/link for this.

author
#2 lore raw
Quoted 5 lines

Adding module parameters is discouraged.
Also note that you have the option already to re-activate ASPM, you can use the standard PCI sysfs attributes under /sys/class/net/<if>/device/link for this.

How about adding a quirk table for the matched DMI patterns, allowing the hardware
makers to opt-in ASPM settings in the kernel segment as an alternative to the PCI sysfs?

A message that is not in the archive (sent off-list or not yet received): CAP-8N0jAjeY8Wthta1yS8Hs57KKt6HyFWpYM6=q1t+jxF_sY1A@mail.gmail.com

maintainer
#4 lore raw
Quoted 9 lines · Crag Wang

Adding module parameters is discouraged.
Also note that you have the option already to re-activate ASPM, you can use the standard PCI sysfs attributes under /sys/class/net/<if>/device/link for this.

How about adding a quirk table for the matched DMI patterns, allowing the hardware makers to opt-in ASPM settings in the kernel segment as an alternative to the PCI sysfs?

There is already such an option, see rtl_aspm_is_safe().