Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1145861rwr; Wed, 26 Apr 2023 10:37:57 -0700 (PDT) X-Google-Smtp-Source: AKy350ZEdC9F8de//wMx0OXvGFFL8Tcsgee5iEw54mL9WdKo4Lqlr87HwQzIuwzXGBxFWC2IcacF X-Received: by 2002:a05:6a21:3389:b0:ef:a31b:af8b with SMTP id yy9-20020a056a21338900b000efa31baf8bmr27828503pzb.24.1682530677061; Wed, 26 Apr 2023 10:37:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682530677; cv=none; d=google.com; s=arc-20160816; b=vQ6nZ7bfSrC5yiicHu99xTR6OSvrl+ZQK7aGHfSxeW+PpQQUNlbcWH8haGos1BfPnF tZqW9k63Y17lDop57piN+vQoZe/BixHPqEL6uLyIqPu2QflDs29ubWIMwIxCVvyfrMF9 KE8QCyf1ISgLLNMlw2OV9RV1M3/UtMiPCITVpcXDQ/FVsuuC2NY/HlNPm1hCXd2fxqPn rhN0xc0yMTfVNHmg3xWrnK2SeqjrK+0kycHZBlC9721qO3ZjtZ3FeHi1PydS4xeFW2j2 tnpSu2yTBf0V8U9sarWIY9w2GYIAZTUWHyD4C1EMFE3+XJ7MM6s0vf2Ioj1qf0/xBqmS bbyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+DhpUvpRVvIdG5OkeY02GObKTJhq87BnOC+97eKwYCA=; b=nuK3bZqSoXRF3ghGYNzdaRZUuZ21hx6WYdbU8iF45GIilO6KsTS6jitikWqI8/ckRP VsCq9KZgmcp+DQEOJ9fCKhac0SFcbU0N+6pPzFZqP8YlIymxO1gF5epLPuN/iZhg+qEB SqNtL1bixM8wAg0CeeeonqgWN8D2xQQNtwerTLRfyi1MBtT102G8GkaioHplRVRCp6Dh LZBRpaKrxkJCC5VUsfW0/Nyxdk5ZYmXV4cx6ejBNL0Kd5u/TI5QVNeaffsxi7uErZHND PP4DiYkzq9TbvAjmaqdP+eQwBIp2A4QPAotn+g645Z/y91nMFDq/RHMJPv7ZRHjR8exr Vjpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T0d38LH2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bm18-20020a656e92000000b0051343ab1eb5si17410329pgb.581.2023.04.26.10.37.44; Wed, 26 Apr 2023 10:37:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T0d38LH2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238466AbjDZR3k (ORCPT + 99 others); Wed, 26 Apr 2023 13:29:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233678AbjDZR3i (ORCPT ); Wed, 26 Apr 2023 13:29:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4425EBE; Wed, 26 Apr 2023 10:29:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D76856232F; Wed, 26 Apr 2023 17:29:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EAEE3C433EF; Wed, 26 Apr 2023 17:29:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682530176; bh=dcW/YGcfbxh1/KUv8M6Wk49tlitkkdIukS6SS0m9pEQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T0d38LH2IrCAUzZ3Ljnkpq7lWYQ10iQ7lD0UNtxp3dtB1QhtTGKYwRMaVwe+Q383d r32hskaz+qbLvPgwaj5D6xRl9HRWAGOGcyBjsinyo4WyEeBSF7Lthir2RCTXtnR57m XFRTFKUUB2Uob7VCrAlDqRFlBSyO9Nq+S+LDnHZWnOKfU5KtwfeQf6Ug2EDa9AHU0e KVCEFaVuck9yig1f7nyW2026ZzDYJlwZ5zoAxTja2kR53ExIRld5CRf995ZyChBKTV Ac0jLjllKJqr+Pm85FC/34lFX67KmHeZ+Hy0MOnDS/AdWa48QuixooT1BKCLE6+6qi LotndTosOc+FQ== From: Jarkko Sakkinen To: linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Huewe , Jarkko Sakkinen , Jason Gunthorpe , Jerry Snitselaar , Stefan Berger , James Bottomley Cc: stable@vger.kernel.org, "Jason A . Donenfeld" Subject: [PATCH 1/2] tpm_tis: Use tpm_chip_{start,stop} decoration inside tpm_tis_resume Date: Wed, 26 Apr 2023 20:29:27 +0300 Message-Id: <20230426172928.3963287-2-jarkko@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230426172928.3963287-1-jarkko@kernel.org> References: <20230426172928.3963287-1-jarkko@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Before sending a TPM command, CLKRUN protocol must be disabled. This is not done in the case of tpm1_do_selftest() call site inside tpm_tis_resume(). Address this by decorating the calls with tpm_chip_{start,stop}, which arm and disarm the TPM chip for transmission, and take care of disabling and re-enabling CLKRUN, among other things. Cc: stable@vger.kernel.org Reported-by: Jason A. Donenfeld Link: https://lore.kernel.org/linux-integrity/CS68AWILHXS4.3M36M1EKZLUMS@suppilovahvero/ Fixes: a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()") Signed-off-by: Jarkko Sakkinen --- drivers/char/tpm/tpm_tis_core.c | 43 +++++++++++++++------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index c2421162cf34..73707026e358 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -1209,25 +1209,20 @@ static void tpm_tis_reenable_interrupts(struct tpm_chip *chip) u32 intmask; int rc; - if (chip->ops->clk_enable != NULL) - chip->ops->clk_enable(chip, true); - - /* reenable interrupts that device may have lost or - * BIOS/firmware may have disabled + /* + * Re-enable interrupts that device may have lost or BIOS/firmware may + * have disabled. */ rc = tpm_tis_write8(priv, TPM_INT_VECTOR(priv->locality), priv->irq); - if (rc < 0) - goto out; + if (rc < 0) { + dev_err(&chip->dev, "Setting IRQ failed.\n"); + return; + } intmask = priv->int_mask | TPM_GLOBAL_INT_ENABLE; - - tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask); - -out: - if (chip->ops->clk_enable != NULL) - chip->ops->clk_enable(chip, false); - - return; + rc = tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask); + if (rc < 0) + dev_err(&chip->dev, "Enabling interrupts failed.\n"); } int tpm_tis_resume(struct device *dev) @@ -1235,27 +1230,27 @@ int tpm_tis_resume(struct device *dev) struct tpm_chip *chip = dev_get_drvdata(dev); int ret; - ret = tpm_tis_request_locality(chip, 0); - if (ret < 0) + ret = tpm_chip_start(chip); + if (ret) return ret; if (chip->flags & TPM_CHIP_FLAG_IRQ) tpm_tis_reenable_interrupts(chip); - ret = tpm_pm_resume(dev); - if (ret) - goto out; - /* * TPM 1.2 requires self-test on resume. This function actually returns * an error code but for unknown reason it isn't handled. */ if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) tpm1_do_selftest(chip); -out: - tpm_tis_relinquish_locality(chip, 0); - return ret; + tpm_chip_stop(chip); + + ret = tpm_pm_resume(dev); + if (ret) + return ret; + + return 0; } EXPORT_SYMBOL_GPL(tpm_tis_resume); #endif -- 2.39.2