You are not logged in.
IMPORTANT NOTE:
this module is ONLY for NV50 cards (GeForce 8xxx, GeForce 9xxx, GeForce 100, GeForce 200, GeForce 300)!
v1.0 – initial release
v1.1 – fixed bug where module would not load at boot
v1.2 – uploaded falconindy’s changes – module doesn’t invade userspace anymore
v1.3 – added kobject_put to free memory on module exit
v1.4 – removed unnecessary kernel thread, removed floating point variables
v1.5 – fixed slope, more accurate
This kernel module enables you to see GPU temperature, its meant to be used with nouveau drivers (but may work on nvidia binary also). I wrote it because nouveau seems unable to display GPU temperature, even though there is a category in "sensors", its value is always 0. Also to practice C programming a bit
The temperature is read from /sys/kernel/nv50/nv50_temp
Code is influenced by nouveau code.
Last edited by karabaja4 (2012-06-13 19:22:44)
Offline
Hello
Reading/Writing files from kernel is not a good idea. See http://kernelnewbies.org/FAQ/WhyWriting … ernelIsBad
ps: $startdir in PKGBUILD should not be used (use $srcdir and $pkgdir instead). "|| return 1" is not needed. you can use build() and package()
Thanks for your contribution.
Offline
ps: $startdir in PKGBUILD should not be used (use $srcdir and $pkgdir instead). "|| return 1" is not needed.
Done. Not sure about build() and package() though
Reading/Writing files from kernel is not a good idea. See http://kernelnewbies.org/FAQ/WhyWriting … ernelIsBad
Yeah, I stumbled onto that, but this was the easiest way for me to fetch the GPU temperature, because in kernel-space I have easy access to hardware, unlike user-space where accessing hardware requires quite a bit of coding. This seems solid enough so far.
Last edited by karabaja4 (2011-09-25 00:59:45)
Offline
I see your point djgera, this module refuses to load at boot-time. I'll try to fix that bug, I didn't anticipate reboots
EDIT: fixed in v1.1.
Please tell me if you find any more bugs.
Last edited by karabaja4 (2011-09-25 01:40:55)
Offline
Sweet, I'll give this a shot later today!
Offline
Very interesting. I am curious about picking /tmp, wouldn't it be better to map the value somewhere in /sys, as is done with e.g CPU temperatures?
Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy
Offline
Very interesting. I am curious about picking /tmp, wouldn't it be better to map the value somewhere in /sys, as is done with e.g CPU temperatures?
As djgera stated above, writing to file from kernel module is generally a bad idea, so I picked /tmp as a location where least can go wrong. Writing to /sys, /proc etc. could mess with system and kernel stuff.
Last edited by karabaja4 (2011-09-25 21:30:30)
Offline
The problem isn't where you write, but the fact that you're invading userspace at all. Out of sheer masochism, I've installed the kernel manpages and jumped in head first...
This seems to work, but I need to figure out how to parent the node in a better place... /sys/devices would be nice....
The uninterruptable sleep should be refactored as well (not sure how other kthreaded modules do this), since you block for up to 10 seconds on unloading the module.
Last edited by falconindy (2011-09-25 21:44:18)
Offline
The uninterruptable sleep should be refactored as well (not sure how other kthreaded modules do this), since you block for up to 10 seconds on unloading the module.
It waits up to 10 seconds (expected ~5s) with msleep_interruptible() just the same, at least on my machine.
P. S. falconindy: at this moment I don't have access to machine where I wrote and tested this (it comes back to me next week), so I cannot include your changes just yet But thanks! In the meantime try and solve that node parenting thing.
Last edited by karabaja4 (2011-09-25 22:29:48)
Offline
The problem isn't where you write, but the fact that you're invading userspace at all. Out of sheer masochism, I've installed the kernel manpages and jumped in head first...
This seems to work, but I need to figure out how to parent the node in a better place... /sys/devices would be nice....
The uninterruptable sleep should be refactored as well (not sure how other kthreaded modules do this), since you block for up to 10 seconds on unloading the module.
Hey, I (just now, sorry for delay) tested your module, but I can't figure out where that kobject is located?
Offline
Should be in /sys/kernel/nv50_temp/
I haven't had time to look into how to reparent it properly.
Ok, I uploaded you changes - I just changed the path to /sys/kernel/nv50/nv50_temp.
So... now it doesn't invade userspace anymore - updated the first post. Thanks!
Last edited by karabaja4 (2011-10-01 18:25:42)
Offline
Offline
I missed a kobject_put call to free the memory on exit. Just make sure its called after sysfs_remove_file (line 98 in thermal_exit, or thereabouts).
Done.
Offline
I've updated this a bit:
v1.4
- kernel thread is no longer used, it was completely unneccesary. Now it reads temperature only when node is actually read.
- floating point variables are no longer used
Offline
Ah, totally forgot about this! Thanks for your work on this, off to try it!
Offline