Message ID | 157841476035.66386.17838417527621752518.stgit@bahia.tlslab.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | ppc/pnv: Reset handler registration cleanup | expand |
On 1/7/20 5:32 PM, Greg Kurz wrote: > And call it from a QEMU reset handler. This allows each PNV child class to > override the reset hook if needed, eg. POWER8 doesn't but POWER9 does. > The proper way to do that would be to use device_class_set_parent_reset(), > but defining a Pnv8PsiClass and a Pnv9PsiClass types with a parent_reset > pointer adds a fair amount of code. Calling pnv_psi_reset() explicitely is > fine for now. > > A subsequent patch will consolidate the call to qemu_register_reset() in > a single place. > > Signed-off-by: Greg Kurz <groug@kaod.org> > Signed-off-by: Cédric Le Goater <clg@kaod.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> > --- > hw/ppc/pnv_psi.c | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > > diff --git a/hw/ppc/pnv_psi.c b/hw/ppc/pnv_psi.c > index 75e20d9da08b..6c94781e377d 100644 > --- a/hw/ppc/pnv_psi.c > +++ b/hw/ppc/pnv_psi.c > @@ -455,7 +455,7 @@ static const MemoryRegionOps pnv_psi_xscom_ops = { > } > }; > > -static void pnv_psi_reset(void *dev) > +static void pnv_psi_reset(DeviceState *dev) > { > PnvPsi *psi = PNV_PSI(dev); > > @@ -464,6 +464,11 @@ static void pnv_psi_reset(void *dev) > psi->regs[PSIHB_XSCOM_BAR] = psi->bar | PSIHB_BAR_EN; > } > > +static void pnv_psi_reset_handler(void *dev) > +{ > + device_reset(DEVICE(dev)); > +} > + > static void pnv_psi_power8_instance_init(Object *obj) > { > Pnv8Psi *psi8 = PNV8_PSI(obj); > @@ -533,7 +538,7 @@ static void pnv_psi_power8_realize(DeviceState *dev, Error **errp) > ((uint64_t) i << PSIHB_XIVR_SRC_SH); > } > > - qemu_register_reset(pnv_psi_reset, dev); > + qemu_register_reset(pnv_psi_reset_handler, dev); > } > > static int pnv_psi_dt_xscom(PnvXScomInterface *dev, void *fdt, int xscom_offset) > @@ -816,7 +821,7 @@ static void pnv_psi_power9_irq_set(PnvPsi *psi, int irq, bool state) > qemu_set_irq(psi->qirqs[irq], state); > } > > -static void pnv_psi_power9_reset(void *dev) > +static void pnv_psi_power9_reset(DeviceState *dev) > { > Pnv9Psi *psi = PNV9_PSI(dev); > > @@ -870,7 +875,7 @@ static void pnv_psi_power9_realize(DeviceState *dev, Error **errp) > > pnv_psi_set_bar(psi, psi->bar | PSIHB_BAR_EN); > > - qemu_register_reset(pnv_psi_power9_reset, dev); > + qemu_register_reset(pnv_psi_reset_handler, dev); > } > > static void pnv_psi_power9_class_init(ObjectClass *klass, void *data) > @@ -882,6 +887,7 @@ static void pnv_psi_power9_class_init(ObjectClass *klass, void *data) > > dc->desc = "PowerNV PSI Controller POWER9"; > dc->realize = pnv_psi_power9_realize; > + dc->reset = pnv_psi_power9_reset; > > ppc->xscom_pcba = PNV9_XSCOM_PSIHB_BASE; > ppc->xscom_size = PNV9_XSCOM_PSIHB_SIZE; > @@ -934,6 +940,7 @@ static void pnv_psi_class_init(ObjectClass *klass, void *data) > > dc->desc = "PowerNV PSI Controller"; > dc->props = pnv_psi_properties; > + dc->reset = pnv_psi_reset; > } > > static const TypeInfo pnv_psi_info = { > >
On Tue, Jan 07, 2020 at 05:32:40PM +0100, Greg Kurz wrote: > And call it from a QEMU reset handler. This allows each PNV child class to > override the reset hook if needed, eg. POWER8 doesn't but POWER9 does. > The proper way to do that would be to use device_class_set_parent_reset(), > but defining a Pnv8PsiClass and a Pnv9PsiClass types with a parent_reset > pointer adds a fair amount of code. Calling pnv_psi_reset() explicitely is > fine for now. > > A subsequent patch will consolidate the call to qemu_register_reset() in > a single place. > > Signed-off-by: Greg Kurz <groug@kaod.org> > Signed-off-by: Cédric Le Goater <clg@kaod.org> Applied to ppc-for-5.0, thanks. > --- > hw/ppc/pnv_psi.c | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > > diff --git a/hw/ppc/pnv_psi.c b/hw/ppc/pnv_psi.c > index 75e20d9da08b..6c94781e377d 100644 > --- a/hw/ppc/pnv_psi.c > +++ b/hw/ppc/pnv_psi.c > @@ -455,7 +455,7 @@ static const MemoryRegionOps pnv_psi_xscom_ops = { > } > }; > > -static void pnv_psi_reset(void *dev) > +static void pnv_psi_reset(DeviceState *dev) > { > PnvPsi *psi = PNV_PSI(dev); > > @@ -464,6 +464,11 @@ static void pnv_psi_reset(void *dev) > psi->regs[PSIHB_XSCOM_BAR] = psi->bar | PSIHB_BAR_EN; > } > > +static void pnv_psi_reset_handler(void *dev) > +{ > + device_reset(DEVICE(dev)); > +} > + > static void pnv_psi_power8_instance_init(Object *obj) > { > Pnv8Psi *psi8 = PNV8_PSI(obj); > @@ -533,7 +538,7 @@ static void pnv_psi_power8_realize(DeviceState *dev, Error **errp) > ((uint64_t) i << PSIHB_XIVR_SRC_SH); > } > > - qemu_register_reset(pnv_psi_reset, dev); > + qemu_register_reset(pnv_psi_reset_handler, dev); > } > > static int pnv_psi_dt_xscom(PnvXScomInterface *dev, void *fdt, int xscom_offset) > @@ -816,7 +821,7 @@ static void pnv_psi_power9_irq_set(PnvPsi *psi, int irq, bool state) > qemu_set_irq(psi->qirqs[irq], state); > } > > -static void pnv_psi_power9_reset(void *dev) > +static void pnv_psi_power9_reset(DeviceState *dev) > { > Pnv9Psi *psi = PNV9_PSI(dev); > > @@ -870,7 +875,7 @@ static void pnv_psi_power9_realize(DeviceState *dev, Error **errp) > > pnv_psi_set_bar(psi, psi->bar | PSIHB_BAR_EN); > > - qemu_register_reset(pnv_psi_power9_reset, dev); > + qemu_register_reset(pnv_psi_reset_handler, dev); > } > > static void pnv_psi_power9_class_init(ObjectClass *klass, void *data) > @@ -882,6 +887,7 @@ static void pnv_psi_power9_class_init(ObjectClass *klass, void *data) > > dc->desc = "PowerNV PSI Controller POWER9"; > dc->realize = pnv_psi_power9_realize; > + dc->reset = pnv_psi_power9_reset; > > ppc->xscom_pcba = PNV9_XSCOM_PSIHB_BASE; > ppc->xscom_size = PNV9_XSCOM_PSIHB_SIZE; > @@ -934,6 +940,7 @@ static void pnv_psi_class_init(ObjectClass *klass, void *data) > > dc->desc = "PowerNV PSI Controller"; > dc->props = pnv_psi_properties; > + dc->reset = pnv_psi_reset; > } > > static const TypeInfo pnv_psi_info = { >
diff --git a/hw/ppc/pnv_psi.c b/hw/ppc/pnv_psi.c index 75e20d9da08b..6c94781e377d 100644 --- a/hw/ppc/pnv_psi.c +++ b/hw/ppc/pnv_psi.c @@ -455,7 +455,7 @@ static const MemoryRegionOps pnv_psi_xscom_ops = { } }; -static void pnv_psi_reset(void *dev) +static void pnv_psi_reset(DeviceState *dev) { PnvPsi *psi = PNV_PSI(dev); @@ -464,6 +464,11 @@ static void pnv_psi_reset(void *dev) psi->regs[PSIHB_XSCOM_BAR] = psi->bar | PSIHB_BAR_EN; } +static void pnv_psi_reset_handler(void *dev) +{ + device_reset(DEVICE(dev)); +} + static void pnv_psi_power8_instance_init(Object *obj) { Pnv8Psi *psi8 = PNV8_PSI(obj); @@ -533,7 +538,7 @@ static void pnv_psi_power8_realize(DeviceState *dev, Error **errp) ((uint64_t) i << PSIHB_XIVR_SRC_SH); } - qemu_register_reset(pnv_psi_reset, dev); + qemu_register_reset(pnv_psi_reset_handler, dev); } static int pnv_psi_dt_xscom(PnvXScomInterface *dev, void *fdt, int xscom_offset) @@ -816,7 +821,7 @@ static void pnv_psi_power9_irq_set(PnvPsi *psi, int irq, bool state) qemu_set_irq(psi->qirqs[irq], state); } -static void pnv_psi_power9_reset(void *dev) +static void pnv_psi_power9_reset(DeviceState *dev) { Pnv9Psi *psi = PNV9_PSI(dev); @@ -870,7 +875,7 @@ static void pnv_psi_power9_realize(DeviceState *dev, Error **errp) pnv_psi_set_bar(psi, psi->bar | PSIHB_BAR_EN); - qemu_register_reset(pnv_psi_power9_reset, dev); + qemu_register_reset(pnv_psi_reset_handler, dev); } static void pnv_psi_power9_class_init(ObjectClass *klass, void *data) @@ -882,6 +887,7 @@ static void pnv_psi_power9_class_init(ObjectClass *klass, void *data) dc->desc = "PowerNV PSI Controller POWER9"; dc->realize = pnv_psi_power9_realize; + dc->reset = pnv_psi_power9_reset; ppc->xscom_pcba = PNV9_XSCOM_PSIHB_BASE; ppc->xscom_size = PNV9_XSCOM_PSIHB_SIZE; @@ -934,6 +940,7 @@ static void pnv_psi_class_init(ObjectClass *klass, void *data) dc->desc = "PowerNV PSI Controller"; dc->props = pnv_psi_properties; + dc->reset = pnv_psi_reset; } static const TypeInfo pnv_psi_info = {