From nobody Sat Sep 13 17:03:36 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 72EA4C64EC3 for ; Tue, 31 Jan 2023 18:10:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231657AbjAaSKU (ORCPT ); Tue, 31 Jan 2023 13:10:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231444AbjAaSKS (ORCPT ); Tue, 31 Jan 2023 13:10:18 -0500 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 760B91B54D; Tue, 31 Jan 2023 10:10:17 -0800 (PST) Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 39E6C20DDD0A; Tue, 31 Jan 2023 10:10:17 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 39E6C20DDD0A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1675188617; bh=fDi0m5SyE7+dA+NV6/8hnqsdAW8zJoIlpf8Mpr+lH/Q=; h=From:To:Subject:Date:In-Reply-To:References:From; b=UPBLZHxWLk7ouTZD5X0Tij6sHjQBGOIIr+j+Yv9SvBYNjMKXO1kvLu1EYvHBVILtt 3Zzx2jJ+4L0lSTwGbcl6VBajfKCG/6B/bdrhEqTX77YK3jFC7gMzC5oGHqaNUuvgXD GioSWwXxPDTWB7fjNuvfHXrbI+df2ar4QjON42l8= From: Saurabh Sengar To: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, daniel.lezcano@linaro.org, tglx@linutronix.de, virtualization@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, mikelley@microsoft.com, ssengar@microsoft.com Subject: [PATCH v2 1/6] drivers/clocksource/hyper-v: non ACPI support in hyperv clock Date: Tue, 31 Jan 2023 10:10:04 -0800 Message-Id: <1675188609-20913-2-git-send-email-ssengar@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1675188609-20913-1-git-send-email-ssengar@linux.microsoft.com> References: <1675188609-20913-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 This change will make it easier to add device tree support for VMBus in subsequent commits. Signed-off-by: Saurabh Sengar --- 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.25.1 From nobody Sat Sep 13 17:03:36 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 EAEC4C636D4 for ; Tue, 31 Jan 2023 18:10:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231433AbjAaSKY (ORCPT ); Tue, 31 Jan 2023 13:10:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231476AbjAaSKS (ORCPT ); Tue, 31 Jan 2023 13:10:18 -0500 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9E1A22194B; Tue, 31 Jan 2023 10:10:17 -0800 (PST) Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 5266E20DE342; Tue, 31 Jan 2023 10:10:17 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5266E20DE342 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1675188617; bh=N4m8eTBLEQ3pQvSAw3zhPyK5+Dh9KUtxaoiQbxVw8Hk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=MT5Cs0TOL4U5Somh7wlFDgMXQo/WPD/1uSvXW2bYjP1tJMKkjlYNw6aKwOax73Ve9 SKZaPFcZ4/X4RvKDoYR7YwNr53l7EECCKeWS6WpLgyGztTN8j2uMZsn4bAhv5Zgu9j i9OJ5KoN6YcjH21ntwF2uINlxCtovlXTl6lwErDY= From: Saurabh Sengar To: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, daniel.lezcano@linaro.org, tglx@linutronix.de, virtualization@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, mikelley@microsoft.com, ssengar@microsoft.com Subject: [PATCH v2 2/6] Drivers: hv: allow non ACPI compilation for hv_is_hibernation_supported Date: Tue, 31 Jan 2023 10:10:05 -0800 Message-Id: <1675188609-20913-3-git-send-email-ssengar@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1675188609-20913-1-git-send-email-ssengar@linux.microsoft.com> References: <1675188609-20913-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 API is only define for CONFIG_ACPI flag and thus it can't be used for non-ACPI builds. Initaly there won't be hibernate support for non ACPI builds. This change will help adding device tree support in subsequent commits. Signed-off-by: Saurabh Sengar --- drivers/hv/hv_common.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c index 52a6f89ccdbd..370ec20d1993 100644 --- a/drivers/hv/hv_common.c +++ b/drivers/hv/hv_common.c @@ -234,7 +234,11 @@ EXPORT_SYMBOL_GPL(hv_setup_dma_ops); =20 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); =20 --=20 2.25.1 From nobody Sat Sep 13 17:03:36 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 5BB74C38142 for ; Tue, 31 Jan 2023 18:10:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231665AbjAaSK0 (ORCPT ); Tue, 31 Jan 2023 13:10:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230013AbjAaSKT (ORCPT ); Tue, 31 Jan 2023 13:10:19 -0500 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A523525E09; Tue, 31 Jan 2023 10:10:17 -0800 (PST) Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 6AA1120DE346; Tue, 31 Jan 2023 10:10:17 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 6AA1120DE346 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1675188617; bh=ANW5SmReljM/ZqznaSaYgwM0EI1m+kZRgs2ecj5BRas=; h=From:To:Subject:Date:In-Reply-To:References:From; b=rj3ua2kL83Z0agsaWPMMpmsz1F8WNVCqvekG8Bacm/FGsJJREglCeP792UZTDVAZN SgCEyziKFYAK/PpxYS0Zmj3uZKzQOX6MP5doiPPbvOiGZXS/ldV1KVAMoR340iH0eC QGhIwMbXB9rjwYA/E3Zd72ASp/2QcJ1bN/TaCSvw= From: Saurabh Sengar To: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, daniel.lezcano@linaro.org, tglx@linutronix.de, virtualization@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, mikelley@microsoft.com, ssengar@microsoft.com Subject: [PATCH v2 3/6] Drivers: hv: vmbus: Convert acpi_device to platform_device Date: Tue, 31 Jan 2023 10:10:06 -0800 Message-Id: <1675188609-20913-4-git-send-email-ssengar@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1675188609-20913-1-git-send-email-ssengar@linux.microsoft.com> References: <1675188609-20913-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" Use more generic platform device instead of acpi device. Also rename the function vmbus_acpi_remove to more generic name vmbus_mmio_remove. Signed-off-by: Saurabh Sengar --- drivers/hv/vmbus_drv.c | 78 +++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 32 deletions(-) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index d24dd65b33d4..49030e756b9f 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 platform_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->dev) =3D=3D DEV_DMA_COHERENT); return 0; } =20 @@ -2090,7 +2091,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->dev; child_device_obj->device.release =3D vmbus_device_release; =20 child_device_obj->device.dma_parms =3D &child_device_obj->dma_parms; @@ -2262,7 +2263,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; @@ -2441,13 +2442,15 @@ 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 platform_device *ancestor; + struct acpi_device *adev =3D to_acpi_device(&pdev->dev); =20 - hv_acpi_dev =3D device; + hv_dev =3D pdev; + adev->fwnode.dev =3D &pdev->dev; =20 /* * Older versions of Hyper-V for ARM64 fail to include the _CCA @@ -2456,15 +2459,16 @@ static int vmbus_acpi_add(struct acpi_device *devic= e) * up the ACPI device to behave as if _CCA is present and indicates * hardware coherence. */ - ACPI_COMPANION_SET(&device->dev, device); + ACPI_COMPANION_SET(&pdev->dev, ACPI_COMPANION(&pdev->dev)); if (IS_ENABLED(CONFIG_ACPI_CCA_REQUIRED) && - device_get_dma_attr(&device->dev) =3D=3D DEV_DMA_NOT_SUPPORTED) { + device_get_dma_attr(&pdev->dev) =3D=3D DEV_DMA_NOT_SUPPORTED) { + struct acpi_device *adev_node =3D ACPI_COMPANION(&pdev->dev); pr_info("No ACPI _CCA found; assuming coherent device I/O\n"); - device->flags.cca_seen =3D true; - device->flags.coherent_dma =3D true; + adev_node->flags.cca_seen =3D true; + adev_node->flags.coherent_dma =3D true; } =20 - result =3D acpi_walk_resources(device->handle, METHOD_NAME__CRS, + result =3D acpi_walk_resources(ACPI_HANDLE(&pdev->dev), METHOD_NAME__CRS, vmbus_walk_resources, NULL); =20 if (ACPI_FAILURE(result)) @@ -2473,9 +2477,9 @@ static int vmbus_acpi_add(struct acpi_device *device) * Some ancestor of the vmbus acpi device (Gen1 or Gen2 * firmware) is the VMOD that has the mmio ranges. Get that. */ - for (ancestor =3D acpi_dev_parent(device); ancestor; - ancestor =3D acpi_dev_parent(ancestor)) { - result =3D acpi_walk_resources(ancestor->handle, METHOD_NAME__CRS, + for (ancestor =3D to_platform_device(pdev->dev.parent); ancestor; + ancestor =3D to_platform_device(ancestor->dev.parent)) { + result =3D acpi_walk_resources(ACPI_HANDLE(&ancestor->dev), METHOD_NAME_= _CRS, vmbus_walk_resources, NULL); =20 if (ACPI_FAILURE(result)) @@ -2489,10 +2493,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) { @@ -2658,15 +2673,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) @@ -2750,12 +2765,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; } @@ -2785,8 +2799,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 @@ -2839,7 +2853,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.25.1 From nobody Sat Sep 13 17:03:36 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 1BCBEC38142 for ; Tue, 31 Jan 2023 18:10:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230054AbjAaSKf (ORCPT ); Tue, 31 Jan 2023 13:10:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231648AbjAaSKT (ORCPT ); Tue, 31 Jan 2023 13:10:19 -0500 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C90FA25E27; Tue, 31 Jan 2023 10:10:17 -0800 (PST) Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 82A9F20DE349; Tue, 31 Jan 2023 10:10:17 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 82A9F20DE349 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1675188617; bh=Bo1Cw+VywhyDQcgWGZuK7oyHRAyzlfuMCm8VaFb4YAM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=pg9+FQh770ejizrOiZ/X53MWdAvo2ADyCRyNiHS2YoLW1kSxbRI9Dd5fgzAPndBsh HoGzsaePEIpbTHoV+2gPjAd1hvHPaKa3UJs3E1e9D2b6ZfSKAg/+m0rx0gVexLpi5V pDZnBqn+CeZisrcIV2Uzk8Knv0Jg4iDYJsqu5E28= From: Saurabh Sengar To: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, daniel.lezcano@linaro.org, tglx@linutronix.de, virtualization@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, mikelley@microsoft.com, ssengar@microsoft.com Subject: [PATCH v2 4/6] dt-bindings: hypervisor: Rename virtio to hypervisor Date: Tue, 31 Jan 2023 10:10:07 -0800 Message-Id: <1675188609-20913-5-git-send-email-ssengar@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1675188609-20913-1-git-send-email-ssengar@linux.microsoft.com> References: <1675188609-20913-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" Rename virtio folder to more generic hypervisor, so that this can accommodate more devices of similar type. Signed-off-by: Saurabh Sengar --- .../devicetree/bindings/{virtio =3D> hypervisor}/mmio.yaml | 2 +- .../devicetree/bindings/{virtio =3D> hypervisor}/pci-iommu.yaml | 2 +- .../bindings/{virtio =3D> hypervisor}/virtio-device.yaml | 2 +- MAINTAINERS | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename Documentation/devicetree/bindings/{virtio =3D> hypervisor}/mmio.yam= l (95%) rename Documentation/devicetree/bindings/{virtio =3D> hypervisor}/pci-iomm= u.yaml (98%) rename Documentation/devicetree/bindings/{virtio =3D> hypervisor}/virtio-d= evice.yaml (93%) diff --git a/Documentation/devicetree/bindings/virtio/mmio.yaml b/Documenta= tion/devicetree/bindings/hypervisor/mmio.yaml similarity index 95% rename from Documentation/devicetree/bindings/virtio/mmio.yaml rename to Documentation/devicetree/bindings/hypervisor/mmio.yaml index 0aa8433f0a5e..8492c9b4fec9 100644 --- a/Documentation/devicetree/bindings/virtio/mmio.yaml +++ b/Documentation/devicetree/bindings/hypervisor/mmio.yaml @@ -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# =20 title: virtio memory mapped devices diff --git a/Documentation/devicetree/bindings/virtio/pci-iommu.yaml b/Docu= mentation/devicetree/bindings/hypervisor/pci-iommu.yaml similarity index 98% rename from Documentation/devicetree/bindings/virtio/pci-iommu.yaml rename to Documentation/devicetree/bindings/hypervisor/pci-iommu.yaml index 972a785a42de..52de535fd4ef 100644 --- a/Documentation/devicetree/bindings/virtio/pci-iommu.yaml +++ b/Documentation/devicetree/bindings/hypervisor/pci-iommu.yaml @@ -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# =20 title: virtio-iommu device using the virtio-pci transport diff --git a/Documentation/devicetree/bindings/virtio/virtio-device.yaml b/= Documentation/devicetree/bindings/hypervisor/virtio-device.yaml similarity index 93% rename from Documentation/devicetree/bindings/virtio/virtio-device.yaml rename to Documentation/devicetree/bindings/hypervisor/virtio-device.yaml index 8c6919ba9497..7b8d93b06237 100644 --- a/Documentation/devicetree/bindings/virtio/virtio-device.yaml +++ b/Documentation/devicetree/bindings/hypervisor/virtio-device.yaml @@ -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# =20 title: Virtio device diff --git a/MAINTAINERS b/MAINTAINERS index 263d37a129b1..9bc5b88b723a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -21967,7 +21967,7 @@ L: virtualization@lists.linux-foundation.org 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/ --=20 2.25.1 From nobody Sat Sep 13 17:03:36 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 1DAABC38142 for ; Tue, 31 Jan 2023 18:10:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231687AbjAaSKd (ORCPT ); Tue, 31 Jan 2023 13:10:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231644AbjAaSKT (ORCPT ); Tue, 31 Jan 2023 13:10:19 -0500 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 47BBF2884D; Tue, 31 Jan 2023 10:10:18 -0800 (PST) Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 9A96520DFDBF; Tue, 31 Jan 2023 10:10:17 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 9A96520DFDBF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1675188617; bh=aolDgf0ZKmA1dIvXP/OLbXrz+i5/r4RkpCnFJWskn6w=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XhFYOZ5zsW06gmNDjCX8xlCrymk2F9BhPsEXvR9/xI2wHtfEIBQr1s3Bs3F3GJg6e vohocTceW2F4c2LX+iYT0AOi9q7dEutF/VcR4tV3wLpkAFX4noleRLV+9F0+goj98u QPBIkVVVrqWCpKTp7PovS5nSvRe43RO4V2jJl7o4= From: Saurabh Sengar To: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, daniel.lezcano@linaro.org, tglx@linutronix.de, virtualization@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, mikelley@microsoft.com, ssengar@microsoft.com Subject: [PATCH v2 5/6] dt-bindings: hypervisor: Add dt-bindings for VMBus Date: Tue, 31 Jan 2023 10:10:08 -0800 Message-Id: <1675188609-20913-6-git-send-email-ssengar@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1675188609-20913-1-git-send-email-ssengar@linux.microsoft.com> References: <1675188609-20913-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 --- .../bindings/hypervisor/msft,vmbus.yaml | 50 +++++++++++++++++++ .../devicetree/bindings/vendor-prefixes.yaml | 2 + MAINTAINERS | 1 + 3 files changed, 53 insertions(+) create mode 100644 Documentation/devicetree/bindings/hypervisor/msft,vmbus= .yaml diff --git a/Documentation/devicetree/bindings/hypervisor/msft,vmbus.yaml b= /Documentation/devicetree/bindings/hypervisor/msft,vmbus.yaml new file mode 100644 index 000000000000..8f50d6097c48 --- /dev/null +++ b/Documentation/devicetree/bindings/hypervisor/msft,vmbus.yaml @@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hypervisor/msft,vmbus.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Microsoft Hyper-V VMBus device tree bindings + +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: msft,vmbus + + ranges: true + + '#address-cells': + const: 2 + + '#size-cells': + const: 1 + +required: + - compatible + - ranges + - '#address-cells' + - '#size-cells' + +additionalProperties: false + +examples: + - | + / { + compatible =3D "foo"; + model =3D "foo"; + #address-cells =3D <0x02>; + #size-cells =3D <0x02>; + + vmbus@ff0000000 { + #address-cells =3D <0x02>; + #size-cells =3D <0x01>; + compatible =3D "msft,vmbus"; + ranges =3D <0x00 0x00 0x0f 0xf0000000 0x10000000>; + }; + }; diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Docum= entation/devicetree/bindings/vendor-prefixes.yaml index 1f7a519a936f..ab74ea97535f 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -876,6 +876,8 @@ patternProperties: deprecated: true "^mscc,.*": description: Microsemi Corporation + "^msft,.*": + description: Microsoft Corporation "^msi,.*": description: Micro-Star International Co. Ltd. "^mstar,.*": diff --git a/MAINTAINERS b/MAINTAINERS index 9bc5b88b723a..c749782b0cff 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9496,6 +9496,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/msft,vmbus.yaml F: Documentation/virt/hyperv F: Documentation/networking/device_drivers/ethernet/microsoft/netvsc.rst F: arch/arm64/hyperv --=20 2.25.1 From nobody Sat Sep 13 17:03:36 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 88CECC636CC for ; Tue, 31 Jan 2023 18:10:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230494AbjAaSKa (ORCPT ); Tue, 31 Jan 2023 13:10:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231650AbjAaSKT (ORCPT ); Tue, 31 Jan 2023 13:10:19 -0500 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4BFFF28865; Tue, 31 Jan 2023 10:10:18 -0800 (PST) Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id B2F6B20DFE14; Tue, 31 Jan 2023 10:10:17 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B2F6B20DFE14 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1675188617; bh=2Oq3rLHSInRpCaH6L9jH9KNuBdNY6d/bl/THZjFDmv0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=N9NFWF+FtHhqTmI33iFD7aDObg0jR3F88cvzGrZRh0vJsPIB+Dp3fERD0gCMq8gRy axOPqo2AgV4txx3gSALFHG/JeE3fC1yq+V4C2mZJR/LW1x+RzdlcjBXjBrx1szlEPp sIyOdGBEaFLYJTfYfC66wgS27ZEqqPeNMR7bAzPY= From: Saurabh Sengar To: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, daniel.lezcano@linaro.org, tglx@linutronix.de, virtualization@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, mikelley@microsoft.com, ssengar@microsoft.com Subject: [PATCH v2 6/6] Driver: VMBus: Add device tree support Date: Tue, 31 Jan 2023 10:10:09 -0800 Message-Id: <1675188609-20913-7-git-send-email-ssengar@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1675188609-20913-1-git-send-email-ssengar@linux.microsoft.com> References: <1675188609-20913-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 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. Signed-off-by: Saurabh Sengar --- drivers/hv/vmbus_drv.c | 75 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 49030e756b9f..1741f1348f9f 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -2152,7 +2152,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. @@ -2262,6 +2262,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) { @@ -2282,7 +2283,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; @@ -2442,6 +2443,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; @@ -2496,10 +2498,68 @@ static int vmbus_acpi_add(struct platform_device *p= dev) vmbus_mmio_remove(); return ret_val; } +#else + +static int vmbus_device_add(struct platform_device *pdev) +{ + struct resource **cur_res =3D &hyperv_mmio; + struct device_node *np; + u32 *ranges, len; + u64 start; + int nr_ranges, child_cells =3D 2, cur_cell =3D 0, ret =3D 0; + + hv_dev =3D pdev; + np =3D pdev->dev.of_node; + + nr_ranges =3D device_property_count_u32(&pdev->dev, "ranges"); + if (nr_ranges < 0) + return nr_ranges; + ranges =3D kcalloc(nr_ranges, sizeof(u32), GFP_KERNEL); + if (!ranges) + return -ENOMEM; + + if (device_property_read_u32_array(&pdev->dev, "ranges", ranges, nr_range= s)) { + ret =3D -EINVAL; + goto free_ranges; + } + + while (cur_cell < nr_ranges) { + struct resource *res; + + /* The first u64 in the ranges description isn't used currently. */ + cur_cell =3D cur_cell + child_cells; + start =3D ranges[cur_cell++]; + start =3D (start << 32) | ranges[cur_cell++]; + len =3D ranges[cur_cell++]; + + res =3D kzalloc(sizeof(*res), GFP_ATOMIC); + if (!res) { + ret =3D -ENOMEM; + goto free_ranges; + } + + res->name =3D "hyperv mmio"; + res->flags =3D IORESOURCE_MEM | IORESOURCE_MEM_64; + res->start =3D start; + res->end =3D start + len; + + *cur_res =3D res; + cur_res =3D &res->sibling; + } + +free_ranges: + kfree(ranges); + return ret; +} +#endif =20 static int vmbus_platform_driver_probe(struct platform_device *pdev) { +#ifdef CONFIG_ACPI return vmbus_acpi_add(pdev); +#else + return vmbus_device_add(pdev); +#endif } =20 static int vmbus_platform_driver_remove(struct platform_device *pdev) @@ -2645,6 +2705,16 @@ static int vmbus_bus_resume(struct device *dev) #define vmbus_bus_resume NULL #endif /* CONFIG_PM_SLEEP */ =20 +static const struct of_device_id vmbus_of_match[] =3D { + { + .compatible =3D "msft,vmbus", + }, + { + /* sentinel */ + }, +}; +MODULE_DEVICE_TABLE(of, vmbus_of_match); + static const struct acpi_device_id vmbus_acpi_device_ids[] =3D { {"VMBUS", 0}, {"VMBus", 0}, @@ -2679,6 +2749,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.25.1