diff mbox series

[v3,15/22] hw/acpi-build: only indicate nvdimm and pc-dimm

Message ID 20180920103243.28474-16-david@redhat.com
State New
Headers show
Series memory-device: complete refactoring + virtio-pmem | expand

Commit Message

David Hildenbrand Sept. 20, 2018, 10:32 a.m. UTC
Once we have other memory devices that are not ACPI devices (e.g.
virtio based), we cannot indicate them via ACPI. So let's skip these
devices.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 hw/i386/acpi-build.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

Comments

Igor Mammedov Sept. 24, 2018, 2:22 p.m. UTC | #1
On Thu, 20 Sep 2018 12:32:36 +0200
David Hildenbrand <david@redhat.com> wrote:

> Once we have other memory devices that are not ACPI devices (e.g.
> virtio based), we cannot indicate them via ACPI. So let's skip these
> devices.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>
dimm specific entries in SRAT will be removed so this patch is not needed
(http://patchwork.ozlabs.org/patch/967512/)

> ---
>  hw/i386/acpi-build.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index e1ee8ae9e0..2278522b87 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -2266,7 +2266,6 @@ static void build_srat_hotpluggable_memory(GArray *table_data, uint64_t base,
>      for (cur = base, info = info_list;
>           cur < end;
>           cur += size, info = info->next) {
> -        numamem = acpi_data_push(table_data, sizeof *numamem);
>  
>          if (!info) {
>              /*
> @@ -2278,19 +2277,30 @@ static void build_srat_hotpluggable_memory(GArray *table_data, uint64_t base,
>               * Memory devices may override proximity set by this entry,
>               * providing _PXM method if necessary.
>               */
> +            numamem = acpi_data_push(table_data, sizeof *numamem);
>              build_srat_memory(numamem, end - 1, 1, default_node,
>                                MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED);
>              break;
>          }
>  
>          mi = info->value;
> +        if (mi->type != MEMORY_DEVICE_INFO_KIND_DIMM &&
> +            mi->type != MEMORY_DEVICE_INFO_KIND_NVDIMM) {
> +            /*
> +             * Don't indicate memory devices that are not proper ACPI devices,
> +             * merge them with the empty ranges.
> +             */
> +            size = 0;
> +            continue;
> +        }
> +
>          is_nvdimm = (mi->type == MEMORY_DEVICE_INFO_KIND_NVDIMM);
>          di = !is_nvdimm ? mi->u.dimm.data : mi->u.nvdimm.data;
>  
>          if (cur < di->addr) {
> +            numamem = acpi_data_push(table_data, sizeof *numamem);
>              build_srat_memory(numamem, cur, di->addr - cur, default_node,
>                                MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED);
> -            numamem = acpi_data_push(table_data, sizeof *numamem);
>          }
>  
>          size = di->size;
> @@ -2303,6 +2313,7 @@ static void build_srat_hotpluggable_memory(GArray *table_data, uint64_t base,
>              flags |= MEM_AFFINITY_NON_VOLATILE;
>          }
>  
> +        numamem = acpi_data_push(table_data, sizeof *numamem);
>          build_srat_memory(numamem, di->addr, size, di->node, flags);
>      }
>
David Hildenbrand Sept. 25, 2018, 8 p.m. UTC | #2
On 24/09/2018 16:22, Igor Mammedov wrote:
> On Thu, 20 Sep 2018 12:32:36 +0200
> David Hildenbrand <david@redhat.com> wrote:
> 
>> Once we have other memory devices that are not ACPI devices (e.g.
>> virtio based), we cannot indicate them via ACPI. So let's skip these
>> devices.
>>
>> Signed-off-by: David Hildenbrand <david@redhat.com>
> dimm specific entries in SRAT will be removed so this patch is not needed
> (http://patchwork.ozlabs.org/patch/967512/)

Indeed, even better - dropped this patch while rebasing.
diff mbox series

Patch

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index e1ee8ae9e0..2278522b87 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -2266,7 +2266,6 @@  static void build_srat_hotpluggable_memory(GArray *table_data, uint64_t base,
     for (cur = base, info = info_list;
          cur < end;
          cur += size, info = info->next) {
-        numamem = acpi_data_push(table_data, sizeof *numamem);
 
         if (!info) {
             /*
@@ -2278,19 +2277,30 @@  static void build_srat_hotpluggable_memory(GArray *table_data, uint64_t base,
              * Memory devices may override proximity set by this entry,
              * providing _PXM method if necessary.
              */
+            numamem = acpi_data_push(table_data, sizeof *numamem);
             build_srat_memory(numamem, end - 1, 1, default_node,
                               MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED);
             break;
         }
 
         mi = info->value;
+        if (mi->type != MEMORY_DEVICE_INFO_KIND_DIMM &&
+            mi->type != MEMORY_DEVICE_INFO_KIND_NVDIMM) {
+            /*
+             * Don't indicate memory devices that are not proper ACPI devices,
+             * merge them with the empty ranges.
+             */
+            size = 0;
+            continue;
+        }
+
         is_nvdimm = (mi->type == MEMORY_DEVICE_INFO_KIND_NVDIMM);
         di = !is_nvdimm ? mi->u.dimm.data : mi->u.nvdimm.data;
 
         if (cur < di->addr) {
+            numamem = acpi_data_push(table_data, sizeof *numamem);
             build_srat_memory(numamem, cur, di->addr - cur, default_node,
                               MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED);
-            numamem = acpi_data_push(table_data, sizeof *numamem);
         }
 
         size = di->size;
@@ -2303,6 +2313,7 @@  static void build_srat_hotpluggable_memory(GArray *table_data, uint64_t base,
             flags |= MEM_AFFINITY_NON_VOLATILE;
         }
 
+        numamem = acpi_data_push(table_data, sizeof *numamem);
         build_srat_memory(numamem, di->addr, size, di->node, flags);
     }