From patchwork Thu Apr 20 08:14:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangbo Lu X-Patchwork-Id: 9689887 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 5FB3A6038D for ; Thu, 20 Apr 2017 08:30:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5041A223B2 for ; Thu, 20 Apr 2017 08:30:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 452A228459; Thu, 20 Apr 2017 08:30:30 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 C874428448 for ; Thu, 20 Apr 2017 08:30:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967755AbdDTIaW (ORCPT ); Thu, 20 Apr 2017 04:30:22 -0400 Received: from mail-co1nam03on0073.outbound.protection.outlook.com ([104.47.40.73]:62496 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S967571AbdDTI3w (ORCPT ); Thu, 20 Apr 2017 04:29:52 -0400 Received: from BN6PR03CA0006.namprd03.prod.outlook.com (10.168.230.144) by CY1PR0301MB0601.namprd03.prod.outlook.com (10.160.142.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1019.17; Thu, 20 Apr 2017 08:29:50 +0000 Received: from BN1BFFO11FD033.protection.gbl (2a01:111:f400:7c10::1:196) by BN6PR03CA0006.outlook.office365.com (2603:10b6:404:23::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1047.13 via Frontend Transport; Thu, 20 Apr 2017 08:29:49 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD033.mail.protection.outlook.com (10.58.144.96) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1019.14 via Frontend Transport; Thu, 20 Apr 2017 08:29:49 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v3K8Tbd3002714; Thu, 20 Apr 2017 01:29:47 -0700 From: Yangbo Lu To: , , Adrian Hunter CC: Xiaobo Xie , Yangbo Lu Subject: [v5, 4/5] mmc: sdhci: Control the delay between tuning commands Date: Thu, 20 Apr 2017 16:14:43 +0800 Message-ID: <1492676084-28218-5-git-send-email-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.1.0.27.g96db324 In-Reply-To: <1492676084-28218-1-git-send-email-yangbo.lu@nxp.com> References: <1492676084-28218-1-git-send-email-yangbo.lu@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131371505897689636; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(39380400002)(39400400002)(39850400002)(39860400002)(39410400002)(39450400003)(39840400002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(9170700003)(81166006)(104016004)(6666003)(2950100002)(189998001)(8676002)(5660300001)(8936002)(105606002)(575784001)(50466002)(106466001)(50226002)(8656002)(76176999)(50986999)(4326008)(54906002)(48376002)(85426001)(33646002)(86362001)(305945005)(47776003)(36756003)(2906002)(5003940100001)(53936002)(356003)(38730400002)(77096006); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB0601; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; A:1; MX:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD033; 1:sSOxZneWcODBCw6BhqleTw95n25+4QCYj/a+yopf1CBTEDROMa8VyGHHmDr/j8GFpVbgmqrcsECAfE17yB+xi/BoWRil2lmRltEItsZ1tIRcoZ+6K+htVBIKKrsD0k/6KXlhnzZlTphVrg4S3uiAUvttr2O0z/aj7AAADaNBbyLhKni9G8xkRaypMglVlXPLcn59E6tDlwa2ExIZQQZejB7IjhmlTfUmJpKSsjmSyQHIRx3jNVzdfRhI9IyBbsYGTN9WbTTjfmN+9vA6pORRQKRwwvbeEX7ma/vqO2rBhAw4ukuOqmB2lLZcqgLcVtFH5xFV/c9ZamFhgG3AqHjPlOAx77BFjYWyu5ke0pzIXJmiGeKiW1gkBGjSXJmOAhFjG6c6QRmqLZhti8on2dz+Rnn31FfoFq6myyRHYs5h7sRHvNsUpaLVXa5BhgnbKYhLStMgkgM+3o14BAP91SHDjVkvyyyqeSz+U7Bl49Jtn/CRpq1jn+LZhwRvzuqnMh4gJ6HFILdWG6nb93NGJ06DV/OsGf/Vv/3C3X0K6zBDiVJld/hi3BQSr6vv/wt6sc+ds260TSovqfoOKj+S0OBQFYWEQrl1+p39Kp+IeUdEncl5XSjPEueh4YGl/WvRsvHQ5HDHd9GQuWcvTuFLfwo2ttUDUDU5oK7dvDyFTyuZuw6GK+iWEYjScjShAPp1j/yYkJFxUsbvrCCfHT93PtisR8MkvY/Zsc67RLu7gUE1Edcv1fjwLyRXkMZcISR2xfekUs0zdXKGAkef9uDTEjY43g== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 0193a743-1b17-42cd-d224-08d487c7691a X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131430075)(201703131517081); SRVR:CY1PR0301MB0601; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0601; 3:gn1Esh6uo17HW/dRlVVz5TpXlZqMakSZnrETMQE/GZLV8bc9wI5/u1UECXF/SCh2/GaZJkyw3a18369kp1RopIB5/xU+LwxxdUkNTlWYHmHdW2FakIeHi8cpg5IlixcIYEal/mdlMzWYoGUut5x7BlxKd0gEiCYFCmZb8NctSECx9xC7BUFsCXSMcduxF/89yFuoQi/wpW1bXTME0oA9Lrbg+fcidHbLLT3Qdlkc7vMYkcdTbp+g6wPqsL2wRQtrUSZ6M+NkbP84V9Ws0xh8cGsdgwaU/Bz5okinGR4RDyGkqhGBQHx0CPMp6WT+MytV1v6tkzklp91toV4C/R23ts0X4x1rw3i5AJjYeYG2898+wq+TRrRZEh88aAgHIkrpbTDRJR06gQbIMiSn72RDz9I54ovQeSh5J1WEtwb+E3wLgHgRmWjv7zFANkxj3Xnu; 25:XhdKKzbpSSiumaUaaoRj03NiXGgj/Wxu1/mJQ3J3LsWz4+obFoe452WPOprL5VB15vnKlE1X8EDb2IbjMSa7d4Y0jg+JRilMGxaXO+A87I5r0mi5QKo/zhXlJrDXfCGzumw+8Jn3DXCwdBjcrT5Hpy92bT9TAzcF6ol7op3IMo/PAOTV7cP2oqxhbaWVMbTjNHyFntOs2qN3oTACH6l5yZQUa73LPVksNC9Zcqiwc+n6TRvYnFRXCk/4OebxAw4A0HF5QfPE54lA3LaofS/n4X8IXgnXWHFVlOeua6t1Y3jMBTE65QkiTwWEc3BklU3rLP7iopANo3xSTLlVGhXDKqM9QZwPTOsUoPtAvU1v01dNt1w3S4yin0ctIv36yN2WOL1UGxK0/q+PJ44LTdmd6qsX++JvEfCPrBYPedP0YXjJc+RDjEhE/nWWaj0l/7kVzSl8YKz2Qe7IwaCqv19vcg== X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0601; 31:+11ajQ4LV9hsrGMOF+FM9de8ii0OCAfk5kPuPlNiEiqIUv90MDxyEyye/GJvN2v12xMGLGgfwwp1zoTKJZVwTo0o7P9ihb7tVxhswftkSLSyxCZs03rwnTn5vc5UK+WNzvpuptxqWwaBXymrb+/y/X7FUaqBkP8B94Rycjphv8HnKBjSDdEY5Om/kLoiXKYqQlCARl6Mq8g0fGSgZGg7IniHaidFDwMdF5k0bzlGDnwoKXoUx8ikhR1TMOxlcqoT19F5o4to+ewGYjf0TqdwqQKwC+V7XQwvKw+5weCrY9g= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(601004)(2401047)(8121501046)(13015025)(5005006)(13017025)(13018025)(13024025)(13023025)(10201501046)(93006095)(93001095)(3002001)(6055026)(6096035)(20161123561025)(20161123563025)(20161123565025)(201703131430075)(201703131441075)(201703131448075)(201703131433075)(201703161259150)(20161123556025); SRVR:CY1PR0301MB0601; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB0601; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB0601; 4:afnlaGn4i5IrbvF7bfLXFPlGYGjNOI4j5JqN8eFP?= =?us-ascii?Q?kP03U3IsVjkMo+u+rCt2BWeEM7DLeaj1XipcIZ2TvVI+rF7BLlkpsqi0qHIo?= =?us-ascii?Q?JL2la4g3wkC1fMNjBLmuyByJDfDnC3RojKW+ZrDX+JiO06dHf7qLUpmt69VQ?= =?us-ascii?Q?rMiHD0Puz7mqZWcV74ieXX+ahOb9LGi9GhxhzfceZ0k74sbgZUKYNNThdS8L?= =?us-ascii?Q?48qyON3OcdlFeDSFNFRtTUQ8I+ue+Da1MuITK9zdLcBs5K4R9iS7XJKItr8m?= =?us-ascii?Q?1QUkjkCP7oM5g6AGOq3wTl2dze/a7bty6ApK4rY3USLi2wf0gTkD71AGspBf?= =?us-ascii?Q?N9yNtJbGy5t5Q+uXm0evRe4tAT7cfbqOFaENZKBuYMnO16cWCTciD9Pi9z1z?= =?us-ascii?Q?+yb04Nm0Puyky2igapRYnXOm0XZMFyDTmZXWSviS/VZ71TMp6jdKhHteODse?= =?us-ascii?Q?P2GaYgGw0oW70dzO1XTyar1xgVpl9as8BzksjNYA5K35DnV6RulwIzZetqcb?= =?us-ascii?Q?jTXYby4QFUdUf2tNCHAUudbxnDU6mVRYJw0KbifPRaefiMOAXYy9klq8Skzp?= =?us-ascii?Q?8D4PXRfy0rmZN2s4GkupFgjLDmd8LLxJzq0wXOwMfm/oeKufKja/CcsMeYEd?= =?us-ascii?Q?12Tb72ZEIcgJaZ7DpXVeJMlWH6AXp1ojb6Onom0W4KP/T+Si1F3yR35Z/d5X?= =?us-ascii?Q?8l/CJgMr1kQ40U9SeS3t1iFaxlpOxvCsa2UT1TxDC0fgdnEXgSZ4szkKjspT?= =?us-ascii?Q?EFP47CBEDm1PnOih3tLdpg9AyYMc2jK/4MUjenFqfgQdZ5zrWQRePuka6tc5?= =?us-ascii?Q?rBAiO2l4SR5oYe26uRjQb+8mlfCIGSZeB94KxMyQbkVQJqIRQgf7kGN5utwk?= =?us-ascii?Q?4MEZQ41EZZWVJreFXDnb+5g+pNRzCQhsWJpvTuYRQ/SNYWoz4Pt2AyG4wtU9?= =?us-ascii?Q?oC912ujF3KWHKNsN0Wc1mSJT7ds8N28NOhqanTw/UQ=3D=3D?= X-Forefront-PRVS: 02830F0362 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB0601; 23:gkwJeSylJgRnYpbavFCS5pySzk99bzmtQzNw6Zc?= =?us-ascii?Q?9A3IGmmm0rDFjf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HN1ccy; 24:9hMMmaTyBD9vEuviBzOlwfw6LrpH2P7jZdpVsX4qWc5Wepm7hppDexWo+W5RSElizzF7ZSLBT/5OlQzb8TLcEzh+4EbfskapIzchlpL+0Xs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0601; 7:UjTHk6yoB2rgGlpIx2Zp0DQSRVYr7Tf0Fgfb8UjDPH96T2+LNqu8szbbBfCBAY3qqGvXyN1lE68JzI8w39QzTHSsBI04qyzB0BIyszX89jUCR8Wy+C5xrICH2QzRP/yuGeWcbP0App40YwpLwTADZPmKCQTNWYE38Phby+zJLiG3U42nqy5zddCshfuPaHG4k6h9IJxa3pjVzMsqWjM5F4TFftUcIe2ho8z6CLpXqyizS/3MgbJytBQ3+2maL1brgiPXaECQT07AvQQSR/VQqqHDybToEDfsPirHXI9qNiAcIPKi0cZlRi+2FT4/7L8i2QHvxPH4hgB9Pp/Qns396w== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Apr 2017 08:29:49.5973 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB0601 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 From: Adrian Hunter 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 Signed-off-by: Yangbo Lu --- Changes for v2: - None Changes for v3: - Used a host member for tuning delay instead of a quirk.(Adrian's patch) - Addressed warning in checkpatch. Changes for v4: - None Changes for v5: - None --- drivers/mmc/host/sdhci.c | 11 ++++++++--- drivers/mmc/host/sdhci.h | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 4bdad89..ecd0d43 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2108,9 +2108,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", @@ -2172,6 +2172,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); @@ -3114,6 +3117,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 78437f8..0469fa1 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -538,6 +538,8 @@ struct sdhci_host { #define SDHCI_TUNING_MODE_1 0 #define SDHCI_TUNING_MODE_2 1 #define SDHCI_TUNING_MODE_3 2 + /* Delay (ms) between tuning commands */ + int tuning_delay; unsigned long private[0] ____cacheline_aligned; };