From patchwork Fri Jan 13 11:05:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 9515239 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 53C06601DA for ; Fri, 13 Jan 2017 11:05:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49C54284B9 for ; Fri, 13 Jan 2017 11:05:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3EA8028601; Fri, 13 Jan 2017 11:05:41 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 D4D41285A1 for ; Fri, 13 Jan 2017 11:05:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751493AbdAMLFi (ORCPT ); Fri, 13 Jan 2017 06:05:38 -0500 Received: from mail-lf0-f45.google.com ([209.85.215.45]:33163 "EHLO mail-lf0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751350AbdAMLFf (ORCPT ); Fri, 13 Jan 2017 06:05:35 -0500 Received: by mail-lf0-f45.google.com with SMTP id k86so34379843lfi.0 for ; Fri, 13 Jan 2017 03:05:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=RoNIk0Y7VTGxSeLOnUaBMLbMIt0eAihBi30PAWz0NH4=; b=J94UmNh4kWbuFTZXdW5wcPTGvJ4wu9M4YN5zG5YKmsboLV82j3kIHnEWgBBj3RYI21 OkYiOW7I5CLOHOvi8mglS0C06i1e0XfZ0ySgD+/dTev7dzoFZAZkc0x3kcu7kI2p8oq6 Uo8KprjFW/RdKaIpUwf1xSkquLVAREfU0o0EM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=RoNIk0Y7VTGxSeLOnUaBMLbMIt0eAihBi30PAWz0NH4=; b=Pi9CcEFPK73REBsYh4ES1zOkmfVGxOTYRDnv516xZwrQGXSat3O/RwAGxlAOoExq5M /2TMQVxv6PlXtXvTmWpDHCbb5pipkSDNeAmaoKXFcfZZT3EVc67uQ4kABmUyO9w9WQcY 8rBUIuFSKr3aplHA/Yu3niNp98JijZX5kpSrbBf9Pmq+PFgcK8bCr36wRwjrlPPdP4gV JEEWUOXw6G1UJUjDCx84xdXNINVfLHh78FCUVCSVgV+SmrZelB4TTtQNOKLtPyCfQ3Om AxfSQdq7dMgQfnBVrb0mwF1LhVYRmbmBsrfmfObBmgt4iRbKgEefqCLiHxA2dHUDovKu DdWw== X-Gm-Message-State: AIkVDXIZQbo5hIYFZ7BBB4CicEXFsbS7EBpqI2NI+jjTV1fo3Rdkw5HMdsAlkM4t4qvZYSHJ X-Received: by 10.46.84.74 with SMTP id y10mr4133602ljd.40.1484305534103; Fri, 13 Jan 2017 03:05:34 -0800 (PST) Received: from localhost.localdomain (h-155-4-221-67.na.cust.bahnhof.se. [155.4.221.67]) by smtp.gmail.com with ESMTPSA id j11sm3190378lfd.23.2017.01.13.03.05.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Jan 2017 03:05:32 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Jaehoon Chung , Adrian Hunter , Linus Walleij , Chaotian Jing , Yong Mao , Shawn Lin , Clemens Gruber , Gary Bisson , Dong Aisheng , Fabio Estevam , Dong Aisheng , Haibo Chen Subject: [PATCH] mmc: core: Restore parts of the polling policy when switch to HS/HS DDR Date: Fri, 13 Jan 2017 12:05:03 +0100 Message-Id: <1484305503-30723-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 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 Regressions for not being able to detect an eMMC HS DDR mode card has been reported for the sdhci-esdhc-imx driver, but potentially other sdhci variants may suffer from the similar problem. The commit e173f8911f09 ("mmc: core: Update CMD13 polling policy when switch to HS DDR mode"), is causing the problem. It seems that change moved one step to far, regarding changing the host's timing before polling for a busy card. To fix this, let's move back to the behaviour when the host's timing is updated after the polling, but before the switch status is fetched and validated. In cases when polling with CMD13, we keep validating the switch status at each attempt. However, to align with the other card busy detections mechanism, let's fetch and validate the switch status also after the host's timing is updated. Reported-by: Clemens Gruber Reported-by: Gary Bisson Fixes: e173f8911f09 ("mmc: core: Update CMD13 polling policy when switch..") Cc: Shawn Lin Cc: Dong Aisheng Cc: Haibo Chen Signed-off-by: Ulf Hansson Tested-by: Clemens Gruber Tested-by: Jagan Teki Reviewed-by: Shawn Lin Tested-by: Haibo Chen Reviewed-by: Dong Aisheng --- drivers/mmc/core/mmc_ops.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index db2969f..fe80f26 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -506,9 +506,6 @@ static int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms, } } while (busy); - if (host->ops->card_busy && send_status) - return mmc_switch_status(card); - return 0; } @@ -577,24 +574,26 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, if (!use_busy_signal) goto out; - /* Switch to new timing before poll and check switch status. */ - if (timing) - mmc_set_timing(host, timing); - /*If SPI or used HW busy detection above, then we don't need to poll. */ if (((host->caps & MMC_CAP_WAIT_WHILE_BUSY) && use_r1b_resp) || - mmc_host_is_spi(host)) { - if (send_status) - err = mmc_switch_status(card); + mmc_host_is_spi(host)) goto out_tim; - } /* Let's try to poll to find out when the command is completed. */ err = mmc_poll_for_busy(card, timeout_ms, send_status, retry_crc_err); + if (err) + goto out; out_tim: - if (err && timing) - mmc_set_timing(host, old_timing); + /* Switch to new timing before check switch status. */ + if (timing) + mmc_set_timing(host, timing); + + if (send_status) { + err = mmc_switch_status(card); + if (err && timing) + mmc_set_timing(host, old_timing); + } out: mmc_retune_release(host);