irq: Add irq_tasks, move NVMe to it

This commit is contained in:
2026-10-30 00:21:36 +01:00
parent 49c454dd97
commit 829490f8c8
7 changed files with 107 additions and 55 deletions
+10 -4
View File
@@ -23,12 +23,11 @@ struct nvme_irq_handler {
struct nvme_ctrl* controller;
};
static enum irq_status nvme_irq_raise(struct irq_handler* self) {
static void nvme_irq_thread(struct irq_handler* self) {
struct nvme_irq_handler* handler = containerof(self, struct nvme_irq_handler, handler);
struct nvme_io_queue* queue = nvme_ctrl_io_queue(handler->controller);
if (queue)
nvme_io_queue_drain(queue);
return IRQ_STATUS_HANDLED;
}
static errno_t map_bar(struct pci_bar* bar, void** out) {
@@ -84,9 +83,16 @@ static errno_t nvme_pci_probe(struct pci_device* dev, const struct pci_match* ma
struct nvme_irq_handler* handler = mem_alloc(sizeof(*handler), 0);
if (!handler)
return ENOMEM;
handler->handler.raise = nvme_irq_raise;
handler->handler.thread = nvme_irq_thread;
handler->controller = controller;
irq_line_attach(irq_line, &handler->handler);
char name[32];
ksnprintf(name, sizeof(name), "nvme-" PCI_ADDR_FMT, PCI_ADDR_ARGS(&dev->address));
status = irq_line_attach_task(irq_line, &handler->handler, name);
if (status) {
mem_free(handler);
return status;
}
if (irq_line->unmask)
irq_line->unmask(irq_line);
}