qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Marc-Andre Lureau <mlureau@redhat.com>
To: Stefan Berger <stefanb@linux.vnet.ibm.com>
Cc: qemu-devel <qemu-devel@nongnu.org>,
	marcandre <marcandre.lureau@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/4] tpm: Split off tpm_crb_reset function
Date: Sat, 3 Feb 2018 14:10:40 +0100	[thread overview]
Message-ID: <CAMxuvazxwHXAPOb6OrznHWpO9JumVCS3obKAwGu80OdopFNdLw@mail.gmail.com> (raw)
In-Reply-To: <1517582668-10923-2-git-send-email-stefanb@linux.vnet.ibm.com>

On Fri, Feb 2, 2018 at 3:44 PM, Stefan Berger
<stefanb@linux.vnet.ibm.com> wrote:
> Split off the tpm_crb_reset function part from tpm_crb_realize
> that we need to run every time the machine resets.
>
> Also register our reset function with the system since TYPE_DEVICE
> seems to not get a reset otherwise.
>
> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


>
> ---
>  v1->v2: register reset function with qemu_register_reset since
>          TYPE_DEVICE seems to not get a reset otherwise
> ---
>  hw/tpm/tpm_crb.c | 48 ++++++++++++++++++++++++++++--------------------
>  1 file changed, 28 insertions(+), 20 deletions(-)
>
> diff --git a/hw/tpm/tpm_crb.c b/hw/tpm/tpm_crb.c
> index 687d255..b5b8256 100644
> --- a/hw/tpm/tpm_crb.c
> +++ b/hw/tpm/tpm_crb.c
> @@ -26,6 +26,7 @@
>  #include "hw/acpi/tpm.h"
>  #include "migration/vmstate.h"
>  #include "sysemu/tpm_backend.h"
> +#include "sysemu/reset.h"
>  #include "tpm_int.h"
>  #include "tpm_util.h"
>
> @@ -210,29 +211,10 @@ static Property tpm_crb_properties[] = {
>      DEFINE_PROP_END_OF_LIST(),
>  };
>
> -static void tpm_crb_realize(DeviceState *dev, Error **errp)
> +static void tpm_crb_reset(void *dev)
>  {
>      CRBState *s = CRB(dev);
>
> -    if (!tpm_find()) {
> -        error_setg(errp, "at most one TPM device is permitted");
> -        return;
> -    }
> -    if (!s->tpmbe) {
> -        error_setg(errp, "'tpmdev' property is required");
> -        return;
> -    }
> -
> -    memory_region_init_io(&s->mmio, OBJECT(s), &tpm_crb_memory_ops, s,
> -        "tpm-crb-mmio", sizeof(s->regs));
> -    memory_region_init_ram(&s->cmdmem, OBJECT(s),
> -        "tpm-crb-cmd", CRB_CTRL_CMD_SIZE, errp);
> -
> -    memory_region_add_subregion(get_system_memory(),
> -        TPM_CRB_ADDR_BASE, &s->mmio);
> -    memory_region_add_subregion(get_system_memory(),
> -        TPM_CRB_ADDR_BASE + sizeof(s->regs), &s->cmdmem);
> -
>      tpm_backend_reset(s->tpmbe);
>
>      ARRAY_FIELD_DP32(s->regs, CRB_INTF_ID,
> @@ -267,6 +249,32 @@ static void tpm_crb_realize(DeviceState *dev, Error **errp)
>      tpm_backend_startup_tpm(s->tpmbe, s->be_buffer_size);
>  }
>
> +static void tpm_crb_realize(DeviceState *dev, Error **errp)
> +{
> +    CRBState *s = CRB(dev);
> +
> +    if (!tpm_find()) {
> +        error_setg(errp, "at most one TPM device is permitted");
> +        return;
> +    }
> +    if (!s->tpmbe) {
> +        error_setg(errp, "'tpmdev' property is required");
> +        return;
> +    }
> +
> +    memory_region_init_io(&s->mmio, OBJECT(s), &tpm_crb_memory_ops, s,
> +        "tpm-crb-mmio", sizeof(s->regs));
> +    memory_region_init_ram(&s->cmdmem, OBJECT(s),
> +        "tpm-crb-cmd", CRB_CTRL_CMD_SIZE, errp);
> +
> +    memory_region_add_subregion(get_system_memory(),
> +        TPM_CRB_ADDR_BASE, &s->mmio);
> +    memory_region_add_subregion(get_system_memory(),
> +        TPM_CRB_ADDR_BASE + sizeof(s->regs), &s->cmdmem);
> +
> +    qemu_register_reset(tpm_crb_reset, dev);
> +}
> +
>  static void tpm_crb_class_init(ObjectClass *klass, void *data)
>  {
>      DeviceClass *dc = DEVICE_CLASS(klass);
> --
> 2.5.5
>

  reply	other threads:[~2018-02-03 13:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-02 14:44 [Qemu-devel] [PATCH 0/4] tpm: A fix and cleanups Stefan Berger
2018-02-02 14:44 ` [Qemu-devel] [PATCH 1/4] tpm: Split off tpm_crb_reset function Stefan Berger
2018-02-03 13:10   ` Marc-Andre Lureau [this message]
2018-02-02 14:44 ` [Qemu-devel] [PATCH 2/4] tpm: wrap stX_be_p in tpm_cmd_set_XYZ functions Stefan Berger
2018-02-02 14:44 ` [Qemu-devel] [PATCH 3/4] MAINTAINERS: add pointer to tpm-next repository Stefan Berger
2018-02-02 15:09   ` Eric Blake
2018-02-03 13:11   ` Marc-Andre Lureau
2018-02-02 14:44 ` [Qemu-devel] [PATCH 4/4] tpm: tis: move one-line function into caller 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=CAMxuvazxwHXAPOb6OrznHWpO9JumVCS3obKAwGu80OdopFNdLw@mail.gmail.com \
    --to=mlureau@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --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 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).