From: Gabriele Mazzotta <gabriele.mzt@gmail.com>
To: Matthew Garrett <mjg59@srcf.ucam.org>
Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: System automatically wakes up because of Intel Rapid Start Technology
Date: Mon, 22 Dec 2014 19:57:25 +0100 [thread overview]
Message-ID: <6760597.z8zpCLmhLz@xps13> (raw)
In-Reply-To: <2403684.tbaxlpZUxO@xps13>
On Monday 22 December 2014 19:41:52 Gabriele Mazzotta wrote:
> On Monday 22 December 2014 18:02:54 Matthew Garrett wrote:
> > Getting this right is a little bit annoying - if the timer would have
> > expired during the time we were suspended, we don't want to re-enable
> > it. I *think* this covers all cases, and does it in generic code rather
> > than special-casing it. Any chance you can give it a test?
>
> I've done a quick test. has_persistent_clock() is false on my system,
> so this patch has no effect as it is.
I did another quick test and moved the code so that it is executed
before has_persistent_clock() is checked. Everything seems to be
working as intended. I tried to suspend and resume multiple times
within one minute and exactly one minute after the last suspension
the system transitioned from S3 to S4.
I haven't checked properly whether it is OK or not to simply move
the code or not, but I wanted to let you know that it works.
> > diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
> > index 472a5ad..4e3a2a1 100644
> > --- a/drivers/rtc/class.c
> > +++ b/drivers/rtc/class.c
> > @@ -91,6 +91,8 @@ static int rtc_suspend(struct device *dev)
> > old_system = timespec64_sub(old_system, delta_delta);
> > }
> >
> > + rtc->valid_alarm = !rtc_read_alarm(rtc, &rtc->alarm);
> > +
> > return 0;
> > }
> >
> > @@ -145,6 +147,29 @@ static int rtc_resume(struct device *dev)
> > if (sleep_time.tv_sec >= 0)
> > timekeeping_inject_sleeptime64(&sleep_time);
> > rtc_hctosys_ret = 0;
> > +
> > + /*
> > + * If there was an alarm set before suspend, make sure that the
> > + * platform hasn't overwritten it
> > + */
> > + if (rtc->valid_alarm) {
> > + struct rtc_time tm;
> > + long now, scheduled;
> > +
> > + rtc_read_time(rtc, &tm);
> > + rtc_tm_to_time(&rtc->alarm.time, &scheduled);
> > + rtc_tm_to_time(&tm, &now);
> > +
> > + /* Clear the alarm if it went off during suspend */
> > + if (scheduled <= now) {
> > + rtc_time_to_tm(0, &rtc->alarm.time);
> > + rtc->alarm.enabled = 0;
> > + }
> > +
> > + if (rtc->ops && rtc->ops->set_alarm)
> > + rtc->ops->set_alarm(rtc->dev.parent, &rtc->alarm);
> > + }
> > +
> > return 0;
> > }
> >
> > diff --git a/include/linux/rtc.h b/include/linux/rtc.h
> > index 6d6be09..bc805ff 100644
> > --- a/include/linux/rtc.h
> > +++ b/include/linux/rtc.h
> > @@ -133,6 +133,10 @@ struct rtc_device
> > /* Some hardware can't support UIE mode */
> > int uie_unsupported;
> >
> > +#ifdef CONFIG_PM_SLEEP
> > + struct rtc_wkalrm alarm;
> > + bool valid_alarm;
> > +#endif
> > #ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
> > struct work_struct uie_task;
> > struct timer_list uie_timer;
> >
> >
> >
next prev parent reply other threads:[~2014-12-22 18:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-22 13:59 System automatically wakes up because of Intel Rapid Start Technology Gabriele Mazzotta
2014-12-22 14:44 ` Matthew Garrett
2014-12-22 14:48 ` Matthew Garrett
2014-12-22 14:59 ` Matthew Garrett
2014-12-22 15:50 ` Gabriele Mazzotta
2014-12-22 16:10 ` Gabriele Mazzotta
2014-12-22 16:13 ` Matthew Garrett
2014-12-22 18:02 ` Matthew Garrett
2014-12-22 18:41 ` Gabriele Mazzotta
2014-12-22 18:57 ` Gabriele Mazzotta [this message]
2014-12-22 16:12 ` Matthew Garrett
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=6760597.z8zpCLmhLz@xps13 \
--to=gabriele.mzt@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mjg59@srcf.ucam.org \
--cc=platform-driver-x86@vger.kernel.org \
/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