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=1796387081; b=UPfqRpqDCxlV1UBHkTpdfbY6GSVugXkzvUV0I3L6m+8JkLp9iyA0mud4nWkapJz3Y2Wo Kl2phIXNJa5Y1hsiEE2kPfQHty8XHX5p82AdtZ3yMjdWamkF5qswmbHudEUpcPOrRe6CH f95jbNO5+y/Jshz9S1FHsMNqVk0KPy5+5nFL4ks43T3yP0mTPLqe0zDQCBVFaMuBQkJIT ZH9+h15RBtneoHc5EbMzNb398aTQ6JXU0MLsEGw8lUhHOQqmL5ax16+9lVAGOLpK0aaFd +ZVNX0/6DvSkU8y6fQL4CgeSqjXY03FutEk9+wjeSGbLJNugp4QHaEAkfUsowdtBQyA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387081; 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=U5RzT3DG3GwkX4MiJiej5s2M1CI8fmKYKj70wnnI058=; b=QCYAiUrNCjPOLUCc9PKEx0T7EBOK81EEVKX67oSXMcYCxV9nHdTJIEWDPt19Ea+UdFpt nrAx2p3+nLNFqf53URo69Lc3LBzamP51UIGzwYUXiDTkT3o2UYNy0nvE6yjSu1mZsixRE XaOmx0uZZqSp9pl//+pFWtL3oyhXYBN9HFtRHqcWEEOBWSuK6d/nwhFRR5yvmrdPgdeDP gbsf6UfCxx8QPhfgMYiVX1o5SrmYlBJqvMsOTdxO4lGVwCc+eHRAE507CDJp4i96FEMQP NcLRUIT3RPTs/IwapFdaGo3MvdDovsRHhYinKcElabcZcH7TO1kNWss4kuDvM/nZIGA== 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=u3n04S9r; 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 BD1E4606A322; Fri, 4 Dec 2026 12:24:41 +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=u3n04S9r Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A7D11F000CE; Fri, 4 Dec 2026 12:24:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387081; bh=U5RzT3DG3GwkX4MiJiej5s2M1CI8fmKYKj70wnnI058=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=u3n04S9rq/GCSqzBig8GU+c27z87e2MxMw88Shoe+32MeILMDl0QHdZp/MrcljQnQ Evg9N5FIMCVcohjVDvoNiejM2aewVJjQOnPnFHcDvWx0z28ZZb1MvGCicggiWbKalR YSws3mvVnBIk6bkdzr9h37Btt/7px8iEkQgHcH7g= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Frederic Konrad , Srikanth Boyapally , Radhey Shyam Pandey , Mark Brown , Sasha Levin Subject: [PATCH 6.1 0126/1059] spi: cadence-quadspi: Fix race between DMA completion and transfer start Date: Fri, 4 Dec 2026 18:54:17 +0900 Message-ID: <20261204100647.486431908@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Frederic Konrad [ Upstream commit 059518f775baecc9803fc97787bd0b17558f8047 ] In cqspi_versal_indirect_read_dma(), the DMA transfer is started by writing CQSPI_REG_INDIRECTRD_START_MASK to the indirect read control register. Under certain timing conditions, the DMA completion interrupt may be triggered and complete the transfer before the completion structure is reinitialized. This creates a race where the completion event is lost, causing wait_for_completion_timeout() to time out even though the transfer has already completed, resulting in errors such as: spi-nor spi0.0: CS0: operation failed with -110 Fix this by reinitializing the completion structure before starting the DMA transfer, ensuring that any completion event generated after the transfer begins is correctly observed. Fixes: 1a6f854f7daa ("spi: cadence-quadspi: Add Xilinx Versal external DMA support") Signed-off-by: Frederic Konrad Signed-off-by: Srikanth Boyapally Signed-off-by: Radhey Shyam Pandey Link: https://patch.msgid.link/20261104071958.2405117-1-radhey.shyam.pandey@amd.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-cadence-quadspi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c index dccbeaf3d690f..eb7f0a56b6e5b 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -857,11 +857,11 @@ static int cqspi_versal_indirect_read_dma(struct cqspi_flash_pdata *f_pdata, writel(CQSPI_REG_VERSAL_DMA_DST_CTRL_VAL, reg_base + CQSPI_REG_VERSAL_DMA_DST_CTRL); + reinit_completion(&cqspi->transfer_complete); + writel(CQSPI_REG_INDIRECTRD_START_MASK, reg_base + CQSPI_REG_INDIRECTRD); - reinit_completion(&cqspi->transfer_complete); - if (!wait_for_completion_timeout(&cqspi->transfer_complete, msecs_to_jiffies(CQSPI_READ_TIMEOUT_MS))) { ret = -ETIMEDOUT; -- 2.53.0