All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roman Kagan <rkagan@virtuozzo.com>
To: qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
	Eduardo Habkost <ehabkost@redhat.com>
Cc: Evgeny Yakovlev <eyakovlev@virtuozzo.com>,
	"Denis V . Lunev" <den@openvz.org>,
	Igor Mammedov <imammedo@redhat.com>
Subject: [Qemu-devel] [PATCH v2 10/23] hyperv: synic: only setup ack notifier if there's a callback
Date: Wed, 21 Jun 2017 19:24:11 +0300	[thread overview]
Message-ID: <20170621162424.10462-11-rkagan@virtuozzo.com> (raw)
In-Reply-To: <20170621162424.10462-1-rkagan@virtuozzo.com>

There's no point setting up an sint ack notifier if no callback is
specified.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
---
 target/i386/hyperv.c | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/target/i386/hyperv.c b/target/i386/hyperv.c
index 2121d8f..3594bd0 100644
--- a/target/i386/hyperv.c
+++ b/target/i386/hyperv.c
@@ -77,15 +77,14 @@ static void kvm_hv_sint_ack_handler(EventNotifier *notifier)
     HvSintRoute *sint_route = container_of(notifier, HvSintRoute,
                                            sint_ack_notifier);
     event_notifier_test_and_clear(notifier);
