From patchwork Thu Jun 30 17:25:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Pronin X-Patchwork-Id: 9208651 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9830C6075F for ; Thu, 30 Jun 2016 17:25:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86EED2866B for ; Thu, 30 Jun 2016 17:25:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A16528681; Thu, 30 Jun 2016 17:25:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 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 mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BDC1E2866B for ; Thu, 30 Jun 2016 17:25:54 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1bIfiq-000311-B0; Thu, 30 Jun 2016 17:25:52 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1bIfip-00030u-El for tpmdd-devel@lists.sourceforge.net; Thu, 30 Jun 2016 17:25:51 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of chromium.org designates 209.85.220.51 as permitted sender) client-ip=209.85.220.51; envelope-from=apronin@chromium.org; helo=mail-pa0-f51.google.com; Received: from mail-pa0-f51.google.com ([209.85.220.51]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) id 1bIfio-0007ic-NS for tpmdd-devel@lists.sourceforge.net; Thu, 30 Jun 2016 17:25:51 +0000 Received: by mail-pa0-f51.google.com with SMTP id hl6so30227319pac.2 for ; Thu, 30 Jun 2016 10:25:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=PKc2bUSod3sn6JjEGQvytEn6LvTBz7gsXMzIU2IPnpk=; b=ctMN/YBrjL+EsQbLPWk/PIuPPiiABQ+SVBiwTLLhJoCnYbIwRQImXY9xiZ+KssUKuL qZRWckFbaa5h3I8qKHbUaDdqr7MuJgSfXIPzjirV+gaWYtA7Y/nb9j7T03F/wzgJd1fH wapQ2xT2db6LYSNKYvT005H5kzkM8q0IxiKTSRd5WvZk+YPKOOJj2QEdyj3ufsz7ZZju kMG5BUNBoMISAN+W4yXVDMnhlRxM+4BPn+5tDeiGxlaRqKwwn7dA1EG0m9wyTg3RixD6 UcydxVmJgn4OOHLBPStyLuq3Qs8bcH4o2xxOrLjSmaYCVd8Wrco8RZgW319u/iiGy3GN nWkA== X-Gm-Message-State: ALyK8tKnKezqJzUvaq/ARPIGRwRDcMeTYTAqy/SCNtk8w04DvL05z+yNoMaKBHVMNuJ3olxh X-Received: by 10.66.78.226 with SMTP id e2mr23448700pax.37.1467307545041; Thu, 30 Jun 2016 10:25:45 -0700 (PDT) Received: from apronin0.mtv.corp.google.com ([172.22.64.136]) by smtp.gmail.com with ESMTPSA id y70sm7233677pff.25.2016.06.30.10.25.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 30 Jun 2016 10:25:44 -0700 (PDT) From: apronin@chromium.org To: Jarkko Sakkinen Date: Thu, 30 Jun 2016 10:25:43 -0700 Message-Id: <1467307543-44566-1-git-send-email-apronin@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 X-Headers-End: 1bIfio-0007ic-NS Cc: Christophe Ricard , linux-kernel@vger.kernel.org, tpmdd-devel@lists.sourceforge.net Subject: [tpmdd-devel] [RESEND][PATCH] tpm: read burstcount from TPM_STS in one 32-bit transaction 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 X-Virus-Scanned: ClamAV using ClamSMTP From: Andrey Pronin Some chips incorrectly support partial reads from TPM_STS register at non-zero offsets. Read the entire 32-bits register instead of making two 8-bit reads to support such devices and reduce the number of bus transactions when obtaining the burstcount from TPM_STS. Signed-off-by: Andrey Pronin Reviewed-by: Jarkko Sakkinen --- No changes. Re-sending to tpmdd-devel member-only list after subscribing. drivers/char/tpm/tpm_tis_core.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index 03a06b3..8110b52 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -157,22 +157,17 @@ static int get_burstcount(struct tpm_chip *chip) struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); unsigned long stop; int burstcnt, rc; - u8 value; + u32 value; /* wait for burstcount */ /* which timeout value, spec has 2 answers (c & d) */ stop = jiffies + chip->timeout_d; do { - rc = tpm_tis_read8(priv, TPM_STS(priv->locality) + 1, &value); + rc = tpm_tis_read32(priv, TPM_STS(priv->locality), &value); if (rc < 0) return rc; - burstcnt = value; - rc = tpm_tis_read8(priv, TPM_STS(priv->locality) + 2, &value); - if (rc < 0) - return rc; - - burstcnt += value << 8; + burstcnt = (value >> 8) & 0xFFFF; if (burstcnt) return burstcnt; msleep(TPM_TIMEOUT);