Skip to contentSkip to conversation

MMC - Driver hangs if using bad SDCard

DISCUSSION Radovan Lekanovic 1 participant 1 message May 21, 2010 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

Hi

I have experienced problems with the MMC driver if using an bad SD card the MMC driver ends up in an infinite loop in file block.c function mmc_blk_issue_rq.

if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) {

do {

int err;

cmd.opcode = MMC_SEND_STATUS;

cmd.arg = card->rca << 16;

cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;

err = mmc_wait_for_cmd(card->host, &cmd, 5);

if (err) {

printk(KERN_ERR "%s: error %d requesting status\n",

req->rq_disk->disk_name, err);

goto cmd_err;

}

/*

* Some cards mishandle the status bits,

* so make sure to check both the busy

* indication and the card state.

*/

} while (!(cmd.resp[0] & R1_READY_FOR_DATA) ||

(R1_CURRENT_STATE(cmd.resp[0]) == 7));

The problem is that R1_CURRENT_STATE(cmd.resp[0]) == 7 will always be TRUE. This problem will drain the battery on portabel devices.
The card works fine on other devices.
My idea to solve this problem is to break this loop by an timer if it take too long time for the SD-Card to replay. Will that solution break anything? Any other better solutions?

BR
Lekan