aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Jiang <[email protected]>2023-08-22 09:04:57 -0700
committerJon Mason <[email protected]>2023-08-22 12:38:19 -0400
commit5a7693e6bbf19b22fd6c1d2c4b7beb0a03969e2c (patch)
tree65c59838f0fbef539e46bd43bb6a4ae8178fd513
parentf195a1a6fe416882984f8bd6c61afc1383171860 (diff)
ntb: Fix calculation ntb_transport_tx_free_entry()
ntb_transport_tx_free_entry() never returns 0 with the current calculation. If head == tail, then it would return qp->tx_max_entry. Change compare to tail >= head and when they are equal, a 0 would be returned. Fixes: e74bfeedad08 ("NTB: Add flow control to the ntb_netdev") Reviewed-by: Logan Gunthorpe <[email protected]> Signed-off-by: renlonglong <[email protected]> Signed-off-by: Dave Jiang <[email protected]> Signed-off-by: Jon Mason <[email protected]>
-rw-r--r--drivers/ntb/ntb_transport.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index 7884ea9c7643..9532108d2dce 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -2429,7 +2429,7 @@ unsigned int ntb_transport_tx_free_entry(struct ntb_transport_qp *qp)
unsigned int head = qp->tx_index;
unsigned int tail = qp->remote_rx_info->entry;
- return tail > head ? tail - head : qp->tx_max_entry + tail - head;
+ return tail >= head ? tail - head : qp->tx_max_entry + tail - head;
}
EXPORT_SYMBOL_GPL(ntb_transport_tx_free_entry);