Bug 596475

Summary: ricoh e822 sdhci device not working
Product: [Fedora] Fedora Reporter: Gregg Lebovitz <gregg>
Component: kernelAssignee: Stanislaw Gruszka <sgruszka>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 13CC: accounts+redhat, alex, anton, Brice.Goglin, bugs, csimpson, CyberCastle, dmsmith555, dougsland, dylan.semler, gansalmon, itamar, jonathan, kai.kasurinen, kernel-maint, reinouts, sergio, sgruszka, thomas
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: kernel-2.6.35.6-48.fc14 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 644280 (view as bug list) Environment:
Last Closed: 2010-10-28 02:09:52 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Bug Depends On:    
Bug Blocks: 644280    
Attachments:
Description Flags
sdhci c file
none
sdhci-pci.c
none
sdhci.c
none
sdhci.h
none
mmc-make-sdhci-work-with-ricoh-mmc-controller-2.6.33.patch
none
mmc-ricoh_E822.diff
none
2.6.33.5-124 kernel patches to fix ricoh 822 sdhci card reader
none
f12-add-ricoh-e822.patch
none
dmesg after inserting the card with debug enabled none

Description Gregg Lebovitz 2010-05-26 15:35:05 EDT
Description of problem:

sdhci device gets an error "mmc0: unexpected interrupt" when an sdhc card is inserted.


Version-Release number of selected component (if applicable):

linux-2.6.32.12-115

How reproducible:r

always


Steps to Reproduce:
1. insert sdhc card
2. check dmesg
3. driver gets a unexpected interrupt
  
Actual results:

sdhc card isn't recognized


Expected results:

sdhc card activating and partition table read


Additional info:

dmesg when card is inserted

mmc0: Unexpected interrupt 0x02000000.
sdhci: ============== REGISTER DUMP ==============
sdhci: Sys addr: 0x00000000 | Version:  0x00000402
sdhci: Blk size: 0x00007008 | Blk cnt:  0x00000001
sdhci: Argument: 0x00000000 | Trn mode: 0x00000013
sdhci: Present:  0x01ff0202 | Host ctl: 0x00000011
sdhci: Power:    0x0000000f | Blk gap:  0x00000000
sdhci: Wake-up:  0x00000000 | Clock:    0x00004007
sdhci: Timeout:  0x0000000a | Int stat: 0x02008008
sdhci: Int enab: 0x02ff00cb | Sig enab: 0x02ff00cb
sdhci: AC12 err: 0x00000000 | Slot int: 0x00000001
sdhci: Caps:     0x21e832b2 | Max curr: 0x00000040
sdhci: ADMA Err: 0x00000001 | ADMA Ptr: 0x2dd84878
sdhci: ===========================================
mmc0: Timeout waiting for hardware interrupt.

dmesg when card is removed

sdhci: ============== REGISTER DUMP ==============
sdhci: Sys addr: 0x00000000 | Version:  0x00000402
sdhci: Blk size: 0x00007008 | Blk cnt:  0x00000001
sdhci: Argument: 0x00000000 | Trn mode: 0x00000013
sdhci: Present:  0x01ff0202 | Host ctl: 0x00000011
sdhci: Power:    0x0000000f | Blk gap:  0x00000000
sdhci: Wake-up:  0x00000000 | Clock:    0x00004007
sdhci: Timeout:  0x0000000a | Int stat: 0x00000000
sdhci: Int enab: 0x02ff00cb | Sig enab: 0x02ff00cb
sdhci: AC12 err: 0x00000000 | Slot int: 0x00000000
sdhci: Caps:     0x21e832b2 | Max curr: 0x00000040
sdhci: ADMA Err: 0x00000001 | ADMA Ptr: 0x2dd84878
sdhci: ===========================================
mmc0: error -110 whilst initialising SD card
Comment 1 Gregg Lebovitz 2010-06-06 13:09:55 EDT
This exact problem exists in the Fedora 12 distribution.
Comment 2 Stanislaw Gruszka 2010-06-12 07:02:30 EDT
Bug report version is F-13, this is mistake or on F-13 sd card not work as well?
Comment 3 Stanislaw Gruszka 2010-06-26 14:11:12 EDT
We need clarification, if this is only F-12 problem, or F-12 and F-13 problem. Info if card works on rawhide will be useful as well.
Comment 4 Gregg Lebovitz 2010-06-26 15:15:54 EDT
this both a F12 and F13 problem. I will try rawhide when I get the chance
Comment 5 CyberCastle 2010-07-04 17:59:58 EDT
[Possible FIX]

