Skip to content

Commit

Permalink
xen: suspend: refactor cancellation flag into a structure
Browse files Browse the repository at this point in the history
Will add extra fields in subsequent patches.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
  • Loading branch information
Ian Campbell authored and Stefano Stabellini committed Feb 25, 2011
1 parent bd1c0ad commit ceb1802
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions drivers/xen/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@ enum shutdown_state {
/* Ignore multiple shutdown requests. */
static enum shutdown_state shutting_down = SHUTDOWN_INVALID;

struct suspend_info {
int cancelled;
};

#ifdef CONFIG_PM_SLEEP
static int xen_hvm_suspend(void *data)
{
struct suspend_info *si = data;
int err;
int *cancelled = data;

BUG_ON(!irqs_disabled());

Expand All @@ -54,12 +58,12 @@ static int xen_hvm_suspend(void *data)
* or the domain was merely checkpointed, and 0 if it
* is resuming in a new domain.
*/
*cancelled = HYPERVISOR_suspend(0UL);
si->cancelled = HYPERVISOR_suspend(0UL);

xen_hvm_post_suspend(*cancelled);
xen_hvm_post_suspend(si->cancelled);
gnttab_resume();

if (!*cancelled) {
if (!si->cancelled) {
xen_irq_resume();
xen_console_resume();
xen_timer_resume();
Expand All @@ -72,8 +76,8 @@ static int xen_hvm_suspend(void *data)

static int xen_suspend(void *data)
{
struct suspend_info *si = data;
int err;
int *cancelled = data;

BUG_ON(!irqs_disabled());

Expand All @@ -93,13 +97,13 @@ static int xen_suspend(void *data)
* or the domain was merely checkpointed, and 0 if it
* is resuming in a new domain.
*/
*cancelled = HYPERVISOR_suspend(virt_to_mfn(xen_start_info));
si->cancelled = HYPERVISOR_suspend(virt_to_mfn(xen_start_info));

xen_post_suspend(*cancelled);
xen_post_suspend(si->cancelled);
gnttab_resume();
xen_mm_unpin_all();

if (!*cancelled) {
if (!si->cancelled) {
xen_irq_resume();
xen_console_resume();
xen_timer_resume();
Expand All @@ -113,7 +117,7 @@ static int xen_suspend(void *data)
static void do_suspend(void)
{
int err;
int cancelled = 1;
struct suspend_info si;

shutting_down = SHUTDOWN_SUSPEND;

Expand Down Expand Up @@ -143,20 +147,22 @@ static void do_suspend(void)
goto out_resume;
}

si.cancelled = 1;

if (xen_hvm_domain())
err = stop_machine(xen_hvm_suspend, &cancelled, cpumask_of(0));
err = stop_machine(xen_hvm_suspend, &si, cpumask_of(0));
else
err = stop_machine(xen_suspend, &cancelled, cpumask_of(0));
err = stop_machine(xen_suspend, &si, cpumask_of(0));

dpm_resume_noirq(PMSG_RESUME);

if (err) {
printk(KERN_ERR "failed to start xen_suspend: %d\n", err);
cancelled = 1;
si.cancelled = 1;
}

out_resume:
if (!cancelled) {
if (!si.cancelled) {
xen_arch_resume();
xs_resume();
} else
Expand Down

0 comments on commit ceb1802

Please sign in to comment.