From nobody Sun May 5 05:03:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14908838765753.0370453837215337; Thu, 30 Mar 2017 07:24:36 -0700 (PDT) Received: from localhost ([::1]:35928 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctb07-0000qh-A5 for importer@patchew.org; Thu, 30 Mar 2017 10:24:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctayF-000806-RJ for qemu-devel@nongnu.org; Thu, 30 Mar 2017 10:22:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctayC-0003FX-HO for qemu-devel@nongnu.org; Thu, 30 Mar 2017 10:22:39 -0400 Received: from mx2.suse.de ([195.135.220.15]:36840) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ctayC-0003F0-BZ for qemu-devel@nongnu.org; Thu, 30 Mar 2017 10:22:36 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 428E6AC4A; Thu, 30 Mar 2017 14:22:35 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Alexander Graf To: qemu-devel@nongnu.org Date: Thu, 30 Mar 2017 16:22:55 +0200 Message-Id: <1490883775-94658-1-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.8.5.6 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 195.135.220.15 Subject: [Qemu-devel] [PATCH] input: Add trace event for empty keyboard queue 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: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When driving QEMU from the outside, we have basically no chance to determine how quickly the guest OS picks up key events, so we usually have to limit ourselves to very slow keyboard presses to make sure the guest always has enough chance to pick them up. This patch adds a trace events when the keyboarde queue is drained. An external driver can use that as hint that new keys can be pressed. Signed-off-by: Alexander Graf --- hw/input/hid.c | 4 ++++ hw/input/trace-events | 1 + 2 files changed, 5 insertions(+) diff --git a/hw/input/hid.c b/hw/input/hid.c index fa9cc4c..93887ec 100644 --- a/hw/input/hid.c +++ b/hw/input/hid.c @@ -256,6 +256,10 @@ static void hid_keyboard_process_keycode(HIDState *hs) slot =3D hs->head & QUEUE_MASK; QUEUE_INCR(hs->head); hs->n--; keycode =3D hs->kbd.keycodes[slot]; =20 + if (!hs->n) { + trace_hid_kbd_queue_empty(); + } + key =3D keycode & 0x7f; index =3D key | ((hs->kbd.modifiers & (1 << 8)) >> 1); hid_code =3D hid_usage_keys[index]; diff --git a/hw/input/trace-events b/hw/input/trace-events index f3bfbed..5a87818 100644 --- a/hw/input/trace-events +++ b/hw/input/trace-events @@ -24,6 +24,7 @@ milkymist_softusb_pulse_irq(void) "Pulse IRQ" =20 # hw/input/hid.c hid_kbd_queue_full(void) "queue full" +hid_kbd_queue_empty(void) "queue empty" =20 # hw/input/virtio virtio_input_queue_full(void) "queue full" --=20 1.8.5.6