Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp878048imm; Wed, 17 Oct 2018 09:37:22 -0700 (PDT) X-Google-Smtp-Source: ACcGV63NjataTAnUCDsubIs68a1eGUcvCBxF7RdsLEwL5OIkIpOsAqIPk1V1pGLtMYBbG+g0G6QR X-Received: by 2002:a63:790e:: with SMTP id u14-v6mr25265817pgc.111.1539794242351; Wed, 17 Oct 2018 09:37:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539794242; cv=none; d=google.com; s=arc-20160816; b=IQHsMSF+vGIXqLgWb/nuiMCQIYTB00amu5XWLYojue5oiPCM4o8wQYFECx78aQV+xl 4f1LDIAiCeOrPB2YynpZSDflKYxHXKT/WNqc1JKervrLf1AlCbrUwEbevyoG03O7FYMb Mbw6FQdZlomMWR+2PJHTvN3j1DNvdSXbWrsPqKy5obUZ4O4PoVFo+NtlyLuGWL08bO/a s+E+zbYBX+fsL0eyduKuY5Bv6jnb8Y27PYhB1vK44kedZ9i51juDGFGMCtG2ZLM7cbo0 D29trosgSnBcp9E2mffHnUYOxBK9YTuB7P0AML6UB6qErhEAx12AJjQdpl2NTuMLNLSY aZeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=cASbIufsx5JZ71LE6uWpiKB5nyVwqLYn06mILwlzoTM=; b=rYhRcokudxRFd1T+W96LkITFF01CknFV4V01G1ABIgS248k6AHtrW8shQBa3CxzPcQ 9MFJ3n5LvtqJeMm+DddkbUFwpi0W3xKmb33Og07yllu7UGfB0Rv2PpYSQSnPD1TOzdVe QpAgS4pSFLe1bJ5nnh/Ht9UeNZexd6qI/dslAbJfDjTMeEQ5uEYCRj3TjbWk1SEnkdxv /Bty4mYi20Lnv+dQnMf5oY+eD5lNbXJqpGABiiV1JGVrlXR9BTflqNi1rDhbC2Tr5HJF NaiHBf0gNpjxnZ/1UHkW0kCj7a0FPL6/ORDRwQ/6AsnzIrFviA0RrtfhBntd3vbuowXs Nndw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bj12-v6si17182393plb.178.2018.10.17.09.37.05; Wed, 17 Oct 2018 09:37:22 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727845AbeJRAcx (ORCPT + 99 others); Wed, 17 Oct 2018 20:32:53 -0400 Received: from mga04.intel.com ([192.55.52.120]:44176 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727061AbeJRAcx (ORCPT ); Wed, 17 Oct 2018 20:32:53 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Oct 2018 09:36:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,393,1534834800"; d="scan'208";a="100048430" Received: from twinkler-lnx.jer.intel.com ([10.12.91.48]) by fmsmga001.fm.intel.com with ESMTP; 17 Oct 2018 09:36:21 -0700 From: Tomas Winkler To: Jarkko Sakkinen , Jason Gunthorpe Cc: Nayna Jain , Alexander Usyskin , Tadeusz Struk , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Tomas Winkler Subject: [PATCH] tpm: tpm_i2c_nuvoton: use correct command duration for TPM 2.x Date: Wed, 17 Oct 2018 19:32:23 +0300 Message-Id: <20181017163223.25141-1-tomas.winkler@intel.com> X-Mailer: git-send-email 2.14.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org tpm_i2c_nuvoton calculated commands duration using TPM 1.x values via tpm_calc_ordinal_duration() also for TPM 2.x chips. Call tpm2_calc_ordinal_duration() for retrieving ordinal duration for TPM 2.X chips. Cc: Nayna Jain Signed-off-by: Tomas Winkler --- drivers/char/tpm/tpm_i2c_nuvoton.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c index caa86b19c76d..f74f451baf6a 100644 --- a/drivers/char/tpm/tpm_i2c_nuvoton.c +++ b/drivers/char/tpm/tpm_i2c_nuvoton.c @@ -369,6 +369,7 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len) struct device *dev = chip->dev.parent; struct i2c_client *client = to_i2c_client(dev); u32 ordinal; + unsigned long duration; size_t count = 0; int burst_count, bytes2write, retries, rc = -EIO; @@ -455,10 +456,12 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len) return rc; } ordinal = be32_to_cpu(*((__be32 *) (buf + 6))); - rc = i2c_nuvoton_wait_for_data_avail(chip, - tpm_calc_ordinal_duration(chip, - ordinal), - &priv->read_queue); + if (chip->flags & TPM_CHIP_FLAG_TPM2) + duration = tpm2_calc_ordinal_duration(chip, ordinal); + else + duration = tpm_calc_ordinal_duration(chip, ordinal); + + rc = i2c_nuvoton_wait_for_data_avail(chip, duration, &priv->read_queue); if (rc) { dev_err(dev, "%s() timeout command duration\n", __func__); i2c_nuvoton_ready(chip); -- 2.14.4