linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How does Linux handle PCI-E Surprise unplug?
@ 2010-02-18  6:17 Rajat Jain
  2010-02-18 14:52 ` Greg KH
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Rajat Jain @ 2010-02-18  6:17 UTC (permalink / raw)
  To: linux-hotplug

Hi,

I'm keen to understand how the Linux kernel handles surprise removal of
a device, from a PCI-e slot that supports "Hot-plug Surprise" removal
(in slot capabilities). 

Consider that the device in the slot is working normally, with its
driver attached to the device, and is doing all sorts of read / write
operations on the device registers that have been mapped into the PCI
memory space. Now when that device is suddenly plugged out (and thus its
registers suddenly disappear from the PCI memory space), the device
driver is still unaware as it is doing the register reads / writes on
the device. At this point, IMHO any attempt to access the device
registers will result in an exception (BUS error?) as the device is
gone. Correct?

From what I understood from the "pciehp.ko" code, it seems that on
detecting that a device has been plugged out, pciehp_disable_slot() is
called only in workqueue context (that will happen later). This would
lead to removal of the device from the PCI hierarchy in the kernel data
structures, and ultimately the driver will also be detached. 

But my question is that it may be too late for all of the above to
happen, and the driver code may still get a chance to run and continue
execution from where it was interrupted (accessing device registers) due
to surprise removal interrupt. And this is bound to break things. So
what am I missing here?

Thanks,

Rajat

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-03-08 22:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-18  6:17 How does Linux handle PCI-E Surprise unplug? Rajat Jain
2010-02-18 14:52 ` Greg KH
2010-02-19  4:13 ` Rajat Jain
2010-02-19  4:27 ` Greg KH
2010-02-19  6:41 ` Hidetoshi Seto
2010-03-08  7:23 ` Rajat Jain
2010-03-08  8:24 ` Kenji Kaneshige
2010-03-08 22:49 ` Grant Grundler

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).