From nobody Mon Feb 28 06:55:53 2022 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 8865119D32A0; Mon, 28 Feb 2022 06:55:54 +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 4K6WP62XqRz4S0R; Mon, 28 Feb 2022 06:55:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646031354; 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=688MBcH3XY1N75tTxPomDMKXMK8ASjmvmnQspb3r+S0=; b=ajM0Mc+EQY9hDn6XUs80l3wGKDdRRd+z8n9OdegiqMfla9Js1Zl3sjEjqNf1jlsxZbJLe6 Xjd6EdAlJUW7OzkQBJ/cUH2b34LLY2yIVSN00fL8uWJHVXKMGU7fUrn+4uR7F+xB1ryyjb tQHKey7To2LvUWA6asydtsPq1lB+jXWj0MANxL8Ne1TrIp2Gx+SxLlq+sgS4/VjcL4C7M/ M6gRy+wldyolKzzgUkKr1xZNcm2qMg8yek6QKxei+Ay12JZFezYSJoCICTSLbnOrhYi4U8 u4xJ8ep+fhG0G755JBao6sCLsgdGWmimgSO7kEAhAISgEpFz7KtFGu51VEHluA== 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 DB12516DA1; Mon, 28 Feb 2022 06:55:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 21S6trwP078017; Mon, 28 Feb 2022 06:55:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21S6trNk078016; Mon, 28 Feb 2022 06:55:53 GMT (envelope-from git) Date: Mon, 28 Feb 2022 06:55:53 GMT Message-Id: <202202280655.21S6trNk078016@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: 2a139853129e - stable/13 - cxgbe(4): Fix illegal hardware access in cxgbe_refresh_stats. 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/13 X-Git-Reftype: branch X-Git-Commit: 2a139853129e890e8291bb215b97fa41a41ef7ae Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646031354; 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=688MBcH3XY1N75tTxPomDMKXMK8ASjmvmnQspb3r+S0=; b=MPq2JtrZ/Xw6qBaSGgaiFeB504r+KhnegHmF3zrXS4ieE/7Y1uymIlH5+Q3DAMApAAwoAm nmXcPDMN2of2Y4kUDyoMSM0Mg91qdeLmBnzYuMA/jcoeq5S1CMwPPyrXLDeYt5R6TD/3vE cd8MZGqRNe+6TDS1/TtftJWAgjAvI6ronaSL9u5ZeVtf1dQ5YKmfDxR1jvVWS2Bv83gIYb cubIR//f9klwbomr4zvWzuLeB7HRVXeJiibt+ZqLHTjPGXPOpDuO1nRwmuImQFzTpG+tBr /EqBOVlwD/hl6sL2urT9yvej0r+zBgpompQh97hYU3AUXtHDuQe5gPpZImK75Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646031354; a=rsa-sha256; cv=none; b=GBVzTg366lELRJ4CGjW7+glVLAkNfVJO5eCxCRjDVAeDu/r4UI/fY7L/pvyPAmAFxKTnwI l8zFMElJacUesRfUwROZwIzwrQkg/0+NzU3r9BPBgwMCUCpAs7fWOJphuuFTLSVzE+VXJe UUAB4k8ly1wWQIbpUAPwQzWIjQDfEIyf3y7x4vn/TY9c+8D+T1h/jHsm/q4Yl8Fp8ulJS3 PyiX9LoBCLwOeARhMAqAvgjg3kjFJSH3Skne6HAXiJaDi53LdIobUtkLradDsmp9zTm6Ou IkmD7WsURPA2b5LOyRgeDQQDfYJFk4+P/22GicY3o3e3XF1h0/j+lPc6U924hQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=2a139853129e890e8291bb215b97fa41a41ef7ae commit 2a139853129e890e8291bb215b97fa41a41ef7ae Author: Navdeep Parhar AuthorDate: 2022-02-12 00:58:46 +0000 Commit: Navdeep Parhar CommitDate: 2022-02-28 06:51:51 +0000 cxgbe(4): Fix illegal hardware access in cxgbe_refresh_stats. cxgbe_refresh_stats takes into account VI_SKIP_STATS but not VI_INIT_DONE when deciding whether to read the hardware stats. But before this change VI_SKIP_STATS was set only for VIs with VI_INIT_DONE. That meant that cxgbe_refresh_stats always accessed the hardware for uninitialized VIs, and this is a problem if the adapter is suspended or in the middle of a reset. Fix this by setting VI_SKIP_STATS on all VIs during suspend. While here, ignore VI_INIT_DONE in vi_refresh_stats too to be consistent with cxgbe_refresh_stats. Sponsored by: Chelsio Communications (cherry picked from commit 08c7dc7fd4735b85e9696d0439af6cc98b23b25d) --- sys/dev/cxgbe/t4_main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index e8f82e4aea3b..333373e69aea 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -1928,13 +1928,15 @@ t4_suspend(device_t dev) for_each_vi(pi, j, vi) { vi->xact_addr_filt = -1; + mtx_lock(&vi->tick_mtx); + vi->flags |= VI_SKIP_STATS; + mtx_unlock(&vi->tick_mtx); if (!(vi->flags & VI_INIT_DONE)) continue; ifp = vi->ifp; if (ifp->if_drv_flags & IFF_DRV_RUNNING) { mtx_lock(&vi->tick_mtx); - vi->flags |= VI_SKIP_STATS; callout_stop(&vi->tick); mtx_unlock(&vi->tick_mtx); callout_drain(&vi->tick); @@ -2265,6 +2267,9 @@ t4_resume(device_t dev) for_each_port(sc, i) { pi = sc->port[i]; for_each_vi(pi, j, vi) { + mtx_lock(&vi->tick_mtx); + vi->flags &= ~VI_SKIP_STATS; + mtx_unlock(&vi->tick_mtx); if (!(vi->flags & VI_INIT_DONE)) continue; rc = vi_full_init(vi); @@ -2301,7 +2306,6 @@ t4_resume(device_t dev) TXQ_UNLOCK(txq); } mtx_lock(&vi->tick_mtx); - vi->flags &= ~VI_SKIP_STATS; callout_schedule(&vi->tick, hz); mtx_unlock(&vi->tick_mtx); } @@ -7081,7 +7085,7 @@ vi_refresh_stats(struct vi_info *vi) mtx_assert(&vi->tick_mtx, MA_OWNED); - if (!(vi->flags & VI_INIT_DONE) || vi->flags & VI_SKIP_STATS) + if (vi->flags & VI_SKIP_STATS) return; getmicrotime(&tv);