I modified the patch posted here (http://thread.gmane.org/gmane.linux.kernel.commits.mm/62262) to support this device.

Attached are the files modified to be compiled into the kernel 2.6.1934.

Tested on OpenSuSE 11.3 RC2

P.D.: I'm sorry for my bad english.
Comment 6 CyberCastle 2010-07-04 18:01:36 EDT
Created attachment 429415 [details]
sdhci c file
Comment 7 CyberCastle 2010-07-04 18:06:01 EDT
Created attachment 429416 [details]
sdhci-pci.c
Comment 8 CyberCastle 2010-07-04 18:06:30 EDT
Created attachment 429417 [details]
sdhci.c
Comment 9 CyberCastle 2010-07-04 18:06:54 EDT
Created attachment 429418 [details]
sdhci.h
Comment 10 CyberCastle 2010-07-04 18:08:26 EDT
Tested on Dell Precision M4500
Comment 11 Gregg Lebovitz 2010-07-07 16:43:01 EDT
This patch doesn't work against the Fedora 13 kernels. I can't' get it to build.
Comment 12 Stanislaw Gruszka 2010-07-15 13:06:37 EDT
Created attachment 432147 [details]
mmc-make-sdhci-work-with-ricoh-mmc-controller-2.6.33.patch

CyberCastle,

Thank you very much for your help. Normally we use patches for kernel source changes not single files. I prepared this patch for 2.6.33 kernel. It generate different files than yours attached here? 

Gregg,
Could you test this patch?
Comment 13 Gregg Lebovitz 2010-07-20 22:44:14 EDT
applied the patch to my sdhci.c sdhci.h and sdhci-pci.c and I don't see any change in behavior.
Comment 14 CyberCastle 2010-07-21 13:35:37 EDT
The patch posted by  Stanislaw Gruszka is incomplete, because it doesn't refer to this device (Ricoh E822)

Test with my patch....
Comment 15 CyberCastle 2010-07-21 13:37:44 EDT
Created attachment 433467 [details]
mmc-ricoh_E822.diff
Comment 16 Gregg Lebovitz 2010-07-21 21:39:39 EDT
I applied the diffs as well as I could to the Fedora 2.6.33.5-124 kernel and it appears to work. There were some differences, likely because the Fedora kernel is older than the one you are patching.

now we need to figure out how to get the patches into the kernel.

Gregg
Comment 17 Gregg Lebovitz 2010-07-21 22:16:54 EDT
Created attachment 433567 [details]
2.6.33.5-124 kernel patches to fix ricoh 822 sdhci card reader

CyberCastle's patches applied to the sdhci.c sdhci.h sdhci-pci.c in the Fedora 2.6.33.5-124 kernel.
Comment 18 Stanislaw Gruszka 2010-07-22 05:20:46 EDT
(In reply to comment #14)
> The patch posted by  Stanislaw Gruszka is incomplete, because it doesn't refer
> to this device (Ricoh E822)

Thanks again, I'm reassigning bug to you :-)

(In reply to comment #16)
> now we need to figure out how to get the patches into the kernel.

Since this is support for new device, this it will get fedora by that long way: mm tree -> linus tree -> fedora rawhide -> fedora release. Actually bug can be closed with UPSTREAM resolution, but please post patch upstream with missing parts (against mm tree). Let me know if you need help with that.
Comment 19 Stanislaw Gruszka 2010-08-04 02:52:38 EDT
Hi CyberCastle,

Any news about upstream posting to mm tree. BTW: it seems only below hunk need to be posted:

> +     {      
> +             .vendor         = PCI_VENDOR_ID_RICOH,                                                 
> +             .device         = 0xe822,
> +             .subvendor      = PCI_ANY_ID,                                                          
> +             .subdevice      = PCI_ANY_ID,                                                          
> +             .driver_data    = (kernel_ulong_t)&sdhci_ricoh_mmc,                                    
> +     },
Comment 20 Gregg Lebovitz 2010-08-04 10:39:17 EDT
stanislaw,

You still have to add the sdhci_ricoh_mmc methods

ricoh_mmc_probe_slot
ricoh_mmc_resume

and struct sdhci_pci_fixes sdhci_ricoh_mmc

Gregg
Comment 21 Stanislaw Gruszka 2010-08-04 10:49:49 EDT
Yes, these things are missing in linux-2.6, but proper patches are already in mm tree http://userweb.kernel.org/~akpm/mmotm/ .

I will post missing hunk today.
Comment 22 Sergio Monteiro Basto 2010-08-30 20:56:17 EDT
(In reply to comment #21)
> Yes, these things are missing in linux-2.6, but proper patches are already in
> mm tree http://userweb.kernel.org/~akpm/mmotm/ .
> 
> I will post missing hunk today.

Where is or what is the completed patch for fedora kernels ? 
Thanks,
Comment 23 Stanislaw Gruszka 2010-09-09 05:02:57 EDT
Created attachment 446174 [details]
f12-add-ricoh-e822.patch

Patch for fedora 12
Comment 24 Stanislaw Gruszka 2010-09-09 05:34:43 EDT
Patch from above comment 23 apples also on F-13 2.6.34 kernel.
Comment 25 Stanislaw Gruszka 2010-09-09 06:07:57 EDT
I will post patches to fedora mailing list to make device work on F-12,13,14 and rawhide.
Comment 26 Stanislaw Gruszka 2010-09-09 06:12:00 EDT
(In reply to comment #25)
> I will post patches to fedora mailing list to make device work on F-12,13,14
Actually since bug is reported against F-13, I will not touch F-12.
Comment 27 Alex Tucker 2010-09-09 09:01:39 EDT
I've rebuilt kernel-2.6.34.6-47.fc13.src.rpm including the patch in attachment 446174 [details], and the SD reader on my Dell Precision M4500 now works fine.
Comment 28 Brice Goglin 2010-09-14 17:50:40 EDT
Unless I am mistaken, this patch is in 2.6.36. But .36-rc3 doesn't work
on my Dell E6410. It just say:
  mmc0: new high speed SD card at address b368
and nothing else happens.

Is there anything to do apart from using the right kernel? Putting 0x40 in sdhci debug_quirks in modprobe helped in the past. Is any of this still needed nowadays?
Comment 29 Stanislaw Gruszka 2010-09-15 03:59:05 EDT
(In reply to comment #28)
> Unless I am mistaken, this patch is in 2.6.36. 

Yes, patches are there.

> But .36-rc3 doesn't work
> on my Dell E6410. It just say:
>   mmc0: new high speed SD card at address b368
> and nothing else happens.

Some SD cards do not work. We have RHEL6 bug report about that (Bug 623631), but closed as INSUFFICIENT DATA.

> Is there anything to do apart from using the right kernel? Putting 0x40 in
> sdhci debug_quirks in modprobe helped in the past. Is any of this still needed
> nowadays?

Please try :-)

Do you have kernel compiled with CONFIG_DYNAMIC_DEBUG=y . If so please do:

> # mount -t debugfs debugfs /sys/kernel/debug/
> # find /lib/modules/`uname -r`/kernel/drivers/mmc -name "*.ko" -exec basename {} .ko \; | while read m ; do echo "module $m +p" ; done > /sys/kernel/debug/dynamic_debug/control

and put card in, and provide dmesg output.
Comment 30 Brice Goglin 2010-09-15 07:32:14 EDT
Created attachment 447442 [details]
dmesg after inserting the card with debug enabled
Comment 31 Stanislaw Gruszka 2010-09-17 07:21:56 EDT
Could you tell what is exact card model/type (SDIO, SDHC, SD ...)? Seems for unknown reason for me, this card is recognized as MMC, what is wrong. Do you have information if that card works with other MMC/SD readers in linux.
Comment 32 Brice Goglin 2010-09-17 07:31:00 EDT
The card is a regular SD card with nothing interesting to say about it. I don't have another machine at hand to try another reader, I'll let you know when I'll find something to test on.
Comment 33 Gregg Lebovitz 2010-09-17 07:52:02 EDT
I can give this new kernel patch a try this weekend. Since I have a working driver in my 2.6.33 kernel, we can use this as a reference. I also have a 6410 laptop.
Comment 34 Stanislaw Gruszka 2010-09-20 04:08:17 EDT
(In reply to comment #31)
> Seems for
> unknown reason for me, this card is recognized as MMC, what is wrong.
No, driver do proper SD card initialization sequence, but there is something wrong when reading card parameters.

Brice, since this is upstream problem too, could you please report it on linux-mmc@vger.kernel.org mailing list ?
Comment 35 Brice Goglin 2010-09-20 04:13:59 EDT
FWIW, the card works fine on Dell Latitude E6500 (older model) with Ubuntu 10.4,
  03:01.2 SD Host controller: Ricoh Co Ltd R5C822 SD/SDIO/MMC/MS/MSPro Host Adapter (rev 21)

So I guess the problem is in the reader, not in the card itself.

I'll mail the MMC ML, thanks.
Comment 36 Fedora Update System 2010-10-19 00:36:19 EDT
kernel-2.6.35.6-46.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/kernel-2.6.35.6-46.fc14
Comment 37 Fedora Update System 2010-10-19 02:31:21 EDT
kernel-2.6.34.7-61.fc13 has been submitted as an update for Fedora 13.
https://admin.fedoraproject.org/updates/kernel-2.6.34.7-61.fc13
Comment 38 Fedora Update System 2010-10-19 02:36:07 EDT
kernel-2.6.32.23-170.fc12 has been submitted as an update for Fedora 12.
https://admin.fedoraproject.org/updates/kernel-2.6.32.23-170.fc12
Comment 39 Stanislaw Gruszka 2010-10-19 05:55:15 EDT
Brice, for your issue I going to open a new bug report, any news from upstream?
Comment 40 Brice Goglin 2010-10-19 06:04:36 EDT
I never got any reply to my mail to the mailing list.
Comment 41 Reinout van Schouwen 2010-10-20 11:16:32 EDT
I've got a Dell Latitude E6410 and FC14 kernel 2.6.35.6-45.fc14.x86_64.
Upon inserting a SD card (actually an SD card adapter for a micro SD card), nothing seems to happen. Dmesg shows this error each time I insert it:

[12930.177557] mmc0: ADMA error
[12930.179608] mmc0: Got data interrupt 0x02000000 even though no data operation was in progress.
[12930.179615] sdhci: ============== REGISTER DUMP ==============
[12930.179625] sdhci: Sys addr: 0x00000000 | Version:  0x00000402
[12930.179634] sdhci: Blk size: 0x00007008 | Blk cnt:  0x00000001
[12930.179643] sdhci: Argument: 0x00000000 | Trn mode: 0x00000013
[12930.179652] sdhci: Present:  0x01ff0000 | Host ctl: 0x00000011
[12930.179660] sdhci: Power:    0x0000000f | Blk gap:  0x00000000
[12930.179669] sdhci: Wake-up:  0x00000000 | Clock:    0x00004007
[12930.179678] sdhci: Timeout:  0x0000000a | Int stat: 0x00000000
[12930.179686] sdhci: Int enab: 0x02ff00cb | Sig enab: 0x02ff00cb
[12930.179695] sdhci: AC12 err: 0x00000000 | Slot int: 0x00000000
[12930.179703] sdhci: Caps:     0x21e832b2 | Max curr: 0x00000040
[12930.179712] sdhci: ADMA Err: 0x00000001 | ADMA Ptr: 0x022d7804
[12930.179717] sdhci: ===========================================
[12930.180804] mmc0: error -5 whilst initialising SD card
Comment 42 Colin Simpson 2010-10-20 12:43:58 EDT
We have this issue too with RHEL5 on Dell laptops. The RHEL5 kernel looks way too far behind to make the patch easy to apply, but maybe looks not impossible, just time consuming.

Anyone tried/succeeded on RHEL5? I suppose an RFE from RH on this is out of the question, the answer might be RHEL6 I guess.
Comment 43 Michael Zabriskie 2010-10-20 12:52:16 EDT
(In reply to comment #37)
> kernel-2.6.34.7-61.fc13 has been submitted as an update for Fedora 13.
> https://admin.fedoraproject.org/updates/kernel-2.6.34.7-61.fc13

Result with Dell M4500.
This patch does not work in every case for me.

8GB SD - Works
Kingston 2GB SD - Works
A-Data 16GB SDHC - Does not (same "kernel: mmc0: error -110 whilst initialising SD card" error)

Tried patching kernel-2.6.34.7-56.fc13.x86_64 with f12-add-ricoh-e822.patch.
And tried kernel-2.6.34.7-61.fc13.x86_64 from comment 37.
I get the same result with both.

Anyone else experiencing a similar problem with this patch?
Comment 44 Fedora Update System 2010-10-22 13:32:42 EDT
kernel-2.6.35.6-48.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/kernel-2.6.35.6-48.fc14
Comment 45 Fedora Update System 2010-10-22 14:04:32 EDT
kernel-2.6.34.7-61.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 46 Fedora Update System 2010-10-28 02:09:31 EDT
kernel-2.6.35.6-48.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 47 Fedora Update System 2010-10-30 19:42:22 EDT
kernel-2.6.32.23-170.fc12 has been pushed to the Fedora 12 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 48 Stanislaw Gruszka 2011-02-18 04:45:37 EST
I have a patch (and compiled kernel with patch) that could possibly fix remaining problems with e822. Please test, also if you have already ricoh controller working, to see if it not causing regression.

https://bugzilla.redhat.com/show_bug.cgi?id=644280#c6