qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@kernel.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Guenter Roeck <linux@roeck-us.net>,
	Klaus Jensen <its@irrelevant.dk>, Jens Axboe <axboe@fb.com>,
	Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
	linux-nvme@lists.infradead.org, qemu-block@nongnu.org,
	qemu-devel@nongnu.org
Subject: Re: completion timeouts with pin-based interrupts in QEMU hw/nvme
Date: Wed, 18 Jan 2023 16:06:16 -0700	[thread overview]
Message-ID: <Y8h7aOuVfCb+RsAP@kbusch-mbp> (raw)
In-Reply-To: <Y8gfQXPYdHKd1v4I@kbusch-mbp>

On Wed, Jan 18, 2023 at 09:33:05AM -0700, Keith Busch wrote:
> On Wed, Jan 18, 2023 at 03:04:06PM +0000, Peter Maydell wrote:
> > On Tue, 17 Jan 2023 at 19:21, Guenter Roeck <linux@roeck-us.net> wrote:
> > > Anyway - any idea what to do to help figuring out what is happening ?
> > > Add tracing support to pci interrupt handling, maybe ?
> > 
> > For intermittent bugs, I like recording the QEMU session under
> > rr (using its chaos mode to provoke the failure if necessary) to
> > get a recording that I can debug and re-debug at leisure. Usually
> > you want to turn on/add tracing to help with this, and if the
> > failure doesn't hit early in bootup then you might need to
> > do a QEMU snapshot just before point-of-failure so you can
> > run rr only on the short snapshot-to-failure segment.
> > 
> > https://translatedcode.wordpress.com/2015/05/30/tricks-for-debugging-qemu-rr/
> > https://translatedcode.wordpress.com/2015/07/06/tricks-for-debugging-qemu-savevm-snapshots/
> > 
> > This gives you a debugging session from the QEMU side's perspective,
> > of course -- assuming you know what the hardware is supposed to do
> > you hopefully wind up with either "the guest software did X,Y,Z
> > and we incorrectly did A" or else "the guest software did X,Y,Z,
> > the spec says A is the right/a permitted thing but the guest got confused".
> > If it's the latter then you have to look at the guest as a separate
> > code analysis/debug problem.
> 
> Here's what I got, though I'm way out of my depth here.
> 
> It looks like Linux kernel's fasteoi for RISC-V's PLIC claims the
> interrupt after its first handling, which I think is expected. After
> claiming, QEMU masks the pending interrupt, lowering the level, though
> the device that raised it never deasserted.

I'm not sure if this is correct, but this is what I'm coming up with and
appears to fix the problem on my setup. The hardware that sets the
pending interrupt is going clear it, so I don't see why the interrupt
controller is automatically clearing it when the host claims it.

---
diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c
index c2dfacf028..f8f7af08dc 100644
--- a/hw/intc/sifive_plic.c
+++ b/hw/intc/sifive_plic.c
@@ -157,7 +157,6 @@ static uint64_t sifive_plic_read(void *opaque, hwaddr addr, unsigned size)
             uint32_t max_irq = sifive_plic_claimed(plic, addrid);
 
             if (max_irq) {
-                sifive_plic_set_pending(plic, max_irq, false);
                 sifive_plic_set_claimed(plic, max_irq, true);
             }
 
--


  reply	other threads:[~2023-01-18 23:07 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-12 13:10 completion timeouts with pin-based interrupts in QEMU hw/nvme Klaus Jensen
2023-01-12 14:26 ` Guenter Roeck
2023-01-12 16:34 ` Keith Busch
2023-01-12 17:45   ` Klaus Jensen
2023-01-12 17:51     ` Keith Busch
2023-01-12 19:14     ` Guenter Roeck
2023-01-12 19:27     ` Keith Busch
2023-01-13  0:27       ` Guenter Roeck
2023-01-12 23:57     ` Guenter Roeck
2023-01-13  8:54 ` Klaus Jensen
2023-01-13 12:32   ` Peter Maydell
2023-01-13 12:37     ` Klaus Jensen
2023-01-13 12:42       ` Peter Maydell
2023-01-13 12:46         ` Klaus Jensen
2023-01-13 16:52     ` Keith Busch
2023-01-16 21:14 ` Klaus Jensen
2023-01-17  4:58   ` Keith Busch
2023-01-17 16:09     ` Guenter Roeck
2023-01-17 16:18       ` Peter Maydell
2023-01-17 19:21         ` Guenter Roeck
2023-01-18 15:04           ` Peter Maydell
2023-01-18 16:33             ` Keith Busch
2023-01-18 23:06               ` Keith Busch [this message]
2023-01-19  0:41                 ` Alistair Francis
2023-01-19  2:44                   ` Keith Busch
2023-01-19  3:10                     ` Alistair Francis
2023-01-19  4:03                       ` Keith Busch
2023-01-19  7:28                         ` Klaus Jensen
2023-01-19  8:02                           ` Klaus Jensen
2023-01-19 14:32                             ` Guenter Roeck
2023-01-19 10:35                         ` Peter Maydell
2023-01-17 16:05   ` Guenter Roeck
2023-01-18  4:17 ` Keith Busch
2023-01-18 22:26 ` Keith Busch
2023-01-19  7:06   ` Klaus Jensen

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=Y8h7aOuVfCb+RsAP@kbusch-mbp \
    --to=kbusch@kernel.org \
    --cc=axboe@fb.com \
    --cc=hch@lst.de \
    --cc=its@irrelevant.dk \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux@roeck-us.net \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sagi@grimberg.me \
    /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).