Patch "uio: uio_dmem_genirq: Fix deadlock between irq config and handling" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    uio: uio_dmem_genirq: Fix deadlock between irq config and handling

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     uio-uio_dmem_genirq-fix-deadlock-between-irq-config-.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 3ee68aea3d494ee573ffe2162689207a9e696e06
Author: Rafael Mendonca <rafaelmendsr@xxxxxxxxx>
Date:   Fri Sep 30 19:40:58 2022 -0300

    uio: uio_dmem_genirq: Fix deadlock between irq config and handling
    
    [ Upstream commit 118b918018175d9fcd8db667f905012e986cc2c9 ]
    
    This fixes a concurrency issue addressed in commit 34cb27528398 ("UIO: Fix
    concurrency issue"):
    
      "In a SMP case there was a race condition issue between
      Uio_pdrv_genirq_irqcontrol() running on one CPU and irq handler on
      another CPU. Fix it by spin_locking shared resources access inside irq
      handler."
    
    The implementation of "uio_dmem_genirq" was based on "uio_pdrv_genirq" and
    it is used in a similar manner to the "uio_pdrv_genirq" driver with respect
    to interrupt configuration and handling. At the time "uio_dmem_genirq" was
    merged, both had the same implementation of the 'uio_info' handlers
    irqcontrol() and handler(), thus, both had the same concurrency issue
    mentioned by the above commit. However, the above patch was only applied to
    the "uio_pdrv_genirq" driver.
    
    Split out from commit 34cb27528398 ("UIO: Fix concurrency issue").
    
    Fixes: 0a0c3b5a24bd ("Add new uio device for dynamic memory allocation")
    Signed-off-by: Rafael Mendonca <rafaelmendsr@xxxxxxxxx>
    Link: https://lore.kernel.org/r/20220930224100.816175-3-rafaelmendsr@xxxxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/uio/uio_dmem_genirq.c b/drivers/uio/uio_dmem_genirq.c
index c25a6bcb2d21..b4b7fa05b29b 100644
--- a/drivers/uio/uio_dmem_genirq.c
+++ b/drivers/uio/uio_dmem_genirq.c
@@ -113,8 +113,10 @@ static irqreturn_t uio_dmem_genirq_handler(int irq, struct uio_info *dev_info)
 	 * remember the state so we can allow user space to enable it later.
 	 */
 
+	spin_lock(&priv->lock);
 	if (!test_and_set_bit(0, &priv->flags))
 		disable_irq_nosync(irq);
+	spin_unlock(&priv->lock);
 
 	return IRQ_HANDLED;
 }
@@ -128,7 +130,8 @@ static int uio_dmem_genirq_irqcontrol(struct uio_info *dev_info, s32 irq_on)
 	 * in the interrupt controller, but keep track of the
 	 * state to prevent per-irq depth damage.
 	 *
-	 * Serialize this operation to support multiple tasks.
+	 * Serialize this operation to support multiple tasks and concurrency
+	 * with irq handler on SMP systems.
 	 */
 
 	spin_lock_irqsave(&priv->lock, flags);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux