Difference between revisions of "Talk:Tpctl"

From ThinkWiki
Jump to: navigation, search
("thinkpad" module kernel compatibility)
(Undo corruption)
 
(5 intermediate revisions by 4 users not shown)
Line 28: Line 28:
 
This is the patch I'd been using up to 2.6.15:
 
This is the patch I'd been using up to 2.6.15:
  
<code>
+
[root@ccb-thinkpad thinkpad-5.8]# more thinkpad-2.6-per_cpu.patch
[root@ccb-thinkpad thinkpad-5.8]# more thinkpad-2.6-per_cpu.patch
+
--- 2.6/drivers/thinkpadpm.c.ccb        2005-07-02 01:02:47.000000000 -0400
--- 2.6/drivers/thinkpadpm.c.ccb        2005-07-02 01:02:47.000000000 -0400
+
+++ 2.6/drivers/thinkpadpm.c    2005-07-02 01:13:20.000000000 -0400
+++ 2.6/drivers/thinkpadpm.c    2005-07-02 01:13:20.000000000 -0400
+
@@ -171,8 +171,8 @@
@@ -171,8 +171,8 @@
+
  #define get_gdt_table()        (cpu_gdt_table[get_cpu()])
 +
  #define put_gdt_table()        put_cpu()
 +
  #else
 +
-#define get_gdt_table()        (get_cpu_ptr(cpu_gdt_table))
 +
-#define put_gdt_table()        put_cpu_ptr(cpu_gdt_table)
 +
+#define get_gdt_table()        per_cpu(cpu_gdt_table, smp_processor_id())
 +
+#define put_gdt_table()        put_cpu()
 +
  #endif
 +
 
 +
Sounds like TedTso took a slightly different approach.
 +
 
 +
As it stands, it won't compile since the release of 2.6.15 because the
 +
once global pm_active variable in the kernel is no longer visible.
 +
 
 +
ccb
 +
 
 +
 
 +
---
 +
Sorry for the ugliness of that patch.  Do a wiki edit on the page
 +
and you'll see it on all of it's Courier10 glory.
 +
 
 +
For 2.6.15: some of the definitions have been split off into a
 +
new header file.  You'll have to edit thinkpadpm.c and add
 +
"#include <linux/pm_legacy.h>" right after the include for pm.h
 +
to get it to compile.
 +
 
 +
ccb
 +
----
 +
Ugliness fixed. [[User:Wyrfel|Wyrfel]] 00:24, 13 February 2006 (CET)
 +
----
 +
 
 +
 
 +
As of 2.6.16 they've reworked some of the macros again.  This patch
 +
applied against virgin thinkpad-5.8 sources appears to work:
 +
 
 +
<pre>
 +
--- ./2.6/drivers/thinkpadpm.c.ccb      2005-09-05 20:53:39.000000000 -0400
 +
+++ ./2.6/drivers/thinkpadpm.c  2006-05-05 10:14:26.000000000 -0400
 +
@@ -38,6 +38,7 @@
 +
#include <asm/uaccess.h>
 +
#include <linux/apm_bios.h>
 +
#include <linux/pm.h>
 +
+#include <linux/pm_legacy.h>
 +
#include <linux/version.h>
 +
#include "thinkpad_common.h"
 +
#include "thinkpadpm.h"
 +
@@ -171,8 +172,8 @@
 
  #define get_gdt_table()        (cpu_gdt_table[get_cpu()])
 
  #define get_gdt_table()        (cpu_gdt_table[get_cpu()])
 
  #define put_gdt_table()        put_cpu()
 
  #define put_gdt_table()        put_cpu()
Line 38: Line 84:
 
-#define get_gdt_table()        (get_cpu_ptr(cpu_gdt_table))
 
-#define get_gdt_table()        (get_cpu_ptr(cpu_gdt_table))
 
-#define put_gdt_table()        put_cpu_ptr(cpu_gdt_table)
 
-#define put_gdt_table()        put_cpu_ptr(cpu_gdt_table)
+#define get_gdt_table()        per_cpu(cpu_gdt_table, smp_processor_id())
+
+#define get_gdt_table()        get_cpu_gdt_table(smp_processor_id())
 
+#define put_gdt_table()        put_cpu()
 
+#define put_gdt_table()        put_cpu()
 
  #endif
 
  #endif
</code>
 
  
Sounds like TedTso took a slightly different approach.
+
/**
 +
@@ -472,7 +473,7 @@
 +
{
  
As it stands, it won't compile since the release of 2.6.15 because the
+
        /*** Set up APM BIOS interface ***/
