mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 12:11:40 +00:00
platform/chrome: cros_ec_lpc: Separate host command and irq disable
Both cros host command and irq disable were moved to suspend
prepare stage from late suspend recently. This is causing EC
to report MKBP event timeouts during suspend stress testing.
When the MKBP event timeouts happen during suspend, subsequent
wakeup of AP by EC using MKBP doesn't happen properly. Move the
irq disabling part back to late suspend stage which is a general
suggestion from the suspend kernel documentaiton to do irq
disable as late as possible.
Fixes: 4b9abbc132
("platform/chrome: cros_ec_lpc: Move host command to prepare/complete")
Signed-off-by: Lalith Rajendran <lalithkraj@chromium.org>
Link: https://lore.kernel.org/r/20231027160221.v4.1.I1725c3ed27eb7cd9836904e49e8bfa9fb0200a97@changeid
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
This commit is contained in:
parent
466f70fb1b
commit
47ea0ddb1f
@ -321,17 +321,8 @@ void cros_ec_unregister(struct cros_ec_device *ec_dev)
|
||||
EXPORT_SYMBOL(cros_ec_unregister);
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
/**
|
||||
* cros_ec_suspend() - Handle a suspend operation for the ChromeOS EC device.
|
||||
* @ec_dev: Device to suspend.
|
||||
*
|
||||
* This can be called by drivers to handle a suspend event.
|
||||
*
|
||||
* Return: 0 on success or negative error code.
|
||||
*/
|
||||
int cros_ec_suspend(struct cros_ec_device *ec_dev)
|
||||
static void cros_ec_send_suspend_event(struct cros_ec_device *ec_dev)
|
||||
{
|
||||
struct device *dev = ec_dev->dev;
|
||||
int ret;
|
||||
u8 sleep_event;
|
||||
|
||||
@ -343,7 +334,26 @@ int cros_ec_suspend(struct cros_ec_device *ec_dev)
|
||||
if (ret < 0)
|
||||
dev_dbg(ec_dev->dev, "Error %d sending suspend event to ec\n",
|
||||
ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* cros_ec_suspend_prepare() - Handle a suspend prepare operation for the ChromeOS EC device.
|
||||
* @ec_dev: Device to suspend.
|
||||
*
|
||||
* This can be called by drivers to handle a suspend prepare stage of suspend.
|
||||
*
|
||||
* Return: 0 always.
|
||||
*/
|
||||
int cros_ec_suspend_prepare(struct cros_ec_device *ec_dev)
|
||||
{
|
||||
cros_ec_send_suspend_event(ec_dev);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(cros_ec_suspend_prepare);
|
||||
|
||||
static void cros_ec_disable_irq(struct cros_ec_device *ec_dev)
|
||||
{
|
||||
struct device *dev = ec_dev->dev;
|
||||
if (device_may_wakeup(dev))
|
||||
ec_dev->wake_enabled = !enable_irq_wake(ec_dev->irq);
|
||||
else
|
||||
@ -351,7 +361,35 @@ int cros_ec_suspend(struct cros_ec_device *ec_dev)
|
||||
|
||||
disable_irq(ec_dev->irq);
|
||||
ec_dev->suspended = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* cros_ec_suspend_late() - Handle a suspend late operation for the ChromeOS EC device.
|
||||
* @ec_dev: Device to suspend.
|
||||
*
|
||||
* This can be called by drivers to handle a suspend late stage of suspend.
|
||||
*
|
||||
* Return: 0 always.
|
||||
*/
|
||||
int cros_ec_suspend_late(struct cros_ec_device *ec_dev)
|
||||
{
|
||||
cros_ec_disable_irq(ec_dev);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(cros_ec_suspend_late);
|
||||
|
||||
/**
|
||||
* cros_ec_suspend() - Handle a suspend operation for the ChromeOS EC device.
|
||||
* @ec_dev: Device to suspend.
|
||||
*
|
||||
* This can be called by drivers to handle a suspend event.
|
||||
*
|
||||
* Return: 0 always.
|
||||
*/
|
||||
int cros_ec_suspend(struct cros_ec_device *ec_dev)
|
||||
{
|
||||
cros_ec_send_suspend_event(ec_dev);
|
||||
cros_ec_disable_irq(ec_dev);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(cros_ec_suspend);
|
||||
@ -370,22 +408,11 @@ static void cros_ec_report_events_during_suspend(struct cros_ec_device *ec_dev)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* cros_ec_resume() - Handle a resume operation for the ChromeOS EC device.
|
||||
* @ec_dev: Device to resume.
|
||||
*
|
||||
* This can be called by drivers to handle a resume event.
|
||||
*
|
||||
* Return: 0 on success or negative error code.
|
||||
*/
|
||||
int cros_ec_resume(struct cros_ec_device *ec_dev)
|
||||
static void cros_ec_send_resume_event(struct cros_ec_device *ec_dev)
|
||||
{
|
||||
int ret;
|
||||
u8 sleep_event;
|
||||
|
||||
ec_dev->suspended = false;
|
||||
enable_irq(ec_dev->irq);
|
||||
|
||||
sleep_event = (!IS_ENABLED(CONFIG_ACPI) || pm_suspend_via_firmware()) ?
|
||||
HOST_SLEEP_EVENT_S3_RESUME :
|
||||
HOST_SLEEP_EVENT_S0IX_RESUME;
|
||||
@ -394,6 +421,24 @@ int cros_ec_resume(struct cros_ec_device *ec_dev)
|
||||
if (ret < 0)
|
||||
dev_dbg(ec_dev->dev, "Error %d sending resume event to ec\n",
|
||||
ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* cros_ec_resume_complete() - Handle a resume complete operation for the ChromeOS EC device.
|
||||
* @ec_dev: Device to resume.
|
||||
*
|
||||
* This can be called by drivers to handle a resume complete stage of resume.
|
||||
*/
|
||||
void cros_ec_resume_complete(struct cros_ec_device *ec_dev)
|
||||
{
|
||||
cros_ec_send_resume_event(ec_dev);
|
||||
}
|
||||
EXPORT_SYMBOL(cros_ec_resume_complete);
|
||||
|
||||
static void cros_ec_enable_irq(struct cros_ec_device *ec_dev)
|
||||
{
|
||||
ec_dev->suspended = false;
|
||||
enable_irq(ec_dev->irq);
|
||||
|
||||
if (ec_dev->wake_enabled)
|
||||
disable_irq_wake(ec_dev->irq);
|
||||
@ -403,8 +448,35 @@ int cros_ec_resume(struct cros_ec_device *ec_dev)
|
||||
* suspend. This way the clients know what to do with them.
|
||||
*/
|
||||
cros_ec_report_events_during_suspend(ec_dev);
|
||||
}
|
||||
|
||||
/**
|
||||
* cros_ec_resume_early() - Handle a resume early operation for the ChromeOS EC device.
|
||||
* @ec_dev: Device to resume.
|
||||
*
|
||||
* This can be called by drivers to handle a resume early stage of resume.
|
||||
*
|
||||
* Return: 0 always.
|
||||
*/
|
||||
int cros_ec_resume_early(struct cros_ec_device *ec_dev)
|
||||
{
|
||||
cros_ec_enable_irq(ec_dev);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(cros_ec_resume_early);
|
||||
|
||||
/**
|
||||
* cros_ec_resume() - Handle a resume operation for the ChromeOS EC device.
|
||||
* @ec_dev: Device to resume.
|
||||
*
|
||||
* This can be called by drivers to handle a resume event.
|
||||
*
|
||||
* Return: 0 always.
|
||||
*/
|
||||
int cros_ec_resume(struct cros_ec_device *ec_dev)
|
||||
{
|
||||
cros_ec_enable_irq(ec_dev);
|
||||
cros_ec_send_resume_event(ec_dev);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(cros_ec_resume);
|
||||
|
@ -16,7 +16,11 @@ int cros_ec_register(struct cros_ec_device *ec_dev);
|
||||
void cros_ec_unregister(struct cros_ec_device *ec_dev);
|
||||
|
||||
int cros_ec_suspend(struct cros_ec_device *ec_dev);
|
||||
int cros_ec_suspend_late(struct cros_ec_device *ec_dev);
|
||||
int cros_ec_suspend_prepare(struct cros_ec_device *ec_dev);
|
||||
int cros_ec_resume(struct cros_ec_device *ec_dev);
|
||||
int cros_ec_resume_early(struct cros_ec_device *ec_dev);
|
||||
void cros_ec_resume_complete(struct cros_ec_device *ec_dev);
|
||||
|
||||
irqreturn_t cros_ec_irq_thread(int irq, void *data);
|
||||
|
||||
|
@ -547,22 +547,36 @@ MODULE_DEVICE_TABLE(dmi, cros_ec_lpc_dmi_table);
|
||||
static int cros_ec_lpc_prepare(struct device *dev)
|
||||
{
|
||||
struct cros_ec_device *ec_dev = dev_get_drvdata(dev);
|
||||
|
||||
return cros_ec_suspend(ec_dev);
|
||||
return cros_ec_suspend_prepare(ec_dev);
|
||||
}
|
||||
|
||||
static void cros_ec_lpc_complete(struct device *dev)
|
||||
{
|
||||
struct cros_ec_device *ec_dev = dev_get_drvdata(dev);
|
||||
cros_ec_resume(ec_dev);
|
||||
cros_ec_resume_complete(ec_dev);
|
||||
}
|
||||
|
||||
static int cros_ec_lpc_suspend_late(struct device *dev)
|
||||
{
|
||||
struct cros_ec_device *ec_dev = dev_get_drvdata(dev);
|
||||
|
||||
return cros_ec_suspend_late(ec_dev);
|
||||
}
|
||||
|
||||
static int cros_ec_lpc_resume_early(struct device *dev)
|
||||
{
|
||||
struct cros_ec_device *ec_dev = dev_get_drvdata(dev);
|
||||
|
||||
return cros_ec_resume_early(ec_dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
static const struct dev_pm_ops cros_ec_lpc_pm_ops = {
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
.prepare = cros_ec_lpc_prepare,
|
||||
.complete = cros_ec_lpc_complete
|
||||
.complete = cros_ec_lpc_complete,
|
||||
#endif
|
||||
SET_LATE_SYSTEM_SLEEP_PM_OPS(cros_ec_lpc_suspend_late, cros_ec_lpc_resume_early)
|
||||
};
|
||||
|
||||
static struct platform_driver cros_ec_lpc_driver = {
|
||||
|
Loading…
Reference in New Issue
Block a user