From patchwork Fri Dec 12 12:44:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 420453 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D0AF1140081 for ; Fri, 12 Dec 2014 23:47:44 +1100 (AEDT) Received: from localhost ([::1]:56891 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzPdH-0002Od-3c for incoming@patchwork.ozlabs.org; Fri, 12 Dec 2014 07:47:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39902) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzPaB-0006tk-TX for qemu-devel@nongnu.org; Fri, 12 Dec 2014 07:44:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XzPZz-0001mb-CW for qemu-devel@nongnu.org; Fri, 12 Dec 2014 07:44:28 -0500 Received: from mail-wi0-x230.google.com ([2a00:1450:400c:c05::230]:55446) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzPZz-0001mJ-5s for qemu-devel@nongnu.org; Fri, 12 Dec 2014 07:44:19 -0500 Received: by mail-wi0-f176.google.com with SMTP id ex7so2351153wid.15 for ; Fri, 12 Dec 2014 04:44:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=b83gls22/KsM1Yv53CDCjeGN4IVpS8pC9jZu55v1XHU=; b=sziya9ZIq9FRnY+GQ0Uypwc/zE6M+Wz0dLELs0PiHCJC8DRmWVyLh50fBYqqRNlLVV nFqNkveDU89e6sFNIvv0X0gNRfE9v9r4lfjpqCH3JZPLjd84lbQ9PHwNcfgSuNceq8IV fUj2ddDt5E1z06Nqd97iCkIv5wjHlP3CI6S1o6Rdj8qczsgTfMxWr4dO0W9j6NKerT5Z DqHCU5dF0y2U3qWFpX9D3skiZGjK7V4kleN8KlKvOzFPezKtJPSN++k4fjlD1vx26TIQ //Z4KScZVlvDQeUVvMALrk/b4rOmoc3lMXMifCsQQzIA4li+yDq/m3ZJdTJG+vqNdAeQ BlEg== X-Received: by 10.194.80.38 with SMTP id o6mr25847557wjx.126.1418388258511; Fri, 12 Dec 2014 04:44:18 -0800 (PST) Received: from playground.station (net-2-35-193-40.cust.vodafonedsl.it. [2.35.193.40]) by mx.google.com with ESMTPSA id hn2sm1716801wjc.5.2014.12.12.04.44.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Dec 2014 04:44:17 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Dec 2014 13:44:03 +0100 Message-Id: <1418388243-1886-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1418388243-1886-1-git-send-email-pbonzini@redhat.com> References: <1418388243-1886-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::230 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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Signed-off-by: Paolo Bonzini --- 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: