aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Lin <shawn.lin@rock-chips.com>2017-08-17 21:16:08 -0400
committerUlf Hansson <ulf.hansson@linaro.org>2017-08-21 07:32:31 -0400
commitd83c2dbaa90a9bd6346e234d9802080a9c7b2fea (patch)
treebbc529eb3f0333c101858500bea1a656cb3a35a9
parent14ccee78fc82f5512908f4424f541549a5705b89 (diff)
mmc: block: prevent propagating R1_OUT_OF_RANGE for open-ending mode
We to some extent should tolerate R1_OUT_OF_RANGE for open-ending mode as it is expected behaviour and most of the backup partition tables should be located near some of the last blocks which will always make open-ending read exceed the capacity of cards. Fixes: 9820a5b11101 ("mmc: core: for data errors, take response of stop cmd into account") Fixes: a04e6bae9e6f ("mmc: core: check also R1 response for stop commands") Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Tested-by: Shawn Guo <shawnguo@kernel.org> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r--drivers/mmc/core/block.c49
1 files changed, 43 insertions, 6 deletions
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index f1bbfd389367..80d1ec693d2d 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -1371,12 +1371,46 @@ static inline void mmc_apply_rel_rw(struct mmc_blk_request *brq,
1371 R1_CC_ERROR | /* Card controller error */ \ 1371 R1_CC_ERROR | /* Card controller error */ \
1372 R1_ERROR) /* General/unknown error */ 1372 R1_ERROR) /* General/unknown error */
1373 1373
1374static bool mmc_blk_has_cmd_err(struct mmc_command *cmd) 1374static void mmc_blk_eval_resp_error(struct mmc_blk_request *brq)
1375{ 1375{
1376 if (!cmd->error && cmd->resp[0] & CMD_ERRORS) 1376 u32 val;
1377 cmd->error = -EIO;
1378 1377
1379 return cmd->error; 1378 /*
1379 * Per the SD specification(physical layer version 4.10)[1],
1380 * section 4.3.3, it explicitly states that "When the last
1381 * block of user area is read using CMD18, the host should
1382 * ignore OUT_OF_RANGE error that may occur even the sequence
1383 * is correct". And JESD84-B51 for eMMC also has a similar
1384 * statement on section 6.8.3.
1385 *
1386 * Multiple block read/write could be done by either predefined
1387 * method, namely CMD23, or open-ending mode. For open-ending mode,
1388 * we should ignore the OUT_OF_RANGE error as it's normal behaviour.
1389 *
1390 * However the spec[1] doesn't tell us whether we should also
1391 * ignore that for predefined method. But per the spec[1], section
1392 * 4.15 Set Block Count Command, it says"If illegal block count
1393 * is set, out of range error will be indicated during read/write
1394 * operation (For example, data transfer is stopped at user area
1395 * boundary)." In another word, we could expect a out of range error
1396 * in the response for the following CMD18/25. And if argument of
1397 * CMD23 + the argument of CMD18/25 exceed the max number of blocks,
1398 * we could also expect to get a -ETIMEDOUT or any error number from
1399 * the host drivers due to missing data response(for write)/data(for
1400 * read), as the cards will stop the data transfer by itself per the
1401 * spec. So we only need to check R1_OUT_OF_RANGE for open-ending mode.
1402 */
1403
1404 if (!brq->stop.error) {
1405 bool oor_with_open_end;
1406 /* If there is no error yet, check R1 response */
1407
1408 val = brq->stop.resp[0] & CMD_ERRORS;
1409 oor_with_open_end = val & R1_OUT_OF_RANGE && !brq->mrq.sbc;
1410
1411 if (val && !oor_with_open_end)
1412 brq->stop.error = -EIO;
1413 }
1380} 1414}
1381 1415
1382static enum mmc_blk_status mmc_blk_err_check(struct mmc_card *card, 1416static enum mmc_blk_status mmc_blk_err_check(struct mmc_card *card,
@@ -1400,8 +1434,11 @@ static enum mmc_blk_status mmc_blk_err_check(struct mmc_card *card,
1400 * stop.error indicates a problem with the stop command. Data 1434 * stop.error indicates a problem with the stop command. Data
1401 * may have been transferred, or may still be transferring. 1435 * may have been transferred, or may still be transferring.
1402 */ 1436 */
1403 if (brq->sbc.error || brq->cmd.error || mmc_blk_has_cmd_err(&brq->stop) || 1437
1404 brq->data.error) { 1438 mmc_blk_eval_resp_error(brq);
1439
1440 if (brq->sbc.error || brq->cmd.error ||
1441 brq->stop.error || brq->data.error) {
1405 switch (mmc_blk_cmd_recovery(card, req, brq, &ecc_err, &gen_err)) { 1442 switch (mmc_blk_cmd_recovery(card, req, brq, &ecc_err, &gen_err)) {
1406 case ERR_RETRY: 1443 case ERR_RETRY:
1407 return MMC_BLK_RETRY; 1444 return MMC_BLK_RETRY;