From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795031135; b=wQ9DG41cT1jpj15NM5Q3EiZsbo37Ne5PuLJydiRBgRmfwNBGhUBGRk44l3RgOyxxJ4Hr YHCH4BH8TFzFIO/lMo7k6eSSlWflbtJSIcC5ZH1B9+mG+1yRW5AVYEmPWU+Is87/vRLt8 B+EW3Z0rH4eqFz8nVTep2ZeA14U552mSBLSy9N3osdeC7R1fharyHJMtC8AR8xr8cBb7P vlFR6nNC8Z8x/NKzEt5ByBZM+L1cSN78sz+VzhUgwybyWVnytY+au4A8UWfdt1gXeLfrT 3LN3zF6V7p0viQZnAFvACIKFGhiVAyYwTEfkhkXrPGfg3cUTB413zR6b2bojyGt4YUg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795031135; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=MDiveqO5L587YMHQeEUGM65cxzY2zVPPN51vX44ZHlg=; b=v9HDY5/w5WGH2iNdOLTGpr5lRwUjTlkc3iUrvB+G8OQYOlbrBpERLcSqWtG4QYQFkcrT YWXElTfenLv1gGGPVjeYGOgfztV38qZTXyg4jWuJze9gjaumW3rrBDFKkfKWGr1GOiNbN CnPljBXwQZOSKZfTKz8g/9l2qyG3gWR2+v47faLHmV3sozwtJQ4S7MELTo/Mdji5dwHRe I9PMDnVcAtp3PT6chfE4Ewvqfp/D5ZrjY0HSA3o8P2Ss4IYmdXxEZNOsxqDnqFWZJnUbe musO351saaXXwx0XP2ju9zau2zPjQqYF/l8fTa9ZA6ZnKvoNe8El+7NHFNSk2AovhPQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=FBc9nvyF; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B1CC606A320; Wed, 18 Nov 2026 19:45:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=FBc9nvyF Received: by smtp.kernel.org (Postfix) with ESMTPSA id 608FD1F000C7; Wed, 18 Nov 2026 19:45:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795031134; bh=MDiveqO5L587YMHQeEUGM65cxzY2zVPPN51vX44ZHlg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FBc9nvyFfrNEGYGNWNyDqpqeYcL/2zQRDUOwNap97lWV5EJ2OYgTog9U3KoSBNX7/ bmSle+xrW7lU9AoQb+EnuxzgiR+NkFcRGN/Guce9sAbGM9FIaDm+3uqjoqQscydHwn EWZ9NKqAFiWSQ1I6ubVz7Q7iM6dfBgkMojYL6DTo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Marc Kleine-Budde , Jonas Rebmann , Mark Brown , Sasha Levin Subject: [PATCH 6.12 0924/1756] spi: spi-sun4i: sun4i_spi_fill_fifo(): always apply A10 FIFO fill level workaround Date: Wed, 18 Nov 2026 15:50:51 +0100 Message-ID: <20261118150046.757897813@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150007.957976754@linuxfoundation.org> References: <20261118150007.957976754@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Marc Kleine-Budde [ Upstream commit ee109e2bbea0986f6ad34bfbcba90fce36f17538 ] In commit 6d9fe44bd73d ("spi: sun4i: fix FIFO limit"), the TX FIFO is filled max to SUN4I_FIFO_DEPTH - 1 (= 63) bytes to work around timeouts observed on A10s SoCs. Commit 196737912da5 ("spi: sun4i: Allow transfers larger than FIFO size") added support for transfers larger than the FIFO size. This commit did not consider the A10 workaround (limit the TX FIFO fill size to SUN4I_FIFO_DEPTH - 1 (= 63) bytes) for refilling the TX FIFO in the IRQ handler. To apply the workaround independent from where sun4i_spi_fill_fifo() is called, remove the length argument from the function and directly take the max fill level of SUN4I_FIFO_DEPTH - 1 into account when calculating the free space in the FIFO. Due to the lack of HW this patch has not been tested on an A10 SoC, but on an A20 SoC. It was not possible to reproduce the timeout on the A20. Fixes: 196737912da5 ("spi: sun4i: Allow transfers larger than FIFO size") Signed-off-by: Marc Kleine-Budde Signed-off-by: Jonas Rebmann Link: https://patch.msgid.link/20260914-spi-sun4i-fixes-v3-2-9fe919d5cecf@pengutronix.de Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-sun4i.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/spi/spi-sun4i.c b/drivers/spi/spi-sun4i.c index 406a28728fb2c..9b21d3b945b35 100644 --- a/drivers/spi/spi-sun4i.c +++ b/drivers/spi/spi-sun4i.c @@ -142,15 +142,21 @@ static inline void sun4i_spi_drain_fifo(struct sun4i_spi *sspi, int len) } } -static inline void sun4i_spi_fill_fifo(struct sun4i_spi *sspi, int len) +static inline void sun4i_spi_fill_fifo(struct sun4i_spi *sspi) { u32 cnt; + int len; u8 byte; - /* See how much data we can fit */ - cnt = SUN4I_FIFO_DEPTH - sun4i_spi_get_tx_fifo_count(sspi); + /* + * See how much data we can fit + * + * Filling the FIFO fully causes timeout for some reason + * at least on spi2 on A10s + */ + cnt = SUN4I_FIFO_DEPTH - 1 - sun4i_spi_get_tx_fifo_count(sspi); - len = min3(len, (int)cnt, sspi->len); + len = min_t(int, cnt, sspi->len); while (len--) { byte = sspi->tx_buf ? *sspi->tx_buf++ : 0; @@ -311,12 +317,8 @@ static int sun4i_spi_transfer_one(struct spi_controller *host, sun4i_spi_write(sspi, SUN4I_BURST_CNT_REG, SUN4I_BURST_CNT(tfr->len)); sun4i_spi_write(sspi, SUN4I_XMIT_CNT_REG, SUN4I_XMIT_CNT(tx_len)); - /* - * Fill the TX FIFO - * Filling the FIFO fully causes timeout for some reason - * at least on spi2 on A10s - */ - sun4i_spi_fill_fifo(sspi, SUN4I_FIFO_DEPTH - 1); + /* Fill the TX FIFO */ + sun4i_spi_fill_fifo(sspi); /* Enable the interrupts */ sun4i_spi_enable_interrupt(sspi, SUN4I_INT_CTL_TC | @@ -373,7 +375,7 @@ static irqreturn_t sun4i_spi_handler(int irq, void *dev_id) /* Transmit FIFO 3/4 empty */ if (status & SUN4I_INT_CTL_TF_E34) { - sun4i_spi_fill_fifo(sspi, SUN4I_FIFO_DEPTH); + sun4i_spi_fill_fifo(sspi); if (!sspi->len) /* nothing left to transmit */ -- 2.53.0