From nobody Sun Dec 26 02:08:01 2021 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 7387E19003B3; Sun, 26 Dec 2021 02:08:01 +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 4JM42T1Vfdz4RZD; Sun, 26 Dec 2021 02:08:01 +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 1347122044; Sun, 26 Dec 2021 02:08:01 +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 1BQ281wt040785; Sun, 26 Dec 2021 02:08:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BQ281b9040784; Sun, 26 Dec 2021 02:08:01 GMT (envelope-from git) Date: Sun, 26 Dec 2021 02:08:01 GMT Message-Id: <202112260208.1BQ281b9040784@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: 6c101ed7a3f7 - main - amdtemp: Remove CTLFLAG_NEEDGIANT from sysctls. 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: mav X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6c101ed7a3f7cb47d6ac5c9e5fd33580ac8fa699 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640484481; 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=oZxg7BhFaPeIo6BxWoY3Nkz6x2Oo+nQL5UT+Iht74vA=; b=wnFC6dg7Cvy+cAbgon9EL9XJywkRYjTJ913ELbM2HTZiMOOpevGrZgKF7ttRit2LjwZX6z Q9T957OUk5ypl1TNYOLqUpONUsnBh+tgKZx86qr53bHmeSN1a6HMbCe4mE7b0e8uj537Ge mfK2j7iYjDZN5BXcUI4YyKFcGsgCsf/0hOea3fCfNVM8cN7Kcm1C5Dt0TZoGFVfm2iBHgx oxYKWHUbhMJfJ0T08foW1sfWfcN2LFJM33p4qu0MFOwzjqk/qg//VobPJ5ezcqyJ8HXUZo Bgjk5kPhOnJ6S6PcQkbqSxHDbIFN9VlQdEyP98sM/XrWQx96EdF4ZLF3Ttjskw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640484481; a=rsa-sha256; cv=none; b=hIegz5Uxcx55XvZ8ABU7wuJOsdSI5+GCK37Y45m+piwMS/qLESwAVWBbd1cUIoGeyNsxGQ HwPD6Urce7MZYMMmC5dnYl+k7idbb6XtMM02jyTgLWgg8LmpuBeESrzeSq7x4RJH7FrYgS waHHNaWgt5WzU3RpD3yWrqfVfYBGQpXFhCPbZOmGf1KzyEvG8+4ThEV5R3Igqpeh82wNfm TVzovkd+E6VbPNhVuYsu2jLib7mGNO0f2IYMO/XPstlpauMYxvjGBPThz5X1EchoDmSLcZ yeB3a0JJj32DtwbdWzuh1s09ZtPLKKk8XdsSGIIhBtgT+rcHctttfKjcFO2Xjg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=6c101ed7a3f7cb47d6ac5c9e5fd33580ac8fa699 commit 6c101ed7a3f7cb47d6ac5c9e5fd33580ac8fa699 Author: Alexander Motin AuthorDate: 2021-12-26 02:03:54 +0000 Commit: Alexander Motin CommitDate: 2021-12-26 02:03:54 +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 --- 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 4606f03ae63c..c8b40b0d68d4 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); }