本文主要是介绍[PCIe] Hot reset and FLR reset Performing in linux,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
“热重置”是通过PCI Express链路触发的常规重置。当链路被迫进入电气空闲状态时,或通过发送带有热复位bit的TS1和TS2有序集来触发热复位。软件可以通过设置然后清除设备上游桥接端口的PCI配置空间中桥接控制寄存器中的辅助总线复位位来启动热复位。(下图Bridge Control Register->Secondary Bus Reset)
Secondary Bus Reset - Setting this bit triggers a hot reset on the corresponding PCI Express Port.
Software must ensure a minimum reset duration (Trst). Software and systems must honor
first-access-following-reset timing requirements defined in Section 6.6 ., unless the Readiness
Notifications mechanism (see Section 6.23 ) is used or if the Immediate Readiness bit in the relevant
Function’s Status register is Set.
Port configuration registers must not be changed, except as required to update Port status.
Default value of this bit is 0b.
“功能级别重置”(FLR)是仅影响PCI Express设备的单个功能的重置。它不得重置整个PCIe设备。 PCIe规范不需要实现功能级别的重置。通过将PCI配置空间中PCI Express功能结构中功能的设备控制寄存器中的启动功能级别复位位置1,可以启动功能级别复位。
Linux以/sys/bus/pci/devices/$dev/reset的形式公开功能级别的重置功能。向该文件写入1将启动相应功能的功能级复位。请注意,这仅影响设备的特定功能,而不影响整个设备,并且不要求设备按照PCIe规范实施功能级别的重置。
我不知道触发热重置的任何“较好”方法(没有sysfs条目)。但是,可以通过以下脚本使用setpci进行操作(其实就是写下游端口配置空间的Bridge Control Register->Secondary Bus Reset):
#!/bin/bashdev=$1if [ -z "$dev" ]; thenecho "Error: no device specified"exit 1
fiif [ ! -e "/sys/bus/pci/devices/$dev" ]; thendev="0000:$dev"
fiif [ ! -e "/sys/bus/pci/devices/$dev" ]; thenecho "Error: device $dev not found"exit 1
fiport=$(basename $(dirname $(readlink "/sys/bus/pci/devices/$dev")))if [ ! -e "/sys/bus/pci/devices/$port" ]; thenecho "Error: device $port not found"exit 1
fiecho "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:" $bcsetpci -s $port BRIDGE_CONTROL=$(printf "%04x" $(("0x$bc" | 0x40)))
sleep 0.01
setpci -s $port BRIDGE_CONTROL=$bc
sleep 0.5echo "Rescanning bus..."echo 1 > "/sys/bus/pci/devices/$port/rescan"
这篇关于[PCIe] Hot reset and FLR reset Performing in linux的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!