Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eb1fa481 authored by Dave Jiang's avatar Dave Jiang Committed by Greg Kroah-Hartman
Browse files

ntb: Fix calculation ntb_transport_tx_free_entry()



commit 5a7693e6bbf19b22fd6c1d2c4b7beb0a03969e2c upstream.

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: e74bfeed ("NTB: Add flow control to the ntb_netdev")
Reviewed-by: default avatarLogan Gunthorpe <logang@deltatee.com>
Signed-off-by: default avatarrenlonglong <ren.longlong@h3c.com>
Signed-off-by: default avatarDave Jiang <dave.jiang@intel.com>
Signed-off-by: default avatarJon Mason <jdmason@kudzu.us>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b2a6a169
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2431,7 +2431,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);