qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: BALATON Zoltan <balaton@eik.bme.hu>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org,
	"Hervé Poussineau" <hpoussin@reactos.org>,
	"Artyom Tarasenko" <atar4qemu@gmail.com>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Peter Maydell" <peter.maydell@linaro.org>
Subject: Re: [PATCH 11/16] hw/pci-host/raven: Do not use parent object for mmcfg region
Date: Tue, 3 Jun 2025 15:45:43 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LMD.2.03.2506031543570.13449@eik.bme.hu> (raw)
In-Reply-To: <fb178d96-ee28-414c-a320-2b5b0ceee5e6@linaro.org>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2797 bytes --]

On Tue, 3 Jun 2025, Philippe Mathieu-Daudé wrote:
> On 4/5/25 18:01, BALATON Zoltan wrote:
>> The mmcfg field in PCIHostState is only used by raven for the PCI
>> config direct access but is not actually needed as the memory region
>> lifetime can be managed by the object given during init so use that
>> and remove the unused field from PCIHostState.
>> 
>
> Well, this is the recommended way to avoid leaking MemoryRegions.
>
> If QOM object allocates something, it should keep a reference to it,
> allowing simpler eventual implementation of DeviceUnrealize handler.

MemoryRegions are already tracked by owner object so no need to free them 
in unrealize or embed them in stat struct to avoid leaking them. I'd only 
store things in state that are really needed.

Regards,
BALATON Zoltan

>> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
>> ---
>>   hw/pci-host/raven.c       | 7 ++++---
>>   include/hw/pci/pci_host.h | 1 -
>>   2 files changed, 4 insertions(+), 4 deletions(-)
>> 
>> diff --git a/hw/pci-host/raven.c b/hw/pci-host/raven.c
>> index c39e95b45f..7550c291c6 100644
>> --- a/hw/pci-host/raven.c
>> +++ b/hw/pci-host/raven.c
>> @@ -212,7 +212,7 @@ static void raven_pcihost_realizefn(DeviceState *d, 
>> Error **errp)
>>       SysBusDevice *dev = SYS_BUS_DEVICE(d);
>>       PCIHostState *h = PCI_HOST_BRIDGE(dev);
>>       PREPPCIState *s = RAVEN_PCI_HOST_BRIDGE(dev);
>> -    MemoryRegion *address_space_mem = get_system_memory();
>> +    MemoryRegion *mr, *address_space_mem = get_system_memory();
>>         qdev_init_gpio_in(d, raven_change_gpio, 1);
>>   @@ -229,9 +229,10 @@ static void raven_pcihost_realizefn(DeviceState *d, 
>> Error **errp)
>>                             "pci-conf-data", 4);
>>       memory_region_add_subregion(&s->pci_io, 0xcfc, &h->data_mem);
>>   -    memory_region_init_io(&h->mmcfg, OBJECT(h), &raven_mmcfg_ops, 
>> h->bus,
>> +    mr = g_new0(MemoryRegion, 1);
>> +    memory_region_init_io(mr, OBJECT(h), &raven_mmcfg_ops, h->bus,
>>                             "pci-mmcfg", 0x00400000);
>> -    memory_region_add_subregion(address_space_mem, 0x80800000, &h->mmcfg);
>> +    memory_region_add_subregion(address_space_mem, 0x80800000, mr);
>>         memory_region_init_io(&s->pci_intack, OBJECT(s), &raven_intack_ops, 
>> s,
>>                             "pci-intack", 1);
>> diff --git a/include/hw/pci/pci_host.h b/include/hw/pci/pci_host.h
>> index e52d8ec2cd..7c0285e2ff 100644
>> --- a/include/hw/pci/pci_host.h
>> +++ b/include/hw/pci/pci_host.h
>> @@ -41,7 +41,6 @@ struct PCIHostState {
>>         MemoryRegion conf_mem;
>>       MemoryRegion data_mem;
>> -    MemoryRegion mmcfg;
>>       uint32_t config_reg;
>>       bool mig_enabled;
>>       PCIBus *bus;
>
>

  reply	other threads:[~2025-06-03 13:46 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-04 16:01 [PATCH 00/16] hw/pci-host/raven clean ups BALATON Zoltan
2025-05-04 16:01 ` [PATCH 01/16] hw/pci-host/raven: Remove is-legacy-prep property BALATON Zoltan
2025-06-03 11:31   ` Philippe Mathieu-Daudé
2025-05-04 16:01 ` [PATCH 02/16] hw/pci-host/raven: Revert "raven: Move BIOS loading from board code to PCI host" BALATON Zoltan
2025-06-03 11:37   ` Philippe Mathieu-Daudé
2025-05-04 16:01 ` [PATCH 03/16] hw/pci-host/raven: Simplify PCI facing part BALATON Zoltan
2025-06-03 11:41   ` Philippe Mathieu-Daudé
2025-06-03 13:41     ` BALATON Zoltan
2025-05-04 16:01 ` [PATCH 04/16] hw/pci-host/raven: Simplify host bridge type declaration BALATON Zoltan
2025-06-03 11:41   ` Philippe Mathieu-Daudé
2025-05-04 16:01 ` [PATCH 05/16] hw/pci-host/raven: Use DEFINE_TYPES macro BALATON Zoltan
2025-06-03 11:42   ` Philippe Mathieu-Daudé
2025-05-04 16:01 ` [PATCH 06/16] hw/pci-host/raven: Simplify PCI bus creation BALATON Zoltan
2025-05-04 16:01 ` [PATCH 07/16] hw/pci-host/raven: Simplify PCI interrupt routing BALATON Zoltan
2025-05-04 16:01 ` [PATCH 08/16] hw/pci-host/raven: Simplify direct config access address decoding BALATON Zoltan
2025-05-04 16:01 ` [PATCH 09/16] hw/pci-host/raven: Rename direct config access ops BALATON Zoltan
2025-05-04 16:01 ` [PATCH 10/16] hw/pci-host/raven: Use correct parameter in direct " BALATON Zoltan
2025-06-03 11:47   ` Philippe Mathieu-Daudé
2025-05-04 16:01 ` [PATCH 11/16] hw/pci-host/raven: Do not use parent object for mmcfg region BALATON Zoltan
2025-06-03 11:50   ` Philippe Mathieu-Daudé
2025-06-03 13:45     ` BALATON Zoltan [this message]
2025-05-04 16:01 ` [PATCH 12/16] hw/pci-host/raven: Fix PCI config direct access region BALATON Zoltan
2025-06-03 11:52   ` Philippe Mathieu-Daudé
2025-05-04 16:01 ` [PATCH 13/16] hw/pci-host/raven: Simpify discontiguous IO access BALATON Zoltan
2025-05-04 16:01 ` [PATCH 14/16] hw/pci-host/raven: Move bus master address space creation to one place BALATON Zoltan
2025-05-04 16:01 ` [PATCH 15/16] hw/pci-host/raven: Do not map regions in init method BALATON Zoltan
2025-06-03 11:54   ` Philippe Mathieu-Daudé
2025-06-03 13:50     ` BALATON Zoltan
2025-06-04 10:39       ` Philippe Mathieu-Daudé
2025-05-04 16:01 ` [PATCH 16/16] hw/ppc/prep: Fix non-contiguous IO control bit BALATON Zoltan
2025-05-22 22:31 ` [PATCH 00/16] hw/pci-host/raven clean ups BALATON Zoltan
2025-06-02 12:27   ` BALATON Zoltan

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=alpine.LMD.2.03.2506031543570.13449@eik.bme.hu \
    --to=balaton@eik.bme.hu \
    --cc=atar4qemu@gmail.com \
    --cc=hpoussin@reactos.org \
    --cc=npiggin@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@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).