9ae3a8
From bf9b8d36996ecbe78f1561404a355af6f7c5d4f6 Mon Sep 17 00:00:00 2001
9ae3a8
From: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
Date: Tue, 21 Jan 2014 11:25:17 -0500
9ae3a8
Subject: [PATCH 6/6] qxl: replace pipe signaling with bottom half
9ae3a8
9ae3a8
Message-id: <1390303517-20167-3-git-send-email-kraxel@redhat.com>
9ae3a8
Patchwork-id: 56865
9ae3a8
O-Subject: [RHEL-7 qemu-kvm PATCH 2/2] qxl: replace pipe signaling with bottom half
9ae3a8
Bugzilla: 1009297
9ae3a8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
9ae3a8
qxl creates a pipe, then writes something to it to wake up the iothread
9ae3a8
from the spice server thread to raise an irq.  These days qemu bottom
9ae3a8
halves can be scheduled from threads and signals, so there is no reason
9ae3a8
to do this any more.  Time to clean it up.
9ae3a8
9ae3a8
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
(cherry picked from commit 4a46c99c8118586f19894fe66fc6e353f159d4d9)
9ae3a8
---
9ae3a8
 hw/display/qxl.c | 33 +++------------------------------
9ae3a8
 hw/display/qxl.h |  3 +--
9ae3a8
 2 files changed, 4 insertions(+), 32 deletions(-)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/display/qxl.c | 33 +++------------------------------
9ae3a8
 hw/display/qxl.h |  3 +--
9ae3a8
 2 files changed, 4 insertions(+), 32 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
9ae3a8
index 830b3c5..4381d97 100644
9ae3a8
--- a/hw/display/qxl.c
9ae3a8
+++ b/hw/display/qxl.c
9ae3a8
@@ -1702,15 +1702,9 @@ static const MemoryRegionOps qxl_io_ops = {
9ae3a8
     },
9ae3a8
 };
9ae3a8
 
9ae3a8
-static void pipe_read(void *opaque)
9ae3a8
+static void qxl_update_irq_bh(void *opaque)
9ae3a8
 {
9ae3a8
     PCIQXLDevice *d = opaque;
9ae3a8
-    char dummy;
9ae3a8
-    int len;
9ae3a8
-
9ae3a8
-    do {
9ae3a8
-        len = read(d->pipe[0], &dummy, sizeof(dummy));
9ae3a8
-    } while (len == sizeof(dummy));
9ae3a8
     qxl_update_irq(d);
9ae3a8
 }
9ae3a8
 
9ae3a8
@@ -1731,28 +1725,7 @@ static void qxl_send_events(PCIQXLDevice *d, uint32_t events)
9ae3a8
     if ((old_pending & le_events) == le_events) {
9ae3a8
         return;
9ae3a8
     }
9ae3a8
-    if (qemu_thread_is_self(&d->main)) {
9ae3a8
-        qxl_update_irq(d);
9ae3a8
-    } else {
9ae3a8
-        if (write(d->pipe[1], d, 1) != 1) {
9ae3a8
-            dprint(d, 1, "%s: write to pipe failed\n", __func__);
9ae3a8
-        }
9ae3a8
-    }
9ae3a8
-}
9ae3a8
-
9ae3a8
-static void init_pipe_signaling(PCIQXLDevice *d)
9ae3a8
-{
9ae3a8
-    if (pipe(d->pipe) < 0) {
9ae3a8
-        fprintf(stderr, "%s:%s: qxl pipe creation failed\n",
9ae3a8
-                __FILE__, __func__);
9ae3a8
-        exit(1);
9ae3a8
-    }
9ae3a8
-    fcntl(d->pipe[0], F_SETFL, O_NONBLOCK);
9ae3a8
-    fcntl(d->pipe[1], F_SETFL, O_NONBLOCK);
9ae3a8
-    fcntl(d->pipe[0], F_SETOWN, getpid());
9ae3a8
-
9ae3a8
-    qemu_thread_get_self(&d->main);
9ae3a8
-    qemu_set_fd_handler(d->pipe[0], pipe_read, NULL, d);
9ae3a8
+    qemu_bh_schedule(d->update_irq);
9ae3a8
 }
9ae3a8
 
9ae3a8
 /* graphics console */
9ae3a8
@@ -2044,7 +2017,7 @@ static int qxl_init_common(PCIQXLDevice *qxl)
9ae3a8
     }
9ae3a8
     qemu_add_vm_change_state_handler(qxl_vm_change_state_handler, qxl);
9ae3a8
 
9ae3a8
-    init_pipe_signaling(qxl);
9ae3a8
+    qxl->update_irq = qemu_bh_new(qxl_update_irq_bh, qxl);
9ae3a8
     qxl_reset_state(qxl);
9ae3a8
 
9ae3a8
     qxl->update_area_bh = qemu_bh_new(qxl_render_update_area_bh, qxl);
9ae3a8
diff --git a/hw/display/qxl.h b/hw/display/qxl.h
9ae3a8
index 8e9b0c2..5da33e2 100644
9ae3a8
--- a/hw/display/qxl.h
9ae3a8
+++ b/hw/display/qxl.h
9ae3a8
@@ -78,8 +78,7 @@ typedef struct PCIQXLDevice {
9ae3a8
     QemuMutex          track_lock;
9ae3a8
 
9ae3a8
     /* thread signaling */
9ae3a8
-    QemuThread         main;
9ae3a8
-    int                pipe[2];
9ae3a8
+    QEMUBH             *update_irq;
9ae3a8
 
9ae3a8
     /* ram pci bar */
9ae3a8
     QXLRam             *ram;
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8