git: 3e68d2c52b4e - main - acpica: Remove CTLFLAG_NEEDGIANT from most sysctls.

From: Alexander Motin <mav_at_FreeBSD.org>
Date: Mon, 27 Dec 2021 00:18:59 UTC
The branch main has been updated by mav:

URL: https://cgit.FreeBSD.org/src/commit/?id=3e68d2c52b4e4b0aafce2c7f6bcb8f063c6a8d55

commit 3e68d2c52b4e4b0aafce2c7f6bcb8f063c6a8d55
Author:     Alexander Motin <mav@FreeBSD.org>
AuthorDate: 2021-12-27 00:17:52 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2021-12-27 00:18:55 +0000

    acpica: Remove CTLFLAG_NEEDGIANT from most sysctls.
    
    MFC after:      2 weeks
---
 sys/dev/acpica/acpi.c         |  18 +++----
 sys/dev/acpica/acpi_acad.c    |  15 +++---
 sys/dev/acpica/acpi_cpu.c     | 108 +++++++++++++++++++-----------------------
 sys/dev/acpica/acpi_dock.c    |   2 +-
 sys/dev/acpica/acpi_thermal.c |  20 ++++----
 sys/dev/acpica/acpi_timer.c   |   2 +-
 sys/dev/acpica/acpi_video.c   |  10 ++--
 7 files changed, 81 insertions(+), 94 deletions(-)

diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index 7066116f19a4..0d03fa063988 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -281,7 +281,7 @@ TUNABLE_STR("hw.acpi.remove_interface", acpi_remove_interface,
 static int acpi_debug_objects;
 TUNABLE_INT("debug.acpi.enable_debug_objects", &acpi_debug_objects);
 SYSCTL_PROC(_debug_acpi, OID_AUTO, enable_debug_objects,
-    CTLFLAG_RW | CTLTYPE_INT | CTLFLAG_NEEDGIANT, NULL, 0,
+    CTLFLAG_RW | CTLTYPE_INT | CTLFLAG_MPSAFE, NULL, 0,
     acpi_debug_objects_sysctl, "I",
     "Enable Debug objects");
 
@@ -576,31 +576,31 @@ acpi_attach(device_t dev)
 	CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "");
     SYSCTL_ADD_PROC(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree),
 	OID_AUTO, "supported_sleep_state",
-	CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT,
+	CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
 	0, 0, acpi_supported_sleep_state_sysctl, "A",
 	"List supported ACPI sleep states.");
     SYSCTL_ADD_PROC(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree),
 	OID_AUTO, "power_button_state",
-	CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
+	CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE,
 	&sc->acpi_power_button_sx, 0, acpi_sleep_state_sysctl, "A",
 	"Power button ACPI sleep state.");
     SYSCTL_ADD_PROC(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree),
 	OID_AUTO, "sleep_button_state",
-	CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
+	CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE,
 	&sc->acpi_sleep_button_sx, 0, acpi_sleep_state_sysctl, "A",
 	"Sleep button ACPI sleep state.");
     SYSCTL_ADD_PROC(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree),
 	OID_AUTO, "lid_switch_state",
-	CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
+	CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE,
 	&sc->acpi_lid_switch_sx, 0, acpi_sleep_state_sysctl, "A",
 	"Lid ACPI sleep state. Set to S3 if you want to suspend your laptop when close the Lid.");
     SYSCTL_ADD_PROC(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree),
 	OID_AUTO, "standby_state",
-	CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
+	CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE,
 	&sc->acpi_standby_sx, 0, acpi_sleep_state_sysctl, "A", "");
     SYSCTL_ADD_PROC(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree),
 	OID_AUTO, "suspend_state",
-	CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
+	CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE,
 	&sc->acpi_suspend_sx, 0, acpi_sleep_state_sysctl, "A", "");
     SYSCTL_ADD_INT(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree),
 	OID_AUTO, "sleep_delay", CTLFLAG_RW, &sc->acpi_sleep_delay, 0,
@@ -4329,11 +4329,11 @@ acpi_debug_sysctl(SYSCTL_HANDLER_ARGS)
 }
 
 SYSCTL_PROC(_debug_acpi, OID_AUTO, layer,
-    CTLFLAG_RW | CTLTYPE_STRING | CTLFLAG_NEEDGIANT, "debug.acpi.layer", 0,
+    CTLFLAG_RW | CTLTYPE_STRING | CTLFLAG_MPSAFE, "debug.acpi.layer", 0,
     acpi_debug_sysctl, "A",
     "");
 SYSCTL_PROC(_debug_acpi, OID_AUTO, level,
-    CTLFLAG_RW | CTLTYPE_STRING | CTLFLAG_NEEDGIANT, "debug.acpi.level", 0,
+    CTLFLAG_RW | CTLTYPE_STRING | CTLFLAG_MPSAFE, "debug.acpi.level", 0,
     acpi_debug_sysctl, "A",
     "");
 #endif /* ACPI_DEBUG */
