From patchwork Thu Sep 3 20:39:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 7119281 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4E9BFBEEC1 for ; Thu, 3 Sep 2015 20:43:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6153E20801 for ; Thu, 3 Sep 2015 20:43:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 524F720809 for ; Thu, 3 Sep 2015 20:43:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753599AbbICUnR (ORCPT ); Thu, 3 Sep 2015 16:43:17 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:34185 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751505AbbICUnQ (ORCPT ); Thu, 3 Sep 2015 16:43:16 -0400 Received: by wicfx3 with SMTP id fx3so2670807wic.1 for ; Thu, 03 Sep 2015 13:43:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; bh=vp3Jmi8fPEozw6xqaF2/5YdOZuPjRlBYB0NfIrfZx3g=; b=IeVL4NaCfpv9qUMAborg1/XVz2S4sRxq7IiQoXAiHHXCz+NYGI22sfR1TOcZ9jeyYX rRkDjJkhOgZq2dQxJyL+vm6NcwUkQOJWns4lp44K7bFVeKptOhyXc5pHt3qDC3p7ufIQ N6mKOg95NPpzH1zjyKNtmAdMQdt0NWRdJ4mQD7KJo53U0kg6OOTmv3UqzZPGy3+TTOYm bk5hdLLqdWdrX6NY6lSKRYUnpXOZSD74Kve7+QRd2WeR7h0GUPau0qDTTbGV/N3wJS5L yyLOOPWAMOwtSMFzBpJ4iPLzQRFZgpddkU+64l04sdGnxNGaK9Oq9E8j/ZZfcu5L2HN+ cAyg== X-Received: by 10.194.112.3 with SMTP id im3mr54916623wjb.54.1441312995171; Thu, 03 Sep 2015 13:43:15 -0700 (PDT) Received: from ?IPv6:2003:62:5f33:d300:bd9c:1f82:410c:b71c? (p200300625F33D300BD9C1F82410CB71C.dip0.t-ipconnect.de. [2003:62:5f33:d300:bd9c:1f82:410c:b71c]) by smtp.googlemail.com with ESMTPSA id bq7sm21557wjc.31.2015.09.03.13.43.14 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Sep 2015 13:43:14 -0700 (PDT) Message-ID: <55E8B008.50508@gmail.com> Date: Thu, 03 Sep 2015 22:39:36 +0200 From: Heiner Kallweit User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Mark Brown CC: Krzysztof Kozlowski , "linux-spi@vger.kernel.org" Subject: [PATCH 2/4 RESEND v2] spi: s3c64xx: extend driver to make full use of runtime PM autosuspend Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Extend the driver to make full use of runtime PM autosuspend. Before only the SPI core was instructed to use autosuspend by setting master->auto_runtime_pm. Nevertheless due to the missing pm_runtime_use_autosuspend call autosuspend wasn't active. Signed-off-by: Heiner Kallweit Reviewed-by: Krzysztof Kozlowski --- Changed: - Let driver autosuspend also after leaving s3c64xx_spi_setup - Enable runtime PM earlier in s3c64xx_spi_probe and prevent suspending in the relevant part of probe v2: - Don't init runtime PM before the driver has a reference to the clocks drivers/spi/spi-s3c64xx.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 8a6ab88..d117fa6 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 */ @@ -859,13 +860,15 @@ static int s3c64xx_spi_setup(struct spi_device *spi) } } - pm_runtime_put(&sdd->pdev->dev); + pm_runtime_mark_last_busy(&sdd->pdev->dev); + pm_runtime_put_autosuspend(&sdd->pdev->dev); if (!(sdd->port_conf->quirks & S3C64XX_SPI_QUIRK_CS_AUTO)) writel(S3C64XX_SPI_SLAVE_SIG_INACT, sdd->regs + S3C64XX_SPI_SLAVE_SEL); return 0; setup_exit: - pm_runtime_put(&sdd->pdev->dev); + pm_runtime_mark_last_busy(&sdd->pdev->dev); + pm_runtime_put_autosuspend(&sdd->pdev->dev); /* setup() returns with device de-selected */ if (!(sdd->port_conf->quirks & S3C64XX_SPI_QUIRK_CS_AUTO)) writel(S3C64XX_SPI_SLAVE_SIG_INACT, sdd->regs + S3C64XX_SPI_SLAVE_SEL); @@ -1162,6 +1165,12 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) goto err2; } + pm_runtime_set_autosuspend_delay(&pdev->dev, AUTOSUSPEND_TIMEOUT); + pm_runtime_use_autosuspend(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + pm_runtime_get_sync(&pdev->dev); + /* Setup Deufult Mode */ s3c64xx_spi_hwinit(sdd, sdd->port_id); @@ -1180,13 +1189,10 @@ 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_active(&pdev->dev); - pm_runtime_enable(&pdev->dev); - ret = devm_spi_register_master(&pdev->dev, master); if (ret != 0) { dev_err(&pdev->dev, "cannot register SPI master: %d\n", ret); - goto err4; + goto err3; } dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Slaves attached\n", @@ -1195,12 +1201,16 @@ 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(&pdev->dev); + pm_runtime_put_autosuspend(&pdev->dev); + return 0; -err4: +err3: + pm_runtime_put_noidle(&pdev->dev); pm_runtime_disable(&pdev->dev); pm_runtime_set_suspended(&pdev->dev); -err3: + clk_disable_unprepare(sdd->src_clk); err2: clk_disable_unprepare(sdd->clk);