Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
en:pcie:hot-reset-linux [2019/04/16 23:00]
alex
en:pcie:hot-reset-linux [2019/04/16 23:01]
alex
Line 15: Line 15:
 I am not aware of any '​nice'​ method for triggering a hot reset (there is no sysfs entry for that). However, it is possible to use setpci to do so with the following script: I am not aware of any '​nice'​ method for triggering a hot reset (there is no sysfs entry for that). However, it is possible to use setpci to do so with the following script:
  
- +<​code ​sh>
- +
-<​code>​+
  
 #!/bin/bash #!/bin/bash
Line 27: Line 25:
     exit 1     exit 1
 fi fi
- 
-if [ ! -e "/​sys/​bus/​pci/​devices/​$dev"​ ]; then 
-    dev="​0000:​$dev"​ 
-fi 
- 
-if [ ! -e "/​sys/​bus/​pci/​devices/​$dev"​ ]; then 
-    echo "​Error:​ device $dev not found" 
-    exit 1 
-fi 
- 
-port=$(basename $(dirname $(readlink "/​sys/​bus/​pci/​devices/​$dev"​))) 
- 
-if [ ! -e "/​sys/​bus/​pci/​devices/​$port"​ ]; then 
-    echo "​Error:​ device $port not found" 
-    exit 1 
-fi 
- 
-echo "​Removing $dev..."​ 
- 
-echo 1 > "/​sys/​bus/​pci/​devices/​$dev/​remove"​ 
- 
-echo "​Performing hot reset of port $port..."​ 
- 
-bc=$(setpci -s $port BRIDGE_CONTROL) 
- 
-echo "​Bridge control:"​ $bc 
- 
-setpci -s $port BRIDGE_CONTROL=$(printf "​%04x"​ $(("​0x$bc"​ | 0x40))) 
-sleep 0.01 
-setpci -s $port BRIDGE_CONTROL=$bc 
-sleep 0.5 
- 
-echo "​Rescanning bus..."​ 
- 
-echo 1 > "/​sys/​bus/​pci/​devices/​$port/​rescan"​ 
  
 </​code>​ </​code>​