This is a note to let you know that I've just added the patch titled ntb: Clean up tx tail index on link down to the 5.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: ntb-clean-up-tx-tail-index-on-link-down.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From cc79bd2738c2d40aba58b2be6ce47dc0e471df0e Mon Sep 17 00:00:00 2001 From: Dave Jiang <dave.jiang@xxxxxxxxx> Date: Tue, 22 Aug 2023 09:04:45 -0700 Subject: ntb: Clean up tx tail index on link down From: Dave Jiang <dave.jiang@xxxxxxxxx> commit cc79bd2738c2d40aba58b2be6ce47dc0e471df0e upstream. The tx tail index is not reset when the link goes down. This causes the tail index to go out of sync when the link goes down and comes back up. Refactor the ntb_qp_link_down_reset() and reset the tail index as well. Fixes: 2849b5d70641 ("NTB: Reset transport QP link stats on down") Reported-by: Yuan Y Lu <yuan.y.lu@xxxxxxxxx> Tested-by: Yuan Y Lu <yuan.y.lu@xxxxxxxxx> Reviewed-by: Logan Gunthorpe <logang@xxxxxxxxxxxx> Signed-off-by: Dave Jiang <dave.jiang@xxxxxxxxx> Signed-off-by: Jon Mason <jdmason@xxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/ntb/ntb_transport.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) --- a/drivers/ntb/ntb_transport.c +++ b/drivers/ntb/ntb_transport.c @@ -911,7 +911,7 @@ static int ntb_set_mw(struct ntb_transpo return 0; } -static void ntb_qp_link_down_reset(struct ntb_transport_qp *qp) +static void ntb_qp_link_context_reset(struct ntb_transport_qp *qp) { qp->link_is_up = false; qp->active = false; @@ -934,6 +934,13 @@ static void ntb_qp_link_down_reset(struc qp->tx_async = 0; } +static void ntb_qp_link_down_reset(struct ntb_transport_qp *qp) +{ + ntb_qp_link_context_reset(qp); + if (qp->remote_rx_info) + qp->remote_rx_info->entry = qp->rx_max_entry - 1; +} + static void ntb_qp_link_cleanup(struct ntb_transport_qp *qp) { struct ntb_transport_ctx *nt = qp->transport; @@ -1176,7 +1183,7 @@ static int ntb_transport_init_queue(stru qp->ndev = nt->ndev; qp->client_ready = false; qp->event_handler = NULL; - ntb_qp_link_down_reset(qp); + ntb_qp_link_context_reset(qp); if (mw_num < qp_count % mw_count) num_qps_mw = qp_count / mw_count + 1; Patches currently in stable-queue which might be from dave.jiang@xxxxxxxxx are queue-5.10/ntb-fix-calculation-ntb_transport_tx_free_entry.patch queue-5.10/ntb-clean-up-tx-tail-index-on-link-down.patch queue-5.10/ntb-drop-packets-when-qp-link-is-down.patch