Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753421AbdHGLxG convert rfc822-to-8bit (ORCPT ); Mon, 7 Aug 2017 07:53:06 -0400 Received: from mout.gmx.net ([212.227.17.22]:59776 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752902AbdHGLxD (ORCPT ); Mon, 7 Aug 2017 07:53:03 -0400 Date: Mon, 07 Aug 2017 13:52:34 +0200 User-Agent: K-9 Mail for Android In-Reply-To: <20170807114632.1339-1-nayna@linux.vnet.ibm.com> References: <20170807114632.1339-1-nayna@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Subject: Re: [PATCH] tpm: improve tpm_tis send() performance by ignoring burstcount To: Nayna Jain , tpmdd-devel@lists.sourceforge.net CC: tpmdd@selhorst.net, jarkko.sakkinen@linux.intel.com, jgunthorpe@obsidianresearch.com, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, patrickc@us.ibm.com From: Peter Huewe Message-ID: X-Provags-ID: V03:K0:1YBzCUd3Bsd0kJ1ROHo8RIpd9lqSdz2DqcoKF0F5UI0I9Eg6ra0 qBaWKJ85l90bt3gPq7GzjIBgqxjC8veeVNbZLgXogynRDD/FPK5jNl8Lz0l2LAi8TenqdSp MPs7qM/mr6Ttm4YPBlO37SMWrDwPvFIv2D3UyJ/ntnlzrmnjVd++ktMRDqHA2PTX2dKk/LR 8UOEaG1osxASHp3udaTug== X-UI-Out-Filterresults: notjunk:1;V01:K0:rUi8JgWi9LU=:p7pQlmaXf6YFfb37sMWCjb vrEdFfscvyGmbQozCJlOfRbjjhNBgoeQoiObiHhyhhSlT2ReCxCLtCWEpXAFBSYbCZHsPTjnI wP0ESmczb3sg+RlmUrRDXZTvEbjgGs4yAqMrG+/ofGGu0iOOUUQHrSND1StFwzW/j4h5f031D FmrcP5J113O3mRnIi0zMVfg5cvjMIXtoopVVjxDROBAWNJHbMIU9d4+gPY41vgwaPynUS3Hc1 E87FpHyTO5X1GUNFmF3oWnSsiD3Czc5AGpnjCSZb9szalXQp21B0vY3ZacFMkzspkJouyJZYk 5AIvU2DRM4q5s6r5eQMdAVWuLjnbXnKAyheL5k3YkfnlULMwo7MnAyExaj+Kvpt9DCDEAPHQP b38q/UF4+zNyteJQSQMdqfzezoRr+/OUkqs0FV3YGkbiz2k957drYYz9ZHsh1cqvTnRxJfhb3 7oHxMI/xtfRy6Xw7jtuajPMKvlB98YE8Nv0CYiDbTMGD4biHwlGMRKO/K6DZy8c4YCEC2AYE4 J9CzlsYiz0CPvhu4o9QgxecKif7RK73fBtDEyu5+/ArPo4JxgPmqo0CSedUdElin6NUl963Os XyPGK9CbNefvIyq/DEsIioOigLRWEFYKDonZA7QS5p3emHNniCk0uFVfuCWMZeQMIuUWZIFkq 7ZsNIHL3VApZwQHSk7Q+fMsfqm7X9MCnzm1bwlgVWSzxpquVdXhWkQfbYF2EUxAt17Je2jJrG CJWZS2HzXEgCoDbByrqDt/3mQswRECQ8gzxL2xDxDaBr8NgT4kx/WT2IiWmm2Cl6z//X6yot6 p3nrE4qKbEcqN2SQ9r6W3N/sIRL66toDxoxYfvGiqR606KtoaA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3257 Lines: 111 Am 7. August 2017 13:46:32 MESZ schrieb Nayna Jain : >The TPM burstcount status indicates the number of bytes that can >be sent to the TPM without causing bus wait states. Effectively, >it is the number of empty bytes in the command FIFO. Further, >some TPMs have a static burstcount, when the value remains zero >until the entire FIFO is empty. > >This patch ignores burstcount, permitting wait states, and thus >writes the command as fast as the TPM can accept the bytes. >The performance of a 34 byte extend on a TPM 1.2 improved from >52 msec to 11 msec. > >Suggested-by: Ken Goldman in >conjunction with the TPM Device Driver work group. >Signed-off-by: Nayna Jain >Acked-by: Mimi Zohar Are you sure this is a good idea? On lpc systems this more or less stalls the bus, including keyboard/mouse (if connected via superio lpc). On which systems have you tested this? Spi/Lpc? Architecture? This might not be noticable for small transfers, but think about much larger transfers.... Imho: NACK from my side. Thanks, Peter >--- >drivers/char/tpm/tpm_tis_core.c | 45 >++--------------------------------------- > 1 file changed, 2 insertions(+), 43 deletions(-) > >diff --git a/drivers/char/tpm/tpm_tis_core.c >b/drivers/char/tpm/tpm_tis_core.c >index b617b2eeb080..478cbc0f61c3 100644 >--- a/drivers/char/tpm/tpm_tis_core.c >+++ b/drivers/char/tpm/tpm_tis_core.c >@@ -255,9 +255,7 @@ static int tpm_tis_recv(struct tpm_chip *chip, u8 >*buf, size_t count) >static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t >len) > { > struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); >- int rc, status, burstcnt; >- size_t count = 0; >- bool itpm = priv->flags & TPM_TIS_ITPM_WORKAROUND; >+ int rc, status; > > status = tpm_tis_status(chip); > if ((status & TPM_STS_COMMAND_READY) == 0) { >@@ -270,49 +268,10 @@ static int tpm_tis_send_data(struct tpm_chip >*chip, u8 *buf, size_t len) > } > } > >- while (count < len - 1) { >- burstcnt = get_burstcount(chip); >- if (burstcnt < 0) { >- dev_err(&chip->dev, "Unable to read burstcount\n"); >- rc = burstcnt; >- goto out_err; >- } >- burstcnt = min_t(int, burstcnt, len - count - 1); >- rc = tpm_tis_write_bytes(priv, TPM_DATA_FIFO(priv->locality), >- burstcnt, buf + count); >- if (rc < 0) >- goto out_err; >- >- count += burstcnt; >- >- if (wait_for_tpm_stat(chip, TPM_STS_VALID, chip->timeout_c, >- &priv->int_queue, false) < 0) { >- rc = -ETIME; >- goto out_err; >- } >- status = tpm_tis_status(chip); >- if (!itpm && (status & TPM_STS_DATA_EXPECT) == 0) { >- rc = -EIO; >- goto out_err; >- } >- } >- >- /* write last byte */ >- rc = tpm_tis_write8(priv, TPM_DATA_FIFO(priv->locality), buf[count]); >+ rc = tpm_tis_write_bytes(priv, TPM_DATA_FIFO(priv->locality), len, >buf); > if (rc < 0) > goto out_err; > >- if (wait_for_tpm_stat(chip, TPM_STS_VALID, chip->timeout_c, >- &priv->int_queue, false) < 0) { >- rc = -ETIME; >- goto out_err; >- } >- status = tpm_tis_status(chip); >- if (!itpm && (status & TPM_STS_DATA_EXPECT) != 0) { >- rc = -EIO; >- goto out_err; >- } >- > return 0; > > out_err: -- Sent from my mobile