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 2DA30C43334 for ; Thu, 30 Jun 2022 20:39:40 +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:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=hhzLXdWOO+z0optWOB5DBlGvSdlP0KiUPH7avJFr5HU=; b=je6o3nRIoImdU8 XAXqIQIr9SgS3IQOv7q7oI/bCupLUT8AuSACBTdlWJjc8hZrYOMt9Js368yjdqhi4Yy21bWfBmoOO UlyqxhJOHxrzx2qEwoUc8FOx0DK+YJqZnfQ2ihnU8sjZLalQr1Gp3KwE0GXwue+6UHUp/jPSRXlmX LXWuWlG5HWK+F6tDQdnII6pmELv7Uh2LI6CAgt6j5VYcwGLKsJ4vPeGd3e+lIVYZi5VW1p6n8WCm6 AtI6M8njwU0wXtUGnNcras9T94Uw6jLmcekQT6GMrkjwJERT7JqKb7RTIZzAUD937UAlQLdFZLTR4 NeJqdIs2p/CKvlo/n/FQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o70uY-001Qvv-RY; Thu, 30 Jun 2022 20:37:15 +0000 Received: from mail-mw2nam12on2083.outbound.protection.outlook.com ([40.107.244.83] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o70uU-001Qo9-AU for linux-arm-kernel@lists.infradead.org; Thu, 30 Jun 2022 20:37:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dsrWc9LP1/x3Gr29KFWUFwckz2TE/+SfFF81KBdGjb/l//H9MxqelvuaNY9h3tLg0kET4eLda6hU5/wtbaji+NQcJanxL1ALWAebqrKboLh7++7VSksFj3QW7LNNjNrxrZL6mAVhghFv/y0Mk+FGkYGGVTU6RkYJ5MERnCC1wfmbhC3q8rIC9kISGw4TRvrgZQWF0S6Kiy1Db/xiXN0eBtbXiPftqW4AGsH6+qg8tQJ455C9+T602zt7LLfRN1v7Rear7Ii+coTB0m58UkhyiRV4CyW6k5SmWi4r9ialnfUqitXdWn4O9NXTaBOh8JvI7C2ButtI1plhaH+/Qwg+Ow== 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=febXSRzXK0Ih93Xah1RdUyDSoDrY6EiMpBtiKcEx6to=; b=EOkQBkEKSeBgAAdvynnWAOymZ1Kzu3joJwTxKgA84gZz+w+coUiC/AsIZ/wKSGLk3IkSUAOnJEOIRmDWlo0PrJH1bV4NQ4EUGborLGpia5TFF2NtOS9Lz4vdrjh9U/wMWRBrW0OwcBmNEUfQ+oxQkv4DHCMm9nWQy+igBr71VtIV8nWTVdZY8W30kwVgGRFpqBDBKLXzehWbD45PLvfpaGKC7qO7HHTGyxIgjfQlrJ5TX1sTjx5sqOv8CpfzhZKEf/Al3EB3u1JviYuPpXDwyD4UsK30Kt30JYlp/O3AnmF2donFrLPkmUkm7ZZYTOQCrIIgvAADAnN5irDcmKY+DQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=gmail.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=febXSRzXK0Ih93Xah1RdUyDSoDrY6EiMpBtiKcEx6to=; b=mS26Z44Jj3O7Qxeh5u8g+Z+VVPOJwsMH83fJpXlqwdnFuUNdfrGE0zSOpryzJnfV/2Ad1X42mDG8MmnbaADPtBtRd5al9dyRr7DALBiX7qxv+YgHxP8kp0vEm2V6N8cDnCXqulxgfsTV3JsNfKYuHLmTNZdDraZDLOX3mPh22gorV70G722CZdQcDkUt/Hoii+bdh296PvKUNILouZ8UOkIK87J+lEnNN5bYd0WSfSyBeDLidX6e/v8iIB3E9hxLtA9hyLbnQsIM2A3MdmP3Tk5KG8ssnTmkWR16ntM+/X8UFEMqYvJaRnDZvPdxW0u6dsqSTMxyP3sUm9MGsgNJ+A== Received: from DS7PR03CA0221.namprd03.prod.outlook.com (2603:10b6:5:3ba::16) by DM6PR12MB4010.namprd12.prod.outlook.com (2603:10b6:5:1ce::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.18; Thu, 30 Jun 2022 20:37:01 +0000 Received: from DM6NAM11FT023.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3ba:cafe::2c) by DS7PR03CA0221.outlook.office365.com (2603:10b6:5:3ba::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.14 via Frontend Transport; Thu, 30 Jun 2022 20:37:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.238) by DM6NAM11FT023.mail.protection.outlook.com (10.13.173.96) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5395.17 via Frontend Transport; Thu, 30 Jun 2022 20:37:00 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Thu, 30 Jun 2022 20:37:00 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Thu, 30 Jun 2022 13:36:59 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.11) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Thu, 30 Jun 2022 13:36:58 -0700 From: Nicolin Chen To: , , , , , , , , , , , , , Subject: [PATCH v4 0/5] Simplify vfio_iommu_type1 attach/detach routine Date: Thu, 30 Jun 2022 13:36:30 -0700 Message-ID: <20220630203635.33200-1-nicolinc@nvidia.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9bba5a0c-a2a0-4a11-cb62-08da5ad848fb X-MS-TrafficTypeDiagnostic: DM6PR12MB4010:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?2tJAYCh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3WDA/?= =?us-ascii?Q?Fezhywr4WfltfJHRGMjcfQPQW962wzrojf91h6fvYec0s0dnVDpSAuVQmgQh?= =?us-ascii?Q?0hZbhrvPK+uolOL713jD7Zq1BMMn0RBVyI5CkJ4iHj2HJAjz8kZDsb99Z3Da?= =?us-ascii?Q?v7ppHSz5/r6VlyGpsTzk5zOUSPjS9eghBa8wchgC3DFwTTk=3D?= X-Forefront-Antispam-Report: CIP:12.22.5.238;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230016)(4636009)(346002)(39860400002)(136003)(396003)(376002)(36840700001)(40470700004)(46966006)(186003)(70586007)(5660300002)(70206006)(316002)(966005)(86362001)(8676002)(8936002)(921005)(1076003)(356005)(4326008)(2906002)(47076005)(82740400003)(36860700001)(7406005)(83380400001)(7416002)(54906003)(81166007)(40460700003)(426003)(110136005)(7696005)(41300700001)(478600001)(82310400005)(2616005)(6666004)(336012)(26005)(40480700001)(36756003)(83996005)(2101003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2022 20:37:00.8993 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9bba5a0c-a2a0-4a11-cb62-08da5ad848fb X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.238];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT023.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4010 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220630_133710_404147_D57D47F9 X-CRM114-Status: GOOD ( 13.83 ) 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: mjrosato@linux.ibm.com, virtualization@lists.linux-foundation.org, thierry.reding@gmail.com, alyssa@rosenzweig.io, linux-s390@vger.kernel.org, kvm@vger.kernel.org, jonathanh@nvidia.com, iommu@lists.linux.dev, yangyingliang@huawei.com, gerald.schaefer@linux.ibm.com, 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, cohuck@redhat.com, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, suravee.suthikulpanit@amd.com, dwmw2@infradead.org 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 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 Changelog 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 | 6 +- 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 | 340 ++++++++++---------- 14 files changed, 224 insertions(+), 210 deletions(-) -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel