From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kevin Hilman Subject: Re: [PATCH 05/17] mmc: mmci: Put the device into low power state at system suspend Date: Mon, 10 Feb 2014 10:03:57 -0800 Message-ID: <7hmwhyalpu.fsf@paris.lan> References: <1391529538-21685-1-git-send-email-ulf.hansson@linaro.org> <1391529538-21685-6-git-send-email-ulf.hansson@linaro.org> <8738jyu1h9.fsf@paris.lan> Mime-Version: 1.0 Content-Type: text/plain Return-path: In-Reply-To: (Ulf Hansson's message of "Mon, 10 Feb 2014 12:11:24 +0100") Sender: linux-kernel-owner@vger.kernel.org To: Ulf Hansson Cc: Russell King , "linux-arm-kernel@lists.infradead.org" , Alessandro Rubini , Linus Walleij , Wolfram Sang , Chris Ball , Mark Brown , "linux-kernel@vger.kernel.org" , "linux-i2c@vger.kernel.org" , "linux-spi@vger.kernel.org" , linux-mmc List-Id: linux-i2c@vger.kernel.org Ulf Hansson writes: > On 4 February 2014 20:22, Kevin Hilman wrote: >> Ulf Hansson writes: >> >>> Due to the available runtime PM callbacks, we are now able to put our >>> device into low power state at system suspend. >>> >>> Earlier we could not accomplish this without trusting a power domain >>> for the device to take care of it. Now we are able to cope with >>> scenarios both with and without a power domain. >>> >>> Cc: Russell King >>> Signed-off-by: Ulf Hansson >>> --- >>> drivers/mmc/host/mmci.c | 45 +++++++++++++++++++++++++-------------------- >>> 1 file changed, 25 insertions(+), 20 deletions(-) >>> >>> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c >>> index c88da1c..074e0cb 100644 >>> --- a/drivers/mmc/host/mmci.c >>> +++ b/drivers/mmc/host/mmci.c >>> @@ -1723,33 +1723,38 @@ static int mmci_remove(struct amba_device *dev) >>> return 0; >>> } >>> >>> -#ifdef CONFIG_SUSPEND >>> -static int mmci_suspend(struct device *dev) >>> +#ifdef CONFIG_PM_SLEEP >>> +static int mmci_suspend_late(struct device *dev) >>> { >>> - struct amba_device *adev = to_amba_device(dev); >>> - struct mmc_host *mmc = amba_get_drvdata(adev); >>> + int ret = 0; >>> >>> - if (mmc) { >>> - struct mmci_host *host = mmc_priv(mmc); >>> - pm_runtime_get_sync(dev); >>> - writel(0, host->base + MMCIMASK0); >>> - } >>> + if (pm_runtime_status_suspended(dev)) >>> + return 0; >>> >>> - return 0; >>> + if (dev->pm_domain && dev->pm_domain->ops.runtime_suspend) >>> + ret = dev->pm_domain->ops.runtime_suspend(dev); >>> + else >>> + ret = dev->bus->pm->runtime_suspend(dev); >>> + >>> + if (!ret) >>> + pm_runtime_set_suspended(dev); >> >> Isn't this basically open-coding pm_runtime_suspend()... > > It is similar, but with once big difference. > > Since the PM core prevents pm_runtime_suspend() from invoking our > ->runtime_suspend callback during system suspend (it does so by > invoking pm_runtime_get_sync() before starting the suspend sequence), > we then need to make the driver handle that by itself. Yeah, I still think we need to allow a bus/pm_domain to override that behavior. Kevin From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kevin Hilman Subject: Re: [PATCH 05/17] mmc: mmci: Put the device into low power state at system suspend Date: Mon, 10 Feb 2014 10:03:57 -0800 Message-ID: <7hmwhyalpu.fsf@paris.lan> References: <1391529538-21685-1-git-send-email-ulf.hansson@linaro.org> <1391529538-21685-6-git-send-email-ulf.hansson@linaro.org> <8738jyu1h9.fsf@paris.lan> Mime-Version: 1.0 Content-Type: text/plain Cc: Russell King , "linux-arm-kernel\@lists.infradead.org" , Alessandro Rubini , Linus Walleij , Wolfram Sang , Chris Ball , Mark Brown , "linux-kernel\@vger.kernel.org" , "linux-i2c\@vger.kernel.org" , "linux-spi\@vger.kernel.org" , linux-mmc To: Ulf Hansson Return-path: In-Reply-To: (Ulf Hansson's message of "Mon, 10 Feb 2014 12:11:24 +0100") Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-spi.vger.kernel.org Ulf Hansson writes: > On 4 February 2014 20:22, Kevin Hilman wrote: >> Ulf Hansson writes: >> >>> Due to the available runtime PM callbacks, we are now able to put our >>> device into low power state at system suspend. >>> >>> Earlier we could not accomplish this without trusting a power domain >>> for the device to take care of it. Now we are able to cope with >>> scenarios both with and without a power domain. >>> >>> Cc: Russell King >>> Signed-off-by: Ulf Hansson >>> --- >>> drivers/mmc/host/mmci.c | 45 +++++++++++++++++++++++++-------------------- >>> 1 file changed, 25 insertions(+), 20 deletions(-) >>> >>> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c >>> index c88da1c..074e0cb 100644 >>> --- a/drivers/mmc/host/mmci.c >>> +++ b/drivers/mmc/host/mmci.c >>> @@ -1723,33 +1723,38 @@ static int mmci_remove(struct amba_device *dev) >>> return 0; >>> } >>> >>> -#ifdef CONFIG_SUSPEND >>> -static int mmci_suspend(struct device *dev) >>> +#ifdef CONFIG_PM_SLEEP >>> +static int mmci_suspend_late(struct device *dev) >>> { >>> - struct amba_device *adev = to_amba_device(dev); >>> - struct mmc_host *mmc = amba_get_drvdata(adev); >>> + int ret = 0; >>> >>> - if (mmc) { >>> - struct mmci_host *host = mmc_priv(mmc); >>> - pm_runtime_get_sync(dev); >>> - writel(0, host->base + MMCIMASK0); >>> - } >>> + if (pm_runtime_status_suspended(dev)) >>> + return 0; >>> >>> - return 0; >>> + if (dev->pm_domain && dev->pm_domain->ops.runtime_suspend) >>> + ret = dev->pm_domain->ops.runtime_suspend(dev); >>> + else >>> + ret = dev->bus->pm->runtime_suspend(dev); >>> + >>> + if (!ret) >>> + pm_runtime_set_suspended(dev); >> >> Isn't this basically open-coding pm_runtime_suspend()... > > It is similar, but with once big difference. > > Since the PM core prevents pm_runtime_suspend() from invoking our > ->runtime_suspend callback during system suspend (it does so by > invoking pm_runtime_get_sync() before starting the suspend sequence), > we then need to make the driver handle that by itself. Yeah, I still think we need to allow a bus/pm_domain to override that behavior. Kevin From mboxrd@z Thu Jan 1 00:00:00 1970 From: khilman@linaro.org (Kevin Hilman) Date: Mon, 10 Feb 2014 10:03:57 -0800 Subject: [PATCH 05/17] mmc: mmci: Put the device into low power state at system suspend In-Reply-To: (Ulf Hansson's message of "Mon, 10 Feb 2014 12:11:24 +0100") References: <1391529538-21685-1-git-send-email-ulf.hansson@linaro.org> <1391529538-21685-6-git-send-email-ulf.hansson@linaro.org> <8738jyu1h9.fsf@paris.lan> Message-ID: <7hmwhyalpu.fsf@paris.lan> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Ulf Hansson writes: > On 4 February 2014 20:22, Kevin Hilman wrote: >> Ulf Hansson writes: >> >>> Due to the available runtime PM callbacks, we are now able to put our >>> device into low power state at system suspend. >>> >>> Earlier we could not accomplish this without trusting a power domain >>> for the device to take care of it. Now we are able to cope with >>> scenarios both with and without a power domain. >>> >>> Cc: Russell King >>> Signed-off-by: Ulf Hansson >>> --- >>> drivers/mmc/host/mmci.c | 45 +++++++++++++++++++++++++-------------------- >>> 1 file changed, 25 insertions(+), 20 deletions(-) >>> >>> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c >>> index c88da1c..074e0cb 100644 >>> --- a/drivers/mmc/host/mmci.c >>> +++ b/drivers/mmc/host/mmci.c >>> @@ -1723,33 +1723,38 @@ static int mmci_remove(struct amba_device *dev) >>> return 0; >>> } >>> >>> -#ifdef CONFIG_SUSPEND >>> -static int mmci_suspend(struct device *dev) >>> +#ifdef CONFIG_PM_SLEEP >>> +static int mmci_suspend_late(struct device *dev) >>> { >>> - struct amba_device *adev = to_amba_device(dev); >>> - struct mmc_host *mmc = amba_get_drvdata(adev); >>> + int ret = 0; >>> >>> - if (mmc) { >>> - struct mmci_host *host = mmc_priv(mmc); >>> - pm_runtime_get_sync(dev); >>> - writel(0, host->base + MMCIMASK0); >>> - } >>> + if (pm_runtime_status_suspended(dev)) >>> + return 0; >>> >>> - return 0; >>> + if (dev->pm_domain && dev->pm_domain->ops.runtime_suspend) >>> + ret = dev->pm_domain->ops.runtime_suspend(dev); >>> + else >>> + ret = dev->bus->pm->runtime_suspend(dev); >>> + >>> + if (!ret) >>> + pm_runtime_set_suspended(dev); >> >> Isn't this basically open-coding pm_runtime_suspend()... > > It is similar, but with once big difference. > > Since the PM core prevents pm_runtime_suspend() from invoking our > ->runtime_suspend callback during system suspend (it does so by > invoking pm_runtime_get_sync() before starting the suspend sequence), > we then need to make the driver handle that by itself. Yeah, I still think we need to allow a bus/pm_domain to override that behavior. Kevin