From: Mostafa Saleh <smostafa@google.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Alim Akhtar <alim.akhtar@samsung.com>,
Alyssa Rosenzweig <alyssa@rosenzweig.io>,
Albert Ou <aou@eecs.berkeley.edu>,
asahi@lists.linux.dev, Lu Baolu <baolu.lu@linux.intel.com>,
David Woodhouse <dwmw2@infradead.org>,
Heiko Stuebner <heiko@sntech.de>,
iommu@lists.linux.dev, Jernej Skrabec <jernej.skrabec@gmail.com>,
Jonathan Hunter <jonathanh@nvidia.com>,
Joerg Roedel <joro@8bytes.org>,
Krzysztof Kozlowski <krzk@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-riscv@lists.infradead.org,
linux-rockchip@lists.infradead.org,
linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev,
linux-tegra@vger.kernel.org,
Marek Szyprowski <m.szyprowski@samsung.com>,
Hector Martin <marcan@marcan.st>,
Palmer Dabbelt <palmer@dabbelt.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
Robin Murphy <robin.murphy@arm.com>,
Samuel Holland <samuel@sholland.org>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
Sven Peter <sven@svenpeter.dev>,
Thierry Reding <thierry.reding@gmail.com>,
Tomasz Jeznach <tjeznach@rivosinc.com>,
Krishna Reddy <vdumpa@nvidia.com>, Chen-Yu Tsai <wens@csie.org>,
Will Deacon <will@kernel.org>,
Bagas Sanjaya <bagasdotme@gmail.com>,
Joerg Roedel <jroedel@suse.de>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
patches@lists.linux.dev, David Rientjes <rientjes@google.com>,
Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH v3 05/23] iommu/pages: Remove the order argument to iommu_free_pages()
Date: Wed, 12 Mar 2025 11:43:39 +0000 [thread overview]
Message-ID: <Z9FzazECgXgE8TNX@google.com> (raw)
In-Reply-To: <5-v3-e797f4dc6918+93057-iommu_pages_jgg@nvidia.com>
On Tue, Feb 25, 2025 at 03:39:22PM -0400, Jason Gunthorpe wrote:
> Now that we have a folio under the allocation iommu_free_pages() can know
> the order of the original allocation and do the correct thing to free it.
>
> The next patch will rename iommu_free_page() to iommu_free_pages() so we
> have naming consistency with iommu_alloc_pages_node().
>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Mostafa Saleh <smostafa@google.com>
> ---
> drivers/iommu/amd/init.c | 28 +++++++++++-----------------
> drivers/iommu/amd/ppr.c | 2 +-
> drivers/iommu/exynos-iommu.c | 8 ++++----
> drivers/iommu/intel/irq_remapping.c | 4 ++--
> drivers/iommu/intel/pasid.c | 3 +--
> drivers/iommu/intel/pasid.h | 1 -
> drivers/iommu/intel/prq.c | 4 ++--
> drivers/iommu/io-pgtable-arm.c | 4 ++--
> drivers/iommu/io-pgtable-dart.c | 10 ++++------
> drivers/iommu/iommu-pages.h | 9 +++++----
> drivers/iommu/riscv/iommu.c | 6 ++----
> drivers/iommu/sun50i-iommu.c | 2 +-
> 12 files changed, 35 insertions(+), 46 deletions(-)
>
> diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
> index c5cd92edada061..f47ff0e0c75f4e 100644
> --- a/drivers/iommu/amd/init.c
> +++ b/drivers/iommu/amd/init.c
> @@ -653,8 +653,7 @@ 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)
> {
> - iommu_free_pages(pci_seg->dev_table,
> - get_order(pci_seg->dev_table_size));
> + iommu_free_pages(pci_seg->dev_table);
> pci_seg->dev_table = NULL;
> }
>
> @@ -671,8 +670,7 @@ 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)
> {
> - iommu_free_pages(pci_seg->rlookup_table,
> - get_order(pci_seg->rlookup_table_size));
> + iommu_free_pages(pci_seg->rlookup_table);
> pci_seg->rlookup_table = NULL;
> }
>
> @@ -691,8 +689,7 @@ 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);
> - iommu_free_pages(pci_seg->irq_lookup_table,
> - get_order(pci_seg->rlookup_table_size));
> + iommu_free_pages(pci_seg->irq_lookup_table);
> pci_seg->irq_lookup_table = NULL;
> }
>
> @@ -716,8 +713,7 @@ 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)
> {
> - iommu_free_pages(pci_seg->alias_table,
> - get_order(pci_seg->alias_table_size));
> + iommu_free_pages(pci_seg->alias_table);
> pci_seg->alias_table = NULL;
> }
>
> @@ -826,7 +822,7 @@ static void iommu_disable_command_buffer(struct amd_iommu *iommu)
>
> static void __init free_command_buffer(struct amd_iommu *iommu)
> {
> - iommu_free_pages(iommu->cmd_buf, get_order(CMD_BUFFER_SIZE));
> + iommu_free_pages(iommu->cmd_buf);
> }
>
> void *__init iommu_alloc_4k_pages(struct amd_iommu *iommu, gfp_t gfp,
> @@ -838,7 +834,7 @@ void *__init iommu_alloc_4k_pages(struct amd_iommu *iommu, gfp_t gfp,
> if (buf &&
> check_feature(FEATURE_SNP) &&
> set_memory_4k((unsigned long)buf, (1 << order))) {
> - iommu_free_pages(buf, order);
> + iommu_free_pages(buf);
> buf = NULL;
> }
>
> @@ -882,14 +878,14 @@ static void iommu_disable_event_buffer(struct amd_iommu *iommu)
>
> static void __init free_event_buffer(struct amd_iommu *iommu)
> {
> - iommu_free_pages(iommu->evt_buf, get_order(EVT_BUFFER_SIZE));
> + iommu_free_pages(iommu->evt_buf);
> }
>
> static void free_ga_log(struct amd_iommu *iommu)
> {
> #ifdef CONFIG_IRQ_REMAP
> - iommu_free_pages(iommu->ga_log, get_order(GA_LOG_SIZE));
> - iommu_free_pages(iommu->ga_log_tail, get_order(8));
> + iommu_free_pages(iommu->ga_log);
> + iommu_free_pages(iommu->ga_log_tail);
> #endif
> }
>
> @@ -2781,8 +2777,7 @@ static void early_enable_iommus(void)
>
> for_each_pci_segment(pci_seg) {
> if (pci_seg->old_dev_tbl_cpy != NULL) {
> - iommu_free_pages(pci_seg->old_dev_tbl_cpy,
> - get_order(pci_seg->dev_table_size));
> + iommu_free_pages(pci_seg->old_dev_tbl_cpy);
> pci_seg->old_dev_tbl_cpy = NULL;
> }
> }
> @@ -2795,8 +2790,7 @@ static void early_enable_iommus(void)
> pr_info("Copied DEV table from previous kernel.\n");
>
> for_each_pci_segment(pci_seg) {
> - iommu_free_pages(pci_seg->dev_table,
> - get_order(pci_seg->dev_table_size));
> + iommu_free_pages(pci_seg->dev_table);
> pci_seg->dev_table = pci_seg->old_dev_tbl_cpy;
> }
>
> diff --git a/drivers/iommu/amd/ppr.c b/drivers/iommu/amd/ppr.c
> index 7c67d69f0b8cad..e6767c057d01fa 100644
> --- a/drivers/iommu/amd/ppr.c
> +++ b/drivers/iommu/amd/ppr.c
> @@ -48,7 +48,7 @@ void amd_iommu_enable_ppr_log(struct amd_iommu *iommu)
>
> void __init amd_iommu_free_ppr_log(struct amd_iommu *iommu)
> {
> - iommu_free_pages(iommu->ppr_log, get_order(PPR_LOG_SIZE));
> + iommu_free_pages(iommu->ppr_log);
> }
>
> /*
> diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
> index c666ecab955d21..1019e08b43b71c 100644
> --- a/drivers/iommu/exynos-iommu.c
> +++ b/drivers/iommu/exynos-iommu.c
> @@ -932,9 +932,9 @@ static struct iommu_domain *exynos_iommu_domain_alloc_paging(struct device *dev)
> return &domain->domain;
>
> err_lv2ent:
> - iommu_free_pages(domain->lv2entcnt, 1);
> + iommu_free_pages(domain->lv2entcnt);
> err_counter:
> - iommu_free_pages(domain->pgtable, 2);
> + iommu_free_pages(domain->pgtable);
> err_pgtable:
> kfree(domain);
> return NULL;
> @@ -975,8 +975,8 @@ static void exynos_iommu_domain_free(struct iommu_domain *iommu_domain)
> phys_to_virt(base));
> }
>
> - iommu_free_pages(domain->pgtable, 2);
> - iommu_free_pages(domain->lv2entcnt, 1);
> + iommu_free_pages(domain->pgtable);
> + iommu_free_pages(domain->lv2entcnt);
> kfree(domain);
> }
>
> diff --git a/drivers/iommu/intel/irq_remapping.c b/drivers/iommu/intel/irq_remapping.c
> index ad795c772f21b5..d6b796f8f100cd 100644
> --- a/drivers/iommu/intel/irq_remapping.c
> +++ b/drivers/iommu/intel/irq_remapping.c
> @@ -620,7 +620,7 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu)
> out_free_bitmap:
> bitmap_free(bitmap);
> out_free_pages:
> - iommu_free_pages(ir_table_base, INTR_REMAP_PAGE_ORDER);
> + iommu_free_pages(ir_table_base);
> out_free_table:
> kfree(ir_table);
>
> @@ -641,7 +641,7 @@ static void intel_teardown_irq_remapping(struct intel_iommu *iommu)
> irq_domain_free_fwnode(fn);
> iommu->ir_domain = NULL;
> }
> - iommu_free_pages(iommu->ir_table->base, INTR_REMAP_PAGE_ORDER);
> + iommu_free_pages(iommu->ir_table->base);
> 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 fb59a7d35958f5..00da94b1c4c907 100644
> --- a/drivers/iommu/intel/pasid.c
> +++ b/drivers/iommu/intel/pasid.c
> @@ -67,7 +67,6 @@ int intel_pasid_alloc_table(struct device *dev)
> }
>
> pasid_table->table = dir;
> - pasid_table->order = order;
> pasid_table->max_pasid = 1 << (order + PAGE_SHIFT + 3);
> info->pasid_table = pasid_table;
>
> @@ -100,7 +99,7 @@ void intel_pasid_free_table(struct device *dev)
> iommu_free_page(table);
> }
>
> - iommu_free_pages(pasid_table->table, pasid_table->order);
> + iommu_free_pages(pasid_table->table);
> kfree(pasid_table);
> }
>
> diff --git a/drivers/iommu/intel/pasid.h b/drivers/iommu/intel/pasid.h
> index 668d8ece6b143c..fd0fd1a0df84cc 100644
> --- a/drivers/iommu/intel/pasid.h
> +++ b/drivers/iommu/intel/pasid.h
> @@ -47,7 +47,6 @@ struct pasid_entry {
> /* The representative of a PASID table */
> struct pasid_table {
> void *table; /* pasid table pointer */
> - int order; /* page order of pasid table */
> u32 max_pasid; /* max pasid */
> };
>
> diff --git a/drivers/iommu/intel/prq.c b/drivers/iommu/intel/prq.c
> index c2d792db52c3e2..01ecafed31453c 100644
> --- a/drivers/iommu/intel/prq.c
> +++ b/drivers/iommu/intel/prq.c
> @@ -338,7 +338,7 @@ int intel_iommu_enable_prq(struct intel_iommu *iommu)
> dmar_free_hwirq(irq);
> iommu->pr_irq = 0;
> free_prq:
> - iommu_free_pages(iommu->prq, PRQ_ORDER);
> + iommu_free_pages(iommu->prq);
> iommu->prq = NULL;
>
> return ret;
> @@ -361,7 +361,7 @@ int intel_iommu_finish_prq(struct intel_iommu *iommu)
> iommu->iopf_queue = NULL;
> }
>
> - iommu_free_pages(iommu->prq, PRQ_ORDER);
> + iommu_free_pages(iommu->prq);
> iommu->prq = NULL;
>
> return 0;
> diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c
> index 7632c80edea63a..62df2528d020b2 100644
> --- a/drivers/iommu/io-pgtable-arm.c
> +++ b/drivers/iommu/io-pgtable-arm.c
> @@ -300,7 +300,7 @@ static void *__arm_lpae_alloc_pages(size_t size, gfp_t gfp,
> if (cfg->free)
> cfg->free(cookie, pages, size);
> else
> - iommu_free_pages(pages, order);
> + iommu_free_pages(pages);
>
> return NULL;
> }
> @@ -316,7 +316,7 @@ static void __arm_lpae_free_pages(void *pages, size_t size,
> if (cfg->free)
> cfg->free(cookie, pages, size);
> else
> - iommu_free_pages(pages, get_order(size));
> + iommu_free_pages(pages);
> }
>
> static void __arm_lpae_sync_pte(arm_lpae_iopte *ptep, int num_entries,
> diff --git a/drivers/iommu/io-pgtable-dart.c b/drivers/iommu/io-pgtable-dart.c
> index c004640640ee50..7efcaea0bd5c86 100644
> --- a/drivers/iommu/io-pgtable-dart.c
> +++ b/drivers/iommu/io-pgtable-dart.c
> @@ -262,7 +262,7 @@ static int dart_map_pages(struct io_pgtable_ops *ops, unsigned long iova,
>
> pte = dart_install_table(cptep, ptep, 0, data);
> if (pte)
> - iommu_free_pages(cptep, get_order(tblsz));
> + iommu_free_pages(cptep);
>
> /* L2 table is present (now) */
> pte = READ_ONCE(*ptep);
> @@ -423,8 +423,7 @@ apple_dart_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie)
>
> out_free_data:
> while (--i >= 0) {
> - iommu_free_pages(data->pgd[i],
> - get_order(DART_GRANULE(data)));
> + iommu_free_pages(data->pgd[i]);
> }
> kfree(data);
> return NULL;
> @@ -433,7 +432,6 @@ 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;
>
> @@ -445,9 +443,9 @@ static void apple_dart_free_pgtable(struct io_pgtable *iop)
> dart_iopte pte = *ptep++;
>
> if (pte)
> - iommu_free_pages(iopte_deref(pte, data), order);
> + iommu_free_pages(iopte_deref(pte, data));
> }
> - iommu_free_pages(data->pgd[i], order);
> + iommu_free_pages(data->pgd[i]);
> }
>
> kfree(data);
> diff --git a/drivers/iommu/iommu-pages.h b/drivers/iommu/iommu-pages.h
> index 26b91940bdc146..88587da1782b94 100644
> --- a/drivers/iommu/iommu-pages.h
> +++ b/drivers/iommu/iommu-pages.h
> @@ -105,11 +105,12 @@ static inline void *iommu_alloc_page(gfp_t gfp)
> }
>
> /**
> - * iommu_free_pages - free page of a given order
> + * iommu_free_pages - free pages
> * @virt: virtual address of the page to be freed.
> - * @order: page order
> + *
> + * The page must have have been allocated by iommu_alloc_pages_node()
> */
> -static inline void iommu_free_pages(void *virt, int order)
> +static inline void iommu_free_pages(void *virt)
> {
> struct page *page;
>
> @@ -127,7 +128,7 @@ static inline void iommu_free_pages(void *virt, int order)
> */
> static inline void iommu_free_page(void *virt)
> {
> - iommu_free_pages(virt, 0);
> + iommu_free_pages(virt);
> }
>
> /**
> diff --git a/drivers/iommu/riscv/iommu.c b/drivers/iommu/riscv/iommu.c
> index 8f049d4a0e2cb8..1868468d018a28 100644
> --- a/drivers/iommu/riscv/iommu.c
> +++ b/drivers/iommu/riscv/iommu.c
> @@ -48,14 +48,13 @@ static DEFINE_IDA(riscv_iommu_pscids);
> /* Device resource-managed allocations */
> struct riscv_iommu_devres {
> void *addr;
> - int order;
> };
>
> static void riscv_iommu_devres_pages_release(struct device *dev, void *res)
> {
> struct riscv_iommu_devres *devres = res;
>
> - iommu_free_pages(devres->addr, devres->order);
> + iommu_free_pages(devres->addr);
> }
>
> static int riscv_iommu_devres_pages_match(struct device *dev, void *res, void *p)
> @@ -80,12 +79,11 @@ static void *riscv_iommu_get_pages(struct riscv_iommu_device *iommu, int order)
> sizeof(struct riscv_iommu_devres), GFP_KERNEL);
>
> if (unlikely(!devres)) {
> - iommu_free_pages(addr, order);
> + iommu_free_pages(addr);
> return NULL;
> }
>
> devres->addr = addr;
> - devres->order = order;
>
> devres_add(iommu->dev, devres);
>
> diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c
> index 8d8f11854676c0..6385560dbc3fb0 100644
> --- a/drivers/iommu/sun50i-iommu.c
> +++ b/drivers/iommu/sun50i-iommu.c
> @@ -713,7 +713,7 @@ static void sun50i_iommu_domain_free(struct iommu_domain *domain)
> {
> struct sun50i_iommu_domain *sun50i_domain = to_sun50i_domain(domain);
>
> - iommu_free_pages(sun50i_domain->dt, get_order(DT_SIZE));
> + iommu_free_pages(sun50i_domain->dt);
> sun50i_domain->dt = NULL;
>
> kfree(sun50i_domain);
> --
> 2.43.0
>
WARNING: multiple messages have this Message-ID (diff)
From: Mostafa Saleh <smostafa@google.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Alim Akhtar <alim.akhtar@samsung.com>,
Alyssa Rosenzweig <alyssa@rosenzweig.io>,
Albert Ou <aou@eecs.berkeley.edu>,
asahi@lists.linux.dev, Lu Baolu <baolu.lu@linux.intel.com>,
David Woodhouse <dwmw2@infradead.org>,
Heiko Stuebner <heiko@sntech.de>,
iommu@lists.linux.dev, Jernej Skrabec <jernej.skrabec@gmail.com>,
Jonathan Hunter <jonathanh@nvidia.com>,
Joerg Roedel <joro@8bytes.org>,
Krzysztof Kozlowski <krzk@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-riscv@lists.infradead.org,
linux-rockchip@lists.infradead.org,
linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev,
linux-tegra@vger.kernel.org,
Marek Szyprowski <m.szyprowski@samsung.com>,
Hector Martin <marcan@marcan.st>,
Palmer Dabbelt <palmer@dabbelt.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
Robin Murphy <robin.murphy@arm.com>,
Samuel Holland <samuel@sholland.org>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
Sven Peter <sven@svenpeter.dev>,
Thierry Reding <thierry.reding@gmail.com>,
Tomasz Jeznach <tjeznach@rivosinc.com>,
Krishna Reddy <vdumpa@nvidia.com>, Chen-Yu Tsai <wens@csie.org>,
Will Deacon <will@kernel.org>,
Bagas Sanjaya <bagasdotme@gmail.com>,
Joerg Roedel <jroedel@suse.de>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
patches@lists.linux.dev, David Rientjes <rientjes@google.com>,
Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH v3 05/23] iommu/pages: Remove the order argument to iommu_free_pages()
Date: Wed, 12 Mar 2025 11:43:39 +0000 [thread overview]
Message-ID: <Z9FzazECgXgE8TNX@google.com> (raw)
In-Reply-To: <5-v3-e797f4dc6918+93057-iommu_pages_jgg@nvidia.com>
On Tue, Feb 25, 2025 at 03:39:22PM -0400, Jason Gunthorpe wrote:
> Now that we have a folio under the allocation iommu_free_pages() can know
> the order of the original allocation and do the correct thing to free it.
>
> The next patch will rename iommu_free_page() to iommu_free_pages() so we
> have naming consistency with iommu_alloc_pages_node().
>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Mostafa Saleh <smostafa@google.com>
> ---
> drivers/iommu/amd/init.c | 28 +++++++++++-----------------
> drivers/iommu/amd/ppr.c | 2 +-
> drivers/iommu/exynos-iommu.c | 8 ++++----
> drivers/iommu/intel/irq_remapping.c | 4 ++--
> drivers/iommu/intel/pasid.c | 3 +--
> drivers/iommu/intel/pasid.h | 1 -
> drivers/iommu/intel/prq.c | 4 ++--
> drivers/iommu/io-pgtable-arm.c | 4 ++--
> drivers/iommu/io-pgtable-dart.c | 10 ++++------
> drivers/iommu/iommu-pages.h | 9 +++++----
> drivers/iommu/riscv/iommu.c | 6 ++----
> drivers/iommu/sun50i-iommu.c | 2 +-
> 12 files changed, 35 insertions(+), 46 deletions(-)
>
> diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
> index c5cd92edada061..f47ff0e0c75f4e 100644
> --- a/drivers/iommu/amd/init.c
> +++ b/drivers/iommu/amd/init.c
> @@ -653,8 +653,7 @@ 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)
> {
> - iommu_free_pages(pci_seg->dev_table,
> - get_order(pci_seg->dev_table_size));
> + iommu_free_pages(pci_seg->dev_table);
> pci_seg->dev_table = NULL;
> }
>
> @@ -671,8 +670,7 @@ 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)
> {
> - iommu_free_pages(pci_seg->rlookup_table,
> - get_order(pci_seg->rlookup_table_size));
> + iommu_free_pages(pci_seg->rlookup_table);
> pci_seg->rlookup_table = NULL;
> }
>
> @@ -691,8 +689,7 @@ 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);
> - iommu_free_pages(pci_seg->irq_lookup_table,
> - get_order(pci_seg->rlookup_table_size));
> + iommu_free_pages(pci_seg->irq_lookup_table);
> pci_seg->irq_lookup_table = NULL;
> }
>
> @@ -716,8 +713,7 @@ 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)
> {
> - iommu_free_pages(pci_seg->alias_table,
> - get_order(pci_seg->alias_table_size));
> + iommu_free_pages(pci_seg->alias_table);
> pci_seg->alias_table = NULL;
> }
>
> @@ -826,7 +822,7 @@ static void iommu_disable_command_buffer(struct amd_iommu *iommu)
>
> static void __init free_command_buffer(struct amd_iommu *iommu)
> {
> - iommu_free_pages(iommu->cmd_buf, get_order(CMD_BUFFER_SIZE));
> + iommu_free_pages(iommu->cmd_buf);
> }
>
> void *__init iommu_alloc_4k_pages(struct amd_iommu *iommu, gfp_t gfp,
> @@ -838,7 +834,7 @@ void *__init iommu_alloc_4k_pages(struct amd_iommu *iommu, gfp_t gfp,
> if (buf &&
> check_feature(FEATURE_SNP) &&
> set_memory_4k((unsigned long)buf, (1 << order))) {
> - iommu_free_pages(buf, order);
> + iommu_free_pages(buf);
> buf = NULL;
> }
>
> @@ -882,14 +878,14 @@ static void iommu_disable_event_buffer(struct amd_iommu *iommu)
>
> static void __init free_event_buffer(struct amd_iommu *iommu)
> {
> - iommu_free_pages(iommu->evt_buf, get_order(EVT_BUFFER_SIZE));
> + iommu_free_pages(iommu->evt_buf);
> }
>
> static void free_ga_log(struct amd_iommu *iommu)
> {
> #ifdef CONFIG_IRQ_REMAP
> - iommu_free_pages(iommu->ga_log, get_order(GA_LOG_SIZE));
> - iommu_free_pages(iommu->ga_log_tail, get_order(8));
> + iommu_free_pages(iommu->ga_log);
> + iommu_free_pages(iommu->ga_log_tail);
> #endif
> }
>
> @@ -2781,8 +2777,7 @@ static void early_enable_iommus(void)
>
> for_each_pci_segment(pci_seg) {
> if (pci_seg->old_dev_tbl_cpy != NULL) {
> - iommu_free_pages(pci_seg->old_dev_tbl_cpy,
> - get_order(pci_seg->dev_table_size));
> + iommu_free_pages(pci_seg->old_dev_tbl_cpy);
> pci_seg->old_dev_tbl_cpy = NULL;
> }
> }
> @@ -2795,8 +2790,7 @@ static void early_enable_iommus(void)
> pr_info("Copied DEV table from previous kernel.\n");
>
> for_each_pci_segment(pci_seg) {
> - iommu_free_pages(pci_seg->dev_table,
> - get_order(pci_seg->dev_table_size));
> + iommu_free_pages(pci_seg->dev_table);
> pci_seg->dev_table = pci_seg->old_dev_tbl_cpy;
> }
>
> diff --git a/drivers/iommu/amd/ppr.c b/drivers/iommu/amd/ppr.c
> index 7c67d69f0b8cad..e6767c057d01fa 100644
> --- a/drivers/iommu/amd/ppr.c
> +++ b/drivers/iommu/amd/ppr.c
> @@ -48,7 +48,7 @@ void amd_iommu_enable_ppr_log(struct amd_iommu *iommu)
>
> void __init amd_iommu_free_ppr_log(struct amd_iommu *iommu)
> {
> - iommu_free_pages(iommu->ppr_log, get_order(PPR_LOG_SIZE));
> + iommu_free_pages(iommu->ppr_log);
> }
>
> /*
> diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
> index c666ecab955d21..1019e08b43b71c 100644
> --- a/drivers/iommu/exynos-iommu.c
> +++ b/drivers/iommu/exynos-iommu.c
> @@ -932,9 +932,9 @@ static struct iommu_domain *exynos_iommu_domain_alloc_paging(struct device *dev)
> return &domain->domain;
>
> err_lv2ent:
> - iommu_free_pages(domain->lv2entcnt, 1);
> + iommu_free_pages(domain->lv2entcnt);
> err_counter:
> - iommu_free_pages(domain->pgtable, 2);
> + iommu_free_pages(domain->pgtable);
> err_pgtable:
> kfree(domain);
> return NULL;
> @@ -975,8 +975,8 @@ static void exynos_iommu_domain_free(struct iommu_domain *iommu_domain)
> phys_to_virt(base));
> }
>
> - iommu_free_pages(domain->pgtable, 2);
> - iommu_free_pages(domain->lv2entcnt, 1);
> + iommu_free_pages(domain->pgtable);
> + iommu_free_pages(domain->lv2entcnt);
> kfree(domain);
> }
>
> diff --git a/drivers/iommu/intel/irq_remapping.c b/drivers/iommu/intel/irq_remapping.c
> index ad795c772f21b5..d6b796f8f100cd 100644
> --- a/drivers/iommu/intel/irq_remapping.c
> +++ b/drivers/iommu/intel/irq_remapping.c
> @@ -620,7 +620,7 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu)
> out_free_bitmap:
> bitmap_free(bitmap);
> out_free_pages:
> - iommu_free_pages(ir_table_base, INTR_REMAP_PAGE_ORDER);
> + iommu_free_pages(ir_table_base);
> out_free_table:
> kfree(ir_table);
>
> @@ -641,7 +641,7 @@ static void intel_teardown_irq_remapping(struct intel_iommu *iommu)
> irq_domain_free_fwnode(fn);
> iommu->ir_domain = NULL;
> }
> - iommu_free_pages(iommu->ir_table->base, INTR_REMAP_PAGE_ORDER);
> + iommu_free_pages(iommu->ir_table->base);
> 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 fb59a7d35958f5..00da94b1c4c907 100644
> --- a/drivers/iommu/intel/pasid.c
> +++ b/drivers/iommu/intel/pasid.c
> @@ -67,7 +67,6 @@ int intel_pasid_alloc_table(struct device *dev)
> }
>
> pasid_table->table = dir;
> - pasid_table->order = order;
> pasid_table->max_pasid = 1 << (order + PAGE_SHIFT + 3);
> info->pasid_table = pasid_table;
>
> @@ -100,7 +99,7 @@ void intel_pasid_free_table(struct device *dev)
> iommu_free_page(table);
> }
>
> - iommu_free_pages(pasid_table->table, pasid_table->order);
> + iommu_free_pages(pasid_table->table);
> kfree(pasid_table);
> }
>
> diff --git a/drivers/iommu/intel/pasid.h b/drivers/iommu/intel/pasid.h
> index 668d8ece6b143c..fd0fd1a0df84cc 100644
> --- a/drivers/iommu/intel/pasid.h
> +++ b/drivers/iommu/intel/pasid.h
> @@ -47,7 +47,6 @@ struct pasid_entry {
> /* The representative of a PASID table */
> struct pasid_table {
> void *table; /* pasid table pointer */
> - int order; /* page order of pasid table */
> u32 max_pasid; /* max pasid */
> };
>
> diff --git a/drivers/iommu/intel/prq.c b/drivers/iommu/intel/prq.c
> index c2d792db52c3e2..01ecafed31453c 100644
> --- a/drivers/iommu/intel/prq.c
> +++ b/drivers/iommu/intel/prq.c
> @@ -338,7 +338,7 @@ int intel_iommu_enable_prq(struct intel_iommu *iommu)
> dmar_free_hwirq(irq);
> iommu->pr_irq = 0;
> free_prq:
> - iommu_free_pages(iommu->prq, PRQ_ORDER);
> + iommu_free_pages(iommu->prq);
> iommu->prq = NULL;
>
> return ret;
> @@ -361,7 +361,7 @@ int intel_iommu_finish_prq(struct intel_iommu *iommu)
> iommu->iopf_queue = NULL;
> }
>
> - iommu_free_pages(iommu->prq, PRQ_ORDER);
> + iommu_free_pages(iommu->prq);
> iommu->prq = NULL;
>
> return 0;
> diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c
> index 7632c80edea63a..62df2528d020b2 100644
> --- a/drivers/iommu/io-pgtable-arm.c
> +++ b/drivers/iommu/io-pgtable-arm.c
> @@ -300,7 +300,7 @@ static void *__arm_lpae_alloc_pages(size_t size, gfp_t gfp,
> if (cfg->free)
> cfg->free(cookie, pages, size);
> else
> - iommu_free_pages(pages, order);
> + iommu_free_pages(pages);
>
> return NULL;
> }
> @@ -316,7 +316,7 @@ static void __arm_lpae_free_pages(void *pages, size_t size,
> if (cfg->free)
> cfg->free(cookie, pages, size);
> else
> - iommu_free_pages(pages, get_order(size));
> + iommu_free_pages(pages);
> }
>
> static void __arm_lpae_sync_pte(arm_lpae_iopte *ptep, int num_entries,
> diff --git a/drivers/iommu/io-pgtable-dart.c b/drivers/iommu/io-pgtable-dart.c
> index c004640640ee50..7efcaea0bd5c86 100644
> --- a/drivers/iommu/io-pgtable-dart.c
> +++ b/drivers/iommu/io-pgtable-dart.c
> @@ -262,7 +262,7 @@ static int dart_map_pages(struct io_pgtable_ops *ops, unsigned long iova,
>
> pte = dart_install_table(cptep, ptep, 0, data);
> if (pte)
> - iommu_free_pages(cptep, get_order(tblsz));
> + iommu_free_pages(cptep);
>
> /* L2 table is present (now) */
> pte = READ_ONCE(*ptep);
> @@ -423,8 +423,7 @@ apple_dart_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie)
>
> out_free_data:
> while (--i >= 0) {
> - iommu_free_pages(data->pgd[i],
> - get_order(DART_GRANULE(data)));
> + iommu_free_pages(data->pgd[i]);
> }
> kfree(data);
> return NULL;
> @@ -433,7 +432,6 @@ 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;
>
> @@ -445,9 +443,9 @@ static void apple_dart_free_pgtable(struct io_pgtable *iop)
> dart_iopte pte = *ptep++;
>
> if (pte)
> - iommu_free_pages(iopte_deref(pte, data), order);
> + iommu_free_pages(iopte_deref(pte, data));
> }
> - iommu_free_pages(data->pgd[i], order);
> + iommu_free_pages(data->pgd[i]);
> }
>
> kfree(data);
> diff --git a/drivers/iommu/iommu-pages.h b/drivers/iommu/iommu-pages.h
> index 26b91940bdc146..88587da1782b94 100644
> --- a/drivers/iommu/iommu-pages.h
> +++ b/drivers/iommu/iommu-pages.h
> @@ -105,11 +105,12 @@ static inline void *iommu_alloc_page(gfp_t gfp)
> }
>
> /**
> - * iommu_free_pages - free page of a given order
> + * iommu_free_pages - free pages
> * @virt: virtual address of the page to be freed.
> - * @order: page order
> + *
> + * The page must have have been allocated by iommu_alloc_pages_node()
> */
> -static inline void iommu_free_pages(void *virt, int order)
> +static inline void iommu_free_pages(void *virt)
> {
> struct page *page;
>
> @@ -127,7 +128,7 @@ static inline void iommu_free_pages(void *virt, int order)
> */
> static inline void iommu_free_page(void *virt)
> {
> - iommu_free_pages(virt, 0);
> + iommu_free_pages(virt);
> }
>
> /**
> diff --git a/drivers/iommu/riscv/iommu.c b/drivers/iommu/riscv/iommu.c
> index 8f049d4a0e2cb8..1868468d018a28 100644
> --- a/drivers/iommu/riscv/iommu.c
> +++ b/drivers/iommu/riscv/iommu.c
> @@ -48,14 +48,13 @@ static DEFINE_IDA(riscv_iommu_pscids);
> /* Device resource-managed allocations */
> struct riscv_iommu_devres {
> void *addr;
> - int order;
> };
>
> static void riscv_iommu_devres_pages_release(struct device *dev, void *res)
> {
> struct riscv_iommu_devres *devres = res;
>
> - iommu_free_pages(devres->addr, devres->order);
> + iommu_free_pages(devres->addr);
> }
>
> static int riscv_iommu_devres_pages_match(struct device *dev, void *res, void *p)
> @@ -80,12 +79,11 @@ static void *riscv_iommu_get_pages(struct riscv_iommu_device *iommu, int order)
> sizeof(struct riscv_iommu_devres), GFP_KERNEL);
>
> if (unlikely(!devres)) {
> - iommu_free_pages(addr, order);
> + iommu_free_pages(addr);
> return NULL;
> }
>
> devres->addr = addr;
> - devres->order = order;
>
> devres_add(iommu->dev, devres);
>
> diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c
> index 8d8f11854676c0..6385560dbc3fb0 100644
> --- a/drivers/iommu/sun50i-iommu.c
> +++ b/drivers/iommu/sun50i-iommu.c
> @@ -713,7 +713,7 @@ static void sun50i_iommu_domain_free(struct iommu_domain *domain)
> {
> struct sun50i_iommu_domain *sun50i_domain = to_sun50i_domain(domain);
>
> - iommu_free_pages(sun50i_domain->dt, get_order(DT_SIZE));
> + iommu_free_pages(sun50i_domain->dt);
> sun50i_domain->dt = NULL;
>
> kfree(sun50i_domain);
> --
> 2.43.0
>
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
WARNING: multiple messages have this Message-ID (diff)
From: Mostafa Saleh <smostafa@google.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Alim Akhtar <alim.akhtar@samsung.com>,
Alyssa Rosenzweig <alyssa@rosenzweig.io>,
Albert Ou <aou@eecs.berkeley.edu>,
asahi@lists.linux.dev, Lu Baolu <baolu.lu@linux.intel.com>,
David Woodhouse <dwmw2@infradead.org>,
Heiko Stuebner <heiko@sntech.de>,
iommu@lists.linux.dev, Jernej Skrabec <jernej.skrabec@gmail.com>,
Jonathan Hunter <jonathanh@nvidia.com>,
Joerg Roedel <joro@8bytes.org>,
Krzysztof Kozlowski <krzk@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-riscv@lists.infradead.org,
linux-rockchip@lists.infradead.org,
linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev,
linux-tegra@vger.kernel.org,
Marek Szyprowski <m.szyprowski@samsung.com>,
Hector Martin <marcan@marcan.st>,
Palmer Dabbelt <palmer@dabbelt.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
Robin Murphy <robin.murphy@arm.com>,
Samuel Holland <samuel@sholland.org>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
Sven Peter <sven@svenpeter.dev>,
Thierry Reding <thierry.reding@gmail.com>,
Tomasz Jeznach <tjeznach@rivosinc.com>,
Krishna Reddy <vdumpa@nvidia.com>, Chen-Yu Tsai <wens@csie.org>,
Will Deacon <will@kernel.org>,
Bagas Sanjaya <bagasdotme@gmail.com>,
Joerg Roedel <jroedel@suse.de>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
patches@lists.linux.dev, David Rientjes <rientjes@google.com>,
Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH v3 05/23] iommu/pages: Remove the order argument to iommu_free_pages()
Date: Wed, 12 Mar 2025 11:43:39 +0000 [thread overview]
Message-ID: <Z9FzazECgXgE8TNX@google.com> (raw)
In-Reply-To: <5-v3-e797f4dc6918+93057-iommu_pages_jgg@nvidia.com>
On Tue, Feb 25, 2025 at 03:39:22PM -0400, Jason Gunthorpe wrote:
> Now that we have a folio under the allocation iommu_free_pages() can know
> the order of the original allocation and do the correct thing to free it.
>
> The next patch will rename iommu_free_page() to iommu_free_pages() so we
> have naming consistency with iommu_alloc_pages_node().
>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Mostafa Saleh <smostafa@google.com>
> ---
> drivers/iommu/amd/init.c | 28 +++++++++++-----------------
> drivers/iommu/amd/ppr.c | 2 +-
> drivers/iommu/exynos-iommu.c | 8 ++++----
> drivers/iommu/intel/irq_remapping.c | 4 ++--
> drivers/iommu/intel/pasid.c | 3 +--
> drivers/iommu/intel/pasid.h | 1 -
> drivers/iommu/intel/prq.c | 4 ++--
> drivers/iommu/io-pgtable-arm.c | 4 ++--
> drivers/iommu/io-pgtable-dart.c | 10 ++++------
> drivers/iommu/iommu-pages.h | 9 +++++----
> drivers/iommu/riscv/iommu.c | 6 ++----
> drivers/iommu/sun50i-iommu.c | 2 +-
> 12 files changed, 35 insertions(+), 46 deletions(-)
>
> diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
> index c5cd92edada061..f47ff0e0c75f4e 100644
> --- a/drivers/iommu/amd/init.c
> +++ b/drivers/iommu/amd/init.c
> @@ -653,8 +653,7 @@ 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)
> {
> - iommu_free_pages(pci_seg->dev_table,
> - get_order(pci_seg->dev_table_size));
> + iommu_free_pages(pci_seg->dev_table);
> pci_seg->dev_table = NULL;
> }
>
> @@ -671,8 +670,7 @@ 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)
> {
> - iommu_free_pages(pci_seg->rlookup_table,
> - get_order(pci_seg->rlookup_table_size));
> + iommu_free_pages(pci_seg->rlookup_table);
> pci_seg->rlookup_table = NULL;
> }
>
> @@ -691,8 +689,7 @@ 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);
> - iommu_free_pages(pci_seg->irq_lookup_table,
> - get_order(pci_seg->rlookup_table_size));
> + iommu_free_pages(pci_seg->irq_lookup_table);
> pci_seg->irq_lookup_table = NULL;
> }
>
> @@ -716,8 +713,7 @@ 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)
> {
> - iommu_free_pages(pci_seg->alias_table,
> - get_order(pci_seg->alias_table_size));
> + iommu_free_pages(pci_seg->alias_table);
> pci_seg->alias_table = NULL;
> }
>
> @@ -826,7 +822,7 @@ static void iommu_disable_command_buffer(struct amd_iommu *iommu)
>
> static void __init free_command_buffer(struct amd_iommu *iommu)
> {
> - iommu_free_pages(iommu->cmd_buf, get_order(CMD_BUFFER_SIZE));
> + iommu_free_pages(iommu->cmd_buf);
> }
>
> void *__init iommu_alloc_4k_pages(struct amd_iommu *iommu, gfp_t gfp,
> @@ -838,7 +834,7 @@ void *__init iommu_alloc_4k_pages(struct amd_iommu *iommu, gfp_t gfp,
> if (buf &&
> check_feature(FEATURE_SNP) &&
> set_memory_4k((unsigned long)buf, (1 << order))) {
> - iommu_free_pages(buf, order);
> + iommu_free_pages(buf);
> buf = NULL;
> }
>
> @@ -882,14 +878,14 @@ static void iommu_disable_event_buffer(struct amd_iommu *iommu)
>
> static void __init free_event_buffer(struct amd_iommu *iommu)
> {
> - iommu_free_pages(iommu->evt_buf, get_order(EVT_BUFFER_SIZE));
> + iommu_free_pages(iommu->evt_buf);
> }
>
> static void free_ga_log(struct amd_iommu *iommu)
> {
> #ifdef CONFIG_IRQ_REMAP
> - iommu_free_pages(iommu->ga_log, get_order(GA_LOG_SIZE));
> - iommu_free_pages(iommu->ga_log_tail, get_order(8));
> + iommu_free_pages(iommu->ga_log);
> + iommu_free_pages(iommu->ga_log_tail);
> #endif
> }
>
> @@ -2781,8 +2777,7 @@ static void early_enable_iommus(void)
>
> for_each_pci_segment(pci_seg) {
> if (pci_seg->old_dev_tbl_cpy != NULL) {
> - iommu_free_pages(pci_seg->old_dev_tbl_cpy,
> - get_order(pci_seg->dev_table_size));
> + iommu_free_pages(pci_seg->old_dev_tbl_cpy);
> pci_seg->old_dev_tbl_cpy = NULL;
> }
> }
> @@ -2795,8 +2790,7 @@ static void early_enable_iommus(void)
> pr_info("Copied DEV table from previous kernel.\n");
>
> for_each_pci_segment(pci_seg) {
> - iommu_free_pages(pci_seg->dev_table,
> - get_order(pci_seg->dev_table_size));
> + iommu_free_pages(pci_seg->dev_table);
> pci_seg->dev_table = pci_seg->old_dev_tbl_cpy;
> }
>
> diff --git a/drivers/iommu/amd/ppr.c b/drivers/iommu/amd/ppr.c
> index 7c67d69f0b8cad..e6767c057d01fa 100644
> --- a/drivers/iommu/amd/ppr.c
> +++ b/drivers/iommu/amd/ppr.c
> @@ -48,7 +48,7 @@ void amd_iommu_enable_ppr_log(struct amd_iommu *iommu)
>
> void __init amd_iommu_free_ppr_log(struct amd_iommu *iommu)
> {
> - iommu_free_pages(iommu->ppr_log, get_order(PPR_LOG_SIZE));
> + iommu_free_pages(iommu->ppr_log);
> }
>
> /*
> diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
> index c666ecab955d21..1019e08b43b71c 100644
> --- a/drivers/iommu/exynos-iommu.c
> +++ b/drivers/iommu/exynos-iommu.c
> @@ -932,9 +932,9 @@ static struct iommu_domain *exynos_iommu_domain_alloc_paging(struct device *dev)
> return &domain->domain;
>
> err_lv2ent:
> - iommu_free_pages(domain->lv2entcnt, 1);
> + iommu_free_pages(domain->lv2entcnt);
> err_counter:
> - iommu_free_pages(domain->pgtable, 2);
> + iommu_free_pages(domain->pgtable);
> err_pgtable:
> kfree(domain);
> return NULL;
> @@ -975,8 +975,8 @@ static void exynos_iommu_domain_free(struct iommu_domain *iommu_domain)
> phys_to_virt(base));
> }
>
> - iommu_free_pages(domain->pgtable, 2);
> - iommu_free_pages(domain->lv2entcnt, 1);
> + iommu_free_pages(domain->pgtable);
> + iommu_free_pages(domain->lv2entcnt);
> kfree(domain);
> }
>
> diff --git a/drivers/iommu/intel/irq_remapping.c b/drivers/iommu/intel/irq_remapping.c
> index ad795c772f21b5..d6b796f8f100cd 100644
> --- a/drivers/iommu/intel/irq_remapping.c
> +++ b/drivers/iommu/intel/irq_remapping.c
> @@ -620,7 +620,7 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu)
> out_free_bitmap:
> bitmap_free(bitmap);
> out_free_pages:
> - iommu_free_pages(ir_table_base, INTR_REMAP_PAGE_ORDER);
> + iommu_free_pages(ir_table_base);
> out_free_table:
> kfree(ir_table);
>
> @@ -641,7 +641,7 @@ static void intel_teardown_irq_remapping(struct intel_iommu *iommu)
> irq_domain_free_fwnode(fn);
> iommu->ir_domain = NULL;
> }
> - iommu_free_pages(iommu->ir_table->base, INTR_REMAP_PAGE_ORDER);
> + iommu_free_pages(iommu->ir_table->base);
> 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 fb59a7d35958f5..00da94b1c4c907 100644
> --- a/drivers/iommu/intel/pasid.c
> +++ b/drivers/iommu/intel/pasid.c
> @@ -67,7 +67,6 @@ int intel_pasid_alloc_table(struct device *dev)
> }
>
> pasid_table->table = dir;
> - pasid_table->order = order;
> pasid_table->max_pasid = 1 << (order + PAGE_SHIFT + 3);
> info->pasid_table = pasid_table;
>
> @@ -100,7 +99,7 @@ void intel_pasid_free_table(struct device *dev)
> iommu_free_page(table);
> }
>
> - iommu_free_pages(pasid_table->table, pasid_table->order);
> + iommu_free_pages(pasid_table->table);
> kfree(pasid_table);
> }
>
> diff --git a/drivers/iommu/intel/pasid.h b/drivers/iommu/intel/pasid.h
> index 668d8ece6b143c..fd0fd1a0df84cc 100644
> --- a/drivers/iommu/intel/pasid.h
> +++ b/drivers/iommu/intel/pasid.h
> @@ -47,7 +47,6 @@ struct pasid_entry {
> /* The representative of a PASID table */
> struct pasid_table {
> void *table; /* pasid table pointer */
> - int order; /* page order of pasid table */
> u32 max_pasid; /* max pasid */
> };
>
> diff --git a/drivers/iommu/intel/prq.c b/drivers/iommu/intel/prq.c
> index c2d792db52c3e2..01ecafed31453c 100644
> --- a/drivers/iommu/intel/prq.c
> +++ b/drivers/iommu/intel/prq.c
> @@ -338,7 +338,7 @@ int intel_iommu_enable_prq(struct intel_iommu *iommu)
> dmar_free_hwirq(irq);
> iommu->pr_irq = 0;
> free_prq:
> - iommu_free_pages(iommu->prq, PRQ_ORDER);
> + iommu_free_pages(iommu->prq);
> iommu->prq = NULL;
>
> return ret;
> @@ -361,7 +361,7 @@ int intel_iommu_finish_prq(struct intel_iommu *iommu)
> iommu->iopf_queue = NULL;
> }
>
> - iommu_free_pages(iommu->prq, PRQ_ORDER);
> + iommu_free_pages(iommu->prq);
> iommu->prq = NULL;
>
> return 0;
> diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c
> index 7632c80edea63a..62df2528d020b2 100644
> --- a/drivers/iommu/io-pgtable-arm.c
> +++ b/drivers/iommu/io-pgtable-arm.c
> @@ -300,7 +300,7 @@ static void *__arm_lpae_alloc_pages(size_t size, gfp_t gfp,
> if (cfg->free)
> cfg->free(cookie, pages, size);
> else
> - iommu_free_pages(pages, order);
> + iommu_free_pages(pages);
>
> return NULL;
> }
> @@ -316,7 +316,7 @@ static void __arm_lpae_free_pages(void *pages, size_t size,
> if (cfg->free)
> cfg->free(cookie, pages, size);
> else
> - iommu_free_pages(pages, get_order(size));
> + iommu_free_pages(pages);
> }
>
> static void __arm_lpae_sync_pte(arm_lpae_iopte *ptep, int num_entries,
> diff --git a/drivers/iommu/io-pgtable-dart.c b/drivers/iommu/io-pgtable-dart.c
> index c004640640ee50..7efcaea0bd5c86 100644
> --- a/drivers/iommu/io-pgtable-dart.c
> +++ b/drivers/iommu/io-pgtable-dart.c
> @@ -262,7 +262,7 @@ static int dart_map_pages(struct io_pgtable_ops *ops, unsigned long iova,
>
> pte = dart_install_table(cptep, ptep, 0, data);
> if (pte)
> - iommu_free_pages(cptep, get_order(tblsz));
> + iommu_free_pages(cptep);
>
> /* L2 table is present (now) */
> pte = READ_ONCE(*ptep);
> @@ -423,8 +423,7 @@ apple_dart_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie)
>
> out_free_data:
> while (--i >= 0) {
> - iommu_free_pages(data->pgd[i],
> - get_order(DART_GRANULE(data)));
> + iommu_free_pages(data->pgd[i]);
> }
> kfree(data);
> return NULL;
> @@ -433,7 +432,6 @@ 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;
>
> @@ -445,9 +443,9 @@ static void apple_dart_free_pgtable(struct io_pgtable *iop)
> dart_iopte pte = *ptep++;
>
> if (pte)
> - iommu_free_pages(iopte_deref(pte, data), order);
> + iommu_free_pages(iopte_deref(pte, data));
> }
> - iommu_free_pages(data->pgd[i], order);
> + iommu_free_pages(data->pgd[i]);
> }
>
> kfree(data);
> diff --git a/drivers/iommu/iommu-pages.h b/drivers/iommu/iommu-pages.h
> index 26b91940bdc146..88587da1782b94 100644
> --- a/drivers/iommu/iommu-pages.h
> +++ b/drivers/iommu/iommu-pages.h
> @@ -105,11 +105,12 @@ static inline void *iommu_alloc_page(gfp_t gfp)
> }
>
> /**
> - * iommu_free_pages - free page of a given order
> + * iommu_free_pages - free pages
> * @virt: virtual address of the page to be freed.
> - * @order: page order
> + *
> + * The page must have have been allocated by iommu_alloc_pages_node()
> */
> -static inline void iommu_free_pages(void *virt, int order)
> +static inline void iommu_free_pages(void *virt)
> {
> struct page *page;
>
> @@ -127,7 +128,7 @@ static inline void iommu_free_pages(void *virt, int order)
> */
> static inline void iommu_free_page(void *virt)
> {
> - iommu_free_pages(virt, 0);
> + iommu_free_pages(virt);
> }
>
> /**
> diff --git a/drivers/iommu/riscv/iommu.c b/drivers/iommu/riscv/iommu.c
> index 8f049d4a0e2cb8..1868468d018a28 100644
> --- a/drivers/iommu/riscv/iommu.c
> +++ b/drivers/iommu/riscv/iommu.c
> @@ -48,14 +48,13 @@ static DEFINE_IDA(riscv_iommu_pscids);
> /* Device resource-managed allocations */
> struct riscv_iommu_devres {
> void *addr;
> - int order;
> };
>
> static void riscv_iommu_devres_pages_release(struct device *dev, void *res)
> {
> struct riscv_iommu_devres *devres = res;
>
> - iommu_free_pages(devres->addr, devres->order);
> + iommu_free_pages(devres->addr);
> }
>
> static int riscv_iommu_devres_pages_match(struct device *dev, void *res, void *p)
> @@ -80,12 +79,11 @@ static void *riscv_iommu_get_pages(struct riscv_iommu_device *iommu, int order)
> sizeof(struct riscv_iommu_devres), GFP_KERNEL);
>
> if (unlikely(!devres)) {
> - iommu_free_pages(addr, order);
> + iommu_free_pages(addr);
> return NULL;
> }
>
> devres->addr = addr;
> - devres->order = order;
>
> devres_add(iommu->dev, devres);
>
> diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c
> index 8d8f11854676c0..6385560dbc3fb0 100644
> --- a/drivers/iommu/sun50i-iommu.c
> +++ b/drivers/iommu/sun50i-iommu.c
> @@ -713,7 +713,7 @@ static void sun50i_iommu_domain_free(struct iommu_domain *domain)
> {
> struct sun50i_iommu_domain *sun50i_domain = to_sun50i_domain(domain);
>
> - iommu_free_pages(sun50i_domain->dt, get_order(DT_SIZE));
> + iommu_free_pages(sun50i_domain->dt);
> sun50i_domain->dt = NULL;
>
> kfree(sun50i_domain);
> --
> 2.43.0
>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2025-03-12 11:43 UTC|newest]
Thread overview: 165+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-25 19:39 [PATCH v3 00/23] iommu: Further abstract iommu-pages Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` [PATCH v3 01/23] iommu/terga: Do not use struct page as the handle for as->pd memory Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` [PATCH v3 02/23] iommu/tegra: Do not use struct page as the handle for pts Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` [PATCH v3 03/23] iommu/pages: Remove __iommu_alloc_pages()/__iommu_free_pages() Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-26 6:25 ` Baolu Lu
2025-02-26 6:25 ` Baolu Lu
2025-02-26 6:25 ` Baolu Lu
2025-03-12 11:43 ` Mostafa Saleh
2025-03-12 11:43 ` Mostafa Saleh
2025-03-12 11:43 ` Mostafa Saleh
2025-02-25 19:39 ` [PATCH v3 04/23] iommu/pages: Make iommu_put_pages_list() work with high order allocations Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-26 6:28 ` Baolu Lu
2025-02-26 6:28 ` Baolu Lu
2025-02-26 6:28 ` Baolu Lu
2025-02-25 19:39 ` [PATCH v3 05/23] iommu/pages: Remove the order argument to iommu_free_pages() Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-26 6:32 ` Baolu Lu
2025-02-26 6:32 ` Baolu Lu
2025-02-26 6:32 ` Baolu Lu
2025-03-12 11:43 ` Mostafa Saleh [this message]
2025-03-12 11:43 ` Mostafa Saleh
2025-03-12 11:43 ` Mostafa Saleh
2025-02-25 19:39 ` [PATCH v3 06/23] iommu/pages: Remove iommu_free_page() Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-26 6:34 ` Baolu Lu
2025-02-26 6:34 ` Baolu Lu
2025-02-26 6:34 ` Baolu Lu
2025-03-12 11:44 ` Mostafa Saleh
2025-03-12 11:44 ` Mostafa Saleh
2025-03-12 11:44 ` Mostafa Saleh
2025-02-25 19:39 ` [PATCH v3 07/23] iommu/pages: De-inline the substantial functions Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-26 6:43 ` Baolu Lu
2025-02-26 6:43 ` Baolu Lu
2025-02-26 6:43 ` Baolu Lu
2025-03-12 12:45 ` Mostafa Saleh
2025-03-12 12:45 ` Mostafa Saleh
2025-03-12 12:45 ` Mostafa Saleh
2025-02-25 19:39 ` [PATCH v3 08/23] iommu/vtd: Use virt_to_phys() Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-03-10 2:21 ` Baolu Lu
2025-03-10 2:21 ` Baolu Lu
2025-03-10 2:21 ` Baolu Lu
2025-02-25 19:39 ` [PATCH v3 09/23] iommu/pages: Formalize the freelist API Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-26 6:56 ` Baolu Lu
2025-02-26 6:56 ` Baolu Lu
2025-02-26 6:56 ` Baolu Lu
2025-02-26 17:31 ` Jason Gunthorpe
2025-02-26 17:31 ` Jason Gunthorpe
2025-02-26 17:31 ` Jason Gunthorpe
2025-02-27 5:11 ` Baolu Lu
2025-02-27 5:11 ` Baolu Lu
2025-02-27 5:11 ` Baolu Lu
2025-02-25 19:39 ` [PATCH v3 10/23] iommu/riscv: Convert to use struct iommu_pages_list Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` [PATCH v3 11/23] iommu/amd: " Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` [PATCH v3 12/23] iommu: Change iommu_iotlb_gather to use iommu_page_list Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-26 7:02 ` Baolu Lu
2025-02-26 7:02 ` Baolu Lu
2025-02-26 7:02 ` Baolu Lu
2025-02-25 19:39 ` [PATCH v3 13/23] iommu/pages: Remove iommu_put_pages_list_old and the _Generic Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-26 7:04 ` Baolu Lu
2025-02-26 7:04 ` Baolu Lu
2025-02-26 7:04 ` Baolu Lu
2025-02-25 19:39 ` [PATCH v3 14/23] iommu/pages: Move from struct page to struct ioptdesc and folio Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-26 12:42 ` Baolu Lu
2025-02-26 12:42 ` Baolu Lu
2025-02-26 12:42 ` Baolu Lu
2025-02-26 13:51 ` Jason Gunthorpe
2025-02-26 13:51 ` Jason Gunthorpe
2025-02-26 13:51 ` Jason Gunthorpe
2025-02-27 5:17 ` Baolu Lu
2025-02-27 5:17 ` Baolu Lu
2025-02-27 5:17 ` Baolu Lu
2025-02-27 5:17 ` Baolu Lu
2025-02-27 5:17 ` Baolu Lu
2025-02-27 5:17 ` Baolu Lu
2025-02-25 19:39 ` [PATCH v3 15/23] iommu/pages: Move the __GFP_HIGHMEM checks into the common code Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-03-12 12:45 ` Mostafa Saleh
2025-03-12 12:45 ` Mostafa Saleh
2025-03-12 12:45 ` Mostafa Saleh
2025-02-25 19:39 ` [PATCH v3 16/23] iommu/pages: Allow sub page sizes to be passed into the allocator Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-26 12:22 ` Baolu Lu
2025-02-26 12:22 ` Baolu Lu
2025-02-26 12:22 ` Baolu Lu
2025-02-25 19:39 ` [PATCH v3 17/23] iommu/amd: Change rlookup, irq_lookup, and alias to use kvalloc() Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` [PATCH v3 18/23] iommu/amd: Use roundup_pow_two() instead of get_order() Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` [PATCH v3 19/23] iommu/riscv: Update to use iommu_alloc_pages_node_lg2() Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` [PATCH v3 20/23] iommu: Update various drivers to pass in lg2sz instead of order to iommu pages Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-26 12:24 ` Baolu Lu
2025-02-26 12:24 ` Baolu Lu
2025-02-26 12:24 ` Baolu Lu
2025-03-12 12:59 ` Mostafa Saleh
2025-03-12 12:59 ` Mostafa Saleh
2025-03-12 12:59 ` Mostafa Saleh
2025-03-17 13:35 ` Jason Gunthorpe
2025-03-17 13:35 ` Jason Gunthorpe
2025-03-17 13:35 ` Jason Gunthorpe
2025-03-18 10:46 ` Mostafa Saleh
2025-03-18 10:46 ` Mostafa Saleh
2025-03-18 10:46 ` Mostafa Saleh
2025-03-18 10:57 ` Robin Murphy
2025-03-18 10:57 ` Robin Murphy
2025-03-18 10:57 ` Robin Murphy
2025-02-25 19:39 ` [PATCH v3 21/23] iommu/pages: Remove iommu_alloc_page/pages() Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-26 9:15 ` Marek Szyprowski
2025-02-26 9:15 ` Marek Szyprowski
2025-02-26 9:15 ` Marek Szyprowski
2025-02-25 19:39 ` [PATCH v3 22/23] iommu/pages: Remove iommu_alloc_page_node() Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-26 12:26 ` Baolu Lu
2025-02-26 12:26 ` Baolu Lu
2025-02-26 12:26 ` Baolu Lu
2025-02-25 19:39 ` [PATCH v3 23/23] iommu/pages: Remove iommu_alloc_pages_node() Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-25 19:39 ` Jason Gunthorpe
2025-02-26 12:30 ` Baolu Lu
2025-02-26 12:30 ` Baolu Lu
2025-02-26 12:30 ` Baolu Lu
2025-02-25 20:18 ` [PATCH v3 00/23] iommu: Further abstract iommu-pages Nicolin Chen
2025-02-25 20:18 ` Nicolin Chen
2025-02-25 20:18 ` Nicolin Chen
2025-02-25 23:17 ` Alejandro Jimenez
2025-02-25 23:17 ` Alejandro Jimenez
2025-02-25 23:17 ` Alejandro Jimenez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z9FzazECgXgE8TNX@google.com \
--to=smostafa@google.com \
--cc=alim.akhtar@samsung.com \
--cc=alyssa@rosenzweig.io \
--cc=aou@eecs.berkeley.edu \
--cc=asahi@lists.linux.dev \
--cc=bagasdotme@gmail.com \
--cc=baolu.lu@linux.intel.com \
--cc=dwmw2@infradead.org \
--cc=heiko@sntech.de \
--cc=iommu@lists.linux.dev \
--cc=jernej.skrabec@gmail.com \
--cc=jgg@nvidia.com \
--cc=jonathanh@nvidia.com \
--cc=joro@8bytes.org \
--cc=jroedel@suse.de \
--cc=krzk@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=linux-tegra@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=marcan@marcan.st \
--cc=palmer@dabbelt.com \
--cc=pasha.tatashin@soleen.com \
--cc=patches@lists.linux.dev \
--cc=paul.walmsley@sifive.com \
--cc=rientjes@google.com \
--cc=robin.murphy@arm.com \
--cc=samuel@sholland.org \
--cc=suravee.suthikulpanit@amd.com \
--cc=sven@svenpeter.dev \
--cc=thierry.reding@gmail.com \
--cc=tjeznach@rivosinc.com \
--cc=vdumpa@nvidia.com \
--cc=wens@csie.org \
--cc=will@kernel.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.