Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp2997974rdb; Tue, 26 Dec 2023 12:04:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IHd9TcCif26aeeYk8wj7yuXt4FfL1N6acTc8swWoCbhfdHpPiqEC4smXizqOuw5OVHAx3u3 X-Received: by 2002:a50:d69d:0:b0:553:dcb7:c1cc with SMTP id r29-20020a50d69d000000b00553dcb7c1ccmr4781472edi.50.1703621044007; Tue, 26 Dec 2023 12:04:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703621043; cv=none; d=google.com; s=arc-20160816; b=Z5PItNZGhqd3X+M6oH+Ud8o5JGDLVNxOcVTFqWC9NJedO3GEZwfYzVvd8N3qShDG6v XRyBWlf4BcrLZciZ1IaQH239TKODr4u+teY5a6M+SUUreud5fDvFr+3wdmU/AHvtK30S ZZr6QoEvAUXru56StXkJKruXNOlPC06bxuFIq1hTRGGDksV7fFwktzhJM1g+ZHueY0ty WtzCM9MVPghFUKKm1iy3D3nxiZKM7e6TM/NgoiIQ8iY1ugHZfXjkuBPYhriNzce1hrFA bO6EbJouVskSZcba5A70EJ2wIkSOvpCzMwimPGQADOeBgnumGJ4emcONmj8tSWUpBrus 2e4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=Kc2MBt2GVAxAWlt3U6Mxk50gGM7GPQMuVWdXUG/ygbQ=; fh=lUkiT048LCyG2kYH3uS9GPNyu6fkGQdYtFXGdyQ4NZk=; b=YWQkG3qMliqyxeY8nMQb2jM8oSbsobczgWk9mNjlDjbKfj+so3OxsU6bj1kASx6d+C RldPPwvKIyiEj2OkBjq0nzFCr4cjWQFDIqkimm6Y0JmyvvVhT76oR/3LOVVdG9MgxwCb rqkJa9jLRLAuDEtkSb+ws1fE0E7XDzBPtrCXLtv56/9DRocGY74nVtT5XBTTHMl/PrS7 pdzazK3zOfAQsYLvJMj3TyqT5v6QiNmlfYoBdHb5aEtx1pbev2pXIgWSImLLUCsUtml+ Z+eBadgGp5cLg4v+LqBnHb5d4fayjkykBGeNG9iSHiu2UgR3vdufuDp0tVfy7kqalI9r 52sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=TYQcptE4; spf=pass (google.com: domain of linux-kernel+bounces-11669-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11669-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 21-20020a508e15000000b0055469363fe7si4055182edw.370.2023.12.26.12.04.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 12:04:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-11669-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=TYQcptE4; spf=pass (google.com: domain of linux-kernel+bounces-11669-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11669-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 97F481F21B1E for ; Tue, 26 Dec 2023 20:04:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E225525B; Tue, 26 Dec 2023 20:02:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=soleen.com header.i=@soleen.com header.b="TYQcptE4" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AA61568A for ; Tue, 26 Dec 2023 20:02:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=soleen.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=soleen.com Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-67fdfed519dso22056546d6.2 for ; Tue, 26 Dec 2023 12:02:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1703620932; x=1704225732; darn=vger.kernel.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=TYQcptE4w63bH82sd1QrRMi8qb0+WbZWHGkz3m0R4s1ZhQRQzh069mRAHzb+sP4+yJ DsYnxFJtkSR44MRM3zJK+5u2rSIMMP+v4eldcZ5oEjmmRIwkUb9YaBrvlHdH6CPeV0Gk Bofx+b/nheklIBBN102y7ZE/kuSfHawPGNOEDTbUCjT5CaPwEw0L1PZoK33B8xRMawJX bcTqExmHeeuyLrzKCHms+j4k/rVFVz9bWh0yjzKEeRQJWMUcRZmuxoWBY7PAwBrSHA9i 2XDY6RqKBJQj9wMIbgWMFwZal0iXMGoUcbYYkkbDR3PuwFnPYBO/dDIhTZ1vdWWVYqub 5/aw== 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=Rv+gjIYxB5OH9ZUGvA8nsDu/6Z4/hYBaM6ZXZMlmmuvX7KnouIrLFyI9SSr2hBbaZi kV3nyBULLhXNH9nGuM2/OX8m1Kz4ap40bh0nm3gqPtnUBcGSWDjLbmvChA5uZ6Y895Ly QyfG/+XmXG6RL6Yc+0dTjlKlMd9I0zIO2uj5Z5cgeiZs1WkHEvp5ksqmj0CM1Z++u4WJ iwSxF6d8Itat4Ib8OKppf+L3RIh3VRt8KaKZLukrA6Q0gsjVQQU6RhXpaR2xlxnnY3PA PtPxKyiZueHOhol/26fV0Uejqu8TBtWaHBLfLwHR4GMUFPc85qCVgGGvswnfsYjhkEf7 VdoQ== X-Gm-Message-State: AOJu0YxyshzlXor1Sbac1VVbClIsDjQaUiXBQRMGt7S7bJSU3FuSVfLM trD/nmbXxO6jHQR1A6fOHg2X0BU9I3VX1w== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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); -- 2.43.0.472.g3155946c3a-goog