From patchwork Thu Nov 30 20:14:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13475013 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 B34FBC10DC1 for ; Thu, 30 Nov 2023 20:15:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1DA576B0498; Thu, 30 Nov 2023 15:15:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 163186B0499; Thu, 30 Nov 2023 15:15:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E82976B049A; Thu, 30 Nov 2023 15:15:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D13B86B0498 for ; Thu, 30 Nov 2023 15:15:11 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9FE0B140311 for ; Thu, 30 Nov 2023 20:15:11 +0000 (UTC) X-FDA: 81515724822.14.63E4211 Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) by imf09.hostedemail.com (Postfix) with ESMTP id B9C9614002E for ; Thu, 30 Nov 2023 20:15:09 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=L5ZjrDvB; spf=pass (imf09.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.53 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701375309; 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=5Yy4hUPviTRiK7d1jgshQ8ZyWUkBDBJBzqyGrbBWtJ8=; b=A8ev0Qcyn5sjMHZ4bLcllI/38uNihqU8b74dQxBYlMrCGwx4B4IUS2V0RmjV0s1rBflizw o5JorBln/llqTAmap4IvJN7LNzY/5h9Cpc6wKa12jL1P13GOTueajYd4Xbkj5lahMNZn5d jUuc83KSVlS4LD87s1zE7qO8pM3XgvI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701375309; a=rsa-sha256; cv=none; b=bDYexTWKZp4ggXuTYTnXF+dOtQcCc46LSUbZ6KBwVmVKfmJ20L5WmmCqWtwDsUNonL05fi Lho8Fhf6psuovLYL9n8QzxFK+L2GkF4Siap+0cz5FqEpHyT6LjhmAtCCugpBlPIVsRleGf NlVKwfTPBfegD/rwOLqtrz349hYXbu0= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=L5ZjrDvB; spf=pass (imf09.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.53 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-67a18556e4aso8196716d6.1 for ; Thu, 30 Nov 2023 12:15:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701375309; x=1701980109; 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=5Yy4hUPviTRiK7d1jgshQ8ZyWUkBDBJBzqyGrbBWtJ8=; b=L5ZjrDvB9BiKeyuKzwb9cfa98YXCpwCQqLTAftOvg2RfZwNkyHxYi1DLZMUzQ6Bhsy fQ1WkyMN8kyOM5fyUhJWiJTwe1COnwi2EcLQiR9tByFdaXDYmPRYHp9RR9YhXlHLpdCY U3W612AZVg+OU1GQ2JWJgsu3cU360VOXLi0Dc8ZAU8ba/uVYIqI8onxrQrNQxP2BdErg tsF3lIQtg/KYELaGAWubSKPmldFDP+KfdGIuzqnixH9ffx214Swq/rR5yqFdfVS0c70y 1KM5pI/MXiNmV6FtuYs/SEPG1u9lZ+DBTAX8ty9ZHdE0zIetQYcMCtCasX2GUUTlsI1r Y4Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701375309; x=1701980109; 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=5Yy4hUPviTRiK7d1jgshQ8ZyWUkBDBJBzqyGrbBWtJ8=; b=KNtZZmiLvBwNpH14XFVQcmedBaOZc7wZdElxcU9JZ6ra88MNS+KFAX3rF2IMUh272H bv6BwCLbiVOI0HxQG//1OjJJKvPOoQQafeSZevIaheO3xq3UXB/FKLL7stAgsEkUeryP 7KCvoayNzIYl8otBLjv0eJ6DT5P11qXPLliVu/UdBdBkaaKaBTXavxYU1f/UnrFHhUNb oKAyFbuMXan8KzohiPsbZEQn5teUMWekjeGO8wKcu4xtSUMyGtOe7CanQQRuJFh7TCmS YqIKmRsWH64hg4ZlYlado6LCvJLW7OxMh1pkxgnVYSDYGWrIOjk8HGN5EqkpTaZRrXeB xypA== X-Gm-Message-State: AOJu0YyCk8Hk6sIc8612W8C5k0YNGAIGx0t9CSpuAyZh4CX8CKmrv/rt JDvMkIt2VL25yQKc6G2GkQbYsQ== X-Google-Smtp-Source: AGHT+IGCIqCObFA80tw7Jta1n2W741ba5hgCsTPwLFmmg3Py4KcfDat3ov/DNtpwRDSPnMG9nDwuDg== X-Received: by 2002:a05:6214:287:b0:67a:2bbf:183c with SMTP id l7-20020a056214028700b0067a2bbf183cmr19404618qvv.2.1701375308866; Thu, 30 Nov 2023 12:15:08 -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 e1-20020a0cb441000000b0067a35608186sm795252qvf.28.2023.11.30.12.15.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:15:08 -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 Subject: [PATCH v2 01/10] iommu/vt-d: add wrapper functions for page allocations Date: Thu, 30 Nov 2023 20:14:55 +0000 Message-ID: <20231130201504.2322355-2-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231130201504.2322355-1-pasha.tatashin@soleen.com> References: <20231130201504.2322355-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: B9C9614002E X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 9zpgbodhsgitcuziyadug93dq9oygkqz X-HE-Tag: 1701375309-120109 X-HE-Meta: U2FsdGVkX19oOQFVHn6TlMghM7QIukFXcmOrJq8UGD8OctU16plc4894WhQgbTNKVuBIc6TYsQ74UxcBtONUFKIzBUmUCK9U0aU5nEeK9AcHO0yQFjUI9HF5xy3fAyLX+AZJZuTqiyTfJfy/QuAFycmNnfVh+i2oD/UGpTED63GBJdxMmYmzUT8FQDwT6B09Rnuvu5sDtYqU2IjBXJdWIiWuhlgy9uiXB/SdrRY/gwvT8ON6EpaMD7RXUMs+3lkrQqjOff8+FIWaG/lAffHF1niUltFlVLsbtIdvyBVwHqaAoYcquLZFxQ1iY4McSaFQuodt9898jPkuvt1WBu10p6CRvk/1M0oSPYIlL0TgG3ctgTvrc/PuMZz/ZYepc/suh/mcTmKInQjxrji5SXut5gw5XS5wpHPRfl4e2BRLKwR3M1uL3DAlSCwkUmU5ljdCPfIw3cQkBNaZdvwel3C4dc+vr/0yHzFKxo39ly1e3CD+b037L3YRCIWeYRRpukGgXwSQMCV/eI/wmHtDVCm3uI4ZQzoc5pfLoy8o7/mTJVMT//NJ4ouceS/ddq5ddnfoHHUfcy1lDuxbi6Sw6YHT+lbrEHPfOHk5UARuJiz+O+SLW95yhStpUZRpYOi8O7CzsYeokLr01EdIeY0oQPnsP42v9dXJRkyg77vpCtVlUeANAjv/rw//FjEgjT5pOvFvks/nJJ/oz9Dzrwj2GzAfjgsVTSJJltf858nq4rHv6Bq64aTYSzQyznZWyqg3hTBfE7b+MRifK7H//xp5nuNY9ycd/5CMrfQ5yd8LmmYuUnqEI54c+12ezL40u/aJUYDSgIJiJNohv8cMdR47mpro8tMyVzxwIctUN5tWqJzttnGbjdUhkIabagnzJjxpA24BPP5FGVa0l9XN6e2N+/dI0POmLVX86RH3I2EHg8yg9QpS85ScrqAlIKOpHDc1cUslxkIzul40JeuOlRgs7D/ +vFNS8rA GQmYzbmLycWqNIbk1rSiUCfwofimiplmiGTsOWUHUoJ9AoJIP8TYEeZzuvVCYL4RFkmnmtMsDTy2XmCQ4Xrtp14vH7FnxM35JjNmGLrODkLCsViM/DHEIXz2VDCZH5AqzIx5JI0s33TfpJPrh9454epB7nqRMM5JTe45OFxOO+7hhQ3CZv00hPCx0BT9JPKEdgzeaRJ/PGuJKfd8lRvTAXD16gZcYjxgPwx5Q6hNXEUiMfhnEOOO2sEZNsI8CU/KFWWZU8BMN6/FCrays2zAjbF3XeufkdusHHFWd1LOhTOCP9rFiDXUNgR+UsL7l33gAq6eM5uqTKf1iWrY5MD5rnSrVlKwoqJnkS5nUpCB1OZGIOfmXVA0Dlj49NnUmSdjW+/f3Ykl/i2OA8aGo6chCXdCAdWMN2CDTSvFn+yIWM/UKWpWPp83a+eVvrR3tzp+VNbctgojdgFGy2H+J95TbpL84K7OQppfhVFbEv3j2BH0Sdj5pkCGLJKt4ESYiwDmSO/RcFVuH12+Nt5GiLl3S6DjqHQ== 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: In order to improve observability and accountability of IOMMU layer, we must account the number of pages that are allocated by functions that are calling directly into buddy allocator. This is achieved by first wrapping the allocation related functions into a separate inline functions in new file: drivers/iommu/iommu-pages.h Convert all page allocation calls under iommu/intel to use these new functions. Signed-off-by: Pasha Tatashin --- drivers/iommu/intel/dmar.c | 10 +- drivers/iommu/intel/iommu.c | 47 +++---- drivers/iommu/intel/iommu.h | 2 - drivers/iommu/intel/irq_remapping.c | 10 +- drivers/iommu/intel/pasid.c | 12 +- drivers/iommu/intel/svm.c | 7 +- drivers/iommu/iommu-pages.h | 199 ++++++++++++++++++++++++++++ 7 files changed, 236 insertions(+), 51 deletions(-) create mode 100644 drivers/iommu/iommu-pages.h diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c index a3414afe11b0..a6937e1e20a5 100644 --- a/drivers/iommu/intel/dmar.c +++ b/drivers/iommu/intel/dmar.c @@ -32,6 +32,7 @@ #include "iommu.h" #include "../irq_remapping.h" +#include "../iommu-pages.h" #include "perf.h" #include "trace.h" #include "perfmon.h" @@ -1185,7 +1186,7 @@ static void free_iommu(struct intel_iommu *iommu) } if (iommu->qi) { - free_page((unsigned long)iommu->qi->desc); + iommu_free_page(iommu->qi->desc); kfree(iommu->qi->desc_status); kfree(iommu->qi); } @@ -1714,6 +1715,7 @@ int dmar_enable_qi(struct intel_iommu *iommu) { struct q_inval *qi; struct page *desc_page; + int order; if (!ecap_qis(iommu->ecap)) return -ENOENT; @@ -1734,8 +1736,8 @@ int dmar_enable_qi(struct intel_iommu *iommu) * Need two pages to accommodate 256 descriptors of 256 bits each * if the remapping hardware supports scalable mode translation. */ - desc_page = alloc_pages_node(iommu->node, GFP_ATOMIC | __GFP_ZERO, - !!ecap_smts(iommu->ecap)); + order = ecap_smts(iommu->ecap) ? 1 : 0; + desc_page = __iommu_alloc_pages_node(iommu->node, GFP_ATOMIC, order); if (!desc_page) { kfree(qi); iommu->qi = NULL; @@ -1746,7 +1748,7 @@ int dmar_enable_qi(struct intel_iommu *iommu) qi->desc_status = kcalloc(QI_LENGTH, sizeof(int), GFP_ATOMIC); if (!qi->desc_status) { - free_page((unsigned long) qi->desc); + iommu_free_page(qi->desc); kfree(qi); iommu->qi = NULL; return -ENOMEM; diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 3531b956556c..04f852175cbe 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -28,6 +28,7 @@ #include "../dma-iommu.h" #include "../irq_remapping.h" #include "../iommu-sva.h" +#include "../iommu-pages.h" #include "pasid.h" #include "cap_audit.h" #include "perfmon.h" @@ -367,22 +368,6 @@ static int __init intel_iommu_setup(char *str) } __setup("intel_iommu=", intel_iommu_setup); -void *alloc_pgtable_page(int node, gfp_t gfp) -{ - struct page *page; - void *vaddr = NULL; - - page = alloc_pages_node(node, gfp | __GFP_ZERO, 0); - if (page) - vaddr = page_address(page); - return vaddr; -} - -void free_pgtable_page(void *vaddr) -{ - free_page((unsigned long)vaddr); -} - static inline int domain_type_is_si(struct dmar_domain *domain) { return domain->domain.type == IOMMU_DOMAIN_IDENTITY; @@ -617,7 +602,7 @@ struct context_entry *iommu_context_addr(struct intel_iommu *iommu, u8 bus, if (!alloc) return NULL; - context = alloc_pgtable_page(iommu->node, GFP_ATOMIC); + context = iommu_alloc_page_node(iommu->node, GFP_ATOMIC); if (!context) return NULL; @@ -791,17 +776,17 @@ static void free_context_table(struct intel_iommu *iommu) for (i = 0; i < ROOT_ENTRY_NR; i++) { context = iommu_context_addr(iommu, i, 0, 0); if (context) - free_pgtable_page(context); + iommu_free_page(context); if (!sm_supported(iommu)) continue; context = iommu_context_addr(iommu, i, 0x80, 0); if (context) - free_pgtable_page(context); + iommu_free_page(context); } - free_pgtable_page(iommu->root_entry); + iommu_free_page(iommu->root_entry); iommu->root_entry = NULL; } @@ -939,7 +924,7 @@ static struct dma_pte *pfn_to_dma_pte(struct dmar_domain *domain, if (!dma_pte_present(pte)) { uint64_t pteval; - tmp_page = alloc_pgtable_page(domain->nid, gfp); + tmp_page = iommu_alloc_page_node(domain->nid, gfp); if (!tmp_page) return NULL; @@ -951,7 +936,7 @@ static struct dma_pte *pfn_to_dma_pte(struct dmar_domain *domain, if (cmpxchg64(&pte->val, 0ULL, pteval)) /* Someone else set it while we were thinking; use theirs. */ - free_pgtable_page(tmp_page); + iommu_free_page(tmp_page); else domain_flush_cache(domain, pte, sizeof(*pte)); } @@ -1064,7 +1049,7 @@ static void dma_pte_free_level(struct dmar_domain *domain, int level, last_pfn < level_pfn + level_size(level) - 1)) { dma_clear_pte(pte); domain_flush_cache(domain, pte, sizeof(*pte)); - free_pgtable_page(level_pte); + iommu_free_page(level_pte); } next: pfn += level_size(level); @@ -1088,7 +1073,7 @@ static void dma_pte_free_pagetable(struct dmar_domain *domain, /* free pgd */ if (start_pfn == 0 && last_pfn == DOMAIN_MAX_PFN(domain->gaw)) { - free_pgtable_page(domain->pgd); + iommu_free_page(domain->pgd); domain->pgd = NULL; } } @@ -1190,7 +1175,7 @@ static int iommu_alloc_root_entry(struct intel_iommu *iommu) { struct root_entry *root; - root = alloc_pgtable_page(iommu->node, GFP_ATOMIC); + root = iommu_alloc_page_node(iommu->node, GFP_ATOMIC); if (!root) { pr_err("Allocating root entry for %s failed\n", iommu->name); @@ -1863,7 +1848,7 @@ static void domain_exit(struct dmar_domain *domain) LIST_HEAD(freelist); domain_unmap(domain, 0, DOMAIN_MAX_PFN(domain->gaw), &freelist); - put_pages_list(&freelist); + iommu_free_pages_list(&freelist); } if (WARN_ON(!list_empty(&domain->devices))) @@ -2637,7 +2622,7 @@ static int copy_context_table(struct intel_iommu *iommu, if (!old_ce) goto out; - new_ce = alloc_pgtable_page(iommu->node, GFP_KERNEL); + new_ce = iommu_alloc_page_node(iommu->node, GFP_KERNEL); if (!new_ce) goto out_unmap; @@ -3570,7 +3555,7 @@ static int intel_iommu_memory_notifier(struct notifier_block *nb, start_vpfn, mhp->nr_pages, list_empty(&freelist), 0); rcu_read_unlock(); - put_pages_list(&freelist); + iommu_free_pages_list(&freelist); } break; } @@ -4001,7 +3986,7 @@ static int md_domain_init(struct dmar_domain *domain, int guest_width) domain->max_addr = 0; /* always allocate the top pgd */ - domain->pgd = alloc_pgtable_page(domain->nid, GFP_ATOMIC); + domain->pgd = iommu_alloc_page_node(domain->nid, GFP_ATOMIC); if (!domain->pgd) return -ENOMEM; domain_flush_cache(domain, domain->pgd, PAGE_SIZE); @@ -4148,7 +4133,7 @@ int prepare_domain_attach_device(struct iommu_domain *domain, pte = dmar_domain->pgd; if (dma_pte_present(pte)) { dmar_domain->pgd = phys_to_virt(dma_pte_addr(pte)); - free_pgtable_page(pte); + iommu_free_page(pte); } dmar_domain->agaw--; } @@ -4295,7 +4280,7 @@ static void intel_iommu_tlb_sync(struct iommu_domain *domain, start_pfn, nrpages, list_empty(&gather->freelist), 0); - put_pages_list(&gather->freelist); + iommu_free_pages_list(&gather->freelist); } static phys_addr_t intel_iommu_iova_to_phys(struct iommu_domain *domain, diff --git a/drivers/iommu/intel/iommu.h b/drivers/iommu/intel/iommu.h index 65d37a138c75..b505f3f44d0a 100644 --- a/drivers/iommu/intel/iommu.h +++ b/drivers/iommu/intel/iommu.h @@ -894,8 +894,6 @@ void domain_update_iommu_cap(struct dmar_domain *domain); int dmar_ir_support(void); -void *alloc_pgtable_page(int node, gfp_t gfp); -void free_pgtable_page(void *vaddr); void iommu_flush_write_buffer(struct intel_iommu *iommu); struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devfn); struct iommu_domain *intel_nested_domain_alloc(struct iommu_domain *parent, diff --git a/drivers/iommu/intel/irq_remapping.c b/drivers/iommu/intel/irq_remapping.c index 29b9e55dcf26..72e1c1342c13 100644 --- a/drivers/iommu/intel/irq_remapping.c +++ b/drivers/iommu/intel/irq_remapping.c @@ -22,6 +22,7 @@ #include "iommu.h" #include "../irq_remapping.h" +#include "../iommu-pages.h" #include "cap_audit.h" enum irq_mode { @@ -536,8 +537,8 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu) if (!ir_table) return -ENOMEM; - pages = alloc_pages_node(iommu->node, GFP_KERNEL | __GFP_ZERO, - INTR_REMAP_PAGE_ORDER); + pages = __iommu_alloc_pages_node(iommu->node, GFP_KERNEL, + INTR_REMAP_PAGE_ORDER); if (!pages) { pr_err("IR%d: failed to allocate pages of order %d\n", iommu->seq_id, INTR_REMAP_PAGE_ORDER); @@ -622,7 +623,7 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu) out_free_bitmap: bitmap_free(bitmap); out_free_pages: - __free_pages(pages, INTR_REMAP_PAGE_ORDER); + __iommu_free_pages(pages, INTR_REMAP_PAGE_ORDER); out_free_table: kfree(ir_table); @@ -643,8 +644,7 @@ static void intel_teardown_irq_remapping(struct intel_iommu *iommu) irq_domain_free_fwnode(fn); iommu->ir_domain = NULL; } - free_pages((unsigned long)iommu->ir_table->base, - INTR_REMAP_PAGE_ORDER); + iommu_free_pages(iommu->ir_table->base, INTR_REMAP_PAGE_ORDER); bitmap_free(iommu->ir_table->bitmap); kfree(iommu->ir_table); iommu->ir_table = NULL; diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index 74e8e4c17e81..1856e74bba78 100644 --- a/drivers/iommu/intel/pasid.c +++ b/drivers/iommu/intel/pasid.c @@ -20,6 +20,7 @@ #include "iommu.h" #include "pasid.h" +#include "../iommu-pages.h" /* * Intel IOMMU system wide PASID name space: @@ -116,8 +117,7 @@ int intel_pasid_alloc_table(struct device *dev) size = max_pasid >> (PASID_PDE_SHIFT - 3); order = size ? get_order(size) : 0; - pages = alloc_pages_node(info->iommu->node, - GFP_KERNEL | __GFP_ZERO, order); + pages = __iommu_alloc_pages_node(info->iommu->node, GFP_KERNEL, order); if (!pages) { kfree(pasid_table); return -ENOMEM; @@ -154,10 +154,10 @@ void intel_pasid_free_table(struct device *dev) max_pde = pasid_table->max_pasid >> PASID_PDE_SHIFT; for (i = 0; i < max_pde; i++) { table = get_pasid_table_from_pde(&dir[i]); - free_pgtable_page(table); + iommu_free_page(table); } - free_pages((unsigned long)pasid_table->table, pasid_table->order); + iommu_free_pages(pasid_table->table, pasid_table->order); kfree(pasid_table); } @@ -203,7 +203,7 @@ static struct pasid_entry *intel_pasid_get_entry(struct device *dev, u32 pasid) retry: entries = get_pasid_table_from_pde(&dir[dir_index]); if (!entries) { - entries = alloc_pgtable_page(info->iommu->node, GFP_ATOMIC); + entries = iommu_alloc_page_node(info->iommu->node, GFP_ATOMIC); if (!entries) return NULL; @@ -215,7 +215,7 @@ static struct pasid_entry *intel_pasid_get_entry(struct device *dev, u32 pasid) */ if (cmpxchg64(&dir[dir_index].val, 0ULL, (u64)virt_to_phys(entries) | PASID_PTE_PRESENT)) { - free_pgtable_page(entries); + iommu_free_page(entries); goto retry; } if (!ecap_coherent(info->iommu->ecap)) { diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c index 50a481c895b8..4cf8826b30e1 100644 --- a/drivers/iommu/intel/svm.c +++ b/drivers/iommu/intel/svm.c @@ -23,6 +23,7 @@ #include "pasid.h" #include "perf.h" #include "../iommu-sva.h" +#include "../iommu-pages.h" #include "trace.h" static irqreturn_t prq_event_thread(int irq, void *d); @@ -67,7 +68,7 @@ int intel_svm_enable_prq(struct intel_iommu *iommu) struct page *pages; int irq, ret; - pages = alloc_pages(GFP_KERNEL | __GFP_ZERO, PRQ_ORDER); + pages = __iommu_alloc_pages(GFP_KERNEL, PRQ_ORDER); if (!pages) { pr_warn("IOMMU: %s: Failed to allocate page request queue\n", iommu->name); @@ -118,7 +119,7 @@ int intel_svm_enable_prq(struct intel_iommu *iommu) dmar_free_hwirq(irq); iommu->pr_irq = 0; free_prq: - free_pages((unsigned long)iommu->prq, PRQ_ORDER); + iommu_free_pages(iommu->prq, PRQ_ORDER); iommu->prq = NULL; return ret; @@ -141,7 +142,7 @@ int intel_svm_finish_prq(struct intel_iommu *iommu) iommu->iopf_queue = NULL; } - free_pages((unsigned long)iommu->prq, PRQ_ORDER); + iommu_free_pages(iommu->prq, PRQ_ORDER); iommu->prq = NULL; return 0; diff --git a/drivers/iommu/iommu-pages.h b/drivers/iommu/iommu-pages.h new file mode 100644 index 000000000000..2332f807d514 --- /dev/null +++ b/drivers/iommu/iommu-pages.h @@ -0,0 +1,199 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2023, Google LLC. + * Pasha Tatashin + */ + +#ifndef __IOMMU_PAGES_H +#define __IOMMU_PAGES_H + +#include +#include +#include + +/* + * All page allocation that are performed in the IOMMU subsystem must use one of + * the functions below. This is necessary for the proper accounting as IOMMU + * state can be rather large, i.e. multiple gigabytes in size. + */ + +/** + * __iommu_alloc_pages_node - allocate a zeroed page of a given order from + * specific NUMA node. + * @nid: memory NUMA node id + * @gfp: buddy allocator flags + * @order: page order + * + * returns the head struct page of the allocated page. + */ +static inline struct page *__iommu_alloc_pages_node(int nid, gfp_t gfp, + int order) +{ + struct page *pages; + + pages = alloc_pages_node(nid, gfp | __GFP_ZERO, order); + if (!pages) + return NULL; + + return pages; +} + +/** + * __iommu_alloc_pages - allocate a zeroed page of a given order. + * @gfp: buddy allocator flags + * @order: page order + * + * returns the head struct page of the allocated page. + */ +static inline struct page *__iommu_alloc_pages(gfp_t gfp, int order) +{ + struct page *pages; + + pages = alloc_pages(gfp | __GFP_ZERO, order); + if (!pages) + return NULL; + + return pages; +} + +/** + * __iommu_alloc_page_node - allocate a zeroed page at specific NUMA node. + * @nid: memory NUMA node id + * @gfp: buddy allocator flags + * + * returns the struct page of the allocated page. + */ +static inline struct page *__iommu_alloc_page_node(int nid, gfp_t gfp) +{ + return __iommu_alloc_pages_node(nid, gfp, 0); +} + +/** + * __iommu_alloc_page - allocate a zeroed page + * @gfp: buddy allocator flags + * + * returns the struct page of the allocated page. + */ +static inline struct page *__iommu_alloc_page(gfp_t gfp) +{ + return __iommu_alloc_pages(gfp, 0); +} + +/** + * __iommu_free_pages - free page of a given order + * @pages: head struct page of the page + * @order: page order + */ +static inline void __iommu_free_pages(struct page *pages, int order) +{ + if (!pages) + return; + + __free_pages(pages, order); +} + +/** + * __iommu_free_page - free page + * @page: struct page of the page + */ +static inline void __iommu_free_page(struct page *page) +{ + __iommu_free_pages(page, 0); +} + +/** + * iommu_alloc_pages_node - allocate a zeroed page of a given order from + * specific NUMA node. + * @nid: memory NUMA node id + * @gfp: buddy allocator flags + * @order: page order + * + * returns the virtual address of the allocated page + */ +static inline void *iommu_alloc_pages_node(int nid, gfp_t gfp, int order) +{ + struct page *pages = __iommu_alloc_pages_node(nid, gfp, order); + + if (!pages) + return NULL; + + return page_address(pages); +} + +/** + * iommu_alloc_pages - allocate a zeroed page of a given order + * @gfp: buddy allocator flags + * @order: page order + * + * returns the virtual address of the allocated page + */ +static inline void *iommu_alloc_pages(gfp_t gfp, int order) +{ + struct page *pages = __iommu_alloc_pages(gfp, order); + + if (!pages) + return NULL; + + return page_address(pages); +} + +/** + * iommu_alloc_page_node - allocate a zeroed page at specific NUMA node. + * @nid: memory NUMA node id + * @gfp: buddy allocator flags + * + * returns the virtual address of the allocated page + */ +static inline void *iommu_alloc_page_node(int nid, gfp_t gfp) +{ + return iommu_alloc_pages_node(nid, gfp, 0); +} + +/** + * iommu_alloc_page - allocate a zeroed page + * @gfp: buddy allocator flags + * + * returns the virtual address of the allocated page + */ +static inline void *iommu_alloc_page(gfp_t gfp) +{ + return iommu_alloc_pages(gfp, 0); +} + +/** + * iommu_free_pages - free page of a given order + * @virt: virtual address of the page to be freed. + * @order: page order + */ +static inline void iommu_free_pages(void *virt, int order) +{ + if (!virt) + return; + + __iommu_free_pages(virt_to_page(virt), order); +} + +/** + * iommu_free_page - free page + * @virt: virtual address of the page to be freed. + */ +static inline void iommu_free_page(void *virt) +{ + iommu_free_pages(virt, 0); +} + +/** + * iommu_free_pages_list - free a list of pages. + * @pages: the head of the lru list to be freed. + */ +static inline void iommu_free_pages_list(struct list_head *pages) +{ + while (!list_empty(pages)) { + struct page *p = list_entry(pages->prev, struct page, lru); + + list_del(&p->lru); + put_page(p); + } +} + +#endif /* __IOMMU_PAGES_H */ From patchwork Thu Nov 30 20:14:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13475014 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 E7183C4167B for ; Thu, 30 Nov 2023 20:15:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0A10F6B0499; Thu, 30 Nov 2023 15:15:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 029CD6B049A; Thu, 30 Nov 2023 15:15:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D70E56B049B; Thu, 30 Nov 2023 15:15:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id C66096B0499 for ; Thu, 30 Nov 2023 15:15:12 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A28D4A04F5 for ; Thu, 30 Nov 2023 20:15:12 +0000 (UTC) X-FDA: 81515724864.01.F989EA6 Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) by imf17.hostedemail.com (Postfix) with ESMTP id BCB3E40015 for ; Thu, 30 Nov 2023 20:15:10 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=kcgPfcDp; dmarc=none; spf=pass (imf17.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.51 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=1701375310; 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=k1GabcB3edaQg1Ui1Yy9urjYmEO9oSCGrDI9SMXfmmE=; b=slKfIboeUO5fXwfiqDYlIeMtVQ8rrVDXy06LYNfmfWqxQJmOlP6dGKMncF9pucd01Ccc/n RCNDO49YZ6gWI3icW1nQ4BGJfiJxpndrifckjrp/tuqrZappztHq4Vewp129JRolRkgvMw bb4tr3+GTlFzciJ9YyL0THlXz+2KKxM= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=kcgPfcDp; dmarc=none; spf=pass (imf17.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.51 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701375310; a=rsa-sha256; cv=none; b=Uzs+29MEMXIvTpEBlKi9Nc0gKp+nPzrWjM6116SosQ8Oqz/V4Yw5H6lPqd8l1QMRVB0Q+x MdtgtA6/VR6YzlmfWRQyHn6c0OLqA74jLai7dkWvVu1uEkQ59UK7gsmOQvWsUOJHPfg3bT JR2WZ6AoBOPtcZPvniXZn5rMDWsHOmc= Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-67a31b64a9aso7885006d6.0 for ; Thu, 30 Nov 2023 12:15:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701375310; x=1701980110; 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=k1GabcB3edaQg1Ui1Yy9urjYmEO9oSCGrDI9SMXfmmE=; b=kcgPfcDpL8XbGbm2Ehj1Ww871/Do1noYe54oayHUHg2eC2IEpAAjBIeWmFOAIm5mT8 TD7eath73uzOZO72J7CnUkSKS1mjYXf3/jTryWydawlrdN7S15YI6+32RXQL5b4aWBL6 d9e0aPVPR17/zA2jxjj7c4X8cdg5vhmp2ACBE3oxBFxbU2ILvXVjUf+nOqrqtIcV6YC8 uDNPbOKYrU2AhEI+byGQuTpReH2nfBrLNciCeFyJ2oKqZlXZpE2AGHGIOwx0OW9IWr7v 8u6CZBvV23ubZx7g3mds/N0AspHOdlB1I+qp16VNE2a+EeXjf6iQijPZ3LU54xjakYKo Us5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701375310; x=1701980110; 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=k1GabcB3edaQg1Ui1Yy9urjYmEO9oSCGrDI9SMXfmmE=; b=pNIBqsGmkgZh33mHZ/R3DSimn4eANkb9bRVlt7mJrT0uNyMhPlTSPpAbClaYDN7NGT FjI3xwcY0arWiive+mDsFvLuKLXxej0CdPGuFJeuIXtGWI2gHbOjfycCy0ewOcdxbHb5 Gf6g8LSfhNzk/4GWjHw7R6lhaeearlTCvTL2JHAmDplnCFYho1kDgTyLQvEMkAgwACnm JH8yaY5b1O21YoGhGMl8t09mtnXSyyeqFeSr0KLtpQArzXtGWBV/80BFfiFmrh+xLWUn R82acHUxmc1Doq1r919kKi0uD3O//yNnl2fdYzL4ZdNbhOzB+psP8wr3aiDCOXceA7tT pj4w== X-Gm-Message-State: AOJu0Yx6blh3id9tjzDOidqIeBzv4iSPvSJndEJhhTWrLDaZQnpre5w5 haUrEmOi77H+QpGJLSrQje14UA== X-Google-Smtp-Source: AGHT+IF/Blnoafa9OjCDknxdUTY4F5jBndUc1vQ2ufXTyj0UbD/GMwQrpuQS8tJHsFnHFGhn1lLwKQ== X-Received: by 2002:a05:6214:1111:b0:67a:6041:6f94 with SMTP id e17-20020a056214111100b0067a60416f94mr9016771qvs.24.1701375309752; Thu, 30 Nov 2023 12:15:09 -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 e1-20020a0cb441000000b0067a35608186sm795252qvf.28.2023.11.30.12.15.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:15:09 -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 Subject: [PATCH v2 02/10] iommu/amd: use page allocation function provided by iommu-pages.h Date: Thu, 30 Nov 2023 20:14:56 +0000 Message-ID: <20231130201504.2322355-3-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231130201504.2322355-1-pasha.tatashin@soleen.com> References: <20231130201504.2322355-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: BCB3E40015 X-Stat-Signature: o3w6k6nozkj7r8kxj3j8i37fydqo3q93 X-HE-Tag: 1701375310-403901 X-HE-Meta: U2FsdGVkX18AeYGxc3bFprknzmimzgHk4XrYaimSNCBuaR6eg5DthsoSAWr2Pxlbpn4CWYzU2ZvCEr2x4JMtgUgbEX9tSe4xphmSRUZkbFiBrtvZlT+e+hFP8I3Ywn/Cxsca6YhGa8h6gqH9ggGOuinvzgB48d8+07xP+rb8yEysS+K3J5N/D2s5UPwDy7y43rbj5oJmdx5cgbTvXfNwyu2zQbOAMlCzo+gyj9JjdXbJUhmEowp5H2XIKUeQo7RG5GXvM1JOJN39FcDsqqfxkqgyMw1xPUx5RAQ5Q62Lh9CQ7k/x+MlclXIB9Z6nplKSq6TW0zq7FvZTotTuLauwqufOSFvTGIR0zDJL9Dtdf7j5a05urKoKaoSPM2PJ1ymfoNM7rkAm0ibtyru3zg+DQN4An7LqKQ6lpq5mevB7KpLEuWb5/pIYpEA0uCfgH0HP34qL8CgltFxffoMjOcYWOWuAYVE65rPtwTb/aiCKfulYdidqZ8O8zXwmnM7SuBLjK2/PNm2cYxh2FIOpPA75t+yLfR7WGdVICf4UG9sJC1xr96+KN3IBDj1dnN3VjKrh/HyBo0pi90AavNUq8LvTHEKMfWxC/fqmxVyhzf8+bgwU2y+DNoGiqLIQGzvfRPCxg1pHkIYzwjDRQ+/eyP77lUNCpGwzEcZBdktKsMGE5DDjgFHYG3mEtakVDucq+LRRpMtUMnmFI2V/IVUQt4N6ks5Ut7Q/lQfAOXK0hAKJm0gDWbIBVL2FJcLZBczLEJi3xr8iYV479E0pc+sguS48wECDaTns/ApSpwSRvutZK8duO18SMxbKhYGFJnelBfwBCJOkXQaUgHOxClFLcPHRfxHYWp0wV6Swqb6hYYfYKsL5kRUo8uAn8ROfa6dObbIVgm3700kqHldtaLM3gBwGinPZkV+w3T659AYRilGURL2cRY681r/1kBi7x1VD/sTro3oEjMEJNWUZRPKJFiH z2Etj+0E 1n0oKjI7wd3E1TGh4wuUCpPDmIFjSdxSK8AQeiPIXrHSqVcXT9NUh3nlZgpVZRxACv0yFEiO+VZJT0ozZdh6DDwyGuPySldy5OLDrfVyJN9PYGTAbHOxpjSmxnvAHsRirtguz2Urk0rmf4h0lvN8b6RCaQed0uqS/MXBduB6ItElT1LgaFiQZI6/eHa6o/9b/ANWb2j5aTMEtwqKvU7zDmJv9qsJ1fDsryO+cExPGB9yEzRMiaH64+wAlZy+Y8IVVLl+dLFzJr/YrEny3ODdOS030yioQvWi2lXV8sT7gCYtRD/JZqfkWeuqbHztri72pDBp7vN+Xz03g5ibA7TOzxEi2k2NsVqhQk48aovXU+XVkW9YciTtrdmSsNoQNT6/bO/1ZdwoW6cuNLb8ZZ09fy7RwDcHGq+XyZyewDM/bjWHJn7hBlsxCN3vcBw1EpneWGfAEeNWkKakZoZE+cqpiFGsmPeyaVbM+zQt4YxRZHFUyq25llhIje+HBp/Dz4xury/yDn815LvDC4VF1ukIKzlI8YQ== 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/amd/* files to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin Acked-by: David Rientjes --- drivers/iommu/amd/amd_iommu.h | 8 --- drivers/iommu/amd/init.c | 91 ++++++++++++++----------------- drivers/iommu/amd/io_pgtable.c | 13 +++-- drivers/iommu/amd/io_pgtable_v2.c | 20 +++---- drivers/iommu/amd/iommu.c | 13 +++-- 5 files changed, 64 insertions(+), 81 deletions(-) diff --git a/drivers/iommu/amd/amd_iommu.h b/drivers/iommu/amd/amd_iommu.h index 86be1edd50ee..bf697d566e0b 100644 --- a/drivers/iommu/amd/amd_iommu.h +++ b/drivers/iommu/amd/amd_iommu.h @@ -136,14 +136,6 @@ static inline int get_pci_sbdf_id(struct pci_dev *pdev) return PCI_SEG_DEVID_TO_SBDF(seg, devid); } -static inline void *alloc_pgtable_page(int nid, gfp_t gfp) -{ - struct page *page; - - page = alloc_pages_node(nid, gfp | __GFP_ZERO, 0); - return page ? page_address(page) : NULL; -} - bool translation_pre_enabled(struct amd_iommu *iommu); bool amd_iommu_is_attach_deferred(struct device *dev); int __init add_special_device(u8 type, u8 id, u32 *devid, bool cmd_line); diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c index 64bcf3df37ee..5b8a80fc7e50 100644 --- a/drivers/iommu/amd/init.c +++ b/drivers/iommu/amd/init.c @@ -35,6 +35,7 @@ #include "amd_iommu.h" #include "../irq_remapping.h" +#include "../iommu-pages.h" /* * definitions for the ACPI scanning code @@ -648,8 +649,8 @@ static int __init find_last_devid_acpi(struct acpi_table_header *table, u16 pci_ /* Allocate per PCI segment device table */ static inline int __init alloc_dev_table(struct amd_iommu_pci_seg *pci_seg) { - pci_seg->dev_table = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO | GFP_DMA32, - get_order(pci_seg->dev_table_size)); + pci_seg->dev_table = iommu_alloc_pages(GFP_KERNEL | GFP_DMA32, + get_order(pci_seg->dev_table_size)); if (!pci_seg->dev_table) return -ENOMEM; @@ -658,17 +659,16 @@ static inline int __init alloc_dev_table(struct amd_iommu_pci_seg *pci_seg) static inline void free_dev_table(struct amd_iommu_pci_seg *pci_seg) { - free_pages((unsigned long)pci_seg->dev_table, - get_order(pci_seg->dev_table_size)); + iommu_free_pages(pci_seg->dev_table, + get_order(pci_seg->dev_table_size)); pci_seg->dev_table = NULL; } /* Allocate per PCI segment IOMMU rlookup table. */ static inline int __init alloc_rlookup_table(struct amd_iommu_pci_seg *pci_seg) { - pci_seg->rlookup_table = (void *)__get_free_pages( - GFP_KERNEL | __GFP_ZERO, - get_order(pci_seg->rlookup_table_size)); + pci_seg->rlookup_table = iommu_alloc_pages(GFP_KERNEL, + get_order(pci_seg->rlookup_table_size)); if (pci_seg->rlookup_table == NULL) return -ENOMEM; @@ -677,16 +677,15 @@ static inline int __init alloc_rlookup_table(struct amd_iommu_pci_seg *pci_seg) static inline void free_rlookup_table(struct amd_iommu_pci_seg *pci_seg) { - free_pages((unsigned long)pci_seg->rlookup_table, - get_order(pci_seg->rlookup_table_size)); + iommu_free_pages(pci_seg->rlookup_table, + get_order(pci_seg->rlookup_table_size)); pci_seg->rlookup_table = NULL; } static inline int __init alloc_irq_lookup_table(struct amd_iommu_pci_seg *pci_seg) { - pci_seg->irq_lookup_table = (void *)__get_free_pages( - GFP_KERNEL | __GFP_ZERO, - get_order(pci_seg->rlookup_table_size)); + pci_seg->irq_lookup_table = iommu_alloc_pages(GFP_KERNEL, + get_order(pci_seg->rlookup_table_size)); kmemleak_alloc(pci_seg->irq_lookup_table, pci_seg->rlookup_table_size, 1, GFP_KERNEL); if (pci_seg->irq_lookup_table == NULL) @@ -698,8 +697,8 @@ static inline int __init alloc_irq_lookup_table(struct amd_iommu_pci_seg *pci_se static inline void free_irq_lookup_table(struct amd_iommu_pci_seg *pci_seg) { kmemleak_free(pci_seg->irq_lookup_table); - free_pages((unsigned long)pci_seg->irq_lookup_table, - get_order(pci_seg->rlookup_table_size)); + iommu_free_pages(pci_seg->irq_lookup_table, + get_order(pci_seg->rlookup_table_size)); pci_seg->irq_lookup_table = NULL; } @@ -707,8 +706,8 @@ static int __init alloc_alias_table(struct amd_iommu_pci_seg *pci_seg) { int i; - pci_seg->alias_table = (void *)__get_free_pages(GFP_KERNEL, - get_order(pci_seg->alias_table_size)); + pci_seg->alias_table = iommu_alloc_pages(GFP_KERNEL, + get_order(pci_seg->alias_table_size)); if (!pci_seg->alias_table) return -ENOMEM; @@ -723,8 +722,8 @@ static int __init alloc_alias_table(struct amd_iommu_pci_seg *pci_seg) static void __init free_alias_table(struct amd_iommu_pci_seg *pci_seg) { - free_pages((unsigned long)pci_seg->alias_table, - get_order(pci_seg->alias_table_size)); + iommu_free_pages(pci_seg->alias_table, + get_order(pci_seg->alias_table_size)); pci_seg->alias_table = NULL; } @@ -735,8 +734,8 @@ static void __init free_alias_table(struct amd_iommu_pci_seg *pci_seg) */ static int __init alloc_command_buffer(struct amd_iommu *iommu) { - iommu->cmd_buf = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, - get_order(CMD_BUFFER_SIZE)); + iommu->cmd_buf = iommu_alloc_pages(GFP_KERNEL, + get_order(CMD_BUFFER_SIZE)); return iommu->cmd_buf ? 0 : -ENOMEM; } @@ -844,19 +843,19 @@ static void iommu_disable_command_buffer(struct amd_iommu *iommu) static void __init free_command_buffer(struct amd_iommu *iommu) { - free_pages((unsigned long)iommu->cmd_buf, get_order(CMD_BUFFER_SIZE)); + iommu_free_pages(iommu->cmd_buf, get_order(CMD_BUFFER_SIZE)); } static void *__init iommu_alloc_4k_pages(struct amd_iommu *iommu, gfp_t gfp, size_t size) { int order = get_order(size); - void *buf = (void *)__get_free_pages(gfp, order); + void *buf = iommu_alloc_pages(gfp, order); if (buf && check_feature(FEATURE_SNP) && set_memory_4k((unsigned long)buf, (1 << order))) { - free_pages((unsigned long)buf, order); + iommu_free_pages(buf, order); buf = NULL; } @@ -866,7 +865,7 @@ static void *__init iommu_alloc_4k_pages(struct amd_iommu *iommu, /* allocates the memory where the IOMMU will log its events to */ static int __init alloc_event_buffer(struct amd_iommu *iommu) { - iommu->evt_buf = iommu_alloc_4k_pages(iommu, GFP_KERNEL | __GFP_ZERO, + iommu->evt_buf = iommu_alloc_4k_pages(iommu, GFP_KERNEL, EVT_BUFFER_SIZE); return iommu->evt_buf ? 0 : -ENOMEM; @@ -900,14 +899,13 @@ static void iommu_disable_event_buffer(struct amd_iommu *iommu) static void __init free_event_buffer(struct amd_iommu *iommu) { - free_pages((unsigned long)iommu->evt_buf, get_order(EVT_BUFFER_SIZE)); + iommu_free_pages(iommu->evt_buf, get_order(EVT_BUFFER_SIZE)); } /* allocates the memory where the IOMMU will log its events to */ static int __init alloc_ppr_log(struct amd_iommu *iommu) { - iommu->ppr_log = iommu_alloc_4k_pages(iommu, GFP_KERNEL | __GFP_ZERO, - PPR_LOG_SIZE); + iommu->ppr_log = iommu_alloc_4k_pages(iommu, GFP_KERNEL, PPR_LOG_SIZE); return iommu->ppr_log ? 0 : -ENOMEM; } @@ -936,14 +934,14 @@ static void iommu_enable_ppr_log(struct amd_iommu *iommu) static void __init free_ppr_log(struct amd_iommu *iommu) { - free_pages((unsigned long)iommu->ppr_log, get_order(PPR_LOG_SIZE)); + iommu_free_pages(iommu->ppr_log, get_order(PPR_LOG_SIZE)); } static void free_ga_log(struct amd_iommu *iommu) { #ifdef CONFIG_IRQ_REMAP - free_pages((unsigned long)iommu->ga_log, get_order(GA_LOG_SIZE)); - free_pages((unsigned long)iommu->ga_log_tail, get_order(8)); + iommu_free_pages(iommu->ga_log, get_order(GA_LOG_SIZE)); + iommu_free_pages(iommu->ga_log_tail, get_order(8)); #endif } @@ -988,13 +986,11 @@ static int iommu_init_ga_log(struct amd_iommu *iommu) if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir)) return 0; - iommu->ga_log = (u8 *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, - get_order(GA_LOG_SIZE)); + iommu->ga_log = iommu_alloc_pages(GFP_KERNEL, get_order(GA_LOG_SIZE)); if (!iommu->ga_log) goto err_out; - iommu->ga_log_tail = (u8 *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, - get_order(8)); + iommu->ga_log_tail = iommu_alloc_pages(GFP_KERNEL, get_order(8)); if (!iommu->ga_log_tail) goto err_out; @@ -1007,7 +1003,7 @@ static int iommu_init_ga_log(struct amd_iommu *iommu) static int __init alloc_cwwb_sem(struct amd_iommu *iommu) { - iommu->cmd_sem = iommu_alloc_4k_pages(iommu, GFP_KERNEL | __GFP_ZERO, 1); + iommu->cmd_sem = iommu_alloc_4k_pages(iommu, GFP_KERNEL, 1); return iommu->cmd_sem ? 0 : -ENOMEM; } @@ -1015,7 +1011,7 @@ static int __init alloc_cwwb_sem(struct amd_iommu *iommu) static void __init free_cwwb_sem(struct amd_iommu *iommu) { if (iommu->cmd_sem) - free_page((unsigned long)iommu->cmd_sem); + iommu_free_page((void *)iommu->cmd_sem); } static void iommu_enable_xt(struct amd_iommu *iommu) @@ -1080,7 +1076,6 @@ static bool __copy_device_table(struct amd_iommu *iommu) u32 lo, hi, devid, old_devtb_size; phys_addr_t old_devtb_phys; u16 dom_id, dte_v, irq_v; - gfp_t gfp_flag; u64 tmp; /* Each IOMMU use separate device table with the same size */ @@ -1114,9 +1109,8 @@ static bool __copy_device_table(struct amd_iommu *iommu) if (!old_devtb) return false; - gfp_flag = GFP_KERNEL | __GFP_ZERO | GFP_DMA32; - pci_seg->old_dev_tbl_cpy = (void *)__get_free_pages(gfp_flag, - get_order(pci_seg->dev_table_size)); + pci_seg->old_dev_tbl_cpy = iommu_alloc_pages(GFP_KERNEL | GFP_DMA32, + get_order(pci_seg->dev_table_size)); if (pci_seg->old_dev_tbl_cpy == NULL) { pr_err("Failed to allocate memory for copying old device table!\n"); memunmap(old_devtb); @@ -2800,8 +2794,8 @@ static void early_enable_iommus(void) for_each_pci_segment(pci_seg) { if (pci_seg->old_dev_tbl_cpy != NULL) { - free_pages((unsigned long)pci_seg->old_dev_tbl_cpy, - get_order(pci_seg->dev_table_size)); + iommu_free_pages(pci_seg->old_dev_tbl_cpy, + get_order(pci_seg->dev_table_size)); pci_seg->old_dev_tbl_cpy = NULL; } } @@ -2814,8 +2808,8 @@ static void early_enable_iommus(void) pr_info("Copied DEV table from previous kernel.\n"); for_each_pci_segment(pci_seg) { - free_pages((unsigned long)pci_seg->dev_table, - get_order(pci_seg->dev_table_size)); + iommu_free_pages(pci_seg->dev_table, + get_order(pci_seg->dev_table_size)); pci_seg->dev_table = pci_seg->old_dev_tbl_cpy; } @@ -3018,8 +3012,8 @@ static bool __init check_ioapic_information(void) static void __init free_dma_resources(void) { - free_pages((unsigned long)amd_iommu_pd_alloc_bitmap, - get_order(MAX_DOMAIN_ID/8)); + iommu_free_pages(amd_iommu_pd_alloc_bitmap, + get_order(MAX_DOMAIN_ID / 8)); amd_iommu_pd_alloc_bitmap = NULL; free_unity_maps(); @@ -3091,9 +3085,8 @@ static int __init early_amd_iommu_init(void) /* Device table - directly used by all IOMMUs */ ret = -ENOMEM; - amd_iommu_pd_alloc_bitmap = (void *)__get_free_pages( - GFP_KERNEL | __GFP_ZERO, - get_order(MAX_DOMAIN_ID/8)); + amd_iommu_pd_alloc_bitmap = iommu_alloc_pages(GFP_KERNEL, + get_order(MAX_DOMAIN_ID / 8)); if (amd_iommu_pd_alloc_bitmap == NULL) goto out; diff --git a/drivers/iommu/amd/io_pgtable.c b/drivers/iommu/amd/io_pgtable.c index 6c0621f6f572..f8b7d4c39a9f 100644 --- a/drivers/iommu/amd/io_pgtable.c +++ b/drivers/iommu/amd/io_pgtable.c @@ -22,6 +22,7 @@ #include "amd_iommu_types.h" #include "amd_iommu.h" +#include "../iommu-pages.h" static void v1_tlb_flush_all(void *cookie) { @@ -156,7 +157,7 @@ static bool increase_address_space(struct protection_domain *domain, bool ret = true; u64 *pte; - pte = alloc_pgtable_page(domain->nid, gfp); + pte = iommu_alloc_page_node(domain->nid, gfp); if (!pte) return false; @@ -187,7 +188,7 @@ static bool increase_address_space(struct protection_domain *domain, out: spin_unlock_irqrestore(&domain->lock, flags); - free_page((unsigned long)pte); + iommu_free_page(pte); return ret; } @@ -250,7 +251,7 @@ static u64 *alloc_pte(struct protection_domain *domain, if (!IOMMU_PTE_PRESENT(__pte) || pte_level == PAGE_MODE_NONE) { - page = alloc_pgtable_page(domain->nid, gfp); + page = iommu_alloc_page_node(domain->nid, gfp); if (!page) return NULL; @@ -259,7 +260,7 @@ static u64 *alloc_pte(struct protection_domain *domain, /* pte could have been changed somewhere. */ if (!try_cmpxchg64(pte, &__pte, __npte)) - free_page((unsigned long)page); + iommu_free_page(page); else if (IOMMU_PTE_PRESENT(__pte)) *updated = true; @@ -430,7 +431,7 @@ static int iommu_v1_map_pages(struct io_pgtable_ops *ops, unsigned long iova, } /* Everything flushed out, free pages now */ - put_pages_list(&freelist); + iommu_free_pages_list(&freelist); return ret; } @@ -579,7 +580,7 @@ static void v1_free_pgtable(struct io_pgtable *iop) /* Make changes visible to IOMMUs */ amd_iommu_domain_update(dom); - put_pages_list(&freelist); + iommu_free_pages_list(&freelist); } static struct io_pgtable *v1_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie) diff --git a/drivers/iommu/amd/io_pgtable_v2.c b/drivers/iommu/amd/io_pgtable_v2.c index f818a7e254d4..1e08dab93686 100644 --- a/drivers/iommu/amd/io_pgtable_v2.c +++ b/drivers/iommu/amd/io_pgtable_v2.c @@ -18,6 +18,7 @@ #include "amd_iommu_types.h" #include "amd_iommu.h" +#include "../iommu-pages.h" #define IOMMU_PAGE_PRESENT BIT_ULL(0) /* Is present */ #define IOMMU_PAGE_RW BIT_ULL(1) /* Writeable */ @@ -99,11 +100,6 @@ static inline int page_size_to_level(u64 pg_size) return PAGE_MODE_1_LEVEL; } -static inline void free_pgtable_page(u64 *pt) -{ - free_page((unsigned long)pt); -} - static void free_pgtable(u64 *pt, int level) { u64 *p; @@ -125,10 +121,10 @@ static void free_pgtable(u64 *pt, int level) if (level > 2) free_pgtable(p, level - 1); else - free_pgtable_page(p); + iommu_free_page(p); } - free_pgtable_page(pt); + iommu_free_page(pt); } /* Allocate page table */ @@ -156,14 +152,14 @@ static u64 *v2_alloc_pte(int nid, u64 *pgd, unsigned long iova, } if (!IOMMU_PTE_PRESENT(__pte)) { - page = alloc_pgtable_page(nid, gfp); + page = iommu_alloc_page_node(nid, gfp); if (!page) return NULL; __npte = set_pgtable_attr(page); /* pte could have been changed somewhere. */ if (cmpxchg64(pte, __pte, __npte) != __pte) - free_pgtable_page(page); + iommu_free_page(page); else if (IOMMU_PTE_PRESENT(__pte)) *updated = true; @@ -185,7 +181,7 @@ static u64 *v2_alloc_pte(int nid, u64 *pgd, unsigned long iova, if (pg_size == IOMMU_PAGE_SIZE_1G) free_pgtable(__pte, end_level - 1); else if (pg_size == IOMMU_PAGE_SIZE_2M) - free_pgtable_page(__pte); + iommu_free_page(__pte); } return pte; @@ -380,7 +376,7 @@ static struct io_pgtable *v2_alloc_pgtable(struct io_pgtable_cfg *cfg, void *coo int ret; int ias = IOMMU_IN_ADDR_BIT_SIZE; - pgtable->pgd = alloc_pgtable_page(pdom->nid, GFP_ATOMIC); + pgtable->pgd = iommu_alloc_page_node(pdom->nid, GFP_ATOMIC); if (!pgtable->pgd) return NULL; @@ -403,7 +399,7 @@ static struct io_pgtable *v2_alloc_pgtable(struct io_pgtable_cfg *cfg, void *coo return &pgtable->iop; err_free_pgd: - free_pgtable_page(pgtable->pgd); + iommu_free_page(pgtable->pgd); return NULL; } diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index fcc987f5d4ed..9a228a95da0e 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -42,6 +42,7 @@ #include "amd_iommu.h" #include "../dma-iommu.h" #include "../irq_remapping.h" +#include "../iommu-pages.h" #define CMD_SET_TYPE(cmd, t) ((cmd)->data[1] |= ((t) << 28)) @@ -1642,7 +1643,7 @@ static void free_gcr3_tbl_level1(u64 *tbl) ptr = iommu_phys_to_virt(tbl[i] & PAGE_MASK); - free_page((unsigned long)ptr); + iommu_free_page(ptr); } } @@ -1670,7 +1671,7 @@ static void free_gcr3_table(struct protection_domain *domain) else BUG_ON(domain->glx != 0); - free_page((unsigned long)domain->gcr3_tbl); + iommu_free_page(domain->gcr3_tbl); } /* @@ -1697,7 +1698,7 @@ static int setup_gcr3_table(struct protection_domain *domain, int pasids) if (levels > amd_iommu_max_glx_val) return -EINVAL; - domain->gcr3_tbl = alloc_pgtable_page(domain->nid, GFP_ATOMIC); + domain->gcr3_tbl = iommu_alloc_page_node(domain->nid, GFP_ATOMIC); if (domain->gcr3_tbl == NULL) return -ENOMEM; @@ -2092,7 +2093,7 @@ static void protection_domain_free(struct protection_domain *domain) free_gcr3_table(domain); if (domain->iop.root) - free_page((unsigned long)domain->iop.root); + iommu_free_page(domain->iop.root); if (domain->id) domain_id_free(domain->id); @@ -2107,7 +2108,7 @@ static int protection_domain_init_v1(struct protection_domain *domain, int mode) BUG_ON(mode < PAGE_MODE_NONE || mode > PAGE_MODE_6_LEVEL); if (mode != PAGE_MODE_NONE) { - pt_root = (void *)get_zeroed_page(GFP_KERNEL); + pt_root = iommu_alloc_page(GFP_KERNEL); if (!pt_root) return -ENOMEM; } @@ -2783,7 +2784,7 @@ static u64 *__get_gcr3_pte(u64 *root, int level, u32 pasid, bool alloc) if (!alloc) return NULL; - root = (void *)get_zeroed_page(GFP_ATOMIC); + root = iommu_alloc_page(GFP_ATOMIC); if (root == NULL) return NULL; From patchwork Thu Nov 30 20:14:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13475015 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 60924C07CA9 for ; Thu, 30 Nov 2023 20:15:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CD9566B049A; Thu, 30 Nov 2023 15:15:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C61756B049B; Thu, 30 Nov 2023 15:15:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A8A5F6B049C; Thu, 30 Nov 2023 15:15:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 962AC6B049A for ; Thu, 30 Nov 2023 15:15:13 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6633F12030E for ; Thu, 30 Nov 2023 20:15:13 +0000 (UTC) X-FDA: 81515724906.22.23C150D Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) by imf08.hostedemail.com (Postfix) with ESMTP id 947BD16000B for ; Thu, 30 Nov 2023 20:15:11 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=TMKUh94h; dmarc=none; spf=pass (imf08.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.210.54 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=1701375311; 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=agdpEgslqhHdhrn0hnWdDpIJa9Hen54IbPQiTYhpn3E=; b=gAu3ME1g5ogJ06QuuU5UCXdCg48thfHuUrER6Qw+JpOum5hZ1DmaKiWtmjbdLmV7PSnFG8 EvZWfH9s7hhARD+iQzoSOcYO7CjoQP4vaLBYp4VpT1BqzeFtB8aKVmV29fT0pmaikIsQuB AeXep4jd8khCRpUTBVwft93dHCl+74E= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=TMKUh94h; dmarc=none; spf=pass (imf08.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.210.54 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701375311; a=rsa-sha256; cv=none; b=dsOh4eU1fH3NQQkG9yct0vB4IajGYemY3b6+C/LKJTSN6C4SD/vhSH9wd0r6uqDWy0Y4t2 TLZVcNeokLHci2RXLMHYeN8Q7/FcKH3bYZulWyTbNPCCIXlMdxz+qBX7aYi9f7dttjrxNW jtDh3MscQg5JEs9W+eiTReYFBF9jSEM= Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-6ce2eaf7c2bso872846a34.0 for ; Thu, 30 Nov 2023 12:15:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701375310; x=1701980110; 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=agdpEgslqhHdhrn0hnWdDpIJa9Hen54IbPQiTYhpn3E=; b=TMKUh94h/vE5YhFrr3I+P76I1bkILkw3O4flsqrZwYdsEvoGMQjB80uNag/7L8fGoP nt7Wxha4ezhLTzE6HlhAsuIsdytuE+mPUiEyIryvcW1fL6Q4kVG+qOV3zIImj4N1KKrN uWs/tbKu0A/J1daqsMhv+oh2Wufkmz54/qGs6wOnyi0zPkcH2S2vTzVgOvOM376Vxxtp vzLSumvlRhxCEI2nzfvTuxgExUcZuFOJPLfNECdC2juydF5zzPGkH/xFX6Hi7u0V3wvi KKhNcQ3G4XFn8d7sYlcdwcr5JZOJvZv8cmgGdE5sGCca2fVFxRAvVlluTs9rm1Y85hk5 KWZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701375310; x=1701980110; 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=agdpEgslqhHdhrn0hnWdDpIJa9Hen54IbPQiTYhpn3E=; b=vpF03co1MRdQGtsNJ1J4KwaPhoKqYaCJg9nk5QJQ4dnFBju0ZnxKl4Wl0HUvOcYi0g v9znqwWHgMeuUNcapF+ujRhSqDl8l/Wta04ogTsCCVV9dL46a9h1B/vKEfTzQeRTdDYz hPGLgxS3EiCDEA+tzMlTBgP92XScOIlq2rta92+OP7/SvM3DLSXA3DbmAbuF+Q8irjgd Uf/qz9MmtrluX8BGQ7PJLVObbTwuun4NL4NseJX1Dj0r4RaoxFr+2vGqdPu/J3qs9ot1 OQN30782JBrwBL/17D4opCT1YxsdoyMJfDIfn+9w/h26flC0VtZwnUpHX+Rvguh6wwa3 WhvQ== X-Gm-Message-State: AOJu0Yz5envXVpV/JEHEEPXZNFvRgFqdl884dcJaqhiR7lNBgobe4D6o Nk/iyCGdw4dPJy4tL7/oRlHV6A== X-Google-Smtp-Source: AGHT+IGqd1nCfT5mpKZHzFpkRZAyFydlrTR6nVwlbdpa33SL4CJzD0tuFZYwet7aKrGY42Lko6YVCg== X-Received: by 2002:a05:6830:2644:b0:6d5:11f6:eec7 with SMTP id f4-20020a056830264400b006d511f6eec7mr794143otu.28.1701375310765; Thu, 30 Nov 2023 12:15:10 -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 e1-20020a0cb441000000b0067a35608186sm795252qvf.28.2023.11.30.12.15.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:15:10 -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 Subject: [PATCH v2 03/10] iommu/io-pgtable-arm: use page allocation function provided by iommu-pages.h Date: Thu, 30 Nov 2023 20:14:57 +0000 Message-ID: <20231130201504.2322355-4-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231130201504.2322355-1-pasha.tatashin@soleen.com> References: <20231130201504.2322355-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 947BD16000B X-Stat-Signature: y37e5awgikag4o5utmhdgcrtheps7t7m X-HE-Tag: 1701375311-198244 X-HE-Meta: U2FsdGVkX1/dGuNyBQHVoSo1M+bd3nVyc/RNsi8iTfkeNEUs7UWz57WG14D3G9q3hyA44lkrrDbJmV8ilWyF4YqcACttkd2G1/Inpoidfi/kTEIIRAW+SpbhT3hzEDxEw7yjnf5V7GAM/t3NyGUkEyz6cMWuW156yG3IwhUGLvj70Y4WwxjBn0TXfVzLFWjXsOESnaxXS3OWryvNZ+UvcwYnyl9aFrVjMr4wTS7KoqTjBEccmxXtdtHQGV87x3Hwytw3V7IT+4Yn7Jt7y0+62wfnYqwB+hY4taGGs0x6Xv/gI8MvqcHRVrPSzYLObqCyGE1XcZusK3gmA/Z5kUSTaTInTT0Heox9facKkqHYyht1+D4bRRNlI8yKjFNyVA9TkCd33qFW9nNwmDL4V8EDV7sqcosxB09hKCZmYjt5uhmBxcVApit9wPwknYc7RV0H0XGSiz4bca5EFEe5UsAwhlP5rlYbVgYu30WxRzG58ecwHZoM/cv8FtwO0TzTq74kMgU6/j2eiTNG6fz/n0sbYw/ZIkjTiv/zBlpPiYM3pUgGrFxAdh1hiSVFwuQIXvX4r4z7JdYjKePaIHx4qY5oumIkomS7vbffPnyQ+VzQWkIfv/aPpPnB9+TWGjaqo5KAHTwFHCMta/HxTG2IDRuEKz/4/zEGewvOjRc+kQQxn5Ayew+Gt8VPDgv50r3d9VRAj0qXrW3H5BhC4wB2BNaVEGrS3iBw0y7UbpyRzM2VDl+Rm2EfDC2mnZP0nhaTp7pjS83F3OwtmPDKCsn8rOyOPgKMW/UL4fez9h+W0VxrQ8LiBqpXwP3v7g86/ivzsAk9x+9xfxJBdPHQMgWsCtC1OwE8xUkJGE7X/0jv9aDi5+V6XIWMp4oqfozR+/E0GgWehhkcqlieozN0JcYezgSS3Qhr/RBJF0VLuVpf4txkA9Xd3se+9WE488bMJGB2iqkaCqGgKs+mGhfDjtaejMu Bs4qc1zC gdZgwvP3LvfcxOSuPZ9lZW/e61CfBHHVsAtuBIs2At5VNi1G3oVg+pLdz1iC+8CXQIXsP/7cxcFvkgWpar1VXW0vumWObxRIhwGmYI6oK053CRfQX9SR1ASDjCrAn2O9fizd67HteYUa9DM7BLascMaSnJ4a+g/upaxjn3rs5qpolu+ewcqvUbQFY2hoqa6OOdjlsBP3PPrh7OqSRMX4wT4OPXjifot5sWktj+MN82TfxkeV2S7LcAsYNUQZWjBYPy8QBXKPuLQiEmKqBEG6iR2PbW21ZjNOV1yEoAC7vw6HVH0oZduQx7xsk1GcGA6DuEBOk1FRR8IXDK4G2mIohebTBmyJK/vaTWDueJtRuHKmAWCYHSuQsn20ZStJHmOvf/94CY0b4oBc+//A6NdrMPg8PFH9CnkXUpGQq2HIny9bPBPgupqPR6oxwK88S5+P4qA8JWBrR9KoIVTU/qW/a/+aBd3QsJ1mN6Sk6TpvXy1FBRO7RSuGoAzTPpPyJmms3aRh4Tq88h8f+N5NyumJwbDd7fw== 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-arm.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin Acked-by: David Rientjes --- drivers/iommu/io-pgtable-arm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index 72dcdd468cf3..21d315151ad6 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -21,6 +21,7 @@ #include #include "io-pgtable-arm.h" +#include "iommu-pages.h" #define ARM_LPAE_MAX_ADDR_BITS 52 #define ARM_LPAE_S2_MAX_CONCAT_PAGES 16 @@ -197,7 +198,7 @@ static void *__arm_lpae_alloc_pages(size_t size, gfp_t gfp, void *pages; VM_BUG_ON((gfp & __GFP_HIGHMEM)); - p = alloc_pages_node(dev_to_node(dev), gfp | __GFP_ZERO, order); + p = __iommu_alloc_pages_node(dev_to_node(dev), gfp, order); if (!p) return NULL; @@ -221,7 +222,7 @@ static void *__arm_lpae_alloc_pages(size_t size, gfp_t gfp, dev_err(dev, "Cannot accommodate DMA translation for IOMMU page tables\n"); dma_unmap_single(dev, dma, size, DMA_TO_DEVICE); out_free: - __free_pages(p, order); + __iommu_free_pages(p, order); return NULL; } @@ -231,7 +232,7 @@ static void __arm_lpae_free_pages(void *pages, size_t size, if (!cfg->coherent_walk) dma_unmap_single(cfg->iommu_dev, __arm_lpae_dma_addr(pages), size, DMA_TO_DEVICE); - free_pages((unsigned long)pages, get_order(size)); + iommu_free_pages(pages, get_order(size)); } static void __arm_lpae_sync_pte(arm_lpae_iopte *ptep, int num_entries, From patchwork Thu Nov 30 20:14:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13475016 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 02C78C07CA9 for ; Thu, 30 Nov 2023 20:15:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC6976B049C; Thu, 30 Nov 2023 15:15:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B5A6F6B049D; Thu, 30 Nov 2023 15:15:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 952476B049E; Thu, 30 Nov 2023 15:15:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7867E6B049C for ; Thu, 30 Nov 2023 15:15:14 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 57AC1140313 for ; Thu, 30 Nov 2023 20:15:14 +0000 (UTC) X-FDA: 81515724948.10.637C42A Received: from mail-oo1-f43.google.com (mail-oo1-f43.google.com [209.85.161.43]) by imf01.hostedemail.com (Postfix) with ESMTP id 9660A40006 for ; Thu, 30 Nov 2023 20:15:12 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=NNA2UTJI; dmarc=none; spf=pass (imf01.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.161.43 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=1701375312; 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=yfTdzFG6SHCh2UHnxot++MviNj2L80bFYdKeG3yhIm0=; b=7OBCdkidfIwOxvPkqayF01o3zk37nfHSjtfNvFUo5rcwuYLq1eM0XxiaAHYQJyCLOgCQAb P04IUps7eTCqc3bDJmpUmHEefqL/4HL1Ufx4JmNyIqNmAHtB8qiJMv9yFGtQXHgIZ0QmXI ElZ7CQAS/+bPHiSpchg8F0gVljwokZs= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=NNA2UTJI; dmarc=none; spf=pass (imf01.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.161.43 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701375312; a=rsa-sha256; cv=none; b=puNuihe6o5C4u1oophkulc4uoMCFFfj+hFawV7jbpCVzgsDFH46p+jj4mKZ90hTnJmG+ur WqHY016VvRVlzkQeQxfo6v37fKbBsohGFZKEtHeZg9hdt3/V3xPV6iVemjliDWwuhTZSUe qlwRxQP3kIN7KQi9WReVONO3ycssxZo= Received: by mail-oo1-f43.google.com with SMTP id 006d021491bc7-58ceab7daddso698029eaf.3 for ; Thu, 30 Nov 2023 12:15:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701375311; x=1701980111; 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=yfTdzFG6SHCh2UHnxot++MviNj2L80bFYdKeG3yhIm0=; b=NNA2UTJIC9H719SihmmwVST9bjB3PCMP44pbT/Sk9khvW56pKW+UxGfip4POEqh7ep LX9AOKlRa+XV3NvPkElxXsTPLpmLSR2FpwlzQrVPUKOsn0RIO1uGXXqEsHSpfyjZCZDg oushfEAGXo6kfVegvSTqVg8qaKUlf/KkNMZCiygDfOQq/B25rf1ZLSKj9o5FGiA/ziHc ebCWahkkDbFZiDw8dc/fu4UT9JR1IMm5AVXiYDEPkNsX+wsBQryU5l1qa9qwAdaL3tNe XIVX3N+HeSkRunqMD8k0siwowdJ/aWWky92tS8jea4BNpeoxZ+EwULbqI+jnogq15a7b /3ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701375311; x=1701980111; 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=yfTdzFG6SHCh2UHnxot++MviNj2L80bFYdKeG3yhIm0=; b=Iz9OelkpAZgLj0E/IZQodXt5oWuLu4YZqQ6dpvP6P6+xActJn5Yky8xvW9l2PpjbGz fj7isO7Z509qrzE054Ktk5+oeuX4YjuPz7AYTKAlZ/KR9M64F9L+/wOQjpGAHStWrv9J MxZkY72YAxykIM+hXZw29+NAsat8gBPzBHE2yiX+ZJJp7PjX9wl2lVuD/G7apQ3+MVQ+ PZ/jOcGvlPFkn1nVHJOOfSaORS7zmQqXlQsygiRCBqNGIKXd0e+FRz/y7Z99Mjen++ZT e+LqDncgQxvZd7GScy6M06NZ2bBlcVswyeHnk7etS7s0N10it9D7IEMzXnestNI443Oa vU/Q== X-Gm-Message-State: AOJu0Yy6P5//oejG6UYMohJZ2pgmPvpHR2Bz3l43MuuFroQNLhCsOeP3 Cc7b5qanbaTDmAGqVpqADzCXXA== X-Google-Smtp-Source: AGHT+IFMEwE+ifBtQCWWH8W7nWxbE36GDcNl4TH5XHATcaDXANsvzTlHeJN6S0z8EPAHXXipNQHPnA== X-Received: by 2002:a05:6870:41cd:b0:1fa:c97:220a with SMTP id z13-20020a05687041cd00b001fa0c97220amr24204427oac.10.1701375311601; Thu, 30 Nov 2023 12:15:11 -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 e1-20020a0cb441000000b0067a35608186sm795252qvf.28.2023.11.30.12.15.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:15: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 Subject: [PATCH v2 04/10] iommu/io-pgtable-dart: use page allocation function provided by iommu-pages.h Date: Thu, 30 Nov 2023 20:14:58 +0000 Message-ID: <20231130201504.2322355-5-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231130201504.2322355-1-pasha.tatashin@soleen.com> References: <20231130201504.2322355-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 9660A40006 X-Stat-Signature: o66qoewgzn3hgmnaa3bw97egqohstg8a X-Rspam-User: X-HE-Tag: 1701375312-647552 X-HE-Meta: U2FsdGVkX188RzeF9JDnj2uMhVvE8LYJ0duB6GWXdah26fcHV4BGjf98FrQCJ4Ch4AKMO1e3lC+GBQ8KOM+0eNcwPuPrAlFdKmYKOGqxWSAwQ0kvlOwFZGSFUYuNsYcqgVJL8g7WPesyUS0Rnn5kJrcGTlDGHpDsNCHmdoGHubqkkR8hKUh8UWBPePHTCE3gi9ePfdv0V63mAdTER67yLOcsDjAQN6PqTP9SlhoH4Z5Kr30GjQEYu06e1gKSY2ioQCoV6yMnvR5I0xZznuMHaISl/dwxVJzsELeypsbGmKXOAg1AeYtbu3Hs8P/sNu/lGOOSpkoF0qcmtxBdRqhn80g4/Nfc+ykx6yMwFOxV6uVmpF9YSc1CpgrsqPBfDt0LMLaID9Hmnr9Uq9gzOme7eWiKKRssLm59j0vZhk9JKF3WEAEBmZFLlove6Pq+bmsaAaj2lhYfsHh5ObANgAiQH0f73nX6n3T0Nu/Cq0C3q7aeKJoJsN0loYdIt/uFXpKyCLaecVJ0sGvgAQl8xoNi6CnZkVm0rnUKAuK5Ep3Case6NFF6KZUMlTJGg2wy4Rtnd4KgCmbL4SL7ONb9ql6VBgst2KR8yqi6TOkXBR7jINvBk/NBlOhkLaMmT0sol7x9xu9paJwtJM16Vsgi9+OoM62eSeGuNC530DZcvyYC6i3Y2REc4a7WQT+C9SFP/NsGxXYiPWOzh+LdsRdiaxZHUkJYPlR8YOAr5VcfGevOiuG6HUpY8AmjvdgqabCnVxnEqcbxRf9G6T3gowGr7kiEEvXFMYO6pjSBuS/O0D8sFWP57l/8UU0eFAwcIl69hVGhtLfVq03bMusIgTb7aB+sVqkq/ZwReGpo5vDFzZaN79B6W76Y9LErbX8fb1I+b5BzcK61yRr1UBo3bPnL2+MzdmC4Z4nXMQzu8Q9wEmmD6Ki8lRn7xpHqgzz6aLCyAr8d8wsIx0GYMB/GQOBOmy0 Ysn9Xpft ZNkEVv1I6GjObWf7A0WxC/4KzEjcO6hnPPyFcI/G7zGM6j4UZBE73EfaEKxY8QLtd1JL2vDBlu0kCII3VFhcUQ9nXqggfWeR0l7MICNL75hkSisgEfE1EnH0fg2nHXvl3B2iywrIiPWsZtRdsSj47dU2mgCtSjoW1hci5bC7haUlEV9RGdq+aMFPTLQoV5wJO5EtTjIvWMoAPMN01bFKQ1NJneyHDALmITbUgXIaXpCBD8FcoPZ37SJ0qUvGrtaUnSJz3ulTnt8ZOWVO2ppaiqQCs01wYw4jNt/qUrHqDmqTeDQt2u4iXYol1/YIiGI0NKRPTkm/bhqVi/sskleAi89CTAUDOu7Mdds1JRxBqMt9j4K2fGrCrL32vzKBtkTbCl7VBrrw4D+x6lNWl1cLkrQE1l8ZCP4KcJ2zqpVEcNMhZ/fJVdkbN4AT2oLFzL4t9RGG11dEBb1SrYwtSH5LXQle3gOSuJXiox9bUiKnws+jBIp5eieBiPIvjbKz6e6bMsYFO 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. 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); From patchwork Thu Nov 30 20:14:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13475017 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 BBB5DC4167B for ; Thu, 30 Nov 2023 20:15:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B4F896B049D; Thu, 30 Nov 2023 15:15:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ADEEF6B049E; Thu, 30 Nov 2023 15:15:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92C6C6B049F; Thu, 30 Nov 2023 15:15:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7F4486B049D for ; Thu, 30 Nov 2023 15:15:15 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 52253160325 for ; Thu, 30 Nov 2023 20:15:15 +0000 (UTC) X-FDA: 81515724990.04.BEED5D6 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) by imf26.hostedemail.com (Postfix) with ESMTP id 65D84140008 for ; Thu, 30 Nov 2023 20:15:13 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=E6JM9IPs; spf=pass (imf26.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.178 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701375313; 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=jRGmXGqyJzQ9dzCxzy8J7vcwlH74KXpuX5+P/ckDUHQ=; b=lTe85jJWNLAzvw2g+shP83evX/xd2kGsvzFrmWOYLBlbpGJOhpRwwBhBNvDOvLmhqpQhTC 1z+Aq02x8si8JEvSdLpu7MROEZob9V60fZs7jgVEfmFWDDbzpsaK8cSdXqJhSmx0+gqew+ ktOECuGyKwvpMWxc25YRGsrnsNA3XMk= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=E6JM9IPs; spf=pass (imf26.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.178 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701375313; a=rsa-sha256; cv=none; b=vQEe1oDqWtjooRJiNYJ3kVSmWh8j3uDrq+5OHUNs0XBBAfmkQlhqbOFwYd6jMqoQ4mUIxa dfJWXuYUIaeWUUyrCrtyvASMfB5eucPyIVC4/BUKe5JpAnLbijCLNH+9+Kl0nKt92PG9Vi K52NVfm8Wk7IwMV/k9g87ZhHX9NrNuQ= Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-77db736aae5so66726185a.0 for ; Thu, 30 Nov 2023 12:15:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701375312; x=1701980112; 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=jRGmXGqyJzQ9dzCxzy8J7vcwlH74KXpuX5+P/ckDUHQ=; b=E6JM9IPstN6TwnBdlM0j8vBlHeAHXCr2wdgYSBs7NSd9zyNFHu7739msquKhM7GdlL 2Z72J357rlmxJ3IaaV0sde7ldQdrOBQn8SHnY63lBvAF5vkwCQzxPEtLPQz12pCbZz2B PqnulwN2dQeM9/LzgGULGb2si5F2TxKsz4+ZVAi9lKWRli+PMGenaZyHtHCPWKt0MDQo GRAc/8ZKmOvHh6YxP6ZawPADlL5mhV8tBpu/RggPxh2wcSxku9EQYdkJw1aUkb7r10Hl oJ5b6px4UZRmNUSTHAzRF1phex8YWh9LLotFqe6RcvwtB3MeTZGtK8prsguQQO/JpwSu VWgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701375312; x=1701980112; 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=jRGmXGqyJzQ9dzCxzy8J7vcwlH74KXpuX5+P/ckDUHQ=; b=dgW9BQRveXvGtMbC9CjcflicyHFOCpqoc/KnqDqWHlPYw9q0HtDrlPTdNnrxJ80faf QwWNiTN/ddkRP18JnH3ymF0DlquaNz3fICXlHOUFVcqK1LVogpgRQPkmu6K4XeFKInw6 5vyKTiA+OKOMgUV+0RTg4tGwBh9MOC8OGC092xolZAnmy1DEVqn0IZ74yLo7VJ5uJiXm JIdMqAQS/8nR5HzJo5nGQKT9A0lfAgwqDCkO3NJskeT5qa8XucuO8pOJzSrB/rZaFB9b m7fi2TgB3KRI6e5Twodp+gAh/Cq4oxUzBsSDkyIJ7w531dos4Gc5DkL/cX5/HLZXoh7T rJbA== X-Gm-Message-State: AOJu0YxwDQex8sPu70ZZ7XRMmLLO1AYRpgn4dOnch/nZKySx8n+0jpwU o96lgpMKcE91yaCN1rrp4DPOsA== X-Google-Smtp-Source: AGHT+IGcwSJfMg7Wvu1IirdGyJp85Q7AXnz+gps4Wsq6RDzrMQCHyomSRCyLZSC9k8WgNjE2V5K0wQ== X-Received: by 2002:a05:6214:2e11:b0:67a:93fa:b331 with SMTP id mx17-20020a0562142e1100b0067a93fab331mr288846qvb.6.1701375312521; Thu, 30 Nov 2023 12:15: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 e1-20020a0cb441000000b0067a35608186sm795252qvf.28.2023.11.30.12.15.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:15:12 -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 Subject: [PATCH v2 05/10] iommu/exynos: use page allocation function provided by iommu-pages.h Date: Thu, 30 Nov 2023 20:14:59 +0000 Message-ID: <20231130201504.2322355-6-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231130201504.2322355-1-pasha.tatashin@soleen.com> References: <20231130201504.2322355-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 65D84140008 X-Rspam-User: X-Stat-Signature: fjq3kiio7jytgb7dso1xqdmfcakxjick X-Rspamd-Server: rspam01 X-HE-Tag: 1701375313-469583 X-HE-Meta: U2FsdGVkX1+/Ui2Z1tMMbU32d1Vm6bA6OLa7dkAlxeldAhUbhVu2zTfFz3F214KUYRtycsq0A8GK4LBHHRMroUWZjyiWxjrXA5Uuj/DyoQsFdMS4t3+J+ddCqf066ezyVPijaetOpto3hgV1CGFl9BEaXmLL0BHhao+uSj4z5kjYTRt8fX9yluCyEhL3tKBvwn53ABMp1TXmrGHxmklcZ5Y+gNGl4DTPLe7uDRYG/PHgSXBohZ+T5jyVcVBtV9m4aQK2UQVNjCEV/BDHTDG7FGTiTQPRuCp7be4EgVQpO6E5qAVHSiMkJ8GrXadd04LBzsrR82X1sUlyRe1gr/mpbhHbFYv6HFcwI+d7XoHyEMtY1CFsfl4h/bXIyWoOIDDsqp5eWA0JI0zEpsFd6We00ULkDDrL31/Lzes3T2ux//pMPh07kZc/6hN1geHkH/9WCpX8T40jWl+1n8JiJreFqC8kFoViZydgVLH6ZNGtF6GL0qyIL2DlIcFH7ZD9DGJ3qo0vDsFWd9FnLFiLzBo3nitoU9hVhXn55oH3ICGs8xg3cce5QtLKC/gN59wBNwYc7WryvYUj+eQ1f9EQi+6YNUy6y0EquMVoZzV47M3NRkkaayVZpzz1bdXU0SM91p5hpfbq70j5/r2XYU6UHtyiiPCO+U0pyvG0dyvqKcLQm9fepSA/CGiynu2qi8FFP1D8ubRabqjFJyw/5Mn2lB0tJ+FjOdiRefgMBQIchXwUWEcN2SIDYe4CKcDgInjen+4a7oHr7/q8VOAu/XBVp0uJYlcBmIO3baaTx2OxaMvqv3Lztvwxp1lQHMu9ymVeovHP1krwR/FLi3Jg/fAvzxHHCE6kRnbA7VB1wxlGqEK53XN2srGhMbf+WgRkLG1YbfFalC4ngkDoMcxF5Wc2ZEgDuRYhoWxwFR187/CzdA81JKGHjEacdTfMJJh5T0ELD4zs4F7+IsGPYzcv5QGJdCJ rbofYw+Y XrV4olpQAtTop9N9M9w4Cb20bJFI2Qh8wrREDVtNDeOM0P2r0W2Qedc8B6zQLLXTxDkWw1j7UyMmuLOsOpfI88Hr9kyBaueYTCYnBWf3oxbZOpA8U0HddB4MbtwEh18edToTVlrsWxi4yIDMKe76yVygD2DB1ezTuwVt2aTMHA7cFl22fLjw6RlR1C1M2+T7+/RKKD4aaMFCUT7H6fSO+U3YNIct3XSasM6eSblSfKheTD9PuKPaI5/TYPjCurCa+t3wi/VTEjsXiirUsKMdf6Ai3V9bIy/FT0l4mTkepMHa70UvB8HMtgqjUq9oNUHODsMxQFdvA9FuiQQrxRmuh5fIlfMWz5+IL59OMZtEpdDcetZNcbZgiJxSh+uF8Tfc+LFyOiLJcy5RRYqntXmzW/946Q54hCL1X3quP4kVUG/qFneX12IT/Jyo34ZQQ012e8JHNK7miT1Uu7/A1CWPqzvMNI5C0eHvqJdtulir9INSpDJusPHe980WdvUJvF9Gn+addp8u3mtg/G8+YhMoWtcABhA== 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/exynos-iommu.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin Acked-by: David Rientjes --- drivers/iommu/exynos-iommu.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 2c6e9094f1e9..3eab0ae65a4f 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -22,6 +22,8 @@ #include #include +#include "iommu-pages.h" + typedef u32 sysmmu_iova_t; typedef u32 sysmmu_pte_t; static struct iommu_domain exynos_identity_domain; @@ -900,11 +902,11 @@ static struct iommu_domain *exynos_iommu_domain_alloc_paging(struct device *dev) if (!domain) return NULL; - domain->pgtable = (sysmmu_pte_t *)__get_free_pages(GFP_KERNEL, 2); + domain->pgtable = iommu_alloc_pages(GFP_KERNEL, 2); if (!domain->pgtable) goto err_pgtable; - domain->lv2entcnt = (short *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, 1); + domain->lv2entcnt = iommu_alloc_pages(GFP_KERNEL, 1); if (!domain->lv2entcnt) goto err_counter; @@ -930,9 +932,9 @@ static struct iommu_domain *exynos_iommu_domain_alloc_paging(struct device *dev) return &domain->domain; err_lv2ent: - free_pages((unsigned long)domain->lv2entcnt, 1); + iommu_free_pages(domain->lv2entcnt, 1); err_counter: - free_pages((unsigned long)domain->pgtable, 2); + iommu_free_pages(domain->pgtable, 2); err_pgtable: kfree(domain); return NULL; @@ -973,8 +975,8 @@ static void exynos_iommu_domain_free(struct iommu_domain *iommu_domain) phys_to_virt(base)); } - free_pages((unsigned long)domain->pgtable, 2); - free_pages((unsigned long)domain->lv2entcnt, 1); + iommu_free_pages(domain->pgtable, 2); + iommu_free_pages(domain->lv2entcnt, 1); kfree(domain); } From patchwork Thu Nov 30 20:15:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13475018 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 84E6DC46CA0 for ; Thu, 30 Nov 2023 20:15:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9550F6B049E; Thu, 30 Nov 2023 15:15:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9040F6B049F; Thu, 30 Nov 2023 15:15:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 77F616B04A0; Thu, 30 Nov 2023 15:15:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 607496B049E for ; Thu, 30 Nov 2023 15:15:16 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 3BF311C032E for ; Thu, 30 Nov 2023 20:15:16 +0000 (UTC) X-FDA: 81515725032.24.6DAE9B1 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) by imf20.hostedemail.com (Postfix) with ESMTP id 6480E1C0015 for ; Thu, 30 Nov 2023 20:15:14 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=a+ShOfy9; dmarc=none; spf=pass (imf20.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.47 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=1701375314; 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=8aM4P70fu6Mpyhz2ZxBL57luN308AqDDoR+bdvrzfCU=; b=nwTSEeycNxioJWGO5Ou5xVdZRKMeZ12rBzqY8SI5wB4AfBiIkPhg79BskK/RWXN/oaTztW wcaiN5Ii27JanaVbKTWmRRhXRvA7KlpKfN3UV4Ptt98qUTht9hlh7F2YfYYfriaUN2GY1G EyuBMWu+ZaDLogHJ9LbWZ5KEqUd0rJA= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=a+ShOfy9; dmarc=none; spf=pass (imf20.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.47 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701375314; a=rsa-sha256; cv=none; b=hMHJawtGUdHsX2IdKq6FlopqszYz6MqIC6Qvhlb+zvTrmxpMIgnUxoucXmePOCdALVX3ot Aj5sGpeGf5j6xK9H4qL2X/TAIfKE3ffb4j8jJ2HPwt7Wx2qXLni0KB7fJCQ/sCkO/Xqu0o u+ye6g8Fn05zDmQ9MnHmjNzE9AtK2SM= Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-67a18556e4aso8197266d6.1 for ; Thu, 30 Nov 2023 12:15:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701375313; x=1701980113; 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=8aM4P70fu6Mpyhz2ZxBL57luN308AqDDoR+bdvrzfCU=; b=a+ShOfy9Zgy1ghxCh1Mn4vvjMwqxes6xmMt4WRdvx+/oKN1Rq1yKcXXVdx3rFJCLk3 D179YAooTiEF3Y6DDYa1HMJVA6fWg0sI2Ktl/eKShqxQGnAU/XVbB+nEOtxXj92WdDzX scuUuwE28povZCL0cERGVB2fOLsJamENmqTQhQsfqY62TxolGsfGL60JHXUC7HKCe+Rh 6ljTM0fR6p87BA2UVLpO9339DO3Q5bB5QpgAPE995coEuGsLCIkPAMkHPco5hPoK282x 5vszonJgMCpOnInU3sUJRTHNO27JHnROrxtnQbGNcCsT1HDWY/KCCayRfKs0/gJS+++t QgOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701375313; x=1701980113; 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=8aM4P70fu6Mpyhz2ZxBL57luN308AqDDoR+bdvrzfCU=; b=XFp1soORCcv5QsFhEJ/e892gsMGgbFj9TT8l7LKBsTnVgQRnuhPZqgysJKdd/87Abv cOemI+WEDTt92PlJv0qPpHUPB15Nc/G3Uff4NsvUEM8xAb1a3I/vp0sySH0E5yuGSB6A 7I8Dr4P70j7gc0vgePcOXNonNewYxWOP/6EAb1CEYercaF6eyqw3PeQ2UZByCqG7asEb YN6QII9cAnZFjIXBsszLl2Ef//ko8zueftL2Oks70LwNwqlCYVvbokUxDPUa1J+UO9FF bjgZFFyxKmgzrkXSOuWflsJtyujnQK1/IiEgFjbt7D1KIbM/vHPREO0GHN6h6DXQO2C0 gwAA== X-Gm-Message-State: AOJu0YwoIeUp+oLpZOwgCwULAH1MmzCT/oimoQMgeJFWHUKlUXTBRWBJ WekcbUY9mqa5wWHweqDh52lX6A== X-Google-Smtp-Source: AGHT+IEBs6D/FyJYqfxI4mL3iV1h7OCPfLZXSrKHIqLtLdmOiu4XOIwm8bZeJ7cSdUFCvrQdbklyMg== X-Received: by 2002:a05:6214:5294:b0:67a:255c:c43f with SMTP id kj20-20020a056214529400b0067a255cc43fmr20595303qvb.18.1701375313540; Thu, 30 Nov 2023 12:15:13 -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 e1-20020a0cb441000000b0067a35608186sm795252qvf.28.2023.11.30.12.15.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:15:13 -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 Subject: [PATCH v2 06/10] iommu/rockchip: use page allocation function provided by iommu-pages.h Date: Thu, 30 Nov 2023 20:15:00 +0000 Message-ID: <20231130201504.2322355-7-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231130201504.2322355-1-pasha.tatashin@soleen.com> References: <20231130201504.2322355-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 6480E1C0015 X-Stat-Signature: engx5koxfbtt39zbm1cgtt8f6tuya4pf X-HE-Tag: 1701375314-302781 X-HE-Meta: U2FsdGVkX1+VXWZh8PwYi7wj2BJIz0VdmajyRqqq+EtJZZMsiSufHBIfdHoggz5PpLo17ZSf83oJbPVSYlmj6tVBvXFzBSJ6f39AWwhItK6KDi/59ctqQ+FS8oBqXZpVL2If+IKe9Ux8RAOSvjhvV5JqMbe+j4eNhES4N3WKsHVkuorm+cAKzPYB0vb9Um5GpyiydF17D1JdMA6cGSZsqXQ0a5BNeiOuEOx3yZ8zUUDQJ7gSBAvgpcau08H/GyQjWCZqgxI9zQsWTY5IvR4sxKKyAXIUS6RUTWef9XQl3hKFjeaCDyaSpAXsbm1+ty7uGNCS9tRzZgKfm7BibDjlF/Z9lqpgQShzMpmnTj0gOqd/II/ZZhb0Tlut9ft0ZqEU7E0OBiUmbfAzns3MjlABRrkmL2epsVyb/WegxffNaPhkAc4D6TvpA08NQfr+3nuVZhmecD3OVGQsVyJQxv2uFxGUE8sS8gdUP3/341Qo69kKHmwRDc4gBinbTZ5xXBaZQV9+V06r1DrPsJMbLpU62CG0pCQ4pijp/VXAEym33MhIH6U9OI+nAmU7JfI1PYOQxvE/gNNzUaWzOq2t8Ta6Mxo7SB8N9cTTgDsZHEQEKZqm9D5pocuW2ffL/cVMW002vsPOwA3p7ovx4zPEqfBFe9iYonBX8phU7HNnYYp9iLzHOMfs7FrXCppK5FohPMpiSA768W0Rw7XUUWxhYGLSTbheD2qeW1DfgkPpoPk9q85AGN8PymIlGSGcYLVteSLZxOp6ym6dHRtQqgULPrCMZayQOQBdYGGRWKt+Mi0bQ33MZ9sl8zPRnlfEapwxLNT4MlN/TCWbiQVAHB0WWFJ6RCOTdQO/NFNRQRwyb50UFOfCh5IWbB1A63Tm3Ha3TEMFbhifJQVGxOp658IbmOsgST8pejvPfitdLPqjK/lMVTuOfv9vB1EIiRHFvM7WYS7nS57iT7GjEDmc8LJULBN Kw7aupZ+ j0red82OyvW/bRRRx6JenfkDtSPE+Ogai59kHhP7cf0k65i8h3N084cHeLmbT4wEw6wM3j8jwog9AP/5/wW/qMYmaVV6OfH4t1R1O6yOXFeGxTDiG4xzNHYNs4yTiAYJK2K+aSJ9QWF13gaCjY8x8o5G4OAVqvXH/fPW6bk/VFKKzBI9bXL1G4N5sFyWLAkM+Vj7sRrfjP0eXwVYnwza3a9BfCAY8XitLVve/BdmoYSdlPuJXKjxAYJK0n6n8UWeL5Fh4kMYejbGABJwlCft0US3OXjskJcKKC0p30mZkia6hPzA8N+T6+ab5W9h+8Ipz9MLV9DnkQdAISNil/paU5aJY58XKWPfcNI8DsZQIeaXtHQI= 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/rockchip-iommu.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin Acked-by: David Rientjes --- drivers/iommu/rockchip-iommu.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index 2685861c0a12..e04f22d481d0 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -26,6 +26,8 @@ #include #include +#include "iommu-pages.h" + /** MMU register offsets */ #define RK_MMU_DTE_ADDR 0x00 /* Directory table address */ #define RK_MMU_STATUS 0x04 @@ -727,14 +729,14 @@ static u32 *rk_dte_get_page_table(struct rk_iommu_domain *rk_domain, if (rk_dte_is_pt_valid(dte)) goto done; - page_table = (u32 *)get_zeroed_page(GFP_ATOMIC | rk_ops->gfp_flags); + page_table = iommu_alloc_page(GFP_ATOMIC | rk_ops->gfp_flags); if (!page_table) return ERR_PTR(-ENOMEM); pt_dma = dma_map_single(dma_dev, page_table, SPAGE_SIZE, DMA_TO_DEVICE); if (dma_mapping_error(dma_dev, pt_dma)) { dev_err(dma_dev, "DMA mapping error while allocating page table\n"); - free_page((unsigned long)page_table); + iommu_free_page(page_table); return ERR_PTR(-ENOMEM); } @@ -1061,7 +1063,7 @@ static struct iommu_domain *rk_iommu_domain_alloc_paging(struct device *dev) * Each level1 (dt) and level2 (pt) table has 1024 4-byte entries. * Allocate one 4 KiB page for each table. */ - rk_domain->dt = (u32 *)get_zeroed_page(GFP_KERNEL | rk_ops->gfp_flags); + rk_domain->dt = iommu_alloc_page(GFP_KERNEL | rk_ops->gfp_flags); if (!rk_domain->dt) goto err_free_domain; @@ -1083,7 +1085,7 @@ static struct iommu_domain *rk_iommu_domain_alloc_paging(struct device *dev) return &rk_domain->domain; err_free_dt: - free_page((unsigned long)rk_domain->dt); + iommu_free_page(rk_domain->dt); err_free_domain: kfree(rk_domain); @@ -1104,13 +1106,13 @@ static void rk_iommu_domain_free(struct iommu_domain *domain) u32 *page_table = phys_to_virt(pt_phys); dma_unmap_single(dma_dev, pt_phys, SPAGE_SIZE, DMA_TO_DEVICE); - free_page((unsigned long)page_table); + iommu_free_page(page_table); } } dma_unmap_single(dma_dev, rk_domain->dt_dma, SPAGE_SIZE, DMA_TO_DEVICE); - free_page((unsigned long)rk_domain->dt); + iommu_free_page(rk_domain->dt); kfree(rk_domain); } From patchwork Thu Nov 30 20:15:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13475019 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 C7465C10DC2 for ; Thu, 30 Nov 2023 20:15:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A3F506B049F; Thu, 30 Nov 2023 15:15:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9A1E56B04A1; Thu, 30 Nov 2023 15:15:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7CC856B04A2; Thu, 30 Nov 2023 15:15:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 689E96B049F for ; Thu, 30 Nov 2023 15:15:17 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 43B9F1402DB for ; Thu, 30 Nov 2023 20:15:17 +0000 (UTC) X-FDA: 81515725074.13.02B0649 Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.45]) by imf25.hostedemail.com (Postfix) with ESMTP id 58C4CA0019 for ; Thu, 30 Nov 2023 20:15:15 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=QLOyt4Nk; spf=pass (imf25.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.161.45 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701375315; 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=WwZxW20NTsAI6OtU2mg3WBn7dc7VhXurLb9lJcGaB3s=; b=hbDJCm8Y/lBdMfiU7RuJAVoZvdkuO6ZU15Uxrg7k4AKJsAz+IFQjuwvZMPWsoQ4Rm/Su5g F5f52NZfMOy/+s6iOuTbCY0r5HjJ2SjW9LKMmyiiaEZwQUWom02bgXpZkWZKgsRah6DCjA /xRvVXUmm8HQ7y4ceAlWryoC/RwfWeI= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=QLOyt4Nk; spf=pass (imf25.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.161.45 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701375315; a=rsa-sha256; cv=none; b=5ZwKVS4tDj5veZqFcT8UdCcw15gCmGKc0HHyBCqKZM+zBOgkI763iRkzoD2uAcguS9XCh/ qfWYc1w1xqQ+oLfL/BfqJ6argQXSXj8lLBbrX3YBxBgZGyKRbJ5ASbaTvoE17DHCKd0pcs opWAZWaZxcwAXlEIaxbpoDO+VA9JbkA= Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-58d54fd8c5aso694668eaf.2 for ; Thu, 30 Nov 2023 12:15:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701375314; x=1701980114; 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=WwZxW20NTsAI6OtU2mg3WBn7dc7VhXurLb9lJcGaB3s=; b=QLOyt4NkgSkFtuZC7HcrV+lbAaj7ZNnrwNRc3C0mRIuIEqbRG0NEc43NwVjDntSYoV X5WnQdItlUngp640/mqPwGlePvxsLLjVX8iIlYDQa1F0i/0kykgAitxfi4th9CNFnYrJ 6VmaoLKo65MDqNT5tBByQ7EBky3J1VaXfv+rL5vvSY70/JjATNzLsG3hWik+Hzq8KVS6 mQAOXkqHYTgKaca4RijvzgKh3AhoIA9k2H/B8BGX05BalWB/jb5m/Qrprv9OEDk7geKm 2U3DKUW4oSMwKvNyaQAbEyqF3zWYGp+DGA2QO83Y1AP6hOIW5sFHZrdhURvpMWs2DnCt mCDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701375314; x=1701980114; 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=WwZxW20NTsAI6OtU2mg3WBn7dc7VhXurLb9lJcGaB3s=; b=rhg6TC6WeW1Ww97VL3nPdTlhxubRMyNzoli1Ow7bgUprU4QHT7J4rDwBnO9q9OowpQ E2SC1vnvVhOFhSKP14Hw/RGdFHWcVNTwbZNivyHg+lBbRZ0FDMib13Ox9DfCNCH2EJIU XMkgWaaDlB//4jYd8KhsZZQEeeW2JYCFJsWfbAIezL8m1PWaZH0JXNVm1CFcS+M5BkOX nTT+TXmdjTIZo5hGE63XvU8BiSUrc5havN0yaDuMyzaSql5lTS2e8dwUkOWya0eKYlWS XBxAi5Ob0xtSaiS3X/IbktJ29NXnX5uzvN3abm7kr1fcTyAtwQDQNvgbDrQuoPciW3z9 neWQ== X-Gm-Message-State: AOJu0YxulGu3i/O1eAIM1ePdFsDLCggaeIAE3TnNpGuYn9WM9YmXgiO/ Kq8WNj7KLdsDtBtwW3D2C3+1mw== X-Google-Smtp-Source: AGHT+IGTxsoHsoEZ+jaTqaWghyHDgBjLPZzal0bywx3elLmQBrrmBhd0Hv9BOGHbfQGzeWmE2Kea2A== X-Received: by 2002:a05:6871:3281:b0:1fa:5890:7840 with SMTP id mp1-20020a056871328100b001fa58907840mr16958744oac.35.1701375314449; Thu, 30 Nov 2023 12:15:14 -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 e1-20020a0cb441000000b0067a35608186sm795252qvf.28.2023.11.30.12.15.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:15:14 -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 Subject: [PATCH v2 07/10] iommu/sun50i: use page allocation function provided by iommu-pages.h Date: Thu, 30 Nov 2023 20:15:01 +0000 Message-ID: <20231130201504.2322355-8-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231130201504.2322355-1-pasha.tatashin@soleen.com> References: <20231130201504.2322355-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 58C4CA0019 X-Rspam-User: X-Stat-Signature: xszp5iyyeu4o4e53tb16mkswqqc1rfj7 X-Rspamd-Server: rspam01 X-HE-Tag: 1701375315-150291 X-HE-Meta: U2FsdGVkX19RUiKGBe4Wxh0dJi+ujTJUtbovEYyvjIS8PTPBgnav4C5k3SJrk96r4Z488UaMaPtKo0Qpz7/blmBAugkz62Ovfjj3rcwzCVUJOaSz1e9RM8CHtqxmIbXrixv+aJiijkLot76nSlZnEx2fLivQWSpq1HXdsmeKfXFtsJ/MZ4PuPRNcUhz2kgYH3eD4ZquQzyeznGrg/3gu55ODi4OpK24dS7TFqNKD+IXVXqG71oPwkiek0lNYxp7cRrwckJlf278/WsFJPe+xS46764EX+CuDoJMRgFttZE3atWLn9LPp4Z4c2t53MVryl+VDksgdkz66tBBveXEwVbVSdJt9uU24CYOGuPocJircVynfI1tLSRbkeSo6P065p1ko1dgaRxfl6qHTyBe0XGdyxFGlbDPu+ejtYRnTGWOKk43Lr+jXshWU7ERKgLb9+ixeC9YLWgBq856R1bd4bpX0MGzvoG9VXxR1GEMVXGrMsLiIYj350mWkpakHiP4HEslN8lpiE6gnUeU+KTzIGLIadRLl0wPkhMQf3P5ipWHWC8CalD9xiQNh+MEQUluqVXHKIJYbEGC2P9C7NS/wPPuF4W79Tijp9NRv6i8QyrDzsyR0bsz1vlnX6BEDP7P7Y3ykyJxzUOFqR1ICbCfxsdIt0Hc5sQXR8T3SogpY/63e059rKuxwCS0Jo5mX0tz4HakyLUTrdIKmnzFfwHwSEDPDzXrs3rNZecQFqnH30IcIvchvzfC6TrruJWl2PjL6oSsJzbczB6k1eTKSGFSCjsJKvAR+rWPqHMwykZ8ZKxSAOKlXfMNlxz8OhRGd2glqSr5sAnDC+XZ2hd+W1IGM5El8n7515THEQo/eSWBz1cK8gDNpOFqLKy8vWbfqP8hapP+UvevdHajmwKnBNyG2zRGXk7Qp7i2OY49nYA0rfPlsN8Ipc6MaSd/vH2lU96hMwB3+iLshD383uu99paW 01MZOvw/ laizSYQGWhEQeIdANc+LmGQfwx6AuRGS5kAvfr0rd52FfB7406pk4rb6TfGk6g8w+rROs7evk7CsHgh9Qsp2QcYID34CisNvQpP64ZaldcSeE8GfBTTgzlYTgPfIDkQs0M7Uk0rxccsgd29nL1/iib1N2kp48qY5Bg0rEIjKNnCya6Ev7EVFItqHSCoGssP7Eh1c94RDlTOrfoCjeOHk4s3yydCUs58MCTmSALNlHKTH0CHgBLA3IbgU/gN4tsmnwCtNHjdhqBmH5BATTJzraZUFz84bEAgTjbygTDX9YXqVdsMfWD7dSnHCP49AlMW9cf61fVaE/SptzElTcj+QMExCymNhp3o4mrecJ06BnALPCpmXH72zE8aLMtKQtAlXhgqqiNn0pbzZRrMqamzM5dvxMtgVE2tRlbXAW6/oH9s3+fWJdTyLocQ3QdlUbPAls4goqweXn1Doz4CEh6H1187JbilgIvlMSDfSlYcy3kAPDMpD+q/FgcKp3YVqJtyfBqHpUTpUdH7BplLI= 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/sun50i-iommu.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin Acked-by: David Rientjes --- drivers/iommu/sun50i-iommu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c index 41484a5a399b..172ddb717eb5 100644 --- a/drivers/iommu/sun50i-iommu.c +++ b/drivers/iommu/sun50i-iommu.c @@ -26,6 +26,8 @@ #include #include +#include "iommu-pages.h" + #define IOMMU_RESET_REG 0x010 #define IOMMU_RESET_RELEASE_ALL 0xffffffff #define IOMMU_ENABLE_REG 0x020 @@ -679,8 +681,7 @@ sun50i_iommu_domain_alloc_paging(struct device *dev) if (!sun50i_domain) return NULL; - sun50i_domain->dt = (u32 *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, - get_order(DT_SIZE)); + sun50i_domain->dt = iommu_alloc_pages(GFP_KERNEL, get_order(DT_SIZE)); if (!sun50i_domain->dt) goto err_free_domain; @@ -702,7 +703,7 @@ static void sun50i_iommu_domain_free(struct iommu_domain *domain) { struct sun50i_iommu_domain *sun50i_domain = to_sun50i_domain(domain); - free_pages((unsigned long)sun50i_domain->dt, get_order(DT_SIZE)); + iommu_free_pages(sun50i_domain->dt, get_order(DT_SIZE)); sun50i_domain->dt = NULL; kfree(sun50i_domain); From patchwork Thu Nov 30 20:15:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13475020 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 E9F2DC10F04 for ; Thu, 30 Nov 2023 20:15:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6E3206B04A1; Thu, 30 Nov 2023 15:15:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 693056B04A2; Thu, 30 Nov 2023 15:15:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 471176B04A3; Thu, 30 Nov 2023 15:15:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 300DA6B04A1 for ; Thu, 30 Nov 2023 15:15:18 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 07390140329 for ; Thu, 30 Nov 2023 20:15:18 +0000 (UTC) X-FDA: 81515725116.04.ED3A6F2 Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) by imf05.hostedemail.com (Postfix) with ESMTP id 461E810001D for ; Thu, 30 Nov 2023 20:15:16 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=c7X7LIcN; spf=pass (imf05.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.42 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701375316; 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=CTqyv+/QBqQRpLXIT6J0+RNMQRf6NZoT619SVstW8Ks=; b=GdRGRCYsVVgsArNMXgS3HRXj2sg6sbHU2LvG1mZ3Os5rhruiYigLCpRNSSyQJiRy122ZOG kcGUg/ZML2eC/7SRFyajwVMJ/yfZ4yK6VNJD+Eep3tGuxGNDYJdev8d46gC3tTKfT4QwI/ LUoLz3lF1Iyz+7awev4c4Fvd0HO427Q= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701375316; a=rsa-sha256; cv=none; b=uj/6zv9Yctn/oHYRiqmMcrAK2zSMMqx7NHsdgI7nTfB0IbF8mEXAC/1u4sSUgavyuYY+90 Q+YjB5XGLX6d9GKamyUjJbnDoc0WdZ00xeuKWoGzxSCvl+3Mj+116R4zKjUP/bVOtBh4vJ vT7esdWCrfujLrqFBHzAJZsQxN7Bw1g= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=c7X7LIcN; spf=pass (imf05.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.42 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none Received: by mail-qv1-f42.google.com with SMTP id 6a1803df08f44-67a8a745c43so6156886d6.0 for ; Thu, 30 Nov 2023 12:15:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701375315; x=1701980115; 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=CTqyv+/QBqQRpLXIT6J0+RNMQRf6NZoT619SVstW8Ks=; b=c7X7LIcN3RF65sgEsl63oljkMqMohSPK5BMJQdFcLdwqaAxYFpzirbGTsTPgsWw3Y3 uE6IgLaGZ9IsS/o7QadS636qXi3ET7yFgzn4p5joZula5UjNSOqqnVqnPpP/tWSC5GXG TRO++0YSQ5uk/6Tb6kclw8pAbxQsL5EY9TuFoMz87m2dSZEapU8g+q1U4KXAsVg3gzFm t9A8R9qmGlc48JmhtbtF4tt9R3PSeSPqWSrYuujWpkpQzPPZ4lQe6A0S94vnLgOpl0T2 C4Jz2Gkmhyrfgr2MhZL9D+OguUVY/wnNxKdD1ZFwrcQlmhvbDvvPxPkb2vqqOebd1GHm 3eOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701375315; x=1701980115; 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=CTqyv+/QBqQRpLXIT6J0+RNMQRf6NZoT619SVstW8Ks=; b=JiWp/BZA33zYooIj+5ASWan6a5LCBGL/wwo/ph/gZCSr/UH0q2FqYPZf89u+EHle5n M6gR4T3UCb+XyxwJHqEdmU0XDSkbcwe2x7Dl0OZ1s48BsdYTPgItvjDsZW3iVTsnRdn8 tTWAYqW/O4l6syYSqyVvBAOxr/yUXvXXzHbBlneE1AxixQ1LzpJh+e2g/OjFknuk+yib b8kjM+RwHkr4oyRmBgLcnui5MWNXg8jSsxN3ZoppPDN6VY6F0OByzqMwDDuEXzgkWzYS 1ih9x2AKYfjZGMgHkHimx3yF9eg34cosETv1CjtIlsG+6KQEhML2Or6fiBSimK0/g0Me y12g== X-Gm-Message-State: AOJu0Yw1WIHZDzWFfyuKySV89TLA+HQFRcIvkdCfEkFETfUUD05XGcG6 tP+XrMZzkXU7Qr2rA2OytQjBZA== X-Google-Smtp-Source: AGHT+IE4JYPLoA/tNY4x2pKdpnHf/W/XblnfOPtcPXpbeLos1tHq3JCEAsQT3LPHq1ybHp62KX3VJw== X-Received: by 2002:a05:6214:4115:b0:67a:3a51:8773 with SMTP id kc21-20020a056214411500b0067a3a518773mr24916856qvb.5.1701375315320; Thu, 30 Nov 2023 12:15:15 -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 e1-20020a0cb441000000b0067a35608186sm795252qvf.28.2023.11.30.12.15.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:15:15 -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 Subject: [PATCH v2 08/10] iommu/tegra-smmu: use page allocation function provided by iommu-pages.h Date: Thu, 30 Nov 2023 20:15:02 +0000 Message-ID: <20231130201504.2322355-9-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231130201504.2322355-1-pasha.tatashin@soleen.com> References: <20231130201504.2322355-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 461E810001D X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: afetm8nhh67p7gufqr65uihi151jiofw X-HE-Tag: 1701375316-89355 X-HE-Meta: U2FsdGVkX1+jzl4iBFme9xEXdwtQpP0SOwM7Lo8sWv8VgaO9lgpD28fEUwQB8jjkzkJ8Zl7nCTF+N5kygLVcM+YFkoGxqAwYD2Gay11zZPpbFDQKc8zdICj4SG87RNtJ5JiqxvYxdAeOMapwjt4TCONSg6fjZMGshPzUH040mfyHrKL9PJkbRpCMOr4B17phfs6JU9+sJBSuK167oe/IuPSPfHXdAJ8g2vb3c4ioBjO8xR39D2xvubFgOImI/y0Eh/Y+A9BPTiYd9JRErCmlmQx03dYqHu0jTJvjSz9xNNY6YKxUZb80yup4TKASoP3NEitzU1HKmh7h1p6J3CeBtS8MZkrDFW3gfMAtJPrsmKakZ65IQkqzKgoX+yyPqjQ7n1VVlmAy/bD/H9WASN4382mP0XGjRzKrk3FSA1R8zUsTJUbIEmrLSxKVbo+oaPIdtARc6hZgSll3igoEq/Af8O0+fQ/g1A8i1I9OQQ4cRET/8ZXKVKDWcMFzmLpKPRAaQSmCyaZdj/gvSzjXUFCSuNc8pdJ10KVH0v13pbBKh3ttWBhrfqjC3yW76yEekVoZS/OAkZCIwhkEBlVrthQI95eciKTE/WEkI+eAthvLWn6jIqOkNHcGfowDNBxERloL8UIqhK/y4NLdaHD1OySdXLCStE33xMLAx3AftVm174QfdmUCAIuBTp0ODjdTTRJjjOhmAwC7fm+iglsON0dSMkYA1+XXtFfN/f9rZyLAoIJlVLAypSio2Oxl3oWR8037u8lvcy69DUN7BKnoVfxUtzmOLkNCRIRhti267mAg6HjBPffcsEcyZAXPMWFohm8oQgKcyH0iSw65jk9+y1u6fjaeHcX42rtrN9eTK71RaIM6Wf0/FUnNxIqd0bFALYSND8mnDQ/ewlgSx3DNxd1DR0Jt816WzVBueAy8H/dT5N2SvmY8cWk9IU8ohBLQE78dk/TPDX31LG/nTE7or8B TzrmUwk/ VLn3Zykc2tfzJLCMfpsp1qw5HUH5Uy0v/T5fVboFTL/TZqIbgXQLyyK3a5NIokK3rHl8tOqhMklcOUL/3B7cyF8i16u1EXAq3zXYFShGh2acc9unvw2onyfav1iz9LRVvBAbFVc/YyHjt8YtlK7qLJAEtCOYt8EfpuSqGxSOfPomuOhQmAhweAyl1vKN0txHnw8dkO9HvAGhwScZKbY7MGxlZf2W1i0jSogVj+2vMCZOjxKy8045XpVSpnHpuliDo1dI/xlu3IWfU+mxi6GNNq//25aJ97mZS33omg+yG9J1Ph0WZbDRdjoiOaJ2ol6tjWoduc0iDR17NmX2GFWmroYz+Hqm72/ck6zCTZH040AVHGTGaxWK7u02mBE5kz39tk/ZUKABATQrXrGeLisF+1GXDXojGBAgqzL9XIe4fWKqR+OczPJEuiNQWHSL9U34v0Kqv3I0SMgsBDrWsVyOHLVlAMeR8I+nVYpdV2+OrhGYCm+BH9s6vWV/0pK4aMjclGmv5yyzSsFlKVCY= 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/tegra-smmu.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin Acked-by: David Rientjes --- drivers/iommu/tegra-smmu.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c index 310871728ab4..5e0730dc1b0e 100644 --- a/drivers/iommu/tegra-smmu.c +++ b/drivers/iommu/tegra-smmu.c @@ -19,6 +19,8 @@ #include #include +#include "iommu-pages.h" + struct tegra_smmu_group { struct list_head list; struct tegra_smmu *smmu; @@ -282,7 +284,7 @@ static struct iommu_domain *tegra_smmu_domain_alloc_paging(struct device *dev) as->attr = SMMU_PD_READABLE | SMMU_PD_WRITABLE | SMMU_PD_NONSECURE; - as->pd = alloc_page(GFP_KERNEL | __GFP_DMA | __GFP_ZERO); + as->pd = __iommu_alloc_page(GFP_KERNEL | __GFP_DMA); if (!as->pd) { kfree(as); return NULL; @@ -290,7 +292,7 @@ static struct iommu_domain *tegra_smmu_domain_alloc_paging(struct device *dev) as->count = kcalloc(SMMU_NUM_PDE, sizeof(u32), GFP_KERNEL); if (!as->count) { - __free_page(as->pd); + __iommu_free_page(as->pd); kfree(as); return NULL; } @@ -298,7 +300,7 @@ static struct iommu_domain *tegra_smmu_domain_alloc_paging(struct device *dev) as->pts = kcalloc(SMMU_NUM_PDE, sizeof(*as->pts), GFP_KERNEL); if (!as->pts) { kfree(as->count); - __free_page(as->pd); + __iommu_free_page(as->pd); kfree(as); return NULL; } @@ -599,14 +601,14 @@ static u32 *as_get_pte(struct tegra_smmu_as *as, dma_addr_t iova, dma = dma_map_page(smmu->dev, page, 0, SMMU_SIZE_PT, DMA_TO_DEVICE); if (dma_mapping_error(smmu->dev, dma)) { - __free_page(page); + __iommu_free_page(page); return NULL; } if (!smmu_dma_addr_valid(smmu, dma)) { dma_unmap_page(smmu->dev, dma, SMMU_SIZE_PT, DMA_TO_DEVICE); - __free_page(page); + __iommu_free_page(page); return NULL; } @@ -649,7 +651,7 @@ static void tegra_smmu_pte_put_use(struct tegra_smmu_as *as, unsigned long iova) tegra_smmu_set_pde(as, iova, 0); dma_unmap_page(smmu->dev, pte_dma, SMMU_SIZE_PT, DMA_TO_DEVICE); - __free_page(page); + __iommu_free_page(page); as->pts[pde] = NULL; } } @@ -688,7 +690,7 @@ static struct page *as_get_pde_page(struct tegra_smmu_as *as, if (gfpflags_allow_blocking(gfp)) spin_unlock_irqrestore(&as->lock, *flags); - page = alloc_page(gfp | __GFP_DMA | __GFP_ZERO); + page = __iommu_alloc_page(gfp | __GFP_DMA); if (gfpflags_allow_blocking(gfp)) spin_lock_irqsave(&as->lock, *flags); @@ -700,7 +702,7 @@ static struct page *as_get_pde_page(struct tegra_smmu_as *as, */ if (as->pts[pde]) { if (page) - __free_page(page); + __iommu_free_page(page); page = as->pts[pde]; } From patchwork Thu Nov 30 20:15:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13475021 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 DC659C07CA9 for ; Thu, 30 Nov 2023 20:15:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 75CE36B04A2; Thu, 30 Nov 2023 15:15:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E22A6B04A3; Thu, 30 Nov 2023 15:15:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50DF76B04A5; Thu, 30 Nov 2023 15:15:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 3E2596B04A2 for ; Thu, 30 Nov 2023 15:15:19 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0F0C81C0324 for ; Thu, 30 Nov 2023 20:15:19 +0000 (UTC) X-FDA: 81515725158.26.104D69E Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) by imf19.hostedemail.com (Postfix) with ESMTP id 0FCCD1A0003 for ; Thu, 30 Nov 2023 20:15:16 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b="P/N/UTlA"; dmarc=none; spf=pass (imf19.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.210.54 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=1701375317; 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=B42Ompk/0S+0FHWlF0c0WCUF97rKJOKtrfjrMLAbFqA=; b=hFoR6o4fYtD4CfDrTCb93DHFHauhhtAoLMZFOmyut1d+7JIa30Xax0HSfsJ14/MBag+ZUa xBFWHpMpOHcOAokn3PWYPSAEUd6o5ubYCz+3lYAM3v5hNavUItm13Q+oFIMJGUGp/jycfi 4wr2qWno5mbFNmU7z5ofCelWPZfUC8A= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b="P/N/UTlA"; dmarc=none; spf=pass (imf19.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.210.54 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701375317; a=rsa-sha256; cv=none; b=K9/VS/CrL3YA+z9fCmSfSLv3pQQl58mX2MZA/mq1jxkIx8edDbAqQ9xfWno2djCe+NKst4 hiU/FnZMaKnqSQ57cc9swGQTYT6gubtw9FKj1E9iNcRaMfmNM4IZmmZMBmg91B59RpnmTg 6ITXsnaezZqG2/EzXnPDABKBGsRHOgY= Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-6d856210057so803655a34.1 for ; Thu, 30 Nov 2023 12:15:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701375316; x=1701980116; 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=B42Ompk/0S+0FHWlF0c0WCUF97rKJOKtrfjrMLAbFqA=; b=P/N/UTlAY4uSfQfqjHlMQNjeHgkeSVgQpovJxJLsclCW/yWyHQCvphF4KwAXjyXIjq MVQsCsHxHuNeOLgL6aSqaZTpNA3mki4NpMhUTkbrRL0sPY1yiUBIQjzZJ47GASj7UM1o A5gPRRtG+/Kb6LJ0mDBCNhCENUtED3TXrs0G3ejR+dfySRc4zpFNSgzpdXiLbeAsxnXj Hc4CaIWN+/f4ay5vA36aY7/2Kme0O8nQIyIkgk+syPAAcpMJzOTc8kVkYuVVkqnONjz2 QN/xJDmVO2Nz8KadIyTcwWKCXTPzRCrRJqX1dJQXnaoiD8daDtA7pJFRoScDVErote0X EMEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701375316; x=1701980116; 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=B42Ompk/0S+0FHWlF0c0WCUF97rKJOKtrfjrMLAbFqA=; b=NAOK0FI+AnpMZtXMBakP5ChcSILI9PizamwhzIyikCWe3R82gNPDQJw6IIMZ2gzeNJ Jpyy+lBBUXQJzQ25Zec/OaoE2BT1sHP099TtXatv033mSMl0DXdDmhL3VHaBYScxCYJ4 CtdX6SOm7/WlJXse82PCb2JUPyYERHnD4qgALnAkHdGo+HAOl1MFOKXu06xiq+biqtl6 X62ICwEW3FpfBxS6GmrCWxEe2Jo5eBQjkhZuHQ1+tsohMhNShukDnWgEeCiGeFBAbIvT P89oYU7akENrhkOzpBRSZCYCByMVGVJtBesk83TEVfMSCwt2y2gdQTO8apSCogSNR7vQ RBzw== X-Gm-Message-State: AOJu0YwaIMQvXuNse0iTnsjrtrB5AIxWT2+BmUy2QPUhxV6Ikx8khUi7 4cJc3+o2Gyb/t23Ri7YUV4xT7Q== X-Google-Smtp-Source: AGHT+IFm2VZamMYGPMsf9vCHQb4stofA9P0lnINgFWclhv2SjMIVDU5Q4H8UbP8D1DLG6NZm/4QG2w== X-Received: by 2002:a9d:7dd2:0:b0:6d7:f02f:dcc3 with SMTP id k18-20020a9d7dd2000000b006d7f02fdcc3mr809535otn.28.1701375316245; Thu, 30 Nov 2023 12:15:16 -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 e1-20020a0cb441000000b0067a35608186sm795252qvf.28.2023.11.30.12.15.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:15:15 -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 Subject: [PATCH v2 09/10] iommu: observability of the IOMMU allocations Date: Thu, 30 Nov 2023 20:15:03 +0000 Message-ID: <20231130201504.2322355-10-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231130201504.2322355-1-pasha.tatashin@soleen.com> References: <20231130201504.2322355-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 0FCCD1A0003 X-Stat-Signature: ymax8xpuhk88oo3u4k194k4m89gequcw X-HE-Tag: 1701375316-542674 X-HE-Meta: U2FsdGVkX1/mO0fT/6di2IrQ9SiuKYFamzTxdyVMaX4y6sszxz6soIU0H59TQqYkLpMO1v63k3CZaqAmeDpaZZ5y3r0kFYo8qvCqlTqrSUEM8+smi/SID4ahMW7cwTR4ajO6I4wn+ZZ4FiqStxrMoqv6nqdqcySOLEx12XvKCBWr/yB9wURJZx8WEiRjBWvwcVA2RFQ+Xt7zcTDmaJXmI4RnnUbZIn8nQalV/GTsWfXSvY2LQ1ZB9DBRKIc48fJm6gRgO/HwHVuFKiD0nyDs6LFMyjb7xReR3iPy5AsOfjONQsA9f8UAsFT7hy1iWSLdtOnRl98MXpGhJQ40qScqbwr27wnCxW815l5VFNfFWw3Y0HJ2NnUxztCgHOUrIqB35iLjqs/F5wpl1cT6zDl41Q5lXOctyEj/fxUp6AJPT488eCFvrH6mWdyld0iRt0g+tBjDAk2d9Pl0nWYbiGJBCAjlz7w8tkPs8+op6SPKZ1ulhnm1sGGRuCELKq2L8917MHUdxTXS7axOwHsC784BgFgxGCGqnvBQzKtQIGXbFEi/Pq2VZl3YQBkNnIpxyJj1wrg3EL0DR1StTZa9+erud5zcwd2Xegn36s9o7qR7PrLMsfy236gotKut6Dsh7lCOOieQziOCkP3hyVTizkml+PxUV9n6hXmbth2r/Y5/t0Pes0Ok8u1LnTWN81H4jqqG9/9OpunJmYqU7WiCfLE/KvlT2GUBDv3qxLDZUEjoIT8gHpbKrfkmPm2NObu7mm3WyzYiigWsqFQkFHFpbKiKqY6WM56UkkDUuq6Bfh+jlzTZUC2VVj5NjuxnQoC0Cva69VVVTXPdeBnN4py9Xi7rnHjv1r+fb/NTq8JRTH73EeeMhoaxT9O7jW8sG/esW9iBMUgl6Mqt5nzsW3IqOhr78qJqo2Sje8UZjmnrC6smhpkNu0S6pucfMkPKarhwfVSoB0P51rd3dAJ+D1feHw6 22Q7Z4Ae I060Z4jCSddzB0Frv/7Z8hr6KKURHG1zLlej8WFjkiBhUoFn1RgkKE6Xn7idiKUQTTKalNSehR/2aSgWi5+uxiwsQZzoEnnKWvHX4++sHiMayLUaACeYSZdQLg1bkRVSqv7Ufn1yiNpDN5atuD+Ad5pybIK8yUuF7ZNkuwamjnD/D2YhdLa4wnnBwOOWbplKgEPZb3Zw11Wfj8LcyidTpjKQX2LWlmx/jRGuwro0Y+vVc1PnFsJCNMe9ZNL8Mpbhw0kI+xGevsEI6kANCxsgCWHPujweloj35k8fJATPW/2ihdhuQpd0AHYAjGCypUs7d4+dyGNEU2WV44xrHt5pQqZNJgLbHQYCSO01gxwP0C5YttuB7SQRt2PGzLqJbZcmETlvggnRZdu0STtNiRGrL7XJskj9aikaYDPtVLHvxgbHoGkOGYLBHelHk0faXR2WUghaBlYkaBIo4NuDTOLHKuzlw67GHk7RH+i8KRv0vj1ndf0d3aFni8cZF9izUyUKtK2Z+DxdN9fj80TmbOsVJCs7WGw== 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: Add NR_IOMMU_PAGES into node_stat_item that counts number of pages that are allocated by the IOMMU subsystem. The allocations can be view per-node via: /sys/devices/system/node/nodeN/vmstat. For example: $ grep iommu /sys/devices/system/node/node*/vmstat /sys/devices/system/node/node0/vmstat:nr_iommu_pages 106025 /sys/devices/system/node/node1/vmstat:nr_iommu_pages 3464 The value is in page-count, therefore, in the above example the iommu allocations amount to ~428M. Signed-off-by: Pasha Tatashin Acked-by: David Rientjes --- drivers/iommu/iommu-pages.h | 30 ++++++++++++++++++++++++++++++ include/linux/mmzone.h | 3 +++ mm/vmstat.c | 3 +++ 3 files changed, 36 insertions(+) diff --git a/drivers/iommu/iommu-pages.h b/drivers/iommu/iommu-pages.h index 2332f807d514..69895a355c0c 100644 --- a/drivers/iommu/iommu-pages.h +++ b/drivers/iommu/iommu-pages.h @@ -17,6 +17,30 @@ * state can be rather large, i.e. multiple gigabytes in size. */ +/** + * __iommu_alloc_account - account for newly allocated page. + * @pages: head struct page of the page. + * @order: order of the page + */ +static inline void __iommu_alloc_account(struct page *pages, int order) +{ + const long pgcnt = 1l << order; + + mod_node_page_state(page_pgdat(pages), NR_IOMMU_PAGES, pgcnt); +} + +/** + * __iommu_free_account - account a page that is about to be freed. + * @pages: head struct page of the page. + * @order: order of the page + */ +static inline void __iommu_free_account(struct page *pages, int order) +{ + const long pgcnt = 1l << order; + + mod_node_page_state(page_pgdat(pages), NR_IOMMU_PAGES, -pgcnt); +} + /** * __iommu_alloc_pages_node - allocate a zeroed page of a given order from * specific NUMA node. @@ -35,6 +59,8 @@ static inline struct page *__iommu_alloc_pages_node(int nid, gfp_t gfp, if (!pages) return NULL; + __iommu_alloc_account(pages, order); + return pages; } @@ -53,6 +79,8 @@ static inline struct page *__iommu_alloc_pages(gfp_t gfp, int order) if (!pages) return NULL; + __iommu_alloc_account(pages, order); + return pages; } @@ -89,6 +117,7 @@ static inline void __iommu_free_pages(struct page *pages, int order) if (!pages) return; + __iommu_free_account(pages, order); __free_pages(pages, order); } @@ -192,6 +221,7 @@ static inline void iommu_free_pages_list(struct list_head *pages) struct page *p = list_entry(pages->prev, struct page, lru); list_del(&p->lru); + __iommu_free_account(p, 0); put_page(p); } } diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 3c25226beeed..1a4d0bba3e8b 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -200,6 +200,9 @@ enum node_stat_item { #endif NR_PAGETABLE, /* used for pagetables */ NR_SECONDARY_PAGETABLE, /* secondary pagetables, e.g. KVM pagetables */ +#ifdef CONFIG_IOMMU_SUPPORT + NR_IOMMU_PAGES, /* # of pages allocated by IOMMU */ +#endif #ifdef CONFIG_SWAP NR_SWAPCACHE, #endif diff --git a/mm/vmstat.c b/mm/vmstat.c index 359460deb377..801b58890b6c 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1242,6 +1242,9 @@ const char * const vmstat_text[] = { #endif "nr_page_table_pages", "nr_sec_page_table_pages", +#ifdef CONFIG_IOMMU_SUPPORT + "nr_iommu_pages", +#endif #ifdef CONFIG_SWAP "nr_swapcached", #endif From patchwork Thu Nov 30 20:15:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13475022 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 8F0B9C07CA9 for ; Thu, 30 Nov 2023 20:15:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B7A56B04A3; Thu, 30 Nov 2023 15:15:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0CAD66B04A5; Thu, 30 Nov 2023 15:15:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE69A6B04A6; Thu, 30 Nov 2023 15:15:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id CAFC86B04A3 for ; Thu, 30 Nov 2023 15:15:19 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A653480282 for ; Thu, 30 Nov 2023 20:15:19 +0000 (UTC) X-FDA: 81515725158.17.E285F2A Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) by imf16.hostedemail.com (Postfix) with ESMTP id DF279180029 for ; Thu, 30 Nov 2023 20:15:17 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=QVao737I; spf=pass (imf16.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.48 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701375317; 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=Nk58INbxx30xLOHUnMGn9OdPuZubp6H+G9gT2CVk01Q=; b=24j5kIdaAB+ToMbJOhRIiObRBGHGobMR2SoVKE5qm+QDCmMBucyeVTaKsgN7/xF8x7TPmD T4ZgRCehG3reg+mq6DJOwcRsA/ZFec1MWdwBzYYUY6e/u4pdgX6uO3jcTEFF4omIDZSZk5 i6vic/WnRgyj786MRgrTrpHbmJHiGkU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701375317; a=rsa-sha256; cv=none; b=NQOWgb/VrR3fMJjkOBSzKZXcH6nmP8f8CAgYbqXFcJ7aPMWhzKF1vU3Ot7t5VXEjOlJGs9 9XRGwqES4DSs3dY3YB0Drl51cFQozud/c2wjdhRvRbd7akCR7VcpIjFM9/0xdQrJo4VXqX iyBx71WlPJSIMoo9YbkFXnnhuQwW9LA= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=QVao737I; spf=pass (imf16.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.48 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none Received: by mail-qv1-f48.google.com with SMTP id 6a1803df08f44-67a35b68c34so7512116d6.3 for ; Thu, 30 Nov 2023 12:15:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701375317; x=1701980117; 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=Nk58INbxx30xLOHUnMGn9OdPuZubp6H+G9gT2CVk01Q=; b=QVao737I5t123cE5y/4CMhjze2EqyIQ2jun2q0RTEKyi0guA1VHKTn6P/okVZrIzNh 6ExHXZccNMd0JX0+AfH9m3QWk7/m7QFp7P6ewPZK6/jJfeDXoolt52fiNgqtbH4Wt1FQ PFE0PSS3A/U6SVgDsjaQAgO42SPZOmgq5iI6HwKROljuvoqEdaUcgLPHuAACMScv9owe J0Tr0bL3F6cf1Wb5pxMB58kcBMhi9U1uKe2kUqrMYIWz21wfzMCZhnqZ9/t/aZ2CIzRZ 5DGQDuvQtpKKoTlLdN18Yjv7Z0WLwnrYND1k5yaHnSs41o4aSNvSBNJCbSSmn5xK7VUz QWCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701375317; x=1701980117; 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=Nk58INbxx30xLOHUnMGn9OdPuZubp6H+G9gT2CVk01Q=; b=Xe6f3MR73x12YLSVJ+fS6gA/t5g/evZwJOdcW0otBDY2NIE7wquVUJhk8FB86gsVff 6ASaglfNujepnMuZXP/G1OcevXYds3J6luNtKQOUnzQztU52MSI9vKtDbFET88kXQNh6 5nQirx6XG2ziLk9abRtb9XygWxybIBblkosJVqctzHr2Zb550PNBQ+1s85JMcYtPBeV6 IFrEAKc6PGo5i/Yj/PMgOZvdSyyg+LBBxDALCI+fN+omocJG2E5qZstwy60gZP9j0VPE PZ3iCnrMIePreqaJsacQWbO9uGi/X0MwoMlJKi1/OCn9g2kUjqD4UxXo9AnKpcWzdlOo KBkg== X-Gm-Message-State: AOJu0Yy5eqvR0ELo4EFGzLblr4HY4NvUA4vhBeaAaxkny8cf+YktmpAs hV/mHKUQ3rq22OVB2niW9qlfAQ== X-Google-Smtp-Source: AGHT+IGvd2g71GGje9dR/iX9F2NrVDVxx6CHTrqO1K3GZh4lvqRPIVhnZdc8oub8jQLvnHQLKAhyCg== X-Received: by 2002:a05:6214:16d:b0:67a:2942:988 with SMTP id y13-20020a056214016d00b0067a29420988mr18670319qvs.21.1701375317117; Thu, 30 Nov 2023 12:15:17 -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 e1-20020a0cb441000000b0067a35608186sm795252qvf.28.2023.11.30.12.15.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:15:16 -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 Subject: [PATCH v2 10/10] iommu: account IOMMU allocated memory Date: Thu, 30 Nov 2023 20:15:04 +0000 Message-ID: <20231130201504.2322355-11-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231130201504.2322355-1-pasha.tatashin@soleen.com> References: <20231130201504.2322355-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Stat-Signature: ym4gbup5oxu1wch6qykb3hkoyr4fd8k1 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: DF279180029 X-Rspam-User: X-HE-Tag: 1701375317-937306 X-HE-Meta: U2FsdGVkX1+pX1YHvha9sbVUlQKWN7p9FoDSime3QP5DLfWeAk8SrugpxJdgnybiV3zqC2UOiXR+jpBF2yGkkPyJ1xaqrLbH5Sxp0nkEKOmby+6iP4Uj93uNq44inOI4Sip+/2IZ6YDGyAR/vVyGQItDb38Dq0PZnMeEMHbMMnSQrVXDeW0FOiRAGxmsjNpkV94IIjHUzqyFWPZGmvlXAZC5KKpvHnqWVZHB5+DrEi1qPXt93A0KgsJleVH9bp5/m5BnhYXOeWMuPRLGHFCmUNOdmCTYUDFY81uXIV4XlcRpMShKMWIcvKmNjjbPSfqrIukCtnIkeimBTocHnRkbV98FSL8rbQWuk9LGrg046kiqVLaPmg5CgkvsqmtgwsgplxYFRHpEE0j8MptvSHqXso68F/J2TRm0YAm7mdslvcnNkHkAqlZ+V7DpYK5F4a8G5fJgG0+v7T5I35DMpNyelaI9/dDxUbiX83aXCzzy8THmtjS6z46RF9I20r/MDNntIFZdIagnJJ2thpUdrPMbMkZ+a1yrndBAMVt8gUj3I632V80UpXrCjsQJzDP4EkxCL3kHGRO4qP+fgifNLnnhsN9HlRiXJhNzxwgXE0mARWdn0XqnjNVqhomnR91UwzIiJ6diWMP3BI3NjXu/bRSR+j8eF7CGy7QsNLjPaBYY/bhvKI4/wii9W0GV863kyhMBw2EMt9HIdZzRNLawY/RiDmG1NZe+oEGFPNPUm7YFuaKDOXIK+2ihfRC9uxIuph6uB9/Zyna1sMIy9Yg0B9h6xZAowcvpsACZFqiWA/ZtBt195MV7bWhKIDAAPusUSgqesHD5iosmhqb+Uk4QuJHgoyueVSzLXe1oAjrsr583L8dec1ibUyWcaCjTFW73l68gCO8UZmBOaaNxhCbPhMyt25n2jUeobmPfAXSOpmc3/JZl9+fbj3otruk3v/RIu3FXJ1hE0WmH+qowKj8KJ4k 6ASiS1kF JBr06TEIHqmYLGlTld2cRueEw2Tiip6RLCxXsK9isaIa3riKjY3ES98OPoeVaLcECiEYPTWfa3rknCLmoLZtGfv61TN+TBrn+uRtYucioXDpZbaysypTkq/SCjYNE3GPWqQ30itJwp94D66+wiee8xGS3XMN3KxDei6NX8aFFiIleb9N6CY46ezukrqcQuDxw0oFOF2YjPZHLrfr2l8BCX2Mi6+aOthdlzeUxInSfMOK4DkiraEEgeNItG8UHycWp2VrEM+FLhE/VXU+YsXHWDDUH9q1ShSaFyjEiq1kBnkK7hOpu92rYkxSV/gThG7we+Ywwl+QAwqDarFj61tyq79L8F300+yJNlvG7TGnPPEDgQCvGhXSc8QL5Lxk7THByMAXSX9ujWfoC3LCukjs4fvC+c/N4+Dbpsw0bd9Nz6Z5AAc6d+CJtz1ghVA== 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: In order to be able to limit the amount of memory that is allocated by IOMMU subsystem, the memory must be accounted. Account IOMMU as part of the secondary pagetables as it was discussed at LPC. The value of SecPageTables now contains mmeory allocation by IOMMU and KVM. Signed-off-by: Pasha Tatashin Acked-by: David Rientjes --- Documentation/admin-guide/cgroup-v2.rst | 2 +- Documentation/filesystems/proc.rst | 4 ++-- drivers/iommu/iommu-pages.h | 2 ++ include/linux/mmzone.h | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst index 3f85254f3cef..e004e05a7cde 100644 --- a/Documentation/admin-guide/cgroup-v2.rst +++ b/Documentation/admin-guide/cgroup-v2.rst @@ -1418,7 +1418,7 @@ PAGE_SIZE multiple when read back. sec_pagetables Amount of memory allocated for secondary page tables, this currently includes KVM mmu allocations on x86 - and arm64. + and arm64 and IOMMU page tables. percpu (npn) Amount of memory used for storing per-cpu kernel diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst index 49ef12df631b..86f137a9b66b 100644 --- a/Documentation/filesystems/proc.rst +++ b/Documentation/filesystems/proc.rst @@ -1110,8 +1110,8 @@ KernelStack PageTables Memory consumed by userspace page tables SecPageTables - Memory consumed by secondary page tables, this currently - currently includes KVM mmu allocations on x86 and arm64. + Memory consumed by secondary page tables, this currently includes + KVM mmu and IOMMU allocations on x86 and arm64. NFS_Unstable Always zero. Previous counted pages which had been written to the server, but has not been committed to stable storage. diff --git a/drivers/iommu/iommu-pages.h b/drivers/iommu/iommu-pages.h index 69895a355c0c..cdd257585284 100644 --- a/drivers/iommu/iommu-pages.h +++ b/drivers/iommu/iommu-pages.h @@ -27,6 +27,7 @@ static inline void __iommu_alloc_account(struct page *pages, int order) const long pgcnt = 1l << order; mod_node_page_state(page_pgdat(pages), NR_IOMMU_PAGES, pgcnt); + mod_lruvec_page_state(pages, NR_SECONDARY_PAGETABLE, pgcnt); } /** @@ -39,6 +40,7 @@ static inline void __iommu_free_account(struct page *pages, int order) const long pgcnt = 1l << order; mod_node_page_state(page_pgdat(pages), NR_IOMMU_PAGES, -pgcnt); + mod_lruvec_page_state(pages, NR_SECONDARY_PAGETABLE, -pgcnt); } /** diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 1a4d0bba3e8b..aaabb385663c 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -199,7 +199,7 @@ enum node_stat_item { NR_KERNEL_SCS_KB, /* measured in KiB */ #endif NR_PAGETABLE, /* used for pagetables */ - NR_SECONDARY_PAGETABLE, /* secondary pagetables, e.g. KVM pagetables */ + NR_SECONDARY_PAGETABLE, /* secondary pagetables, KVM & IOMMU */ #ifdef CONFIG_IOMMU_SUPPORT NR_IOMMU_PAGES, /* # of pages allocated by IOMMU */ #endif