-    if (sint_route->sint_ack_clb) {
-        sint_route->sint_ack_clb(sint_route);
-    }
+    sint_route->sint_ack_clb(sint_route);
 }
 
 HvSintRoute *kvm_hv_sint_route_create(uint32_t vp_index, uint32_t sint,
                                       HvSintAckClb sint_ack_clb)
 {
     HvSintRoute *sint_route;
+    EventNotifier *ack_notifier;
     int r, gsi;
 
     sint_route = g_new0(HvSintRoute, 1);
@@ -94,13 +93,15 @@ HvSintRoute *kvm_hv_sint_route_create(uint32_t vp_index, uint32_t sint,
         goto err;
     }
 
-    r = event_notifier_init(&sint_route->sint_ack_notifier, false);
-    if (r) {
-        goto err_sint_set_notifier;
-    }
+    ack_notifier = sint_ack_clb ? &sint_route->sint_ack_notifier : NULL;
+    if (ack_notifier) {
+        r = event_notifier_init(ack_notifier, false);
+        if (r) {
+            goto err_sint_set_notifier;
+        }
 
-    event_notifier_set_handler(&sint_route->sint_ack_notifier,
-                               kvm_hv_sint_ack_handler);
+        event_notifier_set_handler(ack_notifier, kvm_hv_sint_ack_handler);
+    }
 
     gsi = kvm_irqchip_add_hv_sint_route(kvm_state, vp_index, sint);
     if (gsi < 0) {
@@ -109,7 +110,7 @@ HvSintRoute *kvm_hv_sint_route_create(uint32_t vp_index, uint32_t sint,
 
     r = kvm_irqchip_add_irqfd_notifier_gsi(kvm_state,
                                            &sint_route->sint_set_notifier,
-                                           &sint_route->sint_ack_notifier, gsi);
+                                           ack_notifier, gsi);
     if (r) {
         goto err_irqfd;
     }
@@ -123,8 +124,10 @@ HvSintRoute *kvm_hv_sint_route_create(uint32_t vp_index, uint32_t sint,
 err_irqfd:
     kvm_irqchip_release_virq(kvm_state, gsi);
 err_gsi:
-    event_notifier_set_handler(&sint_route->sint_ack_notifier, NULL);
-    event_notifier_cleanup(&sint_route->sint_ack_notifier);
+    if (ack_notifier) {
+        event_notifier_set_handler(ack_notifier, NULL);
+        event_notifier_cleanup(ack_notifier);
+    }
 err_sint_set_notifier:
     event_notifier_cleanup(&sint_route->sint_set_notifier);
 err:
@@ -139,8 +142,10 @@ void kvm_hv_sint_route_destroy(HvSintRoute *sint_route)
                                           &sint_route->sint_set_notifier,
                                           sint_route->gsi);
     kvm_irqchip_release_virq(kvm_state, sint_route->gsi);
-    event_notifier_set_handler(&sint_route->sint_ack_notifier, NULL);
-    event_notifier_cleanup(&sint_route->sint_ack_notifier);
+    if (sint_route->sint_ack_clb) {
+        event_notifier_set_handler(&sint_route->sint_ack_notifier, NULL);
+        event_notifier_cleanup(&sint_route->sint_ack_notifier);
+    }
     event_notifier_cleanup(&sint_route->sint_set_notifier);
     g_free(sint_route);
 }
-- 
2.9.4

  parent reply	other threads:[~2017-06-21 16:25 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-21 16:24 [Qemu-devel] [PATCH v2 00/23] hyperv fixes and enhancements Roman Kagan
2017-06-21 16:24 ` [Qemu-devel] [PATCH v2 01/23] hyperv: add header with protocol definitions Roman Kagan
2017-06-21 16:24 ` [Qemu-devel] [PATCH v2 02/23] update-linux-headers: prepare for hyperv.h removal Roman Kagan
2017-06-21 16:24 ` [Qemu-devel] [PATCH v2 03/23] hyperv: set partition-wide MSRs only on first vcpu Roman Kagan
2017-06-21 16:24 ` [Qemu-devel] [PATCH v2 04/23] hyperv: ensure SINTx msrs are reset properly Roman Kagan
2017-06-21 16:24 ` [Qemu-devel] [PATCH v2 05/23] hyperv: make SynIC version msr constant Roman Kagan
2017-06-21 16:24 ` [Qemu-devel] [PATCH v2 06/23] [not to commit] add new hyperv-related caps Roman Kagan
2017-06-21 16:24 ` [Qemu-devel] [PATCH v2 07/23] hyperv: ensure VP index equal to QEMU cpu_index Roman Kagan
2017-06-28 14:47   ` Igor Mammedov
2017-06-29  9:53     ` Roman Kagan
2017-06-29 11:53       ` Igor Mammedov
2017-06-29 13:10         ` Roman Kagan
2017-06-29 14:39           ` Igor Mammedov
2017-06-29 17:31             ` Roman Kagan
2017-06-21 16:24 ` [Qemu-devel] [PATCH v2 08/23] hyperv_testdev: refactor for readability Roman Kagan
2017-06-21 16:24 ` [Qemu-devel] [PATCH v2 09/23] hyperv: cosmetic: g_malloc -> g_new Roman Kagan
2017-06-21 16:24 ` Roman Kagan [this message]
2017-06-21 16:24 ` [Qemu-devel] [PATCH v2 11/23] hyperv: allow passing arbitrary data to sint ack callback Roman Kagan
2017-06-21 16:24 ` [Qemu-devel] [PATCH v2 12/23] hyperv: address HvSintRoute by X86CPU pointer Roman Kagan
2017-06-21 16:24 ` [Qemu-devel] [PATCH v2 13/23] hyperv: make HvSintRoute reference-counted Roman Kagan
2017-06-21 16:24 ` [Qemu-devel] [PATCH v2 14/23] hyperv: qom-ify SynIC Roman Kagan
2017-06-29 15:05   ` Igor Mammedov
2017-06-29 17:51     ` Roman Kagan
2017-07-07 12:22       ` Igor Mammedov
2017-07-07 12:47         ` Roman Kagan
2017-07-07 13:27           ` Igor Mammedov
2017-06-21 16:24 ` [Qemu-devel] [PATCH v2 15/23] hyperv: block SynIC use in QEMU in incompatible configurations Roman Kagan
2017-06-21 16:24 ` [Qemu-devel] [PATCH v2 16/23] hyperv: make overlay pages for SynIC Roman Kagan
2017-06-21 16:24 ` [Qemu-devel] [PATCH v2 18/23] hyperv: add synic event flag signaling Roman Kagan
2017-06-21 16:24 ` [Qemu-devel] [PATCH v2 19/23] hyperv: process SIGNAL_EVENT hypercall Roman Kagan
2017-06-21 16:24 ` [Qemu-devel] [PATCH v2 20/23] hyperv: process POST_MESSAGE hypercall Roman Kagan
2017-06-21 16:24 ` [Qemu-devel] [PATCH v2 21/23] hyperv_testdev: add SynIC message and event testmodes Roman Kagan
2017-06-21 16:24 ` [Qemu-devel] [PATCH v2 22/23] MAINTAINERS: add myself and eyakovlev@ for hyperv* Roman Kagan
2017-06-21 16:24 ` [Qemu-devel] [PATCH v2 23/23] hyperv: update copyright notices Roman Kagan
2017-06-29 15:20 ` [Qemu-devel] [PATCH v2 00/23] hyperv fixes and enhancements Igor Mammedov
2017-06-29 17:58   ` Roman Kagan

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=20170621162424.10462-11-rkagan@virtuozzo.com \
    --to=rkagan@virtuozzo.com \
    --cc=den@openvz.org \
    --cc=ehabkost@redhat.com \
    --cc=eyakovlev@virtuozzo.com \
    --cc=imammedo@redhat.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 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.