From nobody Sun Jan 09 01:27:43 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 A64BD193E44B; Sun, 9 Jan 2022 01:27:44 +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 4JWfTW5ct2z3LSX; Sun, 9 Jan 2022 01:27:43 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 48F3A115F; Sun, 9 Jan 2022 01:27:43 +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 2091RhZU001794; Sun, 9 Jan 2022 01:27:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2091RhW6001793; Sun, 9 Jan 2022 01:27:43 GMT (envelope-from git) Date: Sun, 9 Jan 2022 01:27:43 GMT Message-Id: <202201090127.2091RhW6001793@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: 2a36679b74e0 - stable/13 - amdtemp: Remove CTLFLAG_NEEDGIANT from sysctls. 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: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2a36679b74e06f630d3ce0db53ab6299fc87ebd5 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641691663; 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=6VKCQdF496itGEDnM3yQmbzyGU5QggC/xACFNIox48s=; b=C/9xhk6z3UwqbWYezOWlkFNAT+PxANlgHDb/RXHU3ClrR+z/RA3ERsk+o+AFUniKMskxIw zRV+ZRqXL7i/9aCDsonDer13+jtjzTmrnLGJVIY6oz7wDNHFB9arF6eET78Dpc0NijjtsE HlNusDLreWiMD4MEEXL4ceAco+QSl1j1cgHo0/NHDJJThwbOrMpPPkc9cDyWYcQH+xEF8D PWzd6znIXQn3jZrWBPgZWz5qgUzg+6P2FnAzO1I7hNp0PJb56YHxFn/G9KqKKdpE52tOaI TnZqhk8grhzTO5KxuyzYuuRQahrxuLzJGMa/06ZBmNPBzci/ImlaTpEjanRKTg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641691663; a=rsa-sha256; cv=none; b=OCt1PeIN/VM4qTG5A6l8NBsK/xcTH2fzsgPrj0cFVZBuJCOFG25GLg0oVALgr1yQdUbzrw zlZDQhJoezfNQIo90RV44VTqcDw4wgnnLumr33paxD5A+UU8TH9uDALoR3p3+IPVpB7t/r qC40W2TdbZ1mZb9JygG4+1nCgP0vaXnutZZZzlTs4MMt0VFxyuqdvLggLpdUmJsRZX1WZP Vjf3Bt5LmG98vtnV5p2VLoidvKzy68Es8ubQFQtNCzC58JKpkhNdHdJBTtDFOUs+/yJ/x5 0pDT2q5JLcl7DdK0pxVTK+TmPAemGrv46VJA2DGBHk19zD3Cyft19EbwVjYGcw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=2a36679b74e06f630d3ce0db53ab6299fc87ebd5 commit 2a36679b74e06f630d3ce0db53ab6299fc87ebd5 Author: Alexander Motin AuthorDate: 2021-12-26 02:03:54 +0000 Commit: Alexander Motin CommitDate: 2022-01-09 01:24:07 +0000 amdtemp: Remove CTLFLAG_NEEDGIANT from sysctls. It seems to be needed only to serialize very old K8 registers access. Introduce separate lock for that and remove Giant dependency. MFC after: 2 weeks (cherry picked from commit 6c101ed7a3f7cb47d6ac5c9e5fd33580ac8fa699) --- sys/dev/amdtemp/amdtemp.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/sys/dev/amdtemp/amdtemp.c b/sys/dev/amdtemp/amdtemp.c index 21227a47c513..493f619c0427 100644 --- a/sys/dev/amdtemp/amdtemp.c +++ b/sys/dev/amdtemp/amdtemp.c @@ -41,7 +41,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include +#include #include #include @@ -86,6 +88,7 @@ struct amdtemp_softc { struct sysctl_oid *sc_sysctl_cpu[MAXCPU]; struct intr_config_hook sc_ich; device_t sc_smn; + struct mtx sc_lock; }; /* @@ -479,6 +482,7 @@ amdtemp_attach(device_t dev) if (sc->sc_ncores > MAXCPU) return (ENXIO); + mtx_init(&sc->sc_lock, "amdtemp", NULL, MTX_DEF); if (erratum319) device_printf(dev, "Erratum 319: temperature measurement may be inaccurate\n"); @@ -506,7 +510,7 @@ amdtemp_attach(device_t dev) SYSCTL_ADD_PROC(sysctlctx, SYSCTL_CHILDREN(sysctlnode), OID_AUTO, "sensor0", - CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, dev, CORE0_SENSOR0, amdtemp_sysctl, "IK", "Core 0 / Sensor 0 temperature"); @@ -518,7 +522,7 @@ amdtemp_attach(device_t dev) SYSCTL_ADD_PROC(sysctlctx, SYSCTL_CHILDREN(sysctlnode), OID_AUTO, "sensor1", - CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, dev, CORE0_SENSOR1, amdtemp_sysctl, "IK", "Core 0 / Sensor 1 temperature"); @@ -531,14 +535,14 @@ amdtemp_attach(device_t dev) SYSCTL_ADD_PROC(sysctlctx, SYSCTL_CHILDREN(sysctlnode), OID_AUTO, "sensor0", - CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, dev, CORE1_SENSOR0, amdtemp_sysctl, "IK", "Core 1 / Sensor 0 temperature"); SYSCTL_ADD_PROC(sysctlctx, SYSCTL_CHILDREN(sysctlnode), OID_AUTO, "sensor1", - CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, dev, CORE1_SENSOR1, amdtemp_sysctl, "IK", "Core 1 / Sensor 1 temperature"); } @@ -591,7 +595,7 @@ amdtemp_intrhook(void *arg) sc->sc_sysctl_cpu[i] = SYSCTL_ADD_PROC(sysctlctx, SYSCTL_CHILDREN(device_get_sysctl_tree(cpu)), OID_AUTO, "temperature", - CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, dev, sensor, amdtemp_sysctl, "IK", "Current temparature"); } @@ -612,6 +616,7 @@ amdtemp_detach(device_t dev) /* NewBus removes the dev.amdtemp.N tree by itself. */ + mtx_destroy(&sc->sc_lock); return (0); } @@ -652,6 +657,8 @@ amdtemp_gettemp0f(device_t dev, amdsensor_t sensor) struct amdtemp_softc *sc = device_get_softc(dev); uint32_t mask, offset, temp; + mtx_lock(&sc->sc_lock); + /* Set Sensor/Core selector. */ temp = pci_read_config(dev, AMDTEMP_THERMTP_STAT, 1); temp &= ~(AMDTEMP_TTSR_SELCORE | AMDTEMP_TTSR_SELSENSOR); @@ -683,6 +690,7 @@ amdtemp_gettemp0f(device_t dev, amdsensor_t sensor) temp = ((temp >> 14) & mask) * 5 / 2; temp += AMDTEMP_ZERO_C_TO_K + (sc->sc_offset - offset) * 10; + mtx_unlock(&sc->sc_lock); return (temp); }