From: David Gibson <david@gibson.dropbear.id.au>
To: "Cédric Le Goater" <clg@kaod.org>
Cc: Greg Kurz <groug@kaod.org>, qemu-ppc@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 13/13] spapr/xive: fix device hotplug when VM is stopped
Date: Tue, 26 Feb 2019 15:17:22 +1100 [thread overview]
Message-ID: <20190226041722.GO6872@umbus.fritz.box> (raw)
In-Reply-To: <20190222131322.26079-14-clg@kaod.org>
[-- Attachment #1: Type: text/plain, Size: 2850 bytes --]
On Fri, Feb 22, 2019 at 02:13:22PM +0100, Cédric Le Goater wrote:
> Instead of switching off the sources, set their state to PENDING to
> possibly catch a hotplug event occuring while the VM is stopped. At
> resume, check the previous state and if an interrupt was queued,
> generate a trigger.
First, I think it would be better to fold this fix into the patch
introducing the state change handlers.
Second, IIUC this would handle any instance of an irq being triggered
while the VM is stopped. Hotplug interrupts is one obvious case of
that, but I'm not sure its the only one. VFIO devices could interrupt
while the VM is stopped, I think. Maybe even emulated devices
depending on how their synchronization with the cpu run state works.
There might be other cases. Does that sound right to you?
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
> hw/intc/spapr_xive_kvm.c | 22 +++++++++++++++++++---
> 1 file changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c
> index 99a829fb3f60..64d160babb26 100644
> --- a/hw/intc/spapr_xive_kvm.c
> +++ b/hw/intc/spapr_xive_kvm.c
> @@ -500,8 +500,16 @@ static void kvmppc_xive_change_state_handler(void *opaque, int running,
> if (running) {
> for (i = 0; i < xsrc->nr_irqs; i++) {
> uint8_t pq = xive_source_esb_get(xsrc, i);
> - if (xive_esb_read(xsrc, i, XIVE_ESB_SET_PQ_00 + (pq << 8)) != 0x1) {
> - error_report("XIVE: IRQ %d has an invalid state", i);
> + uint8_t old_pq;
> +
> + old_pq = xive_esb_read(xsrc, i, XIVE_ESB_SET_PQ_00 + (pq << 8));
> +
> + /*
> + * If an interrupt was queued (hotplug event) while VM was
> + * stopped, generate a trigger.
> + */
> + if (pq == XIVE_ESB_RESET && old_pq == XIVE_ESB_QUEUED) {
> + xive_esb_trigger(xsrc, i);
> }
> }
>
> @@ -515,7 +523,15 @@ static void kvmppc_xive_change_state_handler(void *opaque, int running,
> * migration is in progress.
> */
> for (i = 0; i < xsrc->nr_irqs; i++) {
> - uint8_t pq = xive_esb_read(xsrc, i, XIVE_ESB_SET_PQ_01);
> + uint8_t pq = xive_esb_read(xsrc, i, XIVE_ESB_GET);
> +
> + /*
> + * PQ is set to PENDING to possibly catch a hotplug event
> + * occuring while the VM is stopped.
> + */
> + if (pq != XIVE_ESB_OFF) {
> + pq = xive_esb_read(xsrc, i, XIVE_ESB_SET_PQ_10);
> + }
> xive_source_esb_set(xsrc, i, pq);
> }
>
--
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 --]
next prev parent reply other threads:[~2019-02-26 4:17 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-22 13:13 [Qemu-devel] [PATCH v2 00/13] spapr: add KVM support to the XIVE interrupt mode Cédric Le Goater
2019-02-22 13:13 ` [Qemu-devel] [PATCH v2 01/13] spapr/xive: add KVM support Cédric Le Goater
2019-02-25 5:55 ` David Gibson
2019-03-11 15:53 ` Cédric Le Goater
2019-02-22 13:13 ` [Qemu-devel] [PATCH v2 02/13] spapr/xive: add hcall support when under KVM Cédric Le Goater
2019-02-25 23:22 ` David Gibson
2019-03-11 17:32 ` Cédric Le Goater
2019-02-22 13:13 ` [Qemu-devel] [PATCH v2 03/13] spapr/xive: activate KVM support Cédric Le Goater
2019-02-25 23:49 ` David Gibson
2019-02-25 23:49 ` David Gibson
2019-03-11 20:44 ` Cédric Le Goater
2019-02-22 13:13 ` [Qemu-devel] [PATCH v2 04/13] spapr/xive: add state synchronization with KVM Cédric Le Goater
2019-02-26 0:01 ` David Gibson
2019-03-11 20:41 ` Cédric Le Goater
2019-02-22 13:13 ` [Qemu-devel] [PATCH v2 05/13] spapr/xive: introduce a VM state change handler Cédric Le Goater
2019-02-26 0:39 ` David Gibson
2019-02-22 13:13 ` [Qemu-devel] [PATCH v2 06/13] spapr/xive: add migration support for KVM Cédric Le Goater
2019-02-26 0:58 ` David Gibson
2019-02-22 13:13 ` [Qemu-devel] [PATCH v2 07/13] spapr/xive: fix migration of the XiveTCTX under TCG Cédric Le Goater
2019-02-26 1:02 ` David Gibson
2019-03-11 20:45 ` Cédric Le Goater
2019-02-22 13:13 ` [Qemu-devel] [PATCH v2 08/13] spapr/rtas: modify spapr_rtas_register() to remove RTAS handlers Cédric Le Goater
2019-02-22 13:13 ` [Qemu-devel] [PATCH v2 09/13] sysbus: add a sysbus_mmio_unmap() helper Cédric Le Goater
2019-02-22 13:13 ` [Qemu-devel] [PATCH v2 10/13] spapr: introduce routines to delete the KVM IRQ device Cédric Le Goater
2019-02-26 1:10 ` David Gibson
2019-02-22 13:13 ` [Qemu-devel] [PATCH v2 11/13] spapr: check for the activation of " Cédric Le Goater
2019-02-26 1:27 ` David Gibson
2019-02-22 13:13 ` [Qemu-devel] [PATCH v2 12/13] spapr: add KVM support to the 'dual' machine Cédric Le Goater
2019-02-28 5:15 ` David Gibson
2019-02-22 13:13 ` [Qemu-devel] [PATCH v2 13/13] spapr/xive: fix device hotplug when VM is stopped Cédric Le Goater
2019-02-26 4:17 ` David Gibson [this message]
2019-03-11 20:59 ` Cédric Le Goater
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=20190226041722.GO6872@umbus.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=clg@kaod.org \
--cc=groug@kaod.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).