Skip to contentSkip to conversation

Device tree support for Hyper-V VMBus driver

PATCH Superseded Saurabh Sengar 6 participants 19 messages Feb 7, 2023 – Feb 8, 2023

Subsystems (7)

v4 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v4 cover Device tree support for Hyper-V VMBus driver

This set of patches expands the VMBus driver to include device tree support. This feature allows for a kernel boot without the use of ACPI tables, resulting in a smaller memory footprint and potentially faster boot times. This is tested by enabling CONFIG_FLAT and OF_EARLY_FLATTREE for x86.

The first two patches enable compilation of Hyper-V APIs in a non-ACPI build.

The third patch converts the VMBus driver from acpi to more generic platform driver.

Further to add device tree documentation for VMBus, it needs to club with other virtualization driver's documentation. For this rename the virtio folder to more generic hypervisor, so that all the hypervisor based devices can co-exist in a single place in device tree documentation. The fourth patch does this renaming.

The fifth patch introduces the device tree documentation for VMBus.

The sixth patch adds device tree support to the VMBus driver. Currently this is tested only for x86 and it may not work for other archs.

[V4]
- rebased which fixed return type of 'vmbus_mmio_remove' from int to void
- used __maybe_unused for 'vmbus_of_match' and safeguard vmbus_acpi_device_ids under #ifdef

[V3]
- Changed the logic to use generic api (for_each_of_range) for parsing "ranges".
- Remove dependency of ACPI for HYPERV in case of x86.
- Removed "device tree bindings" from title and patch subject.
- Removed duplicate vendor prefix, used microsoft instead of msft.
- Use 'soc' in example of device tree documantation for parent node.
- Fixed compatible schemas error generated in other modules referring to virtio.
- Drop hex notation and leading zeros from device tree cell properties.
- Added missing full stop at the end of commit message.
- Typos fix: s/Initaly/Initially/ and s/hibernate/hibernation/.
- Replace to_acpi_device with ACPI_COMPANION which simplify the logic.
- Added more info in cover letter aboutsystem under test.

[v2]
- Convert VMBus acpi device to platform device, and added device tree support in separate patch. This enables using same driver structure for both the flows.
- In Device tree documentation, changed virtio folder to hypervisor and moved VMBus documentation there.
- Moved bindings before Device tree patch.
- Removed stale ".data" and ".name" field from of_device match table.
- Removed debug print.

Saurabh Sengar (6):
drivers/clocksource/hyper-v: non ACPI support in hyperv clock
Drivers: hv: allow non ACPI compilation for
hv_is_hibernation_supported
Drivers: hv: vmbus: Convert acpi_device to more generic
platform_device
dt-bindings: hypervisor: Rename virtio to hypervisor
dt-bindings: hypervisor: VMBus
Driver: VMBus: Add device tree support

 .../devicetree/bindings/gpio/gpio-virtio.yaml      |   4 +-
 .../bindings/hypervisor/microsoft,vmbus.yaml       |  48 +++++++++
 .../bindings/{virtio => hypervisor}/mmio.yaml      |   2 +-
 .../bindings/{virtio => hypervisor}/pci-iommu.yaml |   2 +-
 .../{virtio => hypervisor}/virtio-device.yaml      |   2 +-
 .../devicetree/bindings/i2c/i2c-virtio.yaml        |   4 +-
 MAINTAINERS                                        |   3 +-
 drivers/clocksource/hyperv_timer.c                 |  15 ++-
 drivers/hv/Kconfig                                 |   4 +-
 drivers/hv/hv_common.c                             |   4 +
 drivers/hv/vmbus_drv.c                             | 120 ++++++++++++++++-----
 11 files changed, 171 insertions(+), 37 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/hypervisor/microsoft,vmbus.yaml
 rename Documentation/devicetree/bindings/{virtio => hypervisor}/mmio.yaml (95%)
 rename Documentation/devicetree/bindings/{virtio => hypervisor}/pci-iommu.yaml (98%)
 rename Documentation/devicetree/bindings/{virtio => hypervisor}/virtio-device.yaml (93%)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v4 1/6 drivers/clocksource/hyper-v: non ACPI support in hyperv clock

Add a placeholder function for the hv_setup_stimer0_irq API to accommodate systems without ACPI support. Since this function is not utilized on x86/x64 systems and non-ACPI support is only intended for x86/x64 systems, a placeholder function is sufficient for now and can be improved upon if necessary in the future.

This change will make it easier to add device tree support for VMBus in subsequent commits.

---
 drivers/clocksource/hyperv_timer.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/clocksource/hyperv_timer.c +13 -2
index c0cef92..f32948c 100644
@@ -49,7 +49,7 @@
 
 static int stimer0_irq = -1;
 static int stimer0_message_sint;
-static DEFINE_PER_CPU(long, stimer0_evt);
+static __maybe_unused DEFINE_PER_CPU(long, stimer0_evt);
 
 /*
  * Common code for stimer0 interrupts coming via Direct Mode or
@@ -68,7 +68,7 @@ void hv_stimer0_isr(void)
  * stimer0 interrupt handler for architectures that support
  * per-cpu interrupts, which also implies Direct Mode.
  */
-static irqreturn_t hv_stimer0_percpu_isr(int irq, void *dev_id)
+static irqreturn_t __maybe_unused hv_stimer0_percpu_isr(int irq, void *dev_id)
 {
 	hv_stimer0_isr();
 	return IRQ_HANDLED;
@@ -196,6 +196,7 @@ void __weak hv_remove_stimer0_handler(void)
 {
 };
 
+#ifdef CONFIG_ACPI
 /* Called only on architectures with per-cpu IRQs (i.e., not x86/x64) */
 static int hv_setup_stimer0_irq(void)
 {
@@ -230,6 +231,16 @@ static void hv_remove_stimer0_irq(void)
 		stimer0_irq = -1;
 	}
 }
