From patchwork Tue Feb 7 23:46:14 2023 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: 651270 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp3180524pva; Tue, 7 Feb 2023 15:47:30 -0800 (PST) X-Google-Smtp-Source: AK7set/OoSvyhaIQjGpu+6TPJTLGEogP46vP60R5pSgW8wovk10nGOLuWs5Bnr8izmOuH4Ts96QR X-Received: by 2002:a05:622a:4d0:b0:3b8:5a96:166 with SMTP id q16-20020a05622a04d000b003b85a960166mr9367077qtx.35.1675813650503; Tue, 07 Feb 2023 15:47:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675813650; cv=none; d=google.com; s=arc-20160816; b=vsqo/abNVYhZlUWEAuVcDzEE4NJXWB10xt4VUFZ0qy99EqXBXqWG1CzXjy0vdI6Sli fcW+tlNAXZ5z6OZW/VWGajvNnUztwSENJr6CrLsq5aiXyYE+nU1e4mTDjP4NWTofLCec JzKvMSlmQP/tLfREa7JiipLLSJQRYtCa8eoT7rXBJsmpC+ormKdtliOVZh+Swt4lTPjt DqBgKz68Ypemm3dMLb5/g9RvYyCT8M3+R3o4+NcApojbzqmYMB8JK5AXgKzLESt9efxU q/HKHy3wXdUchSyiVhfRCpcC841f1cJezSax6CQUBhDjAIZp3BzWBlFWWpNsra1C+ROF pYZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=T0B/27v5fhkvj3rxQ4L912Gij24XP5X1PWCgVXuzjfw=; b=d0HL/cKvoTtSYnR/LXWcYnxMDautmNwtVc4oyGIPmsGVfoa9dOCPCj0Jvpym7qB1uS fW3IVg8FnfSVTmj18FTNCjRf4PLj5mBROFgxQ+tgfPcMpmDV8OYnjndWltcyvHx+J25O IyCWahABmRgNjhrVM5iGXU3b7ZsJAHvlBq8FEV5XZ9s/nlizSgc/OeHVz7O/p1Ez9AKP plnZBzNoCKzixJxYdSqbufGcl/FazJKG2PPGViewWiogeBZCEf8Lu7ANCRcTXQojDVp0 rnaNsOm1SE/ROCfysR7ROf9oVraNx3kV3F7+1VDZpLfl0Wn4YHC8qSyF0fUpnXKUCNW6 DtqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Zsm3FaMQ; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l4-20020a05620a28c400b00738a4041778si466245qkp.174.2023.02.07.15.47.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Feb 2023 15:47:30 -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=Zsm3FaMQ; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pPXfS-0006ne-Bv; Tue, 07 Feb 2023 18:46:30 -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 1pPXfP-0006kn-Uh for qemu-devel@nongnu.org; Tue, 07 Feb 2023 18:46:28 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pPXfN-0004GK-Qc for qemu-devel@nongnu.org; Tue, 07 Feb 2023 18:46:27 -0500 Received: by mail-wr1-x429.google.com with SMTP id i5so7982606wrc.0 for ; Tue, 07 Feb 2023 15:46:25 -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=T0B/27v5fhkvj3rxQ4L912Gij24XP5X1PWCgVXuzjfw=; b=Zsm3FaMQGz6WOd/VxH8J/uOfdjYcjgyhQ9vgiuYP47AtGhRyvHPMHYDsejbkhju8NT X5ksYTVKilahLJuzPm0R3BC/Gw9knjNzTAnrT3aXMJC7hCQJ8CsO8NZUne1DED1DnCgV 2YpkNUSFehsmz3YJIgTNbfB9Aeac8jMUj6piuvAFwFVyi1wkkVXXTTc0o9cgCNnxiSPT JJOCf1KkaFYYNoSQ0PlrsbScRUGBq1bzuI1JdtCE1ungPxVMT1T9moOZFptYn+ua5Sr9 JM1DN7ejV+oYt120ouQ3RWur3boYex9GFMSIHJuiXs7ExDQrsS0Ud9T7Oak7k3E65SCW 826A== 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=T0B/27v5fhkvj3rxQ4L912Gij24XP5X1PWCgVXuzjfw=; b=UjBhTJvvvF0RsaRXPWFzcvHJkRHTqJpYxnAlz2N03/4UAkjvv8r6CSINv6CO+AtvDD c0lFjiZUZlRF04izfrHDxQ2YdDtYYWAUrzPuayTlYSjU82jL+6mlDF7u3T9+Gv063vJk B3A286QhkGy13aCM4uk4owrkWkBgLrtgBA5DTQtAhfVKoOg9imfo1muEAe0ZTiqZPMmd jBer7n/5JTD/eLmbDWnHhanq8hndSM1bTcD0LcjGi+jbxmgglhKpobS59cnGhay+lbNG 5TyJ7PkJjtrq16CzV+QjttiGvdbAi2K60KrqJWkZ2A8evt0fsdLT8kzd1LwmWAKeU/aL 10Kg== X-Gm-Message-State: AO0yUKVn/xFu55MUyCpfo9FRjqa+IWEd5CWYN2a4NYYjtiMTHn7O4oMs hLacpNpU+k+wnrT3PlWHmpl131mCfbDUSr8x X-Received: by 2002:adf:f212:0:b0:2bf:de33:61a8 with SMTP id p18-20020adff212000000b002bfde3361a8mr4915005wro.28.1675813583739; Tue, 07 Feb 2023 15:46:23 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id o15-20020a5d684f000000b002c3f03d8851sm3862862wrw.16.2023.02.07.15.46.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 07 Feb 2023 15:46:23 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Xu , =?utf-8?q?Herv=C3=A9_Poussineau?= , Bernhard Beschow , David Hildenbrand , "Michael S. Tsirkin" , Mark Cave-Ayland , qemu-ppc@nongnu.org, Gerd Hoffmann , Paolo Bonzini Subject: [PATCH 1/2] exec/ioport: Factor portio_list_register_flush_coalesced() out Date: Wed, 8 Feb 2023 00:46:14 +0100 Message-Id: <20230207234615.77300-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230207234615.77300-1-philmd@linaro.org> References: <20230207234615.77300-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=philmd@linaro.org; helo=mail-wr1-x429.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=unavailable 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 We always follow the same pattern when registering coalesced portio: - portio_list_init() - portio_list_set_flush_coalesced() - portio_list_add() Factor these 3 operations in a single helper named portio_list_register_flush_coalesced(). Drop portio_list_set_flush_coalesced() which is now inlined. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/display/qxl.c | 7 +++---- hw/display/vga.c | 5 ++--- include/exec/ioport.h | 5 ++++- softmmu/ioport.c | 27 ++++++++++++++++++++++----- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/hw/display/qxl.c b/hw/display/qxl.c index ec712d3ca2..2ecaa0643f 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -2224,10 +2224,9 @@ static void qxl_realize_primary(PCIDevice *dev, Error **errp) } vga_init(vga, OBJECT(dev), pci_address_space(dev), pci_address_space_io(dev), false); - portio_list_init(&qxl->vga_port_list, OBJECT(dev), qxl_vga_portio_list, - vga, "vga"); - portio_list_set_flush_coalesced(&qxl->vga_port_list); - portio_list_add(&qxl->vga_port_list, pci_address_space_io(dev), 0x3b0); + portio_list_register_flush_coalesced(&qxl->vga_port_list, OBJECT(dev), + qxl_vga_portio_list, vga, "vga", + pci_address_space_io(dev), 0x3b0); qxl->have_vga = true; vga->con = graphic_console_init(DEVICE(dev), 0, &qxl_ops, qxl); diff --git a/hw/display/vga.c b/hw/display/vga.c index 7a5fdff649..98d644922e 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -2309,9 +2309,8 @@ void vga_init(VGACommonState *s, Object *obj, MemoryRegion *address_space, 1); memory_region_set_coalescing(vga_io_memory); if (init_vga_ports) { - portio_list_init(&s->vga_port_list, obj, vga_ports, s, "vga"); - portio_list_set_flush_coalesced(&s->vga_port_list); - portio_list_add(&s->vga_port_list, address_space_io, 0x3b0); + portio_list_register_flush_coalesced(&s->vga_port_list, obj, vga_ports, + s, "vga", address_space_io, 0x3b0); } if (vbe_ports) { portio_list_init(&s->vbe_port_list, obj, vbe_ports, s, "vbe"); diff --git a/include/exec/ioport.h b/include/exec/ioport.h index e34f668998..eb9882a3ee 100644 --- a/include/exec/ioport.h +++ b/include/exec/ioport.h @@ -65,7 +65,10 @@ typedef struct PortioList { void portio_list_init(PortioList *piolist, Object *owner, const struct MemoryRegionPortio *callbacks, void *opaque, const char *name); -void portio_list_set_flush_coalesced(PortioList *piolist); +void portio_list_register_flush_coalesced(PortioList *piolist, Object *owner, + const MemoryRegionPortio *callbacks, + void *opaque, const char *name, + MemoryRegion *mr, uint32_t offset); void portio_list_destroy(PortioList *piolist); void portio_list_add(PortioList *piolist, struct MemoryRegion *address_space, diff --git a/softmmu/ioport.c b/softmmu/ioport.c index cb8adb0b93..be0c920c5c 100644 --- a/softmmu/ioport.c +++ b/softmmu/ioport.c @@ -124,6 +124,7 @@ void portio_list_init(PortioList *piolist, ++n; } + assert(owner); piolist->ports = callbacks; piolist->nr = 0; piolist->regions = g_new0(MemoryRegion *, n); @@ -134,11 +135,6 @@ void portio_list_init(PortioList *piolist, piolist->flush_coalesced_mmio = false; } -void portio_list_set_flush_coalesced(PortioList *piolist) -{ - piolist->flush_coalesced_mmio = true; -} - void portio_list_destroy(PortioList *piolist) { MemoryRegionPortioList *mrpio; @@ -297,3 +293,24 @@ void portio_list_del(PortioList *piolist) memory_region_del_subregion(piolist->address_space, &mrpio->mr); } } + +static void do_portio_list_register(PortioList *piolist, Object *owner, + const MemoryRegionPortio *callbacks, + void *opaque, const char *name, + MemoryRegion *mr, uint32_t offset, + bool flush_coalesced_mmio) +{ + assert(piolist && !piolist->owner); + portio_list_init(piolist, owner, callbacks, opaque, name); + piolist->flush_coalesced_mmio = flush_coalesced_mmio; + portio_list_add(piolist, mr, offset); +} + +void portio_list_register_flush_coalesced(PortioList *piolist, Object *owner, + const MemoryRegionPortio *callbacks, + void *opaque, const char *name, + MemoryRegion *mr, uint32_t offset) +{ + do_portio_list_register(piolist, owner, callbacks, + opaque, name, mr, offset, true); +}