From patchwork Tue Dec 26 20:01:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13505027 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 54C11C4706F for ; Tue, 26 Dec 2023 20:02:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9714A6B0071; Tue, 26 Dec 2023 15:02:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8F97A6B0074; Tue, 26 Dec 2023 15:02:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B3606B007B; Tue, 26 Dec 2023 15:02:12 -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 42A606B0071 for ; Tue, 26 Dec 2023 15:02:12 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 04F72C04D5 for ; Tue, 26 Dec 2023 20:02:11 +0000 (UTC) X-FDA: 81610040904.25.56996C5 Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) by imf02.hostedemail.com (Postfix) with ESMTP id 1664A80010 for ; Tue, 26 Dec 2023 20:02:09 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=IHt4Khdi; spf=pass (imf02.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.45 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703620930; a=rsa-sha256; cv=none; b=baG+XZLVYciIpSEjASAJ1AfmKEQJn8LxXkQ22zJogYI4otDjeCoWiNSyKgRUv4O8J4GoP4 CvBaUqpVbXlbrIwgiQAMTxo3/6yyxxKCw7Li1JudWCLDYaQvrMh3O44CM9OLZNUAcRALoS cjhl5mhgNyqTjpkP42XNatX10Zl+wAY= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=IHt4Khdi; spf=pass (imf02.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.45 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703620930; 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=JrgxBJJnUtul2cVGK+LwAz1M+T2/gmkmQ5y2nUTXV7A=; b=uWGyKmQVsE0zxExzGdmuXUDGLo9LMFlT84wiq5nAcNKajZmgM643DfLZpTkBvkZQOJVdS7 5Cwx+ocjDE7hGR3SBXTNqPqczBr/E4B30RjUTOgkJ3tB33+QEWFc1X8VTWqgh6ntRP5PSA U4FknWmHhrArpZd/eYR7l3QsQCTKfh4= Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-67fe0210665so16404976d6.1 for ; Tue, 26 Dec 2023 12:02:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1703620929; x=1704225729; 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=JrgxBJJnUtul2cVGK+LwAz1M+T2/gmkmQ5y2nUTXV7A=; b=IHt4Khdia2OmnNDUQHNAcWGl2op3Kf8Dgw/OGVUL77GaW25qT5tjauyHZ9zUsivo8P HwxKyZsaiDInKIWGdYxG5QeqxhO/c78cGMD3Q4efw2xgdq1RpQjQ8Fa1io1N99zq9t/j w1nUehrU3DmRcYeFLkWy/9PXe1Bvn0tUmJs+48vbAgEB+o1elswrpUUJPlIAaOzARIzw aXw2ylP+Mg5Q528K3e33+9g8HgbV6PFrKEMQrIsyWyUOqhpEtREZuLgthZMFcAGWrgzg 0P0MwKNNIZmrkPDV7gXgpJi4SqjCHGEboVn0A34kcap7V+OA2JmWCoL9Ikdgs2jXWfff ztXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703620929; x=1704225729; 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=JrgxBJJnUtul2cVGK+LwAz1M+T2/gmkmQ5y2nUTXV7A=; b=pEXhKMGPL0D5X2Ld9lbMe0K6hDZDEWg8/eZtG/MQTx3L1BphVynLWN9/GspQp9Jazc TAeOuF9WdjXxEjFfB4OFGMTb57Vvjr+dWIeZc8TJ7qJvOze1uXhSrerWt9pB1jC2F4q8 oPhBhVuHyzqwWw5l2hJNOumO3myC1USljYRGvX+AZyyts3NY1c1ZyZcDjSUryvYfl4hk 72zQ6QaS7zzzttTu3ZGb4plMCw2I3nit+wa/Fc95z8TAlVLN/KCJwQsEQiU9XG69dJ+t fY2sE2Defu0Yr3Ncsw3k1BEooHDV5uXPgTRqqRVsG8iqHV7RumuZq5VjjU1Brlz4618E v1HA== X-Gm-Message-State: AOJu0YzPFaXqhiYXWZ+4NxcrQU0dGU3zcKRaC8Oy1ygAhao2zw2RCIxd d/WGELqe5C4vH5lwk+tonEhjeQRTAyWukQ== X-Google-Smtp-Source: AGHT+IHu+hz5hjZkOjtuugcvM9g0ro43MdzPJSM3RLwP6wrMyMOdUctTt4PeczEJLjFNtTFkqbfPDg== X-Received: by 2002:a05:6214:f62:b0:67a:db18:10e2 with SMTP id iy2-20020a0562140f6200b0067adb1810e2mr13115303qvb.37.1703620929161; Tue, 26 Dec 2023 12:02:09 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id t5-20020a0cf985000000b0067f696f412esm4894539qvn.112.2023.12.26.12.02.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 12:02:08 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, pasha.tatashin@soleen.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com, rientjes@google.com Subject: [PATCH v3 01/10] iommu/vt-d: add wrapper functions for page allocations Date: Tue, 26 Dec 2023 20:01:56 +0000 Message-ID: <20231226200205.562565-2-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231226200205.562565-1-pasha.tatashin@soleen.com> References: <20231226200205.562565-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 1664A80010 X-Stat-Signature: uajm73gxj8isbfh4kfk3bggxrj8d8rqa X-Rspam-User: X-HE-Tag: 1703620929-615738 X-HE-Meta: U2FsdGVkX18DZc9J93S8kaZWKWCTH8EFENMvBRMV0hHjkBNrKV8F49xmj6droGkXt5bbiOfQl4t0+9D/tb98gCiSN2t593kUQtnui8FFZSBVUUEMGaYKBf9naHEm9mERWGKcJUeAGo633HuXwktMud4z3drpvfdjVlhSIux7Ctch9OzlfWkDqpxusQp8ZqF99caGrf4AFEwhFHvqTiAdfWlErF+59ltGULz8gs+ODPdgQbWr9fbRX9BGIeA/C2ERKRrsf6nV0fcI2FwzNJB3YWwPS3/4vLqDtXhjw9HmDG7Irn7QE4o/9EncnuSZuxYGughRe7Po1cxfkz6FiwHgTFT+CRSHuv+0FTdzlX6Ihnw1p9d1LYOStqqIBGwM3bQdicbsQXcpo6+qdLyLnnDBICWQZFYrvjm7WjQHpbwqhmMHKNuxZYH6Idl3k0DiJjmfu0KuHn9RpyinsvZtC8QViZkal4cac6vURKm2fMStoyLqKHz0xBNn8clKNhR4wMh2eDFbNgRf935VLf0mDKet/V7RolojmTAd3g7YatZ8vgscgS+kKOEFUpuo/wnTe9CLysRJWwHS14K0+xFuFGU7lL8SJEP8u9J8jyA9drH0gAb18Rjramh14e0UIP1AIa8KGZJVu4kzm4OekSHhN1G/LZD0CYk9oSdoK/bCntsCDb8kuVlCEAw/TdzVn0V4eIRbi9plrrBrDV12e+Tt9bcs0OK785c/zHmZYDuLsW66JkAD9I2k3OkoH6dYjAJmSUWx67cUKRPCTf2McrxO+armQLoim0o4VmLfyvmo6ppUQ+MttOXSeCJvkR7A6wVPrbMbeeIDBODzCgeSzR8qrdhf/dlFalyTgFQmhwCg3c7pqTEH1bvrMTruYe7HWZv3Urj+UF7Ng7zEnXF/bZmqKsaAFevFpmhqyn5NoMKdbj4zt7POQLRxJUhFGohIk/Yyzly7Tb1nLbXUqIJ37zJVf4c ejxXTqr7 C5MzqmSj5Q/iqHIsu8E0Ajx15bpxiVsFGG0mGO4fHENwwku44x2YLMFaq8ZG/gX8xRamv1TPNh7cbBWid9lDCJOLi53lq33Ju9zPm0QJIEZdcMCBnhzsoFR+wn6VEt8rrg6nfsp/KdJWDUkF+3owiRpC71BrP+oXLNredO0/7ptyIMUS6hKnPSoMDFvX+zc86SX5TMvyZ/QflgNJEA5zwKcWHZorqI4mjPaBi+IhcRwLF2VRomXopRQPGHO0GfBivjD6JT8jzcdzJL8l4jpaUW70rSCxFeC/qVGYi3HlpfuJXDSehdUR6TtUqnYTQe9efFVrVFg+VgUAbFANXmK7ujEMAnjkba08JI2Cfx7vaCAAZyGn7CvSfYvzj6mDYJbjLw4sh7oWvx3gmlyS+3cxQUKNvLVCzpYm7OYLbshdsYsl2IpVHPuoyaPgUKjcD+YjZSzxz X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: In order to improve observability and accountability of IOMMU layer, we must account the number of pages that are allocated by functions that are calling directly into buddy allocator. This is achieved by first wrapping the allocation related functions into a separate inline functions in new file: drivers/iommu/iommu-pages.h Convert all page allocation calls under iommu/intel to use these new functions. Signed-off-by: Pasha Tatashin Acked-by: David Rientjes --- 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 | 204 ++++++++++++++++++++++++++++ 7 files changed, 241 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 23cb80d62a9a..f72b1e4334b1 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); } @@ -1732,6 +1733,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; @@ -1752,8 +1754,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; @@ -1764,7 +1766,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 897159dba47d..4ae52569ab4a 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))) @@ -2640,7 +2625,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; @@ -3573,7 +3558,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; } @@ -4004,7 +3989,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); @@ -4151,7 +4136,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--; } @@ -4298,7 +4283,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 ce030c5b5772..453e5d84f6a6 100644 --- a/drivers/iommu/intel/iommu.h +++ b/drivers/iommu/intel/iommu.h @@ -897,8 +897,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 ac12f76c1212..e97f68427b54 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..99105503b771 --- /dev/null +++ b/drivers/iommu/iommu-pages.h @@ -0,0 +1,204 @@ +/* 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 *page; + + page = alloc_pages_node(nid, gfp | __GFP_ZERO, order); + if (unlikely(!page)) + return NULL; + + return page; +} + +/** + * __iommu_alloc_pages - allocate a zeroed page of a given order. + * @gfp: buddy allocator flags + * @order: page order + * + * returns the head struct page of the allocated page. + */ +static inline struct page *__iommu_alloc_pages(gfp_t gfp, int order) +{ + struct page *page; + + page = alloc_pages(gfp | __GFP_ZERO, order); + if (unlikely(!page)) + return NULL; + + return page; +} + +/** + * __iommu_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 + * @page: head struct page of the page + * @order: page order + */ +static inline void __iommu_free_pages(struct page *page, int order) +{ + if (!page) + return; + + __free_pages(page, order); +} + +/** + * __iommu_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 *page = __iommu_alloc_pages_node(nid, gfp, order); + + if (unlikely(!page)) + return NULL; + + return page_address(page); +} + +/** + * iommu_alloc_pages - allocate a zeroed page of a given order + * @gfp: buddy allocator flags + * @order: page order + * + * returns the virtual address of the allocated page + */ +static inline void *iommu_alloc_pages(gfp_t gfp, int order) +{ + struct page *page = __iommu_alloc_pages(gfp, order); + + if (unlikely(!page)) + return NULL; + + return page_address(page); +} + +/** + * iommu_alloc_page_node - allocate a zeroed page at specific NUMA node. + * @nid: memory NUMA node id + * @gfp: buddy allocator flags + * + * returns the virtual address of the allocated page + */ +static inline void *iommu_alloc_page_node(int nid, gfp_t gfp) +{ + return iommu_alloc_pages_node(nid, gfp, 0); +} + +/** + * iommu_alloc_page - allocate a zeroed page + * @gfp: buddy allocator flags + * + * returns the virtual address of the allocated page + */ +static inline void *iommu_alloc_page(gfp_t gfp) +{ + return iommu_alloc_pages(gfp, 0); +} + +/** + * iommu_free_pages - free page of a given order + * @virt: virtual address of the page to be freed. + * @order: page order + */ +static inline void iommu_free_pages(void *virt, int order) +{ + if (!virt) + return; + + __iommu_free_pages(virt_to_page(virt), order); +} + +/** + * iommu_free_page - free page + * @virt: virtual address of the page to be freed. + */ +static inline void iommu_free_page(void *virt) +{ + iommu_free_pages(virt, 0); +} + +/** + * iommu_free_pages_list - free a list of pages. + * @page: the head of the lru list to be freed. + * + * There are no locking requirement for these pages, as they are going to be + * put on a free list as soon as refcount reaches 0. Pages are put on this LRU + * list once they are removed from the IOMMU page tables. However, they can + * still be access through debugfs. + */ +static inline void iommu_free_pages_list(struct list_head *page) +{ + while (!list_empty(page)) { + struct page *p = list_entry(page->prev, struct page, lru); + + list_del(&p->lru); + put_page(p); + } +} + +#endif /* __IOMMU_PAGES_H */ From patchwork Tue Dec 26 20:01:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13505028 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 4FA8BC46CD3 for ; Tue, 26 Dec 2023 20:02:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B1E0F6B0074; Tue, 26 Dec 2023 15:02:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AA84F6B0075; Tue, 26 Dec 2023 15:02:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 837AF6B007B; Tue, 26 Dec 2023 15:02:13 -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 61B536B0074 for ; Tue, 26 Dec 2023 15:02:13 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id DD7CA1605A6 for ; Tue, 26 Dec 2023 20:02:12 +0000 (UTC) X-FDA: 81610040904.14.B717685 Received: from mail-qv1-f52.google.com (mail-qv1-f52.google.com [209.85.219.52]) by imf16.hostedemail.com (Postfix) with ESMTP id 07FD9180015 for ; Tue, 26 Dec 2023 20:02:10 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b="b/1Xrhg5"; dmarc=none; spf=pass (imf16.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.52 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=1703620931; 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=fw1r14mYd/eh7ZKj+/jN30p/HYowmCojeYXfDLguFk8=; b=gZsT2QGDc3UjIX4VCCwXDKnxUPW29Qgx4vRSVPLq8TmEnFc0X2KJdkVrZdiAHzUkqfWDwb dk4HWZODUysTiGFjQ2FVh9GGWsERuh0PI5Fi0mnGYmLg9gwurntDMRDXNUSvUlcO8nTkX4 8B5yvjidm5cq6sR4Mrr/EAucS/U1oKM= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b="b/1Xrhg5"; dmarc=none; spf=pass (imf16.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.52 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703620931; a=rsa-sha256; cv=none; b=eMo/XLIHwThdDpOBT8+gzFop1Zjwr1tI/cuxYa0pAbVV7qPvFTfwHtqjkzZa7SBfAeLG80 zeOjTxS9CIz0NaBKcpkiMwaUA4p8O0MYJzgFRHMuU+r03+RXfNNLRI3dEbqipPLiEqqQix vV9ChQIu0ohN0EKBoVBVfQ90Bk2fG+k= Received: by mail-qv1-f52.google.com with SMTP id 6a1803df08f44-680285e7ce8so9403276d6.0 for ; Tue, 26 Dec 2023 12:02:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1703620930; x=1704225730; 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=fw1r14mYd/eh7ZKj+/jN30p/HYowmCojeYXfDLguFk8=; b=b/1Xrhg5W4HLJpB8PyoCHZwmITiSR6svYuLAuI2Hfyvzh89+ZOck2mtlsbLhBLXy3Z CsjMEFzsfyWd2fn3cZc9GaV2V7hC+LtQv0T8NT9eH6XyI9bgEs5Jo1eXYnTxnP2Fbu1m pDHZqUavfkuFumrvoye1pJLui5bJZwcMDzjbZKmu3SJSP6e+TQydSoj8S969WAWcxTDE Ps8qH3Erp1u3r77QpZ7EDnxJtHfgH+i82l3PUzi2WK2G5aeeqpWjGFLCirS+l3p6rrjS ghd3MwgdPrmouyimnOLkMmGc1E70l1El0VehJhvrQ1a+fjuWP8NVSaEDUOkpV4NNotUc ZOzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703620930; x=1704225730; 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=fw1r14mYd/eh7ZKj+/jN30p/HYowmCojeYXfDLguFk8=; b=Dw7OyKQVfVHIfrNJyt2b6fdFafnYOmBDZidtKNZzQBip06Hh/+PK2NC3/h+P9JlMQs ScxyC7Z5zyyUxXGW1YGzIRtKr1bM5uKdgpRAYH3t2Ik7NMQ0Z3X/2QBzEbryoq0syWkA L+3l7oY6XGxD5W65P9iX+e4msew0dl/R8NvcOygatNjHI4aPYCv787bEMcwhE3nC/BzA xfYC4bMqJigZR7TangsZoyi7H4iwZrKBgTvWQcdH3H5LZLeRNzg9dGErhHpxAIzcq7br KUPeycUAFTwH7FivvKuWcnEBcu/VeuqGZ5N7sChtE4zVFHcZmqAz8mHaNvsqefaMGpxZ v3YA== X-Gm-Message-State: AOJu0YwUA/O8kP74nnBEh/Y0T3D0nhl5dx2ro9SgfO66CDZu5S7cxUfE K0XXRBLqzZ9RsbyxZb8rPBK3wBmkV4NnrA== X-Google-Smtp-Source: AGHT+IGJeiDIJ6fnNS4YMbib8jx0koBbx8pwPib/wY3O12z4NHSpxaNNOfqEN0BRD/BFxXkXFxJLJg== X-Received: by 2002:a05:6214:4c01:b0:67f:bd1a:a11f with SMTP id qh1-20020a0562144c0100b0067fbd1aa11fmr6157088qvb.117.1703620930216; Tue, 26 Dec 2023 12:02:10 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id t5-20020a0cf985000000b0067f696f412esm4894539qvn.112.2023.12.26.12.02.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 12:02:09 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, pasha.tatashin@soleen.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com, rientjes@google.com Subject: [PATCH v3 02/10] iommu/amd: use page allocation function provided by iommu-pages.h Date: Tue, 26 Dec 2023 20:01:57 +0000 Message-ID: <20231226200205.562565-3-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231226200205.562565-1-pasha.tatashin@soleen.com> References: <20231226200205.562565-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 07FD9180015 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: ecpae3btjbyowx8nwhsab7r8b5b6u7qx X-HE-Tag: 1703620930-699612 X-HE-Meta: U2FsdGVkX18hF2fjZ/sUh0mcoq04KzBtiImetGyL31LBVCxzUOmnbecZOUILEKcPA7eLm3fQgx7WCRzztfBeABvYd/K2LBbJgufm2qopO0QcVNjS7S/KxF9sYCPtOLY5MjZFWu1cr4SWdh7tS6sxsw9Bq42PXh3L4wVt+GvTNf4nhJ6P1I0DPqneeHiCp7LHH/q5tBVzdDgLYtXg18+vn+jX1weBZFVdhXQlxOrolgBlV36tuNHoY31veM1wO9gVI9BiZeeeHIWRN6/ukTlwjFchRVtQElQuAqumob5HkUGsNrv8ui0vZULDVEDi1+KNty0+Lhq2m7ySXgGlNsa3VtQ4VdNQJzq7EgZAaOH4ahAAgL0VYZHZfy4oQcJm6+eYaTZ6UwNrFh+5kOc82PXTg/i4sSkA7hGr/Jnc545P4D8M8Vkqh3RNcE8C+oVPxJmDcNolEjKn6PnctM4QF4ZBXu0idG4B3A7c9ThOyBJCkEH6Rky7e5gfvfYD33DoWBB9pRP2zrsWQiKOLAShbpl+fjkldsGnujWSdw63eIRxjI/qOzcRFa0qpubKP8ywCxITEsc7X0zjfISYr0Vda2Qtfcyeo9XwwiGW2fwPH0eCG6JyVWk62oxoLAKy+uzZj4v8mAHPN/yHG2A8Wj4+MEpYrsDrNNuYcGyuf6fc5BLyuWh7EPMbIqnxAs2sP5LMWXoZzZ9Yqp5CvItNU/SpIobz8fFV0OaNq0XXfljDWyCx53LrFjLExZ1noquLo6f3YSp8jPkHTWLZp7nOd7QZcb6FKsY1pOQMBSseXwSzh6Xir7n79c34QJYyx2moUDGSV4DfldGxTuMAYcOL36iNDgSnFnRMbEsCBcyE63pCMeKdFCC/ecGEr848zD4jdsTHlbufP+doOCUAHaLmybha5cnGHP6lT5mjgag45d1+fqtFjc96Lxb0r9/gAuko8fW141MBnTlJcDUBMQHnjBnrVxe RQQ0OdZX rsrkTe50lteJ/GnWFjQdQugP4G9P/LTT5SntoBq01eGcLqso96SPWyq9ACb8gsl2HERJJr/lMoyGsBJSe2KunEJ8usnGDoEG3rEM76hTaQbcKvHwJgp0noaI2vSBkDxfmE7SylPX1Srnk60DFSjouCz7rVpNO7tgjZPVEsBUuV54v+OEGg90gopC3naYzpD7HCINkXSShTCSZBWNuK2lAb61JLQkU7kk9yYzLp7gxvAfepX6bUkP9mOu9dJ42mhpvX5huXpn73Y4UtBxHtaAQhpmtQ9ugMCubDPAzreinlCbJoBUFJOuIm7X06R8wHBtn/xkGfDIvsgXi/MqE9dOElExdCTOqgXOgIxtXR7Jl8yjRuiCtJrS8QfzxDzG0w02lxJPkTY7Yn1kubvB04zbViW8jnq/6KmXTalpDuHcOgA34vKjCaPzF6857G+sGfHVNVu1z8+U9Y3GO5JTlPIYgHQD0iQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Convert iommu/amd/* files to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin Acked-by: David Rientjes --- drivers/iommu/amd/amd_iommu.h | 8 --- drivers/iommu/amd/init.c | 91 ++++++++++++++----------------- drivers/iommu/amd/io_pgtable.c | 13 +++-- drivers/iommu/amd/io_pgtable_v2.c | 20 +++---- drivers/iommu/amd/iommu.c | 13 +++-- 5 files changed, 64 insertions(+), 81 deletions(-) diff --git a/drivers/iommu/amd/amd_iommu.h b/drivers/iommu/amd/amd_iommu.h index 86be1edd50ee..bf697d566e0b 100644 --- a/drivers/iommu/amd/amd_iommu.h +++ b/drivers/iommu/amd/amd_iommu.h @@ -136,14 +136,6 @@ static inline int get_pci_sbdf_id(struct pci_dev *pdev) return PCI_SEG_DEVID_TO_SBDF(seg, devid); } -static inline void *alloc_pgtable_page(int nid, gfp_t gfp) -{ - struct page *page; - - page = alloc_pages_node(nid, gfp | __GFP_ZERO, 0); - return page ? page_address(page) : NULL; -} - bool translation_pre_enabled(struct amd_iommu *iommu); bool amd_iommu_is_attach_deferred(struct device *dev); int __init add_special_device(u8 type, u8 id, u32 *devid, bool cmd_line); diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c index 64bcf3df37ee..5b8a80fc7e50 100644 --- a/drivers/iommu/amd/init.c +++ b/drivers/iommu/amd/init.c @@ -35,6 +35,7 @@ #include "amd_iommu.h" #include "../irq_remapping.h" +#include "../iommu-pages.h" /* * definitions for the ACPI scanning code @@ -648,8 +649,8 @@ static int __init find_last_devid_acpi(struct acpi_table_header *table, u16 pci_ /* Allocate per PCI segment device table */ static inline int __init alloc_dev_table(struct amd_iommu_pci_seg *pci_seg) { - pci_seg->dev_table = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO | GFP_DMA32, - get_order(pci_seg->dev_table_size)); + pci_seg->dev_table = iommu_alloc_pages(GFP_KERNEL | GFP_DMA32, + get_order(pci_seg->dev_table_size)); if (!pci_seg->dev_table) return -ENOMEM; @@ -658,17 +659,16 @@ static inline int __init alloc_dev_table(struct amd_iommu_pci_seg *pci_seg) static inline void free_dev_table(struct amd_iommu_pci_seg *pci_seg) { - free_pages((unsigned long)pci_seg->dev_table, - get_order(pci_seg->dev_table_size)); + iommu_free_pages(pci_seg->dev_table, + get_order(pci_seg->dev_table_size)); pci_seg->dev_table = NULL; } /* Allocate per PCI segment IOMMU rlookup table. */ static inline int __init alloc_rlookup_table(struct amd_iommu_pci_seg *pci_seg) { - pci_seg->rlookup_table = (void *)__get_free_pages( - GFP_KERNEL | __GFP_ZERO, - get_order(pci_seg->rlookup_table_size)); + pci_seg->rlookup_table = iommu_alloc_pages(GFP_KERNEL, + get_order(pci_seg->rlookup_table_size)); if (pci_seg->rlookup_table == NULL) return -ENOMEM; @@ -677,16 +677,15 @@ static inline int __init alloc_rlookup_table(struct amd_iommu_pci_seg *pci_seg) static inline void free_rlookup_table(struct amd_iommu_pci_seg *pci_seg) { - free_pages((unsigned long)pci_seg->rlookup_table, - get_order(pci_seg->rlookup_table_size)); + iommu_free_pages(pci_seg->rlookup_table, + get_order(pci_seg->rlookup_table_size)); pci_seg->rlookup_table = NULL; } static inline int __init alloc_irq_lookup_table(struct amd_iommu_pci_seg *pci_seg) { - pci_seg->irq_lookup_table = (void *)__get_free_pages( - GFP_KERNEL | __GFP_ZERO, - get_order(pci_seg->rlookup_table_size)); + pci_seg->irq_lookup_table = iommu_alloc_pages(GFP_KERNEL, + get_order(pci_seg->rlookup_table_size)); kmemleak_alloc(pci_seg->irq_lookup_table, pci_seg->rlookup_table_size, 1, GFP_KERNEL); if (pci_seg->irq_lookup_table == NULL) @@ -698,8 +697,8 @@ static inline int __init alloc_irq_lookup_table(struct amd_iommu_pci_seg *pci_se static inline void free_irq_lookup_table(struct amd_iommu_pci_seg *pci_seg) { kmemleak_free(pci_seg->irq_lookup_table); - free_pages((unsigned long)pci_seg->irq_lookup_table, - get_order(pci_seg->rlookup_table_size)); + iommu_free_pages(pci_seg->irq_lookup_table, + get_order(pci_seg->rlookup_table_size)); pci_seg->irq_lookup_table = NULL; } @@ -707,8 +706,8 @@ static int __init alloc_alias_table(struct amd_iommu_pci_seg *pci_seg) { int i; - pci_seg->alias_table = (void *)__get_free_pages(GFP_KERNEL, - get_order(pci_seg->alias_table_size)); + pci_seg->alias_table = iommu_alloc_pages(GFP_KERNEL, + get_order(pci_seg->alias_table_size)); if (!pci_seg->alias_table) return -ENOMEM; @@ -723,8 +722,8 @@ static int __init alloc_alias_table(struct amd_iommu_pci_seg *pci_seg) static void __init free_alias_table(struct amd_iommu_pci_seg *pci_seg) { - free_pages((unsigned long)pci_seg->alias_table, - get_order(pci_seg->alias_table_size)); + iommu_free_pages(pci_seg->alias_table, + get_order(pci_seg->alias_table_size)); pci_seg->alias_table = NULL; } @@ -735,8 +734,8 @@ static void __init free_alias_table(struct amd_iommu_pci_seg *pci_seg) */ static int __init alloc_command_buffer(struct amd_iommu *iommu) { - iommu->cmd_buf = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, - get_order(CMD_BUFFER_SIZE)); + iommu->cmd_buf = iommu_alloc_pages(GFP_KERNEL, + get_order(CMD_BUFFER_SIZE)); return iommu->cmd_buf ? 0 : -ENOMEM; } @@ -844,19 +843,19 @@ static void iommu_disable_command_buffer(struct amd_iommu *iommu) static void __init free_command_buffer(struct amd_iommu *iommu) { - free_pages((unsigned long)iommu->cmd_buf, get_order(CMD_BUFFER_SIZE)); + iommu_free_pages(iommu->cmd_buf, get_order(CMD_BUFFER_SIZE)); } static void *__init iommu_alloc_4k_pages(struct amd_iommu *iommu, gfp_t gfp, size_t size) { int order = get_order(size); - void *buf = (void *)__get_free_pages(gfp, order); + void *buf = iommu_alloc_pages(gfp, order); if (buf && check_feature(FEATURE_SNP) && set_memory_4k((unsigned long)buf, (1 << order))) { - free_pages((unsigned long)buf, order); + iommu_free_pages(buf, order); buf = NULL; } @@ -866,7 +865,7 @@ static void *__init iommu_alloc_4k_pages(struct amd_iommu *iommu, /* allocates the memory where the IOMMU will log its events to */ static int __init alloc_event_buffer(struct amd_iommu *iommu) { - iommu->evt_buf = iommu_alloc_4k_pages(iommu, GFP_KERNEL | __GFP_ZERO, + iommu->evt_buf = iommu_alloc_4k_pages(iommu, GFP_KERNEL, EVT_BUFFER_SIZE); return iommu->evt_buf ? 0 : -ENOMEM; @@ -900,14 +899,13 @@ static void iommu_disable_event_buffer(struct amd_iommu *iommu) static void __init free_event_buffer(struct amd_iommu *iommu) { - free_pages((unsigned long)iommu->evt_buf, get_order(EVT_BUFFER_SIZE)); + iommu_free_pages(iommu->evt_buf, get_order(EVT_BUFFER_SIZE)); } /* allocates the memory where the IOMMU will log its events to */ static int __init alloc_ppr_log(struct amd_iommu *iommu) { - iommu->ppr_log = iommu_alloc_4k_pages(iommu, GFP_KERNEL | __GFP_ZERO, - PPR_LOG_SIZE); + iommu->ppr_log = iommu_alloc_4k_pages(iommu, GFP_KERNEL, PPR_LOG_SIZE); return iommu->ppr_log ? 0 : -ENOMEM; } @@ -936,14 +934,14 @@ static void iommu_enable_ppr_log(struct amd_iommu *iommu) static void __init free_ppr_log(struct amd_iommu *iommu) { - free_pages((unsigned long)iommu->ppr_log, get_order(PPR_LOG_SIZE)); + iommu_free_pages(iommu->ppr_log, get_order(PPR_LOG_SIZE)); } static void free_ga_log(struct amd_iommu *iommu) { #ifdef CONFIG_IRQ_REMAP - free_pages((unsigned long)iommu->ga_log, get_order(GA_LOG_SIZE)); - free_pages((unsigned long)iommu->ga_log_tail, get_order(8)); + iommu_free_pages(iommu->ga_log, get_order(GA_LOG_SIZE)); + iommu_free_pages(iommu->ga_log_tail, get_order(8)); #endif } @@ -988,13 +986,11 @@ static int iommu_init_ga_log(struct amd_iommu *iommu) if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir)) return 0; - iommu->ga_log = (u8 *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, - get_order(GA_LOG_SIZE)); + iommu->ga_log = iommu_alloc_pages(GFP_KERNEL, get_order(GA_LOG_SIZE)); if (!iommu->ga_log) goto err_out; - iommu->ga_log_tail = (u8 *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, - get_order(8)); + iommu->ga_log_tail = iommu_alloc_pages(GFP_KERNEL, get_order(8)); if (!iommu->ga_log_tail) goto err_out; @@ -1007,7 +1003,7 @@ static int iommu_init_ga_log(struct amd_iommu *iommu) static int __init alloc_cwwb_sem(struct amd_iommu *iommu) { - iommu->cmd_sem = iommu_alloc_4k_pages(iommu, GFP_KERNEL | __GFP_ZERO, 1); + iommu->cmd_sem = iommu_alloc_4k_pages(iommu, GFP_KERNEL, 1); return iommu->cmd_sem ? 0 : -ENOMEM; } @@ -1015,7 +1011,7 @@ static int __init alloc_cwwb_sem(struct amd_iommu *iommu) static void __init free_cwwb_sem(struct amd_iommu *iommu) { if (iommu->cmd_sem) - free_page((unsigned long)iommu->cmd_sem); + iommu_free_page((void *)iommu->cmd_sem); } static void iommu_enable_xt(struct amd_iommu *iommu) @@ -1080,7 +1076,6 @@ static bool __copy_device_table(struct amd_iommu *iommu) u32 lo, hi, devid, old_devtb_size; phys_addr_t old_devtb_phys; u16 dom_id, dte_v, irq_v; - gfp_t gfp_flag; u64 tmp; /* Each IOMMU use separate device table with the same size */ @@ -1114,9 +1109,8 @@ static bool __copy_device_table(struct amd_iommu *iommu) if (!old_devtb) return false; - gfp_flag = GFP_KERNEL | __GFP_ZERO | GFP_DMA32; - pci_seg->old_dev_tbl_cpy = (void *)__get_free_pages(gfp_flag, - get_order(pci_seg->dev_table_size)); + pci_seg->old_dev_tbl_cpy = iommu_alloc_pages(GFP_KERNEL | GFP_DMA32, + get_order(pci_seg->dev_table_size)); if (pci_seg->old_dev_tbl_cpy == NULL) { pr_err("Failed to allocate memory for copying old device table!\n"); memunmap(old_devtb); @@ -2800,8 +2794,8 @@ static void early_enable_iommus(void) for_each_pci_segment(pci_seg) { if (pci_seg->old_dev_tbl_cpy != NULL) { - free_pages((unsigned long)pci_seg->old_dev_tbl_cpy, - get_order(pci_seg->dev_table_size)); + iommu_free_pages(pci_seg->old_dev_tbl_cpy, + get_order(pci_seg->dev_table_size)); pci_seg->old_dev_tbl_cpy = NULL; } } @@ -2814,8 +2808,8 @@ static void early_enable_iommus(void) pr_info("Copied DEV table from previous kernel.\n"); for_each_pci_segment(pci_seg) { - free_pages((unsigned long)pci_seg->dev_table, - get_order(pci_seg->dev_table_size)); + iommu_free_pages(pci_seg->dev_table, + get_order(pci_seg->dev_table_size)); pci_seg->dev_table = pci_seg->old_dev_tbl_cpy; } @@ -3018,8 +3012,8 @@ static bool __init check_ioapic_information(void) static void __init free_dma_resources(void) { - free_pages((unsigned long)amd_iommu_pd_alloc_bitmap, - get_order(MAX_DOMAIN_ID/8)); + iommu_free_pages(amd_iommu_pd_alloc_bitmap, + get_order(MAX_DOMAIN_ID / 8)); amd_iommu_pd_alloc_bitmap = NULL; free_unity_maps(); @@ -3091,9 +3085,8 @@ static int __init early_amd_iommu_init(void) /* Device table - directly used by all IOMMUs */ ret = -ENOMEM; - amd_iommu_pd_alloc_bitmap = (void *)__get_free_pages( - GFP_KERNEL | __GFP_ZERO, - get_order(MAX_DOMAIN_ID/8)); + amd_iommu_pd_alloc_bitmap = iommu_alloc_pages(GFP_KERNEL, + get_order(MAX_DOMAIN_ID / 8)); if (amd_iommu_pd_alloc_bitmap == NULL) goto out; diff --git a/drivers/iommu/amd/io_pgtable.c b/drivers/iommu/amd/io_pgtable.c index 6c0621f6f572..f8b7d4c39a9f 100644 --- a/drivers/iommu/amd/io_pgtable.c +++ b/drivers/iommu/amd/io_pgtable.c @@ -22,6 +22,7 @@ #include "amd_iommu_types.h" #include "amd_iommu.h" +#include "../iommu-pages.h" static void v1_tlb_flush_all(void *cookie) { @@ -156,7 +157,7 @@ static bool increase_address_space(struct protection_domain *domain, bool ret = true; u64 *pte; - pte = alloc_pgtable_page(domain->nid, gfp); + pte = iommu_alloc_page_node(domain->nid, gfp); if (!pte) return false; @@ -187,7 +188,7 @@ static bool increase_address_space(struct protection_domain *domain, out: spin_unlock_irqrestore(&domain->lock, flags); - free_page((unsigned long)pte); + iommu_free_page(pte); return ret; } @@ -250,7 +251,7 @@ static u64 *alloc_pte(struct protection_domain *domain, if (!IOMMU_PTE_PRESENT(__pte) || pte_level == PAGE_MODE_NONE) { - page = alloc_pgtable_page(domain->nid, gfp); + page = iommu_alloc_page_node(domain->nid, gfp); if (!page) return NULL; @@ -259,7 +260,7 @@ static u64 *alloc_pte(struct protection_domain *domain, /* pte could have been changed somewhere. */ if (!try_cmpxchg64(pte, &__pte, __npte)) - free_page((unsigned long)page); + iommu_free_page(page); else if (IOMMU_PTE_PRESENT(__pte)) *updated = true; @@ -430,7 +431,7 @@ static int iommu_v1_map_pages(struct io_pgtable_ops *ops, unsigned long iova, } /* Everything flushed out, free pages now */ - put_pages_list(&freelist); + iommu_free_pages_list(&freelist); return ret; } @@ -579,7 +580,7 @@ static void v1_free_pgtable(struct io_pgtable *iop) /* Make changes visible to IOMMUs */ amd_iommu_domain_update(dom); - put_pages_list(&freelist); + iommu_free_pages_list(&freelist); } static struct io_pgtable *v1_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie) diff --git a/drivers/iommu/amd/io_pgtable_v2.c b/drivers/iommu/amd/io_pgtable_v2.c index f818a7e254d4..1e08dab93686 100644 --- a/drivers/iommu/amd/io_pgtable_v2.c +++ b/drivers/iommu/amd/io_pgtable_v2.c @@ -18,6 +18,7 @@ #include "amd_iommu_types.h" #include "amd_iommu.h" +#include "../iommu-pages.h" #define IOMMU_PAGE_PRESENT BIT_ULL(0) /* Is present */ #define IOMMU_PAGE_RW BIT_ULL(1) /* Writeable */ @@ -99,11 +100,6 @@ static inline int page_size_to_level(u64 pg_size) return PAGE_MODE_1_LEVEL; } -static inline void free_pgtable_page(u64 *pt) -{ - free_page((unsigned long)pt); -} - static void free_pgtable(u64 *pt, int level) { u64 *p; @@ -125,10 +121,10 @@ static void free_pgtable(u64 *pt, int level) if (level > 2) free_pgtable(p, level - 1); else - free_pgtable_page(p); + iommu_free_page(p); } - free_pgtable_page(pt); + iommu_free_page(pt); } /* Allocate page table */ @@ -156,14 +152,14 @@ static u64 *v2_alloc_pte(int nid, u64 *pgd, unsigned long iova, } if (!IOMMU_PTE_PRESENT(__pte)) { - page = alloc_pgtable_page(nid, gfp); + page = iommu_alloc_page_node(nid, gfp); if (!page) return NULL; __npte = set_pgtable_attr(page); /* pte could have been changed somewhere. */ if (cmpxchg64(pte, __pte, __npte) != __pte) - free_pgtable_page(page); + iommu_free_page(page); else if (IOMMU_PTE_PRESENT(__pte)) *updated = true; @@ -185,7 +181,7 @@ static u64 *v2_alloc_pte(int nid, u64 *pgd, unsigned long iova, if (pg_size == IOMMU_PAGE_SIZE_1G) free_pgtable(__pte, end_level - 1); else if (pg_size == IOMMU_PAGE_SIZE_2M) - free_pgtable_page(__pte); + iommu_free_page(__pte); } return pte; @@ -380,7 +376,7 @@ static struct io_pgtable *v2_alloc_pgtable(struct io_pgtable_cfg *cfg, void *coo int ret; int ias = IOMMU_IN_ADDR_BIT_SIZE; - pgtable->pgd = alloc_pgtable_page(pdom->nid, GFP_ATOMIC); + pgtable->pgd = iommu_alloc_page_node(pdom->nid, GFP_ATOMIC); if (!pgtable->pgd) return NULL; @@ -403,7 +399,7 @@ static struct io_pgtable *v2_alloc_pgtable(struct io_pgtable_cfg *cfg, void *coo return &pgtable->iop; err_free_pgd: - free_pgtable_page(pgtable->pgd); + iommu_free_page(pgtable->pgd); return NULL; } diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index fcc987f5d4ed..9a228a95da0e 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -42,6 +42,7 @@ #include "amd_iommu.h" #include "../dma-iommu.h" #include "../irq_remapping.h" +#include "../iommu-pages.h" #define CMD_SET_TYPE(cmd, t) ((cmd)->data[1] |= ((t) << 28)) @@ -1642,7 +1643,7 @@ static void free_gcr3_tbl_level1(u64 *tbl) ptr = iommu_phys_to_virt(tbl[i] & PAGE_MASK); - free_page((unsigned long)ptr); + iommu_free_page(ptr); } } @@ -1670,7 +1671,7 @@ static void free_gcr3_table(struct protection_domain *domain) else BUG_ON(domain->glx != 0); - free_page((unsigned long)domain->gcr3_tbl); + iommu_free_page(domain->gcr3_tbl); } /* @@ -1697,7 +1698,7 @@ static int setup_gcr3_table(struct protection_domain *domain, int pasids) if (levels > amd_iommu_max_glx_val) return -EINVAL; - domain->gcr3_tbl = alloc_pgtable_page(domain->nid, GFP_ATOMIC); + domain->gcr3_tbl = iommu_alloc_page_node(domain->nid, GFP_ATOMIC); if (domain->gcr3_tbl == NULL) return -ENOMEM; @@ -2092,7 +2093,7 @@ static void protection_domain_free(struct protection_domain *domain) free_gcr3_table(domain); if (domain->iop.root) - free_page((unsigned long)domain->iop.root); + iommu_free_page(domain->iop.root); if (domain->id) domain_id_free(domain->id); @@ -2107,7 +2108,7 @@ static int protection_domain_init_v1(struct protection_domain *domain, int mode) BUG_ON(mode < PAGE_MODE_NONE || mode > PAGE_MODE_6_LEVEL); if (mode != PAGE_MODE_NONE) { - pt_root = (void *)get_zeroed_page(GFP_KERNEL); + pt_root = iommu_alloc_page(GFP_KERNEL); if (!pt_root) return -ENOMEM; } @@ -2783,7 +2784,7 @@ static u64 *__get_gcr3_pte(u64 *root, int level, u32 pasid, bool alloc) if (!alloc) return NULL; - root = (void *)get_zeroed_page(GFP_ATOMIC); + root = iommu_alloc_page(GFP_ATOMIC); if (root == NULL) return NULL; From patchwork Tue Dec 26 20:01:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13505029 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 5BF8CC47073 for ; Tue, 26 Dec 2023 20:02:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 245216B0075; Tue, 26 Dec 2023 15:02:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1CF116B007B; Tue, 26 Dec 2023 15:02:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F13EC6B007D; Tue, 26 Dec 2023 15:02:13 -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 DFF686B0075 for ; Tue, 26 Dec 2023 15:02:13 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B8D8240657 for ; Tue, 26 Dec 2023 20:02:13 +0000 (UTC) X-FDA: 81610040946.05.BFF6FAB Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) by imf12.hostedemail.com (Postfix) with ESMTP id F2DF94001B for ; Tue, 26 Dec 2023 20:02:11 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=G0uiQc06; dmarc=none; spf=pass (imf12.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.46 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=1703620932; 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=ypS1Neib8HIDm9UmxS/HJDs2d4K6sNmK80zg2UdXDks=; b=MJV7Pe5GmiEC9vr4DYxk0eopEasvPBpp83BCN2yZ3oZnP1lz9mBVa00z0eL8keLj0KdLs4 GuVusXcOfWqeLUncnj31glTmVXEhJKKn6sG3jOYI2U185VO/3JR6W+E3Fz3bS4sNgUuFy+ /7ECb1TXleRa7G290jlhqhV/rkOpmUs= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=G0uiQc06; dmarc=none; spf=pass (imf12.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.46 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703620932; a=rsa-sha256; cv=none; b=ztyEhG4usPyCqsGnGJVa0xVdaHJNdkzgy/x/sxNVjeavxTnRvdfPH6hiFqDH4mNybZEoml zW8gEXIoRcAI1XH1Sh85pZMt++rddukIuQxyl/fJ1aeo0KpWU4jQ3a/IUE+plymHGZ5sdD ovSeSFAKCPVF6XZiH2VB2nSJ83EOUzc= Received: by mail-qv1-f46.google.com with SMTP id 6a1803df08f44-67fe0210665so16405106d6.1 for ; Tue, 26 Dec 2023 12:02:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1703620931; x=1704225731; 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=ypS1Neib8HIDm9UmxS/HJDs2d4K6sNmK80zg2UdXDks=; b=G0uiQc061HmbHnGIBQVJLj4Y0rONTaZlPpM5pFiSEVHjzthS36WXcYyIEgaKM+HJer x84KoVE/6kb4KRUnKeSQ2P0FaBL0qcT5ZEdMWZ7n/drzM1OjAyINcH+zZfII+R832Qrl vD/Nkt4OyxTI1UPqwwW8h8JtN9qeuXNCfUyuimyzVc2tOH553pSzkiMbbfe+U1kkARFG shBffxYU53ln3F4ruLi0OzDaecg9hpgKT5kOwJQ9V2jD9SRz5mgq1OZAruoIBnaXICrF WeG03kEj4dAZ4l33mclA2pD54xSHkFnVcyNb67aCjamQcopttMOy2zDGPsBTDZdUPgld bEQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703620931; x=1704225731; 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=ypS1Neib8HIDm9UmxS/HJDs2d4K6sNmK80zg2UdXDks=; b=DCSBHEhGwfR5Cvgj26vixjypz3N0b+Nrw9IHC7OBaYYGwV4WrCxIPNc9LXtrest6JW mrzhoXUMVfYzDcnIuRAOvjsgnNo2KWWGCizr4wOhRhJrmbM0yvvaqdbyS4Ni6XLs1rgW JuTe6QU2yi8nSnodASb9PZ9O3hyrE45AuA38SNzu83PPuQ3HE/IoGuE1tsYR3+H7qHaU v8hSgHbsikIMvsBlZXIRP0hfLnPDoKIt7EMeDqOSTlT5dJAJSD1S0zcdVgHsF3xeFfmu gkJyP+0ghDp44Ru78AMTo3KMfBMrrNXBpIRMAPQ3jLrThIWrCLNx7iWd5gNGG2FmJ4hr yxFw== X-Gm-Message-State: AOJu0YwX0N37Kh2B15Kv6Xdb4nUkZV1Gh2C+rLqEUkv4seB/hqg9nYvE 7iHRxKhTVDrgkplugbKc0sEoKlzTFEVW/w== X-Google-Smtp-Source: AGHT+IHSQM+LgRuNVnF3iWBSyAs/u7g89umL2iScajvlGIrSq1uiM5Mc659FcM2VTca3M8kj7d2P0g== X-Received: by 2002:ad4:5ae7:0:b0:67f:7c5c:3449 with SMTP id c7-20020ad45ae7000000b0067f7c5c3449mr13308631qvh.14.1703620931126; Tue, 26 Dec 2023 12:02:11 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id t5-20020a0cf985000000b0067f696f412esm4894539qvn.112.2023.12.26.12.02.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 12:02:10 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, pasha.tatashin@soleen.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com, rientjes@google.com Subject: [PATCH v3 03/10] iommu/io-pgtable-arm: use page allocation function provided by iommu-pages.h Date: Tue, 26 Dec 2023 20:01:58 +0000 Message-ID: <20231226200205.562565-4-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231226200205.562565-1-pasha.tatashin@soleen.com> References: <20231226200205.562565-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: F2DF94001B X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: p7748zjr5myhe8q95x5zp4go4urqgnmw X-HE-Tag: 1703620931-732269 X-HE-Meta: U2FsdGVkX18wu5YigUuU+3thKnMTh2J4SNcWAPbLZNbbBLEARfRqGco/kyhjtbvcB9j7BrLFaFt3RzveD8ihjuYapY5UMKeWwAgf7rqtYizqXcCe/MY+yd1PmW60/7GXIFQfBRwkq9Yv066DqNgaefnYNw4zHisQ91iBTjpfJ+lko4nmgT1Ix2bkRhB4fzznAhce9jO25pb0t+nOA6e13jemqv7bPF86lZOKYidVHMHrfoAfUXpDodIEEicVcki/NlDjGJmSlB3VnvJXQTFY88qczwLL73lN0CPKPe9pVo/9cwRwPF4edAKqIunTVbxQQ455TExVuKGoJztPul+H0LLMTbgFoyOcgESFvofz4gC/ugl0h35JVMvdz23J8ZB76kZGth2z1oaCNtkl6a3/Mhgq1WdxfiLpyTBUdq3/DYZcgOSxqJMfR4CYXBa3UAFSI568Bdq6p4qk59MQzP4vgCO0V+xCtoJq5d4tyvl7Dihl1CwvGt6Dlnp3DTUdBiHsWBvCbZ6VnN3lq9XxhfUVGY+Yytsw9Ohfn4orGvZbgbiynD6xeEnUI218Rs+VBlXyLZbaRMaFhFgR2jyqdsLRNH2fxqAg2iNkEmespKF+ftJmc5LqdqBhQNqAbGD6r77EKLCmNuQ7GL+VoSqh4kzN+mN/+AxlDUbTqTcFlGFsK4TpE+iaxGJmmetFZzjn52Iy1vSQwoR4kGLMR4UnhjNhb9bokY3zC4BzasipiQ9++cf/LVD59PEJMyNYey1wfVAHjbEdXTpbfAvhVJJV9bxbFSLG7i/4aA0Qdvi9X7e9kpXrzLyXp/9pcB5ORU3bTq7nSwEWqMG7LAvUa8KVTrWQNZGmrMC05bhDj995CYSsCwl8fbppHho3IFJN5TD1G/W6O9faKrkOtN81e5sQ9jZ1GNTEcPHLGwPoiBWgpmPlGnDdqYDz065G5eT7eJxDQNNUpnHXzUxSgBDWDlzHQmT 8rpzMVnD dTTAwcabKABneCqGEYGGuOWgxmQDiSl9EMoy/ToiFgBH0VooRqtIeiRAAyjR1rxD6BINdOelbcPfD3n+Zi0YP3bgREnD5IWCyn9A7/QpPx70rQBPm87zwmp5wojnIgPlP1I/+kcBwEcHA5rUNCG+KzAPw/K+Nj4JDUKxYWmFC9Iy4gcJLyAH2gJJhYtAIxtUEl0q5pz9zDkpqAs0fAZyX+80hiUzNo1DuAgo5UbwTog09UNXBh3owLMHhnTliz0wDsob91vYa7JOr/xW7SWF8Ib3/CfwvH9347EpG+gnefVKqc0h8ZIA+sMtMqaGNCT1cTsYw4bbiVifGmz8mSrPOlWwZzzoCIQVvSTgZggmZzZ3BrX7hRhWf4WBa+uVPsdky5e9+vENeDQOvJXQNr1Pj6DgiksF491e9u8tA2lyhzI5j5/hJ8MMPE4ssEA3EsAIT5CUIfNde13GWHK1HHbL9eJiRvA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Convert iommu/io-pgtable-arm.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin Acked-by: David Rientjes --- drivers/iommu/io-pgtable-arm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index 72dcdd468cf3..21d315151ad6 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -21,6 +21,7 @@ #include #include "io-pgtable-arm.h" +#include "iommu-pages.h" #define ARM_LPAE_MAX_ADDR_BITS 52 #define ARM_LPAE_S2_MAX_CONCAT_PAGES 16 @@ -197,7 +198,7 @@ static void *__arm_lpae_alloc_pages(size_t size, gfp_t gfp, void *pages; VM_BUG_ON((gfp & __GFP_HIGHMEM)); - p = alloc_pages_node(dev_to_node(dev), gfp | __GFP_ZERO, order); + p = __iommu_alloc_pages_node(dev_to_node(dev), gfp, order); if (!p) return NULL; @@ -221,7 +222,7 @@ static void *__arm_lpae_alloc_pages(size_t size, gfp_t gfp, dev_err(dev, "Cannot accommodate DMA translation for IOMMU page tables\n"); dma_unmap_single(dev, dma, size, DMA_TO_DEVICE); out_free: - __free_pages(p, order); + __iommu_free_pages(p, order); return NULL; } @@ -231,7 +232,7 @@ static void __arm_lpae_free_pages(void *pages, size_t size, if (!cfg->coherent_walk) dma_unmap_single(cfg->iommu_dev, __arm_lpae_dma_addr(pages), size, DMA_TO_DEVICE); - free_pages((unsigned long)pages, get_order(size)); + iommu_free_pages(pages, get_order(size)); } static void __arm_lpae_sync_pte(arm_lpae_iopte *ptep, int num_entries, From patchwork Tue Dec 26 20:01:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13505030 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 3B693C4706F for ; Tue, 26 Dec 2023 20:02:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3CD576B007B; Tue, 26 Dec 2023 15:02:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 37CB56B007E; Tue, 26 Dec 2023 15:02:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A8236B0080; Tue, 26 Dec 2023 15:02:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id F35A96B007B for ; Tue, 26 Dec 2023 15:02:14 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C4DF61C0EAB for ; Tue, 26 Dec 2023 20:02:14 +0000 (UTC) X-FDA: 81610040988.17.DE0A527 Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) by imf13.hostedemail.com (Postfix) with ESMTP id F17862001D for ; Tue, 26 Dec 2023 20:02:12 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b="T/yUwP0p"; dmarc=none; spf=pass (imf13.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.46 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=1703620933; 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=Kc2MBt2GVAxAWlt3U6Mxk50gGM7GPQMuVWdXUG/ygbQ=; b=wLi1cCgXhuIxOw6dXLJw/HK1Pat0jIJrjD0r1hjaxQu9Hu/CpK1mTykynhUydNzIkPxt/B VwFzkUeCDB5aVEYhAjyxjI0cwmx5UiNpJOQv5sgUnx3VLiS4q5hZOqDj0VDsjY09xOa/wQ cMiE6z4sKrm8GPYEaluwD/uthkdrFq0= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b="T/yUwP0p"; dmarc=none; spf=pass (imf13.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.46 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703620933; a=rsa-sha256; cv=none; b=NmAxF8J2YbQNAsZk1PKuyqhm8dXeUt/is7m9zUaAmrzDoyqgmD8UlHQHFcIQQyCDOOGb5E 65ikWyEpEjh9qFa4GLjWGMHZ3aE1NtUO7Ap3i+yz03+83iaUnnHeZkA3l8lx0ECIUv5myy FmXEM4w98lM6xc4yQPRQA0kwAagwcsM= Received: by mail-qv1-f46.google.com with SMTP id 6a1803df08f44-67f911e9ac4so39520096d6.3 for ; Tue, 26 Dec 2023 12:02:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1703620932; x=1704225732; 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=Kc2MBt2GVAxAWlt3U6Mxk50gGM7GPQMuVWdXUG/ygbQ=; b=T/yUwP0pryRMHnEQj1q2Xx2zmFuTZHSY0IADTILfPzTGVGIIavE4ZaCVusi5JrXhFl Q4c2gX8/Kl44Q3rjvAPnNfaKsWxV1e7cr02GjBSPcDJmkPP8YuFcjPFn1Z/YvxGRZ2e8 /DBp0iHMIBQfpdYlBgDJKol/pKA6l1TyzW7mAikKTJwaFWlHBheNC61D0cYgRHtXzcgB oNGoNmw6fzCF5+alljjnMdx0PVH/VGB3c22mdzpaHepGjOf4xYh0gbXJTh+W1pqvzHHm nmBCFl8Q/SJU4kt3hHE8AJtPnQYwClufm+Xp9wYN0dQ7Ge2Mwj5VgALr8eTGYi/CKXSN CCbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703620932; x=1704225732; 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=Kc2MBt2GVAxAWlt3U6Mxk50gGM7GPQMuVWdXUG/ygbQ=; b=hCrRaSjJCI7CBsdqLHzFKhhm7FmWMtPLGUp1a3sZC1LhoikuDO00dHdwDK6QCpd4aN 0pOiTD8TA/BhJQCIYtmxcFKRDw8+EbvQ/2l3SpKtm8k2bXIu4V3CBKcO6oUR2Gzvqsoq FXYO4P4PK8s+bJG4YKvqvuhVmdXOmbS8zd5SmQ/Gzkzyy3tv4U+Q7fVtvFGLNNv48spk iHcu/W7FG76sMbR5WM3BVSqw5oN0ERRPUf2cjKcbssWPU6oJbJJ6blu43qnsVrxspJn7 hOC6YAUOYy24Sshofeu25/CWCrRYY+pddo4NU5o9jWq3q3YQr3ZGhtS3dV/7xBVSbCA2 uDxg== X-Gm-Message-State: AOJu0Yz+6SZJpA7bWAyZBaRp8L9AU5ascHV9Y1DSkAzWF5uoNU2K9GA6 2GJOSfAS+3y8qJ0POb+qVU1AUEGpTojTQA== X-Google-Smtp-Source: AGHT+IGESQ4vJslQjT1sSibx4aOBHwxj4JmN7OYbYn4cPlnzh7uIRGIg35PIp/kXV1ck4NfeaNvKVg== X-Received: by 2002:a05:6214:122:b0:67f:b7fa:9d4f with SMTP id w2-20020a056214012200b0067fb7fa9d4fmr7176762qvs.119.1703620932023; Tue, 26 Dec 2023 12:02:12 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id t5-20020a0cf985000000b0067f696f412esm4894539qvn.112.2023.12.26.12.02.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 12:02:11 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, pasha.tatashin@soleen.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com, rientjes@google.com Subject: [PATCH v3 04/10] iommu/io-pgtable-dart: use page allocation function provided by iommu-pages.h Date: Tue, 26 Dec 2023 20:01:59 +0000 Message-ID: <20231226200205.562565-5-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231226200205.562565-1-pasha.tatashin@soleen.com> References: <20231226200205.562565-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: F17862001D X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: b6og4wmi6kz659aq94mkuowig6e8kq1y X-HE-Tag: 1703620932-475922 X-HE-Meta: U2FsdGVkX1+CKvatZNrdp0XXcSYJxaiDBF27bj8dwlhl6JgfcOASXWF7mNwQKb2NJ07ahv7rlkaBDkJGC0EXCC1/v6uPVycUlBRM+KlNjc3SJ5iv+/GEXawxps3Z0SdtVEMW6mPWSN455St8l0aAohqUAo29r5z59uqCQUeN1WIC3nHkMkR0mC6lGhRoSFLAq89B9pfYrGKg4Td3CAjShTT0b2qNWuBwlPPpcmtw31uYCcqwvyyu0V8HmEwhvNBbK81Av/xqWCmbeZgR4vboL7vdpCwjopKH7QX4hYOqNcHBzlxe2KpbEqyw3B15zGKqpatr/z+XiKueOC43+2yF1bW3xVdbBj8hm13a0xL2x+YwQfB1NOn3WkYfiLkH7VUIe9CEiXPhH3uJIp5OCo9XsWSVWPI49DppJySw+sR6Ei2wrMQM1TJDANe7j2qFlzJcv/WJW6a4K3QKlgu5ecKGYvJZupLgtZ6AcMiWDe/ZcrBFsKNXRUJWnOZQ+vsl1l8/nj5oVMTdacvExES164rLD+n4zw56ZRD+rhJD2Uu4ler0e2ZkCh1adSSQjkPPMVYqlvguunu+8D/ht5v+s/Z1/B+1MHaRvJtVH1BUx7msKIviInAL1EdEfyW1fYeOrsaU/zjWlWV9wGtLX0/LSPQF2h3cyFRB/92SdOh7BKqPjPevUk/lOFzXVZNRsznS3PfnzOiO5O2TCCMJKe2QMtXz7WFKC7831aXpKgA2OqZ164PrWvbRXk0kFtbF2qiiNIckF3RyMjMwKG70XP8et908Z5trrbN1HeQxTEpe6c5cWW4L28l38DpQwXsgzGH1g7A/LgAXHWvfPYccDyQTgUvAYzD/bRGWEtnby6ivUwp3iaTPx0oRtLqFEsW80E29CsqcwQElsMmcs6f+wc5sYNK3XJ3jJ3VJSz/sIP11se0hAJ7FSjsrANNQFX4rAK32IBUCllg4OQn3mUCWxkhaxwl EJjHEYbg MtjDfyeA6UFwMNHk+jZXD1dE/lUfyppFVmGhRyO8Whd4vI46sEOg4HwPVeGKp3UCzCbPr2EC3LDJPDldfLYpKn9g8uNzvhWoBMc45UEEZKWPkA+DVhN4ReLtQbOgi4RVR8f8vdJ+5P6qzniI5WdIoaAug9fcF0Kqu5VdhZceXAynW1kf1vFgWGdFgG5xoWaG/tdO9m/S2Fq9akReeYiodGrf9+XtaNkCIeA6sevzNzgHrh6Jl9jBiiDe6OzF3L5SAq6VZP7gsZK93qJCw2ZS8QcfUnxbdAa8B11EfY+8ZA0c2oqIToTUgRJTSXtv3J6Qx51HfAakJnE67TlbCzLDxOzlTbUXqyLxXsWbqar7P77XIkzwErCG2+0YM8Iz9m4Ag9hBAS3G+evn2kfKeJPMEYY9Qi+LZCoIoIZc7sPJkJ0oUVNbAJRYqWkuvDbu2YTTiKTnP9A+oB/0xO4ot439hjO+CQW2mYyI+bDdmKbn75I/cyN88QMr+b1JJ8xLs5MHKnV6eCvPsOFfd+m8+2qauoXlYzQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Convert iommu/io-pgtable-dart.c to use the new page allocation functions provided in iommu-pages.h., and remove unnecessary struct io_pgtable_cfg argument from __dart_alloc_pages(). Signed-off-by: Pasha Tatashin Reviewed-by: Janne Grunau Acked-by: David Rientjes --- 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 Dec 26 20:02:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13505033 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 7B9FFC47074 for ; Tue, 26 Dec 2023 20:02:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF7BB6B0082; Tue, 26 Dec 2023 15:02:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C2F876B0083; Tue, 26 Dec 2023 15:02:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 972AC6B0085; Tue, 26 Dec 2023 15:02:18 -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 7D88B6B0082 for ; Tue, 26 Dec 2023 15:02:18 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 82D80C05B1 for ; Tue, 26 Dec 2023 20:02:15 +0000 (UTC) X-FDA: 81610041030.11.B8178E0 Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) by imf18.hostedemail.com (Postfix) with ESMTP id AAB791C0029 for ; Tue, 26 Dec 2023 20:02:13 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=iO9NZZMc; spf=pass (imf18.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.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=1703620933; 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=nvjQljl7JPoogUlmvytdtR3rbtLgZccu0UZbVKP5s2w=; b=SecOReDAg55WAy42inKIE16JNn3EBqMnGq449F9H5yzRHTXfqeGWhgPSf42smAFyVE7f33 pl0sNDPhtnt1+VoECogodGFCB4ctUAxr44TpEZYLA28rJn3sR4MAWaxL+LE8KBK3r+zhZ2 Bt2Xe2tT9Z4AUtc19mQV/EANSV6/Of8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703620933; a=rsa-sha256; cv=none; b=Ag1wNAhOO1+TFHXmmIzwz0RI/JnkFYkdYhoB5kQkBTAxl5O5llv4iEIDniC+prKGdS0HGA uAO8Y2w98IXYWsOmXiafBJEEcaisZ4dyOh2MZZBUWSFjEiKqFSVVj08UG8WhcDU2OaRgvy udKPmeJVGRL6WmK1wr9/sNFH0flE/fo= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=iO9NZZMc; spf=pass (imf18.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.170 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-7811c02cfecso310822585a.2 for ; Tue, 26 Dec 2023 12:02:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1703620933; x=1704225733; 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=nvjQljl7JPoogUlmvytdtR3rbtLgZccu0UZbVKP5s2w=; b=iO9NZZMc6iSSpG2NKo0I+kDWjfdu4NkKXAnE+Flex20RQqUyE1n7KrfSNB/UiE3Fps BGgeMLoUlEW9vkGWhfWkU28UUtzqc9UmD+AwhuRFuEDFW+O83GYiiufpXGIDEJawXoJY 9ceKxnQl8TFSoDSY0YqPX1WzZuYKDnQM4S8m9Faa7L4laJdwn93Lo2v/WyB1/7Hij/va 9NJspYnS/+gSwOdA15bY6u7pKeEWjekCReYtzvXvRItA5v9rtvnAFmTCi5OHRrUgKexv q0uW9CqjWsdMD3pdN2Jhmb3+/JD7QuOpKRORJ8nlyk8MxpIi6UCCeA+79aRVTWrS6zO+ 1t1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703620933; x=1704225733; 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=nvjQljl7JPoogUlmvytdtR3rbtLgZccu0UZbVKP5s2w=; b=q3C/cpl/AvfWkm9Lol0gqJKESzxTAtuFQz7CPDBAmZsMUL4YCo7Px0nlf7A4Qfhbb+ t3qoLnjHQSABHiKzJxpYubFZ9oG+iXWEP4xa4vWCGwsJP5ESsaKEQAF4FC73O41nqOD7 /V3AAa6v5on9F1mXoW7fxT1RT9vUTMN5jH1iWvd8Ah0K37UOHMkNTYyFdl4503pqeGsO ZT5Q9sMT2ErWlhVpIVoJ/94BFG2pUWIFKtU5To38jp76dQo+4bW353l1n3dz9rN8V/IU FdZ9aXWznfPwAc2zmFoZFOi/38DJwaHgOaDFp8uQubajOr+t/XW4C6ZvxHqmQxYWNh6w FuMg== X-Gm-Message-State: AOJu0YzN3nfgd0uEdRkHQEiNybq95YWWeZs3tIacaBN/jefeKIV4b9Li 2OQFSkGpZ4qhZ5oW/1qcypI1d9QRgkVbag== X-Google-Smtp-Source: AGHT+IHPjp9+2kjPszPXsBaYDpwmHuWWhdFbzpOIFVRda6CdGBRpo12LyU+NRUYukzs17wjh8sdbkg== X-Received: by 2002:a05:6214:2684:b0:67f:5c5:c035 with SMTP id gm4-20020a056214268400b0067f05c5c035mr12074627qvb.9.1703620932853; Tue, 26 Dec 2023 12:02:12 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id t5-20020a0cf985000000b0067f696f412esm4894539qvn.112.2023.12.26.12.02.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 12:02:12 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, pasha.tatashin@soleen.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com, rientjes@google.com Subject: [PATCH v3 05/10] iommu/exynos: use page allocation function provided by iommu-pages.h Date: Tue, 26 Dec 2023 20:02:00 +0000 Message-ID: <20231226200205.562565-6-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231226200205.562565-1-pasha.tatashin@soleen.com> References: <20231226200205.562565-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: AAB791C0029 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 5g4r3qmbf7njxgrp595pfbiyp3opf9s8 X-HE-Tag: 1703620933-508820 X-HE-Meta: U2FsdGVkX18MSemU5Fpw7JeNswrOeJJfpWVaRVvscBp3J8jpvuPPpPBRKqXOzFRKyW5ja7H/24/W7+/XEge2O1AfWtKQ1dv+t2Zh8vTutWuhrkFMZ1V5jKPvh5FG0bntoDrpPb8/ZHQI7cqRPOd2cNp4HcwOS19cIvPiz+R0yYAAJ0EbyCIgUE4QiMLZrMmjYt4YSxWwvPp5j1K8/IqTTRR12ku3qhriIxKTCK0fB2f1uZ/mS1UoeKVQR938699y7BlyEJJ1WIrILUl+rFdhMtrrgRS1YeWTtijZoACPh3YELnZBXYIio9/Lmx+DEgglDAEt+BVgEz+VBYzLWTL+6AZ4IkYHHVqh7a2i4IENafWVxP24lhl136kd4pR4przWhZS+iqkuH1EPq+roctBexFiJkHD78kMPIskpCH3QPl46+Cje6HeB4n1oNxbKAd2YJWCnrs+csUsnOaRj9OWDG28hMiGVJKQcRWMLp1ls1PzZ8bTgYg2Z2yvqYVlwNmzUsR8jiLaMydD0boFExLxa/xlVPqIWrxG8QhoRNpm6G/nLn5hIwkMnbtC0I4Cqw5KTAQ/p0DnWZ7QFKOaTXPxoFWm8D+6qnDCqIBDWEwliOotbgspz1JTpTws1VCudq2VFa8WALJw4nQ2dznVZWJ9L9lK7HwcxuXgVYW5C/329LD5nXjDD1LNbsGf8Kl6RAjykztyJbzQUTIMQOsXgy6ioT2v4IrMTMsjaJCSUqroZk++/L1yFURufykmYuw2kXh7GZkzo8vEqm261GGIB5e7PauesavCo+V9MAm14dN2qWmjmr/AFTv9X9NAGyqaXjyKAlTnpAaostFtXSx1Jr7WKbnKkmouwme/ayiRP67r2/ux4OnfHPXyPW942WsoWGndKyXqX8pfoqsAYSCJRt6qp2oa522MGfUO0GDTjji82Lxv2qNH2fcG84npc66LaCcrpAQkQv1rLGhgXMZy5Nsq wYiXv3W+ JOs+J2VVNt+jVfB+te1VlLShpvz4eB/wSKRag2AXzI8hH56T+3imBSWc/9CEZOL10uPIftplbWOETt9a4mOgvpwvH+7dns95rwVWETf5cMjKXGXM0GlLyLTcHJKDwftUoK8e0uMcu/EtwGJze1OROnPDeybjpFUnAceoVuX3JMCEkzGEM/JzZEej++xr+Yc+M6LWAVIs//OMRDIJ5cEoXEW9wyG9MovlUs84qFfIGHRlDuY/2uhjMmzgg881coLKyxfDaDtI5pdXM9pZungc/8u/eTEjVtzgXTVVGL0oq0y1Q4A916tSS01nHF2dU3e87tK6OzGAxdViMX9ekNJTKdi9S7fo57lVVqDpxH73Z5M6dW6HkU00a15sz3dHwCvE769HHkFkrP48vbkSqRNmQUGpPIut+3XfeDbDPQi97HgF+XtfGXJZxvdeUO3CaY2NdoO0YUqQTJpVWdpC4eNIys6ixlg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Convert iommu/exynos-iommu.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin Acked-by: David Rientjes --- drivers/iommu/exynos-iommu.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 2c6e9094f1e9..3eab0ae65a4f 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -22,6 +22,8 @@ #include #include +#include "iommu-pages.h" + typedef u32 sysmmu_iova_t; typedef u32 sysmmu_pte_t; static struct iommu_domain exynos_identity_domain; @@ -900,11 +902,11 @@ static struct iommu_domain *exynos_iommu_domain_alloc_paging(struct device *dev) if (!domain) return NULL; - domain->pgtable = (sysmmu_pte_t *)__get_free_pages(GFP_KERNEL, 2); + domain->pgtable = iommu_alloc_pages(GFP_KERNEL, 2); if (!domain->pgtable) goto err_pgtable; - domain->lv2entcnt = (short *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, 1); + domain->lv2entcnt = iommu_alloc_pages(GFP_KERNEL, 1); if (!domain->lv2entcnt) goto err_counter; @@ -930,9 +932,9 @@ static struct iommu_domain *exynos_iommu_domain_alloc_paging(struct device *dev) return &domain->domain; err_lv2ent: - free_pages((unsigned long)domain->lv2entcnt, 1); + iommu_free_pages(domain->lv2entcnt, 1); err_counter: - free_pages((unsigned long)domain->pgtable, 2); + iommu_free_pages(domain->pgtable, 2); err_pgtable: kfree(domain); return NULL; @@ -973,8 +975,8 @@ static void exynos_iommu_domain_free(struct iommu_domain *iommu_domain) phys_to_virt(base)); } - free_pages((unsigned long)domain->pgtable, 2); - free_pages((unsigned long)domain->lv2entcnt, 1); + iommu_free_pages(domain->pgtable, 2); + iommu_free_pages(domain->lv2entcnt, 1); kfree(domain); } From patchwork Tue Dec 26 20:02:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13505031 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 DC500C46CD3 for ; Tue, 26 Dec 2023 20:02:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 15AB86B007E; Tue, 26 Dec 2023 15:02:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0E38C6B0080; Tue, 26 Dec 2023 15:02:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E78D76B0081; Tue, 26 Dec 2023 15:02:16 -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 D13BE6B007E for ; Tue, 26 Dec 2023 15:02:16 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A1763A04DF for ; Tue, 26 Dec 2023 20:02:16 +0000 (UTC) X-FDA: 81610041072.25.9CDD65E Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) by imf27.hostedemail.com (Postfix) with ESMTP id D679740020 for ; Tue, 26 Dec 2023 20:02:14 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b="QDz/MeLJ"; dmarc=none; spf=pass (imf27.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.161.47 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703620934; 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=4Px5z3jJNMJ+cqkQJ8fykFQGitjbal7TFA82XDDTiIs=; b=OpP59d2/r4DEkNgRI2Ow2HSX1J0JOwspz9FHB6qZxEUnLBtYqs3R2PiCFA/WCBZzTul/q8 hz8ZegrWQ+0lC5dYKf5bw2vzCgtB42xpqe/VH4t91/kydBULwdF/IB8dhs5d6LIWIOO7yx TPeOZgClw5FgsEJh6BVFbwSoHziRkbM= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b="QDz/MeLJ"; dmarc=none; spf=pass (imf27.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.161.47 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703620934; a=rsa-sha256; cv=none; b=A23nLiGozyiNau1DQR53Lg1SgTRbSFXHp9mMEb0ZCKDcB+rJSJOY6enouF3Ny8hpm0XRJh Vgj5YmInDCfnO49ND3CZL7emt6XwEI7Z1KmduRyP0XoIV0RdnMkC9VlK6dWoWO2BUI5Isb XxjkbWuFnF0Zxu3p3CERrUlZDAXvzCQ= Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-594cac3cbaeso188055eaf.1 for ; Tue, 26 Dec 2023 12:02:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1703620934; x=1704225734; 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=4Px5z3jJNMJ+cqkQJ8fykFQGitjbal7TFA82XDDTiIs=; b=QDz/MeLJGSrAjeEHRSQibXupM5yfTDHfxRp2yLZtoJhHZ8XFIBWP+Q47kbxs8QuWUZ zOV6loiZk5p/nOeHI6Pbun5kx1zhe8YmFx5Ducie9ZwklUdLXQlkFv7Gv2c7iC41enB6 H5gAeb/9cdN5wGmAKmOjINWm+zhtvVkRhbVYUhU1jzbp1d8W2KL0EWsHiAUYxbcj/fyZ h5PKiMupTFtSkDbn1vuR10a0lhvx0HQ8nU49suum/YALiBv0yJGDoqGiLhXCpXT5RUDf V4kOCvk8JszSEKiSzoIfYv1AgVz7+sRK5pUtdHLLZnw/M53G3WvYQBp9lCIP5gSuR0Nu YBxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703620934; x=1704225734; 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=4Px5z3jJNMJ+cqkQJ8fykFQGitjbal7TFA82XDDTiIs=; b=jrOi5Qev4WEL1Lvxi0m3FCUVx2OW+ZbyPYvDN8QMMidgGG4lVSzHBOi10xbrDrr4gI w7Bzx6Z4fb4QSOpJobv89rkMBlr1J7NvBkQ2o3ajkJ+LLHhhlON5e3C6U+1qBtr4Zucn sAC3itJAAcaJGsZLMQQ+3C49i4DnmJkyDdezdJ6cp9PPBh30CZg0s7UA932aP83S0sz8 /mH23VDSvd/XPdfxv4GLR6g8LE5g3rC2iVf0K54lVD0ougp0Jj3vzJKWbHBI+YZJ6aB+ ywAoAnZuRSemAx1mfZhxwxvKl/8+MhoPwWyroW5VbBDV2nTARTXr2oQB7gosgJGquP8E TZgw== X-Gm-Message-State: AOJu0YzMDAWC0NuU011nc+gJ3ZdP3yY9EtNIoymLvcJlh1XRgbzZJRv4 iA1oSRb4wDVYX20Uut/R0w/48EbkAoC7Cw== X-Google-Smtp-Source: AGHT+IGuyxzVTrkGD7GeRYCWL+kwqdfuJTNbDB34T0ltwnMiuh8TxVV6prFt2lzUE/2C05msUhTBCA== X-Received: by 2002:a05:6358:70c4:b0:174:edbf:a9a2 with SMTP id h4-20020a05635870c400b00174edbfa9a2mr2577495rwh.48.1703620933708; Tue, 26 Dec 2023 12:02:13 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id t5-20020a0cf985000000b0067f696f412esm4894539qvn.112.2023.12.26.12.02.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 12:02:13 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, pasha.tatashin@soleen.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com, rientjes@google.com Subject: [PATCH v3 06/10] iommu/rockchip: use page allocation function provided by iommu-pages.h Date: Tue, 26 Dec 2023 20:02:01 +0000 Message-ID: <20231226200205.562565-7-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231226200205.562565-1-pasha.tatashin@soleen.com> References: <20231226200205.562565-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: D679740020 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: fidwwh9xqtttjygxsk16j9b4mxzz1ekm X-HE-Tag: 1703620934-395810 X-HE-Meta: U2FsdGVkX192/JCSQz7cQnsan0a6550jUjJS8BHJEH0f0t74Zx+C3Eh5O3ZhiA3hn1nnr/OBiwQ2LQ5SI7cXngiWAEdGeBjNEqqridwFRYBGQSa5nMEutltHQ1c00p5pe78PZgJ1DV8IKzJBO0/ifL6tb2BYZsYDTrqDejRuL5RLNYmeJFp2PZ7mUga429wgADv8fhY8xIPP0LR/Rv80LSwPSclnZ2RC2aDgaNmp2D6qqojH6UIYNju+ujLud0O7/V3tQB7YXWk35VypLoMAuEX1wjhb+knOiv0byu6MPYMe66SRXRzbW+D/KyEnKYT+2zlvYFj3OYT0UsNY4H5GUZCCU044ZcESO60noTWWojFqZ4frt1phc0fg72EfU59HDQ1+9qY68cYSSAKpANU8OkRiwCLVEdgcH+KrMgWM1bADgffXJar6MCnRTGo6XYyicPoApQCGvFj9i8PXwkoj7PWmWjD+17pNZVSXuvCF3lJ5Q9BZw1f86K6zRxYI+qq9b6yB93V6Kot6otrxsxAzXGfGw4lE9Q6VCCTgyLzsh2c8NniBtW0Cy+v9/DcebwI6wwEx03jFBaos3chHLyiFvwhNGPV2HFV9DaEDG4OUvH0soPT0uEoiiUHFw7Mpmzhn1e3uDvdtFDVKSq8x94rgbt8KIdZy237Lgpa0PUXXvNb2/z4dH2SHR+G64zlI1XC37ZeoepMer9ElgGu3zEQ9R5Zi8v+JDke61Q0PHH69o4988akHjAvCH2AxkAHELy6NBNvruuwWDiMGrD/heoiTg83VejfyjTyDgST9kNA3xJ1JTwoaTv6vjZrvxBJg7OugOPiB6W7pY+K/WMl7AY9v40xKKNGKQ3WslJCHWAQ+ofu0T31cc1FTB9oDsQTtcFi4X73Ft7GU439gpzx9U0hXVloM8TC3xC5aL+XHM3vJgj560wpeD2pssAr1CDaC8KYsez96krRabMFBMxqiVrP nQo89kSg kNOEgMgpa0MO6tJi7P0z1+omNK5AEOhFilpxAsI+00ElHuYhTERQOAkxCR3uS+spz/W+g+hKxoBVxc7FzDFAealDRlD6Wpm7OLEOO/lAyH4F83Jnv8TFFnSWzJx1VdKBzNXhxtDP2GxbHR9fHkkU7FLLzrZ3JtFz1ISCnoe5Cbb7tZjNggzCK3aYhBzpwvEqbhUdw6WRv0CylQbyqjpdsXxtW+98pmjg5ec0aagijurqzOM2Q0oB7APc8aj2X07tLXQj5tclfSTxoQj2OuEl5FEFjkCSGjErxg/6Zp7ITY2In9eCYdCib+wcKUT8rhG0QS9+WlGesebURdfSGO2OGWR/kjo0mBZ5RfMUEo7qtBguBr4gA8eMbChhZEWyIgsDt4MTK73Wc9HPzdmSr2WFkqkNC2QID+c6Fjf8dyceTnHuAB2d8hMfV2MF0XypR9TE9sQQ956BhALZU6vdkF2E3RGCQ0w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Convert iommu/rockchip-iommu.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin Acked-by: David Rientjes --- drivers/iommu/rockchip-iommu.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index 2685861c0a12..e04f22d481d0 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -26,6 +26,8 @@ #include #include +#include "iommu-pages.h" + /** MMU register offsets */ #define RK_MMU_DTE_ADDR 0x00 /* Directory table address */ #define RK_MMU_STATUS 0x04 @@ -727,14 +729,14 @@ static u32 *rk_dte_get_page_table(struct rk_iommu_domain *rk_domain, if (rk_dte_is_pt_valid(dte)) goto done; - page_table = (u32 *)get_zeroed_page(GFP_ATOMIC | rk_ops->gfp_flags); + page_table = iommu_alloc_page(GFP_ATOMIC | rk_ops->gfp_flags); if (!page_table) return ERR_PTR(-ENOMEM); pt_dma = dma_map_single(dma_dev, page_table, SPAGE_SIZE, DMA_TO_DEVICE); if (dma_mapping_error(dma_dev, pt_dma)) { dev_err(dma_dev, "DMA mapping error while allocating page table\n"); - free_page((unsigned long)page_table); + iommu_free_page(page_table); return ERR_PTR(-ENOMEM); } @@ -1061,7 +1063,7 @@ static struct iommu_domain *rk_iommu_domain_alloc_paging(struct device *dev) * Each level1 (dt) and level2 (pt) table has 1024 4-byte entries. * Allocate one 4 KiB page for each table. */ - rk_domain->dt = (u32 *)get_zeroed_page(GFP_KERNEL | rk_ops->gfp_flags); + rk_domain->dt = iommu_alloc_page(GFP_KERNEL | rk_ops->gfp_flags); if (!rk_domain->dt) goto err_free_domain; @@ -1083,7 +1085,7 @@ static struct iommu_domain *rk_iommu_domain_alloc_paging(struct device *dev) return &rk_domain->domain; err_free_dt: - free_page((unsigned long)rk_domain->dt); + iommu_free_page(rk_domain->dt); err_free_domain: kfree(rk_domain); @@ -1104,13 +1106,13 @@ static void rk_iommu_domain_free(struct iommu_domain *domain) u32 *page_table = phys_to_virt(pt_phys); dma_unmap_single(dma_dev, pt_phys, SPAGE_SIZE, DMA_TO_DEVICE); - free_page((unsigned long)page_table); + iommu_free_page(page_table); } } dma_unmap_single(dma_dev, rk_domain->dt_dma, SPAGE_SIZE, DMA_TO_DEVICE); - free_page((unsigned long)rk_domain->dt); + iommu_free_page(rk_domain->dt); kfree(rk_domain); } From patchwork Tue Dec 26 20:02:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13505032 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 4306BC4706F for ; Tue, 26 Dec 2023 20:02:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C09D66B0080; Tue, 26 Dec 2023 15:02:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B92216B0081; Tue, 26 Dec 2023 15:02:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9BC716B0082; Tue, 26 Dec 2023 15:02:17 -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 87A396B0080 for ; Tue, 26 Dec 2023 15:02:17 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 37F9F120618 for ; Tue, 26 Dec 2023 20:02:17 +0000 (UTC) X-FDA: 81610041114.15.07C37F6 Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) by imf07.hostedemail.com (Postfix) with ESMTP id 71BD240015 for ; Tue, 26 Dec 2023 20:02:15 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=VQEje7Jr; dmarc=none; spf=pass (imf07.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=1703620935; 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=WnHaCiJRfpPGl2Fxvk26Xz7yYvu7rKjQdjdVfjQamuM=; b=uv+EixrSLW4U7SXtRXAZsW+az1jBkB/ymrL5kSNDCxcA4OANqTbweHIRwVmMnJD7M951UB p5k4Sk8MPI74dlMCqLR89hBN4A3S/5ErPKbCIgrzOX54b/O2Q7adJCajI1Un2RMJWyXLSB lfqynyKfz0WpK+3rCQFPA9vWSeg1Xuo= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=VQEje7Jr; dmarc=none; spf=pass (imf07.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=1703620935; a=rsa-sha256; cv=none; b=qfHLk6F14MgldJcBY7/V7rku5QTnjo40QHLOhWgDIrIbzuf7PSIUzLmhxCyJ8YiBVrAuAE CVYvnMqRIY7J3Z3tiFmAAW8alvQsCj0rzOWt2iR/h8aOpbxeRPPjZVns/teHNv31CZmIpx OX+UYaZJ8PYY4gaCAfLHb3WnESecGEg= Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-67f9f6163a1so23913046d6.1 for ; Tue, 26 Dec 2023 12:02:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1703620934; x=1704225734; 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=WnHaCiJRfpPGl2Fxvk26Xz7yYvu7rKjQdjdVfjQamuM=; b=VQEje7JrTw96M/Ji7gtDYJGf5yCSUx21wCUFsSgaw89CG/xkevjiRJYMf94y7O9pqV N+q6keZbDu9qlRcaUaKM46XidMNQGCdDLtuo2ywN1HzOuo5kRBf1WYMXHVHNIwAI9HQt j9IPbAoWxrQdtO9BHchc1jfUfu8QrwpiXmQeZ7J07xjOP0O03B+lvXrp1+X5kF7tKWty pq/hw9UKUV0YGapLPu7/iRhtOeMW5kIFVYBnQlz6OFHjJDS+TIPSs9RYFhyy4EWc1f1Z Bz44PEhdZV+Qt+mIsmNFHz+fIvDxEpQ343k70W/7iqTm73iHmQwJ8Dd736cM4pOZsmw1 G/eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703620934; x=1704225734; 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=WnHaCiJRfpPGl2Fxvk26Xz7yYvu7rKjQdjdVfjQamuM=; b=UMcJKD9SjYEYPd9SCWECFLagjkqGuYMOF5dBnKwlVXqhQSApq0gyrTs8PKrDemLu4J aARno10Ljeo0BTQ/AGk0I5LDmi3VXXz4FcGnN/LvPhEVDcXFkUCneU82rZBBW/Cn5BvM HAUPTowPSs3HMEOJACJW1IpDOUoouhFSThRQSbl//p0Bsc6RBGCqc277Jp17myqzVrSl k+zj42SVN2WDdg3GE+gIphzJkTb5AWcG4/7eFyrFmT4j6JbNBdUu4pbSy3V6RUDHCdWG YVPQo7xFxDHXuRHtrSeYrgeThs9Bhr+bD7x4I4mEBnvgjFxuw8CoMm19r+qVKJEXrySK LneA== X-Gm-Message-State: AOJu0YzIIslz30a9qxxc+i95bvVvl63Cl1OiocD9MMvJzKfUfV4HlokZ jfY9qdicW+XcmVY+YPAuTsoHlDbByeudVg== X-Google-Smtp-Source: AGHT+IEjSL92+xZ/bAtRl2Tju/DugZ1gVQzpypJBCuESKN0IWhI/QyhY0T30YGd/IZCCOkD5WPDVJg== X-Received: by 2002:a05:6214:2a85:b0:67f:67de:5d32 with SMTP id jr5-20020a0562142a8500b0067f67de5d32mr12181917qvb.41.1703620934647; Tue, 26 Dec 2023 12:02:14 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id t5-20020a0cf985000000b0067f696f412esm4894539qvn.112.2023.12.26.12.02.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 12:02:14 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, pasha.tatashin@soleen.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com, rientjes@google.com Subject: [PATCH v3 07/10] iommu/sun50i: use page allocation function provided by iommu-pages.h Date: Tue, 26 Dec 2023 20:02:02 +0000 Message-ID: <20231226200205.562565-8-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231226200205.562565-1-pasha.tatashin@soleen.com> References: <20231226200205.562565-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: rcnsaqsicfpiefi8siguftib5fa4zewj X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 71BD240015 X-HE-Tag: 1703620935-521706 X-HE-Meta: U2FsdGVkX18B/SHmdXkCifmo5kyUNE7Fv9UxLaqie65wAd5YRRs2gPZZG4GGsJIx8U80T31Tp6+isaa7tZ/XGMugCDIweHP0J8uldEfFV+MXyMw2HTD9qFEXuCl5jReTekT8yL7zLEAcr+MupJdOK0Af7rf2V7qd6/JgFy08NcDvHgafntVl60sa3R9sdRFcX+w8YkH5LDqmH83ceo0J6RcWWvZL7ttMUdlLU4odo0UWwMRu3H4p3dbQL5+hek3G+LNIcZTy19oSW7uNVPQB1KaQpvn2mZjOd+snenyk0BNlD7VrJW5MMUETolVK8F8F4PxnAsyrcXYRm57JTekn1xi2QTt9yNGMcYGXUmRPQCsNR6DcAs0T20EMyUfyvDH5AzsEOxcpM08tgbecsr5gdVWZ3lSKrPKIIoBOCzvGNmzLSsrZfAZR0LSm4TQg3dzRLLBUHAxfpNR2zpcq14jewp5KPYkVXVFjyT1ltstgMc03hrhrxrjlNAG0559ziblKgYyG9m2/Y+C8uzR1tpLA2qUjyCINgzpWktckpQTCVqJW9IClas+/wmtVm1Mvho+YWp5oajuDyS4sEd1V0WBHkjsOkG8SwdliMzsc1c1QaNw5ysXkvhViw6wTAAMU7QG3gAnWY3bSxq0PVsX4iQFzdok7uTL+kCQZsEccVjsQP+7/B+qcDOwJdKb1UkZw8DPPCyiALMEUgcJAmUqx23RurYkuV2RBeCQAdcxzK/VW44gZMYMeLwAtlXHfZ6VbZTQ3bR2y5rOepB9JSXATF4mEwhwNZApLr6FvL2XX757ZUZB0oPC07hbZXZim5NNWDvW4LLg6kQ57S5Saev1fQx0KWCP3q4myFPkqB6kQfWs/5bijvjGR6zv8FG9kjpvuRPYqv0+cprQo/B+LTrF6GM7tQlaRx8DiO0GMWqhxrhjfvxd2vh6Wsb5lqbWUv5PGllLSBZSbFQQM0XQMyMVLraJ 2pzl9JQY m5gu/9xPwjPlGaE3q0yyRJWs+t7XpNr8nrfWRFCAPSMLynr5qGRAGzFHkACght+0Mu1vxhO1ZHnNPOBSzNHdbPA+eFJdluaSJMk8hmzNMGOQ7pbPOxxiqLPQQSD5JKhIXwiAjeejb7MyrFt9w49FlxlbykUxIeybo7JJG2y7aYtUHidQoZmy89AUZ6ijy/VMV68A151KTwB8SoRM3AyJN/Z+2npbyyz1mAvfTuxYHQ6xuqi04PRfYIVlsTvXeCfvvIbgwzxI6A7cDUACZ4A1mqVNs98uWiOUI0tu7MZLZO5LPcJjCE4rNKF9OfZjTA4PD3Nh1ZG+1PhRaRi9DxujccR1IpHcF5oI8H1TwBe+VJdT07uk0jXQDUcq454V7ZMXK+J6e1785iHPygEMEOGRP4VzEWgqIYJTrond/hqOb75fUJZ4e/4Db0/YYypW5CO9yCFciqhyTWa9EVZQQu+WpsV1Whw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Convert iommu/sun50i-iommu.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin Acked-by: David Rientjes --- drivers/iommu/sun50i-iommu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c index 41484a5a399b..172ddb717eb5 100644 --- a/drivers/iommu/sun50i-iommu.c +++ b/drivers/iommu/sun50i-iommu.c @@ -26,6 +26,8 @@ #include #include +#include "iommu-pages.h" + #define IOMMU_RESET_REG 0x010 #define IOMMU_RESET_RELEASE_ALL 0xffffffff #define IOMMU_ENABLE_REG 0x020 @@ -679,8 +681,7 @@ sun50i_iommu_domain_alloc_paging(struct device *dev) if (!sun50i_domain) return NULL; - sun50i_domain->dt = (u32 *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, - get_order(DT_SIZE)); + sun50i_domain->dt = iommu_alloc_pages(GFP_KERNEL, get_order(DT_SIZE)); if (!sun50i_domain->dt) goto err_free_domain; @@ -702,7 +703,7 @@ static void sun50i_iommu_domain_free(struct iommu_domain *domain) { struct sun50i_iommu_domain *sun50i_domain = to_sun50i_domain(domain); - free_pages((unsigned long)sun50i_domain->dt, get_order(DT_SIZE)); + iommu_free_pages(sun50i_domain->dt, get_order(DT_SIZE)); sun50i_domain->dt = NULL; kfree(sun50i_domain); From patchwork Tue Dec 26 20:02:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13505034 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 D5454C47077 for ; Tue, 26 Dec 2023 20:02:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 041C26B0083; Tue, 26 Dec 2023 15:02:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E53E76B0087; Tue, 26 Dec 2023 15:02:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BBBEB6B0088; Tue, 26 Dec 2023 15:02:18 -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 97B9D6B0087 for ; Tue, 26 Dec 2023 15:02:18 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 78C17A14F7 for ; Tue, 26 Dec 2023 20:02:18 +0000 (UTC) X-FDA: 81610041156.29.8A0B82F Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) by imf20.hostedemail.com (Postfix) with ESMTP id 7B56E1C002F for ; Tue, 26 Dec 2023 20:02:16 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=lgWc8HoT; dmarc=none; spf=pass (imf20.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.46 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=1703620936; 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=DYpA5AoyDPqGEngVGgZPNQ1qp0VmBsjf7LHh4aHHikg=; b=SJnzwuzO51lDaNjDhHQnytQwXVXPBLnhCHIiYHugwVkxvxYKYeDyM60v3g+uo21YKDLugF 1IxRTd6oDCBhMKE73CIIwwkrvkW+7i6XECjT4lASh4eJQysNquRvoTxA9aE4MZoOK9/58C Egm6L1TT++5OulO2Bb29HD1pmGwyg/g= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=lgWc8HoT; dmarc=none; spf=pass (imf20.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.46 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703620936; a=rsa-sha256; cv=none; b=Fjc9/o+zBrRCoH1qR5daWKxubwIMf5COiC9OWXjoj9MkAFLrCzcZtOlMz/l6uNTCEAaDoz IyrCp+5nQ48aMp7URKE2TslXtUx3ZHIigkkPyju9mYwEYm0H2UqnLEnm/+EzpDwPjfjbKT pg2m9pD5UXDIzGMe68E6egN08E+CUks= Received: by mail-qv1-f46.google.com with SMTP id 6a1803df08f44-67f147c04b7so43559776d6.2 for ; Tue, 26 Dec 2023 12:02:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1703620935; x=1704225735; 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=DYpA5AoyDPqGEngVGgZPNQ1qp0VmBsjf7LHh4aHHikg=; b=lgWc8HoT6VWtc+v4VueWZDA2kBJoelSg5Bof2MomqJzbKL7ry82otTs0Pj5cZ/VMDr ROT1zpWlostngpwKJcwVbO8DmO2GAzUZXwNYelN353Z0PDewPrzbE6eh1CnuGEWFYCeg jlH4jg+GvdXx7eR/VdFJgOeUTGiBfzjyEgaib/tJKb5Hcvw/otbyp52juG5DAvxjQ2WD VmsvqgCePVwOz0elkujhM4owd6PS+Kh2oan25NIlpdufbEUh12IWVr8RWnzckFU3sHtn PUtdfY1SMm/EoENTLvIfugpayQ8qXCc5wng8xvt8SRrY8MhEM80ASCdgn4pXjULuZeG6 xTcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703620935; x=1704225735; 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=DYpA5AoyDPqGEngVGgZPNQ1qp0VmBsjf7LHh4aHHikg=; b=kvbOD4o3bj6yrAsBpdvGh9Yl+qrQIarRn/3BNdUEslyL7sXL/JgZ0KcYyoSLAgOlxC YK8nvEFYCCK4eBenqCs7r+0MrYhr3yjQgzoFNF9hQC8z3e2SSgyvQJRo3u4RsebTrYrb TxRLkPLXligM22SDRGiVI0uBYLnadU45auNelPqhXm6Kp8Uwboyr0VqwcvPKyRT8MCnl 0pXbkbmur/kTGVCMYmKXNexNM67+Kng0/CSIuwuzkkOxeGZOg/gtfu5bv231xclQNqvQ GoJ1ZxxbipZVPbx+ng/4cx8HVf6LGGGWP58uNE9tPCJoTMPPz7/tR5Gkya3M74+eREiL PIwg== X-Gm-Message-State: AOJu0YyPToFGkV9G6UCjoHKB8tdtJbUS/aDiv3NKWm54bBQXvxS2QExk 1dox3e+SUUHaCTtgrJi7onYzSbqgq++aTQ== X-Google-Smtp-Source: AGHT+IEHD5SgGbWwK85ao2UYnS0Sh88kCiwjBFDK6W+qd5C2eGRRvAW0T4zywkQC2m/uRIGxj913QQ== X-Received: by 2002:a05:6214:1fd3:b0:67f:bd9a:a4c0 with SMTP id jh19-20020a0562141fd300b0067fbd9aa4c0mr6481858qvb.108.1703620935668; Tue, 26 Dec 2023 12:02:15 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id t5-20020a0cf985000000b0067f696f412esm4894539qvn.112.2023.12.26.12.02.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 12:02:15 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, pasha.tatashin@soleen.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com, rientjes@google.com Subject: [PATCH v3 08/10] iommu/tegra-smmu: use page allocation function provided by iommu-pages.h Date: Tue, 26 Dec 2023 20:02:03 +0000 Message-ID: <20231226200205.562565-9-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231226200205.562565-1-pasha.tatashin@soleen.com> References: <20231226200205.562565-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 7B56E1C002F X-Stat-Signature: qhy6fekq6kr3d95ahc3pai651um7byqa X-Rspam-User: X-HE-Tag: 1703620936-157925 X-HE-Meta: U2FsdGVkX19DmSLpZn21uZqDq7bPT0qNQ7XtmD4ltHYNUQk/XuUMbUYisnm3zSAWnpArS0Hxq2LHYc9hZ1QF+D4qtyMPl7tbHb0HjQLCYrhLciXMz999U7hkonQ2iw4L/UmJUDXDvb4pAfTWhvYkSldZjSm1gy1GxjaaOoEsSNbvfRTvZa8GqT6a7aLtDZCouzWG+6O2DMHy494RzMHKnyBfkZzmTabcbKEz+ob7lIJX3XbLqrERLW+Bs535NR8pw2ZCtdVA0si6vf8UZf5gGTJ9P1VC3Qw3LDFE+P9oqI4u9gM5raqrakJn8CZGOJ4/S2ac9EfqAs2FqU3fcpB3NarL78lZeW9wFFZQdXo+vpcT77M/c4gsgEbIniQn5bZ2pywyXJjOF/zgKOTYJXAEZE9ciVoC5VmBn11bpM4gW8W4anz8WDej3/S3KXu/sTGBoovhGpOUFodrKaqOSXKeT8yslPOyRT+cV71YmXDsAjRXzteA9XZ0pq/bhIbAovBwLirDnwrTjletWpBBk9dfJwvSlSvbh8SJnh3pAUE85nk7+0IWGawW5cZsIHz3lSh8jgJ2n8lXJ3zYHCwp0QZ3M/TwjELzmwS1My41VisKyOzERa1IZVIuQC1YW1Z+QpeKWMBpuuIdXtwMWtHw8BKDBWha621F+DWK48H/n1Hwzu4zcFWK2OtRqZBhe/RGxDdwmUhVAyzyO+Xk7G1dpUY4X4QCYqGxVS6zgm1t6wBHTXQ+hbkNS96aqiZrK4hGpaDUedp+EHrjiwXnbfceDNez7igp5ndbqg0Ioru6q2O9N26ESQ92CyVt4pZB4mLP5QYb/dJ+NmH2BJsNXy5Oz4GuOhfRz0spt4ZA2O3mwM7U1/CVxvxD7hjxmhCOPBkoBIipH+lMhRE157IlN05jfR2Ojc5plcSsdeMiKS+S9XN4r6dA9CxfkBZJOBM0drFcBPACaizcC9mhXHhGY+E+8cI n5t5oZ6P 7L0foifcazZyVxUg/vfT8ym4XOlHc5ZABId/8t/vfH2jxlRyUtnwNozhceE4gPAalMQYLFbVKn2WBZ1MazrYMUWvJiV+IBDf0GRqz2BujDBnAyblXSg5Z8RYL3MQ7uwM1cFq+dw3VfnkqzCxZ14JtA796sxvcesafCbXI50Efx7PNjTEqO44Ymfkj3tC9bOu/6g/4eF84INhbWSLQiwJf1+1m2zQkAA+867Ikwt39JfyZaUEvg1rH6Hr/2GfRpiyUC+NOBFheLESXTSY21TZzFuJs/nkv55l+ngea35cOS5Y4ikJLNShfnLhhL2jKusDodaOMmJEIQxyc9SxWFC7Q4XmbvxSiIIUA8efIRR8bHYvjqzPHpenAIC3u/uENrGv1hU9+qCocNuy7OA0ZSBespiGx5Mil/h9q9vffWPBbOdUONsylxceEt7SUfrHmRUAPVmDcpa4bYygIQpzRS+o2PPf53Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Convert iommu/tegra-smmu.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin Acked-by: David Rientjes Acked-by: Thierry Reding --- 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 Dec 26 20:02:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13505035 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 893E6C4707B for ; Tue, 26 Dec 2023 20:02:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 777206B0085; Tue, 26 Dec 2023 15:02:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6AF826B0087; Tue, 26 Dec 2023 15:02:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B6AD6B0088; Tue, 26 Dec 2023 15:02:19 -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 2F3EC6B0085 for ; Tue, 26 Dec 2023 15:02:19 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 10AD840659 for ; Tue, 26 Dec 2023 20:02:19 +0000 (UTC) X-FDA: 81610041198.20.B3B9C55 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) by imf23.hostedemail.com (Postfix) with ESMTP id 62CC5140023 for ; Tue, 26 Dec 2023 20:02:17 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=FKYsw2IM; dmarc=none; spf=pass (imf23.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.167.175 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=1703620937; 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=mxo16AeffIcUl0pfz0nlTIeaxJpBLQvEVDy59ntWJzo=; b=RT0RaLAwmN+mOnA210PNJ39avMG4NyBUZZEExmN9GkGM7iXj6+dwbtkIK+aW0wXj5FwnR5 XaZsim/ZWMbVe/EoDXwnZPCiulAwC58bhQGAdQgZui7UH2JbUnjfX5Ka5smtIzd4gu2Uqg MFFpi0AadfcUE53BgzoVHNPhNgjkKw0= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=FKYsw2IM; dmarc=none; spf=pass (imf23.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.167.175 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703620937; a=rsa-sha256; cv=none; b=6EcRZ7qDdDMT8X6OSGYUxWxIJEgVsFZyvuSaswjjwHnRklhdO+6TaqQaMJJSAzIDH3/Hs2 3gNUgc09GQ01cruJ482mc1m6FLbSQ4wbnqCq3WGbmK9J+SEm7lyJbd+Kfm77ckeiNCLR3X XIbNB5xGHRVobNfZXn1KiOLcixBOb5o= Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-3bb968c02baso1737442b6e.0 for ; Tue, 26 Dec 2023 12:02:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1703620936; x=1704225736; 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=mxo16AeffIcUl0pfz0nlTIeaxJpBLQvEVDy59ntWJzo=; b=FKYsw2IMHEm9h9xXJ+HtRUj4EZ+mjNPSbBEJkGKVEAUw2O3NVlw5a3OYg/4ONpcXb9 4yJxOmiIhjiCiNWUrrxRl84AGhtcgMGV+saYDiTtPsTmZjRRAGm0Ky1ciLc37wWKBiE6 7gKQT7LBoIUtk0kriHgPbnKh51ehNTocTz9huSROU2toyeRmWG3ncQUTgTzPa7jwZgOn 8ahMhwkjvQicLZs5+Tieb4WKq7cUt70DliOR5R/HSaRt5EPY5iy/3hFYJt/vE+zKLi5v +Fk7J8n/tofPyN2QCsPRii5+oGarYoa3liSBho68YFZWV15n4fmyxVMu1oMfMmf6x1jx 71Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703620936; x=1704225736; 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=mxo16AeffIcUl0pfz0nlTIeaxJpBLQvEVDy59ntWJzo=; b=NWxd5NMAPdgqqSbEZ1J02MLp+fqYVGNCgrAaMG4SvLmg64e0hisgFRQluvLOSh9Jl+ vLbaF2MBCHMPq5Sv4t42pRkH+625DvWlnK3NdBr1hRrafFYQ3Cqo14TiZnA/A725/mAI 7G0KaUO1UJgXyr5gJjM5mhjGklX2e2lBJbZUYnxnauQszNTCdNXmVaY8tAhS55+EQJZ7 ADoslBYmDQ4o7SbraFe2tXZaidGLM4psZ8WWxZfqkpjVtKUAoH9R+en1T4ql+PyQ+j6V tmUM5CNtkPIg1QxbRGXC4m1RisM5Ja9VsnYR2Kvb6RsU7lq75o/0fID0PyRgLGEK39yl 3GjA== X-Gm-Message-State: AOJu0Yyt9kgmM+yNXet3Mxb+II2x46AbRUslq0ep2+RI2uygIXawtHv7 n+LNDizgCptkoDGKVtKMLeDRZ7pl6QVqqA== X-Google-Smtp-Source: AGHT+IHrGAGi+32a17cjz4hMVcRXIy2GjdCBrEmS3N5kwjkJAZZsim1kCd/4+YrLV4TJHLLCVok4zA== X-Received: by 2002:a05:6808:448c:b0:3ae:5bf5:4ad1 with SMTP id eq12-20020a056808448c00b003ae5bf54ad1mr9246412oib.33.1703620936477; Tue, 26 Dec 2023 12:02:16 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id t5-20020a0cf985000000b0067f696f412esm4894539qvn.112.2023.12.26.12.02.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 12:02:16 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, pasha.tatashin@soleen.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com, rientjes@google.com Subject: [PATCH v3 09/10] iommu: observability of the IOMMU allocations Date: Tue, 26 Dec 2023 20:02:04 +0000 Message-ID: <20231226200205.562565-10-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231226200205.562565-1-pasha.tatashin@soleen.com> References: <20231226200205.562565-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 62CC5140023 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: qkfyowt6hbhq55fp73ea94h9pdo3fu8p X-HE-Tag: 1703620937-953573 X-HE-Meta: U2FsdGVkX1+0Z5pnZx/jNUq8q27UTlyx2MONM0x98P8v8ZT/6l3Wh0R15JthsgkYYxQayiCcH2vtSg7mg/aNitdWQ3Mj56iMGu7uDtgEt/sQTq69V3F+pk1wTdv7gYWWT2u8kZ1C9yxZ+VenPBMviqXtt7zozacpfIdz8+4P71GIs+xT9JQ8GslPSmdAIA2+dq/zCizpioOG2DQEol3nfO7eeTi3kC3ICR/qIIGYKPCQ93GeiJR3RE4kzmWxQT8Ah7DkRfyfLJcmval/OPTGUGYjRfFYgBjQvUMdcmXQLggusVQeu9ksrt4QbURV0LeXKKlTQLDvwBAY5c7Wk2s2sqVbgHvoDmbUjPWk5N035XWxTN8xYT4OGXX9+p9r9qidT/6v7vUiSCbZ26eVAbmoJasTTVgnlRIIWzpfndiD/ordS91jECT09HPZmwvpW3HQ/eNZHqv7Sb9b1dbJtPgE962V+AXcrOdoHjFqizw7OxXyPLJF4CxBkyhZtAkCYCkNVwW5q2pz7Z+A3Azo3mibMnLSUqFxcw5FzSdfk/iucP3k19BRMkb2Ay0NHPE21NXJCTbkRrlKQvhH1LGUcbJTTFTDbgqCLuXnx6Xxbmk74B/ojzp+hswTM3nSQd0mReaaP0HuKGlKfgvaSwUoy7T+Q1w1gsHiITu4AqzCiirX3uFunEUGHyOeE00rx9AzM7E9s0xK4HDdAkDd/SsobApMHfWy+GoL4s4Ycxjyb5x3ZVKtEyw/zYSDwqQ2JahjzN5tIE/ZvvmOKV6qOqn44W+3iVyF4TGSo+fHf+aaEO8epCrw8otLCQhvEJYqu9kmF1cD0J3zji4IbtNI7VcEivZuPGYIp6rwHzK8vq1nbLgbuKsQE6fNv21vrba2UKdsFAmXOqTU68W+c3Y60r6toUGTjWexCHNyUoFd7Bu8G/y0Z+K5S1zLqX9bFCPr4E5pDh7KhYuaVMNdY1qhepcUDNF Dmtmee2O 3tLpw5yqKDSPlXVaLDzQcm1hGJaEbIbv9iiJkEiXdM2aP7zSZBpa3QtK0VhcCtsE5oJtm5l1O0shzdFGgeHfZ33wC0VW7Bzn1AyklVjsm8sganld1SXX2xm5qF6gv/IRGnDIQ6DBZrpmVDIB3RLLhqqR2ed1XddGxYg+75pgvNj09JfE= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add NR_IOMMU_PAGES into node_stat_item that counts number of pages that are allocated by the IOMMU subsystem. The allocations can be view per-node via: /sys/devices/system/node/nodeN/vmstat. For example: $ grep iommu /sys/devices/system/node/node*/vmstat /sys/devices/system/node/node0/vmstat:nr_iommu_pages 106025 /sys/devices/system/node/node1/vmstat:nr_iommu_pages 3464 The value is in page-count, therefore, in the above example the iommu allocations amount to ~428M. Signed-off-by: Pasha Tatashin Acked-by: David Rientjes --- drivers/iommu/iommu-pages.h | 30 ++++++++++++++++++++++++++++++ include/linux/mmzone.h | 3 +++ mm/vmstat.c | 3 +++ 3 files changed, 36 insertions(+) diff --git a/drivers/iommu/iommu-pages.h b/drivers/iommu/iommu-pages.h index 99105503b771..4e70cdf7acac 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. + * @page: head struct page of the page. + * @order: order of the page + */ +static inline void __iommu_alloc_account(struct page *page, int order) +{ + const long pgcnt = 1l << order; + + mod_node_page_state(page_pgdat(page), NR_IOMMU_PAGES, pgcnt); +} + +/** + * __iommu_free_account - account a page that is about to be freed. + * @page: head struct page of the page. + * @order: order of the page + */ +static inline void __iommu_free_account(struct page *page, int order) +{ + const long pgcnt = 1l << order; + + mod_node_page_state(page_pgdat(page), NR_IOMMU_PAGES, -pgcnt); +} + /** * __iommu_alloc_pages_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 (unlikely(!page)) return NULL; + __iommu_alloc_account(page, order); + return page; } @@ -53,6 +79,8 @@ static inline struct page *__iommu_alloc_pages(gfp_t gfp, int order) if (unlikely(!page)) return NULL; + __iommu_alloc_account(page, order); + return page; } @@ -89,6 +117,7 @@ static inline void __iommu_free_pages(struct page *page, int order) if (!page) return; + __iommu_free_account(page, order); __free_pages(page, order); } @@ -197,6 +226,7 @@ static inline void iommu_free_pages_list(struct list_head *page) struct page *p = list_entry(page->prev, struct page, lru); list_del(&p->lru); + __iommu_free_account(p, 0); put_page(p); } } diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 9db36e197712..f0b54c752e22 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 Dec 26 20:02:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13505036 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 09BCCC46CD3 for ; Tue, 26 Dec 2023 20:02:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 57BC06B0087; Tue, 26 Dec 2023 15:02:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 502C66B0088; Tue, 26 Dec 2023 15:02:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 32DFC6B0089; Tue, 26 Dec 2023 15:02:20 -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 1B1456B0087 for ; Tue, 26 Dec 2023 15:02:20 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id EA938A0684 for ; Tue, 26 Dec 2023 20:02:19 +0000 (UTC) X-FDA: 81610041198.10.44B6E90 Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) by imf24.hostedemail.com (Postfix) with ESMTP id 258D118001F for ; Tue, 26 Dec 2023 20:02:17 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=gQRpXMdj; dmarc=none; spf=pass (imf24.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.43 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703620938; 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=BtxKf3FqZi0ydpudkf0bXoEdqlC2cPc9JiSI0VbRHzc=; b=Mj6vFoFDThg9Z9btc3yh5SIc88eQq0pp3owjob+VLEkn+pyE6Zrew9XS54n8gjXgs1Dd+F CFbj7brwgMpbtG59ZP836mAo3ZRE+gNr5P+hhdZrhC4JReawiKGsqxbwPm6C/WleGasyk/ 4cAsgHVt8/+zGo8sbD1Z+NrOhP4mdMo= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=gQRpXMdj; dmarc=none; spf=pass (imf24.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.43 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703620938; a=rsa-sha256; cv=none; b=QXBb8B3ybJ79QIcAyEsPBegvRh2aAgaFD/Jn5K1AoiKVmjsd2RG6pST/+5FOMSR6YUDOpL zUIjS+ynAXTgqyLNcefeBAS+O7zC/NYthtfnyfXyq4vYZEOWUKWuub2TnszrGaE203nYrQ 2XuHU8W5Xwf68cd4SzqPOWYNGZdmJdY= Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-67f6272e7c6so42218576d6.1 for ; Tue, 26 Dec 2023 12:02:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1703620937; x=1704225737; 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=BtxKf3FqZi0ydpudkf0bXoEdqlC2cPc9JiSI0VbRHzc=; b=gQRpXMdjeO01uIFvbTsngROmXackuvSGSuM+ACRnHiUm5yF8LrTNShJkyNq3JVIv+2 wXcF8b9nPADk49YmCZeainS5IUZ6dFz4DtPFgCiOJ/Gw4laKIZ804tAV+qUOkb7DbAy/ WtY0zdfyDS1ZL/KZpSt/N3tD6hSoVf/YHFw04f6PV6Pl9ZtGxcmq1VDzY93w7YoG+E0/ S00VKYsUDC90VlgqtiysovM10kjVi0Xo8l2tkae7dxmg4oJYYIWK7X4GH5nfob1COH0l pWU4Getk+bPLDSNKCO/ihbgnuECEkHeARc2fiMQBUiawHOTs0nyehm2xvVgRf78uA0tE sK/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703620937; x=1704225737; 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=BtxKf3FqZi0ydpudkf0bXoEdqlC2cPc9JiSI0VbRHzc=; b=in4mAsBy6stBmxhDvXQjL6+Iu8AUr35PsLhfO/HaNp3BZuyGyYT0N8Jqy3h9rOh9GI D4H4swHgvFaBM2wRuqob7trxXsPR3HhjkrllB9LylmwpE+qazAIcKMhgcL8p3O1DqsRr XPrYb8VHTYo3g85k+G3T+SX/9zEqlL6hIYC/HipTmjObAxFxiEluOf3kVhNvHaRHNGZW aJ6uDkI5AMBMyLSpyw+NfFJPOMVBDrE93tSydX/5zcMAsT3QEvnfA0VOvPpsEJr3b3vj CxqAtVPxjccByVIK1jbUui+YU7e8NY/8TBeQIKlMYb8C81ZV1M+d9lBAu80xoP8FX4ni u0Xw== X-Gm-Message-State: AOJu0YygwC4AN6NWBmrZbVNgVjHN06hawcFlIAaRCwou+YzfbLCYvN+h aqHvg0KrDJzfWSkIDf01ULLLT1Tc+SFGOw== X-Google-Smtp-Source: AGHT+IF6SHRllSaxJq4UXQlu+eJlDbGhCpDAe3qqJtRfc6g3mN6rB4PyhEEN8AN1FQVjUmVdCTe1Ag== X-Received: by 2002:a0c:e90e:0:b0:67f:d69e:9c45 with SMTP id a14-20020a0ce90e000000b0067fd69e9c45mr6794763qvo.11.1703620937325; Tue, 26 Dec 2023 12:02:17 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id t5-20020a0cf985000000b0067f696f412esm4894539qvn.112.2023.12.26.12.02.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 12:02:17 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, pasha.tatashin@soleen.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com, rientjes@google.com Subject: [PATCH v3 10/10] iommu: account IOMMU allocated memory Date: Tue, 26 Dec 2023 20:02:05 +0000 Message-ID: <20231226200205.562565-11-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231226200205.562565-1-pasha.tatashin@soleen.com> References: <20231226200205.562565-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 258D118001F X-Stat-Signature: 8p8bq8cc8wwict8r3jrs54b4854od39j X-HE-Tag: 1703620937-147825 X-HE-Meta: U2FsdGVkX1/jABqT0hpLTbiEIn67cy9IZfC16fPMwnLRXaHViQNY9X2XWNN5bT4tyyLDaBi1OWq/WAxjS1pRxFOynrKRLjS/TrLqEOguASyAKXOC8rpmOmJjBmMv6Q25HR4zOfPPIGW89YOdPjYjddrsAQ7nRSR0ZWKSuZzkXPi6g90t8u3BczVQozUoMzycNJRH99XtfqaQ4gv3Y14kvil2oW3NWKlyEUCIi7DGYZohIJZL1ibhqhIIhIKoKbo7p0fYfz+jw9bsMMqlsJpIaNWqH9U3NZltj69GI7HjFUzhl89bksHSUTkY/dxJR4VMszaRU8CJ5kB5hI1xGshHR/2/5uHYEcnpeLc2Wopi5IzqvnumupiP0kZYhWVbDT0XpGRiN+0lzx7VAMFd/pX3B3p7VmbsilxrCWD0Ui7D3JR3of1s5qCWYLjKVF+IktVRJxEbqeoqOLDhqfU2V8qOy8kiiwfzYPj+0eqhAdMdh1Fn5X8UXQKR3hDtC0KHRJ0jybXEJh8/UqBTMNPc5rjyAOX3QxZLM8CF3Hfx/VU1SLAPL1Gs6Jf3wHXPWgYZwwJ0jjs78KfZF1tpCczkm7WHX2kmdM3m9hUsRjg7DejfZYyPM/vZM8ue3jhMeZR31oaItyBqSyQZWOHFnhldq9qjS2NwFQKFoCtJEoKur0EkfcaPaw/StcF6exLaAjPLGNJxK0JHIcPuvBR6/pO7Ok8XzghEI1DQOq0Ed+gGH+sBJ8ysR0XGc6VTHDrYKF3lzmRmvujw2V+U5i0qLIccZSujnYEOEndO+oeFIgkNkMJ4+H9JMkFuc+vulr2iYQh7B/VvKj5ERoWci6wepV/DJoKFGBcZQO2F7tEyWLgEhv0AtOe+o5uieUT5hTD1htBxjqrYDMtVSujqr19JcUL+6jP/rvkmIGs0aCjeXQDbrMWF8gNLx/N7rRUA/8xlj4gOuty8vjFawSQT8IYojndfB8n i9XQJE78 0I0FWa/b5TiFZpXsI2oe2Po3ffh+2sO/nVL2hVtyrv8VQextAxxRVoW86GHrE/yGcZReCtAT6ajt8TGeGjM5yD90BBq8zqYxI8Kp4LIhOR++UbDx40ZygZDWL2Z5sd+EmZu+hK/MkOGE3HdqOPgeXf9wsCMn8GoMj4CUFKrepxxF/hRPfOwV/A0vvBhRQGnO1YwVfibCXAcga6wqFysKZCkSljw/HhEgNupX8wTEURRE5bx1VV4iUXRcsIe226D06L+EwZSgozEzh47DGWen3bTAzT8mNUA/CQ2hnH2OG0UVH0DMxlfo+9gqY6kF8xqAuZrXDdmCcyV1ea29FuKQ8nhlKVjfDx7kRM/uE9QsxjbIn6FhbFTuTjMzLDFJeurkaleYefQIbcpL7Car5N/lf35JU44EHKW03TX4vGowrunWltJstCG1opVUOBEkFEUe8ZPBK X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: In order to be able to limit the amount of memory that is allocated by IOMMU subsystem, the memory must be accounted. Account IOMMU as part of the secondary pagetables as it was discussed at LPC. The value of SecPageTables now contains mmeory allocation by IOMMU and KVM. Signed-off-by: Pasha Tatashin Acked-by: David Rientjes --- Documentation/admin-guide/cgroup-v2.rst | 2 +- Documentation/filesystems/proc.rst | 4 ++-- drivers/iommu/iommu-pages.h | 2 ++ include/linux/mmzone.h | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst index 3f85254f3cef..e004e05a7cde 100644 --- a/Documentation/admin-guide/cgroup-v2.rst +++ b/Documentation/admin-guide/cgroup-v2.rst @@ -1418,7 +1418,7 @@ PAGE_SIZE multiple when read back. sec_pagetables Amount of memory allocated for secondary page tables, this currently includes KVM mmu allocations on x86 - and arm64. + and arm64 and IOMMU page tables. percpu (npn) Amount of memory used for storing per-cpu kernel diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst index 49ef12df631b..86f137a9b66b 100644 --- a/Documentation/filesystems/proc.rst +++ b/Documentation/filesystems/proc.rst @@ -1110,8 +1110,8 @@ KernelStack PageTables Memory consumed by userspace page tables SecPageTables - Memory consumed by secondary page tables, this currently - currently includes KVM mmu allocations on x86 and arm64. + Memory consumed by secondary page tables, this currently includes + KVM mmu and IOMMU allocations on x86 and arm64. NFS_Unstable Always zero. Previous counted pages which had been written to the server, but has not been committed to stable storage. diff --git a/drivers/iommu/iommu-pages.h b/drivers/iommu/iommu-pages.h index 4e70cdf7acac..b4289d577e2c 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 *page, int order) const long pgcnt = 1l << order; mod_node_page_state(page_pgdat(page), NR_IOMMU_PAGES, pgcnt); + mod_lruvec_page_state(page, NR_SECONDARY_PAGETABLE, pgcnt); } /** @@ -39,6 +40,7 @@ static inline void __iommu_free_account(struct page *page, int order) const long pgcnt = 1l << order; mod_node_page_state(page_pgdat(page), NR_IOMMU_PAGES, -pgcnt); + mod_lruvec_page_state(page, NR_SECONDARY_PAGETABLE, -pgcnt); } /** diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index f0b54c752e22..da68f9977206 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