mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/1] r8169: add module parameter aspm_en_force
@ 2025-03-24 12:55 Crag Wang
  2025-03-24 13:27 ` Heiner Kallweit
  0 siblings, 1 reply; 4+ messages in thread
From: Crag Wang @ 2025-03-24 12:55 UTC (permalink / raw)
  To: Heiner Kallweit, nic_swsd, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: crag.wang, dell.client.kernel, Crag Wang, netdev, linux-kernel

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;
-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] r8169: add module parameter aspm_en_force
  2025-03-24 12:55 [PATCH 1/1] r8169: add module parameter aspm_en_force Crag Wang
@ 2025-03-24 13:27 ` Heiner Kallweit
  2025-04-21  8:20   ` Crag Wang
       [not found]   ` <CAP-8N0jAjeY8Wthta1yS8Hs57KKt6HyFWpYM6=q1t+jxF_sY1A@mail.gmail.com>
  0 siblings, 2 replies; 4+ messages in thread
From: Heiner Kallweit @ 2025-03-24 13:27 UTC (permalink / raw)
  To: Crag Wang, nic_swsd, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: crag.wang, dell.client.kernel, netdev, linux-kernel

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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] r8169: add module parameter aspm_en_force
  2025-03-24 13:27 ` Heiner Kallweit
@ 2025-04-21  8:20   ` Crag Wang
       [not found]   ` <CAP-8N0jAjeY8Wthta1yS8Hs57KKt6HyFWpYM6=q1t+jxF_sY1A@mail.gmail.com>
  1 sibling, 0 replies; 4+ messages in thread
From: Crag Wang @ 2025-04-21  8:20 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: nic_swsd, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, crag.wang, dell.client.kernel,
	netdev, linux-kernel

>
> 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?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] r8169: add module parameter aspm_en_force
       [not found]   ` <CAP-8N0jAjeY8Wthta1yS8Hs57KKt6HyFWpYM6=q1t+jxF_sY1A@mail.gmail.com>
@ 2025-04-21  8:45     ` Heiner Kallweit
  0 siblings, 0 replies; 4+ messages in thread
From: Heiner Kallweit @ 2025-04-21  8:45 UTC (permalink / raw)
  To: Crag Wang
  Cc: nic_swsd, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, crag.wang, dell.client.kernel,
	netdev, linux-kernel

On 21.04.2025 10:17, Crag Wang wrote:
> 
>     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().

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-04-21  8:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-24 12:55 [PATCH 1/1] r8169: add module parameter aspm_en_force Crag Wang
2025-03-24 13:27 ` Heiner Kallweit
2025-04-21  8:20   ` Crag Wang
     [not found]   ` <CAP-8N0jAjeY8Wthta1yS8Hs57KKt6HyFWpYM6=q1t+jxF_sY1A@mail.gmail.com>
2025-04-21  8:45     ` Heiner Kallweit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®