PM: Introduce suspend state PM_SUSPEND_FREEZE
Subsystems (7)
RFC PATCH 1/3 PM: Introduce suspend state PM_SUSPEND_FREEZE
PM_SUSPEND_FREEZE state is a general state that does not need any platform specific support, it equals frozen processes + suspended devices + idle processors.
Compared with PM_SUSPEND_MEMORY,PM_SUSPEND_FREEZE saves less power
because the system is still in a running state. PM_SUSPEND_FREEZE has less resume latency because it does not touch BIOS, and the processors are in idle state.
Compared with RTPM/idle,PM_SUSPEND_FREEZE saves more power as
1. the processor has longer sleep time because processes are frozen. The deeper c-state the processor supports, more power saving we can get.
2. PM_SUSPEND_FREEZE uses system suspend code path, thus we can get more power saving from the devices that does not have good RTPM support.
This state is useful for
1) platforms that do not have STR, or have a broken STR.
2) platforms that have an extremely low power idle state, which can be used to replace STR.
The following describes how PM_SUSPEND_FREEZE state works.
1. echo freeze > /sys/power/state
2. the processes are frozen.
3. all the devices are suspended.
4. all the processors are blocked by a wait queue
5. all the processors idles and enters (Deep) c-state.
6. an interrupt fires.
7. a processor is woken up and handles the irq.
8. if it is a general event,
a) the irq handler runs and quites.
b) goto step 4.
9. if it is a real wake event, say, power button pressing, keyboard touch, mouse moving,
a) the irq handler runs and activate the wakeup source
b) wakeup_source_activate() notifies the wait queue.
c) system starts resuming from PM_SUSPEND_FREEZE
10. all the devices are resumed.
11. all the processes are unfrozen.
12. system is back to working.
Known Issue:
The wakeup of this new PM_SUSPEND_FREEZE state may behave differently from the previous suspend state.
Take ACPI platform for example, there are some GPEs that only enabled when the system is in sleep state, to wake the system backk from S3/S4. But we are not touching these GPEs during transition to PM_SUSPEND_FREEZE. This means we may lose some wake event.
But on the other hand, as we do not disable all the Interrupts during PM_SUSPEND_FREEZE, we may get some extra "wakeup" Interrupts, that are not available for S3/S4.
The patches has been tested on an old Sony laptop, and here are the results:
Average Power:
1. RPTM/idle for half an hour:
14.8W, 12.6W, 14.1W, 12.5W, 14.4W, 13.2W, 12.9W
2. Freeze for half an hour:
11W, 10.4W, 9.4W, 11.3W 10.5W
3. RTPM/idle for three hours:
11.6W
4. Freeze for three hours:
10W
5. Suspend to Memory:
0.5~0.9W
Average Resume Latency:
1. RTPM/idle with a black screen: (From pressing keyboard to screen back) Less than 0.2s
2. Freeze: (From pressing power button to screen back)
2.50s
3. Suspend to Memory: (From pressing power button to screen back) 4.33s
Quoted 1 line
From the results, we can see that all the platforms should benefit from
this patch, even if it does not have Low Power S0.
--- drivers/base/power/wakeup.c | 6 ++++ include/linux/suspend.h | 5 +++- kernel/power/main.c | 2 +- kernel/power/suspend.c | 69 +++++++++++++++++++++++++++++++++++-------- 4 files changed, 67 insertions(+), 15 deletions(-)
drivers/base/power/wakeup.c +6 -0
@@ -382,6 +382,12 @@ static void wakeup_source_activate(struct wakeup_source *ws) {unsigned int cec; +/* +* active wakeup source should bring the system +* out of PM_SUSPEND_FREEZE state +*/ +freeze_wake (); + ws->active = true; ws->active_count++; ws->last_time =ktime_get ();
include/linux/suspend.h +4 -1
@@ -34,8 +34,10 @@ static inline void pm_restore_console(void)typedef int __bitwise suspend_state_t ;#define PM_SUSPEND_ON ((__force suspend_state_t) 0) -#define PM_SUSPEND_STANDBY ((__force suspend_state_t) 1) +#define PM_SUSPEND_FREEZE ((__force suspend_state_t) 1) +#define PM_SUSPEND_STANDBY ((__force suspend_state_t) 2)#define PM_SUSPEND_MEM ((__force suspend_state_t) 3) +#define PM_SUSPEND_MIN PM_SUSPEND_FREEZE#define PM_SUSPEND_MAX ((__force suspend_state_t) 4)enum suspend_stat_step {
@@ -192,6 +194,7 @@ struct platform_suspend_ops {*/ extern void suspend_set_ops (const struct platform_suspend_ops *ops);extern int suspend_valid_only_mem (suspend_state_t state); +extern void freeze_wake (void );/** * arch_suspend_disable_irqs - disable IRQs for suspend
kernel/power/main.c +1 -1
@@ -313,7 +313,7 @@ static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr,static suspend_state_t decode_state (const char *buf,size_t n) {#ifdef CONFIG_SUSPEND -suspend_state_t state =PM_SUSPEND_STANDBY ; +suspend_state_t state =PM_SUSPEND_MIN ;const char *const *s;#endif char *p;
kernel/power/suspend.c +56 -13
162 lines not on this page · raw message
Signature · 1 line
1.7.9.5
RFC PATCH 2/3 ACPI: enable ACPI SCI during suspend
Enable ACPI SCI during suspend so that SCI can be used as wake events for PM_SUSPEND_FREEZE.
For S3/S4 transition,
We disable all GPEs in suspend_ops->prepare_late() to fix a problem that GPEs may trigger SCI before arch_suspend_disable_irqs() is run.
So it is safe to leave the SCI enabled until arch_suspend_irq_disable() is run.
--- drivers/acpi/osl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/osl.c +1 -1
@@ -787,7 +787,7 @@ acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler, acpi_irq_handler = handler; acpi_irq_context = context; -if (request_irq (irq, acpi_irq,IRQF_SHARED ,"acpi" , acpi_irq)) { +if (request_irq (irq, acpi_irq,IRQF_SHARED |IRQF_NO_SUSPEND ,"acpi" , acpi_irq)) { printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq); acpi_irq_handler =NULL ;return AE_NOT_ACQUIRED ;
Signature · 1 line
1.7.9.5
RFC PATCH 3/3 i915: ignore lid open event when resuming
In reply to Zhang Ruii915 driver needs to do modeset when
1. system resumes from sleep
2. lid is opened
In PM_SUSPEND_MEM state, all the GPEs are cleared when system resumes, thus it is the i915_resume code does the modeset rather than intel_lid_notify().
In PM_SUSPEND_FREEZE state, system is still resposive to the lid events.
1. When we close the lid in Freeze state, intel_lid_notify() sets modeset_on_lid.
2. When we reopen the lid, intel_lid_notify() will do a modeset, before the system is resumed.
here is the error log,
[92146.548074] WARNING: at drivers/gpu/drm/i915/intel_display.c:1028 intel_wait_for_pipe_off+0x184/0x190 [i915]() [92146.548076] Hardware name: VGN-Z540N [92146.548078] pipe_off wait timed out [92146.548167] Modules linked in: hid_generic usbhid hid snd_hda_codec_realtek snd_hda_intel snd_hda_codec parport_pc snd_hwdep ppdev snd_pcm_oss i915 snd_mixer_oss snd_pcm arc4 iwldvm snd_seq_dummy mac80211 snd_seq_oss snd_seq_midi fbcon tileblit font bitblit softcursor drm_kms_helper snd_rawmidi snd_seq_midi_event coretemp drm snd_seq kvm btusb bluetooth snd_timer iwlwifi pcmcia tpm_infineon i2c_algo_bit joydev snd_seq_device intel_agp cfg80211 snd intel_gtt yenta_socket pcmcia_rsrc sony_laptop agpgart microcode psmouse tpm_tis serio_raw mxm_wmi soundcore snd_page_alloc tpm acpi_cpufreq lpc_ich pcmcia_core tpm_bios mperf processor lp parport firewire_ohci firewire_core crc_itu_t sdhci_pci sdhci thermal e1000e [92146.548173] Pid: 4304, comm: kworker/0:0 Tainted: G W 3.8.0-rc3-s0i3-v3-test+ #9 [92146.548175] Call Trace: [92146.548189] [<c10378e2>] warn_slowpath_common+0x72/0xa0 [92146.548227] [<f86398b4>] ? intel_wait_for_pipe_off+0x184/0x190 [i915] [92146.548263] [<f86398b4>] ? intel_wait_for_pipe_off+0x184/0x190 [i915] [92146.548270] [<c10379b3>] warn_slowpath_fmt+0x33/0x40 [92146.548307] [<f86398b4>] intel_wait_for_pipe_off+0x184/0x190 [i915] [92146.548344] [<f86399c2>] intel_disable_pipe+0x102/0x190 [i915] [92146.548380] [<f8639ea4>] ? intel_disable_plane+0x64/0x80 [i915] [92146.548417] [<f8639f7c>] i9xx_crtc_disable+0xbc/0x150 [i915] [92146.548456] [<f863ebee>] intel_crtc_update_dpms+0x5e/0x90 [i915] [92146.548493] [<f86437cf>] intel_modeset_setup_hw_state+0x42f/0x8f0 [i915] [92146.548535] [<f8645b0b>] intel_lid_notify+0x9b/0xc0 [i915] [92146.548543] [<c15610d3>] notifier_call_chain+0x43/0x60 [92146.548550] [<c105d1e1>] __blocking_notifier_call_chain+0x41/0x80 [92146.548556] [<c105d23f>] blocking_notifier_call_chain+0x1f/0x30 [92146.548563] [<c131a684>] acpi_lid_send_state+0x78/0xa4 [92146.548569] [<c131aa9e>] acpi_button_notify+0x3b/0xf1 [92146.548577] [<c12df56a>] ? acpi_os_execute+0x17/0x19 [92146.548582] [<c12e591a>] ? acpi_ec_sync_query+0xa5/0xbc [92146.548589] [<c12e2b82>] acpi_device_notify+0x16/0x18 [92146.548595] [<c12f4904>] acpi_ev_notify_dispatch+0x38/0x4f [92146.548600] [<c12df0e8>] acpi_os_execute_deferred+0x20/0x2b [92146.548607] [<c1051208>] process_one_work+0x128/0x3f0 [92146.548613] [<c1564f73>] ? common_interrupt+0x33/0x38 [92146.548618] [<c104f8c0>] ? wake_up_worker+0x30/0x30 [92146.548624] [<c12df0c8>] ? acpi_os_wait_events_complete+0x1e/0x1e [92146.548629] [<c10524f9>] worker_thread+0x119/0x3b0 [92146.548634] [<c10523e0>] ? manage_workers+0x240/0x240 [92146.548640] [<c1056e84>] kthread+0x94/0xa0 [92146.548647] [<c1060000>] ? ftrace_raw_output_sched_stat_runtime+0x70/0xf0 [92146.548652] [<c15649b7>] ret_from_kernel_thread+0x1b/0x28 [92146.548658] [<c1056df0>] ? kthread_create_on_node+0xc0/0xc0
so I'd like to use tristate for modeset_on_lid instead of bool. -1: ingore all the lid events.
0: do not do modeset when there is a lid-open event.
1: do modeset when there is a lid-open event.
In this way, only device resume code will do modeset in a suspend/resume cycle.
--- drivers/gpu/drm/i915/i915_drv.c | 4 ++-- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/intel_lvds.c | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +2 -2
@@ -492,8 +492,8 @@ static int i915_drm_freeze(struct drm_device *dev)intel_opregion_fini (dev); -/* Modeset on resume, not lid events */ - dev_priv->modeset_on_lid =0 ; +/* Modeset on resume, ignore lid events */ + dev_priv->modeset_on_lid =-1 ;console_lock ();intel_fbdev_set_suspend (dev,1 );
drivers/gpu/drm/i915/i915_drv.h +1 -1
@@ -748,7 +748,7 @@ typedef struct drm_i915_private {unsigned long quirks;/* Register state */ -bool modeset_on_lid; +int modeset_on_lid;/* -1: invalid, 0: no modeset, 1: do modeset */ struct {/** Bridge to intel-gtt-ko */
drivers/gpu/drm/i915/intel_lvds.c +2 -0
@@ -512,6 +512,8 @@ static int intel_lid_notify(struct notifier_block *nb, unsigned long val,if (dev->switch_power_state !=DRM_SWITCH_POWER_ON )return NOTIFY_OK ; +if (dev_priv->modeset_on_lid ==-1 ) +return NOTIFY_OK ;/* * check and update the status of LVDS connector after receiving * the LID nofication event.
Signature · 1 line
1.7.9.5
Re: [Intel-gfx] [RFC PATCH 3/3] i915: ignore lid open event when resuming
Quoted 52 lines · Zhang Rui
i915 driver needs to do modeset when
1. system resumes from sleep
2. lid is openedIn
PM_SUSPEND_MEMstate, all the GPEs are cleared when system resumes, thus it is thei915_resumecode does the modeset rather thanintel_lid_notify().In
PM_SUSPEND_FREEZEstate, system is still resposive to the lid events.
1. When we close the lid in Freeze state,intel_lid_notify()setsmodeset_on_lid.
2. When we reopen the lid,intel_lid_notify()will do a modeset, before the system is resumed.here is the error log,
[92146.548074] WARNING: at drivers/gpu/drm/i915/intel_display.c:1028 intel_wait_for_pipe_off+0x184/0x190 [i915]() [92146.548076] Hardware name: VGN-Z540N [92146.548078] pipe_off wait timed out [92146.548167] Modules linked in: hid_generic usbhid hid snd_hda_codec_realtek snd_hda_intel snd_hda_codec parport_pc snd_hwdep ppdev snd_pcm_oss i915 snd_mixer_oss snd_pcm arc4 iwldvm snd_seq_dummy mac80211 snd_seq_oss snd_seq_midi fbcon tileblit font bitblit softcursor drm_kms_helper snd_rawmidi snd_seq_midi_event coretemp drm snd_seq kvm btusb bluetooth snd_timer iwlwifi pcmcia tpm_infineon i2c_algo_bit joydev snd_seq_device intel_agp cfg80211 snd intel_gtt yenta_socket pcmcia_rsrc sony_laptop agpgart microcode psmouse tpm_tis serio_raw mxm_wmi soundcore snd_page_alloc tpm acpi_cpufreq lpc_ich pcmcia_core tpm_bios mperf processor lp parport firewire_ohci firewire_core crc_itu_t sdhci_pci sdhci thermal e1000e [92146.548173] Pid: 4304, comm: kworker/0:0 Tainted: G W 3.8.0-rc3-s0i3-v3-test+ #9 [92146.548175] Call Trace: [92146.548189] [<c10378e2>] warn_slowpath_common+0x72/0xa0 [92146.548227] [<f86398b4>] ? intel_wait_for_pipe_off+0x184/0x190 [i915] [92146.548263] [<f86398b4>] ? intel_wait_for_pipe_off+0x184/0x190 [i915] [92146.548270] [<c10379b3>] warn_slowpath_fmt+0x33/0x40 [92146.548307] [<f86398b4>] intel_wait_for_pipe_off+0x184/0x190 [i915] [92146.548344] [<f86399c2>] intel_disable_pipe+0x102/0x190 [i915] [92146.548380] [<f8639ea4>] ? intel_disable_plane+0x64/0x80 [i915] [92146.548417] [<f8639f7c>] i9xx_crtc_disable+0xbc/0x150 [i915] [92146.548456] [<f863ebee>] intel_crtc_update_dpms+0x5e/0x90 [i915] [92146.548493] [<f86437cf>] intel_modeset_setup_hw_state+0x42f/0x8f0 [i915] [92146.548535] [<f8645b0b>] intel_lid_notify+0x9b/0xc0 [i915] [92146.548543] [<c15610d3>] notifier_call_chain+0x43/0x60 [92146.548550] [<c105d1e1>] __blocking_notifier_call_chain+0x41/0x80 [92146.548556] [<c105d23f>] blocking_notifier_call_chain+0x1f/0x30 [92146.548563] [<c131a684>] acpi_lid_send_state+0x78/0xa4 [92146.548569] [<c131aa9e>] acpi_button_notify+0x3b/0xf1 [92146.548577] [<c12df56a>] ? acpi_os_execute+0x17/0x19 [92146.548582] [<c12e591a>] ? acpi_ec_sync_query+0xa5/0xbc [92146.548589] [<c12e2b82>] acpi_device_notify+0x16/0x18 [92146.548595] [<c12f4904>] acpi_ev_notify_dispatch+0x38/0x4f [92146.548600] [<c12df0e8>] acpi_os_execute_deferred+0x20/0x2b [92146.548607] [<c1051208>] process_one_work+0x128/0x3f0 [92146.548613] [<c1564f73>] ? common_interrupt+0x33/0x38 [92146.548618] [<c104f8c0>] ? wake_up_worker+0x30/0x30 [92146.548624] [<c12df0c8>] ? acpi_os_wait_events_complete+0x1e/0x1e [92146.548629] [<c10524f9>] worker_thread+0x119/0x3b0 [92146.548634] [<c10523e0>] ? manage_workers+0x240/0x240 [92146.548640] [<c1056e84>] kthread+0x94/0xa0 [92146.548647] [<c1060000>] ? ftrace_raw_output_sched_stat_runtime+0x70/0xf0 [92146.548652] [<c15649b7>] ret_from_kernel_thread+0x1b/0x28 [92146.548658] [<c1056df0>] ? kthread_create_on_node+0xc0/0xc0
Quoted 7 lines
so I'd like to use tristate for
modeset_on_lidinstead of bool. -1: ingore all the lid events.
0: do not do modeset when there is a lid-open event.
1: do modeset when there is a lid-open event.
In this way, only device resume code will do modeset in a suspend/resume cycle.Signed-off-by Zhang Rui <[email protected]>
Given that this essentially requires users to manually set this module option to make stuff work I don't like this.
I see a few possible options:
- plug the races between all the different parts - I've never really understood why acpi sends us events before the resume code has completed ... If that's indeed intentional, we could delay the handling a bit until at least the i915 resume code completed.
- Judging from the diff context you're not on the latest 3.8-rc codebase - we've applied a few fixes to this lid hack recently. Please retest on a kernel with
commit 45e2b5f640b3766da3eda48f6c35f088155c06f3
Author: Daniel Vetter <[email protected]> Date: Fri Nov 23 18:16:34 2012 +0100
drm/i915: force restore on lid open
- This lid hack is only required since a few moronic BIOS implementations touch the display hw state behind our backs. On platforms with OpRegion support this shouldn't be the case any longer (which means pretty much everything shipped in the last few years), so we could conditionalize this hack on that (e.g. check out the existing dev_priv->opregion.header check in the i915_resume function in i915_drv.c in drm-next).
Yours, Daniel
Quoted 54 lines
--- drivers/gpu/drm/i915/i915_drv.c | 4 ++-- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/intel_lvds.c | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/i915_drv.c +2
-2@@ -492,8 +492,8 @@ static int i915_drm_freeze(struct drm_device *dev)intel_opregion_fini (dev); -/* Modeset on resume, not lid events */ - dev_priv->modeset_on_lid =0 ; +/* Modeset on resume, ignore lid events */ + dev_priv->modeset_on_lid =-1 ;console_lock ();intel_fbdev_set_suspend (dev,1 );drivers/gpu/drm/i915/i915_drv.h +1
-1@@ -748,7 +748,7 @@ typedef struct drm_i915_private {unsigned long quirks;/* Register state */ -bool modeset_on_lid; +int modeset_on_lid;/* -1: invalid, 0: no modeset, 1: do modeset */ struct {/** Bridge to intel-gtt-ko */ drivers/gpu/drm/i915/intel_lvds.c +2
-1@@ -512,6 +512,8 @@ static int intel_lid_notify(struct notifier_block *nb, unsigned long val,if (dev->switch_power_state !=DRM_SWITCH_POWER_ON )return NOTIFY_OK ; +if (dev_priv->modeset_on_lid ==-1 ) +return NOTIFY_OK ;/* * check and update the status of LVDS connector after receiving * the LID nofication event. -- 1.7.9.5
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [Intel-gfx] [RFC PATCH 3/3] i915: ignore lid open event when resuming
Quoted 61 lines · Daniel Vetter
Quoted 52 lines · Zhang Rui
i915 driver needs to do modeset when
1. system resumes from sleep
2. lid is openedIn
PM_SUSPEND_MEMstate, all the GPEs are cleared when system resumes, thus it is thei915_resumecode does the modeset rather thanintel_lid_notify().In
PM_SUSPEND_FREEZEstate, system is still resposive to the lid events.
1. When we close the lid in Freeze state,intel_lid_notify()setsmodeset_on_lid.
2. When we reopen the lid,intel_lid_notify()will do a modeset, before the system is resumed.here is the error log,
[92146.548074] WARNING: at drivers/gpu/drm/i915/intel_display.c:1028 intel_wait_for_pipe_off+0x184/0x190 [i915]() [92146.548076] Hardware name: VGN-Z540N [92146.548078] pipe_off wait timed out [92146.548167] Modules linked in: hid_generic usbhid hid snd_hda_codec_realtek snd_hda_intel snd_hda_codec parport_pc snd_hwdep ppdev snd_pcm_oss i915 snd_mixer_oss snd_pcm arc4 iwldvm snd_seq_dummy mac80211 snd_seq_oss snd_seq_midi fbcon tileblit font bitblit softcursor drm_kms_helper snd_rawmidi snd_seq_midi_event coretemp drm snd_seq kvm btusb bluetooth snd_timer iwlwifi pcmcia tpm_infineon i2c_algo_bit joydev snd_seq_device intel_agp cfg80211 snd intel_gtt yenta_socket pcmcia_rsrc sony_laptop agpgart microcode psmouse tpm_tis serio_raw mxm_wmi soundcore snd_page_alloc tpm acpi_cpufreq lpc_ich pcmcia_core tpm_bios mperf processor lp parport firewire_ohci firewire_core crc_itu_t sdhci_pci sdhci thermal e1000e [92146.548173] Pid: 4304, comm: kworker/0:0 Tainted: G W 3.8.0-rc3-s0i3-v3-test+ #9 [92146.548175] Call Trace: [92146.548189] [<c10378e2>] warn_slowpath_common+0x72/0xa0 [92146.548227] [<f86398b4>] ? intel_wait_for_pipe_off+0x184/0x190 [i915] [92146.548263] [<f86398b4>] ? intel_wait_for_pipe_off+0x184/0x190 [i915] [92146.548270] [<c10379b3>] warn_slowpath_fmt+0x33/0x40 [92146.548307] [<f86398b4>] intel_wait_for_pipe_off+0x184/0x190 [i915] [92146.548344] [<f86399c2>] intel_disable_pipe+0x102/0x190 [i915] [92146.548380] [<f8639ea4>] ? intel_disable_plane+0x64/0x80 [i915] [92146.548417] [<f8639f7c>] i9xx_crtc_disable+0xbc/0x150 [i915] [92146.548456] [<f863ebee>] intel_crtc_update_dpms+0x5e/0x90 [i915] [92146.548493] [<f86437cf>] intel_modeset_setup_hw_state+0x42f/0x8f0 [i915] [92146.548535] [<f8645b0b>] intel_lid_notify+0x9b/0xc0 [i915] [92146.548543] [<c15610d3>] notifier_call_chain+0x43/0x60 [92146.548550] [<c105d1e1>] __blocking_notifier_call_chain+0x41/0x80 [92146.548556] [<c105d23f>] blocking_notifier_call_chain+0x1f/0x30 [92146.548563] [<c131a684>] acpi_lid_send_state+0x78/0xa4 [92146.548569] [<c131aa9e>] acpi_button_notify+0x3b/0xf1 [92146.548577] [<c12df56a>] ? acpi_os_execute+0x17/0x19 [92146.548582] [<c12e591a>] ? acpi_ec_sync_query+0xa5/0xbc [92146.548589] [<c12e2b82>] acpi_device_notify+0x16/0x18 [92146.548595] [<c12f4904>] acpi_ev_notify_dispatch+0x38/0x4f [92146.548600] [<c12df0e8>] acpi_os_execute_deferred+0x20/0x2b [92146.548607] [<c1051208>] process_one_work+0x128/0x3f0 [92146.548613] [<c1564f73>] ? common_interrupt+0x33/0x38 [92146.548618] [<c104f8c0>] ? wake_up_worker+0x30/0x30 [92146.548624] [<c12df0c8>] ? acpi_os_wait_events_complete+0x1e/0x1e [92146.548629] [<c10524f9>] worker_thread+0x119/0x3b0 [92146.548634] [<c10523e0>] ? manage_workers+0x240/0x240 [92146.548640] [<c1056e84>] kthread+0x94/0xa0 [92146.548647] [<c1060000>] ? ftrace_raw_output_sched_stat_runtime+0x70/0xf0 [92146.548652] [<c15649b7>] ret_from_kernel_thread+0x1b/0x28 [92146.548658] [<c1056df0>] ? kthread_create_on_node+0xc0/0xc0Quoted 7 lines
so I'd like to use tristate for
modeset_on_lidinstead of bool. -1: ingore all the lid events.
0: do not do modeset when there is a lid-open event.
1: do modeset when there is a lid-open event.
In this way, only device resume code will do modeset in a suspend/resume cycle.Signed-off-by Zhang Rui <[email protected]>
Quoted 7 lines
Given that this essentially requires users to manually set this module option to make stuff work I don't like this.
I see a few possible options:
- plug the races between all the different parts - I've never really understood why acpi sends us events before the resume code has completed ...
This particular one may be a result of patch [2/3] in the series, actually, because that patch makes SCI work over the whole cycle.
Quoted 2 lines
If that's indeed intentional, we could delay the handling a bit until at least the i915 resume code completed.
I would do that for now at least if possible. It shouldn't hurt anyway.
Thanks,
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [Intel-gfx] [RFC PATCH 3/3] i915: ignore lid open event when resuming
Quoted 8 lines · Rafael J. Wysocki
Quoted 7 lines
Given that this essentially requires users to manually set this module option to make stuff work I don't like this.
I see a few possible options:
- plug the races between all the different parts - I've never really understood why acpi sends us events before the resume code has completed ...
Quoted 7 lines
This particular one may be a result of patch [2/3] in the series, actually, because that patch makes SCI work over the whole cycle.
Quoted 2 lines
If that's indeed intentional, we could delay the handling a bit until at least the i915 resume code completed.
I would do that for now at least if possible. It shouldn't hurt anyway.
Since I lack a bit clue about how the pm stuff works exactly: Is there a ready-made helper for that kind of synchronization, where a notifier callback can be called from a different device's resume callbacks, which is someplace completely unrelated in the device-tree? Or any anti-patterns to avoid?
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [Intel-gfx] [RFC PATCH 3/3] i915: ignore lid open event when resuming
In reply to Daniel VetterQuoted 59 lines · Daniel Vetter
Quoted 58 lines · Zhang Rui
i915 driver needs to do modeset when
1. system resumes from sleep
2. lid is openedIn
PM_SUSPEND_MEMstate, all the GPEs are cleared when system resumes, thus it is thei915_resumecode does the modeset rather thanintel_lid_notify().In
PM_SUSPEND_FREEZEstate, system is still resposive to the lid events.
1. When we close the lid in Freeze state,intel_lid_notify()setsmodeset_on_lid.
2. When we reopen the lid,intel_lid_notify()will do a modeset, before the system is resumed.here is the error log,
[92146.548074] WARNING: at drivers/gpu/drm/i915/intel_display.c:1028 intel_wait_for_pipe_off+0x184/0x190 [i915]() [92146.548076] Hardware name: VGN-Z540N [92146.548078] pipe_off wait timed out [92146.548167] Modules linked in: hid_generic usbhid hid snd_hda_codec_realtek snd_hda_intel snd_hda_codec parport_pc snd_hwdep ppdev snd_pcm_oss i915 snd_mixer_oss snd_pcm arc4 iwldvm snd_seq_dummy mac80211 snd_seq_oss snd_seq_midi fbcon tileblit font bitblit softcursor drm_kms_helper snd_rawmidi snd_seq_midi_event coretemp drm snd_seq kvm btusb bluetooth snd_timer iwlwifi pcmcia tpm_infineon i2c_algo_bit joydev snd_seq_device intel_agp cfg80211 snd intel_gtt yenta_socket pcmcia_rsrc sony_laptop agpgart microcode psmouse tpm_tis serio_raw mxm_wmi soundcore snd_page_alloc tpm acpi_cpufreq lpc_ich pcmcia_core tpm_bios mperf processor lp parport firewire_ohci firewire_core crc_itu_t sdhci_pci sdhci thermal e1000e [92146.548173] Pid: 4304, comm: kworker/0:0 Tainted: G W 3.8.0-rc3-s0i3-v3-test+ #9 [92146.548175] Call Trace: [92146.548189] [<c10378e2>] warn_slowpath_common+0x72/0xa0 [92146.548227] [<f86398b4>] ? intel_wait_for_pipe_off+0x184/0x190 [i915] [92146.548263] [<f86398b4>] ? intel_wait_for_pipe_off+0x184/0x190 [i915] [92146.548270] [<c10379b3>] warn_slowpath_fmt+0x33/0x40 [92146.548307] [<f86398b4>] intel_wait_for_pipe_off+0x184/0x190 [i915] [92146.548344] [<f86399c2>] intel_disable_pipe+0x102/0x190 [i915] [92146.548380] [<f8639ea4>] ? intel_disable_plane+0x64/0x80 [i915] [92146.548417] [<f8639f7c>] i9xx_crtc_disable+0xbc/0x150 [i915] [92146.548456] [<f863ebee>] intel_crtc_update_dpms+0x5e/0x90 [i915] [92146.548493] [<f86437cf>] intel_modeset_setup_hw_state+0x42f/0x8f0 [i915] [92146.548535] [<f8645b0b>] intel_lid_notify+0x9b/0xc0 [i915] [92146.548543] [<c15610d3>] notifier_call_chain+0x43/0x60 [92146.548550] [<c105d1e1>] __blocking_notifier_call_chain+0x41/0x80 [92146.548556] [<c105d23f>] blocking_notifier_call_chain+0x1f/0x30 [92146.548563] [<c131a684>] acpi_lid_send_state+0x78/0xa4 [92146.548569] [<c131aa9e>] acpi_button_notify+0x3b/0xf1 [92146.548577] [<c12df56a>] ? acpi_os_execute+0x17/0x19 [92146.548582] [<c12e591a>] ? acpi_ec_sync_query+0xa5/0xbc [92146.548589] [<c12e2b82>] acpi_device_notify+0x16/0x18 [92146.548595] [<c12f4904>] acpi_ev_notify_dispatch+0x38/0x4f [92146.548600] [<c12df0e8>] acpi_os_execute_deferred+0x20/0x2b [92146.548607] [<c1051208>] process_one_work+0x128/0x3f0 [92146.548613] [<c1564f73>] ? common_interrupt+0x33/0x38 [92146.548618] [<c104f8c0>] ? wake_up_worker+0x30/0x30 [92146.548624] [<c12df0c8>] ? acpi_os_wait_events_complete+0x1e/0x1e [92146.548629] [<c10524f9>] worker_thread+0x119/0x3b0 [92146.548634] [<c10523e0>] ? manage_workers+0x240/0x240 [92146.548640] [<c1056e84>] kthread+0x94/0xa0 [92146.548647] [<c1060000>] ? ftrace_raw_output_sched_stat_runtime+0x70/0xf0 [92146.548652] [<c15649b7>] ret_from_kernel_thread+0x1b/0x28 [92146.548658] [<c1056df0>] ? kthread_create_on_node+0xc0/0xc0so I'd like to use tristate for
modeset_on_lidinstead of bool. -1: ingore all the lid events.
0: do not do modeset when there is a lid-open event.
1: do modeset when there is a lid-open event.
In this way, only device resume code will do modeset in a suspend/resume cycle.
Quoted 5 lines
Quoted 1 line
Signed-off-by Zhang Rui <[email protected]>Given that this essentially requires users to manually set this module option to make stuff work I don't like this.
sorry, I do not understand.
this patch just disables modeset_on_lid during suspend.
Quoted 5 lines
I see a few possible options:
- plug the races between all the different parts - I've never really understood why acpi sends us events before the resume code has completed ... If that's indeed intentional, we could delay the handling a bit until at least the i915 resume code completed.
IMO, the real question is that, during a suspend/resume cycle, if we need to take care of the lid open event or not.
To me, the answer is no, because when resuming from STR, i915 is not aware of such an event, and the i915 resume code works well, right? so I do not think it is a problem to ignore the lid event for another lightweight suspend state, which is introduced in Patch 1/3 in this series.
Quoted 4 lines
- Judging from the diff context you're not on the latest 3.8-rc codebase - we've applied a few fixes to this lid hack recently. Please retest on a kernel with
the patch is based on 3.8.0-rc3, which already includes the commit below.
And yes, the problem still exists.
thanks,
rui
Quoted 73 lines
commit
45e2b5f640b3766da3eda48f6c35f088155c06f3Author: Daniel Vetter <[email protected]> Date: Fri Nov 23 18:16:34 2012 +0100drm/i915: force restore on lid open
- This lid hack is only required since a few moronic BIOS implementations touch the display hw state behind our backs. On platforms with OpRegion support this shouldn't be the case any longer (which means pretty much everything shipped in the last few years), so we could conditionalize this hack on that (e.g. check out the existing
dev_priv->opregion.headercheck in thei915_resumefunction ini915_drv.cin drm-next).Yours, Daniel
Quoted 54 lines
--- drivers/gpu/drm/i915/i915_drv.c | 4 ++-- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/intel_lvds.c | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/i915_drv.c +2
-2@@ -492,8 +492,8 @@ static int i915_drm_freeze(struct drm_device *dev)intel_opregion_fini (dev); -/* Modeset on resume, not lid events */ - dev_priv->modeset_on_lid =0 ; +/* Modeset on resume, ignore lid events */ + dev_priv->modeset_on_lid =-1 ;console_lock ();intel_fbdev_set_suspend (dev,1 );drivers/gpu/drm/i915/i915_drv.h +1
-1@@ -748,7 +748,7 @@ typedef struct drm_i915_private {unsigned long quirks;/* Register state */ -bool modeset_on_lid; +int modeset_on_lid;/* -1: invalid, 0: no modeset, 1: do modeset */ struct {/** Bridge to intel-gtt-ko */ drivers/gpu/drm/i915/intel_lvds.c +2
-1@@ -512,6 +512,8 @@ static int intel_lid_notify(struct notifier_block *nb, unsigned long val,if (dev->switch_power_state !=DRM_SWITCH_POWER_ON )return NOTIFY_OK ; +if (dev_priv->modeset_on_lid ==-1 ) +return NOTIFY_OK ;/* * check and update the status of LVDS connector after receiving * the LID nofication event. -- 1.7.9.5
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [RFC PATCH 3/3] i915: ignore lid open event when resuming
Quoted 5 lines · Zhang Rui
Quoted 3 lines
Given that this essentially requires users to manually set this module option to make stuff work I don't like this.
sorry, I do not understand.
this patch just disablesmodeset_on_lidduring suspend.
Pardon me, the misunderstanding is on my side - I've mixed up dev_priv->modeset_on_lid with the corresponding module option.
Is my understanding correct that only with the new SCI pm state this can happen, since that still allows acpi events to be processed (and so our lid_notifier being called?
Quoted 14 lines
Quoted 5 lines
I see a few possible options:
- plug the races between all the different parts - I've never really understood why acpi sends us events before the resume code has completed ... If that's indeed intentional, we could delay the handling a bit until at least the i915 resume code completed.IMO, the real question is that, during a suspend/resume cycle, if we need to take care of the lid open event or not.
To me, the answer is no, because when resuming from STR, i915 is not aware of such an event, and the i915 resume code works well, right? so I do not think it is a problem to ignore the lid event for another lightweight suspend state, which is introduced in Patch 1/3 in this series.
Quoted 7 lines
Quoted 4 lines
- Judging from the diff context you're not on the latest 3.8-rc codebase - we've applied a few fixes to this lid hack recently. Please retest on a kernel with
the patch is based on 3.8.0-rc3, which already includes the commit below.
And yes, the problem still exists.
Ok, I think I see the issue now. But I suspect that we need some additional locking to make this solid, since currently dev_priv->modeset_on_lid updates can race with our lid notifier handler. Let me think about this a bit more.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [Intel-gfx] [RFC PATCH 3/3] i915: ignore lid open event when resuming
Quoted 7 lines · Daniel Vetter
Quoted 5 lines · Zhang Rui
Quoted 3 lines
Given that this essentially requires users to manually set this module option to make stuff work I don't like this.
sorry, I do not understand.
this patch just disablesmodeset_on_lidduring suspend.
Quoted 7 lines
Pardon me, the misunderstanding is on my side - I've mixed up
dev_priv->modeset_on_lidwith the corresponding module option.Is my understanding correct that only with the new SCI pm state this can happen, since that still allows acpi events to be processed (and so our
lid_notifierbeing called?
yep.
Quoted 18 lines
Quoted 18 lines
Quoted 5 lines
I see a few possible options:
- plug the races between all the different parts - I've never really understood why acpi sends us events before the resume code has completed ... If that's indeed intentional, we could delay the handling a bit until at least the i915 resume code completed.IMO, the real question is that, during a suspend/resume cycle, if we need to take care of the lid open event or not.
To me, the answer is no, because when resuming from STR, i915 is not aware of such an event, and the i915 resume code works well, right? so I do not think it is a problem to ignore the lid event for another lightweight suspend state, which is introduced in Patch 1/3 in this series.Quoted 4 lines
- Judging from the diff context you're not on the latest 3.8-rc codebase - we've applied a few fixes to this lid hack recently. Please retest on a kernel with
Quoted 8 lines
Quoted 3 lines
the patch is based on 3.8.0-rc3, which already includes the commit below.
And yes, the problem still exists.Ok, I think I see the issue now. But I suspect that we need some additional locking to make this solid, since currently
dev_priv->modeset_on_lidupdates can race with our lid notifier handler. Let me think about this a bit more.
hmm,
with this patch, intel_lid_notify() will return immediately if modeset_on_lid is set to -1. So the only problem in my mind is that we got a lid open event during i915_suspend().
Say,
lid is opened -> i915_lid_notify() is invoked (modeset_on_lid is 1 at this time) -> i915_suspend() set modeset_on_lid to -1, just before intel_modeset_setup_hw_state() being invoked in i915_lid_notify() -> intel_modeset_setup_hw_state() breaks the system.
but my first question would be is this (lid open on suspend) possible in real world?
If the answer is yes, then my second question is that, this problem exists for STR as well because SCI is still valid at this time when suspending to memory, have we seen such issues for STR before?
Anyway, if the current code does not break STR, this patch should be enough for the new suspend state.
what do you think?
thanks,
rui
Re: [Intel-gfx] [RFC PATCH 3/3] i915: ignore lid open event when resuming
Quoted 61 lines · Zhang Rui
Quoted 7 lines · Daniel Vetter
Quoted 5 lines · Zhang Rui
Quoted 3 lines
Given that this essentially requires users to manually set this module option to make stuff work I don't like this.
sorry, I do not understand.
this patch just disablesmodeset_on_lidduring suspend.Quoted 7 lines
Pardon me, the misunderstanding is on my side - I've mixed up
dev_priv->modeset_on_lidwith the corresponding module option.Is my understanding correct that only with the new SCI pm state this can happen, since that still allows acpi events to be processed (and so our
lid_notifierbeing called?yep.
Quoted 18 lines
Quoted 18 lines
Quoted 5 lines
I see a few possible options:
- plug the races between all the different parts - I've never really understood why acpi sends us events before the resume code has completed ... If that's indeed intentional, we could delay the handling a bit until at least the i915 resume code completed.IMO, the real question is that, during a suspend/resume cycle, if we need to take care of the lid open event or not.
To me, the answer is no, because when resuming from STR, i915 is not aware of such an event, and the i915 resume code works well, right? so I do not think it is a problem to ignore the lid event for another lightweight suspend state, which is introduced in Patch 1/3 in this series.Quoted 4 lines
- Judging from the diff context you're not on the latest 3.8-rc codebase - we've applied a few fixes to this lid hack recently. Please retest on a kernel with
Quoted 8 lines
Quoted 3 lines
the patch is based on 3.8.0-rc3, which already includes the commit below.
And yes, the problem still exists.Ok, I think I see the issue now. But I suspect that we need some additional locking to make this solid, since currently
dev_priv->modeset_on_lidupdates can race with our lid notifier handler. Let me think about this a bit more.hmm,
with this patch,intel_lid_notify()will return immediately ifmodeset_on_lidis set to -1. So the only problem in my mind is that we got a lid open event duringi915_suspend().Say,
lid is opened ->i915_lid_notify()is invoked (modeset_on_lidis 1 at this time) ->i915_suspend()setmodeset_on_lidto -1, just beforeintel_modeset_setup_hw_state()being invoked ini915_lid_notify()->intel_modeset_setup_hw_state()breaks the system.but my first question would be is this (lid open on suspend) possible in real world?
If the answer is yes, then my second question is that, this problem exists for STR as well because SCI is still valid at this time when suspending to memory, have we seen such issues for STR before?
Quoted 3 lines
Anyway, if the current code does not break STR, this patch should be enough for the new suspend state.
what do you think?
I think I have two wishlist changes for your patch ;-)
- Convert dev_priv->modeset_on_lid to an enum, so that we have descriptive names instead of magic numbers.
- I think we can close all races by adding a new lid_notifier mutex (I prefer a new lock instead of overloading an existing one with). If we hold that in the suspend/resume paths just for changing modeset_on_lid and also for the entire lid notifier callback (i.e. grab the lock before first looking at modest_on_lid, only drop it once the modeset fixup has been completed at the end of the function) we should be race-free in all cases.
Also, I think we should move the modeset_on_lid updates in the suspend/resume paths to the very beginning/end.
Can you pls update your patch with these changes? Or do you see an additional race we need to plug somewhere?
Thanks, Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [Intel-gfx] [RFC PATCH 3/3] i915: ignore lid open event when resuming
Quoted 62 lines · Daniel Vetter
Quoted 61 lines · Zhang Rui
Quoted 7 lines · Daniel Vetter
Quoted 5 lines · Zhang Rui
Quoted 3 lines
Given that this essentially requires users to manually set this module option to make stuff work I don't like this.
sorry, I do not understand.
this patch just disablesmodeset_on_lidduring suspend.Quoted 7 lines
Pardon me, the misunderstanding is on my side - I've mixed up
dev_priv->modeset_on_lidwith the corresponding module option.Is my understanding correct that only with the new SCI pm state this can happen, since that still allows acpi events to be processed (and so our
lid_notifierbeing called?yep.
Quoted 18 lines
Quoted 18 lines
Quoted 5 lines
I see a few possible options:
- plug the races between all the different parts - I've never really understood why acpi sends us events before the resume code has completed ... If that's indeed intentional, we could delay the handling a bit until at least the i915 resume code completed.IMO, the real question is that, during a suspend/resume cycle, if we need to take care of the lid open event or not.
To me, the answer is no, because when resuming from STR, i915 is not aware of such an event, and the i915 resume code works well, right? so I do not think it is a problem to ignore the lid event for another lightweight suspend state, which is introduced in Patch 1/3 in this series.Quoted 4 lines
- Judging from the diff context you're not on the latest 3.8-rc codebase - we've applied a few fixes to this lid hack recently. Please retest on a kernel with
Quoted 8 lines
Quoted 3 lines
the patch is based on 3.8.0-rc3, which already includes the commit below.
And yes, the problem still exists.Ok, I think I see the issue now. But I suspect that we need some additional locking to make this solid, since currently
dev_priv->modeset_on_lidupdates can race with our lid notifier handler. Let me think about this a bit more.hmm,
with this patch,intel_lid_notify()will return immediately ifmodeset_on_lidis set to -1. So the only problem in my mind is that we got a lid open event duringi915_suspend().Say,
lid is opened ->i915_lid_notify()is invoked (modeset_on_lidis 1 at this time) ->i915_suspend()setmodeset_on_lidto -1, just beforeintel_modeset_setup_hw_state()being invoked ini915_lid_notify()->intel_modeset_setup_hw_state()breaks the system.but my first question would be is this (lid open on suspend) possible in real world?
If the answer is yes, then my second question is that, this problem exists for STR as well because SCI is still valid at this time when suspending to memory, have we seen such issues for STR before?
Quoted 9 lines
Quoted 3 lines
Anyway, if the current code does not break STR, this patch should be enough for the new suspend state.
what do you think?I think I have two wishlist changes for your patch ;-)
- Convert
dev_priv->modeset_on_lidto an enum, so that we have descriptive names instead of magic numbers.
sure, will update in next version.
Quoted 8 lines
- I think we can close all races by adding a new
lid_notifiermutex (I prefer a new lock instead of overloading an existing one with). If we hold that in the suspend/resume paths just for changingmodeset_on_lidand also for the entire lid notifier callback (i.e. grab the lock before first looking atmodest_on_lid, only drop it once the modeset fixup has been completed at the end of the function) we should be race-free in all cases.
Quoted 6 lines
Also, I think we should move the
modeset_on_lidupdates in the suspend/resume paths to the very beginning/end.Can you pls update your patch with these changes? Or do you see an additional race we need to plug somewhere?
yep. will send out V2 soon.
thanks for your comments.
-rui
Hi,
first, thanks a lot for advancing PM infrastructure!
include/linux/suspend.h static inline void pm_restore_console(void) · line 41
Quoted 7 lines
#define
PM_SUSPEND_ON((__forcesuspend_state_t) 0)include/linux/suspend.h +3
-1-#define PM_SUSPEND_STANDBY ((__force suspend_state_t) 1) +#define PM_SUSPEND_FREEZE ((__force suspend_state_t) 1) +#define PM_SUSPEND_STANDBY ((__force suspend_state_t) 2)#define PM_SUSPEND_MEM ((__force suspend_state_t) 3) +#define PM_SUSPEND_MIN PM_SUSPEND_FREEZE#define PM_SUSPEND_MAX ((__force suspend_state_t) 4)
I'll just pretend to be hopeful that you managed to hunt down all relevant code sites (possibly even splattered around drivers?) which may have made illegally hard-coded assumptions about the number of PM_SUSPEND state "enum"s ;)
(e.g. comparisons - such as "==", "<=" etc. - come into mind)
Review of your patch was all fine, nothing to object about.
Thanks,
Andreas Mohr