From patchwork Thu Feb 22 17:39:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13567700 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 29A40C54791 for ; Thu, 22 Feb 2024 17:39:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0BAC76B0080; Thu, 22 Feb 2024 12:39:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F36746B0089; Thu, 22 Feb 2024 12:39:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B18706B0085; Thu, 22 Feb 2024 12:39:50 -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 96EF76B0080 for ; Thu, 22 Feb 2024 12:39:50 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 546CEA14FA for ; Thu, 22 Feb 2024 17:39:50 +0000 (UTC) X-FDA: 81820152540.18.74B1099 Received: from mail-qt1-f180.google.com (mail-qt1-f180.google.com [209.85.160.180]) by imf09.hostedemail.com (Postfix) with ESMTP id B0E7A140012 for ; Thu, 22 Feb 2024 17:39:47 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=IM0YM6bQ; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf09.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.180 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=1708623587; 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=1fcI0uaQFUEiKBIfCVy//9pH2CxpWQoJnXq3vQbUjb8=; b=3ybu99crDMoCqx6J8RFXq+t0q6UtljkmrOKel1F/5mwF8YKwQc7wMFKWNnEjQpPf8FM6Pv +iibHYtcVUgEe4FOn0TSM5Y62hyPr5Q11wZikRL6XRdbCCN/ETIyVUvfGIqiCyUIFFAVb0 6UQKzIB3PM4GErcfhc1RJjJaYH69xEk= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=IM0YM6bQ; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf09.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.180 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708623587; a=rsa-sha256; cv=none; b=aGbBj6N3NanpBiRjqBt6CA/hFz/PRNGqd2JE0d0F5axMG8nkTMmv/WVEpnLpaYr1r9T1pa YOzx9PW+znmlKibyaIPeELUcw+e1zCI+DmRUVGF9W8orD4IU/nMnkhPlgC98jVt11W7LT3 DUYWWvHyz/l5x2zCNnRP1td6SaAyiZQ= Received: by mail-qt1-f180.google.com with SMTP id d75a77b69052e-42c7c1cb2e9so47182421cf.3 for ; Thu, 22 Feb 2024 09:39:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1708623587; x=1709228387; 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=1fcI0uaQFUEiKBIfCVy//9pH2CxpWQoJnXq3vQbUjb8=; b=IM0YM6bQ2YdrGBMhPbnKTX3tp6Tx2wAYMS3pdu0jcD8ZEDlUvO5tdFjZ+1u60DsQil LMdlbA/YuBc7hLria1mmbpVUuEvOaL3NwfXgBNmd28r8hLgYj23cGyS1tLr4wgiIApL9 +vbn47q3EJ3LBB7A34rQynNr4M237+Ap3yCjP0WJ6OYoLNt+120JmzInta6lRl13Le6X XNamdhYKPq2syeBrGJ6g4p83rL+scNworUIFLtfY4NHVbh1hWx3b+4tpx6FnG1D8qWCP D0dzOFQBI/ioxSz6YF7RHdZj9qRwe76NHLqVgbph5I/5rYUW1znj89V8Q7rTtn+sF/xL yTqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708623587; x=1709228387; 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=1fcI0uaQFUEiKBIfCVy//9pH2CxpWQoJnXq3vQbUjb8=; b=Li/pEH8Dij82CnBW2JOhG/oHk18HxKpoEGeZ+fu9Kc7tj5fi5JJwRVG8Ie9fRGdHvW vbDOwedL6FdvChh5KHOnwNiM2LKQ997m3GmAnXR2+deCYFp0CAzaxdOCEyI5zXNC6I39 lUeyP3UfqbGuLmQ2kBLMG8xRLnE8yCWYNcm3aNglmw3Otc8yrmk1HRBQgw1bJTwkaXES zNX5qPQH9o1ti5DaViNRC2TUcg0dQfqFargimR7yMu3lmbvY07d4T3VgovO9d1ucw532 q4HEDK3Ylt/u8NsABFzXHX5s1/AATO0AvU9zljxpjn+laajcS4kP/Dew3LTiYm8vHetr hCQQ== X-Forwarded-Encrypted: i=1; AJvYcCVwKFWd1zuw7499MD4HuchRy0pAp6hF+oJaSnV7mlSafMSbXmVLauE0droD+KOhisf3j49akl1v/l+WMHvrGjK6i5U= X-Gm-Message-State: AOJu0YwbTBN1tVShzcRyrwzb3r9C7NADc/zgfo/+pCGtwD25zqyocsPC 5oCQYr/isjzgWIs7IzFUa04yvhU64GWPRt2fQ+7RYifOt0TVKw3kj1m5Sg43yBY= X-Google-Smtp-Source: AGHT+IFWubVhcjno/1dInfb5gL5/ufjhoDUSfH2lDjpmITwDB6XycMQX/FnyemXoGRaHGtgajuLX+A== X-Received: by 2002:a05:622a:82:b0:42d:bf5e:70dd with SMTP id o2-20020a05622a008200b0042dbf5e70ddmr29382985qtw.26.1708623586681; Thu, 22 Feb 2024 09:39:46 -0800 (PST) Received: from soleen.c.googlers.com.com (249.240.85.34.bc.googleusercontent.com. [34.85.240.249]) by smtp.gmail.com with ESMTPSA id f17-20020ac86ed1000000b0042e5ab6f24fsm259682qtv.7.2024.02.22.09.39.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:39:46 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, pasha.tatashin@soleen.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com, rientjes@google.com, bagasdotme@gmail.com, mkoutny@suse.com Subject: [PATCH v5 01/11] iommu/vt-d: add wrapper functions for page allocations Date: Thu, 22 Feb 2024 17:39:27 +0000 Message-ID: <20240222173942.1481394-2-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog In-Reply-To: <20240222173942.1481394-1-pasha.tatashin@soleen.com> References: <20240222173942.1481394-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: B0E7A140012 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 3eh13cte7agt6pd6fdraxa3k31eqbihx X-HE-Tag: 1708623587-396672 X-HE-Meta: U2FsdGVkX1/cx4Tk6IsJdlQnU8HZmn1Lk5u88fgxaxCeqPeEW5/hhhna4XWhLv48mOCZOC0L5Dy+8QPnrCV2Fj1/3ZsG6m9c9BNVRuOBCdJv7v8meppidPOPq8V153gbZE6LMHaZRSHimVRddV9HAFwdQNLYULuycSrF17ArKn70URi9l5dvyVydY9c2Wc2AkJKd/rkr+gE5Ini7P47/td03Bi63V3P5Q12sooPuih4PSjTF/C+lmEMf/jdxvosAaO2wcCy8F72GzumhEHeZue1mdI5+VKqpV2rqu4cOJK2cKER9jzl4q/XIMTnw11xryFRsaM8FGw62+UXIIDbcTFfweOadhvsBJgJIomj5CYkthSEQc9lXbTXQhZqfxhfPZ/dm0FOa0ECJqon17vKgw8GUxnKy/W6KiXDuKDDXkQ7odMxJF8AYhx075E86Thirhrsi1oEaKpfqYauwTn4acZcFNuvP6Nsc2vDh5ahi6lxrS2+8djsx/mt/PG8wga6Z1qyC7YQFz02sGUGen5OqYYaU5HUyYFo+vkujEAufhamEadKU2Jy+AeZ73uChnyV3t/lVAGJB2SU141iXG0qZYh+lpqoiQ5hfiU75JKhfvxsQGbOl5/Uo3EBkp4rsDAD6ZPo6O88y9TcOom3kq0bZGPeWtQ/7/IossR9YrqhDVFZrBvaoOp7ReIzXDkPrsYSfrpvOinQo8dXXZOALvGG7rUYAsjZD0Ut9wqexa071mKDEe32LagTjOsNb+Q8EECsbEJWkiZylPxS3xECExAW7e8M7MmIH2jvfnu9G1IMrP8js/ipVzLmkfm5g3ycaWCtJ2oGsDEVsTM/o4MkU5NnEC+vgzl1Aj659qRGTx+4hIQSapSlG2UrYrqq6HWw7qGzDmET6mtnk+daJJNeMNLN1K+e55mO4KO5Au7ih5r/BqukDsKFLnhcs9ewCkMvqCJ1GcDbhsQSr7FpZyMv0G4s 8WkBf/Hy hRhryjQpCvxBYXk7A0IUcwrM1pHMycNvqH7mYhKZDmjabnCE2GCGlHCsjhXJd17dREsdFXgFzPMGSCwH2rzfX5tBlICqFsjtynaNuOFYM8YXqIGZc0mbizZfAWx9zAKmeROIyabwBsdWQYR515L3IcczrmzLaB3u0qzXS7WJWqLeswsT3M5E6tUlPsusO31sjEnOExaRP73BrcN5b6wku9JIBGpS81kj4bkbWB6BLPmAcC8M+YgRmpTwgBg== 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 Acked-by: David Rientjes Tested-by: Bagas Sanjaya --- drivers/iommu/intel/dmar.c | 16 +-- drivers/iommu/intel/iommu.c | 47 +++------ drivers/iommu/intel/iommu.h | 2 - drivers/iommu/intel/irq_remapping.c | 16 +-- drivers/iommu/intel/pasid.c | 18 ++-- drivers/iommu/intel/svm.c | 11 +- drivers/iommu/iommu-pages.h | 154 ++++++++++++++++++++++++++++ 7 files changed, 201 insertions(+), 63 deletions(-) create mode 100644 drivers/iommu/iommu-pages.h diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c index 23cb80d62a9a..ff6045ae8e97 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); } @@ -1731,7 +1732,8 @@ static void __dmar_enable_qi(struct intel_iommu *iommu) int dmar_enable_qi(struct intel_iommu *iommu) { struct q_inval *qi; - struct page *desc_page; + void *desc; + int order; if (!ecap_qis(iommu->ecap)) return -ENOENT; @@ -1752,19 +1754,19 @@ 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)); - if (!desc_page) { + order = ecap_smts(iommu->ecap) ? 1 : 0; + desc = iommu_alloc_pages_node(iommu->node, GFP_ATOMIC, order); + if (!desc) { kfree(qi); iommu->qi = NULL; return -ENOMEM; } - qi->desc = page_address(desc_page); + qi->desc = desc; 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 6fb5f6fceea1..2c676f46e38c 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" @@ -224,22 +225,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 int domain_type_is_si(struct dmar_domain *domain) { return domain->domain.type == IOMMU_DOMAIN_IDENTITY; @@ -473,7 +458,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; @@ -647,17 +632,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; } @@ -795,7 +780,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; @@ -807,7 +792,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)); } @@ -920,7 +905,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); @@ -944,7 +929,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; } } @@ -1046,7 +1031,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); @@ -1718,7 +1703,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_put_pages_list(&freelist); } if (WARN_ON(!list_empty(&domain->devices))) @@ -2452,7 +2437,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; @@ -3385,7 +3370,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_put_pages_list(&freelist); } break; } @@ -3816,7 +3801,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); @@ -3960,7 +3945,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--; } @@ -4107,7 +4092,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_put_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 d02f916d8e59..9fe04cea29c4 100644 --- a/drivers/iommu/intel/iommu.h +++ b/drivers/iommu/intel/iommu.h @@ -1069,8 +1069,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 iommu_domain *intel_nested_domain_alloc(struct iommu_domain *parent, const struct iommu_user_data *user_data); diff --git a/drivers/iommu/intel/irq_remapping.c b/drivers/iommu/intel/irq_remapping.c index 566297bc87dd..39cd9626eb8d 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 { @@ -527,7 +528,7 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu) struct ir_table *ir_table; struct fwnode_handle *fn; unsigned long *bitmap; - struct page *pages; + void *ir_table_base; if (iommu->ir_table) return 0; @@ -536,9 +537,9 @@ 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); - if (!pages) { + ir_table_base = iommu_alloc_pages_node(iommu->node, GFP_KERNEL, + INTR_REMAP_PAGE_ORDER); + if (!ir_table_base) { pr_err("IR%d: failed to allocate pages of order %d\n", iommu->seq_id, INTR_REMAP_PAGE_ORDER); goto out_free_table; @@ -573,7 +574,7 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu) else iommu->ir_domain->msi_parent_ops = &dmar_msi_parent_ops; - ir_table->base = page_address(pages); + ir_table->base = ir_table_base; ir_table->bitmap = bitmap; iommu->ir_table = ir_table; @@ -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(ir_table_base, 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 3239cefa4c33..d46f661dd971 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: @@ -38,7 +39,7 @@ int intel_pasid_alloc_table(struct device *dev) { struct device_domain_info *info; struct pasid_table *pasid_table; - struct page *pages; + struct pasid_dir_entry *dir; u32 max_pasid = 0; int order, size; @@ -59,14 +60,13 @@ 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); - if (!pages) { + dir = iommu_alloc_pages_node(info->iommu->node, GFP_KERNEL, order); + if (!dir) { kfree(pasid_table); return -ENOMEM; } - pasid_table->table = page_address(pages); + pasid_table->table = dir; pasid_table->order = order; pasid_table->max_pasid = 1 << (order + PAGE_SHIFT + 3); info->pasid_table = pasid_table; @@ -97,10 +97,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); } @@ -146,7 +146,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; @@ -158,7 +158,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 40edd282903f..a691f917456c 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); @@ -64,16 +65,14 @@ svm_lookup_device_by_dev(struct intel_svm *svm, struct device *dev) int intel_svm_enable_prq(struct intel_iommu *iommu) { struct iopf_queue *iopfq; - struct page *pages; int irq, ret; - pages = alloc_pages(GFP_KERNEL | __GFP_ZERO, PRQ_ORDER); - if (!pages) { + iommu->prq = iommu_alloc_pages(GFP_KERNEL, PRQ_ORDER); + if (!iommu->prq) { pr_warn("IOMMU: %s: Failed to allocate page request queue\n", iommu->name); return -ENOMEM; } - iommu->prq = page_address(pages); irq = dmar_alloc_hwirq(IOMMU_IRQ_ID_OFFSET_PRQ + iommu->seq_id, iommu->node, iommu); if (irq <= 0) { @@ -118,7 +117,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 +140,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..35bfa369b134 --- /dev/null +++ b/drivers/iommu/iommu-pages.h @@ -0,0 +1,154 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2024, Google LLC. + * Pasha Tatashin + */ + +#ifndef __IOMMU_PAGES_H +#define __IOMMU_PAGES_H + +#include +#include +#include + +/* + * All page allocations that should be reported to as "iommu-pagetables" to + * userspace must use on of the functions below. This includes allocations of + * page-tables and other per-iommu_domain configuration structures. + * + * This is necessary for the proper accounting as IOMMU state can be rather + * large, i.e. multiple gigabytes in size. + */ + +/** + * __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 *page; + + page = alloc_pages(gfp | __GFP_ZERO, order); + if (unlikely(!page)) + return NULL; + + return page; +} + +/** + * __iommu_free_pages - free page of a given order + * @page: head struct page of the page + * @order: page order + */ +static inline void __iommu_free_pages(struct page *page, int order) +{ + if (!page) + return; + + __free_pages(page, order); +} + +/** + * 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 *page = alloc_pages_node(nid, gfp | __GFP_ZERO, order); + + if (unlikely(!page)) + return NULL; + + return page_address(page); +} + +/** + * 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 *page = __iommu_alloc_pages(gfp, order); + + if (unlikely(!page)) + return NULL; + + return page_address(page); +} + +/** + * 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_put_pages_list - free a list of pages. + * @page: the head of the lru list to be freed. + * + * There are no locking requirement for these pages, as they are going to be + * put on a free list as soon as refcount reaches 0. Pages are put on this LRU + * list once they are removed from the IOMMU page tables. However, they can + * still be access through debugfs. + */ +static inline void iommu_put_pages_list(struct list_head *page) +{ + while (!list_empty(page)) { + struct page *p = list_entry(page->prev, struct page, lru); + + list_del(&p->lru); + put_page(p); + } +} + +#endif /* __IOMMU_PAGES_H */ From patchwork Thu Feb 22 17:39:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13567699 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 515E2C48BF8 for ; Thu, 22 Feb 2024 17:39:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CEF746B007E; Thu, 22 Feb 2024 12:39:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C507E6B0080; Thu, 22 Feb 2024 12:39:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A554C6B0087; Thu, 22 Feb 2024 12:39:50 -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 960566B007E for ; Thu, 22 Feb 2024 12:39:50 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4E3C880EFA for ; Thu, 22 Feb 2024 17:39:50 +0000 (UTC) X-FDA: 81820152540.22.21A9A3D Received: from mail-qt1-f180.google.com (mail-qt1-f180.google.com [209.85.160.180]) by imf01.hostedemail.com (Postfix) with ESMTP id B2C044001F for ; Thu, 22 Feb 2024 17:39:48 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=ICnWzgeh; spf=pass (imf01.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.180 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708623588; 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=WCq+3vWtONMZUCcchixRvndD69tz6ABYgm5wv9T97ic=; b=yi7CRzP/19XRj25JTMJ6rAa0w6jMFrrtoWPvDKFjfQlcGHhpfiGAUciAdliBpgZ4XmGciP qI832ZkL9n6ExtESirHCq+hwWZ0H5vG3aEtPdP1w7xzYln0u59almiHrbsKVFVUmzLAHzs KC5kL/4c20kL8MQznRWJbF5n6T75jk8= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=ICnWzgeh; spf=pass (imf01.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.180 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708623588; a=rsa-sha256; cv=none; b=4xb2sVj9Z1CdakGBksuk8NAl+14/LN2bkPu/pxU0R/8rHdM6JuumhHCegvzio1uxS91a2v 5c5w4/gc2/8kQ+13iC24R9fqVRGaIBlRXqkH4To+1D+s0tn8ZWF6C2itCylqV0RccDWNk0 JHp15HFO5AMHrS4ckKcZeg0tgt+MQ5A= Received: by mail-qt1-f180.google.com with SMTP id d75a77b69052e-42c7c1cb2e9so47182611cf.3 for ; Thu, 22 Feb 2024 09:39:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1708623588; x=1709228388; 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=WCq+3vWtONMZUCcchixRvndD69tz6ABYgm5wv9T97ic=; b=ICnWzgehp7OCmMu/v99U43yBvelzHdSyFidTkbXsqi5MxuFmrs/nZ3UOZVz+MSDIX/ tYJWUDUUnmTESWTlIYFCV+N4VvL9f3V6UOsVIpcF3jS60uEsJmb3olaLVn26VV/2eJ1d 9XVc8veidNBBxCSVGjYiJVC/13+5DcAG7WhURTk0fUhPV5qRfZY9ZJEAq2w+YrjQoSYt UO7qkK3xCiUywGpPFHyxHkwEOqQRoxjpGd8/FHcv5Fgf1bpNax0LbQgSYFWyRCwXIJJI GRkTzz7G31psW+fD45SsLixNiQx94zmWbE8zelBpbe97nAfuJZyNQNaKgSzuRisSesv3 m37A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708623588; x=1709228388; 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=WCq+3vWtONMZUCcchixRvndD69tz6ABYgm5wv9T97ic=; b=s4OWu8Tb9cJPkU9h9cJDA+Qo4iU3B9dK4wiTknRup29ry7Po4+Bnk3onsiIHS82tLx IXzj/kJBiL1POUo/ihgqxzlPoDS+9GyYeLebiAbFgSUjCdNf1BXJZHy8bDPKjBZ+0fHX wx0YpsrwWflkvfRDzyn3pOGmkVyMvUo+2V//Pq8LqBQ6InY+/T+rcZDDvwPAEvkB9qLy 476XTO4nvSeh61nrxMBpBZDOUKH06LFmJDeliBtCl6wBG8oEtmAVHfW8KB0s3jlYHOvt E2AkGmnQfFMgaTWfrnWxQ9ho2P386FwRd9mG15sM2NrUme6GN2UeMfz4ZJuSiz8f5Sfq bIEg== X-Forwarded-Encrypted: i=1; AJvYcCXu1uKjZeUeVNu+aSWVS6DszJWKIbTyox+0zSrxUoFJdrVF69nnNY8FHHaK2WozmtYX0X+tNqxV1WXSCFujPZIQY1A= X-Gm-Message-State: AOJu0Yw/y3Zs6c9lVeL2h0qXhBzy5mkhsrHm1WVaNXGTptaOb/Pvfw74 2NBpyD/GRkzA39aSOkV3AmvL3GNMC8ZTVgQXrOiVtjnNNmK26hVSTxCRlHtnv58= X-Google-Smtp-Source: AGHT+IHYsjufxgrQOIaZKGAlBEgAe+E77c4mX2kxpmgTPbMZQuerhv+xRzMr0weawYHNzNvAJaqSlw== X-Received: by 2002:ac8:7e82:0:b0:42e:5791:3531 with SMTP id w2-20020ac87e82000000b0042e57913531mr1519017qtj.22.1708623587773; Thu, 22 Feb 2024 09:39:47 -0800 (PST) Received: from soleen.c.googlers.com.com (249.240.85.34.bc.googleusercontent.com. [34.85.240.249]) by smtp.gmail.com with ESMTPSA id f17-20020ac86ed1000000b0042e5ab6f24fsm259682qtv.7.2024.02.22.09.39.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:39:47 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, pasha.tatashin@soleen.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com, rientjes@google.com, bagasdotme@gmail.com, mkoutny@suse.com Subject: [PATCH v5 02/11] iommu/dma: use iommu_put_pages_list() to releae freelist Date: Thu, 22 Feb 2024 17:39:28 +0000 Message-ID: <20240222173942.1481394-3-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog In-Reply-To: <20240222173942.1481394-1-pasha.tatashin@soleen.com> References: <20240222173942.1481394-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: B2C044001F X-Rspam-User: X-Stat-Signature: jcrhwzyin356ek17xbj6ba7yzixiun9c X-Rspamd-Server: rspam01 X-HE-Tag: 1708623588-852463 X-HE-Meta: U2FsdGVkX182KlzcyzJfD87QUSo0ip9Q5S7fZKynNc3ut0/E8dLhM82O9yUbKI2YraAgC9hhOHvhUzsTCOF6vLETSPvTvk6NhtD4YbxB1S1F27QYaOY0BpX0HoLFU57jfh/xeMKyCx8QRMnCLhs92OPxeJeTT0qCqNLXD12B/uPmc0wl0lcNUQMJSXyucHUtugFAhsMunCBO6IhxH1xRkwAybbYMAT/cAZCs5TLy5JY2KyDnWqeThzKRAhENgqRhJerlzhpB1oWCNQ4EN94Z16YuiAQ0pGEg2pW8Qy1qcEzylOYLeNo2tXS7bO60Y6PL+vumZ7bzEyVLAZcMGzxVN/39+Xc6fGgDyRcp4u2EkvmzuIr3haJZ/Er4CLn11z/prnwtTc0qYar/QsMgNKKQDnmHwPlNgFj1e7ihyQquX3pwONtGhlqQHFZJI5T3osHs++ck95jGmi84+NFIZMLQ81dtlKkvlEOZaKLd6KGROUJEpbEvbe+eD9G/nHkZqN6PmIfufA3gsM1sUc71+wzaUi+jNyv7Orwd2DZtGq3SPEjzYw8Z8E3IAvYGw5W0Fw2z4aZ9lHlnf8SkZsNtXjkgfex4hf2+oAYVeguRXFZCOx+ivtNQULylvxU0klJROk8kZAk3Q8I8E7ooNd9P2Duvftf5DVjgFRZ7KXJdvjBzjA2JAVNV9GdU0lfd2kvY2FuNHfVI579f6cU1kkV6MQr9iBa+wRCFnDBioeRHCjfvGu8UVCTrAlcf89+c3dH+c3YD8+LUVrxE6PE3fpzqPncLfhYeufHvXeNOdwwzNfLiS8u3lDu8XrofrvdzW7Rv5rczZ5/t9yTblDHJdVWuMgfCqVgS3586rc9F2DJPGQWVtMrcsQBDrTeIWKalV/uOeZ9GOcxn0IgzbnWgl+grJZaELtwRPP/dz0Te7sn4uFXddkbvRfyiNiZkYNEAMWcECLLXHqQ14pcCOXVi6QaMKc+ OmaF1+37 BsULnu4897Gc/80b1x+mP042BW93cnnLbhQrhpehV7WHVdbz17HK9kQ7Eh+pldmxj33H8FIwYlqWWIZOsGMXWd1CUppbChjjbQzMXUFESWPPEpjkpj3wU/zANVdaET1uwyyznLNwYsQzcOpwOF4BXi+8xn0TIBY/VbFb7hN2LZ8rZVGVIrYot3JfynZn7JhXhlMrHXFtkFNYQBL0vZU38T0hehpamRsJfRSEpufAuT38wdVGwAUHc1PfwfmPMVhr53EgumG5VmB2XlcvBPkPF0CN9r2nDZi5X/MQdzjOqjKMSo1o= 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: Free the IOMMU page tables via iommu_put_pages_list(). The page tables were allocated via iommu_alloc_* functions in architecture specific places, but are released in dma-iommu if the freelist is gathered during map/unmap operations into iommu_iotlb_gather data structure. Currently, only iommu/intel that does that. Signed-off-by: Pasha Tatashin Acked-by: David Rientjes --- drivers/iommu/dma-iommu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 50ccc4f1ef81..fa0c4be79f9f 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -32,6 +32,7 @@ #include #include "dma-iommu.h" +#include "iommu-pages.h" struct iommu_dma_msi_page { struct list_head list; @@ -156,7 +157,7 @@ static void fq_ring_free_locked(struct iommu_dma_cookie *cookie, struct iova_fq if (fq->entries[idx].counter >= counter) break; - put_pages_list(&fq->entries[idx].freelist); + iommu_put_pages_list(&fq->entries[idx].freelist); free_iova_fast(&cookie->iovad, fq->entries[idx].iova_pfn, fq->entries[idx].pages); @@ -254,7 +255,7 @@ static void iommu_dma_free_fq_single(struct iova_fq *fq) int idx; fq_ring_for_each(idx, fq) - put_pages_list(&fq->entries[idx].freelist); + iommu_put_pages_list(&fq->entries[idx].freelist); vfree(fq); } @@ -267,7 +268,7 @@ static void iommu_dma_free_fq_percpu(struct iova_fq __percpu *percpu_fq) struct iova_fq *fq = per_cpu_ptr(percpu_fq, cpu); fq_ring_for_each(idx, fq) - put_pages_list(&fq->entries[idx].freelist); + iommu_put_pages_list(&fq->entries[idx].freelist); } free_percpu(percpu_fq); From patchwork Thu Feb 22 17:39:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13567701 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 E72DFC48BF8 for ; Thu, 22 Feb 2024 17:39:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0E17C6B0089; Thu, 22 Feb 2024 12:39:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F384F6B0088; Thu, 22 Feb 2024 12:39:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D8A226B0089; Thu, 22 Feb 2024 12:39:51 -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 BBCCE6B0085 for ; Thu, 22 Feb 2024 12:39:51 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 8F7761C111F for ; Thu, 22 Feb 2024 17:39:51 +0000 (UTC) X-FDA: 81820152582.05.D113496 Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) by imf04.hostedemail.com (Postfix) with ESMTP id C5AA64000E for ; Thu, 22 Feb 2024 17:39:49 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b="CUctCT/G"; spf=pass (imf04.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.170 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708623589; 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=0jGBGlM37DR4CmKrdq8cbF3ft7sPK0FoJu+SYmxd9DI=; b=4X+6TO+UNBsNZnpsrRn5pF3S23m1k8d09jg9EqsGJVKIk6g1hQoMK7wffMxHNjadv5i5vL fXNV3LTrwk1DOjUw3kRxJKCvqIcbGLhTnM7lKyh+Q1HPywSR1ZJwRSW0fLtcTNx7Z+Ounu uwSZ+CfQ0vG4/lwhuIf6aabprNGWWks= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708623589; a=rsa-sha256; cv=none; b=7WkBDyv1B3HOki2DHmaXnapZ5Muh8AOW4n0CjFQsR2Xxye7KVbowfxUrlOnYI5Khjs2qFW mXCtS4/BBCzhv6gh/xtqrcwu13JarDAPe0wuMI+/BJkNGndp6rgFr8QkQcyfX0hQqV4nFF ovwchjWi/ahfBsBOQ+kMtcqc1puHDjA= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b="CUctCT/G"; spf=pass (imf04.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.170 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-787a405e724so41605985a.0 for ; Thu, 22 Feb 2024 09:39:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1708623589; x=1709228389; 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=0jGBGlM37DR4CmKrdq8cbF3ft7sPK0FoJu+SYmxd9DI=; b=CUctCT/G/nxSasdcIKWS39hJDAmJYgRGSwcKUaMROmJW8NHRDNbMSiL0tHXr2CWXc4 Gdsb+yZcfeYMJ8ipTYXZJ3Xv9XMn04IIKzrPN+T7DffsrTDAPJQsTAN2yJp6rblS8KA7 KQ4oK1rpMpJN4twn4lYBWVt/+ks/3vY2t7pKG9XvoMjxzxD70BE06c6wE9qjet2ryGYj yG1SyrRfwON3STXj1c0h3TddmQK+M8QX0fOPnrtqbhhEKuFh+KGnohlbsDTMSi4UJYvQ O4ohbIbxh1FvVYf9B3FWXLcu1tkMFToAvmAXm6FIggVlnnon925drbfjv/M7z8EcIn5m LQvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708623589; x=1709228389; 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=0jGBGlM37DR4CmKrdq8cbF3ft7sPK0FoJu+SYmxd9DI=; b=P6CtbMuueB49fhdyoicQevFNtvWrB3oKuBT5ICy1wU63oY+VqFszHHoe5rD3kKOD2Z WgREij06PIDYUvyo9ajZOXBa0S0l29kjKkJssrJLE4CtHOGNi8T6uwSxBJLBop88uU4M oaQ4ozx0k+Cj5Z7viWat8cpcbtaeYZWAAiHk9jGq2qubTJphYEWTfJTAkGFi5ftsdXUe 5HY9uYeYtxv1v8lnlWq2UXpuFMJClqYtJLggaUTOqj7ob5yTuNhyr7c8Oao6SJyrp8M/ Dm5NzDJQh4QbvhFgoumg55werGj0sP/PPBWc320SsO1FCvqCMg/yirI2Ix9RLw3u04As YjUA== X-Forwarded-Encrypted: i=1; AJvYcCWd093bSTMaOK2fWcbLAf22w3pRaICyJdPDyHcv+ZSXxoiiA/v91hBw1PMWAtgdts7tXOJOJmqXbVWlPGYo7WcUiT4= X-Gm-Message-State: AOJu0YwkoG1QGAPz6gFTQOyowB8jx8nt8tAgx2eEdLxVIIkbpkTECcyu 1e4m9mDQxOaQqta5ocAYUQAA4lgcoT7mkoMgmtX58JmRF/gyfsFCLw5G4CGvHg0= X-Google-Smtp-Source: AGHT+IH+kIjLLfLyOzm9C0V9Dr7151V3H5g9HJ46A8lDyWKlgbGtjZeDGbDVECOJUtojPL5N13V8FQ== X-Received: by 2002:ac8:5c83:0:b0:42d:a980:587f with SMTP id r3-20020ac85c83000000b0042da980587fmr27432684qta.58.1708623588668; Thu, 22 Feb 2024 09:39:48 -0800 (PST) Received: from soleen.c.googlers.com.com (249.240.85.34.bc.googleusercontent.com. [34.85.240.249]) by smtp.gmail.com with ESMTPSA id f17-20020ac86ed1000000b0042e5ab6f24fsm259682qtv.7.2024.02.22.09.39.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:39:48 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, pasha.tatashin@soleen.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com, rientjes@google.com, bagasdotme@gmail.com, mkoutny@suse.com Subject: [PATCH v5 03/11] iommu/amd: use page allocation function provided by iommu-pages.h Date: Thu, 22 Feb 2024 17:39:29 +0000 Message-ID: <20240222173942.1481394-4-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog In-Reply-To: <20240222173942.1481394-1-pasha.tatashin@soleen.com> References: <20240222173942.1481394-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: C5AA64000E X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: r91y5w8mxperkw8ikt7ozqsyq8tkjcxm X-HE-Tag: 1708623589-711449 X-HE-Meta: U2FsdGVkX1+a1498XyIMwD4KFYfZAfVhKnnNiRAxn9kFbXntr4j1PK0vzXBl748IcU9Xx/SzFnFPXF9OKjGQ7Tpa9OJWz2SYEbowglXyo+u9vXLEcdg8vp5fyWNxKOhNN3XyFqeGQCL616VLKKY4PThDV/E/098GFXCMUPwxQ9RFRYmsw/zz6Wc5Cc9qhLIeeTy4TY2rdXxeh45HTkWsBQOt4jz5L7gQ3EHXrBwy5jt/HII6oVe7wM18KR9MrKRUvb5nYAblek/Rvuzol7S8uMnvMhMk5prHPOnIBvxU0VmCCtEsPdcIYP9Bs1rZEmJY60bvb6uSW3OA2utB7nfxqYHlxoL4yCXb03e2x4yOArt3Xq50kVL7hHoXeVy7BuLwKYtDDmqfUVsdqFeUO1WCxiHH4+OzFjlNZS6kY7wN4qmhLnxQk3gojsS26n2dODSSKo2H1i5gda5fCTQk6iBtEV2Wa62ntH5ZYWqoofwkHQgLfuj0KqxiGA4kc5uEUaCWK+n9tNZCt6EiowoMbqfpzQsSSrNC2kU5JkeDP1zsmcSbNSo19Pf3+hCOIuSh1z4J2x+c5B51zkxYX31OJtniN7BAPDzaZzohTiE1JgDBrTWGapoRL9dO/LhOJ6fnWUldWvUTvmZyUZxuCyWZbIKA8MTT6gNBmHTEosgEQcltyehhrWNhrkcdX0ztIyoa0h3L2Bpj9PEhY9Qj0hW0qnPQ0LJ3ku6/iXoIomiw8xamZw22v2dYqtL9rCtLtXhq7z9u+OvYDBxl087w8SI5q1mGxTNCVp/HL0oEcQgWR9pwSNRR7GDjeIc6jAnXyw7iYIVpzUjI4e0uzViQyM3Qowmj3e/vSlwpJhPFQH8qx8b9kg+SVH8R2PWM7uoL2FfRY3Dq5o/denu3CXYNBnEUJy9uOUC7SPCEwbi1l6nsHDUMvumd6cK0XZALTp4cGJc2uNrwUJcfuL1KArKhZRetduH N/gCD1PU BxeqngReiElFRHq6nK3B/ZN0ubS9ZG43GzKfdETDDzpHXHTJN1C6Ta09b4D4Qi4QtlF6pvPE/Sp+w8/Gn9vcgsmTA0yHi8f9m4/uU+9SHMusYWZ52dNa1+MJsQM2VP7viEshFgWeyJsxNCQPIwiyaHse73bF/vlnUm7gK1g2DrT9n/LsW84nCjJNgH6ahfT7dOWQBLKT4dnFaS65LpNd0JFVDEHNt6WcY24FMPgVu7VoK196xmpnKrcq4NYfJSao7gRsUtb+wnMzMrmodhuZnnkFdB8aqi29TDnsDZJ45swVNH/S5igzDOD40NdWlbWeuE5f1mGxa8p0FGc0yWk3n9ze6O01pTqWE6JjMl9zYpw2wHuSXgsIHa/mKN7fwAPSCFQ7JK6d1xpCknsJ9Kw3djm/zC016m87op0HLXwOQFSrAaRKEl9UnvcurHPmdjhOxAapXWw278TV0W4iD2lnkFPLQoMf12GbM+nFmslft0A+WH8vIJjVc65B4yZazGQqg2XgNrkqtuZYw1+Ermd6CqczywlNQptKj3sLOXsTbb0rHzXmXqv+O58BERk7TyiKR1fgw 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 Tested-by: Bagas Sanjaya --- 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 8b3601f285fd..9270c820a2ab 100644 --- a/drivers/iommu/amd/amd_iommu.h +++ b/drivers/iommu/amd/amd_iommu.h @@ -142,14 +142,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 c83bd0c2a1c9..239ddf46426f 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 2a0d1e97e52f..9d9a7fde59e7 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; @@ -431,7 +432,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_put_pages_list(&freelist); return ret; } @@ -580,7 +581,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_put_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 6d69ba60744f..477371b1ed54 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; @@ -374,7 +370,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; @@ -397,7 +393,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 4283dd8191f0..0c7bd09ab617 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)) @@ -1637,7 +1638,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); } } @@ -1665,7 +1666,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); } /* @@ -1692,7 +1693,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; @@ -2074,7 +2075,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); @@ -2089,7 +2090,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; } @@ -2762,7 +2763,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 Feb 22 17:39:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13567725 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 02CDDC54791 for ; Thu, 22 Feb 2024 17:47:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 667146B00A0; Thu, 22 Feb 2024 12:47:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F0156B00A1; Thu, 22 Feb 2024 12:47:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 469336B00A2; Thu, 22 Feb 2024 12:47:49 -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 32B8D6B00A0 for ; Thu, 22 Feb 2024 12:47:49 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F0D9EA1489 for ; Thu, 22 Feb 2024 17:47:48 +0000 (UTC) X-FDA: 81820172616.26.748E58D Received: from mail-oo1-f51.google.com (mail-oo1-f51.google.com [209.85.161.51]) by imf13.hostedemail.com (Postfix) with ESMTP id 349EC2001A for ; Thu, 22 Feb 2024 17:47:47 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=Q3n+VrnL; spf=pass (imf13.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.161.51 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708624067; 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=C9sOCaXXTnuRzyvLt2S+i0eLigQNp6D64P7FATFt28E=; b=vE5uj5jYmQ+5jfc84t+hRXp4We9rzcIJPrcDgYq82xCm0BVTcXl4Ups63jYYguChZbHnN1 LiPv9ZgdeaZg6lDsKXMMRXG/fYBG2m6FKLESjT4NBNoMaBu9WP8tQM9nk+8y6XE0yJcwyX 8dHWyu7hP8qisBx67F/9b8ihHil6BZc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708624067; a=rsa-sha256; cv=none; b=jVQ1QLtxQnpBPQr8oU+2KDHBHb58Dqi9KyyDekkeNcT++s0PXNUNpFlCpCXfzpihucPikJ P12UpsB1BFwUBxARDx2qd8AJdHppM1sUU6e1DF6zJD38N6gHCWEiCDxGG3jomhTyqFJxAR P+4MqmnktyRKiQinWlmylvPkDgIv9D8= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=Q3n+VrnL; spf=pass (imf13.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.161.51 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com Received: by mail-oo1-f51.google.com with SMTP id 006d021491bc7-59fd6684316so35488eaf.0 for ; Thu, 22 Feb 2024 09:47:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1708624066; x=1709228866; 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=C9sOCaXXTnuRzyvLt2S+i0eLigQNp6D64P7FATFt28E=; b=Q3n+VrnLj5Fwa7Ic1KQnMLOELJSuBOTkr5Nt7qGSj8/BHmJcvO/m0D0TfPZIJnHM9z 1hcYi2mJ2qhTZyQJLY3A0yZMbVPmrKxrG2n1sGR9Kt7lioF7czVUpTs6aPB6PR9gWOH+ UCSfRew4H9LI3UXMROc7S+rVfbA/a6rvbfnayZPvl0ByuSSJfmY84NLFNB/86btUKnVe pKLdHiG+84Ysxg8eokj7KYgkOkGoZBjrLl9EDR1g3UnET7pO/RoIsBzFtCKJxHeiJiUT obVx4tC1kDbjBCRByA/0e0pZL7DhytZEvgbgkf88GiBm9SXlLzuX3P4qXb09ump5Pndm SUFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708624066; x=1709228866; 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=C9sOCaXXTnuRzyvLt2S+i0eLigQNp6D64P7FATFt28E=; b=aUBzcEhy0+PC7FzHjiz6AyStfVeFoGWkGraMfbyz6Sv2M4Fu1mKfx2iwjzNUQUIFYx bQ/UbzaOgl9Sjk7BnDJAPYhS/Gi3CSFxdo2I5GsjimkoowHQb5WlalcAjkW1IUgfHNMe +Mdf3/sPsrUpypYL8w6xsJggszJYYVIFmC9csDzc91RtdM6h6CAhwcq2kv0/WvCIYKuY 56HqjfUebbG1qp1RP1ptOCcxHKvHptsSu9QD5BTBHrpdNzOBQLJ+hG8ULd6SwQXUi8P9 TCBO8m4cqdXG4gz0EqubGf0dnMfCDOCmWaa76NUuJCAI0TSb3kWW1eYHmy0eIawh/luO 5YQw== X-Forwarded-Encrypted: i=1; AJvYcCXWJ+07pI+1Y+rnfwVRZALfSTdjDQaZJvOVrJ4pIUCTq4yQ+++ERKd8d7yH7EQQujYddvymNarnKc9JqWYGDyU44s4= X-Gm-Message-State: AOJu0YxvR8NekIdxRxh53QJuzShPOTflDgnARPt677GeH6O2x+JAgNPp 0UGdxnshQLINs4ufDQkrzJ7fsu56P1pCKEgWNi2gwnhyXWdK019I9xt0XbOK21gKmYbpWBQG7pi W X-Google-Smtp-Source: AGHT+IEnNHT8mmpNAC8qGBK3waMn+7XKEftGRHH+gMR5BoK6c8bTMJMeqnbIkBxo5nuTApw4Lzgcmg== X-Received: by 2002:a05:622a:103:b0:42d:b355:1538 with SMTP id u3-20020a05622a010300b0042db3551538mr27425174qtw.55.1708623589605; Thu, 22 Feb 2024 09:39:49 -0800 (PST) Received: from soleen.c.googlers.com.com (249.240.85.34.bc.googleusercontent.com. [34.85.240.249]) by smtp.gmail.com with ESMTPSA id f17-20020ac86ed1000000b0042e5ab6f24fsm259682qtv.7.2024.02.22.09.39.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:39:49 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, pasha.tatashin@soleen.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com, rientjes@google.com, bagasdotme@gmail.com, mkoutny@suse.com Subject: [PATCH v5 04/11] iommu/io-pgtable-arm: use page allocation function provided by iommu-pages.h Date: Thu, 22 Feb 2024 17:39:30 +0000 Message-ID: <20240222173942.1481394-5-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog In-Reply-To: <20240222173942.1481394-1-pasha.tatashin@soleen.com> References: <20240222173942.1481394-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 349EC2001A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: fadxan1e3xsw76o9g7acuh6m7pwcbgoe X-HE-Tag: 1708624067-689955 X-HE-Meta: U2FsdGVkX18jVIBirzJYz5IKSG+gvPKzCdmFap76GMvxOA2WsBFxW+r8edbF+XM1+ZHDl87INlyuBa5Aze4eV8aXOdhSPx9Zsofjl8fso+v8TGKlV4h9FeiGRDVP1rIiaSVkZfaJxS2D5+60Hem6K+hrH+95rr/bp1wLcs0gH1d0Bh4k84gGxnwhHRceG8zYtEHLkb4Mtus01FzLYv5X/6qEHdqeDOycPRrbb4+0ShkvTUonjmq3yjeZoS39rDjqX7uHbUfrVxr77F1OOTqV1Vl2QzDWL/x95MRnohSPvAYtN2KsWaddlVIGm2rUonr4qkd50eW+SKpaHflOJAfiFy5DmtLemS9lkEbZkR46mKIU5QOILxztPctOhNCelgmC17Voe3ls1Yqxdj2i0prkYlWLDtpap/7dmmNKmLD9KgJNL30KRBFSiTCoR9pOYgzfRyGcr26z9LUSQoAAiRSfmteFNuhWll0n1DQr7OlzhvtIPE8qTShaoragTyAoREjn37Oyd90oBcxcCGY51wjr57sOg0WsmQ00FJnJjoShgge+0HXksXfL8Cpq6RgB4DcpdnjeNqc4KK98Q3Lw3RtUVdTeyfeLR0O3EPImNbcgsEP0HNWbknwP+eel+nNGAwJ5IHpKe+RJIdDn3bU5ObsmHS4Wz53+ELW8bbabWP9kuJEKStVZnQpHsrahXs/FmaqqTfJb9213s4vzGZ+eIqy+Csba5I6u/VCDQIaiSdDKYi1o6G+54X+gYhb2T00hhVNgI6f9fVLqSg/zWlok+2u4lGdm2zjztVlT0JJl4XYqIv2UJ1gNb73vdf9neFWfO3W0m+IEdXTE7d1YgsPS/amXYZsELUcfcnVrpcFKY1DMMXwY6K4Q4LNe+LbDT/N7eRSaMdJ1TmyHO77Zhnk2n8gQCISuVbn63j6oAD3/pKqzeY9XwXj4j2J3314sPn2MOH5dpQ92NmCqVK+SCQEC6TH upOmXbdW 66hFsN+dTPEiheh+IdbK9sJPm+NWgDwM7qtPE48K4O/hMvX10XDBCYdSXvUAwSC+TRBI9T6eDcS5LCM521GtHxjxVhqzuL/tKO2CnbFlpVD7xnH4qY9lmHsXypk90Eje0SVa1ZbnQR9RQk1wC2yuAE+/ms0QsC8b/2b3/fkn3U4vnjyLQrZkWcjgo+kRUcej92F1uTnKCAfDFXCSr4jCT3xmicUJR1/8Y0YqWRZAaC616Vo0EL5Edg9rqxPNZGlD5HnElclreKsBg/DO3ZEHXjF/zENqlVLml2+Z7L9uZzlSP7Y1NnqBjwz+/cDfAxcNLoMn0CgJki3D/wq0YHHG9qsbhBkeotJeRRE5+IFEA+qDX48JreDx8W0lIECQMw6FsQ8CiJtzsAJ3XdPj2y7fiz0JPXc+jjOAEBODrQ2zcFO7Cw+Zo3BKrIkfQYEcwhf7PqFJiAgtMqFKMqyKBW0iUnOkaNuOqwjM4T/ux8yfmqXydEvQn40D3cgA0ZLL9Rd/r7zMw+d4Wbe0wyIZnxdv94BH5r2pvGjnvGLlSyzincY19rvacICIc8uvgaRKRzLWOM3pg 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 Tested-by: Bagas Sanjaya --- drivers/iommu/io-pgtable-arm.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index f7828a7aad41..3d23b924cec1 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 @@ -198,14 +199,10 @@ static void *__arm_lpae_alloc_pages(size_t size, gfp_t gfp, VM_BUG_ON((gfp & __GFP_HIGHMEM)); - if (cfg->alloc) { + if (cfg->alloc) pages = cfg->alloc(cookie, size, gfp); - } else { - struct page *p; - - p = alloc_pages_node(dev_to_node(dev), gfp | __GFP_ZERO, order); - pages = p ? page_address(p) : NULL; - } + else + pages = iommu_alloc_pages_node(dev_to_node(dev), gfp, order); if (!pages) return NULL; @@ -233,7 +230,7 @@ static void *__arm_lpae_alloc_pages(size_t size, gfp_t gfp, if (cfg->free) cfg->free(cookie, pages, size); else - free_pages((unsigned long)pages, order); + iommu_free_pages(pages, order); return NULL; } @@ -249,7 +246,7 @@ static void __arm_lpae_free_pages(void *pages, size_t size, if (cfg->free) cfg->free(cookie, pages, size); else - 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 Feb 22 17:39:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13567702 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 996DFC5479F for ; Thu, 22 Feb 2024 17:39:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B1E226B0085; Thu, 22 Feb 2024 12:39:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A55026B0088; Thu, 22 Feb 2024 12:39:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A77C6B008A; Thu, 22 Feb 2024 12:39:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 70E9D6B0085 for ; Thu, 22 Feb 2024 12:39:53 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 27CDB40EC8 for ; Thu, 22 Feb 2024 17:39:53 +0000 (UTC) X-FDA: 81820152666.23.D48D0DF Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) by imf08.hostedemail.com (Postfix) with ESMTP id 8528816000F for ; Thu, 22 Feb 2024 17:39:51 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=0505KPtW; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf08.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.171 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708623591; a=rsa-sha256; cv=none; b=5zpCiuNvCHpb4KMdGFxhbX+DkSbuaiHhxDW9R3OrtIrG8F8Akefa/MuaKdnaYeY5y4Fgcy 2OxsweQJWyU25JOx1LzxNch9UBJpU3BXN1OAN/FVT1FUeZnRTWP0j4CGSr8cPLDX7PyZ7k 0tu4ZC4Y2nzgm/M5w8iaSGeLquNC3u0= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=0505KPtW; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf08.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.171 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708623591; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xhLjauiol2hX/CcN6wSXepYqvX9ekQ41OuBb1dZBQzE=; b=I7Da08g9pcccC2ZQtLKt42gZ0X6iFGxSXnP9oKwvAIsB3WM0VQEn7W0L2VUbtH5JtsXwIV 8i0AcdtIlzkVW1LTPJal06C4SB0RNfjrnoG+3QSLG8qiepagm05CPEw7b2AtrpHUU5WRsW m8ujVd8WAgaPGbykmcrnk9s7U0fUh6s= Received: by mail-qt1-f171.google.com with SMTP id d75a77b69052e-42e28e0e879so10647671cf.2 for ; Thu, 22 Feb 2024 09:39:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1708623590; x=1709228390; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=xhLjauiol2hX/CcN6wSXepYqvX9ekQ41OuBb1dZBQzE=; b=0505KPtWIVduFIhnEzkeRD426yFuz2SEB9JWgItAyrtF5qBkZsF0E6YmsBEI8CzMRl zX6U39WmY1QfBj1+obH06Y8d4dE3/AQgHm9Cl/IIKLwP7YTMB6fg8nJF/euI95T8zyWl y0CrKvo1IkF8HbG2UCyBx14NHPcHQz8umFgT6J9MgULh4DlqR8cbwV3l8yXS8gmpeYVe x9m5ppHtJu3VinDWNhZfgRTq5JYA2PzNuWJ2UQvjUKZF8ufpCi0uMqV/B6HcZqeiO2AF FmIj+OihY8pLsmLnfz37oILZgmX0fF6c1d9GD7V0bZfi3hc1ip2ow1e9fKfp/Zcir4ET FPsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708623590; x=1709228390; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xhLjauiol2hX/CcN6wSXepYqvX9ekQ41OuBb1dZBQzE=; b=jt4U4dJDS7MnxsV38cCBv6D2D/0AAgzKIi6kMIQQ7C4QcrRI/ViWEp69RR2h4Ymqb9 VX318RiBuj0L3uK0OFBlCeTiLtJ3dFD7QWyvolcvL6T1dvnt0PmP5LaoG4+7vLyIf0Ub K25CGpaW4iDXVMg0oc9jxUhJ461KZW7iZleFG3e8M8Ji6A8uLCuCaA2z4nYuR+mVUXMH IKhngzIyXJSfTaM3/5zBdQ1TSp8utfpAF6rEnOSoTBksxQfRrvojb1zNf4486pKnluvx cWACSCNuSR8rs6hNZIj0m0OVZriMnAX83PhewNIouV+Z/EXmG5tBFPeFhP+3x7xsSDem orsg== X-Forwarded-Encrypted: i=1; AJvYcCUdExYvIbiBEef5+CE447MBlbZuiL59mCvzqA2LTw08gpu+XN5OYa9eMw22WkSR11pB21uAAX9JymMHqYIk+veQg+E= X-Gm-Message-State: AOJu0YzefalBmRJQBCtZ7BYjhO1D6c+QNbIUWGNtTdQWtmBymuXS/AGG jyY03fhm4WWdFAzye9Wi7zw+3ap7AhFUeVVnTi65YCtZlFikxgO7vZGuVpcA5rs= X-Google-Smtp-Source: AGHT+IEp4MwFnGzbjUWvOKNS7CvUx1mMeLXTjvER84y2unxVOxwU99/U/wStbNygCnfZAxx//dKL9w== X-Received: by 2002:ac8:5b84:0:b0:42e:3bf2:89ce with SMTP id a4-20020ac85b84000000b0042e3bf289cemr5044762qta.49.1708623590514; Thu, 22 Feb 2024 09:39:50 -0800 (PST) Received: from soleen.c.googlers.com.com (249.240.85.34.bc.googleusercontent.com. [34.85.240.249]) by smtp.gmail.com with ESMTPSA id f17-20020ac86ed1000000b0042e5ab6f24fsm259682qtv.7.2024.02.22.09.39.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:39:50 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, pasha.tatashin@soleen.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com, rientjes@google.com, bagasdotme@gmail.com, mkoutny@suse.com Subject: [PATCH v5 05/11] iommu/io-pgtable-dart: use page allocation function provided by iommu-pages.h Date: Thu, 22 Feb 2024 17:39:31 +0000 Message-ID: <20240222173942.1481394-6-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog In-Reply-To: <20240222173942.1481394-1-pasha.tatashin@soleen.com> References: <20240222173942.1481394-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 8528816000F X-Stat-Signature: ro8mppxwg6x54t6ito1aoarajhrn6pq9 X-HE-Tag: 1708623591-891885 X-HE-Meta: U2FsdGVkX19gSys/MTE8l9HnNmrwhpAwBUT+q6I9NlUNPoRNarC8gLV0FBkdFGJDnIh0VF1i79v9q6/oYP1jjGDUOvY28DoDJ480ZyWGExiW9BY7O26tkToh4u+Llm88LD26raCHkzxpr890v9pMKitxPe2Yqk0ZwphMUdxaJcudX2y7pVKOC7mIr+RUT6Lwj/hbwxUqGzHlPUQifmbeG6x9d+/c4LXFpoKQvb2nV90I89fTwZKBSyhuECgaIVs0KFEeTp6bUaZ4D3a7VuMm+5JzpMVzAXwefxlyKhb9ytamuT8/3fIlJRtb11Gkd2UkxasiSNysMFfsRKn3eaevt3v4Iljg5Us+yO4TgxX6tg9nJr7IMxwsn8uljzd99ooBAWgvD6ljMOpJThSSToU8mVYmFjfaFuwjvc5qzSPTrNepK3Og99g3rau93JiPS0/483UHW3eb2rL3sW5XFay4ua3l2uPKj1xbHq7nnZJVl6XjxYVKSq1tS5i/ZXIywuSR/HOexP3scbCzUgnksD2AX6P52ejvd8yphqHijmVTE8FEirvCW3TLvIPQ14RYd84BqiHd7aMAfbwFtZARe3j/49MAyNc+m77oX9SmjK28RscZfn6kXCKsGvJ8RwHNEhHiXGfAOfkLuikJMuRHoJyZKb8NuvuHdyUPYQofu41oTcDDIAciHHNwG7SOtIkFAI/wC5eKJNSVMzZPzTK4PpWkJV4N3U6jDa6MxhMDw4hNF4kqe/5wCqzqUtrJz0bkcdtG9Exs/uOBM4+Y+/suy0j7HnJeYT6P3myjPX7ky3b0ibXCFcC0EWTqqoLQmF8yUeSpPpRThQ02xYfYGUpJRDhk8HDi4EQGzFaX0r2VzrbFlb8hYA/B5jF/cw8dtmT2eJob4Cdyi5fZ1etrrrpvQwgaURG8GUa7pUE6zwZfHmj0uNYpUQgikmkVQPnCSNxqznk4XIXBeoYNfSMcntikgk2 YFqrMfYK VE8vk17V/gK5qIByqR2ck0jEr1qevjKnE35+5aiE2eSvFK39yGTa1+12VmxSyY99Z3NGIjiSoYnwm3y5FjSWNaeK0d4Wr+2IpqhWjPXsG4aD2cASGc57X7KwMZ3qfJazOXAIZU4t8Z10nmNMHmFEmM1tUWnvzFofSPNbim1BXARqB92CHgVwxAeNdrULOe9p9kO5gv1WhuDExOHREHQWraqQI8hdytk1i7w8p9O1maXr224iCXwKf+KQysA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Convert iommu/io-pgtable-dart.c to use the new page allocation functions provided in iommu-pages.h., and remove unnecessary struct io_pgtable_cfg argument from __dart_alloc_pages(). Signed-off-by: Pasha Tatashin Reviewed-by: Janne Grunau Acked-by: David Rientjes Tested-by: Bagas Sanjaya --- drivers/iommu/io-pgtable-dart.c | 37 +++++++++++++-------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/drivers/iommu/io-pgtable-dart.c b/drivers/iommu/io-pgtable-dart.c index 74b1ef2b96be..ad28031e1e93 100644 --- a/drivers/iommu/io-pgtable-dart.c +++ b/drivers/iommu/io-pgtable-dart.c @@ -23,6 +23,7 @@ #include #include +#include "iommu-pages.h" #define DART1_MAX_ADDR_BITS 36 @@ -106,18 +107,12 @@ static phys_addr_t iopte_to_paddr(dart_iopte pte, return paddr; } -static void *__dart_alloc_pages(size_t size, gfp_t gfp, - struct io_pgtable_cfg *cfg) +static void *__dart_alloc_pages(size_t size, gfp_t gfp) { int order = get_order(size); - struct page *p; VM_BUG_ON((gfp & __GFP_HIGHMEM)); - p = alloc_pages(gfp | __GFP_ZERO, order); - if (!p) - return NULL; - - return page_address(p); + return iommu_alloc_pages(gfp, order); } static int dart_init_pte(struct dart_io_pgtable *data, @@ -262,13 +257,13 @@ static int dart_map_pages(struct io_pgtable_ops *ops, unsigned long iova, /* no L2 table present */ if (!pte) { - cptep = __dart_alloc_pages(tblsz, gfp, cfg); + cptep = __dart_alloc_pages(tblsz, gfp); if (!cptep) return -ENOMEM; pte = dart_install_table(cptep, ptep, 0, data); if (pte) - free_pages((unsigned long)cptep, get_order(tblsz)); + iommu_free_pages(cptep, get_order(tblsz)); /* L2 table is present (now) */ pte = READ_ONCE(*ptep); @@ -419,8 +414,7 @@ apple_dart_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie) cfg->apple_dart_cfg.n_ttbrs = 1 << data->tbl_bits; for (i = 0; i < cfg->apple_dart_cfg.n_ttbrs; ++i) { - data->pgd[i] = __dart_alloc_pages(DART_GRANULE(data), GFP_KERNEL, - cfg); + data->pgd[i] = __dart_alloc_pages(DART_GRANULE(data), GFP_KERNEL); if (!data->pgd[i]) goto out_free_data; cfg->apple_dart_cfg.ttbr[i] = virt_to_phys(data->pgd[i]); @@ -429,9 +423,10 @@ apple_dart_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie) return &data->iop; out_free_data: - while (--i >= 0) - free_pages((unsigned long)data->pgd[i], - get_order(DART_GRANULE(data))); + while (--i >= 0) { + iommu_free_pages(data->pgd[i], + get_order(DART_GRANULE(data))); + } kfree(data); return NULL; } @@ -439,6 +434,7 @@ apple_dart_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie) static void apple_dart_free_pgtable(struct io_pgtable *iop) { struct dart_io_pgtable *data = io_pgtable_to_data(iop); + int order = get_order(DART_GRANULE(data)); dart_iopte *ptep, *end; int i; @@ -449,15 +445,10 @@ static void apple_dart_free_pgtable(struct io_pgtable *iop) while (ptep != end) { dart_iopte pte = *ptep++; - if (pte) { - unsigned long page = - (unsigned long)iopte_deref(pte, data); - - free_pages(page, get_order(DART_GRANULE(data))); - } + if (pte) + iommu_free_pages(iopte_deref(pte, data), order); } - free_pages((unsigned long)data->pgd[i], - get_order(DART_GRANULE(data))); + iommu_free_pages(data->pgd[i], order); } kfree(data); From patchwork Thu Feb 22 17:39:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13567703 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 7DE8EC48BF8 for ; Thu, 22 Feb 2024 17:40:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3A15B6B008A; Thu, 22 Feb 2024 12:39:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 32DF26B0092; Thu, 22 Feb 2024 12:39:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 153C96B008C; Thu, 22 Feb 2024 12:39:54 -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 055FB6B0088 for ; Thu, 22 Feb 2024 12:39:54 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D5509120F12 for ; Thu, 22 Feb 2024 17:39:53 +0000 (UTC) X-FDA: 81820152666.15.BFD1A71 Received: from mail-qt1-f180.google.com (mail-qt1-f180.google.com [209.85.160.180]) by imf04.hostedemail.com (Postfix) with ESMTP id 2D2BC40017 for ; Thu, 22 Feb 2024 17:39:52 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=eF+QgYpc; spf=pass (imf04.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.180 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708623592; a=rsa-sha256; cv=none; b=yToRP9ha4ocykYUGLd/y38/H1KAgZ1G0WQZsCDcgp4ozbvvkU/6KLPxCJDK3a6dg/l2z9D fyTbf39Iy4fmm+EoJ4C2szn72LsAxs50WBdim0oLvHYMHwJumka+OJQrI6ufG1nAcoOaSI lh5Jewil9hr4EygIwdTQY368ZtyUwCU= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=eF+QgYpc; spf=pass (imf04.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.180 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708623592; 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=g7w3BmgXmvWecR5SKtsZ1cNA/rDbNvV1OeS7wJNdwTQ=; b=sFxiOyduUEJiVStaoKrhfJWfNRwWruc8AFhUgv9Rso/bcMFwsPlPRYKRKlowgBRnoQhRFU jtcLCH/9q7QPx5czhjnUx30y+1mhKoxHqFsu9P5IpMj0ssrvsSI87WTLmrQjpYF+vBupL5 qzl6he+WQBcpi6cVhgduYQBeLJAMxAw= Received: by mail-qt1-f180.google.com with SMTP id d75a77b69052e-42c758f075dso10246901cf.0 for ; Thu, 22 Feb 2024 09:39:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1708623591; x=1709228391; 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=g7w3BmgXmvWecR5SKtsZ1cNA/rDbNvV1OeS7wJNdwTQ=; b=eF+QgYpcKANedrRWyR2TmDqE/uGtHWlgcKI8h4QcbvJhLOQfDEd0Fi+ZPy2Vpd1uUP C/9Ag7gcVL3h0IdIqKf+PujOvJU9mkGj9DyRUV5VDpbJknQCrv30Ti5YFx7af1jTChcO xPb/HttME35hUmSuwSp5qTifNiYh+P+Mp9IfTcx65p84O/IaeYFqGoYgQnWjMroV2u9J o1ymWdh8Dw0KRWyRfHMgyxnUmRK9GW5txKVadwPEIc5bEer0nb7sib7SBN7qZOepHFJB 9wAB16j3QUNNaV8osim/JVz/oP3ifiHtKoK8eI7/oqnga6INkb/bUnYXgU7XMIXS6/vE xqNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708623591; x=1709228391; 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=g7w3BmgXmvWecR5SKtsZ1cNA/rDbNvV1OeS7wJNdwTQ=; b=bkgeUiycIOnAq3XxKBctF97eEjXlD1ta+tTIzjSqfwXFcFYmCDos42YSasXm7c1RyD QT+tl5/JPYRw1/7brw08dix18U58GqEoAv2Kkm5IyWd+EmkBRhcmBpxKrw1bVVW3R2bJ r+ajcL0Wp66kwrvKE8cXOlaEp2y23h6cRrVzcFaRLxlCKrDk6wL6Z70xHwWFYdBBuSTu ycnRotEtlQxaDppbQH45fLtVQw69jALM7WozNOLvdmkbOS6F+mt2vWXT8cyjVbVx0wIY mKOsL7zMnSPMgi23A0CNR4IjRQ5Ba6Cdjq4Jv0uqqsZQX5fcnN/1k8SHIpieXdUlQ72u Ajqw== X-Forwarded-Encrypted: i=1; AJvYcCXQV3NKavpGtyhsaBVbmtWgUAakDjQhwDxrmGhQoik4rcRI9w31X72VKhLtqQ9dWgzQmAl14DPrB4ghWAbXwTDt2PU= X-Gm-Message-State: AOJu0Yy4Uu1FXkLBt3HHfsuYHOQ5tF/+jh2ZJlDuk2Y2Tis5xHZWM3Sv Y7c6++EpbAJs/WZfD4nHzNGHvCRmiwTz+KNuZUgUCUetuf7/mnAvXq8qY/7QfoY= X-Google-Smtp-Source: AGHT+IG90zBa6YLMZGIfCYT7Th/1b5UWVffhOhrq9tGqR1mvmgjPkxAiIwv1iDqI+0/4uYQJoXyfRA== X-Received: by 2002:ac8:4e82:0:b0:42c:8054:8a with SMTP id 2-20020ac84e82000000b0042c8054008amr5212735qtp.27.1708623591384; Thu, 22 Feb 2024 09:39:51 -0800 (PST) Received: from soleen.c.googlers.com.com (249.240.85.34.bc.googleusercontent.com. [34.85.240.249]) by smtp.gmail.com with ESMTPSA id f17-20020ac86ed1000000b0042e5ab6f24fsm259682qtv.7.2024.02.22.09.39.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:39:51 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, pasha.tatashin@soleen.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com, rientjes@google.com, bagasdotme@gmail.com, mkoutny@suse.com Subject: [PATCH v5 06/11] iommu/exynos: use page allocation function provided by iommu-pages.h Date: Thu, 22 Feb 2024 17:39:32 +0000 Message-ID: <20240222173942.1481394-7-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog In-Reply-To: <20240222173942.1481394-1-pasha.tatashin@soleen.com> References: <20240222173942.1481394-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 2D2BC40017 X-Stat-Signature: wxr9hsxcx14szftf71n8xrr69zxybe3a X-Rspam-User: X-HE-Tag: 1708623592-655265 X-HE-Meta: U2FsdGVkX1/um/YFNBT0ati+SkrI3iw8/o4aLWR5Shx4TIgFLUH0JL9ozagUWlAJMARv9nmHvKl+POvUTGoQ3kQC+EKNZ9R1DXgPXGQq4Wh/MWK0BtLP6rMBS19fpsARJtfiLAdHps+sCF41CBvRSu3MRilynVgVxuT14lu9vxOVMJ+uX9fkvMvBYb+9NCttUOqLURmoPLGzPo9jBJ4Q2O9oYCRFghaoVDB5nVtydtjlyNVpWrWYg9XqCzgI7v38DVY1buM3Unlm86+m0s0d9YBokzg1xAkeunkOGuZ3JYWFpJ3cCZ6iDolDvmpOdVBLZqYHz8pWmxEkkz/NKI3pfqpZjBqK5zLUPmzh43jR/KoN+xHeXRl84DdF67qwHjmh3k8QzYoeurp64N7YEw9GT3DdaY0rlEMORF1ILXrW1BVNSLD8rWJFID4z5ncbvPWLjqCf3aJptETi76z6L0CWLGtL/0/t4t+knIC0my3jYFYrNrzg3bw72Bpq1UnLcsNTeK1IMRD6BWcdLdJaC15X91QfAnOtt0Hjx2Umx9sQWR4X/FhircVoUZhrxLK0ojDxU/Cnmv4BBBR4xDUNexFdDOtKdCSaNavWwDPzqerotpwdFuPPktXTx6mC1Ud74azM9aiPs1X60v82brggduVeo1JPPoNZvtSpSht/rJLAaMNMwSHf8ftOwRsPlDDSUomNVPSsPoOWOCFSLLo2lMJ8nUqiYNu0udQGHICDPIA4xbktGytulwJpdKnKwInXvHiz54+EqtqKg2Ljn+lTp09QHvDJ+d1RWfqOCYX1cZdFgeNKoH+UqLOV7H1TctvTSrDkNxHnVKsZIe9wqNzIKy2RMA6FeK/LoK+MNUbJbEsVj7nxo+Nc0eAfz5i62m97YZnE5N/RGwpFPwv2ultuPpw+4LSxSsp9mGA+J1RcpQ7HQ3oLtqWRbxZDSKBAvEgwvZ7RodJkUb088pakkmCUvhZ 9g7NeQ9b d8KSbB5qUc0FecQWlRdeIZuCsbL5nywPtzGjEDs3Wp62Q5ItN3y8Sw/jSQ4BY75MIMdNj/k+2OwJlazwSDc75qxBMx8FeQ37Dd1rq+51VT8mAKLSTdipgQAL2QVsPWTpORj9ClBGjRwBUIb0Utta2xtKlxhmXdyayIIfnrkAB9hH4ZVkDFk/SSHX2ggnWEKyJvdmxU4GCoEu+llKW/J3sXBv4Dt5dUQ38YvjTl4ZNq0ua/k2QGUUl7Cj6hg== 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 Acked-by: Marek Szyprowski Tested-by: Bagas Sanjaya --- 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 Feb 22 17:39:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13567704 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 13761C5479F for ; Thu, 22 Feb 2024 17:40:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 415016B008C; Thu, 22 Feb 2024 12:39:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 39FD46B0092; Thu, 22 Feb 2024 12:39:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C9A26B0093; Thu, 22 Feb 2024 12:39:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 0AABA6B008C for ; Thu, 22 Feb 2024 12:39:55 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id CAF31140AFE for ; Thu, 22 Feb 2024 17:39:54 +0000 (UTC) X-FDA: 81820152708.03.29A33CE Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) by imf30.hostedemail.com (Postfix) with ESMTP id 18FCE8001E for ; Thu, 22 Feb 2024 17:39:52 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=XWveh08i; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf30.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.171 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708623593; 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=1VAat8TBDVTapf/cNKrpWJJOpQ7pgkQwxbfklHwcriQ=; b=3ChVGG6s1h/DgX0RtiNyqjR6WY42YzkzBG1TT++5J7WwrTSPYZfrEr324BeOVzzorEMlCP Dsk69tfhTPii4JG/zNfabJgxdeBEUJc/a52FBLGIVw6k1LMsVWM4sfmkSnDMNvBiIZCatx pD2d9JcX1yla+ms8ICHQUp2ba3KTEWE= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=XWveh08i; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf30.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.171 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708623593; a=rsa-sha256; cv=none; b=KoiWsR3g0/+vRRYhKYjKMTfamYe5UrTRsKlsYwzpRAtIOj+Y+viogySzklGB2sw9Q0hvxc doUriNx5PWYQ27RsMwRzoZ2bOtwJRiJw4d5UeI6Ik5ZSlDpqrt/D4VHZi+lKtQWF8Cv8to d5NAbvwgmjKTS+Ge3t3TMsvwh6GKt/o= Received: by mail-qt1-f171.google.com with SMTP id d75a77b69052e-42dd6f6518fso26854811cf.1 for ; Thu, 22 Feb 2024 09:39:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1708623592; x=1709228392; 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=1VAat8TBDVTapf/cNKrpWJJOpQ7pgkQwxbfklHwcriQ=; b=XWveh08i3vqu0J/5S3ueHhucF04SqreSTCtlPikHgKJlULyo4KsmbRyhUsfZQ7lFkx B4CaysG95lTK8vqQjd+WrTn9aqwD2F6GzaUgd5m4E2bAuvNAn5bV2mJLR0G4E85kzXm6 s7OkZxh+t5Aslhh+OWXUb9++JxTfJIpkg717C3Zp4rnBhTLl4RAVA7ybRggWAG2k4zmE P6rYCebxvL093bvUO05N2ItBP6LNYNW6j/xs/GZ6QQgTNuw4DU5ghlHCwwm1d6cJQIi+ Pow3JbLN4IMvDtKAU0D2qJ4GrFB5L//OWIeeo+mhP8t7gCxEdfj54CXk+SLazuq6NDIS ey0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708623592; x=1709228392; 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=1VAat8TBDVTapf/cNKrpWJJOpQ7pgkQwxbfklHwcriQ=; b=kZhLta3YczPuh3eLKK28smhuZYip8p27N9Fkg5BYpCTP9Qjc02IVOfPCUIGQ4FovCn WyFFLO9xTDke8CoUb96GlbA9WIwvdyZ1f1A/nWGeWZT+xK5fxeJoV8SfMb0qBJo7EoGg rh8xOe1kDTRk7+XLr7DzfTZetoXSyqadaz/41QJJFPRb0zDr5+5ejMIfcsWTlBcLYQ6W ps/BwiJ6Lxmrmgf1G7nWxpyPYgT/j5DImLPw+hGuV15IZ7uJe/w5E5kxySLIcSyfGt4F VBBDhvThCbYp6zufbZscawFVU5Ea2hSIXi1YnfPEGrVbGzh40ecHdLucZ/dFT28l7vSo ZndA== X-Forwarded-Encrypted: i=1; AJvYcCXaYShIW36iZTwNk3oGeOaahqlZHqwnPPq3oF3ZH0CMCelpyJlfp2Ozc+YQJdQmOVacie0ukw3+oi36JuqZ2b1Q4+M= X-Gm-Message-State: AOJu0Yxuj7h5H53ZZlFJRoauG5KEl0Xk16/6hRSWjrqmQfsb3f0fa/Ts D+WPpuDTPg2EsEq41X5Z2MzCFP6rqWQqs5AximxM6GkBzOOosdoNQl2sRGmYi8w= X-Google-Smtp-Source: AGHT+IHz4D/tAkiJUKSEKYTo9KdtwALGRXWZMTTOk9WSdUZLPjcPPGovrQbnMAx6QcYLnGz/9iyYUQ== X-Received: by 2002:ac8:5f4c:0:b0:42c:7b12:70eb with SMTP id y12-20020ac85f4c000000b0042c7b1270ebmr25812453qta.3.1708623592225; Thu, 22 Feb 2024 09:39:52 -0800 (PST) Received: from soleen.c.googlers.com.com (249.240.85.34.bc.googleusercontent.com. [34.85.240.249]) by smtp.gmail.com with ESMTPSA id f17-20020ac86ed1000000b0042e5ab6f24fsm259682qtv.7.2024.02.22.09.39.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:39:51 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, pasha.tatashin@soleen.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com, rientjes@google.com, bagasdotme@gmail.com, mkoutny@suse.com Subject: [PATCH v5 07/11] iommu/rockchip: use page allocation function provided by iommu-pages.h Date: Thu, 22 Feb 2024 17:39:33 +0000 Message-ID: <20240222173942.1481394-8-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog In-Reply-To: <20240222173942.1481394-1-pasha.tatashin@soleen.com> References: <20240222173942.1481394-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: opjagpt65q7fwnq8ey8b7kcdwc3coo1u X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 18FCE8001E X-HE-Tag: 1708623592-283530 X-HE-Meta: U2FsdGVkX18RxXUAgQ+2geOt09qmHIzMm8FYqSqBv2k5naAlCwITYHLr91ErakFjbkUSORZa6rhgwlSpe9cKJxeCbZDXOKub5SeNk3cr5vhO3epxREhY+WB1A/+/D7IiGb4NOe4uuKAY7tjTubtH6Xyx/bXSnU9nuu8ZmC+RhtFZxHiNNJ7LU/1fWJGRypE9WVV6va5T48k0oSpqKBE6lXOtoKGoRuFooFJIqzc8JQ//B3wsQUYTXpCunEes7nx0tySaABZordgp8dTAcNP5+t5DTKb00AdAasuTbdVMbULk9LCFLLHm6S7GJpZOpRfAIre7/Lv1VHJSk8FZZCA8+DMw0Cd0cal6sqCfuWBkDch1d2tB4bIi+mWovywHSeHu4TlLApa8FiFDXVyfDZq9VANIPQ8fyVjVkaxMZlpQrL/nrilDIHi4w7H5IRF7juvaiQhSQ9XwoBO3NY2Xj2t/NNe6XiLze5iB52LZhHJUeob8YNbWrqAKym3vDNNgKShVPzlutkWCyOa9D4NV04hKGQ6xAYE+7V0ofXXuKX/xhz1yuwpIk2QAgUV39Fwh1AcepmVhEh7Vx5dn7DZYHHV62M8ITYv7ljbkX1AcD2ltfbHnnqRcigzRLj/OiSqUnHhF2O6FZ7yMN3+Vm8+aQGt+00u4dTJl9nxZewG3xK2UFVaeCLJfaAoLQUOK4RJzn6oTPrSnt/IvCUYHvj4KEjX/YDdy9BeIkKhxTb5jdklIM/+xlDxjF5NZeQf8jsgI8U5i1j0I3ydbgHR7Mufp2rcyvuzzuJOvGA0lGAOg5LD3sF49X7v6536drlGBefFJUU9mgRimG124i4tyZyPRBjfwokIY/DMa/IRn8vu2tFFuqQbqlqfB2/3iCX1vCl7jQ3RBRV3bp4hGlUIMEsA3R3lGQqK39QgQG7SoZfRBrwh6EIwPaWKyIMs1r8QeaHo/vg5qGFSFhGTCr1kUg6n6CZ0 6l4yKyVD 8kKw5CAM2oxB5yZzZfTo5XGUhjhgOXC8suf4b0+M+SRNw1i8rQA1sjhGfeYal58UQEld2/vH7Uo3eujN/YX4O5cieSi/YfX50fln/0cYyMEcOWrf4v/paAU+8+RlZHHLY3oIEPtZgQ2ttoUdp0sh6N0naWHH22Yux6UDd8JYiG0gJ8NPq3SMtl0jzIIkk+Oj0z4PDjr/K6AbczSdTKAolvhKV64efhij8YR9eFiiI1jQOpzcte1UEtcjnf+pNRkj1Sk8r+f1DhOvvSzcL1wp7hrVTl7/rudfeNAnaRoGgrYAZTj4hGfV0Ks2XBxRiwndBL8z8jNb/jb6bQMX+chNQtPOJLWzb9tqwbiP5P0kvrXHmaLGM40HLFXO2Xp/rZ6fgdrlEyDf7cYcjqYdP8dmTeUL5/xA8DjogBzqN4sctyLyeUF4D5Y89rqzAqv31FMmLBMDCTdf/TslL3EbFrvA2z9Xkvq4inBZyz5xhi0cKJbPwjfXTwmBh4nEHz9xu4f7pYWkO/4LepHe9pup0fdvTpqAQVaSk15fVCrJmm6dx96g46z3jWZiKWQaf8KBqkhWEGNRt 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 Tested-by: Bagas Sanjaya --- 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 Feb 22 17:39:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13567706 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 B15F1C5479F for ; Thu, 22 Feb 2024 17:40:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3A3F46B0092; Thu, 22 Feb 2024 12:39:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 30BBF6B0096; Thu, 22 Feb 2024 12:39:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0DEAC6B0092; Thu, 22 Feb 2024 12:39:57 -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 E3C216B0092 for ; Thu, 22 Feb 2024 12:39:56 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id BCB8DA0F57 for ; Thu, 22 Feb 2024 17:39:56 +0000 (UTC) X-FDA: 81820152792.24.D39B26A Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) by imf18.hostedemail.com (Postfix) with ESMTP id EAE921C0017 for ; Thu, 22 Feb 2024 17:39:53 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=SNWTQJxY; spf=pass (imf18.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.177 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708623594; 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=ZEqwPir77gZiomgrLUuNDH63tTDpLGc+7y089oTBF1I=; b=sFb0NpfLhVyk2M7DKnrVN2/q/I0ozm27O7xV3dwrFs3DMOd34ZWVQqf+8WA3mkaHhkl9Of xYrAI/zlhZZmSQZxDSYyBlWsslCE/06hiaqQjO3orc+XdtcweAgcoYiKnDWr06u5TXY2CC HJinmpzJSovCcPF/rvJD9x/YxA2QMCg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708623594; a=rsa-sha256; cv=none; b=8m6C9IkVyla9m4vozEGMY/e1YuOMmN0Q7BYzxMccnQK3KxXKmjt5clS4XJDA4zKZkCUyWB cafEXZVwSyC2zgb19djX+2jGe5cT+z7G2xKA7gQszcKPzlepbT2w9H0oht/esU7Pb9mY1j UZLkZ11O9hcGzWFYbrHRff2ZXmz4TBE= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=SNWTQJxY; spf=pass (imf18.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.177 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com Received: by mail-qt1-f177.google.com with SMTP id d75a77b69052e-42a029c8e76so57475061cf.2 for ; Thu, 22 Feb 2024 09:39:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1708623593; x=1709228393; 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=ZEqwPir77gZiomgrLUuNDH63tTDpLGc+7y089oTBF1I=; b=SNWTQJxYwEGx1wv6iyLgYKjfyHSqTqpShIutthkLfAiFqTwKOGR5PExop6a2Br6W9C OykH7HQfIm8A/zsIajCTuaaywUCnx0NNSXHLmyMtnch+1nQyUaoVYDhYS03WppozuG2e BA2B2nDleCgIX+9a+X6vmNl7+GBD+gLU/HcKtHtO4NZxDOm7T3cf/F3PBQzwYjLgMNPO zqleUgDCS+t69mDHL8fpclqzgY7qhtJBJUk7C9RZbdI4+5aJeIT+2kjwuXAHsLXGNMDe Ki/oMnRkDCFYntYiRz4BtQoqSnMjP+jfrWp9IfdP4S7TxsKGDVEklX7PSx2pkUS1bvtJ jEKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708623593; x=1709228393; 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=ZEqwPir77gZiomgrLUuNDH63tTDpLGc+7y089oTBF1I=; b=ud6s9mVSIh/H7VHuvEU+lyAA5zuFaR9YArnMMSAhDdJd/7HwYEU/Y+jkkq+IKOLlRV zr7EbR+W8sGi1Dy4PaPX9oNcKBm7Fwy+dGRxwg4A7JwV2BJLV/lsYj8h5Wo896cpR6j7 lGVKTkSKSdPUuLGfWjZIJxZEyLS/GtxqeW3ORnRe5a07l8LTHV2kVV5JCZFEJDQyGIxb XpqjmEWsJjxNgG35Th5w9HT/xOlIo7tq01BUdjmsXBh69pW4oOevrd3Xjn6Kzi/oJ1uV OMubk5zcp+vy/M3/lVWzpkL4fkRJz0IJAqPKDxUMKlUvPMi8QBGGa+PcolRSReRX+6h3 ldhQ== X-Forwarded-Encrypted: i=1; AJvYcCVYmLHpNu9VhaHgUb8cnq8Fukh1XW0K1Gq5anzN2l8REnXM39T2rrGUWeoP6YWvph62qMG+OAEsr4pBAXtIGZl8Loc= X-Gm-Message-State: AOJu0YxKhAoNwOMX3yq59+yDViNfndlpsXTBVtsjPQaX6nJX8nKJIknZ XZqMF5ktUqDg4X7CXV2QAXnGfusV8PyIG5X9COCMSMElsYsPnRICXLD8+ZAdSE8= X-Google-Smtp-Source: AGHT+IHWgbe6ipO8HL4XSLjafpdpzGiSGfQct8NtUqWcRWqXLU3Gq7aLBUbxfLYc4BAno8BAqxzaSw== X-Received: by 2002:a05:622a:11d0:b0:42d:feeb:64df with SMTP id n16-20020a05622a11d000b0042dfeeb64dfmr18277023qtk.36.1708623593054; Thu, 22 Feb 2024 09:39:53 -0800 (PST) Received: from soleen.c.googlers.com.com (249.240.85.34.bc.googleusercontent.com. [34.85.240.249]) by smtp.gmail.com with ESMTPSA id f17-20020ac86ed1000000b0042e5ab6f24fsm259682qtv.7.2024.02.22.09.39.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:39:52 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, pasha.tatashin@soleen.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com, rientjes@google.com, bagasdotme@gmail.com, mkoutny@suse.com Subject: [PATCH v5 08/11] iommu/sun50i: use page allocation function provided by iommu-pages.h Date: Thu, 22 Feb 2024 17:39:34 +0000 Message-ID: <20240222173942.1481394-9-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog In-Reply-To: <20240222173942.1481394-1-pasha.tatashin@soleen.com> References: <20240222173942.1481394-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: EAE921C0017 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: dnodapjfc9na64z56canbb5u87ipbk3i X-HE-Tag: 1708623593-175252 X-HE-Meta: U2FsdGVkX1838mwzumuDNC0MoqZf2gyEX7aoHtxhY9v2oi88tVHN6jOAvHtJgfRzU8FBSHvEKvVCIeZyg7OrMOTwGnY8AlvL+avkbTY64401YLCpxkNq3tc/Oik5Jd6LT6PYCR+ExpaQgNOU5GdR0l8+yqCFBL2Oj5vsEGqvZLTJyGgg4ZKvYKKNdekzgFP9NWleZzMQMQZOM18W8dl69kLqPworJpu9cjNQPkiVZnknHtcpOn9mbf97xaOVFUyHe6U5FPpOr5bcus4sbXqNG6HyQkNp5x3NJEwdNZSoq7oEPQGlkZgNMa0cYKMb3OSmfEBSDQotCMT8SUP2hhoDnmrUh/atrnCADy7mTZEp8/k1dBNtwxOeLtSR98C+f/tX0/pP+vnFiwGeKrlqw4M6voeuJn4+rf+h06ejb3RP+ayIjBqXqp1Gy4bA+CjQa7oPgUG024ShOt59Njs3nM1iD5UEJhLDKuumKqQB27ea71JQOOm56FZWvKLUFF7xjnX3fjfi+b2F1Zqt3khRXxyNCct6YRg27xBA2BVNuREJhNPUcL1Nnal0cof9qU8VlNfn2ncQhRkMyzY1XH8MgCfanTPZX2/IBuBRs4eEo1xRFUVNPS+vofvSaJqwqk2CgwiOCk0kJLyEtCbPL5ss7jAVuWzLu66wvcnkowX0AZ/GquRckHg2Bh1aAwTBSS6wW8eiQo0Ig6Q3a1BnIFFW6bigyGPtEnlvJPDWxVwyLMtT4M6FJXQvoFDS2FkX5MbFopwQtzVjWVcL8IYIuvEgmgg5mbnXa1GVFYY719MSx9EpmkWfMQFn19phbesXkqX39gSFzZTm4YBTeHjUFlaJQQaaoCTgSNkV11nO/z6/NhRrZKeEbH87U4tfwJKkmLo2eTde7iNh84WvY+Xx/Meyi/xC/QVk/z21hMnhFJzmUzzWYZNHZtHL5tng3P855/uJDz9QrIMivBdJrujmeyACbVL Po7igfkU qkB80HZqfglU7ojdATvZbifNkwdsy38LPxB0BKilvREWfNOAbqksG8cZtmagmMnNfLoVf0jtREBd4NNbowBPUQ8QDHhVLCZAZzSNfzWeIG5SHFpnsAgqNV6pVINC2YuJuF+2KKNp2VSw+fTnvR9g1vCOGz+AhpAW8blCaLrMwG2O+NgXGSZDi7oljR5NYZrTV9wavJE+h6Vyu7iZ30UEh3Do545xgctDMnxrCt4kh4hvq5nuJCbvFa26cA6+j85XWurJv3Zj15WBiVTSBtgMLyr4RnuLVgA9BopOWmGW95EY9b44bFHMaO8UupMF3dP9JcW8EoOK5hBqvUKGZ+kD1LuobOe+HQQA9rUOuo5HjBnw4wnvNiP+k6++JDHgqRI/58KDXym6ElMqnPMqBTYl5f2LxJ4UVXo0eXGwEhPIUIFd3woj88MFwiz0wHUVsKymI7DAL8xboWlnj11Lq1E+uQ2mqQq3uPT5z8EaURh2brd2h4uo4/z69xhnGsoHxQAl2In1UZCN1YHMR2A4foc5r6hVFUlGCITxAOMVFMTxh/J1G+kcVi6VBA98XASi9EkAzemFHsXfp9dAYyMY= 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 Acked-by: Jernej Skrabec Tested-by: Bagas Sanjaya --- 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 Feb 22 17:39:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13567705 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 C4DA2C54791 for ; Thu, 22 Feb 2024 17:40:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0E4796B0093; Thu, 22 Feb 2024 12:39:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0920D6B0098; Thu, 22 Feb 2024 12:39:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E24896B0095; Thu, 22 Feb 2024 12:39:56 -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 D16496B0092 for ; Thu, 22 Feb 2024 12:39:56 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A9429140EB7 for ; Thu, 22 Feb 2024 17:39:56 +0000 (UTC) X-FDA: 81820152792.14.49D90FB Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) by imf01.hostedemail.com (Postfix) with ESMTP id 1921E4001F for ; Thu, 22 Feb 2024 17:39:54 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=lw2AtJZm; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf01.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.169 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=1708623595; 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=uv35HUKrFfNdue1C7Aw2CpDwCbY0H46wtzckiJmEetQ=; b=P4zFIHQ/E1EymEpMG13MmyyJgNxMAfAql8+8N38pte89kr++3SF+BZk/GfmfcivDvS9i5l W//jnTZQVL40mlvFLvZq3oNxn1O7k/DakQwT3cgjGRz/N2HNfTq4A/jXgPA222S5uca0uq dPdEBNFCODd4zN0peTNu+4FoVyQadPk= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=lw2AtJZm; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf01.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.169 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708623595; a=rsa-sha256; cv=none; b=d62m0vDbP6wCKO352ysQb+jSJBVCh1zoS/q6kJypFSqx1GZpiZb2n7cPjwoBaGigMjyKRY AZfX4d/S4oTIqKI4iyOCLN4AFoWT7WslbC6H5ZaHCZp++56i/8ILpZs2XvfdJXQegrDw5V 1Z8q9DcT+CVcj+NBiR7ocBPCfWxP9qY= Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-42a029c8e62so14482631cf.1 for ; Thu, 22 Feb 2024 09:39:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1708623594; x=1709228394; 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=uv35HUKrFfNdue1C7Aw2CpDwCbY0H46wtzckiJmEetQ=; b=lw2AtJZmk3VplTnUzXXZ6cDVtf+nAxIie8P8G6Oxm11uBz/GHUY0leRMsM4RO46tQ/ FVnyhhc0fFM/yI6iNdQYmyvW4F++3SkQU6mAuB5X6HPG+4ZOlBhc3mQ5v7eR7Q3dfZuJ U1ByNlRgq5bZIZX44gJerXzQijVGMKVGkiW7/iE/QeasrdxJDAVQlmdYvyHaN8+M3e7D sGAuRFkdNhsx9k3A4MkIWmGn6/hJaDgu4GPmOJNQYr7MzNN4G49JBvSNzoKvxCtC91KP VJWZ5XEDP06oqKWIDSf+UzpL4ljA7aQezDD49UOlOgUbxFgdD45tvIQx0hT/Gqaqk1vw tPug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708623594; x=1709228394; 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=uv35HUKrFfNdue1C7Aw2CpDwCbY0H46wtzckiJmEetQ=; b=HYM3pE1lCQ0jyDhD8QR++bC7/gGr6VigJ7gzklu/cVMjX5sndsH7pbl6Z5A+EF747V 5R1St40P6kKhoF1+euvjHpa/mxb1Tk1XP3zQvv6NYGTvn6Xb3DLzDmhmnOUZJf3JJMDc SpDYvyeDWiTSh6ckl37xG0L0GP2OYfxNJG8Y6k+snhcfizYW53GPT1gUfIAV6/HXvevV sM1rhfHVKclPgtelEa6uLrF2hALq8oAytIQuICnAj8ToYmWGcz/TS/Zy5tjuuHtpR1lb wRmiF1oEoG/AeFq57JIaipjNAQvb7/WiiY2PumGD/dQkM7KBomILXJPLVOj4MkOA5tUZ WqxA== X-Forwarded-Encrypted: i=1; AJvYcCXeeOV6/esrnj8aB9gN2Rrtk7EAlvouou1t41WosvFVhMkt/lI0jLSyx428V8HepSYSqwPD52HxGoEeAF4t+Tj7QPQ= X-Gm-Message-State: AOJu0Yx6QDkhyufbZWTThISwjsJQK7gukDh3ieDx0kUK0sFuE5Lzy6Lu oY68UvcErYknrqkA2YrN+7QGO3DflsgvSoo1yAq481RDyTCKEyMXqG6MsY0MwL8= X-Google-Smtp-Source: AGHT+IE+Akg5+Cr9C5q9XoLFcnfSS9pk8lVxXF1AmEM7lT1XFT68HyiX2ha271XqH9ioEWyp0Wi6uw== X-Received: by 2002:a05:622a:148e:b0:42e:1d1a:d414 with SMTP id t14-20020a05622a148e00b0042e1d1ad414mr12238355qtx.15.1708623594202; Thu, 22 Feb 2024 09:39:54 -0800 (PST) Received: from soleen.c.googlers.com.com (249.240.85.34.bc.googleusercontent.com. [34.85.240.249]) by smtp.gmail.com with ESMTPSA id f17-20020ac86ed1000000b0042e5ab6f24fsm259682qtv.7.2024.02.22.09.39.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:39:53 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, pasha.tatashin@soleen.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com, rientjes@google.com, bagasdotme@gmail.com, mkoutny@suse.com Subject: [PATCH v5 09/11] iommu/tegra-smmu: use page allocation function provided by iommu-pages.h Date: Thu, 22 Feb 2024 17:39:35 +0000 Message-ID: <20240222173942.1481394-10-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog In-Reply-To: <20240222173942.1481394-1-pasha.tatashin@soleen.com> References: <20240222173942.1481394-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 1921E4001F X-Stat-Signature: 3nqxhtu7idumscan1b99qo6pfxnfuyft X-HE-Tag: 1708623594-456475 X-HE-Meta: U2FsdGVkX197M1rArrLchHm0woH4OFKbbr0n77bwsr5lfRAG0s9MP7oOy45EquiUhWnomboo7vZLRo03hUjFKSyXkBBrjyphVyEnbBtAV4gohJUijNG5CFuvgoDAErJFqLCTjMEG4Xa3k3xf7cRtULimvDvIJLZzibEjJwu1HFc8+efizMGQjADd36iZtm+3QgFe1Qtt9lK/oq3c5IMO/4tLYJYg3QlljYCBGbvbEUL2RwNlKJQ6nLJNLmpbi6BWIMpMt2WJmzXhMDNz/xdhcyLlfL2Y2OT14ZxOaiIHX7bhijc5kYMTlO+DpeO21NidI7B8wpvTZpQrca+DJF6EoL4IULvDarZP47zZ4SCYpSsuK2qAAPj/hy4TftkiWSsPV6Ut7VJlyGrE68Hp9ndX/daeBn9jRmdDHC6D5Ra1fHxHu7h8Y7scIpSolr0Cmc1KQ7SYcy2XuLqwDKW7uniiKmStbRRZ/IRRdUibGsVX7y+DqWJL1p9O05YHSG7xxuUie7L+itkpGaQm0zX1vW5LYevlnVg9BCWudjKZe+iaE3/gpDXyBTWrwituJEeOr1Ed0hitweEZ2IMYAWUcjTibqmOA3KfRrhNBkP4iYPuHk5GBDzNcbP64lJyk4qc9fN5/PX2prCavwGiPxq4VZTJXZre42kx1pb2Rqos3gtpOxskuw7xqlfW4l3Tf1WKnOqBsCBYWMsOlu/V2A61hkn/a3X6cEkKL0RF1rgSni+sqiVxTDnttOgCWaLhLWzphCM7jvKNt7JJx//7Ep/hgkUl6HiYuU7Lajau8Eg/smw/y5vXngK5e1d8WToUkfBjlCLFoywvpFaEW5JW3t00XFZQECaVf5j01YCEEQG7SXF+C50R9frLrjW8jxFGEyLYFr9x/U0fq3zlGiMGYyGDC+t9MatkIYhiaInH9Wyw1fNYP9fleDLOPX58sDjmD1ue8mFxQTuo4/DipqEwEkqsxScA GXS4hHhI dawuOmWLV2pCcVKuX9DFkgj6I+nqyb9TfI71wrdfQUQegBkCMTC8vrw9TSuNYBoLzY5WRMil0FBvb5wRlu2TpDyWKrAxQJxQyMVZXENhGscCigY7BU5VCSu2UwGBLH3is3+bMhspWghqPUmy6pxORgRFuXQkDjQyqMh4r6j2/IOgFEMilEDy3aaOEQUxl6vFObjfsevCu+P8L+ev8urUHOkBlMEkT00RWUWKaOId2HS8oiCcos7TJ7Oq1IA== 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 Acked-by: Thierry Reding Tested-by: Bagas Sanjaya --- 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..8be74d472f21 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_pages(GFP_KERNEL | __GFP_DMA, 0); 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_pages(as->pd, 0); 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_pages(as->pd, 0); 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_pages(page, 0); 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_pages(page, 0); 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_pages(page, 0); 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_pages(gfp | __GFP_DMA, 0); 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_pages(page, 0); page = as->pts[pde]; } From patchwork Thu Feb 22 17:39:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13567707 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 79805C54791 for ; Thu, 22 Feb 2024 17:40:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E513E6B0096; Thu, 22 Feb 2024 12:39:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DFF446B0098; Thu, 22 Feb 2024 12:39:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C29406B0099; Thu, 22 Feb 2024 12:39:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id AE7C46B0096 for ; Thu, 22 Feb 2024 12:39:57 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 829B6140EEA for ; Thu, 22 Feb 2024 17:39:57 +0000 (UTC) X-FDA: 81820152834.01.C665797 Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) by imf19.hostedemail.com (Postfix) with ESMTP id E89D51A0020 for ; Thu, 22 Feb 2024 17:39:55 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=gekjj0Qo; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf19.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.176 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=1708623595; 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=V0ReaiTECyup4iu8c9tFSBLtkPVhLn8yFZIGfl9p6vs=; b=BJ0x0o01rdgOPHmnLOFvByZKf/veNDzKw07eEKsWCqqKAckH/DURbLd4dQK0WpF9HK9zxJ Hia0dejMMoNLTWsjLUP7j9A8R1FLPK8O3+eUq/KMDHi3C+5N3fIx9ytX6Y75PjBEqsMREs pYpRt3U4rituHvs/3tklt/qhNCbWL9w= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=gekjj0Qo; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf19.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.176 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708623595; a=rsa-sha256; cv=none; b=ahhayU7PuDu0AUj9ek1q90hRucbHhs8t4LZv5rxs0j/dp2EqAGO+6axb+/XcwUae9Sja6n AJBa5vssevvPye7t6qcRsEn0IMsDNUTNwB0hWQSRUviGPYacaspRlLAQecuSj8uXsCcMId 3KIlDRaZFYtutNvWkjkr60c4scX0yW8= Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-42a9f4935a6so7789111cf.1 for ; Thu, 22 Feb 2024 09:39:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1708623595; x=1709228395; 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=V0ReaiTECyup4iu8c9tFSBLtkPVhLn8yFZIGfl9p6vs=; b=gekjj0QoKjnsz1d1Uk+7fjHF/9JAXwUngjUs/IR50BzUP6ViFcTAK5rfC9PDtXYFhF rHgHnwGtGaraBrxRhd4T7SLQBnV2YYh9W66cZIUtTv4YtnKCL76hEjUCtu7Q0C2v/Zl7 Y+5p4/yKBV53WMXznWL7JOr9Kq7EuRW3fhpI5j6mPAvXUd0piPQv2jJerFDvwuPlAFpO ZskqzQImaLAflPFG8iLqpqjZWI1vKpSghcgAI9Tm9Vb59Jf5yuifEKybIBDimcRnIpZP 5SW8Vqk3RUxmSwvMpRUo4ebToxBhtFzq2dV1LLZu3Svjdu5zw2Ih09S2An+7dgAiPsGp V2Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708623595; x=1709228395; 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=V0ReaiTECyup4iu8c9tFSBLtkPVhLn8yFZIGfl9p6vs=; b=iXO09uQFL6aFFdSwIxrIByZfwRUFMssPUWEVLsOCMVXKNys+uS4RlWvd2VXnbVTeMk yD+uzFSDMPJrZ7KtJ++LPE2VD57O2kgIhn8So/OXAGRuAF43R67avj6BOq0xCDMmwH8Y 8x76yyxWpLY2wBrCVvn34yu5JFPNiy1uzcX8yqOkAf+rHBzUdO+z/4K/Rjf+wc+L29H7 Bg3l7qrOYUGlu4cn3TQ/klaCzoJs6I9HF30CATyOirNG1k7GHo6+yGVcIWIhGp6ts8Ao 0mikvGGai8ncg2fQZs/UklT4xIaxdKGgredOvUpskffncN+1zhLJoAgcrb4GinCllCEV yipg== X-Forwarded-Encrypted: i=1; AJvYcCUO60uJsArv9d4Fepx7lgD91x/ygMGjjSY97Jac8AP04xU0a0by/HpI/s55KolymCuNPOUVGMRMQumgx5jtZM72r8o= X-Gm-Message-State: AOJu0YxA/hccM4Jrb0MFnzzR0yRxkC7ObTmiNQiPab9mn9dOL7PjQSPc hXqkDvpaT6s8HtsCEKgptOLddf1a/2VF4IUOj0ywUbenPyfGY28REdJtFKqAGYA= X-Google-Smtp-Source: AGHT+IEfgzE/uC4xDSwqJvxbjnpMCM7aGgkDw9ad0MN7VOXeeW4kWverRuOWKwGaZsiVILRRW0AILg== X-Received: by 2002:ac8:6c2:0:b0:42d:f128:eccf with SMTP id j2-20020ac806c2000000b0042df128eccfmr3903788qth.33.1708623595045; Thu, 22 Feb 2024 09:39:55 -0800 (PST) Received: from soleen.c.googlers.com.com (249.240.85.34.bc.googleusercontent.com. [34.85.240.249]) by smtp.gmail.com with ESMTPSA id f17-20020ac86ed1000000b0042e5ab6f24fsm259682qtv.7.2024.02.22.09.39.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:39:54 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, pasha.tatashin@soleen.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com, rientjes@google.com, bagasdotme@gmail.com, mkoutny@suse.com Subject: [PATCH v5 10/11] iommu: observability of the IOMMU allocations Date: Thu, 22 Feb 2024 17:39:36 +0000 Message-ID: <20240222173942.1481394-11-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog In-Reply-To: <20240222173942.1481394-1-pasha.tatashin@soleen.com> References: <20240222173942.1481394-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: E89D51A0020 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: xmpis9w5tiqmubwreu519q9c1b4x4cwr X-HE-Tag: 1708623595-381510 X-HE-Meta: U2FsdGVkX19GrNJx11HyZgnkb8oZxSm93Qb3wESrXIs9tvp5MFZyCkgNeV/ksa4gpdi8h4eXgbPQuxKgydbj1otcUFbR93JAPGj6MDCztwYjyDN+oueT47kfpC4TTWhatjq/pEyQA81LZUh3o5e4wbEIfAxuASzDpK/Hoae1V/ns87HGsHiLkfW/+rU9HfE0UpKXy9Qh40oz22rY5jQp/iBTZfAWB/Iu3yuFz4xGqy3x1zzi+4TpnQ5ahKM6cNa2hePZLKCiL5ILYkqFcib69yKjWxnOTEZZt6uVUWvYP0SwOpgNroZej2Q3r+RJkvrK9WjZB05IMaatRYLycJC/LmD0OhcQZ+mwwOrJG5/MEklLLDR2+U20vI4hA79iJWSVrPPEPknZO0iubc3tmwW/SWRY2JNZFOo4U5v8hz9KaV/Rx0xoRowdAIcUszv9dXukXvUgctkbcuRJ0Fl0GYAQOrEzitwuUmQMFH5Lw1kC+BPN5lonUGWZPcceIoW2REts9phGYYnWucExGWALwBi0AlHGcCTqbkHeO4x5TpzqkeXtHwg3EmE88TC/+wjiXOFAfSuQytUEohnItawg0glorN/qGuKcWHLM9sSFKE1H7qio794S5/yrVFcC9RrzQd5+FNOr2+OG95rZAsWhiivbNGtWOd1bAUWogLgrmXOaBOrp0jApoIsNK9ZP0MQi6uFfnDbHQjavOf9TKt53OSqNSwAC31IALMwXMOYRySmgV0x2AjcEftflPpSjRiA3e0hnjpMGgq1bLHvb0dywVk1KngyIEeJfxVSgAr72VzyP+R2SrRgYpFsml60nXLZqPbphEhCiXIeWIVopx9UjHqMLuyHOqErfXiqa1lLF2z8+2RWlzPv58/inLXSP0pIZSShIO9bVRTco2KMZNA5gx9GheRYwGpqQjawPTV8t+m7RnmsfWThp8ZQUtS/kSKFjBr2Y7OscBIX9OVQg5Q44XOi ApSmVWyi O5mLPpUPu/nkQYC0y4yc1CuUWU0sG3OCQsKCPfs9bzVQPiaE/It65HZLxnBhjFGMPFKQ7/C2W6zxouRBTXDGGRwTsmhJSd+15humcz+elZsqNIvZ8GsEoYjEYkn2jgunqEBqgEkgk8XEk8LwVj7Z5qt+zr3vGEI28gz33ZGB9ZuyV7XGdH/DoVQvoaERKo3Tv2cSsjojQcFcZz77zJ3/YrpjfBe9iL1ozT7ezlHg6vN+8g0qZXaG3FcwNlw== 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 Tested-by: Bagas Sanjaya --- 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 35bfa369b134..daac2da00e40 100644 --- a/drivers/iommu/iommu-pages.h +++ b/drivers/iommu/iommu-pages.h @@ -20,6 +20,30 @@ * large, i.e. multiple gigabytes in size. */ +/** + * __iommu_alloc_account - account for newly allocated page. + * @page: head struct page of the page. + * @order: order of the page + */ +static inline void __iommu_alloc_account(struct page *page, int order) +{ + const long pgcnt = 1l << order; + + mod_node_page_state(page_pgdat(page), NR_IOMMU_PAGES, pgcnt); +} + +/** + * __iommu_free_account - account a page that is about to be freed. + * @page: head struct page of the page. + * @order: order of the page + */ +static inline void __iommu_free_account(struct page *page, int order) +{ + const long pgcnt = 1l << order; + + mod_node_page_state(page_pgdat(page), NR_IOMMU_PAGES, -pgcnt); +} + /** * __iommu_alloc_pages - allocate a zeroed page of a given order. * @gfp: buddy allocator flags @@ -35,6 +59,8 @@ static inline struct page *__iommu_alloc_pages(gfp_t gfp, int order) if (unlikely(!page)) return NULL; + __iommu_alloc_account(page, order); + return page; } @@ -48,6 +74,7 @@ static inline void __iommu_free_pages(struct page *page, int order) if (!page) return; + __iommu_free_account(page, order); __free_pages(page, order); } @@ -67,6 +94,8 @@ static inline void *iommu_alloc_pages_node(int nid, gfp_t gfp, int order) if (unlikely(!page)) return NULL; + __iommu_alloc_account(page, order); + return page_address(page); } @@ -147,6 +176,7 @@ static inline void iommu_put_pages_list(struct list_head *page) struct page *p = list_entry(page->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 a497f189d988..bb6bc504915a 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -203,6 +203,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 db79935e4a54..8507c497218b 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 Feb 22 17:39:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13567708 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 78BCEC48BF8 for ; Thu, 22 Feb 2024 17:40:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0BBCD6B0098; Thu, 22 Feb 2024 12:39:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0935B6B0099; Thu, 22 Feb 2024 12:39:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD7206B009A; Thu, 22 Feb 2024 12:39:58 -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 C8DB66B0098 for ; Thu, 22 Feb 2024 12:39:58 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 9AEA740EF8 for ; Thu, 22 Feb 2024 17:39:58 +0000 (UTC) X-FDA: 81820152876.25.5CA909F Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) by imf20.hostedemail.com (Postfix) with ESMTP id CE2BA1C0017 for ; Thu, 22 Feb 2024 17:39:56 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=wXZUL2zG; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf20.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.128.173 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=1708623596; 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=SZ2pQJ9+dxF//EaiCt/uq+OdRpwnCyd+9hrUk8R734o=; b=a3wqCA8/q5RVUFehabMYFE97crUAaN2lQ/rLoZ0K8PjMIkPSL7Tjn2vhOaGMae8OZYpusI NLN3KUoMSj5ZHqJui2U7Nnt/W4sdf/LfY2dfZmNIBVT7fZqHv6zTJ3HCJi1pKplWuPmAea jtbuguHS2Hk9nK/nd7sM96OxDpKMyN4= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=wXZUL2zG; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf20.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.128.173 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708623596; a=rsa-sha256; cv=none; b=soZSDMIlrksKBxVadwkjK7xu6w9lB+F87J+axe4yikzHrJJksciLGabCJJEHx+FvaEMggI SaeXyJXkZJudj57bodn0lRh9nzlVrP8D3TEr07R0n5M1GoKvG/FLZaz4bMcFfWuElmoEok FioKxg7x5KZIkkAE/70xk2+jJUlBLxk= Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-607c5679842so20926137b3.2 for ; Thu, 22 Feb 2024 09:39:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1708623596; x=1709228396; 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=SZ2pQJ9+dxF//EaiCt/uq+OdRpwnCyd+9hrUk8R734o=; b=wXZUL2zG9xn+FsCe/oxYRnTeMNlJHYVRHjQEzwOGvk79wlhBmk3tw0C/bEuNfQHgTr mXcEYhKaG7S2b9WsQGNEXiwJjawjeqA/sys2X29VsMG2LZ89csXTDb2kQaNpiHKSnlt/ qX/0r0BWGBPiZaqw/WP6fCaWUK7tdN6Gd1NoCzXMdNuwxmeJPUDhDGFmg2b5/y7wJvu6 P4DXR1VxfgsHG6hUOUOJuUYRt1Z5v6n1fhD4esyumB0Mrst0yww8dvxBcPsQWBir5BRY ry+zpij9yKEekElkSpA4/dJUovZi1HIK9WMdElqQKx8Av1ZSK/kcetX/jZiUq95Gpb4Q 2ovw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708623596; x=1709228396; 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=SZ2pQJ9+dxF//EaiCt/uq+OdRpwnCyd+9hrUk8R734o=; b=I4DhJ+CkQ4H8BUMksW7Q2UgEcp7IOHM3Xk0KRv3jpIk0s16NRE84VkVI0sxruKmbO1 vW+N445voDYDD74bungXzt2Fgz5w8fl47Egr5wVtrvO7YL7WWQWp/MKmypeb6SH77rqk /A/vS8nFJy2fjawGgz0Tvl4IMY/tZDsKeKqohA4q0R0q74jP45YWOhh+SZWb2HoJQscU fxVmPf2QvpFo4+PnikRovuGLLXX/TB2Odxo3G+NnoTGQD2gF7MPbJdsUbL7BfhX5R49J ymj5O6y44kuri5o3aqTJQ391SSNecWhpj9dICPkT9gi+nUybIdcRTfzuH82vlHDW55lF WeGw== X-Forwarded-Encrypted: i=1; AJvYcCUcXTKaS6Vqt300qE8W1PsHTj9KwPDgnRMO55t6nE1Bo0mDnI4mea46hauLWABGoQs4UvfOcAyEGFUWbsdK3vuxhLs= X-Gm-Message-State: AOJu0YzP5w4LDDRGTZRBiFbiMjnxE/cTmSp1MrxiZiPstc7dHKqEJ3YQ 7ioiy/abN5aacCVHj1+njiV0T1l4ZL125aNWg7dOtHYzo/f4V7zpWzyYlAIBvU0= X-Google-Smtp-Source: AGHT+IEtAUUqy5uqw2b6AFNUjnG1318TVskHRq83YxSHDfvItzdqlBQeiT8forYQaEVyJnoFBVJVWg== X-Received: by 2002:a81:431a:0:b0:607:ef06:eb8 with SMTP id q26-20020a81431a000000b00607ef060eb8mr20801514ywa.40.1708623595945; Thu, 22 Feb 2024 09:39:55 -0800 (PST) Received: from soleen.c.googlers.com.com (249.240.85.34.bc.googleusercontent.com. [34.85.240.249]) by smtp.gmail.com with ESMTPSA id f17-20020ac86ed1000000b0042e5ab6f24fsm259682qtv.7.2024.02.22.09.39.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:39:55 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, pasha.tatashin@soleen.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com, rientjes@google.com, bagasdotme@gmail.com, mkoutny@suse.com Subject: [PATCH v5 11/11] iommu: account IOMMU allocated memory Date: Thu, 22 Feb 2024 17:39:37 +0000 Message-ID: <20240222173942.1481394-12-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog In-Reply-To: <20240222173942.1481394-1-pasha.tatashin@soleen.com> References: <20240222173942.1481394-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: CE2BA1C0017 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: afaon5ai1xujqyutuo7p9uzc75gs9pg1 X-HE-Tag: 1708623596-641882 X-HE-Meta: U2FsdGVkX1+pG/vKC9597drVCLNakKkErMnokY6Rf2LxGGkdVyNuoJaIYUsNUiiIeZp8Km5meCWWHBEXIKiwYXTXyWv2bXILFpd1a3n9FEXeZQ57uqKhJrsumTcPDKyW9LIZcDsILoWM/JEQwAt/kP1CN1lnxxdySkttOH7OfYsnTxlUtotWkdJFj/yCs3h+Wj4wbX8r/QpofN8Rz67IaAzjVE3txTjh5ohy6HS5bsLXF4o0hMTbG8YKKTUHl8gZI2u3MGFg0mGwsH1hnTbh0Tp3lN2b1zgp+6u2cjIQ7vUXJta9AU3AhTfcqlLc2Ky0LiDYGx5gBpYadwPaqnV8SRd+jH5neJcpT5guv7DeudCZk5rkkE46wY4uurF4sPmvMhvj5Zyeqvu99GUE77oj+r2Gu+vTPzRPHFmsvZsa3q3d/gEWiZUhpX4ogtHX/Vd8863nqvHrZ68JaJhnkACi6sNhM/dfTe4TvrJglZr1o109ZQ+AWWRAe/CWFhjXcZN2Ep71vwqbPJfNGN24NDCJwQF82b9uFgrnQyo8sI1P8zgUe2T4TRx/EewzDoDv4KvRPzr0fXFh4ZlN0EAsbWwZZD8OxVaJM7H+pt8hkgJnzh+95cdJms7B9GdPjwFgMqcfrkUzksDZxLhaK6gX+3Xlj2FbaDDA7+b5SBmbSspX07K8eH9GU4a7ilMpqbpo4tJ0eyEdx2crah8a+7zmsZohvZf2MREdftsfpAeAS0oCYcLWFZnmoDgw6lektydjqroeqT9geB4fzDBsJStx80lYBntuUJ0Q500y2n0ofrHO39iBQ9UiZglB2EY/EbJ7fDxUxn7PxTfpQzhuZNXmfem0FCxp7orvLa+HqT0jSeDlbaqv14MSTUMCSz5r8+74Q4Sl5fl55zhGviKron8z8xllYOh4Rnhmx1PbHq432SONMdCuGPsjPgqvpmgOie5DkbMhiErCnDog+fqUzEOwH2G OhOP8CFP /WbFhPD+QvamJ/cx6+rayIRT8h604NlVLrdNuzFef+/tafH+EbZKCaPoWAIXfVLQNkdIw0pWbS0RF0HpmmjVfCstPk1deYTkJi1XkVlerIlsn03pFZl3zDw/GvlFvWjG2WH7IIJ0WVu2Wp9AjPi144NAMSKqQhRD3JmiPEO9p2SKUdm7xQHQvtLLt9ZnRtBi57wrRVoD3pRVTQKUv6E8Pjm1fnt4UB2oT73hAb5EECga/BIpNTfFbnbep8CAxD0OnGNd/tImTCs5kAlobMX6yWHvBR62PkxqX+pwhDWD2KcrSy+0F1/99j3Pm70sFNHan2bo8l6nDYM1i0xXR1qGjDe34R1v7isZyLVyh7AJN6STsDSA63Skp/0p0JgqooWHgzq7XkxiSu+2l3tkLgPpr8A0FIFrdXOS4bl/YOlDj8ak+V1lUkHPEa1YRTny94QPyVJj1vvz/qYUcpwibWtxbc83KTOmePx0klIgAPV4FZDa5+ncGr2tL2ZjFPUDS3thehs8exMTPveqLoB6IBHC1r8nzSZW5Hu0xOmCXwkdzr2AU0hYmMTWY6Jk+Pblm/gkfKGR4 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. There is a difference between GFP_ACCOUNT and what NR_IOMMU_PAGES shows. GFP_ACCOUNT is set only where it makes sense to charge to user processes, i.e. IOMMU Page Tables, but there more IOMMU shared data that should not really be charged to a specific process. Signed-off-by: Pasha Tatashin Acked-by: David Rientjes Tested-by: Bagas Sanjaya --- 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 17e6e9565156..15f80fea8df7 100644 --- a/Documentation/admin-guide/cgroup-v2.rst +++ b/Documentation/admin-guide/cgroup-v2.rst @@ -1432,7 +1432,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 104c6d047d9b..604b2dccdc5a 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 daac2da00e40..6df286931907 100644 --- a/drivers/iommu/iommu-pages.h +++ b/drivers/iommu/iommu-pages.h @@ -30,6 +30,7 @@ static inline void __iommu_alloc_account(struct page *page, int order) const long pgcnt = 1l << order; mod_node_page_state(page_pgdat(page), NR_IOMMU_PAGES, pgcnt); + mod_lruvec_page_state(page, NR_SECONDARY_PAGETABLE, pgcnt); } /** @@ -42,6 +43,7 @@ static inline void __iommu_free_account(struct page *page, int order) const long pgcnt = 1l << order; mod_node_page_state(page_pgdat(page), NR_IOMMU_PAGES, -pgcnt); + mod_lruvec_page_state(page, NR_SECONDARY_PAGETABLE, -pgcnt); } /** diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index bb6bc504915a..a18edcf12d53 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -202,7 +202,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