How to handling PLIC interrupt on Linux?

PLIC’ interrupt is claim to M-mode.
But Linux kernel is runnning on S-mode.

How to handling (and controll )PLIC interrupt on Linux ?

I can not found source-ode to solve these.

The Linux interface to the PLIC for device drivers is through generic, non-platform-specific mechanisms, such as request_irq(). Here is an example of how the SiFive serial port driver interacts with the generic Linux interrupt API:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/serial/sifive.c#n971

The PLIC driver itself, which connects the PLIC to the standard Linux interrupt controller core code, is here:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/irqchip/irq-sifive-plic.c

Oh, really?
PLIC interrupt directly notify to S-mode?

Does section 3.1.8 “Machine Trap Delegation Registers (medeleg and mideleg)” of the RISC-V Privileged ISA Specification v20190608-Priv-MSU-Ratified provide the information you’re looking for?

https://github.com/riscv/riscv-isa-manual/releases/download/draft-20190608-f467e5d/riscv-privileged.pdf

Yes. I see document.
But,
U54 manual written,
mideleg SSIP/STIP/SEIP only.
By default, all interrupts are handled in machine mode.

So , I think that require software for from M-mode MEIP to S-mode SEIP.
Am I wrong?

Right now, mainline Linux can’t run on RISC-V systems by itself. Users generally either use BBL:

or OpenSBI:

as companion software. Among other tasks, these two software packages write to medeleg and mideleg to delegate exceptions and interrupts to supervisor mode.

1 Like

Thank you.
I found what I wanted.