mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com>
To: Conor Dooley <conor@kernel.org>, <linux-spi@vger.kernel.org>
Cc: Conor Dooley <conor.dooley@microchip.com>,
	<stable@vger.kernel.org>,
	Daire McNamara <daire.mcnamara@microchip.com>,
	Mark Brown <broonie@kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] spi: microchip-core: prevent RX overflows when transmit size > FIFO size
Date: Wed, 29 Jan 2025 18:57:34 +0530	[thread overview]
Message-ID: <3e8c08fb-ec3a-4d00-a3e9-43c299dcf942@quicinc.com> (raw)
In-Reply-To: <20250114-easiness-pregame-d1d2d4b57e7b@spud>



On 1/14/2025 10:43 PM, Conor Dooley wrote:
> From: Conor Dooley <conor.dooley@microchip.com>
Not sure why this "From:" is coming here, should be not coming.
> 
> When the size of a transfer exceeds the size of the FIFO (32 bytes), RX
> overflows will be generated and receive data will be corrupted and
> warnings will be produced. For example, here's an error generated by a
> transfer of 36 bytes:
> 
why warning on RX generated when TZ size is > 32 bytes ?
Also you should be taking 32 bytes in a one go and then send remaining 4 
bytes. I am thinking if your TX is faster than the RX receiving ?
>    spi_master spi0: mchp_corespi_interrupt: RX OVERFLOW: rxlen: 4, txlen: 0
> 
> I am not entirely sure how this happens, as rxlen being 4 means that 32
> of 36 bytes have been read from the RX FIFO so there should be
> sufficient room for 4 more bytes but timing is likely a factor as simply
> adding a delay in the transmit path is enough to avoid the overflows.
I suggest to try to chunk in 32 bytes size.
> 
> CC: stable@vger.kernel.org
> Fixes: 9ac8d17694b6 ("spi: add support for microchip fpga spi controllers")
> Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
> ---
> Been sitting on this one for a bit, original reporter claims the problem
> isn't fixed, but it fixed the issue on my setup so I am sending the patch
> as it's an improvement on the status quo at the very least.
> 
> CC: Conor Dooley <conor.dooley@microchip.com>
> CC: Daire McNamara <daire.mcnamara@microchip.com>
> CC: Mark Brown <broonie@kernel.org>
> CC: linux-spi@vger.kernel.org
> CC: linux-kernel@vger.kernel.org
> ---
>   drivers/spi/spi-microchip-core.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/spi/spi-microchip-core.c b/drivers/spi/spi-microchip-core.c
> index 5b6af55855ef..3582fe8d3fc4 100644
> --- a/drivers/spi/spi-microchip-core.c
> +++ b/drivers/spi/spi-microchip-core.c
> @@ -221,6 +221,13 @@ static inline void mchp_corespi_write_fifo(struct mchp_corespi *spi)
>   	while ((i < fifo_max) && !(mchp_corespi_read(spi, REG_STATUS) & STATUS_TXFIFO_FULL)) {
>   		u32 word;
>   
> +		/*
> +		 * If the transfer is larger than FIFO_DEPTH, spin until space
> +		 * is made in the RX FIFO to avoid losing data to RX overflows
> +		 */
what if you transfer first 32 bytes and then remaining ?
> +		while (mchp_corespi_read(spi, REG_STATUS) & STATUS_RXFIFO_FULL)
> +			;
> +
>   		if (spi->n_bytes == 4)
>   			word = spi->tx_buf ? *((u32 *)spi->tx_buf) : 0xaa;
>   		else if (spi->n_bytes == 2)


  parent reply	other threads:[~2025-01-29 13:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-14 17:13 Conor Dooley
2025-01-14 19:44 ` Mark Brown
2025-01-15 18:22   ` Conor Dooley
2025-01-15 19:33     ` Mark Brown
2025-01-29 13:27 ` Mukesh Kumar Savaliya [this message]
2025-01-29 16:30   ` Conor Dooley
2025-03-04 12:34 ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3e8c08fb-ec3a-4d00-a3e9-43c299dcf942@quicinc.com \
    --to=quic_msavaliy@quicinc.com \
    --cc=broonie@kernel.org \
    --cc=conor.dooley@microchip.com \
    --cc=conor@kernel.org \
    --cc=daire.mcnamara@microchip.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®