qemu-devel
[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: Philippe Mathieu-Daudé
Subject: Re: [PATCH for-6.2 10/25] hw/arm: Don't allocate separate MemoryRegions in stm32 SoC realize
Date: Sun, 15 Aug 2021 18:37:20 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0

On 8/12/21 2:27 PM, Peter Maydell wrote:
> 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.

FYI since more than 2 years now Igor recommends using DEFINE_TYPES()
for newer QOM style, which makes adding board-specific fields to
MachineState quite easy (see hw/avr/arduino.c or hw/arm/raspi.c).



reply via email to

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