|
|
619821 |
From 8497b21c6dabe117b27d76f3bdbd86d80b0dd1d7 Mon Sep 17 00:00:00 2001
|
|
|
b28c64 |
From: Fam Zheng <famz@redhat.com>
|
|
|
619821 |
Date: Thu, 18 May 2017 09:21:30 +0200
|
|
|
b28c64 |
Subject: [PATCH 17/18] serial: separate serial_xmit and serial_watch_cb
|
|
|
b28c64 |
|
|
|
b28c64 |
RH-Author: Fam Zheng <famz@redhat.com>
|
|
|
619821 |
Message-id: <20170518092131.16571-18-famz@redhat.com>
|
|
|
619821 |
Patchwork-id: 75309
|
|
|
619821 |
O-Subject: [RHEL-7.4 qemu-kvm PATCH v3 17/18] serial: separate serial_xmit and serial_watch_cb
|
|
|
619821 |
Bugzilla: 1451470
|
|
|
b28c64 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
619821 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
b28c64 |
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
b28c64 |
|
|
|
b28c64 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
b28c64 |
|
|
|
b28c64 |
serial_xmit starts transmission of whatever is in the transmitter
|
|
|
b28c64 |
register, THR or FIFO; serial_watch_cb is a wrapper around it and is
|
|
|
b28c64 |
only used as a qemu_chr_fe_add_watch callback.
|
|
|
b28c64 |
|
|
|
b28c64 |
Tested-by: Bret Ketchum <bcketchum@gmail.com>
|
|
|
b28c64 |
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
b28c64 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
b28c64 |
(cherry picked from commit b0585e7e07982daa578c3bfef7f6843c89f110a8)
|
|
|
b28c64 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
b28c64 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
b28c64 |
|
|
|
b28c64 |
Conflicts:
|
|
|
b28c64 |
hw/char/serial.c
|
|
|
b28c64 |
|
|
|
b28c64 |
Contextual conflict because the surrounding migration code around the
|
|
|
b28c64 |
touched functions is different.
|
|
|
b28c64 |
---
|
|
|
b28c64 |
hw/char/serial.c | 18 +++++++++++-------
|
|
|
b28c64 |
1 file changed, 11 insertions(+), 7 deletions(-)
|
|
|
b28c64 |
|
|
|
b28c64 |
diff --git a/hw/char/serial.c b/hw/char/serial.c
|
|
|
b28c64 |
index fdda802..69fefb2 100644
|
|
|
b28c64 |
--- a/hw/char/serial.c
|
|
|
b28c64 |
+++ b/hw/char/serial.c
|
|
|
b28c64 |
@@ -104,6 +104,7 @@ do {} while (0)
|
|
|
b28c64 |
#endif
|
|
|
b28c64 |
|
|
|
b28c64 |
static void serial_receive1(void *opaque, const uint8_t *buf, int size);
|
|
|
b28c64 |
+static void serial_xmit(SerialState *s);
|
|
|
b28c64 |
|
|
|
b28c64 |
static inline void recv_fifo_put(SerialState *s, uint8_t chr)
|
|
|
b28c64 |
{
|
|
|
b28c64 |
@@ -219,10 +220,16 @@ static void serial_update_msl(SerialState *s)
|
|
|
b28c64 |
qemu_mod_timer(s->modem_status_poll, qemu_get_clock_ns(vm_clock) + get_ticks_per_sec() / 100);
|
|
|
b28c64 |
}
|
|
|
b28c64 |
|
|
|
b28c64 |
-static gboolean serial_xmit(GIOChannel *chan, GIOCondition cond, void *opaque)
|
|
|
b28c64 |
+static gboolean serial_watch_cb(GIOChannel *chan, GIOCondition cond,
|
|
|
b28c64 |
+ void *opaque)
|
|
|
b28c64 |
{
|
|
|
b28c64 |
SerialState *s = opaque;
|
|
|
b28c64 |
+ serial_xmit(s);
|
|
|
b28c64 |
+ return FALSE;
|
|
|
b28c64 |
+}
|
|
|
b28c64 |
|
|
|
b28c64 |
+static void serial_xmit(SerialState *s)
|
|
|
b28c64 |
+{
|
|
|
b28c64 |
do {
|
|
|
b28c64 |
assert(!(s->lsr & UART_LSR_TEMT));
|
|
|
b28c64 |
if (s->tsr_retry == 0) {
|
|
|
b28c64 |
@@ -250,9 +257,9 @@ static gboolean serial_xmit(GIOChannel *chan, GIOCondition cond, void *opaque)
|
|
|
b28c64 |
} else if (qemu_chr_fe_write(s->chr, &s->tsr, 1) != 1) {
|
|
|
b28c64 |
if (s->tsr_retry < MAX_XMIT_RETRY &&
|
|
|
b28c64 |
qemu_chr_fe_add_watch(s->chr, G_IO_OUT|G_IO_HUP,
|
|
|
b28c64 |
- serial_xmit, s) > 0) {
|
|
|
b28c64 |
+ serial_watch_cb, s) > 0) {
|
|
|
b28c64 |
s->tsr_retry++;
|
|
|
b28c64 |
- return FALSE;
|
|
|
b28c64 |
+ return;
|
|
|
b28c64 |
}
|
|
|
b28c64 |
}
|
|
|
b28c64 |
s->tsr_retry = 0;
|
|
|
b28c64 |
@@ -263,11 +270,8 @@ static gboolean serial_xmit(GIOChannel *chan, GIOCondition cond, void *opaque)
|
|
|
b28c64 |
|
|
|
b28c64 |
s->last_xmit_ts = qemu_get_clock_ns(vm_clock);
|
|
|
b28c64 |
s->lsr |= UART_LSR_TEMT;
|
|
|
b28c64 |
-
|
|
|
b28c64 |
- return FALSE;
|
|
|
b28c64 |
}
|
|
|
b28c64 |
|
|
|
b28c64 |
-
|
|
|
b28c64 |
static void serial_ioport_write(void *opaque, hwaddr addr, uint64_t val,
|
|
|
b28c64 |
unsigned size)
|
|
|
b28c64 |
{
|
|
|
b28c64 |
@@ -295,7 +299,7 @@ static void serial_ioport_write(void *opaque, hwaddr addr, uint64_t val,
|
|
|
b28c64 |
s->lsr &= ~UART_LSR_TEMT;
|
|
|
b28c64 |
serial_update_irq(s);
|
|
|
b28c64 |
if (s->tsr_retry == 0) {
|
|
|
b28c64 |
- serial_xmit(NULL, G_IO_OUT, s);
|
|
|
b28c64 |
+ serial_xmit(s);
|
|
|
b28c64 |
}
|
|
|
b28c64 |
}
|
|
|
b28c64 |
break;
|
|
|
b28c64 |
--
|
|
|
b28c64 |
1.8.3.1
|
|
|
b28c64 |
|