Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1546482ybc; Wed, 13 Nov 2019 00:01:54 -0800 (PST) X-Google-Smtp-Source: APXvYqxpKeprW6GzKb4EGYt6tSRQNf7e3q0Tz7S8SeOOOLvGDHd3i2qFVfc0dS+nSq5o4XQGZQou X-Received: by 2002:aa7:d6d1:: with SMTP id x17mr2166432edr.158.1573632113891; Wed, 13 Nov 2019 00:01:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573632113; cv=none; d=google.com; s=arc-20160816; b=YGYvjDWFjUR6bkYNUO+x7Jg5RvoxwWwpsU76cXgqjkARv4JtWPY346yMQzJMei62KI HvB7ZiRuC4PyOg7KwuI7ApRnqEN3xiN0LUa+5pDvBUa713BLTWlAvsgIKi6h41bCxit0 8xyKEJituVDLK25mgxY73Xm62to+L/3QAbNwa7P6w3s2jNUOb23BoUl9hVmwfPHR//2x CcmtFodR9yFOBbEE6ooaLvjir/l8d89A2IxwIkMGEtByws5ognVPjpmEs4vCCh4yR4Is SNSj0Ytg+qXfVi+U+aw1/+Milb8XiQc+BrGb1mmOHvW7QivpxCxgQ2cjfddsXMcLgzBr o6rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=CMk5IBNgQTUKXm1UH2KRTJi2cKWC2WnWXM6M0NEqON4=; b=DwcMebKVpkYzrUTVanQG9TaXI+DvwWZ2vGGG+Bb4whizmVkVuel+gbhKR/v14TKH/K tEnTSXU7Hha+eWJLm89Qc8Qt6yB8eufcQ15fG6mabyuW8xzevl9uXhu3za/CHkk9sDZT 8oMkRuCc4GvHgYK+49AzUw6OQuQkT4hoDQoKCZx77fId1klR8QO2cZrmvYHCUlZANXex L/e8f+PYQexH8+1h4jeJsbhRM7HXBrv50uy/CiQ2+8t0Dfe6ajPnPxbNeFIuUMVEJ19m byBjVHAuBuwMPFzCcKii4edGH6LQALxN7Fm0IVRTikyeyaFjI8E6P3Mg/2yMFPWbH4Mz e/TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MzAhovt2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j5si812219edc.195.2019.11.13.00.01.28; Wed, 13 Nov 2019 00:01:53 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=MzAhovt2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726155AbfKMIA7 (ORCPT + 99 others); Wed, 13 Nov 2019 03:00:59 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:33711 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725966AbfKMIA7 (ORCPT ); Wed, 13 Nov 2019 03:00:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573632057; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CMk5IBNgQTUKXm1UH2KRTJi2cKWC2WnWXM6M0NEqON4=; b=MzAhovt2G9YZSZ4XyffpYNPH7JlP+a4cFlsASdV0KMV7v9dmcjvmT1rireMSLTzoN5aI5M 4IjFOSEJRMqZi4GBTQuy8dGcFCnKU0dPEhCr2cqbVQqOR8y4zuMmPWat+3zYkR6wqw10Gg U/zC+B9DQqd0LNbWhBwMbjYL7fdwCwM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-332-DZfi_6wuNua0lcrnQv12BA-1; Wed, 13 Nov 2019 03:00:54 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9C5D118B5F6A; Wed, 13 Nov 2019 08:00:52 +0000 (UTC) Received: from cantor.redhat.com (ovpn-116-198.phx2.redhat.com [10.3.116.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42F5C5D9E5; Wed, 13 Nov 2019 08:00:52 +0000 (UTC) From: Jerry Snitselaar To: linux-integrity@vger.kernel.org Cc: Peter Huewe , Jarkko Sakkinen , Jason Gunthorpe , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH] tpm: move TPM_CHIP_FLAG_HAVE_TIMEOUTS check Date: Wed, 13 Nov 2019 01:00:02 -0700 Message-Id: <20191113080002.14932-1-jsnitsel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: DZfi_6wuNua0lcrnQv12BA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since tpm1_get_timeouts and tpm2_get_timeouts are now called directly by the auto startup code in addition to being called by tpm_get_timeouts, push the flag check down into the individual functions to avoid going through them again if they've already set the TPM_CHIP_FLAG_HAVE_TIMEOUTS flag. Cc: Peter Huewe Cc: Jarkko Sakkinen Cc: Jason Gunthorpe Cc: linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org Fixes: d4a317563207 ("tpm: move tpm 1.x selftest code from tpm-interface.c = tpm1-cmd.c") Fixes: 9db7fe187c54 ("tpm: factor out tpm_startup function") Signed-off-by: Jerry Snitselaar --- drivers/char/tpm/tpm-interface.c | 3 --- drivers/char/tpm/tpm1-cmd.c | 3 +++ drivers/char/tpm/tpm2-cmd.c | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interf= ace.c index d7a3888ad80f..3c9e14981ce6 100644 --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c @@ -237,9 +237,6 @@ EXPORT_SYMBOL_GPL(tpm_transmit_cmd); =20 int tpm_get_timeouts(struct tpm_chip *chip) { -=09if (chip->flags & TPM_CHIP_FLAG_HAVE_TIMEOUTS) -=09=09return 0; - =09if (chip->flags & TPM_CHIP_FLAG_TPM2) =09=09return tpm2_get_timeouts(chip); =09else diff --git a/drivers/char/tpm/tpm1-cmd.c b/drivers/char/tpm/tpm1-cmd.c index 149e953ca369..5330b32d1469 100644 --- a/drivers/char/tpm/tpm1-cmd.c +++ b/drivers/char/tpm/tpm1-cmd.c @@ -345,6 +345,9 @@ int tpm1_get_timeouts(struct tpm_chip *chip) =09unsigned long timeout_old[4], timeout_chip[4], timeout_eff[4]; =09ssize_t rc; =20 +=09if (chip->flags & TPM_CHIP_FLAG_HAVE_TIMEOUTS) +=09=09return 0; + =09rc =3D tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, NULL, =09=09=09 sizeof(cap.timeout)); =09if (rc =3D=3D TPM_ERR_INVALID_POSTINIT) { diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c index ba9acae83bff..55d96be86ed8 100644 --- a/drivers/char/tpm/tpm2-cmd.c +++ b/drivers/char/tpm/tpm2-cmd.c @@ -38,6 +38,9 @@ static struct tpm2_hash tpm2_hash_map[] =3D { =20 int tpm2_get_timeouts(struct tpm_chip *chip) { +=09if (chip->flags & TPM_CHIP_FLAG_HAVE_TIMEOUTS) +=09=09return 0; + =09/* Fixed timeouts for TPM2 */ =09chip->timeout_a =3D msecs_to_jiffies(TPM2_TIMEOUT_A); =09chip->timeout_b =3D msecs_to_jiffies(TPM2_TIMEOUT_B); --=20 2.24.0