+#else
+static int hv_setup_stimer0_irq(void)
+{
+	return 0;
+}
+
+static void hv_remove_stimer0_irq(void)
+{
+}
+#endif
 
 /* hv_stimer_alloc - Global initialization of the clockevent and stimer0 */
 int hv_stimer_alloc(bool have_percpu_irqs)
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH v4 2/6 Drivers: hv: allow non ACPI compilation for hv_is_hibernation_supported

In reply to Saurabh Sengar

acpi_sleep_state_supported API is only define for CONFIG_ACPI flag and thus it can't be used for non-ACPI builds. Initially there won't be hibernation support for non ACPI builds.

This change will help adding device tree support in subsequent commits.

---
 drivers/hv/hv_common.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/hv/hv_common.c +4 -0
index 52a6f89..370ec20 100644
@@ -234,7 +234,11 @@ void hv_setup_dma_ops(struct device *dev, bool coherent)
 
 bool hv_is_hibernation_supported(void)
 {
+#ifdef CONFIG_ACPI
 	return !hv_root_partition && acpi_sleep_state_supported(ACPI_STATE_S4);
+#else
+	return false;
+#endif
 }
 EXPORT_SYMBOL_GPL(hv_is_hibernation_supported);
 
Signature · 1 line
1.8.3.1
#10 lore raw

PATCH v4 5/6 dt-bindings: hypervisor: VMBus

In reply to Saurabh Sengar

Add dt-bindings for Hyper-V VMBus.

---
 .../bindings/hypervisor/microsoft,vmbus.yaml       | 48 ++++++++++++++++++++++
 MAINTAINERS                                        |  1 +
 2 files changed, 49 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hypervisor/microsoft,vmbus.yaml
Documentation/devicetree/bindings/hypervisor/microsoft,vmbus.yaml new file +48 -0
new file mode 100644
index 0000000..a9c43a6
@@ -0,0 +1,48 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hypervisor/microsoft,vmbus.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Microsoft Hyper-V VMBus
+
+maintainers:
+  - Saurabh Sengar <[email protected]>
+
+description:
+  VMBus is a software bus that implement the protocols for communication
+  between the root or host OS and guest OSs (virtual machines).
+
+properties:
+  compatible:
+    const: microsoft,vmbus
+
+  ranges: true
+
+  '#address-cells':
+    const: 2
+
+  '#size-cells':
+    const: 1
+
+required:
+  - compatible
+  - ranges
+  - '#address-cells'
+  - '#size-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    soc {
+        #address-cells = <2>;
+        #size-cells = <2>;
+
+        vmbus@ff0000000 {
+            #address-cells = <2>;
+            #size-cells = <1>;
+            compatible = "microsoft,vmbus";
+            ranges = <0x0f 0xf0000000 0x0f 0xf0000000 0x10000000>;
+        };
+    };
MAINTAINERS +1 -0
index 27a5650..669f1c1 100644
@@ -9490,6 +9490,7 @@ S:	Supported
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git
 F:	Documentation/ABI/stable/sysfs-bus-vmbus
 F:	Documentation/ABI/testing/debugfs-hyperv
+F:	Documentation/devicetree/bindings/hypervisor/microsoft,vmbus.yaml
 F:	Documentation/virt/hyperv
 F:	Documentation/networking/device_drivers/ethernet/microsoft/netvsc.rst
 F:	arch/arm64/hyperv
Signature · 1 line
1.8.3.1
#5 lore raw

PATCH v4 3/6 Drivers: hv: vmbus: Convert acpi_device to more generic platform_device

In reply to Saurabh Sengar

Use more generic platform device instead of acpi device. Also rename the function vmbus_acpi_remove to more generic name vmbus_mmio_remove.

---
[V4]
- rebased which fixed return type of 'vmbus_mmio_remove' from int to void

 drivers/hv/vmbus_drv.c | 58 ++++++++++++++++++++++++++++++--------------------
 1 file changed, 35 insertions(+), 23 deletions(-)
drivers/hv/vmbus_drv.c +35 -23
index d24dd65..7349715 100644
@@ -12,6 +12,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/device.h>
+#include <linux/platform_device.h>
 #include <linux/interrupt.h>
 #include <linux/sysctl.h>
 #include <linux/slab.h>
@@ -44,7 +45,7 @@ struct vmbus_dynid {
 	struct hv_vmbus_device_id id;
 };
 
-static struct acpi_device  *hv_acpi_dev;
+static struct device  *hv_dev;
 
 static int hyperv_cpuhp_online;
 
@@ -143,7 +144,7 @@ static int hv_die_panic_notify_crash(struct notifier_block *self,
 
 static int vmbus_exists(void)
 {
-	if (hv_acpi_dev == NULL)
+	if (hv_dev == NULL)
 		return -ENODEV;
 
 	return 0;
@@ -932,7 +933,7 @@ static int vmbus_dma_configure(struct device *child_device)
 	 * On x86/x64 coherence is assumed and these calls have no effect.
 	 */
 	hv_setup_dma_ops(child_device,
-		device_get_dma_attr(&hv_acpi_dev->dev) == DEV_DMA_COHERENT);
+		device_get_dma_attr(hv_dev) == DEV_DMA_COHERENT);
 	return 0;
 }
 
