imx9/lpuart: Fix race condition / regression in imx9_txint

Commit 83a119160 fixed SMP by removing call to uart_xmitchars from inside spinlock.

This only works for SMP, since uart_xmitchars has a lock only in SMP. In a single
core configuration the function can be called in parallel from the interrupt
handler and from the imx9_txint.

Fix this by filling the uart buffers already before enabling the
interrupt, this way it is not possible to get the function called in parallel
for the same device.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
This commit is contained in:
Jukka Laitinen 2025-07-01 14:44:42 +03:00 committed by Alan C. Assis
parent 55bef681e1
commit 5594c2e887

View file

@ -2340,6 +2340,13 @@ static void imx9_txint(struct uart_dev_s *dev, bool enable)
irqstate_t flags;
uint32_t regval;
#ifndef CONFIG_SUPPRESS_SERIAL_INTS
if (enable)
{
uart_xmitchars(dev);
}
#endif
/* Enable interrupt for TX complete */
flags = spin_lock_irqsave(&priv->lock);
@ -2359,13 +2366,6 @@ static void imx9_txint(struct uart_dev_s *dev, bool enable)
regval |= priv->ie;
imx9_serialout(priv, IMX9_LPUART_CTRL_OFFSET, regval);
spin_unlock_irqrestore(&priv->lock, flags);
#ifndef CONFIG_SUPPRESS_SERIAL_INTS
if (enable)
{
uart_xmitchars(dev);
}
#endif
}
#endif