Re: [PATCH v2 1/1] PCI: pciehp: Skip DLLSC handling if DPC is triggered

From: Lukas Wunner
Date: Sun Mar 28 2021 - 05:08:22 EST


On Sat, Mar 27, 2021 at 10:49:45PM -0700, Kuppuswamy, Sathyanarayanan wrote:
> On 3/16/21 9:13 PM, Lukas Wunner wrote:
> > --- a/drivers/pci/hotplug/pciehp_hpc.c
> > +++ b/drivers/pci/hotplug/pciehp_hpc.c
> > @@ -707,6 +707,17 @@ static irqreturn_t pciehp_ist(int irq, void *dev_id)
> > }
> > /*
> > + * Ignore Link Down/Up caused by Downstream Port Containment
> > + * if recovery from the error succeeded.
> > + */
> > + if ((events & PCI_EXP_SLTSTA_DLLSC) && pci_dpc_recovered(pdev) &&
> > + ctrl->state == ON_STATE) {
> > + atomic_and(~PCI_EXP_SLTSTA_DLLSC, &ctrl->pending_events);
>
> Why modify pending_events here. It should be already be zero right?

"pending_events" is expected to contain the Link Up event
after successful recovery, whereas "events" contains the
Link Down event (if DPC was triggered).

pciehp is structured around the generic irq core's separation
of hardirq handler (runs in interrupt context) and irq thread
(runs in task context). The hardirq handler pciehp_isr() picks
up events from the Slot Status register and stores them in
"pending_events" for later consumption by the irq thread
pciehp_ist(). The irq thread performs long running tasks such
as slot bringup and bringdown. The irq thread is also allowed
to sleep.

While pciehp_ist() awaits completion of DPC recovery, a DLLSC
event will be picked up by pciehp_isr() which is caused by
link retraining. That event is contained in "pending_events",
so after successful recovery, pciehp_ist() can just delete it.

Thanks,

Lukas