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=1796381554; b=CKXYlVRcWk463yqhR0pFsDb2u3bKRYYdsl/rEWzpTmKcKlHk8ZFEtFi+9hkinbFv3sF9 996zdxImrlnVOwbkL9t51CBSD8DuaKlQrX8rv0uqFefaAQuGQwXgxCwW9CXgpG14rhjw6 rcmjabQuAcoo9aTm13sGynSGBfjgkvBNntVjF8IDT+5/xe0AZhDmdmY5Py4BtJDX+eD75 KChByxwjAbRpcFTyWYRA1e55fxPUsGXQ2gB0VBRiWZtj3gyqt8HchHmR+rNu/sVqCfQhr 04SdDYZAc7EUATQDIUcBobukC6xEn9kRd45g1gUYA/UajUcBMkYgHDzZ42emECSH1/Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381554; 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=bZzzNZKRVc0ZysIlkTYkNdD7ZZW1JrWLhQla3YjrjV8=; b=vSbNG/eZVJLFZmRtAWTupFTM9+FHedVEXNuv0Y0/TTTYDFvdS9dVqa1Afmuc7FGX9y/T 4euU1LKcikJwazfqhlfrAVHwuIG28Og8TLwpacLchkiHKvSdVHFO+gopclJlWoJQhvxmN mJortLGqUR1EZkFjn1zGOmTpPw1NwnDRtHKpqvUFZp656pitRSLUO22GMJr/vHFb3uu7U i6rH+6toHOzGcdmsZKTVHbf3pQb9FEtXju37ZOGt1btYh/3k/Y2wWzjlm4CUu+nGEfZhD rrb9cGZMwE3bl9LSChpAXyyYM8elH7EZi9UxTo3aGAWinq0Q2Wv+uhM6Zy86ZyjHb3w== 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=s+TtMVJi; 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 D6C1F606A32C; Fri, 4 Dec 2026 10:52:34 +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=s+TtMVJi Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E04F1F000C2; Fri, 4 Dec 2026 10:52:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381554; bh=bZzzNZKRVc0ZysIlkTYkNdD7ZZW1JrWLhQla3YjrjV8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=s+TtMVJiICWd9thD9odynEGXHqZCoO6pAJ5DQP9K/069TAiv/r9odgz4uBENue7DG kDYaV+kg8Off7F0fB/Ivk9cXdq5CT7kwA/zctsy/qfFsO8f20iZOWlPIt8cLZaYEbQ INCcMcwlJMdoTT0zmPt/B2JxZPhXQfHQXH9SrHKc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Vishwaroop A , Mark Brown , Sasha Levin Subject: [PATCH 6.18 075/703] spi: tegra210-quad: Unmap DMA buffers on transfer timeout Date: Fri, 4 Dec 2026 18:59:34 +0900 Message-ID: <20261204100629.720170797@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vishwaroop A [ Upstream commit d04ad85dd8015713b0b2531b5b934fe67828d741 ] tegra_qspi_start_dma_based_transfer() maps the client TX/RX buffers with dma_map_single() via tegra_qspi_dma_map_xfer(). The matching unmap only happens in handle_dma_based_xfer(), which runs from the interrupt bottom half. When wait_for_completion_timeout() expires and tegra_qspi_handle_timeout() cannot establish that the hardware finished, it returns an error without the bottom half ever having run. Both transfer paths then abort the transfer with tegra_qspi_dma_stop(), reset the controller and clear curr_xfer, but never unmap the buffers. Every genuine transfer timeout therefore leaks the streaming DMA mappings for that chunk, which gradually exhausts the IOVA space on systems with an IOMMU in front of QSPI. Unmap the transfer after stopping DMA on both timeout error paths. The unmap is placed after tegra_qspi_dma_stop() so the DMA engine is quiesced before the mappings go away. The recovery paths that do reach handle_dma_based_xfer() unmap there themselves. The preceding patch makes tegra_qspi_dma_unmap_xfer() a no-op once the mapping is released, so this cleanup cannot unmap twice or run against a chunk that was never mapped. Fixes: 921fc1838fb0 ("spi: tegra210-quad: Add support for Tegra210 QSPI controller") Cc: stable@vger.kernel.org # with "spi: tegra210-quad: Track DMA mapping state" Signed-off-by: Vishwaroop A Link: https://patch.msgid.link/20261026111412.3843954-4-va@nvidia.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-tegra210-quad.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-tegra210-quad.c b/drivers/spi/spi-tegra210-quad.c index 8caf17a32e397..1b28dcce8372e 100644 --- a/drivers/spi/spi-tegra210-quad.c +++ b/drivers/spi/spi-tegra210-quad.c @@ -1261,10 +1261,12 @@ static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi, dev_err(tqspi->dev, "transfer timeout\n"); /* Abort transfer by resetting pio/dma bit */ - if (tqspi->is_curr_dma_xfer) + if (tqspi->is_curr_dma_xfer) { tegra_qspi_dma_stop(tqspi); - else + tegra_qspi_dma_unmap_xfer(tqspi, xfer); + } else { tegra_qspi_pio_stop(tqspi); + } /* Reset controller if timeout happens */ tegra_qspi_reset(tqspi); @@ -1377,8 +1379,10 @@ static int tegra_qspi_non_combined_seq_xfer(struct tegra_qspi *tqspi, /* Real timeout - clean up and fail */ dev_err(tqspi->dev, "transfer timeout\n"); - if (tqspi->is_curr_dma_xfer) + if (tqspi->is_curr_dma_xfer) { tegra_qspi_dma_stop(tqspi); + tegra_qspi_dma_unmap_xfer(tqspi, xfer); + } tegra_qspi_handle_error(tqspi); ret = -EIO; -- 2.53.0