Coder Social home page Coder Social logo

r8169's Introduction

Maybe deprecated since 4.19

I haven't verified power consumption on linux > 4.19 but there seems to be some ASPM related change: https://github.com/torvalds/linux/commit/a99790bf5c7f3d68d8b01e015d3212a98ee7bd57

r8169

ASPM [1] is disabled for Realtek network chips by default when running linux. This leads to a vast increase in power consumption on certain systems. This patch enables ASPM on some chips to prolong battery life and decrease cpu temperature.

Details

Due to the reported regressions that have been reported for the ASPM patch [2] it had been reverted several years ago. Nevertheless similar modifications on the driver work perfectly on my notebook by now. This repository contains the modificated driver thus ASPM can be enabled by a modprobe option. If there are more people that report it's running stable a pull request will be sent to linux upstream. On my notebook this module decreased the system power consumption from 13W to 8W, as the cpu was prohibited from entering low package sleep states (PC6/PC7) before.

To check if you are affected of this problem, too you can run

watch -n1 sudo cpupower monitor

For a haswell system on idle output should look something like that:

CPU C3 C6 PC3 PC6 C7 PC2 PC7 C0 Cx Freq POLL C1-H C1E- C3-H C6-H C7s-
0 0,28 0,04 6,84 50,04 94,53 31,23 0,00 3,23 96,77 2469 0,00 0,73 0,31 0,31 0,04 95,21
4 0,28 0,04 6,84 50,04 94,53 31,23 0,00 0,70 99,30 2386 0,00 0,00 0,00 0,00 0,00 99,67
1 0,21 0,04 6,84 50,04 97,47 31,23 0,00 1,51 98,49 2773 0,00 0,00 0,02 0,19 0,10 98,53
5 0,21 0,04 6,84 50,04 97,47 31,23 0,00 0,72 99,28 2363 0,00 0,00 0,02 0,11 0,00 99,52
2 0,16 0,01 6,84 50,04 97,35 31,23 0,00 1,52 98,48 2493 0,00 0,00 0,00 0,21 0,00 98,59
6 0,16 0,01 6,84 50,04 97,36 31,23 0,00 0,57 99,43 2334 0,00 0,00 0,00 0,10 0,00 99,70
3 0,24 0,00 6,84 50,04 95,19 31,23 0,00 1,54 98,46 2435 0,00 0,00 0,00 0,10 0,00 98,64
7 0,24 0,00 6,84 50,04 95,19 31,23 0,00 2,26 97,74 2465 0,00 0,00 0,01 0,21 0,00 97,77

States with a higher numbers are deeper thus the cores should be in C7s the package (the states that start with a 'P') should be in PC6 or higher for more than 50%. PC7 is only used when display is turned off.

As long as a single device or prevents the cpu from sleeping the result looks similar to that:

CPU C3 C6 PC3 PC6 C7 PC2 PC7 C0 Cx Freq POLL C1-H C1E- C3-H C6-H C7s-
0 0,11 0,10 76,37 0,00 95,81 17,02 0,00 1,90 98,10 2484 0,00 1,27 0,30 0,11 0,10 96,25
4 0,11 0,10 76,37 0,00 95,81 17,02 0,00 0,58 99,42 2707 0,00 0,00 0,00 0,04 0,00 99,65
1 0,03 0,08 76,37 0,00 98,18 17,02 0,00 0,83 99,17 2598 0,00 0,00 0,10 0,00 0,08 99,27
5 0,03 0,08 76,37 0,00 98,18 17,02 0,00 0,49 99,51 2716 0,00 0,00 0,01 0,03 0,00 99,73
2 0,06 0,12 76,37 0,00 97,86 17,02 0,00 1,25 98,75 2497 0,00 0,00 0,00 0,07 0,06 98,78
6 0,06 0,12 76,37 0,00 97,86 17,02 0,00 0,59 99,41 2661 0,00 0,00 0,00 0,00 0,06 99,60
3 0,00 0,07 76,37 0,00 98,88 17,02 0,00 0,41 99,59 2777 0,00 0,00 0,00 0,00 0,07 99,80
7 0,00 0,07 76,37 0,00 98,88 17,02 0,00 0,35 99,65 2748 0,00 0,00 0,00 0,00 0,00 99,92

PC6 and higher isn't used at all even when all cores are at a deep sleep state.

To narrow the problems that prevent the cpu from sleeping you can run

sudo lspci -vvv | fgrep "ASPM Disabled" 

To check if there are pcie devices that don't use ASPM. If it's only the realtek network card please use this driver to check if the problem is solved then.

Hints

You can't enable ASPM. The only thing you can do is NOT DISABLE it. That means, if the wrong driver, or the driver with wrong options was loaded once a COLD reboot has to be done to reset the pci device and to be able to use ASPM again. Only loading the other module won't work as less as only a warm reboot sudo reboot.

