Add two helpers:BUS_RESET() method is implemented for pcie buses and pci devices.
For pcie bus,
- pci_hard_reset() for plain hard reset of a pci device. If device is PCIe and has upstream port, toggle the link and retrain it afterwards. Otherwise, fall back to D0->D3->D0 power reset. The function is raw, it is up to caller to ensure that reset is safe. Use this for ppt(4) instead of open-coding power reset.all devices below the bus are detached or suspended
- pcie_down_port_link_reset() detaches the drivers from all sibling functions behind- BUS_RESET_PREPARE() is called on each child
- the link is disabled on the same updownstream port, and save/restore configuration around the linkthen retrained
- BUS_RESET_POST() is called on each child
- all children are re-attached or unsuspended.
PCIe standard only mentions that link disable causes conventional reset. This function can be safely used by drivers without needing to handle pci config state or other functions in multi-functions cardsRe-train does not seem to be automatic after the link is re-enabled.
For pci devices, the same dance with detach/prepare and post/reattach is done, but FLR is tried, then power reset if no FLR or FLR failed.
Sponsored by: Mellanox Technologies