qemu-arm
[Top][All Lists]
Advanced

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

Re: [PATCH for-6.2 10/25] hw/arm: Don't allocate separate MemoryRegions


From: Peter Maydell
Subject: Re: [PATCH for-6.2 10/25] hw/arm: Don't allocate separate MemoryRegions in stm32 SoC realize
Date: Thu, 12 Aug 2021 13:27:20 +0100

On Thu, 12 Aug 2021 at 13:13, Alexandre IOOSS <erdnaxe@crans.org> wrote:
>
> On 8/12/21 11:33 AM, Peter Maydell wrote:
> > In the realize methods of the stm32f100 and stm32f205 SoC objects, we
> > call g_new() to create new MemoryRegion objjects for the sram, flash,
> > and flash_alias.  This is unnecessary (and leaves open the
> > possibility of leaking the allocations if we exit from realize with
> > an error).  Make these MemoryRegions member fields of the device
> > state struct instead, as stm32f405 already does.
>
> There is a typo in "objjects".
>
> This is something I had issue understanding as I was seeing both
> patterns in the codebase, thank you for making this clear.

Basically if there's a struct that the MemoryRegion can live
in  then that's the best place for it. For some board-level code
where we haven't needed to subclass MachineState there is no
convenient struct, so we just g_new(). In a few places like this
one the board-code pattern has been copied into an SoC object.

-- PMM



reply via email to

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