Commit 8b05e7d0 authored by Andrew Jones's avatar Andrew Jones Committed by Palmer Dabbelt

RISC-V: Factor out body of riscv_init_cbom_blocksize loop

Refactor riscv_init_cbom_blocksize() to prepare for it to be used
for both cbom block size and cboz block size.
Signed-off-by: default avatarAndrew Jones <ajones@ventanamicro.com>
Reviewed-by: default avatarHeiko Stuebner <heiko@sntech.de>
Reviewed-by: default avatarConor Dooley <conor.dooley@microchip.com>
Link: https://lore.kernel.org/r/20230224162631.405473-3-ajones@ventanamicro.comSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
parent 0b2f658f
...@@ -100,34 +100,39 @@ void flush_icache_pte(pte_t pte) ...@@ -100,34 +100,39 @@ void flush_icache_pte(pte_t pte)
unsigned int riscv_cbom_block_size; unsigned int riscv_cbom_block_size;
EXPORT_SYMBOL_GPL(riscv_cbom_block_size); EXPORT_SYMBOL_GPL(riscv_cbom_block_size);
static void cbo_get_block_size(struct device_node *node,
const char *name, u32 *block_size,
unsigned long *first_hartid)
{
unsigned long hartid;
u32 val;
if (riscv_of_processor_hartid(node, &hartid))
return;
if (of_property_read_u32(node, name, &val))
return;
if (!*block_size) {
*block_size = val;
*first_hartid = hartid;
} else if (*block_size != val) {
pr_warn("%s mismatched between harts %lu and %lu\n",
name, *first_hartid, hartid);
}
}
void riscv_init_cbom_blocksize(void) void riscv_init_cbom_blocksize(void)
{ {
struct device_node *node; struct device_node *node;
unsigned long cbom_hartid; unsigned long cbom_hartid;
u32 val, probed_block_size; u32 probed_block_size;
int ret;
probed_block_size = 0; probed_block_size = 0;
for_each_of_cpu_node(node) { for_each_of_cpu_node(node) {
unsigned long hartid;
ret = riscv_of_processor_hartid(node, &hartid);
if (ret)
continue;
/* set block-size for cbom extension if available */ /* set block-size for cbom extension if available */
ret = of_property_read_u32(node, "riscv,cbom-block-size", &val); cbo_get_block_size(node, "riscv,cbom-block-size",
if (ret) &probed_block_size, &cbom_hartid);
continue;
if (!probed_block_size) {
probed_block_size = val;
cbom_hartid = hartid;
} else {
if (probed_block_size != val)
pr_warn("cbom-block-size mismatched between harts %lu and %lu\n",
cbom_hartid, hartid);
}
} }
if (probed_block_size) if (probed_block_size)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment