From patchwork Thu Aug 15 15:11:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13764897 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31409C52D7D for ; Thu, 15 Aug 2024 15:11:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B30C16B0124; Thu, 15 Aug 2024 11:11:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AE04C6B0125; Thu, 15 Aug 2024 11:11:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8E2CD6B0126; Thu, 15 Aug 2024 11:11:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 72D386B0124 for ; Thu, 15 Aug 2024 11:11:47 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3896B1A15FD for ; Thu, 15 Aug 2024 15:11:47 +0000 (UTC) X-FDA: 82454819454.11.02F5375 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2057.outbound.protection.outlook.com [40.107.92.57]) by imf05.hostedemail.com (Postfix) with ESMTP id 7456710001F for ; Thu, 15 Aug 2024 15:11:44 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=YnuUYWUD; spf=pass (imf05.hostedemail.com: domain of jgg@nvidia.com designates 40.107.92.57 as permitted sender) smtp.mailfrom=jgg@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723734668; h=from:from:sender: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:dkim-signature; bh=ih2iiSzTZXbZw5C0UvsFEnc7n2vkMt87bzhOXl2eUhg=; b=yXqUJogjzwCvVnr2N+q7C4/DipyKT70rKaZuu4AV8v8tm9LcPSTLgu1aplxtGFRKVF1et4 aQweMGi7P8Z4wfqVAIM8F6Td/uoFd/Imw01wa1uQB3Xm+IgBZ8HWjzUEMExHVWfm+1M5EE YMVPKEzgtPDy9eAtZaekUNpTzmKWCLg= ARC-Authentication-Results: i=2; imf05.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=YnuUYWUD; spf=pass (imf05.hostedemail.com: domain of jgg@nvidia.com designates 40.107.92.57 as permitted sender) smtp.mailfrom=jgg@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1723734668; a=rsa-sha256; cv=pass; b=oTLA/Ymot9BcaNEw3HPVBJFeIL1XPofxm0PnuvIO5+gN5nGUdaoImg6WL+7P27a9v1dfus Zwdh9vRc4L4ex+tWCUlnCWKUeVazKNTo9zN3QT2rpFG4NXmhGkkSXDwVCzWXSJb7WfaAIe /FWeibGstX8LwKJ6nGQbc6QY/oCPW4I= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kJKHuRXzk+Tcy0vBAUCL1X0jojrh7/++AooYuMcDBLRGDIf0/lE7v0bQGt8HwgQDMM91wYbxDTJKs6bmzk2pD7w8l0AHYX+I8o22TH7IleVuHV4Wrtw2mUFWnV8EKWznRChe875X9c+dR2Ket5ravAaOOyuj7biWoGJPT8Y8ToFeQ5y229aO7xBMr+Acwr0W1q2ubCRRxOi8QZOFtEer3YVkqS8C+/HXgvNI1NORgP2rXwnBJ3I3PPpM8pirTE84BgB5MHuHOBux+JeMo2YsCx/bRKnCLXIzVlIBn2e4bHHFjUoM0RUWmNzRveBa0RAnchLzK5eMwCTwSvRPuyE7Tg== 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=ih2iiSzTZXbZw5C0UvsFEnc7n2vkMt87bzhOXl2eUhg=; b=n3jZ/8/ymiZqrHdsDUsplrYryHWVpIMeq2zgveW45l4XfZqaL9GZxd8HCtoo3A69Q2lQ0yuN5tmwOoInrwCMoB/WvnnYSzwkOGlAKuR1qbFDx4WaRUiZLCR7kEUdzakEk7Nr806Qq6cHhXwvg6ol4uOsYLFNNiSLCk2LJmiKEkdKuCZ5L3Yj9xQ3rAkti44Gx7RaXZ5GLgezhDthoRnjvSeCnuZi9Sf3CT1ky1kbjm5FLBj9jp0Fb91oOVF1gp6hu4S5rq1ZWxrmL8IsDujT+2gQ8uM2HU7FBWvdX26fsKZKo/4Kx1aAI67qRKRiK5liWQiC6Ay7xMiY4SXDtcoxdA== 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=ih2iiSzTZXbZw5C0UvsFEnc7n2vkMt87bzhOXl2eUhg=; b=YnuUYWUD9wjjuuDSf2HDzaYTUPdZrNVYdDb8BWvC7d9exXY+fFq5xbDCEKLUXLt1IO/OV+gQ8GfBVH9idlUpU+uC8si76AKWmyniOeQDE2QjF+PKIfHvwes0FFoHaahAlBCi7mRA7tQV+PYgHuWxGYQd3urFatLMlwtfS/I3T0nPW0Wl/7GLknJ8RBGhqHkWoG3H+ZC/ajkGVql1mkjVlxM2lU8iDJFmPZSbVGL+uR20WYcJCsqa7xxRQuXs3ka6/mOQCkaa4CLGffeMOYQmXeJmzSTVHyDitipWrum7jAkLc8fq2BfcMf8oFRn9DBJ49rC5QShKkbHX99AZW4jA1g== Received: from CH3PR12MB7763.namprd12.prod.outlook.com (2603:10b6:610:145::10) by SN7PR12MB8146.namprd12.prod.outlook.com (2603:10b6:806:323::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.17; Thu, 15 Aug 2024 15:11:34 +0000 Received: from CH3PR12MB7763.namprd12.prod.outlook.com ([fe80::8b63:dd80:c182:4ce8]) by CH3PR12MB7763.namprd12.prod.outlook.com ([fe80::8b63:dd80:c182:4ce8%3]) with mapi id 15.20.7875.016; Thu, 15 Aug 2024 15:11:34 +0000 From: Jason Gunthorpe To: Cc: Alejandro Jimenez , Lu Baolu , David Hildenbrand , Christoph Hellwig , iommu@lists.linux.dev, Joao Martins , Kevin Tian , kvm@vger.kernel.org, linux-mm@kvack.org, Pasha Tatashin , Peter Xu , Ryan Roberts , Sean Christopherson , Tina Zhang Subject: [PATCH 04/16] iommupt: Add iova_to_phys op Date: Thu, 15 Aug 2024 12:11:20 -0300 Message-ID: <4-v1-01fa10580981+1d-iommu_pt_jgg@nvidia.com> In-Reply-To: <0-v1-01fa10580981+1d-iommu_pt_jgg@nvidia.com> References: X-ClientProxiedBy: BLAPR05CA0032.namprd05.prod.outlook.com (2603:10b6:208:335::13) To CH3PR12MB7763.namprd12.prod.outlook.com (2603:10b6:610:145::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB7763:EE_|SN7PR12MB8146:EE_ X-MS-Office365-Filtering-Correlation-Id: 24ec37ee-8034-4c88-5ab5-08dcbd3c8d25 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: Un7aPPwuGhvbOkb+rfT/uc+jo7mEwZyuUIEzbkIQQcFQ6moqOgtWZ93/IhCSkV7YzFZZndkZ0304C86pGPYtQcTEWSWdJ9zOUGdyuGwiAL8D7gTMeyPzibAAFlzEWTQN9NKwr8yRtU6tD+itRTBYUMwSEbuamuyvhSR/LnEf8hE+gZpqUIAptKv8m/fxVfA8g6n/ifOjN6URy0u8P1bangx6JhxLvQM85WREw7ZjOW+twQDmiqLzvVwcE+WndC47KxsKevXsR0Uh0pOwe5okIDL/wWdkZ7Hkd8EPLDJ/y5oCswfaDfvNMd1pnLaL2stO2E3U9nVXIfgJnBqYr3IoMA195uixXcUbgXtrgn9HMi7iDr2Fx+1n17eLN/n5GFWtoz0lWh7RgGdpJNrCOQFOg3R4974kkHrhwuYngEwg8/i1vAiqcpYgDKuFZOTtutL8TDdJIM7sArl1RNc02/D0QZECOSiLt75mwD6dOnc0kM0X1/jHVy2D+NKQOYwpr1A1G1DeYEdOBI9tVqe9sodn4J4wy4ORfLsP/+UhlJzgTPw18/Yh52u0hFbuBM3DnjS5XAn80CGzxKPjlz0e0fw5pL3FLGy7jag5xLEZpFK96ic9loCHOXxJQKziOTESPND/GWNEbr5biKpmB6pZiB1W9Vkt1FsFEbNQwv90BlbpgIzdsrqgbr476nbtbgu6rXwyfy3Ox59Ge9vPkMJnsjYLPNmiEHGMVeWI2jMrsuBNOV3daO7RhOlBQoYs+YpImDLZci5gEC8q19CPJFVNbSBP09RvJLx5rTzR0/PGQf1dCw/qoorEM6Jd3kqrolbI0jaV8t/CcdBAxJhJ2gjnZkb2d/hNeAiGZcUqutVjH02cL+i53lYBxIar8Zd5k1vcwT6DIMtVHVD1lhUpHHXVtHdpJPEoSZosG2zHJKB1nP0vfuT9HxXjcaaRhowB8FCwI3gOnsB6iHZ/kb9V8ynAWxJADoTvXYeAIy+TPPggBZUZzWZyy2OHBrlj+28F7d+oESzBvPiXxwE6ZkrxHVuoEGJW+SceXZKBB8j19DGn78KMfn3oKZfG2EfjNcqhhyUILgcRzYmXNFSKnLXIHzqiNd26kO7D2oD+e4ivDvZqCGabLbmfQuF2rveCd7B0r/+mESG0Tb/LATWfB1UPW9XaSN/rq52SRu8PbsiPP3RbNIFIyDYa2cwOYy7MtsGdc4D/d9iOwooetbwg4qla3z/uq421rmeu5tFeDMTHgb41+V3sHYkb9gW5epyyE32JXGiJOQX7Ekl4ID7QrE87frx+s/Jdd+HVg7XEgTtdqBVZ+YU+fArPBQp9eE+vOM/Y5ebbtzXrBcC6e6+LjsOyVYEpxnrU8w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH3PR12MB7763.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zHaaUriN71aEAQVsBSX/P7JY/DlE580xWLToJ7c4T9EBvScwFimH5tp1pIouU4BXHcSZ1/9QI+/HO8Csfm5OphIm5PlE4AnAEfcPfnDhXL+ftU1NnJIJup87Ug7REFnglNXXg8YQNFNINe5kwwad7wlyHen3vLWK+NflCFjvKCACcV13VxxZUQkhGkCWaoTYaGoKYg63QrzhUa9WNLvea0FL8CFApl9DIOelxayZCbHmZvOZttqCW8BdR/NMuimZBOn4ijiF5myutH0OWNUNG/NsdnjVRim1JcWTzT/0vfUQVCXKLZzxXzJrlt5goFP7bapDEBPFHNEwF6VJcfMYDMoXNvG+JTbE+YU4WEgJ+Zw0wqmItJsq3oyO+sHX/AUBuL9LVR22jTD4fuD8rzG9O50YsncpMGWSiD+S716i54T0bac81P4v7yUqkbZxn5b7r6ajQBgd/C3jwfmsthdlq93uhDZApetAmBFQ/HZIShR6HuGjT4NjMPRqoug+lhZbzFDp+3WKTFsQYE8w1ebJcasF7hXD30O7L5znv9db/HCxHWfI7mUV+ZBq+bstKcjQ/FP5oZ49gO5oFmuJOgBL8Rxfn0dOhIMVxHa2rE4/ECgSokqQ2oryrHC0xbrlPXPU5bgyMWYI5c/Nh+LxvuxZ46C+KLLErT9VE+c12ypEFo2CMkbx/GoW3LUdl1bNe33lz6qp37qYs7IisyrlmNbEaJtxXhYbfl04PT94UZtnY3YdQIRJ+/iMf/iuoLASZq14fwzz0ON+Zy/XmmmfxPZ4x6L1IAghGaU1LO27UIwAL8Ucm4GNT8apENIE4fV9Z+iHU+pL/rr9ER+WwpZZPh2bSw9oyFA/Zd8eyxZ2iGgk1R6q3J9npVZr+vN+TTBTBYni4QZ1E58a+9OJ2/qUAh15R01QmQNYzuYYpfgCAwLIh9E92sjfHAAAe5JDBPM3pTBt3x/X5W2MMRrP5GGcz3s+qPhCJ4us5KWvwbTnReK45UjFJM8jIzi0EWyQ+aK+Fq1XO7/LRuaAz8CPpj+h791O90rmQMBSgCDDRzqQshOkytVM/7fskBGpadTg/iE3GTxTJmuNt/IVB/DVYRLX/RnhWvdUs5xqCBPOBUpyL5pTmdAhz9vUapzr54REQr7Dw7kHZd8KTSKtpYRPszSBEqrjyMoNKPZZKaazekC+UoOM7NQue5V2yJWJoVA5wrsvsCebC+WS21iCgPkK/cnDOhDDWOsJHt+yYiIktRWq6iVxzqiYx0J6JWul/x/A8a8FZOO28SQAHIVsFDbSQVLLDBZQwrugdDzhVPANaWl/hlcJdCGoKlqLsWnVlusNAImmBYdeAbdd8eS6wQ1MgEsoyOkb6HOtvBYJ8s01WWA8/+Cd4rox8CooLG8NkFz3JDCulqu9OsGjhDry+BaGuz7kHK1MmtNoQ1urtNQ6N1bKQinygQELrQHk91UQe2jD4x9mk5Cg/8jNf9BxSMhCzmeCmfoKv2zm9vWe+1WCSMd2RQG8i+Bekip1B8m4jRL2ld0VD0wuQk4/C1oNePT5ghWcRDiIMfPEXfnd6Yq/kPKeCKltnzE= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 24ec37ee-8034-4c88-5ab5-08dcbd3c8d25 X-MS-Exchange-CrossTenant-AuthSource: CH3PR12MB7763.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2024 15:11:34.4851 (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: vTnM+g2enx9VxjQBLA39q/LZBtRau75PYHiwyKcrGHMX4YeHNIMFQ1tFY8hDuVQ1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8146 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 7456710001F X-Stat-Signature: hue94gffztw6xfq5oe1wwgpkfzxxgj95 X-HE-Tag: 1723734704-239594 X-HE-Meta: U2FsdGVkX19ltfBInEDs5+9kpP9BjPUsp+wGGPMhn1FYyaLWjyMZ7cMYYWcEWB0t2u4bN5TUN8qWQb8AxcfaczGnUvmw28Z8JlFQcu2S+H/G+ARBHl+NwjSO3/ZNskrGjB7a53QFQE8Kyl8jkNt01eSN/dqVjD64HC1EwecOv3AKthQHxSBv7NOBHwXoaGdlFVC/ZKQmTB+viTfihKF5VZYY1d4RyAtrHMQVNYEAgbhvD0Ma49T5MLnTaGPVr0P2VWN6ybRfcr6hvmpcXP2FEX9QyO1CzCpPe18pZYMSpeJTihJ3Fja3E51PPAHX8EFHJtUW8zetSxlmZZAZIorllHP21pNDnQOAAsZUv4u+3QM8BbhzaTl54RBy3ZU95PllciHJzJC+kZ8hEhg6sfwzGquhR6eb3DsndxMsl5knG9D03OuKvOd5BOPJKVwRP2BnjsZtsiNd+K7o4yJlOXjhcsJKy9bWR/kw0YWDx6oSmVvEDl7pYOxLmxy8z5OVRa188L9AGwAvyO+4i+XzAfr2LmSuu2b+ct22aU2++mnknvbbk+zqO1J2rUXHafX4I/nY50fH1pqirZxF0VLS4aFUgfj5LQ0h7nSmSm0MVTFu0GJE0UyFR5WWkDldo5p8Fw6lRpj0m/AZX+q/UePTXgffhp3NR2K9RMrYx2bYm/yrfL08FfYoqH7Jhrt5D4Qip0WBUkh5oqbuHB6sjjU87RRLYqabN92TIQcEEvdvyZQqPe18FAJtrGQzQJAfNjGJaBnQlTVBwn5ppsxSj0m/L2Q6c38Gne+BIDCK6WWHviXZVc4KRf0LSZHEM0/aCZYKO8gzy4SX4/uo2srC3hqGzj2cylpOXlfMhOjAsJsFIX0+xfS3EXx2DV3kq2ea1r9AXR/ERalR72RKcs88RnuXBeSAIBhYmQVQ3BcvXyIEYA20mpVyBJpImxd21ElwxpFel5kQVw8MmWvX4DYiOkbRcE8 OwSuY0R8 UHMZLNjG2kflk0/UQcRyqlGwHDKzQjguUnZiy5G+7Dx/pn/yJoPksITxFndopjJLyJmoeV9yFrIQqXjkCmXUDOFLpM+BNXrRf/aUO8EXtm9Sn40vRXeXnI8ukPFXtRyPQG+sZaNyX140YhezvwV196cdsR3iPFDeuWRv5DsSyWtc2P7gs4mmKEUF1oO8CxUsoIlvdVf/2pd+L0KUFu9km1EXQIK7qiJPjztJuSsxN0MO9XtNxTbr+f2/mf3FVy+EH6tp9jVD8o2497okAUZ65gJ8rMeLULA/fGrBuQwkDwben/LLSLyd8YTx+PdCekHdi6O6xnoCNWuH0OicRYBQ6q30SjYe/KPmoXQUQ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: iova_to_phys is a performance path for the DMA API and iommufd, implement it using an unrolled get_user_pages() like function waterfall scheme. The implementation itself is fairly trivial. Signed-off-by: Jason Gunthorpe --- drivers/iommu/generic_pt/iommu_pt.h | 58 +++++++++++++++++++++++++++++ include/linux/generic_pt/iommu.h | 16 ++++++++ 2 files changed, 74 insertions(+) diff --git a/drivers/iommu/generic_pt/iommu_pt.h b/drivers/iommu/generic_pt/iommu_pt.h index 708beaf5d812f7..835c84ea716093 100644 --- a/drivers/iommu/generic_pt/iommu_pt.h +++ b/drivers/iommu/generic_pt/iommu_pt.h @@ -15,6 +15,64 @@ #include #include +static int make_range(struct pt_common *common, struct pt_range *range, + dma_addr_t iova, dma_addr_t len) +{ + dma_addr_t last; + + if (unlikely(len == 0)) + return -EINVAL; + + if (check_add_overflow(iova, len - 1, &last)) + return -EOVERFLOW; + + *range = pt_make_range(common, iova, last); + if (sizeof(iova) > sizeof(range->va)) { + if (unlikely(range->va != iova || range->last_va != last)) + return -EOVERFLOW; + } + return pt_check_range(range); +} + +static __always_inline int __do_iova_to_phys(struct pt_range *range, void *arg, + unsigned int level, + struct pt_table_p *table, + pt_level_fn_t descend_fn) +{ + struct pt_state pts = pt_init(range, level, table); + pt_oaddr_t *res = arg; + + switch (pt_load_single_entry(&pts)) { + case PT_ENTRY_EMPTY: + return -ENOENT; + case PT_ENTRY_TABLE: + return pt_descend(&pts, arg, descend_fn); + case PT_ENTRY_OA: + *res = pt_entry_oa_full(&pts); + return 0; + } + return -ENOENT; +} +PT_MAKE_LEVELS(__iova_to_phys, __do_iova_to_phys); + +static phys_addr_t NS(iova_to_phys)(struct pt_iommu *iommu_table, + dma_addr_t iova) +{ + struct pt_range range; + pt_oaddr_t res; + int ret; + + ret = make_range(common_from_iommu(iommu_table), &range, iova, 1); + if (ret) + return ret; + + ret = pt_walk_range(&range, __iova_to_phys, &res); + /* PHYS_ADDR_MAX would be a better error code */ + if (ret) + return 0; + return res; +} + struct pt_iommu_collect_args { struct pt_radix_list_head free_list; u8 ignore_mapped : 1; diff --git a/include/linux/generic_pt/iommu.h b/include/linux/generic_pt/iommu.h index d9d3da49dc0fe2..5cd56eac14b41d 100644 --- a/include/linux/generic_pt/iommu.h +++ b/include/linux/generic_pt/iommu.h @@ -60,6 +60,22 @@ struct pt_iommu_info { /* See the function comments in iommu_pt.c for kdocs */ struct pt_iommu_ops { + /** + * iova_to_phys() - Return the output address for the given IOVA + * @iommu_table: Table to query + * @iova: IO virtual address to query + * + * Determine the output address from the given IOVA. @iova may have any + * alignment, the returned physical will be adjusted with any sub page + * offset. + * + * Context: The caller must hold a read range lock that includes @iova. + * + * Return: 0 if there is no translation for the given iova. + */ + phys_addr_t (*iova_to_phys)(struct pt_iommu *iommu_table, + dma_addr_t iova); + /** * get_info() - Return the pt_iommu_info structure * @iommu_table: Table to query