Skip to content

Commit 0d3616b

Browse files
Niklas CasselMarc Zyngier
authored andcommitted
irqchip/sifive-plic: Improve naming scheme for per context offsets
The PLIC supports a fixed number of contexts (15872). Each context has fixed register offsets in PLIC. The number of contexts that we need to initialize depends on the privilege modes supported by each hart. Therefore, this mapping between PLIC context registers to hart privilege modes is platform specific, and is currently supplied via device tree. For example, canaan,k210 has the following mapping: Context0: hart0 M-mode Context1: hart0 S-mode Context2: hart1 M-mode Context3: hart1 S-mode While sifive,fu540 has the following mapping: Context0: hart0 M-mode Context1: hart1 M-mode Context2: hart1 S-mode Because the number of contexts per hart is not fixed, the names ENABLE_PER_HART and CONTEXT_PER_HART for the register offsets are quite confusing and might mislead the reader to think that these are fixed register offsets per hart. Rename the offsets to more clearly highlight that these are per PLIC context and not per hart. Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com> Reviewed-by: Anup Patel <anup@brainfault.org> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20220302131544.3166154-2-Niklas.Cassel@wdc.com
1 parent dfd42fa commit 0d3616b

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

drivers/irqchip/irq-sifive-plic.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@
4444
* Each hart context has a vector of interrupt enable bits associated with it.
4545
* There's one bit for each interrupt source.
4646
*/
47-
#define ENABLE_BASE 0x2000
48-
#define ENABLE_PER_HART 0x80
47+
#define CONTEXT_ENABLE_BASE 0x2000
48+
#define CONTEXT_ENABLE_SIZE 0x80
4949

5050
/*
5151
* Each hart context has a set of control registers associated with it. Right
5252
* now there's only two: a source priority threshold over which the hart will
5353
* take an interrupt, and a register to claim interrupts.
5454
*/
5555
#define CONTEXT_BASE 0x200000
56-
#define CONTEXT_PER_HART 0x1000
56+
#define CONTEXT_SIZE 0x1000
5757
#define CONTEXT_THRESHOLD 0x00
5858
#define CONTEXT_CLAIM 0x04
5959

@@ -361,11 +361,11 @@ static int __init plic_init(struct device_node *node,
361361

362362
cpumask_set_cpu(cpu, &priv->lmask);
363363
handler->present = true;
364-
handler->hart_base =
365-
priv->regs + CONTEXT_BASE + i * CONTEXT_PER_HART;
364+
handler->hart_base = priv->regs + CONTEXT_BASE +
365+
i * CONTEXT_SIZE;
366366
raw_spin_lock_init(&handler->enable_lock);
367-
handler->enable_base =
368-
priv->regs + ENABLE_BASE + i * ENABLE_PER_HART;
367+
handler->enable_base = priv->regs + CONTEXT_ENABLE_BASE +
368+
i * CONTEXT_ENABLE_SIZE;
369369
handler->priv = priv;
370370
done:
371371
for (hwirq = 1; hwirq <= nr_irqs; hwirq++)

0 commit comments

Comments
 (0)