Skip to contentSkip to conversation

hmat acpi: Build System Locality Latency and Bandwidth Information Structure(s) in ACPI HMAT

PATCH Superseded Liu Jingqi 1 participant 1 message May 9, 2018

lore
Share & tools
lore

Liu Jingqi

author
#0 lore raw

PATCH 2/7 hmat acpi: Build System Locality Latency and Bandwidth Information Structure(s) in ACPI HMAT

This structure describes the memory access latency and bandwidth information from various memory access initiator proximity domains. The latency and bandwidth numbers represented in this structure correspond to rated latency and bandwidth for the platform. The software could use this information as hint for optimization.

---
 hw/acpi/hmat.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/acpi/hmat.h | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 151 insertions(+), 1 deletion(-)
hw/acpi/hmat.c +75 -0
index bca1fbb..00dfba9 100644
@@ -36,6 +36,7 @@
 #define HOLE_640K_START  (640 * 1024)
 #define HOLE_640K_END    (1024 * 1024)
 
+struct numa_hmat_lb_info *hmat_lb_info[HMAT_LB_LEVELS][HMAT_LB_TYPES] = {0};
 uint32_t initiator_pxm[MAX_NODES], target_pxm[MAX_NODES];
 uint32_t num_initiator = 0, num_target = 0;
 
@@ -150,10 +151,84 @@ static void hmat_build_spa(GArray *table_data, PCMachineState *pcms)
     }
 }
 
+static void hmat_build_lb(GArray *table_data)
+{
+    AcpiHmatLBInfo *hmat_lb;
+    struct numa_hmat_lb_info *numa_hmat_lb;
+    int i, j, hrchy, type;
+
+    for (hrchy = HMAT_LB_MEM_MEMORY;
+         hrchy <= HMAT_LB_MEM_CACHE_3RD_LEVEL; hrchy++) {
+        for (type = HMAT_LB_DATA_ACCESS_LATENCY;
+             type <= HMAT_LB_DATA_WRITE_BANDWIDTH; type++) {
+            numa_hmat_lb = hmat_lb_info[hrchy][type];
+
+            if (numa_hmat_lb) {
+                uint64_t start;
+                uint32_t *list_entry;
+                uint16_t *entry, *entry_start;
+                uint32_t size;
+                uint8_t m, n;
+
+                start = table_data->len;
+                hmat_lb = acpi_data_push(table_data, sizeof(*hmat_lb));
+
+                hmat_lb->type          = ACPI_HMAT_LB_INFO;
+                hmat_lb->flags         = numa_hmat_lb->hierarchy;
+                hmat_lb->data_type     = numa_hmat_lb->data_type;
+                hmat_lb->num_initiator = num_initiator;
+                hmat_lb->num_target    = num_target;
+
+                if (type <= HMAT_LB_DATA_WRITE_LATENCY) {
+                    hmat_lb->base_unit = numa_hmat_lb->base_lat;
+                } else {
+                    hmat_lb->base_unit = numa_hmat_lb->base_bw;
+                }
+                if (!hmat_lb->base_unit) {
+                    hmat_lb->base_unit = 1;
+                }
+
+                /* the initiator proximity domain list */
+                size = sizeof(*list_entry) * num_initiator;
+                list_entry = acpi_data_push(table_data, size);
+                memcpy(list_entry, initiator_pxm, size);
+
+                /* the target proximity domain list */
+                size = sizeof(*list_entry) * num_target;
+                list_entry = acpi_data_push(table_data, size);
+                memcpy(list_entry, target_pxm, size);
+
+                /* latency or bandwidth entries */
+                size = sizeof(uint16_t) * num_initiator * num_target;
+                entry_start = acpi_data_push(table_data, size);
+
+                for (i = 0; i < num_initiator; i++) {
+                    m = initiator_pxm[i];
+                    for (j = 0; j < num_target; j++) {
+                        n = target_pxm[j];
+                        entry = entry_start + i * num_target + j;
+                        if (type <= HMAT_LB_DATA_WRITE_LATENCY) {
+                            *entry = numa_hmat_lb->latency[m][n];
+                        } else {
+                            *entry = numa_hmat_lb->bandwidth[m][n];
+                        }
+                    }
+                }
+
+                hmat_lb = (AcpiHmatLBInfo *)(table_data->data + start);
+                hmat_lb->length = table_data->len - start;
+            }
+        }
+    }
+}
+
 static void hmat_build_hma(GArray *hma, PCMachineState *pcms)
 {
     /* Build HMAT Memory Subsystem Address Range. */
     hmat_build_spa(hma, pcms);
+
+    /* Build HMAT System Locality Latency and Bandwidth Information. */
+    hmat_build_lb(hma);
 }
 
 void hmat_build_acpi(GArray *table_data, BIOSLinker *linker,
hw/acpi/hmat.h +76 -1

97 lines not on this page · raw message

Signature · 1 line
2.7.4