From patchwork Wed Mar 23 20:31:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael Kelley (LINUX)" X-Patchwork-Id: 12790115 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 BAEECC433EF for ; Wed, 23 Mar 2022 20:31:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344663AbiCWUdS (ORCPT ); Wed, 23 Mar 2022 16:33:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230260AbiCWUdM (ORCPT ); Wed, 23 Mar 2022 16:33:12 -0400 Received: from na01-obe.outbound.protection.outlook.com (mail-eus2azon11020016.outbound.protection.outlook.com [52.101.56.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86E148BF58; Wed, 23 Mar 2022 13:31:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fCJar78Fn7oCwKUFCh0QgzZXOQOcCVj9u4DQASmgelnvvpjuicIlKzVohLjSNXHWKAYcbCAuEGP/31FxDh6o9pPORn3k8PjvuL2f48tpXTgIKDDViN0LF/wNjnt/YNFrLnp79ALeN1E5U7ZKz1O5wEOnjMFZSdCetcpjtWFj/HLGM/K4WS8idHlAKf0oW7LajCz4a3TDVrVqNa3vNJrk5G2vjPCVhnC/fM9mxPm+ZM4E8+Gljzl1/4LWo/x7U+pvd5I7aPMJ1eBRwOBVwlgPos3Og237ezRULfoDgMJMwf2aGzrFMtJ9q4zKYPQmUE37OYsF0rR+aCvGaieelCbLSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rnw/CDnGeI3MpXk5h9WsPYZ6xWMVJWVMcUX7OVq+iUY=; b=ADTTN3EWpgwvz5O5uMyMad3LLC7UBBlsOtO3fULgMozfsuy7vUSxSD6lPCJTAsOFLOPOdB8vPNnG5H1djJlxBlbqOIUy0T2omZgZ62ioTUdIWNGuDzcXj6+3DaFJKNoRxj+n4pPQEGFMZTIrlGGmDOQrgFkaKO7pPRMEcMPNmX8PbPQWQdj+pN7UgralR+KlZf6vRu/EvzgkAU6o563KlUMz1C3wtvDbbIMZ7HeJ72uWwbWWckneOF1RHB5LN86c6IQyymNqxEmNITt1Um5MbzSkoShT7+6NmLhyRdnPdCvoLUs411kpZngZOF1pQSshWsRVcUwAePGlW1+O3a8qxg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rnw/CDnGeI3MpXk5h9WsPYZ6xWMVJWVMcUX7OVq+iUY=; b=DToV2q6MV0C49SOLGvpGqCXwas+exQHywvmb2aCt2sj+cODXo4qD98e4SFJZhry7WSsWWlVOslpMMISdm/BZGW6TvsvEgeZk3PcFvJBDkM9juHI9XWpV49gikcZ9OsuDGu4ZlI3osSgxq+Mk4f+jPorZlizZH7vFJqPuMHMvxg4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from DM6PR21MB1514.namprd21.prod.outlook.com (2603:10b6:5:22d::11) by SN6PR2101MB0942.namprd21.prod.outlook.com (2603:10b6:805:4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.8; Wed, 23 Mar 2022 20:31:40 +0000 Received: from DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::f8aa:99ff:9265:bb6b]) by DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::f8aa:99ff:9265:bb6b%4]) with mapi id 15.20.5123.008; Wed, 23 Mar 2022 20:31:40 +0000 From: Michael Kelley To: sthemmin@microsoft.com, kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, rafael@kernel.org, lenb@kernel.org, lorenzo.pieralisi@arm.com, robh@kernel.org, kw@linux.com, bhelgaas@google.com, hch@lst.de, m.szyprowski@samsung.com, robin.murphy@arm.com, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, iommu@lists.linux-foundation.org Cc: mikelley@microsoft.com Subject: [PATCH v2 1/2] Drivers: hv: vmbus: Propagate VMbus coherence to each VMbus device Date: Wed, 23 Mar 2022 13:31:11 -0700 Message-Id: <1648067472-13000-2-git-send-email-mikelley@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1648067472-13000-1-git-send-email-mikelley@microsoft.com> References: <1648067472-13000-1-git-send-email-mikelley@microsoft.com> X-ClientProxiedBy: MW3PR05CA0019.namprd05.prod.outlook.com (2603:10b6:303:2b::24) To DM6PR21MB1514.namprd21.prod.outlook.com (2603:10b6:5:22d::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 716ac052-5893-4635-5c81-08da0d0c22a4 X-MS-TrafficTypeDiagnostic: SN6PR2101MB0942:EE_ X-MS-Exchange-AtpMessageProperties: SA|SL X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xeo52j/nRTUYi9BIUlh8YwYp3FMk5ZuC88BJvT2rZ9OlzgEuvtnbKO1Gy7cyIjbrCI5ojOWnaockbDJscWo5A+hIVlQ5LHw8kKK8uPfJE6/ZvyjOAxFp5Qn9dwmjnCqu0cT0J0JVGDe+6yca2XnBRkVguuti8EbCPmSfdkPkolM0p9VUBj/o7Uq8gRAdragi0cX/vDRKCZGb7qyk21xU/EANHhUH/uIuXVNnKtz0/LyctLnzq1ankXBSODkxwLQrD2rgart1jdU3IOxWU4y+g82GeBapJLOddoC0JwHcw9FeAA+CxL+ckY5afwMZawuCZHeEF+u/XB4/KPSujTd2bPwYG7sUqtmsCWK7UgSOC3Z4BKZjfXGA2HiOkrtZMrtVs+DPo4P9M2L4/0k+xn2RTl575GM3f8PwiHBUTN6plsztkhwGT3gwX6IgJFnxXP0ctmirpdPUAYZ5ejyVTz1eTPANytJLj1pkKMm8kHRRJ9xfw4KHry0iZ1TGhlMHP4CGhCoucEcuQRWMAnGU9YXvGL6F3H4cGnO+pimS7f0sLMnw+x0eA7KN8alIQOxK9wwlVpoaVIrsRiUbxuIvL2iIze5FRdtgr29QkG0GBvoLp/+p8ReHIbwuEH0D3yVZVb+zVYs1evkPWICDyGm2jb69vpwwpjhx46vIzcq8M/wbLPk0FkZ6lNzPYVnv5i3ewggs+fW1ngwOaCJm7N+QKF3ZlBLEA6DScRpsT6igVUYKFE2H8w8zg5F3UHHndRmLNlHAN0BJmZL0+0HjI6nUytU+Gg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR21MB1514.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(451199009)(921005)(5660300002)(107886003)(316002)(7416002)(36756003)(38100700002)(82950400001)(82960400001)(38350700002)(2906002)(83380400001)(86362001)(66946007)(4326008)(8676002)(66476007)(66556008)(6486002)(10290500003)(8936002)(26005)(186003)(2616005)(6506007)(6512007)(508600001)(6666004)(52116002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2KbkfcCUZGqsxn2WvvxKPGDWJqVmoF0DZMC1x2tGqqq+tHVcv2uUPfb6GYy7ewk5GHsSacX/yplSh2GDuxxk7vEz9GuQkepupMvA8uWFx7BJEVOp3mmjBwjou2z9unEASJq8JEfyYlORm5AFqCyOJ1JS+/Wi3v6ARvG9csrNzp0/7ev8FRvWhiUnBKQaa1a/qOSIOXz0FOVl5aNoX8SP/veW6BrNpRK8inndsnVdIx98nxjUVwP6a9UItboBhOvnQjdiqe7txk89VmhFNimV+L+eyN4ydUGsQ2Rx8GuWotls/mZYAVXkfNQwLLvohdM1gpagEUcO7gfrbleHVXVYQq596uLptyNYqLmdjyLnQ3ZH8Cab8JH0Gv180JkLWCn1fsBJrLMHgHAeWXNywYK/Ah8MA2jFPhvc5IQYkoohfnPk6jYltRMsBLuTm8GHlq70wLwcHr9GMCuAbcamaJajZze7poT+Blzf5SHDTkWa1pYwfCOtFp/XvAGlU6/nPx/cEq1vVD4P8/uy7OYYoVTrNJOK4Vuz4kzLAbJDM86/mv6sFm2rum3ISIAZXrnVDKRQfAu2d2E7y2BgErcvmZxQeVM1hHEzqKK60VDoSDzGzzJa493y3dVysWJlwvhvBZOtljgDFJGmTRIL8C97f/I7tGasBJ0Tg4OZ+KXPh4x2deSYgDuW49Ma4T+3jBso6psUY2LhJfo3HagvDqdLOV3sgKx1mBgCi+2UQFsqHs8wNg44mZOGnrf+cp7t3TbkNeHosUN8vrFAIDAz+9ZsQiW5C3+hk+ZGr33WS3qMG5MP/f5TbDDis48SvV2l11tgmdoKVwyceJDOquaf7nxq7Obx9xC72Cq48hYn8iiel4R/KJxBrv6jnqQrqFD61olXRaD0Mx1eSQxugOnWQK2A1+ceid+ynrArcP0UlhWsEo7l30sNCjuIsUPHh/F/XORAjOqYahsQNZBdlBYVQlMN+Oi8liwXmiwDHRQUoKGcKjOKwO7AHIbZWOvPMosycJzzOybKb9/16w5jNsrJPGB94zxUaPSTnZzCDlud4SOPp/EOQEiv70IVjWpTKKk6rlxlZUSu2LoTTaryUThySIqXOxfyeUN86Pd+exw1wt5ZvL6T5Uo+GeaC3va8IwxXuGgc4uG/iJheQcGd9WrAAzb0LnRgjDXAaIo2uZZ9CsSFAJrmMy2q43g+MmPl4ub2KNgfZ3I4T563ZVofHTYu/g97LjZk09w6Ii1Ijt4ZJRIaNdjcro8weGIu1sHJpfktKRltiLJMn1ETwVBZCms9WPD/7E8xCmvLGZLiw7dhrG8iog10vtA/ZKlD/JPeVD0fcY9wrQOu80A5iAaSdmXi2MQb5zfKK3hY+vNhZuu5um4KPXL14htOBRAUwujKm1UfA8tvi/R5Oy8hRnML11Tv+wkpP+XI9HNyN2TGxC0m+sA5VpQ2fHacfFchLJliZmmn0XrzMTvoGPskBvNXaBACtHfpPcGKq6YLsVqr+pwb01Xwn5t7Teu/yWohS/9aTE3lQYGWTYhsL7yCf5TBwr0+tdgjGs/DG8noOo6j+infCi4HfiHJb3izwHAGR425tZsCEUTk1y1h32FU7OPiI5u8fmlu8SDnhm62Nh6u0jlm5bETINo397hp2gJpzJFoNCo7tAfl1lJaE3lErCBAftI/PHVpOYHJb40Terto48KIiYJDR0qt6Pj6evUAse0c8FQ8eR7gaXx9sR77FmWudpBaNkgTJdTEXLn/NojSDc8saL4TmS6l08w= X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 716ac052-5893-4635-5c81-08da0d0c22a4 X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1514.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2022 20:31:39.9361 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IyYxCAOnRrBwkbJBODYtbpc0Bs8hhLdnPzhy0Iplj9gaf1qWOkMvgrhi6y7MqevuYX6Bp7uuI23z9eyiUrp14w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR2101MB0942 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org VMbus synthetic devices are not represented in the ACPI DSDT -- only the top level VMbus device is represented. As a result, on ARM64 coherence information in the _CCA method is not specified for synthetic devices, so they default to not hardware coherent. Drivers for some of these synthetic devices have been recently updated to use the standard DMA APIs, and they are incurring extra overhead of unneeded software coherence management. Fix this by propagating coherence information from the VMbus node in ACPI to the individual synthetic devices. There's no effect on x86/x64 where devices are always hardware coherent. Signed-off-by: Michael Kelley Acked-by: Robin Murphy --- drivers/hv/hv_common.c | 11 +++++++++++ drivers/hv/vmbus_drv.c | 23 +++++++++++++++++++++++ include/asm-generic/mshyperv.h | 1 + 3 files changed, 35 insertions(+) diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c index 181d16b..820e814 100644 --- a/drivers/hv/hv_common.c +++ b/drivers/hv/hv_common.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -216,6 +217,16 @@ bool hv_query_ext_cap(u64 cap_query) } EXPORT_SYMBOL_GPL(hv_query_ext_cap); +void hv_setup_dma_ops(struct device *dev, bool coherent) +{ + /* + * Hyper-V does not offer a vIOMMU in the guest + * VM, so pass 0/NULL for the IOMMU settings + */ + arch_setup_dma_ops(dev, 0, 0, NULL, coherent); +} +EXPORT_SYMBOL_GPL(hv_setup_dma_ops); + bool hv_is_hibernation_supported(void) { return !hv_root_partition && acpi_sleep_state_supported(ACPI_STATE_S4); diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 12a2b37..2d2c54c 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -905,6 +905,14 @@ static int vmbus_probe(struct device *child_device) struct hv_device *dev = device_to_hv_device(child_device); const struct hv_vmbus_device_id *dev_id; + /* + * On ARM64, propagate the DMA coherence setting from the top level + * VMbus ACPI device to the child VMbus device being added here. + * 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); + dev_id = hv_vmbus_get_id(drv, dev); if (drv->probe) { ret = drv->probe(dev, dev_id); @@ -2428,6 +2436,21 @@ static int vmbus_acpi_add(struct acpi_device *device) hv_acpi_dev = device; + /* + * Older versions of Hyper-V for ARM64 fail to include the _CCA + * method on the top level VMbus device in the DSDT. But devices + * are hardware coherent in all current Hyper-V use cases, so fix + * up the ACPI device to behave as if _CCA is present and indicates + * hardware coherence. + */ + ACPI_COMPANION_SET(&device->dev, device); + if (IS_ENABLED(CONFIG_ACPI_CCA_REQUIRED) && + device_get_dma_attr(&device->dev) == DEV_DMA_NOT_SUPPORTED) { + pr_info("No ACPI _CCA found; assuming coherent device I/O\n"); + device->flags.cca_seen = true; + device->flags.coherent_dma = true; + } + result = acpi_walk_resources(device->handle, METHOD_NAME__CRS, vmbus_walk_resources, NULL); diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h index c08758b..c05d2ce 100644 --- a/include/asm-generic/mshyperv.h +++ b/include/asm-generic/mshyperv.h @@ -269,6 +269,7 @@ static inline int cpumask_to_vpset_noself(struct hv_vpset *vpset, u64 hv_ghcb_hypercall(u64 control, void *input, void *output, u32 input_size); void hyperv_cleanup(void); bool hv_query_ext_cap(u64 cap_query); +void hv_setup_dma_ops(struct device *dev, bool coherent); void *hv_map_memory(void *addr, unsigned long size); void hv_unmap_memory(void *addr); #else /* CONFIG_HYPERV */ From patchwork Wed Mar 23 20:31:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael Kelley (LINUX)" X-Patchwork-Id: 12790116 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 E2843C433FE for ; Wed, 23 Mar 2022 20:31:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344669AbiCWUdS (ORCPT ); Wed, 23 Mar 2022 16:33:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344660AbiCWUdN (ORCPT ); Wed, 23 Mar 2022 16:33:13 -0400 Received: from na01-obe.outbound.protection.outlook.com (mail-eus2azon11020016.outbound.protection.outlook.com [52.101.56.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8228B8C7E5; Wed, 23 Mar 2022 13:31:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c0+o2t+mCra/5lmQuhzGa3OYOvUI3eCInhI5zv2CFWPcInK35MUeJ7/z0VZin+C1NvhzabEZF52KZn26+10urIs/LLUxdMqPCBC8n+/qhFGFFBS8IEMrg1xP9UA6DZTxK5tbImm2HRZoWB8iev1BDsasNI3b8fQETpuFJ1h1b99XM21MmwAZeXrnA0/CVzVJ12Ao/LbITtgJ1vyJKpPjEOf/KQuxRwJdeCwyQ2DyP5v11KINIZmg+1+ZtfpMarsK38dRSL8RS1lbXVxsWUX8Ggzy1VoH6TAJzF8PBF8AHeMnJnd+84FxsV/Je2t8MtfxSj91WtOC1cWDqqLOfrPcwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AyO99w7s7VMNWuDh5lI4ielArWozmZ63exfDFTApM+0=; b=eih6srCKE1Qdz3H0JnECWtpfxwz/AzOFvivpevQSoz7ZOEdo4jaAYDhJNfRwRfFTTNAMDGP1erTfgCFTVNakMkN8CXxf/Q5cY7Y7cSP+diyVzgFriaqnSLjwSbZzE7BNHyvH3tGZQwuUmZnJ50XL9f9AwTAr3DINPkIhv5jo4hd75Few8y9pZ+PL9kyRK2YGViNNTdoZ3AP7+0QIO2abuAewNGbx/Wt5o36PuUGtqPEh1N4Tj7TZwLKwy02AcHbG2JB8nuOekwZMtgTnwZ0Jnk23lODhqtdzaPdLQap7IvD6ORh0z7sj6CAgwX51olag1bw3sElhmbpKWPXjKzM+KA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AyO99w7s7VMNWuDh5lI4ielArWozmZ63exfDFTApM+0=; b=Zd69c+i00gTjAH0Ab/5L2muIiEZqgmvjdZkmpafV1mZsNb6z1teMyRH5R1OfwUo7uNAVw6bNAXe4DLjhFaQ5xxBWaPGnz6q1anaqpxJADxvPTQ2Cz6zBOylEEh6l12V34fQIm14+hV5l8hTQI+mrQysE4eJ1/CWR2JYhR5IFgEE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from DM6PR21MB1514.namprd21.prod.outlook.com (2603:10b6:5:22d::11) by SN6PR2101MB0942.namprd21.prod.outlook.com (2603:10b6:805:4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.8; Wed, 23 Mar 2022 20:31:41 +0000 Received: from DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::f8aa:99ff:9265:bb6b]) by DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::f8aa:99ff:9265:bb6b%4]) with mapi id 15.20.5123.008; Wed, 23 Mar 2022 20:31:41 +0000 From: Michael Kelley To: sthemmin@microsoft.com, kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, rafael@kernel.org, lenb@kernel.org, lorenzo.pieralisi@arm.com, robh@kernel.org, kw@linux.com, bhelgaas@google.com, hch@lst.de, m.szyprowski@samsung.com, robin.murphy@arm.com, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, iommu@lists.linux-foundation.org Cc: mikelley@microsoft.com Subject: [PATCH v2 2/2] PCI: hv: Propagate coherence from VMbus device to PCI device Date: Wed, 23 Mar 2022 13:31:12 -0700 Message-Id: <1648067472-13000-3-git-send-email-mikelley@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1648067472-13000-1-git-send-email-mikelley@microsoft.com> References: <1648067472-13000-1-git-send-email-mikelley@microsoft.com> X-ClientProxiedBy: MW3PR05CA0019.namprd05.prod.outlook.com (2603:10b6:303:2b::24) To DM6PR21MB1514.namprd21.prod.outlook.com (2603:10b6:5:22d::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 09428e1d-bba0-48bb-6b21-08da0d0c235b X-MS-TrafficTypeDiagnostic: SN6PR2101MB0942:EE_ X-MS-Exchange-AtpMessageProperties: SA|SL X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y3ySo2lXKl6zIiZBW3nWjpUeHZVqaehBmfFITXC1425SoIpNTQDA6+2xJ7xJjaeWBzuMnsRsbFrTJi+UYhkVfGQUyEwwMIkqWY2s/5byy6hvYpVl4dHx0d/4clNF65JVQEcZuFTbRzrQi9T5/P6e19vOS04GN3zXcT5fs0Arp/rIuvG3V2y7eHEkkC80cd6kZ2m0F2nnNlgHZFSd4lEPJhCBa1VgwShKV5Lm9XBBxUQe4yfB8+FLAdiz/uYLqHeADkixhUNgKGr3uuPu+JZiE605EHPN6oOLl9IqLD5LaJN/E3YcKIT13NaGOTn+0gvLAEL1rk0hGyneuxihj+zoZdLfhhaAANI+TTEsV83evMYJglLjsApls5D5ikvYaumhNDbZvr8Lp+hbI9aTgQZ4cm7NCUJ3VuScIwIMXTpgTvcEMp+jT+SDPIOh2OJ2vgwoisT+XKIRVijEdZiOy1f32nbn9utpBwZhlgEP9InJmz2qdp8aPed5oe4qVWyScXuAt0x5qCARSwwdRSBXnHu9lP8rYEKItDkjSyfb1j+2rbxWBCa+8vyrUzIhXmyJozLYYjsf0XjPjdza8YRe4VxnIBCuVXX4+10x55TY+kxgrB/cZnfbNRBen8Igirhe+ijNKObCCIcV20DOijPO0JNcX0Qf6PkQan+M79hXjfbBsSFKeOWXcWQIwKWzKeyqN8kJGpxWJ2JxoEeLMe5tmJHumTi25/ay06sP8RddaGt3CJpM5Gh0KkpZUp6IKZv/I6ABoNUlHPPVIPu6mGVLK0DPpw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR21MB1514.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(451199009)(921005)(5660300002)(107886003)(316002)(7416002)(36756003)(38100700002)(82950400001)(82960400001)(38350700002)(2906002)(86362001)(66946007)(4326008)(8676002)(66476007)(66556008)(6486002)(10290500003)(8936002)(26005)(186003)(2616005)(6506007)(6512007)(508600001)(6666004)(52116002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FhRkgwpAeiWFcCBuhlJ98YHisBWoxzDuNIdCAEzn1DCh+slkcVDt3H0NyIrfo6kP1Kj8xKKABHiXySoloJVuZhUEHdKvhh3Tk5kxUAV7njwTxMD9dJlk0EtQqvy2TQnw3v7FlWtY4DeOKR/eiBnnH/wVJagNxTvP4WIVWC57kbl9sjoB6dPEoRUxYuCmwccmKLkTJTH4mbeqsv2F7pYFxNY9UA3/4uFCaoQq2V7pi0secaiZZyimwlyD61hGLN5dfkrQkKRDEpDHdMLbiwuZt59oEGk1CxMI1hvkYZ5iL2pOwtoNH0S/4IteRSs4A/o08gxRr3OCeSwRH85rTgBXLggZpk+7H583TMICR/6C5rtADVgnWPCiRlK0Zu4GjVNRFZbUZkkM5nhfRe9wgf85EWbF0O2TW30Aw1yho3iVAuDkzwKigCNwVjuY+EPcgrNg+zCte5b3KGmWXGV7R44aXC+TdKsb8J74yjZh8f9By7IWbnLnCplsVjFjSEMY75Kw8i6OMzgNJ7EmAxue7HFFKheFkKIeUNE6UbhcC7i4V6mitmCLq+3LfFi8DYmYaaXzy+Ld3kXqYcATtr7CdBs9D9wQA9zzFqsMg+c9+H4BtFM8mBAmK1BHo8b45B8bETLZDIdNwZBPlXuFQXP2DJXqK/kwWSqpaxa7w312/Iord2azBxc1CpmcWqWqhYgKQTflHFp5f2XsfUBj/G8Cvg/OOyqrPtECbA3m1HH+XsCYm/F1hjy2TqtVJFReBhg2EhTumtPEdXYIbrYdpc//8qE5TuXlLhcZRMmFOYkwXVppYLxX4KFfl01lioaRgWjcgu57poJn6DWpXHR/zBWQVhm3BK5V/Qtb3mWFo/fTf/IyOcOn3SXbaZqrI8YYp8yr+K/npejt5f1jaTv19Aqlz35+vm9ml0OHkrGbPMH+Be5D1keT/E9ySige557JnrepQc8eYlbVGKBPiwtgyl9uq3lRC3p9EfPat/t/P3iAIrM9A0s9gdo3AaWYNPNQV6TCRukwGp6yoEBkISNgr4P2A5782kd0QEeWTvTConbn3Lh7Wx5/2xS4uPt8PRkeRqI9yMbUpxL7DnRnMBD3Gg7yvnG7gQcqobgWmV+wt4+w+0SjK5KnFtqvlmVjmxbA/Fi/xVOSUP2pvnL7Sk8nhWPt786WjSPFW43ObvGPJXgbL1K0QeobZZ/6060IKSgOw0hyrBbO6QPB4zCnlbfuo6pHVb108SGRJvNn+Rgx8ut24G4xbC3Z62iJBheGYblDw8FlBLb4H41RKoAzmiJvlYr9Jk/3RMoEG6xz0RSobsdnCCCRkteozWMaoSNpFaeI6pfH3H5qmZTBIteUt7Jb16f0igL0DlTXRSdzzvmWOMA3Vx/L/IrreyP1Udawqu7iY/bG5fCa56Cr5WmP3ar4jn8ugGmfD9SOv/Kyjx85z69jCKrk9iGFxnAYcxd5rE88Aysj0PFvvp36B/j4ubsM3oV8chNhKIqITLarGYKdpfm4UfBJlRHeEqWqqzU6hh2VyjMKiIzLLop5QtGeR6Gu8Hy7NUpc3YDZ0nlyxVVCA7vMohFuwCkKHQP13Ah0qmZvidSf5H+9FZt2d2grWvs53QaNPrIZG0rT234mRLzJKt6ls2iZbMZP2rOu9UPqQhQXsOQUMjinF96+4XA8FG2UPkJZdiCz1Q/pUcb4NoZydWTbgIWZKTJeuSxIgzYk/rlEOw2rF9UmLrge/xT1EE/Uzw/Utz5DHQ== X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 09428e1d-bba0-48bb-6b21-08da0d0c235b X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1514.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2022 20:31:41.1358 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xUQrvMNEm3AMc2z4Ef8geSz7jrsMZSOQhMhmOV8hj1vdshsTkOl+bG3q+eQQAbdhMUY3pSQgKq/BUOAvBOnMUw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR2101MB0942 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org PCI pass-thru devices in a Hyper-V VM are represented as a VMBus device and as a PCI device. The coherence of the VMbus device is set based on the VMbus node in ACPI, but the PCI device has no ACPI node and defaults to not hardware coherent. This results in extra software coherence management overhead on ARM64 when devices are hardware coherent. Fix this by setting up the PCI host bus so that normal PCI mechanisms will propagate the coherence of the VMbus device to the PCI device. There's no effect on x86/x64 where devices are always hardware coherent. Signed-off-by: Michael Kelley Acked-by: Boqun Feng Acked-by: Robin Murphy --- drivers/pci/controller/pci-hyperv.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index ae0bc2f..88b3b56 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -3404,6 +3404,15 @@ static int hv_pci_probe(struct hv_device *hdev, hbus->bridge->domain_nr = dom; #ifdef CONFIG_X86 hbus->sysdata.domain = dom; +#elif defined(CONFIG_ARM64) + /* + * Set the PCI bus parent to be the corresponding VMbus + * device. Then the VMbus device will be assigned as the + * ACPI companion in pcibios_root_bridge_prepare() and + * pci_dma_configure() will propagate device coherence + * information to devices created on the bus. + */ + hbus->sysdata.parent = hdev->device.parent; #endif hbus->hdev = hdev;