qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>
Subject: [Qemu-devel] [PATCH 21/21] memory: give name to every AddressSpace
Date: Thu, 30 May 2013 23:17:09 +0200	[thread overview]
Message-ID: <1369948629-2833-22-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1369948629-2833-1-git-send-email-pbonzini@redhat.com>

From: Alexey Kardashevskiy <aik@ozlabs.ru>

The "info mtree" command in QEMU console prints only "memory" and "I/O"
address spaces while there are actually a lot more other AddressSpace
structs created by PCI and VIO devices. Those devices do not normally
have names and therefore not present in "info mtree" output.

The patch fixes this.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 exec.c                | 6 ++----
 hw/pci/pci.c          | 3 ++-
 hw/ppc/spapr_pci.c    | 4 +++-
 hw/ppc/spapr_vio.c    | 2 +-
 include/exec/memory.h | 6 ++++--
 memory.c              | 8 +++-----
 6 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/exec.c b/exec.c
index e58f842..8909478 100644
--- a/exec.c
+++ b/exec.c
@@ -1827,13 +1827,11 @@ static void memory_map_init(void)
 {
     system_memory = g_malloc(sizeof(*system_memory));
     memory_region_init(system_memory, "system", INT64_MAX);
-    address_space_init(&address_space_memory, system_memory);
-    address_space_memory.name = "memory";
+    address_space_init(&address_space_memory, system_memory, "memory");
 
     system_io = g_malloc(sizeof(*system_io));
     memory_region_init(system_io, "io", 65536);
-    address_space_init(&address_space_io, system_io);
-    address_space_io.name = "I/O";
+    address_space_init(&address_space_io, system_io, "I/O");
 
     memory_listener_register(&core_memory_listener, &address_space_memory);
     memory_listener_register(&io_memory_listener, &address_space_io);
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 2b1bc6d..fa30110 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -815,7 +815,8 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
     memory_region_init_alias(&pci_dev->bus_master_enable_region, "bus master",
                              dma_as->root, 0, memory_region_size(dma_as->root));
     memory_region_set_enabled(&pci_dev->bus_master_enable_region, false);
-    address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region);
+    address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region,
+                       name);
 
     pci_dev->devfn = devfn;
     pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 459398c..04e8362 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -650,7 +650,9 @@ static int spapr_phb_init(SysBusDevice *s)
         fprintf(stderr, "Unable to create TCE table for %s\n", sphb->dtbusname);
         return -1;
     }
-    address_space_init(&sphb->iommu_as, spapr_tce_get_iommu(sphb->tcet));
+    address_space_init(&sphb->iommu_as, spapr_tce_get_iommu(sphb->tcet),
+                       sphb->dtbusname);
+
     pci_setup_iommu(bus, spapr_pci_dma_iommu, sphb);
 
     QLIST_INSERT_HEAD(&spapr->phbs, sphb, list);
diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c
index 5e72f1b..3cfa326 100644
--- a/hw/ppc/spapr_vio.c
+++ b/hw/ppc/spapr_vio.c
@@ -458,7 +458,7 @@ static int spapr_vio_busdev_init(DeviceState *qdev)
     if (pc->rtce_window_size) {
         uint32_t liobn = SPAPR_VIO_BASE_LIOBN | dev->reg;
         dev->tcet = spapr_tce_new_table(liobn, pc->rtce_window_size);
-        address_space_init(&dev->as, spapr_tce_get_iommu(dev->tcet));
+        address_space_init(&dev->as, spapr_tce_get_iommu(dev->tcet), qdev->id);
     }
 
     return pc->init(dev);
