From patchwork Thu Jan 12 18:12:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej S. Szmigiero" X-Patchwork-Id: 714588 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tzv475S1Tz9ryZ for ; Fri, 13 Jan 2017 05:12:23 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1cRjrJ-0004fF-Ua; Thu, 12 Jan 2017 18:12:21 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1cRjrI-0004f8-7D for tpmdd-devel@lists.sourceforge.net; Thu, 12 Jan 2017 18:12:20 +0000 X-ACL-Warn: Received: from vps-vb.mhejs.net ([37.28.154.113]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1cRjrH-0006AH-7b for tpmdd-devel@lists.sourceforge.net; Thu, 12 Jan 2017 18:12:20 +0000 Received: by vps-vb.mhejs.net with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.87) (envelope-from ) id 1cRjr5-0000zf-2l; Thu, 12 Jan 2017 19:12:07 +0100 From: "Maciej S. Szmigiero" To: tpmdd-devel@lists.sourceforge.net Message-ID: <6bd0d2fe-f979-a4dc-7c4d-54036f4d37f8@maciej.szmigiero.name> Date: Thu, 12 Jan 2017 19:12:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 X-Spam-Score: 0.0 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. X-Headers-End: 1cRjrH-0006AH-7b Cc: Christophe Ricard , linux-kernel Subject: [tpmdd-devel] [PATCH] tpm_tis: fix iTPM probe via probe_itpm() function X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Tpm Device Driver maintainance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tpmdd-devel-bounces@lists.sourceforge.net probe_itpm() function is supposed to send command without an itpm flag set and if this fails to repeat it, this time with the itpm flag set. However, commit 41a5e1cf1fe15 ("tpm/tpm_tis: Split tpm_tis driver into a core and TCG TIS compliant phy") moved the itpm flag from an "itpm" variable to a TPM_TIS_ITPM_POSSIBLE chip flag, so setting the (now function-local) itpm variable no longer had any effect. Finally, this function-local itpm variable was removed by commit 56af322156dbe9 ("tpm/tpm_tis: remove unused itpm variable") Tested only on non-iTPM TIS TPM. Signed-off-by: Maciej S. Szmigiero Fixes: 41a5e1cf1fe15 ("Split tpm_tis driver into a core and TCG TIS compliant phy") Cc: stable@vger.kernel.org Reviewed-by: Jason Gunthorpe Reviewed-by: Jarkko Sakkinen --- drivers/char/tpm/tpm_tis_core.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) ------------------------------------------------------------------------------ Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE. Training and support from Colfax. Order your platform today. http://sdm.link/xeonphi diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index e42e5a6a3c2f..401f1228547c 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -467,6 +467,9 @@ static int probe_itpm(struct tpm_chip *chip) size_t len = sizeof(cmd_getticks); u16 vendor; + if (priv->flags & TPM_TIS_ITPM_POSSIBLE) + return 0; + rc = tpm_tis_read16(priv, TPM_DID_VID(0), &vendor); if (rc < 0) return rc; @@ -482,12 +485,15 @@ static int probe_itpm(struct tpm_chip *chip) tpm_tis_ready(chip); release_locality(chip, priv->locality, 0); + priv->flags |= TPM_TIS_ITPM_POSSIBLE; + rc = tpm_tis_send_data(chip, cmd_getticks, len); - if (rc == 0) { + if (rc == 0) dev_info(&chip->dev, "Detected an iTPM.\n"); - rc = 1; - } else + else { + priv->flags &= ~TPM_TIS_ITPM_POSSIBLE; rc = -EFAULT; + } out: tpm_tis_ready(chip); @@ -743,15 +749,10 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, (chip->flags & TPM_CHIP_FLAG_TPM2) ? "2.0" : "1.2", vendor >> 16, rid); - if (!(priv->flags & TPM_TIS_ITPM_POSSIBLE)) { - probe = probe_itpm(chip); - if (probe < 0) { - rc = -ENODEV; - goto out_err; - } - - if (!!probe) - priv->flags |= TPM_TIS_ITPM_POSSIBLE; + probe = probe_itpm(chip); + if (probe < 0) { + rc = -ENODEV; + goto out_err; } /* Figure out the capabilities */