* [GIT PATCH] thinkpad-acpi queue for 2.6.30
@ 2009-04-04 4:25 Henrique de Moraes Holschuh
2009-04-04 4:25 ` [PATCH 01/12] thinkpad-acpi: update copyright notices Henrique de Moraes Holschuh
` (12 more replies)
0 siblings, 13 replies; 16+ messages in thread
From: Henrique de Moraes Holschuh @ 2009-04-04 4:25 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi, ibm-acpi-devel
Len,
This patchset has the changes for thinkpad-acpi that I would like to
see merged for 2.6.30 (while the window is still open).
It contains the patch for
http://bugzilla.kernel.org/show_bug.cgi?id=11750, and a few
enhancements.
Shortlog:
Henrique de Moraes Holschuh (12):
thinkpad-acpi: update copyright notices
thinkpad-acpi: drop ibm-acpi alias
thinkpad-acpi: documentation cleanup
thinkpad-acpi: cleanup debug helpers
thinkpad-acpi: add missing log levels
thinkpad-acpi: add new debug helpers and warn of deprecated atts
thinkpad-acpi: remove HKEY disable functionality
thinkpad-acpi: restrict access to some firmware LEDs
thinkpad-acpi: enhanced debugging messages for rfkill subdrivers
thinkpad-acpi: enhanced debugging messages for the hotkey subdriver
thinkpad-acpi: enhanced debugging messages for the fan subdriver
thinkpad-acpi: rework brightness support
--
"One disk to rule them all, One disk to find them. One disk to bring
them all and in the darkness grind them. In the Land of Redmond
where the shadows lie." -- The Silicon Valley Tarot
Henrique Holschuh
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 01/12] thinkpad-acpi: update copyright notices
2009-04-04 4:25 [GIT PATCH] thinkpad-acpi queue for 2.6.30 Henrique de Moraes Holschuh
@ 2009-04-04 4:25 ` Henrique de Moraes Holschuh
2009-04-04 4:25 ` [PATCH 02/12] thinkpad-acpi: drop ibm-acpi alias Henrique de Moraes Holschuh
` (11 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Henrique de Moraes Holschuh @ 2009-04-04 4:25 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi, ibm-acpi-devel, Henrique de Moraes Holschuh
It is that time of the year again...
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
---
drivers/platform/x86/thinkpad_acpi.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index d99f1cd..fd6985b 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -3,7 +3,7 @@
*
*
* Copyright (C) 2004-2005 Borislav Deianov <borislav@users.sf.net>
- * Copyright (C) 2006-2008 Henrique de Moraes Holschuh <hmh@hmh.eng.br>
+ * Copyright (C) 2006-2009 Henrique de Moraes Holschuh <hmh@hmh.eng.br>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
--
1.6.2.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 02/12] thinkpad-acpi: drop ibm-acpi alias
2009-04-04 4:25 [GIT PATCH] thinkpad-acpi queue for 2.6.30 Henrique de Moraes Holschuh
2009-04-04 4:25 ` [PATCH 01/12] thinkpad-acpi: update copyright notices Henrique de Moraes Holschuh
@ 2009-04-04 4:25 ` Henrique de Moraes Holschuh
2009-04-04 4:25 ` [PATCH 03/12] thinkpad-acpi: documentation cleanup Henrique de Moraes Holschuh
` (10 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Henrique de Moraes Holschuh @ 2009-04-04 4:25 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi, ibm-acpi-devel, Henrique de Moraes Holschuh
The driver was renamed two years ago, on 2.6.21. Drop the old
compatibility alias, we have given everybody quite enough time
to update their configs to the new name.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
---
drivers/platform/x86/thinkpad_acpi.c | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index fd6985b..5fd5549 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -7515,9 +7515,6 @@ static int __init thinkpad_acpi_module_init(void)
return 0;
}
-/* Please remove this in year 2009 */
-MODULE_ALIAS("ibm_acpi");
-
MODULE_ALIAS(TPACPI_DRVR_SHORTNAME);
/*
--
1.6.2.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 03/12] thinkpad-acpi: documentation cleanup
2009-04-04 4:25 [GIT PATCH] thinkpad-acpi queue for 2.6.30 Henrique de Moraes Holschuh
2009-04-04 4:25 ` [PATCH 01/12] thinkpad-acpi: update copyright notices Henrique de Moraes Holschuh
2009-04-04 4:25 ` [PATCH 02/12] thinkpad-acpi: drop ibm-acpi alias Henrique de Moraes Holschuh
@ 2009-04-04 4:25 ` Henrique de Moraes Holschuh
2009-04-04 4:25 ` [PATCH 04/12] thinkpad-acpi: cleanup debug helpers Henrique de Moraes Holschuh
` (9 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Henrique de Moraes Holschuh @ 2009-04-04 4:25 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi, ibm-acpi-devel, Henrique de Moraes Holschuh
Some cleanups to the documentation of the driver.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
---
Documentation/laptops/thinkpad-acpi.txt | 76 +++++++++++++++++++++----------
1 files changed, 52 insertions(+), 24 deletions(-)
diff --git a/Documentation/laptops/thinkpad-acpi.txt b/Documentation/laptops/thinkpad-acpi.txt
index 41bc99f..f6e6bc6 100644
--- a/Documentation/laptops/thinkpad-acpi.txt
+++ b/Documentation/laptops/thinkpad-acpi.txt
@@ -20,7 +20,8 @@ moved to the drivers/misc tree and renamed to thinkpad-acpi for kernel
kernel 2.6.29 and release 0.22.
The driver is named "thinkpad-acpi". In some places, like module
-names, "thinkpad_acpi" is used because of userspace issues.
+names and log messages, "thinkpad_acpi" is used because of userspace
+issues.
"tpacpi" is used as a shorthand where "thinkpad-acpi" would be too
long due to length limitations on some Linux kernel versions.
@@ -37,7 +38,7 @@ detailed description):
- ThinkLight on and off
- limited docking and undocking
- UltraBay eject
- - CMOS control
+ - CMOS/UCMS control
- LED control
- ACPI sounds
- temperature sensors
@@ -46,6 +47,7 @@ detailed description):
- Volume control
- Fan control and monitoring: fan speed, fan enable/disable
- WAN enable and disable
+ - UWB enable and disable
A compatibility table by model and feature is maintained on the web
site, http://ibm-acpi.sf.net/. I appreciate any success or failure
@@ -53,7 +55,7 @@ reports, especially if they add to or correct the compatibility table.
Please include the following information in your report:
- ThinkPad model name
- - a copy of your DSDT, from /proc/acpi/dsdt
+ - a copy of your ACPI tables, using the "acpidump" utility
- a copy of the output of dmidecode, with serial numbers
and UUIDs masked off
- which driver features work and which don't
@@ -66,17 +68,18 @@ Installation
------------
If you are compiling this driver as included in the Linux kernel
-sources, simply enable the CONFIG_THINKPAD_ACPI option, and optionally
-enable the CONFIG_THINKPAD_ACPI_BAY option if you want the
-thinkpad-specific bay functionality.
+sources, look for the CONFIG_THINKPAD_ACPI Kconfig option.
+It is located on the menu path: "Device Drivers" -> "X86 Platform
+Specific Device Drivers" -> "ThinkPad ACPI Laptop Extras".
+
Features
--------
The driver exports two different interfaces to userspace, which can be
used to access the features it provides. One is a legacy procfs-based
-interface, which will be removed at some time in the distant future.
-The other is a new sysfs-based interface which is not complete yet.
+interface, which will be removed at some time in the future. The other
+is a new sysfs-based interface which is not complete yet.
The procfs interface creates the /proc/acpi/ibm directory. There is a
file under that directory for each feature it supports. The procfs
@@ -111,15 +114,17 @@ The version of thinkpad-acpi's sysfs interface is exported by the driver
as a driver attribute (see below).
Sysfs driver attributes are on the driver's sysfs attribute space,
-for 2.6.23 this is /sys/bus/platform/drivers/thinkpad_acpi/ and
+for 2.6.23+ this is /sys/bus/platform/drivers/thinkpad_acpi/ and
/sys/bus/platform/drivers/thinkpad_hwmon/
Sysfs device attributes are on the thinkpad_acpi device sysfs attribute
-space, for 2.6.23 this is /sys/devices/platform/thinkpad_acpi/.
+space, for 2.6.23+ this is /sys/devices/platform/thinkpad_acpi/.
Sysfs device attributes for the sensors and fan are on the
thinkpad_hwmon device's sysfs attribute space, but you should locate it
-looking for a hwmon device with the name attribute of "thinkpad".
+looking for a hwmon device with the name attribute of "thinkpad", or
+better yet, through libsensors.
+
Driver version
--------------
@@ -129,6 +134,7 @@ sysfs driver attribute: version
The driver name and version. No commands can be written to this file.
+
Sysfs interface version
-----------------------
@@ -160,6 +166,7 @@ expect that an attribute might not be there, and deal with it properly
(an attribute not being there *is* a valid way to make it clear that a
feature is not available in sysfs).
+
Hot keys
--------
@@ -618,6 +625,7 @@ For Lenovo models *with* ACPI backlight control:
and map them to KEY_BRIGHTNESS_UP and KEY_BRIGHTNESS_DOWN. Process
these keys on userspace somehow (e.g. by calling xbacklight).
+
Bluetooth
---------
@@ -628,6 +636,9 @@ sysfs rfkill class: switch "tpacpi_bluetooth_sw"
This feature shows the presence and current state of a ThinkPad
Bluetooth device in the internal ThinkPad CDC slot.
+If the ThinkPad supports it, the Bluetooth state is stored in NVRAM,
+so it is kept across reboots and power-off.
+
Procfs notes:
If Bluetooth is installed, the following commands can be used:
@@ -652,6 +663,7 @@ Sysfs notes:
rfkill controller switch "tpacpi_bluetooth_sw": refer to
Documentation/rfkill.txt for details.
+
Video output control -- /proc/acpi/ibm/video
--------------------------------------------
@@ -693,11 +705,8 @@ Fn-F7 from working. This also disables the video output switching
features of this driver, as it uses the same ACPI methods as
Fn-F7. Video switching on the console should still work.
-UPDATE: There's now a patch for the X.org Radeon driver which
-addresses this issue. Some people are reporting success with the patch
-while others are still having problems. For more information:
+UPDATE: refer to https://bugs.freedesktop.org/show_bug.cgi?id=2000
-https://bugs.freedesktop.org/show_bug.cgi?id=2000
ThinkLight control
------------------
@@ -720,10 +729,11 @@ The ThinkLight sysfs interface is documented by the LED class
documentation, in Documentation/leds-class.txt. The ThinkLight LED name
is "tpacpi::thinklight".
-Due to limitations in the sysfs LED class, if the status of the thinklight
+Due to limitations in the sysfs LED class, if the status of the ThinkLight
cannot be read or if it is unknown, thinkpad-acpi will report it as "off".
It is impossible to know if the status returned through sysfs is valid.
+
Docking / undocking -- /proc/acpi/ibm/dock
------------------------------------------
@@ -784,6 +794,7 @@ the only docking stations currently supported are the X-series
UltraBase docks and "dumb" port replicators like the Mini Dock (the
latter don't need any ACPI support, actually).
+
UltraBay eject -- /proc/acpi/ibm/bay
------------------------------------
@@ -847,8 +858,9 @@ supported. Use "eject2" instead of "eject" for the second bay.
Note: the UltraBay eject support on the 600e/x, A22p and A3x is
EXPERIMENTAL and may not work as expected. USE WITH CAUTION!
-CMOS control
-------------
+
+CMOS/UCMS control
+-----------------
procfs: /proc/acpi/ibm/cmos
sysfs device attribute: cmos_command
@@ -882,6 +894,7 @@ The cmos command interface is prone to firmware split-brain problems, as
in newer ThinkPads it is just a compatibility layer. Do not use it, it is
exported just as a debug tool.
+
LED control
-----------
@@ -939,6 +952,7 @@ ThinkPad indicator LED should blink in hardware accelerated mode, use the
"timer" trigger, and leave the delay_on and delay_off parameters set to
zero (to request hardware acceleration autodetection).
+
ACPI sounds -- /proc/acpi/ibm/beep
----------------------------------
@@ -968,6 +982,7 @@ X40:
16 - one medium-pitched beep repeating constantly, stop with 17
17 - stop 16
+
Temperature sensors
-------------------
@@ -1115,6 +1130,7 @@ registers contain the current battery capacity, etc. If you experiment
with this, do send me your results (including some complete dumps with
a description of the conditions when they were taken.)
+
LCD brightness control
----------------------
@@ -1124,10 +1140,9 @@ sysfs backlight device "thinkpad_screen"
This feature allows software control of the LCD brightness on ThinkPad
models which don't have a hardware brightness slider.
-It has some limitations: the LCD backlight cannot be actually turned on or
-off by this interface, and in many ThinkPad models, the "dim while on
-battery" functionality will be enabled by the BIOS when this interface is
-used, and cannot be controlled.
+It has some limitations: the LCD backlight cannot be actually turned
+on or off by this interface, it just controls the backlight brightness
+level.
On IBM (and some of the earlier Lenovo) ThinkPads, the backlight control
has eight brightness levels, ranging from 0 to 7. Some of the levels
@@ -1201,6 +1216,7 @@ WARNING:
and maybe reduce the life of the backlight lamps by needlessly kicking
its level up and down at every change.
+
Volume control -- /proc/acpi/ibm/volume
---------------------------------------
@@ -1217,6 +1233,11 @@ distinct. The unmute the volume after the mute command, use either the
up or down command (the level command will not unmute the volume).
The current volume level and mute state is shown in the file.
+The ALSA mixer interface to this feature is still missing, but patches
+to add it exist. That problem should be addressed in the not so
+distant future.
+
+
Fan control and monitoring: fan speed, fan enable/disable
---------------------------------------------------------
@@ -1383,8 +1404,11 @@ procfs: /proc/acpi/ibm/wan
sysfs device attribute: wwan_enable (deprecated)
sysfs rfkill class: switch "tpacpi_wwan_sw"
-This feature shows the presence and current state of a W-WAN (Sierra
-Wireless EV-DO) device.
+This feature shows the presence and current state of the built-in
+Wireless WAN device.
+
+If the ThinkPad supports it, the WWAN state is stored in NVRAM,
+so it is kept across reboots and power-off.
It was tested on a Lenovo ThinkPad X60. It should probably work on other
ThinkPad models which come with this module installed.
@@ -1413,6 +1437,7 @@ Sysfs notes:
rfkill controller switch "tpacpi_wwan_sw": refer to
Documentation/rfkill.txt for details.
+
EXPERIMENTAL: UWB
-----------------
@@ -1431,6 +1456,7 @@ Sysfs notes:
rfkill controller switch "tpacpi_uwb_sw": refer to
Documentation/rfkill.txt for details.
+
Multiple Commands, Module Parameters
------------------------------------
@@ -1445,6 +1471,7 @@ for example:
modprobe thinkpad_acpi hotkey=enable,0xffff video=auto_disable
+
Enabling debugging output
-------------------------
@@ -1467,6 +1494,7 @@ The level of debugging information output by the driver can be changed
at runtime through sysfs, using the driver attribute debug_level. The
attribute takes the same bitmask as the debug module parameter above.
+
Force loading of module
-----------------------
--
1.6.2.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 04/12] thinkpad-acpi: cleanup debug helpers
2009-04-04 4:25 [GIT PATCH] thinkpad-acpi queue for 2.6.30 Henrique de Moraes Holschuh
` (2 preceding siblings ...)
2009-04-04 4:25 ` [PATCH 03/12] thinkpad-acpi: documentation cleanup Henrique de Moraes Holschuh
@ 2009-04-04 4:25 ` Henrique de Moraes Holschuh
2009-04-04 4:25 ` [PATCH 05/12] thinkpad-acpi: add missing log levels Henrique de Moraes Holschuh
` (8 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Henrique de Moraes Holschuh @ 2009-04-04 4:25 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi, ibm-acpi-devel, Henrique de Moraes Holschuh
Fix the vdbg_printk macro definition to be sane when
CONFIG_THINKPAD_ACPI_DEBUG is undefined, and move the mess into a file
section of its own.
This doesn't change anything in the current code, but future code will
need the proper behaviour.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
---
drivers/platform/x86/thinkpad_acpi.c | 29 ++++++++++++++++++-----------
1 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 5fd5549..0a01f76 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -184,17 +184,6 @@ enum {
#define TPACPI_DBG_ALL 0xffff
#define TPACPI_DBG_INIT 0x0001
#define TPACPI_DBG_EXIT 0x0002
-#define dbg_printk(a_dbg_level, format, arg...) \
- do { if (dbg_level & a_dbg_level) \
- printk(TPACPI_DEBUG "%s: " format, __func__ , ## arg); \
- } while (0)
-#ifdef CONFIG_THINKPAD_ACPI_DEBUG
-#define vdbg_printk(a_dbg_level, format, arg...) \
- dbg_printk(a_dbg_level, format, ## arg)
-static const char *str_supported(int is_supported);
-#else
-#define vdbg_printk(a_dbg_level, format, arg...)
-#endif
#define onoff(status, bit) ((status) & (1 << (bit)) ? "on" : "off")
#define enabled(status, bit) ((status) & (1 << (bit)) ? "enabled" : "disabled")
@@ -326,6 +315,24 @@ static int tpacpi_uwb_emulstate;
#endif
+/*************************************************************************
+ * Debugging helpers
+ */
+
+#define dbg_printk(a_dbg_level, format, arg...) \
+ do { if (dbg_level & (a_dbg_level)) \
+ printk(TPACPI_DEBUG "%s: " format, __func__ , ## arg); \
+ } while (0)
+
+#ifdef CONFIG_THINKPAD_ACPI_DEBUG
+#define vdbg_printk dbg_printk
+static const char *str_supported(int is_supported);
+#else
+#define vdbg_printk(a_dbg_level, format, arg...) \
+ do { } while (0)
+#endif
+
+
/****************************************************************************
****************************************************************************
*
--
1.6.2.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 05/12] thinkpad-acpi: add missing log levels
2009-04-04 4:25 [GIT PATCH] thinkpad-acpi queue for 2.6.30 Henrique de Moraes Holschuh
` (3 preceding siblings ...)
2009-04-04 4:25 ` [PATCH 04/12] thinkpad-acpi: cleanup debug helpers Henrique de Moraes Holschuh
@ 2009-04-04 4:25 ` Henrique de Moraes Holschuh
2009-04-04 4:25 ` [PATCH 06/12] thinkpad-acpi: add new debug helpers and warn of deprecated atts Henrique de Moraes Holschuh
` (7 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Henrique de Moraes Holschuh @ 2009-04-04 4:25 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi, ibm-acpi-devel, Henrique de Moraes Holschuh
Add missing log levels in a standalone commit, to avoid dependencies in
future unrelated changes, just because they wanted to use one of the
missing log levels.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
---
drivers/platform/x86/thinkpad_acpi.c | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 0a01f76..c93324a 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -172,15 +172,18 @@ enum {
TPACPI_RFK_UWB_SW_ID,
};
-/* Debugging */
+/* printk headers */
#define TPACPI_LOG TPACPI_FILE ": "
-#define TPACPI_ALERT KERN_ALERT TPACPI_LOG
-#define TPACPI_CRIT KERN_CRIT TPACPI_LOG
-#define TPACPI_ERR KERN_ERR TPACPI_LOG
-#define TPACPI_NOTICE KERN_NOTICE TPACPI_LOG
-#define TPACPI_INFO KERN_INFO TPACPI_LOG
-#define TPACPI_DEBUG KERN_DEBUG TPACPI_LOG
-
+#define TPACPI_EMERG KERN_EMERG TPACPI_LOG
+#define TPACPI_ALERT KERN_ALERT TPACPI_LOG
+#define TPACPI_CRIT KERN_CRIT TPACPI_LOG
+#define TPACPI_ERR KERN_ERR TPACPI_LOG
+#define TPACPI_WARN KERN_WARNING TPACPI_LOG
+#define TPACPI_NOTICE KERN_NOTICE TPACPI_LOG
+#define TPACPI_INFO KERN_INFO TPACPI_LOG
+#define TPACPI_DEBUG KERN_DEBUG TPACPI_LOG
+
+/* Debugging printk groups */
#define TPACPI_DBG_ALL 0xffff
#define TPACPI_DBG_INIT 0x0001
#define TPACPI_DBG_EXIT 0x0002
--
1.6.2.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 06/12] thinkpad-acpi: add new debug helpers and warn of deprecated atts
2009-04-04 4:25 [GIT PATCH] thinkpad-acpi queue for 2.6.30 Henrique de Moraes Holschuh
` (4 preceding siblings ...)
2009-04-04 4:25 ` [PATCH 05/12] thinkpad-acpi: add missing log levels Henrique de Moraes Holschuh
@ 2009-04-04 4:25 ` Henrique de Moraes Holschuh
2009-04-04 4:25 ` [PATCH 07/12] thinkpad-acpi: remove HKEY disable functionality Henrique de Moraes Holschuh
` (6 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Henrique de Moraes Holschuh @ 2009-04-04 4:25 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi, ibm-acpi-devel, Henrique de Moraes Holschuh
Add a debug helper that discloses the TGID of the userspace task
attempting to access the driver. This is highly useful when dealing
with bug reports, since often the user has no idea that some userspace
application is accessing thinkpad-acpi...
Also add a helper to log warnings about sysfs attributes that are
deprecated.
Use the new helpers to issue deprecation warnings for bluetooth_enable
and wwan_enabled, that have been deprecated for a while, now.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
---
Documentation/laptops/thinkpad-acpi.txt | 2 +
drivers/platform/x86/thinkpad_acpi.c | 40 +++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/Documentation/laptops/thinkpad-acpi.txt b/Documentation/laptops/thinkpad-acpi.txt
index f6e6bc6..e8f52fb 100644
--- a/Documentation/laptops/thinkpad-acpi.txt
+++ b/Documentation/laptops/thinkpad-acpi.txt
@@ -1484,6 +1484,8 @@ will enable all debugging output classes. It takes a bitmask, so
to enable more than one output class, just add their values.
Debug bitmask Description
+ 0x8000 Disclose PID of userspace programs
+ accessing some functions of the driver
0x0001 Initialization and probing
0x0002 Removal
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index c93324a..badf471 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -54,6 +54,7 @@
#include <linux/string.h>
#include <linux/list.h>
#include <linux/mutex.h>
+#include <linux/sched.h>
#include <linux/kthread.h>
#include <linux/freezer.h>
#include <linux/delay.h>
@@ -185,6 +186,7 @@ enum {
/* Debugging printk groups */
#define TPACPI_DBG_ALL 0xffff
+#define TPACPI_DBG_DISCLOSETASK 0x8000
#define TPACPI_DBG_INIT 0x0001
#define TPACPI_DBG_EXIT 0x0002
@@ -335,6 +337,21 @@ static const char *str_supported(int is_supported);
do { } while (0)
#endif
+static void tpacpi_log_usertask(const char * const what)
+{
+ printk(TPACPI_DEBUG "%s: access by process with PID %d\n",
+ what, task_tgid_vnr(current));
+}
+
+#define tpacpi_disclose_usertask(what, format, arg...) \
+ do { \
+ if (unlikely( \
+ (dbg_level & TPACPI_DBG_DISCLOSETASK) && \
+ (tpacpi_lifecycle == TPACPI_LIFE_RUNNING))) { \
+ printk(TPACPI_DEBUG "%s: PID %d: " format, \
+ what, task_tgid_vnr(current), ## arg); \
+ } \
+ } while (0)
/****************************************************************************
****************************************************************************
@@ -1030,6 +1047,21 @@ static int __init tpacpi_new_rfkill(const unsigned int id,
return 0;
}
+static void printk_deprecated_attribute(const char * const what,
+ const char * const details)
+{
+ tpacpi_log_usertask("deprecated sysfs attribute");
+ printk(TPACPI_WARN "WARNING: sysfs attribute %s is deprecated and "
+ "will be removed. %s\n",
+ what, details);
+}
+
+static void printk_deprecated_rfkill_attribute(const char * const what)
+{
+ printk_deprecated_attribute(what,
+ "Please switch to generic rfkill before year 2010");
+}
+
/*************************************************************************
* thinkpad-acpi driver attributes
*/
@@ -3070,6 +3102,8 @@ static ssize_t bluetooth_enable_show(struct device *dev,
{
int status;
+ printk_deprecated_rfkill_attribute("bluetooth_enable");
+
status = bluetooth_get_radiosw();
if (status < 0)
return status;
@@ -3085,6 +3119,8 @@ static ssize_t bluetooth_enable_store(struct device *dev,
unsigned long t;
int res;
+ printk_deprecated_rfkill_attribute("bluetooth_enable");
+
if (parse_strtoul(buf, 1, &t))
return -EINVAL;
@@ -3347,6 +3383,8 @@ static ssize_t wan_enable_show(struct device *dev,
{
int status;
+ printk_deprecated_rfkill_attribute("wwan_enable");
+
status = wan_get_radiosw();
if (status < 0)
return status;
@@ -3362,6 +3400,8 @@ static ssize_t wan_enable_store(struct device *dev,
unsigned long t;
int res;
+ printk_deprecated_rfkill_attribute("wwan_enable");
+
if (parse_strtoul(buf, 1, &t))
return -EINVAL;
--
1.6.2.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 07/12] thinkpad-acpi: remove HKEY disable functionality
2009-04-04 4:25 [GIT PATCH] thinkpad-acpi queue for 2.6.30 Henrique de Moraes Holschuh
` (5 preceding siblings ...)
2009-04-04 4:25 ` [PATCH 06/12] thinkpad-acpi: add new debug helpers and warn of deprecated atts Henrique de Moraes Holschuh
@ 2009-04-04 4:25 ` Henrique de Moraes Holschuh
2009-10-29 6:58 ` remove HKEY disable functionality (triggers Ubuntu Karmic regression) Mark Stosberg
2009-04-04 4:25 ` [PATCH 08/12] thinkpad-acpi: restrict access to some firmware LEDs Henrique de Moraes Holschuh
` (5 subsequent siblings)
12 siblings, 1 reply; 16+ messages in thread
From: Henrique de Moraes Holschuh @ 2009-04-04 4:25 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi, ibm-acpi-devel, Henrique de Moraes Holschuh
The HKEY disable functionality basically cripples the entire event
model of the ThinkPad firmware and of the thinkpad-acpi driver.
Remove this functionality from the driver. HKEY must be enabled at
all times while thinkpad-acpi is loaded, and disabled otherwise.
For sysfs, according to the sysfs ABI and the thinkpad-acpi sysfs
rules of engagement, we will just remove the attributes. This will be
done in two stages: disable their function now, after two kernel
releases, remove the attributes.
For procfs, we call WARN(). If nothing triggers it, I will simply
remove the enable/disable commands entirely in the future along with
the sysfs attributes.
I don't expect much, if any fallout from this. There really isn't any
reason to mess with hotkey_enable or with the enable/disable commands
to /proc/acpi/ibm/hotkey, and this has been true for years...
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
---
Documentation/laptops/thinkpad-acpi.txt | 39 ++++++++++++------------
drivers/platform/x86/thinkpad_acpi.c | 49 +++++++++++++++++--------------
2 files changed, 46 insertions(+), 42 deletions(-)
diff --git a/Documentation/laptops/thinkpad-acpi.txt b/Documentation/laptops/thinkpad-acpi.txt
index e8f52fb..de6f14c 100644
--- a/Documentation/laptops/thinkpad-acpi.txt
+++ b/Documentation/laptops/thinkpad-acpi.txt
@@ -179,17 +179,14 @@ system. Enabling the hotkey functionality of thinkpad-acpi signals the
firmware that such a driver is present, and modifies how the ThinkPad
firmware will behave in many situations.
-The driver enables the hot key feature automatically when loaded. The
-feature can later be disabled and enabled back at runtime. The driver
-will also restore the hot key feature to its previous state and mask
-when it is unloaded.
+The driver enables the HKEY ("hot key") event reporting automatically
+when loaded, and disables it when it is removed.
-When the hotkey feature is enabled and the hot key mask is set (see
-below), the driver will report HKEY events in the following format:
+The driver will report HKEY events in the following format:
ibm/hotkey HKEY 00000080 0000xxxx
-Some of these events refer to hot key presses, but not all.
+Some of these events refer to hot key presses, but not all of them.
The driver will generate events over the input layer for hot keys and
radio switches, and over the ACPI netlink layer for other events. The
@@ -221,13 +218,17 @@ procfs notes:
The following commands can be written to the /proc/acpi/ibm/hotkey file:
- echo enable > /proc/acpi/ibm/hotkey -- enable the hot keys feature
- echo disable > /proc/acpi/ibm/hotkey -- disable the hot keys feature
echo 0xffffffff > /proc/acpi/ibm/hotkey -- enable all hot keys
echo 0 > /proc/acpi/ibm/hotkey -- disable all possible hot keys
... any other 8-hex-digit mask ...
echo reset > /proc/acpi/ibm/hotkey -- restore the original mask
+The following commands have been deprecated and will cause the kernel
+to log a warning:
+
+ echo enable > /proc/acpi/ibm/hotkey -- does nothing
+ echo disable > /proc/acpi/ibm/hotkey -- returns an error
+
The procfs interface does not support NVRAM polling control. So as to
maintain maximum bug-to-bug compatibility, it does not report any masks,
nor does it allow one to manipulate the hot key mask when the firmware
@@ -236,12 +237,9 @@ does not support masks at all, even if NVRAM polling is in use.
sysfs notes:
hotkey_bios_enabled:
- Returns the status of the hot keys feature when
- thinkpad-acpi was loaded. Upon module unload, the hot
- key feature status will be restored to this value.
+ DEPRECATED, WILL BE REMOVED SOON.
- 0: hot keys were disabled
- 1: hot keys were enabled (unusual)
+ Returns 0.
hotkey_bios_mask:
Returns the hot keys mask when thinkpad-acpi was loaded.
@@ -249,13 +247,10 @@ sysfs notes:
to this value.
hotkey_enable:
- Enables/disables the hot keys feature in the ACPI
- firmware, and reports current status of the hot keys
- feature. Has no effect on the NVRAM hot key polling
- functionality.
+ DEPRECATED, WILL BE REMOVED SOON.
- 0: disables the hot keys feature / feature disabled
- 1: enables the hot keys feature / feature enabled
+ 0: returns -EPERM
+ 1: does nothing
hotkey_mask:
bit mask to enable driver-handling (and depending on
@@ -1535,3 +1530,7 @@ Sysfs interface changelog:
0x020200: Add poll()/select() support to the following attributes:
hotkey_radio_sw, wakeup_hotunplug_complete, wakeup_reason
+
+0x020300: hotkey enable/disable support removed, attributes
+ hotkey_bios_enabled and hotkey_enable deprecated and
+ marked for removal.
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index badf471..ef6c963 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -22,7 +22,7 @@
*/
#define TPACPI_VERSION "0.22"
-#define TPACPI_SYSFS_VERSION 0x020200
+#define TPACPI_SYSFS_VERSION 0x020300
/*
* Changelog:
@@ -1424,7 +1424,6 @@ static enum { /* Reasons for waking up */
static int hotkey_autosleep_ack;
-static int hotkey_orig_status;
static u32 hotkey_orig_mask;
static u32 hotkey_all_mask;
static u32 hotkey_reserved_mask;
@@ -1571,9 +1570,9 @@ static int hotkey_status_get(int *status)
return 0;
}
-static int hotkey_status_set(int status)
+static int hotkey_status_set(bool enable)
{
- if (!acpi_evalf(hkey_handle, NULL, "MHKC", "vd", status))
+ if (!acpi_evalf(hkey_handle, NULL, "MHKC", "vd", enable ? 1 : 0))
return -EIO;
return 0;
@@ -1889,6 +1888,9 @@ static ssize_t hotkey_enable_show(struct device *dev,
{
int res, status;
+ printk_deprecated_attribute("hotkey_enable",
+ "Hotkey reporting is always enabled");
+
res = hotkey_status_get(&status);
if (res)
return res;
@@ -1901,14 +1903,17 @@ static ssize_t hotkey_enable_store(struct device *dev,
const char *buf, size_t count)
{
unsigned long t;
- int res;
+
+ printk_deprecated_attribute("hotkey_enable",
+ "Hotkeys can be disabled through hotkey_mask");
if (parse_strtoul(buf, 1, &t))
return -EINVAL;
- res = hotkey_status_set(t);
+ if (t == 0)
+ return -EPERM;
- return (res) ? res : count;
+ return count;
}
static struct device_attribute dev_attr_hotkey_enable =
@@ -1964,7 +1969,7 @@ static ssize_t hotkey_bios_enabled_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%d\n", hotkey_orig_status);
+ return sprintf(buf, "0\n");
}
static struct device_attribute dev_attr_hotkey_bios_enabled =
@@ -2243,7 +2248,7 @@ static void hotkey_exit(void)
"restoring original hot key mask\n");
/* no short-circuit boolean operator below! */
if ((hotkey_mask_set(hotkey_orig_mask) |
- hotkey_status_set(hotkey_orig_status)) != 0)
+ hotkey_status_set(false)) != 0)
printk(TPACPI_ERR
"failed to restore hot key mask "
"to BIOS defaults\n");
@@ -2438,10 +2443,6 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
/* hotkey_source_mask *must* be zero for
* the first hotkey_mask_get */
- res = hotkey_status_get(&hotkey_orig_status);
- if (res)
- goto err_exit;
-
if (tp_features.hotkey_mask) {
res = hotkey_mask_get();
if (res)
@@ -2581,7 +2582,7 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
}
dbg_printk(TPACPI_DBG_INIT, "enabling hot key handling\n");
- res = hotkey_status_set(1);
+ res = hotkey_status_set(true);
if (res) {
hotkey_exit();
return res;
@@ -2926,9 +2927,17 @@ static int hotkey_read(char *p)
return len;
}
+static void hotkey_enabledisable_warn(void)
+{
+ tpacpi_log_usertask("procfs hotkey enable/disable");
+ WARN(1, TPACPI_WARN
+ "hotkey enable/disable functionality has been "
+ "removed from the driver. Hotkeys are always enabled.\n");
+}
+
static int hotkey_write(char *buf)
{
- int res, status;
+ int res;
u32 mask;
char *cmd;
@@ -2938,17 +2947,16 @@ static int hotkey_write(char *buf)
if (mutex_lock_killable(&hotkey_mutex))
return -ERESTARTSYS;
- status = -1;
mask = hotkey_mask;
res = 0;
while ((cmd = next_cmd(&buf))) {
if (strlencmp(cmd, "enable") == 0) {
- status = 1;
+ hotkey_enabledisable_warn();
} else if (strlencmp(cmd, "disable") == 0) {
- status = 0;
+ hotkey_enabledisable_warn();
+ res = -EPERM;
} else if (strlencmp(cmd, "reset") == 0) {
- status = hotkey_orig_status;
mask = hotkey_orig_mask;
} else if (sscanf(cmd, "0x%x", &mask) == 1) {
/* mask set */
@@ -2959,9 +2967,6 @@ static int hotkey_write(char *buf)
goto errexit;
}
}
- if (status != -1)
- res = hotkey_status_set(status);
-
if (!res && mask != hotkey_mask)
res = hotkey_mask_set(mask);
--
1.6.2.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 08/12] thinkpad-acpi: restrict access to some firmware LEDs
2009-04-04 4:25 [GIT PATCH] thinkpad-acpi queue for 2.6.30 Henrique de Moraes Holschuh
` (6 preceding siblings ...)
2009-04-04 4:25 ` [PATCH 07/12] thinkpad-acpi: remove HKEY disable functionality Henrique de Moraes Holschuh
@ 2009-04-04 4:25 ` Henrique de Moraes Holschuh
2009-04-04 4:25 ` [PATCH 09/12] thinkpad-acpi: enhanced debugging messages for rfkill subdrivers Henrique de Moraes Holschuh
` (4 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Henrique de Moraes Holschuh @ 2009-04-04 4:25 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi, ibm-acpi-devel, Henrique de Moraes Holschuh
Some of the ThinkPad LEDs indicate critical conditions that can cause
data loss or cause hardware damage when ignored (e.g. force-ejecting
a powered up bay; ignoring a failing battery, or empty battery; force-
undocking with the dock buses still active, etc).
On almost all ThinkPads, LED access is write-only, and the firmware
usually does fire-and-forget signaling on them, so you effectively
lose whatever message the firmware was trying to convey to the user
when you override the LED state, without any chance to restore it.
Restrict access to all LEDs that can convey important alarms, or that
could mislead the user into incorrectly operating the hardware. This
will make the Lenovo engineers less unhappy about the whole issue.
Allow users that really want it to still control all LEDs, it is the
unaware user that we have to worry about.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
---
Documentation/laptops/thinkpad-acpi.txt | 11 +++++
drivers/platform/x86/Kconfig | 24 ++++++++++
drivers/platform/x86/thinkpad_acpi.c | 76 +++++++++++++++++++++++--------
3 files changed, 91 insertions(+), 20 deletions(-)
diff --git a/Documentation/laptops/thinkpad-acpi.txt b/Documentation/laptops/thinkpad-acpi.txt
index de6f14c..bce1d95 100644
--- a/Documentation/laptops/thinkpad-acpi.txt
+++ b/Documentation/laptops/thinkpad-acpi.txt
@@ -901,6 +901,17 @@ some older ThinkPad models, it is possible to query the status of the
LED indicators as well. Newer ThinkPads cannot query the real status
of the LED indicators.
+Because misuse of the LEDs could induce an unaware user to perform
+dangerous actions (like undocking or ejecting a bay device while the
+buses are still active), or mask an important alarm (such as a nearly
+empty battery, or a broken battery), access to most LEDs is
+restricted.
+
+Unrestricted access to all LEDs requires that thinkpad-acpi be
+compiled with the CONFIG_THINKPAD_ACPI_UNSAFE_LEDS option enabled.
+Distributions must never enable this option. Individual users that
+are aware of the consequences are welcome to enabling it.
+
procfs notes:
The available commands are:
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 3608081..d45c6ab 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -226,6 +226,30 @@ config THINKPAD_ACPI_DEBUG
If you are not sure, say N here.
+config THINKPAD_ACPI_UNSAFE_LEDS
+ bool "Allow control of important LEDs (unsafe)"
+ depends on THINKPAD_ACPI
+ default n
+ ---help---
+ Overriding LED state on ThinkPads can mask important
+ firmware alerts (like critical battery condition), or misled
+ the user into damaging the hardware (undocking or ejecting
+ the bay while buses are still active), etc.
+
+ LED control on the ThinkPad is write-only (with very few
+ exceptions on very ancient models), which makes it
+ impossible to know beforehand if important information will
+ be lost when one changes LED state.
+
+ Users that know what they are doing can enable this option
+ and the driver will allow control of every LED, including
+ the ones on the dock stations.
+
+ Never enable this option on a distribution kernel.
+
+ Say N here, unless you are building a kernel for your own
+ use, and need to control the important firmware LEDs.
+
config THINKPAD_ACPI_DOCK
bool "Legacy Docking Station Support"
depends on THINKPAD_ACPI
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index ef6c963..d03b76a 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -4657,6 +4657,16 @@ static const char * const tpacpi_led_names[TPACPI_LED_NUMLEDS] = {
"tpacpi::unknown_led",
"tpacpi::standby",
};
+#define TPACPI_SAFE_LEDS 0x0081U
+
+static inline bool tpacpi_is_led_restricted(const unsigned int led)
+{
+#ifdef CONFIG_THINKPAD_ACPI_UNSAFE_LEDS
+ return false;
+#else
+ return (TPACPI_SAFE_LEDS & (1 << led)) == 0;
+#endif
+}
static int led_get_status(const unsigned int led)
{
@@ -4694,16 +4704,20 @@ static int led_set_status(const unsigned int led,
switch (led_supported) {
case TPACPI_LED_570:
/* 570 */
- if (led > 7)
+ if (unlikely(led > 7))
return -EINVAL;
+ if (unlikely(tpacpi_is_led_restricted(led)))
+ return -EPERM;
if (!acpi_evalf(led_handle, NULL, NULL, "vdd",
(1 << led), led_sled_arg1[ledstatus]))
rc = -EIO;
break;
case TPACPI_LED_OLD:
/* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20 */
- if (led > 7)
+ if (unlikely(led > 7))
return -EINVAL;
+ if (unlikely(tpacpi_is_led_restricted(led)))
+ return -EPERM;
rc = ec_write(TPACPI_LED_EC_HLMS, (1 << led));
if (rc >= 0)
rc = ec_write(TPACPI_LED_EC_HLBL,
@@ -4714,6 +4728,10 @@ static int led_set_status(const unsigned int led,
break;
case TPACPI_LED_NEW:
/* all others */
+ if (unlikely(led >= TPACPI_LED_NUMLEDS))
+ return -EINVAL;
+ if (unlikely(tpacpi_is_led_restricted(led)))
+ return -EPERM;
if (!acpi_evalf(led_handle, NULL, NULL, "vdd",
led, led_led_arg1[ledstatus]))
rc = -EIO;
@@ -4806,6 +4824,30 @@ static void led_exit(void)
kfree(tpacpi_leds);
}
+static int __init tpacpi_init_led(unsigned int led)
+{
+ int rc;
+
+ tpacpi_leds[led].led = led;
+
+ tpacpi_leds[led].led_classdev.brightness_set = &led_sysfs_set;
+ tpacpi_leds[led].led_classdev.blink_set = &led_sysfs_blink_set;
+ if (led_supported == TPACPI_LED_570)
+ tpacpi_leds[led].led_classdev.brightness_get =
+ &led_sysfs_get;
+
+ tpacpi_leds[led].led_classdev.name = tpacpi_led_names[led];
+
+ INIT_WORK(&tpacpi_leds[led].work, led_set_status_worker);
+
+ rc = led_classdev_register(&tpacpi_pdev->dev,
+ &tpacpi_leds[led].led_classdev);
+ if (rc < 0)
+ tpacpi_leds[led].led_classdev.name = NULL;
+
+ return rc;
+}
+
static int __init led_init(struct ibm_init_struct *iibm)
{
unsigned int i;
@@ -4839,27 +4881,21 @@ static int __init led_init(struct ibm_init_struct *iibm)
}
for (i = 0; i < TPACPI_LED_NUMLEDS; i++) {
- tpacpi_leds[i].led = i;
-
- tpacpi_leds[i].led_classdev.brightness_set = &led_sysfs_set;
- tpacpi_leds[i].led_classdev.blink_set = &led_sysfs_blink_set;
- if (led_supported == TPACPI_LED_570)
- tpacpi_leds[i].led_classdev.brightness_get =
- &led_sysfs_get;
-
- tpacpi_leds[i].led_classdev.name = tpacpi_led_names[i];
-
- INIT_WORK(&tpacpi_leds[i].work, led_set_status_worker);
-
- rc = led_classdev_register(&tpacpi_pdev->dev,
- &tpacpi_leds[i].led_classdev);
- if (rc < 0) {
- tpacpi_leds[i].led_classdev.name = NULL;
- led_exit();
- return rc;
+ if (!tpacpi_is_led_restricted(i)) {
+ rc = tpacpi_init_led(i);
+ if (rc < 0) {
+ led_exit();
+ return rc;
+ }
}
}
+#ifdef CONFIG_THINKPAD_ACPI_UNSAFE_LEDS
+ if (led_supported != TPACPI_LED_NONE)
+ printk(TPACPI_NOTICE
+ "warning: userspace override of important "
+ "firmware LEDs is enabled\n");
+#endif
return (led_supported != TPACPI_LED_NONE)? 0 : 1;
}
--
1.6.2.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 09/12] thinkpad-acpi: enhanced debugging messages for rfkill subdrivers
2009-04-04 4:25 [GIT PATCH] thinkpad-acpi queue for 2.6.30 Henrique de Moraes Holschuh
` (7 preceding siblings ...)
2009-04-04 4:25 ` [PATCH 08/12] thinkpad-acpi: restrict access to some firmware LEDs Henrique de Moraes Holschuh
@ 2009-04-04 4:25 ` Henrique de Moraes Holschuh
2009-04-04 4:25 ` [PATCH 10/12] thinkpad-acpi: enhanced debugging messages for the hotkey subdriver Henrique de Moraes Holschuh
` (3 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Henrique de Moraes Holschuh @ 2009-04-04 4:25 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi, ibm-acpi-devel, Henrique de Moraes Holschuh
Enhance debugging messages for all rfkill subdrivers in thinkpad-acpi.
Also, log a warning if the deprecated sysfs attributes are in use.
These attributes are going to be removed sometime in 2010.
There is an user-visible side-effect: we now coalesce attempts to
enable/disable bluetooth or WWAN in the procfs interface, instead of
hammering the firmware with multiple requests.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
---
Documentation/laptops/thinkpad-acpi.txt | 2 +
drivers/platform/x86/thinkpad_acpi.c | 117 +++++++++++++++++++++++++------
2 files changed, 98 insertions(+), 21 deletions(-)
diff --git a/Documentation/laptops/thinkpad-acpi.txt b/Documentation/laptops/thinkpad-acpi.txt
index bce1d95..7daca05 100644
--- a/Documentation/laptops/thinkpad-acpi.txt
+++ b/Documentation/laptops/thinkpad-acpi.txt
@@ -1494,6 +1494,8 @@ to enable more than one output class, just add their values.
accessing some functions of the driver
0x0001 Initialization and probing
0x0002 Removal
+ 0x0004 RF Transmitter control (RFKILL)
+ (bluetooth, WWAN, UWB...)
There is also a kernel build option to enable more debugging
information, which may be necessary to debug driver problems.
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index d03b76a..92fff8d 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -189,6 +189,7 @@ enum {
#define TPACPI_DBG_DISCLOSETASK 0x8000
#define TPACPI_DBG_INIT 0x0001
#define TPACPI_DBG_EXIT 0x0002
+#define TPACPI_DBG_RFKILL 0x0004
#define onoff(status, bit) ((status) & (1 << (bit)) ? "on" : "off")
#define enabled(status, bit) ((status) & (1 << (bit)) ? "enabled" : "disabled")
@@ -1016,10 +1017,13 @@ static int __init tpacpi_new_rfkill(const unsigned int id,
/* try to set the initial state as the default for the rfkill
* type, since we ask the firmware to preserve it across S5 in
* NVRAM */
- rfkill_set_default(rfktype,
+ if (rfkill_set_default(rfktype,
(initial_state == RFKILL_STATE_UNBLOCKED) ?
RFKILL_STATE_UNBLOCKED :
- RFKILL_STATE_SOFT_BLOCKED);
+ RFKILL_STATE_SOFT_BLOCKED) == -EPERM)
+ vdbg_printk(TPACPI_DBG_RFKILL,
+ "Default state for %s cannot be changed\n",
+ name);
}
*rfk = rfkill_allocate(&tpacpi_pdev->dev, rfktype);
@@ -3018,13 +3022,17 @@ enum {
TP_ACPI_BLTH_SAVE_STATE = 0x05, /* Save state for S4/S5 */
};
+#define TPACPI_RFK_BLUETOOTH_SW_NAME "tpacpi_bluetooth_sw"
+
static struct rfkill *tpacpi_bluetooth_rfkill;
static void bluetooth_suspend(pm_message_t state)
{
/* Try to make sure radio will resume powered off */
- acpi_evalf(NULL, NULL, "\\BLTH", "vd",
- TP_ACPI_BLTH_PWR_OFF_ON_RESUME);
+ if (!acpi_evalf(NULL, NULL, "\\BLTH", "vd",
+ TP_ACPI_BLTH_PWR_OFF_ON_RESUME))
+ vdbg_printk(TPACPI_DBG_RFKILL,
+ "bluetooth power down on resume request failed\n");
}
static int bluetooth_get_radiosw(void)
@@ -3062,6 +3070,10 @@ static void bluetooth_update_rfk(void)
if (status < 0)
return;
rfkill_force_state(tpacpi_bluetooth_rfkill, status);
+
+ vdbg_printk(TPACPI_DBG_RFKILL,
+ "forced rfkill state to %d\n",
+ status);
}
static int bluetooth_set_radiosw(int radio_on, int update_rfk)
@@ -3077,6 +3089,9 @@ static int bluetooth_set_radiosw(int radio_on, int update_rfk)
&& radio_on)
return -EPERM;
+ vdbg_printk(TPACPI_DBG_RFKILL,
+ "will %s bluetooth\n", radio_on ? "enable" : "disable");
+
#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
if (dbg_bluetoothemul) {
tpacpi_bluetooth_emulstate = !!radio_on;
@@ -3129,6 +3144,8 @@ static ssize_t bluetooth_enable_store(struct device *dev,
if (parse_strtoul(buf, 1, &t))
return -EINVAL;
+ tpacpi_disclose_usertask("bluetooth_enable", "set to %ld\n", t);
+
res = bluetooth_set_radiosw(t, 1);
return (res) ? res : count;
@@ -3162,6 +3179,8 @@ static int tpacpi_bluetooth_rfk_get(void *data, enum rfkill_state *state)
static int tpacpi_bluetooth_rfk_set(void *data, enum rfkill_state state)
{
+ dbg_printk(TPACPI_DBG_RFKILL,
+ "request to change radio state to %d\n", state);
return bluetooth_set_radiosw((state == RFKILL_STATE_UNBLOCKED), 0);
}
@@ -3172,6 +3191,9 @@ static void bluetooth_shutdown(void)
TP_ACPI_BLTH_SAVE_STATE))
printk(TPACPI_NOTICE
"failed to save bluetooth state to NVRAM\n");
+ else
+ vdbg_printk(TPACPI_DBG_RFKILL,
+ "bluestooth state saved to NVRAM\n");
}
static void bluetooth_exit(void)
@@ -3190,7 +3212,8 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm)
int res;
int status = 0;
- vdbg_printk(TPACPI_DBG_INIT, "initializing bluetooth subdriver\n");
+ vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL,
+ "initializing bluetooth subdriver\n");
TPACPI_ACPIHANDLE_INIT(hkey);
@@ -3199,7 +3222,8 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm)
tp_features.bluetooth = hkey_handle &&
acpi_evalf(hkey_handle, &status, "GBDC", "qd");
- vdbg_printk(TPACPI_DBG_INIT, "bluetooth is %s, status 0x%02x\n",
+ vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL,
+ "bluetooth is %s, status 0x%02x\n",
str_supported(tp_features.bluetooth),
status);
@@ -3214,7 +3238,7 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm)
!(status & TP_ACPI_BLUETOOTH_HWPRESENT)) {
/* no bluetooth hardware present in system */
tp_features.bluetooth = 0;
- dbg_printk(TPACPI_DBG_INIT,
+ dbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL,
"bluetooth hardware not installed\n");
}
@@ -3229,7 +3253,7 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm)
res = tpacpi_new_rfkill(TPACPI_RFK_BLUETOOTH_SW_ID,
&tpacpi_bluetooth_rfkill,
RFKILL_TYPE_BLUETOOTH,
- "tpacpi_bluetooth_sw",
+ TPACPI_RFK_BLUETOOTH_SW_NAME,
true,
tpacpi_bluetooth_rfk_set,
tpacpi_bluetooth_rfk_get);
@@ -3262,19 +3286,27 @@ static int bluetooth_read(char *p)
static int bluetooth_write(char *buf)
{
char *cmd;
+ int state = -1;
if (!tp_features.bluetooth)
return -ENODEV;
while ((cmd = next_cmd(&buf))) {
if (strlencmp(cmd, "enable") == 0) {
- bluetooth_set_radiosw(1, 1);
+ state = 1;
} else if (strlencmp(cmd, "disable") == 0) {
- bluetooth_set_radiosw(0, 1);
+ state = 0;
} else
return -EINVAL;
}
+ if (state != -1) {
+ tpacpi_disclose_usertask("procfs bluetooth",
+ "attempt to %s\n",
+ state ? "enable" : "disable");
+ bluetooth_set_radiosw(state, 1);
+ }
+
return 0;
}
@@ -3299,13 +3331,17 @@ enum {
off / last state */
};
+#define TPACPI_RFK_WWAN_SW_NAME "tpacpi_wwan_sw"
+
static struct rfkill *tpacpi_wan_rfkill;
static void wan_suspend(pm_message_t state)
{
/* Try to make sure radio will resume powered off */
- acpi_evalf(NULL, NULL, "\\WGSV", "qvd",
- TP_ACPI_WGSV_PWR_OFF_ON_RESUME);
+ if (!acpi_evalf(NULL, NULL, "\\WGSV", "qvd",
+ TP_ACPI_WGSV_PWR_OFF_ON_RESUME))
+ vdbg_printk(TPACPI_DBG_RFKILL,
+ "WWAN power down on resume request failed\n");
}
static int wan_get_radiosw(void)
@@ -3343,6 +3379,10 @@ static void wan_update_rfk(void)
if (status < 0)
return;
rfkill_force_state(tpacpi_wan_rfkill, status);
+
+ vdbg_printk(TPACPI_DBG_RFKILL,
+ "forced rfkill state to %d\n",
+ status);
}
static int wan_set_radiosw(int radio_on, int update_rfk)
@@ -3358,6 +3398,9 @@ static int wan_set_radiosw(int radio_on, int update_rfk)
&& radio_on)
return -EPERM;
+ vdbg_printk(TPACPI_DBG_RFKILL,
+ "will %s WWAN\n", radio_on ? "enable" : "disable");
+
#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
if (dbg_wwanemul) {
tpacpi_wwan_emulstate = !!radio_on;
@@ -3410,6 +3453,8 @@ static ssize_t wan_enable_store(struct device *dev,
if (parse_strtoul(buf, 1, &t))
return -EINVAL;
+ tpacpi_disclose_usertask("wwan_enable", "set to %ld\n", t);
+
res = wan_set_radiosw(t, 1);
return (res) ? res : count;
@@ -3443,6 +3488,8 @@ static int tpacpi_wan_rfk_get(void *data, enum rfkill_state *state)
static int tpacpi_wan_rfk_set(void *data, enum rfkill_state state)
{
+ dbg_printk(TPACPI_DBG_RFKILL,
+ "request to change radio state to %d\n", state);
return wan_set_radiosw((state == RFKILL_STATE_UNBLOCKED), 0);
}
@@ -3453,6 +3500,9 @@ static void wan_shutdown(void)
TP_ACPI_WGSV_SAVE_STATE))
printk(TPACPI_NOTICE
"failed to save WWAN state to NVRAM\n");
+ else
+ vdbg_printk(TPACPI_DBG_RFKILL,
+ "WWAN state saved to NVRAM\n");
}
static void wan_exit(void)
@@ -3471,14 +3521,16 @@ static int __init wan_init(struct ibm_init_struct *iibm)
int res;
int status = 0;
- vdbg_printk(TPACPI_DBG_INIT, "initializing wan subdriver\n");
+ vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL,
+ "initializing wan subdriver\n");
TPACPI_ACPIHANDLE_INIT(hkey);
tp_features.wan = hkey_handle &&
acpi_evalf(hkey_handle, &status, "GWAN", "qd");
- vdbg_printk(TPACPI_DBG_INIT, "wan is %s, status 0x%02x\n",
+ vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL,
+ "wan is %s, status 0x%02x\n",
str_supported(tp_features.wan),
status);
@@ -3493,7 +3545,7 @@ static int __init wan_init(struct ibm_init_struct *iibm)
!(status & TP_ACPI_WANCARD_HWPRESENT)) {
/* no wan hardware present in system */
tp_features.wan = 0;
- dbg_printk(TPACPI_DBG_INIT,
+ dbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL,
"wan hardware not installed\n");
}
@@ -3508,7 +3560,7 @@ static int __init wan_init(struct ibm_init_struct *iibm)
res = tpacpi_new_rfkill(TPACPI_RFK_WWAN_SW_ID,
&tpacpi_wan_rfkill,
RFKILL_TYPE_WWAN,
- "tpacpi_wwan_sw",
+ TPACPI_RFK_WWAN_SW_NAME,
true,
tpacpi_wan_rfk_set,
tpacpi_wan_rfk_get);
@@ -3526,6 +3578,8 @@ static int wan_read(char *p)
int len = 0;
int status = wan_get_radiosw();
+ tpacpi_disclose_usertask("procfs wan", "read");
+
if (!tp_features.wan)
len += sprintf(p + len, "status:\t\tnot supported\n");
else {
@@ -3541,19 +3595,27 @@ static int wan_read(char *p)
static int wan_write(char *buf)
{
char *cmd;
+ int state = -1;
if (!tp_features.wan)
return -ENODEV;
while ((cmd = next_cmd(&buf))) {
if (strlencmp(cmd, "enable") == 0) {
- wan_set_radiosw(1, 1);
+ state = 1;
} else if (strlencmp(cmd, "disable") == 0) {
- wan_set_radiosw(0, 1);
+ state = 0;
} else
return -EINVAL;
}
+ if (state != -1) {
+ tpacpi_disclose_usertask("procfs wan",
+ "attempt to %s\n",
+ state ? "enable" : "disable");
+ wan_set_radiosw(state, 1);
+ }
+
return 0;
}
@@ -3576,6 +3638,8 @@ enum {
TP_ACPI_UWB_RADIOSSW = 0x02, /* UWB radio enabled */
};
+#define TPACPI_RFK_UWB_SW_NAME "tpacpi_uwb_sw"
+
static struct rfkill *tpacpi_uwb_rfkill;
static int uwb_get_radiosw(void)
@@ -3613,6 +3677,10 @@ static void uwb_update_rfk(void)
if (status < 0)
return;
rfkill_force_state(tpacpi_uwb_rfkill, status);
+
+ vdbg_printk(TPACPI_DBG_RFKILL,
+ "forced rfkill state to %d\n",
+ status);
}
static int uwb_set_radiosw(int radio_on, int update_rfk)
@@ -3628,6 +3696,9 @@ static int uwb_set_radiosw(int radio_on, int update_rfk)
&& radio_on)
return -EPERM;
+ vdbg_printk(TPACPI_DBG_RFKILL,
+ "will %s UWB\n", radio_on ? "enable" : "disable");
+
#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
if (dbg_uwbemul) {
tpacpi_uwb_emulstate = !!radio_on;
@@ -3662,6 +3733,8 @@ static int tpacpi_uwb_rfk_get(void *data, enum rfkill_state *state)
static int tpacpi_uwb_rfk_set(void *data, enum rfkill_state state)
{
+ dbg_printk(TPACPI_DBG_RFKILL,
+ "request to change radio state to %d\n", state);
return uwb_set_radiosw((state == RFKILL_STATE_UNBLOCKED), 0);
}
@@ -3676,14 +3749,16 @@ static int __init uwb_init(struct ibm_init_struct *iibm)
int res;
int status = 0;
- vdbg_printk(TPACPI_DBG_INIT, "initializing uwb subdriver\n");
+ vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL,
+ "initializing uwb subdriver\n");
TPACPI_ACPIHANDLE_INIT(hkey);
tp_features.uwb = hkey_handle &&
acpi_evalf(hkey_handle, &status, "GUWB", "qd");
- vdbg_printk(TPACPI_DBG_INIT, "uwb is %s, status 0x%02x\n",
+ vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_RFKILL,
+ "uwb is %s, status 0x%02x\n",
str_supported(tp_features.uwb),
status);
@@ -3708,7 +3783,7 @@ static int __init uwb_init(struct ibm_init_struct *iibm)
res = tpacpi_new_rfkill(TPACPI_RFK_UWB_SW_ID,
&tpacpi_uwb_rfkill,
RFKILL_TYPE_UWB,
- "tpacpi_uwb_sw",
+ TPACPI_RFK_UWB_SW_NAME,
false,
tpacpi_uwb_rfk_set,
tpacpi_uwb_rfk_get);
--
1.6.2.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 10/12] thinkpad-acpi: enhanced debugging messages for the hotkey subdriver
2009-04-04 4:25 [GIT PATCH] thinkpad-acpi queue for 2.6.30 Henrique de Moraes Holschuh
` (8 preceding siblings ...)
2009-04-04 4:25 ` [PATCH 09/12] thinkpad-acpi: enhanced debugging messages for rfkill subdrivers Henrique de Moraes Holschuh
@ 2009-04-04 4:25 ` Henrique de Moraes Holschuh
2009-04-04 4:25 ` [PATCH 11/12] thinkpad-acpi: enhanced debugging messages for the fan subdriver Henrique de Moraes Holschuh
` (2 subsequent siblings)
12 siblings, 0 replies; 16+ messages in thread
From: Henrique de Moraes Holschuh @ 2009-04-04 4:25 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi, ibm-acpi-devel, Henrique de Moraes Holschuh
Enhance debugging messages for the hotkey subdriver.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
---
Documentation/laptops/thinkpad-acpi.txt | 1 +
drivers/platform/x86/thinkpad_acpi.c | 39 +++++++++++++++++++++++--------
2 files changed, 30 insertions(+), 10 deletions(-)
diff --git a/Documentation/laptops/thinkpad-acpi.txt b/Documentation/laptops/thinkpad-acpi.txt
index 7daca05..abbbe78 100644
--- a/Documentation/laptops/thinkpad-acpi.txt
+++ b/Documentation/laptops/thinkpad-acpi.txt
@@ -1496,6 +1496,7 @@ to enable more than one output class, just add their values.
0x0002 Removal
0x0004 RF Transmitter control (RFKILL)
(bluetooth, WWAN, UWB...)
+ 0x0008 HKEY event interface, hotkeys
There is also a kernel build option to enable more debugging
information, which may be necessary to debug driver problems.
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 92fff8d..c8bd563 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -190,6 +190,7 @@ enum {
#define TPACPI_DBG_INIT 0x0001
#define TPACPI_DBG_EXIT 0x0002
#define TPACPI_DBG_RFKILL 0x0004
+#define TPACPI_DBG_HKEY 0x0008
#define onoff(status, bit) ((status) & (1 << (bit)) ? "on" : "off")
#define enabled(status, bit) ((status) & (1 << (bit)) ? "enabled" : "disabled")
@@ -1961,6 +1962,8 @@ static ssize_t hotkey_mask_store(struct device *dev,
mutex_unlock(&hotkey_mutex);
+ tpacpi_disclose_usertask("hotkey_mask", "set to 0x%08lx\n", t);
+
return (res) ? res : count;
}
@@ -2047,6 +2050,8 @@ static ssize_t hotkey_source_mask_store(struct device *dev,
mutex_unlock(&hotkey_mutex);
+ tpacpi_disclose_usertask("hotkey_source_mask", "set to 0x%08lx\n", t);
+
return count;
}
@@ -2079,6 +2084,8 @@ static ssize_t hotkey_poll_freq_store(struct device *dev,
hotkey_poll_setup(1);
mutex_unlock(&hotkey_mutex);
+ tpacpi_disclose_usertask("hotkey_poll_freq", "set to %lu\n", t);
+
return count;
}
@@ -2248,7 +2255,7 @@ static void hotkey_exit(void)
kfree(hotkey_keycode_map);
if (tp_features.hotkey) {
- dbg_printk(TPACPI_DBG_EXIT,
+ dbg_printk(TPACPI_DBG_EXIT | TPACPI_DBG_HKEY,
"restoring original hot key mask\n");
/* no short-circuit boolean operator below! */
if ((hotkey_mask_set(hotkey_orig_mask) |
@@ -2378,7 +2385,8 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
int status;
int hkeyv;
- vdbg_printk(TPACPI_DBG_INIT, "initializing hotkey subdriver\n");
+ vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY,
+ "initializing hotkey subdriver\n");
BUG_ON(!tpacpi_inputdev);
BUG_ON(tpacpi_inputdev->open != NULL ||
@@ -2395,7 +2403,8 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
/* hotkey not supported on 570 */
tp_features.hotkey = hkey_handle != NULL;
- vdbg_printk(TPACPI_DBG_INIT, "hotkeys are %s\n",
+ vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY,
+ "hotkeys are %s\n",
str_supported(tp_features.hotkey));
if (!tp_features.hotkey)
@@ -2427,10 +2436,14 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
* T4x, X31, and later
*/
tp_features.hotkey_mask = 1;
+ vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY,
+ "firmware HKEY interface version: 0x%x\n",
+ hkeyv);
}
}
- vdbg_printk(TPACPI_DBG_INIT, "hotkey masks are %s\n",
+ vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY,
+ "hotkey masks are %s\n",
str_supported(tp_features.hotkey_mask));
if (tp_features.hotkey_mask) {
@@ -2469,7 +2482,7 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
hotkey_source_mask = TPACPI_HKEY_NVRAM_GOOD_MASK;
}
- vdbg_printk(TPACPI_DBG_INIT,
+ vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY,
"hotkey source mask 0x%08x, polling freq %d\n",
hotkey_source_mask, hotkey_poll_freq);
#endif
@@ -2523,12 +2536,12 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
}
if (thinkpad_id.vendor == PCI_VENDOR_ID_LENOVO) {
- dbg_printk(TPACPI_DBG_INIT,
+ dbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY,
"using Lenovo default hot key map\n");
memcpy(hotkey_keycode_map, &lenovo_keycode_map,
TPACPI_HOTKEY_MAP_SIZE);
} else {
- dbg_printk(TPACPI_DBG_INIT,
+ dbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY,
"using IBM default hot key map\n");
memcpy(hotkey_keycode_map, &ibm_keycode_map,
TPACPI_HOTKEY_MAP_SIZE);
@@ -2585,7 +2598,8 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
| (1 << TP_ACPI_HOTKEYSCAN_FNEND);
}
- dbg_printk(TPACPI_DBG_INIT, "enabling hot key handling\n");
+ dbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY,
+ "enabling firmware HKEY event interface...\n");
res = hotkey_status_set(true);
if (res) {
hotkey_exit();
@@ -2599,8 +2613,8 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
return res;
}
- dbg_printk(TPACPI_DBG_INIT,
- "legacy hot key reporting over procfs %s\n",
+ dbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY,
+ "legacy ibm/hotkey event reporting over procfs %s\n",
(hotkey_report_mode < 2) ?
"enabled" : "disabled");
@@ -2971,6 +2985,11 @@ static int hotkey_write(char *buf)
goto errexit;
}
}
+
+ if (!res)
+ tpacpi_disclose_usertask("procfs hotkey",
+ "set mask to 0x%08x\n", mask);
+
if (!res && mask != hotkey_mask)
res = hotkey_mask_set(mask);
--
1.6.2.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 11/12] thinkpad-acpi: enhanced debugging messages for the fan subdriver
2009-04-04 4:25 [GIT PATCH] thinkpad-acpi queue for 2.6.30 Henrique de Moraes Holschuh
` (9 preceding siblings ...)
2009-04-04 4:25 ` [PATCH 10/12] thinkpad-acpi: enhanced debugging messages for the hotkey subdriver Henrique de Moraes Holschuh
@ 2009-04-04 4:25 ` Henrique de Moraes Holschuh
[not found] ` <1238819153-16004-1-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
2009-04-04 7:36 ` [GIT PATCH] thinkpad-acpi queue for 2.6.30 Len Brown
12 siblings, 0 replies; 16+ messages in thread
From: Henrique de Moraes Holschuh @ 2009-04-04 4:25 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi, ibm-acpi-devel, Henrique de Moraes Holschuh
Enhance debugging messages for the fan subdriver.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
---
Documentation/laptops/thinkpad-acpi.txt | 1 +
drivers/platform/x86/thinkpad_acpi.c | 46 +++++++++++++++++++++++++++---
2 files changed, 42 insertions(+), 5 deletions(-)
diff --git a/Documentation/laptops/thinkpad-acpi.txt b/Documentation/laptops/thinkpad-acpi.txt
index abbbe78..25ed43d 100644
--- a/Documentation/laptops/thinkpad-acpi.txt
+++ b/Documentation/laptops/thinkpad-acpi.txt
@@ -1497,6 +1497,7 @@ to enable more than one output class, just add their values.
0x0004 RF Transmitter control (RFKILL)
(bluetooth, WWAN, UWB...)
0x0008 HKEY event interface, hotkeys
+ 0x0010 Fan control
There is also a kernel build option to enable more debugging
information, which may be necessary to debug driver problems.
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index c8bd563..27c9480 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -191,6 +191,7 @@ enum {
#define TPACPI_DBG_EXIT 0x0002
#define TPACPI_DBG_RFKILL 0x0004
#define TPACPI_DBG_HKEY 0x0008
+#define TPACPI_DBG_FAN 0x0010
#define onoff(status, bit) ((status) & (1 << (bit)) ? "on" : "off")
#define enabled(status, bit) ((status) & (1 << (bit)) ? "enabled" : "disabled")
@@ -6271,6 +6272,9 @@ static int fan_set_level(int level)
default:
return -ENXIO;
}
+
+ vdbg_printk(TPACPI_DBG_FAN,
+ "fan control: set fan control register to 0x%02x\n", level);
return 0;
}
@@ -6348,6 +6352,11 @@ static int fan_set_enable(void)
}
mutex_unlock(&fan_mutex);
+
+ if (!rc)
+ vdbg_printk(TPACPI_DBG_FAN,
+ "fan control: set fan control register to 0x%02x\n",
+ s);
return rc;
}
@@ -6384,6 +6393,9 @@ static int fan_set_disable(void)
rc = -ENXIO;
}
+ if (!rc)
+ vdbg_printk(TPACPI_DBG_FAN,
+ "fan control: set fan control register to 0\n");
mutex_unlock(&fan_mutex);
return rc;
@@ -6512,6 +6524,9 @@ static ssize_t fan_pwm1_enable_store(struct device *dev,
if (parse_strtoul(buf, 2, &t))
return -EINVAL;
+ tpacpi_disclose_usertask("hwmon pwm1_enable",
+ "set fan mode to %lu\n", t);
+
switch (t) {
case 0:
level = TP_EC_FAN_FULLSPEED;
@@ -6577,6 +6592,9 @@ static ssize_t fan_pwm1_store(struct device *dev,
if (parse_strtoul(buf, 255, &s))
return -EINVAL;
+ tpacpi_disclose_usertask("hwmon pwm1",
+ "set fan speed to %lu\n", s);
+
/* scale down from 0-255 to 0-7 */
newlevel = (s >> 5) & 0x07;
@@ -6643,6 +6661,8 @@ static ssize_t fan_fan_watchdog_store(struct device_driver *drv,
fan_watchdog_maxinterval = t;
fan_watchdog_reset();
+ tpacpi_disclose_usertask("fan_watchdog", "set to %lu\n", t);
+
return count;
}
@@ -6664,7 +6684,8 @@ static int __init fan_init(struct ibm_init_struct *iibm)
{
int rc;
- vdbg_printk(TPACPI_DBG_INIT, "initializing fan subdriver\n");
+ vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_FAN,
+ "initializing fan subdriver\n");
mutex_init(&fan_mutex);
fan_status_access_mode = TPACPI_FAN_NONE;
@@ -6723,7 +6744,8 @@ static int __init fan_init(struct ibm_init_struct *iibm)
}
}
- vdbg_printk(TPACPI_DBG_INIT, "fan is %s, modes %d, %d\n",
+ vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_FAN,
+ "fan is %s, modes %d, %d\n",
str_supported(fan_status_access_mode != TPACPI_FAN_NONE ||
fan_control_access_mode != TPACPI_FAN_WR_NONE),
fan_status_access_mode, fan_control_access_mode);
@@ -6732,7 +6754,7 @@ static int __init fan_init(struct ibm_init_struct *iibm)
if (!fan_control_allowed) {
fan_control_access_mode = TPACPI_FAN_WR_NONE;
fan_control_commands = 0;
- dbg_printk(TPACPI_DBG_INIT,
+ dbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_FAN,
"fan control features disabled by parameter\n");
}
@@ -6761,7 +6783,7 @@ static int __init fan_init(struct ibm_init_struct *iibm)
static void fan_exit(void)
{
- vdbg_printk(TPACPI_DBG_EXIT,
+ vdbg_printk(TPACPI_DBG_EXIT | TPACPI_DBG_FAN,
"cancelling any pending fan watchdog tasks\n");
/* FIXME: can we really do this unconditionally? */
@@ -6942,6 +6964,9 @@ static int fan_write_cmd_level(const char *cmd, int *rc)
if (*rc == -ENXIO)
printk(TPACPI_ERR "level command accepted for unsupported "
"access mode %d", fan_control_access_mode);
+ else if (!*rc)
+ tpacpi_disclose_usertask("procfs fan",
+ "set level to %d\n", level);
return 1;
}
@@ -6955,6 +6980,8 @@ static int fan_write_cmd_enable(const char *cmd, int *rc)
if (*rc == -ENXIO)
printk(TPACPI_ERR "enable command accepted for unsupported "
"access mode %d", fan_control_access_mode);
+ else if (!*rc)
+ tpacpi_disclose_usertask("procfs fan", "enable\n");
return 1;
}
@@ -6968,6 +6995,8 @@ static int fan_write_cmd_disable(const char *cmd, int *rc)
if (*rc == -ENXIO)
printk(TPACPI_ERR "disable command accepted for unsupported "
"access mode %d", fan_control_access_mode);
+ else if (!*rc)
+ tpacpi_disclose_usertask("procfs fan", "disable\n");
return 1;
}
@@ -6986,6 +7015,9 @@ static int fan_write_cmd_speed(const char *cmd, int *rc)
if (*rc == -ENXIO)
printk(TPACPI_ERR "speed command accepted for unsupported "
"access mode %d", fan_control_access_mode);
+ else if (!*rc)
+ tpacpi_disclose_usertask("procfs fan",
+ "set speed to %d\n", speed);
return 1;
}
@@ -6999,8 +7031,12 @@ static int fan_write_cmd_watchdog(const char *cmd, int *rc)
if (interval < 0 || interval > 120)
*rc = -EINVAL;
- else
+ else {
fan_watchdog_maxinterval = interval;
+ tpacpi_disclose_usertask("procfs fan",
+ "set watchdog timer to %d\n",
+ interval);
+ }
return 1;
}
--
1.6.2.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 12/12] thinkpad-acpi: rework brightness support
[not found] ` <1238819153-16004-1-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
@ 2009-04-04 4:25 ` Henrique de Moraes Holschuh
0 siblings, 0 replies; 16+ messages in thread
From: Henrique de Moraes Holschuh @ 2009-04-04 4:25 UTC (permalink / raw)
To: Len Brown
Cc: linux-acpi-u79uwXL29TY76Z2rM5mHXA, Henrique de Moraes Holschuh,
ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Refactor and redesign the brightness control backend...
In order to fix bugzilla #11750...
Add a new brightness control mode: support direct NVRAM checkpointing
of the backlight level (i.e. store directly to NVRAM without the need
for UCMS calls), and use that together with the EC-based control.
Disallow UCMS+EC, thus avoiding races with the SMM firmware.
Switch the models that define HBRV (EC Brightness Value) in the DSDT
to the new mode. These are: T40-T43, R50-R52, R50e, R51e, X31-X41.
Change the default for all other IBM ThinkPads to UCMS-only. The
Lenovo models already default to UCMS-only.
Reported-by: Alexey Fisher <bug-track-M18mAb7Tlt0yCq4wW13eYl6hYfS7NtTn@public.gmane.org>
Signed-off-by: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
---
Documentation/laptops/thinkpad-acpi.txt | 12 +-
drivers/platform/x86/thinkpad_acpi.c | 317 +++++++++++++++++++++----------
2 files changed, 227 insertions(+), 102 deletions(-)
diff --git a/Documentation/laptops/thinkpad-acpi.txt b/Documentation/laptops/thinkpad-acpi.txt
index 25ed43d..3d76507 100644
--- a/Documentation/laptops/thinkpad-acpi.txt
+++ b/Documentation/laptops/thinkpad-acpi.txt
@@ -1157,10 +1157,15 @@ display backlight brightness control methods have 16 levels, ranging
from 0 to 15.
There are two interfaces to the firmware for direct brightness control,
-EC and CMOS. To select which one should be used, use the
+EC and UCMS (or CMOS). To select which one should be used, use the
brightness_mode module parameter: brightness_mode=1 selects EC mode,
-brightness_mode=2 selects CMOS mode, brightness_mode=3 selects both EC
-and CMOS. The driver tries to auto-detect which interface to use.
+brightness_mode=2 selects UCMS mode, brightness_mode=3 selects EC
+mode with NVRAM backing (so that brightness changes are remembered
+across shutdown/reboot).
+
+The driver tries to select which interface to use from a table of
+defaults for each ThinkPad model. If it makes a wrong choice, please
+report this as a bug, so that we can fix it.
When display backlight brightness controls are available through the
standard ACPI interface, it is best to use it instead of this direct
@@ -1498,6 +1503,7 @@ to enable more than one output class, just add their values.
(bluetooth, WWAN, UWB...)
0x0008 HKEY event interface, hotkeys
0x0010 Fan control
+ 0x0020 Backlight brightness
There is also a kernel build option to enable more debugging
information, which may be necessary to debug driver problems.
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 27c9480..a40b075 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -192,6 +192,7 @@ enum {
#define TPACPI_DBG_RFKILL 0x0004
#define TPACPI_DBG_HKEY 0x0008
#define TPACPI_DBG_FAN 0x0010
+#define TPACPI_DBG_BRGHT 0x0020
#define onoff(status, bit) ((status) & (1 << (bit)) ? "on" : "off")
#define enabled(status, bit) ((status) & (1 << (bit)) ? "enabled" : "disabled")
@@ -274,7 +275,6 @@ static struct {
static struct {
u16 hotkey_mask_ff:1;
- u16 bright_cmos_ec_unsync:1;
} tp_warned;
struct thinkpad_id_data {
@@ -5526,6 +5526,20 @@ static struct ibm_struct ecdump_driver_data = {
#define TPACPI_BACKLIGHT_DEV_NAME "thinkpad_screen"
+/*
+ * ThinkPads can read brightness from two places: EC HBRV (0x31), or
+ * CMOS NVRAM byte 0x5E, bits 0-3.
+ *
+ * EC HBRV (0x31) has the following layout
+ * Bit 7: unknown function
+ * Bit 6: unknown function
+ * Bit 5: Z: honour scale changes, NZ: ignore scale changes
+ * Bit 4: must be set to zero to avoid problems
+ * Bit 3-0: backlight brightness level
+ *
+ * brightness_get_raw returns status data in the HBRV layout
+ */
+
enum {
TP_EC_BACKLIGHT = 0x31,
@@ -5535,108 +5549,164 @@ enum {
TP_EC_BACKLIGHT_MAPSW = 0x20,
};
+enum tpacpi_brightness_access_mode {
+ TPACPI_BRGHT_MODE_AUTO = 0, /* Not implemented yet */
+ TPACPI_BRGHT_MODE_EC, /* EC control */
+ TPACPI_BRGHT_MODE_UCMS_STEP, /* UCMS step-based control */
+ TPACPI_BRGHT_MODE_ECNVRAM, /* EC control w/ NVRAM store */
+ TPACPI_BRGHT_MODE_MAX
+};
+
static struct backlight_device *ibm_backlight_device;
-static int brightness_mode;
+
+static enum tpacpi_brightness_access_mode brightness_mode =
+ TPACPI_BRGHT_MODE_MAX;
+
static unsigned int brightness_enable = 2; /* 2 = auto, 0 = no, 1 = yes */
static struct mutex brightness_mutex;
-/*
- * ThinkPads can read brightness from two places: EC 0x31, or
- * CMOS NVRAM byte 0x5E, bits 0-3.
- *
- * EC 0x31 has the following layout
- * Bit 7: unknown function
- * Bit 6: unknown function
- * Bit 5: Z: honour scale changes, NZ: ignore scale changes
- * Bit 4: must be set to zero to avoid problems
- * Bit 3-0: backlight brightness level
- *
- * brightness_get_raw returns status data in the EC 0x31 layout
- */
-static int brightness_get_raw(int *status)
+/* NVRAM brightness access,
+ * call with brightness_mutex held! */
+static unsigned int tpacpi_brightness_nvram_get(void)
{
- u8 lec = 0, lcmos = 0, level = 0;
+ u8 lnvram;
- if (brightness_mode & 1) {
- if (!acpi_ec_read(TP_EC_BACKLIGHT, &lec))
- return -EIO;
- level = lec & TP_EC_BACKLIGHT_LVLMSK;
- };
- if (brightness_mode & 2) {
- lcmos = (nvram_read_byte(TP_NVRAM_ADDR_BRIGHTNESS)
- & TP_NVRAM_MASK_LEVEL_BRIGHTNESS)
- >> TP_NVRAM_POS_LEVEL_BRIGHTNESS;
- lcmos &= (tp_features.bright_16levels)? 0x0f : 0x07;
- level = lcmos;
- }
-
- if (brightness_mode == 3) {
- *status = lec; /* Prefer EC, CMOS is just a backing store */
- lec &= TP_EC_BACKLIGHT_LVLMSK;
- if (lec == lcmos)
- tp_warned.bright_cmos_ec_unsync = 0;
- else {
- if (!tp_warned.bright_cmos_ec_unsync) {
- printk(TPACPI_ERR
- "CMOS NVRAM (%u) and EC (%u) do not "
- "agree on display brightness level\n",
- (unsigned int) lcmos,
- (unsigned int) lec);
- tp_warned.bright_cmos_ec_unsync = 1;
- }
+ lnvram = (nvram_read_byte(TP_NVRAM_ADDR_BRIGHTNESS)
+ & TP_NVRAM_MASK_LEVEL_BRIGHTNESS)
+ >> TP_NVRAM_POS_LEVEL_BRIGHTNESS;
+ lnvram &= (tp_features.bright_16levels) ? 0x0f : 0x07;
+
+ return lnvram;
+}
+
+static void tpacpi_brightness_checkpoint_nvram(void)
+{
+ u8 lec = 0;
+ u8 b_nvram;
+
+ if (brightness_mode != TPACPI_BRGHT_MODE_ECNVRAM)
+ return;
+
+ vdbg_printk(TPACPI_DBG_BRGHT,
+ "trying to checkpoint backlight level to NVRAM...\n");
+
+ if (mutex_lock_killable(&brightness_mutex) < 0)
+ return;
+
+ if (unlikely(!acpi_ec_read(TP_EC_BACKLIGHT, &lec)))
+ goto unlock;
+ lec &= TP_EC_BACKLIGHT_LVLMSK;
+ b_nvram = nvram_read_byte(TP_NVRAM_ADDR_BRIGHTNESS);
+
+ if (lec != ((b_nvram & TP_NVRAM_MASK_LEVEL_BRIGHTNESS)
+ >> TP_NVRAM_POS_LEVEL_BRIGHTNESS)) {
+ /* NVRAM needs update */
+ b_nvram &= ~(TP_NVRAM_MASK_LEVEL_BRIGHTNESS <<
+ TP_NVRAM_POS_LEVEL_BRIGHTNESS);
+ b_nvram |= lec;
+ nvram_write_byte(b_nvram, TP_NVRAM_ADDR_BRIGHTNESS);
+ dbg_printk(TPACPI_DBG_BRGHT,
+ "updated NVRAM backlight level to %u (0x%02x)\n",
+ (unsigned int) lec, (unsigned int) b_nvram);
+ } else
+ vdbg_printk(TPACPI_DBG_BRGHT,
+ "NVRAM backlight level already is %u (0x%02x)\n",
+ (unsigned int) lec, (unsigned int) b_nvram);
+
+unlock:
+ mutex_unlock(&brightness_mutex);
+}
+
+
+/* call with brightness_mutex held! */
+static int tpacpi_brightness_get_raw(int *status)
+{
+ u8 lec = 0;
+
+ switch (brightness_mode) {
+ case TPACPI_BRGHT_MODE_UCMS_STEP:
+ *status = tpacpi_brightness_nvram_get();
+ return 0;
+ case TPACPI_BRGHT_MODE_EC:
+ case TPACPI_BRGHT_MODE_ECNVRAM:
+ if (unlikely(!acpi_ec_read(TP_EC_BACKLIGHT, &lec)))
return -EIO;
- }
- } else {
- *status = level;
+ *status = lec;
+ return 0;
+ default:
+ return -ENXIO;
}
+}
+
+/* call with brightness_mutex held! */
+/* do NOT call with illegal backlight level value */
+static int tpacpi_brightness_set_ec(unsigned int value)
+{
+ u8 lec = 0;
+
+ if (unlikely(!acpi_ec_read(TP_EC_BACKLIGHT, &lec)))
+ return -EIO;
+
+ if (unlikely(!acpi_ec_write(TP_EC_BACKLIGHT,
+ (lec & TP_EC_BACKLIGHT_CMDMSK) |
+ (value & TP_EC_BACKLIGHT_LVLMSK))))
+ return -EIO;
+
+ return 0;
+}
+
+/* call with brightness_mutex held! */
+static int tpacpi_brightness_set_ucmsstep(unsigned int value)
+{
+ int cmos_cmd, inc;
+ unsigned int current_value, i;
+
+ current_value = tpacpi_brightness_nvram_get();
+
+ if (value == current_value)
+ return 0;
+
+ cmos_cmd = (value > current_value) ?
+ TP_CMOS_BRIGHTNESS_UP :
+ TP_CMOS_BRIGHTNESS_DOWN;
+ inc = (value > current_value) ? 1 : -1;
+
+ for (i = current_value; i != value; i += inc)
+ if (issue_thinkpad_cmos_command(cmos_cmd))
+ return -EIO;
return 0;
}
/* May return EINTR which can always be mapped to ERESTARTSYS */
-static int brightness_set(int value)
+static int brightness_set(unsigned int value)
{
- int cmos_cmd, inc, i, res;
- int current_value;
- int command_bits;
+ int res;
if (value > ((tp_features.bright_16levels)? 15 : 7) ||
value < 0)
return -EINVAL;
+ vdbg_printk(TPACPI_DBG_BRGHT,
+ "set backlight level to %d\n", value);
+
res = mutex_lock_killable(&brightness_mutex);
if (res < 0)
return res;
- res = brightness_get_raw(¤t_value);
- if (res < 0)
- goto errout;
-
- command_bits = current_value & TP_EC_BACKLIGHT_CMDMSK;
- current_value &= TP_EC_BACKLIGHT_LVLMSK;
-
- cmos_cmd = value > current_value ?
- TP_CMOS_BRIGHTNESS_UP :
- TP_CMOS_BRIGHTNESS_DOWN;
- inc = (value > current_value)? 1 : -1;
-
- res = 0;
- for (i = current_value; i != value; i += inc) {
- if ((brightness_mode & 2) &&
- issue_thinkpad_cmos_command(cmos_cmd)) {
- res = -EIO;
- goto errout;
- }
- if ((brightness_mode & 1) &&
- !acpi_ec_write(TP_EC_BACKLIGHT,
- (i + inc) | command_bits)) {
- res = -EIO;
- goto errout;;
- }
+ switch (brightness_mode) {
+ case TPACPI_BRGHT_MODE_EC:
+ case TPACPI_BRGHT_MODE_ECNVRAM:
+ res = tpacpi_brightness_set_ec(value);
+ break;
+ case TPACPI_BRGHT_MODE_UCMS_STEP:
+ res = tpacpi_brightness_set_ucmsstep(value);
+ break;
+ default:
+ res = -ENXIO;
}
-errout:
mutex_unlock(&brightness_mutex);
return res;
}
@@ -5645,21 +5715,34 @@ errout:
static int brightness_update_status(struct backlight_device *bd)
{
- /* it is the backlight class's job (caller) to handle
- * EINTR and other errors properly */
- return brightness_set(
+ unsigned int level =
(bd->props.fb_blank == FB_BLANK_UNBLANK &&
bd->props.power == FB_BLANK_UNBLANK) ?
- bd->props.brightness : 0);
+ bd->props.brightness : 0;
+
+ dbg_printk(TPACPI_DBG_BRGHT,
+ "backlight: attempt to set level to %d\n",
+ level);
+
+ /* it is the backlight class's job (caller) to handle
+ * EINTR and other errors properly */
+ return brightness_set(level);
}
static int brightness_get(struct backlight_device *bd)
{
int status, res;
- res = brightness_get_raw(&status);
+ res = mutex_lock_killable(&brightness_mutex);
if (res < 0)
- return 0; /* FIXME: teach backlight about error handling */
+ return 0;
+
+ res = tpacpi_brightness_get_raw(&status);
+
+ mutex_unlock(&brightness_mutex);
+
+ if (res < 0)
+ return 0;
return status & TP_EC_BACKLIGHT_LVLMSK;
}
@@ -5709,7 +5792,7 @@ static int __init brightness_init(struct ibm_init_struct *iibm)
}
if (!brightness_enable) {
- dbg_printk(TPACPI_DBG_INIT,
+ dbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_BRGHT,
"brightness support disabled by "
"module parameter\n");
return 1;
@@ -5724,20 +5807,38 @@ static int __init brightness_init(struct ibm_init_struct *iibm)
if (b == 16)
tp_features.bright_16levels = 1;
- if (!brightness_mode) {
- if (thinkpad_id.vendor == PCI_VENDOR_ID_LENOVO)
- brightness_mode = 2;
- else
- brightness_mode = 3;
+ /*
+ * Check for module parameter bogosity, note that we
+ * init brightness_mode to TPACPI_BRGHT_MODE_MAX in order to be
+ * able to detect "unspecified"
+ */
+ if (brightness_mode > TPACPI_BRGHT_MODE_MAX)
+ return -EINVAL;
- dbg_printk(TPACPI_DBG_INIT, "selected brightness_mode=%d\n",
- brightness_mode);
- }
+ /* TPACPI_BRGHT_MODE_AUTO not implemented yet, just use default */
+ if (brightness_mode == TPACPI_BRGHT_MODE_AUTO ||
+ brightness_mode == TPACPI_BRGHT_MODE_MAX) {
+ if (thinkpad_id.vendor == PCI_VENDOR_ID_IBM) {
+ /*
+ * IBM models that define HBRV probably have
+ * EC-based backlight level control
+ */
+ if (acpi_evalf(ec_handle, NULL, "HBRV", "qd"))
+ /* T40-T43, R50-R52, R50e, R51e, X31-X41 */
+ brightness_mode = TPACPI_BRGHT_MODE_ECNVRAM;
+ else
+ /* all other IBM ThinkPads */
+ brightness_mode = TPACPI_BRGHT_MODE_UCMS_STEP;
+ } else
+ /* All Lenovo ThinkPads */
+ brightness_mode = TPACPI_BRGHT_MODE_UCMS_STEP;
- if (brightness_mode > 3)
- return -EINVAL;
+ dbg_printk(TPACPI_DBG_BRGHT,
+ "selected brightness_mode=%d\n",
+ brightness_mode);
+ }
- if (brightness_get_raw(&b) < 0)
+ if (tpacpi_brightness_get_raw(&b) < 0)
return 1;
if (tp_features.bright_16levels)
@@ -5751,7 +5852,8 @@ static int __init brightness_init(struct ibm_init_struct *iibm)
printk(TPACPI_ERR "Could not register backlight device\n");
return PTR_ERR(ibm_backlight_device);
}
- vdbg_printk(TPACPI_DBG_INIT, "brightness is supported\n");
+ vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_BRGHT,
+ "brightness is supported\n");
ibm_backlight_device->props.max_brightness =
(tp_features.bright_16levels)? 15 : 7;
@@ -5761,13 +5863,25 @@ static int __init brightness_init(struct ibm_init_struct *iibm)
return 0;
}
+static void brightness_suspend(pm_message_t state)
+{
+ tpacpi_brightness_checkpoint_nvram();
+}
+
+static void brightness_shutdown(void)
+{
+ tpacpi_brightness_checkpoint_nvram();
+}
+
static void brightness_exit(void)
{
if (ibm_backlight_device) {
- vdbg_printk(TPACPI_DBG_EXIT,
+ vdbg_printk(TPACPI_DBG_EXIT | TPACPI_DBG_BRGHT,
"calling backlight_device_unregister()\n");
backlight_device_unregister(ibm_backlight_device);
}
+
+ tpacpi_brightness_checkpoint_nvram();
}
static int brightness_read(char *p)
@@ -5814,6 +5928,9 @@ static int brightness_write(char *buf)
return -EINVAL;
}
+ tpacpi_disclose_usertask("procfs brightness",
+ "set level to %d\n", level);
+
/*
* Now we know what the final level should be, so we try to set it.
* Doing it this way makes the syscall restartable in case of EINTR
@@ -5827,6 +5944,8 @@ static struct ibm_struct brightness_driver_data = {
.read = brightness_read,
.write = brightness_write,
.exit = brightness_exit,
+ .suspend = brightness_suspend,
+ .shutdown = brightness_shutdown,
};
/*************************************************************************
@@ -7464,10 +7583,10 @@ module_param_named(fan_control, fan_control_allowed, bool, 0);
MODULE_PARM_DESC(fan_control,
"Enables setting fan parameters features when true");
-module_param_named(brightness_mode, brightness_mode, int, 0);
+module_param_named(brightness_mode, brightness_mode, uint, 0);
MODULE_PARM_DESC(brightness_mode,
"Selects brightness control strategy: "
- "0=auto, 1=EC, 2=CMOS, 3=both");
+ "0=auto, 1=EC, 2=UCMS, 3=EC+NVRAM");
module_param(brightness_enable, uint, 0);
MODULE_PARM_DESC(brightness_enable,
--
1.6.2.1
------------------------------------------------------------------------------
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [GIT PATCH] thinkpad-acpi queue for 2.6.30
2009-04-04 4:25 [GIT PATCH] thinkpad-acpi queue for 2.6.30 Henrique de Moraes Holschuh
` (11 preceding siblings ...)
[not found] ` <1238819153-16004-1-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
@ 2009-04-04 7:36 ` Len Brown
12 siblings, 0 replies; 16+ messages in thread
From: Len Brown @ 2009-04-04 7:36 UTC (permalink / raw)
To: Henrique de Moraes Holschuh; +Cc: linux-acpi, ibm-acpi-devel
applied
thanks,
Len Brown, Intel Open Source Technology Center
On Sat, 4 Apr 2009, Henrique de Moraes Holschuh wrote:
> Len,
>
> This patchset has the changes for thinkpad-acpi that I would like to
> see merged for 2.6.30 (while the window is still open).
>
> It contains the patch for
> http://bugzilla.kernel.org/show_bug.cgi?id=11750, and a few
> enhancements.
>
> Shortlog:
>
> Henrique de Moraes Holschuh (12):
> thinkpad-acpi: update copyright notices
> thinkpad-acpi: drop ibm-acpi alias
> thinkpad-acpi: documentation cleanup
> thinkpad-acpi: cleanup debug helpers
> thinkpad-acpi: add missing log levels
> thinkpad-acpi: add new debug helpers and warn of deprecated atts
> thinkpad-acpi: remove HKEY disable functionality
> thinkpad-acpi: restrict access to some firmware LEDs
> thinkpad-acpi: enhanced debugging messages for rfkill subdrivers
> thinkpad-acpi: enhanced debugging messages for the hotkey subdriver
> thinkpad-acpi: enhanced debugging messages for the fan subdriver
> thinkpad-acpi: rework brightness support
>
> --
> "One disk to rule them all, One disk to find them. One disk to bring
> them all and in the darkness grind them. In the Land of Redmond
> where the shadows lie." -- The Silicon Valley Tarot
> Henrique Holschuh
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* remove HKEY disable functionality (triggers Ubuntu Karmic regression)
2009-04-04 4:25 ` [PATCH 07/12] thinkpad-acpi: remove HKEY disable functionality Henrique de Moraes Holschuh
@ 2009-10-29 6:58 ` Mark Stosberg
2009-10-29 22:46 ` Henrique de Moraes Holschuh
0 siblings, 1 reply; 16+ messages in thread
From: Mark Stosberg @ 2009-10-29 6:58 UTC (permalink / raw)
To: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Cc: linux-acpi-u79uwXL29TY76Z2rM5mHXA
Hello,
The following patch is involved in a regression for a number of Ubuntu Karmic
Koala users. There is apparently still a few bits of code in Ubuntu that
trigger this issue and will ultimately need to be updated. Ubuntu also has some
kind of tool that monitors for kernel warnings and reports them to users with a
scary warning:
"Your system might become unstable now and might need to be restarted."
It seems I get this "kernel oops" warning at least once a day.
With the release of Karmic upon us, perhaps there a short term fix that
can be made, like making the warning level less severe.
Here's a link to the Ubuntu bug report about it:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/430361
I appreciate your work on the related drivers and hope that you help us
resolve this.
Thanks!
Mark
On Sat, 4 Apr 2009 01:25:48 -0300
Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org> wrote:
> The HKEY disable functionality basically cripples the entire event
> model of the ThinkPad firmware and of the thinkpad-acpi driver.
> Remove this functionality from the driver. HKEY must be enabled at
> all times while thinkpad-acpi is loaded, and disabled otherwise.
>
> For sysfs, according to the sysfs ABI and the thinkpad-acpi sysfs
> rules of engagement, we will just remove the attributes. This will be
> done in two stages: disable their function now, after two kernel
> releases, remove the attributes.
>
> For procfs, we call WARN(). If nothing triggers it, I will simply
> remove the enable/disable commands entirely in the future along with
> the sysfs attributes.
>
> I don't expect much, if any fallout from this. There really isn't any
> reason to mess with hotkey_enable or with the enable/disable commands
> to /proc/acpi/ibm/hotkey, and this has been true for years...
>
> Signed-off-by: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
> ---
> Documentation/laptops/thinkpad-acpi.txt | 39 ++++++++++++------------
> drivers/platform/x86/thinkpad_acpi.c | 49 +++++++++++++++++--------------
> 2 files changed, 46 insertions(+), 42 deletions(-)
>
> diff --git a/Documentation/laptops/thinkpad-acpi.txt b/Documentation/laptops/thinkpad-acpi.txt
> index e8f52fb..de6f14c 100644
> --- a/Documentation/laptops/thinkpad-acpi.txt
> +++ b/Documentation/laptops/thinkpad-acpi.txt
> @@ -179,17 +179,14 @@ system. Enabling the hotkey functionality of thinkpad-acpi signals the
> firmware that such a driver is present, and modifies how the ThinkPad
> firmware will behave in many situations.
>
> -The driver enables the hot key feature automatically when loaded. The
> -feature can later be disabled and enabled back at runtime. The driver
> -will also restore the hot key feature to its previous state and mask
> -when it is unloaded.
> +The driver enables the HKEY ("hot key") event reporting automatically
> +when loaded, and disables it when it is removed.
>
> -When the hotkey feature is enabled and the hot key mask is set (see
> -below), the driver will report HKEY events in the following format:
> +The driver will report HKEY events in the following format:
>
> ibm/hotkey HKEY 00000080 0000xxxx
>
> -Some of these events refer to hot key presses, but not all.
> +Some of these events refer to hot key presses, but not all of them.
>
> The driver will generate events over the input layer for hot keys and
> radio switches, and over the ACPI netlink layer for other events. The
> @@ -221,13 +218,17 @@ procfs notes:
>
> The following commands can be written to the /proc/acpi/ibm/hotkey file:
>
> - echo enable > /proc/acpi/ibm/hotkey -- enable the hot keys feature
> - echo disable > /proc/acpi/ibm/hotkey -- disable the hot keys feature
> echo 0xffffffff > /proc/acpi/ibm/hotkey -- enable all hot keys
> echo 0 > /proc/acpi/ibm/hotkey -- disable all possible hot keys
> ... any other 8-hex-digit mask ...
> echo reset > /proc/acpi/ibm/hotkey -- restore the original mask
>
> +The following commands have been deprecated and will cause the kernel
> +to log a warning:
> +
> + echo enable > /proc/acpi/ibm/hotkey -- does nothing
> + echo disable > /proc/acpi/ibm/hotkey -- returns an error
> +
> The procfs interface does not support NVRAM polling control. So as to
> maintain maximum bug-to-bug compatibility, it does not report any masks,
> nor does it allow one to manipulate the hot key mask when the firmware
> @@ -236,12 +237,9 @@ does not support masks at all, even if NVRAM polling is in use.
> sysfs notes:
>
> hotkey_bios_enabled:
> - Returns the status of the hot keys feature when
> - thinkpad-acpi was loaded. Upon module unload, the hot
> - key feature status will be restored to this value.
> + DEPRECATED, WILL BE REMOVED SOON.
>
> - 0: hot keys were disabled
> - 1: hot keys were enabled (unusual)
> + Returns 0.
>
> hotkey_bios_mask:
> Returns the hot keys mask when thinkpad-acpi was loaded.
> @@ -249,13 +247,10 @@ sysfs notes:
> to this value.
>
> hotkey_enable:
> - Enables/disables the hot keys feature in the ACPI
> - firmware, and reports current status of the hot keys
> - feature. Has no effect on the NVRAM hot key polling
> - functionality.
> + DEPRECATED, WILL BE REMOVED SOON.
>
> - 0: disables the hot keys feature / feature disabled
> - 1: enables the hot keys feature / feature enabled
> + 0: returns -EPERM
> + 1: does nothing
>
> hotkey_mask:
> bit mask to enable driver-handling (and depending on
> @@ -1535,3 +1530,7 @@ Sysfs interface changelog:
>
> 0x020200: Add poll()/select() support to the following attributes:
> hotkey_radio_sw, wakeup_hotunplug_complete, wakeup_reason
> +
> +0x020300: hotkey enable/disable support removed, attributes
> + hotkey_bios_enabled and hotkey_enable deprecated and
> + marked for removal.
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index badf471..ef6c963 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -22,7 +22,7 @@
> */
>
> #define TPACPI_VERSION "0.22"
> -#define TPACPI_SYSFS_VERSION 0x020200
> +#define TPACPI_SYSFS_VERSION 0x020300
>
> /*
> * Changelog:
> @@ -1424,7 +1424,6 @@ static enum { /* Reasons for waking up */
>
> static int hotkey_autosleep_ack;
>
> -static int hotkey_orig_status;
> static u32 hotkey_orig_mask;
> static u32 hotkey_all_mask;
> static u32 hotkey_reserved_mask;
> @@ -1571,9 +1570,9 @@ static int hotkey_status_get(int *status)
> return 0;
> }
>
> -static int hotkey_status_set(int status)
> +static int hotkey_status_set(bool enable)
> {
> - if (!acpi_evalf(hkey_handle, NULL, "MHKC", "vd", status))
> + if (!acpi_evalf(hkey_handle, NULL, "MHKC", "vd", enable ? 1 : 0))
> return -EIO;
>
> return 0;
> @@ -1889,6 +1888,9 @@ static ssize_t hotkey_enable_show(struct device *dev,
> {
> int res, status;
>
> + printk_deprecated_attribute("hotkey_enable",
> + "Hotkey reporting is always enabled");
> +
> res = hotkey_status_get(&status);
> if (res)
> return res;
> @@ -1901,14 +1903,17 @@ static ssize_t hotkey_enable_store(struct device *dev,
> const char *buf, size_t count)
> {
> unsigned long t;
> - int res;
> +
> + printk_deprecated_attribute("hotkey_enable",
> + "Hotkeys can be disabled through hotkey_mask");
>
> if (parse_strtoul(buf, 1, &t))
> return -EINVAL;
>
> - res = hotkey_status_set(t);
> + if (t == 0)
> + return -EPERM;
>
> - return (res) ? res : count;
> + return count;
> }
>
> static struct device_attribute dev_attr_hotkey_enable =
> @@ -1964,7 +1969,7 @@ static ssize_t hotkey_bios_enabled_show(struct device *dev,
> struct device_attribute *attr,
> char *buf)
> {
> - return snprintf(buf, PAGE_SIZE, "%d\n", hotkey_orig_status);
> + return sprintf(buf, "0\n");
> }
>
> static struct device_attribute dev_attr_hotkey_bios_enabled =
> @@ -2243,7 +2248,7 @@ static void hotkey_exit(void)
> "restoring original hot key mask\n");
> /* no short-circuit boolean operator below! */
> if ((hotkey_mask_set(hotkey_orig_mask) |
> - hotkey_status_set(hotkey_orig_status)) != 0)
> + hotkey_status_set(false)) != 0)
> printk(TPACPI_ERR
> "failed to restore hot key mask "
> "to BIOS defaults\n");
> @@ -2438,10 +2443,6 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
>
> /* hotkey_source_mask *must* be zero for
> * the first hotkey_mask_get */
> - res = hotkey_status_get(&hotkey_orig_status);
> - if (res)
> - goto err_exit;
> -
> if (tp_features.hotkey_mask) {
> res = hotkey_mask_get();
> if (res)
> @@ -2581,7 +2582,7 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
> }
>
> dbg_printk(TPACPI_DBG_INIT, "enabling hot key handling\n");
> - res = hotkey_status_set(1);
> + res = hotkey_status_set(true);
> if (res) {
> hotkey_exit();
> return res;
> @@ -2926,9 +2927,17 @@ static int hotkey_read(char *p)
> return len;
> }
>
> +static void hotkey_enabledisable_warn(void)
> +{
> + tpacpi_log_usertask("procfs hotkey enable/disable");
> + WARN(1, TPACPI_WARN
> + "hotkey enable/disable functionality has been "
> + "removed from the driver. Hotkeys are always enabled.\n");
> +}
> +
> static int hotkey_write(char *buf)
> {
> - int res, status;
> + int res;
> u32 mask;
> char *cmd;
>
> @@ -2938,17 +2947,16 @@ static int hotkey_write(char *buf)
> if (mutex_lock_killable(&hotkey_mutex))
> return -ERESTARTSYS;
>
> - status = -1;
> mask = hotkey_mask;
>
> res = 0;
> while ((cmd = next_cmd(&buf))) {
> if (strlencmp(cmd, "enable") == 0) {
> - status = 1;
> + hotkey_enabledisable_warn();
> } else if (strlencmp(cmd, "disable") == 0) {
> - status = 0;
> + hotkey_enabledisable_warn();
> + res = -EPERM;
> } else if (strlencmp(cmd, "reset") == 0) {
> - status = hotkey_orig_status;
> mask = hotkey_orig_mask;
> } else if (sscanf(cmd, "0x%x", &mask) == 1) {
> /* mask set */
> @@ -2959,9 +2967,6 @@ static int hotkey_write(char *buf)
> goto errexit;
> }
> }
> - if (status != -1)
> - res = hotkey_status_set(status);
> -
> if (!res && mask != hotkey_mask)
> res = hotkey_mask_set(mask);
>
--
http://mark.stosberg.com/
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: remove HKEY disable functionality (triggers Ubuntu Karmic regression)
2009-10-29 6:58 ` remove HKEY disable functionality (triggers Ubuntu Karmic regression) Mark Stosberg
@ 2009-10-29 22:46 ` Henrique de Moraes Holschuh
0 siblings, 0 replies; 16+ messages in thread
From: Henrique de Moraes Holschuh @ 2009-10-29 22:46 UTC (permalink / raw)
To: Mark Stosberg
Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
linux-acpi-u79uwXL29TY76Z2rM5mHXA
On Wed, 28 Oct 2009, Mark Stosberg wrote:
> With the release of Karmic upon us, perhaps there a short term fix that
> can be made, like making the warning level less severe.
If the userspace in Ubuntu is triggering the warning, and you don't have
enough time to fix the issue properly (i.e. remove any code that
attempts to mess with hotkey_enable), the Ubuntu kernel team will have
to remove the WARN from the driver code, yes.
However, I recommend trying to fix the real bug, first. There are
absolutely no known-valid reasons for any program to access the
hotkey_enable attribute.
Please ask someone who can reproduce the warning to check for debug output
from thinkpad-acpi, it will log to the kernel log the PID of the process
trying to access the deprecated attributes. The user should check the PID
and use the ps command to find out what process corresponts to that PID:
Run this in a shell window:
tail -f /var/log/kern.log | grep "thinkpad_acpi"
then run whatever application causes the warnings to happen, or if they
are common, just wait for one to happen. Thinkpad-acpi will log the PID
of the offending processes using a phrase like "access by process with
PID...".
I would be interested in the full log output by thinkpad-acpi showing the
problem. In fact, I find it surprising that your automated bug report tool
doesn't attach to the bug report the last 100 lines of the kernel log or
somesuch...
Anyway, now that the user knows the PID of the process attempting to access
the deprecated attributes, he should immediately use the "ps PID", where PID
is the numerical value of the PID logged by thinkpad-acpi, to find out the
name and parameters of the process who accessed the deprecated attribute.
Maybe the user should also use "pstree -p" to help locate the parent of the
process if the PID resultued in something unhelpful (e.g. bash).
That could give us a clue about exactly why that attribute is being
accessed, especially if it is happening when someone is trying to test their
ALSA setup...
--
"One disk to rule them all, One disk to find them. One disk to bring
them all and in the darkness grind them. In the Land of Redmond
where the shadows lie." -- The Silicon Valley Tarot
Henrique Holschuh
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2009-10-29 22:46 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-04 4:25 [GIT PATCH] thinkpad-acpi queue for 2.6.30 Henrique de Moraes Holschuh
2009-04-04 4:25 ` [PATCH 01/12] thinkpad-acpi: update copyright notices Henrique de Moraes Holschuh
2009-04-04 4:25 ` [PATCH 02/12] thinkpad-acpi: drop ibm-acpi alias Henrique de Moraes Holschuh
2009-04-04 4:25 ` [PATCH 03/12] thinkpad-acpi: documentation cleanup Henrique de Moraes Holschuh
2009-04-04 4:25 ` [PATCH 04/12] thinkpad-acpi: cleanup debug helpers Henrique de Moraes Holschuh
2009-04-04 4:25 ` [PATCH 05/12] thinkpad-acpi: add missing log levels Henrique de Moraes Holschuh
2009-04-04 4:25 ` [PATCH 06/12] thinkpad-acpi: add new debug helpers and warn of deprecated atts Henrique de Moraes Holschuh
2009-04-04 4:25 ` [PATCH 07/12] thinkpad-acpi: remove HKEY disable functionality Henrique de Moraes Holschuh
2009-10-29 6:58 ` remove HKEY disable functionality (triggers Ubuntu Karmic regression) Mark Stosberg
2009-10-29 22:46 ` Henrique de Moraes Holschuh
2009-04-04 4:25 ` [PATCH 08/12] thinkpad-acpi: restrict access to some firmware LEDs Henrique de Moraes Holschuh
2009-04-04 4:25 ` [PATCH 09/12] thinkpad-acpi: enhanced debugging messages for rfkill subdrivers Henrique de Moraes Holschuh
2009-04-04 4:25 ` [PATCH 10/12] thinkpad-acpi: enhanced debugging messages for the hotkey subdriver Henrique de Moraes Holschuh
2009-04-04 4:25 ` [PATCH 11/12] thinkpad-acpi: enhanced debugging messages for the fan subdriver Henrique de Moraes Holschuh
[not found] ` <1238819153-16004-1-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
2009-04-04 4:25 ` [PATCH 12/12] thinkpad-acpi: rework brightness support Henrique de Moraes Holschuh
2009-04-04 7:36 ` [GIT PATCH] thinkpad-acpi queue for 2.6.30 Len Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox