[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] tpm: Move memory initialization into realize fu
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH] tpm: Move memory initialization into realize function |
Date: |
Tue, 10 Mar 2015 10:35:35 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 |
On 10/03/2015 00:51, Stefan Berger wrote:
> From: Stefan Berger <address@hidden>
>
> Move the memory initialization into the DeviceClass realize function due to
> isa_address_space crashing if called in the instance init function.
> A recent change must have changed the order in which structures are
> initialized so that this move is now necessary.
>
> Signed-off-by: Stefan Berger <address@hidden>
> ---
> hw/tpm/tpm_tis.c | 11 ++---------
> 1 file changed, 2 insertions(+), 9 deletions(-)
>
> diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
> index d0bb97f..339e1bf 100644
> --- a/hw/tpm/tpm_tis.c
> +++ b/hw/tpm/tpm_tis.c
> @@ -959,18 +959,12 @@ static void tpm_tis_realizefn(DeviceState *dev, Error
> **errp)
> tis->bh = qemu_bh_new(tpm_tis_receive_bh, s);
>
> isa_init_irq(&s->busdev, &tis->irq, tis->irq_num);
> -}
> -
> -static void tpm_tis_initfn(Object *obj)
> -{
> - ISADevice *dev = ISA_DEVICE(obj);
> - TPMState *s = TPM(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);
> - memory_region_add_subregion(isa_address_space(dev), TPM_TIS_ADDR_BASE,
> - &s->mmio);
> + memory_region_add_subregion(isa_address_space(ISA_DEVICE(dev)),
> + TPM_TIS_ADDR_BASE, &s->mmio);
> }
Please leave memory_region_init_io in the instance_init function, though.
Thanks,
Paolo
> static void tpm_tis_class_init(ObjectClass *klass, void *data)
> @@ -987,7 +981,6 @@ static const TypeInfo tpm_tis_info = {
> .name = TYPE_TPM_TIS,
> .parent = TYPE_ISA_DEVICE,
> .instance_size = sizeof(TPMState),
> - .instance_init = tpm_tis_initfn,
> .class_init = tpm_tis_class_init,
> };
>
>