FAILED: patch "[PATCH] net: mana: Fix doorbell out of order violation and avoid" failed to apply to 5.15-stable tree
Subsystems (5)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 58a63729c957621f1990c3494c702711188ca347
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2024081950-tweed-tattle-7f2c@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^..
Possible dependencies:
58a63729c957 ("net: mana: Fix doorbell out of order violation and avoid unnecessary doorbell rings") 18010ff776fa ("net: mana: Fix race on per-CQ variable napi work_done")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 58a63729c957621f1990c3494c702711188ca347 Mon Sep 17 00:00:00 2001
From: Long Li <[email protected]>
Date: Fri, 9 Aug 2024 08:58:58 -0700
Subject: [PATCH] net: mana: Fix doorbell out of order violation and avoid
unnecessary doorbell rings
After napi_complete_done() is called when NAPI is polling in the current process context, another NAPI may be scheduled and start running in softirq on another CPU and may ring the doorbell before the current CPU does. When combined with unnecessary rings when there is no need to arm the CQ, it triggers error paths in the hardware.
This patch fixes this by calling napi_complete_done() after doorbell rings. It limits the number of unnecessary rings when there is no need to arm. MANA hardware specifies that there must be one doorbell ring every 8 CQ wraparounds. This driver guarantees one doorbell ring as soon as the number of consumed CQEs exceeds 4 CQ wraparounds. In practical workloads, the 4 CQ wraparounds proves to be big enough that it rarely exceeds this limit before all the napi weight is consumed.
To implement this, add a per-CQ counter cq->work_done_since_doorbell, and make sure the CQ is armed as soon as passing 4 wraparounds of the CQ.
drivers/net/ethernet/microsoft/mana/mana_en.c +14 -8
@@ -1792,7 +1792,6 @@ static void mana_poll_rx_cq(struct mana_cq *cq)static int mana_cq_handler (void *context,struct gdma_queue *gdma_queue) {struct mana_cq *cq = context; -u8 arm_bit;int w;WARN_ON_ONCE (cq->gdma_cq != gdma_queue);
@@ -1803,16 +1802,23 @@ static int mana_cq_handler(void *context, struct gdma_queue *gdma_queue)mana_poll_tx_cq (cq); w = cq->work_done; + cq->work_done_since_doorbell += w; -if (w < cq->budget && -napi_complete_done (&cq->napi, w)) { - arm_bit =SET_ARM_BIT ; - }else { - arm_bit =0 ; +if (w < cq->budget) { +mana_gd_ring_cq (gdma_queue,SET_ARM_BIT ); + cq->work_done_since_doorbell =0 ; +napi_complete_done (&cq->napi, w); + }else if (cq->work_done_since_doorbell > + cq->gdma_cq->queue_size /COMP_ENTRY_SIZE *4 ) { +/* MANA hardware requires at least one doorbell ring every 8 +* wraparounds of CQ even if there is no need to arm the CQ. +* This driver rings the doorbell as soon as we have exceeded +* 4 wraparounds. +*/ +mana_gd_ring_cq (gdma_queue,0 ); + cq->work_done_since_doorbell =0 ; } -mana_gd_ring_cq (gdma_queue, arm_bit); -return w; }
include/net/mana/mana.h +1 -0
@@ -275,6 +275,7 @@ struct mana_cq {/* NAPI data */ struct napi_struct napi;int work_done; +int work_done_since_doorbell;int budget; };