]>
Commit | Line | Data |
---|---|---|
d369aec6 SL |
1 | From cc6226dd773083288be31039503ee739b9517037 Mon Sep 17 00:00:00 2001 |
2 | From: Tomonori Sakita <tomonori.sakita@sord.co.jp> | |
3 | Date: Fri, 25 Jan 2019 11:02:22 +0900 | |
4 | Subject: net: altera_tse: fix msgdma_tx_completion on non-zero fill_level case | |
5 | ||
6 | [ Upstream commit 6571ebce112a21ec9be68ef2f53b96fcd41fd81b ] | |
7 | ||
8 | If fill_level was not zero and status was not BUSY, | |
9 | result of "tx_prod - tx_cons - inuse" might be zero. | |
10 | Subtracting 1 unconditionally results invalid negative return value | |
11 | on this case. | |
12 | Make sure not to return an negative value. | |
13 | ||
14 | Signed-off-by: Tomonori Sakita <tomonori.sakita@sord.co.jp> | |
15 | Signed-off-by: Atsushi Nemoto <atsushi.nemoto@sord.co.jp> | |
16 | Reviewed-by: Dalon L Westergreen <dalon.westergreen@linux.intel.com> | |
17 | Acked-by: Thor Thayer <thor.thayer@linux.intel.com> | |
18 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
19 | Signed-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 | ||
24 | diff --git a/drivers/net/ethernet/altera/altera_msgdma.c b/drivers/net/ethernet/altera/altera_msgdma.c | |
25 | index 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 | -- | |
39 | 2.19.1 | |
40 |