summaryrefslogtreecommitdiffstats
path: root/sys/dev/k8temp
diff options
context:
space:
mode:
authorrpaulo <rpaulo@FreeBSD.org>2008-07-05 23:19:37 +0000
committerrpaulo <rpaulo@FreeBSD.org>2008-07-05 23:19:37 +0000
commite2fdb427337a865303abbafa08d8a0b9002510be (patch)
tree3697da5d89588c192ea2cf2a8d03876ed75198cd /sys/dev/k8temp
parent12adeb8575505af26a6454ba8077cd2b319a818c (diff)
downloadFreeBSD-src-e2fdb427337a865303abbafa08d8a0b9002510be.zip
FreeBSD-src-e2fdb427337a865303abbafa08d8a0b9002510be.tar.gz
Use config_intrhook API to create the dev.cpu.N.temperature sysctl node.
Our hook creates the sysctl node before root is mounted, but after cpu is probed. It seems that k8temp can be loaded before the cpu module and, in those cases, dev.cpu.0.temperature was not created. PR: 124939
Diffstat (limited to 'sys/dev/k8temp')
-rw-r--r--sys/dev/k8temp/k8temp.c62
1 files changed, 42 insertions, 20 deletions
diff --git a/sys/dev/k8temp/k8temp.c b/sys/dev/k8temp/k8temp.c
index c8e5c1f..d489d56 100644
--- a/sys/dev/k8temp/k8temp.c
+++ b/sys/dev/k8temp/k8temp.c
@@ -54,6 +54,7 @@ struct k8temp_softc {
int sc_ntemps;
struct sysctl_oid *sc_oid;
struct sysctl_oid *sc_sysctl_cpu[2];
+ struct intr_config_hook sc_ich;
};
#define VENDORID_AMD 0x1022
@@ -91,6 +92,7 @@ typedef enum {
static void k8temp_identify(driver_t *driver, device_t parent);
static int k8temp_probe(device_t dev);
static int k8temp_attach(device_t dev);
+static void k8temp_intrhook(void *arg);
static int k8temp_detach(device_t dev);
static int k8temp_match(device_t dev);
static int32_t k8temp_gettemp(device_t dev, k8sensor_t sensor);
@@ -173,32 +175,19 @@ k8temp_probe(device_t dev)
static int
k8temp_attach(device_t dev)
{
- device_t nexus, acpi, cpu;
struct k8temp_softc *sc = device_get_softc(dev);
- int i;
struct sysctl_ctx_list *sysctlctx;
struct sysctl_oid *sysctlnode;
+
/*
- * dev.cpu.N.temperature.
+ * Setup intrhook function to create dev.cpu sysctl entries. This is
+ * needed because the cpu driver may be loaded late on boot, before
+ * us.
*/
- nexus = device_find_child(root_bus, "nexus", 0);
- acpi = device_find_child(nexus, "acpi", 0);
-
- for (i = 0; i < 2; i++) {
- cpu = device_find_child(acpi, "cpu",
- device_get_unit(dev) * 2 + i);
- if (cpu) {
- sysctlctx = device_get_sysctl_ctx(cpu);
-
- sc->sc_sysctl_cpu[i] = SYSCTL_ADD_PROC(sysctlctx,
- SYSCTL_CHILDREN(device_get_sysctl_tree(cpu)),
- OID_AUTO, "temperature", CTLTYPE_INT | CTLFLAG_RD,
- dev, CORE0, k8temp_sysctl, "I",
- "Max of sensor 0 / 1");
- }
- }
-
+ sc->sc_ich.ich_func = k8temp_intrhook;
+ sc->sc_ich.ich_arg = dev;
+
/*
* dev.k8temp.N tree.
*/
@@ -238,6 +227,39 @@ k8temp_attach(device_t dev)
return (0);
}
+void
+k8temp_intrhook(void *arg)
+{
+ int i;
+ device_t nexus, acpi, cpu;
+ device_t dev = (device_t) arg;
+ struct k8temp_softc *sc;
+ struct sysctl_ctx_list *sysctlctx;
+
+ sc = device_get_softc(dev);
+
+ /*
+ * dev.cpu.N.temperature.
+ */
+ nexus = device_find_child(root_bus, "nexus", 0);
+ acpi = device_find_child(nexus, "acpi", 0);
+
+ for (i = 0; i < 2; i++) {
+ cpu = device_find_child(acpi, "cpu",
+ device_get_unit(dev) * 2 + i);
+ if (cpu) {
+ sysctlctx = device_get_sysctl_ctx(cpu);
+
+ sc->sc_sysctl_cpu[i] = SYSCTL_ADD_PROC(sysctlctx,
+ SYSCTL_CHILDREN(device_get_sysctl_tree(cpu)),
+ OID_AUTO, "temperature", CTLTYPE_INT | CTLFLAG_RD,
+ dev, CORE0, k8temp_sysctl, "I",
+ "Max of sensor 0 / 1");
+ }
+ }
+ config_intrhook_disestablish(&sc->sc_ich);
+}
+
int
k8temp_detach(device_t dev)
{
OpenPOWER on IntegriCloud