From patchwork Thu Mar 23 07:03:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 9640447 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 68FA4601E9 for ; Thu, 23 Mar 2017 07:09:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 504B6284D9 for ; Thu, 23 Mar 2017 07:09:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 42F57284E8; Thu, 23 Mar 2017 07:09:48 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AFCC0284D9 for ; Thu, 23 Mar 2017 07:09:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=biXb8Sk5M6OVETHQzdguq/8lPXjgcbupg+DGFxovssY=; b=JqPBSBOkadaXXh vUQjFsGuryYKJls3YGll5uX3i+XXNslSqGMS21Y5+7W+9jmZKVoB7hY+oIDCY/dkNf/z1nNzxQ6G0 5HI0XJBZ/YiuK9fUdu6QfhOayZz1ki8BarQEpuBS0O/g3Bxl5Lu0g9FzIwnbNlAVQ2PZlIzkxonci gCgqCb/IMRWB8mBawfH2iaQVrJsQjKnYKHu9Jh0LQ75Uh/xVsOVUoZ1kGtgLDkSb4Ay0jMLXTGqbl L8qN8Hc26+P2Q1ofwFefkTrxjQzW09P7ssWbBQwLzeEbWTwV+JRUSlH0T5DkElzFjqR6CqZtuOoQE MzrVLuRwtkQ5HTMQr/9w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cqwsP-0004ky-2C; Thu, 23 Mar 2017 07:09:41 +0000 Received: from mga05.intel.com ([192.55.52.43]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cqwsL-0004jc-AF for linux-arm-kernel@lists.infradead.org; Thu, 23 Mar 2017 07:09:38 +0000 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP; 23 Mar 2017 00:09:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,208,1486454400"; d="scan'208";a="239421817" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.168]) ([10.237.72.168]) by fmsmga004.fm.intel.com with ESMTP; 23 Mar 2017 00:09:14 -0700 Subject: Re: [v2, 4/7] mmc: sdhci: add a quirk to restore delay in tuning To: Yangbo Lu , linux-mmc@vger.kernel.org, ulf.hansson@linaro.org, Rob Herring , Mark Rutland , Catalin Marinas , Will Deacon References: <1488529129-23560-1-git-send-email-yangbo.lu@nxp.com> <1488529129-23560-5-git-send-email-yangbo.lu@nxp.com> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: <878da006-5b83-a9d9-6136-07d8f07ea65f@intel.com> Date: Thu, 23 Mar 2017 09:03:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <1488529129-23560-5-git-send-email-yangbo.lu@nxp.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170323_000937_459360_23B47F11 X-CRM114-Status: GOOD ( 18.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Xiaobo Xie , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On 03/03/17 10:18, Yangbo Lu wrote: > There was a mdelay between tuning cycles which is removed since > eMMC spec didn't require that. However it's observed that eSDHC > needed this delay for HS200 successful tuning. Maybe it's also > needed for some other controllers. This patch is to add a quirk > to fix it. > > Fixes: 197160d52e85 ("mmc: sdhci: remove mdelay in eMMC tuning") > Signed-off-by: Yangbo Lu > --- I would prefer to do something like this: --- From: Adrian Hunter Date: Thu, 23 Mar 2017 08:54:06 +0200 Subject: [PATCH] mmc: sdhci: Control the delay between tuning commands The delay between tuning commands for SD cards is not part of the specification. A driver that needs it probably needs it for eMMC too, whereas most drivers would probably like to set it to 0. Make it a host member (host->tuning_delay) that defaults to the existing behaviour. Drivers can set it to zero to eliminate the delay, or set it to a positive value to always have a delay. Signed-off-by: Adrian Hunter --- drivers/mmc/host/sdhci.c | 11 ++++++++--- drivers/mmc/host/sdhci.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index a33102fc800b..2fc33485df1d 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2100,9 +2100,9 @@ static void __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode) break; } - /* eMMC spec does not require a delay between tuning cycles */ - if (opcode == MMC_SEND_TUNING_BLOCK) - mdelay(1); + /* Spec does not require a delay between tuning cycles */ + if (host->tuning_delay > 0) + mdelay(host->tuning_delay); } pr_info("%s: Tuning failed, falling back to fixed sampling clock\n", @@ -2164,6 +2164,9 @@ int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode) host->mmc->retune_period = tuning_count; + if (host->tuning_delay < 0) + host->tuning_delay = opcode == MMC_SEND_TUNING_BLOCK; + sdhci_start_tuning(host); __sdhci_execute_tuning(host, opcode); @@ -3108,6 +3111,8 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev, host->cqe_ier = SDHCI_CQE_INT_MASK; host->cqe_err_ier = SDHCI_CQE_INT_ERR_MASK; + host->tuning_delay = -1; + return host; } diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 35b41da0a636..b0f416fc9548 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -538,6 +538,7 @@ struct sdhci_host { #define SDHCI_TUNING_MODE_1 0 #define SDHCI_TUNING_MODE_2 1 #define SDHCI_TUNING_MODE_3 2 + int tuning_delay; /* Delay (ms) between tuning commands */ unsigned long private[0] ____cacheline_aligned; };