From patchwork Wed Feb 7 17:40:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13548804 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 CA44BC4828D for ; Wed, 7 Feb 2024 17:41:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A38B06B007E; Wed, 7 Feb 2024 12:41:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9E9C76B0080; Wed, 7 Feb 2024 12:41:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 814CC6B0081; Wed, 7 Feb 2024 12:41:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 6EBDC6B007E for ; Wed, 7 Feb 2024 12:41:15 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id EDD8080DE6 for ; Wed, 7 Feb 2024 17:41:14 +0000 (UTC) X-FDA: 81765724068.24.67ECB90 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) by imf07.hostedemail.com (Postfix) with ESMTP id 34A9C40017 for ; Wed, 7 Feb 2024 17:41:13 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none ("invalid DKIM record") header.d=soleen.com header.s=google header.b=oPnlaIQE; dmarc=none; spf=none (imf07.hostedemail.com: domain of pasha.tatashin@soleen.com has no SPF policy when checking 209.85.167.175) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707327673; 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=nU1hsaMMETz5PI0ifQcx6wtutKo5o6JsITK4WP9xIfM=; b=PDh2OLmOHSjfYIqCpjwMvdQwGyP6pWiMefWny1iAFeRTgv2Qh4vBvg6vxRo1PPiwAU4Vcl QopkBjRFQNE6Q5JLdatcZxgFppyYXfqR9yWWKDH1qSOKNnTKBtszUy4DH4ebj9PLNBq1al 1MVYpUglU4P0iEE3ZL7F06566Q4+Bho= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none ("invalid DKIM record") header.d=soleen.com header.s=google header.b=oPnlaIQE; dmarc=none; spf=none (imf07.hostedemail.com: domain of pasha.tatashin@soleen.com has no SPF policy when checking 209.85.167.175) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707327673; a=rsa-sha256; cv=none; b=CVVt+joAIHYIoniRIoyzwUrlWM5RY8hWq1nWO9+DlSo20pIilIFCqw+7rsh/BLaIhxYS8N FHdTxEFp07JByT8J3BVLVwnVYhcyQTQgym7m9YzXX/vcabLdN7zem9ji8AIeBc15z09znV k6Vf1laAGm+BKT0UKaVSFT4zKUidxgM= Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-3bfcbfbfd92so480867b6e.2 for ; Wed, 07 Feb 2024 09:41:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1707327672; x=1707932472; 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=nU1hsaMMETz5PI0ifQcx6wtutKo5o6JsITK4WP9xIfM=; b=oPnlaIQEluu3JQPYnpkz5azxZNNX0B2BNpqXlKnjl8XrSMbssksRilyHX2F3jnJ9Xi NQYr3x9OWcpp5nGtGQbcld/bEmAnDiFCWmxQha/7kpx7GLrOseNpxjLQcPzy7x6bU/jy P2YjPlyi2fjxZ+InVye6FDWM2Bozj1jXxwwnr9s1eVpxzTeNFdpKYd4VH+ZsrcXxdjHa VBRGGZuSD3qCR3J86/oiphSI46+absU8AZ/MCz/ckwSW2CAIhokagVKCCMSCzzcCkKcB C7zjkpWK5duF1dx4XkhUH48ojYirM1a1UiBSLltzCxRBB8Nn50yPDMJePlh8QtrjNE5x OdCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707327672; x=1707932472; 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=nU1hsaMMETz5PI0ifQcx6wtutKo5o6JsITK4WP9xIfM=; b=uzFCxBveJ5Py+8pC5gUATOcMkbBdpZZ6ZTTUoLKn7P9oDjvDEOAnMpVurk+pn0oNF0 CRZy1hOJY63qlqTW4nvBPoqlUrT2/dsHeNjoQEAH79WBxQWHq3qN8qddmP/ulQJ41nop g6j/t5STUqbiYSS6FJURFrHkChHBvDPvydZxzqOi+nb/FVUMrI4HQlmKtpMrrdHs3Haz 9764unulqmyP8mHl10RfiQV0VQBGAvGUDqfOESHmm4XiFsc/v0S2LMKoW/5ZO/dJMok7 MVBgDZetutHPnMSyyJv7HaMrXscq+BdEURn4a8oEFwRk6fxLFiwfh822AvGRHpgg6kvN C99Q== X-Gm-Message-State: AOJu0Yx8KTxO2JLW+DiNQAQLOQqpfZNfd0GFKO/TfqwuVLNaWUVFWWd/ L6gw8JnfZirrHtc04SaUgDZwLvskxup06AN3hv4THGbrIw+medbV8vc+Z/R9nG8= X-Google-Smtp-Source: AGHT+IFfEVUCKzT5CwUfTWDGYwi/acQYuhOxMwLwTqPmmzQgMoM1RPknF1EO7W4FpUIP2TDEpv0nmA== X-Received: by 2002:a05:6808:170b:b0:3bf:cd78:6759 with SMTP id bc11-20020a056808170b00b003bfcd786759mr7147363oib.54.1707327672178; Wed, 07 Feb 2024 09:41:12 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVZFB7U9B7PRWrPSa4Vm9JmfrqIfgvQmXJpEOBtNUmvSOjpwYquO3trQQgAz1YG9ML/HHjiBiy6VD9fRFGt91lhuf7+nYjR4rQlDPNeLxvlF7lf5fsIURb6D/+FPxIXEfNHePjZwnf/eJKPk8N4hejgBf9CgxBjRH8C7zoRBr70yQfJMx+T+z8aHOmeUBJfXbUrOyuqrIB/jOTCZIIPUxodCnNa1HjKcJxAaMlaebQghiZoxFazuVbzaancHHc0RIiOoAgPGBaVoCWC9ZSqEacGLMMVR4oUYKJob8ZjjrmLluN3Gm70Hp9p8E4+If2Dz/WCStrviHsRKJYQfwIJxjmgQnEgQ5lpg+7KBJ1NyE2I3J0fCX4nG5vqXgnpOARX2y9NWm1phXJf1JYc5/Oojpc0G5y/8V5o0yHcg73qI0YEtASy23+RxEI3SR3SJ8lVgg6RymMoVips177XOLYq6YaZjGnJzDqUa0QaF/0yvsAw1A1WMQVKSBhnl80xpbCHUp/AngwVe7DX3D00A2BcP/JC9KlEJSWAjruJ53zMgT0EAnEVgDNEu553g//Lqlo7rAS9pJ2BzEyAw7MRBh3zcmKCnIsh8VtTjh+jxgZ0T0y5RyB8UZC9WdMH/ywue7GfpHzx4WMaLAB1fPOK/jnCnItRzlZE2cnR6+UcobUeymHUia9MinrA42aJDGwz48xLeZUapI6z3XaSjbDqNA6bu2hwarQQHP/o6+CgxfItlyueY2yKNinbbQ3sGtjYVyJFpr36wZHL3Im3jTbCJhBhywPdZxuB92WxvF09LB4AFcM2ZSs6j1NCGbUgVlYH061oIVzrduqppQBTG7pKegtnxU77zowM9wwgFdby+9EWfzCmujL1sJ0k4aFxPhY5ZrgmQhCxiLHTwSSHD6bSZmhB1GostD0qm2aczbx36w/TWAN3T0NYTrysQg6sPtb2IO 9x18Eng1 YnIK0trnAheCgMO/3csZdfTu2FEA9Y9+tOJBtd0Kvu9kmJ01kz7cZ1+TY91LWy0W7NPAgrABtVr3uIriVrWIUS74fFRAWjk534ed/073Z3w8fm/dfgqszqf3hNAFXNLaKUjUlzsDxGOB2dhzQEEtNloHFSHvL9wtNSji6PcpYZC4Bg/W/kadih/Qh75sYZqtohZI9BMa2rYOLzNHCCy+rUAlKvhROT19ZzyqSb1BeoKi76qoL+qcgp96Drr0FjPc641vD7GlZiZcBKiOR5Qp+pJOxYhfqNe75t5Ma1xpvmJToVXrNx4f475KpOmW/LBYXSiN9TZX3XEhD6Wo9gSGAkZbyQZHNbpp88as+ALb1ZUQCQ+hOh414MHuPZKbmNdlt+6/7W4P2qOp/U/IiG3Xg0qHla/DOU+J437gr+hBNBiHCguyxl3s04AH/aHOLV4MCYYur/xHb0eZWBCD6XhOuBZv9h8Tj/knG/C05njAez74oc 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 e10-20020a37db0a000000b007854018044bsm696310qki.134.2024.02.07.09.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 09:41: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, bagasdotme@gmail.com, mkoutny@suse.com Subject: [PATCH v4 04/10] iommu/io-pgtable-dart: use page allocation function provided by iommu-pages.h Date: Wed, 7 Feb 2024 17:40:56 +0000 Message-ID: <20240207174102.1486130-5-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.594.gd9cf4e227d-goog In-Reply-To: <20240207174102.1486130-1-pasha.tatashin@soleen.com> References: <20240207174102.1486130-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: p4hqihjse5gnh96b7jccgzzhpnz717it X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 34A9C40017 X-HE-Tag: 1707327673-562673 X-HE-Meta: U2FsdGVkX1/PjMYqiQGaND+Ej3IBTS8AotyiE/BIykVQ2SIyehP/wkyKADPQPZQ6DKSHqlXauhf1WsoNetRo/KrlRlste4ewBVN8mgyKbR3iN9Q2ciuB2oRCX6Ln6eZgyT4pQE6FdV+o9KtSlRWubPZsQkIAzO6NWbBwtfsndC6KYTlCI5u8fn3VJ5czsGDD6cAXgafiC8K5fftid2X8UvE3cdjEuyUGPYzEsGenIIZDdRkOxW/Pf8vWn5hYeTOrIRMFcSS/En9iSxtRWhUPqeIaY2uLg5En7+LX9+bvJiQtHikH6C0kBcBVMVHPvihJFh9ppc6gYJlO3jMUsIL4nxXPtqfgpdw+dMC20aEQVRXn24rRwDqYDTzta2y1/mxegSG2JkWIHWCksDFIe7SY4SLP3JfGRgedDFXRQUs7x5cprbp3MAWt3FSMNFEdo6aOLslfi1R1QmUHQ0kZYbWIYTpgM/zXiX2YKlGNHuE3ouIE34afzazYbeuQrGgC81DmW/kRDfaVEL1U0aP3THDqGekqT19lJLddHhQbaXM19LdTn+tDYd9vAoaM09kzh9tFTv9F8Jt98enJD4k+lCaofFVtnOaNixy+4l+HXSaAz1F/LU50R47OGRstZqgy9VIXvLcohBLEeNvUMwi0Zcdp+C/EzXnMfP1MGhV92wjZEBPlBgEr7qmfhVmA7wbQBjIgDU7aRZgmT0fioagZvfS920w7+DmOqtlKSaEqWTrIPIIN4Ojec5xfCqMlqzGSzL8lRRgysJrvL36nyVcqPv8TQu4x0rxJt73vmOzueL5eVJWd7eK3BBW/LucW4IrUUQ5bejgIdaOGz1oZdoL1F2vQmeRDvV3UL241Vjl0JPdShRwybOV0Njv/ZhBJRyh6CIM1EHGa+xfbMrei7Yp+px1SALEUmtflBdhVymxsx8Sh29Slk9/K7FxHDRQaA8BZS2rLoTbkPn8FEI4SMeGySDg rA+zbg5J oRZHfEv7tGakR2d1NmRlJINKju8MUY9bMu8KQVqH48LRgGhIFopPXIdhB/PEa1V94eyLPdQLxLMm8fROkgvwkncucdEgxOaa8lJjh+p1bCHIAdCvcM+HbKwgQQsO+xqc7h/p1h6612KuVKaMtXWWi8/KJcvRvQ2HmEyllfqzZf0ijBGnEic7MUqmiVqzgHb6eJIzqJDmlQ3pFR/kJncsjtE68PV7VLvzImSbTxSUbkzw+ymAqpp7nfDrld/FhtR45wV+79ViyvPY7opDg8vumE8rlKttj7HuhbV3wbL+DDN0gK9il8IJyWkHXISGgCSYmH60yadnMxdwZsgUuoOR7ILG+O/nyGJjihwZ3kDogAN9PcVRldlyyVQ63JaVQqTxmAJd4svZVzIvRBDtQ6OBa8cWUpf+63OG3s0MfyZwuAlfOQ8Kwb60rX+hejTmhZRtFa7lQgai9IlC+f8jlBJNdOIrSAmv4moJ6FSx9XiK40OSd8Fwf+AupxJYdOhoaXIQRiHnz 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);