From: Laszlo Ersek <lersek@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org, M.Cerveny@computer.org
Subject: Re: [Qemu-devel] [PATCH] xhci: fix event queue IRQ handling
Date: Fri, 3 Feb 2017 14:44:03 +0100 [thread overview]
Message-ID: <c77a6d6b-5903-3964-4b82-4b88d8b65dbe@redhat.com> (raw)
In-Reply-To: <1486104705-13761-1-git-send-email-kraxel@redhat.com>
trivial comments:
On 02/03/17 07:51, Gerd Hoffmann wrote:
> The qemu xhci emulation doesn't handle the ERDP_EHB flag correctly.
>
> When the host adapter queues a new event the ERDP_EHB flag is set. The
> flag is cleared (via w1c) by the guest when it updates the ERDP (event
> ring dequeue pointer) register to notify the host adapter which events
> it has fetched.
>
> An IRQ must raised in case the ERDP_EHB flag flips from clear to set.
s/must raised/must be raised/
> If the flag is set already (which implies there are events queued up
> which are not yet processed by the guest) xhci must *not* raise a IRQ.
>
> Qemu got that wrong and raised an IRQ on every event, thereby generating
> suspious interrupts in case we've queued events faster than the guest
s/suspious/spurious/ (3 occurrences in total)
Thanks
Laszlo
> processed them. This patch fixes that.
>
> With that change in place we also have to check ERDP updates, to see
> whenever the guest has fetched all queued events. In case there are
> still pending events set ERDP_EHB and raise an IRQ again, to make sure
> the events don't linger unseen forever.
>
> The linux kernel driver and the microsoft windows driver (shipped with
> win8+) can deal with the suspious interrupts without problems. The
> renesas windows driver (v2.1.39) which can be used on older windows
> versions is quite upset though. It does suspious ERDP updates now and
> then (not every time, seems we must hit a race window for this to
> happen), which in turn makes the qemu xhci emulation think the event
> ring is full. Things go south from here ...
>
> tl;dr: This is the "fix xhci on win7" patch.
>
> Cc: M.Cerveny@computer.org
> Cc: 1373228@bugs.launchpad.net
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> hw/usb/hcd-xhci.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
> index df75907..4f05747 100644
> --- a/hw/usb/hcd-xhci.c
> +++ b/hw/usb/hcd-xhci.c
> @@ -789,11 +789,15 @@ static void xhci_msix_update(XHCIState *xhci, int v)
> static void xhci_intr_raise(XHCIState *xhci, int v)
> {
> PCIDevice *pci_dev = PCI_DEVICE(xhci);
> + bool pending = (xhci->intr[v].erdp_low & ERDP_EHB);
>
> xhci->intr[v].erdp_low |= ERDP_EHB;
> xhci->intr[v].iman |= IMAN_IP;
> xhci->usbsts |= USBSTS_EINT;
>
> + if (pending) {
> + return;
> + }
> if (!(xhci->intr[v].iman & IMAN_IE)) {
> return;
> }
> @@ -3352,6 +3356,15 @@ static void xhci_runtime_write(void *ptr, hwaddr reg,
> intr->erdp_low &= ~ERDP_EHB;
> }
> intr->erdp_low = (val & ~ERDP_EHB) | (intr->erdp_low & ERDP_EHB);
> + if (val & ERDP_EHB) {
> + dma_addr_t erdp = xhci_addr64(intr->erdp_low, intr->erdp_high);
> + unsigned int dp_idx = (erdp - intr->er_start) / TRB_SIZE;
> + if (erdp >= intr->er_start &&
> + erdp < (intr->er_start + TRB_SIZE * intr->er_size) &&
> + dp_idx != intr->er_ep_idx) {
> + xhci_intr_raise(xhci, v);
> + }
> + }
> break;
> case 0x1c: /* ERDP high */
> intr->erdp_high = val;
>
prev parent reply other threads:[~2017-02-03 13:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-03 6:51 [Qemu-devel] [PATCH] xhci: fix event queue IRQ handling Gerd Hoffmann
2017-02-03 11:39 ` Martin Cerveny
2017-02-10 0:17 ` Martin Cerveny
2017-02-10 7:38 ` Gerd Hoffmann
2017-02-03 13:44 ` Laszlo Ersek [this message]
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=c77a6d6b-5903-3964-4b82-4b88d8b65dbe@redhat.com \
--to=lersek@redhat.com \
--cc=M.Cerveny@computer.org \
--cc=kraxel@redhat.com \
--cc=qemu-devel@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).