Received: by 10.223.164.221 with SMTP id h29csp2735993wrb; Wed, 18 Oct 2017 06:10:33 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RydbdDp3oxCPP7+Rv6tA5MP8a845wLLwFYNXj7XWZBYcuzXqz2oaTENt58PMwiUUY3D42e X-Received: by 10.159.254.20 with SMTP id r20mr2570189pls.443.1508332233319; Wed, 18 Oct 2017 06:10:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508332233; cv=none; d=google.com; s=arc-20160816; b=g+FglnK332m1whOlUhXtFJQxOiWlZpycB8oSA/IuWIQR5CZAPCbx50Fqy1ulC9Acqx ERVG4/SCInq1VtrMn8G6RoEgFhvNu+6le8zW2coa4+nQLFhW1w/1Hg+2dczgqBxdzP0g GYwtLAUeH+Ml5/tFm7+mYZaoprY5DDq6Iv9Edlrpz9/tmyTy6CIOSVrSnEOYjmN25VDl FrN0v454o2KAQ7Gg7Z8kjdAhsIpdUKTH0kfKRn0h05KTXzfetMACJaUUXE8KXbkUNzha fCChGxNJR+EL3lSALsWVWw60CPRBsTBBhpcjIlFlsZpI4BgGXQorvUr4yz9SGBZp4LBC TuVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=fFaMBksA+qP0K0L31nMx/72D2zBYGqK7/579jxFji2M=; b=cGGq1jOgdVYLMIpuVYHR1GG6Eh8KCNMPvfHEDsepAiOP1qGTppDF2y72WsmO/6fBi3 E7oQbKAOwHv0EYhmW6KuHqFfJ6RcKaVFswBhgNdS1Lvu5zfRYTXiM4L5ayrsIcoNZkg7 3JmhOhOM9YOeSpRgVdndXMm4y0EvEzNhzr8aQGZaptbc7TcBy7FdUj68kd4+9pHwIkzD jw3zv0/7YnchC+Q+js8OZ+/7PT8j9LveiUshiwJ4rpV3TO8HAIVjcPP5bSwVoh1f9Fmh 4MoKErTo9kY0Xex90oHNxmNt4kYibTQu4eRJhhNjjWBbF147AKVOYhVBAO7viGMGBon5 YBVA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m63si1407208pld.191.2017.10.18.06.10.18; Wed, 18 Oct 2017 06:10:33 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934756AbdJQUdD (ORCPT + 99 others); Tue, 17 Oct 2017 16:33:03 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:50522 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934849AbdJQUc5 (ORCPT ); Tue, 17 Oct 2017 16:32:57 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9HKTWeB089799 for ; Tue, 17 Oct 2017 16:32:57 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 2dnk4whsrn-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 17 Oct 2017 16:32:57 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 17 Oct 2017 21:32:54 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 17 Oct 2017 21:32:52 +0100 Received: from d23av05.au.ibm.com (d23av05.au.ibm.com [9.190.234.119]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v9HKWnHS11993306; Tue, 17 Oct 2017 20:32:51 GMT Received: from d23av05.au.ibm.com (localhost [127.0.0.1]) by d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v9HKWmCc028484; Wed, 18 Oct 2017 07:32:49 +1100 Received: from dhcp-9-60-73-198.endicott.ibm.com (dhcp-9-60-73-198.endicott.ibm.com [9.60.73.198]) by d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v9HKWaMv028254; Wed, 18 Oct 2017 07:32:46 +1100 From: Nayna Jain To: linux-integrity@vger.kernel.org Cc: zohar@linux.vnet.ibm.com, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, peterhuewe@gmx.de, jarkko.sakkinen@linux.intel.com, tpmdd@selhorst.net, jgunthorpe@obsidianresearch.com, patrickc@us.ibm.com, Nayna Jain Subject: [PATCH v4 2/4] tpm: ignore burstcount to improve tpm_tis send() performance Date: Tue, 17 Oct 2017 16:32:30 -0400 X-Mailer: git-send-email 2.13.3 In-Reply-To: <20171017203232.2262-1-nayna@linux.vnet.ibm.com> References: <20171017203232.2262-1-nayna@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17101720-0040-0000-0000-00000403C935 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17101720-0041-0000-0000-000020A615D2 Message-Id: <20171017203232.2262-3-nayna@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-10-17_14:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=5 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710170289 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. This patch optimizes the tpm_tis_send_data() function by checking the burstcount only once. And if the burstcount is valid, it writes all the bytes at once, permitting wait state. After this change, performance on a TPM 1.2 with an 8 byte burstcount for 1000 extends improved from ~41sec to ~14sec. Suggested-by: Ken Goldman in conjunction with the TPM Device Driver work group. Signed-off-by: Nayna Jain Acked-by: Mimi Zohar --- drivers/char/tpm/tpm_tis_core.c | 42 +++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index b33126a35694..993328ae988c 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -316,7 +316,6 @@ 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; status = tpm_tis_status(chip); @@ -330,35 +329,24 @@ 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; - } + /* + * Get the initial burstcount to ensure TPM is ready to + * accept data. + */ + burstcnt = get_burstcount(chip); + if (burstcnt < 0) { + dev_err(&chip->dev, "Unable to read burstcount\n"); + rc = burstcnt; + goto out_err; } + rc = tpm_tis_write_bytes(priv, TPM_DATA_FIFO(priv->locality), + len - 1, buf); + if (rc < 0) + goto out_err; + /* write last byte */ - rc = tpm_tis_write8(priv, TPM_DATA_FIFO(priv->locality), buf[count]); + rc = tpm_tis_write8(priv, TPM_DATA_FIFO(priv->locality), buf[len-1]); if (rc < 0) goto out_err; -- 2.13.3 From 1585322676526363509@xxx Tue Nov 28 15:05:19 +0000 2017 X-GM-THRID: 1585322676526363509 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread