Re: [PATCH v2 2/2] PCI: pciehp: Prevent deadlock on disconnect

From: Mika Westerberg
Date: Mon Aug 19 2019 - 04:56:27 EST


On Sun, Aug 18, 2019 at 10:28:13PM -0400, Sinan Kaya wrote:
> On 8/12/2019 10:31 AM, Mika Westerberg wrote:
> > +int pciehp_card_present_or_link_active(struct controller *ctrl)
> > {
> > - return pciehp_card_present(ctrl) || pciehp_check_link_active(ctrl);
> > + int ret;
> > +
> > + ret = pciehp_card_present(ctrl);
> > + if (ret)
> > + return ret;
> > +
> > + return pciehp_check_link_active(ctrl);
>
> The semantics of this function changed here. Before it was checking for
> either presence detect bit or link active bit. Now, it is looking to
> have both set.

Hmm, maybe I haven't got enough coffee yet but I'm not sure I understand :)
The intention was that the above two are equivalent with the exception
of handling the possible error.

> There are PCI controllers that won't report presence detect correctly,
> but still report link active.

If that's the case then pciehp_card_present() returns false so we call
pciehp_check_link_active() which should work with those controllers.

What I'm missing here?