// SPDX-License-Identifier: GPL-2.0 /* * Functions related to interrupt-poll handling in the block layer. This * is similar to NAPI for network devices. */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/init.h> #include <linux/bio.h> #include <linux/interrupt.h> #include <linux/cpu.h> #include <linux/irq_poll.h> #include <linux/delay.h> static unsigned int irq_poll_budget __read_mostly = …; static DEFINE_PER_CPU(struct list_head, blk_cpu_iopoll); /** * irq_poll_sched - Schedule a run of the iopoll handler * @iop: The parent iopoll structure * * Description: * Add this irq_poll structure to the pending poll list and trigger the * raise of the blk iopoll softirq. **/ void irq_poll_sched(struct irq_poll *iop) { … } EXPORT_SYMBOL(…); /** * __irq_poll_complete - Mark this @iop as un-polled again * @iop: The parent iopoll structure * * Description: * See irq_poll_complete(). This function must be called with interrupts * disabled. **/ static void __irq_poll_complete(struct irq_poll *iop) { … } /** * irq_poll_complete - Mark this @iop as un-polled again * @iop: The parent iopoll structure * * Description: * If a driver consumes less than the assigned budget in its run of the * iopoll handler, it'll end the polled mode by calling this function. The * iopoll handler will not be invoked again before irq_poll_sched() * is called. **/ void irq_poll_complete(struct irq_poll *iop) { … } EXPORT_SYMBOL(…); static void __latent_entropy irq_poll_softirq(void) { … } /** * irq_poll_disable - Disable iopoll on this @iop * @iop: The parent iopoll structure * * Description: * Disable io polling and wait for any pending callbacks to have completed. **/ void irq_poll_disable(struct irq_poll *iop) { … } EXPORT_SYMBOL(…); /** * irq_poll_enable - Enable iopoll on this @iop * @iop: The parent iopoll structure * * Description: * Enable iopoll on this @iop. Note that the handler run will not be * scheduled, it will only mark it as active. **/ void irq_poll_enable(struct irq_poll *iop) { … } EXPORT_SYMBOL(…); /** * irq_poll_init - Initialize this @iop * @iop: The parent iopoll structure * @weight: The default weight (or command completion budget) * @poll_fn: The handler to invoke * * Description: * Initialize and enable this irq_poll structure. **/ void irq_poll_init(struct irq_poll *iop, int weight, irq_poll_fn *poll_fn) { … } EXPORT_SYMBOL(…); static int irq_poll_cpu_dead(unsigned int cpu) { … } static __init int irq_poll_setup(void) { … } subsys_initcall(irq_poll_setup);