Root Cause Analysis
The warning is triggered because parport_attach() in drivers/comedi/drivers/comedi_parport.c passes a user-supplied IRQ number (it->options[1]) directly to request_irq() without checking whether the target IRQ descriptor is a per-CPU interrupt (IRQ_PER_CPU_DEVID) or whether the platform even supports legacy ISA IRQs.
Trigger Path
- Userspace invokes the
COMEDI_DEVCONFIG ioctl (comedi_unlocked_ioctl() -> do_devconfig_ioctl() in drivers/comedi/comedi_fops.c), passing a struct comedi_devconfig with board_name matching "comedi_parport" and options[0] / options[1] specifying the I/O base address and IRQ number (requires CAP_SYS_ADMIN).
do_devconfig_ioctl() calls comedi_device_attach() (drivers/comedi/drivers.c:1101), which invokes parport_attach(dev, it) (drivers/comedi/drivers/comedi_parport.c:231).
- After claiming the I/O port region via
comedi_check_request_region(), parport_attach() checks (drivers/comedi/drivers/comedi_parport.c:247-252):
/* only ISA interrupts are valid on a parallel port */
if (it->options[1] >= 1 && it->options[1] <= 15) {
ret = request_irq(it->options[1], parport_interrupt, 0,
dev->board_name, dev);
if (ret == 0)
dev->irq = it->options[1];
}
- Unlike
CONFIG_COMEDI_ISA_DRIVERS (which depends on ISA || ISA_BUS || PC104), CONFIG_COMEDI_PARPORT in drivers/comedi/Kconfig only depends on HAS_IOPORT. On non-ISA architectures with CONFIG_HAS_IOPORT=y (such as RISC-V riscv-virtio), Linux IRQ numbers 1..15 are dynamically assigned virtual IRQs rather than fixed ISA IRQs, and may be mapped to per-CPU interruptsβfor example by riscv_intc_domain_map() (drivers/irqchip/irq-riscv-intc.c:128), which calls irq_set_percpu_devid(irq) and sets _IRQ_PER_CPU_DEVID in desc->status_use_accessors.
request_irq() calls request_threaded_irq() (kernel/irq/manage.c:2171-2173):
if (!irq_settings_can_request(desc) ||
WARN_ON(irq_settings_is_per_cpu_devid(desc)))
return -EINVAL;
Because irq_settings_is_per_cpu_devid(desc) is true for the per-CPU IRQ, request_threaded_irq() hits the WARN_ON at kernel/irq/manage.c:2172 and returns -EINVAL.
Fix Direction
parport_attach() should validate that the requested IRQ is not a per-CPU devid IRQ (e.g., via !irq_is_percpu_devid(it->options[1])) before calling request_irq(), and/or COMEDI_PARPORT (or its ISA IRQ request path) should be gated appropriately when legacy ISA interrupts are unavailable.