Skip to content

Commit 8cd010b

Browse files
mjchen0jhedberg
authored andcommitted
drivers: mbox: imx_mu: return early in ISR when done
Change the ISR code to return once all pended interrupts are handled instead of continuing to iterate over all channels. Common occurence is just for one interrupt bit to be set so no need to check all bits in all channels if only one bit is pending. Signed-off-by: Mike J. Chen <[email protected]>
1 parent 13e0588 commit 8cd010b

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

drivers/mbox/mbox_nxp_imx_mu.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static void mu_isr(const struct device *dev)
181181
{
182182
struct nxp_imx_mu_data *data = dev->data;
183183
const struct nxp_imx_mu_config *config = dev->config;
184-
const uint32_t flags = MU_GetStatusFlags(config->base);
184+
uint32_t flags = MU_GetStatusFlags(config->base);
185185

186186
for (int i_channel = 0; i_channel < MU_MAX_CHANNELS; i_channel++) {
187187
/* Handle notification interrupt for the channel first and
@@ -199,6 +199,13 @@ static void mu_isr(const struct device *dev)
199199
data->cb[i_channel](dev, i_channel, data->user_data[i_channel],
200200
NULL);
201201
}
202+
/* Clear the interrupt just handled and break
203+
* if no more pending.
204+
*/
205+
flags &= ~gen_int_mask;
206+
if (flags == 0) {
207+
break;
208+
}
202209
}
203210

204211
const uint32_t rx_int_mask = g_rx_flag_mask[i_channel];
@@ -211,6 +218,13 @@ static void mu_isr(const struct device *dev)
211218
data->cb[i_channel](dev, i_channel, data->user_data[i_channel],
212219
&msg);
213220
}
221+
/* Clear the interrupt just handled and break
222+
* if no more pending.
223+
*/
224+
flags &= ~rx_int_mask;
225+
if (flags == 0) {
226+
break;
227+
}
214228
}
215229
}
216230
}

0 commit comments

Comments
 (0)