Skip to content

Commit d175d69

Browse files
avpatelpalmer-dabbelt
authored andcommitted
RISC-V: Rename and move plic_find_hart_id() to arch directory
The plic_find_hart_id() can be useful to other interrupt controller drivers (such as RISC-V local interrupt driver) so we rename this function to riscv_of_parent_hartid() and place it in arch directory along with riscv_of_processor_hartid(). Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Palmer Dabbelt <[email protected]> Acked-by: Palmer Dabbelt <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]> Reviewed-by: Marc Zyngier <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 5cf998b commit d175d69

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

arch/riscv/include/asm/processor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ static inline void wait_for_interrupt(void)
7575

7676
struct device_node;
7777
int riscv_of_processor_hartid(struct device_node *node);
78+
int riscv_of_parent_hartid(struct device_node *node);
7879

7980
extern void riscv_fill_hwcap(void);
8081

arch/riscv/kernel/cpu.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,22 @@ int riscv_of_processor_hartid(struct device_node *node)
4444
return hart;
4545
}
4646

47+
/*
48+
* Find hart ID of the CPU DT node under which given DT node falls.
49+
*
50+
* To achieve this, we walk up the DT tree until we find an active
51+
* RISC-V core (HART) node and extract the cpuid from it.
52+
*/
53+
int riscv_of_parent_hartid(struct device_node *node)
54+
{
55+
for (; node; node = node->parent) {
56+
if (of_device_is_compatible(node, "riscv"))
57+
return riscv_of_processor_hartid(node);
58+
}
59+
60+
return -1;
61+
}
62+
4763
#ifdef CONFIG_PROC_FS
4864

4965
static void print_isa(struct seq_file *f, const char *isa)

drivers/irqchip/irq-sifive-plic.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -240,20 +240,6 @@ static void plic_handle_irq(struct pt_regs *regs)
240240
csr_set(CSR_IE, IE_EIE);
241241
}
242242

243-
/*
244-
* Walk up the DT tree until we find an active RISC-V core (HART) node and
245-
* extract the cpuid from it.
246-
*/
247-
static int plic_find_hart_id(struct device_node *node)
248-
{
249-
for (; node; node = node->parent) {
250-
if (of_device_is_compatible(node, "riscv"))
251-
return riscv_of_processor_hartid(node);
252-
}
253-
254-
return -1;
255-
}
256-
257243
static void plic_set_threshold(struct plic_handler *handler, u32 threshold)
258244
{
259245
/* priority must be > threshold to trigger an interrupt */
@@ -330,7 +316,7 @@ static int __init plic_init(struct device_node *node,
330316
if (parent.args[0] != RV_IRQ_EXT)
331317
continue;
332318

333-
hartid = plic_find_hart_id(parent.np);
319+
hartid = riscv_of_parent_hartid(parent.np);
334320
if (hartid < 0) {
335321
pr_warn("failed to parse hart ID for context %d.\n", i);
336322
continue;

0 commit comments

Comments
 (0)