@@ -2090,7 +2091,7 @@ int vmbus_device_register(struct hv_device *child_device_obj)
 		     &child_device_obj->channel->offermsg.offer.if_instance);
 
 	child_device_obj->device.bus = &hv_bus;
-	child_device_obj->device.parent = &hv_acpi_dev->dev;
+	child_device_obj->device.parent = hv_dev;
 	child_device_obj->device.release = vmbus_device_release;
 
 	child_device_obj->device.dma_parms = &child_device_obj->dma_parms;
@@ -2262,7 +2263,7 @@ static acpi_status vmbus_walk_resources(struct acpi_resource *res, void *ctx)
 	return AE_OK;
 }
 
-static void vmbus_acpi_remove(struct acpi_device *device)
+static void vmbus_mmio_remove(void)
 {
 	struct resource *cur_res;
 	struct resource *next_res;
@@ -2441,13 +2442,14 @@ void vmbus_free_mmio(resource_size_t start, resource_size_t size)
 }
 EXPORT_SYMBOL_GPL(vmbus_free_mmio);
 
-static int vmbus_acpi_add(struct acpi_device *device)
+static int vmbus_acpi_add(struct platform_device *pdev)
 {
 	acpi_status result;
 	int ret_val = -ENODEV;
 	struct acpi_device *ancestor;
+	struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
 
-	hv_acpi_dev = device;
+	hv_dev = &device->dev;
 
 	/*
 	 * Older versions of Hyper-V for ARM64 fail to include the _CCA
@@ -2489,10 +2491,21 @@ static int vmbus_acpi_add(struct acpi_device *device)
 
 acpi_walk_err:
 	if (ret_val)
-		vmbus_acpi_remove(device);
+		vmbus_mmio_remove();
 	return ret_val;
 }
 
+static int vmbus_platform_driver_probe(struct platform_device *pdev)
+{
+	return vmbus_acpi_add(pdev);
+}
+
+static int vmbus_platform_driver_remove(struct platform_device *pdev)
+{
+	vmbus_mmio_remove();
+	return 0;
+}
+
 #ifdef CONFIG_PM_SLEEP
 static int vmbus_bus_suspend(struct device *dev)
 {
@@ -2658,15 +2671,15 @@ static int vmbus_bus_resume(struct device *dev)
 	.restore_noirq	= vmbus_bus_resume
 };
 
-static struct acpi_driver vmbus_acpi_driver = {
-	.name = "vmbus",
-	.ids = vmbus_acpi_device_ids,
-	.ops = {
-		.add = vmbus_acpi_add,
-		.remove = vmbus_acpi_remove,
-	},
-	.drv.pm = &vmbus_bus_pm,
-	.drv.probe_type = PROBE_FORCE_SYNCHRONOUS,
+static struct platform_driver vmbus_platform_driver = {
+	.probe = vmbus_platform_driver_probe,
+	.remove = vmbus_platform_driver_remove,
+	.driver = {
+		.name = "vmbus",
+		.acpi_match_table = ACPI_PTR(vmbus_acpi_device_ids),
+		.pm = &vmbus_bus_pm,
+		.probe_type = PROBE_FORCE_SYNCHRONOUS,
+	}
 };
 
 static void hv_kexec_handler(void)
@@ -2750,12 +2763,11 @@ static int __init hv_acpi_init(void)
 	/*
 	 * Get ACPI resources first.
 	 */
-	ret = acpi_bus_register_driver(&vmbus_acpi_driver);
-
+	ret = platform_driver_register(&vmbus_platform_driver);
 	if (ret)
 		return ret;
 
-	if (!hv_acpi_dev) {
+	if (!hv_dev) {
 		ret = -ENODEV;
 		goto cleanup;
 	}
@@ -2785,8 +2797,8 @@ static int __init hv_acpi_init(void)
 	return 0;
 
 cleanup:
-	acpi_bus_unregister_driver(&vmbus_acpi_driver);
-	hv_acpi_dev = NULL;
+	platform_driver_unregister(&vmbus_platform_driver);
+	hv_dev = NULL;
 	return ret;
 }
 
@@ -2839,7 +2851,7 @@ static void __exit vmbus_exit(void)
 
 	cpuhp_remove_state(hyperv_cpuhp_online);
 	hv_synic_free();
-	acpi_bus_unregister_driver(&vmbus_acpi_driver);
+	platform_driver_unregister(&vmbus_platform_driver);
 }
 
 
Signature · 1 line
1.8.3.1
#7 lore raw

PATCH v4 4/6 dt-bindings: hypervisor: Rename virtio to hypervisor

In reply to Saurabh Sengar

Rename virtio folder to more generic hypervisor, so that this can accommodate more devices of similar type.

---
 Documentation/devicetree/bindings/gpio/gpio-virtio.yaml               | 4 ++--
 Documentation/devicetree/bindings/{virtio => hypervisor}/mmio.yaml    | 2 +-
 .../devicetree/bindings/{virtio => hypervisor}/pci-iommu.yaml         | 2 +-
 .../devicetree/bindings/{virtio => hypervisor}/virtio-device.yaml     | 2 +-
 Documentation/devicetree/bindings/i2c/i2c-virtio.yaml                 | 4 ++--
 MAINTAINERS                                                           | 2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)
 rename Documentation/devicetree/bindings/{virtio => hypervisor}/mmio.yaml (95%)
 rename Documentation/devicetree/bindings/{virtio => hypervisor}/pci-iommu.yaml (98%)
 rename Documentation/devicetree/bindings/{virtio => hypervisor}/virtio-device.yaml (93%)
