From patchwork Tue Dec 26 20:01:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13505030 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 3B693C4706F for ; Tue, 26 Dec 2023 20:02:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3CD576B007B; Tue, 26 Dec 2023 15:02:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 37CB56B007E; Tue, 26 Dec 2023 15:02:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A8236B0080; Tue, 26 Dec 2023 15:02:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id F35A96B007B for ; Tue, 26 Dec 2023 15:02:14 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C4DF61C0EAB for ; Tue, 26 Dec 2023 20:02:14 +0000 (UTC) X-FDA: 81610040988.17.DE0A527 Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) by imf13.hostedemail.com (Postfix) with ESMTP id F17862001D for ; Tue, 26 Dec 2023 20:02:12 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b="T/yUwP0p"; dmarc=none; spf=pass (imf13.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.46 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703620933; 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=Kc2MBt2GVAxAWlt3U6Mxk50gGM7GPQMuVWdXUG/ygbQ=; b=wLi1cCgXhuIxOw6dXLJw/HK1Pat0jIJrjD0r1hjaxQu9Hu/CpK1mTykynhUydNzIkPxt/B VwFzkUeCDB5aVEYhAjyxjI0cwmx5UiNpJOQv5sgUnx3VLiS4q5hZOqDj0VDsjY09xOa/wQ cMiE6z4sKrm8GPYEaluwD/uthkdrFq0= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b="T/yUwP0p"; dmarc=none; spf=pass (imf13.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.46 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703620933; a=rsa-sha256; cv=none; b=NmAxF8J2YbQNAsZk1PKuyqhm8dXeUt/is7m9zUaAmrzDoyqgmD8UlHQHFcIQQyCDOOGb5E 65ikWyEpEjh9qFa4GLjWGMHZ3aE1NtUO7Ap3i+yz03+83iaUnnHeZkA3l8lx0ECIUv5myy FmXEM4w98lM6xc4yQPRQA0kwAagwcsM= Received: by mail-qv1-f46.google.com with SMTP id 6a1803df08f44-67f911e9ac4so39520096d6.3 for ; Tue, 26 Dec 2023 12:02:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1703620932; x=1704225732; 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=Kc2MBt2GVAxAWlt3U6Mxk50gGM7GPQMuVWdXUG/ygbQ=; b=T/yUwP0pryRMHnEQj1q2Xx2zmFuTZHSY0IADTILfPzTGVGIIavE4ZaCVusi5JrXhFl Q4c2gX8/Kl44Q3rjvAPnNfaKsWxV1e7cr02GjBSPcDJmkPP8YuFcjPFn1Z/YvxGRZ2e8 /DBp0iHMIBQfpdYlBgDJKol/pKA6l1TyzW7mAikKTJwaFWlHBheNC61D0cYgRHtXzcgB oNGoNmw6fzCF5+alljjnMdx0PVH/VGB3c22mdzpaHepGjOf4xYh0gbXJTh+W1pqvzHHm nmBCFl8Q/SJU4kt3hHE8AJtPnQYwClufm+Xp9wYN0dQ7Ge2Mwj5VgALr8eTGYi/CKXSN CCbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703620932; x=1704225732; 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=Kc2MBt2GVAxAWlt3U6Mxk50gGM7GPQMuVWdXUG/ygbQ=; b=hCrRaSjJCI7CBsdqLHzFKhhm7FmWMtPLGUp1a3sZC1LhoikuDO00dHdwDK6QCpd4aN 0pOiTD8TA/BhJQCIYtmxcFKRDw8+EbvQ/2l3SpKtm8k2bXIu4V3CBKcO6oUR2Gzvqsoq FXYO4P4PK8s+bJG4YKvqvuhVmdXOmbS8zd5SmQ/Gzkzyy3tv4U+Q7fVtvFGLNNv48spk iHcu/W7FG76sMbR5WM3BVSqw5oN0ERRPUf2cjKcbssWPU6oJbJJ6blu43qnsVrxspJn7 hOC6YAUOYy24Sshofeu25/CWCrRYY+pddo4NU5o9jWq3q3YQr3ZGhtS3dV/7xBVSbCA2 uDxg== X-Gm-Message-State: AOJu0Yz+6SZJpA7bWAyZBaRp8L9AU5ascHV9Y1DSkAzWF5uoNU2K9GA6 2GJOSfAS+3y8qJ0POb+qVU1AUEGpTojTQA== X-Google-Smtp-Source: AGHT+IGESQ4vJslQjT1sSibx4aOBHwxj4JmN7OYbYn4cPlnzh7uIRGIg35PIp/kXV1ck4NfeaNvKVg== X-Received: by 2002:a05:6214:122:b0:67f:b7fa:9d4f with SMTP id w2-20020a056214012200b0067fb7fa9d4fmr7176762qvs.119.1703620932023; Tue, 26 Dec 2023 12:02:12 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id t5-20020a0cf985000000b0067f696f412esm4894539qvn.112.2023.12.26.12.02.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 12:02:11 -0800 (PST) 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 Subject: [PATCH v3 04/10] iommu/io-pgtable-dart: use page allocation function provided by iommu-pages.h Date: Tue, 26 Dec 2023 20:01:59 +0000 Message-ID: <20231226200205.562565-5-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231226200205.562565-1-pasha.tatashin@soleen.com> References: <20231226200205.562565-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: F17862001D X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: b6og4wmi6kz659aq94mkuowig6e8kq1y X-HE-Tag: 1703620932-475922 X-HE-Meta: U2FsdGVkX1+CKvatZNrdp0XXcSYJxaiDBF27bj8dwlhl6JgfcOASXWF7mNwQKb2NJ07ahv7rlkaBDkJGC0EXCC1/v6uPVycUlBRM+KlNjc3SJ5iv+/GEXawxps3Z0SdtVEMW6mPWSN455St8l0aAohqUAo29r5z59uqCQUeN1WIC3nHkMkR0mC6lGhRoSFLAq89B9pfYrGKg4Td3CAjShTT0b2qNWuBwlPPpcmtw31uYCcqwvyyu0V8HmEwhvNBbK81Av/xqWCmbeZgR4vboL7vdpCwjopKH7QX4hYOqNcHBzlxe2KpbEqyw3B15zGKqpatr/z+XiKueOC43+2yF1bW3xVdbBj8hm13a0xL2x+YwQfB1NOn3WkYfiLkH7VUIe9CEiXPhH3uJIp5OCo9XsWSVWPI49DppJySw+sR6Ei2wrMQM1TJDANe7j2qFlzJcv/WJW6a4K3QKlgu5ecKGYvJZupLgtZ6AcMiWDe/ZcrBFsKNXRUJWnOZQ+vsl1l8/nj5oVMTdacvExES164rLD+n4zw56ZRD+rhJD2Uu4ler0e2ZkCh1adSSQjkPPMVYqlvguunu+8D/ht5v+s/Z1/B+1MHaRvJtVH1BUx7msKIviInAL1EdEfyW1fYeOrsaU/zjWlWV9wGtLX0/LSPQF2h3cyFRB/92SdOh7BKqPjPevUk/lOFzXVZNRsznS3PfnzOiO5O2TCCMJKe2QMtXz7WFKC7831aXpKgA2OqZ164PrWvbRXk0kFtbF2qiiNIckF3RyMjMwKG70XP8et908Z5trrbN1HeQxTEpe6c5cWW4L28l38DpQwXsgzGH1g7A/LgAXHWvfPYccDyQTgUvAYzD/bRGWEtnby6ivUwp3iaTPx0oRtLqFEsW80E29CsqcwQElsMmcs6f+wc5sYNK3XJ3jJ3VJSz/sIP11se0hAJ7FSjsrANNQFX4rAK32IBUCllg4OQn3mUCWxkhaxwl EJjHEYbg MtjDfyeA6UFwMNHk+jZXD1dE/lUfyppFVmGhRyO8Whd4vI46sEOg4HwPVeGKp3UCzCbPr2EC3LDJPDldfLYpKn9g8uNzvhWoBMc45UEEZKWPkA+DVhN4ReLtQbOgi4RVR8f8vdJ+5P6qzniI5WdIoaAug9fcF0Kqu5VdhZceXAynW1kf1vFgWGdFgG5xoWaG/tdO9m/S2Fq9akReeYiodGrf9+XtaNkCIeA6sevzNzgHrh6Jl9jBiiDe6OzF3L5SAq6VZP7gsZK93qJCw2ZS8QcfUnxbdAa8B11EfY+8ZA0c2oqIToTUgRJTSXtv3J6Qx51HfAakJnE67TlbCzLDxOzlTbUXqyLxXsWbqar7P77XIkzwErCG2+0YM8Iz9m4Ag9hBAS3G+evn2kfKeJPMEYY9Qi+LZCoIoIZc7sPJkJ0oUVNbAJRYqWkuvDbu2YTTiKTnP9A+oB/0xO4ot439hjO+CQW2mYyI+bDdmKbn75I/cyN88QMr+b1JJ8xLs5MHKnV6eCvPsOFfd+m8+2qauoXlYzQ== 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/io-pgtable-dart.c to use the new page allocation functions provided in iommu-pages.h., and remove unnecessary struct io_pgtable_cfg argument from __dart_alloc_pages(). Signed-off-by: Pasha Tatashin Reviewed-by: Janne Grunau Acked-by: David Rientjes --- drivers/iommu/io-pgtable-dart.c | 37 +++++++++++++-------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/drivers/iommu/io-pgtable-dart.c b/drivers/iommu/io-pgtable-dart.c index 74b1ef2b96be..ad28031e1e93 100644 --- a/drivers/iommu/io-pgtable-dart.c +++ b/drivers/iommu/io-pgtable-dart.c @@ -23,6 +23,7 @@ #include #include +#include "iommu-pages.h" #define DART1_MAX_ADDR_BITS 36 @@ -106,18 +107,12 @@ static phys_addr_t iopte_to_paddr(dart_iopte pte, return paddr; } -static void *__dart_alloc_pages(size_t size, gfp_t gfp, - struct io_pgtable_cfg *cfg) +static void *__dart_alloc_pages(size_t size, gfp_t gfp) { int order = get_order(size); - struct page *p; VM_BUG_ON((gfp & __GFP_HIGHMEM)); - p = alloc_pages(gfp | __GFP_ZERO, order); - if (!p) - return NULL; - - return page_address(p); + return iommu_alloc_pages(gfp, order); } static int dart_init_pte(struct dart_io_pgtable *data, @@ -262,13 +257,13 @@ static int dart_map_pages(struct io_pgtable_ops *ops, unsigned long iova, /* no L2 table present */ if (!pte) { - cptep = __dart_alloc_pages(tblsz, gfp, cfg); + cptep = __dart_alloc_pages(tblsz, gfp); if (!cptep) return -ENOMEM; pte = dart_install_table(cptep, ptep, 0, data); if (pte) - free_pages((unsigned long)cptep, get_order(tblsz)); + iommu_free_pages(cptep, get_order(tblsz)); /* L2 table is present (now) */ pte = READ_ONCE(*ptep); @@ -419,8 +414,7 @@ apple_dart_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie) cfg->apple_dart_cfg.n_ttbrs = 1 << data->tbl_bits; for (i = 0; i < cfg->apple_dart_cfg.n_ttbrs; ++i) { - data->pgd[i] = __dart_alloc_pages(DART_GRANULE(data), GFP_KERNEL, - cfg); + data->pgd[i] = __dart_alloc_pages(DART_GRANULE(data), GFP_KERNEL); if (!data->pgd[i]) goto out_free_data; cfg->apple_dart_cfg.ttbr[i] = virt_to_phys(data->pgd[i]); @@ -429,9 +423,10 @@ apple_dart_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie) return &data->iop; out_free_data: - while (--i >= 0) - free_pages((unsigned long)data->pgd[i], - get_order(DART_GRANULE(data))); + while (--i >= 0) { + iommu_free_pages(data->pgd[i], + get_order(DART_GRANULE(data))); + } kfree(data); return NULL; } @@ -439,6 +434,7 @@ apple_dart_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie) static void apple_dart_free_pgtable(struct io_pgtable *iop) { struct dart_io_pgtable *data = io_pgtable_to_data(iop); + int order = get_order(DART_GRANULE(data)); dart_iopte *ptep, *end; int i; @@ -449,15 +445,10 @@ static void apple_dart_free_pgtable(struct io_pgtable *iop) while (ptep != end) { dart_iopte pte = *ptep++; - if (pte) { - unsigned long page = - (unsigned long)iopte_deref(pte, data); - - free_pages(page, get_order(DART_GRANULE(data))); - } + if (pte) + iommu_free_pages(iopte_deref(pte, data), order); } - free_pages((unsigned long)data->pgd[i], - get_order(DART_GRANULE(data))); + iommu_free_pages(data->pgd[i], order); } kfree(data);