diff --git a/sys/dev/acpica/acpi_acad.c b/sys/dev/acpica/acpi_acad.c
index 7f4d025b55f4..ac7ff1315734 100644
--- a/sys/dev/acpica/acpi_acad.c
+++ b/sys/dev/acpica/acpi_acad.c
@@ -173,7 +173,7 @@ acpi_acad_attach(device_t dev)
 	acpi_sc = acpi_device_get_parent_softc(dev);
 	SYSCTL_ADD_PROC(&acpi_sc->acpi_sysctl_ctx,
 	    SYSCTL_CHILDREN(acpi_sc->acpi_sysctl_tree), OID_AUTO, "acline",
-	    CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, &sc->status, 0,
+	    CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, dev, 0,
 	    acpi_acad_sysctl, "I", "");
     }
 
@@ -219,14 +219,13 @@ acpi_acad_ioctl(u_long cmd, caddr_t addr, void *arg)
 static int
 acpi_acad_sysctl(SYSCTL_HANDLER_ARGS)
 {
-    int val, error;
+    device_t dev = oidp->oid_arg1;
+    struct acpi_acad_softc *sc = device_get_softc(dev);
+    int val;
 
-    if (acpi_acad_get_acline(&val) != 0)
-	return (ENXIO);
-
-    val = *(u_int *)oidp->oid_arg1;
-    error = sysctl_handle_int(oidp, &val, 0, req);
-    return (error);
+    acpi_acad_get_status(dev);
+    val = sc->status;
+    return (sysctl_handle_int(oidp, &val, 0, req));
 }
 
 static void
diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c
index b1520368756f..9530b8867536 100644
--- a/sys/dev/acpica/acpi_cpu.c
+++ b/sys/dev/acpica/acpi_cpu.c
@@ -973,7 +973,7 @@ acpi_cpu_startup(void *arg)
 
     /* Add a sysctl handler to handle global Cx lowest setting */
     SYSCTL_ADD_PROC(&cpu_sysctl_ctx, SYSCTL_CHILDREN(cpu_sysctl_tree),
-	OID_AUTO, "cx_lowest", CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
+	OID_AUTO, "cx_lowest", CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE,
 	NULL, 0, acpi_cpu_global_cx_lowest_sysctl, "A",
 	"Global lowest Cx sleep state to use");
 
@@ -1018,23 +1018,23 @@ acpi_cpu_startup_cx(struct acpi_cpu_softc *sc)
 		      "Cx/microsecond values for supported Cx states");
     SYSCTL_ADD_PROC(&sc->cpu_sysctl_ctx,
         SYSCTL_CHILDREN(device_get_sysctl_tree(sc->cpu_dev)), OID_AUTO,
-	"cx_lowest", CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
+	"cx_lowest", CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE,
 	(void *)sc, 0, acpi_cpu_cx_lowest_sysctl, "A",
 	"lowest Cx sleep state to use");
     SYSCTL_ADD_PROC(&sc->cpu_sysctl_ctx,
         SYSCTL_CHILDREN(device_get_sysctl_tree(sc->cpu_dev)), OID_AUTO,
-	"cx_usage", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT,
+	"cx_usage", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
 	(void *)sc, 0, acpi_cpu_usage_sysctl, "A",
 	"percent usage for each Cx state");
     SYSCTL_ADD_PROC(&sc->cpu_sysctl_ctx,
         SYSCTL_CHILDREN(device_get_sysctl_tree(sc->cpu_dev)), OID_AUTO,
-	"cx_usage_counters", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT,
+	"cx_usage_counters", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
 	(void *)sc, 0, acpi_cpu_usage_counters_sysctl, "A",
 	"Cx sleep state counters");
 #if defined(__i386__) || defined(__amd64__)
     SYSCTL_ADD_PROC(&sc->cpu_sysctl_ctx,
         SYSCTL_CHILDREN(device_get_sysctl_tree(sc->cpu_dev)), OID_AUTO,
-	"cx_method", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT,
+	"cx_method", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
 	(void *)sc, 0, acpi_cpu_method_sysctl, "A", "Cx entrance methods");
 #endif
 
