From patchwork Tue Jun 14 15:07:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 9176117 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 832CF60772 for ; Tue, 14 Jun 2016 15:10:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 759E9265B9 for ; Tue, 14 Jun 2016 15:10:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A23B27E78; Tue, 14 Jun 2016 15:10:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5685B265B9 for ; Tue, 14 Jun 2016 15:10:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bCpxj-0004Wi-0a; Tue, 14 Jun 2016 15:09:07 +0000 Received: from mail-lf0-x236.google.com ([2a00:1450:4010:c07::236]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bCpws-0003jy-AF for linux-arm-kernel@lists.infradead.org; Tue, 14 Jun 2016 15:08:15 +0000 Received: by mail-lf0-x236.google.com with SMTP id q132so68630411lfe.3 for ; Tue, 14 Jun 2016 08:07:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4NKPnyJ/yLir3jNHDbVFxwrJ9YOXsP/DP3ybBPOM24w=; b=Q7FUdRjxs0iVF89NgHOZWhuT9npFYhkvAShheTs74eT7/7XI52GVQhqHaFwwq8HTdU QhxoSF7wmttt1VDU7QBJKcyV0EjBmn8P3FaG3IO9T9BUqRwDXzwCR171xUUDTThDHrZQ 1L5kOkldXC7t4/LU5rY0axzBoiwAZfCe9UubQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4NKPnyJ/yLir3jNHDbVFxwrJ9YOXsP/DP3ybBPOM24w=; b=L4HGVh324zHKA3G6LpFPwXcrWoVp4Aj7PyJ4hk4w6o9S/sfl/5Ffx34m/qP9QUBcFN oVzeDOl14MDeUfIYB6kOgWFDs5sV7sZwx1UC8poIbcD3UH5AK3GTAkQzgAVKAdJy/fRb Dqm/Yd4NkGXDe03odlCipabPooHVUsF/oS70sa6G3e8EByUMysmK+MeOVRrT8nnMS2D+ veHlWJ83nm5+3zf4i+7Cb8n8CVfSF68KUmYIUQNN4vCofshklnxbKyLAai4LcmVCpAN8 fKEORpumfTap4MmXbcLsq+oRCAUmF2jYfUw04Pcq24aXV/Wi9WjAbpMRiJCQ7GgWt6ig MvGg== X-Gm-Message-State: ALyK8tJu0gnqQZ6kHcQ+w8KdAJ9cqScbLXHS/fmTqJ3HQv17/IfdF1VNZMKt3CTs0SgqLdy0 X-Received: by 10.25.41.197 with SMTP id p188mr2166252lfp.32.1465916872165; Tue, 14 Jun 2016 08:07:52 -0700 (PDT) Received: from localhost.localdomain (h-155-4-128-67.na.cust.bahnhof.se. [155.4.128.67]) by smtp.gmail.com with ESMTPSA id f195sm3477060lfb.47.2016.06.14.08.07.50 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 14 Jun 2016 08:07:51 -0700 (PDT) From: Ulf Hansson To: Wolfram Sang , linux-i2c@vger.kernel.org Subject: [PATCH 05/10] i2c: designware-platdrv: Fix clk gating in ->remove() Date: Tue, 14 Jun 2016 17:07:23 +0200 Message-Id: <1465916848-8207-6-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465916848-8207-1-git-send-email-ulf.hansson@linaro.org> References: <1465916848-8207-1-git-send-email-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160614_080814_634514_835BCDB8 X-CRM114-Status: GOOD ( 13.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Guodong Xu , John Stultz , Jarkko Nikula , Andy Shevchenko , Mika Westerberg , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The current approach to gate the clock in ->remove() relies on CONFIG_PM to be set, as it's expected that the call to pm_runtime_put_sync() triggers the ->runtime_suspend() callback to be invoked. Even in the case when CONFIG_PM is set, userspace may prevent runtime PM suspend via sysfs (pm_runtime_forbid()) for the device. Fix the behaviour by converting from using pm_runtime_put_sync() into directly using the clk API to manage clock gating. Let's also update the runtime PM status for the device as to reflect the state of the HW. Signed-off-by: Ulf Hansson --- drivers/i2c/busses/i2c-designware-platdrv.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index 7f67d801..4083376 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -268,11 +268,16 @@ static int dw_i2c_plat_remove(struct platform_device *pdev) i2c_dw_disable(dev); + if (!IS_ERR(dev->clk)) + clk_disable_unprepare(dev->clk); + + pm_runtime_disable(&pdev->dev); + pm_runtime_dont_use_autosuspend(&pdev->dev); if (dev->pm_runtime_disabled) pm_runtime_put_noidle(&pdev->dev); - pm_runtime_dont_use_autosuspend(&pdev->dev); - pm_runtime_put_sync(&pdev->dev); - pm_runtime_disable(&pdev->dev); + + pm_runtime_put_noidle(&pdev->dev); + pm_runtime_set_suspended(&pdev->dev); return 0; }