MMC core:

- Don't return error code R1_OUT_OF_RANGE for open-ending mode
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJZn/APAAoJEP4mhCVzWIwpPD4QAKb7ibtDveRRyV27sBD99Lgo
 N6fXhTEVkEvtKt90eAs+e6n3egoknfe4bPi698oaiG3YrxE6EKB/z4ffDRCdZwPu
 wc9IfKeeUTm+tkWHQOxS67xNO8mqNDMtBRvr/jaJE9P79BLtG5/scIf+27c0DdS1
 RolaDTbPKGlQ11F+p7Z1IIxQnpBp0KXXfdg3qJhBT91C0UdN3/4Om+jceJ7VgjcO
 FIgMVWxlQg00wdGGMcNhBTeynzGk+KPVXXf4sRho65WzHxYxWek2JJ5AnLdfvNZ/
 6pcr9XAHnY4TDtDThpajuZyQtVa45yHV5qq0RDjHc+IPN6XG30XrOGJt9iWEAUmp
 W4zzf3j9edTDCkKa9fnFFbFdGKH4q6aow4Ndp20v/Tga3zIZg0n9WilNakl2xDRP
 RIrlD2ndLX+V2uRZzvZ00XlpL+DglY3kp8MCXp4sD2LteG3K0iXQHKW7qtlkqADg
 cs18hIhhhGaT/zJsNVsNBrTPywk/qMfp4pfwGqLwQ8V98iol850XQj8pJ4IQoErs
 KhM3Wmp1nkHBHCYzrTjGd9ulUKvJiky1mE0wmYTHAsHBFLg6B2/NoeMF4dAokmaU
 iMbPlulD2o7HUiuufmh0LL4qPr2EikdBy4thOKStyPUXhavN6WHWEae1u3V+vGuY
 C+rzk6ZfULFXEt+k5B2l
 =JiUR
 -----END PGP SIGNATURE-----

Merge tag 'mmc-v4.13-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc

Pull MMC fix from Ulf Hansson:
 "MMC core: don't return error code R1_OUT_OF_RANGE for open-ending mode"

* tag 'mmc-v4.13-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc:
  mmc: block: prevent propagating R1_OUT_OF_RANGE for open-ending mode
This commit is contained in:
Linus Torvalds 2017-08-25 16:57:53 -07:00
commit 299c460876
1 changed files with 43 additions and 6 deletions

View File

@ -1371,12 +1371,46 @@ static inline void mmc_apply_rel_rw(struct mmc_blk_request *brq,
R1_CC_ERROR | /* Card controller error */ \
R1_ERROR) /* General/unknown error */
static bool mmc_blk_has_cmd_err(struct mmc_command *cmd)
static void mmc_blk_eval_resp_error(struct mmc_blk_request *brq)
{
if (!cmd->error && cmd->resp[0] & CMD_ERRORS)
cmd->error = -EIO;
u32 val;
return cmd->error;
/*
* Per the SD specification(physical layer version 4.10)[1],
* section 4.3.3, it explicitly states that "When the last
* block of user area is read using CMD18, the host should
* ignore OUT_OF_RANGE error that may occur even the sequence
* is correct". And JESD84-B51 for eMMC also has a similar
* statement on section 6.8.3.
*
* Multiple block read/write could be done by either predefined
* method, namely CMD23, or open-ending mode. For open-ending mode,
* we should ignore the OUT_OF_RANGE error as it's normal behaviour.
*
* However the spec[1] doesn't tell us whether we should also
* ignore that for predefined method. But per the spec[1], section
* 4.15 Set Block Count Command, it says"If illegal block count
* is set, out of range error will be indicated during read/write
* operation (For example, data transfer is stopped at user area
* boundary)." In another word, we could expect a out of range error
* in the response for the following CMD18/25. And if argument of
* CMD23 + the argument of CMD18/25 exceed the max number of blocks,
* we could also expect to get a -ETIMEDOUT or any error number from
* the host drivers due to missing data response(for write)/data(for
* read), as the cards will stop the data transfer by itself per the
* spec. So we only need to check R1_OUT_OF_RANGE for open-ending mode.
*/
if (!brq->stop.error) {
bool oor_with_open_end;
/* If there is no error yet, check R1 response */
val = brq->stop.resp[0] & CMD_ERRORS;
oor_with_open_end = val & R1_OUT_OF_RANGE && !brq->mrq.sbc;
if (val && !oor_with_open_end)
brq->stop.error = -EIO;
}
}
static 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,
* stop.error indicates a problem with the stop command. Data
* may have been transferred, or may still be transferring.
*/
if (brq->sbc.error || brq->cmd.error || mmc_blk_has_cmd_err(&brq->stop) ||
brq->data.error) {
mmc_blk_eval_resp_error(brq);
if (brq->sbc.error || brq->cmd.error ||
brq->stop.error || brq->data.error) {
switch (mmc_blk_cmd_recovery(card, req, brq, &ecc_err, &gen_err)) {
case ERR_RETRY:
return MMC_BLK_RETRY;