Skip to content

Commit 13e0588

Browse files
mjchen0jhedberg
authored andcommitted
drivers: mbox: imx_mu: change order of interrupt handling
Handle notification interrupt before data interrupt of a channel. Notification interrupts are more commonly used (e.g. for ipc) and clearing the interrupt ASAP helps reduce the possiblility that the sender finds the interrupt already pending if it tries to send multiple ipc messages in quick succession. Signed-off-by: Mike J. Chen <[email protected]>
1 parent 3c80b15 commit 13e0588

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

drivers/mbox/mbox_nxp_imx_mu.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,25 @@ static void mu_isr(const struct device *dev)
184184
const uint32_t flags = MU_GetStatusFlags(config->base);
185185

186186
for (int i_channel = 0; i_channel < MU_MAX_CHANNELS; i_channel++) {
187-
const uint32_t rx_int_mask = g_rx_flag_mask[i_channel];
187+
/* Handle notification interrupt for the channel first and
188+
* then handle the data ready interrupt for the channel.
189+
* Notification interrupts are more commonly used (e.g. for
190+
* ipc) and clearing the interrupt ASAP reduces the chance
191+
* the other side gets an error when pending a new interrupt
192+
* if it is sending multiple IPC messages in quick succession.
193+
*/
188194
const uint32_t gen_int_mask = g_gen_int_pend_mask[i_channel];
189195

196+
if ((flags & gen_int_mask) == gen_int_mask) {
197+
MU_ClearStatusFlags(config->base, gen_int_mask);
198+
if (data->cb[i_channel]) {
199+
data->cb[i_channel](dev, i_channel, data->user_data[i_channel],
200+
NULL);
201+
}
202+
}
203+
204+
const uint32_t rx_int_mask = g_rx_flag_mask[i_channel];
205+
190206
if ((flags & rx_int_mask) == rx_int_mask) {
191207
data->received_data = MU_ReceiveMsgNonBlocking(config->base, i_channel);
192208
struct mbox_msg msg = {(const void *)&data->received_data, MU_MBOX_SIZE};
@@ -196,13 +212,5 @@ static void mu_isr(const struct device *dev)
196212
&msg);
197213
}
198214
}
199-
if ((flags & gen_int_mask) == gen_int_mask) {
200-
MU_ClearStatusFlags(config->base, gen_int_mask);
201-
if (data->cb[i_channel]) {
202-
data->cb[i_channel](dev, i_channel, data->user_data[i_channel],
203-
NULL);
204-
}
205-
}
206-
207215
}
208216
}

0 commit comments

Comments
 (0)