From patchwork Tue Aug 15 09:16:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 9901459 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A98ED6028A for ; Tue, 15 Aug 2017 09:16:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9809F287ED for ; Tue, 15 Aug 2017 09:16:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CEF128816; Tue, 15 Aug 2017 09:16:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_TVD_MIME_EPI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4CB3287ED for ; Tue, 15 Aug 2017 09:16:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752347AbdHOJQV (ORCPT ); Tue, 15 Aug 2017 05:16:21 -0400 Received: from sauhun.de ([88.99.104.3]:52435 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751807AbdHOJQU (ORCPT ); Tue, 15 Aug 2017 05:16:20 -0400 Received: from localhost (p54B33537.dip0.t-ipconnect.de [84.179.53.55]) by pokefinder.org (Postfix) with ESMTPSA id 710A82C2F95; Tue, 15 Aug 2017 11:16:19 +0200 (CEST) Date: Tue, 15 Aug 2017 11:16:19 +0200 From: Wolfram Sang To: Shawn Lin Cc: Ulf Hansson , linux-mmc@vger.kernel.org, Shawn Guo , Yoshihiro Shimoda Subject: Re: [PATCH v2] mmc: block: prevent propagating R1_OUT_OF_RANGE for open-ending mode Message-ID: <20170815091618.ydnwlqx5ahwvn33e@ninjato> References: <1502152045-150457-1-git-send-email-shawn.lin@rock-chips.com> <20170814175831.bgwr6hwc4tvbkmoc@ninjato> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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): Regards, Wolfram 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;