The comment above the wmb() in tpm_pm_resume() states that the barrier
guarantees TPM_CHIP_FLAG_SUSPENDED is written last, so that hwrng does
not activate before the chip has been fully resumed.  It cannot do so:
it is placed after the store that clears the flag, and therefore does
not order the preceding resume work before that store.  It also has
nothing to pair with, as tpm_try_get_ops() contains no matching read
barrier.

Drop the barrier along with the comment rather than leave a no-op
behind.  Should such ordering turn out to be needed, it would require
paired barriers or locking.

Link: 
https://lore.kernel.org/all/[email protected]/
Signed-off-by: Richard Lyu <[email protected]>

---
v2:
- Drop the Fixes tag: this is a cleanup, not a bug fix.
- Link to v1: https://lore.kernel.org/all/aqIVn0cDBvIYKggE@r1chard/
---
 drivers/char/tpm/tpm-interface.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index b4e749e70b02..0bab78c8767c 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -497,12 +497,6 @@ int tpm_pm_resume(struct device *dev)
 
        chip->flags &= ~TPM_CHIP_FLAG_SUSPENDED;
 
-       /*
-        * Guarantee that SUSPENDED is written last, so that hwrng does not
-        * activate before the chip has been fully resumed.
-        */
-       wmb();
-
        return 0;
 }
 EXPORT_SYMBOL_GPL(tpm_pm_resume);
-- 
2.51.0


Reply via email to