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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58FE8CCA473 for ; Wed, 6 Jul 2022 17:42:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233945AbiGFRm3 (ORCPT ); Wed, 6 Jul 2022 13:42:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233937AbiGFRmY (ORCPT ); Wed, 6 Jul 2022 13:42:24 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0186DB87C for ; Wed, 6 Jul 2022 10:42:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657129342; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Bm6ni0e0Z3ZqDaHM6VmzfCaa2VxT43x1YW4zQJliK1o=; b=ARIhqBTzHZQ3VgDQMRTAdHi9Y8jPgiIXohT0OxHDSwtw6gl1N1h3ET1DRL3mNkdAKR4gl6 XQbWPvIJwfAF+rAqbPWyMz8zjxbXnMlgxddojke0zmTnLcIx8i0t1Pk9r4FXhENIQ8ANqy gM0XkDbbUUOpgle8EGk3Q9y5Rv5Z12k= Received: from mail-io1-f72.google.com (mail-io1-f72.google.com [209.85.166.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-216-UdZ-f08BPvi55cmvco9HOw-1; Wed, 06 Jul 2022 13:42:21 -0400 X-MC-Unique: UdZ-f08BPvi55cmvco9HOw-1 Received: by mail-io1-f72.google.com with SMTP id k1-20020a5d8741000000b00678ad1103e7so2470803iol.21 for ; Wed, 06 Jul 2022 10:42:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=Bm6ni0e0Z3ZqDaHM6VmzfCaa2VxT43x1YW4zQJliK1o=; b=VraKFXw1G5WZ7KQB8YnG+vbhu7rgq7azu0nLPUaAoHgicYkZKJpLKct4dd6+bgEZh1 Bz5yYf13i8mGuN/RvRvcsf60KKMG+Gf6vQ+q2ZrV9SUzh2jS7vVn4ewfbBkOn1RELfP1 jZ2iWqyCOXL7Zv5v287c122Xx22vC90KdAn3cvP8zp6oE/FwuJVkq2CppQvvg9wpVzPF jK2+655IOox2xCElg8JIXxFYs9db4Mp+2+rXy4rvUv6ISlcWtfNsge9gvxuuoCG+foNV C47yCADI+8HqTnqusUZsEsIhMaxTGGIDFVcRDyzHqig09tt/ekSJvaocK4ixbbcALQC2 nJiQ== X-Gm-Message-State: AJIora9lN2Llj+WQj+pc4GGqUej28/pyaLjRNrJynXkA/2HlyuGVl+xO t78xFqav2rEceKxV8wc8au3A/dGtuyRyMQHJZ0kdixGqqHHlpPVcpSwBuPkhwrERrJ8UbmokAKS htEZh48Gyal21EkolI3i6sh3sGA== X-Received: by 2002:a05:6e02:1be6:b0:2db:ea7f:10c4 with SMTP id y6-20020a056e021be600b002dbea7f10c4mr17220897ilv.248.1657129340263; Wed, 06 Jul 2022 10:42:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tKW5hHrIbN8D8MKAPlov0FsaTgJJCZrivyPi82ikNP5NQmibHb26OWtdHiMispm5nOi3tbJA== X-Received: by 2002:a05:6e02:1be6:b0:2db:ea7f:10c4 with SMTP id y6-20020a056e021be600b002dbea7f10c4mr17220872ilv.248.1657129339926; Wed, 06 Jul 2022 10:42:19 -0700 (PDT) Received: from redhat.com ([38.15.36.239]) by smtp.gmail.com with ESMTPSA id i83-20020a6bb856000000b0065a47e16f53sm17005663iof.37.2022.07.06.10.42.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 10:42:19 -0700 (PDT) Date: Wed, 6 Jul 2022 11:42:17 -0600 From: Alex Williamson To: Nicolin Chen Cc: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v5 0/5] cover-letter: Simplify vfio_iommu_type1 attach/detach routine Message-ID: <20220706114217.105f4f61.alex.williamson@redhat.com> In-Reply-To: <20220701214455.14992-1-nicolinc@nvidia.com> References: <20220701214455.14992-1-nicolinc@nvidia.com> Organization: Red Hat MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On Fri, 1 Jul 2022 14:44:50 -0700 Nicolin Chen wrote: > This is a preparatory series for IOMMUFD v2 patches. It enforces error > code -EMEDIUMTYPE in iommu_attach_device() and iommu_attach_group() when > an IOMMU domain and a device/group are incompatible. It also drops the > useless domain->ops check since it won't fail in current environment. > > These allow VFIO iommu code to simplify its group attachment routine, by > avoiding the extra IOMMU domain allocations and attach/detach sequences > of the old code. > > Worths mentioning the exact match for enforce_cache_coherency is removed > with this series, since there's very less value in doing that as KVM will > not be able to take advantage of it -- this just wastes domain memory. > Instead, we rely on Intel IOMMU driver taking care of that internally. > > This is on github: > https://github.com/nicolinc/iommufd/commits/vfio_iommu_attach How do you foresee this going in, I'm imagining Joerg would merge the first patch via the IOMMU tree and provide a topic branch that I'd merge into the vfio tree along with the remaining patches. Sound right? Thanks, Alex > Changelog > v5: > * Rebased on top of Robin's "Simplify bus_type determination". > * Fixed a wrong change returning -EMEDIUMTYPE in arm-smmu driver. > * Added Baolu's "Reviewed-by". > v4: > * Dropped -EMEDIUMTYPE change in mtk_v1 driver per Robin's input > * Added Baolu's and Kevin's Reviewed-by lines > v3: https://lore.kernel.org/kvm/20220623200029.26007-1-nicolinc@nvidia.com/ > * Dropped all dev_err since -EMEDIUMTYPE clearly indicates what error. > * Updated commit message of enforce_cache_coherency removing patch. > * Updated commit message of domain->ops removing patch. > * Replaced "goto out_unlock" with simply mutex_unlock() and return. > * Added a line of comments for -EMEDIUMTYPE return check. > * Moved iommu_get_msi_cookie() into alloc_attach_domain() as a cookie > should be logically tied to the lifetime of a domain itself. > * Added Kevin's "Reviewed-by". > v2: https://lore.kernel.org/kvm/20220616000304.23890-1-nicolinc@nvidia.com/ > * Added -EMEDIUMTYPE to more IOMMU drivers that fit the category. > * Changed dev_err to dev_dbg for -EMEDIUMTYPE to avoid kernel log spam. > * Dropped iommu_ops patch, and removed domain->ops in VFIO directly, > since there's no mixed-driver use case that would fail the sanity. > * Updated commit log of the patch removing enforce_cache_coherency. > * Fixed a misplace of "num_non_pinned_groups--" in detach_group patch. > * Moved "num_non_pinned_groups++" in PATCH-5 to the common path between > domain-reusing and new-domain pathways, like the code previously did. > * Fixed a typo in EMEDIUMTYPE patch. > v1: https://lore.kernel.org/kvm/20220606061927.26049-1-nicolinc@nvidia.com/ > > Jason Gunthorpe (1): > vfio/iommu_type1: Prefer to reuse domains vs match enforced cache > coherency > > Nicolin Chen (4): > iommu: Return -EMEDIUMTYPE for incompatible domain and device/group > vfio/iommu_type1: Remove the domain->ops comparison > vfio/iommu_type1: Clean up update_dirty_scope in detach_group() > vfio/iommu_type1: Simplify group attachment > > drivers/iommu/amd/iommu.c | 2 +- > drivers/iommu/apple-dart.c | 4 +- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 15 +- > drivers/iommu/arm/arm-smmu/arm-smmu.c | 5 +- > drivers/iommu/arm/arm-smmu/qcom_iommu.c | 9 +- > drivers/iommu/intel/iommu.c | 10 +- > drivers/iommu/iommu.c | 28 ++ > drivers/iommu/ipmmu-vmsa.c | 4 +- > drivers/iommu/omap-iommu.c | 3 +- > drivers/iommu/s390-iommu.c | 2 +- > drivers/iommu/sprd-iommu.c | 6 +- > drivers/iommu/tegra-gart.c | 2 +- > drivers/iommu/virtio-iommu.c | 3 +- > drivers/vfio/vfio_iommu_type1.c | 352 ++++++++++---------- > 14 files changed, 229 insertions(+), 216 deletions(-) > 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 C481FC433EF for ; Wed, 6 Jul 2022 17:42:34 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 2FFBE417D9; Wed, 6 Jul 2022 17:42:34 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 2FFBE417D9 Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VS/bX/+V 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 7ttCsFuBuqK2; Wed, 6 Jul 2022 17:42:33 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 36FF2417DA; Wed, 6 Jul 2022 17:42:32 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 36FF2417DA Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0B9B9C0035; Wed, 6 Jul 2022 17:42:32 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 97589C002D for ; Wed, 6 Jul 2022 17:42:30 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 6F12381310 for ; Wed, 6 Jul 2022 17:42:30 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 6F12381310 Authentication-Results: smtp1.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VS/bX/+V 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 JsZZG6ckRoNA for ; Wed, 6 Jul 2022 17:42:29 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 470088129B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 470088129B for ; Wed, 6 Jul 2022 17:42:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657129347; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Bm6ni0e0Z3ZqDaHM6VmzfCaa2VxT43x1YW4zQJliK1o=; b=VS/bX/+Vu38g2mUxNvCNUsYi17HjwgN8SRmc+JnmdM7re6LxWiqGk7rhSleVvXi/+l5hN6 uNoqlbyiFY+o+RAEQ3Ms6M4vImPHhoDeAWCLsLTo2TVNt8iM5zW09HflITezqzBsQDOVZE xouIWArAtAVjSpROPLGEbHU3UQKGZyU= Received: from mail-il1-f197.google.com (mail-il1-f197.google.com [209.85.166.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-646-JIoS-3CMNK2O9Rqs_sOxkA-1; Wed, 06 Jul 2022 13:42:21 -0400 X-MC-Unique: JIoS-3CMNK2O9Rqs_sOxkA-1 Received: by mail-il1-f197.google.com with SMTP id o9-20020a056e0214c900b002dc29c288bfso2728367ilk.3 for ; Wed, 06 Jul 2022 10:42:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=Bm6ni0e0Z3ZqDaHM6VmzfCaa2VxT43x1YW4zQJliK1o=; b=cJ6Wb0PL1fnpjwfGqvO1P3zU3X73RDjqQ7i1Ei4xQ7FZT0hkHiBvyfj1F9f8N/+Kx5 oe9LlPF1NTxv8+p4IlxBCgVtXJRmMG/qReWG2In32I+mVLPPusEesFf5NyLK5Dw9XBiD Ixl9doZjwUmudXonBO8PFOTnleHvYcR0QhKQIB692J+F0XcUx280BX4kJCoyIHGRCxdn NIbof/2Q0U5vSu1T+yQSynnctXNYTqLXjhIwn51ZRqTgodmTxr2LWJh1eL27WVVCueiU 0516XxE4HxPMTEJIQ+F+Kk+yWX6jndSET1CoVpwafE7Mq4er6H9G4fjmyI5awc3MS01y /KLw== X-Gm-Message-State: AJIora/Snb+nMjkzDB1yjxqvay8VMoVqGDT1RmcfwBZ+IjbuJbJrTeZP W1Fjz3KKnXIKm3IhLOLbDNZcDwwsMnXDjHnNITC0WweD61bp1gd7hcmub3nkVgWBG7JXwxIYzQs jKdwjXxoMe6mxvYLRxu29ibo10B6wXuPowPTL4MolCA== X-Received: by 2002:a05:6e02:1be6:b0:2db:ea7f:10c4 with SMTP id y6-20020a056e021be600b002dbea7f10c4mr17220913ilv.248.1657129340275; Wed, 06 Jul 2022 10:42:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tKW5hHrIbN8D8MKAPlov0FsaTgJJCZrivyPi82ikNP5NQmibHb26OWtdHiMispm5nOi3tbJA== X-Received: by 2002:a05:6e02:1be6:b0:2db:ea7f:10c4 with SMTP id y6-20020a056e021be600b002dbea7f10c4mr17220872ilv.248.1657129339926; Wed, 06 Jul 2022 10:42:19 -0700 (PDT) Received: from redhat.com ([38.15.36.239]) by smtp.gmail.com with ESMTPSA id i83-20020a6bb856000000b0065a47e16f53sm17005663iof.37.2022.07.06.10.42.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 10:42:19 -0700 (PDT) Date: Wed, 6 Jul 2022 11:42:17 -0600 From: Alex Williamson To: Nicolin Chen Subject: Re: [PATCH v5 0/5] cover-letter: Simplify vfio_iommu_type1 attach/detach routine Message-ID: <20220706114217.105f4f61.alex.williamson@redhat.com> In-Reply-To: <20220701214455.14992-1-nicolinc@nvidia.com> References: <20220701214455.14992-1-nicolinc@nvidia.com> Organization: Red Hat MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=alex.williamson@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: linux-s390@vger.kernel.org, marcan@marcan.st, mjrosato@linux.ibm.com, virtualization@lists.linux-foundation.org, thierry.reding@gmail.com, will@kernel.org, alyssa@rosenzweig.io, jean-philippe@linaro.org, kvm@vger.kernel.org, zhang.lyra@gmail.com, joro@8bytes.org, jonathanh@nvidia.com, iommu@lists.linux.dev, jgg@nvidia.com, yangyingliang@huawei.com, orsonzhai@gmail.com, gerald.schaefer@linux.ibm.com, sven@svenpeter.dev, linux-arm-msm@vger.kernel.org, john.garry@huawei.com, vdumpa@nvidia.com, christophe.jaillet@wanadoo.fr, thunder.leizhen@huawei.com, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, chenxiang66@hisilicon.com, dwmw2@infradead.org, cohuck@redhat.com, linux-kernel@vger.kernel.org, robdclark@gmail.com, suravee.suthikulpanit@amd.com, baolin.wang7@gmail.com, robin.murphy@arm.com, 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" On Fri, 1 Jul 2022 14:44:50 -0700 Nicolin Chen wrote: > This is a preparatory series for IOMMUFD v2 patches. It enforces error > code -EMEDIUMTYPE in iommu_attach_device() and iommu_attach_group() when > an IOMMU domain and a device/group are incompatible. It also drops the > useless domain->ops check since it won't fail in current environment. > > These allow VFIO iommu code to simplify its group attachment routine, by > avoiding the extra IOMMU domain allocations and attach/detach sequences > of the old code. > > Worths mentioning the exact match for enforce_cache_coherency is removed > with this series, since there's very less value in doing that as KVM will > not be able to take advantage of it -- this just wastes domain memory. > Instead, we rely on Intel IOMMU driver taking care of that internally. > > This is on github: > https://github.com/nicolinc/iommufd/commits/vfio_iommu_attach How do you foresee this going in, I'm imagining Joerg would merge the first patch via the IOMMU tree and provide a topic branch that I'd merge into the vfio tree along with the remaining patches. Sound right? Thanks, Alex > Changelog > v5: > * Rebased on top of Robin's "Simplify bus_type determination". > * Fixed a wrong change returning -EMEDIUMTYPE in arm-smmu driver. > * Added Baolu's "Reviewed-by". > v4: > * Dropped -EMEDIUMTYPE change in mtk_v1 driver per Robin's input > * Added Baolu's and Kevin's Reviewed-by lines > v3: https://lore.kernel.org/kvm/20220623200029.26007-1-nicolinc@nvidia.com/ > * Dropped all dev_err since -EMEDIUMTYPE clearly indicates what error. > * Updated commit message of enforce_cache_coherency removing patch. > * Updated commit message of domain->ops removing patch. > * Replaced "goto out_unlock" with simply mutex_unlock() and return. > * Added a line of comments for -EMEDIUMTYPE return check. > * Moved iommu_get_msi_cookie() into alloc_attach_domain() as a cookie > should be logically tied to the lifetime of a domain itself. > * Added Kevin's "Reviewed-by". > v2: https://lore.kernel.org/kvm/20220616000304.23890-1-nicolinc@nvidia.com/ > * Added -EMEDIUMTYPE to more IOMMU drivers that fit the category. > * Changed dev_err to dev_dbg for -EMEDIUMTYPE to avoid kernel log spam. > * Dropped iommu_ops patch, and removed domain->ops in VFIO directly, > since there's no mixed-driver use case that would fail the sanity. > * Updated commit log of the patch removing enforce_cache_coherency. > * Fixed a misplace of "num_non_pinned_groups--" in detach_group patch. > * Moved "num_non_pinned_groups++" in PATCH-5 to the common path between > domain-reusing and new-domain pathways, like the code previously did. > * Fixed a typo in EMEDIUMTYPE patch. > v1: https://lore.kernel.org/kvm/20220606061927.26049-1-nicolinc@nvidia.com/ > > Jason Gunthorpe (1): > vfio/iommu_type1: Prefer to reuse domains vs match enforced cache > coherency > > Nicolin Chen (4): > iommu: Return -EMEDIUMTYPE for incompatible domain and device/group > vfio/iommu_type1: Remove the domain->ops comparison > vfio/iommu_type1: Clean up update_dirty_scope in detach_group() > vfio/iommu_type1: Simplify group attachment > > drivers/iommu/amd/iommu.c | 2 +- > drivers/iommu/apple-dart.c | 4 +- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 15 +- > drivers/iommu/arm/arm-smmu/arm-smmu.c | 5 +- > drivers/iommu/arm/arm-smmu/qcom_iommu.c | 9 +- > drivers/iommu/intel/iommu.c | 10 +- > drivers/iommu/iommu.c | 28 ++ > drivers/iommu/ipmmu-vmsa.c | 4 +- > drivers/iommu/omap-iommu.c | 3 +- > drivers/iommu/s390-iommu.c | 2 +- > drivers/iommu/sprd-iommu.c | 6 +- > drivers/iommu/tegra-gart.c | 2 +- > drivers/iommu/virtio-iommu.c | 3 +- > drivers/vfio/vfio_iommu_type1.c | 352 ++++++++++---------- > 14 files changed, 229 insertions(+), 216 deletions(-) > _______________________________________________ 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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 5C69FC433EF for ; Wed, 6 Jul 2022 17:43:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Qmx788V9s3niviWRl8vuq+bKrjUqmUshxsKhoOeLaB4=; b=pDD1KzXahHDGHM fdbHbu4Dui+vhaY/UvONCwbDXWThA4SK4Hw1dTDV2IzFpbaq2KsEYRLimxUP5svCg6yFIdqeX+Cp3 VPmlhrLd2a6Qfk0XTRhX1520RC55X9jy5CJOkx5CqcJL7K6s1bVbT209MgGZBnF8hAsXB05CvzlCd /zg/zJmVTuznq5SXWO7jRBb8DP4FbfudVXy+tYlEnNqdUku7fFznLgLoniqQf7aOCb8jgzYwFqMyF y7z1ptk90pO5y9Hn3sc2oU9UpWFVeMHwVLGOO6mstzWGQ6zurjvvNoxkKJRgRmpQdqDfYiBdYVBVd jke87mfa7gAjrK9zf9Kg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o992m-00Blgy-4Z; Wed, 06 Jul 2022 17:42:32 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o992h-00BleS-Nd for linux-arm-kernel@lists.infradead.org; Wed, 06 Jul 2022 17:42:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657129343; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Bm6ni0e0Z3ZqDaHM6VmzfCaa2VxT43x1YW4zQJliK1o=; b=bRkNBhGdBd4GpOyFO/Su+lYkljtGNjfykD/xASJje7SZNJBA6RJte2DlkBfYHLx3RlnBN+ /HLbnsI9ryG3lE2z9mVCAXkoTojej1HGbsD6pT7A6/sjNFefiqyXy010/YX7ov4kAs1D20 QlS7Q8kevrTWlCWsdYPI4mpZdKuJIdY= Received: from mail-io1-f72.google.com (mail-io1-f72.google.com [209.85.166.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-453-cWGMmLPvNBiELaKMcZ2bzg-1; Wed, 06 Jul 2022 13:42:20 -0400 X-MC-Unique: cWGMmLPvNBiELaKMcZ2bzg-1 Received: by mail-io1-f72.google.com with SMTP id h73-20020a6bb74c000000b0067275998ba8so8394472iof.2 for ; Wed, 06 Jul 2022 10:42:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=Bm6ni0e0Z3ZqDaHM6VmzfCaa2VxT43x1YW4zQJliK1o=; b=hDjOJz3pMHHRSCA6RfjytLj0OrBhthVT/SnrVTXzGnULCO+Nq5oixddfuPxr18lzXF VWDYOBI+/vb8dshYJ2mxibc0eJWP0ABNjqsQz3UtSCYiQdXO69AjMR+MXkQUxhfDI/Bj RcLaZCuJQ6zNSz0KXS2rBLQ4Q0gKLhJj/d3BEc3Pd4/8UFAPqip0IhSnTX75WoBmLUYd 6gx0O5ueRewkwDEz63UY9Btb3EXqercffDmbJFzr32qkyNAznYeIhM+DCZIxuKfUgmAF W8UU4jAo3szC9RUPdTLWr2LZlFiKuSUmkm/ORPfoAenkrnVH/z+z7TvZxvLZ/TgHUMAw 2QGA== X-Gm-Message-State: AJIora8HtnHX35cXpZ6Q3iYF/Fjfqs9ox1nTeZo5YvW+LopgrNhnvMsV zVmsTMamT+EVl5kIgB3KpFd9VQwhumajZPqlTmv9HdNZ/Y2PIhlH5heT976Rh/cPzJRQ85Wnttv syAGMO+UdgvJcRJO70zoY3SpzUgE3gn3GP78= X-Received: by 2002:a05:6e02:1be6:b0:2db:ea7f:10c4 with SMTP id y6-20020a056e021be600b002dbea7f10c4mr17220890ilv.248.1657129340258; Wed, 06 Jul 2022 10:42:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tKW5hHrIbN8D8MKAPlov0FsaTgJJCZrivyPi82ikNP5NQmibHb26OWtdHiMispm5nOi3tbJA== X-Received: by 2002:a05:6e02:1be6:b0:2db:ea7f:10c4 with SMTP id y6-20020a056e021be600b002dbea7f10c4mr17220872ilv.248.1657129339926; Wed, 06 Jul 2022 10:42:19 -0700 (PDT) Received: from redhat.com ([38.15.36.239]) by smtp.gmail.com with ESMTPSA id i83-20020a6bb856000000b0065a47e16f53sm17005663iof.37.2022.07.06.10.42.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 10:42:19 -0700 (PDT) Date: Wed, 6 Jul 2022 11:42:17 -0600 From: Alex Williamson To: Nicolin Chen Subject: Re: [PATCH v5 0/5] cover-letter: Simplify vfio_iommu_type1 attach/detach routine Message-ID: <20220706114217.105f4f61.alex.williamson@redhat.com> In-Reply-To: <20220701214455.14992-1-nicolinc@nvidia.com> References: <20220701214455.14992-1-nicolinc@nvidia.com> Organization: Red Hat MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=alex.williamson@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220706_104227_916088_86CB450E X-CRM114-Status: GOOD ( 25.35 ) 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: , Cc: linux-s390@vger.kernel.org, marcan@marcan.st, mjrosato@linux.ibm.com, virtualization@lists.linux-foundation.org, thierry.reding@gmail.com, will@kernel.org, alyssa@rosenzweig.io, jean-philippe@linaro.org, kvm@vger.kernel.org, zhang.lyra@gmail.com, joro@8bytes.org, jonathanh@nvidia.com, iommu@lists.linux.dev, jgg@nvidia.com, yangyingliang@huawei.com, orsonzhai@gmail.com, gerald.schaefer@linux.ibm.com, kevin.tian@intel.com, sven@svenpeter.dev, linux-arm-msm@vger.kernel.org, john.garry@huawei.com, christophe.jaillet@wanadoo.fr, thunder.leizhen@huawei.com, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, chenxiang66@hisilicon.com, dwmw2@infradead.org, cohuck@redhat.com, linux-kernel@vger.kernel.org, robdclark@gmail.com, suravee.suthikulpanit@amd.com, baolin.wang7@gmail.com, robin.murphy@arm.com, baolu.lu@linux.intel.com 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 On Fri, 1 Jul 2022 14:44:50 -0700 Nicolin Chen wrote: > This is a preparatory series for IOMMUFD v2 patches. It enforces error > code -EMEDIUMTYPE in iommu_attach_device() and iommu_attach_group() when > an IOMMU domain and a device/group are incompatible. It also drops the > useless domain->ops check since it won't fail in current environment. > > These allow VFIO iommu code to simplify its group attachment routine, by > avoiding the extra IOMMU domain allocations and attach/detach sequences > of the old code. > > Worths mentioning the exact match for enforce_cache_coherency is removed > with this series, since there's very less value in doing that as KVM will > not be able to take advantage of it -- this just wastes domain memory. > Instead, we rely on Intel IOMMU driver taking care of that internally. > > This is on github: > https://github.com/nicolinc/iommufd/commits/vfio_iommu_attach How do you foresee this going in, I'm imagining Joerg would merge the first patch via the IOMMU tree and provide a topic branch that I'd merge into the vfio tree along with the remaining patches. Sound right? Thanks, Alex > Changelog > v5: > * Rebased on top of Robin's "Simplify bus_type determination". > * Fixed a wrong change returning -EMEDIUMTYPE in arm-smmu driver. > * Added Baolu's "Reviewed-by". > v4: > * Dropped -EMEDIUMTYPE change in mtk_v1 driver per Robin's input > * Added Baolu's and Kevin's Reviewed-by lines > v3: https://lore.kernel.org/kvm/20220623200029.26007-1-nicolinc@nvidia.com/ > * Dropped all dev_err since -EMEDIUMTYPE clearly indicates what error. > * Updated commit message of enforce_cache_coherency removing patch. > * Updated commit message of domain->ops removing patch. > * Replaced "goto out_unlock" with simply mutex_unlock() and return. > * Added a line of comments for -EMEDIUMTYPE return check. > * Moved iommu_get_msi_cookie() into alloc_attach_domain() as a cookie > should be logically tied to the lifetime of a domain itself. > * Added Kevin's "Reviewed-by". > v2: https://lore.kernel.org/kvm/20220616000304.23890-1-nicolinc@nvidia.com/ > * Added -EMEDIUMTYPE to more IOMMU drivers that fit the category. > * Changed dev_err to dev_dbg for -EMEDIUMTYPE to avoid kernel log spam. > * Dropped iommu_ops patch, and removed domain->ops in VFIO directly, > since there's no mixed-driver use case that would fail the sanity. > * Updated commit log of the patch removing enforce_cache_coherency. > * Fixed a misplace of "num_non_pinned_groups--" in detach_group patch. > * Moved "num_non_pinned_groups++" in PATCH-5 to the common path between > domain-reusing and new-domain pathways, like the code previously did. > * Fixed a typo in EMEDIUMTYPE patch. > v1: https://lore.kernel.org/kvm/20220606061927.26049-1-nicolinc@nvidia.com/ > > Jason Gunthorpe (1): > vfio/iommu_type1: Prefer to reuse domains vs match enforced cache > coherency > > Nicolin Chen (4): > iommu: Return -EMEDIUMTYPE for incompatible domain and device/group > vfio/iommu_type1: Remove the domain->ops comparison > vfio/iommu_type1: Clean up update_dirty_scope in detach_group() > vfio/iommu_type1: Simplify group attachment > > drivers/iommu/amd/iommu.c | 2 +- > drivers/iommu/apple-dart.c | 4 +- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 15 +- > drivers/iommu/arm/arm-smmu/arm-smmu.c | 5 +- > drivers/iommu/arm/arm-smmu/qcom_iommu.c | 9 +- > drivers/iommu/intel/iommu.c | 10 +- > drivers/iommu/iommu.c | 28 ++ > drivers/iommu/ipmmu-vmsa.c | 4 +- > drivers/iommu/omap-iommu.c | 3 +- > drivers/iommu/s390-iommu.c | 2 +- > drivers/iommu/sprd-iommu.c | 6 +- > drivers/iommu/tegra-gart.c | 2 +- > drivers/iommu/virtio-iommu.c | 3 +- > drivers/vfio/vfio_iommu_type1.c | 352 ++++++++++---------- > 14 files changed, 229 insertions(+), 216 deletions(-) > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel