From: Stefan Berger <stefanb@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: amarnath.valluri@intel.com, marcandre.lureau@gmail.com,
Stefan Berger <stefanb@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH v2 3/7] tpm: implement tpm_backend_wait_cmd_completed
Date: Fri, 27 Oct 2017 19:02:37 -0400 [thread overview]
Message-ID: <1509145361-11218-4-git-send-email-stefanb@linux.vnet.ibm.com> (raw)
In-Reply-To: <1509145361-11218-1-git-send-email-stefanb@linux.vnet.ibm.com>
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(+)
diff --git a/backends/tpm.c b/backends/tpm.c
index 2f60166..6e26832 100644
--- a/backends/tpm.c
+++ b/backends/tpm.c
@@ -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);
diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h
index e08c51d..8c271f4 100644
--- a/include/sysemu/tpm_backend.h
+++ b/include/sysemu/tpm_backend.h
@@ -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);
--
2.5.5
next prev parent reply other threads:[~2017-10-27 23:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-27 23:02 [Qemu-devel] [PATCH v2 0/7] tpm: Extend TPM with state migration support Stefan Berger
2017-10-27 23:02 ` [Qemu-devel] [PATCH v2 1/7] tpm: Introduce condition to notify waiters of completed command Stefan Berger
2017-10-27 23:02 ` [Qemu-devel] [PATCH v2 2/7] tpm: Introduce condition in TPM backend for notification Stefan Berger
2017-10-27 23:02 ` Stefan Berger [this message]
2017-10-27 23:02 ` [Qemu-devel] [PATCH v2 4/7] tpm: Implement tpm_sized_buffer_reset Stefan Berger
2017-10-27 23:02 ` [Qemu-devel] [PATCH v2 5/7] tpm: extend TPM emulator with state migration support Stefan Berger
2017-10-27 23:02 ` [Qemu-devel] [PATCH v2 6/7] tpm: extend TPM TIS " Stefan Berger
2017-10-27 23:02 ` [Qemu-devel] [PATCH v2 7/7] tpm: extend TPM CRB " Stefan Berger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1509145361-11218-4-git-send-email-stefanb@linux.vnet.ibm.com \
--to=stefanb@linux.vnet.ibm.com \
--cc=amarnath.valluri@intel.com \
--cc=marcandre.lureau@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).