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=1795602829; b=xC+bG5IAaO/6dElDtYLQsPkiYD9QB3GXJs7zdYJGj9Xs9bnmnceNdNFZwu17RsJIkNHX CKJMYnThs54ten+D0lmrp33VNAaaLm0T7Xk685dXKI/S2pyCGdecxCYRUJuHVIY89GbyQ iTkWB7xmfLWYe8SvW8R7fQo8K7AbreRxpcVJIOrQAkX5/Tfb3zBKB4hIsEzr+MBjp0H7x Iu5CUYk3EBOpgl6izTv0MizAiuDC+Aj6Wr8bikC3+xI8m5xEarz7AfW/0bALtljCukpg5 x/7D0kcrdyE+cJ4J67NEgt7lDHCOV/6Wdrlzc2x3ldIuLg57Pm4t3M/vSxj78Cs9Gvg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795602829; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=X69SryzAWJEpBIblVaSeOHpDOKIpz6WvIv/pJ1shGHY=; b=mYF8e/P8nD1fVkNotK6ibkeBfpNAiEmcn+Sc5hCTRA9RTxpVoyn8mglnxMUMR84z94o0 R81h9Lfb6wRW1aH/fUhm/OeIiUGjvtJhZh/VXQZq0xYhPGC0f0uxgYibLV+AKbwlHiP44 GtWeV6wUg3HyVOHR3Bo0ti1BfLWvk+0/i/7DfdWLtmdPARUjg2AXApNTS/UU4c6IGSFdp 8X/0Y0B4M4pUvd7iDfwh+TG8zelM81EB0EK084JG/3inebHaIxR0tg7UgVYcC6CGNepSY yHA/AHrnOniS7/9NIfhuuL4HlxvkfHdOvE6mnOuA5bfb8WggPV96AZS2g21fljAGp+w== 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=HlccMShY; 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 86428606A326 for ; Wed, 25 Nov 2026 10:33:49 +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=HlccMShY Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BAA01F000C6; Wed, 25 Nov 2026 10:33:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795602829; bh=X69SryzAWJEpBIblVaSeOHpDOKIpz6WvIv/pJ1shGHY=; h=Subject:To:Cc:From:Date; b=HlccMShYpHi8H8Q2nk0Cf6hkMlf0PGGUTxIQWpPeqeHJ4HRKmrdSiZL6wCiFfLehI 3GS1p050aZ9rNaE1byf9tMEzwbmrtNInnVBuGNm3ZXgtd1KSIchXgFyT/VeY6v7iTd I1Nfr4gM8sXXYlqylspnTEg0+TpXVAuU6OpRHuVU= Subject: FAILED: patch "[PATCH] spi: tegra210-quad: Track DMA mapping state" failed to apply to 6.12-stable tree To: va@nvidia.com,broonie@kernel.org Cc: From: Date: Wed, 25 Nov 2026 11:14:53 +0100 Message-ID: <2026112553-rudder-camera-262f@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.12-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y git checkout FETCH_HEAD git cherry-pick -x 7b9e6f7bc13c0259b192d0a964e802d4ad53b8b8 # git commit -s git send-email --to '' --in-reply-to '2026112553-rudder-camera-262f@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 7b9e6f7bc13c0259b192d0a964e802d4ad53b8b8 Mon Sep 17 00:00:00 2001 From: Vishwaroop A Date: Mon, 26 Oct 2026 11:14:11 +0000 Subject: [PATCH] spi: tegra210-quad: Track DMA mapping state tegra_qspi_dma_unmap_xfer() assumes a streaming mapping is always outstanding and recomputes its length from the live tqspi->curr_dma_words. Nothing records whether tegra_qspi_dma_map_xfer() mapped anything, so neither assumption holds. For a multi-chunk transfer, handle_dma_based_xfer() unmaps the chunk that just completed, recalculates the parameters for the next chunk, which overwrites curr_dma_words, and re-arms the hardware. If tegra_qspi_start_dma_based_transfer() then fails at its tegra_qspi_dma_map_xfer() call, nothing is mapped. That early return also sits above the smp_store_release() that clears tqspi->trans_status, so the previous chunk's QSPI_RDY survives, and the re-arm's return value is never checked, so handle_dma_based_xfer() returns IRQ_HANDLED without completing the transfer. The caller times out, tegra_qspi_handle_timeout() sees the stale QSPI_RDY, concludes the transfer completed and calls handle_dma_based_xfer() again. No DMA completion arrives, so num_errors is incremented and tegra_qspi_dma_unmap_xfer() runs with nothing mapped. t->tx_dma then holds either the DMA_MAPPING_ERROR sentinel or, if the RX mapping was the one that failed, the preceding chunk's address that has already been released. Behind an IOMMU the latter frees an IOVA that may since have been reallocated. Record whether a mapping is outstanding and the length that was mapped, and return early from tegra_qspi_dma_unmap_xfer() when there is nothing to release. is_dma_mapped is only updated under tqspi->lock, or on the timeout path after synchronize_irq() and cancel_work_sync() have quiesced the ISR and the bottom half. Also skip releasing the TX mapping on the RX failure path unless a TX mapping was created; t->tx_dma is uninitialised when t->tx_buf is NULL. Fixes: 921fc1838fb0 ("spi: tegra210-quad: Add support for Tegra210 QSPI controller") Suggested-by: Mark Brown Cc: stable@vger.kernel.org Signed-off-by: Vishwaroop A Link: https://patch.msgid.link/20261026111412.3843954-3-va@nvidia.com Signed-off-by: Mark Brown diff --git a/drivers/spi/spi-tegra210-quad.c b/drivers/spi/spi-tegra210-quad.c index 8b8b317e2078..1cd65a71bd5a 100644 --- a/drivers/spi/spi-tegra210-quad.c +++ b/drivers/spi/spi-tegra210-quad.c @@ -237,6 +237,17 @@ struct tegra_qspi { bool is_packed; bool use_dma; + /* + * Set while a streaming mapping created by + * tegra_qspi_dma_map_xfer() is outstanding, together with the + * length that was handed to dma_map_single(). is_curr_dma_xfer + * only records that the last armed chunk took the DMA path, + * which is not the same thing: a chunk whose mapping failed + * leaves the DMA path flagged with nothing mapped. + */ + bool is_dma_mapped; + unsigned int dma_map_len; + u32 command1_reg; u32 dma_control_reg; u32 def_command1_reg; @@ -606,24 +617,32 @@ static int tegra_qspi_dma_map_xfer(struct tegra_qspi *tqspi, struct spi_transfer if (t->rx_buf) { t->rx_dma = dma_map_single(tqspi->rx_dma_dev, (void *)rx_buf, len, DMA_FROM_DEVICE); if (dma_mapping_error(tqspi->rx_dma_dev, t->rx_dma)) { - dma_unmap_single(tqspi->tx_dma_dev, t->tx_dma, len, DMA_TO_DEVICE); + if (t->tx_buf) + dma_unmap_single(tqspi->tx_dma_dev, t->tx_dma, + len, DMA_TO_DEVICE); return -ENOMEM; } } + tqspi->dma_map_len = len; + tqspi->is_dma_mapped = true; + return 0; } static void tegra_qspi_dma_unmap_xfer(struct tegra_qspi *tqspi, struct spi_transfer *t) { - unsigned int len; - - len = DIV_ROUND_UP(tqspi->curr_dma_words * tqspi->bytes_per_word, 4) * 4; + if (!tqspi->is_dma_mapped) + return; if (t->tx_buf) - dma_unmap_single(tqspi->tx_dma_dev, t->tx_dma, len, DMA_TO_DEVICE); + dma_unmap_single(tqspi->tx_dma_dev, t->tx_dma, + tqspi->dma_map_len, DMA_TO_DEVICE); if (t->rx_buf) - dma_unmap_single(tqspi->rx_dma_dev, t->rx_dma, len, DMA_FROM_DEVICE); + dma_unmap_single(tqspi->rx_dma_dev, t->rx_dma, + tqspi->dma_map_len, DMA_FROM_DEVICE); + + tqspi->is_dma_mapped = false; } static int tegra_qspi_start_dma_based_transfer(struct tegra_qspi *tqspi, struct spi_transfer *t)