From patchwork Mon Aug 14 17:58:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 9899899 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 83F58602CA for ; Mon, 14 Aug 2017 17:59:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 737F627FA1 for ; Mon, 14 Aug 2017 17:59:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 687A4281D2; Mon, 14 Aug 2017 17:59:29 +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 1453C281F9 for ; Mon, 14 Aug 2017 17:59:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750950AbdHNR6m (ORCPT ); Mon, 14 Aug 2017 13:58:42 -0400 Received: from sauhun.de ([88.99.104.3]:50248 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752411AbdHNR6d (ORCPT ); Mon, 14 Aug 2017 13:58:33 -0400 Received: from localhost (p54B33755.dip0.t-ipconnect.de [84.179.55.85]) by pokefinder.org (Postfix) with ESMTPSA id 21E0C2C3335; Mon, 14 Aug 2017 19:58:32 +0200 (CEST) Date: Mon, 14 Aug 2017 19:58:31 +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: <20170814175831.bgwr6hwc4tvbkmoc@ninjato> References: <1502152045-150457-1-git-send-email-shawn.lin@rock-chips.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1502152045-150457-1-git-send-email-shawn.lin@rock-chips.com> 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, really sorry for the delay! But now, here are my thoughts: > + /* > + * Per the SD specification(physical layer version 4.10), > + * 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 missing "if"? ..."even if the sequence"... Yeah, it is missing in the specs, too, but still. > + * is correct". And JESD84-B51 for eMMC also has a similar > + * statement on section 6.8.3. As CMD23 is optional for either > + * cards or hosts, so we need to check the MMC_BLK_CMD23 flag > + * to prevent the OUT_OF_RANGE error for open-ending multiple > + * block operations as it's normal behaviour. > + */ I really like adding this comment. Yet, I don't really get why you check for CMD23, though, since the SD specs say CMD18? As I understand it, this is true for all multiblock accesses, so we could also do something like this (only build tested)? Note that I decided to not couple STOP_ERRORS and CMD_ERRORS in case we need more adjustments in the future. And your comment needs to be added somewhere, too. It is just to show what I mean. Do you think this could work, too? Or am I missing something? Thanks and kind regards, Wolfram diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index f1bbfd389367ff..e83d8291ad4f99 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1362,6 +1362,14 @@ static inline void mmc_apply_rel_rw(struct mmc_blk_request *brq, } } +#define STOP_ERRORS \ + (R1_ADDRESS_ERROR | /* Misaligned address */ \ + R1_BLOCK_LEN_ERROR | /* Transferred block length incorrect */\ + R1_WP_VIOLATION | /* Tried to write to protected block */ \ + R1_CARD_ECC_FAILED | /* Card ECC failed */ \ + R1_CC_ERROR | /* Card controller error */ \ + R1_ERROR) /* General/unknown error */ + #define CMD_ERRORS \ (R1_OUT_OF_RANGE | /* Command argument out of range */ \ R1_ADDRESS_ERROR | /* Misaligned address */ \ @@ -1371,9 +1379,9 @@ 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 bool mmc_blk_has_cmd_err(struct mmc_command *cmd, u32 err_mask) { - if (!cmd->error && cmd->resp[0] & CMD_ERRORS) + if (!cmd->error && cmd->resp[0] & err_mask) cmd->error = -EIO; return cmd->error; @@ -1400,7 +1408,7 @@ 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) || + if (brq->sbc.error || brq->cmd.error || mmc_blk_has_cmd_err(&brq->stop, STOP_ERRORS) || brq->data.error) { switch (mmc_blk_cmd_recovery(card, req, brq, &ecc_err, &gen_err)) { case ERR_RETRY: