Skip to contentSkip to conversation

mmc: avoid getting CID on SDIO-only cards

PATCH In review David Vrabel 2 participants 2 messages Aug 18, 2010 – Aug 19, 2010 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: avoid getting CID on SDIO-only cards

The introduction of support for SD combo cards breaks the initialization of all CSR SDIO chips. The GO_IDLE (CMD0) in mmc_sd_get_cid() causes CSR chips to be reset (this is non-standard behavior).

When initializing an SDIO card check for a combo card by using the memory present bit in the R4 response to IO_SEND_OP_COND (CMD5). This avoids the call to mmc_sd_get_cid() on an SDIO-only card.

Cc Michał Mirosław <[email protected]>

---
Andrew, this is a regression in 2.6.36-rc1. Please queue for 2.6.36 if Michał acks it.

---
 drivers/mmc/core/sdio.c  |    8 +++++---
 include/linux/mmc/sdio.h |    2 ++
 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/mmc/core/sdio.c +5 -3
index bd2755e..cc34523 100644
@@ -362,11 +362,13 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr,
 		goto err;
 	}
 
-	err = mmc_sd_get_cid(host, host->ocr & ocr, card->raw_cid);
-
-	if (!err) {
+	if (ocr & R4_MEMORY_PRESENT) {
 		card->type = MMC_TYPE_SD_COMBO;
 
+		err = mmc_sd_get_cid(host, host->ocr & ocr, card->raw_cid);
+		if (err)
+			goto remove;
+
 		if (oldcard && (oldcard->type != MMC_TYPE_SD_COMBO ||
 		    memcmp(card->raw_cid, oldcard->raw_cid, sizeof(card->raw_cid)) != 0)) {
 			mmc_remove_card(card);
include/linux/mmc/sdio.h +2 -0
index 329a8fa..245cdac 100644
@@ -38,6 +38,8 @@
  *      [8:0] Byte/block count
  */
 
+#define R4_MEMORY_PRESENT (1 << 27)
+
 /*
   SDIO status in R5
   Type
Signature · 1 line
1.6.3.3
#1 lore raw
Quoted 26 lines · David Vrabel

The introduction of support for SD combo cards breaks the initialization of all CSR SDIO chips. The GO_IDLE (CMD0) in mmc_sd_get_cid() causes CSR chips to be reset (this is non-standard behavior).

When initializing an SDIO card check for a combo card by using the memory present bit in the R4 response to IO_SEND_OP_COND (CMD5). This avoids the call to mmc_sd_get_cid() on an SDIO-only card.

Cc Michał Mirosław <[email protected]>

---
Andrew, this is a regression in 2.6.36-rc1. Please queue for 2.6.36 if Michał acks it.

---
 drivers/mmc/core/sdio.c  |    8 +++++---
 include/linux/mmc/sdio.h |    2 ++
 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/mmc/core/sdio.c +0 -0
index bd2755e..cc34523 100644
@@ -362,11 +362,13 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr,
 		goto err;
 	}
 

drivers/mmc/core/sdio.c static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, · line 371

Quoted 10 lines
drivers/mmc/core/sdio.c +5 -3
-	err = mmc_sd_get_cid(host, host->ocr & ocr, card->raw_cid);
-
-	if (!err) {
+	if (ocr & R4_MEMORY_PRESENT) {
 		card->type = MMC_TYPE_SD_COMBO;
 
+		err = mmc_sd_get_cid(host, host->ocr & ocr, card->raw_cid);
+		if (err)
+			goto remove;
+

In case of memory part init failure, SDIO part will not be initialized with your patch. This, too, is nonstandard, but SDIO might actually work even if memory part is broken.

You can change the condition to:

if ((ocr & R4_MEMORY_PRESENT) && !(err = mmc_sd_get_cid(host, host->ocr & ocr, card->raw_cid)))

(or something better following kernel coding style).

With that change you have my Acked-by.

Quoted 18 lines
drivers/mmc/core/sdio.c +0 -0
 		if (oldcard && (oldcard->type != MMC_TYPE_SD_COMBO ||
 		    memcmp(card->raw_cid, oldcard->raw_cid, sizeof(card->raw_cid)) != 0)) {
 			mmc_remove_card(card);
include/linux/mmc/sdio.h +2 -0
index 329a8fa..245cdac 100644
@@ -38,6 +38,8 @@
  *      [8:0] Byte/block count
  */
 
+#define R4_MEMORY_PRESENT (1 << 27)
+
 /*
   SDIO status in R5
   Type
Signature · 1 line
1.6.3.3

Best Regards,
Michał Mirosław