Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 179651
b: refs/heads/master
c: 361243f
h: refs/heads/master
i:
  179649: a7eb336
  179647: 8978001
v: v3
  • Loading branch information
Len Brown committed Jan 20, 2010
1 parent ec1238d commit c2e19e9
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 64 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d22edd293ff3f1e2d252f164fe2cf744620cb660
refs/heads/master: 361243fd62f22abd6c905f59655e87b062434f71
37 changes: 20 additions & 17 deletions trunk/drivers/acpi/acpi_pad.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static int power_saving_thread(void *data)
* the mechanism only works when all CPUs have RT task running,
* as if one CPU hasn't RT task, RT task from other CPUs will
* borrow CPU time from this CPU and cause RT task use > 95%
* CPU time. To make 'avoid staration' work, takes a nap here.
* CPU time. To make 'avoid starvation' work, takes a nap here.
*/
if (do_sleep)
schedule_timeout_killable(HZ * idle_pct / 100);
Expand All @@ -222,21 +222,26 @@ static struct task_struct *ps_tsks[NR_CPUS];
static unsigned int ps_tsk_num;
static int create_power_saving_task(void)
{
int rc = -ENOMEM;

ps_tsks[ps_tsk_num] = kthread_run(power_saving_thread,
(void *)(unsigned long)ps_tsk_num,
"power_saving/%d", ps_tsk_num);
if (ps_tsks[ps_tsk_num]) {
rc = IS_ERR(ps_tsks[ps_tsk_num]) ? PTR_ERR(ps_tsks[ps_tsk_num]) : 0;
if (!rc)
ps_tsk_num++;
return 0;
}
return -EINVAL;
else
ps_tsks[ps_tsk_num] = NULL;

return rc;
}

static void destroy_power_saving_task(void)
{
if (ps_tsk_num > 0) {
ps_tsk_num--;
kthread_stop(ps_tsks[ps_tsk_num]);
ps_tsks[ps_tsk_num] = NULL;
}
}

Expand All @@ -253,15 +258,14 @@ static void set_power_saving_task_num(unsigned int num)
}
}

static int acpi_pad_idle_cpus(unsigned int num_cpus)
static void acpi_pad_idle_cpus(unsigned int num_cpus)
{
get_online_cpus();

num_cpus = min_t(unsigned int, num_cpus, num_online_cpus());
set_power_saving_task_num(num_cpus);

put_online_cpus();
return 0;
}

static uint32_t acpi_pad_idle_cpus_num(void)
Expand Down Expand Up @@ -369,19 +373,21 @@ static void acpi_pad_remove_sysfs(struct acpi_device *device)
static int acpi_pad_pur(acpi_handle handle, int *num_cpus)
{
struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
acpi_status status;
union acpi_object *package;
int rev, num, ret = -EINVAL;

status = acpi_evaluate_object(handle, "_PUR", NULL, &buffer);
if (ACPI_FAILURE(status))
if (ACPI_FAILURE(acpi_evaluate_object(handle, "_PUR", NULL, &buffer)))
return -EINVAL;

if (!buffer.length || !buffer.pointer)
return -EINVAL;

package = buffer.pointer;
if (package->type != ACPI_TYPE_PACKAGE || package->package.count != 2)
goto out;
rev = package->package.elements[0].integer.value;
num = package->package.elements[1].integer.value;
if (rev != 1)
if (rev != 1 || num < 0)
goto out;
*num_cpus = num;
ret = 0;
Expand Down Expand Up @@ -410,20 +416,17 @@ static void acpi_pad_ost(acpi_handle handle, int stat,

static void acpi_pad_handle_notify(acpi_handle handle)
{
int num_cpus, ret;
int num_cpus;
uint32_t idle_cpus;

mutex_lock(&isolated_cpus_lock);
if (acpi_pad_pur(handle, &num_cpus)) {
mutex_unlock(&isolated_cpus_lock);
return;
}
ret = acpi_pad_idle_cpus(num_cpus);
acpi_pad_idle_cpus(num_cpus);
idle_cpus = acpi_pad_idle_cpus_num();
if (!ret)
acpi_pad_ost(handle, 0, idle_cpus);
else
acpi_pad_ost(handle, 1, 0);
acpi_pad_ost(handle, 0, idle_cpus);
mutex_unlock(&isolated_cpus_lock);
}

Expand Down
122 changes: 77 additions & 45 deletions trunk/drivers/acpi/ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,13 @@ static void advance_transaction(struct acpi_ec *ec, u8 status)
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;
}
Expand Down Expand Up @@ -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 */
Expand All @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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(&copy, 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;
}

Expand Down
43 changes: 43 additions & 0 deletions trunk/drivers/acpi/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ MODULE_LICENSE("GPL");
static int brightness_switch_enabled = 1;
module_param(brightness_switch_enabled, bool, 0644);

/*
* By default, we don't allow duplicate ACPI video bus devices
* under the same VGA controller
*/
static int allow_duplicates;
module_param(allow_duplicates, bool, 0644);

static int register_count = 0;
static int acpi_video_bus_add(struct acpi_device *device);
static int acpi_video_bus_remove(struct acpi_device *device, int type);
Expand Down Expand Up @@ -2239,11 +2246,47 @@ static int acpi_video_resume(struct acpi_device *device)
return AE_OK;
}

static acpi_status
acpi_video_bus_match(acpi_handle handle, u32 level, void *context,
void **return_value)
{
struct acpi_device *device = context;
struct acpi_device *sibling;
int result;

if (handle == device->handle)
return AE_CTRL_TERMINATE;

result = acpi_bus_get_device(handle, &sibling);
if (result)
return AE_OK;

if (!strcmp(acpi_device_name(sibling), ACPI_VIDEO_BUS_NAME))
return AE_ALREADY_EXISTS;

return AE_OK;
}

static int acpi_video_bus_add(struct acpi_device *device)
{
struct acpi_video_bus *video;
struct input_dev *input;
int error;
acpi_status status;

status = acpi_walk_namespace(ACPI_TYPE_DEVICE,
device->parent->handle, 1,
acpi_video_bus_match, NULL,
device, NULL);
if (status == AE_ALREADY_EXISTS) {
printk(KERN_WARNING FW_BUG
"Duplicate ACPI video bus devices for the"
" same VGA controller, please try module "
"parameter \"video.allow_duplicates=1\""
"if the current driver doesn't work.\n");
if (!allow_duplicates)
return -ENODEV;
}

video = kzalloc(sizeof(struct acpi_video_bus), GFP_KERNEL);
if (!video)
Expand Down
2 changes: 1 addition & 1 deletion trunk/include/acpi/platform/aclinux.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit c2e19e9

Please sign in to comment.