From patchwork Tue Nov 5 18:14:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13863349 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 61509D3177E for ; Tue, 5 Nov 2024 18:25:56 +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=nSsxSmPxlksAOVGjYdQmoHC2LN7QlKhIRFvU/0aUrDE=; b=vQt3yB4mBnEdKCOQZ5oNB7hJ+F qUxmjp8V7Hm5OSi6anwFiw4kYAS0PiVTvDtWG6dDKMc6KmFl6V3HOTMDX8LP68x3oO9St09hSkUs6 3UAWaTKOQj8XaxcEnyZuYJy6wH4Yh56ZdVJoMgmq9A2QgIPYSryGn8aX96uNazvz2s924tQlATvKt ZWxK0TsflZ3JczSTPorv+CGH/7I/S/XSpp9H8KNACYq1rR4Lsl2XBYPsfqvsrdNSOijd8uo2MMj93 FzB0vFMKud0PHf8kPHo2rEiz9W80Rz02hTzaocJRVxEOyIhqVP/Sagwb2a894mZIH1EJJaa2cGLmc 8kwpzS2g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t8OFN-00000000Mix-0rAo; Tue, 05 Nov 2024 18:25:45 +0000 Received: from mail-dm6nam04on20605.outbound.protection.outlook.com ([2a01:111:f403:2409::605] helo=NAM04-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t8O5L-00000000LGm-17gA for linux-arm-kernel@lists.infradead.org; Tue, 05 Nov 2024 18:15:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Q+vuUKAisc3Qvt65gYbca/pp1VkLcdrJ2qrjrrF6LAricMe5eZz3QOqin3sAGuAoTW0WT2mGac2AuI8SzzErtWONbkHqmO4j2EIAHB4jJAT1yrw5f4GS8lFUbH3wY4GU/ewOi5iuGP21EiMRmUhm9EASffjQhRVaqtWGUUwyiKJOSPPf9/F01XltILfR2wJWbA8RgcU027d+tACLaTBJ5x4+mM448V1FCmIWIcRioyTbsFO8Ga7FsY7E/Ac2Mffwuuqk1KXQMNUnm63wI9ssdRVChQlOri1ByE9vopVA0shV95nwmFZhnZ9EoGhAhMkAsQQ/qSDGCAmygQBDI3fYGw== 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=nSsxSmPxlksAOVGjYdQmoHC2LN7QlKhIRFvU/0aUrDE=; b=CMODATzuOphn/4KhGkurmO4OVXKAPCQXKMu6JXFeIdTQW4Y3oZRZ5m1nStSInb2TjRNKjWEU2yAmTO+BODflK7tHsvaT+rd4/BpW4APUOvYprwdyzVst+ITjkbG4TCn5X7EnwSSnMtBXtB3aZDiAD3ZgLQy/oVP+cpVkanb6sBUXNYgnUsNpGcKiXvFhmGz3OAG/HkMVYcF0RtJ0g2HGAOtgx/brtYHA8IJcbFFgwiYx194SufYgGGzRA/lrFbN+T5TM2rB8SBFYWON5TLG0AakKgdn04yiH1iso5imG3wu9ybRtENvuE/5HXFrCVNpn+5EvKqPDTFBwIe7pemitoQ== 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=nSsxSmPxlksAOVGjYdQmoHC2LN7QlKhIRFvU/0aUrDE=; b=ix3xOg95VV7fD34FVsFNxiNYrCYqM11njBLw/YSxT5wXr3ghNDukiuRw767X4Lo71qP2wRsuAdjmb5qa3nyZDdUznvuWqFWVciMmjv1SyHI/YlNiwb4KcVpQnHsckXB3EmlGbXErBcM87fLFfj+AX+74K2+p6n8sjRX4CafKLZHF+64KlR+H9nfpqMyeggurI8+UZfj1jfjGxI/wZhkm1/Se9NSJjXqFxS4+kG6J4b+ZYPhixoTR7Jv7V4p7Kbh9wO7Gu7rsnb5Qoz+J3wXunPIb6F0Sh1jYwszXvLVfwk0fyngHmbu3Up7lYs+6t3S3Cv0cFEY5CkGxM11xXnKZIQ== 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 IA0PR12MB7508.namprd12.prod.outlook.com (2603:10b6:208:440::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18; Tue, 5 Nov 2024 18:14:28 +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.8137.018; Tue, 5 Nov 2024 18:14:28 +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 v3 2/3] iommu/io-pgtable-arm-v7s: Remove split on unmap behavior Date: Tue, 5 Nov 2024 14:14:25 -0400 Message-ID: <2-v3-b3a5b5937f56+7bb-arm_no_split_jgg@nvidia.com> In-Reply-To: <0-v3-b3a5b5937f56+7bb-arm_no_split_jgg@nvidia.com> References: X-ClientProxiedBy: MN2PR05CA0054.namprd05.prod.outlook.com (2603:10b6:208:236::23) To CH3PR12MB8659.namprd12.prod.outlook.com (2603:10b6:610:17c::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB8659:EE_|IA0PR12MB7508:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a7b208d-38aa-4d57-2897-08dcfdc5af95 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|366016; X-Microsoft-Antispam-Message-Info: okNpcY9dailgwi/fcAMGhW25C78owI2s5Lcl0614gGiJEeOkeuUr2q2EOTMQyC180xVHHepgGjGDFSss7uACRKIPxBVSQPGm8kxkY2iLpAzUuAaNyRlAxQkUwniXlc34xrawfAkc5T8kDTke57KiJ4B0UtiSmrNuEzsklOQmPKQBAoDWQRyFJ2ARmEGhqLcJw+x5eUNTmjvqw2AqFAcQhNwYFkv0B4iepTle94uqLxop9jCqzEhfbWhEx4oK3lEjmFEJT5c2JHlNV5OBeabnuRDaWbPkh+10nEDzD1GB3ljRpVlTBBmqrzAkaZ6OUwkU+qdNHbAIZN8RaPSdP/4b8zZc61zPTXOUh8g1gBMkk/QmGBubuSerTFP85ppc5CaPo0zkoArWDruUlvZS3azAoKo35nKcMGt3oRenl9qQJfpqa8MZ0mRoNucpALxqKXnRgDwqKFRzENr6CTGLV+JnGuH9qJep2gQ7YlZgfrrlVQ3KTRhU121AdvBmo4QiBoIlaT4fWdlhLFDkJq1k56HeM2BmhU2iaY8n/ys3ugB/uNyIxBFD40MHTAmfQAWe89NyuC9D3FYjoFs37FlZKYP89wx6b46S81bQpWsJa0i9owcqf6EEXOm+Sseuj/CKqO1jlOcfwDpvajSutHIHjzP3OJGKO23ysdp6hsYBec0om2kY3mZyIKWTiwurSSO/OY3evNQZ3UJqfO1sufCyx08lKaIfbwL4H3iprZ/U+mJcOD2kPdjaVcy0Y5oL+EYkwo4AfyV0H10knFCnaOn0eqSNDbxp3d3rbxqPEEQ2rfHWI9V5DXMPrKPJuq7nWyY6npQj7yfCuGk8gcqBafLH1wK3IdfxLfz68fqNB/LtjrxxSWjvD8/NavXBLqtNKtTX7uCdli1fsiwFxrMU5IFSE2/IP5dUH9B53EIdSOnhD1SHBc4bY9FdAUNCYiq5Qn3KP+M6KbDE7OFg65yX5XDqBEuGGqn+T4J8airHttkbAAJOFehfa8mrwAfKRF8gNKhx6Y2g3jeuZ9RV/WGcCfQCA5tvts+y80yj31rVd6YcUK1YcAwtI5BWeN+fitXr2k4JApaywca/dJbd9462l8JJdF/lbAtT7rkLsJOO7bZsjQLBYodnVMHmWzVZCrSZsL5re1S/vYatbv3cFX3W7aXJgO8BiQPj5IZan52GCLb8WKEhgRSlJ2ly1dMDTlnB3ovty9YihMoQSUYvQahy2fo2uOXVWtA1hpChad7B9g7Omvk9+a8TeuqiPKjyHvRlCatUL03MNIRvS+py0eUtaBeIVWPioyUfj7FV+pthIM5myY9lAwpmZm7TSVjQSbMiNmV8pNgn X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH3PR12MB8659.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sFwDArlOtGr2PbxTse1Y4t1GPmxFnmrOICsK7o5zHSctcklKfbaYrJdASiVr7WxpvPSBWfKHJOMy5zvC+S0WIc2QEZjFYuwT8katJxQ8KihmQGWaFeH9hH4lPdDM7Mizsym6Dmn6lIipw25AMeLm3vio7A7PsZYMdNXab1VubFxOkMY7EWoDbOATbhuxSEgYS9ApA+rIzFv4VkUFR+PhLEMcKRrYq68zZu4KO6NArusdf83K9BjCX652oy5Yl/dEsG6Xq1VYr1nIt2GOdmncBiFUdxy+mQ8Oup6m9uSm8S/SlSicWoOWoFubzlYvXXhVx/jjRdd5JIl4yjXrtdZnmArIilZp7v14BIowabLEfz1SqVs+ieX7nCmVK4Vkc/Zrs6SLTsjhRZizFjk0eJYyp92f0lBwlAQgRSyb9yyafhM791R1XDo2lkKCiDbUxMzxwABTGeghTZNExSTMhRBvutA2IHgW39QEU8g1xh5xeDoWYYQceuoAso9MGj4+wdvrTDtejHbx++mjkdlmSbBd6ZEmQ/2iB+F8n0xqKgNJU5BnB7n6SBxny91xne6cCDotqaZMF4EYkgkVFdjo6m/rsZLBXT+jS+T/WKLgsiyf297MFfn0jeovHurtiYzgK30CY1Lfwz+ia+JtInDZpR5EIHFnJcR+e5CSV9/Nad6B7ltHRr8xjVEwnZ/L/4r5SH3TTJIFTUy/cs8gXjiIU81VtGKU2Bt0F0wQi5C0ZZpEpuOrV15M4FcobZlFpu8NXSX/hPmrHmJOAADfR/ht3+omlI+RJoW0+AZGqpVPQcf8983GTJRKqzVyLFlqEzEgAVyVnw2/fv03Di0FPIsG7QjEakVywNjIQ9LJbfnXoBiMIBJtFMHTK9J6hCy+TJyyIKKHngSsOYDXKltRaX3dQaqBLtViti2fgG1sfPGZhhARkWLviHzLDQJySZCmc2X55Nk6u4dOnfmUhI3WEm45jUU8bRgBJLji9F7fDPnqfOPBYL01Fhn/SSHojLcN2mNL8TXpHaunMFbkJZJZ/viicUAI70AsNhbp4amGu1Pm6GItu+Vi87Gu7TJTlXi2xSz+R40rgDaWxe3AnOhwDXeHH8169qAvG/J151qI3/92LbiNFqmnfBDTpCAaEGtgjyicSkPRh77sybA0+UfcfJgI/Lzd1wuPlmbxym3KQ4bRRfmr64vqv3eVe7Hq0rXsOF3za5js8xALdTG+0oUkBFz557Z2GRNM8wxDREqviikrZJp348jvRMNoNkDtamaXRJaCZsdV4pRdEV/58CNP3KhOMCmkoNEzMF41kS5UIWgx+D1MBGDt4tA4YFXARQWuoxL+wFbSbJwXQn/CRYJMowo1veEyv9uEIogu8WqzxKZzQhfd5IK+9ing0tHjbz80vJuAOG6+7B/XDmSRTGnVF0anY39ulloL/vtWbN1SCrwoEhJfz7lH6K3RFto2vNOiHsUaGr/6qm6vn4x/5eVAIFmQ044Uei0gQnvs1mOhGM92/BEGwcWdUVvPHASQEwqqQG9jh2rX8wYZpQZW9FP8JqPEm0wOwadpKKYFqLimXbCRTzvL8rpMnYALPM9nDgsMPJVA6C2U X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a7b208d-38aa-4d57-2897-08dcfdc5af95 X-MS-Exchange-CrossTenant-AuthSource: CH3PR12MB8659.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 18:14:27.7746 (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: YopAym4rrJD1iEjhynvnVj0GgYoJ18v1bPB/YPQHcnAqIWQMYI4mjEKAWpL3oaze X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7508 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241105_101523_465681_85888270 X-CRM114-Status: GOOD ( 20.60 ) 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 A minority of page table implementations (arm_lpae, armv7) are unique in how they handle partial unmap of large IOPTEs. Other implementations will unmap the large IOPTE and return it's length. For example if a 2M IOPTE is present and the first 4K is requested to be unmapped then unmap will remove the whole 2M and report 2M as the result. armv7 instead will break up contiguous entries and replace an entry with a whole table so it can unmap the requested 4k. This seems copied from the arm_lpae implementation, which was analyzed here: https://lore.kernel.org/all/20241024134411.GA6956@nvidia.com/ Bring consistency to the implementations and remove this unused functionality. There are no uses outside iommu, this effects the ARM_V7S drivers msm_iommu, mtk_iommu, and arm-smmmu. Signed-off-by: Jason Gunthorpe --- drivers/iommu/io-pgtable-arm-v7s.c | 146 +---------------------------- 1 file changed, 5 insertions(+), 141 deletions(-) diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c index 06ffc683b28fee..9ae8cb8999ef51 100644 --- a/drivers/iommu/io-pgtable-arm-v7s.c +++ b/drivers/iommu/io-pgtable-arm-v7s.c @@ -166,7 +166,6 @@ struct arm_v7s_io_pgtable { arm_v7s_iopte *pgd; struct kmem_cache *l2_tables; - spinlock_t split_lock; }; static bool arm_v7s_pte_is_cont(arm_v7s_iopte pte, int lvl); @@ -363,25 +362,6 @@ static arm_v7s_iopte arm_v7s_prot_to_pte(int prot, int lvl, return pte; } -static int arm_v7s_pte_to_prot(arm_v7s_iopte pte, int lvl) -{ - int prot = IOMMU_READ; - arm_v7s_iopte attr = pte >> ARM_V7S_ATTR_SHIFT(lvl); - - if (!(attr & ARM_V7S_PTE_AP_RDONLY)) - prot |= IOMMU_WRITE; - if (!(attr & ARM_V7S_PTE_AP_UNPRIV)) - prot |= IOMMU_PRIV; - if ((attr & (ARM_V7S_TEX_MASK << ARM_V7S_TEX_SHIFT)) == 0) - prot |= IOMMU_MMIO; - else if (pte & ARM_V7S_ATTR_C) - prot |= IOMMU_CACHE; - if (pte & ARM_V7S_ATTR_XN(lvl)) - prot |= IOMMU_NOEXEC; - - return prot; -} - static arm_v7s_iopte arm_v7s_pte_to_cont(arm_v7s_iopte pte, int lvl) { if (lvl == 1) { @@ -398,23 +378,6 @@ static arm_v7s_iopte arm_v7s_pte_to_cont(arm_v7s_iopte pte, int lvl) return pte; } -static arm_v7s_iopte arm_v7s_cont_to_pte(arm_v7s_iopte pte, int lvl) -{ - if (lvl == 1) { - pte &= ~ARM_V7S_CONT_SECTION; - } else if (lvl == 2) { - arm_v7s_iopte xn = pte & BIT(ARM_V7S_CONT_PAGE_XN_SHIFT); - arm_v7s_iopte tex = pte & (ARM_V7S_CONT_PAGE_TEX_MASK << - ARM_V7S_CONT_PAGE_TEX_SHIFT); - - pte ^= xn | tex | ARM_V7S_PTE_TYPE_CONT_PAGE; - pte |= (xn >> ARM_V7S_CONT_PAGE_XN_SHIFT) | - (tex >> ARM_V7S_CONT_PAGE_TEX_SHIFT) | - ARM_V7S_PTE_TYPE_PAGE; - } - return pte; -} - static bool arm_v7s_pte_is_cont(arm_v7s_iopte pte, int lvl) { if (lvl == 1 && !ARM_V7S_PTE_IS_TABLE(pte, lvl)) @@ -591,77 +554,6 @@ static void arm_v7s_free_pgtable(struct io_pgtable *iop) kfree(data); } -static arm_v7s_iopte arm_v7s_split_cont(struct arm_v7s_io_pgtable *data, - unsigned long iova, int idx, int lvl, - arm_v7s_iopte *ptep) -{ - struct io_pgtable *iop = &data->iop; - arm_v7s_iopte pte; - size_t size = ARM_V7S_BLOCK_SIZE(lvl); - int i; - - /* Check that we didn't lose a race to get the lock */ - pte = *ptep; - if (!arm_v7s_pte_is_cont(pte, lvl)) - return pte; - - ptep -= idx & (ARM_V7S_CONT_PAGES - 1); - pte = arm_v7s_cont_to_pte(pte, lvl); - for (i = 0; i < ARM_V7S_CONT_PAGES; i++) - ptep[i] = pte + i * size; - - __arm_v7s_pte_sync(ptep, ARM_V7S_CONT_PAGES, &iop->cfg); - - size *= ARM_V7S_CONT_PAGES; - io_pgtable_tlb_flush_walk(iop, iova, size, size); - return pte; -} - -static size_t arm_v7s_split_blk_unmap(struct arm_v7s_io_pgtable *data, - struct iommu_iotlb_gather *gather, - unsigned long iova, size_t size, - arm_v7s_iopte blk_pte, - arm_v7s_iopte *ptep) -{ - struct io_pgtable_cfg *cfg = &data->iop.cfg; - arm_v7s_iopte pte, *tablep; - int i, unmap_idx, num_entries, num_ptes; - - tablep = __arm_v7s_alloc_table(2, GFP_ATOMIC, data); - if (!tablep) - return 0; /* Bytes unmapped */ - - num_ptes = ARM_V7S_PTES_PER_LVL(2, cfg); - num_entries = size >> ARM_V7S_LVL_SHIFT(2); - unmap_idx = ARM_V7S_LVL_IDX(iova, 2, cfg); - - pte = arm_v7s_prot_to_pte(arm_v7s_pte_to_prot(blk_pte, 1), 2, cfg); - if (num_entries > 1) - pte = arm_v7s_pte_to_cont(pte, 2); - - for (i = 0; i < num_ptes; i += num_entries, pte += size) { - /* Unmap! */ - if (i == unmap_idx) - continue; - - __arm_v7s_set_pte(&tablep[i], pte, num_entries, cfg); - } - - pte = arm_v7s_install_table(tablep, ptep, blk_pte, cfg); - if (pte != blk_pte) { - __arm_v7s_free_table(tablep, 2, data); - - if (!ARM_V7S_PTE_IS_TABLE(pte, 1)) - return 0; - - tablep = iopte_deref(pte, 1, data); - return __arm_v7s_unmap(data, gather, iova, size, 2, tablep); - } - - io_pgtable_tlb_add_page(&data->iop, gather, iova, size); - return size; -} - static size_t __arm_v7s_unmap(struct arm_v7s_io_pgtable *data, struct iommu_iotlb_gather *gather, unsigned long iova, size_t size, int lvl, @@ -694,11 +586,8 @@ static size_t __arm_v7s_unmap(struct arm_v7s_io_pgtable *data, * case in a lock for the sake of correctness and be done with it. */ if (num_entries <= 1 && arm_v7s_pte_is_cont(pte[0], lvl)) { - unsigned long flags; - - spin_lock_irqsave(&data->split_lock, flags); - pte[0] = arm_v7s_split_cont(data, iova, idx, lvl, ptep); - spin_unlock_irqrestore(&data->split_lock, flags); + WARN_ONCE(true, "Unmap of a partial large IOPTE is not allowed"); + return 0; } /* If the size matches this level, we're in the right place */ @@ -721,12 +610,8 @@ static size_t __arm_v7s_unmap(struct arm_v7s_io_pgtable *data, } return size; } else if (lvl == 1 && !ARM_V7S_PTE_IS_TABLE(pte[0], lvl)) { - /* - * Insert a table at the next level to map the old region, - * minus the part we want to unmap - */ - return arm_v7s_split_blk_unmap(data, gather, iova, size, pte[0], - ptep); + WARN_ONCE(true, "Unmap of a partial large IOPTE is not allowed"); + return 0; } /* Keep on walkin' */ @@ -811,8 +696,6 @@ static struct io_pgtable *arm_v7s_alloc_pgtable(struct io_pgtable_cfg *cfg, if (!data) return NULL; - spin_lock_init(&data->split_lock); - /* * ARM_MTK_TTBR_EXT extend the translation table base support larger * memory address. @@ -936,7 +819,7 @@ static int __init arm_v7s_do_selftests(void) .quirks = IO_PGTABLE_QUIRK_ARM_NS, .pgsize_bitmap = SZ_4K | SZ_64K | SZ_1M | SZ_16M, }; - unsigned int iova, size, iova_start; + unsigned int iova, size; unsigned int i, loopnr = 0; size_t mapped; @@ -988,25 +871,6 @@ static int __init arm_v7s_do_selftests(void) loopnr++; } - /* Partial unmap */ - i = 1; - size = 1UL << __ffs(cfg.pgsize_bitmap); - while (i < loopnr) { - iova_start = i * SZ_16M; - if (ops->unmap_pages(ops, iova_start + size, size, 1, NULL) != size) - return __FAIL(ops); - - /* Remap of partial unmap */ - if (ops->map_pages(ops, iova_start + size, size, size, 1, - IOMMU_READ, GFP_KERNEL, &mapped)) - return __FAIL(ops); - - if (ops->iova_to_phys(ops, iova_start + size + 42) - != (size + 42)) - return __FAIL(ops); - i++; - } - /* Full unmap */ iova = 0; for_each_set_bit(i, &cfg.pgsize_bitmap, BITS_PER_LONG) {