MMC: Select only one voltage bit in OCR response
PATCH 1/1 MMC: Select only one voltage bit in OCR response
The card might go to inactive state (according to specification), if there are unsupported bits set in the OCR.
---
drivers/mmc/mmc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
8208e380f51ca772e84a0b83098d24aacfa3cc2b
drivers/mmc/mmc.c +1 -1
@@ -475,7 +475,7 @@ static u32 mmc_select_voltage(struct mmcif (bit) { bit -=1 ; - ocr =3 << bit; + ocr =1 << bit; host->ios.vdd = bit;mmc_set_ios (host);
Signature · 1 line
1.2.3.g90cc1
Quoted 2 lines · Timo Teras
The card might go to inactive state (according to specification), if there are unsupported bits set in the OCR.
NAK. This breaks some MMC cards.
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Quoted 5 lines · Russell King
Quoted 2 lines · Timo Teras
The card might go to inactive state (according to specification), if there are unsupported bits set in the OCR.
NAK. This breaks some MMC cards.
I see. But if we do send an OCR with an unsupported bit set, the card will go to inactive state and is unusable. This problem is masked on controllers with only 3.3V support, but I'm working with a controller supporting several different voltages.
For example, I have a card giving an OCR reply of 0x0ff80080. The current code will reply to this with 0x00000180 which is clearly incorrect.
Maybe something like "ocr &= 3 << bit;" would be more approriate?
Cheers,
Timo
PATCH 1/1 MMC: Do not set unsupported bits in OCR response
In reply to Russell KingThe card might go to inactive state (according to specification), if there are unsupported bits set in the OCR.
---
drivers/mmc/mmc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mmc/mmc.c +1 -1
@@ -475,7 +475,7 @@ static u32 mmc_select_voltage(struct mmcif (bit) { bit -=1 ; - ocr =3 << bit; + ocr &=3 << bit; host->ios.vdd = bit;mmc_set_ios (host);
Quoted 10 lines · Timo Teras
I see. But if we do send an OCR with an unsupported bit set, the card will go to inactive state and is unusable. This problem is masked on controllers with only 3.3V support, but I'm working with a controller supporting several different voltages.
For example, I have a card giving an OCR reply of
0x0ff80080. The current code will reply to this with0x00000180which is clearly incorrect.Maybe something like "ocr &= 3 << bit;" would be more approriate?
Russell? Comments? Do you still have the offending card?
Signature · 6 lines
-- Pierre Ossman Linux kernel, MMC maintainer http://www.kernel.org PulseAudio, core developer http://pulseaudio.org rdesktop, core developer http://www.rdesktop.org OLPC, developer http://www.laptop.org
(In case you've missed it)
Quoted 14 lines · Pierre Ossman
Quoted 10 lines · Timo Teras
I see. But if we do send an OCR with an unsupported bit set, the card will go to inactive state and is unusable. This problem is masked on controllers with only 3.3V support, but I'm working with a controller supporting several different voltages.
For example, I have a card giving an OCR reply of
0x0ff80080. The current code will reply to this with0x00000180which is clearly incorrect.Maybe something like "ocr &= 3 << bit;" would be more approriate?
Russell? Comments? Do you still have the offending card?
Signature · 5 lines
-- Pierre Ossman Linux kernel, MMC maintainer http://www.kernel.org PulseAudio, core developer http://pulseaudio.org rdesktop, core developer http://www.rdesktop.org
Quoted 6 lines · Pierre Ossman
Quoted 5 lines · Timo Teras
I see. But if we do send an OCR with an unsupported bit set, the card will go to inactive state and is unusable. This problem is masked on controllers with only 3.3V support, but I'm working with a controller supporting several different voltages.
Quoted 7 lines
Quoted 5 lines
For example, I have a card giving an OCR reply of
0x0ff80080. The current code will reply to this with0x00000180which is clearly incorrect.Maybe something like "ocr &= 3 << bit;" would be more approriate?
Russell? Comments? Do you still have the offending card?
It wasn't my cards, but was reported by several other folk. I don't think we can revert on this without breakage.
However, we should probably ensure that we don't end up setting voltage bits which the cards don't support. So maybe masking the resulting OCR value with the received combined OCR would be a good idea? Such as:
drivers/mmc/mmc.c +6 -5
@@ -467,23 +467,24 @@ static inline void mmc_delay(unsigned in*/ static u32 mmc_select_voltage (struct mmc_host *host,u32 ocr) { +u32 selected_ocr;int bit; - ocr &= host->ocr_avail; + selected_ocr = ocr & host->ocr_avail; - bit =ffs (ocr); + bit =ffs (selected_ocr);if (bit) { bit -=1 ; - ocr =3 << bit; + selected_ocr =3 << bit; host->ios.vdd = bit;mmc_set_ios (host); }else { - ocr =0 ; + selected_ocr =0 ; } -return ocr; +return selected_ocr & ocr; }#define UNSTUFF_BITS (resp,start,size) \
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Quoted 10 lines · Russell King
Quoted 3 lines
Quoted 2 lines
Maybe something like "ocr &= 3 << bit;" would be more approriate?
Russell? Comments? Do you still have the offending card?
It wasn't my cards, but was reported by several other folk. I don't think we can revert on this without breakage.
However, we should probably ensure that we don't end up setting voltage bits which the cards don't support. So maybe masking the resulting OCR value with the received combined OCR would be a good idea? Such as:
Isn't this exactly what Timo is proposing above?
Cheers,
Juha
Quoted 32 lines
drivers/mmc/mmc.c +6
-5@@ -467,23 +467,24 @@ static inline void mmc_delay(unsigned in*/ static u32 mmc_select_voltage (struct mmc_host *host,u32 ocr) { +u32 selected_ocr;int bit; - ocr &= host->ocr_avail; + selected_ocr = ocr & host->ocr_avail; - bit =ffs (ocr); + bit =ffs (selected_ocr);if (bit) { bit -=1 ; - ocr =3 << bit; + selected_ocr =3 << bit; host->ios.vdd = bit;mmc_set_ios (host); }else { - ocr =0 ; + selected_ocr =0 ; } -return ocr; +return selected_ocr & ocr; }
Quoted 3 lines · Juha Yrjola
Isn't this exactly what Timo is proposing above?
I sure can't see the difference. Timo's patch queued up for -mm.
Rgds
Signature · 5 lines
-- Pierre Ossman Linux kernel, MMC maintainer http://www.kernel.org PulseAudio, core developer http://pulseaudio.org rdesktop, core developer http://www.rdesktop.org