Commit b76b51ba authored by Feng Tang's avatar Feng Tang Committed by Rafael J. Wysocki

ACPI / EC: Add more debug info and trivial code cleanup

Add more debug info for EC transaction debugging, like the interrupt
status register value, the detail info of a EC transaction.
Signed-off-by: default avatarFeng Tang <feng.tang@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent f351d027
...@@ -175,30 +175,32 @@ static void start_transaction(struct acpi_ec *ec) ...@@ -175,30 +175,32 @@ static void start_transaction(struct acpi_ec *ec)
static void advance_transaction(struct acpi_ec *ec, u8 status) static void advance_transaction(struct acpi_ec *ec, u8 status)
{ {
unsigned long flags; unsigned long flags;
struct transaction *t = ec->curr;
spin_lock_irqsave(&ec->lock, flags); spin_lock_irqsave(&ec->lock, flags);
if (!ec->curr) if (!t)
goto unlock; goto unlock;
if (ec->curr->wlen > ec->curr->wi) { if (t->wlen > t->wi) {
if ((status & ACPI_EC_FLAG_IBF) == 0) if ((status & ACPI_EC_FLAG_IBF) == 0)
acpi_ec_write_data(ec, acpi_ec_write_data(ec,
ec->curr->wdata[ec->curr->wi++]); t->wdata[t->wi++]);
else else
goto err; goto err;
} else if (ec->curr->rlen > ec->curr->ri) { } else if (t->rlen > t->ri) {
if ((status & ACPI_EC_FLAG_OBF) == 1) { if ((status & ACPI_EC_FLAG_OBF) == 1) {
ec->curr->rdata[ec->curr->ri++] = acpi_ec_read_data(ec); t->rdata[t->ri++] = acpi_ec_read_data(ec);
if (ec->curr->rlen == ec->curr->ri) if (t->rlen == t->ri)
ec->curr->done = true; t->done = true;
} else } else
goto err; goto err;
} else if (ec->curr->wlen == ec->curr->wi && } else if (t->wlen == t->wi &&
(status & ACPI_EC_FLAG_IBF) == 0) (status & ACPI_EC_FLAG_IBF) == 0)
ec->curr->done = true; t->done = true;
goto unlock; goto unlock;
err: err:
/* false interrupt, state didn't change */ /* false interrupt, state didn't change */
if (in_interrupt()) if (in_interrupt())
++ec->curr->irq_count; ++t->irq_count;
unlock: unlock:
spin_unlock_irqrestore(&ec->lock, flags); spin_unlock_irqrestore(&ec->lock, flags);
} }
...@@ -310,7 +312,8 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t) ...@@ -310,7 +312,8 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t)
status = -ETIME; status = -ETIME;
goto end; goto end;
} }
pr_debug(PREFIX "transaction start\n"); pr_debug(PREFIX "transaction start (cmd=0x%02x, addr=0x%02x)\n",
t->command, t->wdata ? t->wdata[0] : 0);
/* disable GPE during transaction if storm is detected */ /* disable GPE during transaction if storm is detected */
if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) { if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) {
/* It has to be disabled, so that it doesn't trigger. */ /* It has to be disabled, so that it doesn't trigger. */
...@@ -326,8 +329,9 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t) ...@@ -326,8 +329,9 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t)
/* It is safe to enable the GPE outside of the transaction. */ /* It is safe to enable the GPE outside of the transaction. */
acpi_enable_gpe(NULL, ec->gpe); acpi_enable_gpe(NULL, ec->gpe);
} else if (t->irq_count > ec_storm_threshold) { } else if (t->irq_count > ec_storm_threshold) {
pr_info(PREFIX "GPE storm detected, " pr_info(PREFIX "GPE storm detected(%d GPEs), "
"transactions will use polling mode\n"); "transactions will use polling mode\n",
t->irq_count);
set_bit(EC_FLAGS_GPE_STORM, &ec->flags); set_bit(EC_FLAGS_GPE_STORM, &ec->flags);
} }
pr_debug(PREFIX "transaction end\n"); pr_debug(PREFIX "transaction end\n");
...@@ -403,7 +407,7 @@ int ec_burst_disable(void) ...@@ -403,7 +407,7 @@ int ec_burst_disable(void)
EXPORT_SYMBOL(ec_burst_disable); EXPORT_SYMBOL(ec_burst_disable);
int ec_read(u8 addr, u8 * val) int ec_read(u8 addr, u8 *val)
{ {
int err; int err;
u8 temp_data; u8 temp_data;
...@@ -622,10 +626,11 @@ static u32 acpi_ec_gpe_handler(acpi_handle gpe_device, ...@@ -622,10 +626,11 @@ static u32 acpi_ec_gpe_handler(acpi_handle gpe_device,
u32 gpe_number, void *data) u32 gpe_number, void *data)
{ {
struct acpi_ec *ec = data; struct acpi_ec *ec = data;
u8 status = acpi_ec_read_status(ec);
pr_debug(PREFIX "~~~> interrupt\n"); pr_debug(PREFIX "~~~> interrupt, status:0x%02x\n", status);
advance_transaction(ec, acpi_ec_read_status(ec)); advance_transaction(ec, status);
if (ec_transaction_done(ec) && if (ec_transaction_done(ec) &&
(acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) == 0) { (acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) == 0) {
wake_up(&ec->wait); wake_up(&ec->wait);
......
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