CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: riastradh Date: Fri Dec 31 14:44:50 UTC 2021 Modified Files: src/sys/dev/sysmon: sysmonvar.h Log Message: sysmon(9): Document lock order. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sys/dev/sysmon/sysmonvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmonvar.h diff -u src/sys/dev/sysmon/sysmonvar.h:1.52 src/sys/dev/sysmon/sysmonvar.h:1.53 --- src/sys/dev/sysmon/sysmonvar.h:1.52 Fri Dec 31 14:30:04 2021 +++ src/sys/dev/sysmon/sysmonvar.h Fri Dec 31 14:44:50 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmonvar.h,v 1.52 2021/12/31 14:30:04 riastradh Exp $ */ +/* $NetBSD: sysmonvar.h,v 1.53 2021/12/31 14:44:50 riastradh Exp $ */ /*- * Copyright (c) 2000 Zembu Labs, Inc. @@ -217,6 +217,8 @@ struct sysmon_envsys { /* * Locking/synchronization. + * + * Lock order: sme_global_mtx -> sme_mtx -> sme_work_mtx */ int sme_busy; /* number of items on workqueue, * sme_work_mtx to read or write */
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: riastradh Date: Fri Dec 31 14:44:50 UTC 2021 Modified Files: src/sys/dev/sysmon: sysmonvar.h Log Message: sysmon(9): Document lock order. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sys/dev/sysmon/sysmonvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: riastradh Date: Fri Dec 31 14:30:04 UTC 2021 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c sysmon_envsys_events.c sysmonvar.h Log Message: sysmon(9): Fix callout/thread synchronization. Callout may ONLY take sme_work_mtx, at IPL_SOFTCLOCK; MUST NOT touch sme_mtx at IPL_NONE. All state the callout needs is serialized by sme_work_mtx now: - calls to sme_schedule_callout - calls to sme_schedule_halt - struct sysmon_envsys::sme_events_timeout - struct sysmon_envsys::sme_events_list - struct sysmon_envsys::sme_callout_state - struct envsys_data::flags => yes, this is a little silly -- used for ENVSYS_FNEED_REFRESH => should maybe separate the static driver-defined features from the state flags needed by sysmon_envsys but not important now Sleeping under sme_work_mtx (except on other adaptive locks at IPL_SOFTCLOCK) is forbidden. Calling out to the driver under sme_work_mtx is forbidden. This should properly fix: https://mail-index.netbsd.org/tech-kern/2015/10/14/msg019511.html PR kern/56592 To generate a diff of this commit: cvs rdiff -u -r1.149 -r1.150 src/sys/dev/sysmon/sysmon_envsys.c cvs rdiff -u -r1.122 -r1.123 src/sys/dev/sysmon/sysmon_envsys_events.c cvs rdiff -u -r1.51 -r1.52 src/sys/dev/sysmon/sysmonvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: riastradh Date: Fri Dec 31 14:30:04 UTC 2021 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c sysmon_envsys_events.c sysmonvar.h Log Message: sysmon(9): Fix callout/thread synchronization. Callout may ONLY take sme_work_mtx, at IPL_SOFTCLOCK; MUST NOT touch sme_mtx at IPL_NONE. All state the callout needs is serialized by sme_work_mtx now: - calls to sme_schedule_callout - calls to sme_schedule_halt - struct sysmon_envsys::sme_events_timeout - struct sysmon_envsys::sme_events_list - struct sysmon_envsys::sme_callout_state - struct envsys_data::flags => yes, this is a little silly -- used for ENVSYS_FNEED_REFRESH => should maybe separate the static driver-defined features from the state flags needed by sysmon_envsys but not important now Sleeping under sme_work_mtx (except on other adaptive locks at IPL_SOFTCLOCK) is forbidden. Calling out to the driver under sme_work_mtx is forbidden. This should properly fix: https://mail-index.netbsd.org/tech-kern/2015/10/14/msg019511.html PR kern/56592 To generate a diff of this commit: cvs rdiff -u -r1.149 -r1.150 src/sys/dev/sysmon/sysmon_envsys.c cvs rdiff -u -r1.122 -r1.123 src/sys/dev/sysmon/sysmon_envsys_events.c cvs rdiff -u -r1.51 -r1.52 src/sys/dev/sysmon/sysmonvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon_envsys.c diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.149 src/sys/dev/sysmon/sysmon_envsys.c:1.150 --- src/sys/dev/sysmon/sysmon_envsys.c:1.149 Fri Dec 31 11:05:41 2021 +++ src/sys/dev/sysmon/sysmon_envsys.c Fri Dec 31 14:30:04 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_envsys.c,v 1.149 2021/12/31 11:05:41 riastradh Exp $ */ +/* $NetBSD: sysmon_envsys.c,v 1.150 2021/12/31 14:30:04 riastradh Exp $ */ /*- * Copyright (c) 2007, 2008 Juan Romero Pardines. @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.149 2021/12/31 11:05:41 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.150 2021/12/31 14:30:04 riastradh Exp $"); #include #include @@ -531,7 +531,7 @@ sysmon_envsys_create(void) TAILQ_INIT(>sme_sensors_list); LIST_INIT(>sme_events_list); mutex_init(>sme_mtx, MUTEX_DEFAULT, IPL_NONE); - mutex_init(>sme_work_mtx, MUTEX_DEFAULT, IPL_NONE); + mutex_init(>sme_work_mtx, MUTEX_DEFAULT, IPL_SOFTCLOCK); cv_init(>sme_condvar, "sme_wait"); return sme; @@ -655,11 +655,13 @@ sysmon_envsys_sensor_detach(struct sysmo if (oedata->flags & ENVSYS_FHAS_ENTROPY) rnd_detach_source(>rnd_src); sme_event_unregister_sensor(sme, edata); + mutex_enter(>sme_work_mtx); if (LIST_EMPTY(>sme_events_list)) { if (sme->sme_callout_state == SME_CALLOUT_READY) sme_events_halt_callout(sme); destroy = true; } + mutex_exit(>sme_work_mtx); TAILQ_REMOVE(>sme_sensors_list, edata, sensors_head); sme->sme_nsensors--; sysmon_envsys_release(sme, true); @@ -1324,18 +1326,12 @@ sme_remove_userprops(void) /* * Restore default timeout value. */ + mutex_enter(>sme_work_mtx); sme->sme_events_timeout = SME_EVENTS_DEFTIMEOUT; - - /* - * Note that we need to hold the sme_mtx while calling - * sme_schedule_callout(). Thus to avoid dropping, - * reacquiring, and dropping it again, we just tell - * sme_envsys_release() that the mutex is already owned. - */ - mutex_enter(>sme_mtx); sme_schedule_callout(sme); - sysmon_envsys_release(sme, true); - mutex_exit(>sme_mtx); + mutex_exit(>sme_work_mtx); + + sysmon_envsys_release(sme, false); } mutex_exit(_global_mtx); } @@ -1350,6 +1346,7 @@ sme_add_property_dictionary(struct sysmo prop_dictionary_t dict) { prop_dictionary_t pdict; + uint64_t timo; const char *class; int error = 0; @@ -1374,15 +1371,15 @@ sme_add_property_dictionary(struct sysmo * ... * */ + mutex_enter(>sme_work_mtx); if (sme->sme_events_timeout == 0) { sme->sme_events_timeout = SME_EVENTS_DEFTIMEOUT; - mutex_enter(>sme_mtx); sme_schedule_callout(sme); - mutex_exit(>sme_mtx); } + timo = sme->sme_events_timeout; + mutex_exit(>sme_work_mtx); - if (!prop_dictionary_set_uint64(pdict, "refresh-timeout", - sme->sme_events_timeout)) { + if (!prop_dictionary_set_uint64(pdict, "refresh-timeout", timo)) { error = EINVAL; goto out; } @@ -1606,6 +1603,7 @@ sme_update_dictionary(struct sysmon_envs { envsys_data_t *edata; prop_object_t array, dict, obj, obj2; + uint64_t timo; int error = 0; /* @@ -1634,8 +1632,10 @@ sme_update_dictionary(struct sysmon_envs /* * Update the 'refresh-timeout' property. */ - if (!prop_dictionary_set_uint64(obj2, "refresh-timeout", - sme->sme_events_timeout)) + mutex_enter(>sme_work_mtx); + timo = sme->sme_events_timeout; + mutex_exit(>sme_work_mtx); + if (!prop_dictionary_set_uint64(obj2, "refresh-timeout", timo)) return EINVAL; /* @@ -1852,12 +1852,12 @@
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: riastradh Date: Fri Dec 31 14:29:14 UTC 2021 Modified Files: src/sys/dev/sysmon: sysmon_taskq.c Log Message: sysmon(9): Fix mistake in sysmon_task_queue_barrier. Need to allocate the task structure with malloc(9), not on the stack; the task thread will free it with free(9). Forgot to squash this into previous commit. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/dev/sysmon/sysmon_taskq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon_taskq.c diff -u src/sys/dev/sysmon/sysmon_taskq.c:1.22 src/sys/dev/sysmon/sysmon_taskq.c:1.23 --- src/sys/dev/sysmon/sysmon_taskq.c:1.22 Fri Dec 31 14:22:11 2021 +++ src/sys/dev/sysmon/sysmon_taskq.c Fri Dec 31 14:29:14 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_taskq.c,v 1.22 2021/12/31 14:22:11 riastradh Exp $ */ +/* $NetBSD: sysmon_taskq.c,v 1.23 2021/12/31 14:29:14 riastradh Exp $ */ /* * Copyright (c) 2001, 2003 Wasabi Systems, Inc. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sysmon_taskq.c,v 1.22 2021/12/31 14:22:11 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_taskq.c,v 1.23 2021/12/31 14:29:14 riastradh Exp $"); #include #include @@ -280,7 +280,7 @@ tqbarrier_task(void *cookie) void sysmon_task_queue_barrier(u_int pri) { - struct sysmon_task st; + struct sysmon_task *st; struct tqbarrier bar; (void)RUN_ONCE(_tq, tq_preinit); @@ -292,11 +292,12 @@ sysmon_task_queue_barrier(u_int pri) cv_init(, "sysmontq"); bar.done = false; - st.st_func = _task; - st.st_arg = - st.st_pri = pri; + st = malloc(sizeof(*st), M_TEMP, M_WAITOK); + st->st_func = _task; + st->st_arg = + st->st_pri = pri; - sysmon_task_queue_sched_task(); + sysmon_task_queue_sched_task(st); mutex_enter(); while (!bar.done)
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: riastradh Date: Fri Dec 31 14:29:14 UTC 2021 Modified Files: src/sys/dev/sysmon: sysmon_taskq.c Log Message: sysmon(9): Fix mistake in sysmon_task_queue_barrier. Need to allocate the task structure with malloc(9), not on the stack; the task thread will free it with free(9). Forgot to squash this into previous commit. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/dev/sysmon/sysmon_taskq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: riastradh Date: Fri Dec 31 11:05:41 UTC 2021 Modified Files: src/sys/dev/sysmon: swsensor.c swwdog.c sysmon.c sysmon_envsys.c sysmon_envsys_events.c sysmon_envsysvar.h sysmon_power.c sysmon_taskq.c sysmon_wdog.c sysmonvar.h Log Message: sysmon: Delete trailing whitespace. No functional change intended. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/dev/sysmon/swsensor.c cvs rdiff -u -r1.22 -r1.23 src/sys/dev/sysmon/swwdog.c cvs rdiff -u -r1.30 -r1.31 src/sys/dev/sysmon/sysmon.c cvs rdiff -u -r1.148 -r1.149 src/sys/dev/sysmon/sysmon_envsys.c cvs rdiff -u -r1.121 -r1.122 src/sys/dev/sysmon/sysmon_envsys_events.c cvs rdiff -u -r1.47 -r1.48 src/sys/dev/sysmon/sysmon_envsysvar.h cvs rdiff -u -r1.68 -r1.69 src/sys/dev/sysmon/sysmon_power.c cvs rdiff -u -r1.20 -r1.21 src/sys/dev/sysmon/sysmon_taskq.c cvs rdiff -u -r1.29 -r1.30 src/sys/dev/sysmon/sysmon_wdog.c cvs rdiff -u -r1.50 -r1.51 src/sys/dev/sysmon/sysmonvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/swsensor.c diff -u src/sys/dev/sysmon/swsensor.c:1.18 src/sys/dev/sysmon/swsensor.c:1.19 --- src/sys/dev/sysmon/swsensor.c:1.18 Thu Jun 11 02:39:31 2020 +++ src/sys/dev/sysmon/swsensor.c Fri Dec 31 11:05:41 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: swsensor.c,v 1.18 2020/06/11 02:39:31 thorpej Exp $ */ +/* $NetBSD: swsensor.c,v 1.19 2021/12/31 11:05:41 riastradh Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: swsensor.c,v 1.18 2020/06/11 02:39:31 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: swsensor.c,v 1.19 2021/12/31 11:05:41 riastradh Exp $"); #include #include @@ -139,18 +139,18 @@ swsensor_refresh(struct sysmon_envsys *s * Sensor get/set limit routines */ -static void +static void swsensor_get_limits(struct sysmon_envsys *sme, envsys_data_t *edata, - sysmon_envsys_lim_t *limits, uint32_t *props) + sysmon_envsys_lim_t *limits, uint32_t *props) { *props = PROP_CRITMIN | PROP_DRIVER_LIMITS; limits->sel_critmin = sw_sensor_limit; } -static void +static void swsensor_set_limits(struct sysmon_envsys *sme, envsys_data_t *edata, - sysmon_envsys_lim_t *limits, uint32_t *props) + sysmon_envsys_lim_t *limits, uint32_t *props) { if (limits == NULL) { @@ -250,7 +250,7 @@ swsensor_init(void *arg) /* Sensor limit behavior * 0 - simple sensor, no hw limits * 1 - simple sensor, hw provides initial limit - * 2 - complex sensor, hw provides settable + * 2 - complex sensor, hw provides settable * limits and does its own limit checking */ if (strcmp(key, "mode") == 0) { Index: src/sys/dev/sysmon/swwdog.c diff -u src/sys/dev/sysmon/swwdog.c:1.22 src/sys/dev/sysmon/swwdog.c:1.23 --- src/sys/dev/sysmon/swwdog.c:1.22 Mon Mar 16 21:20:09 2020 +++ src/sys/dev/sysmon/swwdog.c Fri Dec 31 11:05:41 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: swwdog.c,v 1.22 2020/03/16 21:20:09 pgoyette Exp $ */ +/* $NetBSD: swwdog.c,v 1.23 2021/12/31 11:05:41 riastradh Exp $ */ /* * Copyright (c) 2004, 2005 Steven M. Bellovin @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: swwdog.c,v 1.22 2020/03/16 21:20:09 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: swwdog.c,v 1.23 2021/12/31 11:05:41 riastradh Exp $"); /* * @@ -286,8 +286,7 @@ SYSCTL_SETUP(swwdog_sysctl_setup, "swwdo * Module management */ -static -int +static int swwdog_init(void *arg) { /* @@ -314,8 +313,7 @@ swwdog_init(void *arg) return error; } -static -int +static int swwdog_fini(void *arg) { int error; @@ -337,26 +335,22 @@ swwdog_fini(void *arg) return error; } -static -int +static int swwdog_modcmd(modcmd_t cmd, void *arg) { int ret; - + switch (cmd) { case MODULE_CMD_INIT: ret = swwdog_init(arg); break; - case MODULE_CMD_FINI: ret = swwdog_fini(arg); break; - case MODULE_CMD_STAT: default: ret = ENOTTY; } - + return ret; } - Index: src/sys/dev/sysmon/sysmon.c diff -u src/sys/dev/sysmon/sysmon.c:1.30 src/sys/dev/sysmon/sysmon.c:1.31 --- src/sys/dev/sysmon/sysmon.c:1.30 Mon Aug 26 10:05:34 2019 +++ src/sys/dev/sysmon/sysmon.c Fri Dec 31 11:05:41 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon.c,v 1.30 2019/08/26 10:05:34 nakayama Exp $ */ +/* $NetBSD: sysmon.c,v 1.31 2021/12/31 11:05:41 riastradh Exp $ */ /*- * Copyright (c) 2000 Zembu Labs, Inc. @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sysmon.c,v 1.30 2019/08/26 10:05:34 nakayama Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon.c,v 1.31 2021/12/31 11:05:41 riastradh Exp $"); #include #include @@ -78,7 +78,7 @@ const struct cdevsw sysmon_cdevsw = { .d_flag = D_OTHER | D_MPSAFE }; -static int
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: riastradh Date: Fri Dec 31 11:05:41 UTC 2021 Modified Files: src/sys/dev/sysmon: swsensor.c swwdog.c sysmon.c sysmon_envsys.c sysmon_envsys_events.c sysmon_envsysvar.h sysmon_power.c sysmon_taskq.c sysmon_wdog.c sysmonvar.h Log Message: sysmon: Delete trailing whitespace. No functional change intended. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/dev/sysmon/swsensor.c cvs rdiff -u -r1.22 -r1.23 src/sys/dev/sysmon/swwdog.c cvs rdiff -u -r1.30 -r1.31 src/sys/dev/sysmon/sysmon.c cvs rdiff -u -r1.148 -r1.149 src/sys/dev/sysmon/sysmon_envsys.c cvs rdiff -u -r1.121 -r1.122 src/sys/dev/sysmon/sysmon_envsys_events.c cvs rdiff -u -r1.47 -r1.48 src/sys/dev/sysmon/sysmon_envsysvar.h cvs rdiff -u -r1.68 -r1.69 src/sys/dev/sysmon/sysmon_power.c cvs rdiff -u -r1.20 -r1.21 src/sys/dev/sysmon/sysmon_taskq.c cvs rdiff -u -r1.29 -r1.30 src/sys/dev/sysmon/sysmon_wdog.c cvs rdiff -u -r1.50 -r1.51 src/sys/dev/sysmon/sysmonvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: thorpej Date: Sun Sep 26 16:24:21 UTC 2021 Modified Files: src/sys/dev/sysmon: sysmon_power.c Log Message: - Call selnotify() with sysmon_power_event_queue_mtx held, passing the correct hints. Adjust filt_sysmon_power_read() accordingly (assert that the mutex is held iff NOTE_SUBMIT). - Mark sysmon_power_read_filtops as MPSAFE. - Use seltrue_filtops rather than rolling our own with filt_seltrue. To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/sys/dev/sysmon/sysmon_power.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon_power.c diff -u src/sys/dev/sysmon/sysmon_power.c:1.67 src/sys/dev/sysmon/sysmon_power.c:1.68 --- src/sys/dev/sysmon/sysmon_power.c:1.67 Sun Sep 26 01:16:09 2021 +++ src/sys/dev/sysmon/sysmon_power.c Sun Sep 26 16:24:21 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_power.c,v 1.67 2021/09/26 01:16:09 thorpej Exp $ */ +/* $NetBSD: sysmon_power.c,v 1.68 2021/09/26 16:24:21 thorpej Exp $ */ /*- * Copyright (c) 2007 Juan Romero Pardines. @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.67 2021/09/26 01:16:09 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.68 2021/09/26 16:24:21 thorpej Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -419,8 +419,9 @@ sysmon_power_daemon_task(struct power_ev ped->flags |= SYSMON_POWER_DICTIONARY_READY; SIMPLEQ_INSERT_TAIL(_dict_list, ped, pev_dict_head); cv_broadcast(_power_event_queue_cv); + selnotify(_power_event_queue_selinfo, + POLLIN | POLLRDNORM, NOTE_SUBMIT); mutex_exit(_power_event_queue_mtx); - selnotify(_power_event_queue_selinfo, 0, 0); } out: @@ -546,27 +547,28 @@ static int filt_sysmon_power_read(struct knote *kn, long hint) { - mutex_enter(_power_event_queue_mtx); + if (hint & NOTE_SUBMIT) { + KASSERT(mutex_owned(_power_event_queue_mtx)); + } else { + mutex_enter(_power_event_queue_mtx); + } + kn->kn_data = sysmon_power_event_queue_count; - mutex_exit(_power_event_queue_mtx); + + if ((hint & NOTE_SUBMIT) == 0) { + mutex_exit(_power_event_queue_mtx); + } return kn->kn_data > 0; } static const struct filterops sysmon_power_read_filtops = { - .f_flags = FILTEROP_ISFD, + .f_flags = FILTEROP_ISFD | FILTEROP_MPSAFE, .f_attach = NULL, .f_detach = filt_sysmon_power_rdetach, .f_event = filt_sysmon_power_read, }; -static const struct filterops sysmon_power_write_filtops = { - .f_flags = FILTEROP_ISFD, - .f_attach = NULL, - .f_detach = filt_sysmon_power_rdetach, - .f_event = filt_seltrue, -}; - /* * sysmonkqfilter_power: * @@ -579,20 +581,19 @@ sysmonkqfilter_power(dev_t dev, struct k switch (kn->kn_filter) { case EVFILT_READ: kn->kn_fop = _power_read_filtops; + mutex_enter(_power_event_queue_mtx); + selrecord_knote(_power_event_queue_selinfo, kn); + mutex_exit(_power_event_queue_mtx); break; case EVFILT_WRITE: - kn->kn_fop = _power_write_filtops; + kn->kn_fop = _filtops; break; default: return EINVAL; } - mutex_enter(_power_event_queue_mtx); - selrecord_knote(_power_event_queue_selinfo, kn); - mutex_exit(_power_event_queue_mtx); - return 0; }
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: thorpej Date: Sun Sep 26 16:24:21 UTC 2021 Modified Files: src/sys/dev/sysmon: sysmon_power.c Log Message: - Call selnotify() with sysmon_power_event_queue_mtx held, passing the correct hints. Adjust filt_sysmon_power_read() accordingly (assert that the mutex is held iff NOTE_SUBMIT). - Mark sysmon_power_read_filtops as MPSAFE. - Use seltrue_filtops rather than rolling our own with filt_seltrue. To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/sys/dev/sysmon/sysmon_power.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: thorpej Date: Fri Dec 18 01:46:40 UTC 2020 Modified Files: src/sys/dev/sysmon: sysmon_power.c Log Message: Use sel{remove,record}_knote(). To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/sys/dev/sysmon/sysmon_power.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon_power.c diff -u src/sys/dev/sysmon/sysmon_power.c:1.65 src/sys/dev/sysmon/sysmon_power.c:1.66 --- src/sys/dev/sysmon/sysmon_power.c:1.65 Fri Oct 30 22:19:18 2020 +++ src/sys/dev/sysmon/sysmon_power.c Fri Dec 18 01:46:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_power.c,v 1.65 2020/10/30 22:19:18 christos Exp $ */ +/* $NetBSD: sysmon_power.c,v 1.66 2020/12/18 01:46:39 thorpej Exp $ */ /*- * Copyright (c) 2007 Juan Romero Pardines. @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.65 2020/10/30 22:19:18 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.66 2020/12/18 01:46:39 thorpej Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -538,8 +538,7 @@ filt_sysmon_power_rdetach(struct knote * { mutex_enter(_power_event_queue_mtx); - SLIST_REMOVE(_power_event_queue_selinfo.sel_klist, - kn, knote, kn_selnext); + selremove_knote(_power_event_queue_selinfo, kn); mutex_exit(_power_event_queue_mtx); } @@ -576,16 +575,13 @@ static const struct filterops sysmon_pow int sysmonkqfilter_power(dev_t dev, struct knote *kn) { - struct klist *klist; switch (kn->kn_filter) { case EVFILT_READ: - klist = _power_event_queue_selinfo.sel_klist; kn->kn_fop = _power_read_filtops; break; case EVFILT_WRITE: - klist = _power_event_queue_selinfo.sel_klist; kn->kn_fop = _power_write_filtops; break; @@ -594,7 +590,7 @@ sysmonkqfilter_power(dev_t dev, struct k } mutex_enter(_power_event_queue_mtx); - SLIST_INSERT_HEAD(klist, kn, kn_selnext); + selrecord_knote(_power_event_queue_selinfo, kn); mutex_exit(_power_event_queue_mtx); return 0;
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: thorpej Date: Fri Dec 18 01:46:40 UTC 2020 Modified Files: src/sys/dev/sysmon: sysmon_power.c Log Message: Use sel{remove,record}_knote(). To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/sys/dev/sysmon/sysmon_power.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: christos Date: Fri Oct 30 22:19:19 UTC 2020 Modified Files: src/sys/dev/sysmon: sysmon_power.c Log Message: fix indentation To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/sys/dev/sysmon/sysmon_power.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: christos Date: Fri Oct 30 22:19:19 UTC 2020 Modified Files: src/sys/dev/sysmon: sysmon_power.c Log Message: fix indentation To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/sys/dev/sysmon/sysmon_power.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon_power.c diff -u src/sys/dev/sysmon/sysmon_power.c:1.64 src/sys/dev/sysmon/sysmon_power.c:1.65 --- src/sys/dev/sysmon/sysmon_power.c:1.64 Wed Jun 10 22:39:31 2020 +++ src/sys/dev/sysmon/sysmon_power.c Fri Oct 30 18:19:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_power.c,v 1.64 2020/06/11 02:39:31 thorpej Exp $ */ +/* $NetBSD: sysmon_power.c,v 1.65 2020/10/30 22:19:18 christos Exp $ */ /*- * Copyright (c) 2007 Juan Romero Pardines. @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.64 2020/06/11 02:39:31 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.65 2020/10/30 22:19:18 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -555,17 +555,17 @@ filt_sysmon_power_read(struct knote *kn, } static const struct filterops sysmon_power_read_filtops = { -.f_isfd = 1, -.f_attach = NULL, -.f_detach = filt_sysmon_power_rdetach, -.f_event = filt_sysmon_power_read, + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_sysmon_power_rdetach, + .f_event = filt_sysmon_power_read, }; static const struct filterops sysmon_power_write_filtops = { -.f_isfd = 1, -.f_attach = NULL, -.f_detach = filt_sysmon_power_rdetach, -.f_event = filt_seltrue, + .f_isfd = 1, + .f_attach = NULL, + .f_detach = filt_sysmon_power_rdetach, + .f_event = filt_seltrue, }; /*
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: thorpej Date: Mon Jun 8 20:18:13 UTC 2020 Modified Files: src/sys/dev/sysmon: swsensor.c sysmon_envsys.c sysmon_envsys_util.c sysmon_power.c Log Message: Update for proplib(3) API changes. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/dev/sysmon/swsensor.c cvs rdiff -u -r1.145 -r1.146 src/sys/dev/sysmon/sysmon_envsys.c cvs rdiff -u -r1.5 -r1.6 src/sys/dev/sysmon/sysmon_envsys_util.c cvs rdiff -u -r1.62 -r1.63 src/sys/dev/sysmon/sysmon_power.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/swsensor.c diff -u src/sys/dev/sysmon/swsensor.c:1.16 src/sys/dev/sysmon/swsensor.c:1.17 --- src/sys/dev/sysmon/swsensor.c:1.16 Mon Mar 16 21:20:09 2020 +++ src/sys/dev/sysmon/swsensor.c Mon Jun 8 20:18:13 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: swsensor.c,v 1.16 2020/03/16 21:20:09 pgoyette Exp $ */ +/* $NetBSD: swsensor.c,v 1.17 2020/06/08 20:18:13 thorpej Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: swsensor.c,v 1.16 2020/03/16 21:20:09 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: swsensor.c,v 1.17 2020/06/08 20:18:13 thorpej Exp $"); #include #include @@ -212,7 +212,7 @@ swsensor_init(void *arg) return ENOMEM; while ((obj = prop_object_iterator_next(iter)) != NULL) { - key = prop_dictionary_keysym_cstring_nocopy(obj); + key = prop_dictionary_keysym_value(obj); po = prop_dictionary_get_keysym(pd, obj); type = prop_object_type(po); if (type == PROP_TYPE_NUMBER) Index: src/sys/dev/sysmon/sysmon_envsys.c diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.145 src/sys/dev/sysmon/sysmon_envsys.c:1.146 --- src/sys/dev/sysmon/sysmon_envsys.c:1.145 Mon Jun 1 21:54:47 2020 +++ src/sys/dev/sysmon/sysmon_envsys.c Mon Jun 8 20:18:13 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_envsys.c,v 1.145 2020/06/01 21:54:47 riastradh Exp $ */ +/* $NetBSD: sysmon_envsys.c,v 1.146 2020/06/08 20:18:13 thorpej Exp $ */ /*- * Copyright (c) 2007, 2008 Juan Romero Pardines. @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.145 2020/06/01 21:54:47 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.146 2020/06/08 20:18:13 thorpej Exp $"); #include #include @@ -267,7 +267,7 @@ sysmonioctl_envsys(dev_t dev, u_long cmd return EINVAL; } - devname = prop_dictionary_keysym_cstring_nocopy(obj); + devname = prop_dictionary_keysym_value(obj); DPRINTF(("%s: processing the '%s' array requests\n", __func__, devname)); @@ -950,9 +950,9 @@ sysmon_envsys_destroy_plist(prop_array_t DPRINTFOBJ(("%s: iterating over dictionary\n", __func__)); while ((obj = prop_object_iterator_next(iter2)) != NULL) { DPRINTFOBJ(("%s: obj=%s\n", __func__, - prop_dictionary_keysym_cstring_nocopy(obj))); + prop_dictionary_keysym_value(obj))); prop_dictionary_remove(dict, - prop_dictionary_keysym_cstring_nocopy(obj)); + prop_dictionary_keysym_value(obj)); prop_object_iterator_reset(iter2); } prop_object_iterator_release(iter2); @@ -1848,7 +1848,7 @@ sme_userset_dictionary(struct sysmon_env if (obj1 && prop_object_type(obj1) == PROP_TYPE_NUMBER) { targetfound = true; refresh_timo = - prop_number_unsigned_integer_value(obj1); + prop_number_unsigned_value(obj1); if (refresh_timo < 1) error = EINVAL; else { Index: src/sys/dev/sysmon/sysmon_envsys_util.c diff -u src/sys/dev/sysmon/sysmon_envsys_util.c:1.5 src/sys/dev/sysmon/sysmon_envsys_util.c:1.6 --- src/sys/dev/sysmon/sysmon_envsys_util.c:1.5 Fri Nov 16 08:00:16 2007 +++ src/sys/dev/sysmon/sysmon_envsys_util.c Mon Jun 8 20:18:13 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_envsys_util.c,v 1.5 2007/11/16 08:00:16 xtraeme Exp $ */ +/* $NetBSD: sysmon_envsys_util.c,v 1.6 2020/06/08 20:18:13 thorpej Exp $ */ /*- * Copyright (c) 2007 Juan Romero Pardines. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_util.c,v 1.5 2007/11/16 08:00:16 xtraeme Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_util.c,v 1.6 2020/06/08 20:18:13 thorpej Exp $"); #include #include @@ -78,7 +78,7 @@ sme_sensor_upint32(prop_dictionary_t dic obj = prop_dictionary_get(dict, key); if (obj) { - if (!prop_number_equals_integer(obj, val)) { + if (!prop_number_equals_signed(obj, val)) { if (!prop_dictionary_set_int32(dict, key, val)) { DPRINTF(("%s: (up) set_int32 %s:%d\n", __func__, key, val)); @@ -105,7 +105,7 @@ sme_sensor_upuint32(prop_dictionary_t di obj = prop_dictionary_get(dict, key); if (obj) { - if (!prop_number_equals_unsigned_integer(obj, val)) { + if (!prop_number_equals_unsigned(obj, val)) { if (!prop_dictionary_set_uint32(dict, key, val)) { DPRINTF(("%s: (up) set_uint32
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: thorpej Date: Mon Jun 8 20:18:13 UTC 2020 Modified Files: src/sys/dev/sysmon: swsensor.c sysmon_envsys.c sysmon_envsys_util.c sysmon_power.c Log Message: Update for proplib(3) API changes. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/dev/sysmon/swsensor.c cvs rdiff -u -r1.145 -r1.146 src/sys/dev/sysmon/sysmon_envsys.c cvs rdiff -u -r1.5 -r1.6 src/sys/dev/sysmon/sysmon_envsys_util.c cvs rdiff -u -r1.62 -r1.63 src/sys/dev/sysmon/sysmon_power.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: riastradh Date: Mon Jun 1 21:54:47 UTC 2020 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c Log Message: Don't queue sysmon refresh until the rndsource is attached. Using the rndsource, as refreshing the sensors will do, is not allowed until _after_ rnd_source_attach. XXX pullup-7 XXX pullup-8 XXX pullup-9 To generate a diff of this commit: cvs rdiff -u -r1.144 -r1.145 src/sys/dev/sysmon/sysmon_envsys.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: riastradh Date: Mon Jun 1 21:54:47 UTC 2020 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c Log Message: Don't queue sysmon refresh until the rndsource is attached. Using the rndsource, as refreshing the sensors will do, is not allowed until _after_ rnd_source_attach. XXX pullup-7 XXX pullup-8 XXX pullup-9 To generate a diff of this commit: cvs rdiff -u -r1.144 -r1.145 src/sys/dev/sysmon/sysmon_envsys.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon_envsys.c diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.144 src/sys/dev/sysmon/sysmon_envsys.c:1.145 --- src/sys/dev/sysmon/sysmon_envsys.c:1.144 Tue Mar 26 15:50:23 2019 +++ src/sys/dev/sysmon/sysmon_envsys.c Mon Jun 1 21:54:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_envsys.c,v 1.144 2019/03/26 15:50:23 bad Exp $ */ +/* $NetBSD: sysmon_envsys.c,v 1.145 2020/06/01 21:54:47 riastradh Exp $ */ /*- * Copyright (c) 2007, 2008 Juan Romero Pardines. @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.144 2019/03/26 15:50:23 bad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.145 2020/06/01 21:54:47 riastradh Exp $"); #include #include @@ -824,16 +824,6 @@ out: if (error == 0) { nevent = 0; - if (sme->sme_flags & SME_INIT_REFRESH) { - sysmon_task_queue_sched(0, sme_initial_refresh, sme); - DPRINTF(("%s: scheduled initial refresh for '%s'\n", -__func__, sme->sme_name)); - } - SLIST_FOREACH(evdv, _evdrv_list, evdrv_head) { - sysmon_task_queue_sched(0, - sme_event_drvadd, evdv->evdrv); - nevent++; - } /* * Hook the sensor into rnd(4) entropy pool if requested */ @@ -889,6 +879,17 @@ out: rnd_type, rnd_flag); } } + + if (sme->sme_flags & SME_INIT_REFRESH) { + sysmon_task_queue_sched(0, sme_initial_refresh, sme); + DPRINTF(("%s: scheduled initial refresh for '%s'\n", +__func__, sme->sme_name)); + } + SLIST_FOREACH(evdv, _evdrv_list, evdrv_head) { + sysmon_task_queue_sched(0, + sme_event_drvadd, evdv->evdrv); + nevent++; + } DPRINTF(("%s: driver '%s' registered (nsens=%d nevent=%d)\n", __func__, sme->sme_name, sme->sme_nsensors, nevent)); }
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: nakayama Date: Mon Aug 26 10:05:35 UTC 2019 Modified Files: src/sys/dev/sysmon: sysmon.c Log Message: Module class of sysmon_envsys, sysmon_wdog and sysmon_power is MODULE_CLASS_DRIVER, not MODULE_CLASS_MISC. Fix that invoking envsys without sysmon_envsys kernel module failes with: WARNING: module error: incompatible module class for `sysmon_envsys' (1 != 3) To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/dev/sysmon/sysmon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: nakayama Date: Mon Aug 26 10:05:35 UTC 2019 Modified Files: src/sys/dev/sysmon: sysmon.c Log Message: Module class of sysmon_envsys, sysmon_wdog and sysmon_power is MODULE_CLASS_DRIVER, not MODULE_CLASS_MISC. Fix that invoking envsys without sysmon_envsys kernel module failes with: WARNING: module error: incompatible module class for `sysmon_envsys' (1 != 3) To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/dev/sysmon/sysmon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon.c diff -u src/sys/dev/sysmon/sysmon.c:1.29 src/sys/dev/sysmon/sysmon.c:1.30 --- src/sys/dev/sysmon/sysmon.c:1.29 Fri Apr 26 08:38:25 2019 +++ src/sys/dev/sysmon/sysmon.c Mon Aug 26 10:05:34 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon.c,v 1.29 2019/04/26 08:38:25 pgoyette Exp $ */ +/* $NetBSD: sysmon.c,v 1.30 2019/08/26 10:05:34 nakayama Exp $ */ /*- * Copyright (c) 2000 Zembu Labs, Inc. @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sysmon.c,v 1.29 2019/04/26 08:38:25 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon.c,v 1.30 2019/08/26 10:05:34 nakayama Exp $"); #include #include @@ -151,7 +151,7 @@ sysmonopen(dev_t dev, int flag, int mode if (sysmon_opvec_table[minor(dev)] == NULL) { mutex_exit(_minor_mtx); error = module_autoload(sysmon_mod[minor(dev)], - MODULE_CLASS_MISC); + MODULE_CLASS_DRIVER); if (error) return error; mutex_enter(_minor_mtx);
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: maxv Date: Tue Aug 20 18:43:57 UTC 2019 Modified Files: src/sys/dev/sysmon: sysmon_power.c Log Message: Fix info leak, not all of 'pev' is initialized. To generate a diff of this commit: cvs rdiff -u -r1.60 -r1.61 src/sys/dev/sysmon/sysmon_power.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon_power.c diff -u src/sys/dev/sysmon/sysmon_power.c:1.60 src/sys/dev/sysmon/sysmon_power.c:1.61 --- src/sys/dev/sysmon/sysmon_power.c:1.60 Fri Mar 1 11:06:56 2019 +++ src/sys/dev/sysmon/sysmon_power.c Tue Aug 20 18:43:57 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_power.c,v 1.60 2019/03/01 11:06:56 pgoyette Exp $ */ +/* $NetBSD: sysmon_power.c,v 1.61 2019/08/20 18:43:57 maxv Exp $ */ /*- * Copyright (c) 2007 Juan Romero Pardines. @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.60 2019/03/01 11:06:56 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.61 2019/08/20 18:43:57 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -331,6 +331,8 @@ sysmon_power_daemon_task(struct power_ev if (!ped || !ped->dict || !pev_data) return EINVAL; + memset(, 0, sizeof(pev)); + mutex_enter(_power_event_queue_mtx); switch (event) {
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: maxv Date: Tue Aug 20 18:43:57 UTC 2019 Modified Files: src/sys/dev/sysmon: sysmon_power.c Log Message: Fix info leak, not all of 'pev' is initialized. To generate a diff of this commit: cvs rdiff -u -r1.60 -r1.61 src/sys/dev/sysmon/sysmon_power.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Wed Mar 27 09:52:16 UTC 2019 Modified Files: src/sys/dev/sysmon: swwdog.c Log Message: Don't create the driver's workqueue twice! The driver is modular, so its modcmd(MOULE_CMD_INIT) always gets called whether or not the driver is built-in to the kernel. The modcmd init code always calls swwdogattach() which creates the workqueue. Therefore there's no need to also create it in swwdog_attach() (used to attach a device instance). To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/dev/sysmon/swwdog.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/swwdog.c diff -u src/sys/dev/sysmon/swwdog.c:1.19 src/sys/dev/sysmon/swwdog.c:1.20 --- src/sys/dev/sysmon/swwdog.c:1.19 Tue May 12 10:20:14 2015 +++ src/sys/dev/sysmon/swwdog.c Wed Mar 27 09:52:16 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: swwdog.c,v 1.19 2015/05/12 10:20:14 pgoyette Exp $ */ +/* $NetBSD: swwdog.c,v 1.20 2019/03/27 09:52:16 pgoyette Exp $ */ /* * Copyright (c) 2004, 2005 Steven M. Bellovin @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: swwdog.c,v 1.19 2015/05/12 10:20:14 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: swwdog.c,v 1.20 2019/03/27 09:52:16 pgoyette Exp $"); /* * @@ -160,11 +160,6 @@ swwdog_attach(device_t parent, device_t { struct swwdog_softc *sc = device_private(self); - if (workqueue_create(, "swwreboot", doreboot, NULL, - PRI_NONE, IPL_NONE, 0) != 0) { - aprint_error_dev(self, "failed to create reboot workqueue"); - } - sc->sc_dev = self; sc->sc_smw.smw_name = device_xname(self); sc->sc_smw.smw_cookie = sc; @@ -181,7 +176,6 @@ swwdog_attach(device_t parent, device_t aprint_error_dev(self, "unable to register software " "watchdog with sysmon\n"); callout_destroy(>sc_c); - workqueue_destroy(wq); return; }
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Wed Mar 27 09:52:16 UTC 2019 Modified Files: src/sys/dev/sysmon: swwdog.c Log Message: Don't create the driver's workqueue twice! The driver is modular, so its modcmd(MOULE_CMD_INIT) always gets called whether or not the driver is built-in to the kernel. The modcmd init code always calls swwdogattach() which creates the workqueue. Therefore there's no need to also create it in swwdog_attach() (used to attach a device instance). To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/dev/sysmon/swwdog.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: bad Date: Tue Mar 26 15:50:23 UTC 2019 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c Log Message: in sysmon_envsys_unregister(): loop over sme_sensors_list with TAILQ_FIRST instead of TAILQ_FOREACH. sysmon_envsys_sensor_detach() removes the sensor from sme_sensors_list. Hence using TAILQ_FOREACH is not safe. Suggested by thorpej and jmcneill. Thanks! To generate a diff of this commit: cvs rdiff -u -r1.143 -r1.144 src/sys/dev/sysmon/sysmon_envsys.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: bad Date: Tue Mar 26 15:50:23 UTC 2019 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c Log Message: in sysmon_envsys_unregister(): loop over sme_sensors_list with TAILQ_FIRST instead of TAILQ_FOREACH. sysmon_envsys_sensor_detach() removes the sensor from sme_sensors_list. Hence using TAILQ_FOREACH is not safe. Suggested by thorpej and jmcneill. Thanks! To generate a diff of this commit: cvs rdiff -u -r1.143 -r1.144 src/sys/dev/sysmon/sysmon_envsys.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon_envsys.c diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.143 src/sys/dev/sysmon/sysmon_envsys.c:1.144 --- src/sys/dev/sysmon/sysmon_envsys.c:1.143 Sat May 26 21:15:46 2018 +++ src/sys/dev/sysmon/sysmon_envsys.c Tue Mar 26 15:50:23 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_envsys.c,v 1.143 2018/05/26 21:15:46 thorpej Exp $ */ +/* $NetBSD: sysmon_envsys.c,v 1.144 2019/03/26 15:50:23 bad Exp $ */ /*- * Copyright (c) 2007, 2008 Juan Romero Pardines. @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.143 2018/05/26 21:15:46 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.144 2019/03/26 15:50:23 bad Exp $"); #include #include @@ -993,7 +993,7 @@ sysmon_envsys_unregister(struct sysmon_e LIST_REMOVE(sme, sme_list); mutex_exit(_global_mtx); - TAILQ_FOREACH(edata, >sme_sensors_list, sensors_head) { + while ((edata = TAILQ_FIRST(>sme_sensors_list)) != NULL) { sysmon_envsys_sensor_detach(sme, edata); }
Re: CVS commit: src/sys/dev/sysmon
Unknown of course -- thorpej Sent from my iPhone. > On May 26, 2018, at 2:15 PM, Jason R Thorpewrote: > > Module Name:src > Committed By:thorpej > Date:Sat May 26 21:15:46 UTC 2018 > > Modified Files: >src/sys/dev/sysmon: sysmon_envsys.c > > Log Message: > Avoid dereferencing NULL if we attempt to look up an known unit type. > > > To generate a diff of this commit: > cvs rdiff -u -r1.142 -r1.143 src/sys/dev/sysmon/sysmon_envsys.c > > Please note that diffs are not public domain; they are subject to the > copyright notices on the relevant files. >
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: thorpej Date: Sat May 26 21:15:46 UTC 2018 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c Log Message: Avoid dereferencing NULL if we attempt to look up an known unit type. To generate a diff of this commit: cvs rdiff -u -r1.142 -r1.143 src/sys/dev/sysmon/sysmon_envsys.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon_envsys.c diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.142 src/sys/dev/sysmon/sysmon_envsys.c:1.143 --- src/sys/dev/sysmon/sysmon_envsys.c:1.142 Sat May 5 00:14:28 2018 +++ src/sys/dev/sysmon/sysmon_envsys.c Sat May 26 21:15:46 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_envsys.c,v 1.142 2018/05/05 00:14:28 pgoyette Exp $ */ +/* $NetBSD: sysmon_envsys.c,v 1.143 2018/05/26 21:15:46 thorpej Exp $ */ /*- * Copyright (c) 2007, 2008 Juan Romero Pardines. @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.142 2018/05/05 00:14:28 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.143 2018/05/26 21:15:46 thorpej Exp $"); #include #include @@ -578,7 +578,7 @@ sysmon_envsys_sensor_attach(struct sysmo * Find the correct units for this sensor. */ sdt_units = sme_find_table_entry(SME_DESC_UNITS, edata->units); - if (sdt_units->type == -1) + if (sdt_units == NULL || sdt_units->type == -1) return EINVAL; /*
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: thorpej Date: Sat May 26 21:15:46 UTC 2018 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c Log Message: Avoid dereferencing NULL if we attempt to look up an known unit type. To generate a diff of this commit: cvs rdiff -u -r1.142 -r1.143 src/sys/dev/sysmon/sysmon_envsys.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Sat May 5 00:14:28 UTC 2018 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c Log Message: Defend against some table-lookup-not-found errors. To generate a diff of this commit: cvs rdiff -u -r1.141 -r1.142 src/sys/dev/sysmon/sysmon_envsys.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon_envsys.c diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.141 src/sys/dev/sysmon/sysmon_envsys.c:1.142 --- src/sys/dev/sysmon/sysmon_envsys.c:1.141 Mon Sep 11 06:02:09 2017 +++ src/sys/dev/sysmon/sysmon_envsys.c Sat May 5 00:14:28 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_envsys.c,v 1.141 2017/09/11 06:02:09 pgoyette Exp $ */ +/* $NetBSD: sysmon_envsys.c,v 1.142 2018/05/05 00:14:28 pgoyette Exp $ */ /*- * Copyright (c) 2007, 2008 Juan Romero Pardines. @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.141 2017/09/11 06:02:09 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.142 2018/05/05 00:14:28 pgoyette Exp $"); #include #include @@ -1706,6 +1706,8 @@ sme_update_sensor_dictionary(prop_object * update sensor's type. */ sdt = sme_find_table_entry(SME_DESC_UNITS, edata->units); + if (sdt == NULL) + return EINVAL; DPRINTFOBJ(("%s: sensor #%d units=%d (%s)\n", __func__, edata->sensor, sdt->type, sdt->desc)); @@ -1784,6 +1786,8 @@ sme_update_sensor_dictionary(prop_object if (edata->units == ENVSYS_DRIVE) { sdt = sme_find_table_entry(SME_DESC_DRIVE_STATES, edata->value_cur); + if (sdt == NULL) + return EINVAL; error = sme_sensor_upstring(dict, "drive-state", sdt->desc); if (error) return error; @@ -1796,6 +1800,8 @@ sme_update_sensor_dictionary(prop_object if (edata->units == ENVSYS_BATTERY_CAPACITY) { sdt = sme_find_table_entry(SME_DESC_BATTERY_CAPACITY, edata->value_cur); + if (sdt == NULL) + return EINVAL; error = sme_sensor_upstring(dict, "battery-capacity", sdt->desc); if (error)
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Sat May 5 00:14:28 UTC 2018 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c Log Message: Defend against some table-lookup-not-found errors. To generate a diff of this commit: cvs rdiff -u -r1.141 -r1.142 src/sys/dev/sysmon/sysmon_envsys.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Mon Sep 11 06:02:09 UTC 2017 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c sysmon_envsys_events.c sysmonvar.h Log Message: Improve tracking of the state of an event's callout, and protect all queries or modifications of the state with the sme_mtx mutex. Detach the rndsrc before re-attaching it (with potentially new values). Clean up some lock-ordering issues. And a couple of KNF issues for good measure! Should address PR kern/52533 XXX Pullup-8 along with the previous fixes from msaitoh@ XXX http://mail-index.netbsd.org/source-changes/2017/09/06/msg088028.html ~ ~ To generate a diff of this commit: cvs rdiff -u -r1.140 -r1.141 src/sys/dev/sysmon/sysmon_envsys.c cvs rdiff -u -r1.120 -r1.121 src/sys/dev/sysmon/sysmon_envsys_events.c cvs rdiff -u -r1.49 -r1.50 src/sys/dev/sysmon/sysmonvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon_envsys.c diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.140 src/sys/dev/sysmon/sysmon_envsys.c:1.141 --- src/sys/dev/sysmon/sysmon_envsys.c:1.140 Wed Sep 6 11:08:53 2017 +++ src/sys/dev/sysmon/sysmon_envsys.c Mon Sep 11 06:02:09 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_envsys.c,v 1.140 2017/09/06 11:08:53 msaitoh Exp $ */ +/* $NetBSD: sysmon_envsys.c,v 1.141 2017/09/11 06:02:09 pgoyette Exp $ */ /*- * Copyright (c) 2007, 2008 Juan Romero Pardines. @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.140 2017/09/06 11:08:53 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.141 2017/09/11 06:02:09 pgoyette Exp $"); #include #include @@ -525,6 +525,8 @@ sysmon_envsys_create(void) { struct sysmon_envsys *sme; + CTASSERT(SME_CALLOUT_INVALID == 0); + sme = kmem_zalloc(sizeof(*sme), KM_SLEEP); TAILQ_INIT(>sme_sensors_list); LIST_INIT(>sme_events_list); @@ -654,7 +656,8 @@ sysmon_envsys_sensor_detach(struct sysmo rnd_detach_source(>rnd_src); sme_event_unregister_sensor(sme, edata); if (LIST_EMPTY(>sme_events_list)) { - sme_events_halt_callout(sme); + if (sme->sme_callout_state == SME_CALLOUT_READY) + sme_events_halt_callout(sme); destroy = true; } TAILQ_REMOVE(>sme_sensors_list, edata, sensors_head); @@ -1269,15 +1272,23 @@ sme_remove_userprops(void) } /* - * Finally, remove any old limits event, then - * install a new event (which will update the - * dictionary) + * If the sensor is providing entropy data, + * get rid of the rndsrc; we'll provide a new + * one shortly. + */ + if (edata->flags & ENVSYS_FHAS_ENTROPY) +rnd_detach_source(>rnd_src); + + /* + * Remove the old limits event, if any */ sme_event_unregister(sme, edata->desc, PENVSYS_EVENT_LIMITS); /* - * Find the correct units for this sensor. + * Create and install a new event (which will + * update the dictionary) with the correct + * units. */ sdt_units = sme_find_table_entry(SME_DESC_UNITS, edata->units); @@ -1290,6 +1301,11 @@ sme_remove_userprops(void) , props, PENVSYS_EVENT_LIMITS, sdt_units->crittype); } + + /* Finally, if the sensor provides entropy, + * create an additional event entry and attach + * the rndsrc + */ if (edata->flags & ENVSYS_FHAS_ENTROPY) { sme_event_register(sdict, edata, sme, , props, PENVSYS_EVENT_NULL, @@ -1308,8 +1324,17 @@ sme_remove_userprops(void) * Restore default timeout value. */ sme->sme_events_timeout = SME_EVENTS_DEFTIMEOUT; + + /* + * Note that we need to hold the sme_mtx while calling + * sme_schedule_callout(). Thus to avoid dropping, + * reacquiring, and dropping it again, we just tell + * sme_envsys_release() that the mutex is already owned. + */ + mutex_enter(>sme_mtx); sme_schedule_callout(sme); - sysmon_envsys_release(sme, false); + sysmon_envsys_release(sme, true); + mutex_exit(>sme_mtx); } mutex_exit(_global_mtx); } @@ -1350,7 +1375,9 @@ sme_add_property_dictionary(struct sysmo */ if (sme->sme_events_timeout == 0) { sme->sme_events_timeout = SME_EVENTS_DEFTIMEOUT; + mutex_enter(>sme_mtx); sme_schedule_callout(sme); + mutex_exit(>sme_mtx); } if (!prop_dictionary_set_uint64(pdict, "refresh-timeout", @@ -1824,7 +1851,7 @@ sme_userset_dictionary(struct sysmon_env sme_schedule_callout(sme); } mutex_exit(>sme_mtx); - } + } } return error; Index: src/sys/dev/sysmon/sysmon_envsys_events.c diff -u src/sys/dev/sysmon/sysmon_envsys_events.c:1.120 src/sys/dev/sysmon/sysmon_envsys_events.c:1.121 --- src/sys/dev/sysmon/sysmon_envsys_events.c:1.120 Wed Sep 6 11:08:53 2017 +++ src/sys/dev/sysmon/sysmon_envsys_events.c Mon Sep 11 06:02:09 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_envsys_events.c,v 1.120 2017/09/06 11:08:53 msaitoh Exp $ */ +/* $NetBSD: sysmon_envsys_events.c,v 1.121
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Mon Sep 11 06:02:09 UTC 2017 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c sysmon_envsys_events.c sysmonvar.h Log Message: Improve tracking of the state of an event's callout, and protect all queries or modifications of the state with the sme_mtx mutex. Detach the rndsrc before re-attaching it (with potentially new values). Clean up some lock-ordering issues. And a couple of KNF issues for good measure! Should address PR kern/52533 XXX Pullup-8 along with the previous fixes from msaitoh@ XXX http://mail-index.netbsd.org/source-changes/2017/09/06/msg088028.html ~ ~ To generate a diff of this commit: cvs rdiff -u -r1.140 -r1.141 src/sys/dev/sysmon/sysmon_envsys.c cvs rdiff -u -r1.120 -r1.121 src/sys/dev/sysmon/sysmon_envsys_events.c cvs rdiff -u -r1.49 -r1.50 src/sys/dev/sysmon/sysmonvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: msaitoh Date: Wed Sep 6 11:08:54 UTC 2017 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c sysmon_envsys_events.c Log Message: 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@. To generate a diff of this commit: cvs rdiff -u -r1.139 -r1.140 src/sys/dev/sysmon/sysmon_envsys.c cvs rdiff -u -r1.119 -r1.120 src/sys/dev/sysmon/sysmon_envsys_events.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon_envsys.c diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.139 src/sys/dev/sysmon/sysmon_envsys.c:1.140 --- src/sys/dev/sysmon/sysmon_envsys.c:1.139 Mon Dec 14 01:08:47 2015 +++ src/sys/dev/sysmon/sysmon_envsys.c Wed Sep 6 11:08:53 2017 @@ -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 -__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 #include @@ -650,6 +650,8 @@ sysmon_envsys_sensor_detach(struct sysmo /* * remove it, unhook from rnd(4), and decrement the sensors count. */ + if (oedata->flags & ENVSYS_FHAS_ENTROPY) + rnd_detach_source(>rnd_src); sme_event_unregister_sensor(sme, edata); if (LIST_EMPTY(>sme_events_list)) { sme_events_halt_callout(sme); @@ -970,6 +972,7 @@ sysmon_envsys_unregister(struct sysmon_e { prop_array_t array; struct sysmon_envsys *osme; + envsys_data_t *edata; KASSERT(sme != NULL); @@ -987,6 +990,10 @@ sysmon_envsys_unregister(struct sysmon_e LIST_REMOVE(sme, sme_list); mutex_exit(_global_mtx); + TAILQ_FOREACH(edata, >sme_sensors_list, sensors_head) { + sysmon_envsys_sensor_detach(sme, edata); + } + /* * Unregister all events associated with device. */ Index: src/sys/dev/sysmon/sysmon_envsys_events.c diff -u src/sys/dev/sysmon/sysmon_envsys_events.c:1.119 src/sys/dev/sysmon/sysmon_envsys_events.c:1.120 --- src/sys/dev/sysmon/sysmon_envsys_events.c:1.119 Thu Jun 1 02:45:11 2017 +++ src/sys/dev/sysmon/sysmon_envsys_events.c Wed Sep 6 11:08:53 2017 @@ -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 -__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 #include @@ -480,8 +480,6 @@ sme_remove_event(sme_event_t *see, struc KASSERT(mutex_owned(>sme_mtx)); - if (see->see_edata->flags & ENVSYS_FHAS_ENTROPY) - rnd_detach_source(>see_edata->rnd_src); LIST_REMOVE(see, see_list); kmem_free(see, sizeof(*see)); }
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: msaitoh Date: Wed Sep 6 11:08:54 UTC 2017 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c sysmon_envsys_events.c Log Message: 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@. To generate a diff of this commit: cvs rdiff -u -r1.139 -r1.140 src/sys/dev/sysmon/sysmon_envsys.c cvs rdiff -u -r1.119 -r1.120 src/sys/dev/sysmon/sysmon_envsys_events.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: jdc Date: Sun Dec 13 17:41:48 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c Log Message: Note the sensor number in the error output. Useful for drivers adding multiple sensors. To generate a diff of this commit: cvs rdiff -u -r1.137 -r1.138 src/sys/dev/sysmon/sysmon_envsys.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon_envsys.c diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.137 src/sys/dev/sysmon/sysmon_envsys.c:1.138 --- src/sys/dev/sysmon/sysmon_envsys.c:1.137 Sat Apr 25 23:40:09 2015 +++ src/sys/dev/sysmon/sysmon_envsys.c Sun Dec 13 17:41:48 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_envsys.c,v 1.137 2015/04/25 23:40:09 pgoyette Exp $ */ +/* $NetBSD: sysmon_envsys.c,v 1.138 2015/12/13 17:41:48 jdc Exp $ */ /*- * Copyright (c) 2007, 2008 Juan Romero Pardines. @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.137 2015/04/25 23:40:09 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.138 2015/12/13 17:41:48 jdc Exp $"); #include #include @@ -1656,8 +1656,8 @@ sme_update_sensor_dictionary(prop_object sdt = sme_find_table_entry(SME_DESC_STATES, edata->state); if (sdt == NULL) { - printf("sme_update_sensor_dictionary: can not update sensor " - "state %d unknown\n", edata->state); + printf("sme_update_sensor_dictionary: cannot update sensor %d " + "state %d unknown\n", edata->sensor, edata->state); return EINVAL; }
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: jdc Date: Sun Dec 13 17:41:48 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c Log Message: Note the sensor number in the error output. Useful for drivers adding multiple sensors. To generate a diff of this commit: cvs rdiff -u -r1.137 -r1.138 src/sys/dev/sysmon/sysmon_envsys.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Mon Dec 14 01:08:47 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c sysmon_power.c sysmon_wdog.c Log Message: sysmon's components need to be MODULE_CLASS_DRIVER so they will get initialized before we configure/initialize any devices that interact with them. Thanks, marty! To generate a diff of this commit: cvs rdiff -u -r1.138 -r1.139 src/sys/dev/sysmon/sysmon_envsys.c cvs rdiff -u -r1.56 -r1.57 src/sys/dev/sysmon/sysmon_power.c cvs rdiff -u -r1.28 -r1.29 src/sys/dev/sysmon/sysmon_wdog.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Mon Dec 14 01:08:47 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c sysmon_power.c sysmon_wdog.c Log Message: sysmon's components need to be MODULE_CLASS_DRIVER so they will get initialized before we configure/initialize any devices that interact with them. Thanks, marty! To generate a diff of this commit: cvs rdiff -u -r1.138 -r1.139 src/sys/dev/sysmon/sysmon_envsys.c cvs rdiff -u -r1.56 -r1.57 src/sys/dev/sysmon/sysmon_power.c cvs rdiff -u -r1.28 -r1.29 src/sys/dev/sysmon/sysmon_wdog.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon_envsys.c diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.138 src/sys/dev/sysmon/sysmon_envsys.c:1.139 --- src/sys/dev/sysmon/sysmon_envsys.c:1.138 Sun Dec 13 17:41:48 2015 +++ src/sys/dev/sysmon/sysmon_envsys.c Mon Dec 14 01:08:47 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_envsys.c,v 1.138 2015/12/13 17:41:48 jdc Exp $ */ +/* $NetBSD: sysmon_envsys.c,v 1.139 2015/12/14 01:08:47 pgoyette Exp $ */ /*- * Copyright (c) 2007, 2008 Juan Romero Pardines. @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.138 2015/12/13 17:41:48 jdc Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.139 2015/12/14 01:08:47 pgoyette Exp $"); #include #include @@ -103,7 +103,7 @@ static void sme_initial_refresh(void *); static uint32_t sme_get_max_value(struct sysmon_envsys *, bool (*)(const envsys_data_t*), bool); -MODULE(MODULE_CLASS_MISC, sysmon_envsys, "sysmon,sysmon_taskq,sysmon_power"); +MODULE(MODULE_CLASS_DRIVER, sysmon_envsys, "sysmon,sysmon_taskq,sysmon_power"); static struct sysmon_opvec sysmon_envsys_opvec = { sysmonopen_envsys, sysmonclose_envsys, sysmonioctl_envsys, Index: src/sys/dev/sysmon/sysmon_power.c diff -u src/sys/dev/sysmon/sysmon_power.c:1.56 src/sys/dev/sysmon/sysmon_power.c:1.57 --- src/sys/dev/sysmon/sysmon_power.c:1.56 Mon Aug 24 22:50:33 2015 +++ src/sys/dev/sysmon/sysmon_power.c Mon Dec 14 01:08:47 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_power.c,v 1.56 2015/08/24 22:50:33 pooka Exp $ */ +/* $NetBSD: sysmon_power.c,v 1.57 2015/12/14 01:08:47 pgoyette Exp $ */ /*- * Copyright (c) 2007 Juan Romero Pardines. @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.56 2015/08/24 22:50:33 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.57 2015/12/14 01:08:47 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -93,7 +93,7 @@ __KERNEL_RCSID(0, "$NetBSD: sysmon_power #include #include -MODULE(MODULE_CLASS_MISC, sysmon_power, "sysmon"); +MODULE(MODULE_CLASS_DRIVER, sysmon_power, "sysmon"); /* * Singly linked list for dictionaries to be stored/sent. Index: src/sys/dev/sysmon/sysmon_wdog.c diff -u src/sys/dev/sysmon/sysmon_wdog.c:1.28 src/sys/dev/sysmon/sysmon_wdog.c:1.29 --- src/sys/dev/sysmon/sysmon_wdog.c:1.28 Fri Jun 5 00:53:47 2015 +++ src/sys/dev/sysmon/sysmon_wdog.c Mon Dec 14 01:08:47 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_wdog.c,v 1.28 2015/06/05 00:53:47 matt Exp $ */ +/* $NetBSD: sysmon_wdog.c,v 1.29 2015/12/14 01:08:47 pgoyette Exp $ */ /*- * Copyright (c) 2000 Zembu Labs, Inc. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sysmon_wdog.c,v 1.28 2015/06/05 00:53:47 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_wdog.c,v 1.29 2015/12/14 01:08:47 pgoyette Exp $"); #include #include @@ -81,7 +81,7 @@ static struct sysmon_opvec sysmon_wdog_o NULL, NULL, NULL }; -MODULE(MODULE_CLASS_MISC, sysmon_wdog, "sysmon"); +MODULE(MODULE_CLASS_DRIVER, sysmon_wdog, "sysmon"); ONCE_DECL(once_wdog);
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: bouyer Date: Thu Oct 15 13:35:30 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys_events.c Log Message: As proposed in https://mail-index.netbsd.org/tech-kern/2015/10/14/msg019511.html don't sleep on sme->sme_mtx in the callout but use mutex_tryenter() and just reschedule the callout if we can't get the mutex now. This fixes a deadlock which can happen if the backed wants to sleep with timeout (e.g. cv_timedwait()) as the backed is called with sme->sme_mtx held. This is a stopgap measure for netbsd-7; sysmon should be changed to not sleep (or call a backend which will sleep) with mutexes held. To generate a diff of this commit: cvs rdiff -u -r1.117 -r1.118 src/sys/dev/sysmon/sysmon_envsys_events.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon_envsys_events.c diff -u src/sys/dev/sysmon/sysmon_envsys_events.c:1.117 src/sys/dev/sysmon/sysmon_envsys_events.c:1.118 --- src/sys/dev/sysmon/sysmon_envsys_events.c:1.117 Tue Jun 23 19:22:56 2015 +++ src/sys/dev/sysmon/sysmon_envsys_events.c Thu Oct 15 13:35:30 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_envsys_events.c,v 1.117 2015/06/23 19:22:56 pgoyette Exp $ */ +/* $NetBSD: sysmon_envsys_events.c,v 1.118 2015/10/15 13:35:30 bouyer Exp $ */ /*- * Copyright (c) 2007, 2008 Juan Romero Pardines. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.117 2015/06/23 19:22:56 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.118 2015/10/15 13:35:30 bouyer Exp $"); #include #include @@ -739,18 +739,21 @@ sme_events_check(void *arg) mutex_exit(>sme_work_mtx); return; } - mutex_exit(>sme_work_mtx); - - mutex_enter(>sme_mtx); - mutex_enter(>sme_work_mtx); + if (!mutex_tryenter(>sme_mtx)) { + /* can't get lock - try again later */ + if (!sysmon_low_power) + sme_schedule_callout(sme); + mutex_exit(>sme_work_mtx); + return; + } LIST_FOREACH(see, >sme_events_list, see_list) { workqueue_enqueue(sme->sme_wq, >see_wk, NULL); see->see_edata->flags |= ENVSYS_FNEED_REFRESH; sme->sme_busy++; } - mutex_exit(>sme_work_mtx); if (!sysmon_low_power) sme_schedule_callout(sme); + mutex_exit(>sme_work_mtx); mutex_exit(>sme_mtx); }
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: bouyer Date: Thu Oct 15 13:35:30 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys_events.c Log Message: As proposed in https://mail-index.netbsd.org/tech-kern/2015/10/14/msg019511.html don't sleep on sme->sme_mtx in the callout but use mutex_tryenter() and just reschedule the callout if we can't get the mutex now. This fixes a deadlock which can happen if the backed wants to sleep with timeout (e.g. cv_timedwait()) as the backed is called with sme->sme_mtx held. This is a stopgap measure for netbsd-7; sysmon should be changed to not sleep (or call a backend which will sleep) with mutexes held. To generate a diff of this commit: cvs rdiff -u -r1.117 -r1.118 src/sys/dev/sysmon/sysmon_envsys_events.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Tue Jun 23 19:22:56 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys_events.c Log Message: Separate the two conditions for the KASSERT, so we can tell which one occurred. To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 src/sys/dev/sysmon/sysmon_envsys_events.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sys/dev/sysmon
yeah - done! thanks! On Tue, 23 Jun 2015, Christoph Badura wrote: On Tue, Jun 23, 2015 at 10:41:42AM +, Paul Goyette wrote: Committed By: pgoyette Date: Tue Jun 23 10:41:42 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys_events.c Log Message: Fix the KASSERT - we want to make sure that _both_ pointers are non-NULL, not just that one or the other is non-NULL! Wouldn't it be better written as: KASSERT(sme != NULL); KASSERT(edata != NULL); Same effect, but when one of the triggers you know immediately which pointer was NULL. --chris - | Paul Goyette | PGP Key fingerprint: | E-mail addresses: | | (Retired)| FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com| | Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org | -
Re: CVS commit: src/sys/dev/sysmon
On Tue, Jun 23, 2015 at 10:41:42AM +, Paul Goyette wrote: Committed By: pgoyette Date: Tue Jun 23 10:41:42 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys_events.c Log Message: Fix the KASSERT - we want to make sure that _both_ pointers are non-NULL, not just that one or the other is non-NULL! Wouldn't it be better written as: KASSERT(sme != NULL); KASSERT(edata != NULL); Same effect, but when one of the triggers you know immediately which pointer was NULL. --chris
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Tue Jun 23 10:41:42 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys_events.c Log Message: Fix the KASSERT - we want to make sure that _both_ pointers are non-NULL, n ot just that one or the other is non-NULL! To generate a diff of this commit: cvs rdiff -u -r1.115 -r1.116 src/sys/dev/sysmon/sysmon_envsys_events.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon_envsys_events.c diff -u src/sys/dev/sysmon/sysmon_envsys_events.c:1.115 src/sys/dev/sysmon/sysmon_envsys_events.c:1.116 --- src/sys/dev/sysmon/sysmon_envsys_events.c:1.115 Sat Apr 18 14:44:44 2015 +++ src/sys/dev/sysmon/sysmon_envsys_events.c Tue Jun 23 10:41:41 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_envsys_events.c,v 1.115 2015/04/18 14:44:44 mlelstv Exp $ */ +/* $NetBSD: sysmon_envsys_events.c,v 1.116 2015/06/23 10:41:41 pgoyette 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.115 2015/04/18 14:44:44 mlelstv Exp $); +__KERNEL_RCSID(0, $NetBSD: sysmon_envsys_events.c,v 1.116 2015/06/23 10:41:41 pgoyette Exp $); #include sys/param.h #include sys/types.h @@ -768,7 +768,7 @@ sme_events_worker(struct work *wk, void envsys_data_t *edata = see-see_edata; KASSERT(wk == see-see_wk); - KASSERT(sme != NULL || edata != NULL); + KASSERT(sme != NULL edata != NULL); mutex_enter(sme-sme_mtx); see-see_flags |= SEE_EVENT_WORKING;
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Tue Jun 23 10:41:42 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys_events.c Log Message: Fix the KASSERT - we want to make sure that _both_ pointers are non-NULL, n ot just that one or the other is non-NULL! To generate a diff of this commit: cvs rdiff -u -r1.115 -r1.116 src/sys/dev/sysmon/sysmon_envsys_events.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: matt Date: Fri Jun 5 00:53:47 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_wdog.c Log Message: Move callout_init to wdog_preinit To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sys/dev/sysmon/sysmon_wdog.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon_wdog.c diff -u src/sys/dev/sysmon/sysmon_wdog.c:1.27 src/sys/dev/sysmon/sysmon_wdog.c:1.28 --- src/sys/dev/sysmon/sysmon_wdog.c:1.27 Sat Apr 25 23:40:09 2015 +++ src/sys/dev/sysmon/sysmon_wdog.c Fri Jun 5 00:53:47 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_wdog.c,v 1.27 2015/04/25 23:40:09 pgoyette Exp $ */ +/* $NetBSD: sysmon_wdog.c,v 1.28 2015/06/05 00:53:47 matt Exp $ */ /*- * Copyright (c) 2000 Zembu Labs, Inc. @@ -41,7 +41,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: sysmon_wdog.c,v 1.27 2015/04/25 23:40:09 pgoyette Exp $); +__KERNEL_RCSID(0, $NetBSD: sysmon_wdog.c,v 1.28 2015/06/05 00:53:47 matt Exp $); #include sys/param.h #include sys/conf.h @@ -92,6 +92,7 @@ wdog_preinit(void) mutex_init(sysmon_wdog_list_mtx, MUTEX_DEFAULT, IPL_NONE); mutex_init(sysmon_wdog_mtx, MUTEX_DEFAULT, IPL_SOFTCLOCK); cv_init(sysmon_wdog_cv, wdogref); + callout_init(sysmon_wdog_callout, 0); return 0; } @@ -109,7 +110,6 @@ sysmon_wdog_init(void) sysmon_wdog_cphook = critpollhook_establish(sysmon_wdog_critpoll, NULL); if (sysmon_wdog_cphook == NULL) printf(WARNING: unable to register watchdog critpoll hook\n); - callout_init(sysmon_wdog_callout, 0); error = sysmon_attach_minor(SYSMON_MINOR_WDOG, sysmon_wdog_opvec);
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: matt Date: Fri Jun 5 00:53:47 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_wdog.c Log Message: Move callout_init to wdog_preinit To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sys/dev/sysmon/sysmon_wdog.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Tue May 12 10:20:14 UTC 2015 Modified Files: src/sys/dev/sysmon: swwdog.c Log Message: Finish work started in previous commit. Ensure that initialization code is only called once for built-in variants of the module. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/dev/sysmon/swwdog.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/swwdog.c diff -u src/sys/dev/sysmon/swwdog.c:1.18 src/sys/dev/sysmon/swwdog.c:1.19 --- src/sys/dev/sysmon/swwdog.c:1.18 Tue May 12 02:38:00 2015 +++ src/sys/dev/sysmon/swwdog.c Tue May 12 10:20:14 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: swwdog.c,v 1.18 2015/05/12 02:38:00 pgoyette Exp $ */ +/* $NetBSD: swwdog.c,v 1.19 2015/05/12 10:20:14 pgoyette Exp $ */ /* * Copyright (c) 2004, 2005 Steven M. Bellovin @@ -33,7 +33,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: swwdog.c,v 1.18 2015/05/12 02:38:00 pgoyette Exp $); +__KERNEL_RCSID(0, $NetBSD: swwdog.c,v 1.19 2015/05/12 10:20:14 pgoyette Exp $); /* * @@ -309,7 +309,8 @@ swwdog_init(void *arg) * Merge the driver info into the kernel tables and attach the * pseudo-device */ - int error; + int error = 0; + #ifdef _MODULE error = config_cfdriver_attach(swwdog_cd); @@ -318,9 +319,7 @@ swwdog_init(void *arg) swwdog_cd.cd_name); return error; } -#endif error = swwdogattach(1); -#ifdef _MODULE if (error) { aprint_error(%s: device attach failed\n, swwdog_cd.cd_name); config_cfdriver_detach(swwdog_cd);
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Tue May 12 02:38:00 UTC 2015 Modified Files: src/sys/dev/sysmon: swwdog.c Log Message: Don't manipulate the autoconfig databases for built-in module. Thanks, christos! To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/dev/sysmon/swwdog.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/swwdog.c diff -u src/sys/dev/sysmon/swwdog.c:1.17 src/sys/dev/sysmon/swwdog.c:1.18 --- src/sys/dev/sysmon/swwdog.c:1.17 Fri Apr 24 19:49:24 2015 +++ src/sys/dev/sysmon/swwdog.c Tue May 12 02:38:00 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: swwdog.c,v 1.17 2015/04/24 19:49:24 christos Exp $ */ +/* $NetBSD: swwdog.c,v 1.18 2015/05/12 02:38:00 pgoyette Exp $ */ /* * Copyright (c) 2004, 2005 Steven M. Bellovin @@ -33,7 +33,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: swwdog.c,v 1.17 2015/04/24 19:49:24 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: swwdog.c,v 1.18 2015/05/12 02:38:00 pgoyette Exp $); /* * @@ -311,17 +311,21 @@ swwdog_init(void *arg) */ int error; +#ifdef _MODULE error = config_cfdriver_attach(swwdog_cd); if (error) { aprint_error(%s: unable to attach cfdriver\n, swwdog_cd.cd_name); return error; } +#endif error = swwdogattach(1); +#ifdef _MODULE if (error) { aprint_error(%s: device attach failed\n, swwdog_cd.cd_name); config_cfdriver_detach(swwdog_cd); } +#endif return error; } @@ -334,6 +338,7 @@ swwdog_fini(void *arg) error = config_detach(swwdog_dev, 0); +#ifdef _MODULE error = config_cfattach_detach(swwdog_cd.cd_name, swwdog_ca); if (error) aprint_error(%s: error detaching cfattach: %d\n, @@ -343,6 +348,7 @@ swwdog_fini(void *arg) if (error) aprint_error(%s: error detaching cfdriver: %d\n, swwdog_cd.cd_name, error); +#endif return error; }
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Tue May 5 09:22:33 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon.c Log Message: Optimize a bit - don't re-enter the mutex if we're just going to exit. While here, remove some parens around a return value. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sys/dev/sysmon/sysmon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon.c diff -u src/sys/dev/sysmon/sysmon.c:1.27 src/sys/dev/sysmon/sysmon.c:1.28 --- src/sys/dev/sysmon/sysmon.c:1.27 Tue May 5 00:28:25 2015 +++ src/sys/dev/sysmon/sysmon.c Tue May 5 09:22:33 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon.c,v 1.27 2015/05/05 00:28:25 pgoyette Exp $ */ +/* $NetBSD: sysmon.c,v 1.28 2015/05/05 09:22:33 pgoyette Exp $ */ /*- * Copyright (c) 2000 Zembu Labs, Inc. @@ -39,7 +39,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: sysmon.c,v 1.27 2015/05/05 00:28:25 pgoyette Exp $); +__KERNEL_RCSID(0, $NetBSD: sysmon.c,v 1.28 2015/05/05 09:22:33 pgoyette Exp $); #include sys/param.h #include sys/conf.h @@ -152,9 +152,9 @@ sysmonopen(dev_t dev, int flag, int mode mutex_exit(sysmon_minor_mtx); error = module_autoload(sysmon_mod[minor(dev)], MODULE_CLASS_MISC); - mutex_enter(sysmon_minor_mtx); if (error) -break; +return error; + mutex_enter(sysmon_minor_mtx); if (sysmon_opvec_table[minor(dev)] == NULL) { error = ENODEV; break; @@ -170,7 +170,7 @@ sysmonopen(dev_t dev, int flag, int mode } mutex_exit(sysmon_minor_mtx); - return (error); + return error; } /*
Re: CVS commit: src/sys/dev/sysmon
On May 5, 10:22am, p...@vps1.whooppee.com (Paul Goyette) wrote: -- Subject: Re: CVS commit: src/sys/dev/sysmon | On Tue, 5 May 2015, Christos Zoulas wrote: | | In article 20150505002825.9e50...@cvs.netbsd.org, | Paul Goyette source-changes-d@NetBSD.org wrote: | -=-=-=-=-=- | | Module Name: src | Committed By: pgoyette | Date: Tue May 5 00:28:25 UTC 2015 | | Modified Files: | src/sys/dev/sysmon: sysmon.c | | Log Message: | If module_autoload() returns an error, just return that value instead | of overwriting with ENODEV. | | Thanks, christos! | | Yes, but break before the mutex_enter... | | Need to hold the mutex so we can release it below... Return error then? christos
Re: CVS commit: src/sys/dev/sysmon
On Tue, 5 May 2015, Christos Zoulas wrote: | If module_autoload() returns an error, just return that value instead | of overwriting with ENODEV. | | | Yes, but break before the mutex_enter... | | Need to hold the mutex so we can release it below... Return error then? Yeah, possible. let me have another look. - | Paul Goyette | PGP Key fingerprint: | E-mail addresses: | | (Retired)| FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com| | Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org | -
Re: CVS commit: src/sys/dev/sysmon
On Tue, 5 May 2015, Christos Zoulas wrote: In article 20150505002825.9e50...@cvs.netbsd.org, Paul Goyette source-changes-d@NetBSD.org wrote: -=-=-=-=-=- Module Name:src Committed By: pgoyette Date: Tue May 5 00:28:25 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon.c Log Message: If module_autoload() returns an error, just return that value instead of overwriting with ENODEV. Thanks, christos! Yes, but break before the mutex_enter... Need to hold the mutex so we can release it below... - | Paul Goyette | PGP Key fingerprint: | E-mail addresses: | | (Retired)| FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com| | Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org | -
Re: CVS commit: src/sys/dev/sysmon
In article 20150504235036.d534...@cvs.netbsd.org, Paul Goyette source-changes-d@NetBSD.org wrote: -=-=-=-=-=- Module Name: src Committed By: pgoyette Date: Mon May 4 23:50:36 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon.c Log Message: If autoload of the subcomponent module fails, don't try to call its open routine. Just return an error. Hopefully this will fix the recently reported issues with atf tests running on xen guest. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/dev/sysmon/sysmon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. -=-=-=-=-=- #include sys/param.h #include sys/conf.h @@ -153,8 +153,10 @@ sysmonopen(dev_t dev, int flag, int mode error = module_autoload(sysmon_mod[minor(dev)], MODULE_CLASS_MISC); I am confused; at this point if autoload returned an error, why bother continuing and losing the error return from the autoload? Why not add: if (error) break; christos mutex_enter(sysmon_minor_mtx); - if (sysmon_opvec_table[minor(dev)] == NULL) + if (sysmon_opvec_table[minor(dev)] == NULL) { error = ENODEV; + break; + } } error = (sysmon_opvec_table[minor(dev)]-so_open)(dev, flag, mode, l); -=-=-=-=-=-
Re: CVS commit: src/sys/dev/sysmon
On Tue, 5 May 2015, Christos Zoulas wrote: Module Name:src Committed By: pgoyette Date: Mon May 4 23:50:36 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon.c Log Message: If autoload of the subcomponent module fails, don't try to call its open routine. Just return an error. Hopefully this will fix the recently reported issues with atf tests running on xen guest. -=-=-=-=-=- #include sys/param.h #include sys/conf.h @@ -153,8 +153,10 @@ sysmonopen(dev_t dev, int flag, int mode error = module_autoload(sysmon_mod[minor(dev)], MODULE_CLASS_MISC); I am confused; at this point if autoload returned an error, why bother continuing and losing the error return from the autoload? Why not add: if (error) break; mutex_enter(sysmon_minor_mtx); - if (sysmon_opvec_table[minor(dev)] == NULL) + if (sysmon_opvec_table[minor(dev)] == NULL) { error = ENODEV; + break; + } } error = (sysmon_opvec_table[minor(dev)]-so_open)(dev, flag, mode, l); -=-=-=-=-=- Yeah, makes sense. I will update accordingly. - | Paul Goyette | PGP Key fingerprint: | E-mail addresses: | | (Retired)| FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com| | Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org | -
Re: CVS commit: src/sys/dev/sysmon
In article 20150505002825.9e50...@cvs.netbsd.org, Paul Goyette source-changes-d@NetBSD.org wrote: -=-=-=-=-=- Module Name: src Committed By: pgoyette Date: Tue May 5 00:28:25 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon.c Log Message: If module_autoload() returns an error, just return that value instead of overwriting with ENODEV. Thanks, christos! Yes, but break before the mutex_enter... christos To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/dev/sysmon/sysmon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. -=-=-=-=-=- Modified files: Index: src/sys/dev/sysmon/sysmon.c diff -u src/sys/dev/sysmon/sysmon.c:1.26 src/sys/dev/sysmon/sysmon.c:1.27 --- src/sys/dev/sysmon/sysmon.c:1.26 Mon May 4 23:50:36 2015 +++ src/sys/dev/sysmon/sysmon.cTue May 5 00:28:25 2015 @@ -1,4 +1,4 @@ -/*$NetBSD: sysmon.c,v 1.26 2015/05/04 23:50:36 pgoyette Exp $ */ +/*$NetBSD: sysmon.c,v 1.27 2015/05/05 00:28:25 pgoyette Exp $ */ /*- * Copyright (c) 2000 Zembu Labs, Inc. @@ -39,7 +39,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: sysmon.c,v 1.26 2015/05/04 23:50:36 pgoyette Exp $); +__KERNEL_RCSID(0, $NetBSD: sysmon.c,v 1.27 2015/05/05 00:28:25 pgoyette Exp $); #include sys/param.h #include sys/conf.h @@ -153,6 +153,8 @@ sysmonopen(dev_t dev, int flag, int mode error = module_autoload(sysmon_mod[minor(dev)], MODULE_CLASS_MISC); mutex_enter(sysmon_minor_mtx); + if (error) + break; if (sysmon_opvec_table[minor(dev)] == NULL) { error = ENODEV; break; -=-=-=-=-=-
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Tue May 5 00:28:25 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon.c Log Message: If module_autoload() returns an error, just return that value instead of overwriting with ENODEV. Thanks, christos! To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/dev/sysmon/sysmon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon.c diff -u src/sys/dev/sysmon/sysmon.c:1.26 src/sys/dev/sysmon/sysmon.c:1.27 --- src/sys/dev/sysmon/sysmon.c:1.26 Mon May 4 23:50:36 2015 +++ src/sys/dev/sysmon/sysmon.c Tue May 5 00:28:25 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon.c,v 1.26 2015/05/04 23:50:36 pgoyette Exp $ */ +/* $NetBSD: sysmon.c,v 1.27 2015/05/05 00:28:25 pgoyette Exp $ */ /*- * Copyright (c) 2000 Zembu Labs, Inc. @@ -39,7 +39,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: sysmon.c,v 1.26 2015/05/04 23:50:36 pgoyette Exp $); +__KERNEL_RCSID(0, $NetBSD: sysmon.c,v 1.27 2015/05/05 00:28:25 pgoyette Exp $); #include sys/param.h #include sys/conf.h @@ -153,6 +153,8 @@ sysmonopen(dev_t dev, int flag, int mode error = module_autoload(sysmon_mod[minor(dev)], MODULE_CLASS_MISC); mutex_enter(sysmon_minor_mtx); + if (error) +break; if (sysmon_opvec_table[minor(dev)] == NULL) { error = ENODEV; break;
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Mon May 4 23:50:36 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon.c Log Message: If autoload of the subcomponent module fails, don't try to call its open routine. Just return an error. Hopefully this will fix the recently reported issues with atf tests running on xen guest. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/dev/sysmon/sysmon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon.c diff -u src/sys/dev/sysmon/sysmon.c:1.25 src/sys/dev/sysmon/sysmon.c:1.26 --- src/sys/dev/sysmon/sysmon.c:1.25 Wed Apr 29 03:27:27 2015 +++ src/sys/dev/sysmon/sysmon.c Mon May 4 23:50:36 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon.c,v 1.25 2015/04/29 03:27:27 pgoyette Exp $ */ +/* $NetBSD: sysmon.c,v 1.26 2015/05/04 23:50:36 pgoyette Exp $ */ /*- * Copyright (c) 2000 Zembu Labs, Inc. @@ -39,7 +39,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: sysmon.c,v 1.25 2015/04/29 03:27:27 pgoyette Exp $); +__KERNEL_RCSID(0, $NetBSD: sysmon.c,v 1.26 2015/05/04 23:50:36 pgoyette Exp $); #include sys/param.h #include sys/conf.h @@ -153,8 +153,10 @@ sysmonopen(dev_t dev, int flag, int mode error = module_autoload(sysmon_mod[minor(dev)], MODULE_CLASS_MISC); mutex_enter(sysmon_minor_mtx); - if (sysmon_opvec_table[minor(dev)] == NULL) + if (sysmon_opvec_table[minor(dev)] == NULL) { error = ENODEV; +break; + } } error = (sysmon_opvec_table[minor(dev)]-so_open)(dev, flag, mode, l);
Re: CVS commit: src/sys/dev/sysmon
Date: Tue, 28 Apr 2015 17:01:10 +0800 (PHT) From: Paul Goyette p...@vps1.whooppee.com Well, it really is a (pseudo-)device, and even has its own major device number. We cannot avoid all of the device goop, since a non-built-in-module would still have to merge in the devsw. My goal is to eventually be able to build and run a kernel which has no portion of sysmon built-in, and still be able to load and unload the wdog/power/envsys components, along with the actual drivers for timers/power-switches/sensors. But what purpose does attaching an *autoconf* device serve? The devsw is the userland interface, /dev/sysmon, and is not actually related to autoconf devices. You can attach a devsw without any associated autoconf device, and vice versa. The defpseudo config directive with the associated (often empty) xyzattach routine allows you to include or exclude the code from a kernel statically with the pseudo-device directive. Some pseudo-devices have multiple instances, e.g. cgd(4): each /dev/cgdN needs its own separate state. So it uses multiple autoconf devices to manage the numbered instances. Some pseudo-devices attach children, so they also need an autoconf device. In the case of sysmon, there's only one global state. Some of it is put into a softc struct (sc_minor_mtx); the rest of it is in global variables (sysmon_opvec_table, sysmon_refcnt). It doesn't seem to attach any children. There's no defpseudo, so you can't configure it statically in your kernel. I think you could remove the whole cfattach/cfdriver/sysmon_match/c. business and replace it by initialization in MODULE_CMD_INIT (plus the RUN_ONCE nonsense because builtin modules get initialized too late).
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: martin Date: Tue Apr 28 11:58:50 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_taskq.c Log Message: sysmon_task_queue_sched needs to RUN_ONCE(tq_preinit) as well, it can be called from sysmon_envsys_register() early. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/dev/sysmon/sysmon_taskq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon_taskq.c diff -u src/sys/dev/sysmon/sysmon_taskq.c:1.18 src/sys/dev/sysmon/sysmon_taskq.c:1.19 --- src/sys/dev/sysmon/sysmon_taskq.c:1.18 Mon Apr 27 07:51:28 2015 +++ src/sys/dev/sysmon/sysmon_taskq.c Tue Apr 28 11:58:49 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_taskq.c,v 1.18 2015/04/27 07:51:28 pgoyette Exp $ */ +/* $NetBSD: sysmon_taskq.c,v 1.19 2015/04/28 11:58:49 martin Exp $ */ /* * Copyright (c) 2001, 2003 Wasabi Systems, Inc. @@ -41,7 +41,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: sysmon_taskq.c,v 1.18 2015/04/27 07:51:28 pgoyette Exp $); +__KERNEL_RCSID(0, $NetBSD: sysmon_taskq.c,v 1.19 2015/04/28 11:58:49 martin Exp $); #include sys/param.h #include sys/malloc.h @@ -212,6 +212,8 @@ sysmon_task_queue_sched(u_int pri, void { struct sysmon_task *st, *lst; + (void)RUN_ONCE(once_tq, tq_preinit); + if (sysmon_task_queue_lwp == NULL) aprint_debug(WARNING: Callback scheduled before sysmon task queue thread present\n);
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: martin Date: Tue Apr 28 11:58:50 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_taskq.c Log Message: sysmon_task_queue_sched needs to RUN_ONCE(tq_preinit) as well, it can be called from sysmon_envsys_register() early. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/dev/sysmon/sysmon_taskq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Wed Apr 29 03:27:27 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon.c Log Message: At suggestion from riastradh@ ... Remove auto_configure(9) goop from sysmon device. It does make things a bit cleaner, and also reduces source code by about 10%. Tested via QEMU with no obvious side-effects. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/dev/sysmon/sysmon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon.c diff -u src/sys/dev/sysmon/sysmon.c:1.24 src/sys/dev/sysmon/sysmon.c:1.25 --- src/sys/dev/sysmon/sysmon.c:1.24 Sat Apr 25 23:40:09 2015 +++ src/sys/dev/sysmon/sysmon.c Wed Apr 29 03:27:27 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon.c,v 1.24 2015/04/25 23:40:09 pgoyette Exp $ */ +/* $NetBSD: sysmon.c,v 1.25 2015/04/29 03:27:27 pgoyette Exp $ */ /*- * Copyright (c) 2000 Zembu Labs, Inc. @@ -39,7 +39,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: sysmon.c,v 1.24 2015/04/25 23:40:09 pgoyette Exp $); +__KERNEL_RCSID(0, $NetBSD: sysmon.c,v 1.25 2015/04/29 03:27:27 pgoyette Exp $); #include sys/param.h #include sys/conf.h @@ -52,6 +52,7 @@ __KERNEL_RCSID(0, $NetBSD: sysmon.c,v 1 #include sys/module.h #include sys/mutex.h #include sys/device.h +#include sys/once.h #include dev/sysmon/sysmonvar.h @@ -77,13 +78,8 @@ const struct cdevsw sysmon_cdevsw = { .d_flag = D_OTHER | D_MPSAFE }; -static int sysmon_match(device_t, cfdata_t, void *); -static void sysmon_attach(device_t, device_t, void *); -static int sysmon_detach(device_t, int); - static int sysmon_modcmd(modcmd_t, void *); - -CFDRIVER_DECL(sysmon, DV_DULL, NULL); +static int sm_init_once(void); /* * Info about our minor devices @@ -93,44 +89,13 @@ static int sysmon_refcnt[] = { 0, 0, 0 static const char *sysmon_mod[] = { sysmon_envsys, sysmon_wdog, sysmon_power }; +static kmutex_t sysmon_minor_mtx; -struct sysmon_softc { - device_t sc_dev; - kmutex_t sc_minor_mtx; -}; - -static device_t sysmon_dev = NULL; - -CFATTACH_DECL_NEW(sysmon, sizeof(struct sysmon_softc), -sysmon_match, sysmon_attach, sysmon_detach, NULL); -extern struct cfdriver sysmon_cd; - -static int -sysmon_match(device_t parent, cfdata_t data, void *aux) -{ - - return 1; -} - -static void -sysmon_attach(device_t parent, device_t self, void *aux) -{ - -struct sysmon_softc *sc = device_private(self); - -sc-sc_dev = self; - - mutex_init(sc-sc_minor_mtx, MUTEX_DEFAULT, IPL_NONE); -} - -static int -sysmon_detach(device_t self, int flags) -{ -struct sysmon_softc *sc = device_private(self); +#ifdef _MODULE +static bool sm_is_attached; +#endif - mutex_destroy(sc-sc_minor_mtx); - return 0; -} +ONCE_DECL(once_sm); /* * sysmon_attach_minor @@ -145,10 +110,9 @@ sysmon_detach(device_t self, int flags) int sysmon_attach_minor(int minor, struct sysmon_opvec *opvec) { - struct sysmon_softc *sc = device_private(sysmon_dev); int ret; - mutex_enter(sc-sc_minor_mtx); + mutex_enter(sysmon_minor_mtx); if (opvec) { if (sysmon_opvec_table[minor] == NULL) { sysmon_refcnt[minor] = 0; @@ -164,7 +128,7 @@ sysmon_attach_minor(int minor, struct sy ret = EBUSY; } - mutex_exit(sc-sc_minor_mtx); + mutex_exit(sysmon_minor_mtx); return ret; } @@ -176,20 +140,19 @@ sysmon_attach_minor(int minor, struct sy int sysmonopen(dev_t dev, int flag, int mode, struct lwp *l) { - struct sysmon_softc *sc = device_private(sysmon_dev); int error; - mutex_enter(sc-sc_minor_mtx); + mutex_enter(sysmon_minor_mtx); switch (minor(dev)) { case SYSMON_MINOR_ENVSYS: case SYSMON_MINOR_WDOG: case SYSMON_MINOR_POWER: if (sysmon_opvec_table[minor(dev)] == NULL) { - mutex_exit(sc-sc_minor_mtx); + mutex_exit(sysmon_minor_mtx); error = module_autoload(sysmon_mod[minor(dev)], MODULE_CLASS_MISC); - mutex_enter(sc-sc_minor_mtx); + mutex_enter(sysmon_minor_mtx); if (sysmon_opvec_table[minor(dev)] == NULL) error = ENODEV; } @@ -202,7 +165,7 @@ sysmonopen(dev_t dev, int flag, int mode error = ENODEV; } - mutex_exit(sc-sc_minor_mtx); + mutex_exit(sysmon_minor_mtx); return (error); } @@ -342,65 +305,36 @@ sysmonkqfilter(dev_t dev, struct knote * MODULE(MODULE_CLASS_DRIVER, sysmon, ); +static int +sm_init_once(void) +{ + + mutex_init(sysmon_minor_mtx, MUTEX_DEFAULT, IPL_NONE); + + return 0; +} + int sysmon_init(void) { + int error; #ifdef _MODULE devmajor_t bmajor, cmajor; #endif - static struct cfdata cf; - int error = 0; - if (sysmon_dev != NULL) { - return EEXIST; - } - - error = config_cfdriver_attach(sysmon_cd); - if (error) { - aprint_error(%s: unable to attach cfdriver\n, - sysmon_cd.cd_name); - return error; - } - error = config_cfattach_attach(sysmon_cd.cd_name, sysmon_ca); - if (error) { -
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Wed Apr 29 03:27:27 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon.c Log Message: At suggestion from riastradh@ ... Remove auto_configure(9) goop from sysmon device. It does make things a bit cleaner, and also reduces source code by about 10%. Tested via QEMU with no obvious side-effects. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/dev/sysmon/sysmon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sys/dev/sysmon
Well, it really is a (pseudo-)device, and even has its own major device number. We cannot avoid all of the device goop, since a non-built-in-module would still have to merge in the devsw. My goal is to eventually be able to build and run a kernel which has no portion of sysmon built-in, and still be able to load and unload the wdog/power/envsys components, along with the actual drivers for timers/power-switches/sensors. It's really not all that complicated. On Tue, 28 Apr 2015, Taylor R Campbell wrote: Date: Thu, 23 Apr 2015 23:22:03 + From: Paul Goyette pgoye...@netbsd.org Modularize sysmon and its components Why does this introduce a sysmon(4) autoconf device? It seems like needless bookkeeping -- you could just make the mutex global, like all the state it protects, and skip all the match/attach/detach/cfdriver autoconf business. - | Paul Goyette | PGP Key fingerprint: | E-mail addresses: | | (Retired)| FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com| | Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org | -
Re: CVS commit: src/sys/dev/sysmon
Date: Thu, 23 Apr 2015 23:22:03 + From: Paul Goyette pgoye...@netbsd.org Modularize sysmon and its components Why does this introduce a sysmon(4) autoconf device? It seems like needless bookkeeping -- you could just make the mutex global, like all the state it protects, and skip all the match/attach/detach/cfdriver autoconf business.
re: CVS commit: src/sys/dev/sysmon
Christos Zoulas writes: Module Name: src Committed By: christos Date: Sat Apr 25 14:06:58 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c Log Message: make things boot again, from martin. thanks. updating to test now.. but shouldn't this use RUN_ONCE() and/or a lock/atomic? .mrg.
Re: CVS commit: src/sys/dev/sysmon
Done. Doing some testing now but should be ok. On Sat, 25 Apr 2015, Christos Zoulas wrote: In article 1723.1429983...@splode.eterna.com.au, matthew green m...@eterna.com.au wrote: Christos Zoulas writes: Module Name:src Committed By: christos Date: Sat Apr 25 14:06:58 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c Log Message: make things boot again, from martin. thanks. updating to test now.. but shouldn't this use RUN_ONCE() and/or a lock/atomic? Yes, I am letting paul fix it properly the way he wants. christos - | Paul Goyette | PGP Key fingerprint: | E-mail addresses: | | (Retired)| FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com| | Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org | -
Re: CVS commit: src/sys/dev/sysmon
Thanks. :) I'll get this (and the corresponding changes to sysmon_power and sysmon_wdog subcomponents) done shortly. On Sat, 25 Apr 2015, Christos Zoulas wrote: In article 1723.1429983...@splode.eterna.com.au, matthew green m...@eterna.com.au wrote: Christos Zoulas writes: Module Name:src Committed By: christos Date: Sat Apr 25 14:06:58 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c Log Message: make things boot again, from martin. thanks. updating to test now.. but shouldn't this use RUN_ONCE() and/or a lock/atomic? Yes, I am letting paul fix it properly the way he wants. christos - | Paul Goyette | PGP Key fingerprint: | E-mail addresses: | | (Retired)| FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com| | Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org | -
Re: CVS commit: src/sys/dev/sysmon
On 4/25/15 3:46 PM, Paul Goyette wrote: Module Name:src Committed By: pgoyette Date: Sat Apr 25 22:46:31 UTC 2015 + if (pmf_device_register(sysmon_dev, NULL, NULL)) + aprintf_error(%s: failed to register with pmf\n, I think you mean aprint_error. This doesn't link. +j
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Sat Apr 25 23:55:24 UTC 2015 Modified Files: src/sys/dev/sysmon: swsensor.c Log Message: Remove another debug printf() that snuck in. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/dev/sysmon/swsensor.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/swsensor.c diff -u src/sys/dev/sysmon/swsensor.c:1.14 src/sys/dev/sysmon/swsensor.c:1.15 --- src/sys/dev/sysmon/swsensor.c:1.14 Thu Apr 23 23:23:01 2015 +++ src/sys/dev/sysmon/swsensor.c Sat Apr 25 23:55:23 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: swsensor.c,v 1.14 2015/04/23 23:23:01 pgoyette Exp $ */ +/* $NetBSD: swsensor.c,v 1.15 2015/04/25 23:55:23 pgoyette Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. @@ -27,7 +27,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: swsensor.c,v 1.14 2015/04/23 23:23:01 pgoyette Exp $); +__KERNEL_RCSID(0, $NetBSD: swsensor.c,v 1.15 2015/04/25 23:55:23 pgoyette Exp $); #include sys/param.h #include sys/kernel.h @@ -225,7 +225,6 @@ swsensor_init(void *arg) val = prop_number_integer_value(po); /* Sensor type/units */ -printf(%s: prop object key = \%s\\n, __func__, key); if (strcmp(key, type) == 0) { if (type == PROP_TYPE_NUMBER) { descr = sme_find_table_entry(
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Sat Apr 25 23:55:24 UTC 2015 Modified Files: src/sys/dev/sysmon: swsensor.c Log Message: Remove another debug printf() that snuck in. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/dev/sysmon/swsensor.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sys/dev/sysmon
Ooops - this should have been two commits. Log message is correct for sysmon.c For the others, message has been corrected to read: Handle early initialization requirements - thanks martin@ and others On Sat, 25 Apr 2015, Paul Goyette wrote: Module Name:src Committed By: pgoyette Date: Sat Apr 25 23:40:09 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon.c sysmon_envsys.c sysmon_power.c sysmon_wdog.c Log Message: Correctly check return status when registering with pmf To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/dev/sysmon/sysmon.c cvs rdiff -u -r1.136 -r1.137 src/sys/dev/sysmon/sysmon_envsys.c cvs rdiff -u -r1.54 -r1.55 src/sys/dev/sysmon/sysmon_power.c cvs rdiff -u -r1.26 -r1.27 src/sys/dev/sysmon/sysmon_wdog.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. - | Paul Goyette | PGP Key fingerprint: | E-mail addresses: | | (Retired)| FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com| | Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org | -
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Sat Apr 25 23:40:09 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon.c sysmon_envsys.c sysmon_power.c sysmon_wdog.c Log Message: Correctly check return status when registering with pmf To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/dev/sysmon/sysmon.c cvs rdiff -u -r1.136 -r1.137 src/sys/dev/sysmon/sysmon_envsys.c cvs rdiff -u -r1.54 -r1.55 src/sys/dev/sysmon/sysmon_power.c cvs rdiff -u -r1.26 -r1.27 src/sys/dev/sysmon/sysmon_wdog.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon.c diff -u src/sys/dev/sysmon/sysmon.c:1.23 src/sys/dev/sysmon/sysmon.c:1.24 --- src/sys/dev/sysmon/sysmon.c:1.23 Sat Apr 25 23:16:37 2015 +++ src/sys/dev/sysmon/sysmon.c Sat Apr 25 23:40:09 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon.c,v 1.23 2015/04/25 23:16:37 pgoyette Exp $ */ +/* $NetBSD: sysmon.c,v 1.24 2015/04/25 23:40:09 pgoyette Exp $ */ /*- * Copyright (c) 2000 Zembu Labs, Inc. @@ -39,7 +39,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: sysmon.c,v 1.23 2015/04/25 23:16:37 pgoyette Exp $); +__KERNEL_RCSID(0, $NetBSD: sysmon.c,v 1.24 2015/04/25 23:40:09 pgoyette Exp $); #include sys/param.h #include sys/conf.h @@ -397,7 +397,7 @@ sysmon_init(void) error = ENODEV; } - if (pmf_device_register(sysmon_dev, NULL, NULL)) + if (!pmf_device_register(sysmon_dev, NULL, NULL)) aprint_error(%s: failed to register with pmf\n, sysmon_cd.cd_name); Index: src/sys/dev/sysmon/sysmon_envsys.c diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.136 src/sys/dev/sysmon/sysmon_envsys.c:1.137 --- src/sys/dev/sysmon/sysmon_envsys.c:1.136 Sat Apr 25 14:06:58 2015 +++ src/sys/dev/sysmon/sysmon_envsys.c Sat Apr 25 23:40:09 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_envsys.c,v 1.136 2015/04/25 14:06:58 christos Exp $ */ +/* $NetBSD: sysmon_envsys.c,v 1.137 2015/04/25 23:40:09 pgoyette 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.136 2015/04/25 14:06:58 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: sysmon_envsys.c,v 1.137 2015/04/25 23:40:09 pgoyette Exp $); #include sys/param.h #include sys/types.h @@ -78,6 +78,7 @@ __KERNEL_RCSID(0, $NetBSD: sysmon_envsy #include sys/kmem.h #include sys/rndsource.h #include sys/module.h +#include sys/once.h #include dev/sysmon/sysmonvar.h #include dev/sysmon/sysmon_envsysvar.h @@ -109,18 +110,17 @@ static struct sysmon_opvec sysmon_envsys NULL, NULL, NULL }; -static void +ONCE_DECL(once_envsys); + +static int sme_preinit(void) { - static bool passed = false; - if (passed) - return; - - passed = true; LIST_INIT(sysmon_envsys_list); mutex_init(sme_global_mtx, MUTEX_DEFAULT, IPL_NONE); sme_propd = prop_dictionary_create(); + + return 0; } /* @@ -133,7 +133,7 @@ sysmon_envsys_init(void) { int error; - sme_preinit(); + (void)RUN_ONCE(once_envsys, sme_preinit); error = sysmon_attach_minor(SYSMON_MINOR_ENVSYS, sysmon_envsys_opvec); @@ -694,7 +694,7 @@ sysmon_envsys_register(struct sysmon_env KASSERT(sme != NULL); KASSERT(sme-sme_name != NULL); - sme_preinit(); + (void)RUN_ONCE(once_envsys, sme_preinit); /* * Check if requested sysmon_envsys device is valid Index: src/sys/dev/sysmon/sysmon_power.c diff -u src/sys/dev/sysmon/sysmon_power.c:1.54 src/sys/dev/sysmon/sysmon_power.c:1.55 --- src/sys/dev/sysmon/sysmon_power.c:1.54 Thu Apr 23 23:22:03 2015 +++ src/sys/dev/sysmon/sysmon_power.c Sat Apr 25 23:40:09 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_power.c,v 1.54 2015/04/23 23:22:03 pgoyette Exp $ */ +/* $NetBSD: sysmon_power.c,v 1.55 2015/04/25 23:40:09 pgoyette Exp $ */ /*- * Copyright (c) 2007 Juan Romero Pardines. @@ -69,7 +69,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: sysmon_power.c,v 1.54 2015/04/23 23:22:03 pgoyette Exp $); +__KERNEL_RCSID(0, $NetBSD: sysmon_power.c,v 1.55 2015/04/25 23:40:09 pgoyette Exp $); #ifndef _LKM #include opt_compat_netbsd.h @@ -88,6 +88,7 @@ __KERNEL_RCSID(0, $NetBSD: sysmon_power #include sys/device.h #include sys/rndsource.h #include sys/module.h +#include sys/once.h #include dev/sysmon/sysmonvar.h #include prop/proplib.h @@ -199,6 +200,18 @@ static struct sysmon_opvec sysmon_power_ #define SYSMON_NEXT_EVENT(x) (((x) + 1) % SYSMON_MAX_POWER_EVENTS) +ONCE_DECL(once_power); + +static int +power_preinit(void) +{ + + mutex_init(sysmon_power_event_queue_mtx, MUTEX_DEFAULT, IPL_NONE); + cv_init(sysmon_power_event_queue_cv, smpower); + + return 0; +} + /* * sysmon_power_init: * @@ -210,8 +223,8 @@ sysmon_power_init(void) { int error; - mutex_init(sysmon_power_event_queue_mtx, MUTEX_DEFAULT, IPL_NONE); - cv_init(sysmon_power_event_queue_cv, smpower); + (void)RUN_ONCE(once_power, power_preinit); +
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Sat Apr 25 23:40:09 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon.c sysmon_envsys.c sysmon_power.c sysmon_wdog.c Log Message: Correctly check return status when registering with pmf To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/dev/sysmon/sysmon.c cvs rdiff -u -r1.136 -r1.137 src/sys/dev/sysmon/sysmon_envsys.c cvs rdiff -u -r1.54 -r1.55 src/sys/dev/sysmon/sysmon_power.c cvs rdiff -u -r1.26 -r1.27 src/sys/dev/sysmon/sysmon_wdog.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Sat Apr 25 23:16:37 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon.c Log Message: Fix typo - thanks, riz@ To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/dev/sysmon/sysmon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon.c diff -u src/sys/dev/sysmon/sysmon.c:1.22 src/sys/dev/sysmon/sysmon.c:1.23 --- src/sys/dev/sysmon/sysmon.c:1.22 Sat Apr 25 22:46:31 2015 +++ src/sys/dev/sysmon/sysmon.c Sat Apr 25 23:16:37 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon.c,v 1.22 2015/04/25 22:46:31 pgoyette Exp $ */ +/* $NetBSD: sysmon.c,v 1.23 2015/04/25 23:16:37 pgoyette Exp $ */ /*- * Copyright (c) 2000 Zembu Labs, Inc. @@ -39,7 +39,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: sysmon.c,v 1.22 2015/04/25 22:46:31 pgoyette Exp $); +__KERNEL_RCSID(0, $NetBSD: sysmon.c,v 1.23 2015/04/25 23:16:37 pgoyette Exp $); #include sys/param.h #include sys/conf.h @@ -398,7 +398,7 @@ sysmon_init(void) } if (pmf_device_register(sysmon_dev, NULL, NULL)) - aprintf_error(%s: failed to register with pmf\n, + aprint_error(%s: failed to register with pmf\n, sysmon_cd.cd_name); return error;
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Sat Apr 25 23:16:37 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon.c Log Message: Fix typo - thanks, riz@ To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/dev/sysmon/sysmon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sys/dev/sysmon
Yup - fixing now... On Sat, 25 Apr 2015, Jeff Rizzo wrote: On 4/25/15 3:46 PM, Paul Goyette wrote: Module Name:src Committed By: pgoyette Date: Sat Apr 25 22:46:31 UTC 2015 + if (pmf_device_register(sysmon_dev, NULL, NULL)) + aprintf_error(%s: failed to register with pmf\n, I think you mean aprint_error. This doesn't link. +j - | Paul Goyette | PGP Key fingerprint: | E-mail addresses: | | (Retired)| FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com| | Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org | -
Re: CVS commit: src/sys/dev/sysmon
In article 1723.1429983...@splode.eterna.com.au, matthew green m...@eterna.com.au wrote: Christos Zoulas writes: Module Name: src Committed By:christos Date:Sat Apr 25 14:06:58 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c Log Message: make things boot again, from martin. thanks. updating to test now.. but shouldn't this use RUN_ONCE() and/or a lock/atomic? Yes, I am letting paul fix it properly the way he wants. christos
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Sat Apr 25 22:46:31 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon.c Log Message: Register the sysmon pseudo-device with power management framework so we can properly suspend the system. Thanks, mrg, for pointing this out. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/dev/sysmon/sysmon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Sat Apr 25 22:46:31 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon.c Log Message: Register the sysmon pseudo-device with power management framework so we can properly suspend the system. Thanks, mrg, for pointing this out. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/dev/sysmon/sysmon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon.c diff -u src/sys/dev/sysmon/sysmon.c:1.21 src/sys/dev/sysmon/sysmon.c:1.22 --- src/sys/dev/sysmon/sysmon.c:1.21 Fri Apr 24 03:35:49 2015 +++ src/sys/dev/sysmon/sysmon.c Sat Apr 25 22:46:31 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon.c,v 1.21 2015/04/24 03:35:49 pgoyette Exp $ */ +/* $NetBSD: sysmon.c,v 1.22 2015/04/25 22:46:31 pgoyette Exp $ */ /*- * Copyright (c) 2000 Zembu Labs, Inc. @@ -39,7 +39,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: sysmon.c,v 1.21 2015/04/24 03:35:49 pgoyette Exp $); +__KERNEL_RCSID(0, $NetBSD: sysmon.c,v 1.22 2015/04/25 22:46:31 pgoyette Exp $); #include sys/param.h #include sys/conf.h @@ -397,6 +397,10 @@ sysmon_init(void) error = ENODEV; } + if (pmf_device_register(sysmon_dev, NULL, NULL)) + aprintf_error(%s: failed to register with pmf\n, + sysmon_cd.cd_name); + return error; } @@ -413,6 +417,7 @@ sysmon_fini(void) error = EBUSY; else { + pmf_device_deregister(sysmon_dev); config_detach(sysmon_dev, 0); devsw_detach(NULL, sysmon_cdevsw); config_cfattach_detach(sysmon_cd.cd_name, sysmon_ca);
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: christos Date: Sat Apr 25 14:06:58 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c Log Message: make things boot again, from martin. To generate a diff of this commit: cvs rdiff -u -r1.135 -r1.136 src/sys/dev/sysmon/sysmon_envsys.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: christos Date: Sat Apr 25 14:06:58 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c Log Message: make things boot again, from martin. To generate a diff of this commit: cvs rdiff -u -r1.135 -r1.136 src/sys/dev/sysmon/sysmon_envsys.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon_envsys.c diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.135 src/sys/dev/sysmon/sysmon_envsys.c:1.136 --- src/sys/dev/sysmon/sysmon_envsys.c:1.135 Fri Apr 24 22:41:42 2015 +++ src/sys/dev/sysmon/sysmon_envsys.c Sat Apr 25 10:06:58 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_envsys.c,v 1.135 2015/04/25 02:41:42 pgoyette Exp $ */ +/* $NetBSD: sysmon_envsys.c,v 1.136 2015/04/25 14:06:58 christos 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.135 2015/04/25 02:41:42 pgoyette Exp $); +__KERNEL_RCSID(0, $NetBSD: sysmon_envsys.c,v 1.136 2015/04/25 14:06:58 christos Exp $); #include sys/param.h #include sys/types.h @@ -109,6 +109,20 @@ static struct sysmon_opvec sysmon_envsys NULL, NULL, NULL }; +static void +sme_preinit(void) +{ + static bool passed = false; + + if (passed) + return; + + passed = true; + LIST_INIT(sysmon_envsys_list); + mutex_init(sme_global_mtx, MUTEX_DEFAULT, IPL_NONE); + sme_propd = prop_dictionary_create(); +} + /* * sysmon_envsys_init: * @@ -119,9 +133,7 @@ sysmon_envsys_init(void) { int error; - LIST_INIT(sysmon_envsys_list); - mutex_init(sme_global_mtx, MUTEX_DEFAULT, IPL_NONE); - sme_propd = prop_dictionary_create(); + sme_preinit(); error = sysmon_attach_minor(SYSMON_MINOR_ENVSYS, sysmon_envsys_opvec); @@ -141,6 +153,8 @@ sysmon_envsys_fini(void) if (error == 0) mutex_destroy(sme_global_mtx); + // XXX: prop_dictionary ??? + return error; } @@ -680,6 +694,8 @@ sysmon_envsys_register(struct sysmon_env KASSERT(sme != NULL); KASSERT(sme-sme_name != NULL); + sme_preinit(); + /* * Check if requested sysmon_envsys device is valid * and does not exist already in the list.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Fri Apr 24 11:34:14 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c Log Message: The sysmon_envsys module also depends on sysmon_power (for delivery of sensor events to userland). To generate a diff of this commit: cvs rdiff -u -r1.132 -r1.133 src/sys/dev/sysmon/sysmon_envsys.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon_envsys.c diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.132 src/sys/dev/sysmon/sysmon_envsys.c:1.133 --- src/sys/dev/sysmon/sysmon_envsys.c:1.132 Fri Apr 24 03:32:25 2015 +++ src/sys/dev/sysmon/sysmon_envsys.c Fri Apr 24 11:34:14 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_envsys.c,v 1.132 2015/04/24 03:32:25 pgoyette Exp $ */ +/* $NetBSD: sysmon_envsys.c,v 1.133 2015/04/24 11:34:14 pgoyette 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.132 2015/04/24 03:32:25 pgoyette Exp $); +__KERNEL_RCSID(0, $NetBSD: sysmon_envsys.c,v 1.133 2015/04/24 11:34:14 pgoyette Exp $); #include sys/param.h #include sys/types.h @@ -102,7 +102,7 @@ static void sme_initial_refresh(void *); static uint32_t sme_get_max_value(struct sysmon_envsys *, bool (*)(const envsys_data_t*), bool); -MODULE(MODULE_CLASS_MISC, sysmon_envsys, sysmon,sysmon_taskq); +MODULE(MODULE_CLASS_MISC, sysmon_envsys, sysmon,sysmon_taskq,sysmon_power); static struct sysmon_opvec sysmon_envsys_opvec = { sysmonopen_envsys, sysmonclose_envsys, sysmonioctl_envsys,
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Fri Apr 24 11:34:14 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c Log Message: The sysmon_envsys module also depends on sysmon_power (for delivery of sensor events to userland). To generate a diff of this commit: cvs rdiff -u -r1.132 -r1.133 src/sys/dev/sysmon/sysmon_envsys.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Sat Apr 25 00:54:14 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c Log Message: Release the mutex in the error path. To generate a diff of this commit: cvs rdiff -u -r1.133 -r1.134 src/sys/dev/sysmon/sysmon_envsys.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon_envsys.c diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.133 src/sys/dev/sysmon/sysmon_envsys.c:1.134 --- src/sys/dev/sysmon/sysmon_envsys.c:1.133 Fri Apr 24 11:34:14 2015 +++ src/sys/dev/sysmon/sysmon_envsys.c Sat Apr 25 00:54:14 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_envsys.c,v 1.133 2015/04/24 11:34:14 pgoyette Exp $ */ +/* $NetBSD: sysmon_envsys.c,v 1.134 2015/04/25 00:54:14 pgoyette 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.133 2015/04/24 11:34:14 pgoyette Exp $); +__KERNEL_RCSID(0, $NetBSD: sysmon_envsys.c,v 1.134 2015/04/25 00:54:14 pgoyette Exp $); #include sys/param.h #include sys/types.h @@ -779,6 +779,7 @@ sysmon_envsys_register(struct sysmon_env mutex_enter(sme_global_mtx); if (!prop_dictionary_set(sme_propd, sme-sme_name, array)) { error = EINVAL; + mutex_exit(sme_global_mtx); DPRINTF((%s: prop_dictionary_set for '%s'\n, __func__, sme-sme_name)); goto out;
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Sat Apr 25 00:54:14 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c Log Message: Release the mutex in the error path. To generate a diff of this commit: cvs rdiff -u -r1.133 -r1.134 src/sys/dev/sysmon/sysmon_envsys.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Sat Apr 25 02:41:42 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c Log Message: Use tabs for indentation. To generate a diff of this commit: cvs rdiff -u -r1.134 -r1.135 src/sys/dev/sysmon/sysmon_envsys.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon_envsys.c diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.134 src/sys/dev/sysmon/sysmon_envsys.c:1.135 --- src/sys/dev/sysmon/sysmon_envsys.c:1.134 Sat Apr 25 00:54:14 2015 +++ src/sys/dev/sysmon/sysmon_envsys.c Sat Apr 25 02:41:42 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_envsys.c,v 1.134 2015/04/25 00:54:14 pgoyette Exp $ */ +/* $NetBSD: sysmon_envsys.c,v 1.135 2015/04/25 02:41:42 pgoyette 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.134 2015/04/25 00:54:14 pgoyette Exp $); +__KERNEL_RCSID(0, $NetBSD: sysmon_envsys.c,v 1.135 2015/04/25 02:41:42 pgoyette Exp $); #include sys/param.h #include sys/types.h @@ -687,8 +687,8 @@ sysmon_envsys_register(struct sysmon_env mutex_enter(sme_global_mtx); LIST_FOREACH(lsme, sysmon_envsys_list, sme_list) { if (strcmp(lsme-sme_name, sme-sme_name) == 0) { - mutex_exit(sme_global_mtx); - return EEXIST; + mutex_exit(sme_global_mtx); + return EEXIST; } } mutex_exit(sme_global_mtx);
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Sat Apr 25 02:41:42 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c Log Message: Use tabs for indentation. To generate a diff of this commit: cvs rdiff -u -r1.134 -r1.135 src/sys/dev/sysmon/sysmon_envsys.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: christos Date: Fri Apr 24 19:49:24 UTC 2015 Modified Files: src/sys/dev/sysmon: swwdog.c Log Message: We only need the _cd when we are a module. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/dev/sysmon/swwdog.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/swwdog.c diff -u src/sys/dev/sysmon/swwdog.c:1.16 src/sys/dev/sysmon/swwdog.c:1.17 --- src/sys/dev/sysmon/swwdog.c:1.16 Thu Apr 23 19:23:01 2015 +++ src/sys/dev/sysmon/swwdog.c Fri Apr 24 15:49:24 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: swwdog.c,v 1.16 2015/04/23 23:23:01 pgoyette Exp $ */ +/* $NetBSD: swwdog.c,v 1.17 2015/04/24 19:49:24 christos Exp $ */ /* * Copyright (c) 2004, 2005 Steven M. Bellovin @@ -33,7 +33,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: swwdog.c,v 1.16 2015/04/23 23:23:01 pgoyette Exp $); +__KERNEL_RCSID(0, $NetBSD: swwdog.c,v 1.17 2015/04/24 19:49:24 christos Exp $); /* * @@ -71,7 +71,9 @@ static device_t swwdog_dev; MODULE(MODULE_CLASS_DRIVER, swwdog, sysmon_wdog); +#ifdef _MODULE CFDRIVER_DECL(swwdog, DV_DULL, NULL); +#endif int swwdogattach(int);
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: christos Date: Fri Apr 24 19:49:24 UTC 2015 Modified Files: src/sys/dev/sysmon: swwdog.c Log Message: We only need the _cd when we are a module. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/dev/sysmon/swwdog.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Fri Apr 24 03:32:25 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c Log Message: Remove a left-over debugging printf() To generate a diff of this commit: cvs rdiff -u -r1.131 -r1.132 src/sys/dev/sysmon/sysmon_envsys.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Fri Apr 24 03:33:43 UTC 2015 Modified Files: src/sys/dev/sysmon: files.sysmon Log Message: Update configuration definitions for new sysmon To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/dev/sysmon/files.sysmon Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/files.sysmon diff -u src/sys/dev/sysmon/files.sysmon:1.14 src/sys/dev/sysmon/files.sysmon:1.15 --- src/sys/dev/sysmon/files.sysmon:1.14 Thu Sep 6 12:10:28 2012 +++ src/sys/dev/sysmon/files.sysmon Fri Apr 24 03:33:43 2015 @@ -1,24 +1,24 @@ -# $NetBSD: files.sysmon,v 1.14 2012/09/06 12:10:28 macallan Exp $ +# $NetBSD: files.sysmon,v 1.15 2015/04/24 03:33:43 pgoyette Exp $ define sysmon_taskq file dev/sysmon/sysmon_taskq.c sysmon_taskq needs-flag -define sysmon_power +define sysmon +file dev/sysmon/sysmon.c sysmon + +define sysmon_power: sysmon file dev/sysmon/sysmon_power.c sysmon_power needs-flag -define sysmon_envsys: sysmon_power, sysmon_taskq +define sysmon_envsys: sysmon, sysmon_power, sysmon_taskq file dev/sysmon/sysmon_envsys.c sysmon_envsys needs-flag file dev/sysmon/sysmon_envsys_events.c sysmon_envsys file dev/sysmon/sysmon_envsys_tables.c sysmon_envsys file dev/sysmon/sysmon_envsys_util.c sysmon_envsys defflag opt_envsys.h ENVSYS_DEBUG ENVSYS_OBJECTS_DEBUG -define sysmon_wdog +define sysmon_wdog: sysmon file dev/sysmon/sysmon_wdog.c sysmon_wdog needs-flag -file dev/sysmon/sysmon.c sysmon_envsys | sysmon_wdog | - sysmon_power - defpseudodev swwdog: sysmon_wdog file dev/sysmon/swwdog.c swwdog
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Fri Apr 24 03:33:43 UTC 2015 Modified Files: src/sys/dev/sysmon: files.sysmon Log Message: Update configuration definitions for new sysmon To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/dev/sysmon/files.sysmon Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Fri Apr 24 03:32:25 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_envsys.c Log Message: Remove a left-over debugging printf() To generate a diff of this commit: cvs rdiff -u -r1.131 -r1.132 src/sys/dev/sysmon/sysmon_envsys.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon_envsys.c diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.131 src/sys/dev/sysmon/sysmon_envsys.c:1.132 --- src/sys/dev/sysmon/sysmon_envsys.c:1.131 Thu Apr 23 23:22:03 2015 +++ src/sys/dev/sysmon/sysmon_envsys.c Fri Apr 24 03:32:25 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_envsys.c,v 1.131 2015/04/23 23:22:03 pgoyette Exp $ */ +/* $NetBSD: sysmon_envsys.c,v 1.132 2015/04/24 03:32:25 pgoyette 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.131 2015/04/23 23:22:03 pgoyette Exp $); +__KERNEL_RCSID(0, $NetBSD: sysmon_envsys.c,v 1.132 2015/04/24 03:32:25 pgoyette Exp $); #include sys/param.h #include sys/types.h @@ -877,7 +877,6 @@ out2: SLIST_REMOVE_HEAD(sme_evdrv_list, evdrv_head); kmem_free(evdv, sizeof(*evdv)); } -printf(%s: finished, error %d\n, __func__, error); if (!error) return 0;
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Fri Apr 24 03:35:49 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon.c Log Message: With new (corrected) configuration declarations file, the cdevsw is already included by config. So, for built-in sysmon module we don't need to add the cdevsw to the table. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/dev/sysmon/sysmon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon.c diff -u src/sys/dev/sysmon/sysmon.c:1.20 src/sys/dev/sysmon/sysmon.c:1.21 --- src/sys/dev/sysmon/sysmon.c:1.20 Thu Apr 23 23:22:03 2015 +++ src/sys/dev/sysmon/sysmon.c Fri Apr 24 03:35:49 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon.c,v 1.20 2015/04/23 23:22:03 pgoyette Exp $ */ +/* $NetBSD: sysmon.c,v 1.21 2015/04/24 03:35:49 pgoyette Exp $ */ /*- * Copyright (c) 2000 Zembu Labs, Inc. @@ -39,7 +39,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: sysmon.c,v 1.20 2015/04/23 23:22:03 pgoyette Exp $); +__KERNEL_RCSID(0, $NetBSD: sysmon.c,v 1.21 2015/04/24 03:35:49 pgoyette Exp $); #include sys/param.h #include sys/conf.h @@ -345,7 +345,9 @@ MODULE(MODULE_CLASS_DRIVER, sysmon, ); int sysmon_init(void) { +#ifdef _MODULE devmajor_t bmajor, cmajor; +#endif static struct cfdata cf; int error = 0; @@ -367,6 +369,7 @@ sysmon_init(void) return error; } +#ifdef _MODULE bmajor = cmajor = -1; error = devsw_attach(sysmon, NULL, bmajor, sysmon_cdevsw, cmajor); @@ -377,6 +380,7 @@ sysmon_init(void) sysmon_cd.cd_name); return error; } +#endif cf.cf_name = sysmon_cd.cd_name; cf.cf_atname = sysmon_cd.cd_name;
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Fri Apr 24 03:35:49 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon.c Log Message: With new (corrected) configuration declarations file, the cdevsw is already included by config. So, for built-in sysmon module we don't need to add the cdevsw to the table. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/dev/sysmon/sysmon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Thu Apr 23 23:22:03 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon.c sysmon_envsys.c sysmon_power.c sysmon_taskq.c sysmon_wdog.c sysmonvar.h Removed Files: src/sys/dev/sysmon: sysmonconf.h Log Message: Modularize sysmon and its components To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/dev/sysmon/sysmon.c cvs rdiff -u -r1.130 -r1.131 src/sys/dev/sysmon/sysmon_envsys.c cvs rdiff -u -r1.53 -r1.54 src/sys/dev/sysmon/sysmon_power.c cvs rdiff -u -r1.14 -r1.15 src/sys/dev/sysmon/sysmon_taskq.c cvs rdiff -u -r1.25 -r1.26 src/sys/dev/sysmon/sysmon_wdog.c cvs rdiff -u -r1.3 -r0 src/sys/dev/sysmon/sysmonconf.h cvs rdiff -u -r1.48 -r1.49 src/sys/dev/sysmon/sysmonvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/sysmon/sysmon.c diff -u src/sys/dev/sysmon/sysmon.c:1.19 src/sys/dev/sysmon/sysmon.c:1.20 --- src/sys/dev/sysmon/sysmon.c:1.19 Fri Jul 25 08:10:39 2014 +++ src/sys/dev/sysmon/sysmon.c Thu Apr 23 23:22:03 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon.c,v 1.19 2014/07/25 08:10:39 dholland Exp $ */ +/* $NetBSD: sysmon.c,v 1.20 2015/04/23 23:22:03 pgoyette Exp $ */ /*- * Copyright (c) 2000 Zembu Labs, Inc. @@ -39,7 +39,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: sysmon.c,v 1.19 2014/07/25 08:10:39 dholland Exp $); +__KERNEL_RCSID(0, $NetBSD: sysmon.c,v 1.20 2015/04/23 23:22:03 pgoyette Exp $); #include sys/param.h #include sys/conf.h @@ -49,9 +49,11 @@ __KERNEL_RCSID(0, $NetBSD: sysmon.c,v 1 #include sys/kernel.h #include sys/systm.h #include sys/proc.h +#include sys/module.h +#include sys/mutex.h +#include sys/device.h #include dev/sysmon/sysmonvar.h -#include dev/sysmon/sysmonconf.h dev_type_open(sysmonopen); dev_type_close(sysmonclose); @@ -75,6 +77,97 @@ const struct cdevsw sysmon_cdevsw = { .d_flag = D_OTHER | D_MPSAFE }; +static int sysmon_match(device_t, cfdata_t, void *); +static void sysmon_attach(device_t, device_t, void *); +static int sysmon_detach(device_t, int); + +static int sysmon_modcmd(modcmd_t, void *); + +CFDRIVER_DECL(sysmon, DV_DULL, NULL); + +/* + * Info about our minor devices + */ +static struct sysmon_opvec *sysmon_opvec_table[] = { NULL, NULL, NULL }; +static int sysmon_refcnt[] = { 0, 0, 0 }; +static const char *sysmon_mod[] = { sysmon_envsys, + sysmon_wdog, + sysmon_power }; + +struct sysmon_softc { + device_t sc_dev; + kmutex_t sc_minor_mtx; +}; + +static device_t sysmon_dev = NULL; + +CFATTACH_DECL_NEW(sysmon, sizeof(struct sysmon_softc), +sysmon_match, sysmon_attach, sysmon_detach, NULL); +extern struct cfdriver sysmon_cd; + +static int +sysmon_match(device_t parent, cfdata_t data, void *aux) +{ + + return 1; +} + +static void +sysmon_attach(device_t parent, device_t self, void *aux) +{ + +struct sysmon_softc *sc = device_private(self); + +sc-sc_dev = self; + + mutex_init(sc-sc_minor_mtx, MUTEX_DEFAULT, IPL_NONE); +} + +static int +sysmon_detach(device_t self, int flags) +{ +struct sysmon_softc *sc = device_private(self); + + mutex_destroy(sc-sc_minor_mtx); + return 0; +} + +/* + * sysmon_attach_minor + * + * Attach a minor device for wdog, power, or envsys. Manage a + * reference count so we can prevent the device from being + * detached if there are still users with the minor device opened. + * + * If the opvec argument is NULL, this is a request to detach the + * minor device - make sure the refcnt is zero! + */ +int +sysmon_attach_minor(int minor, struct sysmon_opvec *opvec) +{ + struct sysmon_softc *sc = device_private(sysmon_dev); + int ret; + + mutex_enter(sc-sc_minor_mtx); + if (opvec) { + if (sysmon_opvec_table[minor] == NULL) { + sysmon_refcnt[minor] = 0; + sysmon_opvec_table[minor] = opvec; + ret = 0; + } else + ret = EEXIST; + } else { + if (sysmon_refcnt[minor] == 0) { + sysmon_opvec_table[minor] = NULL; + ret = 0; + } else + ret = EBUSY; + } + + mutex_exit(sc-sc_minor_mtx); + return ret; +} + /* * sysmonopen: * @@ -83,28 +176,33 @@ const struct cdevsw sysmon_cdevsw = { int sysmonopen(dev_t dev, int flag, int mode, struct lwp *l) { + struct sysmon_softc *sc = device_private(sysmon_dev); int error; + mutex_enter(sc-sc_minor_mtx); + switch (minor(dev)) { -#if NSYSMON_ENVSYS 0 case SYSMON_MINOR_ENVSYS: - error = sysmonopen_envsys(dev, flag, mode, l); - break; -#endif -#if NSYSMON_WDOG 0 case SYSMON_MINOR_WDOG: - error = sysmonopen_wdog(dev, flag, mode, l); - break; -#endif -#if NSYSMON_POWER 0 case SYSMON_MINOR_POWER: - error = sysmonopen_power(dev, flag, mode, l); + if (sysmon_opvec_table[minor(dev)] == NULL) { + mutex_exit(sc-sc_minor_mtx); + error = module_autoload(sysmon_mod[minor(dev)], + MODULE_CLASS_MISC); + mutex_enter(sc-sc_minor_mtx); + if (sysmon_opvec_table[minor(dev)]
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: pgoyette Date: Thu Apr 23 23:22:03 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon.c sysmon_envsys.c sysmon_power.c sysmon_taskq.c sysmon_wdog.c sysmonvar.h Removed Files: src/sys/dev/sysmon: sysmonconf.h Log Message: Modularize sysmon and its components To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/dev/sysmon/sysmon.c cvs rdiff -u -r1.130 -r1.131 src/sys/dev/sysmon/sysmon_envsys.c cvs rdiff -u -r1.53 -r1.54 src/sys/dev/sysmon/sysmon_power.c cvs rdiff -u -r1.14 -r1.15 src/sys/dev/sysmon/sysmon_taskq.c cvs rdiff -u -r1.25 -r1.26 src/sys/dev/sysmon/sysmon_wdog.c cvs rdiff -u -r1.3 -r0 src/sys/dev/sysmon/sysmonconf.h cvs rdiff -u -r1.48 -r1.49 src/sys/dev/sysmon/sysmonvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/sysmon
Module Name:src Committed By: agc Date: Fri Apr 24 00:04:47 UTC 2015 Modified Files: src/sys/dev/sysmon: sysmon_taskq.c Log Message: It's a function returning void; don't return an error code. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/dev/sysmon/sysmon_taskq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.