From patchwork Mon Aug 26 07:20:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seungwon Jeon X-Patchwork-Id: 2849406 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0CE3EBF546 for ; Mon, 26 Aug 2013 07:20:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AC2392011F for ; Mon, 26 Aug 2013 07:20:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 07FB320103 for ; Mon, 26 Aug 2013 07:20:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756438Ab3HZHUJ (ORCPT ); Mon, 26 Aug 2013 03:20:09 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:24499 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756377Ab3HZHUH (ORCPT ); Mon, 26 Aug 2013 03:20:07 -0400 Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MS400E0EN1H79M0@mailout1.samsung.com> for linux-mmc@vger.kernel.org; Mon, 26 Aug 2013 16:20:05 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.48]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id 97.91.30629.5A10B125; Mon, 26 Aug 2013 16:20:05 +0900 (KST) X-AuditID: cbfee68d-b7fe86d0000077a5-ec-521b01a56f3f Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 4C.CB.09055.5A10B125; Mon, 26 Aug 2013 16:20:05 +0900 (KST) Received: from DOTGIHJUN01 ([12.23.118.161]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MS4000OKN1GRT50@mmp1.samsung.com>; Mon, 26 Aug 2013 16:20:04 +0900 (KST) From: Seungwon Jeon To: 'linux-mmc' Cc: 'Chris Ball' , 'Ulf Hansson' References: <002301ce9e6b$e72da2a0$b588e7e0$%jun@samsung.com> In-reply-to: Subject: [PATCH v2] mmc: add ignorance case for CMD13 CRC error Date: Mon, 26 Aug 2013 16:20:04 +0900 Message-id: <002901cea22c$af778730$0e669590$%jun@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=Windows-1252 Content-transfer-encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-index: Ac6f4htQhD/QurVzQqS17R1iDxEymQCRla5g Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrMIsWRmVeSWpSXmKPExsVy+t8zA92ljNJBBsd6+C22v97IZnHkfz+j xfG14Q7MHoeurGX0uHNtD5vH501yAcxRXDYpqTmZZalF+nYJXBnT169hKjggVXGuvZGxgXGq aBcjJ4eEgInEq87DrBC2mMSFe+vZuhi5OIQEljFK9Dx+wwRTtPfmfWaIxCJGidaWLywQzh9G ibMTHrKDVLEJaEn8ffOGGcQWEdCW2DjrKFicWcBT4sXLNnaIhhZGiTenHrKAJDgFgiUOf9vF CGILC9hLfH97EqiIg4NFQFVi7mklkDCvgK3EjOfvmSBsQYkfk++xQMzUk/j45zYjhC0vsXnN W2aQVgkBdYlHf3UhTjCSeDLjCdQJIhL7XrxjBDlBQmAfu8TGL7PAXmYREJD4NvkQC0SvrMSm A8wQD0tKHFxxg2UCo8QsJJtnIdk8C8nmWUhWLGBkWcUomlqQXFCclF5kqFecmFtcmpeul5yf u4kREoG9OxhvH7A+xJgMtH4is5Rocj4wgvNK4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vnW/jvx20RaK75Vl/2P84J7kOz450+/9tk9v3V71+nu87nk5J5H3vr7/N0mumicW6GvM tb46P5JLiaU4I9FQi7moOBEAreugmDMDAAA= 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 --- Change in v2: - Removed function declaration.(From Ulf Hansson) drivers/mmc/core/mmc_ops.c | 70 ++++++++++++++++++++++++++----------------- 1 files changed, 42 insertions(+), 28 deletions(-) diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index ef18348..1464c1e 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; BUG_ON(!card); BUG_ON(!card->host); @@ -408,10 +443,15 @@ 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. + */ + ignore_crc = (index == EXT_CSD_HS_TIMING) ? true : false; 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 +489,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)