From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: peter.maydell@linaro.org
Cc: olaf@aepfle.de, xen-devel@lists.xensource.com,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
qemu-devel@nongnu.org, Zhenzhong Duan <zhenzhong.duan@oracle.com>,
anthony@codemonkey.ws, Anthony.Perard@citrix.com,
pbonzini@redhat.com
Subject: [Qemu-devel] [PULL 2/7] qemu-xen: free all the pirqs for msi/msix when driver unload
Date: Wed, 7 May 2014 16:09:57 +0100 [thread overview]
Message-ID: <1399475403-5408-2-git-send-email-stefano.stabellini@eu.citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1405071606230.14596@kaball.uk.xensource.com>
From: Zhenzhong Duan <zhenzhong.duan@oracle.com>
Pirqs are not freed when driver unload, then new pirqs are allocated when
driver reload. This could exhaust pirqs if do it in a loop.
This patch fixes the bug by freeing pirqs when ENABLE bit is cleared in
msi/msix control reg.
There is also other way of fixing it such as reuse pirqs between driver reload,
but this way is better.
Xen-devel: http://marc.info/?l=xen-devel&m=136800120304275&w=2
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
hw/xen/xen_pt_config_init.c | 6 ++++--
hw/xen/xen_pt_msi.c | 6 ++++--
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
index 8ccc2e4..de9a20f 100644
--- a/hw/xen/xen_pt_config_init.c
+++ b/hw/xen/xen_pt_config_init.c
@@ -1123,8 +1123,8 @@ static int xen_pt_msgctrl_reg_write(XenPCIPassthroughState *s,
msi->mapped = true;
}
msi->flags |= PCI_MSI_FLAGS_ENABLE;
- } else {
- msi->flags &= ~PCI_MSI_FLAGS_ENABLE;
+ } else if (msi->mapped) {
+ xen_pt_msi_disable(s);
}
/* pass through MSI_ENABLE bit */
@@ -1397,6 +1397,8 @@ static int xen_pt_msixctrl_reg_write(XenPCIPassthroughState *s,
if ((*val & PCI_MSIX_FLAGS_ENABLE)
&& !(*val & PCI_MSIX_FLAGS_MASKALL)) {
xen_pt_msix_update(s);
+ } else if (!(*val & PCI_MSIX_FLAGS_ENABLE) && s->msix->enabled) {
+ xen_pt_msix_disable(s);
}
debug_msix_enabled_old = s->msix->enabled;
diff --git a/hw/xen/xen_pt_msi.c b/hw/xen/xen_pt_msi.c
index 6fbe0cc..12b4c45 100644
--- a/hw/xen/xen_pt_msi.c
+++ b/hw/xen/xen_pt_msi.c
@@ -282,7 +282,8 @@ void xen_pt_msi_disable(XenPCIPassthroughState *s)
msi->initialized);
/* clear msi info */
- msi->flags = 0;
+ msi->flags &= ~PCI_MSI_FLAGS_ENABLE;
+ msi->initialized = false;
msi->mapped = false;
msi->pirq = XEN_PT_UNASSIGNED_PIRQ;
}
@@ -446,7 +447,8 @@ static void pci_msix_write(void *opaque, hwaddr addr,
if (offset != PCI_MSIX_ENTRY_VECTOR_CTRL) {
const volatile uint32_t *vec_ctrl;
- if (get_entry_value(entry, offset) == val) {
+ if (get_entry_value(entry, offset) == val
+ && entry->pirq != XEN_PT_UNASSIGNED_PIRQ) {
return;
}
--
1.7.10.4
next prev parent reply other threads:[~2014-05-07 15:10 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-07 15:09 [Qemu-devel] [PULL 0/7] xen-140507 Stefano Stabellini
2014-05-07 15:09 ` [Qemu-devel] [PULL 1/7] exec: Limit translation limiting in address_space_translate to xen Stefano Stabellini
2014-05-07 15:12 ` Peter Maydell
2014-05-07 15:22 ` Paolo Bonzini
2014-05-07 15:30 ` Stefano Stabellini
2014-05-07 15:32 ` Peter Maydell
2014-05-07 15:38 ` Paolo Bonzini
2014-05-07 15:09 ` Stefano Stabellini [this message]
2014-05-07 15:09 ` [Qemu-devel] [PULL 3/7] xen: move Xen PV machine files to hw/xenpv Stefano Stabellini
2014-05-07 15:09 ` [Qemu-devel] [PULL 4/7] xen: move Xen HVM files under hw/i386/xen Stefano Stabellini
2014-05-07 15:10 ` [Qemu-devel] [PULL 5/7] xen: factor out common functions Stefano Stabellini
2014-05-07 15:10 ` [Qemu-devel] [PULL 6/7] pass an inclusive address range to xc_domain_pin_memory_cacheattr Stefano Stabellini
2014-05-07 15:10 ` [Qemu-devel] [PULL 7/7] xen_disk: add discard support Stefano Stabellini
2014-05-07 15:55 ` [Qemu-devel] [PULL 0/7] xen-140507 Peter Maydell
2014-05-07 16:19 ` Stefano Stabellini
-- strict thread matches above, loose matches on Subject: below --
2014-05-07 16:21 [Qemu-devel] [PULL 0/7] xen-140507-2 Stefano Stabellini
2014-05-07 16:21 ` [Qemu-devel] [PULL 2/7] qemu-xen: free all the pirqs for msi/msix when driver unload Stefano Stabellini
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=1399475403-5408-2-git-send-email-stefano.stabellini@eu.citrix.com \
--to=stefano.stabellini@eu.citrix.com \
--cc=Anthony.Perard@citrix.com \
--cc=anthony@codemonkey.ws \
--cc=konrad.wilk@oracle.com \
--cc=olaf@aepfle.de \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=xen-devel@lists.xensource.com \
--cc=zhenzhong.duan@oracle.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).