Documentation/devicetree/bindings/gpio/gpio-virtio.yaml +2 -2
index 601d857..e08ed2a 100644
@@ -10,10 +10,10 @@ maintainers:
   - Viresh Kumar <[email protected]>
 
 allOf:
-  - $ref: /schemas/virtio/virtio-device.yaml#
+  - $ref: /schemas/hypervisor/virtio-device.yaml#
 
 description:
-  Virtio GPIO controller, see /schemas/virtio/virtio-device.yaml for more
+  Virtio GPIO controller, see /schemas/hypervisor/virtio-device.yaml for more
   details.
 
 properties:
Documentation/devicetree/bindings/hypervisor/mmio.yaml renamed from Documentation/devicetree/bindings/virtio/mmio.yaml +1 -1
similarity index 95%
rename from Documentation/devicetree/bindings/virtio/mmio.yaml
rename to Documentation/devicetree/bindings/hypervisor/mmio.yaml
index 0aa8433..8492c9b 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
 %YAML 1.2
 ---
-$id: http://devicetree.org/schemas/virtio/mmio.yaml#
+$id: http://devicetree.org/schemas/hypervisor/mmio.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
 title: virtio memory mapped devices
Documentation/devicetree/bindings/hypervisor/pci-iommu.yaml renamed from Documentation/devicetree/bindings/virtio/pci-iommu.yaml +1 -1
similarity index 98%
rename from Documentation/devicetree/bindings/virtio/pci-iommu.yaml
rename to Documentation/devicetree/bindings/hypervisor/pci-iommu.yaml
index 972a785..52de535 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
 %YAML 1.2
 ---
-$id: http://devicetree.org/schemas/virtio/pci-iommu.yaml#
+$id: http://devicetree.org/schemas/hypervisor/pci-iommu.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
 title: virtio-iommu device using the virtio-pci transport
Documentation/devicetree/bindings/hypervisor/virtio-device.yaml renamed from Documentation/devicetree/bindings/virtio/virtio-device.yaml +1 -1
similarity index 93%
rename from Documentation/devicetree/bindings/virtio/virtio-device.yaml
rename to Documentation/devicetree/bindings/hypervisor/virtio-device.yaml
index 8c6919b..7b8d93b 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
 %YAML 1.2
 ---
-$id: http://devicetree.org/schemas/virtio/virtio-device.yaml#
+$id: http://devicetree.org/schemas/hypervisor/virtio-device.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
 title: Virtio device
Documentation/devicetree/bindings/i2c/i2c-virtio.yaml +2 -2
index 7d87ed8..99a0ce2 100644
@@ -11,10 +11,10 @@ maintainers:
 
 allOf:
   - $ref: /schemas/i2c/i2c-controller.yaml#
-  - $ref: /schemas/virtio/virtio-device.yaml#
+  - $ref: /schemas/hypervisor/virtio-device.yaml#
 
 description:
-  Virtio I2C device, see /schemas/virtio/virtio-device.yaml for more details.
+  Virtio I2C device, see /schemas/hypervisor/virtio-device.yaml for more details.
 
 properties:
   $nodename:
MAINTAINERS +1 -1
index f76ca28..27a5650 100644
@@ -21977,7 +21977,7 @@ L:	[email protected]
 S:	Maintained
 F:	Documentation/ABI/testing/sysfs-bus-vdpa
 F:	Documentation/ABI/testing/sysfs-class-vduse
-F:	Documentation/devicetree/bindings/virtio/
+F:	Documentation/devicetree/bindings/hypervisor/
 F:	Documentation/driver-api/virtio/
 F:	drivers/block/virtio_blk.c
 F:	drivers/crypto/virtio/
Signature · 1 line
1.8.3.1
#14 lore raw

PATCH v4 6/6 Driver: VMBus: Add device tree support

In reply to Saurabh Sengar

Update the driver to support device tree boot as well along with ACPI. At present the device tree parsing only provides the mmio region info and is not the exact copy of ACPI parsing. This is sufficient to cater all the current device tree usecases for VMBus.

Currently device tree is supported only for x86 systems.

---
[V4]
- used __maybe_unused for 'vmbus_of_match' and safeguard vmbus_acpi_device_ids under #ifdef

 drivers/hv/Kconfig     |  4 ++--
 drivers/hv/vmbus_drv.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 62 insertions(+), 4 deletions(-)
drivers/hv/Kconfig +2 -2
index 0747a8f..7e44d42 100644
@@ -4,8 +4,8 @@ menu "Microsoft Hyper-V guest support"
 
 config HYPERV
 	tristate "Microsoft Hyper-V client drivers"
-	depends on ACPI && ((X86 && X86_LOCAL_APIC && HYPERVISOR_GUEST) \
-		|| (ARM64 && !CPU_BIG_ENDIAN))
+	depends on (X86 && X86_LOCAL_APIC && HYPERVISOR_GUEST) \
+		|| (ACPI && ARM64 && !CPU_BIG_ENDIAN)
 	select PARAVIRT
 	select X86_HV_CALLBACK_VECTOR if X86
 	select VMAP_PFN
drivers/hv/vmbus_drv.c +60 -2

120 lines not on this page · raw message

Signature · 1 line
1.8.3.1
maintainer
#11 lore raw

Re: [PATCH v4 5/6] dt-bindings: hypervisor: VMBus

In reply to Saurabh Sengar
Quoted 9 lines · Saurabh Sengar

Add dt-bindings for Hyper-V VMBus.

