From: Anthony Liguori <anthony@codemonkey.ws>
To: virtualization@lists.linux-foundation.org
Cc: kernel@vger.kernel.org, Matt Wilson <msw@amazon.com>,
Anthony Liguori <aliguori@amazon.com>,
Michael Tsirkin <mst@redhat.com>
Subject: [PATCH] virtio_pci: properly clean up MSI-X state when initialization fails
Date: Sun, 14 Sep 2014 20:23:26 -0700 [thread overview]
Message-ID: <1410751406-10039-1-git-send-email-anthony@codemonkey.ws> (raw)
From: Anthony Liguori <aliguori@amazon.com>
If MSI-X initialization fails after setting msix_enabled = 1, then
the device is left in an inconsistent state. This would normally
only happen if there was a bug in the device emulation but it still
should be handled correctly.
Cc: Matt Wilson <msw@amazon.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Michael Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
---
drivers/virtio/virtio_pci.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index 9cbac33..3d2c2a5 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -357,7 +357,7 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors,
v = ioread16(vp_dev->ioaddr + VIRTIO_MSI_CONFIG_VECTOR);
if (v == VIRTIO_MSI_NO_VECTOR) {
err = -EBUSY;
- goto error;
+ goto error_msix_used;
}
if (!per_vq_vectors) {
@@ -369,11 +369,15 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors,
vp_vring_interrupt, 0, vp_dev->msix_names[v],
vp_dev);
if (err)
- goto error;
+ goto error_msix_used;
++vp_dev->msix_used_vectors;
}
return 0;
+error_msix_used:
+ v = --vp_dev->msix_used_vectors;
+ free_irq(vp_dev->msix_entries[v].vector, vp_dev);
error:
+ vp_dev->msix_enabled = 0;
vp_free_vectors(vdev);
return err;
}
--
1.7.9.5
next reply other threads:[~2014-09-15 3:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-15 3:23 Anthony Liguori [this message]
2014-09-15 3:43 ` [PATCH] virtio_pci: properly clean up MSI-X state when initialization fails Matt Wilson
2014-09-15 8:32 ` Michael S. Tsirkin
2014-09-15 14:10 ` Anthony Liguori
2014-09-15 14:10 ` Anthony Liguori
2014-09-15 14:39 ` Michael S. Tsirkin
2014-09-15 14:39 ` Michael S. Tsirkin
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=1410751406-10039-1-git-send-email-anthony@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=aliguori@amazon.com \
--cc=kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=msw@amazon.com \
--cc=virtualization@lists.linux-foundation.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.