From patchwork Sun Mar 5 23:53:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Winkler, Tomas" X-Patchwork-Id: 9604829 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 45CA6604E2 for ; Sun, 5 Mar 2017 23:54:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35C9E2236A for ; Sun, 5 Mar 2017 23:54:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 28E7527D5D; Sun, 5 Mar 2017 23:54:18 +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 9C3C327C0B for ; Sun, 5 Mar 2017 23:54:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752443AbdCEXyP (ORCPT ); Sun, 5 Mar 2017 18:54:15 -0500 Received: from mga04.intel.com ([192.55.52.120]:45128 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752442AbdCEXyP (ORCPT ); Sun, 5 Mar 2017 18:54:15 -0500 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Mar 2017 15:54:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,250,1484035200"; d="scan'208";a="1138255412" Received: from twinkler-lnx.jer.intel.com ([10.12.87.167]) by fmsmga002.fm.intel.com with ESMTP; 05 Mar 2017 15:54:12 -0800 From: Tomas Winkler To: tpmdd-devel@lists.sourceforge.net, Jarkko Sakkinen , Jason Gunthorpe Cc: linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Tomas Winkler Subject: [PATCH] tpm/tpm_crb: enter the low power state upon device suspend Date: Mon, 6 Mar 2017 01:53:35 +0200 Message-Id: <1488758015-12681-1-git-send-email-tomas.winkler@intel.com> X-Mailer: git-send-email 2.7.4 Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This fix enables a platform to enter the idle state (suspend-to-idle) The driver needs to request explicitly go_idle upon completion from the pm suspend handler. The runtime pm is disabled on suspend during prepare state by calling pm_runtime_get_noresume, hence we cannot relay on runtime pm to leave the device in low power state. Symmetrically cmdReady is called upon resume. Signed-off-by: Tomas Winkler Tested-by: Jarkko Sakkinen Reviewed-by: Jarkko Sakkinen --- drivers/char/tpm/tpm_crb.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c index 86f355b6df1d..d8dfff0fdfce 100644 --- a/drivers/char/tpm/tpm_crb.c +++ b/drivers/char/tpm/tpm_crb.c @@ -479,10 +479,33 @@ static int crb_pm_runtime_resume(struct device *dev) return crb_cmd_ready(dev, priv); } + +static int crb_pm_suspend(struct device *dev) +{ + int ret; + + ret = tpm_pm_suspend(dev); + if (ret) + return ret; + + return crb_pm_runtime_suspend(dev); +} + +static int crb_pm_resume(struct device *dev) +{ + int ret; + + ret = crb_pm_runtime_resume(dev); + if (ret) + return ret; + + return tpm_pm_resume(dev); +} + #endif /* CONFIG_PM */ static const struct dev_pm_ops crb_pm = { - SET_SYSTEM_SLEEP_PM_OPS(tpm_pm_suspend, tpm_pm_resume) + SET_SYSTEM_SLEEP_PM_OPS(crb_pm_suspend, crb_pm_resume) SET_RUNTIME_PM_OPS(crb_pm_runtime_suspend, crb_pm_runtime_resume, NULL) };