提交 dd15f8c4 编写于 作者: A Alexey Starikovskiy 提交者: Len Brown

ACPI: EC: wait for last write gpe

There is a possibility that EC might break if next command is
issued within 1 us after write or burst-disable command.
Suggestd-by: NZhao Yakui <yakui.zhao@intel.com>
Signed-off-by: NAlexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: NLen Brown <len.brown@intel.com>
上级 f8248434
...@@ -102,6 +102,7 @@ struct transaction { ...@@ -102,6 +102,7 @@ struct transaction {
u8 command; u8 command;
u8 wlen; u8 wlen;
u8 rlen; u8 rlen;
bool done;
}; };
static struct acpi_ec { static struct acpi_ec {
...@@ -178,7 +179,7 @@ static int ec_transaction_done(struct acpi_ec *ec) ...@@ -178,7 +179,7 @@ static int ec_transaction_done(struct acpi_ec *ec)
unsigned long flags; unsigned long flags;
int ret = 0; int ret = 0;
spin_lock_irqsave(&ec->curr_lock, flags); spin_lock_irqsave(&ec->curr_lock, flags);
if (!ec->curr || (!ec->curr->wlen && !ec->curr->rlen)) if (!ec->curr || ec->curr->done)
ret = 1; ret = 1;
spin_unlock_irqrestore(&ec->curr_lock, flags); spin_unlock_irqrestore(&ec->curr_lock, flags);
return ret; return ret;
...@@ -195,17 +196,20 @@ static void gpe_transaction(struct acpi_ec *ec, u8 status) ...@@ -195,17 +196,20 @@ static void gpe_transaction(struct acpi_ec *ec, u8 status)
acpi_ec_write_data(ec, *(ec->curr->wdata++)); acpi_ec_write_data(ec, *(ec->curr->wdata++));
--ec->curr->wlen; --ec->curr->wlen;
} else } else
/* false interrupt, state didn't change */ goto err;
++ec->curr->irq_count;
} else if (ec->curr->rlen > 0) { } else if (ec->curr->rlen > 0) {
if ((status & ACPI_EC_FLAG_OBF) == 1) { if ((status & ACPI_EC_FLAG_OBF) == 1) {
*(ec->curr->rdata++) = acpi_ec_read_data(ec); *(ec->curr->rdata++) = acpi_ec_read_data(ec);
--ec->curr->rlen; if (--ec->curr->rlen == 0)
ec->curr->done = true;
} else } else
goto err;
} else if (ec->curr->wlen == 0 && (status & ACPI_EC_FLAG_IBF) == 0)
ec->curr->done = true;
goto unlock;
err:
/* false interrupt, state didn't change */ /* false interrupt, state didn't change */
++ec->curr->irq_count; ++ec->curr->irq_count;
}
unlock: unlock:
spin_unlock_irqrestore(&ec->curr_lock, flags); spin_unlock_irqrestore(&ec->curr_lock, flags);
} }
...@@ -265,6 +269,7 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, ...@@ -265,6 +269,7 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec,
spin_lock_irqsave(&ec->curr_lock, tmp); spin_lock_irqsave(&ec->curr_lock, tmp);
/* following two actions should be kept atomic */ /* following two actions should be kept atomic */
t->irq_count = 0; t->irq_count = 0;
t->done = false;
ec->curr = t; ec->curr = t;
acpi_ec_write_cmd(ec, ec->curr->command); acpi_ec_write_cmd(ec, ec->curr->command);
if (ec->curr->command == ACPI_EC_COMMAND_QUERY) if (ec->curr->command == ACPI_EC_COMMAND_QUERY)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册