@@ -1339,33 +1339,29 @@ acpi_cpu_quirks_piix4(void)
 static int
 acpi_cpu_usage_sysctl(SYSCTL_HANDLER_ARGS)
 {
-    struct acpi_cpu_softc *sc;
-    struct sbuf	 sb;
-    char	 buf[128];
-    int		 i;
-    uintmax_t	 fract, sum, whole;
-
-    sc = (struct acpi_cpu_softc *) arg1;
-    sum = 0;
-    for (i = 0; i < sc->cpu_cx_count; i++)
-	sum += sc->cpu_cx_stats[i];
-    sbuf_new(&sb, buf, sizeof(buf), SBUF_FIXEDLEN);
-    for (i = 0; i < sc->cpu_cx_count; i++) {
-	if (sum > 0) {
-	    whole = (uintmax_t)sc->cpu_cx_stats[i] * 100;
-	    fract = (whole % sum) * 100;
-	    sbuf_printf(&sb, "%u.%02u%% ", (u_int)(whole / sum),
-		(u_int)(fract / sum));
-	} else
-	    sbuf_printf(&sb, "0.00%% ");
-    }
-    sbuf_printf(&sb, "last %dus", sc->cpu_prev_sleep);
-    sbuf_trim(&sb);
-    sbuf_finish(&sb);
-    sysctl_handle_string(oidp, sbuf_data(&sb), sbuf_len(&sb), req);
-    sbuf_delete(&sb);
-
-    return (0);
+	struct acpi_cpu_softc *sc = (struct acpi_cpu_softc *)arg1;
+	struct sbuf	 sb;
+	char		 buf[128];
+	int		 error, i;
+	uintmax_t	 fract, sum, whole;
+
+	sbuf_new_for_sysctl(&sb, buf, sizeof(buf), req);
+	sum = 0;
+	for (i = 0; i < sc->cpu_cx_count; i++)
+		sum += sc->cpu_cx_stats[i];
+	for (i = 0; i < sc->cpu_cx_count; i++) {
+		if (sum > 0) {
+			whole = (uintmax_t)sc->cpu_cx_stats[i] * 100;
+			fract = (whole % sum) * 100;
+			sbuf_printf(&sb, "%u.%02u%% ", (u_int)(whole / sum),
+			    (u_int)(fract / sum));
+		} else
+			sbuf_printf(&sb, "0.00%% ");
+	}
+	sbuf_printf(&sb, "last %dus", sc->cpu_prev_sleep);
+	error = sbuf_finish(&sb);
+	sbuf_delete(&sb);
+	return (error);
 }
 
 /*
@@ -1375,42 +1371,37 @@ acpi_cpu_usage_sysctl(SYSCTL_HANDLER_ARGS)
 static int
 acpi_cpu_usage_counters_sysctl(SYSCTL_HANDLER_ARGS)
 {
-    struct acpi_cpu_softc *sc;
-    struct sbuf	 sb;
-    char	 buf[128];
-    int		 i;
-
-    sc = (struct acpi_cpu_softc *) arg1;
-
-    /* Print out the raw counters */
-    sbuf_new(&sb, buf, sizeof(buf), SBUF_FIXEDLEN);
-
-    for (i = 0; i < sc->cpu_cx_count; i++) {
-        sbuf_printf(&sb, "%u ", sc->cpu_cx_stats[i]);
-    }
-
-    sbuf_trim(&sb);
-    sbuf_finish(&sb);
-    sysctl_handle_string(oidp, sbuf_data(&sb), sbuf_len(&sb), req);
-    sbuf_delete(&sb);
+	struct acpi_cpu_softc *sc = (struct acpi_cpu_softc *)arg1;
+	struct sbuf	 sb;
+	char		 buf[128];
+	int		 error, i;
 
