mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 22:14:03 +02:00
mailbox: qcom-cpucp: fix PREEMPT_RT self-deadlock in IRQ handler
qcom_cpucp_mbox_irq_fn() calls mbox_chan_received_data() while holding
chan->lock. Under PREEMPT_RT, spin_lock_irqsave() is converted to an
rt_spinlock (rtmutex-based), which tracks ownership and can sleep.
The callback chain triggered by mbox_chan_received_data() eventually
reaches mailbox_clear_channel() -> mbox_send_message() -> add_to_rbuf(),
which attempts to re-acquire the same chan->lock. Since rtmutex detects
the re-entrant lock attempt by the same owner, the thread blocks waiting
for a lock it already holds, causing a permanent deadlock.
This deadlock manifests as 'irq/N-apss_cpucp_mbox' stuck in D state
with the following call trace:
rt_spin_lock -> mbox_send_message -> mailbox_clear_channel ->
scmi_rx_callback -> mbox_chan_received_data [<- held chan->lock here]
Fix by saving chan->cl locally and clearing the HW interrupt register
inside the lock, then invoking mbox_chan_received_data() after releasing
the lock. This preserves the mutual exclusion for chan->cl access while
avoiding the lock re-entrancy that causes the PREEMPT_RT deadlock.
Fixes: 0e2a9a0310 ("mailbox: Add support for QTI CPUCP mailbox controller")
Signed-off-by: Jia Yang <jia.yang@oss.qualcomm.com>
Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>
This commit is contained in:
parent
9e9afcb436
commit
3690aaa6d1
|
|
@ -63,14 +63,25 @@ static irqreturn_t qcom_cpucp_mbox_irq_fn(int irq, void *data)
|
|||
for_each_set_bit(i, (unsigned long *)&status, cpucp->mbox.num_chans) {
|
||||
u32 val = readl(cpucp->rx_base + APSS_CPUCP_RX_MBOX_CMD(i) + APSS_CPUCP_MBOX_CMD_OFF);
|
||||
struct mbox_chan *chan = &cpucp->chans[i];
|
||||
struct mbox_client *cl;
|
||||
unsigned long flags;
|
||||
|
||||
/* Provide mutual exclusion with changes to chan->cl */
|
||||
/*
|
||||
* Provide mutual exclusion with changes to chan->cl.
|
||||
* Save cl locally and clear the HW interrupt inside the lock,
|
||||
* then invoke mbox_chan_received_data() outside the lock to
|
||||
* avoid a PREEMPT_RT self-deadlock: mbox_chan_received_data()
|
||||
* can call back into mbox_send_message() via scmi_rx_callback()
|
||||
* -> mailbox_clear_channel(), which re-acquires chan->lock
|
||||
* (converted to an rt_spinlock under PREEMPT_RT).
|
||||
*/
|
||||
spin_lock_irqsave(&chan->lock, flags);
|
||||
if (chan->cl)
|
||||
mbox_chan_received_data(chan, &val);
|
||||
cl = chan->cl;
|
||||
writeq(BIT(i), cpucp->rx_base + APSS_CPUCP_RX_MBOX_CLEAR);
|
||||
spin_unlock_irqrestore(&chan->lock, flags);
|
||||
|
||||
if (cl)
|
||||
mbox_chan_received_data(chan, &val);
|
||||
}
|
||||
|
||||
return IRQ_HANDLED;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user