aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/tpm/tpm_tis.c
diff options
context:
space:
mode:
authorStefan Berger <stefanb@linux.vnet.ibm.com>2013-01-22 14:52:35 -0500
committerKent Yoder <key@linux.vnet.ibm.com>2013-02-05 10:38:24 -0500
commit1f866057291fc00f14e4962473bd7724ffa8f578 (patch)
treeea780b029f24530a32913fa983a60f1a01a4d0d4 /drivers/char/tpm/tpm_tis.c
parent3e3a5e906998b090ad929010a5f5082ac0dbbdfb (diff)
tpm: Fix cancellation of TPM commands (polling mode)
On one of my machines the cancellation of TPM commands does not work. The reason is that by writing into sysfs 'cancel' the tpm_tis_ready call causes the status flag TPM_STS_VALID to be set in the statusregister. However, the TIS driver seems to wait for TPM_STS_COMMAND_READY. Once a 2nd time sysfs 'cancel' is written to, the TPM_STS_COMMAND_READY flag also gets set, resulting in TPM_STS_VALID|TPM_STS_COMMAND_READY to be read from the status register. This patch now converts req_canceled into a function to enable more complex comparisons against possible cancellation status codes. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
Diffstat (limited to 'drivers/char/tpm/tpm_tis.c')
-rw-r--r--drivers/char/tpm/tpm_tis.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 3615d210e603..e4e0c65df768 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -400,6 +400,19 @@ out:
400 return rc; 400 return rc;
401} 401}
402 402
403static bool tpm_tis_req_canceled(struct tpm_chip *chip, u8 status)
404{
405 switch (chip->vendor.manufacturer_id) {
406 case TPM_VID_WINBOND:
407 return ((status == TPM_STS_VALID) ||
408 (status == (TPM_STS_VALID | TPM_STS_COMMAND_READY)));
409 case TPM_VID_STM:
410 return (status == (TPM_STS_VALID | TPM_STS_COMMAND_READY));
411 default:
412 return (status == TPM_STS_COMMAND_READY);
413 }
414}
415
403static const struct file_operations tis_ops = { 416static const struct file_operations tis_ops = {
404 .owner = THIS_MODULE, 417 .owner = THIS_MODULE,
405 .llseek = no_llseek, 418 .llseek = no_llseek,
@@ -445,7 +458,7 @@ static struct tpm_vendor_specific tpm_tis = {
445 .cancel = tpm_tis_ready, 458 .cancel = tpm_tis_ready,
446 .req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID, 459 .req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID,
447 .req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID, 460 .req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID,
448 .req_canceled = TPM_STS_COMMAND_READY, 461 .req_canceled = tpm_tis_req_canceled,
449 .attr_group = &tis_attr_grp, 462 .attr_group = &tis_attr_grp,
450 .miscdev = { 463 .miscdev = {
451 .fops = &tis_ops,}, 464 .fops = &tis_ops,},