Date: Mon, 10 Jun 2019 03:16:55 +0000 (UTC) From: Justin Hibbits <jhibbits@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r348844 - head/sys/powerpc/powernv Message-ID: <201906100316.x5A3Gtj4005247@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhibbits Date: Mon Jun 10 03:16:55 2019 New Revision: 348844 URL: https://svnweb.freebsd.org/changeset/base/348844 Log: powerpc/powernv: Reduce the scope of the sensor guarding mutex vmem_xalloc() cannot be called while holding a nonblocking mutex, warned by WITNESS. The lock may not be necessary in general, but it avoids superfluous concurrent OPAL calls for the same sensor. Reported by: pkubaj Modified: head/sys/powerpc/powernv/opal_sensor.c Modified: head/sys/powerpc/powernv/opal_sensor.c ============================================================================== --- head/sys/powerpc/powernv/opal_sensor.c Mon Jun 10 03:07:10 2019 (r348843) +++ head/sys/powerpc/powernv/opal_sensor.c Mon Jun 10 03:16:55 2019 (r348844) @@ -92,13 +92,14 @@ const char *opal_sensor_types[] = { * Retrieve the raw value from OPAL. This will be cooked by the sysctl handler. */ static int -opal_sensor_get_val(uint32_t key, uint64_t *val) +opal_sensor_get_val(struct opal_sensor_softc *sc, uint32_t key, uint64_t *val) { struct opal_msg msg; uint32_t val32; int rv, token; token = opal_alloc_async_token(); + SENSOR_LOCK(sc); rv = opal_call(OPAL_SENSOR_READ, key, token, vtophys(&val32)); if (rv == OPAL_ASYNC_COMPLETION) { @@ -110,6 +111,7 @@ opal_sensor_get_val(uint32_t key, uint64_t *val) if (rv == OPAL_SUCCESS) val32 = msg.params[0]; } + SENSOR_UNLOCK(sc); if (rv == OPAL_SUCCESS) *val = val32; @@ -131,9 +133,7 @@ opal_sensor_sysctl(SYSCTL_HANDLER_ARGS) sc = arg1; sensor = arg2; - SENSOR_LOCK(sc); - error = opal_sensor_get_val(sensor, &sensval); - SENSOR_UNLOCK(sc); + error = opal_sensor_get_val(sc, sensor, &sensval); if (error) return (error);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201906100316.x5A3Gtj4005247>