All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v3] PXB: convert to realize()
@ 2015-12-22 12:50 Cao jin
  2015-12-22 14:11 ` Marcel Apfelbaum
  0 siblings, 1 reply; 5+ messages in thread
From: Cao jin @ 2015-12-22 12:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcel, pbonzini

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
---
v3 changelog:
1. As per Paolo`s review, also Marcel`s test suggestion, just unparent bus
   object while unref the ds & bds object

 hw/pci-bridge/pci_expander_bridge.c | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c
index 57f8a37..7db6a78 100644
--- a/hw/pci-bridge/pci_expander_bridge.c
+++ b/hw/pci-bridge/pci_expander_bridge.c
@@ -145,25 +145,23 @@ static const TypeInfo pxb_host_info = {
  * Returns 0 on successs, -1 if i440fx host was not
  * found or the bus number is already in use.
  */
-static int pxb_register_bus(PCIDevice *dev, PCIBus *pxb_bus)
+static void pxb_register_bus(PCIDevice *dev, PCIBus *pxb_bus, Error **errp)
 {
     PCIBus *bus = dev->bus;
     int pxb_bus_num = pci_bus_num(pxb_bus);
 
     if (bus->parent_dev) {
-        error_report("PXB devices can be attached only to root bus.");
-        return -1;
+        error_setg(errp, "PXB devices can be attached only to root bus.");
+        return;
     }
 
     QLIST_FOREACH(bus, &bus->child, sibling) {
         if (pci_bus_num(bus) == pxb_bus_num) {
-            error_report("Bus %d is already in use.", pxb_bus_num);
-            return -1;
+            error_setg(errp, "Bus %d is already in use.", pxb_bus_num);
+            return;
         }
     }
     QLIST_INSERT_HEAD(&dev->bus->child, pxb_bus, sibling);
-
-    return 0;
 }
 
 static int pxb_map_irq_fn(PCIDevice *pci_dev, int pin)
@@ -193,7 +191,7 @@ static gint pxb_compare(gconstpointer a, gconstpointer b)
            0;
 }
 
-static int pxb_dev_initfn(PCIDevice *dev)
+static void pxb_dev_realize(PCIDevice *dev, Error **errp)
 {
     PXBDev *pxb = PXB_DEV(dev);
     DeviceState *ds, *bds;
@@ -202,8 +200,8 @@ static int pxb_dev_initfn(PCIDevice *dev)
 
     if (pxb->numa_node != NUMA_NODE_UNASSIGNED &&
         pxb->numa_node >= nb_numa_nodes) {
-        error_report("Illegal numa node %d.", pxb->numa_node);
-        return -EINVAL;
+        error_setg(errp, "Illegal numa node %d.", pxb->numa_node);
+        return;
     }
 
     if (dev->qdev.id && *dev->qdev.id) {
@@ -225,8 +223,9 @@ static int pxb_dev_initfn(PCIDevice *dev)
 
     PCI_HOST_BRIDGE(ds)->bus = bus;
 
-    if (pxb_register_bus(dev, bus)) {
-        return -EINVAL;
+    pxb_register_bus(dev, bus, errp);
+    if (*errp) {
+        goto err_register_bus;
     }
 
     qdev_init_nofail(ds);
@@ -237,7 +236,13 @@ static int pxb_dev_initfn(PCIDevice *dev)
     pci_config_set_class(dev->config, PCI_CLASS_BRIDGE_HOST);
 
     pxb_dev_list = g_list_insert_sorted(pxb_dev_list, pxb, pxb_compare);
-    return 0;
+
+    return;
+
+err_register_bus:
+    object_unref(OBJECT(bds));
+    object_unparent(OBJECT(bus));
+    object_unref(OBJECT(ds));
 }
 
 static void pxb_dev_exitfn(PCIDevice *pci_dev)
@@ -259,7 +264,7 @@ static void pxb_dev_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
-    k->init = pxb_dev_initfn;
+    k->realize = pxb_dev_realize;
     k->exit = pxb_dev_exitfn;
     k->vendor_id = PCI_VENDOR_ID_REDHAT;
     k->device_id = PCI_DEVICE_ID_REDHAT_PXB;
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v3] PXB: convert to realize()
  2015-12-22 12:50 [Qemu-devel] [PATCH v3] PXB: convert to realize() Cao jin
@ 2015-12-22 14:11 ` Marcel Apfelbaum
  2016-01-10  7:27   ` Cao jin
  0 siblings, 1 reply; 5+ messages in thread
From: Marcel Apfelbaum @ 2015-12-22 14:11 UTC (permalink / raw)
  To: Cao jin, qemu-devel; +Cc: pbonzini

On 12/22/2015 02:50 PM, Cao jin wrote:
> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
> ---
> v3 changelog:
> 1. As per Paolo`s review, also Marcel`s test suggestion, just unparent bus
>     object while unref the ds & bds object
>
>   hw/pci-bridge/pci_expander_bridge.c | 33 +++++++++++++++++++--------------
>   1 file changed, 19 insertions(+), 14 deletions(-)
>
> diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c
> index 57f8a37..7db6a78 100644
> --- a/hw/pci-bridge/pci_expander_bridge.c
> +++ b/hw/pci-bridge/pci_expander_bridge.c
> @@ -145,25 +145,23 @@ static const TypeInfo pxb_host_info = {
>    * Returns 0 on successs, -1 if i440fx host was not
>    * found or the bus number is already in use.
>    */
> -static int pxb_register_bus(PCIDevice *dev, PCIBus *pxb_bus)
> +static void pxb_register_bus(PCIDevice *dev, PCIBus *pxb_bus, Error **errp)
>   {
>       PCIBus *bus = dev->bus;
>       int pxb_bus_num = pci_bus_num(pxb_bus);
>
>       if (bus->parent_dev) {
> -        error_report("PXB devices can be attached only to root bus.");
> -        return -1;
> +        error_setg(errp, "PXB devices can be attached only to root bus.");
> +        return;
>       }
>
>       QLIST_FOREACH(bus, &bus->child, sibling) {
>           if (pci_bus_num(bus) == pxb_bus_num) {
> -            error_report("Bus %d is already in use.", pxb_bus_num);
> -            return -1;
> +            error_setg(errp, "Bus %d is already in use.", pxb_bus_num);
> +            return;
>           }
>       }
>       QLIST_INSERT_HEAD(&dev->bus->child, pxb_bus, sibling);
> -
> -    return 0;
>   }
>
>   static int pxb_map_irq_fn(PCIDevice *pci_dev, int pin)
> @@ -193,7 +191,7 @@ static gint pxb_compare(gconstpointer a, gconstpointer b)
>              0;
>   }
>
> -static int pxb_dev_initfn(PCIDevice *dev)
> +static void pxb_dev_realize(PCIDevice *dev, Error **errp)
>   {
>       PXBDev *pxb = PXB_DEV(dev);
>       DeviceState *ds, *bds;
> @@ -202,8 +200,8 @@ static int pxb_dev_initfn(PCIDevice *dev)
>
>       if (pxb->numa_node != NUMA_NODE_UNASSIGNED &&
>           pxb->numa_node >= nb_numa_nodes) {
> -        error_report("Illegal numa node %d.", pxb->numa_node);
> -        return -EINVAL;
> +        error_setg(errp, "Illegal numa node %d.", pxb->numa_node);
> +        return;
>       }
>
>       if (dev->qdev.id && *dev->qdev.id) {
> @@ -225,8 +223,9 @@ static int pxb_dev_initfn(PCIDevice *dev)
>
>       PCI_HOST_BRIDGE(ds)->bus = bus;
>
> -    if (pxb_register_bus(dev, bus)) {
> -        return -EINVAL;
> +    pxb_register_bus(dev, bus, errp);
> +    if (*errp) {
> +        goto err_register_bus;
>       }
>
>       qdev_init_nofail(ds);
> @@ -237,7 +236,13 @@ static int pxb_dev_initfn(PCIDevice *dev)
>       pci_config_set_class(dev->config, PCI_CLASS_BRIDGE_HOST);
>
>       pxb_dev_list = g_list_insert_sorted(pxb_dev_list, pxb, pxb_compare);
> -    return 0;
> +
> +    return;
> +
> +err_register_bus:
> +    object_unref(OBJECT(bds));
> +    object_unparent(OBJECT(bus));
> +    object_unref(OBJECT(ds));
>   }
>
>   static void pxb_dev_exitfn(PCIDevice *pci_dev)
> @@ -259,7 +264,7 @@ static void pxb_dev_class_init(ObjectClass *klass, void *data)
>       DeviceClass *dc = DEVICE_CLASS(klass);
>       PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
>
> -    k->init = pxb_dev_initfn;
> +    k->realize = pxb_dev_realize;
>       k->exit = pxb_dev_exitfn;
>       k->vendor_id = PCI_VENDOR_ID_REDHAT;
>       k->device_id = PCI_DEVICE_ID_REDHAT_PXB;
>


Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>


Thanks,
Marcel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v3] PXB: convert to realize()
  2015-12-22 14:11 ` Marcel Apfelbaum
@ 2016-01-10  7:27   ` Cao jin
  2016-01-11 15:44     ` Markus Armbruster
  0 siblings, 1 reply; 5+ messages in thread
From: Cao jin @ 2016-01-10  7:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marcel Apfelbaum, pbonzini

Hi,
     The patch has been reviewed by: Marcel Apfelbaum 
<marcel@redhat.com>, but still not seeing it in upstream, is it missed?

On 12/22/2015 10:11 PM, Marcel Apfelbaum wrote:
> On 12/22/2015 02:50 PM, Cao jin wrote:
>> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
>> ---
>> v3 changelog:
>> 1. As per Paolo`s review, also Marcel`s test suggestion, just unparent
>> bus
>>     object while unref the ds & bds object
>>
>>   hw/pci-bridge/pci_expander_bridge.c | 33
>> +++++++++++++++++++--------------
>>   1 file changed, 19 insertions(+), 14 deletions(-)
>>
>> diff --git a/hw/pci-bridge/pci_expander_bridge.c
>> b/hw/pci-bridge/pci_expander_bridge.c
>> index 57f8a37..7db6a78 100644
>> --- a/hw/pci-bridge/pci_expander_bridge.c
>> +++ b/hw/pci-bridge/pci_expander_bridge.c
>> @@ -145,25 +145,23 @@ static const TypeInfo pxb_host_info = {
>>    * Returns 0 on successs, -1 if i440fx host was not
>>    * found or the bus number is already in use.
>>    */
>> -static int pxb_register_bus(PCIDevice *dev, PCIBus *pxb_bus)
>> +static void pxb_register_bus(PCIDevice *dev, PCIBus *pxb_bus, Error
>> **errp)
>>   {
>>       PCIBus *bus = dev->bus;
>>       int pxb_bus_num = pci_bus_num(pxb_bus);
>>
>>       if (bus->parent_dev) {
>> -        error_report("PXB devices can be attached only to root bus.");
>> -        return -1;
>> +        error_setg(errp, "PXB devices can be attached only to root
>> bus.");
>> +        return;
>>       }
>>
>>       QLIST_FOREACH(bus, &bus->child, sibling) {
>>           if (pci_bus_num(bus) == pxb_bus_num) {
>> -            error_report("Bus %d is already in use.", pxb_bus_num);
>> -            return -1;
>> +            error_setg(errp, "Bus %d is already in use.", pxb_bus_num);
>> +            return;
>>           }
>>       }
>>       QLIST_INSERT_HEAD(&dev->bus->child, pxb_bus, sibling);
>> -
>> -    return 0;
>>   }
>>
>>   static int pxb_map_irq_fn(PCIDevice *pci_dev, int pin)
>> @@ -193,7 +191,7 @@ static gint pxb_compare(gconstpointer a,
>> gconstpointer b)
>>              0;
>>   }
>>
>> -static int pxb_dev_initfn(PCIDevice *dev)
>> +static void pxb_dev_realize(PCIDevice *dev, Error **errp)
>>   {
>>       PXBDev *pxb = PXB_DEV(dev);
>>       DeviceState *ds, *bds;
>> @@ -202,8 +200,8 @@ static int pxb_dev_initfn(PCIDevice *dev)
>>
>>       if (pxb->numa_node != NUMA_NODE_UNASSIGNED &&
>>           pxb->numa_node >= nb_numa_nodes) {
>> -        error_report("Illegal numa node %d.", pxb->numa_node);
>> -        return -EINVAL;
>> +        error_setg(errp, "Illegal numa node %d.", pxb->numa_node);
>> +        return;
>>       }
>>
>>       if (dev->qdev.id && *dev->qdev.id) {
>> @@ -225,8 +223,9 @@ static int pxb_dev_initfn(PCIDevice *dev)
>>
>>       PCI_HOST_BRIDGE(ds)->bus = bus;
>>
>> -    if (pxb_register_bus(dev, bus)) {
>> -        return -EINVAL;
>> +    pxb_register_bus(dev, bus, errp);
>> +    if (*errp) {
>> +        goto err_register_bus;
>>       }
>>
>>       qdev_init_nofail(ds);
>> @@ -237,7 +236,13 @@ static int pxb_dev_initfn(PCIDevice *dev)
>>       pci_config_set_class(dev->config, PCI_CLASS_BRIDGE_HOST);
>>
>>       pxb_dev_list = g_list_insert_sorted(pxb_dev_list, pxb,
>> pxb_compare);
>> -    return 0;
>> +
>> +    return;
>> +
>> +err_register_bus:
>> +    object_unref(OBJECT(bds));
>> +    object_unparent(OBJECT(bus));
>> +    object_unref(OBJECT(ds));
>>   }
>>
>>   static void pxb_dev_exitfn(PCIDevice *pci_dev)
>> @@ -259,7 +264,7 @@ static void pxb_dev_class_init(ObjectClass *klass,
>> void *data)
>>       DeviceClass *dc = DEVICE_CLASS(klass);
>>       PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
>>
>> -    k->init = pxb_dev_initfn;
>> +    k->realize = pxb_dev_realize;
>>       k->exit = pxb_dev_exitfn;
>>       k->vendor_id = PCI_VENDOR_ID_REDHAT;
>>       k->device_id = PCI_DEVICE_ID_REDHAT_PXB;
>>
>
>
> Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
>
>
> Thanks,
> Marcel
>
>
>
> .
>

-- 
Yours Sincerely,

Cao jin

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v3] PXB: convert to realize()
  2016-01-10  7:27   ` Cao jin
@ 2016-01-11 15:44     ` Markus Armbruster
  0 siblings, 0 replies; 5+ messages in thread
From: Markus Armbruster @ 2016-01-11 15:44 UTC (permalink / raw)
  To: Cao jin; +Cc: Marcel Apfelbaum, pbonzini, qemu-devel, Michael S. Tsirkin

Cao jin <caoj.fnst@cn.fujitsu.com> writes:

> Hi,
>     The patch has been reviewed by: Marcel Apfelbaum
> <marcel@redhat.com>, but still not seeing it in upstream, is it
> missed?

Copying the maintainer you forgot :)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH v3] PXB: convert to realize()
@ 2015-12-22 11:48 Cao jin
  0 siblings, 0 replies; 5+ messages in thread
