From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michal Simek Subject: Re: [PATCH v3 3/3] mmc: sdhci-of-arasan: add runtime pm support Date: Tue, 20 Oct 2015 10:03:16 +0200 Message-ID: <5625F544.8000600@xilinx.com> References: <1445324727-31448-1-git-send-email-shawn.lin@rock-chips.com> Mime-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1445324727-31448-1-git-send-email-shawn.lin@rock-chips.com> Sender: linux-kernel-owner@vger.kernel.org To: Shawn Lin , Ulf Hansson , Michal Simek , soren.brinkmann@xilinx.com Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org List-Id: linux-mmc@vger.kernel.org Hi, On 10/20/2015 09:05 AM, Shawn Lin wrote: > This patch add runtime_suspend and runtime_resume for > sdhci-of-arasan. Currently we also suspend phy at > runtime_suspend for power-saving. > > Signed-off-by: Shawn Lin > --- > > Changes in v2: None > > drivers/mmc/host/sdhci-of-arasan.c | 80 ++++++++++++++++++++++++++++++++++++-- > 1 file changed, 77 insertions(+), 3 deletions(-) > > diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c > index 85bd0f9d..579f7bb 100644 > --- a/drivers/mmc/host/sdhci-of-arasan.c > +++ b/drivers/mmc/host/sdhci-of-arasan.c > @@ -30,6 +30,8 @@ > #define CLK_CTRL_TIMEOUT_MASK (0xf << CLK_CTRL_TIMEOUT_SHIFT) > #define CLK_CTRL_TIMEOUT_MIN_EXP 13 > > +#define ARASAN_RPM_DELAY_MS 50 > + > /** > * struct sdhci_arasan_data > * @clk_ahb: Pointer to the AHB clock > @@ -183,8 +185,70 @@ static int sdhci_arasan_resume(struct device *dev) > } > #endif /* ! CONFIG_PM_SLEEP */ > > -static SIMPLE_DEV_PM_OPS(sdhci_arasan_dev_pm_ops, sdhci_arasan_suspend, > - sdhci_arasan_resume); > + > +#ifdef CONFIG_PM > +static int sdhci_arasan_runtime_suspend(struct device *dev) > +{ > + struct sdhci_host *host = dev_get_drvdata(dev); > + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); > + struct sdhci_arasan_data *sdhci_arasan = pltfm_host->priv; > + int ret; > + > + ret = sdhci_runtime_suspend_host(host); > + if (ret) > + return ret; > + > + if (!IS_ERR(sdhci_arasan->phy)) { > + ret = sdhci_arasan_suspend_phy(sdhci_arasan->phy); > + if (ret) { > + dev_err(dev, "Cannot suspend phy at runtime.\n"); > + sdhci_runtime_resume_host(host); > + return ret; > + } > + } > + > + clk_disable_unprepare(sdhci_arasan->clk_ahb); > + clk_disable_unprepare(pltfm_host->clk); > + > + return 0; > +} > + > +static int sdhci_arasan_runtime_resume(struct device *dev) > +{ > + struct sdhci_host *host = dev_get_drvdata(dev); > + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); > + struct sdhci_arasan_data *sdhci_arasan = pltfm_host->priv; > + int ret; > + > + clk_prepare_enable(pltfm_host->clk); > + clk_prepare_enable(sdhci_arasan->clk_ahb); > + > + if (!IS_ERR(sdhci_arasan->phy)) { > + ret = sdhci_arasan_resume_phy(sdhci_arasan->phy); > + if (ret) { > + dev_err(dev, "Cannot resume phy at runtime.\n"); > + clk_disable_unprepare(sdhci_arasan->clk_ahb); > + clk_disable_unprepare(pltfm_host->clk); > + return ret; > + } > + } > + > + return sdhci_runtime_resume_host(host); > +} > +#endif > + > +#ifdef CONFIG_PM > +static const struct dev_pm_ops sdhci_arasan_pmops = { > + SET_SYSTEM_SLEEP_PM_OPS(sdhci_arasan_suspend, sdhci_arasan_resume) > + SET_RUNTIME_PM_OPS(sdhci_arasan_runtime_suspend, > + sdhci_arasan_runtime_resume, NULL) > +}; > + > +#define SDHCI_ARASAN_PMOPS (&sdhci_arasan_pmops) > + > +#else > +#define SDHCI_ARASAN_PMOPS NULL > +#endif This is completely wrong. SET_SYSTEM_SLEEP_PM_OPS, SET_RUNTIME_PM_OPS have both declarations for !PM_SLEEP, !PM cases. It means you can remove this ifdef mess. I was doing experiment with your code and you need to add __maybe_unused for functions which are not used when certain functions are not wired for !PM, !PM_SLEEP cases. Something like this should be added to any SDHCI header. (or Using macros). Definitely this should be tested for all combinations. #if !defined(CONFIG_PM) static inline int sdhci_suspend_host(struct sdhci_host *host) { return -1; } static inline int sdhci_resume_host(struct sdhci_host *host) { return -1; } static inline int sdhci_runtime_suspend_host(struct sdhci_host *host) { return -1; } static inline int sdhci_runtime_resume_host(struct sdhci_host *host) { return -1; } #endif > > static int sdhci_arasan_probe(struct platform_device *pdev) > { > @@ -272,6 +336,11 @@ static int sdhci_arasan_probe(struct platform_device *pdev) > goto clk_disable_all; > } > > + pm_runtime_set_autosuspend_delay(&pdev->dev, ARASAN_RPM_DELAY_MS); > + pm_runtime_use_autosuspend(&pdev->dev); > + pm_runtime_enable(&pdev->dev); > + pm_suspend_ignore_children(&pdev->dev, 1); > + > ret = sdhci_add_host(host); > if (ret) > goto err_pltfm_free; > @@ -279,6 +348,7 @@ static int sdhci_arasan_probe(struct platform_device *pdev) > return 0; > > err_pltfm_free: > + pm_runtime_disable(&pdev->dev); > sdhci_pltfm_free(pdev); > clk_disable_all: > clk_disable_unprepare(clk_xin); > @@ -297,6 +367,10 @@ static int sdhci_arasan_remove(struct platform_device *pdev) > if (!IS_ERR(sdhci_arasan->phy)) > phy_exit(sdhci_arasan->phy); > > + pm_runtime_get_sync(&pdev->dev); > + pm_runtime_dont_use_autosuspend(&pdev->dev); > + pm_runtime_disable(&pdev->dev); > + > clk_disable_unprepare(sdhci_arasan->clk_ahb); > > return sdhci_pltfm_unregister(pdev); > @@ -314,7 +388,7 @@ static struct platform_driver sdhci_arasan_driver = { > .driver = { > .name = "sdhci-arasan", > .of_match_table = sdhci_arasan_of_match, > - .pm = &sdhci_arasan_dev_pm_ops, > + .pm = SDHCI_ARASAN_PMOPS, Keep origin name here. No reason for this macro at all. > }, > .probe = sdhci_arasan_probe, > .remove = sdhci_arasan_remove, > Thanks, Michal From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753260AbbJTIDi (ORCPT ); Tue, 20 Oct 2015 04:03:38 -0400 Received: from mail-bn1bon0082.outbound.protection.outlook.com ([157.56.111.82]:15871 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752544AbbJTIDb (ORCPT ); Tue, 20 Oct 2015 04:03:31 -0400 Authentication-Results: spf=pass (sender IP is 149.199.60.100) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=xilinx.com; Subject: Re: [PATCH v3 3/3] mmc: sdhci-of-arasan: add runtime pm support To: Shawn Lin , Ulf Hansson , Michal Simek , References: <1445324727-31448-1-git-send-email-shawn.lin@rock-chips.com> CC: , From: Michal Simek X-Enigmail-Draft-Status: N1110 Message-ID: <5625F544.8000600@xilinx.com> Date: Tue, 20 Oct 2015 10:03:16 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1445324727-31448-1-git-send-email-shawn.lin@rock-chips.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-21890.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD043;1:EwVBeVmJ2PnQxDPVr01w7YcD2PP4LCIMQ0nwFwztvR2/pIoWeXhusXNJ8jB3OfyQPmuTPkKMMvlr8zbs3yHKOsexssYkp+Szuga5hNS4xOW1LQa0Glsd0hf+Nm8viCPglgr79nYWtXuWekXUs5M77+xcqfwDtYQCcfOyZr06r2qEyVSvJuMR5UO7CejvAHmkbhFQ6DnKXg+52XPLfcvOC4RlnwmYBSetlfxuJf9ogytnaMn/3XmtAxarkEm4D6D4MQfrSC5YTdg9DqmlM2yjiXTZSOLpzZS8urUVGCs8+V7NlcCX/sAO1cni41Qqu1WCH4CdjeJcaLQJ1cfJgoXa88a1sh44lAgefv3H/HMw2FH7RZOFmdIzSbgHHJLIDSdl6vD+Yac89ZxfDiIeNajTgQ== X-Forefront-Antispam-Report: CIP:149.199.60.100;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(438002)(479174004)(24454002)(189002)(377454003)(199003)(164054003)(65956001)(189998001)(86362001)(4001350100001)(23746002)(80316001)(64126003)(5001770100001)(36386004)(19580395003)(19580405001)(65806001)(87266999)(65816999)(54356999)(64706001)(50466002)(87936001)(50986999)(83506001)(33656002)(575784001)(47776003)(36756003)(76176999)(92566002)(106466001)(230783001)(46102003)(63266004)(5007970100001)(4001450100002)(5001960100002)(2950100001)(77096005)(59896002)(81156007)(11100500001)(5008740100001)(16796002)(6806005)(107986001)(5001870100001);DIR:OUT;SFP:1101;SCL:1;SRVR:BL2FFO11HUB005;H:xsj-pvapsmtpgw02;FPR:;SPF:Pass;PTR:xapps1.xilinx.com,unknown-60-100.xilinx.com;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11HUB005;2:vSTo1Rf4GZIcHbGrm90qYvJuSsnHjhYWXEkVJvPBQkBq4j5zOKJQUmwl5MKEdYQfhYdLGmBFO4Udv/Vw1PFA2LoueY+Tqsi51u88hktGJgpNmeDdLdDoq5cdzMVYuIcgNubMkGZXc0HCq8LvlISCxHlogIFTnB+uBK7ZhJOnXJU=;3:wHTKCUPyugsEIdJYb27MnMRJ3uW8GeD75yhvY8q/i5Jke0PW/zMd5ys1HIU2juVGtcL46k9+okWNFVvM04Sov+N8nwA9vqBL9dnShL1QTQKJPmWRSsW3gKfCQYbC7bty6xIZVKdocd9CuteOW6S6/drngstTEgdG7y/JiHJsvpUt3Rk/io9QLF9KgZfOBeVeykF6J1su4udwgwE2iePonNY3Jz1DrOTAjmU1uuytAbNacM2DTQIYnpKJpFALAMQGJ4s5SNXiActU7RbgB/bknQ==;25:BUDrnqDtzvPjO0CfiWbCeRHXbTdIHhTzGVOelbr+YP5YScu8aNQ8TsB7i0pP9UhF/F71GYAGED6m4jnWN0LRHP68AKcjzeXArg8yNGnh61sASHm39+Ztmg34SYspdYeICNL/iAMshyyOxPO0x3Xj3OIObhcTOJ2kDFf/PTSLYZyB4buFu5kr7r9zCJ/Ox3rJjoP18RXh+slvngNCas+jU4cYMLCP9xGoGjIPk9FrkuUo0/EaWbM1DByiMxSVK98viSPY5CXxA2YJPzaL/+sJKQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(8251501001);SRVR:BL2FFO11HUB005; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11HUB005;20:M294bf0gr77XG3i5Pq23UrE61DcHL/8fPPWSAySh+rW1fkNmEfsmShcXQmjzSoCEjKljwXvVNe9brnPr2HihCNzRyRRPv1xJbG6fBDEOerx3nvPrFFYVdMUDgK0SsKB3cCiAg21EBqisis3IFBhvtiSKLykXAKUI6FESyVhn3WbVO9QyY3ThDueIxnttlu92pb0Lje06YQkSpp4nXyuhm6oiTdPCGWzXNYJcbj4ZrbcQZFFp4DyqJaDVnNU36Ns3Kz7yR1SFhB8xNHV5/8pabfZ3pOVLo3jF6twKh8mqqIoLJAiIuqOsgbV/CHowTiDKhDdfeAjN/+5BHEftbo0bTAYzr2YxBZMGAtFm1SUwKMQA7r6cQJWmV1NDsfcNKCOsrNgW/dHklOb7Z1mUW3Ot13y3nMWA17ixg5p0xfo5TgHvx0bjRtumVIyvpu9QSLFXnx/WUUZ1leCbTIRP6RszBVexfhEtMNn1lhBM00VFlx4VS1SjVwqXmqepxuSHh+nx;4:GLGRZM+0ntkZoGycbEiW5B16C+IiZciiNvS0QufWsGVcWOmGVRJwznLJ8Qoa/B7VZtLriDwYMHz5y76luXX7HTSRiOerM4sOAC5Vr0dDnuWXTQOEymOrTp2Xc9FldjiJtGxqpetjflWn/biz3jlxu0CXfKD2NNW6S99+RYYWq5Pt/zBQnD0I9pAt3ZoGeKY/AJrdBTHZC6ENg9wqP+Pix60VZHnPlySDty6c6rEjNYFhRbKOTadzLWvjBBPXC3CwD2AeqOq1havlMWXdXI5SxF84ObQRs95XGPuA/C4t3yPntXCU++XJDlfz2XI5a3CBtcL4NgGo0/KRqb9Ee4tyKHVteE0sm8E4T1ebVyJQeHToWcB/OGU2uO4HTwCZ1OS1 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(520078)(5005006)(3002001)(10115024);SRVR:BL2FFO11HUB005;BCL:0;PCL:0;RULEID:;SRVR:BL2FFO11HUB005; X-Forefront-PRVS: 073515755F X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;BL2FFO11HUB005;23:ufcW8t2AH7TaQAhFFfyBwAB27ODCUS3RUV7q?= =?Windows-1252?Q?sFIZgxOfszY13W+s+AgvP3BY3wkDTarAENc6Ma0NJ9QIsYFpZg0CHfi9?= =?Windows-1252?Q?+HeYajKm04w7RUL8T6D+uQnOL7yNyaWVeefAc4FsN414Xkl2WypB3w/T?= =?Windows-1252?Q?zroi1l7r6Q05FonnY7G0T0OpubTRbpXu+n4VPopIvBvYXOKRL/jV9kLh?= =?Windows-1252?Q?3PyYZo4Ok3Wd8mrzo/T7S7VGaNckDinBjKRdToCVqTQb1j3DMaN0uZ0x?= =?Windows-1252?Q?muUmunCbA+d+J6dKd287KqAKvqasUtgNHHxQnz4o8x93bulDVQ64ENDB?= =?Windows-1252?Q?GrTzSw9MDAzIjDJ5N2Z/5kmBNnx8SXAt9q9ifeHFdj6TLQdacPUdBR4x?= =?Windows-1252?Q?B6QstGjSvSCPSr333JOwZkk1EDsyOd1d/ay/xTvzn6DNmnsHivgOypyr?= =?Windows-1252?Q?KXAt8fsC/srGeiprURL259OloXSnuSios/ipLsFyqPKoptD5sM544RZi?= =?Windows-1252?Q?dq2ZETLONsu3GXnu7j33cOnTeU+f0lHDCFaYoUgd7xMtjGn+yywcsBa5?= =?Windows-1252?Q?Rzszsi4C5BOxoMpi4xh/Z95K0LODlksCApVUU+K6YrxrLXG5k3AKp16s?= =?Windows-1252?Q?zD1NxlcN/BmjnubuCjUy5T7fh1jsEGPGuKDDmZh2Xle5NGXDuvs5ZTGg?= =?Windows-1252?Q?vgykj3hFXJVA8czU3pXYSwgi3IaBoL7v8/6kLiUjvwz6XwO+BtBwmmWq?= =?Windows-1252?Q?/tpo5vBkQOfv0cX8eqCuotY460QFQM0NnuY/lA+JSE0934UDHpTDMAGJ?= =?Windows-1252?Q?AkmItjDvjbXeH4g2dtWqcCUxjN8cf0yL5GbRTFdQO2smfvIRyJbUcvdl?= =?Windows-1252?Q?JQeRw3AmUsrhrOEeyUtLT9WU8pRce0+voH8UP0Yqu+mwWnBkLxnM7KCO?= =?Windows-1252?Q?gWkrh0+TZSBvtTHWPWurdvQkQdaANwVnGT9qJk5tmmiBCbxE/ollIR36?= =?Windows-1252?Q?xP83U14XnzFojHnGGiUiB1uWAiG6W94F/TuhK/6cVhIs2WAOPULxlhZt?= =?Windows-1252?Q?2rh40RKfmUAggwXr3WGOrvogJAEhd9xHngQxyEjEQ/BQhKV/42A8cO5w?= =?Windows-1252?Q?eKnynX95HJxGSQ04c/aZ3Fk8MtpCfI1Abgit5v3Ma+nh7LJy5KJhcZtB?= =?Windows-1252?Q?aEBKinZcF2Y4scSw0LZGmK/hpC41YEsjuYOMrSWafzxdyu43gKgsqAak?= =?Windows-1252?Q?N3gR6Pm1STWb9LWdnON/1GfRuOonzlFoUJ4II+MKlTLwjK89wtakJRht?= =?Windows-1252?Q?8GSvwGaYRFkfX0KxrYpJIIt3JWIIVCa5wTQbrqysz33Sljp0d7gpKuBG?= =?Windows-1252?Q?Q9KLA7koNIiFHwaYO1OWs9QS5Ny8GD3/X1ii1buOkA+oq0o+hwkUEN77?= =?Windows-1252?Q?jl+qw2qAaBqnR5ugvcuSjalDYtyGPUtt9lOb0xwh1vuR9uiElFEk9NGB?= =?Windows-1252?Q?LZAVAAw=3D?= X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11HUB005;5:+qsnFUIfvaDE//4ozKLx9DxGzghsTR1YtJZ9iHdaUl702Cq5/mg4pkMJKFxjRYDa1AMRhNWRSeMCYt3eOPzC7err1oM0qzw7i6zE2Y+mSks6kp04/I3crUJsce205tt1U5pjh0oRdDN5A8hSqKmEMw==;24:Hm6PPRRc6p82KEeBsc1Gqfd0QW37S8u5u1e/e0t2rgo2aMiGzLX75Z32WRS0bQMY8Ig/bufIgm355fHQPeSAXZFP2jmC+eWCelTow8q5ad0= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2015 08:03:28.4102 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.60.100];Helo=[xsj-pvapsmtpgw02] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2FFO11HUB005 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 10/20/2015 09:05 AM, Shawn Lin wrote: > This patch add runtime_suspend and runtime_resume for > sdhci-of-arasan. Currently we also suspend phy at > runtime_suspend for power-saving. > > Signed-off-by: Shawn Lin > --- > > Changes in v2: None > > drivers/mmc/host/sdhci-of-arasan.c | 80 ++++++++++++++++++++++++++++++++++++-- > 1 file changed, 77 insertions(+), 3 deletions(-) > > diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c > index 85bd0f9d..579f7bb 100644 > --- a/drivers/mmc/host/sdhci-of-arasan.c > +++ b/drivers/mmc/host/sdhci-of-arasan.c > @@ -30,6 +30,8 @@ > #define CLK_CTRL_TIMEOUT_MASK (0xf << CLK_CTRL_TIMEOUT_SHIFT) > #define CLK_CTRL_TIMEOUT_MIN_EXP 13 > > +#define ARASAN_RPM_DELAY_MS 50 > + > /** > * struct sdhci_arasan_data > * @clk_ahb: Pointer to the AHB clock > @@ -183,8 +185,70 @@ static int sdhci_arasan_resume(struct device *dev) > } > #endif /* ! CONFIG_PM_SLEEP */ > > -static SIMPLE_DEV_PM_OPS(sdhci_arasan_dev_pm_ops, sdhci_arasan_suspend, > - sdhci_arasan_resume); > + > +#ifdef CONFIG_PM > +static int sdhci_arasan_runtime_suspend(struct device *dev) > +{ > + struct sdhci_host *host = dev_get_drvdata(dev); > + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); > + struct sdhci_arasan_data *sdhci_arasan = pltfm_host->priv; > + int ret; > + > + ret = sdhci_runtime_suspend_host(host); > + if (ret) > + return ret; > + > + if (!IS_ERR(sdhci_arasan->phy)) { > + ret = sdhci_arasan_suspend_phy(sdhci_arasan->phy); > + if (ret) { > + dev_err(dev, "Cannot suspend phy at runtime.\n"); > + sdhci_runtime_resume_host(host); > + return ret; > + } > + } > + > + clk_disable_unprepare(sdhci_arasan->clk_ahb); > + clk_disable_unprepare(pltfm_host->clk); > + > + return 0; > +} > + > +static int sdhci_arasan_runtime_resume(struct device *dev) > +{ > + struct sdhci_host *host = dev_get_drvdata(dev); > + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); > + struct sdhci_arasan_data *sdhci_arasan = pltfm_host->priv; > + int ret; > + > + clk_prepare_enable(pltfm_host->clk); > + clk_prepare_enable(sdhci_arasan->clk_ahb); > + > + if (!IS_ERR(sdhci_arasan->phy)) { > + ret = sdhci_arasan_resume_phy(sdhci_arasan->phy); > + if (ret) { > + dev_err(dev, "Cannot resume phy at runtime.\n"); > + clk_disable_unprepare(sdhci_arasan->clk_ahb); > + clk_disable_unprepare(pltfm_host->clk); > + return ret; > + } > + } > + > + return sdhci_runtime_resume_host(host); > +} > +#endif > + > +#ifdef CONFIG_PM > +static const struct dev_pm_ops sdhci_arasan_pmops = { > + SET_SYSTEM_SLEEP_PM_OPS(sdhci_arasan_suspend, sdhci_arasan_resume) > + SET_RUNTIME_PM_OPS(sdhci_arasan_runtime_suspend, > + sdhci_arasan_runtime_resume, NULL) > +}; > + > +#define SDHCI_ARASAN_PMOPS (&sdhci_arasan_pmops) > + > +#else > +#define SDHCI_ARASAN_PMOPS NULL > +#endif This is completely wrong. SET_SYSTEM_SLEEP_PM_OPS, SET_RUNTIME_PM_OPS have both declarations for !PM_SLEEP, !PM cases. It means you can remove this ifdef mess. I was doing experiment with your code and you need to add __maybe_unused for functions which are not used when certain functions are not wired for !PM, !PM_SLEEP cases. Something like this should be added to any SDHCI header. (or Using macros). Definitely this should be tested for all combinations. #if !defined(CONFIG_PM) static inline int sdhci_suspend_host(struct sdhci_host *host) { return -1; } static inline int sdhci_resume_host(struct sdhci_host *host) { return -1; } static inline int sdhci_runtime_suspend_host(struct sdhci_host *host) { return -1; } static inline int sdhci_runtime_resume_host(struct sdhci_host *host) { return -1; } #endif > > static int sdhci_arasan_probe(struct platform_device *pdev) > { > @@ -272,6 +336,11 @@ static int sdhci_arasan_probe(struct platform_device *pdev) > goto clk_disable_all; > } > > + pm_runtime_set_autosuspend_delay(&pdev->dev, ARASAN_RPM_DELAY_MS); > + pm_runtime_use_autosuspend(&pdev->dev); > + pm_runtime_enable(&pdev->dev); > + pm_suspend_ignore_children(&pdev->dev, 1); > + > ret = sdhci_add_host(host); > if (ret) > goto err_pltfm_free; > @@ -279,6 +348,7 @@ static int sdhci_arasan_probe(struct platform_device *pdev) > return 0; > > err_pltfm_free: > + pm_runtime_disable(&pdev->dev); > sdhci_pltfm_free(pdev); > clk_disable_all: > clk_disable_unprepare(clk_xin); > @@ -297,6 +367,10 @@ static int sdhci_arasan_remove(struct platform_device *pdev) > if (!IS_ERR(sdhci_arasan->phy)) > phy_exit(sdhci_arasan->phy); > > + pm_runtime_get_sync(&pdev->dev); > + pm_runtime_dont_use_autosuspend(&pdev->dev); > + pm_runtime_disable(&pdev->dev); > + > clk_disable_unprepare(sdhci_arasan->clk_ahb); > > return sdhci_pltfm_unregister(pdev); > @@ -314,7 +388,7 @@ static struct platform_driver sdhci_arasan_driver = { > .driver = { > .name = "sdhci-arasan", > .of_match_table = sdhci_arasan_of_match, > - .pm = &sdhci_arasan_dev_pm_ops, > + .pm = SDHCI_ARASAN_PMOPS, Keep origin name here. No reason for this macro at all. > }, > .probe = sdhci_arasan_probe, > .remove = sdhci_arasan_remove, > Thanks, Michal