vmbus: retrieve connection-id from DeviceTree
PATCH v3 1/1 vmbus: retrieve connection-id from DeviceTree
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 <vendor>,<field> 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).
---
v3:
- Added documentation for the new property in DeviceTree bindings
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/
---
.../devicetree/bindings/bus/microsoft,vmbus.yaml | 8 ++++++++ drivers/hv/connection.c | 6 ++++-- drivers/hv/vmbus_drv.c | 13 +++++++++++++
3 files changed, 25 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml +0 -0
@@ -17,6 +17,14 @@ properties:
compatible:
const: microsoft,vmbus
+ microsoft,message-connection-id:
+ description:
+ VMBus message connection ID to be used for communication between host and + guest. If not specified, defaults to VMBUS_MESSAGE_CONNECTION_ID_4 for + protocol version VERSION_WIN10_V5 and above, or VMBUS_MESSAGE_CONNECTION_ID + for older versions.
+ $ref: /schemas/types.yaml#/definitions/uint32
+
ranges: true
'#address-cells':
drivers/hv/connection.c +0 -0
@@ -99,12 +99,14 @@ int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, u32 version)
if (version >= VERSION_WIN10_V5) {
msg->msg_sint = VMBUS_MESSAGE_SINT;
msg->msg_vtl = ms_hyperv.vtl;
- vmbus_connection.msg_conn_id = VMBUS_MESSAGE_CONNECTION_ID_4; } else {
msg->interrupt_page = virt_to_phys(vmbus_connection.int_page); - vmbus_connection.msg_conn_id = VMBUS_MESSAGE_CONNECTION_ID; }
+ /* Set default connection ID if not provided via DeviceTree */ + if (!vmbus_connection.msg_conn_id)
+ vmbus_connection.msg_conn_id = (version >= VERSION_WIN10_V5) ? + VMBUS_MESSAGE_CONNECTION_ID_4 : VMBUS_MESSAGE_CONNECTION_ID; /*
* shared_gpa_boundary is zero in non-SNP VMs, so it's safe to always
* bitwise OR it
drivers/hv/vmbus_drv.c +0 -0
@@ -2541,10 +2541,23 @@ static int vmbus_device_add(struct platform_device *pdev)
struct of_range range;
struct of_range_parser parser;
struct device_node *np = pdev->dev.of_node;
+ unsigned int conn_id;
int ret;
vmbus_root_device = &pdev->dev;
+ /*
+ * Read connection ID from DeviceTree. The property name follows the + * format <vendor>,<field> where:
+ * - vendor: "microsoft"
+ * - field: "message-connection-id"
+ */
+ ret = of_property_read_u32(np, "microsoft,message-connection-id", &conn_id); + if (!ret) {
+ pr_info("VMBus message connection ID: %u\n", conn_id);
+ vmbus_connection.msg_conn_id = conn_id;
+ }
+
ret = of_range_parser_init(&parser, np);
if (ret)
return ret;
Signature · 1 line
2.40.4
Quoted 13 lines · Hardik Garg
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 <vendor>,<field> 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_IDorVMBUS_MESSAGE_CONNECTION_ID_4based on protocol version).
Quoted 4 lines
Signed-off-by Hardik Garg <[email protected]>---
v3:
- Added documentation for the new property in DeviceTree bindings
Please run scripts/checkpatch.pl on the patches and fix reported warnings. After that, run also 'scripts/checkpatch.pl --strict' on the patches and (probably) fix more warnings. Some warnings can be ignored, especially from --strict run, but the code here looks like it needs a fix. Feel free to get in touch if the warning is not clear.
<form letter>
Please use scripts/get_maintainers.pl to get a list of necessary people and lists to CC. It might happen, that command when run on an older kernel, gives you outdated entries. Therefore please be sure you base your patches on recent Linux kernel.
Tools like b4 or scripts/get_maintainer.pl provide you proper list of people, so fix your workflow. Tools might also fail if you work on some ancient tree (don't, instead use mainline) or work on fork of kernel (don't, instead use mainline). Just use b4 and everything should be fine, although remember about b4 prep --auto-to-cc if you added new patches to the patchset.
You missed at least devicetree list (maybe more), so this won't be tested by automated tooling. Performing review on untested code might be a waste of time.
Please kindly resend and include all necessary To/Cc entries. </form letter>
Quoted 24 lines
v2:
https://lore.kernel.org/all/[email protected]/v1:
https://lore.kernel.org/all/[email protected]/--- .../devicetree/bindings/bus/microsoft,vmbus.yaml | 8 ++++++++ drivers/hv/connection.c | 6 ++++-- drivers/hv/vmbus_drv.c | 13 +++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-)Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml +3
-0@@ -17,6 +17,14 @@ properties: compatible: const: microsoft,vmbus + microsoft,message-connection-id: + description: + VMBus message connection ID to be used for communication between
Quoted 1 line
host and
Malformed email patch. Don't use Microsoft tools to send emails... They don't work outside of Microsoft. :/
Best regards,
Krzysztof