From patchwork Sat Apr 13 00:25:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13628393 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 B82C2C4345F for ; Sat, 13 Apr 2024 00:25:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AAC4C6B0098; Fri, 12 Apr 2024 20:25:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A0D786B0099; Fri, 12 Apr 2024 20:25:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 812556B009A; Fri, 12 Apr 2024 20:25:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 602606B0098 for ; Fri, 12 Apr 2024 20:25:33 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 24D85A1053 for ; Sat, 13 Apr 2024 00:25:33 +0000 (UTC) X-FDA: 82002614946.18.8374638 Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) by imf30.hostedemail.com (Postfix) with ESMTP id 6546580011 for ; Sat, 13 Apr 2024 00:25:31 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=cNdP2DEl; spf=pass (imf30.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.181 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=1712967931; 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=BdzMORim0dHB7uEOtMEVFDL6Z2C9ADZmlFONNgiqMWY=; b=0gXTAWHQBagCDN9mxAlO/GgC7+hPY0AnvJaPewdaawu6sSmR6rUgcyloZdWkBKt623wnql GQ/BvRnjMKD6tfWmSyCoiasRuDogdDdXUOIZRFOd8Ha2//N5LWDmeem6UX/b7pYCUXCI8K Y+b4QbmNQV2b9xYi93HBAHviUB9UD6c= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712967931; a=rsa-sha256; cv=none; b=geL79fWPfTcv75UVB9wPrVLbLidjqTeyothJToiCbdwWF0X/OmFqgK2kVesbA7fxLH6y6h giwi0PfCg5ImMNTme1P/UpOHouEgxAwpXwg86nT9YaMCQrjLrWslZTdziGuEQKdFk33TrF gAi/uzJsGCCAsvvzhoy9PDOTQcyQ3Zs= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=cNdP2DEl; spf=pass (imf30.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.181 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com Received: by mail-qk1-f181.google.com with SMTP id af79cd13be357-78d677dca70so95746185a.0 for ; Fri, 12 Apr 2024 17:25:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1712967930; x=1713572730; 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=BdzMORim0dHB7uEOtMEVFDL6Z2C9ADZmlFONNgiqMWY=; b=cNdP2DElR/9VYlz44ZcDBRN9bMZTW+VQpO63mK4Foe5zvoEHH6g66GwB2Alp0ju3Xh /z+sWAcX4p05QIuIcT7OCELUU+SP4mc1IIBbR+gcGhu3MEyuyVNEncDCFVL1Mg5WzrF1 1a3THVsRVmTCXvwuQMriPPoqSlEDr+ZJFObDGl/IPB0GUcFOLnBoyx/u6QxemwqFvz1J dBxovrIreRBzfzITg4Y3VZQgx0BwyUUCk/Tg6KD3mtXjVXdrfP9al25IszEIrpJC+bKK 1wzXq6S+WLf4hpV543y44DHVgSsTfKBeEOEDBK4jsUmdbvS42aY6vi3tMEYOQKnlz+bX w/bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712967930; x=1713572730; 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=BdzMORim0dHB7uEOtMEVFDL6Z2C9ADZmlFONNgiqMWY=; b=MLq1kTuBnYiXRxqd/mnblwM2UpVLgaDy1DZF/d1HuEyUeW7vqSWNUHjBAlzkNxQAbk qz2U6QsE+9+dyk3qn3aH9wLLc42+OJoJyOrqYJddxESgGbnPJd9yhWEwc+dVEe+HEvKp tcGjuAW4ZsgNI/t340tMta4HoGcS9C0RjWhzUFmw0tAej4Remdlj5CCGQi+Mteg2Lylq InWJxMulbMXMfKc2MUAdJRPxLIyzToyG0rlM3FnIdWdASo/DtJ+lI3EE3fJMgVvujufS Tl9iWEIep7y96mhp0JxXcrg4uWWKFVr5DpB2yaueKIHyAKZMpOhneKCRPdRFjUQrLvLL CCIw== X-Forwarded-Encrypted: i=1; AJvYcCVK4YmBQbiNmIEW/1EMVEqdYhsyeYClNYiw9b4DJmxaWzmyaGXiHnYiPHRVtjrRPNjwO6UIjpkm7/c0XnrH4tbBtEI= X-Gm-Message-State: AOJu0YwXPAbXkXjRyk7N5+dHm8vpve/AxPxFXvCQGrM/JC8IgF0vRnnp v6BEB04YqLTQgg4GF4odk9yUh3YO3XZOv+fx8SGugQiZB0aylcdLsgPo0Eh8h/Y= X-Google-Smtp-Source: AGHT+IH5Os3iRz2ANP4F2z0zw+BDU7+6X7QWkqdDRIDhPQUP0t1/fto88yhC6Si55lvEExsYEHVs9w== X-Received: by 2002:a05:620a:28d6:b0:78e:d7dc:44ff with SMTP id l22-20020a05620a28d600b0078ed7dc44ffmr198409qkp.75.1712967930559; Fri, 12 Apr 2024 17:25:30 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 17:25:30 -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 05/11] iommu/io-pgtable-dart: use page allocation function provided by iommu-pages.h Date: Sat, 13 Apr 2024 00:25:16 +0000 Message-ID: <20240413002522.1101315-6-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-Queue-Id: 6546580011 X-Rspam-User: X-Stat-Signature: 9inr8o98gnebb76ah6wzekzeyahthjdg X-Rspamd-Server: rspam03 X-HE-Tag: 1712967931-324773 X-HE-Meta: U2FsdGVkX1/NyzKtqW5vNf22MJ6ZJqTdX1r+TJ985KYVqiYP9a2q3y/E16vbVktfwxumZREbMNRn8+UtN0czmwnWqcFJ8NOCbQ818CX8Hxv3BzOs05vzJ02IUuzVcyHe3dWlBTiW1AypBe6EfSDze3kCwDFLr3a/ARjs/gRKq6Cbm7gjnhRuBu8jXi2duuWDrRc+4BAwIpZly4lkXvIPO9qR2mPjZIxXbYxAO1Na6ER/nF3XWmnEjEq+ACzPNY8dZpimsJxxWIthlOZvbPaK1EAfWFjZXNntrlD04r8PwBVFNXskLrnqMPvS8Bq0/gRzfbbanwLG73DDLOcaVhOYW0Hzos/rd8uMl3ZwPvuy1PIKXJS4ktHRhaGYhaqoKOduyVpOQ7Abz6zQ2ta/PKZMxPxhUbQALiMtbqIXeuKfd+mj5Rwcavrvtr3Tsvz8ifHEtYzQFCj8rqQiag6/GvUPLONfrNBqrJGhq8oQM+39xR2QVpy1A6JS/TDj+kipVvUZBj8iS1CEU3wWS/N8Fn4kRONaJDe07Wzu8WnKuWu/u6VoF1T6lQxPyTLE91VYRy6ChUom2taQUVg5n0nWQd6njTAjvv4da8jseQCLu6rayIXcUzz/9AQ256WpLVdDhf+E1PO2jiBk+XHv9SAKFZu0egC6q6mjsdc8QG//NyfmLp4geFV5anaxxzdsrKEfVd7fWoBOUy7LeXQUJrcrsuynb+FwPHcPZJbZ/5sjo76Cqb1LuEXuSFnZuqPU70A3uFv9+9ah+nYtoeGBxcLTBUEklJbYlBBiNlnAChHj95PwJc5gHaMKetpHIuhiijSNr/DVZVyRXnegB4NoFNkFzGA1cHt7x0hAFmxTaFyudVV2jdNNk5R00Y/3XayjHTdmvPSmpbx8Bze4s4KQIz0B8e1Zo1PYybIhm/OcnOtS+AMMI+5zFAw3mNNOk6jkBS3TzTQkEhWnDfXOBcgI9aWwNnb omF9RagM L6K9RBnqMK6DvBqTO5JgrnsGXw42Fen/p0oWVmnF3Mpz8a6kSmGPjeOJRCRIvnu4p1Q67yoReyCh1Xp6dz8p2qUGXPZ0dqWEKWeMdFCPsmcfcdxRNPUVifRZXO/PIEUBNc99at8ihgXfifPmGNb0x7GCLvTWsCQ4DJ/wsZ9jh8AH+3rNbglHPjy4ZjdqGo0Wek0u3OIbgRbg7SRHf4ZLHNjWRxegc1+pzhJgxIMdX6vBLvCYmNOehgc73unuHnGP9KLkQXLTn+TlGX8aa1xAq9AaSu8oEBKBEBY/LRHpdAWGcUJZ75/znAr4w2sHjH6QEKY5aZNAUuqxB/k3f6ERBLGiSEX6Hggvaia+jWifzvf5l2AYQdGg5TAYs8HtZsiqbC6h0O2FVs3io2SdDmFld+jkaJLfaS9UP70taYbXToJCktHSPqm5L/M3EX61FcHbY9GridK4H/YxLgctUXGr/l4ktuRhvVaw+9N5AVBgz2cXtwZx+Wvnow09Q1zrPm5+VJOUpsWwJ/TCK9cUhuT+vln3cBMdgjH+k4RZvnZOvKhcvNwJ6m7XnXketFCf4pFOsvUHPpb8bPSM42EVl+heLTcT0V4+H2++bWAMv99Rm0bVAlKyznQZir3ahIkOs2FCROP+I 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 Tested-by: Bagas Sanjaya --- 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);