Subject: Re: linux-next: Tree for September 5

From: Alexey Starikovskiy <[email-masked]>
Date: Mon, 08 Sep 2008 16:39:20 +0400

Hi Bartlomiej,

Could you please try updated patch?

Thanks,
Alex.

Bartlomiej Zolnierkiewicz wrote:
> Hi,
> 
> On Friday 05 September 2008, Stephen Rothwell wrote:
>> Hi all,
>>
>> There will be no linux-next tree until at least September 9 (US Central
>> time) as I will be travelling.
>>
>> Changes since next-20080904:
> 
> The following commit:
> 
> commit 50c0f43ff1199bbea5f0418d40df32f4d4029b13
> Author: Andi Kleen <[email-masked]>
> Date:   Thu Sep 4 15:13:29 2008 +0200
> 
>     ACPI: EC: do transaction from interrupt context
> 
>     From: Alexey Starikovskiy <[email-masked]>
> 
>     It is easier and faster to do transaction directly from interrupt context
>     rather than waking control thread.
>     Also, cleaner GPE storm avoidance is implemented.
> 
>     AK: Merged with earlier io port patch
> 
>     Signed-off-by: Alexey Starikovskiy <[email-masked]>
>     Signed-off-by: Andi Kleen <[email-masked]>
> 
> makes my laptop *power-off* on haldaemon startup (Fedora 9 here).
> 
> dmesg with the commit reverted:
> 
> Linux version 2.6.27-rc5-next-20080905-04648-ge9f2a9c ([email-masked]) (gcc version 4.3.0 20080428 (Red Hat 4.3.0-8) (GCC) ) #223 PREEMPT Sat Sep 6 00:19:40 CEST 2008
> BIOS-provided physical RAM map:
>  BIOS-e820: 0000000000000000 - 000000000009fc00 (usable)
>  BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved)
>  BIOS-e820: 00000000000e0000 - 0000000000100000 (reserved)
>  BIOS-e820: 0000000000100000 - 000000001fff0000 (usable)
>  BIOS-e820: 000000001fff0000 - 000000001fffffc0 (ACPI data)
>  BIOS-e820: 000000001fffffc0 - 0000000020000000 (ACPI NVS)
>  BIOS-e820: 00000000ffb80000 - 00000000ffc00000 (reserved)
>  BIOS-e820: 00000000fff80000 - 0000000100000000 (reserved)
> last_pfn = 0x1fff0 max_arch_pfn = 0x100000
> kernel direct mapping tables up to 1fff0000 @ 7000-d000
> DMI 2.3 present.
> ACPI: RSDP 000E6010, 0014 (r0 OID_00)
> ACPI: RSDT 1FFFA7F0, 0034 (r1 INSYDE RSDT_000        1 _CSI    10101)
> ACPI: FACP 1FFFFB00, 0074 (r1 ACER   DCL56         200 _CSI    10101)
> ACPI: DSDT 1FFFAC70, 4E8A (r1 ACER     TM_290        6 MSFT  100000E)
> ACPI: FACS 1FFFFFC0, 0040
> ACPI: BOOT 1FFFFB90, 0028 (r1 INSYDE SYS_BOOT      100 _CSI    10101)
> ACPI: DBGP 1FFFFBC0, 0034 (r1 INSYDE DBGP_000      100 _CSI    10101)
> ACPI: SSDT 1FFFA830, 0192 (r1 INSYDE   GV3Ref     2000 INTL 20021002)
> ACPI: DMI detected: Acer
> 511MB LOWMEM available.
>   mapped low ram: 0 - 1fff0000
>   low ram: 00000000 - 1fff0000
>   bootmap 00001000 - 00005000
> (6 early reservations) ==> bootmem [0000000000 - 001fff0000]
>   #0 [0000000000 - 0000001000]   BIOS data page ==> [0000000000 - 0000001000]
>   #1 [0000100000 - 000045dc5c]    TEXT DATA BSS ==> [0000100000 - 000045dc5c]
>   #2 [000045e000 - 0000461000]    INIT_PG_TABLE ==> [000045e000 - 0000461000]
>   #3 [000009fc00 - 0000100000]    BIOS reserved ==> [000009fc00 - 0000100000]
>   #4 [0000007000 - 0000009000]          PGTABLE ==> [0000007000 - 0000009000]
>   #5 [0000001000 - 0000005000]          BOOTMAP ==> [0000001000 - 0000005000]
> Zone PFN ranges:
>   DMA      0x00000000 -> 0x00001000
>   Normal   0x00001000 -> 0x0001fff0
> Movable zone start PFN for each node
> early_node_map[2] active PFN ranges
>     0: 0x00000000 -> 0x0000009f
>     0: 0x00000100 -> 0x0001fff0
> On node 0 totalpages: 130959
> free_area_init_node: node 0, pgdat c03cdbd8, node_mem_map c1000000
>   DMA zone: 3967 pages, LIFO batch:0
>   Normal zone: 125968 pages, LIFO batch:31
> ACPI: PM-Timer IO Port: 0x1008
> Local APIC disabled by BIOS -- reenabling.
> Found and enabled local APIC!
> Allocating PCI resources starting at 30000000 (gap: 20000000:dfb80000)
> dyn_array 0xc041a240 size:0xc nr:256 align:0x1000
> dyn_array 0xc041a10c size:0x1c nr:32 align:0x1000
> dyn_array 0xc044d9b0 size:0x48 nr:32 align:0x1000
> dyn_array total_size: 0x3000
> dyn_array 0xc041a240  ==> [0x1402000 - 0x1402c00]
> dyn_array 0xc041a10c  ==> [0x1403000 - 0x1403380]
> dyn_array 0xc044d9b0  ==> [0x1404000 - 0x1404900]
> kstat_irqs ==> [0x1405000 - 0x1405080]
> Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 129935
> Kernel command line: ro vga=0x318 lapic pci=assign-busses
> Enabling fast FPU save and restore... done.
> Enabling unmasked SIMD FPU exception support... done.
> Initializing CPU#0
> found new irq_desc for irq 0
> found new irq_desc for irq 1
> found new irq_desc for irq 2
> found new irq_desc for irq 3
> found new irq_desc for irq 4
> found new irq_desc for irq 5
> found new irq_desc for irq 6
> found new irq_desc for irq 7
> found new irq_desc for irq 8
> found new irq_desc for irq 9
> found new irq_desc for irq 10
> found new irq_desc for irq 11
> found new irq_desc for irq 12
> found new irq_desc for irq 13
> found new irq_desc for irq 14
> found new irq_desc for irq 15
> CPU 0 irqstacks, hard=c040e000 soft=c040d000
> PID hash table entries: 2048 (order: 11, 8192 bytes)
> TSC: PIT calibration confirmed by PMTIMER.
> TSC: using PIT calibration value
> Detected 1495.140 MHz processor.
> Console: colour dummy device 80x25
> console [tty0] enabled
> Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
> Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
> Memory: 515676k/524224k available (2047k kernel code, 8000k reserved, 852k data, 208k init, 0k highmem)
> virtual kernel memory layout:
>     fixmap  : 0xfffb9000 - 0xfffff000   ( 280 kB)
>     vmalloc : 0xe07f0000 - 0xfffb7000   ( 503 MB)
>     lowmem  : 0xc0000000 - 0xdfff0000   ( 511 MB)
>       .init : 0xc03d6000 - 0xc040a000   ( 208 kB)
>       .data : 0xc02ffd05 - 0xc03d4de0   ( 852 kB)
>       .text : 0xc0100000 - 0xc02ffd05   (2047 kB)
> Checking if this processor honours the WP bit even in supervisor mode...Ok.
> CPA: page pool initialized 1 of 1 pages preallocated
> Calibrating delay loop (skipped), value calculated using timer frequency.. 2990.28 BogoMIPS (lpj=5980560)
> Mount-cache hash table entries: 512
> CPU: L1 I cache: 32K, L1 D cache: 32K
> CPU: L2 cache: 2048K
> Intel machine check architecture supported.
> Intel machine check reporting enabled on CPU#0.
> CPU: Intel(R) Pentium(R) M processor 1.50GHz stepping 06
> Checking 'hlt' instruction... OK.
> Freeing SMP alternatives: 0k freed
> ACPI: Core revision 20080729
> ACPI: setting ELCR to 0200 (from 0c00)
> net_namespace: 612 bytes
> NET: Registered protocol family 16
> No dock devices found.
> ACPI: bus type pci registered
> PCI: PCI BIOS revision 2.10 entry at 0xe97a4, last bus=2
> PCI: Using configuration type 1 for base access
> ------------[ cut here ]------------
> WARNING: at fs/sysfs/dir.c:465 sysfs_add_one+0x27/0x2f()
> sysfs: duplicate filename 'acpi' can not be created
> Modules linked in:
> Pid: 1, comm: swapper Not tainted 2.6.27-rc5-next-20080905-04648-ge9f2a9c #223
>  [<c011c5a1>] warn_slowpath+0x5a/0x7b
>  [<c011663b>] update_curr+0x3d/0x5d
>  [<c011723d>] __dequeue_entity+0x1f/0x71
>  [<c01d0ba8>] idr_get_empty_slot+0x154/0x202
>  [<c01d0d35>] ida_get_new_above+0xdf/0x17b
>  [<c01912d8>] sysfs_ilookup_test+0x0/0xd
>  [<c016cee9>] ifind+0x15/0x8a
>  [<c01914d3>] sysfs_find_dirent+0x13/0x23
>  [<c019164c>] sysfs_add_one+0x27/0x2f
>  [<c0191ae8>] create_dir+0x3c/0x6b
>  [<c0191b40>] sysfs_create_dir+0x29/0x3b
>  [<c01d145a>] kobject_get+0xf/0x13
>  [<c01d1578>] kobject_add_internal+0xb8/0x151
>  [<c01d18ac>] kobject_init_and_add+0x23/0x25
>  [<c03e1e76>] kernel_param_sysfs_setup+0x4f/0x9f
>  [<c03e1fb5>] param_sysfs_init+0xef/0x141
>  [<c0101122>] _stext+0x3a/0x12a
>  [<c03e1ec6>] param_sysfs_init+0x0/0x141
>  [<c0117500>] __enqueue_entity+0xa8/0xe2
>  [<c0128dd3>] __create_workqueue_key+0x14d/0x162
>  [<c03d64ba>] kernel_init+0xec/0x150
>  [<c03d63ce>] kernel_init+0x0/0x150
>  [<c0103a47>] kernel_thread_helper+0x7/0x10
>  =======================
> ---[ end trace 4eaa2a86a8e2da22 ]---
> kobject_add_internal failed for acpi with -EEXIST, don't try to register things with the same name in the same directory.
> Pid: 1, comm: swapper Tainted: G        W 2.6.27-rc5-next-20080905-04648-ge9f2a9c #223
>  [<c01d1601>] kobject_add_internal+0x141/0x151
>  [<c01d18ac>] kobject_init_and_add+0x23/0x25
>  [<c03e1e76>] kernel_param_sysfs_setup+0x4f/0x9f
>  [<c03e1fb5>] param_sysfs_init+0xef/0x141
>  [<c0101122>] _stext+0x3a/0x12a
>  [<c03e1ec6>] param_sysfs_init+0x0/0x141
>  [<c0117500>] __enqueue_entity+0xa8/0xe2
>  [<c0128dd3>] __create_workqueue_key+0x14d/0x162
>  [<c03d64ba>] kernel_init+0xec/0x150
>  [<c03d63ce>] kernel_init+0x0/0x150
>  [<c0103a47>] kernel_thread_helper+0x7/0x10
>  =======================
> Module 'acpi' failed to be added to sysfs, error number -17
> The system will be unstable now.
> ACPI: EC: Look up EC in DSDT
> ACPI: Interpreter enabled
> ACPI: (supports S0 S1 S3 S5)
> ACPI: Using PIC for interrupt routing
> ACPI: EC: GPE = 0x1c, I/O: command/status = 0x66, data = 0x62
> ACPI: EC: driver started in poll mode
> ACPI: PCI Root Bridge [PCI0] (0000:00)
> pci 0000:00:1d.7: PME# supported from D0 D3hot D3cold
> pci 0000:00:1d.7: PME# disabled
> HPET not enabled in BIOS. You might try hpet=force boot option
> pci 0000:00:1f.0: quirk: region 1000-107f claimed by ICH4 ACPI/GPIO/TCO
> pci 0000:00:1f.0: quirk: region 1300-133f claimed by ICH4 GPIO
> pci 0000:00:1f.5: PME# supported from D0 D3hot D3cold
> pci 0000:00:1f.5: PME# disabled
> pci 0000:00:1f.6: PME# supported from D0 D3hot D3cold
> pci 0000:00:1f.6: PME# disabled
> pci 0000:01:00.0: supports D1 D2
> PCI: bridge 0000:00:01.0 io port: [c000, dfff]
> PCI: bridge 0000:00:01.0 32bit mmio: [e0000000, efffffff]
> PCI: bridge 0000:00:01.0 32bit mmio pref: [a0000000, afffffff]
> pci 0000:02:00.0: supports D2
> pci 0000:02:00.0: PME# supported from D2 D3hot D3cold
> pci 0000:02:00.0: PME# disabled
> pci 0000:02:01.0: supports D1 D2
> pci 0000:02:01.0: PME# supported from D1 D2 D3hot D3cold
> pci 0000:02:01.0: PME# disabled
> pci 0000:02:02.0: PME# supported from D0 D3hot D3cold
> pci 0000:02:02.0: PME# disabled
> pci 0000:02:03.0: supports D1 D2
> pci 0000:02:03.0: PME# supported from D0 D1 D2 D3hot D3cold
> pci 0000:02:03.0: PME# disabled
> pci 0000:00:1e.0: transparent bridge
> PCI: bridge 0000:00:1e.0 io port: [a000, bfff]
> PCI: bridge 0000:00:1e.0 32bit mmio: [d0000000, dfffffff]
> PCI: bridge 0000:00:1e.0 32bit mmio pref: [90000000, 9fffffff]
> bus 00 -> node 0
> ACPI: PCI Interrupt Routing Table [\_SB_.PCI0._PRT]
> ACPI: PCI Interrupt Routing Table [\_SB_.PCI0.AGPB._PRT]
> ACPI: PCI Interrupt Routing Table [\_SB_.PCI0.HUB_._PRT]
> ACPI: PCI Interrupt Link [LNKA] (IRQs 5 *10)
> ACPI: PCI Interrupt Link [LNKB] (IRQs 5 10) *11
> ACPI: PCI Interrupt Link [LNKC] (IRQs 5 10) *11
> ACPI: PCI Interrupt Link [LNKD] (IRQs 5 10) *11
> ACPI: PCI Interrupt Link [LNKE] (IRQs 3 4 5 7 10 11 12 14 15) *0, disabled.
> ACPI: PCI Interrupt Link [LNKF] (IRQs 3 4 5 7 10 11 12 14 15) *0, disabled.
> ACPI: PCI Interrupt Link [LNKG] (IRQs 3 4 5 7 10 11 12 14 15) *0, disabled.
> ACPI: PCI Interrupt Link [LNKH] (IRQs 5 10) *11
> Linux Plug and Play Support v0.97 (c) Adam Belay
> pnp: PnP ACPI init
> ACPI: bus type pnp registered
> pnp: PnP ACPI: found 10 devices
> ACPI: ACPI bus type pnp unregistered
> SCSI subsystem initialized
> libata version 3.00 loaded.
> usbcore: registered new interface driver usbfs
> usbcore: registered new interface driver hub
> usbcore: registered new device driver usb
> PCI: Using ACPI for IRQ routing
> pci 0000:02:03.0: BAR 0: can't allocate resource
> system 00:01: ioport range 0x1000-0x107f has been reserved
> system 00:01: ioport range 0x1300-0x133f has been reserved
> system 00:01: ioport range 0x200-0x20f has been reserved
> system 00:01: ioport range 0x4d0-0x4d1 has been reserved
> system 00:01: ioport range 0xfe00-0xfe00 has been reserved
> system 00:01: ioport range 0xff2c-0xff2f has been reserved
> system 00:01: iomem range 0xfff80000-0xffffffff could not be reserved
> pci 0000:00:01.0: PCI bridge, secondary bus 0000:01
> pci 0000:00:01.0:   IO window: 0xc000-0xdfff
> pci 0000:00:01.0:   MEM window: 0xe0000000-0xefffffff
> pci 0000:00:01.0:   PREFETCH window: 0x000000a0000000-0x000000afffffff
> pci 0000:02:03.0: CardBus bridge, secondary bus 0000:03
> pci 0000:02:03.0:   IO window: 0x00a400-0x00a4ff
> pci 0000:02:03.0:   IO window: 0x00a800-0x00a8ff
> pci 0000:02:03.0:   PREFETCH window: 0x90000000-0x93ffffff
> pci 0000:02:03.0:   MEM window: 0xd4000000-0xd7ffffff
> pci 0000:00:1e.0: PCI bridge, secondary bus 0000:02
> pci 0000:00:1e.0:   IO window: 0xa000-0xbfff
> pci 0000:00:1e.0:   MEM window: 0xd0000000-0xdfffffff
> pci 0000:00:1e.0:   PREFETCH window: 0x00000090000000-0x0000009fffffff
> pci 0000:00:1e.0: setting latency timer to 64
> ACPI: PCI Interrupt Link [LNKC] enabled at IRQ 10
> PCI: setting IRQ 10 as level-triggered
> pci 0000:02:03.0: PCI INT A -> Link[LNKC] -> GSI 10 (level, low) -> IRQ 10
> bus: 00 index 0 io port: [0, ffff]
> bus: 00 index 1 mmio: [0, ffffffff]
> bus: 01 index 0 io port: [c000, dfff]
> bus: 01 index 1 mmio: [e0000000, efffffff]
> bus: 01 index 2 mmio: [a0000000, afffffff]
> bus: 01 index 3 mmio: [0, 0]
> bus: 02 index 0 io port: [a000, bfff]
> bus: 02 index 1 mmio: [d0000000, dfffffff]
> bus: 02 index 2 mmio: [90000000, 9fffffff]
> bus: 02 index 3 io port: [0, ffff]
> bus: 02 index 4 mmio: [0, ffffffff]
> bus: 03 index 0 io port: [a400, a4ff]
> bus: 03 index 1 io port: [a800, a8ff]
> bus: 03 index 2 mmio: [90000000, 93ffffff]
> bus: 03 index 3 mmio: [d4000000, d7ffffff]
> NET: Registered protocol family 2
> IP route cache hash table entries: 4096 (order: 2, 16384 bytes)
> TCP established hash table entries: 16384 (order: 5, 131072 bytes)
> TCP bind hash table entries: 16384 (order: 4, 65536 bytes)
> TCP: Hash tables configured (established 16384 bind 16384)
> TCP reno registered
> NET: Registered protocol family 1
> pci 0000:01:00.0: Boot video device
> ACPI: Battery Slot [BAT1] (battery present)
> input: Power Button (FF) as /class/input/input0
> ACPI: Power Button (FF) [PWRF]
> ACPI Error (evxfevnt-0186): Could not enable SleepButton event [20080729]
> ACPI Warning (evxface-0145): Could not enable fixed event 3 [20080729]
> input: Lid Switch as /class/input/input1
> ACPI: Lid Switch [LID]
> input: Power Button (CM) as /class/input/input2
> ACPI: Power Button (CM) [PWRB]
> Simple Boot Flag at 0x37 set to 0x1
> Machine check exception polling timer started.
> alg: cipher: Test 1 failed on encryption for aes-asm
> 00000000: 00 01 02 03 04 05 06 07 08 08 08 08 08 08 08 08 
> audit: initializing netlink socket (disabled)
> type=2000 audit(1220653912.172:1): initialized
> HugeTLB registered 4 MB page size, pre-allocated 0 pages
> fuse init (API version 7.9)
> msgmni has been set to 1007
> alg: No test for stdrng (krng)
> io scheduler noop registered
> io scheduler anticipatory registered (default)
> io scheduler deadline registered
> io scheduler cfq registered
> vesafb: framebuffer at 0xa8000000, mapped to 0xe0880000, using 4608k, total 65536k
> vesafb: mode is 1024x768x24, linelength=3072, pages=27
> vesafb: protected mode interface info at c000:5673
> vesafb: pmi: set display start = c00c56e1, set palette = c00c571b
> vesafb: pmi: ports = c010 c016 c054 c038 c03c c05c c000 c004 c0b0 c0b2 c0b4 
> vesafb: scrolling: redraw
> vesafb: Truecolor: size=0:8:8:8, shift=0:16:8:0
> Console: switching to colour frame buffer device 128x48
> fb0: VESA VGA frame buffer device
> ACPI: AC Adapter [ACAD] (off-line)
> ACPI: CPU0 (power states: C1[C1] C2[C2] C3[C3] C4[C3])
> processor ACPI0007:00: registered as cooling_device0
> ACPI: Processor [CPU0] (supports 8 throttling states)
> isapnp: Scanning for PnP cards...
> isapnp: No Plug & Play device found
> Real Time Clock Driver v1.12ac
> Linux agpgart interface v0.103
> agpgart-intel 0000:00:00.0: Intel 855PM Chipset
> agpgart-intel 0000:00:00.0: AGP aperture is 64M @ 0xb0000000
> Serial: 8250/16550 driver4 ports, IRQ sharing enabled
> Switched to NOHz mode on CPU #0
> serial8250: ttyS1 at I/O 0x2f8 (irq = 0) is a 16550A
> ACPI: PCI Interrupt Link [LNKB] enabled at IRQ 10
> serial 0000:00:1f.6: PCI INT B -> Link[LNKB] -> GSI 10 (level, low) -> IRQ 10
> serial 0000:00:1f.6: PCI INT B disabled
> 8139too Fast Ethernet driver 0.9.28
> ACPI: PCI Interrupt Link [LNKD] enabled at IRQ 10
> 8139too 0000:02:01.0: PCI INT A -> Link[LNKD] -> GSI 10 (level, low) -> IRQ 10
> eth0: RealTek RTL8139 at 0xa000, 00:02:3f:18:5a:a6, IRQ 10
> eth0:  Identified 8139 chip type 'RTL-8100B/8139D'
> Uniform Multi-Platform E-IDE driver
> piix 0000:00:1f.1: IDE controller (0x8086:0x24ca rev 0x03)
> pci 0000:00:1f.1: enabling device (0005 -> 0007)
> pci 0000:00:1f.1: PCI INT A -> Link[LNKC] -> GSI 10 (level, low) -> IRQ 10
> piix 0000:00:1f.1: not 100% native mode: will probe irqs later
>     ide0: BM-DMA at 0x1100-0x1107
>     ide1: BM-DMA at 0x1108-0x110f
> Probing IDE interface ide0...
> hda: IC25N060ATMR04-0, ATA DISK drive
> hda: host max PIO4 wanted PIO255(auto-tune) selected PIO4
> hda: UDMA/100 mode selected
> Probing IDE interface ide1...
> hdc: TOSHIBA ODD-DVD SD-R6372, ATAPI CD/DVD-ROM drive
> hdc: host max PIO4 wanted PIO255(auto-tune) selected PIO4
> hdc: UDMA/33 mode selected
> ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
> ide1 at 0x170-0x177,0x376 on irq 15
> ide_generic: please use "probe_mask=0x3f" module parameter for probing all legacy ISA IDE ports
> hda: max request size: 512KiB
> hda: 117210240 sectors (60011 MB) w/7884KiB Cache, CHS=16383/255/63
> hda: cache flushes supported
>  hda: hda1 hda2 hda3 hda4 < hda5 hda6 >
> Driver 'sd' needs updating - please use bus_type methods
> Driver 'sr' needs updating - please use bus_type methods
> PNP: PS/2 Controller [PNP0303:KBC0,PNP0f13:MSE0] at 0x60,0x64 irq 1,12
> i8042.c: Detected active multiplexing controller, rev 1.1.
> serio: i8042 KBD port at 0x60,0x64 irq 1
> serio: i8042 AUX0 port at 0x60,0x64 irq 12
> serio: i8042 AUX1 port at 0x60,0x64 irq 12
> serio: i8042 AUX2 port at 0x60,0x64 irq 12
> serio: i8042 AUX3 port at 0x60,0x64 irq 12
> mice: PS/2 mouse device common for all mice
> input: AT Translated Set 2 keyboard as /class/input/input3
> device-mapper: ioctl: 4.14.0-ioctl (2008-04-23) initialised: [email-masked]
> cpuidle: using governor ladder
> cpuidle: using governor menu
> usbcore: registered new interface driver usbhid
> usbhid: v2.6:USB HID core driver
> ip_tables: (C) 2000-2006 Netfilter Core Team
> TCP bic registered
> NET: Registered protocol family 17
> NET: Registered protocol family 15
> ieee80211: 802.11 data/management/control stack, git-1.1.13
> ieee80211: Copyright (C) 2004-2005 Intel Corporation <[email-masked]>
> ieee80211_crypt: registered algorithm 'NULL'
> ieee80211_crypt: registered algorithm 'WEP'
> IO APIC resources could be not be allocated.
> Using IPI Shortcut mode
> Marking TSC unstable due to TSC halts in idle
> Clocksource tsc unstable (delta = -77171083 ns)
> Synaptics Touchpad, model: 1, fw: 5.9, id: 0x254ab1, caps: 0x804713/0x0
> input: SynPS/2 Synaptics TouchPad as /class/input/input4
> EXT3-fs: INFO: recovery required on readonly filesystem.
> EXT3-fs: write access will be enabled during recovery.
> kjournald starting.  Commit interval 5 seconds
> EXT3-fs: recovery complete.
> EXT3-fs: mounted filesystem with ordered data mode.
> VFS: Mounted root (ext3 filesystem) readonly.
> Freeing unused kernel memory: 208k freed
> USB Universal Host Controller Interface driver v3.0
> ACPI: PCI Interrupt Link [LNKA] enabled at IRQ 10
> uhci_hcd 0000:00:1d.0: PCI INT A -> Link[LNKA] -> GSI 10 (level, low) -> IRQ 10
> uhci_hcd 0000:00:1d.0: setting latency timer to 64
> uhci_hcd 0000:00:1d.0: UHCI Host Controller
> uhci_hcd 0000:00:1d.0: new USB bus registered, assigned bus number 1
> uhci_hcd 0000:00:1d.0: irq 10, io base 0x00001200
> usb usb1: configuration #1 chosen from 1 choice
> hub 1-0:1.0: USB hub found
> hub 1-0:1.0: 2 ports detected
> uhci_hcd 0000:00:1d.1: PCI INT B -> Link[LNKD] -> GSI 10 (level, low) -> IRQ 10
> uhci_hcd 0000:00:1d.1: setting latency timer to 64
> uhci_hcd 0000:00:1d.1: UHCI Host Controller
> uhci_hcd 0000:00:1d.1: new USB bus registered, assigned bus number 2
> uhci_hcd 0000:00:1d.1: irq 10, io base 0x00001600
> usb usb2: configuration #1 chosen from 1 choice
> hub 2-0:1.0: USB hub found
> hub 2-0:1.0: 2 ports detected
> ACPI: PCI Interrupt Link [LNKH] enabled at IRQ 10
> ehci_hcd 0000:00:1d.7: PCI INT D -> Link[LNKH] -> GSI 10 (level, low) -> IRQ 10
> ehci_hcd 0000:00:1d.7: setting latency timer to 64
> ehci_hcd 0000:00:1d.7: EHCI Host Controller
> ehci_hcd 0000:00:1d.7: new USB bus registered, assigned bus number 3
> ehci_hcd 0000:00:1d.7: debug port 1
> ehci_hcd 0000:00:1d.7: cache line size of 32 is not supported
> ehci_hcd 0000:00:1d.7: irq 10, io mem 0xf4000000
> ehci_hcd 0000:00:1d.7: USB 2.0 started, EHCI 1.00, driver 10 Dec 2004
> usb usb3: configuration #1 chosen from 1 choice
> hub 3-0:1.0: USB hub found
> hub 3-0:1.0: 6 ports detected
> parport_pc 00:09: reported by Plug and Play ACPI
> parport0: PC-style at 0x378, irq 7 [PCSPP,TRISTATE,EPP]
> ipw2200: Intel(R) PRO/Wireless 2200/2915 Network Driver, 1.2.2k
> ipw2200: Copyright(c) 2003-2006 Intel Corporation
> uhci_hcd 0000:00:1d.2: PCI INT C -> Link[LNKC] -> GSI 10 (level, low) -> IRQ 10
> uhci_hcd 0000:00:1d.2: setting latency timer to 64
> uhci_hcd 0000:00:1d.2: UHCI Host Controller
> uhci_hcd 0000:00:1d.2: new USB bus registered, assigned bus number 4
> uhci_hcd 0000:00:1d.2: irq 10, io base 0x00001700
> usb usb4: configuration #1 chosen from 1 choice
> hub 4-0:1.0: USB hub found
> hub 4-0:1.0: 2 ports detected
> hdc: ATAPI 24X DVD-ROM DVD-R CD-R/RW drive, 2048kB Cache
> Uniform CD-ROM driver Revision: 3.20
> ppdev: user-space parallel port driver
> yenta_cardbus 0000:02:03.0: CardBus bridge found [1025:005a]
> yenta_cardbus 0000:02:03.0: Using CSCINT to route CSC interrupts to PCI
> yenta_cardbus 0000:02:03.0: Routing CardBus interrupts to PCI
> yenta_cardbus 0000:02:03.0: TI: mfunc 0x001c1112, devctl 0x44
> yenta_cardbus 0000:02:03.0: ISA IRQ mask 0x0860, PCI irq 10
> yenta_cardbus 0000:02:03.0: Socket status: 30000006
> yenta_cardbus 0000:02:03.0: pcmcia: parent PCI bridge I/O window: 0xa000 - 0xbfff
>  : cs: IO port probe 0xa000-0xbfff: clean.
> yenta_cardbus 0000:02:03.0: pcmcia: parent PCI bridge Memory window: 0xd0000000 - 0xdfffffff
> yenta_cardbus 0000:02:03.0: pcmcia: parent PCI bridge Memory window: 0x90000000 - 0x9fffffff
> ipw2200 0000:02:02.0: power state changed by ACPI to D0
> ipw2200 0000:02:02.0: PCI INT A -> Link[LNKC] -> GSI 10 (level, low) -> IRQ 10
> ipw2200: Detected Intel PRO/Wireless 2200BG Network Connection
> firmware: requesting ipw2200-bss.fw
> ipw2200: Radio Frequency Kill Switch is On:
> Kill switch must be turned off for wireless networking to work.
> ipw2200: Detected geography ZZM (11 802.11bg channels, 0 802.11a channels)
> Intel ICH Modem 0000:00:1f.6: PCI INT B -> Link[LNKB] -> GSI 10 (level, low) -> IRQ 10
> Intel ICH Modem 0000:00:1f.6: setting latency timer to 64
> Intel ICH 0000:00:1f.5: PCI INT B -> Link[LNKB] -> GSI 10 (level, low) -> IRQ 10
> Intel ICH 0000:00:1f.5: setting latency timer to 64
> pcmcia_socket pcmcia_socket0: cs: IO port probe 0x100-0x3af: excluding 0x230-0x237
> pcmcia_socket pcmcia_socket0: cs: IO port probe 0x3e0-0x4ff: clean.
> pcmcia_socket pcmcia_socket0: cs: IO port probe 0x820-0x8ff: clean.
> pcmcia_socket pcmcia_socket0: cs: IO port probe 0xc00-0xcf7: clean.
> pcmcia_socket pcmcia_socket0: cs: IO port probe 0xa00-0xaff: clean.
> intel8x0_measure_ac97_clock: measured 54490 usecs
> intel8x0: clocking to 48000
> EXT3 FS on hda1, internal journal
> nf_conntrack version 0.5.0 (8192 buckets, 32768 max)
> warning: `dbus-daemon' uses deprecated v2 capabilities in a way that may be insecure.
> ACPI: EC: non-query interrupt received, switching to interrupt mode
> ACPI: EC: GPE storm detected, disabling EC GPE
> [drm] Initialized drm 1.1.0 20060810
> pci 0000:01:00.0: PCI INT A -> Link[LNKA] -> GSI 10 (level, low) -> IRQ 10
> [drm] Initialized radeon 1.29.0 20080528 on minor 0
> agpgart-intel 0000:00:00.0: AGP 2.0 bridge
> agpgart-intel 0000:00:00.0: putting AGP V2 device into 4x mode
> pci 0000:01:00.0: putting AGP V2 device into 4x mode
> [drm] Setting GART location based on new memory map
> [drm] Loading R300 Microcode
> [drm] Num pipes: 1
> [drm] writeback test succeeded in 1 usecs
> evdev.c(EVIOCGBIT): Suspicious buffer size 511, limiting output to 64 bytes. See http://userweb.kernel.org/~dtor/eviocgbit-bug.html
> [drm] Num pipes: 1
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email-masked]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

ACPI: EC: do transaction from interrupt context

From: Alexey Starikovskiy <[email-masked]>

It is easier and faster to do transaction directly from interrupt context
rather than waking control thread.
Also, cleaner GPE storm avoidance is implemented.

Signed-off-by: Alexey Starikovskiy <[email-masked]>
---

 drivers/acpi/ec.c |  288 ++++++++++++++++++++++++++---------------------------
 1 files changed, 139 insertions(+), 149 deletions(-)

diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 13593f9..97168d4 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -1,7 +1,7 @@
 /*
- *  ec.c - ACPI Embedded Controller Driver (v2.0)
+ *  ec.c - ACPI Embedded Controller Driver (v2.1)
  *
- *  Copyright (C) 2006, 2007 Alexey Starikovskiy <[email-masked]>
+ *  Copyright (C) 2006-2008 Alexey Starikovskiy <[email-masked]>
  *  Copyright (C) 2006 Denis Sadykov <[email-masked]>
  *  Copyright (C) 2004 Luming Yu <[email-masked]>
  *  Copyright (C) 2001, 2002 Andy Grover <[email-masked]>
@@ -26,8 +26,8 @@
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
-/* Uncomment next line to get verbose print outs*/
-/* #define DEBUG */
+/* Uncomment next line to get verbose printout */
+#define DEBUG
 
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -38,6 +38,7 @@
 #include <linux/seq_file.h>
 #include <linux/interrupt.h>
 #include <linux/list.h>
+#include <linux/spinlock.h>
 #include <asm/io.h>
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
@@ -65,22 +66,18 @@ enum ec_command {
 	ACPI_EC_COMMAND_QUERY = 0x84,
 };
 
-/* EC events */
-enum ec_event {
-	ACPI_EC_EVENT_OBF_1 = 1,	/* Output buffer full */
-	ACPI_EC_EVENT_IBF_0,		/* Input buffer empty */
-};
-
 #define ACPI_EC_DELAY		500	/* Wait 500ms max. during EC ops */
 #define ACPI_EC_UDELAY_GLK	1000	/* Wait 1ms max. to get global lock */
 #define ACPI_EC_UDELAY		100	/* Wait 100us before polling EC again */
 
+#define ACPI_EC_STORM_THRESHOLD 20	/* number of false interrupts
+					   per one transaction */
+
 enum {
-	EC_FLAGS_WAIT_GPE = 0,		/* Don't check status until GPE arrives */
 	EC_FLAGS_QUERY_PENDING,		/* Query is pending */
 	EC_FLAGS_GPE_MODE,		/* Expect GPE to be sent for status change */
 	EC_FLAGS_NO_GPE,		/* Don't use GPE mode */
-	EC_FLAGS_RESCHEDULE_POLL	/* Re-schedule poll */
+	EC_FLAGS_GPE_STORM		/* GPE storm detected */
 };
 
 /* If we find an EC via the ECDT, we need to keep a ptr to its context */
@@ -95,6 +92,14 @@ struct acpi_ec_query_handler {
 	u8 query_bit;
 };
 
+struct transaction_data {
+	const u8 *wdata;
+	u8 *rdata;
+	u8 command;
+	u8 wlen;
+	u8 rlen;
+};
+
 static struct acpi_ec {
 	acpi_handle handle;
 	unsigned long gpe;
@@ -105,7 +110,8 @@ static struct acpi_ec {
 	struct mutex lock;
 	wait_queue_head_t wait;
 	struct list_head list;
-	struct delayed_work work;
+	struct transaction_data t;
+	spinlock_t spinlock;
 	atomic_t irq_count;
 	u8 handlers_installed;
 } *boot_ec, *first_ec;
@@ -150,13 +156,26 @@ static inline u8 acpi_ec_read_data(struct acpi_ec *ec)
 {
 	u8 x = inb(ec->data_addr);
 	pr_debug(PREFIX "---> data = 0x%2.2x\n", x);
-	return inb(ec->data_addr);
+	return x;
 }
 
 static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command)
 {
+	unsigned long flags;
 	pr_debug(PREFIX "<--- command = 0x%2.2x\n", command);
-	outb(command, ec->command_addr);
+	spin_lock_irqsave(&ec->spinlock, flags);
+	outb((ec->t.command = command), ec->command_addr);
+	spin_unlock_irqrestore(&ec->spinlock, flags);
+}
+
+static inline u8 ec_read_command(struct acpi_ec *ec)
+{
+	unsigned long flags;
+	u8 cmd;
+	spin_lock_irqsave(&ec->spinlock, flags);
+	cmd = ec->t.command;
+	spin_unlock_irqrestore(&ec->spinlock, flags);
+	return cmd;
 }
 
 static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data)
@@ -165,69 +184,61 @@ static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data)
 	outb(data, ec->data_addr);
 }
 
-static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event)
+static int ec_transaction_done(struct acpi_ec *ec)
 {
-	if (test_bit(EC_FLAGS_WAIT_GPE, &ec->flags))
-		return 0;
-	if (event == ACPI_EC_EVENT_OBF_1) {
-		if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_OBF)
-			return 1;
-	} else if (event == ACPI_EC_EVENT_IBF_0) {
-		if (!(acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF))
-			return 1;
-	}
-
+	if (!ec_read_command(ec))
+		return 1;
+	if (!ec->t.wlen && !ec->t.rlen)
+		return 1;
 	return 0;
 }
 
-static void ec_schedule_ec_poll(struct acpi_ec *ec)
+static void gpe_transaction(struct acpi_ec *ec, u8 status)
 {
-	if (test_bit(EC_FLAGS_RESCHEDULE_POLL, &ec->flags))
-		schedule_delayed_work(&ec->work,
-				      msecs_to_jiffies(ACPI_EC_DELAY));
+	if (!ec_read_command(ec))
+		return;
+	if (ec->t.wlen > 0) {
+		if ((status & ACPI_EC_FLAG_IBF) == 0) {
+			acpi_ec_write_data(ec, *(ec->t.wdata++));
+			--ec->t.wlen;
+		} else
+			/* false interrupt, state didn't change */
+			atomic_inc(&ec->irq_count);
+
+	} else if (ec->t.rlen > 0) {
+		if ((status & ACPI_EC_FLAG_OBF) == 1) {
+			*(ec->t.rdata++) = acpi_ec_read_data(ec);
+			--ec->t.rlen;
+		} else
+			/* false interrupt, state didn't change */
+			atomic_inc(&ec->irq_count);
+	}
 }
 
-static void ec_switch_to_poll_mode(struct acpi_ec *ec)
+static int acpi_ec_wait(struct acpi_ec *ec)
 {
+	if (wait_event_timeout(ec->wait, ec_transaction_done(ec),
+			       msecs_to_jiffies(ACPI_EC_DELAY)))
+		return 0;
+	/* missing GPEs, switch back to poll mode */
+	if (printk_ratelimit())
+		pr_info(PREFIX "missing confirmations, "
+				"switch off interrupt mode.\n");
 	set_bit(EC_FLAGS_NO_GPE, &ec->flags);
 	clear_bit(EC_FLAGS_GPE_MODE, &ec->flags);
-	acpi_disable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
-	set_bit(EC_FLAGS_RESCHEDULE_POLL, &ec->flags);
+	return 1;
 }
 
-static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll)
+static void acpi_ec_gpe_query(void *ec_cxt);
+
+static int ec_check_sci(struct acpi_ec *ec, u8 state)
 {
-	atomic_set(&ec->irq_count, 0);
-	if (likely(test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) &&
-	    likely(!force_poll)) {
-		if (wait_event_timeout(ec->wait, acpi_ec_check_status(ec, event),
-				       msecs_to_jiffies(ACPI_EC_DELAY)))
-			return 0;
-		clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
-		if (acpi_ec_check_status(ec, event)) {
-			/* missing GPEs, switch back to poll mode */
-			if (printk_ratelimit())
-				pr_info(PREFIX "missing confirmations, "
-						"switch off interrupt mode.\n");
-			ec_switch_to_poll_mode(ec);
-			ec_schedule_ec_poll(ec);
-			return 0;
-		}
-	} else {
-		unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY);
-		clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
-		while (time_before(jiffies, delay)) {
-			if (acpi_ec_check_status(ec, event))
-				return 0;
-			msleep(1);
-		}
-		if (acpi_ec_check_status(ec,event))
-			return 0;
+	if (state & ACPI_EC_FLAG_SCI) {
+		if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags))
+			return acpi_os_execute(OSL_EC_BURST_HANDLER,
+				acpi_ec_gpe_query, ec);
 	}
-	pr_err(PREFIX "acpi_ec_wait timeout, status = 0x%2.2x, event = %s\n",
-		acpi_ec_read_status(ec),
-		(event == ACPI_EC_EVENT_OBF_1) ? "\"b0=1\"" : "\"b1=0\"");
-	return -ETIME;
+	return 0;
 }
 
 static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
@@ -235,45 +246,54 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
 					u8 * rdata, unsigned rdata_len,
 					int force_poll)
 {
-	int result = 0;
-	set_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
+	unsigned long delay;
 	pr_debug(PREFIX "transaction start\n");
-	acpi_ec_write_cmd(ec, command);
-	for (; wdata_len > 0; --wdata_len) {
-		result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll);
-		if (result) {
-			pr_err(PREFIX
-			       "write_cmd timeout, command = %d\n", command);
-			goto end;
-		}
-		set_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
-		acpi_ec_write_data(ec, *(wdata++));
+	/* disable GPE during transaction if storm is detected */
+	if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) {
+		set_bit(EC_FLAGS_NO_GPE, &ec->flags);
+		clear_bit(EC_FLAGS_GPE_MODE, &ec->flags);
+		acpi_disable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
 	}
-
-	if (!rdata_len) {
-		result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll);
-		if (result) {
-			pr_err(PREFIX
-			       "finish-write timeout, command = %d\n", command);
-			goto end;
-		}
-	} else if (command == ACPI_EC_COMMAND_QUERY)
-		clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
-
-	for (; rdata_len > 0; --rdata_len) {
-		result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1, force_poll);
-		if (result) {
-			pr_err(PREFIX "read timeout, command = %d\n", command);
-			goto end;
+	atomic_set(&ec->irq_count, 0);
+	/* fill in transaction structure */
+	ec->t.wdata = wdata;
+	ec->t.wlen = wdata_len;
+	ec->t.rdata = rdata;
+	ec->t.rlen = rdata_len;
+	/* start transaction */
+	acpi_ec_write_cmd(ec, command);
+	/* if we selected poll mode or failed in GPE-mode do a poll loop */
+	if (force_poll ||
+	    !test_bit(EC_FLAGS_GPE_MODE, &ec->flags) ||
+	    acpi_ec_wait(ec)) {
+		delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY);
+		while (time_before(jiffies, delay)) {
+			gpe_transaction(ec, acpi_ec_read_status(ec));
+			msleep(1);
+			if (ec_transaction_done(ec))
+				goto end;
 		}
-		/* Don't expect GPE after last read */
-		if (rdata_len > 1)
-			set_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
-		*(rdata++) = acpi_ec_read_data(ec);
 	}
-      end:
+end:
 	pr_debug(PREFIX "transaction end\n");
-	return result;
+	ec->t.command = 0;
+	if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) {
+		/* check if we received SCI during transaction */
+		ec_check_sci(ec, acpi_ec_read_status(ec));
+		/* it is safe to enable GPE outside of transaction */
+		acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
+	} else if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags) &&
+		   atomic_read(&ec->irq_count) > ACPI_EC_STORM_THRESHOLD) {
+		pr_debug(PREFIX "GPE storm detected\n");
+		set_bit(EC_FLAGS_GPE_STORM, &ec->flags);
+	}
+	return 0;
+}
+
+static int ec_check_ibf0(struct acpi_ec *ec)
+{
+	u8 status = acpi_ec_read_status(ec);
+	return (status & ACPI_EC_FLAG_IBF) == 0;
 }
 
 static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
@@ -283,40 +303,34 @@ static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
 {
 	int status;
 	u32 glk;
-
 	if (!ec || (wdata_len && !wdata) || (rdata_len && !rdata))
 		return -EINVAL;
-
 	if (rdata)
 		memset(rdata, 0, rdata_len);
-
 	mutex_lock(&ec->lock);
 	if (ec->global_lock) {
 		status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
 		if (ACPI_FAILURE(status)) {
-			mutex_unlock(&ec->lock);
-			return -ENODEV;
+			status = -ENODEV;
+			goto unlock;
 		}
 	}
-
-	status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, 0);
-	if (status) {
+	if (!wait_event_timeout(ec->wait, ec_check_ibf0(ec),
+				msecs_to_jiffies(ACPI_EC_DELAY))) {
 		pr_err(PREFIX "input buffer is not empty, "
 				"aborting transaction\n");
+		status = -ETIME;
 		goto end;
 	}
-
 	status = acpi_ec_transaction_unlocked(ec, command,
 					      wdata, wdata_len,
 					      rdata, rdata_len,
 					      force_poll);
-
-      end:
-
+end:
 	if (ec->global_lock)
 		acpi_release_global_lock(glk);
+unlock:
 	mutex_unlock(&ec->lock);
-
 	return status;
 }
 
@@ -332,7 +346,9 @@ int acpi_ec_burst_enable(struct acpi_ec *ec)
 
 int acpi_ec_burst_disable(struct acpi_ec *ec)
 {
-	return acpi_ec_transaction(ec, ACPI_EC_BURST_DISABLE, NULL, 0, NULL, 0, 0);
+	return (acpi_ec_read_status(ec) & ACPI_EC_FLAG_BURST)?
+		acpi_ec_transaction(ec, ACPI_EC_BURST_DISABLE,
+			NULL, 0, NULL, 0, 0) : 0;
 }
 
 static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 * data)
@@ -437,6 +453,7 @@ static int acpi_ec_query(struct acpi_ec *ec, u8 * data)
 	 */
 
 	result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1, 0);
+	clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
 	if (result)
 		return result;
 
@@ -515,24 +532,17 @@ static u32 acpi_ec_gpe_handler(void *data)
 {
 	acpi_status status = AE_OK;
 	struct acpi_ec *ec = data;
-	u8 state = acpi_ec_read_status(ec);
+	u8 state;
 
 	pr_debug(PREFIX "~~~> interrupt\n");
-	atomic_inc(&ec->irq_count);
-	if (atomic_read(&ec->irq_count) > 5) {
-		pr_err(PREFIX "GPE storm detected, disabling EC GPE\n");
-		ec_switch_to_poll_mode(ec);
-		goto end;
-	}
-	clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
-	if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))
+	state = acpi_ec_read_status(ec);
+
+	gpe_transaction(ec, state);
+	if ((status & ACPI_EC_FLAG_IBF) == 0)
 		wake_up(&ec->wait);
 
-	if (state & ACPI_EC_FLAG_SCI) {
-		if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags))
-			status = acpi_os_execute(OSL_EC_BURST_HANDLER,
-				acpi_ec_gpe_query, ec);
-	} else if (!test_bit(EC_FLAGS_GPE_MODE, &ec->flags) &&
+	status = ec_check_sci(ec, state);
+	if (!test_bit(EC_FLAGS_GPE_MODE, &ec->flags) &&
 		   !test_bit(EC_FLAGS_NO_GPE, &ec->flags) &&
 		   in_interrupt()) {
 		/* this is non-query, must be confirmation */
@@ -540,21 +550,11 @@ static u32 acpi_ec_gpe_handler(void *data)
 			pr_info(PREFIX "non-query interrupt received,"
 				" switching to interrupt mode\n");
 		set_bit(EC_FLAGS_GPE_MODE, &ec->flags);
-		clear_bit(EC_FLAGS_RESCHEDULE_POLL, &ec->flags);
 	}
-end:
-	ec_schedule_ec_poll(ec);
 	return ACPI_SUCCESS(status) ?
 	    ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
 }
 
-static void do_ec_poll(struct work_struct *work)
-{
-	struct acpi_ec *ec = container_of(work, struct acpi_ec, work.work);
-	atomic_set(&ec->irq_count, 0);
-	(void)acpi_ec_gpe_handler(ec);
-}
-
 /* --------------------------------------------------------------------------
                              Address Space Management
    -------------------------------------------------------------------------- */
@@ -696,8 +696,8 @@ static struct acpi_ec *make_acpi_ec(void)
 	mutex_init(&ec->lock);
 	init_waitqueue_head(&ec->wait);
 	INIT_LIST_HEAD(&ec->list);
-	INIT_DELAYED_WORK_DEFERRABLE(&ec->work, do_ec_poll);
 	atomic_set(&ec->irq_count, 0);
+	spin_lock_init(&ec->spinlock);
 	return ec;
 }
 
@@ -736,15 +736,8 @@ ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval)
 	return AE_CTRL_TERMINATE;
 }
 
-static void ec_poll_stop(struct acpi_ec *ec)
-{
-	clear_bit(EC_FLAGS_RESCHEDULE_POLL, &ec->flags);
-	cancel_delayed_work(&ec->work);
-}
-
 static void ec_remove_handlers(struct acpi_ec *ec)
 {
-	ec_poll_stop(ec);
 	if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle,
 				ACPI_ADR_SPACE_EC, &acpi_ec_space_handler)))
 		pr_err(PREFIX "failed to remove space handler\n");
@@ -849,14 +842,12 @@ static int ec_install_handlers(struct acpi_ec *ec)
 	if (ec->handlers_installed)
 		return 0;
 	status = acpi_install_gpe_handler(NULL, ec->gpe,
-					  ACPI_GPE_EDGE_TRIGGERED,
-					  &acpi_ec_gpe_handler, ec);
+				  ACPI_GPE_EDGE_TRIGGERED,
+				  &acpi_ec_gpe_handler, ec);
 	if (ACPI_FAILURE(status))
 		return -ENODEV;
-
 	acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
 	acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
-
 	status = acpi_install_address_space_handler(ec->handle,
 						    ACPI_ADR_SPACE_EC,
 						    &acpi_ec_space_handler,
@@ -887,7 +878,6 @@ static int acpi_ec_start(struct acpi_device *device)
 
 	/* EC is fully operational, allow queries */
 	clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
-	ec_schedule_ec_poll(ec);
 	return ret;
 }