• David Collins's avatar
    spmi: spmi-pmic-arb: fix irq_set_type race condition · 1b18af40
    David Collins authored
    The qpnpint_irq_set_type() callback function configures the type
    (edge vs level) and polarity (high, low, or both) of a particular
    PMIC interrupt within a given peripheral.  To do this, it reads
    the three consecutive IRQ configuration registers, modifies the
    specified IRQ bit within the register values, and finally writes
    the three modified register values back to the PMIC.  While a
    spinlock is used to provide mutual exclusion on the SPMI bus
    during the register read and write calls, there is no locking
    around the overall read, modify, write sequence.  This opens up
    the possibility of a race condition if two tasks set the type of
    a PMIC IRQ within the same peripheral simultaneously.
    
    When the race condition is encountered, both tasks will read the
    old value of the registers and IRQ bits set by one of the tasks
    will be dropped upon the register write of the other task.  This
    then leads to PMIC IRQs being enabled with an incorrect type and
    polarity config...
    1b18af40
spmi-pmic-arb.c 39.4 KB