From nobody Fri Dec 19 19:06:32 2025 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A9CD1FC8; Thu, 5 Jun 2025 06:09:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749103776; cv=none; b=gaGytrRfiqZM500YoyRMh/2alehV485YoPWLPXHhk7UEbtAuRbhnl33/Us6mP0b6OITCIs6/LSo1QE2vMruUOmtlsqCvzqswF9Zztyf2KEsHkswhaXJnxOeL0w16h48ZaJNAXv7Rb6wVnhTvuwieR2TnQnkc6zKmIW5tCtHQE6E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749103776; c=relaxed/simple; bh=O84wJObH89CUpgkwkPADWcvnXK7hHeg8rak4mox67q4=; h=Message-ID:Date:MIME-Version:To:Cc:From:Subject:Content-Type; b=P2IYWTVeDs66PoamFX08Ue/TXB9PpkZHHqQ+PNJFhHR9y2mnx/McUuF29TBZ8t7NrpNF9nkNfVURB7MREYxp7cDNeTeaP4YEwURGD84mudst1ZVmXCKWucEOTdF9mhS6obvS8cRzX12cK97JBkmWD+NHOALaLZ/6t7JrDjYGrqI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=UPIYNxzi; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="UPIYNxzi" Received: from [100.64.1.134] (unknown [40.65.108.177]) by linux.microsoft.com (Postfix) with ESMTPSA id A9BD0201FF4E; Wed, 4 Jun 2025 23:09:32 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A9BD0201FF4E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1749103773; bh=arEF/2LdOdCfNP5R12P7zhBgPfTao/upFbApLg+9CFw=; h=Date:To:Cc:From:Subject:From; b=UPIYNxzitA7Tyg6oV7jSLomnxLkewK0LYNmWB5L1vLFiQns5uL7IDDNPKkpQ2Ncej /1CMyeG6bIQ/cDEG+9HY9EAwmTKPPrGYt65FKwtvB2D3kwS6Euxy/usrJjKDqXOb97 1oEbEg3gcRr7DpfDv5mJN6+Idr/lN7MeB3Vene2I= Message-ID: <6a92ca86-ad6b-4d49-af6e-1ed7651b8ab8@linux.microsoft.com> Date: Wed, 4 Jun 2025 23:09:31 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, ssengar@microsoft.com Cc: romank@linux.microsoft.com, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, stable@kernel.org, apais@microsoft.com From: Hardik Garg Subject: [PATCH v3] vmbus: retrieve connection-id from DeviceTree Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable The connection-id determines which hypervisor communication channel the guest should use to talk to the VMBus host. This patch adds support to read this value from the DeviceTree where it exists as a property under the vmbus node with the compatible ID "microsoft,message-connection-id". The property name follows the format , where "vendor": "microsoft" and "field": "message-connection-id" Reading from DeviceTree allows platforms to specify their preferred communication channel, making it more flexible. If the property is not found in the DeviceTree, use the default connection ID (VMBUS_MESSAGE_CONNECTION_ID or VMBUS_MESSAGE_CONNECTION_ID_4 based on protocol version). Signed-off-by: Hardik Garg --- v3: - Added documentation for the new property in DeviceTree bindings v2:=20 https://lore.kernel.org/all/096edaf7-cc90-42b6-aff4-c5f088574e1e@linux.micr= osoft.com/ v1:=20 https://lore.kernel.org/all/6acee4bf-cb04-43b9-9476-e8d811d26dfd@linux.micr= osoft.com/ --- =C2=A0.../devicetree/bindings/bus/microsoft,vmbus.yaml=C2=A0=C2=A0=C2=A0 |= =C2=A0 8 ++++++++ =C2=A0drivers/hv/connection.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 6 ++++-- =C2=A0drivers/hv/vmbus_drv.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 13 +++++++++++++ =C2=A03 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml=20 b/Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml index 0bea4f5287ce..729ca6defec6 100644 --- a/Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml +++ b/Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml @@ -17,6 +17,14 @@ properties: =C2=A0=C2=A0 compatible: =C2=A0=C2=A0=C2=A0=C2=A0 const: microsoft,vmbus +=C2=A0 microsoft,message-connection-id: +=C2=A0=C2=A0=C2=A0 description: +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 VMBus message connection ID to be used for = communication between=20 host and +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 guest. If not specified, defaults to=20 VMBUS_MESSAGE_CONNECTION_ID_4 for +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 protocol version VERSION_WIN10_V5 and above= , or=20 VMBUS_MESSAGE_CONNECTION_ID +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 for older versions. +=C2=A0=C2=A0=C2=A0 $ref: /schemas/types.yaml#/definitions/uint32 + =C2=A0=C2=A0 ranges: true =C2=A0=C2=A0 '#address-cells': diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c index be490c598785..e0f38d799d06 100644 --- a/drivers/hv/connection.c +++ b/drivers/hv/connection.c @@ -99,12 +99,14 @@ int vmbus_negotiate_version(struct=20 vmbus_channel_msginfo *msginfo, u32 version) =C2=A0=C2=A0=C2=A0=C2=A0 if (version >=3D VERSION_WIN10_V5) { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 msg->msg_sint =3D VMBUS_M= ESSAGE_SINT; =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 msg->msg_vtl =3D ms_hyper= v.vtl; -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 vmbus_connection.msg_conn_id = =3D VMBUS_MESSAGE_CONNECTION_ID_4; =C2=A0=C2=A0=C2=A0=C2=A0 } else { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 msg->interrupt_page =3D v= irt_to_phys(vmbus_connection.int_page); -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 vmbus_connection.msg_conn_id = =3D VMBUS_MESSAGE_CONNECTION_ID; =C2=A0=C2=A0=C2=A0=C2=A0 } +=C2=A0=C2=A0=C2=A0 /* Set default connection ID if not provided via Device= Tree */ +=C2=A0=C2=A0=C2=A0 if (!vmbus_connection.msg_conn_id) +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 vmbus_connection.msg_conn_id = =3D (version >=3D VERSION_WIN10_V5) ? +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 VMBUS_M= ESSAGE_CONNECTION_ID_4 : VMBUS_MESSAGE_CONNECTION_ID; =C2=A0=C2=A0=C2=A0=C2=A0 /* =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * shared_gpa_boundary is zero in non-SNP VM= s, so it's safe to always =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * bitwise OR it diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index c236081d0a87..d14d286671cc 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -2541,10 +2541,23 @@ static int vmbus_device_add(struct=20 platform_device *pdev) =C2=A0=C2=A0=C2=A0=C2=A0 struct of_range range; =C2=A0=C2=A0=C2=A0=C2=A0 struct of_range_parser parser; =C2=A0=C2=A0=C2=A0=C2=A0 struct device_node *np =3D pdev->dev.of_node; +=C2=A0=C2=A0=C2=A0 unsigned int conn_id; =C2=A0=C2=A0=C2=A0=C2=A0 int ret; =C2=A0=C2=A0=C2=A0=C2=A0 vmbus_root_device =3D &pdev->dev; +=C2=A0=C2=A0=C2=A0 /* +=C2=A0=C2=A0=C2=A0=C2=A0 * Read connection ID from DeviceTree. The propert= y name follows the +=C2=A0=C2=A0=C2=A0=C2=A0 * format , where: +=C2=A0=C2=A0=C2=A0=C2=A0 * - vendor: "microsoft" +=C2=A0=C2=A0=C2=A0=C2=A0 * - field: "message-connection-id" +=C2=A0=C2=A0=C2=A0=C2=A0 */ +=C2=A0=C2=A0=C2=A0 ret =3D of_property_read_u32(np, "microsoft,message-con= nection-id",=20 &conn_id); +=C2=A0=C2=A0=C2=A0 if (!ret) { +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pr_info("VMBus message connecti= on ID: %u\n", conn_id); +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 vmbus_connection.msg_conn_id = =3D conn_id; +=C2=A0=C2=A0=C2=A0 } + =C2=A0=C2=A0=C2=A0=C2=A0 ret =3D of_range_parser_init(&parser, np); =C2=A0=C2=A0=C2=A0=C2=A0 if (ret) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return ret; --=20 2.40.4