From patchwork Tue Mar 24 06:47:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Ricard X-Patchwork-Id: 453741 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 77469140157 for ; Tue, 24 Mar 2015 17:47:40 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YaIcj-0005P2-OV; Tue, 24 Mar 2015 06:47:37 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YaIch-0005Oq-S0 for tpmdd-devel@lists.sourceforge.net; Tue, 24 Mar 2015 06:47:35 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of gmail.com designates 74.125.82.178 as permitted sender) client-ip=74.125.82.178; envelope-from=christophe.ricard@gmail.com; helo=mail-we0-f178.google.com; Received: from mail-we0-f178.google.com ([74.125.82.178]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YaIcf-0005H9-PD for tpmdd-devel@lists.sourceforge.net; Tue, 24 Mar 2015 06:47:35 +0000 Received: by weoy45 with SMTP id y45so5803697weo.2 for ; Mon, 23 Mar 2015 23:47:27 -0700 (PDT) X-Received: by 10.180.107.198 with SMTP id he6mr11607887wib.68.1427179647823; Mon, 23 Mar 2015 23:47:27 -0700 (PDT) Received: from localhost.localdomain (ax113-6-78-236-204-66.fbx.proxad.net. [78.236.204.66]) by mx.google.com with ESMTPSA id i5sm2301619wiz.0.2015.03.23.23.47.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Mar 2015 23:47:26 -0700 (PDT) From: Christophe Ricard X-Google-Original-From: Christophe Ricard To: peterhuewe@gmx.de Date: Tue, 24 Mar 2015 07:47:13 +0100 Message-Id: <1427179633-3246-2-git-send-email-christophe-h.ricard@st.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1427179633-3246-1-git-send-email-christophe-h.ricard@st.com> References: <1427179633-3246-1-git-send-email-christophe-h.ricard@st.com> X-Spam-Score: -1.6 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (christophe.ricard[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1YaIcf-0005H9-PD Cc: jean-luc.blanc@st.com, ashley@ashleylai.com, christophe.ricard@gmail.com, tpmdd-devel@lists.sourceforge.net, christophe-h.ricard@st.com, benoit.houyere@st.com Subject: [tpmdd-devel] [PATCH v3] tpm/tpm_i2c_stm_st33: Add proper wait for ordinal duration in case of irq mode 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: , MIME-Version: 1.0 Errors-To: tpmdd-devel-bounces@lists.sourceforge.net In case the driver is configured to use irq, we are not waiting the answer for a duration period to see the DATA_AVAIL status bit to raise but at maximum timeout_c. This may result in critical failure as we will not wait long enough for the command completion. This patch is a backport from kernel 4.1 fix. Signed-off-by: Christophe Ricard Reviewed-by: Peter Huewe Signed-off-by: Peter Huewe --- drivers/char/tpm/tpm_i2c_stm_st33.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/char/tpm/tpm_i2c_stm_st33.c b/drivers/char/tpm/tpm_i2c_stm_st33.c index 612845b..5850222 100644 --- a/drivers/char/tpm/tpm_i2c_stm_st33.c +++ b/drivers/char/tpm/tpm_i2c_stm_st33.c @@ -496,7 +496,7 @@ static irqreturn_t tpm_ioserirq_handler(int irq, void *dev_id) static int tpm_stm_i2c_send(struct tpm_chip *chip, unsigned char *buf, size_t len) { - u32 status, i, size; + u32 status, i, size, ordinal; int burstcnt = 0; int ret; u8 data; @@ -559,6 +559,16 @@ static int tpm_stm_i2c_send(struct tpm_chip *chip, unsigned char *buf, data = TPM_STS_GO; I2C_WRITE_DATA(tpm_dev, TPM_STS, &data, 1); + if (chip->vendor.irq) { + ordinal = be32_to_cpu(*((__be32 *) (buf + 6))); + + ret = wait_for_stat(chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID, + tpm_calc_ordinal_duration(chip, ordinal), + &chip->vendor.read_queue, false); + if (ret < 0) + goto out_err; + } + return len; out_err: tpm_stm_i2c_cancel(chip);