From patchwork Fri May 25 06:18:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 10426451 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 C1801602D8 for ; Fri, 25 May 2018 06:18:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6EE62900C for ; Fri, 25 May 2018 06:18:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B4BC29113; Fri, 25 May 2018 06:18:26 +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.4 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_WEB 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 8947E2900C for ; Fri, 25 May 2018 06:18:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752927AbeEYGSY (ORCPT ); Fri, 25 May 2018 02:18:24 -0400 Received: from lucky1.263xmail.com ([211.157.147.135]:40782 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751711AbeEYGSY (ORCPT ); Fri, 25 May 2018 02:18:24 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.177]) by lucky1.263xmail.com (Postfix) with ESMTP id BE1C76DF4; Fri, 25 May 2018 14:18:21 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id F08F339E; Fri, 25 May 2018 14:18:20 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: ulf.hansson@linaro.org X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: <50a38bb8e13a40216d7f7efe76dea465> X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 29578KTX7VV; Fri, 25 May 2018 14:18:21 +0800 (CST) From: Shawn Lin To: Ulf Hansson Cc: linux-mmc@vger.kernel.org, Martin Hicks , Shawn Lin Subject: [PATCH 05/11] mmc: core: Adjust the checking for device status in mmc_do_erase() Date: Fri, 25 May 2018 14:18:03 +0800 Message-Id: <1527229083-217091-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1527228930-216210-1-git-send-email-shawn.lin@rock-chips.com> References: <1527228930-216210-1-git-send-email-shawn.lin@rock-chips.com> 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 mmc_do_erase() gives up checking for bit 17 and bit 18 in device status, as the spec asks hosts to ignore these two bits according to JESD84-B51 spec, section 6.13, table 68(Device status). Also, erase need the device in unlocked status, so we add checking for bit 25. The most important part is checking for bit 15, WP_ERASE_SKIP. The spec says "Only partial address space was erased due to existing write protected blocks.", which obviously means we should fail this I/O. Otherwise, the partial erased data stored in nonvalatile flash violates the data integrity from the view of I/O owner, which probably confuse it when further used. Signed-off-by: Shawn Lin --- drivers/mmc/core/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 42cfcb6..2cb8450 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2077,7 +2077,7 @@ static int mmc_do_erase(struct mmc_card *card, unsigned int from, cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; /* Do not retry else we can't see errors */ err = mmc_wait_for_cmd(card->host, &cmd, 0); - if (err || (cmd.resp[0] & 0xFDF92000)) { + if (err || (cmd.resp[0] & 0xFFF9A000)) { pr_err("error %d requesting status %#x\n", err, cmd.resp[0]); err = -EIO;