|
|
9ae3a8 |
From 03b9104f9cf6c0b4f7b7976b987753afddb32599 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Date: Thu, 18 May 2017 09:21:28 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 15/18] serial: make tsr_retry unsigned
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Message-id: <20170518092131.16571-16-famz@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 75305
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.4 qemu-kvm PATCH v3 15/18] serial: make tsr_retry unsigned
|
|
|
9ae3a8 |
Bugzilla: 1451470
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
It can never become negative; reflect this in the type of the field
|
|
|
9ae3a8 |
and simplify the conditions.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Tested-by: Bret Ketchum <bcketchum@gmail.com>
|
|
|
9ae3a8 |
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 807464d8a7326e1025a2f392bf41636b0809d6da)
|
|
|
9ae3a8 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Conflicts:
|
|
|
9ae3a8 |
hw/char/serial.c
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Downstream doesn't have 7385b275d9, so dropped the vmstate_serial_tsr
|
|
|
9ae3a8 |
hunk because the structure doesn't exist.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
The serial_post_load hunk is backported because it's safe, and good for
|
|
|
9ae3a8 |
the future backport of 7385b275d9 if there will be.
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/char/serial.c | 10 +++++++---
|
|
|
9ae3a8 |
include/hw/char/serial.h | 2 +-
|
|
|
9ae3a8 |
2 files changed, 8 insertions(+), 4 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/hw/char/serial.c b/hw/char/serial.c
|
|
|
9ae3a8 |
index 9986adf..afa1932 100644
|
|
|
9ae3a8 |
--- a/hw/char/serial.c
|
|
|
9ae3a8 |
+++ b/hw/char/serial.c
|
|
|
9ae3a8 |
@@ -225,7 +225,7 @@ static gboolean serial_xmit(GIOChannel *chan, GIOCondition cond, void *opaque)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
do {
|
|
|
9ae3a8 |
assert(!(s->lsr & UART_LSR_TEMT));
|
|
|
9ae3a8 |
- if (s->tsr_retry <= 0) {
|
|
|
9ae3a8 |
+ if (s->tsr_retry == 0) {
|
|
|
9ae3a8 |
assert(!(s->lsr & UART_LSR_THRE));
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (s->fcr & UART_FCR_FE) {
|
|
|
9ae3a8 |
@@ -248,7 +248,7 @@ static gboolean serial_xmit(GIOChannel *chan, GIOCondition cond, void *opaque)
|
|
|
9ae3a8 |
/* in loopback mode, say that we just received a char */
|
|
|
9ae3a8 |
serial_receive1(s, &s->tsr, 1);
|
|
|
9ae3a8 |
} else if (qemu_chr_fe_write(s->chr, &s->tsr, 1) != 1) {
|
|
|
9ae3a8 |
- if (s->tsr_retry >= 0 && s->tsr_retry < MAX_XMIT_RETRY &&
|
|
|
9ae3a8 |
+ if (s->tsr_retry < MAX_XMIT_RETRY &&
|
|
|
9ae3a8 |
qemu_chr_fe_add_watch(s->chr, G_IO_OUT|G_IO_HUP,
|
|
|
9ae3a8 |
serial_xmit, s) > 0) {
|
|
|
9ae3a8 |
s->tsr_retry++;
|
|
|
9ae3a8 |
@@ -296,7 +296,7 @@ static void serial_ioport_write(void *opaque, hwaddr addr, uint64_t val,
|
|
|
9ae3a8 |
s->lsr &= ~UART_LSR_THRE;
|
|
|
9ae3a8 |
s->lsr &= ~UART_LSR_TEMT;
|
|
|
9ae3a8 |
serial_update_irq(s);
|
|
|
9ae3a8 |
- if (s->tsr_retry <= 0) {
|
|
|
9ae3a8 |
+ if (s->tsr_retry == 0) {
|
|
|
9ae3a8 |
serial_xmit(NULL, G_IO_OUT, s);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -619,6 +619,10 @@ static int serial_post_load(void *opaque, int version_id)
|
|
|
9ae3a8 |
if (version_id < 3) {
|
|
|
9ae3a8 |
s->fcr_vmstate = 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
+ if (s->tsr_retry > MAX_XMIT_RETRY) {
|
|
|
9ae3a8 |
+ s->tsr_retry = MAX_XMIT_RETRY;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
/* Initialize fcr via setter to perform essential side-effects */
|
|
|
9ae3a8 |
serial_ioport_write(s, 0x02, s->fcr_vmstate, 1);
|
|
|
9ae3a8 |
serial_update_parameters(s);
|
|
|
9ae3a8 |
diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h
|
|
|
9ae3a8 |
index 9ab81f6..2661f8c 100644
|
|
|
9ae3a8 |
--- a/include/hw/char/serial.h
|
|
|
9ae3a8 |
+++ b/include/hw/char/serial.h
|
|
|
9ae3a8 |
@@ -55,7 +55,7 @@ struct SerialState {
|
|
|
9ae3a8 |
int last_break_enable;
|
|
|
9ae3a8 |
int it_shift;
|
|
|
9ae3a8 |
int baudbase;
|
|
|
9ae3a8 |
- int tsr_retry;
|
|
|
9ae3a8 |
+ uint32_t tsr_retry;
|
|
|
9ae3a8 |
uint32_t wakeup;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* Time when the last byte was successfully sent out of the tsr */
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|