From mboxrd@z Thu Jan 1 00:00:00 1970 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 smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D2AE9C433F5 for ; Thu, 17 Mar 2022 16:25:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 9DBFA417B6; Thu, 17 Mar 2022 16:25:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4_7suEucudIA; Thu, 17 Mar 2022 16:25:52 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id 63AA541912; Thu, 17 Mar 2022 16:25:52 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3D24BC0012; Thu, 17 Mar 2022 16:25:52 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3FC28C000B for ; Thu, 17 Mar 2022 16:25:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 38E0940017 for ; Thu, 17 Mar 2022 16:25:49 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=microsoft.com Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Lnc4A2ilR_Cy for ; Thu, 17 Mar 2022 16:25:48 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from na01-obe.outbound.protection.outlook.com (mail-cusazlp170110003.outbound.protection.outlook.com [IPv6:2a01:111:f403:c111::3]) by smtp2.osuosl.org (Postfix) with ESMTPS id 5D77040502 for ; Thu, 17 Mar 2022 16:25:48 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jso8lGDRloSWDlJ9ed9eAN6Lu1mI6F2skw+wU6uioHTK0AYsg8FOc+DLR6Qit71Hj9MGUB8yMSuigJgTexkDWvkG+GlbXg5LSZWCguHeMPdXDEMHEqdkkHBni9Y/n65dxxMCiIDj0pUxsMryLpDEYfl4qnBua/23adB7Nr2x9y8qj0ibK+4YKGqMnO8bbGKqqFBMS6Pi6h6/TgV0ZhwW8f16Lh/VMTkcV7zI3I0ZBiqB5CCdKoTksx/u3pB+6kkgwYB4HTn9QFFh6V6wIygYi4XdJf436/a93VNytvMPRf20IoQvPkAmzW5Fi6M4kvK343ZgE9tLiYa6murvlvQhcQ== 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=TMBkvB8XqJXPIW9KcFtQrPV7sFII7sr9r1YK92fPbUg=; b=d+BvDfcDIhmBuHaZNbzSRDxH7F4kjAN685yNS284908+AH0j8718JeaexYEjhfKJg4/IT8OU84rSctkPIm7M1U6tnzEhh4h9+pK7IH8jJYMjLvgsTpbYLQydgpBaO/0L0TjKpEiLmSV6R8yLqwJOIPOJGHWB+s8CK4Krz9YwSBLUbghFJbwwrXuku/fQCRbL9akaSOkvwOxN907o4m+tMMdR/B4iJxFwELbjdhLrzQSUkP1cn6Ba53o5kvBOnW/9AbJl+38UPZar6EVOQgl4fFLofhjZoI+yBaFsBWItXiyA15DqeIpJ0wUZNKUaAAsBKTHXdzz+0kvzf9JZzTWUvw== 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=TMBkvB8XqJXPIW9KcFtQrPV7sFII7sr9r1YK92fPbUg=; b=g/T2hVXJton/8y0wyTwv8nl2Mb45A0mPQkEj7j4zKmcpxAYjNbLxHMxxlGgEA0yOTZoefNfTrg0acSvE3FF1sUjPKhJI1NexYJGJwk0GkjgSZs0qd68BBB2PUEyOqVOyaJywYGoSd1epWFZwcHGNiB29PNZMH/Bbg3Dn5/TigUc= 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 BL0PR2101MB1796.namprd21.prod.outlook.com (2603:10b6:207:19::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.7; Thu, 17 Mar 2022 16:25:46 +0000 Received: from DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::8c81:f644:fc1c:1357]) by DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::8c81:f644:fc1c:1357%4]) with mapi id 15.20.5102.007; Thu, 17 Mar 2022 16:25:45 +0000 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 Subject: [PATCH 4/4 RESEND] PCI: hv: Propagate coherence from VMbus device to PCI device Date: Thu, 17 Mar 2022 09:25:11 -0700 Message-Id: <1647534311-2349-5-git-send-email-mikelley@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1647534311-2349-1-git-send-email-mikelley@microsoft.com> References: <1647534311-2349-1-git-send-email-mikelley@microsoft.com> X-ClientProxiedBy: MW4P222CA0001.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::6) 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: 6eb045ae-5cb7-4bea-3391-08da0832c9e7 X-MS-TrafficTypeDiagnostic: BL0PR2101MB1796: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: 6nmNVD7+VrwOL1LWsCZ5yDAm6zK6hd01a13m7Ds1JvPeSQwm7+Pr5aptTDpmmKIvVFUmvdjesTWxChcUU6+8WZtykwJO+4o5X/lgpmFBxvhnIAdqsYIAH00ZEOwWK0RF3O2yZCeAsUMCnurN8aX+R1MLxeflPdX5jztN498INWwWP7VUxEiRxJ+TLUGDZhmAWggxU29Mx2BKIlt7FBFCtnm+mnEowNXqAWUkbZYtTvLVHQ8/4+3uYxLgiixyq8xkCl9YWeGxrQRj+lcuAv7SYafWr5FU3+zGVE4CKtJ2mEGcuELFHbtF40+5N+eTw550xDekrNOw2uCGY3Te6r+WePilbBVzVHRRg9wS78skHEqRSD1z+Dv8H5NPm/q4pY1b46wJyfOL4Kr387Le9sGTNvITZ9I+H9k6oSD8T8HTu+SJC9M85oWBp25fpqG8WO/rZVOEZ6BxmXR219lKDA/NAsJ+XMWm/SySiu8U7CSOscqEn8v8CL4TobWM5zezEIU1HNh++3JIK0fawXogIIugJ6sn3NutNj6K4ARnlCrAeG9GKtZOdsTy/GNaMdosChCqCdyUD0quaV7pjK3NTXCrxkHvSlfNSWUM+qyA6MxJwI4TMoajXwN5R7VMaNWZd7mPC5pB3HY0iLl6LwcRtgxgVobsP3/keE9krt4p0qumeduBJjm+i9NacG4mL7DoYUI1FZD6Sp+xc/cCBJU+PHwOe8IzE/nWd6gz1dvNWH/cufqKXYR1EsOVt6FQPi1wGxj+I7Mt6F9WBIWTJ2xE5PEvfA== 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)(6666004)(4326008)(8676002)(7416002)(66476007)(66556008)(66946007)(6506007)(921005)(508600001)(82950400001)(10290500003)(82960400001)(52116002)(38350700002)(6486002)(38100700002)(8936002)(2906002)(83380400001)(107886003)(5660300002)(6512007)(86362001)(26005)(186003)(36756003)(316002)(2616005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?HFUBH3kH254ypgDiOcIzPk4/7ervIBIjyVW02Sb9jCkJvtPt7xF4ilfprTIN?= =?us-ascii?Q?CQWrzE8bA/t1HvTJ8gDdLjMkwwdDZi2w8VzQn3QGHVSzFSFL6aH/SuJcq/Qm?= =?us-ascii?Q?PJhCfjCCm/LY5Hq/2KtKhsiyGPvGhAyh8Ooz4D0aWIr8BszlT1tY7JyyHaJT?= =?us-ascii?Q?lW0Kz1qJ8hIBjqyHU8EjbgcqkTtnyJ39TEJNQbCWh470pEeGUhSdcw2myMvd?= =?us-ascii?Q?HuTscoSbLutYefnVRf85s0was1A7kvsX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?Q?i2MLsbgV2EgLpVQApUF/z9tGvyWnInkJbBPjZ5LmryiHVVcn/V6knSxv/Rau?= =?us-ascii?Q?n/Gxc9uiOj29pzFxstTSxHYFmP9bX8tvBG4H/LA4Kil+uVnkEeJzN+2jla5W?= =?us-ascii?Q?t6q3oyl8gmPqOmod+bNm4cxsqJoOEG8Sm/HiBjRDSQgZTGnBHxHmrW19T6rm?= =?us-ascii?Q?XMyMhUU/8CmPrd7Pg9os+64J32bJYRC12+TijTRg1BMLBEdfOOrOWNfS10F4?= =?us-ascii?Q?KoA1bX+RP1JTAoLvxv2Qpp3mivH8lrd5qtrFDNuRB8HADmpy3dMt11iuiU9x?= =?us-ascii?Q?aZQ61EumhJk8AGLYkYoEjNnuoCzImscAHmEVArZIdtLeD6khIi28ig=3D=3D?= X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6eb045ae-5cb7-4bea-3391-08da0832c9e7 X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1514.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2022 16:25:45.8216 (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: mkT0jZx7Ru7C6rkvMwD+JnVn2oeWLXOkfGR44Zn5QUH5Lv7k+sI95cLck/lq0g+rCxkjare7PYTEofc7/+1lYQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR2101MB1796 Cc: mikelley@microsoft.com X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Michael Kelley via iommu Reply-To: Michael Kelley Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" 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 propagating 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 --- drivers/pci/controller/pci-hyperv.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index ae0bc2f..14276f5 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -49,6 +49,7 @@ #include #include #include +#include #include /* @@ -2142,9 +2143,9 @@ static void hv_pci_remove_slots(struct hv_pcibus_device *hbus) } /* - * Set NUMA node for the devices on the bus + * Set NUMA node and DMA coherence for the devices on the bus */ -static void hv_pci_assign_numa_node(struct hv_pcibus_device *hbus) +static void hv_pci_assign_properties(struct hv_pcibus_device *hbus) { struct pci_dev *dev; struct pci_bus *bus = hbus->bridge->bus; @@ -2167,6 +2168,14 @@ static void hv_pci_assign_numa_node(struct hv_pcibus_device *hbus) numa_map_to_online_node( hv_dev->desc.virtual_numa_node)); + /* + * On ARM64, propagate the DMA coherence from the VMbus device + * to the corresponding PCI device. On x86/x64, these calls + * have no effect because DMA is always hardware coherent. + */ + dev_set_dma_coherent(&dev->dev, + dev_is_dma_coherent(&hbus->hdev->device)); + put_pcichild(hv_dev); } } @@ -2191,7 +2200,7 @@ static int create_root_hv_pci_bus(struct hv_pcibus_device *hbus) return error; pci_lock_rescan_remove(); - hv_pci_assign_numa_node(hbus); + hv_pci_assign_properties(hbus); pci_bus_assign_resources(bridge->bus); hv_pci_assign_slots(hbus); pci_bus_add_devices(bridge->bus); @@ -2458,7 +2467,7 @@ static void pci_devices_present_work(struct work_struct *work) */ pci_lock_rescan_remove(); pci_scan_child_bus(hbus->bridge->bus); - hv_pci_assign_numa_node(hbus); + hv_pci_assign_properties(hbus); hv_pci_assign_slots(hbus); pci_unlock_rescan_remove(); break; -- 1.8.3.1 _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu