From patchwork Tue Jul 12 07:46:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 9224753 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 40565604DB for ; Tue, 12 Jul 2016 08:09:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31EDF27CF9 for ; Tue, 12 Jul 2016 08:09:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2692B27E63; Tue, 12 Jul 2016 08:09:17 +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=unavailable 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 A7FD027CF9 for ; Tue, 12 Jul 2016 08:09:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750850AbcGLIJP (ORCPT ); Tue, 12 Jul 2016 04:09:15 -0400 Received: from mail-by2nam03on0049.outbound.protection.outlook.com ([104.47.42.49]:53753 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750838AbcGLIJM (ORCPT ); Tue, 12 Jul 2016 04:09:12 -0400 X-Greylist: delayed 873 seconds by postgrey-1.27 at vger.kernel.org; Tue, 12 Jul 2016 04:09:12 EDT Received: from BN3PR0301CA0003.namprd03.prod.outlook.com (10.160.180.141) by DM2PR0301MB0782.namprd03.prod.outlook.com (10.160.97.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.539.14; Tue, 12 Jul 2016 07:54:28 +0000 Received: from BL2FFO11OLC010.protection.gbl (2a01:111:f400:7c09::167) by BN3PR0301CA0003.outlook.office365.com (2a01:111:e400:4000::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.534.14 via Frontend Transport; Tue, 12 Jul 2016 07:54:28 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; gmail.com; dkim=none (message not signed) header.d=none; gmail.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 BL2FFO11OLC010.mail.protection.outlook.com (10.173.160.154) with Microsoft SMTP Server (TLS) id 15.1.534.7 via Frontend Transport; Tue, 12 Jul 2016 07:54:28 +0000 Received: from shlinux2.ap.freescale.net (shlinux2.ap.freescale.net [10.192.224.44]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u6C7rxtf002725; Tue, 12 Jul 2016 00:54:25 -0700 From: Dong Aisheng To: CC: , , , , , , , Subject: [PATCH V2 08/15] mmc: sdhci: add standard hw auto retuning support Date: Tue, 12 Jul 2016 15:46:17 +0800 Message-ID: <1468309584-3591-9-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1468309584-3591-1-git-send-email-aisheng.dong@nxp.com> References: <1468309584-3591-1-git-send-email-aisheng.dong@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131127836683666062; (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)(7916002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(33646002)(229853001)(2351001)(106466001)(77096005)(105606002)(50466002)(48376002)(19580395003)(19580405001)(85426001)(92566002)(4326007)(356003)(7846002)(81156014)(81166006)(8666005)(11100500001)(6806005)(2906002)(36756003)(76176999)(50986999)(575784001)(8676002)(97736004)(8936002)(47776003)(110136002)(50226002)(86362001)(189998001)(586003)(2950100001)(87936001)(5003940100001)(104016004)(305945005)(68736007)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR0301MB0782; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11OLC010; 1:YNkz1mEZSA/CkF0nqau3WgwuZYiu7bXtMMb7SgtR9wmVc8uQDG40YcZzkNeETUQtISbALB7FaL9++4CVfn0rsigW7lXph2KJNEAvlWtGoo4ZH3r+urgFhxKdrdD6dWf9cysECXxVJsSq9gP8xDH0ax6PhRBBF2WD46qK/o1LjUPHj5mL+m/emuJweUMWqP35XoNM9C0FKm2ly9l91C3PsCcXMy23zGuJ2P2Ep//Eh3Z617cNDAs1sorChPkqf2wBt9jDh2QNAmR8KCYmu1tXmahk5iujvGcyR8D6cIGpjPViK2SnSlLk8Ve3zz+xXC1UxnE/Mg5aerLe4a7tqQviDkWAieWJfqPkQ6RAGydw6sCLZWF+1doguk0TvHCzvoVyYcgoHV3OxllXFHWWhciyLMCPoeogt3aFWX/Pb12mWaJDoYIDDVwnVpTwx9rvyGWQ6x+f+ztoJ4eDy4lM4gE0IhL+EqibcRgbCewfR5GCODbir3XDxoQjr/S8hvey39lkFx2mnCm9NHUqomvry4gylyvCz4b49+NP5s4fd4ay8KTJ+dbRqRHn8nkC2K+CGWKaPUUfo93T4/1sUj1MTLM7ZxRDzFnyY6DSfRSTIm3rTilPLIve8zYXPgbpg6oRTI1QUE8Wx2HofrGrAtP3lT5iIp5EYXhmXkERTd7bMf2AxSc= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: b48c64f6-a1ef-48da-028e-08d3aa29c029 X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0782; 2:6hvu3T8/xoPJyCXT2mFSAf3xlUhFGL3gMyHbghH0w5BqcuS98Khv6TmexaiByTu0Nrb14TO2iF0P1wTuQmONZw0+6jBudCvAbFcuMvpcOyVjU4v7IJtj6vVjrmhlM3GgCihcBPxScI0DVCm0XD0XGbigpQafgVHges1aC4jaGUnXcT4sgVmkhw/4ZWA9puz9; 3:OWqPLqIhgwwbiyrLyudwx67hOk9f/TD87gA5Z60hAp73T7nT2/HHQTDdZmn4PA2iVPlXN22f5oTKxOKbsORckzvN/c+wG+uByp/LlU59EOww9Tv+A1JuusoVB82mhLzDIuTMjAG8drDr9zj4yxMqKZNutW4aaKOmUc+2cg9pJNKWm4gvqOMl1gCyXbFVUWTliXUEyRBdikdXbdT9LfAsCkVzw9KZbjz4B/Ln9Hggn24=; 25:rjGxZy17KQZvR4z8ZP11oOchPD7U0gb0zpJSzNeguMLfGC5cFlNUlXaICaGk7CfV4qSa0M0TIBZM620G88Wa9nuBCCNvmLNFytqOskhSUqcgn3P70aBwD5MtpQbJQ+68VrqOk8NzV9vlRnzoWFV2cC7u5ZiR5paOFOkLl8TqD6fbiF50CnAgL18INwo0Z5HRDw3R9JE9d4s2HBd702g6SaWPnEDJOp49p/iOHEsun9G458x+uYP5S17OqEUTRQrFwLe7yvETlIwhtdt+PoV8OFbSPWicZTs4qjZNcuNw69RxXs9FqAzfwr6d+mBemn+Sg22JzoOA7mqfieZRULlfFMww/WOVg7xAwJxm9ySLHEhIiIzihU4VBoShAfJRl7Yf6R5SgRs2C92Ka5ZGzQbzOq9sXOinBW5aX2m7Pi5RWEs= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB0782; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0782; 31:inJRNl8TNjVrwucmiMOA09WQWjTpcu+TFbQrBCj4UP+m+ppzNSXLIapcQGU1+4NE0hCVgV1uvXgzx/Nf+PZTEly04K1f7KK/NbGcPriA7bu6ujy+JfbQShh+mnAfegU4BKwPhdVlA6uoKIy4LiSomgjQ9DAYsubM5FPFHLGt2hKMlF0HEH4q4TUnOmLR8xVM/ra+OlhZxyC5snJSn4mDag==; 4:MEmLdO+XLqLS+Mzzu87BfLQefW2BMx+hY/syB1NY3y2nFUd+vAp+WTHLe2arVQ8bW/OmCoHnMy48PJIkJG5yOBsP17aw7Cf/D5wf6qopHw0iRWH/4xmjQsf1GpejwaG9TQY3xE8ucZj9R9F7LrKp7t0c34I/+t+dMB6NVrgy4uf4qmsfeMurIihwdhblD2863QDnmglWJIyG/SpvVoJYO9IRxGyJ3LoXI8Xw8jaloJR5KLKtXDVkd1Sv/dX7NTF8y/NP1V1eOzQt4UM0heXonAaB2qG/9jXCzZLPk0yqeKi9Z8o1YWzvFj3RdOVgulZGtNa49vm5ffUCQ59BALNphG/BDyRYmlYDH9Upp5nOdMhGIw7V4l0ZAd88X6oufL7M9U890HwSrBi1+vbRp3zORd1kMtgpM+6YvT2gRtHiqEF1DRW79cbZgrMHzmqnVPboY4g6REiXKDaHFdBUsWaNzLjcaWAhi3mP8IAqtPXiu3ne723Pd+uh1dkcPmIdGDWYmtvCl+mHOXUYRag4h3cV9w== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13024025)(13015025)(13017025)(13023025)(13018025)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:DM2PR0301MB0782; BCL:0; PCL:0; RULEID:(400006); SRVR:DM2PR0301MB0782; X-Forefront-PRVS: 0001227049 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR0301MB0782; 23:/YozlqU7lNcLnvsnVQUFed4UfkUQ9v469pG0sao?= =?us-ascii?Q?WJ93ygwkU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wrsLtJnAaEhJXPDKe/LUFjJa954l+oWZ2NlbHoUD50gltEqVqay6WAkWbokn784W99dpL4qTi9Wl2MDmOhbhy15G/nyIjA1UzBtXYrSTCuczwj4W7+hvGvAP4U96oJhZLprb1e/bX3uhfbDzd/ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2016 07:54:28.1950 (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: DM2PR0301MB0782 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 If HW supports SDHCI_TUNING_MODE_3 which is auto retuning, we won't retune during runtime suspend and resume, instead we use Re-tuning Request signaled via SDHCI_INT_RETUNE interrupt to do retuning and hw auto retuning during data transfer to guarantee the signal sample window correction. This can avoid a mass of repeatedly retuning during small file system data access and improve the performance. Signed-off-by: Dong Aisheng Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci.c | 15 ++++++++++++--- drivers/mmc/host/sdhci.h | 3 +++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 7894652b9929..31c14b0ff8e2 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -229,6 +229,10 @@ static void sdhci_init(struct sdhci_host *host, int soft) SDHCI_INT_TIMEOUT | SDHCI_INT_DATA_END | SDHCI_INT_RESPONSE; + if (host->tuning_mode == SDHCI_TUNING_MODE_2 || + host->tuning_mode == SDHCI_TUNING_MODE_3) + host->ier |= SDHCI_INT_RETUNE; + sdhci_writel(host, host->ier, SDHCI_INT_ENABLE); sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE); @@ -2673,6 +2677,9 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id) pr_err("%s: Card is consuming too much power!\n", mmc_hostname(host->mmc)); + if (intmask & SDHCI_INT_RETUNE) + mmc_retune_needed(host->mmc); + if (intmask & SDHCI_INT_CARD_INT) { sdhci_enable_sdio_irq_nolock(host, false); host->thread_isr |= SDHCI_INT_CARD_INT; @@ -2682,7 +2689,7 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id) intmask &= ~(SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE | SDHCI_INT_CMD_MASK | SDHCI_INT_DATA_MASK | SDHCI_INT_ERROR | SDHCI_INT_BUS_POWER | - SDHCI_INT_CARD_INT); + SDHCI_INT_RETUNE | SDHCI_INT_CARD_INT); if (intmask) { unexpected |= intmask; @@ -2787,7 +2794,8 @@ int sdhci_suspend_host(struct sdhci_host *host) sdhci_disable_card_detection(host); mmc_retune_timer_stop(host->mmc); - mmc_retune_needed(host->mmc); + if (host->tuning_mode != SDHCI_TUNING_MODE_3) + mmc_retune_needed(host->mmc); if (!device_may_wakeup(mmc_dev(host->mmc))) { host->ier = 0; @@ -2848,7 +2856,8 @@ int sdhci_runtime_suspend_host(struct sdhci_host *host) unsigned long flags; mmc_retune_timer_stop(host->mmc); - mmc_retune_needed(host->mmc); + if (host->tuning_mode != SDHCI_TUNING_MODE_3) + mmc_retune_needed(host->mmc); spin_lock_irqsave(&host->lock, flags); host->ier &= SDHCI_INT_CARD_INT; diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index e241e11a90d0..0411c9f36461 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -128,6 +128,7 @@ #define SDHCI_INT_CARD_INSERT 0x00000040 #define SDHCI_INT_CARD_REMOVE 0x00000080 #define SDHCI_INT_CARD_INT 0x00000100 +#define SDHCI_INT_RETUNE 0x00001000 #define SDHCI_INT_ERROR 0x00008000 #define SDHCI_INT_TIMEOUT 0x00010000 #define SDHCI_INT_CRC 0x00020000 @@ -518,6 +519,8 @@ struct sdhci_host { unsigned int tuning_count; /* Timer count for re-tuning */ unsigned int tuning_mode; /* Re-tuning mode supported by host */ #define SDHCI_TUNING_MODE_1 0 +#define SDHCI_TUNING_MODE_2 1 +#define SDHCI_TUNING_MODE_3 2 unsigned long private[0] ____cacheline_aligned; };