From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bRjA6-00005p-4F for qemu-devel@nongnu.org; Mon, 25 Jul 2016 12:55:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bRjA5-0001lm-58 for qemu-devel@nongnu.org; Mon, 25 Jul 2016 12:55:26 -0400 Received: from mail-vk0-x229.google.com ([2607:f8b0:400c:c05::229]:34633) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bRjA4-0001lb-Jo for qemu-devel@nongnu.org; Mon, 25 Jul 2016 12:55:25 -0400 Received: by mail-vk0-x229.google.com with SMTP id s189so251760953vkh.1 for ; Mon, 25 Jul 2016 09:55:24 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Peter Maydell Date: Mon, 25 Jul 2016 17:55:04 +0100 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] [PATCH v1 1/5] cadence_gem: QOMify Cadence GEM List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alistair Francis Cc: Peter Crosthwaite , qemu-arm , QEMU Developers On 25 July 2016 at 17:42, Alistair Francis wrote: > On Mon, Jul 25, 2016 at 9:38 AM, Alistair Francis > wrote: >> On Mon, Jul 25, 2016 at 8:20 AM, Peter Maydell wrote: >>> On 12 July 2016 at 00:20, Alistair Francis wrote: >>>> Signed-off-by: Alistair Francis >>>> --- >>>> >>>> hw/net/cadence_gem.c | 27 ++++++++++++++++----------- >>>> 1 file changed, 16 insertions(+), 11 deletions(-) >>>> >>>> diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c >>>> index 8a4be1e..9d64644 100644 >>>> --- a/hw/net/cadence_gem.c >>>> +++ b/hw/net/cadence_gem.c >>>> @@ -1214,24 +1214,29 @@ static NetClientInfo net_gem_info = { >>>> .link_status_changed = gem_set_link, >>>> }; >>>> >>>> -static int gem_init(SysBusDevice *sbd) >>>> +static void gem_realize(DeviceState *dev, Error **errp) >>>> { >>>> - DeviceState *dev = DEVICE(sbd); >>>> CadenceGEMState *s = CADENCE_GEM(dev); >>>> >>>> - DB_PRINT("\n"); >>>> + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq); >>>> >>>> - gem_init_register_masks(s); >>>> - memory_region_init_io(&s->iomem, OBJECT(s), &gem_ops, s, >>>> - "enet", sizeof(s->regs)); >>>> - sysbus_init_mmio(sbd, &s->iomem); >>>> - sysbus_init_irq(sbd, &s->irq); >>>> qemu_macaddr_default_if_unset(&s->conf.macaddr); >>>> >>>> s->nic = qemu_new_nic(&net_gem_info, &s->conf, >>>> object_get_typename(OBJECT(dev)), dev->id, s); >>>> +} >>>> + >>>> +static void gem_init(Object *obj) >>>> +{ >>>> + CadenceGEMState *s = CADENCE_GEM(obj); >>>> + DeviceState *dev = DEVICE(obj); >>>> + >>>> + DB_PRINT("\n"); >>>> >>>> - return 0; >>>> + gem_init_register_masks(s); >>>> + memory_region_init_io(&s->iomem, OBJECT(s), &gem_ops, s, >>>> + "enet", sizeof(s->regs)); >>>> + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); >>>> } >>> >>> I don't understand the logic behind which things are >>> in init and which in realize here -- why is >>> sysbus_init_mmio() in init but sysbus_init_irq() in >>> realize ? >> >> That was just a mistake. I have moved all of the *_init_* functions to >> the main init function. > > As soon as I sent that mail I remembered why it was like that. > > Eventually the sysbus_init_irq() function depends on the number of > queues, which is a property so it can't be set in the init. > > Do you think the sysbus_init_mmio() should be moved to the realise as well then? Oh, I see. This is fine, then, but put a note in the commit message about why the sysbus_init_irq() is where it is. Reviewed-by: Peter Maydell thanks -- PMM