mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	iommu@lists.linux.dev
Cc: Marek Szyprowski <m.szyprowski@samsung.com>,
	Rob Herring <robh@kernel.org>,
	Saravana Kannan <saravanak@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>
Subject: [PATCH] of: reserved_mem: Drop node_fixup, CMA can handle it internally again
Date: Thu,  5 Nov 2026 22:54:11 +0100	[thread overview]
Message-ID: <20261105215413.1439745-1-m.szyprowski@samsung.com> (raw)
In-Reply-To: <CGME20261105215426eucas1p1fb2de3113bd185a84e1d0925e14fc4fc@eucas1p1.samsung.com>

The separate fixup step was needed because node initialization used to
run too late, after paging_init(). Since commit aa05faf81583 ("of:
reserved_mem: allocate and map the reserved_mem array early") node_init
runs early enough again, so dma_contiguous_early_fixup() can be called
directly from rmem_cma_setup() once the CMA region has been successfully
initialized, as it was before commit 2c223f7239f37 ("of: reserved_mem:
Restructure call site for dma_contiguous_early_fixup()").

Drop the now unused node_fixup callback and its helper. This also fixes
the premature call to fixup when region fails to initialize.

Closes: https://sashiko.dev/#/bug/linux-61818eaa-5dc1-4457-bd21-3a9be2ed4d6d
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
 drivers/of/of_reserved_mem.c    | 34 ---------------------------------
 include/linux/of_reserved_mem.h |  2 --
 kernel/dma/contiguous.c         | 17 +++--------------
 3 files changed, 3 insertions(+), 50 deletions(-)

diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 0fd1683cba01..e7764f57438b 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -86,8 +86,6 @@ static void fdt_init_reserved_mem_node(unsigned long node, const char *uname,
 				       phys_addr_t base, phys_addr_t size);
 static int fdt_validate_reserved_mem_node(unsigned long node,
 					  phys_addr_t *align);
-static int fdt_fixup_reserved_mem_node(unsigned long node,
-				       phys_addr_t base, phys_addr_t size);
 
 static int __init early_init_dt_reserve_memory(phys_addr_t base,
 					       phys_addr_t size, bool nomap)
@@ -139,7 +137,6 @@ static int __init __reserved_mem_reserve_reg(unsigned long node,
 	size = s;
 
 	if (size && early_init_dt_reserve_memory(base, size, nomap) == 0) {
-		fdt_fixup_reserved_mem_node(node, base, size);
 		pr_debug("Reserved memory: reserved region for node '%s': base %pa, size %lu MiB\n",
 			 uname, &base, (unsigned long)(size / SZ_1M));
 	} else {
@@ -305,7 +302,6 @@ static int __init __reserved_mem_alloc_size(unsigned long node, const char *unam
 		return -ENOMEM;
 	}
 
-	fdt_fixup_reserved_mem_node(node, base, size);
 	fdt_init_reserved_mem_node(node, uname, base, size);
 
 	return 0;
@@ -494,36 +490,6 @@ extern const struct of_device_id __reservedmem_of_table[];
 static const struct of_device_id __rmem_of_table_sentinel
 	__used __section("__reservedmem_of_table_end");
 
-/**
- * fdt_fixup_reserved_mem_node() - call fixup function for a reserved memory node
- * @node: FDT node to fixup
- * @base: base address of the reserved memory region
- * @size: size of the reserved memory region
- *
- * This function iterates through the reserved memory drivers and calls
- * the node_fixup callback for the compatible entry matching the node.
- *
- * Return: 0 on success, -ENODEV if no compatible match found
- */
-static int __init fdt_fixup_reserved_mem_node(unsigned long node,
-					phys_addr_t base, phys_addr_t size)
-{
-	const struct of_device_id *i;
-	int ret = -ENODEV;
-
-	for (i = __reservedmem_of_table; ret == -ENODEV &&
-	     i < &__rmem_of_table_sentinel; i++) {
-		const struct reserved_mem_ops *ops = i->data;
-
-		if (!of_flat_dt_is_compatible(node, i->compatible))
-			continue;
-
-		if (ops->node_fixup)
-			ret = ops->node_fixup(node, base, size);
-	}
-	return ret;
-}
-
 /**
  * fdt_validate_reserved_mem_node() - validate a reserved memory node
  * @node: FDT node to validate
diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h
index 49da515859f2..7a940d1815b6 100644
--- a/include/linux/of_reserved_mem.h
+++ b/include/linux/of_reserved_mem.h
@@ -19,8 +19,6 @@ struct reserved_mem {
 
 struct reserved_mem_ops {
 	int	(*node_validate)(unsigned long fdt_node, phys_addr_t *align);
-	int	(*node_fixup)(unsigned long fdt_node, phys_addr_t base,
-			      phys_addr_t size);
 	int	(*node_init)(unsigned long fdt_node, struct reserved_mem *rmem);
 	int	(*device_init)(struct reserved_mem *rmem,
 			       struct device *dev);
diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
index 90937dc7c627..9acb092ab7d6 100644
--- a/kernel/dma/contiguous.c
+++ b/kernel/dma/contiguous.c
@@ -529,19 +529,6 @@ static int __init rmem_cma_validate(unsigned long node, phys_addr_t *align)
 	return 0;
 }
 
-static int __init rmem_cma_fixup(unsigned long node, phys_addr_t base,
-				    phys_addr_t size)
-{
-	int ret = __rmem_cma_verify_node(node);
-
-	if (ret)
-		return ret;
-
-	/* Architecture specific contiguous memory fixup. */
-	dma_contiguous_early_fixup(base, size);
-	return 0;
-}
-
 static int __init rmem_cma_setup(unsigned long node, struct reserved_mem *rmem)
 {
 	bool default_cma = of_get_flat_dt_prop(node, "linux,cma-default", NULL);
@@ -563,6 +550,9 @@ static int __init rmem_cma_setup(unsigned long node, struct reserved_mem *rmem)
 		return ret;
 	}
 
+	/* Architecture specific contiguous memory fixup. */
+	dma_contiguous_early_fixup(rmem->base, rmem->size);
+
 	if (default_cma)
 		dma_contiguous_default_area = cma;
 
@@ -580,7 +570,6 @@ static int __init rmem_cma_setup(unsigned long node, struct reserved_mem *rmem)
 
 static const struct reserved_mem_ops rmem_cma_ops = {
 	.node_validate  = rmem_cma_validate,
-	.node_fixup	= rmem_cma_fixup,
 	.node_init	= rmem_cma_setup,
 	.device_init	= rmem_cma_device_init,
 	.device_release = rmem_cma_device_release,
-- 
2.43.0


           reply	other threads:[~2026-11-05 21:54 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <CGME20261105215426eucas1p1fb2de3113bd185a84e1d0925e14fc4fc@eucas1p1.samsung.com>]

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=20261105215413.1439745-1-m.szyprowski@samsung.com \
    --to=m.szyprowski@samsung.com \
    --cc=devicetree@vger.kernel.org \
    --cc=iommu@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=saravanak@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®