serial: msm_geni: validate RX data with IRQ status
PATCH 1/1 serial: msm_geni: validate RX data with IRQ status
The GENI UART hardware can retain stale data in the RX FIFO. The msm_serial_pending() function was reporting this stale data as pending input, causing U-Boot to incorrectly assume a key press and stop at the CLI prompt instead of continuing the boot process.
Add IRQ status validation to distinguish between legitimate received data and stale FIFO contents. Check the Secondary IRQ status register for RX watermark or last flags before reporting pending data. If the FIFO contains data but no valid IRQ flags are set, ignore it as stale.
--- drivers/serial/serial_msm_geni.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-)
drivers/serial/serial_msm_geni.c +22 -5
@@ -424,13 +424,30 @@ static int msm_serial_getc(struct udevice *dev)static int msm_serial_pending (struct udevice *dev,bool input) {struct msm_serial_data *priv =dev_get_priv (dev); - -if (input) -return readl (priv->base +SE_GENI_RX_FIFO_STATUS ) & -RX_FIFO_WC_MSK ; -else +u32 rx_fifo_status, s_irq_status; +int result; + +if (input) { + rx_fifo_status =readl (priv->base +SE_GENI_RX_FIFO_STATUS ); + result = rx_fifo_status &RX_FIFO_WC_MSK ; + +/* +* Validate RX data with IRQ status +* Only report pending data if valid RX IRQ indicators are set. +*/ +if (result) { + s_irq_status =readl (priv->base +SE_GENI_S_IRQ_STATUS ); + +if (!(s_irq_status & (S_RX_FIFO_WATERMARK_EN |S_RX_FIFO_LAST_EN ))) { +/* No valid RX IRQ, ignore stale data */ +return 0 ; + } + } +return result; + }else {return readl (priv->base +SE_GENI_TX_FIFO_STATUS ) &TX_FIFO_WC_MSK ; + }return 0 ; }
---
base-commit: 6902fb4c17faa375003124c451c2550deab5463d
change-id: 20260629-uart-e07d893e4508
Best regards,
Signature · 1 line
Balaji Selvanathan <[email protected]>
Quoted 44 lines · Balaji Selvanathan
The GENI UART hardware can retain stale data in the RX FIFO. The
msm_serial_pending()function was reporting this stale data as pending input, causing U-Boot to incorrectly assume a key press and stop at the CLI prompt instead of continuing the boot process.Add IRQ status validation to distinguish between legitimate received data and stale FIFO contents. Check the Secondary IRQ status register for RX watermark or last flags before reporting pending data. If the FIFO contains data but no valid IRQ flags are set, ignore it as stale.
Signed-off-by Balaji Selvanathan <[email protected]>--- drivers/serial/serial_msm_geni.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-)drivers/serial/serial_msm_geni.c +16
-5@@ -424,13 +424,30 @@ static int msm_serial_getc(struct udevice *dev)static int msm_serial_pending (struct udevice *dev,bool input) {struct msm_serial_data *priv =dev_get_priv (dev); - -if (input) -return readl (priv->base +SE_GENI_RX_FIFO_STATUS ) & -RX_FIFO_WC_MSK ; -else +u32 rx_fifo_status, s_irq_status; +int result; + +if (input) { + rx_fifo_status =readl (priv->base +SE_GENI_RX_FIFO_STATUS ); + result = rx_fifo_status &RX_FIFO_WC_MSK ; + +/* +* Validate RX data with IRQ status +* Only report pending data if valid RX IRQ indicators are set. +*/ +if (result) { + s_irq_status =readl (priv->base +SE_GENI_S_IRQ_STATUS ); + +if (!(s_irq_status & (S_RX_FIFO_WATERMARK_EN |S_RX_FIFO_LAST_EN ))) { +/* No valid RX IRQ, ignore stale data */
drivers/serial/serial_msm_geni.c static int msm_serial_getc(struct udevice *dev) · line 452
Quoted 10 lines
drivers/serial/serial_msm_geni.c +6
-0+return 0 ; + } + } +return result; + }else {return readl (priv->base +SE_GENI_TX_FIFO_STATUS ) &TX_FIFO_WC_MSK ; + }return 0 ;
It won't reach here...
Quoted 10 lines
drivers/serial/serial_msm_geni.c +0
-1} ---base-commit:
6902fb4c17faa375003124c451c2550deab5463d
change-id: 20260629-uart-e07d893e4508Best regards,
--
Balaji Selvanathan <[email protected]>
Hi Balaji,
Quoted 9 lines · Balaji Selvanathan
The GENI UART hardware can retain stale data in the RX FIFO. The
msm_serial_pending()function was reporting this stale data as pending input, causing U-Boot to incorrectly assume a key press and stop at the CLI prompt instead of continuing the boot process.Add IRQ status validation to distinguish between legitimate received data and stale FIFO contents. Check the Secondary IRQ status register for RX watermark or last flags before reporting pending data. If the FIFO contains data but no valid IRQ flags are set, ignore it as stale.
Taking a look here compared to the Linux polling mode driver I don't think this is the right way to solve this.
In qcom_geni_serial_stop_rx_fifo() in Linux after clearing the RX IRQs the cancel command is sent (and polled on) and then if S_RX_FIFO_LAST_EN is set the FIFO is drained.
So the right fix here for U-Boot would be to do something similar in msm_geni_serial_setup_rx(), send a cancel rather than an abort, wait for it to complete (or timeout), drain the fifo, and then send an abort if S_GENI_CMD_ACTIVE is still set to fully reset it.
so NAK, please solve this properly by fixing the init sequence.
Quoted 19 lines
Signed-off-by Balaji Selvanathan <[email protected]>--- drivers/serial/serial_msm_geni.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-)drivers/serial/serial_msm_geni.c +0
-5@@ -424,13 +424,30 @@ static int msm_serial_getc(struct udevice *dev)static int msm_serial_pending (struct udevice *dev,bool input) {struct msm_serial_data *priv =dev_get_priv (dev); - -if (input) -return readl (priv->base +SE_GENI_RX_FIFO_STATUS ) & -RX_FIFO_WC_MSK ; -else
drivers/serial/serial_msm_geni.c static int msm_serial_getc(struct udevice *dev) · line 436
Quoted 10 lines
drivers/serial/serial_msm_geni.c +10
-0+u32 rx_fifo_status, s_irq_status; +int result; + +if (input) { + rx_fifo_status =readl (priv->base +SE_GENI_RX_FIFO_STATUS ); + result = rx_fifo_status &RX_FIFO_WC_MSK ; + +/* +* Validate RX data with IRQ status +* Only report pending data if valid RX IRQ indicators are set.
What does this mean "valid RX IRQ indicators"??? This comment is fluff, use better variable names (result -> word_count)
drivers/serial/serial_msm_geni.c static int msm_serial_getc(struct udevice *dev) · line 438
Quoted 2 lines
drivers/serial/serial_msm_geni.c +2
-0+*/ +if (result) {
if (word_count > 0)> + s_irq_status = readl(priv->base + SE_GENI_S_IRQ_STATUS);
Quoted 20 lines
drivers/serial/serial_msm_geni.c +9
-1+ +if (!(s_irq_status & (S_RX_FIFO_WATERMARK_EN |S_RX_FIFO_LAST_EN ))) { +/* No valid RX IRQ, ignore stale data */ +return 0 ; + } + } +return result; + }else {return readl (priv->base +SE_GENI_TX_FIFO_STATUS ) &TX_FIFO_WC_MSK ; + }return 0 ; } ---base-commit:
6902fb4c17faa375003124c451c2550deab5463d
change-id: 20260629-uart-e07d893e4508Best regards,
Hi Casey,
Quoted 13 lines · Casey Connolly
Hi Balaji,
Quoted 9 lines · Balaji Selvanathan
The GENI UART hardware can retain stale data in the RX FIFO. The
msm_serial_pending()function was reporting this stale data as pending input, causing U-Boot to incorrectly assume a key press and stop at the CLI prompt instead of continuing the boot process.Add IRQ status validation to distinguish between legitimate received data and stale FIFO contents. Check the Secondary IRQ status register for RX watermark or last flags before reporting pending data. If the FIFO contains data but no valid IRQ flags are set, ignore it as stale.
Quoted 7 lines
Taking a look here compared to the Linux polling mode driver I don't think this is the right way to solve this.
In
qcom_geni_serial_stop_rx_fifo()in Linux after clearing the RX IRQs the cancel command is sent (and polled on) and then ifS_RX_FIFO_LAST_ENis set the FIFO is drained.So the right fix here for U-Boot would be to do something similar in
msm_geni_serial_setup_rx(), send a cancel rather than an abort, wait for it to complete (or timeout), drain the fifo, and then send an abort ifS_GENI_CMD_ACTIVEis still set to fully reset it.so NAK, please solve this properly by fixing the init sequence.
Fixed the init sequence in v2: https://lore.kernel.org/u-boot/[email protected]/
But even after fixing init sequence, still the issue is observed, so seems SE_GENI_S_IRQ_STATUS register has to be checked to make sure data is valid (https://lore.kernel.org/u-boot/[email protected]/).
Thanks,
Balaji
Quoted 57 lines
Quoted 20 lines
Signed-off-by Balaji Selvanathan <[email protected]>---
drivers/serial/serial_msm_geni.c| 27 ++++++++++++++++++++++-----1 file changed, 22 insertions(+), 5 deletions(-)drivers/serial/serial_msm_geni.c +0
-5@@ -424,13 +424,30 @@ static int msm_serial_getc(struct udevice *dev) static int msm_serial_pending(struct udevice *dev, bool input) { struct msm_serial_data *priv = dev_get_priv(dev); - - if (input) - return readl(priv->base + SE_GENI_RX_FIFO_STATUS) & - RX_FIFO_WC_MSK; - elsedrivers/serial/serial_msm_geni.c static int msm_serial_getc(struct udevice *dev) · line 436
Quoted 10 lines
drivers/serial/serial_msm_geni.c +10
-0+ u32 rx_fifo_status, s_irq_status; + int result; + + if (input) { + rx_fifo_status = readl(priv->base + SE_GENI_RX_FIFO_STATUS); + result = rx_fifo_status & RX_FIFO_WC_MSK; + + /* +* Validate RX data with IRQ status +* Only report pending data if valid RX IRQ indicators are set. What does this mean "valid RX IRQ indicators"??? This comment is fluff, use better variable names (result ->
word_count)drivers/serial/serial_msm_geni.c static int msm_serial_getc(struct udevice *dev) · line 438
Quoted 2 lines
drivers/serial/serial_msm_geni.c +2
-0+*/ + if (result) {if (
word_count> 0)> +s_irq_status=readl(priv->base + SE_GENI_S_IRQ_STATUS);Quoted 20 lines
drivers/serial/serial_msm_geni.c +8
-0+ + if (!(s_irq_status & (S_RX_FIFO_WATERMARK_EN |S_RX_FIFO_LAST_EN ))) { + /* No valid RX IRQ, ignore stale data */ + return 0; + } + } + return result; + } else {return
readl(priv->base + SE_GENI_TX_FIFO_STATUS)&TX_FIFO_WC_MSK;
+ }
return 0;
}---
base-commit:6902fb4c17faa375003124c451c2550deab5463d
change-id: 20260629-uart-e07d893e4508Best regards,