All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Stefan Berger <stefanb@linux.vnet.ibm.com>
Cc: imammedo@redhat.com, qemu-devel@nongnu.org, quan.xu@intel.com
Subject: Re: [Qemu-devel] [PATCH v3 4/6] Introduce condition to notifiy waiters of completed command
Date: Sun, 31 May 2015 20:11:42 +0200	[thread overview]
Message-ID: <20150531181142.GG5268@redhat.com> (raw)
In-Reply-To: <1432676024-1046793-5-git-send-email-stefanb@linux.vnet.ibm.com>

Typo in subject.

On Tue, May 26, 2015 at 05:33:42PM -0400, Stefan Berger wrote:
> Introduce a lock and a condition to notify anyone waiting for the completion
> of the execution of a TPM command by the backend (thread). The backend
> uses the condition to signal anyone waiting for command completion.
> We need to place the condition in two locations: one is invoked by the
> backend thread, the other by the bottom half thread.
> We will use the signalling to wait for command completion before VM
> suspend.
> 
> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
> ---
>  hw/tpm/tpm_int.h |  3 +++
>  hw/tpm/tpm_tis.c | 14 ++++++++++++++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/hw/tpm/tpm_int.h b/hw/tpm/tpm_int.h
> index 6b2c9c9..70be1ad 100644
> --- a/hw/tpm/tpm_int.h
> +++ b/hw/tpm/tpm_int.h
> @@ -30,6 +30,9 @@ struct TPMState {
>      char *backend;
>      TPMBackend *be_driver;
>      TPMVersion be_tpm_version;
> +
> +    QemuMutex state_lock;
> +    QemuCond cmd_complete;
>  };
>  
>  #define TPM(obj) OBJECT_CHECK(TPMState, (obj), TYPE_TPM_TIS)
> diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
> index 1fb4e17..f278e1e 100644
> --- a/hw/tpm/tpm_tis.c
> +++ b/hw/tpm/tpm_tis.c
> @@ -367,6 +367,8 @@ static void tpm_tis_receive_bh(void *opaque)
>      TPMTISEmuState *tis = &s->s.tis;
>      uint8_t locty = s->locty_number;
>  
> +    qemu_mutex_lock(&s->state_lock);
> +
>      tpm_tis_sts_set(&tis->loc[locty],
>                      TPM_TIS_STS_VALID | TPM_TIS_STS_DATA_AVAILABLE);
>      tis->loc[locty].state = TPM_TIS_STATE_COMPLETION;
> @@ -383,6 +385,10 @@ static void tpm_tis_receive_bh(void *opaque)
>      tpm_tis_raise_irq(s, locty,
>                        TPM_TIS_INT_DATA_AVAILABLE | TPM_TIS_INT_STS_VALID);
>  #endif
> +
> +    /* notify of completed command */
> +    qemu_cond_signal(&s->cmd_complete);
> +    qemu_mutex_unlock(&s->state_lock);
>  }
>  
>  /*
> @@ -402,6 +408,11 @@ static void tpm_tis_receive_cb(TPMState *s, uint8_t locty,
>          }
>      }
>  
> +    qemu_mutex_lock(&s->state_lock);
> +    /* notify of completed command */
> +    qemu_cond_signal(&s->cmd_complete);
> +    qemu_mutex_unlock(&s->state_lock);
> +
>      qemu_bh_schedule(tis->bh);
>  }
>  
> @@ -1097,6 +1108,9 @@ static void tpm_tis_initfn(Object *obj)
>      memory_region_init_io(&s->mmio, OBJECT(s), &tpm_tis_memory_ops,
>                            s, "tpm-tis-mmio",
>                            TPM_TIS_NUM_LOCALITIES << TPM_TIS_LOCALITY_SHIFT);
> +
> +    qemu_mutex_init(&s->state_lock);
> +    qemu_cond_init(&s->cmd_complete);
>  }
>  
>  static void tpm_tis_class_init(ObjectClass *klass, void *data)
> -- 
> 1.9.3
> 

  reply	other threads:[~2015-05-31 18:11 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-26 21:33 [Qemu-devel] [PATCH v3 0/6] Extend TPM support with a QEMU-external TPM Stefan Berger
2015-05-26 21:33 ` [Qemu-devel] [PATCH v3 1/6] Provide support for the CUSE TPM Stefan Berger
2015-05-26 23:05   ` Eric Blake
2015-05-27  1:53     ` Stefan Berger
2015-05-26 21:33 ` [Qemu-devel] [PATCH v3 2/6] Introduce RAM location in vendor specific area in TIS Stefan Berger
2015-05-26 21:33 ` [Qemu-devel] [PATCH v3 3/6] Support Physical Presence Interface Spec Stefan Berger
2015-05-31 18:11   ` Michael S. Tsirkin
2015-06-02  3:11     ` Stefan Berger
2015-06-02  9:15       ` Michael S. Tsirkin
2015-06-02 13:22         ` Stefan Berger
2015-06-02 13:30           ` Michael S. Tsirkin
2015-06-02 14:28             ` Stefan Berger
2015-06-02 14:46               ` Michael S. Tsirkin
2015-06-02 15:06                 ` Stefan Berger
2015-06-02 15:11                   ` Michael S. Tsirkin
2015-06-02 16:28                     ` Stefan Berger
2015-06-02 15:18                 ` Kevin O'Connor
2015-06-02 16:18                   ` Stefan Berger
2015-06-02 15:00               ` Michael S. Tsirkin
2015-05-26 21:33 ` [Qemu-devel] [PATCH v3 4/6] Introduce condition to notifiy waiters of completed command Stefan Berger
2015-05-31 18:11   ` Michael S. Tsirkin [this message]
2015-05-26 21:33 ` [Qemu-devel] [PATCH v3 5/6] Introduce condition in TPM backend for notification Stefan Berger
2015-05-26 21:33 ` [Qemu-devel] [PATCH v3 6/6] Add support for VM suspend/resume for TPM TIS Stefan Berger
2015-05-31 18:11 ` [Qemu-devel] [PATCH v3 0/6] Extend TPM support with a QEMU-external TPM Michael S. Tsirkin
2015-06-02 13:17   ` 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=20150531181142.GG5268@redhat.com \
    --to=mst@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quan.xu@intel.com \
    --cc=stefanb@linux.vnet.ibm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.