9e954e3680
Move content from stx-gplv2 into stx-integ Packages will be relocated to stx-integ: base/ bash cgcs-users cluster-resource-agents dpkg haproxy libfdt netpbm rpm database/ mariadb filesystem/ iscsi-initiator-utils filesystem/drbd/ drbd-tools kernel/kernel-modules/ drbd integrity intel-e1000e intel-i40e intel-i40evf intel-ixgbe intel-ixgbevf qat17 tpmdd ldap/ ldapscripts networking/ iptables net-tools Change-Id: I0a9070e35559e5545b14e1fdd933a2ca2e969fd1 Story: 2002801 Task: 22687 Signed-off-by: Scott Little <scott.little@windriver.com>
124 lines
4.1 KiB
Diff
124 lines
4.1 KiB
Diff
From 2e23fe68b72638a1185f6243528f05f7dc665a3a Mon Sep 17 00:00:00 2001
|
|
From: Nayna Jain <nayna@linux.vnet.ibm.com>
|
|
Date: Tue, 14 Nov 2017 11:01:56 -0500
|
|
Subject: [PATCH] tpm: define __wait_for_tpm_stat to specify variable polling
|
|
sleep time
|
|
|
|
The existing wait_for_tpm_stat() checks the chip status before
|
|
sleeping for 5 msec in a polling loop. For some functions although
|
|
the status isn't ready immediately, the status returns extremely
|
|
quickly. Waiting for 5 msec causes an unnecessary delay. An
|
|
example is the send() call in the tpms_tis driver.
|
|
|
|
This patch defines __wait_for_tpm_stat(), allowing the caller
|
|
to specify the polling sleep timeout value within the loop.
|
|
The existing wait_for_tpm_stat() becomes a wrapper for this
|
|
function.
|
|
|
|
After this change, performance on a TPM 1.2 with an 8 byte
|
|
burstcount for 1000 extends improved from ~14sec to ~10sec.
|
|
|
|
Signed-off-by: Nayna Jain <nayna@linux.vnet.ibm.com>
|
|
Acked-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
|
|
---
|
|
tpm-interface.c | 15 ++++++++++++---
|
|
tpm.h | 3 +++
|
|
tpm_tis_core.c | 13 +++++++------
|
|
3 files changed, 22 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/tpm-interface.c b/tpm-interface.c
|
|
index 9971422..69041ec 100644
|
|
--- a/tpm-interface.c
|
|
+++ b/tpm-interface.c
|
|
@@ -1015,8 +1015,9 @@ static bool wait_for_tpm_stat_cond(struct tpm_chip *chip, u8 mask,
|
|
return false;
|
|
}
|
|
|
|
-int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout,
|
|
- wait_queue_head_t *queue, bool check_cancel)
|
|
+int __wait_for_tpm_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout,
|
|
+ unsigned int poll_sleep, wait_queue_head_t *queue,
|
|
+ bool check_cancel)
|
|
{
|
|
unsigned long stop;
|
|
long rc;
|
|
@@ -1050,7 +1051,7 @@ again:
|
|
}
|
|
} else {
|
|
do {
|
|
- tpm_msleep(1);
|
|
+ tpm_msleep(poll_sleep);
|
|
status = chip->ops->status(chip);
|
|
if ((status & mask) == mask)
|
|
return 0;
|
|
@@ -1058,6 +1059,14 @@ again:
|
|
}
|
|
return -ETIME;
|
|
}
|
|
+EXPORT_SYMBOL_GPL(__wait_for_tpm_stat);
|
|
+
|
|
+int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout,
|
|
+ wait_queue_head_t *queue, bool check_cancel)
|
|
+{
|
|
+ return __wait_for_tpm_stat(chip, mask, timeout, TPM_TIMEOUT,
|
|
+ queue, check_cancel);
|
|
+}
|
|
EXPORT_SYMBOL_GPL(wait_for_tpm_stat);
|
|
|
|
#define TPM_ORD_SAVESTATE cpu_to_be32(152)
|
|
diff --git a/tpm.h b/tpm.h
|
|
index 6f3297e..e2c9f06 100644
|
|
--- a/tpm.h
|
|
+++ b/tpm.h
|
|
@@ -545,6 +545,9 @@ int tpm_do_selftest(struct tpm_chip *chip);
|
|
unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal);
|
|
int tpm_pm_suspend(struct device *dev);
|
|
int tpm_pm_resume(struct device *dev);
|
|
+int __wait_for_tpm_stat(struct tpm_chip *chip, u8 mask,
|
|
+ unsigned long timeout, unsigned int poll_sleep,
|
|
+ wait_queue_head_t *queue, bool check_cancel);
|
|
int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout,
|
|
wait_queue_head_t *queue, bool check_cancel);
|
|
|
|
diff --git a/tpm_tis_core.c b/tpm_tis_core.c
|
|
index d87255f..330b1a7 100644
|
|
--- a/tpm_tis_core.c
|
|
+++ b/tpm_tis_core.c
|
|
@@ -262,9 +262,9 @@ static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len)
|
|
status = tpm_tis_status(chip);
|
|
if ((status & TPM_STS_COMMAND_READY) == 0) {
|
|
tpm_tis_ready(chip);
|
|
- if (wait_for_tpm_stat
|
|
- (chip, TPM_STS_COMMAND_READY, chip->timeout_b,
|
|
- &priv->int_queue, false) < 0) {
|
|
+ if (__wait_for_tpm_stat
|
|
+ (chip, TPM_STS_COMMAND_READY, chip->timeout_b, 1,
|
|
+ &priv->int_queue, false) < 0) {
|
|
rc = -ETIME;
|
|
goto out_err;
|
|
}
|
|
@@ -285,7 +285,8 @@ static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len)
|
|
|
|
count += burstcnt;
|
|
|
|
- if (wait_for_tpm_stat(chip, TPM_STS_VALID, chip->timeout_c,
|
|
+ if (__wait_for_tpm_stat(chip, TPM_STS_VALID,
|
|
+ chip->timeout_c, 1,
|
|
&priv->int_queue, false) < 0) {
|
|
rc = -ETIME;
|
|
goto out_err;
|
|
@@ -302,8 +303,8 @@ static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len)
|
|
if (rc < 0)
|
|
goto out_err;
|
|
|
|
- if (wait_for_tpm_stat(chip, TPM_STS_VALID, chip->timeout_c,
|
|
- &priv->int_queue, false) < 0) {
|
|
+ if (__wait_for_tpm_stat(chip, TPM_STS_VALID, chip->timeout_c,
|
|
+ 1, &priv->int_queue, false) < 0) {
|
|
rc = -ETIME;
|
|
goto out_err;
|
|
}
|
|
--
|
|
1.8.3.1
|
|
|