From nobody Wed Sep 10 02:39:11 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC503E728D7 for ; Fri, 29 Sep 2023 18:02:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233714AbjI2SCQ (ORCPT ); Fri, 29 Sep 2023 14:02:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233856AbjI2SCF (ORCPT ); Fri, 29 Sep 2023 14:02:05 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 707E4CC0; Fri, 29 Sep 2023 11:01:57 -0700 (PDT) Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 9759C20B74C5; Fri, 29 Sep 2023 11:01:56 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 9759C20B74C5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1696010516; bh=3fBbVBD2uKgvoquqz27ACQRB2O2cWkvCr1Y5+xe6PMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TVzDnXd53dpojCdgNZ5GSAI//ZFMoeAD646kLVWXYHL7HjKqKyHska0roEu9A8e06 48THBjuWo+E3tP8M0Lca97fbz4zZJfSDJeqq+ebFnchVaWQ2KK1Bdbh1NlVkc25n6r kkk0+eDGORRWw+MIk77oxZqmF5pLRWnzrB45aqAI= From: Nuno Das Neves To: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org Cc: patches@lists.linux.dev, mikelley@microsoft.com, kys@microsoft.com, wei.liu@kernel.org, gregkh@linuxfoundation.org, haiyangz@microsoft.com, decui@microsoft.com, apais@linux.microsoft.com, Tianyu.Lan@microsoft.com, ssengar@linux.microsoft.com, mukeshrathor@microsoft.com, stanislav.kinsburskiy@gmail.com, jinankjain@linux.microsoft.com, vkuznets@redhat.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, will@kernel.org, catalin.marinas@arm.com Subject: [PATCH v4 03/15] mshyperv: Introduce numa_node_to_proximity_domain_info Date: Fri, 29 Sep 2023 11:01:29 -0700 Message-Id: <1696010501-24584-4-git-send-email-nunodasneves@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1696010501-24584-1-git-send-email-nunodasneves@linux.microsoft.com> References: <1696010501-24584-1-git-send-email-nunodasneves@linux.microsoft.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Factor out logic for converting numa node to proximity domain info into a helper function, and export it. Change hv_proximity_domain_info to a struct to simplify the code. Signed-off-by: Nuno Das Neves Reviewed-by: Wei Liu --- arch/x86/hyperv/hv_proc.c | 8 ++------ drivers/acpi/numa/srat.c | 1 + include/asm-generic/hyperv-tlfs.h | 14 +++++--------- include/asm-generic/mshyperv.h | 15 +++++++++++++++ 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/arch/x86/hyperv/hv_proc.c b/arch/x86/hyperv/hv_proc.c index 68a0843d4750..5ba5ca1b2089 100644 --- a/arch/x86/hyperv/hv_proc.c +++ b/arch/x86/hyperv/hv_proc.c @@ -121,7 +121,6 @@ int hv_call_add_logical_proc(int node, u32 lp_index, u3= 2 apic_id) u64 status; unsigned long flags; int ret =3D HV_STATUS_SUCCESS; - int pxm =3D node_to_pxm(node); =20 /* * When adding a logical processor, the hypervisor may return @@ -137,11 +136,8 @@ int hv_call_add_logical_proc(int node, u32 lp_index, u= 32 apic_id) =20 input->lp_index =3D lp_index; input->apic_id =3D apic_id; - input->flags =3D 0; - input->proximity_domain_info.domain_id =3D pxm; - input->proximity_domain_info.flags.reserved =3D 0; - input->proximity_domain_info.flags.proximity_info_valid =3D 1; - input->proximity_domain_info.flags.proximity_preferred =3D 1; + input->proximity_domain_info =3D + numa_node_to_proximity_domain_info(node); status =3D hv_do_hypercall(HVCALL_ADD_LOGICAL_PROCESSOR, input, output); local_irq_restore(flags); diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c index 1f4fc5f8a819..0cf9f0574495 100644 --- a/drivers/acpi/numa/srat.c +++ b/drivers/acpi/numa/srat.c @@ -48,6 +48,7 @@ int node_to_pxm(int node) return PXM_INVAL; return node_to_pxm_map[node]; } +EXPORT_SYMBOL(node_to_pxm); =20 static void __acpi_map_pxm_to_node(int pxm, int node) { diff --git a/include/asm-generic/hyperv-tlfs.h b/include/asm-generic/hyperv= -tlfs.h index f63b3704d89e..a6dffb346bf2 100644 --- a/include/asm-generic/hyperv-tlfs.h +++ b/include/asm-generic/hyperv-tlfs.h @@ -512,13 +512,9 @@ struct hv_proximity_domain_flags { u32 proximity_info_valid : 1; } __packed; =20 -/* Not a union in windows but useful for zeroing */ -union hv_proximity_domain_info { - struct { - u32 domain_id; - struct hv_proximity_domain_flags flags; - }; - u64 as_uint64; +struct hv_proximity_domain_info { + u32 domain_id; + struct hv_proximity_domain_flags flags; } __packed; =20 struct hv_lp_startup_status { @@ -535,7 +531,7 @@ struct hv_lp_startup_status { struct hv_add_logical_processor_in { u32 lp_index; u32 apic_id; - union hv_proximity_domain_info proximity_domain_info; + struct hv_proximity_domain_info proximity_domain_info; u64 flags; } __packed; =20 @@ -560,7 +556,7 @@ struct hv_create_vp { u8 padding[3]; u8 subnode_type; u64 subnode_id; - union hv_proximity_domain_info proximity_domain_info; + struct hv_proximity_domain_info proximity_domain_info; u64 flags; } __packed; =20 diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h index 9f2c06c9d5d1..8cc7b0e316d7 100644 --- a/include/asm-generic/mshyperv.h +++ b/include/asm-generic/mshyperv.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -28,6 +29,20 @@ =20 #define VTPM_BASE_ADDRESS 0xfed40000 =20 +static inline struct hv_proximity_domain_info +numa_node_to_proximity_domain_info(int node) +{ + struct hv_proximity_domain_info proximity_domain_info =3D {}; + + if (node !=3D NUMA_NO_NODE) { + proximity_domain_info.domain_id =3D node_to_pxm(node); + proximity_domain_info.flags.proximity_info_valid =3D 1; + proximity_domain_info.flags.proximity_preferred =3D 1; + } + + return proximity_domain_info; +} + struct ms_hyperv_info { u32 features; u32 priv_high; --=20 2.25.1