qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH RFC 07/15] timer/arm_mptimer: Convert to QOM realize
Date: Sat, 06 Jul 2013 15:28:52 +0200	[thread overview]
Message-ID: <51D81B94.6060002@suse.de> (raw)
In-Reply-To: <CAEgOgz5r14+jfLaf-5xEE=hmXek0uvAikM0Ss4N1cf-DN5fw5g@mail.gmail.com>

Am 01.07.2013 11:33, schrieb Peter Crosthwaite:
> Hi Andreas,
> 
> On Mon, Jul 1, 2013 at 7:00 AM, Andreas Färber <afaerber@suse.de> wrote:
>> From: Andreas Färber <andreas.faerber@web.de>
>>
>> Split the SysBusDevice initfn into instance_init and realizefn.
>>
>> Signed-off-by: Andreas Färber <andreas.faerber@web.de>
>> ---
>>  hw/timer/arm_mptimer.c | 25 +++++++++++++++----------
>>  1 file changed, 15 insertions(+), 10 deletions(-)
>>
>> diff --git a/hw/timer/arm_mptimer.c b/hw/timer/arm_mptimer.c
>> index 588e34b..a19ffa3 100644
>> --- a/hw/timer/arm_mptimer.c
>> +++ b/hw/timer/arm_mptimer.c
>> @@ -226,8 +226,18 @@ static void arm_mptimer_reset(DeviceState *dev)
>>      }
>>  }
>>
>> -static int arm_mptimer_init(SysBusDevice *dev)
>> +static void arm_mptimer_init(Object *obj)
>>  {
>> +    ARMMPTimerState *s = ARM_MP_TIMER(obj);
>> +
>> +    memory_region_init_io(&s->iomem, &arm_thistimer_ops, s,
>> +                          "arm_mptimer_timer", 0x20);
>> +    sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem);
>> +}
> 
> Splitting off only one of the memory region setups to init seems a bit
> awkward. Is it really worth it given that we need to wait for
> realization for the rest to occur anyway?

Well, my main interest wrt MemoryRegions here is to have the
*mpcore_priv container MemoryRegion mappable before realize and to avoid
having to implement unnecessary cleanups in unrealize.

An alternative would be for PMM to use his array properties to
dynamically allocate the MemoryRegions before realize, but so far he has
failed to come up with a solution...
Another solution, since this is a fixed-length array, would be to always
initialize all MemoryRegions and just keep adding all 3(?) in realize.

FWIU adding subregions is desired in instance_init as long as it affects
only containing devices and not a global address space.

Regards,
Andreas