---
 .../bindings/hypervisor/microsoft,vmbus.yaml       | 48 ++++++++++++++++++++++
 MAINTAINERS                                        |  1 +
 2 files changed, 49 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hypervisor/microsoft,vmbus.yaml

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
make[1]: *** Deleting file 'Documentation/devicetree/bindings/serial/brcm,bcm6345-uart.example.dtb' make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1508: dt_binding_check] Error 2

doc reference errors (make refcheckdocs):
Warning: MAINTAINERS references a file that doesn't exist: Documentation/devicetree/bindings/virtio/
MAINTAINERS: Documentation/devicetree/bindings/virtio/

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

maintainer
#12 lore raw

Re: [PATCH v4 5/6] dt-bindings: hypervisor: VMBus

Quoted 15 lines · Rob Herring
Quoted 9 lines · Saurabh Sengar

Add dt-bindings for Hyper-V VMBus.

---
 .../bindings/hypervisor/microsoft,vmbus.yaml       | 48 ++++++++++++++++++++++
 MAINTAINERS                                        |  1 +
 2 files changed, 49 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hypervisor/microsoft,vmbus.yaml

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

Quoted 6 lines

yamllint warnings/errors:

dtschema/dtc warnings/errors:
make[1]: *** Deleting file 'Documentation/devicetree/bindings/serial/brcm,bcm6345-uart.example.dtb' make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1508: dt_binding_check] Error 2

You can ignore this, it's a problem with the CI job.

Quoted 4 lines

doc reference errors (make refcheckdocs):
Warning: MAINTAINERS references a file that doesn't exist: Documentation/devicetree/bindings/virtio/
MAINTAINERS: Documentation/devicetree/bindings/virtio/

But this probably needs to be fixed.

Rob
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

maintainer
#8 lore raw

Re: [PATCH v4 4/6] dt-bindings: hypervisor: Rename virtio to hypervisor

In reply to Saurabh Sengar
Quoted 4 lines · Saurabh Sengar

Rename virtio folder to more generic hypervisor, so that this can accommodate more devices of similar type.

Quoted 11 lines
---
 Documentation/devicetree/bindings/gpio/gpio-virtio.yaml               | 4 ++--
 Documentation/devicetree/bindings/{virtio => hypervisor}/mmio.yaml    | 2 +-
 .../devicetree/bindings/{virtio => hypervisor}/pci-iommu.yaml         | 2 +-
 .../devicetree/bindings/{virtio => hypervisor}/virtio-device.yaml     | 2 +-
 Documentation/devicetree/bindings/i2c/i2c-virtio.yaml                 | 4 ++--
 MAINTAINERS                                                           | 2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)
 rename Documentation/devicetree/bindings/{virtio => hypervisor}/mmio.yaml (95%)
 rename Documentation/devicetree/bindings/{virtio => hypervisor}/pci-iommu.yaml (98%)
 rename Documentation/devicetree/bindings/{virtio => hypervisor}/virtio-device.yaml (93%)

virtio is used for more than just an interface to hypervisors. I think this should remain. Instead, I'd put vmbus under bindings/bus/.

Rob

Reviewed-by on v4 1/6
#2 lore raw

RE: [PATCH v4 1/6] drivers/clocksource/hyper-v: non ACPI support in hyperv clock

In reply to Saurabh Sengar

From: Saurabh Sengar <[email protected]> Sent: Monday, February 6, 2023 11:50 PM

Quoted 63 lines

Add a placeholder function for the hv_setup_stimer0_irq API to accommodate systems without ACPI support. Since this function is not utilized on x86/x64 systems and non-ACPI support is only intended for x86/x64 systems, a placeholder function is sufficient for now and can be improved upon if necessary in the future.

This change will make it easier to add device tree support for VMBus in subsequent commits.

---
 drivers/clocksource/hyperv_timer.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/clocksource/hyperv_timer.c +13 -3
index c0cef92..f32948c 100644
@@ -49,7 +49,7 @@
 
 static int stimer0_irq = -1;
 static int stimer0_message_sint;
-static DEFINE_PER_CPU(long, stimer0_evt);
+static __maybe_unused DEFINE_PER_CPU(long, stimer0_evt);
 
 /*
  * Common code for stimer0 interrupts coming via Direct Mode or
@@ -68,7 +68,7 @@ void hv_stimer0_isr(void)
  * stimer0 interrupt handler for architectures that support
  * per-cpu interrupts, which also implies Direct Mode.
  */
-static irqreturn_t hv_stimer0_percpu_isr(int irq, void *dev_id)
+static irqreturn_t __maybe_unused hv_stimer0_percpu_isr(int irq, void *dev_id)
 {
 	hv_stimer0_isr();
 	return IRQ_HANDLED;
@@ -196,6 +196,7 @@ void __weak hv_remove_stimer0_handler(void)
 {
 };
 
+#ifdef CONFIG_ACPI
 /* Called only on architectures with per-cpu IRQs (i.e., not x86/x64) */
 static int hv_setup_stimer0_irq(void)
 {
@@ -230,6 +231,16 @@ static void hv_remove_stimer0_irq(void)
 		stimer0_irq = -1;
 	}
 }
+#else
+static int hv_setup_stimer0_irq(void)
+{
+	return 0;
+}
+
+static void hv_remove_stimer0_irq(void)
+{
+}
+#endif
 
 /* hv_stimer_alloc - Global initialization of the clockevent and stimer0 */
 int hv_stimer_alloc(bool have_percpu_irqs)
--
Quoted 1 line

1.8.3.1

#4 lore raw

RE: [PATCH v4 2/6] Drivers: hv: allow non ACPI compilation for hv_is_hibernation_supported

In reply to Saurabh Sengar

