login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2010
»
April
»
28
Re: [PATCH 1/8] PM: Add suspend block api.
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Rafael J. Wysocki
Subject:
Re: [PATCH 1/8] PM: Add suspend block api.
Date: Wednesday, April 28, 2010 - 2:13 pm
On Wednesday 28 April 2010, Alan Stern wrote:
quoted text
> On Tue, 27 Apr 2010, [UTF-8] Arve Hjønnevåg wrote: > > > +For example, in cell phones or other embedded systems, where powering the screen > > +is a significant drain on the battery, suspend blockers can be used to allow > > +user-space to decide whether a keystroke received while the system is suspended > > +should cause the screen to be turned back on or allow the system to go back into > > +suspend. Use set_irq_wake or a platform specific api to make sure the keypad > > +interrupt wakes up the cpu. Once the keypad driver has resumed, the sequence of > > +events can look like this: > > + > > +- The Keypad driver gets an interrupt. It then calls suspend_block on the > > + keypad-scan suspend_blocker and starts scanning the keypad matrix. > > +- The keypad-scan code detects a key change and reports it to the input-event > > + driver. > > +- The input-event driver sees the key change, enqueues an event, and calls > > + suspend_block on the input-event-queue suspend_blocker. > > +- The keypad-scan code detects that no keys are held and calls suspend_unblock > > + on the keypad-scan suspend_blocker. > > +- The user-space input-event thread returns from select/poll, calls > > + suspend_block on the process-input-events suspend_blocker and then calls read > > + on the input-event device. > > +- The input-event driver dequeues the key-event and, since the queue is now > > + empty, it calls suspend_unblock on the input-event-queue suspend_blocker. > > +- The user-space input-event thread returns from read. If it determines that > > + the key should leave the screen off, it calls suspend_unblock on the > > + process_input_events suspend_blocker and then calls select or poll. The > > + system will automatically suspend again, since now no suspend blockers are > > + active. > > + > > + Key pressed Key released > > + | | > > +keypad-scan ++++++++++++++++++ > > +input-event-queue +++ +++ > > +process-input-events +++ +++ > > This is better than before, but it still isn't ideal. Here's what I > mean: > > > suspend blockers can be used to allow > > +user-space to decide whether a keystroke received while the system is suspended > > +should cause the screen to be turned back on or allow the system to go back into > > +suspend. > > That's not right. Handling the screen doesn't need suspend blockers: > The program decides what to do and then either turns on the screen or > else writes "mem" to /sys/power/state. What suspend blockers add is > the ability to resolve races and satisfy multiple constraints when > going into suspend -- which has nothing to do with operating the > screen. > > I _think_ what you're trying to get at can be expressed this way: > > Here's an example showing how a cell phone or other embedded > system can handle keystrokes (or other input events) in the > presence of suspend blockers. Use set_irq_wake... > > ... > > - The user-space input-event thread returns from read. It > carries out whatever activities are appropriate (for example, > powering up the display screen, running other programs, and so > on). When it is finished, it calls suspend_unblock on the > process_input_events suspend_blocker and then calls select or > poll. The system will automatically suspend again when it is > idle and no suspend blockers remain active.
Yeah, that sounds better. Arve, what do you think?
quoted text
> > +/** > > + * suspend_block() - Block suspend > > + * @blocker: The suspend blocker to use > > + * > > + * It is safe to call this function from interrupt context. > > + */ > > +void suspend_block(struct suspend_blocker *blocker) > > +{ > > + unsigned long irqflags; > > + > > + if (WARN_ON(!(blocker->flags & SB_INITIALIZED))) > > + return; > > + > > + spin_lock_irqsave(&list_lock, irqflags); > > + blocker->flags |= SB_ACTIVE; > > + list_del(&blocker->link); > > + > > + if (debug_mask & DEBUG_SUSPEND_BLOCKER) > > + pr_info("suspend_block: %s\n", blocker->name); > > + > > + list_add(&blocker->link, &active_blockers); > > Here and in suspend_unblock(), you can use list_move() in place of > list_del() followed by list_add().
Indeed. And the debug statement might be moved out of the critical section IMHO. Thanks, Rafael --
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
Re: [PATCH 1/8] PM: Add suspend block api.
, Alan Stern
, (Wed Apr 28, 12:13 pm)
Re: [PATCH 1/8] PM: Add suspend block api.
, Rafael J. Wysocki
, (Wed Apr 28, 2:13 pm)
Re: [PATCH 1/8] PM: Add suspend block api.
, Arve Hjønnevåg
, (Wed Apr 28, 4:35 pm)
Re: [PATCH 1/8] PM: Add suspend block api.
, Arve Hjønnevåg
, (Thu Apr 29, 4:39 pm)
Navigation
Create content
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Rafael J. Wysocki
[Bug #11287] Regression in 2.6.27-rc2 in acpi_processor_init()
Ingo Molnar
Re: [PATCH] x86: silence section mismatch warning - uv_cpu_init
FUJITA Tomonori
Re: [Scst-devel] Integration of SCST in the mainstream Linux kernel
Bill Davidsen
Re: Linux 2.6.23-rc9 and a heads-up for the 2.6.24 series..
Chris Snook
Re: [PATCH 0/24] make atomic_read() behave consistently across all architectures
git
:
Mark Junker
git on MacOSX and files with decomposed utf-8 file names
Junio C Hamano
Re: git-svnimport
Junio C Hamano
Re: [PATCH] Detached HEAD (experimental)
Johannes Schindelin
Re: [PATCH] Fix approxidate("never") to always return 0
A Large Angry SCM
Re: [RFC] origin link for cherry-pick and revert
linux-netdev
:
Arnaldo Carvalho de Melo
Re: [PATCH 06/37] dccp: Limit feature negotiation to connection setup phase
Gerrit Renker
[PATCH 1/5] dccp: Initialisation framework for feature negotiation
Daniel Lezcano
getsockopt(TCP_DEFER_ACCEPT) value change
David Miller
Re: 2.6.27.18: bnx2/tg3: BUG: "scheduling while atomic" trying to ifenslave a seco...
Gerrit Renker
[PATCH 37/37] dccp: Debugging functions for feature negotiation
git-commits-head
:
Linux Kernel Mailing List
ath9k_htc: Allocate URBs properly
Linux Kernel Mailing List
powerpc/kexec: Add support for FSL-BookE
Linux Kernel Mailing List
V4L/DVB (8976): af9015: Add USB ID for AVerMedia A309
Linux Kernel Mailing List
ARM: 5670/1: bcmring: add default configuration for bcmring arch
Linux Kernel Mailing List
perf probe: Fix to exit callback soon after finding too many probe points
openbsd-misc
:
Christophe Rioux
Implementation example of snmp
Stephen J. Bevan
GRE over IPsec
Nick Holland
Re: booting openbsd on eee without cd-rom
Cabillot Julien
Re: OpenBSD isakmpd and pf vs Cisco PIX or ASA
Guido Tschakert
Re: what exactly is enc0?
Colocation donated by:
Syndicate