qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] memory: could we add extra input param for memory_region_init_io()?
@ 2012-08-14  8:30 liu ping fan
  2012-08-14 10:49 ` Avi Kivity
  0 siblings, 1 reply; 19+ messages in thread
From: liu ping fan @ 2012-08-14  8:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Avi Kivity, Anthony Liguori

To make memoryRegion survive without the protection of qemu big lock,
we need to pin its based Object.
In current code, the type of mr->opaque are quite different.  Lots of
them are Object, but quite of them are not yet.

The most challenge for changing from memory_region_init_io(..., void
*opaque, ...) to memory_region_init_io(..., Object *opaque,...) is
such codes:
hw/ide/cmd646.c:
static void setup_cmd646_bar(PCIIDEState *d, int bus_num)
{
    IDEBus *bus = &d->bus[bus_num];
    CMD646BAR *bar = &d->cmd646_bar[bus_num];

    bar->bus = bus;
    bar->pci_dev = d;
    memory_region_init_io(&bar->cmd, &cmd646_cmd_ops, bar, "cmd646-cmd", 4);
    memory_region_init_io(&bar->data, &cmd646_data_ops, bar, "cmd646-data", 8);
}
If we passed in mr's based Object @d to substitute @bar, then we can
not pass the extra info @bus_num.

To solve such issue, introduce extra member "Object *base" for MemoryRegion.

diff --git a/memory.c b/memory.c
index 643871b..afd5dea 100644
--- a/memory.c
+++ b/memory.c
@@ -931,6 +931,7 @@ static void memory_region_dispatch_write(MemoryRegion *mr,

 void memory_region_init_io(MemoryRegion *mr,
                            const MemoryRegionOps *ops,
+                           Object *base,
                            void *opaque,
                            const char *name,
                            uint64_t size)
@@ -938,6 +939,7 @@ void memory_region_init_io(MemoryRegion *mr,
     memory_region_init(mr, name, size);
     mr->ops = ops;
     mr->opaque = opaque;
+    mr->base = base;
     mr->terminates = true;
     mr->destructor = memory_region_destructor_iomem;
     mr->ram_addr = ~(ram_addr_t)0;
diff --git a/memory.h b/memory.h
index bd1bbae..2746e70 100644
--- a/memory.h
+++ b/memory.h
@@ -120,6 +120,7 @@ struct MemoryRegion {
     /* All fields are private - violators will be prosecuted */
     const MemoryRegionOps *ops;
     void *opaque;
+    Object *base;
     MemoryRegion *parent;
     Int128 size;
     target_phys_addr_t addr;


Any comment?

Thanks,
pingfan

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2012-08-24  9:48 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-14  8:30 [Qemu-devel] memory: could we add extra input param for memory_region_init_io()? liu ping fan
2012-08-14 10:49 ` Avi Kivity
2012-08-16  3:22   ` liu ping fan
2012-08-16  9:23     ` Avi Kivity
2012-08-17  2:52       ` liu ping fan
2012-08-17  7:41         ` liu ping fan
2012-08-19 10:12           ` Avi Kivity
2012-08-19 11:23             ` Peter Maydell
2012-08-19 11:36               ` Avi Kivity
2012-08-21  4:48                 ` liu ping fan
2012-08-21  8:57                   ` Avi Kivity
2012-08-21  9:25                     ` liu ping fan
2012-08-21 10:13                       ` Avi Kivity
2012-08-21 11:18                         ` liu ping fan
2012-08-21 12:41                           ` Avi Kivity
2012-08-24  9:47                             ` liu ping fan
2012-08-19 12:03               ` Peter Maydell
2012-08-19 13:05                 ` Blue Swirl
2012-08-19 10:10         ` Avi Kivity

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).