From: Roman Kagan <rkagan@virtuozzo.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Eduardo Habkost <ehabkost@redhat.com>,
Evgeny Yakovlev <eyakovlev@virtuozzo.com>,
"Denis V . Lunev" <den@openvz.org>
Subject: [Qemu-devel] [PATCH 12/23] hyperv: make HvSintRoute reference-counted
Date: Tue, 6 Jun 2017 21:19:37 +0300 [thread overview]
Message-ID: <20170606181948.16238-13-rkagan@virtuozzo.com> (raw)
In-Reply-To: <20170606181948.16238-1-rkagan@virtuozzo.com>
Multiple entities (e.g. VMBus devices) can use the same SINT route. To
make their lives easier in maintaining SINT route ownership, make it
reference-counted. Adjust the respective API names accordingly.
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
---
target/i386/hyperv.h | 10 +++++-----
hw/misc/hyperv_testdev.c | 4 ++--
target/i386/hyperv.c | 25 +++++++++++++++++++++----
3 files changed, 28 insertions(+), 11 deletions(-)
diff --git a/target/i386/hyperv.h b/target/i386/hyperv.h
index bc071da..ca5a32d 100644
--- a/target/i386/hyperv.h
+++ b/target/i386/hyperv.h
@@ -23,11 +23,11 @@ typedef void (*HvSintAckClb)(void *data);
int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exit *exit);
-HvSintRoute *kvm_hv_sint_route_create(X86CPU *cpu, uint32_t sint,
- HvSintAckClb sint_ack_clb,
- void *sint_ack_clb_data);
-
-void kvm_hv_sint_route_destroy(HvSintRoute *sint_route);
+HvSintRoute *hyperv_sint_route_new(X86CPU *cpu, uint32_t sint,
+ HvSintAckClb sint_ack_clb,
+ void *sint_ack_clb_data);
+void hyperv_sint_route_ref(HvSintRoute *sint_route);
+void hyperv_sint_route_unref(HvSintRoute *sint_route);
int kvm_hv_sint_route_set_sint(HvSintRoute *sint_route);
diff --git a/hw/misc/hyperv_testdev.c b/hw/misc/hyperv_testdev.c
index 1b12295..929bf4f 100644
--- a/hw/misc/hyperv_testdev.c
+++ b/hw/misc/hyperv_testdev.c
@@ -55,7 +55,7 @@ static void sint_route_create(HypervTestDev *dev, X86CPU *cpu, uint8_t sint)
sint_route->cpu = cpu;
sint_route->sint = sint;
- sint_route->sint_route = kvm_hv_sint_route_create(cpu, sint, NULL, NULL);
+ sint_route->sint_route = hyperv_sint_route_new(cpu, sint, NULL, NULL);
assert(sint_route->sint_route);
QLIST_INSERT_HEAD(&dev->sint_routes, sint_route, le);
@@ -81,7 +81,7 @@ static void sint_route_destroy(HypervTestDev *dev, X86CPU *cpu, uint8_t sint)
sint_route = sint_route_find(dev, cpu, sint);
QLIST_REMOVE(sint_route, le);
- kvm_hv_sint_route_destroy(sint_route->sint_route);
+ hyperv_sint_route_unref(sint_route->sint_route);
g_free(sint_route);
}
diff --git a/target/i386/hyperv.c b/target/i386/hyperv.c
index a150401..ae67f82 100644
--- a/target/i386/hyperv.c
+++ b/target/i386/hyperv.c
@@ -24,6 +24,7 @@ struct HvSintRoute {
EventNotifier sint_ack_notifier;
HvSintAckClb sint_ack_clb;
void *sint_ack_clb_data;
+ unsigned refcount;
};
uint32_t hyperv_vp_index(X86CPU *cpu)
@@ -90,9 +91,9 @@ static void kvm_hv_sint_ack_handler(EventNotifier *notifier)
sint_route->sint_ack_clb(sint_route->sint_ack_clb_data);
}
-HvSintRoute *kvm_hv_sint_route_create(X86CPU *cpu, uint32_t sint,
- HvSintAckClb sint_ack_clb,
- void *sint_ack_clb_data)
+HvSintRoute *hyperv_sint_route_new(X86CPU *cpu, uint32_t sint,
+ HvSintAckClb sint_ack_clb,
+ void *sint_ack_clb_data)
{
HvSintRoute *sint_route;
EventNotifier *ack_notifier;
@@ -130,6 +131,7 @@ HvSintRoute *kvm_hv_sint_route_create(X86CPU *cpu, uint32_t sint,
sint_route->sint_ack_clb_data = sint_ack_clb_data;
sint_route->cpu = cpu;
sint_route->sint = sint;
+ sint_route->refcount = 1;
return sint_route;
@@ -148,8 +150,23 @@ err:
return NULL;
}
-void kvm_hv_sint_route_destroy(HvSintRoute *sint_route)
+void hyperv_sint_route_ref(HvSintRoute *sint_route)
{
+ sint_route->refcount++;
+}
+
+void hyperv_sint_route_unref(HvSintRoute *sint_route)
+{
+ if (!sint_route) {
+ return;
+ }
+
+ assert(sint_route->refcount > 0);
+
+ if (--sint_route->refcount) {
+ return;
+ }
+
kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state,
&sint_route->sint_set_notifier,
sint_route->gsi);
--
2.9.4
next prev parent reply other threads:[~2017-06-06 18:20 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-06 18:19 [Qemu-devel] [PATCH 00/23] hyperv fixes and enhancements Roman Kagan
2017-06-06 18:19 ` [Qemu-devel] [PATCH 01/23] hyperv: add header with protocol definitions Roman Kagan
2017-06-06 18:19 ` [Qemu-devel] [PATCH 02/23] update-linux-headers: prepare for hyperv.h removal Roman Kagan
2017-06-06 18:19 ` [Qemu-devel] [PATCH 03/23] hyperv: set partition-wide MSRs only on first vcpu Roman Kagan
2017-06-06 18:19 ` [Qemu-devel] [PATCH 04/23] hyperv: ensure msrs are inited properly Roman Kagan
2017-06-06 18:19 ` [Qemu-devel] [PATCH 05/23] hyperv: ensure VP index equal to QEMU cpu_index Roman Kagan
2017-06-13 18:57 ` Eduardo Habkost
2017-06-14 11:25 ` Roman Kagan
2017-06-14 11:26 ` Paolo Bonzini
2017-06-14 13:00 ` Igor Mammedov
2017-06-15 12:41 ` Roman Kagan
2017-06-15 13:22 ` Paolo Bonzini
2017-06-15 13:27 ` Igor Mammedov
2017-06-15 16:05 ` Roman Kagan
2017-06-18 15:29 ` Eduardo Habkost
2017-06-14 13:01 ` Eduardo Habkost
2017-06-14 13:11 ` Igor Mammedov
2017-06-14 13:17 ` Paolo Bonzini
2017-06-14 13:22 ` Eduardo Habkost
2017-06-14 13:37 ` Paolo Bonzini
2017-06-14 13:38 ` Igor Mammedov
2017-06-14 13:45 ` Eduardo Habkost
2017-06-14 18:40 ` Roman Kagan
2017-06-14 18:59 ` Eduardo Habkost
2017-06-15 8:26 ` Paolo Bonzini
2017-06-15 11:40 ` Roman Kagan
2017-06-15 11:42 ` Paolo Bonzini
2017-06-15 12:03 ` Roman Kagan
2017-06-14 13:19 ` Eduardo Habkost
2017-06-14 13:00 ` Eduardo Habkost
2017-06-14 13:24 ` Igor Mammedov
2017-06-14 13:35 ` Eduardo Habkost
2017-06-14 15:31 ` Igor Mammedov
2017-06-06 18:19 ` [Qemu-devel] [PATCH 06/23] hyperv: helper to find vcpu by VP index Roman Kagan
2017-06-06 18:19 ` [Qemu-devel] [PATCH 07/23] hyperv_testdev: refactor for readability Roman Kagan
2017-06-06 18:19 ` [Qemu-devel] [PATCH 08/23] hyperv: cosmetic: g_malloc -> g_new Roman Kagan
2017-06-06 18:19 ` [Qemu-devel] [PATCH 09/23] hyperv: synic: only setup ack notifier if there's a callback Roman Kagan
2017-06-06 18:19 ` [Qemu-devel] [PATCH 10/23] hyperv: allow passing arbitrary data to sint ack callback Roman Kagan
2017-06-06 18:19 ` Roman Kagan [this message]
2017-06-14 13:53 ` [Qemu-devel] [PATCH 12/23] hyperv: make HvSintRoute reference-counted Eduardo Habkost
2017-06-14 16:23 ` Roman Kagan
2017-06-23 12:44 ` Eduardo Habkost
2017-06-06 18:19 ` [Qemu-devel] [PATCH 13/23] hyperv: qdev-ify SynIC Roman Kagan
2017-06-13 18:34 ` Eduardo Habkost
2017-06-14 9:58 ` Roman Kagan
2017-06-14 12:46 ` Eduardo Habkost
2017-06-14 15:11 ` Roman Kagan
2017-06-14 15:21 ` Eduardo Habkost
2017-06-06 18:19 ` [Qemu-devel] [PATCH 14/23] kvm-all: make async_safe_run_on_cpu safe on kvm too Roman Kagan
2017-06-08 14:47 ` Paolo Bonzini
2017-06-06 18:19 ` [Qemu-devel] [PATCH 15/23] hyperv: make overlay pages for SynIC Roman Kagan
2017-06-06 18:19 ` [Qemu-devel] [PATCH 16/23] hyperv: map overlay pages after updating msrs Roman Kagan
2017-06-14 11:12 ` Paolo Bonzini
2017-06-14 11:54 ` Roman Kagan
2017-06-14 12:11 ` Paolo Bonzini
2017-06-14 12:41 ` Roman Kagan
2017-06-14 12:46 ` Paolo Bonzini
2017-06-06 18:19 ` [Qemu-devel] [PATCH 17/23] hyperv: add synic message delivery Roman Kagan
2017-06-14 15:08 ` Paolo Bonzini
2017-06-14 15:28 ` Roman Kagan
2017-06-14 15:32 ` Paolo Bonzini
2017-06-14 15:39 ` Roman Kagan
2017-06-06 18:19 ` [Qemu-devel] [PATCH 18/23] hyperv: add synic event flag signaling Roman Kagan
2017-06-14 15:07 ` Paolo Bonzini
2017-06-06 18:19 ` [Qemu-devel] [PATCH 19/23] hyperv: process SIGNAL_EVENT hypercall Roman Kagan
2017-06-06 18:19 ` [Qemu-devel] [PATCH 20/23] hyperv: process POST_MESSAGE hypercall Roman Kagan
2017-06-14 11:19 ` Paolo Bonzini
2017-06-14 14:20 ` Roman Kagan
2017-06-14 14:30 ` Paolo Bonzini
2017-06-06 18:19 ` [Qemu-devel] [PATCH 21/23] hyperv_testdev: add SynIC message and event testmodes Roman Kagan
2017-06-06 18:19 ` [Qemu-devel] [PATCH 22/23] MAINTAINERS: add myself and eyakovlev@ for hyperv* Roman Kagan
2017-06-06 18:19 ` [Qemu-devel] [PATCH 23/23] hyperv: update copyright notices Roman Kagan
[not found] ` <20170606181948.16238-12-rkagan@virtuozzo.com>
2017-06-13 19:02 ` [Qemu-devel] [PATCH 11/23] hyperv: address HvSintRoute by X86CPU pointer Eduardo Habkost
2017-06-14 11:08 ` Paolo Bonzini
2017-06-14 12:14 ` Roman Kagan
2017-06-14 12:17 ` Paolo Bonzini
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=20170606181948.16238-13-rkagan@virtuozzo.com \
--to=rkagan@virtuozzo.com \
--cc=den@openvz.org \
--cc=ehabkost@redhat.com \
--cc=eyakovlev@virtuozzo.com \
--cc=pbonzini@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).