Skip to content

Commit 6d3898a

Browse files
ahunter6storulf
authored andcommitted
mmc: block: Add error-handling comments
Add error-handling comments to explain what would also be done for blk-mq if it used the legacy error-handling. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Tested-by: Linus Walleij <linus.walleij@linaro.org>
1 parent afab1bb commit 6d3898a

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

drivers/mmc/core/block.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1911,7 +1911,11 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)
19111911
case MMC_BLK_SUCCESS:
19121912
case MMC_BLK_PARTIAL:
19131913
/*
1914-
* A block was successfully transferred.
1914+
* Reset success, and accept bytes_xfered. For
1915+
* MMC_BLK_PARTIAL re-submit the remaining request. For
1916+
* MMC_BLK_SUCCESS error out the remaining request (it
1917+
* could not be re-submitted anyway if a next request
1918+
* had already begun).
19151919
*/
19161920
mmc_blk_reset_success(md, type);
19171921

@@ -1931,6 +1935,14 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)
19311935
}
19321936
break;
19331937
case MMC_BLK_CMD_ERR:
1938+
/*
1939+
* For SD cards, get bytes written, but do not accept
1940+
* bytes_xfered if that fails. For MMC cards accept
1941+
* bytes_xfered. Then try to reset. If reset fails then
1942+
* error out the remaining request, otherwise retry
1943+
* once (N.B mmc_blk_reset() will not succeed twice in a
1944+
* row).
1945+
*/
19341946
req_pending = mmc_blk_rw_cmd_err(md, card, brq, old_req, req_pending);
19351947
if (mmc_blk_reset(md, card->host, type)) {
19361948
if (req_pending)
@@ -1947,11 +1959,20 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)
19471959
}
19481960
break;
19491961
case MMC_BLK_RETRY:
1962+
/*
1963+
* Do not accept bytes_xfered, but retry up to 5 times,
1964+
* otherwise same as abort.
1965+
*/
19501966
retune_retry_done = brq->retune_retry_done;
19511967
if (retry++ < 5)
19521968
break;
19531969
/* Fall through */
19541970
case MMC_BLK_ABORT:
1971+
/*
1972+
* Do not accept bytes_xfered, but try to reset. If
1973+
* reset succeeds, try once more, otherwise error out
1974+
* the request.
1975+
*/
19551976
if (!mmc_blk_reset(md, card->host, type))
19561977
break;
19571978
mmc_blk_rw_cmd_abort(mq, card, old_req, mq_rq);
@@ -1960,6 +1981,13 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)
19601981
case MMC_BLK_DATA_ERR: {
19611982
int err;
19621983

1984+
/*
1985+
* Do not accept bytes_xfered, but try to reset. If
1986+
* reset succeeds, try once more. If reset fails with
1987+
* ENODEV which means the partition is wrong, then error
1988+
* out the request. Otherwise attempt to read one sector
1989+
* at a time.
1990+
*/
19631991
err = mmc_blk_reset(md, card->host, type);
19641992
if (!err)
19651993
break;
@@ -1971,6 +1999,10 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)
19711999
/* Fall through */
19722000
}
19732001
case MMC_BLK_ECC_ERR:
2002+
/*
2003+
* Do not accept bytes_xfered. If reading more than one
2004+
* sector, try reading one sector at a time.
2005+
*/
19742006
if (brq->data.blocks > 1) {
19752007
/* Redo read one sector at a time */
19762008
pr_warn("%s: retrying using single block read\n",
@@ -1992,10 +2024,12 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)
19922024
}
19932025
break;
19942026
case MMC_BLK_NOMEDIUM:
2027+
/* Do not accept bytes_xfered. Error out the request */
19952028
mmc_blk_rw_cmd_abort(mq, card, old_req, mq_rq);
19962029
mmc_blk_rw_try_restart(mq, new_req, mqrq_cur);
19972030
return;
19982031
default:
2032+
/* Do not accept bytes_xfered. Error out the request */
19992033
pr_err("%s: Unhandled return value (%d)",
20002034
old_req->rq_disk->disk_name, status);
20012035
mmc_blk_rw_cmd_abort(mq, card, old_req, mq_rq);

0 commit comments

Comments
 (0)