[Qemu-devel] [for-2.11 PATCH 08/26] spapr_drc: add unrealize method to physical DRC class

Greg Kurz posted 26 patches 8 years, 3 months ago
[Qemu-devel] [for-2.11 PATCH 08/26] spapr_drc: add unrealize method to physical DRC class
Posted by Greg Kurz 8 years, 3 months ago
When hot-unplugging a PHB, all its PCI DRC connectors get unrealized. This
patch adds an unrealize method to the physical DRC class, in order to undo
registrations performed in realize_physical().

Signed-off-by: Greg Kurz <groug@kaod.org>
---
 hw/ppc/spapr_drc.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
index d72453bcb42f..105ce85b6d04 100644
--- a/hw/ppc/spapr_drc.c
+++ b/hw/ppc/spapr_drc.c
@@ -626,12 +626,28 @@ static void realize_physical(DeviceState *d, Error **errp)
     qemu_register_reset(drc_physical_reset, drcp);
 }
 
+static void unrealize_physical(DeviceState *d, Error **errp)
+{
+    sPAPRDRCPhysical *drcp = SPAPR_DRC_PHYSICAL(d);
+    Error *local_err = NULL;
+
+    unrealize(d, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
+
+    vmstate_unregister(DEVICE(drcp), &vmstate_spapr_drc_physical, drcp);
+    qemu_unregister_reset(drc_physical_reset, drcp);
+}
+
 static void spapr_drc_physical_class_init(ObjectClass *k, void *data)
 {
     DeviceClass *dk = DEVICE_CLASS(k);
     sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_CLASS(k);
 
     dk->realize = realize_physical;
+    dk->unrealize = unrealize_physical;
     drck->dr_entity_sense = physical_entity_sense;
     drck->isolate = drc_isolate_physical;
     drck->unisolate = drc_unisolate_physical;


Re: [Qemu-devel] [for-2.11 PATCH 08/26] spapr_drc: add unrealize method to physical DRC class
Posted by David Gibson 8 years, 3 months ago
On Tue, Jul 25, 2017 at 07:59:44PM +0200, Greg Kurz wrote:
> When hot-unplugging a PHB, all its PCI DRC connectors get unrealized. This
> patch adds an unrealize method to the physical DRC class, in order to undo
> registrations performed in realize_physical().
> 
> Signed-off-by: Greg Kurz <groug@kaod.org>

Applied to ppc-for-2.11.  In a sense this is fix that could be applied
to ppc-for-2.10, but unlike the last patch, AFAICT there's no way this
bug can be triggered in the current code.

> ---
>  hw/ppc/spapr_drc.c |   16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
> index d72453bcb42f..105ce85b6d04 100644
> --- a/hw/ppc/spapr_drc.c
> +++ b/hw/ppc/spapr_drc.c
> @@ -626,12 +626,28 @@ static void realize_physical(DeviceState *d, Error **errp)
>      qemu_register_reset(drc_physical_reset, drcp);
>  }
>  
> +static void unrealize_physical(DeviceState *d, Error **errp)
> +{
> +    sPAPRDRCPhysical *drcp = SPAPR_DRC_PHYSICAL(d);
> +    Error *local_err = NULL;
> +
> +    unrealize(d, &local_err);
> +    if (local_err) {
> +        error_propagate(errp, local_err);
> +        return;
> +    }
> +
> +    vmstate_unregister(DEVICE(drcp), &vmstate_spapr_drc_physical, drcp);
> +    qemu_unregister_reset(drc_physical_reset, drcp);
> +}
> +
>  static void spapr_drc_physical_class_init(ObjectClass *k, void *data)
>  {
>      DeviceClass *dk = DEVICE_CLASS(k);
>      sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_CLASS(k);
>  
>      dk->realize = realize_physical;
> +    dk->unrealize = unrealize_physical;
>      drck->dr_entity_sense = physical_entity_sense;
>      drck->isolate = drc_isolate_physical;
>      drck->unisolate = drc_unisolate_physical;
> 

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [for-2.11 PATCH 08/26] spapr_drc: add unrealize method to physical DRC class
Posted by Greg Kurz 8 years, 3 months ago
On Wed, 26 Jul 2017 14:06:29 +1000
David Gibson <david@gibson.dropbear.id.au> wrote:

> On Tue, Jul 25, 2017 at 07:59:44PM +0200, Greg Kurz wrote:
> > When hot-unplugging a PHB, all its PCI DRC connectors get unrealized. This
> > patch adds an unrealize method to the physical DRC class, in order to undo
> > registrations performed in realize_physical().
> > 
> > Signed-off-by: Greg Kurz <groug@kaod.org>  
> 
> Applied to ppc-for-2.11.  In a sense this is fix that could be applied
> to ppc-for-2.10, but unlike the last patch, AFAICT there's no way this
> bug can be triggered in the current code.
> 

Correct. The current code won't unrealize DRCs.

> > ---
> >  hw/ppc/spapr_drc.c |   16 ++++++++++++++++
> >  1 file changed, 16 insertions(+)
> > 
> > diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
> > index d72453bcb42f..105ce85b6d04 100644
> > --- a/hw/ppc/spapr_drc.c
> > +++ b/hw/ppc/spapr_drc.c
> > @@ -626,12 +626,28 @@ static void realize_physical(DeviceState *d, Error **errp)
> >      qemu_register_reset(drc_physical_reset, drcp);
> >  }
> >  
> > +static void unrealize_physical(DeviceState *d, Error **errp)
> > +{
> > +    sPAPRDRCPhysical *drcp = SPAPR_DRC_PHYSICAL(d);
> > +    Error *local_err = NULL;
> > +
> > +    unrealize(d, &local_err);
> > +    if (local_err) {
> > +        error_propagate(errp, local_err);
> > +        return;
> > +    }
> > +
> > +    vmstate_unregister(DEVICE(drcp), &vmstate_spapr_drc_physical, drcp);
> > +    qemu_unregister_reset(drc_physical_reset, drcp);
> > +}
> > +
> >  static void spapr_drc_physical_class_init(ObjectClass *k, void *data)
> >  {
> >      DeviceClass *dk = DEVICE_CLASS(k);
> >      sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_CLASS(k);
> >  
> >      dk->realize = realize_physical;
> > +    dk->unrealize = unrealize_physical;
> >      drck->dr_entity_sense = physical_entity_sense;
> >      drck->isolate = drc_isolate_physical;
> >      drck->unisolate = drc_unisolate_physical;
> >   
>