acpi-test branch contents
Subsystems (4)
Len Brown
reviewerIn addition to the patches on the release branch queued for 2.6.33-rc2, the following patches are also in the acpi-test tree.
Please let me know if you believe they merit inclusion in 2.6.33, modification, or should wait for 2.6.34.
thanks,
Len Brown, Intel Open Source Technology Center
Len Brown
reviewerPATCH 1/6 ACPI: don't cond_resched if irq is disabled
From: Xiaotian Feng <[email protected]>
commit 8bd108d adds preemption point after each opcode parse, then a sleeping function called from invalid context bug was founded during suspend/resume stage. this was fixed in commit abe1dfa by don't cond_resched when irq_disabled. But recent commit 138d156 changes the behaviour to don't cond_resched when in_atomic. This makes the sleeping function called from invalid context bug happen again, which is reported in http://lkml.org/lkml/2009/12/1/371.
This patch also fixes http://bugzilla.kernel.org/show_bug.cgi?id=14483
--- include/acpi/platform/aclinux.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
include/acpi/platform/aclinux.h +1 -1
@@ -152,7 +152,7 @@ static inline void *acpi_os_acquire_object(acpi_cache_t * cache)#include <linux/hardirq.h> #define ACPI_PREEMPTION_POINT () \ do { \ - if (!in_atomic_preempt_off()) \ + if (!in_atomic_preempt_off() && !irqs_disabled()) \ cond_resched(); \ } while (0)
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 2/6 sony-laptop - remove private workqueue, use keventd instead
In reply to Len BrownFrom: Dmitry Torokhov <[email protected]>
If we reschedule work instead of having work function sleep for 10 msecs between reads from kfifo we can safely use the main workqueue (keventd) and not bother with creating driver-private one.
--- drivers/platform/x86/sony-laptop.c | 71 ++++++++++++++++++++---------------- 1 files changed, 39 insertions(+), 32 deletions(-)
drivers/platform/x86/sony-laptop.c +39 -32
@@ -145,7 +145,6 @@ struct sony_laptop_input_s {struct input_dev *key_dev;struct kfifo fifo;spinlock_t fifo_lock; -struct workqueue_struct *wq; };static struct sony_laptop_input_s sony_laptop_input = {
@@ -301,18 +300,28 @@ static int sony_laptop_input_keycode_map[] = {/* release buttons after a short delay if pressed */ static void do_sony_laptop_release_key (struct work_struct *work) { +struct delayed_work *dwork = + container_of(work, struct delayed_work, work);struct sony_laptop_keypress kp; +unsigned long flags; + +spin_lock_irqsave (&sony_laptop_input.fifo_lock, flags); -while (kfifo_out_locked (&sony_laptop_input.fifo, (unsigned char *)&kp, -sizeof (kp), &sony_laptop_input.fifo_lock) - ==sizeof (kp)) { -msleep (10 ); +if (kfifo_out (&sony_laptop_input.fifo, + (unsigned char *)&kp,sizeof (kp)) ==sizeof (kp)) {input_report_key (kp.dev, kp.key,0 );input_sync (kp.dev); } + +/* If there is something in the fifo schedule next release. */ +if (kfifo_len (&sony_laptop_input.fifo) !=0 ) +schedule_delayed_work (dwork,msecs_to_jiffies (10 )); + +spin_unlock_irqrestore (&sony_laptop_input.fifo_lock, flags); } -static DECLARE_WORK(sony_laptop_release_key_work, - do_sony_laptop_release_key); + +static DECLARE_DELAYED_WORK(sony_laptop_release_key_work, + do_sony_laptop_release_key);/* forward event to the input subsystem */ static void sony_laptop_report_input_event (u8 event)
@@ -366,13 +375,13 @@ static void sony_laptop_report_input_event(u8 event)/* we emit the scancode so we can always remap the key */ input_event (kp.dev,EV_MSC ,MSC_SCAN , event);input_sync (kp.dev); -kfifo_in_locked (&sony_laptop_input.fifo, - (unsigned char *)&kp,sizeof (kp), - &sony_laptop_input.fifo_lock); -if (!work_pending (&sony_laptop_release_key_work)) -queue_work (sony_laptop_input.wq, - &sony_laptop_release_key_work); +/* schedule key release */ +kfifo_in_locked (&sony_laptop_input.fifo, + (unsigned char *)&kp,sizeof (kp), + &sony_laptop_input.fifo_lock); +schedule_delayed_work (&sony_laptop_release_key_work, +msecs_to_jiffies (10 )); }else dprintk ("unknown input event %.2x\n" , event); }
@@ -390,27 +399,18 @@ static int sony_laptop_setup_input(struct acpi_device *acpi_device)/* kfifo */ spin_lock_init (&sony_laptop_input.fifo_lock); - error = -kfifo_alloc (&sony_laptop_input.fifo,SONY_LAPTOP_BUF_SIZE ,GFP_KERNEL ); + error =kfifo_alloc (&sony_laptop_input.fifo, +SONY_LAPTOP_BUF_SIZE ,GFP_KERNEL );if (error) { printk(KERN_ERR DRV_PFX "kfifo_alloc failed\n"); goto err_dec_users; } -/* init workqueue */ - sony_laptop_input.wq =create_singlethread_workqueue ("sony-laptop" ); -if (!sony_laptop_input.wq) { - printk(KERN_ERR DRV_PFX - "Unable to create workqueue.\n"); - error = -ENXIO ; - goto err_free_kfifo; - } -/* input keys */ key_dev =input_allocate_device ();if (!key_dev) { error = -ENOMEM ; - goto err_destroy_wq; + goto err_free_kfifo; } key_dev->name ="Sony Vaio Keys" ;
@@ -473,9 +473,6 @@ err_unregister_keydev: err_free_keydev:input_free_device (key_dev); -err_destroy_wq: -destroy_workqueue (sony_laptop_input.wq); - err_free_kfifo:kfifo_free (&sony_laptop_input.fifo);
@@ -486,12 +483,23 @@ err_dec_users:static void sony_laptop_remove_input (void ) { -/* cleanup only after the last user has gone */ +struct sony_laptop_keypress kp = {NULL }; + +/* Cleanup only after the last user has gone */ if (!atomic_dec_and_test (&sony_laptop_input.users))return ; -/* flush workqueue first */ -flush_workqueue (sony_laptop_input.wq); +cancel_delayed_work_sync (&sony_laptop_release_key_work); + +/* +* Generate key-up events for remaining keys. Note that we don't +* need locking since nobody is adding new events to the kfifo. +*/ +while (kfifo_out (&sony_laptop_input.fifo, + (unsigned char *)&kp,sizeof (kp)) ==sizeof (kp)) { +input_report_key (kp.dev, kp.key,0 ); +input_sync (kp.dev); + }/* destroy input devs */ input_unregister_device (sony_laptop_input.key_dev);
@@ -502,7 +510,6 @@ static void sony_laptop_remove_input(void) sony_laptop_input.jog_dev =NULL ; } -destroy_workqueue (sony_laptop_input.wq);kfifo_free (&sony_laptop_input.fifo); }
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 3/6 sony-laptop - simplify keymap initialization
In reply to Len BrownFrom: Dmitry Torokhov <[email protected]>
Also use input_set_capability() helper instead of manipulating bits directly.
--- drivers/platform/x86/sony-laptop.c | 20 ++++++++------------ 1 files changed, 8 insertions(+), 12 deletions(-)
drivers/platform/x86/sony-laptop.c +8 -12
@@ -419,18 +419,15 @@ static int sony_laptop_setup_input(struct acpi_device *acpi_device) key_dev->dev.parent = &acpi_device->dev;/* Initialize the Input Drivers: special keys */ -set_bit (EV_KEY , key_dev->evbit); -set_bit (EV_MSC , key_dev->evbit); -set_bit (MSC_SCAN , key_dev->mscbit); +input_set_capability (key_dev,EV_MSC ,MSC_SCAN ); + +__set_bit (EV_KEY , key_dev->evbit); key_dev->keycodesize =sizeof (sony_laptop_input_keycode_map[0 ]); key_dev->keycodemax =ARRAY_SIZE (sony_laptop_input_keycode_map); key_dev->keycode = &sony_laptop_input_keycode_map; -for (i =0 ; i <ARRAY_SIZE (sony_laptop_input_keycode_map); i++) { -if (sony_laptop_input_keycode_map[i] !=KEY_RESERVED ) { -set_bit (sony_laptop_input_keycode_map[i], - key_dev->keybit); - } - } +for (i =0 ; i <ARRAY_SIZE (sony_laptop_input_keycode_map); i++) +__set_bit (sony_laptop_input_keycode_map[i], key_dev->keybit); +__clear_bit (KEY_RESERVED , key_dev->keybit); error =input_register_device (key_dev);if (error)
@@ -450,9 +447,8 @@ static int sony_laptop_setup_input(struct acpi_device *acpi_device) jog_dev->id.vendor =PCI_VENDOR_ID_SONY ; key_dev->dev.parent = &acpi_device->dev; - jog_dev->evbit[0 ] =BIT_MASK (EV_KEY ) |BIT_MASK (EV_REL ); - jog_dev->keybit[BIT_WORD (BTN_MOUSE )] =BIT_MASK (BTN_MIDDLE ); - jog_dev->relbit[0 ] =BIT_MASK (REL_WHEEL ); +input_set_capability (jog_dev,EV_KEY ,BTN_MIDDLE ); +input_set_capability (jog_dev,EV_REL ,REL_WHEEL ); error =input_register_device (jog_dev);if (error)
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 4/6 sony-laptop - switch from workqueue to a timer
In reply to Len BrownFrom: Dmitry Torokhov <[email protected]>
The function that is executing in workqueue context does not need to sleep so let's switch to a timer which is more lightweight.
--- drivers/platform/x86/sony-laptop.c | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-)
drivers/platform/x86/sony-laptop.c +10 -10
@@ -145,6 +145,7 @@ struct sony_laptop_input_s {struct input_dev *key_dev;struct kfifo fifo;spinlock_t fifo_lock; +struct timer_list release_key_timer; };static struct sony_laptop_input_s sony_laptop_input = {
@@ -298,10 +299,8 @@ static int sony_laptop_input_keycode_map[] = { };/* release buttons after a short delay if pressed */ -static void do_sony_laptop_release_key (struct work_struct *work) +static void do_sony_laptop_release_key (unsigned long unused) { -struct delayed_work *dwork = - container_of(work, struct delayed_work, work);struct sony_laptop_keypress kp;unsigned long flags;
@@ -315,14 +314,12 @@ static void do_sony_laptop_release_key(struct work_struct *work)/* If there is something in the fifo schedule next release. */ if (kfifo_len (&sony_laptop_input.fifo) !=0 ) -schedule_delayed_work (dwork,msecs_to_jiffies (10 )); +mod_timer (&sony_laptop_input.release_key_timer, + jiffies +msecs_to_jiffies (10 ));spin_unlock_irqrestore (&sony_laptop_input.fifo_lock, flags); } -static DECLARE_DELAYED_WORK(sony_laptop_release_key_work, - do_sony_laptop_release_key); -/* forward event to the input subsystem */ static void sony_laptop_report_input_event (u8 event) {
@@ -380,8 +377,8 @@ static void sony_laptop_report_input_event(u8 event)kfifo_in_locked (&sony_laptop_input.fifo, (unsigned char *)&kp,sizeof (kp), &sony_laptop_input.fifo_lock); -schedule_delayed_work (&sony_laptop_release_key_work, -msecs_to_jiffies (10 )); +mod_timer (&sony_laptop_input.release_key_timer, + jiffies +msecs_to_jiffies (10 )); }else dprintk ("unknown input event %.2x\n" , event); }
@@ -406,6 +403,9 @@ static int sony_laptop_setup_input(struct acpi_device *acpi_device) goto err_dec_users; } +setup_timer (&sony_laptop_input.release_key_timer, + do_sony_laptop_release_key,0 ); +/* input keys */ key_dev =input_allocate_device ();if (!key_dev) {
@@ -485,7 +485,7 @@ static void sony_laptop_remove_input(void)if (!atomic_dec_and_test (&sony_laptop_input.users))return ; -cancel_delayed_work_sync (&sony_laptop_release_key_work); +del_timer_sync (&sony_laptop_input.release_key_timer);/* * Generate key-up events for remaining keys. Note that we don't
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 5/6 ACPI: EC: Accelerate query execution
In reply to Len BrownFrom: Alexey Starikovskiy <[email protected]>
Split EC query handling into acknowledge and execution phase. This allows much smaller pending query lattency and lowers chances of EC going "wild" and losing events.
Reference: http://bugzilla.kernel.org/show_bug.cgi?id=14858
--- drivers/acpi/ec.c | 122 +++++++++++++++++++++++++++++++++------------------- 1 files changed, 77 insertions(+), 45 deletions(-)
drivers/acpi/ec.c +77 -45
@@ -201,14 +201,13 @@ unlock:spin_unlock_irqrestore (&ec->curr_lock, flags); } -static void acpi_ec_gpe_query (void *ec_cxt); +static int acpi_ec_sync_query (struct acpi_ec *ec); -static int ec_check_sci (struct acpi_ec *ec,u8 state) +static int ec_check_sci_sync (struct acpi_ec *ec,u8 state) {if (state &ACPI_EC_FLAG_SCI ) {if (!test_and_set_bit (EC_FLAGS_QUERY_PENDING , &ec->flags)) -return acpi_os_execute (OSL_EC_BURST_HANDLER , - acpi_ec_gpe_query, ec); +return acpi_ec_sync_query (ec); }return 0 ; }
@@ -249,11 +248,6 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, {unsigned long tmp;int ret =0 ; -pr_debug (PREFIX "transaction start\n" ); -/* disable GPE during transaction if storm is detected */ -if (test_bit (EC_FLAGS_GPE_STORM , &ec->flags)) { -acpi_disable_gpe (NULL , ec->gpe); - }if (EC_FLAGS_MSI )udelay (ACPI_EC_MSI_UDELAY );/* start transaction */
@@ -269,16 +263,6 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec,spin_lock_irqsave (&ec->curr_lock, tmp); ec->curr =NULL ;spin_unlock_irqrestore (&ec->curr_lock, tmp); -if (test_bit (EC_FLAGS_GPE_STORM , &ec->flags)) { -/* check if we received SCI during transaction */ -ec_check_sci (ec,acpi_ec_read_status (ec)); -/* it is safe to enable GPE outside of transaction */ -acpi_enable_gpe (NULL , ec->gpe); - }else if (t->irq_count >ACPI_EC_STORM_THRESHOLD ) { -pr_info (PREFIX "GPE storm detected, " -"transactions will use polling mode\n" ); -set_bit (EC_FLAGS_GPE_STORM , &ec->flags); - }return ret; }
@@ -321,7 +305,24 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t) status = -ETIME ; goto end; } +pr_debug (PREFIX "transaction start\n" ); +/* disable GPE during transaction if storm is detected */ +if (test_bit (EC_FLAGS_GPE_STORM , &ec->flags)) { +acpi_disable_gpe (NULL , ec->gpe); + } + status =acpi_ec_transaction_unlocked (ec, t); + +/* check if we received SCI during transaction */ +ec_check_sci_sync (ec,acpi_ec_read_status (ec)); +if (test_bit (EC_FLAGS_GPE_STORM , &ec->flags)) { +/* it is safe to enable GPE outside of transaction */ +acpi_enable_gpe (NULL , ec->gpe); + }else if (t->irq_count >ACPI_EC_STORM_THRESHOLD ) { +pr_info (PREFIX "GPE storm detected, " +"transactions will use polling mode\n" ); +set_bit (EC_FLAGS_GPE_STORM , &ec->flags); + } end:if (ec->global_lock)acpi_release_global_lock (glk);
@@ -443,7 +444,7 @@ int ec_transaction(u8 command,EXPORT_SYMBOL (ec_transaction); -static int acpi_ec_query (struct acpi_ec *ec,u8 * data) +static int acpi_ec_query_unlocked (struct acpi_ec *ec,u8 * data) {int result;u8 d;
@@ -452,20 +453,16 @@ static int acpi_ec_query(struct acpi_ec *ec, u8 * data) .wlen = 0, .rlen = 1};if (!ec || !data)return -EINVAL ; -/* * Query the EC to find out which _Qxx method we need to evaluate. * Note that successful completion of the query causes the ACPI_EC_SCI * bit to be cleared (and thus clearing the interrupt source). */ - - result =acpi_ec_transaction (ec, &t); + result =acpi_ec_transaction_unlocked (ec, &t);if (result)return result; -if (!d)return -ENODATA ; - *data = d;return 0 ; }
@@ -509,43 +506,78 @@ void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit)EXPORT_SYMBOL_GPL (acpi_ec_remove_query_handler); -static void acpi_ec_gpe_query (void *ec_cxt) +static void acpi_ec_run (void *cxt) { -struct acpi_ec *ec = ec_cxt; -u8 value =0 ; -struct acpi_ec_query_handler *handler, copy; - -if (!ec ||acpi_ec_query (ec, &value)) +struct acpi_ec_query_handler *handler = cxt; +if (!handler)return ; -mutex_lock (&ec->lock); +pr_debug (PREFIX "start query execution\n" ); +if (handler->func) + handler->func (handler->data); +else if (handler->handle) +acpi_evaluate_object (handler->handle,NULL ,NULL ,NULL ); +pr_debug (PREFIX "stop query execution\n" ); +kfree (handler); +} + +static int acpi_ec_sync_query (struct acpi_ec *ec) +{ +u8 value =0 ; +int status; +struct acpi_ec_query_handler *handler, *copy; +if ((status =acpi_ec_query_unlocked (ec, &value))) +return status;list_for_each_entry (handler, &ec->list, node) {if (value == handler->query_bit) {/* have custom handler for this bit */ -memcpy (©, handler,sizeof (copy)); -mutex_unlock (&ec->lock); -if (copy.func) { - copy.func (copy.data); - }else if (copy.handle) { -acpi_evaluate_object (copy.handle,NULL ,NULL ,NULL ); - } -return ; + copy =kmalloc (sizeof (*handler),GFP_KERNEL ); +if (!copy) +return -ENOMEM ; +memcpy (copy, handler,sizeof (*copy)); +pr_debug (PREFIX "push query execution (0x%2x) on queue\n" , value); +return acpi_os_execute (OSL_GPE_HANDLER , + acpi_ec_run, copy); } } +return 0 ; +} + +static void acpi_ec_gpe_query (void *ec_cxt) +{ +struct acpi_ec *ec = ec_cxt; +if (!ec) +return ; +mutex_lock (&ec->lock); +acpi_ec_sync_query (ec);mutex_unlock (&ec->lock); } +static void acpi_ec_gpe_query (void *ec_cxt); + +static int ec_check_sci (struct acpi_ec *ec,u8 state) +{ +if (state &ACPI_EC_FLAG_SCI ) { +if (!test_and_set_bit (EC_FLAGS_QUERY_PENDING , &ec->flags)) { +pr_debug (PREFIX "push gpe query to the queue\n" ); +return acpi_os_execute (OSL_NOTIFY_HANDLER , + acpi_ec_gpe_query, ec); + } + } +return 0 ; +} +static u32 acpi_ec_gpe_handler (void *data) {struct acpi_ec *ec = data; -u8 status;pr_debug (PREFIX "~~~> interrupt\n" ); - status =acpi_ec_read_status (ec); -advance_transaction (ec, status); -if (ec_transaction_done (ec) && (status &ACPI_EC_FLAG_IBF ) ==0 ) +advance_transaction (ec,acpi_ec_read_status (ec)); +if (ec_transaction_done (ec) && + (acpi_ec_read_status (ec) &ACPI_EC_FLAG_IBF ) ==0 ) {wake_up (&ec->wait); -ec_check_sci (ec, status); +ec_check_sci (ec,acpi_ec_read_status (ec)); + }return ACPI_INTERRUPT_HANDLED ; }
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 6/6 ACPI: Disable explicit power state retrieval on fans
In reply to Len BrownFrom: Zhang Rui <[email protected]>
If the ACPI power state can be got both directly and indirectly, we prefer to get it indirectly.
https://bugzilla.redhat.com/show_bug.cgi?id=531916 describes a system with a _PSC method for the fan that always returns "on". There's no benefit in us always requesting the state of the fan when performing transitions - we want to do everything we can to ensure that the fan turns on when it should do, not risk hardware damage by believing the hardware when it tells us the fan is already on. Given that the Leading Other OS(tm) works fine on this machine, it seems likely that it behaves in much this way.
--- drivers/acpi/bus.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/acpi/bus.c +5 -5
@@ -190,16 +190,16 @@ int acpi_bus_get_power(acpi_handle handle, int *state)* Get the device's power state either directly (via _PSC) or * indirectly (via power resources). */ -if (device->power.flags.explicit_get) { +if (device->power.flags.power_resources) { + result =acpi_power_get_inferred_state (device); +if (result) +return result; + }else if (device->power.flags.explicit_get) { status =acpi_evaluate_integer (device->handle,"_PSC" ,NULL , &psc);if (ACPI_FAILURE (status))return -ENODEV ; device->power.state = (int )psc; - }else if (device->power.flags.power_resources) { - result =acpi_power_get_inferred_state (device); -if (result) -return result; } *state = device->power.state;
Signature · 1 line
1.6.0.6