Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp500231rdb; Thu, 22 Feb 2024 10:01:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUUyorTVmTrzVuB/h6xL4XQlzOwLzuryEbIhfXKaUs1PiPHndBCDIV2/DGZIcdsz/V1Qokn7BF4HYNh2r9WiBznlI3wrDYmSnzqc3Te7g== X-Google-Smtp-Source: AGHT+IEQIdaNYmASEjUSUGu91SRAse7mRSNLbE9m9CJ1EQlPKXgr5sFdEKXOt0YLn4wPXWTkiNLp X-Received: by 2002:a17:903:110c:b0:1da:1e60:f9fe with SMTP id n12-20020a170903110c00b001da1e60f9femr25630506plh.54.1708624899443; Thu, 22 Feb 2024 10:01:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708624899; cv=pass; d=google.com; s=arc-20160816; b=uu0ZJFDe5on70v7IpQ1c5bqvn2XKddQRICHYMpKUILFNLf9l46agS1sci9KMLr4b9r x5ePHwE6mwXK7ExgFIBgnsew50hOPRJCfoH8VYeQA9382qzd3sqlcpOkvYLSq2tDqcuR kNSoAOfFcRvVKiLeOsaolLdkiovrSNu5DrtRXH7suxOXAYfcg6R+wChjSSAaA8TUwmLk OICYAgQqAX67gCZf0AT6ItjFrxLJBgglzwDQRhdIUZKs+NiVjwrbNe8o/UBZN9m13iPW 84zCBg+4E/CiPiMaP5zIiQgu4UhY6sSHXSIUIVXg/h/TJaHSaS2GzehBrbo6uS26Ydjt PMWQ== ARC-Message-Signature: i=2; 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=xhLjauiol2hX/CcN6wSXepYqvX9ekQ41OuBb1dZBQzE=; fh=MIcOPOXJwD8HNT9qUcvkhe4C8Sf+BQ4liDTzhbdg6xk=; b=dKSqYabHuUMr17kq0/8Nd8ByXFhuiKJWjDD9iAuvAuMgRW20jaYLhyCqLZDwy6cAGZ pWDm4xM24ZMH33WIvgZSmWZgay8jzNaOHQnx7ku8UwrBQwSNwVucX0rIHmQjwGhwzChG 7FT9Q/KhT+5X9ldBlQB1qap++8J+/5WzS64fYzrxYffXNyVnieFMmugU/Ytm2j/fCD4E f3V4eNfrgDbh7XUTeASH27fE8kX/uQTar+RhXg3BTINoZdyMn4R3WZSo4czIvYoiULyF 6IPY74tZM+Yl9waxZ305rce+0VM5jU7J7NUbABFyGMoXnPjMT8XkaRsxOLRD1cOwK2ao mXDQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@soleen-com.20230601.gappssmtp.com header.s=20230601 header.b="dUwkbRo/"; arc=pass (i=1 spf=pass spfdomain=soleen.com dkim=pass dkdomain=soleen-com.20230601.gappssmtp.com dmarc=pass fromdomain=soleen.com); spf=pass (google.com: domain of linux-kernel+bounces-76993-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76993-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=soleen.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id u14-20020a170902e80e00b001d8da1c6933si10903486plg.58.2024.02.22.10.01.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:01:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76993-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@soleen-com.20230601.gappssmtp.com header.s=20230601 header.b="dUwkbRo/"; arc=pass (i=1 spf=pass spfdomain=soleen.com dkim=pass dkdomain=soleen-com.20230601.gappssmtp.com dmarc=pass fromdomain=soleen.com); spf=pass (google.com: domain of linux-kernel+bounces-76993-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76993-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=soleen.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id BC641286126 for ; Thu, 22 Feb 2024 17:41:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6339615AAA1; Thu, 22 Feb 2024 17:40:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=soleen-com.20230601.gappssmtp.com header.i=@soleen-com.20230601.gappssmtp.com header.b="dUwkbRo/" Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) (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 16F40157E72 for ; Thu, 22 Feb 2024 17:39:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708623599; cv=none; b=SFMAahR5xR5MMKJVGY/xt6xs0k16P+UEcHs02KF4kEaAZ76I0Or3RH4w7On/nU1jpCIhAdmyR7YzVxcxQ25NE2KxmXlGhMosiqujjHlTJi1QLxwpkUXMHNafxlmxAhrqEAqLp0l4o34yfO50HG16uZJ66O0EV7vfL54lbvWa3wU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708623599; c=relaxed/simple; bh=HFMzJSfAagxMsn8PANMQxhVlBhQeJV3s4jHhao7IlsQ=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tlX6/aC5qR9HKhHZCsV9pJP7NMwXzZxjtUSierufkGo2aUrWMqfcLs7Vuy6MxJlRqMBxYyTDz2b8L7eR8x7pBM2pE4Djmcdaq4IBRlo2/b5ktvI1foVMDNmnRH+YMhI2qZa8D5+Cx1BJ75Lb6HVYqvwn4jtHqH6vK3KJaKJtJAQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=soleen.com; spf=pass smtp.mailfrom=soleen.com; dkim=pass (2048-bit key) header.d=soleen-com.20230601.gappssmtp.com header.i=@soleen-com.20230601.gappssmtp.com header.b=dUwkbRo/; arc=none smtp.client-ip=209.85.160.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=soleen.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=soleen.com Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-42e28e0e879so10647721cf.2 for ; Thu, 22 Feb 2024 09:39:52 -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=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=xhLjauiol2hX/CcN6wSXepYqvX9ekQ41OuBb1dZBQzE=; b=dUwkbRo/zGxx9V4pg7lnXDNrH/12crjApNGm2Q2xxjqsQ+v2rB5nxiefqSxuwzocKA tPk+QTnm059ZfEl8OMlD4HX4t/SXbXlNCWjgF6JrtQZGtQxi5RU1EL6TrkrOUCqRv3OQ 9gyIpXQ+v5N4M+94vhSUmF0KvWZb2yt17vuZAqWzjPIrSO+iexv8t2v/uO67m/LfsfyN esQjijjIh3Vbp/mmBwdQ33ZloGSfJkMRqwHwAcN5ViPgLqwLLmHYlTzAbNfIIdL/YMds pLR6uZTP63fLywonb6n6NerRM4xNZPTFhdCbkPf773R1g6dFdth7O04BUXl5Dp+b09gy dfmg== 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=Ig6EQtW7VCsMaZ2gSCuKUVZHyn5vZLN+32djRV0ye3wz5N4bwIpBpf8umnDezBUYib ttwOIgWGPsDPEH2V5cEm52I+ZfxZcf3BUwvlPoPTQ36C0KZk4NmBAIk14+ZhPFAx3Pn+ 3w6SFAPKgr+TKZQ0i7+t8uo180hoQu57kl0I6+KDNqxQL/uHXSV3xXs7iQxWIhvLmgoC BG3sMI1Xjbqwd1WEnOa68g4+MSua0vXuV7/DM9nwS8jY4ZNpHoafVFF7EN4nbprCSqyF Jfca3ofJpLMQ/49uUSqBf/gctWbfPSl25hsvKaTOCa2jXv3+ivV9yU7IA0VqLTkrvxdd ZmFA== X-Forwarded-Encrypted: i=1; AJvYcCXFzjPy57XCFKRpgZlDPA9+YpkAJ789FOXuQAnkvaJkXQ01Xhp8g9CR0uStVivlN1l7ZfXL8J+dPpOCrFTX2Ae81e5fBuHfIShTmh8A X-Gm-Message-State: AOJu0YxPhhHz+SXjfCKn/rO3UQQOlaf2MpJ+TLEBuASrHSOM/Xx5OVel 368nylhDj3cF2T83+HUsbZ/NUeyny9wJmw95Bvo6CWmWZcGgitTZSpvehYpOznE= 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> 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 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); -- 2.44.0.rc0.258.g7320e95886-goog