From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org, anthony@codemonkey.ws
Subject: [Qemu-devel] [PATCH 5/5] msix: clear pending bit of an unused vector
Date: Wed, 25 Nov 2009 13:39:24 +0200 [thread overview]
Message-ID: <20091125113924.GF9322@redhat.com> (raw)
In-Reply-To: <cover.1259149089.git.mst@redhat.com>
PCI spec states:
if a masked vector has its Pending bit set, and the associated
underlying interrupt events are somehow satisfied (usually by software
though the exact manner is function-specific), the function must clear
the Pending bit, to avoid sending a spurious interrupt message later
when software unmasks the vector.
In our case this happens if vector becomes unused.
Clear pending bit in this case.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/msix.c | 27 +++++++++++++++++----------
1 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/hw/msix.c b/hw/msix.c
index a60ea95..0baedef 100644
--- a/hw/msix.c
+++ b/hw/msix.c
@@ -108,14 +108,6 @@ static int msix_add_config(struct PCIDevice *pdev, unsigned short nentries,
return 0;
}
-static void msix_free_irq_entries(PCIDevice *dev)
-{
- int vector;
-
- for (vector = 0; vector < dev->msix_entries_nr; ++vector)
- dev->msix_entry_used[vector] = 0;
-}
-
static uint32_t msix_mmio_readl(void *opaque, target_phys_addr_t addr)
{
PCIDevice *dev = opaque;
@@ -299,6 +291,16 @@ err_index:
return ret;
}
+static void msix_free_irq_entries(PCIDevice *dev)
+{
+ int vector;
+
+ for (vector = 0; vector < dev->msix_entries_nr; ++vector) {
+ dev->msix_entry_used[vector] = 0;
+ msix_clr_pending(dev, vector);
+ }
+}
+
/* Clean up resources for the device. */
int msix_uninit(PCIDevice *dev)
{
@@ -415,8 +417,13 @@ int msix_vector_use(PCIDevice *dev, unsigned vector)
/* Mark vector as unused. */
void msix_vector_unuse(PCIDevice *dev, unsigned vector)
{
- if (vector < dev->msix_entries_nr && dev->msix_entry_used[vector])
- --dev->msix_entry_used[vector];
+ if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector]) {
+ return;
+ }
+ if (--dev->msix_entry_used[vector]) {
+ return;
+ }
+ msix_clr_pending(dev, vector);
}
void msix_unuse_all_vectors(PCIDevice *dev)
--
1.6.5.2.143.g8cc62
prev parent reply other threads:[~2009-11-25 11:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1259149089.git.mst@redhat.com>
2009-11-25 11:38 ` [Qemu-devel] [PATCH 1/5] msix: fix mask bit state after reset Michael S. Tsirkin
2009-11-25 11:39 ` [Qemu-devel] [PATCH 2/5] msix: fix reset value for enable bit Michael S. Tsirkin
2009-11-25 11:39 ` [Qemu-devel] [PATCH 3/5] msix: macro rename for function mask support Michael S. Tsirkin
2009-11-25 11:39 ` [Qemu-devel] [PATCH 4/5] msix: " Michael S. Tsirkin
2009-11-25 11:39 ` Michael S. Tsirkin [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=20091125113924.GF9322@redhat.com \
--to=mst@redhat.com \
--cc=anthony@codemonkey.ws \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.