cryptospore / rpms / qemu-kvm

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