@@ -28,6 +28,16 @@ void tpm_backend_cmd_completed(TPMBackend *s)
qemu_mutex_unlock(&s->state_lock);
}
+void tpm_backend_wait_cmd_completed(TPMBackend *s)
+{
+ qemu_mutex_lock(&s->state_lock);
+
+ if (s->tpm_busy) {
+ qemu_cond_wait(&s->cmd_complete, &s->state_lock);
+ }
+ qemu_mutex_unlock(&s->state_lock);
+}
+
static void tpm_backend_request_completed_bh(void *opaque)
{
TPMBackend *s = TPM_BACKEND(opaque);
@@ -207,6 +207,14 @@ TPMInfo *tpm_backend_query_tpm(TPMBackend *s);
*/
void tpm_backend_cmd_completed(TPMBackend *s);
+/**
+ * tpm_backend_wait_cmd_completed:
+ * @s: the backend
+ *
+ * Wait the backend to not be busy anymore
+ */
+void tpm_backend_wait_cmd_completed(TPMBackend *s);
+
TPMBackend *qemu_find_tpm_be(const char *id);
void tpm_register_model(enum TpmModel model);
Implement tpm_backend_wait_cmd_completed to synchronize with the backend (thread) for the completion of a command. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com> --- backends/tpm.c | 10 ++++++++++ include/sysemu/tpm_backend.h | 8 ++++++++ 2 files changed, 18 insertions(+)