@
FireDrunk ik heb nog eens wat onderzoek gedaan voor de H610T naar aanleiding van
deze post waarin verwezen wordt naar
deze informatie. Ik heb dit inmiddels getest met Debian 12, Ubuntu 23.10 en UnRaid, allemaal
werkend op L1 ASPM. (Ook getest op mijn andere machine die L1 en L0s nu ondersteund met een Realtek NIC!)
Het handmatig instellen van de "Link Control Register" bood geen oplossing:
Bash:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| root@--:~# lspci -s 00:1c.2 -xxx
00:1c.2 PCI bridge: Intel Corporation Device 7aba (rev 11)
00: 86 80 ba 7a 07 04 10 00 11 00 04 06 10 00 81 00
10: 00 00 00 00 00 00 00 00 00 03 03 00 30 30 00 00
20: a0 84 a0 84 f1 ff 01 00 00 00 00 00 00 00 00 00
30: 00 00 00 00 40 00 00 00 00 00 00 00 ff 03 12 00
40: 10 80 42 01 01 80 00 00 0f 00 10 00 13 48 73 03
50: 42 00 11 70 00 b2 34 00 00 00 40 00 08 00 00 00
60: 00 00 00 00 37 08 b8 00 00 04 00 00 0e 00 80 01
70: 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00
80: 05 98 81 00 78 02 e0 fe 00 00 00 00 00 00 00 00
90: 00 00 00 00 00 00 00 00 0d a0 00 00 43 10 94 86
a0: 01 00 03 c8 00 00 00 00 00 00 00 00 00 00 00 00
b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
d0: 01 00 00 0e 42 18 01 40 08 00 1e 09 00 00 00 00
e0: 00 03 41 00 00 00 00 00 04 00 81 00 00 00 00 00
f0: 70 01 00 00 00 00 00 00 00 0f 11 00 00 00 00 03 |
Het vinden van de juiste setting werkt wat rekenwerk maar is als volgt te doen:
1. Kijk naar Regel 30 - stuk 5. Daar zie je 40 staan.
2. Verwezen naar regel 40. Begint het eerste stuk op 10? Dan tel je deze bij elkaar op 40 + 10 = 50
3. We weten nu dat ASPM parameter op regel 50 zit.
4. De eerste waarde kan 40 / 41 / 42 / 43 zijn. In mijn geval 42.
code:
1
2
3
4
| 40 = 0b00 = L0 only
41 = 0b01 = L0s only
42 = 0b10 = L1 only
43 = 0b11 = L1 and L0s |
Dat betekent dat ASPM L1 actief hoorde te zijn. In de praktijk stond ie niet aan. Na het handmatig instellen op 43 kon ik uitlezen dat de waarde daadwerkelijk aangepast werd.
Bash:
1
2
3
4
5
6
7
8
9
10
11
| # Disables ASPM, enables only L0 (this was the existing setting)
sudo setpci -s 00:1c.2 0x50.B=0x40
# Enable L0s only
sudo setpci -s 00:1c.2 0x50.B=0x41
# Enable L1 only
sudo setpci -s 00:1c.2 0x50.B=0x42
# Enable L1 and L0s
sudo setpci -s 00:1c.2 0x50.B=0x43 |
Echter deed de NIC / of het OS helemaal niets met deze informatie. Na een reboot was de aangepaste waarde ook weer terug op default 42. Dit werkte dus niet.
-------------------------------------------
-------------------------------------------
Na de documentatie nog eens uit te lezen zag ik een verwijzing naar een website voor "
enable_aspm". Alleen die website werkt niet meer. Via
WayBack Machine heb ik het script alsnog kunnen vinden.
Instellen van L1 en L0s zorgde voor een hoger verbruik. Duidelijk te merken dat BIOS / NIC dit niet ondersteunt.
Na het instellen van L1 (ook al stond de waarde daar al op) gaat de NIC tot en met C8.
code:
1
2
3
4
5
6
7
| C2 (pc2) 1.8%
C3 (pc3) 0.0%
C6 (pc6) 0.3%
C7 (pc7) 0.0%
C8 (pc8) 86.7%
C9 (pc9) 0.0%
C10 (pc10) 0.0% |
Resultaat? 5.xx watt lager verbruik vergeleken met default!
Code voor Asus H610T:
Bash:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
| #!/bin/bash
# Copyright (c) 2010-2013 Luis R. Rodriguez <mcgrof@do-not-panic.com>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# ASPM Tuning script
#
# This script lets you enable ASPM on your devices in case your BIOS
# does not have it enabled for some reason. If your BIOS does not have
# it enabled it is usually for a good reason so you should only use this if
# you know what you are doing. Typically you would only need to enable
# ASPM manually when doing development and using a card that typically
# is not present on a laptop, or using the cardbus slot. The BIOS typically
# disables ASPM for foreign cards and on the cardbus slot. Check also
# if you may need to do other things than what is below on your vendor
# documentation.
#
# To use this script You will need for now to at least query your device
# PCI endpoint and root complex addresses using the convention output by
# lspci: [<bus>]:[<slot>].[<func>]
#
# For example:
#
# 03:00.0 Network controller: Atheros Communications Inc. AR9300 Wireless LAN adaptor (rev 01
# 00:1c.1 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 2 (rev 03)
#
# The root complex for the endpoint can be found using lspci -t
#
# For more details refer to:
#
# http://wireless.kernel.org/en/users/Documentation/ASPM
# You just need to modify these three values:
#ROOT_COMPLEX="00:1c.1"
#ROOT_COMPLEX="00:1e.0"
ROOT_COMPLEX="00:1c.2"
#ENDPOINT="03:00.0"
#ENDPOINT="05:00.0"
ENDPOINT="03:00.0"
# We'll only enable the last 2 bits by using a mask
# of :3 to setpci, this will ensure we keep the existing
# values on the byte.
#
# Hex Binary Meaning
# -------------------------
# 0 0b00 L0 only
# 1 0b01 L0s only
# 2 0b10 L1 only
# 3 0b11 L1 and L0s
ASPM_SETTING=2
function aspm_setting_to_string()
{
case $1 in
0)
echo -e "\t${BLUE}L0 only${NORMAL}, ${RED}ASPM disabled${NORMAL}"
;;
1)
;;
2)
echo -e "\t${GREEN}L1 only${NORMAL}"
;;
3)
echo -e "\t${GREEN}L1 and L0s${NORMAL}"
;;
*)
echo -e "\t${RED}Invalid${NORMAL}"
;;
esac
}
###################################################################
# Do not edit below here unless you are sending me a patch
###################################################################
#
# TODO: patches are welcomed to me until we submit to to
# PCI Utilities upstream.
#
# This can be improved by in this order:
#
# * Accept arguments for endpoint and root complex address, and
# desired ASPM settings
# * Look for your ASPM capabilities by quering your
# LnkCap register first. Use these values to let you
# select whether you want to enable only L1 or L1 & L0s
# * Searching for your root complex for you
# * Search for your PCI device by using the driver
# * Disable your driver and ask to reboot ?
# * Rewrite in C
# * Write ncurses interface [ wishlist ]
# * Write GTK/QT interface [ wishlist ]
# * Submit upstream as aspm.c to the PCI Utilities, which are
# maintained by Martin Mares <mj@ucw.cz>
# Pretty colors
GREEN="\033[01;32m"
YELLOW="\033[01;33m"
NORMAL="\033[00m"
BLUE="\033[34m"
RED="\033[31m"
PURPLE="\033[35m"
CYAN="\033[36m"
UNDERLINE="\033[02m"
# we can surely read the spec to get a better value
MAX_SEARCH=20
SEARCH_COUNT=1
ASPM_BYTE_ADDRESS="INVALID"
ROOT_PRESENT=$(lspci | grep -c "$ROOT_COMPLEXT")
ENDPOINT_PRESENT=$(lspci | grep -c "$ENDPOINT")
if [[ $(id -u) != 0 ]]; then
echo "This needs to be run as root"
exit 1
fi
if [[ $ROOT_PRESENT -eq 0 ]]; then
echo "Root complex $ROOT_COMPLEX is not present"
exit
fi
if [[ $ENDPOINT_PRESENT -eq 0 ]]; then
echo "Endpoint $ENDPOINT is not present"
exit
fi
# XXX: lspci -s some_device_not_existing does not return positive
# if the device does not exist, fix this upstream
function device_present()
{
PRESENT=$(lspci | grep -c "$1")
COMPLAINT="${RED}not present${NORMAL}"
if [[ $PRESENT -eq 0 ]]; then
if [[ $2 != "present" ]]; then
COMPLAINT="${RED}disappeared${NORMAL}"
fi
echo -e "Device ${BLUE}${1}${NORMAL} $COMPLAINT"
return 1
fi
return 0
}
function find_aspm_byte_address()
{
device_present $ENDPOINT present
if [[ $? -ne 0 ]]; then
exit
fi
SEARCH=$(setpci -s $1 34.b)
# We know on the first search $SEARCH will not be
# 10 but this simplifies the implementation.
while [[ $SEARCH != 10 && $SEARCH_COUNT -le $MAX_SEARCH ]]; do
END_SEARCH=$(setpci -s $1 ${SEARCH}.b)
# Convert hex digits to uppercase for bc
SEARCH_UPPER=$(printf "%X" 0x${SEARCH})
if [[ $END_SEARCH = 10 ]]; then
ASPM_BYTE_ADDRESS=$(echo "obase=16; ibase=16; $SEARCH_UPPER + 10" | bc)
break
fi
SEARCH=$(echo "obase=16; ibase=16; $SEARCH + 1" | bc)
SEARCH=$(setpci -s $1 ${SEARCH}.b)
let SEARCH_COUNT=$SEARCH_COUNT+1
done
if [[ $SEARCH_COUNT -ge $MAX_SEARCH ]]; then
echo -e "Long loop while looking for ASPM word for $1"
return 1
fi
return 0
}
function enable_aspm_byte()
{
device_present $1 present
if [[ $? -ne 0 ]]; then
exit
fi
find_aspm_byte_address $1
if [[ $? -ne 0 ]]; then
return 1
fi
ASPM_BYTE_HEX=$(setpci -s $1 ${ASPM_BYTE_ADDRESS}.b)
ASPM_BYTE_HEX=$(printf "%X" 0x${ASPM_BYTE_HEX})
# setpci doesn't support a mask on the query yet, only on the set,
# so to verify a setting on a mask we have no other optoin but
# to do do this stuff ourselves.
DESIRED_ASPM_BYTE_HEX=$(printf "%X" $(( (0x${ASPM_BYTE_HEX} & ~0x7) |0x${ASPM_SETTING})))
if [[ $ASPM_BYTE_ADDRESS = "INVALID" ]]; then
echo -e "No ASPM byte could be found for $(lspci -s $1)"
return
fi
echo -e "$(lspci -s $1)"
echo -en "\t${YELLOW}0x${ASPM_BYTE_ADDRESS}${NORMAL} : ${CYAN}0x${ASPM_BYTE_HEX}${GREEN} --> ${BLUE}0x${DESIRED_ASPM_BYTE_HEX}${NORMAL} ... "
device_present $1 present
if [[ $? -ne 0 ]]; then
exit
fi
# Avoid setting if already set
if [[ $ASPM_BYTE_HEX = $DESIRED_ASPM_BYTE_HEX ]]; then
echo -e "[${GREEN}SUCESS${NORMAL}] (${GREEN}already set${NORMAL})"
aspm_setting_to_string $ASPM_SETTING
return 0
fi
# This only writes the last 3 bits
setpci -s $1 ${ASPM_BYTE_ADDRESS}.b=${ASPM_SETTING}:3
sleep 3
ACTUAL_ASPM_BYTE_HEX=$(setpci -s $1 ${ASPM_BYTE_ADDRESS}.b)
ACTUAL_ASPM_BYTE_HEX=$(printf "%X" 0x${ACTUAL_ASPM_BYTE_HEX})
# Do not retry this if it failed, if it failed to set.
# Likey if it failed its a good reason and you should look
# into that.
if [[ $ACTUAL_ASPM_BYTE_HEX != $DESIRED_ASPM_BYTE_HEX ]]; then
echo -e "\t[${RED}FAIL${NORMAL}] (0x${ACTUAL_ASPM_BYTE_HEX})"
return 1
fi
echo -e "\t[${GREEN}SUCCESS]${NORMAL}]"
aspm_setting_to_string $ASPM_SETTING
return 0
}
device_present $ENDPOINT not_sure
if [[ $? -ne 0 ]]; then
exit
fi
echo -e "${CYAN}Root complex${NORMAL}:"
enable_aspm_byte $ROOT_COMPLEX
echo
echo -e "${CYAN}Endpoint${NORMAL}:"
enable_aspm_byte $ENDPOINT
echo |
Deze code kan gebruikt worden voor alle PCI devices overigens. Ik heb het script in een bash script gezet en vervolgens in een crontab @reboot. Tijdens het booten van de machine zie ik ook daadwerkelijk de NIC eventjes uit/aan gaan. Ik verwacht ergens nog een mogelijkheid tot het verlagen van het idle verbruik op andere PCI devices.
Met de volgende hardware behaal ik nu 6.36w idle.
MOBO: Asus Pro H610T
CPU: i7 12700T
SSD0: Samsung 980 Pro 2TB NVME
SSD1: Samsung 870 EVO 8TB SATA
SSD2: Samsung 870 EVO 8TB SATA
MEM: 2x 32GB DDR4 sodimm (Crucial CT32G4SFD832A)
FAN: 2x 4020mm fans (Noctua NF-A4x20-PWM, 40mm)