once global pm_active variable in the kernel is no longer visible.
+
-      if ( !pm_active ) {
 +
+        if ( !pm_active ) {
 +
                printk(KERN_INFO "thinkpadpm: Power management not active. :-(\n");
 +
                return -ENODEV;
 +
        }
 +
 
 +
</pre>
  
 
ccb
 
ccb
 +
----
 +
Seems not to work since 2.6.17 (with thinkpad_6.0) because of the use of old MODULE_PARM macro and inter_module_* function.
 +
 +
A patch is submitted [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=366170 here]
 +
But due to my lack of experience, I have not tested it. If someone could confirm it works -or not...-
 +
 +
Mat

Latest revision as of 15:18, 11 April 2007

"thinkpad" module kernel compatibility

Ajunge, how do you compile the "thinkpad" module compile on kernel >=2.6.9? The latest thinkpad version (5.8) still uses "get_cpu_ptr" and "set_cpu_ptr", which were removed in 2.6.9.

--Thinker 13:53, 10 Dec 2005 (CET)


The Debian thinkpad-source package in unstable (version 5.8-4) works just fine; I'm compiling it with 2.6.14 without any problems. And get_cpu_ptr is present; it's defined in include/linux/percpu.h.

--TedTso 18:56, 17 Dec 2005 (EDT)


Stock thinkpad_5.8.tar.gz doesn't #include percpu.h anyway, and doesn't compile on vanilla 2.6.14.3 or 2.6.15-rc5. Maybe Debian patched it? In that case the article page should ref the patch.

--Thinker 11:50, 18 Dec 2005 (CET)


Oops, my mistake. I forgot that I had patched my copy of thinkpadpm.c. I replaced the use of get_cpu_ptr and set_cpu_ptr with get_cpu_val() and set_cpu_val(). I just double checked, and it tpctl is working for me on 2.6.15-rc5.

--TedTso 14:45, 19 Dec 2005 (EDT)


Care to send a patch? It would be useful on the article page, and maybe we can get it into upstream.

--Thinker 23:11, 19 Dec 2005 (CET)


This is the patch I'd been using up to 2.6.15:

[root@ccb-thinkpad thinkpad-5.8]# more thinkpad-2.6-per_cpu.patch
--- 2.6/drivers/thinkpadpm.c.ccb        2005-07-02 01:02:47.000000000 -0400
+++ 2.6/drivers/thinkpadpm.c    2005-07-02 01:13:20.000000000 -0400
@@ -171,8 +171,8 @@
 #define get_gdt_table()        (cpu_gdt_table[get_cpu()])
 #define put_gdt_table()        put_cpu()
 #else
-#define get_gdt_table()        (get_cpu_ptr(cpu_gdt_table))
-#define put_gdt_table()        put_cpu_ptr(cpu_gdt_table)
+#define get_gdt_table()        per_cpu(cpu_gdt_table, smp_processor_id())
+#define put_gdt_table()        put_cpu()
 #endif

Sounds like TedTso took a slightly different approach.

As it stands, it won't compile since the release of 2.6.15 because the once global pm_active variable in the kernel is no longer visible.

ccb


--- Sorry for the ugliness of that patch. Do a wiki edit on the page and you'll see it on all of it's Courier10 glory.

For 2.6.15: some of the definitions have been split off into a new header file. You'll have to edit thinkpadpm.c and add "#include <linux/pm_legacy.h>" right after the include for pm.h to get it to compile.

ccb


Ugliness fixed. Wyrfel 00:24, 13 February 2006 (CET)



As of 2.6.16 they've reworked some of the macros again. This patch applied against virgin thinkpad-5.8 sources appears to work:

--- ./2.6/drivers/thinkpadpm.c.ccb      2005-09-05 20:53:39.000000000 -0400
+++ ./2.6/drivers/thinkpadpm.c  2006-05-05 10:14:26.000000000 -0400
@@ -38,6 +38,7 @@
 #include <asm/uaccess.h>
 #include <linux/apm_bios.h>
 #include <linux/pm.h>
+#include <linux/pm_legacy.h>
 #include <linux/version.h>
 #include "thinkpad_common.h"
 #include "thinkpadpm.h"
@@ -171,8 +172,8 @@
 #define get_gdt_table()        (cpu_gdt_table[get_cpu()])
 #define put_gdt_table()        put_cpu()
 #else
-#define get_gdt_table()        (get_cpu_ptr(cpu_gdt_table))
-#define put_gdt_table()        put_cpu_ptr(cpu_gdt_table)
+#define get_gdt_table()        get_cpu_gdt_table(smp_processor_id())
+#define put_gdt_table()        put_cpu()
 #endif

 /**
@@ -472,7 +473,7 @@
 {

        /*** Set up APM BIOS interface ***/
-       if ( !pm_active ) {
+        if ( !pm_active ) {
                printk(KERN_INFO "thinkpadpm: Power management not active. :-(\n");
                return -ENODEV;
        }

ccb


Seems not to work since 2.6.17 (with thinkpad_6.0) because of the use of old MODULE_PARM macro and inter_module_* function.

A patch is submitted here But due to my lack of experience, I have not tested it. If someone could confirm it works -or not...-

Mat