Why don't we use r8168

This driver, provided by Realtek itself, worked for me to prevent the ASPM bug. Nevertheless there had been system freezes quite regularly (every 30 seconds for about 2 seconds) thus this module was unusable for me.

Installation

Please remove/save your old r8169 module before installing this module. Its in

/var/lib/modules/$(uname -r)/kernel/drivers/net/ethernet/realtek/r8169.ko.gz

for me.

make
sudo make install
sudo depmod -a
sudo modprobe r8169

[1] https://en.wikipedia.org/wiki/Active_State_Power_Management [2] https://lkml.org/lkml/2012/11/1/216

r8169's People

Contributors

chankruze avatar jepperc avatar kastb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

r8169's Issues

Only enables ASPM L1, not L0s

And skylake does not go into PC6 when L0s is not enabled... any idea how to fix?

LnkCtl: ASPM L1 Enabled; RCB 64 bytes Disabled- CommClk+

Problem "transmit queue 0 timed out" with this patched driver

Hello,

tested this version and got much better power efficency (more than 3 watts) on an Fujitsu D3400 mainboard with an Celeron G3900 processor (Skylake).

But system losts network connection with netio stress tests, about 30 seconds every time:

[  188.786003] [drm] RC6 on
[  203.477795] r8169 0000:01:00.0 eth0: PCI error (cmd = 0xffff, status = 0xffff)
[  203.482593] r8169 0000:01:00.0 eth0: link up
[  203.496237] r8169 0000:01:00.0 eth0: link up
[  204.409424] r8169 0000:01:00.0 eth0: PCI error (cmd = 0xffff, status = 0xffff)
[  204.414806] r8169 0000:01:00.0 eth0: link up
[  204.428215] r8169 0000:01:00.0 eth0: link up
[  210.785226] [drm] RC6 on
[  232.784823] [drm] RC6 on
[  254.784358] [drm] RC6 on
[  276.783859] [drm] RC6 on
[  298.783386] [drm] RC6 on
[  312.790641] ------------[ cut here ]------------
[  312.790666] WARNING: CPU: 1 PID: 0 at /build/linux-lVEVrl/linux-4.7.8/net/sched/sch_generic.c:272 dev_watchdog+0x220/0x230
[  312.790672] NETDEV WATCHDOG: eth0 (r8169): transmit queue 0 timed out
[  312.790675] Modules linked in: cpuid msr cpufreq_stats cpufreq_userspace cpufreq_powersave cpufreq_conservative nfsd auth_rpcgss nfs_acl nfs lockd grace fscache sunrpc snd_hda_codec_hdmi snd_hda_codec_realtek snd_hda_codec_generic intel_rapl x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel kvm irqbypass crct10dif_pclmul crc32_pclmul ghash_clmulni_intel hmac drbg ansi_cprng iTCO_wdt iTCO_vendor_support evdev aesni_intel aes_x86_64 lrw gf128mul glue_helper ablk_helper cryptd snd_hda_intel pcspkr serio_raw snd_hda_codec i915 snd_hda_core snd_hwdep snd_pcm snd_timer snd soundcore i2c_i801 hci_uart btbcm btqca btintel drm_kms_helper drm mei_me bluetooth mei shpchp i2c_algo_bit fujitsu_laptop wmi intel_lpss_acpi rfkill intel_lpss mfd_core video acpi_pad tpm_crb button tpm_tis tpm vboxnetadp(OE)
[  312.790765]  vboxnetflt(OE) vboxdrv(OE) fuse autofs4 ext4 crc16 jbd2 mbcache btrfs xor raid6_pq dm_mod raid1 md_mod sg sd_mod crc32c_intel psmouse ahci libahci r8169(OE) mii xhci_pci libata xhci_hcd usbcore scsi_mod usb_common fan thermal i2c_hid hid fjes
[  312.790802] CPU: 1 PID: 0 Comm: swapper/1 Tainted: G     U     OE   4.7.0-0.bpo.1-amd64 #1 Debian 4.7.8-1~bpo8+1
[  312.790805] Hardware name: FUJITSU D3400-B1/D3400-B1, BIOS V5.0.0.11 R1.17.0 for D3400-B1x                    09/16/2016
[  312.790809]  0000000000000286 6e251c1d7a9fa6e3 ffffffff84d1c805 ffff88022f503e18
[  312.790814]  0000000000000000 ffffffff84a7c9c4 0000000000000000 ffff88022f503e70
[  312.790820]  ffff880222292000 0000000000000001 ffff8802220d5080 0000000000000001
[  312.790824] Call Trace:
[  312.790827]  <IRQ>  [<ffffffff84d1c805>] ? dump_stack+0x5c/0x77
[  312.790842]  [<ffffffff84a7c9c4>] ? __warn+0xc4/0xe0
[  312.790848]  [<ffffffff84a7ca3f>] ? warn_slowpath_fmt+0x5f/0x80
[  312.790856]  [<ffffffff84f08120>] ? dev_watchdog+0x220/0x230
[  312.790862]  [<ffffffff84f07f00>] ? dev_deactivate_queue.constprop.32+0x60/0x60
[  312.790869]  [<ffffffff84ae6910>] ? call_timer_fn+0x30/0x120
[  312.790875]  [<ffffffff84f07f00>] ? dev_deactivate_queue.constprop.32+0x60/0x60
[  312.790880]  [<ffffffff84ae7881>] ? run_timer_softirq+0x231/0x2e0
[  312.790887]  [<ffffffff84fe20b6>] ? __do_softirq+0x106/0x294
[  312.790891]  [<ffffffff84a82306>] ? irq_exit+0x86/0x90
[  312.790897]  [<ffffffff84fe1ebe>] ? smp_apic_timer_interrupt+0x3e/0x50
[  312.790901]  [<ffffffff84fe01e2>] ? apic_timer_interrupt+0x82/0x90
[  312.790903]  <EOI>  [<ffffffff84ea38e2>] ? cpuidle_enter_state+0x112/0x260
[  312.790915]  [<ffffffff84abe31e>] ? cpu_startup_entry+0x2be/0x360
[  312.790921]  [<ffffffff84a4e1c1>] ? start_secondary+0x151/0x190
[  312.790926] ---[ end trace abcf6597c4d62904 ]---
[  312.810459] r8169 0000:01:00.0 eth0: link up
[  320.782685] [drm] RC6 on

