正在使用 polarfire soc , risc-v 多核处理器,产生中断疑问?

polarfire soc 是一个 5核 risc-v 处理器, 1个 RV64IMAC 和 4个 RV64GC 处理器, 包含 CLINT 和 PLIC ;

问题:比如串口外设产生全局中断时,则 5个内核都会产生中断,跳转到 各自对应的 MTVEC 对应地址 处理 ?

有没有 大佬路过 解答下 谢谢

4 个赞

当一个串口产生外部中断时,PLIC 会广播给全部使能的 hart,使能的 hart 都会进入 handle_exception->do_irq ,但是只有一个 hart 会读到非零的 hwirq,处理中断。

获取中断的操作是通过读取 claim 寄存器完成的。

The U54-MC Core Complex can perform an interrupt claim by reading the claim/complete register (Table 8.10), which returns the ID of the highest priority pending interrupt or zero if there is no pending interrupt. A successful claim will also atomically clear the corresponding pending bit on the interrupt source. [1]

static void plic_handle_irq(struct irq_desc *desc)
{
	struct plic_handler *handler = this_cpu_ptr(&plic_handlers);
	struct irq_chip *chip = irq_desc_get_chip(desc);
	void __iomem *claim = handler->hart_base + CONTEXT_CLAIM;
	irq_hw_number_t hwirq;

	WARN_ON_ONCE(!handler->present);

	chained_irq_enter(chip, desc);

	while ((hwirq = readl(claim))) {
		int err = generic_handle_domain_irq(handler->priv->irqdomain,
						    hwirq);
		if (unlikely(err)) {
			pr_warn_ratelimited("%pfwP: can't find mapping for hwirq %lu\n",
					    handler->priv->fwnode, hwirq);
		}
	}

	chained_irq_exit(chip, desc);
}

只有一个 hart 会读到非零的 hwirq
while ((hwirq = readl(claim)))

[2]

没有读取到 hwirq (claim 失败)的 hart 不会进入处理流程。

获取 irq 的流程 [3]

[1] https://static.dev.sifive.com/U54-MC-RVCoreIP.pdf (chapter 8)
[2] https://elixir.bootlin.com/linux/v6.15/source/drivers/irqchip/irq-sifive-plic.c#L374
[3] https://five-embeddev.com/riscv-priv-isa-manual/Priv-v1.12/plic.html#fig:intflow
5 个赞

非常感谢!

1 个赞