[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240125164256.4147-15-alexandru.elisei@arm.com>
Date: Thu, 25 Jan 2024 16:42:35 +0000
From: Alexandru Elisei <alexandru.elisei@....com>
To: catalin.marinas@....com,
will@...nel.org,
oliver.upton@...ux.dev,
maz@...nel.org,
james.morse@....com,
suzuki.poulose@....com,
yuzenghui@...wei.com,
arnd@...db.de,
akpm@...ux-foundation.org,
mingo@...hat.com,
peterz@...radead.org,
juri.lelli@...hat.com,
vincent.guittot@...aro.org,
dietmar.eggemann@....com,
rostedt@...dmis.org,
bsegall@...gle.com,
mgorman@...e.de,
bristot@...hat.com,
vschneid@...hat.com,
mhiramat@...nel.org,
rppt@...nel.org,
hughd@...gle.com
Cc: pcc@...gle.com,
steven.price@....com,
anshuman.khandual@....com,
vincenzo.frascino@....com,
david@...hat.com,
eugenis@...gle.com,
kcc@...gle.com,
hyesoo.yu@...sung.com,
linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org,
kvmarm@...ts.linux.dev,
linux-fsdevel@...r.kernel.org,
linux-arch@...r.kernel.org,
linux-mm@...ck.org,
linux-trace-kernel@...r.kernel.org
Subject: [PATCH RFC v3 14/35] of: fdt: Return the region size in of_flat_dt_translate_address()
Alongside the base address, arm64 will also need to know the size of a
tag storage region. Teach of_flat_dt_translate_address() to parse and
return the size.
Signed-off-by: Alexandru Elisei <alexandru.elisei@....com>
---
Changes since rfc v2:
* New patch, suggested by Rob Herring.
arch/sh/kernel/cpu/sh2/probe.c | 2 +-
drivers/of/fdt_address.c | 12 +++++++++---
drivers/tty/serial/earlycon.c | 2 +-
include/linux/of_fdt.h | 2 +-
4 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/arch/sh/kernel/cpu/sh2/probe.c b/arch/sh/kernel/cpu/sh2/probe.c
index 70a07f4f2142..fa8904e8f390 100644
--- a/arch/sh/kernel/cpu/sh2/probe.c
+++ b/arch/sh/kernel/cpu/sh2/probe.c
@@ -21,7 +21,7 @@ static int __init scan_cache(unsigned long node, const char *uname,
if (!of_flat_dt_is_compatible(node, "jcore,cache"))
return 0;
- j2_ccr_base = ioremap(of_flat_dt_translate_address(node), 4);
+ j2_ccr_base = ioremap(of_flat_dt_translate_address(node, NULL), 4);
return 1;
}
diff --git a/drivers/of/fdt_address.c b/drivers/of/fdt_address.c
index 1dc15ab78b10..4c077778d710 100644
--- a/drivers/of/fdt_address.c
+++ b/drivers/of/fdt_address.c
@@ -160,7 +160,8 @@ static int __init fdt_translate_one(const void *blob, int parent,
* that can be mapped to a cpu physical address). This is not really specified
* that way, but this is traditionally the way IBM at least do things
*/
-static u64 __init fdt_translate_address(const void *blob, int node_offset)
+static u64 __init fdt_translate_address(const void *blob, int node_offset,
+ u64 *out_size)
{
int parent, len;
const struct of_bus *bus, *pbus;
@@ -193,6 +194,9 @@ static u64 __init fdt_translate_address(const void *blob, int node_offset)
goto bail;
}
memcpy(addr, reg, na * 4);
+ /* The size of the region doesn't need translating. */
+ if (out_size)
+ *out_size = of_read_number(reg + na, ns);
pr_debug("bus (na=%d, ns=%d) on %s\n",
na, ns, fdt_get_name(blob, parent, NULL));
@@ -242,8 +246,10 @@ static u64 __init fdt_translate_address(const void *blob, int node_offset)
/**
* of_flat_dt_translate_address - translate DT addr into CPU phys addr
* @node: node in the flat blob
+ * @out_size: size of the region, can be NULL if not needed
+ * @return: the address, OF_BAD_ADDR in case of error
*/
-u64 __init of_flat_dt_translate_address(unsigned long node)
+u64 __init of_flat_dt_translate_address(unsigned long node, u64 *out_size)
{
- return fdt_translate_address(initial_boot_params, node);
+ return fdt_translate_address(initial_boot_params, node, out_size);
}
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index a5fbb6ed38ae..e941cf786232 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -265,7 +265,7 @@ int __init of_setup_earlycon(const struct earlycon_id *match,
spin_lock_init(&port->lock);
port->iotype = UPIO_MEM;
- addr = of_flat_dt_translate_address(node);
+ addr = of_flat_dt_translate_address(node, NULL);
if (addr == OF_BAD_ADDR) {
pr_warn("[%s] bad address\n", match->name);
return -ENXIO;
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index d69ad5bb1eb1..0e26f8c3b10e 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -36,7 +36,7 @@ extern char __dtb_start[];
extern char __dtb_end[];
/* Other Prototypes */
-extern u64 of_flat_dt_translate_address(unsigned long node);
+extern u64 of_flat_dt_translate_address(unsigned long node, u64 *out_size);
extern void of_fdt_limit_memory(int limit);
#endif /* CONFIG_OF_FLATTREE */
--
2.43.0
Powered by blists - more mailing lists