From patchwork Thu Aug 25 12:33:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 9299315 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 8A71560757 for ; Thu, 25 Aug 2016 12:34:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B9C92929D for ; Thu, 25 Aug 2016 12:34:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6EC272929F; Thu, 25 Aug 2016 12:34:02 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B81832929A for ; Thu, 25 Aug 2016 12:34:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758857AbcHYMdl (ORCPT ); Thu, 25 Aug 2016 08:33:41 -0400 Received: from foss.arm.com ([217.140.101.70]:57350 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754281AbcHYMdj (ORCPT ); Thu, 25 Aug 2016 08:33:39 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A42E426B; Thu, 25 Aug 2016 05:35:18 -0700 (PDT) Received: from e107155-lin.cambridge.arm.com (unknown [10.1.210.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 071FF3F220; Thu, 25 Aug 2016 05:33:36 -0700 (PDT) From: Sudeep Holla To: linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org Cc: Sudeep Holla , Andy Gross , David Brown , Mark Brown Subject: [PATCH] spi: qup: skip clk_disable_unprepare if the device is already runtime suspended Date: Thu, 25 Aug 2016 13:33:28 +0100 Message-Id: <1472128408-7231-1-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the spi device is already runtime suspended, if spi_qup_suspend is executed during suspend-to-idle or suspend-to-ram it will result in the following splat: WARNING: CPU: 3 PID: 1593 at drivers/clk/clk.c:476 clk_core_unprepare+0x80/0x90 Modules linked in: CPU: 3 PID: 1593 Comm: bash Tainted: G W 4.8.0-rc3 #14 Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT) PC is at clk_core_unprepare+0x80/0x90 LR is at clk_unprepare+0x28/0x40 pc : [] lr : [] pstate: 60000145 Call trace: clk_core_unprepare+0x80/0x90 spi_qup_suspend+0x68/0x90 platform_pm_suspend+0x24/0x68 dpm_run_callback.isra.7+0x1c/0x70 __device_suspend+0xf4/0x298 dpm_suspend+0x10c/0x228 dpm_suspend_start+0x68/0x78 suspend_devices_and_enter+0xb8/0x460 pm_suspend+0x1ec/0x240 state_store+0x84/0xf8 kobj_attr_store+0x14/0x28 sysfs_kf_write+0x48/0x58 kernfs_fop_write+0x15c/0x1f8 __vfs_write+0x1c/0x100 vfs_write+0x9c/0x1b8 SyS_write+0x44/0xa0 el0_svc_naked+0x24/0x28 This patch fixes the issue by executing clk_disable_unprepare conditionally in spi_qup_suspend. Cc: Andy Gross Cc: David Brown Cc: Mark Brown Signed-off-by: Sudeep Holla Tested-by: Andy Gross --- drivers/spi/spi-qup.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c index c338ef1136f6..a047e9882da8 100644 --- a/drivers/spi/spi-qup.c +++ b/drivers/spi/spi-qup.c @@ -982,8 +982,10 @@ static int spi_qup_suspend(struct device *device) if (ret) return ret; - clk_disable_unprepare(controller->cclk); - clk_disable_unprepare(controller->iclk); + if (!pm_runtime_suspended(device)) { + clk_disable_unprepare(controller->cclk); + clk_disable_unprepare(controller->iclk); + } return 0; }