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 X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C191AC43470 for ; Fri, 23 Apr 2021 11:57:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9ACA36145A for ; Fri, 23 Apr 2021 11:57:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229957AbhDWL5m (ORCPT ); Fri, 23 Apr 2021 07:57:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231472AbhDWL5h (ORCPT ); Fri, 23 Apr 2021 07:57:37 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E07BAC06175F for ; Fri, 23 Apr 2021 04:57:00 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id p6so41451380wrn.9 for ; Fri, 23 Apr 2021 04:57:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UQIMwLFTls4/WJjymQFgC41Tqut/moVpCvSGVMf3p14=; b=Se4ZGfMvg0biJnx9os+LbCidHgcUoRYMUQXaJ9i8nJ8CAL99l38h8GPg0NHq49WW6Y mw1HDf5F6KlG0LIlhxpFz1Dbr6v7NyQtWGEUGnus7O1uj9JPoj+FvchqF9voIr3Lw7+2 M5dc/EKCPMli8MltA6zuQTi89PJ9sKFptK+3b5ZJjI7nOKf8bLoctqz1zx/o4CnCIsrz JVrPibAH9yZspQx1yQAZZh7zv5PsJ/AMqDE0G3P0W0WF+vxlnmr3nPjMz3ikPlpBZRAf 93+Y7IU3tAdRYBSUiBhAwU3/KwrrQ/nBjUi+aREYk3hY3aK8OVBk4gpyUtNN/QrgrUzU 79hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UQIMwLFTls4/WJjymQFgC41Tqut/moVpCvSGVMf3p14=; b=QJ96PM9Syqm4YDiye5FXoIv2HXyJZ0KMaJfb0GEYcdIvMrcwTQrO2YBGsmnKCJNPIl T4PZxExNZXhvwdhx8DWJuG3pBl0BhHBTGILh2y1tlUrYQQLL+nmv7KMbtvaylyCgLmCZ J2T0Hl84R+JwQBDmj+R4ITl/g2FR9mVfmcE7VCt2qAD4lGy+8RM6JBG8Nv+pcOrX9xnE +i4xng1YrOtXFCwA8R6BenAQjCS8R24n6y57+iKZ5IWhKS5FlHcIwXzDyGJI/ltvCi3W 7grOS8gJFG4tg8ZX9OP6ZhHvYWUWG/s6Psx8UxfHqb+iZzbaroRCGWuI15RcIJVY8JeE WVsA== X-Gm-Message-State: AOAM5317jCZajOEGBWa68+JamtoE5b7mQtxxK/FsA0aX7tRgGI9YdYNh chuvS5eQvOQzoWn9ASXpa0GaTg== X-Google-Smtp-Source: ABdhPJysuuOvIFTUKOIqqVw+v/bc4x5l41zhX5bZVOgfrTtfrN8ysU7xvrJmyKi3hnVPMITPgWptTQ== X-Received: by 2002:adf:a1db:: with SMTP id v27mr4292159wrv.181.1619179019689; Fri, 23 Apr 2021 04:56:59 -0700 (PDT) Received: from localhost.localdomain ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id g9sm7485195wmh.21.2021.04.23.04.56.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 04:56:59 -0700 (PDT) From: Jean-Philippe Brucker To: rjw@rjwysocki.net, lenb@kernel.org, joro@8bytes.org, mst@redhat.com Cc: will@kernel.org, catalin.marinas@arm.com, baolu.lu@linux.intel.com, dwmw2@infradead.org, linux-acpi@vger.kernel.org, iommu@lists.linux-foundation.org, virtualization@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, eric.auger@redhat.com, sebastien.boeuf@intel.com, robin.murphy@arm.com, kevin.tian@intel.com, lorenzo.pieralisi@arm.com, guohanjun@huawei.com, sudeep.holla@arm.com, jean-philippe@linaro.org Subject: [PATCH v2 6/6] iommu/virtio: Enable x86 support Date: Fri, 23 Apr 2021 13:38:37 +0200 Message-Id: <20210423113836.3974972-7-jean-philippe@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210423113836.3974972-1-jean-philippe@linaro.org> References: <20210423113836.3974972-1-jean-philippe@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org With the VIOT support in place, x86 platforms can now use the virtio-iommu. Because the other x86 IOMMU drivers aren't yet ready to use the acpi_dma_setup() path, x86 doesn't implement arch_setup_dma_ops() at the moment. Similarly to Vt-d and AMD IOMMU, call iommu_setup_dma_ops() from probe_finalize(). Acked-by: Joerg Roedel Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/Kconfig | 3 ++- drivers/iommu/dma-iommu.c | 1 + drivers/iommu/virtio-iommu.c | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index aff8a4830dd1..07b7c25cbed8 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -400,8 +400,9 @@ config HYPERV_IOMMU config VIRTIO_IOMMU tristate "Virtio IOMMU driver" depends on VIRTIO - depends on ARM64 + depends on (ARM64 || X86) select IOMMU_API + select IOMMU_DMA select INTERVAL_TREE select ACPI_VIOT if ACPI help diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 175f8eaeb5b3..46ed43c400cf 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -1332,6 +1332,7 @@ void iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 dma_limit) pr_warn("Failed to set up IOMMU for device %s; retaining platform DMA ops\n", dev_name(dev)); } +EXPORT_SYMBOL_GPL(iommu_setup_dma_ops); static struct iommu_dma_msi_page *iommu_dma_get_msi_page(struct device *dev, phys_addr_t msi_addr, struct iommu_domain *domain) diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c index 29a397c2d12f..8be546a338e7 100644 --- a/drivers/iommu/virtio-iommu.c +++ b/drivers/iommu/virtio-iommu.c @@ -1027,6 +1027,13 @@ static struct iommu_device *viommu_probe_device(struct device *dev) return ERR_PTR(ret); } +static void viommu_probe_finalize(struct device *dev) +{ +#ifndef CONFIG_ARCH_HAS_SETUP_DMA_OPS + iommu_setup_dma_ops(dev, 0, U64_MAX); +#endif +} + static void viommu_release_device(struct device *dev) { struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); @@ -1063,6 +1070,7 @@ static struct iommu_ops viommu_ops = { .iova_to_phys = viommu_iova_to_phys, .iotlb_sync = viommu_iotlb_sync, .probe_device = viommu_probe_device, + .probe_finalize = viommu_probe_finalize, .release_device = viommu_release_device, .device_group = viommu_device_group, .get_resv_regions = viommu_get_resv_regions, -- 2.31.1 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 X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 737B4C433B4 for ; Fri, 23 Apr 2021 11:57:08 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0FAA66141C for ; Fri, 23 Apr 2021 11:57:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0FAA66141C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id B72EB84419; Fri, 23 Apr 2021 11:57:07 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ytvZWiriL9mh; Fri, 23 Apr 2021 11:57:06 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTP id E08A384416; Fri, 23 Apr 2021 11:57:05 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 23A3FC002F; Fri, 23 Apr 2021 11:57:05 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 136AAC000B for ; Fri, 23 Apr 2021 11:57:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 0FB4840620 for ; Fri, 23 Apr 2021 11:57:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=linaro.org 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 NR-PG4zQhiDl for ; Fri, 23 Apr 2021 11:57:01 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by smtp2.osuosl.org (Postfix) with ESMTPS id 76ACE40610 for ; Fri, 23 Apr 2021 11:57:01 +0000 (UTC) Received: by mail-wr1-x42a.google.com with SMTP id j5so47152881wrn.4 for ; Fri, 23 Apr 2021 04:57:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UQIMwLFTls4/WJjymQFgC41Tqut/moVpCvSGVMf3p14=; b=Se4ZGfMvg0biJnx9os+LbCidHgcUoRYMUQXaJ9i8nJ8CAL99l38h8GPg0NHq49WW6Y mw1HDf5F6KlG0LIlhxpFz1Dbr6v7NyQtWGEUGnus7O1uj9JPoj+FvchqF9voIr3Lw7+2 M5dc/EKCPMli8MltA6zuQTi89PJ9sKFptK+3b5ZJjI7nOKf8bLoctqz1zx/o4CnCIsrz JVrPibAH9yZspQx1yQAZZh7zv5PsJ/AMqDE0G3P0W0WF+vxlnmr3nPjMz3ikPlpBZRAf 93+Y7IU3tAdRYBSUiBhAwU3/KwrrQ/nBjUi+aREYk3hY3aK8OVBk4gpyUtNN/QrgrUzU 79hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UQIMwLFTls4/WJjymQFgC41Tqut/moVpCvSGVMf3p14=; b=KVP9Bk1LgB0gNq0+ynYj0+wdXvZPtK4FXsynOtSCHPcRREaL6Dg0xPM31oGWpcyuXB hgMmc5SduxKR13ZY47n1VHUWon4/wHdGDmYOK6u0QTJCgWqMoTzwCpSHUBVXQx7EGCPV brNcHvddmw8Je+WwJyhp02093qOJQmty0trOSl4cGiDKs0IeYOT7pKcj1otT+vprrWkX KxlfRPdDEr6d4B6KtJo8mPE3TTWYL5vNi6ugiu+HftW6QsRlIxNE0k8IsF0kKaSYncsD CGQ6AnLxr5nUnqtUE5Q/dsJxLCQwBgJAnNpvozKrM/NjKSjHESsSk1Sdtby3+BOAJeI7 afhA== X-Gm-Message-State: AOAM530YHV1r4eLKhFQyVOG4KSkm4hOFwzNloN6hL0OjY+7NoVZS6SJh vDGgBe/Gi16l40fqtxUH2TnFXg== X-Google-Smtp-Source: ABdhPJysuuOvIFTUKOIqqVw+v/bc4x5l41zhX5bZVOgfrTtfrN8ysU7xvrJmyKi3hnVPMITPgWptTQ== X-Received: by 2002:adf:a1db:: with SMTP id v27mr4292159wrv.181.1619179019689; Fri, 23 Apr 2021 04:56:59 -0700 (PDT) Received: from localhost.localdomain ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id g9sm7485195wmh.21.2021.04.23.04.56.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 04:56:59 -0700 (PDT) From: Jean-Philippe Brucker To: rjw@rjwysocki.net, lenb@kernel.org, joro@8bytes.org, mst@redhat.com Subject: [PATCH v2 6/6] iommu/virtio: Enable x86 support Date: Fri, 23 Apr 2021 13:38:37 +0200 Message-Id: <20210423113836.3974972-7-jean-philippe@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210423113836.3974972-1-jean-philippe@linaro.org> References: <20210423113836.3974972-1-jean-philippe@linaro.org> MIME-Version: 1.0 Cc: jean-philippe@linaro.org, kevin.tian@intel.com, catalin.marinas@arm.com, sudeep.holla@arm.com, robin.murphy@arm.com, virtualization@lists.linux-foundation.org, linux-acpi@vger.kernel.org, iommu@lists.linux-foundation.org, sebastien.boeuf@intel.com, guohanjun@huawei.com, will@kernel.org, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" With the VIOT support in place, x86 platforms can now use the virtio-iommu. Because the other x86 IOMMU drivers aren't yet ready to use the acpi_dma_setup() path, x86 doesn't implement arch_setup_dma_ops() at the moment. Similarly to Vt-d and AMD IOMMU, call iommu_setup_dma_ops() from probe_finalize(). Acked-by: Joerg Roedel Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/Kconfig | 3 ++- drivers/iommu/dma-iommu.c | 1 + drivers/iommu/virtio-iommu.c | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index aff8a4830dd1..07b7c25cbed8 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -400,8 +400,9 @@ config HYPERV_IOMMU config VIRTIO_IOMMU tristate "Virtio IOMMU driver" depends on VIRTIO - depends on ARM64 + depends on (ARM64 || X86) select IOMMU_API + select IOMMU_DMA select INTERVAL_TREE select ACPI_VIOT if ACPI help diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 175f8eaeb5b3..46ed43c400cf 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -1332,6 +1332,7 @@ void iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 dma_limit) pr_warn("Failed to set up IOMMU for device %s; retaining platform DMA ops\n", dev_name(dev)); } +EXPORT_SYMBOL_GPL(iommu_setup_dma_ops); static struct iommu_dma_msi_page *iommu_dma_get_msi_page(struct device *dev, phys_addr_t msi_addr, struct iommu_domain *domain) diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c index 29a397c2d12f..8be546a338e7 100644 --- a/drivers/iommu/virtio-iommu.c +++ b/drivers/iommu/virtio-iommu.c @@ -1027,6 +1027,13 @@ static struct iommu_device *viommu_probe_device(struct device *dev) return ERR_PTR(ret); } +static void viommu_probe_finalize(struct device *dev) +{ +#ifndef CONFIG_ARCH_HAS_SETUP_DMA_OPS + iommu_setup_dma_ops(dev, 0, U64_MAX); +#endif +} + static void viommu_release_device(struct device *dev) { struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); @@ -1063,6 +1070,7 @@ static struct iommu_ops viommu_ops = { .iova_to_phys = viommu_iova_to_phys, .iotlb_sync = viommu_iotlb_sync, .probe_device = viommu_probe_device, + .probe_finalize = viommu_probe_finalize, .release_device = viommu_release_device, .device_group = viommu_device_group, .get_resv_regions = viommu_get_resv_regions, -- 2.31.1 _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu 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 X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABC72C433ED for ; Fri, 23 Apr 2021 11:57:11 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 50C976141C for ; Fri, 23 Apr 2021 11:57:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 50C976141C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=virtualization-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 201934051A; Fri, 23 Apr 2021 11:57:09 +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 SFd3d5reywQN; Fri, 23 Apr 2021 11:57:07 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTP id 9EC3D41836; Fri, 23 Apr 2021 11:57:06 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 83B56C0025; Fri, 23 Apr 2021 11:57:05 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 20586C001A for ; Fri, 23 Apr 2021 11:57:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id A15A260DD7 for ; Fri, 23 Apr 2021 11:57:02 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp3.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=linaro.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id v0sHr2hoV5kx for ; Fri, 23 Apr 2021 11:57:01 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by smtp3.osuosl.org (Postfix) with ESMTPS id 6E32360DAE for ; Fri, 23 Apr 2021 11:57:01 +0000 (UTC) Received: by mail-wr1-x436.google.com with SMTP id w4so44399727wrt.5 for ; Fri, 23 Apr 2021 04:57:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UQIMwLFTls4/WJjymQFgC41Tqut/moVpCvSGVMf3p14=; b=Se4ZGfMvg0biJnx9os+LbCidHgcUoRYMUQXaJ9i8nJ8CAL99l38h8GPg0NHq49WW6Y mw1HDf5F6KlG0LIlhxpFz1Dbr6v7NyQtWGEUGnus7O1uj9JPoj+FvchqF9voIr3Lw7+2 M5dc/EKCPMli8MltA6zuQTi89PJ9sKFptK+3b5ZJjI7nOKf8bLoctqz1zx/o4CnCIsrz JVrPibAH9yZspQx1yQAZZh7zv5PsJ/AMqDE0G3P0W0WF+vxlnmr3nPjMz3ikPlpBZRAf 93+Y7IU3tAdRYBSUiBhAwU3/KwrrQ/nBjUi+aREYk3hY3aK8OVBk4gpyUtNN/QrgrUzU 79hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UQIMwLFTls4/WJjymQFgC41Tqut/moVpCvSGVMf3p14=; b=MD+HzvxFCRbalVOhkNFuUdM7mMyoRfK57k6sMYkoCyYhejMlyOp954oFWpY51a+3a4 pWcc6X7Mi3TMu9jxc9JdCgiKTbTLzWuS8s3Z4sxJ1yjuZmRnT8gMVJuAgN+b9TeIxSVc Svy2IgskmnIacw+PI+MJ7wgh3VD9uhXmV06p7iJFw/OFPrV3DniaA1rSt4SVZjd6l0Xl v1Dx2dXwzC4PJ4MTRpdwVctFb5slN+CvFeyJecmEx1Oq31SN2K5o6bQbgFxhQfeeRVDm P2ktjKf1SqlmBLptdEsEnbtBGn4N9hB2ghoTm9b891i8bEV46AYTEgMIO08C9tkDGlBS K7YQ== X-Gm-Message-State: AOAM530bsqV5SzGgy0NeH//Zu7y+40Xa5KhtG5AFW4JDNksjhVvJqYr5 5D3PLBtHea1KSdxPMTJ/zCO9CA== X-Google-Smtp-Source: ABdhPJysuuOvIFTUKOIqqVw+v/bc4x5l41zhX5bZVOgfrTtfrN8ysU7xvrJmyKi3hnVPMITPgWptTQ== X-Received: by 2002:adf:a1db:: with SMTP id v27mr4292159wrv.181.1619179019689; Fri, 23 Apr 2021 04:56:59 -0700 (PDT) Received: from localhost.localdomain ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id g9sm7485195wmh.21.2021.04.23.04.56.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 04:56:59 -0700 (PDT) From: Jean-Philippe Brucker To: rjw@rjwysocki.net, lenb@kernel.org, joro@8bytes.org, mst@redhat.com Subject: [PATCH v2 6/6] iommu/virtio: Enable x86 support Date: Fri, 23 Apr 2021 13:38:37 +0200 Message-Id: <20210423113836.3974972-7-jean-philippe@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210423113836.3974972-1-jean-philippe@linaro.org> References: <20210423113836.3974972-1-jean-philippe@linaro.org> MIME-Version: 1.0 Cc: jean-philippe@linaro.org, lorenzo.pieralisi@arm.com, eric.auger@redhat.com, catalin.marinas@arm.com, sudeep.holla@arm.com, robin.murphy@arm.com, virtualization@lists.linux-foundation.org, linux-acpi@vger.kernel.org, iommu@lists.linux-foundation.org, sebastien.boeuf@intel.com, guohanjun@huawei.com, will@kernel.org, dwmw2@infradead.org, linux-arm-kernel@lists.infradead.org, baolu.lu@linux.intel.com X-BeenThere: virtualization@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux virtualization List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" With the VIOT support in place, x86 platforms can now use the virtio-iommu. Because the other x86 IOMMU drivers aren't yet ready to use the acpi_dma_setup() path, x86 doesn't implement arch_setup_dma_ops() at the moment. Similarly to Vt-d and AMD IOMMU, call iommu_setup_dma_ops() from probe_finalize(). Acked-by: Joerg Roedel Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/Kconfig | 3 ++- drivers/iommu/dma-iommu.c | 1 + drivers/iommu/virtio-iommu.c | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index aff8a4830dd1..07b7c25cbed8 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -400,8 +400,9 @@ config HYPERV_IOMMU config VIRTIO_IOMMU tristate "Virtio IOMMU driver" depends on VIRTIO - depends on ARM64 + depends on (ARM64 || X86) select IOMMU_API + select IOMMU_DMA select INTERVAL_TREE select ACPI_VIOT if ACPI help diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 175f8eaeb5b3..46ed43c400cf 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -1332,6 +1332,7 @@ void iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 dma_limit) pr_warn("Failed to set up IOMMU for device %s; retaining platform DMA ops\n", dev_name(dev)); } +EXPORT_SYMBOL_GPL(iommu_setup_dma_ops); static struct iommu_dma_msi_page *iommu_dma_get_msi_page(struct device *dev, phys_addr_t msi_addr, struct iommu_domain *domain) diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c index 29a397c2d12f..8be546a338e7 100644 --- a/drivers/iommu/virtio-iommu.c +++ b/drivers/iommu/virtio-iommu.c @@ -1027,6 +1027,13 @@ static struct iommu_device *viommu_probe_device(struct device *dev) return ERR_PTR(ret); } +static void viommu_probe_finalize(struct device *dev) +{ +#ifndef CONFIG_ARCH_HAS_SETUP_DMA_OPS + iommu_setup_dma_ops(dev, 0, U64_MAX); +#endif +} + static void viommu_release_device(struct device *dev) { struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); @@ -1063,6 +1070,7 @@ static struct iommu_ops viommu_ops = { .iova_to_phys = viommu_iova_to_phys, .iotlb_sync = viommu_iotlb_sync, .probe_device = viommu_probe_device, + .probe_finalize = viommu_probe_finalize, .release_device = viommu_release_device, .device_group = viommu_device_group, .get_resv_regions = viommu_get_resv_regions, -- 2.31.1 _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization 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 X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4779DC433ED for ; Fri, 23 Apr 2021 12:00:13 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A5FDD613AD for ; Fri, 23 Apr 2021 12:00:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5FDD613AD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=JWvUhh3A8LjZkqEQ5UiTukXm+xgsLrWq+VMIBSeZLtk=; b=kxWo1KG36jTS45dxgQuXMunlh y2WKAAMOYju4N3RRq1ZuF7SDIvqA151Ji+d3rQb0i3rc1N8SVCBMg0gLdy7M89LxT28TfWe7x2g/9 VKrzTliKNvuAtEnuKi6GVwxp34D1QEIL3Sg3mUZWiTW6lC1V1AwvJ2QGb9EcpQll86XEbR392gLdw 2dASSjtK8VZSogSsj+UxuqWhl5f///JSy0T61xJlTv9FPCAmmtoApioAYQ+Mw4IZCWUCtKtT42a0V BRkwDccXDUg9NP0Oy8KIkWQJutVrfLCwDBZPK5D1uowRWYohLtgkBLKXCLernIdbwg9SU+oe5b6yS lIsiJSj8A==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZuRz-001PHA-Kt; Fri, 23 Apr 2021 11:58:24 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZuQj-001P84-3T for linux-arm-kernel@desiato.infradead.org; Fri, 23 Apr 2021 11:57:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=UQIMwLFTls4/WJjymQFgC41Tqut/moVpCvSGVMf3p14=; b=Y1iN5vsNjqsmqpMrxHbfAlylJw MOrX5TGMTTD5icg0qN2RLtrboO1cfdDtl1M9I3ThdDnoIlKtbfmqpE1eEAf8vWJBxZ0k4UvpL+Rak BzXEFBJuldvnxiDr5O6oEAYTl9eYq9inYO6jTIWVHET+4ajYAK2e8sBZR7XIE3Ysj5h8n6dnIL7rG F/hqPo9akmv1del5xxkeNgu0vgJ1S7lRWffjCyHtgbpFk5U/Vk+BU++3jr7fOJn9fwg2n4HK5LDgB vdn7uOnRcb5363KNKkwO/ZSx4WxRCWNq+bEtu/GdoAqKMD391I13DyGQp/VV61T+KxM6kpYAugbEJ UL1qtVhw==; Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZuQf-00ENSg-HE for linux-arm-kernel@lists.infradead.org; Fri, 23 Apr 2021 11:57:03 +0000 Received: by mail-wr1-x42d.google.com with SMTP id h4so39078666wrt.12 for ; Fri, 23 Apr 2021 04:57:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UQIMwLFTls4/WJjymQFgC41Tqut/moVpCvSGVMf3p14=; b=Se4ZGfMvg0biJnx9os+LbCidHgcUoRYMUQXaJ9i8nJ8CAL99l38h8GPg0NHq49WW6Y mw1HDf5F6KlG0LIlhxpFz1Dbr6v7NyQtWGEUGnus7O1uj9JPoj+FvchqF9voIr3Lw7+2 M5dc/EKCPMli8MltA6zuQTi89PJ9sKFptK+3b5ZJjI7nOKf8bLoctqz1zx/o4CnCIsrz JVrPibAH9yZspQx1yQAZZh7zv5PsJ/AMqDE0G3P0W0WF+vxlnmr3nPjMz3ikPlpBZRAf 93+Y7IU3tAdRYBSUiBhAwU3/KwrrQ/nBjUi+aREYk3hY3aK8OVBk4gpyUtNN/QrgrUzU 79hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UQIMwLFTls4/WJjymQFgC41Tqut/moVpCvSGVMf3p14=; b=pv+ZmM4tQtAcL/HF2JHgY7Z61rRWXYziYSaaldpp/6EguUWQs5sWnvibFAKPCc1512 jzL+cJurI0mdo2lcU5W85r4YFCDgka47fIisUkQXNas3i1gdU4LwGD2Za6z6/QeTp1DQ 8tRWo7LxQ8J9P0PtW49LLMLMVunE4mhlY0umhgBO/Fkb51sLnbcC2ZwKaXQyxJvBsFDw j7Y1ALbSzORp9aqkY4OZPphfHslJtaltWq/gBlpF955hDATJexT8Fbqjns9Bk0ANPypJ r4KjxAAbexxogMmaaUQlaLoju0dLI/jRBy0H0eDH9eGKm3GjaeplCNDpdtbVLMzgR+y6 9DzQ== X-Gm-Message-State: AOAM532WCdvwZDMi4CStwUg+0JuNBwbPY2g8UxfdnhhAs6gkBOgpJtjU M24XsdYdSMv/qNrvjWLEheMaOA== X-Google-Smtp-Source: ABdhPJysuuOvIFTUKOIqqVw+v/bc4x5l41zhX5bZVOgfrTtfrN8ysU7xvrJmyKi3hnVPMITPgWptTQ== X-Received: by 2002:adf:a1db:: with SMTP id v27mr4292159wrv.181.1619179019689; Fri, 23 Apr 2021 04:56:59 -0700 (PDT) Received: from localhost.localdomain ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id g9sm7485195wmh.21.2021.04.23.04.56.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 04:56:59 -0700 (PDT) From: Jean-Philippe Brucker To: rjw@rjwysocki.net, lenb@kernel.org, joro@8bytes.org, mst@redhat.com Cc: will@kernel.org, catalin.marinas@arm.com, baolu.lu@linux.intel.com, dwmw2@infradead.org, linux-acpi@vger.kernel.org, iommu@lists.linux-foundation.org, virtualization@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, eric.auger@redhat.com, sebastien.boeuf@intel.com, robin.murphy@arm.com, kevin.tian@intel.com, lorenzo.pieralisi@arm.com, guohanjun@huawei.com, sudeep.holla@arm.com, jean-philippe@linaro.org Subject: [PATCH v2 6/6] iommu/virtio: Enable x86 support Date: Fri, 23 Apr 2021 13:38:37 +0200 Message-Id: <20210423113836.3974972-7-jean-philippe@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210423113836.3974972-1-jean-philippe@linaro.org> References: <20210423113836.3974972-1-jean-philippe@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210423_045701_578231_7950F6AD X-CRM114-Status: GOOD ( 15.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org With the VIOT support in place, x86 platforms can now use the virtio-iommu. Because the other x86 IOMMU drivers aren't yet ready to use the acpi_dma_setup() path, x86 doesn't implement arch_setup_dma_ops() at the moment. Similarly to Vt-d and AMD IOMMU, call iommu_setup_dma_ops() from probe_finalize(). Acked-by: Joerg Roedel Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/Kconfig | 3 ++- drivers/iommu/dma-iommu.c | 1 + drivers/iommu/virtio-iommu.c | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index aff8a4830dd1..07b7c25cbed8 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -400,8 +400,9 @@ config HYPERV_IOMMU config VIRTIO_IOMMU tristate "Virtio IOMMU driver" depends on VIRTIO - depends on ARM64 + depends on (ARM64 || X86) select IOMMU_API + select IOMMU_DMA select INTERVAL_TREE select ACPI_VIOT if ACPI help diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 175f8eaeb5b3..46ed43c400cf 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -1332,6 +1332,7 @@ void iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 dma_limit) pr_warn("Failed to set up IOMMU for device %s; retaining platform DMA ops\n", dev_name(dev)); } +EXPORT_SYMBOL_GPL(iommu_setup_dma_ops); static struct iommu_dma_msi_page *iommu_dma_get_msi_page(struct device *dev, phys_addr_t msi_addr, struct iommu_domain *domain) diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c index 29a397c2d12f..8be546a338e7 100644 --- a/drivers/iommu/virtio-iommu.c +++ b/drivers/iommu/virtio-iommu.c @@ -1027,6 +1027,13 @@ static struct iommu_device *viommu_probe_device(struct device *dev) return ERR_PTR(ret); } +static void viommu_probe_finalize(struct device *dev) +{ +#ifndef CONFIG_ARCH_HAS_SETUP_DMA_OPS + iommu_setup_dma_ops(dev, 0, U64_MAX); +#endif +} + static void viommu_release_device(struct device *dev) { struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); @@ -1063,6 +1070,7 @@ static struct iommu_ops viommu_ops = { .iova_to_phys = viommu_iova_to_phys, .iotlb_sync = viommu_iotlb_sync, .probe_device = viommu_probe_device, + .probe_finalize = viommu_probe_finalize, .release_device = viommu_release_device, .device_group = viommu_device_group, .get_resv_regions = viommu_get_resv_regions, -- 2.31.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel