Patchwork [v3,1/6] suspend: add infrastructure

login
register
mail settings
Submitter Gerd Hoffmann
Date Feb. 9, 2012, 12:46 p.m.
Message ID <4F33C00F.7040408@redhat.com>
Download mbox | patch
Permalink /patch/140375/
State New
Headers show

Comments

Gerd Hoffmann - Feb. 9, 2012, 12:46 p.m.
Hi,

>> Incremental patch (just infrastructure, no acpi windup yet) attached.
>> Something like this?
>>
> We need to give ACPI ability to prevent wakeup. So, for instance, if RTC
> alarm calls wakeup but ACPI detects that RTC_EN is cleared it can
> prevent it.

Yea, already figured that after reading your rtc reply ...

One more incremental attached for review.

thanks,
  Gerd
commit ef93688e70bf11313ec89c7e609fc142259dfd74
Author: Gerd Hoffmann <kraxel@redhat.com>
Date:   Thu Feb 9 13:44:37 2012 +0100

    enable/disable reasons
Gleb Natapov - Feb. 9, 2012, 1:17 p.m.
On Thu, Feb 09, 2012 at 01:46:07PM +0100, Gerd Hoffmann wrote:
>   Hi,
> 
> >> Incremental patch (just infrastructure, no acpi windup yet) attached.
> >> Something like this?
> >>
> > We need to give ACPI ability to prevent wakeup. So, for instance, if RTC
> > alarm calls wakeup but ACPI detects that RTC_EN is cleared it can
> > prevent it.
> 
> Yea, already figured that after reading your rtc reply ...
> 
> One more incremental attached for review.
> 
We can start from that. But other devices can use STS/EN registers
from different GPEs, so they will have same "reason" bit, but in
different registers. Also I'd rather hide this logic in ACPI code
instead of having it in vl.c.

> thanks,
>   Gerd
> 

> commit ef93688e70bf11313ec89c7e609fc142259dfd74
> Author: Gerd Hoffmann <kraxel@redhat.com>
> Date:   Thu Feb 9 13:44:37 2012 +0100
> 
>     enable/disable reasons
> 
> diff --git a/sysemu.h b/sysemu.h
> index e7060aa..781bdaf 100644
> --- a/sysemu.h
> +++ b/sysemu.h
> @@ -47,6 +47,7 @@ void qemu_system_reset_request(void);
>  void qemu_system_suspend_request(void);
>  void qemu_register_suspend_notifier(Notifier *notifier);
>  void qemu_system_wakeup_request(WakeupReason reason);
> +void qemu_system_wakeup_enable(WakeupReason reason, bool enabled);
>  void qemu_register_wakeup_notifier(Notifier *notifier);
>  void qemu_system_shutdown_request(void);
>  void qemu_system_powerdown_request(void);
> diff --git a/vl.c b/vl.c
> index 17d4b72..1feac41 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1288,6 +1288,7 @@ static NotifierList suspend_notifiers =
>      NOTIFIER_LIST_INITIALIZER(suspend_notifiers);
>  static NotifierList wakeup_notifiers =
>      NOTIFIER_LIST_INITIALIZER(wakeup_notifiers);
> +static uint32_t wakeup_reason_mask;
>  static RunState vmstop_requested = RUN_STATE_MAX;
>  
>  int qemu_shutdown_requested_get(void)
> @@ -1423,12 +1424,24 @@ void qemu_system_wakeup_request(WakeupReason reason)
>      if (!is_suspended) {
>          return;
>      }
> +    if (!(wakeup_reason_mask & (1 << reason))) {
> +        return;
> +    }
>      notifier_list_notify(&wakeup_notifiers, &reason);
>      reset_requested = 1;
>      qemu_notify_event();
>      is_suspended = false;
>  }
>  
> +void qemu_system_wakeup_enable(WakeupReason reason, bool enabled)
> +{
> +    if (enabled) {
> +        wakeup_reason_mask |= (1 << reason);
> +    } else {
> +        wakeup_reason_mask &= ~(1 << reason);
> +    }
> +}
> +
>  void qemu_register_wakeup_notifier(Notifier *notifier)
>  {
>      notifier_list_add(&wakeup_notifiers, notifier);


--
			Gleb.
Gerd Hoffmann - Feb. 9, 2012, 1:29 p.m.
Hi,

>>> We need to give ACPI ability to prevent wakeup. So, for instance, if RTC
>>> alarm calls wakeup but ACPI detects that RTC_EN is cleared it can
>>> prevent it.
>>
>> Yea, already figured that after reading your rtc reply ...
>>
>> One more incremental attached for review.
>>
> We can start from that. But other devices can use STS/EN registers
> from different GPEs, so they will have same "reason" bit, but in
> different registers.

Yes, we'll need more reason bits then, basically one per device.

> Also I'd rather hide this logic in ACPI code
> instead of having it in vl.c.

The acpi bits will be in acpi of course.

I'll try to get a complete v4 out of the door later today, that should
the direction I'm heading to more clear than these incremental bits.

cheers,
  Gerd
Gerd Hoffmann - Feb. 9, 2012, 4 p.m.
Hi,

> I'll try to get a complete v4 out of the door later today, that should
> the direction I'm heading to more clear than these incremental bits.

While wading through the acpi mess^Wcode: the acpi timer can s3 wakeups
too IIRC, is that correct?

cheers,
  Gerd
Gleb Natapov - Feb. 9, 2012, 4:05 p.m.
On Thu, Feb 09, 2012 at 05:00:52PM +0100, Gerd Hoffmann wrote:
>   Hi,
> 
> > I'll try to get a complete v4 out of the door later today, that should
> > the direction I'm heading to more clear than these incremental bits.
> 
> While wading through the acpi mess^Wcode: the acpi timer can s3 wakeups
> too IIRC, is that correct?
> 
According to ACPI spec^Wmess you are correct.

--
			Gleb.

Patch

diff --git a/sysemu.h b/sysemu.h
index e7060aa..781bdaf 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -47,6 +47,7 @@  void qemu_system_reset_request(void);
 void qemu_system_suspend_request(void);
 void qemu_register_suspend_notifier(Notifier *notifier);
 void qemu_system_wakeup_request(WakeupReason reason);
+void qemu_system_wakeup_enable(WakeupReason reason, bool enabled);
 void qemu_register_wakeup_notifier(Notifier *notifier);
 void qemu_system_shutdown_request(void);
 void qemu_system_powerdown_request(void);
diff --git a/vl.c b/vl.c
index 17d4b72..1feac41 100644
--- a/vl.c
+++ b/vl.c
@@ -1288,6 +1288,7 @@  static NotifierList suspend_notifiers =
     NOTIFIER_LIST_INITIALIZER(suspend_notifiers);
 static NotifierList wakeup_notifiers =
     NOTIFIER_LIST_INITIALIZER(wakeup_notifiers);
+static uint32_t wakeup_reason_mask;
 static RunState vmstop_requested = RUN_STATE_MAX;
 
 int qemu_shutdown_requested_get(void)
@@ -1423,12 +1424,24 @@  void qemu_system_wakeup_request(WakeupReason reason)
     if (!is_suspended) {
         return;
     }
+    if (!(wakeup_reason_mask & (1 << reason))) {
+        return;
+    }
     notifier_list_notify(&wakeup_notifiers, &reason);
     reset_requested = 1;
     qemu_notify_event();
     is_suspended = false;
 }
 
+void qemu_system_wakeup_enable(WakeupReason reason, bool enabled)
+{
+    if (enabled) {
+        wakeup_reason_mask |= (1 << reason);
+    } else {
+        wakeup_reason_mask &= ~(1 << reason);
+    }
+}
+
 void qemu_register_wakeup_notifier(Notifier *notifier)
 {
     notifier_list_add(&wakeup_notifiers, notifier);