All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Greg Kurz <groug@kaod.org>
Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org,
	"Cédric Le Goater" <clg@kaod.org>,
	"Bharata B Rao" <bharata@linux.vnet.ibm.com>,
	"Satheesh Rajendran" <sathnaga@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH] ppc/xics: fix ICP reset path
Date: Fri, 13 Jul 2018 10:10:23 +1000	[thread overview]
Message-ID: <20180713001023.GT22363@umbus.fritz.box> (raw)
In-Reply-To: <153138970964.331720.14349788349972574256.stgit@bahia>

[-- Attachment #1: Type: text/plain, Size: 3721 bytes --]

On Thu, Jul 12, 2018 at 12:01:49PM +0200, Greg Kurz wrote:
> Recent cleanup in commit a028dd423ee6 dropped the ICPStateClass::reset
> handler. It is now up to child ICP classes to call the DeviceClass::reset
> handler of the parent class, thanks to device_class_set_parent_reset().
> This is a better object programming pattern, but unfortunately it causes
> QEMU to crash during CPU hotplug:
> 
> (qemu) device_add host-spapr-cpu-core,id=core1,core-id=1
> Segmentation fault (core dumped)
> 
> When the hotplug path tries to reset the ICP device, we end up calling:
> 
> static void icp_kvm_reset(DeviceState *dev)
> {
>     ICPStateClass *icpc = ICP_GET_CLASS(dev);
> 
>     icpc->parent_reset(dev);
> 
> but icpc->parent_reset is NULL... This happens because icp_kvm_class_init()
> calls:
> 
>     device_class_set_parent_reset(dc, icp_kvm_reset,
>                                   &icpc->parent_reset);
> 
> but dc->reset, ie, DeviceClass::reset for the TYPE_ICP type, is
> itself NULL.
> 
> This patch hence sets DeviceClass::reset for the TYPE_ICP type to
> point to icp_reset(). It then registers a reset handler that calls
> DeviceClass::reset. If the ICP subtype has configured its own reset
> handler with device_class_set_parent_reset(), this ensures it will
> be called first and it can then call ICPStateClass::parent_reset
> safely. This fixes the reset path for the TYPE_KVM_ICP type, which
> is the only subtype that defines its own reset function.
> 
> Reported-by: Satheesh Rajendran <sathnaga@linux.vnet.ibm.com>
> Suggested-by: David Gibson <david@gibson.dropbear.id.au>
> Fixes: a028dd423ee6dfd091a8c63028240832bf10f671
> Signed-off-by: Greg Kurz <groug@kaod.org>

Much simpler than the previous version, thanks.

Applied to ppc-for-3.0.

> ---
>  hw/intc/xics.c |   14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/intc/xics.c b/hw/intc/xics.c
> index b9f1a3c97214..c90c893228dc 100644
> --- a/hw/intc/xics.c
> +++ b/hw/intc/xics.c
> @@ -291,7 +291,7 @@ static const VMStateDescription vmstate_icp_server = {
>      },
>  };
>  
> -static void icp_reset(void *dev)
> +static void icp_reset(DeviceState *dev)
>  {
>      ICPState *icp = ICP(dev);
>  
> @@ -303,6 +303,13 @@ static void icp_reset(void *dev)
>      qemu_set_irq(icp->output, 0);
>  }
>  
> +static void icp_reset_handler(void *dev)
> +{
> +    DeviceClass *dc = DEVICE_GET_CLASS(dev);
> +
> +    dc->reset(dev);
> +}
> +
>  static void icp_realize(DeviceState *dev, Error **errp)
>  {
>      ICPState *icp = ICP(dev);
> @@ -345,7 +352,7 @@ static void icp_realize(DeviceState *dev, Error **errp)
>          return;
>      }
>  
> -    qemu_register_reset(icp_reset, dev);
> +    qemu_register_reset(icp_reset_handler, dev);
>      vmstate_register(NULL, icp->cs->cpu_index, &vmstate_icp_server, icp);
>  }
>  
> @@ -354,7 +361,7 @@ static void icp_unrealize(DeviceState *dev, Error **errp)
>      ICPState *icp = ICP(dev);
>  
>      vmstate_unregister(NULL, &vmstate_icp_server, icp);
> -    qemu_unregister_reset(icp_reset, dev);
> +    qemu_unregister_reset(icp_reset_handler, dev);
>  }
>  
>  static void icp_class_init(ObjectClass *klass, void *data)
> @@ -363,6 +370,7 @@ static void icp_class_init(ObjectClass *klass, void *data)
>  
>      dc->realize = icp_realize;
>      dc->unrealize = icp_unrealize;
> +    dc->reset = icp_reset;
>  }
>  
>  static const TypeInfo icp_info = {
> 

-- 
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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2018-07-13  0:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-12 10:01 [Qemu-devel] [PATCH] ppc/xics: fix ICP reset path Greg Kurz
2018-07-13  0:10 ` David Gibson [this message]
2018-07-23 11:36 ` Cédric Le Goater
2018-07-23 17:51   ` Greg Kurz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180713001023.GT22363@umbus.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=bharata@linux.vnet.ibm.com \
    --cc=clg@kaod.org \
    --cc=groug@kaod.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=sathnaga@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.