Re: [PATCH 4/7] qemu-kvm: Fix and clean up msix vector use/unuse hooks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Apr 23, 2011 at 12:23:37PM +0200, Jan Kiszka wrote:
> From: Jan Kiszka <jan.kiszka@xxxxxxxxxxx>
> 
> 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@xxxxxxxxxxx>

Good catch!

Acked-by: Michael S. Tsirkin <mst@xxxxxxxxxx>

> ---
>  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
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux