本文将总结PCI&PCIe device function reset的相关内容。

1. Background

当pass-thru device时,需要reset device function。code

内核中,reset a PCI device function的函数是__pci_reset_function_locked,如有兴趣,可以深入研究。

2. Spec

3. 总结

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.

3.1 conventional reset

3.1.1 cold reset

A cold reset is a fundamental reset that takes place after power is applied to a PCIe device.
因为主电源断开后重新连接导致的复位。

3.1.2 warm reset

A warm reset is a fundamental reset that is triggered without disconnecting power from the device.
在不关闭主电源的情况下,产生的复位。

3.1.3 hot reset

A hot reset is a conventional reset that is triggered across a PCI express link. A hot reset is triggered either when a link is forced into electrical idle or by sending TS1 and TS2 ordered sets with the hot reset bit set. Software can initiate a hot reset by setting and then clearing the secondary bus reset bit in the bridge control register in the PCI configuration space of the bridge port upstream of the device.

3.2 function-level reset

A function-level reset (FLR) is a reset that affects only a single function of a PCI express device. It must not reset the entire PCIe device. Implementing function-level resets is not required by the PCIe specification. A function-level reset is initiated by setting the initiate function-level reset bit in the function’s device control register in the PCI express capability structure in the PCI configuration space.
当PCIe设备使用FLR方式进行复位时,有些与PCIe链路相关的状态和寄存器并不会被复位;还有一些特殊的配置寄存器不能被FLR方式复位,如Max_Payload_Size、RCB和一些与电源管理、流量控制和链路控制直接相关的寄存器。

4. sysfs interface

/sys/bus/pci/devices/…/reset

reset_store

1
2
3
reset_store
pci_reset_function
__pci_reset_function_locked

参考资料:

  1. PCIe扫盲——复位机制介绍
  2. How to Reset/Cycle Power to a PCIe Device?
  3. PCIe总线的两种复位方式