diff options
Diffstat (limited to 'drivers')
40 files changed, 982 insertions, 675 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 087a7028ae84..b9f923ef173d 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
@@ -50,7 +50,6 @@ config ACPI_SLEEP | |||
50 | config ACPI_PROCFS | 50 | config ACPI_PROCFS |
51 | bool "Deprecated /proc/acpi files" | 51 | bool "Deprecated /proc/acpi files" |
52 | depends on PROC_FS | 52 | depends on PROC_FS |
53 | default y | ||
54 | ---help--- | 53 | ---help--- |
55 | For backwards compatibility, this option allows | 54 | For backwards compatibility, this option allows |
56 | deprecated /proc/acpi/ files to exist, even when | 55 | deprecated /proc/acpi/ files to exist, even when |
@@ -61,7 +60,6 @@ config ACPI_PROCFS | |||
61 | /proc/acpi/info (/sys/modules/acpi/parameters/acpica_version) | 60 | /proc/acpi/info (/sys/modules/acpi/parameters/acpica_version) |
62 | /proc/acpi/dsdt (/sys/firmware/acpi/tables/DSDT) | 61 | /proc/acpi/dsdt (/sys/firmware/acpi/tables/DSDT) |
63 | /proc/acpi/fadt (/sys/firmware/acpi/tables/FACP) | 62 | /proc/acpi/fadt (/sys/firmware/acpi/tables/FACP) |
64 | /proc/acpi/battery (/sys/class/power_supply) | ||
65 | /proc/acpi/debug_layer (/sys/module/acpi/parameters/debug_layer) | 63 | /proc/acpi/debug_layer (/sys/module/acpi/parameters/debug_layer) |
66 | /proc/acpi/debug_level (/sys/module/acpi/parameters/debug_level) | 64 | /proc/acpi/debug_level (/sys/module/acpi/parameters/debug_level) |
67 | 65 | ||
@@ -69,7 +67,21 @@ config ACPI_PROCFS | |||
69 | and functions which do not yet exist in /sys. | 67 | and functions which do not yet exist in /sys. |
70 | 68 | ||
71 | Say N to delete /proc/acpi/ files that have moved to /sys/ | 69 | Say N to delete /proc/acpi/ files that have moved to /sys/ |
72 | 70 | config ACPI_PROCFS_POWER | |
71 | bool "Deprecated power /proc/acpi folders" | ||
72 | depends on PROC_FS | ||
73 | default y | ||
74 | ---help--- | ||
75 | For backwards compatibility, this option allows | ||
76 | deprecated power /proc/acpi/ folders to exist, even when | ||
77 | they have been replaced by functions in /sys. | ||
78 | The deprecated folders (and their replacements) include: | ||
79 | /proc/acpi/battery/* (/sys/class/power_supply/*) | ||
80 | /proc/acpi/ac_adapter/* (sys/class/power_supply/*) | ||
81 | This option has no effect on /proc/acpi/ folders | ||
82 | and functions, which do not yet exist in /sys | ||
83 | |||
84 | Say N to delete power /proc/acpi/ folders that have moved to /sys/ | ||
73 | config ACPI_PROC_EVENT | 85 | config ACPI_PROC_EVENT |
74 | bool "Deprecated /proc/acpi/event support" | 86 | bool "Deprecated /proc/acpi/event support" |
75 | depends on PROC_FS | 87 | depends on PROC_FS |
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 54e3ab0e5fc0..456446f90077 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile | |||
@@ -58,6 +58,6 @@ obj-$(CONFIG_ACPI_NUMA) += numa.o | |||
58 | obj-$(CONFIG_ACPI_ASUS) += asus_acpi.o | 58 | obj-$(CONFIG_ACPI_ASUS) += asus_acpi.o |
59 | obj-$(CONFIG_ACPI_TOSHIBA) += toshiba_acpi.o | 59 | obj-$(CONFIG_ACPI_TOSHIBA) += toshiba_acpi.o |
60 | obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o | 60 | obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o |
61 | obj-y += cm_sbs.o | 61 | obj-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o |
62 | obj-$(CONFIG_ACPI_SBS) += sbs.o | 62 | obj-$(CONFIG_ACPI_SBS) += sbs.o |
63 | obj-$(CONFIG_ACPI_SBS) += sbshc.o | 63 | obj-$(CONFIG_ACPI_SBS) += sbshc.o |
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 30238f6ff232..76ed4f52bebd 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/types.h> | 29 | #include <linux/types.h> |
30 | #ifdef CONFIG_ACPI_PROCFS | 30 | #ifdef CONFIG_ACPI_PROCFS_POWER |
31 | #include <linux/proc_fs.h> | 31 | #include <linux/proc_fs.h> |
32 | #include <linux/seq_file.h> | 32 | #include <linux/seq_file.h> |
33 | #endif | 33 | #endif |
@@ -51,7 +51,7 @@ MODULE_AUTHOR("Paul Diefenbaugh"); | |||
51 | MODULE_DESCRIPTION("ACPI AC Adapter Driver"); | 51 | MODULE_DESCRIPTION("ACPI AC Adapter Driver"); |
52 | MODULE_LICENSE("GPL"); | 52 | MODULE_LICENSE("GPL"); |
53 | 53 | ||
54 | #ifdef CONFIG_ACPI_PROCFS | 54 | #ifdef CONFIG_ACPI_PROCFS_POWER |
55 | extern struct proc_dir_entry *acpi_lock_ac_dir(void); | 55 | extern struct proc_dir_entry *acpi_lock_ac_dir(void); |
56 | extern void *acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir); | 56 | extern void *acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir); |
57 | static int acpi_ac_open_fs(struct inode *inode, struct file *file); | 57 | static int acpi_ac_open_fs(struct inode *inode, struct file *file); |
@@ -86,7 +86,7 @@ struct acpi_ac { | |||
86 | 86 | ||
87 | #define to_acpi_ac(x) container_of(x, struct acpi_ac, charger); | 87 | #define to_acpi_ac(x) container_of(x, struct acpi_ac, charger); |
88 | 88 | ||
89 | #ifdef CONFIG_ACPI_PROCFS | 89 | #ifdef CONFIG_ACPI_PROCFS_POWER |
90 | static const struct file_operations acpi_ac_fops = { | 90 | static const struct file_operations acpi_ac_fops = { |
91 | .open = acpi_ac_open_fs, | 91 | .open = acpi_ac_open_fs, |
92 | .read = seq_read, | 92 | .read = seq_read, |
@@ -136,7 +136,7 @@ static int acpi_ac_get_state(struct acpi_ac *ac) | |||
136 | return 0; | 136 | return 0; |
137 | } | 137 | } |
138 | 138 | ||
139 | #ifdef CONFIG_ACPI_PROCFS | 139 | #ifdef CONFIG_ACPI_PROCFS_POWER |
140 | /* -------------------------------------------------------------------------- | 140 | /* -------------------------------------------------------------------------- |
141 | FS Interface (/proc) | 141 | FS Interface (/proc) |
142 | -------------------------------------------------------------------------- */ | 142 | -------------------------------------------------------------------------- */ |
@@ -275,7 +275,7 @@ static int acpi_ac_add(struct acpi_device *device) | |||
275 | if (result) | 275 | if (result) |
276 | goto end; | 276 | goto end; |
277 | 277 | ||
278 | #ifdef CONFIG_ACPI_PROCFS | 278 | #ifdef CONFIG_ACPI_PROCFS_POWER |
279 | result = acpi_ac_add_fs(device); | 279 | result = acpi_ac_add_fs(device); |
280 | #endif | 280 | #endif |
281 | if (result) | 281 | if (result) |
@@ -300,7 +300,7 @@ static int acpi_ac_add(struct acpi_device *device) | |||
300 | 300 | ||
301 | end: | 301 | end: |
302 | if (result) { | 302 | if (result) { |
303 | #ifdef CONFIG_ACPI_PROCFS | 303 | #ifdef CONFIG_ACPI_PROCFS_POWER |
304 | acpi_ac_remove_fs(device); | 304 | acpi_ac_remove_fs(device); |
305 | #endif | 305 | #endif |
306 | kfree(ac); | 306 | kfree(ac); |
@@ -339,7 +339,7 @@ static int acpi_ac_remove(struct acpi_device *device, int type) | |||
339 | ACPI_ALL_NOTIFY, acpi_ac_notify); | 339 | ACPI_ALL_NOTIFY, acpi_ac_notify); |
340 | if (ac->charger.dev) | 340 | if (ac->charger.dev) |
341 | power_supply_unregister(&ac->charger); | 341 | power_supply_unregister(&ac->charger); |
342 | #ifdef CONFIG_ACPI_PROCFS | 342 | #ifdef CONFIG_ACPI_PROCFS_POWER |
343 | acpi_ac_remove_fs(device); | 343 | acpi_ac_remove_fs(device); |
344 | #endif | 344 | #endif |
345 | 345 | ||
@@ -355,7 +355,7 @@ static int __init acpi_ac_init(void) | |||
355 | if (acpi_disabled) | 355 | if (acpi_disabled) |
356 | return -ENODEV; | 356 | return -ENODEV; |
357 | 357 | ||
358 | #ifdef CONFIG_ACPI_PROCFS | 358 | #ifdef CONFIG_ACPI_PROCFS_POWER |
359 | acpi_ac_dir = acpi_lock_ac_dir(); | 359 | acpi_ac_dir = acpi_lock_ac_dir(); |
360 | if (!acpi_ac_dir) | 360 | if (!acpi_ac_dir) |
361 | return -ENODEV; | 361 | return -ENODEV; |
@@ -363,7 +363,7 @@ static int __init acpi_ac_init(void) | |||
363 | 363 | ||
364 | result = acpi_bus_register_driver(&acpi_ac_driver); | 364 | result = acpi_bus_register_driver(&acpi_ac_driver); |
365 | if (result < 0) { | 365 | if (result < 0) { |
366 | #ifdef CONFIG_ACPI_PROCFS | 366 | #ifdef CONFIG_ACPI_PROCFS_POWER |
367 | acpi_unlock_ac_dir(acpi_ac_dir); | 367 | acpi_unlock_ac_dir(acpi_ac_dir); |
368 | #endif | 368 | #endif |
369 | return -ENODEV; | 369 | return -ENODEV; |
@@ -377,7 +377,7 @@ static void __exit acpi_ac_exit(void) | |||
377 | 377 | ||
378 | acpi_bus_unregister_driver(&acpi_ac_driver); | 378 | acpi_bus_unregister_driver(&acpi_ac_driver); |
379 | 379 | ||
380 | #ifdef CONFIG_ACPI_PROCFS | 380 | #ifdef CONFIG_ACPI_PROCFS_POWER |
381 | acpi_unlock_ac_dir(acpi_ac_dir); | 381 | acpi_unlock_ac_dir(acpi_ac_dir); |
382 | #endif | 382 | #endif |
383 | 383 | ||
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 192c244f6190..7d6be23eff89 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include <linux/types.h> | 31 | #include <linux/types.h> |
32 | #include <linux/jiffies.h> | 32 | #include <linux/jiffies.h> |
33 | 33 | ||
34 | #ifdef CONFIG_ACPI_PROCFS | 34 | #ifdef CONFIG_ACPI_PROCFS_POWER |
35 | #include <linux/proc_fs.h> | 35 | #include <linux/proc_fs.h> |
36 | #include <linux/seq_file.h> | 36 | #include <linux/seq_file.h> |
37 | #include <asm/uaccess.h> | 37 | #include <asm/uaccess.h> |
@@ -63,7 +63,7 @@ static unsigned int cache_time = 1000; | |||
63 | module_param(cache_time, uint, 0644); | 63 | module_param(cache_time, uint, 0644); |
64 | MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); | 64 | MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); |
65 | 65 | ||
66 | #ifdef CONFIG_ACPI_PROCFS | 66 | #ifdef CONFIG_ACPI_PROCFS_POWER |
67 | extern struct proc_dir_entry *acpi_lock_battery_dir(void); | 67 | extern struct proc_dir_entry *acpi_lock_battery_dir(void); |
68 | extern void *acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir); | 68 | extern void *acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir); |
69 | 69 | ||
@@ -153,6 +153,8 @@ static int acpi_battery_get_property(struct power_supply *psy, | |||
153 | val->intval = POWER_SUPPLY_STATUS_CHARGING; | 153 | val->intval = POWER_SUPPLY_STATUS_CHARGING; |
154 | else if (battery->state == 0) | 154 | else if (battery->state == 0) |
155 | val->intval = POWER_SUPPLY_STATUS_FULL; | 155 | val->intval = POWER_SUPPLY_STATUS_FULL; |
156 | else | ||
157 | val->intval = POWER_SUPPLY_STATUS_UNKNOWN; | ||
156 | break; | 158 | break; |
157 | case POWER_SUPPLY_PROP_PRESENT: | 159 | case POWER_SUPPLY_PROP_PRESENT: |
158 | val->intval = acpi_battery_present(battery); | 160 | val->intval = acpi_battery_present(battery); |
@@ -221,7 +223,7 @@ static enum power_supply_property energy_battery_props[] = { | |||
221 | POWER_SUPPLY_PROP_MANUFACTURER, | 223 | POWER_SUPPLY_PROP_MANUFACTURER, |
222 | }; | 224 | }; |
223 | 225 | ||
224 | #ifdef CONFIG_ACPI_PROCFS | 226 | #ifdef CONFIG_ACPI_PROCFS_POWER |
225 | inline char *acpi_battery_units(struct acpi_battery *battery) | 227 | inline char *acpi_battery_units(struct acpi_battery *battery) |
226 | { | 228 | { |
227 | return (battery->power_unit)?"mA":"mW"; | 229 | return (battery->power_unit)?"mA":"mW"; |
@@ -479,7 +481,7 @@ static int acpi_battery_update(struct acpi_battery *battery) | |||
479 | FS Interface (/proc) | 481 | FS Interface (/proc) |
480 | -------------------------------------------------------------------------- */ | 482 | -------------------------------------------------------------------------- */ |
481 | 483 | ||
482 | #ifdef CONFIG_ACPI_PROCFS | 484 | #ifdef CONFIG_ACPI_PROCFS_POWER |
483 | static struct proc_dir_entry *acpi_battery_dir; | 485 | static struct proc_dir_entry *acpi_battery_dir; |
484 | 486 | ||
485 | static int acpi_battery_print_info(struct seq_file *seq, int result) | 487 | static int acpi_battery_print_info(struct seq_file *seq, int result) |
@@ -786,7 +788,7 @@ static int acpi_battery_add(struct acpi_device *device) | |||
786 | acpi_driver_data(device) = battery; | 788 | acpi_driver_data(device) = battery; |
787 | mutex_init(&battery->lock); | 789 | mutex_init(&battery->lock); |
788 | acpi_battery_update(battery); | 790 | acpi_battery_update(battery); |
789 | #ifdef CONFIG_ACPI_PROCFS | 791 | #ifdef CONFIG_ACPI_PROCFS_POWER |
790 | result = acpi_battery_add_fs(device); | 792 | result = acpi_battery_add_fs(device); |
791 | if (result) | 793 | if (result) |
792 | goto end; | 794 | goto end; |
@@ -804,7 +806,7 @@ static int acpi_battery_add(struct acpi_device *device) | |||
804 | device->status.battery_present ? "present" : "absent"); | 806 | device->status.battery_present ? "present" : "absent"); |
805 | end: | 807 | end: |
806 | if (result) { | 808 | if (result) { |
807 | #ifdef CONFIG_ACPI_PROCFS | 809 | #ifdef CONFIG_ACPI_PROCFS_POWER |
808 | acpi_battery_remove_fs(device); | 810 | acpi_battery_remove_fs(device); |
809 | #endif | 811 | #endif |
810 | kfree(battery); | 812 | kfree(battery); |
@@ -823,7 +825,7 @@ static int acpi_battery_remove(struct acpi_device *device, int type) | |||
823 | status = acpi_remove_notify_handler(device->handle, | 825 | status = acpi_remove_notify_handler(device->handle, |
824 | ACPI_ALL_NOTIFY, | 826 | ACPI_ALL_NOTIFY, |
825 | acpi_battery_notify); | 827 | acpi_battery_notify); |
826 | #ifdef CONFIG_ACPI_PROCFS | 828 | #ifdef CONFIG_ACPI_PROCFS_POWER |
827 | acpi_battery_remove_fs(device); | 829 | acpi_battery_remove_fs(device); |
828 | #endif | 830 | #endif |
829 | sysfs_remove_battery(battery); | 831 | sysfs_remove_battery(battery); |
@@ -859,13 +861,13 @@ static int __init acpi_battery_init(void) | |||
859 | { | 861 | { |
860 | if (acpi_disabled) | 862 | if (acpi_disabled) |
861 | return -ENODEV; | 863 | return -ENODEV; |
862 | #ifdef CONFIG_ACPI_PROCFS | 864 | #ifdef CONFIG_ACPI_PROCFS_POWER |
863 | acpi_battery_dir = acpi_lock_battery_dir(); | 865 | acpi_battery_dir = acpi_lock_battery_dir(); |
864 | if (!acpi_battery_dir) | 866 | if (!acpi_battery_dir) |
865 | return -ENODEV; | 867 | return -ENODEV; |
866 | #endif | 868 | #endif |
867 | if (acpi_bus_register_driver(&acpi_battery_driver) < 0) { | 869 | if (acpi_bus_register_driver(&acpi_battery_driver) < 0) { |
868 | #ifdef CONFIG_ACPI_PROCFS | 870 | #ifdef CONFIG_ACPI_PROCFS_POWER |
869 | acpi_unlock_battery_dir(acpi_battery_dir); | 871 | acpi_unlock_battery_dir(acpi_battery_dir); |
870 | #endif | 872 | #endif |
871 | return -ENODEV; | 873 | return -ENODEV; |
@@ -876,7 +878,7 @@ static int __init acpi_battery_init(void) | |||
876 | static void __exit acpi_battery_exit(void) | 878 | static void __exit acpi_battery_exit(void) |
877 | { | 879 | { |
878 | acpi_bus_unregister_driver(&acpi_battery_driver); | 880 | acpi_bus_unregister_driver(&acpi_battery_driver); |
879 | #ifdef CONFIG_ACPI_PROCFS | 881 | #ifdef CONFIG_ACPI_PROCFS_POWER |
880 | acpi_unlock_battery_dir(acpi_battery_dir); | 882 | acpi_unlock_battery_dir(acpi_battery_dir); |
881 | #endif | 883 | #endif |
882 | } | 884 | } |
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 06b78e5e33a1..d411017f8c06 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -47,6 +47,9 @@ | |||
47 | #undef PREFIX | 47 | #undef PREFIX |
48 | #define PREFIX "ACPI: EC: " | 48 | #define PREFIX "ACPI: EC: " |
49 | 49 | ||
50 | /* Uncomment next line to get verbose print outs*/ | ||
51 | /* #define DEBUG */ | ||
52 | |||
50 | /* EC status register */ | 53 | /* EC status register */ |
51 | #define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */ | 54 | #define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */ |
52 | #define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */ | 55 | #define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */ |
@@ -75,7 +78,10 @@ enum { | |||
75 | EC_FLAGS_WAIT_GPE = 0, /* Don't check status until GPE arrives */ | 78 | EC_FLAGS_WAIT_GPE = 0, /* Don't check status until GPE arrives */ |
76 | EC_FLAGS_QUERY_PENDING, /* Query is pending */ | 79 | EC_FLAGS_QUERY_PENDING, /* Query is pending */ |
77 | EC_FLAGS_GPE_MODE, /* Expect GPE to be sent for status change */ | 80 | EC_FLAGS_GPE_MODE, /* Expect GPE to be sent for status change */ |
78 | EC_FLAGS_ONLY_IBF_GPE, /* Expect GPE only for IBF = 0 event */ | 81 | EC_FLAGS_NO_ADDRESS_GPE, /* Expect GPE only for non-address event */ |
82 | EC_FLAGS_ADDRESS, /* Address is being written */ | ||
83 | EC_FLAGS_NO_WDATA_GPE, /* Don't expect WDATA GPE event */ | ||
84 | EC_FLAGS_WDATA, /* Data is being written */ | ||
79 | }; | 85 | }; |
80 | 86 | ||
81 | static int acpi_ec_remove(struct acpi_device *device, int type); | 87 | static int acpi_ec_remove(struct acpi_device *device, int type); |
@@ -131,21 +137,27 @@ static struct acpi_ec { | |||
131 | 137 | ||
132 | static inline u8 acpi_ec_read_status(struct acpi_ec *ec) | 138 | static inline u8 acpi_ec_read_status(struct acpi_ec *ec) |
133 | { | 139 | { |
134 | return inb(ec->command_addr); | 140 | u8 x = inb(ec->command_addr); |
141 | pr_debug(PREFIX "---> status = 0x%2x\n", x); | ||
142 | return x; | ||
135 | } | 143 | } |
136 | 144 | ||
137 | static inline u8 acpi_ec_read_data(struct acpi_ec *ec) | 145 | static inline u8 acpi_ec_read_data(struct acpi_ec *ec) |
138 | { | 146 | { |
147 | u8 x = inb(ec->data_addr); | ||
148 | pr_debug(PREFIX "---> data = 0x%2x\n", x); | ||
139 | return inb(ec->data_addr); | 149 | return inb(ec->data_addr); |
140 | } | 150 | } |
141 | 151 | ||
142 | static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command) | 152 | static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command) |
143 | { | 153 | { |
154 | pr_debug(PREFIX "<--- command = 0x%2x\n", command); | ||
144 | outb(command, ec->command_addr); | 155 | outb(command, ec->command_addr); |
145 | } | 156 | } |
146 | 157 | ||
147 | static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data) | 158 | static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data) |
148 | { | 159 | { |
160 | pr_debug(PREFIX "<--- data = 0x%2x\n", data); | ||
149 | outb(data, ec->data_addr); | 161 | outb(data, ec->data_addr); |
150 | } | 162 | } |
151 | 163 | ||
@@ -166,38 +178,54 @@ static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event) | |||
166 | 178 | ||
167 | static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll) | 179 | static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll) |
168 | { | 180 | { |
181 | int ret = 0; | ||
182 | if (unlikely(test_bit(EC_FLAGS_ADDRESS, &ec->flags) && | ||
183 | test_bit(EC_FLAGS_NO_ADDRESS_GPE, &ec->flags))) | ||
184 | force_poll = 1; | ||
185 | if (unlikely(test_bit(EC_FLAGS_WDATA, &ec->flags) && | ||
186 | test_bit(EC_FLAGS_NO_WDATA_GPE, &ec->flags))) | ||
187 | force_poll = 1; | ||
169 | if (likely(test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) && | 188 | if (likely(test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) && |
170 | likely(!force_poll)) { | 189 | likely(!force_poll)) { |
171 | if (wait_event_timeout(ec->wait, acpi_ec_check_status(ec, event), | 190 | if (wait_event_timeout(ec->wait, acpi_ec_check_status(ec, event), |
172 | msecs_to_jiffies(ACPI_EC_DELAY))) | 191 | msecs_to_jiffies(ACPI_EC_DELAY))) |
173 | return 0; | 192 | goto end; |
174 | clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); | 193 | clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); |
175 | if (acpi_ec_check_status(ec, event)) { | 194 | if (acpi_ec_check_status(ec, event)) { |
176 | if (event == ACPI_EC_EVENT_OBF_1) { | 195 | if (test_bit(EC_FLAGS_ADDRESS, &ec->flags)) { |
177 | /* miss OBF = 1 GPE, don't expect it anymore */ | 196 | /* miss address GPE, don't expect it anymore */ |
178 | printk(KERN_INFO PREFIX "missing OBF_1 confirmation," | 197 | pr_info(PREFIX "missing address confirmation, " |
179 | "switching to degraded mode.\n"); | 198 | "don't expect it any longer.\n"); |
180 | set_bit(EC_FLAGS_ONLY_IBF_GPE, &ec->flags); | 199 | set_bit(EC_FLAGS_NO_ADDRESS_GPE, &ec->flags); |
200 | } else if (test_bit(EC_FLAGS_WDATA, &ec->flags)) { | ||
201 | /* miss write data GPE, don't expect it */ | ||
202 | pr_info(PREFIX "missing write data confirmation, " | ||
203 | "don't expect it any longer.\n"); | ||
204 | set_bit(EC_FLAGS_NO_WDATA_GPE, &ec->flags); | ||
181 | } else { | 205 | } else { |
182 | /* missing GPEs, switch back to poll mode */ | 206 | /* missing GPEs, switch back to poll mode */ |
183 | printk(KERN_INFO PREFIX "missing IBF_1 confirmations," | 207 | if (printk_ratelimit()) |
184 | "switch off interrupt mode.\n"); | 208 | pr_info(PREFIX "missing confirmations, " |
209 | "switch off interrupt mode.\n"); | ||
185 | clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); | 210 | clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); |
186 | } | 211 | } |
187 | return 0; | 212 | goto end; |
188 | } | 213 | } |
189 | } else { | 214 | } else { |
190 | unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); | 215 | unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); |
191 | clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); | 216 | clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); |
192 | while (time_before(jiffies, delay)) { | 217 | while (time_before(jiffies, delay)) { |
193 | if (acpi_ec_check_status(ec, event)) | 218 | if (acpi_ec_check_status(ec, event)) |
194 | return 0; | 219 | goto end; |
195 | } | 220 | } |
196 | } | 221 | } |
197 | printk(KERN_ERR PREFIX "acpi_ec_wait timeout," | 222 | pr_err(PREFIX "acpi_ec_wait timeout," |
198 | " status = %d, expect_event = %d\n", | 223 | " status = %d, expect_event = %d\n", |
199 | acpi_ec_read_status(ec), event); | 224 | acpi_ec_read_status(ec), event); |
200 | return -ETIME; | 225 | ret = -ETIME; |
226 | end: | ||
227 | clear_bit(EC_FLAGS_ADDRESS, &ec->flags); | ||
228 | return ret; | ||
201 | } | 229 | } |
202 | 230 | ||
203 | static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, | 231 | static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, |
@@ -208,22 +236,26 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, | |||
208 | int result = 0; | 236 | int result = 0; |
209 | set_bit(EC_FLAGS_WAIT_GPE, &ec->flags); | 237 | set_bit(EC_FLAGS_WAIT_GPE, &ec->flags); |
210 | acpi_ec_write_cmd(ec, command); | 238 | acpi_ec_write_cmd(ec, command); |
211 | 239 | pr_debug(PREFIX "transaction start\n"); | |
212 | for (; wdata_len > 0; --wdata_len) { | 240 | for (; wdata_len > 0; --wdata_len) { |
213 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll); | 241 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll); |
214 | if (result) { | 242 | if (result) { |
215 | printk(KERN_ERR PREFIX | 243 | pr_err(PREFIX |
216 | "write_cmd timeout, command = %d\n", command); | 244 | "write_cmd timeout, command = %d\n", command); |
217 | goto end; | 245 | goto end; |
218 | } | 246 | } |
247 | /* mark the address byte written to EC */ | ||
248 | if (rdata_len + wdata_len > 1) | ||
249 | set_bit(EC_FLAGS_ADDRESS, &ec->flags); | ||
219 | set_bit(EC_FLAGS_WAIT_GPE, &ec->flags); | 250 | set_bit(EC_FLAGS_WAIT_GPE, &ec->flags); |
220 | acpi_ec_write_data(ec, *(wdata++)); | 251 | acpi_ec_write_data(ec, *(wdata++)); |
221 | } | 252 | } |
222 | 253 | ||
223 | if (!rdata_len) { | 254 | if (!rdata_len) { |
255 | set_bit(EC_FLAGS_WDATA, &ec->flags); | ||
224 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll); | 256 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll); |
225 | if (result) { | 257 | if (result) { |
226 | printk(KERN_ERR PREFIX | 258 | pr_err(PREFIX |
227 | "finish-write timeout, command = %d\n", command); | 259 | "finish-write timeout, command = %d\n", command); |
228 | goto end; | 260 | goto end; |
229 | } | 261 | } |
@@ -231,12 +263,9 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, | |||
231 | clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); | 263 | clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); |
232 | 264 | ||
233 | for (; rdata_len > 0; --rdata_len) { | 265 | for (; rdata_len > 0; --rdata_len) { |
234 | if (test_bit(EC_FLAGS_ONLY_IBF_GPE, &ec->flags)) | ||
235 | force_poll = 1; | ||
236 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1, force_poll); | 266 | result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1, force_poll); |
237 | if (result) { | 267 | if (result) { |
238 | printk(KERN_ERR PREFIX "read timeout, command = %d\n", | 268 | pr_err(PREFIX "read timeout, command = %d\n", command); |
239 | command); | ||
240 | goto end; | 269 | goto end; |
241 | } | 270 | } |
242 | /* Don't expect GPE after last read */ | 271 | /* Don't expect GPE after last read */ |
@@ -245,6 +274,7 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command, | |||
245 | *(rdata++) = acpi_ec_read_data(ec); | 274 | *(rdata++) = acpi_ec_read_data(ec); |
246 | } | 275 | } |
247 | end: | 276 | end: |
277 | pr_debug(PREFIX "transaction end\n"); | ||
248 | return result; | 278 | return result; |
249 | } | 279 | } |
250 | 280 | ||
@@ -273,8 +303,8 @@ static int acpi_ec_transaction(struct acpi_ec *ec, u8 command, | |||
273 | 303 | ||
274 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, 0); | 304 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, 0); |
275 | if (status) { | 305 | if (status) { |
276 | printk(KERN_ERR PREFIX | 306 | pr_err(PREFIX "input buffer is not empty, " |
277 | "input buffer is not empty, aborting transaction\n"); | 307 | "aborting transaction\n"); |
278 | goto end; | 308 | goto end; |
279 | } | 309 | } |
280 | 310 | ||
@@ -488,6 +518,7 @@ static u32 acpi_ec_gpe_handler(void *data) | |||
488 | acpi_status status = AE_OK; | 518 | acpi_status status = AE_OK; |
489 | struct acpi_ec *ec = data; | 519 | struct acpi_ec *ec = data; |
490 | 520 | ||
521 | pr_debug(PREFIX "~~~> interrupt\n"); | ||
491 | clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); | 522 | clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); |
492 | if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) | 523 | if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) |
493 | wake_up(&ec->wait); | 524 | wake_up(&ec->wait); |
@@ -498,8 +529,9 @@ static u32 acpi_ec_gpe_handler(void *data) | |||
498 | acpi_ec_gpe_query, ec); | 529 | acpi_ec_gpe_query, ec); |
499 | } else if (unlikely(!test_bit(EC_FLAGS_GPE_MODE, &ec->flags))) { | 530 | } else if (unlikely(!test_bit(EC_FLAGS_GPE_MODE, &ec->flags))) { |
500 | /* this is non-query, must be confirmation */ | 531 | /* this is non-query, must be confirmation */ |
501 | printk(KERN_INFO PREFIX "non-query interrupt received," | 532 | if (printk_ratelimit()) |
502 | " switching to interrupt mode\n"); | 533 | pr_info(PREFIX "non-query interrupt received," |
534 | " switching to interrupt mode\n"); | ||
503 | set_bit(EC_FLAGS_GPE_MODE, &ec->flags); | 535 | set_bit(EC_FLAGS_GPE_MODE, &ec->flags); |
504 | } | 536 | } |
505 | 537 | ||
@@ -701,10 +733,10 @@ static void ec_remove_handlers(struct acpi_ec *ec) | |||
701 | { | 733 | { |
702 | if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle, | 734 | if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle, |
703 | ACPI_ADR_SPACE_EC, &acpi_ec_space_handler))) | 735 | ACPI_ADR_SPACE_EC, &acpi_ec_space_handler))) |
704 | printk(KERN_ERR PREFIX "failed to remove space handler\n"); | 736 | pr_err(PREFIX "failed to remove space handler\n"); |
705 | if (ACPI_FAILURE(acpi_remove_gpe_handler(NULL, ec->gpe, | 737 | if (ACPI_FAILURE(acpi_remove_gpe_handler(NULL, ec->gpe, |
706 | &acpi_ec_gpe_handler))) | 738 | &acpi_ec_gpe_handler))) |
707 | printk(KERN_ERR PREFIX "failed to remove gpe handler\n"); | 739 | pr_err(PREFIX "failed to remove gpe handler\n"); |
708 | ec->handlers_installed = 0; | 740 | ec->handlers_installed = 0; |
709 | } | 741 | } |
710 | 742 | ||
@@ -747,9 +779,9 @@ static int acpi_ec_add(struct acpi_device *device) | |||
747 | first_ec = ec; | 779 | first_ec = ec; |
748 | acpi_driver_data(device) = ec; | 780 | acpi_driver_data(device) = ec; |
749 | acpi_ec_add_fs(device); | 781 | acpi_ec_add_fs(device); |
750 | printk(KERN_INFO PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n", | 782 | pr_info(PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n", |
751 | ec->gpe, ec->command_addr, ec->data_addr); | 783 | ec->gpe, ec->command_addr, ec->data_addr); |
752 | printk(KERN_INFO PREFIX "driver started in %s mode\n", | 784 | pr_info(PREFIX "driver started in %s mode\n", |
753 | (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))?"interrupt":"poll"); | 785 | (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))?"interrupt":"poll"); |
754 | return 0; | 786 | return 0; |
755 | } | 787 | } |
@@ -875,18 +907,26 @@ int __init acpi_ec_ecdt_probe(void) | |||
875 | status = acpi_get_table(ACPI_SIG_ECDT, 1, | 907 | status = acpi_get_table(ACPI_SIG_ECDT, 1, |
876 | (struct acpi_table_header **)&ecdt_ptr); | 908 | (struct acpi_table_header **)&ecdt_ptr); |
877 | if (ACPI_SUCCESS(status)) { | 909 | if (ACPI_SUCCESS(status)) { |
878 | printk(KERN_INFO PREFIX "EC description table is found, configuring boot EC\n"); | 910 | pr_info(PREFIX "EC description table is found, configuring boot EC\n"); |
879 | boot_ec->command_addr = ecdt_ptr->control.address; | 911 | boot_ec->command_addr = ecdt_ptr->control.address; |
880 | boot_ec->data_addr = ecdt_ptr->data.address; | 912 | boot_ec->data_addr = ecdt_ptr->data.address; |
881 | boot_ec->gpe = ecdt_ptr->gpe; | 913 | boot_ec->gpe = ecdt_ptr->gpe; |
882 | boot_ec->handle = ACPI_ROOT_OBJECT; | 914 | boot_ec->handle = ACPI_ROOT_OBJECT; |
883 | } else { | 915 | } else { |
916 | /* This workaround is needed only on some broken machines, | ||
917 | * which require early EC, but fail to provide ECDT */ | ||
918 | acpi_handle x; | ||
884 | printk(KERN_DEBUG PREFIX "Look up EC in DSDT\n"); | 919 | printk(KERN_DEBUG PREFIX "Look up EC in DSDT\n"); |
885 | status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device, | 920 | status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device, |
886 | boot_ec, NULL); | 921 | boot_ec, NULL); |
887 | /* Check that acpi_get_devices actually find something */ | 922 | /* Check that acpi_get_devices actually find something */ |
888 | if (ACPI_FAILURE(status) || !boot_ec->handle) | 923 | if (ACPI_FAILURE(status) || !boot_ec->handle) |
889 | goto error; | 924 | goto error; |
925 | /* We really need to limit this workaround, the only ASUS, | ||
926 | * which needs it, has fake EC._INI method, so use it as flag. | ||
927 | */ | ||
928 | if (ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI", &x))) | ||
929 | goto error; | ||
890 | } | 930 | } |
891 | 931 | ||
892 | ret = ec_install_handlers(boot_ec); | 932 | ret = ec_install_handlers(boot_ec); |
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index aabc6ca4a81c..e3a673a00845 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c | |||
@@ -387,17 +387,14 @@ acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width) | |||
387 | if (!value) | 387 | if (!value) |
388 | value = &dummy; | 388 | value = &dummy; |
389 | 389 | ||
390 | switch (width) { | 390 | *value = 0; |
391 | case 8: | 391 | if (width <= 8) { |
392 | *(u8 *) value = inb(port); | 392 | *(u8 *) value = inb(port); |
393 | break; | 393 | } else if (width <= 16) { |
394 | case 16: | ||
395 | *(u16 *) value = inw(port); | 394 | *(u16 *) value = inw(port); |
396 | break; | 395 | } else if (width <= 32) { |
397 | case 32: | ||
398 | *(u32 *) value = inl(port); | 396 | *(u32 *) value = inl(port); |
399 | break; | 397 | } else { |
400 | default: | ||
401 | BUG(); | 398 | BUG(); |
402 | } | 399 | } |
403 | 400 | ||
@@ -408,17 +405,13 @@ EXPORT_SYMBOL(acpi_os_read_port); | |||
408 | 405 | ||
409 | acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width) | 406 | acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width) |
410 | { | 407 | { |
411 | switch (width) { | 408 | if (width <= 8) { |
412 | case 8: | ||
413 | outb(value, port); | 409 | outb(value, port); |
414 | break; | 410 | } else if (width <= 16) { |
415 | case 16: | ||
416 | outw(value, port); | 411 | outw(value, port); |
417 | break; | 412 | } else if (width <= 32) { |
418 | case 32: | ||
419 | outl(value, port); | 413 | outl(value, port); |
420 | break; | 414 | } else { |
421 | default: | ||
422 | BUG(); | 415 | BUG(); |
423 | } | 416 | } |
424 | 417 | ||
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 235a51e328c3..015689d295c7 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c | |||
@@ -612,12 +612,6 @@ static int acpi_processor_get_info(struct acpi_processor *pr, unsigned has_uid) | |||
612 | request_region(pr->throttling.address, 6, "ACPI CPU throttle"); | 612 | request_region(pr->throttling.address, 6, "ACPI CPU throttle"); |
613 | } | 613 | } |
614 | 614 | ||
615 | #ifdef CONFIG_CPU_FREQ | ||
616 | acpi_processor_ppc_has_changed(pr); | ||
617 | #endif | ||
618 | acpi_processor_get_throttling_info(pr); | ||
619 | acpi_processor_get_limit_info(pr); | ||
620 | |||
621 | return 0; | 615 | return 0; |
622 | } | 616 | } |
623 | 617 | ||
@@ -647,7 +641,7 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device) | |||
647 | */ | 641 | */ |
648 | if (processor_device_array[pr->id] != NULL && | 642 | if (processor_device_array[pr->id] != NULL && |
649 | processor_device_array[pr->id] != device) { | 643 | processor_device_array[pr->id] != device) { |
650 | printk(KERN_WARNING "BIOS reported wrong ACPI id" | 644 | printk(KERN_WARNING "BIOS reported wrong ACPI id " |
651 | "for the processor\n"); | 645 | "for the processor\n"); |
652 | return -ENODEV; | 646 | return -ENODEV; |
653 | } | 647 | } |
@@ -665,6 +659,12 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device) | |||
665 | /* _PDC call should be done before doing anything else (if reqd.). */ | 659 | /* _PDC call should be done before doing anything else (if reqd.). */ |
666 | arch_acpi_processor_init_pdc(pr); | 660 | arch_acpi_processor_init_pdc(pr); |
667 | acpi_processor_set_pdc(pr); | 661 | acpi_processor_set_pdc(pr); |
662 | #ifdef CONFIG_CPU_FREQ | ||
663 | acpi_processor_ppc_has_changed(pr); | ||
664 | #endif | ||
665 | acpi_processor_get_throttling_info(pr); | ||
666 | acpi_processor_get_limit_info(pr); | ||
667 | |||
668 | 668 | ||
669 | acpi_processor_power_init(pr, device); | 669 | acpi_processor_power_init(pr, device); |
670 | 670 | ||
@@ -684,7 +684,7 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) | |||
684 | { | 684 | { |
685 | struct acpi_processor *pr = data; | 685 | struct acpi_processor *pr = data; |
686 | struct acpi_device *device = NULL; | 686 | struct acpi_device *device = NULL; |
687 | 687 | int saved; | |
688 | 688 | ||
689 | if (!pr) | 689 | if (!pr) |
690 | return; | 690 | return; |
@@ -694,7 +694,10 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) | |||
694 | 694 | ||
695 | switch (event) { | 695 | switch (event) { |
696 | case ACPI_PROCESSOR_NOTIFY_PERFORMANCE: | 696 | case ACPI_PROCESSOR_NOTIFY_PERFORMANCE: |
697 | saved = pr->performance_platform_limit; | ||
697 | acpi_processor_ppc_has_changed(pr); | 698 | acpi_processor_ppc_has_changed(pr); |
699 | if (saved == pr->performance_platform_limit) | ||
700 | break; | ||
698 | acpi_bus_generate_proc_event(device, event, | 701 | acpi_bus_generate_proc_event(device, event, |
699 | pr->performance_platform_limit); | 702 | pr->performance_platform_limit); |
700 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 703 | acpi_bus_generate_netlink_event(device->pnp.device_class, |
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index f996d0e37689..7b6c20eeeaff 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c | |||
@@ -197,6 +197,19 @@ static inline u32 ticks_elapsed_in_us(u32 t1, u32 t2) | |||
197 | return PM_TIMER_TICKS_TO_US((0xFFFFFFFF - t1) + t2); | 197 | return PM_TIMER_TICKS_TO_US((0xFFFFFFFF - t1) + t2); |
198 | } | 198 | } |
199 | 199 | ||
200 | static void acpi_safe_halt(void) | ||
201 | { | ||
202 | current_thread_info()->status &= ~TS_POLLING; | ||
203 | /* | ||
204 | * TS_POLLING-cleared state must be visible before we | ||
205 | * test NEED_RESCHED: | ||
206 | */ | ||
207 | smp_mb(); | ||
208 | if (!need_resched()) | ||
209 | safe_halt(); | ||
210 | current_thread_info()->status |= TS_POLLING; | ||
211 | } | ||
212 | |||
200 | #ifndef CONFIG_CPU_IDLE | 213 | #ifndef CONFIG_CPU_IDLE |
201 | 214 | ||
202 | static void | 215 | static void |
@@ -239,19 +252,6 @@ acpi_processor_power_activate(struct acpi_processor *pr, | |||
239 | return; | 252 | return; |
240 | } | 253 | } |
241 | 254 | ||
242 | static void acpi_safe_halt(void) | ||
243 | { | ||
244 | current_thread_info()->status &= ~TS_POLLING; | ||
245 | /* | ||
246 | * TS_POLLING-cleared state must be visible before we | ||
247 | * test NEED_RESCHED: | ||
248 | */ | ||
249 | smp_mb(); | ||
250 | if (!need_resched()) | ||
251 | safe_halt(); | ||
252 | current_thread_info()->status |= TS_POLLING; | ||
253 | } | ||
254 | |||
255 | static atomic_t c3_cpu_count; | 255 | static atomic_t c3_cpu_count; |
256 | 256 | ||
257 | /* Common C-state entry for C2, C3, .. */ | 257 | /* Common C-state entry for C2, C3, .. */ |
@@ -1373,15 +1373,7 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev, | |||
1373 | if (pr->flags.bm_check) | 1373 | if (pr->flags.bm_check) |
1374 | acpi_idle_update_bm_rld(pr, cx); | 1374 | acpi_idle_update_bm_rld(pr, cx); |
1375 | 1375 | ||
1376 | current_thread_info()->status &= ~TS_POLLING; | 1376 | acpi_safe_halt(); |
1377 | /* | ||
1378 | * TS_POLLING-cleared state must be visible before we test | ||
1379 | * NEED_RESCHED: | ||
1380 | */ | ||
1381 | smp_mb(); | ||
1382 | if (!need_resched()) | ||
1383 | safe_halt(); | ||
1384 | current_thread_info()->status |= TS_POLLING; | ||
1385 | 1377 | ||
1386 | cx->usage++; | 1378 | cx->usage++; |
1387 | 1379 | ||
@@ -1399,6 +1391,8 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev, | |||
1399 | struct acpi_processor *pr; | 1391 | struct acpi_processor *pr; |
1400 | struct acpi_processor_cx *cx = cpuidle_get_statedata(state); | 1392 | struct acpi_processor_cx *cx = cpuidle_get_statedata(state); |
1401 | u32 t1, t2; | 1393 | u32 t1, t2; |
1394 | int sleep_ticks = 0; | ||
1395 | |||
1402 | pr = processors[smp_processor_id()]; | 1396 | pr = processors[smp_processor_id()]; |
1403 | 1397 | ||
1404 | if (unlikely(!pr)) | 1398 | if (unlikely(!pr)) |
@@ -1428,6 +1422,8 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev, | |||
1428 | ACPI_FLUSH_CPU_CACHE(); | 1422 | ACPI_FLUSH_CPU_CACHE(); |
1429 | 1423 | ||
1430 | t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); | 1424 | t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); |
1425 | /* Tell the scheduler that we are going deep-idle: */ | ||
1426 | sched_clock_idle_sleep_event(); | ||
1431 | acpi_state_timer_broadcast(pr, cx, 1); | 1427 | acpi_state_timer_broadcast(pr, cx, 1); |
1432 | acpi_idle_do_entry(cx); | 1428 | acpi_idle_do_entry(cx); |
1433 | t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); | 1429 | t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); |
@@ -1436,6 +1432,10 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev, | |||
1436 | /* TSC could halt in idle, so notify users */ | 1432 | /* TSC could halt in idle, so notify users */ |
1437 | mark_tsc_unstable("TSC halts in idle");; | 1433 | mark_tsc_unstable("TSC halts in idle");; |
1438 | #endif | 1434 | #endif |
1435 | sleep_ticks = ticks_elapsed(t1, t2); | ||
1436 | |||
1437 | /* Tell the scheduler how much we idled: */ | ||
1438 | sched_clock_idle_wakeup_event(sleep_ticks*PM_TIMER_TICK_NS); | ||
1439 | 1439 | ||
1440 | local_irq_enable(); | 1440 | local_irq_enable(); |
1441 | current_thread_info()->status |= TS_POLLING; | 1441 | current_thread_info()->status |= TS_POLLING; |
@@ -1443,7 +1443,7 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev, | |||
1443 | cx->usage++; | 1443 | cx->usage++; |
1444 | 1444 | ||
1445 | acpi_state_timer_broadcast(pr, cx, 0); | 1445 | acpi_state_timer_broadcast(pr, cx, 0); |
1446 | cx->time += ticks_elapsed(t1, t2); | 1446 | cx->time += sleep_ticks; |
1447 | return ticks_elapsed_in_us(t1, t2); | 1447 | return ticks_elapsed_in_us(t1, t2); |
1448 | } | 1448 | } |
1449 | 1449 | ||
@@ -1463,6 +1463,8 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, | |||
1463 | struct acpi_processor *pr; | 1463 | struct acpi_processor *pr; |
1464 | struct acpi_processor_cx *cx = cpuidle_get_statedata(state); | 1464 | struct acpi_processor_cx *cx = cpuidle_get_statedata(state); |
1465 | u32 t1, t2; | 1465 | u32 t1, t2; |
1466 | int sleep_ticks = 0; | ||
1467 | |||
1466 | pr = processors[smp_processor_id()]; | 1468 | pr = processors[smp_processor_id()]; |
1467 | 1469 | ||
1468 | if (unlikely(!pr)) | 1470 | if (unlikely(!pr)) |
@@ -1471,6 +1473,15 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, | |||
1471 | if (acpi_idle_suspend) | 1473 | if (acpi_idle_suspend) |
1472 | return(acpi_idle_enter_c1(dev, state)); | 1474 | return(acpi_idle_enter_c1(dev, state)); |
1473 | 1475 | ||
1476 | if (acpi_idle_bm_check()) { | ||
1477 | if (dev->safe_state) { | ||
1478 | return dev->safe_state->enter(dev, dev->safe_state); | ||
1479 | } else { | ||
1480 | acpi_safe_halt(); | ||
1481 | return 0; | ||
1482 | } | ||
1483 | } | ||
1484 | |||
1474 | local_irq_disable(); | 1485 | local_irq_disable(); |
1475 | current_thread_info()->status &= ~TS_POLLING; | 1486 | current_thread_info()->status &= ~TS_POLLING; |
1476 | /* | 1487 | /* |
@@ -1485,38 +1496,45 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, | |||
1485 | return 0; | 1496 | return 0; |
1486 | } | 1497 | } |
1487 | 1498 | ||
1499 | /* Tell the scheduler that we are going deep-idle: */ | ||
1500 | sched_clock_idle_sleep_event(); | ||
1488 | /* | 1501 | /* |
1489 | * Must be done before busmaster disable as we might need to | 1502 | * Must be done before busmaster disable as we might need to |
1490 | * access HPET ! | 1503 | * access HPET ! |
1491 | */ | 1504 | */ |
1492 | acpi_state_timer_broadcast(pr, cx, 1); | 1505 | acpi_state_timer_broadcast(pr, cx, 1); |
1493 | 1506 | ||
1494 | if (acpi_idle_bm_check()) { | 1507 | acpi_idle_update_bm_rld(pr, cx); |
1495 | cx = pr->power.bm_state; | ||
1496 | |||
1497 | acpi_idle_update_bm_rld(pr, cx); | ||
1498 | |||
1499 | t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); | ||
1500 | acpi_idle_do_entry(cx); | ||
1501 | t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); | ||
1502 | } else { | ||
1503 | acpi_idle_update_bm_rld(pr, cx); | ||
1504 | 1508 | ||
1509 | /* | ||
1510 | * disable bus master | ||
1511 | * bm_check implies we need ARB_DIS | ||
1512 | * !bm_check implies we need cache flush | ||
1513 | * bm_control implies whether we can do ARB_DIS | ||
1514 | * | ||
1515 | * That leaves a case where bm_check is set and bm_control is | ||
1516 | * not set. In that case we cannot do much, we enter C3 | ||
1517 | * without doing anything. | ||
1518 | */ | ||
1519 | if (pr->flags.bm_check && pr->flags.bm_control) { | ||
1505 | spin_lock(&c3_lock); | 1520 | spin_lock(&c3_lock); |
1506 | c3_cpu_count++; | 1521 | c3_cpu_count++; |
1507 | /* Disable bus master arbitration when all CPUs are in C3 */ | 1522 | /* Disable bus master arbitration when all CPUs are in C3 */ |
1508 | if (c3_cpu_count == num_online_cpus()) | 1523 | if (c3_cpu_count == num_online_cpus()) |
1509 | acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1); | 1524 | acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1); |
1510 | spin_unlock(&c3_lock); | 1525 | spin_unlock(&c3_lock); |
1526 | } else if (!pr->flags.bm_check) { | ||
1527 | ACPI_FLUSH_CPU_CACHE(); | ||
1528 | } | ||
1511 | 1529 | ||
1512 | t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); | 1530 | t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); |
1513 | acpi_idle_do_entry(cx); | 1531 | acpi_idle_do_entry(cx); |
1514 | t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); | 1532 | t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); |
1515 | 1533 | ||
1534 | /* Re-enable bus master arbitration */ | ||
1535 | if (pr->flags.bm_check && pr->flags.bm_control) { | ||
1516 | spin_lock(&c3_lock); | 1536 | spin_lock(&c3_lock); |
1517 | /* Re-enable bus master arbitration */ | 1537 | acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0); |
1518 | if (c3_cpu_count == num_online_cpus()) | ||
1519 | acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0); | ||
1520 | c3_cpu_count--; | 1538 | c3_cpu_count--; |
1521 | spin_unlock(&c3_lock); | 1539 | spin_unlock(&c3_lock); |
1522 | } | 1540 | } |
@@ -1525,6 +1543,9 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, | |||
1525 | /* TSC could halt in idle, so notify users */ | 1543 | /* TSC could halt in idle, so notify users */ |
1526 | mark_tsc_unstable("TSC halts in idle"); | 1544 | mark_tsc_unstable("TSC halts in idle"); |
1527 | #endif | 1545 | #endif |
1546 | sleep_ticks = ticks_elapsed(t1, t2); | ||
1547 | /* Tell the scheduler how much we idled: */ | ||
1548 | sched_clock_idle_wakeup_event(sleep_ticks*PM_TIMER_TICK_NS); | ||
1528 | 1549 | ||
1529 | local_irq_enable(); | 1550 | local_irq_enable(); |
1530 | current_thread_info()->status |= TS_POLLING; | 1551 | current_thread_info()->status |= TS_POLLING; |
@@ -1532,7 +1553,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, | |||
1532 | cx->usage++; | 1553 | cx->usage++; |
1533 | 1554 | ||
1534 | acpi_state_timer_broadcast(pr, cx, 0); | 1555 | acpi_state_timer_broadcast(pr, cx, 0); |
1535 | cx->time += ticks_elapsed(t1, t2); | 1556 | cx->time += sleep_ticks; |
1536 | return ticks_elapsed_in_us(t1, t2); | 1557 | return ticks_elapsed_in_us(t1, t2); |
1537 | } | 1558 | } |
1538 | 1559 | ||
@@ -1584,12 +1605,14 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) | |||
1584 | case ACPI_STATE_C1: | 1605 | case ACPI_STATE_C1: |
1585 | state->flags |= CPUIDLE_FLAG_SHALLOW; | 1606 | state->flags |= CPUIDLE_FLAG_SHALLOW; |
1586 | state->enter = acpi_idle_enter_c1; | 1607 | state->enter = acpi_idle_enter_c1; |
1608 | dev->safe_state = state; | ||
1587 | break; | 1609 | break; |
1588 | 1610 | ||
1589 | case ACPI_STATE_C2: | 1611 | case ACPI_STATE_C2: |
1590 | state->flags |= CPUIDLE_FLAG_BALANCED; | 1612 | state->flags |= CPUIDLE_FLAG_BALANCED; |
1591 | state->flags |= CPUIDLE_FLAG_TIME_VALID; | 1613 | state->flags |= CPUIDLE_FLAG_TIME_VALID; |
1592 | state->enter = acpi_idle_enter_simple; | 1614 | state->enter = acpi_idle_enter_simple; |
1615 | dev->safe_state = state; | ||
1593 | break; | 1616 | break; |
1594 | 1617 | ||
1595 | case ACPI_STATE_C3: | 1618 | case ACPI_STATE_C3: |
@@ -1610,14 +1633,6 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) | |||
1610 | if (!count) | 1633 | if (!count) |
1611 | return -EINVAL; | 1634 | return -EINVAL; |
1612 | 1635 | ||
1613 | /* find the deepest state that can handle active BM */ | ||
1614 | if (pr->flags.bm_check) { | ||
1615 | for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) | ||
1616 | if (pr->power.states[i].type == ACPI_STATE_C3) | ||
1617 | break; | ||
1618 | pr->power.bm_state = &pr->power.states[i-1]; | ||
1619 | } | ||
1620 | |||
1621 | return 0; | 1636 | return 0; |
1622 | } | 1637 | } |
1623 | 1638 | ||
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index 0b8204e7082a..c26c61fb36c3 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c | |||
@@ -70,7 +70,55 @@ static int acpi_processor_get_platform_limit(struct acpi_processor *pr) | |||
70 | 70 | ||
71 | int acpi_processor_tstate_has_changed(struct acpi_processor *pr) | 71 | int acpi_processor_tstate_has_changed(struct acpi_processor *pr) |
72 | { | 72 | { |
73 | return acpi_processor_get_platform_limit(pr); | 73 | int result = 0; |
74 | int throttling_limit; | ||
75 | int current_state; | ||
76 | struct acpi_processor_limit *limit; | ||
77 | int target_state; | ||
78 | |||
79 | result = acpi_processor_get_platform_limit(pr); | ||
80 | if (result) { | ||
81 | /* Throttling Limit is unsupported */ | ||
82 | return result; | ||
83 | } | ||
84 | |||
85 | throttling_limit = pr->throttling_platform_limit; | ||
86 | if (throttling_limit >= pr->throttling.state_count) { | ||
87 | /* Uncorrect Throttling Limit */ | ||
88 | return -EINVAL; | ||
89 | } | ||
90 | |||
91 | current_state = pr->throttling.state; | ||
92 | if (current_state > throttling_limit) { | ||
93 | /* | ||
94 | * The current state can meet the requirement of | ||
95 | * _TPC limit. But it is reasonable that OSPM changes | ||
96 | * t-states from high to low for better performance. | ||
97 | * Of course the limit condition of thermal | ||
98 | * and user should be considered. | ||
99 | */ | ||
100 | limit = &pr->limit; | ||
101 | target_state = throttling_limit; | ||
102 | if (limit->thermal.tx > target_state) | ||
103 | target_state = limit->thermal.tx; | ||
104 | if (limit->user.tx > target_state) | ||
105 | target_state = limit->user.tx; | ||
106 | } else if (current_state == throttling_limit) { | ||
107 | /* | ||
108 | * Unnecessary to change the throttling state | ||
109 | */ | ||
110 | return 0; | ||
111 | } else { | ||
112 | /* | ||
113 | * If the current state is lower than the limit of _TPC, it | ||
114 | * will be forced to switch to the throttling state defined | ||
115 | * by throttling_platfor_limit. | ||
116 | * Because the previous state meets with the limit condition | ||
117 | * of thermal and user, it is unnecessary to check it again. | ||
118 | */ | ||
119 | target_state = throttling_limit; | ||
120 | } | ||
121 | return acpi_processor_set_throttling(pr, target_state); | ||
74 | } | 122 | } |
75 | 123 | ||
76 | /* | 124 | /* |
@@ -83,6 +131,7 @@ static int acpi_processor_get_throttling_control(struct acpi_processor *pr) | |||
83 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | 131 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
84 | union acpi_object *ptc = NULL; | 132 | union acpi_object *ptc = NULL; |
85 | union acpi_object obj = { 0 }; | 133 | union acpi_object obj = { 0 }; |
134 | struct acpi_processor_throttling *throttling; | ||
86 | 135 | ||
87 | status = acpi_evaluate_object(pr->handle, "_PTC", NULL, &buffer); | 136 | status = acpi_evaluate_object(pr->handle, "_PTC", NULL, &buffer); |
88 | if (ACPI_FAILURE(status)) { | 137 | if (ACPI_FAILURE(status)) { |
@@ -134,6 +183,22 @@ static int acpi_processor_get_throttling_control(struct acpi_processor *pr) | |||
134 | memcpy(&pr->throttling.status_register, obj.buffer.pointer, | 183 | memcpy(&pr->throttling.status_register, obj.buffer.pointer, |
135 | sizeof(struct acpi_ptc_register)); | 184 | sizeof(struct acpi_ptc_register)); |
136 | 185 | ||
186 | throttling = &pr->throttling; | ||
187 | |||
188 | if ((throttling->control_register.bit_width + | ||
189 | throttling->control_register.bit_offset) > 32) { | ||
190 | printk(KERN_ERR PREFIX "Invalid _PTC control register\n"); | ||
191 | result = -EFAULT; | ||
192 | goto end; | ||
193 | } | ||
194 | |||
195 | if ((throttling->status_register.bit_width + | ||
196 | throttling->status_register.bit_offset) > 32) { | ||
197 | printk(KERN_ERR PREFIX "Invalid _PTC status register\n"); | ||
198 | result = -EFAULT; | ||
199 | goto end; | ||
200 | } | ||
201 | |||
137 | end: | 202 | end: |
138 | kfree(buffer.pointer); | 203 | kfree(buffer.pointer); |
139 | 204 | ||
@@ -328,44 +393,132 @@ static int acpi_processor_get_throttling_fadt(struct acpi_processor *pr) | |||
328 | return 0; | 393 | return 0; |
329 | } | 394 | } |
330 | 395 | ||
331 | static int acpi_read_throttling_status(struct acpi_processor_throttling | 396 | #ifdef CONFIG_X86 |
332 | *throttling) | 397 | static int acpi_throttling_rdmsr(struct acpi_processor *pr, |
398 | acpi_integer * value) | ||
333 | { | 399 | { |
334 | int value = -1; | 400 | struct cpuinfo_x86 *c; |
401 | u64 msr_high, msr_low; | ||
402 | unsigned int cpu; | ||
403 | u64 msr = 0; | ||
404 | int ret = -1; | ||
405 | |||
406 | cpu = pr->id; | ||
407 | c = &cpu_data(cpu); | ||
408 | |||
409 | if ((c->x86_vendor != X86_VENDOR_INTEL) || | ||
410 | !cpu_has(c, X86_FEATURE_ACPI)) { | ||
411 | printk(KERN_ERR PREFIX | ||
412 | "HARDWARE addr space,NOT supported yet\n"); | ||
413 | } else { | ||
414 | msr_low = 0; | ||
415 | msr_high = 0; | ||
416 | rdmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL, | ||
417 | (u32 *)&msr_low , (u32 *) &msr_high); | ||
418 | msr = (msr_high << 32) | msr_low; | ||
419 | *value = (acpi_integer) msr; | ||
420 | ret = 0; | ||
421 | } | ||
422 | return ret; | ||
423 | } | ||
424 | |||
425 | static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value) | ||
426 | { | ||
427 | struct cpuinfo_x86 *c; | ||
428 | unsigned int cpu; | ||
429 | int ret = -1; | ||
430 | u64 msr; | ||
431 | |||
432 | cpu = pr->id; | ||
433 | c = &cpu_data(cpu); | ||
434 | |||
435 | if ((c->x86_vendor != X86_VENDOR_INTEL) || | ||
436 | !cpu_has(c, X86_FEATURE_ACPI)) { | ||
437 | printk(KERN_ERR PREFIX | ||
438 | "HARDWARE addr space,NOT supported yet\n"); | ||
439 | } else { | ||
440 | msr = value; | ||
441 | wrmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL, | ||
442 | msr & 0xffffffff, msr >> 32); | ||
443 | ret = 0; | ||
444 | } | ||
445 | return ret; | ||
446 | } | ||
447 | #else | ||
448 | static int acpi_throttling_rdmsr(struct acpi_processor *pr, | ||
449 | acpi_integer * value) | ||
450 | { | ||
451 | printk(KERN_ERR PREFIX | ||
452 | "HARDWARE addr space,NOT supported yet\n"); | ||
453 | return -1; | ||
454 | } | ||
455 | |||
456 | static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value) | ||
457 | { | ||
458 | printk(KERN_ERR PREFIX | ||
459 | "HARDWARE addr space,NOT supported yet\n"); | ||
460 | return -1; | ||
461 | } | ||
462 | #endif | ||
463 | |||
464 | static int acpi_read_throttling_status(struct acpi_processor *pr, | ||
465 | acpi_integer *value) | ||
466 | { | ||
467 | u32 bit_width, bit_offset; | ||
468 | u64 ptc_value; | ||
469 | u64 ptc_mask; | ||
470 | struct acpi_processor_throttling *throttling; | ||
471 | int ret = -1; | ||
472 | |||
473 | throttling = &pr->throttling; | ||
335 | switch (throttling->status_register.space_id) { | 474 | switch (throttling->status_register.space_id) { |
336 | case ACPI_ADR_SPACE_SYSTEM_IO: | 475 | case ACPI_ADR_SPACE_SYSTEM_IO: |
476 | ptc_value = 0; | ||
477 | bit_width = throttling->status_register.bit_width; | ||
478 | bit_offset = throttling->status_register.bit_offset; | ||
479 | |||
337 | acpi_os_read_port((acpi_io_address) throttling->status_register. | 480 | acpi_os_read_port((acpi_io_address) throttling->status_register. |
338 | address, &value, | 481 | address, (u32 *) &ptc_value, |
339 | (u32) throttling->status_register.bit_width * | 482 | (u32) (bit_width + bit_offset)); |
340 | 8); | 483 | ptc_mask = (1 << bit_width) - 1; |
484 | *value = (acpi_integer) ((ptc_value >> bit_offset) & ptc_mask); | ||
485 | ret = 0; | ||
341 | break; | 486 | break; |
342 | case ACPI_ADR_SPACE_FIXED_HARDWARE: | 487 | case ACPI_ADR_SPACE_FIXED_HARDWARE: |
343 | printk(KERN_ERR PREFIX | 488 | ret = acpi_throttling_rdmsr(pr, value); |
344 | "HARDWARE addr space,NOT supported yet\n"); | ||
345 | break; | 489 | break; |
346 | default: | 490 | default: |
347 | printk(KERN_ERR PREFIX "Unknown addr space %d\n", | 491 | printk(KERN_ERR PREFIX "Unknown addr space %d\n", |
348 | (u32) (throttling->status_register.space_id)); | 492 | (u32) (throttling->status_register.space_id)); |
349 | } | 493 | } |
350 | return value; | 494 | return ret; |
351 | } | 495 | } |
352 | 496 | ||
353 | static int acpi_write_throttling_state(struct acpi_processor_throttling | 497 | static int acpi_write_throttling_state(struct acpi_processor *pr, |
354 | *throttling, int value) | 498 | acpi_integer value) |
355 | { | 499 | { |
500 | u32 bit_width, bit_offset; | ||
501 | u64 ptc_value; | ||
502 | u64 ptc_mask; | ||
503 | struct acpi_processor_throttling *throttling; | ||
356 | int ret = -1; | 504 | int ret = -1; |
357 | 505 | ||
506 | throttling = &pr->throttling; | ||
358 | switch (throttling->control_register.space_id) { | 507 | switch (throttling->control_register.space_id) { |
359 | case ACPI_ADR_SPACE_SYSTEM_IO: | 508 | case ACPI_ADR_SPACE_SYSTEM_IO: |
509 | bit_width = throttling->control_register.bit_width; | ||
510 | bit_offset = throttling->control_register.bit_offset; | ||
511 | ptc_mask = (1 << bit_width) - 1; | ||
512 | ptc_value = value & ptc_mask; | ||
513 | |||
360 | acpi_os_write_port((acpi_io_address) throttling-> | 514 | acpi_os_write_port((acpi_io_address) throttling-> |
361 | control_register.address, value, | 515 | control_register.address, |
362 | (u32) throttling->control_register. | 516 | (u32) (ptc_value << bit_offset), |
363 | bit_width * 8); | 517 | (u32) (bit_width + bit_offset)); |
364 | ret = 0; | 518 | ret = 0; |
365 | break; | 519 | break; |
366 | case ACPI_ADR_SPACE_FIXED_HARDWARE: | 520 | case ACPI_ADR_SPACE_FIXED_HARDWARE: |
367 | printk(KERN_ERR PREFIX | 521 | ret = acpi_throttling_wrmsr(pr, value); |
368 | "HARDWARE addr space,NOT supported yet\n"); | ||
369 | break; | 522 | break; |
370 | default: | 523 | default: |
371 | printk(KERN_ERR PREFIX "Unknown addr space %d\n", | 524 | printk(KERN_ERR PREFIX "Unknown addr space %d\n", |
@@ -374,7 +527,8 @@ static int acpi_write_throttling_state(struct acpi_processor_throttling | |||
374 | return ret; | 527 | return ret; |
375 | } | 528 | } |
376 | 529 | ||
377 | static int acpi_get_throttling_state(struct acpi_processor *pr, int value) | 530 | static int acpi_get_throttling_state(struct acpi_processor *pr, |
531 | acpi_integer value) | ||
378 | { | 532 | { |
379 | int i; | 533 | int i; |
380 | 534 | ||
@@ -390,22 +544,26 @@ static int acpi_get_throttling_state(struct acpi_processor *pr, int value) | |||
390 | return i; | 544 | return i; |
391 | } | 545 | } |
392 | 546 | ||
393 | static int acpi_get_throttling_value(struct acpi_processor *pr, int state) | 547 | static int acpi_get_throttling_value(struct acpi_processor *pr, |
548 | int state, acpi_integer *value) | ||
394 | { | 549 | { |
395 | int value = -1; | 550 | int ret = -1; |
551 | |||
396 | if (state >= 0 && state <= pr->throttling.state_count) { | 552 | if (state >= 0 && state <= pr->throttling.state_count) { |
397 | struct acpi_processor_tx_tss *tx = | 553 | struct acpi_processor_tx_tss *tx = |
398 | (struct acpi_processor_tx_tss *)&(pr->throttling. | 554 | (struct acpi_processor_tx_tss *)&(pr->throttling. |
399 | states_tss[state]); | 555 | states_tss[state]); |
400 | value = tx->control; | 556 | *value = tx->control; |
557 | ret = 0; | ||
401 | } | 558 | } |
402 | return value; | 559 | return ret; |
403 | } | 560 | } |
404 | 561 | ||
405 | static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr) | 562 | static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr) |
406 | { | 563 | { |
407 | int state = 0; | 564 | int state = 0; |
408 | u32 value = 0; | 565 | int ret; |
566 | acpi_integer value; | ||
409 | 567 | ||
410 | if (!pr) | 568 | if (!pr) |
411 | return -EINVAL; | 569 | return -EINVAL; |
@@ -415,8 +573,9 @@ static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr) | |||
415 | 573 | ||
416 | pr->throttling.state = 0; | 574 | pr->throttling.state = 0; |
417 | local_irq_disable(); | 575 | local_irq_disable(); |
418 | value = acpi_read_throttling_status(&pr->throttling); | 576 | value = 0; |
419 | if (value >= 0) { | 577 | ret = acpi_read_throttling_status(pr, &value); |
578 | if (ret >= 0) { | ||
420 | state = acpi_get_throttling_state(pr, value); | 579 | state = acpi_get_throttling_state(pr, value); |
421 | pr->throttling.state = state; | 580 | pr->throttling.state = state; |
422 | } | 581 | } |
@@ -430,6 +589,40 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr) | |||
430 | return pr->throttling.acpi_processor_get_throttling(pr); | 589 | return pr->throttling.acpi_processor_get_throttling(pr); |
431 | } | 590 | } |
432 | 591 | ||
592 | static int acpi_processor_get_fadt_info(struct acpi_processor *pr) | ||
593 | { | ||
594 | int i, step; | ||
595 | |||
596 | if (!pr->throttling.address) { | ||
597 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n")); | ||
598 | return -EINVAL; | ||
599 | } else if (!pr->throttling.duty_width) { | ||
600 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n")); | ||
601 | return -EINVAL; | ||
602 | } | ||
603 | /* TBD: Support duty_cycle values that span bit 4. */ | ||
604 | else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) { | ||
605 | printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n"); | ||
606 | return -EINVAL; | ||
607 | } | ||
608 | |||
609 | pr->throttling.state_count = 1 << acpi_gbl_FADT.duty_width; | ||
610 | |||
611 | /* | ||
612 | * Compute state values. Note that throttling displays a linear power | ||
613 | * performance relationship (at 50% performance the CPU will consume | ||
614 | * 50% power). Values are in 1/10th of a percent to preserve accuracy. | ||
615 | */ | ||
616 | |||
617 | step = (1000 / pr->throttling.state_count); | ||
618 | |||
619 | for (i = 0; i < pr->throttling.state_count; i++) { | ||
620 | pr->throttling.states[i].performance = 1000 - step * i; | ||
621 | pr->throttling.states[i].power = 1000 - step * i; | ||
622 | } | ||
623 | return 0; | ||
624 | } | ||
625 | |||
433 | static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr, | 626 | static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr, |
434 | int state) | 627 | int state) |
435 | { | 628 | { |
@@ -506,7 +699,8 @@ static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr, | |||
506 | static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr, | 699 | static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr, |
507 | int state) | 700 | int state) |
508 | { | 701 | { |
509 | u32 value = 0; | 702 | int ret; |
703 | acpi_integer value; | ||
510 | 704 | ||
511 | if (!pr) | 705 | if (!pr) |
512 | return -EINVAL; | 706 | return -EINVAL; |
@@ -524,10 +718,10 @@ static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr, | |||
524 | return -EPERM; | 718 | return -EPERM; |
525 | 719 | ||
526 | local_irq_disable(); | 720 | local_irq_disable(); |
527 | 721 | value = 0; | |
528 | value = acpi_get_throttling_value(pr, state); | 722 | ret = acpi_get_throttling_value(pr, state, &value); |
529 | if (value >= 0) { | 723 | if (ret >= 0) { |
530 | acpi_write_throttling_state(&pr->throttling, value); | 724 | acpi_write_throttling_state(pr, value); |
531 | pr->throttling.state = state; | 725 | pr->throttling.state = state; |
532 | } | 726 | } |
533 | local_irq_enable(); | 727 | local_irq_enable(); |
@@ -543,8 +737,6 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state) | |||
543 | int acpi_processor_get_throttling_info(struct acpi_processor *pr) | 737 | int acpi_processor_get_throttling_info(struct acpi_processor *pr) |
544 | { | 738 | { |
545 | int result = 0; | 739 | int result = 0; |
546 | int step = 0; | ||
547 | int i = 0; | ||
548 | 740 | ||
549 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 741 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
550 | "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n", | 742 | "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n", |
@@ -563,6 +755,8 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr) | |||
563 | acpi_processor_get_throttling_states(pr) || | 755 | acpi_processor_get_throttling_states(pr) || |
564 | acpi_processor_get_platform_limit(pr)) | 756 | acpi_processor_get_platform_limit(pr)) |
565 | { | 757 | { |
758 | if (acpi_processor_get_fadt_info(pr)) | ||
759 | return 0; | ||
566 | pr->throttling.acpi_processor_get_throttling = | 760 | pr->throttling.acpi_processor_get_throttling = |
567 | &acpi_processor_get_throttling_fadt; | 761 | &acpi_processor_get_throttling_fadt; |
568 | pr->throttling.acpi_processor_set_throttling = | 762 | pr->throttling.acpi_processor_set_throttling = |
@@ -576,19 +770,6 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr) | |||
576 | 770 | ||
577 | acpi_processor_get_tsd(pr); | 771 | acpi_processor_get_tsd(pr); |
578 | 772 | ||
579 | if (!pr->throttling.address) { | ||
580 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n")); | ||
581 | return 0; | ||
582 | } else if (!pr->throttling.duty_width) { | ||
583 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n")); | ||
584 | return 0; | ||
585 | } | ||
586 | /* TBD: Support duty_cycle values that span bit 4. */ | ||
587 | else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) { | ||
588 | printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n"); | ||
589 | return 0; | ||
590 | } | ||
591 | |||
592 | /* | 773 | /* |
593 | * PIIX4 Errata: We don't support throttling on the original PIIX4. | 774 | * PIIX4 Errata: We don't support throttling on the original PIIX4. |
594 | * This shouldn't be an issue as few (if any) mobile systems ever | 775 | * This shouldn't be an issue as few (if any) mobile systems ever |
@@ -600,21 +781,6 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr) | |||
600 | return 0; | 781 | return 0; |
601 | } | 782 | } |
602 | 783 | ||
603 | pr->throttling.state_count = 1 << acpi_gbl_FADT.duty_width; | ||
604 | |||
605 | /* | ||
606 | * Compute state values. Note that throttling displays a linear power/ | ||
607 | * performance relationship (at 50% performance the CPU will consume | ||
608 | * 50% power). Values are in 1/10th of a percent to preserve accuracy. | ||
609 | */ | ||
610 | |||
611 | step = (1000 / pr->throttling.state_count); | ||
612 | |||
613 | for (i = 0; i < pr->throttling.state_count; i++) { | ||
614 | pr->throttling.states[i].performance = step * i; | ||
615 | pr->throttling.states[i].power = step * i; | ||
616 | } | ||
617 | |||
618 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d throttling states\n", | 784 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d throttling states\n", |
619 | pr->throttling.state_count)); | 785 | pr->throttling.state_count)); |
620 | 786 | ||
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index 90fd09c65f95..6045cdbe176b 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <linux/moduleparam.h> | 29 | #include <linux/moduleparam.h> |
30 | #include <linux/kernel.h> | 30 | #include <linux/kernel.h> |
31 | 31 | ||
32 | #ifdef CONFIG_ACPI_PROCFS | 32 | #ifdef CONFIG_ACPI_PROCFS_POWER |
33 | #include <linux/proc_fs.h> | 33 | #include <linux/proc_fs.h> |
34 | #include <linux/seq_file.h> | 34 | #include <linux/seq_file.h> |
35 | #include <asm/uaccess.h> | 35 | #include <asm/uaccess.h> |
@@ -88,7 +88,7 @@ MODULE_DEVICE_TABLE(acpi, sbs_device_ids); | |||
88 | struct acpi_battery { | 88 | struct acpi_battery { |
89 | struct power_supply bat; | 89 | struct power_supply bat; |
90 | struct acpi_sbs *sbs; | 90 | struct acpi_sbs *sbs; |
91 | #ifdef CONFIG_ACPI_PROCFS | 91 | #ifdef CONFIG_ACPI_PROCFS_POWER |
92 | struct proc_dir_entry *proc_entry; | 92 | struct proc_dir_entry *proc_entry; |
93 | #endif | 93 | #endif |
94 | unsigned long update_time; | 94 | unsigned long update_time; |
@@ -113,6 +113,7 @@ struct acpi_battery { | |||
113 | u16 spec; | 113 | u16 spec; |
114 | u8 id; | 114 | u8 id; |
115 | u8 present:1; | 115 | u8 present:1; |
116 | u8 have_sysfs_alarm:1; | ||
116 | }; | 117 | }; |
117 | 118 | ||
118 | #define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); | 119 | #define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); |
@@ -122,7 +123,7 @@ struct acpi_sbs { | |||
122 | struct acpi_device *device; | 123 | struct acpi_device *device; |
123 | struct acpi_smb_hc *hc; | 124 | struct acpi_smb_hc *hc; |
124 | struct mutex lock; | 125 | struct mutex lock; |
125 | #ifdef CONFIG_ACPI_PROCFS | 126 | #ifdef CONFIG_ACPI_PROCFS_POWER |
126 | struct proc_dir_entry *charger_entry; | 127 | struct proc_dir_entry *charger_entry; |
127 | #endif | 128 | #endif |
128 | struct acpi_battery battery[MAX_SBS_BAT]; | 129 | struct acpi_battery battery[MAX_SBS_BAT]; |
@@ -468,7 +469,7 @@ static struct device_attribute alarm_attr = { | |||
468 | FS Interface (/proc/acpi) | 469 | FS Interface (/proc/acpi) |
469 | -------------------------------------------------------------------------- */ | 470 | -------------------------------------------------------------------------- */ |
470 | 471 | ||
471 | #ifdef CONFIG_ACPI_PROCFS | 472 | #ifdef CONFIG_ACPI_PROCFS_POWER |
472 | /* Generic Routines */ | 473 | /* Generic Routines */ |
473 | static int | 474 | static int |
474 | acpi_sbs_add_fs(struct proc_dir_entry **dir, | 475 | acpi_sbs_add_fs(struct proc_dir_entry **dir, |
@@ -789,7 +790,7 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id) | |||
789 | return result; | 790 | return result; |
790 | 791 | ||
791 | sprintf(battery->name, ACPI_BATTERY_DIR_NAME, id); | 792 | sprintf(battery->name, ACPI_BATTERY_DIR_NAME, id); |
792 | #ifdef CONFIG_ACPI_PROCFS | 793 | #ifdef CONFIG_ACPI_PROCFS_POWER |
793 | acpi_sbs_add_fs(&battery->proc_entry, acpi_battery_dir, | 794 | acpi_sbs_add_fs(&battery->proc_entry, acpi_battery_dir, |
794 | battery->name, &acpi_battery_info_fops, | 795 | battery->name, &acpi_battery_info_fops, |
795 | &acpi_battery_state_fops, &acpi_battery_alarm_fops, | 796 | &acpi_battery_state_fops, &acpi_battery_alarm_fops, |
@@ -808,7 +809,13 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id) | |||
808 | } | 809 | } |
809 | battery->bat.get_property = acpi_sbs_battery_get_property; | 810 | battery->bat.get_property = acpi_sbs_battery_get_property; |
810 | result = power_supply_register(&sbs->device->dev, &battery->bat); | 811 | result = power_supply_register(&sbs->device->dev, &battery->bat); |
811 | device_create_file(battery->bat.dev, &alarm_attr); | 812 | if (result) |
813 | goto end; | ||
814 | result = device_create_file(battery->bat.dev, &alarm_attr); | ||
815 | if (result) | ||
816 | goto end; | ||
817 | battery->have_sysfs_alarm = 1; | ||
818 | end: | ||
812 | printk(KERN_INFO PREFIX "%s [%s]: Battery Slot [%s] (battery %s)\n", | 819 | printk(KERN_INFO PREFIX "%s [%s]: Battery Slot [%s] (battery %s)\n", |
813 | ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), | 820 | ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), |
814 | battery->name, sbs->battery->present ? "present" : "absent"); | 821 | battery->name, sbs->battery->present ? "present" : "absent"); |
@@ -817,14 +824,16 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id) | |||
817 | 824 | ||
818 | static void acpi_battery_remove(struct acpi_sbs *sbs, int id) | 825 | static void acpi_battery_remove(struct acpi_sbs *sbs, int id) |
819 | { | 826 | { |
820 | if (sbs->battery[id].bat.dev) | 827 | struct acpi_battery *battery = &sbs->battery[id]; |
821 | device_remove_file(sbs->battery[id].bat.dev, &alarm_attr); | 828 | |
822 | power_supply_unregister(&sbs->battery[id].bat); | 829 | if (battery->bat.dev) { |
823 | #ifdef CONFIG_ACPI_PROCFS | 830 | if (battery->have_sysfs_alarm) |
824 | if (sbs->battery[id].proc_entry) { | 831 | device_remove_file(battery->bat.dev, &alarm_attr); |
825 | acpi_sbs_remove_fs(&(sbs->battery[id].proc_entry), | 832 | power_supply_unregister(&battery->bat); |
826 | acpi_battery_dir); | ||
827 | } | 833 | } |
834 | #ifdef CONFIG_ACPI_PROCFS_POWER | ||
835 | if (battery->proc_entry) | ||
836 | acpi_sbs_remove_fs(&battery->proc_entry, acpi_battery_dir); | ||
828 | #endif | 837 | #endif |
829 | } | 838 | } |
830 | 839 | ||
@@ -835,7 +844,7 @@ static int acpi_charger_add(struct acpi_sbs *sbs) | |||
835 | result = acpi_ac_get_present(sbs); | 844 | result = acpi_ac_get_present(sbs); |
836 | if (result) | 845 | if (result) |
837 | goto end; | 846 | goto end; |
838 | #ifdef CONFIG_ACPI_PROCFS | 847 | #ifdef CONFIG_ACPI_PROCFS_POWER |
839 | result = acpi_sbs_add_fs(&sbs->charger_entry, acpi_ac_dir, | 848 | result = acpi_sbs_add_fs(&sbs->charger_entry, acpi_ac_dir, |
840 | ACPI_AC_DIR_NAME, NULL, | 849 | ACPI_AC_DIR_NAME, NULL, |
841 | &acpi_ac_state_fops, NULL, sbs); | 850 | &acpi_ac_state_fops, NULL, sbs); |
@@ -859,7 +868,7 @@ static void acpi_charger_remove(struct acpi_sbs *sbs) | |||
859 | { | 868 | { |
860 | if (sbs->charger.dev) | 869 | if (sbs->charger.dev) |
861 | power_supply_unregister(&sbs->charger); | 870 | power_supply_unregister(&sbs->charger); |
862 | #ifdef CONFIG_ACPI_PROCFS | 871 | #ifdef CONFIG_ACPI_PROCFS_POWER |
863 | if (sbs->charger_entry) | 872 | if (sbs->charger_entry) |
864 | acpi_sbs_remove_fs(&sbs->charger_entry, acpi_ac_dir); | 873 | acpi_sbs_remove_fs(&sbs->charger_entry, acpi_ac_dir); |
865 | #endif | 874 | #endif |
@@ -965,7 +974,7 @@ static int acpi_sbs_remove(struct acpi_device *device, int type) | |||
965 | 974 | ||
966 | static void acpi_sbs_rmdirs(void) | 975 | static void acpi_sbs_rmdirs(void) |
967 | { | 976 | { |
968 | #ifdef CONFIG_ACPI_PROCFS | 977 | #ifdef CONFIG_ACPI_PROCFS_POWER |
969 | if (acpi_ac_dir) { | 978 | if (acpi_ac_dir) { |
970 | acpi_unlock_ac_dir(acpi_ac_dir); | 979 | acpi_unlock_ac_dir(acpi_ac_dir); |
971 | acpi_ac_dir = NULL; | 980 | acpi_ac_dir = NULL; |
@@ -1004,7 +1013,7 @@ static int __init acpi_sbs_init(void) | |||
1004 | 1013 | ||
1005 | if (acpi_disabled) | 1014 | if (acpi_disabled) |
1006 | return -ENODEV; | 1015 | return -ENODEV; |
1007 | #ifdef CONFIG_ACPI_PROCFS | 1016 | #ifdef CONFIG_ACPI_PROCFS_POWER |
1008 | acpi_ac_dir = acpi_lock_ac_dir(); | 1017 | acpi_ac_dir = acpi_lock_ac_dir(); |
1009 | if (!acpi_ac_dir) | 1018 | if (!acpi_ac_dir) |
1010 | return -ENODEV; | 1019 | return -ENODEV; |
diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c index 5f1d85f2ffe4..010f19652f80 100644 --- a/drivers/acpi/tables/tbutils.c +++ b/drivers/acpi/tables/tbutils.c | |||
@@ -449,7 +449,7 @@ acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags) | |||
449 | /* XSDT has NULL entry, RSDT is used */ | 449 | /* XSDT has NULL entry, RSDT is used */ |
450 | address = rsdt_address; | 450 | address = rsdt_address; |
451 | table_entry_size = sizeof(u32); | 451 | table_entry_size = sizeof(u32); |
452 | ACPI_WARNING((AE_INFO, "BIOS XSDT has NULL entry," | 452 | ACPI_WARNING((AE_INFO, "BIOS XSDT has NULL entry, " |
453 | "using RSDT")); | 453 | "using RSDT")); |
454 | } | 454 | } |
455 | } | 455 | } |
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index bac956b30c57..44a0d9ba9bd6 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/init.h> | 29 | #include <linux/init.h> |
30 | #include <linux/types.h> | 30 | #include <linux/types.h> |
31 | #include <linux/list.h> | 31 | #include <linux/list.h> |
32 | #include <linux/mutex.h> | ||
32 | #include <linux/proc_fs.h> | 33 | #include <linux/proc_fs.h> |
33 | #include <linux/seq_file.h> | 34 | #include <linux/seq_file.h> |
34 | #include <linux/input.h> | 35 | #include <linux/input.h> |
@@ -135,8 +136,8 @@ struct acpi_video_bus { | |||
135 | u8 attached_count; | 136 | u8 attached_count; |
136 | struct acpi_video_bus_cap cap; | 137 | struct acpi_video_bus_cap cap; |
137 | struct acpi_video_bus_flags flags; | 138 | struct acpi_video_bus_flags flags; |
138 | struct semaphore sem; | ||
139 | struct list_head video_device_list; | 139 | struct list_head video_device_list; |
140 | struct mutex device_list_lock; /* protects video_device_list */ | ||
140 | struct proc_dir_entry *dir; | 141 | struct proc_dir_entry *dir; |
141 | struct input_dev *input; | 142 | struct input_dev *input; |
142 | char phys[32]; /* for input device */ | 143 | char phys[32]; /* for input device */ |
@@ -896,7 +897,7 @@ acpi_video_device_write_brightness(struct file *file, | |||
896 | { | 897 | { |
897 | struct seq_file *m = file->private_data; | 898 | struct seq_file *m = file->private_data; |
898 | struct acpi_video_device *dev = m->private; | 899 | struct acpi_video_device *dev = m->private; |
899 | char str[4] = { 0 }; | 900 | char str[5] = { 0 }; |
900 | unsigned int level = 0; | 901 | unsigned int level = 0; |
901 | int i; | 902 | int i; |
902 | 903 | ||
@@ -1436,9 +1437,9 @@ acpi_video_bus_get_one_device(struct acpi_device *device, | |||
1436 | return -ENODEV; | 1437 | return -ENODEV; |
1437 | } | 1438 | } |
1438 | 1439 | ||
1439 | down(&video->sem); | 1440 | mutex_lock(&video->device_list_lock); |
1440 | list_add_tail(&data->entry, &video->video_device_list); | 1441 | list_add_tail(&data->entry, &video->video_device_list); |
1441 | up(&video->sem); | 1442 | mutex_unlock(&video->device_list_lock); |
1442 | 1443 | ||
1443 | acpi_video_device_add_fs(device); | 1444 | acpi_video_device_add_fs(device); |
1444 | 1445 | ||
@@ -1462,12 +1463,14 @@ acpi_video_bus_get_one_device(struct acpi_device *device, | |||
1462 | 1463 | ||
1463 | static void acpi_video_device_rebind(struct acpi_video_bus *video) | 1464 | static void acpi_video_device_rebind(struct acpi_video_bus *video) |
1464 | { | 1465 | { |
1465 | struct list_head *node, *next; | 1466 | struct acpi_video_device *dev; |
1466 | list_for_each_safe(node, next, &video->video_device_list) { | 1467 | |
1467 | struct acpi_video_device *dev = | 1468 | mutex_lock(&video->device_list_lock); |
1468 | container_of(node, struct acpi_video_device, entry); | 1469 | |
1470 | list_for_each_entry(dev, &video->video_device_list, entry) | ||
1469 | acpi_video_device_bind(video, dev); | 1471 | acpi_video_device_bind(video, dev); |
1470 | } | 1472 | |
1473 | mutex_unlock(&video->device_list_lock); | ||
1471 | } | 1474 | } |
1472 | 1475 | ||
1473 | /* | 1476 | /* |
@@ -1592,30 +1595,33 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video) | |||
1592 | 1595 | ||
1593 | static int acpi_video_switch_output(struct acpi_video_bus *video, int event) | 1596 | static int acpi_video_switch_output(struct acpi_video_bus *video, int event) |
1594 | { | 1597 | { |
1595 | struct list_head *node, *next; | 1598 | struct list_head *node; |
1596 | struct acpi_video_device *dev = NULL; | 1599 | struct acpi_video_device *dev = NULL; |
1597 | struct acpi_video_device *dev_next = NULL; | 1600 | struct acpi_video_device *dev_next = NULL; |
1598 | struct acpi_video_device *dev_prev = NULL; | 1601 | struct acpi_video_device *dev_prev = NULL; |
1599 | unsigned long state; | 1602 | unsigned long state; |
1600 | int status = 0; | 1603 | int status = 0; |
1601 | 1604 | ||
1605 | mutex_lock(&video->device_list_lock); | ||
1602 | 1606 | ||
1603 | list_for_each_safe(node, next, &video->video_device_list) { | 1607 | list_for_each(node, &video->video_device_list) { |
1604 | dev = container_of(node, struct acpi_video_device, entry); | 1608 | dev = container_of(node, struct acpi_video_device, entry); |
1605 | status = acpi_video_device_get_state(dev, &state); | 1609 | status = acpi_video_device_get_state(dev, &state); |
1606 | if (state & 0x2) { | 1610 | if (state & 0x2) { |
1607 | dev_next = | 1611 | dev_next = container_of(node->next, |
1608 | container_of(node->next, struct acpi_video_device, | 1612 | struct acpi_video_device, entry); |
1609 | entry); | 1613 | dev_prev = container_of(node->prev, |
1610 | dev_prev = | 1614 | struct acpi_video_device, entry); |
1611 | container_of(node->prev, struct acpi_video_device, | ||
1612 | entry); | ||
1613 | goto out; | 1615 | goto out; |
1614 | } | 1616 | } |
1615 | } | 1617 | } |
1618 | |||
1616 | dev_next = container_of(node->next, struct acpi_video_device, entry); | 1619 | dev_next = container_of(node->next, struct acpi_video_device, entry); |
1617 | dev_prev = container_of(node->prev, struct acpi_video_device, entry); | 1620 | dev_prev = container_of(node->prev, struct acpi_video_device, entry); |
1618 | out: | 1621 | |
1622 | out: | ||
1623 | mutex_unlock(&video->device_list_lock); | ||
1624 | |||
1619 | switch (event) { | 1625 | switch (event) { |
1620 | case ACPI_VIDEO_NOTIFY_CYCLE: | 1626 | case ACPI_VIDEO_NOTIFY_CYCLE: |
1621 | case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: | 1627 | case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: |
@@ -1691,24 +1697,17 @@ acpi_video_bus_get_devices(struct acpi_video_bus *video, | |||
1691 | struct acpi_device *device) | 1697 | struct acpi_device *device) |
1692 | { | 1698 | { |
1693 | int status = 0; | 1699 | int status = 0; |
1694 | struct list_head *node, *next; | 1700 | struct acpi_device *dev; |
1695 | |||
1696 | 1701 | ||
1697 | acpi_video_device_enumerate(video); | 1702 | acpi_video_device_enumerate(video); |
1698 | 1703 | ||
1699 | list_for_each_safe(node, next, &device->children) { | 1704 | list_for_each_entry(dev, &device->children, node) { |
1700 | struct acpi_device *dev = | ||
1701 | list_entry(node, struct acpi_device, node); | ||
1702 | |||
1703 | if (!dev) | ||
1704 | continue; | ||
1705 | 1705 | ||
1706 | status = acpi_video_bus_get_one_device(dev, video); | 1706 | status = acpi_video_bus_get_one_device(dev, video); |
1707 | if (ACPI_FAILURE(status)) { | 1707 | if (ACPI_FAILURE(status)) { |
1708 | ACPI_EXCEPTION((AE_INFO, status, "Cant attach device")); | 1708 | ACPI_EXCEPTION((AE_INFO, status, "Cant attach device")); |
1709 | continue; | 1709 | continue; |
1710 | } | 1710 | } |
1711 | |||
1712 | } | 1711 | } |
1713 | return status; | 1712 | return status; |
1714 | } | 1713 | } |
@@ -1724,9 +1723,6 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device) | |||
1724 | 1723 | ||
1725 | video = device->video; | 1724 | video = device->video; |
1726 | 1725 | ||
1727 | down(&video->sem); | ||
1728 | list_del(&device->entry); | ||
1729 | up(&video->sem); | ||
1730 | acpi_video_device_remove_fs(device->dev); | 1726 | acpi_video_device_remove_fs(device->dev); |
1731 | 1727 | ||
1732 | status = acpi_remove_notify_handler(device->dev->handle, | 1728 | status = acpi_remove_notify_handler(device->dev->handle, |
@@ -1734,32 +1730,34 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device) | |||
1734 | acpi_video_device_notify); | 1730 | acpi_video_device_notify); |
1735 | backlight_device_unregister(device->backlight); | 1731 | backlight_device_unregister(device->backlight); |
1736 | video_output_unregister(device->output_dev); | 1732 | video_output_unregister(device->output_dev); |
1733 | |||
1737 | return 0; | 1734 | return 0; |
1738 | } | 1735 | } |
1739 | 1736 | ||
1740 | static int acpi_video_bus_put_devices(struct acpi_video_bus *video) | 1737 | static int acpi_video_bus_put_devices(struct acpi_video_bus *video) |
1741 | { | 1738 | { |
1742 | int status; | 1739 | int status; |
1743 | struct list_head *node, *next; | 1740 | struct acpi_video_device *dev, *next; |
1744 | 1741 | ||
1742 | mutex_lock(&video->device_list_lock); | ||
1745 | 1743 | ||
1746 | list_for_each_safe(node, next, &video->video_device_list) { | 1744 | list_for_each_entry_safe(dev, next, &video->video_device_list, entry) { |
1747 | struct acpi_video_device *data = | ||
1748 | list_entry(node, struct acpi_video_device, entry); | ||
1749 | if (!data) | ||
1750 | continue; | ||
1751 | 1745 | ||
1752 | status = acpi_video_bus_put_one_device(data); | 1746 | status = acpi_video_bus_put_one_device(dev); |
1753 | if (ACPI_FAILURE(status)) | 1747 | if (ACPI_FAILURE(status)) |
1754 | printk(KERN_WARNING PREFIX | 1748 | printk(KERN_WARNING PREFIX |
1755 | "hhuuhhuu bug in acpi video driver.\n"); | 1749 | "hhuuhhuu bug in acpi video driver.\n"); |
1756 | 1750 | ||
1757 | if (data->brightness) | 1751 | if (dev->brightness) { |
1758 | kfree(data->brightness->levels); | 1752 | kfree(dev->brightness->levels); |
1759 | kfree(data->brightness); | 1753 | kfree(dev->brightness); |
1760 | kfree(data); | 1754 | } |
1755 | list_del(&dev->entry); | ||
1756 | kfree(dev); | ||
1761 | } | 1757 | } |
1762 | 1758 | ||
1759 | mutex_unlock(&video->device_list_lock); | ||
1760 | |||
1763 | return 0; | 1761 | return 0; |
1764 | } | 1762 | } |
1765 | 1763 | ||
@@ -1782,9 +1780,6 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data) | |||
1782 | struct input_dev *input; | 1780 | struct input_dev *input; |
1783 | int keycode; | 1781 | int keycode; |
1784 | 1782 | ||
1785 | |||
1786 | printk("video bus notify\n"); | ||
1787 | |||
1788 | if (!video) | 1783 | if (!video) |
1789 | return; | 1784 | return; |
1790 | 1785 | ||
@@ -1897,14 +1892,10 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data) | |||
1897 | static int instance; | 1892 | static int instance; |
1898 | static int acpi_video_bus_add(struct acpi_device *device) | 1893 | static int acpi_video_bus_add(struct acpi_device *device) |
1899 | { | 1894 | { |
1900 | int result = 0; | 1895 | acpi_status status; |
1901 | acpi_status status = 0; | 1896 | struct acpi_video_bus *video; |
1902 | struct acpi_video_bus *video = NULL; | ||
1903 | struct input_dev *input; | 1897 | struct input_dev *input; |
1904 | 1898 | int error; | |
1905 | |||
1906 | if (!device) | ||
1907 | return -EINVAL; | ||
1908 | 1899 | ||
1909 | video = kzalloc(sizeof(struct acpi_video_bus), GFP_KERNEL); | 1900 | video = kzalloc(sizeof(struct acpi_video_bus), GFP_KERNEL); |
1910 | if (!video) | 1901 | if (!video) |
@@ -1923,15 +1914,15 @@ static int acpi_video_bus_add(struct acpi_device *device) | |||
1923 | acpi_driver_data(device) = video; | 1914 | acpi_driver_data(device) = video; |
1924 | 1915 | ||
1925 | acpi_video_bus_find_cap(video); | 1916 | acpi_video_bus_find_cap(video); |
1926 | result = acpi_video_bus_check(video); | 1917 | error = acpi_video_bus_check(video); |
1927 | if (result) | 1918 | if (error) |
1928 | goto end; | 1919 | goto err_free_video; |
1929 | 1920 | ||
1930 | result = acpi_video_bus_add_fs(device); | 1921 | error = acpi_video_bus_add_fs(device); |
1931 | if (result) | 1922 | if (error) |
1932 | goto end; | 1923 | goto err_free_video; |
1933 | 1924 | ||
1934 | init_MUTEX(&video->sem); | 1925 | mutex_init(&video->device_list_lock); |
1935 | INIT_LIST_HEAD(&video->video_device_list); | 1926 | INIT_LIST_HEAD(&video->video_device_list); |
1936 | 1927 | ||
1937 | acpi_video_bus_get_devices(video, device); | 1928 | acpi_video_bus_get_devices(video, device); |
@@ -1943,16 +1934,15 @@ static int acpi_video_bus_add(struct acpi_device *device) | |||
1943 | if (ACPI_FAILURE(status)) { | 1934 | if (ACPI_FAILURE(status)) { |
1944 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 1935 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
1945 | "Error installing notify handler\n")); | 1936 | "Error installing notify handler\n")); |
1946 | acpi_video_bus_stop_devices(video); | 1937 | error = -ENODEV; |
1947 | acpi_video_bus_put_devices(video); | 1938 | goto err_stop_video; |
1948 | kfree(video->attached_array); | ||
1949 | acpi_video_bus_remove_fs(device); | ||
1950 | result = -ENODEV; | ||
1951 | goto end; | ||
1952 | } | 1939 | } |
1953 | 1940 | ||
1954 | |||
1955 | video->input = input = input_allocate_device(); | 1941 | video->input = input = input_allocate_device(); |
1942 | if (!input) { | ||
1943 | error = -ENOMEM; | ||
1944 | goto err_uninstall_notify; | ||
1945 | } | ||
1956 | 1946 | ||
1957 | snprintf(video->phys, sizeof(video->phys), | 1947 | snprintf(video->phys, sizeof(video->phys), |
1958 | "%s/video/input0", acpi_device_hid(video->device)); | 1948 | "%s/video/input0", acpi_device_hid(video->device)); |
@@ -1961,6 +1951,7 @@ static int acpi_video_bus_add(struct acpi_device *device) | |||
1961 | input->phys = video->phys; | 1951 | input->phys = video->phys; |
1962 | input->id.bustype = BUS_HOST; | 1952 | input->id.bustype = BUS_HOST; |
1963 | input->id.product = 0x06; | 1953 | input->id.product = 0x06; |
1954 | input->dev.parent = &device->dev; | ||
1964 | input->evbit[0] = BIT(EV_KEY); | 1955 | input->evbit[0] = BIT(EV_KEY); |
1965 | set_bit(KEY_SWITCHVIDEOMODE, input->keybit); | 1956 | set_bit(KEY_SWITCHVIDEOMODE, input->keybit); |
1966 | set_bit(KEY_VIDEO_NEXT, input->keybit); | 1957 | set_bit(KEY_VIDEO_NEXT, input->keybit); |
@@ -1971,18 +1962,10 @@ static int acpi_video_bus_add(struct acpi_device *device) | |||
1971 | set_bit(KEY_BRIGHTNESS_ZERO, input->keybit); | 1962 | set_bit(KEY_BRIGHTNESS_ZERO, input->keybit); |
1972 | set_bit(KEY_DISPLAY_OFF, input->keybit); | 1963 | set_bit(KEY_DISPLAY_OFF, input->keybit); |
1973 | set_bit(KEY_UNKNOWN, input->keybit); | 1964 | set_bit(KEY_UNKNOWN, input->keybit); |
1974 | result = input_register_device(input); | ||
1975 | if (result) { | ||
1976 | acpi_remove_notify_handler(video->device->handle, | ||
1977 | ACPI_DEVICE_NOTIFY, | ||
1978 | acpi_video_bus_notify); | ||
1979 | acpi_video_bus_stop_devices(video); | ||
1980 | acpi_video_bus_put_devices(video); | ||
1981 | kfree(video->attached_array); | ||
1982 | acpi_video_bus_remove_fs(device); | ||
1983 | goto end; | ||
1984 | } | ||
1985 | 1965 | ||
1966 | error = input_register_device(input); | ||
1967 | if (error) | ||
1968 | goto err_free_input_dev; | ||
1986 | 1969 | ||
1987 | printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s rom: %s post: %s)\n", | 1970 | printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s rom: %s post: %s)\n", |
1988 | ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device), | 1971 | ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device), |
@@ -1990,11 +1973,23 @@ static int acpi_video_bus_add(struct acpi_device *device) | |||
1990 | video->flags.rom ? "yes" : "no", | 1973 | video->flags.rom ? "yes" : "no", |
1991 | video->flags.post ? "yes" : "no"); | 1974 | video->flags.post ? "yes" : "no"); |
1992 | 1975 | ||
1993 | end: | 1976 | return 0; |
1994 | if (result) | 1977 | |
1995 | kfree(video); | 1978 | err_free_input_dev: |
1979 | input_free_device(input); | ||
1980 | err_uninstall_notify: | ||
1981 | acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, | ||
1982 | acpi_video_bus_notify); | ||
1983 | err_stop_video: | ||
1984 | acpi_video_bus_stop_devices(video); | ||
1985 | acpi_video_bus_put_devices(video); | ||
1986 | kfree(video->attached_array); | ||
1987 | acpi_video_bus_remove_fs(device); | ||
1988 | err_free_video: | ||
1989 | kfree(video); | ||
1990 | acpi_driver_data(device) = NULL; | ||
1996 | 1991 | ||
1997 | return result; | 1992 | return error; |
1998 | } | 1993 | } |
1999 | 1994 | ||
2000 | static int acpi_video_bus_remove(struct acpi_device *device, int type) | 1995 | static int acpi_video_bus_remove(struct acpi_device *device, int type) |
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c index 328ce8a08426..483269db2c7d 100644 --- a/drivers/ata/ata_piix.c +++ b/drivers/ata/ata_piix.c | |||
@@ -119,18 +119,19 @@ enum { | |||
119 | PIIX_80C_SEC = (1 << 7) | (1 << 6), | 119 | PIIX_80C_SEC = (1 << 7) | (1 << 6), |
120 | 120 | ||
121 | /* controller IDs */ | 121 | /* controller IDs */ |
122 | piix_pata_33 = 0, /* PIIX4 at 33Mhz */ | 122 | piix_pata_mwdma = 0, /* PIIX3 MWDMA only */ |
123 | ich_pata_33 = 1, /* ICH up to UDMA 33 only */ | 123 | piix_pata_33, /* PIIX4 at 33Mhz */ |
124 | ich_pata_66 = 2, /* ICH up to 66 Mhz */ | 124 | ich_pata_33, /* ICH up to UDMA 33 only */ |
125 | ich_pata_100 = 3, /* ICH up to UDMA 100 */ | 125 | ich_pata_66, /* ICH up to 66 Mhz */ |
126 | ich5_sata = 5, | 126 | ich_pata_100, /* ICH up to UDMA 100 */ |
127 | ich6_sata = 6, | 127 | ich5_sata, |
128 | ich6_sata_ahci = 7, | 128 | ich6_sata, |
129 | ich6m_sata_ahci = 8, | 129 | ich6_sata_ahci, |
130 | ich8_sata_ahci = 9, | 130 | ich6m_sata_ahci, |
131 | piix_pata_mwdma = 10, /* PIIX3 MWDMA only */ | 131 | ich8_sata_ahci, |
132 | tolapai_sata_ahci = 11, | 132 | ich8_2port_sata, |
133 | ich9_2port_sata = 12, | 133 | ich8m_apple_sata_ahci, /* locks up on second port enable */ |
134 | tolapai_sata_ahci, | ||
134 | 135 | ||
135 | /* constants for mapping table */ | 136 | /* constants for mapping table */ |
136 | P0 = 0, /* port 0 */ | 137 | P0 = 0, /* port 0 */ |
@@ -239,19 +240,21 @@ static const struct pci_device_id piix_pci_tbl[] = { | |||
239 | /* SATA Controller 1 IDE (ICH8) */ | 240 | /* SATA Controller 1 IDE (ICH8) */ |
240 | { 0x8086, 0x2820, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, | 241 | { 0x8086, 0x2820, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, |
241 | /* SATA Controller 2 IDE (ICH8) */ | 242 | /* SATA Controller 2 IDE (ICH8) */ |
242 | { 0x8086, 0x2825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich9_2port_sata }, | 243 | { 0x8086, 0x2825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, |
243 | /* Mobile SATA Controller IDE (ICH8M) */ | 244 | /* Mobile SATA Controller IDE (ICH8M) */ |
244 | { 0x8086, 0x2828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, | 245 | { 0x8086, 0x2828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, |
246 | /* Mobile SATA Controller IDE (ICH8M), Apple */ | ||
247 | { 0x8086, 0x2828, 0x106b, 0x00a0, 0, 0, ich8m_apple_sata_ahci }, | ||
245 | /* SATA Controller IDE (ICH9) */ | 248 | /* SATA Controller IDE (ICH9) */ |
246 | { 0x8086, 0x2920, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, | 249 | { 0x8086, 0x2920, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, |
247 | /* SATA Controller IDE (ICH9) */ | 250 | /* SATA Controller IDE (ICH9) */ |
248 | { 0x8086, 0x2921, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich9_2port_sata }, | 251 | { 0x8086, 0x2921, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, |
249 | /* SATA Controller IDE (ICH9) */ | 252 | /* SATA Controller IDE (ICH9) */ |
250 | { 0x8086, 0x2926, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich9_2port_sata }, | 253 | { 0x8086, 0x2926, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, |
251 | /* SATA Controller IDE (ICH9M) */ | 254 | /* SATA Controller IDE (ICH9M) */ |
252 | { 0x8086, 0x2928, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich9_2port_sata }, | 255 | { 0x8086, 0x2928, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, |
253 | /* SATA Controller IDE (ICH9M) */ | 256 | /* SATA Controller IDE (ICH9M) */ |
254 | { 0x8086, 0x292d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich9_2port_sata }, | 257 | { 0x8086, 0x292d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, |
255 | /* SATA Controller IDE (ICH9M) */ | 258 | /* SATA Controller IDE (ICH9M) */ |
256 | { 0x8086, 0x292e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, | 259 | { 0x8086, 0x292e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_ahci }, |
257 | /* SATA Controller IDE (Tolapai) */ | 260 | /* SATA Controller IDE (Tolapai) */ |
@@ -427,7 +430,7 @@ static const struct piix_map_db ich6m_map_db = { | |||
427 | 430 | ||
428 | static const struct piix_map_db ich8_map_db = { | 431 | static const struct piix_map_db ich8_map_db = { |
429 | .mask = 0x3, | 432 | .mask = 0x3, |
430 | .port_enable = 0x3, | 433 | .port_enable = 0xf, |
431 | .map = { | 434 | .map = { |
432 | /* PM PS SM SS MAP */ | 435 | /* PM PS SM SS MAP */ |
433 | { P0, P2, P1, P3 }, /* 00b (hardwired when in AHCI) */ | 436 | { P0, P2, P1, P3 }, /* 00b (hardwired when in AHCI) */ |
@@ -437,7 +440,7 @@ static const struct piix_map_db ich8_map_db = { | |||
437 | }, | 440 | }, |
438 | }; | 441 | }; |
439 | 442 | ||
440 | static const struct piix_map_db tolapai_map_db = { | 443 | static const struct piix_map_db ich8_2port_map_db = { |
441 | .mask = 0x3, | 444 | .mask = 0x3, |
442 | .port_enable = 0x3, | 445 | .port_enable = 0x3, |
443 | .map = { | 446 | .map = { |
@@ -449,7 +452,19 @@ static const struct piix_map_db tolapai_map_db = { | |||
449 | }, | 452 | }, |
450 | }; | 453 | }; |
451 | 454 | ||
452 | static const struct piix_map_db ich9_2port_map_db = { | 455 | static const struct piix_map_db ich8m_apple_map_db = { |
456 | .mask = 0x3, | ||
457 | .port_enable = 0x1, | ||
458 | .map = { | ||
459 | /* PM PS SM SS MAP */ | ||
460 | { P0, NA, NA, NA }, /* 00b */ | ||
461 | { RV, RV, RV, RV }, | ||
462 | { P0, P2, IDE, IDE }, /* 10b */ | ||
463 | { RV, RV, RV, RV }, | ||
464 | }, | ||
465 | }; | ||
466 | |||
467 | static const struct piix_map_db tolapai_map_db = { | ||
453 | .mask = 0x3, | 468 | .mask = 0x3, |
454 | .port_enable = 0x3, | 469 | .port_enable = 0x3, |
455 | .map = { | 470 | .map = { |
@@ -467,11 +482,21 @@ static const struct piix_map_db *piix_map_db_table[] = { | |||
467 | [ich6_sata_ahci] = &ich6_map_db, | 482 | [ich6_sata_ahci] = &ich6_map_db, |
468 | [ich6m_sata_ahci] = &ich6m_map_db, | 483 | [ich6m_sata_ahci] = &ich6m_map_db, |
469 | [ich8_sata_ahci] = &ich8_map_db, | 484 | [ich8_sata_ahci] = &ich8_map_db, |
485 | [ich8_2port_sata] = &ich8_2port_map_db, | ||
486 | [ich8m_apple_sata_ahci] = &ich8m_apple_map_db, | ||
470 | [tolapai_sata_ahci] = &tolapai_map_db, | 487 | [tolapai_sata_ahci] = &tolapai_map_db, |
471 | [ich9_2port_sata] = &ich9_2port_map_db, | ||
472 | }; | 488 | }; |
473 | 489 | ||
474 | static struct ata_port_info piix_port_info[] = { | 490 | static struct ata_port_info piix_port_info[] = { |
491 | [piix_pata_mwdma] = /* PIIX3 MWDMA only */ | ||
492 | { | ||
493 | .sht = &piix_sht, | ||
494 | .flags = PIIX_PATA_FLAGS, | ||
495 | .pio_mask = 0x1f, /* pio0-4 */ | ||
496 | .mwdma_mask = 0x06, /* mwdma1-2 ?? CHECK 0 should be ok but slow */ | ||
497 | .port_ops = &piix_pata_ops, | ||
498 | }, | ||
499 | |||
475 | [piix_pata_33] = /* PIIX4 at 33MHz */ | 500 | [piix_pata_33] = /* PIIX4 at 33MHz */ |
476 | { | 501 | { |
477 | .sht = &piix_sht, | 502 | .sht = &piix_sht, |
@@ -565,13 +590,15 @@ static struct ata_port_info piix_port_info[] = { | |||
565 | .port_ops = &piix_sata_ops, | 590 | .port_ops = &piix_sata_ops, |
566 | }, | 591 | }, |
567 | 592 | ||
568 | [piix_pata_mwdma] = /* PIIX3 MWDMA only */ | 593 | [ich8_2port_sata] = |
569 | { | 594 | { |
570 | .sht = &piix_sht, | 595 | .sht = &piix_sht, |
571 | .flags = PIIX_PATA_FLAGS, | 596 | .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SCR | |
597 | PIIX_FLAG_AHCI, | ||
572 | .pio_mask = 0x1f, /* pio0-4 */ | 598 | .pio_mask = 0x1f, /* pio0-4 */ |
573 | .mwdma_mask = 0x06, /* mwdma1-2 ?? CHECK 0 should be ok but slow */ | 599 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
574 | .port_ops = &piix_pata_ops, | 600 | .udma_mask = ATA_UDMA6, |
601 | .port_ops = &piix_sata_ops, | ||
575 | }, | 602 | }, |
576 | 603 | ||
577 | [tolapai_sata_ahci] = | 604 | [tolapai_sata_ahci] = |
@@ -585,7 +612,7 @@ static struct ata_port_info piix_port_info[] = { | |||
585 | .port_ops = &piix_sata_ops, | 612 | .port_ops = &piix_sata_ops, |
586 | }, | 613 | }, |
587 | 614 | ||
588 | [ich9_2port_sata] = | 615 | [ich8m_apple_sata_ahci] = |
589 | { | 616 | { |
590 | .sht = &piix_sht, | 617 | .sht = &piix_sht, |
591 | .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SCR | | 618 | .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SCR | |
@@ -595,6 +622,7 @@ static struct ata_port_info piix_port_info[] = { | |||
595 | .udma_mask = ATA_UDMA6, | 622 | .udma_mask = ATA_UDMA6, |
596 | .port_ops = &piix_sata_ops, | 623 | .port_ops = &piix_sata_ops, |
597 | }, | 624 | }, |
625 | |||
598 | }; | 626 | }; |
599 | 627 | ||
600 | static struct pci_bits piix_enable_bits[] = { | 628 | static struct pci_bits piix_enable_bits[] = { |
@@ -974,6 +1002,13 @@ static int piix_broken_suspend(void) | |||
974 | }, | 1002 | }, |
975 | }, | 1003 | }, |
976 | { | 1004 | { |
1005 | .ident = "SATELLITE U205", | ||
1006 | .matches = { | ||
1007 | DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), | ||
1008 | DMI_MATCH(DMI_PRODUCT_NAME, "SATELLITE U205"), | ||
1009 | }, | ||
1010 | }, | ||
1011 | { | ||
977 | .ident = "Portege M500", | 1012 | .ident = "Portege M500", |
978 | .matches = { | 1013 | .matches = { |
979 | DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), | 1014 | DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), |
@@ -1086,12 +1121,12 @@ static int piix_disable_ahci(struct pci_dev *pdev) | |||
1086 | if (!mmio) | 1121 | if (!mmio) |
1087 | return -ENOMEM; | 1122 | return -ENOMEM; |
1088 | 1123 | ||
1089 | tmp = readl(mmio + AHCI_GLOBAL_CTL); | 1124 | tmp = ioread32(mmio + AHCI_GLOBAL_CTL); |
1090 | if (tmp & AHCI_ENABLE) { | 1125 | if (tmp & AHCI_ENABLE) { |
1091 | tmp &= ~AHCI_ENABLE; | 1126 | tmp &= ~AHCI_ENABLE; |
1092 | writel(tmp, mmio + AHCI_GLOBAL_CTL); | 1127 | iowrite32(tmp, mmio + AHCI_GLOBAL_CTL); |
1093 | 1128 | ||
1094 | tmp = readl(mmio + AHCI_GLOBAL_CTL); | 1129 | tmp = ioread32(mmio + AHCI_GLOBAL_CTL); |
1095 | if (tmp & AHCI_ENABLE) | 1130 | if (tmp & AHCI_ENABLE) |
1096 | rc = -EIO; | 1131 | rc = -EIO; |
1097 | } | 1132 | } |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 81898036dbca..33f06277b3be 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -30,6 +30,14 @@ | |||
30 | * Hardware documentation available from http://www.t13.org/ and | 30 | * Hardware documentation available from http://www.t13.org/ and |
31 | * http://www.sata-io.org/ | 31 | * http://www.sata-io.org/ |
32 | * | 32 | * |
33 | * Standards documents from: | ||
34 | * http://www.t13.org (ATA standards, PCI DMA IDE spec) | ||
35 | * http://www.t10.org (SCSI MMC - for ATAPI MMC) | ||
36 | * http://www.sata-io.org (SATA) | ||
37 | * http://www.compactflash.org (CF) | ||
38 | * http://www.qic.org (QIC157 - Tape and DSC) | ||
39 | * http://www.ce-ata.org (CE-ATA: not supported) | ||
40 | * | ||
33 | */ | 41 | */ |
34 | 42 | ||
35 | #include <linux/kernel.h> | 43 | #include <linux/kernel.h> |
@@ -2307,8 +2315,10 @@ int ata_dev_configure(struct ata_device *dev) | |||
2307 | } | 2315 | } |
2308 | 2316 | ||
2309 | if ((dev->class == ATA_DEV_ATAPI) && | 2317 | if ((dev->class == ATA_DEV_ATAPI) && |
2310 | (atapi_command_packet_set(id) == TYPE_TAPE)) | 2318 | (atapi_command_packet_set(id) == TYPE_TAPE)) { |
2311 | dev->max_sectors = ATA_MAX_SECTORS_TAPE; | 2319 | dev->max_sectors = ATA_MAX_SECTORS_TAPE; |
2320 | dev->horkage |= ATA_HORKAGE_STUCK_ERR; | ||
2321 | } | ||
2312 | 2322 | ||
2313 | if (dev->horkage & ATA_HORKAGE_MAX_SEC_128) | 2323 | if (dev->horkage & ATA_HORKAGE_MAX_SEC_128) |
2314 | dev->max_sectors = min_t(unsigned int, ATA_MAX_SECTORS_128, | 2324 | dev->max_sectors = min_t(unsigned int, ATA_MAX_SECTORS_128, |
@@ -2581,81 +2591,6 @@ void sata_print_link_status(struct ata_link *link) | |||
2581 | } | 2591 | } |
2582 | 2592 | ||
2583 | /** | 2593 | /** |
2584 | * __sata_phy_reset - Wake/reset a low-level SATA PHY | ||
2585 | * @ap: SATA port associated with target SATA PHY. | ||
2586 | * | ||
2587 | * This function issues commands to standard SATA Sxxx | ||
2588 | * PHY registers, to wake up the phy (and device), and | ||
2589 | * clear any reset condition. | ||
2590 | * | ||
2591 | * LOCKING: | ||
2592 | * PCI/etc. bus probe sem. | ||
2593 | * | ||
2594 | */ | ||
2595 | void __sata_phy_reset(struct ata_port *ap) | ||
2596 | { | ||
2597 | struct ata_link *link = &ap->link; | ||
2598 | unsigned long timeout = jiffies + (HZ * 5); | ||
2599 | u32 sstatus; | ||
2600 | |||
2601 | if (ap->flags & ATA_FLAG_SATA_RESET) { | ||
2602 | /* issue phy wake/reset */ | ||
2603 | sata_scr_write_flush(link, SCR_CONTROL, 0x301); | ||
2604 | /* Couldn't find anything in SATA I/II specs, but | ||
2605 | * AHCI-1.1 10.4.2 says at least 1 ms. */ | ||
2606 | mdelay(1); | ||
2607 | } | ||
2608 | /* phy wake/clear reset */ | ||
2609 | sata_scr_write_flush(link, SCR_CONTROL, 0x300); | ||
2610 | |||
2611 | /* wait for phy to become ready, if necessary */ | ||
2612 | do { | ||
2613 | msleep(200); | ||
2614 | sata_scr_read(link, SCR_STATUS, &sstatus); | ||
2615 | if ((sstatus & 0xf) != 1) | ||
2616 | break; | ||
2617 | } while (time_before(jiffies, timeout)); | ||
2618 | |||
2619 | /* print link status */ | ||
2620 | sata_print_link_status(link); | ||
2621 | |||
2622 | /* TODO: phy layer with polling, timeouts, etc. */ | ||
2623 | if (!ata_link_offline(link)) | ||
2624 | ata_port_probe(ap); | ||
2625 | else | ||
2626 | ata_port_disable(ap); | ||
2627 | |||
2628 | if (ap->flags & ATA_FLAG_DISABLED) | ||
2629 | return; | ||
2630 | |||
2631 | if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) { | ||
2632 | ata_port_disable(ap); | ||
2633 | return; | ||
2634 | } | ||
2635 | |||
2636 | ap->cbl = ATA_CBL_SATA; | ||
2637 | } | ||
2638 | |||
2639 | /** | ||
2640 | * sata_phy_reset - Reset SATA bus. | ||
2641 | * @ap: SATA port associated with target SATA PHY. | ||
2642 | * | ||
2643 | * This function resets the SATA bus, and then probes | ||
2644 | * the bus for devices. | ||
2645 | * | ||
2646 | * LOCKING: | ||
2647 | * PCI/etc. bus probe sem. | ||
2648 | * | ||
2649 | */ | ||
2650 | void sata_phy_reset(struct ata_port *ap) | ||
2651 | { | ||
2652 | __sata_phy_reset(ap); | ||
2653 | if (ap->flags & ATA_FLAG_DISABLED) | ||
2654 | return; | ||
2655 | ata_bus_reset(ap); | ||
2656 | } | ||
2657 | |||
2658 | /** | ||
2659 | * ata_dev_pair - return other device on cable | 2594 | * ata_dev_pair - return other device on cable |
2660 | * @adev: device | 2595 | * @adev: device |
2661 | * | 2596 | * |
@@ -5490,11 +5425,19 @@ fsm_start: | |||
5490 | * let the EH abort the command or reset the device. | 5425 | * let the EH abort the command or reset the device. |
5491 | */ | 5426 | */ |
5492 | if (unlikely(status & (ATA_ERR | ATA_DF))) { | 5427 | if (unlikely(status & (ATA_ERR | ATA_DF))) { |
5493 | ata_port_printk(ap, KERN_WARNING, "DRQ=1 with device " | 5428 | /* Some ATAPI tape drives forget to clear the ERR bit |
5494 | "error, dev_stat 0x%X\n", status); | 5429 | * when doing the next command (mostly request sense). |
5495 | qc->err_mask |= AC_ERR_HSM; | 5430 | * We ignore ERR here to workaround and proceed sending |
5496 | ap->hsm_task_state = HSM_ST_ERR; | 5431 | * the CDB. |
5497 | goto fsm_start; | 5432 | */ |
5433 | if (!(qc->dev->horkage & ATA_HORKAGE_STUCK_ERR)) { | ||
5434 | ata_port_printk(ap, KERN_WARNING, | ||
5435 | "DRQ=1 with device error, " | ||
5436 | "dev_stat 0x%X\n", status); | ||
5437 | qc->err_mask |= AC_ERR_HSM; | ||
5438 | ap->hsm_task_state = HSM_ST_ERR; | ||
5439 | goto fsm_start; | ||
5440 | } | ||
5498 | } | 5441 | } |
5499 | 5442 | ||
5500 | /* Send the CDB (atapi) or the first data block (ata pio out). | 5443 | /* Send the CDB (atapi) or the first data block (ata pio out). |
@@ -7653,8 +7596,6 @@ EXPORT_SYMBOL_GPL(ata_dev_disable); | |||
7653 | EXPORT_SYMBOL_GPL(sata_set_spd); | 7596 | EXPORT_SYMBOL_GPL(sata_set_spd); |
7654 | EXPORT_SYMBOL_GPL(sata_link_debounce); | 7597 | EXPORT_SYMBOL_GPL(sata_link_debounce); |
7655 | EXPORT_SYMBOL_GPL(sata_link_resume); | 7598 | EXPORT_SYMBOL_GPL(sata_link_resume); |
7656 | EXPORT_SYMBOL_GPL(sata_phy_reset); | ||
7657 | EXPORT_SYMBOL_GPL(__sata_phy_reset); | ||
7658 | EXPORT_SYMBOL_GPL(ata_bus_reset); | 7599 | EXPORT_SYMBOL_GPL(ata_bus_reset); |
7659 | EXPORT_SYMBOL_GPL(ata_std_prereset); | 7600 | EXPORT_SYMBOL_GPL(ata_std_prereset); |
7660 | EXPORT_SYMBOL_GPL(ata_std_softreset); | 7601 | EXPORT_SYMBOL_GPL(ata_std_softreset); |
@@ -7725,7 +7666,6 @@ EXPORT_SYMBOL_GPL(ata_port_desc); | |||
7725 | #ifdef CONFIG_PCI | 7666 | #ifdef CONFIG_PCI |
7726 | EXPORT_SYMBOL_GPL(ata_port_pbar_desc); | 7667 | EXPORT_SYMBOL_GPL(ata_port_pbar_desc); |
7727 | #endif /* CONFIG_PCI */ | 7668 | #endif /* CONFIG_PCI */ |
7728 | EXPORT_SYMBOL_GPL(ata_eng_timeout); | ||
7729 | EXPORT_SYMBOL_GPL(ata_port_schedule_eh); | 7669 | EXPORT_SYMBOL_GPL(ata_port_schedule_eh); |
7730 | EXPORT_SYMBOL_GPL(ata_link_abort); | 7670 | EXPORT_SYMBOL_GPL(ata_link_abort); |
7731 | EXPORT_SYMBOL_GPL(ata_port_abort); | 7671 | EXPORT_SYMBOL_GPL(ata_port_abort); |
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index ed8813b222a0..0dac69db1fdf 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c | |||
@@ -559,101 +559,6 @@ void ata_port_wait_eh(struct ata_port *ap) | |||
559 | } | 559 | } |
560 | } | 560 | } |
561 | 561 | ||
562 | /** | ||
563 | * ata_qc_timeout - Handle timeout of queued command | ||
564 | * @qc: Command that timed out | ||
565 | * | ||
566 | * Some part of the kernel (currently, only the SCSI layer) | ||
567 | * has noticed that the active command on port @ap has not | ||
568 | * completed after a specified length of time. Handle this | ||
569 | * condition by disabling DMA (if necessary) and completing | ||
570 | * transactions, with error if necessary. | ||
571 | * | ||
572 | * This also handles the case of the "lost interrupt", where | ||
573 | * for some reason (possibly hardware bug, possibly driver bug) | ||
574 | * an interrupt was not delivered to the driver, even though the | ||
575 | * transaction completed successfully. | ||
576 | * | ||
577 | * TODO: kill this function once old EH is gone. | ||
578 | * | ||
579 | * LOCKING: | ||
580 | * Inherited from SCSI layer (none, can sleep) | ||
581 | */ | ||
582 | static void ata_qc_timeout(struct ata_queued_cmd *qc) | ||
583 | { | ||
584 | struct ata_port *ap = qc->ap; | ||
585 | u8 host_stat = 0, drv_stat; | ||
586 | unsigned long flags; | ||
587 | |||
588 | DPRINTK("ENTER\n"); | ||
589 | |||
590 | ap->hsm_task_state = HSM_ST_IDLE; | ||
591 | |||
592 | spin_lock_irqsave(ap->lock, flags); | ||
593 | |||
594 | switch (qc->tf.protocol) { | ||
595 | |||
596 | case ATA_PROT_DMA: | ||
597 | case ATA_PROT_ATAPI_DMA: | ||
598 | host_stat = ap->ops->bmdma_status(ap); | ||
599 | |||
600 | /* before we do anything else, clear DMA-Start bit */ | ||
601 | ap->ops->bmdma_stop(qc); | ||
602 | |||
603 | /* fall through */ | ||
604 | |||
605 | default: | ||
606 | ata_altstatus(ap); | ||
607 | drv_stat = ata_chk_status(ap); | ||
608 | |||
609 | /* ack bmdma irq events */ | ||
610 | ap->ops->irq_clear(ap); | ||
611 | |||
612 | ata_dev_printk(qc->dev, KERN_ERR, "command 0x%x timeout, " | ||
613 | "stat 0x%x host_stat 0x%x\n", | ||
614 | qc->tf.command, drv_stat, host_stat); | ||
615 | |||
616 | /* complete taskfile transaction */ | ||
617 | qc->err_mask |= AC_ERR_TIMEOUT; | ||
618 | break; | ||
619 | } | ||
620 | |||
621 | spin_unlock_irqrestore(ap->lock, flags); | ||
622 | |||
623 | ata_eh_qc_complete(qc); | ||
624 | |||
625 | DPRINTK("EXIT\n"); | ||
626 | } | ||
627 | |||
628 | /** | ||
629 | * ata_eng_timeout - Handle timeout of queued command | ||
630 | * @ap: Port on which timed-out command is active | ||
631 | * | ||
632 | * Some part of the kernel (currently, only the SCSI layer) | ||
633 | * has noticed that the active command on port @ap has not | ||
634 | * completed after a specified length of time. Handle this | ||
635 | * condition by disabling DMA (if necessary) and completing | ||
636 | * transactions, with error if necessary. | ||
637 | * | ||
638 | * This also handles the case of the "lost interrupt", where | ||
639 | * for some reason (possibly hardware bug, possibly driver bug) | ||
640 | * an interrupt was not delivered to the driver, even though the | ||
641 | * transaction completed successfully. | ||
642 | * | ||
643 | * TODO: kill this function once old EH is gone. | ||
644 | * | ||
645 | * LOCKING: | ||
646 | * Inherited from SCSI layer (none, can sleep) | ||
647 | */ | ||
648 | void ata_eng_timeout(struct ata_port *ap) | ||
649 | { | ||
650 | DPRINTK("ENTER\n"); | ||
651 | |||
652 | ata_qc_timeout(ata_qc_from_tag(ap, ap->link.active_tag)); | ||
653 | |||
654 | DPRINTK("EXIT\n"); | ||
655 | } | ||
656 | |||
657 | static int ata_eh_nr_in_flight(struct ata_port *ap) | 562 | static int ata_eh_nr_in_flight(struct ata_port *ap) |
658 | { | 563 | { |
659 | unsigned int tag; | 564 | unsigned int tag; |
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 94144ed50a6b..a883bb03d4c7 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -2485,11 +2485,40 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc) | |||
2485 | if (!using_pio && ata_check_atapi_dma(qc)) | 2485 | if (!using_pio && ata_check_atapi_dma(qc)) |
2486 | using_pio = 1; | 2486 | using_pio = 1; |
2487 | 2487 | ||
2488 | /* Some controller variants snoop this value for Packet transfers | 2488 | /* Some controller variants snoop this value for Packet |
2489 | to do state machine and FIFO management. Thus we want to set it | 2489 | * transfers to do state machine and FIFO management. Thus we |
2490 | properly, and for DMA where it is effectively meaningless */ | 2490 | * want to set it properly, and for DMA where it is |
2491 | * effectively meaningless. | ||
2492 | */ | ||
2491 | nbytes = min(qc->nbytes, (unsigned int)63 * 1024); | 2493 | nbytes = min(qc->nbytes, (unsigned int)63 * 1024); |
2492 | 2494 | ||
2495 | /* Most ATAPI devices which honor transfer chunk size don't | ||
2496 | * behave according to the spec when odd chunk size which | ||
2497 | * matches the transfer length is specified. If the number of | ||
2498 | * bytes to transfer is 2n+1. According to the spec, what | ||
2499 | * should happen is to indicate that 2n+1 is going to be | ||
2500 | * transferred and transfer 2n+2 bytes where the last byte is | ||
2501 | * padding. | ||
2502 | * | ||
2503 | * In practice, this doesn't happen. ATAPI devices first | ||
2504 | * indicate and transfer 2n bytes and then indicate and | ||
2505 | * transfer 2 bytes where the last byte is padding. | ||
2506 | * | ||
2507 | * This inconsistency confuses several controllers which | ||
2508 | * perform PIO using DMA such as Intel AHCIs and sil3124/32. | ||
2509 | * These controllers use actual number of transferred bytes to | ||
2510 | * update DMA poitner and transfer of 4n+2 bytes make those | ||
2511 | * controller push DMA pointer by 4n+4 bytes because SATA data | ||
2512 | * FISes are aligned to 4 bytes. This causes data corruption | ||
2513 | * and buffer overrun. | ||
2514 | * | ||
2515 | * Always setting nbytes to even number solves this problem | ||
2516 | * because then ATAPI devices don't have to split data at 2n | ||
2517 | * boundaries. | ||
2518 | */ | ||
2519 | if (nbytes & 0x1) | ||
2520 | nbytes++; | ||
2521 | |||
2493 | qc->tf.lbam = (nbytes & 0xFF); | 2522 | qc->tf.lbam = (nbytes & 0xFF); |
2494 | qc->tf.lbah = (nbytes >> 8); | 2523 | qc->tf.lbah = (nbytes >> 8); |
2495 | 2524 | ||
@@ -2869,7 +2898,8 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, | |||
2869 | xlat_func = NULL; | 2898 | xlat_func = NULL; |
2870 | if (likely((scsi_op != ATA_16) || !atapi_passthru16)) { | 2899 | if (likely((scsi_op != ATA_16) || !atapi_passthru16)) { |
2871 | /* relay SCSI command to ATAPI device */ | 2900 | /* relay SCSI command to ATAPI device */ |
2872 | if (unlikely(scmd->cmd_len > dev->cdb_len)) | 2901 | int len = COMMAND_SIZE(scsi_op); |
2902 | if (unlikely(len > scmd->cmd_len || len > dev->cdb_len)) | ||
2873 | goto bad_cdb_len; | 2903 | goto bad_cdb_len; |
2874 | 2904 | ||
2875 | xlat_func = atapi_xlat; | 2905 | xlat_func = atapi_xlat; |
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c index 364534e7aff4..8caf9afc8b90 100644 --- a/drivers/ata/pata_ali.c +++ b/drivers/ata/pata_ali.c | |||
@@ -63,6 +63,9 @@ static int ali_cable_override(struct pci_dev *pdev) | |||
63 | /* Fujitsu P2000 */ | 63 | /* Fujitsu P2000 */ |
64 | if (pdev->subsystem_vendor == 0x10CF && pdev->subsystem_device == 0x10AF) | 64 | if (pdev->subsystem_vendor == 0x10CF && pdev->subsystem_device == 0x10AF) |
65 | return 1; | 65 | return 1; |
66 | /* Mitac 8317 (Winbook-A) and relatives */ | ||
67 | if (pdev->subsystem_vendor == 0x1071 && pdev->subsystem_device == 0x8317) | ||
68 | return 1; | ||
66 | /* Systems by DMI */ | 69 | /* Systems by DMI */ |
67 | if (dmi_check_system(cable_dmi_table)) | 70 | if (dmi_check_system(cable_dmi_table)) |
68 | return 1; | 71 | return 1; |
@@ -282,6 +285,21 @@ static void ali_lock_sectors(struct ata_device *adev) | |||
282 | adev->max_sectors = 255; | 285 | adev->max_sectors = 255; |
283 | } | 286 | } |
284 | 287 | ||
288 | /** | ||
289 | * ali_check_atapi_dma - DMA check for most ALi controllers | ||
290 | * @adev: Device | ||
291 | * | ||
292 | * Called to decide whether commands should be sent by DMA or PIO | ||
293 | */ | ||
294 | |||
295 | static int ali_check_atapi_dma(struct ata_queued_cmd *qc) | ||
296 | { | ||
297 | /* If its not a media command, its not worth it */ | ||
298 | if (qc->nbytes < 2048) | ||
299 | return -EOPNOTSUPP; | ||
300 | return 0; | ||
301 | } | ||
302 | |||
285 | static struct scsi_host_template ali_sht = { | 303 | static struct scsi_host_template ali_sht = { |
286 | .module = THIS_MODULE, | 304 | .module = THIS_MODULE, |
287 | .name = DRV_NAME, | 305 | .name = DRV_NAME, |
@@ -378,6 +396,7 @@ static struct ata_port_operations ali_c2_port_ops = { | |||
378 | .mode_filter = ata_pci_default_filter, | 396 | .mode_filter = ata_pci_default_filter, |
379 | .tf_load = ata_tf_load, | 397 | .tf_load = ata_tf_load, |
380 | .tf_read = ata_tf_read, | 398 | .tf_read = ata_tf_read, |
399 | .check_atapi_dma = ali_check_atapi_dma, | ||
381 | .check_status = ata_check_status, | 400 | .check_status = ata_check_status, |
382 | .exec_command = ata_exec_command, | 401 | .exec_command = ata_exec_command, |
383 | .dev_select = ata_std_dev_select, | 402 | .dev_select = ata_std_dev_select, |
@@ -415,6 +434,7 @@ static struct ata_port_operations ali_c5_port_ops = { | |||
415 | .mode_filter = ata_pci_default_filter, | 434 | .mode_filter = ata_pci_default_filter, |
416 | .tf_load = ata_tf_load, | 435 | .tf_load = ata_tf_load, |
417 | .tf_read = ata_tf_read, | 436 | .tf_read = ata_tf_read, |
437 | .check_atapi_dma = ali_check_atapi_dma, | ||
418 | .check_status = ata_check_status, | 438 | .check_status = ata_check_status, |
419 | .exec_command = ata_exec_command, | 439 | .exec_command = ata_exec_command, |
420 | .dev_select = ata_std_dev_select, | 440 | .dev_select = ata_std_dev_select, |
diff --git a/drivers/ata/pata_bf54x.c b/drivers/ata/pata_bf54x.c index b5e38426b815..81db405a5445 100644 --- a/drivers/ata/pata_bf54x.c +++ b/drivers/ata/pata_bf54x.c | |||
@@ -1145,13 +1145,13 @@ static unsigned char bfin_bmdma_status(struct ata_port *ap) | |||
1145 | unsigned short int_status = ATAPI_GET_INT_STATUS(base); | 1145 | unsigned short int_status = ATAPI_GET_INT_STATUS(base); |
1146 | 1146 | ||
1147 | if (ATAPI_GET_STATUS(base) & (MULTI_XFER_ON|ULTRA_XFER_ON)) { | 1147 | if (ATAPI_GET_STATUS(base) & (MULTI_XFER_ON|ULTRA_XFER_ON)) { |
1148 | host_stat = ATA_DMA_ACTIVE; | 1148 | host_stat |= ATA_DMA_ACTIVE; |
1149 | } | 1149 | } |
1150 | if (int_status & (MULTI_DONE_INT|UDMAIN_DONE_INT|UDMAOUT_DONE_INT)) { | 1150 | if (int_status & (MULTI_DONE_INT|UDMAIN_DONE_INT|UDMAOUT_DONE_INT)) { |
1151 | host_stat = ATA_DMA_INTR; | 1151 | host_stat |= ATA_DMA_INTR; |
1152 | } | 1152 | } |
1153 | if (int_status & (MULTI_TERM_INT|UDMAIN_TERM_INT|UDMAOUT_TERM_INT)) { | 1153 | if (int_status & (MULTI_TERM_INT|UDMAIN_TERM_INT|UDMAOUT_TERM_INT)) { |
1154 | host_stat = ATA_DMA_ERR; | 1154 | host_stat |= ATA_DMA_ERR; |
1155 | } | 1155 | } |
1156 | 1156 | ||
1157 | return host_stat; | 1157 | return host_stat; |
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c index 3816b8605e0d..46dc70e0dee7 100644 --- a/drivers/ata/pata_hpt37x.c +++ b/drivers/ata/pata_hpt37x.c | |||
@@ -329,7 +329,7 @@ static int hpt37x_pre_reset(struct ata_link *link, unsigned long deadline) | |||
329 | /* Restore state */ | 329 | /* Restore state */ |
330 | pci_write_config_byte(pdev, 0x5B, scr2); | 330 | pci_write_config_byte(pdev, 0x5B, scr2); |
331 | 331 | ||
332 | if (ata66 & (1 << ap->port_no)) | 332 | if (ata66 & (2 >> ap->port_no)) |
333 | ap->cbl = ATA_CBL_PATA40; | 333 | ap->cbl = ATA_CBL_PATA40; |
334 | else | 334 | else |
335 | ap->cbl = ATA_CBL_PATA80; | 335 | ap->cbl = ATA_CBL_PATA80; |
diff --git a/drivers/ata/pata_isapnp.c b/drivers/ata/pata_isapnp.c index 88ab0e1d353f..4320e7986321 100644 --- a/drivers/ata/pata_isapnp.c +++ b/drivers/ata/pata_isapnp.c | |||
@@ -75,13 +75,16 @@ static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev | |||
75 | struct ata_host *host; | 75 | struct ata_host *host; |
76 | struct ata_port *ap; | 76 | struct ata_port *ap; |
77 | void __iomem *cmd_addr, *ctl_addr; | 77 | void __iomem *cmd_addr, *ctl_addr; |
78 | int irq = 0; | ||
79 | irq_handler_t handler = NULL; | ||
78 | 80 | ||
79 | if (pnp_port_valid(idev, 0) == 0) | 81 | if (pnp_port_valid(idev, 0) == 0) |
80 | return -ENODEV; | 82 | return -ENODEV; |
81 | 83 | ||
82 | /* FIXME: Should selected polled PIO here not fail */ | 84 | if (pnp_irq_valid(idev, 0)) { |
83 | if (pnp_irq_valid(idev, 0) == 0) | 85 | irq = pnp_irq(idev, 0); |
84 | return -ENODEV; | 86 | handler = ata_interrupt; |
87 | } | ||
85 | 88 | ||
86 | /* allocate host */ | 89 | /* allocate host */ |
87 | host = ata_host_alloc(&idev->dev, 1); | 90 | host = ata_host_alloc(&idev->dev, 1); |
@@ -115,7 +118,7 @@ static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev | |||
115 | (unsigned long long)pnp_port_start(idev, 1)); | 118 | (unsigned long long)pnp_port_start(idev, 1)); |
116 | 119 | ||
117 | /* activate */ | 120 | /* activate */ |
118 | return ata_host_activate(host, pnp_irq(idev, 0), ata_interrupt, 0, | 121 | return ata_host_activate(host, irq, handler, 0, |
119 | &isapnp_sht); | 122 | &isapnp_sht); |
120 | } | 123 | } |
121 | 124 | ||
diff --git a/drivers/ata/pata_jmicron.c b/drivers/ata/pata_jmicron.c index 225a7223a726..5b8174d94067 100644 --- a/drivers/ata/pata_jmicron.c +++ b/drivers/ata/pata_jmicron.c | |||
@@ -80,11 +80,10 @@ static int jmicron_pre_reset(struct ata_link *link, unsigned long deadline) | |||
80 | * actually do our cable checking etc. Thankfully we don't need | 80 | * actually do our cable checking etc. Thankfully we don't need |
81 | * to do the plumbing for other cases. | 81 | * to do the plumbing for other cases. |
82 | */ | 82 | */ |
83 | switch (port_map[port]) | 83 | switch (port_map[port]) { |
84 | { | ||
85 | case PORT_PATA0: | 84 | case PORT_PATA0: |
86 | if (control & (1 << 5)) | 85 | if ((control & (1 << 5)) == 0) |
87 | return 0; | 86 | return -ENOENT; |
88 | if (control & (1 << 3)) /* 40/80 pin primary */ | 87 | if (control & (1 << 3)) /* 40/80 pin primary */ |
89 | ap->cbl = ATA_CBL_PATA40; | 88 | ap->cbl = ATA_CBL_PATA40; |
90 | else | 89 | else |
@@ -93,7 +92,7 @@ static int jmicron_pre_reset(struct ata_link *link, unsigned long deadline) | |||
93 | case PORT_PATA1: | 92 | case PORT_PATA1: |
94 | /* Bit 21 is set if the port is enabled */ | 93 | /* Bit 21 is set if the port is enabled */ |
95 | if ((control5 & (1 << 21)) == 0) | 94 | if ((control5 & (1 << 21)) == 0) |
96 | return 0; | 95 | return -ENOENT; |
97 | if (control5 & (1 << 19)) /* 40/80 pin secondary */ | 96 | if (control5 & (1 << 19)) /* 40/80 pin secondary */ |
98 | ap->cbl = ATA_CBL_PATA40; | 97 | ap->cbl = ATA_CBL_PATA40; |
99 | else | 98 | else |
diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c index 5c1e9cb59ecb..503245a1eafa 100644 --- a/drivers/ata/pata_sil680.c +++ b/drivers/ata/pata_sil680.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/libata.h> | 33 | #include <linux/libata.h> |
34 | 34 | ||
35 | #define DRV_NAME "pata_sil680" | 35 | #define DRV_NAME "pata_sil680" |
36 | #define DRV_VERSION "0.4.7" | 36 | #define DRV_VERSION "0.4.8" |
37 | 37 | ||
38 | #define SIL680_MMIO_BAR 5 | 38 | #define SIL680_MMIO_BAR 5 |
39 | 39 | ||
@@ -94,34 +94,6 @@ static int sil680_cable_detect(struct ata_port *ap) { | |||
94 | } | 94 | } |
95 | 95 | ||
96 | /** | 96 | /** |
97 | * sil680_bus_reset - reset the SIL680 bus | ||
98 | * @link: ATA link to reset | ||
99 | * @deadline: deadline jiffies for the operation | ||
100 | * | ||
101 | * Perform the SIL680 housekeeping when doing an ATA bus reset | ||
102 | */ | ||
103 | |||
104 | static int sil680_bus_reset(struct ata_link *link, unsigned int *classes, | ||
105 | unsigned long deadline) | ||
106 | { | ||
107 | struct ata_port *ap = link->ap; | ||
108 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | ||
109 | unsigned long addr = sil680_selreg(ap, 0); | ||
110 | u8 reset; | ||
111 | |||
112 | pci_read_config_byte(pdev, addr, &reset); | ||
113 | pci_write_config_byte(pdev, addr, reset | 0x03); | ||
114 | udelay(25); | ||
115 | pci_write_config_byte(pdev, addr, reset); | ||
116 | return ata_std_softreset(link, classes, deadline); | ||
117 | } | ||
118 | |||
119 | static void sil680_error_handler(struct ata_port *ap) | ||
120 | { | ||
121 | ata_bmdma_drive_eh(ap, ata_std_prereset, sil680_bus_reset, NULL, ata_std_postreset); | ||
122 | } | ||
123 | |||
124 | /** | ||
125 | * sil680_set_piomode - set initial PIO mode data | 97 | * sil680_set_piomode - set initial PIO mode data |
126 | * @ap: ATA interface | 98 | * @ap: ATA interface |
127 | * @adev: ATA device | 99 | * @adev: ATA device |
@@ -249,7 +221,7 @@ static struct ata_port_operations sil680_port_ops = { | |||
249 | 221 | ||
250 | .freeze = ata_bmdma_freeze, | 222 | .freeze = ata_bmdma_freeze, |
251 | .thaw = ata_bmdma_thaw, | 223 | .thaw = ata_bmdma_thaw, |
252 | .error_handler = sil680_error_handler, | 224 | .error_handler = ata_bmdma_error_handler, |
253 | .post_internal_cmd = ata_bmdma_post_internal_cmd, | 225 | .post_internal_cmd = ata_bmdma_post_internal_cmd, |
254 | .cable_detect = sil680_cable_detect, | 226 | .cable_detect = sil680_cable_detect, |
255 | 227 | ||
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c index 3b5be77e861c..87546d9f1ca0 100644 --- a/drivers/ata/pata_sis.c +++ b/drivers/ata/pata_sis.c | |||
@@ -55,6 +55,7 @@ static const struct sis_laptop sis_laptop[] = { | |||
55 | /* devid, subvendor, subdev */ | 55 | /* devid, subvendor, subdev */ |
56 | { 0x5513, 0x1043, 0x1107 }, /* ASUS A6K */ | 56 | { 0x5513, 0x1043, 0x1107 }, /* ASUS A6K */ |
57 | { 0x5513, 0x1734, 0x105F }, /* FSC Amilo A1630 */ | 57 | { 0x5513, 0x1734, 0x105F }, /* FSC Amilo A1630 */ |
58 | { 0x5513, 0x1071, 0x8640 }, /* EasyNote K5305 */ | ||
58 | /* end marker */ | 59 | /* end marker */ |
59 | { 0, } | 60 | { 0, } |
60 | }; | 61 | }; |
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c index 187dcb02c681..96fd5260446d 100644 --- a/drivers/ata/sata_sil24.c +++ b/drivers/ata/sata_sil24.c | |||
@@ -63,6 +63,21 @@ enum { | |||
63 | SIL24_HOST_BAR = 0, | 63 | SIL24_HOST_BAR = 0, |
64 | SIL24_PORT_BAR = 2, | 64 | SIL24_PORT_BAR = 2, |
65 | 65 | ||
66 | /* sil24 fetches in chunks of 64bytes. The first block | ||
67 | * contains the PRB and two SGEs. From the second block, it's | ||
68 | * consisted of four SGEs and called SGT. Calculate the | ||
69 | * number of SGTs that fit into one page. | ||
70 | */ | ||
71 | SIL24_PRB_SZ = sizeof(struct sil24_prb) | ||
72 | + 2 * sizeof(struct sil24_sge), | ||
73 | SIL24_MAX_SGT = (PAGE_SIZE - SIL24_PRB_SZ) | ||
74 | / (4 * sizeof(struct sil24_sge)), | ||
75 | |||
76 | /* This will give us one unused SGEs for ATA. This extra SGE | ||
77 | * will be used to store CDB for ATAPI devices. | ||
78 | */ | ||
79 | SIL24_MAX_SGE = 4 * SIL24_MAX_SGT + 1, | ||
80 | |||
66 | /* | 81 | /* |
67 | * Global controller registers (128 bytes @ BAR0) | 82 | * Global controller registers (128 bytes @ BAR0) |
68 | */ | 83 | */ |
@@ -247,13 +262,13 @@ enum { | |||
247 | 262 | ||
248 | struct sil24_ata_block { | 263 | struct sil24_ata_block { |
249 | struct sil24_prb prb; | 264 | struct sil24_prb prb; |
250 | struct sil24_sge sge[LIBATA_MAX_PRD]; | 265 | struct sil24_sge sge[SIL24_MAX_SGE]; |
251 | }; | 266 | }; |
252 | 267 | ||
253 | struct sil24_atapi_block { | 268 | struct sil24_atapi_block { |
254 | struct sil24_prb prb; | 269 | struct sil24_prb prb; |
255 | u8 cdb[16]; | 270 | u8 cdb[16]; |
256 | struct sil24_sge sge[LIBATA_MAX_PRD - 1]; | 271 | struct sil24_sge sge[SIL24_MAX_SGE]; |
257 | }; | 272 | }; |
258 | 273 | ||
259 | union sil24_cmd_block { | 274 | union sil24_cmd_block { |
@@ -378,7 +393,7 @@ static struct scsi_host_template sil24_sht = { | |||
378 | .change_queue_depth = ata_scsi_change_queue_depth, | 393 | .change_queue_depth = ata_scsi_change_queue_depth, |
379 | .can_queue = SIL24_MAX_CMDS, | 394 | .can_queue = SIL24_MAX_CMDS, |
380 | .this_id = ATA_SHT_THIS_ID, | 395 | .this_id = ATA_SHT_THIS_ID, |
381 | .sg_tablesize = LIBATA_MAX_PRD, | 396 | .sg_tablesize = SIL24_MAX_SGE, |
382 | .cmd_per_lun = ATA_SHT_CMD_PER_LUN, | 397 | .cmd_per_lun = ATA_SHT_CMD_PER_LUN, |
383 | .emulated = ATA_SHT_EMULATED, | 398 | .emulated = ATA_SHT_EMULATED, |
384 | .use_clustering = ATA_SHT_USE_CLUSTERING, | 399 | .use_clustering = ATA_SHT_USE_CLUSTERING, |
@@ -1284,6 +1299,7 @@ static void sil24_init_controller(struct ata_host *host) | |||
1284 | 1299 | ||
1285 | static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | 1300 | static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
1286 | { | 1301 | { |
1302 | extern int __MARKER__sil24_cmd_block_is_sized_wrongly; | ||
1287 | static int printed_version; | 1303 | static int printed_version; |
1288 | struct ata_port_info pi = sil24_port_info[ent->driver_data]; | 1304 | struct ata_port_info pi = sil24_port_info[ent->driver_data]; |
1289 | const struct ata_port_info *ppi[] = { &pi, NULL }; | 1305 | const struct ata_port_info *ppi[] = { &pi, NULL }; |
@@ -1292,6 +1308,10 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1292 | int i, rc; | 1308 | int i, rc; |
1293 | u32 tmp; | 1309 | u32 tmp; |
1294 | 1310 | ||
1311 | /* cause link error if sil24_cmd_block is sized wrongly */ | ||
1312 | if (sizeof(union sil24_cmd_block) != PAGE_SIZE) | ||
1313 | __MARKER__sil24_cmd_block_is_sized_wrongly = 1; | ||
1314 | |||
1295 | if (!printed_version++) | 1315 | if (!printed_version++) |
1296 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 1316 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
1297 | 1317 | ||
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 3cf7129d83e6..924ddd8bccd2 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c | |||
@@ -223,7 +223,7 @@ static int virtblk_probe(struct virtio_device *vdev) | |||
223 | err = virtio_config_val(vdev, VIRTIO_CONFIG_BLK_F_CAPACITY, &cap); | 223 | err = virtio_config_val(vdev, VIRTIO_CONFIG_BLK_F_CAPACITY, &cap); |
224 | if (err) { | 224 | if (err) { |
225 | dev_err(&vdev->dev, "Bad/missing capacity in config\n"); | 225 | dev_err(&vdev->dev, "Bad/missing capacity in config\n"); |
226 | goto out_put_disk; | 226 | goto out_cleanup_queue; |
227 | } | 227 | } |
228 | 228 | ||
229 | /* If capacity is too big, truncate with warning. */ | 229 | /* If capacity is too big, truncate with warning. */ |
@@ -239,7 +239,7 @@ static int virtblk_probe(struct virtio_device *vdev) | |||
239 | blk_queue_max_segment_size(vblk->disk->queue, v); | 239 | blk_queue_max_segment_size(vblk->disk->queue, v); |
240 | else if (err != -ENOENT) { | 240 | else if (err != -ENOENT) { |
241 | dev_err(&vdev->dev, "Bad SIZE_MAX in config\n"); | 241 | dev_err(&vdev->dev, "Bad SIZE_MAX in config\n"); |
242 | goto out_put_disk; | 242 | goto out_cleanup_queue; |
243 | } | 243 | } |
244 | 244 | ||
245 | err = virtio_config_val(vdev, VIRTIO_CONFIG_BLK_F_SEG_MAX, &v); | 245 | err = virtio_config_val(vdev, VIRTIO_CONFIG_BLK_F_SEG_MAX, &v); |
@@ -247,12 +247,14 @@ static int virtblk_probe(struct virtio_device *vdev) | |||
247 | blk_queue_max_hw_segments(vblk->disk->queue, v); | 247 | blk_queue_max_hw_segments(vblk->disk->queue, v); |
248 | else if (err != -ENOENT) { | 248 | else if (err != -ENOENT) { |
249 | dev_err(&vdev->dev, "Bad SEG_MAX in config\n"); | 249 | dev_err(&vdev->dev, "Bad SEG_MAX in config\n"); |
250 | goto out_put_disk; | 250 | goto out_cleanup_queue; |
251 | } | 251 | } |
252 | 252 | ||
253 | add_disk(vblk->disk); | 253 | add_disk(vblk->disk); |
254 | return 0; | 254 | return 0; |
255 | 255 | ||
256 | out_cleanup_queue: | ||
257 | blk_cleanup_queue(vblk->disk->queue); | ||
256 | out_put_disk: | 258 | out_put_disk: |
257 | put_disk(vblk->disk); | 259 | put_disk(vblk->disk); |
258 | out_unregister_blkdev: | 260 | out_unregister_blkdev: |
@@ -277,6 +279,8 @@ static void virtblk_remove(struct virtio_device *vdev) | |||
277 | put_disk(vblk->disk); | 279 | put_disk(vblk->disk); |
278 | unregister_blkdev(major, "virtblk"); | 280 | unregister_blkdev(major, "virtblk"); |
279 | mempool_destroy(vblk->pool); | 281 | mempool_destroy(vblk->pool); |
282 | /* There should be nothing in the queue now, so no need to shutdown */ | ||
283 | vdev->config->del_vq(vblk->vq); | ||
280 | kfree(vblk); | 284 | kfree(vblk); |
281 | } | 285 | } |
282 | 286 | ||
diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c index b39d1f5b378e..ced83c202cac 100644 --- a/drivers/isdn/i4l/isdn_net.c +++ b/drivers/isdn/i4l/isdn_net.c | |||
@@ -2104,7 +2104,7 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup) | |||
2104 | u_long flags; | 2104 | u_long flags; |
2105 | isdn_net_dev *p; | 2105 | isdn_net_dev *p; |
2106 | isdn_net_phone *n; | 2106 | isdn_net_phone *n; |
2107 | char nr[32]; | 2107 | char nr[ISDN_MSNLEN]; |
2108 | char *my_eaz; | 2108 | char *my_eaz; |
2109 | 2109 | ||
2110 | /* Search name in netdev-chain */ | 2110 | /* Search name in netdev-chain */ |
@@ -2113,7 +2113,7 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup) | |||
2113 | nr[1] = '\0'; | 2113 | nr[1] = '\0'; |
2114 | printk(KERN_INFO "isdn_net: Incoming call without OAD, assuming '0'\n"); | 2114 | printk(KERN_INFO "isdn_net: Incoming call without OAD, assuming '0'\n"); |
2115 | } else | 2115 | } else |
2116 | strcpy(nr, setup->phone); | 2116 | strlcpy(nr, setup->phone, ISDN_MSNLEN); |
2117 | si1 = (int) setup->si1; | 2117 | si1 = (int) setup->si1; |
2118 | si2 = (int) setup->si2; | 2118 | si2 = (int) setup->si2; |
2119 | if (!setup->eazmsn[0]) { | 2119 | if (!setup->eazmsn[0]) { |
@@ -2789,7 +2789,7 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg) | |||
2789 | chidx = -1; | 2789 | chidx = -1; |
2790 | } | 2790 | } |
2791 | } | 2791 | } |
2792 | strcpy(lp->msn, cfg->eaz); | 2792 | strlcpy(lp->msn, cfg->eaz, sizeof(lp->msn)); |
2793 | lp->pre_device = drvidx; | 2793 | lp->pre_device = drvidx; |
2794 | lp->pre_channel = chidx; | 2794 | lp->pre_channel = chidx; |
2795 | lp->onhtime = cfg->onhtime; | 2795 | lp->onhtime = cfg->onhtime; |
@@ -2936,7 +2936,7 @@ isdn_net_addphone(isdn_net_ioctl_phone * phone) | |||
2936 | if (p) { | 2936 | if (p) { |
2937 | if (!(n = kmalloc(sizeof(isdn_net_phone), GFP_KERNEL))) | 2937 | if (!(n = kmalloc(sizeof(isdn_net_phone), GFP_KERNEL))) |
2938 | return -ENOMEM; | 2938 | return -ENOMEM; |
2939 | strcpy(n->num, phone->phone); | 2939 | strlcpy(n->num, phone->phone, sizeof(n->num)); |
2940 | n->next = p->local->phone[phone->outgoing & 1]; | 2940 | n->next = p->local->phone[phone->outgoing & 1]; |
2941 | p->local->phone[phone->outgoing & 1] = n; | 2941 | p->local->phone[phone->outgoing & 1] = n; |
2942 | return 0; | 2942 | return 0; |
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c index 66f38722253a..e2eec38c83c2 100644 --- a/drivers/lguest/lguest_device.c +++ b/drivers/lguest/lguest_device.c | |||
@@ -247,6 +247,8 @@ static void lg_del_vq(struct virtqueue *vq) | |||
247 | { | 247 | { |
248 | struct lguest_vq_info *lvq = vq->priv; | 248 | struct lguest_vq_info *lvq = vq->priv; |
249 | 249 | ||
250 | /* Release the interrupt */ | ||
251 | free_irq(lvq->config.irq, vq); | ||
250 | /* Tell virtio_ring.c to free the virtqueue. */ | 252 | /* Tell virtio_ring.c to free the virtqueue. */ |
251 | vring_del_virtqueue(vq); | 253 | vring_del_virtqueue(vq); |
252 | /* Unmap the pages containing the ring. */ | 254 | /* Unmap the pages containing the ring. */ |
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c index e953276664a0..ab23a3221585 100644 --- a/drivers/misc/thinkpad_acpi.c +++ b/drivers/misc/thinkpad_acpi.c | |||
@@ -21,7 +21,7 @@ | |||
21 | * 02110-1301, USA. | 21 | * 02110-1301, USA. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #define IBM_VERSION "0.16" | 24 | #define IBM_VERSION "0.17" |
25 | #define TPACPI_SYSFS_VERSION 0x020000 | 25 | #define TPACPI_SYSFS_VERSION 0x020000 |
26 | 26 | ||
27 | /* | 27 | /* |
@@ -964,15 +964,15 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) | |||
964 | KEY_UNKNOWN, /* 0x0C: FN+BACKSPACE */ | 964 | KEY_UNKNOWN, /* 0x0C: FN+BACKSPACE */ |
965 | KEY_UNKNOWN, /* 0x0D: FN+INSERT */ | 965 | KEY_UNKNOWN, /* 0x0D: FN+INSERT */ |
966 | KEY_UNKNOWN, /* 0x0E: FN+DELETE */ | 966 | KEY_UNKNOWN, /* 0x0E: FN+DELETE */ |
967 | KEY_BRIGHTNESSUP, /* 0x0F: FN+HOME (brightness up) */ | 967 | KEY_RESERVED, /* 0x0F: FN+HOME (brightness up) */ |
968 | /* Scan codes 0x10 to 0x1F: Extended ACPI HKEY hot keys */ | 968 | /* Scan codes 0x10 to 0x1F: Extended ACPI HKEY hot keys */ |
969 | KEY_BRIGHTNESSDOWN, /* 0x10: FN+END (brightness down) */ | 969 | KEY_RESERVED, /* 0x10: FN+END (brightness down) */ |
970 | KEY_RESERVED, /* 0x11: FN+PGUP (thinklight toggle) */ | 970 | KEY_RESERVED, /* 0x11: FN+PGUP (thinklight toggle) */ |
971 | KEY_UNKNOWN, /* 0x12: FN+PGDOWN */ | 971 | KEY_UNKNOWN, /* 0x12: FN+PGDOWN */ |
972 | KEY_ZOOM, /* 0x13: FN+SPACE (zoom) */ | 972 | KEY_ZOOM, /* 0x13: FN+SPACE (zoom) */ |
973 | KEY_VOLUMEUP, /* 0x14: VOLUME UP */ | 973 | KEY_RESERVED, /* 0x14: VOLUME UP */ |
974 | KEY_VOLUMEDOWN, /* 0x15: VOLUME DOWN */ | 974 | KEY_RESERVED, /* 0x15: VOLUME DOWN */ |
975 | KEY_MUTE, /* 0x16: MUTE */ | 975 | KEY_RESERVED, /* 0x16: MUTE */ |
976 | KEY_VENDOR, /* 0x17: Thinkpad/AccessIBM/Lenovo */ | 976 | KEY_VENDOR, /* 0x17: Thinkpad/AccessIBM/Lenovo */ |
977 | /* (assignments unknown, please report if found) */ | 977 | /* (assignments unknown, please report if found) */ |
978 | KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, | 978 | KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, |
@@ -993,9 +993,9 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) | |||
993 | KEY_RESERVED, /* 0x11: FN+PGUP (thinklight toggle) */ | 993 | KEY_RESERVED, /* 0x11: FN+PGUP (thinklight toggle) */ |
994 | KEY_UNKNOWN, /* 0x12: FN+PGDOWN */ | 994 | KEY_UNKNOWN, /* 0x12: FN+PGDOWN */ |
995 | KEY_ZOOM, /* 0x13: FN+SPACE (zoom) */ | 995 | KEY_ZOOM, /* 0x13: FN+SPACE (zoom) */ |
996 | KEY_VOLUMEUP, /* 0x14: VOLUME UP */ | 996 | KEY_RESERVED, /* 0x14: VOLUME UP */ |
997 | KEY_VOLUMEDOWN, /* 0x15: VOLUME DOWN */ | 997 | KEY_RESERVED, /* 0x15: VOLUME DOWN */ |
998 | KEY_MUTE, /* 0x16: MUTE */ | 998 | KEY_RESERVED, /* 0x16: MUTE */ |
999 | KEY_VENDOR, /* 0x17: Thinkpad/AccessIBM/Lenovo */ | 999 | KEY_VENDOR, /* 0x17: Thinkpad/AccessIBM/Lenovo */ |
1000 | /* (assignments unknown, please report if found) */ | 1000 | /* (assignments unknown, please report if found) */ |
1001 | KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, | 1001 | KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, |
@@ -1342,9 +1342,8 @@ static int hotkey_read(char *p) | |||
1342 | return len; | 1342 | return len; |
1343 | } | 1343 | } |
1344 | 1344 | ||
1345 | res = mutex_lock_interruptible(&hotkey_mutex); | 1345 | if (mutex_lock_interruptible(&hotkey_mutex)) |
1346 | if (res < 0) | 1346 | return -ERESTARTSYS; |
1347 | return res; | ||
1348 | res = hotkey_get(&status, &mask); | 1347 | res = hotkey_get(&status, &mask); |
1349 | mutex_unlock(&hotkey_mutex); | 1348 | mutex_unlock(&hotkey_mutex); |
1350 | if (res) | 1349 | if (res) |
@@ -1373,9 +1372,8 @@ static int hotkey_write(char *buf) | |||
1373 | if (!tp_features.hotkey) | 1372 | if (!tp_features.hotkey) |
1374 | return -ENODEV; | 1373 | return -ENODEV; |
1375 | 1374 | ||
1376 | res = mutex_lock_interruptible(&hotkey_mutex); | 1375 | if (mutex_lock_interruptible(&hotkey_mutex)) |
1377 | if (res < 0) | 1376 | return -ERESTARTSYS; |
1378 | return res; | ||
1379 | 1377 | ||
1380 | res = hotkey_get(&status, &mask); | 1378 | res = hotkey_get(&status, &mask); |
1381 | if (res) | 1379 | if (res) |
@@ -3114,6 +3112,99 @@ static struct backlight_ops ibm_backlight_data = { | |||
3114 | 3112 | ||
3115 | static struct mutex brightness_mutex; | 3113 | static struct mutex brightness_mutex; |
3116 | 3114 | ||
3115 | static int __init tpacpi_query_bcll_levels(acpi_handle handle) | ||
3116 | { | ||
3117 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
3118 | union acpi_object *obj; | ||
3119 | int rc; | ||
3120 | |||
3121 | if (ACPI_SUCCESS(acpi_evaluate_object(handle, NULL, NULL, &buffer))) { | ||
3122 | obj = (union acpi_object *)buffer.pointer; | ||
3123 | if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) { | ||
3124 | printk(IBM_ERR "Unknown BCLL data, " | ||
3125 | "please report this to %s\n", IBM_MAIL); | ||
3126 | rc = 0; | ||
3127 | } else { | ||
3128 | rc = obj->package.count; | ||
3129 | } | ||
3130 | } else { | ||
3131 | return 0; | ||
3132 | } | ||
3133 | |||
3134 | kfree(buffer.pointer); | ||
3135 | return rc; | ||
3136 | } | ||
3137 | |||
3138 | static acpi_status __init brightness_find_bcll(acpi_handle handle, u32 lvl, | ||
3139 | void *context, void **rv) | ||
3140 | { | ||
3141 | char name[ACPI_PATH_SEGMENT_LENGTH]; | ||
3142 | struct acpi_buffer buffer = { sizeof(name), &name }; | ||
3143 | |||
3144 | if (ACPI_SUCCESS(acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer)) && | ||
3145 | !strncmp("BCLL", name, sizeof(name) - 1)) { | ||
3146 | if (tpacpi_query_bcll_levels(handle) == 16) { | ||
3147 | *rv = handle; | ||
3148 | return AE_CTRL_TERMINATE; | ||
3149 | } else { | ||
3150 | return AE_OK; | ||
3151 | } | ||
3152 | } else { | ||
3153 | return AE_OK; | ||
3154 | } | ||
3155 | } | ||
3156 | |||
3157 | static int __init brightness_check_levels(void) | ||
3158 | { | ||
3159 | int status; | ||
3160 | void *found_node = NULL; | ||
3161 | |||
3162 | if (!vid_handle) { | ||
3163 | IBM_ACPIHANDLE_INIT(vid); | ||
3164 | } | ||
3165 | if (!vid_handle) | ||
3166 | return 0; | ||
3167 | |||
3168 | /* Search for a BCLL package with 16 levels */ | ||
3169 | status = acpi_walk_namespace(ACPI_TYPE_PACKAGE, vid_handle, 3, | ||
3170 | brightness_find_bcll, NULL, &found_node); | ||
3171 | |||
3172 | return (ACPI_SUCCESS(status) && found_node != NULL); | ||
3173 | } | ||
3174 | |||
3175 | static acpi_status __init brightness_find_bcl(acpi_handle handle, u32 lvl, | ||
3176 | void *context, void **rv) | ||
3177 | { | ||
3178 | char name[ACPI_PATH_SEGMENT_LENGTH]; | ||
3179 | struct acpi_buffer buffer = { sizeof(name), &name }; | ||
3180 | |||
3181 | if (ACPI_SUCCESS(acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer)) && | ||
3182 | !strncmp("_BCL", name, sizeof(name) - 1)) { | ||
3183 | *rv = handle; | ||
3184 | return AE_CTRL_TERMINATE; | ||
3185 | } else { | ||
3186 | return AE_OK; | ||
3187 | } | ||
3188 | } | ||
3189 | |||
3190 | static int __init brightness_check_std_acpi_support(void) | ||
3191 | { | ||
3192 | int status; | ||
3193 | void *found_node = NULL; | ||
3194 | |||
3195 | if (!vid_handle) { | ||
3196 | IBM_ACPIHANDLE_INIT(vid); | ||
3197 | } | ||
3198 | if (!vid_handle) | ||
3199 | return 0; | ||
3200 | |||
3201 | /* Search for a _BCL method, but don't execute it */ | ||
3202 | status = acpi_walk_namespace(ACPI_TYPE_METHOD, vid_handle, 3, | ||
3203 | brightness_find_bcl, NULL, &found_node); | ||
3204 | |||
3205 | return (ACPI_SUCCESS(status) && found_node != NULL); | ||
3206 | } | ||
3207 | |||
3117 | static int __init brightness_init(struct ibm_init_struct *iibm) | 3208 | static int __init brightness_init(struct ibm_init_struct *iibm) |
3118 | { | 3209 | { |
3119 | int b; | 3210 | int b; |
@@ -3122,6 +3213,18 @@ static int __init brightness_init(struct ibm_init_struct *iibm) | |||
3122 | 3213 | ||
3123 | mutex_init(&brightness_mutex); | 3214 | mutex_init(&brightness_mutex); |
3124 | 3215 | ||
3216 | if (!brightness_enable) { | ||
3217 | dbg_printk(TPACPI_DBG_INIT, | ||
3218 | "brightness support disabled by module parameter\n"); | ||
3219 | return 1; | ||
3220 | } else if (brightness_enable > 1) { | ||
3221 | if (brightness_check_std_acpi_support()) { | ||
3222 | printk(IBM_NOTICE | ||
3223 | "standard ACPI backlight interface available, not loading native one...\n"); | ||
3224 | return 1; | ||
3225 | } | ||
3226 | } | ||
3227 | |||
3125 | if (!brightness_mode) { | 3228 | if (!brightness_mode) { |
3126 | if (thinkpad_id.vendor == PCI_VENDOR_ID_LENOVO) | 3229 | if (thinkpad_id.vendor == PCI_VENDOR_ID_LENOVO) |
3127 | brightness_mode = 2; | 3230 | brightness_mode = 2; |
@@ -3135,10 +3238,17 @@ static int __init brightness_init(struct ibm_init_struct *iibm) | |||
3135 | if (brightness_mode > 3) | 3238 | if (brightness_mode > 3) |
3136 | return -EINVAL; | 3239 | return -EINVAL; |
3137 | 3240 | ||
3241 | tp_features.bright_16levels = | ||
3242 | thinkpad_id.vendor == PCI_VENDOR_ID_LENOVO && | ||
3243 | brightness_check_levels(); | ||
3244 | |||
3138 | b = brightness_get(NULL); | 3245 | b = brightness_get(NULL); |
3139 | if (b < 0) | 3246 | if (b < 0) |
3140 | return 1; | 3247 | return 1; |
3141 | 3248 | ||
3249 | if (tp_features.bright_16levels) | ||
3250 | printk(IBM_INFO "detected a 16-level brightness capable ThinkPad\n"); | ||
3251 | |||
3142 | ibm_backlight_device = backlight_device_register( | 3252 | ibm_backlight_device = backlight_device_register( |
3143 | TPACPI_BACKLIGHT_DEV_NAME, NULL, NULL, | 3253 | TPACPI_BACKLIGHT_DEV_NAME, NULL, NULL, |
3144 | &ibm_backlight_data); | 3254 | &ibm_backlight_data); |
@@ -3148,7 +3258,8 @@ static int __init brightness_init(struct ibm_init_struct *iibm) | |||
3148 | } | 3258 | } |
3149 | vdbg_printk(TPACPI_DBG_INIT, "brightness is supported\n"); | 3259 | vdbg_printk(TPACPI_DBG_INIT, "brightness is supported\n"); |
3150 | 3260 | ||
3151 | ibm_backlight_device->props.max_brightness = 7; | 3261 | ibm_backlight_device->props.max_brightness = |
3262 | (tp_features.bright_16levels)? 15 : 7; | ||
3152 | ibm_backlight_device->props.brightness = b; | 3263 | ibm_backlight_device->props.brightness = b; |
3153 | backlight_update_status(ibm_backlight_device); | 3264 | backlight_update_status(ibm_backlight_device); |
3154 | 3265 | ||
@@ -3167,6 +3278,8 @@ static void brightness_exit(void) | |||
3167 | 3278 | ||
3168 | static int brightness_update_status(struct backlight_device *bd) | 3279 | static int brightness_update_status(struct backlight_device *bd) |
3169 | { | 3280 | { |
3281 | /* it is the backlight class's job (caller) to handle | ||
3282 | * EINTR and other errors properly */ | ||
3170 | return brightness_set( | 3283 | return brightness_set( |
3171 | (bd->props.fb_blank == FB_BLANK_UNBLANK && | 3284 | (bd->props.fb_blank == FB_BLANK_UNBLANK && |
3172 | bd->props.power == FB_BLANK_UNBLANK) ? | 3285 | bd->props.power == FB_BLANK_UNBLANK) ? |
@@ -3184,13 +3297,14 @@ static int brightness_get(struct backlight_device *bd) | |||
3184 | if (brightness_mode & 1) { | 3297 | if (brightness_mode & 1) { |
3185 | if (!acpi_ec_read(brightness_offset, &lec)) | 3298 | if (!acpi_ec_read(brightness_offset, &lec)) |
3186 | return -EIO; | 3299 | return -EIO; |
3187 | lec &= 7; | 3300 | lec &= (tp_features.bright_16levels)? 0x0f : 0x07; |
3188 | level = lec; | 3301 | level = lec; |
3189 | }; | 3302 | }; |
3190 | if (brightness_mode & 2) { | 3303 | if (brightness_mode & 2) { |
3191 | lcmos = (nvram_read_byte(TP_NVRAM_ADDR_BRIGHTNESS) | 3304 | lcmos = (nvram_read_byte(TP_NVRAM_ADDR_BRIGHTNESS) |
3192 | & TP_NVRAM_MASK_LEVEL_BRIGHTNESS) | 3305 | & TP_NVRAM_MASK_LEVEL_BRIGHTNESS) |
3193 | >> TP_NVRAM_POS_LEVEL_BRIGHTNESS; | 3306 | >> TP_NVRAM_POS_LEVEL_BRIGHTNESS; |
3307 | lcmos &= (tp_features.bright_16levels)? 0x0f : 0x07; | ||
3194 | level = lcmos; | 3308 | level = lcmos; |
3195 | } | 3309 | } |
3196 | 3310 | ||
@@ -3206,12 +3320,13 @@ static int brightness_get(struct backlight_device *bd) | |||
3206 | return level; | 3320 | return level; |
3207 | } | 3321 | } |
3208 | 3322 | ||
3323 | /* May return EINTR which can always be mapped to ERESTARTSYS */ | ||
3209 | static int brightness_set(int value) | 3324 | static int brightness_set(int value) |
3210 | { | 3325 | { |
3211 | int cmos_cmd, inc, i, res; | 3326 | int cmos_cmd, inc, i, res; |
3212 | int current_value; | 3327 | int current_value; |
3213 | 3328 | ||
3214 | if (value > 7) | 3329 | if (value > ((tp_features.bright_16levels)? 15 : 7)) |
3215 | return -EINVAL; | 3330 | return -EINVAL; |
3216 | 3331 | ||
3217 | res = mutex_lock_interruptible(&brightness_mutex); | 3332 | res = mutex_lock_interruptible(&brightness_mutex); |
@@ -3227,7 +3342,7 @@ static int brightness_set(int value) | |||
3227 | cmos_cmd = value > current_value ? | 3342 | cmos_cmd = value > current_value ? |
3228 | TP_CMOS_BRIGHTNESS_UP : | 3343 | TP_CMOS_BRIGHTNESS_UP : |
3229 | TP_CMOS_BRIGHTNESS_DOWN; | 3344 | TP_CMOS_BRIGHTNESS_DOWN; |
3230 | inc = value > current_value ? 1 : -1; | 3345 | inc = (value > current_value)? 1 : -1; |
3231 | 3346 | ||
3232 | res = 0; | 3347 | res = 0; |
3233 | for (i = current_value; i != value; i += inc) { | 3348 | for (i = current_value; i != value; i += inc) { |
@@ -3256,10 +3371,11 @@ static int brightness_read(char *p) | |||
3256 | if ((level = brightness_get(NULL)) < 0) { | 3371 | if ((level = brightness_get(NULL)) < 0) { |
3257 | len += sprintf(p + len, "level:\t\tunreadable\n"); | 3372 | len += sprintf(p + len, "level:\t\tunreadable\n"); |
3258 | } else { | 3373 | } else { |
3259 | len += sprintf(p + len, "level:\t\t%d\n", level & 0x7); | 3374 | len += sprintf(p + len, "level:\t\t%d\n", level); |
3260 | len += sprintf(p + len, "commands:\tup, down\n"); | 3375 | len += sprintf(p + len, "commands:\tup, down\n"); |
3261 | len += sprintf(p + len, "commands:\tlevel <level>" | 3376 | len += sprintf(p + len, "commands:\tlevel <level>" |
3262 | " (<level> is 0-7)\n"); | 3377 | " (<level> is 0-%d)\n", |
3378 | (tp_features.bright_16levels) ? 15 : 7); | ||
3263 | } | 3379 | } |
3264 | 3380 | ||
3265 | return len; | 3381 | return len; |
@@ -3268,28 +3384,34 @@ static int brightness_read(char *p) | |||
3268 | static int brightness_write(char *buf) | 3384 | static int brightness_write(char *buf) |
3269 | { | 3385 | { |
3270 | int level; | 3386 | int level; |
3271 | int new_level; | 3387 | int rc; |
3272 | char *cmd; | 3388 | char *cmd; |
3389 | int max_level = (tp_features.bright_16levels) ? 15 : 7; | ||
3273 | 3390 | ||
3274 | while ((cmd = next_cmd(&buf))) { | 3391 | level = brightness_get(NULL); |
3275 | if ((level = brightness_get(NULL)) < 0) | 3392 | if (level < 0) |
3276 | return level; | 3393 | return level; |
3277 | level &= 7; | ||
3278 | 3394 | ||
3395 | while ((cmd = next_cmd(&buf))) { | ||
3279 | if (strlencmp(cmd, "up") == 0) { | 3396 | if (strlencmp(cmd, "up") == 0) { |
3280 | new_level = level == 7 ? 7 : level + 1; | 3397 | if (level < max_level) |
3398 | level++; | ||
3281 | } else if (strlencmp(cmd, "down") == 0) { | 3399 | } else if (strlencmp(cmd, "down") == 0) { |
3282 | new_level = level == 0 ? 0 : level - 1; | 3400 | if (level > 0) |
3283 | } else if (sscanf(cmd, "level %d", &new_level) == 1 && | 3401 | level--; |
3284 | new_level >= 0 && new_level <= 7) { | 3402 | } else if (sscanf(cmd, "level %d", &level) == 1 && |
3285 | /* new_level set */ | 3403 | level >= 0 && level <= max_level) { |
3404 | /* new level set */ | ||
3286 | } else | 3405 | } else |
3287 | return -EINVAL; | 3406 | return -EINVAL; |
3288 | |||
3289 | brightness_set(new_level); | ||
3290 | } | 3407 | } |
3291 | 3408 | ||
3292 | return 0; | 3409 | /* |
3410 | * Now we know what the final level should be, so we try to set it. | ||
3411 | * Doing it this way makes the syscall restartable in case of EINTR | ||
3412 | */ | ||
3413 | rc = brightness_set(level); | ||
3414 | return (rc == -EINTR)? ERESTARTSYS : rc; | ||
3293 | } | 3415 | } |
3294 | 3416 | ||
3295 | static struct ibm_struct brightness_driver_data = { | 3417 | static struct ibm_struct brightness_driver_data = { |
@@ -3652,9 +3774,8 @@ static ssize_t fan_pwm1_store(struct device *dev, | |||
3652 | /* scale down from 0-255 to 0-7 */ | 3774 | /* scale down from 0-255 to 0-7 */ |
3653 | newlevel = (s >> 5) & 0x07; | 3775 | newlevel = (s >> 5) & 0x07; |
3654 | 3776 | ||
3655 | rc = mutex_lock_interruptible(&fan_mutex); | 3777 | if (mutex_lock_interruptible(&fan_mutex)) |
3656 | if (rc < 0) | 3778 | return -ERESTARTSYS; |
3657 | return rc; | ||
3658 | 3779 | ||
3659 | rc = fan_get_status(&status); | 3780 | rc = fan_get_status(&status); |
3660 | if (!rc && (status & | 3781 | if (!rc && (status & |
@@ -3904,9 +4025,8 @@ static int fan_get_status_safe(u8 *status) | |||
3904 | int rc; | 4025 | int rc; |
3905 | u8 s; | 4026 | u8 s; |
3906 | 4027 | ||
3907 | rc = mutex_lock_interruptible(&fan_mutex); | 4028 | if (mutex_lock_interruptible(&fan_mutex)) |
3908 | if (rc < 0) | 4029 | return -ERESTARTSYS; |
3909 | return rc; | ||
3910 | rc = fan_get_status(&s); | 4030 | rc = fan_get_status(&s); |
3911 | if (!rc) | 4031 | if (!rc) |
3912 | fan_update_desired_level(s); | 4032 | fan_update_desired_level(s); |
@@ -4040,9 +4160,8 @@ static int fan_set_level_safe(int level) | |||
4040 | if (!fan_control_allowed) | 4160 | if (!fan_control_allowed) |
4041 | return -EPERM; | 4161 | return -EPERM; |
4042 | 4162 | ||
4043 | rc = mutex_lock_interruptible(&fan_mutex); | 4163 | if (mutex_lock_interruptible(&fan_mutex)) |
4044 | if (rc < 0) | 4164 | return -ERESTARTSYS; |
4045 | return rc; | ||
4046 | 4165 | ||
4047 | if (level == TPACPI_FAN_LAST_LEVEL) | 4166 | if (level == TPACPI_FAN_LAST_LEVEL) |
4048 | level = fan_control_desired_level; | 4167 | level = fan_control_desired_level; |
@@ -4063,9 +4182,8 @@ static int fan_set_enable(void) | |||
4063 | if (!fan_control_allowed) | 4182 | if (!fan_control_allowed) |
4064 | return -EPERM; | 4183 | return -EPERM; |
4065 | 4184 | ||
4066 | rc = mutex_lock_interruptible(&fan_mutex); | 4185 | if (mutex_lock_interruptible(&fan_mutex)) |
4067 | if (rc < 0) | 4186 | return -ERESTARTSYS; |
4068 | return rc; | ||
4069 | 4187 | ||
4070 | switch (fan_control_access_mode) { | 4188 | switch (fan_control_access_mode) { |
4071 | case TPACPI_FAN_WR_ACPI_FANS: | 4189 | case TPACPI_FAN_WR_ACPI_FANS: |
@@ -4119,9 +4237,8 @@ static int fan_set_disable(void) | |||
4119 | if (!fan_control_allowed) | 4237 | if (!fan_control_allowed) |
4120 | return -EPERM; | 4238 | return -EPERM; |
4121 | 4239 | ||
4122 | rc = mutex_lock_interruptible(&fan_mutex); | 4240 | if (mutex_lock_interruptible(&fan_mutex)) |
4123 | if (rc < 0) | 4241 | return -ERESTARTSYS; |
4124 | return rc; | ||
4125 | 4242 | ||
4126 | rc = 0; | 4243 | rc = 0; |
4127 | switch (fan_control_access_mode) { | 4244 | switch (fan_control_access_mode) { |
@@ -4158,9 +4275,8 @@ static int fan_set_speed(int speed) | |||
4158 | if (!fan_control_allowed) | 4275 | if (!fan_control_allowed) |
4159 | return -EPERM; | 4276 | return -EPERM; |
4160 | 4277 | ||
4161 | rc = mutex_lock_interruptible(&fan_mutex); | 4278 | if (mutex_lock_interruptible(&fan_mutex)) |
4162 | if (rc < 0) | 4279 | return -ERESTARTSYS; |
4163 | return rc; | ||
4164 | 4280 | ||
4165 | rc = 0; | 4281 | rc = 0; |
4166 | switch (fan_control_access_mode) { | 4282 | switch (fan_control_access_mode) { |
@@ -4701,9 +4817,15 @@ static int __init set_ibm_param(const char *val, struct kernel_param *kp) | |||
4701 | unsigned int i; | 4817 | unsigned int i; |
4702 | struct ibm_struct *ibm; | 4818 | struct ibm_struct *ibm; |
4703 | 4819 | ||
4820 | if (!kp || !kp->name || !val) | ||
4821 | return -EINVAL; | ||
4822 | |||
4704 | for (i = 0; i < ARRAY_SIZE(ibms_init); i++) { | 4823 | for (i = 0; i < ARRAY_SIZE(ibms_init); i++) { |
4705 | ibm = ibms_init[i].data; | 4824 | ibm = ibms_init[i].data; |
4706 | BUG_ON(ibm == NULL); | 4825 | WARN_ON(ibm == NULL); |
4826 | |||
4827 | if (!ibm || !ibm->name) | ||
4828 | continue; | ||
4707 | 4829 | ||
4708 | if (strcmp(ibm->name, kp->name) == 0 && ibm->write) { | 4830 | if (strcmp(ibm->name, kp->name) == 0 && ibm->write) { |
4709 | if (strlen(val) > sizeof(ibms_init[i].param) - 2) | 4831 | if (strlen(val) > sizeof(ibms_init[i].param) - 2) |
@@ -4732,6 +4854,9 @@ module_param_named(fan_control, fan_control_allowed, bool, 0); | |||
4732 | static int brightness_mode; | 4854 | static int brightness_mode; |
4733 | module_param_named(brightness_mode, brightness_mode, int, 0); | 4855 | module_param_named(brightness_mode, brightness_mode, int, 0); |
4734 | 4856 | ||
4857 | static unsigned int brightness_enable = 2; /* 2 = auto, 0 = no, 1 = yes */ | ||
4858 | module_param(brightness_enable, uint, 0); | ||
4859 | |||
4735 | static unsigned int hotkey_report_mode; | 4860 | static unsigned int hotkey_report_mode; |
4736 | module_param(hotkey_report_mode, uint, 0); | 4861 | module_param(hotkey_report_mode, uint, 0); |
4737 | 4862 | ||
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h index 3abcc8120634..8fba2bbe345e 100644 --- a/drivers/misc/thinkpad_acpi.h +++ b/drivers/misc/thinkpad_acpi.h | |||
@@ -84,7 +84,7 @@ | |||
84 | 84 | ||
85 | /* ThinkPad CMOS NVRAM constants */ | 85 | /* ThinkPad CMOS NVRAM constants */ |
86 | #define TP_NVRAM_ADDR_BRIGHTNESS 0x5e | 86 | #define TP_NVRAM_ADDR_BRIGHTNESS 0x5e |
87 | #define TP_NVRAM_MASK_LEVEL_BRIGHTNESS 0x07 | 87 | #define TP_NVRAM_MASK_LEVEL_BRIGHTNESS 0x0f |
88 | #define TP_NVRAM_POS_LEVEL_BRIGHTNESS 0 | 88 | #define TP_NVRAM_POS_LEVEL_BRIGHTNESS 0 |
89 | 89 | ||
90 | #define onoff(status,bit) ((status) & (1 << (bit)) ? "on" : "off") | 90 | #define onoff(status,bit) ((status) & (1 << (bit)) ? "on" : "off") |
@@ -246,6 +246,7 @@ static struct { | |||
246 | u32 hotkey_wlsw:1; | 246 | u32 hotkey_wlsw:1; |
247 | u32 light:1; | 247 | u32 light:1; |
248 | u32 light_status:1; | 248 | u32 light_status:1; |
249 | u32 bright_16levels:1; | ||
249 | u32 wan:1; | 250 | u32 wan:1; |
250 | u32 fan_ctrl_status_undef:1; | 251 | u32 fan_ctrl_status_undef:1; |
251 | u32 input_device_registered:1; | 252 | u32 input_device_registered:1; |
@@ -338,6 +339,7 @@ static int bluetooth_write(char *buf); | |||
338 | static struct backlight_device *ibm_backlight_device; | 339 | static struct backlight_device *ibm_backlight_device; |
339 | static int brightness_offset = 0x31; | 340 | static int brightness_offset = 0x31; |
340 | static int brightness_mode; | 341 | static int brightness_mode; |
342 | static unsigned int brightness_enable; /* 0 = no, 1 = yes, 2 = auto */ | ||
341 | 343 | ||
342 | static int brightness_init(struct ibm_init_struct *iibm); | 344 | static int brightness_init(struct ibm_init_struct *iibm); |
343 | static void brightness_exit(void); | 345 | static void brightness_exit(void); |
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index e38d5a3b2a89..aeb32a93f6a0 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c | |||
@@ -44,6 +44,9 @@ | |||
44 | * max 8 partitions per card | 44 | * max 8 partitions per card |
45 | */ | 45 | */ |
46 | #define MMC_SHIFT 3 | 46 | #define MMC_SHIFT 3 |
47 | #define MMC_NUM_MINORS (256 >> MMC_SHIFT) | ||
48 | |||
49 | static unsigned long dev_use[MMC_NUM_MINORS/(8*sizeof(unsigned long))]; | ||
47 | 50 | ||
48 | /* | 51 | /* |
49 | * There is one mmc_blk_data per slot. | 52 | * There is one mmc_blk_data per slot. |
@@ -80,6 +83,9 @@ static void mmc_blk_put(struct mmc_blk_data *md) | |||
80 | mutex_lock(&open_lock); | 83 | mutex_lock(&open_lock); |
81 | md->usage--; | 84 | md->usage--; |
82 | if (md->usage == 0) { | 85 | if (md->usage == 0) { |
86 | int devidx = md->disk->first_minor >> MMC_SHIFT; | ||
87 | __clear_bit(devidx, dev_use); | ||
88 | |||
83 | put_disk(md->disk); | 89 | put_disk(md->disk); |
84 | kfree(md); | 90 | kfree(md); |
85 | } | 91 | } |
@@ -321,7 +327,13 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) | |||
321 | req->rq_disk->disk_name, err); | 327 | req->rq_disk->disk_name, err); |
322 | goto cmd_err; | 328 | goto cmd_err; |
323 | } | 329 | } |
324 | } while (!(cmd.resp[0] & R1_READY_FOR_DATA)); | 330 | /* |
331 | * Some cards mishandle the status bits, | ||
332 | * so make sure to check both the busy | ||
333 | * indication and the card state. | ||
334 | */ | ||
335 | } while (!(cmd.resp[0] & R1_READY_FOR_DATA) || | ||
336 | (R1_CURRENT_STATE(cmd.resp[0]) == 7)); | ||
325 | 337 | ||
326 | #if 0 | 338 | #if 0 |
327 | if (cmd.resp[0] & ~0x00000900) | 339 | if (cmd.resp[0] & ~0x00000900) |
@@ -400,9 +412,6 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) | |||
400 | return 0; | 412 | return 0; |
401 | } | 413 | } |
402 | 414 | ||
403 | #define MMC_NUM_MINORS (256 >> MMC_SHIFT) | ||
404 | |||
405 | static unsigned long dev_use[MMC_NUM_MINORS/(8*sizeof(unsigned long))]; | ||
406 | 415 | ||
407 | static inline int mmc_blk_readonly(struct mmc_card *card) | 416 | static inline int mmc_blk_readonly(struct mmc_card *card) |
408 | { | 417 | { |
@@ -568,17 +577,12 @@ static void mmc_blk_remove(struct mmc_card *card) | |||
568 | struct mmc_blk_data *md = mmc_get_drvdata(card); | 577 | struct mmc_blk_data *md = mmc_get_drvdata(card); |
569 | 578 | ||
570 | if (md) { | 579 | if (md) { |
571 | int devidx; | ||
572 | |||
573 | /* Stop new requests from getting into the queue */ | 580 | /* Stop new requests from getting into the queue */ |
574 | del_gendisk(md->disk); | 581 | del_gendisk(md->disk); |
575 | 582 | ||
576 | /* Then flush out any already in there */ | 583 | /* Then flush out any already in there */ |
577 | mmc_cleanup_queue(&md->queue); | 584 | mmc_cleanup_queue(&md->queue); |
578 | 585 | ||
579 | devidx = md->disk->first_minor >> MMC_SHIFT; | ||
580 | __clear_bit(devidx, dev_use); | ||
581 | |||
582 | mmc_blk_put(md); | 586 | mmc_blk_put(md); |
583 | } | 587 | } |
584 | mmc_set_drvdata(card, NULL); | 588 | mmc_set_drvdata(card, NULL); |
diff --git a/drivers/mmc/host/tifm_sd.c b/drivers/mmc/host/tifm_sd.c index c11a3d256051..20d5c7bd940a 100644 --- a/drivers/mmc/host/tifm_sd.c +++ b/drivers/mmc/host/tifm_sd.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <linux/mmc/host.h> | 16 | #include <linux/mmc/host.h> |
17 | #include <linux/highmem.h> | 17 | #include <linux/highmem.h> |
18 | #include <linux/scatterlist.h> | 18 | #include <linux/scatterlist.h> |
19 | #include <linux/log2.h> | ||
20 | #include <asm/io.h> | 19 | #include <asm/io.h> |
21 | 20 | ||
22 | #define DRIVER_NAME "tifm_sd" | 21 | #define DRIVER_NAME "tifm_sd" |
@@ -638,17 +637,15 @@ static void tifm_sd_request(struct mmc_host *mmc, struct mmc_request *mrq) | |||
638 | goto err_out; | 637 | goto err_out; |
639 | } | 638 | } |
640 | 639 | ||
641 | if (mrq->data && !is_power_of_2(mrq->data->blksz)) { | ||
642 | printk(KERN_ERR "%s: Unsupported block size (%d bytes)\n", | ||
643 | sock->dev.bus_id, mrq->data->blksz); | ||
644 | mrq->cmd->error = -EINVAL; | ||
645 | goto err_out; | ||
646 | } | ||
647 | |||
648 | host->cmd_flags = 0; | 640 | host->cmd_flags = 0; |
649 | host->block_pos = 0; | 641 | host->block_pos = 0; |
650 | host->sg_pos = 0; | 642 | host->sg_pos = 0; |
651 | 643 | ||
644 | if (mrq->data && !is_power_of_2(mrq->data->blksz)) | ||
645 | host->no_dma = 1; | ||
646 | else | ||
647 | host->no_dma = no_dma ? 1 : 0; | ||
648 | |||
652 | if (r_data) { | 649 | if (r_data) { |
653 | tifm_sd_set_data_timeout(host, r_data); | 650 | tifm_sd_set_data_timeout(host, r_data); |
654 | 651 | ||
@@ -676,7 +673,7 @@ static void tifm_sd_request(struct mmc_host *mmc, struct mmc_request *mrq) | |||
676 | : PCI_DMA_FROMDEVICE)) { | 673 | : PCI_DMA_FROMDEVICE)) { |
677 | printk(KERN_ERR "%s : scatterlist map failed\n", | 674 | printk(KERN_ERR "%s : scatterlist map failed\n", |
678 | sock->dev.bus_id); | 675 | sock->dev.bus_id); |
679 | spin_unlock_irqrestore(&sock->lock, flags); | 676 | mrq->cmd->error = -ENOMEM; |
680 | goto err_out; | 677 | goto err_out; |
681 | } | 678 | } |
682 | host->sg_len = tifm_map_sg(sock, r_data->sg, | 679 | host->sg_len = tifm_map_sg(sock, r_data->sg, |
@@ -692,7 +689,7 @@ static void tifm_sd_request(struct mmc_host *mmc, struct mmc_request *mrq) | |||
692 | r_data->flags & MMC_DATA_WRITE | 689 | r_data->flags & MMC_DATA_WRITE |
693 | ? PCI_DMA_TODEVICE | 690 | ? PCI_DMA_TODEVICE |
694 | : PCI_DMA_FROMDEVICE); | 691 | : PCI_DMA_FROMDEVICE); |
695 | spin_unlock_irqrestore(&sock->lock, flags); | 692 | mrq->cmd->error = -ENOMEM; |
696 | goto err_out; | 693 | goto err_out; |
697 | } | 694 | } |
698 | 695 | ||
@@ -966,7 +963,6 @@ static int tifm_sd_probe(struct tifm_dev *sock) | |||
966 | return -ENOMEM; | 963 | return -ENOMEM; |
967 | 964 | ||
968 | host = mmc_priv(mmc); | 965 | host = mmc_priv(mmc); |
969 | host->no_dma = no_dma; | ||
970 | tifm_set_drvdata(sock, mmc); | 966 | tifm_set_drvdata(sock, mmc); |
971 | host->dev = sock; | 967 | host->dev = sock; |
972 | host->timeout_jiffies = msecs_to_jiffies(1000); | 968 | host->timeout_jiffies = msecs_to_jiffies(1000); |
diff --git a/drivers/net/plip.c b/drivers/net/plip.c index 5071fcd8a0bd..57c98669984d 100644 --- a/drivers/net/plip.c +++ b/drivers/net/plip.c | |||
@@ -663,7 +663,7 @@ plip_receive_packet(struct net_device *dev, struct net_local *nl, | |||
663 | case PLIP_PK_DONE: | 663 | case PLIP_PK_DONE: |
664 | /* Inform the upper layer for the arrival of a packet. */ | 664 | /* Inform the upper layer for the arrival of a packet. */ |
665 | rcv->skb->protocol=plip_type_trans(rcv->skb, dev); | 665 | rcv->skb->protocol=plip_type_trans(rcv->skb, dev); |
666 | netif_rx(rcv->skb); | 666 | netif_rx_ni(rcv->skb); |
667 | dev->last_rx = jiffies; | 667 | dev->last_rx = jiffies; |
668 | dev->stats.rx_bytes += rcv->length.h; | 668 | dev->stats.rx_bytes += rcv->length.h; |
669 | dev->stats.rx_packets++; | 669 | dev->stats.rx_packets++; |
@@ -1269,7 +1269,7 @@ static void plip_attach (struct parport *port) | |||
1269 | 1269 | ||
1270 | nl = netdev_priv(dev); | 1270 | nl = netdev_priv(dev); |
1271 | nl->dev = dev; | 1271 | nl->dev = dev; |
1272 | nl->pardev = parport_register_device(port, name, plip_preempt, | 1272 | nl->pardev = parport_register_device(port, dev->name, plip_preempt, |
1273 | plip_wakeup, plip_interrupt, | 1273 | plip_wakeup, plip_interrupt, |
1274 | 0, dev); | 1274 | 0, dev); |
1275 | 1275 | ||
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index a75be57fb209..5413dbf3d4ac 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c | |||
@@ -198,8 +198,8 @@ again: | |||
198 | if (vi->num < vi->max / 2) | 198 | if (vi->num < vi->max / 2) |
199 | try_fill_recv(vi); | 199 | try_fill_recv(vi); |
200 | 200 | ||
201 | /* All done? */ | 201 | /* Out of packets? */ |
202 | if (!skb) { | 202 | if (received < budget) { |
203 | netif_rx_complete(vi->dev, napi); | 203 | netif_rx_complete(vi->dev, napi); |
204 | if (unlikely(!vi->rvq->vq_ops->restart(vi->rvq)) | 204 | if (unlikely(!vi->rvq->vq_ops->restart(vi->rvq)) |
205 | && netif_rx_reschedule(vi->dev, napi)) | 205 | && netif_rx_reschedule(vi->dev, napi)) |
@@ -404,8 +404,12 @@ free: | |||
404 | 404 | ||
405 | static void virtnet_remove(struct virtio_device *vdev) | 405 | static void virtnet_remove(struct virtio_device *vdev) |
406 | { | 406 | { |
407 | unregister_netdev(vdev->priv); | 407 | struct virtnet_info *vi = vdev->priv; |
408 | free_netdev(vdev->priv); | 408 | |
409 | vdev->config->del_vq(vi->svq); | ||
410 | vdev->config->del_vq(vi->rvq); | ||
411 | unregister_netdev(vi->dev); | ||
412 | free_netdev(vi->dev); | ||
409 | } | 413 | } |
410 | 414 | ||
411 | static struct virtio_device_id id_table[] = { | 415 | static struct virtio_device_id id_table[] = { |
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index cd0a204d96d1..11adab13f2b7 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c | |||
@@ -75,6 +75,7 @@ static void pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res, | |||
75 | { | 75 | { |
76 | int i = 0; | 76 | int i = 0; |
77 | int irq; | 77 | int irq; |
78 | int p, t; | ||
78 | 79 | ||
79 | if (!valid_IRQ(gsi)) | 80 | if (!valid_IRQ(gsi)) |
80 | return; | 81 | return; |
@@ -85,15 +86,22 @@ static void pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res, | |||
85 | if (i >= PNP_MAX_IRQ) | 86 | if (i >= PNP_MAX_IRQ) |
86 | return; | 87 | return; |
87 | 88 | ||
88 | #ifdef CONFIG_X86 | 89 | /* |
89 | if (gsi < 16 && (triggering != ACPI_EDGE_SENSITIVE || | 90 | * in IO-APIC mode, use overrided attribute. Two reasons: |
90 | polarity != ACPI_ACTIVE_HIGH)) { | 91 | * 1. BIOS bug in DSDT |
91 | pnp_warn("BIOS BUG: legacy PNP IRQ %d should be edge trigger, " | 92 | * 2. BIOS uses IO-APIC mode Interrupt Source Override |
92 | "active high", gsi); | 93 | */ |
93 | triggering = ACPI_EDGE_SENSITIVE; | 94 | if (!acpi_get_override_irq(gsi, &t, &p)) { |
94 | polarity = ACPI_ACTIVE_HIGH; | 95 | t = t ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE; |
96 | p = p ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH; | ||
97 | |||
98 | if (triggering != t || polarity != p) { | ||
99 | pnp_warn("IRQ %d override to %s, %s", | ||
100 | gsi, t ? "edge":"level", p ? "low":"high"); | ||
101 | triggering = t; | ||
102 | polarity = p; | ||
103 | } | ||
95 | } | 104 | } |
96 | #endif | ||
97 | 105 | ||
98 | res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag | 106 | res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag |
99 | res->irq_resource[i].flags |= irq_flags(triggering, polarity); | 107 | res->irq_resource[i].flags |= irq_flags(triggering, polarity); |
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c index 838f7ac0dc32..6db31089d2d7 100644 --- a/drivers/s390/cio/css.c +++ b/drivers/s390/cio/css.c | |||
@@ -483,7 +483,7 @@ static DECLARE_WORK(css_reprobe_work, reprobe_all); | |||
483 | void css_schedule_reprobe(void) | 483 | void css_schedule_reprobe(void) |
484 | { | 484 | { |
485 | need_reprobe = 1; | 485 | need_reprobe = 1; |
486 | queue_work(ccw_device_work, &css_reprobe_work); | 486 | queue_work(slow_path_wq, &css_reprobe_work); |
487 | } | 487 | } |
488 | 488 | ||
489 | EXPORT_SYMBOL_GPL(css_schedule_reprobe); | 489 | EXPORT_SYMBOL_GPL(css_schedule_reprobe); |
diff --git a/drivers/s390/cio/device_fsm.c b/drivers/s390/cio/device_fsm.c index 8867443b8060..bfad421cda66 100644 --- a/drivers/s390/cio/device_fsm.c +++ b/drivers/s390/cio/device_fsm.c | |||
@@ -1034,7 +1034,7 @@ device_trigger_reprobe(struct subchannel *sch) | |||
1034 | if (sch->schib.pmcw.dev != cdev->private->dev_id.devno) { | 1034 | if (sch->schib.pmcw.dev != cdev->private->dev_id.devno) { |
1035 | PREPARE_WORK(&cdev->private->kick_work, | 1035 | PREPARE_WORK(&cdev->private->kick_work, |
1036 | ccw_device_move_to_orphanage); | 1036 | ccw_device_move_to_orphanage); |
1037 | queue_work(ccw_device_work, &cdev->private->kick_work); | 1037 | queue_work(slow_path_wq, &cdev->private->kick_work); |
1038 | } else | 1038 | } else |
1039 | ccw_device_start_id(cdev, 0); | 1039 | ccw_device_start_id(cdev, 0); |
1040 | } | 1040 | } |
diff --git a/drivers/s390/cio/device_id.c b/drivers/s390/cio/device_id.c index f232832f2b22..2f6bf462425e 100644 --- a/drivers/s390/cio/device_id.c +++ b/drivers/s390/cio/device_id.c | |||
@@ -113,19 +113,10 @@ __ccw_device_sense_id_start(struct ccw_device *cdev) | |||
113 | { | 113 | { |
114 | struct subchannel *sch; | 114 | struct subchannel *sch; |
115 | struct ccw1 *ccw; | 115 | struct ccw1 *ccw; |
116 | int ret; | ||
117 | 116 | ||
118 | sch = to_subchannel(cdev->dev.parent); | 117 | sch = to_subchannel(cdev->dev.parent); |
119 | /* Setup sense channel program. */ | 118 | /* Setup sense channel program. */ |
120 | ccw = cdev->private->iccws; | 119 | ccw = cdev->private->iccws; |
121 | if (sch->schib.pmcw.pim != 0x80) { | ||
122 | /* more than one path installed. */ | ||
123 | ccw->cmd_code = CCW_CMD_SUSPEND_RECONN; | ||
124 | ccw->cda = 0; | ||
125 | ccw->count = 0; | ||
126 | ccw->flags = CCW_FLAG_SLI | CCW_FLAG_CC; | ||
127 | ccw++; | ||
128 | } | ||
129 | ccw->cmd_code = CCW_CMD_SENSE_ID; | 120 | ccw->cmd_code = CCW_CMD_SENSE_ID; |
130 | ccw->cda = (__u32) __pa (&cdev->private->senseid); | 121 | ccw->cda = (__u32) __pa (&cdev->private->senseid); |
131 | ccw->count = sizeof (struct senseid); | 122 | ccw->count = sizeof (struct senseid); |
@@ -133,25 +124,9 @@ __ccw_device_sense_id_start(struct ccw_device *cdev) | |||
133 | 124 | ||
134 | /* Reset device status. */ | 125 | /* Reset device status. */ |
135 | memset(&cdev->private->irb, 0, sizeof(struct irb)); | 126 | memset(&cdev->private->irb, 0, sizeof(struct irb)); |
127 | cdev->private->flags.intretry = 0; | ||
136 | 128 | ||
137 | /* Try on every path. */ | 129 | return cio_start(sch, ccw, LPM_ANYPATH); |
138 | ret = -ENODEV; | ||
139 | while (cdev->private->imask != 0) { | ||
140 | if ((sch->opm & cdev->private->imask) != 0 && | ||
141 | cdev->private->iretry > 0) { | ||
142 | cdev->private->iretry--; | ||
143 | /* Reset internal retry indication. */ | ||
144 | cdev->private->flags.intretry = 0; | ||
145 | ret = cio_start (sch, cdev->private->iccws, | ||
146 | cdev->private->imask); | ||
147 | /* ret is 0, -EBUSY, -EACCES or -ENODEV */ | ||
148 | if (ret != -EACCES) | ||
149 | return ret; | ||
150 | } | ||
151 | cdev->private->imask >>= 1; | ||
152 | cdev->private->iretry = 5; | ||
153 | } | ||
154 | return ret; | ||
155 | } | 130 | } |
156 | 131 | ||
157 | void | 132 | void |
@@ -161,8 +136,7 @@ ccw_device_sense_id_start(struct ccw_device *cdev) | |||
161 | 136 | ||
162 | memset (&cdev->private->senseid, 0, sizeof (struct senseid)); | 137 | memset (&cdev->private->senseid, 0, sizeof (struct senseid)); |
163 | cdev->private->senseid.cu_type = 0xFFFF; | 138 | cdev->private->senseid.cu_type = 0xFFFF; |
164 | cdev->private->imask = 0x80; | 139 | cdev->private->iretry = 3; |
165 | cdev->private->iretry = 5; | ||
166 | ret = __ccw_device_sense_id_start(cdev); | 140 | ret = __ccw_device_sense_id_start(cdev); |
167 | if (ret && ret != -EBUSY) | 141 | if (ret && ret != -EBUSY) |
168 | ccw_device_sense_id_done(cdev, ret); | 142 | ccw_device_sense_id_done(cdev, ret); |
@@ -278,14 +252,13 @@ ccw_device_sense_id_irq(struct ccw_device *cdev, enum dev_event dev_event) | |||
278 | ccw_device_sense_id_done(cdev, ret); | 252 | ccw_device_sense_id_done(cdev, ret); |
279 | break; | 253 | break; |
280 | case -EACCES: /* channel is not operational. */ | 254 | case -EACCES: /* channel is not operational. */ |
281 | sch->lpm &= ~cdev->private->imask; | ||
282 | cdev->private->imask >>= 1; | ||
283 | cdev->private->iretry = 5; | ||
284 | /* fall through. */ | ||
285 | case -EAGAIN: /* try again. */ | 255 | case -EAGAIN: /* try again. */ |
286 | ret = __ccw_device_sense_id_start(cdev); | 256 | cdev->private->iretry--; |
287 | if (ret == 0 || ret == -EBUSY) | 257 | if (cdev->private->iretry > 0) { |
288 | break; | 258 | ret = __ccw_device_sense_id_start(cdev); |
259 | if (ret == 0 || ret == -EBUSY) | ||
260 | break; | ||
261 | } | ||
289 | /* fall through. */ | 262 | /* fall through. */ |
290 | default: /* Sense ID failed. Try asking VM. */ | 263 | default: /* Sense ID failed. Try asking VM. */ |
291 | if (MACHINE_IS_VM) { | 264 | if (MACHINE_IS_VM) { |
diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c index 1e32b3d13f2e..62867cb63fef 100644 --- a/drivers/video/aty/radeon_base.c +++ b/drivers/video/aty/radeon_base.c | |||
@@ -202,6 +202,7 @@ static struct pci_device_id radeonfb_pci_table[] = { | |||
202 | CHIP_DEF(PCI_CHIP_RV380_3154, RV380, CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY), | 202 | CHIP_DEF(PCI_CHIP_RV380_3154, RV380, CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY), |
203 | CHIP_DEF(PCI_CHIP_RV370_5B60, RV380, CHIP_HAS_CRTC2), | 203 | CHIP_DEF(PCI_CHIP_RV370_5B60, RV380, CHIP_HAS_CRTC2), |
204 | CHIP_DEF(PCI_CHIP_RV370_5B62, RV380, CHIP_HAS_CRTC2), | 204 | CHIP_DEF(PCI_CHIP_RV370_5B62, RV380, CHIP_HAS_CRTC2), |
205 | CHIP_DEF(PCI_CHIP_RV370_5B63, RV380, CHIP_HAS_CRTC2), | ||
205 | CHIP_DEF(PCI_CHIP_RV370_5B64, RV380, CHIP_HAS_CRTC2), | 206 | CHIP_DEF(PCI_CHIP_RV370_5B64, RV380, CHIP_HAS_CRTC2), |
206 | CHIP_DEF(PCI_CHIP_RV370_5B65, RV380, CHIP_HAS_CRTC2), | 207 | CHIP_DEF(PCI_CHIP_RV370_5B65, RV380, CHIP_HAS_CRTC2), |
207 | CHIP_DEF(PCI_CHIP_RV370_5460, RV380, CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY), | 208 | CHIP_DEF(PCI_CHIP_RV370_5460, RV380, CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY), |
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index 15d7787dea87..69d7ea02cd48 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c | |||
@@ -96,10 +96,23 @@ static int virtio_dev_probe(struct device *_d) | |||
96 | return err; | 96 | return err; |
97 | } | 97 | } |
98 | 98 | ||
99 | static int virtio_dev_remove(struct device *_d) | ||
100 | { | ||
101 | struct virtio_device *dev = container_of(_d,struct virtio_device,dev); | ||
102 | struct virtio_driver *drv = container_of(dev->dev.driver, | ||
103 | struct virtio_driver, driver); | ||
104 | |||
105 | dev->config->set_status(dev, dev->config->get_status(dev) | ||
106 | & ~VIRTIO_CONFIG_S_DRIVER); | ||
107 | drv->remove(dev); | ||
108 | return 0; | ||
109 | } | ||
110 | |||
99 | int register_virtio_driver(struct virtio_driver *driver) | 111 | int register_virtio_driver(struct virtio_driver *driver) |
100 | { | 112 | { |
101 | driver->driver.bus = &virtio_bus; | 113 | driver->driver.bus = &virtio_bus; |
102 | driver->driver.probe = virtio_dev_probe; | 114 | driver->driver.probe = virtio_dev_probe; |
115 | driver->driver.remove = virtio_dev_remove; | ||
103 | return driver_register(&driver->driver); | 116 | return driver_register(&driver->driver); |
104 | } | 117 | } |
105 | EXPORT_SYMBOL_GPL(register_virtio_driver); | 118 | EXPORT_SYMBOL_GPL(register_virtio_driver); |
diff --git a/drivers/zorro/zorro-driver.c b/drivers/zorro/zorro-driver.c index 067c07be928c..e6c4390d8bd6 100644 --- a/drivers/zorro/zorro-driver.c +++ b/drivers/zorro/zorro-driver.c | |||
@@ -60,6 +60,20 @@ static int zorro_device_probe(struct device *dev) | |||
60 | } | 60 | } |
61 | 61 | ||
62 | 62 | ||
63 | static int zorro_device_remove(struct device *dev) | ||
64 | { | ||
65 | struct zorro_dev *z = to_zorro_dev(dev); | ||
66 | struct zorro_driver *drv = to_zorro_driver(dev->driver); | ||
67 | |||
68 | if (drv) { | ||
69 | if (drv->remove) | ||
70 | drv->remove(z); | ||
71 | z->driver = NULL; | ||
72 | } | ||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | |||
63 | /** | 77 | /** |
64 | * zorro_register_driver - register a new Zorro driver | 78 | * zorro_register_driver - register a new Zorro driver |
65 | * @drv: the driver structure to register | 79 | * @drv: the driver structure to register |
@@ -128,6 +142,7 @@ struct bus_type zorro_bus_type = { | |||
128 | .name = "zorro", | 142 | .name = "zorro", |
129 | .match = zorro_bus_match, | 143 | .match = zorro_bus_match, |
130 | .probe = zorro_device_probe, | 144 | .probe = zorro_device_probe, |
145 | .remove = zorro_device_remove, | ||
131 | }; | 146 | }; |
132 | 147 | ||
133 | 148 | ||