[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/2] qemu kvm: Set up gsi bitmap correctly
From: |
Jan Kiszka |
Subject: |
Re: [Qemu-devel] [PATCH 1/2] qemu kvm: Set up gsi bitmap correctly |
Date: |
Tue, 27 Mar 2012 23:52:18 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 |
On 2012-03-27 23:00, Jason Baron wrote:
> The current 'kvm_init_irq_routing()' doesn't set up the gsi bitmap
> correctly, and as a consequence pins max_gsi to 32 when it really
> should be 1024. I ran into this limitation while testing pci
> passthrough, where I consistently would get -ENOSPACE return from
> kvm_get_irq_route_gsi() in assigned_dev_update_msix_mmio().
>
> Signed-off-by: Jason Baron <address@hidden>
> ---
> kvm-all.c | 4 ++--
> qemu-kvm.c | 2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/kvm-all.c b/kvm-all.c
> index ab88c7c..7d602af 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -873,9 +873,9 @@ static void kvm_init_irq_routing(KVMState *s)
> unsigned int gsi_bits, i;
>
> /* Round up so we can search ints using ffs */
> - gsi_bits = (gsi_count + 31) / 32;
> + gsi_bits = ALIGN(gsi_count, 32);
Oops.
> s->used_gsi_bitmap = g_malloc0(gsi_bits / 8);
> - s->max_gsi = gsi_bits;
> + s->max_gsi = gsi_count;
>
> /* Mark any over-allocated bits as already in use */
> for (i = gsi_count; i < gsi_bits; i++) {
When redefining its semantic anyway, ket's take the chance and rename
gsi_max to gsi_count. gsi_max actually sounds to me like gsi_count - 1.
This change should then be a uq/master patch. The other bits for
qemu-kvm can build on top.
> diff --git a/qemu-kvm.c b/qemu-kvm.c
> index 2047ebb..b17cae0 100644
> --- a/qemu-kvm.c
> +++ b/qemu-kvm.c
> @@ -249,7 +249,7 @@ int kvm_get_irq_route_gsi(void)
> uint32_t *buf = s->used_gsi_bitmap;
>
> /* Return the lowest unused GSI in the bitmap */
> - for (i = 0; i < s->max_gsi / 32; i++) {
> + for (i = 0; i < (ALIGN(s->max_gsi, 32) / 32); i++) {
> bit = ffs(~buf[i]);
> if (!bit) {
> continue;
Would be nicer to hold the loop limit in local variable.
Jan
signature.asc
Description: OpenPGP digital signature
[Qemu-devel] [PATCH 2/2] qemu kvm: add better error reporting when kvm_get_irq_route_gsi() fails, Jason Baron, 2012/03/27