From: Cao jin @ 2015-12-22 11:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcel, pbonzini, mst

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
---
v3 changelog:
1. As per Paolo`s review, also Marcel`s test suggestion, just unparent bus
   object while unref the ds & bds object

 hw/pci-bridge/pci_expander_bridge.c | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c
index 57f8a37..7db6a78 100644
--- a/hw/pci-bridge/pci_expander_bridge.c
+++ b/hw/pci-bridge/pci_expander_bridge.c
@@ -145,25 +145,23 @@ static const TypeInfo pxb_host_info = {
  * Returns 0 on successs, -1 if i440fx host was not
  * found or the bus number is already in use.
  */
-static int pxb_register_bus(PCIDevice *dev, PCIBus *pxb_bus)
+static void pxb_register_bus(PCIDevice *dev, PCIBus *pxb_bus, Error **errp)
 {
     PCIBus *bus = dev->bus;
     int pxb_bus_num = pci_bus_num(pxb_bus);
 
     if (bus->parent_dev) {
-        error_report("PXB devices can be attached only to root bus.");
-        return -1;
+        error_setg(errp, "PXB devices can be attached only to root bus.");
+        return;
     }
 
     QLIST_FOREACH(bus, &bus->child, sibling) {
         if (pci_bus_num(bus) == pxb_bus_num) {
-            error_report("Bus %d is already in use.", pxb_bus_num);
-            return -1;
+            error_setg(errp, "Bus %d is already in use.", pxb_bus_num);
+            return;
         }
     }
     QLIST_INSERT_HEAD(&dev->bus->child, pxb_bus, sibling);
-
-    return 0;
 }
 
 static int pxb_map_irq_fn(PCIDevice *pci_dev, int pin)
@@ -193,7 +191,7 @@ static gint pxb_compare(gconstpointer a, gconstpointer b)
            0;
 }
 
