From patchwork Tue Oct 18 07:39:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bough Chen X-Patchwork-Id: 9382635 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 B829660839 for ; Tue, 18 Oct 2016 16:08:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7AA829679 for ; Tue, 18 Oct 2016 16:08:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B0572967E; Tue, 18 Oct 2016 16:08:08 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 611BC29679 for ; Tue, 18 Oct 2016 16:08:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964839AbcJRQIG (ORCPT ); Tue, 18 Oct 2016 12:08:06 -0400 Received: from mail-db5eur01on0055.outbound.protection.outlook.com ([104.47.2.55]:2803 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1030371AbcJRQIB (ORCPT ); Tue, 18 Oct 2016 12:08:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=NfaXZLWLeB+KrVzTVaCko2hH3Qovk4PmRLgWeB1NYjM=; b=f7d/kZKeAAKFMbbGbuKWjIeAvA6eN9UIh1XG40IH8T3B/ntG03AxZ+Mxtn/AAg5CFEh+qKPpNWY0UaVryRI6nwi4M2znXnvtFLII66z3hoHlPZvEF4P1Z6znPbyohHy8MerqJ42kCPae/+kYVcBOjsKqtwH5hqcvE2fItCKNgT8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=haibo.chen@nxp.com; Received: from b51421-server.ap.freescale.net (199.59.230.102) by AM4PR0401MB2321.eurprd04.prod.outlook.com (10.165.45.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.659.8; Tue, 18 Oct 2016 07:33:58 +0000 From: Haibo Chen To: , , CC: , , Subject: [PATCH] mmc: sdhci-esdhc-imx: make sure usdhc clock enabled while doing suspend Date: Tue, 18 Oct 2016 15:39:00 +0800 Message-ID: <1476776340-23718-1-git-send-email-haibo.chen@nxp.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [199.59.230.102] X-ClientProxiedBy: HK2PR02CA0072.apcprd02.prod.outlook.com (10.165.70.40) To AM4PR0401MB2321.eurprd04.prod.outlook.com (10.165.45.20) X-MS-Office365-Filtering-Correlation-Id: 4244ff7d-09f3-4a01-d453-08d3f729231a X-Microsoft-Exchange-Diagnostics: 1; AM4PR0401MB2321; 2:HInzf69yYjLw+ic3ygG92qygTLz/DS1o1qsPZjzjjWagnXOqHlgEi6+V7KOcgqlbh+pwhK7UfzBScbRF46v4MdHJ3BPjJgVL2RhIN18YXffVh7VnAy3ro41bYqrI2sZ4481uP9n4Ti5Fr149EnVes8ybnE7A18TwF7agW8Rhs87BYCePZEiiwGMNPpr0SUUcPX11giuguH8aPvUCUUM2Bw==; 3:X4+KJdoWaKYNJZaJEVJp4cdx0iDIhF6VkAAps/V3pPNqHpNwjYVWupHq5sBATFC3Cfj9Bcsm5o4S+vhpc6Xh77Z6xtj6kIW0bSP/hbahiNCuAha3K9U3hCneqqdmwq0fd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hMXJZDz4PODxVFRYnUuAX3gnvf+V4FDbfP2f+uTxYD0eIAhvSNAIwjEIDCSr6BeWbCeS1mbqY6Qs2Ll+vjeI8Ec6NbDeQBN+345l6QJFqGWcel2S4MB1iD1VQgLtnNSzkF6pMBegpv7U1SkJ7H6e5NHjTMjH9rIs1O2uuZnJuL9M+pgSWXepy2XI4fOKW2IPrPtZ6gF5nhf+pVqJzmNOKhb7sswVnWgz4B8maz5i+EogsVvXQXdlV3Va6xTS2oTcHsXnAWbvm3OxvbJA9bHtTPCyXl4VlBo1s8 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(21532816269658); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:AM4PR0401MB2321; BCL:0; PCL:0; RULEID:; SRVR:AM4PR0401MB2321; X-Microsoft-Exchange-Diagnostics: 1; AM4PR0401MB2321; 4:A1CCwA8tmVDf1L1abkRTg6az+r1zzJ2/8Eex3pdRhVXqa2Bm15oaisDITuYuvBOqyKf+M11mNpRBpiYai7WUP30tHaTO+C7sE98bni2rVgp+Cajj2VuNBjKASCuFMyhGOUEwLguySEZokKZq0zdufd03Lm6qmATnDZwh9JblW9UoY0sbvaYAqpwaM6ZxrMTysuN/Ij5jtkSxppImVH1Oi1IVoU+pq2wbsuPN0s/MjNPBEURorM9yFPECdgMcZowxiTmcNHuvU9yjszHwf0kMaJVEIgeH8lsLXYaKGGNIBUdRK+xB6tczmEkQ46VCnUYOMg9tdT0y/EBVSMhjVy0iYZ8/2L0VCUUlkYmqrdrTweXYbN89q7hfD6rzi7++Np92T9VmBehf/L7f3OB6NuDIB6vMDnbE5DRuos7x84HVtt/2U2jQ56dYAMpbeWI0ucE13xn2iTj2Pou84OCfOHmQHzjRLQkkQ4Tum6ejruAWTpBz2nbRhZxmIdsC0BofC8Zo X-Forefront-PRVS: 00997889E7 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(189002)(199003)(6666003)(105586002)(50986999)(106356001)(5660300001)(586003)(6116002)(3846002)(42186005)(68736007)(101416001)(33646002)(36756003)(97736004)(230783001)(5001770100001)(5003940100001)(189998001)(66066001)(19580395003)(19580405001)(229853001)(47776003)(15650500001)(4326007)(7736002)(50466002)(7846002)(50226002)(2201001)(92566002)(8676002)(2906002)(81166006)(81156014)(48376002)(305945005)(77096005)(86362001)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR0401MB2321; H:b51421-server.ap.freescale.net; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM4PR0401MB2321; 23:CGWLc7nFM3oVnSHHvdMXj/RtFDQda1MuJw4Bj4Y?= =?us-ascii?Q?7zogLYOeLk8+VKQuFjXjPhiLHb6aHU6CjZmtxXebh9Y903JnGCelObUzeDft?= =?us-ascii?Q?SALFjW+gipWSygYMIwz4Y1QtPYS/icV4MrqKNJfr9J8VsWDAkEVg6KyRcdIT?= =?us-ascii?Q?vKf/cDFXGytlQ5Hjcz+//YZQuaxong13eBrrl/TjVzI+WO86+cTtUUzIrCAt?= =?us-ascii?Q?3B3ZvLmEfUGEug2BA4/DaBjaJpC6j9NEGSogXZqzxfgrQ228Tb0gIZZ5ve0c?= =?us-ascii?Q?o0xlcds8dxK19stRzLY0zUWfIPUCEkDa4sej5Q6ffN7UHfD4wQPxrZddRib+?= =?us-ascii?Q?2uOLHV3azPqj6b40fNWqihMvNPZzxGEaqiHYywZiX6cr0X6rbANAAdHhVkfZ?= =?us-ascii?Q?SqJnH6Q5EI3qb/NMu6OxoceLCKEK03shAioDPAOZeRke1MD9pR+2QLK8MJ9/?= =?us-ascii?Q?59IgZ39zzVeJN+luGzpisPWCu3KXuLxx5olj0bIcBL2cOEX8qKLLLttjYL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MWKruFexUBIdbTzoj3n5S46uwNOt40LkiZhnuj13i+UWxwMn4gSxP625JTPpXsSplCr8kKrza3j9fgADpE5DuZlOa5KLigsaf1fw1N1uMxw=; 5:jIqEi1hqSufDHqZ9xef+BfkApxfZJgC6ACa9PiIhi4G4xdukyOFt9yqHvxt37xZpUcg6TRtyk7VnuzffrhLOObapBJGLL6rQNblrIb5NKYxzgEpRPvLfmmu+yXzMpSH543t3R5eIzqPK6bCxAvt51Ppn2Wnnh7ezOYXnPaWxXAs=; 24:TfhMwU+3yXfYn5rSPGeWRxSJcwY6cU/ZqkqwaY+uykVsQ+rdDHaXw1w1igbIJz/w6Tva1teEOnjis4HCwMjzDB28JWx9+twlNaYzlrOzQYI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM4PR0401MB2321; 7:5R2l7io7gAMScbCyxRfyBKC/h4W0eG+NRnmpdJsQj5MY+cuMaLrtgKxmNKt+MwPORWkhRL8QuKkdL/JckAbmoCg1lHHmCP40bpGVUEYh5WMWGwTCvRA8ixHqwd6FrKLIWa1HD072Av5l4nlwHBL7GUbx7STUtS42ZIug7p17BEhzlwcAa+BgvenGR0oGxP7vwkVeZOnzhocBJmtRVkEToNeXv482wVF2OBIRv1yl3/r5ywI1Rmi76I/gN0WDg7pa2OC2LWBpE/aKDSKRwY4Hbg2jyU1LzLg+lgqRRD7ELf2UZXPy27C4cH1AJ5rp9mnZPSckpOz+Q4EREwz7YnuT4GNnmxiZ5LXiip8aTCm+Zyo= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2016 07:33:58.1880 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0401MB2321 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 When suspend usdhc, it will access usdhc register. So usdhc clock should be enabled, otherwise the access usdhc register will return error or cause system hung. Take this into consideration, if system enable a usdhc and do not connect any SD/SDIO/MMC card, after system boot up, this usdhc will do runtime suspend, and close all usdhc clock. At this time, if suspend the system, due to no card persent, usdhc runtime resume will not be called. So usdhc clock still closed, then in suspend, once access usdhc register, system hung or bus error return. This patch make sure usdhc clock always enabled while doing usdhc suspend. Signed-off-by: Haibo Chen --- drivers/mmc/host/sdhci-esdhc-imx.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index 7123ef9..1df3846 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -1322,17 +1322,28 @@ static int sdhci_esdhc_suspend(struct device *dev) { struct sdhci_host *host = dev_get_drvdata(dev); +#ifdef CONFIG_PM + pm_runtime_get_sync(host->mmc->parent); +#endif + return sdhci_suspend_host(host); } static int sdhci_esdhc_resume(struct device *dev) { struct sdhci_host *host = dev_get_drvdata(dev); + int ret; /* re-initialize hw state in case it's lost in low power mode */ sdhci_esdhc_imx_hwinit(host); + ret = sdhci_resume_host(host); - return sdhci_resume_host(host); +#ifdef CONFIG_PM + pm_runtime_mark_last_busy(host->mmc->parent); + pm_runtime_put_autosuspend(host->mmc->parent); +#endif + + return ret; } #endif