From patchwork Tue Nov 28 20:49:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13471783 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 DC08DC07E97 for ; Tue, 28 Nov 2023 20:49:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A8F26B0351; Tue, 28 Nov 2023 15:49:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 65A806B0352; Tue, 28 Nov 2023 15:49:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D2AB6B0353; Tue, 28 Nov 2023 15:49:45 -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 3943F6B0351 for ; Tue, 28 Nov 2023 15:49:45 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 08DA0A03A8 for ; Tue, 28 Nov 2023 20:49:45 +0000 (UTC) X-FDA: 81508554330.11.2F11753 Received: from mail-vs1-f41.google.com (mail-vs1-f41.google.com [209.85.217.41]) by imf22.hostedemail.com (Postfix) with ESMTP id 2E8D8C000A for ; Tue, 28 Nov 2023 20:49:42 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b="TlS/z+fY"; dmarc=none; spf=pass (imf22.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.217.41 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=1701204583; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5Yy4hUPviTRiK7d1jgshQ8ZyWUkBDBJBzqyGrbBWtJ8=; b=Fap1dpBDa23L9cXAo3aAT4qSq6IEytwUSnAvdKX2eBexIqC3nJK87MB19L4yhb0Ozt8jL8 /dRhulVMRmArV4Y9h9wT5si7/CQfUYlUnGmxRzSGjgBhDdeKcr1ZbEdikXQIUkdvTUOwHI s3waxjcD46bBxflaJii4krehVSXTxJI= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b="TlS/z+fY"; dmarc=none; spf=pass (imf22.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.217.41 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701204583; a=rsa-sha256; cv=none; b=Fd9C2ywz7vNXY6Cpq3EvITzIuyaNiOUPhSUpWSOTCrmRSD7e+MVfKBh9g4cDk0EYgDVbCa 5tR7OnVtYaUq+yINhVyYctmI7kzZ5YnDSu5ZtbP+22pXpVHBrg5+/8TVc8rl1jaIEWlR/E uxGG6gzX88Q1s77FM7JJzYo7QP4WvuI= Received: by mail-vs1-f41.google.com with SMTP id ada2fe7eead31-46443867752so165017137.0 for ; Tue, 28 Nov 2023 12:49:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701204582; x=1701809382; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=5Yy4hUPviTRiK7d1jgshQ8ZyWUkBDBJBzqyGrbBWtJ8=; b=TlS/z+fYALBTi+mHZKLZslB5wubmQQtRm67TWcONrA30Hb5vXIptBxtxnCzg49sm4p ixDt7cuJCqklWFe+QOf0xqD76u9T5e4stxtlDUE1xy2oGfdT5V0ziKWtrHDU9o21Y/ic p8uwnabauD8MqoP6MIDfZqaoqQKbw/Vyh5ZOdWUIYnDVJw/iyFchjM/Mx5G0KJ2Vh7lm Li1JGNaRJrQCtay8z8zWlx5eb17EXZa5Bvgmz+NVliiWWnMYeBiUbGh3dQZysvIYv2G9 c/nLzdrhsgB/WMjk6GrwrFqhHvR9O/SKDDQSKFQed8bCaX4zr9uhKgvPSUxwFbmMTdXj n2zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701204582; x=1701809382; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5Yy4hUPviTRiK7d1jgshQ8ZyWUkBDBJBzqyGrbBWtJ8=; b=MdwkEGcxxKesXeVLJFDIy4SUZTEgIPJvo+eH9DhwfLygf5EB/Ns0k2nQ8MuiDnCzcs vh3Sntb/EXs7GxSGFHWodppek1w7+l2gLjeA4vJP2G5sm6bxAnHTOstaQiKZO19olmFP 1NpqI8CKrh/1b05Vh7l5U8A56ddwju1KkHHtI9eEXAvi6JoR1nM1xTmA4bqetkSroV90 VzYgYYuX5n8WPb4hPYZ9kFqyGJfel9xV8AON2dTJF7ZEVE5Z8ZuYh/mzyXn9+DpEACJp LV+Q7nQ/MyVT0+mimvzhiPrn45liBIB/usRPz/SvrPCxzNTd1Ul65YNLoTVO44FmN2YY YsuA== X-Gm-Message-State: AOJu0YyIatu5iokO/+Smn6topqPIdRXehC4I9Ac4lLqLtRfKRz/P5rCI AYVCcETGKUcY8JLD9lImDANcJQ== X-Google-Smtp-Source: AGHT+IH8/bEeoEWe4piY4GbZu9GZ1mU2v9u0hs2sQwvgjF+pi6uXD6MYgG32AAFD5esMsPCrla3XFw== X-Received: by 2002:a05:6102:cd4:b0:462:ad06:c90b with SMTP id g20-20020a0561020cd400b00462ad06c90bmr19786797vst.18.1701204582009; Tue, 28 Nov 2023 12:49:42 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id d11-20020a0cfe8b000000b0067a56b6adfesm1056863qvs.71.2023.11.28.12.49.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 12:49:41 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alex.williamson@redhat.com, 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, jasowang@redhat.com, jernej.skrabec@gmail.com, jgg@ziepe.ca, jonathanh@nvidia.com, joro@8bytes.org, kevin.tian@intel.com, krzysztof.kozlowski@linaro.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.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, mst@redhat.com, m.szyprowski@samsung.com, netdev@vger.kernel.org, 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, virtualization@lists.linux.dev, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com Subject: [PATCH 01/16] iommu/vt-d: add wrapper functions for page allocations Date: Tue, 28 Nov 2023 20:49:23 +0000 Message-ID: <20231128204938.1453583-2-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231128204938.1453583-1-pasha.tatashin@soleen.com> References: <20231128204938.1453583-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 2E8D8C000A X-Stat-Signature: djq13b3k7zxk15z51odeariyue7q98yx X-HE-Tag: 1701204582-722874 X-HE-Meta: U2FsdGVkX19I7h69TDeXY0nC/ltdYtkY2MWCn3b/W0lD0W3nqnuwIh5iCNr13Cado3ZgSJJLHM6Sld1oDtyAsOvdx2/9ZInF/EE3/HEFsbAL6IILiN26BXwfuhv8fhUpE1HGKOQVIusjXfjb99r6mkNMIGm4PNXyw5dmh/cHQrc9hg8F0hJh1Y/JJnYqZUKhzeejCtffdp3t+7OTkAQpDOvI0z7xIa+JFyD8lQ+JgOdCk9T5b3jTnM6yoIeq+I34yUeVr+Z/bqdz88YxIDx7mutwmHruotICaYLCkNWJLHHfu6AdGjI+EFBxSwRsHMNsFaW4BUhRRyd3k1T5sf14UYO0/JcGVuY0EJ7x57/bdQuaxyrI3q9bF33r1xpMXzBEAn8ygZs33Rp5si5lxX81bbYkxTYd+QKUq8plvCQ3eYbGnHqEHEdtB2zVDoLPhJTiRhbyMPpBxDpmT7RktA4gv5bYM4saWz0J4FVbyd30moRGTpSlEAssabDdpPZkA/GWjGnJA6qbnz3Zo4wYoNUGmCljfzbZBz3HwP/36BVFkf8x6ViYIrFuF2lpwsvDnpwQFX22m0GoQ4DRmaZgHDowN2xsePZT+Gqb7qPjL1U1qzpZePM/s18dBlUqD3oBG0gfLQcEql+GTGp5u8gpG9m8ODShNFkVHtLKgkgc5sNAW+h57ls7bRfqmn+zcqBp2lDE06FZsahUCe3nsf4POpktOxu8xBVJCurv6G4Vu86TQNWYO0zkQVCic1Qdt7xXq+YXENk7vS6cj4dG0in7OdYwDPx6puEyNiIX8VSq8+gnPaQ20zsysO2M+eO+d/3LFuSFtYooowu9/I0tTmNLXeRQOd+pRYcqeOuV+B2wCKHEU0IXz7n6admHu+dtAs7mDc9l61GDzuZ0LfvZN+CkUvUpG6mJBVEOkNO13gQj6EqJz1CKITpFtaf8iymlNBcdr3ZzV5IkayX0NqxI9PvoryI vcKy7Lpm BpCI3vLsDKOHOaMqWED58e64E2QeMKpFkQAeN3n3v5F8wBchy3NCIWxKLkuJx/NDeWhUC/aBJz6bFmXujYBU7QdwyxeJ5siYCNwtVKbQFOeACCdBpcvHhUt0QbgbykIhC1I3DQl4mrB+O+mHZU/caSrgMzFIWsxAgUHVvdN0B3PEnwOBe/Amot18EoeGlvwf7OBtFRY8Mdpiz+0wuXdHBvu1Dr65UgqgEdUa4+yWrleaExUT6lcrSK/sOAqR4PkZZEmsCC3VhMbI9DTZQxL5XSpcaai9J9pp7cBrXX54heG/V26GyWvh+77h2XuQ3bZi4Wjc3maNlvvjL55vj9hP+kt5JbSGiCfuMc8M3i2KYLeJfWMeYTvX+uYNr2OVV/qOb0NKCuoeB1P0LDMhL4QIb6yRfF1RC/9zRmIcY2luzs++UqbJfUg9hjwz+gPLIccUL5Khw X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: In order to improve observability and accountability of IOMMU layer, we must account the number of pages that are allocated by functions that are calling directly into buddy allocator. This is achieved by first wrapping the allocation related functions into a separate inline functions in new file: drivers/iommu/iommu-pages.h Convert all page allocation calls under iommu/intel to use these new functions. Signed-off-by: Pasha Tatashin --- drivers/iommu/intel/dmar.c | 10 +- drivers/iommu/intel/iommu.c | 47 +++---- drivers/iommu/intel/iommu.h | 2 - drivers/iommu/intel/irq_remapping.c | 10 +- drivers/iommu/intel/pasid.c | 12 +- drivers/iommu/intel/svm.c | 7 +- drivers/iommu/iommu-pages.h | 199 ++++++++++++++++++++++++++++ 7 files changed, 236 insertions(+), 51 deletions(-) create mode 100644 drivers/iommu/iommu-pages.h diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c index a3414afe11b0..a6937e1e20a5 100644 --- a/drivers/iommu/intel/dmar.c +++ b/drivers/iommu/intel/dmar.c @@ -32,6 +32,7 @@ #include "iommu.h" #include "../irq_remapping.h" +#include "../iommu-pages.h" #include "perf.h" #include "trace.h" #include "perfmon.h" @@ -1185,7 +1186,7 @@ static void free_iommu(struct intel_iommu *iommu) } if (iommu->qi) { - free_page((unsigned long)iommu->qi->desc); + iommu_free_page(iommu->qi->desc); kfree(iommu->qi->desc_status); kfree(iommu->qi); } @@ -1714,6 +1715,7 @@ int dmar_enable_qi(struct intel_iommu *iommu) { struct q_inval *qi; struct page *desc_page; + int order; if (!ecap_qis(iommu->ecap)) return -ENOENT; @@ -1734,8 +1736,8 @@ int dmar_enable_qi(struct intel_iommu *iommu) * Need two pages to accommodate 256 descriptors of 256 bits each * if the remapping hardware supports scalable mode translation. */ - desc_page = alloc_pages_node(iommu->node, GFP_ATOMIC | __GFP_ZERO, - !!ecap_smts(iommu->ecap)); + order = ecap_smts(iommu->ecap) ? 1 : 0; + desc_page = __iommu_alloc_pages_node(iommu->node, GFP_ATOMIC, order); if (!desc_page) { kfree(qi); iommu->qi = NULL; @@ -1746,7 +1748,7 @@ int dmar_enable_qi(struct intel_iommu *iommu) qi->desc_status = kcalloc(QI_LENGTH, sizeof(int), GFP_ATOMIC); if (!qi->desc_status) { - free_page((unsigned long) qi->desc); + iommu_free_page(qi->desc); kfree(qi); iommu->qi = NULL; return -ENOMEM; diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 3531b956556c..04f852175cbe 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -28,6 +28,7 @@ #include "../dma-iommu.h" #include "../irq_remapping.h" #include "../iommu-sva.h" +#include "../iommu-pages.h" #include "pasid.h" #include "cap_audit.h" #include "perfmon.h" @@ -367,22 +368,6 @@ static int __init intel_iommu_setup(char *str) } __setup("intel_iommu=", intel_iommu_setup); -void *alloc_pgtable_page(int node, gfp_t gfp) -{ - struct page *page; - void *vaddr = NULL; - - page = alloc_pages_node(node, gfp | __GFP_ZERO, 0); - if (page) - vaddr = page_address(page); - return vaddr; -} - -void free_pgtable_page(void *vaddr) -{ - free_page((unsigned long)vaddr); -} - static inline int domain_type_is_si(struct dmar_domain *domain) { return domain->domain.type == IOMMU_DOMAIN_IDENTITY; @@ -617,7 +602,7 @@ struct context_entry *iommu_context_addr(struct intel_iommu *iommu, u8 bus, if (!alloc) return NULL; - context = alloc_pgtable_page(iommu->node, GFP_ATOMIC); + context = iommu_alloc_page_node(iommu->node, GFP_ATOMIC); if (!context) return NULL; @@ -791,17 +776,17 @@ static void free_context_table(struct intel_iommu *iommu) for (i = 0; i < ROOT_ENTRY_NR; i++) { context = iommu_context_addr(iommu, i, 0, 0); if (context) - free_pgtable_page(context); + iommu_free_page(context); if (!sm_supported(iommu)) continue; context = iommu_context_addr(iommu, i, 0x80, 0); if (context) - free_pgtable_page(context); + iommu_free_page(context); } - free_pgtable_page(iommu->root_entry); + iommu_free_page(iommu->root_entry); iommu->root_entry = NULL; } @@ -939,7 +924,7 @@ static struct dma_pte *pfn_to_dma_pte(struct dmar_domain *domain, if (!dma_pte_present(pte)) { uint64_t pteval; - tmp_page = alloc_pgtable_page(domain->nid, gfp); + tmp_page = iommu_alloc_page_node(domain->nid, gfp); if (!tmp_page) return NULL; @@ -951,7 +936,7 @@ static struct dma_pte *pfn_to_dma_pte(struct dmar_domain *domain, if (cmpxchg64(&pte->val, 0ULL, pteval)) /* Someone else set it while we were thinking; use theirs. */ - free_pgtable_page(tmp_page); + iommu_free_page(tmp_page); else domain_flush_cache(domain, pte, sizeof(*pte)); } @@ -1064,7 +1049,7 @@ static void dma_pte_free_level(struct dmar_domain *domain, int level, last_pfn < level_pfn + level_size(level) - 1)) { dma_clear_pte(pte); domain_flush_cache(domain, pte, sizeof(*pte)); - free_pgtable_page(level_pte); + iommu_free_page(level_pte); } next: pfn += level_size(level); @@ -1088,7 +1073,7 @@ static void dma_pte_free_pagetable(struct dmar_domain *domain, /* free pgd */ if (start_pfn == 0 && last_pfn == DOMAIN_MAX_PFN(domain->gaw)) { - free_pgtable_page(domain->pgd); + iommu_free_page(domain->pgd); domain->pgd = NULL; } } @@ -1190,7 +1175,7 @@ static int iommu_alloc_root_entry(struct intel_iommu *iommu) { struct root_entry *root; - root = alloc_pgtable_page(iommu->node, GFP_ATOMIC); + root = iommu_alloc_page_node(iommu->node, GFP_ATOMIC); if (!root) { pr_err("Allocating root entry for %s failed\n", iommu->name); @@ -1863,7 +1848,7 @@ static void domain_exit(struct dmar_domain *domain) LIST_HEAD(freelist); domain_unmap(domain, 0, DOMAIN_MAX_PFN(domain->gaw), &freelist); - put_pages_list(&freelist); + iommu_free_pages_list(&freelist); } if (WARN_ON(!list_empty(&domain->devices))) @@ -2637,7 +2622,7 @@ static int copy_context_table(struct intel_iommu *iommu, if (!old_ce) goto out; - new_ce = alloc_pgtable_page(iommu->node, GFP_KERNEL); + new_ce = iommu_alloc_page_node(iommu->node, GFP_KERNEL); if (!new_ce) goto out_unmap; @@ -3570,7 +3555,7 @@ static int intel_iommu_memory_notifier(struct notifier_block *nb, start_vpfn, mhp->nr_pages, list_empty(&freelist), 0); rcu_read_unlock(); - put_pages_list(&freelist); + iommu_free_pages_list(&freelist); } break; } @@ -4001,7 +3986,7 @@ static int md_domain_init(struct dmar_domain *domain, int guest_width) domain->max_addr = 0; /* always allocate the top pgd */ - domain->pgd = alloc_pgtable_page(domain->nid, GFP_ATOMIC); + domain->pgd = iommu_alloc_page_node(domain->nid, GFP_ATOMIC); if (!domain->pgd) return -ENOMEM; domain_flush_cache(domain, domain->pgd, PAGE_SIZE); @@ -4148,7 +4133,7 @@ int prepare_domain_attach_device(struct iommu_domain *domain, pte = dmar_domain->pgd; if (dma_pte_present(pte)) { dmar_domain->pgd = phys_to_virt(dma_pte_addr(pte)); - free_pgtable_page(pte); + iommu_free_page(pte); } dmar_domain->agaw--; } @@ -4295,7 +4280,7 @@ static void intel_iommu_tlb_sync(struct iommu_domain *domain, start_pfn, nrpages, list_empty(&gather->freelist), 0); - put_pages_list(&gather->freelist); + iommu_free_pages_list(&gather->freelist); } static phys_addr_t intel_iommu_iova_to_phys(struct iommu_domain *domain, diff --git a/drivers/iommu/intel/iommu.h b/drivers/iommu/intel/iommu.h index 65d37a138c75..b505f3f44d0a 100644 --- a/drivers/iommu/intel/iommu.h +++ b/drivers/iommu/intel/iommu.h @@ -894,8 +894,6 @@ void domain_update_iommu_cap(struct dmar_domain *domain); int dmar_ir_support(void); -void *alloc_pgtable_page(int node, gfp_t gfp); -void free_pgtable_page(void *vaddr); void iommu_flush_write_buffer(struct intel_iommu *iommu); struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devfn); struct iommu_domain *intel_nested_domain_alloc(struct iommu_domain *parent, diff --git a/drivers/iommu/intel/irq_remapping.c b/drivers/iommu/intel/irq_remapping.c index 29b9e55dcf26..72e1c1342c13 100644 --- a/drivers/iommu/intel/irq_remapping.c +++ b/drivers/iommu/intel/irq_remapping.c @@ -22,6 +22,7 @@ #include "iommu.h" #include "../irq_remapping.h" +#include "../iommu-pages.h" #include "cap_audit.h" enum irq_mode { @@ -536,8 +537,8 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu) if (!ir_table) return -ENOMEM; - pages = alloc_pages_node(iommu->node, GFP_KERNEL | __GFP_ZERO, - INTR_REMAP_PAGE_ORDER); + pages = __iommu_alloc_pages_node(iommu->node, GFP_KERNEL, + INTR_REMAP_PAGE_ORDER); if (!pages) { pr_err("IR%d: failed to allocate pages of order %d\n", iommu->seq_id, INTR_REMAP_PAGE_ORDER); @@ -622,7 +623,7 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu) out_free_bitmap: bitmap_free(bitmap); out_free_pages: - __free_pages(pages, INTR_REMAP_PAGE_ORDER); + __iommu_free_pages(pages, INTR_REMAP_PAGE_ORDER); out_free_table: kfree(ir_table); @@ -643,8 +644,7 @@ static void intel_teardown_irq_remapping(struct intel_iommu *iommu) irq_domain_free_fwnode(fn); iommu->ir_domain = NULL; } - free_pages((unsigned long)iommu->ir_table->base, - INTR_REMAP_PAGE_ORDER); + iommu_free_pages(iommu->ir_table->base, INTR_REMAP_PAGE_ORDER); bitmap_free(iommu->ir_table->bitmap); kfree(iommu->ir_table); iommu->ir_table = NULL; diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index 74e8e4c17e81..1856e74bba78 100644 --- a/drivers/iommu/intel/pasid.c +++ b/drivers/iommu/intel/pasid.c @@ -20,6 +20,7 @@ #include "iommu.h" #include "pasid.h" +#include "../iommu-pages.h" /* * Intel IOMMU system wide PASID name space: @@ -116,8 +117,7 @@ int intel_pasid_alloc_table(struct device *dev) size = max_pasid >> (PASID_PDE_SHIFT - 3); order = size ? get_order(size) : 0; - pages = alloc_pages_node(info->iommu->node, - GFP_KERNEL | __GFP_ZERO, order); + pages = __iommu_alloc_pages_node(info->iommu->node, GFP_KERNEL, order); if (!pages) { kfree(pasid_table); return -ENOMEM; @@ -154,10 +154,10 @@ void intel_pasid_free_table(struct device *dev) max_pde = pasid_table->max_pasid >> PASID_PDE_SHIFT; for (i = 0; i < max_pde; i++) { table = get_pasid_table_from_pde(&dir[i]); - free_pgtable_page(table); + iommu_free_page(table); } - free_pages((unsigned long)pasid_table->table, pasid_table->order); + iommu_free_pages(pasid_table->table, pasid_table->order); kfree(pasid_table); } @@ -203,7 +203,7 @@ static struct pasid_entry *intel_pasid_get_entry(struct device *dev, u32 pasid) retry: entries = get_pasid_table_from_pde(&dir[dir_index]); if (!entries) { - entries = alloc_pgtable_page(info->iommu->node, GFP_ATOMIC); + entries = iommu_alloc_page_node(info->iommu->node, GFP_ATOMIC); if (!entries) return NULL; @@ -215,7 +215,7 @@ static struct pasid_entry *intel_pasid_get_entry(struct device *dev, u32 pasid) */ if (cmpxchg64(&dir[dir_index].val, 0ULL, (u64)virt_to_phys(entries) | PASID_PTE_PRESENT)) { - free_pgtable_page(entries); + iommu_free_page(entries); goto retry; } if (!ecap_coherent(info->iommu->ecap)) { diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c index 50a481c895b8..4cf8826b30e1 100644 --- a/drivers/iommu/intel/svm.c +++ b/drivers/iommu/intel/svm.c @@ -23,6 +23,7 @@ #include "pasid.h" #include "perf.h" #include "../iommu-sva.h" +#include "../iommu-pages.h" #include "trace.h" static irqreturn_t prq_event_thread(int irq, void *d); @@ -67,7 +68,7 @@ int intel_svm_enable_prq(struct intel_iommu *iommu) struct page *pages; int irq, ret; - pages = alloc_pages(GFP_KERNEL | __GFP_ZERO, PRQ_ORDER); + pages = __iommu_alloc_pages(GFP_KERNEL, PRQ_ORDER); if (!pages) { pr_warn("IOMMU: %s: Failed to allocate page request queue\n", iommu->name); @@ -118,7 +119,7 @@ int intel_svm_enable_prq(struct intel_iommu *iommu) dmar_free_hwirq(irq); iommu->pr_irq = 0; free_prq: - free_pages((unsigned long)iommu->prq, PRQ_ORDER); + iommu_free_pages(iommu->prq, PRQ_ORDER); iommu->prq = NULL; return ret; @@ -141,7 +142,7 @@ int intel_svm_finish_prq(struct intel_iommu *iommu) iommu->iopf_queue = NULL; } - free_pages((unsigned long)iommu->prq, PRQ_ORDER); + iommu_free_pages(iommu->prq, PRQ_ORDER); iommu->prq = NULL; return 0; diff --git a/drivers/iommu/iommu-pages.h b/drivers/iommu/iommu-pages.h new file mode 100644 index 000000000000..2332f807d514 --- /dev/null +++ b/drivers/iommu/iommu-pages.h @@ -0,0 +1,199 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2023, Google LLC. + * Pasha Tatashin + */ + +#ifndef __IOMMU_PAGES_H +#define __IOMMU_PAGES_H + +#include +#include +#include + +/* + * All page allocation that are performed in the IOMMU subsystem must use one of + * the functions below. This is necessary for the proper accounting as IOMMU + * state can be rather large, i.e. multiple gigabytes in size. + */ + +/** + * __iommu_alloc_pages_node - allocate a zeroed page of a given order from + * specific NUMA node. + * @nid: memory NUMA node id + * @gfp: buddy allocator flags + * @order: page order + * + * returns the head struct page of the allocated page. + */ +static inline struct page *__iommu_alloc_pages_node(int nid, gfp_t gfp, + int order) +{ + struct page *pages; + + pages = alloc_pages_node(nid, gfp | __GFP_ZERO, order); + if (!pages) + return NULL; + + return pages; +} + +/** + * __iommu_alloc_pages - allocate a zeroed page of a given order. + * @gfp: buddy allocator flags + * @order: page order + * + * returns the head struct page of the allocated page. + */ +static inline struct page *__iommu_alloc_pages(gfp_t gfp, int order) +{ + struct page *pages; + + pages = alloc_pages(gfp | __GFP_ZERO, order); + if (!pages) + return NULL; + + return pages; +} + +/** + * __iommu_alloc_page_node - allocate a zeroed page at specific NUMA node. + * @nid: memory NUMA node id + * @gfp: buddy allocator flags + * + * returns the struct page of the allocated page. + */ +static inline struct page *__iommu_alloc_page_node(int nid, gfp_t gfp) +{ + return __iommu_alloc_pages_node(nid, gfp, 0); +} + +/** + * __iommu_alloc_page - allocate a zeroed page + * @gfp: buddy allocator flags + * + * returns the struct page of the allocated page. + */ +static inline struct page *__iommu_alloc_page(gfp_t gfp) +{ + return __iommu_alloc_pages(gfp, 0); +} + +/** + * __iommu_free_pages - free page of a given order + * @pages: head struct page of the page + * @order: page order + */ +static inline void __iommu_free_pages(struct page *pages, int order) +{ + if (!pages) + return; + + __free_pages(pages, order); +} + +/** + * __iommu_free_page - free page + * @page: struct page of the page + */ +static inline void __iommu_free_page(struct page *page) +{ + __iommu_free_pages(page, 0); +} + +/** + * iommu_alloc_pages_node - allocate a zeroed page of a given order from + * specific NUMA node. + * @nid: memory NUMA node id + * @gfp: buddy allocator flags + * @order: page order + * + * returns the virtual address of the allocated page + */ +static inline void *iommu_alloc_pages_node(int nid, gfp_t gfp, int order) +{ + struct page *pages = __iommu_alloc_pages_node(nid, gfp, order); + + if (!pages) + return NULL; + + return page_address(pages); +} + +/** + * iommu_alloc_pages - allocate a zeroed page of a given order + * @gfp: buddy allocator flags + * @order: page order + * + * returns the virtual address of the allocated page + */ +static inline void *iommu_alloc_pages(gfp_t gfp, int order) +{ + struct page *pages = __iommu_alloc_pages(gfp, order); + + if (!pages) + return NULL; + + return page_address(pages); +} + +/** + * iommu_alloc_page_node - allocate a zeroed page at specific NUMA node. + * @nid: memory NUMA node id + * @gfp: buddy allocator flags + * + * returns the virtual address of the allocated page + */ +static inline void *iommu_alloc_page_node(int nid, gfp_t gfp) +{ + return iommu_alloc_pages_node(nid, gfp, 0); +} + +/** + * iommu_alloc_page - allocate a zeroed page + * @gfp: buddy allocator flags + * + * returns the virtual address of the allocated page + */ +static inline void *iommu_alloc_page(gfp_t gfp) +{ + return iommu_alloc_pages(gfp, 0); +} + +/** + * iommu_free_pages - free page of a given order + * @virt: virtual address of the page to be freed. + * @order: page order + */ +static inline void iommu_free_pages(void *virt, int order) +{ + if (!virt) + return; + + __iommu_free_pages(virt_to_page(virt), order); +} + +/** + * iommu_free_page - free page + * @virt: virtual address of the page to be freed. + */ +static inline void iommu_free_page(void *virt) +{ + iommu_free_pages(virt, 0); +} + +/** + * iommu_free_pages_list - free a list of pages. + * @pages: the head of the lru list to be freed. + */ +static inline void iommu_free_pages_list(struct list_head *pages) +{ + while (!list_empty(pages)) { + struct page *p = list_entry(pages->prev, struct page, lru); + + list_del(&p->lru); + put_page(p); + } +} + +#endif /* __IOMMU_PAGES_H */ From patchwork Tue Nov 28 20:49:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13471784 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 2E2FAC4167B for ; Tue, 28 Nov 2023 20:49:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5234F6B0352; Tue, 28 Nov 2023 15:49:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4ABB16B0353; Tue, 28 Nov 2023 15:49:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2B0B76B0354; Tue, 28 Nov 2023 15:49:46 -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 1B7CD6B0352 for ; Tue, 28 Nov 2023 15:49:46 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F2EC3A020B for ; Tue, 28 Nov 2023 20:49:45 +0000 (UTC) X-FDA: 81508554330.01.3A2D611 Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) by imf08.hostedemail.com (Postfix) with ESMTP id 2FE0B16001E for ; Tue, 28 Nov 2023 20:49:44 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=GJGWqzEm; dmarc=none; spf=pass (imf08.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.48 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=1701204584; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=k1GabcB3edaQg1Ui1Yy9urjYmEO9oSCGrDI9SMXfmmE=; b=ucsXzvBHhMdu0BeiH8ehklsewPnC4yBs12GHoDCKua1/ftgmz7o5qVJJQeSxhOYHPAIjVu Xo0KJ4mHwOYc8tKsr7gl+BbkukhZ4NdPHtQ2okdMqfCq4XP/sqPmBn9qcDJjTi1yq3cetq 9AlSJInrpOb9VUtZKby3tfZq86z4juA= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=GJGWqzEm; dmarc=none; spf=pass (imf08.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.48 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701204584; a=rsa-sha256; cv=none; b=yZHiTIRhii11kRMbswzYKqpipnqLwUpR6VjsG66COLVyPF1iD7yHodc4oYT51479p0epdA mhslHcEzmioOq3l2QzhbW5xSI5AwDPuyLw85I75rxDFHW302jFqT/K73xsFZWeJtzPSf96 5nvmPyVdfPsMtknWRuSm0xfd7Jf36IA= Received: by mail-qv1-f48.google.com with SMTP id 6a1803df08f44-67a5cebbd36so4847326d6.3 for ; Tue, 28 Nov 2023 12:49:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701204583; x=1701809383; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=k1GabcB3edaQg1Ui1Yy9urjYmEO9oSCGrDI9SMXfmmE=; b=GJGWqzEmwxuYZRDgpqYAjo5biEf1TiJm9af8eKsUlrGFiHxuKQalVYcuMgBuNXUqfA v3CUggc6KdJHo7+sLTeukzhxS34MLy3NVA6IZWjISuXZlGYAYmxLhIKq6Dg37ZK2k0m/ Uqty9HFtyWn9gjsZTGkrIIf1YFUlXWGDV1cVIgnT589UPcg89wLYToP2IWNzDw1tTPgu bUdrD7b657/K7ELLFNjS7sq+/rqbD3aLzRL94mlpmAWPFfakVpY9g8fBwgGzj/PINGLZ q/h+OLZs4AVbP32vDa3Ke/oB+wwvQ8/iuYFQkbyPVncd+3q+I8lNRv8BbG0V6Yfdun+e L7HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701204583; x=1701809383; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=k1GabcB3edaQg1Ui1Yy9urjYmEO9oSCGrDI9SMXfmmE=; b=Wn1IKf+cpB+4km2XgOFKdaXRwUMeoxj2uZzVkgKOz7r/CW6vsP4Iu1//chcdL8xM15 nj5tK7Qn18zonuSY882SmM+lzfpGKdlHE5avEnQYrwQnXQm1TW7XqZuCY9aProDxpeHX fh9S9txkHnBR+E8i/sy3vJbMA+kWhsXqICi2vdYlZsEC49gEyIxxZVyh2xiD2p/bDCyP HFOKVY/GaV8fyKGoQcpU+BUyuPG8uPte+1N95YX5ac6XQdKx3he3k19iAhrV5HjuJHV4 8YBFrN23YP2n6Q34PFKZA+KUyqw3/tNBb7U/cc0eo+0z1F76I0IMUOjl3joZhJMdpSnI Ou/w== X-Gm-Message-State: AOJu0YxJadAveovBda44Ed1dneQvU/7GfRKYQW8hfYqHJy+xXcghuhPb qBZ4/4kYRD7QT94KsC4CMb4cUQ== X-Google-Smtp-Source: AGHT+IFZ2J6ifaJU9E1oZ5e/lDPloT8/cUCHwQamxmJzlr5gT1J0RGoEUSTPlGzdwJlACbJO6NjPTw== X-Received: by 2002:ad4:580a:0:b0:67a:26ad:fabc with SMTP id dd10-20020ad4580a000000b0067a26adfabcmr10428038qvb.22.1701204583234; Tue, 28 Nov 2023 12:49:43 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id d11-20020a0cfe8b000000b0067a56b6adfesm1056863qvs.71.2023.11.28.12.49.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 12:49:42 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alex.williamson@redhat.com, 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, jasowang@redhat.com, jernej.skrabec@gmail.com, jgg@ziepe.ca, jonathanh@nvidia.com, joro@8bytes.org, kevin.tian@intel.com, krzysztof.kozlowski@linaro.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.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, mst@redhat.com, m.szyprowski@samsung.com, netdev@vger.kernel.org, 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, virtualization@lists.linux.dev, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com Subject: [PATCH 02/16] iommu/amd: use page allocation function provided by iommu-pages.h Date: Tue, 28 Nov 2023 20:49:24 +0000 Message-ID: <20231128204938.1453583-3-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231128204938.1453583-1-pasha.tatashin@soleen.com> References: <20231128204938.1453583-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 2FE0B16001E X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: xih4aqea5rb1kjyqq1ap8q7pyh4ojss1 X-HE-Tag: 1701204584-983573 X-HE-Meta: U2FsdGVkX19lCJCZ84hpgu5nN7sFRdZIYotLlQwi/WVorEdjtwjKhYbVjdAA3X7RU1XnlHE/yhfBlax+gJhoFDK/Oy5hpKZkHgwJOVuCrqaSral7hfr3yIi/4KFTzSPGz6XTu8S09mxTPivlfXki/zsS9X2A/e9wExXAQQ7eJs3SuDt7G4S/mDNPpN1T0E00EE/7fM4bjLTPecof46NyRMVdd6+xjvFYs4OlfEnBvjM+yZYftjcHKH6SG5HZesvpNBYmzrHxwxMAK+zUMk6LeIhhR6of574mlFglXt10FLTefK7i/1Gg5vbKDdIDULJARwqa28SH5H8SOg8bZ1xMGLfvb5Bayfvp8NfZz8CMTtSVTvGuCvX7WJZYY7HbClQvu0jidMpbmeLKaOI0uLd0GA+lN4HFqQ+W8yapOOXM8NKOSahoHfSA/wE0xY2be01BaVWVXZ0SdFbMfqeDAXljgHgB1CHtc95sPhg8CfEvWXc22seyQT4R5PoR2dYb3wfxC89QeaYYCgJj8H6zbvthwkCBhyil5xhD+0t1G6pNqbWMeQ0m4EdAGDvBRXbl7MZB9iYJh8SN7rtmaoi77PcnZaVMq0muTmKGz0+q1njyHxULqoxOZrLL3DXj+fn1NSW/LzCuJ2TEXQCwNkILC8NMb8v3vvylnClAbM7fMrBgBNGWNzWX47aqdkiouSWCokMY8PjT0vySsbfhrTQ0ndBfm8xZN0HYGx8P9Tf1WlIZP1lS6zIToTIuTSWxryHF/tU5HQxJJXk/UrtNtPdU/j/6mz9KxLhIrd0mXau5DsJILNA4cXgAx/x21Obva1+aPyLw/c8JtquCtTQtsaf+HBPfAepDQeokh5f6m/b6WOsYQeFrRi+iwRd8FT80W6QDTL3FNY7rusglu2Fl6q26zbmNJV0vw/EPPTrVqhp07jlPr4w2K37uRumWhOPnWTDBj68PUl8A+d1bthPSdYRV97e y6bE9MY+ Zmys/mwf2F9B4Ma51m8xtgx3iWywFVMf9wOYzW82ruwcjO5DsO6kdd1ilXls0mv+UfDF7hA+X5chalOdN4iJbdMruYk6LCfhwIvW/ppoWmAvvbnEMTN/yEq49Ypxkx29dVcaic1icnb+mBbKLGBnU8L/PVFpQGEdXSq7/kpW1fTpSW/FM3Ao1y3I17OUJOJuwv94q/R6wcjXSST6upjgnEQ9RyD3UMpjOkctzqbZsQk6Vlfdtn9HFHJrFy8oaA7RFEXyuYSq0BvJQ/L3B1DP/rNj7cdKtLl8uNwXd7Drvojo/KrS6ujWlx4UY21zmwMSdECEIenyL9zRiOyYBxlKctRD8VdqWjhoZ4pIN 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 --- drivers/iommu/amd/amd_iommu.h | 8 --- drivers/iommu/amd/init.c | 91 ++++++++++++++----------------- drivers/iommu/amd/io_pgtable.c | 13 +++-- drivers/iommu/amd/io_pgtable_v2.c | 20 +++---- drivers/iommu/amd/iommu.c | 13 +++-- 5 files changed, 64 insertions(+), 81 deletions(-) diff --git a/drivers/iommu/amd/amd_iommu.h b/drivers/iommu/amd/amd_iommu.h index 86be1edd50ee..bf697d566e0b 100644 --- a/drivers/iommu/amd/amd_iommu.h +++ b/drivers/iommu/amd/amd_iommu.h @@ -136,14 +136,6 @@ static inline int get_pci_sbdf_id(struct pci_dev *pdev) return PCI_SEG_DEVID_TO_SBDF(seg, devid); } -static inline void *alloc_pgtable_page(int nid, gfp_t gfp) -{ - struct page *page; - - page = alloc_pages_node(nid, gfp | __GFP_ZERO, 0); - return page ? page_address(page) : NULL; -} - bool translation_pre_enabled(struct amd_iommu *iommu); bool amd_iommu_is_attach_deferred(struct device *dev); int __init add_special_device(u8 type, u8 id, u32 *devid, bool cmd_line); diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c index 64bcf3df37ee..5b8a80fc7e50 100644 --- a/drivers/iommu/amd/init.c +++ b/drivers/iommu/amd/init.c @@ -35,6 +35,7 @@ #include "amd_iommu.h" #include "../irq_remapping.h" +#include "../iommu-pages.h" /* * definitions for the ACPI scanning code @@ -648,8 +649,8 @@ static int __init find_last_devid_acpi(struct acpi_table_header *table, u16 pci_ /* Allocate per PCI segment device table */ static inline int __init alloc_dev_table(struct amd_iommu_pci_seg *pci_seg) { - pci_seg->dev_table = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO | GFP_DMA32, - get_order(pci_seg->dev_table_size)); + pci_seg->dev_table = iommu_alloc_pages(GFP_KERNEL | GFP_DMA32, + get_order(pci_seg->dev_table_size)); if (!pci_seg->dev_table) return -ENOMEM; @@ -658,17 +659,16 @@ static inline int __init alloc_dev_table(struct amd_iommu_pci_seg *pci_seg) static inline void free_dev_table(struct amd_iommu_pci_seg *pci_seg) { - free_pages((unsigned long)pci_seg->dev_table, - get_order(pci_seg->dev_table_size)); + iommu_free_pages(pci_seg->dev_table, + get_order(pci_seg->dev_table_size)); pci_seg->dev_table = NULL; } /* Allocate per PCI segment IOMMU rlookup table. */ static inline int __init alloc_rlookup_table(struct amd_iommu_pci_seg *pci_seg) { - pci_seg->rlookup_table = (void *)__get_free_pages( - GFP_KERNEL | __GFP_ZERO, - get_order(pci_seg->rlookup_table_size)); + pci_seg->rlookup_table = iommu_alloc_pages(GFP_KERNEL, + get_order(pci_seg->rlookup_table_size)); if (pci_seg->rlookup_table == NULL) return -ENOMEM; @@ -677,16 +677,15 @@ static inline int __init alloc_rlookup_table(struct amd_iommu_pci_seg *pci_seg) static inline void free_rlookup_table(struct amd_iommu_pci_seg *pci_seg) { - free_pages((unsigned long)pci_seg->rlookup_table, - get_order(pci_seg->rlookup_table_size)); + iommu_free_pages(pci_seg->rlookup_table, + get_order(pci_seg->rlookup_table_size)); pci_seg->rlookup_table = NULL; } static inline int __init alloc_irq_lookup_table(struct amd_iommu_pci_seg *pci_seg) { - pci_seg->irq_lookup_table = (void *)__get_free_pages( - GFP_KERNEL | __GFP_ZERO, - get_order(pci_seg->rlookup_table_size)); + pci_seg->irq_lookup_table = iommu_alloc_pages(GFP_KERNEL, + get_order(pci_seg->rlookup_table_size)); kmemleak_alloc(pci_seg->irq_lookup_table, pci_seg->rlookup_table_size, 1, GFP_KERNEL); if (pci_seg->irq_lookup_table == NULL) @@ -698,8 +697,8 @@ static inline int __init alloc_irq_lookup_table(struct amd_iommu_pci_seg *pci_se static inline void free_irq_lookup_table(struct amd_iommu_pci_seg *pci_seg) { kmemleak_free(pci_seg->irq_lookup_table); - free_pages((unsigned long)pci_seg->irq_lookup_table, - get_order(pci_seg->rlookup_table_size)); + iommu_free_pages(pci_seg->irq_lookup_table, + get_order(pci_seg->rlookup_table_size)); pci_seg->irq_lookup_table = NULL; } @@ -707,8 +706,8 @@ static int __init alloc_alias_table(struct amd_iommu_pci_seg *pci_seg) { int i; - pci_seg->alias_table = (void *)__get_free_pages(GFP_KERNEL, - get_order(pci_seg->alias_table_size)); + pci_seg->alias_table = iommu_alloc_pages(GFP_KERNEL, + get_order(pci_seg->alias_table_size)); if (!pci_seg->alias_table) return -ENOMEM; @@ -723,8 +722,8 @@ static int __init alloc_alias_table(struct amd_iommu_pci_seg *pci_seg) static void __init free_alias_table(struct amd_iommu_pci_seg *pci_seg) { - free_pages((unsigned long)pci_seg->alias_table, - get_order(pci_seg->alias_table_size)); + iommu_free_pages(pci_seg->alias_table, + get_order(pci_seg->alias_table_size)); pci_seg->alias_table = NULL; } @@ -735,8 +734,8 @@ static void __init free_alias_table(struct amd_iommu_pci_seg *pci_seg) */ static int __init alloc_command_buffer(struct amd_iommu *iommu) { - iommu->cmd_buf = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, - get_order(CMD_BUFFER_SIZE)); + iommu->cmd_buf = iommu_alloc_pages(GFP_KERNEL, + get_order(CMD_BUFFER_SIZE)); return iommu->cmd_buf ? 0 : -ENOMEM; } @@ -844,19 +843,19 @@ static void iommu_disable_command_buffer(struct amd_iommu *iommu) static void __init free_command_buffer(struct amd_iommu *iommu) { - free_pages((unsigned long)iommu->cmd_buf, get_order(CMD_BUFFER_SIZE)); + iommu_free_pages(iommu->cmd_buf, get_order(CMD_BUFFER_SIZE)); } static void *__init iommu_alloc_4k_pages(struct amd_iommu *iommu, gfp_t gfp, size_t size) { int order = get_order(size); - void *buf = (void *)__get_free_pages(gfp, order); + void *buf = iommu_alloc_pages(gfp, order); if (buf && check_feature(FEATURE_SNP) && set_memory_4k((unsigned long)buf, (1 << order))) { - free_pages((unsigned long)buf, order); + iommu_free_pages(buf, order); buf = NULL; } @@ -866,7 +865,7 @@ static void *__init iommu_alloc_4k_pages(struct amd_iommu *iommu, /* allocates the memory where the IOMMU will log its events to */ static int __init alloc_event_buffer(struct amd_iommu *iommu) { - iommu->evt_buf = iommu_alloc_4k_pages(iommu, GFP_KERNEL | __GFP_ZERO, + iommu->evt_buf = iommu_alloc_4k_pages(iommu, GFP_KERNEL, EVT_BUFFER_SIZE); return iommu->evt_buf ? 0 : -ENOMEM; @@ -900,14 +899,13 @@ static void iommu_disable_event_buffer(struct amd_iommu *iommu) static void __init free_event_buffer(struct amd_iommu *iommu) { - free_pages((unsigned long)iommu->evt_buf, get_order(EVT_BUFFER_SIZE)); + iommu_free_pages(iommu->evt_buf, get_order(EVT_BUFFER_SIZE)); } /* allocates the memory where the IOMMU will log its events to */ static int __init alloc_ppr_log(struct amd_iommu *iommu) { - iommu->ppr_log = iommu_alloc_4k_pages(iommu, GFP_KERNEL | __GFP_ZERO, - PPR_LOG_SIZE); + iommu->ppr_log = iommu_alloc_4k_pages(iommu, GFP_KERNEL, PPR_LOG_SIZE); return iommu->ppr_log ? 0 : -ENOMEM; } @@ -936,14 +934,14 @@ static void iommu_enable_ppr_log(struct amd_iommu *iommu) static void __init free_ppr_log(struct amd_iommu *iommu) { - free_pages((unsigned long)iommu->ppr_log, get_order(PPR_LOG_SIZE)); + iommu_free_pages(iommu->ppr_log, get_order(PPR_LOG_SIZE)); } static void free_ga_log(struct amd_iommu *iommu) { #ifdef CONFIG_IRQ_REMAP - free_pages((unsigned long)iommu->ga_log, get_order(GA_LOG_SIZE)); - free_pages((unsigned long)iommu->ga_log_tail, get_order(8)); + iommu_free_pages(iommu->ga_log, get_order(GA_LOG_SIZE)); + iommu_free_pages(iommu->ga_log_tail, get_order(8)); #endif } @@ -988,13 +986,11 @@ static int iommu_init_ga_log(struct amd_iommu *iommu) if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir)) return 0; - iommu->ga_log = (u8 *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, - get_order(GA_LOG_SIZE)); + iommu->ga_log = iommu_alloc_pages(GFP_KERNEL, get_order(GA_LOG_SIZE)); if (!iommu->ga_log) goto err_out; - iommu->ga_log_tail = (u8 *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, - get_order(8)); + iommu->ga_log_tail = iommu_alloc_pages(GFP_KERNEL, get_order(8)); if (!iommu->ga_log_tail) goto err_out; @@ -1007,7 +1003,7 @@ static int iommu_init_ga_log(struct amd_iommu *iommu) static int __init alloc_cwwb_sem(struct amd_iommu *iommu) { - iommu->cmd_sem = iommu_alloc_4k_pages(iommu, GFP_KERNEL | __GFP_ZERO, 1); + iommu->cmd_sem = iommu_alloc_4k_pages(iommu, GFP_KERNEL, 1); return iommu->cmd_sem ? 0 : -ENOMEM; } @@ -1015,7 +1011,7 @@ static int __init alloc_cwwb_sem(struct amd_iommu *iommu) static void __init free_cwwb_sem(struct amd_iommu *iommu) { if (iommu->cmd_sem) - free_page((unsigned long)iommu->cmd_sem); + iommu_free_page((void *)iommu->cmd_sem); } static void iommu_enable_xt(struct amd_iommu *iommu) @@ -1080,7 +1076,6 @@ static bool __copy_device_table(struct amd_iommu *iommu) u32 lo, hi, devid, old_devtb_size; phys_addr_t old_devtb_phys; u16 dom_id, dte_v, irq_v; - gfp_t gfp_flag; u64 tmp; /* Each IOMMU use separate device table with the same size */ @@ -1114,9 +1109,8 @@ static bool __copy_device_table(struct amd_iommu *iommu) if (!old_devtb) return false; - gfp_flag = GFP_KERNEL | __GFP_ZERO | GFP_DMA32; - pci_seg->old_dev_tbl_cpy = (void *)__get_free_pages(gfp_flag, - get_order(pci_seg->dev_table_size)); + pci_seg->old_dev_tbl_cpy = iommu_alloc_pages(GFP_KERNEL | GFP_DMA32, + get_order(pci_seg->dev_table_size)); if (pci_seg->old_dev_tbl_cpy == NULL) { pr_err("Failed to allocate memory for copying old device table!\n"); memunmap(old_devtb); @@ -2800,8 +2794,8 @@ static void early_enable_iommus(void) for_each_pci_segment(pci_seg) { if (pci_seg->old_dev_tbl_cpy != NULL) { - free_pages((unsigned long)pci_seg->old_dev_tbl_cpy, - get_order(pci_seg->dev_table_size)); + iommu_free_pages(pci_seg->old_dev_tbl_cpy, + get_order(pci_seg->dev_table_size)); pci_seg->old_dev_tbl_cpy = NULL; } } @@ -2814,8 +2808,8 @@ static void early_enable_iommus(void) pr_info("Copied DEV table from previous kernel.\n"); for_each_pci_segment(pci_seg) { - free_pages((unsigned long)pci_seg->dev_table, - get_order(pci_seg->dev_table_size)); + iommu_free_pages(pci_seg->dev_table, + get_order(pci_seg->dev_table_size)); pci_seg->dev_table = pci_seg->old_dev_tbl_cpy; } @@ -3018,8 +3012,8 @@ static bool __init check_ioapic_information(void) static void __init free_dma_resources(void) { - free_pages((unsigned long)amd_iommu_pd_alloc_bitmap, - get_order(MAX_DOMAIN_ID/8)); + iommu_free_pages(amd_iommu_pd_alloc_bitmap, + get_order(MAX_DOMAIN_ID / 8)); amd_iommu_pd_alloc_bitmap = NULL; free_unity_maps(); @@ -3091,9 +3085,8 @@ static int __init early_amd_iommu_init(void) /* Device table - directly used by all IOMMUs */ ret = -ENOMEM; - amd_iommu_pd_alloc_bitmap = (void *)__get_free_pages( - GFP_KERNEL | __GFP_ZERO, - get_order(MAX_DOMAIN_ID/8)); + amd_iommu_pd_alloc_bitmap = iommu_alloc_pages(GFP_KERNEL, + get_order(MAX_DOMAIN_ID / 8)); if (amd_iommu_pd_alloc_bitmap == NULL) goto out; diff --git a/drivers/iommu/amd/io_pgtable.c b/drivers/iommu/amd/io_pgtable.c index 6c0621f6f572..f8b7d4c39a9f 100644 --- a/drivers/iommu/amd/io_pgtable.c +++ b/drivers/iommu/amd/io_pgtable.c @@ -22,6 +22,7 @@ #include "amd_iommu_types.h" #include "amd_iommu.h" +#include "../iommu-pages.h" static void v1_tlb_flush_all(void *cookie) { @@ -156,7 +157,7 @@ static bool increase_address_space(struct protection_domain *domain, bool ret = true; u64 *pte; - pte = alloc_pgtable_page(domain->nid, gfp); + pte = iommu_alloc_page_node(domain->nid, gfp); if (!pte) return false; @@ -187,7 +188,7 @@ static bool increase_address_space(struct protection_domain *domain, out: spin_unlock_irqrestore(&domain->lock, flags); - free_page((unsigned long)pte); + iommu_free_page(pte); return ret; } @@ -250,7 +251,7 @@ static u64 *alloc_pte(struct protection_domain *domain, if (!IOMMU_PTE_PRESENT(__pte) || pte_level == PAGE_MODE_NONE) { - page = alloc_pgtable_page(domain->nid, gfp); + page = iommu_alloc_page_node(domain->nid, gfp); if (!page) return NULL; @@ -259,7 +260,7 @@ static u64 *alloc_pte(struct protection_domain *domain, /* pte could have been changed somewhere. */ if (!try_cmpxchg64(pte, &__pte, __npte)) - free_page((unsigned long)page); + iommu_free_page(page); else if (IOMMU_PTE_PRESENT(__pte)) *updated = true; @@ -430,7 +431,7 @@ static int iommu_v1_map_pages(struct io_pgtable_ops *ops, unsigned long iova, } /* Everything flushed out, free pages now */ - put_pages_list(&freelist); + iommu_free_pages_list(&freelist); return ret; } @@ -579,7 +580,7 @@ static void v1_free_pgtable(struct io_pgtable *iop) /* Make changes visible to IOMMUs */ amd_iommu_domain_update(dom); - put_pages_list(&freelist); + iommu_free_pages_list(&freelist); } static struct io_pgtable *v1_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie) diff --git a/drivers/iommu/amd/io_pgtable_v2.c b/drivers/iommu/amd/io_pgtable_v2.c index f818a7e254d4..1e08dab93686 100644 --- a/drivers/iommu/amd/io_pgtable_v2.c +++ b/drivers/iommu/amd/io_pgtable_v2.c @@ -18,6 +18,7 @@ #include "amd_iommu_types.h" #include "amd_iommu.h" +#include "../iommu-pages.h" #define IOMMU_PAGE_PRESENT BIT_ULL(0) /* Is present */ #define IOMMU_PAGE_RW BIT_ULL(1) /* Writeable */ @@ -99,11 +100,6 @@ static inline int page_size_to_level(u64 pg_size) return PAGE_MODE_1_LEVEL; } -static inline void free_pgtable_page(u64 *pt) -{ - free_page((unsigned long)pt); -} - static void free_pgtable(u64 *pt, int level) { u64 *p; @@ -125,10 +121,10 @@ static void free_pgtable(u64 *pt, int level) if (level > 2) free_pgtable(p, level - 1); else - free_pgtable_page(p); + iommu_free_page(p); } - free_pgtable_page(pt); + iommu_free_page(pt); } /* Allocate page table */ @@ -156,14 +152,14 @@ static u64 *v2_alloc_pte(int nid, u64 *pgd, unsigned long iova, } if (!IOMMU_PTE_PRESENT(__pte)) { - page = alloc_pgtable_page(nid, gfp); + page = iommu_alloc_page_node(nid, gfp); if (!page) return NULL; __npte = set_pgtable_attr(page); /* pte could have been changed somewhere. */ if (cmpxchg64(pte, __pte, __npte) != __pte) - free_pgtable_page(page); + iommu_free_page(page); else if (IOMMU_PTE_PRESENT(__pte)) *updated = true; @@ -185,7 +181,7 @@ static u64 *v2_alloc_pte(int nid, u64 *pgd, unsigned long iova, if (pg_size == IOMMU_PAGE_SIZE_1G) free_pgtable(__pte, end_level - 1); else if (pg_size == IOMMU_PAGE_SIZE_2M) - free_pgtable_page(__pte); + iommu_free_page(__pte); } return pte; @@ -380,7 +376,7 @@ static struct io_pgtable *v2_alloc_pgtable(struct io_pgtable_cfg *cfg, void *coo int ret; int ias = IOMMU_IN_ADDR_BIT_SIZE; - pgtable->pgd = alloc_pgtable_page(pdom->nid, GFP_ATOMIC); + pgtable->pgd = iommu_alloc_page_node(pdom->nid, GFP_ATOMIC); if (!pgtable->pgd) return NULL; @@ -403,7 +399,7 @@ static struct io_pgtable *v2_alloc_pgtable(struct io_pgtable_cfg *cfg, void *coo return &pgtable->iop; err_free_pgd: - free_pgtable_page(pgtable->pgd); + iommu_free_page(pgtable->pgd); return NULL; } diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index fcc987f5d4ed..9a228a95da0e 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -42,6 +42,7 @@ #include "amd_iommu.h" #include "../dma-iommu.h" #include "../irq_remapping.h" +#include "../iommu-pages.h" #define CMD_SET_TYPE(cmd, t) ((cmd)->data[1] |= ((t) << 28)) @@ -1642,7 +1643,7 @@ static void free_gcr3_tbl_level1(u64 *tbl) ptr = iommu_phys_to_virt(tbl[i] & PAGE_MASK); - free_page((unsigned long)ptr); + iommu_free_page(ptr); } } @@ -1670,7 +1671,7 @@ static void free_gcr3_table(struct protection_domain *domain) else BUG_ON(domain->glx != 0); - free_page((unsigned long)domain->gcr3_tbl); + iommu_free_page(domain->gcr3_tbl); } /* @@ -1697,7 +1698,7 @@ static int setup_gcr3_table(struct protection_domain *domain, int pasids) if (levels > amd_iommu_max_glx_val) return -EINVAL; - domain->gcr3_tbl = alloc_pgtable_page(domain->nid, GFP_ATOMIC); + domain->gcr3_tbl = iommu_alloc_page_node(domain->nid, GFP_ATOMIC); if (domain->gcr3_tbl == NULL) return -ENOMEM; @@ -2092,7 +2093,7 @@ static void protection_domain_free(struct protection_domain *domain) free_gcr3_table(domain); if (domain->iop.root) - free_page((unsigned long)domain->iop.root); + iommu_free_page(domain->iop.root); if (domain->id) domain_id_free(domain->id); @@ -2107,7 +2108,7 @@ static int protection_domain_init_v1(struct protection_domain *domain, int mode) BUG_ON(mode < PAGE_MODE_NONE || mode > PAGE_MODE_6_LEVEL); if (mode != PAGE_MODE_NONE) { - pt_root = (void *)get_zeroed_page(GFP_KERNEL); + pt_root = iommu_alloc_page(GFP_KERNEL); if (!pt_root) return -ENOMEM; } @@ -2783,7 +2784,7 @@ static u64 *__get_gcr3_pte(u64 *root, int level, u32 pasid, bool alloc) if (!alloc) return NULL; - root = (void *)get_zeroed_page(GFP_ATOMIC); + root = iommu_alloc_page(GFP_ATOMIC); if (root == NULL) return NULL; From patchwork Tue Nov 28 20:49:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13471785 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 8C41AC07E98 for ; Tue, 28 Nov 2023 20:49:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 487E36B0353; Tue, 28 Nov 2023 15:49:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 411B86B0354; Tue, 28 Nov 2023 15:49:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1EEA46B0355; Tue, 28 Nov 2023 15:49:47 -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 EF42B6B0353 for ; Tue, 28 Nov 2023 15:49:46 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D1BF31C0180 for ; Tue, 28 Nov 2023 20:49:46 +0000 (UTC) X-FDA: 81508554372.24.3F2C974 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) by imf23.hostedemail.com (Postfix) with ESMTP id 15B19140003 for ; Tue, 28 Nov 2023 20:49:44 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=DfEVXdkb; dmarc=none; spf=pass (imf23.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.172 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=1701204585; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=agdpEgslqhHdhrn0hnWdDpIJa9Hen54IbPQiTYhpn3E=; b=5tTJWlyFTLDE/UyZwCyhCtgKBBBK/p7jTE6MioehqIEdjdBrjdzYnZ+nzdiNKwhn3CsleV expAXXTUNLWq3v5yKv4gwoCThWmbJME9kBNKHMKJ4+vAZQROsQLPCWA7Ma78unX7julWz9 GWqsPEZnrCsnHhxKd9L5H5JhIGpgVQA= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=DfEVXdkb; dmarc=none; spf=pass (imf23.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.172 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701204585; a=rsa-sha256; cv=none; b=NmaHIxJEbvvu7AkJ2xQlUqxnOjalzZxMsY+bXWxUmQoFkkTvR15oR81iiT7KzkZTP3l0+A 2KbIvswZ9fSLF/+/gnonBV4QMRPr3PuW679q2DE1uz1KSHHMiyJbrfn3kLLJBgDmXW6D7O 7i/rr+9xxBwxte7xcFHGjoXoSwHT07w= Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-423c28db22eso1591451cf.1 for ; Tue, 28 Nov 2023 12:49:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701204584; x=1701809384; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=agdpEgslqhHdhrn0hnWdDpIJa9Hen54IbPQiTYhpn3E=; b=DfEVXdkb/GhnTpx5X549w2HsA+NyBrmYRSpQS74fM+OMkG/+HzQc0+kavB7OVc0lPK vhHgj1uPydfTdjCK4vKFE0cX6+41NBCXQyZwfbtwJhC+a3AaqMbGvawi5HEgAp5azKB2 4G8rnWQvbOtrem+U7+cf8RsUOV7r5EzvcgVWxkpCC8ZgBzYsg6My+2aqGyJvkvigpvwj E2rhQe8bqHsXo87D/yLyAEPaV/dkE2A8unpr4M4CSoL19Oyyhu2KIyWGq8S4sG1ltvoz Rgv8Q5cbPjGpSq9nNTa4No2oAZJoKHrnVgnt5DFZG8dQ7PWRkWfyHAiHk93bze6UTD0w Lb4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701204584; x=1701809384; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=agdpEgslqhHdhrn0hnWdDpIJa9Hen54IbPQiTYhpn3E=; b=Zz2rVhXklk06NlnZDQhouGENaFt/50/aVwmb6A1D1TMjJakzxMVzXiitKce4WVKc5z TGHC67jaVViWMshOS9j+AaYljwSbGn1ZaWnsWEoFRKlrxbDN3k9V49/QKIFGLLt4IcvL ZEdW7yxkT5IHw5Tj15X0vXjChQ3PQgBSMAr2IUPpu9duDTeNCVmHzeBEFwyVNRBXjNIF nT0Qe3jNVoO4wtaRLFbORNx/PCTaG72+b55t0O9Okc/YF2fOLWnz5uPkMZZkJ2kygDun WNtgDdq8R38H6qhpOpu3uMJw2JdYsgsjgqhY5AV7YhI9dOj3xx7Dhp2YCUt17t8qsLmE JIqA== X-Gm-Message-State: AOJu0YyKTVCARezBmgctQryilmVKX8xeyoitp+lR7YoXBcbv4si+s/Tr uklK3Jie2j/lQ+iqFwgOL3i6qA== X-Google-Smtp-Source: AGHT+IGsN1gYKfhSPZCpUVGbGKIu06D7uLG0xM+OZwtg49W/WqG56O+xCl6uRGYTfUcoNhDPZKc9YQ== X-Received: by 2002:a05:6214:2249:b0:67a:52eb:7a00 with SMTP id c9-20020a056214224900b0067a52eb7a00mr10312900qvc.7.1701204584210; Tue, 28 Nov 2023 12:49:44 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id d11-20020a0cfe8b000000b0067a56b6adfesm1056863qvs.71.2023.11.28.12.49.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 12:49:43 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alex.williamson@redhat.com, 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, jasowang@redhat.com, jernej.skrabec@gmail.com, jgg@ziepe.ca, jonathanh@nvidia.com, joro@8bytes.org, kevin.tian@intel.com, krzysztof.kozlowski@linaro.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.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, mst@redhat.com, m.szyprowski@samsung.com, netdev@vger.kernel.org, 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, virtualization@lists.linux.dev, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com Subject: [PATCH 03/16] iommu/io-pgtable-arm: use page allocation function provided by iommu-pages.h Date: Tue, 28 Nov 2023 20:49:25 +0000 Message-ID: <20231128204938.1453583-4-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231128204938.1453583-1-pasha.tatashin@soleen.com> References: <20231128204938.1453583-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 15B19140003 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ir7ayih8fiagzej9uubtacyntokzyt57 X-HE-Tag: 1701204584-182290 X-HE-Meta: U2FsdGVkX19sNOJqXfuYWelBgqr/FRdgajoyQN5uGrWKm6GsaJttW2r1tTg60v0kMIzB7XjqZcDil5kpr635ume5bgZ+MVQ6vQ1BB71RBi1ojg/SvNlCluXrbybTUVRsVczIxfo6gVb3LiM1+iT3K1HQK/WsSNc2JTIHyb7jQTfrw+B4LJxtoICXjcHtxzpWAKwTMPHTH/e0vLNY+dy0vqRldyTOIEq6QKr0nbMOYwNkQvF92rV0SdpKqmPouTZ+WsFDNVJjc9FhR58R9Y5Y6dbRw74bdK8dHGW+PmXcSBYZEVQ1RGMEOlko2BHrRrAZZY6hfKcAn/d7c/ZgbNrOW4inulMFFMgy3hegtsHbpAGp7I1VJHrYuDUXk+2XXgaVJLKmiwPSQUfCATkBUpQFk9Hvv+EFHQgx6ZozFhu5dve7Nn3PsDsRfjga49cw8yp0M8ympPjAzA5B5w12Qpq6rX+VCCJH+QHQjcTNsXzQ6inQGGseKGPXHL4E1LLd9Q3IvaFCHeKvgU7TOpV103f/EWNWDrJ4EPCopDxqHVzsXp0fQecLoi8DK8KkkIpqsxPkpiJ4DA+6cvaZzPCTBcXjcjr5KQn1lB5qQ555EwBTf3DC58Db/wDvekmv2BA323zxlF7bNqxiYt5MSeigF+vZwTs/if3rD85twfUymB4XI0QCDfynv6LFwyWuN+FYgaO2hScr8IXLRg8J6z34Ilz7KIqIof1r9iDWc165F/zrMAnq3C589GrHFeIdRUog9YwJb8u2NEZHiJSsu2yHR7wB6W1pDLb+tU7NHjL7lcfzo+52El1YHAZPngb8bfjtUbBhKM5kxNLzAb5UoEE0R7mwetXZQ8Div8EMrni/UIveCI6a21ni6DA16sp26Mk9krSJSwq/AA+xwntUewXwknR86sfUKhdYy1CDQXUvNsX8XpfAWhav0Hi9wx4OWOf/4yN0T59jQfI9HlkmPqyec5O SnNLDexp RIiaBalgYOWrPE0WAsSnLZyGZNd+XDCLNGtA9+qA6NRdt10fqS+0Nh4xTGf+d+A9Z9cBbfxFLTRHXEJauBptCZJNOYA3rVC4wilZrIOrFkk5Xp3TnTLhDJeeJScUG3Diypb/yrOhL4vpUZxztxVjDxys+t3H+ZYKt8OUfDNb/A/BIY8n/l6CjRJNCwQtWPUEp8KuiCEraXCQUSIHo77joPYcnbSCEj18K2QDxPTpNA55h3nGn7GWprT+yz1Kkmd5Wdr8e1siR2Xi0+W/Hjuir6esmqLx4wuLqcUQVnpNxNrqoaxMM4F+ga1dUApNwFSWstS/1cpFvnyAhbh2Ryzoq4z4M6de+aiWaJjVDDt4CF5Tr1FQhi5X/4/CYeiy9/gb69/veGWCnm8eM8+O/a59rnwirjnebr/5lsH8ytyhPwOk30JFiaNfegpAcCstCmb8UqE6h 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 --- drivers/iommu/io-pgtable-arm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index 72dcdd468cf3..21d315151ad6 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -21,6 +21,7 @@ #include #include "io-pgtable-arm.h" +#include "iommu-pages.h" #define ARM_LPAE_MAX_ADDR_BITS 52 #define ARM_LPAE_S2_MAX_CONCAT_PAGES 16 @@ -197,7 +198,7 @@ static void *__arm_lpae_alloc_pages(size_t size, gfp_t gfp, void *pages; VM_BUG_ON((gfp & __GFP_HIGHMEM)); - p = alloc_pages_node(dev_to_node(dev), gfp | __GFP_ZERO, order); + p = __iommu_alloc_pages_node(dev_to_node(dev), gfp, order); if (!p) return NULL; @@ -221,7 +222,7 @@ static void *__arm_lpae_alloc_pages(size_t size, gfp_t gfp, dev_err(dev, "Cannot accommodate DMA translation for IOMMU page tables\n"); dma_unmap_single(dev, dma, size, DMA_TO_DEVICE); out_free: - __free_pages(p, order); + __iommu_free_pages(p, order); return NULL; } @@ -231,7 +232,7 @@ static void __arm_lpae_free_pages(void *pages, size_t size, if (!cfg->coherent_walk) dma_unmap_single(cfg->iommu_dev, __arm_lpae_dma_addr(pages), size, DMA_TO_DEVICE); - free_pages((unsigned long)pages, get_order(size)); + iommu_free_pages(pages, get_order(size)); } static void __arm_lpae_sync_pte(arm_lpae_iopte *ptep, int num_entries, From patchwork Tue Nov 28 20:49:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13471786 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 15A7DC4167B for ; Tue, 28 Nov 2023 20:49:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 093566B0354; Tue, 28 Nov 2023 15:49:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 03F9B6B0356; Tue, 28 Nov 2023 15:49:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D87E36B0357; Tue, 28 Nov 2023 15:49:47 -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 C22086B0354 for ; Tue, 28 Nov 2023 15:49:47 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A133D1C0297 for ; Tue, 28 Nov 2023 20:49:47 +0000 (UTC) X-FDA: 81508554414.19.57CFF3F Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) by imf01.hostedemail.com (Postfix) with ESMTP id E2A2F4001C for ; Tue, 28 Nov 2023 20:49:45 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=RcuZHkEF; dmarc=none; spf=pass (imf01.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.42 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=1701204585; 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=4JJWGGhifJfmWwzsRRAotq/YxAL9K3n4NSfU3ou+3rE=; b=PUC1var3RAMbrkMAbe+NO9+AcaSnqem6qlGvIXbFyl6jWnCUPUYc09+63Hc7UW/9MAM0of bhR+q+kdh88FwhdP54s8rN+QYfpxZtaSZm1IHZZ55hel+Fdx9Z/SnYbpQ3/ucva04VPY/R ikzXfYHEN4LmJDNBOVA+aO6Fe1SkUiY= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=RcuZHkEF; dmarc=none; spf=pass (imf01.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.42 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701204585; a=rsa-sha256; cv=none; b=dsfxGW35b8IEzwMorQxAAOumpR6qGsgpbhFsMNqvho4QzslI3mA3jq7DgBrK6TOoItn5cI hzz+TaR9JvVFdS/mJoyZvGvLbdBUYpeu/3vdWtloGoLNv0pn40L1XpmEb76Rz5Q7VWK7EE W4e1RqQHqs8U+mrmElgRnYRr0a7CQ3k= Received: by mail-qv1-f42.google.com with SMTP id 6a1803df08f44-67a3e0fb11aso16258346d6.2 for ; Tue, 28 Nov 2023 12:49:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701204585; x=1701809385; 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=4JJWGGhifJfmWwzsRRAotq/YxAL9K3n4NSfU3ou+3rE=; b=RcuZHkEF1HyP8jVsAGHTFXSsNiKzMCEHCEcDKqJUCDFi7DcdBu5flneoVVUdl077Nt 2igliDDWwG3Al4xgKxq3z7QfFb0B9+08/qdH+/l6cfnWpK+BcuCtl5pTpqTIZZoR31FM FuWOl7F0h0znMVRQJ/YmtMo3uA7eqxV667L7S5hOwMETu7EKVPfHm2jknTusrl0jjN8h 2oINB5Cf+q5Eyw6cxJqf9ayR+31XraTJ/mc8lN1KG6/iy9rJSPatS2oIGhtQ73AQ53El Hap4S8oVag1Ls5Fa/5o8wWBaR1D98NVHEIMPWQb1q1NKmbavIvHPAEyZkOUwMwnfKya7 AWjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701204585; x=1701809385; 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=4JJWGGhifJfmWwzsRRAotq/YxAL9K3n4NSfU3ou+3rE=; b=MnR51/pq+/PdzkxSDeqkTfZcRJHm34sB9ciMRaWeojvNvGfF7oR+zWTCiuKK1khm4O F356HlK88oOSgfGWLO0LYUk9/+ojvO17JkULStRWs0+uzIf2PpOR1Yxyn3w4RIO5+M7n yhRsEHAtiSC2VLXp06tci0r8JLRFey3LT1EPLlE1zn3V7fn5Wkb7X/Frm4eA2PsxZR0I 2pkK87QYNOJg5k6D+icHmIJayX1Tq8GsCK2rRM4pl0s7AA54GC60t/XsyNBYKqPF8MQS s0TTGiDoHPRUhql9arQcvEZhU5F7i0tJNtDbseYVXFfB2mZlveeUfuM121dDI/n+ndY0 ihzg== X-Gm-Message-State: AOJu0YwXglCcqPd5uWIR2xd/H23GTq1NXwDDn40SzYBq2ijFNjCgdltB 46lrhixHRHW42z68ejMblt214g== X-Google-Smtp-Source: AGHT+IEDZ/ij59NC+/N0WE8v2site2Dd8U3b4CDvl6tiF76N0ZJEMNbYN0ZJKJUKEFAmf3sLjyNRCw== X-Received: by 2002:ad4:5499:0:b0:67a:5744:264c with SMTP id pv25-20020ad45499000000b0067a5744264cmr3635072qvb.55.1701204585073; Tue, 28 Nov 2023 12:49:45 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id d11-20020a0cfe8b000000b0067a56b6adfesm1056863qvs.71.2023.11.28.12.49.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 12:49:44 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alex.williamson@redhat.com, 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, jasowang@redhat.com, jernej.skrabec@gmail.com, jgg@ziepe.ca, jonathanh@nvidia.com, joro@8bytes.org, kevin.tian@intel.com, krzysztof.kozlowski@linaro.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.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, mst@redhat.com, m.szyprowski@samsung.com, netdev@vger.kernel.org, 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, virtualization@lists.linux.dev, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com Subject: [PATCH 04/16] iommu/io-pgtable-dart: use page allocation function provided by iommu-pages.h Date: Tue, 28 Nov 2023 20:49:26 +0000 Message-ID: <20231128204938.1453583-5-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231128204938.1453583-1-pasha.tatashin@soleen.com> References: <20231128204938.1453583-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: E2A2F4001C X-Stat-Signature: 5dhdpbyff1swdti17rdhpcgzsfpx5wxi X-HE-Tag: 1701204585-417476 X-HE-Meta: U2FsdGVkX18qbM3hFTsohppKNr2H9Ssf0qAXKAMOj3enoH255MGZl+prj7ndC4GnTB2dKOhSlx+ih+seFrQYscyb/y+B0Qg5dU8isoWbXzovkfkRsqZpQpU2spbTitolH6yC3peC6+GCiJyzLKtAMOQTUMuzTh++hqbKxn9rXws6mHYyN4lPeHJlTo47kVuZ57dFTr0G2peca3iG/EPi1HjNZ12UIzxrtVt4XYnBTf7pSGnQeBOWOV1TAwrBvRZVnSwV1gI4CCSwqKfisvU1f0qgLeAc5G4zsE7rTm3LlZR3BrUbfI4bKJc0IyP0oizqdlCi9SpRZEk8T+PZndjlNC4uI9k5VuIs/JFecmZJ0QgzQ5L9jSvACoxLvOKzz3aJazDemxcOJEySYPEj0+LWs2BuKfDQsIwA7D7yM0CKtWArnv34vRL9+jc1fs3D9Sz3+X1lYgbeAobwP38q0NAB6MGYVBhZ0ydbqEji9Fbp4aRlLK4p87gh1ezZS5XGejcLb/p8lePy0nveohZBXfmVhUfwTr9eYPwcU7hGywGsoLIi2w4wE6juZJciJneOtlcFuIqH7Ra+c9/+CAkMuTMjMaYyyerk1634j+qTY43/qpAeNiOSOvEn6SB3e6WDgLaqHt8tN6CbUb//G53p6LhdlRqMnVeF3VheGsHnV3+H8WQ5k6RSL+8dP4OHlQKETxNX2XoxCO+2elSzIm93TQKYPkKyM6KnMlAp8ihkxA/Ws4W4hoPYbaznUSmCwc2bw8tB8YPKxFhXiTBBe8xISbsIT65tlmfTeS4qjF+Ffms5YQ+4v7eNKzprEsirEm6FjgRUpuJhkhYE26eW4FLW5xhMS3RR1mGg/GKPtz+V1awmoWkPDfAFuVMNwt4OlfewBPuHFMyqXbDo5ruiJJxJbqwtia7tDyOt4npAM7s+zHNYGVXm78+hvd9kRKXruAX+xGYUIAUDMJZBIhXD/1dVvbt uTqg7/CB qwrasENEzLsLPpOiAgyn7IHSxSdi6QwaMQPf9ZuC7HHkxpfNeOzdTWoTMilmEx7QmERCrXr1I+1yDoUmmwynPIk75Uy1SZz5b0Lr2VBuM4H5IqO2Mn2HAq3qRkrcwlCqf53Z81RCCqjRxP4oaz4/YaGlCNLZ7B380BCEMWMXkBu8NN/bYOn5raRnmNpe6K+Y9eOuB8MysnnUChAtRQUGsC8jV2PrLxDCaEClOqobUOoYT3NafX5s87msiowzmHg05ffWeY9aHC7jVJeMctKXsAUwv7rTOTOg8LJhY3sCig7CMasnxcNSZXua6hf71zfIZhYjzHuzi/PSJ8fVUoSHm0aaSKgILXSIxBst2 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Convert iommu/io-pgtable-dart.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin Reviewed-by: Janne Grunau --- 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 Tue Nov 28 20:49:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13471787 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 8583FC07E98 for ; Tue, 28 Nov 2023 20:49:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0E0906B0356; Tue, 28 Nov 2023 15:49:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 06F626B0357; Tue, 28 Nov 2023 15:49:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD3D06B0358; Tue, 28 Nov 2023 15:49:48 -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 C83C46B0356 for ; Tue, 28 Nov 2023 15:49:48 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A54C1160354 for ; Tue, 28 Nov 2023 20:49:48 +0000 (UTC) X-FDA: 81508554456.12.A3408B2 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) by imf28.hostedemail.com (Postfix) with ESMTP id D88ACC000F for ; Tue, 28 Nov 2023 20:49:46 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=Rl1tGf8+; spf=pass (imf28.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.47 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701204586; 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=EfTMP0IEjMSODjtdYrx10bu5wkmZdOPfzS7HMIYgctc=; b=IokSi+a8z8+s3aiOLvxrLabUh4BxeGy87xom1zHLxYsDV6wAEs0L4Aok5Gx+GUy0jEVXVF MPaTXuG8JwC48OQvDUmP5iEUzR0Uwe2X1azvLT2oGsUrsv9B7kAP2klTCFeQD9YgR+penO V7J42nK3biqPh5HSfW3fudO2Ql8A5hE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701204586; a=rsa-sha256; cv=none; b=D7An4iDj1cZte7F8P8gSxi6/41ES6yxgL9EgJSdMvcamdghP4YhmSufEKUrOThoc3QUE7A IG1TtnW7AqUdStgYV+AG1vga9L0xWcU0AF1Kkhnl4KV80QzF5R+TSouGpOpX3Ug16xCzM9 Skx1/O13tU3A7ZhcjhI9Omu/9s60Eig= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=Rl1tGf8+; spf=pass (imf28.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.47 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-67a51ad638eso1805756d6.0 for ; Tue, 28 Nov 2023 12:49:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701204586; x=1701809386; 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=EfTMP0IEjMSODjtdYrx10bu5wkmZdOPfzS7HMIYgctc=; b=Rl1tGf8+HGYqKd+Q7QSeH0LDMgOB5jSe9mKF8hSa0Q0FVDHsKVTTSBx0DFK6E3NEoX WYEMeYyHd+mVfMwi/6ez8RqIbnBiJwcDvFn0/JqHqsAxf7+ecbKvlHh4TLi+fO7sVUzr e7xwOt41erYgfoMyTNLZPidpZeFxdwxxk/O2y85dNBqQ6XQWCvS6JjImCj8x/u1fEqp2 AFLeCUN4Hi4bKjtpagImXvtmO+lLh99BIGvsjVRadjeb8KpAtHoqYsskE81fQ4Y0nLnh kp65rIixua8v6gTgSRguTsm7fVr+kQaynH+G+A0FMtd1pIjLuhY33J8gghqLNY2bJC0e eZ5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701204586; x=1701809386; 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=EfTMP0IEjMSODjtdYrx10bu5wkmZdOPfzS7HMIYgctc=; b=wTkfNgTfEjZJVnLVjv1OSa2hEOUV/GeywvPt0OXBjzPI7iC+fo+m46YcxMfephlgHF x3gOJKTVUZ7m7iis+ediiGfSnI5XUmfgK1aglf15XdSbLbO/4z0uUIgfu4kJ+T1KEEio KOytpZObJYDWx9r66gYdRgrtElO3TjZoxNQvXnkPIn6FQNsn92XCX5SzrkkABWmad/Ia BaTpT6hA+gEORtF0qnZy5J32PrWxDXLFMJ30VDUjED0mGDzrqo9CbKdUzPOVZdDj1bB4 AG2NCWqVDgxcd63wOITjnwh3Z+DFMXUIXisfkFw8rNuF4pIprHZjEGx9HnmA1UQ7TOmh 8Wgg== X-Gm-Message-State: AOJu0YyJFgYBGOoTObKfYt+n9aOWA1RyK8+i3ZZVHqcSVSjvHCJq1c14 Av5lGK+OcRB5nYGWMNIzjogg/g== X-Google-Smtp-Source: AGHT+IEKeO0ndku7kDd+vg89Kzhd+WrQKp5SmuH7bGrf2GIbl4sfu3JTwF6Gf3JxLicYu9UrEBSdGQ== X-Received: by 2002:a05:6214:1c0b:b0:67a:4546:9895 with SMTP id u11-20020a0562141c0b00b0067a45469895mr14672255qvc.12.1701204585983; Tue, 28 Nov 2023 12:49:45 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id d11-20020a0cfe8b000000b0067a56b6adfesm1056863qvs.71.2023.11.28.12.49.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 12:49:45 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alex.williamson@redhat.com, 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, jasowang@redhat.com, jernej.skrabec@gmail.com, jgg@ziepe.ca, jonathanh@nvidia.com, joro@8bytes.org, kevin.tian@intel.com, krzysztof.kozlowski@linaro.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.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, mst@redhat.com, m.szyprowski@samsung.com, netdev@vger.kernel.org, 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, virtualization@lists.linux.dev, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com Subject: [PATCH 05/16] iommu/io-pgtable-arm-v7s: use page allocation function provided by iommu-pages.h Date: Tue, 28 Nov 2023 20:49:27 +0000 Message-ID: <20231128204938.1453583-6-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231128204938.1453583-1-pasha.tatashin@soleen.com> References: <20231128204938.1453583-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Stat-Signature: h1e549yx6da8oiwbgm5fq3zkdj58y8nx X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: D88ACC000F X-Rspam-User: X-HE-Tag: 1701204586-760493 X-HE-Meta: U2FsdGVkX18TYlfi6YsB7MDtlO4xcx+NqILiuTzm1UUI7Ls3SB61A1+r0B3GKKkF6t9D62bnvs9tyC3te3MSpd1l6Ik1cd5mMESZfoN6c+6uBMG6Heqo1X/g1OVdJ+scX+nsns2owqNWsY6xjp9JQ97b4WX9QgzHzuF+yGlGTzBN+AXaWc7PVHz31IX+Ttonzcm3sIJE0ulXLEh5ONc/M+ycVHwZMq+wVswFb+Vbyiy3LgkEuFs3TFanQQVrbXQ+HguTsdX+6CuQw9h0i5UreOOx5fa+NZ+z9V3h8xWD9RphzQU/lK127CksPZiqxRLX1CQ0oxtyJhWPQrkqqI3rinRHnwgHdBb+bO896OuKOp3UrzWOynJceXNh8ANSGQLPt1raOf/XdhprR+uKDCiBnTPJeWZo+ja/eWm34Y60z1XYLct1/oJlACdY6x7Y079SQRLNL+y5eMNwLy6j6q8x4hNVPX8HNQx7HIhXa703L+UTZACuF5VcT3NeBOCB/1yke8W9R2LcEVeT1HyuO7ncy0oHjIXwGa1oBeFJeMaqMiIBopSvVkKuVOL8/OHUBlHkthvODYg0Yy5aOJlu5X274iEYIqfMEQN3jEggu4+YEaSFkYzvi9IKXZxilSJmisz7LHNhRH+xjDSl+aT7NQgX+zplphVLZK8M/GL+kiU5tnQUq2bL97NYSVC9MZ5ntJk1EIyGrwr2lUWDKfMKgMXT+IJwrRjwjFCuoLwDO1Mon9f8o8EjMam6703A7Z0vSLGEgmYxXiCPT1l0EjZB4ieAaQLWyKfK83p1ExpzqnPtO1EALVmRcCPgD4Si/da1z9Ii6VuRapGCmCQ5ySvRJ+s/fzQbxFN0wdlgXhjv42qc+dsNwTSZ/t7g9XIQ8MguZLCiKPr/9FCEVQ982xKikkIUUe8/io3mcZCo5aDSYVvFkuAqULZuddhvtuB2ZEjHNUdzUZTR55Uj+4hLgGtpIkj S+XRyX/D Eek3jUawegNi2n1kecvDex1ZLZaFXUBnXgAh4dVSL0FmP0mfiLVedIup3a59dypiNb5euJM6wpQi1mnq9J0e24mTxZmDPTTDABRlOlQBqXlahLUATdDeLQuO9M33DHHfKPRoePGWhbgRZti8AkUv6cWvO8eBO13j7jY4DoSk8VW2irr6WQZLCyQZXwphHpv4vOGH68OUrp+fmSeyiZ9C3RyC42EV5tYUGK74pDMgHeFiYw//sLdeLwyPIYtVTNVmX4hGoEvIKi9C84icoGFaNYJBxEaR2CAXaaB2K+mjBXBw6DDBtUytCDGCeX9HANucESp4HN7erCeYwBZwKSZuEB8XCxeQSW56CPtyf3u7v0yvhNg6jv1UGKeOYnckXtSGwpecoN6gFTUw97i801RpFRhgQ0bHOadMZBLPz6gmfVDaJ6avX777D+wpsdlcRe6/CKNW0 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-v7s.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin --- drivers/iommu/io-pgtable-arm-v7s.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c index 75f244a3e12d..3d494ca1f671 100644 --- a/drivers/iommu/io-pgtable-arm-v7s.c +++ b/drivers/iommu/io-pgtable-arm-v7s.c @@ -34,6 +34,7 @@ #include #include +#include "iommu-pages.h" /* Struct accessors */ #define io_pgtable_to_data(x) \ @@ -255,7 +256,7 @@ static void *__arm_v7s_alloc_table(int lvl, gfp_t gfp, GFP_KERNEL : ARM_V7S_TABLE_GFP_DMA; if (lvl == 1) - table = (void *)__get_free_pages(gfp_l1 | __GFP_ZERO, get_order(size)); + table = iommu_alloc_pages(gfp_l1, get_order(size)); else if (lvl == 2) table = kmem_cache_zalloc(data->l2_tables, gfp); @@ -283,6 +284,7 @@ static void *__arm_v7s_alloc_table(int lvl, gfp_t gfp, } if (lvl == 2) kmemleak_ignore(table); + return table; out_unmap: @@ -290,7 +292,7 @@ static void *__arm_v7s_alloc_table(int lvl, gfp_t gfp, dma_unmap_single(dev, dma, size, DMA_TO_DEVICE); out_free: if (lvl == 1) - free_pages((unsigned long)table, get_order(size)); + iommu_free_pages(table, get_order(size)); else kmem_cache_free(data->l2_tables, table); return NULL; @@ -306,8 +308,9 @@ static void __arm_v7s_free_table(void *table, int lvl, if (!cfg->coherent_walk) dma_unmap_single(dev, __arm_v7s_dma_addr(table), size, DMA_TO_DEVICE); + if (lvl == 1) - free_pages((unsigned long)table, get_order(size)); + iommu_free_pages(table, get_order(size)); else kmem_cache_free(data->l2_tables, table); } From patchwork Tue Nov 28 20:49:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13471788 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 3F8E7C46CA0 for ; Tue, 28 Nov 2023 20:49:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E4B166B0357; Tue, 28 Nov 2023 15:49:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DFAB76B0358; Tue, 28 Nov 2023 15:49:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C25D16B0359; Tue, 28 Nov 2023 15:49:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id AE01C6B0357 for ; Tue, 28 Nov 2023 15:49:49 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 89B0412039F for ; Tue, 28 Nov 2023 20:49:49 +0000 (UTC) X-FDA: 81508554498.30.18A98FF Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177]) by imf16.hostedemail.com (Postfix) with ESMTP id CBA0C180020 for ; Tue, 28 Nov 2023 20:49:47 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=eNpTfjfv; dmarc=none; spf=pass (imf16.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.128.177 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701204587; a=rsa-sha256; cv=none; b=ojUbjC20UrHRNUOnDLVHpZmN/+CKytJI3RNABRipg/bHOvhkTnZpUWYT/GBYv/SNAPLxKC 9iZefyPlVwehwa7fIq5HVNMxyNE3ZKwO7e/uHNBvaBbq3nmy+DA5t+L1Xx4fSDDYiF6DAc fkBYsv4PBx7bnm6a3ZXQ5mf78sUr8ag= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=eNpTfjfv; dmarc=none; spf=pass (imf16.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.128.177 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=1701204587; 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=9pzjq4U1m3Jk3/Q2EGDhq/3TlS/Ht1C4D8j4bsFObkQ=; b=t3aXKEXeSuB0PTO07X+ZyaWnEVXj21PkyB3xHgukj3dVVXm/0oTw38z+Vw5Gq+GMfXTr9b LXyYegdTiR1FEVhelVrVW7d+pA29xydzNemcXvkMtf47eyO2XKqkVlGjunsfpYI6TtnOwJ dxfBFiA8+8j3he0oHaW9t4jwpfHZc8M= Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-5d0572434afso24577617b3.1 for ; Tue, 28 Nov 2023 12:49:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701204587; x=1701809387; 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=9pzjq4U1m3Jk3/Q2EGDhq/3TlS/Ht1C4D8j4bsFObkQ=; b=eNpTfjfvA5gE8cLv/cGszv6lhSar8KGzrWychBCxh1jLWHPQRbgn27am9KM/cQIsFo 1SlYh4+T1PGvrO+wgGNAstkw4jrgfmDLtzmYN+U2J1OewhcYd0pRq251F0mFK0RaGwPb JsJg9piSWCdKYl4HrI97NzGHAzM3OGEi58Yb7XfRf3A0TGa27lgwjDBVymVW/dm60ZPw CvEUwFgEyoBXuUzuWXQhXicwlZBMXjdhXA0c/x/35lUxkxSkdIF/7VwM2dTx8GY0AV4G 6fZ80hT4LCMQx6ZptLwn6LHWj1he592LHQHX7tEWVEX98vPsWWYRs70p9UVOeSyFBE1L WFsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701204587; x=1701809387; 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=9pzjq4U1m3Jk3/Q2EGDhq/3TlS/Ht1C4D8j4bsFObkQ=; b=CZ4aXePyCkRV8otUPNEHkH/9ydF1t896e/8dUJhEejvM0Mxla5qs0YB29H8+utoh7s 1QcBJvMziT3yfwFm6Tu+lYGzyBaC7AO1/IsikjqnVFGEsSTOGxa2ZBUA1Bwi/GyoCRu4 jd4HmMd1gR/8/t3kYeHUSPzAs+uEJZqoGZhpCgODzaCrWGdwOLnIOIPK+tCrxfW8HvKK rFVJcO17F16jZHft/pCVgVsJDsOFJx7YdrQNMOMl2sKkZTVp7wCD2cd99JMt1yt2xKEw IyV5sI4wQEWJ4qj/v8bz3P7gn45Xiej10/n+77cCsM33dMCoUJ5jtR1jdXT5ilR0K4/H Igbw== X-Gm-Message-State: AOJu0Yw3dL1mLhrGhaGap+Q/1sJljlfmxtIHAmv9xfb2fE1gv/jeYJQB 6vzVjzGOFCaIT/nsIggthH3mBQ== X-Google-Smtp-Source: AGHT+IE/Byn/8N8Vta6BS83r49MMC2Wgiev3AoCZv/F2NdDhJZ9+kkS7XfcNeLYX07tpu8Z2obgTjA== X-Received: by 2002:a81:87c2:0:b0:5c0:fc45:a249 with SMTP id x185-20020a8187c2000000b005c0fc45a249mr12000775ywf.40.1701204586847; Tue, 28 Nov 2023 12:49:46 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id d11-20020a0cfe8b000000b0067a56b6adfesm1056863qvs.71.2023.11.28.12.49.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 12:49:46 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alex.williamson@redhat.com, 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, jasowang@redhat.com, jernej.skrabec@gmail.com, jgg@ziepe.ca, jonathanh@nvidia.com, joro@8bytes.org, kevin.tian@intel.com, krzysztof.kozlowski@linaro.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.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, mst@redhat.com, m.szyprowski@samsung.com, netdev@vger.kernel.org, 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, virtualization@lists.linux.dev, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com Subject: [PATCH 06/16] iommu/dma: use page allocation function provided by iommu-pages.h Date: Tue, 28 Nov 2023 20:49:28 +0000 Message-ID: <20231128204938.1453583-7-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231128204938.1453583-1-pasha.tatashin@soleen.com> References: <20231128204938.1453583-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: CBA0C180020 X-Stat-Signature: yn9bdjwb1163db6xq9fw39y1wzqny3kd X-HE-Tag: 1701204587-468907 X-HE-Meta: U2FsdGVkX1/qgOpZtpIpjVlFUdun0hcNy+xdzAsd4HTMGtcr90HM/z5L0v08NafSTWs8qyZRX1uUH9N70jygy18zz2pCD2toeNo0O2uWQU1uiseAgNL1jmXl12bwU0LQto3vgxeoyasG+BR8yXx24CMENCgorjbFzCSXXRPAqKFFLIqkQsmc5MRQgMKxj2u0moGsw8wnO/Hil7zHPUDzN8xjMQ7tUs7549UB4VsQt9H9J0/H0KGUUOKcPya5sEzjgD/vI54TOpGeaboRy7q5T3T5xJ0O2jYSmPjM5WKpJZuvj3uc7DINQDLkiqrHVHndtetOi3sOVzYrK821oQHKvEiA945oo3mGN3JLLwNndg6mWShqX7KV+3HgVfKcmmVEi7hp8BHkIeDT0KGzbL+Zyl1m8FYxALzPbNXTZoDpIYNU82qCgdGFt93aG1ejM4kQEvUklsQ7wyhXEMNzxPPS9pcoiDJTQ4F1SoObQPJPlUpVtGvIs66Iio4dELIsFxTA9Wvj9Trztzrep5Ypcwd3DA9iBEnUvpvqkz8Z8h7FYpdt5wLHJ8NrdWm7wfuEpGwfrjywAdygQnbf1LLm8uHm5SAalCgDWntA/DVjsKmRtX1RTl3dnN7AtHjdnM1Cg52IYaGiB6pX4P5j8CrkmAM5UTj+hZQ3lKErxaqfPTrLlMH5yhFAsgdjcu6TvXbOQW1HJpHgK2rhVBsQg/r5oYtxMTOjLCZlcsbHAc5/don96wZeVZWJmKrb1R+gd9xhXc+L78ns2TDBIpGqD5Afqa887cik7eAd/Lhcotyh8OiMNHIdUaam/JXzIkUfn7fpZNCg9M2hZXZBHyBBMYOgfIldUu2tHUR52yVFmQ+GUIxSJNEKQbzxAn2Ul6acuNQnBa0ZYU+mnhldh44U4mCY37wIsu+HUQwpLkhQc0i0zvyg0Na0L03voi1usN+3/empsvSk8apfAMUtpxsVtL3Nphu zUEANyby CbYggpYpxuxRqruvDyT4z0JvpHkcPY0CLofuYCEjijgdLdIdOodhcHmct9MQKpMp+X24GYGQLnY3OGCGP0QNjVzd1baWx6QPigot31jIMAabShXqOA0q6x2DxNe9wljmGovbQMevMh0ioxyjICp8qFW7Dtq9NX1CS5+xXvUPpkbfyyxgP94xZI17XWCQxQueG3trflC+yaVVmYmE9rTIy675Z8m641OZvygwKWZvjwA35rEH2csuETyeKWRD1/DnIP1T3xuR5D5xAa5fOTZvAfA+iaeaEv7iwPZLQUezxr58Ix+tSWcxhyyxgBDjSff6QuYHgC0o06HlF1KG2FhAIYvdT1RE7MVbskev3nmeaYBcLmkcb8+rvOx35NrmwR8MqAIKCZw09kKZDuO+Z7hiQPOhjmKPN5Nh6zs7PPLcFTZPJ9ypLOFkgX9rt77wsbxEkwLmr 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/dma-iommu.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin --- drivers/iommu/dma-iommu.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 85163a83df2f..822adad464c2 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -31,6 +31,7 @@ #include #include "dma-iommu.h" +#include "iommu-pages.h" struct iommu_dma_msi_page { struct list_head list; @@ -874,7 +875,7 @@ static dma_addr_t __iommu_dma_map(struct device *dev, phys_addr_t phys, static void __iommu_dma_free_pages(struct page **pages, int count) { while (count--) - __free_page(pages[count]); + __iommu_free_page(pages[count]); kvfree(pages); } @@ -912,7 +913,8 @@ static struct page **__iommu_dma_alloc_pages(struct device *dev, order_size = 1U << order; if (order_mask > order_size) alloc_flags |= __GFP_NORETRY; - page = alloc_pages_node(nid, alloc_flags, order); + page = __iommu_alloc_pages_node(nid, alloc_flags, + order); if (!page) continue; if (order) @@ -1572,7 +1574,7 @@ static void *iommu_dma_alloc_pages(struct device *dev, size_t size, page = dma_alloc_contiguous(dev, alloc_size, gfp); if (!page) - page = alloc_pages_node(node, gfp, get_order(alloc_size)); + page = __iommu_alloc_pages_node(node, gfp, get_order(alloc_size)); if (!page) return NULL; From patchwork Tue Nov 28 20:49:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13471789 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 5AA28C07E97 for ; Tue, 28 Nov 2023 20:50:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 042896B0359; Tue, 28 Nov 2023 15:49:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F35E46B035A; Tue, 28 Nov 2023 15:49:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D5FF26B035B; Tue, 28 Nov 2023 15:49:50 -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 BBA666B0359 for ; Tue, 28 Nov 2023 15:49:50 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8B34416039A for ; Tue, 28 Nov 2023 20:49:50 +0000 (UTC) X-FDA: 81508554540.22.E79AEBC Received: from mail-yb1-f179.google.com (mail-yb1-f179.google.com [209.85.219.179]) by imf10.hostedemail.com (Postfix) with ESMTP id BB71FC0023 for ; Tue, 28 Nov 2023 20:49:48 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=ooVgi3pI; spf=pass (imf10.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.179 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701204588; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=jRGmXGqyJzQ9dzCxzy8J7vcwlH74KXpuX5+P/ckDUHQ=; b=FXjAHQm+eptRmKwBH+pMHiJSZiXRZVE/FkXLzUsLa74QnITeyYQcXyGovxZk7pZoFdD2JG s+ToU8PZyGR9JC1Oy+M+HWfUBgzb9jJYzivw0XJMWYoTo0CDoizaXQT9eRDjpmO1Q76i7+ Ht2g4GPhFuuAT5F58jgipquBZ9f6RZ8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701204588; a=rsa-sha256; cv=none; b=EzRLeptSAi83+PEMQ1tVwidoBiGppTlJ26xZhE6GNecUYhP6FWbclGeT6bFpQtSd8P730I ZKiloW6z+B3kzm8v9dbINHYbnWjcD9joEskK5vEixlsItF2nf3p7mvbN8VyLwmLbI8ZqGP OnzpA3GOqhjPw/sV231PJHbiS5eLtWU= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=ooVgi3pI; spf=pass (imf10.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.179 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none Received: by mail-yb1-f179.google.com with SMTP id 3f1490d57ef6-d9caf5cc948so5416666276.0 for ; Tue, 28 Nov 2023 12:49:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701204588; x=1701809388; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=jRGmXGqyJzQ9dzCxzy8J7vcwlH74KXpuX5+P/ckDUHQ=; b=ooVgi3pItrRBjZVQrdZabMynphA0FUJuXFdtBru7Ch/sBNWwkniVqRhq6jLPSQk+Sa 2edG+x7pvEQqLOXn9zVEyRiBUNc8PR9BDw8S8Vnb5hMxbq5oki/aBu4x7VvLqmKIgP3z ZpGnuvKK02NdhmMfAW5Bkm8ROQAYyWSqN0LoAcbUVGksGtIDtL2U1l1Nzh66NxWPhGpt mjAYTjVJVjXaR1hPaUmCobC0P0+OIvprQ9udCFDcIuQseLA/gngixcYwdqG11jwBOpDG okjhGSET9pdzMJQXo1hmbYc/wdjXXEKgLhtKVM3DCA/IsqqZw2qesvL3CfDVkyS6e8G5 YyAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701204588; x=1701809388; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jRGmXGqyJzQ9dzCxzy8J7vcwlH74KXpuX5+P/ckDUHQ=; b=stSz1gekOAREOAcgGJ4igGIFCz7Z65f/X60F7kc9UP0L/Q56nM+tl0KJ5CgCe9V3lC MqAzrj58/o+ZH8TMYVrIYH/2wjDesGzS35X/BLQc36dNfCa683g14iW3umlZ10e1iNcT m4z7X8ThnccIH66//EOyGwuIPc8uSLexeEEvgFcESDQmsKqWvzLpXofs+ia6ocavVEMe QRGGcDfnyye1SVCOn+YPdJiqtgn1BM71kTOsWogaIDC37vXHemJOcswPzcxVFZklX7/z UUOXWnKVCTYVbKENc4hukEC8WFkE3ZJBP1+nUzLk1oRdGnDU1IsL6SutYjnjjjlP+U+W P7KA== X-Gm-Message-State: AOJu0Yx8cC2uw2JY3bObAGwJ6KrHdZd1TiajYbxhLFN1FgsdPaIs0JU+ a4CPShLbyqygssygLT/NNhi50w== X-Google-Smtp-Source: AGHT+IE78UUsr3+phF/56bFMU/5eN5UKiQDczVpHvT25XLH3DszV1HuF5Eb6PvW6XiPusog1uQd9qQ== X-Received: by 2002:a05:6902:20f:b0:da0:c615:e4a6 with SMTP id j15-20020a056902020f00b00da0c615e4a6mr16658576ybs.24.1701204587831; Tue, 28 Nov 2023 12:49:47 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id d11-20020a0cfe8b000000b0067a56b6adfesm1056863qvs.71.2023.11.28.12.49.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 12:49:47 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alex.williamson@redhat.com, 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, jasowang@redhat.com, jernej.skrabec@gmail.com, jgg@ziepe.ca, jonathanh@nvidia.com, joro@8bytes.org, kevin.tian@intel.com, krzysztof.kozlowski@linaro.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.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, mst@redhat.com, m.szyprowski@samsung.com, netdev@vger.kernel.org, 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, virtualization@lists.linux.dev, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com Subject: [PATCH 07/16] iommu/exynos: use page allocation function provided by iommu-pages.h Date: Tue, 28 Nov 2023 20:49:29 +0000 Message-ID: <20231128204938.1453583-8-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231128204938.1453583-1-pasha.tatashin@soleen.com> References: <20231128204938.1453583-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Stat-Signature: pn5xrucyi48o5tdcqnqtraze4us5ogdb X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: BB71FC0023 X-Rspam-User: X-HE-Tag: 1701204588-848166 X-HE-Meta: U2FsdGVkX19oBh+5J77ZoKrvwCxTCp6LlZyvHTF6WKVFscbIy64jIsFXKpvvViMfgvGP89s1EN3iM/WQED1xTcmGx8aWtTmaotiUBRdNEK1Rwd8usOlNkcRrQHVLAjS2akcJZgAe+kuxzEO14uOZ3Q5Dah4iV7t5F/+nDiEox+h6FSqX7p7PvV5panqCLb7xc1tgvXltnsJXanNvhRL2sJvufVBmTI2zKg56noBjFgOfT6lrtPx26vv+LZtlPhRTzJcZ3xxK8fRNLYF+/D7bLe0atg8rdKhJ5lFPFVbc6cUsmoz793DRsvZxMGV4lU//OfhfrX+9lmkAzGGTA4UJ6pZNbtyisX4eo18csM7OF5EcD0gum4VWYFVXKO4T9I+TqOqkXlLqrYsNDXIc1WkiaDSQ1ex96Nqc00/c8likwfrGksqBQFzBm/DkUEAaVpFDHYQUyQBSY1A1vXn1efta3RSgoLmxcDmQQiUl4im5xhCL1oZhBHt0HqzOo2ZpTdGjjyViJAOa6NemHj3G/m0Tiyc2X3qHMJwqDp7P2OyISEvJ6liQ8KnKrHEX+BsVcfVq5dpndRKV9OsrNCV7Sp3rgbOllPNm3AEJGFX3GT/Qt4beXrViLdzqwjGJjM8I5rUb4VgpJDwas9FSv/dCpz4f0dmUFfPv8Or2tyofQS3tgh/UI9cUf9Q4tZZLHJdxSsm1j5V/0+ndOnOEEbyJpN+ZZuAUZXxFJW47euimLJLgApoLVj+apI3eU9bBigxrGb2lccq7p5gmKfpIkos8aQiGMlUr0dFlh+HokvYYUrgAF06oK6KTW6c/x1Zx4YO90DRUAyUofLOh2D1QrTjHqRPZxZnJRBzi6LOpIoKpDO2OB+Lqzde8Wzlk4JMUX6aJcBkPSzUWMss6kjHsG/eE7PD0nhzRM9AZSIZ5Jw4YAGvoaiEwSiSqt7BOt9aaXL9XGfpu1CYVJZlNmeDq8l/YH3R NHYEQq44 xyoDSZ48HPUqlKAomgeJ+56SawTD/DbQePZJTMMvKDrl8utprnBn3k69t2GDq2mY8lk8Z0KC/6sSo1zFgvaPK4PJno1uxGdebAton1aRd/21N4HpN1UW17k2IjgJwIcMDT2T5ud1qP1fYLhHGwk37F9SNp17fIUi41e10Hl4+NdZrzVMwMerMNBDPFiWAQMEonPlMBRN7ZgUIdW9n9C27U3Upd/7l/xVyFHlfde6N9GowVDszhPyVdsYnW+6qyoRUAYDhunAd/DTTf8pWpxz7gqyKNGsZCGpTRp+Bj20c1ojgQ4971t/2VhEewv/caGd2ue6KLXbJFhvGP2qaW6YmNkYoevtnqiIyErqJiF7DlORCzGfIB9EMYgpWxKCXJkiStZFwyN0SBRR4c8ZMGFDitxkg4l8GH+sbT7ZR6+N0LBO4BBWVEugwh+Bs3ns/fV/YWBac 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 --- 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 Tue Nov 28 20:49:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13471790 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 422BEC4167B for ; Tue, 28 Nov 2023 20:50:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 17C5E6B035A; Tue, 28 Nov 2023 15:49:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B71E6B035B; Tue, 28 Nov 2023 15:49:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E718D6B035C; Tue, 28 Nov 2023 15:49:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D340E6B035A for ; Tue, 28 Nov 2023 15:49:51 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A9FF212038B for ; Tue, 28 Nov 2023 20:49:51 +0000 (UTC) X-FDA: 81508554582.13.A75A093 Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) by imf11.hostedemail.com (Postfix) with ESMTP id C8F764000B for ; Tue, 28 Nov 2023 20:49:49 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=FkPVc7WT; spf=pass (imf11.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.128.170 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701204589; 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=S6nAo2mT7pHcrL/oNBUQ6H06jfJ0V1n29MMcCYzl3v8=; b=cX+I9G9J2v1Gh7cLmoEkuWWZ/48mJVuS2Z7kyu72650EdQFthHvZqfS1H9J44e0qvOEQgH 3TwEJ8kZNhwDq3J9xd6vONRa0byKBwizLhO0lJwsLyw20gb6aRKQoh1KKWANmHZ0DWPZUS dRlLYqRvFqjHUEr3EhF6oh5zKgBOgaQ= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=FkPVc7WT; spf=pass (imf11.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.128.170 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701204589; a=rsa-sha256; cv=none; b=HY8DCRZXyVTemE372iz2gx8Clx6FB/T48vwBTV9nSZeerQgC96Plvnm+v8wlVwzZe2bINo LjaCIPDkylvSswaDQCSXN4PVgIwDq0GSFOYo/trnIYkuXobBEV0qpA5zA7AnTlgtAB5l+t rlujZoviHOkiq0HWK/YZyjRZFcu4kIg= Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-5c8c26cf056so61615767b3.1 for ; Tue, 28 Nov 2023 12:49:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701204589; x=1701809389; 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=S6nAo2mT7pHcrL/oNBUQ6H06jfJ0V1n29MMcCYzl3v8=; b=FkPVc7WTLWhroA3uYxqa2qLcsKSmi4SnfmCpILZXxpSGOGt+yyH9Us1nK1gxP7g1tk XpJX4B0tSp7NkSaV1X03pL2MZuZL223DlziiyKTegMXyjbyB2bZU6mnqQhykPJE0fkYA VY+T94b1KTO0Y3/dXEGqEsKyLLwhNLghQ/TzFzGfO+OniLb3OzS7eJyPiY/6y15fOKCE bQPYq3QSh7RmCRGFsmEB9fq4nQp2qJGC0zlFC5+wre+mzz6n1yz3/+lDga7nwKm5SXGP Kfi8MOtnU/8nQCSUlukosTyWZVK4Oc2saQ9v9QFzm4rGZTcknlDn2B8tkcmpSO/UpN0U kztQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701204589; x=1701809389; 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=S6nAo2mT7pHcrL/oNBUQ6H06jfJ0V1n29MMcCYzl3v8=; b=DwOGY6YAOlueL8ASw+yOqlfYVUZKd5KrDeRDr/6s798GOvXlXWhTvZ1iPVt3mH0LRb SGggiAKT0jqCL74nKcfQn6ctWhX88YTli+4K36hSqScscqjwZ0jJZJ1PMJOEHy+zGHtw hqHUQRsVj/YpAOpDIGUy3gOp2JOUcwFhhQIzOp6Db9XurtmHrjdKj0AA5HYZvYlg1NAO uXxwK1LrI6HvqUxxeZx/XZf/gwJebKFjUx8QWAtARuHvvaB/8oh3lrMPwrZbPoLhPP1B O5RkSFmSJY8JZVLtWVxe/HC4a7bCjBw8d9+iNo2oGlr22wZ3+tWNhV3WmdMRxFpHyhe+ af9Q== X-Gm-Message-State: AOJu0YzrihjiJJ4YNFUVRgBvM/4dkdkAzb4MQoPPpT74CtGIIhJ8JqAT qcns4R+Oo3/J9bA0aeA1bK57YQ== X-Google-Smtp-Source: AGHT+IHzqIoJvEd/INF3AF90sz+4QhWdk8I4ronh0w1gK1vKHyIxxYwztLst06FhLLj54D6SeAj/qg== X-Received: by 2002:a25:68c7:0:b0:da0:c6ae:ad0e with SMTP id d190-20020a2568c7000000b00da0c6aead0emr15080570ybc.21.1701204588830; Tue, 28 Nov 2023 12:49:48 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id d11-20020a0cfe8b000000b0067a56b6adfesm1056863qvs.71.2023.11.28.12.49.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 12:49:48 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alex.williamson@redhat.com, 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, jasowang@redhat.com, jernej.skrabec@gmail.com, jgg@ziepe.ca, jonathanh@nvidia.com, joro@8bytes.org, kevin.tian@intel.com, krzysztof.kozlowski@linaro.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.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, mst@redhat.com, m.szyprowski@samsung.com, netdev@vger.kernel.org, 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, virtualization@lists.linux.dev, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com Subject: [PATCH 08/16] iommu/fsl: use page allocation function provided by iommu-pages.h Date: Tue, 28 Nov 2023 20:49:30 +0000 Message-ID: <20231128204938.1453583-9-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231128204938.1453583-1-pasha.tatashin@soleen.com> References: <20231128204938.1453583-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: C8F764000B X-Rspam-User: X-Stat-Signature: r7dpjrj735agag87cyjtwaybptpxuyx3 X-Rspamd-Server: rspam01 X-HE-Tag: 1701204589-104944 X-HE-Meta: U2FsdGVkX18xRg0OfQh1oWk2MKn3FQwN7iJNk3OR37GcvBLc4iQvMY7actAqX9ugUGJM0Lspgt6Bmv8v4nFR1WZY9T/6x35uHWgf/y6mqLGIv2aMIRylaM7DsMATNmlRdDM+HS/mgY7o/8IS8yJzqMMKYgS0rek3rS5k65yOX39iHgQtmImdSfAu/C0kMedXhbWtsY3T+LYa87dsyvFOgGq3FW2wTMsaR1RKTOEFG5aEjcsfmVvGrxi6WbftnmKtCRugqF124aFeMiH6oiIEpPK0AyPp+baj2YJTqezJ2RmwTUUAUXLtUoaKhn7mSKGlkQsmwMOOm9ZdVd/ZnX/BAKZC7K6FqkuWcB2FCEMsft1h3LYZ97i5ZjQqZQn2OvK8glI4gbZhmFec+FIWtWhWzRUJc9TesUIS7FP9DESDMORh8uYHYFkIl5koYuN0fR8zICeaWlnKM7iGcnRd+nG48wz8MM3HDhBMl2IijqBNVTcudWmNgzqZAXuADrL+QwTxZAq2qekMCTtkmAuE82weLJ8FnVKt3sDrpmpCk5Wxxt+iLtUlUq8+Hq5kOFAEsHOU5uEn2uovfsxVlnUmc0FTimNXVqckbt8rTrhMWH6+nLw0L59QroGsaO8AjRUs8r9/txNX4tfIyOW7XqzmqKkmCwounXwS08uM86NK++8N+Somjtx0pK8RzZ4OoamPJ3zkd7zWfS7V1WBm86vSpdlNKJ2Djv5eTU2QSZkUMaD5JybiddxFXLXrpCgGfCXTBbDCF8s6EgZKj2/MovpAkk0Tsv6/tja5fPIKeBRvfEei7EIL9DxQHAMnORHWCS1/RMuD55xVNoWS1wTKeinRkCeNvWuFDMo1Rl+qFTArreemRr/c7G7lYNwAG/omU4aWn5ebMFWJoG35QGar2xES/6dPjZ72lbbIrvciZtNfeFQQt+QrWFDhQr/qW3aemwCt64DruNwWvODHmsJYrmzU1im dS9Kn+jb mZhaRO9JDeOGMKsWIgkO+tFd+lCRnQgFVFOC05jTb33annd1DMs7OwpsHYNy95mp5AZ5VTfhjqBXbZP0ZRhON8D+h+jUpVE+3YZ0ekLOK9d/F7Kj6/tnUCxgE7buVQ1aFKsn2C1XkDy5LI7WUicVVU3aTTd+sGUfwDv9iHzBd2MndtC2oaW2S1QzR+66O2ftY/HSFBpmNPyiyZTNd1Z+4gaSfWyNJqah7ApD4XAZi0Xq5vg2GypIwIOpxtZZx8jHm/JqjN2KhJAOpdfkXYrCxsSsRllVZ8qADGbvDrJzcykW+J7lNlAxnrIlhoe72RRbkbGuPVjyq7FOYIAKCGD7+G9hHVg3UaVPSynj2+lWxmDNTJQIwNPQ75JBTH+/OH6wmLG/s8D+mbExBOE9MOKuIDodfYIj/6C8HIYNuKO4lBjhsiL8Q9mW1imn7sVj5Wm1LU9gR 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/fsl_pamu.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin --- drivers/iommu/fsl_pamu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/fsl_pamu.c b/drivers/iommu/fsl_pamu.c index f37d3b044131..7bfb49940f0c 100644 --- a/drivers/iommu/fsl_pamu.c +++ b/drivers/iommu/fsl_pamu.c @@ -16,6 +16,7 @@ #include #include +#include "iommu-pages.h" /* define indexes for each operation mapping scenario */ #define OMI_QMAN 0x00 @@ -828,7 +829,7 @@ static int fsl_pamu_probe(struct platform_device *pdev) (PAGE_SIZE << get_order(OMT_SIZE)); order = get_order(mem_size); - p = alloc_pages(GFP_KERNEL | __GFP_ZERO, order); + p = __iommu_alloc_pages(GFP_KERNEL, order); if (!p) { dev_err(dev, "unable to allocate PAACT/SPAACT/OMT block\n"); ret = -ENOMEM; @@ -916,7 +917,7 @@ static int fsl_pamu_probe(struct platform_device *pdev) iounmap(guts_regs); if (ppaact) - free_pages((unsigned long)ppaact, order); + iommu_free_pages(ppaact, order); ppaact = NULL; From patchwork Tue Nov 28 20:49:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13471791 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 0B0D4C07E97 for ; Tue, 28 Nov 2023 20:50:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DDD396B035C; Tue, 28 Nov 2023 15:49:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D19766B035D; Tue, 28 Nov 2023 15:49:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AECD96B035E; Tue, 28 Nov 2023 15:49:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9A3A26B035C for ; Tue, 28 Nov 2023 15:49:52 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7833780358 for ; Tue, 28 Nov 2023 20:49:52 +0000 (UTC) X-FDA: 81508554624.05.AFF38F3 Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) by imf22.hostedemail.com (Postfix) with ESMTP id 7CEF0C0006 for ; Tue, 28 Nov 2023 20:49:50 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=AkhZFfNz; dmarc=none; spf=pass (imf22.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.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=1701204590; 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=GuhRNW8EraGxCVOazJoq98oeC/940DRf0iOPJkOnyXY=; b=WVbBo+Nle36Mk1sdwHzGXEczaaaBaf/q+dZJ8e2oW1YUpuCFQN+O3qQIUeIV2YnFo2+NEH cT88SbDZFVRT2RH+xOUybhkSe2X7Vu3tIT4dnyleVTnr3HdLo4ayrgQqPK47CWvwmFaWEu stMNXuIIyl9yVT0QaIgye/X4xX0ca9w= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=AkhZFfNz; dmarc=none; spf=pass (imf22.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.176 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701204590; a=rsa-sha256; cv=none; b=MCPeM4TS7bUnmj7t6ZHEu1q6pkLN/OZdSRp4qkajfju1/gojT4BXxid23Kq7GDeJ0uCgXh ne9iF+Yo8P8kM+2hUVH5HmnQXlwoukrJVUqMShwrtZ9FxOJqwMutAFqhWzj4greKPn9xz4 ZwA0+IVjcB20sSAlDYmv8o6vk5TJpo8= Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-77d66c7af31so15650485a.1 for ; Tue, 28 Nov 2023 12:49:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701204589; x=1701809389; 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=GuhRNW8EraGxCVOazJoq98oeC/940DRf0iOPJkOnyXY=; b=AkhZFfNzqPr5vrmyKNt4ivZsAUwO/X07CbXdk8ri02qLROC+AHc8G7/7MXONtSGOit KNg4m1xGzbX6Uv7QfZJtQVeqihBgawiX3t5nlcAkLoO2OmUfiH5hn9ADHqjuI5d3uJNJ Kciq5ZudpSFb/k+REe2pNSp1RsQpcIEk/xKNgsgKgLlM9AaGzp0LLdnlZu9ObCm3tn14 mMspnYAOqh3c9+UH6QLwQ2wuFJs1rljLYH2ZYLxv/JyZ3ZiAg9n9tXeCkLDpSw8AiO7Q BCWTtO+XoHQmY447jDPruoVfOZu/FpPn7sl82IZWijIXrY9aGW30JK5uPf1iXYc31yTu qtlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701204589; x=1701809389; 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=GuhRNW8EraGxCVOazJoq98oeC/940DRf0iOPJkOnyXY=; b=sPf5DUGlfKwGA09lf5mhZO5dUW4jeNMHpzsxlt+VMdA7fP6wCTXpfcaRcTBj8P/63M 3zYRK1xakMKJEuUAL4qBImVXfFhpXOjPzm/GmcmPTDQJ5mm8pXZsMjrv0cHZspTbOQqJ LfltrxH8FCciJjNVwvzRp3gv8a+QwereZidYHyocbF3u3z1FuJrZ0X2WjjM1dsh1UmWa aWmnhKEnNbISpb7vTDvS6Tb6uin5qZgIgwkx2ZKzWYbolv4fnNmM2eblGGYq3Ltfmnts uMgnoes2bXsJhRFqakZ44y1/Ik7PEgCTR/OBoRDQPe/rCxeexYsty5z0lEvbo6sipLAo qvZA== X-Gm-Message-State: AOJu0YyB2xHoFCD6Mm/2npjLuICWDSN29rVThHgYS7PjAWyzkMwSszXI Bn9lALtljD+SmV3Bl1YMYv3JPQ== X-Google-Smtp-Source: AGHT+IGPu3upFAdCP6yNYmrLD/qlosIlP36YcCIt0RdR7fCBV7LNnnJ4icXgqHOsHyLuFzh/n11wOA== X-Received: by 2002:a05:6214:1c0b:b0:67a:4546:9895 with SMTP id u11-20020a0562141c0b00b0067a45469895mr14672496qvc.12.1701204589666; Tue, 28 Nov 2023 12:49:49 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id d11-20020a0cfe8b000000b0067a56b6adfesm1056863qvs.71.2023.11.28.12.49.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 12:49:49 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alex.williamson@redhat.com, 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, jasowang@redhat.com, jernej.skrabec@gmail.com, jgg@ziepe.ca, jonathanh@nvidia.com, joro@8bytes.org, kevin.tian@intel.com, krzysztof.kozlowski@linaro.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.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, mst@redhat.com, m.szyprowski@samsung.com, netdev@vger.kernel.org, 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, virtualization@lists.linux.dev, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com Subject: [PATCH 09/16] iommu/iommufd: use page allocation function provided by iommu-pages.h Date: Tue, 28 Nov 2023 20:49:31 +0000 Message-ID: <20231128204938.1453583-10-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231128204938.1453583-1-pasha.tatashin@soleen.com> References: <20231128204938.1453583-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7CEF0C0006 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: swrsm3curxqocohmwfs66goi84cbtesz X-HE-Tag: 1701204590-778696 X-HE-Meta: U2FsdGVkX19+YIWz7sk/SUFpmRSjiJ/uJV8xKGaJw04n02uuPKN+rnWCAbOkIYtpTp3pFhec/i7gitpxje78s2BlhgQwpNL07ok87NtICcEOhMjKNbRqo1H6eSNBD7Z+7w5uVTd2q5lUzZEM/fwl25+aNcgXZBAkH9hJpCy694tSK2kza/z9szuA6bnP9fbqbgModC9XM2/Dd0BRTcxEK2W6C0WiDk/f1SK7ycFgAl3TIgdpa11mZl75LHper5KYD0thn5e9+/qZq4T5N9GqZEfQT6Y3pPwX8F61vXW5IQyl9t65TJV35OovrprnNAHWimJUViWTEVVzH/Kiq1/UXKRCmHtV6SyErYHIfSGvnU7bt0lrLXvpug39CbYr0BFY59+Xr/f13gsT5ZlVzYo3JQdSIkC+wGENAL3u1V1Wg236F62/M859w8ZLknlit2UNDaMrWB1LAheSPJuAB8QJyMivrMyW7Jjnz0Gm5lK9D/aNR08e/6TvSj9jM39TcyQgFpgP2rh6fskDvgtoFS7j8ej/gMZFH7Q7FKmecGi4b14A5zvkWfITFK4PgkvngvaTUcPzvM2sdlDGhdcxeufCY5JtwMhDdIsuWcEenKdHOy9mkb0UJ6rNbTI+PNZQWxeCQvdR5Ih4ZHCG4HAEieSRS3bWxVXYM9Y4tBbF27r5uc/RuGoEp78T2lK/1ss53+DeGmXkHuKiBQB9KnqEiNPNu1+IZYkBmMBpEdUss18OczPlh2iLvfN6b6ojv1NmRIImMPJfc6Zi1DbFGeWBawhda2sjcA704Not1IsoK5QpOVh9osJIKDuRaYPyYPr/1n7qgtt5D/5eAA5trVkKplM9QX+mdxojmERh7SHC5FB519KutfhslrrQdAiBpsj0kvo4HT9BpcI7Ggf3XSxgzlubqltcadD5pFB9Ulb2xaiSj0E5HHMvoJ2scIQEB1aZCXkvKt3eaACKCstZ9ek8E0r JSz7kFhV xROCQWvSGCKgRysH9KhYfKu+EzQzGvN6sXapa/PM34kwrCKF+kLcFqkx87E50YkO300EMfBQapT/u6pptSjRiIYuTIRd2ggio7tNpFL8z/6dw2PlF16y9/EFiZk98W68Q/5cSf3SKeJ1a9pOgOvottmB7lwb4fwcG+7uIi/5liB0kiw1RZjo0OnsB+9DarousLstHSjGj10yIFmzJtXw2Uyhc4ff/3t2/cYxG+JtMQn78ko5Ad4IhVmVIBrIrcOXPkWUcDjrzuzjmI8mw4LLmO+8NOmhjNfLbxxI3jeT24etpQJtXGVURnR2U4BY5swWY+CLtVEkqahsC02x1RHdw0+Z5c+UwTBhsScssrVwfYE3qGFbZFeV4k7xRLUgENH+esH/BjnGRWKdKlwIZ2XjKeRvbvipFW83lp1VYwxddtUJz+XQCHKNyZ2g7jI+o0mpqn4fF 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/iommufd/* files to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin --- drivers/iommu/iommufd/iova_bitmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/iommufd/iova_bitmap.c b/drivers/iommu/iommufd/iova_bitmap.c index 0a92c9eeaf7f..6b8575b93f17 100644 --- a/drivers/iommu/iommufd/iova_bitmap.c +++ b/drivers/iommu/iommufd/iova_bitmap.c @@ -253,7 +253,7 @@ struct iova_bitmap *iova_bitmap_alloc(unsigned long iova, size_t length, bitmap->iova = iova; bitmap->length = length; mapped->iova = iova; - mapped->pages = (struct page **)__get_free_page(GFP_KERNEL); + mapped->pages = iommu_alloc_page(GFP_KERNEL); if (!mapped->pages) { rc = -ENOMEM; goto err; @@ -284,7 +284,7 @@ void iova_bitmap_free(struct iova_bitmap *bitmap) iova_bitmap_put(bitmap); if (mapped->pages) { - free_page((unsigned long)mapped->pages); + iommu_free_page(mapped->pages); mapped->pages = NULL; } From patchwork Tue Nov 28 20:49:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13471792 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 815E7C4167B for ; Tue, 28 Nov 2023 20:50:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B3FA96B035D; Tue, 28 Nov 2023 15:49:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AC6D36B035E; Tue, 28 Nov 2023 15:49:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A3886B035F; Tue, 28 Nov 2023 15:49:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 747E26B035D for ; Tue, 28 Nov 2023 15:49:53 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 42BFFA03CB for ; Tue, 28 Nov 2023 20:49:53 +0000 (UTC) X-FDA: 81508554666.23.F57FE55 Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) by imf06.hostedemail.com (Postfix) with ESMTP id 8271A18001B for ; Tue, 28 Nov 2023 20:49:51 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=BgiQHTC5; dmarc=none; spf=pass (imf06.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.50 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=1701204591; 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=ETdhPmFEsQhEIbzNxRgoLUCae/wd+Ix3V20Xa0Oz0Bc=; b=MGz1L6H3cbY3yH5lWEDniy6PaJ8Y/CvzHQs9Q/9jAQ+w3eDOZFqLk2HT8T0pCquubktaSQ M0JYnw4sGhQ2PMdM3S3ZI+ixo4c0MO68/dK3hIZ6NMys+AW6almyOiFDD7crLhGySsy002 NRsFwfPvocqLNUHkDO/a97ZCp9UpOyI= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=BgiQHTC5; dmarc=none; spf=pass (imf06.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.50 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701204591; a=rsa-sha256; cv=none; b=c2DlpkPi6ijz+24477EQ3eZUEIpcQ+wnrI7Un+Jszta/Jxb+OH08aio7P+OEiE/d/AQr9V V52vppw7h/fs2MdPVnqrMXEN6VY511tGuzoIBgLZc3oVCu1Y5tJ4OxxM0gCWOTVRYZpWdu bjBo7ci/AZjuwpfMaKSca6RnzjlqYjg= Received: by mail-qv1-f50.google.com with SMTP id 6a1803df08f44-67a34fbaf12so18842966d6.3 for ; Tue, 28 Nov 2023 12:49:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701204590; x=1701809390; 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=ETdhPmFEsQhEIbzNxRgoLUCae/wd+Ix3V20Xa0Oz0Bc=; b=BgiQHTC5KFQycKeh0AoM7KHBurTNY1spIN9wS+dSGuDvLWi6M5GKQjMaSVayaYxqiI YvgibEpGjY09sVXoszbNdusknjnOFCJpg3mxQqs3EnGJMT5xIWdVa05DYeYxFya09/KX 7guta/cCjaxM8hzAnhQGfZHF8ctglSoCpweu00mLxqhm7NyXOxjnUFOXtGPDwKxhmPN/ GGsM9e9s+xD+tSmvD53cZ2jGYGGIlerFPIfI3QkhrbFEooYCqEVTrLeSNgbURJZgxv1I DQGVF4jdz8S7mZ8IQDawxTKealRa9yvHy//L7zBetrSUTmh0/AqAq/aR7OZoF/E5ebAk MGXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701204590; x=1701809390; 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=ETdhPmFEsQhEIbzNxRgoLUCae/wd+Ix3V20Xa0Oz0Bc=; b=f3jF/UAL5sX2ek/R6QaruSUqpKckj9wrZneWbqonZA31BF50SAEC0EUeaW+5cz/CVk ztKpeqxxx2oouV7Fjk6xIwPv/jbjacjOnRrjYkF1OKX7L/qRvnpWyO7x5+FSGXPuD/RH 2maq7ltSNvGy1ltMfSH8g2aXmSuvA3hb+K9svLFQeBVPnSzmE0icCs2Hhexe5YwOJIoY tH5cJCeZ18D9f7VVx2KVkb3hSR+v6G+b4oOwNWeO504FaGb24RU3/flsX24Cyh21MJkv LiOYZzAP0V2UBxYsbPujIdVX3xt/UjgFkT6wF2CUCNX7L7MTkbdm+Ddyk07bEZfbaxud OtmQ== X-Gm-Message-State: AOJu0YwZkM5BbJpWMty34ikQKbJB20cY5fwAz11T5JSDmO5XamT1T2gH yfmu1/2RZXmvHqvVfSdREWsHPw== X-Google-Smtp-Source: AGHT+IF20t0VWjgac0dRIZCA1JkcXVtwNJBGTcAuMHzFzEm0RhGR7NzU38i0clAtj6I8+ULrxoVFmw== X-Received: by 2002:a0c:ebc3:0:b0:67a:2129:c05a with SMTP id k3-20020a0cebc3000000b0067a2129c05amr14629363qvq.53.1701204590697; Tue, 28 Nov 2023 12:49:50 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id d11-20020a0cfe8b000000b0067a56b6adfesm1056863qvs.71.2023.11.28.12.49.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 12:49:50 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alex.williamson@redhat.com, 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, jasowang@redhat.com, jernej.skrabec@gmail.com, jgg@ziepe.ca, jonathanh@nvidia.com, joro@8bytes.org, kevin.tian@intel.com, krzysztof.kozlowski@linaro.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.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, mst@redhat.com, m.szyprowski@samsung.com, netdev@vger.kernel.org, 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, virtualization@lists.linux.dev, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com Subject: [PATCH 10/16] iommu/rockchip: use page allocation function provided by iommu-pages.h Date: Tue, 28 Nov 2023 20:49:32 +0000 Message-ID: <20231128204938.1453583-11-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231128204938.1453583-1-pasha.tatashin@soleen.com> References: <20231128204938.1453583-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8271A18001B X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: wmkrc8jak35etn4s5omywef961jebnxz X-HE-Tag: 1701204591-824692 X-HE-Meta: U2FsdGVkX19eFLaBI4CV7jPpcQY3nh1iWn48buuDDG6QrCtYDmu90D+FJPtHJUPj64D5PiE8hIdjd+9VZ5bpcklvnWIBpvb8QlT1luXbHBR+GAcmp/OgFBSmrDtanIATi37fsKRBPZeS6h+TbG2r4ApQ/5V8jzEgE8yJ/YQt+HB2EMB3p7nH6FjInAh2LIBSi2U/jMjtKIzTBjwVg7xXtmBTqirTTMSzCT/Ghc+B22bwSNn8DbW1sdj7nOrh8ESJp6cP4oO6AMMvyC8rUaAtM/SiZ8q47x0AQgfJr9a9HnTU1IwJP/B0sW3yRgtpwRCy5zo+NYCwFbobHCONolQOQLH4NrxKJRIBj+pN/suJWUe7KMfHjflkAiBZCz2d85bvr6Zy/vumlweQxSJqtx6MbDH7yV3oVHZ1LGqBKaatbhUQWC6CiSWbRK2mvlvsNIUo3OxP3ZVac03ZTiL0RILi4dHpM4lyPr4FH+9hw/iLzTbRZvkKzrEPlbXRNT603AGs3PvunI/Y6R8qymzkp6snOf6WcFYRRasZIVxTsoUFex/Caz1FwIrupF18ITP6NIwP64P+sgD0XqDsLCydQcIYpmbYUihFzC7le+L2A3dKNhsVIETt3Wu+VJO/QmzxbNe4vK10hSWIWop+cBXonF1HhjZ2GUaymWBOISvnucJNWiTPanGHxCPIgRfxojZN9bWcQMHUT2eZ8TvbSB17W3qUz+nl/u9t+rMiIKIT4kHP0utc4TE0Vz/4GEPSqHHfA9ZFnIgi2V2W4ZZoOPVfxLnE6B+UVQJ3QtgLXtl/nzFsPiyvlnIhg3KCTUkp6RUcyBXoJPJKVUI9oWGBDIFbJPSWUq6xFHNa9YZMT6D+x0HpydboLTiOfErkrKiwj8oqy7vLlDB7I+aClTSOwt4n6P5P8MZRFDdSRUhywg0gOTkYnDTFmupxl+1dNNnTngXStzaNBUBkdQ2yb8yKIh7WSA2 W0pbz9cb wCQ+PM72E7Z9AJk7Bf45sN20FYl5D2MPYwTWY7+eyE45vdzaFpyS7eudzCJ0iR8WAyCfWZMu8Mq2aweJoMCAM7i0/kFhvErHL8MUx9icU1CQX+A/x8AQd7tdEQnwrzGEdQMU7oCIOyodGbvsfiFA2uHTmf2CywWdPhTecLdo5RBlQDEke15SgOFVuStBLZ5vIZolUtDHoDAYp7nqHC26lD494RglS+gKSA9GiJFURzTA41nvyjuZMjCCTB2sGVc1/VSnVRVsQWOGz9z8kFGSPtKmYsaf1fRDJ107poxy9mARJfXhi/7V6dbvb1yqSs/VKx0tC3Mc/r/472IVvMI+sx1i47usJS9OPXHqUw1XCPKafdKih3BBmuffG4FFdpcdEhFlIT//f8u1V2pUqzrD2/8qhznTjMk+Hfspe/rqmutnE21tMwPkdSNDFhmfhbSW+grc6tkzUwHC6Km0YzNWUy0OqdUrl5gytOm0W 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 --- drivers/iommu/iommufd/iova_bitmap.c | 2 ++ drivers/iommu/rockchip-iommu.c | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/iommufd/iova_bitmap.c b/drivers/iommu/iommufd/iova_bitmap.c index 6b8575b93f17..4d5d1be807fe 100644 --- a/drivers/iommu/iommufd/iova_bitmap.c +++ b/drivers/iommu/iommufd/iova_bitmap.c @@ -8,6 +8,8 @@ #include #include +#include "../iommu-pages.h" + #define BITS_PER_PAGE (PAGE_SIZE * BITS_PER_BYTE) /* 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 Tue Nov 28 20:49:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13471793 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 12CA0C07E98 for ; Tue, 28 Nov 2023 20:50:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8A7CC6B035E; Tue, 28 Nov 2023 15:49:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 855DE6B035F; Tue, 28 Nov 2023 15:49:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 65BEB6B0361; Tue, 28 Nov 2023 15:49: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 52C7D6B035E for ; Tue, 28 Nov 2023 15:49:54 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 2E65EA03AA for ; Tue, 28 Nov 2023 20:49:54 +0000 (UTC) X-FDA: 81508554708.21.4F5B268 Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.182]) by imf15.hostedemail.com (Postfix) with ESMTP id 6B3B8A0012 for ; Tue, 28 Nov 2023 20:49:52 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=lXKOIJ1t; dmarc=none; spf=pass (imf15.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.128.182 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=1701204592; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WwZxW20NTsAI6OtU2mg3WBn7dc7VhXurLb9lJcGaB3s=; b=IDA+d0adFqChIpCLSh/xNSswVlrJ7hOCHOKcoZ1b+vib80P++QqCnoCQ7dDnr7YBPyKfuo pp3j+yDQ9bwLCX+j1hjnN2aBkNWS+XphNztbVPjAkmD9h15G0TnP0uaT9nsSwuhxTBv/GN bgML6xbLqxeTdMfczyiRLZDxt30ONWs= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=lXKOIJ1t; dmarc=none; spf=pass (imf15.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.128.182 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701204592; a=rsa-sha256; cv=none; b=uswtFspruHstzAO98QPV3YL2KE+VNZO1A0cO72pL9vFQ7EwsOp7La44tegwue0o3bfhzid w7Nog8eu5eH2ooyIWzE2LQJOvvkMRLyA+g+QO8pHbDjW48grbv6TMxE6IaTdjWf7TSQU5K NZQeODuixg/LYqf3VO2GEIZOf4mSqJg= Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-5d05ff42db0so27503557b3.2 for ; Tue, 28 Nov 2023 12:49:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701204591; x=1701809391; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=WwZxW20NTsAI6OtU2mg3WBn7dc7VhXurLb9lJcGaB3s=; b=lXKOIJ1tvlFsqy4JXBOZTVEqXfQKyXLcJXHv222z4LDeL15X9gm4iNJjhi89zjrRyD hpv2D3WMDsKHNraoNfxuv8+AymYC+JOFTQmcsE3mVGmmhOka8A6xEkTfYidyUKt4pPSE xtx+s4Wsar0lVZP43q2K1wVAYGFrBVL2rAbK7oXO+LdLgR8VvJRHWmJEi+wLQ/AHJM7k gkJ99laZ4tQnGGq9eIKQyv+25kn4R+QvTaL1iKZ9ECibsX2Gj6mGNMPUnyfyAbZr4jUl +GMVxHPAp3i6jX6RVxQmH5/Bwo2bgRLchrIylFNoiNp/q7K4z3pPULo8BT97eOeDZrLN 50GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701204591; x=1701809391; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WwZxW20NTsAI6OtU2mg3WBn7dc7VhXurLb9lJcGaB3s=; b=CUoHNLOBFvAswlpbAsky8F/dfYCSy/lbyNFQ5qI+TWCBVo3WqTQTPS7W8NQxzsbNmI I6iYUmDdvCNnk2j7wpN6tBGb1RjZgCY40WJlqOgUVML60wunDIfzQ/WxBHSCXSKAVZou NTmGfDYNtSOCEb09YTa4/Hh7WtCNXRHIzVgWuhJBxTQIMdBgzjicOpsBuQJNuGwnTNQL 3piMQNewl2UoR98JucK+ZgwdWJdPl3VfqGv8o3e1/At3+Tdrk7TuKW8fgGPaOr7wyt/4 ZI3LzPTpZ5lJ9bIwulVDUgNTo/GMkMAvHDyi/shsUc1uOUL6rHaZcEq4G0bJucPmJEtL 4nDw== X-Gm-Message-State: AOJu0YwvYkrHjLgskodYBSUeBZhO041nfyPN17Dg+qi/X8o6iPe+S7+j VeCcsEtbmkJ6lsCfmsffxYsGMQ== X-Google-Smtp-Source: AGHT+IHCcneC8xut0NvwO9Mjx/qxjTP4L7ixlY2hbUe9eNo80eBX8ekYQZcNVvvgdD6z0QrQuBV3MA== X-Received: by 2002:a0d:d409:0:b0:5cb:5171:ab07 with SMTP id w9-20020a0dd409000000b005cb5171ab07mr16139567ywd.12.1701204591541; Tue, 28 Nov 2023 12:49:51 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id d11-20020a0cfe8b000000b0067a56b6adfesm1056863qvs.71.2023.11.28.12.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 12:49:51 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alex.williamson@redhat.com, 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, jasowang@redhat.com, jernej.skrabec@gmail.com, jgg@ziepe.ca, jonathanh@nvidia.com, joro@8bytes.org, kevin.tian@intel.com, krzysztof.kozlowski@linaro.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.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, mst@redhat.com, m.szyprowski@samsung.com, netdev@vger.kernel.org, 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, virtualization@lists.linux.dev, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com Subject: [PATCH 11/16] iommu/sun50i: use page allocation function provided by iommu-pages.h Date: Tue, 28 Nov 2023 20:49:33 +0000 Message-ID: <20231128204938.1453583-12-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231128204938.1453583-1-pasha.tatashin@soleen.com> References: <20231128204938.1453583-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 6B3B8A0012 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: hfjj76xxkhpmxxhibcf1mwo7yrpd8g8e X-HE-Tag: 1701204592-438416 X-HE-Meta: U2FsdGVkX1/FYCbCo8YbDWrmKbv6fT3FCVvwQjuBDh4dzfx7xwGTfN/udjGhJTxvxFjOmWBNupF3RLZS2Yq3oS5Ro2T8OOw7AIfvXRcKFyRHtf3hr9CK1ZFYrRBMST9v58zlIGw1/wjLT1QJu3X914U0TOBItHCloFojY5030dDpdhOCrd7N7ohWTmWVUpihzSpSQhnrean34m3WfEolWs23XObIUM3ZOq8pLWbe6uLHzKgOYtd03KnZB3HFbJjMclGRJkyR8QIb0memtUJnYgK7a2EeW5J6MeKMTPdfVHsLCYHfa36Y1sjip7UYF4giERreyhUn0+ktYUS+keNmrROF7N3ZDK1aYiFzYeCB8DoEF995XoBwnL9JRQUvqWcs9MbUvcji4syhqDnC1HBmJpBDAelkTa5GGXn4td1A36kLWVuzfycHiU40BzvZyz/nSgp7QhXkHDv2GR0RApqW9blmYTroJXmHSubByOUCtVdyUfInyx6TYKInLdk8IDaWBZDpHP6zF5+OrH4oy7ghcF4nh37hSQGaCumw+rZcrcRzNK2d16EAmznoWZA609DQqWXlrLOPc44frH9184FAk+QMBNDjiqjlyn7tz4gBcF6YxmWki+7g4FZRLyKJTYAe7G4IpFdZoW5z5WojWzuw5gnCm3aCVkkiqFlDhRcF+gpEYQ0+lxXMNHSRK445sdWTjHw7DlCjtxoMv6DvA2/Vpcw4ZkGIa6ikAbDt0ut/QylpshuMOmctwRXeTXU/3ihN5X4n/bCvtj0OLMfcL67LVd+3iea3f6BmSydZgB1rIproom193BtT48+vWoU7yMsAbC8yV0dCiyyiGRHVkjJJOYyAhEXxCTg98zBnsHe1ytCaESZTiC212y8Ixr9ooYX1QzkusywGjcCiOGqt4nt0/wF0huzfHGRIbvYgX/9QXBjNgYDOszwRcw3HmgbS44vV2Ozvg9tyF2kljluIwb0 RiZQU1vH VdFfz/WNX+k4NlnzLq4uGnH6gh4VoeETq9CZCSBc0ouyblMOGot47eDSZnhlZ1s9AGGyF4l/FkPr5bwPBdZ5qXu/J+iS8XdTqu2f/tsA4aQOa4FPXrHEPL8S9Q/poOvZuuAQPLHBPjPYs+dTLhOSy51slmNg/WxsPRlhzwjwJZ1td4ssweoz5F6wxgPIBFhY+QmHx0d6hWm/lOz+1xvef8/FBa5/EmkrNxLSvqYk9RqvN/PP5PdVA9ALt+mU2ENCxeggFxEg4OpjpRMfqWWia3OJF9S40HxgOXReVWe7fdcXxp6pW4DR2dfM0pnBtOmkdJONhVfOLj4TrivZFr5Iuan3jdL9eQ/g6Y99KVx/5s/GZn2OywrdmgkqA+8tb2RhTmINj7lyGyLvDmlhBduyiB+lMF/uEJdhG8A8jgKX8npKEZrcAcX2SaTtZ7cALUMQ9Yplc 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 --- 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 Tue Nov 28 20:49:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13471794 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 A2A18C46CA3 for ; Tue, 28 Nov 2023 20:50:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B19576B035F; Tue, 28 Nov 2023 15:49:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AC65D6B0362; Tue, 28 Nov 2023 15:49:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8CBA86B0363; Tue, 28 Nov 2023 15:49:55 -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 7826D6B035F for ; Tue, 28 Nov 2023 15:49:55 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4E97B140388 for ; Tue, 28 Nov 2023 20:49:55 +0000 (UTC) X-FDA: 81508554750.08.2BECD40 Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) by imf18.hostedemail.com (Postfix) with ESMTP id 878F91C000A for ; Tue, 28 Nov 2023 20:49:53 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=fi9tGPoo; dmarc=none; spf=pass (imf18.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.53 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=1701204593; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=CTqyv+/QBqQRpLXIT6J0+RNMQRf6NZoT619SVstW8Ks=; b=a+UOgwMSr+fO8+WjK0+Yyvo5WTdVa2NG4Hhe17BBstICWoTdBEYHsuktcdSpsiX2PQG6ta 1j/2ODn1vO0uuWAeCIAO4ORWvuDSaP5zO1w26zEAl1Vz6FReRDkqsVDZOTvaGYZ9Xf2VUP cP0pQyTr/wJVPB3k3HqeeEHQO7uMj2g= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=fi9tGPoo; dmarc=none; spf=pass (imf18.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.53 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701204593; a=rsa-sha256; cv=none; b=ciINCWtOoTmN3832LsbHSY/yt1FsA5EFf0uupSCg2cTVS0CXvvoI+zh0e5iXB3OVg/+dzq yK053X1AWex5Z1AmVcUzTu9MWZjzAi8P6nyGZferqJ4PuVDpH2qfYXVE0giutKzgW0d9Yt l0ncSlKDx5uPhVgrZytIu9Di8Z3ml2U= Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-67a095fbe27so1639996d6.1 for ; Tue, 28 Nov 2023 12:49:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701204592; x=1701809392; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=CTqyv+/QBqQRpLXIT6J0+RNMQRf6NZoT619SVstW8Ks=; b=fi9tGPoog52TSWD+5FtBWQi2IVWWJhSQO31E1yBcaSE7SSvpEXbuZDSZytQYYWqo5K Sv/myzN0Lo0BxyifMTKLhG3R3ha/5PaiDvXRpMaQKEAwnWyTCT/qEehtVHrhLxPmD3cD 36tYz7jpTkoUFma+RhZMx3Wq4JXvLdQGG/+wG7/DipZb8srLEDB4Os9A9MNP9cfcxXut uV/lH/Wieh3j6jGaOfYkj4zCFPZc8GGWQ72IGsiLrabGrrX86RDnkR6mz53J6zG3O/Ip kjKOZICYBH7kYLdaZfwghPjCV7O1+E5VTvL3z1Ed7YKj8u3VHuWLJ1ohrCHD67TrAysx hyxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701204592; x=1701809392; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CTqyv+/QBqQRpLXIT6J0+RNMQRf6NZoT619SVstW8Ks=; b=TlkmzXRh/j2Q/7qN1Q728SnMRxfvsMyQzPHUmT+5cjIJhbMOA73F+A6GweyXpEKnFv GoIHyFoerM2K8IU6mIXh6EHfv59TaW2w7hId8khx3b9DOfC5TtZGpTZ2YoFADIMsqJaU HCrkQFuVAxzViTvDmLvyfiOq8g433MmTxYq2kPIunbbJWGKGF9J7uEu8rP3sK3YDRhnY InfBEwqzktVozADHjof5x91Z9+ZUVZOC6L0nWEDnuICMWFfS8MGL2YYXmqr8c671bwtp X2ynV4U2zQZnPIyH5BPMzShKJ9UVLYp3+NRPvn6WzuG9X03a+dTqVlGhBsfHDc4Vg/GG dD7g== X-Gm-Message-State: AOJu0YxFbNxiB9qmzxgsYch7EjWrjiPkwTtDaQZzTirs28TbIG147nC4 NLi3FBmN4L7nf7gG/FAmwc35Eg== X-Google-Smtp-Source: AGHT+IE3AYmHHgK/QSP8+MPcS+KRS5b9M1xHWJUdTuMzT9sQ+l/sj698GMRB0ddulu50PHGvh8bO9Q== X-Received: by 2002:a05:6214:c86:b0:67a:4f19:d862 with SMTP id r6-20020a0562140c8600b0067a4f19d862mr8115033qvr.18.1701204592666; Tue, 28 Nov 2023 12:49:52 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id d11-20020a0cfe8b000000b0067a56b6adfesm1056863qvs.71.2023.11.28.12.49.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 12:49:52 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alex.williamson@redhat.com, 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, jasowang@redhat.com, jernej.skrabec@gmail.com, jgg@ziepe.ca, jonathanh@nvidia.com, joro@8bytes.org, kevin.tian@intel.com, krzysztof.kozlowski@linaro.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.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, mst@redhat.com, m.szyprowski@samsung.com, netdev@vger.kernel.org, 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, virtualization@lists.linux.dev, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com Subject: [PATCH 12/16] iommu/tegra-smmu: use page allocation function provided by iommu-pages.h Date: Tue, 28 Nov 2023 20:49:34 +0000 Message-ID: <20231128204938.1453583-13-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231128204938.1453583-1-pasha.tatashin@soleen.com> References: <20231128204938.1453583-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 878F91C000A X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: kcwsweraikuiqrf9fbipe5powyqrtjau X-HE-Tag: 1701204593-940994 X-HE-Meta: U2FsdGVkX1872XVWyJDKBIJjc+sH7tf8KxjWn1ZMDzVraIkea9YYD0Xs3IROzA6GA86TPRCWJ/cdce+dmEVNHXG5l8VTEXcXCi4l6T4NRoy+2bmXZ4vEquaPZLODaz9oAZrS17iTmdbgQ4yUemrAH6VN0jKPRJsrICVqXUTgZEnXnldpTqs1QVjlV39a4h+fHkUjx/z/DsdhCP+OTGzmY9U8i/b2+wdUyQVVb4YS4CivMsa7shAyPmAdu5SeytSjks5uesOPPY0j97rqGA7boTKcMY8uq0RkLb/tDqNe4WMzEOqrZGZsqrpTfw6svW7Vza7lKtwaW670m68WtH5g4j24SP67j9+zSbHdfKk44ZeNcwA6wbBufuG6U4sT4qaCuKkBFPjRlGEJTjUMFw5qro2VSXSt0F+BMJ5UlbmkDy/ZxwVCPdPCN3Lt0MisXOs5Erbsl+luLJakjl1uhtu5eFjJHArfayFul+iXINvDDH6u6MQTjjteUoAGeaPg/3/SU9Bx7dzzx44PBstJqVUDSjr4NrmUDeo0i8hOd0yrBtgstbFQv4m8YcREiP2PdG8XwkARVtX6bSEumcv/pH9Lq0Dfwq+xTpweuyNaSDY03S5UballXD0SVL14xdZxTGz1ZcPC4chqdglW3u82YtjdZG72bKP1f6BnFi65HAY3oIXP2RA+mZqarAe22G7W4ohcgBRMyXIRAt3URVkFM6V98uq2B0QUjT05Gn8mnnpAqau/TIDPYA3GQbESlFaHWm5y3emWo0xGT6H2T4HHDN7y/SSKngqy1Vtmh9gpYHtAvF08jDv3z/CMLscp7j4U7MkDojzwkhPxuIS4jDYjq0ySYRbhEBUvo6fRKDboGhr1f6p7zw0wHTMoLf4EU+jYzvamTXLHBEwTAO4KI8Bjt+rO8pCj19k0L7x/DdYlfFzRGtfcVZwQJFsMlL0OvRDpoXkpYEFnvfv240I/sgBxRnp aolPtgz3 +ub5W8T08I1Ao7ggPVGkiPxOOpt1k/0IR6K2LdqmMfVQSogClKbf6bDaB0YQQj+7b8oGFurfi9cIO68V858rRVfrSL/3JfhCoU7hlww8IukhibK1zRj4qzddHSEHMnTjrNqpXbrWIhjEgwrf3RGrG/Sxd0yEL1TH7dEySYZ8yML5bfh76M+j+8V3ZEvwOISLauywxqi8ICj99Ut+Xuy6BhCCr1M15hIR70g8R06U0995v7xziMiPLTIi9Ja96gZZzR/fvFpbxnQyss+n/KvfTxx71LO+1KGzgUWFcjpwvVbYFQVU65+24ujoVn3tHIRJXX1x72mge1DNGYhhuytBf22GHYOZOo5uSXKcU05sd+3jEXcc6BDGUIjwiGUDVItD5yRs+eEGMfrRi3X9+XM4VbEGKrsgP/rLpDIbgzh0FYEHNGU2DCCJ/43D46xCmKBk4kQGU 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 --- drivers/iommu/tegra-smmu.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c index 310871728ab4..5e0730dc1b0e 100644 --- a/drivers/iommu/tegra-smmu.c +++ b/drivers/iommu/tegra-smmu.c @@ -19,6 +19,8 @@ #include #include +#include "iommu-pages.h" + struct tegra_smmu_group { struct list_head list; struct tegra_smmu *smmu; @@ -282,7 +284,7 @@ static struct iommu_domain *tegra_smmu_domain_alloc_paging(struct device *dev) as->attr = SMMU_PD_READABLE | SMMU_PD_WRITABLE | SMMU_PD_NONSECURE; - as->pd = alloc_page(GFP_KERNEL | __GFP_DMA | __GFP_ZERO); + as->pd = __iommu_alloc_page(GFP_KERNEL | __GFP_DMA); if (!as->pd) { kfree(as); return NULL; @@ -290,7 +292,7 @@ static struct iommu_domain *tegra_smmu_domain_alloc_paging(struct device *dev) as->count = kcalloc(SMMU_NUM_PDE, sizeof(u32), GFP_KERNEL); if (!as->count) { - __free_page(as->pd); + __iommu_free_page(as->pd); kfree(as); return NULL; } @@ -298,7 +300,7 @@ static struct iommu_domain *tegra_smmu_domain_alloc_paging(struct device *dev) as->pts = kcalloc(SMMU_NUM_PDE, sizeof(*as->pts), GFP_KERNEL); if (!as->pts) { kfree(as->count); - __free_page(as->pd); + __iommu_free_page(as->pd); kfree(as); return NULL; } @@ -599,14 +601,14 @@ static u32 *as_get_pte(struct tegra_smmu_as *as, dma_addr_t iova, dma = dma_map_page(smmu->dev, page, 0, SMMU_SIZE_PT, DMA_TO_DEVICE); if (dma_mapping_error(smmu->dev, dma)) { - __free_page(page); + __iommu_free_page(page); return NULL; } if (!smmu_dma_addr_valid(smmu, dma)) { dma_unmap_page(smmu->dev, dma, SMMU_SIZE_PT, DMA_TO_DEVICE); - __free_page(page); + __iommu_free_page(page); return NULL; } @@ -649,7 +651,7 @@ static void tegra_smmu_pte_put_use(struct tegra_smmu_as *as, unsigned long iova) tegra_smmu_set_pde(as, iova, 0); dma_unmap_page(smmu->dev, pte_dma, SMMU_SIZE_PT, DMA_TO_DEVICE); - __free_page(page); + __iommu_free_page(page); as->pts[pde] = NULL; } } @@ -688,7 +690,7 @@ static struct page *as_get_pde_page(struct tegra_smmu_as *as, if (gfpflags_allow_blocking(gfp)) spin_unlock_irqrestore(&as->lock, *flags); - page = alloc_page(gfp | __GFP_DMA | __GFP_ZERO); + page = __iommu_alloc_page(gfp | __GFP_DMA); if (gfpflags_allow_blocking(gfp)) spin_lock_irqsave(&as->lock, *flags); @@ -700,7 +702,7 @@ static struct page *as_get_pde_page(struct tegra_smmu_as *as, */ if (as->pts[pde]) { if (page) - __free_page(page); + __iommu_free_page(page); page = as->pts[pde]; } From patchwork Tue Nov 28 20:49:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13471795 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 565A4C07E97 for ; Tue, 28 Nov 2023 20:50:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8AA9E6B0362; Tue, 28 Nov 2023 15:49:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 832D26B0363; Tue, 28 Nov 2023 15:49:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A99C6B0364; Tue, 28 Nov 2023 15:49:56 -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 553836B0362 for ; Tue, 28 Nov 2023 15:49:56 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 383EFA0158 for ; Tue, 28 Nov 2023 20:49:56 +0000 (UTC) X-FDA: 81508554792.29.DA3AF7A Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) by imf18.hostedemail.com (Postfix) with ESMTP id 5AB091C0012 for ; Tue, 28 Nov 2023 20:49:54 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=XRRjlRmC; dmarc=none; spf=pass (imf18.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.44 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=1701204594; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=B42Ompk/0S+0FHWlF0c0WCUF97rKJOKtrfjrMLAbFqA=; b=HHPrvoUN9vSJ54+wMhrHdKOWKrQIiyxsbRHtvednsl9HJLChVkwgFRX0RyCESf/N7epYTu SZEkn4BD/iC2ppS6A+Z0bLQSLpFCoXQG+SZBslO7P8lgbY3g+IZDgm5lawocRuOMKHiusL bjk9P++7YhTx+v3yXbr+4pHzmsrSlQo= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=XRRjlRmC; dmarc=none; spf=pass (imf18.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.44 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701204594; a=rsa-sha256; cv=none; b=0h0O0Ts2Vupazl5UIi0ZU/dtPUyB0gkhkL41DExU0ry7qt4CWec0wOgtQalxdhxzEyoaFf rNVV9nbiD0JgB1nfOTDoy2cfHAG2c2HtAHJFbQVhgDhmzLI3lwpJ0KVwFLmyqF5GBf01Ca ud4HpdrAzxNCno+nZ3iKFjkgUzlzqZQ= Received: by mail-qv1-f44.google.com with SMTP id 6a1803df08f44-67a31b64a9aso19243636d6.0 for ; Tue, 28 Nov 2023 12:49:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701204593; x=1701809393; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=B42Ompk/0S+0FHWlF0c0WCUF97rKJOKtrfjrMLAbFqA=; b=XRRjlRmCmElYd/vRl+4X62fT2o3fdEDmpl0510IrXPwSEtMhfSEtDknIc9W5PwAhfz SLd7EQqSgbXiowLPYhLKkLTd8I7ovBGbvIJmLyA6a0uoXcFQB0zjdNG65i69h2yXJtjy ZzPuoAOjjCIfjO37DzHaCmU8NtBEbc0Ox/6RsjlrIw4EYlMF6mE1YFpt+GXiQiZtHCqv AQNAS2euhLn1lteAD1GlnI/gIZMGYT7NSkOnw2RKoLxYrH6Ef2/os8103O6V7f2gYPkh z+tth4QHwq5pYyidHUabRB0a7AAhBPXn9BcRmIatRYFDvDTlLFeGB0PLz74vdydJXfmF osvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701204593; x=1701809393; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B42Ompk/0S+0FHWlF0c0WCUF97rKJOKtrfjrMLAbFqA=; b=hArrqPEL8MNILQZ+Pij/urToP8n6brQNZ9vwJ87eHsh6dcERr7Gzht3/ZhBdO2dtOJ hoG2dBINor3EkRskcEjq8KMS0oYVu7BnFVXhUwDESjP8IVp/2iMeSa6Rdcp6iOAl3B8E vcTol2J6y+lsgw1LcNxHK4UjyOB751nrHoT6X4DZnqUlQ9JyiNTXA4IyOlCwuwkb3rIr FILnjVXeYgP2hdzDr4ybWbD+5zR4BzattVdUAnITux3MENqUiJLyDe9yMMMyDlgmp3pa GnPHLMLC2Esp5ae82jrSEjD/nnnwhpP5vXApTGGHv+HDKqDy5qVk/hmRtDt+r1vbh/2F wkFA== X-Gm-Message-State: AOJu0Yzz04Pr4YL0Z/TutvZXblk58vtGbX2CFO/SMgS1jTorSgwrhTgX G9pRWM8E8XYP3lqe7GVoXr1C4Q== X-Google-Smtp-Source: AGHT+IEnkegi/uFQPrDyc6H7OPo4j0lB/ryXbrV4xgswOmTSvbgLDCpwj8bvXcZGxvDXiQNLdJDbew== X-Received: by 2002:ad4:4a6f:0:b0:67a:5ae8:d346 with SMTP id cn15-20020ad44a6f000000b0067a5ae8d346mr3075756qvb.62.1701204593484; Tue, 28 Nov 2023 12:49:53 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id d11-20020a0cfe8b000000b0067a56b6adfesm1056863qvs.71.2023.11.28.12.49.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 12:49:53 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alex.williamson@redhat.com, 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, jasowang@redhat.com, jernej.skrabec@gmail.com, jgg@ziepe.ca, jonathanh@nvidia.com, joro@8bytes.org, kevin.tian@intel.com, krzysztof.kozlowski@linaro.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.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, mst@redhat.com, m.szyprowski@samsung.com, netdev@vger.kernel.org, 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, virtualization@lists.linux.dev, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com Subject: [PATCH 13/16] iommu: observability of the IOMMU allocations Date: Tue, 28 Nov 2023 20:49:35 +0000 Message-ID: <20231128204938.1453583-14-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231128204938.1453583-1-pasha.tatashin@soleen.com> References: <20231128204938.1453583-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5AB091C0012 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: z56irjt46twprknhcc7qqgehmu6s67oe X-HE-Tag: 1701204594-318821 X-HE-Meta: U2FsdGVkX1/igkfQCMNEfEaps9XS+sEmL6AAIeGTlpxZaKExYqzydka/IHi7arC7nn18eI0TufY7I6iFv/SCYfl4UncwmNreLwZ2tswb85Azg/KcH3b818ASvefZIEoj2Z4YZ/2hGBA+yIujAxaw+Fo0m76r8CGgxm1ODratsqHkD47UP/m3PbJoFv55fYtX5IUPgph0jax8xBO2Lzfg4rojliCmwLKUNX+WsJqFjqX1swRJQir/YYNWmOJXYYCo+OUwHeOebxgGERu4DCVzo8X5rY/BQBYD82Xo9xnpx4nTUGQ2Nhb6LtVt6yaV/gxpGaolCPbdfwo9kQhCLlfw5ejC4PzeFeh4P29rqwnsaKaGP0j4pRSGtCdV4sR9TgrKDDEHv8eaji9jRn3URsNVxxw+mtzOHZEkAH+O1UCXREHvoARtM/jkkeyhBZPL8qxYtZJRkBGh0doJie9bdyCt0XOkCO8o+OOXpaKwNZZWdpv55iwVeaWTmgRsWSgVrH+AXrRekwDdfwLkkzccrhfhh/susUUtcCbsQGjl8wmSnPB0EHTpYontdUekFxgK2ofqKrZ1+J5Hyb+nhmTWfZcdrjbtOFiihPeCbuBGR+pU9Y12vGoGhXAsBEIGJTpPhJBI8AyJ9+LY/o7pLgqg6V9KMuHxd7ESc92G3SDRZ05tMoGPAO9NS9ka97vN6YXXVT+BDpXI5GBDptbNu6i/gNeJMXoJ4ULBmt21UDLMSYNYBry0870zR7MMBDlknWeOKDmkc0pUKv/WQFY+FDELkFZ0u662BqdIg6/m/1Q2e9xzJQjUv5az8qvgQS8nPlAmn3aaQl9YsphQ/Uzg0fyg4+9PfZkpDJhycWMoxaYlaaG+70iyP4k87lnNblBsYrfj0WyebmHQIA/Te4VmFqSDgxMJkZ1lv6MnfkW/3xRg8JS3QHrYl7OEz9qU4f/F9bw6ir7uqDhwgG2fZeu746pTRC4 +yuLblAJ qGtiuJDRNNy5XTQw9VHvRKZA7XLalfXhN5A+O7ykyLI6vnaTg+WqRbfY+MAXH5HtAmxZPhSLc8t0XyRnHpdFPdaqbIJ+vpEtxNkQuyuMDRfynowPtdYumKGS7i5zDDRMdkN4cEG2ov2cgwTZKygvCkcjrBTsY4Uu3knnjI6LUDhfvnQUvIEi3RzXlvCjb8lY7O1nGvTguxbqhBihfyFQDtMIQMogjXBtodGqhtj76ujxCEfMTij0aT+EuwAk7KoPsQdflV76uxfjJ/0EDqnM9zkHGGA5lPjiuiN6UA6kdL4q0d/FMkbYBlYXz6X8v9BNRWQ8aEQ5DQ9kGyS2O5q7VkvGkwxYx+yNKOkSXJRoe0GEHMdU= 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 --- drivers/iommu/iommu-pages.h | 30 ++++++++++++++++++++++++++++++ include/linux/mmzone.h | 3 +++ mm/vmstat.c | 3 +++ 3 files changed, 36 insertions(+) diff --git a/drivers/iommu/iommu-pages.h b/drivers/iommu/iommu-pages.h index 2332f807d514..69895a355c0c 100644 --- a/drivers/iommu/iommu-pages.h +++ b/drivers/iommu/iommu-pages.h @@ -17,6 +17,30 @@ * state can be rather large, i.e. multiple gigabytes in size. */ +/** + * __iommu_alloc_account - account for newly allocated page. + * @pages: head struct page of the page. + * @order: order of the page + */ +static inline void __iommu_alloc_account(struct page *pages, int order) +{ + const long pgcnt = 1l << order; + + mod_node_page_state(page_pgdat(pages), NR_IOMMU_PAGES, pgcnt); +} + +/** + * __iommu_free_account - account a page that is about to be freed. + * @pages: head struct page of the page. + * @order: order of the page + */ +static inline void __iommu_free_account(struct page *pages, int order) +{ + const long pgcnt = 1l << order; + + mod_node_page_state(page_pgdat(pages), NR_IOMMU_PAGES, -pgcnt); +} + /** * __iommu_alloc_pages_node - allocate a zeroed page of a given order from * specific NUMA node. @@ -35,6 +59,8 @@ static inline struct page *__iommu_alloc_pages_node(int nid, gfp_t gfp, if (!pages) return NULL; + __iommu_alloc_account(pages, order); + return pages; } @@ -53,6 +79,8 @@ static inline struct page *__iommu_alloc_pages(gfp_t gfp, int order) if (!pages) return NULL; + __iommu_alloc_account(pages, order); + return pages; } @@ -89,6 +117,7 @@ static inline void __iommu_free_pages(struct page *pages, int order) if (!pages) return; + __iommu_free_account(pages, order); __free_pages(pages, order); } @@ -192,6 +221,7 @@ static inline void iommu_free_pages_list(struct list_head *pages) struct page *p = list_entry(pages->prev, struct page, lru); list_del(&p->lru); + __iommu_free_account(p, 0); put_page(p); } } diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 3c25226beeed..1a4d0bba3e8b 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -200,6 +200,9 @@ enum node_stat_item { #endif NR_PAGETABLE, /* used for pagetables */ NR_SECONDARY_PAGETABLE, /* secondary pagetables, e.g. KVM pagetables */ +#ifdef CONFIG_IOMMU_SUPPORT + NR_IOMMU_PAGES, /* # of pages allocated by IOMMU */ +#endif #ifdef CONFIG_SWAP NR_SWAPCACHE, #endif diff --git a/mm/vmstat.c b/mm/vmstat.c index 359460deb377..801b58890b6c 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1242,6 +1242,9 @@ const char * const vmstat_text[] = { #endif "nr_page_table_pages", "nr_sec_page_table_pages", +#ifdef CONFIG_IOMMU_SUPPORT + "nr_iommu_pages", +#endif #ifdef CONFIG_SWAP "nr_swapcached", #endif From patchwork Tue Nov 28 20:49:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13471796 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 033BAC46CA0 for ; Tue, 28 Nov 2023 20:50:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 749896B0363; Tue, 28 Nov 2023 15:49:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F74D6B0364; Tue, 28 Nov 2023 15:49:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4FCA86B0365; Tue, 28 Nov 2023 15:49:57 -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 3BFDD6B0363 for ; Tue, 28 Nov 2023 15:49:57 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 040158034D for ; Tue, 28 Nov 2023 20:49:56 +0000 (UTC) X-FDA: 81508554834.21.08CA12B Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com [209.85.128.169]) by imf08.hostedemail.com (Postfix) with ESMTP id 43386160013 for ; Tue, 28 Nov 2023 20:49:55 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b="mvDvr/M1"; spf=pass (imf08.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.128.169 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701204595; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Nk58INbxx30xLOHUnMGn9OdPuZubp6H+G9gT2CVk01Q=; b=phIWLgEuDxv92AIZhGfw+EGW167LF5JCtkcwTmMEADLEMOOwKME/J7J9ojLPcTWl6kWqtv 8sYzW6gRw76xjzEEKlYUJ2CU3/sb9o9x3ydQNy7dA+AeAlXw+GRaycYtbpn7H1AbbiMpS5 CSlraTrWX9EN/zQk/3y4wFhCTmqdqic= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701204595; a=rsa-sha256; cv=none; b=M7YtTDx2G43Qg9bwZQ3mFnfXyY+NmZP3Y5qYxz28rRn4ynEKIW6AewFYgQD61z8uK7JTr+ yOaAA1HosBIwHOKh3LAYOodbQr/MtxkBA5afEw1kv+GHJl1N/eMh1fZZg+q+yhQXja623I YdMzylIfyZhI6Ed+EhM2g7QK7eeJzdQ= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b="mvDvr/M1"; spf=pass (imf08.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.128.169 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-5ce8eff71e1so41753707b3.0 for ; Tue, 28 Nov 2023 12:49:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701204594; x=1701809394; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Nk58INbxx30xLOHUnMGn9OdPuZubp6H+G9gT2CVk01Q=; b=mvDvr/M1DsuICzjWl3ECvd4/wGd+aDwmV/H6CIyz6fBrPBiEMXTcq5pgDnf1KXeYzz JplNw6pi7F+xLHlpAEOfcD6/JkluZ2Bpqk59YnRrr+7FJiFXbDKpoUhyxARktMMyr8xA BxXr8x5HUhwYIbONfOWqpcctpR1MfHZ8cK6yQ1wiL5jZ8XPM/xwBOy5pgQ18HJBwGKm9 puWgV528vpnLA6DLRGhQbxzvjylGqRueSlJlI1xKUQUmaPF6Iw/+bkFQOIwFhcV/J6Zi g5nDxXP/sfSP9WQOKSTngYws2+tmOvwrhbDBhpahzmfznRQRiH7hO/I0alJ6fjDK1tLa J+gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701204594; x=1701809394; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Nk58INbxx30xLOHUnMGn9OdPuZubp6H+G9gT2CVk01Q=; b=TJskc468cDjsvBJE//koZSMhjfkH65E9w0dAULihkmmUZlF6qFCi5lcstt6i44haid tQ3Pxp2JR1NhJdCxtmSLrwk0I3k3EFnhNM/KHAUp8RmDk8yL3ML8mZGT9U19szo/HKY8 SKyZOKuKvLI/+TokI1JbansL40fyNPM/FNfjn3jABU6RIyJsHe/yYbRgE4Jl14OxLZYd qyuzHhRP00N4367zG5SfQhMJd2in8zyBrSdd7UBINefCnumrKysbznR9IMNgLmVhBueV eQo5ybYHs6xcSeQQQ1rkhdseo1mMVgciWe+76VVKkGF88eKug2QTUzVqRZ3BWbo4eQJv siaQ== X-Gm-Message-State: AOJu0YzVFCL6TQbo12mMI7B6DjjWwRSxru/wfE/BtX983qdj0jnwJK9T 7/zBk+fN9X0b9OB/hKPmZIxOpg== X-Google-Smtp-Source: AGHT+IFeRft5lu3DnWQgWnRJh58TGHHoSR4IZRyS1wE4nkLKveRfays9X3IHaY/+Xezkx1Q2h+wp9Q== X-Received: by 2002:a81:a507:0:b0:5cb:d645:8cdf with SMTP id u7-20020a81a507000000b005cbd6458cdfmr16849996ywg.48.1701204594372; Tue, 28 Nov 2023 12:49:54 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id d11-20020a0cfe8b000000b0067a56b6adfesm1056863qvs.71.2023.11.28.12.49.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 12:49:54 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alex.williamson@redhat.com, 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, jasowang@redhat.com, jernej.skrabec@gmail.com, jgg@ziepe.ca, jonathanh@nvidia.com, joro@8bytes.org, kevin.tian@intel.com, krzysztof.kozlowski@linaro.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.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, mst@redhat.com, m.szyprowski@samsung.com, netdev@vger.kernel.org, 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, virtualization@lists.linux.dev, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com Subject: [PATCH 14/16] iommu: account IOMMU allocated memory Date: Tue, 28 Nov 2023 20:49:36 +0000 Message-ID: <20231128204938.1453583-15-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231128204938.1453583-1-pasha.tatashin@soleen.com> References: <20231128204938.1453583-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 43386160013 X-Rspam-User: X-Stat-Signature: wp84wzftu8tqnm5hk65zqj6kky7z4y48 X-Rspamd-Server: rspam03 X-HE-Tag: 1701204595-470387 X-HE-Meta: U2FsdGVkX1955hdCsRVLf0neuy5Dy92i1vVNa7zGGOe9nDr5gj5rCg5+4t0Xw9JxyaAMeEbfrD31Spi5sNSmAHJuoda3/hvcVK4GP1Jfs5HTJm3D1+PvQGAE3tCp8Vghezenu6+VCwpM+N75sveLpMI3vbnqBeRdaSWxPu9plwgxRrLMlhjyGUTO1/5eqY8R52PmUT7NWtYReA2f6nf+aTJ5/aSCQ/DQWdxQE3/D4/2ivRkt0PjPdj2UVThzhpJGS2SG1yW4yQkwlHzPgUwXeYp5DOv05fskLLYJtX6E/3VVn45l2j7R/MUq6p54WtHiDsZjoOIEiKDDT+zm48jTAacx8EStOmZ1H3js8q5MRVD94Fyvwic1oVvvFOwIWzSmYV1ZJw4nL+c8BrueFu+S0US1kgAzqVta5pfFq0pHE+arygctkZePQZZQ3YYIx9/nH9dp0HYmUm6lCQ14ZJcVtT5gjQMdvSVq4Ukjpk2odk408703ZH+o/Jie7TI/WVzer06vPIIDT6V3hT2h/KTr/KT0YM3M5BxOW2lNHOsI4hhbIahxbljaF5fzpQ4n4C811Bw4OhrnYxZJpAZ29MbRx7osisnn1HhG+17td9mJ7OMjIgBs1Gf4n+unkB+w7FBpz5FXfxi07yKB71fuk5TUdUKDEZ9+3pYoXMJAzI8pMysHF+UtHY7PRAXoQbkAIPWr9r3DY0Z1FYW18uxGlcGbjmdgC5uMM34nvOYPqEfOnaxYMqe9NEt7AfFSCkjlXxmLc4J8FkLURI69bDDxVKUD5F/VG8ux8INTcgNiHCTBvWRC5ZrqUR7T1O30r94l+nfgkquRGgscoanEzZSPhzpGoROGM+FKNsmGPhbWhZ/DCPOD9Pxz1jhMNu0UbEb8AcbII8VJK5FV3Uc666chO2JyI84W7407ebneOLvp+j1viZVx+kTgTlCkewWj/zGkjIjuv+h0RkyyrTdIVfgAcpU xIq1G44J qUOSnTytIBK3A8zNWn1uF3xX6/SogoB0rtKZkWNDRo5E0gq2MAZA8ODm/hlesSR2roPim9g1rB6rm0BNd/4nj3ldSwq3TaARnD5QLDo8nU9XNkhxL1ZnsIhWy+7kSG8adtE/RwqWvVc3AL0ow1FjzhH0GdObwHREYB7ofm7zuYi44SfI5wVv09os7mJ4X+1ERdDb4npYERVRnxN5kIK/JwWBi+F1DaRayJA3I4IINj0wqz99vPcO2MJ+FvTCLFaXxqGlDk9yKSk4V0Ggu0vxJgo1tYyWhv73EA5tY3ACi9uoio47EyJXNNrVffTsTYmkR/C2zaY0R8HIlUDSQWJDMFzXXEvXLO4bbUUa3/y7y4/0y2D/2cZgDOCRzSJ2MIGl2JJI8w7lFQ+Bms3VsK4PzrXGWAhlXxIOkNLQegGB8DMGBrdhiQ5VutrnLmKWGN45/ohma X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: In order to be able to limit the amount of memory that is allocated by IOMMU subsystem, the memory must be accounted. Account IOMMU as part of the secondary pagetables as it was discussed at LPC. The value of SecPageTables now contains mmeory allocation by IOMMU and KVM. Signed-off-by: Pasha Tatashin --- Documentation/admin-guide/cgroup-v2.rst | 2 +- Documentation/filesystems/proc.rst | 4 ++-- drivers/iommu/iommu-pages.h | 2 ++ include/linux/mmzone.h | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst index 3f85254f3cef..e004e05a7cde 100644 --- a/Documentation/admin-guide/cgroup-v2.rst +++ b/Documentation/admin-guide/cgroup-v2.rst @@ -1418,7 +1418,7 @@ PAGE_SIZE multiple when read back. sec_pagetables Amount of memory allocated for secondary page tables, this currently includes KVM mmu allocations on x86 - and arm64. + and arm64 and IOMMU page tables. percpu (npn) Amount of memory used for storing per-cpu kernel diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst index 49ef12df631b..86f137a9b66b 100644 --- a/Documentation/filesystems/proc.rst +++ b/Documentation/filesystems/proc.rst @@ -1110,8 +1110,8 @@ KernelStack PageTables Memory consumed by userspace page tables SecPageTables - Memory consumed by secondary page tables, this currently - currently includes KVM mmu allocations on x86 and arm64. + Memory consumed by secondary page tables, this currently includes + KVM mmu and IOMMU allocations on x86 and arm64. NFS_Unstable Always zero. Previous counted pages which had been written to the server, but has not been committed to stable storage. diff --git a/drivers/iommu/iommu-pages.h b/drivers/iommu/iommu-pages.h index 69895a355c0c..cdd257585284 100644 --- a/drivers/iommu/iommu-pages.h +++ b/drivers/iommu/iommu-pages.h @@ -27,6 +27,7 @@ static inline void __iommu_alloc_account(struct page *pages, int order) const long pgcnt = 1l << order; mod_node_page_state(page_pgdat(pages), NR_IOMMU_PAGES, pgcnt); + mod_lruvec_page_state(pages, NR_SECONDARY_PAGETABLE, pgcnt); } /** @@ -39,6 +40,7 @@ static inline void __iommu_free_account(struct page *pages, int order) const long pgcnt = 1l << order; mod_node_page_state(page_pgdat(pages), NR_IOMMU_PAGES, -pgcnt); + mod_lruvec_page_state(pages, NR_SECONDARY_PAGETABLE, -pgcnt); } /** diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 1a4d0bba3e8b..aaabb385663c 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -199,7 +199,7 @@ enum node_stat_item { NR_KERNEL_SCS_KB, /* measured in KiB */ #endif NR_PAGETABLE, /* used for pagetables */ - NR_SECONDARY_PAGETABLE, /* secondary pagetables, e.g. KVM pagetables */ + NR_SECONDARY_PAGETABLE, /* secondary pagetables, KVM & IOMMU */ #ifdef CONFIG_IOMMU_SUPPORT NR_IOMMU_PAGES, /* # of pages allocated by IOMMU */ #endif From patchwork Tue Nov 28 20:49:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13471797 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 C0D08C4167B for ; Tue, 28 Nov 2023 20:50:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 969F56B0364; Tue, 28 Nov 2023 15:49:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 91B986B0366; Tue, 28 Nov 2023 15:49:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6CF6E6B0367; Tue, 28 Nov 2023 15:49:58 -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 55F066B0364 for ; Tue, 28 Nov 2023 15:49:58 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1F615A0158 for ; Tue, 28 Nov 2023 20:49:58 +0000 (UTC) X-FDA: 81508554876.13.A5A6680 Received: from mail-qv1-f54.google.com (mail-qv1-f54.google.com [209.85.219.54]) by imf27.hostedemail.com (Postfix) with ESMTP id 4E34040021 for ; Tue, 28 Nov 2023 20:49:56 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=l7XNEMto; dmarc=none; spf=pass (imf27.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.54 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701204596; 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=iygGvNb1KE298FiVkmeH8gdBVxeTTuJw4eGKIF/nIuM=; b=8NGnj9gmHCTNsLeFByBjfUubz9XzEsu1ZB4gKDZmh92Ua3/b4gU9FNeoBbnM3fVyEBoEGB ZTnCKPOT2DSyKch/zk8bwv3AgCmQoaO5tofk/3Qx67W7GwEJyi5F1KG4NG2dNltkFttX4w 2EVQJJbwSdtS5GrTjsdHn06EVX5r0Lw= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=l7XNEMto; dmarc=none; spf=pass (imf27.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.54 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701204596; a=rsa-sha256; cv=none; b=1ZAv780IoerXZrD32DtQQce//4oE/zypMufIuYVleDw7nC3sxSC7XcIUWAiUb2DxIDamIJ x8GHh8UD4B4eHi4NcJi7bnp+gGe9zb2lTqyouIbCemWG8++23jVuMGt40fdDNrgpOUNb3V r0E51n3d7Ep020tWfRwb1iumMNvjlZc= Received: by mail-qv1-f54.google.com with SMTP id 6a1803df08f44-67a18556e4aso29143836d6.1 for ; Tue, 28 Nov 2023 12:49:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701204595; x=1701809395; 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=iygGvNb1KE298FiVkmeH8gdBVxeTTuJw4eGKIF/nIuM=; b=l7XNEMtoQPDm9pD/nJGKCQypzcRR1fMzikPb5hcjxbnImVtZenioknAkrGiQcepHH1 kTRjxZ4tD0tXa+vXxTKC79erLwIWJ6d94PysGeuE9Gx0Xiqjjw69Q3RzIa9RwNp2/uS7 sKadvTDRtUYIzmojFCsGJ8Qhi9DLmbCyeizVMHmwy6XmiMssYQLH3dsyxHBnxGXoWxtK QrHZjVr141xYnX2AaPvxaa5z7a2S+84c5JWdF8ulRm/uLBUuwVCvjT8yExjuIYUcuiiX bF7UKgzuIUSWGrFTcaoEI1iLKEFaehSJNHRKPhhDKU5j/y76OLk4V/LCivovEKZjtq1V 1AFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701204595; x=1701809395; 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=iygGvNb1KE298FiVkmeH8gdBVxeTTuJw4eGKIF/nIuM=; b=WOMgqq2uFhgL6QuXeGCroL+SvZ8dveGATu2ZdsPar9e1oTBnJ//w9/svZUkzgNXRtB V0V6fk2q5w1DVdpALyL38MiuQmPaGCIGmxkSvWSu1T6dd6qsOyi/KvSyrcAfgUZKMa5m Lln0Dsk7YkfmdleUDTFU2v/HpgdbncvIkoJ9lwGMvKvD6C561UqSedu8wfoF1+mCtAgQ ghkEFtgWVBoyB09LPADN+x2Ri9Al0b8IrLZc/R1a2+haOgnQ22THWlc1WyGNWcTLtrCi CcwyQqMqwXSHR3o/pF1T31mKV1EDyT8S35I3Iu19YW2/quSgpUGi/Fsfxf/Bv/TKVpj7 MvGg== X-Gm-Message-State: AOJu0Yx3pjMsJ3t9UZ1qW+842DF0R97/7YhdtBTI6mGoRPkORmOLDhvR z4y3Y9hAAh2HgiXa25eqT2ViHw== X-Google-Smtp-Source: AGHT+IE0Jl3QLEggdMt0xv2T8AyvhzkahJgD3VRGmfbhI7sqHJ8Aa/AdHKiYq6E8wbv77IBFZbLYmg== X-Received: by 2002:ad4:5dc6:0:b0:67a:21aa:6513 with SMTP id m6-20020ad45dc6000000b0067a21aa6513mr18119809qvh.17.1701204595440; Tue, 28 Nov 2023 12:49:55 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id d11-20020a0cfe8b000000b0067a56b6adfesm1056863qvs.71.2023.11.28.12.49.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 12:49:54 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alex.williamson@redhat.com, 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, jasowang@redhat.com, jernej.skrabec@gmail.com, jgg@ziepe.ca, jonathanh@nvidia.com, joro@8bytes.org, kevin.tian@intel.com, krzysztof.kozlowski@linaro.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.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, mst@redhat.com, m.szyprowski@samsung.com, netdev@vger.kernel.org, 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, virtualization@lists.linux.dev, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com Subject: [PATCH 15/16] vhost-vdpa: account iommu allocations Date: Tue, 28 Nov 2023 20:49:37 +0000 Message-ID: <20231128204938.1453583-16-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231128204938.1453583-1-pasha.tatashin@soleen.com> References: <20231128204938.1453583-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: 59hoso95bk6rbbb5o43smmh3tpwymx7q X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 4E34040021 X-HE-Tag: 1701204596-66054 X-HE-Meta: U2FsdGVkX186Bh8Oaxp01ssa3gq6jBP/wv1vyJP1NP2w05lt8gITGKLk5zY8YQCy5aTFRhA6+7tfj52OppHiwuQ1epU6RSO+SwrWOlU49w+UP6clpQaUuvY+Oel1pNW5c0qDqjqYINdl41EuUv0uwZ3+WJMRcVSqio+nGDfcH71a9Vq50O/0gzWNH9idl6RIb3HYAxgrJFcapxzf8QUDabBm7hp0GgLpS8N1A+5A7EQHl5GC8TC/djMwk/Y7lGogRw+Brv3uJ6dU4KqYv5ixrj1WXGE0uyBMkks8Rh5BuwOd1Tpil/WAQ2QxaExWeiIZ8xmO6kjr8lskhoSUFPimX1rC3Z/byNhEKzHH+0yoULPfnAs4k6BSKUo8428dKcBDF7BfOmillM75+99ciEN7khb91HcmtiFxH60bBJC1nPPIktRuTmUR5xZUqlVbmC6ygJJ1tLjkykEzv+P8kiFwzGqwHib+XOqp9497C2pwPojroUU29bOYI94Mnwe9py+nH7Xl+TJPEOARhVEmQwBL22g+Eux6DTnigJBuaBzyDNCPLSoi79zPENOKQnx5znd7x8XFu82nCIJZfQcm0PVj26udG5J6IHhpNHdw1g52cvLX4IAJJAOLeBdKmqW2baA4c4dOFIeBE3muiQplxEWVx+Kzddj34OgGMYYCyc+FT37nSSu5BJF5kHh1nK60Uc7Mehjk5WE7J1roFLqiuHQ5H3FpY6AldJiEMadkrdcaR/CZIG16u4uFx9Q0nf+KLqvElo1Qx20kxqvSxat6iVYacbXnH85Jt3G9chBEAnUQYaC4ANOWR7lQy3w9aeU7GQaU3CCoHD+8uACRVOI8zaP9E9VqNx2h4rH2zhW1jVZ3sUc3d7UkQ3TOff8hgl/LhS4cVTPxFtWrVgEuC8gfDmVaLrYXosSHe2RpA3gcumc8Q66wcx7oGlK9zolvWX1dKlPKbyzKR1ZV8JkP9GeS2sw auPtT6UP V2QSsz+SdrNYNQwFUsoMwB2bz325OWhV2QSBC8uXLA8NomXSYcifCp50OUinYi1pVgTUIHBjEiRwsA4i9rs2Rf7awUoyIYn1LPI/YGlPcZSpWswYWMdxK7vBVIovIVWWVYq9YMWhDGVFcW9wGOr4e1kt9BASTfjE1NEcqjqpbMSia9d/muG8iAxUnoLAL3ExbJkjPOVlRND3OniOB2rgT+J9r3o31GlXT3tjXz1CCsVW57raCLwkPvvxCODmXbdDk7CX0uSotWyeqVGcHvm4KlDceUYL66FN0YYQbH/a22QXhlIH+pKzqbc+83V+33MDlSF/thyApLnX2GTqyFOjKNMZhOqNVGNz/4mmdWEtmlBJp1FFP0BZLrZg6BeKT2+GDG0Mg9/CmwSMB+Hs7X+/j2FFLuC61v1qIL1w2MJLGIq44B4riX6JOZOk+jbTtpJ9b47aAfo+mdZbyBYBWEKmr+CCyQw== 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: iommu allocations should be accounted in order to allow admins to monitor and limit the amount of iommu memory. Signed-off-by: Pasha Tatashin Acked-by: Michael S. Tsirkin --- drivers/vhost/vdpa.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index da7ec77cdaff..a51c69c078d9 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -968,7 +968,8 @@ static int vhost_vdpa_map(struct vhost_vdpa *v, struct vhost_iotlb *iotlb, r = ops->set_map(vdpa, asid, iotlb); } else { r = iommu_map(v->domain, iova, pa, size, - perm_to_iommu_flags(perm), GFP_KERNEL); + perm_to_iommu_flags(perm), + GFP_KERNEL_ACCOUNT); } if (r) { vhost_iotlb_del_range(iotlb, iova, iova + size - 1); From patchwork Tue Nov 28 20:49:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13471798 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 C3D77C07E97 for ; Tue, 28 Nov 2023 20:50:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6360F6B0366; Tue, 28 Nov 2023 15:49:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E6436B0367; Tue, 28 Nov 2023 15:49:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 438FC6B0368; Tue, 28 Nov 2023 15:49:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 304866B0366 for ; Tue, 28 Nov 2023 15:49:59 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 0B171403B9 for ; Tue, 28 Nov 2023 20:49:59 +0000 (UTC) X-FDA: 81508554918.02.9BDCBEC Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) by imf13.hostedemail.com (Postfix) with ESMTP id 4917920024 for ; Tue, 28 Nov 2023 20:49:57 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=MIEkkt7x; spf=pass (imf13.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.53 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701204597; a=rsa-sha256; cv=none; b=Kmwk44AMP0dZBO9K7/NDkLAiQBAdBaBm1SyL3rnTr9BoWYxW67rhAThZOC8wCURZRbmTyn EhCdtOcyfgNdA56JRVNTRXrwvE0f8mKseVEtOTKA8hc4CJdgJL8eeHHz4ylk42ag8cZ3nV N9clAhrWPeEEnbNfOAU4Ww7616LmZ6Y= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=MIEkkt7x; spf=pass (imf13.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.53 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701204597; 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=YSGX0jW3To7/xuABL7QXXsr1KCFhu7Z9tThr0mLMrMc=; b=RPtO7ND7//Qgay71+4T24Vnwirl4uA87QPK8iGElWCf3huhJrQJHo/P5kttpCHoNPmO+Jl uLpQ/XBrAG+X0Ssc/8uRyGyF4wCYQOHx+0fX8igpP+Ro3LUfPR7Tr3JFS/sf5qZR/5a1zS pR7Ga2pgqrSxzr8M5SbDtJGB5Zd8cM4= Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-67a35b68c34so18752466d6.3 for ; Tue, 28 Nov 2023 12:49:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701204596; x=1701809396; 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=YSGX0jW3To7/xuABL7QXXsr1KCFhu7Z9tThr0mLMrMc=; b=MIEkkt7xOjvBDE4lorEGMG6oicUw34E+BSY+NrpZX57VgatEHEDLehItwBu101ZqX3 QCsG8r6z7DuP3RIsCHrXblxdqzde4GUZJL2FRiCimoIwhmXZJDmtnM4L00vUleEHIXCi Z9YT9bb2KkV7LYrYnJdagV634WFLEXDEdX1sKf5ghQmn0uBqhb1chtsIz6UNxv9GLI5Z arvxYLVhWEvYEVH83ePu/roZaOg1uooTggipGJrBgPZPTUQSL/rhoykTywY6x8BfXwzj F7Fv4oVL7n5Nzf8FV5C5tQa/WtiKIUkUyM+tGQD/tly0hyq4T/rA7XUMrYHK6yX2Dd2z OsSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701204596; x=1701809396; 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=YSGX0jW3To7/xuABL7QXXsr1KCFhu7Z9tThr0mLMrMc=; b=daAj6vYrPfE7A+gFy1j5Wlsrv2phKtidnPeQv0GE5h6oZ3sXCtjeTbZwyBMaHqe3x/ DhsmihzaLWl0XoJhCsvLZuYxcbGRlqixFbhSafMvHf36dqym2r7IJokipumFyDHsYwka dENR1Xnz7duw3AN7+MNSyApwRjVweEr+f3b0OxGjADriMnl6bnEdukQ+b+vJdDCyL6Bt xRZCZKTb5Pf5240CAfgMY7g2PA0Nd8OvSoMI063E64/M7+3MI57Fig0KBTdDAoMJkxq0 D7ivbfVb166jN8KiZO5B1XjsiFOA4GZje1mfILnEAa8VuQm9X2QtiYXkII3vGjDiRNyq tX9A== X-Gm-Message-State: AOJu0YzCMHRAa1nSywAtMNzSdUzC5MAcezwuWtzbgKcFrlRSdUJdLRV4 UGfW+1zUyXvFvB8y6Z+nTbIPOA== X-Google-Smtp-Source: AGHT+IH3XyzLx3HqaxxWdryJd33MqMJHkx6z6Xt3swBEGkMdx9JQSLka9GW0WH1FkTVqo27TzFUimQ== X-Received: by 2002:a05:6214:246f:b0:67a:4ba1:84d5 with SMTP id im15-20020a056214246f00b0067a4ba184d5mr7928400qvb.16.1701204596396; Tue, 28 Nov 2023 12:49:56 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id d11-20020a0cfe8b000000b0067a56b6adfesm1056863qvs.71.2023.11.28.12.49.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 12:49:56 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alex.williamson@redhat.com, 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, jasowang@redhat.com, jernej.skrabec@gmail.com, jgg@ziepe.ca, jonathanh@nvidia.com, joro@8bytes.org, kevin.tian@intel.com, krzysztof.kozlowski@linaro.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.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, mst@redhat.com, m.szyprowski@samsung.com, netdev@vger.kernel.org, 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, virtualization@lists.linux.dev, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com Subject: [PATCH 16/16] vfio: account iommu allocations Date: Tue, 28 Nov 2023 20:49:38 +0000 Message-ID: <20231128204938.1453583-17-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231128204938.1453583-1-pasha.tatashin@soleen.com> References: <20231128204938.1453583-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 4917920024 X-Stat-Signature: rs3bqait9f53o5i8gh6supyameocq67n X-Rspam-User: X-HE-Tag: 1701204597-489471 X-HE-Meta: U2FsdGVkX18qjhfPLYewTaxuQ1Vq0t3ko0TssOxTOF6rzSfL6K1GkXBITHrDNfehOoH4nAO4X3CzbP7TFY0VCQx8/ub9NzjxOyK5GyQW37jXSXqJGwXZhgmsXp9l4W4xTGm6Yu05w4R5sueFKa02E7fNceVAdDCcBFW/flWYSe/ynfaN4jGWHTHSOCPnsIJ5f0t+hhLbQkufTkDXuraZANP+aAbnC4p8hkm5msV/oGKhzSY5UMnaV9UJ7IY0iKgutTQgRyfP0BCn1TOAgSlu2gyN9W10Djixuvl2AwfQiYVX/pVKBSLWNuGtKSPHdmRm/ZnCxMeKCcm87Y2lrugl5ttnnnzU1THYS28vADGCl/x7LTxMXrYONdPvCeHSx0u8TvKTwwHRbcBAjv2iLJpBVpMdglyCpXhCUI7PlYGz+akHL8hOe05IGTf8MqeqlFeuEC6WpL/dV4S78OT0S/0s0kVA3dYe68cu3WcdwQ88P3tjmwBN4Wd93cV9poKcacZkkKBilQ4abJYLWR9H271MyTSKjWAX0/4SKCoPGNIBFKK1gcOGH/Fc76ImB2p7kDYJfMdwrSABthXWj5tGbhGoazdAu27Vu1ZXR14CgPgaAMfJWW3x08xU1A4W826ittOjDqZ1/xqhAqOND8gQ/NGC5PQk8RGsqn2GYZrf7KLV8FuW5DA2VVg54Xh6uOWKR4qtaycjJbab5SJ8/HFAGjHR7UguB5W8z+Jmf99+65j9DBJYxCHcADjA5C1mvGRzV5RKG5F35wBKxoZ1/wtk+GRPUnhGSh3PMLxgGjAEEiIMqgxj2yAeE3CxBpaZEBThI0tVqaLfs2e68dY5Lg2Ua6AUKHH+RQb5M7pGxYR7GQvZTx2Mrd2lqhdOPRRCKxr8HN2waw6QfuxIco8VEme/uek0dcJ2I/ESk8Orv0zxT5H9fyMDT+wZ/AUVvpSpjn0Hlc3aVk70G49r2MLveUU0lvE Bx78GbY5 HsJiyeznPYQdg0tT0jmmsAGRDJa5k/CL23nQJ5vvJgjc5bI5dqbLJpMgeB1jkjexmFbTOxxSj/e4CTUdn2MwY32pkYYl0KC/Rwy1jnsPVw4An92LThpAOXQb3xkMOSLWlJ/arYjcSEGqtHIaZVUO+1rbHUXd8YAKJy4NSuJjPOFYiHYxMm7whnVGYWL5lJC7bKzvyJyAPJBpp5uFn3a7bZtKkmnQOGoBol8NICjstANV/feKL1oBT5XGfDJdmmUCQvj9YKS6Z6T4q02hTbMPAZL+2WTBmJ7dDjaOjMNVqWNB8pkxz5TwqjNBr8mtEAteL2FWpBeIOGEruTWPmr6PxIbBKKMcS9Yjam9L7APeKbXORT72n3Bnyv/ObEY2lyNjUh0WPVQEjpa9yklr6X423LN4VGYU3lr4qhMB0N5msLr8BXPJ6EAWOp2m2Er8pgQL/FdZ+ 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: iommu allocations should be accounted in order to allow admins to monitor and limit the amount of iommu memory. Signed-off-by: Pasha Tatashin --- drivers/vfio/vfio_iommu_type1.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index eacd6ec04de5..b2854d7939ce 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -1436,7 +1436,7 @@ static int vfio_iommu_map(struct vfio_iommu *iommu, dma_addr_t iova, list_for_each_entry(d, &iommu->domain_list, next) { ret = iommu_map(d->domain, iova, (phys_addr_t)pfn << PAGE_SHIFT, npage << PAGE_SHIFT, prot | IOMMU_CACHE, - GFP_KERNEL); + GFP_KERNEL_ACCOUNT); if (ret) goto unwind; @@ -1750,7 +1750,8 @@ static int vfio_iommu_replay(struct vfio_iommu *iommu, } ret = iommu_map(domain->domain, iova, phys, size, - dma->prot | IOMMU_CACHE, GFP_KERNEL); + dma->prot | IOMMU_CACHE, + GFP_KERNEL_ACCOUNT); if (ret) { if (!dma->iommu_mapped) { vfio_unpin_pages_remote(dma, iova, @@ -1845,7 +1846,8 @@ static void vfio_test_domain_fgsp(struct vfio_domain *domain, struct list_head * continue; ret = iommu_map(domain->domain, start, page_to_phys(pages), PAGE_SIZE * 2, - IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE, GFP_KERNEL); + IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE, + GFP_KERNEL_ACCOUNT); if (!ret) { size_t unmapped = iommu_unmap(domain->domain, start, PAGE_SIZE);