aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.mailmap1
-rw-r--r--Documentation/DocBook/device-drivers.tmpl4
-rw-r--r--Documentation/kernel-parameters.txt4
-rw-r--r--MAINTAINERS22
-rw-r--r--arch/arm/include/asm/hardware/sp810.h6
-rw-r--r--arch/arm/include/asm/memory.h2
-rw-r--r--arch/arm/kernel/smp_twd.c7
-rw-r--r--arch/arm/mach-ep93xx/gpio.c7
-rw-r--r--arch/arm/mach-omap1/Kconfig2
-rw-r--r--arch/arm/mach-omap1/Makefile3
-rw-r--r--arch/arm/mach-omap1/time.c101
-rw-r--r--arch/arm/mach-omap1/timer32k.c13
-rw-r--r--arch/arm/mach-omap2/board-cm-t3517.c29
-rw-r--r--arch/arm/mach-omap2/board-devkit8000.c3
-rw-r--r--arch/arm/mach-omap2/clock44xx_data.c1
-rw-r--r--arch/arm/mach-omap2/clockdomain.c30
-rw-r--r--arch/arm/mach-omap2/clockdomains44xx_data.c2
-rw-r--r--arch/arm/mach-omap2/pm24xx.c4
-rw-r--r--arch/arm/mach-omap2/pm34xx.c4
-rw-r--r--arch/arm/mach-omap2/powerdomain2xxx_3xxx.c1
-rw-r--r--arch/arm/mach-omap2/serial.c4
-rw-r--r--arch/arm/mach-omap2/timer-gp.c10
-rw-r--r--arch/arm/mach-realview/Kconfig49
-rw-r--r--arch/arm/mach-realview/platsmp.c2
-rw-r--r--arch/arm/mach-shmobile/Kconfig2
-rw-r--r--arch/arm/mach-shmobile/board-ag5evm.c180
-rw-r--r--arch/arm/mach-shmobile/board-g3evm.c1
-rw-r--r--arch/arm/mach-shmobile/board-mackerel.c5
-rw-r--r--arch/arm/mach-shmobile/clock-sh7372.c4
-rw-r--r--arch/arm/mach-shmobile/clock-sh73a0.c29
-rw-r--r--arch/arm/mach-shmobile/intc-sh7372.c11
-rw-r--r--arch/arm/mach-shmobile/intc-sh73a0.c5
-rw-r--r--arch/arm/mach-tegra/include/mach/kbc.h61
-rw-r--r--arch/arm/mach-versatile/Kconfig10
-rw-r--r--arch/arm/mach-vexpress/platsmp.c2
-rw-r--r--arch/arm/mach-vexpress/v2m.c9
-rw-r--r--arch/arm/plat-omap/Kconfig8
-rw-r--r--arch/arm/plat-omap/counter_32k.c22
-rw-r--r--arch/arm/plat-omap/dma.c7
-rw-r--r--arch/arm/plat-omap/include/plat/common.h3
-rw-r--r--arch/m68k/amiga/config.c16
-rw-r--r--arch/m68k/atari/ataints.c4
-rw-r--r--arch/m68k/atari/config.c2
-rw-r--r--arch/m68k/atari/debug.c14
-rw-r--r--arch/m68k/include/asm/atarihw.h2
-rw-r--r--arch/m68k/include/asm/string.h12
-rw-r--r--arch/parisc/kernel/pdc_cons.c4
-rw-r--r--arch/powerpc/kernel/perf_event_fsl_emb.c1
-rw-r--r--arch/sh/Kconfig1
-rw-r--r--arch/sh/Makefile3
-rw-r--r--arch/sh/boards/mach-ecovec24/setup.c2
-rw-r--r--arch/sh/boot/Makefile11
-rw-r--r--arch/sh/boot/compressed/Makefile4
-rw-r--r--arch/sh/boot/compressed/misc.c4
-rw-r--r--arch/sh/include/asm/pgtable.h1
-rw-r--r--arch/sh/kernel/cpu/sh4/setup-sh7750.c6
-rw-r--r--arch/sh/kernel/topology.c1
-rw-r--r--arch/x86/include/asm/cacheflush.h42
-rw-r--r--arch/x86/include/asm/cpu.h1
-rw-r--r--arch/x86/include/asm/jump_label.h2
-rw-r--r--arch/x86/include/asm/paravirt.h5
-rw-r--r--arch/x86/kernel/cpu/intel_cacheinfo.c3
-rw-r--r--arch/x86/kernel/cpu/mcheck/therm_throt.c1
-rw-r--r--arch/x86/kernel/process.c3
-rw-r--r--arch/x86/kernel/smpboot.c3
-rw-r--r--drivers/char/agp/intel-gtt.c19
-rw-r--r--drivers/char/bfin_jtag_comm.c8
-rw-r--r--drivers/char/tpm/tpm.c10
-rw-r--r--drivers/char/tpm/tpm_tis.c6
-rw-r--r--drivers/clocksource/acpi_pm.c6
-rw-r--r--drivers/clocksource/tcb_clksrc.c4
-rw-r--r--drivers/gpio/langwell_gpio.c9
-rw-r--r--drivers/gpu/drm/Kconfig3
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c35
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c5
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h5
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c12
-rw-r--r--drivers/gpu/drm/i915/i915_gem_execbuffer.c2
-rw-r--r--drivers/gpu/drm/i915/i915_gem_gtt.c4
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c37
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h6
-rw-r--r--drivers/gpu/drm/i915/intel_display.c25
-rw-r--r--drivers/gpu/drm/i915/intel_opregion.c3
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c83
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.h3
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.c8
-rw-r--r--drivers/gpu/drm/radeon/atombios_crtc.c22
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c3
-rw-r--r--drivers/gpu/drm/radeon/r100.c2
-rw-r--r--drivers/gpu/drm/radeon/r600.c3
-rw-r--r--drivers/gpu/drm/radeon/radeon_atombios.c14
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c10
-rw-r--r--drivers/gpu/drm/radeon/radeon_drv.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_irq_kms.c3
-rw-r--r--drivers/gpu/drm/radeon/radeon_kms.c4
-rw-r--r--drivers/gpu/vga/vgaarb.c2
-rw-r--r--drivers/idle/intel_idle.c8
-rw-r--r--drivers/input/keyboard/Kconfig10
-rw-r--r--drivers/input/keyboard/Makefile1
-rw-r--r--drivers/input/keyboard/gpio_keys.c6
-rw-r--r--drivers/input/keyboard/tegra-kbc.c727
-rw-r--r--drivers/input/keyboard/tnetv107x-keypad.c5
-rw-r--r--drivers/input/serio/ct82c710.c8
-rw-r--r--drivers/input/serio/serport.c24
-rw-r--r--drivers/input/sparse-keymap.c1
-rw-r--r--drivers/input/tablet/wacom_wac.c27
-rw-r--r--drivers/input/touchscreen/bu21013_ts.c39
-rw-r--r--drivers/input/touchscreen/tnetv107x-ts.c5
-rw-r--r--drivers/leds/leds-pwm.c1
-rw-r--r--drivers/mmc/host/mmci.c98
-rw-r--r--drivers/mmc/host/mmci.h5
-rw-r--r--drivers/mmc/host/msm_sdcc.c52
-rw-r--r--drivers/net/arm/ks8695net.c2
-rw-r--r--drivers/parport/share.c4
-rw-r--r--drivers/platform/x86/intel_scu_ipc.c7
-rw-r--r--drivers/platform/x86/intel_scu_ipcutil.c2
-rw-r--r--drivers/pps/clients/pps-ktimer.c2
-rw-r--r--drivers/pps/clients/pps_parport.c2
-rw-r--r--drivers/pps/generators/pps_gen_parport.c2
-rw-r--r--drivers/rapidio/rio-scan.c2
-rw-r--r--drivers/rtc/Kconfig12
-rw-r--r--drivers/rtc/interface.c61
-rw-r--r--drivers/sh/intc/chip.c6
-rw-r--r--drivers/staging/msm/msm_fb.c8
-rw-r--r--drivers/staging/olpc_dcon/olpc_dcon.c10
-rw-r--r--drivers/staging/sm7xx/smtcfb.c8
-rw-r--r--drivers/tty/serial/sb1250-duart.c2
-rw-r--r--drivers/tty/sysrq.c2
-rw-r--r--drivers/tty/tty_io.c4
-rw-r--r--drivers/tty/vt/selection.c4
-rw-r--r--drivers/tty/vt/vc_screen.c16
-rw-r--r--drivers/tty/vt/vt.c124
-rw-r--r--drivers/tty/vt/vt_ioctl.c60
-rw-r--r--drivers/video/arkfb.c12
-rw-r--r--drivers/video/aty/aty128fb.c12
-rw-r--r--drivers/video/aty/atyfb_base.c10
-rw-r--r--drivers/video/aty/radeon_pm.c10
-rw-r--r--drivers/video/bf537-lq035.c58
-rw-r--r--drivers/video/chipsfb.c8
-rw-r--r--drivers/video/console/fbcon.c42
-rw-r--r--drivers/video/console/vgacon.c6
-rw-r--r--drivers/video/da8xx-fb.c11
-rw-r--r--drivers/video/fbmem.c12
-rw-r--r--drivers/video/fbsysfs.c20
-rw-r--r--drivers/video/geode/gxfb_core.c8
-rw-r--r--drivers/video/geode/lxfb_core.c8
-rw-r--r--drivers/video/i810/i810_main.c8
-rw-r--r--drivers/video/jz4740_fb.c8
-rw-r--r--drivers/video/mx3fb.c8
-rw-r--r--drivers/video/nuc900fb.c6
-rw-r--r--drivers/video/nvidia/nvidia.c8
-rw-r--r--drivers/video/ps3fb.c16
-rw-r--r--drivers/video/pxa168fb.c6
-rw-r--r--drivers/video/pxa3xx-gcu.c4
-rw-r--r--drivers/video/s3fb.c16
-rw-r--r--drivers/video/savage/savagefb_driver.c8
-rw-r--r--drivers/video/sh_mobile_hdmi.c8
-rw-r--r--drivers/video/sh_mobile_lcdcfb.c4
-rw-r--r--drivers/video/sm501fb.c8
-rw-r--r--drivers/video/tmiofb.c10
-rw-r--r--drivers/video/via/viafbdev.c8
-rw-r--r--drivers/video/vt8623fb.c12
-rw-r--r--drivers/video/xen-fbfront.c4
-rw-r--r--fs/cifs/cifs_dfs_ref.c1
-rw-r--r--fs/cifs/cifsglob.h33
-rw-r--r--fs/cifs/connect.c12
-rw-r--r--fs/dcache.c4
-rw-r--r--fs/nilfs2/super.c3
-rw-r--r--fs/proc/consoles.c4
-rw-r--r--fs/squashfs/block.c8
-rw-r--r--fs/squashfs/xz_wrapper.c6
-rw-r--r--fs/squashfs/zlib_wrapper.c6
-rw-r--r--include/asm-generic/vmlinux.lds.h7
-rw-r--r--include/drm/radeon_drm.h1
-rw-r--r--include/linux/console.h6
-rw-r--r--include/linux/gfp.h2
-rw-r--r--include/linux/input/bu21013.h4
-rw-r--r--include/linux/kernel.h32
-rw-r--r--include/linux/kmemcheck.h2
-rw-r--r--include/linux/mmc/sh_mmcif.h4
-rw-r--r--include/linux/module.h27
-rw-r--r--include/linux/moduleparam.h6
-rw-r--r--include/linux/rtc.h4
-rw-r--r--include/linux/sysrq.h3
-rw-r--r--include/linux/virtio_config.h5
-rw-r--r--kernel/futex.c22
-rw-r--r--kernel/params.c65
-rw-r--r--kernel/perf_event.c46
-rw-r--r--kernel/printk.c100
-rw-r--r--kernel/rtmutex-debug.c1
-rw-r--r--kernel/rtmutex.c318
-rw-r--r--kernel/rtmutex_common.h16
-rw-r--r--kernel/sched_fair.c78
-rw-r--r--kernel/sysctl.c3
-rw-r--r--kernel/time/tick-sched.c7
-rw-r--r--lib/radix-tree.c7
-rw-r--r--mm/Kconfig2
-rw-r--r--mm/memcontrol.c31
-rw-r--r--mm/migrate.c2
-rw-r--r--mm/page_alloc.c18
-rw-r--r--mm/pgtable-generic.c1
-rw-r--r--mm/vmscan.c3
-rw-r--r--net/dsa/dsa.c2
-rw-r--r--security/keys/Makefile4
-rw-r--r--security/keys/encrypted.c (renamed from security/keys/encrypted_defined.c)3
-rw-r--r--security/keys/encrypted.h (renamed from security/keys/encrypted_defined.h)0
-rw-r--r--security/keys/internal.h6
-rw-r--r--security/keys/key.c8
-rw-r--r--security/keys/keyring.c31
-rw-r--r--security/keys/request_key.c2
-rw-r--r--security/keys/trusted.c (renamed from security/keys/trusted_defined.c)3
-rw-r--r--security/keys/trusted.h (renamed from security/keys/trusted_defined.h)0
-rw-r--r--security/selinux/ss/conditional.c2
-rw-r--r--security/selinux/ss/policydb.c4
-rw-r--r--sound/arm/aaci.c48
-rw-r--r--tools/perf/Makefile9
-rw-r--r--tools/perf/builtin-annotate.c6
-rw-r--r--tools/perf/builtin-kmem.c4
-rw-r--r--tools/perf/builtin-lock.c6
-rw-r--r--tools/perf/builtin-record.c2
-rw-r--r--tools/perf/builtin-report.c2
-rw-r--r--tools/perf/builtin-sched.c20
-rw-r--r--tools/perf/builtin-script.c6
-rw-r--r--tools/perf/builtin-stat.c4
-rw-r--r--tools/perf/builtin-test.c54
-rw-r--r--tools/perf/builtin-top.c9
-rw-r--r--tools/perf/util/event.c5
-rw-r--r--tools/perf/util/header.c4
-rw-r--r--tools/perf/util/hist.c17
-rw-r--r--tools/perf/util/include/linux/bitops.h1
-rw-r--r--tools/perf/util/map.c3
-rw-r--r--tools/perf/util/parse-events.c2
-rw-r--r--tools/perf/util/parse-events.h2
-rw-r--r--tools/perf/util/probe-event.c2
-rw-r--r--tools/perf/util/session.c28
-rw-r--r--tools/perf/util/svghelper.c9
-rw-r--r--tools/perf/util/symbol.c16
-rw-r--r--tools/perf/util/types.h10
-rw-r--r--tools/perf/util/ui/browsers/hists.c2
-rw-r--r--tools/perf/util/ui/browsers/map.c5
-rw-r--r--tools/perf/util/values.c10
241 files changed, 2790 insertions, 1353 deletions
diff --git a/.mailmap b/.mailmap
index 581fd39193a2..1eba28acab64 100644
--- a/.mailmap
+++ b/.mailmap
@@ -23,6 +23,7 @@ Andy Adamson <andros@citi.umich.edu>
23Arnaud Patard <arnaud.patard@rtp-net.org> 23Arnaud Patard <arnaud.patard@rtp-net.org>
24Arnd Bergmann <arnd@arndb.de> 24Arnd Bergmann <arnd@arndb.de>
25Axel Dyks <xl@xlsigned.net> 25Axel Dyks <xl@xlsigned.net>
26Axel Lin <axel.lin@gmail.com>
26Ben Gardner <bgardner@wabtec.com> 27Ben Gardner <bgardner@wabtec.com>
27Ben M Cahill <ben.m.cahill@intel.com> 28Ben M Cahill <ben.m.cahill@intel.com>
28Björn Steinbrink <B.Steinbrink@gmx.de> 29Björn Steinbrink <B.Steinbrink@gmx.de>
diff --git a/Documentation/DocBook/device-drivers.tmpl b/Documentation/DocBook/device-drivers.tmpl
index 35447e081736..36f63d4a0a06 100644
--- a/Documentation/DocBook/device-drivers.tmpl
+++ b/Documentation/DocBook/device-drivers.tmpl
@@ -217,8 +217,8 @@ X!Isound/sound_firmware.c
217 <chapter id="uart16x50"> 217 <chapter id="uart16x50">
218 <title>16x50 UART Driver</title> 218 <title>16x50 UART Driver</title>
219!Iinclude/linux/serial_core.h 219!Iinclude/linux/serial_core.h
220!Edrivers/serial/serial_core.c 220!Edrivers/tty/serial/serial_core.c
221!Edrivers/serial/8250.c 221!Edrivers/tty/serial/8250.c
222 </chapter> 222 </chapter>
223 223
224 <chapter id="fbdev"> 224 <chapter id="fbdev">
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index b72e071a3e5b..89835a4766a6 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -43,11 +43,11 @@ parameter is applicable:
43 AVR32 AVR32 architecture is enabled. 43 AVR32 AVR32 architecture is enabled.
44 AX25 Appropriate AX.25 support is enabled. 44 AX25 Appropriate AX.25 support is enabled.
45 BLACKFIN Blackfin architecture is enabled. 45 BLACKFIN Blackfin architecture is enabled.
46 DRM Direct Rendering Management support is enabled.
47 DYNAMIC_DEBUG Build in debug messages and enable them at runtime
46 EDD BIOS Enhanced Disk Drive Services (EDD) is enabled 48 EDD BIOS Enhanced Disk Drive Services (EDD) is enabled
47 EFI EFI Partitioning (GPT) is enabled 49 EFI EFI Partitioning (GPT) is enabled
48 EIDE EIDE/ATAPI support is enabled. 50 EIDE EIDE/ATAPI support is enabled.
49 DRM Direct Rendering Management support is enabled.
50 DYNAMIC_DEBUG Build in debug messages and enable them at runtime
51 FB The frame buffer device is enabled. 51 FB The frame buffer device is enabled.
52 GCOV GCOV profiling is enabled. 52 GCOV GCOV profiling is enabled.
53 HW Appropriate hardware is enabled. 53 HW Appropriate hardware is enabled.
diff --git a/MAINTAINERS b/MAINTAINERS
index 55592f8b672c..cf0f3a5c09cc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3674,6 +3674,28 @@ F: include/linux/key-type.h
3674F: include/keys/ 3674F: include/keys/
3675F: security/keys/ 3675F: security/keys/
3676 3676
3677KEYS-TRUSTED
3678M: David Safford <safford@watson.ibm.com>
3679M: Mimi Zohar <zohar@us.ibm.com>
3680L: linux-security-module@vger.kernel.org
3681L: keyrings@linux-nfs.org
3682S: Supported
3683F: Documentation/keys-trusted-encrypted.txt
3684F: include/keys/trusted-type.h
3685F: security/keys/trusted.c
3686F: security/keys/trusted.h
3687
3688KEYS-ENCRYPTED
3689M: Mimi Zohar <zohar@us.ibm.com>
3690M: David Safford <safford@watson.ibm.com>
3691L: linux-security-module@vger.kernel.org
3692L: keyrings@linux-nfs.org
3693S: Supported
3694F: Documentation/keys-trusted-encrypted.txt
3695F: include/keys/encrypted-type.h
3696F: security/keys/encrypted.c
3697F: security/keys/encrypted.h
3698
3677KGDB / KDB /debug_core 3699KGDB / KDB /debug_core
3678M: Jason Wessel <jason.wessel@windriver.com> 3700M: Jason Wessel <jason.wessel@windriver.com>
3679W: http://kgdb.wiki.kernel.org/ 3701W: http://kgdb.wiki.kernel.org/
diff --git a/arch/arm/include/asm/hardware/sp810.h b/arch/arm/include/asm/hardware/sp810.h
index a101f10bb5b1..721847dc68ab 100644
--- a/arch/arm/include/asm/hardware/sp810.h
+++ b/arch/arm/include/asm/hardware/sp810.h
@@ -50,6 +50,12 @@
50#define SCPCELLID2 0xFF8 50#define SCPCELLID2 0xFF8
51#define SCPCELLID3 0xFFC 51#define SCPCELLID3 0xFFC
52 52
53#define SCCTRL_TIMEREN0SEL_REFCLK (0 << 15)
54#define SCCTRL_TIMEREN0SEL_TIMCLK (1 << 15)
55
56#define SCCTRL_TIMEREN1SEL_REFCLK (0 << 17)
57#define SCCTRL_TIMEREN1SEL_TIMCLK (1 << 17)
58
53static inline void sysctl_soft_reset(void __iomem *base) 59static inline void sysctl_soft_reset(void __iomem *base)
54{ 60{
55 /* writing any value to SCSYSSTAT reg will reset system */ 61 /* writing any value to SCSYSSTAT reg will reset system */
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index 23c2e8e5c0fa..d0ee74b7cf86 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -188,7 +188,7 @@
188 * translation for translating DMA addresses. Use the driver 188 * translation for translating DMA addresses. Use the driver
189 * DMA support - see dma-mapping.h. 189 * DMA support - see dma-mapping.h.
190 */ 190 */
191static inline unsigned long virt_to_phys(void *x) 191static inline unsigned long virt_to_phys(const volatile void *x)
192{ 192{
193 return __virt_to_phys((unsigned long)(x)); 193 return __virt_to_phys((unsigned long)(x));
194} 194}
diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c
index fd9156698ab9..60636f499cb3 100644
--- a/arch/arm/kernel/smp_twd.c
+++ b/arch/arm/kernel/smp_twd.c
@@ -36,6 +36,7 @@ static void twd_set_mode(enum clock_event_mode mode,
36 /* timer load already set up */ 36 /* timer load already set up */
37 ctrl = TWD_TIMER_CONTROL_ENABLE | TWD_TIMER_CONTROL_IT_ENABLE 37 ctrl = TWD_TIMER_CONTROL_ENABLE | TWD_TIMER_CONTROL_IT_ENABLE
38 | TWD_TIMER_CONTROL_PERIODIC; 38 | TWD_TIMER_CONTROL_PERIODIC;
39 __raw_writel(twd_timer_rate / HZ, twd_base + TWD_TIMER_LOAD);
39 break; 40 break;
40 case CLOCK_EVT_MODE_ONESHOT: 41 case CLOCK_EVT_MODE_ONESHOT:
41 /* period set, and timer enabled in 'next_event' hook */ 42 /* period set, and timer enabled in 'next_event' hook */
@@ -81,7 +82,7 @@ int twd_timer_ack(void)
81 82
82static void __cpuinit twd_calibrate_rate(void) 83static void __cpuinit twd_calibrate_rate(void)
83{ 84{
84 unsigned long load, count; 85 unsigned long count;
85 u64 waitjiffies; 86 u64 waitjiffies;
86 87
87 /* 88 /*
@@ -116,10 +117,6 @@ static void __cpuinit twd_calibrate_rate(void)
116 printk("%lu.%02luMHz.\n", twd_timer_rate / 1000000, 117 printk("%lu.%02luMHz.\n", twd_timer_rate / 1000000,
117 (twd_timer_rate / 1000000) % 100); 118 (twd_timer_rate / 1000000) % 100);
118 } 119 }
119
120 load = twd_timer_rate / HZ;
121
122 __raw_writel(load, twd_base + TWD_TIMER_LOAD);
123} 120}
124 121
125/* 122/*
diff --git a/arch/arm/mach-ep93xx/gpio.c b/arch/arm/mach-ep93xx/gpio.c
index f3dc76fdcea8..bec34b834958 100644
--- a/arch/arm/mach-ep93xx/gpio.c
+++ b/arch/arm/mach-ep93xx/gpio.c
@@ -427,6 +427,13 @@ void __init ep93xx_gpio_init(void)
427{ 427{
428 int i; 428 int i;
429 429
430 /* Set Ports C, D, E, G, and H for GPIO use */
431 ep93xx_devcfg_set_bits(EP93XX_SYSCON_DEVCFG_KEYS |
432 EP93XX_SYSCON_DEVCFG_GONK |
433 EP93XX_SYSCON_DEVCFG_EONIDE |
434 EP93XX_SYSCON_DEVCFG_GONIDE |
435 EP93XX_SYSCON_DEVCFG_HONIDE);
436
430 for (i = 0; i < ARRAY_SIZE(ep93xx_gpio_banks); i++) 437 for (i = 0; i < ARRAY_SIZE(ep93xx_gpio_banks); i++)
431 gpiochip_add(&ep93xx_gpio_banks[i].chip); 438 gpiochip_add(&ep93xx_gpio_banks[i].chip);
432} 439}
diff --git a/arch/arm/mach-omap1/Kconfig b/arch/arm/mach-omap1/Kconfig
index 8d2f2daba0c0..e0a028161dde 100644
--- a/arch/arm/mach-omap1/Kconfig
+++ b/arch/arm/mach-omap1/Kconfig
@@ -9,6 +9,7 @@ config ARCH_OMAP730
9 depends on ARCH_OMAP1 9 depends on ARCH_OMAP1
10 bool "OMAP730 Based System" 10 bool "OMAP730 Based System"
11 select CPU_ARM926T 11 select CPU_ARM926T
12 select OMAP_MPU_TIMER
12 select ARCH_OMAP_OTG 13 select ARCH_OMAP_OTG
13 14
14config ARCH_OMAP850 15config ARCH_OMAP850
@@ -22,6 +23,7 @@ config ARCH_OMAP15XX
22 default y 23 default y
23 bool "OMAP15xx Based System" 24 bool "OMAP15xx Based System"
24 select CPU_ARM925T 25 select CPU_ARM925T
26 select OMAP_MPU_TIMER
25 27
26config ARCH_OMAP16XX 28config ARCH_OMAP16XX
27 depends on ARCH_OMAP1 29 depends on ARCH_OMAP1
diff --git a/arch/arm/mach-omap1/Makefile b/arch/arm/mach-omap1/Makefile
index 6ee19504845f..ba6009f27677 100644
--- a/arch/arm/mach-omap1/Makefile
+++ b/arch/arm/mach-omap1/Makefile
@@ -3,12 +3,11 @@
3# 3#
4 4
5# Common support 5# Common support
6obj-y := io.o id.o sram.o irq.o mux.o flash.o serial.o devices.o dma.o 6obj-y := io.o id.o sram.o time.o irq.o mux.o flash.o serial.o devices.o dma.o
7obj-y += clock.o clock_data.o opp_data.o 7obj-y += clock.o clock_data.o opp_data.o
8 8
9obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o 9obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
10 10
11obj-$(CONFIG_OMAP_MPU_TIMER) += time.o
12obj-$(CONFIG_OMAP_32K_TIMER) += timer32k.o 11obj-$(CONFIG_OMAP_32K_TIMER) += timer32k.o
13 12
14# Power Management 13# Power Management
diff --git a/arch/arm/mach-omap1/time.c b/arch/arm/mach-omap1/time.c
index ed7a61ff916a..f83fc335c613 100644
--- a/arch/arm/mach-omap1/time.c
+++ b/arch/arm/mach-omap1/time.c
@@ -44,16 +44,21 @@
44#include <linux/clocksource.h> 44#include <linux/clocksource.h>
45#include <linux/clockchips.h> 45#include <linux/clockchips.h>
46#include <linux/io.h> 46#include <linux/io.h>
47#include <linux/sched.h>
47 48
48#include <asm/system.h> 49#include <asm/system.h>
49#include <mach/hardware.h> 50#include <mach/hardware.h>
50#include <asm/leds.h> 51#include <asm/leds.h>
51#include <asm/irq.h> 52#include <asm/irq.h>
53#include <asm/sched_clock.h>
54
52#include <asm/mach/irq.h> 55#include <asm/mach/irq.h>
53#include <asm/mach/time.h> 56#include <asm/mach/time.h>
54 57
55#include <plat/common.h> 58#include <plat/common.h>
56 59
60#ifdef CONFIG_OMAP_MPU_TIMER
61
57#define OMAP_MPU_TIMER_BASE OMAP_MPU_TIMER1_BASE 62#define OMAP_MPU_TIMER_BASE OMAP_MPU_TIMER1_BASE
58#define OMAP_MPU_TIMER_OFFSET 0x100 63#define OMAP_MPU_TIMER_OFFSET 0x100
59 64
@@ -67,7 +72,7 @@ typedef struct {
67((volatile omap_mpu_timer_regs_t*)OMAP1_IO_ADDRESS(OMAP_MPU_TIMER_BASE + \ 72((volatile omap_mpu_timer_regs_t*)OMAP1_IO_ADDRESS(OMAP_MPU_TIMER_BASE + \
68 (n)*OMAP_MPU_TIMER_OFFSET)) 73 (n)*OMAP_MPU_TIMER_OFFSET))
69 74
70static inline unsigned long omap_mpu_timer_read(int nr) 75static inline unsigned long notrace omap_mpu_timer_read(int nr)
71{ 76{
72 volatile omap_mpu_timer_regs_t* timer = omap_mpu_timer_base(nr); 77 volatile omap_mpu_timer_regs_t* timer = omap_mpu_timer_base(nr);
73 return timer->read_tim; 78 return timer->read_tim;
@@ -212,6 +217,32 @@ static struct clocksource clocksource_mpu = {
212 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 217 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
213}; 218};
214 219
220static DEFINE_CLOCK_DATA(cd);
221
222static inline unsigned long long notrace _omap_mpu_sched_clock(void)
223{
224 u32 cyc = mpu_read(&clocksource_mpu);
225 return cyc_to_sched_clock(&cd, cyc, (u32)~0);
226}
227
228#ifndef CONFIG_OMAP_32K_TIMER
229unsigned long long notrace sched_clock(void)
230{
231 return _omap_mpu_sched_clock();
232}
233#else
234static unsigned long long notrace omap_mpu_sched_clock(void)
235{
236 return _omap_mpu_sched_clock();
237}
238#endif
239
240static void notrace mpu_update_sched_clock(void)
241{
242 u32 cyc = mpu_read(&clocksource_mpu);
243 update_sched_clock(&cd, cyc, (u32)~0);
244}
245
215static void __init omap_init_clocksource(unsigned long rate) 246static void __init omap_init_clocksource(unsigned long rate)
216{ 247{
217 static char err[] __initdata = KERN_ERR 248 static char err[] __initdata = KERN_ERR
@@ -219,17 +250,13 @@ static void __init omap_init_clocksource(unsigned long rate)
219 250
220 setup_irq(INT_TIMER2, &omap_mpu_timer2_irq); 251 setup_irq(INT_TIMER2, &omap_mpu_timer2_irq);
221 omap_mpu_timer_start(1, ~0, 1); 252 omap_mpu_timer_start(1, ~0, 1);
253 init_sched_clock(&cd, mpu_update_sched_clock, 32, rate);
222 254
223 if (clocksource_register_hz(&clocksource_mpu, rate)) 255 if (clocksource_register_hz(&clocksource_mpu, rate))
224 printk(err, clocksource_mpu.name); 256 printk(err, clocksource_mpu.name);
225} 257}
226 258
227/* 259static void __init omap_mpu_timer_init(void)
228 * ---------------------------------------------------------------------------
229 * Timer initialization
230 * ---------------------------------------------------------------------------
231 */
232static void __init omap_timer_init(void)
233{ 260{
234 struct clk *ck_ref = clk_get(NULL, "ck_ref"); 261 struct clk *ck_ref = clk_get(NULL, "ck_ref");
235 unsigned long rate; 262 unsigned long rate;
@@ -246,6 +273,66 @@ static void __init omap_timer_init(void)
246 omap_init_clocksource(rate); 273 omap_init_clocksource(rate);
247} 274}
248 275
276#else
277static inline void omap_mpu_timer_init(void)
278{
279 pr_err("Bogus timer, should not happen\n");
280}
281#endif /* CONFIG_OMAP_MPU_TIMER */
282
283#if defined(CONFIG_OMAP_MPU_TIMER) && defined(CONFIG_OMAP_32K_TIMER)
284static unsigned long long (*preferred_sched_clock)(void);
285
286unsigned long long notrace sched_clock(void)
287{
288 if (!preferred_sched_clock)
289 return 0;
290
291 return preferred_sched_clock();
292}
293
294static inline void preferred_sched_clock_init(bool use_32k_sched_clock)
295{
296 if (use_32k_sched_clock)
297 preferred_sched_clock = omap_32k_sched_clock;
298 else
299 preferred_sched_clock = omap_mpu_sched_clock;
300}
301#else
302static inline void preferred_sched_clock_init(bool use_32k_sched_clcok)
303{
304}
305#endif
306
307static inline int omap_32k_timer_usable(void)
308{
309 int res = false;
310
311 if (cpu_is_omap730() || cpu_is_omap15xx())
312 return res;
313
314#ifdef CONFIG_OMAP_32K_TIMER
315 res = omap_32k_timer_init();
316#endif
317
318 return res;
319}
320
321/*
322 * ---------------------------------------------------------------------------
323 * Timer initialization
324 * ---------------------------------------------------------------------------
325 */
326static void __init omap_timer_init(void)
327{
328 if (omap_32k_timer_usable()) {
329 preferred_sched_clock_init(1);
330 } else {
331 omap_mpu_timer_init();
332 preferred_sched_clock_init(0);
333 }
334}
335
249struct sys_timer omap_timer = { 336struct sys_timer omap_timer = {
250 .init = omap_timer_init, 337 .init = omap_timer_init,
251}; 338};
diff --git a/arch/arm/mach-omap1/timer32k.c b/arch/arm/mach-omap1/timer32k.c
index 20cfbcc6c60c..13d7b8f145bd 100644
--- a/arch/arm/mach-omap1/timer32k.c
+++ b/arch/arm/mach-omap1/timer32k.c
@@ -52,10 +52,9 @@
52#include <asm/irq.h> 52#include <asm/irq.h>
53#include <asm/mach/irq.h> 53#include <asm/mach/irq.h>
54#include <asm/mach/time.h> 54#include <asm/mach/time.h>
55#include <plat/common.h>
55#include <plat/dmtimer.h> 56#include <plat/dmtimer.h>
56 57
57struct sys_timer omap_timer;
58
59/* 58/*
60 * --------------------------------------------------------------------------- 59 * ---------------------------------------------------------------------------
61 * 32KHz OS timer 60 * 32KHz OS timer
@@ -181,14 +180,14 @@ static __init void omap_init_32k_timer(void)
181 * Timer initialization 180 * Timer initialization
182 * --------------------------------------------------------------------------- 181 * ---------------------------------------------------------------------------
183 */ 182 */
184static void __init omap_timer_init(void) 183bool __init omap_32k_timer_init(void)
185{ 184{
185 omap_init_clocksource_32k();
186
186#ifdef CONFIG_OMAP_DM_TIMER 187#ifdef CONFIG_OMAP_DM_TIMER
187 omap_dm_timer_init(); 188 omap_dm_timer_init();
188#endif 189#endif
189 omap_init_32k_timer(); 190 omap_init_32k_timer();
190}
191 191
192struct sys_timer omap_timer = { 192 return true;
193 .init = omap_timer_init, 193}
194};
diff --git a/arch/arm/mach-omap2/board-cm-t3517.c b/arch/arm/mach-omap2/board-cm-t3517.c
index 5b0c77732dfc..8f9a64d650ee 100644
--- a/arch/arm/mach-omap2/board-cm-t3517.c
+++ b/arch/arm/mach-omap2/board-cm-t3517.c
@@ -124,8 +124,9 @@ static inline void cm_t3517_init_hecc(void) {}
124#if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE) 124#if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
125#define RTC_IO_GPIO (153) 125#define RTC_IO_GPIO (153)
126#define RTC_WR_GPIO (154) 126#define RTC_WR_GPIO (154)
127#define RTC_RD_GPIO (160) 127#define RTC_RD_GPIO (53)
128#define RTC_CS_GPIO (163) 128#define RTC_CS_GPIO (163)
129#define RTC_CS_EN_GPIO (160)
129 130
130struct v3020_platform_data cm_t3517_v3020_pdata = { 131struct v3020_platform_data cm_t3517_v3020_pdata = {
131 .use_gpio = 1, 132 .use_gpio = 1,
@@ -145,6 +146,16 @@ static struct platform_device cm_t3517_rtc_device = {
145 146
146static void __init cm_t3517_init_rtc(void) 147static void __init cm_t3517_init_rtc(void)
147{ 148{
149 int err;
150
151 err = gpio_request(RTC_CS_EN_GPIO, "rtc cs en");
152 if (err) {
153 pr_err("CM-T3517: rtc cs en gpio request failed: %d\n", err);
154 return;
155 }
156
157 gpio_direction_output(RTC_CS_EN_GPIO, 1);
158
148 platform_device_register(&cm_t3517_rtc_device); 159 platform_device_register(&cm_t3517_rtc_device);
149} 160}
150#else 161#else
@@ -214,12 +225,12 @@ static struct mtd_partition cm_t3517_nand_partitions[] = {
214 }, 225 },
215 { 226 {
216 .name = "linux", 227 .name = "linux",
217 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */ 228 .offset = MTDPART_OFS_APPEND, /* Offset = 0x2A0000 */
218 .size = 32 * NAND_BLOCK_SIZE, 229 .size = 32 * NAND_BLOCK_SIZE,
219 }, 230 },
220 { 231 {
221 .name = "rootfs", 232 .name = "rootfs",
222 .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */ 233 .offset = MTDPART_OFS_APPEND, /* Offset = 0x6A0000 */
223 .size = MTDPART_SIZ_FULL, 234 .size = MTDPART_SIZ_FULL,
224 }, 235 },
225}; 236};
@@ -256,11 +267,19 @@ static void __init cm_t3517_init_irq(void)
256static struct omap_board_mux board_mux[] __initdata = { 267static struct omap_board_mux board_mux[] __initdata = {
257 /* GPIO186 - Green LED */ 268 /* GPIO186 - Green LED */
258 OMAP3_MUX(SYS_CLKOUT2, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT), 269 OMAP3_MUX(SYS_CLKOUT2, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
259 /* RTC GPIOs: IO, WR#, RD#, CS# */ 270
271 /* RTC GPIOs: */
272 /* IO - GPIO153 */
260 OMAP3_MUX(MCBSP4_DR, OMAP_MUX_MODE4 | OMAP_PIN_INPUT), 273 OMAP3_MUX(MCBSP4_DR, OMAP_MUX_MODE4 | OMAP_PIN_INPUT),
274 /* WR# - GPIO154 */
261 OMAP3_MUX(MCBSP4_DX, OMAP_MUX_MODE4 | OMAP_PIN_INPUT), 275 OMAP3_MUX(MCBSP4_DX, OMAP_MUX_MODE4 | OMAP_PIN_INPUT),
262 OMAP3_MUX(MCBSP_CLKS, OMAP_MUX_MODE4 | OMAP_PIN_INPUT), 276 /* RD# - GPIO53 */
277 OMAP3_MUX(GPMC_NCS2, OMAP_MUX_MODE4 | OMAP_PIN_INPUT),
278 /* CS# - GPIO163 */
263 OMAP3_MUX(UART3_CTS_RCTX, OMAP_MUX_MODE4 | OMAP_PIN_INPUT), 279 OMAP3_MUX(UART3_CTS_RCTX, OMAP_MUX_MODE4 | OMAP_PIN_INPUT),
280 /* CS EN - GPIO160 */
281 OMAP3_MUX(MCBSP_CLKS, OMAP_MUX_MODE4 | OMAP_PIN_INPUT),
282
264 /* HSUSB1 RESET */ 283 /* HSUSB1 RESET */
265 OMAP3_MUX(UART2_TX, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT), 284 OMAP3_MUX(UART2_TX, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
266 /* HSUSB2 RESET */ 285 /* HSUSB2 RESET */
diff --git a/arch/arm/mach-omap2/board-devkit8000.c b/arch/arm/mach-omap2/board-devkit8000.c
index 00bb1fc5e017..e906e05bb41b 100644
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -275,8 +275,7 @@ static struct twl4030_gpio_platform_data devkit8000_gpio_data = {
275 .irq_base = TWL4030_GPIO_IRQ_BASE, 275 .irq_base = TWL4030_GPIO_IRQ_BASE,
276 .irq_end = TWL4030_GPIO_IRQ_END, 276 .irq_end = TWL4030_GPIO_IRQ_END,
277 .use_leds = true, 277 .use_leds = true,
278 .pullups = BIT(1), 278 .pulldowns = BIT(1) | BIT(2) | BIT(6) | BIT(8) | BIT(13)
279 .pulldowns = BIT(2) | BIT(6) | BIT(7) | BIT(8) | BIT(13)
280 | BIT(15) | BIT(16) | BIT(17), 279 | BIT(15) | BIT(16) | BIT(17),
281 .setup = devkit8000_twl_gpio_setup, 280 .setup = devkit8000_twl_gpio_setup,
282}; 281};
diff --git a/arch/arm/mach-omap2/clock44xx_data.c b/arch/arm/mach-omap2/clock44xx_data.c
index e8cb32fd7f13..de9ec8ddd2ae 100644
--- a/arch/arm/mach-omap2/clock44xx_data.c
+++ b/arch/arm/mach-omap2/clock44xx_data.c
@@ -34,7 +34,6 @@
34#include "cm2_44xx.h" 34#include "cm2_44xx.h"
35#include "cm-regbits-44xx.h" 35#include "cm-regbits-44xx.h"
36#include "prm44xx.h" 36#include "prm44xx.h"
37#include "prm44xx.h"
38#include "prm-regbits-44xx.h" 37#include "prm-regbits-44xx.h"
39#include "control.h" 38#include "control.h"
40#include "scrm44xx.h" 39#include "scrm44xx.h"
diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c
index e20b98636ab4..58e42f76603f 100644
--- a/arch/arm/mach-omap2/clockdomain.c
+++ b/arch/arm/mach-omap2/clockdomain.c
@@ -423,6 +423,12 @@ int clkdm_add_wkdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2)
423{ 423{
424 struct clkdm_dep *cd; 424 struct clkdm_dep *cd;
425 425
426 if (!cpu_is_omap24xx() && !cpu_is_omap34xx()) {
427 pr_err("clockdomain: %s/%s: %s: not yet implemented\n",
428 clkdm1->name, clkdm2->name, __func__);
429 return -EINVAL;
430 }
431
426 if (!clkdm1 || !clkdm2) 432 if (!clkdm1 || !clkdm2)
427 return -EINVAL; 433 return -EINVAL;
428 434
@@ -458,6 +464,12 @@ int clkdm_del_wkdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2)
458{ 464{
459 struct clkdm_dep *cd; 465 struct clkdm_dep *cd;
460 466
467 if (!cpu_is_omap24xx() && !cpu_is_omap34xx()) {
468 pr_err("clockdomain: %s/%s: %s: not yet implemented\n",
469 clkdm1->name, clkdm2->name, __func__);
470 return -EINVAL;
471 }
472
461 if (!clkdm1 || !clkdm2) 473 if (!clkdm1 || !clkdm2)
462 return -EINVAL; 474 return -EINVAL;
463 475
@@ -500,6 +512,12 @@ int clkdm_read_wkdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2)
500 if (!clkdm1 || !clkdm2) 512 if (!clkdm1 || !clkdm2)
501 return -EINVAL; 513 return -EINVAL;
502 514
515 if (!cpu_is_omap24xx() && !cpu_is_omap34xx()) {
516 pr_err("clockdomain: %s/%s: %s: not yet implemented\n",
517 clkdm1->name, clkdm2->name, __func__);
518 return -EINVAL;
519 }
520
503 cd = _clkdm_deps_lookup(clkdm2, clkdm1->wkdep_srcs); 521 cd = _clkdm_deps_lookup(clkdm2, clkdm1->wkdep_srcs);
504 if (IS_ERR(cd)) { 522 if (IS_ERR(cd)) {
505 pr_debug("clockdomain: hardware cannot set/clear wake up of " 523 pr_debug("clockdomain: hardware cannot set/clear wake up of "
@@ -527,6 +545,12 @@ int clkdm_clear_all_wkdeps(struct clockdomain *clkdm)
527 struct clkdm_dep *cd; 545 struct clkdm_dep *cd;
528 u32 mask = 0; 546 u32 mask = 0;
529 547
548 if (!cpu_is_omap24xx() && !cpu_is_omap34xx()) {
549 pr_err("clockdomain: %s: %s: not yet implemented\n",
550 clkdm->name, __func__);
551 return -EINVAL;
552 }
553
530 if (!clkdm) 554 if (!clkdm)
531 return -EINVAL; 555 return -EINVAL;
532 556
@@ -830,8 +854,7 @@ void omap2_clkdm_allow_idle(struct clockdomain *clkdm)
830 * dependency code and data for OMAP4. 854 * dependency code and data for OMAP4.
831 */ 855 */
832 if (cpu_is_omap44xx()) { 856 if (cpu_is_omap44xx()) {
833 WARN_ONCE(1, "clockdomain: OMAP4 wakeup/sleep dependency " 857 pr_err("clockdomain: %s: OMAP4 wakeup/sleep dependency support: not yet implemented\n", clkdm->name);
834 "support is not yet implemented\n");
835 } else { 858 } else {
836 if (atomic_read(&clkdm->usecount) > 0) 859 if (atomic_read(&clkdm->usecount) > 0)
837 _clkdm_add_autodeps(clkdm); 860 _clkdm_add_autodeps(clkdm);
@@ -872,8 +895,7 @@ void omap2_clkdm_deny_idle(struct clockdomain *clkdm)
872 * dependency code and data for OMAP4. 895 * dependency code and data for OMAP4.
873 */ 896 */
874 if (cpu_is_omap44xx()) { 897 if (cpu_is_omap44xx()) {
875 WARN_ONCE(1, "clockdomain: OMAP4 wakeup/sleep dependency " 898 pr_err("clockdomain: %s: OMAP4 wakeup/sleep dependency support: not yet implemented\n", clkdm->name);
876 "support is not yet implemented\n");
877 } else { 899 } else {
878 if (atomic_read(&clkdm->usecount) > 0) 900 if (atomic_read(&clkdm->usecount) > 0)
879 _clkdm_del_autodeps(clkdm); 901 _clkdm_del_autodeps(clkdm);
diff --git a/arch/arm/mach-omap2/clockdomains44xx_data.c b/arch/arm/mach-omap2/clockdomains44xx_data.c
index 51920fc7fc52..10622c914abc 100644
--- a/arch/arm/mach-omap2/clockdomains44xx_data.c
+++ b/arch/arm/mach-omap2/clockdomains44xx_data.c
@@ -30,8 +30,6 @@
30#include "cm1_44xx.h" 30#include "cm1_44xx.h"
31#include "cm2_44xx.h" 31#include "cm2_44xx.h"
32 32
33#include "cm1_44xx.h"
34#include "cm2_44xx.h"
35#include "cm-regbits-44xx.h" 33#include "cm-regbits-44xx.h"
36#include "prm44xx.h" 34#include "prm44xx.h"
37#include "prcm44xx.h" 35#include "prcm44xx.h"
diff --git a/arch/arm/mach-omap2/pm24xx.c b/arch/arm/mach-omap2/pm24xx.c
index 9e5dc8ed51e9..97feb3ab6a69 100644
--- a/arch/arm/mach-omap2/pm24xx.c
+++ b/arch/arm/mach-omap2/pm24xx.c
@@ -134,7 +134,7 @@ static void omap2_enter_full_retention(void)
134 134
135 /* Block console output in case it is on one of the OMAP UARTs */ 135 /* Block console output in case it is on one of the OMAP UARTs */
136 if (!is_suspending()) 136 if (!is_suspending())
137 if (try_acquire_console_sem()) 137 if (!console_trylock())
138 goto no_sleep; 138 goto no_sleep;
139 139
140 omap_uart_prepare_idle(0); 140 omap_uart_prepare_idle(0);
@@ -151,7 +151,7 @@ static void omap2_enter_full_retention(void)
151 omap_uart_resume_idle(0); 151 omap_uart_resume_idle(0);
152 152
153 if (!is_suspending()) 153 if (!is_suspending())
154 release_console_sem(); 154 console_unlock();
155 155
156no_sleep: 156no_sleep:
157 if (omap2_pm_debug) { 157 if (omap2_pm_debug) {
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 8cbbeade4b8a..a4aa1920a75c 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -398,7 +398,7 @@ void omap_sram_idle(void)
398 if (!is_suspending()) 398 if (!is_suspending())
399 if (per_next_state < PWRDM_POWER_ON || 399 if (per_next_state < PWRDM_POWER_ON ||
400 core_next_state < PWRDM_POWER_ON) 400 core_next_state < PWRDM_POWER_ON)
401 if (try_acquire_console_sem()) 401 if (!console_trylock())
402 goto console_still_active; 402 goto console_still_active;
403 403
404 /* PER */ 404 /* PER */
@@ -481,7 +481,7 @@ void omap_sram_idle(void)
481 } 481 }
482 482
483 if (!is_suspending()) 483 if (!is_suspending())
484 release_console_sem(); 484 console_unlock();
485 485
486console_still_active: 486console_still_active:
487 /* Disable IO-PAD and IO-CHAIN wakeup */ 487 /* Disable IO-PAD and IO-CHAIN wakeup */
diff --git a/arch/arm/mach-omap2/powerdomain2xxx_3xxx.c b/arch/arm/mach-omap2/powerdomain2xxx_3xxx.c
index d5233890370c..cf600e22bf8e 100644
--- a/arch/arm/mach-omap2/powerdomain2xxx_3xxx.c
+++ b/arch/arm/mach-omap2/powerdomain2xxx_3xxx.c
@@ -19,7 +19,6 @@
19#include <plat/prcm.h> 19#include <plat/prcm.h>
20 20
21#include "powerdomain.h" 21#include "powerdomain.h"
22#include "prm-regbits-34xx.h"
23#include "prm.h" 22#include "prm.h"
24#include "prm-regbits-24xx.h" 23#include "prm-regbits-24xx.h"
25#include "prm-regbits-34xx.h" 24#include "prm-regbits-34xx.h"
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 302da7403a10..32e91a9c8b6b 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -812,7 +812,7 @@ void __init omap_serial_init_port(struct omap_board_data *bdata)
812 812
813 oh->dev_attr = uart; 813 oh->dev_attr = uart;
814 814
815 acquire_console_sem(); /* in case the earlycon is on the UART */ 815 console_lock(); /* in case the earlycon is on the UART */
816 816
817 /* 817 /*
818 * Because of early UART probing, UART did not get idled 818 * Because of early UART probing, UART did not get idled
@@ -838,7 +838,7 @@ void __init omap_serial_init_port(struct omap_board_data *bdata)
838 omap_uart_block_sleep(uart); 838 omap_uart_block_sleep(uart);
839 uart->timeout = DEFAULT_TIMEOUT; 839 uart->timeout = DEFAULT_TIMEOUT;
840 840
841 release_console_sem(); 841 console_unlock();
842 842
843 if ((cpu_is_omap34xx() && uart->padconf) || 843 if ((cpu_is_omap34xx() && uart->padconf) ||
844 (uart->wk_en && uart->wk_mask)) { 844 (uart->wk_en && uart->wk_mask)) {
diff --git a/arch/arm/mach-omap2/timer-gp.c b/arch/arm/mach-omap2/timer-gp.c
index 4e48e786bec7..7b7c2683ae7b 100644
--- a/arch/arm/mach-omap2/timer-gp.c
+++ b/arch/arm/mach-omap2/timer-gp.c
@@ -42,6 +42,8 @@
42 42
43#include "timer-gp.h" 43#include "timer-gp.h"
44 44
45#include <plat/common.h>
46
45/* MAX_GPTIMER_ID: number of GPTIMERs on the chip */ 47/* MAX_GPTIMER_ID: number of GPTIMERs on the chip */
46#define MAX_GPTIMER_ID 12 48#define MAX_GPTIMER_ID 12
47 49
@@ -176,10 +178,14 @@ static void __init omap2_gp_clockevent_init(void)
176/* 178/*
177 * When 32k-timer is enabled, don't use GPTimer for clocksource 179 * When 32k-timer is enabled, don't use GPTimer for clocksource
178 * instead, just leave default clocksource which uses the 32k 180 * instead, just leave default clocksource which uses the 32k
179 * sync counter. See clocksource setup in see plat-omap/common.c. 181 * sync counter. See clocksource setup in plat-omap/counter_32k.c
180 */ 182 */
181 183
182static inline void __init omap2_gp_clocksource_init(void) {} 184static void __init omap2_gp_clocksource_init(void)
185{
186 omap_init_clocksource_32k();
187}
188
183#else 189#else
184/* 190/*
185 * clocksource 191 * clocksource
diff --git a/arch/arm/mach-realview/Kconfig b/arch/arm/mach-realview/Kconfig
index b4575ae9648e..7ca138a943a9 100644
--- a/arch/arm/mach-realview/Kconfig
+++ b/arch/arm/mach-realview/Kconfig
@@ -2,52 +2,56 @@ menu "RealView platform type"
2 depends on ARCH_REALVIEW 2 depends on ARCH_REALVIEW
3 3
4config MACH_REALVIEW_EB 4config MACH_REALVIEW_EB
5 bool "Support RealView/EB platform" 5 bool "Support RealView(R) Emulation Baseboard"
6 select ARM_GIC 6 select ARM_GIC
7 help 7 help
8 Include support for the ARM(R) RealView Emulation Baseboard platform. 8 Include support for the ARM(R) RealView(R) Emulation Baseboard
9 platform.
9 10
10config REALVIEW_EB_A9MP 11config REALVIEW_EB_A9MP
11 bool "Support Multicore Cortex-A9" 12 bool "Support Multicore Cortex-A9 Tile"
12 depends on MACH_REALVIEW_EB 13 depends on MACH_REALVIEW_EB
13 select CPU_V7 14 select CPU_V7
14 help 15 help
15 Enable support for the Cortex-A9MPCore tile on the Realview platform. 16 Enable support for the Cortex-A9MPCore tile fitted to the
17 Realview(R) Emulation Baseboard platform.
16 18
17config REALVIEW_EB_ARM11MP 19config REALVIEW_EB_ARM11MP
18 bool "Support ARM11MPCore tile" 20 bool "Support ARM11MPCore Tile"
19 depends on MACH_REALVIEW_EB 21 depends on MACH_REALVIEW_EB
20 select CPU_V6 22 select CPU_V6
21 select ARCH_HAS_BARRIERS if SMP 23 select ARCH_HAS_BARRIERS if SMP
22 help 24 help
23 Enable support for the ARM11MPCore tile on the Realview platform. 25 Enable support for the ARM11MPCore tile fitted to the Realview(R)
26 Emulation Baseboard platform.
24 27
25config REALVIEW_EB_ARM11MP_REVB 28config REALVIEW_EB_ARM11MP_REVB
26 bool "Support ARM11MPCore RevB tile" 29 bool "Support ARM11MPCore RevB Tile"
27 depends on REALVIEW_EB_ARM11MP 30 depends on REALVIEW_EB_ARM11MP
28 help 31 help
29 Enable support for the ARM11MPCore RevB tile on the Realview 32 Enable support for the ARM11MPCore Revision B tile on the
30 platform. Since there are device address differences, a 33 Realview(R) Emulation Baseboard platform. Since there are device
31 kernel built with this option enabled is not compatible with 34 address differences, a kernel built with this option enabled is
32 other revisions of the ARM11MPCore tile. 35 not compatible with other revisions of the ARM11MPCore tile.
33 36
34config MACH_REALVIEW_PB11MP 37config MACH_REALVIEW_PB11MP
35 bool "Support RealView/PB11MPCore platform" 38 bool "Support RealView(R) Platform Baseboard for ARM11MPCore"
36 select CPU_V6 39 select CPU_V6
37 select ARM_GIC 40 select ARM_GIC
38 select HAVE_PATA_PLATFORM 41 select HAVE_PATA_PLATFORM
39 select ARCH_HAS_BARRIERS if SMP 42 select ARCH_HAS_BARRIERS if SMP
40 help 43 help
41 Include support for the ARM(R) RealView MPCore Platform Baseboard. 44 Include support for the ARM(R) RealView(R) Platform Baseboard for
42 PB11MPCore is a platform with an on-board ARM11MPCore and has 45 the ARM11MPCore. This platform has an on-board ARM11MPCore and has
43 support for PCI-E and Compact Flash. 46 support for PCI-E and Compact Flash.
44 47
45config MACH_REALVIEW_PB1176 48config MACH_REALVIEW_PB1176
46 bool "Support RealView/PB1176 platform" 49 bool "Support RealView(R) Platform Baseboard for ARM1176JZF-S"
47 select CPU_V6 50 select CPU_V6
48 select ARM_GIC 51 select ARM_GIC
49 help 52 help
50 Include support for the ARM(R) RealView ARM1176 Platform Baseboard. 53 Include support for the ARM(R) RealView(R) Platform Baseboard for
54 ARM1176JZF-S.
51 55
52config REALVIEW_PB1176_SECURE_FLASH 56config REALVIEW_PB1176_SECURE_FLASH
53 bool "Allow access to the secure flash memory block" 57 bool "Allow access to the secure flash memory block"
@@ -59,23 +63,24 @@ config REALVIEW_PB1176_SECURE_FLASH
59 block (64MB @ 0x3c000000) is required. 63 block (64MB @ 0x3c000000) is required.
60 64
61config MACH_REALVIEW_PBA8 65config MACH_REALVIEW_PBA8
62 bool "Support RealView/PB-A8 platform" 66 bool "Support RealView(R) Platform Baseboard for Cortex(tm)-A8 platform"
63 select CPU_V7 67 select CPU_V7
64 select ARM_GIC 68 select ARM_GIC
65 select HAVE_PATA_PLATFORM 69 select HAVE_PATA_PLATFORM
66 help 70 help
67 Include support for the ARM(R) RealView Cortex-A8 Platform Baseboard. 71 Include support for the ARM(R) RealView Platform Baseboard for
68 PB-A8 is a platform with an on-board Cortex-A8 and has support for 72 Cortex(tm)-A8. This platform has an on-board Cortex-A8 and has
69 PCI-E and Compact Flash. 73 support for PCI-E and Compact Flash.
70 74
71config MACH_REALVIEW_PBX 75config MACH_REALVIEW_PBX
72 bool "Support RealView/PBX platform" 76 bool "Support RealView(R) Platform Baseboard Explore"
73 select ARM_GIC 77 select ARM_GIC
74 select HAVE_PATA_PLATFORM 78 select HAVE_PATA_PLATFORM
75 select ARCH_SPARSEMEM_ENABLE if CPU_V7 && !REALVIEW_HIGH_PHYS_OFFSET 79 select ARCH_SPARSEMEM_ENABLE if CPU_V7 && !REALVIEW_HIGH_PHYS_OFFSET
76 select ZONE_DMA if SPARSEMEM 80 select ZONE_DMA if SPARSEMEM
77 help 81 help
78 Include support for the ARM(R) RealView PBX platform. 82 Include support for the ARM(R) RealView(R) Platform Baseboard
83 Explore.
79 84
80config REALVIEW_HIGH_PHYS_OFFSET 85config REALVIEW_HIGH_PHYS_OFFSET
81 bool "High physical base address for the RealView platform" 86 bool "High physical base address for the RealView platform"
diff --git a/arch/arm/mach-realview/platsmp.c b/arch/arm/mach-realview/platsmp.c
index a22bf67f2f78..6959d13d908a 100644
--- a/arch/arm/mach-realview/platsmp.c
+++ b/arch/arm/mach-realview/platsmp.c
@@ -41,7 +41,7 @@ volatile int __cpuinitdata pen_release = -1;
41 * observers, irrespective of whether they're taking part in coherency 41 * observers, irrespective of whether they're taking part in coherency
42 * or not. This is necessary for the hotplug code to work reliably. 42 * or not. This is necessary for the hotplug code to work reliably.
43 */ 43 */
44static void write_pen_release(int val) 44static void __cpuinit write_pen_release(int val)
45{ 45{
46 pen_release = val; 46 pen_release = val;
47 smp_wmb(); 47 smp_wmb();
diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig
index 4d1b4c5c9389..0c8f6cf3e948 100644
--- a/arch/arm/mach-shmobile/Kconfig
+++ b/arch/arm/mach-shmobile/Kconfig
@@ -60,6 +60,8 @@ endchoice
60 60
61config MACH_AG5EVM 61config MACH_AG5EVM
62 bool "AG5EVM board" 62 bool "AG5EVM board"
63 select ARCH_REQUIRE_GPIOLIB
64 select SH_LCD_MIPI_DSI
63 depends on ARCH_SH73A0 65 depends on ARCH_SH73A0
64 66
65config MACH_MACKEREL 67config MACH_MACKEREL
diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c
index c18a740a4159..2123b96b5638 100644
--- a/arch/arm/mach-shmobile/board-ag5evm.c
+++ b/arch/arm/mach-shmobile/board-ag5evm.c
@@ -34,9 +34,10 @@
34#include <linux/input/sh_keysc.h> 34#include <linux/input/sh_keysc.h>
35#include <linux/mmc/host.h> 35#include <linux/mmc/host.h>
36#include <linux/mmc/sh_mmcif.h> 36#include <linux/mmc/sh_mmcif.h>
37 37#include <linux/sh_clk.h>
38#include <video/sh_mobile_lcdc.h>
39#include <video/sh_mipi_dsi.h>
38#include <sound/sh_fsi.h> 40#include <sound/sh_fsi.h>
39
40#include <mach/hardware.h> 41#include <mach/hardware.h>
41#include <mach/sh73a0.h> 42#include <mach/sh73a0.h>
42#include <mach/common.h> 43#include <mach/common.h>
@@ -183,11 +184,165 @@ static struct platform_device mmc_device = {
183 .resource = sh_mmcif_resources, 184 .resource = sh_mmcif_resources,
184}; 185};
185 186
187/* IrDA */
188static struct resource irda_resources[] = {
189 [0] = {
190 .start = 0xE6D00000,
191 .end = 0xE6D01FD4 - 1,
192 .flags = IORESOURCE_MEM,
193 },
194 [1] = {
195 .start = gic_spi(95),
196 .flags = IORESOURCE_IRQ,
197 },
198};
199
200static struct platform_device irda_device = {
201 .name = "sh_irda",
202 .id = 0,
203 .resource = irda_resources,
204 .num_resources = ARRAY_SIZE(irda_resources),
205};
206
207static unsigned char lcd_backlight_seq[3][2] = {
208 { 0x04, 0x07 },
209 { 0x23, 0x80 },
210 { 0x03, 0x01 },
211};
212
213static void lcd_backlight_on(void)
214{
215 struct i2c_adapter *a;
216 struct i2c_msg msg;
217 int k;
218
219 a = i2c_get_adapter(1);
220 for (k = 0; a && k < 3; k++) {
221 msg.addr = 0x6d;
222 msg.buf = &lcd_backlight_seq[k][0];
223 msg.len = 2;
224 msg.flags = 0;
225 if (i2c_transfer(a, &msg, 1) != 1)
226 break;
227 }
228}
229
230static void lcd_backlight_reset(void)
231{
232 gpio_set_value(GPIO_PORT235, 0);
233 mdelay(24);
234 gpio_set_value(GPIO_PORT235, 1);
235}
236
237static void lcd_on(void *board_data, struct fb_info *info)
238{
239 lcd_backlight_on();
240}
241
242static void lcd_off(void *board_data)
243{
244 lcd_backlight_reset();
245}
246
247/* LCDC0 */
248static const struct fb_videomode lcdc0_modes[] = {
249 {
250 .name = "R63302(QHD)",
251 .xres = 544,
252 .yres = 961,
253 .left_margin = 72,
254 .right_margin = 600,
255 .hsync_len = 16,
256 .upper_margin = 8,
257 .lower_margin = 8,
258 .vsync_len = 2,
259 .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
260 },
261};
262
263static struct sh_mobile_lcdc_info lcdc0_info = {
264 .clock_source = LCDC_CLK_PERIPHERAL,
265 .ch[0] = {
266 .chan = LCDC_CHAN_MAINLCD,
267 .interface_type = RGB24,
268 .clock_divider = 1,
269 .flags = LCDC_FLAGS_DWPOL,
270 .lcd_size_cfg.width = 44,
271 .lcd_size_cfg.height = 79,
272 .bpp = 16,
273 .lcd_cfg = lcdc0_modes,
274 .num_cfg = ARRAY_SIZE(lcdc0_modes),
275 .board_cfg = {
276 .display_on = lcd_on,
277 .display_off = lcd_off,
278 },
279 }
280};
281
282static struct resource lcdc0_resources[] = {
283 [0] = {
284 .name = "LCDC0",
285 .start = 0xfe940000, /* P4-only space */
286 .end = 0xfe943fff,
287 .flags = IORESOURCE_MEM,
288 },
289 [1] = {
290 .start = intcs_evt2irq(0x580),
291 .flags = IORESOURCE_IRQ,
292 },
293};
294
295static struct platform_device lcdc0_device = {
296 .name = "sh_mobile_lcdc_fb",
297 .num_resources = ARRAY_SIZE(lcdc0_resources),
298 .resource = lcdc0_resources,
299 .id = 0,
300 .dev = {
301 .platform_data = &lcdc0_info,
302 .coherent_dma_mask = ~0,
303 },
304};
305
306/* MIPI-DSI */
307static struct resource mipidsi0_resources[] = {
308 [0] = {
309 .start = 0xfeab0000,
310 .end = 0xfeab3fff,
311 .flags = IORESOURCE_MEM,
312 },
313 [1] = {
314 .start = 0xfeab4000,
315 .end = 0xfeab7fff,
316 .flags = IORESOURCE_MEM,
317 },
318};
319
320static struct sh_mipi_dsi_info mipidsi0_info = {
321 .data_format = MIPI_RGB888,
322 .lcd_chan = &lcdc0_info.ch[0],
323 .vsynw_offset = 20,
324 .clksrc = 1,
325 .flags = SH_MIPI_DSI_HSABM,
326};
327
328static struct platform_device mipidsi0_device = {
329 .name = "sh-mipi-dsi",
330 .num_resources = ARRAY_SIZE(mipidsi0_resources),
331 .resource = mipidsi0_resources,
332 .id = 0,
333 .dev = {
334 .platform_data = &mipidsi0_info,
335 },
336};
337
186static struct platform_device *ag5evm_devices[] __initdata = { 338static struct platform_device *ag5evm_devices[] __initdata = {
187 &eth_device, 339 &eth_device,
188 &keysc_device, 340 &keysc_device,
189 &fsi_device, 341 &fsi_device,
190 &mmc_device, 342 &mmc_device,
343 &irda_device,
344 &lcdc0_device,
345 &mipidsi0_device,
191}; 346};
192 347
193static struct map_desc ag5evm_io_desc[] __initdata = { 348static struct map_desc ag5evm_io_desc[] __initdata = {
@@ -224,6 +379,8 @@ void __init ag5evm_init_irq(void)
224 __raw_writew(__raw_readw(PINTCR0A) | (2<<10), PINTCR0A); 379 __raw_writew(__raw_readw(PINTCR0A) | (2<<10), PINTCR0A);
225} 380}
226 381
382#define DSI0PHYCR 0xe615006c
383
227static void __init ag5evm_init(void) 384static void __init ag5evm_init(void)
228{ 385{
229 sh73a0_pinmux_init(); 386 sh73a0_pinmux_init();
@@ -287,6 +444,25 @@ static void __init ag5evm_init(void)
287 gpio_request(GPIO_FN_FSIAISLD, NULL); 444 gpio_request(GPIO_FN_FSIAISLD, NULL);
288 gpio_request(GPIO_FN_FSIAOSLD, NULL); 445 gpio_request(GPIO_FN_FSIAOSLD, NULL);
289 446
447 /* IrDA */
448 gpio_request(GPIO_FN_PORT241_IRDA_OUT, NULL);
449 gpio_request(GPIO_FN_PORT242_IRDA_IN, NULL);
450 gpio_request(GPIO_FN_PORT243_IRDA_FIRSEL, NULL);
451
452 /* LCD panel */
453 gpio_request(GPIO_PORT217, NULL); /* RESET */
454 gpio_direction_output(GPIO_PORT217, 0);
455 mdelay(1);
456 gpio_set_value(GPIO_PORT217, 1);
457
458 /* LCD backlight controller */
459 gpio_request(GPIO_PORT235, NULL); /* RESET */
460 gpio_direction_output(GPIO_PORT235, 0);
461 lcd_backlight_reset();
462
463 /* MIPI-DSI clock setup */
464 __raw_writel(0x2a809010, DSI0PHYCR);
465
290#ifdef CONFIG_CACHE_L2X0 466#ifdef CONFIG_CACHE_L2X0
291 /* Shared attribute override enable, 64K*8way */ 467 /* Shared attribute override enable, 64K*8way */
292 l2x0_init(__io(0xf0100000), 0x00460000, 0xc2000fff); 468 l2x0_init(__io(0xf0100000), 0x00460000, 0xc2000fff);
diff --git a/arch/arm/mach-shmobile/board-g3evm.c b/arch/arm/mach-shmobile/board-g3evm.c
index 686b304a7708..ef4613b993a2 100644
--- a/arch/arm/mach-shmobile/board-g3evm.c
+++ b/arch/arm/mach-shmobile/board-g3evm.c
@@ -347,7 +347,6 @@ static void __init g3evm_init(void)
347 gpio_request(GPIO_FN_IRDA_OUT, NULL); 347 gpio_request(GPIO_FN_IRDA_OUT, NULL);
348 gpio_request(GPIO_FN_IRDA_IN, NULL); 348 gpio_request(GPIO_FN_IRDA_IN, NULL);
349 gpio_request(GPIO_FN_IRDA_FIRSEL, NULL); 349 gpio_request(GPIO_FN_IRDA_FIRSEL, NULL);
350 set_irq_type(evt2irq(0x480), IRQ_TYPE_LEVEL_LOW);
351 350
352 sh7367_add_standard_devices(); 351 sh7367_add_standard_devices();
353 352
diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c
index 7b15d21f0f68..fb4213a4e15a 100644
--- a/arch/arm/mach-shmobile/board-mackerel.c
+++ b/arch/arm/mach-shmobile/board-mackerel.c
@@ -169,9 +169,8 @@
169 * SW1 | SW33 169 * SW1 | SW33
170 * | bit1 | bit2 | bit3 | bit4 170 * | bit1 | bit2 | bit3 | bit4
171 * -------------+------+------+------+------- 171 * -------------+------+------+------+-------
172 * MMC0 OFF | OFF | ON | ON | X 172 * MMC0 OFF | OFF | X | ON | X (Use MMCIF)
173 * MMC1 ON | OFF | ON | X | ON 173 * SDHI1 OFF | ON | X | OFF | X (Use MFD_SH_MOBILE_SDHI)
174 * SDHI1 OFF | ON | X | OFF | ON
175 * 174 *
176 */ 175 */
177 176
diff --git a/arch/arm/mach-shmobile/clock-sh7372.c b/arch/arm/mach-shmobile/clock-sh7372.c
index 9aa8d68d1a9c..e9731b5a73ed 100644
--- a/arch/arm/mach-shmobile/clock-sh7372.c
+++ b/arch/arm/mach-shmobile/clock-sh7372.c
@@ -234,7 +234,9 @@ static int pllc2_set_rate(struct clk *clk, unsigned long rate)
234 234
235 value = __raw_readl(PLLC2CR) & ~(0x3f << 24); 235 value = __raw_readl(PLLC2CR) & ~(0x3f << 24);
236 236
237 __raw_writel((value & ~0x80000000) | ((idx + 19) << 24), PLLC2CR); 237 __raw_writel(value | ((idx + 19) << 24), PLLC2CR);
238
239 clk->rate = clk->freq_table[idx].frequency;
238 240
239 return 0; 241 return 0;
240} 242}
diff --git a/arch/arm/mach-shmobile/clock-sh73a0.c b/arch/arm/mach-shmobile/clock-sh73a0.c
index 720a71433be6..ddd4a1b775f0 100644
--- a/arch/arm/mach-shmobile/clock-sh73a0.c
+++ b/arch/arm/mach-shmobile/clock-sh73a0.c
@@ -118,8 +118,16 @@ static unsigned long pll_recalc(struct clk *clk)
118{ 118{
119 unsigned long mult = 1; 119 unsigned long mult = 1;
120 120
121 if (__raw_readl(PLLECR) & (1 << clk->enable_bit)) 121 if (__raw_readl(PLLECR) & (1 << clk->enable_bit)) {
122 mult = (((__raw_readl(clk->enable_reg) >> 24) & 0x3f) + 1); 122 mult = (((__raw_readl(clk->enable_reg) >> 24) & 0x3f) + 1);
123 /* handle CFG bit for PLL1 and PLL2 */
124 switch (clk->enable_bit) {
125 case 1:
126 case 2:
127 if (__raw_readl(clk->enable_reg) & (1 << 20))
128 mult *= 2;
129 }
130 }
123 131
124 return clk->parent->rate * mult; 132 return clk->parent->rate * mult;
125} 133}
@@ -212,7 +220,7 @@ enum { DIV4_I, DIV4_ZG, DIV4_M3, DIV4_B, DIV4_M1, DIV4_M2,
212static struct clk div4_clks[DIV4_NR] = { 220static struct clk div4_clks[DIV4_NR] = {
213 [DIV4_I] = DIV4(FRQCRA, 20, 0xfff, CLK_ENABLE_ON_INIT), 221 [DIV4_I] = DIV4(FRQCRA, 20, 0xfff, CLK_ENABLE_ON_INIT),
214 [DIV4_ZG] = DIV4(FRQCRA, 16, 0xbff, CLK_ENABLE_ON_INIT), 222 [DIV4_ZG] = DIV4(FRQCRA, 16, 0xbff, CLK_ENABLE_ON_INIT),
215 [DIV4_M3] = DIV4(FRQCRA, 8, 0xfff, CLK_ENABLE_ON_INIT), 223 [DIV4_M3] = DIV4(FRQCRA, 12, 0xfff, CLK_ENABLE_ON_INIT),
216 [DIV4_B] = DIV4(FRQCRA, 8, 0xfff, CLK_ENABLE_ON_INIT), 224 [DIV4_B] = DIV4(FRQCRA, 8, 0xfff, CLK_ENABLE_ON_INIT),
217 [DIV4_M1] = DIV4(FRQCRA, 4, 0xfff, 0), 225 [DIV4_M1] = DIV4(FRQCRA, 4, 0xfff, 0),
218 [DIV4_M2] = DIV4(FRQCRA, 0, 0xfff, 0), 226 [DIV4_M2] = DIV4(FRQCRA, 0, 0xfff, 0),
@@ -255,10 +263,10 @@ static struct clk div6_clks[DIV6_NR] = {
255}; 263};
256 264
257enum { MSTP001, 265enum { MSTP001,
258 MSTP125, MSTP116, 266 MSTP125, MSTP118, MSTP116, MSTP100,
259 MSTP219, 267 MSTP219,
260 MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200, 268 MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200,
261 MSTP331, MSTP329, MSTP323, MSTP312, 269 MSTP331, MSTP329, MSTP325, MSTP323, MSTP312,
262 MSTP411, MSTP410, MSTP403, 270 MSTP411, MSTP410, MSTP403,
263 MSTP_NR }; 271 MSTP_NR };
264 272
@@ -268,7 +276,9 @@ enum { MSTP001,
268static struct clk mstp_clks[MSTP_NR] = { 276static struct clk mstp_clks[MSTP_NR] = {
269 [MSTP001] = MSTP(&div4_clks[DIV4_HP], SMSTPCR0, 1, 0), /* IIC2 */ 277 [MSTP001] = MSTP(&div4_clks[DIV4_HP], SMSTPCR0, 1, 0), /* IIC2 */
270 [MSTP125] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR1, 25, 0), /* TMU0 */ 278 [MSTP125] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR1, 25, 0), /* TMU0 */
279 [MSTP118] = MSTP(&div4_clks[DIV4_B], SMSTPCR1, 18, 0), /* DSITX0 */
271 [MSTP116] = MSTP(&div4_clks[DIV4_HP], SMSTPCR1, 16, 0), /* IIC0 */ 280 [MSTP116] = MSTP(&div4_clks[DIV4_HP], SMSTPCR1, 16, 0), /* IIC0 */
281 [MSTP100] = MSTP(&div4_clks[DIV4_B], SMSTPCR1, 0, 0), /* LCDC0 */
272 [MSTP219] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 19, 0), /* SCIFA7 */ 282 [MSTP219] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 19, 0), /* SCIFA7 */
273 [MSTP207] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 7, 0), /* SCIFA5 */ 283 [MSTP207] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 7, 0), /* SCIFA5 */
274 [MSTP206] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 6, 0), /* SCIFB */ 284 [MSTP206] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 6, 0), /* SCIFB */
@@ -279,6 +289,7 @@ static struct clk mstp_clks[MSTP_NR] = {
279 [MSTP200] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 0, 0), /* SCIFA4 */ 289 [MSTP200] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 0, 0), /* SCIFA4 */
280 [MSTP331] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR3, 31, 0), /* SCIFA6 */ 290 [MSTP331] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR3, 31, 0), /* SCIFA6 */
281 [MSTP329] = MSTP(&r_clk, SMSTPCR3, 29, 0), /* CMT10 */ 291 [MSTP329] = MSTP(&r_clk, SMSTPCR3, 29, 0), /* CMT10 */
292 [MSTP325] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR3, 25, 0), /* IrDA */
282 [MSTP323] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 23, 0), /* IIC1 */ 293 [MSTP323] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 23, 0), /* IIC1 */
283 [MSTP312] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 12, 0), /* MMCIF0 */ 294 [MSTP312] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 12, 0), /* MMCIF0 */
284 [MSTP411] = MSTP(&div4_clks[DIV4_HP], SMSTPCR4, 11, 0), /* IIC3 */ 295 [MSTP411] = MSTP(&div4_clks[DIV4_HP], SMSTPCR4, 11, 0), /* IIC3 */
@@ -288,16 +299,25 @@ static struct clk mstp_clks[MSTP_NR] = {
288 299
289#define CLKDEV_CON_ID(_id, _clk) { .con_id = _id, .clk = _clk } 300#define CLKDEV_CON_ID(_id, _clk) { .con_id = _id, .clk = _clk }
290#define CLKDEV_DEV_ID(_id, _clk) { .dev_id = _id, .clk = _clk } 301#define CLKDEV_DEV_ID(_id, _clk) { .dev_id = _id, .clk = _clk }
302#define CLKDEV_ICK_ID(_cid, _did, _clk) { .con_id = _cid, .dev_id = _did, .clk = _clk }
291 303
292static struct clk_lookup lookups[] = { 304static struct clk_lookup lookups[] = {
293 /* main clocks */ 305 /* main clocks */
294 CLKDEV_CON_ID("r_clk", &r_clk), 306 CLKDEV_CON_ID("r_clk", &r_clk),
295 307
308 /* DIV6 clocks */
309 CLKDEV_ICK_ID("dsit_clk", "sh-mipi-dsi.0", &div6_clks[DIV6_DSIT]),
310 CLKDEV_ICK_ID("dsit_clk", "sh-mipi-dsi.1", &div6_clks[DIV6_DSIT]),
311 CLKDEV_ICK_ID("dsi0p_clk", "sh-mipi-dsi.0", &div6_clks[DIV6_DSI0P]),
312 CLKDEV_ICK_ID("dsi1p_clk", "sh-mipi-dsi.1", &div6_clks[DIV6_DSI1P]),
313
296 /* MSTP32 clocks */ 314 /* MSTP32 clocks */
297 CLKDEV_DEV_ID("i2c-sh_mobile.2", &mstp_clks[MSTP001]), /* I2C2 */ 315 CLKDEV_DEV_ID("i2c-sh_mobile.2", &mstp_clks[MSTP001]), /* I2C2 */
316 CLKDEV_DEV_ID("sh_mobile_lcdc_fb.0", &mstp_clks[MSTP100]), /* LCDC0 */
298 CLKDEV_DEV_ID("sh_tmu.0", &mstp_clks[MSTP125]), /* TMU00 */ 317 CLKDEV_DEV_ID("sh_tmu.0", &mstp_clks[MSTP125]), /* TMU00 */
299 CLKDEV_DEV_ID("sh_tmu.1", &mstp_clks[MSTP125]), /* TMU01 */ 318 CLKDEV_DEV_ID("sh_tmu.1", &mstp_clks[MSTP125]), /* TMU01 */
300 CLKDEV_DEV_ID("i2c-sh_mobile.0", &mstp_clks[MSTP116]), /* I2C0 */ 319 CLKDEV_DEV_ID("i2c-sh_mobile.0", &mstp_clks[MSTP116]), /* I2C0 */
320 CLKDEV_DEV_ID("sh-mipi-dsi.0", &mstp_clks[MSTP118]), /* DSITX */
301 CLKDEV_DEV_ID("sh-sci.7", &mstp_clks[MSTP219]), /* SCIFA7 */ 321 CLKDEV_DEV_ID("sh-sci.7", &mstp_clks[MSTP219]), /* SCIFA7 */
302 CLKDEV_DEV_ID("sh-sci.5", &mstp_clks[MSTP207]), /* SCIFA5 */ 322 CLKDEV_DEV_ID("sh-sci.5", &mstp_clks[MSTP207]), /* SCIFA5 */
303 CLKDEV_DEV_ID("sh-sci.8", &mstp_clks[MSTP206]), /* SCIFB */ 323 CLKDEV_DEV_ID("sh-sci.8", &mstp_clks[MSTP206]), /* SCIFB */
@@ -308,6 +328,7 @@ static struct clk_lookup lookups[] = {
308 CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[MSTP200]), /* SCIFA4 */ 328 CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[MSTP200]), /* SCIFA4 */
309 CLKDEV_DEV_ID("sh-sci.6", &mstp_clks[MSTP331]), /* SCIFA6 */ 329 CLKDEV_DEV_ID("sh-sci.6", &mstp_clks[MSTP331]), /* SCIFA6 */
310 CLKDEV_DEV_ID("sh_cmt.10", &mstp_clks[MSTP329]), /* CMT10 */ 330 CLKDEV_DEV_ID("sh_cmt.10", &mstp_clks[MSTP329]), /* CMT10 */
331 CLKDEV_DEV_ID("sh_irda.0", &mstp_clks[MSTP325]), /* IrDA */
311 CLKDEV_DEV_ID("i2c-sh_mobile.1", &mstp_clks[MSTP323]), /* I2C1 */ 332 CLKDEV_DEV_ID("i2c-sh_mobile.1", &mstp_clks[MSTP323]), /* I2C1 */
312 CLKDEV_DEV_ID("sh_mmcif.0", &mstp_clks[MSTP312]), /* MMCIF0 */ 333 CLKDEV_DEV_ID("sh_mmcif.0", &mstp_clks[MSTP312]), /* MMCIF0 */
313 CLKDEV_DEV_ID("i2c-sh_mobile.3", &mstp_clks[MSTP411]), /* I2C3 */ 334 CLKDEV_DEV_ID("i2c-sh_mobile.3", &mstp_clks[MSTP411]), /* I2C3 */
diff --git a/arch/arm/mach-shmobile/intc-sh7372.c b/arch/arm/mach-shmobile/intc-sh7372.c
index f78a1ead71a5..ca5f9d17b39a 100644
--- a/arch/arm/mach-shmobile/intc-sh7372.c
+++ b/arch/arm/mach-shmobile/intc-sh7372.c
@@ -365,6 +365,7 @@ static struct intc_desc intca_desc __initdata = {
365 365
366enum { 366enum {
367 UNUSED_INTCS = 0, 367 UNUSED_INTCS = 0,
368 ENABLED_INTCS,
368 369
369 INTCS, 370 INTCS,
370 371
@@ -413,7 +414,7 @@ enum {
413 CMT4, 414 CMT4,
414 DSITX1_DSITX1_0, 415 DSITX1_DSITX1_0,
415 DSITX1_DSITX1_1, 416 DSITX1_DSITX1_1,
416 /* MFIS2 */ 417 MFIS2_INTCS, /* Priority always enabled using ENABLED_INTCS */
417 CPORTS2R, 418 CPORTS2R,
418 /* CEC */ 419 /* CEC */
419 JPU6E, 420 JPU6E,
@@ -477,7 +478,7 @@ static struct intc_vect intcs_vectors[] = {
477 INTCS_VECT(CMT4, 0x1980), 478 INTCS_VECT(CMT4, 0x1980),
478 INTCS_VECT(DSITX1_DSITX1_0, 0x19a0), 479 INTCS_VECT(DSITX1_DSITX1_0, 0x19a0),
479 INTCS_VECT(DSITX1_DSITX1_1, 0x19c0), 480 INTCS_VECT(DSITX1_DSITX1_1, 0x19c0),
480 /* MFIS2 */ 481 INTCS_VECT(MFIS2_INTCS, 0x1a00),
481 INTCS_VECT(CPORTS2R, 0x1a20), 482 INTCS_VECT(CPORTS2R, 0x1a20),
482 /* CEC */ 483 /* CEC */
483 INTCS_VECT(JPU6E, 0x1a80), 484 INTCS_VECT(JPU6E, 0x1a80),
@@ -543,7 +544,7 @@ static struct intc_mask_reg intcs_mask_registers[] = {
543 { 0, TMU1_TUNI2, TMU1_TUNI1, TMU1_TUNI0, 544 { 0, TMU1_TUNI2, TMU1_TUNI1, TMU1_TUNI0,
544 CMT4, DSITX1_DSITX1_0, DSITX1_DSITX1_1, 0 } }, 545 CMT4, DSITX1_DSITX1_0, DSITX1_DSITX1_1, 0 } },
545 { 0xffd5019c, 0xffd501dc, 8, /* IMR7SA3 / IMCR7SA3 */ 546 { 0xffd5019c, 0xffd501dc, 8, /* IMR7SA3 / IMCR7SA3 */
546 { 0, CPORTS2R, 0, 0, 547 { MFIS2_INTCS, CPORTS2R, 0, 0,
547 JPU6E, 0, 0, 0 } }, 548 JPU6E, 0, 0, 0 } },
548 { 0xffd20104, 0, 16, /* INTAMASK */ 549 { 0xffd20104, 0, 16, /* INTAMASK */
549 { 0, 0, 0, 0, 0, 0, 0, 0, 550 { 0, 0, 0, 0, 0, 0, 0, 0,
@@ -571,7 +572,8 @@ static struct intc_prio_reg intcs_prio_registers[] = {
571 { 0xffd50030, 0, 16, 4, /* IPRMS3 */ { TMU1, 0, 0, 0 } }, 572 { 0xffd50030, 0, 16, 4, /* IPRMS3 */ { TMU1, 0, 0, 0 } },
572 { 0xffd50034, 0, 16, 4, /* IPRNS3 */ { CMT4, DSITX1_DSITX1_0, 573 { 0xffd50034, 0, 16, 4, /* IPRNS3 */ { CMT4, DSITX1_DSITX1_0,
573 DSITX1_DSITX1_1, 0 } }, 574 DSITX1_DSITX1_1, 0 } },
574 { 0xffd50038, 0, 16, 4, /* IPROS3 */ { 0, CPORTS2R, 0, 0 } }, 575 { 0xffd50038, 0, 16, 4, /* IPROS3 */ { ENABLED_INTCS, CPORTS2R,
576 0, 0 } },
575 { 0xffd5003c, 0, 16, 4, /* IPRPS3 */ { JPU6E, 0, 0, 0 } }, 577 { 0xffd5003c, 0, 16, 4, /* IPRPS3 */ { JPU6E, 0, 0, 0 } },
576}; 578};
577 579
@@ -590,6 +592,7 @@ static struct resource intcs_resources[] __initdata = {
590 592
591static struct intc_desc intcs_desc __initdata = { 593static struct intc_desc intcs_desc __initdata = {
592 .name = "sh7372-intcs", 594 .name = "sh7372-intcs",
595 .force_enable = ENABLED_INTCS,
593 .resource = intcs_resources, 596 .resource = intcs_resources,
594 .num_resources = ARRAY_SIZE(intcs_resources), 597 .num_resources = ARRAY_SIZE(intcs_resources),
595 .hw = INTC_HW_DESC(intcs_vectors, intcs_groups, intcs_mask_registers, 598 .hw = INTC_HW_DESC(intcs_vectors, intcs_groups, intcs_mask_registers,
diff --git a/arch/arm/mach-shmobile/intc-sh73a0.c b/arch/arm/mach-shmobile/intc-sh73a0.c
index 322d8d57cbcf..5d0e1503ece6 100644
--- a/arch/arm/mach-shmobile/intc-sh73a0.c
+++ b/arch/arm/mach-shmobile/intc-sh73a0.c
@@ -252,10 +252,11 @@ static irqreturn_t sh73a0_intcs_demux(int irq, void *dev_id)
252 252
253void __init sh73a0_init_irq(void) 253void __init sh73a0_init_irq(void)
254{ 254{
255 void __iomem *gic_base = __io(0xf0001000); 255 void __iomem *gic_dist_base = __io(0xf0001000);
256 void __iomem *gic_cpu_base = __io(0xf0000100);
256 void __iomem *intevtsa = ioremap_nocache(0xffd20100, PAGE_SIZE); 257 void __iomem *intevtsa = ioremap_nocache(0xffd20100, PAGE_SIZE);
257 258
258 gic_init(0, 29, gic_base, gic_base); 259 gic_init(0, 29, gic_dist_base, gic_cpu_base);
259 260
260 register_intc_controller(&intcs_desc); 261 register_intc_controller(&intcs_desc);
261 262
diff --git a/arch/arm/mach-tegra/include/mach/kbc.h b/arch/arm/mach-tegra/include/mach/kbc.h
new file mode 100644
index 000000000000..66ad2760c621
--- /dev/null
+++ b/arch/arm/mach-tegra/include/mach/kbc.h
@@ -0,0 +1,61 @@
1/*
2 * Platform definitions for tegra-kbc keyboard input driver
3 *
4 * Copyright (c) 2010-2011, NVIDIA Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20
21#ifndef ASMARM_ARCH_TEGRA_KBC_H
22#define ASMARM_ARCH_TEGRA_KBC_H
23
24#include <linux/types.h>
25#include <linux/input/matrix_keypad.h>
26
27#ifdef CONFIG_ARCH_TEGRA_2x_SOC
28#define KBC_MAX_GPIO 24
29#define KBC_MAX_KPENT 8
30#else
31#define KBC_MAX_GPIO 20
32#define KBC_MAX_KPENT 7
33#endif
34
35#define KBC_MAX_ROW 16
36#define KBC_MAX_COL 8
37#define KBC_MAX_KEY (KBC_MAX_ROW * KBC_MAX_COL)
38
39struct tegra_kbc_pin_cfg {
40 bool is_row;
41 unsigned char num;
42};
43
44struct tegra_kbc_wake_key {
45 u8 row:4;
46 u8 col:4;
47};
48
49struct tegra_kbc_platform_data {
50 unsigned int debounce_cnt;
51 unsigned int repeat_cnt;
52
53 unsigned int wake_cnt; /* 0:wake on any key >1:wake on wake_cfg */
54 const struct tegra_kbc_wake_key *wake_cfg;
55
56 struct tegra_kbc_pin_cfg pin_cfg[KBC_MAX_GPIO];
57 const struct matrix_keymap_data *keymap_data;
58
59 bool wakeup;
60};
61#endif
diff --git a/arch/arm/mach-versatile/Kconfig b/arch/arm/mach-versatile/Kconfig
index 3f7b5e9d83c5..9cdec5aa04a0 100644
--- a/arch/arm/mach-versatile/Kconfig
+++ b/arch/arm/mach-versatile/Kconfig
@@ -2,17 +2,19 @@ menu "Versatile platform type"
2 depends on ARCH_VERSATILE 2 depends on ARCH_VERSATILE
3 3
4config ARCH_VERSATILE_PB 4config ARCH_VERSATILE_PB
5 bool "Support Versatile/PB platform" 5 bool "Support Versatile Platform Baseboard for ARM926EJ-S"
6 select CPU_ARM926T 6 select CPU_ARM926T
7 select MIGHT_HAVE_PCI 7 select MIGHT_HAVE_PCI
8 default y 8 default y
9 help 9 help
10 Include support for the ARM(R) Versatile/PB platform. 10 Include support for the ARM(R) Versatile Platform Baseboard
11 for the ARM926EJ-S.
11 12
12config MACH_VERSATILE_AB 13config MACH_VERSATILE_AB
13 bool "Support Versatile/AB platform" 14 bool "Support Versatile Application Baseboard for ARM926EJ-S"
14 select CPU_ARM926T 15 select CPU_ARM926T
15 help 16 help
16 Include support for the ARM(R) Versatile/AP platform. 17 Include support for the ARM(R) Versatile Application Baseboard
18 for the ARM926EJ-S.
17 19
18endmenu 20endmenu
diff --git a/arch/arm/mach-vexpress/platsmp.c b/arch/arm/mach-vexpress/platsmp.c
index b1687b6abe63..634bf1d3a311 100644
--- a/arch/arm/mach-vexpress/platsmp.c
+++ b/arch/arm/mach-vexpress/platsmp.c
@@ -39,7 +39,7 @@ volatile int __cpuinitdata pen_release = -1;
39 * observers, irrespective of whether they're taking part in coherency 39 * observers, irrespective of whether they're taking part in coherency
40 * or not. This is necessary for the hotplug code to work reliably. 40 * or not. This is necessary for the hotplug code to work reliably.
41 */ 41 */
42static void write_pen_release(int val) 42static void __cpuinit write_pen_release(int val)
43{ 43{
44 pen_release = val; 44 pen_release = val;
45 smp_wmb(); 45 smp_wmb();
diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
index a9ed3428a2fa..1edae65a0e72 100644
--- a/arch/arm/mach-vexpress/v2m.c
+++ b/arch/arm/mach-vexpress/v2m.c
@@ -19,6 +19,7 @@
19#include <asm/mach/time.h> 19#include <asm/mach/time.h>
20#include <asm/hardware/arm_timer.h> 20#include <asm/hardware/arm_timer.h>
21#include <asm/hardware/timer-sp.h> 21#include <asm/hardware/timer-sp.h>
22#include <asm/hardware/sp810.h>
22 23
23#include <mach/motherboard.h> 24#include <mach/motherboard.h>
24 25
@@ -50,8 +51,16 @@ void __init v2m_map_io(struct map_desc *tile, size_t num)
50 51
51static void __init v2m_timer_init(void) 52static void __init v2m_timer_init(void)
52{ 53{
54 u32 scctrl;
55
53 versatile_sched_clock_init(MMIO_P2V(V2M_SYS_24MHZ), 24000000); 56 versatile_sched_clock_init(MMIO_P2V(V2M_SYS_24MHZ), 24000000);
54 57
58 /* Select 1MHz TIMCLK as the reference clock for SP804 timers */
59 scctrl = readl(MMIO_P2V(V2M_SYSCTL + SCCTRL));
60 scctrl |= SCCTRL_TIMEREN0SEL_TIMCLK;
61 scctrl |= SCCTRL_TIMEREN1SEL_TIMCLK;
62 writel(scctrl, MMIO_P2V(V2M_SYSCTL + SCCTRL));
63
55 writel(0, MMIO_P2V(V2M_TIMER0) + TIMER_CTRL); 64 writel(0, MMIO_P2V(V2M_TIMER0) + TIMER_CTRL);
56 writel(0, MMIO_P2V(V2M_TIMER1) + TIMER_CTRL); 65 writel(0, MMIO_P2V(V2M_TIMER1) + TIMER_CTRL);
57 66
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index 18fe3cb195dc..b6333ae3f92a 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -144,12 +144,9 @@ config OMAP_IOMMU_DEBUG
144config OMAP_IOMMU_IVA2 144config OMAP_IOMMU_IVA2
145 bool 145 bool
146 146
147choice
148 prompt "System timer"
149 default OMAP_32K_TIMER if !ARCH_OMAP15XX
150
151config OMAP_MPU_TIMER 147config OMAP_MPU_TIMER
152 bool "Use mpu timer" 148 bool "Use mpu timer"
149 depends on ARCH_OMAP1
153 help 150 help
154 Select this option if you want to use the OMAP mpu timer. This 151 Select this option if you want to use the OMAP mpu timer. This
155 timer provides more intra-tick resolution than the 32KHz timer, 152 timer provides more intra-tick resolution than the 32KHz timer,
@@ -158,6 +155,7 @@ config OMAP_MPU_TIMER
158config OMAP_32K_TIMER 155config OMAP_32K_TIMER
159 bool "Use 32KHz timer" 156 bool "Use 32KHz timer"
160 depends on ARCH_OMAP16XX || ARCH_OMAP2PLUS 157 depends on ARCH_OMAP16XX || ARCH_OMAP2PLUS
158 default y if (ARCH_OMAP16XX || ARCH_OMAP2PLUS)
161 help 159 help
162 Select this option if you want to enable the OMAP 32KHz timer. 160 Select this option if you want to enable the OMAP 32KHz timer.
163 This timer saves power compared to the OMAP_MPU_TIMER, and has 161 This timer saves power compared to the OMAP_MPU_TIMER, and has
@@ -165,8 +163,6 @@ config OMAP_32K_TIMER
165 intra-tick resolution than OMAP_MPU_TIMER. The 32KHz timer is 163 intra-tick resolution than OMAP_MPU_TIMER. The 32KHz timer is
166 currently only available for OMAP16XX, 24XX, 34XX and OMAP4. 164 currently only available for OMAP16XX, 24XX, 34XX and OMAP4.
167 165
168endchoice
169
170config OMAP3_L2_AUX_SECURE_SAVE_RESTORE 166config OMAP3_L2_AUX_SECURE_SAVE_RESTORE
171 bool "OMAP3 HS/EMU save and restore for L2 AUX control register" 167 bool "OMAP3 HS/EMU save and restore for L2 AUX control register"
172 depends on ARCH_OMAP3 && PM 168 depends on ARCH_OMAP3 && PM
diff --git a/arch/arm/plat-omap/counter_32k.c b/arch/arm/plat-omap/counter_32k.c
index ea4644021fb9..862dda95d61d 100644
--- a/arch/arm/plat-omap/counter_32k.c
+++ b/arch/arm/plat-omap/counter_32k.c
@@ -36,8 +36,6 @@
36 36
37#define OMAP16XX_TIMER_32K_SYNCHRONIZED 0xfffbc410 37#define OMAP16XX_TIMER_32K_SYNCHRONIZED 0xfffbc410
38 38
39#if !(defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP15XX))
40
41#include <linux/clocksource.h> 39#include <linux/clocksource.h>
42 40
43/* 41/*
@@ -122,12 +120,24 @@ static DEFINE_CLOCK_DATA(cd);
122#define SC_MULT 4000000000u 120#define SC_MULT 4000000000u
123#define SC_SHIFT 17 121#define SC_SHIFT 17
124 122
125unsigned long long notrace sched_clock(void) 123static inline unsigned long long notrace _omap_32k_sched_clock(void)
126{ 124{
127 u32 cyc = clocksource_32k.read(&clocksource_32k); 125 u32 cyc = clocksource_32k.read(&clocksource_32k);
128 return cyc_to_fixed_sched_clock(&cd, cyc, (u32)~0, SC_MULT, SC_SHIFT); 126 return cyc_to_fixed_sched_clock(&cd, cyc, (u32)~0, SC_MULT, SC_SHIFT);
129} 127}
130 128
129#ifndef CONFIG_OMAP_MPU_TIMER
130unsigned long long notrace sched_clock(void)
131{
132 return _omap_32k_sched_clock();
133}
134#else
135unsigned long long notrace omap_32k_sched_clock(void)
136{
137 return _omap_32k_sched_clock();
138}
139#endif
140
131static void notrace omap_update_sched_clock(void) 141static void notrace omap_update_sched_clock(void)
132{ 142{
133 u32 cyc = clocksource_32k.read(&clocksource_32k); 143 u32 cyc = clocksource_32k.read(&clocksource_32k);
@@ -160,7 +170,7 @@ void read_persistent_clock(struct timespec *ts)
160 *ts = *tsp; 170 *ts = *tsp;
161} 171}
162 172
163static int __init omap_init_clocksource_32k(void) 173int __init omap_init_clocksource_32k(void)
164{ 174{
165 static char err[] __initdata = KERN_ERR 175 static char err[] __initdata = KERN_ERR
166 "%s: can't register clocksource!\n"; 176 "%s: can't register clocksource!\n";
@@ -195,7 +205,3 @@ static int __init omap_init_clocksource_32k(void)
195 } 205 }
196 return 0; 206 return 0;
197} 207}
198arch_initcall(omap_init_clocksource_32k);
199
200#endif /* !(defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP15XX)) */
201
diff --git a/arch/arm/plat-omap/dma.c b/arch/arm/plat-omap/dma.c
index c4b2b478b1a5..85363084cc1a 100644
--- a/arch/arm/plat-omap/dma.c
+++ b/arch/arm/plat-omap/dma.c
@@ -53,7 +53,7 @@ enum { DMA_CHAIN_STARTED, DMA_CHAIN_NOTSTARTED };
53#endif 53#endif
54 54
55#define OMAP_DMA_ACTIVE 0x01 55#define OMAP_DMA_ACTIVE 0x01
56#define OMAP2_DMA_CSR_CLEAR_MASK 0xffe 56#define OMAP2_DMA_CSR_CLEAR_MASK 0xffffffff
57 57
58#define OMAP_FUNC_MUX_ARM_BASE (0xfffe1000 + 0xec) 58#define OMAP_FUNC_MUX_ARM_BASE (0xfffe1000 + 0xec)
59 59
@@ -1873,7 +1873,7 @@ static int omap2_dma_handle_ch(int ch)
1873 printk(KERN_INFO "DMA misaligned error with device %d\n", 1873 printk(KERN_INFO "DMA misaligned error with device %d\n",
1874 dma_chan[ch].dev_id); 1874 dma_chan[ch].dev_id);
1875 1875
1876 p->dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR, ch); 1876 p->dma_write(status, CSR, ch);
1877 p->dma_write(1 << ch, IRQSTATUS_L0, ch); 1877 p->dma_write(1 << ch, IRQSTATUS_L0, ch);
1878 /* read back the register to flush the write */ 1878 /* read back the register to flush the write */
1879 p->dma_read(IRQSTATUS_L0, ch); 1879 p->dma_read(IRQSTATUS_L0, ch);
@@ -1893,10 +1893,9 @@ static int omap2_dma_handle_ch(int ch)
1893 OMAP_DMA_CHAIN_INCQHEAD(chain_id); 1893 OMAP_DMA_CHAIN_INCQHEAD(chain_id);
1894 1894
1895 status = p->dma_read(CSR, ch); 1895 status = p->dma_read(CSR, ch);
1896 p->dma_write(status, CSR, ch);
1896 } 1897 }
1897 1898
1898 p->dma_write(status, CSR, ch);
1899
1900 if (likely(dma_chan[ch].callback != NULL)) 1899 if (likely(dma_chan[ch].callback != NULL))
1901 dma_chan[ch].callback(ch, status, dma_chan[ch].data); 1900 dma_chan[ch].callback(ch, status, dma_chan[ch].data);
1902 1901
diff --git a/arch/arm/plat-omap/include/plat/common.h b/arch/arm/plat-omap/include/plat/common.h
index 6b8088ec74af..29b2afb4288f 100644
--- a/arch/arm/plat-omap/include/plat/common.h
+++ b/arch/arm/plat-omap/include/plat/common.h
@@ -35,6 +35,9 @@ struct sys_timer;
35 35
36extern void omap_map_common_io(void); 36extern void omap_map_common_io(void);
37extern struct sys_timer omap_timer; 37extern struct sys_timer omap_timer;
38extern bool omap_32k_timer_init(void);
39extern int __init omap_init_clocksource_32k(void);
40extern unsigned long long notrace omap_32k_sched_clock(void);
38 41
39extern void omap_reserve(void); 42extern void omap_reserve(void);
40 43
diff --git a/arch/m68k/amiga/config.c b/arch/m68k/amiga/config.c
index b1577f741fa8..82a4bb51d5d8 100644
--- a/arch/m68k/amiga/config.c
+++ b/arch/m68k/amiga/config.c
@@ -610,17 +610,17 @@ static void amiga_mem_console_write(struct console *co, const char *s,
610 610
611static int __init amiga_savekmsg_setup(char *arg) 611static int __init amiga_savekmsg_setup(char *arg)
612{ 612{
613 static struct resource debug_res = { .name = "Debug" };
614
615 if (!MACH_IS_AMIGA || strcmp(arg, "mem")) 613 if (!MACH_IS_AMIGA || strcmp(arg, "mem"))
616 goto done; 614 return 0;
617 615
618 if (!AMIGAHW_PRESENT(CHIP_RAM)) { 616 if (amiga_chip_size < SAVEKMSG_MAXMEM) {
619 printk("Warning: no chipram present for debugging\n"); 617 pr_err("Not enough chipram for debugging\n");
620 goto done; 618 return -ENOMEM;
621 } 619 }
622 620
623 savekmsg = amiga_chip_alloc_res(SAVEKMSG_MAXMEM, &debug_res); 621 /* Just steal the block, the chipram allocator isn't functional yet */
622 amiga_chip_size -= SAVEKMSG_MAXMEM;
623 savekmsg = (void *)ZTWO_VADDR(CHIP_PHYSADDR + amiga_chip_size);
624 savekmsg->magic1 = SAVEKMSG_MAGIC1; 624 savekmsg->magic1 = SAVEKMSG_MAGIC1;
625 savekmsg->magic2 = SAVEKMSG_MAGIC2; 625 savekmsg->magic2 = SAVEKMSG_MAGIC2;
626 savekmsg->magicptr = ZTWO_PADDR(savekmsg); 626 savekmsg->magicptr = ZTWO_PADDR(savekmsg);
@@ -628,8 +628,6 @@ static int __init amiga_savekmsg_setup(char *arg)
628 628
629 amiga_console_driver.write = amiga_mem_console_write; 629 amiga_console_driver.write = amiga_mem_console_write;
630 register_console(&amiga_console_driver); 630 register_console(&amiga_console_driver);
631
632done:
633 return 0; 631 return 0;
634} 632}
635 633
diff --git a/arch/m68k/atari/ataints.c b/arch/m68k/atari/ataints.c
index 39478dd08e67..26a804e67bce 100644
--- a/arch/m68k/atari/ataints.c
+++ b/arch/m68k/atari/ataints.c
@@ -388,9 +388,9 @@ void __init atari_init_IRQ(void)
388 } 388 }
389 389
390 if (ATARIHW_PRESENT(SCC) && !atari_SCC_reset_done) { 390 if (ATARIHW_PRESENT(SCC) && !atari_SCC_reset_done) {
391 scc.cha_a_ctrl = 9; 391 atari_scc.cha_a_ctrl = 9;
392 MFPDELAY(); 392 MFPDELAY();
393 scc.cha_a_ctrl = (char) 0xc0; /* hardware reset */ 393 atari_scc.cha_a_ctrl = (char) 0xc0; /* hardware reset */
394 } 394 }
395 395
396 if (ATARIHW_PRESENT(SCU)) { 396 if (ATARIHW_PRESENT(SCU)) {
diff --git a/arch/m68k/atari/config.c b/arch/m68k/atari/config.c
index ae2d96e5d618..4203d101363c 100644
--- a/arch/m68k/atari/config.c
+++ b/arch/m68k/atari/config.c
@@ -315,7 +315,7 @@ void __init config_atari(void)
315 ATARIHW_SET(SCC_DMA); 315 ATARIHW_SET(SCC_DMA);
316 printk("SCC_DMA "); 316 printk("SCC_DMA ");
317 } 317 }
318 if (scc_test(&scc.cha_a_ctrl)) { 318 if (scc_test(&atari_scc.cha_a_ctrl)) {
319 ATARIHW_SET(SCC); 319 ATARIHW_SET(SCC);
320 printk("SCC "); 320 printk("SCC ");
321 } 321 }
diff --git a/arch/m68k/atari/debug.c b/arch/m68k/atari/debug.c
index 28efdc33c1ae..5a484247e493 100644
--- a/arch/m68k/atari/debug.c
+++ b/arch/m68k/atari/debug.c
@@ -53,9 +53,9 @@ static inline void ata_scc_out(char c)
53{ 53{
54 do { 54 do {
55 MFPDELAY(); 55 MFPDELAY();
56 } while (!(scc.cha_b_ctrl & 0x04)); /* wait for tx buf empty */ 56 } while (!(atari_scc.cha_b_ctrl & 0x04)); /* wait for tx buf empty */
57 MFPDELAY(); 57 MFPDELAY();
58 scc.cha_b_data = c; 58 atari_scc.cha_b_data = c;
59} 59}
60 60
61static void atari_scc_console_write(struct console *co, const char *str, 61static void atari_scc_console_write(struct console *co, const char *str,
@@ -140,9 +140,9 @@ int atari_scc_console_wait_key(struct console *co)
140{ 140{
141 do { 141 do {
142 MFPDELAY(); 142 MFPDELAY();
143 } while (!(scc.cha_b_ctrl & 0x01)); /* wait for rx buf filled */ 143 } while (!(atari_scc.cha_b_ctrl & 0x01)); /* wait for rx buf filled */
144 MFPDELAY(); 144 MFPDELAY();
145 return scc.cha_b_data; 145 return atari_scc.cha_b_data;
146} 146}
147 147
148int atari_midi_console_wait_key(struct console *co) 148int atari_midi_console_wait_key(struct console *co)
@@ -185,9 +185,9 @@ static void __init atari_init_mfp_port(int cflag)
185 185
186#define SCC_WRITE(reg, val) \ 186#define SCC_WRITE(reg, val) \
187 do { \ 187 do { \
188 scc.cha_b_ctrl = (reg); \ 188 atari_scc.cha_b_ctrl = (reg); \
189 MFPDELAY(); \ 189 MFPDELAY(); \
190 scc.cha_b_ctrl = (val); \ 190 atari_scc.cha_b_ctrl = (val); \
191 MFPDELAY(); \ 191 MFPDELAY(); \
192 } while (0) 192 } while (0)
193 193
@@ -240,7 +240,7 @@ static void __init atari_init_scc_port(int cflag)
240 reg3 = (cflag & CSIZE) == CS8 ? 0xc0 : 0x40; 240 reg3 = (cflag & CSIZE) == CS8 ? 0xc0 : 0x40;
241 reg5 = (cflag & CSIZE) == CS8 ? 0x60 : 0x20 | 0x82 /* assert DTR/RTS */; 241 reg5 = (cflag & CSIZE) == CS8 ? 0x60 : 0x20 | 0x82 /* assert DTR/RTS */;
242 242
243 (void)scc.cha_b_ctrl; /* reset reg pointer */ 243 (void)atari_scc.cha_b_ctrl; /* reset reg pointer */
244 SCC_WRITE(9, 0xc0); /* reset */ 244 SCC_WRITE(9, 0xc0); /* reset */
245 LONG_DELAY(); /* extra delay after WR9 access */ 245 LONG_DELAY(); /* extra delay after WR9 access */
246 SCC_WRITE(4, (cflag & PARENB) ? ((cflag & PARODD) ? 0x01 : 0x03) 246 SCC_WRITE(4, (cflag & PARENB) ? ((cflag & PARODD) ? 0x01 : 0x03)
diff --git a/arch/m68k/include/asm/atarihw.h b/arch/m68k/include/asm/atarihw.h
index a714e1aa072a..f51f709bbf30 100644
--- a/arch/m68k/include/asm/atarihw.h
+++ b/arch/m68k/include/asm/atarihw.h
@@ -449,7 +449,7 @@ struct SCC
449 u_char char_dummy3; 449 u_char char_dummy3;
450 u_char cha_b_data; 450 u_char cha_b_data;
451 }; 451 };
452# define scc ((*(volatile struct SCC*)SCC_BAS)) 452# define atari_scc ((*(volatile struct SCC*)SCC_BAS))
453 453
454/* The ESCC (Z85230) in an Atari ST. The channels are reversed! */ 454/* The ESCC (Z85230) in an Atari ST. The channels are reversed! */
455# define st_escc ((*(volatile struct SCC*)0xfffffa31)) 455# define st_escc ((*(volatile struct SCC*)0xfffffa31))
diff --git a/arch/m68k/include/asm/string.h b/arch/m68k/include/asm/string.h
index 2936dda938d7..65b131282837 100644
--- a/arch/m68k/include/asm/string.h
+++ b/arch/m68k/include/asm/string.h
@@ -81,18 +81,6 @@ static inline char *strncpy(char *dest, const char *src, size_t n)
81 strcpy(__d + strlen(__d), (s)); \ 81 strcpy(__d + strlen(__d), (s)); \
82}) 82})
83 83
84#define __HAVE_ARCH_STRCHR
85static inline char *strchr(const char *s, int c)
86{
87 char sc, ch = c;
88
89 for (; (sc = *s++) != ch; ) {
90 if (!sc)
91 return NULL;
92 }
93 return (char *)s - 1;
94}
95
96#ifndef CONFIG_COLDFIRE 84#ifndef CONFIG_COLDFIRE
97#define __HAVE_ARCH_STRCMP 85#define __HAVE_ARCH_STRCMP
98static inline int strcmp(const char *cs, const char *ct) 86static inline int strcmp(const char *cs, const char *ct)
diff --git a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c
index 11bdd68e5762..fc770be465ff 100644
--- a/arch/parisc/kernel/pdc_cons.c
+++ b/arch/parisc/kernel/pdc_cons.c
@@ -169,11 +169,11 @@ static int __init pdc_console_tty_driver_init(void)
169 169
170 struct console *tmp; 170 struct console *tmp;
171 171
172 acquire_console_sem(); 172 console_lock();
173 for_each_console(tmp) 173 for_each_console(tmp)
174 if (tmp == &pdc_cons) 174 if (tmp == &pdc_cons)
175 break; 175 break;
176 release_console_sem(); 176 console_unlock();
177 177
178 if (!tmp) { 178 if (!tmp) {
179 printk(KERN_INFO "PDC console driver not registered anymore, not creating %s\n", pdc_cons.name); 179 printk(KERN_INFO "PDC console driver not registered anymore, not creating %s\n", pdc_cons.name);
diff --git a/arch/powerpc/kernel/perf_event_fsl_emb.c b/arch/powerpc/kernel/perf_event_fsl_emb.c
index 4dcf5f831e9d..b0dc8f7069cd 100644
--- a/arch/powerpc/kernel/perf_event_fsl_emb.c
+++ b/arch/powerpc/kernel/perf_event_fsl_emb.c
@@ -596,6 +596,7 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
596 if (left <= 0) 596 if (left <= 0)
597 left = period; 597 left = period;
598 record = 1; 598 record = 1;
599 event->hw.last_period = event->hw.sample_period;
599 } 600 }
600 if (left < 0x80000000LL) 601 if (left < 0x80000000LL)
601 val = 0x80000000LL - left; 602 val = 0x80000000LL - left;
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index ae555569823b..8a9011dced14 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -15,6 +15,7 @@ config SUPERH
15 select HAVE_KERNEL_GZIP 15 select HAVE_KERNEL_GZIP
16 select HAVE_KERNEL_BZIP2 16 select HAVE_KERNEL_BZIP2
17 select HAVE_KERNEL_LZMA 17 select HAVE_KERNEL_LZMA
18 select HAVE_KERNEL_XZ
18 select HAVE_KERNEL_LZO 19 select HAVE_KERNEL_LZO
19 select HAVE_SYSCALL_TRACEPOINTS 20 select HAVE_SYSCALL_TRACEPOINTS
20 select HAVE_REGS_AND_STACK_ACCESS_API 21 select HAVE_REGS_AND_STACK_ACCESS_API
diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index 9c8c6e1a2a15..e3d8170ad00b 100644
--- a/arch/sh/Makefile
+++ b/arch/sh/Makefile
@@ -200,7 +200,7 @@ endif
200libs-$(CONFIG_SUPERH32) := arch/sh/lib/ $(libs-y) 200libs-$(CONFIG_SUPERH32) := arch/sh/lib/ $(libs-y)
201libs-$(CONFIG_SUPERH64) := arch/sh/lib64/ $(libs-y) 201libs-$(CONFIG_SUPERH64) := arch/sh/lib64/ $(libs-y)
202 202
203BOOT_TARGETS = uImage uImage.bz2 uImage.gz uImage.lzma uImage.lzo \ 203BOOT_TARGETS = uImage uImage.bz2 uImage.gz uImage.lzma uImage.xz uImage.lzo \
204 uImage.srec uImage.bin zImage vmlinux.bin vmlinux.srec \ 204 uImage.srec uImage.bin zImage vmlinux.bin vmlinux.srec \
205 romImage 205 romImage
206PHONY += $(BOOT_TARGETS) 206PHONY += $(BOOT_TARGETS)
@@ -230,5 +230,6 @@ define archhelp
230 @echo '* uImage.gz - Kernel-only image for U-Boot (gzip)' 230 @echo '* uImage.gz - Kernel-only image for U-Boot (gzip)'
231 @echo ' uImage.bz2 - Kernel-only image for U-Boot (bzip2)' 231 @echo ' uImage.bz2 - Kernel-only image for U-Boot (bzip2)'
232 @echo ' uImage.lzma - Kernel-only image for U-Boot (lzma)' 232 @echo ' uImage.lzma - Kernel-only image for U-Boot (lzma)'
233 @echo ' uImage.xz - Kernel-only image for U-Boot (xz)'
233 @echo ' uImage.lzo - Kernel-only image for U-Boot (lzo)' 234 @echo ' uImage.lzo - Kernel-only image for U-Boot (lzo)'
234endef 235endef
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index 33b662999fc6..701667acfd89 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -1294,6 +1294,7 @@ static int __init arch_setup(void)
1294 i2c_register_board_info(1, i2c1_devices, 1294 i2c_register_board_info(1, i2c1_devices,
1295 ARRAY_SIZE(i2c1_devices)); 1295 ARRAY_SIZE(i2c1_devices));
1296 1296
1297#if defined(CONFIG_VIDEO_SH_VOU) || defined(CONFIG_VIDEO_SH_VOU_MODULE)
1297 /* VOU */ 1298 /* VOU */
1298 gpio_request(GPIO_FN_DV_D15, NULL); 1299 gpio_request(GPIO_FN_DV_D15, NULL);
1299 gpio_request(GPIO_FN_DV_D14, NULL); 1300 gpio_request(GPIO_FN_DV_D14, NULL);
@@ -1325,6 +1326,7 @@ static int __init arch_setup(void)
1325 1326
1326 /* Remove reset */ 1327 /* Remove reset */
1327 gpio_set_value(GPIO_PTG4, 1); 1328 gpio_set_value(GPIO_PTG4, 1);
1329#endif
1328 1330
1329 return platform_add_devices(ecovec_devices, 1331 return platform_add_devices(ecovec_devices,
1330 ARRAY_SIZE(ecovec_devices)); 1332 ARRAY_SIZE(ecovec_devices));
diff --git a/arch/sh/boot/Makefile b/arch/sh/boot/Makefile
index 1ce63624c9b9..ba515d800245 100644
--- a/arch/sh/boot/Makefile
+++ b/arch/sh/boot/Makefile
@@ -24,12 +24,13 @@ suffix-y := bin
24suffix-$(CONFIG_KERNEL_GZIP) := gz 24suffix-$(CONFIG_KERNEL_GZIP) := gz
25suffix-$(CONFIG_KERNEL_BZIP2) := bz2 25suffix-$(CONFIG_KERNEL_BZIP2) := bz2
26suffix-$(CONFIG_KERNEL_LZMA) := lzma 26suffix-$(CONFIG_KERNEL_LZMA) := lzma
27suffix-$(CONFIG_KERNEL_XZ) := xz
27suffix-$(CONFIG_KERNEL_LZO) := lzo 28suffix-$(CONFIG_KERNEL_LZO) := lzo
28 29
29targets := zImage vmlinux.srec romImage uImage uImage.srec uImage.gz \ 30targets := zImage vmlinux.srec romImage uImage uImage.srec uImage.gz \
30 uImage.bz2 uImage.lzma uImage.lzo uImage.bin 31 uImage.bz2 uImage.lzma uImage.xz uImage.lzo uImage.bin
31extra-y += vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \ 32extra-y += vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
32 vmlinux.bin.lzo 33 vmlinux.bin.xz vmlinux.bin.lzo
33subdir- := compressed romimage 34subdir- := compressed romimage
34 35
35$(obj)/zImage: $(obj)/compressed/vmlinux FORCE 36$(obj)/zImage: $(obj)/compressed/vmlinux FORCE
@@ -76,6 +77,9 @@ $(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
76$(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE 77$(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
77 $(call if_changed,lzma) 78 $(call if_changed,lzma)
78 79
80$(obj)/vmlinux.bin.xz: $(obj)/vmlinux.bin FORCE
81 $(call if_changed,xzkern)
82
79$(obj)/vmlinux.bin.lzo: $(obj)/vmlinux.bin FORCE 83$(obj)/vmlinux.bin.lzo: $(obj)/vmlinux.bin FORCE
80 $(call if_changed,lzo) 84 $(call if_changed,lzo)
81 85
@@ -88,6 +92,9 @@ $(obj)/uImage.gz: $(obj)/vmlinux.bin.gz
88$(obj)/uImage.lzma: $(obj)/vmlinux.bin.lzma 92$(obj)/uImage.lzma: $(obj)/vmlinux.bin.lzma
89 $(call if_changed,uimage,lzma) 93 $(call if_changed,uimage,lzma)
90 94
95$(obj)/uImage.xz: $(obj)/vmlinux.bin.xz
96 $(call if_changed,uimage,xz)
97
91$(obj)/uImage.lzo: $(obj)/vmlinux.bin.lzo 98$(obj)/uImage.lzo: $(obj)/vmlinux.bin.lzo
92 $(call if_changed,uimage,lzo) 99 $(call if_changed,uimage,lzo)
93 100
diff --git a/arch/sh/boot/compressed/Makefile b/arch/sh/boot/compressed/Makefile
index cfa5a087a886..e0b0293bae63 100644
--- a/arch/sh/boot/compressed/Makefile
+++ b/arch/sh/boot/compressed/Makefile
@@ -6,7 +6,7 @@
6 6
7targets := vmlinux vmlinux.bin vmlinux.bin.gz \ 7targets := vmlinux vmlinux.bin vmlinux.bin.gz \
8 vmlinux.bin.bz2 vmlinux.bin.lzma \ 8 vmlinux.bin.bz2 vmlinux.bin.lzma \
9 vmlinux.bin.lzo \ 9 vmlinux.bin.xz vmlinux.bin.lzo \
10 head_$(BITS).o misc.o piggy.o 10 head_$(BITS).o misc.o piggy.o
11 11
12OBJECTS = $(obj)/head_$(BITS).o $(obj)/misc.o $(obj)/cache.o 12OBJECTS = $(obj)/head_$(BITS).o $(obj)/misc.o $(obj)/cache.o
@@ -50,6 +50,8 @@ $(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE
50 $(call if_changed,bzip2) 50 $(call if_changed,bzip2)
51$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE 51$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE
52 $(call if_changed,lzma) 52 $(call if_changed,lzma)
53$(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE
54 $(call if_changed,xzkern)
53$(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE 55$(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE
54 $(call if_changed,lzo) 56 $(call if_changed,lzo)
55 57
diff --git a/arch/sh/boot/compressed/misc.c b/arch/sh/boot/compressed/misc.c
index 27140a6b365d..95470a472d2c 100644
--- a/arch/sh/boot/compressed/misc.c
+++ b/arch/sh/boot/compressed/misc.c
@@ -61,6 +61,10 @@ static unsigned long free_mem_end_ptr;
61#include "../../../../lib/decompress_unlzma.c" 61#include "../../../../lib/decompress_unlzma.c"
62#endif 62#endif
63 63
64#ifdef CONFIG_KERNEL_XZ
65#include "../../../../lib/decompress_unxz.c"
66#endif
67
64#ifdef CONFIG_KERNEL_LZO 68#ifdef CONFIG_KERNEL_LZO
65#include "../../../../lib/decompress_unlzo.c" 69#include "../../../../lib/decompress_unlzo.c"
66#endif 70#endif
diff --git a/arch/sh/include/asm/pgtable.h b/arch/sh/include/asm/pgtable.h
index 083ea068e819..db85916b9e95 100644
--- a/arch/sh/include/asm/pgtable.h
+++ b/arch/sh/include/asm/pgtable.h
@@ -134,6 +134,7 @@ typedef pte_t *pte_addr_t;
134extern void pgtable_cache_init(void); 134extern void pgtable_cache_init(void);
135 135
136struct vm_area_struct; 136struct vm_area_struct;
137struct mm_struct;
137 138
138extern void __update_cache(struct vm_area_struct *vma, 139extern void __update_cache(struct vm_area_struct *vma,
139 unsigned long address, pte_t pte); 140 unsigned long address, pte_t pte);
diff --git a/arch/sh/kernel/cpu/sh4/setup-sh7750.c b/arch/sh/kernel/cpu/sh4/setup-sh7750.c
index c2b0aaaedcae..672944f5b19c 100644
--- a/arch/sh/kernel/cpu/sh4/setup-sh7750.c
+++ b/arch/sh/kernel/cpu/sh4/setup-sh7750.c
@@ -230,10 +230,10 @@ static struct platform_device *sh7750_devices[] __initdata = {
230static int __init sh7750_devices_setup(void) 230static int __init sh7750_devices_setup(void)
231{ 231{
232 if (mach_is_rts7751r2d()) { 232 if (mach_is_rts7751r2d()) {
233 platform_register_device(&scif_device); 233 platform_device_register(&scif_device);
234 } else { 234 } else {
235 platform_register_device(&sci_device); 235 platform_device_register(&sci_device);
236 platform_register_device(&scif_device); 236 platform_device_register(&scif_device);
237 } 237 }
238 238
239 return platform_add_devices(sh7750_devices, 239 return platform_add_devices(sh7750_devices,
diff --git a/arch/sh/kernel/topology.c b/arch/sh/kernel/topology.c
index 948fdb656933..38e862852dd0 100644
--- a/arch/sh/kernel/topology.c
+++ b/arch/sh/kernel/topology.c
@@ -17,6 +17,7 @@
17static DEFINE_PER_CPU(struct cpu, cpu_devices); 17static DEFINE_PER_CPU(struct cpu, cpu_devices);
18 18
19cpumask_t cpu_core_map[NR_CPUS]; 19cpumask_t cpu_core_map[NR_CPUS];
20EXPORT_SYMBOL(cpu_core_map);
20 21
21static cpumask_t cpu_coregroup_map(unsigned int cpu) 22static cpumask_t cpu_coregroup_map(unsigned int cpu)
22{ 23{
diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
index 63e35ec9075c..62f084478f7e 100644
--- a/arch/x86/include/asm/cacheflush.h
+++ b/arch/x86/include/asm/cacheflush.h
@@ -1,48 +1,8 @@
1#ifndef _ASM_X86_CACHEFLUSH_H 1#ifndef _ASM_X86_CACHEFLUSH_H
2#define _ASM_X86_CACHEFLUSH_H 2#define _ASM_X86_CACHEFLUSH_H
3 3
4/* Keep includes the same across arches. */
5#include <linux/mm.h>
6
7/* Caches aren't brain-dead on the intel. */ 4/* Caches aren't brain-dead on the intel. */
8static inline void flush_cache_all(void) { } 5#include <asm-generic/cacheflush.h>
9static inline void flush_cache_mm(struct mm_struct *mm) { }
10static inline void flush_cache_dup_mm(struct mm_struct *mm) { }
11static inline void flush_cache_range(struct vm_area_struct *vma,
12 unsigned long start, unsigned long end) { }
13static inline void flush_cache_page(struct vm_area_struct *vma,
14 unsigned long vmaddr, unsigned long pfn) { }
15#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
16static inline void flush_dcache_page(struct page *page) { }
17static inline void flush_dcache_mmap_lock(struct address_space *mapping) { }
18static inline void flush_dcache_mmap_unlock(struct address_space *mapping) { }
19static inline void flush_icache_range(unsigned long start,
20 unsigned long end) { }
21static inline void flush_icache_page(struct vm_area_struct *vma,
22 struct page *page) { }
23static inline void flush_icache_user_range(struct vm_area_struct *vma,
24 struct page *page,
25 unsigned long addr,
26 unsigned long len) { }
27static inline void flush_cache_vmap(unsigned long start, unsigned long end) { }
28static inline void flush_cache_vunmap(unsigned long start,
29 unsigned long end) { }
30
31static inline void copy_to_user_page(struct vm_area_struct *vma,
32 struct page *page, unsigned long vaddr,
33 void *dst, const void *src,
34 unsigned long len)
35{
36 memcpy(dst, src, len);
37}
38
39static inline void copy_from_user_page(struct vm_area_struct *vma,
40 struct page *page, unsigned long vaddr,
41 void *dst, const void *src,
42 unsigned long len)
43{
44 memcpy(dst, src, len);
45}
46 6
47#ifdef CONFIG_X86_PAT 7#ifdef CONFIG_X86_PAT
48/* 8/*
diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h
index 4fab24de26b1..6e6e7558e702 100644
--- a/arch/x86/include/asm/cpu.h
+++ b/arch/x86/include/asm/cpu.h
@@ -32,5 +32,6 @@ extern void arch_unregister_cpu(int);
32 32
33DECLARE_PER_CPU(int, cpu_state); 33DECLARE_PER_CPU(int, cpu_state);
34 34
35int __cpuinit mwait_usable(const struct cpuinfo_x86 *);
35 36
36#endif /* _ASM_X86_CPU_H */ 37#endif /* _ASM_X86_CPU_H */
diff --git a/arch/x86/include/asm/jump_label.h b/arch/x86/include/asm/jump_label.h
index f52d42e80585..574dbc22893a 100644
--- a/arch/x86/include/asm/jump_label.h
+++ b/arch/x86/include/asm/jump_label.h
@@ -14,7 +14,7 @@
14 do { \ 14 do { \
15 asm goto("1:" \ 15 asm goto("1:" \
16 JUMP_LABEL_INITIAL_NOP \ 16 JUMP_LABEL_INITIAL_NOP \
17 ".pushsection __jump_table, \"a\" \n\t"\ 17 ".pushsection __jump_table, \"aw\" \n\t"\
18 _ASM_PTR "1b, %l[" #label "], %c0 \n\t" \ 18 _ASM_PTR "1b, %l[" #label "], %c0 \n\t" \
19 ".popsection \n\t" \ 19 ".popsection \n\t" \
20 : : "i" (key) : : label); \ 20 : : "i" (key) : : label); \
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index 2071a8b2b32f..ebbc4d8ab170 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -558,13 +558,12 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
558static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr, 558static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr,
559 pmd_t *pmdp, pmd_t pmd) 559 pmd_t *pmdp, pmd_t pmd)
560{ 560{
561#if PAGETABLE_LEVELS >= 3
562 if (sizeof(pmdval_t) > sizeof(long)) 561 if (sizeof(pmdval_t) > sizeof(long))
563 /* 5 arg words */ 562 /* 5 arg words */
564 pv_mmu_ops.set_pmd_at(mm, addr, pmdp, pmd); 563 pv_mmu_ops.set_pmd_at(mm, addr, pmdp, pmd);
565 else 564 else
566 PVOP_VCALL4(pv_mmu_ops.set_pmd_at, mm, addr, pmdp, pmd.pmd); 565 PVOP_VCALL4(pv_mmu_ops.set_pmd_at, mm, addr, pmdp,
567#endif 566 native_pmd_val(pmd));
568} 567}
569#endif 568#endif
570 569
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index 7283e98deaae..ec2c19a7b8ef 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -45,6 +45,7 @@ static const struct _cache_table __cpuinitconst cache_table[] =
45 { 0x0a, LVL_1_DATA, 8 }, /* 2 way set assoc, 32 byte line size */ 45 { 0x0a, LVL_1_DATA, 8 }, /* 2 way set assoc, 32 byte line size */
46 { 0x0c, LVL_1_DATA, 16 }, /* 4-way set assoc, 32 byte line size */ 46 { 0x0c, LVL_1_DATA, 16 }, /* 4-way set assoc, 32 byte line size */
47 { 0x0d, LVL_1_DATA, 16 }, /* 4-way set assoc, 64 byte line size */ 47 { 0x0d, LVL_1_DATA, 16 }, /* 4-way set assoc, 64 byte line size */
48 { 0x0e, LVL_1_DATA, 24 }, /* 6-way set assoc, 64 byte line size */
48 { 0x21, LVL_2, 256 }, /* 8-way set assoc, 64 byte line size */ 49 { 0x21, LVL_2, 256 }, /* 8-way set assoc, 64 byte line size */
49 { 0x22, LVL_3, 512 }, /* 4-way set assoc, sectored cache, 64 byte line size */ 50 { 0x22, LVL_3, 512 }, /* 4-way set assoc, sectored cache, 64 byte line size */
50 { 0x23, LVL_3, MB(1) }, /* 8-way set assoc, sectored cache, 64 byte line size */ 51 { 0x23, LVL_3, MB(1) }, /* 8-way set assoc, sectored cache, 64 byte line size */
@@ -66,6 +67,7 @@ static const struct _cache_table __cpuinitconst cache_table[] =
66 { 0x45, LVL_2, MB(2) }, /* 4-way set assoc, 32 byte line size */ 67 { 0x45, LVL_2, MB(2) }, /* 4-way set assoc, 32 byte line size */
67 { 0x46, LVL_3, MB(4) }, /* 4-way set assoc, 64 byte line size */ 68 { 0x46, LVL_3, MB(4) }, /* 4-way set assoc, 64 byte line size */
68 { 0x47, LVL_3, MB(8) }, /* 8-way set assoc, 64 byte line size */ 69 { 0x47, LVL_3, MB(8) }, /* 8-way set assoc, 64 byte line size */
70 { 0x48, LVL_2, MB(3) }, /* 12-way set assoc, 64 byte line size */
69 { 0x49, LVL_3, MB(4) }, /* 16-way set assoc, 64 byte line size */ 71 { 0x49, LVL_3, MB(4) }, /* 16-way set assoc, 64 byte line size */
70 { 0x4a, LVL_3, MB(6) }, /* 12-way set assoc, 64 byte line size */ 72 { 0x4a, LVL_3, MB(6) }, /* 12-way set assoc, 64 byte line size */
71 { 0x4b, LVL_3, MB(8) }, /* 16-way set assoc, 64 byte line size */ 73 { 0x4b, LVL_3, MB(8) }, /* 16-way set assoc, 64 byte line size */
@@ -87,6 +89,7 @@ static const struct _cache_table __cpuinitconst cache_table[] =
87 { 0x7c, LVL_2, MB(1) }, /* 8-way set assoc, sectored cache, 64 byte line size */ 89 { 0x7c, LVL_2, MB(1) }, /* 8-way set assoc, sectored cache, 64 byte line size */
88 { 0x7d, LVL_2, MB(2) }, /* 8-way set assoc, 64 byte line size */ 90 { 0x7d, LVL_2, MB(2) }, /* 8-way set assoc, 64 byte line size */
89 { 0x7f, LVL_2, 512 }, /* 2-way set assoc, 64 byte line size */ 91 { 0x7f, LVL_2, 512 }, /* 2-way set assoc, 64 byte line size */
92 { 0x80, LVL_2, 512 }, /* 8-way set assoc, 64 byte line size */
90 { 0x82, LVL_2, 256 }, /* 8-way set assoc, 32 byte line size */ 93 { 0x82, LVL_2, 256 }, /* 8-way set assoc, 32 byte line size */
91 { 0x83, LVL_2, 512 }, /* 8-way set assoc, 32 byte line size */ 94 { 0x83, LVL_2, 512 }, /* 8-way set assoc, 32 byte line size */
92 { 0x84, LVL_2, MB(1) }, /* 8-way set assoc, 32 byte line size */ 95 { 0x84, LVL_2, MB(1) }, /* 8-way set assoc, 32 byte line size */
diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
index e12246ff5aa6..6f8c5e9da97f 100644
--- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
+++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
@@ -59,6 +59,7 @@ struct thermal_state {
59 59
60/* Callback to handle core threshold interrupts */ 60/* Callback to handle core threshold interrupts */
61int (*platform_thermal_notify)(__u64 msr_val); 61int (*platform_thermal_notify)(__u64 msr_val);
62EXPORT_SYMBOL(platform_thermal_notify);
62 63
63static DEFINE_PER_CPU(struct thermal_state, thermal_state); 64static DEFINE_PER_CPU(struct thermal_state, thermal_state);
64 65
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index d8286ed54ffa..e764fc05d700 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -14,6 +14,7 @@
14#include <linux/utsname.h> 14#include <linux/utsname.h>
15#include <trace/events/power.h> 15#include <trace/events/power.h>
16#include <linux/hw_breakpoint.h> 16#include <linux/hw_breakpoint.h>
17#include <asm/cpu.h>
17#include <asm/system.h> 18#include <asm/system.h>
18#include <asm/apic.h> 19#include <asm/apic.h>
19#include <asm/syscalls.h> 20#include <asm/syscalls.h>
@@ -505,7 +506,7 @@ static void poll_idle(void)
505#define MWAIT_ECX_EXTENDED_INFO 0x01 506#define MWAIT_ECX_EXTENDED_INFO 0x01
506#define MWAIT_EDX_C1 0xf0 507#define MWAIT_EDX_C1 0xf0
507 508
508static int __cpuinit mwait_usable(const struct cpuinfo_x86 *c) 509int __cpuinit mwait_usable(const struct cpuinfo_x86 *c)
509{ 510{
510 u32 eax, ebx, ecx, edx; 511 u32 eax, ebx, ecx, edx;
511 512
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 763df77343dd..0cbe8c0b35ed 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1402,8 +1402,9 @@ static inline void mwait_play_dead(void)
1402 unsigned int highest_subcstate = 0; 1402 unsigned int highest_subcstate = 0;
1403 int i; 1403 int i;
1404 void *mwait_ptr; 1404 void *mwait_ptr;
1405 struct cpuinfo_x86 *c = __this_cpu_ptr(&cpu_info);
1405 1406
1406 if (!cpu_has(__this_cpu_ptr(&cpu_info), X86_FEATURE_MWAIT)) 1407 if (!(cpu_has(c, X86_FEATURE_MWAIT) && mwait_usable(c)))
1407 return; 1408 return;
1408 if (!cpu_has(__this_cpu_ptr(&cpu_info), X86_FEATURE_CLFLSH)) 1409 if (!cpu_has(__this_cpu_ptr(&cpu_info), X86_FEATURE_CLFLSH))
1409 return; 1410 return;
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index 826ab0939a12..fab3d3265adb 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -68,6 +68,7 @@ static struct _intel_private {
68 phys_addr_t gma_bus_addr; 68 phys_addr_t gma_bus_addr;
69 u32 PGETBL_save; 69 u32 PGETBL_save;
70 u32 __iomem *gtt; /* I915G */ 70 u32 __iomem *gtt; /* I915G */
71 bool clear_fake_agp; /* on first access via agp, fill with scratch */
71 int num_dcache_entries; 72 int num_dcache_entries;
72 union { 73 union {
73 void __iomem *i9xx_flush_page; 74 void __iomem *i9xx_flush_page;
@@ -869,21 +870,12 @@ static int intel_fake_agp_free_gatt_table(struct agp_bridge_data *bridge)
869 870
870static int intel_fake_agp_configure(void) 871static int intel_fake_agp_configure(void)
871{ 872{
872 int i;
873
874 if (!intel_enable_gtt()) 873 if (!intel_enable_gtt())
875 return -EIO; 874 return -EIO;
876 875
876 intel_private.clear_fake_agp = true;
877 agp_bridge->gart_bus_addr = intel_private.gma_bus_addr; 877 agp_bridge->gart_bus_addr = intel_private.gma_bus_addr;
878 878
879 for (i = 0; i < intel_private.base.gtt_total_entries; i++) {
880 intel_private.driver->write_entry(intel_private.scratch_page_dma,
881 i, 0);
882 }
883 readl(intel_private.gtt+i-1); /* PCI Posting. */
884
885 global_cache_flush();
886
887 return 0; 879 return 0;
888} 880}
889 881
@@ -945,6 +937,13 @@ static int intel_fake_agp_insert_entries(struct agp_memory *mem,
945{ 937{
946 int ret = -EINVAL; 938 int ret = -EINVAL;
947 939
940 if (intel_private.clear_fake_agp) {
941 int start = intel_private.base.stolen_size / PAGE_SIZE;
942 int end = intel_private.base.gtt_mappable_entries;
943 intel_gtt_clear_range(start, end - start);
944 intel_private.clear_fake_agp = false;
945 }
946
948 if (INTEL_GTT_GEN == 1 && type == AGP_DCACHE_MEMORY) 947 if (INTEL_GTT_GEN == 1 && type == AGP_DCACHE_MEMORY)
949 return i810_insert_dcache_entries(mem, pg_start, type); 948 return i810_insert_dcache_entries(mem, pg_start, type);
950 949
diff --git a/drivers/char/bfin_jtag_comm.c b/drivers/char/bfin_jtag_comm.c
index e397df3ad98e..16402445f2b2 100644
--- a/drivers/char/bfin_jtag_comm.c
+++ b/drivers/char/bfin_jtag_comm.c
@@ -183,16 +183,16 @@ bfin_jc_circ_write(const unsigned char *buf, int count)
183} 183}
184 184
185#ifndef CONFIG_BFIN_JTAG_COMM_CONSOLE 185#ifndef CONFIG_BFIN_JTAG_COMM_CONSOLE
186# define acquire_console_sem() 186# define console_lock()
187# define release_console_sem() 187# define console_unlock()
188#endif 188#endif
189static int 189static int
190bfin_jc_write(struct tty_struct *tty, const unsigned char *buf, int count) 190bfin_jc_write(struct tty_struct *tty, const unsigned char *buf, int count)
191{ 191{
192 int i; 192 int i;
193 acquire_console_sem(); 193 console_lock();
194 i = bfin_jc_circ_write(buf, count); 194 i = bfin_jc_circ_write(buf, count);
195 release_console_sem(); 195 console_unlock();
196 wake_up_process(bfin_jc_kthread); 196 wake_up_process(bfin_jc_kthread);
197 return i; 197 return i;
198} 198}
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 1f46f1cd9225..36e0fa161c2b 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -364,12 +364,14 @@ unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip,
364 tpm_protected_ordinal_duration[ordinal & 364 tpm_protected_ordinal_duration[ordinal &
365 TPM_PROTECTED_ORDINAL_MASK]; 365 TPM_PROTECTED_ORDINAL_MASK];
366 366
367 if (duration_idx != TPM_UNDEFINED) 367 if (duration_idx != TPM_UNDEFINED) {
368 duration = chip->vendor.duration[duration_idx]; 368 duration = chip->vendor.duration[duration_idx];
369 if (duration <= 0) 369 /* if duration is 0, it's because chip->vendor.duration wasn't */
370 /* filled yet, so we set the lowest timeout just to give enough */
371 /* time for tpm_get_timeouts() to succeed */
372 return (duration <= 0 ? HZ : duration);
373 } else
370 return 2 * 60 * HZ; 374 return 2 * 60 * HZ;
371 else
372 return duration;
373} 375}
374EXPORT_SYMBOL_GPL(tpm_calc_ordinal_duration); 376EXPORT_SYMBOL_GPL(tpm_calc_ordinal_duration);
375 377
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index c17a305ecb28..dd21df55689d 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -493,9 +493,6 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
493 "1.2 TPM (device-id 0x%X, rev-id %d)\n", 493 "1.2 TPM (device-id 0x%X, rev-id %d)\n",
494 vendor >> 16, ioread8(chip->vendor.iobase + TPM_RID(0))); 494 vendor >> 16, ioread8(chip->vendor.iobase + TPM_RID(0)));
495 495
496 if (is_itpm(to_pnp_dev(dev)))
497 itpm = 1;
498
499 if (itpm) 496 if (itpm)
500 dev_info(dev, "Intel iTPM workaround enabled\n"); 497 dev_info(dev, "Intel iTPM workaround enabled\n");
501 498
@@ -637,6 +634,9 @@ static int __devinit tpm_tis_pnp_init(struct pnp_dev *pnp_dev,
637 else 634 else
638 interrupts = 0; 635 interrupts = 0;
639 636
637 if (is_itpm(pnp_dev))
638 itpm = 1;
639
640 return tpm_tis_init(&pnp_dev->dev, start, len, irq); 640 return tpm_tis_init(&pnp_dev->dev, start, len, irq);
641} 641}
642 642
diff --git a/drivers/clocksource/acpi_pm.c b/drivers/clocksource/acpi_pm.c
index cfb0f5278415..effe7974aa9a 100644
--- a/drivers/clocksource/acpi_pm.c
+++ b/drivers/clocksource/acpi_pm.c
@@ -202,17 +202,21 @@ static int __init init_acpi_pm_clocksource(void)
202 printk(KERN_INFO "PM-Timer had inconsistent results:" 202 printk(KERN_INFO "PM-Timer had inconsistent results:"
203 " 0x%#llx, 0x%#llx - aborting.\n", 203 " 0x%#llx, 0x%#llx - aborting.\n",
204 value1, value2); 204 value1, value2);
205 pmtmr_ioport = 0;
205 return -EINVAL; 206 return -EINVAL;
206 } 207 }
207 if (i == ACPI_PM_READ_CHECKS) { 208 if (i == ACPI_PM_READ_CHECKS) {
208 printk(KERN_INFO "PM-Timer failed consistency check " 209 printk(KERN_INFO "PM-Timer failed consistency check "
209 " (0x%#llx) - aborting.\n", value1); 210 " (0x%#llx) - aborting.\n", value1);
211 pmtmr_ioport = 0;
210 return -ENODEV; 212 return -ENODEV;
211 } 213 }
212 } 214 }
213 215
214 if (verify_pmtmr_rate() != 0) 216 if (verify_pmtmr_rate() != 0){
217 pmtmr_ioport = 0;
215 return -ENODEV; 218 return -ENODEV;
219 }
216 220
217 return clocksource_register_hz(&clocksource_acpi_pm, 221 return clocksource_register_hz(&clocksource_acpi_pm,
218 PMTMR_TICKS_PER_SEC); 222 PMTMR_TICKS_PER_SEC);
diff --git a/drivers/clocksource/tcb_clksrc.c b/drivers/clocksource/tcb_clksrc.c
index 01b886e68822..79c47e88d5d1 100644
--- a/drivers/clocksource/tcb_clksrc.c
+++ b/drivers/clocksource/tcb_clksrc.c
@@ -196,9 +196,9 @@ static void __init setup_clkevents(struct atmel_tc *tc, int clk32k_divisor_idx)
196 clkevt.clkevt.min_delta_ns = clockevent_delta2ns(1, &clkevt.clkevt) + 1; 196 clkevt.clkevt.min_delta_ns = clockevent_delta2ns(1, &clkevt.clkevt) + 1;
197 clkevt.clkevt.cpumask = cpumask_of(0); 197 clkevt.clkevt.cpumask = cpumask_of(0);
198 198
199 setup_irq(irq, &tc_irqaction);
200
201 clockevents_register_device(&clkevt.clkevt); 199 clockevents_register_device(&clkevt.clkevt);
200
201 setup_irq(irq, &tc_irqaction);
202} 202}
203 203
204#else /* !CONFIG_GENERIC_CLOCKEVENTS */ 204#else /* !CONFIG_GENERIC_CLOCKEVENTS */
diff --git a/drivers/gpio/langwell_gpio.c b/drivers/gpio/langwell_gpio.c
index d81cc748e77f..54d70a47afc1 100644
--- a/drivers/gpio/langwell_gpio.c
+++ b/drivers/gpio/langwell_gpio.c
@@ -187,7 +187,7 @@ MODULE_DEVICE_TABLE(pci, lnw_gpio_ids);
187 187
188static void lnw_irq_handler(unsigned irq, struct irq_desc *desc) 188static void lnw_irq_handler(unsigned irq, struct irq_desc *desc)
189{ 189{
190 struct lnw_gpio *lnw = (struct lnw_gpio *)get_irq_data(irq); 190 struct lnw_gpio *lnw = get_irq_data(irq);
191 u32 base, gpio; 191 u32 base, gpio;
192 void __iomem *gedr; 192 void __iomem *gedr;
193 u32 gedr_v; 193 u32 gedr_v;
@@ -206,7 +206,12 @@ static void lnw_irq_handler(unsigned irq, struct irq_desc *desc)
206 /* clear the edge detect status bit */ 206 /* clear the edge detect status bit */
207 writel(gedr_v, gedr); 207 writel(gedr_v, gedr);
208 } 208 }
209 desc->chip->eoi(irq); 209
210 if (desc->chip->irq_eoi)
211 desc->chip->irq_eoi(irq_get_irq_data(irq));
212 else
213 dev_warn(lnw->chip.dev, "missing EOI handler for irq %d\n", irq);
214
210} 215}
211 216
212static int __devinit lnw_gpio_probe(struct pci_dev *pdev, 217static int __devinit lnw_gpio_probe(struct pci_dev *pdev,
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index bea966f8ac84..0902d4460039 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -100,7 +100,10 @@ config DRM_I830
100config DRM_I915 100config DRM_I915
101 tristate "i915 driver" 101 tristate "i915 driver"
102 depends on AGP_INTEL 102 depends on AGP_INTEL
103 # we need shmfs for the swappable backing store, and in particular
104 # the shmem_readpage() which depends upon tmpfs
103 select SHMEM 105 select SHMEM
106 select TMPFS
104 select DRM_KMS_HELPER 107 select DRM_KMS_HELPER
105 select FB_CFB_FILLRECT 108 select FB_CFB_FILLRECT
106 select FB_CFB_COPYAREA 109 select FB_CFB_COPYAREA
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 844f3c972b04..17bd766f2081 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -152,7 +152,7 @@ static int i915_initialize(struct drm_device * dev, drm_i915_init_t * init)
152{ 152{
153 drm_i915_private_t *dev_priv = dev->dev_private; 153 drm_i915_private_t *dev_priv = dev->dev_private;
154 struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv; 154 struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv;
155 struct intel_ring_buffer *ring = LP_RING(dev_priv); 155 int ret;
156 156
157 master_priv->sarea = drm_getsarea(dev); 157 master_priv->sarea = drm_getsarea(dev);
158 if (master_priv->sarea) { 158 if (master_priv->sarea) {
@@ -163,33 +163,22 @@ static int i915_initialize(struct drm_device * dev, drm_i915_init_t * init)
163 } 163 }
164 164
165 if (init->ring_size != 0) { 165 if (init->ring_size != 0) {
166 if (ring->obj != NULL) { 166 if (LP_RING(dev_priv)->obj != NULL) {
167 i915_dma_cleanup(dev); 167 i915_dma_cleanup(dev);
168 DRM_ERROR("Client tried to initialize ringbuffer in " 168 DRM_ERROR("Client tried to initialize ringbuffer in "
169 "GEM mode\n"); 169 "GEM mode\n");
170 return -EINVAL; 170 return -EINVAL;
171 } 171 }
172 172
173 ring->size = init->ring_size; 173 ret = intel_render_ring_init_dri(dev,
174 174 init->ring_start,
175 ring->map.offset = init->ring_start; 175 init->ring_size);
176 ring->map.size = init->ring_size; 176 if (ret) {
177 ring->map.type = 0;
178 ring->map.flags = 0;
179 ring->map.mtrr = 0;
180
181 drm_core_ioremap_wc(&ring->map, dev);
182
183 if (ring->map.handle == NULL) {
184 i915_dma_cleanup(dev); 177 i915_dma_cleanup(dev);
185 DRM_ERROR("can not ioremap virtual address for" 178 return ret;
186 " ring buffer\n");
187 return -ENOMEM;
188 } 179 }
189 } 180 }
190 181
191 ring->virtual_start = ring->map.handle;
192
193 dev_priv->cpp = init->cpp; 182 dev_priv->cpp = init->cpp;
194 dev_priv->back_offset = init->back_offset; 183 dev_priv->back_offset = init->back_offset;
195 dev_priv->front_offset = init->front_offset; 184 dev_priv->front_offset = init->front_offset;
@@ -1226,9 +1215,15 @@ static int i915_load_modeset_init(struct drm_device *dev)
1226 if (ret) 1215 if (ret)
1227 DRM_INFO("failed to find VBIOS tables\n"); 1216 DRM_INFO("failed to find VBIOS tables\n");
1228 1217
1229 /* if we have > 1 VGA cards, then disable the radeon VGA resources */ 1218 /* If we have > 1 VGA cards, then we need to arbitrate access
1219 * to the common VGA resources.
1220 *
1221 * If we are a secondary display controller (!PCI_DISPLAY_CLASS_VGA),
1222 * then we do not take part in VGA arbitration and the
1223 * vga_client_register() fails with -ENODEV.
1224 */
1230 ret = vga_client_register(dev->pdev, dev, NULL, i915_vga_set_decode); 1225 ret = vga_client_register(dev->pdev, dev, NULL, i915_vga_set_decode);
1231 if (ret) 1226 if (ret && ret != -ENODEV)
1232 goto cleanup_ringbuffer; 1227 goto cleanup_ringbuffer;
1233 1228
1234 intel_register_dsm_handler(); 1229 intel_register_dsm_handler();
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 72fea2bcfc4f..66796bb82d3e 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -60,7 +60,7 @@ extern int intel_agp_enabled;
60 60
61#define INTEL_VGA_DEVICE(id, info) { \ 61#define INTEL_VGA_DEVICE(id, info) { \
62 .class = PCI_CLASS_DISPLAY_VGA << 8, \ 62 .class = PCI_CLASS_DISPLAY_VGA << 8, \
63 .class_mask = 0xffff00, \ 63 .class_mask = 0xff0000, \
64 .vendor = 0x8086, \ 64 .vendor = 0x8086, \
65 .device = id, \ 65 .device = id, \
66 .subvendor = PCI_ANY_ID, \ 66 .subvendor = PCI_ANY_ID, \
@@ -752,6 +752,9 @@ static int __init i915_init(void)
752 driver.driver_features &= ~DRIVER_MODESET; 752 driver.driver_features &= ~DRIVER_MODESET;
753#endif 753#endif
754 754
755 if (!(driver.driver_features & DRIVER_MODESET))
756 driver.get_vblank_timestamp = NULL;
757
755 return drm_init(&driver); 758 return drm_init(&driver);
756} 759}
757 760
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 5969f46ac2d6..a0149c619cdd 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -543,8 +543,11 @@ typedef struct drm_i915_private {
543 /** List of all objects in gtt_space. Used to restore gtt 543 /** List of all objects in gtt_space. Used to restore gtt
544 * mappings on resume */ 544 * mappings on resume */
545 struct list_head gtt_list; 545 struct list_head gtt_list;
546 /** End of mappable part of GTT */ 546
547 /** Usable portion of the GTT for GEM */
548 unsigned long gtt_start;
547 unsigned long gtt_mappable_end; 549 unsigned long gtt_mappable_end;
550 unsigned long gtt_end;
548 551
549 struct io_mapping *gtt_mapping; 552 struct io_mapping *gtt_mapping;
550 int gtt_mtrr; 553 int gtt_mtrr;
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 3dfc848ff755..cf4f74c7c6fb 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -140,12 +140,16 @@ void i915_gem_do_init(struct drm_device *dev,
140{ 140{
141 drm_i915_private_t *dev_priv = dev->dev_private; 141 drm_i915_private_t *dev_priv = dev->dev_private;
142 142
143 drm_mm_init(&dev_priv->mm.gtt_space, start, 143 drm_mm_init(&dev_priv->mm.gtt_space, start, end - start);
144 end - start);
145 144
145 dev_priv->mm.gtt_start = start;
146 dev_priv->mm.gtt_mappable_end = mappable_end;
147 dev_priv->mm.gtt_end = end;
146 dev_priv->mm.gtt_total = end - start; 148 dev_priv->mm.gtt_total = end - start;
147 dev_priv->mm.mappable_gtt_total = min(end, mappable_end) - start; 149 dev_priv->mm.mappable_gtt_total = min(end, mappable_end) - start;
148 dev_priv->mm.gtt_mappable_end = mappable_end; 150
151 /* Take over this portion of the GTT */
152 intel_gtt_clear_range(start / PAGE_SIZE, (end-start) / PAGE_SIZE);
149} 153}
150 154
151int 155int
@@ -1857,7 +1861,7 @@ i915_gem_retire_requests_ring(struct drm_device *dev,
1857 1861
1858 seqno = ring->get_seqno(ring); 1862 seqno = ring->get_seqno(ring);
1859 1863
1860 for (i = 0; i < I915_NUM_RINGS; i++) 1864 for (i = 0; i < ARRAY_SIZE(ring->sync_seqno); i++)
1861 if (seqno >= ring->sync_seqno[i]) 1865 if (seqno >= ring->sync_seqno[i])
1862 ring->sync_seqno[i] = 0; 1866 ring->sync_seqno[i] = 0;
1863 1867
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index dcfdf4151b6d..d2f445e825f2 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -1175,7 +1175,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
1175 goto err; 1175 goto err;
1176 1176
1177 seqno = i915_gem_next_request_seqno(dev, ring); 1177 seqno = i915_gem_next_request_seqno(dev, ring);
1178 for (i = 0; i < I915_NUM_RINGS-1; i++) { 1178 for (i = 0; i < ARRAY_SIZE(ring->sync_seqno); i++) {
1179 if (seqno < ring->sync_seqno[i]) { 1179 if (seqno < ring->sync_seqno[i]) {
1180 /* The GPU can not handle its semaphore value wrapping, 1180 /* The GPU can not handle its semaphore value wrapping,
1181 * so every billion or so execbuffers, we need to stall 1181 * so every billion or so execbuffers, we need to stall
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 70433ae50ac8..b0abdc64aa9f 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -34,6 +34,10 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev)
34 struct drm_i915_private *dev_priv = dev->dev_private; 34 struct drm_i915_private *dev_priv = dev->dev_private;
35 struct drm_i915_gem_object *obj; 35 struct drm_i915_gem_object *obj;
36 36
37 /* First fill our portion of the GTT with scratch pages */
38 intel_gtt_clear_range(dev_priv->mm.gtt_start / PAGE_SIZE,
39 (dev_priv->mm.gtt_end - dev_priv->mm.gtt_start) / PAGE_SIZE);
40
37 list_for_each_entry(obj, &dev_priv->mm.gtt_list, gtt_list) { 41 list_for_each_entry(obj, &dev_priv->mm.gtt_list, gtt_list) {
38 i915_gem_clflush_object(obj); 42 i915_gem_clflush_object(obj);
39 43
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index b8e509ae065e..062f353497e6 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -274,24 +274,35 @@ int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe,
274 return ret; 274 return ret;
275} 275}
276 276
277int i915_get_vblank_timestamp(struct drm_device *dev, int crtc, 277int i915_get_vblank_timestamp(struct drm_device *dev, int pipe,
278 int *max_error, 278 int *max_error,
279 struct timeval *vblank_time, 279 struct timeval *vblank_time,
280 unsigned flags) 280 unsigned flags)
281{ 281{
282 struct drm_crtc *drmcrtc; 282 struct drm_i915_private *dev_priv = dev->dev_private;
283 struct drm_crtc *crtc;
283 284
284 if (crtc < 0 || crtc >= dev->num_crtcs) { 285 if (pipe < 0 || pipe >= dev_priv->num_pipe) {
285 DRM_ERROR("Invalid crtc %d\n", crtc); 286 DRM_ERROR("Invalid crtc %d\n", pipe);
286 return -EINVAL; 287 return -EINVAL;
287 } 288 }
288 289
289 /* Get drm_crtc to timestamp: */ 290 /* Get drm_crtc to timestamp: */
290 drmcrtc = intel_get_crtc_for_pipe(dev, crtc); 291 crtc = intel_get_crtc_for_pipe(dev, pipe);
292 if (crtc == NULL) {
293 DRM_ERROR("Invalid crtc %d\n", pipe);
294 return -EINVAL;
295 }
296
297 if (!crtc->enabled) {
298 DRM_DEBUG_KMS("crtc %d is disabled\n", pipe);
299 return -EBUSY;
300 }
291 301
292 /* Helper routine in DRM core does all the work: */ 302 /* Helper routine in DRM core does all the work: */
293 return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc, max_error, 303 return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
294 vblank_time, flags, drmcrtc); 304 vblank_time, flags,
305 crtc);
295} 306}
296 307
297/* 308/*
@@ -348,8 +359,12 @@ static void notify_ring(struct drm_device *dev,
348 struct intel_ring_buffer *ring) 359 struct intel_ring_buffer *ring)
349{ 360{
350 struct drm_i915_private *dev_priv = dev->dev_private; 361 struct drm_i915_private *dev_priv = dev->dev_private;
351 u32 seqno = ring->get_seqno(ring); 362 u32 seqno;
352 363
364 if (ring->obj == NULL)
365 return;
366
367 seqno = ring->get_seqno(ring);
353 trace_i915_gem_request_complete(dev, seqno); 368 trace_i915_gem_request_complete(dev, seqno);
354 369
355 ring->irq_seqno = seqno; 370 ring->irq_seqno = seqno;
@@ -831,6 +846,8 @@ static void i915_capture_error_state(struct drm_device *dev)
831 i++; 846 i++;
832 error->pinned_bo_count = i - error->active_bo_count; 847 error->pinned_bo_count = i - error->active_bo_count;
833 848
849 error->active_bo = NULL;
850 error->pinned_bo = NULL;
834 if (i) { 851 if (i) {
835 error->active_bo = kmalloc(sizeof(*error->active_bo)*i, 852 error->active_bo = kmalloc(sizeof(*error->active_bo)*i,
836 GFP_ATOMIC); 853 GFP_ATOMIC);
@@ -1278,12 +1295,12 @@ static int i915_wait_irq(struct drm_device * dev, int irq_nr)
1278 if (master_priv->sarea_priv) 1295 if (master_priv->sarea_priv)
1279 master_priv->sarea_priv->perf_boxes |= I915_BOX_WAIT; 1296 master_priv->sarea_priv->perf_boxes |= I915_BOX_WAIT;
1280 1297
1281 ret = -ENODEV;
1282 if (ring->irq_get(ring)) { 1298 if (ring->irq_get(ring)) {
1283 DRM_WAIT_ON(ret, ring->irq_queue, 3 * DRM_HZ, 1299 DRM_WAIT_ON(ret, ring->irq_queue, 3 * DRM_HZ,
1284 READ_BREADCRUMB(dev_priv) >= irq_nr); 1300 READ_BREADCRUMB(dev_priv) >= irq_nr);
1285 ring->irq_put(ring); 1301 ring->irq_put(ring);
1286 } 1302 } else if (wait_for(READ_BREADCRUMB(dev_priv) >= irq_nr, 3000))
1303 ret = -EBUSY;
1287 1304
1288 if (ret == -EBUSY) { 1305 if (ret == -EBUSY) {
1289 DRM_ERROR("EBUSY -- rec: %d emitted: %d\n", 1306 DRM_ERROR("EBUSY -- rec: %d emitted: %d\n",
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 40a407f41f61..5cfc68940f17 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -513,6 +513,10 @@
513#define GEN6_BLITTER_SYNC_STATUS (1 << 24) 513#define GEN6_BLITTER_SYNC_STATUS (1 << 24)
514#define GEN6_BLITTER_USER_INTERRUPT (1 << 22) 514#define GEN6_BLITTER_USER_INTERRUPT (1 << 22)
515 515
516#define GEN6_BLITTER_ECOSKPD 0x221d0
517#define GEN6_BLITTER_LOCK_SHIFT 16
518#define GEN6_BLITTER_FBC_NOTIFY (1<<3)
519
516#define GEN6_BSD_SLEEP_PSMI_CONTROL 0x12050 520#define GEN6_BSD_SLEEP_PSMI_CONTROL 0x12050
517#define GEN6_BSD_SLEEP_PSMI_CONTROL_RC_ILDL_MESSAGE_MODIFY_MASK (1 << 16) 521#define GEN6_BSD_SLEEP_PSMI_CONTROL_RC_ILDL_MESSAGE_MODIFY_MASK (1 << 16)
518#define GEN6_BSD_SLEEP_PSMI_CONTROL_RC_ILDL_MESSAGE_DISABLE (1 << 0) 522#define GEN6_BSD_SLEEP_PSMI_CONTROL_RC_ILDL_MESSAGE_DISABLE (1 << 0)
@@ -2626,6 +2630,8 @@
2626#define DISPLAY_PORT_PLL_BIOS_2 0x46014 2630#define DISPLAY_PORT_PLL_BIOS_2 0x46014
2627 2631
2628#define PCH_DSPCLK_GATE_D 0x42020 2632#define PCH_DSPCLK_GATE_D 0x42020
2633# define DPFCUNIT_CLOCK_GATE_DISABLE (1 << 9)
2634# define DPFCRUNIT_CLOCK_GATE_DISABLE (1 << 8)
2629# define DPFDUNIT_CLOCK_GATE_DISABLE (1 << 7) 2635# define DPFDUNIT_CLOCK_GATE_DISABLE (1 << 7)
2630# define DPARBUNIT_CLOCK_GATE_DISABLE (1 << 5) 2636# define DPARBUNIT_CLOCK_GATE_DISABLE (1 << 5)
2631 2637
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 98967f3b7724..d7f237deaaf0 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -1213,6 +1213,26 @@ static bool g4x_fbc_enabled(struct drm_device *dev)
1213 return I915_READ(DPFC_CONTROL) & DPFC_CTL_EN; 1213 return I915_READ(DPFC_CONTROL) & DPFC_CTL_EN;
1214} 1214}
1215 1215
1216static void sandybridge_blit_fbc_update(struct drm_device *dev)
1217{
1218 struct drm_i915_private *dev_priv = dev->dev_private;
1219 u32 blt_ecoskpd;
1220
1221 /* Make sure blitter notifies FBC of writes */
1222 __gen6_force_wake_get(dev_priv);
1223 blt_ecoskpd = I915_READ(GEN6_BLITTER_ECOSKPD);
1224 blt_ecoskpd |= GEN6_BLITTER_FBC_NOTIFY <<
1225 GEN6_BLITTER_LOCK_SHIFT;
1226 I915_WRITE(GEN6_BLITTER_ECOSKPD, blt_ecoskpd);
1227 blt_ecoskpd |= GEN6_BLITTER_FBC_NOTIFY;
1228 I915_WRITE(GEN6_BLITTER_ECOSKPD, blt_ecoskpd);
1229 blt_ecoskpd &= ~(GEN6_BLITTER_FBC_NOTIFY <<
1230 GEN6_BLITTER_LOCK_SHIFT);
1231 I915_WRITE(GEN6_BLITTER_ECOSKPD, blt_ecoskpd);
1232 POSTING_READ(GEN6_BLITTER_ECOSKPD);
1233 __gen6_force_wake_put(dev_priv);
1234}
1235
1216static void ironlake_enable_fbc(struct drm_crtc *crtc, unsigned long interval) 1236static void ironlake_enable_fbc(struct drm_crtc *crtc, unsigned long interval)
1217{ 1237{
1218 struct drm_device *dev = crtc->dev; 1238 struct drm_device *dev = crtc->dev;
@@ -1266,6 +1286,7 @@ static void ironlake_enable_fbc(struct drm_crtc *crtc, unsigned long interval)
1266 I915_WRITE(SNB_DPFC_CTL_SA, 1286 I915_WRITE(SNB_DPFC_CTL_SA,
1267 SNB_CPU_FENCE_ENABLE | dev_priv->cfb_fence); 1287 SNB_CPU_FENCE_ENABLE | dev_priv->cfb_fence);
1268 I915_WRITE(DPFC_CPU_FENCE_OFFSET, crtc->y); 1288 I915_WRITE(DPFC_CPU_FENCE_OFFSET, crtc->y);
1289 sandybridge_blit_fbc_update(dev);
1269 } 1290 }
1270 1291
1271 DRM_DEBUG_KMS("enabled fbc on plane %d\n", intel_crtc->plane); 1292 DRM_DEBUG_KMS("enabled fbc on plane %d\n", intel_crtc->plane);
@@ -6286,7 +6307,9 @@ void intel_enable_clock_gating(struct drm_device *dev)
6286 6307
6287 if (IS_GEN5(dev)) { 6308 if (IS_GEN5(dev)) {
6288 /* Required for FBC */ 6309 /* Required for FBC */
6289 dspclk_gate |= DPFDUNIT_CLOCK_GATE_DISABLE; 6310 dspclk_gate |= DPFCUNIT_CLOCK_GATE_DISABLE |
6311 DPFCRUNIT_CLOCK_GATE_DISABLE |
6312 DPFDUNIT_CLOCK_GATE_DISABLE;
6290 /* Required for CxSR */ 6313 /* Required for CxSR */
6291 dspclk_gate |= DPARBUNIT_CLOCK_GATE_DISABLE; 6314 dspclk_gate |= DPARBUNIT_CLOCK_GATE_DISABLE;
6292 6315
diff --git a/drivers/gpu/drm/i915/intel_opregion.c b/drivers/gpu/drm/i915/intel_opregion.c
index f295a7aaadf9..64fd64443ca6 100644
--- a/drivers/gpu/drm/i915/intel_opregion.c
+++ b/drivers/gpu/drm/i915/intel_opregion.c
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28#include <linux/acpi.h> 28#include <linux/acpi.h>
29#include <linux/acpi_io.h>
29#include <acpi/video.h> 30#include <acpi/video.h>
30 31
31#include "drmP.h" 32#include "drmP.h"
@@ -476,7 +477,7 @@ int intel_opregion_setup(struct drm_device *dev)
476 return -ENOTSUPP; 477 return -ENOTSUPP;
477 } 478 }
478 479
479 base = ioremap(asls, OPREGION_SIZE); 480 base = acpi_os_ioremap(asls, OPREGION_SIZE);
480 if (!base) 481 if (!base)
481 return -ENOMEM; 482 return -ENOMEM;
482 483
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index f6b9baa6a63d..6218fa97aa1e 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -34,6 +34,14 @@
34#include "i915_trace.h" 34#include "i915_trace.h"
35#include "intel_drv.h" 35#include "intel_drv.h"
36 36
37static inline int ring_space(struct intel_ring_buffer *ring)
38{
39 int space = (ring->head & HEAD_ADDR) - (ring->tail + 8);
40 if (space < 0)
41 space += ring->size;
42 return space;
43}
44
37static u32 i915_gem_get_seqno(struct drm_device *dev) 45static u32 i915_gem_get_seqno(struct drm_device *dev)
38{ 46{
39 drm_i915_private_t *dev_priv = dev->dev_private; 47 drm_i915_private_t *dev_priv = dev->dev_private;
@@ -204,11 +212,9 @@ static int init_ring_common(struct intel_ring_buffer *ring)
204 if (!drm_core_check_feature(ring->dev, DRIVER_MODESET)) 212 if (!drm_core_check_feature(ring->dev, DRIVER_MODESET))
205 i915_kernel_lost_context(ring->dev); 213 i915_kernel_lost_context(ring->dev);
206 else { 214 else {
207 ring->head = I915_READ_HEAD(ring) & HEAD_ADDR; 215 ring->head = I915_READ_HEAD(ring);
208 ring->tail = I915_READ_TAIL(ring) & TAIL_ADDR; 216 ring->tail = I915_READ_TAIL(ring) & TAIL_ADDR;
209 ring->space = ring->head - (ring->tail + 8); 217 ring->space = ring_space(ring);
210 if (ring->space < 0)
211 ring->space += ring->size;
212 } 218 }
213 219
214 return 0; 220 return 0;
@@ -921,32 +927,34 @@ static int intel_wrap_ring_buffer(struct intel_ring_buffer *ring)
921 } 927 }
922 928
923 ring->tail = 0; 929 ring->tail = 0;
924 ring->space = ring->head - 8; 930 ring->space = ring_space(ring);
925 931
926 return 0; 932 return 0;
927} 933}
928 934
929int intel_wait_ring_buffer(struct intel_ring_buffer *ring, int n) 935int intel_wait_ring_buffer(struct intel_ring_buffer *ring, int n)
930{ 936{
931 int reread = 0;
932 struct drm_device *dev = ring->dev; 937 struct drm_device *dev = ring->dev;
933 struct drm_i915_private *dev_priv = dev->dev_private; 938 struct drm_i915_private *dev_priv = dev->dev_private;
934 unsigned long end; 939 unsigned long end;
935 u32 head; 940 u32 head;
936 941
942 /* If the reported head position has wrapped or hasn't advanced,
943 * fallback to the slow and accurate path.
944 */
945 head = intel_read_status_page(ring, 4);
946 if (head > ring->head) {
947 ring->head = head;
948 ring->space = ring_space(ring);
949 if (ring->space >= n)
950 return 0;
951 }
952
937 trace_i915_ring_wait_begin (dev); 953 trace_i915_ring_wait_begin (dev);
938 end = jiffies + 3 * HZ; 954 end = jiffies + 3 * HZ;
939 do { 955 do {
940 /* If the reported head position has wrapped or hasn't advanced, 956 ring->head = I915_READ_HEAD(ring);
941 * fallback to the slow and accurate path. 957 ring->space = ring_space(ring);
942 */
943 head = intel_read_status_page(ring, 4);
944 if (reread)
945 head = I915_READ_HEAD(ring);
946 ring->head = head & HEAD_ADDR;
947 ring->space = ring->head - (ring->tail + 8);
948 if (ring->space < 0)
949 ring->space += ring->size;
950 if (ring->space >= n) { 958 if (ring->space >= n) {
951 trace_i915_ring_wait_end(dev); 959 trace_i915_ring_wait_end(dev);
952 return 0; 960 return 0;
@@ -961,7 +969,6 @@ int intel_wait_ring_buffer(struct intel_ring_buffer *ring, int n)
961 msleep(1); 969 msleep(1);
962 if (atomic_read(&dev_priv->mm.wedged)) 970 if (atomic_read(&dev_priv->mm.wedged))
963 return -EAGAIN; 971 return -EAGAIN;
964 reread = 1;
965 } while (!time_after(jiffies, end)); 972 } while (!time_after(jiffies, end));
966 trace_i915_ring_wait_end (dev); 973 trace_i915_ring_wait_end (dev);
967 return -EBUSY; 974 return -EBUSY;
@@ -1292,6 +1299,48 @@ int intel_init_render_ring_buffer(struct drm_device *dev)
1292 return intel_init_ring_buffer(dev, ring); 1299 return intel_init_ring_buffer(dev, ring);
1293} 1300}
1294 1301
1302int intel_render_ring_init_dri(struct drm_device *dev, u64 start, u32 size)
1303{
1304 drm_i915_private_t *dev_priv = dev->dev_private;
1305 struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
1306
1307 *ring = render_ring;
1308 if (INTEL_INFO(dev)->gen >= 6) {
1309 ring->add_request = gen6_add_request;
1310 ring->irq_get = gen6_render_ring_get_irq;
1311 ring->irq_put = gen6_render_ring_put_irq;
1312 } else if (IS_GEN5(dev)) {
1313 ring->add_request = pc_render_add_request;
1314 ring->get_seqno = pc_render_get_seqno;
1315 }
1316
1317 ring->dev = dev;
1318 INIT_LIST_HEAD(&ring->active_list);
1319 INIT_LIST_HEAD(&ring->request_list);
1320 INIT_LIST_HEAD(&ring->gpu_write_list);
1321
1322 ring->size = size;
1323 ring->effective_size = ring->size;
1324 if (IS_I830(ring->dev))
1325 ring->effective_size -= 128;
1326
1327 ring->map.offset = start;
1328 ring->map.size = size;
1329 ring->map.type = 0;
1330 ring->map.flags = 0;
1331 ring->map.mtrr = 0;
1332
1333 drm_core_ioremap_wc(&ring->map, dev);
1334 if (ring->map.handle == NULL) {
1335 DRM_ERROR("can not ioremap virtual address for"
1336 " ring buffer\n");
1337 return -ENOMEM;
1338 }
1339
1340 ring->virtual_start = (void __force __iomem *)ring->map.handle;
1341 return 0;
1342}
1343
1295int intel_init_bsd_ring_buffer(struct drm_device *dev) 1344int intel_init_bsd_ring_buffer(struct drm_device *dev)
1296{ 1345{
1297 drm_i915_private_t *dev_priv = dev->dev_private; 1346 drm_i915_private_t *dev_priv = dev->dev_private;
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index 5b0abfa881fc..6d6fde85a636 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -166,4 +166,7 @@ int intel_init_blt_ring_buffer(struct drm_device *dev);
166u32 intel_ring_get_active_head(struct intel_ring_buffer *ring); 166u32 intel_ring_get_active_head(struct intel_ring_buffer *ring);
167void intel_ring_setup_status_page(struct intel_ring_buffer *ring); 167void intel_ring_setup_status_page(struct intel_ring_buffer *ring);
168 168
169/* DRI warts */
170int intel_render_ring_init_dri(struct drm_device *dev, u64 start, u32 size);
171
169#endif /* _INTEL_RINGBUFFER_H_ */ 172#endif /* _INTEL_RINGBUFFER_H_ */
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.c b/drivers/gpu/drm/nouveau/nouveau_drv.c
index 13bb672a16f4..f658a04eecf9 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.c
@@ -234,9 +234,9 @@ nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state)
234 pci_set_power_state(pdev, PCI_D3hot); 234 pci_set_power_state(pdev, PCI_D3hot);
235 } 235 }
236 236
237 acquire_console_sem(); 237 console_lock();
238 nouveau_fbcon_set_suspend(dev, 1); 238 nouveau_fbcon_set_suspend(dev, 1);
239 release_console_sem(); 239 console_unlock();
240 nouveau_fbcon_restore_accel(dev); 240 nouveau_fbcon_restore_accel(dev);
241 return 0; 241 return 0;
242 242
@@ -359,9 +359,9 @@ nouveau_pci_resume(struct pci_dev *pdev)
359 nv_crtc->lut.depth = 0; 359 nv_crtc->lut.depth = 0;
360 } 360 }
361 361
362 acquire_console_sem(); 362 console_lock();
363 nouveau_fbcon_set_suspend(dev, 0); 363 nouveau_fbcon_set_suspend(dev, 0);
364 release_console_sem(); 364 console_unlock();
365 365
366 nouveau_fbcon_zfill_all(dev); 366 nouveau_fbcon_zfill_all(dev);
367 367
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index b0ab185b86f6..d3ca17080df7 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -606,14 +606,9 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
606 args.v1.usPixelClock = cpu_to_le16(mode->clock / 10); 606 args.v1.usPixelClock = cpu_to_le16(mode->clock / 10);
607 args.v1.ucTransmitterID = radeon_encoder->encoder_id; 607 args.v1.ucTransmitterID = radeon_encoder->encoder_id;
608 args.v1.ucEncodeMode = encoder_mode; 608 args.v1.ucEncodeMode = encoder_mode;
609 if (encoder_mode == ATOM_ENCODER_MODE_DP) { 609 if (ss_enabled)
610 if (ss_enabled)
611 args.v1.ucConfig |=
612 ADJUST_DISPLAY_CONFIG_SS_ENABLE;
613 } else if (encoder_mode == ATOM_ENCODER_MODE_LVDS) {
614 args.v1.ucConfig |= 610 args.v1.ucConfig |=
615 ADJUST_DISPLAY_CONFIG_SS_ENABLE; 611 ADJUST_DISPLAY_CONFIG_SS_ENABLE;
616 }
617 612
618 atom_execute_table(rdev->mode_info.atom_context, 613 atom_execute_table(rdev->mode_info.atom_context,
619 index, (uint32_t *)&args); 614 index, (uint32_t *)&args);
@@ -624,12 +619,12 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
624 args.v3.sInput.ucTransmitterID = radeon_encoder->encoder_id; 619 args.v3.sInput.ucTransmitterID = radeon_encoder->encoder_id;
625 args.v3.sInput.ucEncodeMode = encoder_mode; 620 args.v3.sInput.ucEncodeMode = encoder_mode;
626 args.v3.sInput.ucDispPllConfig = 0; 621 args.v3.sInput.ucDispPllConfig = 0;
622 if (ss_enabled)
623 args.v3.sInput.ucDispPllConfig |=
624 DISPPLL_CONFIG_SS_ENABLE;
627 if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { 625 if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) {
628 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; 626 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
629 if (encoder_mode == ATOM_ENCODER_MODE_DP) { 627 if (encoder_mode == ATOM_ENCODER_MODE_DP) {
630 if (ss_enabled)
631 args.v3.sInput.ucDispPllConfig |=
632 DISPPLL_CONFIG_SS_ENABLE;
633 args.v3.sInput.ucDispPllConfig |= 628 args.v3.sInput.ucDispPllConfig |=
634 DISPPLL_CONFIG_COHERENT_MODE; 629 DISPPLL_CONFIG_COHERENT_MODE;
635 /* 16200 or 27000 */ 630 /* 16200 or 27000 */
@@ -649,18 +644,11 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
649 } 644 }
650 } else if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { 645 } else if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
651 if (encoder_mode == ATOM_ENCODER_MODE_DP) { 646 if (encoder_mode == ATOM_ENCODER_MODE_DP) {
652 if (ss_enabled)
653 args.v3.sInput.ucDispPllConfig |=
654 DISPPLL_CONFIG_SS_ENABLE;
655 args.v3.sInput.ucDispPllConfig |= 647 args.v3.sInput.ucDispPllConfig |=
656 DISPPLL_CONFIG_COHERENT_MODE; 648 DISPPLL_CONFIG_COHERENT_MODE;
657 /* 16200 or 27000 */ 649 /* 16200 or 27000 */
658 args.v3.sInput.usPixelClock = cpu_to_le16(dp_clock / 10); 650 args.v3.sInput.usPixelClock = cpu_to_le16(dp_clock / 10);
659 } else if (encoder_mode == ATOM_ENCODER_MODE_LVDS) { 651 } else if (encoder_mode != ATOM_ENCODER_MODE_LVDS) {
660 if (ss_enabled)
661 args.v3.sInput.ucDispPllConfig |=
662 DISPPLL_CONFIG_SS_ENABLE;
663 } else {
664 if (mode->clock > 165000) 652 if (mode->clock > 165000)
665 args.v3.sInput.ucDispPllConfig |= 653 args.v3.sInput.ucDispPllConfig |=
666 DISPPLL_CONFIG_DUAL_LINK; 654 DISPPLL_CONFIG_DUAL_LINK;
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index a8973acb3987..677af91b555c 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -2201,6 +2201,9 @@ static int evergreen_gpu_soft_reset(struct radeon_device *rdev)
2201 struct evergreen_mc_save save; 2201 struct evergreen_mc_save save;
2202 u32 grbm_reset = 0; 2202 u32 grbm_reset = 0;
2203 2203
2204 if (!(RREG32(GRBM_STATUS) & GUI_ACTIVE))
2205 return 0;
2206
2204 dev_info(rdev->dev, "GPU softreset \n"); 2207 dev_info(rdev->dev, "GPU softreset \n");
2205 dev_info(rdev->dev, " GRBM_STATUS=0x%08X\n", 2208 dev_info(rdev->dev, " GRBM_STATUS=0x%08X\n",
2206 RREG32(GRBM_STATUS)); 2209 RREG32(GRBM_STATUS));
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 46da5142b131..5968dde243e9 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -3522,7 +3522,7 @@ int r100_ring_test(struct radeon_device *rdev)
3522 if (i < rdev->usec_timeout) { 3522 if (i < rdev->usec_timeout) {
3523 DRM_INFO("ring test succeeded in %d usecs\n", i); 3523 DRM_INFO("ring test succeeded in %d usecs\n", i);
3524 } else { 3524 } else {
3525 DRM_ERROR("radeon: ring test failed (sracth(0x%04X)=0x%08X)\n", 3525 DRM_ERROR("radeon: ring test failed (scratch(0x%04X)=0x%08X)\n",
3526 scratch, tmp); 3526 scratch, tmp);
3527 r = -EINVAL; 3527 r = -EINVAL;
3528 } 3528 }
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index aca2236268fa..1e10e3e2ba2a 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -1287,6 +1287,9 @@ int r600_gpu_soft_reset(struct radeon_device *rdev)
1287 S_008014_CB2_BUSY(1) | S_008014_CB3_BUSY(1); 1287 S_008014_CB2_BUSY(1) | S_008014_CB3_BUSY(1);
1288 u32 tmp; 1288 u32 tmp;
1289 1289
1290 if (!(RREG32(GRBM_STATUS) & GUI_ACTIVE))
1291 return 0;
1292
1290 dev_info(rdev->dev, "GPU softreset \n"); 1293 dev_info(rdev->dev, "GPU softreset \n");
1291 dev_info(rdev->dev, " R_008010_GRBM_STATUS=0x%08X\n", 1294 dev_info(rdev->dev, " R_008010_GRBM_STATUS=0x%08X\n",
1292 RREG32(R_008010_GRBM_STATUS)); 1295 RREG32(R_008010_GRBM_STATUS));
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
index 1573202a6418..52777902bbcc 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -387,15 +387,11 @@ static bool radeon_atom_apply_quirks(struct drm_device *dev,
387 *line_mux = 0x90; 387 *line_mux = 0x90;
388 } 388 }
389 389
390 /* mac rv630 */ 390 /* mac rv630, rv730, others */
391 if ((dev->pdev->device == 0x9588) && 391 if ((supported_device == ATOM_DEVICE_TV1_SUPPORT) &&
392 (dev->pdev->subsystem_vendor == 0x106b) && 392 (*connector_type == DRM_MODE_CONNECTOR_DVII)) {
393 (dev->pdev->subsystem_device == 0x00a6)) { 393 *connector_type = DRM_MODE_CONNECTOR_9PinDIN;
394 if ((supported_device == ATOM_DEVICE_TV1_SUPPORT) && 394 *line_mux = CONNECTOR_7PIN_DIN_ENUM_ID1;
395 (*connector_type == DRM_MODE_CONNECTOR_DVII)) {
396 *connector_type = DRM_MODE_CONNECTOR_9PinDIN;
397 *line_mux = CONNECTOR_7PIN_DIN_ENUM_ID1;
398 }
399 } 395 }
400 396
401 /* ASUS HD 3600 XT board lists the DVI port as HDMI */ 397 /* ASUS HD 3600 XT board lists the DVI port as HDMI */
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 26091d602b84..0d478932b1a9 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -891,9 +891,9 @@ int radeon_suspend_kms(struct drm_device *dev, pm_message_t state)
891 pci_disable_device(dev->pdev); 891 pci_disable_device(dev->pdev);
892 pci_set_power_state(dev->pdev, PCI_D3hot); 892 pci_set_power_state(dev->pdev, PCI_D3hot);
893 } 893 }
894 acquire_console_sem(); 894 console_lock();
895 radeon_fbdev_set_suspend(rdev, 1); 895 radeon_fbdev_set_suspend(rdev, 1);
896 release_console_sem(); 896 console_unlock();
897 return 0; 897 return 0;
898} 898}
899 899
@@ -905,11 +905,11 @@ int radeon_resume_kms(struct drm_device *dev)
905 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) 905 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
906 return 0; 906 return 0;
907 907
908 acquire_console_sem(); 908 console_lock();
909 pci_set_power_state(dev->pdev, PCI_D0); 909 pci_set_power_state(dev->pdev, PCI_D0);
910 pci_restore_state(dev->pdev); 910 pci_restore_state(dev->pdev);
911 if (pci_enable_device(dev->pdev)) { 911 if (pci_enable_device(dev->pdev)) {
912 release_console_sem(); 912 console_unlock();
913 return -1; 913 return -1;
914 } 914 }
915 pci_set_master(dev->pdev); 915 pci_set_master(dev->pdev);
@@ -920,7 +920,7 @@ int radeon_resume_kms(struct drm_device *dev)
920 radeon_restore_bios_scratch_regs(rdev); 920 radeon_restore_bios_scratch_regs(rdev);
921 921
922 radeon_fbdev_set_suspend(rdev, 0); 922 radeon_fbdev_set_suspend(rdev, 0);
923 release_console_sem(); 923 console_unlock();
924 924
925 /* reset hpd state */ 925 /* reset hpd state */
926 radeon_hpd_init(rdev); 926 radeon_hpd_init(rdev);
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index d5680a0c87af..275b26a708d6 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -48,7 +48,7 @@
48 * - 2.5.0 - add get accel 2 to work around ddx breakage for evergreen 48 * - 2.5.0 - add get accel 2 to work around ddx breakage for evergreen
49 * - 2.6.0 - add tiling config query (r6xx+), add initial HiZ support (r300->r500) 49 * - 2.6.0 - add tiling config query (r6xx+), add initial HiZ support (r300->r500)
50 * 2.7.0 - fixups for r600 2D tiling support. (no external ABI change), add eg dyn gpr regs 50 * 2.7.0 - fixups for r600 2D tiling support. (no external ABI change), add eg dyn gpr regs
51 * 2.8.0 - pageflip support, r500 US_FORMAT regs. r500 ARGB2101010 colorbuf, r300->r500 CMASK 51 * 2.8.0 - pageflip support, r500 US_FORMAT regs. r500 ARGB2101010 colorbuf, r300->r500 CMASK, clock crystal query
52 */ 52 */
53#define KMS_DRIVER_MAJOR 2 53#define KMS_DRIVER_MAJOR 2
54#define KMS_DRIVER_MINOR 8 54#define KMS_DRIVER_MINOR 8
diff --git a/drivers/gpu/drm/radeon/radeon_irq_kms.c b/drivers/gpu/drm/radeon/radeon_irq_kms.c
index a289646e8aa4..9ec830c77af0 100644
--- a/drivers/gpu/drm/radeon/radeon_irq_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_irq_kms.c
@@ -110,11 +110,14 @@ void radeon_driver_irq_uninstall_kms(struct drm_device *dev)
110 110
111int radeon_irq_kms_init(struct radeon_device *rdev) 111int radeon_irq_kms_init(struct radeon_device *rdev)
112{ 112{
113 int i;
113 int r = 0; 114 int r = 0;
114 115
115 INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func); 116 INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func);
116 117
117 spin_lock_init(&rdev->irq.sw_lock); 118 spin_lock_init(&rdev->irq.sw_lock);
119 for (i = 0; i < rdev->num_crtc; i++)
120 spin_lock_init(&rdev->irq.pflip_lock[i]);
118 r = drm_vblank_init(rdev->ddev, rdev->num_crtc); 121 r = drm_vblank_init(rdev->ddev, rdev->num_crtc);
119 if (r) { 122 if (r) {
120 return r; 123 return r;
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index 28a53e4a925f..98321298cffd 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -201,6 +201,10 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
201 } 201 }
202 radeon_set_filp_rights(dev, &rdev->cmask_filp, filp, &value); 202 radeon_set_filp_rights(dev, &rdev->cmask_filp, filp, &value);
203 break; 203 break;
204 case RADEON_INFO_CLOCK_CRYSTAL_FREQ:
205 /* return clock value in KHz */
206 value = rdev->clock.spll.reference_freq * 10;
207 break;
204 default: 208 default:
205 DRM_DEBUG_KMS("Invalid request %d\n", info->request); 209 DRM_DEBUG_KMS("Invalid request %d\n", info->request);
206 return -EINVAL; 210 return -EINVAL;
diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c
index c380c65da417..ace2b1623b21 100644
--- a/drivers/gpu/vga/vgaarb.c
+++ b/drivers/gpu/vga/vgaarb.c
@@ -636,7 +636,7 @@ int vga_client_register(struct pci_dev *pdev, void *cookie,
636 void (*irq_set_state)(void *cookie, bool state), 636 void (*irq_set_state)(void *cookie, bool state),
637 unsigned int (*set_vga_decode)(void *cookie, bool decode)) 637 unsigned int (*set_vga_decode)(void *cookie, bool decode))
638{ 638{
639 int ret = -1; 639 int ret = -ENODEV;
640 struct vga_device *vgadev; 640 struct vga_device *vgadev;
641 unsigned long flags; 641 unsigned long flags;
642 642
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index 7acb32e7f817..1fa091e05690 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -263,7 +263,7 @@ static void __setup_broadcast_timer(void *arg)
263 clockevents_notify(reason, &cpu); 263 clockevents_notify(reason, &cpu);
264} 264}
265 265
266static int __cpuinit setup_broadcast_cpuhp_notify(struct notifier_block *n, 266static int setup_broadcast_cpuhp_notify(struct notifier_block *n,
267 unsigned long action, void *hcpu) 267 unsigned long action, void *hcpu)
268{ 268{
269 int hotcpu = (unsigned long)hcpu; 269 int hotcpu = (unsigned long)hcpu;
@@ -273,15 +273,11 @@ static int __cpuinit setup_broadcast_cpuhp_notify(struct notifier_block *n,
273 smp_call_function_single(hotcpu, __setup_broadcast_timer, 273 smp_call_function_single(hotcpu, __setup_broadcast_timer,
274 (void *)true, 1); 274 (void *)true, 1);
275 break; 275 break;
276 case CPU_DOWN_PREPARE:
277 smp_call_function_single(hotcpu, __setup_broadcast_timer,
278 (void *)false, 1);
279 break;
280 } 276 }
281 return NOTIFY_OK; 277 return NOTIFY_OK;
282} 278}
283 279
284static struct notifier_block __cpuinitdata setup_broadcast_notifier = { 280static struct notifier_block setup_broadcast_notifier = {
285 .notifier_call = setup_broadcast_cpuhp_notify, 281 .notifier_call = setup_broadcast_cpuhp_notify,
286}; 282};
287 283
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 417507348bab..c7a92028f450 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -343,6 +343,16 @@ config KEYBOARD_NOMADIK
343 To compile this driver as a module, choose M here: the 343 To compile this driver as a module, choose M here: the
344 module will be called nmk-ske-keypad. 344 module will be called nmk-ske-keypad.
345 345
346config KEYBOARD_TEGRA
347 tristate "NVIDIA Tegra internal matrix keyboard controller support"
348 depends on ARCH_TEGRA
349 help
350 Say Y here if you want to use a matrix keyboard connected directly
351 to the internal keyboard controller on Tegra SoCs.
352
353 To compile this driver as a module, choose M here: the
354 module will be called tegra-kbc.
355
346config KEYBOARD_OPENCORES 356config KEYBOARD_OPENCORES
347 tristate "OpenCores Keyboard Controller" 357 tristate "OpenCores Keyboard Controller"
348 help 358 help
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 4e5571b72cda..468c627a2844 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -42,6 +42,7 @@ obj-$(CONFIG_KEYBOARD_STMPE) += stmpe-keypad.o
42obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o 42obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o
43obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o 43obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o
44obj-$(CONFIG_KEYBOARD_TC3589X) += tc3589x-keypad.o 44obj-$(CONFIG_KEYBOARD_TC3589X) += tc3589x-keypad.o
45obj-$(CONFIG_KEYBOARD_TEGRA) += tegra-kbc.o
45obj-$(CONFIG_KEYBOARD_TNETV107X) += tnetv107x-keypad.o 46obj-$(CONFIG_KEYBOARD_TNETV107X) += tnetv107x-keypad.o
46obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o 47obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o
47obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o 48obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 6069abe31e42..eb3006361ee4 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -322,7 +322,7 @@ static void gpio_keys_report_event(struct gpio_button_data *bdata)
322 struct gpio_keys_button *button = bdata->button; 322 struct gpio_keys_button *button = bdata->button;
323 struct input_dev *input = bdata->input; 323 struct input_dev *input = bdata->input;
324 unsigned int type = button->type ?: EV_KEY; 324 unsigned int type = button->type ?: EV_KEY;
325 int state = (gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low; 325 int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low;
326 326
327 input_event(input, type, button->code, !!state); 327 input_event(input, type, button->code, !!state);
328 input_sync(input); 328 input_sync(input);
@@ -410,8 +410,8 @@ static int __devinit gpio_keys_setup_key(struct platform_device *pdev,
410 if (!button->can_disable) 410 if (!button->can_disable)
411 irqflags |= IRQF_SHARED; 411 irqflags |= IRQF_SHARED;
412 412
413 error = request_irq(irq, gpio_keys_isr, irqflags, desc, bdata); 413 error = request_any_context_irq(irq, gpio_keys_isr, irqflags, desc, bdata);
414 if (error) { 414 if (error < 0) {
415 dev_err(dev, "Unable to claim irq %d; error %d\n", 415 dev_err(dev, "Unable to claim irq %d; error %d\n",
416 irq, error); 416 irq, error);
417 goto fail3; 417 goto fail3;
diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c
new file mode 100644
index 000000000000..939476659ad6
--- /dev/null
+++ b/drivers/input/keyboard/tegra-kbc.c
@@ -0,0 +1,727 @@
1/*
2 * Keyboard class input driver for the NVIDIA Tegra SoC internal matrix
3 * keyboard controller
4 *
5 * Copyright (c) 2009-2011, NVIDIA Corporation.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21
22#include <linux/module.h>
23#include <linux/input.h>
24#include <linux/platform_device.h>
25#include <linux/delay.h>
26#include <linux/io.h>
27#include <linux/interrupt.h>
28#include <linux/clk.h>
29#include <linux/slab.h>
30#include <mach/clk.h>
31#include <mach/kbc.h>
32
33#define KBC_MAX_DEBOUNCE_CNT 0x3ffu
34
35/* KBC row scan time and delay for beginning the row scan. */
36#define KBC_ROW_SCAN_TIME 16
37#define KBC_ROW_SCAN_DLY 5
38
39/* KBC uses a 32KHz clock so a cycle = 1/32Khz */
40#define KBC_CYCLE_USEC 32
41
42/* KBC Registers */
43
44/* KBC Control Register */
45#define KBC_CONTROL_0 0x0
46#define KBC_FIFO_TH_CNT_SHIFT(cnt) (cnt << 14)
47#define KBC_DEBOUNCE_CNT_SHIFT(cnt) (cnt << 4)
48#define KBC_CONTROL_FIFO_CNT_INT_EN (1 << 3)
49#define KBC_CONTROL_KBC_EN (1 << 0)
50
51/* KBC Interrupt Register */
52#define KBC_INT_0 0x4
53#define KBC_INT_FIFO_CNT_INT_STATUS (1 << 2)
54
55#define KBC_ROW_CFG0_0 0x8
56#define KBC_COL_CFG0_0 0x18
57#define KBC_INIT_DLY_0 0x28
58#define KBC_RPT_DLY_0 0x2c
59#define KBC_KP_ENT0_0 0x30
60#define KBC_KP_ENT1_0 0x34
61#define KBC_ROW0_MASK_0 0x38
62
63#define KBC_ROW_SHIFT 3
64
65struct tegra_kbc {
66 void __iomem *mmio;
67 struct input_dev *idev;
68 unsigned int irq;
69 unsigned int wake_enable_rows;
70 unsigned int wake_enable_cols;
71 spinlock_t lock;
72 unsigned int repoll_dly;
73 unsigned long cp_dly_jiffies;
74 const struct tegra_kbc_platform_data *pdata;
75 unsigned short keycode[KBC_MAX_KEY];
76 unsigned short current_keys[KBC_MAX_KPENT];
77 unsigned int num_pressed_keys;
78 struct timer_list timer;
79 struct clk *clk;
80};
81
82static const u32 tegra_kbc_default_keymap[] = {
83 KEY(0, 2, KEY_W),
84 KEY(0, 3, KEY_S),
85 KEY(0, 4, KEY_A),
86 KEY(0, 5, KEY_Z),
87 KEY(0, 7, KEY_FN),
88
89 KEY(1, 7, KEY_MENU),
90
91 KEY(2, 6, KEY_RIGHTALT),
92 KEY(2, 7, KEY_LEFTALT),
93
94 KEY(3, 0, KEY_5),
95 KEY(3, 1, KEY_4),
96 KEY(3, 2, KEY_R),
97 KEY(3, 3, KEY_E),
98 KEY(3, 4, KEY_F),
99 KEY(3, 5, KEY_D),
100 KEY(3, 6, KEY_X),
101
102 KEY(4, 0, KEY_7),
103 KEY(4, 1, KEY_6),
104 KEY(4, 2, KEY_T),
105 KEY(4, 3, KEY_H),
106 KEY(4, 4, KEY_G),
107 KEY(4, 5, KEY_V),
108 KEY(4, 6, KEY_C),
109 KEY(4, 7, KEY_SPACE),
110
111 KEY(5, 0, KEY_9),
112 KEY(5, 1, KEY_8),
113 KEY(5, 2, KEY_U),
114 KEY(5, 3, KEY_Y),
115 KEY(5, 4, KEY_J),
116 KEY(5, 5, KEY_N),
117 KEY(5, 6, KEY_B),
118 KEY(5, 7, KEY_BACKSLASH),
119
120 KEY(6, 0, KEY_MINUS),
121 KEY(6, 1, KEY_0),
122 KEY(6, 2, KEY_O),
123 KEY(6, 3, KEY_I),
124 KEY(6, 4, KEY_L),
125 KEY(6, 5, KEY_K),
126 KEY(6, 6, KEY_COMMA),
127 KEY(6, 7, KEY_M),
128
129 KEY(7, 1, KEY_EQUAL),
130 KEY(7, 2, KEY_RIGHTBRACE),
131 KEY(7, 3, KEY_ENTER),
132 KEY(7, 7, KEY_MENU),
133
134 KEY(8, 4, KEY_RIGHTSHIFT),
135 KEY(8, 5, KEY_LEFTSHIFT),
136
137 KEY(9, 5, KEY_RIGHTCTRL),
138 KEY(9, 7, KEY_LEFTCTRL),
139
140 KEY(11, 0, KEY_LEFTBRACE),
141 KEY(11, 1, KEY_P),
142 KEY(11, 2, KEY_APOSTROPHE),
143 KEY(11, 3, KEY_SEMICOLON),
144 KEY(11, 4, KEY_SLASH),
145 KEY(11, 5, KEY_DOT),
146
147 KEY(12, 0, KEY_F10),
148 KEY(12, 1, KEY_F9),
149 KEY(12, 2, KEY_BACKSPACE),
150 KEY(12, 3, KEY_3),
151 KEY(12, 4, KEY_2),
152 KEY(12, 5, KEY_UP),
153 KEY(12, 6, KEY_PRINT),
154 KEY(12, 7, KEY_PAUSE),
155
156 KEY(13, 0, KEY_INSERT),
157 KEY(13, 1, KEY_DELETE),
158 KEY(13, 3, KEY_PAGEUP),
159 KEY(13, 4, KEY_PAGEDOWN),
160 KEY(13, 5, KEY_RIGHT),
161 KEY(13, 6, KEY_DOWN),
162 KEY(13, 7, KEY_LEFT),
163
164 KEY(14, 0, KEY_F11),
165 KEY(14, 1, KEY_F12),
166 KEY(14, 2, KEY_F8),
167 KEY(14, 3, KEY_Q),
168 KEY(14, 4, KEY_F4),
169 KEY(14, 5, KEY_F3),
170 KEY(14, 6, KEY_1),
171 KEY(14, 7, KEY_F7),
172
173 KEY(15, 0, KEY_ESC),
174 KEY(15, 1, KEY_GRAVE),
175 KEY(15, 2, KEY_F5),
176 KEY(15, 3, KEY_TAB),
177 KEY(15, 4, KEY_F1),
178 KEY(15, 5, KEY_F2),
179 KEY(15, 6, KEY_CAPSLOCK),
180 KEY(15, 7, KEY_F6),
181};
182
183static const struct matrix_keymap_data tegra_kbc_default_keymap_data = {
184 .keymap = tegra_kbc_default_keymap,
185 .keymap_size = ARRAY_SIZE(tegra_kbc_default_keymap),
186};
187
188static void tegra_kbc_report_released_keys(struct input_dev *input,
189 unsigned short old_keycodes[],
190 unsigned int old_num_keys,
191 unsigned short new_keycodes[],
192 unsigned int new_num_keys)
193{
194 unsigned int i, j;
195
196 for (i = 0; i < old_num_keys; i++) {
197 for (j = 0; j < new_num_keys; j++)
198 if (old_keycodes[i] == new_keycodes[j])
199 break;
200
201 if (j == new_num_keys)
202 input_report_key(input, old_keycodes[i], 0);
203 }
204}
205
206static void tegra_kbc_report_pressed_keys(struct input_dev *input,
207 unsigned char scancodes[],
208 unsigned short keycodes[],
209 unsigned int num_pressed_keys)
210{
211 unsigned int i;
212
213 for (i = 0; i < num_pressed_keys; i++) {
214 input_event(input, EV_MSC, MSC_SCAN, scancodes[i]);
215 input_report_key(input, keycodes[i], 1);
216 }
217}
218
219static void tegra_kbc_report_keys(struct tegra_kbc *kbc)
220{
221 unsigned char scancodes[KBC_MAX_KPENT];
222 unsigned short keycodes[KBC_MAX_KPENT];
223 u32 val = 0;
224 unsigned int i;
225 unsigned int num_down = 0;
226 unsigned long flags;
227
228 spin_lock_irqsave(&kbc->lock, flags);
229 for (i = 0; i < KBC_MAX_KPENT; i++) {
230 if ((i % 4) == 0)
231 val = readl(kbc->mmio + KBC_KP_ENT0_0 + i);
232
233 if (val & 0x80) {
234 unsigned int col = val & 0x07;
235 unsigned int row = (val >> 3) & 0x0f;
236 unsigned char scancode =
237 MATRIX_SCAN_CODE(row, col, KBC_ROW_SHIFT);
238
239 scancodes[num_down] = scancode;
240 keycodes[num_down++] = kbc->keycode[scancode];
241 }
242
243 val >>= 8;
244 }
245 spin_unlock_irqrestore(&kbc->lock, flags);
246
247 tegra_kbc_report_released_keys(kbc->idev,
248 kbc->current_keys, kbc->num_pressed_keys,
249 keycodes, num_down);
250 tegra_kbc_report_pressed_keys(kbc->idev, scancodes, keycodes, num_down);
251 input_sync(kbc->idev);
252
253 memcpy(kbc->current_keys, keycodes, sizeof(kbc->current_keys));
254 kbc->num_pressed_keys = num_down;
255}
256
257static void tegra_kbc_keypress_timer(unsigned long data)
258{
259 struct tegra_kbc *kbc = (struct tegra_kbc *)data;
260 unsigned long flags;
261 u32 val;
262 unsigned int i;
263
264 val = (readl(kbc->mmio + KBC_INT_0) >> 4) & 0xf;
265 if (val) {
266 unsigned long dly;
267
268 tegra_kbc_report_keys(kbc);
269
270 /*
271 * If more than one keys are pressed we need not wait
272 * for the repoll delay.
273 */
274 dly = (val == 1) ? kbc->repoll_dly : 1;
275 mod_timer(&kbc->timer, jiffies + msecs_to_jiffies(dly));
276 } else {
277 /* Release any pressed keys and exit the polling loop */
278 for (i = 0; i < kbc->num_pressed_keys; i++)
279 input_report_key(kbc->idev, kbc->current_keys[i], 0);
280 input_sync(kbc->idev);
281
282 kbc->num_pressed_keys = 0;
283
284 /* All keys are released so enable the keypress interrupt */
285 spin_lock_irqsave(&kbc->lock, flags);
286 val = readl(kbc->mmio + KBC_CONTROL_0);
287 val |= KBC_CONTROL_FIFO_CNT_INT_EN;
288 writel(val, kbc->mmio + KBC_CONTROL_0);
289 spin_unlock_irqrestore(&kbc->lock, flags);
290 }
291}
292
293static irqreturn_t tegra_kbc_isr(int irq, void *args)
294{
295 struct tegra_kbc *kbc = args;
296 u32 val, ctl;
297
298 /*
299 * Until all keys are released, defer further processing to
300 * the polling loop in tegra_kbc_keypress_timer
301 */
302 ctl = readl(kbc->mmio + KBC_CONTROL_0);
303 ctl &= ~KBC_CONTROL_FIFO_CNT_INT_EN;
304 writel(ctl, kbc->mmio + KBC_CONTROL_0);
305
306 /*
307 * Quickly bail out & reenable interrupts if the fifo threshold
308 * count interrupt wasn't the interrupt source
309 */
310 val = readl(kbc->mmio + KBC_INT_0);
311 writel(val, kbc->mmio + KBC_INT_0);
312
313 if (val & KBC_INT_FIFO_CNT_INT_STATUS) {
314 /*
315 * Schedule timer to run when hardware is in continuous
316 * polling mode.
317 */
318 mod_timer(&kbc->timer, jiffies + kbc->cp_dly_jiffies);
319 } else {
320 ctl |= KBC_CONTROL_FIFO_CNT_INT_EN;
321 writel(ctl, kbc->mmio + KBC_CONTROL_0);
322 }
323
324 return IRQ_HANDLED;
325}
326
327static void tegra_kbc_setup_wakekeys(struct tegra_kbc *kbc, bool filter)
328{
329 const struct tegra_kbc_platform_data *pdata = kbc->pdata;
330 int i;
331 unsigned int rst_val;
332
333 BUG_ON(pdata->wake_cnt > KBC_MAX_KEY);
334 rst_val = (filter && pdata->wake_cnt) ? ~0 : 0;
335
336 for (i = 0; i < KBC_MAX_ROW; i++)
337 writel(rst_val, kbc->mmio + KBC_ROW0_MASK_0 + i * 4);
338
339 if (filter) {
340 for (i = 0; i < pdata->wake_cnt; i++) {
341 u32 val, addr;
342 addr = pdata->wake_cfg[i].row * 4 + KBC_ROW0_MASK_0;
343 val = readl(kbc->mmio + addr);
344 val &= ~(1 << pdata->wake_cfg[i].col);
345 writel(val, kbc->mmio + addr);
346 }
347 }
348}
349
350static void tegra_kbc_config_pins(struct tegra_kbc *kbc)
351{
352 const struct tegra_kbc_platform_data *pdata = kbc->pdata;
353 int i;
354
355 for (i = 0; i < KBC_MAX_GPIO; i++) {
356 u32 r_shft = 5 * (i % 6);
357 u32 c_shft = 4 * (i % 8);
358 u32 r_mask = 0x1f << r_shift;
359 u32 c_mask = 0x0f << c_shift;
360 u32 r_offs = (i / 6) * 4 + KBC_ROW_CFG0_0;
361 u32 c_offs = (i / 8) * 4 + KBC_COL_CFG0_0;
362 u32 row_cfg = readl(kbc->mmio + r_offs);
363 u32 col_cfg = readl(kbc->mmio + c_offs);
364
365 row_cfg &= ~r_mask;
366 col_cfg &= ~c_mask;
367
368 if (pdata->pin_cfg[i].is_row)
369 row_cfg |= ((pdata->pin_cfg[i].num << 1) | 1) << r_shft;
370 else
371 col_cfg |= ((pdata->pin_cfg[i].num << 1) | 1) << c_shft;
372
373 writel(row_cfg, kbc->mmio + r_offs);
374 writel(col_cfg, kbc->mmio + c_offs);
375 }
376}
377
378static int tegra_kbc_start(struct tegra_kbc *kbc)
379{
380 const struct tegra_kbc_platform_data *pdata = kbc->pdata;
381 unsigned long flags;
382 unsigned int debounce_cnt;
383 u32 val = 0;
384
385 clk_enable(kbc->clk);
386
387 /* Reset the KBC controller to clear all previous status.*/
388 tegra_periph_reset_assert(kbc->clk);
389 udelay(100);
390 tegra_periph_reset_deassert(kbc->clk);
391 udelay(100);
392
393 tegra_kbc_config_pins(kbc);
394 tegra_kbc_setup_wakekeys(kbc, false);
395
396 writel(pdata->repeat_cnt, kbc->mmio + KBC_RPT_DLY_0);
397
398 /* Keyboard debounce count is maximum of 12 bits. */
399 debounce_cnt = min(pdata->debounce_cnt, KBC_MAX_DEBOUNCE_CNT);
400 val = KBC_DEBOUNCE_CNT_SHIFT(debounce_cnt);
401 val |= KBC_FIFO_TH_CNT_SHIFT(1); /* set fifo interrupt threshold to 1 */
402 val |= KBC_CONTROL_FIFO_CNT_INT_EN; /* interrupt on FIFO threshold */
403 val |= KBC_CONTROL_KBC_EN; /* enable */
404 writel(val, kbc->mmio + KBC_CONTROL_0);
405
406 /*
407 * Compute the delay(ns) from interrupt mode to continuous polling
408 * mode so the timer routine is scheduled appropriately.
409 */
410 val = readl(kbc->mmio + KBC_INIT_DLY_0);
411 kbc->cp_dly_jiffies = usecs_to_jiffies((val & 0xfffff) * 32);
412
413 kbc->num_pressed_keys = 0;
414
415 /*
416 * Atomically clear out any remaining entries in the key FIFO
417 * and enable keyboard interrupts.
418 */
419 spin_lock_irqsave(&kbc->lock, flags);
420 while (1) {
421 val = readl(kbc->mmio + KBC_INT_0);
422 val >>= 4;
423 if (!val)
424 break;
425
426 val = readl(kbc->mmio + KBC_KP_ENT0_0);
427 val = readl(kbc->mmio + KBC_KP_ENT1_0);
428 }
429 writel(0x7, kbc->mmio + KBC_INT_0);
430 spin_unlock_irqrestore(&kbc->lock, flags);
431
432 enable_irq(kbc->irq);
433
434 return 0;
435}
436
437static void tegra_kbc_stop(struct tegra_kbc *kbc)
438{
439 unsigned long flags;
440 u32 val;
441
442 spin_lock_irqsave(&kbc->lock, flags);
443 val = readl(kbc->mmio + KBC_CONTROL_0);
444 val &= ~1;
445 writel(val, kbc->mmio + KBC_CONTROL_0);
446 spin_unlock_irqrestore(&kbc->lock, flags);
447
448 disable_irq(kbc->irq);
449 del_timer_sync(&kbc->timer);
450
451 clk_disable(kbc->clk);
452}
453
454static int tegra_kbc_open(struct input_dev *dev)
455{
456 struct tegra_kbc *kbc = input_get_drvdata(dev);
457
458 return tegra_kbc_start(kbc);
459}
460
461static void tegra_kbc_close(struct input_dev *dev)
462{
463 struct tegra_kbc *kbc = input_get_drvdata(dev);
464
465 return tegra_kbc_stop(kbc);
466}
467
468static bool __devinit
469tegra_kbc_check_pin_cfg(const struct tegra_kbc_platform_data *pdata,
470 struct device *dev, unsigned int *num_rows)
471{
472 int i;
473
474 *num_rows = 0;
475
476 for (i = 0; i < KBC_MAX_GPIO; i++) {
477 const struct tegra_kbc_pin_cfg *pin_cfg = &pdata->pin_cfg[i];
478
479 if (pin_cfg->is_row) {
480 if (pin_cfg->num >= KBC_MAX_ROW) {
481 dev_err(dev,
482 "pin_cfg[%d]: invalid row number %d\n",
483 i, pin_cfg->num);
484 return false;
485 }
486 (*num_rows)++;
487 } else {
488 if (pin_cfg->num >= KBC_MAX_COL) {
489 dev_err(dev,
490 "pin_cfg[%d]: invalid column number %d\n",
491 i, pin_cfg->num);
492 return false;
493 }
494 }
495 }
496
497 return true;
498}
499
500static int __devinit tegra_kbc_probe(struct platform_device *pdev)
501{
502 const struct tegra_kbc_platform_data *pdata = pdev->dev.platform_data;
503 const struct matrix_keymap_data *keymap_data;
504 struct tegra_kbc *kbc;
505 struct input_dev *input_dev;
506 struct resource *res;
507 int irq;
508 int err;
509 int i;
510 int num_rows = 0;
511 unsigned int debounce_cnt;
512 unsigned int scan_time_rows;
513
514 if (!pdata)
515 return -EINVAL;
516
517 if (!tegra_kbc_check_pin_cfg(pdata, &pdev->dev, &num_rows))
518 return -EINVAL;
519
520 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
521 if (!res) {
522 dev_err(&pdev->dev, "failed to get I/O memory\n");
523 return -ENXIO;
524 }
525
526 irq = platform_get_irq(pdev, 0);
527 if (irq < 0) {
528 dev_err(&pdev->dev, "failed to get keyboard IRQ\n");
529 return -ENXIO;
530 }
531
532 kbc = kzalloc(sizeof(*kbc), GFP_KERNEL);
533 input_dev = input_allocate_device();
534 if (!kbc || !input_dev) {
535 err = -ENOMEM;
536 goto err_free_mem;
537 }
538
539 kbc->pdata = pdata;
540 kbc->idev = input_dev;
541 kbc->irq = irq;
542 spin_lock_init(&kbc->lock);
543 setup_timer(&kbc->timer, tegra_kbc_keypress_timer, (unsigned long)kbc);
544
545 res = request_mem_region(res->start, resource_size(res), pdev->name);
546 if (!res) {
547 dev_err(&pdev->dev, "failed to request I/O memory\n");
548 err = -EBUSY;
549 goto err_free_mem;
550 }
551
552 kbc->mmio = ioremap(res->start, resource_size(res));
553 if (!kbc->mmio) {
554 dev_err(&pdev->dev, "failed to remap I/O memory\n");
555 err = -ENXIO;
556 goto err_free_mem_region;
557 }
558
559 kbc->clk = clk_get(&pdev->dev, NULL);
560 if (IS_ERR(kbc->clk)) {
561 dev_err(&pdev->dev, "failed to get keyboard clock\n");
562 err = PTR_ERR(kbc->clk);
563 goto err_iounmap;
564 }
565
566 kbc->wake_enable_rows = 0;
567 kbc->wake_enable_cols = 0;
568 for (i = 0; i < pdata->wake_cnt; i++) {
569 kbc->wake_enable_rows |= (1 << pdata->wake_cfg[i].row);
570 kbc->wake_enable_cols |= (1 << pdata->wake_cfg[i].col);
571 }
572
573 /*
574 * The time delay between two consecutive reads of the FIFO is
575 * the sum of the repeat time and the time taken for scanning
576 * the rows. There is an additional delay before the row scanning
577 * starts. The repoll delay is computed in milliseconds.
578 */
579 debounce_cnt = min(pdata->debounce_cnt, KBC_MAX_DEBOUNCE_CNT);
580 scan_time_rows = (KBC_ROW_SCAN_TIME + debounce_cnt) * num_rows;
581 kbc->repoll_dly = KBC_ROW_SCAN_DLY + scan_time_rows + pdata->repeat_cnt;
582 kbc->repoll_dly = ((kbc->repoll_dly * KBC_CYCLE_USEC) + 999) / 1000;
583
584 input_dev->name = pdev->name;
585 input_dev->id.bustype = BUS_HOST;
586 input_dev->dev.parent = &pdev->dev;
587 input_dev->open = tegra_kbc_open;
588 input_dev->close = tegra_kbc_close;
589
590 input_set_drvdata(input_dev, kbc);
591
592 input_dev->evbit[0] = BIT_MASK(EV_KEY);
593 input_set_capability(input_dev, EV_MSC, MSC_SCAN);
594
595 input_dev->keycode = kbc->keycode;
596 input_dev->keycodesize = sizeof(kbc->keycode[0]);
597 input_dev->keycodemax = ARRAY_SIZE(kbc->keycode);
598
599 keymap_data = pdata->keymap_data ?: &tegra_kbc_default_keymap_data;
600 matrix_keypad_build_keymap(keymap_data, KBC_ROW_SHIFT,
601 input_dev->keycode, input_dev->keybit);
602
603 err = request_irq(kbc->irq, tegra_kbc_isr, IRQF_TRIGGER_HIGH,
604 pdev->name, kbc);
605 if (err) {
606 dev_err(&pdev->dev, "failed to request keyboard IRQ\n");
607 goto err_put_clk;
608 }
609
610 disable_irq(kbc->irq);
611
612 err = input_register_device(kbc->idev);
613 if (err) {
614 dev_err(&pdev->dev, "failed to register input device\n");
615 goto err_free_irq;
616 }
617
618 platform_set_drvdata(pdev, kbc);
619 device_init_wakeup(&pdev->dev, pdata->wakeup);
620
621 return 0;
622
623err_free_irq:
624 free_irq(kbc->irq, pdev);
625err_put_clk:
626 clk_put(kbc->clk);
627err_iounmap:
628 iounmap(kbc->mmio);
629err_free_mem_region:
630 release_mem_region(res->start, resource_size(res));
631err_free_mem:
632 input_free_device(kbc->idev);
633 kfree(kbc);
634
635 return err;
636}
637
638static int __devexit tegra_kbc_remove(struct platform_device *pdev)
639{
640 struct tegra_kbc *kbc = platform_get_drvdata(pdev);
641 struct resource *res;
642
643 free_irq(kbc->irq, pdev);
644 clk_put(kbc->clk);
645
646 input_unregister_device(kbc->idev);
647 iounmap(kbc->mmio);
648 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
649 release_mem_region(res->start, resource_size(res));
650
651 kfree(kbc);
652
653 platform_set_drvdata(pdev, NULL);
654
655 return 0;
656}
657
658#ifdef CONFIG_PM_SLEEP
659static int tegra_kbc_suspend(struct device *dev)
660{
661 struct platform_device *pdev = to_platform_device(dev);
662 struct tegra_kbc *kbc = platform_get_drvdata(pdev);
663
664 if (device_may_wakeup(&pdev->dev)) {
665 tegra_kbc_setup_wakekeys(kbc, true);
666 enable_irq_wake(kbc->irq);
667 /* Forcefully clear the interrupt status */
668 writel(0x7, kbc->mmio + KBC_INT_0);
669 msleep(30);
670 } else {
671 mutex_lock(&kbc->idev->mutex);
672 if (kbc->idev->users)
673 tegra_kbc_stop(kbc);
674 mutex_unlock(&kbc->idev->mutex);
675 }
676
677 return 0;
678}
679
680static int tegra_kbc_resume(struct device *dev)
681{
682 struct platform_device *pdev = to_platform_device(dev);
683 struct tegra_kbc *kbc = platform_get_drvdata(pdev);
684 int err = 0;
685
686 if (device_may_wakeup(&pdev->dev)) {
687 disable_irq_wake(kbc->irq);
688 tegra_kbc_setup_wakekeys(kbc, false);
689 } else {
690 mutex_lock(&kbc->idev->mutex);
691 if (kbc->idev->users)
692 err = tegra_kbc_start(kbc);
693 mutex_unlock(&kbc->idev->mutex);
694 }
695
696 return err;
697}
698#endif
699
700static SIMPLE_DEV_PM_OPS(tegra_kbc_pm_ops, tegra_kbc_suspend, tegra_kbc_resume);
701
702static struct platform_driver tegra_kbc_driver = {
703 .probe = tegra_kbc_probe,
704 .remove = __devexit_p(tegra_kbc_remove),
705 .driver = {
706 .name = "tegra-kbc",
707 .owner = THIS_MODULE,
708 .pm = &tegra_kbc_pm_ops,
709 },
710};
711
712static void __exit tegra_kbc_exit(void)
713{
714 platform_driver_unregister(&tegra_kbc_driver);
715}
716module_exit(tegra_kbc_exit);
717
718static int __init tegra_kbc_init(void)
719{
720 return platform_driver_register(&tegra_kbc_driver);
721}
722module_init(tegra_kbc_init);
723
724MODULE_LICENSE("GPL");
725MODULE_AUTHOR("Rakesh Iyer <riyer@nvidia.com>");
726MODULE_DESCRIPTION("Tegra matrix keyboard controller driver");
727MODULE_ALIAS("platform:tegra-kbc");
diff --git a/drivers/input/keyboard/tnetv107x-keypad.c b/drivers/input/keyboard/tnetv107x-keypad.c
index b4a81ebfab92..c8f097a15d89 100644
--- a/drivers/input/keyboard/tnetv107x-keypad.c
+++ b/drivers/input/keyboard/tnetv107x-keypad.c
@@ -14,6 +14,7 @@
14 */ 14 */
15 15
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/err.h>
17#include <linux/errno.h> 18#include <linux/errno.h>
18#include <linux/input.h> 19#include <linux/input.h>
19#include <linux/platform_device.h> 20#include <linux/platform_device.h>
@@ -219,9 +220,9 @@ static int __devinit keypad_probe(struct platform_device *pdev)
219 } 220 }
220 221
221 kp->clk = clk_get(dev, NULL); 222 kp->clk = clk_get(dev, NULL);
222 if (!kp->clk) { 223 if (IS_ERR(kp->clk)) {
223 dev_err(dev, "cannot claim device clock\n"); 224 dev_err(dev, "cannot claim device clock\n");
224 error = -EINVAL; 225 error = PTR_ERR(kp->clk);
225 goto error_clk; 226 goto error_clk;
226 } 227 }
227 228
diff --git a/drivers/input/serio/ct82c710.c b/drivers/input/serio/ct82c710.c
index 448c7724beb9..852816567241 100644
--- a/drivers/input/serio/ct82c710.c
+++ b/drivers/input/serio/ct82c710.c
@@ -111,9 +111,11 @@ static void ct82c710_close(struct serio *serio)
111static int ct82c710_open(struct serio *serio) 111static int ct82c710_open(struct serio *serio)
112{ 112{
113 unsigned char status; 113 unsigned char status;
114 int err;
114 115
115 if (request_irq(CT82C710_IRQ, ct82c710_interrupt, 0, "ct82c710", NULL)) 116 err = request_irq(CT82C710_IRQ, ct82c710_interrupt, 0, "ct82c710", NULL);
116 return -1; 117 if (err)
118 return err;
117 119
118 status = inb_p(CT82C710_STATUS); 120 status = inb_p(CT82C710_STATUS);
119 121
@@ -131,7 +133,7 @@ static int ct82c710_open(struct serio *serio)
131 status &= ~(CT82C710_ENABLE | CT82C710_INTS_ON); 133 status &= ~(CT82C710_ENABLE | CT82C710_INTS_ON);
132 outb_p(status, CT82C710_STATUS); 134 outb_p(status, CT82C710_STATUS);
133 free_irq(CT82C710_IRQ, NULL); 135 free_irq(CT82C710_IRQ, NULL);
134 return -1; 136 return -EBUSY;
135 } 137 }
136 138
137 return 0; 139 return 0;
diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
index 6e362de3f412..8755f5f3ad37 100644
--- a/drivers/input/serio/serport.c
+++ b/drivers/input/serio/serport.c
@@ -116,14 +116,15 @@ static void serport_ldisc_close(struct tty_struct *tty)
116 116
117/* 117/*
118 * serport_ldisc_receive() is called by the low level tty driver when characters 118 * serport_ldisc_receive() is called by the low level tty driver when characters
119 * are ready for us. We forward the characters, one by one to the 'interrupt' 119 * are ready for us. We forward the characters and flags, one by one to the
120 * routine. 120 * 'interrupt' routine.
121 */ 121 */
122 122
123static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *cp, char *fp, int count) 123static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *cp, char *fp, int count)
124{ 124{
125 struct serport *serport = (struct serport*) tty->disc_data; 125 struct serport *serport = (struct serport*) tty->disc_data;
126 unsigned long flags; 126 unsigned long flags;
127 unsigned int ch_flags;
127 int i; 128 int i;
128 129
129 spin_lock_irqsave(&serport->lock, flags); 130 spin_lock_irqsave(&serport->lock, flags);
@@ -131,8 +132,23 @@ static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *c
131 if (!test_bit(SERPORT_ACTIVE, &serport->flags)) 132 if (!test_bit(SERPORT_ACTIVE, &serport->flags))
132 goto out; 133 goto out;
133 134
134 for (i = 0; i < count; i++) 135 for (i = 0; i < count; i++) {
135 serio_interrupt(serport->serio, cp[i], 0); 136 switch (fp[i]) {
137 case TTY_FRAME:
138 ch_flags = SERIO_FRAME;
139 break;
140
141 case TTY_PARITY:
142 ch_flags = SERIO_PARITY;
143 break;
144
145 default:
146 ch_flags = 0;
147 break;
148 }
149
150 serio_interrupt(serport->serio, cp[i], ch_flags);
151 }
136 152
137out: 153out:
138 spin_unlock_irqrestore(&serport->lock, flags); 154 spin_unlock_irqrestore(&serport->lock, flags);
diff --git a/drivers/input/sparse-keymap.c b/drivers/input/sparse-keymap.c
index a29a7812bd46..7729e547ba65 100644
--- a/drivers/input/sparse-keymap.c
+++ b/drivers/input/sparse-keymap.c
@@ -201,6 +201,7 @@ int sparse_keymap_setup(struct input_dev *dev,
201 break; 201 break;
202 202
203 case KE_SW: 203 case KE_SW:
204 case KE_VSW:
204 __set_bit(EV_SW, dev->evbit); 205 __set_bit(EV_SW, dev->evbit);
205 __set_bit(entry->sw.code, dev->swbit); 206 __set_bit(entry->sw.code, dev->swbit);
206 break; 207 break;
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index 518782999fea..367fa82a607e 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -1101,6 +1101,13 @@ void wacom_setup_device_quirks(struct wacom_features *features)
1101 } 1101 }
1102} 1102}
1103 1103
1104static unsigned int wacom_calculate_touch_res(unsigned int logical_max,
1105 unsigned int physical_max)
1106{
1107 /* Touch physical dimensions are in 100th of mm */
1108 return (logical_max * 100) / physical_max;
1109}
1110
1104void wacom_setup_input_capabilities(struct input_dev *input_dev, 1111void wacom_setup_input_capabilities(struct input_dev *input_dev,
1105 struct wacom_wac *wacom_wac) 1112 struct wacom_wac *wacom_wac)
1106{ 1113{
@@ -1228,8 +1235,12 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev,
1228 case TABLETPC: 1235 case TABLETPC:
1229 if (features->device_type == BTN_TOOL_DOUBLETAP || 1236 if (features->device_type == BTN_TOOL_DOUBLETAP ||
1230 features->device_type == BTN_TOOL_TRIPLETAP) { 1237 features->device_type == BTN_TOOL_TRIPLETAP) {
1231 input_set_abs_params(input_dev, ABS_RX, 0, features->x_phy, 0, 0); 1238 input_abs_set_res(input_dev, ABS_X,
1232 input_set_abs_params(input_dev, ABS_RY, 0, features->y_phy, 0, 0); 1239 wacom_calculate_touch_res(features->x_max,
1240 features->x_phy));
1241 input_abs_set_res(input_dev, ABS_Y,
1242 wacom_calculate_touch_res(features->y_max,
1243 features->y_phy));
1233 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); 1244 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
1234 } 1245 }
1235 1246
@@ -1272,6 +1283,12 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev,
1272 input_set_abs_params(input_dev, ABS_MT_PRESSURE, 1283 input_set_abs_params(input_dev, ABS_MT_PRESSURE,
1273 0, features->pressure_max, 1284 0, features->pressure_max,
1274 features->pressure_fuzz, 0); 1285 features->pressure_fuzz, 0);
1286 input_abs_set_res(input_dev, ABS_X,
1287 wacom_calculate_touch_res(features->x_max,
1288 features->x_phy));
1289 input_abs_set_res(input_dev, ABS_Y,
1290 wacom_calculate_touch_res(features->y_max,
1291 features->y_phy));
1275 } else if (features->device_type == BTN_TOOL_PEN) { 1292 } else if (features->device_type == BTN_TOOL_PEN) {
1276 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); 1293 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1277 __set_bit(BTN_TOOL_PEN, input_dev->keybit); 1294 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
@@ -1426,6 +1443,10 @@ static struct wacom_features wacom_features_0xD3 =
1426 { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT }; 1443 { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT };
1427static const struct wacom_features wacom_features_0xD4 = 1444static const struct wacom_features wacom_features_0xD4 =
1428 { "Wacom Bamboo Pen", WACOM_PKGLEN_BBFUN, 14720, 9200, 255, 63, BAMBOO_PT }; 1445 { "Wacom Bamboo Pen", WACOM_PKGLEN_BBFUN, 14720, 9200, 255, 63, BAMBOO_PT };
1446static struct wacom_features wacom_features_0xD6 =
1447 { "Wacom BambooPT 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT };
1448static struct wacom_features wacom_features_0xD7 =
1449 { "Wacom BambooPT 2FG Small", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT };
1429static struct wacom_features wacom_features_0xD8 = 1450static struct wacom_features wacom_features_0xD8 =
1430 { "Wacom Bamboo Comic 2FG", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT }; 1451 { "Wacom Bamboo Comic 2FG", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT };
1431static struct wacom_features wacom_features_0xDA = 1452static struct wacom_features wacom_features_0xDA =
@@ -1507,6 +1528,8 @@ const struct usb_device_id wacom_ids[] = {
1507 { USB_DEVICE_WACOM(0xD2) }, 1528 { USB_DEVICE_WACOM(0xD2) },
1508 { USB_DEVICE_WACOM(0xD3) }, 1529 { USB_DEVICE_WACOM(0xD3) },
1509 { USB_DEVICE_WACOM(0xD4) }, 1530 { USB_DEVICE_WACOM(0xD4) },
1531 { USB_DEVICE_WACOM(0xD6) },
1532 { USB_DEVICE_WACOM(0xD7) },
1510 { USB_DEVICE_WACOM(0xD8) }, 1533 { USB_DEVICE_WACOM(0xD8) },
1511 { USB_DEVICE_WACOM(0xDA) }, 1534 { USB_DEVICE_WACOM(0xDA) },
1512 { USB_DEVICE_WACOM(0xDB) }, 1535 { USB_DEVICE_WACOM(0xDB) },
diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
index f7fa9ef4cd65..1507ce108d5b 100644
--- a/drivers/input/touchscreen/bu21013_ts.c
+++ b/drivers/input/touchscreen/bu21013_ts.c
@@ -12,6 +12,7 @@
12#include <linux/input.h> 12#include <linux/input.h>
13#include <linux/input/bu21013.h> 13#include <linux/input/bu21013.h>
14#include <linux/slab.h> 14#include <linux/slab.h>
15#include <linux/regulator/consumer.h>
15 16
16#define PEN_DOWN_INTR 0 17#define PEN_DOWN_INTR 0
17#define MAX_FINGERS 2 18#define MAX_FINGERS 2
@@ -139,6 +140,7 @@
139 * @chip: pointer to the touch panel controller 140 * @chip: pointer to the touch panel controller
140 * @in_dev: pointer to the input device structure 141 * @in_dev: pointer to the input device structure
141 * @intr_pin: interrupt pin value 142 * @intr_pin: interrupt pin value
143 * @regulator: pointer to the Regulator used for touch screen
142 * 144 *
143 * Touch panel device data structure 145 * Touch panel device data structure
144 */ 146 */
@@ -149,6 +151,7 @@ struct bu21013_ts_data {
149 const struct bu21013_platform_device *chip; 151 const struct bu21013_platform_device *chip;
150 struct input_dev *in_dev; 152 struct input_dev *in_dev;
151 unsigned int intr_pin; 153 unsigned int intr_pin;
154 struct regulator *regulator;
152}; 155};
153 156
154/** 157/**
@@ -456,6 +459,20 @@ static int __devinit bu21013_probe(struct i2c_client *client,
456 bu21013_data->in_dev = in_dev; 459 bu21013_data->in_dev = in_dev;
457 bu21013_data->chip = pdata; 460 bu21013_data->chip = pdata;
458 bu21013_data->client = client; 461 bu21013_data->client = client;
462
463 bu21013_data->regulator = regulator_get(&client->dev, "V-TOUCH");
464 if (IS_ERR(bu21013_data->regulator)) {
465 dev_err(&client->dev, "regulator_get failed\n");
466 error = PTR_ERR(bu21013_data->regulator);
467 goto err_free_mem;
468 }
469
470 error = regulator_enable(bu21013_data->regulator);
471 if (error < 0) {
472 dev_err(&client->dev, "regulator enable failed\n");
473 goto err_put_regulator;
474 }
475
459 bu21013_data->touch_stopped = false; 476 bu21013_data->touch_stopped = false;
460 init_waitqueue_head(&bu21013_data->wait); 477 init_waitqueue_head(&bu21013_data->wait);
461 478
@@ -464,7 +481,7 @@ static int __devinit bu21013_probe(struct i2c_client *client,
464 error = pdata->cs_en(pdata->cs_pin); 481 error = pdata->cs_en(pdata->cs_pin);
465 if (error < 0) { 482 if (error < 0) {
466 dev_err(&client->dev, "chip init failed\n"); 483 dev_err(&client->dev, "chip init failed\n");
467 goto err_free_mem; 484 goto err_disable_regulator;
468 } 485 }
469 } 486 }
470 487
@@ -485,9 +502,9 @@ static int __devinit bu21013_probe(struct i2c_client *client,
485 __set_bit(EV_ABS, in_dev->evbit); 502 __set_bit(EV_ABS, in_dev->evbit);
486 503
487 input_set_abs_params(in_dev, ABS_MT_POSITION_X, 0, 504 input_set_abs_params(in_dev, ABS_MT_POSITION_X, 0,
488 pdata->x_max_res, 0, 0); 505 pdata->touch_x_max, 0, 0);
489 input_set_abs_params(in_dev, ABS_MT_POSITION_Y, 0, 506 input_set_abs_params(in_dev, ABS_MT_POSITION_Y, 0,
490 pdata->y_max_res, 0, 0); 507 pdata->touch_y_max, 0, 0);
491 input_set_drvdata(in_dev, bu21013_data); 508 input_set_drvdata(in_dev, bu21013_data);
492 509
493 error = request_threaded_irq(pdata->irq, NULL, bu21013_gpio_irq, 510 error = request_threaded_irq(pdata->irq, NULL, bu21013_gpio_irq,
@@ -513,6 +530,10 @@ err_free_irq:
513 bu21013_free_irq(bu21013_data); 530 bu21013_free_irq(bu21013_data);
514err_cs_disable: 531err_cs_disable:
515 pdata->cs_dis(pdata->cs_pin); 532 pdata->cs_dis(pdata->cs_pin);
533err_disable_regulator:
534 regulator_disable(bu21013_data->regulator);
535err_put_regulator:
536 regulator_put(bu21013_data->regulator);
516err_free_mem: 537err_free_mem:
517 input_free_device(in_dev); 538 input_free_device(in_dev);
518 kfree(bu21013_data); 539 kfree(bu21013_data);
@@ -535,6 +556,10 @@ static int __devexit bu21013_remove(struct i2c_client *client)
535 bu21013_data->chip->cs_dis(bu21013_data->chip->cs_pin); 556 bu21013_data->chip->cs_dis(bu21013_data->chip->cs_pin);
536 557
537 input_unregister_device(bu21013_data->in_dev); 558 input_unregister_device(bu21013_data->in_dev);
559
560 regulator_disable(bu21013_data->regulator);
561 regulator_put(bu21013_data->regulator);
562
538 kfree(bu21013_data); 563 kfree(bu21013_data);
539 564
540 device_init_wakeup(&client->dev, false); 565 device_init_wakeup(&client->dev, false);
@@ -561,6 +586,8 @@ static int bu21013_suspend(struct device *dev)
561 else 586 else
562 disable_irq(bu21013_data->chip->irq); 587 disable_irq(bu21013_data->chip->irq);
563 588
589 regulator_disable(bu21013_data->regulator);
590
564 return 0; 591 return 0;
565} 592}
566 593
@@ -577,6 +604,12 @@ static int bu21013_resume(struct device *dev)
577 struct i2c_client *client = bu21013_data->client; 604 struct i2c_client *client = bu21013_data->client;
578 int retval; 605 int retval;
579 606
607 retval = regulator_enable(bu21013_data->regulator);
608 if (retval < 0) {
609 dev_err(&client->dev, "bu21013 regulator enable failed\n");
610 return retval;
611 }
612
580 retval = bu21013_init_chip(bu21013_data); 613 retval = bu21013_init_chip(bu21013_data);
581 if (retval < 0) { 614 if (retval < 0) {
582 dev_err(&client->dev, "bu21013 controller config failed\n"); 615 dev_err(&client->dev, "bu21013 controller config failed\n");
diff --git a/drivers/input/touchscreen/tnetv107x-ts.c b/drivers/input/touchscreen/tnetv107x-ts.c
index cf1dba2e267c..22a3411e93c5 100644
--- a/drivers/input/touchscreen/tnetv107x-ts.c
+++ b/drivers/input/touchscreen/tnetv107x-ts.c
@@ -14,6 +14,7 @@
14 */ 14 */
15 15
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/err.h>
17#include <linux/errno.h> 18#include <linux/errno.h>
18#include <linux/input.h> 19#include <linux/input.h>
19#include <linux/platform_device.h> 20#include <linux/platform_device.h>
@@ -289,9 +290,9 @@ static int __devinit tsc_probe(struct platform_device *pdev)
289 } 290 }
290 291
291 ts->clk = clk_get(dev, NULL); 292 ts->clk = clk_get(dev, NULL);
292 if (!ts->clk) { 293 if (IS_ERR(ts->clk)) {
293 dev_err(dev, "cannot claim device clock\n"); 294 dev_err(dev, "cannot claim device clock\n");
294 error = -EINVAL; 295 error = PTR_ERR(ts->clk);
295 goto error_clk; 296 goto error_clk;
296 } 297 }
297 298
diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index da3fa8dcdf5b..666daf77872e 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -69,6 +69,7 @@ static int led_pwm_probe(struct platform_device *pdev)
69 led_dat->pwm = pwm_request(cur_led->pwm_id, 69 led_dat->pwm = pwm_request(cur_led->pwm_id,
70 cur_led->name); 70 cur_led->name);
71 if (IS_ERR(led_dat->pwm)) { 71 if (IS_ERR(led_dat->pwm)) {
72 ret = PTR_ERR(led_dat->pwm);
72 dev_err(&pdev->dev, "unable to request PWM %d\n", 73 dev_err(&pdev->dev, "unable to request PWM %d\n",
73 cur_led->pwm_id); 74 cur_led->pwm_id);
74 goto err; 75 goto err;
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 563022825667..2de12fe155da 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -46,10 +46,6 @@ static unsigned int fmax = 515633;
46 * is asserted (likewise for RX) 46 * is asserted (likewise for RX)
47 * @fifohalfsize: number of bytes that can be written when MCI_TXFIFOHALFEMPTY 47 * @fifohalfsize: number of bytes that can be written when MCI_TXFIFOHALFEMPTY
48 * is asserted (likewise for RX) 48 * is asserted (likewise for RX)
49 * @broken_blockend: the MCI_DATABLOCKEND is broken on the hardware
50 * and will not work at all.
51 * @broken_blockend_dma: the MCI_DATABLOCKEND is broken on the hardware when
52 * using DMA.
53 * @sdio: variant supports SDIO 49 * @sdio: variant supports SDIO
54 * @st_clkdiv: true if using a ST-specific clock divider algorithm 50 * @st_clkdiv: true if using a ST-specific clock divider algorithm
55 */ 51 */
@@ -59,8 +55,6 @@ struct variant_data {
59 unsigned int datalength_bits; 55 unsigned int datalength_bits;
60 unsigned int fifosize; 56 unsigned int fifosize;
61 unsigned int fifohalfsize; 57 unsigned int fifohalfsize;
62 bool broken_blockend;
63 bool broken_blockend_dma;
64 bool sdio; 58 bool sdio;
65 bool st_clkdiv; 59 bool st_clkdiv;
66}; 60};
@@ -76,7 +70,6 @@ static struct variant_data variant_u300 = {
76 .fifohalfsize = 8 * 4, 70 .fifohalfsize = 8 * 4,
77 .clkreg_enable = 1 << 13, /* HWFCEN */ 71 .clkreg_enable = 1 << 13, /* HWFCEN */
78 .datalength_bits = 16, 72 .datalength_bits = 16,
79 .broken_blockend_dma = true,
80 .sdio = true, 73 .sdio = true,
81}; 74};
82 75
@@ -86,7 +79,6 @@ static struct variant_data variant_ux500 = {
86 .clkreg = MCI_CLK_ENABLE, 79 .clkreg = MCI_CLK_ENABLE,
87 .clkreg_enable = 1 << 14, /* HWFCEN */ 80 .clkreg_enable = 1 << 14, /* HWFCEN */
88 .datalength_bits = 24, 81 .datalength_bits = 24,
89 .broken_blockend = true,
90 .sdio = true, 82 .sdio = true,
91 .st_clkdiv = true, 83 .st_clkdiv = true,
92}; 84};
@@ -210,8 +202,6 @@ static void mmci_start_data(struct mmci_host *host, struct mmc_data *data)
210 host->data = data; 202 host->data = data;
211 host->size = data->blksz * data->blocks; 203 host->size = data->blksz * data->blocks;
212 host->data_xfered = 0; 204 host->data_xfered = 0;
213 host->blockend = false;
214 host->dataend = false;
215 205
216 mmci_init_sg(host, data); 206 mmci_init_sg(host, data);
217 207
@@ -288,21 +278,26 @@ static void
288mmci_data_irq(struct mmci_host *host, struct mmc_data *data, 278mmci_data_irq(struct mmci_host *host, struct mmc_data *data,
289 unsigned int status) 279 unsigned int status)
290{ 280{
291 struct variant_data *variant = host->variant;
292
293 /* First check for errors */ 281 /* First check for errors */
294 if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_TXUNDERRUN|MCI_RXOVERRUN)) { 282 if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_TXUNDERRUN|MCI_RXOVERRUN)) {
283 u32 remain, success;
284
285 /* Calculate how far we are into the transfer */
286 remain = readl(host->base + MMCIDATACNT) << 2;
287 success = data->blksz * data->blocks - remain;
288
295 dev_dbg(mmc_dev(host->mmc), "MCI ERROR IRQ (status %08x)\n", status); 289 dev_dbg(mmc_dev(host->mmc), "MCI ERROR IRQ (status %08x)\n", status);
296 if (status & MCI_DATACRCFAIL) 290 if (status & MCI_DATACRCFAIL) {
291 /* Last block was not successful */
292 host->data_xfered = ((success / data->blksz) - 1 * data->blksz);
297 data->error = -EILSEQ; 293 data->error = -EILSEQ;
298 else if (status & MCI_DATATIMEOUT) 294 } else if (status & MCI_DATATIMEOUT) {
295 host->data_xfered = success;
299 data->error = -ETIMEDOUT; 296 data->error = -ETIMEDOUT;
300 else if (status & (MCI_TXUNDERRUN|MCI_RXOVERRUN)) 297 } else if (status & (MCI_TXUNDERRUN|MCI_RXOVERRUN)) {
298 host->data_xfered = success;
301 data->error = -EIO; 299 data->error = -EIO;
302 300 }
303 /* Force-complete the transaction */
304 host->blockend = true;
305 host->dataend = true;
306 301
307 /* 302 /*
308 * We hit an error condition. Ensure that any data 303 * We hit an error condition. Ensure that any data
@@ -321,61 +316,14 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data,
321 } 316 }
322 } 317 }
323 318
324 /* 319 if (status & MCI_DATABLOCKEND)
325 * On ARM variants in PIO mode, MCI_DATABLOCKEND 320 dev_err(mmc_dev(host->mmc), "stray MCI_DATABLOCKEND interrupt\n");
326 * is always sent first, and we increase the
327 * transfered number of bytes for that IRQ. Then
328 * MCI_DATAEND follows and we conclude the transaction.
329 *
330 * On the Ux500 single-IRQ variant MCI_DATABLOCKEND
331 * doesn't seem to immediately clear from the status,
332 * so we can't use it keep count when only one irq is
333 * used because the irq will hit for other reasons, and
334 * then the flag is still up. So we use the MCI_DATAEND
335 * IRQ at the end of the entire transfer because
336 * MCI_DATABLOCKEND is broken.
337 *
338 * In the U300, the IRQs can arrive out-of-order,
339 * e.g. MCI_DATABLOCKEND sometimes arrives after MCI_DATAEND,
340 * so for this case we use the flags "blockend" and
341 * "dataend" to make sure both IRQs have arrived before
342 * concluding the transaction. (This does not apply
343 * to the Ux500 which doesn't fire MCI_DATABLOCKEND
344 * at all.) In DMA mode it suffers from the same problem
345 * as the Ux500.
346 */
347 if (status & MCI_DATABLOCKEND) {
348 /*
349 * Just being a little over-cautious, we do not
350 * use this progressive update if the hardware blockend
351 * flag is unreliable: since it can stay high between
352 * IRQs it will corrupt the transfer counter.
353 */
354 if (!variant->broken_blockend)
355 host->data_xfered += data->blksz;
356 host->blockend = true;
357 }
358
359 if (status & MCI_DATAEND)
360 host->dataend = true;
361 321
362 /* 322 if (status & MCI_DATAEND) {
363 * On variants with broken blockend we shall only wait for dataend,
364 * on others we must sync with the blockend signal since they can
365 * appear out-of-order.
366 */
367 if (host->dataend && (host->blockend || variant->broken_blockend)) {
368 mmci_stop_data(host); 323 mmci_stop_data(host);
369 324
370 /* Reset these flags */ 325 if (!data->error)
371 host->blockend = false; 326 /* The error clause is handled above, success! */
372 host->dataend = false;
373
374 /*
375 * Variants with broken blockend flags need to handle the
376 * end of the entire transfer here.
377 */
378 if (variant->broken_blockend && !data->error)
379 host->data_xfered += data->blksz * data->blocks; 327 host->data_xfered += data->blksz * data->blocks;
380 328
381 if (!data->stop) { 329 if (!data->stop) {
@@ -770,7 +718,6 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id)
770 struct variant_data *variant = id->data; 718 struct variant_data *variant = id->data;
771 struct mmci_host *host; 719 struct mmci_host *host;
772 struct mmc_host *mmc; 720 struct mmc_host *mmc;
773 unsigned int mask;
774 int ret; 721 int ret;
775 722
776 /* must have platform data */ 723 /* must have platform data */
@@ -951,12 +898,7 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id)
951 goto irq0_free; 898 goto irq0_free;
952 } 899 }
953 900
954 mask = MCI_IRQENABLE; 901 writel(MCI_IRQENABLE, host->base + MMCIMASK0);
955 /* Don't use the datablockend flag if it's broken */
956 if (variant->broken_blockend)
957 mask &= ~MCI_DATABLOCKEND;
958
959 writel(mask, host->base + MMCIMASK0);
960 902
961 amba_set_drvdata(dev, mmc); 903 amba_set_drvdata(dev, mmc);
962 904
diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
index df06f01aac89..c1df7b82d36c 100644
--- a/drivers/mmc/host/mmci.h
+++ b/drivers/mmc/host/mmci.h
@@ -137,7 +137,7 @@
137#define MCI_IRQENABLE \ 137#define MCI_IRQENABLE \
138 (MCI_CMDCRCFAILMASK|MCI_DATACRCFAILMASK|MCI_CMDTIMEOUTMASK| \ 138 (MCI_CMDCRCFAILMASK|MCI_DATACRCFAILMASK|MCI_CMDTIMEOUTMASK| \
139 MCI_DATATIMEOUTMASK|MCI_TXUNDERRUNMASK|MCI_RXOVERRUNMASK| \ 139 MCI_DATATIMEOUTMASK|MCI_TXUNDERRUNMASK|MCI_RXOVERRUNMASK| \
140 MCI_CMDRESPENDMASK|MCI_CMDSENTMASK|MCI_DATABLOCKENDMASK) 140 MCI_CMDRESPENDMASK|MCI_CMDSENTMASK)
141 141
142/* These interrupts are directed to IRQ1 when two IRQ lines are available */ 142/* These interrupts are directed to IRQ1 when two IRQ lines are available */
143#define MCI_IRQ1MASK \ 143#define MCI_IRQ1MASK \
@@ -177,9 +177,6 @@ struct mmci_host {
177 struct timer_list timer; 177 struct timer_list timer;
178 unsigned int oldstat; 178 unsigned int oldstat;
179 179
180 bool blockend;
181 bool dataend;
182
183 /* pio stuff */ 180 /* pio stuff */
184 struct sg_mapping_iter sg_miter; 181 struct sg_mapping_iter sg_miter;
185 unsigned int size; 182 unsigned int size;
diff --git a/drivers/mmc/host/msm_sdcc.c b/drivers/mmc/host/msm_sdcc.c
index 5decfd0bd61d..153ab977a013 100644
--- a/drivers/mmc/host/msm_sdcc.c
+++ b/drivers/mmc/host/msm_sdcc.c
@@ -383,14 +383,30 @@ static int msmsdcc_config_dma(struct msmsdcc_host *host, struct mmc_data *data)
383 host->curr.user_pages = 0; 383 host->curr.user_pages = 0;
384 384
385 box = &nc->cmd[0]; 385 box = &nc->cmd[0];
386 for (i = 0; i < host->dma.num_ents; i++) {
387 box->cmd = CMD_MODE_BOX;
388 386
389 /* Initialize sg dma address */ 387 /* location of command block must be 64 bit aligned */
390 sg->dma_address = page_to_dma(mmc_dev(host->mmc), sg_page(sg)) 388 BUG_ON(host->dma.cmd_busaddr & 0x07);
391 + sg->offset;
392 389
393 if (i == (host->dma.num_ents - 1)) 390 nc->cmdptr = (host->dma.cmd_busaddr >> 3) | CMD_PTR_LP;
391 host->dma.hdr.cmdptr = DMOV_CMD_PTR_LIST |
392 DMOV_CMD_ADDR(host->dma.cmdptr_busaddr);
393 host->dma.hdr.complete_func = msmsdcc_dma_complete_func;
394
395 n = dma_map_sg(mmc_dev(host->mmc), host->dma.sg,
396 host->dma.num_ents, host->dma.dir);
397 if (n == 0) {
398 printk(KERN_ERR "%s: Unable to map in all sg elements\n",
399 mmc_hostname(host->mmc));
400 host->dma.sg = NULL;
401 host->dma.num_ents = 0;
402 return -ENOMEM;
403 }
404
405 for_each_sg(host->dma.sg, sg, n, i) {
406
407 box->cmd = CMD_MODE_BOX;
408
409 if (i == n - 1)
394 box->cmd |= CMD_LC; 410 box->cmd |= CMD_LC;
395 rows = (sg_dma_len(sg) % MCI_FIFOSIZE) ? 411 rows = (sg_dma_len(sg) % MCI_FIFOSIZE) ?
396 (sg_dma_len(sg) / MCI_FIFOSIZE) + 1 : 412 (sg_dma_len(sg) / MCI_FIFOSIZE) + 1 :
@@ -418,27 +434,6 @@ static int msmsdcc_config_dma(struct msmsdcc_host *host, struct mmc_data *data)
418 box->cmd |= CMD_DST_CRCI(crci); 434 box->cmd |= CMD_DST_CRCI(crci);
419 } 435 }
420 box++; 436 box++;
421 sg++;
422 }
423
424 /* location of command block must be 64 bit aligned */
425 BUG_ON(host->dma.cmd_busaddr & 0x07);
426
427 nc->cmdptr = (host->dma.cmd_busaddr >> 3) | CMD_PTR_LP;
428 host->dma.hdr.cmdptr = DMOV_CMD_PTR_LIST |
429 DMOV_CMD_ADDR(host->dma.cmdptr_busaddr);
430 host->dma.hdr.complete_func = msmsdcc_dma_complete_func;
431
432 n = dma_map_sg(mmc_dev(host->mmc), host->dma.sg,
433 host->dma.num_ents, host->dma.dir);
434/* dsb inside dma_map_sg will write nc out to mem as well */
435
436 if (n != host->dma.num_ents) {
437 printk(KERN_ERR "%s: Unable to map in all sg elements\n",
438 mmc_hostname(host->mmc));
439 host->dma.sg = NULL;
440 host->dma.num_ents = 0;
441 return -ENOMEM;
442 } 437 }
443 438
444 return 0; 439 return 0;
@@ -1331,9 +1326,6 @@ msmsdcc_probe(struct platform_device *pdev)
1331 if (host->timer.function) 1326 if (host->timer.function)
1332 pr_info("%s: Polling status mode enabled\n", mmc_hostname(mmc)); 1327 pr_info("%s: Polling status mode enabled\n", mmc_hostname(mmc));
1333 1328
1334#if BUSCLK_PWRSAVE
1335 msmsdcc_disable_clocks(host, 1);
1336#endif
1337 return 0; 1329 return 0;
1338 cmd_irq_free: 1330 cmd_irq_free:
1339 free_irq(cmd_irqres->start, host); 1331 free_irq(cmd_irqres->start, host);
diff --git a/drivers/net/arm/ks8695net.c b/drivers/net/arm/ks8695net.c
index 62d6f88cbab5..aa07657744c3 100644
--- a/drivers/net/arm/ks8695net.c
+++ b/drivers/net/arm/ks8695net.c
@@ -1644,7 +1644,7 @@ ks8695_cleanup(void)
1644module_init(ks8695_init); 1644module_init(ks8695_init);
1645module_exit(ks8695_cleanup); 1645module_exit(ks8695_cleanup);
1646 1646
1647MODULE_AUTHOR("Simtec Electronics") 1647MODULE_AUTHOR("Simtec Electronics");
1648MODULE_DESCRIPTION("Micrel KS8695 (Centaur) Ethernet driver"); 1648MODULE_DESCRIPTION("Micrel KS8695 (Centaur) Ethernet driver");
1649MODULE_LICENSE("GPL"); 1649MODULE_LICENSE("GPL");
1650MODULE_ALIAS("platform:" MODULENAME); 1650MODULE_ALIAS("platform:" MODULENAME);
diff --git a/drivers/parport/share.c b/drivers/parport/share.c
index a2d9d1e59260..a848e02e6be3 100644
--- a/drivers/parport/share.c
+++ b/drivers/parport/share.c
@@ -678,7 +678,7 @@ void parport_unregister_device(struct pardevice *dev)
678 678
679 /* Make sure we haven't left any pointers around in the wait 679 /* Make sure we haven't left any pointers around in the wait
680 * list. */ 680 * list. */
681 spin_lock (&port->waitlist_lock); 681 spin_lock_irq(&port->waitlist_lock);
682 if (dev->waitprev || dev->waitnext || port->waithead == dev) { 682 if (dev->waitprev || dev->waitnext || port->waithead == dev) {
683 if (dev->waitprev) 683 if (dev->waitprev)
684 dev->waitprev->waitnext = dev->waitnext; 684 dev->waitprev->waitnext = dev->waitnext;
@@ -689,7 +689,7 @@ void parport_unregister_device(struct pardevice *dev)
689 else 689 else
690 port->waittail = dev->waitprev; 690 port->waittail = dev->waitprev;
691 } 691 }
692 spin_unlock (&port->waitlist_lock); 692 spin_unlock_irq(&port->waitlist_lock);
693 693
694 kfree(dev->state); 694 kfree(dev->state);
695 kfree(dev); 695 kfree(dev);
diff --git a/drivers/platform/x86/intel_scu_ipc.c b/drivers/platform/x86/intel_scu_ipc.c
index 1752ef006d26..f374c5961b32 100644
--- a/drivers/platform/x86/intel_scu_ipc.c
+++ b/drivers/platform/x86/intel_scu_ipc.c
@@ -161,7 +161,7 @@ static int pwr_reg_rdwr(u16 *addr, u8 *data, u32 count, u32 op, u32 id)
161{ 161{
162 int i, nc, bytes, d; 162 int i, nc, bytes, d;
163 u32 offset = 0; 163 u32 offset = 0;
164 u32 err = 0; 164 int err;
165 u8 cbuf[IPC_WWBUF_SIZE] = { }; 165 u8 cbuf[IPC_WWBUF_SIZE] = { };
166 u32 *wbuf = (u32 *)&cbuf; 166 u32 *wbuf = (u32 *)&cbuf;
167 167
@@ -404,7 +404,7 @@ EXPORT_SYMBOL(intel_scu_ipc_update_register);
404 */ 404 */
405int intel_scu_ipc_simple_command(int cmd, int sub) 405int intel_scu_ipc_simple_command(int cmd, int sub)
406{ 406{
407 u32 err = 0; 407 int err;
408 408
409 mutex_lock(&ipclock); 409 mutex_lock(&ipclock);
410 if (ipcdev.pdev == NULL) { 410 if (ipcdev.pdev == NULL) {
@@ -434,8 +434,7 @@ EXPORT_SYMBOL(intel_scu_ipc_simple_command);
434int intel_scu_ipc_command(int cmd, int sub, u32 *in, int inlen, 434int intel_scu_ipc_command(int cmd, int sub, u32 *in, int inlen,
435 u32 *out, int outlen) 435 u32 *out, int outlen)
436{ 436{
437 u32 err = 0; 437 int i, err;
438 int i = 0;
439 438
440 mutex_lock(&ipclock); 439 mutex_lock(&ipclock);
441 if (ipcdev.pdev == NULL) { 440 if (ipcdev.pdev == NULL) {
diff --git a/drivers/platform/x86/intel_scu_ipcutil.c b/drivers/platform/x86/intel_scu_ipcutil.c
index ba3231d0819e..b93a03259c16 100644
--- a/drivers/platform/x86/intel_scu_ipcutil.c
+++ b/drivers/platform/x86/intel_scu_ipcutil.c
@@ -128,6 +128,6 @@ static void __exit ipc_module_exit(void)
128module_init(ipc_module_init); 128module_init(ipc_module_init);
129module_exit(ipc_module_exit); 129module_exit(ipc_module_exit);
130 130
131MODULE_LICENSE("GPL V2"); 131MODULE_LICENSE("GPL v2");
132MODULE_DESCRIPTION("Utility driver for intel scu ipc"); 132MODULE_DESCRIPTION("Utility driver for intel scu ipc");
133MODULE_AUTHOR("Sreedhara <sreedhara.ds@intel.com>"); 133MODULE_AUTHOR("Sreedhara <sreedhara.ds@intel.com>");
diff --git a/drivers/pps/clients/pps-ktimer.c b/drivers/pps/clients/pps-ktimer.c
index 2728469d3884..82583b0ff82d 100644
--- a/drivers/pps/clients/pps-ktimer.c
+++ b/drivers/pps/clients/pps-ktimer.c
@@ -46,8 +46,6 @@ static void pps_ktimer_event(unsigned long ptr)
46 /* First of all we get the time stamp... */ 46 /* First of all we get the time stamp... */
47 pps_get_ts(&ts); 47 pps_get_ts(&ts);
48 48
49 dev_info(pps->dev, "PPS event at %lu\n", jiffies);
50
51 pps_event(pps, &ts, PPS_CAPTUREASSERT, NULL); 49 pps_event(pps, &ts, PPS_CAPTUREASSERT, NULL);
52 50
53 mod_timer(&ktimer, jiffies + HZ); 51 mod_timer(&ktimer, jiffies + HZ);
diff --git a/drivers/pps/clients/pps_parport.c b/drivers/pps/clients/pps_parport.c
index 32221efd9ca9..c571d6dd8f61 100644
--- a/drivers/pps/clients/pps_parport.c
+++ b/drivers/pps/clients/pps_parport.c
@@ -163,7 +163,7 @@ static void parport_attach(struct parport *port)
163 } 163 }
164 164
165 device->pardev = parport_register_device(port, KBUILD_MODNAME, 165 device->pardev = parport_register_device(port, KBUILD_MODNAME,
166 NULL, NULL, parport_irq, 0, device); 166 NULL, NULL, parport_irq, PARPORT_FLAG_EXCL, device);
167 if (!device->pardev) { 167 if (!device->pardev) {
168 pr_err("couldn't register with %s\n", port->name); 168 pr_err("couldn't register with %s\n", port->name);
169 goto err_free; 169 goto err_free;
diff --git a/drivers/pps/generators/pps_gen_parport.c b/drivers/pps/generators/pps_gen_parport.c
index 5c32f8dacf56..b93af3ebb5ba 100644
--- a/drivers/pps/generators/pps_gen_parport.c
+++ b/drivers/pps/generators/pps_gen_parport.c
@@ -198,7 +198,7 @@ static void parport_attach(struct parport *port)
198 } 198 }
199 199
200 device.pardev = parport_register_device(port, KBUILD_MODNAME, 200 device.pardev = parport_register_device(port, KBUILD_MODNAME,
201 NULL, NULL, NULL, 0, &device); 201 NULL, NULL, NULL, PARPORT_FLAG_EXCL, &device);
202 if (!device.pardev) { 202 if (!device.pardev) {
203 pr_err("couldn't register with %s\n", port->name); 203 pr_err("couldn't register with %s\n", port->name);
204 return; 204 return;
diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c
index 467e82bd0929..a50391b6ba2a 100644
--- a/drivers/rapidio/rio-scan.c
+++ b/drivers/rapidio/rio-scan.c
@@ -943,6 +943,8 @@ static int rio_enum_complete(struct rio_mport *port)
943 * @port: Master port to send transactions 943 * @port: Master port to send transactions
944 * @destid: Current destination ID in network 944 * @destid: Current destination ID in network
945 * @hopcount: Number of hops into the network 945 * @hopcount: Number of hops into the network
946 * @prev: previous rio_dev
947 * @prev_port: previous port number
946 * 948 *
947 * Recursively discovers a RIO network. Transactions are sent via the 949 * Recursively discovers a RIO network. Transactions are sent via the
948 * master port passed in @port. 950 * master port passed in @port.
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 4941cade319f..cdd97192dc69 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -97,18 +97,6 @@ config RTC_INTF_DEV
97 97
98 If unsure, say Y. 98 If unsure, say Y.
99 99
100config RTC_INTF_DEV_UIE_EMUL
101 bool "RTC UIE emulation on dev interface"
102 depends on RTC_INTF_DEV
103 help
104 Provides an emulation for RTC_UIE if the underlying rtc chip
105 driver does not expose RTC_UIE ioctls. Those requests generate
106 once-per-second update interrupts, used for synchronization.
107
108 The emulation code will read the time from the hardware
109 clock several times per second, please enable this option
110 only if you know that you really need it.
111
112config RTC_DRV_TEST 100config RTC_DRV_TEST
113 tristate "Test driver/device" 101 tristate "Test driver/device"
114 help 102 help
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 90384b9f6b2c..925006d33109 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -16,6 +16,9 @@
16#include <linux/log2.h> 16#include <linux/log2.h>
17#include <linux/workqueue.h> 17#include <linux/workqueue.h>
18 18
19static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer);
20static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer);
21
19static int __rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm) 22static int __rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm)
20{ 23{
21 int err; 24 int err;
@@ -120,12 +123,18 @@ int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
120 err = mutex_lock_interruptible(&rtc->ops_lock); 123 err = mutex_lock_interruptible(&rtc->ops_lock);
121 if (err) 124 if (err)
122 return err; 125 return err;
123 alarm->enabled = rtc->aie_timer.enabled; 126 if (rtc->ops == NULL)
124 if (alarm->enabled) 127 err = -ENODEV;
128 else if (!rtc->ops->read_alarm)
129 err = -EINVAL;
130 else {
131 memset(alarm, 0, sizeof(struct rtc_wkalrm));
132 alarm->enabled = rtc->aie_timer.enabled;
125 alarm->time = rtc_ktime_to_tm(rtc->aie_timer.node.expires); 133 alarm->time = rtc_ktime_to_tm(rtc->aie_timer.node.expires);
134 }
126 mutex_unlock(&rtc->ops_lock); 135 mutex_unlock(&rtc->ops_lock);
127 136
128 return 0; 137 return err;
129} 138}
130EXPORT_SYMBOL_GPL(rtc_read_alarm); 139EXPORT_SYMBOL_GPL(rtc_read_alarm);
131 140
@@ -175,16 +184,14 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
175 return err; 184 return err;
176 if (rtc->aie_timer.enabled) { 185 if (rtc->aie_timer.enabled) {
177 rtc_timer_remove(rtc, &rtc->aie_timer); 186 rtc_timer_remove(rtc, &rtc->aie_timer);
178 rtc->aie_timer.enabled = 0;
179 } 187 }
180 rtc->aie_timer.node.expires = rtc_tm_to_ktime(alarm->time); 188 rtc->aie_timer.node.expires = rtc_tm_to_ktime(alarm->time);
181 rtc->aie_timer.period = ktime_set(0, 0); 189 rtc->aie_timer.period = ktime_set(0, 0);
182 if (alarm->enabled) { 190 if (alarm->enabled) {
183 rtc->aie_timer.enabled = 1; 191 err = rtc_timer_enqueue(rtc, &rtc->aie_timer);
184 rtc_timer_enqueue(rtc, &rtc->aie_timer);
185 } 192 }
186 mutex_unlock(&rtc->ops_lock); 193 mutex_unlock(&rtc->ops_lock);
187 return 0; 194 return err;
188} 195}
189EXPORT_SYMBOL_GPL(rtc_set_alarm); 196EXPORT_SYMBOL_GPL(rtc_set_alarm);
190 197
@@ -195,15 +202,15 @@ int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled)
195 return err; 202 return err;
196 203
197 if (rtc->aie_timer.enabled != enabled) { 204 if (rtc->aie_timer.enabled != enabled) {
198 if (enabled) { 205 if (enabled)
199 rtc->aie_timer.enabled = 1; 206 err = rtc_timer_enqueue(rtc, &rtc->aie_timer);
200 rtc_timer_enqueue(rtc, &rtc->aie_timer); 207 else
201 } else {
202 rtc_timer_remove(rtc, &rtc->aie_timer); 208 rtc_timer_remove(rtc, &rtc->aie_timer);
203 rtc->aie_timer.enabled = 0;
204 }
205 } 209 }
206 210
211 if (err)
212 return err;
213
207 if (!rtc->ops) 214 if (!rtc->ops)
208 err = -ENODEV; 215 err = -ENODEV;
209 else if (!rtc->ops->alarm_irq_enable) 216 else if (!rtc->ops->alarm_irq_enable)
@@ -235,12 +242,9 @@ int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)
235 now = rtc_tm_to_ktime(tm); 242 now = rtc_tm_to_ktime(tm);
236 rtc->uie_rtctimer.node.expires = ktime_add(now, onesec); 243 rtc->uie_rtctimer.node.expires = ktime_add(now, onesec);
237 rtc->uie_rtctimer.period = ktime_set(1, 0); 244 rtc->uie_rtctimer.period = ktime_set(1, 0);
238 rtc->uie_rtctimer.enabled = 1; 245 err = rtc_timer_enqueue(rtc, &rtc->uie_rtctimer);
239 rtc_timer_enqueue(rtc, &rtc->uie_rtctimer); 246 } else
240 } else {
241 rtc_timer_remove(rtc, &rtc->uie_rtctimer); 247 rtc_timer_remove(rtc, &rtc->uie_rtctimer);
242 rtc->uie_rtctimer.enabled = 0;
243 }
244 248
245out: 249out:
246 mutex_unlock(&rtc->ops_lock); 250 mutex_unlock(&rtc->ops_lock);
@@ -488,10 +492,13 @@ EXPORT_SYMBOL_GPL(rtc_irq_set_freq);
488 * Enqueues a timer onto the rtc devices timerqueue and sets 492 * Enqueues a timer onto the rtc devices timerqueue and sets
489 * the next alarm event appropriately. 493 * the next alarm event appropriately.
490 * 494 *
495 * Sets the enabled bit on the added timer.
496 *
491 * Must hold ops_lock for proper serialization of timerqueue 497 * Must hold ops_lock for proper serialization of timerqueue
492 */ 498 */
493void rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer) 499static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer)
494{ 500{
501 timer->enabled = 1;
495 timerqueue_add(&rtc->timerqueue, &timer->node); 502 timerqueue_add(&rtc->timerqueue, &timer->node);
496 if (&timer->node == timerqueue_getnext(&rtc->timerqueue)) { 503 if (&timer->node == timerqueue_getnext(&rtc->timerqueue)) {
497 struct rtc_wkalrm alarm; 504 struct rtc_wkalrm alarm;
@@ -501,7 +508,13 @@ void rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer)
501 err = __rtc_set_alarm(rtc, &alarm); 508 err = __rtc_set_alarm(rtc, &alarm);
502 if (err == -ETIME) 509 if (err == -ETIME)
503 schedule_work(&rtc->irqwork); 510 schedule_work(&rtc->irqwork);
511 else if (err) {
512 timerqueue_del(&rtc->timerqueue, &timer->node);
513 timer->enabled = 0;
514 return err;
515 }
504 } 516 }
517 return 0;
505} 518}
506 519
507/** 520/**
@@ -512,13 +525,15 @@ void rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer)
512 * Removes a timer onto the rtc devices timerqueue and sets 525 * Removes a timer onto the rtc devices timerqueue and sets
513 * the next alarm event appropriately. 526 * the next alarm event appropriately.
514 * 527 *
528 * Clears the enabled bit on the removed timer.
529 *
515 * Must hold ops_lock for proper serialization of timerqueue 530 * Must hold ops_lock for proper serialization of timerqueue
516 */ 531 */
517void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer) 532static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer)
518{ 533{
519 struct timerqueue_node *next = timerqueue_getnext(&rtc->timerqueue); 534 struct timerqueue_node *next = timerqueue_getnext(&rtc->timerqueue);
520 timerqueue_del(&rtc->timerqueue, &timer->node); 535 timerqueue_del(&rtc->timerqueue, &timer->node);
521 536 timer->enabled = 0;
522 if (next == &timer->node) { 537 if (next == &timer->node) {
523 struct rtc_wkalrm alarm; 538 struct rtc_wkalrm alarm;
524 int err; 539 int err;
@@ -626,8 +641,7 @@ int rtc_timer_start(struct rtc_device *rtc, struct rtc_timer* timer,
626 timer->node.expires = expires; 641 timer->node.expires = expires;
627 timer->period = period; 642 timer->period = period;
628 643
629 timer->enabled = 1; 644 ret = rtc_timer_enqueue(rtc, timer);
630 rtc_timer_enqueue(rtc, timer);
631 645
632 mutex_unlock(&rtc->ops_lock); 646 mutex_unlock(&rtc->ops_lock);
633 return ret; 647 return ret;
@@ -645,7 +659,6 @@ int rtc_timer_cancel(struct rtc_device *rtc, struct rtc_timer* timer)
645 mutex_lock(&rtc->ops_lock); 659 mutex_lock(&rtc->ops_lock);
646 if (timer->enabled) 660 if (timer->enabled)
647 rtc_timer_remove(rtc, timer); 661 rtc_timer_remove(rtc, timer);
648 timer->enabled = 0;
649 mutex_unlock(&rtc->ops_lock); 662 mutex_unlock(&rtc->ops_lock);
650 return ret; 663 return ret;
651} 664}
diff --git a/drivers/sh/intc/chip.c b/drivers/sh/intc/chip.c
index de885a0f917a..f33e2dd97934 100644
--- a/drivers/sh/intc/chip.c
+++ b/drivers/sh/intc/chip.c
@@ -173,7 +173,8 @@ int intc_set_priority(unsigned int irq, unsigned int prio)
173 return 0; 173 return 0;
174} 174}
175 175
176#define VALID(x) (x | 0x80) 176#define SENSE_VALID_FLAG 0x80
177#define VALID(x) (x | SENSE_VALID_FLAG)
177 178
178static unsigned char intc_irq_sense_table[IRQ_TYPE_SENSE_MASK + 1] = { 179static unsigned char intc_irq_sense_table[IRQ_TYPE_SENSE_MASK + 1] = {
179 [IRQ_TYPE_EDGE_FALLING] = VALID(0), 180 [IRQ_TYPE_EDGE_FALLING] = VALID(0),
@@ -201,7 +202,8 @@ static int intc_set_type(struct irq_data *data, unsigned int type)
201 ihp = intc_find_irq(d->sense, d->nr_sense, irq); 202 ihp = intc_find_irq(d->sense, d->nr_sense, irq);
202 if (ihp) { 203 if (ihp) {
203 addr = INTC_REG(d, _INTC_ADDR_E(ihp->handle), 0); 204 addr = INTC_REG(d, _INTC_ADDR_E(ihp->handle), 0);
204 intc_reg_fns[_INTC_FN(ihp->handle)](addr, ihp->handle, value); 205 intc_reg_fns[_INTC_FN(ihp->handle)](addr, ihp->handle,
206 value & ~SENSE_VALID_FLAG);
205 } 207 }
206 208
207 return 0; 209 return 0;
diff --git a/drivers/staging/msm/msm_fb.c b/drivers/staging/msm/msm_fb.c
index 23fa049b51f2..a2f29d464051 100644
--- a/drivers/staging/msm/msm_fb.c
+++ b/drivers/staging/msm/msm_fb.c
@@ -347,7 +347,7 @@ static int msm_fb_suspend(struct platform_device *pdev, pm_message_t state)
347 if ((!mfd) || (mfd->key != MFD_KEY)) 347 if ((!mfd) || (mfd->key != MFD_KEY))
348 return 0; 348 return 0;
349 349
350 acquire_console_sem(); 350 console_lock();
351 fb_set_suspend(mfd->fbi, 1); 351 fb_set_suspend(mfd->fbi, 1);
352 352
353 ret = msm_fb_suspend_sub(mfd); 353 ret = msm_fb_suspend_sub(mfd);
@@ -358,7 +358,7 @@ static int msm_fb_suspend(struct platform_device *pdev, pm_message_t state)
358 pdev->dev.power.power_state = state; 358 pdev->dev.power.power_state = state;
359 } 359 }
360 360
361 release_console_sem(); 361 console_unlock();
362 return ret; 362 return ret;
363} 363}
364#else 364#else
@@ -431,11 +431,11 @@ static int msm_fb_resume(struct platform_device *pdev)
431 if ((!mfd) || (mfd->key != MFD_KEY)) 431 if ((!mfd) || (mfd->key != MFD_KEY))
432 return 0; 432 return 0;
433 433
434 acquire_console_sem(); 434 console_lock();
435 ret = msm_fb_resume_sub(mfd); 435 ret = msm_fb_resume_sub(mfd);
436 pdev->dev.power.power_state = PMSG_ON; 436 pdev->dev.power.power_state = PMSG_ON;
437 fb_set_suspend(mfd->fbi, 1); 437 fb_set_suspend(mfd->fbi, 1);
438 release_console_sem(); 438 console_unlock();
439 439
440 return ret; 440 return ret;
441} 441}
diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c b/drivers/staging/olpc_dcon/olpc_dcon.c
index 9f26dc9408bb..56a283d1a74d 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon.c
+++ b/drivers/staging/olpc_dcon/olpc_dcon.c
@@ -373,17 +373,17 @@ static void dcon_source_switch(struct work_struct *work)
373 * 373 *
374 * For now, we just hope.. 374 * For now, we just hope..
375 */ 375 */
376 acquire_console_sem(); 376 console_lock();
377 ignore_fb_events = 1; 377 ignore_fb_events = 1;
378 if (fb_blank(fbinfo, FB_BLANK_UNBLANK)) { 378 if (fb_blank(fbinfo, FB_BLANK_UNBLANK)) {
379 ignore_fb_events = 0; 379 ignore_fb_events = 0;
380 release_console_sem(); 380 console_unlock();
381 printk(KERN_ERR "olpc-dcon: Failed to enter CPU mode\n"); 381 printk(KERN_ERR "olpc-dcon: Failed to enter CPU mode\n");
382 dcon_pending = DCON_SOURCE_DCON; 382 dcon_pending = DCON_SOURCE_DCON;
383 return; 383 return;
384 } 384 }
385 ignore_fb_events = 0; 385 ignore_fb_events = 0;
386 release_console_sem(); 386 console_unlock();
387 387
388 /* And turn off the DCON */ 388 /* And turn off the DCON */
389 pdata->set_dconload(1); 389 pdata->set_dconload(1);
@@ -435,12 +435,12 @@ static void dcon_source_switch(struct work_struct *work)
435 } 435 }
436 } 436 }
437 437
438 acquire_console_sem(); 438 console_lock();
439 ignore_fb_events = 1; 439 ignore_fb_events = 1;
440 if (fb_blank(fbinfo, FB_BLANK_POWERDOWN)) 440 if (fb_blank(fbinfo, FB_BLANK_POWERDOWN))
441 printk(KERN_ERR "olpc-dcon: couldn't blank fb!\n"); 441 printk(KERN_ERR "olpc-dcon: couldn't blank fb!\n");
442 ignore_fb_events = 0; 442 ignore_fb_events = 0;
443 release_console_sem(); 443 console_unlock();
444 444
445 printk(KERN_INFO "olpc-dcon: The DCON has control\n"); 445 printk(KERN_INFO "olpc-dcon: The DCON has control\n");
446 break; 446 break;
diff --git a/drivers/staging/sm7xx/smtcfb.c b/drivers/staging/sm7xx/smtcfb.c
index 0bc113c44d39..d007e4a12c14 100644
--- a/drivers/staging/sm7xx/smtcfb.c
+++ b/drivers/staging/sm7xx/smtcfb.c
@@ -1044,9 +1044,9 @@ static int __maybe_unused smtcfb_suspend(struct pci_dev *pdev, pm_message_t msg)
1044 1044
1045 /* when doing suspend, call fb apis and pci apis */ 1045 /* when doing suspend, call fb apis and pci apis */
1046 if (msg.event == PM_EVENT_SUSPEND) { 1046 if (msg.event == PM_EVENT_SUSPEND) {
1047 acquire_console_sem(); 1047 console_lock();
1048 fb_set_suspend(&sfb->fb, 1); 1048 fb_set_suspend(&sfb->fb, 1);
1049 release_console_sem(); 1049 console_unlock();
1050 retv = pci_save_state(pdev); 1050 retv = pci_save_state(pdev);
1051 pci_disable_device(pdev); 1051 pci_disable_device(pdev);
1052 retv = pci_choose_state(pdev, msg); 1052 retv = pci_choose_state(pdev, msg);
@@ -1105,9 +1105,9 @@ static int __maybe_unused smtcfb_resume(struct pci_dev *pdev)
1105 1105
1106 smtcfb_setmode(sfb); 1106 smtcfb_setmode(sfb);
1107 1107
1108 acquire_console_sem(); 1108 console_lock();
1109 fb_set_suspend(&sfb->fb, 0); 1109 fb_set_suspend(&sfb->fb, 0);
1110 release_console_sem(); 1110 console_unlock();
1111 1111
1112 return 0; 1112 return 0;
1113} 1113}
diff --git a/drivers/tty/serial/sb1250-duart.c b/drivers/tty/serial/sb1250-duart.c
index a2f2b3254499..602d9845c52f 100644
--- a/drivers/tty/serial/sb1250-duart.c
+++ b/drivers/tty/serial/sb1250-duart.c
@@ -829,7 +829,7 @@ static void __init sbd_probe_duarts(void)
829#ifdef CONFIG_SERIAL_SB1250_DUART_CONSOLE 829#ifdef CONFIG_SERIAL_SB1250_DUART_CONSOLE
830/* 830/*
831 * Serial console stuff. Very basic, polling driver for doing serial 831 * Serial console stuff. Very basic, polling driver for doing serial
832 * console output. The console_sem is held by the caller, so we 832 * console output. The console_lock is held by the caller, so we
833 * shouldn't be interrupted for more console activity. 833 * shouldn't be interrupted for more console activity.
834 */ 834 */
835static void sbd_console_putchar(struct uart_port *uport, int ch) 835static void sbd_console_putchar(struct uart_port *uport, int ch)
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index c556ed9db13d..8e0dd254eb11 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -46,7 +46,7 @@
46#include <asm/irq_regs.h> 46#include <asm/irq_regs.h>
47 47
48/* Whether we react on sysrq keys or just ignore them */ 48/* Whether we react on sysrq keys or just ignore them */
49static int __read_mostly sysrq_enabled = 1; 49static int __read_mostly sysrq_enabled = SYSRQ_DEFAULT_ENABLE;
50static bool __read_mostly sysrq_always_enabled; 50static bool __read_mostly sysrq_always_enabled;
51 51
52static bool sysrq_on(void) 52static bool sysrq_on(void)
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 464d09d97873..6158eae0f64a 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -3256,7 +3256,7 @@ static ssize_t show_cons_active(struct device *dev,
3256 struct console *c; 3256 struct console *c;
3257 ssize_t count = 0; 3257 ssize_t count = 0;
3258 3258
3259 acquire_console_sem(); 3259 console_lock();
3260 for (c = console_drivers; c; c = c->next) { 3260 for (c = console_drivers; c; c = c->next) {
3261 if (!c->device) 3261 if (!c->device)
3262 continue; 3262 continue;
@@ -3271,7 +3271,7 @@ static ssize_t show_cons_active(struct device *dev,
3271 while (i--) 3271 while (i--)
3272 count += sprintf(buf + count, "%s%d%c", 3272 count += sprintf(buf + count, "%s%d%c",
3273 cs[i]->name, cs[i]->index, i ? ' ':'\n'); 3273 cs[i]->name, cs[i]->index, i ? ' ':'\n');
3274 release_console_sem(); 3274 console_unlock();
3275 3275
3276 return count; 3276 return count;
3277} 3277}
diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c
index ebae344ce910..c956ed6c83a3 100644
--- a/drivers/tty/vt/selection.c
+++ b/drivers/tty/vt/selection.c
@@ -316,9 +316,9 @@ int paste_selection(struct tty_struct *tty)
316 /* always called with BTM from vt_ioctl */ 316 /* always called with BTM from vt_ioctl */
317 WARN_ON(!tty_locked()); 317 WARN_ON(!tty_locked());
318 318
319 acquire_console_sem(); 319 console_lock();
320 poke_blanked_console(); 320 poke_blanked_console();
321 release_console_sem(); 321 console_unlock();
322 322
323 ld = tty_ldisc_ref(tty); 323 ld = tty_ldisc_ref(tty);
324 if (!ld) { 324 if (!ld) {
diff --git a/drivers/tty/vt/vc_screen.c b/drivers/tty/vt/vc_screen.c
index eab3a1ff99e4..a672ed192d33 100644
--- a/drivers/tty/vt/vc_screen.c
+++ b/drivers/tty/vt/vc_screen.c
@@ -202,7 +202,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
202 /* Select the proper current console and verify 202 /* Select the proper current console and verify
203 * sanity of the situation under the console lock. 203 * sanity of the situation under the console lock.
204 */ 204 */
205 acquire_console_sem(); 205 console_lock();
206 206
207 attr = (currcons & 128); 207 attr = (currcons & 128);
208 currcons = (currcons & 127); 208 currcons = (currcons & 127);
@@ -336,9 +336,9 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
336 * the pagefault handling code may want to call printk(). 336 * the pagefault handling code may want to call printk().
337 */ 337 */
338 338
339 release_console_sem(); 339 console_unlock();
340 ret = copy_to_user(buf, con_buf_start, orig_count); 340 ret = copy_to_user(buf, con_buf_start, orig_count);
341 acquire_console_sem(); 341 console_lock();
342 342
343 if (ret) { 343 if (ret) {
344 read += (orig_count - ret); 344 read += (orig_count - ret);
@@ -354,7 +354,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
354 if (read) 354 if (read)
355 ret = read; 355 ret = read;
356unlock_out: 356unlock_out:
357 release_console_sem(); 357 console_unlock();
358 mutex_unlock(&con_buf_mtx); 358 mutex_unlock(&con_buf_mtx);
359 return ret; 359 return ret;
360} 360}
@@ -379,7 +379,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
379 /* Select the proper current console and verify 379 /* Select the proper current console and verify
380 * sanity of the situation under the console lock. 380 * sanity of the situation under the console lock.
381 */ 381 */
382 acquire_console_sem(); 382 console_lock();
383 383
384 attr = (currcons & 128); 384 attr = (currcons & 128);
385 currcons = (currcons & 127); 385 currcons = (currcons & 127);
@@ -414,9 +414,9 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
414 /* Temporarily drop the console lock so that we can read 414 /* Temporarily drop the console lock so that we can read
415 * in the write data from userspace safely. 415 * in the write data from userspace safely.
416 */ 416 */
417 release_console_sem(); 417 console_unlock();
418 ret = copy_from_user(con_buf, buf, this_round); 418 ret = copy_from_user(con_buf, buf, this_round);
419 acquire_console_sem(); 419 console_lock();
420 420
421 if (ret) { 421 if (ret) {
422 this_round -= ret; 422 this_round -= ret;
@@ -542,7 +542,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
542 vcs_scr_updated(vc); 542 vcs_scr_updated(vc);
543 543
544unlock_out: 544unlock_out:
545 release_console_sem(); 545 console_unlock();
546 546
547 mutex_unlock(&con_buf_mtx); 547 mutex_unlock(&con_buf_mtx);
548 548
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 76407eca9ab0..b230bd3f056f 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -1003,9 +1003,9 @@ static int vt_resize(struct tty_struct *tty, struct winsize *ws)
1003 struct vc_data *vc = tty->driver_data; 1003 struct vc_data *vc = tty->driver_data;
1004 int ret; 1004 int ret;
1005 1005
1006 acquire_console_sem(); 1006 console_lock();
1007 ret = vc_do_resize(tty, vc, ws->ws_col, ws->ws_row); 1007 ret = vc_do_resize(tty, vc, ws->ws_col, ws->ws_row);
1008 release_console_sem(); 1008 console_unlock();
1009 return ret; 1009 return ret;
1010} 1010}
1011 1011
@@ -1271,7 +1271,7 @@ static void default_attr(struct vc_data *vc)
1271 vc->vc_color = vc->vc_def_color; 1271 vc->vc_color = vc->vc_def_color;
1272} 1272}
1273 1273
1274/* console_sem is held */ 1274/* console_lock is held */
1275static void csi_m(struct vc_data *vc) 1275static void csi_m(struct vc_data *vc)
1276{ 1276{
1277 int i; 1277 int i;
@@ -1415,7 +1415,7 @@ int mouse_reporting(void)
1415 return vc_cons[fg_console].d->vc_report_mouse; 1415 return vc_cons[fg_console].d->vc_report_mouse;
1416} 1416}
1417 1417
1418/* console_sem is held */ 1418/* console_lock is held */
1419static void set_mode(struct vc_data *vc, int on_off) 1419static void set_mode(struct vc_data *vc, int on_off)
1420{ 1420{
1421 int i; 1421 int i;
@@ -1485,7 +1485,7 @@ static void set_mode(struct vc_data *vc, int on_off)
1485 } 1485 }
1486} 1486}
1487 1487
1488/* console_sem is held */ 1488/* console_lock is held */
1489static void setterm_command(struct vc_data *vc) 1489static void setterm_command(struct vc_data *vc)
1490{ 1490{
1491 switch(vc->vc_par[0]) { 1491 switch(vc->vc_par[0]) {
@@ -1545,7 +1545,7 @@ static void setterm_command(struct vc_data *vc)
1545 } 1545 }
1546} 1546}
1547 1547
1548/* console_sem is held */ 1548/* console_lock is held */
1549static void csi_at(struct vc_data *vc, unsigned int nr) 1549static void csi_at(struct vc_data *vc, unsigned int nr)
1550{ 1550{
1551 if (nr > vc->vc_cols - vc->vc_x) 1551 if (nr > vc->vc_cols - vc->vc_x)
@@ -1555,7 +1555,7 @@ static void csi_at(struct vc_data *vc, unsigned int nr)
1555 insert_char(vc, nr); 1555 insert_char(vc, nr);
1556} 1556}
1557 1557
1558/* console_sem is held */ 1558/* console_lock is held */
1559static void csi_L(struct vc_data *vc, unsigned int nr) 1559static void csi_L(struct vc_data *vc, unsigned int nr)
1560{ 1560{
1561 if (nr > vc->vc_rows - vc->vc_y) 1561 if (nr > vc->vc_rows - vc->vc_y)
@@ -1566,7 +1566,7 @@ static void csi_L(struct vc_data *vc, unsigned int nr)
1566 vc->vc_need_wrap = 0; 1566 vc->vc_need_wrap = 0;
1567} 1567}
1568 1568
1569/* console_sem is held */ 1569/* console_lock is held */
1570static void csi_P(struct vc_data *vc, unsigned int nr) 1570static void csi_P(struct vc_data *vc, unsigned int nr)
1571{ 1571{
1572 if (nr > vc->vc_cols - vc->vc_x) 1572 if (nr > vc->vc_cols - vc->vc_x)
@@ -1576,7 +1576,7 @@ static void csi_P(struct vc_data *vc, unsigned int nr)
1576 delete_char(vc, nr); 1576 delete_char(vc, nr);
1577} 1577}
1578 1578
1579/* console_sem is held */ 1579/* console_lock is held */
1580static void csi_M(struct vc_data *vc, unsigned int nr) 1580static void csi_M(struct vc_data *vc, unsigned int nr)
1581{ 1581{
1582 if (nr > vc->vc_rows - vc->vc_y) 1582 if (nr > vc->vc_rows - vc->vc_y)
@@ -1587,7 +1587,7 @@ static void csi_M(struct vc_data *vc, unsigned int nr)
1587 vc->vc_need_wrap = 0; 1587 vc->vc_need_wrap = 0;
1588} 1588}
1589 1589
1590/* console_sem is held (except via vc_init->reset_terminal */ 1590/* console_lock is held (except via vc_init->reset_terminal */
1591static void save_cur(struct vc_data *vc) 1591static void save_cur(struct vc_data *vc)
1592{ 1592{
1593 vc->vc_saved_x = vc->vc_x; 1593 vc->vc_saved_x = vc->vc_x;
@@ -1603,7 +1603,7 @@ static void save_cur(struct vc_data *vc)
1603 vc->vc_saved_G1 = vc->vc_G1_charset; 1603 vc->vc_saved_G1 = vc->vc_G1_charset;
1604} 1604}
1605 1605
1606/* console_sem is held */ 1606/* console_lock is held */
1607static void restore_cur(struct vc_data *vc) 1607static void restore_cur(struct vc_data *vc)
1608{ 1608{
1609 gotoxy(vc, vc->vc_saved_x, vc->vc_saved_y); 1609 gotoxy(vc, vc->vc_saved_x, vc->vc_saved_y);
@@ -1625,7 +1625,7 @@ enum { ESnormal, ESesc, ESsquare, ESgetpars, ESgotpars, ESfunckey,
1625 EShash, ESsetG0, ESsetG1, ESpercent, ESignore, ESnonstd, 1625 EShash, ESsetG0, ESsetG1, ESpercent, ESignore, ESnonstd,
1626 ESpalette }; 1626 ESpalette };
1627 1627
1628/* console_sem is held (except via vc_init()) */ 1628/* console_lock is held (except via vc_init()) */
1629static void reset_terminal(struct vc_data *vc, int do_clear) 1629static void reset_terminal(struct vc_data *vc, int do_clear)
1630{ 1630{
1631 vc->vc_top = 0; 1631 vc->vc_top = 0;
@@ -1685,7 +1685,7 @@ static void reset_terminal(struct vc_data *vc, int do_clear)
1685 csi_J(vc, 2); 1685 csi_J(vc, 2);
1686} 1686}
1687 1687
1688/* console_sem is held */ 1688/* console_lock is held */
1689static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) 1689static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c)
1690{ 1690{
1691 /* 1691 /*
@@ -2119,7 +2119,7 @@ static int is_double_width(uint32_t ucs)
2119 return bisearch(ucs, double_width, ARRAY_SIZE(double_width) - 1); 2119 return bisearch(ucs, double_width, ARRAY_SIZE(double_width) - 1);
2120} 2120}
2121 2121
2122/* acquires console_sem */ 2122/* acquires console_lock */
2123static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int count) 2123static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int count)
2124{ 2124{
2125#ifdef VT_BUF_VRAM_ONLY 2125#ifdef VT_BUF_VRAM_ONLY
@@ -2147,11 +2147,11 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
2147 2147
2148 might_sleep(); 2148 might_sleep();
2149 2149
2150 acquire_console_sem(); 2150 console_lock();
2151 vc = tty->driver_data; 2151 vc = tty->driver_data;
2152 if (vc == NULL) { 2152 if (vc == NULL) {
2153 printk(KERN_ERR "vt: argh, driver_data is NULL !\n"); 2153 printk(KERN_ERR "vt: argh, driver_data is NULL !\n");
2154 release_console_sem(); 2154 console_unlock();
2155 return 0; 2155 return 0;
2156 } 2156 }
2157 2157
@@ -2159,7 +2159,7 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
2159 if (!vc_cons_allocated(currcons)) { 2159 if (!vc_cons_allocated(currcons)) {
2160 /* could this happen? */ 2160 /* could this happen? */
2161 printk_once("con_write: tty %d not allocated\n", currcons+1); 2161 printk_once("con_write: tty %d not allocated\n", currcons+1);
2162 release_console_sem(); 2162 console_unlock();
2163 return 0; 2163 return 0;
2164 } 2164 }
2165 2165
@@ -2375,7 +2375,7 @@ rescan_last_byte:
2375 } 2375 }
2376 FLUSH 2376 FLUSH
2377 console_conditional_schedule(); 2377 console_conditional_schedule();
2378 release_console_sem(); 2378 console_unlock();
2379 notify_update(vc); 2379 notify_update(vc);
2380 return n; 2380 return n;
2381#undef FLUSH 2381#undef FLUSH
@@ -2388,11 +2388,11 @@ rescan_last_byte:
2388 * us to do the switches asynchronously (needed when we want 2388 * us to do the switches asynchronously (needed when we want
2389 * to switch due to a keyboard interrupt). Synchronization 2389 * to switch due to a keyboard interrupt). Synchronization
2390 * with other console code and prevention of re-entrancy is 2390 * with other console code and prevention of re-entrancy is
2391 * ensured with console_sem. 2391 * ensured with console_lock.
2392 */ 2392 */
2393static void console_callback(struct work_struct *ignored) 2393static void console_callback(struct work_struct *ignored)
2394{ 2394{
2395 acquire_console_sem(); 2395 console_lock();
2396 2396
2397 if (want_console >= 0) { 2397 if (want_console >= 0) {
2398 if (want_console != fg_console && 2398 if (want_console != fg_console &&
@@ -2422,7 +2422,7 @@ static void console_callback(struct work_struct *ignored)
2422 } 2422 }
2423 notify_update(vc_cons[fg_console].d); 2423 notify_update(vc_cons[fg_console].d);
2424 2424
2425 release_console_sem(); 2425 console_unlock();
2426} 2426}
2427 2427
2428int set_console(int nr) 2428int set_console(int nr)
@@ -2603,7 +2603,7 @@ static struct console vt_console_driver = {
2603 */ 2603 */
2604 2604
2605/* 2605/*
2606 * Generally a bit racy with respect to console_sem(). 2606 * Generally a bit racy with respect to console_lock();.
2607 * 2607 *
2608 * There are some functions which don't need it. 2608 * There are some functions which don't need it.
2609 * 2609 *
@@ -2629,17 +2629,17 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
2629 switch (type) 2629 switch (type)
2630 { 2630 {
2631 case TIOCL_SETSEL: 2631 case TIOCL_SETSEL:
2632 acquire_console_sem(); 2632 console_lock();
2633 ret = set_selection((struct tiocl_selection __user *)(p+1), tty); 2633 ret = set_selection((struct tiocl_selection __user *)(p+1), tty);
2634 release_console_sem(); 2634 console_unlock();
2635 break; 2635 break;
2636 case TIOCL_PASTESEL: 2636 case TIOCL_PASTESEL:
2637 ret = paste_selection(tty); 2637 ret = paste_selection(tty);
2638 break; 2638 break;
2639 case TIOCL_UNBLANKSCREEN: 2639 case TIOCL_UNBLANKSCREEN:
2640 acquire_console_sem(); 2640 console_lock();
2641 unblank_screen(); 2641 unblank_screen();
2642 release_console_sem(); 2642 console_unlock();
2643 break; 2643 break;
2644 case TIOCL_SELLOADLUT: 2644 case TIOCL_SELLOADLUT:
2645 ret = sel_loadlut(p); 2645 ret = sel_loadlut(p);
@@ -2688,10 +2688,10 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
2688 } 2688 }
2689 break; 2689 break;
2690 case TIOCL_BLANKSCREEN: /* until explicitly unblanked, not only poked */ 2690 case TIOCL_BLANKSCREEN: /* until explicitly unblanked, not only poked */
2691 acquire_console_sem(); 2691 console_lock();
2692 ignore_poke = 1; 2692 ignore_poke = 1;
2693 do_blank_screen(0); 2693 do_blank_screen(0);
2694 release_console_sem(); 2694 console_unlock();
2695 break; 2695 break;
2696 case TIOCL_BLANKEDSCREEN: 2696 case TIOCL_BLANKEDSCREEN:
2697 ret = console_blanked; 2697 ret = console_blanked;
@@ -2790,11 +2790,11 @@ static void con_flush_chars(struct tty_struct *tty)
2790 return; 2790 return;
2791 2791
2792 /* if we race with con_close(), vt may be null */ 2792 /* if we race with con_close(), vt may be null */
2793 acquire_console_sem(); 2793 console_lock();
2794 vc = tty->driver_data; 2794 vc = tty->driver_data;
2795 if (vc) 2795 if (vc)
2796 set_cursor(vc); 2796 set_cursor(vc);
2797 release_console_sem(); 2797 console_unlock();
2798} 2798}
2799 2799
2800/* 2800/*
@@ -2805,7 +2805,7 @@ static int con_open(struct tty_struct *tty, struct file *filp)
2805 unsigned int currcons = tty->index; 2805 unsigned int currcons = tty->index;
2806 int ret = 0; 2806 int ret = 0;
2807 2807
2808 acquire_console_sem(); 2808 console_lock();
2809 if (tty->driver_data == NULL) { 2809 if (tty->driver_data == NULL) {
2810 ret = vc_allocate(currcons); 2810 ret = vc_allocate(currcons);
2811 if (ret == 0) { 2811 if (ret == 0) {
@@ -2813,7 +2813,7 @@ static int con_open(struct tty_struct *tty, struct file *filp)
2813 2813
2814 /* Still being freed */ 2814 /* Still being freed */
2815 if (vc->port.tty) { 2815 if (vc->port.tty) {
2816 release_console_sem(); 2816 console_unlock();
2817 return -ERESTARTSYS; 2817 return -ERESTARTSYS;
2818 } 2818 }
2819 tty->driver_data = vc; 2819 tty->driver_data = vc;
@@ -2827,11 +2827,11 @@ static int con_open(struct tty_struct *tty, struct file *filp)
2827 tty->termios->c_iflag |= IUTF8; 2827 tty->termios->c_iflag |= IUTF8;
2828 else 2828 else
2829 tty->termios->c_iflag &= ~IUTF8; 2829 tty->termios->c_iflag &= ~IUTF8;
2830 release_console_sem(); 2830 console_unlock();
2831 return ret; 2831 return ret;
2832 } 2832 }
2833 } 2833 }
2834 release_console_sem(); 2834 console_unlock();
2835 return ret; 2835 return ret;
2836} 2836}
2837 2837
@@ -2844,9 +2844,9 @@ static void con_shutdown(struct tty_struct *tty)
2844{ 2844{
2845 struct vc_data *vc = tty->driver_data; 2845 struct vc_data *vc = tty->driver_data;
2846 BUG_ON(vc == NULL); 2846 BUG_ON(vc == NULL);
2847 acquire_console_sem(); 2847 console_lock();
2848 vc->port.tty = NULL; 2848 vc->port.tty = NULL;
2849 release_console_sem(); 2849 console_unlock();
2850 tty_shutdown(tty); 2850 tty_shutdown(tty);
2851} 2851}
2852 2852
@@ -2893,13 +2893,13 @@ static int __init con_init(void)
2893 struct vc_data *vc; 2893 struct vc_data *vc;
2894 unsigned int currcons = 0, i; 2894 unsigned int currcons = 0, i;
2895 2895
2896 acquire_console_sem(); 2896 console_lock();
2897 2897
2898 if (conswitchp) 2898 if (conswitchp)
2899 display_desc = conswitchp->con_startup(); 2899 display_desc = conswitchp->con_startup();
2900 if (!display_desc) { 2900 if (!display_desc) {
2901 fg_console = 0; 2901 fg_console = 0;
2902 release_console_sem(); 2902 console_unlock();
2903 return 0; 2903 return 0;
2904 } 2904 }
2905 2905
@@ -2946,7 +2946,7 @@ static int __init con_init(void)
2946 printable = 1; 2946 printable = 1;
2947 printk("\n"); 2947 printk("\n");
2948 2948
2949 release_console_sem(); 2949 console_unlock();
2950 2950
2951#ifdef CONFIG_VT_CONSOLE 2951#ifdef CONFIG_VT_CONSOLE
2952 register_console(&vt_console_driver); 2952 register_console(&vt_console_driver);
@@ -3037,7 +3037,7 @@ static int bind_con_driver(const struct consw *csw, int first, int last,
3037 if (!try_module_get(owner)) 3037 if (!try_module_get(owner))
3038 return -ENODEV; 3038 return -ENODEV;
3039 3039
3040 acquire_console_sem(); 3040 console_lock();
3041 3041
3042 /* check if driver is registered */ 3042 /* check if driver is registered */
3043 for (i = 0; i < MAX_NR_CON_DRIVER; i++) { 3043 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
@@ -3122,7 +3122,7 @@ static int bind_con_driver(const struct consw *csw, int first, int last,
3122 3122
3123 retval = 0; 3123 retval = 0;
3124err: 3124err:
3125 release_console_sem(); 3125 console_unlock();
3126 module_put(owner); 3126 module_put(owner);
3127 return retval; 3127 return retval;
3128}; 3128};
@@ -3171,7 +3171,7 @@ int unbind_con_driver(const struct consw *csw, int first, int last, int deflt)
3171 if (!try_module_get(owner)) 3171 if (!try_module_get(owner))
3172 return -ENODEV; 3172 return -ENODEV;
3173 3173
3174 acquire_console_sem(); 3174 console_lock();
3175 3175
3176 /* check if driver is registered and if it is unbindable */ 3176 /* check if driver is registered and if it is unbindable */
3177 for (i = 0; i < MAX_NR_CON_DRIVER; i++) { 3177 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
@@ -3185,7 +3185,7 @@ int unbind_con_driver(const struct consw *csw, int first, int last, int deflt)
3185 } 3185 }
3186 3186
3187 if (retval) { 3187 if (retval) {
3188 release_console_sem(); 3188 console_unlock();
3189 goto err; 3189 goto err;
3190 } 3190 }
3191 3191
@@ -3204,12 +3204,12 @@ int unbind_con_driver(const struct consw *csw, int first, int last, int deflt)
3204 } 3204 }
3205 3205
3206 if (retval) { 3206 if (retval) {
3207 release_console_sem(); 3207 console_unlock();
3208 goto err; 3208 goto err;
3209 } 3209 }
3210 3210
3211 if (!con_is_bound(csw)) { 3211 if (!con_is_bound(csw)) {
3212 release_console_sem(); 3212 console_unlock();
3213 goto err; 3213 goto err;
3214 } 3214 }
3215 3215
@@ -3238,7 +3238,7 @@ int unbind_con_driver(const struct consw *csw, int first, int last, int deflt)
3238 if (!con_is_bound(csw)) 3238 if (!con_is_bound(csw))
3239 con_driver->flag &= ~CON_DRIVER_FLAG_INIT; 3239 con_driver->flag &= ~CON_DRIVER_FLAG_INIT;
3240 3240
3241 release_console_sem(); 3241 console_unlock();
3242 /* ignore return value, binding should not fail */ 3242 /* ignore return value, binding should not fail */
3243 bind_con_driver(defcsw, first, last, deflt); 3243 bind_con_driver(defcsw, first, last, deflt);
3244err: 3244err:
@@ -3538,7 +3538,7 @@ int register_con_driver(const struct consw *csw, int first, int last)
3538 if (!try_module_get(owner)) 3538 if (!try_module_get(owner))
3539 return -ENODEV; 3539 return -ENODEV;
3540 3540
3541 acquire_console_sem(); 3541 console_lock();
3542 3542
3543 for (i = 0; i < MAX_NR_CON_DRIVER; i++) { 3543 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
3544 con_driver = &registered_con_driver[i]; 3544 con_driver = &registered_con_driver[i];
@@ -3592,7 +3592,7 @@ int register_con_driver(const struct consw *csw, int first, int last)
3592 } 3592 }
3593 3593
3594err: 3594err:
3595 release_console_sem(); 3595 console_unlock();
3596 module_put(owner); 3596 module_put(owner);
3597 return retval; 3597 return retval;
3598} 3598}
@@ -3613,7 +3613,7 @@ int unregister_con_driver(const struct consw *csw)
3613{ 3613{
3614 int i, retval = -ENODEV; 3614 int i, retval = -ENODEV;
3615 3615
3616 acquire_console_sem(); 3616 console_lock();
3617 3617
3618 /* cannot unregister a bound driver */ 3618 /* cannot unregister a bound driver */
3619 if (con_is_bound(csw)) 3619 if (con_is_bound(csw))
@@ -3639,7 +3639,7 @@ int unregister_con_driver(const struct consw *csw)
3639 } 3639 }
3640 } 3640 }
3641err: 3641err:
3642 release_console_sem(); 3642 console_unlock();
3643 return retval; 3643 return retval;
3644} 3644}
3645EXPORT_SYMBOL(unregister_con_driver); 3645EXPORT_SYMBOL(unregister_con_driver);
@@ -3934,9 +3934,9 @@ int con_set_cmap(unsigned char __user *arg)
3934{ 3934{
3935 int rc; 3935 int rc;
3936 3936
3937 acquire_console_sem(); 3937 console_lock();
3938 rc = set_get_cmap (arg,1); 3938 rc = set_get_cmap (arg,1);
3939 release_console_sem(); 3939 console_unlock();
3940 3940
3941 return rc; 3941 return rc;
3942} 3942}
@@ -3945,9 +3945,9 @@ int con_get_cmap(unsigned char __user *arg)
3945{ 3945{
3946 int rc; 3946 int rc;
3947 3947
3948 acquire_console_sem(); 3948 console_lock();
3949 rc = set_get_cmap (arg,0); 3949 rc = set_get_cmap (arg,0);
3950 release_console_sem(); 3950 console_unlock();
3951 3951
3952 return rc; 3952 return rc;
3953} 3953}
@@ -3994,12 +3994,12 @@ static int con_font_get(struct vc_data *vc, struct console_font_op *op)
3994 } else 3994 } else
3995 font.data = NULL; 3995 font.data = NULL;
3996 3996
3997 acquire_console_sem(); 3997 console_lock();
3998 if (vc->vc_sw->con_font_get) 3998 if (vc->vc_sw->con_font_get)
3999 rc = vc->vc_sw->con_font_get(vc, &font); 3999 rc = vc->vc_sw->con_font_get(vc, &font);
4000 else 4000 else
4001 rc = -ENOSYS; 4001 rc = -ENOSYS;
4002 release_console_sem(); 4002 console_unlock();
4003 4003
4004 if (rc) 4004 if (rc)
4005 goto out; 4005 goto out;
@@ -4076,12 +4076,12 @@ static int con_font_set(struct vc_data *vc, struct console_font_op *op)
4076 font.data = memdup_user(op->data, size); 4076 font.data = memdup_user(op->data, size);
4077 if (IS_ERR(font.data)) 4077 if (IS_ERR(font.data))
4078 return PTR_ERR(font.data); 4078 return PTR_ERR(font.data);
4079 acquire_console_sem(); 4079 console_lock();
4080 if (vc->vc_sw->con_font_set) 4080 if (vc->vc_sw->con_font_set)
4081 rc = vc->vc_sw->con_font_set(vc, &font, op->flags); 4081 rc = vc->vc_sw->con_font_set(vc, &font, op->flags);
4082 else 4082 else
4083 rc = -ENOSYS; 4083 rc = -ENOSYS;
4084 release_console_sem(); 4084 console_unlock();
4085 kfree(font.data); 4085 kfree(font.data);
4086 return rc; 4086 return rc;
4087} 4087}
@@ -4103,12 +4103,12 @@ static int con_font_default(struct vc_data *vc, struct console_font_op *op)
4103 else 4103 else
4104 name[MAX_FONT_NAME - 1] = 0; 4104 name[MAX_FONT_NAME - 1] = 0;
4105 4105
4106 acquire_console_sem(); 4106 console_lock();
4107 if (vc->vc_sw->con_font_default) 4107 if (vc->vc_sw->con_font_default)
4108 rc = vc->vc_sw->con_font_default(vc, &font, s); 4108 rc = vc->vc_sw->con_font_default(vc, &font, s);
4109 else 4109 else
4110 rc = -ENOSYS; 4110 rc = -ENOSYS;
4111 release_console_sem(); 4111 console_unlock();
4112 if (!rc) { 4112 if (!rc) {
4113 op->width = font.width; 4113 op->width = font.width;
4114 op->height = font.height; 4114 op->height = font.height;
@@ -4124,7 +4124,7 @@ static int con_font_copy(struct vc_data *vc, struct console_font_op *op)
4124 if (vc->vc_mode != KD_TEXT) 4124 if (vc->vc_mode != KD_TEXT)
4125 return -EINVAL; 4125 return -EINVAL;
4126 4126
4127 acquire_console_sem(); 4127 console_lock();
4128 if (!vc->vc_sw->con_font_copy) 4128 if (!vc->vc_sw->con_font_copy)
4129 rc = -ENOSYS; 4129 rc = -ENOSYS;
4130 else if (con < 0 || !vc_cons_allocated(con)) 4130 else if (con < 0 || !vc_cons_allocated(con))
@@ -4133,7 +4133,7 @@ static int con_font_copy(struct vc_data *vc, struct console_font_op *op)
4133 rc = 0; 4133 rc = 0;
4134 else 4134 else
4135 rc = vc->vc_sw->con_font_copy(vc, con); 4135 rc = vc->vc_sw->con_font_copy(vc, con);
4136 release_console_sem(); 4136 console_unlock();
4137 return rc; 4137 return rc;
4138} 4138}
4139 4139
diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c
index 6b68a0fb4611..1235ebda6e1c 100644
--- a/drivers/tty/vt/vt_ioctl.c
+++ b/drivers/tty/vt/vt_ioctl.c
@@ -649,12 +649,12 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
649 /* 649 /*
650 * explicitly blank/unblank the screen if switching modes 650 * explicitly blank/unblank the screen if switching modes
651 */ 651 */
652 acquire_console_sem(); 652 console_lock();
653 if (arg == KD_TEXT) 653 if (arg == KD_TEXT)
654 do_unblank_screen(1); 654 do_unblank_screen(1);
655 else 655 else
656 do_blank_screen(1); 656 do_blank_screen(1);
657 release_console_sem(); 657 console_unlock();
658 break; 658 break;
659 659
660 case KDGETMODE: 660 case KDGETMODE:
@@ -893,7 +893,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
893 ret = -EINVAL; 893 ret = -EINVAL;
894 goto out; 894 goto out;
895 } 895 }
896 acquire_console_sem(); 896 console_lock();
897 vc->vt_mode = tmp; 897 vc->vt_mode = tmp;
898 /* the frsig is ignored, so we set it to 0 */ 898 /* the frsig is ignored, so we set it to 0 */
899 vc->vt_mode.frsig = 0; 899 vc->vt_mode.frsig = 0;
@@ -901,7 +901,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
901 vc->vt_pid = get_pid(task_pid(current)); 901 vc->vt_pid = get_pid(task_pid(current));
902 /* no switch is required -- saw@shade.msu.ru */ 902 /* no switch is required -- saw@shade.msu.ru */
903 vc->vt_newvt = -1; 903 vc->vt_newvt = -1;
904 release_console_sem(); 904 console_unlock();
905 break; 905 break;
906 } 906 }
907 907
@@ -910,9 +910,9 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
910 struct vt_mode tmp; 910 struct vt_mode tmp;
911 int rc; 911 int rc;
912 912
913 acquire_console_sem(); 913 console_lock();
914 memcpy(&tmp, &vc->vt_mode, sizeof(struct vt_mode)); 914 memcpy(&tmp, &vc->vt_mode, sizeof(struct vt_mode));
915 release_console_sem(); 915 console_unlock();
916 916
917 rc = copy_to_user(up, &tmp, sizeof(struct vt_mode)); 917 rc = copy_to_user(up, &tmp, sizeof(struct vt_mode));
918 if (rc) 918 if (rc)
@@ -965,9 +965,9 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
965 ret = -ENXIO; 965 ret = -ENXIO;
966 else { 966 else {
967 arg--; 967 arg--;
968 acquire_console_sem(); 968 console_lock();
969 ret = vc_allocate(arg); 969 ret = vc_allocate(arg);
970 release_console_sem(); 970 console_unlock();
971 if (ret) 971 if (ret)
972 break; 972 break;
973 set_console(arg); 973 set_console(arg);
@@ -990,7 +990,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
990 ret = -ENXIO; 990 ret = -ENXIO;
991 else { 991 else {
992 vsa.console--; 992 vsa.console--;
993 acquire_console_sem(); 993 console_lock();
994 ret = vc_allocate(vsa.console); 994 ret = vc_allocate(vsa.console);
995 if (ret == 0) { 995 if (ret == 0) {
996 struct vc_data *nvc; 996 struct vc_data *nvc;
@@ -1003,7 +1003,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1003 put_pid(nvc->vt_pid); 1003 put_pid(nvc->vt_pid);
1004 nvc->vt_pid = get_pid(task_pid(current)); 1004 nvc->vt_pid = get_pid(task_pid(current));
1005 } 1005 }
1006 release_console_sem(); 1006 console_unlock();
1007 if (ret) 1007 if (ret)
1008 break; 1008 break;
1009 /* Commence switch and lock */ 1009 /* Commence switch and lock */
@@ -1044,7 +1044,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1044 /* 1044 /*
1045 * Switching-from response 1045 * Switching-from response
1046 */ 1046 */
1047 acquire_console_sem(); 1047 console_lock();
1048 if (vc->vt_newvt >= 0) { 1048 if (vc->vt_newvt >= 0) {
1049 if (arg == 0) 1049 if (arg == 0)
1050 /* 1050 /*
@@ -1063,7 +1063,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1063 vc->vt_newvt = -1; 1063 vc->vt_newvt = -1;
1064 ret = vc_allocate(newvt); 1064 ret = vc_allocate(newvt);
1065 if (ret) { 1065 if (ret) {
1066 release_console_sem(); 1066 console_unlock();
1067 break; 1067 break;
1068 } 1068 }
1069 /* 1069 /*
@@ -1083,7 +1083,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1083 if (arg != VT_ACKACQ) 1083 if (arg != VT_ACKACQ)
1084 ret = -EINVAL; 1084 ret = -EINVAL;
1085 } 1085 }
1086 release_console_sem(); 1086 console_unlock();
1087 break; 1087 break;
1088 1088
1089 /* 1089 /*
@@ -1096,20 +1096,20 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1096 } 1096 }
1097 if (arg == 0) { 1097 if (arg == 0) {
1098 /* deallocate all unused consoles, but leave 0 */ 1098 /* deallocate all unused consoles, but leave 0 */
1099 acquire_console_sem(); 1099 console_lock();
1100 for (i=1; i<MAX_NR_CONSOLES; i++) 1100 for (i=1; i<MAX_NR_CONSOLES; i++)
1101 if (! VT_BUSY(i)) 1101 if (! VT_BUSY(i))
1102 vc_deallocate(i); 1102 vc_deallocate(i);
1103 release_console_sem(); 1103 console_unlock();
1104 } else { 1104 } else {
1105 /* deallocate a single console, if possible */ 1105 /* deallocate a single console, if possible */
1106 arg--; 1106 arg--;
1107 if (VT_BUSY(arg)) 1107 if (VT_BUSY(arg))
1108 ret = -EBUSY; 1108 ret = -EBUSY;
1109 else if (arg) { /* leave 0 */ 1109 else if (arg) { /* leave 0 */
1110 acquire_console_sem(); 1110 console_lock();
1111 vc_deallocate(arg); 1111 vc_deallocate(arg);
1112 release_console_sem(); 1112 console_unlock();
1113 } 1113 }
1114 } 1114 }
1115 break; 1115 break;
@@ -1126,7 +1126,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1126 get_user(cc, &vtsizes->v_cols)) 1126 get_user(cc, &vtsizes->v_cols))
1127 ret = -EFAULT; 1127 ret = -EFAULT;
1128 else { 1128 else {
1129 acquire_console_sem(); 1129 console_lock();
1130 for (i = 0; i < MAX_NR_CONSOLES; i++) { 1130 for (i = 0; i < MAX_NR_CONSOLES; i++) {
1131 vc = vc_cons[i].d; 1131 vc = vc_cons[i].d;
1132 1132
@@ -1135,7 +1135,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1135 vc_resize(vc_cons[i].d, cc, ll); 1135 vc_resize(vc_cons[i].d, cc, ll);
1136 } 1136 }
1137 } 1137 }
1138 release_console_sem(); 1138 console_unlock();
1139 } 1139 }
1140 break; 1140 break;
1141 } 1141 }
@@ -1187,14 +1187,14 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1187 for (i = 0; i < MAX_NR_CONSOLES; i++) { 1187 for (i = 0; i < MAX_NR_CONSOLES; i++) {
1188 if (!vc_cons[i].d) 1188 if (!vc_cons[i].d)
1189 continue; 1189 continue;
1190 acquire_console_sem(); 1190 console_lock();
1191 if (vlin) 1191 if (vlin)
1192 vc_cons[i].d->vc_scan_lines = vlin; 1192 vc_cons[i].d->vc_scan_lines = vlin;
1193 if (clin) 1193 if (clin)
1194 vc_cons[i].d->vc_font.height = clin; 1194 vc_cons[i].d->vc_font.height = clin;
1195 vc_cons[i].d->vc_resize_user = 1; 1195 vc_cons[i].d->vc_resize_user = 1;
1196 vc_resize(vc_cons[i].d, cc, ll); 1196 vc_resize(vc_cons[i].d, cc, ll);
1197 release_console_sem(); 1197 console_unlock();
1198 } 1198 }
1199 break; 1199 break;
1200 } 1200 }
@@ -1367,7 +1367,7 @@ void vc_SAK(struct work_struct *work)
1367 struct vc_data *vc; 1367 struct vc_data *vc;
1368 struct tty_struct *tty; 1368 struct tty_struct *tty;
1369 1369
1370 acquire_console_sem(); 1370 console_lock();
1371 vc = vc_con->d; 1371 vc = vc_con->d;
1372 if (vc) { 1372 if (vc) {
1373 tty = vc->port.tty; 1373 tty = vc->port.tty;
@@ -1379,7 +1379,7 @@ void vc_SAK(struct work_struct *work)
1379 __do_SAK(tty); 1379 __do_SAK(tty);
1380 reset_vc(vc); 1380 reset_vc(vc);
1381 } 1381 }
1382 release_console_sem(); 1382 console_unlock();
1383} 1383}
1384 1384
1385#ifdef CONFIG_COMPAT 1385#ifdef CONFIG_COMPAT
@@ -1737,10 +1737,10 @@ int vt_move_to_console(unsigned int vt, int alloc)
1737{ 1737{
1738 int prev; 1738 int prev;
1739 1739
1740 acquire_console_sem(); 1740 console_lock();
1741 /* Graphics mode - up to X */ 1741 /* Graphics mode - up to X */
1742 if (disable_vt_switch) { 1742 if (disable_vt_switch) {
1743 release_console_sem(); 1743 console_unlock();
1744 return 0; 1744 return 0;
1745 } 1745 }
1746 prev = fg_console; 1746 prev = fg_console;
@@ -1748,7 +1748,7 @@ int vt_move_to_console(unsigned int vt, int alloc)
1748 if (alloc && vc_allocate(vt)) { 1748 if (alloc && vc_allocate(vt)) {
1749 /* we can't have a free VC for now. Too bad, 1749 /* we can't have a free VC for now. Too bad,
1750 * we don't want to mess the screen for now. */ 1750 * we don't want to mess the screen for now. */
1751 release_console_sem(); 1751 console_unlock();
1752 return -ENOSPC; 1752 return -ENOSPC;
1753 } 1753 }
1754 1754
@@ -1758,10 +1758,10 @@ int vt_move_to_console(unsigned int vt, int alloc)
1758 * Let the calling function know so it can decide 1758 * Let the calling function know so it can decide
1759 * what to do. 1759 * what to do.
1760 */ 1760 */
1761 release_console_sem(); 1761 console_unlock();
1762 return -EIO; 1762 return -EIO;
1763 } 1763 }
1764 release_console_sem(); 1764 console_unlock();
1765 tty_lock(); 1765 tty_lock();
1766 if (vt_waitactive(vt + 1)) { 1766 if (vt_waitactive(vt + 1)) {
1767 pr_debug("Suspend: Can't switch VCs."); 1767 pr_debug("Suspend: Can't switch VCs.");
@@ -1781,8 +1781,8 @@ int vt_move_to_console(unsigned int vt, int alloc)
1781 */ 1781 */
1782void pm_set_vt_switch(int do_switch) 1782void pm_set_vt_switch(int do_switch)
1783{ 1783{
1784 acquire_console_sem(); 1784 console_lock();
1785 disable_vt_switch = !do_switch; 1785 disable_vt_switch = !do_switch;
1786 release_console_sem(); 1786 console_unlock();
1787} 1787}
1788EXPORT_SYMBOL(pm_set_vt_switch); 1788EXPORT_SYMBOL(pm_set_vt_switch);
diff --git a/drivers/video/arkfb.c b/drivers/video/arkfb.c
index d583bea608fd..391ac939f011 100644
--- a/drivers/video/arkfb.c
+++ b/drivers/video/arkfb.c
@@ -23,7 +23,7 @@
23#include <linux/svga.h> 23#include <linux/svga.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/pci.h> 25#include <linux/pci.h>
26#include <linux/console.h> /* Why should fb driver call console functions? because acquire_console_sem() */ 26#include <linux/console.h> /* Why should fb driver call console functions? because console_lock() */
27#include <video/vga.h> 27#include <video/vga.h>
28 28
29#ifdef CONFIG_MTRR 29#ifdef CONFIG_MTRR
@@ -1091,12 +1091,12 @@ static int ark_pci_suspend (struct pci_dev* dev, pm_message_t state)
1091 1091
1092 dev_info(info->device, "suspend\n"); 1092 dev_info(info->device, "suspend\n");
1093 1093
1094 acquire_console_sem(); 1094 console_lock();
1095 mutex_lock(&(par->open_lock)); 1095 mutex_lock(&(par->open_lock));
1096 1096
1097 if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) { 1097 if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) {
1098 mutex_unlock(&(par->open_lock)); 1098 mutex_unlock(&(par->open_lock));
1099 release_console_sem(); 1099 console_unlock();
1100 return 0; 1100 return 0;
1101 } 1101 }
1102 1102
@@ -1107,7 +1107,7 @@ static int ark_pci_suspend (struct pci_dev* dev, pm_message_t state)
1107 pci_set_power_state(dev, pci_choose_state(dev, state)); 1107 pci_set_power_state(dev, pci_choose_state(dev, state));
1108 1108
1109 mutex_unlock(&(par->open_lock)); 1109 mutex_unlock(&(par->open_lock));
1110 release_console_sem(); 1110 console_unlock();
1111 1111
1112 return 0; 1112 return 0;
1113} 1113}
@@ -1122,7 +1122,7 @@ static int ark_pci_resume (struct pci_dev* dev)
1122 1122
1123 dev_info(info->device, "resume\n"); 1123 dev_info(info->device, "resume\n");
1124 1124
1125 acquire_console_sem(); 1125 console_lock();
1126 mutex_lock(&(par->open_lock)); 1126 mutex_lock(&(par->open_lock));
1127 1127
1128 if (par->ref_count == 0) 1128 if (par->ref_count == 0)
@@ -1141,7 +1141,7 @@ static int ark_pci_resume (struct pci_dev* dev)
1141 1141
1142fail: 1142fail:
1143 mutex_unlock(&(par->open_lock)); 1143 mutex_unlock(&(par->open_lock));
1144 release_console_sem(); 1144 console_unlock();
1145 return 0; 1145 return 0;
1146} 1146}
1147#else 1147#else
diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
index dd9de2e80580..4cb6a576c567 100644
--- a/drivers/video/aty/aty128fb.c
+++ b/drivers/video/aty/aty128fb.c
@@ -1860,11 +1860,11 @@ static void aty128_early_resume(void *data)
1860{ 1860{
1861 struct aty128fb_par *par = data; 1861 struct aty128fb_par *par = data;
1862 1862
1863 if (try_acquire_console_sem()) 1863 if (!console_trylock())
1864 return; 1864 return;
1865 pci_restore_state(par->pdev); 1865 pci_restore_state(par->pdev);
1866 aty128_do_resume(par->pdev); 1866 aty128_do_resume(par->pdev);
1867 release_console_sem(); 1867 console_unlock();
1868} 1868}
1869#endif /* CONFIG_PPC_PMAC */ 1869#endif /* CONFIG_PPC_PMAC */
1870 1870
@@ -2438,7 +2438,7 @@ static int aty128_pci_suspend(struct pci_dev *pdev, pm_message_t state)
2438 2438
2439 printk(KERN_DEBUG "aty128fb: suspending...\n"); 2439 printk(KERN_DEBUG "aty128fb: suspending...\n");
2440 2440
2441 acquire_console_sem(); 2441 console_lock();
2442 2442
2443 fb_set_suspend(info, 1); 2443 fb_set_suspend(info, 1);
2444 2444
@@ -2470,7 +2470,7 @@ static int aty128_pci_suspend(struct pci_dev *pdev, pm_message_t state)
2470 if (state.event != PM_EVENT_ON) 2470 if (state.event != PM_EVENT_ON)
2471 aty128_set_suspend(par, 1); 2471 aty128_set_suspend(par, 1);
2472 2472
2473 release_console_sem(); 2473 console_unlock();
2474 2474
2475 pdev->dev.power.power_state = state; 2475 pdev->dev.power.power_state = state;
2476 2476
@@ -2527,9 +2527,9 @@ static int aty128_pci_resume(struct pci_dev *pdev)
2527{ 2527{
2528 int rc; 2528 int rc;
2529 2529
2530 acquire_console_sem(); 2530 console_lock();
2531 rc = aty128_do_resume(pdev); 2531 rc = aty128_do_resume(pdev);
2532 release_console_sem(); 2532 console_unlock();
2533 2533
2534 return rc; 2534 return rc;
2535} 2535}
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
index 767ab4fb1a05..94e293fce1d2 100644
--- a/drivers/video/aty/atyfb_base.c
+++ b/drivers/video/aty/atyfb_base.c
@@ -2069,7 +2069,7 @@ static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
2069 if (state.event == pdev->dev.power.power_state.event) 2069 if (state.event == pdev->dev.power.power_state.event)
2070 return 0; 2070 return 0;
2071 2071
2072 acquire_console_sem(); 2072 console_lock();
2073 2073
2074 fb_set_suspend(info, 1); 2074 fb_set_suspend(info, 1);
2075 2075
@@ -2097,14 +2097,14 @@ static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
2097 par->lock_blank = 0; 2097 par->lock_blank = 0;
2098 atyfb_blank(FB_BLANK_UNBLANK, info); 2098 atyfb_blank(FB_BLANK_UNBLANK, info);
2099 fb_set_suspend(info, 0); 2099 fb_set_suspend(info, 0);
2100 release_console_sem(); 2100 console_unlock();
2101 return -EIO; 2101 return -EIO;
2102 } 2102 }
2103#else 2103#else
2104 pci_set_power_state(pdev, pci_choose_state(pdev, state)); 2104 pci_set_power_state(pdev, pci_choose_state(pdev, state));
2105#endif 2105#endif
2106 2106
2107 release_console_sem(); 2107 console_unlock();
2108 2108
2109 pdev->dev.power.power_state = state; 2109 pdev->dev.power.power_state = state;
2110 2110
@@ -2133,7 +2133,7 @@ static int atyfb_pci_resume(struct pci_dev *pdev)
2133 if (pdev->dev.power.power_state.event == PM_EVENT_ON) 2133 if (pdev->dev.power.power_state.event == PM_EVENT_ON)
2134 return 0; 2134 return 0;
2135 2135
2136 acquire_console_sem(); 2136 console_lock();
2137 2137
2138 /* 2138 /*
2139 * PCI state will have been restored by the core, so 2139 * PCI state will have been restored by the core, so
@@ -2161,7 +2161,7 @@ static int atyfb_pci_resume(struct pci_dev *pdev)
2161 par->lock_blank = 0; 2161 par->lock_blank = 0;
2162 atyfb_blank(FB_BLANK_UNBLANK, info); 2162 atyfb_blank(FB_BLANK_UNBLANK, info);
2163 2163
2164 release_console_sem(); 2164 console_unlock();
2165 2165
2166 pdev->dev.power.power_state = PMSG_ON; 2166 pdev->dev.power.power_state = PMSG_ON;
2167 2167
diff --git a/drivers/video/aty/radeon_pm.c b/drivers/video/aty/radeon_pm.c
index c4e17642d9c5..92bda5848516 100644
--- a/drivers/video/aty/radeon_pm.c
+++ b/drivers/video/aty/radeon_pm.c
@@ -2626,7 +2626,7 @@ int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
2626 goto done; 2626 goto done;
2627 } 2627 }
2628 2628
2629 acquire_console_sem(); 2629 console_lock();
2630 2630
2631 fb_set_suspend(info, 1); 2631 fb_set_suspend(info, 1);
2632 2632
@@ -2690,7 +2690,7 @@ int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
2690 if (rinfo->pm_mode & radeon_pm_d2) 2690 if (rinfo->pm_mode & radeon_pm_d2)
2691 radeon_set_suspend(rinfo, 1); 2691 radeon_set_suspend(rinfo, 1);
2692 2692
2693 release_console_sem(); 2693 console_unlock();
2694 2694
2695 done: 2695 done:
2696 pdev->dev.power.power_state = mesg; 2696 pdev->dev.power.power_state = mesg;
@@ -2715,10 +2715,10 @@ int radeonfb_pci_resume(struct pci_dev *pdev)
2715 return 0; 2715 return 0;
2716 2716
2717 if (rinfo->no_schedule) { 2717 if (rinfo->no_schedule) {
2718 if (try_acquire_console_sem()) 2718 if (!console_trylock())
2719 return 0; 2719 return 0;
2720 } else 2720 } else
2721 acquire_console_sem(); 2721 console_lock();
2722 2722
2723 printk(KERN_DEBUG "radeonfb (%s): resuming from state: %d...\n", 2723 printk(KERN_DEBUG "radeonfb (%s): resuming from state: %d...\n",
2724 pci_name(pdev), pdev->dev.power.power_state.event); 2724 pci_name(pdev), pdev->dev.power.power_state.event);
@@ -2783,7 +2783,7 @@ int radeonfb_pci_resume(struct pci_dev *pdev)
2783 pdev->dev.power.power_state = PMSG_ON; 2783 pdev->dev.power.power_state = PMSG_ON;
2784 2784
2785 bail: 2785 bail:
2786 release_console_sem(); 2786 console_unlock();
2787 2787
2788 return rc; 2788 return rc;
2789} 2789}
diff --git a/drivers/video/bf537-lq035.c b/drivers/video/bf537-lq035.c
index 18c507874ff1..47c21fb2c82f 100644
--- a/drivers/video/bf537-lq035.c
+++ b/drivers/video/bf537-lq035.c
@@ -696,6 +696,7 @@ static int __devinit bfin_lq035_probe(struct platform_device *pdev)
696{ 696{
697 struct backlight_properties props; 697 struct backlight_properties props;
698 dma_addr_t dma_handle; 698 dma_addr_t dma_handle;
699 int ret;
699 700
700 if (request_dma(CH_PPI, KBUILD_MODNAME)) { 701 if (request_dma(CH_PPI, KBUILD_MODNAME)) {
701 pr_err("couldn't request PPI DMA\n"); 702 pr_err("couldn't request PPI DMA\n");
@@ -704,17 +705,16 @@ static int __devinit bfin_lq035_probe(struct platform_device *pdev)
704 705
705 if (request_ports()) { 706 if (request_ports()) {
706 pr_err("couldn't request gpio port\n"); 707 pr_err("couldn't request gpio port\n");
707 free_dma(CH_PPI); 708 ret = -EFAULT;
708 return -EFAULT; 709 goto out_ports;
709 } 710 }
710 711
711 fb_buffer = dma_alloc_coherent(NULL, TOTAL_VIDEO_MEM_SIZE, 712 fb_buffer = dma_alloc_coherent(NULL, TOTAL_VIDEO_MEM_SIZE,
712 &dma_handle, GFP_KERNEL); 713 &dma_handle, GFP_KERNEL);
713 if (fb_buffer == NULL) { 714 if (fb_buffer == NULL) {
714 pr_err("couldn't allocate dma buffer\n"); 715 pr_err("couldn't allocate dma buffer\n");
715 free_dma(CH_PPI); 716 ret = -ENOMEM;
716 free_ports(); 717 goto out_dma_coherent;
717 return -ENOMEM;
718 } 718 }
719 719
720 if (L1_DATA_A_LENGTH) 720 if (L1_DATA_A_LENGTH)
@@ -725,10 +725,8 @@ static int __devinit bfin_lq035_probe(struct platform_device *pdev)
725 725
726 if (dma_desc_table == NULL) { 726 if (dma_desc_table == NULL) {
727 pr_err("couldn't allocate dma descriptor\n"); 727 pr_err("couldn't allocate dma descriptor\n");
728 free_dma(CH_PPI); 728 ret = -ENOMEM;
729 free_ports(); 729 goto out_table;
730 dma_free_coherent(NULL, TOTAL_VIDEO_MEM_SIZE, fb_buffer, 0);
731 return -ENOMEM;
732 } 730 }
733 731
734 bfin_lq035_fb.screen_base = (void *)fb_buffer; 732 bfin_lq035_fb.screen_base = (void *)fb_buffer;
@@ -771,31 +769,21 @@ static int __devinit bfin_lq035_probe(struct platform_device *pdev)
771 bfin_lq035_fb.pseudo_palette = kzalloc(sizeof(u32) * 16, GFP_KERNEL); 769 bfin_lq035_fb.pseudo_palette = kzalloc(sizeof(u32) * 16, GFP_KERNEL);
772 if (bfin_lq035_fb.pseudo_palette == NULL) { 770 if (bfin_lq035_fb.pseudo_palette == NULL) {
773 pr_err("failed to allocate pseudo_palette\n"); 771 pr_err("failed to allocate pseudo_palette\n");
774 free_dma(CH_PPI); 772 ret = -ENOMEM;
775 free_ports(); 773 goto out_palette;
776 dma_free_coherent(NULL, TOTAL_VIDEO_MEM_SIZE, fb_buffer, 0);
777 return -ENOMEM;
778 } 774 }
779 775
780 if (fb_alloc_cmap(&bfin_lq035_fb.cmap, NBR_PALETTE, 0) < 0) { 776 if (fb_alloc_cmap(&bfin_lq035_fb.cmap, NBR_PALETTE, 0) < 0) {
781 pr_err("failed to allocate colormap (%d entries)\n", 777 pr_err("failed to allocate colormap (%d entries)\n",
782 NBR_PALETTE); 778 NBR_PALETTE);
783 free_dma(CH_PPI); 779 ret = -EFAULT;
784 free_ports(); 780 goto out_cmap;
785 dma_free_coherent(NULL, TOTAL_VIDEO_MEM_SIZE, fb_buffer, 0);
786 kfree(bfin_lq035_fb.pseudo_palette);
787 return -EFAULT;
788 } 781 }
789 782
790 if (register_framebuffer(&bfin_lq035_fb) < 0) { 783 if (register_framebuffer(&bfin_lq035_fb) < 0) {
791 pr_err("unable to register framebuffer\n"); 784 pr_err("unable to register framebuffer\n");
792 free_dma(CH_PPI); 785 ret = -EINVAL;
793 free_ports(); 786 goto out_reg;
794 dma_free_coherent(NULL, TOTAL_VIDEO_MEM_SIZE, fb_buffer, 0);
795 fb_buffer = NULL;
796 kfree(bfin_lq035_fb.pseudo_palette);
797 fb_dealloc_cmap(&bfin_lq035_fb.cmap);
798 return -EINVAL;
799 } 787 }
800 788
801 i2c_add_driver(&ad5280_driver); 789 i2c_add_driver(&ad5280_driver);
@@ -807,11 +795,31 @@ static int __devinit bfin_lq035_probe(struct platform_device *pdev)
807 795
808 lcd_dev = lcd_device_register(KBUILD_MODNAME, &pdev->dev, NULL, 796 lcd_dev = lcd_device_register(KBUILD_MODNAME, &pdev->dev, NULL,
809 &bfin_lcd_ops); 797 &bfin_lcd_ops);
798 if (IS_ERR(lcd_dev)) {
799 pr_err("unable to register lcd\n");
800 ret = PTR_ERR(lcd_dev);
801 goto out_lcd;
802 }
810 lcd_dev->props.max_contrast = 255, 803 lcd_dev->props.max_contrast = 255,
811 804
812 pr_info("initialized"); 805 pr_info("initialized");
813 806
814 return 0; 807 return 0;
808out_lcd:
809 unregister_framebuffer(&bfin_lq035_fb);
810out_reg:
811 fb_dealloc_cmap(&bfin_lq035_fb.cmap);
812out_cmap:
813 kfree(bfin_lq035_fb.pseudo_palette);
814out_palette:
815out_table:
816 dma_free_coherent(NULL, TOTAL_VIDEO_MEM_SIZE, fb_buffer, 0);
817 fb_buffer = NULL;
818out_dma_coherent:
819 free_ports();
820out_ports:
821 free_dma(CH_PPI);
822 return ret;
815} 823}
816 824
817static int __devexit bfin_lq035_remove(struct platform_device *pdev) 825static int __devexit bfin_lq035_remove(struct platform_device *pdev)
diff --git a/drivers/video/chipsfb.c b/drivers/video/chipsfb.c
index d637e1f53172..cff742abdc5d 100644
--- a/drivers/video/chipsfb.c
+++ b/drivers/video/chipsfb.c
@@ -460,10 +460,10 @@ static int chipsfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
460 if (!(state.event & PM_EVENT_SLEEP)) 460 if (!(state.event & PM_EVENT_SLEEP))
461 goto done; 461 goto done;
462 462
463 acquire_console_sem(); 463 console_lock();
464 chipsfb_blank(1, p); 464 chipsfb_blank(1, p);
465 fb_set_suspend(p, 1); 465 fb_set_suspend(p, 1);
466 release_console_sem(); 466 console_unlock();
467 done: 467 done:
468 pdev->dev.power.power_state = state; 468 pdev->dev.power.power_state = state;
469 return 0; 469 return 0;
@@ -473,10 +473,10 @@ static int chipsfb_pci_resume(struct pci_dev *pdev)
473{ 473{
474 struct fb_info *p = pci_get_drvdata(pdev); 474 struct fb_info *p = pci_get_drvdata(pdev);
475 475
476 acquire_console_sem(); 476 console_lock();
477 fb_set_suspend(p, 0); 477 fb_set_suspend(p, 0);
478 chipsfb_blank(0, p); 478 chipsfb_blank(0, p);
479 release_console_sem(); 479 console_unlock();
480 480
481 pdev->dev.power.power_state = PMSG_ON; 481 pdev->dev.power.power_state = PMSG_ON;
482 return 0; 482 return 0;
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 7ccc967831f0..9c092b8d64e6 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -375,14 +375,14 @@ static void fb_flashcursor(struct work_struct *work)
375 int c; 375 int c;
376 int mode; 376 int mode;
377 377
378 acquire_console_sem(); 378 console_lock();
379 if (ops && ops->currcon != -1) 379 if (ops && ops->currcon != -1)
380 vc = vc_cons[ops->currcon].d; 380 vc = vc_cons[ops->currcon].d;
381 381
382 if (!vc || !CON_IS_VISIBLE(vc) || 382 if (!vc || !CON_IS_VISIBLE(vc) ||
383 registered_fb[con2fb_map[vc->vc_num]] != info || 383 registered_fb[con2fb_map[vc->vc_num]] != info ||
384 vc->vc_deccm != 1) { 384 vc->vc_deccm != 1) {
385 release_console_sem(); 385 console_unlock();
386 return; 386 return;
387 } 387 }
388 388
@@ -392,7 +392,7 @@ static void fb_flashcursor(struct work_struct *work)
392 CM_ERASE : CM_DRAW; 392 CM_ERASE : CM_DRAW;
393 ops->cursor(vc, info, mode, softback_lines, get_color(vc, info, c, 1), 393 ops->cursor(vc, info, mode, softback_lines, get_color(vc, info, c, 1),
394 get_color(vc, info, c, 0)); 394 get_color(vc, info, c, 0));
395 release_console_sem(); 395 console_unlock();
396} 396}
397 397
398static void cursor_timer_handler(unsigned long dev_addr) 398static void cursor_timer_handler(unsigned long dev_addr)
@@ -836,7 +836,7 @@ static int set_con2fb_map(int unit, int newidx, int user)
836 836
837 found = search_fb_in_map(newidx); 837 found = search_fb_in_map(newidx);
838 838
839 acquire_console_sem(); 839 console_lock();
840 con2fb_map[unit] = newidx; 840 con2fb_map[unit] = newidx;
841 if (!err && !found) 841 if (!err && !found)
842 err = con2fb_acquire_newinfo(vc, info, unit, oldidx); 842 err = con2fb_acquire_newinfo(vc, info, unit, oldidx);
@@ -863,7 +863,7 @@ static int set_con2fb_map(int unit, int newidx, int user)
863 if (!search_fb_in_map(info_idx)) 863 if (!search_fb_in_map(info_idx))
864 info_idx = newidx; 864 info_idx = newidx;
865 865
866 release_console_sem(); 866 console_unlock();
867 return err; 867 return err;
868} 868}
869 869
@@ -3321,7 +3321,7 @@ static ssize_t store_rotate(struct device *device,
3321 if (fbcon_has_exited) 3321 if (fbcon_has_exited)
3322 return count; 3322 return count;
3323 3323
3324 acquire_console_sem(); 3324 console_lock();
3325 idx = con2fb_map[fg_console]; 3325 idx = con2fb_map[fg_console];
3326 3326
3327 if (idx == -1 || registered_fb[idx] == NULL) 3327 if (idx == -1 || registered_fb[idx] == NULL)
@@ -3331,7 +3331,7 @@ static ssize_t store_rotate(struct device *device,
3331 rotate = simple_strtoul(buf, last, 0); 3331 rotate = simple_strtoul(buf, last, 0);
3332 fbcon_rotate(info, rotate); 3332 fbcon_rotate(info, rotate);
3333err: 3333err:
3334 release_console_sem(); 3334 console_unlock();
3335 return count; 3335 return count;
3336} 3336}
3337 3337
@@ -3346,7 +3346,7 @@ static ssize_t store_rotate_all(struct device *device,
3346 if (fbcon_has_exited) 3346 if (fbcon_has_exited)
3347 return count; 3347 return count;
3348 3348
3349 acquire_console_sem(); 3349 console_lock();
3350 idx = con2fb_map[fg_console]; 3350 idx = con2fb_map[fg_console];
3351 3351
3352 if (idx == -1 || registered_fb[idx] == NULL) 3352 if (idx == -1 || registered_fb[idx] == NULL)
@@ -3356,7 +3356,7 @@ static ssize_t store_rotate_all(struct device *device,
3356 rotate = simple_strtoul(buf, last, 0); 3356 rotate = simple_strtoul(buf, last, 0);
3357 fbcon_rotate_all(info, rotate); 3357 fbcon_rotate_all(info, rotate);
3358err: 3358err:
3359 release_console_sem(); 3359 console_unlock();
3360 return count; 3360 return count;
3361} 3361}
3362 3362
@@ -3369,7 +3369,7 @@ static ssize_t show_rotate(struct device *device,
3369 if (fbcon_has_exited) 3369 if (fbcon_has_exited)
3370 return 0; 3370 return 0;
3371 3371
3372 acquire_console_sem(); 3372 console_lock();
3373 idx = con2fb_map[fg_console]; 3373 idx = con2fb_map[fg_console];
3374 3374
3375 if (idx == -1 || registered_fb[idx] == NULL) 3375 if (idx == -1 || registered_fb[idx] == NULL)
@@ -3378,7 +3378,7 @@ static ssize_t show_rotate(struct device *device,
3378 info = registered_fb[idx]; 3378 info = registered_fb[idx];
3379 rotate = fbcon_get_rotate(info); 3379 rotate = fbcon_get_rotate(info);
3380err: 3380err:
3381 release_console_sem(); 3381 console_unlock();
3382 return snprintf(buf, PAGE_SIZE, "%d\n", rotate); 3382 return snprintf(buf, PAGE_SIZE, "%d\n", rotate);
3383} 3383}
3384 3384
@@ -3392,7 +3392,7 @@ static ssize_t show_cursor_blink(struct device *device,
3392 if (fbcon_has_exited) 3392 if (fbcon_has_exited)
3393 return 0; 3393 return 0;
3394 3394
3395 acquire_console_sem(); 3395 console_lock();
3396 idx = con2fb_map[fg_console]; 3396 idx = con2fb_map[fg_console];
3397 3397
3398 if (idx == -1 || registered_fb[idx] == NULL) 3398 if (idx == -1 || registered_fb[idx] == NULL)
@@ -3406,7 +3406,7 @@ static ssize_t show_cursor_blink(struct device *device,
3406 3406
3407 blink = (ops->flags & FBCON_FLAGS_CURSOR_TIMER) ? 1 : 0; 3407 blink = (ops->flags & FBCON_FLAGS_CURSOR_TIMER) ? 1 : 0;
3408err: 3408err:
3409 release_console_sem(); 3409 console_unlock();
3410 return snprintf(buf, PAGE_SIZE, "%d\n", blink); 3410 return snprintf(buf, PAGE_SIZE, "%d\n", blink);
3411} 3411}
3412 3412
@@ -3421,7 +3421,7 @@ static ssize_t store_cursor_blink(struct device *device,
3421 if (fbcon_has_exited) 3421 if (fbcon_has_exited)
3422 return count; 3422 return count;
3423 3423
3424 acquire_console_sem(); 3424 console_lock();
3425 idx = con2fb_map[fg_console]; 3425 idx = con2fb_map[fg_console];
3426 3426
3427 if (idx == -1 || registered_fb[idx] == NULL) 3427 if (idx == -1 || registered_fb[idx] == NULL)
@@ -3443,7 +3443,7 @@ static ssize_t store_cursor_blink(struct device *device,
3443 } 3443 }
3444 3444
3445err: 3445err:
3446 release_console_sem(); 3446 console_unlock();
3447 return count; 3447 return count;
3448} 3448}
3449 3449
@@ -3482,7 +3482,7 @@ static void fbcon_start(void)
3482 if (num_registered_fb) { 3482 if (num_registered_fb) {
3483 int i; 3483 int i;
3484 3484
3485 acquire_console_sem(); 3485 console_lock();
3486 3486
3487 for (i = 0; i < FB_MAX; i++) { 3487 for (i = 0; i < FB_MAX; i++) {
3488 if (registered_fb[i] != NULL) { 3488 if (registered_fb[i] != NULL) {
@@ -3491,7 +3491,7 @@ static void fbcon_start(void)
3491 } 3491 }
3492 } 3492 }
3493 3493
3494 release_console_sem(); 3494 console_unlock();
3495 fbcon_takeover(0); 3495 fbcon_takeover(0);
3496 } 3496 }
3497} 3497}
@@ -3552,7 +3552,7 @@ static int __init fb_console_init(void)
3552{ 3552{
3553 int i; 3553 int i;
3554 3554
3555 acquire_console_sem(); 3555 console_lock();
3556 fb_register_client(&fbcon_event_notifier); 3556 fb_register_client(&fbcon_event_notifier);
3557 fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL, 3557 fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL,
3558 "fbcon"); 3558 "fbcon");
@@ -3568,7 +3568,7 @@ static int __init fb_console_init(void)
3568 for (i = 0; i < MAX_NR_CONSOLES; i++) 3568 for (i = 0; i < MAX_NR_CONSOLES; i++)
3569 con2fb_map[i] = -1; 3569 con2fb_map[i] = -1;
3570 3570
3571 release_console_sem(); 3571 console_unlock();
3572 fbcon_start(); 3572 fbcon_start();
3573 return 0; 3573 return 0;
3574} 3574}
@@ -3591,12 +3591,12 @@ static void __exit fbcon_deinit_device(void)
3591 3591
3592static void __exit fb_console_exit(void) 3592static void __exit fb_console_exit(void)
3593{ 3593{
3594 acquire_console_sem(); 3594 console_lock();
3595 fb_unregister_client(&fbcon_event_notifier); 3595 fb_unregister_client(&fbcon_event_notifier);
3596 fbcon_deinit_device(); 3596 fbcon_deinit_device();
3597 device_destroy(fb_class, MKDEV(0, 0)); 3597 device_destroy(fb_class, MKDEV(0, 0));
3598 fbcon_exit(); 3598 fbcon_exit();
3599 release_console_sem(); 3599 console_unlock();
3600 unregister_con_driver(&fb_con); 3600 unregister_con_driver(&fb_con);
3601} 3601}
3602 3602
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index c97491b8b39b..915fd74da7a2 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -202,11 +202,7 @@ static void vgacon_scrollback_init(int pitch)
202 } 202 }
203} 203}
204 204
205/* 205static void vgacon_scrollback_startup(void)
206 * Called only duing init so call of alloc_bootmen is ok.
207 * Marked __init_refok to silence modpost.
208 */
209static void __init_refok vgacon_scrollback_startup(void)
210{ 206{
211 vgacon_scrollback = kcalloc(CONFIG_VGACON_SOFT_SCROLLBACK_SIZE, 1024, GFP_NOWAIT); 207 vgacon_scrollback = kcalloc(CONFIG_VGACON_SOFT_SCROLLBACK_SIZE, 1024, GFP_NOWAIT);
212 vgacon_scrollback_init(vga_video_num_columns * 2); 208 vgacon_scrollback_init(vga_video_num_columns * 2);
diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
index c265aed09e04..8d61ef96eedd 100644
--- a/drivers/video/da8xx-fb.c
+++ b/drivers/video/da8xx-fb.c
@@ -1092,9 +1092,10 @@ static int __init fb_probe(struct platform_device *device)
1092 1092
1093irq_freq: 1093irq_freq:
1094#ifdef CONFIG_CPU_FREQ 1094#ifdef CONFIG_CPU_FREQ
1095 lcd_da8xx_cpufreq_deregister(par);
1096#endif
1095err_cpu_freq: 1097err_cpu_freq:
1096 unregister_framebuffer(da8xx_fb_info); 1098 unregister_framebuffer(da8xx_fb_info);
1097#endif
1098 1099
1099err_dealloc_cmap: 1100err_dealloc_cmap:
1100 fb_dealloc_cmap(&da8xx_fb_info->cmap); 1101 fb_dealloc_cmap(&da8xx_fb_info->cmap);
@@ -1130,14 +1131,14 @@ static int fb_suspend(struct platform_device *dev, pm_message_t state)
1130 struct fb_info *info = platform_get_drvdata(dev); 1131 struct fb_info *info = platform_get_drvdata(dev);
1131 struct da8xx_fb_par *par = info->par; 1132 struct da8xx_fb_par *par = info->par;
1132 1133
1133 acquire_console_sem(); 1134 console_lock();
1134 if (par->panel_power_ctrl) 1135 if (par->panel_power_ctrl)
1135 par->panel_power_ctrl(0); 1136 par->panel_power_ctrl(0);
1136 1137
1137 fb_set_suspend(info, 1); 1138 fb_set_suspend(info, 1);
1138 lcd_disable_raster(); 1139 lcd_disable_raster();
1139 clk_disable(par->lcdc_clk); 1140 clk_disable(par->lcdc_clk);
1140 release_console_sem(); 1141 console_unlock();
1141 1142
1142 return 0; 1143 return 0;
1143} 1144}
@@ -1146,14 +1147,14 @@ static int fb_resume(struct platform_device *dev)
1146 struct fb_info *info = platform_get_drvdata(dev); 1147 struct fb_info *info = platform_get_drvdata(dev);
1147 struct da8xx_fb_par *par = info->par; 1148 struct da8xx_fb_par *par = info->par;
1148 1149
1149 acquire_console_sem(); 1150 console_lock();
1150 if (par->panel_power_ctrl) 1151 if (par->panel_power_ctrl)
1151 par->panel_power_ctrl(1); 1152 par->panel_power_ctrl(1);
1152 1153
1153 clk_enable(par->lcdc_clk); 1154 clk_enable(par->lcdc_clk);
1154 lcd_enable_raster(); 1155 lcd_enable_raster();
1155 fb_set_suspend(info, 0); 1156 fb_set_suspend(info, 0);
1156 release_console_sem(); 1157 console_unlock();
1157 1158
1158 return 0; 1159 return 0;
1159} 1160}
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 4ac1201ad6c2..e2bf95370e40 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1036,11 +1036,11 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
1036 return -EFAULT; 1036 return -EFAULT;
1037 if (!lock_fb_info(info)) 1037 if (!lock_fb_info(info))
1038 return -ENODEV; 1038 return -ENODEV;
1039 acquire_console_sem(); 1039 console_lock();
1040 info->flags |= FBINFO_MISC_USEREVENT; 1040 info->flags |= FBINFO_MISC_USEREVENT;
1041 ret = fb_set_var(info, &var); 1041 ret = fb_set_var(info, &var);
1042 info->flags &= ~FBINFO_MISC_USEREVENT; 1042 info->flags &= ~FBINFO_MISC_USEREVENT;
1043 release_console_sem(); 1043 console_unlock();
1044 unlock_fb_info(info); 1044 unlock_fb_info(info);
1045 if (!ret && copy_to_user(argp, &var, sizeof(var))) 1045 if (!ret && copy_to_user(argp, &var, sizeof(var)))
1046 ret = -EFAULT; 1046 ret = -EFAULT;
@@ -1072,9 +1072,9 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
1072 return -EFAULT; 1072 return -EFAULT;
1073 if (!lock_fb_info(info)) 1073 if (!lock_fb_info(info))
1074 return -ENODEV; 1074 return -ENODEV;
1075 acquire_console_sem(); 1075 console_lock();
1076 ret = fb_pan_display(info, &var); 1076 ret = fb_pan_display(info, &var);
1077 release_console_sem(); 1077 console_unlock();
1078 unlock_fb_info(info); 1078 unlock_fb_info(info);
1079 if (ret == 0 && copy_to_user(argp, &var, sizeof(var))) 1079 if (ret == 0 && copy_to_user(argp, &var, sizeof(var)))
1080 return -EFAULT; 1080 return -EFAULT;
@@ -1119,11 +1119,11 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
1119 case FBIOBLANK: 1119 case FBIOBLANK:
1120 if (!lock_fb_info(info)) 1120 if (!lock_fb_info(info))
1121 return -ENODEV; 1121 return -ENODEV;
1122 acquire_console_sem(); 1122 console_lock();
1123 info->flags |= FBINFO_MISC_USEREVENT; 1123 info->flags |= FBINFO_MISC_USEREVENT;
1124 ret = fb_blank(info, arg); 1124 ret = fb_blank(info, arg);
1125 info->flags &= ~FBINFO_MISC_USEREVENT; 1125 info->flags &= ~FBINFO_MISC_USEREVENT;
1126 release_console_sem(); 1126 console_unlock();
1127 unlock_fb_info(info); 1127 unlock_fb_info(info);
1128 break; 1128 break;
1129 default: 1129 default:
diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c
index 0a08f1341227..f4a32779168b 100644
--- a/drivers/video/fbsysfs.c
+++ b/drivers/video/fbsysfs.c
@@ -90,11 +90,11 @@ static int activate(struct fb_info *fb_info, struct fb_var_screeninfo *var)
90 int err; 90 int err;
91 91
92 var->activate |= FB_ACTIVATE_FORCE; 92 var->activate |= FB_ACTIVATE_FORCE;
93 acquire_console_sem(); 93 console_lock();
94 fb_info->flags |= FBINFO_MISC_USEREVENT; 94 fb_info->flags |= FBINFO_MISC_USEREVENT;
95 err = fb_set_var(fb_info, var); 95 err = fb_set_var(fb_info, var);
96 fb_info->flags &= ~FBINFO_MISC_USEREVENT; 96 fb_info->flags &= ~FBINFO_MISC_USEREVENT;
97 release_console_sem(); 97 console_unlock();
98 if (err) 98 if (err)
99 return err; 99 return err;
100 return 0; 100 return 0;
@@ -175,7 +175,7 @@ static ssize_t store_modes(struct device *device,
175 if (i * sizeof(struct fb_videomode) != count) 175 if (i * sizeof(struct fb_videomode) != count)
176 return -EINVAL; 176 return -EINVAL;
177 177
178 acquire_console_sem(); 178 console_lock();
179 list_splice(&fb_info->modelist, &old_list); 179 list_splice(&fb_info->modelist, &old_list);
180 fb_videomode_to_modelist((const struct fb_videomode *)buf, i, 180 fb_videomode_to_modelist((const struct fb_videomode *)buf, i,
181 &fb_info->modelist); 181 &fb_info->modelist);
@@ -185,7 +185,7 @@ static ssize_t store_modes(struct device *device,
185 } else 185 } else
186 fb_destroy_modelist(&old_list); 186 fb_destroy_modelist(&old_list);
187 187
188 release_console_sem(); 188 console_unlock();
189 189
190 return 0; 190 return 0;
191} 191}
@@ -301,11 +301,11 @@ static ssize_t store_blank(struct device *device,
301 char *last = NULL; 301 char *last = NULL;
302 int err; 302 int err;
303 303
304 acquire_console_sem(); 304 console_lock();
305 fb_info->flags |= FBINFO_MISC_USEREVENT; 305 fb_info->flags |= FBINFO_MISC_USEREVENT;
306 err = fb_blank(fb_info, simple_strtoul(buf, &last, 0)); 306 err = fb_blank(fb_info, simple_strtoul(buf, &last, 0));
307 fb_info->flags &= ~FBINFO_MISC_USEREVENT; 307 fb_info->flags &= ~FBINFO_MISC_USEREVENT;
308 release_console_sem(); 308 console_unlock();
309 if (err < 0) 309 if (err < 0)
310 return err; 310 return err;
311 return count; 311 return count;
@@ -364,9 +364,9 @@ static ssize_t store_pan(struct device *device,
364 return -EINVAL; 364 return -EINVAL;
365 var.yoffset = simple_strtoul(last, &last, 0); 365 var.yoffset = simple_strtoul(last, &last, 0);
366 366
367 acquire_console_sem(); 367 console_lock();
368 err = fb_pan_display(fb_info, &var); 368 err = fb_pan_display(fb_info, &var);
369 release_console_sem(); 369 console_unlock();
370 370
371 if (err < 0) 371 if (err < 0)
372 return err; 372 return err;
@@ -399,9 +399,9 @@ static ssize_t store_fbstate(struct device *device,
399 399
400 state = simple_strtoul(buf, &last, 0); 400 state = simple_strtoul(buf, &last, 0);
401 401
402 acquire_console_sem(); 402 console_lock();
403 fb_set_suspend(fb_info, (int)state); 403 fb_set_suspend(fb_info, (int)state);
404 release_console_sem(); 404 console_unlock();
405 405
406 return count; 406 return count;
407} 407}
diff --git a/drivers/video/geode/gxfb_core.c b/drivers/video/geode/gxfb_core.c
index 70b1d9d51c96..b4f19db9bb54 100644
--- a/drivers/video/geode/gxfb_core.c
+++ b/drivers/video/geode/gxfb_core.c
@@ -344,10 +344,10 @@ static int gxfb_suspend(struct pci_dev *pdev, pm_message_t state)
344 struct fb_info *info = pci_get_drvdata(pdev); 344 struct fb_info *info = pci_get_drvdata(pdev);
345 345
346 if (state.event == PM_EVENT_SUSPEND) { 346 if (state.event == PM_EVENT_SUSPEND) {
347 acquire_console_sem(); 347 console_lock();
348 gx_powerdown(info); 348 gx_powerdown(info);
349 fb_set_suspend(info, 1); 349 fb_set_suspend(info, 1);
350 release_console_sem(); 350 console_unlock();
351 } 351 }
352 352
353 /* there's no point in setting PCI states; we emulate PCI, so 353 /* there's no point in setting PCI states; we emulate PCI, so
@@ -361,7 +361,7 @@ static int gxfb_resume(struct pci_dev *pdev)
361 struct fb_info *info = pci_get_drvdata(pdev); 361 struct fb_info *info = pci_get_drvdata(pdev);
362 int ret; 362 int ret;
363 363
364 acquire_console_sem(); 364 console_lock();
365 ret = gx_powerup(info); 365 ret = gx_powerup(info);
366 if (ret) { 366 if (ret) {
367 printk(KERN_ERR "gxfb: power up failed!\n"); 367 printk(KERN_ERR "gxfb: power up failed!\n");
@@ -369,7 +369,7 @@ static int gxfb_resume(struct pci_dev *pdev)
369 } 369 }
370 370
371 fb_set_suspend(info, 0); 371 fb_set_suspend(info, 0);
372 release_console_sem(); 372 console_unlock();
373 return 0; 373 return 0;
374} 374}
375#endif 375#endif
diff --git a/drivers/video/geode/lxfb_core.c b/drivers/video/geode/lxfb_core.c
index 39bdbedf43b4..416851ca8754 100644
--- a/drivers/video/geode/lxfb_core.c
+++ b/drivers/video/geode/lxfb_core.c
@@ -465,10 +465,10 @@ static int lxfb_suspend(struct pci_dev *pdev, pm_message_t state)
465 struct fb_info *info = pci_get_drvdata(pdev); 465 struct fb_info *info = pci_get_drvdata(pdev);
466 466
467 if (state.event == PM_EVENT_SUSPEND) { 467 if (state.event == PM_EVENT_SUSPEND) {
468 acquire_console_sem(); 468 console_lock();
469 lx_powerdown(info); 469 lx_powerdown(info);
470 fb_set_suspend(info, 1); 470 fb_set_suspend(info, 1);
471 release_console_sem(); 471 console_unlock();
472 } 472 }
473 473
474 /* there's no point in setting PCI states; we emulate PCI, so 474 /* there's no point in setting PCI states; we emulate PCI, so
@@ -482,7 +482,7 @@ static int lxfb_resume(struct pci_dev *pdev)
482 struct fb_info *info = pci_get_drvdata(pdev); 482 struct fb_info *info = pci_get_drvdata(pdev);
483 int ret; 483 int ret;
484 484
485 acquire_console_sem(); 485 console_lock();
486 ret = lx_powerup(info); 486 ret = lx_powerup(info);
487 if (ret) { 487 if (ret) {
488 printk(KERN_ERR "lxfb: power up failed!\n"); 488 printk(KERN_ERR "lxfb: power up failed!\n");
@@ -490,7 +490,7 @@ static int lxfb_resume(struct pci_dev *pdev)
490 } 490 }
491 491
492 fb_set_suspend(info, 0); 492 fb_set_suspend(info, 0);
493 release_console_sem(); 493 console_unlock();
494 return 0; 494 return 0;
495} 495}
496#else 496#else
diff --git a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c
index 5743ea25e818..318f6fb895b2 100644
--- a/drivers/video/i810/i810_main.c
+++ b/drivers/video/i810/i810_main.c
@@ -1574,7 +1574,7 @@ static int i810fb_suspend(struct pci_dev *dev, pm_message_t mesg)
1574 return 0; 1574 return 0;
1575 } 1575 }
1576 1576
1577 acquire_console_sem(); 1577 console_lock();
1578 fb_set_suspend(info, 1); 1578 fb_set_suspend(info, 1);
1579 1579
1580 if (info->fbops->fb_sync) 1580 if (info->fbops->fb_sync)
@@ -1587,7 +1587,7 @@ static int i810fb_suspend(struct pci_dev *dev, pm_message_t mesg)
1587 pci_save_state(dev); 1587 pci_save_state(dev);
1588 pci_disable_device(dev); 1588 pci_disable_device(dev);
1589 pci_set_power_state(dev, pci_choose_state(dev, mesg)); 1589 pci_set_power_state(dev, pci_choose_state(dev, mesg));
1590 release_console_sem(); 1590 console_unlock();
1591 1591
1592 return 0; 1592 return 0;
1593} 1593}
@@ -1605,7 +1605,7 @@ static int i810fb_resume(struct pci_dev *dev)
1605 return 0; 1605 return 0;
1606 } 1606 }
1607 1607
1608 acquire_console_sem(); 1608 console_lock();
1609 pci_set_power_state(dev, PCI_D0); 1609 pci_set_power_state(dev, PCI_D0);
1610 pci_restore_state(dev); 1610 pci_restore_state(dev);
1611 1611
@@ -1621,7 +1621,7 @@ static int i810fb_resume(struct pci_dev *dev)
1621 fb_set_suspend (info, 0); 1621 fb_set_suspend (info, 0);
1622 info->fbops->fb_blank(VESA_NO_BLANKING, info); 1622 info->fbops->fb_blank(VESA_NO_BLANKING, info);
1623fail: 1623fail:
1624 release_console_sem(); 1624 console_unlock();
1625 return 0; 1625 return 0;
1626} 1626}
1627/*********************************************************************** 1627/***********************************************************************
diff --git a/drivers/video/jz4740_fb.c b/drivers/video/jz4740_fb.c
index 670ecaa0385a..de366937c933 100644
--- a/drivers/video/jz4740_fb.c
+++ b/drivers/video/jz4740_fb.c
@@ -778,9 +778,9 @@ static int jzfb_suspend(struct device *dev)
778{ 778{
779 struct jzfb *jzfb = dev_get_drvdata(dev); 779 struct jzfb *jzfb = dev_get_drvdata(dev);
780 780
781 acquire_console_sem(); 781 console_lock();
782 fb_set_suspend(jzfb->fb, 1); 782 fb_set_suspend(jzfb->fb, 1);
783 release_console_sem(); 783 console_unlock();
784 784
785 mutex_lock(&jzfb->lock); 785 mutex_lock(&jzfb->lock);
786 if (jzfb->is_enabled) 786 if (jzfb->is_enabled)
@@ -800,9 +800,9 @@ static int jzfb_resume(struct device *dev)
800 jzfb_enable(jzfb); 800 jzfb_enable(jzfb);
801 mutex_unlock(&jzfb->lock); 801 mutex_unlock(&jzfb->lock);
802 802
803 acquire_console_sem(); 803 console_lock();
804 fb_set_suspend(jzfb->fb, 0); 804 fb_set_suspend(jzfb->fb, 0);
805 release_console_sem(); 805 console_unlock();
806 806
807 return 0; 807 return 0;
808} 808}
diff --git a/drivers/video/mx3fb.c b/drivers/video/mx3fb.c
index cb013919e9ce..7e3a490e8d76 100644
--- a/drivers/video/mx3fb.c
+++ b/drivers/video/mx3fb.c
@@ -1177,9 +1177,9 @@ static int mx3fb_suspend(struct platform_device *pdev, pm_message_t state)
1177 struct mx3fb_data *mx3fb = platform_get_drvdata(pdev); 1177 struct mx3fb_data *mx3fb = platform_get_drvdata(pdev);
1178 struct mx3fb_info *mx3_fbi = mx3fb->fbi->par; 1178 struct mx3fb_info *mx3_fbi = mx3fb->fbi->par;
1179 1179
1180 acquire_console_sem(); 1180 console_lock();
1181 fb_set_suspend(mx3fb->fbi, 1); 1181 fb_set_suspend(mx3fb->fbi, 1);
1182 release_console_sem(); 1182 console_unlock();
1183 1183
1184 if (mx3_fbi->blank == FB_BLANK_UNBLANK) { 1184 if (mx3_fbi->blank == FB_BLANK_UNBLANK) {
1185 sdc_disable_channel(mx3_fbi); 1185 sdc_disable_channel(mx3_fbi);
@@ -1202,9 +1202,9 @@ static int mx3fb_resume(struct platform_device *pdev)
1202 sdc_set_brightness(mx3fb, mx3fb->backlight_level); 1202 sdc_set_brightness(mx3fb, mx3fb->backlight_level);
1203 } 1203 }
1204 1204
1205 acquire_console_sem(); 1205 console_lock();
1206 fb_set_suspend(mx3fb->fbi, 0); 1206 fb_set_suspend(mx3fb->fbi, 0);
1207 release_console_sem(); 1207 console_unlock();
1208 1208
1209 return 0; 1209 return 0;
1210} 1210}
diff --git a/drivers/video/nuc900fb.c b/drivers/video/nuc900fb.c
index 62498bd662fc..f838d9e277f0 100644
--- a/drivers/video/nuc900fb.c
+++ b/drivers/video/nuc900fb.c
@@ -696,6 +696,8 @@ static int nuc900fb_remove(struct platform_device *pdev)
696 nuc900fb_stop_lcd(fbinfo); 696 nuc900fb_stop_lcd(fbinfo);
697 msleep(1); 697 msleep(1);
698 698
699 unregister_framebuffer(fbinfo);
700 nuc900fb_cpufreq_deregister(fbi);
699 nuc900fb_unmap_video_memory(fbinfo); 701 nuc900fb_unmap_video_memory(fbinfo);
700 702
701 iounmap(fbi->io); 703 iounmap(fbi->io);
@@ -723,7 +725,7 @@ static int nuc900fb_suspend(struct platform_device *dev, pm_message_t state)
723 struct fb_info *fbinfo = platform_get_drvdata(dev); 725 struct fb_info *fbinfo = platform_get_drvdata(dev);
724 struct nuc900fb_info *info = fbinfo->par; 726 struct nuc900fb_info *info = fbinfo->par;
725 727
726 nuc900fb_stop_lcd(); 728 nuc900fb_stop_lcd(fbinfo);
727 msleep(1); 729 msleep(1);
728 clk_disable(info->clk); 730 clk_disable(info->clk);
729 return 0; 731 return 0;
@@ -740,7 +742,7 @@ static int nuc900fb_resume(struct platform_device *dev)
740 msleep(1); 742 msleep(1);
741 743
742 nuc900fb_init_registers(fbinfo); 744 nuc900fb_init_registers(fbinfo);
743 nuc900fb_activate_var(bfinfo); 745 nuc900fb_activate_var(fbinfo);
744 746
745 return 0; 747 return 0;
746} 748}
diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
index efe10ff86d63..081dc4745274 100644
--- a/drivers/video/nvidia/nvidia.c
+++ b/drivers/video/nvidia/nvidia.c
@@ -1057,7 +1057,7 @@ static int nvidiafb_suspend(struct pci_dev *dev, pm_message_t mesg)
1057 1057
1058 if (mesg.event == PM_EVENT_PRETHAW) 1058 if (mesg.event == PM_EVENT_PRETHAW)
1059 mesg.event = PM_EVENT_FREEZE; 1059 mesg.event = PM_EVENT_FREEZE;
1060 acquire_console_sem(); 1060 console_lock();
1061 par->pm_state = mesg.event; 1061 par->pm_state = mesg.event;
1062 1062
1063 if (mesg.event & PM_EVENT_SLEEP) { 1063 if (mesg.event & PM_EVENT_SLEEP) {
@@ -1070,7 +1070,7 @@ static int nvidiafb_suspend(struct pci_dev *dev, pm_message_t mesg)
1070 } 1070 }
1071 dev->dev.power.power_state = mesg; 1071 dev->dev.power.power_state = mesg;
1072 1072
1073 release_console_sem(); 1073 console_unlock();
1074 return 0; 1074 return 0;
1075} 1075}
1076 1076
@@ -1079,7 +1079,7 @@ static int nvidiafb_resume(struct pci_dev *dev)
1079 struct fb_info *info = pci_get_drvdata(dev); 1079 struct fb_info *info = pci_get_drvdata(dev);
1080 struct nvidia_par *par = info->par; 1080 struct nvidia_par *par = info->par;
1081 1081
1082 acquire_console_sem(); 1082 console_lock();
1083 pci_set_power_state(dev, PCI_D0); 1083 pci_set_power_state(dev, PCI_D0);
1084 1084
1085 if (par->pm_state != PM_EVENT_FREEZE) { 1085 if (par->pm_state != PM_EVENT_FREEZE) {
@@ -1097,7 +1097,7 @@ static int nvidiafb_resume(struct pci_dev *dev)
1097 nvidiafb_blank(FB_BLANK_UNBLANK, info); 1097 nvidiafb_blank(FB_BLANK_UNBLANK, info);
1098 1098
1099fail: 1099fail:
1100 release_console_sem(); 1100 console_unlock();
1101 return 0; 1101 return 0;
1102} 1102}
1103#else 1103#else
diff --git a/drivers/video/ps3fb.c b/drivers/video/ps3fb.c
index 9c0144ee7ae5..65560a1a0439 100644
--- a/drivers/video/ps3fb.c
+++ b/drivers/video/ps3fb.c
@@ -513,9 +513,9 @@ static int ps3fb_release(struct fb_info *info, int user)
513 if (atomic_dec_and_test(&ps3fb.f_count)) { 513 if (atomic_dec_and_test(&ps3fb.f_count)) {
514 if (atomic_read(&ps3fb.ext_flip)) { 514 if (atomic_read(&ps3fb.ext_flip)) {
515 atomic_set(&ps3fb.ext_flip, 0); 515 atomic_set(&ps3fb.ext_flip, 0);
516 if (!try_acquire_console_sem()) { 516 if (console_trylock()) {
517 ps3fb_sync(info, 0); /* single buffer */ 517 ps3fb_sync(info, 0); /* single buffer */
518 release_console_sem(); 518 console_unlock();
519 } 519 }
520 } 520 }
521 } 521 }
@@ -830,14 +830,14 @@ static int ps3fb_ioctl(struct fb_info *info, unsigned int cmd,
830 if (vmode) { 830 if (vmode) {
831 var = info->var; 831 var = info->var;
832 fb_videomode_to_var(&var, vmode); 832 fb_videomode_to_var(&var, vmode);
833 acquire_console_sem(); 833 console_lock();
834 info->flags |= FBINFO_MISC_USEREVENT; 834 info->flags |= FBINFO_MISC_USEREVENT;
835 /* Force, in case only special bits changed */ 835 /* Force, in case only special bits changed */
836 var.activate |= FB_ACTIVATE_FORCE; 836 var.activate |= FB_ACTIVATE_FORCE;
837 par->new_mode_id = val; 837 par->new_mode_id = val;
838 retval = fb_set_var(info, &var); 838 retval = fb_set_var(info, &var);
839 info->flags &= ~FBINFO_MISC_USEREVENT; 839 info->flags &= ~FBINFO_MISC_USEREVENT;
840 release_console_sem(); 840 console_unlock();
841 } 841 }
842 break; 842 break;
843 } 843 }
@@ -881,9 +881,9 @@ static int ps3fb_ioctl(struct fb_info *info, unsigned int cmd,
881 break; 881 break;
882 882
883 dev_dbg(info->device, "PS3FB_IOCTL_FSEL:%d\n", val); 883 dev_dbg(info->device, "PS3FB_IOCTL_FSEL:%d\n", val);
884 acquire_console_sem(); 884 console_lock();
885 retval = ps3fb_sync(info, val); 885 retval = ps3fb_sync(info, val);
886 release_console_sem(); 886 console_unlock();
887 break; 887 break;
888 888
889 default: 889 default:
@@ -903,9 +903,9 @@ static int ps3fbd(void *arg)
903 set_current_state(TASK_INTERRUPTIBLE); 903 set_current_state(TASK_INTERRUPTIBLE);
904 if (ps3fb.is_kicked) { 904 if (ps3fb.is_kicked) {
905 ps3fb.is_kicked = 0; 905 ps3fb.is_kicked = 0;
906 acquire_console_sem(); 906 console_lock();
907 ps3fb_sync(info, 0); /* single buffer */ 907 ps3fb_sync(info, 0); /* single buffer */
908 release_console_sem(); 908 console_unlock();
909 } 909 }
910 schedule(); 910 schedule();
911 } 911 }
diff --git a/drivers/video/pxa168fb.c b/drivers/video/pxa168fb.c
index cea6403ae71c..35f61dd0cb3a 100644
--- a/drivers/video/pxa168fb.c
+++ b/drivers/video/pxa168fb.c
@@ -701,16 +701,12 @@ static int __devinit pxa168fb_probe(struct platform_device *pdev)
701 */ 701 */
702 pxa168fb_init_mode(info, mi); 702 pxa168fb_init_mode(info, mi);
703 703
704 ret = pxa168fb_check_var(&info->var, info);
705 if (ret)
706 goto failed_free_fbmem;
707
708 /* 704 /*
709 * Fill in sane defaults. 705 * Fill in sane defaults.
710 */ 706 */
711 ret = pxa168fb_check_var(&info->var, info); 707 ret = pxa168fb_check_var(&info->var, info);
712 if (ret) 708 if (ret)
713 goto failed; 709 goto failed_free_fbmem;
714 710
715 /* 711 /*
716 * enable controller clock 712 * enable controller clock
diff --git a/drivers/video/pxa3xx-gcu.c b/drivers/video/pxa3xx-gcu.c
index b81168df253d..cf4beb9dc9bb 100644
--- a/drivers/video/pxa3xx-gcu.c
+++ b/drivers/video/pxa3xx-gcu.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * pxa3xx-gc.c - Linux kernel module for PXA3xx graphics controllers 2 * pxa3xx-gcu.c - Linux kernel module for PXA3xx graphics controllers
3 * 3 *
4 * This driver needs a DirectFB counterpart in user space, communication 4 * This driver needs a DirectFB counterpart in user space, communication
5 * is handled via mmap()ed memory areas and an ioctl. 5 * is handled via mmap()ed memory areas and an ioctl.
@@ -421,7 +421,7 @@ pxa3xx_gcu_misc_write(struct file *filp, const char *buff,
421 buffer->next = priv->free; 421 buffer->next = priv->free;
422 priv->free = buffer; 422 priv->free = buffer;
423 spin_unlock_irqrestore(&priv->spinlock, flags); 423 spin_unlock_irqrestore(&priv->spinlock, flags);
424 return ret; 424 return -EFAULT;
425 } 425 }
426 426
427 buffer->length = words; 427 buffer->length = words;
diff --git a/drivers/video/s3fb.c b/drivers/video/s3fb.c
index dce8c97b4333..75738a928610 100644
--- a/drivers/video/s3fb.c
+++ b/drivers/video/s3fb.c
@@ -22,7 +22,7 @@
22#include <linux/svga.h> 22#include <linux/svga.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/pci.h> 24#include <linux/pci.h>
25#include <linux/console.h> /* Why should fb driver call console functions? because acquire_console_sem() */ 25#include <linux/console.h> /* Why should fb driver call console functions? because console_lock() */
26#include <video/vga.h> 26#include <video/vga.h>
27 27
28#ifdef CONFIG_MTRR 28#ifdef CONFIG_MTRR
@@ -1113,12 +1113,12 @@ static int s3_pci_suspend(struct pci_dev* dev, pm_message_t state)
1113 1113
1114 dev_info(info->device, "suspend\n"); 1114 dev_info(info->device, "suspend\n");
1115 1115
1116 acquire_console_sem(); 1116 console_lock();
1117 mutex_lock(&(par->open_lock)); 1117 mutex_lock(&(par->open_lock));
1118 1118
1119 if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) { 1119 if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) {
1120 mutex_unlock(&(par->open_lock)); 1120 mutex_unlock(&(par->open_lock));
1121 release_console_sem(); 1121 console_unlock();
1122 return 0; 1122 return 0;
1123 } 1123 }
1124 1124
@@ -1129,7 +1129,7 @@ static int s3_pci_suspend(struct pci_dev* dev, pm_message_t state)
1129 pci_set_power_state(dev, pci_choose_state(dev, state)); 1129 pci_set_power_state(dev, pci_choose_state(dev, state));
1130 1130
1131 mutex_unlock(&(par->open_lock)); 1131 mutex_unlock(&(par->open_lock));
1132 release_console_sem(); 1132 console_unlock();
1133 1133
1134 return 0; 1134 return 0;
1135} 1135}
@@ -1145,12 +1145,12 @@ static int s3_pci_resume(struct pci_dev* dev)
1145 1145
1146 dev_info(info->device, "resume\n"); 1146 dev_info(info->device, "resume\n");
1147 1147
1148 acquire_console_sem(); 1148 console_lock();
1149 mutex_lock(&(par->open_lock)); 1149 mutex_lock(&(par->open_lock));
1150 1150
1151 if (par->ref_count == 0) { 1151 if (par->ref_count == 0) {
1152 mutex_unlock(&(par->open_lock)); 1152 mutex_unlock(&(par->open_lock));
1153 release_console_sem(); 1153 console_unlock();
1154 return 0; 1154 return 0;
1155 } 1155 }
1156 1156
@@ -1159,7 +1159,7 @@ static int s3_pci_resume(struct pci_dev* dev)
1159 err = pci_enable_device(dev); 1159 err = pci_enable_device(dev);
1160 if (err) { 1160 if (err) {
1161 mutex_unlock(&(par->open_lock)); 1161 mutex_unlock(&(par->open_lock));
1162 release_console_sem(); 1162 console_unlock();
1163 dev_err(info->device, "error %d enabling device for resume\n", err); 1163 dev_err(info->device, "error %d enabling device for resume\n", err);
1164 return err; 1164 return err;
1165 } 1165 }
@@ -1169,7 +1169,7 @@ static int s3_pci_resume(struct pci_dev* dev)
1169 fb_set_suspend(info, 0); 1169 fb_set_suspend(info, 0);
1170 1170
1171 mutex_unlock(&(par->open_lock)); 1171 mutex_unlock(&(par->open_lock));
1172 release_console_sem(); 1172 console_unlock();
1173 1173
1174 return 0; 1174 return 0;
1175} 1175}
diff --git a/drivers/video/savage/savagefb_driver.c b/drivers/video/savage/savagefb_driver.c
index 842d157e1025..487911e2926c 100644
--- a/drivers/video/savage/savagefb_driver.c
+++ b/drivers/video/savage/savagefb_driver.c
@@ -2373,7 +2373,7 @@ static int savagefb_suspend(struct pci_dev *dev, pm_message_t mesg)
2373 if (mesg.event == PM_EVENT_FREEZE) 2373 if (mesg.event == PM_EVENT_FREEZE)
2374 return 0; 2374 return 0;
2375 2375
2376 acquire_console_sem(); 2376 console_lock();
2377 fb_set_suspend(info, 1); 2377 fb_set_suspend(info, 1);
2378 2378
2379 if (info->fbops->fb_sync) 2379 if (info->fbops->fb_sync)
@@ -2385,7 +2385,7 @@ static int savagefb_suspend(struct pci_dev *dev, pm_message_t mesg)
2385 pci_save_state(dev); 2385 pci_save_state(dev);
2386 pci_disable_device(dev); 2386 pci_disable_device(dev);
2387 pci_set_power_state(dev, pci_choose_state(dev, mesg)); 2387 pci_set_power_state(dev, pci_choose_state(dev, mesg));
2388 release_console_sem(); 2388 console_unlock();
2389 2389
2390 return 0; 2390 return 0;
2391} 2391}
@@ -2409,7 +2409,7 @@ static int savagefb_resume(struct pci_dev* dev)
2409 return 0; 2409 return 0;
2410 } 2410 }
2411 2411
2412 acquire_console_sem(); 2412 console_lock();
2413 2413
2414 pci_set_power_state(dev, PCI_D0); 2414 pci_set_power_state(dev, PCI_D0);
2415 pci_restore_state(dev); 2415 pci_restore_state(dev);
@@ -2423,7 +2423,7 @@ static int savagefb_resume(struct pci_dev* dev)
2423 savagefb_set_par(info); 2423 savagefb_set_par(info);
2424 fb_set_suspend(info, 0); 2424 fb_set_suspend(info, 0);
2425 savagefb_blank(FB_BLANK_UNBLANK, info); 2425 savagefb_blank(FB_BLANK_UNBLANK, info);
2426 release_console_sem(); 2426 console_unlock();
2427 2427
2428 return 0; 2428 return 0;
2429} 2429}
diff --git a/drivers/video/sh_mobile_hdmi.c b/drivers/video/sh_mobile_hdmi.c
index 74d9f546a2e8..2b9e56a6bde4 100644
--- a/drivers/video/sh_mobile_hdmi.c
+++ b/drivers/video/sh_mobile_hdmi.c
@@ -1151,7 +1151,7 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
1151 1151
1152 ch = info->par; 1152 ch = info->par;
1153 1153
1154 acquire_console_sem(); 1154 console_lock();
1155 1155
1156 /* HDMI plug in */ 1156 /* HDMI plug in */
1157 if (!sh_hdmi_must_reconfigure(hdmi) && 1157 if (!sh_hdmi_must_reconfigure(hdmi) &&
@@ -1171,7 +1171,7 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
1171 fb_set_suspend(info, 0); 1171 fb_set_suspend(info, 0);
1172 } 1172 }
1173 1173
1174 release_console_sem(); 1174 console_unlock();
1175 } else { 1175 } else {
1176 ret = 0; 1176 ret = 0;
1177 if (!hdmi->info) 1177 if (!hdmi->info)
@@ -1181,12 +1181,12 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
1181 fb_destroy_modedb(hdmi->monspec.modedb); 1181 fb_destroy_modedb(hdmi->monspec.modedb);
1182 hdmi->monspec.modedb = NULL; 1182 hdmi->monspec.modedb = NULL;
1183 1183
1184 acquire_console_sem(); 1184 console_lock();
1185 1185
1186 /* HDMI disconnect */ 1186 /* HDMI disconnect */
1187 fb_set_suspend(hdmi->info, 1); 1187 fb_set_suspend(hdmi->info, 1);
1188 1188
1189 release_console_sem(); 1189 console_unlock();
1190 pm_runtime_put(hdmi->dev); 1190 pm_runtime_put(hdmi->dev);
1191 } 1191 }
1192 1192
diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c
index bd4840a8a6b7..bf12e53aed5c 100644
--- a/drivers/video/sh_mobile_lcdcfb.c
+++ b/drivers/video/sh_mobile_lcdcfb.c
@@ -912,9 +912,9 @@ static int sh_mobile_release(struct fb_info *info, int user)
912 912
913 /* Nothing to reconfigure, when called from fbcon */ 913 /* Nothing to reconfigure, when called from fbcon */
914 if (user) { 914 if (user) {
915 acquire_console_sem(); 915 console_lock();
916 sh_mobile_fb_reconfig(info); 916 sh_mobile_fb_reconfig(info);
917 release_console_sem(); 917 console_unlock();
918 } 918 }
919 919
920 mutex_unlock(&ch->open_lock); 920 mutex_unlock(&ch->open_lock);
diff --git a/drivers/video/sm501fb.c b/drivers/video/sm501fb.c
index b7dc1800efa9..bcb44a594ebc 100644
--- a/drivers/video/sm501fb.c
+++ b/drivers/video/sm501fb.c
@@ -2010,9 +2010,9 @@ static int sm501fb_suspend_fb(struct sm501fb_info *info,
2010 2010
2011 /* tell console/fb driver we are suspending */ 2011 /* tell console/fb driver we are suspending */
2012 2012
2013 acquire_console_sem(); 2013 console_lock();
2014 fb_set_suspend(fbi, 1); 2014 fb_set_suspend(fbi, 1);
2015 release_console_sem(); 2015 console_unlock();
2016 2016
2017 /* backup copies in case chip is powered down over suspend */ 2017 /* backup copies in case chip is powered down over suspend */
2018 2018
@@ -2069,9 +2069,9 @@ static void sm501fb_resume_fb(struct sm501fb_info *info,
2069 memcpy_toio(par->cursor.k_addr, par->store_cursor, 2069 memcpy_toio(par->cursor.k_addr, par->store_cursor,
2070 par->cursor.size); 2070 par->cursor.size);
2071 2071
2072 acquire_console_sem(); 2072 console_lock();
2073 fb_set_suspend(fbi, 0); 2073 fb_set_suspend(fbi, 0);
2074 release_console_sem(); 2074 console_unlock();
2075 2075
2076 vfree(par->store_fb); 2076 vfree(par->store_fb);
2077 vfree(par->store_cursor); 2077 vfree(par->store_cursor);
diff --git a/drivers/video/tmiofb.c b/drivers/video/tmiofb.c
index 6913fe168c25..dfef88c803d4 100644
--- a/drivers/video/tmiofb.c
+++ b/drivers/video/tmiofb.c
@@ -25,7 +25,7 @@
25#include <linux/fb.h> 25#include <linux/fb.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28/* Why should fb driver call console functions? because acquire_console_sem() */ 28/* Why should fb driver call console functions? because console_lock() */
29#include <linux/console.h> 29#include <linux/console.h>
30#include <linux/mfd/core.h> 30#include <linux/mfd/core.h>
31#include <linux/mfd/tmio.h> 31#include <linux/mfd/tmio.h>
@@ -944,7 +944,7 @@ static int tmiofb_suspend(struct platform_device *dev, pm_message_t state)
944 struct mfd_cell *cell = dev->dev.platform_data; 944 struct mfd_cell *cell = dev->dev.platform_data;
945 int retval = 0; 945 int retval = 0;
946 946
947 acquire_console_sem(); 947 console_lock();
948 948
949 fb_set_suspend(info, 1); 949 fb_set_suspend(info, 1);
950 950
@@ -965,7 +965,7 @@ static int tmiofb_suspend(struct platform_device *dev, pm_message_t state)
965 if (cell->suspend) 965 if (cell->suspend)
966 retval = cell->suspend(dev); 966 retval = cell->suspend(dev);
967 967
968 release_console_sem(); 968 console_unlock();
969 969
970 return retval; 970 return retval;
971} 971}
@@ -976,7 +976,7 @@ static int tmiofb_resume(struct platform_device *dev)
976 struct mfd_cell *cell = dev->dev.platform_data; 976 struct mfd_cell *cell = dev->dev.platform_data;
977 int retval = 0; 977 int retval = 0;
978 978
979 acquire_console_sem(); 979 console_lock();
980 980
981 if (cell->resume) { 981 if (cell->resume) {
982 retval = cell->resume(dev); 982 retval = cell->resume(dev);
@@ -992,7 +992,7 @@ static int tmiofb_resume(struct platform_device *dev)
992 992
993 fb_set_suspend(info, 0); 993 fb_set_suspend(info, 0);
994out: 994out:
995 release_console_sem(); 995 console_unlock();
996 return retval; 996 return retval;
997} 997}
998#else 998#else
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index 289edd519527..4e66349e4366 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -1674,17 +1674,17 @@ static int parse_mode(const char *str, u32 *xres, u32 *yres)
1674#ifdef CONFIG_PM 1674#ifdef CONFIG_PM
1675static int viafb_suspend(void *unused) 1675static int viafb_suspend(void *unused)
1676{ 1676{
1677 acquire_console_sem(); 1677 console_lock();
1678 fb_set_suspend(viafbinfo, 1); 1678 fb_set_suspend(viafbinfo, 1);
1679 viafb_sync(viafbinfo); 1679 viafb_sync(viafbinfo);
1680 release_console_sem(); 1680 console_unlock();
1681 1681
1682 return 0; 1682 return 0;
1683} 1683}
1684 1684
1685static int viafb_resume(void *unused) 1685static int viafb_resume(void *unused)
1686{ 1686{
1687 acquire_console_sem(); 1687 console_lock();
1688 if (viaparinfo->shared->vdev->engine_mmio) 1688 if (viaparinfo->shared->vdev->engine_mmio)
1689 viafb_reset_engine(viaparinfo); 1689 viafb_reset_engine(viaparinfo);
1690 viafb_set_par(viafbinfo); 1690 viafb_set_par(viafbinfo);
@@ -1692,7 +1692,7 @@ static int viafb_resume(void *unused)
1692 viafb_set_par(viafbinfo1); 1692 viafb_set_par(viafbinfo1);
1693 fb_set_suspend(viafbinfo, 0); 1693 fb_set_suspend(viafbinfo, 0);
1694 1694
1695 release_console_sem(); 1695 console_unlock();
1696 return 0; 1696 return 0;
1697} 1697}
1698 1698
diff --git a/drivers/video/vt8623fb.c b/drivers/video/vt8623fb.c
index 85d76ec4c63e..a2965ab92cfb 100644
--- a/drivers/video/vt8623fb.c
+++ b/drivers/video/vt8623fb.c
@@ -23,7 +23,7 @@
23#include <linux/svga.h> 23#include <linux/svga.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/pci.h> 25#include <linux/pci.h>
26#include <linux/console.h> /* Why should fb driver call console functions? because acquire_console_sem() */ 26#include <linux/console.h> /* Why should fb driver call console functions? because console_lock() */
27#include <video/vga.h> 27#include <video/vga.h>
28 28
29#ifdef CONFIG_MTRR 29#ifdef CONFIG_MTRR
@@ -819,12 +819,12 @@ static int vt8623_pci_suspend(struct pci_dev* dev, pm_message_t state)
819 819
820 dev_info(info->device, "suspend\n"); 820 dev_info(info->device, "suspend\n");
821 821
822 acquire_console_sem(); 822 console_lock();
823 mutex_lock(&(par->open_lock)); 823 mutex_lock(&(par->open_lock));
824 824
825 if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) { 825 if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) {
826 mutex_unlock(&(par->open_lock)); 826 mutex_unlock(&(par->open_lock));
827 release_console_sem(); 827 console_unlock();
828 return 0; 828 return 0;
829 } 829 }
830 830
@@ -835,7 +835,7 @@ static int vt8623_pci_suspend(struct pci_dev* dev, pm_message_t state)
835 pci_set_power_state(dev, pci_choose_state(dev, state)); 835 pci_set_power_state(dev, pci_choose_state(dev, state));
836 836
837 mutex_unlock(&(par->open_lock)); 837 mutex_unlock(&(par->open_lock));
838 release_console_sem(); 838 console_unlock();
839 839
840 return 0; 840 return 0;
841} 841}
@@ -850,7 +850,7 @@ static int vt8623_pci_resume(struct pci_dev* dev)
850 850
851 dev_info(info->device, "resume\n"); 851 dev_info(info->device, "resume\n");
852 852
853 acquire_console_sem(); 853 console_lock();
854 mutex_lock(&(par->open_lock)); 854 mutex_lock(&(par->open_lock));
855 855
856 if (par->ref_count == 0) 856 if (par->ref_count == 0)
@@ -869,7 +869,7 @@ static int vt8623_pci_resume(struct pci_dev* dev)
869 869
870fail: 870fail:
871 mutex_unlock(&(par->open_lock)); 871 mutex_unlock(&(par->open_lock));
872 release_console_sem(); 872 console_unlock();
873 873
874 return 0; 874 return 0;
875} 875}
diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c
index 3e6934d4bea8..a20218c2fda8 100644
--- a/drivers/video/xen-fbfront.c
+++ b/drivers/video/xen-fbfront.c
@@ -491,12 +491,12 @@ xenfb_make_preferred_console(void)
491 if (console_set_on_cmdline) 491 if (console_set_on_cmdline)
492 return; 492 return;
493 493
494 acquire_console_sem(); 494 console_lock();
495 for_each_console(c) { 495 for_each_console(c) {
496 if (!strcmp(c->name, "tty") && c->index == 0) 496 if (!strcmp(c->name, "tty") && c->index == 0)
497 break; 497 break;
498 } 498 }
499 release_console_sem(); 499 console_unlock();
500 if (c) { 500 if (c) {
501 unregister_console(c); 501 unregister_console(c);
502 c->flags |= CON_CONSDEV; 502 c->flags |= CON_CONSDEV;
diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c
index 7ed36536e754..f1c68629f277 100644
--- a/fs/cifs/cifs_dfs_ref.c
+++ b/fs/cifs/cifs_dfs_ref.c
@@ -297,7 +297,6 @@ static struct vfsmount *cifs_dfs_do_automount(struct dentry *mntpt)
297 297
298 cifs_sb = CIFS_SB(mntpt->d_inode->i_sb); 298 cifs_sb = CIFS_SB(mntpt->d_inode->i_sb);
299 tlink = cifs_sb_tlink(cifs_sb); 299 tlink = cifs_sb_tlink(cifs_sb);
300 mnt = ERR_PTR(-EINVAL);
301 if (IS_ERR(tlink)) { 300 if (IS_ERR(tlink)) {
302 mnt = ERR_CAST(tlink); 301 mnt = ERR_CAST(tlink);
303 goto free_full_path; 302 goto free_full_path;
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 5bfb75346cb0..edd5b29b53c9 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -166,6 +166,9 @@ struct TCP_Server_Info {
166 struct socket *ssocket; 166 struct socket *ssocket;
167 struct sockaddr_storage dstaddr; 167 struct sockaddr_storage dstaddr;
168 struct sockaddr_storage srcaddr; /* locally bind to this IP */ 168 struct sockaddr_storage srcaddr; /* locally bind to this IP */
169#ifdef CONFIG_NET_NS
170 struct net *net;
171#endif
169 wait_queue_head_t response_q; 172 wait_queue_head_t response_q;
170 wait_queue_head_t request_q; /* if more than maxmpx to srvr must block*/ 173 wait_queue_head_t request_q; /* if more than maxmpx to srvr must block*/
171 struct list_head pending_mid_q; 174 struct list_head pending_mid_q;
@@ -217,6 +220,36 @@ struct TCP_Server_Info {
217}; 220};
218 221
219/* 222/*
223 * Macros to allow the TCP_Server_Info->net field and related code to drop out
224 * when CONFIG_NET_NS isn't set.
225 */
226
227#ifdef CONFIG_NET_NS
228
229static inline struct net *cifs_net_ns(struct TCP_Server_Info *srv)
230{
231 return srv->net;
232}
233
234static inline void cifs_set_net_ns(struct TCP_Server_Info *srv, struct net *net)
235{
236 srv->net = net;
237}
238
239#else
240
241static inline struct net *cifs_net_ns(struct TCP_Server_Info *srv)
242{
243 return &init_net;
244}
245
246static inline void cifs_set_net_ns(struct TCP_Server_Info *srv, struct net *net)
247{
248}
249
250#endif
251
252/*
220 * Session structure. One of these for each uid session with a particular host 253 * Session structure. One of these for each uid session with a particular host
221 */ 254 */
222struct cifsSesInfo { 255struct cifsSesInfo {
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 18d3c7724d6e..0cc3b81c2e84 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1568,6 +1568,9 @@ cifs_find_tcp_session(struct sockaddr *addr, struct smb_vol *vol)
1568 1568
1569 spin_lock(&cifs_tcp_ses_lock); 1569 spin_lock(&cifs_tcp_ses_lock);
1570 list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) { 1570 list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) {
1571 if (!net_eq(cifs_net_ns(server), current->nsproxy->net_ns))
1572 continue;
1573
1571 if (!match_address(server, addr, 1574 if (!match_address(server, addr,
1572 (struct sockaddr *)&vol->srcaddr)) 1575 (struct sockaddr *)&vol->srcaddr))
1573 continue; 1576 continue;
@@ -1598,6 +1601,8 @@ cifs_put_tcp_session(struct TCP_Server_Info *server)
1598 return; 1601 return;
1599 } 1602 }
1600 1603
1604 put_net(cifs_net_ns(server));
1605
1601 list_del_init(&server->tcp_ses_list); 1606 list_del_init(&server->tcp_ses_list);
1602 spin_unlock(&cifs_tcp_ses_lock); 1607 spin_unlock(&cifs_tcp_ses_lock);
1603 1608
@@ -1672,6 +1677,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info)
1672 goto out_err; 1677 goto out_err;
1673 } 1678 }
1674 1679
1680 cifs_set_net_ns(tcp_ses, get_net(current->nsproxy->net_ns));
1675 tcp_ses->hostname = extract_hostname(volume_info->UNC); 1681 tcp_ses->hostname = extract_hostname(volume_info->UNC);
1676 if (IS_ERR(tcp_ses->hostname)) { 1682 if (IS_ERR(tcp_ses->hostname)) {
1677 rc = PTR_ERR(tcp_ses->hostname); 1683 rc = PTR_ERR(tcp_ses->hostname);
@@ -1752,6 +1758,8 @@ cifs_get_tcp_session(struct smb_vol *volume_info)
1752out_err_crypto_release: 1758out_err_crypto_release:
1753 cifs_crypto_shash_release(tcp_ses); 1759 cifs_crypto_shash_release(tcp_ses);
1754 1760
1761 put_net(cifs_net_ns(tcp_ses));
1762
1755out_err: 1763out_err:
1756 if (tcp_ses) { 1764 if (tcp_ses) {
1757 if (!IS_ERR(tcp_ses->hostname)) 1765 if (!IS_ERR(tcp_ses->hostname))
@@ -2263,8 +2271,8 @@ generic_ip_connect(struct TCP_Server_Info *server)
2263 } 2271 }
2264 2272
2265 if (socket == NULL) { 2273 if (socket == NULL) {
2266 rc = sock_create_kern(sfamily, SOCK_STREAM, 2274 rc = __sock_create(cifs_net_ns(server), sfamily, SOCK_STREAM,
2267 IPPROTO_TCP, &socket); 2275 IPPROTO_TCP, &socket, 1);
2268 if (rc < 0) { 2276 if (rc < 0) {
2269 cERROR(1, "Error %d creating socket", rc); 2277 cERROR(1, "Error %d creating socket", rc);
2270 server->ssocket = NULL; 2278 server->ssocket = NULL;
diff --git a/fs/dcache.c b/fs/dcache.c
index 9f493ee4dcba..2a6bd9a4ae97 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -176,6 +176,7 @@ static void d_free(struct dentry *dentry)
176 176
177/** 177/**
178 * dentry_rcuwalk_barrier - invalidate in-progress rcu-walk lookups 178 * dentry_rcuwalk_barrier - invalidate in-progress rcu-walk lookups
179 * @dentry: the target dentry
179 * After this call, in-progress rcu-walk path lookup will fail. This 180 * After this call, in-progress rcu-walk path lookup will fail. This
180 * should be called after unhashing, and after changing d_inode (if 181 * should be called after unhashing, and after changing d_inode (if
181 * the dentry has not already been unhashed). 182 * the dentry has not already been unhashed).
@@ -281,6 +282,7 @@ static void dentry_lru_move_tail(struct dentry *dentry)
281/** 282/**
282 * d_kill - kill dentry and return parent 283 * d_kill - kill dentry and return parent
283 * @dentry: dentry to kill 284 * @dentry: dentry to kill
285 * @parent: parent dentry
284 * 286 *
285 * The dentry must already be unhashed and removed from the LRU. 287 * The dentry must already be unhashed and removed from the LRU.
286 * 288 *
@@ -1973,7 +1975,7 @@ out:
1973/** 1975/**
1974 * d_validate - verify dentry provided from insecure source (deprecated) 1976 * d_validate - verify dentry provided from insecure source (deprecated)
1975 * @dentry: The dentry alleged to be valid child of @dparent 1977 * @dentry: The dentry alleged to be valid child of @dparent
1976 * @parent: The parent dentry (known to be valid) 1978 * @dparent: The parent dentry (known to be valid)
1977 * 1979 *
1978 * An insecure source has sent us a dentry, here we verify it and dget() it. 1980 * An insecure source has sent us a dentry, here we verify it and dget() it.
1979 * This is used by ncpfs in its readdir implementation. 1981 * This is used by ncpfs in its readdir implementation.
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 0994f6a76c07..58fd707174e1 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -704,7 +704,8 @@ skip_mount_setup:
704 sbp[0]->s_state = 704 sbp[0]->s_state =
705 cpu_to_le16(le16_to_cpu(sbp[0]->s_state) & ~NILFS_VALID_FS); 705 cpu_to_le16(le16_to_cpu(sbp[0]->s_state) & ~NILFS_VALID_FS);
706 /* synchronize sbp[1] with sbp[0] */ 706 /* synchronize sbp[1] with sbp[0] */
707 memcpy(sbp[1], sbp[0], nilfs->ns_sbsize); 707 if (sbp[1])
708 memcpy(sbp[1], sbp[0], nilfs->ns_sbsize);
708 return nilfs_commit_super(sbi, NILFS_SB_COMMIT_ALL); 709 return nilfs_commit_super(sbi, NILFS_SB_COMMIT_ALL);
709} 710}
710 711
diff --git a/fs/proc/consoles.c b/fs/proc/consoles.c
index eafc22ab1fdd..b701eaa482bf 100644
--- a/fs/proc/consoles.c
+++ b/fs/proc/consoles.c
@@ -67,7 +67,7 @@ static void *c_start(struct seq_file *m, loff_t *pos)
67 struct console *con; 67 struct console *con;
68 loff_t off = 0; 68 loff_t off = 0;
69 69
70 acquire_console_sem(); 70 console_lock();
71 for_each_console(con) 71 for_each_console(con)
72 if (off++ == *pos) 72 if (off++ == *pos)
73 break; 73 break;
@@ -84,7 +84,7 @@ static void *c_next(struct seq_file *m, void *v, loff_t *pos)
84 84
85static void c_stop(struct seq_file *m, void *v) 85static void c_stop(struct seq_file *m, void *v)
86{ 86{
87 release_console_sem(); 87 console_unlock();
88} 88}
89 89
90static const struct seq_operations consoles_op = { 90static const struct seq_operations consoles_op = {
diff --git a/fs/squashfs/block.c b/fs/squashfs/block.c
index 2fb2882f0fa7..8ab48bc2fa7d 100644
--- a/fs/squashfs/block.c
+++ b/fs/squashfs/block.c
@@ -63,6 +63,14 @@ static struct buffer_head *get_block_length(struct super_block *sb,
63 *length = (unsigned char) bh->b_data[*offset] | 63 *length = (unsigned char) bh->b_data[*offset] |
64 (unsigned char) bh->b_data[*offset + 1] << 8; 64 (unsigned char) bh->b_data[*offset + 1] << 8;
65 *offset += 2; 65 *offset += 2;
66
67 if (*offset == msblk->devblksize) {
68 put_bh(bh);
69 bh = sb_bread(sb, ++(*cur_index));
70 if (bh == NULL)
71 return NULL;
72 *offset = 0;
73 }
66 } 74 }
67 75
68 return bh; 76 return bh;
diff --git a/fs/squashfs/xz_wrapper.c b/fs/squashfs/xz_wrapper.c
index 856756ca5ee4..c4eb40018256 100644
--- a/fs/squashfs/xz_wrapper.c
+++ b/fs/squashfs/xz_wrapper.c
@@ -95,12 +95,6 @@ static int squashfs_xz_uncompress(struct squashfs_sb_info *msblk, void **buffer,
95 if (!buffer_uptodate(bh[k])) 95 if (!buffer_uptodate(bh[k]))
96 goto release_mutex; 96 goto release_mutex;
97 97
98 if (avail == 0) {
99 offset = 0;
100 put_bh(bh[k++]);
101 continue;
102 }
103
104 stream->buf.in = bh[k]->b_data + offset; 98 stream->buf.in = bh[k]->b_data + offset;
105 stream->buf.in_size = avail; 99 stream->buf.in_size = avail;
106 stream->buf.in_pos = 0; 100 stream->buf.in_pos = 0;
diff --git a/fs/squashfs/zlib_wrapper.c b/fs/squashfs/zlib_wrapper.c
index 818a5e063faf..4661ae2b1cec 100644
--- a/fs/squashfs/zlib_wrapper.c
+++ b/fs/squashfs/zlib_wrapper.c
@@ -82,12 +82,6 @@ static int zlib_uncompress(struct squashfs_sb_info *msblk, void **buffer,
82 if (!buffer_uptodate(bh[k])) 82 if (!buffer_uptodate(bh[k]))
83 goto release_mutex; 83 goto release_mutex;
84 84
85 if (avail == 0) {
86 offset = 0;
87 put_bh(bh[k++]);
88 continue;
89 }
90
91 stream->next_in = bh[k]->b_data + offset; 85 stream->next_in = bh[k]->b_data + offset;
92 stream->avail_in = avail; 86 stream->avail_in = avail;
93 offset = 0; 87 offset = 0;
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 68649336c4ad..6ebb81030d2d 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -364,6 +364,13 @@
364 VMLINUX_SYMBOL(__start___param) = .; \ 364 VMLINUX_SYMBOL(__start___param) = .; \
365 *(__param) \ 365 *(__param) \
366 VMLINUX_SYMBOL(__stop___param) = .; \ 366 VMLINUX_SYMBOL(__stop___param) = .; \
367 } \
368 \
369 /* Built-in module versions. */ \
370 __modver : AT(ADDR(__modver) - LOAD_OFFSET) { \
371 VMLINUX_SYMBOL(__start___modver) = .; \
372 *(__modver) \
373 VMLINUX_SYMBOL(__stop___modver) = .; \
367 . = ALIGN((align)); \ 374 . = ALIGN((align)); \
368 VMLINUX_SYMBOL(__end_rodata) = .; \ 375 VMLINUX_SYMBOL(__end_rodata) = .; \
369 } \ 376 } \
diff --git a/include/drm/radeon_drm.h b/include/drm/radeon_drm.h
index e95a86b8b689..e5c607a02d57 100644
--- a/include/drm/radeon_drm.h
+++ b/include/drm/radeon_drm.h
@@ -907,6 +907,7 @@ struct drm_radeon_cs {
907#define RADEON_INFO_TILING_CONFIG 0x06 907#define RADEON_INFO_TILING_CONFIG 0x06
908#define RADEON_INFO_WANT_HYPERZ 0x07 908#define RADEON_INFO_WANT_HYPERZ 0x07
909#define RADEON_INFO_WANT_CMASK 0x08 /* get access to CMASK on r300 */ 909#define RADEON_INFO_WANT_CMASK 0x08 /* get access to CMASK on r300 */
910#define RADEON_INFO_CLOCK_CRYSTAL_FREQ 0x09 /* clock crystal frequency */
910 911
911struct drm_radeon_info { 912struct drm_radeon_info {
912 uint32_t request; 913 uint32_t request;
diff --git a/include/linux/console.h b/include/linux/console.h
index 9774fe6a1a97..7453cfd593c8 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -139,9 +139,9 @@ extern int update_console_cmdline(char *name, int idx, char *name_new, int idx_n
139extern void register_console(struct console *); 139extern void register_console(struct console *);
140extern int unregister_console(struct console *); 140extern int unregister_console(struct console *);
141extern struct console *console_drivers; 141extern struct console *console_drivers;
142extern void acquire_console_sem(void); 142extern void console_lock(void);
143extern int try_acquire_console_sem(void); 143extern int console_trylock(void);
144extern void release_console_sem(void); 144extern void console_unlock(void);
145extern void console_conditional_schedule(void); 145extern void console_conditional_schedule(void);
146extern void console_unblank(void); 146extern void console_unblank(void);
147extern struct tty_driver *console_device(int *); 147extern struct tty_driver *console_device(int *);
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index a3b148a91874..0b84c61607e8 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -249,7 +249,7 @@ static inline enum zone_type gfp_zone(gfp_t flags)
249 ((1 << ZONES_SHIFT) - 1); 249 ((1 << ZONES_SHIFT) - 1);
250 250
251 if (__builtin_constant_p(bit)) 251 if (__builtin_constant_p(bit))
252 MAYBE_BUILD_BUG_ON((GFP_ZONE_BAD >> bit) & 1); 252 BUILD_BUG_ON((GFP_ZONE_BAD >> bit) & 1);
253 else { 253 else {
254#ifdef CONFIG_DEBUG_VM 254#ifdef CONFIG_DEBUG_VM
255 BUG_ON((GFP_ZONE_BAD >> bit) & 1); 255 BUG_ON((GFP_ZONE_BAD >> bit) & 1);
diff --git a/include/linux/input/bu21013.h b/include/linux/input/bu21013.h
index e470d387dd49..05e03284b92a 100644
--- a/include/linux/input/bu21013.h
+++ b/include/linux/input/bu21013.h
@@ -12,8 +12,6 @@
12 * @cs_en: pointer to the cs enable function 12 * @cs_en: pointer to the cs enable function
13 * @cs_dis: pointer to the cs disable function 13 * @cs_dis: pointer to the cs disable function
14 * @irq_read_val: pointer to read the pen irq value function 14 * @irq_read_val: pointer to read the pen irq value function
15 * @x_max_res: xmax resolution
16 * @y_max_res: ymax resolution
17 * @touch_x_max: touch x max 15 * @touch_x_max: touch x max
18 * @touch_y_max: touch y max 16 * @touch_y_max: touch y max
19 * @cs_pin: chip select pin 17 * @cs_pin: chip select pin
@@ -29,8 +27,6 @@ struct bu21013_platform_device {
29 int (*cs_en)(int reset_pin); 27 int (*cs_en)(int reset_pin);
30 int (*cs_dis)(int reset_pin); 28 int (*cs_dis)(int reset_pin);
31 int (*irq_read_val)(void); 29 int (*irq_read_val)(void);
32 int x_max_res;
33 int y_max_res;
34 int touch_x_max; 30 int touch_x_max;
35 int touch_y_max; 31 int touch_y_max;
36 unsigned int cs_pin; 32 unsigned int cs_pin;
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index d07d8057e440..e2f4d6af2125 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -575,12 +575,6 @@ struct sysinfo {
575 char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */ 575 char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
576}; 576};
577 577
578/* Force a compilation error if condition is true */
579#define BUILD_BUG_ON(condition) ((void)BUILD_BUG_ON_ZERO(condition))
580
581/* Force a compilation error if condition is constant and true */
582#define MAYBE_BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2 * !!(cond)]))
583
584/* Force a compilation error if a constant expression is not a power of 2 */ 578/* Force a compilation error if a constant expression is not a power of 2 */
585#define BUILD_BUG_ON_NOT_POWER_OF_2(n) \ 579#define BUILD_BUG_ON_NOT_POWER_OF_2(n) \
586 BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0)) 580 BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0))
@@ -592,6 +586,32 @@ struct sysinfo {
592#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) 586#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
593#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) 587#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); }))
594 588
589/**
590 * BUILD_BUG_ON - break compile if a condition is true.
591 * @cond: the condition which the compiler should know is false.
592 *
593 * If you have some code which relies on certain constants being equal, or
594 * other compile-time-evaluated condition, you should use BUILD_BUG_ON to
595 * detect if someone changes it.
596 *
597 * The implementation uses gcc's reluctance to create a negative array, but
598 * gcc (as of 4.4) only emits that error for obvious cases (eg. not arguments
599 * to inline functions). So as a fallback we use the optimizer; if it can't
600 * prove the condition is false, it will cause a link error on the undefined
601 * "__build_bug_on_failed". This error message can be harder to track down
602 * though, hence the two different methods.
603 */
604#ifndef __OPTIMIZE__
605#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
606#else
607extern int __build_bug_on_failed;
608#define BUILD_BUG_ON(condition) \
609 do { \
610 ((void)sizeof(char[1 - 2*!!(condition)])); \
611 if (condition) __build_bug_on_failed = 1; \
612 } while(0)
613#endif
614
595/* Trap pasters of __FUNCTION__ at compile-time */ 615/* Trap pasters of __FUNCTION__ at compile-time */
596#define __FUNCTION__ (__func__) 616#define __FUNCTION__ (__func__)
597 617
diff --git a/include/linux/kmemcheck.h b/include/linux/kmemcheck.h
index 08d7dc4ddf40..39f8453239f7 100644
--- a/include/linux/kmemcheck.h
+++ b/include/linux/kmemcheck.h
@@ -76,7 +76,7 @@ bool kmemcheck_is_obj_initialized(unsigned long addr, size_t size);
76 \ 76 \
77 _n = (long) &((ptr)->name##_end) \ 77 _n = (long) &((ptr)->name##_end) \
78 - (long) &((ptr)->name##_begin); \ 78 - (long) &((ptr)->name##_begin); \
79 MAYBE_BUILD_BUG_ON(_n < 0); \ 79 BUILD_BUG_ON(_n < 0); \
80 \ 80 \
81 kmemcheck_mark_initialized(&((ptr)->name##_begin), _n); \ 81 kmemcheck_mark_initialized(&((ptr)->name##_begin), _n); \
82 } while (0) 82 } while (0)
diff --git a/include/linux/mmc/sh_mmcif.h b/include/linux/mmc/sh_mmcif.h
index bf173502d744..38d393092812 100644
--- a/include/linux/mmc/sh_mmcif.h
+++ b/include/linux/mmc/sh_mmcif.h
@@ -94,12 +94,12 @@ struct sh_mmcif_plat_data {
94 94
95static inline u32 sh_mmcif_readl(void __iomem *addr, int reg) 95static inline u32 sh_mmcif_readl(void __iomem *addr, int reg)
96{ 96{
97 return readl(addr + reg); 97 return __raw_readl(addr + reg);
98} 98}
99 99
100static inline void sh_mmcif_writel(void __iomem *addr, int reg, u32 val) 100static inline void sh_mmcif_writel(void __iomem *addr, int reg, u32 val)
101{ 101{
102 writel(val, addr + reg); 102 __raw_writel(val, addr + reg);
103} 103}
104 104
105#define SH_MMCIF_BBS 512 /* boot block size */ 105#define SH_MMCIF_BBS 512 /* boot block size */
diff --git a/include/linux/module.h b/include/linux/module.h
index 8b17fd8c790d..e7c6385c6683 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -58,6 +58,12 @@ struct module_attribute {
58 void (*free)(struct module *); 58 void (*free)(struct module *);
59}; 59};
60 60
61struct module_version_attribute {
62 struct module_attribute mattr;
63 const char *module_name;
64 const char *version;
65};
66
61struct module_kobject 67struct module_kobject
62{ 68{
63 struct kobject kobj; 69 struct kobject kobj;
@@ -161,7 +167,28 @@ extern struct module __this_module;
161 Using this automatically adds a checksum of the .c files and the 167 Using this automatically adds a checksum of the .c files and the
162 local headers in "srcversion". 168 local headers in "srcversion".
163*/ 169*/
170
171#if defined(MODULE) || !defined(CONFIG_SYSFS)
164#define MODULE_VERSION(_version) MODULE_INFO(version, _version) 172#define MODULE_VERSION(_version) MODULE_INFO(version, _version)
173#else
174#define MODULE_VERSION(_version) \
175 extern ssize_t __modver_version_show(struct module_attribute *, \
176 struct module *, char *); \
177 static struct module_version_attribute __modver_version_attr \
178 __used \
179 __attribute__ ((__section__ ("__modver"),aligned(sizeof(void *)))) \
180 = { \
181 .mattr = { \
182 .attr = { \
183 .name = "version", \
184 .mode = S_IRUGO, \
185 }, \
186 .show = __modver_version_show, \
187 }, \
188 .module_name = KBUILD_MODNAME, \
189 .version = _version, \
190 }
191#endif
165 192
166/* Optional firmware file (or files) needed by the module 193/* Optional firmware file (or files) needed by the module
167 * format is simply firmware file name. Multiple firmware 194 * format is simply firmware file name. Multiple firmware
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index 112adf8bd47d..07b41951e3fa 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -16,15 +16,17 @@
16/* Chosen so that structs with an unsigned long line up. */ 16/* Chosen so that structs with an unsigned long line up. */
17#define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long)) 17#define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long))
18 18
19#ifdef MODULE
20#define ___module_cat(a,b) __mod_ ## a ## b 19#define ___module_cat(a,b) __mod_ ## a ## b
21#define __module_cat(a,b) ___module_cat(a,b) 20#define __module_cat(a,b) ___module_cat(a,b)
21#ifdef MODULE
22#define __MODULE_INFO(tag, name, info) \ 22#define __MODULE_INFO(tag, name, info) \
23static const char __module_cat(name,__LINE__)[] \ 23static const char __module_cat(name,__LINE__)[] \
24 __used __attribute__((section(".modinfo"), unused, aligned(1))) \ 24 __used __attribute__((section(".modinfo"), unused, aligned(1))) \
25 = __stringify(tag) "=" info 25 = __stringify(tag) "=" info
26#else /* !MODULE */ 26#else /* !MODULE */
27#define __MODULE_INFO(tag, name, info) 27/* This struct is here for syntactic coherency, it is not used */
28#define __MODULE_INFO(tag, name, info) \
29 struct __module_cat(name,__LINE__) {}
28#endif 30#endif
29#define __MODULE_PARM_TYPE(name, _type) \ 31#define __MODULE_PARM_TYPE(name, _type) \
30 __MODULE_INFO(parmtype, name##type, #name ":" _type) 32 __MODULE_INFO(parmtype, name##type, #name ":" _type)
diff --git a/include/linux/rtc.h b/include/linux/rtc.h
index 3c995b4d742c..a0b639f8e805 100644
--- a/include/linux/rtc.h
+++ b/include/linux/rtc.h
@@ -235,8 +235,6 @@ extern int rtc_irq_set_freq(struct rtc_device *rtc,
235 struct rtc_task *task, int freq); 235 struct rtc_task *task, int freq);
236extern int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled); 236extern int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled);
237extern int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled); 237extern int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled);
238extern int rtc_dev_update_irq_enable_emul(struct rtc_device *rtc,
239 unsigned int enabled);
240 238
241void rtc_aie_update_irq(void *private); 239void rtc_aie_update_irq(void *private);
242void rtc_uie_update_irq(void *private); 240void rtc_uie_update_irq(void *private);
@@ -246,8 +244,6 @@ int rtc_register(rtc_task_t *task);
246int rtc_unregister(rtc_task_t *task); 244int rtc_unregister(rtc_task_t *task);
247int rtc_control(rtc_task_t *t, unsigned int cmd, unsigned long arg); 245int rtc_control(rtc_task_t *t, unsigned int cmd, unsigned long arg);
248 246
249void rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer);
250void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer);
251void rtc_timer_init(struct rtc_timer *timer, void (*f)(void* p), void* data); 247void rtc_timer_init(struct rtc_timer *timer, void (*f)(void* p), void* data);
252int rtc_timer_start(struct rtc_device *rtc, struct rtc_timer* timer, 248int rtc_timer_start(struct rtc_device *rtc, struct rtc_timer* timer,
253 ktime_t expires, ktime_t period); 249 ktime_t expires, ktime_t period);
diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
index 387fa7d05c98..7faf933cced7 100644
--- a/include/linux/sysrq.h
+++ b/include/linux/sysrq.h
@@ -17,6 +17,9 @@
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/types.h> 18#include <linux/types.h>
19 19
20/* Enable/disable SYSRQ support by default (0==no, 1==yes). */
21#define SYSRQ_DEFAULT_ENABLE 1
22
20/* Possible values of bitmask for enabling sysrq functions */ 23/* Possible values of bitmask for enabling sysrq functions */
21/* 0x0001 is reserved for enable everything */ 24/* 0x0001 is reserved for enable everything */
22#define SYSRQ_ENABLE_LOG 0x0002 25#define SYSRQ_ENABLE_LOG 0x0002
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index 0093dd7c1d6f..800617b4ddd5 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -109,7 +109,10 @@ static inline bool virtio_has_feature(const struct virtio_device *vdev,
109 unsigned int fbit) 109 unsigned int fbit)
110{ 110{
111 /* Did you forget to fix assumptions on max features? */ 111 /* Did you forget to fix assumptions on max features? */
112 MAYBE_BUILD_BUG_ON(fbit >= 32); 112 if (__builtin_constant_p(fbit))
113 BUILD_BUG_ON(fbit >= 32);
114 else
115 BUG_ON(fbit >= 32);
113 116
114 if (fbit < VIRTIO_TRANSPORT_F_START) 117 if (fbit < VIRTIO_TRANSPORT_F_START)
115 virtio_check_driver_offered_feature(vdev, fbit); 118 virtio_check_driver_offered_feature(vdev, fbit);
diff --git a/kernel/futex.c b/kernel/futex.c
index b766d28accd6..64c38115c7b6 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -1556,10 +1556,10 @@ static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q,
1556 1556
1557 /* 1557 /*
1558 * We are here either because we stole the rtmutex from the 1558 * We are here either because we stole the rtmutex from the
1559 * pending owner or we are the pending owner which failed to 1559 * previous highest priority waiter or we are the highest priority
1560 * get the rtmutex. We have to replace the pending owner TID 1560 * waiter but failed to get the rtmutex the first time.
1561 * in the user space variable. This must be atomic as we have 1561 * We have to replace the newowner TID in the user space variable.
1562 * to preserve the owner died bit here. 1562 * This must be atomic as we have to preserve the owner died bit here.
1563 * 1563 *
1564 * Note: We write the user space value _before_ changing the pi_state 1564 * Note: We write the user space value _before_ changing the pi_state
1565 * because we can fault here. Imagine swapped out pages or a fork 1565 * because we can fault here. Imagine swapped out pages or a fork
@@ -1608,8 +1608,8 @@ retry:
1608 1608
1609 /* 1609 /*
1610 * To handle the page fault we need to drop the hash bucket 1610 * To handle the page fault we need to drop the hash bucket
1611 * lock here. That gives the other task (either the pending 1611 * lock here. That gives the other task (either the highest priority
1612 * owner itself or the task which stole the rtmutex) the 1612 * waiter itself or the task which stole the rtmutex) the
1613 * chance to try the fixup of the pi_state. So once we are 1613 * chance to try the fixup of the pi_state. So once we are
1614 * back from handling the fault we need to check the pi_state 1614 * back from handling the fault we need to check the pi_state
1615 * after reacquiring the hash bucket lock and before trying to 1615 * after reacquiring the hash bucket lock and before trying to
@@ -1685,18 +1685,20 @@ static int fixup_owner(u32 __user *uaddr, struct futex_q *q, int locked)
1685 /* 1685 /*
1686 * pi_state is incorrect, some other task did a lock steal and 1686 * pi_state is incorrect, some other task did a lock steal and
1687 * we returned due to timeout or signal without taking the 1687 * we returned due to timeout or signal without taking the
1688 * rt_mutex. Too late. We can access the rt_mutex_owner without 1688 * rt_mutex. Too late.
1689 * locking, as the other task is now blocked on the hash bucket
1690 * lock. Fix the state up.
1691 */ 1689 */
1690 raw_spin_lock(&q->pi_state->pi_mutex.wait_lock);
1692 owner = rt_mutex_owner(&q->pi_state->pi_mutex); 1691 owner = rt_mutex_owner(&q->pi_state->pi_mutex);
1692 if (!owner)
1693 owner = rt_mutex_next_owner(&q->pi_state->pi_mutex);
1694 raw_spin_unlock(&q->pi_state->pi_mutex.wait_lock);
1693 ret = fixup_pi_state_owner(uaddr, q, owner); 1695 ret = fixup_pi_state_owner(uaddr, q, owner);
1694 goto out; 1696 goto out;
1695 } 1697 }
1696 1698
1697 /* 1699 /*
1698 * Paranoia check. If we did not take the lock, then we should not be 1700 * Paranoia check. If we did not take the lock, then we should not be
1699 * the owner, nor the pending owner, of the rt_mutex. 1701 * the owner of the rt_mutex.
1700 */ 1702 */
1701 if (rt_mutex_owner(&q->pi_state->pi_mutex) == current) 1703 if (rt_mutex_owner(&q->pi_state->pi_mutex) == current)
1702 printk(KERN_ERR "fixup_owner: ret = %d pi-mutex: %p " 1704 printk(KERN_ERR "fixup_owner: ret = %d pi-mutex: %p "
diff --git a/kernel/params.c b/kernel/params.c
index 08107d181758..0da1411222b9 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -719,9 +719,7 @@ void destroy_params(const struct kernel_param *params, unsigned num)
719 params[i].ops->free(params[i].arg); 719 params[i].ops->free(params[i].arg);
720} 720}
721 721
722static void __init kernel_add_sysfs_param(const char *name, 722static struct module_kobject * __init locate_module_kobject(const char *name)
723 struct kernel_param *kparam,
724 unsigned int name_skip)
725{ 723{
726 struct module_kobject *mk; 724 struct module_kobject *mk;
727 struct kobject *kobj; 725 struct kobject *kobj;
@@ -729,10 +727,7 @@ static void __init kernel_add_sysfs_param(const char *name,
729 727
730 kobj = kset_find_obj(module_kset, name); 728 kobj = kset_find_obj(module_kset, name);
731 if (kobj) { 729 if (kobj) {
732 /* We already have one. Remove params so we can add more. */
733 mk = to_module_kobject(kobj); 730 mk = to_module_kobject(kobj);
734 /* We need to remove it before adding parameters. */
735 sysfs_remove_group(&mk->kobj, &mk->mp->grp);
736 } else { 731 } else {
737 mk = kzalloc(sizeof(struct module_kobject), GFP_KERNEL); 732 mk = kzalloc(sizeof(struct module_kobject), GFP_KERNEL);
738 BUG_ON(!mk); 733 BUG_ON(!mk);
@@ -743,15 +738,36 @@ static void __init kernel_add_sysfs_param(const char *name,
743 "%s", name); 738 "%s", name);
744 if (err) { 739 if (err) {
745 kobject_put(&mk->kobj); 740 kobject_put(&mk->kobj);
746 printk(KERN_ERR "Module '%s' failed add to sysfs, " 741 printk(KERN_ERR
747 "error number %d\n", name, err); 742 "Module '%s' failed add to sysfs, error number %d\n",
748 printk(KERN_ERR "The system will be unstable now.\n"); 743 name, err);
749 return; 744 printk(KERN_ERR
745 "The system will be unstable now.\n");
746 return NULL;
750 } 747 }
751 /* So that exit path is even. */ 748
749 /* So that we hold reference in both cases. */
752 kobject_get(&mk->kobj); 750 kobject_get(&mk->kobj);
753 } 751 }
754 752
753 return mk;
754}
755
756static void __init kernel_add_sysfs_param(const char *name,
757 struct kernel_param *kparam,
758 unsigned int name_skip)
759{
760 struct module_kobject *mk;
761 int err;
762
763 mk = locate_module_kobject(name);
764 if (!mk)
765 return;
766
767 /* We need to remove old parameters before adding more. */
768 if (mk->mp)
769 sysfs_remove_group(&mk->kobj, &mk->mp->grp);
770
755 /* These should not fail at boot. */ 771 /* These should not fail at boot. */
756 err = add_sysfs_param(mk, kparam, kparam->name + name_skip); 772 err = add_sysfs_param(mk, kparam, kparam->name + name_skip);
757 BUG_ON(err); 773 BUG_ON(err);
@@ -796,6 +812,32 @@ static void __init param_sysfs_builtin(void)
796 } 812 }
797} 813}
798 814
815ssize_t __modver_version_show(struct module_attribute *mattr,
816 struct module *mod, char *buf)
817{
818 struct module_version_attribute *vattr =
819 container_of(mattr, struct module_version_attribute, mattr);
820
821 return sprintf(buf, "%s\n", vattr->version);
822}
823
824extern struct module_version_attribute __start___modver[], __stop___modver[];
825
826static void __init version_sysfs_builtin(void)
827{
828 const struct module_version_attribute *vattr;
829 struct module_kobject *mk;
830 int err;
831
832 for (vattr = __start___modver; vattr < __stop___modver; vattr++) {
833 mk = locate_module_kobject(vattr->module_name);
834 if (mk) {
835 err = sysfs_create_file(&mk->kobj, &vattr->mattr.attr);
836 kobject_uevent(&mk->kobj, KOBJ_ADD);
837 kobject_put(&mk->kobj);
838 }
839 }
840}
799 841
800/* module-related sysfs stuff */ 842/* module-related sysfs stuff */
801 843
@@ -875,6 +917,7 @@ static int __init param_sysfs_init(void)
875 } 917 }
876 module_sysfs_initialized = 1; 918 module_sysfs_initialized = 1;
877 919
920 version_sysfs_builtin();
878 param_sysfs_builtin(); 921 param_sysfs_builtin();
879 922
880 return 0; 923 return 0;
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 84522c796987..126a302c481c 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -2201,13 +2201,6 @@ find_lively_task_by_vpid(pid_t vpid)
2201 if (!task) 2201 if (!task)
2202 return ERR_PTR(-ESRCH); 2202 return ERR_PTR(-ESRCH);
2203 2203
2204 /*
2205 * Can't attach events to a dying task.
2206 */
2207 err = -ESRCH;
2208 if (task->flags & PF_EXITING)
2209 goto errout;
2210
2211 /* Reuse ptrace permission checks for now. */ 2204 /* Reuse ptrace permission checks for now. */
2212 err = -EACCES; 2205 err = -EACCES;
2213 if (!ptrace_may_access(task, PTRACE_MODE_READ)) 2206 if (!ptrace_may_access(task, PTRACE_MODE_READ))
@@ -2268,14 +2261,27 @@ retry:
2268 2261
2269 get_ctx(ctx); 2262 get_ctx(ctx);
2270 2263
2271 if (cmpxchg(&task->perf_event_ctxp[ctxn], NULL, ctx)) { 2264 err = 0;
2272 /* 2265 mutex_lock(&task->perf_event_mutex);
2273 * We raced with some other task; use 2266 /*
2274 * the context they set. 2267 * If it has already passed perf_event_exit_task().
2275 */ 2268 * we must see PF_EXITING, it takes this mutex too.
2269 */
2270 if (task->flags & PF_EXITING)
2271 err = -ESRCH;
2272 else if (task->perf_event_ctxp[ctxn])
2273 err = -EAGAIN;
2274 else
2275 rcu_assign_pointer(task->perf_event_ctxp[ctxn], ctx);
2276 mutex_unlock(&task->perf_event_mutex);
2277
2278 if (unlikely(err)) {
2276 put_task_struct(task); 2279 put_task_struct(task);
2277 kfree(ctx); 2280 kfree(ctx);
2278 goto retry; 2281
2282 if (err == -EAGAIN)
2283 goto retry;
2284 goto errout;
2279 } 2285 }
2280 } 2286 }
2281 2287
@@ -5374,6 +5380,8 @@ free_dev:
5374 goto out; 5380 goto out;
5375} 5381}
5376 5382
5383static struct lock_class_key cpuctx_mutex;
5384
5377int perf_pmu_register(struct pmu *pmu, char *name, int type) 5385int perf_pmu_register(struct pmu *pmu, char *name, int type)
5378{ 5386{
5379 int cpu, ret; 5387 int cpu, ret;
@@ -5422,6 +5430,7 @@ skip_type:
5422 5430
5423 cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu); 5431 cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu);
5424 __perf_event_init_context(&cpuctx->ctx); 5432 __perf_event_init_context(&cpuctx->ctx);
5433 lockdep_set_class(&cpuctx->ctx.mutex, &cpuctx_mutex);
5425 cpuctx->ctx.type = cpu_context; 5434 cpuctx->ctx.type = cpu_context;
5426 cpuctx->ctx.pmu = pmu; 5435 cpuctx->ctx.pmu = pmu;
5427 cpuctx->jiffies_interval = 1; 5436 cpuctx->jiffies_interval = 1;
@@ -6127,7 +6136,7 @@ static void perf_event_exit_task_context(struct task_struct *child, int ctxn)
6127 * scheduled, so we are now safe from rescheduling changing 6136 * scheduled, so we are now safe from rescheduling changing
6128 * our context. 6137 * our context.
6129 */ 6138 */
6130 child_ctx = child->perf_event_ctxp[ctxn]; 6139 child_ctx = rcu_dereference_raw(child->perf_event_ctxp[ctxn]);
6131 task_ctx_sched_out(child_ctx, EVENT_ALL); 6140 task_ctx_sched_out(child_ctx, EVENT_ALL);
6132 6141
6133 /* 6142 /*
@@ -6440,11 +6449,6 @@ int perf_event_init_context(struct task_struct *child, int ctxn)
6440 unsigned long flags; 6449 unsigned long flags;
6441 int ret = 0; 6450 int ret = 0;
6442 6451
6443 child->perf_event_ctxp[ctxn] = NULL;
6444
6445 mutex_init(&child->perf_event_mutex);
6446 INIT_LIST_HEAD(&child->perf_event_list);
6447
6448 if (likely(!parent->perf_event_ctxp[ctxn])) 6452 if (likely(!parent->perf_event_ctxp[ctxn]))
6449 return 0; 6453 return 0;
6450 6454
@@ -6533,6 +6537,10 @@ int perf_event_init_task(struct task_struct *child)
6533{ 6537{
6534 int ctxn, ret; 6538 int ctxn, ret;
6535 6539
6540 memset(child->perf_event_ctxp, 0, sizeof(child->perf_event_ctxp));
6541 mutex_init(&child->perf_event_mutex);
6542 INIT_LIST_HEAD(&child->perf_event_list);
6543
6536 for_each_task_context_nr(ctxn) { 6544 for_each_task_context_nr(ctxn) {
6537 ret = perf_event_init_context(child, ctxn); 6545 ret = perf_event_init_context(child, ctxn);
6538 if (ret) 6546 if (ret)
diff --git a/kernel/printk.c b/kernel/printk.c
index 53d9a9ec88e6..2ddbdc73aade 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -97,7 +97,7 @@ static int console_locked, console_suspended;
97/* 97/*
98 * logbuf_lock protects log_buf, log_start, log_end, con_start and logged_chars 98 * logbuf_lock protects log_buf, log_start, log_end, con_start and logged_chars
99 * It is also used in interesting ways to provide interlocking in 99 * It is also used in interesting ways to provide interlocking in
100 * release_console_sem(). 100 * console_unlock();.
101 */ 101 */
102static DEFINE_SPINLOCK(logbuf_lock); 102static DEFINE_SPINLOCK(logbuf_lock);
103 103
@@ -501,7 +501,7 @@ static void _call_console_drivers(unsigned start,
501/* 501/*
502 * Call the console drivers, asking them to write out 502 * Call the console drivers, asking them to write out
503 * log_buf[start] to log_buf[end - 1]. 503 * log_buf[start] to log_buf[end - 1].
504 * The console_sem must be held. 504 * The console_lock must be held.
505 */ 505 */
506static void call_console_drivers(unsigned start, unsigned end) 506static void call_console_drivers(unsigned start, unsigned end)
507{ 507{
@@ -604,11 +604,11 @@ static int have_callable_console(void)
604 * 604 *
605 * This is printk(). It can be called from any context. We want it to work. 605 * This is printk(). It can be called from any context. We want it to work.
606 * 606 *
607 * We try to grab the console_sem. If we succeed, it's easy - we log the output and 607 * We try to grab the console_lock. If we succeed, it's easy - we log the output and
608 * call the console drivers. If we fail to get the semaphore we place the output 608 * call the console drivers. If we fail to get the semaphore we place the output
609 * into the log buffer and return. The current holder of the console_sem will 609 * into the log buffer and return. The current holder of the console_sem will
610 * notice the new output in release_console_sem() and will send it to the 610 * notice the new output in console_unlock(); and will send it to the
611 * consoles before releasing the semaphore. 611 * consoles before releasing the lock.
612 * 612 *
613 * One effect of this deferred printing is that code which calls printk() and 613 * One effect of this deferred printing is that code which calls printk() and
614 * then changes console_loglevel may break. This is because console_loglevel 614 * then changes console_loglevel may break. This is because console_loglevel
@@ -659,19 +659,19 @@ static inline int can_use_console(unsigned int cpu)
659/* 659/*
660 * Try to get console ownership to actually show the kernel 660 * Try to get console ownership to actually show the kernel
661 * messages from a 'printk'. Return true (and with the 661 * messages from a 'printk'. Return true (and with the
662 * console_semaphore held, and 'console_locked' set) if it 662 * console_lock held, and 'console_locked' set) if it
663 * is successful, false otherwise. 663 * is successful, false otherwise.
664 * 664 *
665 * This gets called with the 'logbuf_lock' spinlock held and 665 * This gets called with the 'logbuf_lock' spinlock held and
666 * interrupts disabled. It should return with 'lockbuf_lock' 666 * interrupts disabled. It should return with 'lockbuf_lock'
667 * released but interrupts still disabled. 667 * released but interrupts still disabled.
668 */ 668 */
669static int acquire_console_semaphore_for_printk(unsigned int cpu) 669static int console_trylock_for_printk(unsigned int cpu)
670 __releases(&logbuf_lock) 670 __releases(&logbuf_lock)
671{ 671{
672 int retval = 0; 672 int retval = 0;
673 673
674 if (!try_acquire_console_sem()) { 674 if (console_trylock()) {
675 retval = 1; 675 retval = 1;
676 676
677 /* 677 /*
@@ -827,12 +827,12 @@ asmlinkage int vprintk(const char *fmt, va_list args)
827 * actual magic (print out buffers, wake up klogd, 827 * actual magic (print out buffers, wake up klogd,
828 * etc). 828 * etc).
829 * 829 *
830 * The acquire_console_semaphore_for_printk() function 830 * The console_trylock_for_printk() function
831 * will release 'logbuf_lock' regardless of whether it 831 * will release 'logbuf_lock' regardless of whether it
832 * actually gets the semaphore or not. 832 * actually gets the semaphore or not.
833 */ 833 */
834 if (acquire_console_semaphore_for_printk(this_cpu)) 834 if (console_trylock_for_printk(this_cpu))
835 release_console_sem(); 835 console_unlock();
836 836
837 lockdep_on(); 837 lockdep_on();
838out_restore_irqs: 838out_restore_irqs:
@@ -993,7 +993,7 @@ void suspend_console(void)
993 if (!console_suspend_enabled) 993 if (!console_suspend_enabled)
994 return; 994 return;
995 printk("Suspending console(s) (use no_console_suspend to debug)\n"); 995 printk("Suspending console(s) (use no_console_suspend to debug)\n");
996 acquire_console_sem(); 996 console_lock();
997 console_suspended = 1; 997 console_suspended = 1;
998 up(&console_sem); 998 up(&console_sem);
999} 999}
@@ -1004,7 +1004,7 @@ void resume_console(void)
1004 return; 1004 return;
1005 down(&console_sem); 1005 down(&console_sem);
1006 console_suspended = 0; 1006 console_suspended = 0;
1007 release_console_sem(); 1007 console_unlock();
1008} 1008}
1009 1009
1010/** 1010/**
@@ -1027,21 +1027,21 @@ static int __cpuinit console_cpu_notify(struct notifier_block *self,
1027 case CPU_DYING: 1027 case CPU_DYING:
1028 case CPU_DOWN_FAILED: 1028 case CPU_DOWN_FAILED:
1029 case CPU_UP_CANCELED: 1029 case CPU_UP_CANCELED:
1030 acquire_console_sem(); 1030 console_lock();
1031 release_console_sem(); 1031 console_unlock();
1032 } 1032 }
1033 return NOTIFY_OK; 1033 return NOTIFY_OK;
1034} 1034}
1035 1035
1036/** 1036/**
1037 * acquire_console_sem - lock the console system for exclusive use. 1037 * console_lock - lock the console system for exclusive use.
1038 * 1038 *
1039 * Acquires a semaphore which guarantees that the caller has 1039 * Acquires a lock which guarantees that the caller has
1040 * exclusive access to the console system and the console_drivers list. 1040 * exclusive access to the console system and the console_drivers list.
1041 * 1041 *
1042 * Can sleep, returns nothing. 1042 * Can sleep, returns nothing.
1043 */ 1043 */
1044void acquire_console_sem(void) 1044void console_lock(void)
1045{ 1045{
1046 BUG_ON(in_interrupt()); 1046 BUG_ON(in_interrupt());
1047 down(&console_sem); 1047 down(&console_sem);
@@ -1050,21 +1050,29 @@ void acquire_console_sem(void)
1050 console_locked = 1; 1050 console_locked = 1;
1051 console_may_schedule = 1; 1051 console_may_schedule = 1;
1052} 1052}
1053EXPORT_SYMBOL(acquire_console_sem); 1053EXPORT_SYMBOL(console_lock);
1054 1054
1055int try_acquire_console_sem(void) 1055/**
1056 * console_trylock - try to lock the console system for exclusive use.
1057 *
1058 * Tried to acquire a lock which guarantees that the caller has
1059 * exclusive access to the console system and the console_drivers list.
1060 *
1061 * returns 1 on success, and 0 on failure to acquire the lock.
1062 */
1063int console_trylock(void)
1056{ 1064{
1057 if (down_trylock(&console_sem)) 1065 if (down_trylock(&console_sem))
1058 return -1; 1066 return 0;
1059 if (console_suspended) { 1067 if (console_suspended) {
1060 up(&console_sem); 1068 up(&console_sem);
1061 return -1; 1069 return 0;
1062 } 1070 }
1063 console_locked = 1; 1071 console_locked = 1;
1064 console_may_schedule = 0; 1072 console_may_schedule = 0;
1065 return 0; 1073 return 1;
1066} 1074}
1067EXPORT_SYMBOL(try_acquire_console_sem); 1075EXPORT_SYMBOL(console_trylock);
1068 1076
1069int is_console_locked(void) 1077int is_console_locked(void)
1070{ 1078{
@@ -1095,20 +1103,20 @@ void wake_up_klogd(void)
1095} 1103}
1096 1104
1097/** 1105/**
1098 * release_console_sem - unlock the console system 1106 * console_unlock - unlock the console system
1099 * 1107 *
1100 * Releases the semaphore which the caller holds on the console system 1108 * Releases the console_lock which the caller holds on the console system
1101 * and the console driver list. 1109 * and the console driver list.
1102 * 1110 *
1103 * While the semaphore was held, console output may have been buffered 1111 * While the console_lock was held, console output may have been buffered
1104 * by printk(). If this is the case, release_console_sem() emits 1112 * by printk(). If this is the case, console_unlock(); emits
1105 * the output prior to releasing the semaphore. 1113 * the output prior to releasing the lock.
1106 * 1114 *
1107 * If there is output waiting for klogd, we wake it up. 1115 * If there is output waiting for klogd, we wake it up.
1108 * 1116 *
1109 * release_console_sem() may be called from any context. 1117 * console_unlock(); may be called from any context.
1110 */ 1118 */
1111void release_console_sem(void) 1119void console_unlock(void)
1112{ 1120{
1113 unsigned long flags; 1121 unsigned long flags;
1114 unsigned _con_start, _log_end; 1122 unsigned _con_start, _log_end;
@@ -1141,7 +1149,7 @@ void release_console_sem(void)
1141 if (wake_klogd) 1149 if (wake_klogd)
1142 wake_up_klogd(); 1150 wake_up_klogd();
1143} 1151}
1144EXPORT_SYMBOL(release_console_sem); 1152EXPORT_SYMBOL(console_unlock);
1145 1153
1146/** 1154/**
1147 * console_conditional_schedule - yield the CPU if required 1155 * console_conditional_schedule - yield the CPU if required
@@ -1150,7 +1158,7 @@ EXPORT_SYMBOL(release_console_sem);
1150 * if this CPU should yield the CPU to another task, do 1158 * if this CPU should yield the CPU to another task, do
1151 * so here. 1159 * so here.
1152 * 1160 *
1153 * Must be called within acquire_console_sem(). 1161 * Must be called within console_lock();.
1154 */ 1162 */
1155void __sched console_conditional_schedule(void) 1163void __sched console_conditional_schedule(void)
1156{ 1164{
@@ -1171,14 +1179,14 @@ void console_unblank(void)
1171 if (down_trylock(&console_sem) != 0) 1179 if (down_trylock(&console_sem) != 0)
1172 return; 1180 return;
1173 } else 1181 } else
1174 acquire_console_sem(); 1182 console_lock();
1175 1183
1176 console_locked = 1; 1184 console_locked = 1;
1177 console_may_schedule = 0; 1185 console_may_schedule = 0;
1178 for_each_console(c) 1186 for_each_console(c)
1179 if ((c->flags & CON_ENABLED) && c->unblank) 1187 if ((c->flags & CON_ENABLED) && c->unblank)
1180 c->unblank(); 1188 c->unblank();
1181 release_console_sem(); 1189 console_unlock();
1182} 1190}
1183 1191
1184/* 1192/*
@@ -1189,7 +1197,7 @@ struct tty_driver *console_device(int *index)
1189 struct console *c; 1197 struct console *c;
1190 struct tty_driver *driver = NULL; 1198 struct tty_driver *driver = NULL;
1191 1199
1192 acquire_console_sem(); 1200 console_lock();
1193 for_each_console(c) { 1201 for_each_console(c) {
1194 if (!c->device) 1202 if (!c->device)
1195 continue; 1203 continue;
@@ -1197,7 +1205,7 @@ struct tty_driver *console_device(int *index)
1197 if (driver) 1205 if (driver)
1198 break; 1206 break;
1199 } 1207 }
1200 release_console_sem(); 1208 console_unlock();
1201 return driver; 1209 return driver;
1202} 1210}
1203 1211
@@ -1208,17 +1216,17 @@ struct tty_driver *console_device(int *index)
1208 */ 1216 */
1209void console_stop(struct console *console) 1217void console_stop(struct console *console)
1210{ 1218{
1211 acquire_console_sem(); 1219 console_lock();
1212 console->flags &= ~CON_ENABLED; 1220 console->flags &= ~CON_ENABLED;
1213 release_console_sem(); 1221 console_unlock();
1214} 1222}
1215EXPORT_SYMBOL(console_stop); 1223EXPORT_SYMBOL(console_stop);
1216 1224
1217void console_start(struct console *console) 1225void console_start(struct console *console)
1218{ 1226{
1219 acquire_console_sem(); 1227 console_lock();
1220 console->flags |= CON_ENABLED; 1228 console->flags |= CON_ENABLED;
1221 release_console_sem(); 1229 console_unlock();
1222} 1230}
1223EXPORT_SYMBOL(console_start); 1231EXPORT_SYMBOL(console_start);
1224 1232
@@ -1340,7 +1348,7 @@ void register_console(struct console *newcon)
1340 * Put this console in the list - keep the 1348 * Put this console in the list - keep the
1341 * preferred driver at the head of the list. 1349 * preferred driver at the head of the list.
1342 */ 1350 */
1343 acquire_console_sem(); 1351 console_lock();
1344 if ((newcon->flags & CON_CONSDEV) || console_drivers == NULL) { 1352 if ((newcon->flags & CON_CONSDEV) || console_drivers == NULL) {
1345 newcon->next = console_drivers; 1353 newcon->next = console_drivers;
1346 console_drivers = newcon; 1354 console_drivers = newcon;
@@ -1352,14 +1360,14 @@ void register_console(struct console *newcon)
1352 } 1360 }
1353 if (newcon->flags & CON_PRINTBUFFER) { 1361 if (newcon->flags & CON_PRINTBUFFER) {
1354 /* 1362 /*
1355 * release_console_sem() will print out the buffered messages 1363 * console_unlock(); will print out the buffered messages
1356 * for us. 1364 * for us.
1357 */ 1365 */
1358 spin_lock_irqsave(&logbuf_lock, flags); 1366 spin_lock_irqsave(&logbuf_lock, flags);
1359 con_start = log_start; 1367 con_start = log_start;
1360 spin_unlock_irqrestore(&logbuf_lock, flags); 1368 spin_unlock_irqrestore(&logbuf_lock, flags);
1361 } 1369 }
1362 release_console_sem(); 1370 console_unlock();
1363 console_sysfs_notify(); 1371 console_sysfs_notify();
1364 1372
1365 /* 1373 /*
@@ -1396,7 +1404,7 @@ int unregister_console(struct console *console)
1396 return braille_unregister_console(console); 1404 return braille_unregister_console(console);
1397#endif 1405#endif
1398 1406
1399 acquire_console_sem(); 1407 console_lock();
1400 if (console_drivers == console) { 1408 if (console_drivers == console) {
1401 console_drivers=console->next; 1409 console_drivers=console->next;
1402 res = 0; 1410 res = 0;
@@ -1418,7 +1426,7 @@ int unregister_console(struct console *console)
1418 if (console_drivers != NULL && console->flags & CON_CONSDEV) 1426 if (console_drivers != NULL && console->flags & CON_CONSDEV)
1419 console_drivers->flags |= CON_CONSDEV; 1427 console_drivers->flags |= CON_CONSDEV;
1420 1428
1421 release_console_sem(); 1429 console_unlock();
1422 console_sysfs_notify(); 1430 console_sysfs_notify();
1423 return res; 1431 return res;
1424} 1432}
diff --git a/kernel/rtmutex-debug.c b/kernel/rtmutex-debug.c
index ddabb54bb5c8..3c7cbc2c33be 100644
--- a/kernel/rtmutex-debug.c
+++ b/kernel/rtmutex-debug.c
@@ -215,7 +215,6 @@ void debug_rt_mutex_free_waiter(struct rt_mutex_waiter *waiter)
215 put_pid(waiter->deadlock_task_pid); 215 put_pid(waiter->deadlock_task_pid);
216 TRACE_WARN_ON(!plist_node_empty(&waiter->list_entry)); 216 TRACE_WARN_ON(!plist_node_empty(&waiter->list_entry));
217 TRACE_WARN_ON(!plist_node_empty(&waiter->pi_list_entry)); 217 TRACE_WARN_ON(!plist_node_empty(&waiter->pi_list_entry));
218 TRACE_WARN_ON(waiter->task);
219 memset(waiter, 0x22, sizeof(*waiter)); 218 memset(waiter, 0x22, sizeof(*waiter));
220} 219}
221 220
diff --git a/kernel/rtmutex.c b/kernel/rtmutex.c
index a9604815786a..ab449117aaf2 100644
--- a/kernel/rtmutex.c
+++ b/kernel/rtmutex.c
@@ -20,41 +20,34 @@
20/* 20/*
21 * lock->owner state tracking: 21 * lock->owner state tracking:
22 * 22 *
23 * lock->owner holds the task_struct pointer of the owner. Bit 0 and 1 23 * lock->owner holds the task_struct pointer of the owner. Bit 0
24 * are used to keep track of the "owner is pending" and "lock has 24 * is used to keep track of the "lock has waiters" state.
25 * waiters" state.
26 * 25 *
27 * owner bit1 bit0 26 * owner bit0
28 * NULL 0 0 lock is free (fast acquire possible) 27 * NULL 0 lock is free (fast acquire possible)
29 * NULL 0 1 invalid state 28 * NULL 1 lock is free and has waiters and the top waiter
30 * NULL 1 0 Transitional State* 29 * is going to take the lock*
31 * NULL 1 1 invalid state 30 * taskpointer 0 lock is held (fast release possible)
32 * taskpointer 0 0 lock is held (fast release possible) 31 * taskpointer 1 lock is held and has waiters**
33 * taskpointer 0 1 task is pending owner
34 * taskpointer 1 0 lock is held and has waiters
35 * taskpointer 1 1 task is pending owner and lock has more waiters
36 *
37 * Pending ownership is assigned to the top (highest priority)
38 * waiter of the lock, when the lock is released. The thread is woken
39 * up and can now take the lock. Until the lock is taken (bit 0
40 * cleared) a competing higher priority thread can steal the lock
41 * which puts the woken up thread back on the waiters list.
42 * 32 *
43 * The fast atomic compare exchange based acquire and release is only 33 * The fast atomic compare exchange based acquire and release is only
44 * possible when bit 0 and 1 of lock->owner are 0. 34 * possible when bit 0 of lock->owner is 0.
35 *
36 * (*) It also can be a transitional state when grabbing the lock
37 * with ->wait_lock is held. To prevent any fast path cmpxchg to the lock,
38 * we need to set the bit0 before looking at the lock, and the owner may be
39 * NULL in this small time, hence this can be a transitional state.
45 * 40 *
46 * (*) There's a small time where the owner can be NULL and the 41 * (**) There is a small time when bit 0 is set but there are no
47 * "lock has waiters" bit is set. This can happen when grabbing the lock. 42 * waiters. This can happen when grabbing the lock in the slow path.
48 * To prevent a cmpxchg of the owner releasing the lock, we need to set this 43 * To prevent a cmpxchg of the owner releasing the lock, we need to
49 * bit before looking at the lock, hence the reason this is a transitional 44 * set this bit before looking at the lock.
50 * state.
51 */ 45 */
52 46
53static void 47static void
54rt_mutex_set_owner(struct rt_mutex *lock, struct task_struct *owner, 48rt_mutex_set_owner(struct rt_mutex *lock, struct task_struct *owner)
55 unsigned long mask)
56{ 49{
57 unsigned long val = (unsigned long)owner | mask; 50 unsigned long val = (unsigned long)owner;
58 51
59 if (rt_mutex_has_waiters(lock)) 52 if (rt_mutex_has_waiters(lock))
60 val |= RT_MUTEX_HAS_WAITERS; 53 val |= RT_MUTEX_HAS_WAITERS;
@@ -203,15 +196,14 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task,
203 * reached or the state of the chain has changed while we 196 * reached or the state of the chain has changed while we
204 * dropped the locks. 197 * dropped the locks.
205 */ 198 */
206 if (!waiter || !waiter->task) 199 if (!waiter)
207 goto out_unlock_pi; 200 goto out_unlock_pi;
208 201
209 /* 202 /*
210 * Check the orig_waiter state. After we dropped the locks, 203 * Check the orig_waiter state. After we dropped the locks,
211 * the previous owner of the lock might have released the lock 204 * the previous owner of the lock might have released the lock.
212 * and made us the pending owner:
213 */ 205 */
214 if (orig_waiter && !orig_waiter->task) 206 if (orig_waiter && !rt_mutex_owner(orig_lock))
215 goto out_unlock_pi; 207 goto out_unlock_pi;
216 208
217 /* 209 /*
@@ -254,6 +246,17 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task,
254 246
255 /* Release the task */ 247 /* Release the task */
256 raw_spin_unlock_irqrestore(&task->pi_lock, flags); 248 raw_spin_unlock_irqrestore(&task->pi_lock, flags);
249 if (!rt_mutex_owner(lock)) {
250 /*
251 * If the requeue above changed the top waiter, then we need
252 * to wake the new top waiter up to try to get the lock.
253 */
254
255 if (top_waiter != rt_mutex_top_waiter(lock))
256 wake_up_process(rt_mutex_top_waiter(lock)->task);
257 raw_spin_unlock(&lock->wait_lock);
258 goto out_put_task;
259 }
257 put_task_struct(task); 260 put_task_struct(task);
258 261
259 /* Grab the next task */ 262 /* Grab the next task */
@@ -296,78 +299,16 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task,
296} 299}
297 300
298/* 301/*
299 * Optimization: check if we can steal the lock from the
300 * assigned pending owner [which might not have taken the
301 * lock yet]:
302 */
303static inline int try_to_steal_lock(struct rt_mutex *lock,
304 struct task_struct *task)
305{
306 struct task_struct *pendowner = rt_mutex_owner(lock);
307 struct rt_mutex_waiter *next;
308 unsigned long flags;
309
310 if (!rt_mutex_owner_pending(lock))
311 return 0;
312
313 if (pendowner == task)
314 return 1;
315
316 raw_spin_lock_irqsave(&pendowner->pi_lock, flags);
317 if (task->prio >= pendowner->prio) {
318 raw_spin_unlock_irqrestore(&pendowner->pi_lock, flags);
319 return 0;
320 }
321
322 /*
323 * Check if a waiter is enqueued on the pending owners
324 * pi_waiters list. Remove it and readjust pending owners
325 * priority.
326 */
327 if (likely(!rt_mutex_has_waiters(lock))) {
328 raw_spin_unlock_irqrestore(&pendowner->pi_lock, flags);
329 return 1;
330 }
331
332 /* No chain handling, pending owner is not blocked on anything: */
333 next = rt_mutex_top_waiter(lock);
334 plist_del(&next->pi_list_entry, &pendowner->pi_waiters);
335 __rt_mutex_adjust_prio(pendowner);
336 raw_spin_unlock_irqrestore(&pendowner->pi_lock, flags);
337
338 /*
339 * We are going to steal the lock and a waiter was
340 * enqueued on the pending owners pi_waiters queue. So
341 * we have to enqueue this waiter into
342 * task->pi_waiters list. This covers the case,
343 * where task is boosted because it holds another
344 * lock and gets unboosted because the booster is
345 * interrupted, so we would delay a waiter with higher
346 * priority as task->normal_prio.
347 *
348 * Note: in the rare case of a SCHED_OTHER task changing
349 * its priority and thus stealing the lock, next->task
350 * might be task:
351 */
352 if (likely(next->task != task)) {
353 raw_spin_lock_irqsave(&task->pi_lock, flags);
354 plist_add(&next->pi_list_entry, &task->pi_waiters);
355 __rt_mutex_adjust_prio(task);
356 raw_spin_unlock_irqrestore(&task->pi_lock, flags);
357 }
358 return 1;
359}
360
361/*
362 * Try to take an rt-mutex 302 * Try to take an rt-mutex
363 * 303 *
364 * This fails
365 * - when the lock has a real owner
366 * - when a different pending owner exists and has higher priority than current
367 *
368 * Must be called with lock->wait_lock held. 304 * Must be called with lock->wait_lock held.
305 *
306 * @lock: the lock to be acquired.
307 * @task: the task which wants to acquire the lock
308 * @waiter: the waiter that is queued to the lock's wait list. (could be NULL)
369 */ 309 */
370static int try_to_take_rt_mutex(struct rt_mutex *lock) 310static int try_to_take_rt_mutex(struct rt_mutex *lock, struct task_struct *task,
311 struct rt_mutex_waiter *waiter)
371{ 312{
372 /* 313 /*
373 * We have to be careful here if the atomic speedups are 314 * We have to be careful here if the atomic speedups are
@@ -390,15 +331,52 @@ static int try_to_take_rt_mutex(struct rt_mutex *lock)
390 */ 331 */
391 mark_rt_mutex_waiters(lock); 332 mark_rt_mutex_waiters(lock);
392 333
393 if (rt_mutex_owner(lock) && !try_to_steal_lock(lock, current)) 334 if (rt_mutex_owner(lock))
394 return 0; 335 return 0;
395 336
337 /*
338 * It will get the lock because of one of these conditions:
339 * 1) there is no waiter
340 * 2) higher priority than waiters
341 * 3) it is top waiter
342 */
343 if (rt_mutex_has_waiters(lock)) {
344 if (task->prio >= rt_mutex_top_waiter(lock)->list_entry.prio) {
345 if (!waiter || waiter != rt_mutex_top_waiter(lock))
346 return 0;
347 }
348 }
349
350 if (waiter || rt_mutex_has_waiters(lock)) {
351 unsigned long flags;
352 struct rt_mutex_waiter *top;
353
354 raw_spin_lock_irqsave(&task->pi_lock, flags);
355
356 /* remove the queued waiter. */
357 if (waiter) {
358 plist_del(&waiter->list_entry, &lock->wait_list);
359 task->pi_blocked_on = NULL;
360 }
361
362 /*
363 * We have to enqueue the top waiter(if it exists) into
364 * task->pi_waiters list.
365 */
366 if (rt_mutex_has_waiters(lock)) {
367 top = rt_mutex_top_waiter(lock);
368 top->pi_list_entry.prio = top->list_entry.prio;
369 plist_add(&top->pi_list_entry, &task->pi_waiters);
370 }
371 raw_spin_unlock_irqrestore(&task->pi_lock, flags);
372 }
373
396 /* We got the lock. */ 374 /* We got the lock. */
397 debug_rt_mutex_lock(lock); 375 debug_rt_mutex_lock(lock);
398 376
399 rt_mutex_set_owner(lock, current, 0); 377 rt_mutex_set_owner(lock, task);
400 378
401 rt_mutex_deadlock_account_lock(lock, current); 379 rt_mutex_deadlock_account_lock(lock, task);
402 380
403 return 1; 381 return 1;
404} 382}
@@ -436,6 +414,9 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock,
436 414
437 raw_spin_unlock_irqrestore(&task->pi_lock, flags); 415 raw_spin_unlock_irqrestore(&task->pi_lock, flags);
438 416
417 if (!owner)
418 return 0;
419
439 if (waiter == rt_mutex_top_waiter(lock)) { 420 if (waiter == rt_mutex_top_waiter(lock)) {
440 raw_spin_lock_irqsave(&owner->pi_lock, flags); 421 raw_spin_lock_irqsave(&owner->pi_lock, flags);
441 plist_del(&top_waiter->pi_list_entry, &owner->pi_waiters); 422 plist_del(&top_waiter->pi_list_entry, &owner->pi_waiters);
@@ -472,21 +453,18 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock,
472/* 453/*
473 * Wake up the next waiter on the lock. 454 * Wake up the next waiter on the lock.
474 * 455 *
475 * Remove the top waiter from the current tasks waiter list and from 456 * Remove the top waiter from the current tasks waiter list and wake it up.
476 * the lock waiter list. Set it as pending owner. Then wake it up.
477 * 457 *
478 * Called with lock->wait_lock held. 458 * Called with lock->wait_lock held.
479 */ 459 */
480static void wakeup_next_waiter(struct rt_mutex *lock) 460static void wakeup_next_waiter(struct rt_mutex *lock)
481{ 461{
482 struct rt_mutex_waiter *waiter; 462 struct rt_mutex_waiter *waiter;
483 struct task_struct *pendowner;
484 unsigned long flags; 463 unsigned long flags;
485 464
486 raw_spin_lock_irqsave(&current->pi_lock, flags); 465 raw_spin_lock_irqsave(&current->pi_lock, flags);
487 466
488 waiter = rt_mutex_top_waiter(lock); 467 waiter = rt_mutex_top_waiter(lock);
489 plist_del(&waiter->list_entry, &lock->wait_list);
490 468
491 /* 469 /*
492 * Remove it from current->pi_waiters. We do not adjust a 470 * Remove it from current->pi_waiters. We do not adjust a
@@ -495,43 +473,19 @@ static void wakeup_next_waiter(struct rt_mutex *lock)
495 * lock->wait_lock. 473 * lock->wait_lock.
496 */ 474 */
497 plist_del(&waiter->pi_list_entry, &current->pi_waiters); 475 plist_del(&waiter->pi_list_entry, &current->pi_waiters);
498 pendowner = waiter->task;
499 waiter->task = NULL;
500 476
501 rt_mutex_set_owner(lock, pendowner, RT_MUTEX_OWNER_PENDING); 477 rt_mutex_set_owner(lock, NULL);
502 478
503 raw_spin_unlock_irqrestore(&current->pi_lock, flags); 479 raw_spin_unlock_irqrestore(&current->pi_lock, flags);
504 480
505 /* 481 wake_up_process(waiter->task);
506 * Clear the pi_blocked_on variable and enqueue a possible
507 * waiter into the pi_waiters list of the pending owner. This
508 * prevents that in case the pending owner gets unboosted a
509 * waiter with higher priority than pending-owner->normal_prio
510 * is blocked on the unboosted (pending) owner.
511 */
512 raw_spin_lock_irqsave(&pendowner->pi_lock, flags);
513
514 WARN_ON(!pendowner->pi_blocked_on);
515 WARN_ON(pendowner->pi_blocked_on != waiter);
516 WARN_ON(pendowner->pi_blocked_on->lock != lock);
517
518 pendowner->pi_blocked_on = NULL;
519
520 if (rt_mutex_has_waiters(lock)) {
521 struct rt_mutex_waiter *next;
522
523 next = rt_mutex_top_waiter(lock);
524 plist_add(&next->pi_list_entry, &pendowner->pi_waiters);
525 }
526 raw_spin_unlock_irqrestore(&pendowner->pi_lock, flags);
527
528 wake_up_process(pendowner);
529} 482}
530 483
531/* 484/*
532 * Remove a waiter from a lock 485 * Remove a waiter from a lock and give up
533 * 486 *
534 * Must be called with lock->wait_lock held 487 * Must be called with lock->wait_lock held and
488 * have just failed to try_to_take_rt_mutex().
535 */ 489 */
536static void remove_waiter(struct rt_mutex *lock, 490static void remove_waiter(struct rt_mutex *lock,
537 struct rt_mutex_waiter *waiter) 491 struct rt_mutex_waiter *waiter)
@@ -543,11 +497,13 @@ static void remove_waiter(struct rt_mutex *lock,
543 497
544 raw_spin_lock_irqsave(&current->pi_lock, flags); 498 raw_spin_lock_irqsave(&current->pi_lock, flags);
545 plist_del(&waiter->list_entry, &lock->wait_list); 499 plist_del(&waiter->list_entry, &lock->wait_list);
546 waiter->task = NULL;
547 current->pi_blocked_on = NULL; 500 current->pi_blocked_on = NULL;
548 raw_spin_unlock_irqrestore(&current->pi_lock, flags); 501 raw_spin_unlock_irqrestore(&current->pi_lock, flags);
549 502
550 if (first && owner != current) { 503 if (!owner)
504 return;
505
506 if (first) {
551 507
552 raw_spin_lock_irqsave(&owner->pi_lock, flags); 508 raw_spin_lock_irqsave(&owner->pi_lock, flags);
553 509
@@ -614,21 +570,19 @@ void rt_mutex_adjust_pi(struct task_struct *task)
614 * or TASK_UNINTERRUPTIBLE) 570 * or TASK_UNINTERRUPTIBLE)
615 * @timeout: the pre-initialized and started timer, or NULL for none 571 * @timeout: the pre-initialized and started timer, or NULL for none
616 * @waiter: the pre-initialized rt_mutex_waiter 572 * @waiter: the pre-initialized rt_mutex_waiter
617 * @detect_deadlock: passed to task_blocks_on_rt_mutex
618 * 573 *
619 * lock->wait_lock must be held by the caller. 574 * lock->wait_lock must be held by the caller.
620 */ 575 */
621static int __sched 576static int __sched
622__rt_mutex_slowlock(struct rt_mutex *lock, int state, 577__rt_mutex_slowlock(struct rt_mutex *lock, int state,
623 struct hrtimer_sleeper *timeout, 578 struct hrtimer_sleeper *timeout,
624 struct rt_mutex_waiter *waiter, 579 struct rt_mutex_waiter *waiter)
625 int detect_deadlock)
626{ 580{
627 int ret = 0; 581 int ret = 0;
628 582
629 for (;;) { 583 for (;;) {
630 /* Try to acquire the lock: */ 584 /* Try to acquire the lock: */
631 if (try_to_take_rt_mutex(lock)) 585 if (try_to_take_rt_mutex(lock, current, waiter))
632 break; 586 break;
633 587
634 /* 588 /*
@@ -645,39 +599,11 @@ __rt_mutex_slowlock(struct rt_mutex *lock, int state,
645 break; 599 break;
646 } 600 }
647 601
648 /*
649 * waiter->task is NULL the first time we come here and
650 * when we have been woken up by the previous owner
651 * but the lock got stolen by a higher prio task.
652 */
653 if (!waiter->task) {
654 ret = task_blocks_on_rt_mutex(lock, waiter, current,
655 detect_deadlock);
656 /*
657 * If we got woken up by the owner then start loop
658 * all over without going into schedule to try
659 * to get the lock now:
660 */
661 if (unlikely(!waiter->task)) {
662 /*
663 * Reset the return value. We might
664 * have returned with -EDEADLK and the
665 * owner released the lock while we
666 * were walking the pi chain.
667 */
668 ret = 0;
669 continue;
670 }
671 if (unlikely(ret))
672 break;
673 }
674
675 raw_spin_unlock(&lock->wait_lock); 602 raw_spin_unlock(&lock->wait_lock);
676 603
677 debug_rt_mutex_print_deadlock(waiter); 604 debug_rt_mutex_print_deadlock(waiter);
678 605
679 if (waiter->task) 606 schedule_rt_mutex(lock);
680 schedule_rt_mutex(lock);
681 607
682 raw_spin_lock(&lock->wait_lock); 608 raw_spin_lock(&lock->wait_lock);
683 set_current_state(state); 609 set_current_state(state);
@@ -698,12 +624,11 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state,
698 int ret = 0; 624 int ret = 0;
699 625
700 debug_rt_mutex_init_waiter(&waiter); 626 debug_rt_mutex_init_waiter(&waiter);
701 waiter.task = NULL;
702 627
703 raw_spin_lock(&lock->wait_lock); 628 raw_spin_lock(&lock->wait_lock);
704 629
705 /* Try to acquire the lock again: */ 630 /* Try to acquire the lock again: */
706 if (try_to_take_rt_mutex(lock)) { 631 if (try_to_take_rt_mutex(lock, current, NULL)) {
707 raw_spin_unlock(&lock->wait_lock); 632 raw_spin_unlock(&lock->wait_lock);
708 return 0; 633 return 0;
709 } 634 }
@@ -717,12 +642,14 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state,
717 timeout->task = NULL; 642 timeout->task = NULL;
718 } 643 }
719 644
720 ret = __rt_mutex_slowlock(lock, state, timeout, &waiter, 645 ret = task_blocks_on_rt_mutex(lock, &waiter, current, detect_deadlock);
721 detect_deadlock); 646
647 if (likely(!ret))
648 ret = __rt_mutex_slowlock(lock, state, timeout, &waiter);
722 649
723 set_current_state(TASK_RUNNING); 650 set_current_state(TASK_RUNNING);
724 651
725 if (unlikely(waiter.task)) 652 if (unlikely(ret))
726 remove_waiter(lock, &waiter); 653 remove_waiter(lock, &waiter);
727 654
728 /* 655 /*
@@ -737,14 +664,6 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state,
737 if (unlikely(timeout)) 664 if (unlikely(timeout))
738 hrtimer_cancel(&timeout->timer); 665 hrtimer_cancel(&timeout->timer);
739 666
740 /*
741 * Readjust priority, when we did not get the lock. We might
742 * have been the pending owner and boosted. Since we did not
743 * take the lock, the PI boost has to go.
744 */
745 if (unlikely(ret))
746 rt_mutex_adjust_prio(current);
747
748 debug_rt_mutex_free_waiter(&waiter); 667 debug_rt_mutex_free_waiter(&waiter);
749 668
750 return ret; 669 return ret;
@@ -762,7 +681,7 @@ rt_mutex_slowtrylock(struct rt_mutex *lock)
762 681
763 if (likely(rt_mutex_owner(lock) != current)) { 682 if (likely(rt_mutex_owner(lock) != current)) {
764 683
765 ret = try_to_take_rt_mutex(lock); 684 ret = try_to_take_rt_mutex(lock, current, NULL);
766 /* 685 /*
767 * try_to_take_rt_mutex() sets the lock waiters 686 * try_to_take_rt_mutex() sets the lock waiters
768 * bit unconditionally. Clean this up. 687 * bit unconditionally. Clean this up.
@@ -992,7 +911,7 @@ void rt_mutex_init_proxy_locked(struct rt_mutex *lock,
992{ 911{
993 __rt_mutex_init(lock, NULL); 912 __rt_mutex_init(lock, NULL);
994 debug_rt_mutex_proxy_lock(lock, proxy_owner); 913 debug_rt_mutex_proxy_lock(lock, proxy_owner);
995 rt_mutex_set_owner(lock, proxy_owner, 0); 914 rt_mutex_set_owner(lock, proxy_owner);
996 rt_mutex_deadlock_account_lock(lock, proxy_owner); 915 rt_mutex_deadlock_account_lock(lock, proxy_owner);
997} 916}
998 917
@@ -1008,7 +927,7 @@ void rt_mutex_proxy_unlock(struct rt_mutex *lock,
1008 struct task_struct *proxy_owner) 927 struct task_struct *proxy_owner)
1009{ 928{
1010 debug_rt_mutex_proxy_unlock(lock); 929 debug_rt_mutex_proxy_unlock(lock);
1011 rt_mutex_set_owner(lock, NULL, 0); 930 rt_mutex_set_owner(lock, NULL);
1012 rt_mutex_deadlock_account_unlock(proxy_owner); 931 rt_mutex_deadlock_account_unlock(proxy_owner);
1013} 932}
1014 933
@@ -1034,20 +953,14 @@ int rt_mutex_start_proxy_lock(struct rt_mutex *lock,
1034 953
1035 raw_spin_lock(&lock->wait_lock); 954 raw_spin_lock(&lock->wait_lock);
1036 955
1037 mark_rt_mutex_waiters(lock); 956 if (try_to_take_rt_mutex(lock, task, NULL)) {
1038
1039 if (!rt_mutex_owner(lock) || try_to_steal_lock(lock, task)) {
1040 /* We got the lock for task. */
1041 debug_rt_mutex_lock(lock);
1042 rt_mutex_set_owner(lock, task, 0);
1043 raw_spin_unlock(&lock->wait_lock); 957 raw_spin_unlock(&lock->wait_lock);
1044 rt_mutex_deadlock_account_lock(lock, task);
1045 return 1; 958 return 1;
1046 } 959 }
1047 960
1048 ret = task_blocks_on_rt_mutex(lock, waiter, task, detect_deadlock); 961 ret = task_blocks_on_rt_mutex(lock, waiter, task, detect_deadlock);
1049 962
1050 if (ret && !waiter->task) { 963 if (ret && !rt_mutex_owner(lock)) {
1051 /* 964 /*
1052 * Reset the return value. We might have 965 * Reset the return value. We might have
1053 * returned with -EDEADLK and the owner 966 * returned with -EDEADLK and the owner
@@ -1056,6 +969,10 @@ int rt_mutex_start_proxy_lock(struct rt_mutex *lock,
1056 */ 969 */
1057 ret = 0; 970 ret = 0;
1058 } 971 }
972
973 if (unlikely(ret))
974 remove_waiter(lock, waiter);
975
1059 raw_spin_unlock(&lock->wait_lock); 976 raw_spin_unlock(&lock->wait_lock);
1060 977
1061 debug_rt_mutex_print_deadlock(waiter); 978 debug_rt_mutex_print_deadlock(waiter);
@@ -1110,12 +1027,11 @@ int rt_mutex_finish_proxy_lock(struct rt_mutex *lock,
1110 1027
1111 set_current_state(TASK_INTERRUPTIBLE); 1028 set_current_state(TASK_INTERRUPTIBLE);
1112 1029
1113 ret = __rt_mutex_slowlock(lock, TASK_INTERRUPTIBLE, to, waiter, 1030 ret = __rt_mutex_slowlock(lock, TASK_INTERRUPTIBLE, to, waiter);
1114 detect_deadlock);
1115 1031
1116 set_current_state(TASK_RUNNING); 1032 set_current_state(TASK_RUNNING);
1117 1033
1118 if (unlikely(waiter->task)) 1034 if (unlikely(ret))
1119 remove_waiter(lock, waiter); 1035 remove_waiter(lock, waiter);
1120 1036
1121 /* 1037 /*
@@ -1126,13 +1042,5 @@ int rt_mutex_finish_proxy_lock(struct rt_mutex *lock,
1126 1042
1127 raw_spin_unlock(&lock->wait_lock); 1043 raw_spin_unlock(&lock->wait_lock);
1128 1044
1129 /*
1130 * Readjust priority, when we did not get the lock. We might have been
1131 * the pending owner and boosted. Since we did not take the lock, the
1132 * PI boost has to go.
1133 */
1134 if (unlikely(ret))
1135 rt_mutex_adjust_prio(current);
1136
1137 return ret; 1045 return ret;
1138} 1046}
diff --git a/kernel/rtmutex_common.h b/kernel/rtmutex_common.h
index 97a2f81866af..53a66c85261b 100644
--- a/kernel/rtmutex_common.h
+++ b/kernel/rtmutex_common.h
@@ -91,9 +91,8 @@ task_top_pi_waiter(struct task_struct *p)
91/* 91/*
92 * lock->owner state tracking: 92 * lock->owner state tracking:
93 */ 93 */
94#define RT_MUTEX_OWNER_PENDING 1UL 94#define RT_MUTEX_HAS_WAITERS 1UL
95#define RT_MUTEX_HAS_WAITERS 2UL 95#define RT_MUTEX_OWNER_MASKALL 1UL
96#define RT_MUTEX_OWNER_MASKALL 3UL
97 96
98static inline struct task_struct *rt_mutex_owner(struct rt_mutex *lock) 97static inline struct task_struct *rt_mutex_owner(struct rt_mutex *lock)
99{ 98{
@@ -101,17 +100,6 @@ static inline struct task_struct *rt_mutex_owner(struct rt_mutex *lock)
101 ((unsigned long)lock->owner & ~RT_MUTEX_OWNER_MASKALL); 100 ((unsigned long)lock->owner & ~RT_MUTEX_OWNER_MASKALL);
102} 101}
103 102
104static inline struct task_struct *rt_mutex_real_owner(struct rt_mutex *lock)
105{
106 return (struct task_struct *)
107 ((unsigned long)lock->owner & ~RT_MUTEX_HAS_WAITERS);
108}
109
110static inline unsigned long rt_mutex_owner_pending(struct rt_mutex *lock)
111{
112 return (unsigned long)lock->owner & RT_MUTEX_OWNER_PENDING;
113}
114
115/* 103/*
116 * PI-futex support (proxy locking functions, etc.): 104 * PI-futex support (proxy locking functions, etc.):
117 */ 105 */
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index 77e9166d7bbf..354769979c02 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -699,7 +699,8 @@ account_entity_dequeue(struct cfs_rq *cfs_rq, struct sched_entity *se)
699 cfs_rq->nr_running--; 699 cfs_rq->nr_running--;
700} 700}
701 701
702#if defined CONFIG_SMP && defined CONFIG_FAIR_GROUP_SCHED 702#ifdef CONFIG_FAIR_GROUP_SCHED
703# ifdef CONFIG_SMP
703static void update_cfs_rq_load_contribution(struct cfs_rq *cfs_rq, 704static void update_cfs_rq_load_contribution(struct cfs_rq *cfs_rq,
704 int global_update) 705 int global_update)
705{ 706{
@@ -762,6 +763,51 @@ static void update_cfs_load(struct cfs_rq *cfs_rq, int global_update)
762 list_del_leaf_cfs_rq(cfs_rq); 763 list_del_leaf_cfs_rq(cfs_rq);
763} 764}
764 765
766static long calc_cfs_shares(struct cfs_rq *cfs_rq, struct task_group *tg,
767 long weight_delta)
768{
769 long load_weight, load, shares;
770
771 load = cfs_rq->load.weight + weight_delta;
772
773 load_weight = atomic_read(&tg->load_weight);
774 load_weight -= cfs_rq->load_contribution;
775 load_weight += load;
776
777 shares = (tg->shares * load);
778 if (load_weight)
779 shares /= load_weight;
780
781 if (shares < MIN_SHARES)
782 shares = MIN_SHARES;
783 if (shares > tg->shares)
784 shares = tg->shares;
785
786 return shares;
787}
788
789static void update_entity_shares_tick(struct cfs_rq *cfs_rq)
790{
791 if (cfs_rq->load_unacc_exec_time > sysctl_sched_shares_window) {
792 update_cfs_load(cfs_rq, 0);
793 update_cfs_shares(cfs_rq, 0);
794 }
795}
796# else /* CONFIG_SMP */
797static void update_cfs_load(struct cfs_rq *cfs_rq, int global_update)
798{
799}
800
801static inline long calc_cfs_shares(struct cfs_rq *cfs_rq, struct task_group *tg,
802 long weight_delta)
803{
804 return tg->shares;
805}
806
807static inline void update_entity_shares_tick(struct cfs_rq *cfs_rq)
808{
809}
810# endif /* CONFIG_SMP */
765static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, 811static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
766 unsigned long weight) 812 unsigned long weight)
767{ 813{
@@ -782,7 +828,7 @@ static void update_cfs_shares(struct cfs_rq *cfs_rq, long weight_delta)
782{ 828{
783 struct task_group *tg; 829 struct task_group *tg;
784 struct sched_entity *se; 830 struct sched_entity *se;
785 long load_weight, load, shares; 831 long shares;
786 832
787 if (!cfs_rq) 833 if (!cfs_rq)
788 return; 834 return;
@@ -791,32 +837,14 @@ static void update_cfs_shares(struct cfs_rq *cfs_rq, long weight_delta)
791 se = tg->se[cpu_of(rq_of(cfs_rq))]; 837 se = tg->se[cpu_of(rq_of(cfs_rq))];
792 if (!se) 838 if (!se)
793 return; 839 return;
794 840#ifndef CONFIG_SMP
795 load = cfs_rq->load.weight + weight_delta; 841 if (likely(se->load.weight == tg->shares))
796 842 return;
797 load_weight = atomic_read(&tg->load_weight); 843#endif
798 load_weight -= cfs_rq->load_contribution; 844 shares = calc_cfs_shares(cfs_rq, tg, weight_delta);
799 load_weight += load;
800
801 shares = (tg->shares * load);
802 if (load_weight)
803 shares /= load_weight;
804
805 if (shares < MIN_SHARES)
806 shares = MIN_SHARES;
807 if (shares > tg->shares)
808 shares = tg->shares;
809 845
810 reweight_entity(cfs_rq_of(se), se, shares); 846 reweight_entity(cfs_rq_of(se), se, shares);
811} 847}
812
813static void update_entity_shares_tick(struct cfs_rq *cfs_rq)
814{
815 if (cfs_rq->load_unacc_exec_time > sysctl_sched_shares_window) {
816 update_cfs_load(cfs_rq, 0);
817 update_cfs_shares(cfs_rq, 0);
818 }
819}
820#else /* CONFIG_FAIR_GROUP_SCHED */ 848#else /* CONFIG_FAIR_GROUP_SCHED */
821static void update_cfs_load(struct cfs_rq *cfs_rq, int global_update) 849static void update_cfs_load(struct cfs_rq *cfs_rq, int global_update)
822{ 850{
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index bc86bb32e126..0f1bd83db985 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -170,7 +170,8 @@ static int proc_taint(struct ctl_table *table, int write,
170#endif 170#endif
171 171
172#ifdef CONFIG_MAGIC_SYSRQ 172#ifdef CONFIG_MAGIC_SYSRQ
173static int __sysrq_enabled; /* Note: sysrq code ises it's own private copy */ 173/* Note: sysrq code uses it's own private copy */
174static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE;
174 175
175static int sysrq_sysctl_handler(ctl_table *table, int write, 176static int sysrq_sysctl_handler(ctl_table *table, int write,
176 void __user *buffer, size_t *lenp, 177 void __user *buffer, size_t *lenp,
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 3e216e01bbd1..c55ea2433471 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -642,8 +642,7 @@ static void tick_nohz_switch_to_nohz(void)
642 } 642 }
643 local_irq_enable(); 643 local_irq_enable();
644 644
645 printk(KERN_INFO "Switched to NOHz mode on CPU #%d\n", 645 printk(KERN_INFO "Switched to NOHz mode on CPU #%d\n", smp_processor_id());
646 smp_processor_id());
647} 646}
648 647
649/* 648/*
@@ -795,8 +794,10 @@ void tick_setup_sched_timer(void)
795 } 794 }
796 795
797#ifdef CONFIG_NO_HZ 796#ifdef CONFIG_NO_HZ
798 if (tick_nohz_enabled) 797 if (tick_nohz_enabled) {
799 ts->nohz_mode = NOHZ_MODE_HIGHRES; 798 ts->nohz_mode = NOHZ_MODE_HIGHRES;
799 printk(KERN_INFO "Switched to NOHz mode on CPU #%d\n", smp_processor_id());
800 }
800#endif 801#endif
801} 802}
802#endif /* HIGH_RES_TIMERS */ 803#endif /* HIGH_RES_TIMERS */
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index 5086bb962b4d..7ea2e033d715 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -736,10 +736,11 @@ next:
736 } 736 }
737 } 737 }
738 /* 738 /*
739 * The iftag must have been set somewhere because otherwise 739 * We need not to tag the root tag if there is no tag which is set with
740 * we would return immediated at the beginning of the function 740 * settag within the range from *first_indexp to last_index.
741 */ 741 */
742 root_tag_set(root, settag); 742 if (tagged > 0)
743 root_tag_set(root, settag);
743 *first_indexp = index; 744 *first_indexp = index;
744 745
745 return tagged; 746 return tagged;
diff --git a/mm/Kconfig b/mm/Kconfig
index 3ad483bdf505..e9c0c61f2ddd 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -179,7 +179,7 @@ config SPLIT_PTLOCK_CPUS
179config COMPACTION 179config COMPACTION
180 bool "Allow for memory compaction" 180 bool "Allow for memory compaction"
181 select MIGRATION 181 select MIGRATION
182 depends on EXPERIMENTAL && HUGETLB_PAGE && MMU 182 depends on MMU
183 help 183 help
184 Allows the compaction of memory for the allocation of huge pages. 184 Allows the compaction of memory for the allocation of huge pages.
185 185
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index db76ef726293..3878cfe399dc 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1832,6 +1832,7 @@ static int __mem_cgroup_do_charge(struct mem_cgroup *mem, gfp_t gfp_mask,
1832 if (likely(!ret)) 1832 if (likely(!ret))
1833 return CHARGE_OK; 1833 return CHARGE_OK;
1834 1834
1835 res_counter_uncharge(&mem->res, csize);
1835 mem_over_limit = mem_cgroup_from_res_counter(fail_res, memsw); 1836 mem_over_limit = mem_cgroup_from_res_counter(fail_res, memsw);
1836 flags |= MEM_CGROUP_RECLAIM_NOSWAP; 1837 flags |= MEM_CGROUP_RECLAIM_NOSWAP;
1837 } else 1838 } else
@@ -2144,6 +2145,8 @@ void mem_cgroup_split_huge_fixup(struct page *head, struct page *tail)
2144 struct page_cgroup *tail_pc = lookup_page_cgroup(tail); 2145 struct page_cgroup *tail_pc = lookup_page_cgroup(tail);
2145 unsigned long flags; 2146 unsigned long flags;
2146 2147
2148 if (mem_cgroup_disabled())
2149 return;
2147 /* 2150 /*
2148 * We have no races with charge/uncharge but will have races with 2151 * We have no races with charge/uncharge but will have races with
2149 * page state accounting. 2152 * page state accounting.
@@ -2233,7 +2236,12 @@ static int mem_cgroup_move_account(struct page_cgroup *pc,
2233{ 2236{
2234 int ret = -EINVAL; 2237 int ret = -EINVAL;
2235 unsigned long flags; 2238 unsigned long flags;
2236 2239 /*
2240 * The page is isolated from LRU. So, collapse function
2241 * will not handle this page. But page splitting can happen.
2242 * Do this check under compound_page_lock(). The caller should
2243 * hold it.
2244 */
2237 if ((charge_size > PAGE_SIZE) && !PageTransHuge(pc->page)) 2245 if ((charge_size > PAGE_SIZE) && !PageTransHuge(pc->page))
2238 return -EBUSY; 2246 return -EBUSY;
2239 2247
@@ -2265,7 +2273,7 @@ static int mem_cgroup_move_parent(struct page_cgroup *pc,
2265 struct cgroup *cg = child->css.cgroup; 2273 struct cgroup *cg = child->css.cgroup;
2266 struct cgroup *pcg = cg->parent; 2274 struct cgroup *pcg = cg->parent;
2267 struct mem_cgroup *parent; 2275 struct mem_cgroup *parent;
2268 int charge = PAGE_SIZE; 2276 int page_size = PAGE_SIZE;
2269 unsigned long flags; 2277 unsigned long flags;
2270 int ret; 2278 int ret;
2271 2279
@@ -2278,23 +2286,26 @@ static int mem_cgroup_move_parent(struct page_cgroup *pc,
2278 goto out; 2286 goto out;
2279 if (isolate_lru_page(page)) 2287 if (isolate_lru_page(page))
2280 goto put; 2288 goto put;
2281 /* The page is isolated from LRU and we have no race with splitting */ 2289
2282 charge = PAGE_SIZE << compound_order(page); 2290 if (PageTransHuge(page))
2291 page_size = HPAGE_SIZE;
2283 2292
2284 parent = mem_cgroup_from_cont(pcg); 2293 parent = mem_cgroup_from_cont(pcg);
2285 ret = __mem_cgroup_try_charge(NULL, gfp_mask, &parent, false, charge); 2294 ret = __mem_cgroup_try_charge(NULL, gfp_mask,
2295 &parent, false, page_size);
2286 if (ret || !parent) 2296 if (ret || !parent)
2287 goto put_back; 2297 goto put_back;
2288 2298
2289 if (charge > PAGE_SIZE) 2299 if (page_size > PAGE_SIZE)
2290 flags = compound_lock_irqsave(page); 2300 flags = compound_lock_irqsave(page);
2291 2301
2292 ret = mem_cgroup_move_account(pc, child, parent, true, charge); 2302 ret = mem_cgroup_move_account(pc, child, parent, true, page_size);
2293 if (ret) 2303 if (ret)
2294 mem_cgroup_cancel_charge(parent, charge); 2304 mem_cgroup_cancel_charge(parent, page_size);
2295put_back: 2305
2296 if (charge > PAGE_SIZE) 2306 if (page_size > PAGE_SIZE)
2297 compound_unlock_irqrestore(page, flags); 2307 compound_unlock_irqrestore(page, flags);
2308put_back:
2298 putback_lru_page(page); 2309 putback_lru_page(page);
2299put: 2310put:
2300 put_page(page); 2311 put_page(page);
diff --git a/mm/migrate.c b/mm/migrate.c
index 46fe8cc13d67..9f29a3b7aac2 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -888,7 +888,7 @@ out:
888 * are movable anymore because to has become empty 888 * are movable anymore because to has become empty
889 * or no retryable pages exist anymore. 889 * or no retryable pages exist anymore.
890 * Caller should call putback_lru_pages to return pages to the LRU 890 * Caller should call putback_lru_pages to return pages to the LRU
891 * or free list. 891 * or free list only if ret != 0.
892 * 892 *
893 * Return: Number of pages not migrated or error code. 893 * Return: Number of pages not migrated or error code.
894 */ 894 */
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 90c1439549fd..a873e61e312e 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1088,8 +1088,10 @@ static void drain_pages(unsigned int cpu)
1088 pset = per_cpu_ptr(zone->pageset, cpu); 1088 pset = per_cpu_ptr(zone->pageset, cpu);
1089 1089
1090 pcp = &pset->pcp; 1090 pcp = &pset->pcp;
1091 free_pcppages_bulk(zone, pcp->count, pcp); 1091 if (pcp->count) {
1092 pcp->count = 0; 1092 free_pcppages_bulk(zone, pcp->count, pcp);
1093 pcp->count = 0;
1094 }
1093 local_irq_restore(flags); 1095 local_irq_restore(flags);
1094 } 1096 }
1095} 1097}
@@ -2034,6 +2036,14 @@ restart:
2034 */ 2036 */
2035 alloc_flags = gfp_to_alloc_flags(gfp_mask); 2037 alloc_flags = gfp_to_alloc_flags(gfp_mask);
2036 2038
2039 /*
2040 * Find the true preferred zone if the allocation is unconstrained by
2041 * cpusets.
2042 */
2043 if (!(alloc_flags & ALLOC_CPUSET) && !nodemask)
2044 first_zones_zonelist(zonelist, high_zoneidx, NULL,
2045 &preferred_zone);
2046
2037 /* This is the last chance, in general, before the goto nopage. */ 2047 /* This is the last chance, in general, before the goto nopage. */
2038 page = get_page_from_freelist(gfp_mask, nodemask, order, zonelist, 2048 page = get_page_from_freelist(gfp_mask, nodemask, order, zonelist,
2039 high_zoneidx, alloc_flags & ~ALLOC_NO_WATERMARKS, 2049 high_zoneidx, alloc_flags & ~ALLOC_NO_WATERMARKS,
@@ -2192,7 +2202,9 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order,
2192 2202
2193 get_mems_allowed(); 2203 get_mems_allowed();
2194 /* The preferred zone is used for statistics later */ 2204 /* The preferred zone is used for statistics later */
2195 first_zones_zonelist(zonelist, high_zoneidx, nodemask, &preferred_zone); 2205 first_zones_zonelist(zonelist, high_zoneidx,
2206 nodemask ? : &cpuset_current_mems_allowed,
2207 &preferred_zone);
2196 if (!preferred_zone) { 2208 if (!preferred_zone) {
2197 put_mems_allowed(); 2209 put_mems_allowed();
2198 return NULL; 2210 return NULL;
diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c
index 0369f5b3ba1b..eb663fb533e0 100644
--- a/mm/pgtable-generic.c
+++ b/mm/pgtable-generic.c
@@ -6,6 +6,7 @@
6 * Copyright (C) 2010 Linus Torvalds 6 * Copyright (C) 2010 Linus Torvalds
7 */ 7 */
8 8
9#include <linux/pagemap.h>
9#include <asm/tlb.h> 10#include <asm/tlb.h>
10#include <asm-generic/pgtable.h> 11#include <asm-generic/pgtable.h>
11 12
diff --git a/mm/vmscan.c b/mm/vmscan.c
index f5d90dedebba..148c6e630df2 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2083,7 +2083,8 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
2083 struct zone *preferred_zone; 2083 struct zone *preferred_zone;
2084 2084
2085 first_zones_zonelist(zonelist, gfp_zone(sc->gfp_mask), 2085 first_zones_zonelist(zonelist, gfp_zone(sc->gfp_mask),
2086 NULL, &preferred_zone); 2086 &cpuset_current_mems_allowed,
2087 &preferred_zone);
2087 wait_iff_congested(preferred_zone, BLK_RW_ASYNC, HZ/10); 2088 wait_iff_congested(preferred_zone, BLK_RW_ASYNC, HZ/10);
2088 } 2089 }
2089 } 2090 }
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 0c877a74e1f4..3fb14b7c13cf 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -428,7 +428,7 @@ static void __exit dsa_cleanup_module(void)
428} 428}
429module_exit(dsa_cleanup_module); 429module_exit(dsa_cleanup_module);
430 430
431MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>") 431MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
432MODULE_DESCRIPTION("Driver for Distributed Switch Architecture switch chips"); 432MODULE_DESCRIPTION("Driver for Distributed Switch Architecture switch chips");
433MODULE_LICENSE("GPL"); 433MODULE_LICENSE("GPL");
434MODULE_ALIAS("platform:dsa"); 434MODULE_ALIAS("platform:dsa");
diff --git a/security/keys/Makefile b/security/keys/Makefile
index 6c941050f573..1bf090a885fe 100644
--- a/security/keys/Makefile
+++ b/security/keys/Makefile
@@ -13,8 +13,8 @@ obj-y := \
13 request_key_auth.o \ 13 request_key_auth.o \
14 user_defined.o 14 user_defined.o
15 15
16obj-$(CONFIG_TRUSTED_KEYS) += trusted_defined.o 16obj-$(CONFIG_TRUSTED_KEYS) += trusted.o
17obj-$(CONFIG_ENCRYPTED_KEYS) += encrypted_defined.o 17obj-$(CONFIG_ENCRYPTED_KEYS) += encrypted.o
18obj-$(CONFIG_KEYS_COMPAT) += compat.o 18obj-$(CONFIG_KEYS_COMPAT) += compat.o
19obj-$(CONFIG_PROC_FS) += proc.o 19obj-$(CONFIG_PROC_FS) += proc.o
20obj-$(CONFIG_SYSCTL) += sysctl.o 20obj-$(CONFIG_SYSCTL) += sysctl.o
diff --git a/security/keys/encrypted_defined.c b/security/keys/encrypted.c
index 28791a65740e..9e7e4ce3fae8 100644
--- a/security/keys/encrypted_defined.c
+++ b/security/keys/encrypted.c
@@ -30,7 +30,7 @@
30#include <crypto/sha.h> 30#include <crypto/sha.h>
31#include <crypto/aes.h> 31#include <crypto/aes.h>
32 32
33#include "encrypted_defined.h" 33#include "encrypted.h"
34 34
35static const char KEY_TRUSTED_PREFIX[] = "trusted:"; 35static const char KEY_TRUSTED_PREFIX[] = "trusted:";
36static const char KEY_USER_PREFIX[] = "user:"; 36static const char KEY_USER_PREFIX[] = "user:";
@@ -888,6 +888,7 @@ static int __init init_encrypted(void)
888out: 888out:
889 encrypted_shash_release(); 889 encrypted_shash_release();
890 return ret; 890 return ret;
891
891} 892}
892 893
893static void __exit cleanup_encrypted(void) 894static void __exit cleanup_encrypted(void)
diff --git a/security/keys/encrypted_defined.h b/security/keys/encrypted.h
index cef5e2f2b7d1..cef5e2f2b7d1 100644
--- a/security/keys/encrypted_defined.h
+++ b/security/keys/encrypted.h
diff --git a/security/keys/internal.h b/security/keys/internal.h
index edfa50dbd6f5..a52aa7c88b41 100644
--- a/security/keys/internal.h
+++ b/security/keys/internal.h
@@ -87,13 +87,13 @@ extern void key_type_put(struct key_type *ktype);
87extern int __key_link_begin(struct key *keyring, 87extern int __key_link_begin(struct key *keyring,
88 const struct key_type *type, 88 const struct key_type *type,
89 const char *description, 89 const char *description,
90 struct keyring_list **_prealloc); 90 unsigned long *_prealloc);
91extern int __key_link_check_live_key(struct key *keyring, struct key *key); 91extern int __key_link_check_live_key(struct key *keyring, struct key *key);
92extern void __key_link(struct key *keyring, struct key *key, 92extern void __key_link(struct key *keyring, struct key *key,
93 struct keyring_list **_prealloc); 93 unsigned long *_prealloc);
94extern void __key_link_end(struct key *keyring, 94extern void __key_link_end(struct key *keyring,
95 struct key_type *type, 95 struct key_type *type,
96 struct keyring_list *prealloc); 96 unsigned long prealloc);
97 97
98extern key_ref_t __keyring_search_one(key_ref_t keyring_ref, 98extern key_ref_t __keyring_search_one(key_ref_t keyring_ref,
99 const struct key_type *type, 99 const struct key_type *type,
diff --git a/security/keys/key.c b/security/keys/key.c
index 84d4eb568b08..1c2d43dc5107 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -415,7 +415,7 @@ static int __key_instantiate_and_link(struct key *key,
415 size_t datalen, 415 size_t datalen,
416 struct key *keyring, 416 struct key *keyring,
417 struct key *authkey, 417 struct key *authkey,
418 struct keyring_list **_prealloc) 418 unsigned long *_prealloc)
419{ 419{
420 int ret, awaken; 420 int ret, awaken;
421 421
@@ -481,7 +481,7 @@ int key_instantiate_and_link(struct key *key,
481 struct key *keyring, 481 struct key *keyring,
482 struct key *authkey) 482 struct key *authkey)
483{ 483{
484 struct keyring_list *prealloc; 484 unsigned long prealloc;
485 int ret; 485 int ret;
486 486
487 if (keyring) { 487 if (keyring) {
@@ -526,7 +526,7 @@ int key_negate_and_link(struct key *key,
526 struct key *keyring, 526 struct key *keyring,
527 struct key *authkey) 527 struct key *authkey)
528{ 528{
529 struct keyring_list *prealloc; 529 unsigned long prealloc;
530 struct timespec now; 530 struct timespec now;
531 int ret, awaken, link_ret = 0; 531 int ret, awaken, link_ret = 0;
532 532
@@ -814,7 +814,7 @@ key_ref_t key_create_or_update(key_ref_t keyring_ref,
814 key_perm_t perm, 814 key_perm_t perm,
815 unsigned long flags) 815 unsigned long flags)
816{ 816{
817 struct keyring_list *prealloc; 817 unsigned long prealloc;
818 const struct cred *cred = current_cred(); 818 const struct cred *cred = current_cred();
819 struct key_type *ktype; 819 struct key_type *ktype;
820 struct key *keyring, *key = NULL; 820 struct key *keyring, *key = NULL;
diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index 92024ed12e0a..5620f084dede 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -25,6 +25,8 @@
25 (keyring)->payload.subscriptions, \ 25 (keyring)->payload.subscriptions, \
26 rwsem_is_locked((struct rw_semaphore *)&(keyring)->sem))) 26 rwsem_is_locked((struct rw_semaphore *)&(keyring)->sem)))
27 27
28#define KEY_LINK_FIXQUOTA 1UL
29
28/* 30/*
29 * When plumbing the depths of the key tree, this sets a hard limit 31 * When plumbing the depths of the key tree, this sets a hard limit
30 * set on how deep we're willing to go. 32 * set on how deep we're willing to go.
@@ -699,11 +701,11 @@ static void keyring_unlink_rcu_disposal(struct rcu_head *rcu)
699 * Preallocate memory so that a key can be linked into to a keyring. 701 * Preallocate memory so that a key can be linked into to a keyring.
700 */ 702 */
701int __key_link_begin(struct key *keyring, const struct key_type *type, 703int __key_link_begin(struct key *keyring, const struct key_type *type,
702 const char *description, 704 const char *description, unsigned long *_prealloc)
703 struct keyring_list **_prealloc)
704 __acquires(&keyring->sem) 705 __acquires(&keyring->sem)
705{ 706{
706 struct keyring_list *klist, *nklist; 707 struct keyring_list *klist, *nklist;
708 unsigned long prealloc;
707 unsigned max; 709 unsigned max;
708 size_t size; 710 size_t size;
709 int loop, ret; 711 int loop, ret;
@@ -746,6 +748,7 @@ int __key_link_begin(struct key *keyring, const struct key_type *type,
746 748
747 /* note replacement slot */ 749 /* note replacement slot */
748 klist->delkey = nklist->delkey = loop; 750 klist->delkey = nklist->delkey = loop;
751 prealloc = (unsigned long)nklist;
749 goto done; 752 goto done;
750 } 753 }
751 } 754 }
@@ -760,6 +763,7 @@ int __key_link_begin(struct key *keyring, const struct key_type *type,
760 if (klist && klist->nkeys < klist->maxkeys) { 763 if (klist && klist->nkeys < klist->maxkeys) {
761 /* there's sufficient slack space to append directly */ 764 /* there's sufficient slack space to append directly */
762 nklist = NULL; 765 nklist = NULL;
766 prealloc = KEY_LINK_FIXQUOTA;
763 } else { 767 } else {
764 /* grow the key list */ 768 /* grow the key list */
765 max = 4; 769 max = 4;
@@ -794,8 +798,9 @@ int __key_link_begin(struct key *keyring, const struct key_type *type,
794 nklist->keys[nklist->delkey] = NULL; 798 nklist->keys[nklist->delkey] = NULL;
795 } 799 }
796 800
801 prealloc = (unsigned long)nklist | KEY_LINK_FIXQUOTA;
797done: 802done:
798 *_prealloc = nklist; 803 *_prealloc = prealloc;
799 kleave(" = 0"); 804 kleave(" = 0");
800 return 0; 805 return 0;
801 806
@@ -836,12 +841,12 @@ int __key_link_check_live_key(struct key *keyring, struct key *key)
836 * combination. 841 * combination.
837 */ 842 */
838void __key_link(struct key *keyring, struct key *key, 843void __key_link(struct key *keyring, struct key *key,
839 struct keyring_list **_prealloc) 844 unsigned long *_prealloc)
840{ 845{
841 struct keyring_list *klist, *nklist; 846 struct keyring_list *klist, *nklist;
842 847
843 nklist = *_prealloc; 848 nklist = (struct keyring_list *)(*_prealloc & ~KEY_LINK_FIXQUOTA);
844 *_prealloc = NULL; 849 *_prealloc = 0;
845 850
846 kenter("%d,%d,%p", keyring->serial, key->serial, nklist); 851 kenter("%d,%d,%p", keyring->serial, key->serial, nklist);
847 852
@@ -881,20 +886,22 @@ void __key_link(struct key *keyring, struct key *key,
881 * Must be called with __key_link_begin() having being called. 886 * Must be called with __key_link_begin() having being called.
882 */ 887 */
883void __key_link_end(struct key *keyring, struct key_type *type, 888void __key_link_end(struct key *keyring, struct key_type *type,
884 struct keyring_list *prealloc) 889 unsigned long prealloc)
885 __releases(&keyring->sem) 890 __releases(&keyring->sem)
886{ 891{
887 BUG_ON(type == NULL); 892 BUG_ON(type == NULL);
888 BUG_ON(type->name == NULL); 893 BUG_ON(type->name == NULL);
889 kenter("%d,%s,%p", keyring->serial, type->name, prealloc); 894 kenter("%d,%s,%lx", keyring->serial, type->name, prealloc);
890 895
891 if (type == &key_type_keyring) 896 if (type == &key_type_keyring)
892 up_write(&keyring_serialise_link_sem); 897 up_write(&keyring_serialise_link_sem);
893 898
894 if (prealloc) { 899 if (prealloc) {
895 kfree(prealloc); 900 if (prealloc & KEY_LINK_FIXQUOTA)
896 key_payload_reserve(keyring, 901 key_payload_reserve(keyring,
897 keyring->datalen - KEYQUOTA_LINK_BYTES); 902 keyring->datalen -
903 KEYQUOTA_LINK_BYTES);
904 kfree((struct keyring_list *)(prealloc & ~KEY_LINK_FIXQUOTA));
898 } 905 }
899 up_write(&keyring->sem); 906 up_write(&keyring->sem);
900} 907}
@@ -921,7 +928,7 @@ void __key_link_end(struct key *keyring, struct key_type *type,
921 */ 928 */
922int key_link(struct key *keyring, struct key *key) 929int key_link(struct key *keyring, struct key *key)
923{ 930{
924 struct keyring_list *prealloc; 931 unsigned long prealloc;
925 int ret; 932 int ret;
926 933
927 key_check(keyring); 934 key_check(keyring);
diff --git a/security/keys/request_key.c b/security/keys/request_key.c
index 9a7fb3914b27..a3dc0d460def 100644
--- a/security/keys/request_key.c
+++ b/security/keys/request_key.c
@@ -352,8 +352,8 @@ static int construct_alloc_key(struct key_type *type,
352 struct key_user *user, 352 struct key_user *user,
353 struct key **_key) 353 struct key **_key)
354{ 354{
355 struct keyring_list *prealloc;
356 const struct cred *cred = current_cred(); 355 const struct cred *cred = current_cred();
356 unsigned long prealloc;
357 struct key *key; 357 struct key *key;
358 key_ref_t key_ref; 358 key_ref_t key_ref;
359 int ret; 359 int ret;
diff --git a/security/keys/trusted_defined.c b/security/keys/trusted.c
index 2836c6dc18a3..83fc92e297cd 100644
--- a/security/keys/trusted_defined.c
+++ b/security/keys/trusted.c
@@ -29,7 +29,7 @@
29#include <linux/tpm.h> 29#include <linux/tpm.h>
30#include <linux/tpm_command.h> 30#include <linux/tpm_command.h>
31 31
32#include "trusted_defined.h" 32#include "trusted.h"
33 33
34static const char hmac_alg[] = "hmac(sha1)"; 34static const char hmac_alg[] = "hmac(sha1)";
35static const char hash_alg[] = "sha1"; 35static const char hash_alg[] = "sha1";
@@ -1032,6 +1032,7 @@ static int trusted_update(struct key *key, const void *data, size_t datalen)
1032 ret = datablob_parse(datablob, new_p, new_o); 1032 ret = datablob_parse(datablob, new_p, new_o);
1033 if (ret != Opt_update) { 1033 if (ret != Opt_update) {
1034 ret = -EINVAL; 1034 ret = -EINVAL;
1035 kfree(new_p);
1035 goto out; 1036 goto out;
1036 } 1037 }
1037 /* copy old key values, and reseal with new pcrs */ 1038 /* copy old key values, and reseal with new pcrs */
diff --git a/security/keys/trusted_defined.h b/security/keys/trusted.h
index 3249fbd2b653..3249fbd2b653 100644
--- a/security/keys/trusted_defined.h
+++ b/security/keys/trusted.h
diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c
index c3f845cbcd48..a53373207fb4 100644
--- a/security/selinux/ss/conditional.c
+++ b/security/selinux/ss/conditional.c
@@ -178,7 +178,7 @@ int cond_init_bool_indexes(struct policydb *p)
178 p->bool_val_to_struct = (struct cond_bool_datum **) 178 p->bool_val_to_struct = (struct cond_bool_datum **)
179 kmalloc(p->p_bools.nprim * sizeof(struct cond_bool_datum *), GFP_KERNEL); 179 kmalloc(p->p_bools.nprim * sizeof(struct cond_bool_datum *), GFP_KERNEL);
180 if (!p->bool_val_to_struct) 180 if (!p->bool_val_to_struct)
181 return -1; 181 return -ENOMEM;
182 return 0; 182 return 0;
183} 183}
184 184
diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
index be9de3872837..57363562f0f8 100644
--- a/security/selinux/ss/policydb.c
+++ b/security/selinux/ss/policydb.c
@@ -501,8 +501,8 @@ static int policydb_index(struct policydb *p)
501 if (rc) 501 if (rc)
502 goto out; 502 goto out;
503 503
504 rc = -ENOMEM; 504 rc = cond_init_bool_indexes(p);
505 if (cond_init_bool_indexes(p)) 505 if (rc)
506 goto out; 506 goto out;
507 507
508 for (i = 0; i < SYM_NUM; i++) { 508 for (i = 0; i < SYM_NUM; i++) {
diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c
index 91acc9a243ec..24d3013c0231 100644
--- a/sound/arm/aaci.c
+++ b/sound/arm/aaci.c
@@ -30,6 +30,8 @@
30 30
31#define DRIVER_NAME "aaci-pl041" 31#define DRIVER_NAME "aaci-pl041"
32 32
33#define FRAME_PERIOD_US 21
34
33/* 35/*
34 * PM support is not complete. Turn it off. 36 * PM support is not complete. Turn it off.
35 */ 37 */
@@ -64,8 +66,8 @@ static void aaci_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
64 unsigned short val) 66 unsigned short val)
65{ 67{
66 struct aaci *aaci = ac97->private_data; 68 struct aaci *aaci = ac97->private_data;
69 int timeout;
67 u32 v; 70 u32 v;
68 int timeout = 5000;
69 71
70 if (ac97->num >= 4) 72 if (ac97->num >= 4)
71 return; 73 return;
@@ -81,14 +83,17 @@ static void aaci_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
81 writel(val << 4, aaci->base + AACI_SL2TX); 83 writel(val << 4, aaci->base + AACI_SL2TX);
82 writel(reg << 12, aaci->base + AACI_SL1TX); 84 writel(reg << 12, aaci->base + AACI_SL1TX);
83 85
84 /* 86 /* Initially, wait one frame period */
85 * Wait for the transmission of both slots to complete. 87 udelay(FRAME_PERIOD_US);
86 */ 88
89 /* And then wait an additional eight frame periods for it to be sent */
90 timeout = FRAME_PERIOD_US * 8;
87 do { 91 do {
92 udelay(1);
88 v = readl(aaci->base + AACI_SLFR); 93 v = readl(aaci->base + AACI_SLFR);
89 } while ((v & (SLFR_1TXB|SLFR_2TXB)) && --timeout); 94 } while ((v & (SLFR_1TXB|SLFR_2TXB)) && --timeout);
90 95
91 if (!timeout) 96 if (v & (SLFR_1TXB|SLFR_2TXB))
92 dev_err(&aaci->dev->dev, 97 dev_err(&aaci->dev->dev,
93 "timeout waiting for write to complete\n"); 98 "timeout waiting for write to complete\n");
94 99
@@ -101,9 +106,8 @@ static void aaci_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
101static unsigned short aaci_ac97_read(struct snd_ac97 *ac97, unsigned short reg) 106static unsigned short aaci_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
102{ 107{
103 struct aaci *aaci = ac97->private_data; 108 struct aaci *aaci = ac97->private_data;
109 int timeout, retries = 10;
104 u32 v; 110 u32 v;
105 int timeout = 5000;
106 int retries = 10;
107 111
108 if (ac97->num >= 4) 112 if (ac97->num >= 4)
109 return ~0; 113 return ~0;
@@ -117,35 +121,34 @@ static unsigned short aaci_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
117 */ 121 */
118 writel((reg << 12) | (1 << 19), aaci->base + AACI_SL1TX); 122 writel((reg << 12) | (1 << 19), aaci->base + AACI_SL1TX);
119 123
120 /* 124 /* Initially, wait one frame period */
121 * Wait for the transmission to complete. 125 udelay(FRAME_PERIOD_US);
122 */ 126
127 /* And then wait an additional eight frame periods for it to be sent */
128 timeout = FRAME_PERIOD_US * 8;
123 do { 129 do {
130 udelay(1);
124 v = readl(aaci->base + AACI_SLFR); 131 v = readl(aaci->base + AACI_SLFR);
125 } while ((v & SLFR_1TXB) && --timeout); 132 } while ((v & SLFR_1TXB) && --timeout);
126 133
127 if (!timeout) { 134 if (v & SLFR_1TXB) {
128 dev_err(&aaci->dev->dev, "timeout on slot 1 TX busy\n"); 135 dev_err(&aaci->dev->dev, "timeout on slot 1 TX busy\n");
129 v = ~0; 136 v = ~0;
130 goto out; 137 goto out;
131 } 138 }
132 139
133 /* 140 /* Now wait for the response frame */
134 * Give the AC'97 codec more than enough time 141 udelay(FRAME_PERIOD_US);
135 * to respond. (42us = ~2 frames at 48kHz.)
136 */
137 udelay(42);
138 142
139 /* 143 /* And then wait an additional eight frame periods for data */
140 * Wait for slot 2 to indicate data. 144 timeout = FRAME_PERIOD_US * 8;
141 */
142 timeout = 5000;
143 do { 145 do {
146 udelay(1);
144 cond_resched(); 147 cond_resched();
145 v = readl(aaci->base + AACI_SLFR) & (SLFR_1RXV|SLFR_2RXV); 148 v = readl(aaci->base + AACI_SLFR) & (SLFR_1RXV|SLFR_2RXV);
146 } while ((v != (SLFR_1RXV|SLFR_2RXV)) && --timeout); 149 } while ((v != (SLFR_1RXV|SLFR_2RXV)) && --timeout);
147 150
148 if (!timeout) { 151 if (v != (SLFR_1RXV|SLFR_2RXV)) {
149 dev_err(&aaci->dev->dev, "timeout on RX valid\n"); 152 dev_err(&aaci->dev->dev, "timeout on RX valid\n");
150 v = ~0; 153 v = ~0;
151 goto out; 154 goto out;
@@ -179,6 +182,7 @@ aaci_chan_wait_ready(struct aaci_runtime *aacirun, unsigned long mask)
179 int timeout = 5000; 182 int timeout = 5000;
180 183
181 do { 184 do {
185 udelay(1);
182 val = readl(aacirun->base + AACI_SR); 186 val = readl(aacirun->base + AACI_SR);
183 } while (val & mask && timeout--); 187 } while (val & mask && timeout--);
184} 188}
@@ -874,7 +878,7 @@ static int __devinit aaci_probe_ac97(struct aaci *aaci)
874 * Give the AC'97 codec more than enough time 878 * Give the AC'97 codec more than enough time
875 * to wake up. (42us = ~2 frames at 48kHz.) 879 * to wake up. (42us = ~2 frames at 48kHz.)
876 */ 880 */
877 udelay(42); 881 udelay(FRAME_PERIOD_US * 2);
878 882
879 ret = snd_ac97_bus(aaci->card, 0, &aaci_bus_ops, aaci, &ac97_bus); 883 ret = snd_ac97_bus(aaci->card, 0, &aaci_bus_ops, aaci, &ac97_bus);
880 if (ret) 884 if (ret)
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 2b5387d53ba5..7141c42e1469 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -204,13 +204,11 @@ EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow
204EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Winit-self 204EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Winit-self
205EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wpacked 205EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wpacked
206EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wredundant-decls 206EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wredundant-decls
207EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstack-protector
208EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-aliasing=3 207EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-aliasing=3
209EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-default 208EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-default
210EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-enum 209EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-enum
211EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wno-system-headers 210EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wno-system-headers
212EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wundef 211EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wundef
213EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wvolatile-register-var
214EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wwrite-strings 212EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wwrite-strings
215EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wbad-function-cast 213EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wbad-function-cast
216EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wmissing-declarations 214EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wmissing-declarations
@@ -294,6 +292,13 @@ ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -fstack-protector-all),y)
294 CFLAGS := $(CFLAGS) -fstack-protector-all 292 CFLAGS := $(CFLAGS) -fstack-protector-all
295endif 293endif
296 294
295ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -Wstack-protector),y)
296 CFLAGS := $(CFLAGS) -Wstack-protector
297endif
298
299ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -Wvolatile-register-var),y)
300 CFLAGS := $(CFLAGS) -Wvolatile-register-var
301endif
297 302
298### --- END CONFIGURATION SECTION --- 303### --- END CONFIGURATION SECTION ---
299 304
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index c056cdc06912..8879463807e4 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -212,7 +212,7 @@ get_source_line(struct hist_entry *he, int len, const char *filename)
212 continue; 212 continue;
213 213
214 offset = start + i; 214 offset = start + i;
215 sprintf(cmd, "addr2line -e %s %016llx", filename, offset); 215 sprintf(cmd, "addr2line -e %s %016" PRIx64, filename, offset);
216 fp = popen(cmd, "r"); 216 fp = popen(cmd, "r");
217 if (!fp) 217 if (!fp)
218 continue; 218 continue;
@@ -270,9 +270,9 @@ static void hist_entry__print_hits(struct hist_entry *self)
270 270
271 for (offset = 0; offset < len; ++offset) 271 for (offset = 0; offset < len; ++offset)
272 if (h->ip[offset] != 0) 272 if (h->ip[offset] != 0)
273 printf("%*Lx: %Lu\n", BITS_PER_LONG / 2, 273 printf("%*" PRIx64 ": %" PRIu64 "\n", BITS_PER_LONG / 2,
274 sym->start + offset, h->ip[offset]); 274 sym->start + offset, h->ip[offset]);
275 printf("%*s: %Lu\n", BITS_PER_LONG / 2, "h->sum", h->sum); 275 printf("%*s: %" PRIu64 "\n", BITS_PER_LONG / 2, "h->sum", h->sum);
276} 276}
277 277
278static int hist_entry__tty_annotate(struct hist_entry *he) 278static int hist_entry__tty_annotate(struct hist_entry *he)
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index def7ddc2fd4f..d97256d65980 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -371,10 +371,10 @@ static void __print_result(struct rb_root *root, struct perf_session *session,
371 addr = data->ptr; 371 addr = data->ptr;
372 372
373 if (sym != NULL) 373 if (sym != NULL)
374 snprintf(buf, sizeof(buf), "%s+%Lx", sym->name, 374 snprintf(buf, sizeof(buf), "%s+%" PRIx64 "", sym->name,
375 addr - map->unmap_ip(map, sym->start)); 375 addr - map->unmap_ip(map, sym->start));
376 else 376 else
377 snprintf(buf, sizeof(buf), "%#Lx", addr); 377 snprintf(buf, sizeof(buf), "%#" PRIx64 "", addr);
378 printf(" %-34s |", buf); 378 printf(" %-34s |", buf);
379 379
380 printf(" %9llu/%-5lu | %9llu/%-5lu | %8lu | %8lu | %6.3f%%\n", 380 printf(" %9llu/%-5lu | %9llu/%-5lu | %8lu | %8lu | %6.3f%%\n",
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index b9c6e5432971..2b36defc5d73 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -782,9 +782,9 @@ static void print_result(void)
782 pr_info("%10u ", st->nr_acquired); 782 pr_info("%10u ", st->nr_acquired);
783 pr_info("%10u ", st->nr_contended); 783 pr_info("%10u ", st->nr_contended);
784 784
785 pr_info("%15llu ", st->wait_time_total); 785 pr_info("%15" PRIu64 " ", st->wait_time_total);
786 pr_info("%15llu ", st->wait_time_max); 786 pr_info("%15" PRIu64 " ", st->wait_time_max);
787 pr_info("%15llu ", st->wait_time_min == ULLONG_MAX ? 787 pr_info("%15" PRIu64 " ", st->wait_time_min == ULLONG_MAX ?
788 0 : st->wait_time_min); 788 0 : st->wait_time_min);
789 pr_info("\n"); 789 pr_info("\n");
790 } 790 }
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index fcd29e8af29f..b2f729fdb317 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -817,7 +817,7 @@ static int __cmd_record(int argc, const char **argv)
817 * Approximate RIP event size: 24 bytes. 817 * Approximate RIP event size: 24 bytes.
818 */ 818 */
819 fprintf(stderr, 819 fprintf(stderr,
820 "[ perf record: Captured and wrote %.3f MB %s (~%lld samples) ]\n", 820 "[ perf record: Captured and wrote %.3f MB %s (~%" PRIu64 " samples) ]\n",
821 (double)bytes_written / 1024.0 / 1024.0, 821 (double)bytes_written / 1024.0 / 1024.0,
822 output_name, 822 output_name,
823 bytes_written / 24); 823 bytes_written / 24);
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 75183a4518e6..c27e31f289e6 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -197,7 +197,7 @@ static int process_read_event(event_t *event, struct sample_data *sample __used,
197 event->read.value); 197 event->read.value);
198 } 198 }
199 199
200 dump_printf(": %d %d %s %Lu\n", event->read.pid, event->read.tid, 200 dump_printf(": %d %d %s %" PRIu64 "\n", event->read.pid, event->read.tid,
201 attr ? __event_name(attr->type, attr->config) : "FAIL", 201 attr ? __event_name(attr->type, attr->config) : "FAIL",
202 event->read.value); 202 event->read.value);
203 203
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 29e7ffd85690..29acb894e035 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -193,7 +193,7 @@ static void calibrate_run_measurement_overhead(void)
193 } 193 }
194 run_measurement_overhead = min_delta; 194 run_measurement_overhead = min_delta;
195 195
196 printf("run measurement overhead: %Ld nsecs\n", min_delta); 196 printf("run measurement overhead: %" PRIu64 " nsecs\n", min_delta);
197} 197}
198 198
199static void calibrate_sleep_measurement_overhead(void) 199static void calibrate_sleep_measurement_overhead(void)
@@ -211,7 +211,7 @@ static void calibrate_sleep_measurement_overhead(void)
211 min_delta -= 10000; 211 min_delta -= 10000;
212 sleep_measurement_overhead = min_delta; 212 sleep_measurement_overhead = min_delta;
213 213
214 printf("sleep measurement overhead: %Ld nsecs\n", min_delta); 214 printf("sleep measurement overhead: %" PRIu64 " nsecs\n", min_delta);
215} 215}
216 216
217static struct sched_atom * 217static struct sched_atom *
@@ -617,13 +617,13 @@ static void test_calibrations(void)
617 burn_nsecs(1e6); 617 burn_nsecs(1e6);
618 T1 = get_nsecs(); 618 T1 = get_nsecs();
619 619
620 printf("the run test took %Ld nsecs\n", T1-T0); 620 printf("the run test took %" PRIu64 " nsecs\n", T1 - T0);
621 621
622 T0 = get_nsecs(); 622 T0 = get_nsecs();
623 sleep_nsecs(1e6); 623 sleep_nsecs(1e6);
624 T1 = get_nsecs(); 624 T1 = get_nsecs();
625 625
626 printf("the sleep test took %Ld nsecs\n", T1-T0); 626 printf("the sleep test took %" PRIu64 " nsecs\n", T1 - T0);
627} 627}
628 628
629#define FILL_FIELD(ptr, field, event, data) \ 629#define FILL_FIELD(ptr, field, event, data) \
@@ -816,10 +816,10 @@ replay_switch_event(struct trace_switch_event *switch_event,
816 delta = 0; 816 delta = 0;
817 817
818 if (delta < 0) 818 if (delta < 0)
819 die("hm, delta: %Ld < 0 ?\n", delta); 819 die("hm, delta: %" PRIu64 " < 0 ?\n", delta);
820 820
821 if (verbose) { 821 if (verbose) {
822 printf(" ... switch from %s/%d to %s/%d [ran %Ld nsecs]\n", 822 printf(" ... switch from %s/%d to %s/%d [ran %" PRIu64 " nsecs]\n",
823 switch_event->prev_comm, switch_event->prev_pid, 823 switch_event->prev_comm, switch_event->prev_pid,
824 switch_event->next_comm, switch_event->next_pid, 824 switch_event->next_comm, switch_event->next_pid,
825 delta); 825 delta);
@@ -1048,7 +1048,7 @@ latency_switch_event(struct trace_switch_event *switch_event,
1048 delta = 0; 1048 delta = 0;
1049 1049
1050 if (delta < 0) 1050 if (delta < 0)
1051 die("hm, delta: %Ld < 0 ?\n", delta); 1051 die("hm, delta: %" PRIu64 " < 0 ?\n", delta);
1052 1052
1053 1053
1054 sched_out = perf_session__findnew(session, switch_event->prev_pid); 1054 sched_out = perf_session__findnew(session, switch_event->prev_pid);
@@ -1221,7 +1221,7 @@ static void output_lat_thread(struct work_atoms *work_list)
1221 1221
1222 avg = work_list->total_lat / work_list->nb_atoms; 1222 avg = work_list->total_lat / work_list->nb_atoms;
1223 1223
1224 printf("|%11.3f ms |%9llu | avg:%9.3f ms | max:%9.3f ms | max at: %9.6f s\n", 1224 printf("|%11.3f ms |%9" PRIu64 " | avg:%9.3f ms | max:%9.3f ms | max at: %9.6f s\n",
1225 (double)work_list->total_runtime / 1e6, 1225 (double)work_list->total_runtime / 1e6,
1226 work_list->nb_atoms, (double)avg / 1e6, 1226 work_list->nb_atoms, (double)avg / 1e6,
1227 (double)work_list->max_lat / 1e6, 1227 (double)work_list->max_lat / 1e6,
@@ -1423,7 +1423,7 @@ map_switch_event(struct trace_switch_event *switch_event,
1423 delta = 0; 1423 delta = 0;
1424 1424
1425 if (delta < 0) 1425 if (delta < 0)
1426 die("hm, delta: %Ld < 0 ?\n", delta); 1426 die("hm, delta: %" PRIu64 " < 0 ?\n", delta);
1427 1427
1428 1428
1429 sched_out = perf_session__findnew(session, switch_event->prev_pid); 1429 sched_out = perf_session__findnew(session, switch_event->prev_pid);
@@ -1713,7 +1713,7 @@ static void __cmd_lat(void)
1713 } 1713 }
1714 1714
1715 printf(" -----------------------------------------------------------------------------------------\n"); 1715 printf(" -----------------------------------------------------------------------------------------\n");
1716 printf(" TOTAL: |%11.3f ms |%9Ld |\n", 1716 printf(" TOTAL: |%11.3f ms |%9" PRIu64 " |\n",
1717 (double)all_runtime/1e6, all_count); 1717 (double)all_runtime/1e6, all_count);
1718 1718
1719 printf(" ---------------------------------------------------\n"); 1719 printf(" ---------------------------------------------------\n");
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 150a606002eb..b766c2a9ac97 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -77,8 +77,8 @@ static int process_sample_event(event_t *event, struct sample_data *sample,
77 if (session->sample_type & PERF_SAMPLE_RAW) { 77 if (session->sample_type & PERF_SAMPLE_RAW) {
78 if (debug_mode) { 78 if (debug_mode) {
79 if (sample->time < last_timestamp) { 79 if (sample->time < last_timestamp) {
80 pr_err("Samples misordered, previous: %llu " 80 pr_err("Samples misordered, previous: %" PRIu64
81 "this: %llu\n", last_timestamp, 81 " this: %" PRIu64 "\n", last_timestamp,
82 sample->time); 82 sample->time);
83 nr_unordered++; 83 nr_unordered++;
84 } 84 }
@@ -126,7 +126,7 @@ static int __cmd_script(struct perf_session *session)
126 ret = perf_session__process_events(session, &event_ops); 126 ret = perf_session__process_events(session, &event_ops);
127 127
128 if (debug_mode) 128 if (debug_mode)
129 pr_err("Misordered timestamps: %llu\n", nr_unordered); 129 pr_err("Misordered timestamps: %" PRIu64 "\n", nr_unordered);
130 130
131 return ret; 131 return ret;
132} 132}
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 0ff11d9b13be..a482a191a0ca 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -206,8 +206,8 @@ static int read_counter_aggr(struct perf_evsel *counter)
206 update_stats(&ps->res_stats[i], count[i]); 206 update_stats(&ps->res_stats[i], count[i]);
207 207
208 if (verbose) { 208 if (verbose) {
209 fprintf(stderr, "%s: %Ld %Ld %Ld\n", event_name(counter), 209 fprintf(stderr, "%s: %" PRIu64 " %" PRIu64 " %" PRIu64 "\n",
210 count[0], count[1], count[2]); 210 event_name(counter), count[0], count[1], count[2]);
211 } 211 }
212 212
213 /* 213 /*
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c
index ed5696198d3d..5dcdba653d70 100644
--- a/tools/perf/builtin-test.c
+++ b/tools/perf/builtin-test.c
@@ -146,7 +146,7 @@ next_pair:
146 if (llabs(skew) < page_size) 146 if (llabs(skew) < page_size)
147 continue; 147 continue;
148 148
149 pr_debug("%#Lx: diff end addr for %s v: %#Lx k: %#Lx\n", 149 pr_debug("%#" PRIx64 ": diff end addr for %s v: %#" PRIx64 " k: %#" PRIx64 "\n",
150 sym->start, sym->name, sym->end, pair->end); 150 sym->start, sym->name, sym->end, pair->end);
151 } else { 151 } else {
152 struct rb_node *nnd; 152 struct rb_node *nnd;
@@ -168,11 +168,11 @@ detour:
168 goto detour; 168 goto detour;
169 } 169 }
170 170
171 pr_debug("%#Lx: diff name v: %s k: %s\n", 171 pr_debug("%#" PRIx64 ": diff name v: %s k: %s\n",
172 sym->start, sym->name, pair->name); 172 sym->start, sym->name, pair->name);
173 } 173 }
174 } else 174 } else
175 pr_debug("%#Lx: %s not on kallsyms\n", sym->start, sym->name); 175 pr_debug("%#" PRIx64 ": %s not on kallsyms\n", sym->start, sym->name);
176 176
177 err = -1; 177 err = -1;
178 } 178 }
@@ -211,10 +211,10 @@ detour:
211 211
212 if (pair->start == pos->start) { 212 if (pair->start == pos->start) {
213 pair->priv = 1; 213 pair->priv = 1;
214 pr_info(" %Lx-%Lx %Lx %s in kallsyms as", 214 pr_info(" %" PRIx64 "-%" PRIx64 " %" PRIx64 " %s in kallsyms as",
215 pos->start, pos->end, pos->pgoff, pos->dso->name); 215 pos->start, pos->end, pos->pgoff, pos->dso->name);
216 if (pos->pgoff != pair->pgoff || pos->end != pair->end) 216 if (pos->pgoff != pair->pgoff || pos->end != pair->end)
217 pr_info(": \n*%Lx-%Lx %Lx", 217 pr_info(": \n*%" PRIx64 "-%" PRIx64 " %" PRIx64 "",
218 pair->start, pair->end, pair->pgoff); 218 pair->start, pair->end, pair->pgoff);
219 pr_info(" %s\n", pair->dso->name); 219 pr_info(" %s\n", pair->dso->name);
220 pair->priv = 1; 220 pair->priv = 1;
@@ -307,7 +307,7 @@ static int test__open_syscall_event(void)
307 } 307 }
308 308
309 if (evsel->counts->cpu[0].val != nr_open_calls) { 309 if (evsel->counts->cpu[0].val != nr_open_calls) {
310 pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls, got %Ld\n", 310 pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls, got %" PRIu64 "\n",
311 nr_open_calls, evsel->counts->cpu[0].val); 311 nr_open_calls, evsel->counts->cpu[0].val);
312 goto out_close_fd; 312 goto out_close_fd;
313 } 313 }
@@ -332,8 +332,7 @@ static int test__open_syscall_event_on_all_cpus(void)
332 struct perf_evsel *evsel; 332 struct perf_evsel *evsel;
333 struct perf_event_attr attr; 333 struct perf_event_attr attr;
334 unsigned int nr_open_calls = 111, i; 334 unsigned int nr_open_calls = 111, i;
335 cpu_set_t *cpu_set; 335 cpu_set_t cpu_set;
336 size_t cpu_set_size;
337 int id = trace_event__id("sys_enter_open"); 336 int id = trace_event__id("sys_enter_open");
338 337
339 if (id < 0) { 338 if (id < 0) {
@@ -353,13 +352,8 @@ static int test__open_syscall_event_on_all_cpus(void)
353 return -1; 352 return -1;
354 } 353 }
355 354
356 cpu_set = CPU_ALLOC(cpus->nr);
357 355
358 if (cpu_set == NULL) 356 CPU_ZERO(&cpu_set);
359 goto out_thread_map_delete;
360
361 cpu_set_size = CPU_ALLOC_SIZE(cpus->nr);
362 CPU_ZERO_S(cpu_set_size, cpu_set);
363 357
364 memset(&attr, 0, sizeof(attr)); 358 memset(&attr, 0, sizeof(attr));
365 attr.type = PERF_TYPE_TRACEPOINT; 359 attr.type = PERF_TYPE_TRACEPOINT;
@@ -367,7 +361,7 @@ static int test__open_syscall_event_on_all_cpus(void)
367 evsel = perf_evsel__new(&attr, 0); 361 evsel = perf_evsel__new(&attr, 0);
368 if (evsel == NULL) { 362 if (evsel == NULL) {
369 pr_debug("perf_evsel__new\n"); 363 pr_debug("perf_evsel__new\n");
370 goto out_cpu_free; 364 goto out_thread_map_delete;
371 } 365 }
372 366
373 if (perf_evsel__open(evsel, cpus, threads) < 0) { 367 if (perf_evsel__open(evsel, cpus, threads) < 0) {
@@ -379,14 +373,29 @@ static int test__open_syscall_event_on_all_cpus(void)
379 373
380 for (cpu = 0; cpu < cpus->nr; ++cpu) { 374 for (cpu = 0; cpu < cpus->nr; ++cpu) {
381 unsigned int ncalls = nr_open_calls + cpu; 375 unsigned int ncalls = nr_open_calls + cpu;
376 /*
377 * XXX eventually lift this restriction in a way that
378 * keeps perf building on older glibc installations
379 * without CPU_ALLOC. 1024 cpus in 2010 still seems
380 * a reasonable upper limit tho :-)
381 */
382 if (cpus->map[cpu] >= CPU_SETSIZE) {
383 pr_debug("Ignoring CPU %d\n", cpus->map[cpu]);
384 continue;
385 }
382 386
383 CPU_SET(cpu, cpu_set); 387 CPU_SET(cpus->map[cpu], &cpu_set);
384 sched_setaffinity(0, cpu_set_size, cpu_set); 388 if (sched_setaffinity(0, sizeof(cpu_set), &cpu_set) < 0) {
389 pr_debug("sched_setaffinity() failed on CPU %d: %s ",
390 cpus->map[cpu],
391 strerror(errno));
392 goto out_close_fd;
393 }
385 for (i = 0; i < ncalls; ++i) { 394 for (i = 0; i < ncalls; ++i) {
386 fd = open("/etc/passwd", O_RDONLY); 395 fd = open("/etc/passwd", O_RDONLY);
387 close(fd); 396 close(fd);
388 } 397 }
389 CPU_CLR(cpu, cpu_set); 398 CPU_CLR(cpus->map[cpu], &cpu_set);
390 } 399 }
391 400
392 /* 401 /*
@@ -402,6 +411,9 @@ static int test__open_syscall_event_on_all_cpus(void)
402 for (cpu = 0; cpu < cpus->nr; ++cpu) { 411 for (cpu = 0; cpu < cpus->nr; ++cpu) {
403 unsigned int expected; 412 unsigned int expected;
404 413
414 if (cpus->map[cpu] >= CPU_SETSIZE)
415 continue;
416
405 if (perf_evsel__read_on_cpu(evsel, cpu, 0) < 0) { 417 if (perf_evsel__read_on_cpu(evsel, cpu, 0) < 0) {
406 pr_debug("perf_evsel__open_read_on_cpu\n"); 418 pr_debug("perf_evsel__open_read_on_cpu\n");
407 goto out_close_fd; 419 goto out_close_fd;
@@ -409,8 +421,8 @@ static int test__open_syscall_event_on_all_cpus(void)
409 421
410 expected = nr_open_calls + cpu; 422 expected = nr_open_calls + cpu;
411 if (evsel->counts->cpu[cpu].val != expected) { 423 if (evsel->counts->cpu[cpu].val != expected) {
412 pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls on cpu %d, got %Ld\n", 424 pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls on cpu %d, got %" PRIu64 "\n",
413 expected, cpu, evsel->counts->cpu[cpu].val); 425 expected, cpus->map[cpu], evsel->counts->cpu[cpu].val);
414 goto out_close_fd; 426 goto out_close_fd;
415 } 427 }
416 } 428 }
@@ -420,8 +432,6 @@ out_close_fd:
420 perf_evsel__close_fd(evsel, 1, threads->nr); 432 perf_evsel__close_fd(evsel, 1, threads->nr);
421out_evsel_delete: 433out_evsel_delete:
422 perf_evsel__delete(evsel); 434 perf_evsel__delete(evsel);
423out_cpu_free:
424 CPU_FREE(cpu_set);
425out_thread_map_delete: 435out_thread_map_delete:
426 thread_map__delete(threads); 436 thread_map__delete(threads);
427 return err; 437 return err;
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 05344c6210ac..b6998e055767 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -40,6 +40,7 @@
40#include <stdio.h> 40#include <stdio.h>
41#include <termios.h> 41#include <termios.h>
42#include <unistd.h> 42#include <unistd.h>
43#include <inttypes.h>
43 44
44#include <errno.h> 45#include <errno.h>
45#include <time.h> 46#include <time.h>
@@ -214,7 +215,7 @@ static int parse_source(struct sym_entry *syme)
214 len = sym->end - sym->start; 215 len = sym->end - sym->start;
215 216
216 sprintf(command, 217 sprintf(command,
217 "objdump --start-address=%#0*Lx --stop-address=%#0*Lx -dS %s", 218 "objdump --start-address=%#0*" PRIx64 " --stop-address=%#0*" PRIx64 " -dS %s",
218 BITS_PER_LONG / 4, map__rip_2objdump(map, sym->start), 219 BITS_PER_LONG / 4, map__rip_2objdump(map, sym->start),
219 BITS_PER_LONG / 4, map__rip_2objdump(map, sym->end), path); 220 BITS_PER_LONG / 4, map__rip_2objdump(map, sym->end), path);
220 221
@@ -308,7 +309,7 @@ static void lookup_sym_source(struct sym_entry *syme)
308 struct source_line *line; 309 struct source_line *line;
309 char pattern[PATTERN_LEN + 1]; 310 char pattern[PATTERN_LEN + 1];
310 311
311 sprintf(pattern, "%0*Lx <", BITS_PER_LONG / 4, 312 sprintf(pattern, "%0*" PRIx64 " <", BITS_PER_LONG / 4,
312 map__rip_2objdump(syme->map, symbol->start)); 313 map__rip_2objdump(syme->map, symbol->start));
313 314
314 pthread_mutex_lock(&syme->src->lock); 315 pthread_mutex_lock(&syme->src->lock);
@@ -537,7 +538,7 @@ static void print_sym_table(void)
537 if (nr_counters == 1 || !display_weighted) { 538 if (nr_counters == 1 || !display_weighted) {
538 struct perf_evsel *first; 539 struct perf_evsel *first;
539 first = list_entry(evsel_list.next, struct perf_evsel, node); 540 first = list_entry(evsel_list.next, struct perf_evsel, node);
540 printf("%Ld", first->attr.sample_period); 541 printf("%" PRIu64, (uint64_t)first->attr.sample_period);
541 if (freq) 542 if (freq)
542 printf("Hz "); 543 printf("Hz ");
543 else 544 else
@@ -640,7 +641,7 @@ static void print_sym_table(void)
640 641
641 percent_color_fprintf(stdout, "%4.1f%%", pcnt); 642 percent_color_fprintf(stdout, "%4.1f%%", pcnt);
642 if (verbose) 643 if (verbose)
643 printf(" %016llx", sym->start); 644 printf(" %016" PRIx64, sym->start);
644 printf(" %-*.*s", sym_width, sym_width, sym->name); 645 printf(" %-*.*s", sym_width, sym_width, sym->name);
645 printf(" %-*.*s\n", dso_width, dso_width, 646 printf(" %-*.*s\n", dso_width, dso_width,
646 dso_width >= syme->map->dso->long_name_len ? 647 dso_width >= syme->map->dso->long_name_len ?
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 2302ec051bb4..1478ab4ee222 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -459,7 +459,8 @@ int event__process_comm(event_t *self, struct sample_data *sample __used,
459int event__process_lost(event_t *self, struct sample_data *sample __used, 459int event__process_lost(event_t *self, struct sample_data *sample __used,
460 struct perf_session *session) 460 struct perf_session *session)
461{ 461{
462 dump_printf(": id:%Ld: lost:%Ld\n", self->lost.id, self->lost.lost); 462 dump_printf(": id:%" PRIu64 ": lost:%" PRIu64 "\n",
463 self->lost.id, self->lost.lost);
463 session->hists.stats.total_lost += self->lost.lost; 464 session->hists.stats.total_lost += self->lost.lost;
464 return 0; 465 return 0;
465} 466}
@@ -575,7 +576,7 @@ int event__process_mmap(event_t *self, struct sample_data *sample __used,
575 u8 cpumode = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; 576 u8 cpumode = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
576 int ret = 0; 577 int ret = 0;
577 578
578 dump_printf(" %d/%d: [%#Lx(%#Lx) @ %#Lx]: %s\n", 579 dump_printf(" %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64 "]: %s\n",
579 self->mmap.pid, self->mmap.tid, self->mmap.start, 580 self->mmap.pid, self->mmap.tid, self->mmap.start,
580 self->mmap.len, self->mmap.pgoff, self->mmap.filename); 581 self->mmap.len, self->mmap.pgoff, self->mmap.filename);
581 582
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 989fa2dee2fd..f6a929e74981 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -798,8 +798,8 @@ static int perf_file_section__process(struct perf_file_section *self,
798 int feat, int fd) 798 int feat, int fd)
799{ 799{
800 if (lseek(fd, self->offset, SEEK_SET) == (off_t)-1) { 800 if (lseek(fd, self->offset, SEEK_SET) == (off_t)-1) {
801 pr_debug("Failed to lseek to %Ld offset for feature %d, " 801 pr_debug("Failed to lseek to %" PRIu64 " offset for feature "
802 "continuing...\n", self->offset, feat); 802 "%d, continuing...\n", self->offset, feat);
803 return 0; 803 return 0;
804 } 804 }
805 805
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index c749ba6136a0..32f4f1f2f6e4 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -636,13 +636,13 @@ int hist_entry__snprintf(struct hist_entry *self, char *s, size_t size,
636 } 636 }
637 } 637 }
638 } else 638 } else
639 ret = snprintf(s, size, sep ? "%lld" : "%12lld ", period); 639 ret = snprintf(s, size, sep ? "%" PRIu64 : "%12" PRIu64 " ", period);
640 640
641 if (symbol_conf.show_nr_samples) { 641 if (symbol_conf.show_nr_samples) {
642 if (sep) 642 if (sep)
643 ret += snprintf(s + ret, size - ret, "%c%lld", *sep, period); 643 ret += snprintf(s + ret, size - ret, "%c%" PRIu64, *sep, period);
644 else 644 else
645 ret += snprintf(s + ret, size - ret, "%11lld", period); 645 ret += snprintf(s + ret, size - ret, "%11" PRIu64, period);
646 } 646 }
647 647
648 if (pair_hists) { 648 if (pair_hists) {
@@ -971,7 +971,7 @@ int hist_entry__inc_addr_samples(struct hist_entry *self, u64 ip)
971 sym_size = sym->end - sym->start; 971 sym_size = sym->end - sym->start;
972 offset = ip - sym->start; 972 offset = ip - sym->start;
973 973
974 pr_debug3("%s: ip=%#Lx\n", __func__, self->ms.map->unmap_ip(self->ms.map, ip)); 974 pr_debug3("%s: ip=%#" PRIx64 "\n", __func__, self->ms.map->unmap_ip(self->ms.map, ip));
975 975
976 if (offset >= sym_size) 976 if (offset >= sym_size)
977 return 0; 977 return 0;
@@ -980,8 +980,9 @@ int hist_entry__inc_addr_samples(struct hist_entry *self, u64 ip)
980 h->sum++; 980 h->sum++;
981 h->ip[offset]++; 981 h->ip[offset]++;
982 982
983 pr_debug3("%#Lx %s: period++ [ip: %#Lx, %#Lx] => %Ld\n", self->ms.sym->start, 983 pr_debug3("%#" PRIx64 " %s: period++ [ip: %#" PRIx64 ", %#" PRIx64
984 self->ms.sym->name, ip, ip - self->ms.sym->start, h->ip[offset]); 984 "] => %" PRIu64 "\n", self->ms.sym->start, self->ms.sym->name,
985 ip, ip - self->ms.sym->start, h->ip[offset]);
985 return 0; 986 return 0;
986} 987}
987 988
@@ -1132,7 +1133,7 @@ fallback:
1132 goto out_free_filename; 1133 goto out_free_filename;
1133 } 1134 }
1134 1135
1135 pr_debug("%s: filename=%s, sym=%s, start=%#Lx, end=%#Lx\n", __func__, 1136 pr_debug("%s: filename=%s, sym=%s, start=%#" PRIx64 ", end=%#" PRIx64 "\n", __func__,
1136 filename, sym->name, map->unmap_ip(map, sym->start), 1137 filename, sym->name, map->unmap_ip(map, sym->start),
1137 map->unmap_ip(map, sym->end)); 1138 map->unmap_ip(map, sym->end));
1138 1139
@@ -1142,7 +1143,7 @@ fallback:
1142 dso, dso->long_name, sym, sym->name); 1143 dso, dso->long_name, sym, sym->name);
1143 1144
1144 snprintf(command, sizeof(command), 1145 snprintf(command, sizeof(command),
1145 "objdump --start-address=0x%016Lx --stop-address=0x%016Lx -dS -C %s|grep -v %s|expand", 1146 "objdump --start-address=0x%016" PRIx64 " --stop-address=0x%016" PRIx64 " -dS -C %s|grep -v %s|expand",
1146 map__rip_2objdump(map, sym->start), 1147 map__rip_2objdump(map, sym->start),
1147 map__rip_2objdump(map, sym->end), 1148 map__rip_2objdump(map, sym->end),
1148 symfs_filename, filename); 1149 symfs_filename, filename);
diff --git a/tools/perf/util/include/linux/bitops.h b/tools/perf/util/include/linux/bitops.h
index 8be0b968ca0b..305c8484f200 100644
--- a/tools/perf/util/include/linux/bitops.h
+++ b/tools/perf/util/include/linux/bitops.h
@@ -2,6 +2,7 @@
2#define _PERF_LINUX_BITOPS_H_ 2#define _PERF_LINUX_BITOPS_H_
3 3
4#include <linux/kernel.h> 4#include <linux/kernel.h>
5#include <linux/compiler.h>
5#include <asm/hweight.h> 6#include <asm/hweight.h>
6 7
7#define BITS_PER_LONG __WORDSIZE 8#define BITS_PER_LONG __WORDSIZE
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 3a7eb6ec0eec..a16ecab5229d 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -1,5 +1,6 @@
1#include "symbol.h" 1#include "symbol.h"
2#include <errno.h> 2#include <errno.h>
3#include <inttypes.h>
3#include <limits.h> 4#include <limits.h>
4#include <stdlib.h> 5#include <stdlib.h>
5#include <string.h> 6#include <string.h>
@@ -195,7 +196,7 @@ int map__overlap(struct map *l, struct map *r)
195 196
196size_t map__fprintf(struct map *self, FILE *fp) 197size_t map__fprintf(struct map *self, FILE *fp)
197{ 198{
198 return fprintf(fp, " %Lx-%Lx %Lx %s\n", 199 return fprintf(fp, " %" PRIx64 "-%" PRIx64 " %" PRIx64 " %s\n",
199 self->start, self->end, self->pgoff, self->dso->name); 200 self->start, self->end, self->pgoff, self->dso->name);
200} 201}
201 202
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index bc2732ee23eb..135f69baf966 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -279,7 +279,7 @@ const char *__event_name(int type, u64 config)
279 static char buf[32]; 279 static char buf[32];
280 280
281 if (type == PERF_TYPE_RAW) { 281 if (type == PERF_TYPE_RAW) {
282 sprintf(buf, "raw 0x%llx", config); 282 sprintf(buf, "raw 0x%" PRIx64, config);
283 return buf; 283 return buf;
284 } 284 }
285 285
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index b82cafb83772..458e3ecf17af 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -23,7 +23,7 @@ struct tracepoint_path {
23}; 23};
24 24
25extern struct tracepoint_path *tracepoint_id_to_path(u64 config); 25extern struct tracepoint_path *tracepoint_id_to_path(u64 config);
26extern bool have_tracepoints(struct list_head *evsel_list); 26extern bool have_tracepoints(struct list_head *evlist);
27 27
28extern int nr_counters; 28extern int nr_counters;
29 29
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 128aaab0aeda..6e29d9c9dccc 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -172,7 +172,7 @@ static int kprobe_convert_to_perf_probe(struct probe_trace_point *tp,
172 sym = __find_kernel_function_by_name(tp->symbol, &map); 172 sym = __find_kernel_function_by_name(tp->symbol, &map);
173 if (sym) { 173 if (sym) {
174 addr = map->unmap_ip(map, sym->start + tp->offset); 174 addr = map->unmap_ip(map, sym->start + tp->offset);
175 pr_debug("try to find %s+%ld@%llx\n", tp->symbol, 175 pr_debug("try to find %s+%ld@%" PRIx64 "\n", tp->symbol,
176 tp->offset, addr); 176 tp->offset, addr);
177 ret = find_perf_probe_point((unsigned long)addr, pp); 177 ret = find_perf_probe_point((unsigned long)addr, pp);
178 } 178 }
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 313dac2d94ce..105f00bfd555 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -652,10 +652,11 @@ static void callchain__printf(struct sample_data *sample)
652{ 652{
653 unsigned int i; 653 unsigned int i;
654 654
655 printf("... chain: nr:%Lu\n", sample->callchain->nr); 655 printf("... chain: nr:%" PRIu64 "\n", sample->callchain->nr);
656 656
657 for (i = 0; i < sample->callchain->nr; i++) 657 for (i = 0; i < sample->callchain->nr; i++)
658 printf("..... %2d: %016Lx\n", i, sample->callchain->ips[i]); 658 printf("..... %2d: %016" PRIx64 "\n",
659 i, sample->callchain->ips[i]);
659} 660}
660 661
661static void perf_session__print_tstamp(struct perf_session *session, 662static void perf_session__print_tstamp(struct perf_session *session,
@@ -672,7 +673,7 @@ static void perf_session__print_tstamp(struct perf_session *session,
672 printf("%u ", sample->cpu); 673 printf("%u ", sample->cpu);
673 674
674 if (session->sample_type & PERF_SAMPLE_TIME) 675 if (session->sample_type & PERF_SAMPLE_TIME)
675 printf("%Lu ", sample->time); 676 printf("%" PRIu64 " ", sample->time);
676} 677}
677 678
678static void dump_event(struct perf_session *session, event_t *event, 679static void dump_event(struct perf_session *session, event_t *event,
@@ -681,16 +682,16 @@ static void dump_event(struct perf_session *session, event_t *event,
681 if (!dump_trace) 682 if (!dump_trace)
682 return; 683 return;
683 684
684 printf("\n%#Lx [%#x]: event: %d\n", file_offset, event->header.size, 685 printf("\n%#" PRIx64 " [%#x]: event: %d\n",
685 event->header.type); 686 file_offset, event->header.size, event->header.type);
686 687
687 trace_event(event); 688 trace_event(event);
688 689
689 if (sample) 690 if (sample)
690 perf_session__print_tstamp(session, event, sample); 691 perf_session__print_tstamp(session, event, sample);
691 692
692 printf("%#Lx [%#x]: PERF_RECORD_%s", file_offset, event->header.size, 693 printf("%#" PRIx64 " [%#x]: PERF_RECORD_%s", file_offset,
693 event__get_event_name(event->header.type)); 694 event->header.size, event__get_event_name(event->header.type));
694} 695}
695 696
696static void dump_sample(struct perf_session *session, event_t *event, 697static void dump_sample(struct perf_session *session, event_t *event,
@@ -699,8 +700,9 @@ static void dump_sample(struct perf_session *session, event_t *event,
699 if (!dump_trace) 700 if (!dump_trace)
700 return; 701 return;
701 702
702 printf("(IP, %d): %d/%d: %#Lx period: %Ld\n", event->header.misc, 703 printf("(IP, %d): %d/%d: %#" PRIx64 " period: %" PRIu64 "\n",
703 sample->pid, sample->tid, sample->ip, sample->period); 704 event->header.misc, sample->pid, sample->tid, sample->ip,
705 sample->period);
704 706
705 if (session->sample_type & PERF_SAMPLE_CALLCHAIN) 707 if (session->sample_type & PERF_SAMPLE_CALLCHAIN)
706 callchain__printf(sample); 708 callchain__printf(sample);
@@ -843,8 +845,8 @@ static void perf_session__warn_about_errors(const struct perf_session *session,
843{ 845{
844 if (ops->lost == event__process_lost && 846 if (ops->lost == event__process_lost &&
845 session->hists.stats.total_lost != 0) { 847 session->hists.stats.total_lost != 0) {
846 ui__warning("Processed %Lu events and LOST %Lu!\n\n" 848 ui__warning("Processed %" PRIu64 " events and LOST %" PRIu64
847 "Check IO/CPU overload!\n\n", 849 "!\n\nCheck IO/CPU overload!\n\n",
848 session->hists.stats.total_period, 850 session->hists.stats.total_period,
849 session->hists.stats.total_lost); 851 session->hists.stats.total_lost);
850 } 852 }
@@ -918,7 +920,7 @@ more:
918 920
919 if (size == 0 || 921 if (size == 0 ||
920 (skip = perf_session__process_event(self, &event, ops, head)) < 0) { 922 (skip = perf_session__process_event(self, &event, ops, head)) < 0) {
921 dump_printf("%#Lx [%#x]: skipping unknown header type: %d\n", 923 dump_printf("%#" PRIx64 " [%#x]: skipping unknown header type: %d\n",
922 head, event.header.size, event.header.type); 924 head, event.header.size, event.header.type);
923 /* 925 /*
924 * assume we lost track of the stream, check alignment, and 926 * assume we lost track of the stream, check alignment, and
@@ -1023,7 +1025,7 @@ more:
1023 1025
1024 if (size == 0 || 1026 if (size == 0 ||
1025 perf_session__process_event(session, event, ops, file_pos) < 0) { 1027 perf_session__process_event(session, event, ops, file_pos) < 0) {
1026 dump_printf("%#Lx [%#x]: skipping unknown header type: %d\n", 1028 dump_printf("%#" PRIx64 " [%#x]: skipping unknown header type: %d\n",
1027 file_offset + head, event->header.size, 1029 file_offset + head, event->header.size,
1028 event->header.type); 1030 event->header.type);
1029 /* 1031 /*
diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c
index b3637db025a2..fb737fe9be91 100644
--- a/tools/perf/util/svghelper.c
+++ b/tools/perf/util/svghelper.c
@@ -12,6 +12,7 @@
12 * of the License. 12 * of the License.
13 */ 13 */
14 14
15#include <inttypes.h>
15#include <stdio.h> 16#include <stdio.h>
16#include <stdlib.h> 17#include <stdlib.h>
17#include <unistd.h> 18#include <unistd.h>
@@ -43,11 +44,11 @@ static double cpu2y(int cpu)
43 return cpu2slot(cpu) * SLOT_MULT; 44 return cpu2slot(cpu) * SLOT_MULT;
44} 45}
45 46
46static double time2pixels(u64 time) 47static double time2pixels(u64 __time)
47{ 48{
48 double X; 49 double X;
49 50
50 X = 1.0 * svg_page_width * (time - first_time) / (last_time - first_time); 51 X = 1.0 * svg_page_width * (__time - first_time) / (last_time - first_time);
51 return X; 52 return X;
52} 53}
53 54
@@ -94,7 +95,7 @@ void open_svg(const char *filename, int cpus, int rows, u64 start, u64 end)
94 95
95 total_height = (1 + rows + cpu2slot(cpus)) * SLOT_MULT; 96 total_height = (1 + rows + cpu2slot(cpus)) * SLOT_MULT;
96 fprintf(svgfile, "<?xml version=\"1.0\" standalone=\"no\"?> \n"); 97 fprintf(svgfile, "<?xml version=\"1.0\" standalone=\"no\"?> \n");
97 fprintf(svgfile, "<svg width=\"%i\" height=\"%llu\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n", svg_page_width, total_height); 98 fprintf(svgfile, "<svg width=\"%i\" height=\"%" PRIu64 "\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n", svg_page_width, total_height);
98 99
99 fprintf(svgfile, "<defs>\n <style type=\"text/css\">\n <![CDATA[\n"); 100 fprintf(svgfile, "<defs>\n <style type=\"text/css\">\n <![CDATA[\n");
100 101
@@ -483,7 +484,7 @@ void svg_time_grid(void)
483 color = 128; 484 color = 128;
484 } 485 }
485 486
486 fprintf(svgfile, "<line x1=\"%4.8f\" y1=\"%4.2f\" x2=\"%4.8f\" y2=\"%llu\" style=\"stroke:rgb(%i,%i,%i);stroke-width:%1.3f\"/>\n", 487 fprintf(svgfile, "<line x1=\"%4.8f\" y1=\"%4.2f\" x2=\"%4.8f\" y2=\"%" PRIu64 "\" style=\"stroke:rgb(%i,%i,%i);stroke-width:%1.3f\"/>\n",
487 time2pixels(i), SLOT_MULT/2, time2pixels(i), total_height, color, color, color, thickness); 488 time2pixels(i), SLOT_MULT/2, time2pixels(i), total_height, color, color, color, thickness);
488 489
489 i += 10000000; 490 i += 10000000;
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 15ccfba8cdf8..7821d0e6866f 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -11,6 +11,7 @@
11#include <sys/param.h> 11#include <sys/param.h>
12#include <fcntl.h> 12#include <fcntl.h>
13#include <unistd.h> 13#include <unistd.h>
14#include <inttypes.h>
14#include "build-id.h" 15#include "build-id.h"
15#include "debug.h" 16#include "debug.h"
16#include "symbol.h" 17#include "symbol.h"
@@ -153,7 +154,7 @@ static struct symbol *symbol__new(u64 start, u64 len, u8 binding,
153 self->binding = binding; 154 self->binding = binding;
154 self->namelen = namelen - 1; 155 self->namelen = namelen - 1;
155 156
156 pr_debug4("%s: %s %#Lx-%#Lx\n", __func__, name, start, self->end); 157 pr_debug4("%s: %s %#" PRIx64 "-%#" PRIx64 "\n", __func__, name, start, self->end);
157 158
158 memcpy(self->name, name, namelen); 159 memcpy(self->name, name, namelen);
159 160
@@ -167,7 +168,7 @@ void symbol__delete(struct symbol *self)
167 168
168static size_t symbol__fprintf(struct symbol *self, FILE *fp) 169static size_t symbol__fprintf(struct symbol *self, FILE *fp)
169{ 170{
170 return fprintf(fp, " %llx-%llx %c %s\n", 171 return fprintf(fp, " %" PRIx64 "-%" PRIx64 " %c %s\n",
171 self->start, self->end, 172 self->start, self->end,
172 self->binding == STB_GLOBAL ? 'g' : 173 self->binding == STB_GLOBAL ? 'g' :
173 self->binding == STB_LOCAL ? 'l' : 'w', 174 self->binding == STB_LOCAL ? 'l' : 'w',
@@ -1161,6 +1162,13 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name,
1161 1162
1162 section_name = elf_sec__name(&shdr, secstrs); 1163 section_name = elf_sec__name(&shdr, secstrs);
1163 1164
1165 /* On ARM, symbols for thumb functions have 1 added to
1166 * the symbol address as a flag - remove it */
1167 if ((ehdr.e_machine == EM_ARM) &&
1168 (map->type == MAP__FUNCTION) &&
1169 (sym.st_value & 1))
1170 --sym.st_value;
1171
1164 if (self->kernel != DSO_TYPE_USER || kmodule) { 1172 if (self->kernel != DSO_TYPE_USER || kmodule) {
1165 char dso_name[PATH_MAX]; 1173 char dso_name[PATH_MAX];
1166 1174
@@ -1208,8 +1216,8 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name,
1208 } 1216 }
1209 1217
1210 if (curr_dso->adjust_symbols) { 1218 if (curr_dso->adjust_symbols) {
1211 pr_debug4("%s: adjusting symbol: st_value: %#Lx " 1219 pr_debug4("%s: adjusting symbol: st_value: %#" PRIx64 " "
1212 "sh_addr: %#Lx sh_offset: %#Lx\n", __func__, 1220 "sh_addr: %#" PRIx64 " sh_offset: %#" PRIx64 "\n", __func__,
1213 (u64)sym.st_value, (u64)shdr.sh_addr, 1221 (u64)sym.st_value, (u64)shdr.sh_addr,
1214 (u64)shdr.sh_offset); 1222 (u64)shdr.sh_offset);
1215 sym.st_value -= shdr.sh_addr - shdr.sh_offset; 1223 sym.st_value -= shdr.sh_addr - shdr.sh_offset;
diff --git a/tools/perf/util/types.h b/tools/perf/util/types.h
index 7d6b8331f898..5f3689a3d085 100644
--- a/tools/perf/util/types.h
+++ b/tools/perf/util/types.h
@@ -1,12 +1,14 @@
1#ifndef __PERF_TYPES_H 1#ifndef __PERF_TYPES_H
2#define __PERF_TYPES_H 2#define __PERF_TYPES_H
3 3
4#include <stdint.h>
5
4/* 6/*
5 * We define u64 as unsigned long long for every architecture 7 * We define u64 as uint64_t for every architecture
6 * so that we can print it with %Lx without getting warnings. 8 * so that we can print it with "%"PRIx64 without getting warnings.
7 */ 9 */
8typedef unsigned long long u64; 10typedef uint64_t u64;
9typedef signed long long s64; 11typedef int64_t s64;
10typedef unsigned int u32; 12typedef unsigned int u32;
11typedef signed int s32; 13typedef signed int s32;
12typedef unsigned short u16; 14typedef unsigned short u16;
diff --git a/tools/perf/util/ui/browsers/hists.c b/tools/perf/util/ui/browsers/hists.c
index ebda8c3fde9e..60c463c16028 100644
--- a/tools/perf/util/ui/browsers/hists.c
+++ b/tools/perf/util/ui/browsers/hists.c
@@ -350,7 +350,7 @@ static char *callchain_list__sym_name(struct callchain_list *self,
350 if (self->ms.sym) 350 if (self->ms.sym)
351 return self->ms.sym->name; 351 return self->ms.sym->name;
352 352
353 snprintf(bf, bfsize, "%#Lx", self->ip); 353 snprintf(bf, bfsize, "%#" PRIx64, self->ip);
354 return bf; 354 return bf;
355} 355}
356 356
diff --git a/tools/perf/util/ui/browsers/map.c b/tools/perf/util/ui/browsers/map.c
index e35437dfa5b4..e5158369106e 100644
--- a/tools/perf/util/ui/browsers/map.c
+++ b/tools/perf/util/ui/browsers/map.c
@@ -1,5 +1,6 @@
1#include "../libslang.h" 1#include "../libslang.h"
2#include <elf.h> 2#include <elf.h>
3#include <inttypes.h>
3#include <sys/ttydefaults.h> 4#include <sys/ttydefaults.h>
4#include <ctype.h> 5#include <ctype.h>
5#include <string.h> 6#include <string.h>
@@ -57,7 +58,7 @@ static void map_browser__write(struct ui_browser *self, void *nd, int row)
57 int width; 58 int width;
58 59
59 ui_browser__set_percent_color(self, 0, current_entry); 60 ui_browser__set_percent_color(self, 0, current_entry);
60 slsmg_printf("%*llx %*llx %c ", 61 slsmg_printf("%*" PRIx64 " %*" PRIx64 " %c ",
61 mb->addrlen, sym->start, mb->addrlen, sym->end, 62 mb->addrlen, sym->start, mb->addrlen, sym->end,
62 sym->binding == STB_GLOBAL ? 'g' : 63 sym->binding == STB_GLOBAL ? 'g' :
63 sym->binding == STB_LOCAL ? 'l' : 'w'); 64 sym->binding == STB_LOCAL ? 'l' : 'w');
@@ -150,6 +151,6 @@ int map__browse(struct map *self)
150 ++mb.b.nr_entries; 151 ++mb.b.nr_entries;
151 } 152 }
152 153
153 mb.addrlen = snprintf(tmp, sizeof(tmp), "%llx", maxaddr); 154 mb.addrlen = snprintf(tmp, sizeof(tmp), "%" PRIx64, maxaddr);
154 return map_browser__run(&mb); 155 return map_browser__run(&mb);
155} 156}
diff --git a/tools/perf/util/values.c b/tools/perf/util/values.c
index cfa55d686e3b..bdd33470b235 100644
--- a/tools/perf/util/values.c
+++ b/tools/perf/util/values.c
@@ -150,7 +150,7 @@ static void perf_read_values__display_pretty(FILE *fp,
150 if (width > tidwidth) 150 if (width > tidwidth)
151 tidwidth = width; 151 tidwidth = width;
152 for (j = 0; j < values->counters; j++) { 152 for (j = 0; j < values->counters; j++) {
153 width = snprintf(NULL, 0, "%Lu", values->value[i][j]); 153 width = snprintf(NULL, 0, "%" PRIu64, values->value[i][j]);
154 if (width > counterwidth[j]) 154 if (width > counterwidth[j])
155 counterwidth[j] = width; 155 counterwidth[j] = width;
156 } 156 }
@@ -165,7 +165,7 @@ static void perf_read_values__display_pretty(FILE *fp,
165 fprintf(fp, " %*d %*d", pidwidth, values->pid[i], 165 fprintf(fp, " %*d %*d", pidwidth, values->pid[i],
166 tidwidth, values->tid[i]); 166 tidwidth, values->tid[i]);
167 for (j = 0; j < values->counters; j++) 167 for (j = 0; j < values->counters; j++)
168 fprintf(fp, " %*Lu", 168 fprintf(fp, " %*" PRIu64,
169 counterwidth[j], values->value[i][j]); 169 counterwidth[j], values->value[i][j]);
170 fprintf(fp, "\n"); 170 fprintf(fp, "\n");
171 } 171 }
@@ -196,13 +196,13 @@ static void perf_read_values__display_raw(FILE *fp,
196 width = strlen(values->countername[j]); 196 width = strlen(values->countername[j]);
197 if (width > namewidth) 197 if (width > namewidth)
198 namewidth = width; 198 namewidth = width;
199 width = snprintf(NULL, 0, "%llx", values->counterrawid[j]); 199 width = snprintf(NULL, 0, "%" PRIx64, values->counterrawid[j]);
200 if (width > rawwidth) 200 if (width > rawwidth)
201 rawwidth = width; 201 rawwidth = width;
202 } 202 }
203 for (i = 0; i < values->threads; i++) { 203 for (i = 0; i < values->threads; i++) {
204 for (j = 0; j < values->counters; j++) { 204 for (j = 0; j < values->counters; j++) {
205 width = snprintf(NULL, 0, "%Lu", values->value[i][j]); 205 width = snprintf(NULL, 0, "%" PRIu64, values->value[i][j]);
206 if (width > countwidth) 206 if (width > countwidth)
207 countwidth = width; 207 countwidth = width;
208 } 208 }
@@ -214,7 +214,7 @@ static void perf_read_values__display_raw(FILE *fp,
214 countwidth, "Count"); 214 countwidth, "Count");
215 for (i = 0; i < values->threads; i++) 215 for (i = 0; i < values->threads; i++)
216 for (j = 0; j < values->counters; j++) 216 for (j = 0; j < values->counters; j++)
217 fprintf(fp, " %*d %*d %*s %*llx %*Lu\n", 217 fprintf(fp, " %*d %*d %*s %*" PRIx64 " %*" PRIu64,
218 pidwidth, values->pid[i], 218 pidwidth, values->pid[i],
219 tidwidth, values->tid[i], 219 tidwidth, values->tid[i],
220 namewidth, values->countername[j], 220 namewidth, values->countername[j],