From: David Gibson <david@gibson.dropbear.id.au>
To: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, benh@kernel.crashing.org
Subject: Re: [Qemu-devel] [PATCH 8/8] openpic: Fix problem when IRQ transitions from edge to level
Date: Tue, 19 Sep 2017 06:39:48 +1000 [thread overview]
Message-ID: <20170918203948.GA27153@umbus> (raw)
In-Reply-To: <1505668548-16616-9-git-send-email-mark.cave-ayland@ilande.co.uk>
[-- Attachment #1: Type: text/plain, Size: 4634 bytes --]
On Sun, Sep 17, 2017 at 06:15:48PM +0100, Mark Cave-Ayland wrote:
> From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>
> Some interrupts get triggered before the OS has setup the
> right interrupt type. If an edge interrupt is latched that
> way, not delivered (still masked), then the interrupt is
> changed to level and isn't asserted anymore, it will be
> stuck "pending", causing an interrupt flood. This can happen
> with the PMU GPIO interrupt for example.
>
> There are a few other corner cases like this, so let's keep
> track of the input "level" so we can properly re-evaluate
> when the trigger type changes.
>
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
> hw/intc/openpic.c | 32 +++++++++++++++++++++++++++-----
> 1 file changed, 27 insertions(+), 5 deletions(-)
>
> diff --git a/hw/intc/openpic.c b/hw/intc/openpic.c
> index debfcbf..34749f8 100644
> --- a/hw/intc/openpic.c
> +++ b/hw/intc/openpic.c
> @@ -236,6 +236,7 @@ typedef struct IRQSource {
> int last_cpu;
> int output; /* IRQ level, e.g. OPENPIC_OUTPUT_INT */
> int pending; /* TRUE if IRQ is pending */
> + int cur_level; /* Cache current level */
> IRQType type;
> bool level:1; /* level-triggered */
> bool nomask:1; /* critical interrupts ignore mask on some FSL MPICs */
> @@ -552,14 +553,26 @@ static void openpic_set_irq(void *opaque, int n_IRQ, int level)
> }
>
> src = &opp->src[n_IRQ];
> - DPRINTF("openpic: set irq %d = %d ivpr=0x%08x\n",
> - n_IRQ, level, src->ivpr);
> + DPRINTF("openpic: set irq %d = %d ivpr=0x%08x (l=%d,cl=%d)\n",
> + n_IRQ, level, src->ivpr, src->level, src->cur_level);
> +
> + /* Keep track of the current input level in order to properly deal
> + * with the configuration of the source changing from edge to level
> + * after it's been latched. Otherwise the interrupt can get stuck.
> + */
> + src->cur_level = level;
> +
> if (src->level) {
> - /* level-sensitive irq */
> src->pending = level;
> openpic_update_irq(opp, n_IRQ);
> } else {
> - /* edge-sensitive irq */
> + /* edge-sensitive irq
> + *
> + * In an ideal world we would only set pending on an "edge", ie
> + * if level is set and src->cur_level as clear. However that would
> + * require all the devices to properly send "pulses" rather than
> + * just "raise" which isn't the case today.
> + */
> if (level) {
> src->pending = 1;
> openpic_update_irq(opp, n_IRQ);
> @@ -676,6 +689,13 @@ static inline void write_IRQreg_ivpr(OpenPICState *opp, int n_IRQ, uint32_t val)
> switch (opp->src[n_IRQ].type) {
> case IRQ_TYPE_NORMAL:
> opp->src[n_IRQ].level = !!(opp->src[n_IRQ].ivpr & IVPR_SENSE_MASK);
> +
> + /* If we switched to level we need to re-evaluate "pending" based
> + * on the actual input state.
> + */
> + if (opp->src[n_IRQ].level) {
> + opp->src[n_IRQ].pending = opp->src[n_IRQ].cur_level;
> + }
> break;
>
> case IRQ_TYPE_FSLINT:
> @@ -687,6 +707,7 @@ static inline void write_IRQreg_ivpr(OpenPICState *opp, int n_IRQ, uint32_t val)
> break;
> }
>
> + /* Re-evaluate a level irq */
> openpic_update_irq(opp, n_IRQ);
> DPRINTF("Set IVPR %d to 0x%08x -> 0x%08x\n", n_IRQ, val,
> opp->src[n_IRQ].ivpr);
> @@ -1232,7 +1253,7 @@ static uint32_t openpic_iack(OpenPICState *opp, IRQDest *dst, int cpu)
> }
>
> if (!src->level) {
> - /* edge-sensitive IRQ */
> + /* edge-sensitive IRQ or level dropped */
> src->ivpr &= ~IVPR_ACTIVITY_MASK;
> src->pending = 0;
> IRQ_resetbit(&dst->raised, irq);
> @@ -1564,6 +1585,7 @@ static const VMStateDescription vmstate_openpic_irqsource = {
> VMSTATE_UINT32(destmask, IRQSource),
> VMSTATE_INT32(last_cpu, IRQSource),
> VMSTATE_INT32(pending, IRQSource),
> + VMSTATE_INT32(cur_level, IRQSource),
> VMSTATE_END_OF_LIST()
This alters the migration stream without bumping the version number.
I suspect it will be best to move this hunk into your other patch
updating the migration of the openpic.
> }
> };
--
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:[~2017-09-19 10:36 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-17 17:15 [Qemu-devel] [PATCH 0/8] ppc: more Mac-related fixups Mark Cave-Ayland
2017-09-17 17:15 ` [Qemu-devel] [PATCH 1/8] ppc: QOMify g3beige machine Mark Cave-Ayland
2017-09-18 3:42 ` Philippe Mathieu-Daudé
2017-09-18 20:25 ` David Gibson
2017-09-17 17:15 ` [Qemu-devel] [PATCH 2/8] ppc/mac: Advertise a high clock frequency for NewWorld Macs Mark Cave-Ayland
2017-09-18 20:25 ` David Gibson
2017-09-17 17:15 ` [Qemu-devel] [PATCH 3/8] ppc/ide/macio: Add missing registers Mark Cave-Ayland
2017-09-18 20:27 ` David Gibson
2017-09-17 17:15 ` [Qemu-devel] [PATCH 4/8] macio: convert pmac_ide_ops from old_mmio Mark Cave-Ayland
2017-09-18 20:36 ` David Gibson
2017-09-19 19:31 ` Mark Cave-Ayland
2017-09-17 17:15 ` [Qemu-devel] [PATCH 5/8] ppc/mac: More rework of the DBDMA emulation Mark Cave-Ayland
2017-09-18 20:37 ` David Gibson
2017-09-17 17:15 ` [Qemu-devel] [PATCH 6/8] ppc: Fix OpenPIC model Mark Cave-Ayland
2017-09-18 20:37 ` David Gibson
2017-09-17 17:15 ` [Qemu-devel] [PATCH 7/8] openpic: add missing timer fields to vmstate_openpic_timer Mark Cave-Ayland
2017-09-18 22:44 ` David Gibson
2017-09-19 19:50 ` Mark Cave-Ayland
2017-09-20 12:04 ` David Gibson
2017-09-17 17:15 ` [Qemu-devel] [PATCH 8/8] openpic: Fix problem when IRQ transitions from edge to level Mark Cave-Ayland
2017-09-18 20:39 ` David Gibson [this message]
2017-09-19 19:52 ` Mark Cave-Ayland
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=20170918203948.GA27153@umbus \
--to=david@gibson.dropbear.id.au \
--cc=benh@kernel.crashing.org \
--cc=mark.cave-ayland@ilande.co.uk \
--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).