uio: use threaded interrupts
authorChris Packham <chris.packham@alliedtelesis.co.nz>
Mon, 8 Apr 2024 23:40:49 +0000 (11:40 +1200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 Apr 2024 12:40:29 +0000 (14:40 +0200)
Split the existing uio_interrupt into a hardirq handler and a thread
function. The hardirq handler deals with the interrupt source in
hardware, the thread function notifies userspace that there is an event
to be handled.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20240408234050.2056374-3-chris.packham@alliedtelesis.co.nz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/uio/uio.c

index 009158fef2a8f1ed82fb3fb7a4c4a9b5764e723b..e815856eb46c956d4ac0d103b4539d82cff87eea 100644 (file)
@@ -442,18 +442,27 @@ EXPORT_SYMBOL_GPL(uio_event_notify);
  * @irq: IRQ number, can be UIO_IRQ_CYCLIC for cyclic timer
  * @dev_id: Pointer to the devices uio_device structure
  */
-static irqreturn_t uio_interrupt(int irq, void *dev_id)
+static irqreturn_t uio_interrupt_handler(int irq, void *dev_id)
 {
        struct uio_device *idev = (struct uio_device *)dev_id;
        irqreturn_t ret;
 
        ret = idev->info->handler(irq, idev->info);
        if (ret == IRQ_HANDLED)
-               uio_event_notify(idev->info);
+               ret = IRQ_WAKE_THREAD;
 
        return ret;
 }
 
+static irqreturn_t uio_interrupt_thread(int irq, void *dev_id)
+{
+       struct uio_device *idev = (struct uio_device *)dev_id;
+
+       uio_event_notify(idev->info);
+
+       return IRQ_HANDLED;
+}
+
 struct uio_listener {
        struct uio_device *dev;
        s32 event_count;
@@ -1024,8 +1033,8 @@ int __uio_register_device(struct module *owner,
                 * FDs at the time of unregister and therefore may not be
                 * freed until they are released.
                 */
-               ret = request_irq(info->irq, uio_interrupt,
-                                 info->irq_flags, info->name, idev);
+               ret = request_threaded_irq(info->irq, uio_interrupt_handler, uio_interrupt_thread,
+                                          info->irq_flags, info->name, idev);
                if (ret) {
                        info->uio_dev = NULL;
                        goto err_request_irq;