From nobody Sat Feb 12 18:04:27 2022 X-Original-To: dev-commits-src-main@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 4B7C31957B10; Sat, 12 Feb 2022 18:04:28 +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 4Jwyzw1fb8z4vQN; Sat, 12 Feb 2022 18:04:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644689068; 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=CKTWLt2LLEPlQijhjXwfX4LZ5vQxYfhD2r6YflmCmdc=; b=a7ILqnkdRNlQHd6ZFSQfCxS+CvZBWBFsS4NusbFUFtJtTSH25A1vuIY+g9IIAmbXF6I2wP JgdEDhg6rhGC9mE+KLsAZrL4szBDl4EFGQFVljTnaABCIHbb0A4stniM8CXk5YnM9nqUbO Kemd6eoztVjDdw5luhg51cvyGatsbEizaq1fsATeeDuYiiwXNNjWOY9iIFSIk4gPC9Tgjq 6n2wR25BHdZOR36WcCxW5cpb80Qvm4VtQpFtTcHrxlSrKnCiDuv5JpsJ6rHC1FwHn1uu5K ZwRoaE3PA5tRcnb4JWML9+adEyoxgzS3rso3bIizMZ6EHCfKw6g0aQJUVRbdEg== 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 186C94587; Sat, 12 Feb 2022 18:04:28 +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 21CI4SJI049842; Sat, 12 Feb 2022 18:04:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21CI4Rc3049841; Sat, 12 Feb 2022 18:04:27 GMT (envelope-from git) Date: Sat, 12 Feb 2022 18:04:27 GMT Message-Id: <202202121804.21CI4Rc3049841@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: 08c7dc7fd473 - main - cxgbe(4): Fix illegal hardware access in cxgbe_refresh_stats. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: 08c7dc7fd4735b85e9696d0439af6cc98b23b25d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644689068; 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=CKTWLt2LLEPlQijhjXwfX4LZ5vQxYfhD2r6YflmCmdc=; b=URv1N5CI9VX7oMVhZisP9+7ofA7re2Hroa/3Rq5VtDYoijBG4VFcmIBRdcLgQGXsC5PXJZ BEuGYvx3vzR25VGGjEcGMe19MGlKMrL1BEFQIW08UjJ8CSxfYUq6zIEEnbLZhJtUqvNuau wa5cO5n8IkNloHDu+fXI0e76OjLbNZtPoV2FL6PN8rH/wkIQDTV/jdvCm2SA4msyrCKSpQ ZVBxRX/53XS0wTivduIMo7/SQBthnOpTBtlVBi31h6DE+TbylM3pKkQzZAPK/JLpiajKIi N9sOKWzHA07uTigR2vIURpeKHzDgGCtSCV6VYmmvD9naCMNSsUuW9PgWKtXc6A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1644689068; a=rsa-sha256; cv=none; b=TAKcxJL4YD4p/03IF1zdOUjwVJ3lautE9rVORZQ9HxxXfO2akg0q8y/zyZqV6j/DyO6dL0 pVbLibSLfQ6bPYC9/mXiMEhnSURBO2u3dAfrvw5ORK6pXVlxhPafZ5/56qBBiXhznmJW7a f/4nlT7Sd+4Djf/f/kX01Ret7JRYpEorusu7/B3wF1/8m7A93qT4nhb4+MdE2S0xWmq+r0 gRxW87dwmsNlYdx5OSvjUuSRaya/v05f1EEsPhpL+QRAzsiUcK+huP6TDQhPYVoe1OHAtH FjPc0vJAYicsPkdau35ZJCe+zBaiJUvNnqdO6mmdomtz7ElaMtrbd1uoQHE/Cg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=08c7dc7fd4735b85e9696d0439af6cc98b23b25d commit 08c7dc7fd4735b85e9696d0439af6cc98b23b25d Author: Navdeep Parhar AuthorDate: 2022-02-12 00:58:46 +0000 Commit: Navdeep Parhar CommitDate: 2022-02-12 17:53:50 +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. MFC after: 1 week Sponsored by: Chelsio Communications --- 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 08e9b32cf4d2..c16a4bddceed 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -1919,13 +1919,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); @@ -2256,6 +2258,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); @@ -2292,7 +2297,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); } @@ -7019,7 +7023,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);