76daa3
From 15ee295534f654d6b6ba9499cdd380aa9c954920 Mon Sep 17 00:00:00 2001
76daa3
From: Andrew Jones <drjones@redhat.com>
76daa3
Date: Mon, 1 Aug 2016 14:27:09 +0200
76daa3
Subject: RHEL-only: hw/char/pl011: fix SBSA reset
76daa3
76daa3
RH-Author: Andrew Jones <drjones@redhat.com>
76daa3
Message-id: <1470061629-6395-1-git-send-email-drjones@redhat.com>
76daa3
Patchwork-id: 71697
76daa3
O-Subject: [AArch64 RHEL-7.3 qemu-kvm-rhev PATCH] RHEL-only: hw/char/pl011: fix SBSA reset
76daa3
Bugzilla: 1266048
76daa3
RH-Acked-by: Auger Eric <eric.auger@redhat.com>
76daa3
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
76daa3
RH-Acked-by: Wei Huang <wei@redhat.com>
76daa3
76daa3
When booting Linux with an SBSA UART, e.g. when booting mach-virt
76daa3
with ACPI, if the user types on the console during boot, then when
76daa3
the login prompt appears she won't be able to log in. This is
76daa3
because during boot the SBSA UART needs to be reset, but the SBSA
76daa3
specification doesn't provide registers to enable/disable the FIFOs.
76daa3
This patch observes a couple registers the SBSA UART does write to
76daa3
in order to attempt to guess when a reset is needed, and then do it.
76daa3
We risk losing some characters from the FIFO if the guess is wrong,
76daa3
but the risk of that should be quite low.
76daa3
76daa3
Signed-off-by: Andrew Jones <drjones@redhat.com>
76daa3
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
76daa3
(cherry picked from commit aa0041f7036b3052ec9477bffae2fd6f41ac7ede)
76daa3
(cherry picked from commit 4fed0775a0a86b05fb5539aca43d5ee70fc0ab99)
76daa3
---
76daa3
 hw/char/pl011.c | 12 ++++++++++++
76daa3
 1 file changed, 12 insertions(+)
76daa3
76daa3
diff --git a/hw/char/pl011.c b/hw/char/pl011.c
76daa3
index 24ea973..453fcde 100644
76daa3
--- a/hw/char/pl011.c
76daa3
+++ b/hw/char/pl011.c
76daa3
@@ -209,6 +209,18 @@ static void pl011_write(void *opaque, hwaddr offset,
76daa3
         pl011_update(s);
76daa3
         break;
76daa3
     case 17: /* UARTICR */
76daa3
+        /*
76daa3
+         * RHEL-only, fixes BZ1266048
76daa3
+         *
76daa3
+         * Look for the "signature" of a driver init or shutdown in
76daa3
+         * order to know that we need to reset the SBSA UART. Yes,
76daa3
+         * this is hacky, but as SBSA drivers aren't required to write
76daa3
+         * UARTLCR_H or UARTCR, then we don't have much choice...
76daa3
+         */
76daa3
+        if (s->int_enabled == 0 && value == 0xffff) {
76daa3
+            s->read_count = 0;
76daa3
+            s->read_pos = 0;
76daa3
+        }
76daa3
         s->int_level &= ~value;
76daa3
         pl011_update(s);
76daa3
         break;
76daa3
-- 
76daa3
1.8.3.1
76daa3