Merge branch 'pm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6

* 'pm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6:
  PM: Remove some debug messages producing too much noise
  PM: Fix warning on suspend errors
  PM / Hibernate: Add newline to load_image() fail path
  PM / Hibernate: Fix error handling in save_image()
  PM / Hibernate: Fix blkdev refleaks
  PM / yenta: Split resume into early and late parts (rev. 4)
This commit is contained in:
Linus Torvalds 2009-11-03 07:52:57 -08:00
commit 38dc63459f
7 changed files with 90 additions and 56 deletions

View file

@ -511,6 +511,7 @@ static void dpm_complete(pm_message_t state)
INIT_LIST_HEAD(&list); INIT_LIST_HEAD(&list);
mutex_lock(&dpm_list_mtx); mutex_lock(&dpm_list_mtx);
transition_started = false;
while (!list_empty(&dpm_list)) { while (!list_empty(&dpm_list)) {
struct device *dev = to_device(dpm_list.prev); struct device *dev = to_device(dpm_list.prev);

View file

@ -51,8 +51,6 @@ static int __pm_runtime_idle(struct device *dev)
{ {
int retval = 0; int retval = 0;
dev_dbg(dev, "__pm_runtime_idle()!\n");
if (dev->power.runtime_error) if (dev->power.runtime_error)
retval = -EINVAL; retval = -EINVAL;
else if (dev->power.idle_notification) else if (dev->power.idle_notification)
@ -93,8 +91,6 @@ static int __pm_runtime_idle(struct device *dev)
wake_up_all(&dev->power.wait_queue); wake_up_all(&dev->power.wait_queue);
out: out:
dev_dbg(dev, "__pm_runtime_idle() returns %d!\n", retval);
return retval; return retval;
} }

View file

@ -98,10 +98,13 @@ EXPORT_SYMBOL(pcmcia_socket_list_rwsem);
* These functions check for the appropriate struct pcmcia_soket arrays, * These functions check for the appropriate struct pcmcia_soket arrays,
* and pass them to the low-level functions pcmcia_{suspend,resume}_socket * and pass them to the low-level functions pcmcia_{suspend,resume}_socket
*/ */
static int socket_early_resume(struct pcmcia_socket *skt);
static int socket_late_resume(struct pcmcia_socket *skt);
static int socket_resume(struct pcmcia_socket *skt); static int socket_resume(struct pcmcia_socket *skt);
static int socket_suspend(struct pcmcia_socket *skt); static int socket_suspend(struct pcmcia_socket *skt);
int pcmcia_socket_dev_suspend(struct device *dev) static void pcmcia_socket_dev_run(struct device *dev,
int (*cb)(struct pcmcia_socket *))
{ {
struct pcmcia_socket *socket; struct pcmcia_socket *socket;
@ -110,29 +113,34 @@ int pcmcia_socket_dev_suspend(struct device *dev)
if (socket->dev.parent != dev) if (socket->dev.parent != dev)
continue; continue;
mutex_lock(&socket->skt_mutex); mutex_lock(&socket->skt_mutex);
socket_suspend(socket); cb(socket);
mutex_unlock(&socket->skt_mutex); mutex_unlock(&socket->skt_mutex);
} }
up_read(&pcmcia_socket_list_rwsem); up_read(&pcmcia_socket_list_rwsem);
}
int pcmcia_socket_dev_suspend(struct device *dev)
{
pcmcia_socket_dev_run(dev, socket_suspend);
return 0; return 0;
} }
EXPORT_SYMBOL(pcmcia_socket_dev_suspend); EXPORT_SYMBOL(pcmcia_socket_dev_suspend);
void pcmcia_socket_dev_early_resume(struct device *dev)
{
pcmcia_socket_dev_run(dev, socket_early_resume);
}
EXPORT_SYMBOL(pcmcia_socket_dev_early_resume);
void pcmcia_socket_dev_late_resume(struct device *dev)
{
pcmcia_socket_dev_run(dev, socket_late_resume);
}
EXPORT_SYMBOL(pcmcia_socket_dev_late_resume);
int pcmcia_socket_dev_resume(struct device *dev) int pcmcia_socket_dev_resume(struct device *dev)
{ {
struct pcmcia_socket *socket; pcmcia_socket_dev_run(dev, socket_resume);
down_read(&pcmcia_socket_list_rwsem);
list_for_each_entry(socket, &pcmcia_socket_list, socket_list) {
if (socket->dev.parent != dev)
continue;
mutex_lock(&socket->skt_mutex);
socket_resume(socket);
mutex_unlock(&socket->skt_mutex);
}
up_read(&pcmcia_socket_list_rwsem);
return 0; return 0;
} }
EXPORT_SYMBOL(pcmcia_socket_dev_resume); EXPORT_SYMBOL(pcmcia_socket_dev_resume);
@ -546,29 +554,24 @@ static int socket_suspend(struct pcmcia_socket *skt)
return 0; return 0;
} }
/* static int socket_early_resume(struct pcmcia_socket *skt)
* Resume a socket. If a card is present, verify its CIS against
* our cached copy. If they are different, the card has been
* replaced, and we need to tell the drivers.
*/
static int socket_resume(struct pcmcia_socket *skt)
{ {
int ret;
if (!(skt->state & SOCKET_SUSPEND))
return -EBUSY;
skt->socket = dead_socket; skt->socket = dead_socket;
skt->ops->init(skt); skt->ops->init(skt);
skt->ops->set_socket(skt, &skt->socket); skt->ops->set_socket(skt, &skt->socket);
if (skt->state & SOCKET_PRESENT)
skt->resume_status = socket_setup(skt, resume_delay);
return 0;
}
static int socket_late_resume(struct pcmcia_socket *skt)
{
if (!(skt->state & SOCKET_PRESENT)) { if (!(skt->state & SOCKET_PRESENT)) {
skt->state &= ~SOCKET_SUSPEND; skt->state &= ~SOCKET_SUSPEND;
return socket_insert(skt); return socket_insert(skt);
} }
ret = socket_setup(skt, resume_delay); if (skt->resume_status == 0) {
if (ret == 0) {
/* /*
* FIXME: need a better check here for cardbus cards. * FIXME: need a better check here for cardbus cards.
*/ */
@ -596,6 +599,20 @@ static int socket_resume(struct pcmcia_socket *skt)
return 0; return 0;
} }
/*
* Resume a socket. If a card is present, verify its CIS against
* our cached copy. If they are different, the card has been
* replaced, and we need to tell the drivers.
*/
static int socket_resume(struct pcmcia_socket *skt)
{
if (!(skt->state & SOCKET_SUSPEND))
return -EBUSY;
socket_early_resume(skt);
return socket_late_resume(skt);
}
static void socket_remove(struct pcmcia_socket *skt) static void socket_remove(struct pcmcia_socket *skt)
{ {
dev_printk(KERN_NOTICE, &skt->dev, dev_printk(KERN_NOTICE, &skt->dev,

View file

@ -1275,16 +1275,26 @@ static int yenta_dev_resume_noirq(struct device *dev)
if (socket->type && socket->type->restore_state) if (socket->type && socket->type->restore_state)
socket->type->restore_state(socket); socket->type->restore_state(socket);
return pcmcia_socket_dev_resume(dev); pcmcia_socket_dev_early_resume(dev);
return 0;
}
static int yenta_dev_resume(struct device *dev)
{
pcmcia_socket_dev_late_resume(dev);
return 0;
} }
static struct dev_pm_ops yenta_pm_ops = { static struct dev_pm_ops yenta_pm_ops = {
.suspend_noirq = yenta_dev_suspend_noirq, .suspend_noirq = yenta_dev_suspend_noirq,
.resume_noirq = yenta_dev_resume_noirq, .resume_noirq = yenta_dev_resume_noirq,
.resume = yenta_dev_resume,
.freeze_noirq = yenta_dev_suspend_noirq, .freeze_noirq = yenta_dev_suspend_noirq,
.thaw_noirq = yenta_dev_resume_noirq, .thaw_noirq = yenta_dev_resume_noirq,
.thaw = yenta_dev_resume,
.poweroff_noirq = yenta_dev_suspend_noirq, .poweroff_noirq = yenta_dev_suspend_noirq,
.restore_noirq = yenta_dev_resume_noirq, .restore_noirq = yenta_dev_resume_noirq,
.restore = yenta_dev_resume,
}; };
#define YENTA_PM_OPS (&yenta_pm_ops) #define YENTA_PM_OPS (&yenta_pm_ops)

View file

@ -262,6 +262,8 @@ struct pcmcia_socket {
struct device dev; struct device dev;
/* data internal to the socket driver */ /* data internal to the socket driver */
void *driver_data; void *driver_data;
/* status of the card during resume from a system sleep state */
int resume_status;
}; };
@ -280,6 +282,8 @@ extern struct pccard_resource_ops pccard_nonstatic_ops;
/* socket drivers are expected to use these callbacks in their .drv struct */ /* socket drivers are expected to use these callbacks in their .drv struct */
extern int pcmcia_socket_dev_suspend(struct device *dev); extern int pcmcia_socket_dev_suspend(struct device *dev);
extern void pcmcia_socket_dev_early_resume(struct device *dev);
extern void pcmcia_socket_dev_late_resume(struct device *dev);
extern int pcmcia_socket_dev_resume(struct device *dev); extern int pcmcia_socket_dev_resume(struct device *dev);
/* socket drivers use this callback in their IRQ handler */ /* socket drivers use this callback in their IRQ handler */

View file

@ -693,21 +693,22 @@ static int software_resume(void)
/* The snapshot device should not be opened while we're running */ /* The snapshot device should not be opened while we're running */
if (!atomic_add_unless(&snapshot_device_available, -1, 0)) { if (!atomic_add_unless(&snapshot_device_available, -1, 0)) {
error = -EBUSY; error = -EBUSY;
swsusp_close(FMODE_READ);
goto Unlock; goto Unlock;
} }
pm_prepare_console(); pm_prepare_console();
error = pm_notifier_call_chain(PM_RESTORE_PREPARE); error = pm_notifier_call_chain(PM_RESTORE_PREPARE);
if (error) if (error)
goto Finish; goto close_finish;
error = usermodehelper_disable(); error = usermodehelper_disable();
if (error) if (error)
goto Finish; goto close_finish;
error = create_basic_memory_bitmaps(); error = create_basic_memory_bitmaps();
if (error) if (error)
goto Finish; goto close_finish;
pr_debug("PM: Preparing processes for restore.\n"); pr_debug("PM: Preparing processes for restore.\n");
error = prepare_processes(); error = prepare_processes();
@ -719,6 +720,7 @@ static int software_resume(void)
pr_debug("PM: Reading hibernation image.\n"); pr_debug("PM: Reading hibernation image.\n");
error = swsusp_read(&flags); error = swsusp_read(&flags);
swsusp_close(FMODE_READ);
if (!error) if (!error)
hibernation_restore(flags & SF_PLATFORM_MODE); hibernation_restore(flags & SF_PLATFORM_MODE);
@ -737,6 +739,9 @@ static int software_resume(void)
mutex_unlock(&pm_mutex); mutex_unlock(&pm_mutex);
pr_debug("PM: Resume from disk failed.\n"); pr_debug("PM: Resume from disk failed.\n");
return error; return error;
close_finish:
swsusp_close(FMODE_READ);
goto Finish;
} }
late_initcall(software_resume); late_initcall(software_resume);

View file

@ -314,7 +314,6 @@ static int save_image(struct swap_map_handle *handle,
{ {
unsigned int m; unsigned int m;
int ret; int ret;
int error = 0;
int nr_pages; int nr_pages;
int err2; int err2;
struct bio *bio; struct bio *bio;
@ -329,26 +328,27 @@ static int save_image(struct swap_map_handle *handle,
nr_pages = 0; nr_pages = 0;
bio = NULL; bio = NULL;
do_gettimeofday(&start); do_gettimeofday(&start);
do { while (1) {
ret = snapshot_read_next(snapshot, PAGE_SIZE); ret = snapshot_read_next(snapshot, PAGE_SIZE);
if (ret > 0) { if (ret <= 0)
error = swap_write_page(handle, data_of(*snapshot), break;
&bio); ret = swap_write_page(handle, data_of(*snapshot), &bio);
if (error) if (ret)
break; break;
if (!(nr_pages % m)) if (!(nr_pages % m))
printk("\b\b\b\b%3d%%", nr_pages / m); printk("\b\b\b\b%3d%%", nr_pages / m);
nr_pages++; nr_pages++;
} }
} while (ret > 0);
err2 = wait_on_bio_chain(&bio); err2 = wait_on_bio_chain(&bio);
do_gettimeofday(&stop); do_gettimeofday(&stop);
if (!error) if (!ret)
error = err2; ret = err2;
if (!error) if (!ret)
printk("\b\b\b\bdone\n"); printk("\b\b\b\bdone\n");
else
printk("\n");
swsusp_show_speed(&start, &stop, nr_to_write, "Wrote"); swsusp_show_speed(&start, &stop, nr_to_write, "Wrote");
return error; return ret;
} }
/** /**
@ -536,7 +536,8 @@ static int load_image(struct swap_map_handle *handle,
snapshot_write_finalize(snapshot); snapshot_write_finalize(snapshot);
if (!snapshot_image_loaded(snapshot)) if (!snapshot_image_loaded(snapshot))
error = -ENODATA; error = -ENODATA;
} } else
printk("\n");
swsusp_show_speed(&start, &stop, nr_to_read, "Read"); swsusp_show_speed(&start, &stop, nr_to_read, "Read");
return error; return error;
} }
@ -572,8 +573,6 @@ int swsusp_read(unsigned int *flags_p)
error = load_image(&handle, &snapshot, header->pages - 1); error = load_image(&handle, &snapshot, header->pages - 1);
release_swap_reader(&handle); release_swap_reader(&handle);
blkdev_put(resume_bdev, FMODE_READ);
if (!error) if (!error)
pr_debug("PM: Image successfully loaded\n"); pr_debug("PM: Image successfully loaded\n");
else else
@ -596,7 +595,7 @@ int swsusp_check(void)
error = bio_read_page(swsusp_resume_block, error = bio_read_page(swsusp_resume_block,
swsusp_header, NULL); swsusp_header, NULL);
if (error) if (error)
return error; goto put;
if (!memcmp(SWSUSP_SIG, swsusp_header->sig, 10)) { if (!memcmp(SWSUSP_SIG, swsusp_header->sig, 10)) {
memcpy(swsusp_header->sig, swsusp_header->orig_sig, 10); memcpy(swsusp_header->sig, swsusp_header->orig_sig, 10);
@ -604,8 +603,10 @@ int swsusp_check(void)
error = bio_write_page(swsusp_resume_block, error = bio_write_page(swsusp_resume_block,
swsusp_header, NULL); swsusp_header, NULL);
} else { } else {
return -EINVAL; error = -EINVAL;
} }
put:
if (error) if (error)
blkdev_put(resume_bdev, FMODE_READ); blkdev_put(resume_bdev, FMODE_READ);
else else