All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: fanhuang <FangSheng.Huang@amd.com>
Cc: <qemu-devel@nongnu.org>, <david@kernel.org>, <mst@redhat.com>,
	<gourry@gourry.net>, <philmd@mailo.com>, <peterx@redhat.com>,
	<Zhigang.Luo@amd.com>, <Lianjie.Shi@amd.com>
Subject: Re: [PATCH v13 02/10] qapi, hmp: introspection for the sp-mem device
Date: Mon, 22 Jun 2026 14:52:09 +0200	[thread overview]
Message-ID: <20260622145209.35cc66b8@imammedo> (raw)
In-Reply-To: <20260619111136.3481329-3-FangSheng.Huang@amd.com>

On Fri, 19 Jun 2026 19:11:28 +0800
fanhuang <FangSheng.Huang@amd.com> wrote:

> Add a SpMemDeviceInfo variant to MemoryDeviceInfo so `query-memory-devices`
> reports each sp-mem instance (id, addr, size, node, memdev), and print it
> from HMP `info memory-devices`.
> 
> Signed-off-by: FangSheng Huang <FangSheng.Huang@amd.com>

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  qapi/machine.json          | 43 ++++++++++++++++++++++++++++++++++++--
>  hw/core/machine-hmp-cmds.c | 11 ++++++++++
>  hw/mem/sp-mem.c            | 19 +++++++++++++++++
>  3 files changed, 71 insertions(+), 2 deletions(-)
> 
> diff --git a/qapi/machine.json b/qapi/machine.json
> index 685e4e29b8..777cfc81e1 100644
> --- a/qapi/machine.json
> +++ b/qapi/machine.json
> @@ -1413,6 +1413,32 @@
>            }
>  }
>  
> +##
> +# @SpMemDeviceInfo:
> +#
> +# sp-mem device state information
> +#
> +# @id: device's ID
> +#
> +# @addr: physical address, where device is mapped
> +#
> +# @size: size of memory that the device provides
> +#
> +# @node: NUMA proximity domain to which the device is assigned
> +#
> +# @memdev: memory backend linked with device
> +#
> +# Since: 11.1
> +##
> +{ 'struct': 'SpMemDeviceInfo',
> +  'data': { '*id': 'str',
> +            'addr': 'size',
> +            'size': 'size',
> +            'node': 'int',
> +            'memdev': 'str'
> +          }
> +}
> +
>  ##
>  # @MemoryDeviceInfoKind:
>  #
> @@ -1426,11 +1452,13 @@
>  #
>  # @hv-balloon: since 8.2.
>  #
> +# @sp-mem: since 11.1.
> +#
>  # Since: 2.1
>  ##
>  { 'enum': 'MemoryDeviceInfoKind',
>    'data': [ 'dimm', 'nvdimm', 'virtio-pmem', 'virtio-mem', 'sgx-epc',
> -            'hv-balloon' ] }
> +            'hv-balloon', 'sp-mem' ] }
>  
>  ##
>  # @PCDIMMDeviceInfoWrapper:
> @@ -1482,6 +1510,16 @@
>  { 'struct': 'HvBalloonDeviceInfoWrapper',
>    'data': { 'data': 'HvBalloonDeviceInfo' } }
>  
> +##
> +# @SpMemDeviceInfoWrapper:
> +#
> +# @data: sp-mem device state information
> +#
> +# Since: 11.1
> +##
> +{ 'struct': 'SpMemDeviceInfoWrapper',
> +  'data': { 'data': 'SpMemDeviceInfo' } }
> +
>  ##
>  # @MemoryDeviceInfo:
>  #
> @@ -1499,7 +1537,8 @@
>              'virtio-pmem': 'VirtioPMEMDeviceInfoWrapper',
>              'virtio-mem': 'VirtioMEMDeviceInfoWrapper',
>              'sgx-epc': 'SgxEPCDeviceInfoWrapper',
> -            'hv-balloon': 'HvBalloonDeviceInfoWrapper'
> +            'hv-balloon': 'HvBalloonDeviceInfoWrapper',
> +            'sp-mem': 'SpMemDeviceInfoWrapper'
>            }
>  }
>  
> diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c
> index 46846f741a..686304bafa 100644
> --- a/hw/core/machine-hmp-cmds.c
> +++ b/hw/core/machine-hmp-cmds.c
> @@ -279,6 +279,7 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
>      PCDIMMDeviceInfo *di;
>      SgxEPCDeviceInfo *se;
>      HvBalloonDeviceInfo *hi;
> +    SpMemDeviceInfo *spmi;
>  
>      for (info = info_list; info; info = info->next) {
>          value = info->value;
> @@ -350,6 +351,16 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
>                      monitor_printf(mon, "  memdev: %s\n", hi->memdev);
>                  }
>                  break;
> +            case MEMORY_DEVICE_INFO_KIND_SP_MEM:
> +                spmi = value->u.sp_mem.data;
> +                monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
> +                               MemoryDeviceInfoKind_str(value->type),
> +                               spmi->id ? spmi->id : "");
> +                monitor_printf(mon, "  addr: 0x%" PRIx64 "\n", spmi->addr);
> +                monitor_printf(mon, "  node: %" PRId64 "\n", spmi->node);
> +                monitor_printf(mon, "  size: %" PRIu64 "\n", spmi->size);
> +                monitor_printf(mon, "  memdev: %s\n", spmi->memdev);
> +                break;
>              default:
>                  g_assert_not_reached();
>              }
> diff --git a/hw/mem/sp-mem.c b/hw/mem/sp-mem.c
> index d088222f54..962d0f937e 100644
> --- a/hw/mem/sp-mem.c
> +++ b/hw/mem/sp-mem.c
> @@ -53,6 +53,24 @@ static MemoryRegion *sp_mem_get_memory_region(MemoryDeviceState *md,
>      return host_memory_backend_get_memory(spm->hostmem);
>  }
>  
> +static void sp_mem_fill_device_info(const MemoryDeviceState *md,
> +                                    MemoryDeviceInfo *info)
> +{
> +    SpMemDeviceInfo *di = g_new0(SpMemDeviceInfo, 1);
> +    SpMemDevice *spm = SP_MEM(md);
> +    DeviceState *dev = DEVICE(md);
> +
> +    di->id = dev->id ? g_strdup(dev->id) : NULL;
> +    di->addr = spm->addr;
> +    di->size = memory_region_size(
> +                   host_memory_backend_get_memory(spm->hostmem));
> +    di->node = spm->node;
> +    di->memdev = object_get_canonical_path(OBJECT(spm->hostmem));
> +
> +    info->u.sp_mem.data = di;
> +    info->type = MEMORY_DEVICE_INFO_KIND_SP_MEM;
> +}
> +
>  static void sp_mem_realize(DeviceState *dev, Error **errp)
>  {
>      SpMemDevice *spm = SP_MEM(dev);
> @@ -91,6 +109,7 @@ static void sp_mem_class_init(ObjectClass *oc, const void *data)
>      mdc->set_addr            = sp_mem_set_addr;
>      mdc->get_memory_region   = sp_mem_get_memory_region;
>      mdc->get_plugged_size    = memory_device_get_region_size;
> +    mdc->fill_device_info    = sp_mem_fill_device_info;
>  }
>  
>  static const TypeInfo sp_mem_types[] = {



  reply	other threads:[~2026-06-22 12:52 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-19 11:11 [PATCH v13 00/10] hw/mem: add sp-mem device for Specific Purpose Memory fanhuang
2026-06-19 11:11 ` [PATCH v13 01/10] " fanhuang
2026-06-22 12:49   ` Igor Mammedov
2026-06-19 11:11 ` [PATCH v13 02/10] qapi, hmp: introspection for the sp-mem device fanhuang
2026-06-22 12:52   ` Igor Mammedov [this message]
2026-06-22 12:55   ` Daniel P. Berrangé
2026-06-22 13:07     ` Igor Mammedov
2026-06-22 13:22       ` Daniel P. Berrangé
2026-06-19 11:11 ` [PATCH v13 03/10] i386/acpi-build: partition device_memory SRAT umbrella for sp-mem fanhuang
2026-06-19 11:11 ` [PATCH v13 04/10] hw/i386: hook sp-mem into the pc machine plug path fanhuang
2026-06-22 12:44   ` Igor Mammedov
2026-06-19 11:11 ` [PATCH v13 05/10] MAINTAINERS: cover sp-mem under Memory devices, add R: tag fanhuang
2026-06-19 11:11 ` [PATCH v13 06/10] tests/acpi: add empty expected blobs for sp-mem SRAT test fanhuang
2026-06-22 12:53   ` Igor Mammedov
2026-06-19 11:11 ` [PATCH v13 07/10] tests/acpi: add bios-tables-test case for sp-mem fanhuang
2026-06-22 13:00   ` Igor Mammedov
2026-06-19 11:11 ` [PATCH v13 08/10] tests/acpi: generate expected blobs for sp-mem SRAT test fanhuang
2026-06-22 13:09   ` Igor Mammedov
2026-06-19 11:11 ` [PATCH v13 09/10] tests/qtest: add e820 fw_cfg test fanhuang
2026-06-22 14:09   ` Igor Mammedov
2026-06-19 11:11 ` [PATCH v13 10/10] tests/qtest: cover sp-mem SOFT_RESERVED e820 entry fanhuang
2026-06-22 14:09   ` Igor Mammedov

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=20260622145209.35cc66b8@imammedo \
    --to=imammedo@redhat.com \
    --cc=FangSheng.Huang@amd.com \
    --cc=Lianjie.Shi@amd.com \
    --cc=Zhigang.Luo@amd.com \
    --cc=david@kernel.org \
    --cc=gourry@gourry.net \
    --cc=mst@redhat.com \
    --cc=peterx@redhat.com \
    --cc=philmd@mailo.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.