]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.163/net-altera_tse-fix-msgdma_tx_completion-on-non-zero-.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.163 / net-altera_tse-fix-msgdma_tx_completion-on-non-zero-.patch
CommitLineData
d369aec6
SL
1From cc6226dd773083288be31039503ee739b9517037 Mon Sep 17 00:00:00 2001
2From: Tomonori Sakita <tomonori.sakita@sord.co.jp>
3Date: Fri, 25 Jan 2019 11:02:22 +0900
4Subject: net: altera_tse: fix msgdma_tx_completion on non-zero fill_level case
5
6[ Upstream commit 6571ebce112a21ec9be68ef2f53b96fcd41fd81b ]
7
8If fill_level was not zero and status was not BUSY,
9result of "tx_prod - tx_cons - inuse" might be zero.
10Subtracting 1 unconditionally results invalid negative return value
11on this case.
12Make sure not to return an negative value.
13
14Signed-off-by: Tomonori Sakita <tomonori.sakita@sord.co.jp>
15Signed-off-by: Atsushi Nemoto <atsushi.nemoto@sord.co.jp>
16Reviewed-by: Dalon L Westergreen <dalon.westergreen@linux.intel.com>
17Acked-by: Thor Thayer <thor.thayer@linux.intel.com>
18Signed-off-by: David S. Miller <davem@davemloft.net>
19Signed-off-by: Sasha Levin <sashal@kernel.org>
20---
21 drivers/net/ethernet/altera/altera_msgdma.c | 3 ++-
22 1 file changed, 2 insertions(+), 1 deletion(-)
23
24diff --git a/drivers/net/ethernet/altera/altera_msgdma.c b/drivers/net/ethernet/altera/altera_msgdma.c
25index 0fb986ba3290..0ae723f75341 100644
26--- a/drivers/net/ethernet/altera/altera_msgdma.c
27+++ b/drivers/net/ethernet/altera/altera_msgdma.c
28@@ -145,7 +145,8 @@ u32 msgdma_tx_completions(struct altera_tse_private *priv)
29 & 0xffff;
30
31 if (inuse) { /* Tx FIFO is not empty */
32- ready = priv->tx_prod - priv->tx_cons - inuse - 1;
33+ ready = max_t(int,
34+ priv->tx_prod - priv->tx_cons - inuse - 1, 0);
35 } else {
36 /* Check for buffered last packet */
37 status = csrrd32(priv->tx_dma_csr, msgdma_csroffs(status));
38--
392.19.1
40