tpm: separate cmd_ready/go_idle from runtime_pm
Subsystems (3)
PATCH v4 1/1 tpm: separate cmd_ready/go_idle from runtime_pm
From: "Winkler, Tomas" <[email protected]>
We cannot use go_idle cmd_ready commands via runtime_pm handles as with the introduction of localities this is no longer an optional feature, while runtime pm can be not enabled.
Though cmd_ready/go_idle provides power saving feature, it's also part of TPM2 protocol and should be called explicitly.
This patch exposes cmd_read/go_idle via tpm class ops and removes runtime pm support as it is not used by any driver.
tpm_crb no longer needs own power saving functions and can drop using tpm_pm_suspend/resume.
---
V2-3:resent
V4: 1. Use tpm_pm_suspend/resume in tpm_crb
2. Drop cmd_ready/go_idle around tpm_chip_register, as there is no usage counter like in runtime_pm.
drivers/char/tpm/tpm-interface.c | 15 ++++-- drivers/char/tpm/tpm_crb.c | 100 ++++++++++----------------------------- include/linux/tpm.h | 2 + 3 files changed, 38 insertions(+), 79 deletions(-)
drivers/char/tpm/tpm-interface.c +10 -5
@@ -29,7 +29,6 @@#include <linux/mutex.h> #include <linux/spinlock.h> #include <linux/freezer.h> -#include <linux/pm_runtime.h> #include <linux/tpm_eventlog.h> #include "tpm.h"
@@ -455,8 +454,11 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip, goto out_no_locality; } -if (chip->dev.parent) -pm_runtime_get_sync (chip->dev.parent); +if (chip->ops->cmd_ready) { + rc = chip->ops->cmd_ready (chip); +if (rc) + goto out; + } rc =tpm2_prepare_space (chip, space, ordinal, buf);if (rc)
@@ -518,8 +520,11 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip, rc =tpm2_commit_space (chip, space, ordinal, buf, &len); out: -if (chip->dev.parent) -pm_runtime_put_sync (chip->dev.parent); +if (chip->ops->go_idle) { + rc = chip->ops->go_idle (chip); +if (rc) + goto out; + }if (need_locality)tpm_relinquish_locality (chip);
drivers/char/tpm/tpm_crb.c +26 -74
165 lines not on this page · raw message
include/linux/tpm.h +2 -0
@@ -43,6 +43,8 @@ struct tpm_class_ops {u8 (*status) (struct tpm_chip *chip);bool (*update_timeouts)(struct tpm_chip *chip,unsigned long *timeout_cap); +int (*go_idle)(struct tpm_chip *chip); +int (*cmd_ready)(struct tpm_chip *chip);int (*request_locality)(struct tpm_chip *chip,int loc);int (*relinquish_locality)(struct tpm_chip *chip,int loc);void (*clk_enable)(struct tpm_chip *chip,bool value);
Signature · 6 lines
2.14.3 -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 10 lines · Tomas Winkler
From: "Winkler, Tomas" <[email protected]>
We cannot use
go_idlecmd_readycommands viaruntime_pmhandles as with the introduction of localities this is no longer an optional feature, while runtime pm can be not enabled.
Though cmd_ready/go_idle provides power saving feature, it's also part of TPM2 protocol and should be called explicitly.
This patch exposes cmd_read/go_idle via tpm class ops and removes runtime pm support as it is not used by any driver.
Quoted 4 lines
tpm_crbno longer needs own power saving functions and can drop using tpm_pm_suspend/resume.Signed-off-by Tomas Winkler <[email protected]>
Still fails on Kabylake exactly the same way. With this I get RC_UNBALANCED in these four test cases:
test_flush_context (tpm2_smoke.SpaceTest) ... ERROR test_get_handles (tpm2_smoke.SpaceTest) ... ERROR test_make_two_spaces (tpm2_smoke.SpaceTest) ... ERROR
Without this patch applied these errors do not occur.
/Jarkko
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html