diff options
| author | msaitoh <msaitoh@NetBSD.org> | 2017-09-06 11:08:53 +0000 |
|---|---|---|
| committer | msaitoh <msaitoh@NetBSD.org> | 2017-09-06 11:08:53 +0000 |
| commit | 11f94a5ea2601f2ef3c4039ce4a69b7ac6459f5d (patch) | |
| tree | 29c8622bb584f53cc2f43ad487014eabfef179c2 /sys/dev/sysmon | |
| parent | d9dd199960be4a59b38429dfb12336dbbad1d3aa (diff) | |
Fixes a problem that some driver(e.g. acpitz(4) or coretemp(5)) which
use sysmon_envsys sleep waiting at "rndsrc" when "drvctl -d".
Don't call rnd_detach_source() in sme_remove_event() which is called
from sme_event_unregister_all(). Instead, call rnd_detach_source() in
sysmon_envsys_sensor_detach() and call sysmon_envsys_sensor_detach()
before sme_event_unregister_sensor(). Each sensor(envsys_data) has each
rnd_src, but some sme_events point to the same rnd_src in a sensor.
Calling rnd_detach_souce() twice with the same rnd_src brokes a reference
count in rnd_src. OK'd by pgoyette@.
Diffstat (limited to 'sys/dev/sysmon')
| -rw-r--r-- | sys/dev/sysmon/sysmon_envsys.c | 11 | ||||
| -rw-r--r-- | sys/dev/sysmon/sysmon_envsys_events.c | 6 |
2 files changed, 11 insertions, 6 deletions
diff --git a/sys/dev/sysmon/sysmon_envsys.c b/sys/dev/sysmon/sysmon_envsys.c index a0c9c6ea659..cc9ea02cd68 100644 --- a/sys/dev/sysmon/sysmon_envsys.c +++ b/sys/dev/sysmon/sysmon_envsys.c @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_envsys.c,v 1.139 2015/12/14 01:08:47 pgoyette Exp $ */ +/* $NetBSD: sysmon_envsys.c,v 1.140 2017/09/06 11:08:53 msaitoh Exp $ */ /*- * Copyright (c) 2007, 2008 Juan Romero Pardines. @@ -64,7 +64,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.139 2015/12/14 01:08:47 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.140 2017/09/06 11:08:53 msaitoh Exp $"); #include <sys/param.h> #include <sys/types.h> @@ -650,6 +650,8 @@ sysmon_envsys_sensor_detach(struct sysmon_envsys *sme, envsys_data_t *edata) /* * remove it, unhook from rnd(4), and decrement the sensors count. */ + if (oedata->flags & ENVSYS_FHAS_ENTROPY) + rnd_detach_source(&oedata->rnd_src); sme_event_unregister_sensor(sme, edata); if (LIST_EMPTY(&sme->sme_events_list)) { sme_events_halt_callout(sme); @@ -970,6 +972,7 @@ sysmon_envsys_unregister(struct sysmon_envsys *sme) { prop_array_t array; struct sysmon_envsys *osme; + envsys_data_t *edata; KASSERT(sme != NULL); @@ -987,6 +990,10 @@ sysmon_envsys_unregister(struct sysmon_envsys *sme) LIST_REMOVE(sme, sme_list); mutex_exit(&sme_global_mtx); + TAILQ_FOREACH(edata, &sme->sme_sensors_list, sensors_head) { + sysmon_envsys_sensor_detach(sme, edata); + } + /* * Unregister all events associated with device. */ diff --git a/sys/dev/sysmon/sysmon_envsys_events.c b/sys/dev/sysmon/sysmon_envsys_events.c index 7f5407e722c..8b74656bcad 100644 --- a/sys/dev/sysmon/sysmon_envsys_events.c +++ b/sys/dev/sysmon/sysmon_envsys_events.c @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_envsys_events.c,v 1.119 2017/06/01 02:45:11 chs Exp $ */ +/* $NetBSD: sysmon_envsys_events.c,v 1.120 2017/09/06 11:08:53 msaitoh Exp $ */ /*- * Copyright (c) 2007, 2008 Juan Romero Pardines. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.119 2017/06/01 02:45:11 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.120 2017/09/06 11:08:53 msaitoh Exp $"); #include <sys/param.h> #include <sys/types.h> @@ -480,8 +480,6 @@ sme_remove_event(sme_event_t *see, struct sysmon_envsys *sme) KASSERT(mutex_owned(&sme->sme_mtx)); - if (see->see_edata->flags & ENVSYS_FHAS_ENTROPY) - rnd_detach_source(&see->see_edata->rnd_src); LIST_REMOVE(see, see_list); kmem_free(see, sizeof(*see)); } |
