NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/58148: viac7temp(4) module fails to load



>Number:         58148
>Category:       kern
>Synopsis:       viac7temp(4) module fails to load
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Apr 13 08:40:00 +0000 2024
>Originator:     Andrius V
>Release:        NetBSD 8, 9, 10, current
>Organization:
>Environment:
>Description:
If viac7temp(4) module is not built-in and one attempts to load it using modules, it will fail:
WARNING: module error: `link_set_modules' section not present, error 2
WARNING: module error: cannot fetch info for `viac7temp', error 2

objdump -h viac7temp.kmod confirms that this section is missing.

The issue is present in all currently supported versions (8, 9, 10). I assume it was missed because it is built-in by default and nobody really tries to load it from modules.




>How-To-Repeat:
Build kernel without viac7temp driver and boot to it.
modload viac7temp
>Fix:
The patch below fixes an issue and module loads. I don't have currently a CPU which actually shows the temperature (getting 0), but it may be hardware or some different bug/issue, which I may address in the future.

Index: sys/arch/x86/x86/viac7temp.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/viac7temp.c,v
retrieving revision 1.9
diff -u -p -r1.9 viac7temp.c
--- sys/arch/x86/x86/viac7temp.c	7 Oct 2021 12:52:27 -0000	1.9
+++ sys/arch/x86/x86/viac7temp.c	12 Apr 2024 23:25:42 -0000
@@ -32,6 +32,7 @@ __KERNEL_RCSID(0, "$NetBSD: viac7temp.c,
 #include <sys/param.h>
 #include <sys/device.h>
 #include <sys/kmem.h>
+#include <sys/module.h>
 #include <sys/xcall.h>
 
 #include <dev/sysmon/sysmonvar.h>
@@ -162,3 +163,32 @@ viac7temp_refresh_xcall(void *arg0, void
 	edata->value_cur += 273150000;
 	edata->state = ENVSYS_SVALID;
 }
+
+MODULE(MODULE_CLASS_DRIVER, viac7temp, NULL);
+
+#ifdef _MODULE
+#include "ioconf.c"
+#endif
+
+static int
+viac7temp_modcmd(modcmd_t cmd, void *arg __unused)
+{
+	int error = 0;
+
+	switch (cmd) {
+	case MODULE_CMD_INIT:
+#ifdef _MODULE
+		error = config_init_component(cfdriver_ioconf_viac7temp,
+		    cfattach_ioconf_viac7temp, cfdata_ioconf_viac7temp);
+#endif
+		return error;
+	case MODULE_CMD_FINI:
+#ifdef _MODULE
+		error = config_fini_component(cfdriver_ioconf_viac7temp,
+		    cfattach_ioconf_viac7temp, cfdata_ioconf_viac7temp);
+#endif
+		return error;
+	default:
+		return ENOTTY;
+	}
+}



Home | Main Index | Thread Index | Old Index