svn commit: r354351 - stable/12/sys/dev/ow
Andriy Gapon
avg at FreeBSD.org
Tue Nov 5 07:00:11 UTC 2019
Author: avg
Date: Tue Nov 5 07:00:10 2019
New Revision: 354351
URL: https://svnweb.freebsd.org/changeset/base/354351
Log:
MFC r354067,r354068: ow_temp: drop the lock around a call that can sleep
And use better scopes for the lock.
Modified:
stable/12/sys/dev/ow/ow_temp.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/sys/dev/ow/ow_temp.c
==============================================================================
--- stable/12/sys/dev/ow/ow_temp.c Tue Nov 5 06:55:09 2019 (r354350)
+++ stable/12/sys/dev/ow/ow_temp.c Tue Nov 5 07:00:10 2019 (r354351)
@@ -143,9 +143,11 @@ ow_temp_event_thread(void *arg)
pause("owtstart", device_get_unit(sc->dev) * hz / 100); // 10ms stagger
mtx_lock(&sc->temp_lock);
sc->flags |= OW_TEMP_RUNNING;
+ mtx_unlock(&sc->temp_lock);
ow_temp_read_power_supply(sc->dev, &sc->parasite);
if (sc->parasite)
device_printf(sc->dev, "Running in parasitic mode unsupported\n");
+ mtx_lock(&sc->temp_lock);
while ((sc->flags & OW_TEMP_DONE) == 0) {
mtx_unlock(&sc->temp_lock);
ow_temp_convert_t(sc->dev);
@@ -153,10 +155,9 @@ ow_temp_event_thread(void *arg)
msleep(sc, &sc->temp_lock, 0, "owtcvt", hz);
if (sc->flags & OW_TEMP_DONE)
break;
+ mtx_unlock(&sc->temp_lock);
for (retries = 5; retries > 0; retries--) {
- mtx_unlock(&sc->temp_lock);
rv = ow_temp_read_scratchpad(sc->dev, scratch, sizeof(scratch));
- mtx_lock(&sc->temp_lock);
if (rv == 0) {
crc = own_crc(sc->dev, scratch, sizeof(scratch) - 1);
if (crc == scratch[8]) {
@@ -180,6 +181,7 @@ ow_temp_event_thread(void *arg)
} else
sc->bad_reads++;
}
+ mtx_lock(&sc->temp_lock);
msleep(sc, &sc->temp_lock, 0, "owtcvt", sc->reading_interval);
}
sc->flags &= ~OW_TEMP_RUNNING;
More information about the svn-src-all
mailing list