From mboxrd@z Thu Jan 1 00:00:00 1970 From: Krzysztof Kozlowski Subject: Re: [PATCH 2/3] spi: s3c64xx: fix runtime PM handling Date: Wed, 19 Aug 2015 09:35:23 +0900 Message-ID: <55D3CF4B.5060208@samsung.com> References: <55D39E41.8010908@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-path: Received: from mailout2.w1.samsung.com ([210.118.77.12]:65162 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750822AbbHSAf0 (ORCPT ); Tue, 18 Aug 2015 20:35:26 -0400 In-reply-to: <55D39E41.8010908@gmail.com> Sender: linux-samsung-soc-owner@vger.kernel.org List-Id: linux-samsung-soc@vger.kernel.org To: Heiner Kallweit , linux-samsung-soc@vger.kernel.org Cc: "linux-spi@vger.kernel.org" On 19.08.2015 06:06, Heiner Kallweit wrote: > The patch fixes / extends the runtime PM handling. > - Currently the driver instructs the SPI core to use auto-suspend > but doesn't configure it. Add the necessary calls and let it > autosuspend after probe. After quick look at the driver I think it does not use autosuspend fully. It just sets master->auto_runtime_pm (so the core code will use autosuspend) but its own calls to pm_runtime_put() are regular ones. Shouldn't this be enhanced as well? > - In case the driver registration fails runtime PM needs to be > properly disabled. > > Signed-off-by: Heiner Kallweit > --- > drivers/spi/spi-s3c64xx.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c > index c4d3b06..15a6de1 100644 > --- a/drivers/spi/spi-s3c64xx.c > +++ b/drivers/spi/spi-s3c64xx.c > @@ -32,6 +32,7 @@ > #define MAX_SPI_PORTS 6 > #define S3C64XX_SPI_QUIRK_POLL (1 << 0) > #define S3C64XX_SPI_QUIRK_CS_AUTO (1 << 1) > +#define AUTOSUSPEND_TIMEOUT 2000 > > /* Registers and bit-fields */ > > @@ -1180,13 +1181,15 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) > S3C64XX_SPI_INT_TX_OVERRUN_EN | S3C64XX_SPI_INT_TX_UNDERRUN_EN, > sdd->regs + S3C64XX_SPI_INT_EN); > > + pm_runtime_set_autosuspend_delay(dev, AUTOSUSPEND_TIMEOUT); > + pm_runtime_use_autosuspend(dev); > pm_runtime_set_active(dev); > pm_runtime_enable(dev); > > ret = devm_spi_register_master(dev, master); > if (ret != 0) { > dev_err(dev, "cannot register SPI master: %d\n", ret); > - goto err3; > + goto err4; > } > > dev_dbg(dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Slaves attached\n", > @@ -1195,8 +1198,14 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) > mem_res, (FIFO_LVL_MASK(sdd) >> 1) + 1, > sdd->rx_dma.dmach, sdd->tx_dma.dmach); > > + pm_runtime_mark_last_busy(dev); > + pm_runtime_autosuspend(dev); There is a high chance that device will be suspended already at this point because pm_runtime_put() in setup. In most cases (when SPI is started) this won't do anything so we are back at first of my questions - shouldn't you update pm_runtime_put() calls? Additionally (which is not related to your patch) shouldn't we pm_runtime_get() at some point in probe() to be sure that it won't be suspended to early? > + > return 0; > > +err4: > + pm_runtime_disable(dev); > + pm_runtime_set_suspended(dev); Please separate fixes from enhancements into different patches. Best regards, Krzysztof > err3: > clk_disable_unprepare(sdd->src_clk); > err2: >