linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <Alex_Gagniuc@Dellteam.com>
To: <lukas@wunner.de>, <mr.nuke.me@gmail.com>
Cc: <bhelgaas@google.com>, <Austin.Bolen@dell.com>,
	<keith.busch@intel.com>, <Shyam.Iyer@dell.com>,
	<gustavo@embeddedor.com>, <linux-pci@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] PCI: pciehp: Do not turn off slot if presence comes up after link
Date: Mon, 11 Feb 2019 23:48:12 +0000	[thread overview]
Message-ID: <52afa1c45f684dbda6a8771b65583a22@ausx13mps321.AMER.DELL.COM> (raw)
In-Reply-To: 20190209115849.244u67h7wmn3eb7o@wunner.de

On 2/9/19 5:58 AM, Lukas Wunner wrote:
> 
> [EXTERNAL EMAIL]
> 
> On Tue, Feb 05, 2019 at 03:06:56PM -0600, Alexandru Gagniuc wrote:
>> According to PCIe 3.0, the presence detect state is a logical OR of
>> in-band and out-of-band presence.
> 
> Since Bjorn asked for a spec reference:
> 
> PCIe r4.0 sec 7.8.11: "Presence Detect State - This bit indicates the
> presence of an adapter in the slot, reflected by the logical OR of the
> Physical Layer in-band presence detect mechanism and, if present, any
> out-of-band presence detect mechanism defined for the slot's
> corresponding form factor."

ECN [1] was approved last November, so it's normative spec text. Sorry 
if the Ukranians didn't get ahold of it yet. I'll try to explain the delta.
There's an in-band PD supported/disable set of bits. If 'supported' is 
set, then you can set 'disable', which removes the 'logical OR" and now 
PD is only out-of-band presence.

> Table 4-14 in sec 4.2.6 is also important because it shows the difference
> between Link Up and in-band presence.

So, we'd expect PD to come up at the same time or before DLL?

>> With this, we'd expect the presence
>> state to always be asserted when the link comes up.
>>
>> Not all hardware follows this, and it is possible for the presence to
>> come up after the link. In this case, the PCIe device would be
>> erroneously disabled and re-probed. It is possible to distinguish
>> between a delayed presence and a card swap by looking at the DLL state
>> changed bit -- The link has to come down if the card is removed.
> 
> So in reality, PDC and DLLSC events rarely come in simultaneously and
> we do allow some leeway in pcie_wait_for_link(), it's just not enough
> in your particular case due to the way presence is detected by the
> platform.
> 
> I think in this case instead of changing the behavior for everyone,
> it's more appropriate to add a quirk for your hardware.  Two ideas:
> 
> * Amend pcie_init() to set slot_cap |= PCI_EXP_SLTCAP_ABP.  Insert
>    this as a quirk right below the existing Thunderbolt quirk and
>    use PCI vendor/device IDs and/or DMI checks to identify your
>    particular hardware.  If the ABP bit is set, PDC events are not
>    enabled by pcie_enable_notification(), so you will solely rely on
>    DLLSC events.  Problem solved.  (Hopefully.)
> 
> * Alternatively, add a DECLARE_PCI_FIXUP_FINAL() quirk which sets
>    pdev->link_active_reporting = false.  This causes pcie_wait_for_link()
>    to wait 1100 msec before the hot-added device's config space is
>    accessed for the first time.

These are both hacks right? We're declaring something untrue about the 
hardware because we want to obtain a specific side-effect. BUt the 
side-effects are not guaranteed not to change.

> Would this work for you?

I'm certain it's doable. In theory one could use the PCI ID of the DP, 
and the vendor and machine names to filter the quirk. But what happens 
in situations where the same PCI ID switch is used in different parts of 
the system? You want the quirk here or not there. It quickly becomes a 
shartstorm.

I'd like a generic solution. I suspect supporting 'in-band PD disabled' 
and quirking for that would be a saner way to do things. If we support 
it, then we need to handle PDSC after DLLSC scenarios anyway.

Alex

[1] PCI-SIG ENGINEERING CHANGE NOTICE
	Async Hot-Plug Updates
	Nov 29, 2018

  reply	other threads:[~2019-02-11 23:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-05 21:06 [PATCH] PCI: pciehp: Do not turn off slot if presence comes up after link Alexandru Gagniuc
2019-02-08 19:56 ` Bjorn Helgaas
2019-02-09 11:58 ` Lukas Wunner
2019-02-11 23:48   ` Alex_Gagniuc [this message]
2019-02-12  8:30     ` Lukas Wunner
2019-02-12 10:37       ` Lukas Wunner
2019-02-12 23:57       ` Alex_Gagniuc
2019-02-13  8:36         ` Lukas Wunner
2019-02-13 18:55           ` Alex_Gagniuc
2019-02-14  7:01             ` Lukas Wunner
2019-02-14 19:26               ` Alex_Gagniuc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52afa1c45f684dbda6a8771b65583a22@ausx13mps321.AMER.DELL.COM \
    --to=alex_gagniuc@dellteam.com \
    --cc=Austin.Bolen@dell.com \
    --cc=Shyam.Iyer@dell.com \
    --cc=bhelgaas@google.com \
    --cc=gustavo@embeddedor.com \
    --cc=keith.busch@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=mr.nuke.me@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).