From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: imammedo@redhat.com, andrey@xdel.ru, dgilbert@redhat.com,
batuzovk@ispras.ru
Subject: [Qemu-devel] [PATCH v3 4/4] serial: only resample THR interrupt on rising edge of IER.THRI
Date: Fri, 12 Dec 2014 13:44:03 +0100 [thread overview]
Message-ID: <1418388243-1886-5-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1418388243-1886-1-git-send-email-pbonzini@redhat.com>
There is disagreement on whether LSR.THRE should be resampled when
IER.THRI goes from 1 to 1. Bochs only does it if IER.THRI goes from 0
to 1; PCE does it even if IER.THRI is unchanged. But the Windows driver
seems to always go from 1 to 0 and back to 1, so do things in agreement
with Bochs, because the handling of thr_ipending was reported in 2010
(https://lists.gnu.org/archive/html/qemu-devel/2010-03/msg01914.html)
as breaking DR-DOS Plus.
Reported-by: Roy Tam <roytam@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/char/serial.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/hw/char/serial.c b/hw/char/serial.c
index 0a6747c..5488900 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -336,10 +336,12 @@ static void serial_ioport_write(void *opaque, hwaddr addr, uint64_t val,
s->divider = (s->divider & 0x00ff) | (val << 8);
serial_update_parameters(s);
} else {
+ int changed = (s->ier ^ val) & 0x0f;
s->ier = val & 0x0f;
/* If the backend device is a real serial port, turn polling of the modem
- status lines on physical port on or off depending on UART_IER_MSI state */
- if (s->poll_msl >= 0) {
+ * status lines on physical port on or off depending on UART_IER_MSI state.
+ */
+ if ((changed & UART_IER_MSI) && s->poll_msl >= 0) {
if (s->ier & UART_IER_MSI) {
s->poll_msl = 1;
serial_update_msl(s);
@@ -354,18 +356,23 @@ static void serial_ioport_write(void *opaque, hwaddr addr, uint64_t val,
* This is not in the datasheet, but Windows relies on it. It is
* unclear if THRE has to be resampled every time THRI becomes
* 1, or only on the rising edge. Bochs does the latter, and Windows
- * always toggles IER to all zeroes and back to all ones. But for
- * now leave it as it has always been in QEMU.
+ * always toggles IER to all zeroes and back to all ones, so do the
+ * same.
*
* If IER.THRI is zero, thr_ipending is not used. Set it to zero
* so that the thr_ipending subsection is not migrated.
*/
- if ((s->ier & UART_IER_THRI) && (s->lsr & UART_LSR_THRE)) {
- s->thr_ipending = 1;
- } else {
- s->thr_ipending = 0;
+ if (changed & UART_IER_THRI) {
+ if ((s->ier & UART_IER_THRI) && (s->lsr & UART_LSR_THRE)) {
+ s->thr_ipending = 1;
+ } else {
+ s->thr_ipending = 0;
+ }
+ }
+
+ if (changed) {
+ serial_update_irq(s);
}
- serial_update_irq(s);
}
break;
case 2:
--
1.8.3.1
next prev parent reply other threads:[~2014-12-12 12:44 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-12 12:43 [Qemu-devel] [PATCH v3 0/4] serial fixes, including 2.2->2.1 migration Paolo Bonzini
2014-12-12 12:44 ` [Qemu-devel] [PATCH v3 1/4] serial: reset thri_pending on IER writes with THRI=0 Paolo Bonzini
2014-12-15 10:46 ` Dr. David Alan Gilbert
2014-12-15 11:51 ` Paolo Bonzini
2014-12-15 13:30 ` Dr. David Alan Gilbert
2014-12-15 13:34 ` Paolo Bonzini
2014-12-15 13:37 ` Dr. David Alan Gilbert
2014-12-15 13:45 ` Paolo Bonzini
2014-12-12 12:44 ` [Qemu-devel] [PATCH v3 2/4] serial: clean up THRE/TEMT handling Paolo Bonzini
2014-12-15 11:40 ` Dr. David Alan Gilbert
2014-12-15 12:03 ` Paolo Bonzini
2014-12-15 15:21 ` Dr. David Alan Gilbert
2014-12-15 15:26 ` Paolo Bonzini
2014-12-15 15:29 ` Dr. David Alan Gilbert
2014-12-12 12:44 ` [Qemu-devel] [PATCH v3 3/4] serial: update LSR on enabling/disabling FIFOs Paolo Bonzini
2014-12-15 15:50 ` Dr. David Alan Gilbert
2014-12-15 15:52 ` Paolo Bonzini
2014-12-12 12:44 ` Paolo Bonzini [this message]
2014-12-15 16:05 ` [Qemu-devel] [PATCH v3 4/4] serial: only resample THR interrupt on rising edge of IER.THRI Dr. David Alan Gilbert
2014-12-15 16:10 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1418388243-1886-5-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=andrey@xdel.ru \
--cc=batuzovk@ispras.ru \
--cc=dgilbert@redhat.com \
--cc=imammedo@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).