System Debian Jessie with 4.7.x backports kernel. Same problem with an 4.8.7 and 4.8.10 kernel. The original Realtek Driver r8168 is working for me, but not so much energy efficient and lesser traffic throughput.

Would really appreciate to use this with recent Kernels - any chance to pick this up again?

I've been searching intensely to understand why my system wouldn't go beyond Pkg C3 state, until I switched my RTL8111h device off in my device's BIOS. All of a sudden C9 was easily attainable.

Further digging led me here, however this wonderful initiative seems to have lost speed a while ago.

Is there any way this could be picked up again?
I've been going through the code but have to admit my amateur skills are most definitely not sufficient...

r8169 0000:02:00.0: can't disable ASPM; OS doesn't have ASPM control

I'm using latest Linux kernel 5.5.13 on Lenovo ThinkPad E585
and in dmesg I see

kernel: r8169 0000:02:00.0: can't disable ASPM; OS doesn't have ASPM control

lsmod shows

r8169                  94208  0
libphy                114688  2 r8169,realtek

So it looks like I have r8169 enabled by default from 5.5 kernel but no it sure about this error, any idea?

Compilation Failed at make command. I have grabbed the missing directory error below.

make -C /lib/modules/5.4.0-53-generic/build M=$PWD modules
make[1]: Entering directory '/usr/src/linux-headers-5.4.0-53-generic'
CC [M] /home/shrikant/r8169/r8169_aspm.o
/home/shrikant/r8169/r8169_aspm.c:28:10: fatal error: linux/pci-aspm.h: No such file or directory
#include <linux/pci-aspm.h>
^~~~~~~~~~~~~~~~~~
compilation terminated.
scripts/Makefile.build:273: recipe for target '/home/shrikant/r8169/r8169_aspm.o' failed
make[2]: *** [/home/shrikant/r8169/r8169_aspm.o] Error 1
Makefile:1757: recipe for target '/home/shrikant/r8169' failed
make[1]: *** [/home/shrikant/r8169] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.4.0-53-generic'
Makefile:5: recipe for target 'all' failed
make: *** [all] Error 2

Doesn't complile with linux-4.11.3

make -C /usr/src/linux M=$PWD modules
make[1]: Entering directory '/usr/src/linux-4.11.3-gentoo'
CC [M] /home/sasha/Activities/X62/r8169-master/r8169_aspm.o
/home/sasha/Activities/X62/r8169-master/r8169_aspm.c:8112:21: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
.ndo_get_stats64 = rtl8169_get_stats64,
^
/home/sasha/Activities/X62/r8169-master/r8169_aspm.c:8112:21: note: (near initialization for โ€˜rtl_netdev_ops.ndo_get_stats64โ€™)
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:301: /home/sasha/Activities/X62/r8169-master/r8169_aspm.o] Error 1
make[1]: *** [Makefile:1492: module/home/sasha/Activities/X62/r8169-master] Error 2
make[1]: Leaving directory '/usr/src/linux-4.11.3-gentoo'
make: *** [Makefile:5: all] Error 2

Make these changes upstream

This should really gets merged in upstream Linux, so everyone can benefit.

I can send patches to upstream if you don't know how to do it.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.