From patchwork Mon Nov 4 17:41:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13861829 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 BA84ED1BDD9 for ; Mon, 4 Nov 2024 18:13:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding: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=3FmUti5hyPngciJaVxe7xicKq4d8a253X8yWeIASYzw=; b=flyxpCueSJVFHcwUSFI7q+Rj6m zy8MxKrWrzB5pJLja4XnPRtl7T+jIC3bk3fwR7hjrfKyC506KCtJeAC8aqud5EaDqjTB9tOJDB8MS rNIMIjjoiUL+9BtDeZsETNO2m8Asdt0IAXM2wvzy0/RwfAqgUHhICi8lDde0HJ8mEeMSzmSJ59Yth J8eC+a5H7U+1E2Nw7kHOwWlIppo+3x8sB2HtSSI9yWdM4VD5YRZddf+LFysslMELmR95T/tmvmWB6 tNPTqFud+DCxLNRxxb92QsqSfIkh/mFS25L9Ur6Ffj+RNkxXtIp6HwVVTU8A1QmnvXTSbXISqTJu7 NdE61Z1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t81ZR-0000000Egaz-0LKW; Mon, 04 Nov 2024 18:12:57 +0000 Received: from mail-bn8nam11on2062f.outbound.protection.outlook.com ([2a01:111:f403:2414::62f] helo=NAM11-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t816Z-0000000EZKk-1rIb for linux-arm-kernel@lists.infradead.org; Mon, 04 Nov 2024 17:43:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AIzEIylxcHRps6/EZCt4Sqm39kGABWndptlmWE4dYq8At/jyRE5xG33dgbuWJpdC+eIfhmgK/QJkBNrwQwDUxN+35mLk79LH4LVN3a74/lRNOOzXa0tQVrF6JsPVG8fNktYP80mFL9KTfUEIyXq8G3uyJ+GbO39ck6OpRwsuiM18TC/EzWkhANMqCsPdz7GKmKLCqvu8CsJs6pIIXK57f/ni3t7MQi0uv4Fr4UVqcMvNUYOdAT+PlP8Ytx1rX2r4DwStwQwQ6ZgIBHnzqFTOqtZ6+sp+wBI3dd8M3suL6zdGtAi46wFxJP8E9Y+y4g4J6fOVsZvz6o0YvXpbh94/7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=3FmUti5hyPngciJaVxe7xicKq4d8a253X8yWeIASYzw=; b=HyC5W6Oa+VbH3BhUvBG9+bY/xhkUVfBJRE6KZk4j32g5WG9H/LfcptKCTgRqQKxyIP6ky+fmGjfqwSOMlJufuLDj/onLgy2ojX8wa3JPX3ySq4IzoyEtbI7gngaSEwonmvmSlBE6/KG10xP/sY5vey3zlmM9mNys8cK0FjuuXMHyWVgdZ7g/wNYe4y6n7hw4St+pXsA4KvxNnVCcwUxJixRvr/adqjpPuDBXaNeDrIMvoxpmcz947HpV6kpNcwfqHKzzGqeHbXVu+kCPnCYg+x/5fSu6szu0zoEW7uc0ltkGTsmaTx0Zpma7jcuTLpcXis00a4uyrqF9Du31CRIXMw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=3FmUti5hyPngciJaVxe7xicKq4d8a253X8yWeIASYzw=; b=kSlXz3CBHdilCkShRtJU60f2d6VT2+q0XGV0wivq6MPRJ9JZGI5qMOvxjpdFsBUuyYOFUTFDX37kuWCucZawydQ39JzT+vBBLYyYrFdj73TId+iyKZ1Pr33gche9ZKxE310PwKcmZA9+ZPFLKrkCEm60O5KlXZCrJ9KHAzmQDDJ+72wuOw0NyEtVjODYn9txvLC+brOwhWrCMz4qeUvpdIE6YEIUlwp5h3SewXqUcpvOXbMOVj0mUPOYgNEMaezJD+H9B9fAQ9IOqtI+DoaSfqzaOXlC3gYN2ajdMQcz3PQhgPm76Mchn6YR7KghxToRdcQT/W7Q09D3RCwYTObYVQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CH3PR12MB8659.namprd12.prod.outlook.com (2603:10b6:610:17c::13) by IA1PR12MB6578.namprd12.prod.outlook.com (2603:10b6:208:3a2::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Mon, 4 Nov 2024 17:41:33 +0000 Received: from CH3PR12MB8659.namprd12.prod.outlook.com ([fe80::6eb6:7d37:7b4b:1732]) by CH3PR12MB8659.namprd12.prod.outlook.com ([fe80::6eb6:7d37:7b4b:1732%4]) with mapi id 15.20.8114.015; Mon, 4 Nov 2024 17:41:33 +0000 From: Jason Gunthorpe To: iommu@lists.linux.dev, Joerg Roedel , linux-arm-kernel@lists.infradead.org, Robin Murphy , Will Deacon Cc: Boris Brezillon , dri-devel@lists.freedesktop.org, Liviu Dudau , patches@lists.linux.dev, Steven Price Subject: [PATCH v2 3/3] iommu: Add a kdoc to iommu_unmap() Date: Mon, 4 Nov 2024 13:41:31 -0400 Message-ID: <3-v2-fd55d00a60b2+c69-arm_no_split_jgg@nvidia.com> In-Reply-To: <0-v2-fd55d00a60b2+c69-arm_no_split_jgg@nvidia.com> References: X-ClientProxiedBy: BL1PR13CA0433.namprd13.prod.outlook.com (2603:10b6:208:2c3::18) To CH3PR12MB8659.namprd12.prod.outlook.com (2603:10b6:610:17c::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB8659:EE_|IA1PR12MB6578:EE_ X-MS-Office365-Filtering-Correlation-Id: 0ac6cfea-f5fc-4adc-6a5a-08dcfcf7ebd9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: sZYyiaHSjmF9C2eyWM+0gsK/CmYCoTcHAHF6ct4e/8G6l5rrWlrwo02mPJO0kI0e/sn1QwwQIfFQ3iKwsO1J5fHa/SaMlXI/HXCqyWBdyh9ReXM1D9Ozg3bnWOBTa/A4PbpKyriOmBBaYZ1oqVVS/GRG4fVivxH1aC4jVAgpBCKOxeCqGK81m37Ab63ve3XZxpVsSzLCLISqk489Ap3cHRjxfAbM7SDImlgWNCt6q3Lwegzw+nChE2EF6j1sUhF7K3j511I04mvH9diE7g4cIMP5O2kZznkJz1bEb6Qon9kyBEOOdA9sbnjdnt/qUhNug4PLKnW5evaZxKmErMsFcFjvNLTX9QSgbrvHA/kNJbuP2bU4GfifJv6v35JwWMiZq/i9JP5akGJRktijo/SG3/NykNb0/cf/9bOgri2pNBw+txrWFo4p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Qclxlz7kEltvQdkqhhJT+/cOIaq5ycURd+t9L44Z99VUW/ENouB8+ZsaEwvNreN5IvVhA1Hu8oV5PMFxwTeZqQYRfZvpjanPPT921E6PfJo976QDyiL1kxlQwiCtuKpumZEsTC8zJcfoArnSC3D5pgbtnnlLC1qcW+9ztyH/jAkV6gaI7Lv77AiJUGMcgm0qIX04jkh9QnwbAuhCC9oXuODMVhgRhC5AwnYmJCkTQ75Vg9lTJMPJKaGxj1HsLaifVB5P9bh5zZvbY67JCdUK4yHAN4MXQFFivqMLfW8jlNnHcA6oK9+LEp6e+buBszXGiFvL0cLlVS54lP8gsZmkvZ0S/h8X/FGpUMo9ue4qgulH9WQBuvQY7HEmo+Cg8X1YOIKutDThg5tSAysjqTmM+RZMawYcgwvIH7Wedm9Lv8soq88PvNkardt0HWEVfVcyz3mrpMv35sSfPn/YkQmF5Iw+dMMM1yjfhbTEEU813rh3gktPSPOzdU7/RENjFv99OiOt25f3uUGLjPmnHDhyQiOdbQfkN1pYtQ2d7n5bLiW0eBnzMpbTm2bPN9ktgjBOLh69nBrE X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0ac6cfea-f5fc-4adc-6a5a-08dcfcf7ebd9 X-MS-Exchange-CrossTenant-AuthSource: CH3PR12MB8659.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2024 17:41:32.6334 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VffEiAghkG2nFxqpAdL4DKhEJioefqDnLF77zGzItlqhvtM6awX4tDVwSdm08nuC X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6578 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241104_094307_494546_05BC42DC X-CRM114-Status: GOOD ( 11.33 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Describe the most conservative version of the driver implementations. All drivers should support this. Many drivers support extending the range if a large page is hit, but let's not make that officially approved API. The main point is to document explicitly that split is not supported. Signed-off-by: Jason Gunthorpe Reviewed-by: Liviu Dudau --- drivers/iommu/iommu.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 83c8e617a2c588..d3cf7cc69c797c 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -2586,6 +2586,20 @@ static size_t __iommu_unmap(struct iommu_domain *domain, return unmapped; } +/** + * iommu_unmap() - Remove mappings from a range of IOVA + * @domain: Domain to manipulate + * @iova: IO virtual address to start + * @len: Length of the range starting from @iova + * + * iommu_unmap() will remove a translation created by iommu_map(). It cannot + * subdivide a mapping created by iommu_map(), so it should be called with IOVA + * ranges that match what was passed to iommu_map(). The range can aggregate + * contiguous iommu_map() calls so long as no individual range is split. + * + * Returns: Number of bytes of IOVA unmapped. iova + res will be the point + * unmapping stopped. + */ size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size) {