Bug 40802

Summary: Kernel does not detect JMicron card reader unless a card is inserted when the PCI bus is scanned
Product: Drivers Reporter: rocko (rockorequin)
Component: PCIAssignee: drivers_pci (drivers_pci)
Status: RESOLVED CODE_FIX    
Severity: normal CC: bjorn, drivers_mmc-sd
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 3.0.1 Subsystem:
Regression: No Bisected commit-id:
Attachments: dmesg log
acpidump
lspci -vv

Description rocko 2011-08-10 08:26:28 UTC
The card reader on my XPS 15 L502x laptop, which shows up as several devices:

05:00.0 System peripheral: JMicron Technology Corp. SD/MMC Host Controller (rev 30)
05:00.2 SD Host controller: JMicron Technology Corp. Standard SD Host Controller (rev 30)
05:00.3 System peripheral: JMicron Technology Corp. MS Host Controller (rev 30)
05:00.4 System peripheral: JMicron Technology Corp. xD Host Controller (rev 30)

*only* shows up if there is a card inserted in it when the PCI bus is scanned, which normally only happens during a reboot. 

An "echo 1 > /sys/bus/pci/rescan" as root will rescan and detect the card reader but again only if a card is inserted at the time.

This means that when you insert a card, it cannot be mounted automatically by udev unless there was a card insert when you rebooted the computer or unless you issue the command above after inserting the card.

There is more information at https://bugs.launchpad.net/ubuntu/+source/linux/+bug/703180.
Comment 1 Bjorn Helgaas 2012-10-01 20:46:38 UTC
Is this still a problem?  If so, please attach a complete dmesg log here.

If the device doesn't appear at all when no card is present, I assume there would have to be some sort of hotplug event when the card is inserted.  Does it make any difference if you load pciehp before inserting the card?
Comment 2 rocko 2012-10-05 09:24:01 UTC
Created attachment 82221 [details]
dmesg log

Yes, it's still a problem with kernel 3.6, and loading pciehp doesn't help.

In the attached dmesg, I modprobed pciehp, inserted the card (which was not detected) then rescanned the PCI bus, at which point the card was detected.
Comment 3 Bjorn Helgaas 2012-10-05 20:32:58 UTC
The following reports look like the same issue:
  https://bugzilla.kernel.org/show_bug.cgi?id=16119
  https://bugzilla.kernel.org/show_bug.cgi?id=44021
  https://bugzilla.kernel.org/show_bug.cgi?id=43041
  https://bugs.launchpad.net/ubuntu/+source/linux/+bug/258446
  https://bugs.launchpad.net/ubuntu/+source/linux/+bug/995743

Several comments, e.g., https://bugs.launchpad.net/ubuntu/+source/linux/+bug/258446/comments/42, suggest that the "pciehp_force=1" module parameter fixes this.

We recently merged a change related to that: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=87683e22c646e563061a91f4a0106e6913acebf8

Can you test a kernel that includes that change, e.g., current Linus kernel or
v3.7-rc1 when it comes out in a week or so?

Can you also attach the "lspci -vv" output?  I expect the upstream bridge (00:1c.4) to show that it supports hotplug, and pciehp should handle that.  Please also attach an acpidump, in the event that we're supposed to use ACPI hotplug (acpiphp) instead of PCIe native hotplug (pciehp).
Comment 4 rocko 2012-10-06 00:29:44 UTC
Created attachment 82481 [details]
acpidump
Comment 5 rocko 2012-10-06 00:32:43 UTC
Created attachment 82491 [details]
lspci -vv

Attached lspci and acpidump.

The pciehp_force=1 option doesn't help in my case; in order to detect the reader, I still have to rescan the PCI bus when there is a card in the reader. The only time that the reader works as expected is if I have a card in the reader on reboot.

I'll certainly give 3.7-rc1 a go when it comes out and report back.
Comment 6 rocko 2012-10-15 12:02:21 UTC
3.7-rc1 still doesn't detect the card until a rescan of the PCI bus.
Comment 7 Bjorn Helgaas 2013-09-20 21:02:28 UTC
v3.12-rc1 contains many acpiphp updates, as well as fixes to the
code that decides whether to use acpiphp or pciehp.  Can you please
retest with v3.12-rc1 or later, attach the complete dmesg log,
and note whether this issue is resolved?
Comment 8 rocko 2013-09-24 22:56:58 UTC
I tried 3.12-rc2 and it *did* detect the card without me having to manually rescan the PCI bus!

The system would only mount the card read-only, though.
Comment 9 rocko 2013-09-25 23:08:47 UTC
The read-only problem turned out to be unrelated - I needed to run fsck on the card, possibly because the card reader socket has become a bit dodgy and the card sometimes clicks in then pops out. After running fsck, the card mounts read/write, as expected.

So I'd say the problem is completely resolved in 3.12, which is excellent! Thanks.