drivers: uart: nrf: rx_timeout_slab incorrectly set

When rx_timeout is set to a sufficiently small value,
rx_timeout_slab could potentially get set to a greater
than necessary value that causes spurious UART_RX_RDY
events.

Fixes #62828

Signed-off-by: Jacob Preston <jacob.preston@synapse.com>
This commit is contained in:
Jacob Preston 2023-10-18 09:21:16 -07:00 committed by Carles Cufí
commit 52c55177ba

View file

@ -844,15 +844,7 @@ static int uarte_nrfx_rx_enable(const struct device *dev, uint8_t *buf,
}
data->async->rx_timeout = timeout;
/* Set minimum interval to 3 RTC ticks. 3 is used due to RTC limitation
* which cannot set timeout for next tick. Assuming delay in processing
* 3 instead of 2 is used. Note that lower value would work in a similar
* way but timeouts would always occur later than expected, most likely
* after ~3 ticks.
*/
data->async->rx_timeout_slab =
MAX(timeout / RX_TIMEOUT_DIV,
NRFX_CEIL_DIV(3 * 1000000, CONFIG_SYS_CLOCK_TICKS_PER_SEC));
data->async->rx_timeout_slab = timeout / RX_TIMEOUT_DIV;
data->async->rx_buf = buf;
data->async->rx_buf_len = len;