diff --git a/include/exec/memory.h b/include/exec/memory.h
index c81acfd..a73adbe 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -192,7 +192,7 @@ struct MemoryRegionPortio {
  */
 struct AddressSpace {
     /* All fields are private. */
-    const char *name;
+    char *name;
     MemoryRegion *root;
     struct FlatView *current_map;
     int ioeventfd_nb;
@@ -892,8 +892,10 @@ void mtree_info(fprintf_function mon_printf, void *f);
  *
  * @as: an uninitialized #AddressSpace
  * @root: a #MemoryRegion that routes addesses for the address space
+ * @name: an address space name.  The name is only used for debugging
+ *        output.
  */
-void address_space_init(AddressSpace *as, MemoryRegion *root);
+void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name);
 
 
 /**
diff --git a/memory.c b/memory.c
index 802867d..363f8f2 100644
--- a/memory.c
+++ b/memory.c
@@ -1657,7 +1657,7 @@ void memory_listener_unregister(MemoryListener *listener)
     QTAILQ_REMOVE(&memory_listeners, listener, link);
 }
 
-void address_space_init(AddressSpace *as, MemoryRegion *root)
+void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name)
 {
     memory_region_transaction_begin();
     as->root = root;
@@ -1666,7 +1666,7 @@ void address_space_init(AddressSpace *as, MemoryRegion *root)
     as->ioeventfd_nb = 0;
     as->ioeventfds = NULL;
     QTAILQ_INSERT_TAIL(&address_spaces, as, address_spaces_link);
-    as->name = NULL;
+    as->name = g_strdup(name ? name : "anonymous");
     address_space_init_dispatch(as);
     memory_region_update_pending |= root->enabled;
     memory_region_transaction_commit();
@@ -1681,6 +1681,7 @@ void address_space_destroy(AddressSpace *as)
     QTAILQ_REMOVE(&address_spaces, as, address_spaces_link);
     address_space_destroy_dispatch(as);
     flatview_destroy(as->current_map);
+    g_free(as->name);
     g_free(as->current_map);
     g_free(as->ioeventfds);
 }
@@ -1807,9 +1808,6 @@ void mtree_info(fprintf_function mon_printf, void *f)
     QTAILQ_INIT(&ml_head);
 
     QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) {
-        if (!as->name) {
-            continue;
-        }
         mon_printf(f, "%s\n", as->name);
         mtree_print_mr(mon_printf, f, as->root, 0, 0, &ml_head);
     }
-- 
1.8.1.4

      parent reply	other threads:[~2013-05-30 21:18 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-30 21:16 [Qemu-devel] [PATCH 00/21] Memory/IOMMU patches, part 3: IOMMU implementation Paolo Bonzini
2013-05-30 21:16 ` [Qemu-devel] [PATCH 01/21] memory: Introduce address_space_lookup_region Paolo Bonzini
2013-05-31 21:56   ` Richard Henderson
2013-05-30 21:16 ` [Qemu-devel] [PATCH 02/21] memory: move private types to exec.c Paolo Bonzini
2013-05-31 21:57   ` Richard Henderson
2013-05-30 21:16 ` [Qemu-devel] [PATCH 03/21] exec: Allow unaligned address_space_rw Paolo Bonzini
2013-05-31 21:57   ` Richard Henderson
2013-05-30 21:16 ` [Qemu-devel] [PATCH 04/21] exec: Resolve subpages in one step except for IOTLB fills Paolo Bonzini
2013-05-31 21:58   ` Richard Henderson
2013-05-30 21:16 ` [Qemu-devel] [PATCH 05/21] exec: Implement subpage_read/write via address_space_rw Paolo Bonzini
2013-05-31 21:59   ` Richard Henderson
2013-05-30 21:16 ` [Qemu-devel] [PATCH 06/21] exec: return MemoryRegion from address_space_translate Paolo Bonzini
2013-05-31 22:00   ` Richard Henderson
2013-05-30 21:16 ` [Qemu-devel] [PATCH 07/21] Revert "memory: limit sections in the radix tree to the actual address space size" Paolo Bonzini
2013-05-31 22:04   ` Richard Henderson
2013-06-01  6:29     ` Paolo Bonzini
2013-05-30 21:16 ` [Qemu-devel] [PATCH 08/21] Revert "s390x: reduce TARGET_PHYS_ADDR_SPACE_BITS to 62" Paolo Bonzini
2013-05-30 21:16 ` [Qemu-devel] [PATCH 09/21] exec: reorganize mem_add to match Int128 version Paolo Bonzini
2013-05-31 22:42   ` Richard Henderson
2013-05-30 21:16 ` [Qemu-devel] [PATCH 10/21] memory: make section size a 128-bit integer Paolo Bonzini
2013-05-31  6:56   ` Alexey Kardashevskiy
2013-05-31  7:12     ` Paolo Bonzini
2013-05-31 22:18   ` Richard Henderson
2013-06-02 14:03     ` Paolo Bonzini
2013-06-02 14:18     ` Peter Maydell
2013-06-02 14:36       ` Paolo Bonzini
2013-06-02 14:50         ` Peter Maydell
2013-06-02 19:52           ` Paolo Bonzini
2013-06-06  8:36   ` Alexey Kardashevskiy
2013-06-07  1:09     ` Paolo Bonzini
2013-06-07  1:23       ` Alexey Kardashevskiy
2013-06-07  2:39         ` Paolo Bonzini
2013-05-30 21:16 ` [Qemu-devel] [PATCH 11/21] memory: iommu support Paolo Bonzini
2013-05-31 22:54   ` Richard Henderson
2013-05-30 21:17 ` [Qemu-devel] [PATCH 12/21] memory: Add iommu map/unmap notifiers Paolo Bonzini
2013-05-31 22:56   ` Richard Henderson
2013-05-30 21:17 ` [Qemu-devel] [PATCH 13/21] vfio: abort if an emulated iommu is used Paolo Bonzini
2013-05-31 22:57   ` Richard Henderson
2013-05-30 21:17 ` [Qemu-devel] [PATCH 14/21] spapr: convert TCE API to use an opaque type Paolo Bonzini
2013-05-30 21:17 ` [Qemu-devel] [PATCH 15/21] spapr: make IOMMU translation go through IOMMUTLBEntry Paolo Bonzini
2013-05-30 21:17 ` [Qemu-devel] [PATCH 16/21] spapr: use memory core for iommu support Paolo Bonzini
2013-05-30 21:17 ` [Qemu-devel] [PATCH 17/21] dma: eliminate old-style IOMMU support Paolo Bonzini
2013-05-30 21:17 ` [Qemu-devel] [PATCH 18/21] pci: use memory core for iommu support Paolo Bonzini
2013-05-30 21:17 ` [Qemu-devel] [PATCH 19/21] spapr_vio: take care of creating our own AddressSpace/DMAContext Paolo Bonzini
2013-05-30 21:17 ` [Qemu-devel] [PATCH 20/21] dma: eliminate DMAContext Paolo Bonzini
2013-05-30 21:17 ` Paolo Bonzini [this message]

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=1369948629-2833-22-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=aik@ozlabs.ru \
    --cc=qemu-devel@nongnu.org \
    /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).