From patchwork Wed Mar 23 16:16:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 1608690 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=Yj56xaB+; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KNtm46Kg8z9sFN for ; Thu, 24 Mar 2022 03:17:08 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1nX3fR-0005cV-DZ; Wed, 23 Mar 2022 16:17:01 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1nX3fM-0005Yo-B3 for kernel-team@lists.ubuntu.com; Wed, 23 Mar 2022 16:16:56 +0000 Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id CBC733F043 for ; Wed, 23 Mar 2022 16:16:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1648052215; bh=JuKKu7riZCx3xhQIcC/qPr6i0PZ7WRfQsDGLubU+RF8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Yj56xaB+caC8a4KQDapEowiW3Eg2A1T85NlubKNFoWwd77olM/WCax6PtrpjfcniJ N1EY57BLXvKLb9HNbRRV1yqFyXlRq1JVDsVxXUIV6NfHdSm8sm10WURFzJ2E6EmsN2 zePo/O1fhrLQeKDwY9rTIOokANKEdTHv9/eQpMYgu74cXf4opNjIUV6MLLAdd8zGf9 RTfl7uQepQa7987eRxWPC7YXFF3fPbtIdFftJxDg6ZHJDIua/bMXfCw0fIUdgxtgqK GgByejqyxzMPxigg0t1XqFJw3UKoa49NX5T6vMWq0GOrI3Q5ET0z7Gb/yNzqHRmvKd YLTYIojFUY5ng== Received: by mail-pf1-f199.google.com with SMTP id t66-20020a625f45000000b004fabd8f5cc1so1256902pfb.11 for ; Wed, 23 Mar 2022 09:16:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JuKKu7riZCx3xhQIcC/qPr6i0PZ7WRfQsDGLubU+RF8=; b=agZ6Pc/uAKsKtxdt5/Uzf/5PxLBJAcdknGzHe3uMiZmTAk42eeq1vMODNJuL+A600R Blp2TtpoVCedUkmIowgZJ4zOptek3n9xfrEBr1aG/G4DO9BhI1OBofWkyQSwJBMtgCmD MpQrWT29voP/zWLKaK97Opw/NxYbX1pveqx1l87zTFFC8g2Rw7/Sseohpl8TwX9PPIXT 3q8PFBX4RuP6i+57ikUo/xjHdCWX+5iX8xzACaMsIuaeVQFBdfydAlWocvzr8V8nyDKL 7VSLjc7rkF0I8GrXqDnRWl+hEMgbdcX5752tWRKtXPE6pKnlHxahkVxz7zSBWw2Oy+1T bfNw== X-Gm-Message-State: AOAM530MIZpAvinoSnbdnezbtWAj8vXWIZPcprqLPiu/05KXGm1n45hB 54pRmHcd/KTZigequPIGIrHJhkcpRr3Rvp1hTmNlqGuIn2ezls7HYG4erRDxDVAv9COvLLeyFf/ T0yKM88WVDl2bFBPQ54JDG4MwXaCgK4CR1DAnE3yLRA== X-Received: by 2002:a17:902:7896:b0:151:a6fd:dfb3 with SMTP id q22-20020a170902789600b00151a6fddfb3mr647890pll.124.1648052214016; Wed, 23 Mar 2022 09:16:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywK5+jWOdlcFykXQLsPWNopVFBy22AUTrYgaHH0IKS7XFUfGGSL9D9YY5LBOwqqNqeTExz7w== X-Received: by 2002:a17:902:7896:b0:151:a6fd:dfb3 with SMTP id q22-20020a170902789600b00151a6fddfb3mr647851pll.124.1648052213502; Wed, 23 Mar 2022 09:16:53 -0700 (PDT) Received: from localhost.localdomain ([69.163.84.166]) by smtp.gmail.com with ESMTPSA id 16-20020a17090a199000b001bf4b1b268bsm173027pji.44.2022.03.23.09.16.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 09:16:52 -0700 (PDT) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH 4/4] UBUNTU: SAUCE: azure: PCI: hv: Propagate coherence from VMbus device to PCI device Date: Wed, 23 Mar 2022 10:16:31 -0600 Message-Id: <20220323161631.20421-5-tim.gardner@canonical.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323161631.20421-1-tim.gardner@canonical.com> References: <20220323161631.20421-1-tim.gardner@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Michael Kelley BugLink: https://bugs.launchpad.net/bugs/1966098 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 Signed-off-by: Tim Gardner --- 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 22c97ddb5a32..d7891cf94d76 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -49,6 +49,7 @@ #include #include #include +#include #include /* @@ -2147,9 +2148,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; @@ -2172,6 +2173,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); } } @@ -2196,7 +2205,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); @@ -2465,7 +2474,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;