[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v8 6/8] register: Add block initialise helper

From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH v8 6/8] register: Add block initialise helper
Date: Mon, 27 Jun 2016 17:44:24 +0100

On 27 June 2016 at 17:16, Alistair Francis <address@hidden> wrote:
> On Mon, Jun 27, 2016 at 7:31 AM, Peter Maydell <address@hidden> wrote:
>> On 24 June 2016 at 16:42, Alistair Francis <address@hidden> wrote:
>>> +/**
>>> + * This function should be called to cleanup the registers that were 
>>> initialized
>>> + * when calling register_init_block32()
>>> + *
>>> + * @r_array: An structure containing all of the registers. The caller is in
>>> + *           charge of cleaning up the memory region (r_array->mem).
>> What cleanup does the memory region require?
> The device init function that calls the register init function will
> also call memory_region_add_subregion(). Doesn't it need to call
> memory_region_del_subregion() afterwards?

Somebody also needs to call object_unparent() if the MemoryRegion
is part of a lump of memory that's being g_free()d (see docs/memory.txt).
That probably ought to be this code, and we should say that this
function should only be called from the owner device's instance_finalize.

More generally: I think we should be specific, not vague, about
exactly what the caller's responsibilities are [what they are
expected to have done before calling this function; when they
are permitted to call it]; otherwise the callers will likely get
it wrong.

-- PMM

reply via email to

[Prev in Thread] Current Thread [Next in Thread]