-    return (0);
+	sbuf_new_for_sysctl(&sb, buf, sizeof(buf), req);
+	for (i = 0; i < sc->cpu_cx_count; i++) {
+		if (i > 0)
+			sbuf_putc(&sb, ' ');
+		sbuf_printf(&sb, "%u", sc->cpu_cx_stats[i]);
+	}
+	error = sbuf_finish(&sb);
+	sbuf_delete(&sb);
+	return (error);
 }
 
 #if defined(__i386__) || defined(__amd64__)
 static int
 acpi_cpu_method_sysctl(SYSCTL_HANDLER_ARGS)
 {
-	struct acpi_cpu_softc *sc;
+	struct acpi_cpu_softc *sc = (struct acpi_cpu_softc *)arg1;
 	struct acpi_cx *cx;
 	struct sbuf sb;
 	char buf[128];
-	int i;
+	int error, i;
 
-	sc = (struct acpi_cpu_softc *)arg1;
-	sbuf_new(&sb, buf, sizeof(buf), SBUF_FIXEDLEN);
+	sbuf_new_for_sysctl(&sb, buf, sizeof(buf), req);
 	for (i = 0; i < sc->cpu_cx_count; i++) {
 		cx = &sc->cpu_cx_states[i];
+		if (i > 0)
+			sbuf_putc(&sb, ' ');
 		sbuf_printf(&sb, "C%d/", i + 1);
 		if (cx->do_mwait) {
 			sbuf_cat(&sb, "mwait");
@@ -1425,13 +1416,10 @@ acpi_cpu_method_sysctl(SYSCTL_HANDLER_ARGS)
 		}
 		if (cx->type == ACPI_STATE_C1 && cx->p_lvlx != NULL)
 			sbuf_cat(&sb, "/iohlt");
-		sbuf_putc(&sb, ' ');
 	}
-	sbuf_trim(&sb);
-	sbuf_finish(&sb);
-	sysctl_handle_string(oidp, sbuf_data(&sb), sbuf_len(&sb), req);
+	error = sbuf_finish(&sb);
 	sbuf_delete(&sb);
-	return (0);
+	return (error);
 }
 #endif
 
diff --git a/sys/dev/acpica/acpi_dock.c b/sys/dev/acpica/acpi_dock.c
index 5f1991e42649..2b7a451bfe87 100644
--- a/sys/dev/acpica/acpi_dock.c
+++ b/sys/dev/acpica/acpi_dock.c
@@ -517,7 +517,7 @@ acpi_dock_attach(device_t dev)
 	SYSCTL_ADD_PROC(sc->sysctl_ctx,
 		SYSCTL_CHILDREN(sc->sysctl_tree),
 		OID_AUTO, "status",
-		CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, dev, 0,
+		CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, dev, 0,
 		acpi_dock_status_sysctl, "I",
 		"Dock/Undock operation");
 
diff --git a/sys/dev/acpica/acpi_thermal.c b/sys/dev/acpica/acpi_thermal.c
index cd2024be00d5..9ff86ae8d827 100644
--- a/sys/dev/acpica/acpi_thermal.c
+++ b/sys/dev/acpica/acpi_thermal.c
@@ -263,15 +263,15 @@ acpi_tz_attach(device_t dev)
         SYSCTL_CHILDREN(acpi_tz_sysctl_tree), OID_AUTO, oidname,
 	CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "", "thermal_zone");
     SYSCTL_ADD_PROC(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree),
-        OID_AUTO, "temperature", CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_NEEDGIANT,
+        OID_AUTO, "temperature", CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE,
 	&sc->tz_temperature, 0, sysctl_handle_int, "IK",
 	"current thermal zone temperature");
     SYSCTL_ADD_PROC(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree),
-        OID_AUTO, "active", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc,
+        OID_AUTO, "active", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc,
 	0, acpi_tz_active_sysctl, "I", "cooling is active");
     SYSCTL_ADD_PROC(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree),
         OID_AUTO, "passive_cooling",
-	CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0,
+	CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0,
 	acpi_tz_cooling_sysctl, "I",
 	"enable passive (speed reduction) cooling");
 
@@ -279,31 +279,31 @@ acpi_tz_attach(device_t dev)
 		   OID_AUTO, "thermal_flags", CTLFLAG_RD,
 		   &sc->tz_thflags, 0, "thermal zone flags");
     SYSCTL_ADD_PROC(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree),
-        OID_AUTO, "_PSV", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc,
+        OID_AUTO, "_PSV", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc,
 	offsetof(struct acpi_tz_softc, tz_zone.psv), acpi_tz_temp_sysctl, "IK",
 	"passive cooling temp setpoint");
     SYSCTL_ADD_PROC(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree),
-        OID_AUTO, "_HOT", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc,
+        OID_AUTO, "_HOT", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc,
 	offsetof(struct acpi_tz_softc, tz_zone.hot), acpi_tz_temp_sysctl, "IK",
 	"too hot temp setpoint (suspend now)");
     SYSCTL_ADD_PROC(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree),