From: Saurabh Sengar <[email protected]> Sent: Monday, February 6, 2023 11:50 PM

Quoted 6 lines

acpi_sleep_state_supported API is only define for CONFIG_ACPI flag and thus it can't be used for non-ACPI builds. Initially there won't be hibernation support for non ACPI builds.

This change will help adding device tree support in subsequent commits.

In keeping with the guideline to avoid references like "this patch" or "this change" in commit messages, I'd suggest wording the commit message something like the following:

acpi_sleep_state_supported() currently is defined only when CONFIG_ACPI=y. For future work to enable device tree builds, put this function under #ifdef CONFIG_ACPI. Otherwise, return 'false' from hv_is_hibernation_supported() as Hyper-V guest configs using device tree don't support hibernation.

With that update,
Reviewed-by: Michael Kelley

I gave a Reviewed-by on Patch 1 of this series, but the same comment applies about "this change" in that commit message.

Michael

Quoted 24 lines
---
 drivers/hv/hv_common.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/hv/hv_common.c +4 -1
index 52a6f89..370ec20 100644
@@ -234,7 +234,11 @@ void hv_setup_dma_ops(struct device *dev, bool coherent)
 
 bool hv_is_hibernation_supported(void)
 {
+#ifdef CONFIG_ACPI
 	return !hv_root_partition && acpi_sleep_state_supported(ACPI_STATE_S4);
+#else
+	return false;
+#endif
 }
 EXPORT_SYMBOL_GPL(hv_is_hibernation_supported);
 
--

1.8.3.1

Reviewed-by on v4 3/6
#6 lore raw

RE: [PATCH v4 3/6] Drivers: hv: vmbus: Convert acpi_device to more generic platform_device

In reply to Saurabh Sengar

From: Saurabh Sengar <[email protected]> Sent: Monday, February 6, 2023 11:50 PM

Quoted 3 lines

Use more generic platform device instead of acpi device. Also rename the function vmbus_acpi_remove to more generic name vmbus_mmio_remove.

Let me suggest a slightly expanded commit message along these lines:

VMBus driver code currently has direct dependency on ACPI and struct acpi_device. As a staging step toward optionally configuring based on device tree instead of ACPI, use a more generic platform device to reduce the dependency on ACPI where possible, though the dependency on ACPI is not completely removed. Also rename the function vmbus_acpi_remove() to the more generic vmbus_mmio_remove().

With this tweak,

Quoted 171 lines

---
[V4]
- rebased which fixed return type of 'vmbus_mmio_remove' from int to void

 drivers/hv/vmbus_drv.c | 58 ++++++++++++++++++++++++++++++--------------------
 1 file changed, 35 insertions(+), 23 deletions(-)
drivers/hv/vmbus_drv.c +5 -4
index d24dd65..7349715 100644
@@ -12,6 +12,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/device.h>
+#include <linux/platform_device.h>
 #include <linux/interrupt.h>
 #include <linux/sysctl.h>
 #include <linux/slab.h>
@@ -44,7 +45,7 @@ struct vmbus_dynid {
 	struct hv_vmbus_device_id id;
 };
 
-static struct acpi_device  *hv_acpi_dev;
+static struct device  *hv_dev;
 
 static int hyperv_cpuhp_online;
 
@@ -143,7 +144,7 @@ static int hv_die_panic_notify_crash(struct notifier_block *self,
 
 static int vmbus_exists(void)
 {
-	if (hv_acpi_dev == NULL)
+	if (hv_dev == NULL)
 		return -ENODEV;
 
 	return 0;
@@ -932,7 +933,7 @@ static int vmbus_dma_configure(struct device *child_device)
 	 * On x86/x64 coherence is assumed and these calls have no effect.
 	 */
 	hv_setup_dma_ops(child_device,
-		device_get_dma_attr(&hv_acpi_dev->dev) == DEV_DMA_COHERENT);
+		device_get_dma_attr(hv_dev) == DEV_DMA_COHERENT);
 	return 0;
 }
 
@@ -2090,7 +2091,7 @@ int vmbus_device_register(struct hv_device
 *child_device_obj)
 		     &child_device_obj->channel->offermsg.offer.if_instance);
 
 	child_device_obj->device.bus = &hv_bus;
-	child_device_obj->device.parent = &hv_acpi_dev->dev;
+	child_device_obj->device.parent = hv_dev;
 	child_device_obj->device.release = vmbus_device_release;
 
drivers/hv/vmbus_drv.c +1 -1
 	child_device_obj->device.dma_parms = &child_device_obj->dma_parms;
@@ -2262,7 +2263,7 @@ static acpi_status vmbus_walk_resources(struct
 acpi_resource *res, void *ctx)
 	return AE_OK;
 }
 
-static void vmbus_acpi_remove(struct acpi_device *device)
+static void vmbus_mmio_remove(void)
 {
 	struct resource *cur_res;
drivers/hv/vmbus_drv.c +3 -2
 	struct resource *next_res;
@@ -2441,13 +2442,14 @@ void vmbus_free_mmio(resource_size_t start,
 resource_size_t size)
 }
 EXPORT_SYMBOL_GPL(vmbus_free_mmio);
 
