Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3494297imm; Fri, 19 Oct 2018 11:31:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV62W8+VA3biY6OCPCbWCuK0w0HHnP3awOv1VnEJfkzgimIaog2sw2Mdp40qzIqGB6Hh1KGaI X-Received: by 2002:a63:f05:: with SMTP id e5-v6mr32161091pgl.84.1539973904004; Fri, 19 Oct 2018 11:31:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539973903; cv=none; d=google.com; s=arc-20160816; b=nzqVzgH8cvTGplk3omq5iMkeqfgytfLa0M/hdnaU0oa/XHeao4zXBNoURzUDeYmK/n 8OZlq0q78DpIFvWEACweB/APgqPh73gaxUTcB84LAVWj0EOrQVN4P0NyNk2D4PaNi/nW aMLtuVBc/0YK9Aa4R/pV+zhsYIBma/cm4CkS07txNCmkET1+p/N5lMnh9h+lHCKyJZrT ASAYxiEmWu0Ly4In71LVnFSfeGkRm4G/7CL+F52XGoY07l5XhItmNWkEP/GFuEFm5Guz AnDwv5FEyEUHH5n73iEPLWO39Q1f1weW/2wXrIRnqAUEMQTuBA06fYGBQ7dPXxnr7bsH sJpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=I2gAN4gc3XghHt7nD/X93BqiuFno05+XgwzCpNZ/ZPA=; b=br9n/RL0Ny0tL/18pLdL/6dunKMT8GGkVRksDWfnkKQD7V3X7vE9lVUnq8/fgNvd5d uyL2qDYZXKTlVGWe1/AcHRYDI/XqlfjfeWtqEVwj7CHb8fq7s+/tta67sBR8yNZ5uAn5 MRa33U27ULfFpjQ29u4KDQwl52868N+//EgVWrkz/AQMYe335Ezw1kk6Tw5EqJQ8ZloH 5wX6KzX+cWV06LFMMMEwxF13hoD25WQgr7t7kn88dWprnbkjN+aVpisWn1jWQsKSmQU7 jkD7eat9Kh74fg40TdqfDBl2RWY2+ejsGuPwBqorsfOuI6vx2UGCR+9yU0KBsX3xwbO6 FNUg== 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 r59-v6si24159569plb.6.2018.10.19.11.31.28; Fri, 19 Oct 2018 11:31:43 -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 S1727824AbeJTCeq (ORCPT + 99 others); Fri, 19 Oct 2018 22:34:46 -0400 Received: from mga01.intel.com ([192.55.52.88]:54180 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727547AbeJTCep (ORCPT ); Fri, 19 Oct 2018 22:34:45 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Oct 2018 11:27:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,401,1534834800"; d="scan'208";a="267150069" Received: from twinkler-lnx.jer.intel.com ([10.12.91.48]) by orsmga005.jf.intel.com with ESMTP; 19 Oct 2018 11:27:22 -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 , stable@vger.kernel.org Subject: [PATCH v7 01/21] tpm: tpm_i2c_nuvoton: use correct command duration for TPM 2.x Date: Fri, 19 Oct 2018 21:22:47 +0300 Message-Id: <20181019182307.17745-2-tomas.winkler@intel.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20181019182307.17745-1-tomas.winkler@intel.com> References: <20181019182307.17745-1-tomas.winkler@intel.com> 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: stable@vger.kernel.org Cc: Nayna Jain Signed-off-by: Tomas Winkler Reviewed-by: Nayna Jain Tested-by: Nayna Jain (For TPM 2.0) --- V7: new in the series. 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