From patchwork Fri Jan 11 15:34:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Xu X-Patchwork-Id: 1023651 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43bnBc2mgfz9s7h for ; Sat, 12 Jan 2019 02:40:40 +1100 (AEDT) Received: from localhost ([127.0.0.1]:54521 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghyvG-0003GY-9S for incoming@patchwork.ozlabs.org; Fri, 11 Jan 2019 10:40:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghyrZ-0000fW-PJ for qemu-devel@nongnu.org; Fri, 11 Jan 2019 10:36:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghyrX-0003tv-Sx for qemu-devel@nongnu.org; Fri, 11 Jan 2019 10:36:49 -0500 Received: from mga14.intel.com ([192.55.52.115]:56407) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ghyrX-0003i3-Gd for qemu-devel@nongnu.org; Fri, 11 Jan 2019 10:36:47 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jan 2019 07:36:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,466,1539673200"; d="scan'208";a="107522655" Received: from vmmtaopc.sh.intel.com ([10.239.13.92]) by orsmga006.jf.intel.com with ESMTP; 11 Jan 2019 07:36:44 -0800 From: Tao Xu To: mst@redhat.com, imammedo@redhat.com Date: Fri, 11 Jan 2019 23:34:50 +0800 Message-Id: <20190111153451.14304-9-tao3.xu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190111153451.14304-1-tao3.xu@intel.com> References: <20190111153451.14304-1-tao3.xu@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.115 Subject: [Qemu-devel] [PATCH v2 8/9] hmat acpi: move some function inside of the caller X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ehabkost@redhat.com, jingqi.liu@intel.com, tao3.xu@intel.com, qemu-devel@nongnu.org, pbonzini@redhat.com, danmei.wei@intel.com, rth@twiddle.net Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Per Igor comments, these function is used only once, move its body inside of the caller Reviewed-by: Liu Jingqi Signed-off-by: Tao Xu --- hw/acpi/hmat.c | 93 ++++++++++++++++++++------------------------------ 1 file changed, 37 insertions(+), 56 deletions(-) diff --git a/hw/acpi/hmat.c b/hw/acpi/hmat.c index e8ba9250e9..4523e98ef1 100644 --- a/hw/acpi/hmat.c +++ b/hw/acpi/hmat.c @@ -84,22 +84,41 @@ static int pc_dimm_device_list(Object *obj, void *opaque) return 0; } +static void classify_proximity_domains(void) +{ + int node; + + for (node = 0; node < nb_numa_nodes; node++) { + if (numa_info[node].is_initiator) { + initiator_pxm[num_initiator++] = node; + } + if (numa_info[node].is_target) { + target_pxm[num_target++] = node; + } + } +} + +static void hmat_build_hma(GArray *hma, PCMachineState *pcms) +{ /* * The Proximity Domain of System Physical Address ranges defined * in the HMAT, NFIT and SRAT tables shall match each other. */ -static void hmat_build_spa(GArray *table_data, PCMachineState *pcms) -{ + GSList *device_list = NULL; + AcpiHmatLBInfo *hmat_lb; + AcpiHmatCacheInfo *hmat_cache; + struct numa_hmat_lb_info *numa_hmat_lb; + struct numa_hmat_cache_info *numa_hmat_cache; uint64_t mem_base, mem_len; - int i; + int i, j, hrchy, type, level; if (pcms->numa_nodes && !mem_ranges_number) { build_mem_ranges(pcms); } for (i = 0; i < mem_ranges_number; i++) { - hmat_build_spa_info(table_data, mem_ranges[i].base, + build_hmat_spa(hma, mem_ranges[i].base, mem_ranges[i].length, mem_ranges[i].node); } @@ -113,30 +132,10 @@ static void hmat_build_spa(GArray *table_data, PCMachineState *pcms) mem_len = object_property_get_uint(OBJECT(dimm), PC_DIMM_SIZE_PROP, NULL); i = object_property_get_uint(OBJECT(dimm), PC_DIMM_NODE_PROP, NULL); - hmat_build_spa_info(table_data, mem_base, mem_len, i); - } -} - -static void classify_proximity_domains(void) -{ - int node; - - for (node = 0; node < nb_numa_nodes; node++) { - if (numa_info[node].is_initiator) { - initiator_pxm[num_initiator++] = node; - } - if (numa_info[node].is_target) { - target_pxm[num_target++] = node; - } + build_hmat_spa(hma, mem_base, mem_len, i); } -} - -static void hmat_build_lb(GArray *table_data) -{ - AcpiHmatLBInfo *hmat_lb; - struct numa_hmat_lb_info *numa_hmat_lb; - int i, j, hrchy, type; + /* Build HMAT System Locality Latency and Bandwidth Information. */ if (!num_initiator && !num_target) { classify_proximity_domains(); } @@ -154,8 +153,8 @@ static void hmat_build_lb(GArray *table_data) uint32_t size; uint8_t m, n; - start = table_data->len; - hmat_lb = acpi_data_push(table_data, sizeof(*hmat_lb)); + start = hma->len; + hmat_lb = acpi_data_push(hma, sizeof(*hmat_lb)); hmat_lb->type = cpu_to_le16(ACPI_HMAT_LB_INFO); hmat_lb->flags = numa_hmat_lb->hierarchy; @@ -174,19 +173,19 @@ static void hmat_build_lb(GArray *table_data) /* the initiator proximity domain list */ for (i = 0; i < num_initiator; i++) { - list_entry = acpi_data_push(table_data, sizeof(uint32_t)); + list_entry = acpi_data_push(hma, sizeof(uint32_t)); *list_entry = cpu_to_le32(initiator_pxm[i]); } /* the target proximity domain list */ for (i = 0; i < num_target; i++) { - list_entry = acpi_data_push(table_data, sizeof(uint32_t)); + list_entry = acpi_data_push(hma, sizeof(uint32_t)); *list_entry = cpu_to_le32(target_pxm[i]); } /* latency or bandwidth entries */ size = sizeof(uint16_t) * num_initiator * num_target; - entry_start = acpi_data_push(table_data, size); + entry_start = acpi_data_push(hma, size); for (i = 0; i < num_initiator; i++) { m = initiator_pxm[i]; @@ -200,26 +199,20 @@ static void hmat_build_lb(GArray *table_data) } } } - hmat_lb = (AcpiHmatLBInfo *)(table_data->data + start); - hmat_lb->length = cpu_to_le16(table_data->len - start); + hmat_lb = (AcpiHmatLBInfo *)(hma->data + start); + hmat_lb->length = cpu_to_le16(hma->len - start); } } } -} - -static void hmat_build_cache(GArray *table_data) -{ - AcpiHmatCacheInfo *hmat_cache; - struct numa_hmat_cache_info *numa_hmat_cache; - int i, level; + /* Build HMAT Memory Side Cache Information. */ for (i = 0; i < nb_numa_nodes; i++) { for (level = 0; level <= MAX_HMAT_CACHE_LEVEL; level++) { numa_hmat_cache = hmat_cache_info[i][level]; if (numa_hmat_cache) { - uint64_t start = table_data->len; + uint64_t start = hma->len; - hmat_cache = acpi_data_push(table_data, sizeof(*hmat_cache)); + hmat_cache = acpi_data_push(hma, sizeof(*hmat_cache)); hmat_cache->length = cpu_to_le32(sizeof(*hmat_cache)); hmat_cache->type = cpu_to_le16(ACPI_HMAT_CACHE_INFO); hmat_cache->mem_proximity = @@ -242,10 +235,10 @@ static void hmat_build_cache(GArray *table_data) int size; size = hmat_cache->num_smbios_handles * sizeof(uint16_t); - smbios_handles = acpi_data_push(table_data, size); + smbios_handles = acpi_data_push(hma, size); hmat_cache = (AcpiHmatCacheInfo *) - (table_data->data + start); + (hma->data + start); hmat_cache->length += size; /* TBD: set smbios handles */ @@ -258,18 +251,6 @@ static void hmat_build_cache(GArray *table_data) } } -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); - - /* Build HMAT Memory Side Cache Information. */ - hmat_build_cache(hma); -} - static uint64_t hmat_hma_method_read(void *opaque, hwaddr addr, unsigned size) {