Commit 50fb6f13 authored by Tudor Ambarus's avatar Tudor Ambarus Committed by sanglipeng
Browse files

dmaengine: at_hdmac: Fix impossible condition

stable inclusion
from stable-v5.10.155
commit 85f97c97efc501191bb73020e98d822561d61828
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7M5F4

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=85f97c97efc501191bb73020e98d822561d61828



--------------------------------

commit 28cbe5a0 upstream.

The iterator can not be greater than ATC_MAX_DSCR_TRIALS, as the for loop
will stop when i == ATC_MAX_DSCR_TRIALS. While here, use the common "i"
name for the iterator.

Fixes: 93dce3a6 ("dmaengine: at_hdmac: fix residue computation")
Signed-off-by: default avatarTudor Ambarus <tudor.ambarus@microchip.com>
Cc: stable@vger.kernel.org
Acked-by: default avatarNicolas Ferre <nicolas.ferre@microchip.com>
Link: https://lore.kernel.org/r/20221025090306.297886-1-tudor.ambarus@microchip.com
Link: https://lore.kernel.org/r/20221025090306.297886-15-tudor.ambarus@microchip.com


Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarsanglipeng <sanglipeng1@jd.com>
parent 065cd168
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -299,7 +299,8 @@ static int atc_get_bytes_left(struct dma_chan *chan, dma_cookie_t cookie)
	struct at_desc *desc_first = atc_first_active(atchan);
	struct at_desc *desc;
	int ret;
	u32 ctrla, dscr, trials;
	u32 ctrla, dscr;
	unsigned int i;

	/*
	 * If the cookie doesn't match to the currently running transfer then
@@ -369,7 +370,7 @@ static int atc_get_bytes_left(struct dma_chan *chan, dma_cookie_t cookie)
		dscr = channel_readl(atchan, DSCR);
		rmb(); /* ensure DSCR is read before CTRLA */
		ctrla = channel_readl(atchan, CTRLA);
		for (trials = 0; trials < ATC_MAX_DSCR_TRIALS; ++trials) {
		for (i = 0; i < ATC_MAX_DSCR_TRIALS; ++i) {
			u32 new_dscr;

			rmb(); /* ensure DSCR is read after CTRLA */
@@ -395,7 +396,7 @@ static int atc_get_bytes_left(struct dma_chan *chan, dma_cookie_t cookie)
			rmb(); /* ensure DSCR is read before CTRLA */
			ctrla = channel_readl(atchan, CTRLA);
		}
		if (unlikely(trials >= ATC_MAX_DSCR_TRIALS))
		if (unlikely(i == ATC_MAX_DSCR_TRIALS))
			return -ETIMEDOUT;

		/* for the first descriptor we can be more accurate */