linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Helgaas <bhelgaas@google.com>
To: Paulo Fortuna Carvalho <pricardofc@gmail.com>
Cc: "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: Hot add a PCIe device driver upon hotplug event
Date: Fri, 23 Jan 2015 08:36:00 -0600	[thread overview]
Message-ID: <CAErSpo4bRnGkfmzLnGSUnv-aJfmZLtQ_jXhnZo+9Wm=CgHOB3A@mail.gmail.com> (raw)
In-Reply-To: <CAH9N0t_YoRZtPqWwAaNdHNW3m-HOfrCevBZGiOnM+VWGxeFwEQ@mail.gmail.com>

On Fri, Jan 23, 2015 at 5:35 AM, Paulo Fortuna Carvalho
<pricardofc@gmail.com> wrote:
> 2015-01-22 22:20 GMT, Bjorn Helgaas:

>> In your dmesg log, I see this:
>
>>   pciehp 0000:07:08.0:pcie24: pcie_isr: intr_loc 8
>>   pciehp 0000:07:08.0:pcie24: Presence/Notify input change
>>   pciehp 0000:07:08.0:pcie24: Card not present on Slot(8)
>>   pciehp 0000:07:08.0:pcie24: pcie_isr: intr_loc 8
>>   pciehp 0000:07:08.0:pcie24: Presence/Notify input change
>>   pciehp 0000:07:08.0:pcie24: Card present on Slot(8)
>
>> That means we only saw Presence Detect Changed interrupts: one for card
>> removal and another for card insertion.  We didn't see an Attention Button
>> interrupt at all.
>
> Yes, thats it. The Presence Detect Change signal is what triggers the
> uevent. We dont have an attention button in our ATCA system so we dont
> use it.

If the only signal you have is Presence Detect, I think you're out of
luck, because if Presence Detect State is "false" (see PCIe spec r3.0,
sec 7.8.11), the card is already gone and it's too late to do anything
with it.  If that's the case, you'd have to look for a software
solution, e.g., run a script when you decide to remove the card,
before you physically touch the card.

>> You can look at the Slot Status directly with "lspci -vvs07:08.0".  If you
>> do that while removing the device, e.g., run it while the handle is in
>> position #1, again in position #2, and again in position #3, you should see
>> whether there's any signal that could potentially be used to do what you
>> need.
>
> Yes. I will try to see if the handle switch can trigger an uvent
> before the remove device procedure from the system occurs. I will let
> you know the result.

Sec 6.7.3 lists the events pciehp has to work with:

- Slot events:
  - Attention Button
  - Power Fault Detected
  - MRL Sensor Changed
  - Presence Detect Changed
- Command Completed Events (this is internal to the hotplug controller)
- Data Link Layer State Changed Events

These are really the only inputs to the pciehp driver.  You apparently
don't have an Attention Button.  You do have Presence Detect and
possibly others, but I don't think they normally (other than an
Attention Button) will give you any warning before the card is
removed.

The only possibility I see is the Power Fault handling (see sec
6.7.1.8).  Depending on the form factor, there is the possibility of
independent main and auxiliary power faults.  An auxiliary power fault
can be detected and reported without affecting main power.  And it
says "For example, one form factor may remove auxiliary power when the
MRL for the slot is opened."  If your form factor does that, we might
get a Power Fault when the latch is opened, and the card would still
have main power and software should still be able to operate it.

I don't know how we would distinguish such an auxiliary power fault
from a main power fault.  Maybe a form factor spec would talk about
that.  Do you have any pointers to something like that?  If we could
figure that out, it might be possible to emit a uevent for that case.

Bjorn

  reply	other threads:[~2015-01-23 14:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-12 11:42 Hot add a PCIe device driver upon hotplug event Paulo Fortuna Carvalho
2015-01-12 16:58 ` Bjorn Helgaas
2015-01-12 17:26   ` Paulo Fortuna Carvalho
2015-01-12 17:41     ` Bjorn Helgaas
     [not found]       ` <CAH9N0t-EP9p2V3JMht1F_EyK+bOdiiH1krPLrsTMDQ_961damQ@mail.gmail.com>
2015-01-13 17:29         ` Bjorn Helgaas
     [not found]   ` <CAH9N0t8s+kcG_Qok0wpoDz9jzwvPk_QmBK_p-qbACZJjrr+iVQ@mail.gmail.com>
2015-01-22 17:41     ` Bjorn Helgaas
     [not found]       ` <CAH9N0t-+gog9wNFo7hqhzrWuttrRyf5HjjHciFrDGz1rZUiUfw@mail.gmail.com>
2015-01-22 22:20         ` Bjorn Helgaas
2015-01-23 11:35           ` Paulo Fortuna Carvalho
2015-01-23 14:36             ` Bjorn Helgaas [this message]
2015-01-27 16:31               ` Paulo Fortuna Carvalho
2015-01-27 16:43                 ` Bjorn Helgaas
2015-01-27 16:47                 ` Greg Kroah-Hartman
2015-01-27 17:10                   ` Paulo Fortuna Carvalho
     [not found]                   ` <CAH9N0t-M2QfW84Jd3fRaLr+NdFvZEkjXzrXsgncoLhtYv-xQ3g@mail.gmail.com>
     [not found]                     ` <CAH9N0t-_JbwtZeU+Kyds8=NX=CBT-+_ecKiUWPKr1zXiLKm0vQ@mail.gmail.com>
2015-01-27 17:11                       ` Greg Kroah-Hartman
     [not found]               ` <54C5EF11.8070604@desy.de>
2015-01-27 16:50                 ` Bjorn Helgaas
2015-01-28  7:51                   ` Ludwig Petrosyan

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='CAErSpo4bRnGkfmzLnGSUnv-aJfmZLtQ_jXhnZo+9Wm=CgHOB3A@mail.gmail.com' \
    --to=bhelgaas@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=pricardofc@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).