Bug 57961

Summary: ExpressCard hot-remove and hot-add not recognized by acpiphp
Product: Drivers Reporter: Bjorn Helgaas (bjorn)
Component: PCIAssignee: drivers_pci (drivers_pci)
Status: RESOLVED CODE_FIX    
Severity: normal CC: leho, yinghai
Priority: P1    
Hardware: All   
OS: Linux   
URL: https://lkml.kernel.org/r/CAAh6nkmbKR3HTqm5ommevsBwhL_u0N8Rk7Wsms_LfP=nBgKNew@mail.gmail.com
Kernel Version: 3.9-rc2 Subsystem:
Regression: Yes Bisected commit-id:
Attachments: dmesg log
dmesg log with Yinghai's patch
Yinghai's patch for v3.10
Backport of Yinghai's patch for v3.9

Description Bjorn Helgaas 2013-05-10 15:46:11 UTC
Created attachment 101081 [details]
dmesg log

Gavin Guo reported at
https://lkml.kernel.org/r/CAAh6nkmbKR3HTqm5ommevsBwhL_u0N8Rk7Wsms_LfP=nBgKNew@mail.gmail.com
that on his Dell M4700, a PCI-to-USB card is not automatically recognized
when it is hot-added. 
    
The attached dmesg log includes the following:
    
  - Booting with PCI-USB ExpressCard (0000:04:00.0) plugged-in
  - [    0.168087] acpiphp compiled in
  - [    0.264733] via _OSC, BIOS declines to allow OS to use pciehp
  - [  260.357099] Plugging in a USB disk
  - [  277.399921] Unplugging the USB disk
  - [  283.950198] Unplugging PCI-USB ExpressCard (\_SB_.PCI0 Bus Check)
  - [  294.437369] Plugging in PCI-USB ExpressCard (\_SB_.PCI0 Bus Check)
      
The problem seems to be that the host bridge notify handler,
_handle_hotplug_event_root(), received the Bus Check, but it did not
re-enumerate anything below the bridge.

Prior to 668192b678 ("PCI: acpiphp: Move host bridge hotplug to
pci_root.c"), this happened in _handle_hotplug_event_bridge().  After that
commit, _handle_hotplug_event_bridge() is not installed for host bridges,
and the host bridge notify handler, _handle_hotplug_event_root() did not
re-enumerate.
Comment 1 Bjorn Helgaas 2013-05-10 16:35:00 UTC
Created attachment 101091 [details]
dmesg log with Yinghai's patch

This log shows several successful add and remove events:

  - Booting with PCI-USB ExpressCard (0000:04:00.0) plugged-in
  - [   94.874289] Plug in USB disk
  - [  106.704767] Unplug USB disk
  - [  117.977820] Unplug PCI-USB ExpressCard

  - [  134.346174] Plug in PCI-USB ExpressCard
  - [  195.390379] Plug in USB disk
  - [  214.496404] Unplug USB disk
  - [  218.813946] Unplug PCI-USB ExpressCard

  - [  226.922021] Plug in PCI-USB ExpressCard
  - [  238.532679] Plug in USB disk
  - [  324.507680] Unplug USB disk
  - [  328.484411] Unplug PCI-USB ExpressCard

  - [  343.139202] Plug in PCI-USB ExpressCard (USB disk already attached)

When adding the device, we complain:

[  134.346487] pci 0000:04:00.0: reg 10: [mem 0x00000000-0x00001fff 64bit]
[  134.346715] pci 0000:04:00.0: device not available (can't reserve [mem 0x00000000-0x00001fff 64bit])
[  134.346720] pci 0000:04:00.0: Can't enable PCI device, BIOS handoff failed.

But the device seems to work anyway.  When adding a device, the BARs will be zero; that's to be expected.  We should do a better job of noticing this, and we shouldn't try to reserve that region, but that's for another bug.
Comment 2 Bjorn Helgaas 2013-05-10 17:00:45 UTC
Created attachment 101111 [details]
Yinghai's patch for v3.10

I plan to push this into v3.10.
Comment 3 Bjorn Helgaas 2013-05-10 17:01:36 UTC
Created attachment 101121 [details]
Backport of Yinghai's patch for v3.9
Comment 4 Yinghai Lu 2013-06-26 05:49:02 UTC
patch for 3.9 stable:
https://patchwork.kernel.org/patch/2676821/
Comment 5 Leho Kraav 2013-08-23 13:34:03 UTC
I'm arriving here from googling "_handle_hotplug_event_root Bus check notify on \_SB_.PCI0".

My Dell L421X is spitting this notification both when I close and open the laptop lid, one each. No ACPI LID event is emitted, which doesn't seem right.

Running on 3.10.6. Is this bug related in any way?
Comment 6 Bjorn Helgaas 2013-09-10 21:26:37 UTC
Leho, I think your Bus Check issue is different from the problem Gavin saw.  If that hasn't been fixed yet, please raise it with Rafael Wysocki <rjw@sisk.pl>, linux-acpi@vger.kernel.org, and linux-pci@vger.kernel.org.

Gavin's issue should be resolved by 3f327e39b4, which appeared in v3.10.

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=3f327e39b4
Comment 7 Leho Kraav 2013-09-10 21:31:50 UTC
Mine seems to be alive and well in 3.10.11.

I'll see what I can do about it shortly. Thanks for the help.