From: Jan Kiszka <jan.kiszka@web.de>
To: Jason Baron <jbaron@redhat.com>
Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org, mst@redhat.com,
alex.williamson@redhat.com, avi@redhat.com, aliguori@us.ibm.com
Subject: Re: [PATCH 1/2] qemu kvm: Set up gsi bitmap correctly
Date: Tue, 27 Mar 2012 23:52:18 +0200 [thread overview]
Message-ID: <4F723692.70407@web.de> (raw)
In-Reply-To: <025b834272f9972f97873779be6523527dad42a8.1332881354.git.jbaron@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1958 bytes --]
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 <jbaron@redhat.com>
> ---
> 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
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Jan Kiszka <jan.kiszka@web.de>
To: Jason Baron <jbaron@redhat.com>
Cc: aliguori@us.ibm.com, kvm@vger.kernel.org, mst@redhat.com,
qemu-devel@nongnu.org, alex.williamson@redhat.com,
avi@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/2] qemu kvm: Set up gsi bitmap correctly
Date: Tue, 27 Mar 2012 23:52:18 +0200 [thread overview]
Message-ID: <4F723692.70407@web.de> (raw)
In-Reply-To: <025b834272f9972f97873779be6523527dad42a8.1332881354.git.jbaron@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1958 bytes --]
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 <jbaron@redhat.com>
> ---
> 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
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
next prev parent reply other threads:[~2012-03-27 21:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-27 21:00 [PATCH 0/2] qemu kvm: correct gsi bitmap Jason Baron
2012-03-27 21:00 ` [Qemu-devel] " Jason Baron
2012-03-27 21:00 ` [PATCH 1/2] qemu kvm: Set up gsi bitmap correctly Jason Baron
2012-03-27 21:00 ` [Qemu-devel] " Jason Baron
2012-03-27 21:31 ` Alex Williamson
2012-03-27 21:31 ` [Qemu-devel] " Alex Williamson
2012-03-27 22:01 ` Jan Kiszka
2012-03-27 22:01 ` [Qemu-devel] " Jan Kiszka
2012-03-27 22:25 ` Alex Williamson
2012-03-27 22:25 ` [Qemu-devel] " Alex Williamson
2012-03-27 22:32 ` Jan Kiszka
2012-03-27 22:32 ` [Qemu-devel] " Jan Kiszka
2012-03-27 21:52 ` Jan Kiszka [this message]
2012-03-27 21:52 ` Jan Kiszka
2012-03-27 21:00 ` [PATCH 2/2] qemu kvm: add better error reporting when kvm_get_irq_route_gsi() fails Jason Baron
2012-03-27 21:00 ` [Qemu-devel] " Jason Baron
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=4F723692.70407@web.de \
--to=jan.kiszka@web.de \
--cc=alex.williamson@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=avi@redhat.com \
--cc=jbaron@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.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.