From nobody Tue Feb 10 07:23:26 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1621078600; cv=none; d=zohomail.com; s=zohoarc; b=CSRaROdwZgi1cn1vAKByrnN72hfRFxFjTqk25EgEf58LdF8WwSrOdzRYgRmOncTco/Kwc18nikqHfVnX+DD7e/t9gSnGzdSdxD+luaNfLlnNXq1MwTLCZudkBuK91C455c4h024mC1j8MaFjGptCZ2N0Wma5c+JL0cCApR22gak= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621078600; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=M2KmAnndUFMvq9Tflra/0mRteEr3teZGB07/oSHEMjY=; b=g1hZglPRKPMc7AuVgVeYv1j1k7M7+RNuZ7OTUxRFCikvT9s4LDyLnWk1+63QMTFF8ia0twS8dpohs8U+lv2EcePEusaej1c862akYNUAkV2tdhAsTAAUnkiSvEWaoc1yLUmrzLLAK44SlOR+AFW6IjTey4V70+M1m9kMucTZj2g= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621078600604726.415077181946; Sat, 15 May 2021 04:36:40 -0700 (PDT) Received: from localhost ([::1]:51556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lhsb1-00051p-Hg for importer@patchew.org; Sat, 15 May 2021 07:36:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46462) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhsXm-0004FA-Cr for qemu-devel@nongnu.org; Sat, 15 May 2021 07:33:18 -0400 Received: from mailout07.t-online.de ([194.25.134.83]:48950) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhsXj-0003NK-Ju for qemu-devel@nongnu.org; Sat, 15 May 2021 07:33:18 -0400 Received: from fwd22.aul.t-online.de (fwd22.aul.t-online.de [172.20.26.127]) by mailout07.t-online.de (Postfix) with SMTP id E32DD5300B; Sat, 15 May 2021 13:33:13 +0200 (CEST) Received: from linpower.localnet (bpPRBoZYghVm7V+56Y9dPksAMHLdeQP+CKUipxVHiwbkERSTNnBrdIxieKcXg3KQBg@[79.208.18.63]) by fwd22.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1lhsXh-01TqKm0; Sat, 15 May 2021 13:33:13 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id B145E20062C; Sat, 15 May 2021 13:32:54 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: "Michael S. Tsirkin" , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 08/11] pckbd: add controller response queue Date: Sat, 15 May 2021 13:32:51 +0200 Message-Id: <20210515113254.6245-8-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: bpPRBoZYghVm7V+56Y9dPksAMHLdeQP+CKUipxVHiwbkERSTNnBrdIxieKcXg3KQBg X-TOI-EXPURGATEID: 150726::1621078393-0000454D-E6746B18/0/0 CLEAN NORMAL X-TOI-MSGID: c29e00a8-b4b2-46cd-8929-dcb0cc00d6c5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=194.25.134.83; envelope-from=volker.ruemelin@t-online.de; helo=mailout07.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Add a separate queue for PS/2 controller responses. The responses no longer get queued in the keyboard or mouse queues. The advantage of this can be seen after the next two patches, where the guest can disable the PS/2 communication with keyboard and mouse and still talk to the PS/2 controller. Signed-off-by: Volker R=C3=BCmelin --- hw/input/pckbd.c | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c index adce525b88..e9523e164f 100644 --- a/hw/input/pckbd.c +++ b/hw/input/pckbd.c @@ -132,11 +132,14 @@ =20 #define KBD_PENDING_KBD 1 #define KBD_PENDING_AUX 2 +#define KBD_PENDING_CTRL_KBD 0x04 +#define KBD_PENDING_CTRL_AUX 0x08 =20 #define KBD_MIGR_TIMER_PENDING 0x1 =20 #define KBD_OBSRC_KBD 0x01 #define KBD_OBSRC_MOUSE 0x02 +#define KBD_OBSRC_CTRL 0x04 =20 typedef struct KBDState { uint8_t write_cmd; /* if non zero, write data to port 60 is expected */ @@ -149,6 +152,7 @@ typedef struct KBDState { /* Bitmask of devices with data available. */ uint8_t pending; uint8_t obdata; + uint8_t cbdata; void *kbd; void *mouse; QEMUTimer *throttle_timer; @@ -199,12 +203,18 @@ static void kbd_update_irq(KBDState *s) if (s->pending) { s->status |=3D KBD_STAT_OBF; s->outport |=3D KBD_OUT_OBF; - if (s->pending =3D=3D KBD_PENDING_AUX) { + if (s->pending & KBD_PENDING_CTRL_KBD) { + s->obsrc =3D KBD_OBSRC_CTRL; + } else if (s->pending & KBD_PENDING_CTRL_AUX) { s->status |=3D KBD_STAT_MOUSE_OBF; s->outport |=3D KBD_OUT_MOUSE_OBF; - s->obsrc =3D KBD_OBSRC_MOUSE; - } else { + s->obsrc =3D KBD_OBSRC_CTRL; + } else if (s->pending & KBD_PENDING_KBD) { s->obsrc =3D KBD_OBSRC_KBD; + } else { + s->status |=3D KBD_STAT_MOUSE_OBF; + s->outport |=3D KBD_OUT_MOUSE_OBF; + s->obsrc =3D KBD_OBSRC_MOUSE; } } kbd_update_irq_lines(s); @@ -273,10 +283,21 @@ static uint64_t kbd_read_status(void *opaque, hwaddr = addr, =20 static void kbd_queue(KBDState *s, int b, int aux) { - if (aux) - ps2_queue(s->mouse, b); - else - ps2_queue(s->kbd, b); + s->cbdata =3D b; + s->pending &=3D ~KBD_PENDING_CTRL_KBD & ~KBD_PENDING_CTRL_AUX; + s->pending |=3D aux ? KBD_PENDING_CTRL_AUX : KBD_PENDING_CTRL_KBD; + kbd_safe_update_irq(s); +} + +static uint8_t kbd_dequeue(KBDState *s) +{ + uint8_t b =3D s->cbdata; + + s->pending &=3D ~KBD_PENDING_CTRL_KBD & ~KBD_PENDING_CTRL_AUX; + if (s->pending) { + kbd_update_irq(s); + } + return b; } =20 static void outport_write(KBDState *s, uint32_t val) @@ -386,6 +407,8 @@ static uint64_t kbd_read_data(void *opaque, hwaddr addr, s->obdata =3D ps2_read_data(s->kbd); } else if (s->obsrc & KBD_OBSRC_MOUSE) { s->obdata =3D ps2_read_data(s->mouse); + } else if (s->obsrc & KBD_OBSRC_CTRL) { + s->obdata =3D kbd_dequeue(s); } } =20 @@ -527,6 +550,7 @@ static const VMStateDescription vmstate_kbd =3D { VMSTATE_UINT32_V(migration_flags, KBDState, 4), VMSTATE_UINT32_V(obsrc, KBDState, 4), VMSTATE_UINT8_V(obdata, KBDState, 4), + VMSTATE_UINT8_V(cbdata, KBDState, 4), VMSTATE_END_OF_LIST() }, .subsections =3D (const VMStateDescription*[]) { --=20 2.26.2