Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1934918ima; Thu, 25 Oct 2018 07:15:14 -0700 (PDT) X-Google-Smtp-Source: AJdET5dE09Yd3OLPzlPi6LHa99rwrFEc/jlpQSWo0tl8w2X/+HBvowXapze3vVrw3xT9WZhjO2ke X-Received: by 2002:a65:62d5:: with SMTP id m21-v6mr1671111pgv.243.1540476914127; Thu, 25 Oct 2018 07:15:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540476914; cv=none; d=google.com; s=arc-20160816; b=sk8mxhfVQ28AuLqnKFxfk9Fvdxg0R4w+Z5y7SDUYrNguNszNwSqBjkaCeoQhW7/nsP aI4JS0M7WayMuYwIMkhvP8dhTDhASqKkTEFOFhB19OJMYiGuutBkmyQZcUSog4LI42z9 QTEh74Ncc83btHtDen4cwvNqHKLomoU+avwJDtWIZNlO+YRs9ixxuQinGIp4MZQm6HS+ tBObaKlS20qdkHC5LvR3C7HX6dNfEO5HvuvMi52RzYASguhOS7goSc70Bm47/ubJYL4R zRnjg3B+CFFUFpWDes6ewAEek8HVuZmKyBth0ZTsCV8IGYZiJLMLtg93bC4HPWNnF7ZE sBDg== 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:dkim-signature; bh=LTF8phYVUVR8cghscZ2CESm/6FixSq//dDRAIaRT3YE=; b=McmGZEL6RTrO6qCZF3yKBFz0h/USRLoZ70JeHL68fz0wqVhU7ogx9tG8cQMfdYX6Ti SNY/JBVqVMsv5wFUQdgVNahlI6rMwR2Wae7wR7oaH5RdroPsutb0X84LzWyiWX5arQfh OlImOTojE0/HnHiHps+c8haJgAlYOnqVKUlqJATOo4JaK5H3MIwpOkNT6QJYdbnTQrWh 3RA+Nj4dP2c2lQBHaFiu6xIkkLRJq4C43jKDSWpji524PFUzfYTk6nQagaTWmnRrNDoI tbfV1SxZPgLOqNrYJUW/PIs0p7Sve3CYJnu/iZLTNVJMbYjt7Cjl+Psz7ruk4+09Uaeo i57Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JvvP8LZO; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c11-v6si8515795pgj.409.2018.10.25.07.14.46; Thu, 25 Oct 2018 07:15:14 -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; dkim=pass header.i=@kernel.org header.s=default header.b=JvvP8LZO; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728194AbeJYWo2 (ORCPT + 99 others); Thu, 25 Oct 2018 18:44:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:53250 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728157AbeJYWo1 (ORCPT ); Thu, 25 Oct 2018 18:44:27 -0400 Received: from sasha-vm.mshome.net (unknown [167.98.65.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D588A20834; Thu, 25 Oct 2018 14:11:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540476691; bh=Lot1eGWWiQkKGyF9EY5sk/m8VUkNFT2Cyc0Fj2TASC0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JvvP8LZOVXk5HxMhLJCZpsZIItt8R2zAvu+Q97BaceT6lkUKflIm9P8NCsiNm162L xRg2XE7yiuXFjQiCys9dqGd+JjskAFuEsXxGYwpY1QOJtCbfN1S3zKX+tNQWl6vGkO fYxKpizJr+aMGzYSTd7D9F1BdmYkC1n2uKqf5nhc= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Nayna Jain , Jarkko Sakkinen , Sasha Levin Subject: [PATCH AUTOSEL 4.14 26/46] tpm: move the delay_msec increment after sleep in tpm_transmit() Date: Thu, 25 Oct 2018 10:10:33 -0400 Message-Id: <20181025141053.213330-26-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025141053.213330-1-sashal@kernel.org> References: <20181025141053.213330-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nayna Jain [ Upstream commit 92980756979a9c51be0275f395f4e89c42cf199a ] Commit e2fb992d82c6 ("tpm: add retry logic") introduced a new loop to handle the TPM2_RC_RETRY error. The loop retries the command after sleeping for the specified time, which is incremented exponentially in every iteration. Unfortunately, the loop doubles the time before sleeping, causing the initial sleep to be doubled. This patch fixes the initial sleep time. Fixes: commit e2fb992d82c6 ("tpm: add retry logic") Signed-off-by: Nayna Jain Reviewed-by: Mimi Zohar Tested-by: Jarkko Sakkinen Reviewed-by: Jarkko Sakkinen Signed-off-by: Jarkko Sakkinen Signed-off-by: Sasha Levin --- drivers/char/tpm/tpm-interface.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c index a2070ab86c82..89d5915b1a3f 100644 --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c @@ -611,12 +611,13 @@ ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space, rc = be32_to_cpu(header->return_code); if (rc != TPM2_RC_RETRY) break; - delay_msec *= 2; + if (delay_msec > TPM2_DURATION_LONG) { dev_err(&chip->dev, "TPM is in retry loop\n"); break; } tpm_msleep(delay_msec); + delay_msec *= 2; memcpy(buf, save, save_size); } return ret; -- 2.17.1