Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:pcie:hot-reset-linux [2019/04/16 21:01] – alex | en:pcie:hot-reset-linux [2020/04/29 05:59] (current) – alex | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| Resets in PCI express are a bit complex. There are two main types of resets - conventional reset, and function-level reset. There are also two types of conventional resets, fundamental resets and non-fundamental resets. See the PCI express specification for all of the details. | Resets in PCI express are a bit complex. There are two main types of resets - conventional reset, and function-level reset. There are also two types of conventional resets, fundamental resets and non-fundamental resets. See the PCI express specification for all of the details. | ||
| - | A 'cold reset' is a fundamental reset that takes place after power is applied to a PCIe device. There appears to be no standard way of triggering a cold reset, save for turning the system off and back on again. On my machines, the / | + | A 'cold reset' is a fundamental reset that takes place after power is applied to a PCIe device. There appears to be no standard way of triggering a cold reset, save for turning the system off and back on again. On my machines, the '' |
| A 'warm reset' is a fundamental reset that is triggered without disconnecting power from the device. There appears to be no standard way of triggering a warm reset. | A 'warm reset' is a fundamental reset that is triggered without disconnecting power from the device. There appears to be no standard way of triggering a warm reset. | ||
| Line 11: | Line 11: | ||
| A ' | A ' | ||
| - | Linux exposes the function-level reset functionality in the form of / | + | Linux exposes the function-level reset functionality in the form of '' |
| I am not aware of any ' | I am not aware of any ' | ||
| - | <code sh> | + | < |
| #!/bin/bash | #!/bin/bash | ||
| Line 25: | Line 25: | ||
| exit 1 | exit 1 | ||
| fi | fi | ||
| + | |||
| + | if [ ! -e "/ | ||
| + | dev=" | ||
| + | fi | ||
| + | |||
| + | if [ ! -e "/ | ||
| + | echo " | ||
| + | exit 1 | ||
| + | fi | ||
| + | |||
| + | port=$(basename $(dirname $(readlink "/ | ||
| + | |||
| + | if [ ! -e "/ | ||
| + | echo " | ||
| + | exit 1 | ||
| + | fi | ||
| + | |||
| + | echo " | ||
| + | |||
| + | echo 1 > "/ | ||
| + | |||
| + | echo " | ||
| + | |||
| + | bc=$(setpci -s $port BRIDGE_CONTROL) | ||
| + | |||
| + | echo " | ||
| + | |||
| + | setpci -s $port BRIDGE_CONTROL=$(printf " | ||
| + | sleep 0.01 | ||
| + | setpci -s $port BRIDGE_CONTROL=$bc | ||
| + | sleep 0.5 | ||
| + | |||
| + | echo " | ||
| + | |||
| + | echo 1 > "/ | ||
| </ | </ | ||
| Line 30: | Line 65: | ||
| Ensure that all attached drivers are unloaded before running this script. This script will attempt to remove the PCIe device, then command the upstream switch port to issue a hot reset, then attempt to rescan the PCIe bus. This script has also only been tested on devices with a single function, so it may need some reworking for devices with multiple functions. | Ensure that all attached drivers are unloaded before running this script. This script will attempt to remove the PCIe device, then command the upstream switch port to issue a hot reset, then attempt to rescan the PCIe bus. This script has also only been tested on devices with a single function, so it may need some reworking for devices with multiple functions. | ||
| + | [[https:// | ||