From patchwork Sat Apr 13 00:25:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13628395 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 AAF6AC4345F for ; Sat, 13 Apr 2024 00:25:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C369E6B009B; Fri, 12 Apr 2024 20:25:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B6C3D6B009C; Fri, 12 Apr 2024 20:25:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9BE266B009D; Fri, 12 Apr 2024 20:25:35 -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 7EA3D6B009B for ; Fri, 12 Apr 2024 20:25:35 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0D1C280E68 for ; Sat, 13 Apr 2024 00:25:35 +0000 (UTC) X-FDA: 82002615030.19.6A21AAA Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) by imf20.hostedemail.com (Postfix) with ESMTP id 42E2A1C0003 for ; Sat, 13 Apr 2024 00:25:33 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=HuEQA6BZ; spf=pass (imf20.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.178 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712967933; a=rsa-sha256; cv=none; b=AVzbt31+X70Ojc6mbSJUv3U0bei0/f67buYeGXe0PZBPvd5aQO4HqT3v/8aUFGvNMYWniL hMzKoT98ipvRJfWW7qJQqyGEyGGntpNOsNjAwI1fIuKBEQt2/Q+i8jd7gEtm9a9s4eLdjS GhtlfElffjljW90jYTbTMMuGO/6Xr+c= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=HuEQA6BZ; spf=pass (imf20.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.178 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712967933; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=GxsyMTKANsChLuxDrkmJaktgLM+pVsQuG3GqfblYy+c=; b=mFhH3QjJSWCGZvmMKg/wX1iR7BCWz0QLq6CNYSLWUYSve2gXYigA5jmaqK/sjo5WPj3Bj0 U42xra6A6IYeVYc/DCoVQa0/TuH/4KTuZP0JFv5saAqIg+rAR2BGD3CVXAwyhnWnmKqiTb uggr+oMYnK5zvo5jBq1H8m+MOqRKc68= Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-78d777d7d1fso86384185a.1 for ; Fri, 12 Apr 2024 17:25:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1712967932; x=1713572732; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=GxsyMTKANsChLuxDrkmJaktgLM+pVsQuG3GqfblYy+c=; b=HuEQA6BZX2frwhrcntbdoBSL9iphrqEnXZeyPyKO6UhXo6FykxGddQQ+6HvDVEr3/+ M6M1NQWYUmpTjj5T7bwQUZjvqHNEQYY+zSUmc0JBlSacnSjvs9LR+YtwFuJ5zzxkkcMt 5+JjVK0Qxj/eh4SbbzKnZGN93cXdcSwYtQ9dw5XIflgV2cfz85sCDKkwk/GLgPFweFue NfqVXyHEszAuYlIJ/ZqWg1HWz8Qu+bqOzVhEAkm8Lpe+9MIZpgFeZpdSG+HEKd17PElj zHjb1iN25wTKEwqBTr971+gzHVlAs3vyrgLAd1ULLEZN66U0/qy/fMSrPPsUEYvOOrjM lfWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712967932; x=1713572732; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GxsyMTKANsChLuxDrkmJaktgLM+pVsQuG3GqfblYy+c=; b=gMxQzRcFpMzgyrpN1bgTZiHgb3BWyzdCgY/xG3nzqv4tLy/dKdK4cFrFub4kTIgWL3 WQwoM3/t1N4+6Fzqz2Wnd7dFbcDPRavBbmhY3Q50a3a815PPYGgD+ZHiwWsxaPPMwDuQ f8ciBZ+cTd5KiDOhTXxwGcJ08JN+sb3Rb3Vvd4x3nmuvkWJ2mzB5GYjlWFaCTmAitfi9 fawFKfHHAp67I/60Mt/43tKvaya0/PSklrAZdXeRHRNrIvTO5B2DiDFGMSi6Wx86m2Hx KjFGE4Q/hi4eyk2+nAByi4ScJzmmeP7Dll5WCSAl9lkwiiZnr2QIZm7vqZ6DuWl5ZCBR XM9A== X-Forwarded-Encrypted: i=1; AJvYcCXbnWsfwbd94MQvypne0Lp1Usv0/T9dA5cIN9vFzYyisl4MvIqijEVaEiHTwu1gnRl4SySI9RG6dAGa74OrgL8EisE= X-Gm-Message-State: AOJu0Yxsc7nrWw5BA3zIbvATdeDCuzFyr0fQl1wxAugpYWjn8gbkO1/K lYFul3Wp6wkVb8NvgNlWrNXa8jRHdhusaabqf54bmzp6k6/kRBYdE6B2V+dQaeA= X-Google-Smtp-Source: AGHT+IEkNWXvNi+BSDc9at/eU/P3rQB2xk7v0rRabM9OChaVToo3gqnYxXYIGwdXJVnOXaB2E6eCQQ== X-Received: by 2002:a05:620a:45a4:b0:78e:a3d3:eec1 with SMTP id bp36-20020a05620a45a400b0078ea3d3eec1mr5189213qkb.47.1712967932439; Fri, 12 Apr 2024 17:25:32 -0700 (PDT) Received: from soleen.c.googlers.com.com (128.174.85.34.bc.googleusercontent.com. [34.85.174.128]) by smtp.gmail.com with ESMTPSA id wl25-20020a05620a57d900b0078d5fece9a6sm3053490qkn.101.2024.04.12.17.25.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 17:25:32 -0700 (PDT) From: Pasha Tatashin To: akpm@linux-foundation.org, alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, pasha.tatashin@soleen.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com, rientjes@google.com, bagasdotme@gmail.com, mkoutny@suse.com Subject: [PATCH v6 07/11] iommu/rockchip: use page allocation function provided by iommu-pages.h Date: Sat, 13 Apr 2024 00:25:18 +0000 Message-ID: <20240413002522.1101315-8-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.44.0.683.g7961c838ac-goog In-Reply-To: <20240413002522.1101315-1-pasha.tatashin@soleen.com> References: <20240413002522.1101315-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 42E2A1C0003 X-Stat-Signature: o9jqx6i7xpjepeb1whgkdodr4cbnsb9m X-Rspam-User: X-HE-Tag: 1712967933-114321 X-HE-Meta: U2FsdGVkX1/hoO+Aq4si3QvFCShg1QfjSd4xn21ezq4TM9/G9UI+VojVgpt414qjqq4rAlrnACyIk96mnBnBuVw2iUPCeoD4O2Px9kaQuGaVu/VcCYmN1Qw3pJD2U5ZH3xKsOhgY6MYI4BlVj20BbpCLBu0y2jQV11+d6PxH0VVQWdE8Z9cgOJmSTxr60apnMwKqNeAb1z11vDkX8EhHdrBOJftRXtbXrjtHZNRYvPdc8XSnUMqQu9tZ+NUfvunlN0pKbSY3bAYOXy8O0quoHPkKTbgEOKiaJd/dd/wl9oAI3SYV5pOYEXPUKMeQtzQxJl+M4pRb9BxGdS29wiDIQfVn4IVLK5rTGfK7Iwh3EdNPwpjIKiOsKCWhzcbEDB5zkmf5xDs2xBit2DnpLRKri6UuYoDQ3KfTn+mFyY/qcc9lkhRVzfOduWrflmubUqnp7hO+Tua2f2Z+UePtEOwidpexhUWzQR2Q5UNE5ugr31JsHJIGsX9igFz5wCUOR38hURBgHpDIi6Rn8EQwDNWYi2rZ1cww5Br70mkzofSWPjOOXahYWz3Vj+qTHvn5esHsHQsdgQCAwpa3GqlHx88vTzWck/2p0HRcNf5nVt4BwUnaXXfOQp7w/O+b4Y/hktcsXCXOoXeYMq8qdwCbPwGzyftt4gQPfn3/pS34Hu+4K50y1h/6/5xxkl6CSUXnq/YLTD5yEeqkU3CtG1PP+Ha/NJSuW6+T8lTo2yd+AAr21xkV13Ma4+ZK+mGwhQuR/giKt6At9gQQ7i9uDQazy+MTnKhHMQvt9LKjFTw+9DqpWJXydyb624x0B4ekz9c0eqRBgwberunjbBfiEgZgKjMD+0suZg07ns3l9/0xQlTplvMJWI3CEt6B3KfyJM24LBuUpTVG709pQsYyf4DXx3vlh1AkCZ+GVxBRm2Kg/llnXt+QZL2SNNuwDfIuQRSQbOVK91bE2tWahtUsIMh14IG oK88USEF tVMDNJfqh31iQO7OL1R/wjkGjl9BV1W6vCGKNNmBp/VhIBeoVWPiKklIcWY3KrhBBnkhkyNZhzhQM0Nn+1IEoGE5I2E595VFqhfHPD0FKmuVQz7CuBHIe41ezPGtvlNHLRck4kIfxswqvrRT6mG5m3YAVMzCh8UwstK/AF8GuHYne0+36HCr8fm+o2k6x4pQYZLtOsGAnfH5cM26qRLajmDwcURsf+K9UWuCCahQgEAi3KvQjmqKfzdejnifvsJfWRbsSxgazx4BZke3vJDwbSWp3Taieb9gZcHejZr0VhWBCIhdGkuQg2P/IercoFdF01+eL/8nxv6cKDYVrAq7xvjFIcIOZuN1kwKXmKhg02XZhUXHYR3D9BMKzs3AuZBXk0agii1ebAInCJ1voX2UVZ3kbi4IfPlNdxLqJscLN2HK+FpoEhKUguQdhSSvZyIfxqdWsykw0Y7QbQ0r5GPCF7aaNqYaVFNxCnAOA7mrWxlD/LEc3y46PePx1HNQ9coLf7PBR2uE3cg18DYvww9h/qyJamN0yXieNOpvvy46bAVAvvSFoETAQCfBtgHMUposcftke/pJ9SmUY7Hg= 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: Convert iommu/rockchip-iommu.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin Acked-by: David Rientjes Tested-by: Bagas Sanjaya --- drivers/iommu/rockchip-iommu.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index da79d9f4cf63..4b369419b32c 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -26,6 +26,8 @@ #include #include +#include "iommu-pages.h" + /** MMU register offsets */ #define RK_MMU_DTE_ADDR 0x00 /* Directory table address */ #define RK_MMU_STATUS 0x04 @@ -727,14 +729,14 @@ static u32 *rk_dte_get_page_table(struct rk_iommu_domain *rk_domain, if (rk_dte_is_pt_valid(dte)) goto done; - page_table = (u32 *)get_zeroed_page(GFP_ATOMIC | rk_ops->gfp_flags); + page_table = iommu_alloc_page(GFP_ATOMIC | rk_ops->gfp_flags); if (!page_table) return ERR_PTR(-ENOMEM); pt_dma = dma_map_single(dma_dev, page_table, SPAGE_SIZE, DMA_TO_DEVICE); if (dma_mapping_error(dma_dev, pt_dma)) { dev_err(dma_dev, "DMA mapping error while allocating page table\n"); - free_page((unsigned long)page_table); + iommu_free_page(page_table); return ERR_PTR(-ENOMEM); } @@ -1061,7 +1063,7 @@ static struct iommu_domain *rk_iommu_domain_alloc_paging(struct device *dev) * Each level1 (dt) and level2 (pt) table has 1024 4-byte entries. * Allocate one 4 KiB page for each table. */ - rk_domain->dt = (u32 *)get_zeroed_page(GFP_KERNEL | rk_ops->gfp_flags); + rk_domain->dt = iommu_alloc_page(GFP_KERNEL | rk_ops->gfp_flags); if (!rk_domain->dt) goto err_free_domain; @@ -1083,7 +1085,7 @@ static struct iommu_domain *rk_iommu_domain_alloc_paging(struct device *dev) return &rk_domain->domain; err_free_dt: - free_page((unsigned long)rk_domain->dt); + iommu_free_page(rk_domain->dt); err_free_domain: kfree(rk_domain); @@ -1104,13 +1106,13 @@ static void rk_iommu_domain_free(struct iommu_domain *domain) u32 *page_table = phys_to_virt(pt_phys); dma_unmap_single(dma_dev, pt_phys, SPAGE_SIZE, DMA_TO_DEVICE); - free_page((unsigned long)page_table); + iommu_free_page(page_table); } } dma_unmap_single(dma_dev, rk_domain->dt_dma, SPAGE_SIZE, DMA_TO_DEVICE); - free_page((unsigned long)rk_domain->dt); + iommu_free_page(rk_domain->dt); kfree(rk_domain); }