|
@@ -57,6 +57,7 @@ MODULE_ALIAS("mmc:block");
|
|
#define INAND_CMD38_ARG_SECERASE 0x80
|
|
#define INAND_CMD38_ARG_SECERASE 0x80
|
|
#define INAND_CMD38_ARG_SECTRIM1 0x81
|
|
#define INAND_CMD38_ARG_SECTRIM1 0x81
|
|
#define INAND_CMD38_ARG_SECTRIM2 0x88
|
|
#define INAND_CMD38_ARG_SECTRIM2 0x88
|
|
|
|
+#define MMC_BLK_TIMEOUT_MS (10 * 60 * 1000) /* 10 minute timeout */
|
|
|
|
|
|
static DEFINE_MUTEX(block_mutex);
|
|
static DEFINE_MUTEX(block_mutex);
|
|
|
|
|
|
@@ -1034,6 +1035,9 @@ static int mmc_blk_err_check(struct mmc_card *card,
|
|
*/
|
|
*/
|
|
if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) {
|
|
if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) {
|
|
u32 status;
|
|
u32 status;
|
|
|
|
+ unsigned long timeout;
|
|
|
|
+
|
|
|
|
+ timeout = jiffies + msecs_to_jiffies(MMC_BLK_TIMEOUT_MS);
|
|
do {
|
|
do {
|
|
int err = get_card_status(card, &status, 5);
|
|
int err = get_card_status(card, &status, 5);
|
|
if (err) {
|
|
if (err) {
|
|
@@ -1041,6 +1045,17 @@ static int mmc_blk_err_check(struct mmc_card *card,
|
|
req->rq_disk->disk_name, err);
|
|
req->rq_disk->disk_name, err);
|
|
return MMC_BLK_CMD_ERR;
|
|
return MMC_BLK_CMD_ERR;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /* Timeout if the device never becomes ready for data
|
|
|
|
+ * and never leaves the program state.
|
|
|
|
+ */
|
|
|
|
+ if (time_after(jiffies, timeout)) {
|
|
|
|
+ pr_err("%s: Card stuck in programming state!"\
|
|
|
|
+ " %s %s\n", mmc_hostname(card->host),
|
|
|
|
+ req->rq_disk->disk_name, __func__);
|
|
|
|
+
|
|
|
|
+ return MMC_BLK_CMD_ERR;
|
|
|
|
+ }
|
|
/*
|
|
/*
|
|
* Some cards mishandle the status bits,
|
|
* Some cards mishandle the status bits,
|
|
* so make sure to check both the busy
|
|
* so make sure to check both the busy
|