From patchwork Wed Aug 28 08:21:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 11118177 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AA858112C for ; Wed, 28 Aug 2019 08:22:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8B4CC22CF8 for ; Wed, 28 Aug 2019 08:22:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="PrHtPwM6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726408AbfH1IWM (ORCPT ); Wed, 28 Aug 2019 04:22:12 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:41562 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726400AbfH1IVy (ORCPT ); Wed, 28 Aug 2019 04:21:54 -0400 Received: by mail-pl1-f195.google.com with SMTP id m9so875397pls.8 for ; Wed, 28 Aug 2019 01:21:54 -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=C+xDpWo2oT08ou9fvGrkptCYBMIqSmZRdTRAyh6265I=; b=PrHtPwM6tq7xoo1QWNWyhW8OOQJaq69j7oe0TIWZQrJLHUxb57TWrvr+EyPCpSjxcz x+7xMbyAzfpt877DerOKPBpQkFO2nQUhiJPsNAqSqZB/G6E1+eA0zA0sTsocG9NRX4lh w5BTT4jgcEDX+ObY/F5s2cdIssgj8YhHJ6HSk= 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=C+xDpWo2oT08ou9fvGrkptCYBMIqSmZRdTRAyh6265I=; b=e94Fish5gg564eVaMvTAKucVG/usII0j63axV6eDUXR/H/WT85B0ZJm9U+fvhRhNDb c4SFphEDwQ8VV49tL8tr8vjH/Z2pTSamsM4xBRsW7j0LZxAKH91btFr55cPnQ5+GwCVJ qr1t6YdVWi7XtgZ14iOgka/QzUPn52kzUs8z7RYcqTBHMegzoWNspXREC0DEtRvk6pRB xqItXv1bHRjUFlIKZYOjdnwTWMEqBPlVvp7B2pVhnHZNTXFeHvMun3zFFSith+sYw/yl HLqmKSdp5YI6LjCREt8qF046ozkvIWJMwUL1GjwR+r1BT/gIpzUFY+as0v5lWExEuTP1 W6xA== X-Gm-Message-State: APjAAAWUbZuJgJ59fepylNRpSdm2cxG0zf3dOMSIy5yABTA7PbdHASnC lu6y03tvZ2E7aQ+yAGtbzZwwdA== X-Google-Smtp-Source: APXvYqyS/9fSKUn7Cu6qNhd0MavSj9l+c5ef+ep/CtdNuSaGiQS/h7VtXA9ix52t3bQb/5XrVpJVew== X-Received: by 2002:a17:902:a714:: with SMTP id w20mr3021258plq.135.1566980513957; Wed, 28 Aug 2019 01:21:53 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id y10sm1296959pjp.27.2019.08.28.01.21.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2019 01:21:53 -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 , Heiko Stuebner Subject: [PATCH v5 2/4] tpm: Add a flag to indicate TPM power is managed by firmware Date: Wed, 28 Aug 2019 01:21:48 -0700 Message-Id: <20190828082150.42194-3-swboyd@chromium.org> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog In-Reply-To: <20190828082150.42194-1-swboyd@chromium.org> References: <20190828082150.42194-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 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 Cc: Heiko Stuebner Reviewed-by: Jarkko Sakkinen Signed-off-by: Stephen Boyd --- 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)