Commit 7843932a authored by Alexey Starikovskiy's avatar Alexey Starikovskiy Committed by Len Brown

ACPI: EC: auto select interrupt mode

Start in POLL mode, and if we receive confirmation GPE,
switch to INT mode.
If confirmations are not sent, switch back to POLL.
Signed-off-by: default avatarAlexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent 0c5d31f4
...@@ -586,11 +586,6 @@ and is between 256 and 4096 characters. It is defined in the file ...@@ -586,11 +586,6 @@ and is between 256 and 4096 characters. It is defined in the file
eata= [HW,SCSI] eata= [HW,SCSI]
ec_intr= [HW,ACPI] ACPI Embedded Controller interrupt mode
Format: <int>
0: polling mode
non-0: interrupt mode (default)
edd= [EDD] edd= [EDD]
Format: {"of[f]" | "sk[ipmbr]"} Format: {"of[f]" | "sk[ipmbr]"}
See comment in arch/i386/boot/edd.S See comment in arch/i386/boot/edd.S
......
...@@ -71,14 +71,10 @@ enum ec_event { ...@@ -71,14 +71,10 @@ enum ec_event {
#define ACPI_EC_DELAY 500 /* Wait 500ms max. during EC ops */ #define ACPI_EC_DELAY 500 /* Wait 500ms max. during EC ops */
#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
static enum ec_mode {
EC_INTR = 1, /* Output buffer full */
EC_POLL, /* Input buffer empty */
} acpi_ec_mode = EC_INTR;
enum { enum {
EC_FLAGS_WAIT_GPE = 0, /* Don't check status until GPE arrives */ EC_FLAGS_WAIT_GPE = 0, /* Don't check status until GPE arrives */
EC_FLAGS_QUERY_PENDING, /* Query is pending */ EC_FLAGS_QUERY_PENDING, /* Query is pending */
EC_FLAGS_GPE_MODE, /* Expect GPE to be sent for status change */
}; };
static int acpi_ec_remove(struct acpi_device *device, int type); static int acpi_ec_remove(struct acpi_device *device, int type);
...@@ -169,19 +165,21 @@ static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event) ...@@ -169,19 +165,21 @@ static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event)
static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll) static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll)
{ {
if (unlikely(force_poll) || acpi_ec_mode == EC_POLL) { if (likely(test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) &&
unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); likely(!force_poll)) {
clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
while (time_before(jiffies, delay)) {
if (acpi_ec_check_status(ec, event))
return 0;
}
} else {
if (wait_event_timeout(ec->wait, acpi_ec_check_status(ec, event), if (wait_event_timeout(ec->wait, acpi_ec_check_status(ec, event),
msecs_to_jiffies(ACPI_EC_DELAY))) msecs_to_jiffies(ACPI_EC_DELAY)))
return 0; return 0;
clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
if (acpi_ec_check_status(ec, event)) { if (acpi_ec_check_status(ec, event)) {
clear_bit(EC_FLAGS_GPE_MODE, &ec->flags);
return 0;
}
} else {
unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY);
clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
while (time_before(jiffies, delay)) {
if (acpi_ec_check_status(ec, event))
return 0; return 0;
} }
} }
...@@ -481,18 +479,17 @@ static u32 acpi_ec_gpe_handler(void *data) ...@@ -481,18 +479,17 @@ static u32 acpi_ec_gpe_handler(void *data)
struct acpi_ec *ec = data; struct acpi_ec *ec = data;
clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))
if (acpi_ec_mode == EC_INTR) {
wake_up(&ec->wait); wake_up(&ec->wait);
}
if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_SCI) { if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_SCI) {
if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags))
status = acpi_os_execute(OSL_EC_BURST_HANDLER, status = acpi_os_execute(OSL_EC_BURST_HANDLER,
acpi_ec_gpe_query, ec); acpi_ec_gpe_query, ec);
} } else if (unlikely(!test_bit(EC_FLAGS_GPE_MODE, &ec->flags)))
set_bit(EC_FLAGS_GPE_MODE, &ec->flags);
return status == AE_OK ? return ACPI_SUCCESS(status) ?
ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
} }
...@@ -924,19 +921,3 @@ static void __exit acpi_ec_exit(void) ...@@ -924,19 +921,3 @@ static void __exit acpi_ec_exit(void)
return; return;
} }
#endif /* 0 */ #endif /* 0 */
static int __init acpi_ec_set_intr_mode(char *str)
{
int intr;
if (!get_option(&str, &intr))
return 0;
acpi_ec_mode = (intr) ? EC_INTR : EC_POLL;
printk(KERN_NOTICE PREFIX "%s mode.\n", intr ? "interrupt" : "polling");
return 1;
}
__setup("ec_intr=", acpi_ec_set_intr_mode);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment