#5703 HIGH 8.2.0 (: Lid switch detection is unreliable.

Zarro Boogs per Child bugtracker at laptop.org
Mon Jul 28 03:33:21 EDT 2008


#5703: Lid switch detection is unreliable.
-------------------------+--------------------------------------------------
   Reporter:  cjb        |       Owner:  dilinger            
       Type:  defect     |      Status:  new                 
   Priority:  high       |   Milestone:  8.2.0 (was Update.2)
  Component:  kernel     |     Version:                      
 Resolution:             |    Keywords:  power               
Next_action:  never set  |    Verified:  0                   
  Blockedby:             |    Blocking:  6590                
-------------------------+--------------------------------------------------
Changes (by wmb at firmworks.com):

 * cc: dsaxena (added)
  * next_action:  => never set


Comment:

 I see a possible problem in the lid switch handling code in
 arch/x86/kernel/olpc-pm.c : olpc_pm_interrupt().

 That code assumes that open and close events will always alternate,
 toggling the variable "olpc_lid_flag" on an event of either type, and
 using the previous state of that variable to decide which event (open or
 close) to report and clear.

 That variable could get out of sync with the actual state of the lid if
 both open and close edge status is reported due to a brief lid switch
 "bounce".  The code clears both edge detectors, regardless of which one is
 currently interesting, so the second event would be lost.

 I see two alternative ways to fix this problem:

 a) Instead of blindly toggling that variable, the current state could be
 read directly from the GPIO readback register, thus ensuring that the
 hardware state is known.

 b) Alternatively, instead of clearing both edge detector status bits,
 clear only the one that was expected.  The other one will persist, and
 when its edge interrupt is subsequently enabled, a new interrupt will be
 delivered, thus tracking both edges.

 It is important to note that the CS5536 documentation about these
 registers is misleading.  The docs say that the edge detectors are
 disabled when the enable bits in GPIO registers 0xc0 and 0xc4 are clear.
 That is not true.  The edge detectors themselves, whose outputs are
 reflected in registers 0xc8 and 0xcc, remain active.  The thing that is
 disabled is the forwarding of that event information to the interrupt /
 power management event circuits.  Here is an OFW recipe to demonstrate
 that turning off the enables doesn't fully disable the edge detection:

 {{{
 ok 400.0000 c0 gpio!  400.0000 c4 gpio!   \ Turn off pos and neg lid edge
 enables
 ok 400 c8 gpio!  400 cc gpio!    \ Clear any leftover status indicators
 ok c8 gpio@ 400 and .  cc gpio@ gpio@ 400 and .
 0 0               \ Result 0 0 means no lid events detected
 <Now close and re-open the lid>
 ok c8 gpio@ 400 and .  cc gpio@ gpio@ 400 and .
 400 400           \ Result 400 400 shows lid events detected
 }}}

-- 
Ticket URL: <http://dev.laptop.org/ticket/5703#comment:10>
One Laptop Per Child <http://laptop.org/>
OLPC bug tracking system


More information about the Bugs mailing list