mmc: sdio: runtime PM and 8686 problems
(resending as my mailer seems to have decided that the first try was a reply to "RE: [PATCH 2/2] mmc: core: Support packed command for eMMC4.5 device,"... apologies!)
I have a GUMSTIX Overo (OMAP35xx) with a Marvel 8686 WiFi attached via SDIO (ok, I think it's actually a Wi2Wi W2CBW003 module containing an 8686).
Up to the 3.1 mainline kernel WiFi worked just fine! I could boot the kernel and load the libertas module successfully:
(during boot)
[ 3.193176] mmc1: new SDIO card at address 0001
(when loading module)
# modprobe libertas_sdio [ 30.817749] lib80211: common routines for IEEE802.11 drivers [ 31.143951] cfg80211: Calling CRDA to update world regulatory domain [ 31.375823] libertas_sdio: Libertas SDIO driver [ 31.380737] libertas_sdio: Copyright Pierre Ossman [ 32.035186] libertas_sdio mmc1:0001:1: (unregistered net_device): 00:19:88:3e:4f:f9, fw 9.70.3p36, cap 0x00000303 [ 32.129943] libertas_sdio mmc1:0001:1: wlan0: Marvell WLAN 802.11 adapter
However it seems that runtime PM has now been turned on by default (by setting MMC_CAP_POWER_OFF_CARD in drivers/mmc/core/host.c), and the WiFi has stopped working!
So, if I run the 3.2-rc2 (or rc1 for that matter) I get the following:
(during boot)
[ 3.486541] mmc1: new SDIO card at address 0001
(when loading module)
# modprobe libertas_sdio [ 34.015350] lib80211: common routines for IEEE802.11 drivers [ 34.345092] cfg80211: Calling CRDA to update world regulatory domain [ 34.574096] libertas_sdio: Libertas SDIO driver [ 34.578979] libertas_sdio: Copyright Pierre Ossman [ 34.637481] libertas_sdio: probe of mmc1:0001:1 failed with error -16
Looking at arch/arm/mach-omap2/overo.c you can see that GPIO16 (OVERO_GPIO_W2W_NRESET) is the nRESET line for the 8686. This is held low for 10usecs during boot (see overo.c line 530 to 533).
I'm not 100% sure how power is connected to the SD8686 as GUMSTIX don't release schematics for their modules.
If I disable runtime PM (by commenting out the setting of MMC_CAP_POWER_OFF_CARD) everything works as before.
I can see plenty of threads relating to getting the SD8686 working for OLPC, and that some workarounds have made it in to the mainline kernel. From what I understand the problem is that runtime PM removes power from the 8686 after boot and before the loading of the libertas module.
Are these workarounds expected to be enough for runtime PM to just "work"?
Is there anything special I should be doing with the nRESET line other than that which is done by default in the board file (holding nRESET low for 10usecs)?
Cheers,
Joe
Hi Joe,
Quoted 1 line · Joe Woodward
Are these workarounds expected to be enough for runtime PM to just "work"?
It definitely works for 12xx, and with Daniel's recent work merged I think it also works fine for the sd8686 (Daniel, PCMIIW).
Ohad.
Ohad,
I'm assuming these changes have already made it to the mainline, and therefore are in the 3.2rc2 build I was testing...
If not do you have links to the patches?
Is there anything I can do to debug further the problems I'm seeing?
Cheers,
Joe
-----Original Message-----
From: Ohad Ben-Cohen <[email protected]>
To: Joe Woodward <[email protected]>, Daniel Drake <[email protected]>
Cc: [email protected]
Date: Fri, 18 Nov 2011 11:06:44 +0200
Subject: Re: mmc: sdio: runtime PM and 8686 problems
Quoted 15 lines
Hi Joe,
Quoted 1 line · Joe Woodward
Are these workarounds expected to be enough for runtime PM to just
"work"?
It definitely works for 12xx, and with Daniel's recent work merged I think it also works fine for the sd8686 (Daniel, PCMIIW).
Ohad.
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 1 line · Joe Woodward
I'm assuming these changes have already made it to the mainline, and therefore are in the 3.2rc2 build I was testing...
Most probably, yeah.
Quoted 1 line
Is there anything I can do to debug further the problems I'm seeing?
Let's wait for Daniel to take a look, as he got libertas and sd8686 working with SDIO runtime PM.
Any more feedback on this?
I don't mind having to maintain my own patch to revert the change to core/host.c to disable runtime PM, but I'm a bit concerned by the commit comment:
"... Enable this trivially for a release or two. If no problems are reported, we will follow up with a more extensive patch to remove this flag altogether. If problems are reported, we can look at whitelist/blacklist possibilities as before."
Certainly for my use case I'd appreciate keeping this flag around!
Cheers,
Joe
-----Original Message-----
From: Ohad Ben-Cohen <[email protected]>
To: Joe Woodward <[email protected]>
Cc: Daniel Drake <[email protected]>, [email protected]
Date: Fri, 18 Nov 2011 14:15:03 +0200
Subject: Re: mmc: sdio: runtime PM and 8686 problems
Quoted 15 lines
Quoted 1 line · Joe Woodward
I'm assuming these changes have already made it to the mainline, and
therefore are in the 3.2rc2 build I was testing...
Most probably, yeah.
Quoted 1 line
Is there anything I can do to debug further the problems I'm seeing?
Let's wait for Daniel to take a look, as he got libertas and sd8686 working with SDIO runtime PM.
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 1 line · Joe Woodward
Any more feedback on this?
Daniel, can you please take a look ?
Joe, Daniel's patch is long term the right thing to do, so I hope we could understand and solve the issue you have and still go on with Daniel's long term plan.
At the same time, though, we're very much determined not to compromise any existing functionality. So IMHO it's either fixing your regression or reverting the change (and then possibly introducing white/black listing as Daniel suggested), but we definitely aren't going to have you maintain the fix for this out-of-tree.
Ohad.
Quoted 4 lines · Ohad Ben-Cohen
Quoted 1 line · Joe Woodward
Any more feedback on this?
Daniel, can you please take a look ?
Even though I have the pleasure of working with 8686 quite a bit, I'm blind to how it works on the inside, so I don't have any expert insight.
So first thing to do is to investigate the source of this error, as before:
[ 34.637481] libertas_sdio: probe of mmc1:0001:1 failed with error -16
which is likely bubbling up from somewhere inside the mmc/sdio layer.
Daniel
Hi Daniel,
Quoted 1 line · Daniel Drake
Even though I have the pleasure of working with 8686 quite a bit
(Is there a subtle cynicism here ? :)
Quoted 4 lines
So first thing to do is to investigate the source of this error, as before:
[ 34.637481]libertas_sdio: probe of mmc1:0001:1 failed with error -16which is likely bubbling up from somewhere inside the mmc/sdio layer.
Well, it sounds like Joe might need a hand here.
Since this regression is directly caused by commit 08da834 "mmc:
enable runtime PM by default", which you authored and have interest in, it does make sense that you help Joe here. In case you're short of time, then I suggest to revert 08da834 (which anyway was experimental), and get back to it later, when you're more available.
Thanks,
Ohad.
Quoted 5 lines · Ohad Ben-Cohen
Hi Daniel,
Quoted 1 line · Daniel Drake
Even though I have the pleasure of working with 8686 quite a bit
Quoted 8 lines
(Is there a subtle cynicism here ? :)
Quoted 4 lines
So first thing to do is to investigate the source of this error, as before:
[ 34.637481]libertas_sdio: probe of mmc1:0001:1 failed with error -16which is likely bubbling up from somewhere inside the mmc/sdio layer.
Well, it sounds like Joe might need a hand here.
I can't reproduce it.
My suggestion is to follow the debugging steps from previous threads on this topic such as
MMC runtime PM patches break libertas probe
The goal is to identify the line of code that is causing this error. Use printk debugging in the codepaths mentioned earlier until the point of failure is known. Let me know if further direction is needed.
Quoted 5 lines
Since this regression is directly caused by commit 08da834 "mmc:
enable runtime PM by default", which you authored and have interest in, it does make sense that you help Joe here. In case you're short of time, then I suggest to revert 08da834 (which anyway was experimental), and get back to it later, when you're more available.
My patch simply sets a flag to enable a whole load of code written by you - code which I understand little about. I am now available to help, but given that my understanding of mmc is limited, I didn't write the code in question, and I also lack expert insight into 8686 powerup, I'm not sure how useful I can be.
Daniel
Quoted 5 lines · Daniel Drake
My patch simply sets a flag to enable a whole load of code written by you - code which I understand little about. I am now available to help, but given that my understanding of mmc is limited, I didn't write the code in question, and I also lack expert insight into 8686 powerup, I'm not sure how useful I can be.
Let's revert 08da834 then.
When SDIO runtime PM was originally introduced, we immediately faced two regressions with two different chipsets, and in response decided not to enable it by default.
With your work on the 8686 we hoped we found all the gotchas, so 08da834 did make sense (at least experimentally).
Unfortunately we now see that some setups out there still refuse to work when SDIO runtime PM is enabled by default, and obviously we can't live with these kind of regressions.
commit fd9fec7a00f58a16803e37a99a014ef82543ef6f
Author: Ohad Ben-Cohen <[email protected]> Date: Wed Nov 30 16:22:13 2011 +0200
Revert "mmc: enable runtime PM by default"
When SDIO runtime PM was originally introduced, we immediately faced two regressions with two different chipsets, and in response decided not to enable it by default.
With the recent work on the 8686 we hoped we found all the gotchas, so 08da834 did make sense (at least experimentally).
Unfortunately we now see that some setups out there still refuse to work when SDIO runtime PM is enabled by default (see
http://www.spinics.net/lists/linux-mmc/msg11161.html), and obviously we can't live with these kind of regressions.
This reverts commit 08da834a24312157f512224691ad1fddd11c1073.
drivers/mmc/core/host.c +0 -0
@@ -302,17 +302,6 @@ struct mmc_host *mmc_alloc_host(int extra, struct
device *dev)
host->max_blk_size = 512; host->max_blk_count = PAGE_CACHE_SIZE / 512;
- /*
- * Enable runtime power management by default. This flag was added due
- * to runtime power management causing disruption for some users, but
- * the power on/off code has been improved since then.
- *
- * We'll enable this flag by default as an experiment, and if no
- * problems are reported, we will follow up later and remove the flag
- * altogether.
- */
- host->caps = MMC_CAP_POWER_OFF_CARD;
-
return host;
free:
Quoted 1 line · Ohad Ben-Cohen
Let's revert 08da834 then.
Sounds fine to me, although it may make sense to wait and see if Joe is able to perform further diagnosis, which may raise some clues.
If we go ahead with the revert, can you help me come up with a way to whitelist it for OLPC? Would a DMI-based quirk in sdhci be acceptable for you?
Thanks,
Daniel
(For reference I have a Gumstix Fire (OMAP3530) revision R3118 plugged in to a PALO43 expansion board. The Gumstix Fire contains a W2CBW003, which in turn contains a Marvell 8686 SDIO WiFi).
Running linux-3.2-rc2 built with the omap2plus_defconfig (with a few features minor tweaks).
With the "stock" kernel I get:
# modprobe libertas_sdio [ 25.813598] lib80211: common routines for IEEE802.11 drivers [ 26.141082] cfg80211: Calling CRDA to update world regulatory domain [ 26.373718] libertas_sdio: Libertas SDIO driver [ 26.378479] libertas_sdio: Copyright Pierre Ossman [ 26.433105] libertas_sdio: probe of mmc1:0001:1 failed with error -16
So, I've enabled MMC_DEBUG (in Kconfig) and the DEBUG defines in libertas/defs.h, and now get:
[ 4.036682] mmc1: new SDIO card at address 0001 [ 4.042510] - [ 4.052459] mmc1: mmc_power_save_host: powering down
[ 31.223724] libertas_sdio: Libertas SDIO driver [ 31.228485] libertas_sdio: Copyright Pierre Ossman [ 31.233703] mmc1: mmc_power_restore_host: powering up [ 31.239074] mmc1: clock 0Hz busmode 2 powermode 1 cs 0 Vdd 20 width 0 timing 0 [ 31.239349] omap_hsmmc omap_hsmmc.1: context was not lost [ 31.239379] omap_hsmmc omap_hsmmc.1: enabled [ 31.239410] omap_hsmmc omap_hsmmc.1: Set clock to 0Hz [ 31.243438] omap_hsmmc omap_hsmmc.1: disabled [ 31.262451] mmc1: clock 400000Hz busmode 2 powermode 2 cs 0 Vdd 20 width 0 timing 0 [ 31.262725] omap_hsmmc omap_hsmmc.1: context was not lost [ 31.262725] omap_hsmmc omap_hsmmc.1: enabled [ 31.262786] omap_hsmmc omap_hsmmc.1: Set clock to 400000Hz [ 31.263092] omap_hsmmc omap_hsmmc.1: disabled [ 31.286163] omap_hsmmc omap_hsmmc.1: context was not lost [ 31.286193] omap_hsmmc omap_hsmmc.1: enabled [ 31.286224] mmc1: starting CMD52 arg 00000c00 flags 00000195 [ 31.286254] omap_hsmmc omap_hsmmc.1: mmc1: CMD52, argument 0x00000c00 [ 31.286590] omap_hsmmc omap_hsmmc.1: IRQ Status is 1 [ 31.286621] mmc1: req done (CMD52): 0: 00001000 00000000 00000000 00000000 [ 31.286682] mmc1: starting CMD52 arg 80000c08 flags 00000195 [ 31.286682] omap_hsmmc omap_hsmmc.1: mmc1: CMD52, argument 0x80000c08 [ 31.287017] omap_hsmmc omap_hsmmc.1: IRQ Status is 1 [ 31.287048] mmc1: req done (CMD52): 0: 00001008 00000000 00000000 00000000 [ 31.287109] mmc1: clock 400000Hz busmode 2 powermode 2 cs 1 Vdd 20 width 0 timing 0 [ 31.287109] omap_hsmmc omap_hsmmc.1: Set clock to 400000Hz [ 31.288146] mmc1: starting CMD0 arg 00000000 flags 000000c0 [ 31.288177] omap_hsmmc omap_hsmmc.1: mmc1: CMD0, argument 0x00000000 [ 31.288330] omap_hsmmc omap_hsmmc.1: IRQ Status is 1 [ 31.288360] mmc1: req done (CMD0): 0: 00000000 00000000 00000000 00000000 [ 31.289398] mmc1: clock 400000Hz busmode 2 powermode 2 cs 0 Vdd 20 width 0 timing 0 [ 31.289428] omap_hsmmc omap_hsmmc.1: Set clock to 400000Hz [ 31.290466] mmc1: starting CMD8 arg 000001aa flags 000002f5 [ 31.290466] omap_hsmmc omap_hsmmc.1: mmc1: CMD8, argument 0x000001aa [ 31.290832] omap_hsmmc omap_hsmmc.1: IRQ Status is 18000 [ 31.290863] omap_hsmmc omap_hsmmc.1: MMC IRQ 0x18000 : ERRI CTO [ 31.290893] mmc1: req done (CMD8): -110: 00000000 00000000 00000000 00000000 [ 31.290924] mmc1: starting CMD5 arg 00000000 flags 000002e1 [ 31.290954] omap_hsmmc omap_hsmmc.1: mmc1: CMD5, argument 0x00000000 [ 31.291290] omap_hsmmc omap_hsmmc.1: IRQ Status is 18000 [ 31.291320] omap_hsmmc omap_hsmmc.1: MMC IRQ 0x18000 : ERRI CTO [ 31.291381] mmc1: req failed (CMD5): -110, retrying... [ 31.291412] omap_hsmmc omap_hsmmc.1: mmc1: CMD5, argument 0x00000000 [ 31.291748] omap_hsmmc omap_hsmmc.1: IRQ Status is 18000 [ 31.291778] omap_hsmmc omap_hsmmc.1: MMC IRQ 0x18000 : ERRI CTO [ 31.291839] mmc1: req failed (CMD5): -110, retrying... [ 31.291870] omap_hsmmc omap_hsmmc.1: mmc1: CMD5, argument 0x00000000 [ 31.292205] omap_hsmmc omap_hsmmc.1: IRQ Status is 18000 [ 31.292236] omap_hsmmc omap_hsmmc.1: MMC IRQ 0x18000 : ERRI CTO [ 31.292266] mmc1: req failed (CMD5): -110, retrying... [ 31.292297] omap_hsmmc omap_hsmmc.1: mmc1: CMD5, argument 0x00000000 [ 31.292633] omap_hsmmc omap_hsmmc.1: IRQ Status is 18000 [ 31.292663] omap_hsmmc omap_hsmmc.1: MMC IRQ 0x18000 : ERRI CTO [ 31.292694] mmc1: req done (CMD5): -110: 00000000 00000000 00000000 00000000 [ 31.292877] libertas_sdio: probe of mmc1:0001:1 failed with error -16 [ 31.387481] omap_hsmmc omap_hsmmc.1: disabled
Is this useful?
It seems CMD5 fails (which seems to be what the workarounds were aiming to fix).
I'm afraid I may not be of much more use as Gumstix (annoyingly) don't release schematics of their COMs, so actually probing any signals isn't really possible.
Cheers,
Joe
-----Original Message-----
From: Ohad Ben-Cohen <[email protected]>
To: Daniel Drake <[email protected]>
Cc: Joe Woodward <[email protected]>, [email protected], Chris Ball <[email protected]>
Date: Wed, 30 Nov 2011 16:29:21 +0200
Subject: Re: mmc: sdio: runtime PM and 8686 problems
Quoted 71 lines · Daniel Drake
Quoted 5 lines
My patch simply sets a flag to enable a whole load of code written by you - code which I understand little about. I am now available to help, but given that my understanding of mmc is limited, I didn't write the code in question, and I also lack expert insight into 8686 powerup, I'm not sure how useful I can be.
Let's revert 08da834 then.
When SDIO runtime PM was originally introduced, we immediately faced two regressions with two different chipsets, and in response decided not to enable it by default.
With your work on the 8686 we hoped we found all the gotchas, so 08da834 did make sense (at least experimentally).
Unfortunately we now see that some setups out there still refuse to work when SDIO runtime PM is enabled by default, and obviously we can't live with these kind of regressions.
commit
fd9fec7a00f58a16803e37a99a014ef82543ef6fAuthor: Ohad Ben-Cohen <[email protected]> Date: Wed Nov 30 16:22:13 2011 +0200Revert "mmc: enable runtime PM by default"
When SDIO runtime PM was originally introduced, we immediately
faced
two regressions with two different chipsets, and in response
decided
not to enable it by default.With the recent work on the 8686 we hoped we found all the gotchas, so 08da834 did make sense (at least experimentally).
Unfortunately we now see that some setups out there still refuse to
work
when SDIO runtime PM is enabled by default (see
http://www.spinics.net/lists/linux-mmc/msg11161.html), and
obviously we
can't live with these kind of regressions.This reverts commit
08da834a24312157f512224691ad1fddd11c1073.Signed-off-by Ohad Ben-Cohen <[email protected]>Cc Daniel Drake <[email protected]>drivers/mmc/core/host.c +0
-2@@ -302,17 +302,6 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) host->max_blk_size = 512; host->max_blk_count =PAGE_CACHE_SIZE /512 ; -/* -* Enable runtime power management by default. This flag was added due
drivers/mmc/core/host.c +0
-9-* to runtime power management causing disruption for some users, but -* the power on/off code has been improved since then. -* -* We'll enable this flag by default as an experiment, and if no -* problems are reported, we will follow up later and remove the flag -* altogether. -*/ - host->caps =MMC_CAP_POWER_OFF_CARD ; -return host; free:
Quoted 2 lines · Daniel Drake
If we go ahead with the revert, can you help me come up with a way to whitelist it for OLPC?
Sure thing.
Quoted 1 line
Would a DMI-based quirk in sdhci be acceptable for you?
I wasn't following sdhci development so much as I'm not developing on such hardware, so I'll have to take a look. AFAIK though sdhci is maintained by Wolfram, so you need his consent. Whatever approach Wolfram and you will agree on is of course fine with me.
Thanks,
Ohad.
Quoted 1 line · Joe Woodward
It seems CMD5 fails (which seems to be what the workarounds were aiming to fix).
Right; you get a timeout (-110), which means the 8686 didn't send any response.
This is unexpected because the sdio reset (the CMD52 you see before the init sequence) should be enough to reset the device (we confirmed this with the Marvell folks on this list awhile ago).
Quoted 1 line
I'm afraid I may not be of much more use as Gumstix (annoyingly) don't release schematics of their COMs, so actually probing any signals isn't really possible.
Yes, it makes it difficult to debug.
You can try to verify (in the code) that all the text book prerequisites are there (e.g. all SDIO lines are pulled up and muxed correctly. though since stuff work for you without SDIO runtime PM, I assume these are ok), and maybe even play a bit with stuff like delays, sdio resets and power cycles and see if things change. If you have access to the other inputs of the 8686 (it has several of them which are related to power and resets. Neither me nor Daniel have intimate knowledge about what any of those really do, but you could dig some info from emails send by Marvell folks on this list), then you can also try to play with them and see if things change. With luck, you could learn more about the problem and can hopefully get closer to finding a solution.
It could be great if a solution will be found, but if not, we'll probably have to proceed with the revert...
Good luck!
Ohad.
I've had a play with the nRESET line (as far as I can tell it is the only pin I have access to), and no joy.
Also tried playing about a bit with the CMD sequence, again no joy.
I'm not entirely sure of the CMD sequence. It seems we get:
- CMD52 (x2)
- CMD0
- CMD8 (fails)
- CMD5 (fails)
In the "SDIO Simplified Specification Version 2.00" (https://www.sdcard.org/developers/overview/sdio/sdio_spec/Simplified_SDIO_Card_Spec.pdf) page 6 it seems only a CMD52 should be required to "Re-init IO". Previous thread posts state CMD5 (x2) are required by the 8686, but why CMD0/CMD8?
Incidentally errors only occur after the CMD0, but before the first error we get (i.e. a change of cs from 1 to 0):
"mmc1: clock 400000Hz busmode 2 powermode 2 cs 0 Vdd 20 width 0 timing 0".
Any thoughts?
I think we've probably hit the end of the line here, unless someone else pops up who knows more about the Gumstix (i.e. has access to a schematic) or the W2CBW003 and it's SD8686 internals.
Thanks for the help anyway chaps!
Cheers,
Joe
-----Original Message-----
From: Ohad Ben-Cohen <[email protected]>
To: Joe Woodward <[email protected]>
Cc: Daniel Drake <[email protected]>, [email protected], Chris Ball <[email protected]>
Date: Thu, 1 Dec 2011 10:07:24 +0200
Subject: Re: mmc: sdio: runtime PM and 8686 problems
Quoted 40 lines
Quoted 1 line · Joe Woodward
It seems CMD5 fails (which seems to be what the workarounds were
aiming to fix).
Right; you get a timeout (-110), which means the 8686 didn't send any response.
This is unexpected because the sdio reset (the CMD52 you see before the init sequence) should be enough to reset the device (we confirmed this with the Marvell folks on this list awhile ago).
Quoted 1 line
I'm afraid I may not be of much more use as Gumstix (annoyingly)
don't release schematics of their COMs, so actually probing any signals isn't really possible.
Yes, it makes it difficult to debug.
You can try to verify (in the code) that all the text book prerequisites are there (e.g. all SDIO lines are pulled up and muxed correctly. though since stuff work for you without SDIO runtime PM, I assume these are ok), and maybe even play a bit with stuff like delays, sdio resets and power cycles and see if things change. If you have access to the other inputs of the 8686 (it has several of them which are related to power and resets. Neither me nor Daniel have intimate knowledge about what any of those really do, but you could dig some info from emails send by Marvell folks on this list), then you can also try to play with them and see if things change. With luck, you could learn more about the problem and can hopefully get closer to finding a solution.
It could be great if a solution will be found, but if not, we'll probably have to proceed with the revert...
Good luck!
Ohad.
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 10 lines · Joe Woodward
I've had a play with the nRESET line (as far as I can tell it is the only pin I have access to), and no joy.
Also tried playing about a bit with the CMD sequence, again no joy.
I'm not entirely sure of the CMD sequence. It seems we get:
- CMD52 (x2)
- CMD0
- CMD8 (fails)
- CMD5 (fails)
Quoted 5 lines
In the "SDIO Simplified Specification Version 2.00" (https://www.sdcard.org/developers/overview/sdio/sdio_spec/Simplified_SDIO_Card_Spec.pdf) page 6 it seems only a CMD52 should be required to "Re-init IO". Previous thread posts state CMD5 (x2) are required by the 8686, but why CMD0/CMD8?
Incidentally errors only occur after the CMD0, but before the first error we get (i.e. a change of cs from 1 to 0):
"mmc1: clock 400000Hz busmode 2 powermode 2 cs 0 Vdd 20 width 0 timing 0".
Can you see how this compares with older working kernels?
Some more things to try:
there are some delays in mmc_power_off - try increasing them to 1000.
mmc_sdio_power_restore does:sdio_reset (cmd52)mmc_go_idle (cmd0)mmc_send_if_cond (cmd8)mmc_send_io_op_cond (cmd52)
These are the commands you have been looking at from the angle of the logs.
Try sprinkling in a load of msleep(500) delays before and inbetween those commands. And if you suspect some of them are not necessary trying removing them, etc.
Non-scientific but this is how we have got things working so far :)
Thanks,
Daniel
Quoted 2 lines · Daniel Drake
Quoted 1 line · Joe Woodward
I've had a play with the nRESET line (as far as I can tell it is the only pin I have access to), and no joy.
The card is being reset and powered up successfully during boot, then powered down, then it fails to power up again.
Can you confirm that the reset line is definitely being fiddled during the second and failing power up?
Thanks
Daniel
Right, a bit more information.
First I tried just adding delays as suggested:
# Delays in core.c:mmc_power_up() increased to 1000. # Delay in core.c:mmc_power_off() increased to 1000. # sdio.c:mmc_sdio_power_restore() modified to add delays.
...
msleep(500); sdio_reset(host); msleep(500); mmc_go_idle(host); msleep(500); mmc_send_if_cond(host, host->ocr_avail); msleep(500); ret = mmc_send_io_op_cond(host, 0, &ocr);
...
And there was no improvement (it slowed down the probe a lot!), so I tried again with much longer delays (3 seconds rather than 500ms) and still no change.
So I added control of the nRESET line in sdio.c:mmc_sdio_power_restore().
...
gpio_set_value(16, 0); /* GPIO16 is the nRESET line */ msleep(10); gpio_set_value(16, 1); msleep(100); msleep(3000); sdio_reset(host); msleep(3000); mmc_go_idle(host); msleep(3000); mmc_send_if_cond(host, host->ocr_avail); msleep(3000);
...
and things sprung in to life, well sometimes! Sadly this only worked intermittently, and only with longer delays.
I guess this may not be a suprise, as I'm force resetting the card but not doing a full "probe".
I'm afraid I can't probe the nRESET line as the SD8686 is hidden under a shielding can, and I don't have the schematics for the GUMSTIX Overo to be able to look for the signal anywhere else.
With the SD8686 only working every now and again with the nRESET control it's difficult to make progress as I'm stabbing around in the dark - I never really know if I'm improving things or not when adding/removing timeouts etc...
Previous kernel's never had runtime PM enabled, so I'm not sure what you mean to compare there?
Whatever procedure is first applied to the SD8686 with runtime PM disabled works 100% of the time.
Does anyone know if OLPC keep any out-of-tree patches to make runtime PM work for them on the SD8686 (maybe fudging GPIOs or similar)?
Cheers,
Joe
-----Original Message-----
From: Daniel Drake <[email protected]>
To: Joe Woodward <[email protected]>
Cc: Ohad Ben-Cohen <[email protected]>, [email protected], Chris Ball <[email protected]>
Date: Sat, 3 Dec 2011 10:44:18 -0600
Subject: Re: mmc: sdio: runtime PM and 8686 problems
Quoted 51 lines · Joe Woodward
Quoted 1 line
I've had a play with the nRESET line (as far as I can tell it is the
only pin I have access to), and no joy.
Quoted 10 lines
Also tried playing about a bit with the CMD sequence, again no joy.
I'm not entirely sure of the CMD sequence. It seems we get:
- CMD52 (x2)
- CMD0
- CMD8 (fails)
- CMD5 (fails)In the "SDIO Simplified Specification Version 2.00"
(https://www.sdcard.org/developers/overview/sdio/sdio_spec/Simplified_S
DIO_Card_Spec.pdf) page 6 itQuoted 1 line
seems only a CMD52 should be required to "Re-init IO". Previous
thread posts state CMD5 (x2) are required by the 8686, but why CMD0/CMD8?
Quoted 2 lines
Incidentally errors only occur after the CMD0, but before the first
error we get (i.e. a change of cs from 1 to 0):
Quoted 1 line
"mmc1: clock 400000Hz busmode 2 powermode 2 cs 0 Vdd 20 width 0
timing 0".
Can you see how this compares with older working kernels?
Some more things to try:
there are some delays inmmc_power_off- try increasing them to 1000.
mmc_sdio_power_restoredoes:sdio_reset(cmd52)mmc_go_idle(cmd0)mmc_send_if_cond(cmd8)mmc_send_io_op_cond(cmd52)These are the commands you have been looking at from the angle of the logs.
Try sprinkling in a load of msleep(500) delays before and inbetween those commands. And if you suspect some of them are not necessary trying removing them, etc.
Non-scientific but this is how we have got things working so far :)
Thanks,
Daniel
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Chris,
Quoted 8 lines · Ohad Ben-Cohen
Quoted 5 lines · Daniel Drake
My patch simply sets a flag to enable a whole load of code written by you - code which I understand little about. I am now available to help, but given that my understanding of mmc is limited, I didn't write the code in question, and I also lack expert insight into 8686 powerup, I'm not sure how useful I can be.
Let's revert 08da834 then.
We're slowly progressing towards understanding the issues we have with the 8686 (it seems there are a few different hw revisions of it, some of which do require toggling the reset pin before sending another init sequence), but it might take some more time until a solution fully materializes.
Since 3.2 is just around the corner, I suggest we should now proceed with the revert (see patch below), and later revisit this once we have a complete solution in hand.
Thanks,
Ohad.
Quoted 58 lines
When SDIO runtime PM was originally introduced, we immediately faced two regressions with two different chipsets, and in response decided not to enable it by default.
With your work on the 8686 we hoped we found all the gotchas, so 08da834 did make sense (at least experimentally).
Unfortunately we now see that some setups out there still refuse to work when SDIO runtime PM is enabled by default, and obviously we can't live with these kind of regressions.
commit
fd9fec7a00f58a16803e37a99a014ef82543ef6f
Author: Ohad Ben-Cohen <[email protected]>
Date: Wed Nov 30 16:22:13 2011 +0200Revert "mmc: enable runtime PM by default"
When SDIO runtime PM was originally introduced, we immediately faced two regressions with two different chipsets, and in response decided not to enable it by default.
With the recent work on the 8686 we hoped we found all the gotchas, so 08da834 did make sense (at least experimentally).
Unfortunately we now see that some setups out there still refuse to work when SDIO runtime PM is enabled by default (see
http://www.spinics.net/lists/linux-mmc/msg11161.html), and obviously we can't live with these kind of regressions.This reverts commit
08da834a24312157f512224691ad1fddd11c1073.Signed-off-by Ohad Ben-Cohen <[email protected]>Cc Daniel Drake <[email protected]>drivers/mmc/core/host.c +0
-11@@ -302,17 +302,6 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) host->max_blk_size = 512; host->max_blk_count = PAGE_CACHE_SIZE / 512; - /* - * Enable runtime power management by default. This flag was added due - * to runtime power management causing disruption for some users, but - * the power on/off code has been improved since then. - * - * We'll enable this flag by default as an experiment, and if no - * problems are reported, we will follow up later and remove the flag - * altogether. - */ - host->caps = MMC_CAP_POWER_OFF_CARD; - return host;free:
Quoted 3 lines · Ohad Ben-Cohen
(it seems there are a few different hw revisions of it, some of which do require toggling the reset pin before sending another init sequence)
(it might just be different setups and not really different hw revisions of the 8686)
Quoted 9 lines · Ohad Ben-Cohen
We're slowly progressing towards understanding the issues we have with the 8686 (it seems there are a few different hw revisions of it, some of which do require toggling the reset pin before sending another init sequence), but it might take some more time until a solution fully materializes.
Since 3.2 is just around the corner, I suggest we should now proceed with the revert (see patch below), and later revisit this once we have a complete solution in hand.
Has any progress been made on this issue?
I too have been trying to power down/up the wifi module on the Overo. I'm seeing the same issue described in this thread.
Some additional data:
I rebuilt my kernel (3.2) with a CD GPIO enabled for the mmc port the module is connected to and in turn connected that GPIO to another one that I can toggle from user space.
Toggling the CD GPIO after powering back up the module does indeed work properly -- the module is detected, the driver loaded, and proper function restored.
So basically the procedure I've used is:
- decide wifi can be powered down
- unload the libertas modules
- put the wifi hw in reset with gpio16
- wait till wifi is needed again
- take the chip out of reset
- toggle the CD gpio
- libertas modules are autoloaded, as is the firmware
- wifi is up and functioning
So the next step is to get rid of the silly two GPIO external hardware hack. Is it possible to trigger a card insertion/removal event via some standard API?
Or does the above information provide a clue as to why normal code paths don't work?
Any other ideas?
Steve
Quoted 61 lines
Quoted 56 lines
When SDIO runtime PM was originally introduced, we immediately faced two regressions with two different chipsets, and in response decided not to enable it by default.
With your work on the 8686 we hoped we found all the gotchas, so 08da834 did make sense (at least experimentally).
Unfortunately we now see that some setups out there still refuse to work when SDIO runtime PM is enabled by default, and obviously we can't live with these kind of regressions.
commit
fd9fec7a00f58a16803e37a99a014ef82543ef6f
Author: Ohad Ben-Cohen <[email protected]>
Date: Wed Nov 30 16:22:13 2011 +0200Revert "mmc: enable runtime PM by default"
When SDIO runtime PM was originally introduced, we immediately faced two regressions with two different chipsets, and in response decided not to enable it by default.
With the recent work on the 8686 we hoped we found all the gotchas, so 08da834 did make sense (at least experimentally).
Unfortunately we now see that some setups out there still refuse to work when SDIO runtime PM is enabled by default (see
http://www.spinics.net/lists/linux-mmc/msg11161.html), and obviously we can't live with these kind of regressions.This reverts commit
08da834a24312157f512224691ad1fddd11c1073.Signed-off-by Ohad Ben-Cohen <[email protected]>Cc Daniel Drake <[email protected]>drivers/mmc/core/host.c +0
-11@@ -302,17 +302,6 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) host->max_blk_size = 512; host->max_blk_count = PAGE_CACHE_SIZE / 512; - /* - * Enable runtime power management by default. This flag was added due - * to runtime power management causing disruption for some users, but - * the power on/off code has been improved since then. - * - * We'll enable this flag by default as an experiment, and if no - * problems are reported, we will follow up later and remove the flag - * altogether. - */ - host->caps = MMC_CAP_POWER_OFF_CARD; - return host;Quoted 1 line
free:
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
-----Original Message-----
From: Steve Sakoman <[email protected]>
To: Ohad Ben-Cohen <[email protected]>
Cc: Chris Ball <[email protected]>, Joe Woodward <[email protected]>, [email protected], Neil Brown <[email protected]>, Bing Zhao <[email protected]>, Daniel Drake <[email protected]>
Date: Thu, 26 Apr 2012 16:51:10 -0700
Subject: Re: mmc: sdio: runtime PM and 8686 problems
Quoted 48 lines
Quoted 1 line · Ohad Ben-Cohen
We're slowly progressing towards understanding the issues we have
with
Quoted 2 lines
the 8686 (it seems there are a few different hw revisions of it, some of which do require toggling the reset pin before sending another
init
Quoted 5 lines
sequence), but it might take some more time until a solution fully materializes.
Since 3.2 is just around the corner, I suggest we should now proceed with the revert (see patch below), and later revisit this once we
have
Quoted 1 line
a complete solution in hand.
Has any progress been made on this issue?
I too have been trying to power down/up the wifi module on the Overo. I'm seeing the same issue described in this thread.
Some additional data:
I rebuilt my kernel (3.2) with a CD GPIO enabled for the mmc port the module
is connected to and in turn connected that GPIO to another one that I can toggle from user space.Toggling the CD GPIO after powering back up the module does indeed work properly -- the module is detected, the driver loaded, and proper function
restored.So basically the procedure I've used is:
- decide wifi can be powered down
- unload the libertas modules
- put the wifi hw in reset with gpio16
- wait till wifi is needed again
- take the chip out of reset
- toggle the CD gpio
- libertas modules are autoloaded, as is the firmware
- wifi is up and functioningSo the next step is to get rid of the silly two GPIO external hardware hack. Is it possible to trigger a card insertion/removal event via some standard API?
Quoted 7 lines
Or does the above information provide a clue as to why normal code paths don't work?
Any other ideas?
Steve
Since the patch has been reverted (i.e. no runtime PM) I haven't seen a problem.
I've not put any more work in to getting it to work with runtime PM i'm afriad.
On a side note, I'm doing something very similar to you with my Overo, except with one difference. Where you have routed a GPIO externally which you can toggle from userspace, I've hacked the MMC driver (omap_hsmmc.c) to add a sysfs entry to force a re-scan. This also allows me to safely remove/insert SD cards (as the Overo SDCard slot doesn't have a card-detect pin) when the device is running (I run from a ramfs).
I've thought for a while that a userspace hook to kick the MMC driver where this is no physical GPIO would be useful in mainline, but haven't done any more about it.
Also, I've appled the first pass of patches to enable Libertas async firmware loading (as required by newer UDEVs).
I have two scripts pasted below to turn on/off the WiFi (the delays just work for me, I know they are not optimal).
Hope this helps.
Cheers,
Joe
Quoted 1 line
cat #wifi-down.sh
#!/bin/sh
echo "Turning off WiFi..."
echo "...stopping wlan0 interface"
ifdown wlan0
echo "...unloading WiFi kernel module"
modprobe -r libertas_sdio
echo "...disabling power to WiFi chip"
if [ -e /sys/class/gpio/gpio16/value ] ; then
echo "...already exported GPIO reset control"
else
echo "...exporting GPIO reset control"
echo 16 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio16/direction
fi
echo 0 > /sys/class/gpio/gpio16/value
echo "...removing wpa configuration file"
rm /tmp/wpa_supplicant.conf
echo "..rescanning the MMC/SDIO as we have powered down the WiFi chip" echo 1 > /sys/bus/platform/drivers/omap_hsmmc/omap_hsmmc.1/mmc_host/mmc1/rescan sleep 2
echo "...done"
#> cat wifi-up.sh
#!/bin/sh
# Get the network parameters.
SSID=$1
PSK=$2
echo "Turning on WiFi..."
echo "...enabling power to WiFi chip"
if [ -e /sys/class/gpio/gpio16/value ] ; then
echo "...already exported GPIO reset control"
else
echo "...exporting GPIO reset control"
echo 16 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio16/direction
fi
echo 0 > /sys/class/gpio/gpio16/value
usleep 10
echo 1 > /sys/class/gpio/gpio16/value
usleep 10
echo "..rescanning the MMC/SDIO as we have powered up the WiFi chip" echo 1 > /sys/bus/platform/drivers/omap_hsmmc/omap_hsmmc.1/mmc_host/mmc1/rescan
### Wait for the device to be found.
sleep 2
### Set up the AP and password.
echo "...adding wpa configuration file"
rm /tmp/wpa_supplicant.conf
echo "ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
eapol_version=1
ap_scan=1
fast_reauth=1
network={
ssid=\"${SSID}\"
proto=WPA2 # try WPA RSN if you WPA2 fails
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
scan_ssid=1
psk=\"${PSK}\"
priority=10
}" > /tmp/wpa_supplicant.confecho "...loading WiFi kernel module"
modprobe libertas_sdio
### We must wait for the asynchronous firmware loading to complete. sleep 2
echo "...starting wlan0 interface"
ifup wlan0
echo "...done"
=========
On 3.2 the rescan looks a bit like:
static ssize_t
omap_hsmmc_store_rescan(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
struct mmc_host *mmc = container_of(dev, struct mmc_host, class_dev);
struct omap_hsmmc_host *host = mmc_priv(mmc);printk (KERN_ERR "MMC: rescanning...\n");
if (!host->suspended) schedule_work(&host->mmc_carddetect_work); return size; }
static DEVICE_ATTR(rescan, S_IWUGO, NULL, omap_hsmmc_store_rescan);
And I add in to omap_hsmmc_probe:
ret = device_create_file(&mmc->class_dev, &dev_attr_rescan); if (ret < 0) goto err_slot_name;
Quoted 73 lines
Quoted 12 lines
Quoted 12 lines
When SDIO runtime PM was originally introduced, we immediately faced two regressions with two different chipsets, and in response decided not to enable it by default.
With your work on the 8686 we hoped we found all the gotchas, so 08da834 did make sense (at least experimentally).
Unfortunately we now see that some setups out there still refuse to work when SDIO runtime PM is enabled by default, and obviously we can't live with these kind of regressions.
Quoted 7 lines
Quoted 7 lines
commit
fd9fec7a00f58a16803e37a99a014ef82543ef6f
Author: Ohad Ben-Cohen <[email protected]>
Date: Wed Nov 30 16:22:13 2011 +0200Revert "mmc: enable runtime PM by default"
When SDIO runtime PM was originally introduced, we immediately
faced
Quoted 1 line
Quoted 1 line
two regressions with two different chipsets, and in response
decided
Quoted 3 lines
Quoted 3 lines
not to enable it by default.
With the recent work on the 8686 we hoped we found all the
gotchas,
Quoted 3 lines
Quoted 3 lines
so 08da834 did make sense (at least experimentally).
Unfortunately we now see that some setups out there still
refuse to work
Quoted 2 lines
Quoted 2 lines
when SDIO runtime PM is enabled by default (see
http://www.spinics.net/lists/linux-mmc/msg11161.html), andobviously we
Quoted 4 lines
Quoted 4 lines
can't live with these kind of regressions.
This reverts commit
08da834a24312157f512224691ad1fddd11c1073.Quoted 8 lines
drivers/mmc/core/host.c struct mmc_host *mmc_alloc_host(int extra,
Quoted 8 lines
Signed-off-by Ohad Ben-Cohen <[email protected]>Cc Daniel Drake <[email protected]>drivers/mmc/core/host.c +0
-0@@ -302,17 +302,6 @@ struct mmc_host *mmc_alloc_host(int extra,struct
Quoted 6 lines
drivers/mmc/core/host.c struct mmc_host *mmc_alloc_host(int extra, · line 307
Quoted 6 lines
drivers/mmc/core/host.c +0
-2device *dev) host->max_blk_size = 512; host->max_blk_count = PAGE_CACHE_SIZE / 512; - /* -* Enable runtime power management by default. This flag was added due
Quoted 1 line
drivers/mmc/core/host.c struct mmc_host *mmc_alloc_host(int extra, · line 308
Quoted 1 line
drivers/mmc/core/host.c +0
-1- * to runtime power management causing disruption forsome users, but
Quoted 3 lines
drivers/mmc/core/host.c struct mmc_host *mmc_alloc_host(int extra, · line 311
Quoted 3 lines
drivers/mmc/core/host.c +0
-3- * the power on/off code has been improved since then. - * - * We'll enable this flag by default as an experiment,and if no
Quoted 1 line
drivers/mmc/core/host.c struct mmc_host *mmc_alloc_host(int extra, · line 312
Quoted 1 line
drivers/mmc/core/host.c +0
-1- * problems are reported, we will follow up later andremove the flag
Quoted 9 lines
Quoted 7 lines
drivers/mmc/core/host.c +0
-4-* altogether. -*/ - host->caps = MMC_CAP_POWER_OFF_CARD; - return host;free:
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc"in
Quoted 2 lines
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 38 lines · On Thu, 26 Apr 2012 16:51:10 -0700 Steve Sakoman <[email protected]> wrote:
Quoted 9 lines · Ohad Ben-Cohen
We're slowly progressing towards understanding the issues we have with the 8686 (it seems there are a few different hw revisions of it, some of which do require toggling the reset pin before sending another init sequence), but it might take some more time until a solution fully materializes.
Since 3.2 is just around the corner, I suggest we should now proceed with the revert (see patch below), and later revisit this once we have a complete solution in hand.
Has any progress been made on this issue?
I too have been trying to power down/up the wifi module on the Overo. I'm seeing the same issue described in this thread.
Some additional data:
I rebuilt my kernel (3.2) with a CD GPIO enabled for the mmc port the module is connected to and in turn connected that GPIO to another one that I can toggle from user space.
Toggling the CD GPIO after powering back up the module does indeed work properly -- the module is detected, the driver loaded, and proper function restored.
So basically the procedure I've used is:
- decide wifi can be powered down
- unload the libertas modules
- put the wifi hw in reset with gpio16
- wait till wifi is needed again
- take the chip out of reset
- toggle the CD gpio
- libertas modules are autoloaded, as is the firmware
- wifi is up and functioning
Quoted 8 lines
So the next step is to get rid of the silly two GPIO external hardware hack. Is it possible to trigger a card insertion/removal event via some standard API?
Or does the above information provide a clue as to why normal code paths don't work?
Any other ideas?
I thought I had a nicely working solution, but I recently discovered that it doesn't work as well as I thought it did. I now think we need some help from the mmc layer to get it really working.
My understanding of the underlying problem is that the wifi chip can get into a state where it really needs a hardware reset, but it isn't given one. Applying the reset at the right time is needed.
When the mmc layer wants to power-up the device, it tells the configured regulator to turn on, then sends some standard command sequence. If the regulator was actually off, this works (I think - it is a while since I experimented). However if the regulator wasn't actually off, it doesn't work - the wifi chip gets confused by getting the init sequence when it is already inited, and fails to continue.
So pulsing the resent line low after turning on the power is necessary and sufficient.
In my case, the regulator is shared by the bluetooth and the wifi so if bluetooth is on while the wifi is off the regulator never gets turned off, and so bad things happen when we try to turn the wifi back on.
I had worked around this by defining a separate 'fixed' regulator to power the wifi chip. It declared the real regulator as the 'supply' regulator so that when the mmc driver turns on this pseudo regulator, the real one gets turned on too. The 'fixed' regulator can drive a gpio and I configured it to drive the wifi reset line. So when the regulator was turned off, the wifi was held in reset. When the regulator was turned back on, the reset was release, the power was on, and it all worked beautifully.
But there are two problems with this:
1/ the reset line is also shared with the bluetooth :-( so I cannot hold it
down. It is safe to pulse it down, but the 'fixed' regulator won't do that (without a bit of hacking)
2/ When the voltage is set for the 'fixed' regulator, it is not propagated
back to the real regulator, so the real regulator's voltage doesn't get set properly to make the requirements of the wifi chip.
I can work around the first problem by hacking the 'fixed' regulator, but I wouldn't expect that hack to go upstream.
I can work around the second by observing the hsmmc enables 2 regulators if they are defined: vmmc and vmmc_aux
So I configure the real regulator as vmmc, which gets the voltage setting, and configure the pseudo regulator as vmmc_aux. This gets powered on after vmmc, so the reset happens at the right time.
But I think all this is really just hacking around the problem. I think we need for omap_hsmmc.c to be able to accept a 'reset_gpio' config, and to toggle that after power-on.
It is unfortunate to have to include functionality for one particular device in common code like this, but I really cannot see any other way.
BTW I explicitly set MMC_CAP_POWER_OFF so I don't need any card detect enabled and there is no need to rmmod the device. A simple "ifconfig wlan0 down" will power off the wifi chip, and "ifconfig wlan0 up" will power it on again.
NeilBrown