Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp165580ybl; Wed, 11 Dec 2019 15:56:11 -0800 (PST) X-Google-Smtp-Source: APXvYqxYYDsD/qvghY81iUXa4d0vZdjFuZF/H10+ZWeW58rAwi8Nmgcjcu+N5QPwVWoavnMDmpN8 X-Received: by 2002:a9d:3a49:: with SMTP id j67mr4794510otc.264.1576108571119; Wed, 11 Dec 2019 15:56:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576108571; cv=none; d=google.com; s=arc-20160816; b=X7Dr4CgpxBSFIj0Kcz2J4b/qvbCzvyQJbwp63+JiQcoLa3iPg1+a+Xns7FatjKAWDw xGnCLe2It8wH3HyLO2ltQ36RGoenukqD5s1Fq7M/EBBSnsND8q8UeTH9FS6e0QK/IqJg Y4xq9w9lDZrLpB9GwMRHiME069jOOvIy7TqdHHvx1zuk/C7pBa+zwkIVA+hxme4CWHxc GUOrN7m9U5L7aL7UK5AToDRY8W9ay+LuIx7/BZunYU3raJ4cJpVrkkEs0FOn6gzjgVPu tME9PKM5L5bvL3DEdWFhmTK9ejhDn/MvHa17Rp/88+uoVi3yiAKWdbTbPrMiupDKIVDu j3dw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=G4wpjlektt4yYwx0w6/RAR7IM+7TmJ4/Z5bpkn88zOE=; b=CT+zwN0ESvYpba6o8aEoR0Je5O5TVc/we69x8QemVGrvlI6k/Z/bBJ9Cn/ARaRZo0c 2+4+JrjGirS57IfnqikOOPjJZ2nVtUUYJ1W+zPXkbLrJjcdrWch3sDd6pFkkeP62xjj9 G/R2XMcMeUrBhEAiZ9fdAKkHBVhXbQmVUvMREVaH8PDl+lyBz++t1mnMIC5AmBUtj7dB 8InqzOlp3Qzb9kpHDzRw92ZHHlC6k/g2mOHJ0RmpzOr3z5MkBo5Hh/0h/R/tVGr1Sxqc /EKgqTuZu6ozfyP7a8eckKrxzRluqjTaKa1GuW3I0pZ26mgDnNiQ3Cgn96pMQ3L3cPqs eYIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ROptf8hF; 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 n7si2116366oih.237.2019.12.11.15.55.59; Wed, 11 Dec 2019 15:56:11 -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=ROptf8hF; 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 S1727198AbfLKXz2 (ORCPT + 99 others); Wed, 11 Dec 2019 18:55:28 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:23308 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727101AbfLKXz2 (ORCPT ); Wed, 11 Dec 2019 18:55:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576108527; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G4wpjlektt4yYwx0w6/RAR7IM+7TmJ4/Z5bpkn88zOE=; b=ROptf8hFmOKBRJEJx7CCLHjFVmBR33iu16v8Xv94hju97rt3MRCo4nsjedPYGlY2h7PJgJ lL3s5yR+p1qnmXtevaqvejns3JrldDkNIldC9QRHoabZPEpy2RaBMkQPDWY1XFV4NrlxgS LwSagZjwRQ9MAPBxPZ2rrQNVRkLTs1o= 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-389-OEuByi8_M2i7AF-ZGDEvmQ-1; Wed, 11 Dec 2019 18:55:26 -0500 X-MC-Unique: OEuByi8_M2i7AF-ZGDEvmQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 33EEEDB6B; Wed, 11 Dec 2019 23:55:24 +0000 (UTC) Received: from cantor.redhat.com (ovpn-116-36.phx2.redhat.com [10.3.116.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 727E210013A1; Wed, 11 Dec 2019 23:55:05 +0000 (UTC) From: Jerry Snitselaar To: linux-kernel@vger.kernel.org Cc: Christian Bundy , Dan Williams , Peter Huewe , Jarkko Sakkinen , Jason Gunthorpe , Stefan Berger , stable@vger.kernel.org, linux-integrity@vger.kernel.org Subject: [PATCH v2] tpm_tis: reserve chip for duration of tpm_tis_core_init Date: Wed, 11 Dec 2019 16:54:55 -0700 Message-Id: <20191211235455.24424-1-jsnitsel@redhat.com> In-Reply-To: <20191211231758.22263-1-jsnitsel@redhat.com> References: <20191211231758.22263-1-jsnitsel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of repeatedly calling tpm_chip_start/tpm_chip_stop when issuing commands to the tpm during initialization, just reserve the chip after wait_startup, and release it when we are ready to call tpm_chip_register. Cc: Christian Bundy Cc: Dan Williams Cc: Peter Huewe Cc: Jarkko Sakkinen Cc: Jason Gunthorpe Cc: Stefan Berger Cc: stable@vger.kernel.org Cc: linux-integrity@vger.kernel.org Fixes: a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit= ()") Fixes: 5b359c7c4372 ("tpm_tis_core: Turn on the TPM before probing IRQ's"= ) Signed-off-by: Jerry Snitselaar --- v2: Fix integrity list address and add 5b359c7c4372 to fixes drivers/char/tpm/tpm_tis_core.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_c= ore.c index 8af2cee1a762..308756d278b3 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -978,13 +978,13 @@ int tpm_tis_core_init(struct device *dev, struct tp= m_tis_data *priv, int irq, =20 if (wait_startup(chip, 0) !=3D 0) { rc =3D -ENODEV; - goto out_err; + goto out_start; } =20 /* Take control of the TPM's interrupt hardware and shut it off */ rc =3D tpm_tis_read32(priv, TPM_INT_ENABLE(priv->locality), &intmask); if (rc < 0) - goto out_err; + goto out_start; =20 intmask |=3D TPM_INTF_CMD_READY_INT | TPM_INTF_LOCALITY_CHANGE_INT | TPM_INTF_DATA_AVAIL_INT | TPM_INTF_STS_VALID_INT; @@ -993,9 +993,8 @@ int tpm_tis_core_init(struct device *dev, struct tpm_= tis_data *priv, int irq, =20 rc =3D tpm_chip_start(chip); if (rc) - goto out_err; + goto out_start; rc =3D tpm2_probe(chip); - tpm_chip_stop(chip); if (rc) goto out_err; =20 @@ -1059,7 +1058,6 @@ int tpm_tis_core_init(struct device *dev, struct tp= m_tis_data *priv, int irq, goto out_err; } =20 - tpm_chip_start(chip); chip->flags |=3D TPM_CHIP_FLAG_IRQ; if (irq) { tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED, @@ -1070,18 +1068,17 @@ int tpm_tis_core_init(struct device *dev, struct = tpm_tis_data *priv, int irq, } else { tpm_tis_probe_irq(chip, intmask); } - tpm_chip_stop(chip); } + tpm_chip_stop(chip); =20 rc =3D tpm_chip_register(chip); if (rc) - goto out_err; - - if (chip->ops->clk_enable !=3D NULL) - chip->ops->clk_enable(chip, false); + goto out_start; =20 return 0; out_err: + tpm_chip_stop(chip); +out_start: if ((chip->ops !=3D NULL) && (chip->ops->clk_enable !=3D NULL)) chip->ops->clk_enable(chip, false); =20 --=20 2.24.0