From 139f1f15480afe0c64ced6d79cf9e4f99a0fe9ab Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Wed, 19 May 2021 16:56:13 +0900 Subject: [PATCH] drivers/modem/altair: Fix behavior when a reset packet conflicts with a send packet Even in the case of a conflict between a reset packet and a send packet, the send size is compared and the larger size is sent as the payload. --- drivers/modem/altair/altmdm_spi.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/modem/altair/altmdm_spi.c b/drivers/modem/altair/altmdm_spi.c index ec62233eee..8818c74e77 100644 --- a/drivers/modem/altair/altmdm_spi.c +++ b/drivers/modem/altair/altmdm_spi.c @@ -1232,12 +1232,24 @@ static int do_trxreset(FAR struct altmdm_dev_s *priv) ret = wait_receiverready(priv, WAIT_RXREQ_TIMEOUT); if (ret >= 0) { - /* If a conflict occurs with the reset packet, - * the packet is transferred by the size specified - * by the receiving side. Discard the data on the sending side. + /* Even in the case of a conflict between a reset packet + * and a send packet, the send size is compared and the + * larger size is sent as the payload. + * If the send packet that conflicts with the reset packet + * is in ALTCOM command format, the modem may assert. + * If it is not in the ALTCOM command format, it will be + * discarded by the modem, so dummy data will be sent to + * avoid assertion. */ - xfer_size = spidev->rx_param.total_size; + if (spidev->tx_param.total_size < spidev->rx_param.total_size) + { + xfer_size = spidev->rx_param.total_size; + } + else + { + xfer_size = spidev->tx_param.total_size; + } /* Get DMA transfer size */