From patchwork Mon Aug 7 12:40:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffy Chen X-Patchwork-Id: 9885315 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 AF90A603B4 for ; Mon, 7 Aug 2017 12:42:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FF2728503 for ; Mon, 7 Aug 2017 12:42:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 94452285DA; Mon, 7 Aug 2017 12:42:09 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 259F328503 for ; Mon, 7 Aug 2017 12:42:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=dASt3+JRDpK2OmYars9sX2y6RkiMsgh23v7+v3a8XYw=; b=WnhQ55qf/VYHAv60yM15Yr2Ej8 GEUOjIkmbWfTl5xS7GHPFd4mEHLj23w7/2Ne3TieyN966QsYlo4yCf6GDv19dbsT1rOrTjcCPZ3tM /NCaCbT5D37/VbKf+aAbn5KX2RpehA3Lqn0aoTkhak1kzBaNl7860SMkNPN1bbERhlgYLMHzC6Lo6 bG0gP3tnQB2aKwxROCN6kA/ootcI5H9cQIOiHegqwIfmTEvn/i3EiV8nBgEX645Kmlc7FR8NQECeU 9nhVGENZGvmBFcMvAt+JLoGVj/Nr8fO52AkdUldXVaz5sRr7kTyqdIn0ZrtUKTtk+rlYA7dgFheyq MCpQWB7w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dehMG-00015W-1M; Mon, 07 Aug 2017 12:42:08 +0000 Received: from regular1.263xmail.com ([211.150.99.130]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dehLR-0008FQ-4G; Mon, 07 Aug 2017 12:41:23 +0000 Received: from jeffy.chen?rock-chips.com (unknown [192.168.167.192]) by regular1.263xmail.com (Postfix) with ESMTP id B6F7FB10D; Mon, 7 Aug 2017 20:40:51 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id D225236E; Mon, 7 Aug 2017 20:40:48 +0800 (CST) X-RL-SENDER: jeffy.chen@rock-chips.com X-FST-TO: linux-kernel@vger.kernel.org X-SENDER-IP: 103.29.142.67 X-LOGIN-NAME: jeffy.chen@rock-chips.com X-UNIQUE-TAG: <85ee12c8caf0682b3e06f40293cd18dc> X-ATTACHMENT-NUM: 0 X-SENDER: cjf@rock-chips.com X-DNS-TYPE: 0 Received: from localhost (unknown [103.29.142.67]) by smtp.263.net (Postfix) whith ESMTP id 2900430L3IH; Mon, 07 Aug 2017 20:40:52 +0800 (CST) From: Jeffy Chen To: linux-kernel@vger.kernel.org, broonie@kernel.org Subject: [PATCH 3/3] spi: rockchip: Fix clock handling in suspend/resume Date: Mon, 7 Aug 2017 20:40:20 +0800 Message-Id: <1502109620-26813-4-git-send-email-jeffy.chen@rock-chips.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1502109620-26813-1-git-send-email-jeffy.chen@rock-chips.com> References: <1502109620-26813-1-git-send-email-jeffy.chen@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170807_054118_215048_E7DCF066 X-CRM114-Status: UNSURE ( 8.08 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: briannorris@chromium.org, heiko@sntech.de, Jeffy Chen , dianders@chromium.org, linux-spi@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The runtime suspend callback might be called by pm domain framework at suspend_noirq stage. It would try to disable the clocks which already been disabled by rockchip_spi_suspend. Call pm_runtime_force_suspend/pm_runtime_force_resume when suspend/resume to avoid that. Signed-off-by: Jeffy Chen --- drivers/spi/spi-rockchip.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index a75fd9b..34f6440 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -846,10 +846,9 @@ static int rockchip_spi_suspend(struct device *dev) if (ret < 0) return ret; - if (!pm_runtime_suspended(dev)) { - clk_disable_unprepare(rs->spiclk); - clk_disable_unprepare(rs->apb_pclk); - } + ret = pm_runtime_force_suspend(dev); + if (ret < 0) + return ret; pinctrl_pm_select_sleep_state(dev); @@ -864,17 +863,9 @@ static int rockchip_spi_resume(struct device *dev) pinctrl_pm_select_default_state(dev); - if (!pm_runtime_suspended(dev)) { - ret = clk_prepare_enable(rs->apb_pclk); - if (ret < 0) - return ret; - - ret = clk_prepare_enable(rs->spiclk); - if (ret < 0) { - clk_disable_unprepare(rs->apb_pclk); - return ret; - } - } + ret = pm_runtime_force_resume(dev); + if (ret < 0) + return ret; ret = spi_master_resume(rs->master); if (ret < 0) {