Message ID | 20170815091618.ydnwlqx5ahwvn33e@ninjato (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hi Wolfram, On 2017/8/15 17:16, Wolfram Sang wrote: > Hi Shawn, > >> So that implies we only need to care about open-ending mode. > > I see. Thanks for the explanation. > >> I could fold in the description from the spec see explain why >> we don't need to check this for the CMD23 cases. > > That would be great. > >> Does all the above sound goot to you? > > Basically, yes. If we need to check for CMD23 then, I wonder if why we > really need to do (md->flags & MMC_BLK_CMD23) or if we can't simply > check the presence of brq->mrq.sbc? That could then lead to the > following refactorization which is a lot easier to read IMO (but only > compile tested, just to give you an idea what I had in mind): > Ok, I get your point and it looks good to me as I also plan to introduce ACMD23 for SD card and your suggestion also inspire me there to simplify the patch. Great, I will respin v3 then. :) Thanks for sharing your thought! > diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c > index f1bbfd389367ff..1cf905d0e88e77 100644 > --- a/drivers/mmc/core/block.c > +++ b/drivers/mmc/core/block.c > @@ -1371,12 +1371,17 @@ 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) > +/* Map R1 errors to error codes */ > +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; > + /* If there is no error yet, check R1 response */ > + if (!brq->stop.error) { > + val = brq->stop.resp[0] & CMD_ERRORS; > + if (val && !(val & R1_OUT_OF_RANGE && brq->mrq.sbc)) > + brq->stop.error = -EIO; > + } > } > > static enum mmc_blk_status mmc_blk_err_check(struct mmc_card *card, > @@ -1400,8 +1405,10 @@ 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; > > Regards, > > Wolfram > -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index f1bbfd389367ff..1cf905d0e88e77 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1371,12 +1371,17 @@ 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) +/* Map R1 errors to error codes */ +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; + /* If there is no error yet, check R1 response */ + if (!brq->stop.error) { + val = brq->stop.resp[0] & CMD_ERRORS; + if (val && !(val & R1_OUT_OF_RANGE && brq->mrq.sbc)) + brq->stop.error = -EIO; + } } static enum mmc_blk_status mmc_blk_err_check(struct mmc_card *card, @@ -1400,8 +1405,10 @@ 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;