From patchwork Thu Feb 22 17:39:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13567702 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 996DFC5479F for ; Thu, 22 Feb 2024 17:39:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B1E226B0085; Thu, 22 Feb 2024 12:39:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A55026B0088; Thu, 22 Feb 2024 12:39:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A77C6B008A; Thu, 22 Feb 2024 12:39:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 70E9D6B0085 for ; Thu, 22 Feb 2024 12:39:53 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 27CDB40EC8 for ; Thu, 22 Feb 2024 17:39:53 +0000 (UTC) X-FDA: 81820152666.23.D48D0DF Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) by imf08.hostedemail.com (Postfix) with ESMTP id 8528816000F for ; Thu, 22 Feb 2024 17:39:51 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=0505KPtW; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf08.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.171 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708623591; a=rsa-sha256; cv=none; b=5zpCiuNvCHpb4KMdGFxhbX+DkSbuaiHhxDW9R3OrtIrG8F8Akefa/MuaKdnaYeY5y4Fgcy 2OxsweQJWyU25JOx1LzxNch9UBJpU3BXN1OAN/FVT1FUeZnRTWP0j4CGSr8cPLDX7PyZ7k 0tu4ZC4Y2nzgm/M5w8iaSGeLquNC3u0= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=0505KPtW; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf08.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.171 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=1708623591; 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=xhLjauiol2hX/CcN6wSXepYqvX9ekQ41OuBb1dZBQzE=; b=I7Da08g9pcccC2ZQtLKt42gZ0X6iFGxSXnP9oKwvAIsB3WM0VQEn7W0L2VUbtH5JtsXwIV 8i0AcdtIlzkVW1LTPJal06C4SB0RNfjrnoG+3QSLG8qiepagm05CPEw7b2AtrpHUU5WRsW m8ujVd8WAgaPGbykmcrnk9s7U0fUh6s= Received: by mail-qt1-f171.google.com with SMTP id d75a77b69052e-42e28e0e879so10647671cf.2 for ; Thu, 22 Feb 2024 09:39:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1708623590; x=1709228390; 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=xhLjauiol2hX/CcN6wSXepYqvX9ekQ41OuBb1dZBQzE=; b=0505KPtWIVduFIhnEzkeRD426yFuz2SEB9JWgItAyrtF5qBkZsF0E6YmsBEI8CzMRl zX6U39WmY1QfBj1+obH06Y8d4dE3/AQgHm9Cl/IIKLwP7YTMB6fg8nJF/euI95T8zyWl y0CrKvo1IkF8HbG2UCyBx14NHPcHQz8umFgT6J9MgULh4DlqR8cbwV3l8yXS8gmpeYVe x9m5ppHtJu3VinDWNhZfgRTq5JYA2PzNuWJ2UQvjUKZF8ufpCi0uMqV/B6HcZqeiO2AF FmIj+OihY8pLsmLnfz37oILZgmX0fF6c1d9GD7V0bZfi3hc1ip2ow1e9fKfp/Zcir4ET FPsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708623590; x=1709228390; 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=xhLjauiol2hX/CcN6wSXepYqvX9ekQ41OuBb1dZBQzE=; b=jt4U4dJDS7MnxsV38cCBv6D2D/0AAgzKIi6kMIQQ7C4QcrRI/ViWEp69RR2h4Ymqb9 VX318RiBuj0L3uK0OFBlCeTiLtJ3dFD7QWyvolcvL6T1dvnt0PmP5LaoG4+7vLyIf0Ub K25CGpaW4iDXVMg0oc9jxUhJ461KZW7iZleFG3e8M8Ji6A8uLCuCaA2z4nYuR+mVUXMH IKhngzIyXJSfTaM3/5zBdQ1TSp8utfpAF6rEnOSoTBksxQfRrvojb1zNf4486pKnluvx cWACSCNuSR8rs6hNZIj0m0OVZriMnAX83PhewNIouV+Z/EXmG5tBFPeFhP+3x7xsSDem orsg== X-Forwarded-Encrypted: i=1; AJvYcCUdExYvIbiBEef5+CE447MBlbZuiL59mCvzqA2LTw08gpu+XN5OYa9eMw22WkSR11pB21uAAX9JymMHqYIk+veQg+E= X-Gm-Message-State: AOJu0YzefalBmRJQBCtZ7BYjhO1D6c+QNbIUWGNtTdQWtmBymuXS/AGG jyY03fhm4WWdFAzye9Wi7zw+3ap7AhFUeVVnTi65YCtZlFikxgO7vZGuVpcA5rs= X-Google-Smtp-Source: AGHT+IEp4MwFnGzbjUWvOKNS7CvUx1mMeLXTjvER84y2unxVOxwU99/U/wStbNygCnfZAxx//dKL9w== X-Received: by 2002:ac8:5b84:0:b0:42e:3bf2:89ce with SMTP id a4-20020ac85b84000000b0042e3bf289cemr5044762qta.49.1708623590514; Thu, 22 Feb 2024 09:39:50 -0800 (PST) Received: from soleen.c.googlers.com.com (249.240.85.34.bc.googleusercontent.com. [34.85.240.249]) by smtp.gmail.com with ESMTPSA id f17-20020ac86ed1000000b0042e5ab6f24fsm259682qtv.7.2024.02.22.09.39.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:39:50 -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, bagasdotme@gmail.com, mkoutny@suse.com Subject: [PATCH v5 05/11] iommu/io-pgtable-dart: use page allocation function provided by iommu-pages.h Date: Thu, 22 Feb 2024 17:39:31 +0000 Message-ID: <20240222173942.1481394-6-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog In-Reply-To: <20240222173942.1481394-1-pasha.tatashin@soleen.com> References: <20240222173942.1481394-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 8528816000F X-Stat-Signature: ro8mppxwg6x54t6ito1aoarajhrn6pq9 X-HE-Tag: 1708623591-891885 X-HE-Meta: U2FsdGVkX19gSys/MTE8l9HnNmrwhpAwBUT+q6I9NlUNPoRNarC8gLV0FBkdFGJDnIh0VF1i79v9q6/oYP1jjGDUOvY28DoDJ480ZyWGExiW9BY7O26tkToh4u+Llm88LD26raCHkzxpr890v9pMKitxPe2Yqk0ZwphMUdxaJcudX2y7pVKOC7mIr+RUT6Lwj/hbwxUqGzHlPUQifmbeG6x9d+/c4LXFpoKQvb2nV90I89fTwZKBSyhuECgaIVs0KFEeTp6bUaZ4D3a7VuMm+5JzpMVzAXwefxlyKhb9ytamuT8/3fIlJRtb11Gkd2UkxasiSNysMFfsRKn3eaevt3v4Iljg5Us+yO4TgxX6tg9nJr7IMxwsn8uljzd99ooBAWgvD6ljMOpJThSSToU8mVYmFjfaFuwjvc5qzSPTrNepK3Og99g3rau93JiPS0/483UHW3eb2rL3sW5XFay4ua3l2uPKj1xbHq7nnZJVl6XjxYVKSq1tS5i/ZXIywuSR/HOexP3scbCzUgnksD2AX6P52ejvd8yphqHijmVTE8FEirvCW3TLvIPQ14RYd84BqiHd7aMAfbwFtZARe3j/49MAyNc+m77oX9SmjK28RscZfn6kXCKsGvJ8RwHNEhHiXGfAOfkLuikJMuRHoJyZKb8NuvuHdyUPYQofu41oTcDDIAciHHNwG7SOtIkFAI/wC5eKJNSVMzZPzTK4PpWkJV4N3U6jDa6MxhMDw4hNF4kqe/5wCqzqUtrJz0bkcdtG9Exs/uOBM4+Y+/suy0j7HnJeYT6P3myjPX7ky3b0ibXCFcC0EWTqqoLQmF8yUeSpPpRThQ02xYfYGUpJRDhk8HDi4EQGzFaX0r2VzrbFlb8hYA/B5jF/cw8dtmT2eJob4Cdyi5fZ1etrrrpvQwgaURG8GUa7pUE6zwZfHmj0uNYpUQgikmkVQPnCSNxqznk4XIXBeoYNfSMcntikgk2 YFqrMfYK VE8vk17V/gK5qIByqR2ck0jEr1qevjKnE35+5aiE2eSvFK39yGTa1+12VmxSyY99Z3NGIjiSoYnwm3y5FjSWNaeK0d4Wr+2IpqhWjPXsG4aD2cASGc57X7KwMZ3qfJazOXAIZU4t8Z10nmNMHmFEmM1tUWnvzFofSPNbim1BXARqB92CHgVwxAeNdrULOe9p9kO5gv1WhuDExOHREHQWraqQI8hdytk1i7w8p9O1maXr224iCXwKf+KQysA== 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);