|
|
ddf19c |
From f55b8b251c323856087baf2380d93fbf2da15db7 Mon Sep 17 00:00:00 2001
|
|
|
ddf19c |
From: "plai@redhat.com" <plai@redhat.com>
|
|
|
ddf19c |
Date: Thu, 21 May 2020 23:56:51 +0100
|
|
|
ddf19c |
Subject: [PATCH 08/12] hmat acpi: Build System Locality Latency and Bandwidth
|
|
|
ddf19c |
Information Structure(s)
|
|
|
ddf19c |
|
|
|
ddf19c |
RH-Author: plai@redhat.com
|
|
|
ddf19c |
Message-id: <20200521235655.27141-8-plai@redhat.com>
|
|
|
ddf19c |
Patchwork-id: 96733
|
|
|
ddf19c |
O-Subject: [RHEL8.2.1 AV qemu-kvm PATCH 07/11] hmat acpi: Build System Locality Latency and Bandwidth Information Structure(s)
|
|
|
ddf19c |
Bugzilla: 1600217
|
|
|
ddf19c |
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
ddf19c |
|
|
|
ddf19c |
From: Liu Jingqi <jingqi.liu@intel.com>
|
|
|
ddf19c |
|
|
|
ddf19c |
This structure describes the memory access latency and bandwidth
|
|
|
ddf19c |
information from various memory access initiator proximity domains.
|
|
|
ddf19c |
The latency and bandwidth numbers represented in this structure
|
|
|
ddf19c |
correspond to rated latency and bandwidth for the platform.
|
|
|
ddf19c |
The software could use this information as hint for optimization.
|
|
|
ddf19c |
|
|
|
ddf19c |
Acked-by: Markus Armbruster <armbru@redhat.com>
|
|
|
ddf19c |
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
ddf19c |
Signed-off-by: Liu Jingqi <jingqi.liu@intel.com>
|
|
|
ddf19c |
Signed-off-by: Tao Xu <tao3.xu@intel.com>
|
|
|
ddf19c |
Message-Id: <20191213011929.2520-6-tao3.xu@intel.com>
|
|
|
ddf19c |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
ddf19c |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
ddf19c |
(cherry picked from commit 4586a2cb833f80b19c80ebe364a005ac2fa0974a)
|
|
|
ddf19c |
Signed-off-by: Paul Lai <plai@redhat.com>
|
|
|
ddf19c |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
ddf19c |
---
|
|
|
ddf19c |
hw/acpi/hmat.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
|
|
|
ddf19c |
1 file changed, 103 insertions(+), 1 deletion(-)
|
|
|
ddf19c |
|
|
|
ddf19c |
diff --git a/hw/acpi/hmat.c b/hw/acpi/hmat.c
|
|
|
ddf19c |
index 9ff7930..4635d45 100644
|
|
|
ddf19c |
--- a/hw/acpi/hmat.c
|
|
|
ddf19c |
+++ b/hw/acpi/hmat.c
|
|
|
ddf19c |
@@ -25,6 +25,7 @@
|
|
|
ddf19c |
*/
|
|
|
ddf19c |
|
|
|
ddf19c |
#include "qemu/osdep.h"
|
|
|
ddf19c |
+#include "qemu/units.h"
|
|
|
ddf19c |
#include "sysemu/numa.h"
|
|
|
ddf19c |
#include "hw/acpi/hmat.h"
|
|
|
ddf19c |
|
|
|
ddf19c |
@@ -67,11 +68,89 @@ static void build_hmat_mpda(GArray *table_data, uint16_t flags,
|
|
|
ddf19c |
build_append_int_noprefix(table_data, 0, 8);
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
+/*
|
|
|
ddf19c |
+ * ACPI 6.3: 5.2.27.4 System Locality Latency and Bandwidth Information
|
|
|
ddf19c |
+ * Structure: Table 5-146
|
|
|
ddf19c |
+ */
|
|
|
ddf19c |
+static void build_hmat_lb(GArray *table_data, HMAT_LB_Info *hmat_lb,
|
|
|
ddf19c |
+ uint32_t num_initiator, uint32_t num_target,
|
|
|
ddf19c |
+ uint32_t *initiator_list)
|
|
|
ddf19c |
+{
|
|
|
ddf19c |
+ int i, index;
|
|
|
ddf19c |
+ HMAT_LB_Data *lb_data;
|
|
|
ddf19c |
+ uint16_t *entry_list;
|
|
|
ddf19c |
+ uint32_t base;
|
|
|
ddf19c |
+ /* Length in bytes for entire structure */
|
|
|
ddf19c |
+ uint32_t lb_length
|
|
|
ddf19c |
+ = 32 /* Table length upto and including Entry Base Unit */
|
|
|
ddf19c |
+ + 4 * num_initiator /* Initiator Proximity Domain List */
|
|
|
ddf19c |
+ + 4 * num_target /* Target Proximity Domain List */
|
|
|
ddf19c |
+ + 2 * num_initiator * num_target; /* Latency or Bandwidth Entries */
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ /* Type */
|
|
|
ddf19c |
+ build_append_int_noprefix(table_data, 1, 2);
|
|
|
ddf19c |
+ /* Reserved */
|
|
|
ddf19c |
+ build_append_int_noprefix(table_data, 0, 2);
|
|
|
ddf19c |
+ /* Length */
|
|
|
ddf19c |
+ build_append_int_noprefix(table_data, lb_length, 4);
|
|
|
ddf19c |
+ /* Flags: Bits [3:0] Memory Hierarchy, Bits[7:4] Reserved */
|
|
|
ddf19c |
+ assert(!(hmat_lb->hierarchy >> 4));
|
|
|
ddf19c |
+ build_append_int_noprefix(table_data, hmat_lb->hierarchy, 1);
|
|
|
ddf19c |
+ /* Data Type */
|
|
|
ddf19c |
+ build_append_int_noprefix(table_data, hmat_lb->data_type, 1);
|
|
|
ddf19c |
+ /* Reserved */
|
|
|
ddf19c |
+ build_append_int_noprefix(table_data, 0, 2);
|
|
|
ddf19c |
+ /* Number of Initiator Proximity Domains (s) */
|
|
|
ddf19c |
+ build_append_int_noprefix(table_data, num_initiator, 4);
|
|
|
ddf19c |
+ /* Number of Target Proximity Domains (t) */
|
|
|
ddf19c |
+ build_append_int_noprefix(table_data, num_target, 4);
|
|
|
ddf19c |
+ /* Reserved */
|
|
|
ddf19c |
+ build_append_int_noprefix(table_data, 0, 4);
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ /* Entry Base Unit */
|
|
|
ddf19c |
+ if (hmat_lb->data_type <= HMAT_LB_DATA_WRITE_LATENCY) {
|
|
|
ddf19c |
+ /* Convert latency base from nanoseconds to picosecond */
|
|
|
ddf19c |
+ base = hmat_lb->base * 1000;
|
|
|
ddf19c |
+ } else {
|
|
|
ddf19c |
+ /* Convert bandwidth base from Byte to Megabyte */
|
|
|
ddf19c |
+ base = hmat_lb->base / MiB;
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+ build_append_int_noprefix(table_data, base, 8);
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ /* Initiator Proximity Domain List */
|
|
|
ddf19c |
+ for (i = 0; i < num_initiator; i++) {
|
|
|
ddf19c |
+ build_append_int_noprefix(table_data, initiator_list[i], 4);
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ /* Target Proximity Domain List */
|
|
|
ddf19c |
+ for (i = 0; i < num_target; i++) {
|
|
|
ddf19c |
+ build_append_int_noprefix(table_data, i, 4);
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ /* Latency or Bandwidth Entries */
|
|
|
ddf19c |
+ entry_list = g_malloc0(num_initiator * num_target * sizeof(uint16_t));
|
|
|
ddf19c |
+ for (i = 0; i < hmat_lb->list->len; i++) {
|
|
|
ddf19c |
+ lb_data = &g_array_index(hmat_lb->list, HMAT_LB_Data, i);
|
|
|
ddf19c |
+ index = lb_data->initiator * num_target + lb_data->target;
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ entry_list[index] = (uint16_t)(lb_data->data / hmat_lb->base);
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ for (i = 0; i < num_initiator * num_target; i++) {
|
|
|
ddf19c |
+ build_append_int_noprefix(table_data, entry_list[i], 2);
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ g_free(entry_list);
|
|
|
ddf19c |
+}
|
|
|
ddf19c |
+
|
|
|
ddf19c |
/* Build HMAT sub table structures */
|
|
|
ddf19c |
static void hmat_build_table_structs(GArray *table_data, NumaState *numa_state)
|
|
|
ddf19c |
{
|
|
|
ddf19c |
uint16_t flags;
|
|
|
ddf19c |
- int i;
|
|
|
ddf19c |
+ uint32_t num_initiator = 0;
|
|
|
ddf19c |
+ uint32_t initiator_list[MAX_NODES];
|
|
|
ddf19c |
+ int i, hierarchy, type;
|
|
|
ddf19c |
+ HMAT_LB_Info *hmat_lb;
|
|
|
ddf19c |
|
|
|
ddf19c |
for (i = 0; i < numa_state->num_nodes; i++) {
|
|
|
ddf19c |
flags = 0;
|
|
|
ddf19c |
@@ -82,6 +161,29 @@ static void hmat_build_table_structs(GArray *table_data, NumaState *numa_state)
|
|
|
ddf19c |
|
|
|
ddf19c |
build_hmat_mpda(table_data, flags, numa_state->nodes[i].initiator, i);
|
|
|
ddf19c |
}
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ for (i = 0; i < numa_state->num_nodes; i++) {
|
|
|
ddf19c |
+ if (numa_state->nodes[i].has_cpu) {
|
|
|
ddf19c |
+ initiator_list[num_initiator++] = i;
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ /*
|
|
|
ddf19c |
+ * ACPI 6.3: 5.2.27.4 System Locality Latency and Bandwidth Information
|
|
|
ddf19c |
+ * Structure: Table 5-146
|
|
|
ddf19c |
+ */
|
|
|
ddf19c |
+ for (hierarchy = HMAT_LB_MEM_MEMORY;
|
|
|
ddf19c |
+ hierarchy <= HMAT_LB_MEM_CACHE_3RD_LEVEL; hierarchy++) {
|
|
|
ddf19c |
+ for (type = HMAT_LB_DATA_ACCESS_LATENCY;
|
|
|
ddf19c |
+ type <= HMAT_LB_DATA_WRITE_BANDWIDTH; type++) {
|
|
|
ddf19c |
+ hmat_lb = numa_state->hmat_lb[hierarchy][type];
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ if (hmat_lb && hmat_lb->list->len) {
|
|
|
ddf19c |
+ build_hmat_lb(table_data, hmat_lb, num_initiator,
|
|
|
ddf19c |
+ numa_state->num_nodes, initiator_list);
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
void build_hmat(GArray *table_data, BIOSLinker *linker, NumaState *numa_state)
|
|
|
ddf19c |
--
|
|
|
ddf19c |
1.8.3.1
|
|
|
ddf19c |
|