-        OID_AUTO, "_CRT", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc,
+        OID_AUTO, "_CRT", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc,
 	offsetof(struct acpi_tz_softc, tz_zone.crt), acpi_tz_temp_sysctl, "IK",
 	"critical temp setpoint (shutdown now)");
     SYSCTL_ADD_PROC(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree),
-        OID_AUTO, "_ACx", CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_NEEDGIANT,
+        OID_AUTO, "_ACx", CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE,
 	&sc->tz_zone.ac, sizeof(sc->tz_zone.ac), sysctl_handle_opaque, "IK",
 	"");
     SYSCTL_ADD_PROC(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree),
-        OID_AUTO, "_TC1", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc,
+        OID_AUTO, "_TC1", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc,
 	offsetof(struct acpi_tz_softc, tz_zone.tc1), acpi_tz_passive_sysctl,
 	"I", "thermal constant 1 for passive cooling");
     SYSCTL_ADD_PROC(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree),
-        OID_AUTO, "_TC2", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc,
+        OID_AUTO, "_TC2", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc,
 	offsetof(struct acpi_tz_softc, tz_zone.tc2), acpi_tz_passive_sysctl,
 	"I", "thermal constant 2 for passive cooling");
     SYSCTL_ADD_PROC(&sc->tz_sysctl_ctx, SYSCTL_CHILDREN(sc->tz_sysctl_tree),
-        OID_AUTO, "_TSP", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc,
+        OID_AUTO, "_TSP", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc,
 	offsetof(struct acpi_tz_softc, tz_zone.tsp), acpi_tz_passive_sysctl,
 	"I", "thermal sampling period for passive cooling");
 
diff --git a/sys/dev/acpica/acpi_timer.c b/sys/dev/acpica/acpi_timer.c
index 8e3947709b61..633d5bf52f1d 100644
--- a/sys/dev/acpica/acpi_timer.c
+++ b/sys/dev/acpica/acpi_timer.c
@@ -370,7 +370,7 @@ acpi_timer_sysctl_freq(SYSCTL_HANDLER_ARGS)
 }
 
 SYSCTL_PROC(_machdep, OID_AUTO, acpi_timer_freq,
-    CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, 0, sizeof(u_int),
+    CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0,
     acpi_timer_sysctl_freq, "I",
     "ACPI timer frequency");
 
diff --git a/sys/dev/acpica/acpi_video.c b/sys/dev/acpica/acpi_video.c
index 917c6548f3a2..cbe31d3a66c2 100644
--- a/sys/dev/acpica/acpi_video.c
+++ b/sys/dev/acpica/acpi_video.c
@@ -650,33 +650,33 @@ acpi_video_vo_init(UINT32 adr)
 			SYSCTL_ADD_PROC(&vo->vo_sysctl_ctx,
 			    SYSCTL_CHILDREN(vo->vo_sysctl_tree),
 			    OID_AUTO, "active",
-			    CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, vo,
+			    CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, vo,
 			    0, acpi_video_vo_active_sysctl, "I",
 			    "current activity of this device");
 			SYSCTL_ADD_PROC(&vo->vo_sysctl_ctx,
 			    SYSCTL_CHILDREN(vo->vo_sysctl_tree),
 			    OID_AUTO, "brightness",
-			    CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, vo,
+			    CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, vo,
 			    0, acpi_video_vo_bright_sysctl, "I",
 			    "current brightness level");
 			SYSCTL_ADD_PROC(&vo->vo_sysctl_ctx,
 			    SYSCTL_CHILDREN(vo->vo_sysctl_tree),
 			    OID_AUTO, "fullpower",
-			    CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, vo,
+			    CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, vo,
 			    POWER_PROFILE_PERFORMANCE,
 			    acpi_video_vo_presets_sysctl, "I",
 			    "preset level for full power mode");
 			SYSCTL_ADD_PROC(&vo->vo_sysctl_ctx,
 			    SYSCTL_CHILDREN(vo->vo_sysctl_tree),
 			    OID_AUTO, "economy",
-			    CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, vo,
+			    CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, vo,
 			    POWER_PROFILE_ECONOMY,
 			    acpi_video_vo_presets_sysctl, "I",
 			    "preset level for economy mode");
 			SYSCTL_ADD_PROC(&vo->vo_sysctl_ctx,
 			    SYSCTL_CHILDREN(vo->vo_sysctl_tree),
 			    OID_AUTO, "levels",
-			    CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_NEEDGIANT, vo,
+			    CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, vo,
 			    0, acpi_video_vo_levels_sysctl, "I",
 			    "supported brightness levels");
 		} else