From patchwork Wed Sep 4 12:21:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seungwon Jeon X-Patchwork-Id: 2853635 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0271A9F3DC for ; Wed, 4 Sep 2013 12:21:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A37E320363 for ; Wed, 4 Sep 2013 12:21:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2B9A420357 for ; Wed, 4 Sep 2013 12:21:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757470Ab3IDMVJ (ORCPT ); Wed, 4 Sep 2013 08:21:09 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:29768 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757142Ab3IDMVI (ORCPT ); Wed, 4 Sep 2013 08:21:08 -0400 Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MSL00B6SOZ4F970@mailout4.samsung.com> for linux-mmc@vger.kernel.org; Wed, 04 Sep 2013 21:21:06 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [203.254.230.47]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 35.88.17682.2B527225; Wed, 04 Sep 2013 21:21:06 +0900 (KST) X-AuditID: cbfee68e-b7f756d000004512-c5-522725b22451 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 80.0A.05832.2B527225; Wed, 04 Sep 2013 21:21:06 +0900 (KST) Received: from DOTGIHJUN01 ([12.23.118.161]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MSL007ZVOZ6K960@mmp2.samsung.com>; Wed, 04 Sep 2013 21:21:06 +0900 (KST) From: Seungwon Jeon To: 'linux-mmc' Cc: 'Chris Ball' , 'Ulf Hansson' References: <002301ce9e6b$e72da2a0$b588e7e0$%jun@samsung.com> <002901cea22c$af778730$0e669590$%jun@samsung.com> <001d01cea911$8a509c80$9ef1d580$%jun@samsung.com> In-reply-to: <001d01cea911$8a509c80$9ef1d580$%jun@samsung.com> Subject: [PATCH v3] mmc: add ignorance case for CMD13 CRC error Date: Wed, 04 Sep 2013 21:21:05 +0900 Message-id: <002b01cea969$3ab56630$b0203290$%jun@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-transfer-encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-index: Ac6opVY5BXTnp1aGS9ST7gcaExsxmQAaKFaQABPF9NA= Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrAIsWRmVeSWpSXmKPExsVy+t8zfd1NqupBBvsWK1lsf72RzeLI/35G i+Nrwx2YPQ5dWcvocefaHjaPz5vkApijuGxSUnMyy1KL9O0SuDLerHvLVnBLumL/ufvMDYwT xLoYOTkkBEwkdq5cxARhi0lcuLeeDcQWEljGKDHxiihMza2+z4xdjFxA8emMEof3b4By/jBK 9Ox4CtbNJqAl8ffNG2YQW0RAW2LjrKPsIDazgKfEi5dt7BBTNzNJ3L+rAGJzCthJHN3xD2yb sIC9ROOft2A2i4CqxI6rc8HqeQVsJdo+XWGGsAUlfky+x9LFyAE0U11iypRciPHyEpvXvGUG CUsAhR/91YW4wEri/uRfjBAlIhL7XrwDO1lCYB+7xPa5W1ghVglIfJt8iAWiV1Zi0wFmiH8l JQ6uuMEygVFi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y90iKVxPf3hVZ/iqv42 dd6UP4GfxeIzzKxu+/R9Ov5Euj+R46BFu6iG4lWzx/vfK0vMTBY+s5rHIuOy0vkCTrNrEU/m R80p4f/EbZLaf2Kbu5dKK2c159X+JTU77GIq3C3OyAS8O+bs9OJKhJdLY3bZ8rcqKxcsvr3l RBPnw8ldSizFGYmGWsxFxYkA3cVFtjEDAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP While speed mode is changed, CMD13 cannot be guaranteed. According to the spec., it is not recommended to use CMD13 to check the busy completion of the timing change. If CMD13 is used in this case, CRC error must be ignored. Signed-off-by: Seungwon Jeon Acked-by: Ulf Hansson --- Change in v3: - Adjusted condition with MMC_CAP_WAIT_WHILE_BUSY.(From Ulf Hansson) Change in v2: - Removed function declaration.(From Ulf Hansson) drivers/mmc/core/mmc_ops.c | 73 +++++++++++++++++++++++++++----------------- 1 files changed, 45 insertions(+), 28 deletions(-) diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index ef18348..37f7d70 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -23,6 +23,40 @@ #define MMC_OPS_TIMEOUT_MS (10 * 60 * 1000) /* 10 minute timeout */ +static inline int __mmc_send_status(struct mmc_card *card, u32 *status, + bool ignore_crc) +{ + int err; + struct mmc_command cmd = {0}; + + BUG_ON(!card); + BUG_ON(!card->host); + + cmd.opcode = MMC_SEND_STATUS; + if (!mmc_host_is_spi(card->host)) + cmd.arg = card->rca << 16; + cmd.flags = MMC_RSP_SPI_R2 | MMC_RSP_R1 | MMC_CMD_AC; + if (ignore_crc) + cmd.flags &= ~MMC_RSP_CRC; + + err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES); + if (err) + return err; + + /* NOTE: callers are required to understand the difference + * between "native" and SPI format status words! + */ + if (status) + *status = cmd.resp[0]; + + return 0; +} + +int mmc_send_status(struct mmc_card *card, u32 *status) +{ + return __mmc_send_status(card, status, false); +} + static int _mmc_select_card(struct mmc_host *host, struct mmc_card *card) { int err; @@ -380,6 +414,7 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, struct mmc_command cmd = {0}; unsigned long timeout; u32 status; + bool ignore_crc = false; BUG_ON(!card); BUG_ON(!card->host); @@ -408,10 +443,18 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, if (!use_busy_signal) return 0; - /* Must check status to be sure of no errors */ + /* + * Must check status to be sure of no errors + * If CMD13 is to check the busy completion of the timing change, + * disable the check of CRC error. + */ + if (index == EXT_CSD_HS_TIMING && + !(card->host->caps & MMC_CAP_WAIT_WHILE_BUSY)) + ignore_crc = true; + timeout = jiffies + msecs_to_jiffies(MMC_OPS_TIMEOUT_MS); do { - err = mmc_send_status(card, &status); + err = __mmc_send_status(card, &status, ignore_crc); if (err) return err; if (card->host->caps & MMC_CAP_WAIT_WHILE_BUSY) @@ -449,32 +492,6 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, } EXPORT_SYMBOL_GPL(mmc_switch); -int mmc_send_status(struct mmc_card *card, u32 *status) -{ - int err; - struct mmc_command cmd = {0}; - - BUG_ON(!card); - BUG_ON(!card->host); - - cmd.opcode = MMC_SEND_STATUS; - if (!mmc_host_is_spi(card->host)) - cmd.arg = card->rca << 16; - cmd.flags = MMC_RSP_SPI_R2 | MMC_RSP_R1 | MMC_CMD_AC; - - err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES); - if (err) - return err; - - /* NOTE: callers are required to understand the difference - * between "native" and SPI format status words! - */ - if (status) - *status = cmd.resp[0]; - - return 0; -} - static int mmc_send_bus_test(struct mmc_card *card, struct mmc_host *host, u8 opcode, u8 len)