From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE90F3D5C07 for ; Wed, 24 Jun 2026 15:29:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782314990; cv=none; b=BbUb60CRlY7jkpQYF9XDLIG4j0bpfvLZAS22WkGoR7OT8oaWKw6FyLEV5ZM3HW8Zn5L3Dy1ZgK1GiPNH1PVePNSBLhZ25w7JOetvMaDCjdPoChX6nwSyVwFr5rqPA7ovcgcy4kAmcJpSEWHmqsdJOf0oaECThzmxfYhFMJFm7yw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782314990; c=relaxed/simple; bh=1glqh6kZ8jyXTLuNydOOo/r+0hvO+ngpRp4hoG8/BU8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=rqBDkau+4HVRW8OpSuZli+BsvVWD2nDTfW2DkEQA5Asq7Xc5MRjssFBlL+DO/QmVhRoXk7MiqKJmV8+wnQpQ2n5gXss7sAQ21HxZfPCBkka6t1J5VSTInx9z1r/V8QGiZI/G3nRcPHkFqgaeJIpWETt4o8qcIkfaVmYlXMa+DTo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XLDm6g9G; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XLDm6g9G" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B17A11F000E9; Wed, 24 Jun 2026 15:29:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1782314989; bh=Rj2JE8zO6no8N19Xf+hPBpJrN/JqjceY+56abTgyUFs=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=XLDm6g9GAodM8pC2/f+uZJTm0nL7Bn/5yyaDWiJwx5+0uYYpwkCS+LLaLjGywwJDh 6m38XQn4xXiB6IkaEG42dhGJHQio/K7E7J2aMGysRFwhnm/iquOfr5gSr3wQ95bxj6 52vQXPwgJNmCtibqjJzeKZu2j/XYEjBFt++Uub9lzAuLArT6s/oriu2G+vbptKypGK RLKogMdVEdDzryCWPfCoK1x5XyMyFJtnibrR34mBCno1LaUrVqAcDgy1lb7himOpfk Qu8FigHebosh39hFR3ZRyrwScqvaA3Q0f+e9NtNob5j5vrrdsJqBghRNz036X84f7E x24ALDcbn1DUQ== Message-ID: Date: Wed, 24 Jun 2026 18:29:38 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mtd: rawnand: lpc32xx_slc: fail DMA transfer on completion timeout To: Pengpeng Hou , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Piotr Wojtaszczyk Cc: linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20260624144127.69075-1-pengpeng@iscas.ac.cn> From: Vladimir Zapolskiy In-Reply-To: <20260624144127.69075-1-pengpeng@iscas.ac.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 6/24/26 17:41, Pengpeng Hou wrote: > lpc32xx_xmit_dma() waits for the DMA completion callback but ignores > wait_for_completion_timeout(). A timed out DMA transfer is therefore > unmapped and reported as successful to the NAND read/write path. > > Return -ETIMEDOUT when the completion wait expires. Terminate the DMA > channel before unmapping the scatterlist so the timed out transfer cannot > continue to access the buffer after the error is returned. > > Signed-off-by: Pengpeng Hou > --- > drivers/mtd/nand/raw/lpc32xx_slc.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/drivers/mtd/nand/raw/lpc32xx_slc.c b/drivers/mtd/nand/raw/lpc32xx_slc.c > index 3ca30e7dc..10c808020 100644 > --- a/drivers/mtd/nand/raw/lpc32xx_slc.c > +++ b/drivers/mtd/nand/raw/lpc32xx_slc.c > @@ -430,6 +430,7 @@ static int lpc32xx_xmit_dma(struct mtd_info *mtd, dma_addr_t dma, > struct dma_async_tx_descriptor *desc; > int flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT; > int res; > + unsigned long time_left; > > host->dma_slave_config.direction = dir; > host->dma_slave_config.src_addr = dma; > @@ -467,12 +468,19 @@ static int lpc32xx_xmit_dma(struct mtd_info *mtd, dma_addr_t dma, > dmaengine_submit(desc); > dma_async_issue_pending(host->dma_chan); > > - wait_for_completion_timeout(&host->comp, msecs_to_jiffies(1000)); > + time_left = wait_for_completion_timeout(&host->comp, > + msecs_to_jiffies(1000)); > + if (!time_left) { > + dmaengine_terminate_sync(host->dma_chan); > + res = -ETIMEDOUT; > + } else { > + res = 0; > + } > > dma_unmap_sg(host->dma_chan->device->dev, &host->sgl, 1, > DMA_BIDIRECTIONAL); > > - return 0; > + return res; > out1: > dma_unmap_sg(host->dma_chan->device->dev, &host->sgl, 1, > DMA_BIDIRECTIONAL); Thank you for the change. Reviewed-by: Vladimir Zapolskiy -- Best wishes, Vladimir