Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3778544imu; Mon, 7 Jan 2019 09:15:37 -0800 (PST) X-Google-Smtp-Source: ALg8bN4yy6zPYhCDbsm0MU+C7L6aUVlArl+AXwpNCoeRGrcxcNyZstEh8ty/voexQGTcfoj6Kn23 X-Received: by 2002:a17:902:b595:: with SMTP id a21mr59775408pls.120.1546881336994; Mon, 07 Jan 2019 09:15:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546881336; cv=none; d=google.com; s=arc-20160816; b=TpRjLD+vfDLZAhlJLdzSwiSCJnOSA/4hDOT4rZYbQ7e15ijw8RVhbAjSXsefOZpH3s dN/Lx3YLItM5bMHoLbxbMUraz/szobr6sLrHk6ImUPrORRe2lE8JdoPUhLies6Uq5NDq C7ZAT77DygqBH8vPjVGVutQPtYwcsIfN8uaM5D2sdO+y2GpLJHKxXeIi34yLUr7pRRA5 x6uo5mtD54DFjGpJn6L0iqaqowIycn3NvMHwwnjRZxg7hd/dlGjnUg0hdiDiQXkSL0Ya c+Wrzshl7hJbfkpLx7wpeyxbn15Ct8khLGxqW80NrYUbpWQty3sbNjwroTmcMw5vyWlu ZtcA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OdS0FH4+OS/wr+PPPuxSfTNsIE2d5kuJQZlsyuQla54=; b=UE7NMlLCQf48aZ4o1Vf5+WoCBeA5KNJvrGDSVZMHyMSvXiIYLQCyxSxgP1zQE3oaAi EK57aUP2eubR3SGhyPEXazYl1GLWWeVDUO6wgPRx3MLjbejYXhZ+cH+C0Z5IehwPqDvW 0ELEr1Qp18O4kpLqqvrvd2Ih9xPVDM6mJPbfdp33lbOJ46/sBdAAVZj8704FZRAXOovS l9/DvqSK/Kxd5Y04vvSmEGrYSZIqoxfvAuemRQv0ryS3BJjt2MjUyIayv2xqjUQGFWQd qpG18iWK7+B4Hc6YHMYt/MeikZ45G0hGCA8bFByxBpjXaf0Ig37uSfS6/ZPxyoSS7w/A rTwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="ynnEW/+1"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f22si61362231pgm.81.2019.01.07.09.15.21; Mon, 07 Jan 2019 09:15:36 -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=@kernel.org header.s=default header.b="ynnEW/+1"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731375AbfAGNEY (ORCPT + 99 others); Mon, 7 Jan 2019 08:04:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:51924 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731345AbfAGNEU (ORCPT ); Mon, 7 Jan 2019 08:04:20 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6CB99206BB; Mon, 7 Jan 2019 13:04:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546866259; bh=BsLb6pOl/sHKfaPV+dymtI8376UApm6EMd+yscJWI90=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ynnEW/+1Aosx207SaNwM08+p0bN6B7CkRUFY81ZAzXRi3FG1i/BYm65Jh1GLJ1Uvi jWgWQTJlRj231qWHxaCJrOAKlC8rjrfy0CINHYJqhAdaNVukRq0AvI2aCJozZ8ta4k j2JsyOMqqJasRtPzplw8C6T2J31AAoIhFsfTfl2c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nayna Jain , Tomas Winkler , Nayna Jain , Jarkko Sakkinen Subject: [PATCH 4.14 100/101] tpm: tpm_i2c_nuvoton: use correct command duration for TPM 2.x Date: Mon, 7 Jan 2019 13:33:28 +0100 Message-Id: <20190107105338.194469237@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190107105330.372621917@linuxfoundation.org> References: <20190107105330.372621917@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tomas Winkler commit 2ba5780ce30549cf57929b01d8cba6fe656e31c5 upstream. 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) Reviewed-by: Jarkko Sakkinen Signed-off-by: Jarkko Sakkinen Signed-off-by: Greg Kroah-Hartman --- drivers/char/tpm/tpm_i2c_nuvoton.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- 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_c 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_c 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);