-static int vmbus_acpi_add(struct acpi_device *device)
+static int vmbus_acpi_add(struct platform_device *pdev)
 {
 	acpi_status result;
 	int ret_val = -ENODEV;
 	struct acpi_device *ancestor;
+	struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
 
-	hv_acpi_dev = device;
+	hv_dev = &device->dev;
 
 	/*
drivers/hv/vmbus_drv.c +26 -17
 	 * Older versions of Hyper-V for ARM64 fail to include the _CCA
@@ -2489,10 +2491,21 @@ static int vmbus_acpi_add(struct acpi_device *device)
 
 acpi_walk_err:
 	if (ret_val)
-		vmbus_acpi_remove(device);
+		vmbus_mmio_remove();
 	return ret_val;
 }
 
+static int vmbus_platform_driver_probe(struct platform_device *pdev)
+{
+	return vmbus_acpi_add(pdev);
+}
+
+static int vmbus_platform_driver_remove(struct platform_device *pdev)
+{
+	vmbus_mmio_remove();
+	return 0;
+}
+
 #ifdef CONFIG_PM_SLEEP
 static int vmbus_bus_suspend(struct device *dev)
 {
@@ -2658,15 +2671,15 @@ static int vmbus_bus_resume(struct device *dev)
 	.restore_noirq	= vmbus_bus_resume
 };
 
-static struct acpi_driver vmbus_acpi_driver = {
-	.name = "vmbus",
-	.ids = vmbus_acpi_device_ids,
-	.ops = {
-		.add = vmbus_acpi_add,
-		.remove = vmbus_acpi_remove,
-	},
-	.drv.pm = &vmbus_bus_pm,
-	.drv.probe_type = PROBE_FORCE_SYNCHRONOUS,
+static struct platform_driver vmbus_platform_driver = {
+	.probe = vmbus_platform_driver_probe,
+	.remove = vmbus_platform_driver_remove,
+	.driver = {
+		.name = "vmbus",
+		.acpi_match_table = ACPI_PTR(vmbus_acpi_device_ids),
+		.pm = &vmbus_bus_pm,
+		.probe_type = PROBE_FORCE_SYNCHRONOUS,
+	}
 };
 
 static void hv_kexec_handler(void)
@@ -2750,12 +2763,11 @@ static int __init hv_acpi_init(void)
 	/*
 	 * Get ACPI resources first.
 	 */
-	ret = acpi_bus_register_driver(&vmbus_acpi_driver);
-
+	ret = platform_driver_register(&vmbus_platform_driver);
 	if (ret)
 		return ret;
 
-	if (!hv_acpi_dev) {
+	if (!hv_dev) {
 		ret = -ENODEV;
 		goto cleanup;
 	}
@@ -2785,8 +2797,8 @@ static int __init hv_acpi_init(void)
 	return 0;
 
 cleanup:
-	acpi_bus_unregister_driver(&vmbus_acpi_driver);
-	hv_acpi_dev = NULL;
+	platform_driver_unregister(&vmbus_platform_driver);
+	hv_dev = NULL;
 	return ret;
 }
 
@@ -2839,7 +2851,7 @@ static void __exit vmbus_exit(void)
 
 	cpuhp_remove_state(hyperv_cpuhp_online);
 	hv_synic_free();
-	acpi_bus_unregister_driver(&vmbus_acpi_driver);
+	platform_driver_unregister(&vmbus_platform_driver);
 }
 
 
--

1.8.3.1

#13 lore raw

Re: [PATCH v4 5/6] dt-bindings: hypervisor: VMBus

In reply to Rob Herring
Quoted 23 lines · Rob Herring
Quoted 15 lines · Rob Herring
Quoted 9 lines · Saurabh Sengar

Add dt-bindings for Hyper-V VMBus.

---
 .../bindings/hypervisor/microsoft,vmbus.yaml       | 48 ++++++++++++++++++++++
 MAINTAINERS                                        |  1 +
 2 files changed, 49 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hypervisor/microsoft,vmbus.yaml

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

Quoted 6 lines

yamllint warnings/errors:

dtschema/dtc warnings/errors:
make[1]: *** Deleting file 'Documentation/devicetree/bindings/serial/brcm,bcm6345-uart.example.dtb' make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1508: dt_binding_check] Error 2

Quoted 8 lines

You can ignore this, it's a problem with the CI job.

Quoted 4 lines

doc reference errors (make refcheckdocs):
Warning: MAINTAINERS references a file that doesn't exist: Documentation/devicetree/bindings/virtio/
MAINTAINERS: Documentation/devicetree/bindings/virtio/

But this probably needs to be fixed.

I have updated MAINTAINERS as part of 4/6 patch, and there is no mention of Documentation/devicetree/bindings/virtio/ in MAINTAINERS post 4/6 patch. I have ran the tool locally as well on top of 4/6 and then 5/6 but it never reported this error.

Anyway as per your latest comment I should be moving VMBus to bus folder instead, so no need to worry about this.

Regards,
Saurabh

Quoted 2 lines

Rob

#9 lore raw

Re: [PATCH v4 4/6] dt-bindings: hypervisor: Rename virtio to hypervisor

In reply to Rob Herring
Quoted 17 lines · Rob Herring
Quoted 4 lines · Saurabh Sengar

Rename virtio folder to more generic hypervisor, so that this can accommodate more devices of similar type.

Quoted 11 lines
---
 Documentation/devicetree/bindings/gpio/gpio-virtio.yaml               | 4 ++--
 Documentation/devicetree/bindings/{virtio => hypervisor}/mmio.yaml    | 2 +-
 .../devicetree/bindings/{virtio => hypervisor}/pci-iommu.yaml         | 2 +-
 .../devicetree/bindings/{virtio => hypervisor}/virtio-device.yaml     | 2 +-
 Documentation/devicetree/bindings/i2c/i2c-virtio.yaml                 | 4 ++--
 MAINTAINERS                                                           | 2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)
 rename Documentation/devicetree/bindings/{virtio => hypervisor}/mmio.yaml (95%)
 rename Documentation/devicetree/bindings/{virtio => hypervisor}/pci-iommu.yaml (98%)
 rename Documentation/devicetree/bindings/{virtio => hypervisor}/virtio-device.yaml (93%)
