Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AD2B1F47CA8 for ; Thu, 5 Mar 2026 18:16:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vyDF8-0003C2-0b; Thu, 05 Mar 2026 13:16:14 -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 1vyDEw-0003BY-PG for qemu-arm@nongnu.org; Thu, 05 Mar 2026 13:16:03 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vyDEt-0006gQ-67 for qemu-arm@nongnu.org; Thu, 05 Mar 2026 13:16:01 -0500 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-439baf33150so3678538f8f.0 for ; Thu, 05 Mar 2026 10:15:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772734556; x=1773339356; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:references :in-reply-to:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=NlmsCJf2fzHTAC0WK8L7tDQENhBUUh9+SRB8PgBoI0Y=; b=PQ+fEu3oz8NR791Tv2BI2BtI9tadlSot14vNfOzFfBCdFC32ZvDNmqZnnb5z9c2aJg uN/fv/B+vpwGc5VDSDytL1RWEHcF2HsnSffTb/FTb5QPtmUdgMAVzF3VEKQxIh4+gnu+ FkAHlPcWuMzkGRkPmSTHzG/IH6VAkZqF73CM22QeGvUbWygzmizKXxBg6jaol7YzBVoQ rVUa6ifxSx1p1ThLzu7NUZeU/hbGiqTIotMsLfboAatSx1igbIUNZdmnqXvuQCWvTlfY 0qft7wOygAVYhi8It3AOZBiLV+mQ9wPWBpqkVUxydvaGLYeapPMFUnfIsUIPESRQepyM uv8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772734556; x=1773339356; h=content-transfer-encoding:mime-version:message-id:references :in-reply-to:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=NlmsCJf2fzHTAC0WK8L7tDQENhBUUh9+SRB8PgBoI0Y=; b=w1yBWyYor885Z0tjjEzZfJ5MLaYyu66g5CfDuYvNGS2vDsvrcoxuSX4jrs4QrVnOt0 wBb/rRzs5LXP0VeNrkAqiFAUX4XmusL31TQkkt84+BBMIDBvl18RxnS2wU+ntAY/F4Ta RjiBsXRZWEcrkp3gfGdng3pZspRITRDiwNsPge+SdhwYrnpWrRRN+Gma9oqo6+Igoxov LzlWNhEsOei0BiLQyYRjACQ56dOjdwrmam5n7YOglL/8QWmoFMXVAFJDK9eW3c7nwf9H /8eYa7oJQ7WfjISMREoH9ldfy0jDB0yXbpRrf6XD4uXTa29iXFWXjj2Yl0WCMzOEdTWP GSVQ== X-Forwarded-Encrypted: i=1; AJvYcCWo+XX2LaM2ELt0oBDA0JYRpqvKDzoMX9j8KVTtwMQADRIiNjJKsgz0fj4g5eYuUdlyekyCEKPbMA==@nongnu.org X-Gm-Message-State: AOJu0Yz3U/3jkm4PUYzxg8zH2pHzJm7CtDECYDl2Zh3rpU9iIZWN/FU2 wJud/G5Vp9kaVqNtRSH3kW3d1clBogrzINmkSVLWL3PaZ5KRpScbM1+O X-Gm-Gg: ATEYQzy/iIvSwb+lOOTw+jEwuFdc1rrfLLcuTk+HblSQiVDVESKizdXyhnGfqmqxsCK en7G3md9aOnaPh7Yd+tBrNb2W0FzrvYABymy8U3y7woKZo+hUTyJPSKtViEhg6UAchXFiW1f2Vu MIoaTOan6UG1bNddZbxW5hX2oACimNoiqoUJh02OvwsumJ48PxLJsQ/nGe2ubFEUqX6+SteBb14 gHTEa4I9RZHw169RbwPRoIQVxhdEVjtrvVyULr7pj33Zayfd18dxS7XvkFn8zrWxNUxyFCq7L6T bp+roVD8xrVJJHFuvQPglH93jVd2khgF7R+J6yxs7vQb09A3Zk9pxZNt5+iZ2SztdXGJ73XIiRJ GiIUwn180xYlId3DnWdBEUdsNjzooaXr417UgLyOerBncpaDtS3MczR7mjeSdD6ImHstTBwWrIE IelWP2Dkt50w8vqykj2RyZn3MLMjEJRw== X-Received: by 2002:a05:6000:438a:b0:439:c560:bb79 with SMTP id ffacd0b85a97d-439cfd65a2emr6126449f8f.17.1772734555672; Thu, 05 Mar 2026 10:15:55 -0800 (PST) Received: from ehlo.thunderbird.net ([185.238.219.34]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439ac9f3e5bsm42100771f8f.37.2026.03.05.10.15.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Mar 2026 10:15:55 -0800 (PST) Date: Thu, 05 Mar 2026 17:53:29 +0000 From: Bernhard Beschow To: Peter Maydell CC: qemu-devel@nongnu.org, Helge Deller , =?ISO-8859-1?Q?Marc-Andr=E9_Lureau?= , Steven Lee , =?ISO-8859-1?Q?C=E9dric_Le_Goater?= , Troy Lee , Richard Henderson , Mark Cave-Ayland , qemu-arm@nongnu.org, Jamin Lin , =?ISO-8859-1?Q?Philippe_Mathieu-Daud=E9?= , Paolo Bonzini , "Michael S. Tsirkin" , Andrew Jeffery , Joel Stanley Subject: Re: [PATCH v2 12/13] hw/char/serial: Inherit from SysBusDevice In-Reply-To: References: <20260303222143.142741-1-shentey@gmail.com> <20260303222143.142741-13-shentey@gmail.com> Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=shentey@gmail.com; helo=mail-wr1-x42c.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@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-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org Sender: qemu-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org Am 5=2E M=C3=A4rz 2026 10:07:23 UTC schrieb Peter Maydell : >On Tue, 3 Mar 2026 at 22:22, Bernhard Beschow wrote= : >> >> SerialState currently inherits just from DeviceState and serial devices >> use SerialState as an "IP block"=2E Since DeviceState doesn't have an A= PI >> to provide MMIO regions or IRQs, all serial devices access attributes >> internal to SerialState directly=2E Fix this by having SerialState inhe= rit >> from SysBusDevice=2E >> >> In addition, DeviceState doesn't participate in the reset framework >> while SysBusDevice does=2E This allows for implementing reset >> functionality more idiomatically=2E >> >> Signed-off-by: Bernhard Beschow > > > >> diff --git a/hw/char/diva-gsp=2Ec b/hw/char/diva-gsp=2Ec >> index 2ea60103ea=2E=2E55c42effe9 100644 >> --- a/hw/char/diva-gsp=2Ec >> +++ b/hw/char/diva-gsp=2Ec >> @@ -56,13 +56,13 @@ typedef struct PCIDivaSerialState { >> static void diva_pci_exit(PCIDevice *dev) >> { >> PCIDivaSerialState *pci =3D DO_UPCAST(PCIDivaSerialState, dev, dev= ); >> - SerialState *s; >> int i; >> >> for (i =3D 0; i < pci->ports; i++) { >> - s =3D pci->state + i; >> - qdev_unrealize(DEVICE(s)); >> - memory_region_del_subregion(&pci->membar, &s->io); >> + SysBusDevice *sbd =3D SYS_BUS_DEVICE(pci->state + i); >> + qdev_unrealize(DEVICE(sbd)); >> + memory_region_del_subregion(&pci->membar, >> + sysbus_mmio_get_region(sbd, 0)); >> } >> qemu_free_irqs(pci->irqs, pci->ports); >> } > >The ordering here looks a little odd -- is it really OK to >keep using sbd (passing it to sysbus_mmio_get_region()) after >we have unrealized the device ? Remove the region from the membar >first and then unrealize would seem a more natural order=2E Indeed=2E Will add a patch before this one=2E Thanks, Bermhard >Perhaps the MR refcounts here save us, though=2E > >> diff --git a/hw/char/serial-pci-multi=2Ec b/hw/char/serial-pci-multi=2E= c >> index 38e5a78e6f=2E=2E4e51d14111 100644 >> --- a/hw/char/serial-pci-multi=2Ec >> +++ b/hw/char/serial-pci-multi=2Ec >> @@ -50,13 +50,13 @@ typedef struct PCIMultiSerialState { >> static void multi_serial_pci_exit(PCIDevice *dev) >> { >> PCIMultiSerialState *pci =3D DO_UPCAST(PCIMultiSerialState, dev, d= ev); >> - SerialState *s; >> int i; >> >> for (i =3D 0; i < pci->ports; i++) { >> - s =3D pci->state + i; >> - qdev_unrealize(DEVICE(s)); >> - memory_region_del_subregion(&pci->iobar, &s->io); >> + SysBusDevice *sbd =3D SYS_BUS_DEVICE(pci->state + i); >> + qdev_unrealize(DEVICE(sbd)); >> + memory_region_del_subregion(&pci->iobar, >> + sysbus_mmio_get_region(sbd, 0)); >> } >> } > >Similarly here=2E > >Otherwise >Reviewed-by: Peter Maydell > >thanks >-- PMM