Commit 3d2699bc authored by Liu, Chuansheng's avatar Liu, Chuansheng Committed by Rafael J. Wysocki

PM / sleep: Two flags for async suspend_noirq and suspend_late

The patch is a helper adding two new flags for implementing
async threads for suspend_noirq and suspend_late.
Signed-off-by: default avatarChuansheng Liu <chuansheng.liu@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 6d0abeca
...@@ -91,6 +91,8 @@ void device_pm_sleep_init(struct device *dev) ...@@ -91,6 +91,8 @@ void device_pm_sleep_init(struct device *dev)
{ {
dev->power.is_prepared = false; dev->power.is_prepared = false;
dev->power.is_suspended = false; dev->power.is_suspended = false;
dev->power.is_noirq_suspended = false;
dev->power.is_late_suspended = false;
init_completion(&dev->power.completion); init_completion(&dev->power.completion);
complete_all(&dev->power.completion); complete_all(&dev->power.completion);
dev->power.wakeup = NULL; dev->power.wakeup = NULL;
...@@ -479,6 +481,9 @@ static int device_resume_noirq(struct device *dev, pm_message_t state) ...@@ -479,6 +481,9 @@ static int device_resume_noirq(struct device *dev, pm_message_t state)
if (dev->power.syscore) if (dev->power.syscore)
goto Out; goto Out;
if (!dev->power.is_noirq_suspended)
goto Out;
if (dev->pm_domain) { if (dev->pm_domain) {
info = "noirq power domain "; info = "noirq power domain ";
callback = pm_noirq_op(&dev->pm_domain->ops, state); callback = pm_noirq_op(&dev->pm_domain->ops, state);
...@@ -499,6 +504,7 @@ static int device_resume_noirq(struct device *dev, pm_message_t state) ...@@ -499,6 +504,7 @@ static int device_resume_noirq(struct device *dev, pm_message_t state)
} }
error = dpm_run_callback(callback, dev, state, info); error = dpm_run_callback(callback, dev, state, info);
dev->power.is_noirq_suspended = false;
Out: Out:
TRACE_RESUME(error); TRACE_RESUME(error);
...@@ -561,6 +567,9 @@ static int device_resume_early(struct device *dev, pm_message_t state) ...@@ -561,6 +567,9 @@ static int device_resume_early(struct device *dev, pm_message_t state)
if (dev->power.syscore) if (dev->power.syscore)
goto Out; goto Out;
if (!dev->power.is_late_suspended)
goto Out;
if (dev->pm_domain) { if (dev->pm_domain) {
info = "early power domain "; info = "early power domain ";
callback = pm_late_early_op(&dev->pm_domain->ops, state); callback = pm_late_early_op(&dev->pm_domain->ops, state);
...@@ -581,6 +590,7 @@ static int device_resume_early(struct device *dev, pm_message_t state) ...@@ -581,6 +590,7 @@ static int device_resume_early(struct device *dev, pm_message_t state)
} }
error = dpm_run_callback(callback, dev, state, info); error = dpm_run_callback(callback, dev, state, info);
dev->power.is_late_suspended = false;
Out: Out:
TRACE_RESUME(error); TRACE_RESUME(error);
...@@ -917,6 +927,7 @@ static int device_suspend_noirq(struct device *dev, pm_message_t state) ...@@ -917,6 +927,7 @@ static int device_suspend_noirq(struct device *dev, pm_message_t state)
{ {
pm_callback_t callback = NULL; pm_callback_t callback = NULL;
char *info = NULL; char *info = NULL;
int error;
if (dev->power.syscore) if (dev->power.syscore)
return 0; return 0;
...@@ -940,7 +951,11 @@ static int device_suspend_noirq(struct device *dev, pm_message_t state) ...@@ -940,7 +951,11 @@ static int device_suspend_noirq(struct device *dev, pm_message_t state)
callback = pm_noirq_op(dev->driver->pm, state); callback = pm_noirq_op(dev->driver->pm, state);
} }
return dpm_run_callback(callback, dev, state, info); error = dpm_run_callback(callback, dev, state, info);
if (!error)
dev->power.is_noirq_suspended = true;
return error;
} }
/** /**
...@@ -1003,6 +1018,7 @@ static int device_suspend_late(struct device *dev, pm_message_t state) ...@@ -1003,6 +1018,7 @@ static int device_suspend_late(struct device *dev, pm_message_t state)
{ {
pm_callback_t callback = NULL; pm_callback_t callback = NULL;
char *info = NULL; char *info = NULL;
int error;
__pm_runtime_disable(dev, false); __pm_runtime_disable(dev, false);
...@@ -1028,7 +1044,11 @@ static int device_suspend_late(struct device *dev, pm_message_t state) ...@@ -1028,7 +1044,11 @@ static int device_suspend_late(struct device *dev, pm_message_t state)
callback = pm_late_early_op(dev->driver->pm, state); callback = pm_late_early_op(dev->driver->pm, state);
} }
return dpm_run_callback(callback, dev, state, info); error = dpm_run_callback(callback, dev, state, info);
if (!error)
dev->power.is_late_suspended = true;
return error;
} }
/** /**
......
...@@ -542,6 +542,8 @@ struct dev_pm_info { ...@@ -542,6 +542,8 @@ struct dev_pm_info {
unsigned int async_suspend:1; unsigned int async_suspend:1;
bool is_prepared:1; /* Owned by the PM core */ bool is_prepared:1; /* Owned by the PM core */
bool is_suspended:1; /* Ditto */ bool is_suspended:1; /* Ditto */
bool is_noirq_suspended:1;
bool is_late_suspended:1;
bool ignore_children:1; bool ignore_children:1;
bool early_init:1; /* Owned by the PM core */ bool early_init:1; /* Owned by the PM core */
spinlock_t lock; spinlock_t lock;
......
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