From nobody Sun Apr 28 10:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1555462360; cv=none; d=zoho.com; s=zohoarc; b=PQbjPmh/xIc6iTOvtnHNh66pN4JWxjRoTt8ThA5SgeuaHsCiU5wbT3D2xTxOX6ZlyghoaGFOp9QVPLaIUQdrsoqXgplXqX7GD8YKzcUm0hK0XkNpAfbW9hxuZaYd++iLWa569TTZSrVouOGcS+BOVsm3qm3kevmRln2H192XhCk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555462360; h=Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=HijM4yMTjQ1ZZzGdGKVOKt668jUCoXfBQGB/vyA6H3k=; b=YwUx9DuqZnuG7TLAaeKGSqjdhORpiNO7a3IacjcMKPohM18Ve94BPmzqm2O/sFX+QxOE2kjMv4Lo+yWpknm6IXVsEA1RED71BDqed1ewgs0ALvicMtu4yGdWaGdQgMccrJV2o2FP2o/F3BwxONHLR0Y5qHlHqojR1Nbr+Pg52Fw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555462360237167.36041730037493; Tue, 16 Apr 2019 17:52:40 -0700 (PDT) Received: from localhost ([127.0.0.1]:44823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGYoJ-0008FN-Ir for importer@patchew.org; Tue, 16 Apr 2019 20:52:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40759) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGYnT-0007tm-Qs for qemu-devel@nongnu.org; Tue, 16 Apr 2019 20:51:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGYnS-0000M9-Qb for qemu-devel@nongnu.org; Tue, 16 Apr 2019 20:51:31 -0400 Received: from mail-io1-xd44.google.com ([2607:f8b0:4864:20::d44]:37057) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hGYnS-0000Lg-EW for qemu-devel@nongnu.org; Tue, 16 Apr 2019 20:51:30 -0400 Received: by mail-io1-xd44.google.com with SMTP id x7so19221169ioh.4 for ; Tue, 16 Apr 2019 17:51:29 -0700 (PDT) Received: from worksec.oberlin.net (ip-210-181.oberlin.net. [208.66.210.181]) by smtp.gmail.com with ESMTPSA id 136sm553791itk.28.2019.04.16.17.51.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Apr 2019 17:51:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oberlin-edu.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=HijM4yMTjQ1ZZzGdGKVOKt668jUCoXfBQGB/vyA6H3k=; b=Y3orv1Uqcv/W81V5SxxxMX7QBuJ3vc6BYLrlsROLh3O2EX26zA1Vr18dY9VG++XmWh PjbSp5EzOONUkO+k3644lrNxK3xQ7N3eg+LMQqyABvc6hqW92VqagtR/VgMrnbRLP2/Z p9XIOyaex167n+pD3ltVSsaQUbwsLpP9vwDNQVORA5VyAHZNf/QyzE48OLBvee+j7usj ZotvVqcjt3ESofWcMcNcjZZO4jQdhIdMy3qTYh4XBkM0NXHF9YZ65jzXrOw2MwRdS8UA WgWbQAkOEh2Rf22FS9i/YW0qfms4BJET834oG4g73XpiLUOgqxcdJzHW4GG7BqBZdfWn jxHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=HijM4yMTjQ1ZZzGdGKVOKt668jUCoXfBQGB/vyA6H3k=; b=Zo7fxz+DAyTYEUdteuVP++rw8gbj4OquEjpKuBQQTJdjLMFLoWILAt9fZm+HworlqJ Rdu2yYPtxVxeIDTPL4J2FQEoXbRSFCNHBF5+po25uZfEhd7GzTwEKrTB4+HMgDbsXfq9 yt6KvUCtoxgnADSYn1O0JqGKiCWjuG7vasmDxwjohNZ7nbP9aZvOxP+R8SVw6xN2ahS0 1DgBWBj2F3QXguF4YnxZ2vFCqgm2MSblSmcvDg0JcmlHkflANQTTDOWCxcm1fjptgdhl lhIeLgR+4AYoTj8a8zVN2OBUv2Tnsap0A/dP4a1g8Jn6AaHPapyGzJDthM+07ILK+ACn w+gQ== X-Gm-Message-State: APjAAAWLhP5QHujQEFnG7VTIDJ4NjifXrujgWVZBN4c2JdcjauEiMKt5 zbW/hWxZrWGuQZz3jiV0dxAMgw== X-Google-Smtp-Source: APXvYqyrXzAehE74/FUSnTdXtkK+YusILGDJjP1r10QZghXexfEKUfUhzsvMXeLNkQrAouERZ9uCBw== X-Received: by 2002:a6b:fd0f:: with SMTP id c15mr59343803ioi.132.1555462287582; Tue, 16 Apr 2019 17:51:27 -0700 (PDT) From: Stephen Checkoway To: Paolo Bonzini , Stephen Checkoway , QEMU Developers , Artyom Tarasenko , Laurent Vivier , qemu-trivial@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Mark Cave-Ayland Date: Tue, 16 Apr 2019 20:50:53 -0400 Message-Id: <20190417005053.885-1-stephen.checkoway@oberlin.edu> X-Mailer: git-send-email 2.20.1 (Apple Git-117) MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::d44 Subject: [Qemu-devel] [PATCH v2] hw/char/escc: Lower irq when transmit buffer is filled X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The SCC/ESCC will briefly stop asserting an interrupt when the transmit FIFO is filled. This code doesn't model the transmit FIFO/shift register so the pending transmit interrupt is never deasserted which means that an edge-triggered interrupt controller will never see the low-to-high transition it needs to raise another interrupt. The practical consequence of this is that guest firmware with an interrupt service routine for the ESCC that does not send all of the data it has immediately will stop sending data if the following sequence of events occurs: 1. Disable processor interrupts 2. Write a character to the ESCC 3. Add additional characters to a buffer which is drained by the ISR 4. Enable processor interrupts In this case, the first character will be sent, the interrupt will fire and the ISR will output the second character. Since the pending transmit interrupt remains asserted, no additional interrupts will ever fire. This fixes that situation by explicitly lowering the IRQ when a character is written to the buffer and no other interrupts are currently pending. Signed-off-by: Stephen Checkoway Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/char/escc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/char/escc.c b/hw/char/escc.c index 628f5f81f7..c5b05a63f1 100644 --- a/hw/char/escc.c +++ b/hw/char/escc.c @@ -509,6 +509,13 @@ static void escc_mem_write(void *opaque, hwaddr addr, break; case SERIAL_DATA: trace_escc_mem_writeb_data(CHN_C(s), val); + /* + * Lower the irq when data is written to the Tx buffer and no other + * interrupts are currently pending. The irq will be raised again = once + * the Tx buffer becomes empty below. + */ + s->txint =3D 0; + escc_update_irq(s); s->tx =3D val; if (s->wregs[W_TXCTRL2] & TXCTRL2_TXEN) { // tx enabled if (qemu_chr_fe_backend_connected(&s->chr)) { --=20 2.20.1 (Apple Git-117)