From patchwork Fri Apr 15 17:29:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 8854261 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 11E18BF29F for ; Fri, 15 Apr 2016 17:52:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2CB582021A for ; Fri, 15 Apr 2016 17:52:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 342F320211 for ; Fri, 15 Apr 2016 17:52:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750913AbcDORwy (ORCPT ); Fri, 15 Apr 2016 13:52:54 -0400 Received: from mail-bn1on0067.outbound.protection.outlook.com ([157.56.110.67]:7476 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750899AbcDORwx (ORCPT ); Fri, 15 Apr 2016 13:52:53 -0400 X-Greylist: delayed 940 seconds by postgrey-1.27 at vger.kernel.org; Fri, 15 Apr 2016 13:52:53 EDT Received: from BLUPR03CA006.namprd03.prod.outlook.com (10.255.124.23) by CY1PR0301MB1225.namprd03.prod.outlook.com (10.161.212.147) with Microsoft SMTP Server (TLS) id 15.1.466.19; Fri, 15 Apr 2016 17:37:58 +0000 Received: from BL2FFO11FD030.protection.gbl (10.255.124.4) by BLUPR03CA006.outlook.office365.com (10.255.124.23) with Microsoft SMTP Server (TLS) id 15.1.453.26 via Frontend Transport; Fri, 15 Apr 2016 17:37:57 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; gmail.com; dkim=none (message not signed) header.d=none; gmail.com; dmarc=none action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BL2FFO11FD030.mail.protection.outlook.com (10.173.161.40) with Microsoft SMTP Server (TLS) id 15.1.453.6 via Frontend Transport; Fri, 15 Apr 2016 17:37:57 +0000 Received: from shlinux2.ap.freescale.net (shlinux2.ap.freescale.net [10.192.224.44]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id u3FHb2HS019919; Fri, 15 Apr 2016 10:37:53 -0700 From: Dong Aisheng To: CC: , , , , , , , Subject: [PATCH 17/23] mmc: sdhci: add standard hw auto retuning support Date: Sat, 16 Apr 2016 01:29:41 +0800 Message-ID: <1460741387-23815-18-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1460741387-23815-1-git-send-email-aisheng.dong@nxp.com> References: <1460741387-23815-1-git-send-email-aisheng.dong@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131052154779939583; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(1096002)(19580405001)(1220700001)(19580395003)(50986999)(76176999)(86362001)(575784001)(4326007)(81166005)(110136002)(5003940100001)(2950100001)(77096005)(189998001)(92566002)(2351001)(229853001)(85426001)(106466001)(586003)(105606002)(33646002)(50226001)(47776003)(5008740100001)(2906002)(36756003)(104016004)(87936001)(48376002)(6806005)(50466002)(11100500001)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB1225; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD030; 1:YxIn1f2bUlFz19AUdysgA1vtFk0zI71TTTIfaILJGjAbceTJ0vOC6GEmmi2YYe938m//orwg9MCI6dPmZ1bHNhkBRSH5D0Ms8w7YGcoQq92yTpr3gmRswbCRg2TGsLBbTL2TmK4kcesdPv2U02sZJFPQjmn9M/MQ1PCawN5zqZ13J+UOsySmgJTLRvZcEC/WaWOgpmXchtjtSEw/Z+Td7itu2d2dMsGiwK3F9ObsaOKrUKfHYWI0bzH4PhDhmfqlAZKxAnJIXoFAZf4l3Y66a82vTU2ZfO0dgTll3uVFuDHaWJNAtIghtAmSza/sv9dyG1ezXjcId4Z0yIgAnREcKjVHude9/M4f12fVskqZOy8KU5q1lys13+Qy8Uin+citFd2a0YakbYecZiapq1JerJHgjyUKVvhJj/71zQvcb/avs23MnArtVWsIq8w9qS+Fx12hmKlv4svA1OP3PT94C0KWHxbOsBjiFjhM+jWAL3q0RaGqIZIA/SD4WAO4uxMQ0ixfztIUqGW8Rb266BuAq3YsJwu6unukqSc9jceX7rRou2YgHHpoz/XDJSxKAqYtJjnl7WlL6IXLXzE+N7LGv6wgbKWL+H4SK2PPiG8Vg5uZGm+bhBBg8v80jHPneG3N MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 013f34d4-d99a-4cb0-703d-08d36554af27 X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1225; 2:srZOWTMIcCW4aq93Pmkqa6L+8WPUla87n82R8+9hSwSnj/2A4HEPIeqcIQQzrlPPkeHmRpXbomt0uxEFdT428qTCoBVXUZykBuDzK2EILxGxSTUsazMIXGcv3VnTis98vcok08g6UOjhlno4JokJRWj9/dVKWawsnmSg8g3L7H9ILSHF2pp4yr4mzrgCeLg+; 3:9V46EjJjZsXIqamDbF8wgpja6FX69+aAu5bXWP8W5E9UsP/edCzkHxaEczFiuNkLK7fripNYBmdwNq+lxu7d3JQm8uvdpYum3Nyr2gHfGwjmWwsyzg5keTg3YqUMuiVN3/3yu8Sfuvr5gviDG3ga7qzVTgnKYfWQK5gfJ8O0ETGR9pfMaPQWVCrF46cs40OlRlQSG6mgYSF4JWrB3nw/Ci1itae73SsUsnZYtt3rIpM=; 25:4Ta7Z6b8c0QQbcw1aJTQsFsQ34gZB9Qbgrg1u3o75HxkvO0MZDx3moWPxbsWhRoUQSfL4IM/uEzPMVSG5R3yGmW1CXa1EEaYNg0PRIJouMn038PKdkVKbqb54wZPKsbWwyIhfoR6evHz7Kz/7l8BC7n60z406LCsr4F05K4iAeNH5AzXo70wsEaMuKKEYABLffy84gdWQJgHShxInUpfZXawvGRIX0hF7ypCwUcf5gwE8ZhzhnxLumUy3xa9TVCWedAeWYCv4HYiVwx9RmD7gdJ4TwyJDV2AEIwT1i20b5zEt94Lh4JUP03hgxCu9unjM78n2fJ0lEMQolz/Dad4ZQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1225; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(13015025)(13023025)(13017025)(5005006)(13018025)(13024025)(3002001)(10201501046)(6055026); SRVR:CY1PR0301MB1225; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB1225; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1225; 4:sh0PZO3kXEDpGVp3Db8YAx6JOA0uda13AZBis4jne8ps1uCu76QjsQRzuUxcgdvxKFb3ZBPrMEEeejydtxxJJ7TscQ90cnlPfeP2Hm8yXoJLGSdxir8xYnOy9UCD1giUEIcUzGG3e7gBs3n82y6AcTzfx96CJfN0+b+tP6BTq+47hJqy8CfMUSVNCBfuXbXIP3N+gpla8TeTBANM4JifI8fEO1HIp37g09fQ2kaYZpGtq2pznnj9jgNmPbjGSHkdCoyRAZTpdTp68MBKZLv4qb4omQrZlogWZA13mPRYyY4I05Xiz3jVyEN/3UZioIP6ks+jn7ky5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Fn/LHNn0+TsInPUnsn2XQrAwnX20+32I9c235HSgeULhIqrDtzG9rxnPYDPqXT2HOrgpc= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Apr 2016 17:37:57.0423 (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.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1225 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.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 repeatly retuning during small file system data access and improve the performance. Signed-off-by: Dong Aisheng --- drivers/mmc/host/sdhci.c | 18 ++++++++++++++---- drivers/mmc/host/sdhci.h | 3 +++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 2eb0e34..0027b87 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -252,6 +252,9 @@ 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_3) + host->ier |= SDHCI_INT_RETUNE; + sdhci_writel(host, host->ier, SDHCI_INT_ENABLE); sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE); @@ -2477,6 +2480,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; @@ -2575,8 +2581,10 @@ 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_1) { + mmc_retune_timer_stop(host->mmc); + mmc_retune_needed(host->mmc); + } if (!device_may_wakeup(mmc_dev(host->mmc))) { host->ier = 0; @@ -2651,8 +2659,10 @@ 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_1) { + mmc_retune_timer_stop(host->mmc); + 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 afa4de8..2c2404f 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 @@ -514,6 +515,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; };