From: Kevin Hilman <khilman@kernel.org>
To: Rajendra Nayak <rnayak@codeaurora.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
linux-mmc <linux-mmc@vger.kernel.org>
Subject: Re: [RFC/RFT 4/6] mmc: sdhci-msm: convert driver to use runtime PM apis
Date: Thu, 23 Apr 2015 14:15:21 -0700 [thread overview]
Message-ID: <7htww65yxi.fsf@deeprootsystems.com> (raw)
In-Reply-To: <f390840a65cdf503397b162f2f8f8133.squirrel@www.codeaurora.org> (Rajendra Nayak's message of "Thu, 23 Apr 2015 13:42:52 -0000")
"Rajendra Nayak" <rnayak@codeaurora.org> writes:
>> On 23 April 2015 at 10:45, Rajendra Nayak <rnayak@codeaurora.org> wrote:
>>> With platform support now in place to manage clocks from within runtime
>>> PM
>>> callbacks, get rid of all clock handling from the driver and convert the
>>> driver to use runtime PM apis.
>>>
>>> Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
>>> Cc: <linux-mmc@vger.kernel.org>
>>> ---
>>> drivers/mmc/host/sdhci-msm.c | 46
>>> +++++++++++---------------------------------
>>> 1 file changed, 11 insertions(+), 35 deletions(-)
>>>
>>> diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
>>> index 4a09f76..3c62a77 100644
>>> --- a/drivers/mmc/host/sdhci-msm.c
>>> +++ b/drivers/mmc/host/sdhci-msm.c
>>> @@ -19,6 +19,7 @@
>>> #include <linux/delay.h>
>>> #include <linux/mmc/mmc.h>
>>> #include <linux/slab.h>
>>> +#include <linux/pm_runtime.h>
>>>
>>> #include "sdhci-pltfm.h"
>>>
>>> @@ -56,8 +57,6 @@
>>> struct sdhci_msm_host {
>>> struct platform_device *pdev;
>>> void __iomem *core_mem; /* MSM SDCC mapped address */
>>> - struct clk *clk; /* main SD/MMC bus clock */
>>> - struct clk *pclk; /* SDHC peripheral bus clock */
>>> struct clk *bus_clk; /* SDHC bus voter clock */
>>> struct mmc_host *mmc;
>>> struct sdhci_pltfm_data sdhci_msm_pdata;
>>> @@ -469,29 +468,8 @@ static int sdhci_msm_probe(struct platform_device
>>> *pdev)
>>> goto pltfm_free;
>>> }
>>>
>>> - /* Setup main peripheral bus clock */
>>> - msm_host->pclk = devm_clk_get(&pdev->dev, "iface");
>>> - if (IS_ERR(msm_host->pclk)) {
>>> - ret = PTR_ERR(msm_host->pclk);
>>> - dev_err(&pdev->dev, "Perpheral clk setup failed (%d)\n",
>>> ret);
>>> - goto bus_clk_disable;
>>> - }
>>> -
>>> - ret = clk_prepare_enable(msm_host->pclk);
>>> - if (ret)
>>> - goto bus_clk_disable;
>>> -
>>> - /* Setup SDC MMC clock */
>>> - msm_host->clk = devm_clk_get(&pdev->dev, "core");
>>> - if (IS_ERR(msm_host->clk)) {
>>> - ret = PTR_ERR(msm_host->clk);
>>> - dev_err(&pdev->dev, "SDC MMC clk setup failed (%d)\n",
>>> ret);
>>> - goto pclk_disable;
>>> - }
>>> -
>>> - ret = clk_prepare_enable(msm_host->clk);
>>> - if (ret)
>>> - goto pclk_disable;
>>> + pm_runtime_enable(&pdev->dev);
>>> + pm_runtime_get_sync(&pdev->dev);
>>>
>>> core_memres = platform_get_resource(pdev, IORESOURCE_MEM, 1);
>>> msm_host->core_mem = devm_ioremap_resource(&pdev->dev,
>>> core_memres);
>>> @@ -499,7 +477,7 @@ static int sdhci_msm_probe(struct platform_device
>>> *pdev)
>>> if (IS_ERR(msm_host->core_mem)) {
>>> dev_err(&pdev->dev, "Failed to remap registers\n");
>>> ret = PTR_ERR(msm_host->core_mem);
>>> - goto clk_disable;
>>> + goto err;
>>> }
>>>
>>> /* Reset the core and Enable SDHC mode */
>>> @@ -511,7 +489,7 @@ static int sdhci_msm_probe(struct platform_device
>>> *pdev)
>>> if (readl(msm_host->core_mem + CORE_POWER) & CORE_SW_RST) {
>>> dev_err(&pdev->dev, "Stuck in reset\n");
>>> ret = -ETIMEDOUT;
>>> - goto clk_disable;
>>> + goto err;
>>> }
>>>
>>> /* Set HC_MODE_EN bit in HC_MODE register */
>>> @@ -545,15 +523,13 @@ static int sdhci_msm_probe(struct platform_device
>>> *pdev)
>>>
>>> ret = sdhci_add_host(host);
>>> if (ret)
>>> - goto clk_disable;
>>> + goto err;
>>>
>>> return 0;
>>>
>>> -clk_disable:
>>> - clk_disable_unprepare(msm_host->clk);
>>> -pclk_disable:
>>> - clk_disable_unprepare(msm_host->pclk);
>>> -bus_clk_disable:
>>> +err:
>>> + pm_runtime_put_sync(&pdev->dev);
>>> + pm_runtime_disable(&pdev->dev);
>>> if (!IS_ERR(msm_host->bus_clk))
>>> clk_disable_unprepare(msm_host->bus_clk);
>>> pltfm_free:
>>> @@ -571,8 +547,8 @@ static int sdhci_msm_remove(struct platform_device
>>> *pdev)
>>>
>>> sdhci_remove_host(host, dead);
>>> sdhci_pltfm_free(pdev);
>>> - clk_disable_unprepare(msm_host->clk);
>>> - clk_disable_unprepare(msm_host->pclk);
>>> + pm_runtime_put_sync(&pdev->dev);
>>> + pm_runtime_disable(&pdev->dev);
>>> if (!IS_ERR(msm_host->bus_clk))
>>> clk_disable_unprepare(msm_host->bus_clk);
>>> return 0;
>>> --
>>> QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
>>> member
>>> of Code Aurora Forum, hosted by The Linux Foundation
>>>
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
>> This all looks wrong. The driver will no longer work unless CONFIG_PM is
>> set.
>
> Right, I seem to have completely ignored the !CONFIG_PM case.
> Will look at how to handle that.
IMO, don't complicate the driver with that. Just enable (or leave
enabled) all the clocks in the clock driver in the !CONFIG_PM case.
Kevin
next prev parent reply other threads:[~2015-04-23 21:15 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-23 8:45 [RFC/RFT 0/6] qcom: Add runtime PM support Rajendra Nayak
2015-04-23 8:45 ` [RFC/RFT 1/6] PM / clock_ops: Make pm_clk_notify() do nothing in case DT passes power-domains Rajendra Nayak
2015-04-23 8:45 ` [RFC/RFT 2/6] clk: qcom: Add runtime support to handle clocks using PM clocks Rajendra Nayak
2015-04-24 10:03 ` Ulf Hansson
2015-04-24 10:58 ` Rajendra Nayak
2015-04-26 8:49 ` Geert Uytterhoeven
2015-04-27 20:02 ` Kevin Hilman
2015-04-28 2:52 ` Rajendra Nayak
2015-04-28 7:25 ` Geert Uytterhoeven
2015-04-29 9:49 ` Rajendra Nayak
2015-04-29 11:30 ` Geert Uytterhoeven
2015-04-29 12:31 ` Ulf Hansson
2015-04-29 13:08 ` Geert Uytterhoeven
2015-04-30 6:21 ` Ulf Hansson
2015-04-30 9:02 ` Ulf Hansson
2015-04-27 7:08 ` Ulf Hansson
2015-04-23 8:45 ` [RFC/RFT 3/6] serial: msm: convert driver to use runtime PM apis Rajendra Nayak
2015-04-29 0:16 ` Stephen Boyd
2015-04-29 3:15 ` Rajendra Nayak
2015-04-23 8:45 ` [RFC/RFT 4/6] mmc: sdhci-msm: " Rajendra Nayak
2015-04-23 13:21 ` Ulf Hansson
2015-04-23 13:42 ` Rajendra Nayak
2015-04-23 21:15 ` Kevin Hilman [this message]
2015-04-24 0:45 ` Rajendra Nayak
2015-04-23 13:43 ` Rajendra Nayak
2015-04-23 8:45 ` [RFC/RFT 5/6] i2c: qup: Get rid of clock handling as its done using runtime callbacks Rajendra Nayak
2015-04-23 21:16 ` Kevin Hilman
2015-04-24 2:32 ` Rajendra Nayak
2015-04-25 7:01 ` Ivan T. Ivanov
2015-04-27 2:36 ` Rajendra Nayak
2015-04-23 8:45 ` [RFC/RFT 6/6] spi: " Rajendra Nayak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7htww65yxi.fsf@deeprootsystems.com \
--to=khilman@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rnayak@codeaurora.org \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).