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: 70036 Delivered-To: patches@linaro.org Received: by 10.140.106.246 with SMTP id e109csp2098668qgf; Tue, 14 Jun 2016 08:08:03 -0700 (PDT) X-Received: by 10.25.32.85 with SMTP id g82mr2205976lfg.184.1465916872495; Tue, 14 Jun 2016 08:07:52 -0700 (PDT) Return-Path: Received: from mail-lf0-x229.google.com (mail-lf0-x229.google.com. [2a00:1450:4010:c07::229]) by mx.google.com with ESMTPS id e85si14678285lfi.18.2016.06.14.08.07.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Jun 2016 08:07:52 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::229 as permitted sender) client-ip=2a00:1450:4010:c07::229; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::229 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x229.google.com with SMTP id u74so106494064lff.2 for ; Tue, 14 Jun 2016 08:07:52 -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=c1QaY+Q3XPMFy+NUyui4R33PJ0XqYWZDI7Re55jTRemi/WeCu/N4AliqK9iJvnewmj PUd5Dja/M2JsRx7GK69fgBlmBfH1RGYUHAt93h4QjoxGp1Ah3L1Qjz+7XeyjgOvXxQ+f eF3wODGzv1KO6fTJDccYzckyyT5/g2XWSHdSPA3EPeGcP1jNvBY1J8ozqU5oeeiUjqFx PTR7ntBC/wdGA2NJDFWclD5qgo1Z2pKO4QhKU7wLfMkxnM3e+55uj5Hdget7YbwN3WIi jh8yVkySijHHe5Z+dMThul+loqCtrrXoAMWYd2cokv0t3EXUrSmn+RJcIFk+mP6IsMIB Al6Q== X-Gm-Message-State: ALyK8tL6NfTjkWPCxP5Zpbq7ABmZExBDqI0J0CZDePcHS37GZkx6VkHCGhNP3cpGo1NRWu7ki7g= X-Received: by 10.25.41.197 with SMTP id p188mr2166252lfp.32.1465916872165; Tue, 14 Jun 2016 08:07:52 -0700 (PDT) Return-Path: 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 Cc: Jarkko Nikula , Andy Shevchenko , Mika Westerberg , John Stultz , Guodong Xu , linux-arm-kernel@lists.infradead.org, Ulf Hansson 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> 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(-) -- 1.9.1 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; }