Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5591898imm; Tue, 12 Jun 2018 10:05:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI3Qz5LCV/an30t467Y4stTL+8BqKyvDiecArA0+pWdzd6Zst7F4t9INZuzzU7J/EBHDXpJ X-Received: by 2002:a63:9a52:: with SMTP id e18-v6mr1053700pgo.188.1528823121953; Tue, 12 Jun 2018 10:05:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528823121; cv=none; d=google.com; s=arc-20160816; b=JbCPtbpjXS3A9XE+YfCudy7TAPfiADMwLHdoPHyNHUuwmmjmQI5LvPF77t0duo70KI oxhJ+azjLTvT46o8UpAx81hw8IsKhhkABgp6CdbmNfy63T4Yz2Rnsr8oJ7k+fygZJ13T fa0CIN7rlMzw/NSMmNUnmypL+fWOHPfmnXhcMi0Vs5S6bmKZHyPBrt7tOPKvR0odN+5o 6hrPPsdUSyX2HQFNpVBEbsJNaSuCA6ZWMfxZ+sW1LjIyCoZ32f9bMp/MxEaGin48jHiV y6lMOLMLhahTyap1/rsrXN8i8MvEN9lIrlUM6YZA3lADohbOaxE+CcopEANODp5U3DEp Y6MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=L6VPrIntnDDelihPTMaXW219DVnzqec6LwvDm9S4VDI=; b=Rt+cxV5kMcB+3xhhlKrigK7a7+QLxVcyHvDaUYDNjKSd1hgqAbhH1uyBtxnhqVrQWS zcRh+FqvS1wbULMnJ4IQ1ttwkDeKdxCnxmoxEOg5xz3cRQ0BJtnE13Ro15vo0CDf9S1p LiWh2M2nlTclnEQ8Yj40EZbnx+P+ddeSJ0LfWhulouuSXGMwPZ0r18DJLwmCJceGfdml q4svR7B7ARmKXyx5Y/dH0gWf4bvKi/wRYjNsMAdgRyLZk4ZYXdZCyL6kOxm3KoWzl8KU +77mb+t7QnOzw8t6nL/b7fAB58pWlvU8DttsdB6We+Q2NQgmtEWkVi53fev2giF4CUyc dPSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0CP2YqKd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r59-v6si487260plb.314.2018.06.12.10.05.07; Tue, 12 Jun 2018 10:05:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0CP2YqKd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934999AbeFLQwl (ORCPT + 99 others); Tue, 12 Jun 2018 12:52:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:47804 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933748AbeFLQwj (ORCPT ); Tue, 12 Jun 2018 12:52:39 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2B874208B7; Tue, 12 Jun 2018 16:52:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1528822358; bh=gMXUWmCTZZLdTKVuHeKQUgA+CgqDW/31abOciPmPt5w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0CP2YqKd3BUrBwASCLwGuK8sjjfE2Q8mmKPLDBck+5eawCznTh2Pu5oqGNSdU/UiS xsnJQUwwtjfbEllNpOAU0RONo/7q0GFt3SDm9a4I0S21S1+I15FO30ByUBbK7Khv9/ DtPzSJ7GwCtLhgFW4DAaWt9JwXMDLYN7L+XCGEe0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sonny Rao , Enric Balletbo i Serra , Jason Gunthorpe , Jarkko Sakkinen , James Morris Subject: [PATCH 4.4 01/24] tpm: do not suspend/resume if power stays on Date: Tue, 12 Jun 2018 18:51:45 +0200 Message-Id: <20180612164816.651225293@linuxfoundation.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180612164816.587001852@linuxfoundation.org> References: <20180612164816.587001852@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Enric Balletbo i Serra commit b5d0ebc99bf5d0801a5ecbe958caa3d68b8eaee8 upstream. The suspend/resume behavior of the TPM can be controlled by setting "powered-while-suspended" in the DTS. This is useful for the cases when hardware does not power-off the TPM. Signed-off-by: Sonny Rao Signed-off-by: Enric Balletbo i Serra Reviewed-by: Jason Gunthorpe Reviewed-by: Jarkko Sakkinen Signed-off-by: Jarkko Sakkinen Signed-off-by: James Morris Signed-off-by: Greg Kroah-Hartman --- drivers/char/tpm/tpm-chip.c | 13 +++++++++++++ drivers/char/tpm/tpm-interface.c | 3 +++ drivers/char/tpm/tpm.h | 1 + 3 files changed, 17 insertions(+) --- a/drivers/char/tpm/tpm-chip.c +++ b/drivers/char/tpm/tpm-chip.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "tpm.h" #include "tpm_eventlog.h" @@ -324,8 +325,20 @@ static void tpm1_chip_unregister(struct */ int tpm_chip_register(struct tpm_chip *chip) { +#ifdef CONFIG_OF + struct device_node *np; +#endif int rc; +#ifdef CONFIG_OF + np = of_find_node_by_name(NULL, "vtpm"); + if (np) { + if (of_property_read_bool(np, "powered-while-suspended")) + chip->flags |= TPM_CHIP_FLAG_ALWAYS_POWERED; + } + of_node_put(np); +#endif + rc = tpm1_chip_register(chip); if (rc) return rc; --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c @@ -931,6 +931,9 @@ int tpm_pm_suspend(struct device *dev) if (chip == NULL) return -ENODEV; + if (chip->flags & TPM_CHIP_FLAG_ALWAYS_POWERED) + return 0; + if (chip->flags & TPM_CHIP_FLAG_TPM2) { tpm2_shutdown(chip, TPM2_SU_STATE); return 0; --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h @@ -168,6 +168,7 @@ struct tpm_vendor_specific { enum tpm_chip_flags { TPM_CHIP_FLAG_REGISTERED = BIT(0), TPM_CHIP_FLAG_TPM2 = BIT(1), + TPM_CHIP_FLAG_ALWAYS_POWERED = BIT(5), }; struct tpm_chip {