diff mbox series

[06/14] ppc/pnv: Complete user created PHB3 devices

Message ID 20211202144235.1276352-7-clg@kaod.org (mailing list archive)
State New, archived
Headers show
Series ppc/pnv: Add support for user created PHB3/PHB4 devices | expand

Commit Message

Cédric Le Goater Dec. 2, 2021, 2:42 p.m. UTC
PHB3s ared SysBus devices and should be allowed to be dynamically
created.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/pci-host/pnv_phb3.c | 9 +++++++++
 hw/ppc/pnv.c           | 2 ++
 2 files changed, 11 insertions(+)

Comments

Daniel Henrique Barboza Dec. 2, 2021, 5:33 p.m. UTC | #1
On 12/2/21 11:42, Cédric Le Goater wrote:
> PHB3s ared SysBus devices and should be allowed to be dynamically
> created.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>

>   hw/pci-host/pnv_phb3.c | 9 +++++++++
>   hw/ppc/pnv.c           | 2 ++
>   2 files changed, 11 insertions(+)
> 
> diff --git a/hw/pci-host/pnv_phb3.c b/hw/pci-host/pnv_phb3.c
> index e91f658b0060..b61f9c369f64 100644
> --- a/hw/pci-host/pnv_phb3.c
> +++ b/hw/pci-host/pnv_phb3.c
> @@ -1000,6 +1000,9 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp)
>   
>       /* User created devices */
>       if (!phb->chip) {
> +        Error *local_err = NULL;
> +        BusState *s;
> +
>           phb->chip = pnv_get_chip(pnv, phb->chip_id);
>           if (!phb->chip) {
>               error_setg(errp, "invalid chip id: %d", phb->chip_id);
> @@ -1011,6 +1014,12 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp)
>            * correctly the device tree.
>            */
>           pnv_chip_parent_fixup(phb->chip, OBJECT(phb), phb->phb_id);
> +
> +        s = qdev_get_parent_bus(DEVICE(phb->chip));
> +        if (!qdev_set_parent_bus(DEVICE(phb), s, &local_err)) {
> +            error_propagate(errp, local_err);
> +            return;
> +        }
>       }
>   
>       /* LSI sources */
> diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
> index 9a458655efd9..45d8ecbf2bf7 100644
> --- a/hw/ppc/pnv.c
> +++ b/hw/ppc/pnv.c
> @@ -1927,6 +1927,8 @@ static void pnv_machine_power8_class_init(ObjectClass *oc, void *data)
>   
>       pmc->compat = compat;
>       pmc->compat_size = sizeof(compat);
> +
> +    machine_class_allow_dynamic_sysbus_dev(mc, TYPE_PNV_PHB3);
>   }
>   
>   static void pnv_machine_power9_class_init(ObjectClass *oc, void *data)
>
Frederic Barrat Dec. 7, 2021, 9:53 a.m. UTC | #2
On 02/12/2021 15:42, Cédric Le Goater wrote:
> PHB3s ared SysBus devices and should be allowed to be dynamically
> created.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---

This one is a bit of black magic for me. I don't see an equivalent for 
P9 though. Not needed there? I'll have another comment about P8/P9 later.

   Fred


>   hw/pci-host/pnv_phb3.c | 9 +++++++++
>   hw/ppc/pnv.c           | 2 ++
>   2 files changed, 11 insertions(+)
> 
> diff --git a/hw/pci-host/pnv_phb3.c b/hw/pci-host/pnv_phb3.c
> index e91f658b0060..b61f9c369f64 100644
> --- a/hw/pci-host/pnv_phb3.c
> +++ b/hw/pci-host/pnv_phb3.c
> @@ -1000,6 +1000,9 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp)
>   
>       /* User created devices */
>       if (!phb->chip) {
> +        Error *local_err = NULL;
> +        BusState *s;
> +
>           phb->chip = pnv_get_chip(pnv, phb->chip_id);
>           if (!phb->chip) {
>               error_setg(errp, "invalid chip id: %d", phb->chip_id);
> @@ -1011,6 +1014,12 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp)
>            * correctly the device tree.
>            */
>           pnv_chip_parent_fixup(phb->chip, OBJECT(phb), phb->phb_id);
> +
> +        s = qdev_get_parent_bus(DEVICE(phb->chip));
> +        if (!qdev_set_parent_bus(DEVICE(phb), s, &local_err)) {
> +            error_propagate(errp, local_err);
> +            return;
> +        }
>       }
>   
>       /* LSI sources */
> diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
> index 9a458655efd9..45d8ecbf2bf7 100644
> --- a/hw/ppc/pnv.c
> +++ b/hw/ppc/pnv.c
> @@ -1927,6 +1927,8 @@ static void pnv_machine_power8_class_init(ObjectClass *oc, void *data)
>   
>       pmc->compat = compat;
>       pmc->compat_size = sizeof(compat);
> +
> +    machine_class_allow_dynamic_sysbus_dev(mc, TYPE_PNV_PHB3);
>   }
>   
>   static void pnv_machine_power9_class_init(ObjectClass *oc, void *data)
>
Cédric Le Goater Dec. 7, 2021, 10:19 a.m. UTC | #3
On 12/7/21 10:53, Frederic Barrat wrote:
> 
> 
> On 02/12/2021 15:42, Cédric Le Goater wrote:
>> PHB3s ared SysBus devices and should be allowed to be dynamically
>> created.
>>
>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>> ---
> 
> This one is a bit of black magic for me. 

