aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFeng Tang <feng.tang@intel.com>2012-10-22 19:29:38 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2012-11-14 18:15:59 -0500
commitb76b51ba0cef13980813373a548a12206e3cd3c9 (patch)
tree1f28d6cc0a037ee6700c47c1dfa4d51b4780211c
parentf351d027eea545a7996af54fce99f5668a67fec5 (diff)
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: Feng Tang <feng.tang@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/acpi/ec.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 29f349ccf62b..8f8b644bba8d 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -175,30 +175,32 @@ static void start_transaction(struct acpi_ec *ec)
175static void advance_transaction(struct acpi_ec *ec, u8 status) 175static void advance_transaction(struct acpi_ec *ec, u8 status)
176{ 176{
177 unsigned long flags; 177 unsigned long flags;
178 struct transaction *t = ec->curr;
179
178 spin_lock_irqsave(&ec->lock, flags); 180 spin_lock_irqsave(&ec->lock, flags);
179 if (!ec->curr) 181 if (!t)
180 goto unlock; 182 goto unlock;
181 if (ec->curr->wlen > ec->curr->wi) { 183 if (t->wlen > t->wi) {
182 if ((status & ACPI_EC_FLAG_IBF) == 0) 184 if ((status & ACPI_EC_FLAG_IBF) == 0)
183 acpi_ec_write_data(ec, 185 acpi_ec_write_data(ec,
184 ec->curr->wdata[ec->curr->wi++]); 186 t->wdata[t->wi++]);
185 else 187 else
186 goto err; 188 goto err;
187 } else if (ec->curr->rlen > ec->curr->ri) { 189 } else if (t->rlen > t->ri) {
188 if ((status & ACPI_EC_FLAG_OBF) == 1) { 190 if ((status & ACPI_EC_FLAG_OBF) == 1) {
189 ec->curr->rdata[ec->curr->ri++] = acpi_ec_read_data(ec); 191 t->rdata[t->ri++] = acpi_ec_read_data(ec);
190 if (ec->curr->rlen == ec->curr->ri) 192 if (t->rlen == t->ri)
191 ec->curr->done = true; 193 t->done = true;
192 } else 194 } else
193 goto err; 195 goto err;
194 } else if (ec->curr->wlen == ec->curr->wi && 196 } else if (t->wlen == t->wi &&
195 (status & ACPI_EC_FLAG_IBF) == 0) 197 (status & ACPI_EC_FLAG_IBF) == 0)
196 ec->curr->done = true; 198 t->done = true;
197 goto unlock; 199 goto unlock;
198err: 200err:
199 /* false interrupt, state didn't change */ 201 /* false interrupt, state didn't change */
200 if (in_interrupt()) 202 if (in_interrupt())
201 ++ec->curr->irq_count; 203 ++t->irq_count;
202unlock: 204unlock:
203 spin_unlock_irqrestore(&ec->lock, flags); 205 spin_unlock_irqrestore(&ec->lock, flags);
204} 206}
@@ -310,7 +312,8 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t)
310 status = -ETIME; 312 status = -ETIME;
311 goto end; 313 goto end;
312 } 314 }
313 pr_debug(PREFIX "transaction start\n"); 315 pr_debug(PREFIX "transaction start (cmd=0x%02x, addr=0x%02x)\n",
316 t->command, t->wdata ? t->wdata[0] : 0);
314 /* disable GPE during transaction if storm is detected */ 317 /* disable GPE during transaction if storm is detected */
315 if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) { 318 if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) {
316 /* It has to be disabled, so that it doesn't trigger. */ 319 /* 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 /* It is safe to enable the GPE outside of the transaction. */ 329 /* It is safe to enable the GPE outside of the transaction. */
327 acpi_enable_gpe(NULL, ec->gpe); 330 acpi_enable_gpe(NULL, ec->gpe);
328 } else if (t->irq_count > ec_storm_threshold) { 331 } else if (t->irq_count > ec_storm_threshold) {
329 pr_info(PREFIX "GPE storm detected, " 332 pr_info(PREFIX "GPE storm detected(%d GPEs), "
330 "transactions will use polling mode\n"); 333 "transactions will use polling mode\n",
334 t->irq_count);
331 set_bit(EC_FLAGS_GPE_STORM, &ec->flags); 335 set_bit(EC_FLAGS_GPE_STORM, &ec->flags);
332 } 336 }
333 pr_debug(PREFIX "transaction end\n"); 337 pr_debug(PREFIX "transaction end\n");
@@ -403,7 +407,7 @@ int ec_burst_disable(void)
403 407
404EXPORT_SYMBOL(ec_burst_disable); 408EXPORT_SYMBOL(ec_burst_disable);
405 409
406int ec_read(u8 addr, u8 * val) 410int ec_read(u8 addr, u8 *val)
407{ 411{
408 int err; 412 int err;
409 u8 temp_data; 413 u8 temp_data;
@@ -622,10 +626,11 @@ static u32 acpi_ec_gpe_handler(acpi_handle gpe_device,
622 u32 gpe_number, void *data) 626 u32 gpe_number, void *data)
623{ 627{
624 struct acpi_ec *ec = data; 628 struct acpi_ec *ec = data;
629 u8 status = acpi_ec_read_status(ec);
625 630
626 pr_debug(PREFIX "~~~> interrupt\n"); 631 pr_debug(PREFIX "~~~> interrupt, status:0x%02x\n", status);
627 632
628 advance_transaction(ec, acpi_ec_read_status(ec)); 633 advance_transaction(ec, status);
629 if (ec_transaction_done(ec) && 634 if (ec_transaction_done(ec) &&
630 (acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) == 0) { 635 (acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) == 0) {
631 wake_up(&ec->wait); 636 wake_up(&ec->wait);