From: Harsh Prateek Bora <harshpb@linux.ibm.com>
To: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
BALATON Zoltan <balaton@eik.bme.hu>
Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org,
"Hervé Poussineau" <hpoussin@reactos.org>,
"Artyom Tarasenko" <atar4qemu@gmail.com>,
"Nicholas Piggin" <npiggin@gmail.com>
Subject: Re: [PATCH v3 01/14] hw/pci-host/raven: Simplify PCI facing part
Date: Sat, 18 Oct 2025 08:11:19 +0530 [thread overview]
Message-ID: <a95fed21-de1c-4dc8-a776-a6a2acd4b7d3@linux.ibm.com> (raw)
In-Reply-To: <db65a6dd-cfdf-18b8-1764-8a1d7d3fcc24@eik.bme.hu>
Hi Mark,
Thanks much for pitching in to help with reviewing this series.
On 9/19/25 01:51, BALATON Zoltan wrote:
> On Thu, 18 Sep 2025, Mark Cave-Ayland wrote:
>> On 18/09/2025 19:50, BALATON Zoltan wrote:
>>> The raven PCI device does not need a state struct as it has no data to
>>> store there any more, so we can remove that to simplify code.
>>>
>>> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
>>> ---
>>> hw/pci-host/raven.c | 30 +-----------------------------
>>> 1 file changed, 1 insertion(+), 29 deletions(-)
>>>
>>> diff --git a/hw/pci-host/raven.c b/hw/pci-host/raven.c
>>> index f8c0be5d21..172f01694c 100644
>>> --- a/hw/pci-host/raven.c
>>> +++ b/hw/pci-host/raven.c
>>> @@ -31,7 +31,6 @@
>>> #include "hw/pci/pci_bus.h"
>>> #include "hw/pci/pci_host.h"
>>> #include "hw/qdev-properties.h"
>>> -#include "migration/vmstate.h"
>>> #include "hw/intc/i8259.h"
>>> #include "hw/irq.h"
>>> #include "hw/or-irq.h"
>>> @@ -40,12 +39,6 @@
>>> #define TYPE_RAVEN_PCI_DEVICE "raven"
>>> #define TYPE_RAVEN_PCI_HOST_BRIDGE "raven-pcihost"
>>> -OBJECT_DECLARE_SIMPLE_TYPE(RavenPCIState, RAVEN_PCI_DEVICE)
>>> -
>>> -struct RavenPCIState {
>>> - PCIDevice dev;
>>> -};
>>> -
>>> typedef struct PRePPCIState PREPPCIState;
>>> DECLARE_INSTANCE_CHECKER(PREPPCIState, RAVEN_PCI_HOST_BRIDGE,
>>> TYPE_RAVEN_PCI_HOST_BRIDGE)
>>> @@ -65,7 +58,6 @@ struct PRePPCIState {
>>> MemoryRegion bm_ram_alias;
>>> MemoryRegion bm_pci_memory_alias;
>>> AddressSpace bm_as;
>>> - RavenPCIState pci_dev;
>>> int contiguous_map;
>>> };
>>> @@ -268,8 +260,7 @@ static void raven_pcihost_realizefn(DeviceState
>>> *d, Error **errp)
>>> "pci-intack", 1);
>>> memory_region_add_subregion(address_space_mem, 0xbffffff0,
>>> &s->pci_intack);
>>> - /* TODO Remove once realize propagates to child devices. */
>>> - qdev_realize(DEVICE(&s->pci_dev), BUS(&s->pci_bus), errp);
>>> + pci_create_simple(&s->pci_bus, PCI_DEVFN(0, 0),
>>> TYPE_RAVEN_PCI_DEVICE);
>>> }
<snip>
>>> @@ -361,7 +334,6 @@ static void raven_class_init(ObjectClass *klass,
>>> const void *data)
>>> static const TypeInfo raven_info = {
>>> .name = TYPE_RAVEN_PCI_DEVICE,
>>> .parent = TYPE_PCI_DEVICE,
>>> - .instance_size = sizeof(RavenPCIState),
>>> .class_init = raven_class_init,
>>> .interfaces = (const InterfaceInfo[]) {
>>> { INTERFACE_CONVENTIONAL_PCI_DEVICE },
>>
>> I agree with removing RavenPCIState, but pci_create_simple() isn't the
>> right solution here because it both init()s and realize()s the inner
>> object. The right way to do this is for the parent to init() its inner
>> object(s) within its init() function, and similarly for it to
>> realize() its inner object(s) within its realize() function.
>>
>> FWIW it looks as if the same mistake is present in several other
>> hw/pci-host devices.
>
> So maybe that's not a mistake then. There's no need to init and realize
> it separately as this is an internal object which is enough to be
> created in realize method and init and realize there at one go for which
> pci_create_simple is appropriate. I think this inner object would only
> need to be init separately if it exposed something (like a property)
> that could be inspected or set before realize but that's not the case
> here so it does not have to be created in init only in realize. (A lot
> of simple devices don't even have init method only realize so init is
> only needed for things that have to be set before realize.)
Do we have a consensus here ?
regards,
Harsh
>
> Regards,
> BALATON Zoltan
>
next prev parent reply other threads:[~2025-10-18 2:42 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-18 18:50 [PATCH v3 00/14] hw/pci-host/raven clean ups BALATON Zoltan
2025-09-18 18:50 ` [PATCH v3 01/14] hw/pci-host/raven: Simplify PCI facing part BALATON Zoltan
2025-09-18 19:15 ` Mark Cave-Ayland
2025-09-18 20:21 ` BALATON Zoltan
2025-10-18 2:41 ` Harsh Prateek Bora [this message]
2025-10-18 11:24 ` BALATON Zoltan
2025-10-19 21:40 ` Mark Cave-Ayland
2025-10-19 23:26 ` BALATON Zoltan
2025-10-21 4:02 ` Harsh Prateek Bora
2025-09-18 18:50 ` [PATCH v3 02/14] hw/pci-host/raven: Simplify host bridge type declaration BALATON Zoltan
2025-09-18 19:16 ` Mark Cave-Ayland
2025-09-18 18:50 ` [PATCH v3 03/14] hw/pci-host/raven: Use DEFINE_TYPES macro BALATON Zoltan
2025-09-18 19:16 ` Mark Cave-Ayland
2025-09-18 18:50 ` [PATCH v3 04/14] hw/pci-host/raven: Simplify PCI bus creation BALATON Zoltan
2025-09-18 19:22 ` Mark Cave-Ayland
2025-09-18 18:50 ` [PATCH v3 05/14] hw/pci-host/raven: Simplify PCI interrupt routing BALATON Zoltan
2025-09-18 19:35 ` Mark Cave-Ayland
2025-09-18 20:52 ` BALATON Zoltan
2025-09-18 18:50 ` [PATCH v3 06/14] hw/pci-host/raven: Simplify direct config access address decoding BALATON Zoltan
2025-09-18 19:43 ` Mark Cave-Ayland
2025-10-20 8:37 ` Philippe Mathieu-Daudé
2025-09-18 18:50 ` [PATCH v3 07/14] hw/pci-host/raven: Rename direct config access ops BALATON Zoltan
2025-09-18 19:44 ` Mark Cave-Ayland
2025-10-20 8:38 ` Philippe Mathieu-Daudé
2025-09-18 18:50 ` [PATCH v3 08/14] hw/pci-host/raven: Use correct parameter in direct " BALATON Zoltan
2025-09-18 19:52 ` Mark Cave-Ayland
2025-09-18 21:01 ` BALATON Zoltan
2025-09-18 18:50 ` [PATCH v3 09/14] hw/pci-host/raven: Do not use parent object for mmcfg region BALATON Zoltan
2025-09-18 20:34 ` Mark Cave-Ayland
2025-09-18 21:04 ` BALATON Zoltan
2025-09-18 18:50 ` [PATCH v3 10/14] hw/pci-host/raven: Fix PCI config direct access region BALATON Zoltan
2025-09-18 20:35 ` Mark Cave-Ayland
2025-09-18 18:50 ` [PATCH v3 11/14] hw/pci-host/raven: Simpify discontiguous IO access BALATON Zoltan
2025-09-18 20:49 ` Mark Cave-Ayland
2025-09-18 21:11 ` BALATON Zoltan
2025-09-18 18:50 ` [PATCH v3 12/14] hw/pci-host/raven: Move bus master address space creation to one place BALATON Zoltan
2025-09-18 20:54 ` Mark Cave-Ayland
2025-09-18 21:13 ` BALATON Zoltan
2025-09-18 18:50 ` [PATCH v3 13/14] hw/pci-host/raven: Do not map regions in init method BALATON Zoltan
2025-09-18 21:02 ` Mark Cave-Ayland
2025-09-18 21:22 ` BALATON Zoltan
2025-09-18 18:50 ` [PATCH v3 14/14] hw/ppc/prep: Fix non-contiguous IO control bit BALATON Zoltan
2025-09-18 21:09 ` Mark Cave-Ayland
2025-09-18 21:33 ` 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=a95fed21-de1c-4dc8-a776-a6a2acd4b7d3@linux.ibm.com \
--to=harshpb@linux.ibm.com \
--cc=atar4qemu@gmail.com \
--cc=balaton@eik.bme.hu \
--cc=hpoussin@reactos.org \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=npiggin@gmail.com \
--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).