>> +
>> +static void arm_mptimer_realize(DeviceState *dev, Error **errp)
>> +{
>> +    SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
>>      ARMMPTimerState *s = ARM_MP_TIMER(dev);
>>      int i;
>>
>> @@ -244,19 +254,14 @@ static int arm_mptimer_init(SysBusDevice *dev)
>>       *  * timer for core 1
>>       * and so on.
>>       */
>> -    memory_region_init_io(&s->iomem, &arm_thistimer_ops, s,
>> -                          "arm_mptimer_timer", 0x20);
>> -    sysbus_init_mmio(dev, &s->iomem);
>>      for (i = 0; i < s->num_cpu; i++) {
>>          TimerBlock *tb = &s->timerblock[i];
>>          tb->timer = qemu_new_timer_ns(vm_clock, timerblock_tick, tb);
>> -        sysbus_init_irq(dev, &tb->irq);
>> +        sysbus_init_irq(sbd, &tb->irq);
>>          memory_region_init_io(&tb->iomem, &timerblock_ops, tb,
>>                                "arm_mptimer_timerblock", 0x20);
>> -        sysbus_init_mmio(dev, &tb->iomem);
>> +        sysbus_init_mmio(sbd, &tb->iomem);
>>      }
>> -
>> -    return 0;
>>  }
>>
>>  static const VMStateDescription vmstate_timerblock = {
>> @@ -293,9 +298,8 @@ static Property arm_mptimer_properties[] = {
>>  static void arm_mptimer_class_init(ObjectClass *klass, void *data)
>>  {
>>      DeviceClass *dc = DEVICE_CLASS(klass);
>> -    SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
>>
>> -    sbc->init = arm_mptimer_init;
>> +    dc->realize = arm_mptimer_realize;
>>      dc->vmsd = &vmstate_arm_mptimer;
>>      dc->reset = arm_mptimer_reset;
>>      dc->no_user = 1;
>> @@ -306,6 +310,7 @@ static const TypeInfo arm_mptimer_info = {
>>      .name          = TYPE_ARM_MP_TIMER,
>>      .parent        = TYPE_SYS_BUS_DEVICE,
>>      .instance_size = sizeof(ARMMPTimerState),
>> +    .instance_init = arm_mptimer_init,
>>      .class_init    = arm_mptimer_class_init,
>>  };
>>
>> --
>> 1.8.1.4
>>
>>


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

  reply	other threads:[~2013-07-06 13:29 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-30 21:00 [Qemu-devel] [PATCH RFC 00/15] arm: A9MPCore+A15MPCore QOM'ification Andreas Färber
2013-06-30 21:00 ` [Qemu-devel] [PATCH RFC 01/15] cpu/a9mpcore: QOM casting cleanup Andreas Färber
2013-07-01  9:17   ` Peter Crosthwaite
2013-06-30 21:00 ` [Qemu-devel] [PATCH RFC 02/15] cpu/a9mpcore: Split off instance_init Andreas Färber
2013-06-30 21:00 ` [Qemu-devel] [PATCH RFC 03/15] cpu/a9mpcore: Embed GICState Andreas Färber
2013-06-30 22:13   ` Peter Maydell
2013-07-06 14:43     ` Andreas Färber
2013-06-30 21:00 ` [Qemu-devel] [PATCH RFC 04/15] misc/a9scu: QOM cleanups Andreas Färber
2013-07-01  9:25   ` Peter Crosthwaite
2013-06-30 21:00 ` [Qemu-devel] [PATCH RFC 05/15] cpu/a9mpcore: Embed A9SCUState Andreas Färber
2013-06-30 21:00 ` [Qemu-devel] [PATCH RFC 06/15] timer/arm_mptimer: QOM cast cleanup Andreas Färber
2013-07-01  9:29   ` Peter Crosthwaite
2013-07-06 13:16     ` Andreas Färber
2013-06-30 21:00 ` [Qemu-devel] [PATCH RFC 07/15] timer/arm_mptimer: Convert to QOM realize Andreas Färber
2013-07-01  9:33   ` Peter Crosthwaite
2013-07-06 13:28     ` Andreas Färber [this message]
2013-06-30 21:00 ` [Qemu-devel] [PATCH RFC 08/15] cpu/a9mpcore: Embed ARMMPTimerState Andreas Färber
2013-06-30 21:00 ` [Qemu-devel] [PATCH RFC 09/15] cpu/a9mpcore: Convert to QOM realize Andreas Färber
2013-06-30 21:01 ` [Qemu-devel] [PATCH RFC 10/15] cpu/a9mpcore: Prepare for QOM embedding Andreas Färber
2013-06-30 21:01 ` [Qemu-devel] [PATCH RFC 11/15] cpu/a15mpcore: QOM cast cleanup Andreas Färber
2013-06-30 21:01 ` [Qemu-devel] [PATCH RFC 12/15] cpu/a15mpcore: Split off instance_init Andreas Färber
2013-06-30 21:01 ` [Qemu-devel] [PATCH RFC 13/15] cpu/a15mpcore: Embed GICState Andreas Färber
2013-06-30 21:01 ` [Qemu-devel] [PATCH RFC 14/15] cpu/a15mpcore: Convert to QOM realize Andreas Färber
2013-06-30 21:01 ` [Qemu-devel] [PATCH RFC 15/15] cpu/a15mpcore: Prepare for QOM embedding Andreas Färber

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=51D81B94.6060002@suse.de \
    --to=afaerber@suse.de \
    --cc=pbonzini@redhat.com \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=peter.maydell@linaro.org \
    --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).