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: 91311 Delivered-To: patches@linaro.org Received: by 10.140.20.99 with SMTP id 90csp133836qgi; Fri, 13 Jan 2017 03:05:34 -0800 (PST) X-Received: by 10.25.203.87 with SMTP id b84mr6494134lfg.158.1484305534509; Fri, 13 Jan 2017 03:05:34 -0800 (PST) Return-Path: Received: from mail-lf0-x236.google.com (mail-lf0-x236.google.com. [2a00:1450:4010:c07::236]) by mx.google.com with ESMTPS id b137si7660068lfb.256.2017.01.13.03.05.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jan 2017 03:05:34 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::236 as permitted sender) client-ip=2a00:1450:4010:c07::236; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::236 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x236.google.com with SMTP id k86so34379842lfi.0 for ; Fri, 13 Jan 2017 03:05:34 -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=kLn5CTSytuQPXZxNWPu9/VCI049zYqDRCAMlQqUIJQwVnUd9NsxWg59dYlWNq1sozs alop7zYYlz1gV39IVx+ZMOZB4/DrkvAM+zzDMED4cQV0BUr97KSrdvB21r1bBIIggKG8 OE4uvMZ584EoTkosMzUqrirHWqCFTMKwS8nNcWIuzLljFvoKN4a5Re9N95OnnIlihNit jd9w3nlzHgb3CqAcKON0PRSekXwR/BrZsPGm+hQITixWP6VvKU77PsdR8j9ffySxuZGJ XSaG7CbonjN9jY887sQYJiCIpVCwcC+FGWVPTxJyRlPdQ7H4n8tfKjXlhPEw9Nd9Q7Th r4PA== X-Gm-Message-State: AIkVDXLm7jwqyKpjmeOgEFsHScBJyEokAY1IsoM0xk1GdaNNpux0E1N0lqgy/pAox1y+kB9N1e0= X-Received: by 10.46.84.74 with SMTP id y10mr4133602ljd.40.1484305534103; Fri, 13 Jan 2017 03:05:34 -0800 (PST) Return-Path: 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 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 --- drivers/mmc/core/mmc_ops.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) -- 1.9.1 Tested-by: Clemens Gruber Tested-by: Jagan Teki Reviewed-by: Shawn Lin Tested-by: Haibo Chen Reviewed-by: Dong Aisheng 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);