From nobody Tue Feb 10 15:29:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1668013285; cv=none; d=zohomail.com; s=zohoarc; b=FAcbHgP0T9xo0ID+1rEoqMUvY2wq0iYuAVwc3e2VjPjlcBow7NLakR30p7crWZ8eLPhbFNfr5ududUbe3X93SqCpx+8cdxFjThu6KVGahD5R1PsERV8+IY1XsLEOaZ7zkan82K3hKxl/VGIkXjSsafq1wHC5P0+SDcMsQdMLX2c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668013285; h=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=P/HzFUMC1BdHvhejcPUHEkS5z3kNmrAEn9w+43U063E=; b=UAaHnVt0NcQtDNir4JeUqMMfrqncp0/GBKP8Fi1iW5cSWzf6Aj+u2Rfa24CEdQsS5SQ7gzzd5HQ5eMs4ae0erXRUcQj2scBA16KRMEZ3XWEYDdgkQSDeTIVqKzGiFPTqNA33gMtlr8pn+YahQnzwH1hOJx9A1zzSzRrByu2eGSQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16680132857111.8444699221086012; Wed, 9 Nov 2022 09:01:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1osoR5-0003o8-H3; Wed, 09 Nov 2022 12:00:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1osoQx-0003n1-Oh for qemu-devel@nongnu.org; Wed, 09 Nov 2022 12:00:15 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1osoQw-00019g-5r for qemu-devel@nongnu.org; Wed, 09 Nov 2022 12:00:15 -0500 Received: by mail-wr1-x42e.google.com with SMTP id v1so26663395wrt.11 for ; Wed, 09 Nov 2022 09:00:13 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id p5-20020a05600c358500b003c6b9749505sm2514932wmq.30.2022.11.09.09.00.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 09:00:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=P/HzFUMC1BdHvhejcPUHEkS5z3kNmrAEn9w+43U063E=; b=o660eO91eDH2HCLaNH3uS51pqdcjZRLQ+mSItNPLq37N3hh4tRvnO/j/IB4tvv/7r7 SfIroELONdnArVxIpYjG5rngiq07iVqcJodz3vVGoNxoZ0opxid46zKTfOudlCoYQrO4 E841CGYu+NQ4uPVhmOwSva4fntPpBAW+PaEjPnV0Qe2f13tb64Ooc4O8vfMvLc1Gx9fX LDoA3QzoLvx58Wsn28WbITsXwnIBOHF0KC47H1UcZoGgvF1jS2Qnif/uIxixr19JRXxR njXLEmH0MBG0JYVszW9kgM7pkcNmfqnwq3KbGnBT1BMIhm0Ai5AvyixUzgWw7kdiwHPv 3dzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P/HzFUMC1BdHvhejcPUHEkS5z3kNmrAEn9w+43U063E=; b=3hCLBJV8JjHWaCmbcvShemjgmZH+5DoX85VVa1SN2SuRZBkq/ilobC04HSBIetVlKI F73/ChKDKI6DMjZ0yy5aJtqi/EElOKIYAQPDwCWy5v3iZ5QGvqpopOqVxPWTl2+68ImA yeqTBnZxBfzd5f6bUaqT6pTMXN5GrrDRSTNSCCapGuoFEM7sWN1qFEH0fp4Hfm3T4ZYl v55QZKB1H6AX7hjttAetJ8FGDBC9nn2PTw2fMSx5GX7DSYCd0eO8QdPGCf/ySW11QZLY 8InYt013RB0ODe75WqunBNHk36PZx0XEBz0iBT8w7iwySQqONwPcTf2777gygGFmZO44 KZug== X-Gm-Message-State: ACrzQf3HW2ABjEWfH0A3hrKKbm7RYqNJupf0b0NDytWgxcZQuofUOBw0 W0EOowjFjJcHJIMNAOrbKjKDxJg43VomSQ== X-Google-Smtp-Source: AMsMyM4JPXS45LztCubN674Rtl4Yxdh86s27/GA/WnLJ7Sab7kr4U55gImUQ6kj0bbIh/I8NsN8Zug== X-Received: by 2002:adf:f741:0:b0:236:5aa8:a07e with SMTP id z1-20020adff741000000b002365aa8a07emr933201wrp.437.1668013212555; Wed, 09 Nov 2022 09:00:12 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland Subject: [PATCH for-8.0 1/2] hw/input/ps2: Convert TYPE_PS2_DEVICE to 3-phase reset Date: Wed, 9 Nov 2022 17:00:08 +0000 Message-Id: <20221109170009.3498451-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221109170009.3498451-1-peter.maydell@linaro.org> References: <20221109170009.3498451-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: pass client-ip=2a00:1450:4864:20::42e; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1668013288110100009 Content-Type: text/plain; charset="utf-8" Convert the parent class TYPE_PS2_DEVICE to 3-phase reset. Note that we need an 'exit' phase function as well as the usual 'hold' phase function, because changing outbound IRQ line state is only permitted in 'exit'. (Strictly speaking it's not supposed to be done in a legacy reset handler either, but you can often get away with it.) Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- hw/input/ps2.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 05cf7111e31..47a5d68e300 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -1001,12 +1001,18 @@ void ps2_write_mouse(PS2MouseState *s, int val) } } =20 -static void ps2_reset(DeviceState *dev) +static void ps2_reset_hold(Object *obj) { - PS2State *s =3D PS2_DEVICE(dev); + PS2State *s =3D PS2_DEVICE(obj); =20 s->write_cmd =3D -1; ps2_reset_queue(s); +} + +static void ps2_reset_exit(Object *obj) +{ + PS2State *s =3D PS2_DEVICE(obj); + ps2_lower_irq(s); } =20 @@ -1281,8 +1287,10 @@ static void ps2_init(Object *obj) static void ps2_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); =20 - dc->reset =3D ps2_reset; + rc->phases.hold =3D ps2_reset_hold; + rc->phases.exit =3D ps2_reset_exit; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); } =20 --=20 2.25.1 From nobody Tue Feb 10 15:29:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1668013285467222.77480517014317; Wed, 9 Nov 2022 09:01:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1osoRp-00040y-RM; Wed, 09 Nov 2022 12:01:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1osoQz-0003nc-2O for qemu-devel@nongnu.org; Wed, 09 Nov 2022 12:00:22 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1osoQx-0001AD-C1 for qemu-devel@nongnu.org; Wed, 09 Nov 2022 12:00:16 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 187-20020a1c02c4000000b003cf9c3f3b80so1689280wmc.0 for ; Wed, 09 Nov 2022 09:00:14 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id p5-20020a05600c358500b003c6b9749505sm2514932wmq.30.2022.11.09.09.00.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 09:00:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rBlWL4FLtY8mNZis1U2K8M01p6OCavCbUHNH6wH10ks=; b=cnIOyNhigbJdv0VAYsfj2TpeBr28bxf6/i7swW4drNVDB7CKtQl8NC+hq3G2zXNEwi Dh86RL2wu8YYOp/nN/QP+Ngd+IRhO7ErUTg/cLfae9naJKUExA7gvZzQZkP8pkrb1yZA e8w0GKFLje1kg1VBr2ymkQgtp4tL8fj9xlQq1Eqj4Dt5xpMgYQS7n1Ok4Ul5yVueXRig F0Vbtx/6dAI3FiaABJZKP7J1Y00f8+pKI3PJqgNwrAgMmqEQttZjPpp+ylqpmr3ElT/x 1kCqwzqy2Kk2Niafw5+rZepuv4NBktFc2jBB7l8ROpVlUvU2I5QavdORt0BNsMiWgVBS FVJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rBlWL4FLtY8mNZis1U2K8M01p6OCavCbUHNH6wH10ks=; b=FT11A2YamsAkG8Qdfrmx6dHg/JXQ6leiQdwnVvWr/0FdSwcgc8dHl1HLs5HA9x7NdY DLgK2CMWptgbDIUT+MIrP2rnKi4KI6VBHUPPstTBvpnqug8K0eg1lmjpXd7I4ajRhUOC QrLh4CZvcXPjUhConepzvqaS3V7hCeLYjNiI5pCcVIYpT9LHoftuOuMasO5NpaeLfnMs lSRur6hfr9vsQ8jq2McjGGjQckVm+DJYO+mefZUoqhP4WQkbQBM5kFwxd945tGcDIVEr ZfBN8++pwPKvkSKgF+W0Hu5XJjLX3ZateEDxsqwoZIlIAHQisJl0uL89Uc6msyu//qKN HCYQ== X-Gm-Message-State: ACrzQf2qzCnyVv8v8AeGF18SCTTnYFarBAzv+h8tnxVFOFTNZq2IiXpI Wt62C/9SQ4kALWOBcRoCCwW4QBup2wFmmg== X-Google-Smtp-Source: AMsMyM5r3v9Z4lkxTX8QFE3z8lQC4EqraqO4MmpCkVw/ebor3yhFuarqmetLOcYXCwSTYQpQf+C2pg== X-Received: by 2002:a05:600c:3482:b0:3cf:6af4:c4fa with SMTP id a2-20020a05600c348200b003cf6af4c4famr938490wmq.117.1668013213636; Wed, 09 Nov 2022 09:00:13 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland Subject: [PATCH for-8.0 2/2] hw/input/ps2.c: Convert TYPE_PS2_{KBD, MOUSE}_DEVICE to 3-phase reset Date: Wed, 9 Nov 2022 17:00:09 +0000 Message-Id: <20221109170009.3498451-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221109170009.3498451-1-peter.maydell@linaro.org> References: <20221109170009.3498451-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: pass client-ip=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1668013287505100007 Content-Type: text/plain; charset="utf-8" Convert the child classes TYPE_PS2_KBD_DEVICE and TYPE_PS2_MOUSE_DEVICE to the 3-phase reset system. This allows us to stop using the old device_class_set_parent_reset() function. We don't need to register an 'exit' phase function for the subclasses, because they have no work to do in that phase. Passing NULL to resettable_class_set_parent_phases() will result in the parent class method being called for that phase, so we don't need to register a function purely to chain to the parent 'exit' phase function. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- include/hw/input/ps2.h | 2 +- hw/input/ps2.c | 31 ++++++++++++++++++++----------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/include/hw/input/ps2.h b/include/hw/input/ps2.h index ff777582cd6..cd61a634c39 100644 --- a/include/hw/input/ps2.h +++ b/include/hw/input/ps2.h @@ -36,7 +36,7 @@ struct PS2DeviceClass { SysBusDeviceClass parent_class; =20 - DeviceReset parent_reset; + ResettablePhases parent_phases; }; =20 /* diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 47a5d68e300..3253ab6a92c 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -1042,13 +1042,16 @@ static void ps2_common_post_load(PS2State *s) q->cwptr =3D ccount ? (q->rptr + ccount) & (PS2_BUFFER_SIZE - 1) : -1; } =20 -static void ps2_kbd_reset(DeviceState *dev) +static void ps2_kbd_reset_hold(Object *obj) { - PS2DeviceClass *ps2dc =3D PS2_DEVICE_GET_CLASS(dev); - PS2KbdState *s =3D PS2_KBD_DEVICE(dev); + PS2DeviceClass *ps2dc =3D PS2_DEVICE_GET_CLASS(obj); + PS2KbdState *s =3D PS2_KBD_DEVICE(obj); =20 trace_ps2_kbd_reset(s); - ps2dc->parent_reset(dev); + + if (ps2dc->parent_phases.hold) { + ps2dc->parent_phases.hold(obj); + } =20 s->scan_enabled =3D 1; s->translate =3D 0; @@ -1056,13 +1059,16 @@ static void ps2_kbd_reset(DeviceState *dev) s->modifiers =3D 0; } =20 -static void ps2_mouse_reset(DeviceState *dev) +static void ps2_mouse_reset_hold(Object *obj) { - PS2DeviceClass *ps2dc =3D PS2_DEVICE_GET_CLASS(dev); - PS2MouseState *s =3D PS2_MOUSE_DEVICE(dev); + PS2DeviceClass *ps2dc =3D PS2_DEVICE_GET_CLASS(obj); + PS2MouseState *s =3D PS2_MOUSE_DEVICE(obj); =20 trace_ps2_mouse_reset(s); - ps2dc->parent_reset(dev); + + if (ps2dc->parent_phases.hold) { + ps2dc->parent_phases.hold(obj); + } =20 s->mouse_status =3D 0; s->mouse_resolution =3D 0; @@ -1245,10 +1251,12 @@ static void ps2_mouse_realize(DeviceState *dev, Err= or **errp) static void ps2_kbd_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); PS2DeviceClass *ps2dc =3D PS2_DEVICE_CLASS(klass); =20 dc->realize =3D ps2_kbd_realize; - device_class_set_parent_reset(dc, ps2_kbd_reset, &ps2dc->parent_reset); + resettable_class_set_parent_phases(rc, NULL, ps2_kbd_reset_hold, NULL, + &ps2dc->parent_phases); dc->vmsd =3D &vmstate_ps2_keyboard; } =20 @@ -1262,11 +1270,12 @@ static const TypeInfo ps2_kbd_info =3D { static void ps2_mouse_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); PS2DeviceClass *ps2dc =3D PS2_DEVICE_CLASS(klass); =20 dc->realize =3D ps2_mouse_realize; - device_class_set_parent_reset(dc, ps2_mouse_reset, - &ps2dc->parent_reset); + resettable_class_set_parent_phases(rc, NULL, ps2_mouse_reset_hold, NUL= L, + &ps2dc->parent_phases); dc->vmsd =3D &vmstate_ps2_mouse; } =20 --=20 2.25.1