From patchwork Wed Sep 9 16:33:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yousong Zhou X-Patchwork-Id: 7147481 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id ED040BEEC1 for ; Wed, 9 Sep 2015 16:37:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0C730209FE for ; Wed, 9 Sep 2015 16:37:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3BB22209FC for ; Wed, 9 Sep 2015 16:37:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754154AbbIIQhp (ORCPT ); Wed, 9 Sep 2015 12:37:45 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:34337 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751495AbbIIQhp (ORCPT ); Wed, 9 Sep 2015 12:37:45 -0400 Received: by padhy16 with SMTP id hy16so15026434pad.1 for ; Wed, 09 Sep 2015 09:37:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6J+G2w3Bc4ucpsU80HESkj9U4shiKVsrFdE6UZqgeXE=; b=Zolguygk9Rdlv7GXT3bB/UWZHYsxMEseG5ty931PyqcGuE1KtCk4QdJ/xDifKLoopk tEj4reQdrc9JJZQtS/XheCpBw4XTZAz8yvJAyQ9gj+bcBbasZJZJnVFELhlUdCIBY4X7 V0HaJESXhxuIrp4r7rLCvAeX4uYxaYFbuAnpKS8kXMKjK3XT/hanXlUa0D53rMUPRJDf KZCHMVjyGoFaqgIXIrpCdz7RoN07Yy93ulUFa2Yy06cYQ+xqbM0IFQl2LMthHHp0U982 yvBy5K6rkj0MZDwBbQ0wVNOwVXwAtz7/kcflOskVezo69ffoytxBPg2aJ4sQ54viN8yf yRKQ== X-Received: by 10.68.111.3 with SMTP id ie3mr73249651pbb.63.1441816664603; Wed, 09 Sep 2015 09:37:44 -0700 (PDT) Received: from debian.corp.sankuai.com ([103.29.140.56]) by smtp.gmail.com with ESMTPSA id py6sm3229859pbb.62.2015.09.09.09.37.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2015 09:37:43 -0700 (PDT) From: Yousong Zhou To: Ulf Hansson Cc: Hans de Goede , Shawn Lin , linux-mmc@vger.kernel.org, Yousong Zhou Subject: [PATCH 2/3] mmc: sd: Allow calling sd mode switch with retries Date: Thu, 10 Sep 2015 00:33:17 +0800 Message-Id: <1441816398-4330-2-git-send-email-yszhou4tech@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1441816398-4330-1-git-send-email-yszhou4tech@gmail.com> References: <1441816398-4330-1-git-send-email-yszhou4tech@gmail.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 This will allow retrying access mode switch to High-Speed in the following commit. Signed-off-by: Yousong Zhou Tested-by: Shawn Lin --- drivers/mmc/core/core.c | 4 ++++ drivers/mmc/core/sd_ops.c | 5 +++-- drivers/mmc/core/sd_ops.h | 10 ++++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 9ad73f3..e726bb1 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -468,11 +468,13 @@ static void mmc_wait_for_req_done(struct mmc_host *host, struct mmc_request *mrq) { struct mmc_command *cmd; + struct mmc_data *data; while (1) { wait_for_completion(&mrq->completion); cmd = mrq->cmd; + data = mrq->data; /* * If host has timed out waiting for the sanitize @@ -501,6 +503,8 @@ static void mmc_wait_for_req_done(struct mmc_host *host, mmc_hostname(host), cmd->opcode, cmd->error); cmd->retries--; cmd->error = 0; + if (data) + data->error = 0; __mmc_start_request(host, mrq); } diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c index 48d0c93..22bef3c 100644 --- a/drivers/mmc/core/sd_ops.c +++ b/drivers/mmc/core/sd_ops.c @@ -304,8 +304,8 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr) return 0; } -int mmc_sd_switch(struct mmc_card *card, int mode, int group, - u8 value, u8 *resp) +int __mmc_sd_switch(struct mmc_card *card, int mode, int group, + u8 value, u8 *resp, int retries) { struct mmc_request mrq = {NULL}; struct mmc_command cmd = {0}; @@ -328,6 +328,7 @@ int mmc_sd_switch(struct mmc_card *card, int mode, int group, cmd.arg &= ~(0xF << (group * 4)); cmd.arg |= value << (group * 4); cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC; + cmd.retries = retries; data.blksz = 64; data.blocks = 1; diff --git a/drivers/mmc/core/sd_ops.h b/drivers/mmc/core/sd_ops.h index ffc2305..a53c51e 100644 --- a/drivers/mmc/core/sd_ops.h +++ b/drivers/mmc/core/sd_ops.h @@ -17,9 +17,15 @@ int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr); int mmc_send_if_cond(struct mmc_host *host, u32 ocr); int mmc_send_relative_addr(struct mmc_host *host, unsigned int *rca); int mmc_app_send_scr(struct mmc_card *card, u32 *scr); -int mmc_sd_switch(struct mmc_card *card, int mode, int group, - u8 value, u8 *resp); int mmc_app_sd_status(struct mmc_card *card, void *ssr); +int __mmc_sd_switch(struct mmc_card *card, int mode, int group, + u8 value, u8 *resp, int retries); +static inline int mmc_sd_switch(struct mmc_card *card, int mode, int group, + u8 value, u8 *resp) +{ + return __mmc_sd_switch(card, mode, group, value, resp, 0); +} + #endif