From nobody Sat Aug 17 18:34:26 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WmSFG29LZz5TTx9; Sat, 17 Aug 2024 18:34:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WmSFG1h4Pz461M; Sat, 17 Aug 2024 18:34:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723919666; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4UGyfQIIAXny18HNwVBsxomGEYWcqHUpRpHCQjMTi2M=; b=LukUd1+P+xhxM3+1JTokzSMumTiuBNGRTg7fF4RNRWQYmzkW3Zpp454eFoq7tvklYvN2Bw HayZmctHrCaCQqLI7982lIL/gUGGv42FRxKD038U0Id83b80YyhHqdtODziDni6bilT15v Ncvo5bRBplZhXpshfi/kBmSyi/zX6DYw6yLNQIQ3RF+l1aSos4D6IA3n4Iv4uY9gcOrUli FkLtBMdNBLucH+N1Z+zfj81qfdlsJdMiSICc7Vvjh2nDp6VCa/B3F3ro3V22IEPPUowz1Z aLicEQpY82F++9AUJh9QKvrDbOa168FsHdayYPqifE08GgPKAfX0YJgqPJnscA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1723919666; a=rsa-sha256; cv=none; b=g7zGUoY0nlf4PAk2rqJ8Md4E8rH06K25oSeWopDL9FMTm+p5RVGO8C3mBxnb1U2FmyaLWw DM1kEhcFoJpUunPlXbfRGQgz0KC+azFNPcGXwwXF21VgG4bLxk30ofhBwdCSOlpeOwfMCE 77AJM3t40NpRNy+NterlpLI5ontBYfHxlITUWABRLdXDwm/4t2XN8rgNmXKr1/3xuKdjdR 0K5yBQfgT7DuELs5gE/bq9yOBRk9vVnkIGdIgm8d9uac/WWvCTzNHQVjkyY9UcAKGut2Sc jTLrvIVIBvZaoHSWLxk+sHAqQqs0Bv+uyh7hJWeYf7Yfs+qXf72bxK0cY/0kKg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723919666; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4UGyfQIIAXny18HNwVBsxomGEYWcqHUpRpHCQjMTi2M=; b=AfFjfbqL2j8aSAMBkqYa6/dXRUBHFFwp09EDth8ZOOaUOhyBWrrpCU4oEcAq6rhFXu9b3K bOAeyFrlw/UED1xPyfAxsNTTgnQWWcsPpwpUTQw3P79adq1pVBOqEiMCH4uLev2FZrhd72 yfWM83u3tDYGwcs8WtYGgachbK3v2ixbx+OQF7f6dH0pugAedWNPd62cH+Q5PRV5xbxijb 0+jEGlPoUGhB5anMqtx+5Iq6HH94Gf9x2C0jDw/nBUW6/ayfW0MVebsbYRaygWiCeYRAu+ Yn7L4AMAiHncD4LgsbwRxwZxKxHFRjBlGT46wJ40c+fUoUNtZWFy0qq/Mu3JpQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WmSFG15NJz11GZ; Sat, 17 Aug 2024 18:34:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 47HIYQ6C022399; Sat, 17 Aug 2024 18:34:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47HIYQFr022396; Sat, 17 Aug 2024 18:34:26 GMT (envelope-from git) Date: Sat, 17 Aug 2024 18:34:26 GMT Message-Id: <202408171834.47HIYQFr022396@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Navdeep Parhar Subject: git: 0a9d1da6e6ce - main - cxgbe(4): Stop work request queues in a reliable manner. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0a9d1da6e6cede5e9c0ff63240d724049ad72b5b Auto-Submitted: auto-generated The branch main has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=0a9d1da6e6cede5e9c0ff63240d724049ad72b5b commit 0a9d1da6e6cede5e9c0ff63240d724049ad72b5b Author: Navdeep Parhar AuthorDate: 2024-07-31 19:27:18 +0000 Commit: Navdeep Parhar CommitDate: 2024-08-17 18:23:32 +0000 cxgbe(4): Stop work request queues in a reliable manner. Clear the EQ_HW_ALLOCATED flag with the wrq lock held and discard all work requests, pending or new, when it's not set. MFC after: 1 week Sponsored by: Chelsio Communications --- sys/dev/cxgbe/adapter.h | 5 ++++- sys/dev/cxgbe/t4_main.c | 20 +++++++++++++++++++- sys/dev/cxgbe/t4_sge.c | 15 ++++++++++++++- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index 0d731e736823..3922bd3909fe 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -1561,7 +1561,10 @@ t4_wrq_tx(struct adapter *sc, struct wrqe *wr) struct sge_wrq *wrq = wr->wrq; TXQ_LOCK(wrq); - t4_wrq_tx_locked(sc, wrq, wr); + if (__predict_true(wrq->eq.flags & EQ_HW_ALLOCATED)) + t4_wrq_tx_locked(sc, wrq, wr); + else + free(wr, M_CXGBE); TXQ_UNLOCK(wrq); } diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 795c8d7e2e37..57c1eeceab22 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -2060,7 +2060,9 @@ stop_lld(struct adapter *sc) } #if defined(TCP_OFFLOAD) || defined(RATELIMIT) for_each_ofld_txq(vi, k, ofld_txq) { + TXQ_LOCK(&ofld_txq->wrq); ofld_txq->wrq.eq.flags &= ~EQ_HW_ALLOCATED; + TXQ_UNLOCK(&ofld_txq->wrq); } #endif for_each_rxq(vi, k, rxq) { @@ -2078,7 +2080,9 @@ stop_lld(struct adapter *sc) if (sc->flags & FULL_INIT_DONE) { /* Control queue */ wrq = &sc->sge.ctrlq[i]; + TXQ_LOCK(wrq); wrq->eq.flags &= ~EQ_HW_ALLOCATED; + TXQ_UNLOCK(wrq); quiesce_wrq(wrq); } } @@ -7047,8 +7051,22 @@ quiesce_txq(struct sge_txq *txq) static void quiesce_wrq(struct sge_wrq *wrq) { + struct wrqe *wr; - /* XXXTX */ + TXQ_LOCK(wrq); + while ((wr = STAILQ_FIRST(&wrq->wr_list)) != NULL) { + STAILQ_REMOVE_HEAD(&wrq->wr_list, link); +#ifdef INVARIANTS + wrq->nwr_pending--; + wrq->ndesc_needed -= howmany(wr->wr_len, EQ_ESIZE); +#endif + free(wr, M_CXGBE); + } + MPASS(wrq->nwr_pending == 0); + MPASS(wrq->ndesc_needed == 0); + wrq->nwr_pending = 0; + wrq->ndesc_needed = 0; + TXQ_UNLOCK(wrq); } static void diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index b4eb0701821a..bc81a0251deb 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -2921,6 +2921,10 @@ start_wrq_wr(struct sge_wrq *wrq, int len16, struct wrq_cookie *cookie) MPASS(ndesc > 0 && ndesc <= SGE_MAX_WR_NDESC); EQ_LOCK(eq); + if (__predict_false((eq->flags & EQ_HW_ALLOCATED) == 0)) { + EQ_UNLOCK(eq); + return (NULL); + } if (TAILQ_EMPTY(&wrq->incomplete_wrs) && !STAILQ_EMPTY(&wrq->wr_list)) drain_wrq_wr_list(sc, wrq); @@ -3016,7 +3020,10 @@ commit_wrq_wr(struct sge_wrq *wrq, void *w, struct wrq_cookie *cookie) F_FW_WR_EQUEQ); } - ring_eq_db(wrq->adapter, eq, ndesc); + if (__predict_true(eq->flags & EQ_HW_ALLOCATED)) + ring_eq_db(wrq->adapter, eq, ndesc); + else + IDXINCR(eq->dbidx, ndesc, eq->sidx); } else { MPASS(IDXDIFF(next->pidx, pidx, eq->sidx) == ndesc); next->pidx = pidx; @@ -3852,6 +3859,8 @@ alloc_ctrlq(struct adapter *sc, int idx) if (!(ctrlq->eq.flags & EQ_HW_ALLOCATED)) { MPASS(ctrlq->eq.flags & EQ_SW_ALLOCATED); + MPASS(ctrlq->nwr_pending == 0); + MPASS(ctrlq->ndesc_needed == 0); rc = alloc_eq_hwq(sc, NULL, &ctrlq->eq); if (rc != 0) { @@ -4554,6 +4563,7 @@ free_wrq(struct adapter *sc, struct sge_wrq *wrq) { free_eq(sc, &wrq->eq); MPASS(wrq->nwr_pending == 0); + MPASS(wrq->ndesc_needed == 0); MPASS(TAILQ_EMPTY(&wrq->incomplete_wrs)); MPASS(STAILQ_EMPTY(&wrq->wr_list)); bzero(wrq, sizeof(*wrq)); @@ -4848,6 +4858,9 @@ alloc_ofld_txq(struct vi_info *vi, struct sge_ofld_txq *ofld_txq, int idx) } if (!(eq->flags & EQ_HW_ALLOCATED)) { + MPASS(eq->flags & EQ_SW_ALLOCATED); + MPASS(ofld_txq->wrq.nwr_pending == 0); + MPASS(ofld_txq->wrq.ndesc_needed == 0); rc = alloc_eq_hwq(sc, vi, eq); if (rc != 0) { CH_ERR(vi, "failed to create hw ofld_txq%d: %d\n", idx,