From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: "Florian Mickler" <florian@mickler.org>,
"Linux-pm mailing list" <linux-pm@lists.linux-foundation.org>,
"Matthew Garrett" <mjg59@srcf.ucam.org>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
"Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
"Arve Hjønnevåg" <arve@android.com>, "Neil Brown" <neilb@suse.de>,
"mark gross" <640e9920@gmail.com>
Subject: Re: [update 3] Re: [RFC][PATCH] PM: Avoid losing wakeup events during suspend
Date: Fri, 25 Jun 2010 22:33:32 +0200 [thread overview]
Message-ID: <201006252233.32784.rjw@sisk.pl> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1006251028240.1604-100000@iolanthe.rowland.org>
On Friday, June 25, 2010, Alan Stern wrote:
> On Fri, 25 Jun 2010, Rafael J. Wysocki wrote:
>
> > So, there it goes.
> >
> > I decided not to play with memory allocations at this point, because I really
> > don't expect pm_wakeup_event() to be heavily used initially. If there are more
> > users and it's called more frequently, we can always switch to using a separate
> > slab cache.
> >
> > Hopefully, I haven't overlooked anything vitally important this time.
> >
> > Please tell me what you think.
>
> Obviously comments still need to be added.
Indeed.
> Beyond that...
>
> > --- /dev/null
> > +++ linux-2.6/drivers/base/power/wakeup.c
> > @@ -0,0 +1,143 @@
> > +
> > +#include <linux/device.h>
> > +#include <linux/slab.h>
> > +#include <linux/sched.h>
> > +#include <linux/capability.h>
> > +#include <linux/pm.h>
> > +
> > +bool events_check_enabled;
> > +
> > +static unsigned long event_count;
> > +static unsigned long saved_event_count;
> > +static unsigned long events_in_progress;
> > +static spinlock_t events_lock;
>
> Use static DEFINE_SPINLOCK(events_lock) instead.
Hmm. I thought that was deprecated. Never mind.
> > +static DECLARE_WAIT_QUEUE_HEAD(events_wait_queue);
> > +
> > +void pm_wakeup_events_init(void)
> > +{
> > + spin_lock_init(&events_lock);
> > +}
>
> Then this routine won't be needed.
>
> > +unsigned long pm_dev_wakeup_count(struct device *dev)
> > +{
> > + unsigned long flags;
> > + unsigned long count;
> > +
> > + spin_lock_irqsave(&events_lock, flags);
> > + count = dev->power.wakeup_count;
> > + spin_unlock_irqrestore(&events_lock, flags);
> > + return count;
> > +}
>
> Are the spin_lock calls needed here? I doubt it.
No, they aren't. In fact it may be a static inline.
> > --- linux-2.6.orig/kernel/power/power.h
> > +++ linux-2.6/kernel/power/power.h
> > @@ -184,6 +184,15 @@ static inline void suspend_test_finish(c
> > #ifdef CONFIG_PM_SLEEP
> > /* kernel/power/main.c */
> > extern int pm_notifier_call_chain(unsigned long val);
> > +
> > +/* drivers/base/power/wakeup.c */
> > +extern bool events_check_enabled;
> > +
> > +extern void pm_wakeup_events_init(void);
> > +extern bool pm_check_wakeup_events(void);
> > +extern bool pm_check_wakeup_events_final(void);
> > +extern bool pm_get_wakeup_count(unsigned long *count);
> > +extern bool pm_save_wakeup_count(unsigned long count);
> > #endif
>
> This is unfortunate. These declarations belong in a file that can
> also be #included by drivers/base/power/wakeup.c. Otherwise future
> changes might cause type mismatches the compiler won't be able to
> catch.
You're right. In that case I think include/linux/suspend.h is the right header
to put them into.
> > @@ -511,18 +513,24 @@ int hibernation_platform_enter(void)
> >
> > local_irq_disable();
> > sysdev_suspend(PMSG_HIBERNATE);
> > + if (!pm_check_wakeup_events()) {
> > + error = -EAGAIN;
> > + goto Power_up;
> > + }
> > +
> > hibernation_ops->enter();
> > /* We should never get here */
> > while (1);
> >
> > - /*
> > - * We don't need to reenable the nonboot CPUs or resume consoles, since
> > - * the system is going to be halted anyway.
> > - */
> > + Power_up:
> > + sysdev_resume();
> > + local_irq_enable();
> > + enable_nonboot_cpus();
> > +
> > Platform_finish:
> > hibernation_ops->finish();
> >
> > - dpm_suspend_noirq(PMSG_RESTORE);
> > + dpm_resume_noirq(PMSG_RESTORE);
>
> Is this a bug fix that crept in along with the other changes?
Yeah.
> > --- linux-2.6.orig/drivers/pci/pci.h
> > +++ linux-2.6/drivers/pci/pci.h
> > @@ -6,6 +6,8 @@
> > #define PCI_CFG_SPACE_SIZE 256
> > #define PCI_CFG_SPACE_EXP_SIZE 4096
> >
> > +#define PCI_WAKEUP_COOLDOWN 100
>
> This definition can go directly in pci.c, since it isn't used anywhere
> else.
OK
Thanks for the comments,
Rafael
next prev parent reply other threads:[~2010-06-25 20:35 UTC|newest]
Thread overview: 75+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-19 22:05 Rafael J. Wysocki
2010-06-20 5:52 ` mark gross
2010-06-20 12:49 ` Rafael J. Wysocki
2010-06-20 23:13 ` mark gross
2010-06-20 16:28 ` Alan Stern
2010-06-20 21:50 ` Rafael J. Wysocki
2010-06-21 2:23 ` Alan Stern
2010-06-21 5:32 ` Florian Mickler
2010-06-21 15:23 ` Alan Stern
2010-06-21 20:38 ` Florian Mickler
2010-06-21 22:18 ` Alan Stern
2010-06-21 22:40 ` Rafael J. Wysocki
2010-06-21 22:48 ` Rafael J. Wysocki
2010-06-22 0:50 ` Arve Hjønnevåg
2010-06-22 10:21 ` Rafael J. Wysocki
2010-06-22 14:35 ` Alan Stern
2010-06-22 15:35 ` Rafael J. Wysocki
2010-06-22 19:55 ` Alan Stern
2010-06-22 20:58 ` Rafael J. Wysocki
2010-06-22 19:59 ` [update] " Rafael J. Wysocki
2010-06-22 20:34 ` Alan Stern
2010-06-22 21:41 ` Rafael J. Wysocki
2010-06-23 2:12 ` Alan Stern
2010-06-23 10:09 ` Rafael J. Wysocki
2010-06-23 15:21 ` Alan Stern
2010-06-23 22:17 ` Rafael J. Wysocki
2010-06-24 13:13 ` [update 2] " Rafael J. Wysocki
2010-06-24 15:06 ` Rafael J. Wysocki
2010-06-24 15:35 ` Alan Stern
2010-06-24 23:00 ` [update 3] " Rafael J. Wysocki
2010-06-25 14:42 ` Alan Stern
2010-06-25 20:33 ` Rafael J. Wysocki [this message]
2010-06-24 15:44 ` [update 2] " Alan Stern
2010-06-24 16:19 ` Rafael J. Wysocki
2010-06-24 17:09 ` Alan Stern
2010-06-24 23:06 ` Rafael J. Wysocki
2010-06-25 15:09 ` Alan Stern
2010-06-25 20:37 ` Rafael J. Wysocki
2010-06-25 20:57 ` Alan Stern
2010-06-25 6:40 ` Florian Mickler
2010-06-25 13:28 ` Rafael J. Wysocki
[not found] ` <201006222159.28081.rjw__37084.1419128284$1277237903$gmane$org@sisk.pl>
2010-06-24 14:16 ` [update] " Andy Lutomirski
2010-06-24 14:45 ` Alan Stern
2010-06-24 14:48 ` Rafael J. Wysocki
2010-06-24 15:21 ` Andy Lutomirski
2010-06-22 23:00 ` mark gross
2010-06-21 16:54 ` Alan Stern
2010-06-21 20:40 ` Florian Mickler
2010-06-21 21:18 ` Rafael J. Wysocki
2010-06-21 22:27 ` Alan Stern
2010-06-21 6:13 ` mark gross
2010-06-21 12:10 ` tytso
2010-06-21 12:22 ` Alan Cox
2010-06-21 12:26 ` Florian Mickler
2010-06-21 13:42 ` tytso
2010-06-21 14:01 ` Alan Cox
2010-06-22 1:07 ` mark gross
2010-06-21 16:01 ` Alan Stern
2010-06-22 1:25 ` mark gross
2010-06-22 2:24 ` Alan Stern
2010-06-21 21:58 ` Rafael J. Wysocki
2010-06-20 22:58 ` mark gross
2010-06-21 2:33 ` Alan Stern
2010-06-21 4:04 ` [linux-pm] " David Brownell
2010-06-21 6:02 ` David Brownell
2010-06-21 15:06 ` Alan Stern
2010-06-21 5:55 ` mark gross
2010-06-21 12:39 ` Florian Mickler
2010-06-21 15:57 ` Alan Stern
2010-06-22 1:58 ` mark gross
2010-06-22 2:46 ` Alan Stern
2010-06-22 9:24 ` Rafael J. Wysocki
2010-06-22 6:18 ` Florian Mickler
2010-06-22 23:22 ` mark gross
2010-06-22 9:29 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201006252233.32784.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=640e9920@gmail.com \
--cc=arve@android.com \
--cc=dmitry.torokhov@gmail.com \
--cc=florian@mickler.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=mjg59@srcf.ucam.org \
--cc=neilb@suse.de \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®