From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Bin Meng <bmeng.cn@gmail.com>, Gerd Hoffmann <kraxel@redhat.com>,
qemu-devel@nongnu.org
Cc: Bin Meng <bin.meng@windriver.com>, Ruimei Yan <ruimei.yan@windriver.com>
Subject: Re: [PATCH 2/2] hw/usb: hcd-xhci-pci: Fix spec violation of IP flag for MSI/MSI-X
Date: Fri, 21 May 2021 14:46:05 +0200 [thread overview]
Message-ID: <7feeff48-6fa0-19bf-eb72-09caaba8cdb3@redhat.com> (raw)
In-Reply-To: <20210521024224.2277634-2-bmeng.cn@gmail.com>
On 5/21/21 4:42 AM, Bin Meng wrote:
> From: Ruimei Yan <ruimei.yan@windriver.com>
>
> Per xHCI spec v1.2 chapter 4.17.5 page 296:
>
> If MSI or MSI-X interrupts are enabled, Interrupt Pending (IP)
> shall be cleared automatically when the PCI dword write generated
> by the interrupt assertion is complete.
>
> Currently QEMU does not clear the IP flag in the MSI / MSI-X mode.
> This causes subsequent spurious interrupt to be delivered to guests.
> To solve this, we change the xhci intr_raise() hook routine to have
> a bool return value that is passed to its caller (the xhci core),
> with true indicating that IP should be self-cleared.
>
> Fixes: 62c6ae04cf43 ("xhci: Initial xHCI implementation")
> Fixes: 4c47f800631a ("xhci: add msix support")
> Signed-off-by: Ruimei Yan <ruimei.yan@windriver.com>
> [bmeng: move IP clear codes from xhci pci to xhci core]
> Signed-off-by: Bin Meng <bin.meng@windriver.com>
> ---
>
> hw/usb/hcd-xhci.h | 2 +-
> hw/usb/hcd-xhci-pci.c | 8 +++++---
> hw/usb/hcd-xhci-sysbus.c | 4 +++-
> hw/usb/hcd-xhci.c | 8 ++++++--
> 4 files changed, 15 insertions(+), 7 deletions(-)
>
> diff --git a/hw/usb/hcd-xhci.h b/hw/usb/hcd-xhci.h
> index 7bba361f3b..98f598382a 100644
> --- a/hw/usb/hcd-xhci.h
> +++ b/hw/usb/hcd-xhci.h
> @@ -194,7 +194,7 @@ typedef struct XHCIState {
> uint32_t flags;
> uint32_t max_pstreams_mask;
> void (*intr_update)(XHCIState *s, int n, bool enable);
> - void (*intr_raise)(XHCIState *s, int n, bool level);
> + bool (*intr_raise)(XHCIState *s, int n, bool level);
> DeviceState *hostOpaque;
>
> /* Operational Registers */
> diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c
> index b6acd1790c..e934b1a5b1 100644
> --- a/hw/usb/hcd-xhci-pci.c
> +++ b/hw/usb/hcd-xhci-pci.c
> @@ -57,7 +57,7 @@ static void xhci_pci_intr_update(XHCIState *xhci, int n, bool enable)
> }
> }
>
> -static void xhci_pci_intr_raise(XHCIState *xhci, int n, bool level)
> +static bool xhci_pci_intr_raise(XHCIState *xhci, int n, bool level)
> {
> XHCIPciState *s = container_of(xhci, XHCIPciState, xhci);
> PCIDevice *pci_dev = PCI_DEVICE(s);
> @@ -70,13 +70,15 @@ static void xhci_pci_intr_raise(XHCIState *xhci, int n, bool level)
>
> if (msix_enabled(pci_dev) && level) {
> msix_notify(pci_dev, n);
> - return;
> + return true;
> }
>
> if (msi_enabled(pci_dev) && level) {
> msi_notify(pci_dev, n);
> - return;
> + return true;
> }
> +
> + return false;
> }
Could be simplified as:
if (!level) {
return false;
}
if (msix_enabled(pci_dev)) {
msix_notify(pci_dev, n);
}
if (msi_enabled(pci_dev)) {
msi_notify(pci_dev, n);
}
return true;
Otherwise,
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
next prev parent reply other threads:[~2021-05-21 12:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-21 2:42 [PATCH 1/2] hw/usb: hcd-xhci-pci: Raise MSI/MSI-X interrupts only when told to Bin Meng
2021-05-21 2:42 ` [PATCH 2/2] hw/usb: hcd-xhci-pci: Fix spec violation of IP flag for MSI/MSI-X Bin Meng
2021-05-21 12:46 ` Philippe Mathieu-Daudé [this message]
2021-05-21 13:25 ` Bin Meng
2021-05-21 15:44 ` Philippe Mathieu-Daudé
2021-05-21 12:48 ` [PATCH 1/2] hw/usb: hcd-xhci-pci: Raise MSI/MSI-X interrupts only when told to Philippe Mathieu-Daudé
2021-05-27 6:06 ` Bin Meng
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=7feeff48-6fa0-19bf-eb72-09caaba8cdb3@redhat.com \
--to=philmd@redhat.com \
--cc=bin.meng@windriver.com \
--cc=bmeng.cn@gmail.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=ruimei.yan@windriver.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 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).