Module Name:    src
Committed By:   riastradh
Date:           Wed Dec  4 15:25:12 UTC 2024

Modified Files:
        src/sys/dev: ipmi.c ipmivar.h

Log Message:
ipmi(4): Omit needless condvar/mutex for sleep.

Just use kpause instead.

Cleanup in preparation for:

PR kern/58869: ipmi(4) holds sc_cmd_mtx across copyout, needed for
wdog tickle


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/ipmi.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ipmivar.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/ipmi.c
diff -u src/sys/dev/ipmi.c:1.12 src/sys/dev/ipmi.c:1.13
--- src/sys/dev/ipmi.c:1.12	Tue Dec  3 22:11:38 2024
+++ src/sys/dev/ipmi.c	Wed Dec  4 15:25:12 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipmi.c,v 1.12 2024/12/03 22:11:38 riastradh Exp $ */
+/*	$NetBSD: ipmi.c,v 1.13 2024/12/04 15:25:12 riastradh Exp $ */
 
 /*
  * Copyright (c) 2019 Michael van Elst
@@ -76,7 +76,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.12 2024/12/03 22:11:38 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.13 2024/12/04 15:25:12 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -355,9 +355,7 @@ bmc_io_wait_sleep(struct ipmi_softc *sc,
 		v = bmc_read(sc, offset);
 		if ((v & mask) == value)
 			return v;
-		mutex_enter(&sc->sc_sleep_mtx);
-		cv_timedwait(&sc->sc_cmd_sleep, &sc->sc_sleep_mtx, 1);
-		mutex_exit(&sc->sc_sleep_mtx);
+		kpause("ipmicmd", /*intr*/false, /*timo*/1, /*mtx*/NULL);
 	}
 	return -1;
 }
@@ -1096,9 +1094,7 @@ ipmi_delay(struct ipmi_softc *sc, int ms
 		delay(ms * 1000);
 		return;
 	}
-	mutex_enter(&sc->sc_sleep_mtx);
-	cv_timedwait(&sc->sc_cmd_sleep, &sc->sc_sleep_mtx, mstohz(ms));
-	mutex_exit(&sc->sc_sleep_mtx);
+	kpause("ipmicmd", /*intr*/false, /*timo*/mstohz(ms), /*mtx*/NULL);
 }
 
 /* Read a partial SDR entry */
@@ -1982,12 +1978,10 @@ ipmi_match(device_t parent, cfdata_t cf,
 	sc.sc_if->probe(&sc);
 
 	mutex_init(&sc.sc_cmd_mtx, MUTEX_DEFAULT, IPL_SOFTCLOCK);
-	cv_init(&sc.sc_cmd_sleep, "ipmimtch");
 
 	if (ipmi_get_device_id(&sc, NULL) == 0)
 		rv = 1;
 
-	cv_destroy(&sc.sc_cmd_sleep);
 	mutex_destroy(&sc.sc_cmd_mtx);
 	ipmi_unmap_regs(&sc);
 
@@ -2165,8 +2159,6 @@ ipmi_attach(device_t parent, device_t se
 
 	/* lock around read_sensor so that no one messes with the bmc regs */
 	mutex_init(&sc->sc_cmd_mtx, MUTEX_DEFAULT, IPL_SOFTCLOCK);
-	mutex_init(&sc->sc_sleep_mtx, MUTEX_DEFAULT, IPL_SOFTCLOCK);
-	cv_init(&sc->sc_cmd_sleep, "ipmicmd");
 
 	mutex_init(&sc->sc_poll_mtx, MUTEX_DEFAULT, IPL_SOFTCLOCK);
 	cv_init(&sc->sc_poll_cv, "ipmipoll");
@@ -2230,8 +2222,6 @@ ipmi_detach(device_t self, int flags)
 	cv_destroy(&sc->sc_mode_cv);
 	cv_destroy(&sc->sc_poll_cv);
 	mutex_destroy(&sc->sc_poll_mtx);
-	cv_destroy(&sc->sc_cmd_sleep);
-	mutex_destroy(&sc->sc_sleep_mtx);
 	mutex_destroy(&sc->sc_cmd_mtx);
 
 	return 0;

Index: src/sys/dev/ipmivar.h
diff -u src/sys/dev/ipmivar.h:1.4 src/sys/dev/ipmivar.h:1.5
--- src/sys/dev/ipmivar.h:1.4	Tue Dec  3 19:55:33 2024
+++ src/sys/dev/ipmivar.h	Wed Dec  4 15:25:12 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: ipmivar.h,v 1.4 2024/12/03 19:55:33 riastradh Exp $ */
+/* $NetBSD: ipmivar.h,v 1.5 2024/12/04 15:25:12 riastradh Exp $ */
 
 /*
  * Copyright (c) 2005 Jordan Hargrave
@@ -95,8 +95,6 @@ struct ipmi_softc {
 	kcondvar_t		sc_mode_cv;
 
 	kmutex_t		sc_cmd_mtx;
-	kmutex_t		sc_sleep_mtx;
-	kcondvar_t		sc_cmd_sleep;
 
 	struct ipmi_bmc_args	*sc_iowait_args;
 

Reply via email to