Yes. QEMU internals related to sysbus. I am not an expert either.

> I don't see an equivalent for P9 though. Not needed there? 

No because the phb4-pec devices are simple devices. Not tied to sysbus.

Thanks,

C.

> I'll have another comment about P8/P9 later.
> 
>    Fred
> 
> 
>>   hw/pci-host/pnv_phb3.c | 9 +++++++++
>>   hw/ppc/pnv.c           | 2 ++
>>   2 files changed, 11 insertions(+)
>>
>> diff --git a/hw/pci-host/pnv_phb3.c b/hw/pci-host/pnv_phb3.c
>> index e91f658b0060..b61f9c369f64 100644
>> --- a/hw/pci-host/pnv_phb3.c
>> +++ b/hw/pci-host/pnv_phb3.c
>> @@ -1000,6 +1000,9 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp)
>>       /* User created devices */
>>       if (!phb->chip) {
>> +        Error *local_err = NULL;
>> +        BusState *s;
>> +
>>           phb->chip = pnv_get_chip(pnv, phb->chip_id);
>>           if (!phb->chip) {
>>               error_setg(errp, "invalid chip id: %d", phb->chip_id);
>> @@ -1011,6 +1014,12 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp)
>>            * correctly the device tree.
>>            */
>>           pnv_chip_parent_fixup(phb->chip, OBJECT(phb), phb->phb_id);
>> +
>> +        s = qdev_get_parent_bus(DEVICE(phb->chip));
>> +        if (!qdev_set_parent_bus(DEVICE(phb), s, &local_err)) {
>> +            error_propagate(errp, local_err);
>> +            return;
>> +        }
>>       }
>>       /* LSI sources */
>> diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
>> index 9a458655efd9..45d8ecbf2bf7 100644
>> --- a/hw/ppc/pnv.c
>> +++ b/hw/ppc/pnv.c
>> @@ -1927,6 +1927,8 @@ static void pnv_machine_power8_class_init(ObjectClass *oc, void *data)
>>       pmc->compat = compat;
>>       pmc->compat_size = sizeof(compat);
>> +
>> +    machine_class_allow_dynamic_sysbus_dev(mc, TYPE_PNV_PHB3);
>>   }
>>   static void pnv_machine_power9_class_init(ObjectClass *oc, void *data)
>>
diff mbox series

Patch

diff --git a/hw/pci-host/pnv_phb3.c b/hw/pci-host/pnv_phb3.c
index e91f658b0060..b61f9c369f64 100644
--- a/hw/pci-host/pnv_phb3.c
+++ b/hw/pci-host/pnv_phb3.c
@@ -1000,6 +1000,9 @@  static void pnv_phb3_realize(DeviceState *dev, Error **errp)
 
     /* User created devices */
     if (!phb->chip) {
+        Error *local_err = NULL;
+        BusState *s;
+
         phb->chip = pnv_get_chip(pnv, phb->chip_id);
         if (!phb->chip) {
             error_setg(errp, "invalid chip id: %d", phb->chip_id);
@@ -1011,6 +1014,12 @@  static void pnv_phb3_realize(DeviceState *dev, Error **errp)
          * correctly the device tree.
          */
         pnv_chip_parent_fixup(phb->chip, OBJECT(phb), phb->phb_id);
+
+        s = qdev_get_parent_bus(DEVICE(phb->chip));
+        if (!qdev_set_parent_bus(DEVICE(phb), s, &local_err)) {
+            error_propagate(errp, local_err);
+            return;
+        }
     }
 
     /* LSI sources */
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 9a458655efd9..45d8ecbf2bf7 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -1927,6 +1927,8 @@  static void pnv_machine_power8_class_init(ObjectClass *oc, void *data)
 
     pmc->compat = compat;
     pmc->compat_size = sizeof(compat);
+
+    machine_class_allow_dynamic_sysbus_dev(mc, TYPE_PNV_PHB3);
 }
 
 static void pnv_machine_power9_class_init(ObjectClass *oc, void *data)