Quoted 2 lines

virtio is used for more than just an interface to hypervisors. I think this should remain. Instead, I'd put vmbus under bindings/bus/.

Agree, will move to bus in v5

Quoted 2 lines

Rob

#15 lore raw

Re: [PATCH v4 6/6] Driver: VMBus: Add device tree support

In reply to Saurabh Sengar
Thank you for the patch! Perhaps something to improve:

Hi Saurabh,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on next-20230207]
[cannot apply to robh/for-next tip/timers/core brgl/gpio/for-next wsa/i2c/for-next linus/master v6.2-rc7 v6.2-rc6 v6.2-rc5 v6.2-rc7] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Saurabh-Sengar/drivers-clocksource-hyper-v-non-ACPI-support-in-hyperv-clock/20230207-155113
patch link:    https://lore.kernel.org/r/1675756199-5917-7-git-send-email-ssengar%40linux.microsoft.com
patch subject: [PATCH v4 6/6] Driver: VMBus: Add device tree support
config: i386-randconfig-a015 (https://download.01.org/0day-ci/archive/20230208/[email protected]/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/b3cd029f78e9c1f5cd1633e1ffc7c5a09deae98f
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Saurabh-Sengar/drivers-clocksource-hyper-v-non-ACPI-support-in-hyperv-clock/20230207-155113 git checkout b3cd029f78e9c1f5cd1633e1ffc7c5a09deae98f
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/hv/

If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

>> drivers/hv/vmbus_drv.c:2691:21: warning: attribute declaration must precede definition [-Wignored-attributes]
   static const struct __maybe_unused of_device_id vmbus_of_match[] = {
                       ^
   include/linux/compiler_attributes.h:355:56: note: expanded from macro '__maybe_unused'
   #define __maybe_unused                  __attribute__((__unused__))
                                                          ^
   include/linux/mod_devicetable.h:268:8: note: previous definition is here
   struct of_device_id {
          ^

1 warning generated.

vim +2691 drivers/hv/vmbus_drv.c

2690

> 2691	static const struct __maybe_unused of_device_id vmbus_of_match[] = {

2692 {
2693 .compatible = "microsoft,vmbus",
2694 },
2695 {
2696 /* sentinel */
2697 },
2698 };
2699 MODULE_DEVICE_TABLE(of, vmbus_of_match);
2700

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
#16 lore raw

Re: [PATCH v4 6/6] Driver: VMBus: Add device tree support

Quoted 10 lines · kernel test robot

Hi Saurabh,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on next-20230207]
[cannot apply to robh/for-next tip/timers/core brgl/gpio/for-next wsa/i2c/for-next linus/master v6.2-rc7 v6.2-rc6 v6.2-rc5 v6.2-rc7] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

All of your recent patches have build errors. Can you at least build test them before sending? It's a unnecessary noise in our mailboxes to get non-buildable patches, just to trigger compilation which you can easily do by your own. GCC is a free software...

Best regards,
Krzysztof

#17 lore raw

Re: [PATCH v4 6/6] Driver: VMBus: Add device tree support

Quoted 12 lines · Krzysztof Kozlowski
Quoted 10 lines · kernel test robot

Hi Saurabh,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on next-20230207]
[cannot apply to robh/for-next tip/timers/core brgl/gpio/for-next wsa/i2c/for-next linus/master v6.2-rc7 v6.2-rc6 v6.2-rc5 v6.2-rc7] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

Quoted 4 lines

All of your recent patches have build errors. Can you at least build test them before sending? It's a unnecessary noise in our mailboxes to get non-buildable patches, just to trigger compilation which you can easily do by your own. GCC is a free software...

For what it's worth, GCC does not have a warning like this, it just accepts the incorrect location of the attribute, which has gotten others in trouble before:

https://lore.kernel.org/CAHk-=wgf+kHeSZbpkZumWcTXUD7ordqTMvPRNL6aQVG1DSBDnQ@mail.gmail.com/

So the patch probably did build clean with GCC but that is one of the reasons that there is no longer a compiler monopoly for the kernel ;)

Cheers,
Nathan

#18 lore raw

Re: [PATCH v4 6/6] Driver: VMBus: Add device tree support

Quoted 18 lines · Nathan Chancellor
Quoted 12 lines · Krzysztof Kozlowski
Quoted 10 lines · kernel test robot

Hi Saurabh,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on next-20230207]
[cannot apply to robh/for-next tip/timers/core brgl/gpio/for-next wsa/i2c/for-next linus/master v6.2-rc7 v6.2-rc6 v6.2-rc5 v6.2-rc7] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

Quoted 4 lines

All of your recent patches have build errors. Can you at least build test them before sending? It's a unnecessary noise in our mailboxes to get non-buildable patches, just to trigger compilation which you can easily do by your own. GCC is a free software...

Quoted 8 lines

For what it's worth, GCC does not have a warning like this, it just accepts the incorrect location of the attribute, which has gotten others in trouble before:

https://lore.kernel.org/CAHk-=wgf+kHeSZbpkZumWcTXUD7ordqTMvPRNL6aQVG1DSBDnQ@mail.gmail.com/

So the patch probably did build clean with GCC but that is one of the reasons that there is no longer a compiler monopoly for the kernel ;)

OK then the patchset is reasonable/built enough.

Best regards,
Krzysztof