qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org, Bernhard Beschow <shentey@gmail.com>
Cc: "John Snow" <jsnow@redhat.com>,
	"David Woodhouse" <dwmw2@infradead.org>,
	"BALATON Zoltan" <balaton@eik.bme.hu>,
	"Hervé Poussineau" <hpoussin@reactos.org>,
	qemu-ppc@nongnu.org, "Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Peter Xu" <peterx@redhat.com>,
	"David Hildenbrand" <david@redhat.com>
Subject: [PATCH v3 13/18] exec/ioport: Factor portio_list_register_flush_coalesced() out
Date: Thu,  2 Mar 2023 23:40:53 +0100	[thread overview]
Message-ID: <20230302224058.43315-14-philmd@linaro.org> (raw)
In-Reply-To: <20230302224058.43315-1-philmd@linaro.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.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20230207234615.77300-2-philmd@linaro.org>
---
 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);
+}
-- 
2.38.1



  parent reply	other threads:[~2023-03-02 22:44 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-02 22:40 [PATCH v3 00/18] hw/ide: Untangle ISA/PCI abuses of ide_init_ioport() Philippe Mathieu-Daudé
2023-03-02 22:40 ` [PATCH v3 01/18] hw/ide/piix: Expose output IRQ as properties for late object population Philippe Mathieu-Daudé
2023-04-26 10:35   ` Mark Cave-Ayland
2023-03-02 22:40 ` [PATCH v3 02/18] hw/ide/piix: Allow using PIIX3-IDE as standalone PCI function Philippe Mathieu-Daudé
2023-04-26 12:48   ` Mark Cave-Ayland
2023-03-02 22:40 ` [PATCH v3 03/18] hw/i386/pc_piix: Wire PIIX3 IDE ouput IRQs to ISA bus IRQs 14/15 Philippe Mathieu-Daudé
2023-04-26 12:50   ` Mark Cave-Ayland
2023-04-27  7:54     ` Bernhard Beschow
2023-04-27  7:58     ` Bernhard Beschow
2023-04-27 11:23       ` Mark Cave-Ayland
2023-04-27 13:04         ` BALATON Zoltan
2023-04-28 16:09           ` Bernhard Beschow
2023-03-02 22:40 ` [PATCH v3 04/18] hw/isa/piix4: Wire PIIX4 " Philippe Mathieu-Daudé
2023-04-26 12:51   ` Mark Cave-Ayland
2023-03-02 22:40 ` [PATCH v3 05/18] hw/ide: Rename ISA specific ide_init_ioport -> ide_bus_init_ioport_isa Philippe Mathieu-Daudé
2023-04-26 13:05   ` Mark Cave-Ayland
2023-03-02 22:40 ` [PATCH v3 06/18] hw/ide/piix: Ensure IDE output IRQs are wired at realization Philippe Mathieu-Daudé
2023-04-26 13:10   ` Mark Cave-Ayland
2023-03-02 22:40 ` [PATCH v3 07/18] hw/isa: Deprecate isa_get_irq() in favor of isa_bus_get_irq() Philippe Mathieu-Daudé
2023-04-26 13:12   ` Mark Cave-Ayland
2023-03-02 22:40 ` [PATCH v3 08/18] hw/ide: Introduce generic ide_init_ioport() Philippe Mathieu-Daudé
2023-04-26 13:15   ` Mark Cave-Ayland
2023-03-02 22:40 ` [PATCH v3 09/18] hw/ide/piix: Use generic ide_bus_init_ioport() Philippe Mathieu-Daudé
2023-03-02 22:40 ` [PATCH v3 10/18] hw/isa: Ensure isa_register_portio_list() do not get NULL ISA device Philippe Mathieu-Daudé
2023-04-26 13:16   ` Mark Cave-Ayland
2023-03-02 22:40 ` [PATCH v3 11/18] hw/isa: Simplify isa_address_space[_io]() Philippe Mathieu-Daudé
2023-04-26 13:18   ` Mark Cave-Ayland
2023-03-02 22:40 ` [PATCH v3 12/18] hw/isa: Reduce 'isabus' singleton scope to isa_bus_new() Philippe Mathieu-Daudé
2023-04-26 13:19   ` Mark Cave-Ayland
2023-03-02 22:40 ` Philippe Mathieu-Daudé [this message]
2023-04-26 13:26   ` [PATCH v3 13/18] exec/ioport: Factor portio_list_register_flush_coalesced() out Mark Cave-Ayland
2023-03-02 22:40 ` [PATCH v3 14/18] exec/ioport: Factor portio_list_register() out Philippe Mathieu-Daudé
2023-04-26 13:28   ` Mark Cave-Ayland
2023-03-02 22:40 ` [PATCH v3 15/18] hw/southbridge/piix: Use OBJECT_DECLARE_SIMPLE_TYPE() macro Philippe Mathieu-Daudé
2023-04-26 13:29   ` Mark Cave-Ayland
2023-03-02 22:40 ` [PATCH v3 16/18] hw/isa/piix: Batch register QOM types using DEFINE_TYPES() macro Philippe Mathieu-Daudé
2023-04-26 13:30   ` Mark Cave-Ayland
2023-03-02 22:40 ` [PATCH v3 17/18] hw/isa/piix: Unify QOM type name of PIIX ISA function Philippe Mathieu-Daudé
2023-04-26 13:33   ` Mark Cave-Ayland
2023-03-02 22:40 ` [PATCH v3 18/18] hw/isa/piix: Unify PIIX-ISA QOM type names using qdev aliases Philippe Mathieu-Daudé
2023-04-26 13:35   ` Mark Cave-Ayland
2023-03-03  0:09 ` [PATCH v3 00/18] hw/ide: Untangle ISA/PCI abuses of ide_init_ioport() Michael S. Tsirkin
2023-03-03  6:58 ` David Woodhouse
2023-03-03  7:46   ` Mark Cave-Ayland
2023-03-03 12:50     ` Philippe Mathieu-Daudé
2023-03-03 12:57       ` BALATON Zoltan
2023-03-04 11:52     ` Bernhard Beschow
2023-03-03 12:47   ` BALATON Zoltan
2023-03-03 14:59   ` BALATON Zoltan
2023-04-21  8:25 ` Michael S. Tsirkin
2023-04-26 13:49   ` Mark Cave-Ayland
2023-04-22 15:25 ` Bernhard Beschow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230302224058.43315-14-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=balaton@eik.bme.hu \
    --cc=david@redhat.com \
    --cc=dwmw2@infradead.org \
    --cc=hpoussin@reactos.org \
    --cc=jsnow@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=shentey@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).