On 12/2/26 04:04, Lukas Wunner wrote:
> When PCIe r1.1 introduced hotplug support in 2005, sec 3.2.1 was amended
> to state that a transition from DL_Active to DL_Inactive must not cause a
> Surprise Down error on hotplug ports capable of surprise removal.
>
> But when PCIe r3.1 introduced DPC support in 2014, sec 6.7.6 was added
> which states that:
>
> "Async removal may result in a transition from DL_Active to DL_Down in
> the Downstream Port. This transition may result in a Surprise Down
> error."
>
> I raised this contradiction with our representative at the PCISIG Protocol
> Working Group. He noted that DL_Down is likewise nonsensical because it
> is a Status Output, not a State (sec 3.2). The PWG recently approved the
> following new language for sec 6.7.6 as erratum B157, which will appear in
> the next revision, either r7.1.1 or r7.2:
>
> "Async removal may result in a transition from DL_Active to DL_Inactive
> in the Downstream Port. Error handling for this transition is defined
> in Section 3.2.1."
>
> Commit 2ae8fbbe1cd4 ("PCI/DPC: Ignore Surprise Down error on hot removal")
> changed the DPC driver to handle Surprise Down errors per the old language
> in sec 6.7.6. This was needed for AMD Epyc systems. No Intel system is
> affected.
>
> Document the spec update in the code comment introduced by the commit to
> make it clear that the old spec language should not be followed by new
> hardware implementations.
>
> The functionality introduced by the commit might still be useful beyond
> systems which adhere to the legacy behavior of sec 6.7.6: Sec 3.2.1 does
> allow Surprise Down errors on non-surprise-capable hotplug ports. pciehp
> binds to such ports and handles removal on Surprise Down. It makes sense
> for the DPC driver not to interfere with pciehp in such cases.
>
> Fixes: 2ae8fbbe1cd4 ("PCI/DPC: Ignore Surprise Down error on hot removal")
> Signed-off-by: Lukas Wunner <[email protected]>
> Cc: [email protected] # v6.9+
> ---
Reviewed-by: Kuppuswamy Sathyanarayanan
<[email protected]>
> drivers/pci/pcie/dpc.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c
> index e030811..5538dde 100644
> --- a/drivers/pci/pcie/dpc.c
> +++ b/drivers/pci/pcie/dpc.c
> @@ -374,8 +374,10 @@ static irqreturn_t dpc_handler(int irq, void *context)
> struct pci_dev *pdev = context;
>
> /*
> - * According to PCIe r6.0 sec 6.7.6, errors are an expected side effect
> - * of async removal and should be ignored by software.
> + * From PCIe r3.1 to r7.1, sec 6.7.6 allowed Surprise Down errors as
> + * a side effect of async removal which should be ignored by software.
> + * Newer revisions point to sec 3.2.1 instead, whereby Surprise Down
> + * errors are blocked on hotplug ports capable of surprise removal.
> */
> if (dpc_is_surprise_removal(pdev)) {
> dpc_handle_surprise_removal(pdev);
--
Sathyanarayanan Kuppuswamy
Linux Kernel Developer