From nobody Thu Jan 11 05:33:41 2024 X-Original-To: dev-commits-src-branches@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 4T9YHT47fRz56VXR; Thu, 11 Jan 2024 05:33:41 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4T9YHT3jqFz46BG; Thu, 11 Jan 2024 05:33:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704951221; 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=0cE/b3WwNLlDkEx75nErSz5qusbhVUVzHECJmeYmawU=; b=hFEdwAHU4MjJkzPNL7m7fUOcJLG9yRu/AIH7eZ8UPKdrQNlKD3mvK/2T7WJFJYCP0iR+QL 6lDVvoZQHBtGENEz+gHHLHr02Ii+yOkCaLesOT6Yw4FIPRuDhgRX4eJHzhjjBTTfzJ6Djl XE7lNKcgipUlSrXgi40XWIe/9WrI/j7SCn/kUGWstSIkxDlPa7mOUo64iJl3/Udh+oxU7m w8UcMbxQhu8O/u9GppVqeZ7sP7s1kp4NzWkO19ER/AbNiVKT5sVxdIzKcjrfunGQr9Gtco RijuViMdDdLm9h5SF9b+pe0V/Aue1FT9ICfCBZmRXN3yqzXVPD3Is3xN22w2aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704951221; 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=0cE/b3WwNLlDkEx75nErSz5qusbhVUVzHECJmeYmawU=; b=nxxIpHSTPQsFYaJehLd2kp6OAE2EUtbxDL3cPjSWpjtmxEvluOTdZOjjxeF1JlSKGsLs8d HMtzpwsKyY9KcJkef8khPD5aRQFDW+3EaRGDlNlGC7rj19XoL+hp4ILXrklGD39QURja7R p3NDFzvDn6QzTekAX7BnNoGuzctIg6xFsq7WT6rIFZpxnxprbJU9iwt6sXkUYEBKNljLxm mvLLmJBV3orsivMQg6T9UvHV4SJs6YUXWpA+HAiKwmQ13fL/nRiw8EWonlX+cxM1EqafIZ uqM4hW+rdFD4WGeCOf+CvcIsrvbMuomuPCjdmp6ro+fCTX7hr2EciJrw/dMYHg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704951221; a=rsa-sha256; cv=none; b=pDPj/2eQyDJzigU5fdrK8ZOwO63W/UT4fN/h8/KC3PdO59tnJokM4Cm6UsDSaXPFO1lZdP TRB4BKAwLPHI1vxnmTdUU5+1glNLWNBjxaLPOXo5EPDcnCmcXvPWWroCsSTvcWzUIVGnKn eSGGXYc9eVtdNVofAKjKeYGRW5ylXBLrePXrZRDsUlLjJyzsMP+rfJh9i/C8S2yIoMqHY6 1xbZqQFOFyG4lFkEZtaS2X6AFe/DAB4RRTum+L5CZW9EGtQQhDGueueHtF9+eVzbv7TRUs AsU8uu+HQcBaHA9qDs6ju9ofhVxkn8wvtX+LYkiO9+WGL71/aaY85GWYX3d4hw== 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 4T9YHT2p8Xz15yw; Thu, 11 Jan 2024 05:33:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40B5Xf0e009272; Thu, 11 Jan 2024 05:33:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40B5XfsZ009269; Thu, 11 Jan 2024 05:33:41 GMT (envelope-from git) Date: Thu, 11 Jan 2024 05:33:41 GMT Message-Id: <202401110533.40B5XfsZ009269@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 7d98a455a3ea - stable/14 - cxgbe(4): Fix virtual interface reattach. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/14 X-Git-Reftype: branch X-Git-Commit: 7d98a455a3ea91eadbd3c84c6cd85314f5e29529 Auto-Submitted: auto-generated The branch stable/14 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=7d98a455a3ea91eadbd3c84c6cd85314f5e29529 commit 7d98a455a3ea91eadbd3c84c6cd85314f5e29529 Author: Navdeep Parhar AuthorDate: 2024-01-02 21:20:45 +0000 Commit: Navdeep Parhar CommitDate: 2024-01-11 05:22:31 +0000 cxgbe(4): Fix virtual interface reattach. Replace the DOOMED flag with a transient DETACHING flag that is cleared when VI is detached. This fixes VI reattach when only the VI and not the parent nexus is detached. The old flag was never cleared and prevented subsequent synch op's related to the VI. PR: 275260 Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D43287 Sponsored by: Chelsio Communications (cherry picked from commit 0201eb29dde9dccbf796f81fbf18f3b21798183d) --- sys/dev/cxgbe/adapter.h | 10 ++++++---- sys/dev/cxgbe/t4_main.c | 33 +++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index ddb8621a2300..c3105ecacffd 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -170,7 +170,7 @@ enum { FIXED_IFMEDIA = (1 << 4), /* ifmedia list doesn't change. */ /* VI flags */ - DOOMED = (1 << 0), + VI_DETACHING = (1 << 0), VI_INIT_DONE = (1 << 1), /* 1 << 2 is unused, was VI_SYSCTL_CTX */ TX_USES_VM_WR = (1 << 3), @@ -184,8 +184,9 @@ enum { DF_VERBOSE_SLOWINTR = (1 << 4), /* Chatty slow intr handler */ }; -#define IS_DOOMED(vi) ((vi)->flags & DOOMED) -#define SET_DOOMED(vi) do {(vi)->flags |= DOOMED;} while (0) +#define IS_DETACHING(vi) ((vi)->flags & VI_DETACHING) +#define SET_DETACHING(vi) do {(vi)->flags |= VI_DETACHING;} while (0) +#define CLR_DETACHING(vi) do {(vi)->flags &= ~VI_DETACHING;} while (0) #define IS_BUSY(sc) ((sc)->flags & CXGBE_BUSY) #define SET_BUSY(sc) do {(sc)->flags |= CXGBE_BUSY;} while (0) #define CLR_BUSY(sc) do {(sc)->flags &= ~CXGBE_BUSY;} while (0) @@ -1355,8 +1356,9 @@ int t4_map_bar_2(struct adapter *); int t4_setup_intr_handlers(struct adapter *); void t4_sysctls(struct adapter *); int begin_synchronized_op(struct adapter *, struct vi_info *, int, char *); -void doom_vi(struct adapter *, struct vi_info *); void end_synchronized_op(struct adapter *, int); +void begin_vi_detach(struct adapter *, struct vi_info *); +void end_vi_detach(struct adapter *, struct vi_info *); int update_mac_settings(if_t, int); int adapter_init(struct adapter *); int vi_init(struct vi_info *); diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 570208e2c562..3b6cb7285e64 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -2755,17 +2755,14 @@ cxgbe_detach(device_t dev) device_delete_children(dev); sysctl_ctx_free(&pi->ctx); - doom_vi(sc, &pi->vi[0]); - + begin_vi_detach(sc, &pi->vi[0]); if (pi->flags & HAS_TRACEQ) { sc->traceq = -1; /* cloner should not create ifnet */ t4_tracer_port_detach(sc); } - cxgbe_vi_detach(&pi->vi[0]); ifmedia_removeall(&pi->media); - - end_synchronized_op(sc, 0); + end_vi_detach(sc, &pi->vi[0]); return (0); } @@ -3595,12 +3592,10 @@ vcxgbe_detach(device_t dev) vi = device_get_softc(dev); sc = vi->adapter; - doom_vi(sc, vi); - + begin_vi_detach(sc, vi); cxgbe_vi_detach(vi); t4_free_vi(sc, sc->mbox, sc->pf, 0, vi->viid); - - end_synchronized_op(sc, 0); + end_vi_detach(sc, vi); return (0); } @@ -6245,7 +6240,7 @@ begin_synchronized_op(struct adapter *sc, struct vi_info *vi, int flags, ADAPTER_LOCK(sc); for (;;) { - if (vi && IS_DOOMED(vi)) { + if (vi && IS_DETACHING(vi)) { rc = ENXIO; goto done; } @@ -6284,14 +6279,13 @@ done: /* * Tell if_ioctl and if_init that the VI is going away. This is * special variant of begin_synchronized_op and must be paired with a - * call to end_synchronized_op. + * call to end_vi_detach. */ void -doom_vi(struct adapter *sc, struct vi_info *vi) +begin_vi_detach(struct adapter *sc, struct vi_info *vi) { - ADAPTER_LOCK(sc); - SET_DOOMED(vi); + SET_DETACHING(vi); wakeup(&sc->flags); while (IS_BUSY(sc)) mtx_sleep(&sc->flags, &sc->sc_lock, 0, "t4detach", 0); @@ -6304,6 +6298,17 @@ doom_vi(struct adapter *sc, struct vi_info *vi) ADAPTER_UNLOCK(sc); } +void +end_vi_detach(struct adapter *sc, struct vi_info *vi) +{ + ADAPTER_LOCK(sc); + KASSERT(IS_BUSY(sc), ("%s: controller not busy.", __func__)); + CLR_BUSY(sc); + CLR_DETACHING(vi); + wakeup(&sc->flags); + ADAPTER_UNLOCK(sc); +} + /* * {begin|end}_synchronized_op must be called from the same thread. */