diff mbox

[RFC,v0,1/2] pc-dimm: Make pc_dimm_built_list() global

Message ID 1519022574-6817-2-git-send-email-bharata@linux.vnet.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bharata B Rao Feb. 19, 2018, 6:42 a.m. UTC
Making pc_dimm_built_list() global allows other parts of QEMU code
to build and walk through the DIMM list in address-sorted order.

This is needed in the next patch for sPAPR code to create
ibm,dynamic-memory-v2 device tree property that will have entries
for populated DIMMs as well as available hotpluggable areas.

CHECK: List of DIMMs is already available via qmp_pc_dimm_device_list(),
but that doesn't provide a sorted list.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
---
 hw/mem/pc-dimm.c         | 2 +-
 include/hw/mem/pc-dimm.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

Comments

Igor Mammedov Feb. 20, 2018, 2:35 p.m. UTC | #1
On Mon, 19 Feb 2018 12:12:53 +0530
Bharata B Rao <bharata@linux.vnet.ibm.com> wrote:

> Making pc_dimm_built_list() global allows other parts of QEMU code
> to build and walk through the DIMM list in address-sorted order.
> 
> This is needed in the next patch for sPAPR code to create
> ibm,dynamic-memory-v2 device tree property that will have entries
> for populated DIMMs as well as available hotpluggable areas.
> 
> CHECK: List of DIMMs is already available via qmp_pc_dimm_device_list(),
maybe make it sorted first and use it?

(i.e. use pc_dimm_built_list in qmp_pc_dimm_device_list) and hide
recursive callback ugliness from external users.

MemoryDeviceInfoList *qmp_pc_dimm_device_list(void) {
    object_child_foreach(qdev_get_machine(), pc_dimm_built_list, &list);
    ...
}

> but that doesn't provide a sorted list.
> 
> Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
> ---
>  hw/mem/pc-dimm.c         | 2 +-
>  include/hw/mem/pc-dimm.h | 1 +
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
> index 6e74b61..9bd61ca 100644
> --- a/hw/mem/pc-dimm.c
> +++ b/hw/mem/pc-dimm.c
> @@ -261,7 +261,7 @@ static gint pc_dimm_addr_sort(gconstpointer a, gconstpointer b)
>      return 0;
>  }
>  
> -static int pc_dimm_built_list(Object *obj, void *opaque)
> +int pc_dimm_built_list(Object *obj, void *opaque)
>  {
>      GSList **list = opaque;
>  
> diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h
> index d83b957..d880f5e 100644
> --- a/include/hw/mem/pc-dimm.h
> +++ b/include/hw/mem/pc-dimm.h
> @@ -100,4 +100,5 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
>                           MemoryRegion *mr, uint64_t align, Error **errp);
>  void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms,
>                             MemoryRegion *mr);
> +int pc_dimm_built_list(Object *obj, void *opaque);
>  #endif
Bharata B Rao Feb. 22, 2018, 5:52 a.m. UTC | #2
On Tue, Feb 20, 2018 at 03:35:10PM +0100, Igor Mammedov wrote:
> On Mon, 19 Feb 2018 12:12:53 +0530
> Bharata B Rao <bharata@linux.vnet.ibm.com> wrote:
> 
> > Making pc_dimm_built_list() global allows other parts of QEMU code
> > to build and walk through the DIMM list in address-sorted order.
> > 
> > This is needed in the next patch for sPAPR code to create
> > ibm,dynamic-memory-v2 device tree property that will have entries
> > for populated DIMMs as well as available hotpluggable areas.
> > 
> > CHECK: List of DIMMs is already available via qmp_pc_dimm_device_list(),
> maybe make it sorted first and use it?
> 
> (i.e. use pc_dimm_built_list in qmp_pc_dimm_device_list) and hide
> recursive callback ugliness from external users.
> 
> MemoryDeviceInfoList *qmp_pc_dimm_device_list(void) {
>     object_child_foreach(qdev_get_machine(), pc_dimm_built_list, &list);
>     ...
> }

Thanks will attempt this in my next version.

Regards,
Bharata.
diff mbox

Patch

diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index 6e74b61..9bd61ca 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -261,7 +261,7 @@  static gint pc_dimm_addr_sort(gconstpointer a, gconstpointer b)
     return 0;
 }
 
-static int pc_dimm_built_list(Object *obj, void *opaque)
+int pc_dimm_built_list(Object *obj, void *opaque)
 {
     GSList **list = opaque;
 
diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h
index d83b957..d880f5e 100644
--- a/include/hw/mem/pc-dimm.h
+++ b/include/hw/mem/pc-dimm.h
@@ -100,4 +100,5 @@  void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
                          MemoryRegion *mr, uint64_t align, Error **errp);
 void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms,
                            MemoryRegion *mr);
+int pc_dimm_built_list(Object *obj, void *opaque);
 #endif