From patchwork Fri Jan 10 18:27:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 856285 Delivered-To: patch@linaro.org Received: by 2002:a5d:525c:0:b0:385:e875:8a9e with SMTP id k28csp369591wrc; Fri, 10 Jan 2025 10:28:53 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUYvc52om5cxr1FOWrJYIuxrmK3WTP2fEIv/vcfNMJHX0G/z59RqNN2gpAzBJIi9ICv+W2Z5A==@linaro.org X-Google-Smtp-Source: AGHT+IHSYSnsYcUIet4W/lRWlmVn/paOx/ph3dtd+O+yWK2/gy7aOOYRp5+dfiAQk2lVbTkyWIRD X-Received: by 2002:a05:620a:40c1:b0:79f:67b:4fdc with SMTP id af79cd13be357-7bcd9729ab3mr1604964685a.2.1736533733501; Fri, 10 Jan 2025 10:28:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736533733; cv=none; d=google.com; s=arc-20240605; b=fxRZQ4qEM3y33gPZE2wPvL5LXO5HxoEg2cuO+P2vJK0EfYuOSB0QTQ6Ywmjbm2Voec P1LvbB6dKQxc4GurRb7sNmXqSiF3U7hjdogYPDbfSHr7tDpNDQ9Drf8flVydnkzMRndq cNWr7ryzFcXRY6LqVp0Ugl0mlzHp5oOh2B8shGszsuqCEbtMNj1KqBof/z5loXkSJYvu Fp81yiwSVZvmm0EECSgIEvbkCsSUsLCUNJy9vTA1Bm9ik0MkB+24rYX+d+eLsxHf5pmx r1UBS22qv5NJuBk9mTYA0FCNijDek34VtbkbigFuXbRsjR3RzPGHT/8j7MhkktKDzyOt w4qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=A/yUFaRyzJYE/4lcFjJ8uzhfiQFfrwtitfN415Djc8k=; fh=55AMkU65muUNEfSUDay349Ye7JvT2KZydShfpkveXkE=; b=Acj6WjXXlJqwkCbr2THT2teW8OmoXBDdHTeIVCr7eDZmrBz3yiw9URnZXj60sjCivk iRz4qHa9OKyOno/uiuF5bxRpMcYHKwpABxZf4foMeO4sdytD9pZXFSgWSzldhzJBerWc GtvgnLm8mYASl4MDeS9XYJ8VOEM8+lWeJOePHAJ3xk1BMnBtPjr5ftQ/j3PZNiATG4Op zwxPsDj5/mPHXuBzBXHkYac/0afca56vwL4eWYdQab/wX6jS3Dz90lBv40F5QYH6+hf2 5V7HiWHvNkqXDXMZuzFYGdZnWepjcUtS8dJCQaADTjMdFqcRIEmb6tdiJnRlyas+UC1l ExBA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SNUoBJkd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7bce33076a6si452259085a.323.2025.01.10.10.28.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 10 Jan 2025 10:28:53 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SNUoBJkd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tWJk4-00023U-Jm; Fri, 10 Jan 2025 13:28:20 -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 1tWJk2-00022S-8L for qemu-devel@nongnu.org; Fri, 10 Jan 2025 13:28:18 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tWJjy-0007QA-LP for qemu-devel@nongnu.org; Fri, 10 Jan 2025 13:28:16 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4361e89b6daso17827445e9.3 for ; Fri, 10 Jan 2025 10:28:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736533692; x=1737138492; darn=nongnu.org; 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=A/yUFaRyzJYE/4lcFjJ8uzhfiQFfrwtitfN415Djc8k=; b=SNUoBJkdu1QA5YJwaIQXfsdVuJpFWOZpdbT0aOcS4o7kfyIKfPFOqGD7uhfUjqVN/U hBaSRc1kpFgV+jSg9tMkrDYt2DLAFwq589pzIahnQzW89O8U3uPu6X+O26CyYMlnVWB7 A5gCcLtuhBF8F8lE2Xl3mgxVHBDcsxGxBbZDXIjmwuvKllc+TWkL6k/pzOjo9AHZskYm xqC3Hgh92KVQpRyPqadByNoc0nt2pRojC4dUcWn0ezW2hS1AqC80HwiwgcaBHEOvfS18 NCTyQf3wyFQvwuuGq3A07f7mFrSVqNv+3ihSccnbA6OPAcCT/qMRPrIgetAvAttgG/15 48Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736533692; x=1737138492; 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=A/yUFaRyzJYE/4lcFjJ8uzhfiQFfrwtitfN415Djc8k=; b=IAL+E5wuCzDJimxUvQ5lzWPP34l97LdWYtAOB+OFNTy56mhJG5Ux6HdE9yPvLs016D 9A2xhT2u+N0amBkmRmg68/MDVDLU+7f1C++lS/RWQdAwdFpc1goAs92BP8gbHv95utIJ QWO/qZGhLqRftQ5Y58iiKMeM04P+nlEIeEpGt5NjO240c7IvohDyIwJ4iOz1nRvRdXR5 /orTSsxqN23os46tsSJLsdi/eFssLPO829K4qNudBQCUngNoHsFX59SeGGg2wiMqwIgF MFUk+0c4O2nJec4I4UkvLvq+MInbWNJARJuuvKY1UTWG/bQJ3OpN9wT6Dx30LoT780/P omwQ== X-Gm-Message-State: AOJu0YwmyoVVbetlJggIOw1xGeFkglkPPe+tGgqfXS+qLV5pEFHyagRv Ov2TMTAZi8SdiskQirwxgYss6dYoobUVfpGdBZmcmKwd1KwL0TzjZ+ZCxXfYVdPaspqSPD6dk5j 9KAU= X-Gm-Gg: ASbGncuh+TVg3MWrZfEwhAh2w1v2WIvOZxCS1iCbwiNb1vdmhZnXxglRn3s1qjmU8Pd aFDs18efyrHljS1uwlKoCwHNJFBnKId3STyySboSPjbzjd5cMArm4WtMZrY01BmCpG9Yif9VLzf 5m5/fpxJ3KGcsTTyARFiGYJlMRdBnJTLrqdgI4jX+W4hct9cKNGXZmspweU6dPYDHgV2aYCe8ed 88e+KSGmTH3SOfD5CKRaEZxTURS5OVojFkpPl/wmx48wrTcljBJXkJdHiM2Gf2DRFa0FgGkYXbQ 2VndVx3pRDlXLjMAZGV2B0JM852eSWQ= X-Received: by 2002:a05:600c:1c8b:b0:434:f5c0:32b1 with SMTP id 5b1f17b1804b1-436e26a7578mr116218715e9.15.1736533692137; Fri, 10 Jan 2025 10:28:12 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436dcc8ddddsm82415595e9.0.2025.01.10.10.28.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 10 Jan 2025 10:28:11 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Michael S. Tsirkin" , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Mark Cave-Ayland , Peter Maydell , Pierrick Bouvier , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= Subject: [PATCH v2 2/2] hw/char/serial: Convert to three-phase reset Date: Fri, 10 Jan 2025 19:27:59 +0100 Message-ID: <20250110182759.84071-3-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250110182759.84071-1-philmd@linaro.org> References: <20250110182759.84071-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Convert the TYPE_SERIAL (16550A UART) to three-phase reset. Only local states are reset so use the ResetHold handler, like other legacy devices. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Pierrick Bouvier --- hw/char/serial.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/char/serial.c b/hw/char/serial.c index 562931685e7..9cb6e30c9ce 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -851,9 +851,9 @@ const VMStateDescription vmstate_serial = { } }; -static void serial_reset(void *opaque) +static void serial_reset_hold(Object *obj, ResetType type) { - SerialState *s = opaque; + SerialState *s = (SerialState *)obj; if (s->watch_tag > 0) { g_source_remove(s->watch_tag); @@ -928,13 +928,11 @@ static void serial_realize(DeviceState *dev, Error **errp) s->modem_status_poll = timer_new_ns(QEMU_CLOCK_VIRTUAL, (QEMUTimerCB *) serial_update_msl, s); s->fifo_timeout_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, (QEMUTimerCB *) fifo_timeout_int, s); - qemu_register_reset(serial_reset, s); qemu_chr_fe_set_handlers(&s->chr, serial_can_receive1, serial_receive1, serial_event, serial_be_change, s, NULL, true); fifo8_create(&s->recv_fifo, UART_FIFO_LENGTH); fifo8_create(&s->xmit_fifo, UART_FIFO_LENGTH); - serial_reset(s); } static void serial_unrealize(DeviceState *dev) @@ -949,8 +947,6 @@ static void serial_unrealize(DeviceState *dev) fifo8_destroy(&s->recv_fifo); fifo8_destroy(&s->xmit_fifo); - - qemu_unregister_reset(serial_reset, s); } const MemoryRegionOps serial_io_ops = { @@ -975,12 +971,14 @@ static const Property serial_properties[] = { static void serial_class_init(ObjectClass *klass, void* data) { DeviceClass *dc = DEVICE_CLASS(klass); + ResettableClass *rc = RESETTABLE_CLASS(klass); /* internal device for serialio/serialmm, not user-creatable */ dc->user_creatable = false; dc->realize = serial_realize; dc->unrealize = serial_unrealize; device_class_set_props(dc, serial_properties); + rc->phases.hold = serial_reset_hold; } static const TypeInfo serial_info = {