-static int pxb_dev_initfn(PCIDevice *dev)
+static void pxb_dev_realize(PCIDevice *dev, Error **errp)
 {
     PXBDev *pxb = PXB_DEV(dev);
     DeviceState *ds, *bds;
@@ -202,8 +200,8 @@ static int pxb_dev_initfn(PCIDevice *dev)
 
     if (pxb->numa_node != NUMA_NODE_UNASSIGNED &&
         pxb->numa_node >= nb_numa_nodes) {
-        error_report("Illegal numa node %d.", pxb->numa_node);
-        return -EINVAL;
+        error_setg(errp, "Illegal numa node %d.", pxb->numa_node);
+        return;
     }
 
     if (dev->qdev.id && *dev->qdev.id) {
@@ -225,8 +223,9 @@ static int pxb_dev_initfn(PCIDevice *dev)
 
     PCI_HOST_BRIDGE(ds)->bus = bus;
 
-    if (pxb_register_bus(dev, bus)) {
-        return -EINVAL;
+    pxb_register_bus(dev, bus, errp);
+    if (*errp) {
+        goto err_register_bus;
     }
 
     qdev_init_nofail(ds);
@@ -237,7 +236,13 @@ static int pxb_dev_initfn(PCIDevice *dev)
     pci_config_set_class(dev->config, PCI_CLASS_BRIDGE_HOST);
 
     pxb_dev_list = g_list_insert_sorted(pxb_dev_list, pxb, pxb_compare);
-    return 0;
+
+    return;
+
+err_register_bus:
+    object_unref(OBJECT(bds));
+    object_unparent(OBJECT(bus));
+    object_unref(OBJECT(ds));
 }
 
 static void pxb_dev_exitfn(PCIDevice *pci_dev)
@@ -259,7 +264,7 @@ static void pxb_dev_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
-    k->init = pxb_dev_initfn;
+    k->realize = pxb_dev_realize;
     k->exit = pxb_dev_exitfn;
     k->vendor_id = PCI_VENDOR_ID_REDHAT;
     k->device_id = PCI_DEVICE_ID_REDHAT_PXB;
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-01-11 15:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-22 12:50 [Qemu-devel] [PATCH v3] PXB: convert to realize() Cao jin
2015-12-22 14:11 ` Marcel Apfelbaum
2016-01-10  7:27   ` Cao jin
2016-01-11 15:44     ` Markus Armbruster
  -- strict thread matches above, loose matches on Subject: below --
2015-12-22 11:48 Cao jin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.