diff mbox series

[1/1] r8169: add module parameter aspm_en_force

Message ID 20250324125543.6723-1-crag0715@gmail.com (mailing list archive)
State Rejected
Delegated to: Netdev Maintainers
Headers show
Series [1/1] r8169: add module parameter aspm_en_force | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api fail Found: 'module_param' was: 0 now: 1
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 24 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Crag Wang March 24, 2025, 12:55 p.m. UTC
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

Signed-off-by: Crag Wang <crag0715@gmail.com>
---
 drivers/net/ethernet/realtek/r8169_main.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Heiner Kallweit March 24, 2025, 1:27 p.m. UTC | #1
On 24.03.2025 13:55, Crag Wang wrote:
> 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
> 
> Signed-off-by: Crag Wang <crag0715@gmail.com>
> ---
>  drivers/net/ethernet/realtek/r8169_main.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
> index 53e541ddb439..161b2f2edf52 100644
> --- a/drivers/net/ethernet/realtek/r8169_main.c
> +++ b/drivers/net/ethernet/realtek/r8169_main.c
> @@ -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;

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.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index 53e541ddb439..161b2f2edf52 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -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;