From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jan Kiszka <jan.kiszka@web.de>
Cc: Avi Kivity <avi@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
kvm@vger.kernel.org
Subject: Re: [PATCH 4/7] qemu-kvm: Fix and clean up msix vector use/unuse hooks
Date: Wed, 27 Apr 2011 15:06:32 +0300 [thread overview]
Message-ID: <20110427120631.GE15788@redhat.com> (raw)
In-Reply-To: <bfa5d98451653c76f14e63e1c3644702e1dea05d.1303554218.git.jan.kiszka@web.de>
On Sat, Apr 23, 2011 at 12:23:37PM +0200, Jan Kiszka wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
>
> Remove the premature return from msix_vector_use if the vector was
> already in use, this could cause usage counter imbalances. In contrast,
> the check for msix_entry_used on deletion was redundant. At this chance,
> rename the internal API to clarify what is added/deleted here.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Good catch!
Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> hw/msix.c | 17 ++++++-----------
> 1 files changed, 6 insertions(+), 11 deletions(-)
>
> diff --git a/hw/msix.c b/hw/msix.c
> index 52facd4..1bdffb6 100644
> --- a/hw/msix.c
> +++ b/hw/msix.c
> @@ -108,7 +108,7 @@ static void kvm_msix_update(PCIDevice *dev, int vector,
> }
> }
>
> -static int kvm_msix_add(PCIDevice *dev, unsigned vector)
> +static int kvm_msix_vector_add(PCIDevice *dev, unsigned vector)
> {
> KVMMsiMessage *kmm = dev->msix_irq_entries + vector;
> int r;
> @@ -141,11 +141,8 @@ static int kvm_msix_add(PCIDevice *dev, unsigned vector)
> return 0;
> }
>
> -static void kvm_msix_del(PCIDevice *dev, unsigned vector)
> +static void kvm_msix_vector_del(PCIDevice *dev, unsigned vector)
> {
> - if (dev->msix_entry_used[vector]) {
> - return;
> - }
> kvm_msi_message_del(&dev->msix_irq_entries[vector]);
> kvm_commit_irq_routes();
> }
> @@ -548,11 +545,9 @@ int msix_vector_use(PCIDevice *dev, unsigned vector)
> int ret;
> if (vector >= dev->msix_entries_nr)
> return -EINVAL;
> - if (dev->msix_entry_used[vector]) {
> - return 0;
> - }
> - if (kvm_enabled() && kvm_irqchip_in_kernel()) {
> - ret = kvm_msix_add(dev, vector);
> + if (kvm_enabled() && kvm_irqchip_in_kernel() &&
> + !dev->msix_entry_used[vector]) {
> + ret = kvm_msix_vector_add(dev, vector);
> if (ret) {
> return ret;
> }
> @@ -571,7 +566,7 @@ void msix_vector_unuse(PCIDevice *dev, unsigned vector)
> return;
> }
> if (kvm_enabled() && kvm_irqchip_in_kernel()) {
> - kvm_msix_del(dev, vector);
> + kvm_msix_vector_del(dev, vector);
> }
> msix_clr_pending(dev, vector);
> }
> --
> 1.7.1
next prev parent reply other threads:[~2011-04-27 12:06 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-23 10:23 [PATCH 0/7] qemu-kvm: Clean up and enhance MSI irqchip support Jan Kiszka
2011-04-23 10:23 ` [PATCH 1/7] qemu-kvm: Drop unneeded kvm_irq_routing_entry declaration Jan Kiszka
2011-04-23 10:23 ` [PATCH 2/7] qemu-kvm: Rename kvm_msix_message to KVMMsiMessage Jan Kiszka
2011-04-27 13:34 ` Michael S. Tsirkin
2011-04-27 14:04 ` Jan Kiszka
2011-04-27 14:29 ` Avi Kivity
2011-04-27 14:30 ` Jan Kiszka
2011-04-27 14:40 ` Avi Kivity
2011-04-27 14:47 ` Jan Kiszka
2011-04-27 14:36 ` Michael S. Tsirkin
2011-04-27 14:35 ` Michael S. Tsirkin
2011-04-23 10:23 ` [PATCH 3/7] qemu-kvm: Refactor MSI core API of KVM Jan Kiszka
2011-04-23 10:23 ` [PATCH 4/7] qemu-kvm: Fix and clean up msix vector use/unuse hooks Jan Kiszka
2011-04-27 12:06 ` Michael S. Tsirkin [this message]
2011-04-23 10:23 ` [PATCH 5/7] qemu-kvm: Move gsi bits from kvm_msix_vector_add to kvm_msi_add_message Jan Kiszka
2011-04-27 12:54 ` Michael S. Tsirkin
2011-04-27 13:29 ` Jan Kiszka
2011-04-27 13:36 ` Michael S. Tsirkin
2011-04-23 10:23 ` [PATCH 6/7] qemu-kvm: Move entry comparison into kvm_msi_update_message Jan Kiszka
2011-04-23 10:23 ` [PATCH 7/7] qemu-kvm: Add in-kernel irqchip support for MSI Jan Kiszka
2011-04-27 13:31 ` Michael S. Tsirkin
2011-04-27 14:44 ` Jan Kiszka
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=20110427120631.GE15788@redhat.com \
--to=mst@redhat.com \
--cc=avi@redhat.com \
--cc=jan.kiszka@web.de \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.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