From nobody Wed Jan 03 19:26:01 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 4T507Z2vLFz56XXq; Wed, 3 Jan 2024 19:26:02 +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 4T507Z0m6Gz4HLB; Wed, 3 Jan 2024 19:26:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704309962; 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=JTMTnCKVNcgcuBjjyzLpnvutr7oRMTJI+jWUStL6S7I=; b=LLrJYgZjn6TPBnZ5VYy2UvT1rFUm3b3SyTQVfPdw6lMK7FEb9lRNrgo0faUBpSKMzOUfeh cDej6C9xbxEh1zw3paVU/3vUfklRy4MPENOGOGUh+GPkQYxulfLmKVu16WVMGMGya0l4hT O3Q8u85imYEza07el6TdtWX8/WS9+40R7c8u13OxZZm7GEQE8WvWaTMEXKQYOJg9NQcZNR XBxz8RylMGv8UzI433GXbuyAi3sDr1mcN7hT599CpOlAQLB6nNLr9vfMObSIkblDnaHCKy JLd8vcR4TEA5//WafZ/RXcNW8OVRn63l5PQIktQqWZqz6saQs94cixlwCXtjBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704309962; 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=JTMTnCKVNcgcuBjjyzLpnvutr7oRMTJI+jWUStL6S7I=; b=EXhRj0S1qWY1sUpQCPUDp8TfPFQQZLGE7LpG5jIECzeGJYJmKox76YyEBPGYzUeGDrVXQU pfZpqzr2vTen/TH9i0Ms3+LSW+iCDOOHdz1Nk50LRu4Vq2T8RoFWe4sJ9NQNyC4SW0lE0J Sr5/L8qjXQGxCAevL8Fd0o9dVVYL+46rKO6wwTXi+NdHLPdu1abPBDDqhOt1vRoQW5fOmD AayRtvGTeRYV5E20FFFwGI+isgcH+NsgZvcSROXND47Ob01/5JykbhMqn4wqo2g5B1Px43 M/8teCp/K/CQNjJAiaRwK+5V06zdZbDRYPWUHqwDfZkiND0r6QHICEF/H72EKA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704309962; a=rsa-sha256; cv=none; b=qtQVcSAGnuRJOC1W08N6/hIGS6RaURhIPnlIWtBFuW6xWO+lGnmvyO3sVQ102MmJyE248k pgoE+KBOv3xUOK+IClU39GW8J+5TmZmEQbXRUJYhkk5DmublZuADesquUAdeZpjlNS+tUb bTuo2v3CvnpjZuFLsbtNWTRkMl0wnGuOnlguxgjMrEk9NMQgNgBAOJ6CblfyTsTk6W68k/ 6/v5AARLabZotegA+j1Di6xhtl4/vTg6Ee0zx4KMCCmGvyynZ13h70IXuBHVFd0ztEkmNf 5HusUN5xLxTdkmnUsTAsPXpM5BmPhZeQo06NWgMy5zhptqPjWOaD87a2SDlVpQ== 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 4T507Y6q9lzy2f; Wed, 3 Jan 2024 19:26:01 +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 403JQ1ps003722; Wed, 3 Jan 2024 19:26:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 403JQ17O003719; Wed, 3 Jan 2024 19:26:01 GMT (envelope-from git) Date: Wed, 3 Jan 2024 19:26:01 GMT Message-Id: <202401031926.403JQ17O003719@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: 0201eb29dde9 - main - cxgbe(4): Fix virtual interface reattach. 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: 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: 0201eb29dde9dccbf796f81fbf18f3b21798183d Auto-Submitted: auto-generated The branch main has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=0201eb29dde9dccbf796f81fbf18f3b21798183d commit 0201eb29dde9dccbf796f81fbf18f3b21798183d Author: Navdeep Parhar AuthorDate: 2024-01-02 21:20:45 +0000 Commit: Navdeep Parhar CommitDate: 2024-01-03 19:21:46 +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 MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D43287 Sponsored by: Chelsio Communications --- 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. */