This article is part of a three-part series on PCIe PERST#.
Now that we have a clear understanding about how PERST#’s routing on an AIC board as well as an SoC, let us examine some design ideas on SoCs and AIC boards with reference to PERST#
Depending on the power, clock, and reset domain, some registers may not be accessible during the time PERST# is asserted. Worse yet, some registers are readable (reads reset values) but silently discards the written value. SoC designers are strongly recommended to document the correct register file behavior so that firmware access won’t cause surprises later during bring-up phase.
If the SoC is targeted at AIC designs, to meet the AIC timing specification with reference to PERST#, the LTSSM must enter Detect within 20 ms of PERST# deassertion. Since PERST# can deassert as early as 100 ms after power is stable, that leaves roughly 120 ms from power-good in the worst case. This is a very tight timeline to meet for an SoC that has to do LBIST/MBIST as a part of hardware initialization. Please consider a small boot island with minimal subsystems if you are targeting such markets.
For the ease of software implementation a few board designs features PERST# triggering a board reset. This is a BAD design on multiple counts
The spec guarantees a minimum of 100us between stable REFCLK to PERST# deassert. But, if your clock generator (or parts of clock tree) requires more time than that to produce stable clock outputs, a small (often configurable) delay circuit may be introduced. This could help you in avoiding very weird situations like the PHY behaving badly when its brought out of reset without a stable clock … and other very hard to debug component/IP behaviors.
If your SoC does not provide a method to generate interrupts (as described previously), it would be a good option to connect PERST# to a GPIO pin that can be configured as an input which can be read by firmware determine the PERST# state. This pin can be configured as an interrupt in the GPIO block, but may entail a few problems because:
An interrupt source, with the facility to read the current value would be the ideal solution. Otherwise, a polling routine set up at sub-millisecond interval would be sufficient.
The following table lists various initializations the system firmware executes that are typically associated with different types of host’s booting
| Action by AIC firmware | Host Cold boot | Host Warm boot |
|---|---|---|
| OCM initialization | YES | NO |
| NOC initialization | YES | NO |
| MUX programming (can be several levels of multiplexers) | YES | NO |
| SIO/GPIO controller initialization | YES | NO |
| PHY reset sequence | YES | YES |
| PHY uC firmware loading and stabilization | YES | YES |
| PCIe controller reset sequence | YES | YES |
| PCIe register configuration (DBI) | YES | YES |
| GPIO block initialization | YES | NO |
| UART (for debug messages) | YES | NO |
DDR initialization (due to large configuration and training time) and non-essential non-pcie subsystems (ethernet, USB, SPI, I2C/I3C, …etc) are not carried out before the PCIe initialization. Such actions are executed by either Secondary Boot Loader or the system firmware after PCIe EP init is complete.
This section describes the problems the author and team faced while debugging a knotty problem: The Gen5 AIC failed to link up on several server platforms (Intel, AMD, ARM64) during interoperability testing. After the fixes described below, it interoperates with 9 of the 10 platforms tested. The symptoms were varied – some failed to link up, some showed non-standard device ID/vendor id, some intermittently failed, and some other behaved differently across cold and warm boot cycles.
The SoC featured a well known IP vendor’s PCIe core configured as EP(by firmware, not strapped) and PHY with the following characteristics:
The AIC design was supposed to connect PERST# to a GPIO pin, but this requirement was missed out from the board design and was not noticed until it was too late!
As described previously, this was BAD! This worked well in theory, but caused a significant number of unrelated software errors due to flash corruption. Trying to change the file system to more robust ones with journaling did not help much, just delayed the problems. Trying to run the root FS from memory was not feasible as the application required every byte of memory that can be made available, especially with the high cost of DDR now!
The most unexpected side effect was that the EP failed the timing requirement during the PCIe certification. It took about 20ms for the power rails to stabilize after board reset was deasserted. The EP’s LTSSM entered Detect about 68 ms after PERST# deassertion, more than three times the 20 ms limit!
Since the IP used could generate an interrupt on a link down event (technically two: One for LDE and one for surprise LDE), an interrupt handler was installed for serving both LDEs. The handler reads DID/VID register via DBI (for want of any better method). If read the reset values (that of the vendor), it conveyed to the software that a PERST occurred. This register was safe to access via DBI as long as the core_clk was active and stable. So, after checking the SoC clock tree and making sure that core_clk is driven by an independent clock source, this implementation was tried.
During normal operations, the link down event can be triggered by secondary bus reset from the downstream port, hot resets or normal link down events. These events do not cause the reset of the core and can be differentiated from PERST# assertion by reading DID/VID register contents.
Secondary Bus Reset uses Hot Reset to signal the reset and releases hot reset when directed by software on the host. Hot reset causes TS1s with hot reset bit set. The LTSSM leaves the current state (L0) and enter hot reset state for at least 2ms (or till the end of hot reset in case of software triggered SBR) before exiting to Detect state.
Hot reset causes the LDE but not a PERST# event. In addition to LDE, hot reset causes a hot reset interrupt to the upper layer application and is handled gracefully.
1. LDE triggers the interrupt handler that infers PERST assertion. But, it is critical to determine if the PERST deassertion. If not, the controller programming during PERST assert would be discarded silently by the PCIe core because the asserted PERST# kept the controller in reset
In order to handle this case, the interrupt handler started a poll routine to infer the PERST# deassert. The poll routine scheduled for 250us interval programmed DID/VID register once and read it back. During PERST# assert, the programmed values were lost and reset values were read. Once the read values matched the programmed values, PERST# deassert was inferred.
2. During inter-op/Compatibility testing we discovered that there are a few servers that issued multiple PERST# assertions during cold boot. This situation exposed a fatal shortcoming in the logic implemented.
During the cold boot, the firmware in the EP determines the PERST deassertion and programs the configuration space, PHY, and other components before installing the LDE interrupt handler. But, when the second PERST assertion by the host comes in, the LDE event does not occur because the link has never been established! Link down event happens only after the link has been up at least once. During the cold boot, the root port did bring its PHY out of reset and started link training only after the second PERST# assertion.
Since we cannot depend on LDEs during the host boot up state, using a timer interrupt, we implemented a FSM with three states. During cold boot, the FSM would stay in INIT state and infer the PERST# state once every 500us. First run after PERST# deassert, FSM advances to PROGRAMMED state and continue in it. FSM progresses to OPERATIONAL state once the actual link up event occurs. A PERST assert in any state would take the FSM to INIT. An ordinary link down event (or hot-reset/SBR) would cause the FSM to enter PROGRAMMED state and wait for link up event.
The idea behind Receiver Detect bitfield is that, once LTSSM enters the Detect.Active state, it would execute the Electrical Detection procedure and find if a link partner exists. This method turned out to be unreliable in some platforms. There are a few problems associated with this approach.
This register bit shows if the CDM is in reset. Whenever the controller state changes to reset (including PERST# assertion), this bit would be 1. Once PERST# is deasserted and the controller gets out of reset, will change to 0. This bit is readable irrespective of PERST and can be used as an indicator if you want to avoid read/write cycles to VID/DID register.
During SBR/Hot Reset, this bit gets asserted even when PERST# remain deasserted. So, additional checks are required to infer correct state of PERST#
Fighting a PCIe bring-up, link-training or PCI-SIG compliance issue? Bluehatsoft helps teams bring up PCIe endpoints and pass compliance. Get in touch with us or email us at contact(at-the-rate)bluehatsoft(dot)com.