* [PATCH 0/2] hw/ppc/pegasos2: Extract southbridge creation code to via_vt8231_create
@ 2023-01-17 20:16 Philippe Mathieu-Daudé
2023-01-17 20:16 ` [PATCH 1/2] hw/ppc/pegasos2: Extract via_i2c_bus() helper Philippe Mathieu-Daudé
2023-01-17 20:16 ` [PATCH 2/2] hw/ppc/pegasos2: Extract via_vt8231_create() helper Philippe Mathieu-Daudé
0 siblings, 2 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-17 20:16 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, BALATON Zoltan, Philippe Mathieu-Daudé
Simple refactor to clarify a bit the southbridge device creation.
Philippe Mathieu-Daudé (2):
hw/ppc/pegasos2: Extract via_i2c_bus() helper
hw/ppc/pegasos2: Extract via_vt8231_create() helper
hw/ppc/pegasos2.c | 46 ++++++++++++++++++++++++++++++----------------
1 file changed, 30 insertions(+), 16 deletions(-)
--
2.38.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] hw/ppc/pegasos2: Extract via_i2c_bus() helper
2023-01-17 20:16 [PATCH 0/2] hw/ppc/pegasos2: Extract southbridge creation code to via_vt8231_create Philippe Mathieu-Daudé
@ 2023-01-17 20:16 ` Philippe Mathieu-Daudé
2023-01-17 20:16 ` [PATCH 2/2] hw/ppc/pegasos2: Extract via_vt8231_create() helper Philippe Mathieu-Daudé
1 sibling, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-17 20:16 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, BALATON Zoltan, Philippe Mathieu-Daudé
Simplify a bit pegasos2_init() by extracting via_i2c_bus().
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/ppc/pegasos2.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c
index f46d4bf51d..ac69aee099 100644
--- a/hw/ppc/pegasos2.c
+++ b/hw/ppc/pegasos2.c
@@ -96,6 +96,14 @@ static void pegasos2_cpu_reset(void *opaque)
}
}
+static I2CBus *via_i2c_bus(PCIDevice *via)
+{
+ PCIDevice *dev;
+
+ dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "pm"));
+ return I2C_BUS(qdev_get_child_bus(DEVICE(dev), "i2c"));
+}
+
static void pegasos2_init(MachineState *machine)
{
Pegasos2MachineState *pm = PEGASOS2_MACHINE(machine);
@@ -103,7 +111,6 @@ static void pegasos2_init(MachineState *machine)
MemoryRegion *rom = g_new(MemoryRegion, 1);
PCIBus *pci_bus;
PCIDevice *dev, *via;
- I2CBus *i2c_bus;
const char *fwname = machine->firmware ?: PROM_FILENAME;
char *filename;
int sz;
@@ -171,10 +178,8 @@ static void pegasos2_init(MachineState *machine)
dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "ide"));
pci_ide_create_devs(dev);
- dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "pm"));
- i2c_bus = I2C_BUS(qdev_get_child_bus(DEVICE(dev), "i2c"));
spd_data = spd_data_generate(DDR, machine->ram_size);
- smbus_eeprom_init_one(i2c_bus, 0x57, spd_data);
+ smbus_eeprom_init_one(via_i2c_bus(via), 0x57, spd_data);
/* other PC hardware */
pci_vga_init(pci_bus);
--
2.38.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] hw/ppc/pegasos2: Extract via_vt8231_create() helper
2023-01-17 20:16 [PATCH 0/2] hw/ppc/pegasos2: Extract southbridge creation code to via_vt8231_create Philippe Mathieu-Daudé
2023-01-17 20:16 ` [PATCH 1/2] hw/ppc/pegasos2: Extract via_i2c_bus() helper Philippe Mathieu-Daudé
@ 2023-01-17 20:16 ` Philippe Mathieu-Daudé
2023-01-17 21:17 ` BALATON Zoltan
1 sibling, 1 reply; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-17 20:16 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, BALATON Zoltan, Philippe Mathieu-Daudé
Simplify a bit pegasos2_init() by extracting the VIA southbridge
creation code into a new via_vt8231_create() helper.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/ppc/pegasos2.c | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c
index ac69aee099..445cb5ef31 100644
--- a/hw/ppc/pegasos2.c
+++ b/hw/ppc/pegasos2.c
@@ -96,6 +96,25 @@ static void pegasos2_cpu_reset(void *opaque)
}
}
+static PCIDevice *via_vt8231_create(MachineState *machine, PCIBus *pci_bus)
+{
+ Pegasos2MachineState *pm = PEGASOS2_MACHINE(machine);
+ PCIDevice *dev, *via;
+
+ via = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(12, 0),
+ true, TYPE_VT8231_ISA);
+ object_property_add_alias(OBJECT(machine), "rtc-time",
+ object_resolve_path_component(OBJECT(via), "rtc"),
+ "date");
+ qdev_connect_gpio_out(DEVICE(via), 0,
+ qdev_get_gpio_in_named(pm->mv, "gpp", 31));
+
+ dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "ide"));
+ pci_ide_create_devs(dev);
+
+ return via;
+}
+
static I2CBus *via_i2c_bus(PCIDevice *via)
{
PCIDevice *dev;
@@ -110,7 +129,7 @@ static void pegasos2_init(MachineState *machine)
CPUPPCState *env;
MemoryRegion *rom = g_new(MemoryRegion, 1);
PCIBus *pci_bus;
- PCIDevice *dev, *via;
+ PCIDevice *via;
const char *fwname = machine->firmware ?: PROM_FILENAME;
char *filename;
int sz;
@@ -166,17 +185,7 @@ static void pegasos2_init(MachineState *machine)
pci_bus = mv64361_get_pci_bus(pm->mv, 1);
/* VIA VT8231 South Bridge (multifunction PCI device) */
- via = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(12, 0), true,
- TYPE_VT8231_ISA);
- object_property_add_alias(OBJECT(machine), "rtc-time",
- object_resolve_path_component(OBJECT(via),
- "rtc"),
- "date");
- qdev_connect_gpio_out(DEVICE(via), 0,
- qdev_get_gpio_in_named(pm->mv, "gpp", 31));
-
- dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "ide"));
- pci_ide_create_devs(dev);
+ via = via_vt8231_create(machine, pci_bus);
spd_data = spd_data_generate(DDR, machine->ram_size);
smbus_eeprom_init_one(via_i2c_bus(via), 0x57, spd_data);
--
2.38.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] hw/ppc/pegasos2: Extract via_vt8231_create() helper
2023-01-17 20:16 ` [PATCH 2/2] hw/ppc/pegasos2: Extract via_vt8231_create() helper Philippe Mathieu-Daudé
@ 2023-01-17 21:17 ` BALATON Zoltan
2023-01-18 9:51 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 6+ messages in thread
From: BALATON Zoltan @ 2023-01-17 21:17 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel, qemu-ppc
[-- Attachment #1: Type: text/plain, Size: 3376 bytes --]
On Tue, 17 Jan 2023, Philippe Mathieu-Daudé wrote:
> Simplify a bit pegasos2_init() by extracting the VIA southbridge
> creation code into a new via_vt8231_create() helper.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/ppc/pegasos2.c | 33 +++++++++++++++++++++------------
> 1 file changed, 21 insertions(+), 12 deletions(-)
>
> diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c
> index ac69aee099..445cb5ef31 100644
> --- a/hw/ppc/pegasos2.c
> +++ b/hw/ppc/pegasos2.c
> @@ -96,6 +96,25 @@ static void pegasos2_cpu_reset(void *opaque)
> }
> }
>
> +static PCIDevice *via_vt8231_create(MachineState *machine, PCIBus *pci_bus)
> +{
> + Pegasos2MachineState *pm = PEGASOS2_MACHINE(machine);
> + PCIDevice *dev, *via;
> +
> + via = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(12, 0),
> + true, TYPE_VT8231_ISA);
> + object_property_add_alias(OBJECT(machine), "rtc-time",
> + object_resolve_path_component(OBJECT(via), "rtc"),
> + "date");
> + qdev_connect_gpio_out(DEVICE(via), 0,
> + qdev_get_gpio_in_named(pm->mv, "gpp", 31));
> +
> + dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "ide"));
> + pci_ide_create_devs(dev);
> +
> + return via;
> +}
> +
> static I2CBus *via_i2c_bus(PCIDevice *via)
> {
> PCIDevice *dev;
> @@ -110,7 +129,7 @@ static void pegasos2_init(MachineState *machine)
> CPUPPCState *env;
> MemoryRegion *rom = g_new(MemoryRegion, 1);
> PCIBus *pci_bus;
> - PCIDevice *dev, *via;
> + PCIDevice *via;
> const char *fwname = machine->firmware ?: PROM_FILENAME;
> char *filename;
> int sz;
> @@ -166,17 +185,7 @@ static void pegasos2_init(MachineState *machine)
> pci_bus = mv64361_get_pci_bus(pm->mv, 1);
>
> /* VIA VT8231 South Bridge (multifunction PCI device) */
> - via = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(12, 0), true,
> - TYPE_VT8231_ISA);
> - object_property_add_alias(OBJECT(machine), "rtc-time",
> - object_resolve_path_component(OBJECT(via),
> - "rtc"),
Is this series to help any later patches or is it proposed on its own? In
the latter case I don't see how this would improve it much. The only
useful change in the series is removing the unnecessary line break before
"rtc"); here, otherwise moving patts of this init routine to separate
functions does not make it simpler just makes you jump around instead of
being able to read it linearly. So if this makes it possible for later
patches to move some of it elsewhere then OK otherwise I'd say I'm OK with
how it is now, it's just the normal unreadable QOM stuff you see
everywhere after removing legacy init functions.
Regards,
BALATON Zoltan
> - "date");
> - qdev_connect_gpio_out(DEVICE(via), 0,
> - qdev_get_gpio_in_named(pm->mv, "gpp", 31));
> -
> - dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "ide"));
> - pci_ide_create_devs(dev);
> + via = via_vt8231_create(machine, pci_bus);
>
> spd_data = spd_data_generate(DDR, machine->ram_size);
> smbus_eeprom_init_one(via_i2c_bus(via), 0x57, spd_data);
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] hw/ppc/pegasos2: Extract via_vt8231_create() helper
2023-01-17 21:17 ` BALATON Zoltan
@ 2023-01-18 9:51 ` Philippe Mathieu-Daudé
2023-01-18 16:59 ` BALATON Zoltan
0 siblings, 1 reply; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-18 9:51 UTC (permalink / raw)
To: BALATON Zoltan; +Cc: qemu-devel, qemu-ppc
On 17/1/23 22:17, BALATON Zoltan wrote:
> On Tue, 17 Jan 2023, Philippe Mathieu-Daudé wrote:
>> Simplify a bit pegasos2_init() by extracting the VIA southbridge
>> creation code into a new via_vt8231_create() helper.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>> hw/ppc/pegasos2.c | 33 +++++++++++++++++++++------------
>> 1 file changed, 21 insertions(+), 12 deletions(-)
>>
>> diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c
>> index ac69aee099..445cb5ef31 100644
>> --- a/hw/ppc/pegasos2.c
>> +++ b/hw/ppc/pegasos2.c
>> @@ -96,6 +96,25 @@ static void pegasos2_cpu_reset(void *opaque)
>> }
>> }
>>
>> +static PCIDevice *via_vt8231_create(MachineState *machine, PCIBus
>> *pci_bus)
>> +{
>> + Pegasos2MachineState *pm = PEGASOS2_MACHINE(machine);
>> + PCIDevice *dev, *via;
>> +
>> + via = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(12, 0),
>> + true, TYPE_VT8231_ISA);
>> + object_property_add_alias(OBJECT(machine), "rtc-time",
>> +
>> object_resolve_path_component(OBJECT(via), "rtc"),
>> + "date");
>> + qdev_connect_gpio_out(DEVICE(via), 0,
>> + qdev_get_gpio_in_named(pm->mv, "gpp", 31));
>> +
>> + dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "ide"));
>> + pci_ide_create_devs(dev);
>> +
>> + return via;
>> +}
>> +
>> static I2CBus *via_i2c_bus(PCIDevice *via)
>> {
>> PCIDevice *dev;
>> @@ -110,7 +129,7 @@ static void pegasos2_init(MachineState *machine)
>> CPUPPCState *env;
>> MemoryRegion *rom = g_new(MemoryRegion, 1);
>> PCIBus *pci_bus;
>> - PCIDevice *dev, *via;
>> + PCIDevice *via;
>> const char *fwname = machine->firmware ?: PROM_FILENAME;
>> char *filename;
>> int sz;
>> @@ -166,17 +185,7 @@ static void pegasos2_init(MachineState *machine)
>> pci_bus = mv64361_get_pci_bus(pm->mv, 1);
>>
>> /* VIA VT8231 South Bridge (multifunction PCI device) */
>> - via = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(12, 0),
>> true,
>> - TYPE_VT8231_ISA);
>> - object_property_add_alias(OBJECT(machine), "rtc-time",
>> - object_resolve_path_component(OBJECT(via),
>> - "rtc"),
>
> Is this series to help any later patches or is it proposed on its own?
> In the latter case I don't see how this would improve it much. The only
> useful change in the series is removing the unnecessary line break
> before "rtc"); here, otherwise moving patts of this init routine to
> separate functions does not make it simpler just makes you jump around
> instead of being able to read it linearly. So if this makes it possible
> for later patches to move some of it elsewhere then OK otherwise I'd say
> I'm OK with how it is now, it's just the normal unreadable QOM stuff you
> see everywhere after removing legacy init functions.
Difference of mindset I suppose, as you clearly type linearly :)
I consider logical blocks of hardware, and the southbridge is one of
them. So I thought moving components connected to the 'machine' via
the southbridge in a separate function would be clearer for the
overall community (this file is not exclusively used by you, and
can potentially used as example to build a machine). Anyhow I don't
mind much.
Regards,
Phil.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] hw/ppc/pegasos2: Extract via_vt8231_create() helper
2023-01-18 9:51 ` Philippe Mathieu-Daudé
@ 2023-01-18 16:59 ` BALATON Zoltan
0 siblings, 0 replies; 6+ messages in thread
From: BALATON Zoltan @ 2023-01-18 16:59 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel, qemu-ppc
[-- Attachment #1: Type: text/plain, Size: 5060 bytes --]
On Wed, 18 Jan 2023, Philippe Mathieu-Daudé wrote:
> On 17/1/23 22:17, BALATON Zoltan wrote:
>> On Tue, 17 Jan 2023, Philippe Mathieu-Daudé wrote:
>>> Simplify a bit pegasos2_init() by extracting the VIA southbridge
>>> creation code into a new via_vt8231_create() helper.
>>>
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> ---
>>> hw/ppc/pegasos2.c | 33 +++++++++++++++++++++------------
>>> 1 file changed, 21 insertions(+), 12 deletions(-)
>>>
>>> diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c
>>> index ac69aee099..445cb5ef31 100644
>>> --- a/hw/ppc/pegasos2.c
>>> +++ b/hw/ppc/pegasos2.c
>>> @@ -96,6 +96,25 @@ static void pegasos2_cpu_reset(void *opaque)
>>> }
>>> }
>>>
>>> +static PCIDevice *via_vt8231_create(MachineState *machine, PCIBus
>>> *pci_bus)
>>> +{
>>> + Pegasos2MachineState *pm = PEGASOS2_MACHINE(machine);
>>> + PCIDevice *dev, *via;
>>> +
>>> + via = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(12, 0),
>>> + true, TYPE_VT8231_ISA);
>>> + object_property_add_alias(OBJECT(machine), "rtc-time",
>>> + object_resolve_path_component(OBJECT(via),
>>> "rtc"),
>>> + "date");
>>> + qdev_connect_gpio_out(DEVICE(via), 0,
>>> + qdev_get_gpio_in_named(pm->mv, "gpp", 31));
>>> +
>>> + dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "ide"));
>>> + pci_ide_create_devs(dev);
>>> +
>>> + return via;
>>> +}
>>> +
>>> static I2CBus *via_i2c_bus(PCIDevice *via)
>>> {
>>> PCIDevice *dev;
>>> @@ -110,7 +129,7 @@ static void pegasos2_init(MachineState *machine)
>>> CPUPPCState *env;
>>> MemoryRegion *rom = g_new(MemoryRegion, 1);
>>> PCIBus *pci_bus;
>>> - PCIDevice *dev, *via;
>>> + PCIDevice *via;
>>> const char *fwname = machine->firmware ?: PROM_FILENAME;
>>> char *filename;
>>> int sz;
>>> @@ -166,17 +185,7 @@ static void pegasos2_init(MachineState *machine)
>>> pci_bus = mv64361_get_pci_bus(pm->mv, 1);
>>>
>>> /* VIA VT8231 South Bridge (multifunction PCI device) */
>>> - via = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(12, 0),
>>> true,
>>> - TYPE_VT8231_ISA);
>>> - object_property_add_alias(OBJECT(machine), "rtc-time",
>>> - object_resolve_path_component(OBJECT(via),
>>> - "rtc"),
>>
>> Is this series to help any later patches or is it proposed on its own? In
>> the latter case I don't see how this would improve it much. The only useful
>> change in the series is removing the unnecessary line break before "rtc");
>> here, otherwise moving patts of this init routine to separate functions
>> does not make it simpler just makes you jump around instead of being able
>> to read it linearly. So if this makes it possible for later patches to move
>> some of it elsewhere then OK otherwise I'd say I'm OK with how it is now,
>> it's just the normal unreadable QOM stuff you see everywhere after removing
>> legacy init functions.
>
> Difference of mindset I suppose, as you clearly type linearly :)
>
> I consider logical blocks of hardware, and the southbridge is one of
> them. So I thought moving components connected to the 'machine' via
> the southbridge in a separate function would be clearer for the
> overall community (this file is not exclusively used by you, and
> can potentially used as example to build a machine).
I understand but you cannot clearly move all of it out to one function but
proposed to introduce two small functions with leaving the spd data
creation in board code. In my view only the line creating the 'via'
instance is one unit, he rest connects the instance to the machine (the
rtc alias adds property to the _machine_, pci_ide_create_devs(dev) is
usually part of boards and the spd data is also not part of the 'via' just
uses the i2c bus it provides). So for me it's more logical to have these
in the board init func than in a via_init func as it's not initialises the
'via' itself just uses the one created before. Creating the 'via' instance
is now just one line after moving all the subfunctions in the via model.
It's still in one block separated by comments so i think adding functions
to this would not make it clearer and legacy init functions are also
deprecated in favour of plain QOM in board init lately.
> Anyhow I don't mind much.
In that case I'd leave it as it is with the small readability improvement
I've sent a v2 of fixing the typos and adding your R-b, unless others
think splitting some part of this in separate functions would be better.
Regards,
BALATON Zoltan
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-01-18 17:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-17 20:16 [PATCH 0/2] hw/ppc/pegasos2: Extract southbridge creation code to via_vt8231_create Philippe Mathieu-Daudé
2023-01-17 20:16 ` [PATCH 1/2] hw/ppc/pegasos2: Extract via_i2c_bus() helper Philippe Mathieu-Daudé
2023-01-17 20:16 ` [PATCH 2/2] hw/ppc/pegasos2: Extract via_vt8231_create() helper Philippe Mathieu-Daudé
2023-01-17 21:17 ` BALATON Zoltan
2023-01-18 9:51 ` Philippe Mathieu-Daudé
2023-01-18 16:59 ` BALATON Zoltan
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).