From nobody Tue Sep 9 17:13:15 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 7A611C6FD1D for ; Mon, 20 Mar 2023 07:47:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230215AbjCTHr4 (ORCPT ); Mon, 20 Mar 2023 03:47:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbjCTHrr (ORCPT ); Mon, 20 Mar 2023 03:47:47 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CA5A012594; Mon, 20 Mar 2023 00:47:44 -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 F184B20FAACE; Mon, 20 Mar 2023 00:47:43 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com F184B20FAACE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679298464; bh=9hqMgwt+9rfgzKvMywqn/H23HiHnKG9S9L6A/+1pzh0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=UQ7XWCsoz4aLvEyssGIFuVqFwdiiGt+efQ0p6tQOvIL/9k8jKDly/VSaoLZhnwWNp L73ZiX5d4HKIBjvL3dC3TM0HPuXtjNkBoH8AikaPPbl9RiTp7A6PhoT1xL1XiX97VZ YMqo7II67x8opgdoV5l2WSFvAcqC4PRuWOdP1Hek= From: Saurabh Sengar To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, mikelley@microsoft.com Subject: [PATCH v9 1/5] drivers/clocksource/hyper-v: non ACPI support in hyperv clock Date: Mon, 20 Mar 2023 00:47:36 -0700 Message-Id: <1679298460-11855-2-git-send-email-ssengar@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679298460-11855-1-git-send-email-ssengar@linux.microsoft.com> References: <1679298460-11855-1-git-send-email-ssengar@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" 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. Signed-off-by: Saurabh Sengar Reviewed-by: Michael Kelley --- drivers/clocksource/hyperv_timer.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyper= v_timer.c index c0cef92b12b8..f32948c8a96f 100644 --- a/drivers/clocksource/hyperv_timer.c +++ b/drivers/clocksource/hyperv_timer.c @@ -49,7 +49,7 @@ static bool direct_mode_enabled; =20 static int stimer0_irq =3D -1; static int stimer0_message_sint; -static DEFINE_PER_CPU(long, stimer0_evt); +static __maybe_unused DEFINE_PER_CPU(long, stimer0_evt); =20 /* * Common code for stimer0 interrupts coming via Direct Mode or @@ -68,7 +68,7 @@ EXPORT_SYMBOL_GPL(hv_stimer0_isr); * 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) { }; =20 +#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 =3D -1; } } +#else +static int hv_setup_stimer0_irq(void) +{ + return 0; +} + +static void hv_remove_stimer0_irq(void) +{ +} +#endif =20 /* hv_stimer_alloc - Global initialization of the clockevent and stimer0 */ int hv_stimer_alloc(bool have_percpu_irqs) --=20 2.34.1 From nobody Tue Sep 9 17:13:15 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 30D9BC7618A for ; Mon, 20 Mar 2023 07:47:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230206AbjCTHrv (ORCPT ); Mon, 20 Mar 2023 03:47:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229665AbjCTHrr (ORCPT ); Mon, 20 Mar 2023 03:47:47 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DE7B2125A3; Mon, 20 Mar 2023 00:47:44 -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 1476120FAAD4; Mon, 20 Mar 2023 00:47:44 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1476120FAAD4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679298464; bh=4PRW0VI+oZvbTmFAcVbsrAFK92yD8Gwq6n0ZpwB9zPo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=NFOdiDJZUwvLWn/3+im5vYYkUdZEqchvLQ+qCTga3O3f2mlYIR6k+3iV5fWWH/Gko aCNoxTVlCJVu7RyAIAvKVZXlvgYfIfYr/kjkYMMuAtTcFWB3VD8QOityCWjF3KITHi NqoECmyNJBYO/pnFNRStMYv4y/e+T9W+MF2MvYuc= From: Saurabh Sengar To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, mikelley@microsoft.com Subject: [PATCH v9 2/5] ACPI: bus: Add stub acpi_sleep_state_supported() in non-ACPI cases Date: Mon, 20 Mar 2023 00:47:37 -0700 Message-Id: <1679298460-11855-3-git-send-email-ssengar@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679298460-11855-1-git-send-email-ssengar@linux.microsoft.com> References: <1679298460-11855-1-git-send-email-ssengar@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" acpi_sleep_state_supported() is defined only when CONFIG_ACPI=3Dy. The function is in acpi_bus.h, and acpi_bus.h can only be used in CONFIG_ACPI=3Dy cases. Add the stub function to linux/acpi.h to make compilation successful for !CONFIG_ACPI cases. Signed-off-by: Saurabh Sengar Acked-by: Rafael J. Wysocki --- include/linux/acpi.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/acpi.h b/include/linux/acpi.h index efff750f326d..d331f76b0c19 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1075,6 +1075,11 @@ static inline u32 acpi_osc_ctx_get_cxl_control(struc= t acpi_osc_context *context) return 0; } =20 +static inline bool acpi_sleep_state_supported(u8 sleep_state) +{ + return false; +} + #endif /* !CONFIG_ACPI */ =20 #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC --=20 2.34.1 From nobody Tue Sep 9 17:13:15 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 03B2BC7618A for ; Mon, 20 Mar 2023 07:48:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230260AbjCTHsN (ORCPT ); Mon, 20 Mar 2023 03:48:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230195AbjCTHrt (ORCPT ); Mon, 20 Mar 2023 03:47:49 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C5D6A12590; Mon, 20 Mar 2023 00:47:44 -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 2B9C320FAEC2; Mon, 20 Mar 2023 00:47:44 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2B9C320FAEC2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679298464; bh=kCtr1lBlf7j2Mhd1zlGqb7Klz5qlzuGWzb9TdRoa9Nc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=h24kRzpZ1piu4JIWsThNpoPshq1QFeUxfdMhmGcT9oxm9BCzs9vu9HGBmgEjYDrs+ bsAlp5Jtva2N1IqUznNzg8JFa8jbCMI+qRn75nkTgpROKBd7si1KteQy0Azca0Vb3J b3xZovE+aDvuRYjME3J2OKo4PbotzGN8k9XDQCnY= From: Saurabh Sengar To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, mikelley@microsoft.com Subject: [PATCH v9 3/5] Drivers: hv: vmbus: Convert acpi_device to more generic platform_device Date: Mon, 20 Mar 2023 00:47:38 -0700 Message-Id: <1679298460-11855-4-git-send-email-ssengar@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679298460-11855-1-git-send-email-ssengar@linux.microsoft.com> References: <1679298460-11855-1-git-send-email-ssengar@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" VMBus driver code currently has direct dependency on ACPI and struct acpi_device. As a staging step toward optionally configuring based on Devicetree 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(). Signed-off-by: Saurabh Sengar Reviewed-by: Michael Kelley --- drivers/hv/vmbus_drv.c | 58 +++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 229353f1e9c2..3ad2fa2b92e7 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -44,7 +45,7 @@ struct vmbus_dynid { struct hv_vmbus_device_id id; }; =20 -static struct acpi_device *hv_acpi_dev; +static struct device *hv_dev; =20 static int hyperv_cpuhp_online; =20 @@ -143,7 +144,7 @@ static DEFINE_MUTEX(hyperv_mmio_lock); =20 static int vmbus_exists(void) { - if (hv_acpi_dev =3D=3D NULL) + if (hv_dev =3D=3D NULL) return -ENODEV; =20 return 0; @@ -932,7 +933,7 @@ static int vmbus_dma_configure(struct device *child_dev= ice) * 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) =3D=3D DEV_DMA_COHERENT); + device_get_dma_attr(hv_dev) =3D=3D DEV_DMA_COHERENT); return 0; } =20 @@ -2081,7 +2082,7 @@ int vmbus_device_register(struct hv_device *child_dev= ice_obj) &child_device_obj->channel->offermsg.offer.if_instance); =20 child_device_obj->device.bus =3D &hv_bus; - child_device_obj->device.parent =3D &hv_acpi_dev->dev; + child_device_obj->device.parent =3D hv_dev; child_device_obj->device.release =3D vmbus_device_release; =20 child_device_obj->device.dma_parms =3D &child_device_obj->dma_parms; @@ -2253,7 +2254,7 @@ static acpi_status vmbus_walk_resources(struct acpi_r= esource *res, void *ctx) return AE_OK; } =20 -static void vmbus_acpi_remove(struct acpi_device *device) +static void vmbus_mmio_remove(void) { struct resource *cur_res; struct resource *next_res; @@ -2432,13 +2433,14 @@ void vmbus_free_mmio(resource_size_t start, resourc= e_size_t size) } EXPORT_SYMBOL_GPL(vmbus_free_mmio); =20 -static int vmbus_acpi_add(struct acpi_device *device) +static int vmbus_acpi_add(struct platform_device *pdev) { acpi_status result; int ret_val =3D -ENODEV; struct acpi_device *ancestor; + struct acpi_device *device =3D ACPI_COMPANION(&pdev->dev); =20 - hv_acpi_dev =3D device; + hv_dev =3D &device->dev; =20 /* * Older versions of Hyper-V for ARM64 fail to include the _CCA @@ -2480,10 +2482,21 @@ static int vmbus_acpi_add(struct acpi_device *devic= e) =20 acpi_walk_err: if (ret_val) - vmbus_acpi_remove(device); + vmbus_mmio_remove(); return ret_val; } =20 +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) { @@ -2649,15 +2662,15 @@ static const struct dev_pm_ops vmbus_bus_pm =3D { .restore_noirq =3D vmbus_bus_resume }; =20 -static struct acpi_driver vmbus_acpi_driver =3D { - .name =3D "vmbus", - .ids =3D vmbus_acpi_device_ids, - .ops =3D { - .add =3D vmbus_acpi_add, - .remove =3D vmbus_acpi_remove, - }, - .drv.pm =3D &vmbus_bus_pm, - .drv.probe_type =3D PROBE_FORCE_SYNCHRONOUS, +static struct platform_driver vmbus_platform_driver =3D { + .probe =3D vmbus_platform_driver_probe, + .remove =3D vmbus_platform_driver_remove, + .driver =3D { + .name =3D "vmbus", + .acpi_match_table =3D ACPI_PTR(vmbus_acpi_device_ids), + .pm =3D &vmbus_bus_pm, + .probe_type =3D PROBE_FORCE_SYNCHRONOUS, + } }; =20 static void hv_kexec_handler(void) @@ -2741,12 +2754,11 @@ static int __init hv_acpi_init(void) /* * Get ACPI resources first. */ - ret =3D acpi_bus_register_driver(&vmbus_acpi_driver); - + ret =3D platform_driver_register(&vmbus_platform_driver); if (ret) return ret; =20 - if (!hv_acpi_dev) { + if (!hv_dev) { ret =3D -ENODEV; goto cleanup; } @@ -2776,8 +2788,8 @@ static int __init hv_acpi_init(void) return 0; =20 cleanup: - acpi_bus_unregister_driver(&vmbus_acpi_driver); - hv_acpi_dev =3D NULL; + platform_driver_unregister(&vmbus_platform_driver); + hv_dev =3D NULL; return ret; } =20 @@ -2830,7 +2842,7 @@ static void __exit vmbus_exit(void) =20 cpuhp_remove_state(hyperv_cpuhp_online); hv_synic_free(); - acpi_bus_unregister_driver(&vmbus_acpi_driver); + platform_driver_unregister(&vmbus_platform_driver); } =20 =20 --=20 2.34.1 From nobody Tue Sep 9 17:13:15 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 DF4ADC6FD1D for ; Mon, 20 Mar 2023 07:48:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230249AbjCTHsJ (ORCPT ); Mon, 20 Mar 2023 03:48:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230185AbjCTHrt (ORCPT ); Mon, 20 Mar 2023 03:47:49 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1199D125AB; Mon, 20 Mar 2023 00:47:44 -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 4284A20FAEC9; Mon, 20 Mar 2023 00:47:44 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4284A20FAEC9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679298464; bh=4FMYgFngPsCYjftlQoUOLXjlLUIuzh3R5fN/lo5rhQo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZsbSHZVJy6lV9o3h1gc0pFly1b83s0GIjPS8J1O1F+b7GGqESOpDrWlw/3P8NcP8d dky8mTLBtrXkWFKgj2CMmrz5rw0cWWtz826raSUz1Jd+P1P5f2Y2SyIhDW/qsXfemj GZgtnh5ejgIO4av8KvU0uoFv/r37K7cDwjMC4tbo= From: Saurabh Sengar To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, mikelley@microsoft.com Subject: [PATCH v9 4/5] dt-bindings: bus: VMBus Date: Mon, 20 Mar 2023 00:47:39 -0700 Message-Id: <1679298460-11855-5-git-send-email-ssengar@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679298460-11855-1-git-send-email-ssengar@linux.microsoft.com> References: <1679298460-11855-1-git-send-email-ssengar@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" Add dt-bindings for Hyper-V VMBus. Signed-off-by: Saurabh Sengar Reviewed-by: Rob Herring --- .../bindings/bus/microsoft,vmbus.yaml | 54 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 55 insertions(+) create mode 100644 Documentation/devicetree/bindings/bus/microsoft,vmbus.y= aml diff --git a/Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml b/D= ocumentation/devicetree/bindings/bus/microsoft,vmbus.yaml new file mode 100644 index 000000000000..a8d40c766dcd --- /dev/null +++ b/Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml @@ -0,0 +1,54 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/bus/microsoft,vmbus.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Microsoft Hyper-V VMBus + +maintainers: + - Saurabh Sengar + +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 =3D <2>; + #size-cells =3D <1>; + bus { + compatible =3D "simple-bus"; + #address-cells =3D <2>; + #size-cells =3D <1>; + ranges; + + vmbus@ff0000000 { + compatible =3D "microsoft,vmbus"; + #address-cells =3D <2>; + #size-cells =3D <1>; + ranges =3D <0x0f 0xf0000000 0x0f 0xf0000000 0x10000000>; + }; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 216a61805c93..3cfe67af51f1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9540,6 +9540,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/bus/microsoft,vmbus.yaml F: Documentation/virt/hyperv F: Documentation/networking/device_drivers/ethernet/microsoft/netvsc.rst F: arch/arm64/hyperv --=20 2.34.1 From nobody Tue Sep 9 17:13:15 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 AD938C6FD1D for ; Mon, 20 Mar 2023 07:48:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230214AbjCTHsF (ORCPT ); Mon, 20 Mar 2023 03:48:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230122AbjCTHrs (ORCPT ); Mon, 20 Mar 2023 03:47:48 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4FFF4125B1; Mon, 20 Mar 2023 00:47:47 -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 5991120FAED2; Mon, 20 Mar 2023 00:47:44 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5991120FAED2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679298464; bh=GM5+GaMg13JEPlmbB8fyrcDYf5aGInVhNK1lqkzJoEE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=CP3IsgcRGHuzf3gla+JV6awMwByLeqXxrm6kj3YOPrhQAcwsXbEnVWtkFlAiF+QLo q2R8k0aRJ1F6bXOVh98Fxu0kVm+vKnd0K+OrbjE2Whcywwi+gvKDqhXIzJU02nbUYm LAm8dRRJUOV0K52Sirn+mDkcjBU2VgzxE/HoquKw= From: Saurabh Sengar To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, mikelley@microsoft.com Subject: [PATCH v9 5/5] Driver: VMBus: Add Devicetree support Date: Mon, 20 Mar 2023 00:47:40 -0700 Message-Id: <1679298460-11855-6-git-send-email-ssengar@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679298460-11855-1-git-send-email-ssengar@linux.microsoft.com> References: <1679298460-11855-1-git-send-email-ssengar@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" Update the driver to support Devicetree boot as well along with ACPI. At present the Devicetree parsing only provides the mmio region info and is not the exact copy of ACPI parsing. This is sufficient to cater all the current Devicetree usecases for VMBus. Currently Devicetree is supported only for x86 systems. Signed-off-by: Saurabh Sengar Reviewed-by: Michael Kelley --- [V9] - Add vmbus_mmio_remove for error handling - Remove logic from !acpi_disabled to acpi_disabled=20 drivers/hv/Kconfig | 5 ++-- drivers/hv/vmbus_drv.c | 66 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 65 insertions(+), 6 deletions(-) diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig index 0747a8f1fcee..47132b30b7ee 100644 --- a/drivers/hv/Kconfig +++ b/drivers/hv/Kconfig @@ -4,11 +4,12 @@ menu "Microsoft Hyper-V guest support" =20 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 + select OF_EARLY_FLATTREE if OF help Select this option to run Linux as a Hyper-V client operating system. diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 3ad2fa2b92e7..5de2d3bb8289 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -2143,7 +2144,7 @@ void vmbus_device_unregister(struct hv_device *device= _obj) device_unregister(&device_obj->device); } =20 - +#ifdef CONFIG_ACPI /* * VMBUS is an acpi enumerated device. Get the information we * need from DSDT. @@ -2253,6 +2254,7 @@ static acpi_status vmbus_walk_resources(struct acpi_r= esource *res, void *ctx) =20 return AE_OK; } +#endif =20 static void vmbus_mmio_remove(void) { @@ -2273,7 +2275,7 @@ static void vmbus_mmio_remove(void) } } =20 -static void vmbus_reserve_fb(void) +static void __maybe_unused vmbus_reserve_fb(void) { resource_size_t start =3D 0, size; struct pci_dev *pdev; @@ -2433,6 +2435,7 @@ void vmbus_free_mmio(resource_size_t start, resource_= size_t size) } EXPORT_SYMBOL_GPL(vmbus_free_mmio); =20 +#ifdef CONFIG_ACPI static int vmbus_acpi_add(struct platform_device *pdev) { acpi_status result; @@ -2485,10 +2488,54 @@ static int vmbus_acpi_add(struct platform_device *p= dev) vmbus_mmio_remove(); return ret_val; } +#else +static int vmbus_acpi_add(struct platform_device *pdev) +{ + return 0; +} +#endif + +static int vmbus_device_add(struct platform_device *pdev) +{ + struct resource **cur_res =3D &hyperv_mmio; + struct of_range range; + struct of_range_parser parser; + struct device_node *np =3D pdev->dev.of_node; + int ret; + + hv_dev =3D &pdev->dev; + + ret =3D of_range_parser_init(&parser, np); + if (ret) + return ret; + + for_each_of_range(&parser, &range) { + struct resource *res; + + res =3D kzalloc(sizeof(*res), GFP_KERNEL); + if (!res) { + vmbus_mmio_remove(); + return -ENOMEM; + } + + res->name =3D "hyperv mmio"; + res->flags =3D range.flags; + res->start =3D range.cpu_addr; + res->end =3D range.cpu_addr + range.size; + + *cur_res =3D res; + cur_res =3D &res->sibling; + } + + return ret; +} =20 static int vmbus_platform_driver_probe(struct platform_device *pdev) { - return vmbus_acpi_add(pdev); + if (acpi_disabled) + return vmbus_device_add(pdev); + else + return vmbus_acpi_add(pdev); } =20 static int vmbus_platform_driver_remove(struct platform_device *pdev) @@ -2634,7 +2681,17 @@ static int vmbus_bus_resume(struct device *dev) #define vmbus_bus_resume NULL #endif /* CONFIG_PM_SLEEP */ =20 -static const struct acpi_device_id vmbus_acpi_device_ids[] =3D { +static const __maybe_unused struct of_device_id vmbus_of_match[] =3D { + { + .compatible =3D "microsoft,vmbus", + }, + { + /* sentinel */ + }, +}; +MODULE_DEVICE_TABLE(of, vmbus_of_match); + +static const __maybe_unused struct acpi_device_id vmbus_acpi_device_ids[] = =3D { {"VMBUS", 0}, {"VMBus", 0}, {"", 0}, @@ -2668,6 +2725,7 @@ static struct platform_driver vmbus_platform_driver = =3D { .driver =3D { .name =3D "vmbus", .acpi_match_table =3D ACPI_PTR(vmbus_acpi_device_ids), + .of_match_table =3D of_match_ptr(vmbus_of_match), .pm =3D &vmbus_bus_pm, .probe_type =3D PROBE_FORCE_SYNCHRONOUS, } --=20 2.34.1