From patchwork Mon Aug 12 22:36:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 11090971 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A0F8313AC for ; Mon, 12 Aug 2019 22:36:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91C5327F90 for ; Mon, 12 Aug 2019 22:36:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8636A28384; Mon, 12 Aug 2019 22:36:52 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 1E09927F90 for ; Mon, 12 Aug 2019 22:36:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727116AbfHLWg0 (ORCPT ); Mon, 12 Aug 2019 18:36:26 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:33195 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726488AbfHLWg0 (ORCPT ); Mon, 12 Aug 2019 18:36:26 -0400 Received: by mail-pg1-f194.google.com with SMTP id n190so9385547pgn.0 for ; Mon, 12 Aug 2019 15:36:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DEVqEnZhQhVV35dLTE4fV+ZJ16fecFLxF4vVFu1o1hU=; b=BfJxQ05nyCUD2yykz83BYfJcO7SjUsLU4oEJou/mnS22Lte6HruK8O6ckupd9hUxw7 lUSbPWVbmOP2oeJbyjDnPoYCMKQpniyn/DegbKcbIWj+YwPj+9QuiQnm4VmvFL5KqLey KaKTAoNHbMYPrUFlRM+L1RzmsaJjWXSrNC7RI= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=DEVqEnZhQhVV35dLTE4fV+ZJ16fecFLxF4vVFu1o1hU=; b=kDKiqh1yxwEmdyDQJVTqd4SC0IK29j0NrjZ4+731dja3cjDlqUx4OWzvOxJOqfTSkx ypXrLbQgpJWF5mLzLIi2FEB5PxjNIzyrHTc9OY35Cs4F1XvH3Mbsq+aPevJ86NMDEYS5 YsYtpZcCcq3X52AJr4BEKO0ZBKrDHCarGXD0C6cI7nFnbquhP7IWjiDyAe+snDp+A1Nr oAu09xLWmPFLi50JXEMfBlIG4MEx7EMZL0Asg+qmkGFmg8RY5I9Jd1SNNKzkXxm6hTbF 97wi0ccNJZNc8t+/SuIGR2wfnruqEY3h4tEy0BRc5fQIxQD4l2chjnM8TmVun2QDPM1Y v86A== X-Gm-Message-State: APjAAAXN4IHwPsZZXdz83ioIDMGt2SaT/8MBS55snoOFZLeKdbJNSZr4 ybraoM6Vn2+zou9TSzIwtM6zdw== X-Google-Smtp-Source: APXvYqz86X3o0dGJ23vCO1fyItdzE6+jO7gjy9ZsDTYcnR/UMFXR30FC+/Cmr/ihjD9Gny74O6ywfw== X-Received: by 2002:a62:8688:: with SMTP id x130mr9714539pfd.162.1565649385400; Mon, 12 Aug 2019 15:36:25 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id b6sm93911594pgq.26.2019.08.12.15.36.24 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 12 Aug 2019 15:36:24 -0700 (PDT) From: Stephen Boyd To: Peter Huewe , Jarkko Sakkinen Cc: linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org, Andrey Pronin , Duncan Laurie , Jason Gunthorpe , Arnd Bergmann , Greg Kroah-Hartman , Guenter Roeck , Alexander Steffen Subject: [PATCH v4 1/6] tpm: Add a flag to indicate TPM power is managed by firmware Date: Mon, 12 Aug 2019 15:36:17 -0700 Message-Id: <20190812223622.73297-2-swboyd@chromium.org> X-Mailer: git-send-email 2.23.0.rc1.153.gdeed80330f-goog In-Reply-To: <20190812223622.73297-1-swboyd@chromium.org> References: <20190812223622.73297-1-swboyd@chromium.org> MIME-Version: 1.0 Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On some platforms, the TPM power is managed by firmware and therefore we don't need to stop the TPM on suspend when going to a light version of suspend such as S0ix ("freeze" suspend state). Add a chip flag, TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED, to indicate this so that certain platforms can probe for the usage of this light suspend and avoid touching the TPM state across suspend/resume. Cc: Andrey Pronin Cc: Duncan Laurie Cc: Jason Gunthorpe Cc: Arnd Bergmann Cc: Greg Kroah-Hartman Cc: Guenter Roeck Cc: Alexander Steffen Signed-off-by: Stephen Boyd Reviewed-by: Jarkko Sakkinen --- drivers/char/tpm/tpm-interface.c | 8 +++++++- drivers/char/tpm/tpm.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c index 1b4f95c13e00..0b3def8e8186 100644 --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -395,7 +396,11 @@ int tpm_pm_suspend(struct device *dev) return -ENODEV; if (chip->flags & TPM_CHIP_FLAG_ALWAYS_POWERED) - return 0; + goto suspended; + + if ((chip->flags & TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED) && + !pm_suspend_via_firmware()) + goto suspended; if (!tpm_chip_start(chip)) { if (chip->flags & TPM_CHIP_FLAG_TPM2) @@ -406,6 +411,7 @@ int tpm_pm_suspend(struct device *dev) tpm_chip_stop(chip); } +suspended: return rc; } EXPORT_SYMBOL_GPL(tpm_pm_suspend); diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index e503ffc3aa39..28f73331aa2e 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h @@ -162,6 +162,7 @@ enum tpm_chip_flags { TPM_CHIP_FLAG_VIRTUAL = BIT(3), TPM_CHIP_FLAG_HAVE_TIMEOUTS = BIT(4), TPM_CHIP_FLAG_ALWAYS_POWERED = BIT(5), + TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED = BIT(6), }; #define to_tpm_chip(d) container_of(d, struct tpm_chip, dev)