From patchwork Fri Jan 27 06:32:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pramod Gurav X-Patchwork-Id: 92556 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp96276qgi; Thu, 26 Jan 2017 22:32:28 -0800 (PST) X-Received: by 10.99.67.1 with SMTP id q1mr7838732pga.210.1485498748018; Thu, 26 Jan 2017 22:32:28 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10si3549467plj.35.2017.01.26.22.32.27; Thu, 26 Jan 2017 22:32:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754018AbdA0GcL (ORCPT + 9 others); Fri, 27 Jan 2017 01:32:11 -0500 Received: from mail-pf0-f173.google.com ([209.85.192.173]:34395 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753898AbdA0GcK (ORCPT ); Fri, 27 Jan 2017 01:32:10 -0500 Received: by mail-pf0-f173.google.com with SMTP id e4so70987986pfg.1 for ; Thu, 26 Jan 2017 22:32:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=nasBhU7sC5JWt/UVe2iL/35g/wutzNvkB7CjlbH2M6A=; b=Ywi3E5WDdK94b2Zf/H5zEX4re1SdM/5T16BFFY0LdcP5iZJjZxwWW1G0rLGJxtgvv7 nbJkpy36dRKgoHKX7wkMfPNEMLiztsb5w4qoXi5N85c2g9dAZsYLWL4cngwKp99hugbE A2+qHuExiUEWTn9//uj6YmLSwiUywCPgJvU4A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=nasBhU7sC5JWt/UVe2iL/35g/wutzNvkB7CjlbH2M6A=; b=LDvNPQFjp/kHFuLIQvWeKKnKEu5LK/2w0ovFk9LYC/fqZou2iVs8g3W5MwkLQ+d6zU T49pjLVmCzJtXM2OMyAaD8dYCmTglYQEvFUvbR6vqhuclylX2ZjTUG6dKATcMuQwir9t dTwKHRfNa0q73WUgO6epythkhDOmePLJ5NWGGd4NHdE6Wdn1yfNp6UbqYHGxeHfz48mt iOcJ1vxaAHjPE7hGT9pj/foCiSzSGrj9x7mWZWz9NlUP3rDVG1PEPMS36aj8wbzs1Gtb us4N/jC38kOonC8MCUokpuZDottcLtqDOzaPYYDC8f6PXxW36Hn2/EOIymHTbFphqhsj PpPg== X-Gm-Message-State: AIkVDXIskJFEX9mqfxuV8eTXmTd1NXaa8jVIykqZVFEH5FmrE8LigJZk18ZWfEmranybfeRZ X-Received: by 10.98.18.75 with SMTP id a72mr7356952pfj.16.1485498729609; Thu, 26 Jan 2017 22:32:09 -0800 (PST) Received: from blr-ubuntu-56.ap.qualcomm.com ([202.46.23.61]) by smtp.gmail.com with ESMTPSA id b75sm7847411pfb.90.2017.01.26.22.32.06 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Jan 2017 22:32:09 -0800 (PST) From: Pramod Gurav To: broonie@kernel.org, linux-spi@vger.kernel.org Cc: andy.gross@linaro.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Pramod Gurav Subject: [PATCH] spi: qup: Fix runtime and system PM callbacks. Date: Fri, 27 Jan 2017 12:02:01 +0530 Message-Id: <20170127063201.13529-1-pramod.gurav@linaro.org> X-Mailer: git-send-email 2.10.2 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The SPI clocks were being turned on every suspend/resume cycle. This was increamenting the prepare/enable count after every resume. Fix the same. Signed-off-by: Pramod Gurav --- Tested on db410c drivers/spi/spi-qup.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) -- 2.10.2 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c index 1bfa889..a9731e8 100644 --- a/drivers/spi/spi-qup.c +++ b/drivers/spi/spi-qup.c @@ -956,8 +956,10 @@ static int spi_qup_pm_resume_runtime(struct device *device) return ret; ret = clk_prepare_enable(controller->cclk); - if (ret) + if (ret) { + clk_disable_unprepare(controller->iclk); return ret; + } /* Disable clocks auto gaiting */ config = readl_relaxed(controller->base + QUP_CONFIG); @@ -983,8 +985,7 @@ static int spi_qup_suspend(struct device *device) return ret; if (!pm_runtime_suspended(device)) { - clk_disable_unprepare(controller->cclk); - clk_disable_unprepare(controller->iclk); + pm_runtime_put(device); } return 0; } @@ -995,18 +996,17 @@ static int spi_qup_resume(struct device *device) struct spi_qup *controller = spi_master_get_devdata(master); int ret; - ret = clk_prepare_enable(controller->iclk); - if (ret) - return ret; - - ret = clk_prepare_enable(controller->cclk); - if (ret) + ret = pm_runtime_get_sync(device); + if (ret < 0) { + dev_err(device, "pm runtime failed in resume\n"); return ret; + } ret = spi_qup_set_state(controller, QUP_STATE_RESET); if (ret) return ret; + pm_runtime_put(device); return spi_master_resume(master); } #endif /* CONFIG_PM_SLEEP */