Fix wrong EXT_CSD_REV handling
PATCH 1/1 Fix wrong EXT_CSD_REV handling
It already checked the ext_csd_struct is less than 2, so it doesn't need to check it.
Current code only accepts the revision 1.2.
---
drivers/mmc/core/mmc.c +7 -9
@@ -217,15 +217,13 @@ static int mmc_read_ext_csd(struct mmc_card *card) goto out; } -if (ext_csd_struct >=2 ) { - card->ext_csd.sectors = - ext_csd[EXT_CSD_SEC_CNT +0 ] <<0 | - ext_csd[EXT_CSD_SEC_CNT +1 ] <<8 | - ext_csd[EXT_CSD_SEC_CNT +2 ] <<16 | - ext_csd[EXT_CSD_SEC_CNT +3 ] <<24 ; -if (card->ext_csd.sectors) -mmc_card_set_blockaddr (card); - } + card->ext_csd.sectors = + ext_csd[EXT_CSD_SEC_CNT +0 ] <<0 | + ext_csd[EXT_CSD_SEC_CNT +1 ] <<8 | + ext_csd[EXT_CSD_SEC_CNT +2 ] <<16 | + ext_csd[EXT_CSD_SEC_CNT +3 ] <<24 ; +if (card->ext_csd.sectors) +mmc_card_set_blockaddr (card);switch (ext_csd[EXT_CSD_CARD_TYPE ]) {case EXT_CSD_CARD_TYPE_52 |EXT_CSD_CARD_TYPE_26 :
Quoted 5 lines · On Thu, 13 Dec 2007 16:13:11 +0900 Kyungmin Park <[email protected]>…
It already checked the
ext_csd_structis less than 2, so it doesn't need to check it.
Current code only accepts the revision 1.2.Signed-off-by Kyungmin Park <[email protected]>
It wasn't wrong the last time you brought this up, and it still isn't wrong. Those bits aren't defined until version 1.2 of the EXT_CSD register, hence we do not trust them. If you have some broken card that you feel you must have support for, then start working on some quirks system.
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
Quoted 10 lines · Pierre Ossman
Quoted 5 lines · On Thu, 13 Dec 2007 16:13:11 +0900 Kyungmin Park <[email protected]>…
It already checked the
ext_csd_structis less than 2, so it doesn't need to check it.
Current code only accepts the revision 1.2.Signed-off-by Kyungmin Park <[email protected]>It wasn't wrong the last time you brought this up, and it still isn't wrong. Those bits aren't defined until version 1.2 of the
EXT_CSDregister, hence we do not trust them. If you have some broken card that you feel you must have support for, then start working on some quirks system.
Now see the code.
First, it checks the ext_csd_struct.
ext_csd_struct = ext_csd[EXT_CSD_REV];
if (ext_csd_struct > 2) {
printk(KERN_ERR "%s: unrecognised EXT_CSD structure "
"version %d\n", mmc_hostname(card->host),
ext_csd_struct);
err = -EINVAL;
goto out;
}
=> here possible values are 0, 1, 2
=> It only accepts the ext_csd 2 but my *broken* card has 1.
so it's failed.
if (ext_csd_struct >= 2) {
card->ext_csd.sectors =
ext_csd[EXT_CSD_SEC_CNT + 0] << 0 |
ext_csd[EXT_CSD_SEC_CNT + 1] << 8 |
ext_csd[EXT_CSD_SEC_CNT + 2] << 16 |
ext_csd[EXT_CSD_SEC_CNT + 3] << 24;
if (card->ext_csd.sectors)
mmc_card_set_blockaddr(card);
}In my MMC Spec. (v4.2), there's no problem to read it even though it's revision 1.1
Anyway how do it handle this one? Do you have any idea?
Thank you,
Kyungmin Park
Quoted 4 lines · On Thu, 13 Dec 2007 17:08:16 +0900 "Kyungmin Park" <[email protected]> wrote:
In my MMC Spec. (v4.2), there's no problem to read it even though it's revision 1.1
Well, the spec says that those reserved fields "should be zero". Unfortunately, people seem to have read this in the IETF sense and not as "the fields MUST be zero". I.e. I've seen cards where reserved fields contain junk.
Quoted 2 lines
Anyway how do it handle this one? Do you have any idea?
The EXT_CSD is read after the CID, so add some table that maps certain workarounds to specific cards. Then add some bit saying "is really EXT_CSD 1.2" and check for that bit when parsing the EXT_CSD.
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
Quoted 10 lines · Pierre Ossman
Quoted 4 lines · On Thu, 13 Dec 2007 17:08:16 +0900 "Kyungmin Park" <[email protected]> wrote:
In my MMC Spec. (v4.2), there's no problem to read it even though it's revision 1.1
Well, the spec says that those reserved fields "should be zero". Unfortunately, people seem to have read this in the IETF sense and not as "the fields MUST be zero". I.e. I've seen cards where reserved fields contain junk.
Yes, reserved word should or must be zero, then it should check "if (ext_csd_struct <= 2)" instead of ">= 2".
In the Spec. 4.2, it can have three value 0, 1, or 2. There's no other restriction.
Thank you,
Kyungmin Park.
Quoted 5 lines · On Fri, 14 Dec 2007 11:01:03 +0900 "Kyungmin Park" <[email protected]> wrote:
Yes, reserved word should or must be zero, then it should check "if (
ext_csd_struct<= 2)" instead of ">= 2".
In the Spec. 4.2, it can have three value 0, 1, or 2. There's no other restriction.
As I said, the spec doesn't say "must", and I've seen cards with bogus data in there so I'm afraid we can't rely on the fields being zero. The version field is the only decent way of determining what to expect in the rest of the structure.
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