aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/ABI/testing/sysfs-class-backlight-driver-adp887056
-rw-r--r--Documentation/accounting/cgroupstats.txt4
-rw-r--r--Documentation/cgroups/blkio-controller.txt31
-rw-r--r--Documentation/cgroups/cgroups.txt60
-rw-r--r--Documentation/cgroups/cpuacct.txt21
-rw-r--r--Documentation/cgroups/cpusets.txt28
-rw-r--r--Documentation/cgroups/devices.txt6
-rw-r--r--Documentation/cgroups/freezer-subsystem.txt20
-rw-r--r--Documentation/cgroups/memory.txt58
-rw-r--r--Documentation/feature-removal-schedule.txt17
-rw-r--r--Documentation/kmemleak.txt4
-rw-r--r--Documentation/md.txt2
-rw-r--r--Documentation/printk-formats.txt119
-rw-r--r--Documentation/scheduler/sched-design-CFS.txt7
-rw-r--r--Documentation/scheduler/sched-rt-group.txt7
-rw-r--r--Documentation/vm/hwpoison.txt6
-rw-r--r--MAINTAINERS23
-rw-r--r--Makefile3
-rw-r--r--arch/alpha/kernel/osf_sys.c11
-rw-r--r--arch/arm/boot/compressed/head.S6
-rw-r--r--arch/arm/configs/davinci_all_defconfig2
-rw-r--r--arch/arm/configs/netx_defconfig2
-rw-r--r--arch/arm/configs/viper_defconfig2
-rw-r--r--arch/arm/configs/xcep_defconfig2
-rw-r--r--arch/arm/configs/zeus_defconfig2
-rw-r--r--arch/arm/kernel/devtree.c3
-rw-r--r--arch/arm/kernel/entry-armv.S6
-rw-r--r--arch/arm/kernel/entry-common.S2
-rw-r--r--arch/arm/kernel/traps.c4
-rw-r--r--arch/arm/mach-davinci/devices-da8xx.c2
-rw-r--r--arch/arm/mach-davinci/devices.c2
-rw-r--r--arch/arm/mach-davinci/gpio.c7
-rw-r--r--arch/arm/mach-footbridge/dc21285-timer.c1
-rw-r--r--arch/arm/mach-footbridge/include/mach/debug-macro.S5
-rw-r--r--arch/arm/mach-mxs/ocotp.c2
-rw-r--r--arch/arm/mach-omap1/Makefile4
-rw-r--r--arch/arm/mach-omap1/pm_bus.c8
-rw-r--r--arch/arm/mach-omap2/board-omap3pandora.c3
-rw-r--r--arch/arm/mach-omap2/pm-debug.c4
-rw-r--r--arch/arm/mach-pxa/spitz_pm.c1
-rw-r--r--arch/arm/mach-shmobile/board-ag5evm.c4
-rw-r--r--arch/arm/mach-shmobile/board-mackerel.c208
-rw-r--r--arch/arm/mach-shmobile/intc-sh73a0.c6
-rw-r--r--arch/arm/mach-shmobile/setup-sh7367.c14
-rw-r--r--arch/arm/mach-u300/clock.h2
-rw-r--r--arch/arm/mach-u300/include/mach/u300-regs.h22
-rw-r--r--arch/arm/mach-u300/timer.c3
-rw-r--r--arch/arm/mach-vexpress/v2m.c15
-rw-r--r--arch/arm/mm/context.c17
-rw-r--r--arch/arm/mm/init.c12
-rw-r--r--arch/arm/mm/proc-arm7tdmi.S2
-rw-r--r--arch/arm/mm/proc-arm9tdmi.S2
-rw-r--r--arch/arm/mm/proc-v7.S10
-rw-r--r--arch/arm/plat-mxc/devices/platform-imx-dma.c6
-rw-r--r--arch/arm/plat-omap/omap_device.c19
-rw-r--r--arch/avr32/configs/atngw100_defconfig1
-rw-r--r--arch/avr32/configs/atngw100_evklcd100_defconfig1
-rw-r--r--arch/avr32/configs/atngw100_evklcd101_defconfig1
-rw-r--r--arch/avr32/configs/atngw100_mrmt_defconfig3
-rw-r--r--arch/avr32/configs/atngw100mkii_defconfig1
-rw-r--r--arch/avr32/configs/atngw100mkii_evklcd100_defconfig1
-rw-r--r--arch/avr32/configs/atngw100mkii_evklcd101_defconfig1
-rw-r--r--arch/avr32/configs/atstk1002_defconfig1
-rw-r--r--arch/avr32/configs/atstk1003_defconfig1
-rw-r--r--arch/avr32/configs/atstk1004_defconfig1
-rw-r--r--arch/avr32/configs/atstk1006_defconfig1
-rw-r--r--arch/avr32/configs/favr-32_defconfig1
-rw-r--r--arch/avr32/configs/hammerhead_defconfig1
-rw-r--r--arch/avr32/configs/merisc_defconfig1
-rw-r--r--arch/avr32/configs/mimc200_defconfig1
-rw-r--r--arch/avr32/include/asm/processor.h1
-rw-r--r--arch/avr32/mach-at32ap/at32ap700x.c3
-rw-r--r--arch/avr32/mach-at32ap/include/mach/cpu.h12
-rw-r--r--arch/avr32/mach-at32ap/intc.c4
-rw-r--r--arch/blackfin/configs/CM-BF548_defconfig2
-rw-r--r--arch/m68k/Kconfig.nommu52
-rw-r--r--arch/m68k/kernel/m68k_ksyms.c3
-rw-r--r--arch/m68k/kernel/vmlinux.lds_no.S20
-rw-r--r--arch/m68k/lib/memcpy.c9
-rw-r--r--arch/m68k/lib/memset.c9
-rw-r--r--arch/m68k/lib/muldi3.c21
-rw-r--r--arch/mips/configs/mtx1_defconfig2
-rw-r--r--arch/powerpc/configs/52xx/pcm030_defconfig2
-rw-r--r--arch/powerpc/configs/ps3_defconfig2
-rw-r--r--arch/sh/boards/mach-ecovec24/setup.c48
-rw-r--r--arch/sh/boot/compressed/Makefile22
-rw-r--r--arch/sh/configs/titan_defconfig2
-rw-r--r--arch/sh/include/asm/cmpxchg-grb.h21
-rw-r--r--arch/sh/include/asm/processor_64.h1
-rw-r--r--arch/sh/include/cpu-sh4/cpu/sh7724.h8
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7724.c40
-rw-r--r--arch/sh/kernel/process_32.c2
-rw-r--r--arch/sh/mm/cache-debugfs.c25
-rw-r--r--arch/x86/kernel/apic/x2apic_uv_x.c8
-rw-r--r--arch/x86/kernel/process.c4
-rw-r--r--drivers/char/hpet.c25
-rw-r--r--drivers/cpufreq/cpufreq_stats.c9
-rw-r--r--drivers/cpufreq/powernow-k8.c6
-rw-r--r--drivers/dma/shdma.c13
-rw-r--r--drivers/gpio/gpio-omap.c5
-rw-r--r--drivers/gpu/drm/drm_bufs.c17
-rw-r--r--drivers/gpu/drm/drm_crtc.c2
-rw-r--r--drivers/gpu/drm/drm_edid.c19
-rw-r--r--drivers/gpu/drm/drm_ioc32.c9
-rw-r--r--drivers/gpu/drm/drm_pci.c3
-rw-r--r--drivers/gpu/drm/drm_vm.c2
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c6
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c10
-rw-r--r--drivers/gpu/drm/i915/intel_i2c.c3
-rw-r--r--drivers/gpu/drm/mga/mga_drv.h19
-rw-r--r--drivers/gpu/drm/radeon/atombios.h1
-rw-r--r--drivers/gpu/drm/radeon/atombios_crtc.c7
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c22
-rw-r--r--drivers/gpu/drm/radeon/r100_track.h8
-rw-r--r--drivers/gpu/drm/radeon/r600.c17
-rw-r--r--drivers/gpu/drm/radeon/radeon.h1
-rw-r--r--drivers/gpu/drm/radeon/radeon_asic.c31
-rw-r--r--drivers/gpu/drm/radeon/radeon_atombios.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_clocks.c8
-rw-r--r--drivers/gpu/drm/radeon/radeon_combios.c11
-rw-r--r--drivers/gpu/drm/radeon/radeon_connectors.c71
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_encoders.c123
-rw-r--r--drivers/gpu/drm/radeon/radeon_fence.c51
-rw-r--r--drivers/gpu/drm/radeon/radeon_mode.h2
-rw-r--r--drivers/gpu/drm/savage/savage_bci.c3
-rw-r--r--drivers/hid/Kconfig1
-rw-r--r--drivers/hid/hid-core.c1
-rw-r--r--drivers/hid/hid-ids.h4
-rw-r--r--drivers/hid/hid-magicmouse.c10
-rw-r--r--drivers/hid/hid-multitouch.c62
-rw-r--r--drivers/hid/usbhid/hid-quirks.c1
-rw-r--r--drivers/hid/usbhid/hiddev.c8
-rw-r--r--drivers/hwmon/asus_atk0110.c5
-rw-r--r--drivers/hwmon/coretemp.c4
-rw-r--r--drivers/hwmon/ibmaem.c2
-rw-r--r--drivers/hwmon/ibmpex.c1
-rw-r--r--drivers/hwmon/s3c-hwmon.c2
-rw-r--r--drivers/leds/Kconfig20
-rw-r--r--drivers/md/bitmap.c104
-rw-r--r--drivers/md/bitmap.h10
-rw-r--r--drivers/md/md.c41
-rw-r--r--drivers/md/md.h2
-rw-r--r--drivers/md/raid1.c24
-rw-r--r--drivers/md/raid1.h2
-rw-r--r--drivers/md/raid5.c16
-rw-r--r--drivers/misc/apds990x.c2
-rw-r--r--drivers/misc/cs5535-mfgpt.c2
-rw-r--r--drivers/misc/spear13xx_pcie_gadget.c2
-rw-r--r--drivers/mmc/host/mmci.c12
-rw-r--r--drivers/pci/pci.c4
-rw-r--r--drivers/pcmcia/pxa2xx_vpac270.c1
-rw-r--r--drivers/sh/clk/core.c2
-rw-r--r--drivers/spi/spi_bfin5xx.c7
-rw-r--r--drivers/staging/iio/accel/adis16201.h2
-rw-r--r--drivers/staging/iio/accel/adis16203.h2
-rw-r--r--drivers/tty/serial/pch_uart.c4
-rw-r--r--drivers/video/aty/atyfb_base.c10
-rw-r--r--drivers/video/backlight/Kconfig12
-rw-r--r--drivers/video/backlight/Makefile1
-rw-r--r--drivers/video/backlight/adp8870_bl.c1012
-rw-r--r--drivers/video/efifb.c2
-rw-r--r--drivers/video/s3c-fb.c22
-rw-r--r--drivers/video/sh_mobile_hdmi.c18
-rw-r--r--drivers/w1/masters/Kconfig2
-rw-r--r--fs/afs/dir.c8
-rw-r--r--fs/afs/fsclient.c3
-rw-r--r--fs/afs/inode.c10
-rw-r--r--fs/afs/super.c74
-rw-r--r--fs/afs/write.c21
-rw-r--r--fs/buffer.c4
-rw-r--r--fs/cifs/cache.c6
-rw-r--r--fs/cifs/cifsfs.c33
-rw-r--r--fs/cifs/cifsfs.h2
-rw-r--r--fs/cifs/connect.c23
-rw-r--r--fs/cifs/fscache.c51
-rw-r--r--fs/exec.c2
-rw-r--r--fs/isofs/inode.c3
-rw-r--r--fs/namei.c28
-rw-r--r--fs/proc/namespaces.c9
-rw-r--r--fs/proc/root.c11
-rw-r--r--fs/sysfs/mount.c37
-rw-r--r--fs/sysfs/sysfs.h2
-rw-r--r--fs/ubifs/super.c137
-rw-r--r--fs/xfs/linux-2.6/xfs_file.c50
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.c2
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c75
-rw-r--r--fs/xfs/xfs_log.c11
-rw-r--r--include/asm-generic/gpio.h10
-rw-r--r--include/asm-generic/pgtable.h2
-rw-r--r--include/drm/drm_crtc.h2
-rw-r--r--include/linux/gpio.h11
-rw-r--r--include/linux/i2c/adp8870.h153
-rw-r--r--include/linux/kernel.h4
-rw-r--r--include/linux/kmod.h8
-rw-r--r--include/linux/kmsg_dump.h1
-rw-r--r--include/linux/kobject_ns.h10
-rw-r--r--include/linux/memcontrol.h6
-rw-r--r--include/linux/swap.h8
-rw-r--r--include/linux/sysfs.h7
-rw-r--r--include/linux/topology.h2
-rw-r--r--include/linux/uts.h2
-rw-r--r--include/net/net_namespace.h10
-rw-r--r--include/trace/events/vmscan.h83
-rw-r--r--init/Kconfig10
-rw-r--r--init/calibrate.c3
-rw-r--r--kernel/exit.c31
-rw-r--r--kernel/gcov/Kconfig3
-rw-r--r--kernel/kmod.c16
-rw-r--r--kernel/sched_rt.c6
-rw-r--r--kernel/signal.c2
-rw-r--r--lib/bitmap.c2
-rw-r--r--lib/kobject.c26
-rw-r--r--mm/compaction.c76
-rw-r--r--mm/huge_memory.c5
-rw-r--r--mm/hugetlb.c8
-rw-r--r--mm/ksm.c6
-rw-r--r--mm/memcontrol.c81
-rw-r--r--mm/memory-failure.c4
-rw-r--r--mm/memory.c8
-rw-r--r--mm/memory_hotplug.c6
-rw-r--r--mm/migrate.c2
-rw-r--r--mm/mmap.c12
-rw-r--r--mm/page_cgroup.c71
-rw-r--r--mm/rmap.c106
-rw-r--r--mm/thrash.c105
-rw-r--r--mm/vmscan.c20
-rw-r--r--net/core/net-sysfs.c23
-rw-r--r--net/core/net_namespace.c12
-rwxr-xr-xscripts/checkpatch.pl5
-rw-r--r--security/keys/request_key.c3
-rw-r--r--security/selinux/selinuxfs.c37
-rw-r--r--security/selinux/ss/policydb.c3
-rw-r--r--security/tomoyo/mount.c2
-rw-r--r--sound/firewire/isight.c1
-rw-r--r--sound/pci/emu10k1/emu10k1_main.c8
-rw-r--r--sound/pci/hda/hda_beep.h9
-rw-r--r--sound/pci/hda/patch_realtek.c3
-rw-r--r--sound/pci/hda/patch_via.c11
-rw-r--r--sound/pci/lola/lola.c2
-rw-r--r--sound/pci/rme9652/hdspm.c8
-rw-r--r--sound/usb/6fire/firmware.c1
-rw-r--r--sound/usb/6fire/pcm.c4
-rwxr-xr-xtools/perf/util/PERF-VERSION-GEN2
244 files changed, 3617 insertions, 1231 deletions
diff --git a/Documentation/ABI/testing/sysfs-class-backlight-driver-adp8870 b/Documentation/ABI/testing/sysfs-class-backlight-driver-adp8870
new file mode 100644
index 000000000000..aa11dbdd794b
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-backlight-driver-adp8870
@@ -0,0 +1,56 @@
1What: /sys/class/backlight/<backlight>/<ambient light zone>_max
2What: /sys/class/backlight/<backlight>/l1_daylight_max
3What: /sys/class/backlight/<backlight>/l2_bright_max
4What: /sys/class/backlight/<backlight>/l3_office_max
5What: /sys/class/backlight/<backlight>/l4_indoor_max
6What: /sys/class/backlight/<backlight>/l5_dark_max
7Date: Mai 2011
8KernelVersion: 2.6.40
9Contact: device-drivers-devel@blackfin.uclinux.org
10Description:
11 Control the maximum brightness for <ambient light zone>
12 on this <backlight>. Values are between 0 and 127. This file
13 will also show the brightness level stored for this
14 <ambient light zone>.
15
16What: /sys/class/backlight/<backlight>/<ambient light zone>_dim
17What: /sys/class/backlight/<backlight>/l2_bright_dim
18What: /sys/class/backlight/<backlight>/l3_office_dim
19What: /sys/class/backlight/<backlight>/l4_indoor_dim
20What: /sys/class/backlight/<backlight>/l5_dark_dim
21Date: Mai 2011
22KernelVersion: 2.6.40
23Contact: device-drivers-devel@blackfin.uclinux.org
24Description:
25 Control the dim brightness for <ambient light zone>
26 on this <backlight>. Values are between 0 and 127, typically
27 set to 0. Full off when the backlight is disabled.
28 This file will also show the dim brightness level stored for
29 this <ambient light zone>.
30
31What: /sys/class/backlight/<backlight>/ambient_light_level
32Date: Mai 2011
33KernelVersion: 2.6.40
34Contact: device-drivers-devel@blackfin.uclinux.org
35Description:
36 Get conversion value of the light sensor.
37 This value is updated every 80 ms (when the light sensor
38 is enabled). Returns integer between 0 (dark) and
39 8000 (max ambient brightness)
40
41What: /sys/class/backlight/<backlight>/ambient_light_zone
42Date: Mai 2011
43KernelVersion: 2.6.40
44Contact: device-drivers-devel@blackfin.uclinux.org
45Description:
46 Get/Set current ambient light zone. Reading returns
47 integer between 1..5 (1 = daylight, 2 = bright, ..., 5 = dark).
48 Writing a value between 1..5 forces the backlight controller
49 to enter the corresponding ambient light zone.
50 Writing 0 returns to normal/automatic ambient light level
51 operation. The ambient light sensing feature on these devices
52 is an extension to the API documented in
53 Documentation/ABI/stable/sysfs-class-backlight.
54 It can be enabled by writing the value stored in
55 /sys/class/backlight/<backlight>/max_brightness to
56 /sys/class/backlight/<backlight>/brightness. \ No newline at end of file
diff --git a/Documentation/accounting/cgroupstats.txt b/Documentation/accounting/cgroupstats.txt
index eda40fd39cad..d16a9849e60e 100644
--- a/Documentation/accounting/cgroupstats.txt
+++ b/Documentation/accounting/cgroupstats.txt
@@ -21,7 +21,7 @@ information will not be available.
21To extract cgroup statistics a utility very similar to getdelays.c 21To extract cgroup statistics a utility very similar to getdelays.c
22has been developed, the sample output of the utility is shown below 22has been developed, the sample output of the utility is shown below
23 23
24~/balbir/cgroupstats # ./getdelays -C "/cgroup/a" 24~/balbir/cgroupstats # ./getdelays -C "/sys/fs/cgroup/a"
25sleeping 1, blocked 0, running 1, stopped 0, uninterruptible 0 25sleeping 1, blocked 0, running 1, stopped 0, uninterruptible 0
26~/balbir/cgroupstats # ./getdelays -C "/cgroup" 26~/balbir/cgroupstats # ./getdelays -C "/sys/fs/cgroup"
27sleeping 155, blocked 0, running 1, stopped 0, uninterruptible 2 27sleeping 155, blocked 0, running 1, stopped 0, uninterruptible 2
diff --git a/Documentation/cgroups/blkio-controller.txt b/Documentation/cgroups/blkio-controller.txt
index 465351d4cf85..cd45c8ea7463 100644
--- a/Documentation/cgroups/blkio-controller.txt
+++ b/Documentation/cgroups/blkio-controller.txt
@@ -28,16 +28,19 @@ cgroups. Here is what you can do.
28- Enable group scheduling in CFQ 28- Enable group scheduling in CFQ
29 CONFIG_CFQ_GROUP_IOSCHED=y 29 CONFIG_CFQ_GROUP_IOSCHED=y
30 30
31- Compile and boot into kernel and mount IO controller (blkio). 31- Compile and boot into kernel and mount IO controller (blkio); see
32 cgroups.txt, Why are cgroups needed?.
32 33
33 mount -t cgroup -o blkio none /cgroup 34 mount -t tmpfs cgroup_root /sys/fs/cgroup
35 mkdir /sys/fs/cgroup/blkio
36 mount -t cgroup -o blkio none /sys/fs/cgroup/blkio
34 37
35- Create two cgroups 38- Create two cgroups
36 mkdir -p /cgroup/test1/ /cgroup/test2 39 mkdir -p /sys/fs/cgroup/blkio/test1/ /sys/fs/cgroup/blkio/test2
37 40
38- Set weights of group test1 and test2 41- Set weights of group test1 and test2
39 echo 1000 > /cgroup/test1/blkio.weight 42 echo 1000 > /sys/fs/cgroup/blkio/test1/blkio.weight
40 echo 500 > /cgroup/test2/blkio.weight 43 echo 500 > /sys/fs/cgroup/blkio/test2/blkio.weight
41 44
42- Create two same size files (say 512MB each) on same disk (file1, file2) and 45- Create two same size files (say 512MB each) on same disk (file1, file2) and
43 launch two dd threads in different cgroup to read those files. 46 launch two dd threads in different cgroup to read those files.
@@ -46,12 +49,12 @@ cgroups. Here is what you can do.
46 echo 3 > /proc/sys/vm/drop_caches 49 echo 3 > /proc/sys/vm/drop_caches
47 50
48 dd if=/mnt/sdb/zerofile1 of=/dev/null & 51 dd if=/mnt/sdb/zerofile1 of=/dev/null &
49 echo $! > /cgroup/test1/tasks 52 echo $! > /sys/fs/cgroup/blkio/test1/tasks
50 cat /cgroup/test1/tasks 53 cat /sys/fs/cgroup/blkio/test1/tasks
51 54
52 dd if=/mnt/sdb/zerofile2 of=/dev/null & 55 dd if=/mnt/sdb/zerofile2 of=/dev/null &
53 echo $! > /cgroup/test2/tasks 56 echo $! > /sys/fs/cgroup/blkio/test2/tasks
54 cat /cgroup/test2/tasks 57 cat /sys/fs/cgroup/blkio/test2/tasks
55 58
56- At macro level, first dd should finish first. To get more precise data, keep 59- At macro level, first dd should finish first. To get more precise data, keep
57 on looking at (with the help of script), at blkio.disk_time and 60 on looking at (with the help of script), at blkio.disk_time and
@@ -68,13 +71,13 @@ Throttling/Upper Limit policy
68- Enable throttling in block layer 71- Enable throttling in block layer
69 CONFIG_BLK_DEV_THROTTLING=y 72 CONFIG_BLK_DEV_THROTTLING=y
70 73
71- Mount blkio controller 74- Mount blkio controller (see cgroups.txt, Why are cgroups needed?)
72 mount -t cgroup -o blkio none /cgroup/blkio 75 mount -t cgroup -o blkio none /sys/fs/cgroup/blkio
73 76
74- Specify a bandwidth rate on particular device for root group. The format 77- Specify a bandwidth rate on particular device for root group. The format
75 for policy is "<major>:<minor> <byes_per_second>". 78 for policy is "<major>:<minor> <byes_per_second>".
76 79
77 echo "8:16 1048576" > /cgroup/blkio/blkio.read_bps_device 80 echo "8:16 1048576" > /sys/fs/cgroup/blkio/blkio.read_bps_device
78 81
79 Above will put a limit of 1MB/second on reads happening for root group 82 Above will put a limit of 1MB/second on reads happening for root group
80 on device having major/minor number 8:16. 83 on device having major/minor number 8:16.
@@ -108,7 +111,7 @@ Hierarchical Cgroups
108 CFQ and throttling will practically treat all groups at same level. 111 CFQ and throttling will practically treat all groups at same level.
109 112
110 pivot 113 pivot
111 / | \ \ 114 / / \ \
112 root test1 test2 test3 115 root test1 test2 test3
113 116
114 Down the line we can implement hierarchical accounting/control support 117 Down the line we can implement hierarchical accounting/control support
@@ -149,7 +152,7 @@ Proportional weight policy files
149 152
150 Following is the format. 153 Following is the format.
151 154
152 #echo dev_maj:dev_minor weight > /path/to/cgroup/blkio.weight_device 155 # echo dev_maj:dev_minor weight > blkio.weight_device
153 Configure weight=300 on /dev/sdb (8:16) in this cgroup 156 Configure weight=300 on /dev/sdb (8:16) in this cgroup
154 # echo 8:16 300 > blkio.weight_device 157 # echo 8:16 300 > blkio.weight_device
155 # cat blkio.weight_device 158 # cat blkio.weight_device
diff --git a/Documentation/cgroups/cgroups.txt b/Documentation/cgroups/cgroups.txt
index 0ed99f08f1f3..cd67e90003c0 100644
--- a/Documentation/cgroups/cgroups.txt
+++ b/Documentation/cgroups/cgroups.txt
@@ -138,11 +138,11 @@ With the ability to classify tasks differently for different resources
138the admin can easily set up a script which receives exec notifications 138the admin can easily set up a script which receives exec notifications
139and depending on who is launching the browser he can 139and depending on who is launching the browser he can
140 140
141 # echo browser_pid > /mnt/<restype>/<userclass>/tasks 141 # echo browser_pid > /sys/fs/cgroup/<restype>/<userclass>/tasks
142 142
143With only a single hierarchy, he now would potentially have to create 143With only a single hierarchy, he now would potentially have to create
144a separate cgroup for every browser launched and associate it with 144a separate cgroup for every browser launched and associate it with
145approp network and other resource class. This may lead to 145appropriate network and other resource class. This may lead to
146proliferation of such cgroups. 146proliferation of such cgroups.
147 147
148Also lets say that the administrator would like to give enhanced network 148Also lets say that the administrator would like to give enhanced network
@@ -153,9 +153,9 @@ apps enhanced CPU power,
153With ability to write pids directly to resource classes, it's just a 153With ability to write pids directly to resource classes, it's just a
154matter of : 154matter of :
155 155
156 # echo pid > /mnt/network/<new_class>/tasks 156 # echo pid > /sys/fs/cgroup/network/<new_class>/tasks
157 (after some time) 157 (after some time)
158 # echo pid > /mnt/network/<orig_class>/tasks 158 # echo pid > /sys/fs/cgroup/network/<orig_class>/tasks
159 159
160Without this ability, he would have to split the cgroup into 160Without this ability, he would have to split the cgroup into
161multiple separate ones and then associate the new cgroups with the 161multiple separate ones and then associate the new cgroups with the
@@ -310,21 +310,24 @@ subsystem, this is the case for the cpuset.
310To start a new job that is to be contained within a cgroup, using 310To start a new job that is to be contained within a cgroup, using
311the "cpuset" cgroup subsystem, the steps are something like: 311the "cpuset" cgroup subsystem, the steps are something like:
312 312
313 1) mkdir /dev/cgroup 313 1) mount -t tmpfs cgroup_root /sys/fs/cgroup
314 2) mount -t cgroup -ocpuset cpuset /dev/cgroup 314 2) mkdir /sys/fs/cgroup/cpuset
315 3) Create the new cgroup by doing mkdir's and write's (or echo's) in 315 3) mount -t cgroup -ocpuset cpuset /sys/fs/cgroup/cpuset
316 the /dev/cgroup virtual file system. 316 4) Create the new cgroup by doing mkdir's and write's (or echo's) in
317 4) Start a task that will be the "founding father" of the new job. 317 the /sys/fs/cgroup virtual file system.
318 5) Attach that task to the new cgroup by writing its pid to the 318 5) Start a task that will be the "founding father" of the new job.
319 /dev/cgroup tasks file for that cgroup. 319 6) Attach that task to the new cgroup by writing its pid to the
320 6) fork, exec or clone the job tasks from this founding father task. 320 /sys/fs/cgroup/cpuset/tasks file for that cgroup.
321 7) fork, exec or clone the job tasks from this founding father task.
321 322
322For example, the following sequence of commands will setup a cgroup 323For example, the following sequence of commands will setup a cgroup
323named "Charlie", containing just CPUs 2 and 3, and Memory Node 1, 324named "Charlie", containing just CPUs 2 and 3, and Memory Node 1,
324and then start a subshell 'sh' in that cgroup: 325and then start a subshell 'sh' in that cgroup:
325 326
326 mount -t cgroup cpuset -ocpuset /dev/cgroup 327 mount -t tmpfs cgroup_root /sys/fs/cgroup
327 cd /dev/cgroup 328 mkdir /sys/fs/cgroup/cpuset
329 mount -t cgroup cpuset -ocpuset /sys/fs/cgroup/cpuset
330 cd /sys/fs/cgroup/cpuset
328 mkdir Charlie 331 mkdir Charlie
329 cd Charlie 332 cd Charlie
330 /bin/echo 2-3 > cpuset.cpus 333 /bin/echo 2-3 > cpuset.cpus
@@ -345,7 +348,7 @@ Creating, modifying, using the cgroups can be done through the cgroup
345virtual filesystem. 348virtual filesystem.
346 349
347To mount a cgroup hierarchy with all available subsystems, type: 350To mount a cgroup hierarchy with all available subsystems, type:
348# mount -t cgroup xxx /dev/cgroup 351# mount -t cgroup xxx /sys/fs/cgroup
349 352
350The "xxx" is not interpreted by the cgroup code, but will appear in 353The "xxx" is not interpreted by the cgroup code, but will appear in
351/proc/mounts so may be any useful identifying string that you like. 354/proc/mounts so may be any useful identifying string that you like.
@@ -354,23 +357,32 @@ Note: Some subsystems do not work without some user input first. For instance,
354if cpusets are enabled the user will have to populate the cpus and mems files 357if cpusets are enabled the user will have to populate the cpus and mems files
355for each new cgroup created before that group can be used. 358for each new cgroup created before that group can be used.
356 359
360As explained in section `1.2 Why are cgroups needed?' you should create
361different hierarchies of cgroups for each single resource or group of
362resources you want to control. Therefore, you should mount a tmpfs on
363/sys/fs/cgroup and create directories for each cgroup resource or resource
364group.
365
366# mount -t tmpfs cgroup_root /sys/fs/cgroup
367# mkdir /sys/fs/cgroup/rg1
368
357To mount a cgroup hierarchy with just the cpuset and memory 369To mount a cgroup hierarchy with just the cpuset and memory
358subsystems, type: 370subsystems, type:
359# mount -t cgroup -o cpuset,memory hier1 /dev/cgroup 371# mount -t cgroup -o cpuset,memory hier1 /sys/fs/cgroup/rg1
360 372
361To change the set of subsystems bound to a mounted hierarchy, just 373To change the set of subsystems bound to a mounted hierarchy, just
362remount with different options: 374remount with different options:
363# mount -o remount,cpuset,blkio hier1 /dev/cgroup 375# mount -o remount,cpuset,blkio hier1 /sys/fs/cgroup/rg1
364 376
365Now memory is removed from the hierarchy and blkio is added. 377Now memory is removed from the hierarchy and blkio is added.
366 378
367Note this will add blkio to the hierarchy but won't remove memory or 379Note this will add blkio to the hierarchy but won't remove memory or
368cpuset, because the new options are appended to the old ones: 380cpuset, because the new options are appended to the old ones:
369# mount -o remount,blkio /dev/cgroup 381# mount -o remount,blkio /sys/fs/cgroup/rg1
370 382
371To Specify a hierarchy's release_agent: 383To Specify a hierarchy's release_agent:
372# mount -t cgroup -o cpuset,release_agent="/sbin/cpuset_release_agent" \ 384# mount -t cgroup -o cpuset,release_agent="/sbin/cpuset_release_agent" \
373 xxx /dev/cgroup 385 xxx /sys/fs/cgroup/rg1
374 386
375Note that specifying 'release_agent' more than once will return failure. 387Note that specifying 'release_agent' more than once will return failure.
376 388
@@ -379,17 +391,17 @@ when the hierarchy consists of a single (root) cgroup. Supporting
379the ability to arbitrarily bind/unbind subsystems from an existing 391the ability to arbitrarily bind/unbind subsystems from an existing
380cgroup hierarchy is intended to be implemented in the future. 392cgroup hierarchy is intended to be implemented in the future.
381 393
382Then under /dev/cgroup you can find a tree that corresponds to the 394Then under /sys/fs/cgroup/rg1 you can find a tree that corresponds to the
383tree of the cgroups in the system. For instance, /dev/cgroup 395tree of the cgroups in the system. For instance, /sys/fs/cgroup/rg1
384is the cgroup that holds the whole system. 396is the cgroup that holds the whole system.
385 397
386If you want to change the value of release_agent: 398If you want to change the value of release_agent:
387# echo "/sbin/new_release_agent" > /dev/cgroup/release_agent 399# echo "/sbin/new_release_agent" > /sys/fs/cgroup/rg1/release_agent
388 400
389It can also be changed via remount. 401It can also be changed via remount.
390 402
391If you want to create a new cgroup under /dev/cgroup: 403If you want to create a new cgroup under /sys/fs/cgroup/rg1:
392# cd /dev/cgroup 404# cd /sys/fs/cgroup/rg1
393# mkdir my_cgroup 405# mkdir my_cgroup
394 406
395Now you want to do something with this cgroup. 407Now you want to do something with this cgroup.
diff --git a/Documentation/cgroups/cpuacct.txt b/Documentation/cgroups/cpuacct.txt
index 8b930946c52a..9ad85df4b983 100644
--- a/Documentation/cgroups/cpuacct.txt
+++ b/Documentation/cgroups/cpuacct.txt
@@ -10,26 +10,25 @@ directly present in its group.
10 10
11Accounting groups can be created by first mounting the cgroup filesystem. 11Accounting groups can be created by first mounting the cgroup filesystem.
12 12
13# mkdir /cgroups 13# mount -t cgroup -ocpuacct none /sys/fs/cgroup
14# mount -t cgroup -ocpuacct none /cgroups 14
15 15With the above step, the initial or the parent accounting group becomes
16With the above step, the initial or the parent accounting group 16visible at /sys/fs/cgroup. At bootup, this group includes all the tasks in
17becomes visible at /cgroups. At bootup, this group includes all the 17the system. /sys/fs/cgroup/tasks lists the tasks in this cgroup.
18tasks in the system. /cgroups/tasks lists the tasks in this cgroup. 18/sys/fs/cgroup/cpuacct.usage gives the CPU time (in nanoseconds) obtained
19/cgroups/cpuacct.usage gives the CPU time (in nanoseconds) obtained by 19by this group which is essentially the CPU time obtained by all the tasks
20this group which is essentially the CPU time obtained by all the tasks
21in the system. 20in the system.
22 21
23New accounting groups can be created under the parent group /cgroups. 22New accounting groups can be created under the parent group /sys/fs/cgroup.
24 23
25# cd /cgroups 24# cd /sys/fs/cgroup
26# mkdir g1 25# mkdir g1
27# echo $$ > g1 26# echo $$ > g1
28 27
29The above steps create a new group g1 and move the current shell 28The above steps create a new group g1 and move the current shell
30process (bash) into it. CPU time consumed by this bash and its children 29process (bash) into it. CPU time consumed by this bash and its children
31can be obtained from g1/cpuacct.usage and the same is accumulated in 30can be obtained from g1/cpuacct.usage and the same is accumulated in
32/cgroups/cpuacct.usage also. 31/sys/fs/cgroup/cpuacct.usage also.
33 32
34cpuacct.stat file lists a few statistics which further divide the 33cpuacct.stat file lists a few statistics which further divide the
35CPU time obtained by the cgroup into user and system times. Currently 34CPU time obtained by the cgroup into user and system times. Currently
diff --git a/Documentation/cgroups/cpusets.txt b/Documentation/cgroups/cpusets.txt
index 98a30829af7a..5b0d78e55ccc 100644
--- a/Documentation/cgroups/cpusets.txt
+++ b/Documentation/cgroups/cpusets.txt
@@ -661,21 +661,21 @@ than stress the kernel.
661 661
662To start a new job that is to be contained within a cpuset, the steps are: 662To start a new job that is to be contained within a cpuset, the steps are:
663 663
664 1) mkdir /dev/cpuset 664 1) mkdir /sys/fs/cgroup/cpuset
665 2) mount -t cgroup -ocpuset cpuset /dev/cpuset 665 2) mount -t cgroup -ocpuset cpuset /sys/fs/cgroup/cpuset
666 3) Create the new cpuset by doing mkdir's and write's (or echo's) in 666 3) Create the new cpuset by doing mkdir's and write's (or echo's) in
667 the /dev/cpuset virtual file system. 667 the /sys/fs/cgroup/cpuset virtual file system.
668 4) Start a task that will be the "founding father" of the new job. 668 4) Start a task that will be the "founding father" of the new job.
669 5) Attach that task to the new cpuset by writing its pid to the 669 5) Attach that task to the new cpuset by writing its pid to the
670 /dev/cpuset tasks file for that cpuset. 670 /sys/fs/cgroup/cpuset tasks file for that cpuset.
671 6) fork, exec or clone the job tasks from this founding father task. 671 6) fork, exec or clone the job tasks from this founding father task.
672 672
673For example, the following sequence of commands will setup a cpuset 673For example, the following sequence of commands will setup a cpuset
674named "Charlie", containing just CPUs 2 and 3, and Memory Node 1, 674named "Charlie", containing just CPUs 2 and 3, and Memory Node 1,
675and then start a subshell 'sh' in that cpuset: 675and then start a subshell 'sh' in that cpuset:
676 676
677 mount -t cgroup -ocpuset cpuset /dev/cpuset 677 mount -t cgroup -ocpuset cpuset /sys/fs/cgroup/cpuset
678 cd /dev/cpuset 678 cd /sys/fs/cgroup/cpuset
679 mkdir Charlie 679 mkdir Charlie
680 cd Charlie 680 cd Charlie
681 /bin/echo 2-3 > cpuset.cpus 681 /bin/echo 2-3 > cpuset.cpus
@@ -710,14 +710,14 @@ Creating, modifying, using the cpusets can be done through the cpuset
710virtual filesystem. 710virtual filesystem.
711 711
712To mount it, type: 712To mount it, type:
713# mount -t cgroup -o cpuset cpuset /dev/cpuset 713# mount -t cgroup -o cpuset cpuset /sys/fs/cgroup/cpuset
714 714
715Then under /dev/cpuset you can find a tree that corresponds to the 715Then under /sys/fs/cgroup/cpuset you can find a tree that corresponds to the
716tree of the cpusets in the system. For instance, /dev/cpuset 716tree of the cpusets in the system. For instance, /sys/fs/cgroup/cpuset
717is the cpuset that holds the whole system. 717is the cpuset that holds the whole system.
718 718
719If you want to create a new cpuset under /dev/cpuset: 719If you want to create a new cpuset under /sys/fs/cgroup/cpuset:
720# cd /dev/cpuset 720# cd /sys/fs/cgroup/cpuset
721# mkdir my_cpuset 721# mkdir my_cpuset
722 722
723Now you want to do something with this cpuset. 723Now you want to do something with this cpuset.
@@ -765,12 +765,12 @@ wrapper around the cgroup filesystem.
765 765
766The command 766The command
767 767
768mount -t cpuset X /dev/cpuset 768mount -t cpuset X /sys/fs/cgroup/cpuset
769 769
770is equivalent to 770is equivalent to
771 771
772mount -t cgroup -ocpuset,noprefix X /dev/cpuset 772mount -t cgroup -ocpuset,noprefix X /sys/fs/cgroup/cpuset
773echo "/sbin/cpuset_release_agent" > /dev/cpuset/release_agent 773echo "/sbin/cpuset_release_agent" > /sys/fs/cgroup/cpuset/release_agent
774 774
7752.2 Adding/removing cpus 7752.2 Adding/removing cpus
776------------------------ 776------------------------
diff --git a/Documentation/cgroups/devices.txt b/Documentation/cgroups/devices.txt
index 57ca4c89fe5c..16624a7f8222 100644
--- a/Documentation/cgroups/devices.txt
+++ b/Documentation/cgroups/devices.txt
@@ -22,16 +22,16 @@ removed from the child(ren).
22An entry is added using devices.allow, and removed using 22An entry is added using devices.allow, and removed using
23devices.deny. For instance 23devices.deny. For instance
24 24
25 echo 'c 1:3 mr' > /cgroups/1/devices.allow 25 echo 'c 1:3 mr' > /sys/fs/cgroup/1/devices.allow
26 26
27allows cgroup 1 to read and mknod the device usually known as 27allows cgroup 1 to read and mknod the device usually known as
28/dev/null. Doing 28/dev/null. Doing
29 29
30 echo a > /cgroups/1/devices.deny 30 echo a > /sys/fs/cgroup/1/devices.deny
31 31
32will remove the default 'a *:* rwm' entry. Doing 32will remove the default 'a *:* rwm' entry. Doing
33 33
34 echo a > /cgroups/1/devices.allow 34 echo a > /sys/fs/cgroup/1/devices.allow
35 35
36will add the 'a *:* rwm' entry to the whitelist. 36will add the 'a *:* rwm' entry to the whitelist.
37 37
diff --git a/Documentation/cgroups/freezer-subsystem.txt b/Documentation/cgroups/freezer-subsystem.txt
index 41f37fea1276..c21d77742a07 100644
--- a/Documentation/cgroups/freezer-subsystem.txt
+++ b/Documentation/cgroups/freezer-subsystem.txt
@@ -59,28 +59,28 @@ is non-freezable.
59 59
60* Examples of usage : 60* Examples of usage :
61 61
62 # mkdir /containers 62 # mkdir /sys/fs/cgroup/freezer
63 # mount -t cgroup -ofreezer freezer /containers 63 # mount -t cgroup -ofreezer freezer /sys/fs/cgroup/freezer
64 # mkdir /containers/0 64 # mkdir /sys/fs/cgroup/freezer/0
65 # echo $some_pid > /containers/0/tasks 65 # echo $some_pid > /sys/fs/cgroup/freezer/0/tasks
66 66
67to get status of the freezer subsystem : 67to get status of the freezer subsystem :
68 68
69 # cat /containers/0/freezer.state 69 # cat /sys/fs/cgroup/freezer/0/freezer.state
70 THAWED 70 THAWED
71 71
72to freeze all tasks in the container : 72to freeze all tasks in the container :
73 73
74 # echo FROZEN > /containers/0/freezer.state 74 # echo FROZEN > /sys/fs/cgroup/freezer/0/freezer.state
75 # cat /containers/0/freezer.state 75 # cat /sys/fs/cgroup/freezer/0/freezer.state
76 FREEZING 76 FREEZING
77 # cat /containers/0/freezer.state 77 # cat /sys/fs/cgroup/freezer/0/freezer.state
78 FROZEN 78 FROZEN
79 79
80to unfreeze all tasks in the container : 80to unfreeze all tasks in the container :
81 81
82 # echo THAWED > /containers/0/freezer.state 82 # echo THAWED > /sys/fs/cgroup/freezer/0/freezer.state
83 # cat /containers/0/freezer.state 83 # cat /sys/fs/cgroup/freezer/0/freezer.state
84 THAWED 84 THAWED
85 85
86This is the basic mechanism which should do the right thing for user space task 86This is the basic mechanism which should do the right thing for user space task
diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt
index 7c163477fcd8..06eb6d957c83 100644
--- a/Documentation/cgroups/memory.txt
+++ b/Documentation/cgroups/memory.txt
@@ -1,8 +1,8 @@
1Memory Resource Controller 1Memory Resource Controller
2 2
3NOTE: The Memory Resource Controller has been generically been referred 3NOTE: The Memory Resource Controller has generically been referred to as the
4 to as the memory controller in this document. Do not confuse memory 4 memory controller in this document. Do not confuse memory controller
5 controller used here with the memory controller that is used in hardware. 5 used here with the memory controller that is used in hardware.
6 6
7(For editors) 7(For editors)
8In this document: 8In this document:
@@ -70,6 +70,7 @@ Brief summary of control files.
70 (See sysctl's vm.swappiness) 70 (See sysctl's vm.swappiness)
71 memory.move_charge_at_immigrate # set/show controls of moving charges 71 memory.move_charge_at_immigrate # set/show controls of moving charges
72 memory.oom_control # set/show oom controls. 72 memory.oom_control # set/show oom controls.
73 memory.numa_stat # show the number of memory usage per numa node
73 74
741. History 751. History
75 76
@@ -181,7 +182,7 @@ behind this approach is that a cgroup that aggressively uses a shared
181page will eventually get charged for it (once it is uncharged from 182page will eventually get charged for it (once it is uncharged from
182the cgroup that brought it in -- this will happen on memory pressure). 183the cgroup that brought it in -- this will happen on memory pressure).
183 184
184Exception: If CONFIG_CGROUP_CGROUP_MEM_RES_CTLR_SWAP is not used.. 185Exception: If CONFIG_CGROUP_CGROUP_MEM_RES_CTLR_SWAP is not used.
185When you do swapoff and make swapped-out pages of shmem(tmpfs) to 186When you do swapoff and make swapped-out pages of shmem(tmpfs) to
186be backed into memory in force, charges for pages are accounted against the 187be backed into memory in force, charges for pages are accounted against the
187caller of swapoff rather than the users of shmem. 188caller of swapoff rather than the users of shmem.
@@ -213,7 +214,7 @@ affecting global LRU, memory+swap limit is better than just limiting swap from
213OS point of view. 214OS point of view.
214 215
215* What happens when a cgroup hits memory.memsw.limit_in_bytes 216* What happens when a cgroup hits memory.memsw.limit_in_bytes
216When a cgroup his memory.memsw.limit_in_bytes, it's useless to do swap-out 217When a cgroup hits memory.memsw.limit_in_bytes, it's useless to do swap-out
217in this cgroup. Then, swap-out will not be done by cgroup routine and file 218in this cgroup. Then, swap-out will not be done by cgroup routine and file
218caches are dropped. But as mentioned above, global LRU can do swapout memory 219caches are dropped. But as mentioned above, global LRU can do swapout memory
219from it for sanity of the system's memory management state. You can't forbid 220from it for sanity of the system's memory management state. You can't forbid
@@ -263,16 +264,17 @@ b. Enable CONFIG_RESOURCE_COUNTERS
263c. Enable CONFIG_CGROUP_MEM_RES_CTLR 264c. Enable CONFIG_CGROUP_MEM_RES_CTLR
264d. Enable CONFIG_CGROUP_MEM_RES_CTLR_SWAP (to use swap extension) 265d. Enable CONFIG_CGROUP_MEM_RES_CTLR_SWAP (to use swap extension)
265 266
2661. Prepare the cgroups 2671. Prepare the cgroups (see cgroups.txt, Why are cgroups needed?)
267# mkdir -p /cgroups 268# mount -t tmpfs none /sys/fs/cgroup
268# mount -t cgroup none /cgroups -o memory 269# mkdir /sys/fs/cgroup/memory
270# mount -t cgroup none /sys/fs/cgroup/memory -o memory
269 271
2702. Make the new group and move bash into it 2722. Make the new group and move bash into it
271# mkdir /cgroups/0 273# mkdir /sys/fs/cgroup/memory/0
272# echo $$ > /cgroups/0/tasks 274# echo $$ > /sys/fs/cgroup/memory/0/tasks
273 275
274Since now we're in the 0 cgroup, we can alter the memory limit: 276Since now we're in the 0 cgroup, we can alter the memory limit:
275# echo 4M > /cgroups/0/memory.limit_in_bytes 277# echo 4M > /sys/fs/cgroup/memory/0/memory.limit_in_bytes
276 278
277NOTE: We can use a suffix (k, K, m, M, g or G) to indicate values in kilo, 279NOTE: We can use a suffix (k, K, m, M, g or G) to indicate values in kilo,
278mega or gigabytes. (Here, Kilo, Mega, Giga are Kibibytes, Mebibytes, Gibibytes.) 280mega or gigabytes. (Here, Kilo, Mega, Giga are Kibibytes, Mebibytes, Gibibytes.)
@@ -280,11 +282,11 @@ mega or gigabytes. (Here, Kilo, Mega, Giga are Kibibytes, Mebibytes, Gibibytes.)
280NOTE: We can write "-1" to reset the *.limit_in_bytes(unlimited). 282NOTE: We can write "-1" to reset the *.limit_in_bytes(unlimited).
281NOTE: We cannot set limits on the root cgroup any more. 283NOTE: We cannot set limits on the root cgroup any more.
282 284
283# cat /cgroups/0/memory.limit_in_bytes 285# cat /sys/fs/cgroup/memory/0/memory.limit_in_bytes
2844194304 2864194304
285 287
286We can check the usage: 288We can check the usage:
287# cat /cgroups/0/memory.usage_in_bytes 289# cat /sys/fs/cgroup/memory/0/memory.usage_in_bytes
2881216512 2901216512
289 291
290A successful write to this file does not guarantee a successful set of 292A successful write to this file does not guarantee a successful set of
@@ -464,6 +466,24 @@ value for efficient access. (Of course, when necessary, it's synchronized.)
464If you want to know more exact memory usage, you should use RSS+CACHE(+SWAP) 466If you want to know more exact memory usage, you should use RSS+CACHE(+SWAP)
465value in memory.stat(see 5.2). 467value in memory.stat(see 5.2).
466 468
4695.6 numa_stat
470
471This is similar to numa_maps but operates on a per-memcg basis. This is
472useful for providing visibility into the numa locality information within
473an memcg since the pages are allowed to be allocated from any physical
474node. One of the usecases is evaluating application performance by
475combining this information with the application's cpu allocation.
476
477We export "total", "file", "anon" and "unevictable" pages per-node for
478each memcg. The ouput format of memory.numa_stat is:
479
480total=<total pages> N0=<node 0 pages> N1=<node 1 pages> ...
481file=<total file pages> N0=<node 0 pages> N1=<node 1 pages> ...
482anon=<total anon pages> N0=<node 0 pages> N1=<node 1 pages> ...
483unevictable=<total anon pages> N0=<node 0 pages> N1=<node 1 pages> ...
484
485And we have total = file + anon + unevictable.
486
4676. Hierarchy support 4876. Hierarchy support
468 488
469The memory controller supports a deep hierarchy and hierarchical accounting. 489The memory controller supports a deep hierarchy and hierarchical accounting.
@@ -471,13 +491,13 @@ The hierarchy is created by creating the appropriate cgroups in the
471cgroup filesystem. Consider for example, the following cgroup filesystem 491cgroup filesystem. Consider for example, the following cgroup filesystem
472hierarchy 492hierarchy
473 493
474 root 494 root
475 / | \ 495 / | \
476 / | \ 496 / | \
477 a b c 497 a b c
478 | \ 498 | \
479 | \ 499 | \
480 d e 500 d e
481 501
482In the diagram above, with hierarchical accounting enabled, all memory 502In the diagram above, with hierarchical accounting enabled, all memory
483usage of e, is accounted to its ancestors up until the root (i.e, c and root), 503usage of e, is accounted to its ancestors up until the root (i.e, c and root),
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 1a9446b59153..72e238465b0b 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -481,23 +481,6 @@ Who: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
481 481
482---------------------------- 482----------------------------
483 483
484What: namespace cgroup (ns_cgroup)
485When: 2.6.38
486Why: The ns_cgroup leads to some problems:
487 * cgroup creation is out-of-control
488 * cgroup name can conflict when pids are looping
489 * it is not possible to have a single process handling
490 a lot of namespaces without falling in a exponential creation time
491 * we may want to create a namespace without creating a cgroup
492
493 The ns_cgroup is replaced by a compatibility flag 'clone_children',
494 where a newly created cgroup will copy the parent cgroup values.
495 The userspace has to manually create a cgroup and add a task to
496 the 'tasks' file.
497Who: Daniel Lezcano <daniel.lezcano@free.fr>
498
499----------------------------
500
501What: iwlwifi disable_hw_scan module parameters 484What: iwlwifi disable_hw_scan module parameters
502When: 2.6.40 485When: 2.6.40
503Why: Hareware scan is the prefer method for iwlwifi devices for 486Why: Hareware scan is the prefer method for iwlwifi devices for
diff --git a/Documentation/kmemleak.txt b/Documentation/kmemleak.txt
index 090e6ee04536..51063e681ca4 100644
--- a/Documentation/kmemleak.txt
+++ b/Documentation/kmemleak.txt
@@ -11,7 +11,9 @@ with the difference that the orphan objects are not freed but only
11reported via /sys/kernel/debug/kmemleak. A similar method is used by the 11reported via /sys/kernel/debug/kmemleak. A similar method is used by the
12Valgrind tool (memcheck --leak-check) to detect the memory leaks in 12Valgrind tool (memcheck --leak-check) to detect the memory leaks in
13user-space applications. 13user-space applications.
14Kmemleak is supported on x86, arm, powerpc, sparc, sh, microblaze and tile. 14
15Please check DEBUG_KMEMLEAK dependencies in lib/Kconfig.debug for supported
16architectures.
15 17
16Usage 18Usage
17----- 19-----
diff --git a/Documentation/md.txt b/Documentation/md.txt
index 2366b1c8cf19..f0eee83ff78a 100644
--- a/Documentation/md.txt
+++ b/Documentation/md.txt
@@ -555,7 +555,7 @@ also have
555 sync_min 555 sync_min
556 sync_max 556 sync_max
557 The two values, given as numbers of sectors, indicate a range 557 The two values, given as numbers of sectors, indicate a range
558 withing the array where 'check'/'repair' will operate. Must be 558 within the array where 'check'/'repair' will operate. Must be
559 a multiple of chunk_size. When it reaches "sync_max" it will 559 a multiple of chunk_size. When it reaches "sync_max" it will
560 pause, rather than complete. 560 pause, rather than complete.
561 You can use 'select' or 'poll' on "sync_completed" to wait for 561 You can use 'select' or 'poll' on "sync_completed" to wait for
diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
index 1b5a5ddbc3ef..5df176ed59b8 100644
--- a/Documentation/printk-formats.txt
+++ b/Documentation/printk-formats.txt
@@ -9,7 +9,121 @@ If variable is of Type, use printk format specifier:
9 size_t %zu or %zx 9 size_t %zu or %zx
10 ssize_t %zd or %zx 10 ssize_t %zd or %zx
11 11
12Raw pointer value SHOULD be printed with %p. 12Raw pointer value SHOULD be printed with %p. The kernel supports
13the following extended format specifiers for pointer types:
14
15Symbols/Function Pointers:
16
17 %pF versatile_init+0x0/0x110
18 %pf versatile_init
19 %pS versatile_init+0x0/0x110
20 %ps versatile_init
21 %pB prev_fn_of_versatile_init+0x88/0x88
22
23 For printing symbols and function pointers. The 'S' and 's' specifiers
24 result in the symbol name with ('S') or without ('s') offsets. Where
25 this is used on a kernel without KALLSYMS - the symbol address is
26 printed instead.
27
28 The 'B' specifier results in the symbol name with offsets and should be
29 used when printing stack backtraces. The specifier takes into
30 consideration the effect of compiler optimisations which may occur
31 when tail-call's are used and marked with the noreturn GCC attribute.
32
33 On ia64, ppc64 and parisc64 architectures function pointers are
34 actually function descriptors which must first be resolved. The 'F' and
35 'f' specifiers perform this resolution and then provide the same
36 functionality as the 'S' and 's' specifiers.
37
38Kernel Pointers:
39
40 %pK 0x01234567 or 0x0123456789abcdef
41
42 For printing kernel pointers which should be hidden from unprivileged
43 users. The behaviour of %pK depends on the kptr_restrict sysctl - see
44 Documentation/sysctl/kernel.txt for more details.
45
46Struct Resources:
47
48 %pr [mem 0x60000000-0x6fffffff flags 0x2200] or
49 [mem 0x0000000060000000-0x000000006fffffff flags 0x2200]
50 %pR [mem 0x60000000-0x6fffffff pref] or
51 [mem 0x0000000060000000-0x000000006fffffff pref]
52
53 For printing struct resources. The 'R' and 'r' specifiers result in a
54 printed resource with ('R') or without ('r') a decoded flags member.
55
56MAC/FDDI addresses:
57
58 %pM 00:01:02:03:04:05
59 %pMF 00-01-02-03-04-05
60 %pm 000102030405
61
62 For printing 6-byte MAC/FDDI addresses in hex notation. The 'M' and 'm'
63 specifiers result in a printed address with ('M') or without ('m') byte
64 separators. The default byte separator is the colon (':').
65
66 Where FDDI addresses are concerned the 'F' specifier can be used after
67 the 'M' specifier to use dash ('-') separators instead of the default
68 separator.
69
70IPv4 addresses:
71
72 %pI4 1.2.3.4
73 %pi4 001.002.003.004
74 %p[Ii][hnbl]
75
76 For printing IPv4 dot-separated decimal addresses. The 'I4' and 'i4'
77 specifiers result in a printed address with ('i4') or without ('I4')
78 leading zeros.
79
80 The additional 'h', 'n', 'b', and 'l' specifiers are used to specify
81 host, network, big or little endian order addresses respectively. Where
82 no specifier is provided the default network/big endian order is used.
83
84IPv6 addresses:
85
86 %pI6 0001:0002:0003:0004:0005:0006:0007:0008
87 %pi6 00010002000300040005000600070008
88 %pI6c 1:2:3:4:5:6:7:8
89
90 For printing IPv6 network-order 16-bit hex addresses. The 'I6' and 'i6'
91 specifiers result in a printed address with ('I6') or without ('i6')
92 colon-separators. Leading zeros are always used.
93
94 The additional 'c' specifier can be used with the 'I' specifier to
95 print a compressed IPv6 address as described by
96 http://tools.ietf.org/html/rfc5952
97
98UUID/GUID addresses:
99
100 %pUb 00010203-0405-0607-0809-0a0b0c0d0e0f
101 %pUB 00010203-0405-0607-0809-0A0B0C0D0E0F
102 %pUl 03020100-0504-0706-0809-0a0b0c0e0e0f
103 %pUL 03020100-0504-0706-0809-0A0B0C0E0E0F
104
105 For printing 16-byte UUID/GUIDs addresses. The additional 'l', 'L',
106 'b' and 'B' specifiers are used to specify a little endian order in
107 lower ('l') or upper case ('L') hex characters - and big endian order
108 in lower ('b') or upper case ('B') hex characters.
109
110 Where no additional specifiers are used the default little endian
111 order with lower case hex characters will be printed.
112
113struct va_format:
114
115 %pV
116
117 For printing struct va_format structures. These contain a format string
118 and va_list as follows:
119
120 struct va_format {
121 const char *fmt;
122 va_list *va;
123 };
124
125 Do not use this feature without some mechanism to verify the
126 correctness of the format string and va_list arguments.
13 127
14u64 SHOULD be printed with %llu/%llx, (unsigned long long): 128u64 SHOULD be printed with %llu/%llx, (unsigned long long):
15 129
@@ -32,4 +146,5 @@ Reminder: sizeof() result is of type size_t.
32Thank you for your cooperation and attention. 146Thank you for your cooperation and attention.
33 147
34 148
35By Randy Dunlap <rdunlap@xenotime.net> 149By Randy Dunlap <rdunlap@xenotime.net> and
150Andrew Murray <amurray@mpc-data.co.uk>
diff --git a/Documentation/scheduler/sched-design-CFS.txt b/Documentation/scheduler/sched-design-CFS.txt
index 99961993257a..91ecff07cede 100644
--- a/Documentation/scheduler/sched-design-CFS.txt
+++ b/Documentation/scheduler/sched-design-CFS.txt
@@ -223,9 +223,10 @@ When CONFIG_FAIR_GROUP_SCHED is defined, a "cpu.shares" file is created for each
223group created using the pseudo filesystem. See example steps below to create 223group created using the pseudo filesystem. See example steps below to create
224task groups and modify their CPU share using the "cgroups" pseudo filesystem. 224task groups and modify their CPU share using the "cgroups" pseudo filesystem.
225 225
226 # mkdir /dev/cpuctl 226 # mount -t tmpfs cgroup_root /sys/fs/cgroup
227 # mount -t cgroup -ocpu none /dev/cpuctl 227 # mkdir /sys/fs/cgroup/cpu
228 # cd /dev/cpuctl 228 # mount -t cgroup -ocpu none /sys/fs/cgroup/cpu
229 # cd /sys/fs/cgroup/cpu
229 230
230 # mkdir multimedia # create "multimedia" group of tasks 231 # mkdir multimedia # create "multimedia" group of tasks
231 # mkdir browser # create "browser" group of tasks 232 # mkdir browser # create "browser" group of tasks
diff --git a/Documentation/scheduler/sched-rt-group.txt b/Documentation/scheduler/sched-rt-group.txt
index 605b0d40329d..71b54d549987 100644
--- a/Documentation/scheduler/sched-rt-group.txt
+++ b/Documentation/scheduler/sched-rt-group.txt
@@ -129,9 +129,8 @@ priority!
129Enabling CONFIG_RT_GROUP_SCHED lets you explicitly allocate real 129Enabling CONFIG_RT_GROUP_SCHED lets you explicitly allocate real
130CPU bandwidth to task groups. 130CPU bandwidth to task groups.
131 131
132This uses the /cgroup virtual file system and 132This uses the cgroup virtual file system and "<cgroup>/cpu.rt_runtime_us"
133"/cgroup/<cgroup>/cpu.rt_runtime_us" to control the CPU time reserved for each 133to control the CPU time reserved for each control group.
134control group.
135 134
136For more information on working with control groups, you should read 135For more information on working with control groups, you should read
137Documentation/cgroups/cgroups.txt as well. 136Documentation/cgroups/cgroups.txt as well.
@@ -150,7 +149,7 @@ For now, this can be simplified to just the following (but see Future plans):
150=============== 149===============
151 150
152There is work in progress to make the scheduling period for each group 151There is work in progress to make the scheduling period for each group
153("/cgroup/<cgroup>/cpu.rt_period_us") configurable as well. 152("<cgroup>/cpu.rt_period_us") configurable as well.
154 153
155The constraint on the period is that a subgroup must have a smaller or 154The constraint on the period is that a subgroup must have a smaller or
156equal period to its parent. But realistically its not very useful _yet_ 155equal period to its parent. But realistically its not very useful _yet_
diff --git a/Documentation/vm/hwpoison.txt b/Documentation/vm/hwpoison.txt
index 12f9ba20ccb7..550068466605 100644
--- a/Documentation/vm/hwpoison.txt
+++ b/Documentation/vm/hwpoison.txt
@@ -129,12 +129,12 @@ Limit injection to pages owned by memgroup. Specified by inode number
129of the memcg. 129of the memcg.
130 130
131Example: 131Example:
132 mkdir /cgroup/hwpoison 132 mkdir /sys/fs/cgroup/mem/hwpoison
133 133
134 usemem -m 100 -s 1000 & 134 usemem -m 100 -s 1000 &
135 echo `jobs -p` > /cgroup/hwpoison/tasks 135 echo `jobs -p` > /sys/fs/cgroup/mem/hwpoison/tasks
136 136
137 memcg_ino=$(ls -id /cgroup/hwpoison | cut -f1 -d' ') 137 memcg_ino=$(ls -id /sys/fs/cgroup/mem/hwpoison | cut -f1 -d' ')
138 echo $memcg_ino > /debug/hwpoison/corrupt-filter-memcg 138 echo $memcg_ino > /debug/hwpoison/corrupt-filter-memcg
139 139
140 page-types -p `pidof init` --hwpoison # shall do nothing 140 page-types -p `pidof init` --hwpoison # shall do nothing
diff --git a/MAINTAINERS b/MAINTAINERS
index e50fc6eb99e0..502f2dd761eb 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1889,7 +1889,6 @@ L: cpufreq@vger.kernel.org
1889W: http://www.codemonkey.org.uk/projects/cpufreq/ 1889W: http://www.codemonkey.org.uk/projects/cpufreq/
1890T: git git://git.kernel.org/pub/scm/linux/kernel/git/davej/cpufreq.git 1890T: git git://git.kernel.org/pub/scm/linux/kernel/git/davej/cpufreq.git
1891S: Maintained 1891S: Maintained
1892F: arch/x86/kernel/cpu/cpufreq/
1893F: drivers/cpufreq/ 1892F: drivers/cpufreq/
1894F: include/linux/cpufreq.h 1893F: include/linux/cpufreq.h
1895 1894
@@ -3820,6 +3819,12 @@ S: Maintained
3820F: drivers/leds/ 3819F: drivers/leds/
3821F: include/linux/leds.h 3820F: include/linux/leds.h
3822 3821
3822LEGACY EEPROM DRIVER
3823M: Jean Delvare <khali@linux-fr.org>
3824S: Maintained
3825F: Documentation/misc-devices/eeprom
3826F: drivers/misc/eeprom/eeprom.c
3827
3823LEGO USB Tower driver 3828LEGO USB Tower driver
3824M: Juergen Stuber <starblue@users.sourceforge.net> 3829M: Juergen Stuber <starblue@users.sourceforge.net>
3825L: legousb-devel@lists.sourceforge.net 3830L: legousb-devel@lists.sourceforge.net
@@ -4145,7 +4150,7 @@ F: include/linux/mm.h
4145F: mm/ 4150F: mm/
4146 4151
4147MEMORY RESOURCE CONTROLLER 4152MEMORY RESOURCE CONTROLLER
4148M: Balbir Singh <balbir@linux.vnet.ibm.com> 4153M: Balbir Singh <bsingharora@gmail.com>
4149M: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> 4154M: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
4150M: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> 4155M: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
4151L: linux-mm@kvack.org 4156L: linux-mm@kvack.org
@@ -4890,7 +4895,7 @@ F: mm/percpu*.c
4890F: arch/*/include/asm/percpu.h 4895F: arch/*/include/asm/percpu.h
4891 4896
4892PER-TASK DELAY ACCOUNTING 4897PER-TASK DELAY ACCOUNTING
4893M: Balbir Singh <balbir@linux.vnet.ibm.com> 4898M: Balbir Singh <bsingharora@gmail.com>
4894S: Maintained 4899S: Maintained
4895F: include/linux/delayacct.h 4900F: include/linux/delayacct.h
4896F: kernel/delayacct.c 4901F: kernel/delayacct.c
@@ -6098,7 +6103,7 @@ F: include/target/
6098F: Documentation/target/ 6103F: Documentation/target/
6099 6104
6100TASKSTATS STATISTICS INTERFACE 6105TASKSTATS STATISTICS INTERFACE
6101M: Balbir Singh <balbir@linux.vnet.ibm.com> 6106M: Balbir Singh <bsingharora@gmail.com>
6102S: Maintained 6107S: Maintained
6103F: Documentation/accounting/taskstats* 6108F: Documentation/accounting/taskstats*
6104F: include/linux/taskstats* 6109F: include/linux/taskstats*
@@ -6458,7 +6463,7 @@ M: Jiri Kosina <jkosina@suse.cz>
6458L: linux-usb@vger.kernel.org 6463L: linux-usb@vger.kernel.org
6459T: git git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid.git 6464T: git git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid.git
6460S: Maintained 6465S: Maintained
6461F: Documentation/usb/hiddev.txt 6466F: Documentation/hid/hiddev.txt
6462F: drivers/hid/usbhid/ 6467F: drivers/hid/usbhid/
6463 6468
6464USB ISP116X DRIVER 6469USB ISP116X DRIVER
@@ -6717,6 +6722,14 @@ S: Maintained
6717F: Documentation/filesystems/vfat.txt 6722F: Documentation/filesystems/vfat.txt
6718F: fs/fat/ 6723F: fs/fat/
6719 6724
6725VIDEOBUF2 FRAMEWORK
6726M: Pawel Osciak <pawel@osciak.com>
6727M: Marek Szyprowski <m.szyprowski@samsung.com>
6728L: linux-media@vger.kernel.org
6729S: Maintained
6730F: drivers/media/video/videobuf2-*
6731F: include/media/videobuf2-*
6732
6720VIRTIO CONSOLE DRIVER 6733VIRTIO CONSOLE DRIVER
6721M: Amit Shah <amit.shah@redhat.com> 6734M: Amit Shah <amit.shah@redhat.com>
6722L: virtualization@lists.linux-foundation.org 6735L: virtualization@lists.linux-foundation.org
diff --git a/Makefile b/Makefile
index badb9239e2bb..0499c2ee8541 100644
--- a/Makefile
+++ b/Makefile
@@ -1526,7 +1526,8 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))
1526 1526
1527# Run depmod only if we have System.map and depmod is executable 1527# Run depmod only if we have System.map and depmod is executable
1528quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) 1528quiet_cmd_depmod = DEPMOD $(KERNELRELEASE)
1529 cmd_depmod = $(srctree)/scripts/depmod.sh $(DEPMOD) $(KERNELRELEASE) 1529 cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \
1530 $(KERNELRELEASE)
1530 1531
1531# Create temporary dir for module support files 1532# Create temporary dir for module support files
1532# clean it up only when building all modules 1533# clean it up only when building all modules
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index 376f22130791..326f0a2d56e5 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -409,7 +409,7 @@ SYSCALL_DEFINE2(osf_getdomainname, char __user *, name, int, namelen)
409 return -EFAULT; 409 return -EFAULT;
410 410
411 len = namelen; 411 len = namelen;
412 if (namelen > 32) 412 if (len > 32)
413 len = 32; 413 len = 32;
414 414
415 down_read(&uts_sem); 415 down_read(&uts_sem);
@@ -594,7 +594,7 @@ SYSCALL_DEFINE3(osf_sysinfo, int, command, char __user *, buf, long, count)
594 down_read(&uts_sem); 594 down_read(&uts_sem);
595 res = sysinfo_table[offset]; 595 res = sysinfo_table[offset];
596 len = strlen(res)+1; 596 len = strlen(res)+1;
597 if (len > count) 597 if ((unsigned long)len > (unsigned long)count)
598 len = count; 598 len = count;
599 if (copy_to_user(buf, res, len)) 599 if (copy_to_user(buf, res, len))
600 err = -EFAULT; 600 err = -EFAULT;
@@ -649,7 +649,7 @@ SYSCALL_DEFINE5(osf_getsysinfo, unsigned long, op, void __user *, buffer,
649 return 1; 649 return 1;
650 650
651 case GSI_GET_HWRPB: 651 case GSI_GET_HWRPB:
652 if (nbytes < sizeof(*hwrpb)) 652 if (nbytes > sizeof(*hwrpb))
653 return -EINVAL; 653 return -EINVAL;
654 if (copy_to_user(buffer, hwrpb, nbytes) != 0) 654 if (copy_to_user(buffer, hwrpb, nbytes) != 0)
655 return -EFAULT; 655 return -EFAULT;
@@ -1008,6 +1008,7 @@ SYSCALL_DEFINE4(osf_wait4, pid_t, pid, int __user *, ustatus, int, options,
1008{ 1008{
1009 struct rusage r; 1009 struct rusage r;
1010 long ret, err; 1010 long ret, err;
1011 unsigned int status = 0;
1011 mm_segment_t old_fs; 1012 mm_segment_t old_fs;
1012 1013
1013 if (!ur) 1014 if (!ur)
@@ -1016,13 +1017,15 @@ SYSCALL_DEFINE4(osf_wait4, pid_t, pid, int __user *, ustatus, int, options,
1016 old_fs = get_fs(); 1017 old_fs = get_fs();
1017 1018
1018 set_fs (KERNEL_DS); 1019 set_fs (KERNEL_DS);
1019 ret = sys_wait4(pid, ustatus, options, (struct rusage __user *) &r); 1020 ret = sys_wait4(pid, (unsigned int __user *) &status, options,
1021 (struct rusage __user *) &r);
1020 set_fs (old_fs); 1022 set_fs (old_fs);
1021 1023
1022 if (!access_ok(VERIFY_WRITE, ur, sizeof(*ur))) 1024 if (!access_ok(VERIFY_WRITE, ur, sizeof(*ur)))
1023 return -EFAULT; 1025 return -EFAULT;
1024 1026
1025 err = 0; 1027 err = 0;
1028 err |= put_user(status, ustatus);
1026 err |= __put_user(r.ru_utime.tv_sec, &ur->ru_utime.tv_sec); 1029 err |= __put_user(r.ru_utime.tv_sec, &ur->ru_utime.tv_sec);
1027 err |= __put_user(r.ru_utime.tv_usec, &ur->ru_utime.tv_usec); 1030 err |= __put_user(r.ru_utime.tv_usec, &ur->ru_utime.tv_usec);
1028 err |= __put_user(r.ru_stime.tv_sec, &ur->ru_stime.tv_sec); 1031 err |= __put_user(r.ru_stime.tv_sec, &ur->ru_stime.tv_sec);
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index f9da41921c52..942fad97e447 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -691,9 +691,9 @@ proc_types:
691 691
692 .word 0x41069260 @ ARM926EJ-S (v5TEJ) 692 .word 0x41069260 @ ARM926EJ-S (v5TEJ)
693 .word 0xff0ffff0 693 .word 0xff0ffff0
694 b __arm926ejs_mmu_cache_on 694 W(b) __arm926ejs_mmu_cache_on
695 b __armv4_mmu_cache_off 695 W(b) __armv4_mmu_cache_off
696 b __armv5tej_mmu_cache_flush 696 W(b) __armv5tej_mmu_cache_flush
697 697
698 .word 0x00007000 @ ARM7 IDs 698 .word 0x00007000 @ ARM7 IDs
699 .word 0x0000f000 699 .word 0x0000f000
diff --git a/arch/arm/configs/davinci_all_defconfig b/arch/arm/configs/davinci_all_defconfig
index 889922ad229c..67b5abb6f857 100644
--- a/arch/arm/configs/davinci_all_defconfig
+++ b/arch/arm/configs/davinci_all_defconfig
@@ -157,7 +157,7 @@ CONFIG_LEDS_GPIO=m
157CONFIG_LEDS_TRIGGERS=y 157CONFIG_LEDS_TRIGGERS=y
158CONFIG_LEDS_TRIGGER_TIMER=m 158CONFIG_LEDS_TRIGGER_TIMER=m
159CONFIG_LEDS_TRIGGER_HEARTBEAT=m 159CONFIG_LEDS_TRIGGER_HEARTBEAT=m
160CONFIG_RTC_CLASS=m 160CONFIG_RTC_CLASS=y
161CONFIG_EXT2_FS=y 161CONFIG_EXT2_FS=y
162CONFIG_EXT3_FS=y 162CONFIG_EXT3_FS=y
163CONFIG_XFS_FS=m 163CONFIG_XFS_FS=m
diff --git a/arch/arm/configs/netx_defconfig b/arch/arm/configs/netx_defconfig
index 316af5479d90..9c0ad7993986 100644
--- a/arch/arm/configs/netx_defconfig
+++ b/arch/arm/configs/netx_defconfig
@@ -60,7 +60,7 @@ CONFIG_FB_ARMCLCD=y
60# CONFIG_VGA_CONSOLE is not set 60# CONFIG_VGA_CONSOLE is not set
61CONFIG_FRAMEBUFFER_CONSOLE=y 61CONFIG_FRAMEBUFFER_CONSOLE=y
62CONFIG_LOGO=y 62CONFIG_LOGO=y
63CONFIG_RTC_CLASS=m 63CONFIG_RTC_CLASS=y
64CONFIG_INOTIFY=y 64CONFIG_INOTIFY=y
65CONFIG_TMPFS=y 65CONFIG_TMPFS=y
66CONFIG_JFFS2_FS=y 66CONFIG_JFFS2_FS=y
diff --git a/arch/arm/configs/viper_defconfig b/arch/arm/configs/viper_defconfig
index 8b0c717378fa..1d01ddd33122 100644
--- a/arch/arm/configs/viper_defconfig
+++ b/arch/arm/configs/viper_defconfig
@@ -142,7 +142,7 @@ CONFIG_USB_GADGETFS=m
142CONFIG_USB_FILE_STORAGE=m 142CONFIG_USB_FILE_STORAGE=m
143CONFIG_USB_G_SERIAL=m 143CONFIG_USB_G_SERIAL=m
144CONFIG_USB_G_PRINTER=m 144CONFIG_USB_G_PRINTER=m
145CONFIG_RTC_CLASS=m 145CONFIG_RTC_CLASS=y
146CONFIG_RTC_DRV_DS1307=m 146CONFIG_RTC_DRV_DS1307=m
147CONFIG_RTC_DRV_SA1100=m 147CONFIG_RTC_DRV_SA1100=m
148CONFIG_EXT2_FS=m 148CONFIG_EXT2_FS=m
diff --git a/arch/arm/configs/xcep_defconfig b/arch/arm/configs/xcep_defconfig
index 5b5504143647..721832ffe2d7 100644
--- a/arch/arm/configs/xcep_defconfig
+++ b/arch/arm/configs/xcep_defconfig
@@ -73,7 +73,7 @@ CONFIG_SENSORS_MAX6650=m
73# CONFIG_VGA_CONSOLE is not set 73# CONFIG_VGA_CONSOLE is not set
74# CONFIG_HID_SUPPORT is not set 74# CONFIG_HID_SUPPORT is not set
75# CONFIG_USB_SUPPORT is not set 75# CONFIG_USB_SUPPORT is not set
76CONFIG_RTC_CLASS=m 76CONFIG_RTC_CLASS=y
77CONFIG_RTC_DRV_SA1100=m 77CONFIG_RTC_DRV_SA1100=m
78CONFIG_DMADEVICES=y 78CONFIG_DMADEVICES=y
79# CONFIG_DNOTIFY is not set 79# CONFIG_DNOTIFY is not set
diff --git a/arch/arm/configs/zeus_defconfig b/arch/arm/configs/zeus_defconfig
index 960f65514d88..59577ad3f4ef 100644
--- a/arch/arm/configs/zeus_defconfig
+++ b/arch/arm/configs/zeus_defconfig
@@ -158,7 +158,7 @@ CONFIG_LEDS_TRIGGER_HEARTBEAT=m
158CONFIG_LEDS_TRIGGER_BACKLIGHT=m 158CONFIG_LEDS_TRIGGER_BACKLIGHT=m
159CONFIG_LEDS_TRIGGER_GPIO=m 159CONFIG_LEDS_TRIGGER_GPIO=m
160CONFIG_LEDS_TRIGGER_DEFAULT_ON=m 160CONFIG_LEDS_TRIGGER_DEFAULT_ON=m
161CONFIG_RTC_CLASS=m 161CONFIG_RTC_CLASS=y
162CONFIG_RTC_DRV_ISL1208=m 162CONFIG_RTC_DRV_ISL1208=m
163CONFIG_RTC_DRV_PXA=m 163CONFIG_RTC_DRV_PXA=m
164CONFIG_EXT2_FS=y 164CONFIG_EXT2_FS=y
diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
index a701e4226a6c..0cdd7b456cb2 100644
--- a/arch/arm/kernel/devtree.c
+++ b/arch/arm/kernel/devtree.c
@@ -76,6 +76,9 @@ struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys)
76 unsigned long dt_root; 76 unsigned long dt_root;
77 const char *model; 77 const char *model;
78 78
79 if (!dt_phys)
80 return NULL;
81
79 devtree = phys_to_virt(dt_phys); 82 devtree = phys_to_virt(dt_phys);
80 83
81 /* check device tree validity */ 84 /* check device tree validity */
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index e8d885676807..90c62cd51ca9 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -435,6 +435,10 @@ __irq_usr:
435 usr_entry 435 usr_entry
436 kuser_cmpxchg_check 436 kuser_cmpxchg_check
437 437
438#ifdef CONFIG_IRQSOFF_TRACER
439 bl trace_hardirqs_off
440#endif
441
438 get_thread_info tsk 442 get_thread_info tsk
439#ifdef CONFIG_PREEMPT 443#ifdef CONFIG_PREEMPT
440 ldr r8, [tsk, #TI_PREEMPT] @ get preempt count 444 ldr r8, [tsk, #TI_PREEMPT] @ get preempt count
@@ -453,7 +457,7 @@ __irq_usr:
453#endif 457#endif
454 458
455 mov why, #0 459 mov why, #0
456 b ret_to_user 460 b ret_to_user_from_irq
457 UNWIND(.fnend ) 461 UNWIND(.fnend )
458ENDPROC(__irq_usr) 462ENDPROC(__irq_usr)
459 463
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index 1e7b04a40a31..b2a27b6b0046 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -64,6 +64,7 @@ work_resched:
64ENTRY(ret_to_user) 64ENTRY(ret_to_user)
65ret_slow_syscall: 65ret_slow_syscall:
66 disable_irq @ disable interrupts 66 disable_irq @ disable interrupts
67ENTRY(ret_to_user_from_irq)
67 ldr r1, [tsk, #TI_FLAGS] 68 ldr r1, [tsk, #TI_FLAGS]
68 tst r1, #_TIF_WORK_MASK 69 tst r1, #_TIF_WORK_MASK
69 bne work_pending 70 bne work_pending
@@ -75,6 +76,7 @@ no_work_pending:
75 arch_ret_to_user r1, lr 76 arch_ret_to_user r1, lr
76 77
77 restore_user_regs fast = 0, offset = 0 78 restore_user_regs fast = 0, offset = 0
79ENDPROC(ret_to_user_from_irq)
78ENDPROC(ret_to_user) 80ENDPROC(ret_to_user)
79 81
80/* 82/*
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index d52eec268b47..6807cb1e76dd 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -139,7 +139,7 @@ static void dump_instr(const char *lvl, struct pt_regs *regs)
139 fs = get_fs(); 139 fs = get_fs();
140 set_fs(KERNEL_DS); 140 set_fs(KERNEL_DS);
141 141
142 for (i = -4; i < 1; i++) { 142 for (i = -4; i < 1 + !!thumb; i++) {
143 unsigned int val, bad; 143 unsigned int val, bad;
144 144
145 if (thumb) 145 if (thumb)
@@ -563,7 +563,7 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
563 if (!pmd_present(*pmd)) 563 if (!pmd_present(*pmd))
564 goto bad_access; 564 goto bad_access;
565 pte = pte_offset_map_lock(mm, pmd, addr, &ptl); 565 pte = pte_offset_map_lock(mm, pmd, addr, &ptl);
566 if (!pte_present(*pte) || !pte_dirty(*pte)) { 566 if (!pte_present(*pte) || !pte_write(*pte) || !pte_dirty(*pte)) {
567 pte_unmap_unlock(pte, ptl); 567 pte_unmap_unlock(pte, ptl);
568 goto bad_access; 568 goto bad_access;
569 } 569 }
diff --git a/arch/arm/mach-davinci/devices-da8xx.c b/arch/arm/mach-davinci/devices-da8xx.c
index 4e66881c7aee..fc4e98ea7543 100644
--- a/arch/arm/mach-davinci/devices-da8xx.c
+++ b/arch/arm/mach-davinci/devices-da8xx.c
@@ -494,7 +494,7 @@ static struct platform_device da850_mcasp_device = {
494 .resource = da850_mcasp_resources, 494 .resource = da850_mcasp_resources,
495}; 495};
496 496
497struct platform_device davinci_pcm_device = { 497static struct platform_device davinci_pcm_device = {
498 .name = "davinci-pcm-audio", 498 .name = "davinci-pcm-audio",
499 .id = -1, 499 .id = -1,
500}; 500};
diff --git a/arch/arm/mach-davinci/devices.c b/arch/arm/mach-davinci/devices.c
index 8f4f736aa267..806a2f02b980 100644
--- a/arch/arm/mach-davinci/devices.c
+++ b/arch/arm/mach-davinci/devices.c
@@ -298,7 +298,7 @@ static void davinci_init_wdt(void)
298 298
299/*-------------------------------------------------------------------------*/ 299/*-------------------------------------------------------------------------*/
300 300
301struct platform_device davinci_pcm_device = { 301static struct platform_device davinci_pcm_device = {
302 .name = "davinci-pcm-audio", 302 .name = "davinci-pcm-audio",
303 .id = -1, 303 .id = -1,
304}; 304};
diff --git a/arch/arm/mach-davinci/gpio.c b/arch/arm/mach-davinci/gpio.c
index a0b838894ac9..e7221398e5af 100644
--- a/arch/arm/mach-davinci/gpio.c
+++ b/arch/arm/mach-davinci/gpio.c
@@ -252,9 +252,11 @@ static struct irq_chip gpio_irqchip = {
252static void 252static void
253gpio_irq_handler(unsigned irq, struct irq_desc *desc) 253gpio_irq_handler(unsigned irq, struct irq_desc *desc)
254{ 254{
255 struct davinci_gpio_regs __iomem *g = irq2regs(irq); 255 struct davinci_gpio_regs __iomem *g;
256 u32 mask = 0xffff; 256 u32 mask = 0xffff;
257 257
258 g = (__force struct davinci_gpio_regs __iomem *) irq_desc_get_handler_data(desc);
259
258 /* we only care about one bank */ 260 /* we only care about one bank */
259 if (irq & 1) 261 if (irq & 1)
260 mask <<= 16; 262 mask <<= 16;
@@ -422,8 +424,7 @@ static int __init davinci_gpio_irq_setup(void)
422 424
423 /* set up all irqs in this bank */ 425 /* set up all irqs in this bank */
424 irq_set_chained_handler(bank_irq, gpio_irq_handler); 426 irq_set_chained_handler(bank_irq, gpio_irq_handler);
425 irq_set_chip_data(bank_irq, (__force void *)g); 427 irq_set_handler_data(bank_irq, (__force void *)g);
426 irq_set_handler_data(bank_irq, (void *)irq);
427 428
428 for (i = 0; i < 16 && gpio < ngpio; i++, irq++, gpio++) { 429 for (i = 0; i < 16 && gpio < ngpio; i++, irq++, gpio++) {
429 irq_set_chip(irq, &gpio_irqchip); 430 irq_set_chip(irq, &gpio_irqchip);
diff --git a/arch/arm/mach-footbridge/dc21285-timer.c b/arch/arm/mach-footbridge/dc21285-timer.c
index 5f1f9867fc70..121ad1d4fa39 100644
--- a/arch/arm/mach-footbridge/dc21285-timer.c
+++ b/arch/arm/mach-footbridge/dc21285-timer.c
@@ -103,6 +103,7 @@ static void __init footbridge_timer_init(void)
103 clockevents_calc_mult_shift(ce, mem_fclk_21285, 5); 103 clockevents_calc_mult_shift(ce, mem_fclk_21285, 5);
104 ce->max_delta_ns = clockevent_delta2ns(0xffffff, ce); 104 ce->max_delta_ns = clockevent_delta2ns(0xffffff, ce);
105 ce->min_delta_ns = clockevent_delta2ns(0x000004, ce); 105 ce->min_delta_ns = clockevent_delta2ns(0x000004, ce);
106 ce->cpumask = cpumask_of(smp_processor_id());
106 107
107 clockevents_register_device(ce); 108 clockevents_register_device(ce);
108} 109}
diff --git a/arch/arm/mach-footbridge/include/mach/debug-macro.S b/arch/arm/mach-footbridge/include/mach/debug-macro.S
index 30b971d65815..1be2eeb7a0a0 100644
--- a/arch/arm/mach-footbridge/include/mach/debug-macro.S
+++ b/arch/arm/mach-footbridge/include/mach/debug-macro.S
@@ -26,6 +26,7 @@
26#include <asm/hardware/debug-8250.S> 26#include <asm/hardware/debug-8250.S>
27 27
28#else 28#else
29#include <mach/hardware.h>
29 /* For EBSA285 debugging */ 30 /* For EBSA285 debugging */
30 .equ dc21285_high, ARMCSR_BASE & 0xff000000 31 .equ dc21285_high, ARMCSR_BASE & 0xff000000
31 .equ dc21285_low, ARMCSR_BASE & 0x00ffffff 32 .equ dc21285_low, ARMCSR_BASE & 0x00ffffff
@@ -36,8 +37,8 @@
36 .else 37 .else
37 mov \rp, #0 38 mov \rp, #0
38 .endif 39 .endif
39 orr \rv, \rp, #0x42000000 40 orr \rv, \rp, #dc21285_high
40 orr \rp, \rp, #dc21285_high 41 orr \rp, \rp, #0x42000000
41 .endm 42 .endm
42 43
43 .macro senduart,rd,rx 44 .macro senduart,rd,rx
diff --git a/arch/arm/mach-mxs/ocotp.c b/arch/arm/mach-mxs/ocotp.c
index 65157a35dbba..54add60f94c9 100644
--- a/arch/arm/mach-mxs/ocotp.c
+++ b/arch/arm/mach-mxs/ocotp.c
@@ -16,6 +16,8 @@
16#include <linux/err.h> 16#include <linux/err.h>
17#include <linux/mutex.h> 17#include <linux/mutex.h>
18 18
19#include <asm/processor.h> /* for cpu_relax() */
20
19#include <mach/mxs.h> 21#include <mach/mxs.h>
20 22
21#define OCOTP_WORD_OFFSET 0x20 23#define OCOTP_WORD_OFFSET 0x20
diff --git a/arch/arm/mach-omap1/Makefile b/arch/arm/mach-omap1/Makefile
index af98117043d2..5b114d1558c8 100644
--- a/arch/arm/mach-omap1/Makefile
+++ b/arch/arm/mach-omap1/Makefile
@@ -4,14 +4,14 @@
4 4
5# Common support 5# Common support
6obj-y := io.o id.o sram.o time.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 reset.o 7obj-y += clock.o clock_data.o opp_data.o reset.o pm_bus.o
8 8
9obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o 9obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
10 10
11obj-$(CONFIG_OMAP_32K_TIMER) += timer32k.o 11obj-$(CONFIG_OMAP_32K_TIMER) += timer32k.o
12 12
13# Power Management 13# Power Management
14obj-$(CONFIG_PM) += pm.o sleep.o pm_bus.o 14obj-$(CONFIG_PM) += pm.o sleep.o
15 15
16# DSP 16# DSP
17obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox_mach.o 17obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox_mach.o
diff --git a/arch/arm/mach-omap1/pm_bus.c b/arch/arm/mach-omap1/pm_bus.c
index fe31d933f0ed..334fb8871bc3 100644
--- a/arch/arm/mach-omap1/pm_bus.c
+++ b/arch/arm/mach-omap1/pm_bus.c
@@ -56,9 +56,13 @@ static struct dev_power_domain default_power_domain = {
56 USE_PLATFORM_PM_SLEEP_OPS 56 USE_PLATFORM_PM_SLEEP_OPS
57 }, 57 },
58}; 58};
59#define OMAP1_PWR_DOMAIN (&default_power_domain)
60#else
61#define OMAP1_PWR_DOMAIN NULL
62#endif /* CONFIG_PM_RUNTIME */
59 63
60static struct pm_clk_notifier_block platform_bus_notifier = { 64static struct pm_clk_notifier_block platform_bus_notifier = {
61 .pwr_domain = &default_power_domain, 65 .pwr_domain = OMAP1_PWR_DOMAIN,
62 .con_ids = { "ick", "fck", NULL, }, 66 .con_ids = { "ick", "fck", NULL, },
63}; 67};
64 68
@@ -72,4 +76,4 @@ static int __init omap1_pm_runtime_init(void)
72 return 0; 76 return 0;
73} 77}
74core_initcall(omap1_pm_runtime_init); 78core_initcall(omap1_pm_runtime_init);
75#endif /* CONFIG_PM_RUNTIME */ 79
diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
index 2a0bb4818cae..23f71d40883e 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -84,7 +84,8 @@ static struct mtd_partition omap3pandora_nand_partitions[] = {
84 84
85static struct omap_nand_platform_data pandora_nand_data = { 85static struct omap_nand_platform_data pandora_nand_data = {
86 .cs = 0, 86 .cs = 0,
87 .devsize = 1, /* '0' for 8-bit, '1' for 16-bit device */ 87 .devsize = NAND_BUSWIDTH_16,
88 .xfer_type = NAND_OMAP_PREFETCH_DMA,
88 .parts = omap3pandora_nand_partitions, 89 .parts = omap3pandora_nand_partitions,
89 .nr_parts = ARRAY_SIZE(omap3pandora_nand_partitions), 90 .nr_parts = ARRAY_SIZE(omap3pandora_nand_partitions),
90}; 91};
diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c
index a5a83b358ddd..e01da45c0537 100644
--- a/arch/arm/mach-omap2/pm-debug.c
+++ b/arch/arm/mach-omap2/pm-debug.c
@@ -189,7 +189,7 @@ static struct dentry *pm_dbg_dir;
189 189
190static int pm_dbg_init_done; 190static int pm_dbg_init_done;
191 191
192static int __init pm_dbg_init(void); 192static int pm_dbg_init(void);
193 193
194enum { 194enum {
195 DEBUG_FILE_COUNTERS = 0, 195 DEBUG_FILE_COUNTERS = 0,
@@ -595,7 +595,7 @@ static int option_set(void *data, u64 val)
595 595
596DEFINE_SIMPLE_ATTRIBUTE(pm_dbg_option_fops, option_get, option_set, "%llu\n"); 596DEFINE_SIMPLE_ATTRIBUTE(pm_dbg_option_fops, option_get, option_set, "%llu\n");
597 597
598static int __init pm_dbg_init(void) 598static int pm_dbg_init(void)
599{ 599{
600 int i; 600 int i;
601 struct dentry *d; 601 struct dentry *d;
diff --git a/arch/arm/mach-pxa/spitz_pm.c b/arch/arm/mach-pxa/spitz_pm.c
index 7fe74067d85f..094279aefe9c 100644
--- a/arch/arm/mach-pxa/spitz_pm.c
+++ b/arch/arm/mach-pxa/spitz_pm.c
@@ -14,6 +14,7 @@
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/gpio.h>
17#include <linux/interrupt.h> 18#include <linux/interrupt.h>
18#include <linux/platform_device.h> 19#include <linux/platform_device.h>
19#include <linux/apm-emulation.h> 20#include <linux/apm-emulation.h>
diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c
index c95258c274c1..1e2aba23e0d6 100644
--- a/arch/arm/mach-shmobile/board-ag5evm.c
+++ b/arch/arm/mach-shmobile/board-ag5evm.c
@@ -382,10 +382,8 @@ void ag5evm_sdhi1_set_pwr(struct platform_device *pdev, int state)
382} 382}
383 383
384static struct sh_mobile_sdhi_info sh_sdhi1_platdata = { 384static struct sh_mobile_sdhi_info sh_sdhi1_platdata = {
385 .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
386 .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
387 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE, 385 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
388 .tmio_caps = MMC_CAP_NONREMOVABLE, 386 .tmio_caps = MMC_CAP_NONREMOVABLE | MMC_CAP_SDIO_IRQ,
389 .tmio_ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, 387 .tmio_ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
390 .set_pwr = ag5evm_sdhi1_set_pwr, 388 .set_pwr = ag5evm_sdhi1_set_pwr,
391}; 389};
diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c
index 776f20560e72..7e1d37584321 100644
--- a/arch/arm/mach-shmobile/board-mackerel.c
+++ b/arch/arm/mach-shmobile/board-mackerel.c
@@ -126,7 +126,7 @@
126 * ------+--------------------+--------------------+------- 126 * ------+--------------------+--------------------+-------
127 * IRQ0 | ICR1A.IRQ0SA=0010 | SDHI2 card detect | Low 127 * IRQ0 | ICR1A.IRQ0SA=0010 | SDHI2 card detect | Low
128 * IRQ6 | ICR1A.IRQ6SA=0011 | Ether(LAN9220) | High 128 * IRQ6 | ICR1A.IRQ6SA=0011 | Ether(LAN9220) | High
129 * IRQ7 | ICR1A.IRQ7SA=0010 | LCD Tuch Panel | Low 129 * IRQ7 | ICR1A.IRQ7SA=0010 | LCD Touch Panel | Low
130 * IRQ8 | ICR2A.IRQ8SA=0010 | MMC/SD card detect | Low 130 * IRQ8 | ICR2A.IRQ8SA=0010 | MMC/SD card detect | Low
131 * IRQ9 | ICR2A.IRQ9SA=0010 | KEY(TCA6408) | Low 131 * IRQ9 | ICR2A.IRQ9SA=0010 | KEY(TCA6408) | Low
132 * IRQ21 | ICR4A.IRQ21SA=0011 | Sensor(ADXL345) | High 132 * IRQ21 | ICR4A.IRQ21SA=0011 | Sensor(ADXL345) | High
@@ -165,10 +165,10 @@
165 * USB1 can become Host by r8a66597, and become Function by renesas_usbhs. 165 * USB1 can become Host by r8a66597, and become Function by renesas_usbhs.
166 * But don't select both drivers in same time. 166 * But don't select both drivers in same time.
167 * These uses same IRQ number for request_irq(), and aren't supporting 167 * These uses same IRQ number for request_irq(), and aren't supporting
168 * IRQF_SHARD / IORESOURCE_IRQ_SHAREABLE. 168 * IRQF_SHARED / IORESOURCE_IRQ_SHAREABLE.
169 * 169 *
170 * Actually these are old/new version of USB driver. 170 * Actually these are old/new version of USB driver.
171 * This mean its register will be broken if it supports SHARD IRQ, 171 * This mean its register will be broken if it supports shared IRQ,
172 */ 172 */
173 173
174/* 174/*
@@ -562,7 +562,121 @@ out:
562 clk_put(hdmi_ick); 562 clk_put(hdmi_ick);
563} 563}
564 564
565/* USB1 (Host) */ 565/* USBHS0 is connected to CN22 which takes a USB Mini-B plug
566 *
567 * The sh7372 SoC has IRQ7 set aside for USBHS0 hotplug,
568 * but on this particular board IRQ7 is already used by
569 * the touch screen. This leaves us with software polling.
570 */
571#define USBHS0_POLL_INTERVAL (HZ * 5)
572
573struct usbhs_private {
574 unsigned int usbphyaddr;
575 unsigned int usbcrcaddr;
576 struct renesas_usbhs_platform_info info;
577 struct delayed_work work;
578 struct platform_device *pdev;
579};
580
581#define usbhs_get_priv(pdev) \
582 container_of(renesas_usbhs_get_info(pdev), \
583 struct usbhs_private, info)
584
585#define usbhs_is_connected(priv) \
586 (!((1 << 7) & __raw_readw(priv->usbcrcaddr)))
587
588static int usbhs_get_vbus(struct platform_device *pdev)
589{
590 return usbhs_is_connected(usbhs_get_priv(pdev));
591}
592
593static void usbhs_phy_reset(struct platform_device *pdev)
594{
595 struct usbhs_private *priv = usbhs_get_priv(pdev);
596
597 /* init phy */
598 __raw_writew(0x8a0a, priv->usbcrcaddr);
599}
600
601static int usbhs0_get_id(struct platform_device *pdev)
602{
603 return USBHS_GADGET;
604}
605
606static void usbhs0_work_function(struct work_struct *work)
607{
608 struct usbhs_private *priv = container_of(work, struct usbhs_private,
609 work.work);
610
611 renesas_usbhs_call_notify_hotplug(priv->pdev);
612 schedule_delayed_work(&priv->work, USBHS0_POLL_INTERVAL);
613}
614
615static int usbhs0_hardware_init(struct platform_device *pdev)
616{
617 struct usbhs_private *priv = usbhs_get_priv(pdev);
618
619 priv->pdev = pdev;
620 INIT_DELAYED_WORK(&priv->work, usbhs0_work_function);
621 schedule_delayed_work(&priv->work, USBHS0_POLL_INTERVAL);
622 return 0;
623}
624
625static void usbhs0_hardware_exit(struct platform_device *pdev)
626{
627 struct usbhs_private *priv = usbhs_get_priv(pdev);
628
629 cancel_delayed_work_sync(&priv->work);
630}
631
632static struct usbhs_private usbhs0_private = {
633 .usbcrcaddr = 0xe605810c, /* USBCR2 */
634 .info = {
635 .platform_callback = {
636 .hardware_init = usbhs0_hardware_init,
637 .hardware_exit = usbhs0_hardware_exit,
638 .phy_reset = usbhs_phy_reset,
639 .get_id = usbhs0_get_id,
640 .get_vbus = usbhs_get_vbus,
641 },
642 .driver_param = {
643 .buswait_bwait = 4,
644 },
645 },
646};
647
648static struct resource usbhs0_resources[] = {
649 [0] = {
650 .name = "USBHS0",
651 .start = 0xe6890000,
652 .end = 0xe68900e6 - 1,
653 .flags = IORESOURCE_MEM,
654 },
655 [1] = {
656 .start = evt2irq(0x1ca0) /* USB0_USB0I0 */,
657 .flags = IORESOURCE_IRQ,
658 },
659};
660
661static struct platform_device usbhs0_device = {
662 .name = "renesas_usbhs",
663 .id = 0,
664 .dev = {
665 .platform_data = &usbhs0_private.info,
666 },
667 .num_resources = ARRAY_SIZE(usbhs0_resources),
668 .resource = usbhs0_resources,
669};
670
671/* USBHS1 is connected to CN31 which takes a USB Mini-AB plug
672 *
673 * Use J30 to select between Host and Function. This setting
674 * can however not be detected by software. Hotplug of USBHS1
675 * is provided via IRQ8.
676 */
677#define IRQ8 evt2irq(0x0300)
678
679/* USBHS1 USB Host support via r8a66597_hcd */
566static void usb1_host_port_power(int port, int power) 680static void usb1_host_port_power(int port, int power)
567{ 681{
568 if (!power) /* only power-on is supported for now */ 682 if (!power) /* only power-on is supported for now */
@@ -579,9 +693,9 @@ static struct r8a66597_platdata usb1_host_data = {
579 693
580static struct resource usb1_host_resources[] = { 694static struct resource usb1_host_resources[] = {
581 [0] = { 695 [0] = {
582 .name = "USBHS", 696 .name = "USBHS1",
583 .start = 0xE68B0000, 697 .start = 0xe68b0000,
584 .end = 0xE68B00E6 - 1, 698 .end = 0xe68b00e6 - 1,
585 .flags = IORESOURCE_MEM, 699 .flags = IORESOURCE_MEM,
586 }, 700 },
587 [1] = { 701 [1] = {
@@ -602,37 +716,14 @@ static struct platform_device usb1_host_device = {
602 .resource = usb1_host_resources, 716 .resource = usb1_host_resources,
603}; 717};
604 718
605/* USB1 (Function) */ 719/* USBHS1 USB Function support via renesas_usbhs */
720
606#define USB_PHY_MODE (1 << 4) 721#define USB_PHY_MODE (1 << 4)
607#define USB_PHY_INT_EN ((1 << 3) | (1 << 2)) 722#define USB_PHY_INT_EN ((1 << 3) | (1 << 2))
608#define USB_PHY_ON (1 << 1) 723#define USB_PHY_ON (1 << 1)
609#define USB_PHY_OFF (1 << 0) 724#define USB_PHY_OFF (1 << 0)
610#define USB_PHY_INT_CLR (USB_PHY_ON | USB_PHY_OFF) 725#define USB_PHY_INT_CLR (USB_PHY_ON | USB_PHY_OFF)
611 726
612struct usbhs_private {
613 unsigned int irq;
614 unsigned int usbphyaddr;
615 unsigned int usbcrcaddr;
616 struct renesas_usbhs_platform_info info;
617};
618
619#define usbhs_get_priv(pdev) \
620 container_of(renesas_usbhs_get_info(pdev), \
621 struct usbhs_private, info)
622
623#define usbhs_is_connected(priv) \
624 (!((1 << 7) & __raw_readw(priv->usbcrcaddr)))
625
626static int usbhs1_get_id(struct platform_device *pdev)
627{
628 return USBHS_GADGET;
629}
630
631static int usbhs1_get_vbus(struct platform_device *pdev)
632{
633 return usbhs_is_connected(usbhs_get_priv(pdev));
634}
635
636static irqreturn_t usbhs1_interrupt(int irq, void *data) 727static irqreturn_t usbhs1_interrupt(int irq, void *data)
637{ 728{
638 struct platform_device *pdev = data; 729 struct platform_device *pdev = data;
@@ -654,12 +745,10 @@ static int usbhs1_hardware_init(struct platform_device *pdev)
654 struct usbhs_private *priv = usbhs_get_priv(pdev); 745 struct usbhs_private *priv = usbhs_get_priv(pdev);
655 int ret; 746 int ret;
656 747
657 irq_set_irq_type(priv->irq, IRQ_TYPE_LEVEL_HIGH);
658
659 /* clear interrupt status */ 748 /* clear interrupt status */
660 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->usbphyaddr); 749 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->usbphyaddr);
661 750
662 ret = request_irq(priv->irq, usbhs1_interrupt, 0, 751 ret = request_irq(IRQ8, usbhs1_interrupt, IRQF_TRIGGER_HIGH,
663 dev_name(&pdev->dev), pdev); 752 dev_name(&pdev->dev), pdev);
664 if (ret) { 753 if (ret) {
665 dev_err(&pdev->dev, "request_irq err\n"); 754 dev_err(&pdev->dev, "request_irq err\n");
@@ -679,15 +768,12 @@ static void usbhs1_hardware_exit(struct platform_device *pdev)
679 /* clear interrupt status */ 768 /* clear interrupt status */
680 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->usbphyaddr); 769 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->usbphyaddr);
681 770
682 free_irq(priv->irq, pdev); 771 free_irq(IRQ8, pdev);
683} 772}
684 773
685static void usbhs1_phy_reset(struct platform_device *pdev) 774static int usbhs1_get_id(struct platform_device *pdev)
686{ 775{
687 struct usbhs_private *priv = usbhs_get_priv(pdev); 776 return USBHS_GADGET;
688
689 /* init phy */
690 __raw_writew(0x8a0a, priv->usbcrcaddr);
691} 777}
692 778
693static u32 usbhs1_pipe_cfg[] = { 779static u32 usbhs1_pipe_cfg[] = {
@@ -710,16 +796,15 @@ static u32 usbhs1_pipe_cfg[] = {
710}; 796};
711 797
712static struct usbhs_private usbhs1_private = { 798static struct usbhs_private usbhs1_private = {
713 .irq = evt2irq(0x0300), /* IRQ8 */ 799 .usbphyaddr = 0xe60581e2, /* USBPHY1INTAP */
714 .usbphyaddr = 0xE60581E2, /* USBPHY1INTAP */ 800 .usbcrcaddr = 0xe6058130, /* USBCR4 */
715 .usbcrcaddr = 0xE6058130, /* USBCR4 */
716 .info = { 801 .info = {
717 .platform_callback = { 802 .platform_callback = {
718 .hardware_init = usbhs1_hardware_init, 803 .hardware_init = usbhs1_hardware_init,
719 .hardware_exit = usbhs1_hardware_exit, 804 .hardware_exit = usbhs1_hardware_exit,
720 .phy_reset = usbhs1_phy_reset,
721 .get_id = usbhs1_get_id, 805 .get_id = usbhs1_get_id,
722 .get_vbus = usbhs1_get_vbus, 806 .phy_reset = usbhs_phy_reset,
807 .get_vbus = usbhs_get_vbus,
723 }, 808 },
724 .driver_param = { 809 .driver_param = {
725 .buswait_bwait = 4, 810 .buswait_bwait = 4,
@@ -731,9 +816,9 @@ static struct usbhs_private usbhs1_private = {
731 816
732static struct resource usbhs1_resources[] = { 817static struct resource usbhs1_resources[] = {
733 [0] = { 818 [0] = {
734 .name = "USBHS", 819 .name = "USBHS1",
735 .start = 0xE68B0000, 820 .start = 0xe68b0000,
736 .end = 0xE68B00E6 - 1, 821 .end = 0xe68b00e6 - 1,
737 .flags = IORESOURCE_MEM, 822 .flags = IORESOURCE_MEM,
738 }, 823 },
739 [1] = { 824 [1] = {
@@ -752,7 +837,6 @@ static struct platform_device usbhs1_device = {
752 .resource = usbhs1_resources, 837 .resource = usbhs1_resources,
753}; 838};
754 839
755
756/* LED */ 840/* LED */
757static struct gpio_led mackerel_leds[] = { 841static struct gpio_led mackerel_leds[] = {
758 { 842 {
@@ -1203,6 +1287,7 @@ static struct platform_device *mackerel_devices[] __initdata = {
1203 &nor_flash_device, 1287 &nor_flash_device,
1204 &smc911x_device, 1288 &smc911x_device,
1205 &lcdc_device, 1289 &lcdc_device,
1290 &usbhs0_device,
1206 &usb1_host_device, 1291 &usb1_host_device,
1207 &usbhs1_device, 1292 &usbhs1_device,
1208 &leds_device, 1293 &leds_device,
@@ -1301,6 +1386,7 @@ static void __init mackerel_map_io(void)
1301 1386
1302#define GPIO_PORT9CR 0xE6051009 1387#define GPIO_PORT9CR 0xE6051009
1303#define GPIO_PORT10CR 0xE605100A 1388#define GPIO_PORT10CR 0xE605100A
1389#define GPIO_PORT167CR 0xE60520A7
1304#define GPIO_PORT168CR 0xE60520A8 1390#define GPIO_PORT168CR 0xE60520A8
1305#define SRCR4 0xe61580bc 1391#define SRCR4 0xe61580bc
1306#define USCCR1 0xE6058144 1392#define USCCR1 0xE6058144
@@ -1354,17 +1440,17 @@ static void __init mackerel_init(void)
1354 gpio_request(GPIO_PORT151, NULL); /* LCDDON */ 1440 gpio_request(GPIO_PORT151, NULL); /* LCDDON */
1355 gpio_direction_output(GPIO_PORT151, 1); 1441 gpio_direction_output(GPIO_PORT151, 1);
1356 1442
1357 /* USB enable */ 1443 /* USBHS0 */
1358 gpio_request(GPIO_FN_VBUS0_1, NULL); 1444 gpio_request(GPIO_FN_VBUS0_0, NULL);
1359 gpio_request(GPIO_FN_IDIN_1_18, NULL); 1445 gpio_pull_down(GPIO_PORT168CR); /* VBUS0_0 pull down */
1360 gpio_request(GPIO_FN_PWEN_1_115, NULL); 1446
1361 gpio_request(GPIO_FN_OVCN_1_114, NULL); 1447 /* USBHS1 */
1362 gpio_request(GPIO_FN_EXTLP_1, NULL); 1448 gpio_request(GPIO_FN_VBUS0_1, NULL);
1363 gpio_request(GPIO_FN_OVCN2_1, NULL); 1449 gpio_pull_down(GPIO_PORT167CR); /* VBUS0_1 pull down */
1364 gpio_pull_down(GPIO_PORT168CR); 1450 gpio_request(GPIO_FN_IDIN_1_113, NULL);
1365 1451
1366 /* setup USB phy */ 1452 /* USB phy tweak to make the r8a66597_hcd host driver work */
1367 __raw_writew(0x8a0a, 0xE6058130); /* USBCR4 */ 1453 __raw_writew(0x8a0a, 0xe6058130); /* USBCR4 */
1368 1454
1369 /* enable FSI2 port A (ak4643) */ 1455 /* enable FSI2 port A (ak4643) */
1370 gpio_request(GPIO_FN_FSIAIBT, NULL); 1456 gpio_request(GPIO_FN_FSIAIBT, NULL);
diff --git a/arch/arm/mach-shmobile/intc-sh73a0.c b/arch/arm/mach-shmobile/intc-sh73a0.c
index 5d0e1503ece6..a911a60e7719 100644
--- a/arch/arm/mach-shmobile/intc-sh73a0.c
+++ b/arch/arm/mach-shmobile/intc-sh73a0.c
@@ -250,6 +250,11 @@ static irqreturn_t sh73a0_intcs_demux(int irq, void *dev_id)
250 return IRQ_HANDLED; 250 return IRQ_HANDLED;
251} 251}
252 252
253static int sh73a0_set_wake(struct irq_data *data, unsigned int on)
254{
255 return 0; /* always allow wakeup */
256}
257
253void __init sh73a0_init_irq(void) 258void __init sh73a0_init_irq(void)
254{ 259{
255 void __iomem *gic_dist_base = __io(0xf0001000); 260 void __iomem *gic_dist_base = __io(0xf0001000);
@@ -257,6 +262,7 @@ void __init sh73a0_init_irq(void)
257 void __iomem *intevtsa = ioremap_nocache(0xffd20100, PAGE_SIZE); 262 void __iomem *intevtsa = ioremap_nocache(0xffd20100, PAGE_SIZE);
258 263
259 gic_init(0, 29, gic_dist_base, gic_cpu_base); 264 gic_init(0, 29, gic_dist_base, gic_cpu_base);
265 gic_arch_extn.irq_set_wake = sh73a0_set_wake;
260 266
261 register_intc_controller(&intcs_desc); 267 register_intc_controller(&intcs_desc);
262 268
diff --git a/arch/arm/mach-shmobile/setup-sh7367.c b/arch/arm/mach-shmobile/setup-sh7367.c
index 2c10190dbb55..e546017f15de 100644
--- a/arch/arm/mach-shmobile/setup-sh7367.c
+++ b/arch/arm/mach-shmobile/setup-sh7367.c
@@ -38,7 +38,7 @@ static struct plat_sci_port scif0_platform_data = {
38 .flags = UPF_BOOT_AUTOCONF, 38 .flags = UPF_BOOT_AUTOCONF,
39 .scscr = SCSCR_RE | SCSCR_TE, 39 .scscr = SCSCR_RE | SCSCR_TE,
40 .scbrr_algo_id = SCBRR_ALGO_4, 40 .scbrr_algo_id = SCBRR_ALGO_4,
41 .type = PORT_SCIF, 41 .type = PORT_SCIFA,
42 .irqs = { evt2irq(0xc00), evt2irq(0xc00), 42 .irqs = { evt2irq(0xc00), evt2irq(0xc00),
43 evt2irq(0xc00), evt2irq(0xc00) }, 43 evt2irq(0xc00), evt2irq(0xc00) },
44}; 44};
@@ -57,7 +57,7 @@ static struct plat_sci_port scif1_platform_data = {
57 .flags = UPF_BOOT_AUTOCONF, 57 .flags = UPF_BOOT_AUTOCONF,
58 .scscr = SCSCR_RE | SCSCR_TE, 58 .scscr = SCSCR_RE | SCSCR_TE,
59 .scbrr_algo_id = SCBRR_ALGO_4, 59 .scbrr_algo_id = SCBRR_ALGO_4,
60 .type = PORT_SCIF, 60 .type = PORT_SCIFA,
61 .irqs = { evt2irq(0xc20), evt2irq(0xc20), 61 .irqs = { evt2irq(0xc20), evt2irq(0xc20),
62 evt2irq(0xc20), evt2irq(0xc20) }, 62 evt2irq(0xc20), evt2irq(0xc20) },
63}; 63};
@@ -76,7 +76,7 @@ static struct plat_sci_port scif2_platform_data = {
76 .flags = UPF_BOOT_AUTOCONF, 76 .flags = UPF_BOOT_AUTOCONF,
77 .scscr = SCSCR_RE | SCSCR_TE, 77 .scscr = SCSCR_RE | SCSCR_TE,
78 .scbrr_algo_id = SCBRR_ALGO_4, 78 .scbrr_algo_id = SCBRR_ALGO_4,
79 .type = PORT_SCIF, 79 .type = PORT_SCIFA,
80 .irqs = { evt2irq(0xc40), evt2irq(0xc40), 80 .irqs = { evt2irq(0xc40), evt2irq(0xc40),
81 evt2irq(0xc40), evt2irq(0xc40) }, 81 evt2irq(0xc40), evt2irq(0xc40) },
82}; 82};
@@ -95,7 +95,7 @@ static struct plat_sci_port scif3_platform_data = {
95 .flags = UPF_BOOT_AUTOCONF, 95 .flags = UPF_BOOT_AUTOCONF,
96 .scscr = SCSCR_RE | SCSCR_TE, 96 .scscr = SCSCR_RE | SCSCR_TE,
97 .scbrr_algo_id = SCBRR_ALGO_4, 97 .scbrr_algo_id = SCBRR_ALGO_4,
98 .type = PORT_SCIF, 98 .type = PORT_SCIFA,
99 .irqs = { evt2irq(0xc60), evt2irq(0xc60), 99 .irqs = { evt2irq(0xc60), evt2irq(0xc60),
100 evt2irq(0xc60), evt2irq(0xc60) }, 100 evt2irq(0xc60), evt2irq(0xc60) },
101}; 101};
@@ -114,7 +114,7 @@ static struct plat_sci_port scif4_platform_data = {
114 .flags = UPF_BOOT_AUTOCONF, 114 .flags = UPF_BOOT_AUTOCONF,
115 .scscr = SCSCR_RE | SCSCR_TE, 115 .scscr = SCSCR_RE | SCSCR_TE,
116 .scbrr_algo_id = SCBRR_ALGO_4, 116 .scbrr_algo_id = SCBRR_ALGO_4,
117 .type = PORT_SCIF, 117 .type = PORT_SCIFA,
118 .irqs = { evt2irq(0xd20), evt2irq(0xd20), 118 .irqs = { evt2irq(0xd20), evt2irq(0xd20),
119 evt2irq(0xd20), evt2irq(0xd20) }, 119 evt2irq(0xd20), evt2irq(0xd20) },
120}; 120};
@@ -133,7 +133,7 @@ static struct plat_sci_port scif5_platform_data = {
133 .flags = UPF_BOOT_AUTOCONF, 133 .flags = UPF_BOOT_AUTOCONF,
134 .scscr = SCSCR_RE | SCSCR_TE, 134 .scscr = SCSCR_RE | SCSCR_TE,
135 .scbrr_algo_id = SCBRR_ALGO_4, 135 .scbrr_algo_id = SCBRR_ALGO_4,
136 .type = PORT_SCIF, 136 .type = PORT_SCIFA,
137 .irqs = { evt2irq(0xd40), evt2irq(0xd40), 137 .irqs = { evt2irq(0xd40), evt2irq(0xd40),
138 evt2irq(0xd40), evt2irq(0xd40) }, 138 evt2irq(0xd40), evt2irq(0xd40) },
139}; 139};
@@ -152,7 +152,7 @@ static struct plat_sci_port scif6_platform_data = {
152 .flags = UPF_BOOT_AUTOCONF, 152 .flags = UPF_BOOT_AUTOCONF,
153 .scscr = SCSCR_RE | SCSCR_TE, 153 .scscr = SCSCR_RE | SCSCR_TE,
154 .scbrr_algo_id = SCBRR_ALGO_4, 154 .scbrr_algo_id = SCBRR_ALGO_4,
155 .type = PORT_SCIF, 155 .type = PORT_SCIFB,
156 .irqs = { evt2irq(0xd60), evt2irq(0xd60), 156 .irqs = { evt2irq(0xd60), evt2irq(0xd60),
157 evt2irq(0xd60), evt2irq(0xd60) }, 157 evt2irq(0xd60), evt2irq(0xd60) },
158}; 158};
diff --git a/arch/arm/mach-u300/clock.h b/arch/arm/mach-u300/clock.h
index c34f3ea3017c..4f50ca8f901e 100644
--- a/arch/arm/mach-u300/clock.h
+++ b/arch/arm/mach-u300/clock.h
@@ -31,7 +31,7 @@ struct clk {
31 bool reset; 31 bool reset;
32 __u16 clk_val; 32 __u16 clk_val;
33 __s8 usecount; 33 __s8 usecount;
34 __u32 res_reg; 34 void __iomem * res_reg;
35 __u16 res_mask; 35 __u16 res_mask;
36 36
37 bool hw_ctrld; 37 bool hw_ctrld;
diff --git a/arch/arm/mach-u300/include/mach/u300-regs.h b/arch/arm/mach-u300/include/mach/u300-regs.h
index 8b85df4c8d8f..035fdc9dbdb0 100644
--- a/arch/arm/mach-u300/include/mach/u300-regs.h
+++ b/arch/arm/mach-u300/include/mach/u300-regs.h
@@ -18,6 +18,12 @@
18 * the defines are used for setting up the I/O memory mapping. 18 * the defines are used for setting up the I/O memory mapping.
19 */ 19 */
20 20
21#ifdef __ASSEMBLER__
22#define IOMEM(a) (a)
23#else
24#define IOMEM(a) (void __iomem *) a
25#endif
26
21/* NAND Flash CS0 */ 27/* NAND Flash CS0 */
22#define U300_NAND_CS0_PHYS_BASE 0x80000000 28#define U300_NAND_CS0_PHYS_BASE 0x80000000
23 29
@@ -48,13 +54,6 @@
48#endif 54#endif
49 55
50/* 56/*
51 * All the following peripherals are specified at their PHYSICAL address,
52 * so if you need to access them (in the kernel), you MUST use the macros
53 * defined in <asm/io.h> to map to the IO_ADDRESS_AHB() IO_ADDRESS_FAST()
54 * etc.
55 */
56
57/*
58 * AHB peripherals 57 * AHB peripherals
59 */ 58 */
60 59
@@ -63,11 +62,11 @@
63 62
64/* Vectored Interrupt Controller 0, servicing 32 interrupts */ 63/* Vectored Interrupt Controller 0, servicing 32 interrupts */
65#define U300_INTCON0_BASE (U300_AHB_PER_PHYS_BASE+0x1000) 64#define U300_INTCON0_BASE (U300_AHB_PER_PHYS_BASE+0x1000)
66#define U300_INTCON0_VBASE (U300_AHB_PER_VIRT_BASE+0x1000) 65#define U300_INTCON0_VBASE IOMEM(U300_AHB_PER_VIRT_BASE+0x1000)
67 66
68/* Vectored Interrupt Controller 1, servicing 32 interrupts */ 67/* Vectored Interrupt Controller 1, servicing 32 interrupts */
69#define U300_INTCON1_BASE (U300_AHB_PER_PHYS_BASE+0x2000) 68#define U300_INTCON1_BASE (U300_AHB_PER_PHYS_BASE+0x2000)
70#define U300_INTCON1_VBASE (U300_AHB_PER_VIRT_BASE+0x2000) 69#define U300_INTCON1_VBASE IOMEM(U300_AHB_PER_VIRT_BASE+0x2000)
71 70
72/* Memory Stick Pro (MSPRO) controller */ 71/* Memory Stick Pro (MSPRO) controller */
73#define U300_MSPRO_BASE (U300_AHB_PER_PHYS_BASE+0x3000) 72#define U300_MSPRO_BASE (U300_AHB_PER_PHYS_BASE+0x3000)
@@ -115,7 +114,7 @@
115 114
116/* SYSCON */ 115/* SYSCON */
117#define U300_SYSCON_BASE (U300_SLOW_PER_PHYS_BASE+0x1000) 116#define U300_SYSCON_BASE (U300_SLOW_PER_PHYS_BASE+0x1000)
118#define U300_SYSCON_VBASE (U300_SLOW_PER_VIRT_BASE+0x1000) 117#define U300_SYSCON_VBASE IOMEM(U300_SLOW_PER_VIRT_BASE+0x1000)
119 118
120/* Watchdog */ 119/* Watchdog */
121#define U300_WDOG_BASE (U300_SLOW_PER_PHYS_BASE+0x2000) 120#define U300_WDOG_BASE (U300_SLOW_PER_PHYS_BASE+0x2000)
@@ -125,7 +124,7 @@
125 124
126/* APP side special timer */ 125/* APP side special timer */
127#define U300_TIMER_APP_BASE (U300_SLOW_PER_PHYS_BASE+0x4000) 126#define U300_TIMER_APP_BASE (U300_SLOW_PER_PHYS_BASE+0x4000)
128#define U300_TIMER_APP_VBASE (U300_SLOW_PER_VIRT_BASE+0x4000) 127#define U300_TIMER_APP_VBASE IOMEM(U300_SLOW_PER_VIRT_BASE+0x4000)
129 128
130/* Keypad */ 129/* Keypad */
131#define U300_KEYPAD_BASE (U300_SLOW_PER_PHYS_BASE+0x5000) 130#define U300_KEYPAD_BASE (U300_SLOW_PER_PHYS_BASE+0x5000)
@@ -181,5 +180,4 @@
181 * Virtual accessor macros for static devices 180 * Virtual accessor macros for static devices
182 */ 181 */
183 182
184
185#endif 183#endif
diff --git a/arch/arm/mach-u300/timer.c b/arch/arm/mach-u300/timer.c
index 891cf44591e0..18d7fa0603c2 100644
--- a/arch/arm/mach-u300/timer.c
+++ b/arch/arm/mach-u300/timer.c
@@ -411,8 +411,7 @@ static void __init u300_timer_init(void)
411 /* Use general purpose timer 2 as clock source */ 411 /* Use general purpose timer 2 as clock source */
412 if (clocksource_mmio_init(U300_TIMER_APP_VBASE + U300_TIMER_APP_GPT2CC, 412 if (clocksource_mmio_init(U300_TIMER_APP_VBASE + U300_TIMER_APP_GPT2CC,
413 "GPT2", rate, 300, 32, clocksource_mmio_readl_up)) 413 "GPT2", rate, 300, 32, clocksource_mmio_readl_up))
414 printk(KERN_ERR "timer: failed to initialize clock " 414 pr_err("timer: failed to initialize U300 clock source\n");
415 "source %s\n", clocksource_u300_1mhz.name);
416 415
417 clockevents_calc_mult_shift(&clockevent_u300_1mhz, 416 clockevents_calc_mult_shift(&clockevent_u300_1mhz,
418 rate, APPTIMER_MIN_RANGE); 417 rate, APPTIMER_MIN_RANGE);
diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
index 285edcd2da2a..9e6b93b1a043 100644
--- a/arch/arm/mach-vexpress/v2m.c
+++ b/arch/arm/mach-vexpress/v2m.c
@@ -46,12 +46,6 @@ static struct map_desc v2m_io_desc[] __initdata = {
46 }, 46 },
47}; 47};
48 48
49static void __init v2m_init_early(void)
50{
51 ct_desc->init_early();
52 versatile_sched_clock_init(MMIO_P2V(V2M_SYS_24MHZ), 24000000);
53}
54
55static void __init v2m_timer_init(void) 49static void __init v2m_timer_init(void)
56{ 50{
57 u32 scctrl; 51 u32 scctrl;
@@ -365,6 +359,13 @@ static struct clk_lookup v2m_lookups[] = {
365 }, 359 },
366}; 360};
367 361
362static void __init v2m_init_early(void)
363{
364 ct_desc->init_early();
365 clkdev_add_table(v2m_lookups, ARRAY_SIZE(v2m_lookups));
366 versatile_sched_clock_init(MMIO_P2V(V2M_SYS_24MHZ), 24000000);
367}
368
368static void v2m_power_off(void) 369static void v2m_power_off(void)
369{ 370{
370 if (v2m_cfg_write(SYS_CFG_SHUTDOWN | SYS_CFG_SITE_MB, 0)) 371 if (v2m_cfg_write(SYS_CFG_SHUTDOWN | SYS_CFG_SITE_MB, 0))
@@ -418,8 +419,6 @@ static void __init v2m_init(void)
418{ 419{
419 int i; 420 int i;
420 421
421 clkdev_add_table(v2m_lookups, ARRAY_SIZE(v2m_lookups));
422
423 platform_device_register(&v2m_pcie_i2c_device); 422 platform_device_register(&v2m_pcie_i2c_device);
424 platform_device_register(&v2m_ddc_i2c_device); 423 platform_device_register(&v2m_ddc_i2c_device);
425 platform_device_register(&v2m_flash_device); 424 platform_device_register(&v2m_flash_device);
diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
index 8bfae964b133..b0ee9ba3cfab 100644
--- a/arch/arm/mm/context.c
+++ b/arch/arm/mm/context.c
@@ -24,7 +24,9 @@ DEFINE_PER_CPU(struct mm_struct *, current_mm);
24 24
25/* 25/*
26 * We fork()ed a process, and we need a new context for the child 26 * We fork()ed a process, and we need a new context for the child
27 * to run in. 27 * to run in. We reserve version 0 for initial tasks so we will
28 * always allocate an ASID. The ASID 0 is reserved for the TTBR
29 * register changing sequence.
28 */ 30 */
29void __init_new_context(struct task_struct *tsk, struct mm_struct *mm) 31void __init_new_context(struct task_struct *tsk, struct mm_struct *mm)
30{ 32{
@@ -34,11 +36,8 @@ void __init_new_context(struct task_struct *tsk, struct mm_struct *mm)
34 36
35static void flush_context(void) 37static void flush_context(void)
36{ 38{
37 u32 ttb; 39 /* set the reserved ASID before flushing the TLB */
38 /* Copy TTBR1 into TTBR0 */ 40 asm("mcr p15, 0, %0, c13, c0, 1\n" : : "r" (0));
39 asm volatile("mrc p15, 0, %0, c2, c0, 1\n"
40 "mcr p15, 0, %0, c2, c0, 0"
41 : "=r" (ttb));
42 isb(); 41 isb();
43 local_flush_tlb_all(); 42 local_flush_tlb_all();
44 if (icache_is_vivt_asid_tagged()) { 43 if (icache_is_vivt_asid_tagged()) {
@@ -94,7 +93,7 @@ static void reset_context(void *info)
94 return; 93 return;
95 94
96 smp_rmb(); 95 smp_rmb();
97 asid = cpu_last_asid + cpu; 96 asid = cpu_last_asid + cpu + 1;
98 97
99 flush_context(); 98 flush_context();
100 set_mm_context(mm, asid); 99 set_mm_context(mm, asid);
@@ -144,13 +143,13 @@ void __new_context(struct mm_struct *mm)
144 * to start a new version and flush the TLB. 143 * to start a new version and flush the TLB.
145 */ 144 */
146 if (unlikely((asid & ~ASID_MASK) == 0)) { 145 if (unlikely((asid & ~ASID_MASK) == 0)) {
147 asid = cpu_last_asid + smp_processor_id(); 146 asid = cpu_last_asid + smp_processor_id() + 1;
148 flush_context(); 147 flush_context();
149#ifdef CONFIG_SMP 148#ifdef CONFIG_SMP
150 smp_wmb(); 149 smp_wmb();
151 smp_call_function(reset_context, NULL, 1); 150 smp_call_function(reset_context, NULL, 1);
152#endif 151#endif
153 cpu_last_asid += NR_CPUS - 1; 152 cpu_last_asid += NR_CPUS;
154 } 153 }
155 154
156 set_mm_context(mm, asid); 155 set_mm_context(mm, asid);
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 2c2cce9cd8c8..c19571c40a21 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -331,6 +331,12 @@ void __init arm_memblock_init(struct meminfo *mi, struct machine_desc *mdesc)
331#endif 331#endif
332#ifdef CONFIG_BLK_DEV_INITRD 332#ifdef CONFIG_BLK_DEV_INITRD
333 if (phys_initrd_size && 333 if (phys_initrd_size &&
334 !memblock_is_region_memory(phys_initrd_start, phys_initrd_size)) {
335 pr_err("INITRD: 0x%08lx+0x%08lx is not a memory region - disabling initrd\n",
336 phys_initrd_start, phys_initrd_size);
337 phys_initrd_start = phys_initrd_size = 0;
338 }
339 if (phys_initrd_size &&
334 memblock_is_region_reserved(phys_initrd_start, phys_initrd_size)) { 340 memblock_is_region_reserved(phys_initrd_start, phys_initrd_size)) {
335 pr_err("INITRD: 0x%08lx+0x%08lx overlaps in-use memory region - disabling initrd\n", 341 pr_err("INITRD: 0x%08lx+0x%08lx overlaps in-use memory region - disabling initrd\n",
336 phys_initrd_start, phys_initrd_size); 342 phys_initrd_start, phys_initrd_size);
@@ -635,7 +641,8 @@ void __init mem_init(void)
635 " modules : 0x%08lx - 0x%08lx (%4ld MB)\n" 641 " modules : 0x%08lx - 0x%08lx (%4ld MB)\n"
636 " .init : 0x%p" " - 0x%p" " (%4d kB)\n" 642 " .init : 0x%p" " - 0x%p" " (%4d kB)\n"
637 " .text : 0x%p" " - 0x%p" " (%4d kB)\n" 643 " .text : 0x%p" " - 0x%p" " (%4d kB)\n"
638 " .data : 0x%p" " - 0x%p" " (%4d kB)\n", 644 " .data : 0x%p" " - 0x%p" " (%4d kB)\n"
645 " .bss : 0x%p" " - 0x%p" " (%4d kB)\n",
639 646
640 MLK(UL(CONFIG_VECTORS_BASE), UL(CONFIG_VECTORS_BASE) + 647 MLK(UL(CONFIG_VECTORS_BASE), UL(CONFIG_VECTORS_BASE) +
641 (PAGE_SIZE)), 648 (PAGE_SIZE)),
@@ -657,7 +664,8 @@ void __init mem_init(void)
657 664
658 MLK_ROUNDUP(__init_begin, __init_end), 665 MLK_ROUNDUP(__init_begin, __init_end),
659 MLK_ROUNDUP(_text, _etext), 666 MLK_ROUNDUP(_text, _etext),
660 MLK_ROUNDUP(_sdata, _edata)); 667 MLK_ROUNDUP(_sdata, _edata),
668 MLK_ROUNDUP(__bss_start, __bss_stop));
661 669
662#undef MLK 670#undef MLK
663#undef MLM 671#undef MLM
diff --git a/arch/arm/mm/proc-arm7tdmi.S b/arch/arm/mm/proc-arm7tdmi.S
index e4c165ca6696..537ffcb0646d 100644
--- a/arch/arm/mm/proc-arm7tdmi.S
+++ b/arch/arm/mm/proc-arm7tdmi.S
@@ -146,7 +146,7 @@ __arm7tdmi_proc_info:
146 .long 0 146 .long 0
147 .long 0 147 .long 0
148 .long v4_cache_fns 148 .long v4_cache_fns
149 .size __arm7tdmi_proc_info, . - __arm7dmi_proc_info 149 .size __arm7tdmi_proc_info, . - __arm7tdmi_proc_info
150 150
151 .type __triscenda7_proc_info, #object 151 .type __triscenda7_proc_info, #object
152__triscenda7_proc_info: 152__triscenda7_proc_info:
diff --git a/arch/arm/mm/proc-arm9tdmi.S b/arch/arm/mm/proc-arm9tdmi.S
index 7b7ebd4d096d..546b54da1005 100644
--- a/arch/arm/mm/proc-arm9tdmi.S
+++ b/arch/arm/mm/proc-arm9tdmi.S
@@ -116,7 +116,7 @@ __arm9tdmi_proc_info:
116 .long 0 116 .long 0
117 .long 0 117 .long 0
118 .long v4_cache_fns 118 .long v4_cache_fns
119 .size __arm9tdmi_proc_info, . - __arm9dmi_proc_info 119 .size __arm9tdmi_proc_info, . - __arm9tdmi_proc_info
120 120
121 .type __p2001_proc_info, #object 121 .type __p2001_proc_info, #object
122__p2001_proc_info: 122__p2001_proc_info:
diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S
index b3b566ec83d3..3c3867850a30 100644
--- a/arch/arm/mm/proc-v7.S
+++ b/arch/arm/mm/proc-v7.S
@@ -108,16 +108,18 @@ ENTRY(cpu_v7_switch_mm)
108#ifdef CONFIG_ARM_ERRATA_430973 108#ifdef CONFIG_ARM_ERRATA_430973
109 mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB 109 mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB
110#endif 110#endif
111 mrc p15, 0, r2, c2, c0, 1 @ load TTB 1 111#ifdef CONFIG_ARM_ERRATA_754322
112 mcr p15, 0, r2, c2, c0, 0 @ into TTB 0 112 dsb
113#endif
114 mcr p15, 0, r2, c13, c0, 1 @ set reserved context ID
115 isb
1161: mcr p15, 0, r0, c2, c0, 0 @ set TTB 0
113 isb 117 isb
114#ifdef CONFIG_ARM_ERRATA_754322 118#ifdef CONFIG_ARM_ERRATA_754322
115 dsb 119 dsb
116#endif 120#endif
117 mcr p15, 0, r1, c13, c0, 1 @ set context ID 121 mcr p15, 0, r1, c13, c0, 1 @ set context ID
118 isb 122 isb
119 mcr p15, 0, r0, c2, c0, 0 @ set TTB 0
120 isb
121#endif 123#endif
122 mov pc, lr 124 mov pc, lr
123ENDPROC(cpu_v7_switch_mm) 125ENDPROC(cpu_v7_switch_mm)
diff --git a/arch/arm/plat-mxc/devices/platform-imx-dma.c b/arch/arm/plat-mxc/devices/platform-imx-dma.c
index 3538b85ede91..b130f60ca6b7 100644
--- a/arch/arm/plat-mxc/devices/platform-imx-dma.c
+++ b/arch/arm/plat-mxc/devices/platform-imx-dma.c
@@ -139,7 +139,7 @@ static struct sdma_script_start_addrs addr_imx35_to2 = {
139#endif 139#endif
140 140
141#ifdef CONFIG_SOC_IMX51 141#ifdef CONFIG_SOC_IMX51
142static struct sdma_script_start_addrs addr_imx51_to1 = { 142static struct sdma_script_start_addrs addr_imx51 = {
143 .ap_2_ap_addr = 642, 143 .ap_2_ap_addr = 642,
144 .uart_2_mcu_addr = 817, 144 .uart_2_mcu_addr = 817,
145 .mcu_2_app_addr = 747, 145 .mcu_2_app_addr = 747,
@@ -196,7 +196,9 @@ static int __init imxXX_add_imx_dma(void)
196 196
197#if defined(CONFIG_SOC_IMX51) 197#if defined(CONFIG_SOC_IMX51)
198 if (cpu_is_mx51()) { 198 if (cpu_is_mx51()) {
199 imx51_imx_sdma_data.pdata.script_addrs = &addr_imx51_to1; 199 int to_version = mx51_revision() >> 4;
200 imx51_imx_sdma_data.pdata.to_version = to_version;
201 imx51_imx_sdma_data.pdata.script_addrs = &addr_imx51;
200 ret = imx_add_imx_sdma(&imx51_imx_sdma_data); 202 ret = imx_add_imx_sdma(&imx51_imx_sdma_data);
201 } else 203 } else
202#endif 204#endif
diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c
index a37b8eb65b76..49fc0df0c21f 100644
--- a/arch/arm/plat-omap/omap_device.c
+++ b/arch/arm/plat-omap/omap_device.c
@@ -84,6 +84,7 @@
84#include <linux/io.h> 84#include <linux/io.h>
85#include <linux/clk.h> 85#include <linux/clk.h>
86#include <linux/clkdev.h> 86#include <linux/clkdev.h>
87#include <linux/pm_runtime.h>
87 88
88#include <plat/omap_device.h> 89#include <plat/omap_device.h>
89#include <plat/omap_hwmod.h> 90#include <plat/omap_hwmod.h>
@@ -539,20 +540,34 @@ int omap_early_device_register(struct omap_device *od)
539static int _od_runtime_suspend(struct device *dev) 540static int _od_runtime_suspend(struct device *dev)
540{ 541{
541 struct platform_device *pdev = to_platform_device(dev); 542 struct platform_device *pdev = to_platform_device(dev);
543 int ret;
544
545 ret = pm_generic_runtime_suspend(dev);
546
547 if (!ret)
548 omap_device_idle(pdev);
549
550 return ret;
551}
542 552
543 return omap_device_idle(pdev); 553static int _od_runtime_idle(struct device *dev)
554{
555 return pm_generic_runtime_idle(dev);
544} 556}
545 557
546static int _od_runtime_resume(struct device *dev) 558static int _od_runtime_resume(struct device *dev)
547{ 559{
548 struct platform_device *pdev = to_platform_device(dev); 560 struct platform_device *pdev = to_platform_device(dev);
549 561
550 return omap_device_enable(pdev); 562 omap_device_enable(pdev);
563
564 return pm_generic_runtime_resume(dev);
551} 565}
552 566
553static struct dev_power_domain omap_device_power_domain = { 567static struct dev_power_domain omap_device_power_domain = {
554 .ops = { 568 .ops = {
555 .runtime_suspend = _od_runtime_suspend, 569 .runtime_suspend = _od_runtime_suspend,
570 .runtime_idle = _od_runtime_idle,
556 .runtime_resume = _od_runtime_resume, 571 .runtime_resume = _od_runtime_resume,
557 USE_PLATFORM_PM_SLEEP_OPS 572 USE_PLATFORM_PM_SLEEP_OPS
558 } 573 }
diff --git a/arch/avr32/configs/atngw100_defconfig b/arch/avr32/configs/atngw100_defconfig
index 6f9ca56de1f6..a06bfccc2840 100644
--- a/arch/avr32/configs/atngw100_defconfig
+++ b/arch/avr32/configs/atngw100_defconfig
@@ -5,6 +5,7 @@ CONFIG_POSIX_MQUEUE=y
5CONFIG_LOG_BUF_SHIFT=14 5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_RELAY=y 6CONFIG_RELAY=y
7CONFIG_BLK_DEV_INITRD=y 7CONFIG_BLK_DEV_INITRD=y
8CONFIG_CC_OPTIMIZE_FOR_SIZE=y
8# CONFIG_SYSCTL_SYSCALL is not set 9# CONFIG_SYSCTL_SYSCALL is not set
9# CONFIG_BASE_FULL is not set 10# CONFIG_BASE_FULL is not set
10# CONFIG_COMPAT_BRK is not set 11# CONFIG_COMPAT_BRK is not set
diff --git a/arch/avr32/configs/atngw100_evklcd100_defconfig b/arch/avr32/configs/atngw100_evklcd100_defconfig
index 7eece0af34c9..d8f1fe80d210 100644
--- a/arch/avr32/configs/atngw100_evklcd100_defconfig
+++ b/arch/avr32/configs/atngw100_evklcd100_defconfig
@@ -5,6 +5,7 @@ CONFIG_POSIX_MQUEUE=y
5CONFIG_LOG_BUF_SHIFT=14 5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_RELAY=y 6CONFIG_RELAY=y
7CONFIG_BLK_DEV_INITRD=y 7CONFIG_BLK_DEV_INITRD=y
8CONFIG_CC_OPTIMIZE_FOR_SIZE=y
8# CONFIG_SYSCTL_SYSCALL is not set 9# CONFIG_SYSCTL_SYSCALL is not set
9# CONFIG_BASE_FULL is not set 10# CONFIG_BASE_FULL is not set
10# CONFIG_COMPAT_BRK is not set 11# CONFIG_COMPAT_BRK is not set
diff --git a/arch/avr32/configs/atngw100_evklcd101_defconfig b/arch/avr32/configs/atngw100_evklcd101_defconfig
index 387eb9d6e423..d4c5b19ec950 100644
--- a/arch/avr32/configs/atngw100_evklcd101_defconfig
+++ b/arch/avr32/configs/atngw100_evklcd101_defconfig
@@ -5,6 +5,7 @@ CONFIG_POSIX_MQUEUE=y
5CONFIG_LOG_BUF_SHIFT=14 5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_RELAY=y 6CONFIG_RELAY=y
7CONFIG_BLK_DEV_INITRD=y 7CONFIG_BLK_DEV_INITRD=y
8CONFIG_CC_OPTIMIZE_FOR_SIZE=y
8# CONFIG_SYSCTL_SYSCALL is not set 9# CONFIG_SYSCTL_SYSCALL is not set
9# CONFIG_BASE_FULL is not set 10# CONFIG_BASE_FULL is not set
10# CONFIG_COMPAT_BRK is not set 11# CONFIG_COMPAT_BRK is not set
diff --git a/arch/avr32/configs/atngw100_mrmt_defconfig b/arch/avr32/configs/atngw100_mrmt_defconfig
index 19f6ceeeff7b..77ca4f905d2c 100644
--- a/arch/avr32/configs/atngw100_mrmt_defconfig
+++ b/arch/avr32/configs/atngw100_mrmt_defconfig
@@ -7,6 +7,7 @@ CONFIG_BSD_PROCESS_ACCT_V3=y
7CONFIG_LOG_BUF_SHIFT=14 7CONFIG_LOG_BUF_SHIFT=14
8CONFIG_SYSFS_DEPRECATED_V2=y 8CONFIG_SYSFS_DEPRECATED_V2=y
9CONFIG_BLK_DEV_INITRD=y 9CONFIG_BLK_DEV_INITRD=y
10CONFIG_CC_OPTIMIZE_FOR_SIZE=y
10# CONFIG_SYSCTL_SYSCALL is not set 11# CONFIG_SYSCTL_SYSCALL is not set
11# CONFIG_BASE_FULL is not set 12# CONFIG_BASE_FULL is not set
12# CONFIG_SLUB_DEBUG is not set 13# CONFIG_SLUB_DEBUG is not set
@@ -109,7 +110,7 @@ CONFIG_LEDS_GPIO=y
109CONFIG_LEDS_TRIGGERS=y 110CONFIG_LEDS_TRIGGERS=y
110CONFIG_LEDS_TRIGGER_TIMER=y 111CONFIG_LEDS_TRIGGER_TIMER=y
111CONFIG_LEDS_TRIGGER_HEARTBEAT=y 112CONFIG_LEDS_TRIGGER_HEARTBEAT=y
112CONFIG_RTC_CLASS=m 113CONFIG_RTC_CLASS=y
113CONFIG_RTC_DRV_S35390A=m 114CONFIG_RTC_DRV_S35390A=m
114CONFIG_RTC_DRV_AT32AP700X=m 115CONFIG_RTC_DRV_AT32AP700X=m
115CONFIG_DMADEVICES=y 116CONFIG_DMADEVICES=y
diff --git a/arch/avr32/configs/atngw100mkii_defconfig b/arch/avr32/configs/atngw100mkii_defconfig
index f0fe237133a9..6e0dca4d3131 100644
--- a/arch/avr32/configs/atngw100mkii_defconfig
+++ b/arch/avr32/configs/atngw100mkii_defconfig
@@ -5,6 +5,7 @@ CONFIG_POSIX_MQUEUE=y
5CONFIG_LOG_BUF_SHIFT=14 5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_RELAY=y 6CONFIG_RELAY=y
7CONFIG_BLK_DEV_INITRD=y 7CONFIG_BLK_DEV_INITRD=y
8CONFIG_CC_OPTIMIZE_FOR_SIZE=y
8# CONFIG_SYSCTL_SYSCALL is not set 9# CONFIG_SYSCTL_SYSCALL is not set
9# CONFIG_BASE_FULL is not set 10# CONFIG_BASE_FULL is not set
10# CONFIG_COMPAT_BRK is not set 11# CONFIG_COMPAT_BRK is not set
diff --git a/arch/avr32/configs/atngw100mkii_evklcd100_defconfig b/arch/avr32/configs/atngw100mkii_evklcd100_defconfig
index e4a7c1dc8380..7f2a344a5fa8 100644
--- a/arch/avr32/configs/atngw100mkii_evklcd100_defconfig
+++ b/arch/avr32/configs/atngw100mkii_evklcd100_defconfig
@@ -5,6 +5,7 @@ CONFIG_POSIX_MQUEUE=y
5CONFIG_LOG_BUF_SHIFT=14 5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_RELAY=y 6CONFIG_RELAY=y
7CONFIG_BLK_DEV_INITRD=y 7CONFIG_BLK_DEV_INITRD=y
8CONFIG_CC_OPTIMIZE_FOR_SIZE=y
8# CONFIG_SYSCTL_SYSCALL is not set 9# CONFIG_SYSCTL_SYSCALL is not set
9# CONFIG_BASE_FULL is not set 10# CONFIG_BASE_FULL is not set
10# CONFIG_COMPAT_BRK is not set 11# CONFIG_COMPAT_BRK is not set
diff --git a/arch/avr32/configs/atngw100mkii_evklcd101_defconfig b/arch/avr32/configs/atngw100mkii_evklcd101_defconfig
index 6f37f70c2c37..085eeba88f67 100644
--- a/arch/avr32/configs/atngw100mkii_evklcd101_defconfig
+++ b/arch/avr32/configs/atngw100mkii_evklcd101_defconfig
@@ -5,6 +5,7 @@ CONFIG_POSIX_MQUEUE=y
5CONFIG_LOG_BUF_SHIFT=14 5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_RELAY=y 6CONFIG_RELAY=y
7CONFIG_BLK_DEV_INITRD=y 7CONFIG_BLK_DEV_INITRD=y
8CONFIG_CC_OPTIMIZE_FOR_SIZE=y
8# CONFIG_SYSCTL_SYSCALL is not set 9# CONFIG_SYSCTL_SYSCALL is not set
9# CONFIG_BASE_FULL is not set 10# CONFIG_BASE_FULL is not set
10# CONFIG_COMPAT_BRK is not set 11# CONFIG_COMPAT_BRK is not set
diff --git a/arch/avr32/configs/atstk1002_defconfig b/arch/avr32/configs/atstk1002_defconfig
index 4fb01f5ab42f..d1a887e64055 100644
--- a/arch/avr32/configs/atstk1002_defconfig
+++ b/arch/avr32/configs/atstk1002_defconfig
@@ -5,6 +5,7 @@ CONFIG_POSIX_MQUEUE=y
5CONFIG_LOG_BUF_SHIFT=14 5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_RELAY=y 6CONFIG_RELAY=y
7CONFIG_BLK_DEV_INITRD=y 7CONFIG_BLK_DEV_INITRD=y
8CONFIG_CC_OPTIMIZE_FOR_SIZE=y
8# CONFIG_SYSCTL_SYSCALL is not set 9# CONFIG_SYSCTL_SYSCALL is not set
9# CONFIG_BASE_FULL is not set 10# CONFIG_BASE_FULL is not set
10# CONFIG_COMPAT_BRK is not set 11# CONFIG_COMPAT_BRK is not set
diff --git a/arch/avr32/configs/atstk1003_defconfig b/arch/avr32/configs/atstk1003_defconfig
index 9faaf9b900f2..956f2819ad45 100644
--- a/arch/avr32/configs/atstk1003_defconfig
+++ b/arch/avr32/configs/atstk1003_defconfig
@@ -5,6 +5,7 @@ CONFIG_POSIX_MQUEUE=y
5CONFIG_LOG_BUF_SHIFT=14 5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_RELAY=y 6CONFIG_RELAY=y
7CONFIG_BLK_DEV_INITRD=y 7CONFIG_BLK_DEV_INITRD=y
8CONFIG_CC_OPTIMIZE_FOR_SIZE=y
8# CONFIG_SYSCTL_SYSCALL is not set 9# CONFIG_SYSCTL_SYSCALL is not set
9# CONFIG_BASE_FULL is not set 10# CONFIG_BASE_FULL is not set
10# CONFIG_COMPAT_BRK is not set 11# CONFIG_COMPAT_BRK is not set
diff --git a/arch/avr32/configs/atstk1004_defconfig b/arch/avr32/configs/atstk1004_defconfig
index 3d2a5d85f970..40c69f38c61a 100644
--- a/arch/avr32/configs/atstk1004_defconfig
+++ b/arch/avr32/configs/atstk1004_defconfig
@@ -5,6 +5,7 @@ CONFIG_POSIX_MQUEUE=y
5CONFIG_LOG_BUF_SHIFT=14 5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_RELAY=y 6CONFIG_RELAY=y
7CONFIG_BLK_DEV_INITRD=y 7CONFIG_BLK_DEV_INITRD=y
8CONFIG_CC_OPTIMIZE_FOR_SIZE=y
8# CONFIG_SYSCTL_SYSCALL is not set 9# CONFIG_SYSCTL_SYSCALL is not set
9# CONFIG_BASE_FULL is not set 10# CONFIG_BASE_FULL is not set
10# CONFIG_COMPAT_BRK is not set 11# CONFIG_COMPAT_BRK is not set
diff --git a/arch/avr32/configs/atstk1006_defconfig b/arch/avr32/configs/atstk1006_defconfig
index 1ed8f22d4fe2..511eb8af356d 100644
--- a/arch/avr32/configs/atstk1006_defconfig
+++ b/arch/avr32/configs/atstk1006_defconfig
@@ -5,6 +5,7 @@ CONFIG_POSIX_MQUEUE=y
5CONFIG_LOG_BUF_SHIFT=14 5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_RELAY=y 6CONFIG_RELAY=y
7CONFIG_BLK_DEV_INITRD=y 7CONFIG_BLK_DEV_INITRD=y
8CONFIG_CC_OPTIMIZE_FOR_SIZE=y
8# CONFIG_SYSCTL_SYSCALL is not set 9# CONFIG_SYSCTL_SYSCALL is not set
9# CONFIG_BASE_FULL is not set 10# CONFIG_BASE_FULL is not set
10# CONFIG_COMPAT_BRK is not set 11# CONFIG_COMPAT_BRK is not set
diff --git a/arch/avr32/configs/favr-32_defconfig b/arch/avr32/configs/favr-32_defconfig
index aeadc955db32..19973b06170c 100644
--- a/arch/avr32/configs/favr-32_defconfig
+++ b/arch/avr32/configs/favr-32_defconfig
@@ -6,6 +6,7 @@ CONFIG_LOG_BUF_SHIFT=14
6CONFIG_SYSFS_DEPRECATED_V2=y 6CONFIG_SYSFS_DEPRECATED_V2=y
7CONFIG_RELAY=y 7CONFIG_RELAY=y
8CONFIG_BLK_DEV_INITRD=y 8CONFIG_BLK_DEV_INITRD=y
9CONFIG_CC_OPTIMIZE_FOR_SIZE=y
9# CONFIG_SYSCTL_SYSCALL is not set 10# CONFIG_SYSCTL_SYSCALL is not set
10# CONFIG_BASE_FULL is not set 11# CONFIG_BASE_FULL is not set
11# CONFIG_COMPAT_BRK is not set 12# CONFIG_COMPAT_BRK is not set
diff --git a/arch/avr32/configs/hammerhead_defconfig b/arch/avr32/configs/hammerhead_defconfig
index 1692beeb7ed3..6f45681196d1 100644
--- a/arch/avr32/configs/hammerhead_defconfig
+++ b/arch/avr32/configs/hammerhead_defconfig
@@ -7,6 +7,7 @@ CONFIG_BSD_PROCESS_ACCT_V3=y
7CONFIG_LOG_BUF_SHIFT=14 7CONFIG_LOG_BUF_SHIFT=14
8CONFIG_SYSFS_DEPRECATED_V2=y 8CONFIG_SYSFS_DEPRECATED_V2=y
9CONFIG_BLK_DEV_INITRD=y 9CONFIG_BLK_DEV_INITRD=y
10CONFIG_CC_OPTIMIZE_FOR_SIZE=y
10# CONFIG_SYSCTL_SYSCALL is not set 11# CONFIG_SYSCTL_SYSCALL is not set
11# CONFIG_BASE_FULL is not set 12# CONFIG_BASE_FULL is not set
12# CONFIG_COMPAT_BRK is not set 13# CONFIG_COMPAT_BRK is not set
diff --git a/arch/avr32/configs/merisc_defconfig b/arch/avr32/configs/merisc_defconfig
index 8b670a6530bf..3befab966827 100644
--- a/arch/avr32/configs/merisc_defconfig
+++ b/arch/avr32/configs/merisc_defconfig
@@ -7,6 +7,7 @@ CONFIG_BSD_PROCESS_ACCT_V3=y
7CONFIG_LOG_BUF_SHIFT=14 7CONFIG_LOG_BUF_SHIFT=14
8CONFIG_SYSFS_DEPRECATED_V2=y 8CONFIG_SYSFS_DEPRECATED_V2=y
9CONFIG_BLK_DEV_INITRD=y 9CONFIG_BLK_DEV_INITRD=y
10CONFIG_CC_OPTIMIZE_FOR_SIZE=y
10# CONFIG_SYSCTL_SYSCALL is not set 11# CONFIG_SYSCTL_SYSCALL is not set
11# CONFIG_BASE_FULL is not set 12# CONFIG_BASE_FULL is not set
12CONFIG_MODULES=y 13CONFIG_MODULES=y
diff --git a/arch/avr32/configs/mimc200_defconfig b/arch/avr32/configs/mimc200_defconfig
index 5a51f2e7ffb9..1bee51f22154 100644
--- a/arch/avr32/configs/mimc200_defconfig
+++ b/arch/avr32/configs/mimc200_defconfig
@@ -7,6 +7,7 @@ CONFIG_BSD_PROCESS_ACCT_V3=y
7CONFIG_LOG_BUF_SHIFT=14 7CONFIG_LOG_BUF_SHIFT=14
8CONFIG_SYSFS_DEPRECATED_V2=y 8CONFIG_SYSFS_DEPRECATED_V2=y
9CONFIG_BLK_DEV_INITRD=y 9CONFIG_BLK_DEV_INITRD=y
10CONFIG_CC_OPTIMIZE_FOR_SIZE=y
10# CONFIG_SYSCTL_SYSCALL is not set 11# CONFIG_SYSCTL_SYSCALL is not set
11# CONFIG_BASE_FULL is not set 12# CONFIG_BASE_FULL is not set
12# CONFIG_COMPAT_BRK is not set 13# CONFIG_COMPAT_BRK is not set
diff --git a/arch/avr32/include/asm/processor.h b/arch/avr32/include/asm/processor.h
index 49a88f5a9d2f..108502bc6770 100644
--- a/arch/avr32/include/asm/processor.h
+++ b/arch/avr32/include/asm/processor.h
@@ -131,7 +131,6 @@ struct thread_struct {
131 */ 131 */
132#define start_thread(regs, new_pc, new_sp) \ 132#define start_thread(regs, new_pc, new_sp) \
133 do { \ 133 do { \
134 set_fs(USER_DS); \
135 memset(regs, 0, sizeof(*regs)); \ 134 memset(regs, 0, sizeof(*regs)); \
136 regs->sr = MODE_USER; \ 135 regs->sr = MODE_USER; \
137 regs->pc = new_pc & ~1; \ 136 regs->pc = new_pc & ~1; \
diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c
index aa677e2a3823..7fbf0dcb9afe 100644
--- a/arch/avr32/mach-at32ap/at32ap700x.c
+++ b/arch/avr32/mach-at32ap/at32ap700x.c
@@ -1043,8 +1043,9 @@ void __init at32_map_usart(unsigned int hw_id, unsigned int line, int flags)
1043 data->regs = (void __iomem *)pdev->resource[0].start; 1043 data->regs = (void __iomem *)pdev->resource[0].start;
1044 } 1044 }
1045 1045
1046 pdev->id = line;
1046 pdata = pdev->dev.platform_data; 1047 pdata = pdev->dev.platform_data;
1047 pdata->num = portnr; 1048 pdata->num = line;
1048 at32_usarts[line] = pdev; 1049 at32_usarts[line] = pdev;
1049} 1050}
1050 1051
diff --git a/arch/avr32/mach-at32ap/include/mach/cpu.h b/arch/avr32/mach-at32ap/include/mach/cpu.h
index 9c96a130f3a8..8181293115e4 100644
--- a/arch/avr32/mach-at32ap/include/mach/cpu.h
+++ b/arch/avr32/mach-at32ap/include/mach/cpu.h
@@ -31,8 +31,20 @@
31#define cpu_is_at91sam9263() (0) 31#define cpu_is_at91sam9263() (0)
32#define cpu_is_at91sam9rl() (0) 32#define cpu_is_at91sam9rl() (0)
33#define cpu_is_at91cap9() (0) 33#define cpu_is_at91cap9() (0)
34#define cpu_is_at91cap9_revB() (0)
35#define cpu_is_at91cap9_revC() (0)
34#define cpu_is_at91sam9g10() (0) 36#define cpu_is_at91sam9g10() (0)
37#define cpu_is_at91sam9g20() (0)
35#define cpu_is_at91sam9g45() (0) 38#define cpu_is_at91sam9g45() (0)
36#define cpu_is_at91sam9g45es() (0) 39#define cpu_is_at91sam9g45es() (0)
40#define cpu_is_at91sam9m10() (0)
41#define cpu_is_at91sam9g46() (0)
42#define cpu_is_at91sam9m11() (0)
43#define cpu_is_at91sam9x5() (0)
44#define cpu_is_at91sam9g15() (0)
45#define cpu_is_at91sam9g35() (0)
46#define cpu_is_at91sam9x35() (0)
47#define cpu_is_at91sam9g25() (0)
48#define cpu_is_at91sam9x25() (0)
37 49
38#endif /* __ASM_ARCH_CPU_H */ 50#endif /* __ASM_ARCH_CPU_H */
diff --git a/arch/avr32/mach-at32ap/intc.c b/arch/avr32/mach-at32ap/intc.c
index 3e3646186c9f..c9ac2f8e8f64 100644
--- a/arch/avr32/mach-at32ap/intc.c
+++ b/arch/avr32/mach-at32ap/intc.c
@@ -167,14 +167,12 @@ static int intc_suspend(void)
167 return 0; 167 return 0;
168} 168}
169 169
170static int intc_resume(void) 170static void intc_resume(void)
171{ 171{
172 int i; 172 int i;
173 173
174 for (i = 0; i < 64; i++) 174 for (i = 0; i < 64; i++)
175 intc_writel(&intc0, INTPR0 + 4 * i, intc0.saved_ipr[i]); 175 intc_writel(&intc0, INTPR0 + 4 * i, intc0.saved_ipr[i]);
176
177 return 0;
178} 176}
179#else 177#else
180#define intc_suspend NULL 178#define intc_suspend NULL
diff --git a/arch/blackfin/configs/CM-BF548_defconfig b/arch/blackfin/configs/CM-BF548_defconfig
index 31d954216c05..9f1d08401fca 100644
--- a/arch/blackfin/configs/CM-BF548_defconfig
+++ b/arch/blackfin/configs/CM-BF548_defconfig
@@ -112,7 +112,7 @@ CONFIG_USB_G_SERIAL=m
112CONFIG_USB_G_PRINTER=m 112CONFIG_USB_G_PRINTER=m
113CONFIG_MMC=m 113CONFIG_MMC=m
114CONFIG_SDH_BFIN=m 114CONFIG_SDH_BFIN=m
115CONFIG_RTC_CLASS=m 115CONFIG_RTC_CLASS=y
116CONFIG_RTC_DRV_BFIN=m 116CONFIG_RTC_DRV_BFIN=m
117CONFIG_EXT2_FS=m 117CONFIG_EXT2_FS=m
118# CONFIG_DNOTIFY is not set 118# CONFIG_DNOTIFY is not set
diff --git a/arch/m68k/Kconfig.nommu b/arch/m68k/Kconfig.nommu
index fc98f9b9d4d2..b004dc1b1710 100644
--- a/arch/m68k/Kconfig.nommu
+++ b/arch/m68k/Kconfig.nommu
@@ -14,6 +14,33 @@ config GENERIC_CLOCKEVENTS
14 bool 14 bool
15 default n 15 default n
16 16
17config M68000
18 bool
19 help
20 The Freescale (was Motorola) 68000 CPU is the first generation of
21 the well known M68K family of processors. The CPU core as well as
22 being available as a stand alone CPU was also used in many
23 System-On-Chip devices (eg 68328, 68302, etc). It does not contain
24 a paging MMU.
25
26config MCPU32
27 bool
28 help
29 The Freescale (was then Motorola) CPU32 is a CPU core that is
30 based on the 68020 processor. For the most part it is used in
31 System-On-Chip parts, and does not contain a paging MMU.
32
33config COLDFIRE
34 bool
35 select GENERIC_GPIO
36 select ARCH_REQUIRE_GPIOLIB
37 help
38 The Freescale ColdFire family of processors is a modern derivitive
39 of the 68000 processor family. They are mainly targeted at embedded
40 applications, and are all System-On-Chip (SOC) devices, as opposed
41 to stand alone CPUs. They implement a subset of the original 68000
42 processor instruction set.
43
17config COLDFIRE_SW_A7 44config COLDFIRE_SW_A7
18 bool 45 bool
19 default n 46 default n
@@ -36,26 +63,31 @@ choice
36 63
37config M68328 64config M68328
38 bool "MC68328" 65 bool "MC68328"
66 select M68000
39 help 67 help
40 Motorola 68328 processor support. 68 Motorola 68328 processor support.
41 69
42config M68EZ328 70config M68EZ328
43 bool "MC68EZ328" 71 bool "MC68EZ328"
72 select M68000
44 help 73 help
45 Motorola 68EX328 processor support. 74 Motorola 68EX328 processor support.
46 75
47config M68VZ328 76config M68VZ328
48 bool "MC68VZ328" 77 bool "MC68VZ328"
78 select M68000
49 help 79 help
50 Motorola 68VZ328 processor support. 80 Motorola 68VZ328 processor support.
51 81
52config M68360 82config M68360
53 bool "MC68360" 83 bool "MC68360"
84 select MCPU32
54 help 85 help
55 Motorola 68360 processor support. 86 Motorola 68360 processor support.
56 87
57config M5206 88config M5206
58 bool "MCF5206" 89 bool "MCF5206"
90 select COLDFIRE
59 select COLDFIRE_SW_A7 91 select COLDFIRE_SW_A7
60 select HAVE_MBAR 92 select HAVE_MBAR
61 help 93 help
@@ -63,6 +95,7 @@ config M5206
63 95
64config M5206e 96config M5206e
65 bool "MCF5206e" 97 bool "MCF5206e"
98 select COLDFIRE
66 select COLDFIRE_SW_A7 99 select COLDFIRE_SW_A7
67 select HAVE_MBAR 100 select HAVE_MBAR
68 help 101 help
@@ -70,6 +103,7 @@ config M5206e
70 103
71config M520x 104config M520x
72 bool "MCF520x" 105 bool "MCF520x"
106 select COLDFIRE
73 select GENERIC_CLOCKEVENTS 107 select GENERIC_CLOCKEVENTS
74 select HAVE_CACHE_SPLIT 108 select HAVE_CACHE_SPLIT
75 help 109 help
@@ -77,6 +111,7 @@ config M520x
77 111
78config M523x 112config M523x
79 bool "MCF523x" 113 bool "MCF523x"
114 select COLDFIRE
80 select GENERIC_CLOCKEVENTS 115 select GENERIC_CLOCKEVENTS
81 select HAVE_CACHE_SPLIT 116 select HAVE_CACHE_SPLIT
82 select HAVE_IPSBAR 117 select HAVE_IPSBAR
@@ -85,6 +120,7 @@ config M523x
85 120
86config M5249 121config M5249
87 bool "MCF5249" 122 bool "MCF5249"
123 select COLDFIRE
88 select COLDFIRE_SW_A7 124 select COLDFIRE_SW_A7
89 select HAVE_MBAR 125 select HAVE_MBAR
90 help 126 help
@@ -92,6 +128,7 @@ config M5249
92 128
93config M5271 129config M5271
94 bool "MCF5271" 130 bool "MCF5271"
131 select COLDFIRE
95 select HAVE_CACHE_SPLIT 132 select HAVE_CACHE_SPLIT
96 select HAVE_IPSBAR 133 select HAVE_IPSBAR
97 help 134 help
@@ -99,6 +136,7 @@ config M5271
99 136
100config M5272 137config M5272
101 bool "MCF5272" 138 bool "MCF5272"
139 select COLDFIRE
102 select COLDFIRE_SW_A7 140 select COLDFIRE_SW_A7
103 select HAVE_MBAR 141 select HAVE_MBAR
104 help 142 help
@@ -106,6 +144,7 @@ config M5272
106 144
107config M5275 145config M5275
108 bool "MCF5275" 146 bool "MCF5275"
147 select COLDFIRE
109 select HAVE_CACHE_SPLIT 148 select HAVE_CACHE_SPLIT
110 select HAVE_IPSBAR 149 select HAVE_IPSBAR
111 help 150 help
@@ -113,6 +152,7 @@ config M5275
113 152
114config M528x 153config M528x
115 bool "MCF528x" 154 bool "MCF528x"
155 select COLDFIRE
116 select GENERIC_CLOCKEVENTS 156 select GENERIC_CLOCKEVENTS
117 select HAVE_CACHE_SPLIT 157 select HAVE_CACHE_SPLIT
118 select HAVE_IPSBAR 158 select HAVE_IPSBAR
@@ -121,6 +161,7 @@ config M528x
121 161
122config M5307 162config M5307
123 bool "MCF5307" 163 bool "MCF5307"
164 select COLDFIRE
124 select COLDFIRE_SW_A7 165 select COLDFIRE_SW_A7
125 select HAVE_CACHE_CB 166 select HAVE_CACHE_CB
126 select HAVE_MBAR 167 select HAVE_MBAR
@@ -129,12 +170,14 @@ config M5307
129 170
130config M532x 171config M532x
131 bool "MCF532x" 172 bool "MCF532x"
173 select COLDFIRE
132 select HAVE_CACHE_CB 174 select HAVE_CACHE_CB
133 help 175 help
134 Freescale (Motorola) ColdFire 532x processor support. 176 Freescale (Motorola) ColdFire 532x processor support.
135 177
136config M5407 178config M5407
137 bool "MCF5407" 179 bool "MCF5407"
180 select COLDFIRE
138 select COLDFIRE_SW_A7 181 select COLDFIRE_SW_A7
139 select HAVE_CACHE_CB 182 select HAVE_CACHE_CB
140 select HAVE_MBAR 183 select HAVE_MBAR
@@ -143,6 +186,7 @@ config M5407
143 186
144config M547x 187config M547x
145 bool "MCF547x" 188 bool "MCF547x"
189 select COLDFIRE
146 select HAVE_CACHE_CB 190 select HAVE_CACHE_CB
147 select HAVE_MBAR 191 select HAVE_MBAR
148 help 192 help
@@ -150,6 +194,7 @@ config M547x
150 194
151config M548x 195config M548x
152 bool "MCF548x" 196 bool "MCF548x"
197 select COLDFIRE
153 select HAVE_CACHE_CB 198 select HAVE_CACHE_CB
154 select HAVE_MBAR 199 select HAVE_MBAR
155 help 200 help
@@ -168,13 +213,6 @@ config M54xx
168 depends on (M548x || M547x) 213 depends on (M548x || M547x)
169 default y 214 default y
170 215
171config COLDFIRE
172 bool
173 depends on (M5206 || M5206e || M520x || M523x || M5249 || M527x || M5272 || M528x || M5307 || M532x || M5407 || M54xx)
174 select GENERIC_GPIO
175 select ARCH_REQUIRE_GPIOLIB
176 default y
177
178config CLOCK_SET 216config CLOCK_SET
179 bool "Enable setting the CPU clock frequency" 217 bool "Enable setting the CPU clock frequency"
180 default n 218 default n
diff --git a/arch/m68k/kernel/m68k_ksyms.c b/arch/m68k/kernel/m68k_ksyms.c
index 33f82769547c..1b7a14d1a000 100644
--- a/arch/m68k/kernel/m68k_ksyms.c
+++ b/arch/m68k/kernel/m68k_ksyms.c
@@ -14,8 +14,7 @@ EXPORT_SYMBOL(__ashrdi3);
14EXPORT_SYMBOL(__lshrdi3); 14EXPORT_SYMBOL(__lshrdi3);
15EXPORT_SYMBOL(__muldi3); 15EXPORT_SYMBOL(__muldi3);
16 16
17#if !defined(__mc68020__) && !defined(__mc68030__) && \ 17#if defined(CONFIG_M68000) || defined(CONFIG_COLDFIRE)
18 !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcpu32__)
19/* 18/*
20 * Simpler 68k and ColdFire parts also need a few other gcc functions. 19 * Simpler 68k and ColdFire parts also need a few other gcc functions.
21 */ 20 */
diff --git a/arch/m68k/kernel/vmlinux.lds_no.S b/arch/m68k/kernel/vmlinux.lds_no.S
index f4d715cdca0e..7dc4087a9545 100644
--- a/arch/m68k/kernel/vmlinux.lds_no.S
+++ b/arch/m68k/kernel/vmlinux.lds_no.S
@@ -84,52 +84,52 @@ SECTIONS {
84 /* Kernel symbol table: Normal symbols */ 84 /* Kernel symbol table: Normal symbols */
85 . = ALIGN(4); 85 . = ALIGN(4);
86 __start___ksymtab = .; 86 __start___ksymtab = .;
87 *(__ksymtab) 87 *(SORT(___ksymtab+*))
88 __stop___ksymtab = .; 88 __stop___ksymtab = .;
89 89
90 /* Kernel symbol table: GPL-only symbols */ 90 /* Kernel symbol table: GPL-only symbols */
91 __start___ksymtab_gpl = .; 91 __start___ksymtab_gpl = .;
92 *(__ksymtab_gpl) 92 *(SORT(___ksymtab_gpl+*))
93 __stop___ksymtab_gpl = .; 93 __stop___ksymtab_gpl = .;
94 94
95 /* Kernel symbol table: Normal unused symbols */ 95 /* Kernel symbol table: Normal unused symbols */
96 __start___ksymtab_unused = .; 96 __start___ksymtab_unused = .;
97 *(__ksymtab_unused) 97 *(SORT(___ksymtab_unused+*))
98 __stop___ksymtab_unused = .; 98 __stop___ksymtab_unused = .;
99 99
100 /* Kernel symbol table: GPL-only unused symbols */ 100 /* Kernel symbol table: GPL-only unused symbols */
101 __start___ksymtab_unused_gpl = .; 101 __start___ksymtab_unused_gpl = .;
102 *(__ksymtab_unused_gpl) 102 *(SORT(___ksymtab_unused_gpl+*))
103 __stop___ksymtab_unused_gpl = .; 103 __stop___ksymtab_unused_gpl = .;
104 104
105 /* Kernel symbol table: GPL-future symbols */ 105 /* Kernel symbol table: GPL-future symbols */
106 __start___ksymtab_gpl_future = .; 106 __start___ksymtab_gpl_future = .;
107 *(__ksymtab_gpl_future) 107 *(SORT(___ksymtab_gpl_future+*))
108 __stop___ksymtab_gpl_future = .; 108 __stop___ksymtab_gpl_future = .;
109 109
110 /* Kernel symbol table: Normal symbols */ 110 /* Kernel symbol table: Normal symbols */
111 __start___kcrctab = .; 111 __start___kcrctab = .;
112 *(__kcrctab) 112 *(SORT(___kcrctab+*))
113 __stop___kcrctab = .; 113 __stop___kcrctab = .;
114 114
115 /* Kernel symbol table: GPL-only symbols */ 115 /* Kernel symbol table: GPL-only symbols */
116 __start___kcrctab_gpl = .; 116 __start___kcrctab_gpl = .;
117 *(__kcrctab_gpl) 117 *(SORT(___kcrctab_gpl+*))
118 __stop___kcrctab_gpl = .; 118 __stop___kcrctab_gpl = .;
119 119
120 /* Kernel symbol table: Normal unused symbols */ 120 /* Kernel symbol table: Normal unused symbols */
121 __start___kcrctab_unused = .; 121 __start___kcrctab_unused = .;
122 *(__kcrctab_unused) 122 *(SORT(___kcrctab_unused+*))
123 __stop___kcrctab_unused = .; 123 __stop___kcrctab_unused = .;
124 124
125 /* Kernel symbol table: GPL-only unused symbols */ 125 /* Kernel symbol table: GPL-only unused symbols */
126 __start___kcrctab_unused_gpl = .; 126 __start___kcrctab_unused_gpl = .;
127 *(__kcrctab_unused_gpl) 127 *(SORT(___kcrctab_unused_gpl+*))
128 __stop___kcrctab_unused_gpl = .; 128 __stop___kcrctab_unused_gpl = .;
129 129
130 /* Kernel symbol table: GPL-future symbols */ 130 /* Kernel symbol table: GPL-future symbols */
131 __start___kcrctab_gpl_future = .; 131 __start___kcrctab_gpl_future = .;
132 *(__kcrctab_gpl_future) 132 *(SORT(___kcrctab_gpl_future+*))
133 __stop___kcrctab_gpl_future = .; 133 __stop___kcrctab_gpl_future = .;
134 134
135 /* Kernel symbol table: strings */ 135 /* Kernel symbol table: strings */
diff --git a/arch/m68k/lib/memcpy.c b/arch/m68k/lib/memcpy.c
index 62182c81e91c..064889316974 100644
--- a/arch/m68k/lib/memcpy.c
+++ b/arch/m68k/lib/memcpy.c
@@ -34,8 +34,10 @@ void *memcpy(void *to, const void *from, size_t n)
34 if (temp) { 34 if (temp) {
35 long *lto = to; 35 long *lto = to;
36 const long *lfrom = from; 36 const long *lfrom = from;
37#if defined(__mc68020__) || defined(__mc68030__) || \ 37#if defined(CONFIG_M68000) || defined(CONFIG_COLDFIRE)
38 defined(__mc68040__) || defined(__mc68060__) || defined(__mcpu32__) 38 for (; temp; temp--)
39 *lto++ = *lfrom++;
40#else
39 asm volatile ( 41 asm volatile (
40 " movel %2,%3\n" 42 " movel %2,%3\n"
41 " andw #7,%3\n" 43 " andw #7,%3\n"
@@ -56,9 +58,6 @@ void *memcpy(void *to, const void *from, size_t n)
56 " jpl 4b" 58 " jpl 4b"
57 : "=a" (lfrom), "=a" (lto), "=d" (temp), "=&d" (temp1) 59 : "=a" (lfrom), "=a" (lto), "=d" (temp), "=&d" (temp1)
58 : "0" (lfrom), "1" (lto), "2" (temp)); 60 : "0" (lfrom), "1" (lto), "2" (temp));
59#else
60 for (; temp; temp--)
61 *lto++ = *lfrom++;
62#endif 61#endif
63 to = lto; 62 to = lto;
64 from = lfrom; 63 from = lfrom;
diff --git a/arch/m68k/lib/memset.c b/arch/m68k/lib/memset.c
index f649e6a2e644..8a7639f0a2fe 100644
--- a/arch/m68k/lib/memset.c
+++ b/arch/m68k/lib/memset.c
@@ -32,8 +32,10 @@ void *memset(void *s, int c, size_t count)
32 temp = count >> 2; 32 temp = count >> 2;
33 if (temp) { 33 if (temp) {
34 long *ls = s; 34 long *ls = s;
35#if defined(__mc68020__) || defined(__mc68030__) || \ 35#if defined(CONFIG_M68000) || defined(CONFIG_COLDFIRE)
36 defined(__mc68040__) || defined(__mc68060__) || defined(__mcpu32__) 36 for (; temp; temp--)
37 *ls++ = c;
38#else
37 size_t temp1; 39 size_t temp1;
38 asm volatile ( 40 asm volatile (
39 " movel %1,%2\n" 41 " movel %1,%2\n"
@@ -55,9 +57,6 @@ void *memset(void *s, int c, size_t count)
55 " jpl 1b" 57 " jpl 1b"
56 : "=a" (ls), "=d" (temp), "=&d" (temp1) 58 : "=a" (ls), "=d" (temp), "=&d" (temp1)
57 : "d" (c), "0" (ls), "1" (temp)); 59 : "d" (c), "0" (ls), "1" (temp));
58#else
59 for (; temp; temp--)
60 *ls++ = c;
61#endif 60#endif
62 s = ls; 61 s = ls;
63 } 62 }
diff --git a/arch/m68k/lib/muldi3.c b/arch/m68k/lib/muldi3.c
index 079bafca073e..79e928a525d0 100644
--- a/arch/m68k/lib/muldi3.c
+++ b/arch/m68k/lib/muldi3.c
@@ -19,17 +19,7 @@ along with GNU CC; see the file COPYING. If not, write to
19the Free Software Foundation, 59 Temple Place - Suite 330, 19the Free Software Foundation, 59 Temple Place - Suite 330,
20Boston, MA 02111-1307, USA. */ 20Boston, MA 02111-1307, USA. */
21 21
22#if defined(__mc68020__) || defined(__mc68030__) || \ 22#if defined(CONFIG_M68000) || defined(CONFIG_COLDFIRE)
23 defined(__mc68040__) || defined(__mc68060__) || defined(__mcpu32__)
24
25#define umul_ppmm(w1, w0, u, v) \
26 __asm__ ("mulu%.l %3,%1:%0" \
27 : "=d" ((USItype)(w0)), \
28 "=d" ((USItype)(w1)) \
29 : "%0" ((USItype)(u)), \
30 "dmi" ((USItype)(v)))
31
32#else
33 23
34#define SI_TYPE_SIZE 32 24#define SI_TYPE_SIZE 32
35#define __BITS4 (SI_TYPE_SIZE / 4) 25#define __BITS4 (SI_TYPE_SIZE / 4)
@@ -61,6 +51,15 @@ Boston, MA 02111-1307, USA. */
61 (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0); \ 51 (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0); \
62 } while (0) 52 } while (0)
63 53
54#else
55
56#define umul_ppmm(w1, w0, u, v) \
57 __asm__ ("mulu%.l %3,%1:%0" \
58 : "=d" ((USItype)(w0)), \
59 "=d" ((USItype)(w1)) \
60 : "%0" ((USItype)(u)), \
61 "dmi" ((USItype)(v)))
62
64#endif 63#endif
65 64
66#define __umulsidi3(u, v) \ 65#define __umulsidi3(u, v) \
diff --git a/arch/mips/configs/mtx1_defconfig b/arch/mips/configs/mtx1_defconfig
index 37862b2ce363..807c97eed8a8 100644
--- a/arch/mips/configs/mtx1_defconfig
+++ b/arch/mips/configs/mtx1_defconfig
@@ -678,7 +678,7 @@ CONFIG_LEDS_TRIGGERS=y
678CONFIG_LEDS_TRIGGER_TIMER=y 678CONFIG_LEDS_TRIGGER_TIMER=y
679CONFIG_LEDS_TRIGGER_HEARTBEAT=y 679CONFIG_LEDS_TRIGGER_HEARTBEAT=y
680CONFIG_LEDS_TRIGGER_DEFAULT_ON=y 680CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
681CONFIG_RTC_CLASS=m 681CONFIG_RTC_CLASS=y
682CONFIG_RTC_INTF_DEV_UIE_EMUL=y 682CONFIG_RTC_INTF_DEV_UIE_EMUL=y
683CONFIG_RTC_DRV_TEST=m 683CONFIG_RTC_DRV_TEST=m
684CONFIG_RTC_DRV_DS1307=m 684CONFIG_RTC_DRV_DS1307=m
diff --git a/arch/powerpc/configs/52xx/pcm030_defconfig b/arch/powerpc/configs/52xx/pcm030_defconfig
index 7f7e4a878602..22e719575c60 100644
--- a/arch/powerpc/configs/52xx/pcm030_defconfig
+++ b/arch/powerpc/configs/52xx/pcm030_defconfig
@@ -85,7 +85,7 @@ CONFIG_USB_OHCI_HCD=m
85CONFIG_USB_OHCI_HCD_PPC_OF_BE=y 85CONFIG_USB_OHCI_HCD_PPC_OF_BE=y
86# CONFIG_USB_OHCI_HCD_PCI is not set 86# CONFIG_USB_OHCI_HCD_PCI is not set
87CONFIG_USB_STORAGE=m 87CONFIG_USB_STORAGE=m
88CONFIG_RTC_CLASS=m 88CONFIG_RTC_CLASS=y
89CONFIG_RTC_DRV_PCF8563=m 89CONFIG_RTC_DRV_PCF8563=m
90CONFIG_EXT2_FS=m 90CONFIG_EXT2_FS=m
91CONFIG_EXT3_FS=m 91CONFIG_EXT3_FS=m
diff --git a/arch/powerpc/configs/ps3_defconfig b/arch/powerpc/configs/ps3_defconfig
index 6472322bf13b..185c292b0f1c 100644
--- a/arch/powerpc/configs/ps3_defconfig
+++ b/arch/powerpc/configs/ps3_defconfig
@@ -141,7 +141,7 @@ CONFIG_USB_EHCI_TT_NEWSCHED=y
141# CONFIG_USB_EHCI_HCD_PPC_OF is not set 141# CONFIG_USB_EHCI_HCD_PPC_OF is not set
142CONFIG_USB_OHCI_HCD=m 142CONFIG_USB_OHCI_HCD=m
143CONFIG_USB_STORAGE=m 143CONFIG_USB_STORAGE=m
144CONFIG_RTC_CLASS=m 144CONFIG_RTC_CLASS=y
145CONFIG_RTC_DRV_PS3=m 145CONFIG_RTC_DRV_PS3=m
146CONFIG_EXT2_FS=m 146CONFIG_EXT2_FS=m
147CONFIG_EXT3_FS=m 147CONFIG_EXT3_FS=m
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index 3a32741cc0ac..513cb1a2e6c8 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -20,6 +20,7 @@
20#include <linux/io.h> 20#include <linux/io.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/usb/r8a66597.h> 22#include <linux/usb/r8a66597.h>
23#include <linux/usb/renesas_usbhs.h>
23#include <linux/i2c.h> 24#include <linux/i2c.h>
24#include <linux/i2c/tsc2007.h> 25#include <linux/i2c/tsc2007.h>
25#include <linux/spi/spi.h> 26#include <linux/spi/spi.h>
@@ -232,6 +233,52 @@ static struct platform_device usb1_common_device = {
232 .resource = usb1_common_resources, 233 .resource = usb1_common_resources,
233}; 234};
234 235
236/*
237 * USBHS
238 */
239static int usbhs_get_id(struct platform_device *pdev)
240{
241 return gpio_get_value(GPIO_PTB3);
242}
243
244static struct renesas_usbhs_platform_info usbhs_info = {
245 .platform_callback = {
246 .get_id = usbhs_get_id,
247 },
248 .driver_param = {
249 .buswait_bwait = 4,
250 .detection_delay = 5,
251 },
252};
253
254static struct resource usbhs_resources[] = {
255 [0] = {
256 .start = 0xa4d90000,
257 .end = 0xa4d90124 - 1,
258 .flags = IORESOURCE_MEM,
259 },
260 [1] = {
261 .start = 66,
262 .end = 66,
263 .flags = IORESOURCE_IRQ,
264 },
265};
266
267static struct platform_device usbhs_device = {
268 .name = "renesas_usbhs",
269 .id = 1,
270 .dev = {
271 .dma_mask = NULL, /* not use dma */
272 .coherent_dma_mask = 0xffffffff,
273 .platform_data = &usbhs_info,
274 },
275 .num_resources = ARRAY_SIZE(usbhs_resources),
276 .resource = usbhs_resources,
277 .archdata = {
278 .hwblk_id = HWBLK_USB1,
279 },
280};
281
235/* LCDC */ 282/* LCDC */
236const static struct fb_videomode ecovec_lcd_modes[] = { 283const static struct fb_videomode ecovec_lcd_modes[] = {
237 { 284 {
@@ -897,6 +944,7 @@ static struct platform_device *ecovec_devices[] __initdata = {
897 &sh_eth_device, 944 &sh_eth_device,
898 &usb0_host_device, 945 &usb0_host_device,
899 &usb1_common_device, 946 &usb1_common_device,
947 &usbhs_device,
900 &lcdc_device, 948 &lcdc_device,
901 &ceu0_device, 949 &ceu0_device,
902 &ceu1_device, 950 &ceu1_device,
diff --git a/arch/sh/boot/compressed/Makefile b/arch/sh/boot/compressed/Makefile
index 780e083e4d17..23bc849d9c64 100644
--- a/arch/sh/boot/compressed/Makefile
+++ b/arch/sh/boot/compressed/Makefile
@@ -27,8 +27,6 @@ IMAGE_OFFSET := $(shell /bin/bash -c 'printf "0x%08x" \
27 $(CONFIG_BOOT_LINK_OFFSET)]') 27 $(CONFIG_BOOT_LINK_OFFSET)]')
28endif 28endif
29 29
30LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
31
32ifeq ($(CONFIG_MCOUNT),y) 30ifeq ($(CONFIG_MCOUNT),y)
33ORIG_CFLAGS := $(KBUILD_CFLAGS) 31ORIG_CFLAGS := $(KBUILD_CFLAGS)
34KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS)) 32KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
@@ -37,7 +35,25 @@ endif
37LDFLAGS_vmlinux := --oformat $(ld-bfd) -Ttext $(IMAGE_OFFSET) -e startup \ 35LDFLAGS_vmlinux := --oformat $(ld-bfd) -Ttext $(IMAGE_OFFSET) -e startup \
38 -T $(obj)/../../kernel/vmlinux.lds 36 -T $(obj)/../../kernel/vmlinux.lds
39 37
40$(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o $(LIBGCC) FORCE 38#
39# Pull in the necessary libgcc bits from the in-kernel implementation.
40#
41lib1funcs-$(CONFIG_SUPERH32) := ashiftrt.S ashldi3.c ashrsi3.S ashlsi3.S \
42 lshrsi3.S
43lib1funcs-obj := \
44 $(addsuffix .o, $(basename $(addprefix $(obj)/, $(lib1funcs-y))))
45
46lib1funcs-dir := $(srctree)/arch/$(SRCARCH)/lib
47ifeq ($(BITS),64)
48 lib1funcs-dir := $(addsuffix $(BITS), $(lib1funcs-dir))
49endif
50
51KBUILD_CFLAGS += -I$(lib1funcs-dir)
52
53$(addprefix $(obj)/,$(lib1funcs-y)): $(obj)/%: $(lib1funcs-dir)/% FORCE
54 $(call cmd,shipped)
55
56$(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o $(lib1funcs-obj) FORCE
41 $(call if_changed,ld) 57 $(call if_changed,ld)
42 @: 58 @:
43 59
diff --git a/arch/sh/configs/titan_defconfig b/arch/sh/configs/titan_defconfig
index 0f558914e760..e2cbd92d520b 100644
--- a/arch/sh/configs/titan_defconfig
+++ b/arch/sh/configs/titan_defconfig
@@ -227,7 +227,7 @@ CONFIG_USB_SERIAL=m
227CONFIG_USB_SERIAL_GENERIC=y 227CONFIG_USB_SERIAL_GENERIC=y
228CONFIG_USB_SERIAL_ARK3116=m 228CONFIG_USB_SERIAL_ARK3116=m
229CONFIG_USB_SERIAL_PL2303=m 229CONFIG_USB_SERIAL_PL2303=m
230CONFIG_RTC_CLASS=m 230CONFIG_RTC_CLASS=y
231CONFIG_RTC_DRV_SH=m 231CONFIG_RTC_DRV_SH=m
232CONFIG_EXT2_FS=y 232CONFIG_EXT2_FS=y
233CONFIG_EXT3_FS=y 233CONFIG_EXT3_FS=y
diff --git a/arch/sh/include/asm/cmpxchg-grb.h b/arch/sh/include/asm/cmpxchg-grb.h
index 4676bf57693a..f848dec9e483 100644
--- a/arch/sh/include/asm/cmpxchg-grb.h
+++ b/arch/sh/include/asm/cmpxchg-grb.h
@@ -15,8 +15,9 @@ static inline unsigned long xchg_u32(volatile u32 *m, unsigned long val)
15 " mov.l %2, @%1 \n\t" /* store new value */ 15 " mov.l %2, @%1 \n\t" /* store new value */
16 "1: mov r1, r15 \n\t" /* LOGOUT */ 16 "1: mov r1, r15 \n\t" /* LOGOUT */
17 : "=&r" (retval), 17 : "=&r" (retval),
18 "+r" (m) 18 "+r" (m),
19 : "r" (val) 19 "+r" (val) /* inhibit r15 overloading */
20 :
20 : "memory", "r0", "r1"); 21 : "memory", "r0", "r1");
21 22
22 return retval; 23 return retval;
@@ -36,8 +37,9 @@ static inline unsigned long xchg_u8(volatile u8 *m, unsigned long val)
36 " mov.b %2, @%1 \n\t" /* store new value */ 37 " mov.b %2, @%1 \n\t" /* store new value */
37 "1: mov r1, r15 \n\t" /* LOGOUT */ 38 "1: mov r1, r15 \n\t" /* LOGOUT */
38 : "=&r" (retval), 39 : "=&r" (retval),
39 "+r" (m) 40 "+r" (m),
40 : "r" (val) 41 "+r" (val) /* inhibit r15 overloading */
42 :
41 : "memory" , "r0", "r1"); 43 : "memory" , "r0", "r1");
42 44
43 return retval; 45 return retval;
@@ -54,13 +56,14 @@ static inline unsigned long __cmpxchg_u32(volatile int *m, unsigned long old,
54 " nop \n\t" 56 " nop \n\t"
55 " mov r15, r1 \n\t" /* r1 = saved sp */ 57 " mov r15, r1 \n\t" /* r1 = saved sp */
56 " mov #-8, r15 \n\t" /* LOGIN */ 58 " mov #-8, r15 \n\t" /* LOGIN */
57 " mov.l @%1, %0 \n\t" /* load old value */ 59 " mov.l @%3, %0 \n\t" /* load old value */
58 " cmp/eq %0, %2 \n\t" 60 " cmp/eq %0, %1 \n\t"
59 " bf 1f \n\t" /* if not equal */ 61 " bf 1f \n\t" /* if not equal */
60 " mov.l %3, @%1 \n\t" /* store new value */ 62 " mov.l %2, @%3 \n\t" /* store new value */
61 "1: mov r1, r15 \n\t" /* LOGOUT */ 63 "1: mov r1, r15 \n\t" /* LOGOUT */
62 : "=&r" (retval) 64 : "=&r" (retval),
63 : "r" (m), "r" (old), "r" (new) 65 "+r" (old), "+r" (new) /* old or new can be r15 */
66 : "r" (m)
64 : "memory" , "r0", "r1", "t"); 67 : "memory" , "r0", "r1", "t");
65 68
66 return retval; 69 return retval;
diff --git a/arch/sh/include/asm/processor_64.h b/arch/sh/include/asm/processor_64.h
index 2a541ddb5a1b..e25c4c7d6b63 100644
--- a/arch/sh/include/asm/processor_64.h
+++ b/arch/sh/include/asm/processor_64.h
@@ -150,7 +150,6 @@ struct thread_struct {
150#define SR_USER (SR_MMU | SR_FD) 150#define SR_USER (SR_MMU | SR_FD)
151 151
152#define start_thread(_regs, new_pc, new_sp) \ 152#define start_thread(_regs, new_pc, new_sp) \
153 set_fs(USER_DS); \
154 _regs->sr = SR_USER; /* User mode. */ \ 153 _regs->sr = SR_USER; /* User mode. */ \
155 _regs->pc = new_pc - 4; /* Compensate syscall exit */ \ 154 _regs->pc = new_pc - 4; /* Compensate syscall exit */ \
156 _regs->pc |= 1; /* Set SHmedia ! */ \ 155 _regs->pc |= 1; /* Set SHmedia ! */ \
diff --git a/arch/sh/include/cpu-sh4/cpu/sh7724.h b/arch/sh/include/cpu-sh4/cpu/sh7724.h
index 3daef8ecbc63..cbc47e6bcab5 100644
--- a/arch/sh/include/cpu-sh4/cpu/sh7724.h
+++ b/arch/sh/include/cpu-sh4/cpu/sh7724.h
@@ -298,6 +298,14 @@ enum {
298 SHDMA_SLAVE_SCIF4_RX, 298 SHDMA_SLAVE_SCIF4_RX,
299 SHDMA_SLAVE_SCIF5_TX, 299 SHDMA_SLAVE_SCIF5_TX,
300 SHDMA_SLAVE_SCIF5_RX, 300 SHDMA_SLAVE_SCIF5_RX,
301 SHDMA_SLAVE_USB0D0_TX,
302 SHDMA_SLAVE_USB0D0_RX,
303 SHDMA_SLAVE_USB0D1_TX,
304 SHDMA_SLAVE_USB0D1_RX,
305 SHDMA_SLAVE_USB1D0_TX,
306 SHDMA_SLAVE_USB1D0_RX,
307 SHDMA_SLAVE_USB1D1_TX,
308 SHDMA_SLAVE_USB1D1_RX,
301 SHDMA_SLAVE_SDHI0_TX, 309 SHDMA_SLAVE_SDHI0_TX,
302 SHDMA_SLAVE_SDHI0_RX, 310 SHDMA_SLAVE_SDHI0_RX,
303 SHDMA_SLAVE_SDHI1_TX, 311 SHDMA_SLAVE_SDHI1_TX,
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7724.c b/arch/sh/kernel/cpu/sh4a/setup-sh7724.c
index 0333fe9e3881..134a397b1918 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7724.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7724.c
@@ -93,6 +93,46 @@ static const struct sh_dmae_slave_config sh7724_dmae_slaves[] = {
93 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 93 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT),
94 .mid_rid = 0x36, 94 .mid_rid = 0x36,
95 }, { 95 }, {
96 .slave_id = SHDMA_SLAVE_USB0D0_TX,
97 .addr = 0xA4D80100,
98 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT),
99 .mid_rid = 0x73,
100 }, {
101 .slave_id = SHDMA_SLAVE_USB0D0_RX,
102 .addr = 0xA4D80100,
103 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT),
104 .mid_rid = 0x73,
105 }, {
106 .slave_id = SHDMA_SLAVE_USB0D1_TX,
107 .addr = 0xA4D80120,
108 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT),
109 .mid_rid = 0x77,
110 }, {
111 .slave_id = SHDMA_SLAVE_USB0D1_RX,
112 .addr = 0xA4D80120,
113 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT),
114 .mid_rid = 0x77,
115 }, {
116 .slave_id = SHDMA_SLAVE_USB1D0_TX,
117 .addr = 0xA4D90100,
118 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT),
119 .mid_rid = 0xab,
120 }, {
121 .slave_id = SHDMA_SLAVE_USB1D0_RX,
122 .addr = 0xA4D90100,
123 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT),
124 .mid_rid = 0xab,
125 }, {
126 .slave_id = SHDMA_SLAVE_USB1D1_TX,
127 .addr = 0xA4D90120,
128 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT),
129 .mid_rid = 0xaf,
130 }, {
131 .slave_id = SHDMA_SLAVE_USB1D1_RX,
132 .addr = 0xA4D90120,
133 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT),
134 .mid_rid = 0xaf,
135 }, {
96 .slave_id = SHDMA_SLAVE_SDHI0_TX, 136 .slave_id = SHDMA_SLAVE_SDHI0_TX,
97 .addr = 0x04ce0030, 137 .addr = 0x04ce0030,
98 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT), 138 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT),
diff --git a/arch/sh/kernel/process_32.c b/arch/sh/kernel/process_32.c
index b473f0c06fbc..aaf6d59c2012 100644
--- a/arch/sh/kernel/process_32.c
+++ b/arch/sh/kernel/process_32.c
@@ -102,8 +102,6 @@ EXPORT_SYMBOL(kernel_thread);
102void start_thread(struct pt_regs *regs, unsigned long new_pc, 102void start_thread(struct pt_regs *regs, unsigned long new_pc,
103 unsigned long new_sp) 103 unsigned long new_sp)
104{ 104{
105 set_fs(USER_DS);
106
107 regs->pr = 0; 105 regs->pr = 0;
108 regs->sr = SR_FD; 106 regs->sr = SR_FD;
109 regs->pc = new_pc; 107 regs->pc = new_pc;
diff --git a/arch/sh/mm/cache-debugfs.c b/arch/sh/mm/cache-debugfs.c
index 52411462c409..115725198038 100644
--- a/arch/sh/mm/cache-debugfs.c
+++ b/arch/sh/mm/cache-debugfs.c
@@ -26,9 +26,9 @@ static int cache_seq_show(struct seq_file *file, void *iter)
26{ 26{
27 unsigned int cache_type = (unsigned int)file->private; 27 unsigned int cache_type = (unsigned int)file->private;
28 struct cache_info *cache; 28 struct cache_info *cache;
29 unsigned int waysize, way, cache_size; 29 unsigned int waysize, way;
30 unsigned long ccr, base; 30 unsigned long ccr;
31 static unsigned long addrstart = 0; 31 unsigned long addrstart = 0;
32 32
33 /* 33 /*
34 * Go uncached immediately so we don't skew the results any 34 * Go uncached immediately so we don't skew the results any
@@ -45,28 +45,13 @@ static int cache_seq_show(struct seq_file *file, void *iter)
45 } 45 }
46 46
47 if (cache_type == CACHE_TYPE_DCACHE) { 47 if (cache_type == CACHE_TYPE_DCACHE) {
48 base = CACHE_OC_ADDRESS_ARRAY; 48 addrstart = CACHE_OC_ADDRESS_ARRAY;
49 cache = &current_cpu_data.dcache; 49 cache = &current_cpu_data.dcache;
50 } else { 50 } else {
51 base = CACHE_IC_ADDRESS_ARRAY; 51 addrstart = CACHE_IC_ADDRESS_ARRAY;
52 cache = &current_cpu_data.icache; 52 cache = &current_cpu_data.icache;
53 } 53 }
54 54
55 /*
56 * Due to the amount of data written out (depending on the cache size),
57 * we may be iterated over multiple times. In this case, keep track of
58 * the entry position in addrstart, and rewind it when we've hit the
59 * end of the cache.
60 *
61 * Likewise, the same code is used for multiple caches, so care must
62 * be taken for bouncing addrstart back and forth so the appropriate
63 * cache is hit.
64 */
65 cache_size = cache->ways * cache->sets * cache->linesz;
66 if (((addrstart & 0xff000000) != base) ||
67 (addrstart & 0x00ffffff) > cache_size)
68 addrstart = base;
69
70 waysize = cache->sets; 55 waysize = cache->sets;
71 56
72 /* 57 /*
diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
index b511a011b7d0..adc66c3a1fef 100644
--- a/arch/x86/kernel/apic/x2apic_uv_x.c
+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
@@ -632,14 +632,14 @@ late_initcall(uv_init_heartbeat);
632 632
633/* Direct Legacy VGA I/O traffic to designated IOH */ 633/* Direct Legacy VGA I/O traffic to designated IOH */
634int uv_set_vga_state(struct pci_dev *pdev, bool decode, 634int uv_set_vga_state(struct pci_dev *pdev, bool decode,
635 unsigned int command_bits, bool change_bridge) 635 unsigned int command_bits, u32 flags)
636{ 636{
637 int domain, bus, rc; 637 int domain, bus, rc;
638 638
639 PR_DEVEL("devfn %x decode %d cmd %x chg_brdg %d\n", 639 PR_DEVEL("devfn %x decode %d cmd %x flags %d\n",
640 pdev->devfn, decode, command_bits, change_bridge); 640 pdev->devfn, decode, command_bits, flags);
641 641
642 if (!change_bridge) 642 if (!(flags & PCI_VGA_STATE_CHANGE_BRIDGE))
643 return 0; 643 return 0;
644 644
645 if ((command_bits & PCI_COMMAND_IO) == 0) 645 if ((command_bits & PCI_COMMAND_IO) == 0)
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 2e4928d45a2d..e1ba8cb24e4e 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -337,7 +337,7 @@ EXPORT_SYMBOL(boot_option_idle_override);
337 * Powermanagement idle function, if any.. 337 * Powermanagement idle function, if any..
338 */ 338 */
339void (*pm_idle)(void); 339void (*pm_idle)(void);
340#if defined(CONFIG_APM_MODULE) && defined(CONFIG_APM_CPU_IDLE) 340#ifdef CONFIG_APM_MODULE
341EXPORT_SYMBOL(pm_idle); 341EXPORT_SYMBOL(pm_idle);
342#endif 342#endif
343 343
@@ -399,7 +399,7 @@ void default_idle(void)
399 cpu_relax(); 399 cpu_relax();
400 } 400 }
401} 401}
402#if defined(CONFIG_APM_MODULE) && defined(CONFIG_APM_CPU_IDLE) 402#ifdef CONFIG_APM_MODULE
403EXPORT_SYMBOL(default_idle); 403EXPORT_SYMBOL(default_idle);
404#endif 404#endif
405 405
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 051474c65b78..34d6a1cab8de 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -163,11 +163,32 @@ static irqreturn_t hpet_interrupt(int irq, void *data)
163 * This has the effect of treating non-periodic like periodic. 163 * This has the effect of treating non-periodic like periodic.
164 */ 164 */
165 if ((devp->hd_flags & (HPET_IE | HPET_PERIODIC)) == HPET_IE) { 165 if ((devp->hd_flags & (HPET_IE | HPET_PERIODIC)) == HPET_IE) {
166 unsigned long m, t; 166 unsigned long m, t, mc, base, k;
167 struct hpet __iomem *hpet = devp->hd_hpet;
168 struct hpets *hpetp = devp->hd_hpets;
167 169
168 t = devp->hd_ireqfreq; 170 t = devp->hd_ireqfreq;
169 m = read_counter(&devp->hd_timer->hpet_compare); 171 m = read_counter(&devp->hd_timer->hpet_compare);
170 write_counter(t + m, &devp->hd_timer->hpet_compare); 172 mc = read_counter(&hpet->hpet_mc);
173 /* The time for the next interrupt would logically be t + m,
174 * however, if we are very unlucky and the interrupt is delayed
175 * for longer than t then we will completely miss the next
176 * interrupt if we set t + m and an application will hang.
177 * Therefore we need to make a more complex computation assuming
178 * that there exists a k for which the following is true:
179 * k * t + base < mc + delta
180 * (k + 1) * t + base > mc + delta
181 * where t is the interval in hpet ticks for the given freq,
182 * base is the theoretical start value 0 < base < t,
183 * mc is the main counter value at the time of the interrupt,
184 * delta is the time it takes to write the a value to the
185 * comparator.
186 * k may then be computed as (mc - base + delta) / t .
187 */
188 base = mc % t;
189 k = (mc - base + hpetp->hp_delta) / t;
190 write_counter(t * (k + 1) + base,
191 &devp->hd_timer->hpet_compare);
171 } 192 }
172 193
173 if (devp->hd_flags & HPET_SHARED_IRQ) 194 if (devp->hd_flags & HPET_SHARED_IRQ)
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index b60a4c263686..faf7c5217848 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -298,11 +298,13 @@ static int cpufreq_stat_notifier_trans(struct notifier_block *nb,
298 old_index = stat->last_index; 298 old_index = stat->last_index;
299 new_index = freq_table_get_index(stat, freq->new); 299 new_index = freq_table_get_index(stat, freq->new);
300 300
301 cpufreq_stats_update(freq->cpu); 301 /* We can't do stat->time_in_state[-1]= .. */
302 if (old_index == new_index) 302 if (old_index == -1 || new_index == -1)
303 return 0; 303 return 0;
304 304
305 if (old_index == -1 || new_index == -1) 305 cpufreq_stats_update(freq->cpu);
306
307 if (old_index == new_index)
306 return 0; 308 return 0;
307 309
308 spin_lock(&cpufreq_stats_lock); 310 spin_lock(&cpufreq_stats_lock);
@@ -387,6 +389,7 @@ static void __exit cpufreq_stats_exit(void)
387 unregister_hotcpu_notifier(&cpufreq_stat_cpu_notifier); 389 unregister_hotcpu_notifier(&cpufreq_stat_cpu_notifier);
388 for_each_online_cpu(cpu) { 390 for_each_online_cpu(cpu) {
389 cpufreq_stats_free_table(cpu); 391 cpufreq_stats_free_table(cpu);
392 cpufreq_stats_free_sysfs(cpu);
390 } 393 }
391} 394}
392 395
diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
index 83479b6fb9a1..bce576d7478e 100644
--- a/drivers/cpufreq/powernow-k8.c
+++ b/drivers/cpufreq/powernow-k8.c
@@ -1079,6 +1079,9 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data,
1079 } 1079 }
1080 1080
1081 res = transition_fid_vid(data, fid, vid); 1081 res = transition_fid_vid(data, fid, vid);
1082 if (res)
1083 return res;
1084
1082 freqs.new = find_khz_freq_from_fid(data->currfid); 1085 freqs.new = find_khz_freq_from_fid(data->currfid);
1083 1086
1084 for_each_cpu(i, data->available_cores) { 1087 for_each_cpu(i, data->available_cores) {
@@ -1101,7 +1104,8 @@ static int transition_frequency_pstate(struct powernow_k8_data *data,
1101 /* get MSR index for hardware pstate transition */ 1104 /* get MSR index for hardware pstate transition */
1102 pstate = index & HW_PSTATE_MASK; 1105 pstate = index & HW_PSTATE_MASK;
1103 if (pstate > data->max_hw_pstate) 1106 if (pstate > data->max_hw_pstate)
1104 return 0; 1107 return -EINVAL;
1108
1105 freqs.old = find_khz_freq_from_pstate(data->powernow_table, 1109 freqs.old = find_khz_freq_from_pstate(data->powernow_table,
1106 data->currpstate); 1110 data->currpstate);
1107 freqs.new = find_khz_freq_from_pstate(data->powernow_table, pstate); 1111 freqs.new = find_khz_freq_from_pstate(data->powernow_table, pstate);
diff --git a/drivers/dma/shdma.c b/drivers/dma/shdma.c
index 2a638f9f09a2..028330044201 100644
--- a/drivers/dma/shdma.c
+++ b/drivers/dma/shdma.c
@@ -1221,6 +1221,11 @@ static int __init sh_dmae_probe(struct platform_device *pdev)
1221 } else { 1221 } else {
1222 do { 1222 do {
1223 for (i = chanirq_res->start; i <= chanirq_res->end; i++) { 1223 for (i = chanirq_res->start; i <= chanirq_res->end; i++) {
1224 if (irq_cnt >= SH_DMAC_MAX_CHANNELS) {
1225 irq_cap = 1;
1226 break;
1227 }
1228
1224 if ((errirq_res->flags & IORESOURCE_BITS) == 1229 if ((errirq_res->flags & IORESOURCE_BITS) ==
1225 IORESOURCE_IRQ_SHAREABLE) 1230 IORESOURCE_IRQ_SHAREABLE)
1226 chan_flag[irq_cnt] = IRQF_SHARED; 1231 chan_flag[irq_cnt] = IRQF_SHARED;
@@ -1230,15 +1235,11 @@ static int __init sh_dmae_probe(struct platform_device *pdev)
1230 "Found IRQ %d for channel %d\n", 1235 "Found IRQ %d for channel %d\n",
1231 i, irq_cnt); 1236 i, irq_cnt);
1232 chan_irq[irq_cnt++] = i; 1237 chan_irq[irq_cnt++] = i;
1233
1234 if (irq_cnt >= SH_DMAC_MAX_CHANNELS)
1235 break;
1236 } 1238 }
1237 1239
1238 if (irq_cnt >= SH_DMAC_MAX_CHANNELS) { 1240 if (irq_cnt >= SH_DMAC_MAX_CHANNELS)
1239 irq_cap = 1;
1240 break; 1241 break;
1241 } 1242
1242 chanirq_res = platform_get_resource(pdev, 1243 chanirq_res = platform_get_resource(pdev,
1243 IORESOURCE_IRQ, ++irqres); 1244 IORESOURCE_IRQ, ++irqres);
1244 } while (irq_cnt < pdata->channel_num && chanirq_res); 1245 } while (irq_cnt < pdata->channel_num && chanirq_res);
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 01f74a8459d9..35bebde23e83 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -469,8 +469,9 @@ static inline void set_24xx_gpio_triggering(struct gpio_bank *bank, int gpio,
469 + OMAP24XX_GPIO_CLEARWKUENA); 469 + OMAP24XX_GPIO_CLEARWKUENA);
470 } 470 }
471 } 471 }
472 /* This part needs to be executed always for OMAP34xx */ 472 /* This part needs to be executed always for OMAP{34xx, 44xx} */
473 if (cpu_is_omap34xx() || (bank->non_wakeup_gpios & gpio_bit)) { 473 if (cpu_is_omap34xx() || cpu_is_omap44xx() ||
474 (bank->non_wakeup_gpios & gpio_bit)) {
474 /* 475 /*
475 * Log the edge gpio and manually trigger the IRQ 476 * Log the edge gpio and manually trigger the IRQ
476 * after resume if the input level changes 477 * after resume if the input level changes
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 3e257a50bf56..61e1ef90d4e5 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -46,10 +46,11 @@ static struct drm_map_list *drm_find_matching_map(struct drm_device *dev,
46 list_for_each_entry(entry, &dev->maplist, head) { 46 list_for_each_entry(entry, &dev->maplist, head) {
47 /* 47 /*
48 * Because the kernel-userspace ABI is fixed at a 32-bit offset 48 * Because the kernel-userspace ABI is fixed at a 32-bit offset
49 * while PCI resources may live above that, we ignore the map 49 * while PCI resources may live above that, we only compare the
50 * offset for maps of type _DRM_FRAMEBUFFER or _DRM_REGISTERS. 50 * lower 32 bits of the map offset for maps of type
51 * It is assumed that each driver will have only one resource of 51 * _DRM_FRAMEBUFFER or _DRM_REGISTERS.
52 * each type. 52 * It is assumed that if a driver have more than one resource
53 * of each type, the lower 32 bits are different.
53 */ 54 */
54 if (!entry->map || 55 if (!entry->map ||
55 map->type != entry->map->type || 56 map->type != entry->map->type ||
@@ -59,9 +60,12 @@ static struct drm_map_list *drm_find_matching_map(struct drm_device *dev,
59 case _DRM_SHM: 60 case _DRM_SHM:
60 if (map->flags != _DRM_CONTAINS_LOCK) 61 if (map->flags != _DRM_CONTAINS_LOCK)
61 break; 62 break;
63 return entry;
62 case _DRM_REGISTERS: 64 case _DRM_REGISTERS:
63 case _DRM_FRAME_BUFFER: 65 case _DRM_FRAME_BUFFER:
64 return entry; 66 if ((entry->map->offset & 0xffffffff) ==
67 (map->offset & 0xffffffff))
68 return entry;
65 default: /* Make gcc happy */ 69 default: /* Make gcc happy */
66 ; 70 ;
67 } 71 }
@@ -183,9 +187,6 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
183 return -EINVAL; 187 return -EINVAL;
184 } 188 }
185#endif 189#endif
186#ifdef __alpha__
187 map->offset += dev->hose->mem_space->start;
188#endif
189 /* Some drivers preinitialize some maps, without the X Server 190 /* Some drivers preinitialize some maps, without the X Server
190 * needing to be aware of it. Therefore, we just return success 191 * needing to be aware of it. Therefore, we just return success
191 * when the server tries to create a duplicate map. 192 * when the server tries to create a duplicate map.
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 872747c5a544..21058e6ad2b8 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -1113,7 +1113,7 @@ int drm_mode_getresources(struct drm_device *dev, void *data,
1113 if (card_res->count_fbs >= fb_count) { 1113 if (card_res->count_fbs >= fb_count) {
1114 copied = 0; 1114 copied = 0;
1115 fb_id = (uint32_t __user *)(unsigned long)card_res->fb_id_ptr; 1115 fb_id = (uint32_t __user *)(unsigned long)card_res->fb_id_ptr;
1116 list_for_each_entry(fb, &file_priv->fbs, head) { 1116 list_for_each_entry(fb, &file_priv->fbs, filp_head) {
1117 if (put_user(fb->base.id, fb_id + copied)) { 1117 if (put_user(fb->base.id, fb_id + copied)) {
1118 ret = -EFAULT; 1118 ret = -EFAULT;
1119 goto out; 1119 goto out;
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 0a9357c66ff8..09292193dafe 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -184,9 +184,9 @@ drm_edid_block_valid(u8 *raw_edid)
184 184
185bad: 185bad:
186 if (raw_edid) { 186 if (raw_edid) {
187 DRM_ERROR("Raw EDID:\n"); 187 printk(KERN_ERR "Raw EDID:\n");
188 print_hex_dump_bytes(KERN_ERR, DUMP_PREFIX_NONE, raw_edid, EDID_LENGTH); 188 print_hex_dump_bytes(KERN_ERR, DUMP_PREFIX_NONE, raw_edid, EDID_LENGTH);
189 printk("\n"); 189 printk(KERN_ERR "\n");
190 } 190 }
191 return 0; 191 return 0;
192} 192}
@@ -258,6 +258,17 @@ drm_do_probe_ddc_edid(struct i2c_adapter *adapter, unsigned char *buf,
258 return ret == 2 ? 0 : -1; 258 return ret == 2 ? 0 : -1;
259} 259}
260 260
261static bool drm_edid_is_zero(u8 *in_edid, int length)
262{
263 int i;
264 u32 *raw_edid = (u32 *)in_edid;
265
266 for (i = 0; i < length / 4; i++)
267 if (*(raw_edid + i) != 0)
268 return false;
269 return true;
270}
271
261static u8 * 272static u8 *
262drm_do_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter) 273drm_do_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter)
263{ 274{
@@ -273,6 +284,10 @@ drm_do_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter)
273 goto out; 284 goto out;
274 if (drm_edid_block_valid(block)) 285 if (drm_edid_block_valid(block))
275 break; 286 break;
287 if (i == 0 && drm_edid_is_zero(block, EDID_LENGTH)) {
288 connector->null_edid_counter++;
289 goto carp;
290 }
276 } 291 }
277 if (i == 4) 292 if (i == 4)
278 goto carp; 293 goto carp;
diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
index d61d185cf040..4a058c7af6c0 100644
--- a/drivers/gpu/drm/drm_ioc32.c
+++ b/drivers/gpu/drm/drm_ioc32.c
@@ -28,6 +28,7 @@
28 * IN THE SOFTWARE. 28 * IN THE SOFTWARE.
29 */ 29 */
30#include <linux/compat.h> 30#include <linux/compat.h>
31#include <linux/ratelimit.h>
31 32
32#include "drmP.h" 33#include "drmP.h"
33#include "drm_core.h" 34#include "drm_core.h"
@@ -253,10 +254,10 @@ static int compat_drm_addmap(struct file *file, unsigned int cmd,
253 return -EFAULT; 254 return -EFAULT;
254 255
255 m32.handle = (unsigned long)handle; 256 m32.handle = (unsigned long)handle;
256 if (m32.handle != (unsigned long)handle && printk_ratelimit()) 257 if (m32.handle != (unsigned long)handle)
257 printk(KERN_ERR "compat_drm_addmap truncated handle" 258 printk_ratelimited(KERN_ERR "compat_drm_addmap truncated handle"
258 " %p for type %d offset %x\n", 259 " %p for type %d offset %x\n",
259 handle, m32.type, m32.offset); 260 handle, m32.type, m32.offset);
260 261
261 if (copy_to_user(argp, &m32, sizeof(m32))) 262 if (copy_to_user(argp, &m32, sizeof(m32)))
262 return -EFAULT; 263 return -EFAULT;
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index e1aee4f6a7c6..b6a19cb07caf 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -251,7 +251,7 @@ err:
251} 251}
252 252
253 253
254int drm_pci_irq_by_busid(struct drm_device *dev, struct drm_irq_busid *p) 254static int drm_pci_irq_by_busid(struct drm_device *dev, struct drm_irq_busid *p)
255{ 255{
256 if ((p->busnum >> 8) != drm_get_pci_domain(dev) || 256 if ((p->busnum >> 8) != drm_get_pci_domain(dev) ||
257 (p->busnum & 0xff) != dev->pdev->bus->number || 257 (p->busnum & 0xff) != dev->pdev->bus->number ||
@@ -292,6 +292,7 @@ static struct drm_bus drm_pci_bus = {
292 .get_name = drm_pci_get_name, 292 .get_name = drm_pci_get_name,
293 .set_busid = drm_pci_set_busid, 293 .set_busid = drm_pci_set_busid,
294 .set_unique = drm_pci_set_unique, 294 .set_unique = drm_pci_set_unique,
295 .irq_by_busid = drm_pci_irq_by_busid,
295 .agp_init = drm_pci_agp_init, 296 .agp_init = drm_pci_agp_init,
296}; 297};
297 298
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index 2c3fcbdfd8ff..5db96d45fc71 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -526,7 +526,7 @@ static int drm_mmap_dma(struct file *filp, struct vm_area_struct *vma)
526static resource_size_t drm_core_get_reg_ofs(struct drm_device *dev) 526static resource_size_t drm_core_get_reg_ofs(struct drm_device *dev)
527{ 527{
528#ifdef __alpha__ 528#ifdef __alpha__
529 return dev->hose->dense_mem_base - dev->hose->mem_space->start; 529 return dev->hose->dense_mem_base;
530#else 530#else
531 return 0; 531 return 0;
532#endif 532#endif
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 12d32579b951..94c84d744100 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -465,8 +465,10 @@ i915_gem_shmem_pread_slow(struct drm_device *dev,
465 465
466 page = read_cache_page_gfp(mapping, offset >> PAGE_SHIFT, 466 page = read_cache_page_gfp(mapping, offset >> PAGE_SHIFT,
467 GFP_HIGHUSER | __GFP_RECLAIMABLE); 467 GFP_HIGHUSER | __GFP_RECLAIMABLE);
468 if (IS_ERR(page)) 468 if (IS_ERR(page)) {
469 return PTR_ERR(page); 469 ret = PTR_ERR(page);
470 goto out;
471 }
470 472
471 if (do_bit17_swizzling) { 473 if (do_bit17_swizzling) {
472 slow_shmem_bit17_copy(page, 474 slow_shmem_bit17_copy(page,
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index b9fafe3b045b..9e34a1abeb61 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1740,6 +1740,16 @@ void ironlake_irq_preinstall(struct drm_device *dev)
1740 INIT_WORK(&dev_priv->rps_work, gen6_pm_rps_work); 1740 INIT_WORK(&dev_priv->rps_work, gen6_pm_rps_work);
1741 1741
1742 I915_WRITE(HWSTAM, 0xeffe); 1742 I915_WRITE(HWSTAM, 0xeffe);
1743 if (IS_GEN6(dev)) {
1744 /* Workaround stalls observed on Sandy Bridge GPUs by
1745 * making the blitter command streamer generate a
1746 * write to the Hardware Status Page for
1747 * MI_USER_INTERRUPT. This appears to serialize the
1748 * previous seqno write out before the interrupt
1749 * happens.
1750 */
1751 I915_WRITE(GEN6_BLITTER_HWSTAM, ~GEN6_BLITTER_USER_INTERRUPT);
1752 }
1743 1753
1744 /* XXX hotplug from PCH */ 1754 /* XXX hotplug from PCH */
1745 1755
diff --git a/drivers/gpu/drm/i915/intel_i2c.c b/drivers/gpu/drm/i915/intel_i2c.c
index d3b903bce7c5..d98cee60b602 100644
--- a/drivers/gpu/drm/i915/intel_i2c.c
+++ b/drivers/gpu/drm/i915/intel_i2c.c
@@ -401,8 +401,7 @@ int intel_setup_gmbus(struct drm_device *dev)
401 bus->reg0 = i | GMBUS_RATE_100KHZ; 401 bus->reg0 = i | GMBUS_RATE_100KHZ;
402 402
403 /* XXX force bit banging until GMBUS is fully debugged */ 403 /* XXX force bit banging until GMBUS is fully debugged */
404 if (IS_GEN2(dev)) 404 bus->force_bit = intel_gpio_create(dev_priv, i);
405 bus->force_bit = intel_gpio_create(dev_priv, i);
406 } 405 }
407 406
408 intel_i2c_reset(dev_priv->dev); 407 intel_i2c_reset(dev_priv->dev);
diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
index 1084fa4d261b..54558a01969a 100644
--- a/drivers/gpu/drm/mga/mga_drv.h
+++ b/drivers/gpu/drm/mga/mga_drv.h
@@ -195,29 +195,10 @@ extern long mga_compat_ioctl(struct file *filp, unsigned int cmd,
195 195
196#define mga_flush_write_combine() DRM_WRITEMEMORYBARRIER() 196#define mga_flush_write_combine() DRM_WRITEMEMORYBARRIER()
197 197
198#if defined(__linux__) && defined(__alpha__)
199#define MGA_BASE(reg) ((unsigned long)(dev_priv->mmio->handle))
200#define MGA_ADDR(reg) (MGA_BASE(reg) + reg)
201
202#define MGA_DEREF(reg) (*(volatile u32 *)MGA_ADDR(reg))
203#define MGA_DEREF8(reg) (*(volatile u8 *)MGA_ADDR(reg))
204
205#define MGA_READ(reg) (_MGA_READ((u32 *)MGA_ADDR(reg)))
206#define MGA_READ8(reg) (_MGA_READ((u8 *)MGA_ADDR(reg)))
207#define MGA_WRITE(reg, val) do { DRM_WRITEMEMORYBARRIER(); MGA_DEREF(reg) = val; } while (0)
208#define MGA_WRITE8(reg, val) do { DRM_WRITEMEMORYBARRIER(); MGA_DEREF8(reg) = val; } while (0)
209
210static inline u32 _MGA_READ(u32 *addr)
211{
212 DRM_MEMORYBARRIER();
213 return *(volatile u32 *)addr;
214}
215#else
216#define MGA_READ8(reg) DRM_READ8(dev_priv->mmio, (reg)) 198#define MGA_READ8(reg) DRM_READ8(dev_priv->mmio, (reg))
217#define MGA_READ(reg) DRM_READ32(dev_priv->mmio, (reg)) 199#define MGA_READ(reg) DRM_READ32(dev_priv->mmio, (reg))
218#define MGA_WRITE8(reg, val) DRM_WRITE8(dev_priv->mmio, (reg), (val)) 200#define MGA_WRITE8(reg, val) DRM_WRITE8(dev_priv->mmio, (reg), (val))
219#define MGA_WRITE(reg, val) DRM_WRITE32(dev_priv->mmio, (reg), (val)) 201#define MGA_WRITE(reg, val) DRM_WRITE32(dev_priv->mmio, (reg), (val))
220#endif
221 202
222#define DWGREG0 0x1c00 203#define DWGREG0 0x1c00
223#define DWGREG0_END 0x1dff 204#define DWGREG0_END 0x1dff
diff --git a/drivers/gpu/drm/radeon/atombios.h b/drivers/gpu/drm/radeon/atombios.h
index 49611e2365d9..1b50ad8919d5 100644
--- a/drivers/gpu/drm/radeon/atombios.h
+++ b/drivers/gpu/drm/radeon/atombios.h
@@ -1200,6 +1200,7 @@ typedef struct _EXTERNAL_ENCODER_CONTROL_PARAMETERS_V3
1200#define EXTERNAL_ENCODER_ACTION_V3_ENCODER_BLANKING_OFF 0x10 1200#define EXTERNAL_ENCODER_ACTION_V3_ENCODER_BLANKING_OFF 0x10
1201#define EXTERNAL_ENCODER_ACTION_V3_ENCODER_BLANKING 0x11 1201#define EXTERNAL_ENCODER_ACTION_V3_ENCODER_BLANKING 0x11
1202#define EXTERNAL_ENCODER_ACTION_V3_DACLOAD_DETECTION 0x12 1202#define EXTERNAL_ENCODER_ACTION_V3_DACLOAD_DETECTION 0x12
1203#define EXTERNAL_ENCODER_ACTION_V3_DDC_SETUP 0x14
1203 1204
1204// ucConfig 1205// ucConfig
1205#define EXTERNAL_ENCODER_CONFIG_V3_DPLINKRATE_MASK 0x03 1206#define EXTERNAL_ENCODER_CONFIG_V3_DPLINKRATE_MASK 0x03
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index 84a69e7fa11e..9541995e4b21 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -671,6 +671,13 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
671 DISPPLL_CONFIG_DUAL_LINK; 671 DISPPLL_CONFIG_DUAL_LINK;
672 } 672 }
673 } 673 }
674 if (radeon_encoder_is_dp_bridge(encoder)) {
675 struct drm_encoder *ext_encoder = radeon_atom_get_external_encoder(encoder);
676 struct radeon_encoder *ext_radeon_encoder = to_radeon_encoder(ext_encoder);
677 args.v3.sInput.ucExtTransmitterID = ext_radeon_encoder->encoder_id;
678 } else
679 args.v3.sInput.ucExtTransmitterID = 0;
680
674 atom_execute_table(rdev->mode_info.atom_context, 681 atom_execute_table(rdev->mode_info.atom_context,
675 index, (uint32_t *)&args); 682 index, (uint32_t *)&args);
676 adjusted_clock = le32_to_cpu(args.v3.sOutput.ulDispPllFreq) * 10; 683 adjusted_clock = le32_to_cpu(args.v3.sOutput.ulDispPllFreq) * 10;
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index 98ea597bc76d..7162b7bacac0 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -88,7 +88,8 @@ u32 evergreen_page_flip(struct radeon_device *rdev, int crtc_id, u64 crtc_base)
88/* get temperature in millidegrees */ 88/* get temperature in millidegrees */
89int evergreen_get_temp(struct radeon_device *rdev) 89int evergreen_get_temp(struct radeon_device *rdev)
90{ 90{
91 u32 temp, toffset, actual_temp = 0; 91 u32 temp, toffset;
92 int actual_temp = 0;
92 93
93 if (rdev->family == CHIP_JUNIPER) { 94 if (rdev->family == CHIP_JUNIPER) {
94 toffset = (RREG32(CG_THERMAL_CTRL) & TOFFSET_MASK) >> 95 toffset = (RREG32(CG_THERMAL_CTRL) & TOFFSET_MASK) >>
@@ -2694,28 +2695,25 @@ static inline u32 evergreen_get_ih_wptr(struct radeon_device *rdev)
2694 2695
2695int evergreen_irq_process(struct radeon_device *rdev) 2696int evergreen_irq_process(struct radeon_device *rdev)
2696{ 2697{
2697 u32 wptr = evergreen_get_ih_wptr(rdev); 2698 u32 wptr;
2698 u32 rptr = rdev->ih.rptr; 2699 u32 rptr;
2699 u32 src_id, src_data; 2700 u32 src_id, src_data;
2700 u32 ring_index; 2701 u32 ring_index;
2701 unsigned long flags; 2702 unsigned long flags;
2702 bool queue_hotplug = false; 2703 bool queue_hotplug = false;
2703 2704
2704 DRM_DEBUG("r600_irq_process start: rptr %d, wptr %d\n", rptr, wptr); 2705 if (!rdev->ih.enabled || rdev->shutdown)
2705 if (!rdev->ih.enabled)
2706 return IRQ_NONE; 2706 return IRQ_NONE;
2707 2707
2708 spin_lock_irqsave(&rdev->ih.lock, flags); 2708 wptr = evergreen_get_ih_wptr(rdev);
2709 rptr = rdev->ih.rptr;
2710 DRM_DEBUG("r600_irq_process start: rptr %d, wptr %d\n", rptr, wptr);
2709 2711
2712 spin_lock_irqsave(&rdev->ih.lock, flags);
2710 if (rptr == wptr) { 2713 if (rptr == wptr) {
2711 spin_unlock_irqrestore(&rdev->ih.lock, flags); 2714 spin_unlock_irqrestore(&rdev->ih.lock, flags);
2712 return IRQ_NONE; 2715 return IRQ_NONE;
2713 } 2716 }
2714 if (rdev->shutdown) {
2715 spin_unlock_irqrestore(&rdev->ih.lock, flags);
2716 return IRQ_NONE;
2717 }
2718
2719restart_ih: 2717restart_ih:
2720 /* display interrupts */ 2718 /* display interrupts */
2721 evergreen_irq_ack(rdev); 2719 evergreen_irq_ack(rdev);
@@ -2944,7 +2942,7 @@ restart_ih:
2944 radeon_fence_process(rdev); 2942 radeon_fence_process(rdev);
2945 break; 2943 break;
2946 case 233: /* GUI IDLE */ 2944 case 233: /* GUI IDLE */
2947 DRM_DEBUG("IH: CP EOP\n"); 2945 DRM_DEBUG("IH: GUI idle\n");
2948 rdev->pm.gui_idle = true; 2946 rdev->pm.gui_idle = true;
2949 wake_up(&rdev->irq.idle_queue); 2947 wake_up(&rdev->irq.idle_queue);
2950 break; 2948 break;
diff --git a/drivers/gpu/drm/radeon/r100_track.h b/drivers/gpu/drm/radeon/r100_track.h
index 2fef9de7f363..686f9dc5d4bd 100644
--- a/drivers/gpu/drm/radeon/r100_track.h
+++ b/drivers/gpu/drm/radeon/r100_track.h
@@ -63,7 +63,7 @@ struct r100_cs_track {
63 unsigned num_arrays; 63 unsigned num_arrays;
64 unsigned max_indx; 64 unsigned max_indx;
65 unsigned color_channel_mask; 65 unsigned color_channel_mask;
66 struct r100_cs_track_array arrays[11]; 66 struct r100_cs_track_array arrays[16];
67 struct r100_cs_track_cb cb[R300_MAX_CB]; 67 struct r100_cs_track_cb cb[R300_MAX_CB];
68 struct r100_cs_track_cb zb; 68 struct r100_cs_track_cb zb;
69 struct r100_cs_track_cb aa; 69 struct r100_cs_track_cb aa;
@@ -146,6 +146,12 @@ static inline int r100_packet3_load_vbpntr(struct radeon_cs_parser *p,
146 ib = p->ib->ptr; 146 ib = p->ib->ptr;
147 track = (struct r100_cs_track *)p->track; 147 track = (struct r100_cs_track *)p->track;
148 c = radeon_get_ib_value(p, idx++) & 0x1F; 148 c = radeon_get_ib_value(p, idx++) & 0x1F;
149 if (c > 16) {
150 DRM_ERROR("Only 16 vertex buffers are allowed %d\n",
151 pkt->opcode);
152 r100_cs_dump_packet(p, pkt);
153 return -EINVAL;
154 }
149 track->num_arrays = c; 155 track->num_arrays = c;
150 for (i = 0; i < (c - 1); i+=2, idx+=3) { 156 for (i = 0; i < (c - 1); i+=2, idx+=3) {
151 r = r100_cs_packet_next_reloc(p, &reloc); 157 r = r100_cs_packet_next_reloc(p, &reloc);
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index d74d4d71437f..dc9fde38ef49 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -3294,27 +3294,26 @@ static inline u32 r600_get_ih_wptr(struct radeon_device *rdev)
3294 3294
3295int r600_irq_process(struct radeon_device *rdev) 3295int r600_irq_process(struct radeon_device *rdev)
3296{ 3296{
3297 u32 wptr = r600_get_ih_wptr(rdev); 3297 u32 wptr;
3298 u32 rptr = rdev->ih.rptr; 3298 u32 rptr;
3299 u32 src_id, src_data; 3299 u32 src_id, src_data;
3300 u32 ring_index; 3300 u32 ring_index;
3301 unsigned long flags; 3301 unsigned long flags;
3302 bool queue_hotplug = false; 3302 bool queue_hotplug = false;
3303 3303
3304 DRM_DEBUG("r600_irq_process start: rptr %d, wptr %d\n", rptr, wptr); 3304 if (!rdev->ih.enabled || rdev->shutdown)
3305 if (!rdev->ih.enabled)
3306 return IRQ_NONE; 3305 return IRQ_NONE;
3307 3306
3307 wptr = r600_get_ih_wptr(rdev);
3308 rptr = rdev->ih.rptr;
3309 DRM_DEBUG("r600_irq_process start: rptr %d, wptr %d\n", rptr, wptr);
3310
3308 spin_lock_irqsave(&rdev->ih.lock, flags); 3311 spin_lock_irqsave(&rdev->ih.lock, flags);
3309 3312
3310 if (rptr == wptr) { 3313 if (rptr == wptr) {
3311 spin_unlock_irqrestore(&rdev->ih.lock, flags); 3314 spin_unlock_irqrestore(&rdev->ih.lock, flags);
3312 return IRQ_NONE; 3315 return IRQ_NONE;
3313 } 3316 }
3314 if (rdev->shutdown) {
3315 spin_unlock_irqrestore(&rdev->ih.lock, flags);
3316 return IRQ_NONE;
3317 }
3318 3317
3319restart_ih: 3318restart_ih:
3320 /* display interrupts */ 3319 /* display interrupts */
@@ -3444,7 +3443,7 @@ restart_ih:
3444 radeon_fence_process(rdev); 3443 radeon_fence_process(rdev);
3445 break; 3444 break;
3446 case 233: /* GUI IDLE */ 3445 case 233: /* GUI IDLE */
3447 DRM_DEBUG("IH: CP EOP\n"); 3446 DRM_DEBUG("IH: GUI idle\n");
3448 rdev->pm.gui_idle = true; 3447 rdev->pm.gui_idle = true;
3449 wake_up(&rdev->irq.idle_queue); 3448 wake_up(&rdev->irq.idle_queue);
3450 break; 3449 break;
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index ba643b576054..27f45579e64b 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -165,6 +165,7 @@ struct radeon_clock {
165 uint32_t default_sclk; 165 uint32_t default_sclk;
166 uint32_t default_dispclk; 166 uint32_t default_dispclk;
167 uint32_t dp_extclk; 167 uint32_t dp_extclk;
168 uint32_t max_pixel_clock;
168}; 169};
169 170
170/* 171/*
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c b/drivers/gpu/drm/radeon/radeon_asic.c
index 9bd162fc9b0c..b2449629537d 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -938,6 +938,13 @@ static struct radeon_asic cayman_asic = {
938int radeon_asic_init(struct radeon_device *rdev) 938int radeon_asic_init(struct radeon_device *rdev)
939{ 939{
940 radeon_register_accessor_init(rdev); 940 radeon_register_accessor_init(rdev);
941
942 /* set the number of crtcs */
943 if (rdev->flags & RADEON_SINGLE_CRTC)
944 rdev->num_crtc = 1;
945 else
946 rdev->num_crtc = 2;
947
941 switch (rdev->family) { 948 switch (rdev->family) {
942 case CHIP_R100: 949 case CHIP_R100:
943 case CHIP_RV100: 950 case CHIP_RV100:
@@ -1017,6 +1024,11 @@ int radeon_asic_init(struct radeon_device *rdev)
1017 case CHIP_JUNIPER: 1024 case CHIP_JUNIPER:
1018 case CHIP_CYPRESS: 1025 case CHIP_CYPRESS:
1019 case CHIP_HEMLOCK: 1026 case CHIP_HEMLOCK:
1027 /* set num crtcs */
1028 if (rdev->family == CHIP_CEDAR)
1029 rdev->num_crtc = 4;
1030 else
1031 rdev->num_crtc = 6;
1020 rdev->asic = &evergreen_asic; 1032 rdev->asic = &evergreen_asic;
1021 break; 1033 break;
1022 case CHIP_PALM: 1034 case CHIP_PALM:
@@ -1027,10 +1039,17 @@ int radeon_asic_init(struct radeon_device *rdev)
1027 case CHIP_BARTS: 1039 case CHIP_BARTS:
1028 case CHIP_TURKS: 1040 case CHIP_TURKS:
1029 case CHIP_CAICOS: 1041 case CHIP_CAICOS:
1042 /* set num crtcs */
1043 if (rdev->family == CHIP_CAICOS)
1044 rdev->num_crtc = 4;
1045 else
1046 rdev->num_crtc = 6;
1030 rdev->asic = &btc_asic; 1047 rdev->asic = &btc_asic;
1031 break; 1048 break;
1032 case CHIP_CAYMAN: 1049 case CHIP_CAYMAN:
1033 rdev->asic = &cayman_asic; 1050 rdev->asic = &cayman_asic;
1051 /* set num crtcs */
1052 rdev->num_crtc = 6;
1034 break; 1053 break;
1035 default: 1054 default:
1036 /* FIXME: not supported yet */ 1055 /* FIXME: not supported yet */
@@ -1042,18 +1061,6 @@ int radeon_asic_init(struct radeon_device *rdev)
1042 rdev->asic->set_memory_clock = NULL; 1061 rdev->asic->set_memory_clock = NULL;
1043 } 1062 }
1044 1063
1045 /* set the number of crtcs */
1046 if (rdev->flags & RADEON_SINGLE_CRTC)
1047 rdev->num_crtc = 1;
1048 else {
1049 if (ASIC_IS_DCE41(rdev))
1050 rdev->num_crtc = 2;
1051 else if (ASIC_IS_DCE4(rdev))
1052 rdev->num_crtc = 6;
1053 else
1054 rdev->num_crtc = 2;
1055 }
1056
1057 return 0; 1064 return 0;
1058} 1065}
1059 1066
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
index 90dfb2b8cf03..fa62a503ae70 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -1246,6 +1246,10 @@ bool radeon_atom_get_clock_info(struct drm_device *dev)
1246 } 1246 }
1247 *dcpll = *p1pll; 1247 *dcpll = *p1pll;
1248 1248
1249 rdev->clock.max_pixel_clock = le16_to_cpu(firmware_info->info.usMaxPixelClock);
1250 if (rdev->clock.max_pixel_clock == 0)
1251 rdev->clock.max_pixel_clock = 40000;
1252
1249 return true; 1253 return true;
1250 } 1254 }
1251 1255
diff --git a/drivers/gpu/drm/radeon/radeon_clocks.c b/drivers/gpu/drm/radeon/radeon_clocks.c
index 5249af8931e6..2d48e7a1474b 100644
--- a/drivers/gpu/drm/radeon/radeon_clocks.c
+++ b/drivers/gpu/drm/radeon/radeon_clocks.c
@@ -117,7 +117,7 @@ static bool __devinit radeon_read_clocks_OF(struct drm_device *dev)
117 p1pll->reference_div = RREG32_PLL(RADEON_PPLL_REF_DIV) & 0x3ff; 117 p1pll->reference_div = RREG32_PLL(RADEON_PPLL_REF_DIV) & 0x3ff;
118 if (p1pll->reference_div < 2) 118 if (p1pll->reference_div < 2)
119 p1pll->reference_div = 12; 119 p1pll->reference_div = 12;
120 p2pll->reference_div = p1pll->reference_div; 120 p2pll->reference_div = p1pll->reference_div;
121 121
122 /* These aren't in the device-tree */ 122 /* These aren't in the device-tree */
123 if (rdev->family >= CHIP_R420) { 123 if (rdev->family >= CHIP_R420) {
@@ -139,6 +139,8 @@ static bool __devinit radeon_read_clocks_OF(struct drm_device *dev)
139 p2pll->pll_out_min = 12500; 139 p2pll->pll_out_min = 12500;
140 p2pll->pll_out_max = 35000; 140 p2pll->pll_out_max = 35000;
141 } 141 }
142 /* not sure what the max should be in all cases */
143 rdev->clock.max_pixel_clock = 35000;
142 144
143 spll->reference_freq = mpll->reference_freq = p1pll->reference_freq; 145 spll->reference_freq = mpll->reference_freq = p1pll->reference_freq;
144 spll->reference_div = mpll->reference_div = 146 spll->reference_div = mpll->reference_div =
@@ -151,7 +153,7 @@ static bool __devinit radeon_read_clocks_OF(struct drm_device *dev)
151 else 153 else
152 rdev->clock.default_sclk = 154 rdev->clock.default_sclk =
153 radeon_legacy_get_engine_clock(rdev); 155 radeon_legacy_get_engine_clock(rdev);
154 156
155 val = of_get_property(dp, "ATY,MCLK", NULL); 157 val = of_get_property(dp, "ATY,MCLK", NULL);
156 if (val && *val) 158 if (val && *val)
157 rdev->clock.default_mclk = (*val) / 10; 159 rdev->clock.default_mclk = (*val) / 10;
@@ -160,7 +162,7 @@ static bool __devinit radeon_read_clocks_OF(struct drm_device *dev)
160 radeon_legacy_get_memory_clock(rdev); 162 radeon_legacy_get_memory_clock(rdev);
161 163
162 DRM_INFO("Using device-tree clock info\n"); 164 DRM_INFO("Using device-tree clock info\n");
163 165
164 return true; 166 return true;
165} 167}
166#else 168#else
diff --git a/drivers/gpu/drm/radeon/radeon_combios.c b/drivers/gpu/drm/radeon/radeon_combios.c
index 5b991f7c6e2a..e4594676a07c 100644
--- a/drivers/gpu/drm/radeon/radeon_combios.c
+++ b/drivers/gpu/drm/radeon/radeon_combios.c
@@ -866,6 +866,11 @@ bool radeon_combios_get_clock_info(struct drm_device *dev)
866 rdev->clock.default_sclk = sclk; 866 rdev->clock.default_sclk = sclk;
867 rdev->clock.default_mclk = mclk; 867 rdev->clock.default_mclk = mclk;
868 868
869 if (RBIOS32(pll_info + 0x16))
870 rdev->clock.max_pixel_clock = RBIOS32(pll_info + 0x16);
871 else
872 rdev->clock.max_pixel_clock = 35000; /* might need something asic specific */
873
869 return true; 874 return true;
870 } 875 }
871 return false; 876 return false;
@@ -1548,10 +1553,12 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1548 (rdev->pdev->subsystem_device == 0x4a48)) { 1553 (rdev->pdev->subsystem_device == 0x4a48)) {
1549 /* Mac X800 */ 1554 /* Mac X800 */
1550 rdev->mode_info.connector_table = CT_MAC_X800; 1555 rdev->mode_info.connector_table = CT_MAC_X800;
1551 } else if ((rdev->pdev->device == 0x4150) && 1556 } else if ((of_machine_is_compatible("PowerMac7,2") ||
1557 of_machine_is_compatible("PowerMac7,3")) &&
1558 (rdev->pdev->device == 0x4150) &&
1552 (rdev->pdev->subsystem_vendor == 0x1002) && 1559 (rdev->pdev->subsystem_vendor == 0x1002) &&
1553 (rdev->pdev->subsystem_device == 0x4150)) { 1560 (rdev->pdev->subsystem_device == 0x4150)) {
1554 /* Mac G5 9600 */ 1561 /* Mac G5 tower 9600 */
1555 rdev->mode_info.connector_table = CT_MAC_G5_9600; 1562 rdev->mode_info.connector_table = CT_MAC_G5_9600;
1556 } else 1563 } else
1557#endif /* CONFIG_PPC_PMAC */ 1564#endif /* CONFIG_PPC_PMAC */
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index ee1dccb3fec9..cbfca3a24fdf 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -44,6 +44,8 @@ extern void
44radeon_legacy_backlight_init(struct radeon_encoder *radeon_encoder, 44radeon_legacy_backlight_init(struct radeon_encoder *radeon_encoder,
45 struct drm_connector *drm_connector); 45 struct drm_connector *drm_connector);
46 46
47bool radeon_connector_encoder_is_dp_bridge(struct drm_connector *connector);
48
47void radeon_connector_hotplug(struct drm_connector *connector) 49void radeon_connector_hotplug(struct drm_connector *connector)
48{ 50{
49 struct drm_device *dev = connector->dev; 51 struct drm_device *dev = connector->dev;
@@ -626,8 +628,14 @@ static int radeon_vga_get_modes(struct drm_connector *connector)
626static int radeon_vga_mode_valid(struct drm_connector *connector, 628static int radeon_vga_mode_valid(struct drm_connector *connector,
627 struct drm_display_mode *mode) 629 struct drm_display_mode *mode)
628{ 630{
631 struct drm_device *dev = connector->dev;
632 struct radeon_device *rdev = dev->dev_private;
633
629 /* XXX check mode bandwidth */ 634 /* XXX check mode bandwidth */
630 /* XXX verify against max DAC output frequency */ 635
636 if ((mode->clock / 10) > rdev->clock.max_pixel_clock)
637 return MODE_CLOCK_HIGH;
638
631 return MODE_OK; 639 return MODE_OK;
632} 640}
633 641
@@ -830,6 +838,13 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
830 if (!radeon_connector->edid) { 838 if (!radeon_connector->edid) {
831 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n", 839 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
832 drm_get_connector_name(connector)); 840 drm_get_connector_name(connector));
841 /* rs690 seems to have a problem with connectors not existing and always
842 * return a block of 0's. If we see this just stop polling on this output */
843 if ((rdev->family == CHIP_RS690 || rdev->family == CHIP_RS740) && radeon_connector->base.null_edid_counter) {
844 ret = connector_status_disconnected;
845 DRM_ERROR("%s: detected RS690 floating bus bug, stopping ddc detect\n", drm_get_connector_name(connector));
846 radeon_connector->ddc_bus = NULL;
847 }
833 } else { 848 } else {
834 radeon_connector->use_digital = !!(radeon_connector->edid->input & DRM_EDID_INPUT_DIGITAL); 849 radeon_connector->use_digital = !!(radeon_connector->edid->input & DRM_EDID_INPUT_DIGITAL);
835 850
@@ -1015,6 +1030,11 @@ static int radeon_dvi_mode_valid(struct drm_connector *connector,
1015 } else 1030 } else
1016 return MODE_CLOCK_HIGH; 1031 return MODE_CLOCK_HIGH;
1017 } 1032 }
1033
1034 /* check against the max pixel clock */
1035 if ((mode->clock / 10) > rdev->clock.max_pixel_clock)
1036 return MODE_CLOCK_HIGH;
1037
1018 return MODE_OK; 1038 return MODE_OK;
1019} 1039}
1020 1040
@@ -1052,10 +1072,11 @@ static int radeon_dp_get_modes(struct drm_connector *connector)
1052{ 1072{
1053 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 1073 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1054 struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; 1074 struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv;
1075 struct drm_encoder *encoder = radeon_best_single_encoder(connector);
1055 int ret; 1076 int ret;
1056 1077
1057 if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { 1078 if ((connector->connector_type == DRM_MODE_CONNECTOR_eDP) ||
1058 struct drm_encoder *encoder; 1079 (connector->connector_type == DRM_MODE_CONNECTOR_LVDS)) {
1059 struct drm_display_mode *mode; 1080 struct drm_display_mode *mode;
1060 1081
1061 if (!radeon_dig_connector->edp_on) 1082 if (!radeon_dig_connector->edp_on)
@@ -1067,7 +1088,6 @@ static int radeon_dp_get_modes(struct drm_connector *connector)
1067 ATOM_TRANSMITTER_ACTION_POWER_OFF); 1088 ATOM_TRANSMITTER_ACTION_POWER_OFF);
1068 1089
1069 if (ret > 0) { 1090 if (ret > 0) {
1070 encoder = radeon_best_single_encoder(connector);
1071 if (encoder) { 1091 if (encoder) {
1072 radeon_fixup_lvds_native_mode(encoder, connector); 1092 radeon_fixup_lvds_native_mode(encoder, connector);
1073 /* add scaled modes */ 1093 /* add scaled modes */
@@ -1091,8 +1111,14 @@ static int radeon_dp_get_modes(struct drm_connector *connector)
1091 /* add scaled modes */ 1111 /* add scaled modes */
1092 radeon_add_common_modes(encoder, connector); 1112 radeon_add_common_modes(encoder, connector);
1093 } 1113 }
1094 } else 1114 } else {
1115 /* need to setup ddc on the bridge */
1116 if (radeon_connector_encoder_is_dp_bridge(connector)) {
1117 if (encoder)
1118 radeon_atom_ext_encoder_setup_ddc(encoder);
1119 }
1095 ret = radeon_ddc_get_modes(radeon_connector); 1120 ret = radeon_ddc_get_modes(radeon_connector);
1121 }
1096 1122
1097 return ret; 1123 return ret;
1098} 1124}
@@ -1176,14 +1202,15 @@ radeon_dp_detect(struct drm_connector *connector, bool force)
1176 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 1202 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1177 enum drm_connector_status ret = connector_status_disconnected; 1203 enum drm_connector_status ret = connector_status_disconnected;
1178 struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; 1204 struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv;
1205 struct drm_encoder *encoder = radeon_best_single_encoder(connector);
1179 1206
1180 if (radeon_connector->edid) { 1207 if (radeon_connector->edid) {
1181 kfree(radeon_connector->edid); 1208 kfree(radeon_connector->edid);
1182 radeon_connector->edid = NULL; 1209 radeon_connector->edid = NULL;
1183 } 1210 }
1184 1211
1185 if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { 1212 if ((connector->connector_type == DRM_MODE_CONNECTOR_eDP) ||
1186 struct drm_encoder *encoder = radeon_best_single_encoder(connector); 1213 (connector->connector_type == DRM_MODE_CONNECTOR_LVDS)) {
1187 if (encoder) { 1214 if (encoder) {
1188 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 1215 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
1189 struct drm_display_mode *native_mode = &radeon_encoder->native_mode; 1216 struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
@@ -1203,6 +1230,11 @@ radeon_dp_detect(struct drm_connector *connector, bool force)
1203 atombios_set_edp_panel_power(connector, 1230 atombios_set_edp_panel_power(connector,
1204 ATOM_TRANSMITTER_ACTION_POWER_OFF); 1231 ATOM_TRANSMITTER_ACTION_POWER_OFF);
1205 } else { 1232 } else {
1233 /* need to setup ddc on the bridge */
1234 if (radeon_connector_encoder_is_dp_bridge(connector)) {
1235 if (encoder)
1236 radeon_atom_ext_encoder_setup_ddc(encoder);
1237 }
1206 radeon_dig_connector->dp_sink_type = radeon_dp_getsinktype(radeon_connector); 1238 radeon_dig_connector->dp_sink_type = radeon_dp_getsinktype(radeon_connector);
1207 if (radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) { 1239 if (radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) {
1208 ret = connector_status_connected; 1240 ret = connector_status_connected;
@@ -1217,6 +1249,16 @@ radeon_dp_detect(struct drm_connector *connector, bool force)
1217 ret = connector_status_connected; 1249 ret = connector_status_connected;
1218 } 1250 }
1219 } 1251 }
1252
1253 if ((ret == connector_status_disconnected) &&
1254 radeon_connector->dac_load_detect) {
1255 struct drm_encoder *encoder = radeon_best_single_encoder(connector);
1256 struct drm_encoder_helper_funcs *encoder_funcs;
1257 if (encoder) {
1258 encoder_funcs = encoder->helper_private;
1259 ret = encoder_funcs->detect(encoder, connector);
1260 }
1261 }
1220 } 1262 }
1221 1263
1222 radeon_connector_update_scratch_regs(connector, ret); 1264 radeon_connector_update_scratch_regs(connector, ret);
@@ -1231,7 +1273,8 @@ static int radeon_dp_mode_valid(struct drm_connector *connector,
1231 1273
1232 /* XXX check mode bandwidth */ 1274 /* XXX check mode bandwidth */
1233 1275
1234 if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { 1276 if ((connector->connector_type == DRM_MODE_CONNECTOR_eDP) ||
1277 (connector->connector_type == DRM_MODE_CONNECTOR_LVDS)) {
1235 struct drm_encoder *encoder = radeon_best_single_encoder(connector); 1278 struct drm_encoder *encoder = radeon_best_single_encoder(connector);
1236 1279
1237 if ((mode->hdisplay < 320) || (mode->vdisplay < 240)) 1280 if ((mode->hdisplay < 320) || (mode->vdisplay < 240))
@@ -1241,7 +1284,7 @@ static int radeon_dp_mode_valid(struct drm_connector *connector,
1241 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 1284 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
1242 struct drm_display_mode *native_mode = &radeon_encoder->native_mode; 1285 struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
1243 1286
1244 /* AVIVO hardware supports downscaling modes larger than the panel 1287 /* AVIVO hardware supports downscaling modes larger than the panel
1245 * to the panel size, but I'm not sure this is desirable. 1288 * to the panel size, but I'm not sure this is desirable.
1246 */ 1289 */
1247 if ((mode->hdisplay > native_mode->hdisplay) || 1290 if ((mode->hdisplay > native_mode->hdisplay) ||
@@ -1390,6 +1433,10 @@ radeon_add_atom_connector(struct drm_device *dev,
1390 default: 1433 default:
1391 connector->interlace_allowed = true; 1434 connector->interlace_allowed = true;
1392 connector->doublescan_allowed = true; 1435 connector->doublescan_allowed = true;
1436 radeon_connector->dac_load_detect = true;
1437 drm_connector_attach_property(&radeon_connector->base,
1438 rdev->mode_info.load_detect_property,
1439 1);
1393 break; 1440 break;
1394 case DRM_MODE_CONNECTOR_DVII: 1441 case DRM_MODE_CONNECTOR_DVII:
1395 case DRM_MODE_CONNECTOR_DVID: 1442 case DRM_MODE_CONNECTOR_DVID:
@@ -1411,6 +1458,12 @@ radeon_add_atom_connector(struct drm_device *dev,
1411 connector->doublescan_allowed = true; 1458 connector->doublescan_allowed = true;
1412 else 1459 else
1413 connector->doublescan_allowed = false; 1460 connector->doublescan_allowed = false;
1461 if (connector_type == DRM_MODE_CONNECTOR_DVII) {
1462 radeon_connector->dac_load_detect = true;
1463 drm_connector_attach_property(&radeon_connector->base,
1464 rdev->mode_info.load_detect_property,
1465 1);
1466 }
1414 break; 1467 break;
1415 case DRM_MODE_CONNECTOR_LVDS: 1468 case DRM_MODE_CONNECTOR_LVDS:
1416 case DRM_MODE_CONNECTOR_eDP: 1469 case DRM_MODE_CONNECTOR_eDP:
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index e680501c78ea..7cfaa7e2f3b5 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -215,6 +215,8 @@ int radeon_wb_init(struct radeon_device *rdev)
215 return r; 215 return r;
216 } 216 }
217 217
218 /* clear wb memory */
219 memset((char *)rdev->wb.wb, 0, RADEON_GPU_PAGE_SIZE);
218 /* disable event_write fences */ 220 /* disable event_write fences */
219 rdev->wb.use_event = false; 221 rdev->wb.use_event = false;
220 /* disabled via module param */ 222 /* disabled via module param */
diff --git a/drivers/gpu/drm/radeon/radeon_encoders.c b/drivers/gpu/drm/radeon/radeon_encoders.c
index 03f124d626c2..b293487e5aa3 100644
--- a/drivers/gpu/drm/radeon/radeon_encoders.c
+++ b/drivers/gpu/drm/radeon/radeon_encoders.c
@@ -367,7 +367,8 @@ static bool radeon_atom_mode_fixup(struct drm_encoder *encoder,
367 } 367 }
368 368
369 if (ASIC_IS_DCE3(rdev) && 369 if (ASIC_IS_DCE3(rdev) &&
370 (radeon_encoder->active_device & (ATOM_DEVICE_DFP_SUPPORT | ATOM_DEVICE_LCD_SUPPORT))) { 370 ((radeon_encoder->active_device & (ATOM_DEVICE_DFP_SUPPORT | ATOM_DEVICE_LCD_SUPPORT)) ||
371 radeon_encoder_is_dp_bridge(encoder))) {
371 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder); 372 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
372 radeon_dp_set_link_config(connector, mode); 373 radeon_dp_set_link_config(connector, mode);
373 } 374 }
@@ -660,21 +661,16 @@ atombios_get_encoder_mode(struct drm_encoder *encoder)
660 if (radeon_encoder_is_dp_bridge(encoder)) 661 if (radeon_encoder_is_dp_bridge(encoder))
661 return ATOM_ENCODER_MODE_DP; 662 return ATOM_ENCODER_MODE_DP;
662 663
664 /* DVO is always DVO */
665 if (radeon_encoder->encoder_id == ATOM_ENCODER_MODE_DVO)
666 return ATOM_ENCODER_MODE_DVO;
667
663 connector = radeon_get_connector_for_encoder(encoder); 668 connector = radeon_get_connector_for_encoder(encoder);
664 if (!connector) { 669 /* if we don't have an active device yet, just use one of
665 switch (radeon_encoder->encoder_id) { 670 * the connectors tied to the encoder.
666 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY: 671 */
667 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1: 672 if (!connector)
668 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2: 673 connector = radeon_get_connector_for_encoder_init(encoder);
669 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
670 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1:
671 return ATOM_ENCODER_MODE_DVI;
672 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1:
673 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2:
674 default:
675 return ATOM_ENCODER_MODE_CRT;
676 }
677 }
678 radeon_connector = to_radeon_connector(connector); 674 radeon_connector = to_radeon_connector(connector);
679 675
680 switch (connector->connector_type) { 676 switch (connector->connector_type) {
@@ -1094,9 +1090,10 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
1094 break; 1090 break;
1095 } 1091 }
1096 1092
1097 if (is_dp) 1093 if (is_dp) {
1098 args.v2.acConfig.fCoherentMode = 1; 1094 args.v2.acConfig.fCoherentMode = 1;
1099 else if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { 1095 args.v2.acConfig.fDPConnector = 1;
1096 } else if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) {
1100 if (dig->coherent_mode) 1097 if (dig->coherent_mode)
1101 args.v2.acConfig.fCoherentMode = 1; 1098 args.v2.acConfig.fCoherentMode = 1;
1102 if (radeon_encoder->pixel_clock > 165000) 1099 if (radeon_encoder->pixel_clock > 165000)
@@ -1435,7 +1432,11 @@ radeon_atom_encoder_dpms(struct drm_encoder *encoder, int mode)
1435 if (is_dig) { 1432 if (is_dig) {
1436 switch (mode) { 1433 switch (mode) {
1437 case DRM_MODE_DPMS_ON: 1434 case DRM_MODE_DPMS_ON:
1438 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0); 1435 /* some early dce3.2 boards have a bug in their transmitter control table */
1436 if ((rdev->family == CHIP_RV710) || (rdev->family == CHIP_RV730))
1437 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE, 0, 0);
1438 else
1439 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0);
1439 if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_DP) { 1440 if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_DP) {
1440 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder); 1441 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
1441 1442
@@ -1526,26 +1527,29 @@ radeon_atom_encoder_dpms(struct drm_encoder *encoder, int mode)
1526 } 1527 }
1527 1528
1528 if (ext_encoder) { 1529 if (ext_encoder) {
1529 int action;
1530
1531 switch (mode) { 1530 switch (mode) {
1532 case DRM_MODE_DPMS_ON: 1531 case DRM_MODE_DPMS_ON:
1533 default: 1532 default:
1534 if (ASIC_IS_DCE41(rdev)) 1533 if (ASIC_IS_DCE41(rdev)) {
1535 action = EXTERNAL_ENCODER_ACTION_V3_ENABLE_OUTPUT; 1534 atombios_external_encoder_setup(encoder, ext_encoder,
1536 else 1535 EXTERNAL_ENCODER_ACTION_V3_ENABLE_OUTPUT);
1537 action = ATOM_ENABLE; 1536 atombios_external_encoder_setup(encoder, ext_encoder,
1537 EXTERNAL_ENCODER_ACTION_V3_ENCODER_BLANKING_OFF);
1538 } else
1539 atombios_external_encoder_setup(encoder, ext_encoder, ATOM_ENABLE);
1538 break; 1540 break;
1539 case DRM_MODE_DPMS_STANDBY: 1541 case DRM_MODE_DPMS_STANDBY:
1540 case DRM_MODE_DPMS_SUSPEND: 1542 case DRM_MODE_DPMS_SUSPEND:
1541 case DRM_MODE_DPMS_OFF: 1543 case DRM_MODE_DPMS_OFF:
1542 if (ASIC_IS_DCE41(rdev)) 1544 if (ASIC_IS_DCE41(rdev)) {
1543 action = EXTERNAL_ENCODER_ACTION_V3_DISABLE_OUTPUT; 1545 atombios_external_encoder_setup(encoder, ext_encoder,
1544 else 1546 EXTERNAL_ENCODER_ACTION_V3_ENCODER_BLANKING);
1545 action = ATOM_DISABLE; 1547 atombios_external_encoder_setup(encoder, ext_encoder,
1548 EXTERNAL_ENCODER_ACTION_V3_DISABLE_OUTPUT);
1549 } else
1550 atombios_external_encoder_setup(encoder, ext_encoder, ATOM_DISABLE);
1546 break; 1551 break;
1547 } 1552 }
1548 atombios_external_encoder_setup(encoder, ext_encoder, action);
1549 } 1553 }
1550 1554
1551 radeon_atombios_encoder_dpms_scratch_regs(encoder, (mode == DRM_MODE_DPMS_ON) ? true : false); 1555 radeon_atombios_encoder_dpms_scratch_regs(encoder, (mode == DRM_MODE_DPMS_ON) ? true : false);
@@ -2004,6 +2008,65 @@ radeon_atom_dac_detect(struct drm_encoder *encoder, struct drm_connector *connec
2004 return connector_status_disconnected; 2008 return connector_status_disconnected;
2005} 2009}
2006 2010
2011static enum drm_connector_status
2012radeon_atom_dig_detect(struct drm_encoder *encoder, struct drm_connector *connector)
2013{
2014 struct drm_device *dev = encoder->dev;
2015 struct radeon_device *rdev = dev->dev_private;
2016 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
2017 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
2018 struct drm_encoder *ext_encoder = radeon_atom_get_external_encoder(encoder);
2019 u32 bios_0_scratch;
2020
2021 if (!ASIC_IS_DCE4(rdev))
2022 return connector_status_unknown;
2023
2024 if (!ext_encoder)
2025 return connector_status_unknown;
2026
2027 if ((radeon_connector->devices & ATOM_DEVICE_CRT_SUPPORT) == 0)
2028 return connector_status_unknown;
2029
2030 /* load detect on the dp bridge */
2031 atombios_external_encoder_setup(encoder, ext_encoder,
2032 EXTERNAL_ENCODER_ACTION_V3_DACLOAD_DETECTION);
2033
2034 bios_0_scratch = RREG32(R600_BIOS_0_SCRATCH);
2035
2036 DRM_DEBUG_KMS("Bios 0 scratch %x %08x\n", bios_0_scratch, radeon_encoder->devices);
2037 if (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT) {
2038 if (bios_0_scratch & ATOM_S0_CRT1_MASK)
2039 return connector_status_connected;
2040 }
2041 if (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT) {
2042 if (bios_0_scratch & ATOM_S0_CRT2_MASK)
2043 return connector_status_connected;
2044 }
2045 if (radeon_connector->devices & ATOM_DEVICE_CV_SUPPORT) {
2046 if (bios_0_scratch & (ATOM_S0_CV_MASK|ATOM_S0_CV_MASK_A))
2047 return connector_status_connected;
2048 }
2049 if (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT) {
2050 if (bios_0_scratch & (ATOM_S0_TV1_COMPOSITE | ATOM_S0_TV1_COMPOSITE_A))
2051 return connector_status_connected; /* CTV */
2052 else if (bios_0_scratch & (ATOM_S0_TV1_SVIDEO | ATOM_S0_TV1_SVIDEO_A))
2053 return connector_status_connected; /* STV */
2054 }
2055 return connector_status_disconnected;
2056}
2057
2058void
2059radeon_atom_ext_encoder_setup_ddc(struct drm_encoder *encoder)
2060{
2061 struct drm_encoder *ext_encoder = radeon_atom_get_external_encoder(encoder);
2062
2063 if (ext_encoder)
2064 /* ddc_setup on the dp bridge */
2065 atombios_external_encoder_setup(encoder, ext_encoder,
2066 EXTERNAL_ENCODER_ACTION_V3_DDC_SETUP);
2067
2068}
2069
2007static void radeon_atom_encoder_prepare(struct drm_encoder *encoder) 2070static void radeon_atom_encoder_prepare(struct drm_encoder *encoder)
2008{ 2071{
2009 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2072 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
@@ -2167,7 +2230,7 @@ static const struct drm_encoder_helper_funcs radeon_atom_dig_helper_funcs = {
2167 .mode_set = radeon_atom_encoder_mode_set, 2230 .mode_set = radeon_atom_encoder_mode_set,
2168 .commit = radeon_atom_encoder_commit, 2231 .commit = radeon_atom_encoder_commit,
2169 .disable = radeon_atom_encoder_disable, 2232 .disable = radeon_atom_encoder_disable,
2170 /* no detect for TMDS/LVDS yet */ 2233 .detect = radeon_atom_dig_detect,
2171}; 2234};
2172 2235
2173static const struct drm_encoder_helper_funcs radeon_atom_dac_helper_funcs = { 2236static const struct drm_encoder_helper_funcs radeon_atom_dac_helper_funcs = {
diff --git a/drivers/gpu/drm/radeon/radeon_fence.c b/drivers/gpu/drm/radeon/radeon_fence.c
index 1f8229436570..021d2b6b556f 100644
--- a/drivers/gpu/drm/radeon/radeon_fence.c
+++ b/drivers/gpu/drm/radeon/radeon_fence.c
@@ -40,6 +40,35 @@
40#include "radeon.h" 40#include "radeon.h"
41#include "radeon_trace.h" 41#include "radeon_trace.h"
42 42
43static void radeon_fence_write(struct radeon_device *rdev, u32 seq)
44{
45 if (rdev->wb.enabled) {
46 u32 scratch_index;
47 if (rdev->wb.use_event)
48 scratch_index = R600_WB_EVENT_OFFSET + rdev->fence_drv.scratch_reg - rdev->scratch.reg_base;
49 else
50 scratch_index = RADEON_WB_SCRATCH_OFFSET + rdev->fence_drv.scratch_reg - rdev->scratch.reg_base;
51 rdev->wb.wb[scratch_index/4] = cpu_to_le32(seq);;
52 } else
53 WREG32(rdev->fence_drv.scratch_reg, seq);
54}
55
56static u32 radeon_fence_read(struct radeon_device *rdev)
57{
58 u32 seq;
59
60 if (rdev->wb.enabled) {
61 u32 scratch_index;
62 if (rdev->wb.use_event)
63 scratch_index = R600_WB_EVENT_OFFSET + rdev->fence_drv.scratch_reg - rdev->scratch.reg_base;
64 else
65 scratch_index = RADEON_WB_SCRATCH_OFFSET + rdev->fence_drv.scratch_reg - rdev->scratch.reg_base;
66 seq = le32_to_cpu(rdev->wb.wb[scratch_index/4]);
67 } else
68 seq = RREG32(rdev->fence_drv.scratch_reg);
69 return seq;
70}
71
43int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence *fence) 72int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence *fence)
44{ 73{
45 unsigned long irq_flags; 74 unsigned long irq_flags;
@@ -50,12 +79,12 @@ int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence *fence)
50 return 0; 79 return 0;
51 } 80 }
52 fence->seq = atomic_add_return(1, &rdev->fence_drv.seq); 81 fence->seq = atomic_add_return(1, &rdev->fence_drv.seq);
53 if (!rdev->cp.ready) { 82 if (!rdev->cp.ready)
54 /* FIXME: cp is not running assume everythings is done right 83 /* FIXME: cp is not running assume everythings is done right
55 * away 84 * away
56 */ 85 */
57 WREG32(rdev->fence_drv.scratch_reg, fence->seq); 86 radeon_fence_write(rdev, fence->seq);
58 } else 87 else
59 radeon_fence_ring_emit(rdev, fence); 88 radeon_fence_ring_emit(rdev, fence);
60 89
61 trace_radeon_fence_emit(rdev->ddev, fence->seq); 90 trace_radeon_fence_emit(rdev->ddev, fence->seq);
@@ -73,15 +102,7 @@ static bool radeon_fence_poll_locked(struct radeon_device *rdev)
73 bool wake = false; 102 bool wake = false;
74 unsigned long cjiffies; 103 unsigned long cjiffies;
75 104
76 if (rdev->wb.enabled) { 105 seq = radeon_fence_read(rdev);
77 u32 scratch_index;
78 if (rdev->wb.use_event)
79 scratch_index = R600_WB_EVENT_OFFSET + rdev->fence_drv.scratch_reg - rdev->scratch.reg_base;
80 else
81 scratch_index = RADEON_WB_SCRATCH_OFFSET + rdev->fence_drv.scratch_reg - rdev->scratch.reg_base;
82 seq = le32_to_cpu(rdev->wb.wb[scratch_index/4]);
83 } else
84 seq = RREG32(rdev->fence_drv.scratch_reg);
85 if (seq != rdev->fence_drv.last_seq) { 106 if (seq != rdev->fence_drv.last_seq) {
86 rdev->fence_drv.last_seq = seq; 107 rdev->fence_drv.last_seq = seq;
87 rdev->fence_drv.last_jiffies = jiffies; 108 rdev->fence_drv.last_jiffies = jiffies;
@@ -251,7 +272,7 @@ retry:
251 r = radeon_gpu_reset(rdev); 272 r = radeon_gpu_reset(rdev);
252 if (r) 273 if (r)
253 return r; 274 return r;
254 WREG32(rdev->fence_drv.scratch_reg, fence->seq); 275 radeon_fence_write(rdev, fence->seq);
255 rdev->gpu_lockup = false; 276 rdev->gpu_lockup = false;
256 } 277 }
257 timeout = RADEON_FENCE_JIFFIES_TIMEOUT; 278 timeout = RADEON_FENCE_JIFFIES_TIMEOUT;
@@ -351,7 +372,7 @@ int radeon_fence_driver_init(struct radeon_device *rdev)
351 write_unlock_irqrestore(&rdev->fence_drv.lock, irq_flags); 372 write_unlock_irqrestore(&rdev->fence_drv.lock, irq_flags);
352 return r; 373 return r;
353 } 374 }
354 WREG32(rdev->fence_drv.scratch_reg, 0); 375 radeon_fence_write(rdev, 0);
355 atomic_set(&rdev->fence_drv.seq, 0); 376 atomic_set(&rdev->fence_drv.seq, 0);
356 INIT_LIST_HEAD(&rdev->fence_drv.created); 377 INIT_LIST_HEAD(&rdev->fence_drv.created);
357 INIT_LIST_HEAD(&rdev->fence_drv.emited); 378 INIT_LIST_HEAD(&rdev->fence_drv.emited);
@@ -391,7 +412,7 @@ static int radeon_debugfs_fence_info(struct seq_file *m, void *data)
391 struct radeon_fence *fence; 412 struct radeon_fence *fence;
392 413
393 seq_printf(m, "Last signaled fence 0x%08X\n", 414 seq_printf(m, "Last signaled fence 0x%08X\n",
394 RREG32(rdev->fence_drv.scratch_reg)); 415 radeon_fence_read(rdev));
395 if (!list_empty(&rdev->fence_drv.emited)) { 416 if (!list_empty(&rdev->fence_drv.emited)) {
396 fence = list_entry(rdev->fence_drv.emited.prev, 417 fence = list_entry(rdev->fence_drv.emited.prev,
397 struct radeon_fence, list); 418 struct radeon_fence, list);
diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h
index 977a341266b6..6df4e3cec0c2 100644
--- a/drivers/gpu/drm/radeon/radeon_mode.h
+++ b/drivers/gpu/drm/radeon/radeon_mode.h
@@ -483,6 +483,8 @@ extern void radeon_atom_encoder_init(struct radeon_device *rdev);
483extern void atombios_dig_transmitter_setup(struct drm_encoder *encoder, 483extern void atombios_dig_transmitter_setup(struct drm_encoder *encoder,
484 int action, uint8_t lane_num, 484 int action, uint8_t lane_num,
485 uint8_t lane_set); 485 uint8_t lane_set);
486extern void radeon_atom_ext_encoder_setup_ddc(struct drm_encoder *encoder);
487extern struct drm_encoder *radeon_atom_get_external_encoder(struct drm_encoder *encoder);
486extern int radeon_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode, 488extern int radeon_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode,
487 u8 write_byte, u8 *read_byte); 489 u8 write_byte, u8 *read_byte);
488 490
diff --git a/drivers/gpu/drm/savage/savage_bci.c b/drivers/gpu/drm/savage/savage_bci.c
index bf5f83ea14fe..cb1ee4e0050a 100644
--- a/drivers/gpu/drm/savage/savage_bci.c
+++ b/drivers/gpu/drm/savage/savage_bci.c
@@ -647,9 +647,6 @@ int savage_driver_firstopen(struct drm_device *dev)
647 ret = drm_addmap(dev, aperture_base, SAVAGE_APERTURE_SIZE, 647 ret = drm_addmap(dev, aperture_base, SAVAGE_APERTURE_SIZE,
648 _DRM_FRAME_BUFFER, _DRM_WRITE_COMBINING, 648 _DRM_FRAME_BUFFER, _DRM_WRITE_COMBINING,
649 &dev_priv->aperture); 649 &dev_priv->aperture);
650 if (ret)
651 return ret;
652
653 return ret; 650 return ret;
654} 651}
655 652
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 67d2a7585934..36ca465c00ce 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -305,6 +305,7 @@ config HID_MULTITOUCH
305 - 3M PCT touch screens 305 - 3M PCT touch screens
306 - ActionStar dual touch panels 306 - ActionStar dual touch panels
307 - Cando dual touch panels 307 - Cando dual touch panels
308 - Chunghwa panels
308 - CVTouch panels 309 - CVTouch panels
309 - Cypress TrueTouch panels 310 - Cypress TrueTouch panels
310 - Elo TouchSystems IntelliTouch Plus panels 311 - Elo TouchSystems IntelliTouch Plus panels
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index c957c4b4fe70..f7440e8ce3e7 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1359,6 +1359,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
1359 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR) }, 1359 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR) },
1360 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) }, 1360 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) },
1361 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS) }, 1361 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS) },
1362 { HID_USB_DEVICE(USB_VENDOR_ID_CHUNGHWAT, USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH) },
1362 { HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_PRODIKEYS_PCMIDI) }, 1363 { HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_PRODIKEYS_PCMIDI) },
1363 { HID_USB_DEVICE(USB_VENDOR_ID_CVTOUCH, USB_DEVICE_ID_CVTOUCH_SCREEN) }, 1364 { HID_USB_DEVICE(USB_VENDOR_ID_CVTOUCH, USB_DEVICE_ID_CVTOUCH_SCREEN) },
1364 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) }, 1365 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) },
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 0b374a6d6db0..aecb5a4b8d6d 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -173,6 +173,9 @@
173#define USB_DEVICE_ID_CHICONY_MULTI_TOUCH 0xb19d 173#define USB_DEVICE_ID_CHICONY_MULTI_TOUCH 0xb19d
174#define USB_DEVICE_ID_CHICONY_WIRELESS 0x0618 174#define USB_DEVICE_ID_CHICONY_WIRELESS 0x0618
175 175
176#define USB_VENDOR_ID_CHUNGHWAT 0x2247
177#define USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH 0x0001
178
176#define USB_VENDOR_ID_CIDC 0x1677 179#define USB_VENDOR_ID_CIDC 0x1677
177 180
178#define USB_VENDOR_ID_CMEDIA 0x0d8c 181#define USB_VENDOR_ID_CMEDIA 0x0d8c
@@ -622,6 +625,7 @@
622#define USB_VENDOR_ID_UCLOGIC 0x5543 625#define USB_VENDOR_ID_UCLOGIC 0x5543
623#define USB_DEVICE_ID_UCLOGIC_TABLET_PF1209 0x0042 626#define USB_DEVICE_ID_UCLOGIC_TABLET_PF1209 0x0042
624#define USB_DEVICE_ID_UCLOGIC_TABLET_KNA5 0x6001 627#define USB_DEVICE_ID_UCLOGIC_TABLET_KNA5 0x6001
628#define USB_DEVICE_ID_UCLOGIC_TABLET_TWA60 0x0064
625#define USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U 0x0003 629#define USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U 0x0003
626#define USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U 0x0004 630#define USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U 0x0004
627#define USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U 0x0005 631#define USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U 0x0005
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index a5eda4c8127a..0ec91c18a421 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -501,17 +501,9 @@ static int magicmouse_probe(struct hid_device *hdev,
501 } 501 }
502 report->size = 6; 502 report->size = 6;
503 503
504 /*
505 * The device reponds with 'invalid report id' when feature
506 * report switching it into multitouch mode is sent to it.
507 *
508 * This results in -EIO from the _raw low-level transport callback,
509 * but there seems to be no other way of switching the mode.
510 * Thus the super-ugly hacky success check below.
511 */
512 ret = hdev->hid_output_raw_report(hdev, feature, sizeof(feature), 504 ret = hdev->hid_output_raw_report(hdev, feature, sizeof(feature),
513 HID_FEATURE_REPORT); 505 HID_FEATURE_REPORT);
514 if (ret != -EIO) { 506 if (ret != sizeof(feature)) {
515 hid_err(hdev, "unable to request touch data (%d)\n", ret); 507 hid_err(hdev, "unable to request touch data (%d)\n", ret);
516 goto err_stop_hw; 508 goto err_stop_hw;
517 } 509 }
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index ecd4d2db9e80..0b2dcd0ee591 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -64,6 +64,7 @@ struct mt_device {
64 struct mt_class *mtclass; /* our mt device class */ 64 struct mt_class *mtclass; /* our mt device class */
65 unsigned last_field_index; /* last field index of the report */ 65 unsigned last_field_index; /* last field index of the report */
66 unsigned last_slot_field; /* the last field of a slot */ 66 unsigned last_slot_field; /* the last field of a slot */
67 int last_mt_collection; /* last known mt-related collection */
67 __s8 inputmode; /* InputMode HID feature, -1 if non-existent */ 68 __s8 inputmode; /* InputMode HID feature, -1 if non-existent */
68 __u8 num_received; /* how many contacts we received */ 69 __u8 num_received; /* how many contacts we received */
69 __u8 num_expected; /* expected last contact index */ 70 __u8 num_expected; /* expected last contact index */
@@ -225,8 +226,10 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
225 cls->sn_move); 226 cls->sn_move);
226 /* touchscreen emulation */ 227 /* touchscreen emulation */
227 set_abs(hi->input, ABS_X, field, cls->sn_move); 228 set_abs(hi->input, ABS_X, field, cls->sn_move);
228 td->last_slot_field = usage->hid; 229 if (td->last_mt_collection == usage->collection_index) {
229 td->last_field_index = field->index; 230 td->last_slot_field = usage->hid;
231 td->last_field_index = field->index;
232 }
230 return 1; 233 return 1;
231 case HID_GD_Y: 234 case HID_GD_Y:
232 if (quirks & MT_QUIRK_EGALAX_XYZ_FIXUP) 235 if (quirks & MT_QUIRK_EGALAX_XYZ_FIXUP)
@@ -237,8 +240,10 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
237 cls->sn_move); 240 cls->sn_move);
238 /* touchscreen emulation */ 241 /* touchscreen emulation */
239 set_abs(hi->input, ABS_Y, field, cls->sn_move); 242 set_abs(hi->input, ABS_Y, field, cls->sn_move);
240 td->last_slot_field = usage->hid; 243 if (td->last_mt_collection == usage->collection_index) {
241 td->last_field_index = field->index; 244 td->last_slot_field = usage->hid;
245 td->last_field_index = field->index;
246 }
242 return 1; 247 return 1;
243 } 248 }
244 return 0; 249 return 0;
@@ -246,31 +251,40 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
246 case HID_UP_DIGITIZER: 251 case HID_UP_DIGITIZER:
247 switch (usage->hid) { 252 switch (usage->hid) {
248 case HID_DG_INRANGE: 253 case HID_DG_INRANGE:
249 td->last_slot_field = usage->hid; 254 if (td->last_mt_collection == usage->collection_index) {
250 td->last_field_index = field->index; 255 td->last_slot_field = usage->hid;
256 td->last_field_index = field->index;
257 }
251 return 1; 258 return 1;
252 case HID_DG_CONFIDENCE: 259 case HID_DG_CONFIDENCE:
253 td->last_slot_field = usage->hid; 260 if (td->last_mt_collection == usage->collection_index) {
254 td->last_field_index = field->index; 261 td->last_slot_field = usage->hid;
262 td->last_field_index = field->index;
263 }
255 return 1; 264 return 1;
256 case HID_DG_TIPSWITCH: 265 case HID_DG_TIPSWITCH:
257 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH); 266 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);
258 input_set_capability(hi->input, EV_KEY, BTN_TOUCH); 267 input_set_capability(hi->input, EV_KEY, BTN_TOUCH);
259 td->last_slot_field = usage->hid; 268 if (td->last_mt_collection == usage->collection_index) {
260 td->last_field_index = field->index; 269 td->last_slot_field = usage->hid;
270 td->last_field_index = field->index;
271 }
261 return 1; 272 return 1;
262 case HID_DG_CONTACTID: 273 case HID_DG_CONTACTID:
263 input_mt_init_slots(hi->input, td->maxcontacts); 274 input_mt_init_slots(hi->input, td->maxcontacts);
264 td->last_slot_field = usage->hid; 275 td->last_slot_field = usage->hid;
265 td->last_field_index = field->index; 276 td->last_field_index = field->index;
277 td->last_mt_collection = usage->collection_index;
266 return 1; 278 return 1;
267 case HID_DG_WIDTH: 279 case HID_DG_WIDTH:
268 hid_map_usage(hi, usage, bit, max, 280 hid_map_usage(hi, usage, bit, max,
269 EV_ABS, ABS_MT_TOUCH_MAJOR); 281 EV_ABS, ABS_MT_TOUCH_MAJOR);
270 set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field, 282 set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field,
271 cls->sn_width); 283 cls->sn_width);
272 td->last_slot_field = usage->hid; 284 if (td->last_mt_collection == usage->collection_index) {
273 td->last_field_index = field->index; 285 td->last_slot_field = usage->hid;
286 td->last_field_index = field->index;
287 }
274 return 1; 288 return 1;
275 case HID_DG_HEIGHT: 289 case HID_DG_HEIGHT:
276 hid_map_usage(hi, usage, bit, max, 290 hid_map_usage(hi, usage, bit, max,
@@ -279,8 +293,10 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
279 cls->sn_height); 293 cls->sn_height);
280 input_set_abs_params(hi->input, 294 input_set_abs_params(hi->input,
281 ABS_MT_ORIENTATION, 0, 1, 0, 0); 295 ABS_MT_ORIENTATION, 0, 1, 0, 0);
282 td->last_slot_field = usage->hid; 296 if (td->last_mt_collection == usage->collection_index) {
283 td->last_field_index = field->index; 297 td->last_slot_field = usage->hid;
298 td->last_field_index = field->index;
299 }
284 return 1; 300 return 1;
285 case HID_DG_TIPPRESSURE: 301 case HID_DG_TIPPRESSURE:
286 if (quirks & MT_QUIRK_EGALAX_XYZ_FIXUP) 302 if (quirks & MT_QUIRK_EGALAX_XYZ_FIXUP)
@@ -292,16 +308,20 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
292 /* touchscreen emulation */ 308 /* touchscreen emulation */
293 set_abs(hi->input, ABS_PRESSURE, field, 309 set_abs(hi->input, ABS_PRESSURE, field,
294 cls->sn_pressure); 310 cls->sn_pressure);
295 td->last_slot_field = usage->hid; 311 if (td->last_mt_collection == usage->collection_index) {
296 td->last_field_index = field->index; 312 td->last_slot_field = usage->hid;
313 td->last_field_index = field->index;
314 }
297 return 1; 315 return 1;
298 case HID_DG_CONTACTCOUNT: 316 case HID_DG_CONTACTCOUNT:
299 td->last_field_index = field->index; 317 if (td->last_mt_collection == usage->collection_index)
318 td->last_field_index = field->index;
300 return 1; 319 return 1;
301 case HID_DG_CONTACTMAX: 320 case HID_DG_CONTACTMAX:
302 /* we don't set td->last_slot_field as contactcount and 321 /* we don't set td->last_slot_field as contactcount and
303 * contact max are global to the report */ 322 * contact max are global to the report */
304 td->last_field_index = field->index; 323 if (td->last_mt_collection == usage->collection_index)
324 td->last_field_index = field->index;
305 return -1; 325 return -1;
306 } 326 }
307 /* let hid-input decide for the others */ 327 /* let hid-input decide for the others */
@@ -516,6 +536,7 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
516 } 536 }
517 td->mtclass = mtclass; 537 td->mtclass = mtclass;
518 td->inputmode = -1; 538 td->inputmode = -1;
539 td->last_mt_collection = -1;
519 hid_set_drvdata(hdev, td); 540 hid_set_drvdata(hdev, td);
520 541
521 ret = hid_parse(hdev); 542 ret = hid_parse(hdev);
@@ -593,6 +614,11 @@ static const struct hid_device_id mt_devices[] = {
593 HID_USB_DEVICE(USB_VENDOR_ID_CANDO, 614 HID_USB_DEVICE(USB_VENDOR_ID_CANDO,
594 USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) }, 615 USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) },
595 616
617 /* Chunghwa Telecom touch panels */
618 { .driver_data = MT_CLS_DEFAULT,
619 HID_USB_DEVICE(USB_VENDOR_ID_CHUNGHWAT,
620 USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH) },
621
596 /* CVTouch panels */ 622 /* CVTouch panels */
597 { .driver_data = MT_CLS_DEFAULT, 623 { .driver_data = MT_CLS_DEFAULT,
598 HID_USB_DEVICE(USB_VENDOR_ID_CVTOUCH, 624 HID_USB_DEVICE(USB_VENDOR_ID_CVTOUCH,
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index 0e30b140edca..621959d5cc42 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -74,6 +74,7 @@ static const struct hid_blacklist {
74 { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209, HID_QUIRK_MULTI_INPUT }, 74 { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209, HID_QUIRK_MULTI_INPUT },
75 { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U, HID_QUIRK_MULTI_INPUT }, 75 { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U, HID_QUIRK_MULTI_INPUT },
76 { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_KNA5, HID_QUIRK_MULTI_INPUT }, 76 { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_KNA5, HID_QUIRK_MULTI_INPUT },
77 { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_TWA60, HID_QUIRK_MULTI_INPUT },
77 { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U, HID_QUIRK_MULTI_INPUT }, 78 { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U, HID_QUIRK_MULTI_INPUT },
78 { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U, HID_QUIRK_MULTI_INPUT }, 79 { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U, HID_QUIRK_MULTI_INPUT },
79 { USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH, HID_QUIRK_MULTI_INPUT }, 80 { USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH, HID_QUIRK_MULTI_INPUT },
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index ff3c644888b1..7c1188b53c3e 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -248,12 +248,15 @@ static int hiddev_release(struct inode * inode, struct file * file)
248 usbhid_close(list->hiddev->hid); 248 usbhid_close(list->hiddev->hid);
249 usbhid_put_power(list->hiddev->hid); 249 usbhid_put_power(list->hiddev->hid);
250 } else { 250 } else {
251 mutex_unlock(&list->hiddev->existancelock);
251 kfree(list->hiddev); 252 kfree(list->hiddev);
253 kfree(list);
254 return 0;
252 } 255 }
253 } 256 }
254 257
255 kfree(list);
256 mutex_unlock(&list->hiddev->existancelock); 258 mutex_unlock(&list->hiddev->existancelock);
259 kfree(list);
257 260
258 return 0; 261 return 0;
259} 262}
@@ -923,10 +926,11 @@ void hiddev_disconnect(struct hid_device *hid)
923 usb_deregister_dev(usbhid->intf, &hiddev_class); 926 usb_deregister_dev(usbhid->intf, &hiddev_class);
924 927
925 if (hiddev->open) { 928 if (hiddev->open) {
929 mutex_unlock(&hiddev->existancelock);
926 usbhid_close(hiddev->hid); 930 usbhid_close(hiddev->hid);
927 wake_up_interruptible(&hiddev->wait); 931 wake_up_interruptible(&hiddev->wait);
928 } else { 932 } else {
933 mutex_unlock(&hiddev->existancelock);
929 kfree(hiddev); 934 kfree(hiddev);
930 } 935 }
931 mutex_unlock(&hiddev->existancelock);
932} 936}
diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
index b5e892017e0c..dcb78a7a8047 100644
--- a/drivers/hwmon/asus_atk0110.c
+++ b/drivers/hwmon/asus_atk0110.c
@@ -268,6 +268,7 @@ static struct device_attribute atk_name_attr =
268static void atk_init_attribute(struct device_attribute *attr, char *name, 268static void atk_init_attribute(struct device_attribute *attr, char *name,
269 sysfs_show_func show) 269 sysfs_show_func show)
270{ 270{
271 sysfs_attr_init(&attr->attr);
271 attr->attr.name = name; 272 attr->attr.name = name;
272 attr->attr.mode = 0444; 273 attr->attr.mode = 0444;
273 attr->show = show; 274 attr->show = show;
@@ -1188,19 +1189,15 @@ static int atk_create_files(struct atk_data *data)
1188 int err; 1189 int err;
1189 1190
1190 list_for_each_entry(s, &data->sensor_list, list) { 1191 list_for_each_entry(s, &data->sensor_list, list) {
1191 sysfs_attr_init(&s->input_attr.attr);
1192 err = device_create_file(data->hwmon_dev, &s->input_attr); 1192 err = device_create_file(data->hwmon_dev, &s->input_attr);
1193 if (err) 1193 if (err)
1194 return err; 1194 return err;
1195 sysfs_attr_init(&s->label_attr.attr);
1196 err = device_create_file(data->hwmon_dev, &s->label_attr); 1195 err = device_create_file(data->hwmon_dev, &s->label_attr);
1197 if (err) 1196 if (err)
1198 return err; 1197 return err;
1199 sysfs_attr_init(&s->limit1_attr.attr);
1200 err = device_create_file(data->hwmon_dev, &s->limit1_attr); 1198 err = device_create_file(data->hwmon_dev, &s->limit1_attr);
1201 if (err) 1199 if (err)
1202 return err; 1200 return err;
1203 sysfs_attr_init(&s->limit2_attr.attr);
1204 err = device_create_file(data->hwmon_dev, &s->limit2_attr); 1201 err = device_create_file(data->hwmon_dev, &s->limit2_attr);
1205 if (err) 1202 if (err)
1206 return err; 1203 return err;
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 85e937984ff7..0070d5476dd0 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -97,9 +97,7 @@ struct platform_data {
97struct pdev_entry { 97struct pdev_entry {
98 struct list_head list; 98 struct list_head list;
99 struct platform_device *pdev; 99 struct platform_device *pdev;
100 unsigned int cpu;
101 u16 phys_proc_id; 100 u16 phys_proc_id;
102 u16 cpu_core_id;
103}; 101};
104 102
105static LIST_HEAD(pdev_list); 103static LIST_HEAD(pdev_list);
@@ -653,9 +651,7 @@ static int __cpuinit coretemp_device_add(unsigned int cpu)
653 } 651 }
654 652
655 pdev_entry->pdev = pdev; 653 pdev_entry->pdev = pdev;
656 pdev_entry->cpu = cpu;
657 pdev_entry->phys_proc_id = TO_PHYS_ID(cpu); 654 pdev_entry->phys_proc_id = TO_PHYS_ID(cpu);
658 pdev_entry->cpu_core_id = TO_CORE_ID(cpu);
659 655
660 list_add_tail(&pdev_entry->list, &pdev_list); 656 list_add_tail(&pdev_entry->list, &pdev_list);
661 mutex_unlock(&pdev_list_mutex); 657 mutex_unlock(&pdev_list_mutex);
diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
index 537409d07ee7..1a409c5bc9bc 100644
--- a/drivers/hwmon/ibmaem.c
+++ b/drivers/hwmon/ibmaem.c
@@ -947,6 +947,7 @@ static int aem_register_sensors(struct aem_data *data,
947 947
948 /* Set up read-only sensors */ 948 /* Set up read-only sensors */
949 while (ro->label) { 949 while (ro->label) {
950 sysfs_attr_init(&sensors->dev_attr.attr);
950 sensors->dev_attr.attr.name = ro->label; 951 sensors->dev_attr.attr.name = ro->label;
951 sensors->dev_attr.attr.mode = S_IRUGO; 952 sensors->dev_attr.attr.mode = S_IRUGO;
952 sensors->dev_attr.show = ro->show; 953 sensors->dev_attr.show = ro->show;
@@ -963,6 +964,7 @@ static int aem_register_sensors(struct aem_data *data,
963 964
964 /* Set up read-write sensors */ 965 /* Set up read-write sensors */
965 while (rw->label) { 966 while (rw->label) {
967 sysfs_attr_init(&sensors->dev_attr.attr);
966 sensors->dev_attr.attr.name = rw->label; 968 sensors->dev_attr.attr.name = rw->label;
967 sensors->dev_attr.attr.mode = S_IRUGO | S_IWUSR; 969 sensors->dev_attr.attr.mode = S_IRUGO | S_IWUSR;
968 sensors->dev_attr.show = rw->show; 970 sensors->dev_attr.show = rw->show;
diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c
index 06d4eafcf76b..41dbf8161ed7 100644
--- a/drivers/hwmon/ibmpex.c
+++ b/drivers/hwmon/ibmpex.c
@@ -358,6 +358,7 @@ static int create_sensor(struct ibmpex_bmc_data *data, int type,
358 else if (type == POWER_SENSOR) 358 else if (type == POWER_SENSOR)
359 sprintf(n, power_sensor_name_templates[func], "power", counter); 359 sprintf(n, power_sensor_name_templates[func], "power", counter);
360 360
361 sysfs_attr_init(&data->sensors[sensor].attr[func].dev_attr.attr);
361 data->sensors[sensor].attr[func].dev_attr.attr.name = n; 362 data->sensors[sensor].attr[func].dev_attr.attr.name = n;
362 data->sensors[sensor].attr[func].dev_attr.attr.mode = S_IRUGO; 363 data->sensors[sensor].attr[func].dev_attr.attr.mode = S_IRUGO;
363 data->sensors[sensor].attr[func].dev_attr.show = ibmpex_show_sensor; 364 data->sensors[sensor].attr[func].dev_attr.show = ibmpex_show_sensor;
diff --git a/drivers/hwmon/s3c-hwmon.c b/drivers/hwmon/s3c-hwmon.c
index 92b42db43bcf..b39f52e2752a 100644
--- a/drivers/hwmon/s3c-hwmon.c
+++ b/drivers/hwmon/s3c-hwmon.c
@@ -232,6 +232,7 @@ static int s3c_hwmon_create_attr(struct device *dev,
232 232
233 attr = &attrs->in; 233 attr = &attrs->in;
234 attr->index = channel; 234 attr->index = channel;
235 sysfs_attr_init(&attr->dev_attr.attr);
235 attr->dev_attr.attr.name = attrs->in_name; 236 attr->dev_attr.attr.name = attrs->in_name;
236 attr->dev_attr.attr.mode = S_IRUGO; 237 attr->dev_attr.attr.mode = S_IRUGO;
237 attr->dev_attr.show = s3c_hwmon_ch_show; 238 attr->dev_attr.show = s3c_hwmon_ch_show;
@@ -249,6 +250,7 @@ static int s3c_hwmon_create_attr(struct device *dev,
249 250
250 attr = &attrs->label; 251 attr = &attrs->label;
251 attr->index = channel; 252 attr->index = channel;
253 sysfs_attr_init(&attr->dev_attr.attr);
252 attr->dev_attr.attr.name = attrs->label_name; 254 attr->dev_attr.attr.name = attrs->label_name;
253 attr->dev_attr.attr.mode = S_IRUGO; 255 attr->dev_attr.attr.mode = S_IRUGO;
254 attr->dev_attr.show = s3c_hwmon_label_show; 256 attr->dev_attr.show = s3c_hwmon_label_show;
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 23f0d5e99f35..713d43b4e563 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -1,3 +1,10 @@
1config LEDS_GPIO_REGISTER
2 bool
3 help
4 This option provides the function gpio_led_register_device.
5 As this function is used by arch code it must not be compiled as a
6 module.
7
1menuconfig NEW_LEDS 8menuconfig NEW_LEDS
2 bool "LED Support" 9 bool "LED Support"
3 help 10 help
@@ -7,22 +14,14 @@ menuconfig NEW_LEDS
7 This is not related to standard keyboard LEDs which are controlled 14 This is not related to standard keyboard LEDs which are controlled
8 via the input system. 15 via the input system.
9 16
17if NEW_LEDS
18
10config LEDS_CLASS 19config LEDS_CLASS
11 bool "LED Class Support" 20 bool "LED Class Support"
12 depends on NEW_LEDS
13 help 21 help
14 This option enables the led sysfs class in /sys/class/leds. You'll 22 This option enables the led sysfs class in /sys/class/leds. You'll
15 need this to do anything useful with LEDs. If unsure, say N. 23 need this to do anything useful with LEDs. If unsure, say N.
16 24
17config LEDS_GPIO_REGISTER
18 bool
19 help
20 This option provides the function gpio_led_register_device.
21 As this function is used by arch code it must not be compiled as a
22 module.
23
24if NEW_LEDS
25
26comment "LED drivers" 25comment "LED drivers"
27 26
28config LEDS_88PM860X 27config LEDS_88PM860X
@@ -391,6 +390,7 @@ config LEDS_NETXBIG
391 390
392config LEDS_ASIC3 391config LEDS_ASIC3
393 bool "LED support for the HTC ASIC3" 392 bool "LED support for the HTC ASIC3"
393 depends on LEDS_CLASS
394 depends on MFD_ASIC3 394 depends on MFD_ASIC3
395 default y 395 default y
396 help 396 help
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 70bd738b8b99..574b09afedd3 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -534,6 +534,82 @@ void bitmap_print_sb(struct bitmap *bitmap)
534 kunmap_atomic(sb, KM_USER0); 534 kunmap_atomic(sb, KM_USER0);
535} 535}
536 536
537/*
538 * bitmap_new_disk_sb
539 * @bitmap
540 *
541 * This function is somewhat the reverse of bitmap_read_sb. bitmap_read_sb
542 * reads and verifies the on-disk bitmap superblock and populates bitmap_info.
543 * This function verifies 'bitmap_info' and populates the on-disk bitmap
544 * structure, which is to be written to disk.
545 *
546 * Returns: 0 on success, -Exxx on error
547 */
548static int bitmap_new_disk_sb(struct bitmap *bitmap)
549{
550 bitmap_super_t *sb;
551 unsigned long chunksize, daemon_sleep, write_behind;
552 int err = -EINVAL;
553
554 bitmap->sb_page = alloc_page(GFP_KERNEL);
555 if (IS_ERR(bitmap->sb_page)) {
556 err = PTR_ERR(bitmap->sb_page);
557 bitmap->sb_page = NULL;
558 return err;
559 }
560 bitmap->sb_page->index = 0;
561
562 sb = kmap_atomic(bitmap->sb_page, KM_USER0);
563
564 sb->magic = cpu_to_le32(BITMAP_MAGIC);
565 sb->version = cpu_to_le32(BITMAP_MAJOR_HI);
566
567 chunksize = bitmap->mddev->bitmap_info.chunksize;
568 BUG_ON(!chunksize);
569 if (!is_power_of_2(chunksize)) {
570 kunmap_atomic(sb, KM_USER0);
571 printk(KERN_ERR "bitmap chunksize not a power of 2\n");
572 return -EINVAL;
573 }
574 sb->chunksize = cpu_to_le32(chunksize);
575
576 daemon_sleep = bitmap->mddev->bitmap_info.daemon_sleep;
577 if (!daemon_sleep ||
578 (daemon_sleep < 1) || (daemon_sleep > MAX_SCHEDULE_TIMEOUT)) {
579 printk(KERN_INFO "Choosing daemon_sleep default (5 sec)\n");
580 daemon_sleep = 5 * HZ;
581 }
582 sb->daemon_sleep = cpu_to_le32(daemon_sleep);
583 bitmap->mddev->bitmap_info.daemon_sleep = daemon_sleep;
584
585 /*
586 * FIXME: write_behind for RAID1. If not specified, what
587 * is a good choice? We choose COUNTER_MAX / 2 arbitrarily.
588 */
589 write_behind = bitmap->mddev->bitmap_info.max_write_behind;
590 if (write_behind > COUNTER_MAX)
591 write_behind = COUNTER_MAX / 2;
592 sb->write_behind = cpu_to_le32(write_behind);
593 bitmap->mddev->bitmap_info.max_write_behind = write_behind;
594
595 /* keep the array size field of the bitmap superblock up to date */
596 sb->sync_size = cpu_to_le64(bitmap->mddev->resync_max_sectors);
597
598 memcpy(sb->uuid, bitmap->mddev->uuid, 16);
599
600 bitmap->flags |= BITMAP_STALE;
601 sb->state |= cpu_to_le32(BITMAP_STALE);
602 bitmap->events_cleared = bitmap->mddev->events;
603 sb->events_cleared = cpu_to_le64(bitmap->mddev->events);
604
605 bitmap->flags |= BITMAP_HOSTENDIAN;
606 sb->version = cpu_to_le32(BITMAP_MAJOR_HOSTENDIAN);
607
608 kunmap_atomic(sb, KM_USER0);
609
610 return 0;
611}
612
537/* read the superblock from the bitmap file and initialize some bitmap fields */ 613/* read the superblock from the bitmap file and initialize some bitmap fields */
538static int bitmap_read_sb(struct bitmap *bitmap) 614static int bitmap_read_sb(struct bitmap *bitmap)
539{ 615{
@@ -575,7 +651,7 @@ static int bitmap_read_sb(struct bitmap *bitmap)
575 reason = "unrecognized superblock version"; 651 reason = "unrecognized superblock version";
576 else if (chunksize < 512) 652 else if (chunksize < 512)
577 reason = "bitmap chunksize too small"; 653 reason = "bitmap chunksize too small";
578 else if ((1 << ffz(~chunksize)) != chunksize) 654 else if (!is_power_of_2(chunksize))
579 reason = "bitmap chunksize not a power of 2"; 655 reason = "bitmap chunksize not a power of 2";
580 else if (daemon_sleep < 1 || daemon_sleep > MAX_SCHEDULE_TIMEOUT) 656 else if (daemon_sleep < 1 || daemon_sleep > MAX_SCHEDULE_TIMEOUT)
581 reason = "daemon sleep period out of range"; 657 reason = "daemon sleep period out of range";
@@ -1076,8 +1152,8 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
1076 } 1152 }
1077 1153
1078 printk(KERN_INFO "%s: bitmap initialized from disk: " 1154 printk(KERN_INFO "%s: bitmap initialized from disk: "
1079 "read %lu/%lu pages, set %lu bits\n", 1155 "read %lu/%lu pages, set %lu of %lu bits\n",
1080 bmname(bitmap), bitmap->file_pages, num_pages, bit_cnt); 1156 bmname(bitmap), bitmap->file_pages, num_pages, bit_cnt, chunks);
1081 1157
1082 return 0; 1158 return 0;
1083 1159
@@ -1332,7 +1408,7 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect
1332 return 0; 1408 return 0;
1333 } 1409 }
1334 1410
1335 if (unlikely((*bmc & COUNTER_MAX) == COUNTER_MAX)) { 1411 if (unlikely(COUNTER(*bmc) == COUNTER_MAX)) {
1336 DEFINE_WAIT(__wait); 1412 DEFINE_WAIT(__wait);
1337 /* note that it is safe to do the prepare_to_wait 1413 /* note that it is safe to do the prepare_to_wait
1338 * after the test as long as we do it before dropping 1414 * after the test as long as we do it before dropping
@@ -1404,10 +1480,10 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto
1404 sysfs_notify_dirent_safe(bitmap->sysfs_can_clear); 1480 sysfs_notify_dirent_safe(bitmap->sysfs_can_clear);
1405 } 1481 }
1406 1482
1407 if (!success && ! (*bmc & NEEDED_MASK)) 1483 if (!success && !NEEDED(*bmc))
1408 *bmc |= NEEDED_MASK; 1484 *bmc |= NEEDED_MASK;
1409 1485
1410 if ((*bmc & COUNTER_MAX) == COUNTER_MAX) 1486 if (COUNTER(*bmc) == COUNTER_MAX)
1411 wake_up(&bitmap->overflow_wait); 1487 wake_up(&bitmap->overflow_wait);
1412 1488
1413 (*bmc)--; 1489 (*bmc)--;
@@ -1728,9 +1804,16 @@ int bitmap_create(mddev_t *mddev)
1728 vfs_fsync(file, 1); 1804 vfs_fsync(file, 1);
1729 } 1805 }
1730 /* read superblock from bitmap file (this sets mddev->bitmap_info.chunksize) */ 1806 /* read superblock from bitmap file (this sets mddev->bitmap_info.chunksize) */
1731 if (!mddev->bitmap_info.external) 1807 if (!mddev->bitmap_info.external) {
1732 err = bitmap_read_sb(bitmap); 1808 /*
1733 else { 1809 * If 'MD_ARRAY_FIRST_USE' is set, then device-mapper is
1810 * instructing us to create a new on-disk bitmap instance.
1811 */
1812 if (test_and_clear_bit(MD_ARRAY_FIRST_USE, &mddev->flags))
1813 err = bitmap_new_disk_sb(bitmap);
1814 else
1815 err = bitmap_read_sb(bitmap);
1816 } else {
1734 err = 0; 1817 err = 0;
1735 if (mddev->bitmap_info.chunksize == 0 || 1818 if (mddev->bitmap_info.chunksize == 0 ||
1736 mddev->bitmap_info.daemon_sleep == 0) 1819 mddev->bitmap_info.daemon_sleep == 0)
@@ -1754,9 +1837,6 @@ int bitmap_create(mddev_t *mddev)
1754 bitmap->chunks = chunks; 1837 bitmap->chunks = chunks;
1755 bitmap->pages = pages; 1838 bitmap->pages = pages;
1756 bitmap->missing_pages = pages; 1839 bitmap->missing_pages = pages;
1757 bitmap->counter_bits = COUNTER_BITS;
1758
1759 bitmap->syncchunk = ~0UL;
1760 1840
1761#ifdef INJECT_FATAL_FAULT_1 1841#ifdef INJECT_FATAL_FAULT_1
1762 bitmap->bp = NULL; 1842 bitmap->bp = NULL;
diff --git a/drivers/md/bitmap.h b/drivers/md/bitmap.h
index d0aeaf46d932..b2a127e891ac 100644
--- a/drivers/md/bitmap.h
+++ b/drivers/md/bitmap.h
@@ -85,7 +85,6 @@
85typedef __u16 bitmap_counter_t; 85typedef __u16 bitmap_counter_t;
86#define COUNTER_BITS 16 86#define COUNTER_BITS 16
87#define COUNTER_BIT_SHIFT 4 87#define COUNTER_BIT_SHIFT 4
88#define COUNTER_BYTE_RATIO (COUNTER_BITS / 8)
89#define COUNTER_BYTE_SHIFT (COUNTER_BIT_SHIFT - 3) 88#define COUNTER_BYTE_SHIFT (COUNTER_BIT_SHIFT - 3)
90 89
91#define NEEDED_MASK ((bitmap_counter_t) (1 << (COUNTER_BITS - 1))) 90#define NEEDED_MASK ((bitmap_counter_t) (1 << (COUNTER_BITS - 1)))
@@ -196,19 +195,10 @@ struct bitmap {
196 195
197 mddev_t *mddev; /* the md device that the bitmap is for */ 196 mddev_t *mddev; /* the md device that the bitmap is for */
198 197
199 int counter_bits; /* how many bits per block counter */
200
201 /* bitmap chunksize -- how much data does each bit represent? */ 198 /* bitmap chunksize -- how much data does each bit represent? */
202 unsigned long chunkshift; /* chunksize = 2^chunkshift (for bitops) */ 199 unsigned long chunkshift; /* chunksize = 2^chunkshift (for bitops) */
203 unsigned long chunks; /* total number of data chunks for the array */ 200 unsigned long chunks; /* total number of data chunks for the array */
204 201
205 /* We hold a count on the chunk currently being synced, and drop
206 * it when the last block is started. If the resync is aborted
207 * midway, we need to be able to drop that count, so we remember
208 * the counted chunk..
209 */
210 unsigned long syncchunk;
211
212 __u64 events_cleared; 202 __u64 events_cleared;
213 int need_sync; 203 int need_sync;
214 204
diff --git a/drivers/md/md.c b/drivers/md/md.c
index aa640a85bb21..4332fc2f25d4 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -351,6 +351,9 @@ void mddev_resume(mddev_t *mddev)
351 mddev->suspended = 0; 351 mddev->suspended = 0;
352 wake_up(&mddev->sb_wait); 352 wake_up(&mddev->sb_wait);
353 mddev->pers->quiesce(mddev, 0); 353 mddev->pers->quiesce(mddev, 0);
354
355 md_wakeup_thread(mddev->thread);
356 md_wakeup_thread(mddev->sync_thread); /* possibly kick off a reshape */
354} 357}
355EXPORT_SYMBOL_GPL(mddev_resume); 358EXPORT_SYMBOL_GPL(mddev_resume);
356 359
@@ -1750,6 +1753,18 @@ static struct super_type super_types[] = {
1750 }, 1753 },
1751}; 1754};
1752 1755
1756static void sync_super(mddev_t *mddev, mdk_rdev_t *rdev)
1757{
1758 if (mddev->sync_super) {
1759 mddev->sync_super(mddev, rdev);
1760 return;
1761 }
1762
1763 BUG_ON(mddev->major_version >= ARRAY_SIZE(super_types));
1764
1765 super_types[mddev->major_version].sync_super(mddev, rdev);
1766}
1767
1753static int match_mddev_units(mddev_t *mddev1, mddev_t *mddev2) 1768static int match_mddev_units(mddev_t *mddev1, mddev_t *mddev2)
1754{ 1769{
1755 mdk_rdev_t *rdev, *rdev2; 1770 mdk_rdev_t *rdev, *rdev2;
@@ -1781,8 +1796,8 @@ int md_integrity_register(mddev_t *mddev)
1781 1796
1782 if (list_empty(&mddev->disks)) 1797 if (list_empty(&mddev->disks))
1783 return 0; /* nothing to do */ 1798 return 0; /* nothing to do */
1784 if (blk_get_integrity(mddev->gendisk)) 1799 if (!mddev->gendisk || blk_get_integrity(mddev->gendisk))
1785 return 0; /* already registered */ 1800 return 0; /* shouldn't register, or already is */
1786 list_for_each_entry(rdev, &mddev->disks, same_set) { 1801 list_for_each_entry(rdev, &mddev->disks, same_set) {
1787 /* skip spares and non-functional disks */ 1802 /* skip spares and non-functional disks */
1788 if (test_bit(Faulty, &rdev->flags)) 1803 if (test_bit(Faulty, &rdev->flags))
@@ -2168,8 +2183,7 @@ static void sync_sbs(mddev_t * mddev, int nospares)
2168 /* Don't update this superblock */ 2183 /* Don't update this superblock */
2169 rdev->sb_loaded = 2; 2184 rdev->sb_loaded = 2;
2170 } else { 2185 } else {
2171 super_types[mddev->major_version]. 2186 sync_super(mddev, rdev);
2172 sync_super(mddev, rdev);
2173 rdev->sb_loaded = 1; 2187 rdev->sb_loaded = 1;
2174 } 2188 }
2175 } 2189 }
@@ -2462,7 +2476,7 @@ slot_store(mdk_rdev_t *rdev, const char *buf, size_t len)
2462 if (rdev->raid_disk == -1) 2476 if (rdev->raid_disk == -1)
2463 return -EEXIST; 2477 return -EEXIST;
2464 /* personality does all needed checks */ 2478 /* personality does all needed checks */
2465 if (rdev->mddev->pers->hot_add_disk == NULL) 2479 if (rdev->mddev->pers->hot_remove_disk == NULL)
2466 return -EINVAL; 2480 return -EINVAL;
2467 err = rdev->mddev->pers-> 2481 err = rdev->mddev->pers->
2468 hot_remove_disk(rdev->mddev, rdev->raid_disk); 2482 hot_remove_disk(rdev->mddev, rdev->raid_disk);
@@ -4619,9 +4633,6 @@ int md_run(mddev_t *mddev)
4619 if (mddev->flags) 4633 if (mddev->flags)
4620 md_update_sb(mddev, 0); 4634 md_update_sb(mddev, 0);
4621 4635
4622 md_wakeup_thread(mddev->thread);
4623 md_wakeup_thread(mddev->sync_thread); /* possibly kick off a reshape */
4624
4625 md_new_event(mddev); 4636 md_new_event(mddev);
4626 sysfs_notify_dirent_safe(mddev->sysfs_state); 4637 sysfs_notify_dirent_safe(mddev->sysfs_state);
4627 sysfs_notify_dirent_safe(mddev->sysfs_action); 4638 sysfs_notify_dirent_safe(mddev->sysfs_action);
@@ -4642,6 +4653,10 @@ static int do_md_run(mddev_t *mddev)
4642 bitmap_destroy(mddev); 4653 bitmap_destroy(mddev);
4643 goto out; 4654 goto out;
4644 } 4655 }
4656
4657 md_wakeup_thread(mddev->thread);
4658 md_wakeup_thread(mddev->sync_thread); /* possibly kick off a reshape */
4659
4645 set_capacity(mddev->gendisk, mddev->array_sectors); 4660 set_capacity(mddev->gendisk, mddev->array_sectors);
4646 revalidate_disk(mddev->gendisk); 4661 revalidate_disk(mddev->gendisk);
4647 mddev->changed = 1; 4662 mddev->changed = 1;
@@ -5259,6 +5274,8 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info)
5259 if (mddev->degraded) 5274 if (mddev->degraded)
5260 set_bit(MD_RECOVERY_RECOVER, &mddev->recovery); 5275 set_bit(MD_RECOVERY_RECOVER, &mddev->recovery);
5261 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 5276 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
5277 if (!err)
5278 md_new_event(mddev);
5262 md_wakeup_thread(mddev->thread); 5279 md_wakeup_thread(mddev->thread);
5263 return err; 5280 return err;
5264 } 5281 }
@@ -6866,8 +6883,8 @@ void md_do_sync(mddev_t *mddev)
6866 * Tune reconstruction: 6883 * Tune reconstruction:
6867 */ 6884 */
6868 window = 32*(PAGE_SIZE/512); 6885 window = 32*(PAGE_SIZE/512);
6869 printk(KERN_INFO "md: using %dk window, over a total of %llu blocks.\n", 6886 printk(KERN_INFO "md: using %dk window, over a total of %lluk.\n",
6870 window/2,(unsigned long long) max_sectors/2); 6887 window/2, (unsigned long long)max_sectors/2);
6871 6888
6872 atomic_set(&mddev->recovery_active, 0); 6889 atomic_set(&mddev->recovery_active, 0);
6873 last_check = 0; 6890 last_check = 0;
@@ -7045,7 +7062,6 @@ void md_do_sync(mddev_t *mddev)
7045} 7062}
7046EXPORT_SYMBOL_GPL(md_do_sync); 7063EXPORT_SYMBOL_GPL(md_do_sync);
7047 7064
7048
7049static int remove_and_add_spares(mddev_t *mddev) 7065static int remove_and_add_spares(mddev_t *mddev)
7050{ 7066{
7051 mdk_rdev_t *rdev; 7067 mdk_rdev_t *rdev;
@@ -7157,6 +7173,9 @@ static void reap_sync_thread(mddev_t *mddev)
7157 */ 7173 */
7158void md_check_recovery(mddev_t *mddev) 7174void md_check_recovery(mddev_t *mddev)
7159{ 7175{
7176 if (mddev->suspended)
7177 return;
7178
7160 if (mddev->bitmap) 7179 if (mddev->bitmap)
7161 bitmap_daemon_work(mddev); 7180 bitmap_daemon_work(mddev);
7162 7181
diff --git a/drivers/md/md.h b/drivers/md/md.h
index 0b1fd3f1d85b..1c26c7a08ae6 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -124,6 +124,7 @@ struct mddev_s
124#define MD_CHANGE_DEVS 0 /* Some device status has changed */ 124#define MD_CHANGE_DEVS 0 /* Some device status has changed */
125#define MD_CHANGE_CLEAN 1 /* transition to or from 'clean' */ 125#define MD_CHANGE_CLEAN 1 /* transition to or from 'clean' */
126#define MD_CHANGE_PENDING 2 /* switch from 'clean' to 'active' in progress */ 126#define MD_CHANGE_PENDING 2 /* switch from 'clean' to 'active' in progress */
127#define MD_ARRAY_FIRST_USE 3 /* First use of array, needs initialization */
127 128
128 int suspended; 129 int suspended;
129 atomic_t active_io; 130 atomic_t active_io;
@@ -330,6 +331,7 @@ struct mddev_s
330 atomic_t flush_pending; 331 atomic_t flush_pending;
331 struct work_struct flush_work; 332 struct work_struct flush_work;
332 struct work_struct event_work; /* used by dm to report failure event */ 333 struct work_struct event_work; /* used by dm to report failure event */
334 void (*sync_super)(mddev_t *mddev, mdk_rdev_t *rdev);
333}; 335};
334 336
335 337
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 5d096096f958..f7431b6d8447 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -497,21 +497,19 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio)
497 return best_disk; 497 return best_disk;
498} 498}
499 499
500static int raid1_congested(void *data, int bits) 500int md_raid1_congested(mddev_t *mddev, int bits)
501{ 501{
502 mddev_t *mddev = data;
503 conf_t *conf = mddev->private; 502 conf_t *conf = mddev->private;
504 int i, ret = 0; 503 int i, ret = 0;
505 504
506 if (mddev_congested(mddev, bits))
507 return 1;
508
509 rcu_read_lock(); 505 rcu_read_lock();
510 for (i = 0; i < mddev->raid_disks; i++) { 506 for (i = 0; i < mddev->raid_disks; i++) {
511 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev); 507 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev);
512 if (rdev && !test_bit(Faulty, &rdev->flags)) { 508 if (rdev && !test_bit(Faulty, &rdev->flags)) {
513 struct request_queue *q = bdev_get_queue(rdev->bdev); 509 struct request_queue *q = bdev_get_queue(rdev->bdev);
514 510
511 BUG_ON(!q);
512
515 /* Note the '|| 1' - when read_balance prefers 513 /* Note the '|| 1' - when read_balance prefers
516 * non-congested targets, it can be removed 514 * non-congested targets, it can be removed
517 */ 515 */
@@ -524,7 +522,15 @@ static int raid1_congested(void *data, int bits)
524 rcu_read_unlock(); 522 rcu_read_unlock();
525 return ret; 523 return ret;
526} 524}
525EXPORT_SYMBOL_GPL(md_raid1_congested);
527 526
527static int raid1_congested(void *data, int bits)
528{
529 mddev_t *mddev = data;
530
531 return mddev_congested(mddev, bits) ||
532 md_raid1_congested(mddev, bits);
533}
528 534
529static void flush_pending_writes(conf_t *conf) 535static void flush_pending_writes(conf_t *conf)
530{ 536{
@@ -1972,6 +1978,8 @@ static int run(mddev_t *mddev)
1972 return PTR_ERR(conf); 1978 return PTR_ERR(conf);
1973 1979
1974 list_for_each_entry(rdev, &mddev->disks, same_set) { 1980 list_for_each_entry(rdev, &mddev->disks, same_set) {
1981 if (!mddev->gendisk)
1982 continue;
1975 disk_stack_limits(mddev->gendisk, rdev->bdev, 1983 disk_stack_limits(mddev->gendisk, rdev->bdev,
1976 rdev->data_offset << 9); 1984 rdev->data_offset << 9);
1977 /* as we don't honour merge_bvec_fn, we must never risk 1985 /* as we don't honour merge_bvec_fn, we must never risk
@@ -2013,8 +2021,10 @@ static int run(mddev_t *mddev)
2013 2021
2014 md_set_array_sectors(mddev, raid1_size(mddev, 0, 0)); 2022 md_set_array_sectors(mddev, raid1_size(mddev, 0, 0));
2015 2023
2016 mddev->queue->backing_dev_info.congested_fn = raid1_congested; 2024 if (mddev->queue) {
2017 mddev->queue->backing_dev_info.congested_data = mddev; 2025 mddev->queue->backing_dev_info.congested_fn = raid1_congested;
2026 mddev->queue->backing_dev_info.congested_data = mddev;
2027 }
2018 return md_integrity_register(mddev); 2028 return md_integrity_register(mddev);
2019} 2029}
2020 2030
diff --git a/drivers/md/raid1.h b/drivers/md/raid1.h
index 5fc4ca1af863..e743a64fac4f 100644
--- a/drivers/md/raid1.h
+++ b/drivers/md/raid1.h
@@ -126,4 +126,6 @@ struct r1bio_s {
126 */ 126 */
127#define R1BIO_Returned 6 127#define R1BIO_Returned 6
128 128
129extern int md_raid1_congested(mddev_t *mddev, int bits);
130
129#endif 131#endif
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 346e69bfdab3..b72edf35ec54 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -129,7 +129,7 @@ static inline int raid5_dec_bi_hw_segments(struct bio *bio)
129 129
130static inline void raid5_set_bi_hw_segments(struct bio *bio, unsigned int cnt) 130static inline void raid5_set_bi_hw_segments(struct bio *bio, unsigned int cnt)
131{ 131{
132 bio->bi_phys_segments = raid5_bi_phys_segments(bio) || (cnt << 16); 132 bio->bi_phys_segments = raid5_bi_phys_segments(bio) | (cnt << 16);
133} 133}
134 134
135/* Find first data disk in a raid6 stripe */ 135/* Find first data disk in a raid6 stripe */
@@ -514,7 +514,7 @@ static void ops_run_io(struct stripe_head *sh, struct stripe_head_state *s)
514 bi = &sh->dev[i].req; 514 bi = &sh->dev[i].req;
515 515
516 bi->bi_rw = rw; 516 bi->bi_rw = rw;
517 if (rw == WRITE) 517 if (rw & WRITE)
518 bi->bi_end_io = raid5_end_write_request; 518 bi->bi_end_io = raid5_end_write_request;
519 else 519 else
520 bi->bi_end_io = raid5_end_read_request; 520 bi->bi_end_io = raid5_end_read_request;
@@ -548,13 +548,13 @@ static void ops_run_io(struct stripe_head *sh, struct stripe_head_state *s)
548 bi->bi_io_vec[0].bv_offset = 0; 548 bi->bi_io_vec[0].bv_offset = 0;
549 bi->bi_size = STRIPE_SIZE; 549 bi->bi_size = STRIPE_SIZE;
550 bi->bi_next = NULL; 550 bi->bi_next = NULL;
551 if (rw == WRITE && 551 if ((rw & WRITE) &&
552 test_bit(R5_ReWrite, &sh->dev[i].flags)) 552 test_bit(R5_ReWrite, &sh->dev[i].flags))
553 atomic_add(STRIPE_SECTORS, 553 atomic_add(STRIPE_SECTORS,
554 &rdev->corrected_errors); 554 &rdev->corrected_errors);
555 generic_make_request(bi); 555 generic_make_request(bi);
556 } else { 556 } else {
557 if (rw == WRITE) 557 if (rw & WRITE)
558 set_bit(STRIPE_DEGRADED, &sh->state); 558 set_bit(STRIPE_DEGRADED, &sh->state);
559 pr_debug("skip op %ld on disc %d for sector %llu\n", 559 pr_debug("skip op %ld on disc %d for sector %llu\n",
560 bi->bi_rw, i, (unsigned long long)sh->sector); 560 bi->bi_rw, i, (unsigned long long)sh->sector);
@@ -585,7 +585,7 @@ async_copy_data(int frombio, struct bio *bio, struct page *page,
585 init_async_submit(&submit, flags, tx, NULL, NULL, NULL); 585 init_async_submit(&submit, flags, tx, NULL, NULL, NULL);
586 586
587 bio_for_each_segment(bvl, bio, i) { 587 bio_for_each_segment(bvl, bio, i) {
588 int len = bio_iovec_idx(bio, i)->bv_len; 588 int len = bvl->bv_len;
589 int clen; 589 int clen;
590 int b_offset = 0; 590 int b_offset = 0;
591 591
@@ -601,8 +601,8 @@ async_copy_data(int frombio, struct bio *bio, struct page *page,
601 clen = len; 601 clen = len;
602 602
603 if (clen > 0) { 603 if (clen > 0) {
604 b_offset += bio_iovec_idx(bio, i)->bv_offset; 604 b_offset += bvl->bv_offset;
605 bio_page = bio_iovec_idx(bio, i)->bv_page; 605 bio_page = bvl->bv_page;
606 if (frombio) 606 if (frombio)
607 tx = async_memcpy(page, bio_page, page_offset, 607 tx = async_memcpy(page, bio_page, page_offset,
608 b_offset, clen, &submit); 608 b_offset, clen, &submit);
@@ -4858,7 +4858,7 @@ static raid5_conf_t *setup_conf(mddev_t *mddev)
4858 printk(KERN_INFO "md/raid:%s: device %s operational as raid" 4858 printk(KERN_INFO "md/raid:%s: device %s operational as raid"
4859 " disk %d\n", 4859 " disk %d\n",
4860 mdname(mddev), bdevname(rdev->bdev, b), raid_disk); 4860 mdname(mddev), bdevname(rdev->bdev, b), raid_disk);
4861 } else 4861 } else if (rdev->saved_raid_disk != raid_disk)
4862 /* Cannot rely on bitmap to complete recovery */ 4862 /* Cannot rely on bitmap to complete recovery */
4863 conf->fullsync = 1; 4863 conf->fullsync = 1;
4864 } 4864 }
diff --git a/drivers/misc/apds990x.c b/drivers/misc/apds990x.c
index 200311fea369..e2a52e5cf449 100644
--- a/drivers/misc/apds990x.c
+++ b/drivers/misc/apds990x.c
@@ -609,6 +609,7 @@ static int apds990x_detect(struct apds990x_chip *chip)
609 return ret; 609 return ret;
610} 610}
611 611
612#if defined(CONFIG_PM) || defined(CONFIG_PM_RUNTIME)
612static int apds990x_chip_on(struct apds990x_chip *chip) 613static int apds990x_chip_on(struct apds990x_chip *chip)
613{ 614{
614 int err = regulator_bulk_enable(ARRAY_SIZE(chip->regs), 615 int err = regulator_bulk_enable(ARRAY_SIZE(chip->regs),
@@ -624,6 +625,7 @@ static int apds990x_chip_on(struct apds990x_chip *chip)
624 apds990x_mode_on(chip); 625 apds990x_mode_on(chip);
625 return 0; 626 return 0;
626} 627}
628#endif
627 629
628static int apds990x_chip_off(struct apds990x_chip *chip) 630static int apds990x_chip_off(struct apds990x_chip *chip)
629{ 631{
diff --git a/drivers/misc/cs5535-mfgpt.c b/drivers/misc/cs5535-mfgpt.c
index e01e08c8c88b..bc685bfc4c33 100644
--- a/drivers/misc/cs5535-mfgpt.c
+++ b/drivers/misc/cs5535-mfgpt.c
@@ -174,7 +174,7 @@ struct cs5535_mfgpt_timer *cs5535_mfgpt_alloc_timer(int timer_nr, int domain)
174 timer_nr = t < max ? (int) t : -1; 174 timer_nr = t < max ? (int) t : -1;
175 } else { 175 } else {
176 /* check if the requested timer's available */ 176 /* check if the requested timer's available */
177 if (test_bit(timer_nr, mfgpt->avail)) 177 if (!test_bit(timer_nr, mfgpt->avail))
178 timer_nr = -1; 178 timer_nr = -1;
179 } 179 }
180 180
diff --git a/drivers/misc/spear13xx_pcie_gadget.c b/drivers/misc/spear13xx_pcie_gadget.c
index 7aded90f9daa..cfbddbef11de 100644
--- a/drivers/misc/spear13xx_pcie_gadget.c
+++ b/drivers/misc/spear13xx_pcie_gadget.c
@@ -845,7 +845,7 @@ err_iounmap:
845err_iounmap_app: 845err_iounmap_app:
846 iounmap(config->va_app_base); 846 iounmap(config->va_app_base);
847err_kzalloc: 847err_kzalloc:
848 kfree(config); 848 kfree(target);
849err_rel_res: 849err_rel_res:
850 release_mem_region(res1->start, resource_size(res1)); 850 release_mem_region(res1->start, resource_size(res1));
851err_rel_res0: 851err_rel_res0:
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 5da5bea0f9f0..7721de942c69 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -1144,9 +1144,17 @@ static int __devinit mmci_probe(struct amba_device *dev,
1144 else if (ret != -ENOSYS) 1144 else if (ret != -ENOSYS)
1145 goto err_gpio_cd; 1145 goto err_gpio_cd;
1146 1146
1147 /*
1148 * A gpio pin that will detect cards when inserted and removed
1149 * will most likely want to trigger on the edges if it is
1150 * 0 when ejected and 1 when inserted (or mutatis mutandis
1151 * for the inverted case) so we request triggers on both
1152 * edges.
1153 */
1147 ret = request_any_context_irq(gpio_to_irq(plat->gpio_cd), 1154 ret = request_any_context_irq(gpio_to_irq(plat->gpio_cd),
1148 mmci_cd_irq, 0, 1155 mmci_cd_irq,
1149 DRIVER_NAME " (cd)", host); 1156 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
1157 DRIVER_NAME " (cd)", host);
1150 if (ret >= 0) 1158 if (ret >= 0)
1151 host->gpio_cd_irq = gpio_to_irq(plat->gpio_cd); 1159 host->gpio_cd_irq = gpio_to_irq(plat->gpio_cd);
1152 } 1160 }
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 56098b3e17c0..5f10c23dff94 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3271,11 +3271,11 @@ void __init pci_register_set_vga_state(arch_set_vga_state_t func)
3271} 3271}
3272 3272
3273static int pci_set_vga_state_arch(struct pci_dev *dev, bool decode, 3273static int pci_set_vga_state_arch(struct pci_dev *dev, bool decode,
3274 unsigned int command_bits, bool change_bridge) 3274 unsigned int command_bits, u32 flags)
3275{ 3275{
3276 if (arch_set_vga_state) 3276 if (arch_set_vga_state)
3277 return arch_set_vga_state(dev, decode, command_bits, 3277 return arch_set_vga_state(dev, decode, command_bits,
3278 change_bridge); 3278 flags);
3279 return 0; 3279 return 0;
3280} 3280}
3281 3281
diff --git a/drivers/pcmcia/pxa2xx_vpac270.c b/drivers/pcmcia/pxa2xx_vpac270.c
index 435002dfc3ca..712baab3c83d 100644
--- a/drivers/pcmcia/pxa2xx_vpac270.c
+++ b/drivers/pcmcia/pxa2xx_vpac270.c
@@ -11,6 +11,7 @@
11 * 11 *
12 */ 12 */
13 13
14#include <linux/gpio.h>
14#include <linux/module.h> 15#include <linux/module.h>
15#include <linux/platform_device.h> 16#include <linux/platform_device.h>
16 17
diff --git a/drivers/sh/clk/core.c b/drivers/sh/clk/core.c
index 4f64183b27fa..7e9c39951ecb 100644
--- a/drivers/sh/clk/core.c
+++ b/drivers/sh/clk/core.c
@@ -635,7 +635,7 @@ static void clks_core_resume(void)
635 struct clk *clkp; 635 struct clk *clkp;
636 636
637 list_for_each_entry(clkp, &clock_list, node) { 637 list_for_each_entry(clkp, &clock_list, node) {
638 if (likely(clkp->ops)) { 638 if (likely(clkp->usecount && clkp->ops)) {
639 unsigned long rate = clkp->rate; 639 unsigned long rate = clkp->rate;
640 640
641 if (likely(clkp->ops->set_parent)) 641 if (likely(clkp->ops->set_parent))
diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c
index f706dba165cf..cc880c95e7de 100644
--- a/drivers/spi/spi_bfin5xx.c
+++ b/drivers/spi/spi_bfin5xx.c
@@ -681,13 +681,14 @@ static void bfin_spi_pump_transfers(unsigned long data)
681 drv_data->cs_change = transfer->cs_change; 681 drv_data->cs_change = transfer->cs_change;
682 682
683 /* Bits per word setup */ 683 /* Bits per word setup */
684 bits_per_word = transfer->bits_per_word ? : message->spi->bits_per_word; 684 bits_per_word = transfer->bits_per_word ? :
685 if ((bits_per_word > 0) && (bits_per_word % 16 == 0)) { 685 message->spi->bits_per_word ? : 8;
686 if (bits_per_word % 16 == 0) {
686 drv_data->n_bytes = bits_per_word/8; 687 drv_data->n_bytes = bits_per_word/8;
687 drv_data->len = (transfer->len) >> 1; 688 drv_data->len = (transfer->len) >> 1;
688 cr_width = BIT_CTL_WORDSIZE; 689 cr_width = BIT_CTL_WORDSIZE;
689 drv_data->ops = &bfin_bfin_spi_transfer_ops_u16; 690 drv_data->ops = &bfin_bfin_spi_transfer_ops_u16;
690 } else if ((bits_per_word > 0) && (bits_per_word % 8 == 0)) { 691 } else if (bits_per_word % 8 == 0) {
691 drv_data->n_bytes = bits_per_word/8; 692 drv_data->n_bytes = bits_per_word/8;
692 drv_data->len = transfer->len; 693 drv_data->len = transfer->len;
693 cr_width = 0; 694 cr_width = 0;
diff --git a/drivers/staging/iio/accel/adis16201.h b/drivers/staging/iio/accel/adis16201.h
index 0b9b85424dfa..4cc1a5bfab40 100644
--- a/drivers/staging/iio/accel/adis16201.h
+++ b/drivers/staging/iio/accel/adis16201.h
@@ -81,7 +81,6 @@ struct adis16201_state {
81 81
82int adis16201_set_irq(struct iio_dev *indio_dev, bool enable); 82int adis16201_set_irq(struct iio_dev *indio_dev, bool enable);
83 83
84#ifdef CONFIG_IIO_RING_BUFFER
85enum adis16201_scan { 84enum adis16201_scan {
86 ADIS16201_SCAN_SUPPLY, 85 ADIS16201_SCAN_SUPPLY,
87 ADIS16201_SCAN_ACC_X, 86 ADIS16201_SCAN_ACC_X,
@@ -92,6 +91,7 @@ enum adis16201_scan {
92 ADIS16201_SCAN_INCLI_Y, 91 ADIS16201_SCAN_INCLI_Y,
93}; 92};
94 93
94#ifdef CONFIG_IIO_RING_BUFFER
95void adis16201_remove_trigger(struct iio_dev *indio_dev); 95void adis16201_remove_trigger(struct iio_dev *indio_dev);
96int adis16201_probe_trigger(struct iio_dev *indio_dev); 96int adis16201_probe_trigger(struct iio_dev *indio_dev);
97 97
diff --git a/drivers/staging/iio/accel/adis16203.h b/drivers/staging/iio/accel/adis16203.h
index 8bb8ce50c248..175e21bb9b40 100644
--- a/drivers/staging/iio/accel/adis16203.h
+++ b/drivers/staging/iio/accel/adis16203.h
@@ -76,7 +76,6 @@ struct adis16203_state {
76 76
77int adis16203_set_irq(struct iio_dev *indio_dev, bool enable); 77int adis16203_set_irq(struct iio_dev *indio_dev, bool enable);
78 78
79#ifdef CONFIG_IIO_RING_BUFFER
80enum adis16203_scan { 79enum adis16203_scan {
81 ADIS16203_SCAN_SUPPLY, 80 ADIS16203_SCAN_SUPPLY,
82 ADIS16203_SCAN_AUX_ADC, 81 ADIS16203_SCAN_AUX_ADC,
@@ -85,6 +84,7 @@ enum adis16203_scan {
85 ADIS16203_SCAN_INCLI_Y, 84 ADIS16203_SCAN_INCLI_Y,
86}; 85};
87 86
87#ifdef CONFIG_IIO_RING_BUFFER
88void adis16203_remove_trigger(struct iio_dev *indio_dev); 88void adis16203_remove_trigger(struct iio_dev *indio_dev);
89int adis16203_probe_trigger(struct iio_dev *indio_dev); 89int adis16203_probe_trigger(struct iio_dev *indio_dev);
90 90
diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
index f2cb7503fcb2..465210930890 100644
--- a/drivers/tty/serial/pch_uart.c
+++ b/drivers/tty/serial/pch_uart.c
@@ -1397,6 +1397,7 @@ static struct eg20t_port *pch_uart_init_port(struct pci_dev *pdev,
1397 int fifosize, base_baud; 1397 int fifosize, base_baud;
1398 int port_type; 1398 int port_type;
1399 struct pch_uart_driver_data *board; 1399 struct pch_uart_driver_data *board;
1400 const char *board_name;
1400 1401
1401 board = &drv_dat[id->driver_data]; 1402 board = &drv_dat[id->driver_data];
1402 port_type = board->port_type; 1403 port_type = board->port_type;
@@ -1412,7 +1413,8 @@ static struct eg20t_port *pch_uart_init_port(struct pci_dev *pdev,
1412 base_baud = 1843200; /* 1.8432MHz */ 1413 base_baud = 1843200; /* 1.8432MHz */
1413 1414
1414 /* quirk for CM-iTC board */ 1415 /* quirk for CM-iTC board */
1415 if (strstr(dmi_get_system_info(DMI_BOARD_NAME), "CM-iTC")) 1416 board_name = dmi_get_system_info(DMI_BOARD_NAME);
1417 if (board_name && strstr(board_name, "CM-iTC"))
1416 base_baud = 192000000; /* 192.0MHz */ 1418 base_baud = 192000000; /* 192.0MHz */
1417 1419
1418 switch (port_type) { 1420 switch (port_type) {
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
index ebb893c49e90..d7aaec5667bf 100644
--- a/drivers/video/aty/atyfb_base.c
+++ b/drivers/video/aty/atyfb_base.c
@@ -248,10 +248,6 @@ static int atyfb_sync(struct fb_info *info);
248 248
249static int aty_init(struct fb_info *info); 249static int aty_init(struct fb_info *info);
250 250
251#ifdef CONFIG_ATARI
252static int store_video_par(char *videopar, unsigned char m64_num);
253#endif
254
255static void aty_get_crtc(const struct atyfb_par *par, struct crtc *crtc); 251static void aty_get_crtc(const struct atyfb_par *par, struct crtc *crtc);
256 252
257static void aty_set_crtc(const struct atyfb_par *par, const struct crtc *crtc); 253static void aty_set_crtc(const struct atyfb_par *par, const struct crtc *crtc);
@@ -2268,11 +2264,13 @@ error:
2268 return; 2264 return;
2269} 2265}
2270 2266
2267#ifdef CONFIG_PCI
2271static void aty_bl_exit(struct backlight_device *bd) 2268static void aty_bl_exit(struct backlight_device *bd)
2272{ 2269{
2273 backlight_device_unregister(bd); 2270 backlight_device_unregister(bd);
2274 printk("aty: Backlight unloaded\n"); 2271 printk("aty: Backlight unloaded\n");
2275} 2272}
2273#endif /* CONFIG_PCI */
2276 2274
2277#endif /* CONFIG_FB_ATY_BACKLIGHT */ 2275#endif /* CONFIG_FB_ATY_BACKLIGHT */
2278 2276
@@ -2789,7 +2787,7 @@ aty_init_exit:
2789 return ret; 2787 return ret;
2790} 2788}
2791 2789
2792#ifdef CONFIG_ATARI 2790#if defined(CONFIG_ATARI) && !defined(MODULE)
2793static int __devinit store_video_par(char *video_str, unsigned char m64_num) 2791static int __devinit store_video_par(char *video_str, unsigned char m64_num)
2794{ 2792{
2795 char *p; 2793 char *p;
@@ -2818,7 +2816,7 @@ static int __devinit store_video_par(char *video_str, unsigned char m64_num)
2818 phys_vmembase[m64_num] = 0; 2816 phys_vmembase[m64_num] = 0;
2819 return -1; 2817 return -1;
2820} 2818}
2821#endif /* CONFIG_ATARI */ 2819#endif /* CONFIG_ATARI && !MODULE */
2822 2820
2823/* 2821/*
2824 * Blank the display. 2822 * Blank the display.
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index 0c9373bedd1f..2d93c8d61ad5 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -302,6 +302,18 @@ config BACKLIGHT_ADP8860
302 To compile this driver as a module, choose M here: the module will 302 To compile this driver as a module, choose M here: the module will
303 be called adp8860_bl. 303 be called adp8860_bl.
304 304
305config BACKLIGHT_ADP8870
306 tristate "Backlight Driver for ADP8870 using WLED"
307 depends on BACKLIGHT_CLASS_DEVICE && I2C
308 select NEW_LEDS
309 select LEDS_CLASS
310 help
311 If you have a LCD backlight connected to the ADP8870,
312 say Y here to enable this driver.
313
314 To compile this driver as a module, choose M here: the module will
315 be called adp8870_bl.
316
305config BACKLIGHT_88PM860X 317config BACKLIGHT_88PM860X
306 tristate "Backlight Driver for 88PM8606 using WLED" 318 tristate "Backlight Driver for 88PM8606 using WLED"
307 depends on MFD_88PM860X 319 depends on MFD_88PM860X
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index b9ca8490df87..ee72adb8786e 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_BACKLIGHT_WM831X) += wm831x_bl.o
34obj-$(CONFIG_BACKLIGHT_ADX) += adx_bl.o 34obj-$(CONFIG_BACKLIGHT_ADX) += adx_bl.o
35obj-$(CONFIG_BACKLIGHT_ADP5520) += adp5520_bl.o 35obj-$(CONFIG_BACKLIGHT_ADP5520) += adp5520_bl.o
36obj-$(CONFIG_BACKLIGHT_ADP8860) += adp8860_bl.o 36obj-$(CONFIG_BACKLIGHT_ADP8860) += adp8860_bl.o
37obj-$(CONFIG_BACKLIGHT_ADP8870) += adp8870_bl.o
37obj-$(CONFIG_BACKLIGHT_88PM860X) += 88pm860x_bl.o 38obj-$(CONFIG_BACKLIGHT_88PM860X) += 88pm860x_bl.o
38obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o 39obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o
39 40
diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c
new file mode 100644
index 000000000000..05a8832bb3eb
--- /dev/null
+++ b/drivers/video/backlight/adp8870_bl.c
@@ -0,0 +1,1012 @@
1/*
2 * Backlight driver for Analog Devices ADP8870 Backlight Devices
3 *
4 * Copyright 2009-2011 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#include <linux/module.h>
10#include <linux/version.h>
11#include <linux/init.h>
12#include <linux/errno.h>
13#include <linux/pm.h>
14#include <linux/platform_device.h>
15#include <linux/i2c.h>
16#include <linux/fb.h>
17#include <linux/backlight.h>
18#include <linux/leds.h>
19#include <linux/workqueue.h>
20#include <linux/slab.h>
21
22#include <linux/i2c/adp8870.h>
23#define ADP8870_EXT_FEATURES
24#define ADP8870_USE_LEDS
25
26
27#define ADP8870_MFDVID 0x00 /* Manufacturer and device ID */
28#define ADP8870_MDCR 0x01 /* Device mode and status */
29#define ADP8870_INT_STAT 0x02 /* Interrupts status */
30#define ADP8870_INT_EN 0x03 /* Interrupts enable */
31#define ADP8870_CFGR 0x04 /* Configuration register */
32#define ADP8870_BLSEL 0x05 /* Sink enable backlight or independent */
33#define ADP8870_PWMLED 0x06 /* PWM Enable Selection Register */
34#define ADP8870_BLOFF 0x07 /* Backlight off timeout */
35#define ADP8870_BLDIM 0x08 /* Backlight dim timeout */
36#define ADP8870_BLFR 0x09 /* Backlight fade in and out rates */
37#define ADP8870_BLMX1 0x0A /* Backlight (Brightness Level 1-daylight) maximum current */
38#define ADP8870_BLDM1 0x0B /* Backlight (Brightness Level 1-daylight) dim current */
39#define ADP8870_BLMX2 0x0C /* Backlight (Brightness Level 2-bright) maximum current */
40#define ADP8870_BLDM2 0x0D /* Backlight (Brightness Level 2-bright) dim current */
41#define ADP8870_BLMX3 0x0E /* Backlight (Brightness Level 3-office) maximum current */
42#define ADP8870_BLDM3 0x0F /* Backlight (Brightness Level 3-office) dim current */
43#define ADP8870_BLMX4 0x10 /* Backlight (Brightness Level 4-indoor) maximum current */
44#define ADP8870_BLDM4 0x11 /* Backlight (Brightness Level 4-indoor) dim current */
45#define ADP8870_BLMX5 0x12 /* Backlight (Brightness Level 5-dark) maximum current */
46#define ADP8870_BLDM5 0x13 /* Backlight (Brightness Level 5-dark) dim current */
47#define ADP8870_ISCLAW 0x1A /* Independent sink current fade law register */
48#define ADP8870_ISCC 0x1B /* Independent sink current control register */
49#define ADP8870_ISCT1 0x1C /* Independent Sink Current Timer Register LED[7:5] */
50#define ADP8870_ISCT2 0x1D /* Independent Sink Current Timer Register LED[4:1] */
51#define ADP8870_ISCF 0x1E /* Independent sink current fade register */
52#define ADP8870_ISC1 0x1F /* Independent Sink Current LED1 */
53#define ADP8870_ISC2 0x20 /* Independent Sink Current LED2 */
54#define ADP8870_ISC3 0x21 /* Independent Sink Current LED3 */
55#define ADP8870_ISC4 0x22 /* Independent Sink Current LED4 */
56#define ADP8870_ISC5 0x23 /* Independent Sink Current LED5 */
57#define ADP8870_ISC6 0x24 /* Independent Sink Current LED6 */
58#define ADP8870_ISC7 0x25 /* Independent Sink Current LED7 (Brightness Level 1-daylight) */
59#define ADP8870_ISC7_L2 0x26 /* Independent Sink Current LED7 (Brightness Level 2-bright) */
60#define ADP8870_ISC7_L3 0x27 /* Independent Sink Current LED7 (Brightness Level 3-office) */
61#define ADP8870_ISC7_L4 0x28 /* Independent Sink Current LED7 (Brightness Level 4-indoor) */
62#define ADP8870_ISC7_L5 0x29 /* Independent Sink Current LED7 (Brightness Level 5-dark) */
63#define ADP8870_CMP_CTL 0x2D /* ALS Comparator Control Register */
64#define ADP8870_ALS1_EN 0x2E /* Main ALS comparator level enable */
65#define ADP8870_ALS2_EN 0x2F /* Second ALS comparator level enable */
66#define ADP8870_ALS1_STAT 0x30 /* Main ALS Comparator Status Register */
67#define ADP8870_ALS2_STAT 0x31 /* Second ALS Comparator Status Register */
68#define ADP8870_L2TRP 0x32 /* L2 comparator reference */
69#define ADP8870_L2HYS 0x33 /* L2 hysteresis */
70#define ADP8870_L3TRP 0x34 /* L3 comparator reference */
71#define ADP8870_L3HYS 0x35 /* L3 hysteresis */
72#define ADP8870_L4TRP 0x36 /* L4 comparator reference */
73#define ADP8870_L4HYS 0x37 /* L4 hysteresis */
74#define ADP8870_L5TRP 0x38 /* L5 comparator reference */
75#define ADP8870_L5HYS 0x39 /* L5 hysteresis */
76#define ADP8870_PH1LEVL 0x40 /* First phototransistor ambient light level-low byte register */
77#define ADP8870_PH1LEVH 0x41 /* First phototransistor ambient light level-high byte register */
78#define ADP8870_PH2LEVL 0x42 /* Second phototransistor ambient light level-low byte register */
79#define ADP8870_PH2LEVH 0x43 /* Second phototransistor ambient light level-high byte register */
80
81#define ADP8870_MANUFID 0x3 /* Analog Devices AD8870 Manufacturer and device ID */
82#define ADP8870_DEVID(x) ((x) & 0xF)
83#define ADP8870_MANID(x) ((x) >> 4)
84
85/* MDCR Device mode and status */
86#define D7ALSEN (1 << 7)
87#define INT_CFG (1 << 6)
88#define NSTBY (1 << 5)
89#define DIM_EN (1 << 4)
90#define GDWN_DIS (1 << 3)
91#define SIS_EN (1 << 2)
92#define CMP_AUTOEN (1 << 1)
93#define BLEN (1 << 0)
94
95/* ADP8870_ALS1_EN Main ALS comparator level enable */
96#define L5_EN (1 << 3)
97#define L4_EN (1 << 2)
98#define L3_EN (1 << 1)
99#define L2_EN (1 << 0)
100
101#define CFGR_BLV_SHIFT 3
102#define CFGR_BLV_MASK 0x7
103#define ADP8870_FLAG_LED_MASK 0xFF
104
105#define FADE_VAL(in, out) ((0xF & (in)) | ((0xF & (out)) << 4))
106#define BL_CFGR_VAL(law, blv) ((((blv) & CFGR_BLV_MASK) << CFGR_BLV_SHIFT) | ((0x3 & (law)) << 1))
107#define ALS_CMPR_CFG_VAL(filt) ((0x7 & (filt)) << 1)
108
109struct adp8870_bl {
110 struct i2c_client *client;
111 struct backlight_device *bl;
112 struct adp8870_led *led;
113 struct adp8870_backlight_platform_data *pdata;
114 struct mutex lock;
115 unsigned long cached_daylight_max;
116 int id;
117 int revid;
118 int current_brightness;
119};
120
121struct adp8870_led {
122 struct led_classdev cdev;
123 struct work_struct work;
124 struct i2c_client *client;
125 enum led_brightness new_brightness;
126 int id;
127 int flags;
128};
129
130static int adp8870_read(struct i2c_client *client, int reg, uint8_t *val)
131{
132 int ret;
133
134 ret = i2c_smbus_read_byte_data(client, reg);
135 if (ret < 0) {
136 dev_err(&client->dev, "failed reading at 0x%02x\n", reg);
137 return ret;
138 }
139
140 *val = ret;
141 return 0;
142}
143
144
145static int adp8870_write(struct i2c_client *client, u8 reg, u8 val)
146{
147 int ret = i2c_smbus_write_byte_data(client, reg, val);
148 if (ret)
149 dev_err(&client->dev, "failed to write\n");
150
151 return ret;
152}
153
154static int adp8870_set_bits(struct i2c_client *client, int reg, uint8_t bit_mask)
155{
156 struct adp8870_bl *data = i2c_get_clientdata(client);
157 uint8_t reg_val;
158 int ret;
159
160 mutex_lock(&data->lock);
161
162 ret = adp8870_read(client, reg, &reg_val);
163
164 if (!ret && ((reg_val & bit_mask) == 0)) {
165 reg_val |= bit_mask;
166 ret = adp8870_write(client, reg, reg_val);
167 }
168
169 mutex_unlock(&data->lock);
170 return ret;
171}
172
173static int adp8870_clr_bits(struct i2c_client *client, int reg, uint8_t bit_mask)
174{
175 struct adp8870_bl *data = i2c_get_clientdata(client);
176 uint8_t reg_val;
177 int ret;
178
179 mutex_lock(&data->lock);
180
181 ret = adp8870_read(client, reg, &reg_val);
182
183 if (!ret && (reg_val & bit_mask)) {
184 reg_val &= ~bit_mask;
185 ret = adp8870_write(client, reg, reg_val);
186 }
187
188 mutex_unlock(&data->lock);
189 return ret;
190}
191
192/*
193 * Independent sink / LED
194 */
195#if defined(ADP8870_USE_LEDS)
196static void adp8870_led_work(struct work_struct *work)
197{
198 struct adp8870_led *led = container_of(work, struct adp8870_led, work);
199 adp8870_write(led->client, ADP8870_ISC1 + led->id - 1,
200 led->new_brightness >> 1);
201}
202
203static void adp8870_led_set(struct led_classdev *led_cdev,
204 enum led_brightness value)
205{
206 struct adp8870_led *led;
207
208 led = container_of(led_cdev, struct adp8870_led, cdev);
209 led->new_brightness = value;
210 /*
211 * Use workqueue for IO since I2C operations can sleep.
212 */
213 schedule_work(&led->work);
214}
215
216static int adp8870_led_setup(struct adp8870_led *led)
217{
218 struct i2c_client *client = led->client;
219 int ret = 0;
220
221 ret = adp8870_write(client, ADP8870_ISC1 + led->id - 1, 0);
222 if (ret)
223 return ret;
224
225 ret = adp8870_set_bits(client, ADP8870_ISCC, 1 << (led->id - 1));
226 if (ret)
227 return ret;
228
229 if (led->id > 4)
230 ret = adp8870_set_bits(client, ADP8870_ISCT1,
231 (led->flags & 0x3) << ((led->id - 5) * 2));
232 else
233 ret = adp8870_set_bits(client, ADP8870_ISCT2,
234 (led->flags & 0x3) << ((led->id - 1) * 2));
235
236 return ret;
237}
238
239static int __devinit adp8870_led_probe(struct i2c_client *client)
240{
241 struct adp8870_backlight_platform_data *pdata =
242 client->dev.platform_data;
243 struct adp8870_bl *data = i2c_get_clientdata(client);
244 struct adp8870_led *led, *led_dat;
245 struct led_info *cur_led;
246 int ret, i;
247
248
249 led = kcalloc(pdata->num_leds, sizeof(*led), GFP_KERNEL);
250 if (led == NULL) {
251 dev_err(&client->dev, "failed to alloc memory\n");
252 return -ENOMEM;
253 }
254
255 ret = adp8870_write(client, ADP8870_ISCLAW, pdata->led_fade_law);
256 if (ret)
257 goto err_free;
258
259 ret = adp8870_write(client, ADP8870_ISCT1,
260 (pdata->led_on_time & 0x3) << 6);
261 if (ret)
262 goto err_free;
263
264 ret = adp8870_write(client, ADP8870_ISCF,
265 FADE_VAL(pdata->led_fade_in, pdata->led_fade_out));
266 if (ret)
267 goto err_free;
268
269 for (i = 0; i < pdata->num_leds; ++i) {
270 cur_led = &pdata->leds[i];
271 led_dat = &led[i];
272
273 led_dat->id = cur_led->flags & ADP8870_FLAG_LED_MASK;
274
275 if (led_dat->id > 7 || led_dat->id < 1) {
276 dev_err(&client->dev, "Invalid LED ID %d\n",
277 led_dat->id);
278 goto err;
279 }
280
281 if (pdata->bl_led_assign & (1 << (led_dat->id - 1))) {
282 dev_err(&client->dev, "LED %d used by Backlight\n",
283 led_dat->id);
284 goto err;
285 }
286
287 led_dat->cdev.name = cur_led->name;
288 led_dat->cdev.default_trigger = cur_led->default_trigger;
289 led_dat->cdev.brightness_set = adp8870_led_set;
290 led_dat->cdev.brightness = LED_OFF;
291 led_dat->flags = cur_led->flags >> FLAG_OFFT_SHIFT;
292 led_dat->client = client;
293 led_dat->new_brightness = LED_OFF;
294 INIT_WORK(&led_dat->work, adp8870_led_work);
295
296 ret = led_classdev_register(&client->dev, &led_dat->cdev);
297 if (ret) {
298 dev_err(&client->dev, "failed to register LED %d\n",
299 led_dat->id);
300 goto err;
301 }
302
303 ret = adp8870_led_setup(led_dat);
304 if (ret) {
305 dev_err(&client->dev, "failed to write\n");
306 i++;
307 goto err;
308 }
309 }
310
311 data->led = led;
312
313 return 0;
314
315 err:
316 for (i = i - 1; i >= 0; --i) {
317 led_classdev_unregister(&led[i].cdev);
318 cancel_work_sync(&led[i].work);
319 }
320
321 err_free:
322 kfree(led);
323
324 return ret;
325}
326
327static int __devexit adp8870_led_remove(struct i2c_client *client)
328{
329 struct adp8870_backlight_platform_data *pdata =
330 client->dev.platform_data;
331 struct adp8870_bl *data = i2c_get_clientdata(client);
332 int i;
333
334 for (i = 0; i < pdata->num_leds; i++) {
335 led_classdev_unregister(&data->led[i].cdev);
336 cancel_work_sync(&data->led[i].work);
337 }
338
339 kfree(data->led);
340 return 0;
341}
342#else
343static int __devinit adp8870_led_probe(struct i2c_client *client)
344{
345 return 0;
346}
347
348static int __devexit adp8870_led_remove(struct i2c_client *client)
349{
350 return 0;
351}
352#endif
353
354static int adp8870_bl_set(struct backlight_device *bl, int brightness)
355{
356 struct adp8870_bl *data = bl_get_data(bl);
357 struct i2c_client *client = data->client;
358 int ret = 0;
359
360 if (data->pdata->en_ambl_sens) {
361 if ((brightness > 0) && (brightness < ADP8870_MAX_BRIGHTNESS)) {
362 /* Disable Ambient Light auto adjust */
363 ret = adp8870_clr_bits(client, ADP8870_MDCR,
364 CMP_AUTOEN);
365 if (ret)
366 return ret;
367 ret = adp8870_write(client, ADP8870_BLMX1, brightness);
368 if (ret)
369 return ret;
370 } else {
371 /*
372 * MAX_BRIGHTNESS -> Enable Ambient Light auto adjust
373 * restore daylight l1 sysfs brightness
374 */
375 ret = adp8870_write(client, ADP8870_BLMX1,
376 data->cached_daylight_max);
377 if (ret)
378 return ret;
379
380 ret = adp8870_set_bits(client, ADP8870_MDCR,
381 CMP_AUTOEN);
382 if (ret)
383 return ret;
384 }
385 } else {
386 ret = adp8870_write(client, ADP8870_BLMX1, brightness);
387 if (ret)
388 return ret;
389 }
390
391 if (data->current_brightness && brightness == 0)
392 ret = adp8870_set_bits(client,
393 ADP8870_MDCR, DIM_EN);
394 else if (data->current_brightness == 0 && brightness)
395 ret = adp8870_clr_bits(client,
396 ADP8870_MDCR, DIM_EN);
397
398 if (!ret)
399 data->current_brightness = brightness;
400
401 return ret;
402}
403
404static int adp8870_bl_update_status(struct backlight_device *bl)
405{
406 int brightness = bl->props.brightness;
407 if (bl->props.power != FB_BLANK_UNBLANK)
408 brightness = 0;
409
410 if (bl->props.fb_blank != FB_BLANK_UNBLANK)
411 brightness = 0;
412
413 return adp8870_bl_set(bl, brightness);
414}
415
416static int adp8870_bl_get_brightness(struct backlight_device *bl)
417{
418 struct adp8870_bl *data = bl_get_data(bl);
419
420 return data->current_brightness;
421}
422
423static const struct backlight_ops adp8870_bl_ops = {
424 .update_status = adp8870_bl_update_status,
425 .get_brightness = adp8870_bl_get_brightness,
426};
427
428static int adp8870_bl_setup(struct backlight_device *bl)
429{
430 struct adp8870_bl *data = bl_get_data(bl);
431 struct i2c_client *client = data->client;
432 struct adp8870_backlight_platform_data *pdata = data->pdata;
433 int ret = 0;
434
435 ret = adp8870_write(client, ADP8870_BLSEL, ~pdata->bl_led_assign);
436 if (ret)
437 return ret;
438
439 ret = adp8870_write(client, ADP8870_PWMLED, pdata->pwm_assign);
440 if (ret)
441 return ret;
442
443 ret = adp8870_write(client, ADP8870_BLMX1, pdata->l1_daylight_max);
444 if (ret)
445 return ret;
446
447 ret = adp8870_write(client, ADP8870_BLDM1, pdata->l1_daylight_dim);
448 if (ret)
449 return ret;
450
451 if (pdata->en_ambl_sens) {
452 data->cached_daylight_max = pdata->l1_daylight_max;
453 ret = adp8870_write(client, ADP8870_BLMX2,
454 pdata->l2_bright_max);
455 if (ret)
456 return ret;
457 ret = adp8870_write(client, ADP8870_BLDM2,
458 pdata->l2_bright_dim);
459 if (ret)
460 return ret;
461
462 ret = adp8870_write(client, ADP8870_BLMX3,
463 pdata->l3_office_max);
464 if (ret)
465 return ret;
466 ret = adp8870_write(client, ADP8870_BLDM3,
467 pdata->l3_office_dim);
468 if (ret)
469 return ret;
470
471 ret = adp8870_write(client, ADP8870_BLMX4,
472 pdata->l4_indoor_max);
473 if (ret)
474 return ret;
475
476 ret = adp8870_write(client, ADP8870_BLDM4,
477 pdata->l4_indor_dim);
478 if (ret)
479 return ret;
480
481 ret = adp8870_write(client, ADP8870_BLMX5,
482 pdata->l5_dark_max);
483 if (ret)
484 return ret;
485
486 ret = adp8870_write(client, ADP8870_BLDM5,
487 pdata->l5_dark_dim);
488 if (ret)
489 return ret;
490
491 ret = adp8870_write(client, ADP8870_L2TRP, pdata->l2_trip);
492 if (ret)
493 return ret;
494
495 ret = adp8870_write(client, ADP8870_L2HYS, pdata->l2_hyst);
496 if (ret)
497 return ret;
498
499 ret = adp8870_write(client, ADP8870_L3TRP, pdata->l3_trip);
500 if (ret)
501 return ret;
502
503 ret = adp8870_write(client, ADP8870_L3HYS, pdata->l3_hyst);
504 if (ret)
505 return ret;
506
507 ret = adp8870_write(client, ADP8870_L4TRP, pdata->l4_trip);
508 if (ret)
509 return ret;
510
511 ret = adp8870_write(client, ADP8870_L4HYS, pdata->l4_hyst);
512 if (ret)
513 return ret;
514
515 ret = adp8870_write(client, ADP8870_L5TRP, pdata->l5_trip);
516 if (ret)
517 return ret;
518
519 ret = adp8870_write(client, ADP8870_L5HYS, pdata->l5_hyst);
520 if (ret)
521 return ret;
522
523 ret = adp8870_write(client, ADP8870_ALS1_EN, L5_EN | L4_EN |
524 L3_EN | L2_EN);
525 if (ret)
526 return ret;
527
528 ret = adp8870_write(client, ADP8870_CMP_CTL,
529 ALS_CMPR_CFG_VAL(pdata->abml_filt));
530 if (ret)
531 return ret;
532 }
533
534 ret = adp8870_write(client, ADP8870_CFGR,
535 BL_CFGR_VAL(pdata->bl_fade_law, 0));
536 if (ret)
537 return ret;
538
539 ret = adp8870_write(client, ADP8870_BLFR, FADE_VAL(pdata->bl_fade_in,
540 pdata->bl_fade_out));
541 if (ret)
542 return ret;
543 /*
544 * ADP8870 Rev0 requires GDWN_DIS bit set
545 */
546
547 ret = adp8870_set_bits(client, ADP8870_MDCR, BLEN | DIM_EN | NSTBY |
548 (data->revid == 0 ? GDWN_DIS : 0));
549
550 return ret;
551}
552
553static ssize_t adp8870_show(struct device *dev, char *buf, int reg)
554{
555 struct adp8870_bl *data = dev_get_drvdata(dev);
556 int error;
557 uint8_t reg_val;
558
559 mutex_lock(&data->lock);
560 error = adp8870_read(data->client, reg, &reg_val);
561 mutex_unlock(&data->lock);
562
563 if (error < 0)
564 return error;
565
566 return sprintf(buf, "%u\n", reg_val);
567}
568
569static ssize_t adp8870_store(struct device *dev, const char *buf,
570 size_t count, int reg)
571{
572 struct adp8870_bl *data = dev_get_drvdata(dev);
573 unsigned long val;
574 int ret;
575
576 ret = strict_strtoul(buf, 10, &val);
577 if (ret)
578 return ret;
579
580 mutex_lock(&data->lock);
581 adp8870_write(data->client, reg, val);
582 mutex_unlock(&data->lock);
583
584 return count;
585}
586
587static ssize_t adp8870_bl_l5_dark_max_show(struct device *dev,
588 struct device_attribute *attr, char *buf)
589{
590 return adp8870_show(dev, buf, ADP8870_BLMX5);
591}
592
593static ssize_t adp8870_bl_l5_dark_max_store(struct device *dev,
594 struct device_attribute *attr, const char *buf, size_t count)
595{
596 return adp8870_store(dev, buf, count, ADP8870_BLMX5);
597}
598static DEVICE_ATTR(l5_dark_max, 0664, adp8870_bl_l5_dark_max_show,
599 adp8870_bl_l5_dark_max_store);
600
601
602static ssize_t adp8870_bl_l4_indoor_max_show(struct device *dev,
603 struct device_attribute *attr, char *buf)
604{
605 return adp8870_show(dev, buf, ADP8870_BLMX4);
606}
607
608static ssize_t adp8870_bl_l4_indoor_max_store(struct device *dev,
609 struct device_attribute *attr, const char *buf, size_t count)
610{
611 return adp8870_store(dev, buf, count, ADP8870_BLMX4);
612}
613static DEVICE_ATTR(l4_indoor_max, 0664, adp8870_bl_l4_indoor_max_show,
614 adp8870_bl_l4_indoor_max_store);
615
616
617static ssize_t adp8870_bl_l3_office_max_show(struct device *dev,
618 struct device_attribute *attr, char *buf)
619{
620 return adp8870_show(dev, buf, ADP8870_BLMX3);
621}
622
623static ssize_t adp8870_bl_l3_office_max_store(struct device *dev,
624 struct device_attribute *attr, const char *buf, size_t count)
625{
626 return adp8870_store(dev, buf, count, ADP8870_BLMX3);
627}
628
629static DEVICE_ATTR(l3_office_max, 0664, adp8870_bl_l3_office_max_show,
630 adp8870_bl_l3_office_max_store);
631
632static ssize_t adp8870_bl_l2_bright_max_show(struct device *dev,
633 struct device_attribute *attr, char *buf)
634{
635 return adp8870_show(dev, buf, ADP8870_BLMX2);
636}
637
638static ssize_t adp8870_bl_l2_bright_max_store(struct device *dev,
639 struct device_attribute *attr, const char *buf, size_t count)
640{
641 return adp8870_store(dev, buf, count, ADP8870_BLMX2);
642}
643static DEVICE_ATTR(l2_bright_max, 0664, adp8870_bl_l2_bright_max_show,
644 adp8870_bl_l2_bright_max_store);
645
646static ssize_t adp8870_bl_l1_daylight_max_show(struct device *dev,
647 struct device_attribute *attr, char *buf)
648{
649 return adp8870_show(dev, buf, ADP8870_BLMX1);
650}
651
652static ssize_t adp8870_bl_l1_daylight_max_store(struct device *dev,
653 struct device_attribute *attr, const char *buf, size_t count)
654{
655 struct adp8870_bl *data = dev_get_drvdata(dev);
656 int ret = strict_strtoul(buf, 10, &data->cached_daylight_max);
657 if (ret)
658 return ret;
659
660 return adp8870_store(dev, buf, count, ADP8870_BLMX1);
661}
662static DEVICE_ATTR(l1_daylight_max, 0664, adp8870_bl_l1_daylight_max_show,
663 adp8870_bl_l1_daylight_max_store);
664
665static ssize_t adp8870_bl_l5_dark_dim_show(struct device *dev,
666 struct device_attribute *attr, char *buf)
667{
668 return adp8870_show(dev, buf, ADP8870_BLDM5);
669}
670
671static ssize_t adp8870_bl_l5_dark_dim_store(struct device *dev,
672 struct device_attribute *attr,
673 const char *buf, size_t count)
674{
675 return adp8870_store(dev, buf, count, ADP8870_BLDM5);
676}
677static DEVICE_ATTR(l5_dark_dim, 0664, adp8870_bl_l5_dark_dim_show,
678 adp8870_bl_l5_dark_dim_store);
679
680static ssize_t adp8870_bl_l4_indoor_dim_show(struct device *dev,
681 struct device_attribute *attr, char *buf)
682{
683 return adp8870_show(dev, buf, ADP8870_BLDM4);
684}
685
686static ssize_t adp8870_bl_l4_indoor_dim_store(struct device *dev,
687 struct device_attribute *attr,
688 const char *buf, size_t count)
689{
690 return adp8870_store(dev, buf, count, ADP8870_BLDM4);
691}
692static DEVICE_ATTR(l4_indoor_dim, 0664, adp8870_bl_l4_indoor_dim_show,
693 adp8870_bl_l4_indoor_dim_store);
694
695
696static ssize_t adp8870_bl_l3_office_dim_show(struct device *dev,
697 struct device_attribute *attr, char *buf)
698{
699 return adp8870_show(dev, buf, ADP8870_BLDM3);
700}
701
702static ssize_t adp8870_bl_l3_office_dim_store(struct device *dev,
703 struct device_attribute *attr,
704 const char *buf, size_t count)
705{
706 return adp8870_store(dev, buf, count, ADP8870_BLDM3);
707}
708static DEVICE_ATTR(l3_office_dim, 0664, adp8870_bl_l3_office_dim_show,
709 adp8870_bl_l3_office_dim_store);
710
711static ssize_t adp8870_bl_l2_bright_dim_show(struct device *dev,
712 struct device_attribute *attr, char *buf)
713{
714 return adp8870_show(dev, buf, ADP8870_BLDM2);
715}
716
717static ssize_t adp8870_bl_l2_bright_dim_store(struct device *dev,
718 struct device_attribute *attr,
719 const char *buf, size_t count)
720{
721 return adp8870_store(dev, buf, count, ADP8870_BLDM2);
722}
723static DEVICE_ATTR(l2_bright_dim, 0664, adp8870_bl_l2_bright_dim_show,
724 adp8870_bl_l2_bright_dim_store);
725
726static ssize_t adp8870_bl_l1_daylight_dim_show(struct device *dev,
727 struct device_attribute *attr, char *buf)
728{
729 return adp8870_show(dev, buf, ADP8870_BLDM1);
730}
731
732static ssize_t adp8870_bl_l1_daylight_dim_store(struct device *dev,
733 struct device_attribute *attr,
734 const char *buf, size_t count)
735{
736 return adp8870_store(dev, buf, count, ADP8870_BLDM1);
737}
738static DEVICE_ATTR(l1_daylight_dim, 0664, adp8870_bl_l1_daylight_dim_show,
739 adp8870_bl_l1_daylight_dim_store);
740
741#ifdef ADP8870_EXT_FEATURES
742static ssize_t adp8870_bl_ambient_light_level_show(struct device *dev,
743 struct device_attribute *attr, char *buf)
744{
745 struct adp8870_bl *data = dev_get_drvdata(dev);
746 int error;
747 uint8_t reg_val;
748 uint16_t ret_val;
749
750 mutex_lock(&data->lock);
751 error = adp8870_read(data->client, ADP8870_PH1LEVL, &reg_val);
752 if (error < 0) {
753 mutex_unlock(&data->lock);
754 return error;
755 }
756 ret_val = reg_val;
757 error = adp8870_read(data->client, ADP8870_PH1LEVH, &reg_val);
758 mutex_unlock(&data->lock);
759
760 if (error < 0)
761 return error;
762
763 /* Return 13-bit conversion value for the first light sensor */
764 ret_val += (reg_val & 0x1F) << 8;
765
766 return sprintf(buf, "%u\n", ret_val);
767}
768static DEVICE_ATTR(ambient_light_level, 0444,
769 adp8870_bl_ambient_light_level_show, NULL);
770
771static ssize_t adp8870_bl_ambient_light_zone_show(struct device *dev,
772 struct device_attribute *attr, char *buf)
773{
774 struct adp8870_bl *data = dev_get_drvdata(dev);
775 int error;
776 uint8_t reg_val;
777
778 mutex_lock(&data->lock);
779 error = adp8870_read(data->client, ADP8870_CFGR, &reg_val);
780 mutex_unlock(&data->lock);
781
782 if (error < 0)
783 return error;
784
785 return sprintf(buf, "%u\n",
786 ((reg_val >> CFGR_BLV_SHIFT) & CFGR_BLV_MASK) + 1);
787}
788
789static ssize_t adp8870_bl_ambient_light_zone_store(struct device *dev,
790 struct device_attribute *attr,
791 const char *buf, size_t count)
792{
793 struct adp8870_bl *data = dev_get_drvdata(dev);
794 unsigned long val;
795 uint8_t reg_val;
796 int ret;
797
798 ret = strict_strtoul(buf, 10, &val);
799 if (ret)
800 return ret;
801
802 if (val == 0) {
803 /* Enable automatic ambient light sensing */
804 adp8870_set_bits(data->client, ADP8870_MDCR, CMP_AUTOEN);
805 } else if ((val > 0) && (val < 6)) {
806 /* Disable automatic ambient light sensing */
807 adp8870_clr_bits(data->client, ADP8870_MDCR, CMP_AUTOEN);
808
809 /* Set user supplied ambient light zone */
810 mutex_lock(&data->lock);
811 adp8870_read(data->client, ADP8870_CFGR, &reg_val);
812 reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT);
813 reg_val |= (val - 1) << CFGR_BLV_SHIFT;
814 adp8870_write(data->client, ADP8870_CFGR, reg_val);
815 mutex_unlock(&data->lock);
816 }
817
818 return count;
819}
820static DEVICE_ATTR(ambient_light_zone, 0664,
821 adp8870_bl_ambient_light_zone_show,
822 adp8870_bl_ambient_light_zone_store);
823#endif
824
825static struct attribute *adp8870_bl_attributes[] = {
826 &dev_attr_l5_dark_max.attr,
827 &dev_attr_l5_dark_dim.attr,
828 &dev_attr_l4_indoor_max.attr,
829 &dev_attr_l4_indoor_dim.attr,
830 &dev_attr_l3_office_max.attr,
831 &dev_attr_l3_office_dim.attr,
832 &dev_attr_l2_bright_max.attr,
833 &dev_attr_l2_bright_dim.attr,
834 &dev_attr_l1_daylight_max.attr,
835 &dev_attr_l1_daylight_dim.attr,
836#ifdef ADP8870_EXT_FEATURES
837 &dev_attr_ambient_light_level.attr,
838 &dev_attr_ambient_light_zone.attr,
839#endif
840 NULL
841};
842
843static const struct attribute_group adp8870_bl_attr_group = {
844 .attrs = adp8870_bl_attributes,
845};
846
847static int __devinit adp8870_probe(struct i2c_client *client,
848 const struct i2c_device_id *id)
849{
850 struct backlight_properties props;
851 struct backlight_device *bl;
852 struct adp8870_bl *data;
853 struct adp8870_backlight_platform_data *pdata =
854 client->dev.platform_data;
855 uint8_t reg_val;
856 int ret;
857
858 if (!i2c_check_functionality(client->adapter,
859 I2C_FUNC_SMBUS_BYTE_DATA)) {
860 dev_err(&client->dev, "SMBUS Byte Data not Supported\n");
861 return -EIO;
862 }
863
864 if (!pdata) {
865 dev_err(&client->dev, "no platform data?\n");
866 return -EINVAL;
867 }
868
869 ret = adp8870_read(client, ADP8870_MFDVID, &reg_val);
870 if (ret < 0)
871 return -EIO;
872
873 if (ADP8870_MANID(reg_val) != ADP8870_MANUFID) {
874 dev_err(&client->dev, "failed to probe\n");
875 return -ENODEV;
876 }
877
878 data = kzalloc(sizeof(*data), GFP_KERNEL);
879 if (data == NULL)
880 return -ENOMEM;
881
882 data->revid = ADP8870_DEVID(reg_val);
883 data->client = client;
884 data->pdata = pdata;
885 data->id = id->driver_data;
886 data->current_brightness = 0;
887 i2c_set_clientdata(client, data);
888
889 mutex_init(&data->lock);
890
891 memset(&props, 0, sizeof(props));
892 props.type = BACKLIGHT_RAW;
893 props.max_brightness = props.brightness = ADP8870_MAX_BRIGHTNESS;
894 bl = backlight_device_register(dev_driver_string(&client->dev),
895 &client->dev, data, &adp8870_bl_ops, &props);
896 if (IS_ERR(bl)) {
897 dev_err(&client->dev, "failed to register backlight\n");
898 ret = PTR_ERR(bl);
899 goto out2;
900 }
901
902 data->bl = bl;
903
904 if (pdata->en_ambl_sens)
905 ret = sysfs_create_group(&bl->dev.kobj,
906 &adp8870_bl_attr_group);
907
908 if (ret) {
909 dev_err(&client->dev, "failed to register sysfs\n");
910 goto out1;
911 }
912
913 ret = adp8870_bl_setup(bl);
914 if (ret) {
915 ret = -EIO;
916 goto out;
917 }
918
919 backlight_update_status(bl);
920
921 dev_info(&client->dev, "Rev.%d Backlight\n", data->revid);
922
923 if (pdata->num_leds)
924 adp8870_led_probe(client);
925
926 return 0;
927
928out:
929 if (data->pdata->en_ambl_sens)
930 sysfs_remove_group(&data->bl->dev.kobj,
931 &adp8870_bl_attr_group);
932out1:
933 backlight_device_unregister(bl);
934out2:
935 i2c_set_clientdata(client, NULL);
936 kfree(data);
937
938 return ret;
939}
940
941static int __devexit adp8870_remove(struct i2c_client *client)
942{
943 struct adp8870_bl *data = i2c_get_clientdata(client);
944
945 adp8870_clr_bits(client, ADP8870_MDCR, NSTBY);
946
947 if (data->led)
948 adp8870_led_remove(client);
949
950 if (data->pdata->en_ambl_sens)
951 sysfs_remove_group(&data->bl->dev.kobj,
952 &adp8870_bl_attr_group);
953
954 backlight_device_unregister(data->bl);
955 i2c_set_clientdata(client, NULL);
956 kfree(data);
957
958 return 0;
959}
960
961#ifdef CONFIG_PM
962static int adp8870_i2c_suspend(struct i2c_client *client, pm_message_t message)
963{
964 adp8870_clr_bits(client, ADP8870_MDCR, NSTBY);
965
966 return 0;
967}
968
969static int adp8870_i2c_resume(struct i2c_client *client)
970{
971 adp8870_set_bits(client, ADP8870_MDCR, NSTBY);
972
973 return 0;
974}
975#else
976#define adp8870_i2c_suspend NULL
977#define adp8870_i2c_resume NULL
978#endif
979
980static const struct i2c_device_id adp8870_id[] = {
981 { "adp8870", 0 },
982 { }
983};
984MODULE_DEVICE_TABLE(i2c, adp8870_id);
985
986static struct i2c_driver adp8870_driver = {
987 .driver = {
988 .name = KBUILD_MODNAME,
989 },
990 .probe = adp8870_probe,
991 .remove = __devexit_p(adp8870_remove),
992 .suspend = adp8870_i2c_suspend,
993 .resume = adp8870_i2c_resume,
994 .id_table = adp8870_id,
995};
996
997static int __init adp8870_init(void)
998{
999 return i2c_add_driver(&adp8870_driver);
1000}
1001module_init(adp8870_init);
1002
1003static void __exit adp8870_exit(void)
1004{
1005 i2c_del_driver(&adp8870_driver);
1006}
1007module_exit(adp8870_exit);
1008
1009MODULE_LICENSE("GPL v2");
1010MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
1011MODULE_DESCRIPTION("ADP8870 Backlight driver");
1012MODULE_ALIAS("platform:adp8870-backlight");
diff --git a/drivers/video/efifb.c b/drivers/video/efifb.c
index 69c49dfce9cf..784139aed079 100644
--- a/drivers/video/efifb.c
+++ b/drivers/video/efifb.c
@@ -541,7 +541,7 @@ static int __init efifb_init(void)
541 */ 541 */
542 ret = platform_driver_probe(&efifb_driver, efifb_probe); 542 ret = platform_driver_probe(&efifb_driver, efifb_probe);
543 if (ret) { 543 if (ret) {
544 platform_device_unregister(&efifb_driver); 544 platform_device_unregister(&efifb_device);
545 return ret; 545 return ret;
546 } 546 }
547 547
diff --git a/drivers/video/s3c-fb.c b/drivers/video/s3c-fb.c
index 0352afa49a39..4aecf213c9be 100644
--- a/drivers/video/s3c-fb.c
+++ b/drivers/video/s3c-fb.c
@@ -235,13 +235,12 @@ static int s3c_fb_check_var(struct fb_var_screeninfo *var,
235 struct fb_info *info) 235 struct fb_info *info)
236{ 236{
237 struct s3c_fb_win *win = info->par; 237 struct s3c_fb_win *win = info->par;
238 struct s3c_fb_pd_win *windata = win->windata;
239 struct s3c_fb *sfb = win->parent; 238 struct s3c_fb *sfb = win->parent;
240 239
241 dev_dbg(sfb->dev, "checking parameters\n"); 240 dev_dbg(sfb->dev, "checking parameters\n");
242 241
243 var->xres_virtual = max((unsigned int)windata->virtual_x, var->xres); 242 var->xres_virtual = max(var->xres_virtual, var->xres);
244 var->yres_virtual = max((unsigned int)windata->virtual_y, var->yres); 243 var->yres_virtual = max(var->yres_virtual, var->yres);
245 244
246 if (!s3c_fb_validate_win_bpp(win, var->bits_per_pixel)) { 245 if (!s3c_fb_validate_win_bpp(win, var->bits_per_pixel)) {
247 dev_dbg(sfb->dev, "win %d: unsupported bpp %d\n", 246 dev_dbg(sfb->dev, "win %d: unsupported bpp %d\n",
@@ -558,6 +557,13 @@ static int s3c_fb_set_par(struct fb_info *info)
558 vidosd_set_alpha(win, alpha); 557 vidosd_set_alpha(win, alpha);
559 vidosd_set_size(win, data); 558 vidosd_set_size(win, data);
560 559
560 /* Enable DMA channel for this window */
561 if (sfb->variant.has_shadowcon) {
562 data = readl(sfb->regs + SHADOWCON);
563 data |= SHADOWCON_CHx_ENABLE(win_no);
564 writel(data, sfb->regs + SHADOWCON);
565 }
566
561 data = WINCONx_ENWIN; 567 data = WINCONx_ENWIN;
562 568
563 /* note, since we have to round up the bits-per-pixel, we end up 569 /* note, since we have to round up the bits-per-pixel, we end up
@@ -637,13 +643,6 @@ static int s3c_fb_set_par(struct fb_info *info)
637 writel(data, regs + sfb->variant.wincon + (win_no * 4)); 643 writel(data, regs + sfb->variant.wincon + (win_no * 4));
638 writel(0x0, regs + sfb->variant.winmap + (win_no * 4)); 644 writel(0x0, regs + sfb->variant.winmap + (win_no * 4));
639 645
640 /* Enable DMA channel for this window */
641 if (sfb->variant.has_shadowcon) {
642 data = readl(sfb->regs + SHADOWCON);
643 data |= SHADOWCON_CHx_ENABLE(win_no);
644 writel(data, sfb->regs + SHADOWCON);
645 }
646
647 shadow_protect_win(win, 0); 646 shadow_protect_win(win, 0);
648 647
649 return 0; 648 return 0;
@@ -1487,11 +1486,10 @@ static int __devexit s3c_fb_remove(struct platform_device *pdev)
1487 1486
1488 release_mem_region(sfb->regs_res->start, resource_size(sfb->regs_res)); 1487 release_mem_region(sfb->regs_res->start, resource_size(sfb->regs_res));
1489 1488
1490 kfree(sfb);
1491
1492 pm_runtime_put_sync(sfb->dev); 1489 pm_runtime_put_sync(sfb->dev);
1493 pm_runtime_disable(sfb->dev); 1490 pm_runtime_disable(sfb->dev);
1494 1491
1492 kfree(sfb);
1495 return 0; 1493 return 0;
1496} 1494}
1497 1495
diff --git a/drivers/video/sh_mobile_hdmi.c b/drivers/video/sh_mobile_hdmi.c
index 6ae40b630dc9..7d54e2c612f7 100644
--- a/drivers/video/sh_mobile_hdmi.c
+++ b/drivers/video/sh_mobile_hdmi.c
@@ -1127,23 +1127,16 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
1127 struct fb_info *info = hdmi->info; 1127 struct fb_info *info = hdmi->info;
1128 unsigned long parent_rate = 0, hdmi_rate; 1128 unsigned long parent_rate = 0, hdmi_rate;
1129 1129
1130 /* A device has been plugged in */
1131 pm_runtime_get_sync(hdmi->dev);
1132
1133 ret = sh_hdmi_read_edid(hdmi, &hdmi_rate, &parent_rate); 1130 ret = sh_hdmi_read_edid(hdmi, &hdmi_rate, &parent_rate);
1134 if (ret < 0) { 1131 if (ret < 0)
1135 pm_runtime_put(hdmi->dev);
1136 goto out; 1132 goto out;
1137 }
1138 1133
1139 hdmi->hp_state = HDMI_HOTPLUG_EDID_DONE; 1134 hdmi->hp_state = HDMI_HOTPLUG_EDID_DONE;
1140 1135
1141 /* Reconfigure the clock */ 1136 /* Reconfigure the clock */
1142 ret = sh_hdmi_clk_configure(hdmi, hdmi_rate, parent_rate); 1137 ret = sh_hdmi_clk_configure(hdmi, hdmi_rate, parent_rate);
1143 if (ret < 0) { 1138 if (ret < 0)
1144 pm_runtime_put(hdmi->dev);
1145 goto out; 1139 goto out;
1146 }
1147 1140
1148 msleep(10); 1141 msleep(10);
1149 sh_hdmi_configure(hdmi); 1142 sh_hdmi_configure(hdmi);
@@ -1191,7 +1184,6 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
1191 fb_set_suspend(hdmi->info, 1); 1184 fb_set_suspend(hdmi->info, 1);
1192 1185
1193 console_unlock(); 1186 console_unlock();
1194 pm_runtime_put(hdmi->dev);
1195 } 1187 }
1196 1188
1197out: 1189out:
@@ -1312,7 +1304,7 @@ static int __init sh_hdmi_probe(struct platform_device *pdev)
1312 INIT_DELAYED_WORK(&hdmi->edid_work, sh_hdmi_edid_work_fn); 1304 INIT_DELAYED_WORK(&hdmi->edid_work, sh_hdmi_edid_work_fn);
1313 1305
1314 pm_runtime_enable(&pdev->dev); 1306 pm_runtime_enable(&pdev->dev);
1315 pm_runtime_resume(&pdev->dev); 1307 pm_runtime_get_sync(&pdev->dev);
1316 1308
1317 /* Product and revision IDs are 0 in sh-mobile version */ 1309 /* Product and revision IDs are 0 in sh-mobile version */
1318 dev_info(&pdev->dev, "Detected HDMI controller 0x%x:0x%x\n", 1310 dev_info(&pdev->dev, "Detected HDMI controller 0x%x:0x%x\n",
@@ -1340,7 +1332,7 @@ static int __init sh_hdmi_probe(struct platform_device *pdev)
1340ecodec: 1332ecodec:
1341 free_irq(irq, hdmi); 1333 free_irq(irq, hdmi);
1342ereqirq: 1334ereqirq:
1343 pm_runtime_suspend(&pdev->dev); 1335 pm_runtime_put(&pdev->dev);
1344 pm_runtime_disable(&pdev->dev); 1336 pm_runtime_disable(&pdev->dev);
1345 iounmap(hdmi->base); 1337 iounmap(hdmi->base);
1346emap: 1338emap:
@@ -1377,7 +1369,7 @@ static int __exit sh_hdmi_remove(struct platform_device *pdev)
1377 free_irq(irq, hdmi); 1369 free_irq(irq, hdmi);
1378 /* Wait for already scheduled work */ 1370 /* Wait for already scheduled work */
1379 cancel_delayed_work_sync(&hdmi->edid_work); 1371 cancel_delayed_work_sync(&hdmi->edid_work);
1380 pm_runtime_suspend(&pdev->dev); 1372 pm_runtime_put(&pdev->dev);
1381 pm_runtime_disable(&pdev->dev); 1373 pm_runtime_disable(&pdev->dev);
1382 clk_disable(hdmi->hdmi_clk); 1374 clk_disable(hdmi->hdmi_clk);
1383 clk_put(hdmi->hdmi_clk); 1375 clk_put(hdmi->hdmi_clk);
diff --git a/drivers/w1/masters/Kconfig b/drivers/w1/masters/Kconfig
index 00d615d7aa21..979d6eed9a0f 100644
--- a/drivers/w1/masters/Kconfig
+++ b/drivers/w1/masters/Kconfig
@@ -42,7 +42,7 @@ config W1_MASTER_MXC
42 42
43config W1_MASTER_DS1WM 43config W1_MASTER_DS1WM
44 tristate "Maxim DS1WM 1-wire busmaster" 44 tristate "Maxim DS1WM 1-wire busmaster"
45 depends on W1 45 depends on W1 && GENERIC_HARDIRQS
46 help 46 help
47 Say Y here to enable the DS1WM 1-wire driver, such as that 47 Say Y here to enable the DS1WM 1-wire driver, such as that
48 in HP iPAQ devices like h5xxx, h2200, and ASIC3-based like 48 in HP iPAQ devices like h5xxx, h2200, and ASIC3-based like
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 20c106f24927..1b0b19550015 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -584,11 +584,11 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
584 584
585success: 585success:
586 d_add(dentry, inode); 586 d_add(dentry, inode);
587 _leave(" = 0 { vn=%u u=%u } -> { ino=%lu v=%llu }", 587 _leave(" = 0 { vn=%u u=%u } -> { ino=%lu v=%u }",
588 fid.vnode, 588 fid.vnode,
589 fid.unique, 589 fid.unique,
590 dentry->d_inode->i_ino, 590 dentry->d_inode->i_ino,
591 (unsigned long long)dentry->d_inode->i_version); 591 dentry->d_inode->i_generation);
592 592
593 return NULL; 593 return NULL;
594} 594}
@@ -671,10 +671,10 @@ static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
671 * been deleted and replaced, and the original vnode ID has 671 * been deleted and replaced, and the original vnode ID has
672 * been reused */ 672 * been reused */
673 if (fid.unique != vnode->fid.unique) { 673 if (fid.unique != vnode->fid.unique) {
674 _debug("%s: file deleted (uq %u -> %u I:%llu)", 674 _debug("%s: file deleted (uq %u -> %u I:%u)",
675 dentry->d_name.name, fid.unique, 675 dentry->d_name.name, fid.unique,
676 vnode->fid.unique, 676 vnode->fid.unique,
677 (unsigned long long)dentry->d_inode->i_version); 677 dentry->d_inode->i_generation);
678 spin_lock(&vnode->lock); 678 spin_lock(&vnode->lock);
679 set_bit(AFS_VNODE_DELETED, &vnode->flags); 679 set_bit(AFS_VNODE_DELETED, &vnode->flags);
680 spin_unlock(&vnode->lock); 680 spin_unlock(&vnode->lock);
diff --git a/fs/afs/fsclient.c b/fs/afs/fsclient.c
index 4bd0218473a9..346e3289abd7 100644
--- a/fs/afs/fsclient.c
+++ b/fs/afs/fsclient.c
@@ -89,7 +89,7 @@ static void xdr_decode_AFSFetchStatus(const __be32 **_bp,
89 i_size_write(&vnode->vfs_inode, size); 89 i_size_write(&vnode->vfs_inode, size);
90 vnode->vfs_inode.i_uid = status->owner; 90 vnode->vfs_inode.i_uid = status->owner;
91 vnode->vfs_inode.i_gid = status->group; 91 vnode->vfs_inode.i_gid = status->group;
92 vnode->vfs_inode.i_version = vnode->fid.unique; 92 vnode->vfs_inode.i_generation = vnode->fid.unique;
93 vnode->vfs_inode.i_nlink = status->nlink; 93 vnode->vfs_inode.i_nlink = status->nlink;
94 94
95 mode = vnode->vfs_inode.i_mode; 95 mode = vnode->vfs_inode.i_mode;
@@ -102,6 +102,7 @@ static void xdr_decode_AFSFetchStatus(const __be32 **_bp,
102 vnode->vfs_inode.i_ctime.tv_sec = status->mtime_server; 102 vnode->vfs_inode.i_ctime.tv_sec = status->mtime_server;
103 vnode->vfs_inode.i_mtime = vnode->vfs_inode.i_ctime; 103 vnode->vfs_inode.i_mtime = vnode->vfs_inode.i_ctime;
104 vnode->vfs_inode.i_atime = vnode->vfs_inode.i_ctime; 104 vnode->vfs_inode.i_atime = vnode->vfs_inode.i_ctime;
105 vnode->vfs_inode.i_version = data_version;
105 } 106 }
106 107
107 expected_version = status->data_version; 108 expected_version = status->data_version;
diff --git a/fs/afs/inode.c b/fs/afs/inode.c
index db66c5201474..0fdab6e03d87 100644
--- a/fs/afs/inode.c
+++ b/fs/afs/inode.c
@@ -75,7 +75,8 @@ static int afs_inode_map_status(struct afs_vnode *vnode, struct key *key)
75 inode->i_ctime.tv_nsec = 0; 75 inode->i_ctime.tv_nsec = 0;
76 inode->i_atime = inode->i_mtime = inode->i_ctime; 76 inode->i_atime = inode->i_mtime = inode->i_ctime;
77 inode->i_blocks = 0; 77 inode->i_blocks = 0;
78 inode->i_version = vnode->fid.unique; 78 inode->i_generation = vnode->fid.unique;
79 inode->i_version = vnode->status.data_version;
79 inode->i_mapping->a_ops = &afs_fs_aops; 80 inode->i_mapping->a_ops = &afs_fs_aops;
80 81
81 /* check to see whether a symbolic link is really a mountpoint */ 82 /* check to see whether a symbolic link is really a mountpoint */
@@ -100,7 +101,7 @@ static int afs_iget5_test(struct inode *inode, void *opaque)
100 struct afs_iget_data *data = opaque; 101 struct afs_iget_data *data = opaque;
101 102
102 return inode->i_ino == data->fid.vnode && 103 return inode->i_ino == data->fid.vnode &&
103 inode->i_version == data->fid.unique; 104 inode->i_generation == data->fid.unique;
104} 105}
105 106
106/* 107/*
@@ -122,7 +123,7 @@ static int afs_iget5_set(struct inode *inode, void *opaque)
122 struct afs_vnode *vnode = AFS_FS_I(inode); 123 struct afs_vnode *vnode = AFS_FS_I(inode);
123 124
124 inode->i_ino = data->fid.vnode; 125 inode->i_ino = data->fid.vnode;
125 inode->i_version = data->fid.unique; 126 inode->i_generation = data->fid.unique;
126 vnode->fid = data->fid; 127 vnode->fid = data->fid;
127 vnode->volume = data->volume; 128 vnode->volume = data->volume;
128 129
@@ -380,8 +381,7 @@ int afs_getattr(struct vfsmount *mnt, struct dentry *dentry,
380 381
381 inode = dentry->d_inode; 382 inode = dentry->d_inode;
382 383
383 _enter("{ ino=%lu v=%llu }", inode->i_ino, 384 _enter("{ ino=%lu v=%u }", inode->i_ino, inode->i_generation);
384 (unsigned long long)inode->i_version);
385 385
386 generic_fillattr(inode, stat); 386 generic_fillattr(inode, stat);
387 return 0; 387 return 0;
diff --git a/fs/afs/super.c b/fs/afs/super.c
index fb240e8766d6..356dcf0929e8 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -31,8 +31,8 @@
31static void afs_i_init_once(void *foo); 31static void afs_i_init_once(void *foo);
32static struct dentry *afs_mount(struct file_system_type *fs_type, 32static struct dentry *afs_mount(struct file_system_type *fs_type,
33 int flags, const char *dev_name, void *data); 33 int flags, const char *dev_name, void *data);
34static void afs_kill_super(struct super_block *sb);
34static struct inode *afs_alloc_inode(struct super_block *sb); 35static struct inode *afs_alloc_inode(struct super_block *sb);
35static void afs_put_super(struct super_block *sb);
36static void afs_destroy_inode(struct inode *inode); 36static void afs_destroy_inode(struct inode *inode);
37static int afs_statfs(struct dentry *dentry, struct kstatfs *buf); 37static int afs_statfs(struct dentry *dentry, struct kstatfs *buf);
38 38
@@ -40,7 +40,7 @@ struct file_system_type afs_fs_type = {
40 .owner = THIS_MODULE, 40 .owner = THIS_MODULE,
41 .name = "afs", 41 .name = "afs",
42 .mount = afs_mount, 42 .mount = afs_mount,
43 .kill_sb = kill_anon_super, 43 .kill_sb = afs_kill_super,
44 .fs_flags = 0, 44 .fs_flags = 0,
45}; 45};
46 46
@@ -50,7 +50,6 @@ static const struct super_operations afs_super_ops = {
50 .drop_inode = afs_drop_inode, 50 .drop_inode = afs_drop_inode,
51 .destroy_inode = afs_destroy_inode, 51 .destroy_inode = afs_destroy_inode,
52 .evict_inode = afs_evict_inode, 52 .evict_inode = afs_evict_inode,
53 .put_super = afs_put_super,
54 .show_options = generic_show_options, 53 .show_options = generic_show_options,
55}; 54};
56 55
@@ -282,19 +281,25 @@ static int afs_parse_device_name(struct afs_mount_params *params,
282 */ 281 */
283static int afs_test_super(struct super_block *sb, void *data) 282static int afs_test_super(struct super_block *sb, void *data)
284{ 283{
285 struct afs_mount_params *params = data; 284 struct afs_super_info *as1 = data;
286 struct afs_super_info *as = sb->s_fs_info; 285 struct afs_super_info *as = sb->s_fs_info;
287 286
288 return as->volume == params->volume; 287 return as->volume == as1->volume;
288}
289
290static int afs_set_super(struct super_block *sb, void *data)
291{
292 sb->s_fs_info = data;
293 return set_anon_super(sb, NULL);
289} 294}
290 295
291/* 296/*
292 * fill in the superblock 297 * fill in the superblock
293 */ 298 */
294static int afs_fill_super(struct super_block *sb, void *data) 299static int afs_fill_super(struct super_block *sb,
300 struct afs_mount_params *params)
295{ 301{
296 struct afs_mount_params *params = data; 302 struct afs_super_info *as = sb->s_fs_info;
297 struct afs_super_info *as = NULL;
298 struct afs_fid fid; 303 struct afs_fid fid;
299 struct dentry *root = NULL; 304 struct dentry *root = NULL;
300 struct inode *inode = NULL; 305 struct inode *inode = NULL;
@@ -302,23 +307,13 @@ static int afs_fill_super(struct super_block *sb, void *data)
302 307
303 _enter(""); 308 _enter("");
304 309
305 /* allocate a superblock info record */
306 as = kzalloc(sizeof(struct afs_super_info), GFP_KERNEL);
307 if (!as) {
308 _leave(" = -ENOMEM");
309 return -ENOMEM;
310 }
311
312 afs_get_volume(params->volume);
313 as->volume = params->volume;
314
315 /* fill in the superblock */ 310 /* fill in the superblock */
316 sb->s_blocksize = PAGE_CACHE_SIZE; 311 sb->s_blocksize = PAGE_CACHE_SIZE;
317 sb->s_blocksize_bits = PAGE_CACHE_SHIFT; 312 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
318 sb->s_magic = AFS_FS_MAGIC; 313 sb->s_magic = AFS_FS_MAGIC;
319 sb->s_op = &afs_super_ops; 314 sb->s_op = &afs_super_ops;
320 sb->s_fs_info = as;
321 sb->s_bdi = &as->volume->bdi; 315 sb->s_bdi = &as->volume->bdi;
316 strlcpy(sb->s_id, as->volume->vlocation->vldb.name, sizeof(sb->s_id));
322 317
323 /* allocate the root inode and dentry */ 318 /* allocate the root inode and dentry */
324 fid.vid = as->volume->vid; 319 fid.vid = as->volume->vid;
@@ -326,7 +321,7 @@ static int afs_fill_super(struct super_block *sb, void *data)
326 fid.unique = 1; 321 fid.unique = 1;
327 inode = afs_iget(sb, params->key, &fid, NULL, NULL); 322 inode = afs_iget(sb, params->key, &fid, NULL, NULL);
328 if (IS_ERR(inode)) 323 if (IS_ERR(inode))
329 goto error_inode; 324 return PTR_ERR(inode);
330 325
331 if (params->autocell) 326 if (params->autocell)
332 set_bit(AFS_VNODE_AUTOCELL, &AFS_FS_I(inode)->flags); 327 set_bit(AFS_VNODE_AUTOCELL, &AFS_FS_I(inode)->flags);
@@ -342,16 +337,8 @@ static int afs_fill_super(struct super_block *sb, void *data)
342 _leave(" = 0"); 337 _leave(" = 0");
343 return 0; 338 return 0;
344 339
345error_inode:
346 ret = PTR_ERR(inode);
347 inode = NULL;
348error: 340error:
349 iput(inode); 341 iput(inode);
350 afs_put_volume(as->volume);
351 kfree(as);
352
353 sb->s_fs_info = NULL;
354
355 _leave(" = %d", ret); 342 _leave(" = %d", ret);
356 return ret; 343 return ret;
357} 344}
@@ -367,6 +354,7 @@ static struct dentry *afs_mount(struct file_system_type *fs_type,
367 struct afs_volume *vol; 354 struct afs_volume *vol;
368 struct key *key; 355 struct key *key;
369 char *new_opts = kstrdup(options, GFP_KERNEL); 356 char *new_opts = kstrdup(options, GFP_KERNEL);
357 struct afs_super_info *as;
370 int ret; 358 int ret;
371 359
372 _enter(",,%s,%p", dev_name, options); 360 _enter(",,%s,%p", dev_name, options);
@@ -399,12 +387,22 @@ static struct dentry *afs_mount(struct file_system_type *fs_type,
399 ret = PTR_ERR(vol); 387 ret = PTR_ERR(vol);
400 goto error; 388 goto error;
401 } 389 }
402 params.volume = vol; 390
391 /* allocate a superblock info record */
392 as = kzalloc(sizeof(struct afs_super_info), GFP_KERNEL);
393 if (!as) {
394 ret = -ENOMEM;
395 afs_put_volume(vol);
396 goto error;
397 }
398 as->volume = vol;
403 399
404 /* allocate a deviceless superblock */ 400 /* allocate a deviceless superblock */
405 sb = sget(fs_type, afs_test_super, set_anon_super, &params); 401 sb = sget(fs_type, afs_test_super, afs_set_super, as);
406 if (IS_ERR(sb)) { 402 if (IS_ERR(sb)) {
407 ret = PTR_ERR(sb); 403 ret = PTR_ERR(sb);
404 afs_put_volume(vol);
405 kfree(as);
408 goto error; 406 goto error;
409 } 407 }
410 408
@@ -422,16 +420,16 @@ static struct dentry *afs_mount(struct file_system_type *fs_type,
422 } else { 420 } else {
423 _debug("reuse"); 421 _debug("reuse");
424 ASSERTCMP(sb->s_flags, &, MS_ACTIVE); 422 ASSERTCMP(sb->s_flags, &, MS_ACTIVE);
423 afs_put_volume(vol);
424 kfree(as);
425 } 425 }
426 426
427 afs_put_volume(params.volume);
428 afs_put_cell(params.cell); 427 afs_put_cell(params.cell);
429 kfree(new_opts); 428 kfree(new_opts);
430 _leave(" = 0 [%p]", sb); 429 _leave(" = 0 [%p]", sb);
431 return dget(sb->s_root); 430 return dget(sb->s_root);
432 431
433error: 432error:
434 afs_put_volume(params.volume);
435 afs_put_cell(params.cell); 433 afs_put_cell(params.cell);
436 key_put(params.key); 434 key_put(params.key);
437 kfree(new_opts); 435 kfree(new_opts);
@@ -439,18 +437,12 @@ error:
439 return ERR_PTR(ret); 437 return ERR_PTR(ret);
440} 438}
441 439
442/* 440static void afs_kill_super(struct super_block *sb)
443 * finish the unmounting process on the superblock
444 */
445static void afs_put_super(struct super_block *sb)
446{ 441{
447 struct afs_super_info *as = sb->s_fs_info; 442 struct afs_super_info *as = sb->s_fs_info;
448 443 kill_anon_super(sb);
449 _enter("");
450
451 afs_put_volume(as->volume); 444 afs_put_volume(as->volume);
452 445 kfree(as);
453 _leave("");
454} 446}
455 447
456/* 448/*
diff --git a/fs/afs/write.c b/fs/afs/write.c
index 789b3afb3423..b806285ff853 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -84,23 +84,21 @@ void afs_put_writeback(struct afs_writeback *wb)
84 * partly or wholly fill a page that's under preparation for writing 84 * partly or wholly fill a page that's under preparation for writing
85 */ 85 */
86static int afs_fill_page(struct afs_vnode *vnode, struct key *key, 86static int afs_fill_page(struct afs_vnode *vnode, struct key *key,
87 loff_t pos, unsigned len, struct page *page) 87 loff_t pos, struct page *page)
88{ 88{
89 loff_t i_size; 89 loff_t i_size;
90 unsigned eof;
91 int ret; 90 int ret;
91 int len;
92 92
93 _enter(",,%llu,%u", (unsigned long long)pos, len); 93 _enter(",,%llu", (unsigned long long)pos);
94
95 ASSERTCMP(len, <=, PAGE_CACHE_SIZE);
96 94
97 i_size = i_size_read(&vnode->vfs_inode); 95 i_size = i_size_read(&vnode->vfs_inode);
98 if (pos + len > i_size) 96 if (pos + PAGE_CACHE_SIZE > i_size)
99 eof = i_size; 97 len = i_size - pos;
100 else 98 else
101 eof = PAGE_CACHE_SIZE; 99 len = PAGE_CACHE_SIZE;
102 100
103 ret = afs_vnode_fetch_data(vnode, key, 0, eof, page); 101 ret = afs_vnode_fetch_data(vnode, key, pos, len, page);
104 if (ret < 0) { 102 if (ret < 0) {
105 if (ret == -ENOENT) { 103 if (ret == -ENOENT) {
106 _debug("got NOENT from server" 104 _debug("got NOENT from server"
@@ -153,9 +151,8 @@ int afs_write_begin(struct file *file, struct address_space *mapping,
153 *pagep = page; 151 *pagep = page;
154 /* page won't leak in error case: it eventually gets cleaned off LRU */ 152 /* page won't leak in error case: it eventually gets cleaned off LRU */
155 153
156 if (!PageUptodate(page)) { 154 if (!PageUptodate(page) && len != PAGE_CACHE_SIZE) {
157 _debug("not up to date"); 155 ret = afs_fill_page(vnode, key, index << PAGE_CACHE_SHIFT, page);
158 ret = afs_fill_page(vnode, key, pos, len, page);
159 if (ret < 0) { 156 if (ret < 0) {
160 kfree(candidate); 157 kfree(candidate);
161 _leave(" = %d [prep]", ret); 158 _leave(" = %d [prep]", ret);
diff --git a/fs/buffer.c b/fs/buffer.c
index 49c9aada0374..1a80b048ade8 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1902,10 +1902,8 @@ int __block_write_begin(struct page *page, loff_t pos, unsigned len,
1902 if (!buffer_uptodate(*wait_bh)) 1902 if (!buffer_uptodate(*wait_bh))
1903 err = -EIO; 1903 err = -EIO;
1904 } 1904 }
1905 if (unlikely(err)) { 1905 if (unlikely(err))
1906 page_zero_new_buffers(page, from, to); 1906 page_zero_new_buffers(page, from, to);
1907 ClearPageUptodate(page);
1908 }
1909 return err; 1907 return err;
1910} 1908}
1911EXPORT_SYMBOL(__block_write_begin); 1909EXPORT_SYMBOL(__block_write_begin);
diff --git a/fs/cifs/cache.c b/fs/cifs/cache.c
index dd8584d35a14..545509c3313b 100644
--- a/fs/cifs/cache.c
+++ b/fs/cifs/cache.c
@@ -92,7 +92,7 @@ static uint16_t cifs_server_get_key(const void *cookie_netfs_data,
92 break; 92 break;
93 93
94 default: 94 default:
95 cERROR(1, "CIFS: Unknown network family '%d'", sa->sa_family); 95 cERROR(1, "Unknown network family '%d'", sa->sa_family);
96 key_len = 0; 96 key_len = 0;
97 break; 97 break;
98 } 98 }
@@ -152,7 +152,7 @@ static uint16_t cifs_super_get_key(const void *cookie_netfs_data, void *buffer,
152 152
153 sharename = extract_sharename(tcon->treeName); 153 sharename = extract_sharename(tcon->treeName);
154 if (IS_ERR(sharename)) { 154 if (IS_ERR(sharename)) {
155 cFYI(1, "CIFS: couldn't extract sharename\n"); 155 cFYI(1, "%s: couldn't extract sharename\n", __func__);
156 sharename = NULL; 156 sharename = NULL;
157 return 0; 157 return 0;
158 } 158 }
@@ -302,7 +302,7 @@ static void cifs_fscache_inode_now_uncached(void *cookie_netfs_data)
302 pagevec_init(&pvec, 0); 302 pagevec_init(&pvec, 0);
303 first = 0; 303 first = 0;
304 304
305 cFYI(1, "cifs inode 0x%p now uncached", cifsi); 305 cFYI(1, "%s: cifs inode 0x%p now uncached", __func__, cifsi);
306 306
307 for (;;) { 307 for (;;) {
308 nr_pages = pagevec_lookup(&pvec, 308 nr_pages = pagevec_lookup(&pvec,
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 989442dcfb45..e9def996e383 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -352,6 +352,37 @@ cifs_show_address(struct seq_file *s, struct TCP_Server_Info *server)
352 } 352 }
353} 353}
354 354
355static void
356cifs_show_security(struct seq_file *s, struct TCP_Server_Info *server)
357{
358 seq_printf(s, ",sec=");
359
360 switch (server->secType) {
361 case LANMAN:
362 seq_printf(s, "lanman");
363 break;
364 case NTLMv2:
365 seq_printf(s, "ntlmv2");
366 break;
367 case NTLM:
368 seq_printf(s, "ntlm");
369 break;
370 case Kerberos:
371 seq_printf(s, "krb5");
372 break;
373 case RawNTLMSSP:
374 seq_printf(s, "ntlmssp");
375 break;
376 default:
377 /* shouldn't ever happen */
378 seq_printf(s, "unknown");
379 break;
380 }
381
382 if (server->sec_mode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
383 seq_printf(s, "i");
384}
385
355/* 386/*
356 * cifs_show_options() is for displaying mount options in /proc/mounts. 387 * cifs_show_options() is for displaying mount options in /proc/mounts.
357 * Not all settable options are displayed but most of the important 388 * Not all settable options are displayed but most of the important
@@ -365,6 +396,8 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)
365 struct sockaddr *srcaddr; 396 struct sockaddr *srcaddr;
366 srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr; 397 srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr;
367 398
399 cifs_show_security(s, tcon->ses->server);
400
368 seq_printf(s, ",unc=%s", tcon->treeName); 401 seq_printf(s, ",unc=%s", tcon->treeName);
369 402
370 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER) 403 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index 64313f778ebf..0900e1658c96 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -129,5 +129,5 @@ extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
129extern const struct export_operations cifs_export_ops; 129extern const struct export_operations cifs_export_ops;
130#endif /* CIFS_NFSD_EXPORT */ 130#endif /* CIFS_NFSD_EXPORT */
131 131
132#define CIFS_VERSION "1.72" 132#define CIFS_VERSION "1.73"
133#endif /* _CIFSFS_H */ 133#endif /* _CIFSFS_H */
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index bb659eb73810..12cf72dd0c42 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -152,7 +152,7 @@ cifs_reconnect(struct TCP_Server_Info *server)
152 mid_entry->callback(mid_entry); 152 mid_entry->callback(mid_entry);
153 } 153 }
154 154
155 while (server->tcpStatus == CifsNeedReconnect) { 155 do {
156 try_to_freeze(); 156 try_to_freeze();
157 157
158 /* we should try only the port we connected to before */ 158 /* we should try only the port we connected to before */
@@ -167,7 +167,7 @@ cifs_reconnect(struct TCP_Server_Info *server)
167 server->tcpStatus = CifsNeedNegotiate; 167 server->tcpStatus = CifsNeedNegotiate;
168 spin_unlock(&GlobalMid_Lock); 168 spin_unlock(&GlobalMid_Lock);
169 } 169 }
170 } 170 } while (server->tcpStatus == CifsNeedReconnect);
171 171
172 return rc; 172 return rc;
173} 173}
@@ -2149,7 +2149,10 @@ cifs_put_tlink(struct tcon_link *tlink)
2149} 2149}
2150 2150
2151static inline struct tcon_link * 2151static inline struct tcon_link *
2152cifs_sb_master_tlink(struct cifs_sb_info *cifs_sb); 2152cifs_sb_master_tlink(struct cifs_sb_info *cifs_sb)
2153{
2154 return cifs_sb->master_tlink;
2155}
2153 2156
2154static int 2157static int
2155compare_mount_options(struct super_block *sb, struct cifs_mnt_data *mnt_data) 2158compare_mount_options(struct super_block *sb, struct cifs_mnt_data *mnt_data)
@@ -3171,6 +3174,10 @@ out:
3171 return rc; 3174 return rc;
3172} 3175}
3173 3176
3177/*
3178 * Issue a TREE_CONNECT request. Note that for IPC$ shares, that the tcon
3179 * pointer may be NULL.
3180 */
3174int 3181int
3175CIFSTCon(unsigned int xid, struct cifs_ses *ses, 3182CIFSTCon(unsigned int xid, struct cifs_ses *ses,
3176 const char *tree, struct cifs_tcon *tcon, 3183 const char *tree, struct cifs_tcon *tcon,
@@ -3205,7 +3212,7 @@ CIFSTCon(unsigned int xid, struct cifs_ses *ses,
3205 pSMB->AndXCommand = 0xFF; 3212 pSMB->AndXCommand = 0xFF;
3206 pSMB->Flags = cpu_to_le16(TCON_EXTENDED_SECINFO); 3213 pSMB->Flags = cpu_to_le16(TCON_EXTENDED_SECINFO);
3207 bcc_ptr = &pSMB->Password[0]; 3214 bcc_ptr = &pSMB->Password[0];
3208 if ((ses->server->sec_mode) & SECMODE_USER) { 3215 if (!tcon || (ses->server->sec_mode & SECMODE_USER)) {
3209 pSMB->PasswordLength = cpu_to_le16(1); /* minimum */ 3216 pSMB->PasswordLength = cpu_to_le16(1); /* minimum */
3210 *bcc_ptr = 0; /* password is null byte */ 3217 *bcc_ptr = 0; /* password is null byte */
3211 bcc_ptr++; /* skip password */ 3218 bcc_ptr++; /* skip password */
@@ -3371,7 +3378,7 @@ int cifs_negotiate_protocol(unsigned int xid, struct cifs_ses *ses)
3371 } 3378 }
3372 if (rc == 0) { 3379 if (rc == 0) {
3373 spin_lock(&GlobalMid_Lock); 3380 spin_lock(&GlobalMid_Lock);
3374 if (server->tcpStatus != CifsExiting) 3381 if (server->tcpStatus == CifsNeedNegotiate)
3375 server->tcpStatus = CifsGood; 3382 server->tcpStatus = CifsGood;
3376 else 3383 else
3377 rc = -EHOSTDOWN; 3384 rc = -EHOSTDOWN;
@@ -3484,12 +3491,6 @@ out:
3484 return tcon; 3491 return tcon;
3485} 3492}
3486 3493
3487static inline struct tcon_link *
3488cifs_sb_master_tlink(struct cifs_sb_info *cifs_sb)
3489{
3490 return cifs_sb->master_tlink;
3491}
3492
3493struct cifs_tcon * 3494struct cifs_tcon *
3494cifs_sb_master_tcon(struct cifs_sb_info *cifs_sb) 3495cifs_sb_master_tcon(struct cifs_sb_info *cifs_sb)
3495{ 3496{
diff --git a/fs/cifs/fscache.c b/fs/cifs/fscache.c
index d368a47ba5eb..816696621ec9 100644
--- a/fs/cifs/fscache.c
+++ b/fs/cifs/fscache.c
@@ -28,14 +28,14 @@ void cifs_fscache_get_client_cookie(struct TCP_Server_Info *server)
28 server->fscache = 28 server->fscache =
29 fscache_acquire_cookie(cifs_fscache_netfs.primary_index, 29 fscache_acquire_cookie(cifs_fscache_netfs.primary_index,
30 &cifs_fscache_server_index_def, server); 30 &cifs_fscache_server_index_def, server);
31 cFYI(1, "CIFS: get client cookie (0x%p/0x%p)", server, 31 cFYI(1, "%s: (0x%p/0x%p)", __func__, server,
32 server->fscache); 32 server->fscache);
33} 33}
34 34
35void cifs_fscache_release_client_cookie(struct TCP_Server_Info *server) 35void cifs_fscache_release_client_cookie(struct TCP_Server_Info *server)
36{ 36{
37 cFYI(1, "CIFS: release client cookie (0x%p/0x%p)", server, 37 cFYI(1, "%s: (0x%p/0x%p)", __func__, server,
38 server->fscache); 38 server->fscache);
39 fscache_relinquish_cookie(server->fscache, 0); 39 fscache_relinquish_cookie(server->fscache, 0);
40 server->fscache = NULL; 40 server->fscache = NULL;
41} 41}
@@ -47,13 +47,13 @@ void cifs_fscache_get_super_cookie(struct cifs_tcon *tcon)
47 tcon->fscache = 47 tcon->fscache =
48 fscache_acquire_cookie(server->fscache, 48 fscache_acquire_cookie(server->fscache,
49 &cifs_fscache_super_index_def, tcon); 49 &cifs_fscache_super_index_def, tcon);
50 cFYI(1, "CIFS: get superblock cookie (0x%p/0x%p)", 50 cFYI(1, "%s: (0x%p/0x%p)", __func__, server->fscache,
51 server->fscache, tcon->fscache); 51 tcon->fscache);
52} 52}
53 53
54void cifs_fscache_release_super_cookie(struct cifs_tcon *tcon) 54void cifs_fscache_release_super_cookie(struct cifs_tcon *tcon)
55{ 55{
56 cFYI(1, "CIFS: releasing superblock cookie (0x%p)", tcon->fscache); 56 cFYI(1, "%s: (0x%p)", __func__, tcon->fscache);
57 fscache_relinquish_cookie(tcon->fscache, 0); 57 fscache_relinquish_cookie(tcon->fscache, 0);
58 tcon->fscache = NULL; 58 tcon->fscache = NULL;
59} 59}
@@ -70,8 +70,8 @@ static void cifs_fscache_enable_inode_cookie(struct inode *inode)
70 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_FSCACHE) { 70 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_FSCACHE) {
71 cifsi->fscache = fscache_acquire_cookie(tcon->fscache, 71 cifsi->fscache = fscache_acquire_cookie(tcon->fscache,
72 &cifs_fscache_inode_object_def, cifsi); 72 &cifs_fscache_inode_object_def, cifsi);
73 cFYI(1, "CIFS: got FH cookie (0x%p/0x%p)", tcon->fscache, 73 cFYI(1, "%s: got FH cookie (0x%p/0x%p)", __func__,
74 cifsi->fscache); 74 tcon->fscache, cifsi->fscache);
75 } 75 }
76} 76}
77 77
@@ -80,8 +80,7 @@ void cifs_fscache_release_inode_cookie(struct inode *inode)
80 struct cifsInodeInfo *cifsi = CIFS_I(inode); 80 struct cifsInodeInfo *cifsi = CIFS_I(inode);
81 81
82 if (cifsi->fscache) { 82 if (cifsi->fscache) {
83 cFYI(1, "CIFS releasing inode cookie (0x%p)", 83 cFYI(1, "%s: (0x%p)", __func__, cifsi->fscache);
84 cifsi->fscache);
85 fscache_relinquish_cookie(cifsi->fscache, 0); 84 fscache_relinquish_cookie(cifsi->fscache, 0);
86 cifsi->fscache = NULL; 85 cifsi->fscache = NULL;
87 } 86 }
@@ -92,8 +91,7 @@ static void cifs_fscache_disable_inode_cookie(struct inode *inode)
92 struct cifsInodeInfo *cifsi = CIFS_I(inode); 91 struct cifsInodeInfo *cifsi = CIFS_I(inode);
93 92
94 if (cifsi->fscache) { 93 if (cifsi->fscache) {
95 cFYI(1, "CIFS disabling inode cookie (0x%p)", 94 cFYI(1, "%s: (0x%p)", __func__, cifsi->fscache);
96 cifsi->fscache);
97 fscache_relinquish_cookie(cifsi->fscache, 1); 95 fscache_relinquish_cookie(cifsi->fscache, 1);
98 cifsi->fscache = NULL; 96 cifsi->fscache = NULL;
99 } 97 }
@@ -121,8 +119,8 @@ void cifs_fscache_reset_inode_cookie(struct inode *inode)
121 cifs_sb_master_tcon(cifs_sb)->fscache, 119 cifs_sb_master_tcon(cifs_sb)->fscache,
122 &cifs_fscache_inode_object_def, 120 &cifs_fscache_inode_object_def,
123 cifsi); 121 cifsi);
124 cFYI(1, "CIFS: new cookie 0x%p oldcookie 0x%p", 122 cFYI(1, "%s: new cookie 0x%p oldcookie 0x%p",
125 cifsi->fscache, old); 123 __func__, cifsi->fscache, old);
126 } 124 }
127} 125}
128 126
@@ -132,8 +130,8 @@ int cifs_fscache_release_page(struct page *page, gfp_t gfp)
132 struct inode *inode = page->mapping->host; 130 struct inode *inode = page->mapping->host;
133 struct cifsInodeInfo *cifsi = CIFS_I(inode); 131 struct cifsInodeInfo *cifsi = CIFS_I(inode);
134 132
135 cFYI(1, "CIFS: fscache release page (0x%p/0x%p)", 133 cFYI(1, "%s: (0x%p/0x%p)", __func__, page,
136 page, cifsi->fscache); 134 cifsi->fscache);
137 if (!fscache_maybe_release_page(cifsi->fscache, page, gfp)) 135 if (!fscache_maybe_release_page(cifsi->fscache, page, gfp))
138 return 0; 136 return 0;
139 } 137 }
@@ -144,8 +142,7 @@ int cifs_fscache_release_page(struct page *page, gfp_t gfp)
144static void cifs_readpage_from_fscache_complete(struct page *page, void *ctx, 142static void cifs_readpage_from_fscache_complete(struct page *page, void *ctx,
145 int error) 143 int error)
146{ 144{
147 cFYI(1, "CFS: readpage_from_fscache_complete (0x%p/%d)", 145 cFYI(1, "%s: (0x%p/%d)", __func__, page, error);
148 page, error);
149 if (!error) 146 if (!error)
150 SetPageUptodate(page); 147 SetPageUptodate(page);
151 unlock_page(page); 148 unlock_page(page);
@@ -158,7 +155,7 @@ int __cifs_readpage_from_fscache(struct inode *inode, struct page *page)
158{ 155{
159 int ret; 156 int ret;
160 157
161 cFYI(1, "CIFS: readpage_from_fscache(fsc:%p, p:%p, i:0x%p", 158 cFYI(1, "%s: (fsc:%p, p:%p, i:0x%p", __func__,
162 CIFS_I(inode)->fscache, page, inode); 159 CIFS_I(inode)->fscache, page, inode);
163 ret = fscache_read_or_alloc_page(CIFS_I(inode)->fscache, page, 160 ret = fscache_read_or_alloc_page(CIFS_I(inode)->fscache, page,
164 cifs_readpage_from_fscache_complete, 161 cifs_readpage_from_fscache_complete,
@@ -167,11 +164,11 @@ int __cifs_readpage_from_fscache(struct inode *inode, struct page *page)
167 switch (ret) { 164 switch (ret) {
168 165
169 case 0: /* page found in fscache, read submitted */ 166 case 0: /* page found in fscache, read submitted */
170 cFYI(1, "CIFS: readpage_from_fscache: submitted"); 167 cFYI(1, "%s: submitted", __func__);
171 return ret; 168 return ret;
172 case -ENOBUFS: /* page won't be cached */ 169 case -ENOBUFS: /* page won't be cached */
173 case -ENODATA: /* page not in cache */ 170 case -ENODATA: /* page not in cache */
174 cFYI(1, "CIFS: readpage_from_fscache %d", ret); 171 cFYI(1, "%s: %d", __func__, ret);
175 return 1; 172 return 1;
176 173
177 default: 174 default:
@@ -190,7 +187,7 @@ int __cifs_readpages_from_fscache(struct inode *inode,
190{ 187{
191 int ret; 188 int ret;
192 189
193 cFYI(1, "CIFS: __cifs_readpages_from_fscache (0x%p/%u/0x%p)", 190 cFYI(1, "%s: (0x%p/%u/0x%p)", __func__,
194 CIFS_I(inode)->fscache, *nr_pages, inode); 191 CIFS_I(inode)->fscache, *nr_pages, inode);
195 ret = fscache_read_or_alloc_pages(CIFS_I(inode)->fscache, mapping, 192 ret = fscache_read_or_alloc_pages(CIFS_I(inode)->fscache, mapping,
196 pages, nr_pages, 193 pages, nr_pages,
@@ -199,12 +196,12 @@ int __cifs_readpages_from_fscache(struct inode *inode,
199 mapping_gfp_mask(mapping)); 196 mapping_gfp_mask(mapping));
200 switch (ret) { 197 switch (ret) {
201 case 0: /* read submitted to the cache for all pages */ 198 case 0: /* read submitted to the cache for all pages */
202 cFYI(1, "CIFS: readpages_from_fscache: submitted"); 199 cFYI(1, "%s: submitted", __func__);
203 return ret; 200 return ret;
204 201
205 case -ENOBUFS: /* some pages are not cached and can't be */ 202 case -ENOBUFS: /* some pages are not cached and can't be */
206 case -ENODATA: /* some pages are not cached */ 203 case -ENODATA: /* some pages are not cached */
207 cFYI(1, "CIFS: readpages_from_fscache: no page"); 204 cFYI(1, "%s: no page", __func__);
208 return 1; 205 return 1;
209 206
210 default: 207 default:
@@ -218,7 +215,7 @@ void __cifs_readpage_to_fscache(struct inode *inode, struct page *page)
218{ 215{
219 int ret; 216 int ret;
220 217
221 cFYI(1, "CIFS: readpage_to_fscache(fsc: %p, p: %p, i: %p", 218 cFYI(1, "%s: (fsc: %p, p: %p, i: %p)", __func__,
222 CIFS_I(inode)->fscache, page, inode); 219 CIFS_I(inode)->fscache, page, inode);
223 ret = fscache_write_page(CIFS_I(inode)->fscache, page, GFP_KERNEL); 220 ret = fscache_write_page(CIFS_I(inode)->fscache, page, GFP_KERNEL);
224 if (ret != 0) 221 if (ret != 0)
@@ -230,7 +227,7 @@ void __cifs_fscache_invalidate_page(struct page *page, struct inode *inode)
230 struct cifsInodeInfo *cifsi = CIFS_I(inode); 227 struct cifsInodeInfo *cifsi = CIFS_I(inode);
231 struct fscache_cookie *cookie = cifsi->fscache; 228 struct fscache_cookie *cookie = cifsi->fscache;
232 229
233 cFYI(1, "CIFS: fscache invalidatepage (0x%p/0x%p)", page, cookie); 230 cFYI(1, "%s: (0x%p/0x%p)", __func__, page, cookie);
234 fscache_wait_on_page_write(cookie, page); 231 fscache_wait_on_page_write(cookie, page);
235 fscache_uncache_page(cookie, page); 232 fscache_uncache_page(cookie, page);
236} 233}
diff --git a/fs/exec.c b/fs/exec.c
index 97e0d52d72fd..6075a1e727ae 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1996,7 +1996,7 @@ static void wait_for_dump_helpers(struct file *file)
1996 * is a special value that we use to trap recursive 1996 * is a special value that we use to trap recursive
1997 * core dumps 1997 * core dumps
1998 */ 1998 */
1999static int umh_pipe_setup(struct subprocess_info *info) 1999static int umh_pipe_setup(struct subprocess_info *info, struct cred *new)
2000{ 2000{
2001 struct file *rp, *wp; 2001 struct file *rp, *wp;
2002 struct fdtable *fdt; 2002 struct fdtable *fdt;
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index 3db5ba4568fc..b3cc8586984e 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -974,7 +974,7 @@ out_no_inode:
974out_no_read: 974out_no_read:
975 printk(KERN_WARNING "%s: bread failed, dev=%s, iso_blknum=%d, block=%d\n", 975 printk(KERN_WARNING "%s: bread failed, dev=%s, iso_blknum=%d, block=%d\n",
976 __func__, s->s_id, iso_blknum, block); 976 __func__, s->s_id, iso_blknum, block);
977 goto out_freesbi; 977 goto out_freebh;
978out_bad_zone_size: 978out_bad_zone_size:
979 printk(KERN_WARNING "ISOFS: Bad logical zone size %ld\n", 979 printk(KERN_WARNING "ISOFS: Bad logical zone size %ld\n",
980 sbi->s_log_zone_size); 980 sbi->s_log_zone_size);
@@ -989,6 +989,7 @@ out_unknown_format:
989 989
990out_freebh: 990out_freebh:
991 brelse(bh); 991 brelse(bh);
992 brelse(pri_bh);
992out_freesbi: 993out_freesbi:
993 kfree(opt.iocharset); 994 kfree(opt.iocharset);
994 kfree(sbi); 995 kfree(sbi);
diff --git a/fs/namei.c b/fs/namei.c
index 9802345df5e7..9e425e7e6c8f 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -812,6 +812,11 @@ static int follow_automount(struct path *path, unsigned flags,
812 if (!mnt) /* mount collision */ 812 if (!mnt) /* mount collision */
813 return 0; 813 return 0;
814 814
815 if (!*need_mntput) {
816 /* lock_mount() may release path->mnt on error */
817 mntget(path->mnt);
818 *need_mntput = true;
819 }
815 err = finish_automount(mnt, path); 820 err = finish_automount(mnt, path);
816 821
817 switch (err) { 822 switch (err) {
@@ -819,12 +824,9 @@ static int follow_automount(struct path *path, unsigned flags,
819 /* Someone else made a mount here whilst we were busy */ 824 /* Someone else made a mount here whilst we were busy */
820 return 0; 825 return 0;
821 case 0: 826 case 0:
822 dput(path->dentry); 827 path_put(path);
823 if (*need_mntput)
824 mntput(path->mnt);
825 path->mnt = mnt; 828 path->mnt = mnt;
826 path->dentry = dget(mnt->mnt_root); 829 path->dentry = dget(mnt->mnt_root);
827 *need_mntput = true;
828 return 0; 830 return 0;
829 default: 831 default:
830 return err; 832 return err;
@@ -844,9 +846,10 @@ static int follow_automount(struct path *path, unsigned flags,
844 */ 846 */
845static int follow_managed(struct path *path, unsigned flags) 847static int follow_managed(struct path *path, unsigned flags)
846{ 848{
849 struct vfsmount *mnt = path->mnt; /* held by caller, must be left alone */
847 unsigned managed; 850 unsigned managed;
848 bool need_mntput = false; 851 bool need_mntput = false;
849 int ret; 852 int ret = 0;
850 853
851 /* Given that we're not holding a lock here, we retain the value in a 854 /* Given that we're not holding a lock here, we retain the value in a
852 * local variable for each dentry as we look at it so that we don't see 855 * local variable for each dentry as we look at it so that we don't see
@@ -861,7 +864,7 @@ static int follow_managed(struct path *path, unsigned flags)
861 BUG_ON(!path->dentry->d_op->d_manage); 864 BUG_ON(!path->dentry->d_op->d_manage);
862 ret = path->dentry->d_op->d_manage(path->dentry, false); 865 ret = path->dentry->d_op->d_manage(path->dentry, false);
863 if (ret < 0) 866 if (ret < 0)
864 return ret == -EISDIR ? 0 : ret; 867 break;
865 } 868 }
866 869
867 /* Transit to a mounted filesystem. */ 870 /* Transit to a mounted filesystem. */
@@ -887,14 +890,19 @@ static int follow_managed(struct path *path, unsigned flags)
887 if (managed & DCACHE_NEED_AUTOMOUNT) { 890 if (managed & DCACHE_NEED_AUTOMOUNT) {
888 ret = follow_automount(path, flags, &need_mntput); 891 ret = follow_automount(path, flags, &need_mntput);
889 if (ret < 0) 892 if (ret < 0)
890 return ret == -EISDIR ? 0 : ret; 893 break;
891 continue; 894 continue;
892 } 895 }
893 896
894 /* We didn't change the current path point */ 897 /* We didn't change the current path point */
895 break; 898 break;
896 } 899 }
897 return 0; 900
901 if (need_mntput && path->mnt == mnt)
902 mntput(path->mnt);
903 if (ret == -EISDIR)
904 ret = 0;
905 return ret;
898} 906}
899 907
900int follow_down_one(struct path *path) 908int follow_down_one(struct path *path)
@@ -2713,8 +2721,10 @@ static long do_unlinkat(int dfd, const char __user *pathname)
2713 error = PTR_ERR(dentry); 2721 error = PTR_ERR(dentry);
2714 if (!IS_ERR(dentry)) { 2722 if (!IS_ERR(dentry)) {
2715 /* Why not before? Because we want correct error value */ 2723 /* Why not before? Because we want correct error value */
2724 if (nd.last.name[nd.last.len])
2725 goto slashes;
2716 inode = dentry->d_inode; 2726 inode = dentry->d_inode;
2717 if (nd.last.name[nd.last.len] || !inode) 2727 if (!inode)
2718 goto slashes; 2728 goto slashes;
2719 ihold(inode); 2729 ihold(inode);
2720 error = mnt_want_write(nd.path.mnt); 2730 error = mnt_want_write(nd.path.mnt);
diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c
index 781dec5bd682..be177f702acb 100644
--- a/fs/proc/namespaces.c
+++ b/fs/proc/namespaces.c
@@ -38,18 +38,21 @@ static struct dentry *proc_ns_instantiate(struct inode *dir,
38 struct inode *inode; 38 struct inode *inode;
39 struct proc_inode *ei; 39 struct proc_inode *ei;
40 struct dentry *error = ERR_PTR(-ENOENT); 40 struct dentry *error = ERR_PTR(-ENOENT);
41 void *ns;
41 42
42 inode = proc_pid_make_inode(dir->i_sb, task); 43 inode = proc_pid_make_inode(dir->i_sb, task);
43 if (!inode) 44 if (!inode)
44 goto out; 45 goto out;
45 46
47 ns = ns_ops->get(task);
48 if (!ns)
49 goto out_iput;
50
46 ei = PROC_I(inode); 51 ei = PROC_I(inode);
47 inode->i_mode = S_IFREG|S_IRUSR; 52 inode->i_mode = S_IFREG|S_IRUSR;
48 inode->i_fop = &ns_file_operations; 53 inode->i_fop = &ns_file_operations;
49 ei->ns_ops = ns_ops; 54 ei->ns_ops = ns_ops;
50 ei->ns = ns_ops->get(task); 55 ei->ns = ns;
51 if (!ei->ns)
52 goto out_iput;
53 56
54 dentry->d_op = &pid_dentry_operations; 57 dentry->d_op = &pid_dentry_operations;
55 d_add(dentry, inode); 58 d_add(dentry, inode);
diff --git a/fs/proc/root.c b/fs/proc/root.c
index a9000e9cfee5..d6c3b416529b 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -28,11 +28,12 @@ static int proc_test_super(struct super_block *sb, void *data)
28 28
29static int proc_set_super(struct super_block *sb, void *data) 29static int proc_set_super(struct super_block *sb, void *data)
30{ 30{
31 struct pid_namespace *ns; 31 int err = set_anon_super(sb, NULL);
32 32 if (!err) {
33 ns = (struct pid_namespace *)data; 33 struct pid_namespace *ns = (struct pid_namespace *)data;
34 sb->s_fs_info = get_pid_ns(ns); 34 sb->s_fs_info = get_pid_ns(ns);
35 return set_anon_super(sb, NULL); 35 }
36 return err;
36} 37}
37 38
38static struct dentry *proc_mount(struct file_system_type *fs_type, 39static struct dentry *proc_mount(struct file_system_type *fs_type,
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index 266895783b47..e34f0d99ea4e 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -95,6 +95,14 @@ static int sysfs_set_super(struct super_block *sb, void *data)
95 return error; 95 return error;
96} 96}
97 97
98static void free_sysfs_super_info(struct sysfs_super_info *info)
99{
100 int type;
101 for (type = KOBJ_NS_TYPE_NONE; type < KOBJ_NS_TYPES; type++)
102 kobj_ns_drop(type, info->ns[type]);
103 kfree(info);
104}
105
98static struct dentry *sysfs_mount(struct file_system_type *fs_type, 106static struct dentry *sysfs_mount(struct file_system_type *fs_type,
99 int flags, const char *dev_name, void *data) 107 int flags, const char *dev_name, void *data)
100{ 108{
@@ -108,11 +116,11 @@ static struct dentry *sysfs_mount(struct file_system_type *fs_type,
108 return ERR_PTR(-ENOMEM); 116 return ERR_PTR(-ENOMEM);
109 117
110 for (type = KOBJ_NS_TYPE_NONE; type < KOBJ_NS_TYPES; type++) 118 for (type = KOBJ_NS_TYPE_NONE; type < KOBJ_NS_TYPES; type++)
111 info->ns[type] = kobj_ns_current(type); 119 info->ns[type] = kobj_ns_grab_current(type);
112 120
113 sb = sget(fs_type, sysfs_test_super, sysfs_set_super, info); 121 sb = sget(fs_type, sysfs_test_super, sysfs_set_super, info);
114 if (IS_ERR(sb) || sb->s_fs_info != info) 122 if (IS_ERR(sb) || sb->s_fs_info != info)
115 kfree(info); 123 free_sysfs_super_info(info);
116 if (IS_ERR(sb)) 124 if (IS_ERR(sb))
117 return ERR_CAST(sb); 125 return ERR_CAST(sb);
118 if (!sb->s_root) { 126 if (!sb->s_root) {
@@ -131,12 +139,11 @@ static struct dentry *sysfs_mount(struct file_system_type *fs_type,
131static void sysfs_kill_sb(struct super_block *sb) 139static void sysfs_kill_sb(struct super_block *sb)
132{ 140{
133 struct sysfs_super_info *info = sysfs_info(sb); 141 struct sysfs_super_info *info = sysfs_info(sb);
134
135 /* Remove the superblock from fs_supers/s_instances 142 /* Remove the superblock from fs_supers/s_instances
136 * so we can't find it, before freeing sysfs_super_info. 143 * so we can't find it, before freeing sysfs_super_info.
137 */ 144 */
138 kill_anon_super(sb); 145 kill_anon_super(sb);
139 kfree(info); 146 free_sysfs_super_info(info);
140} 147}
141 148
142static struct file_system_type sysfs_fs_type = { 149static struct file_system_type sysfs_fs_type = {
@@ -145,28 +152,6 @@ static struct file_system_type sysfs_fs_type = {
145 .kill_sb = sysfs_kill_sb, 152 .kill_sb = sysfs_kill_sb,
146}; 153};
147 154
148void sysfs_exit_ns(enum kobj_ns_type type, const void *ns)
149{
150 struct super_block *sb;
151
152 mutex_lock(&sysfs_mutex);
153 spin_lock(&sb_lock);
154 list_for_each_entry(sb, &sysfs_fs_type.fs_supers, s_instances) {
155 struct sysfs_super_info *info = sysfs_info(sb);
156 /*
157 * If we see a superblock on the fs_supers/s_instances
158 * list the unmount has not completed and sb->s_fs_info
159 * points to a valid struct sysfs_super_info.
160 */
161 /* Ignore superblocks with the wrong ns */
162 if (info->ns[type] != ns)
163 continue;
164 info->ns[type] = NULL;
165 }
166 spin_unlock(&sb_lock);
167 mutex_unlock(&sysfs_mutex);
168}
169
170int __init sysfs_init(void) 155int __init sysfs_init(void)
171{ 156{
172 int err = -ENOMEM; 157 int err = -ENOMEM;
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 3d28af31d863..2ed2404f3113 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -136,7 +136,7 @@ struct sysfs_addrm_cxt {
136 * instance). 136 * instance).
137 */ 137 */
138struct sysfs_super_info { 138struct sysfs_super_info {
139 const void *ns[KOBJ_NS_TYPES]; 139 void *ns[KOBJ_NS_TYPES];
140}; 140};
141#define sysfs_info(SB) ((struct sysfs_super_info *)(SB->s_fs_info)) 141#define sysfs_info(SB) ((struct sysfs_super_info *)(SB->s_fs_info))
142extern struct sysfs_dirent sysfs_root; 142extern struct sysfs_dirent sysfs_root;
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index b5aeb5a8ebed..8c892c2d5300 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1848,7 +1848,6 @@ static void ubifs_put_super(struct super_block *sb)
1848 bdi_destroy(&c->bdi); 1848 bdi_destroy(&c->bdi);
1849 ubi_close_volume(c->ubi); 1849 ubi_close_volume(c->ubi);
1850 mutex_unlock(&c->umount_mutex); 1850 mutex_unlock(&c->umount_mutex);
1851 kfree(c);
1852} 1851}
1853 1852
1854static int ubifs_remount_fs(struct super_block *sb, int *flags, char *data) 1853static int ubifs_remount_fs(struct super_block *sb, int *flags, char *data)
@@ -1971,61 +1970,65 @@ static struct ubi_volume_desc *open_ubi(const char *name, int mode)
1971 return ERR_PTR(-EINVAL); 1970 return ERR_PTR(-EINVAL);
1972} 1971}
1973 1972
1974static int ubifs_fill_super(struct super_block *sb, void *data, int silent) 1973static struct ubifs_info *alloc_ubifs_info(struct ubi_volume_desc *ubi)
1975{ 1974{
1976 struct ubi_volume_desc *ubi = sb->s_fs_info;
1977 struct ubifs_info *c; 1975 struct ubifs_info *c;
1978 struct inode *root;
1979 int err;
1980 1976
1981 c = kzalloc(sizeof(struct ubifs_info), GFP_KERNEL); 1977 c = kzalloc(sizeof(struct ubifs_info), GFP_KERNEL);
1982 if (!c) 1978 if (c) {
1983 return -ENOMEM; 1979 spin_lock_init(&c->cnt_lock);
1980 spin_lock_init(&c->cs_lock);
1981 spin_lock_init(&c->buds_lock);
1982 spin_lock_init(&c->space_lock);
1983 spin_lock_init(&c->orphan_lock);
1984 init_rwsem(&c->commit_sem);
1985 mutex_init(&c->lp_mutex);
1986 mutex_init(&c->tnc_mutex);
1987 mutex_init(&c->log_mutex);
1988 mutex_init(&c->mst_mutex);
1989 mutex_init(&c->umount_mutex);
1990 mutex_init(&c->bu_mutex);
1991 mutex_init(&c->write_reserve_mutex);
1992 init_waitqueue_head(&c->cmt_wq);
1993 c->buds = RB_ROOT;
1994 c->old_idx = RB_ROOT;
1995 c->size_tree = RB_ROOT;
1996 c->orph_tree = RB_ROOT;
1997 INIT_LIST_HEAD(&c->infos_list);
1998 INIT_LIST_HEAD(&c->idx_gc);
1999 INIT_LIST_HEAD(&c->replay_list);
2000 INIT_LIST_HEAD(&c->replay_buds);
2001 INIT_LIST_HEAD(&c->uncat_list);
2002 INIT_LIST_HEAD(&c->empty_list);
2003 INIT_LIST_HEAD(&c->freeable_list);
2004 INIT_LIST_HEAD(&c->frdi_idx_list);
2005 INIT_LIST_HEAD(&c->unclean_leb_list);
2006 INIT_LIST_HEAD(&c->old_buds);
2007 INIT_LIST_HEAD(&c->orph_list);
2008 INIT_LIST_HEAD(&c->orph_new);
2009 c->no_chk_data_crc = 1;
2010
2011 c->highest_inum = UBIFS_FIRST_INO;
2012 c->lhead_lnum = c->ltail_lnum = UBIFS_LOG_LNUM;
2013
2014 ubi_get_volume_info(ubi, &c->vi);
2015 ubi_get_device_info(c->vi.ubi_num, &c->di);
2016 }
2017 return c;
2018}
1984 2019
1985 spin_lock_init(&c->cnt_lock); 2020static int ubifs_fill_super(struct super_block *sb, void *data, int silent)
1986 spin_lock_init(&c->cs_lock); 2021{
1987 spin_lock_init(&c->buds_lock); 2022 struct ubifs_info *c = sb->s_fs_info;
1988 spin_lock_init(&c->space_lock); 2023 struct inode *root;
1989 spin_lock_init(&c->orphan_lock); 2024 int err;
1990 init_rwsem(&c->commit_sem);
1991 mutex_init(&c->lp_mutex);
1992 mutex_init(&c->tnc_mutex);
1993 mutex_init(&c->log_mutex);
1994 mutex_init(&c->mst_mutex);
1995 mutex_init(&c->umount_mutex);
1996 mutex_init(&c->bu_mutex);
1997 mutex_init(&c->write_reserve_mutex);
1998 init_waitqueue_head(&c->cmt_wq);
1999 c->buds = RB_ROOT;
2000 c->old_idx = RB_ROOT;
2001 c->size_tree = RB_ROOT;
2002 c->orph_tree = RB_ROOT;
2003 INIT_LIST_HEAD(&c->infos_list);
2004 INIT_LIST_HEAD(&c->idx_gc);
2005 INIT_LIST_HEAD(&c->replay_list);
2006 INIT_LIST_HEAD(&c->replay_buds);
2007 INIT_LIST_HEAD(&c->uncat_list);
2008 INIT_LIST_HEAD(&c->empty_list);
2009 INIT_LIST_HEAD(&c->freeable_list);
2010 INIT_LIST_HEAD(&c->frdi_idx_list);
2011 INIT_LIST_HEAD(&c->unclean_leb_list);
2012 INIT_LIST_HEAD(&c->old_buds);
2013 INIT_LIST_HEAD(&c->orph_list);
2014 INIT_LIST_HEAD(&c->orph_new);
2015 c->no_chk_data_crc = 1;
2016 2025
2017 c->vfs_sb = sb; 2026 c->vfs_sb = sb;
2018 c->highest_inum = UBIFS_FIRST_INO;
2019 c->lhead_lnum = c->ltail_lnum = UBIFS_LOG_LNUM;
2020
2021 ubi_get_volume_info(ubi, &c->vi);
2022 ubi_get_device_info(c->vi.ubi_num, &c->di);
2023
2024 /* Re-open the UBI device in read-write mode */ 2027 /* Re-open the UBI device in read-write mode */
2025 c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READWRITE); 2028 c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READWRITE);
2026 if (IS_ERR(c->ubi)) { 2029 if (IS_ERR(c->ubi)) {
2027 err = PTR_ERR(c->ubi); 2030 err = PTR_ERR(c->ubi);
2028 goto out_free; 2031 goto out;
2029 } 2032 }
2030 2033
2031 /* 2034 /*
@@ -2091,24 +2094,29 @@ out_bdi:
2091 bdi_destroy(&c->bdi); 2094 bdi_destroy(&c->bdi);
2092out_close: 2095out_close:
2093 ubi_close_volume(c->ubi); 2096 ubi_close_volume(c->ubi);
2094out_free: 2097out:
2095 kfree(c);
2096 return err; 2098 return err;
2097} 2099}
2098 2100
2099static int sb_test(struct super_block *sb, void *data) 2101static int sb_test(struct super_block *sb, void *data)
2100{ 2102{
2101 dev_t *dev = data; 2103 struct ubifs_info *c1 = data;
2102 struct ubifs_info *c = sb->s_fs_info; 2104 struct ubifs_info *c = sb->s_fs_info;
2103 2105
2104 return c->vi.cdev == *dev; 2106 return c->vi.cdev == c1->vi.cdev;
2107}
2108
2109static int sb_set(struct super_block *sb, void *data)
2110{
2111 sb->s_fs_info = data;
2112 return set_anon_super(sb, NULL);
2105} 2113}
2106 2114
2107static struct dentry *ubifs_mount(struct file_system_type *fs_type, int flags, 2115static struct dentry *ubifs_mount(struct file_system_type *fs_type, int flags,
2108 const char *name, void *data) 2116 const char *name, void *data)
2109{ 2117{
2110 struct ubi_volume_desc *ubi; 2118 struct ubi_volume_desc *ubi;
2111 struct ubi_volume_info vi; 2119 struct ubifs_info *c;
2112 struct super_block *sb; 2120 struct super_block *sb;
2113 int err; 2121 int err;
2114 2122
@@ -2125,19 +2133,24 @@ static struct dentry *ubifs_mount(struct file_system_type *fs_type, int flags,
2125 name, (int)PTR_ERR(ubi)); 2133 name, (int)PTR_ERR(ubi));
2126 return ERR_CAST(ubi); 2134 return ERR_CAST(ubi);
2127 } 2135 }
2128 ubi_get_volume_info(ubi, &vi);
2129 2136
2130 dbg_gen("opened ubi%d_%d", vi.ubi_num, vi.vol_id); 2137 c = alloc_ubifs_info(ubi);
2138 if (!c) {
2139 err = -ENOMEM;
2140 goto out_close;
2141 }
2142
2143 dbg_gen("opened ubi%d_%d", c->vi.ubi_num, c->vi.vol_id);
2131 2144
2132 sb = sget(fs_type, &sb_test, &set_anon_super, &vi.cdev); 2145 sb = sget(fs_type, sb_test, sb_set, c);
2133 if (IS_ERR(sb)) { 2146 if (IS_ERR(sb)) {
2134 err = PTR_ERR(sb); 2147 err = PTR_ERR(sb);
2135 goto out_close; 2148 kfree(c);
2136 } 2149 }
2137 2150
2138 if (sb->s_root) { 2151 if (sb->s_root) {
2139 struct ubifs_info *c1 = sb->s_fs_info; 2152 struct ubifs_info *c1 = sb->s_fs_info;
2140 2153 kfree(c);
2141 /* A new mount point for already mounted UBIFS */ 2154 /* A new mount point for already mounted UBIFS */
2142 dbg_gen("this ubi volume is already mounted"); 2155 dbg_gen("this ubi volume is already mounted");
2143 if (!!(flags & MS_RDONLY) != c1->ro_mount) { 2156 if (!!(flags & MS_RDONLY) != c1->ro_mount) {
@@ -2146,11 +2159,6 @@ static struct dentry *ubifs_mount(struct file_system_type *fs_type, int flags,
2146 } 2159 }
2147 } else { 2160 } else {
2148 sb->s_flags = flags; 2161 sb->s_flags = flags;
2149 /*
2150 * Pass 'ubi' to 'fill_super()' in sb->s_fs_info where it is
2151 * replaced by 'c'.
2152 */
2153 sb->s_fs_info = ubi;
2154 err = ubifs_fill_super(sb, data, flags & MS_SILENT ? 1 : 0); 2162 err = ubifs_fill_super(sb, data, flags & MS_SILENT ? 1 : 0);
2155 if (err) 2163 if (err)
2156 goto out_deact; 2164 goto out_deact;
@@ -2170,11 +2178,18 @@ out_close:
2170 return ERR_PTR(err); 2178 return ERR_PTR(err);
2171} 2179}
2172 2180
2181static void kill_ubifs_super(struct super_block *s)
2182{
2183 struct ubifs_info *c = s->s_fs_info;
2184 kill_anon_super(s);
2185 kfree(c);
2186}
2187
2173static struct file_system_type ubifs_fs_type = { 2188static struct file_system_type ubifs_fs_type = {
2174 .name = "ubifs", 2189 .name = "ubifs",
2175 .owner = THIS_MODULE, 2190 .owner = THIS_MODULE,
2176 .mount = ubifs_mount, 2191 .mount = ubifs_mount,
2177 .kill_sb = kill_anon_super, 2192 .kill_sb = kill_ubifs_super,
2178}; 2193};
2179 2194
2180/* 2195/*
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c
index f4213ba1ff85..7f782af286bf 100644
--- a/fs/xfs/linux-2.6/xfs_file.c
+++ b/fs/xfs/linux-2.6/xfs_file.c
@@ -131,19 +131,34 @@ xfs_file_fsync(
131{ 131{
132 struct inode *inode = file->f_mapping->host; 132 struct inode *inode = file->f_mapping->host;
133 struct xfs_inode *ip = XFS_I(inode); 133 struct xfs_inode *ip = XFS_I(inode);
134 struct xfs_mount *mp = ip->i_mount;
134 struct xfs_trans *tp; 135 struct xfs_trans *tp;
135 int error = 0; 136 int error = 0;
136 int log_flushed = 0; 137 int log_flushed = 0;
137 138
138 trace_xfs_file_fsync(ip); 139 trace_xfs_file_fsync(ip);
139 140
140 if (XFS_FORCED_SHUTDOWN(ip->i_mount)) 141 if (XFS_FORCED_SHUTDOWN(mp))
141 return -XFS_ERROR(EIO); 142 return -XFS_ERROR(EIO);
142 143
143 xfs_iflags_clear(ip, XFS_ITRUNCATED); 144 xfs_iflags_clear(ip, XFS_ITRUNCATED);
144 145
145 xfs_ioend_wait(ip); 146 xfs_ioend_wait(ip);
146 147
148 if (mp->m_flags & XFS_MOUNT_BARRIER) {
149 /*
150 * If we have an RT and/or log subvolume we need to make sure
151 * to flush the write cache the device used for file data
152 * first. This is to ensure newly written file data make
153 * it to disk before logging the new inode size in case of
154 * an extending write.
155 */
156 if (XFS_IS_REALTIME_INODE(ip))
157 xfs_blkdev_issue_flush(mp->m_rtdev_targp);
158 else if (mp->m_logdev_targp != mp->m_ddev_targp)
159 xfs_blkdev_issue_flush(mp->m_ddev_targp);
160 }
161
147 /* 162 /*
148 * We always need to make sure that the required inode state is safe on 163 * We always need to make sure that the required inode state is safe on
149 * disk. The inode might be clean but we still might need to force the 164 * disk. The inode might be clean but we still might need to force the
@@ -175,9 +190,9 @@ xfs_file_fsync(
175 * updates. The sync transaction will also force the log. 190 * updates. The sync transaction will also force the log.
176 */ 191 */
177 xfs_iunlock(ip, XFS_ILOCK_SHARED); 192 xfs_iunlock(ip, XFS_ILOCK_SHARED);
178 tp = xfs_trans_alloc(ip->i_mount, XFS_TRANS_FSYNC_TS); 193 tp = xfs_trans_alloc(mp, XFS_TRANS_FSYNC_TS);
179 error = xfs_trans_reserve(tp, 0, 194 error = xfs_trans_reserve(tp, 0,
180 XFS_FSYNC_TS_LOG_RES(ip->i_mount), 0, 0, 0); 195 XFS_FSYNC_TS_LOG_RES(mp), 0, 0, 0);
181 if (error) { 196 if (error) {
182 xfs_trans_cancel(tp, 0); 197 xfs_trans_cancel(tp, 0);
183 return -error; 198 return -error;
@@ -209,28 +224,25 @@ xfs_file_fsync(
209 * force the log. 224 * force the log.
210 */ 225 */
211 if (xfs_ipincount(ip)) { 226 if (xfs_ipincount(ip)) {
212 error = _xfs_log_force_lsn(ip->i_mount, 227 error = _xfs_log_force_lsn(mp,
213 ip->i_itemp->ili_last_lsn, 228 ip->i_itemp->ili_last_lsn,
214 XFS_LOG_SYNC, &log_flushed); 229 XFS_LOG_SYNC, &log_flushed);
215 } 230 }
216 xfs_iunlock(ip, XFS_ILOCK_SHARED); 231 xfs_iunlock(ip, XFS_ILOCK_SHARED);
217 } 232 }
218 233
219 if (ip->i_mount->m_flags & XFS_MOUNT_BARRIER) { 234 /*
220 /* 235 * If we only have a single device, and the log force about was
221 * If the log write didn't issue an ordered tag we need 236 * a no-op we might have to flush the data device cache here.
222 * to flush the disk cache for the data device now. 237 * This can only happen for fdatasync/O_DSYNC if we were overwriting
223 */ 238 * an already allocated file and thus do not have any metadata to
224 if (!log_flushed) 239 * commit.
225 xfs_blkdev_issue_flush(ip->i_mount->m_ddev_targp); 240 */
226 241 if ((mp->m_flags & XFS_MOUNT_BARRIER) &&
227 /* 242 mp->m_logdev_targp == mp->m_ddev_targp &&
228 * If this inode is on the RT dev we need to flush that 243 !XFS_IS_REALTIME_INODE(ip) &&
229 * cache as well. 244 !log_flushed)
230 */ 245 xfs_blkdev_issue_flush(mp->m_ddev_targp);
231 if (XFS_IS_REALTIME_INODE(ip))
232 xfs_blkdev_issue_flush(ip->i_mount->m_rtdev_targp);
233 }
234 246
235 return -error; 247 return -error;
236} 248}
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index dd21784525a8..d44d92cd12b1 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -182,7 +182,7 @@ xfs_vn_mknod(
182 if (IS_POSIXACL(dir)) { 182 if (IS_POSIXACL(dir)) {
183 default_acl = xfs_get_acl(dir, ACL_TYPE_DEFAULT); 183 default_acl = xfs_get_acl(dir, ACL_TYPE_DEFAULT);
184 if (IS_ERR(default_acl)) 184 if (IS_ERR(default_acl))
185 return -PTR_ERR(default_acl); 185 return PTR_ERR(default_acl);
186 186
187 if (!default_acl) 187 if (!default_acl)
188 mode &= ~current_umask(); 188 mode &= ~current_umask();
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 1e3a7ce804dc..a1a881e68a9a 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -627,68 +627,6 @@ xfs_blkdev_put(
627 blkdev_put(bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL); 627 blkdev_put(bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL);
628} 628}
629 629
630/*
631 * Try to write out the superblock using barriers.
632 */
633STATIC int
634xfs_barrier_test(
635 xfs_mount_t *mp)
636{
637 xfs_buf_t *sbp = xfs_getsb(mp, 0);
638 int error;
639
640 XFS_BUF_UNDONE(sbp);
641 XFS_BUF_UNREAD(sbp);
642 XFS_BUF_UNDELAYWRITE(sbp);
643 XFS_BUF_WRITE(sbp);
644 XFS_BUF_UNASYNC(sbp);
645 XFS_BUF_ORDERED(sbp);
646
647 xfsbdstrat(mp, sbp);
648 error = xfs_buf_iowait(sbp);
649
650 /*
651 * Clear all the flags we set and possible error state in the
652 * buffer. We only did the write to try out whether barriers
653 * worked and shouldn't leave any traces in the superblock
654 * buffer.
655 */
656 XFS_BUF_DONE(sbp);
657 XFS_BUF_ERROR(sbp, 0);
658 XFS_BUF_UNORDERED(sbp);
659
660 xfs_buf_relse(sbp);
661 return error;
662}
663
664STATIC void
665xfs_mountfs_check_barriers(xfs_mount_t *mp)
666{
667 int error;
668
669 if (mp->m_logdev_targp != mp->m_ddev_targp) {
670 xfs_notice(mp,
671 "Disabling barriers, not supported with external log device");
672 mp->m_flags &= ~XFS_MOUNT_BARRIER;
673 return;
674 }
675
676 if (xfs_readonly_buftarg(mp->m_ddev_targp)) {
677 xfs_notice(mp,
678 "Disabling barriers, underlying device is readonly");
679 mp->m_flags &= ~XFS_MOUNT_BARRIER;
680 return;
681 }
682
683 error = xfs_barrier_test(mp);
684 if (error) {
685 xfs_notice(mp,
686 "Disabling barriers, trial barrier write failed");
687 mp->m_flags &= ~XFS_MOUNT_BARRIER;
688 return;
689 }
690}
691
692void 630void
693xfs_blkdev_issue_flush( 631xfs_blkdev_issue_flush(
694 xfs_buftarg_t *buftarg) 632 xfs_buftarg_t *buftarg)
@@ -1240,14 +1178,6 @@ xfs_fs_remount(
1240 switch (token) { 1178 switch (token) {
1241 case Opt_barrier: 1179 case Opt_barrier:
1242 mp->m_flags |= XFS_MOUNT_BARRIER; 1180 mp->m_flags |= XFS_MOUNT_BARRIER;
1243
1244 /*
1245 * Test if barriers are actually working if we can,
1246 * else delay this check until the filesystem is
1247 * marked writeable.
1248 */
1249 if (!(mp->m_flags & XFS_MOUNT_RDONLY))
1250 xfs_mountfs_check_barriers(mp);
1251 break; 1181 break;
1252 case Opt_nobarrier: 1182 case Opt_nobarrier:
1253 mp->m_flags &= ~XFS_MOUNT_BARRIER; 1183 mp->m_flags &= ~XFS_MOUNT_BARRIER;
@@ -1282,8 +1212,6 @@ xfs_fs_remount(
1282 /* ro -> rw */ 1212 /* ro -> rw */
1283 if ((mp->m_flags & XFS_MOUNT_RDONLY) && !(*flags & MS_RDONLY)) { 1213 if ((mp->m_flags & XFS_MOUNT_RDONLY) && !(*flags & MS_RDONLY)) {
1284 mp->m_flags &= ~XFS_MOUNT_RDONLY; 1214 mp->m_flags &= ~XFS_MOUNT_RDONLY;
1285 if (mp->m_flags & XFS_MOUNT_BARRIER)
1286 xfs_mountfs_check_barriers(mp);
1287 1215
1288 /* 1216 /*
1289 * If this is the first remount to writeable state we 1217 * If this is the first remount to writeable state we
@@ -1465,9 +1393,6 @@ xfs_fs_fill_super(
1465 if (error) 1393 if (error)
1466 goto out_free_sb; 1394 goto out_free_sb;
1467 1395
1468 if (mp->m_flags & XFS_MOUNT_BARRIER)
1469 xfs_mountfs_check_barriers(mp);
1470
1471 error = xfs_filestream_mount(mp); 1396 error = xfs_filestream_mount(mp);
1472 if (error) 1397 if (error)
1473 goto out_free_sb; 1398 goto out_free_sb;
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 211930246f20..41d5b8f2bf92 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -1372,8 +1372,17 @@ xlog_sync(xlog_t *log,
1372 XFS_BUF_ASYNC(bp); 1372 XFS_BUF_ASYNC(bp);
1373 bp->b_flags |= XBF_LOG_BUFFER; 1373 bp->b_flags |= XBF_LOG_BUFFER;
1374 1374
1375 if (log->l_mp->m_flags & XFS_MOUNT_BARRIER) 1375 if (log->l_mp->m_flags & XFS_MOUNT_BARRIER) {
1376 /*
1377 * If we have an external log device, flush the data device
1378 * before flushing the log to make sure all meta data
1379 * written back from the AIL actually made it to disk
1380 * before writing out the new log tail LSN in the log buffer.
1381 */
1382 if (log->l_mp->m_logdev_targp != log->l_mp->m_ddev_targp)
1383 xfs_blkdev_issue_flush(log->l_mp->m_ddev_targp);
1376 XFS_BUF_ORDERED(bp); 1384 XFS_BUF_ORDERED(bp);
1385 }
1377 1386
1378 ASSERT(XFS_BUF_ADDR(bp) <= log->l_logBBsize-1); 1387 ASSERT(XFS_BUF_ADDR(bp) <= log->l_logBBsize-1);
1379 ASSERT(XFS_BUF_ADDR(bp) + BTOBB(count) <= log->l_logBBsize); 1388 ASSERT(XFS_BUF_ADDR(bp) + BTOBB(count) <= log->l_logBBsize);
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index fcdcb5d5c995..d494001b1226 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -170,16 +170,6 @@ extern int __gpio_cansleep(unsigned gpio);
170 170
171extern int __gpio_to_irq(unsigned gpio); 171extern int __gpio_to_irq(unsigned gpio);
172 172
173#define GPIOF_DIR_OUT (0 << 0)
174#define GPIOF_DIR_IN (1 << 0)
175
176#define GPIOF_INIT_LOW (0 << 1)
177#define GPIOF_INIT_HIGH (1 << 1)
178
179#define GPIOF_IN (GPIOF_DIR_IN)
180#define GPIOF_OUT_INIT_LOW (GPIOF_DIR_OUT | GPIOF_INIT_LOW)
181#define GPIOF_OUT_INIT_HIGH (GPIOF_DIR_OUT | GPIOF_INIT_HIGH)
182
183/** 173/**
184 * struct gpio - a structure describing a GPIO with configuration 174 * struct gpio - a structure describing a GPIO with configuration
185 * @gpio: the GPIO number 175 * @gpio: the GPIO number
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index e9b8e5926bef..76bff2bff15e 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -88,7 +88,7 @@ static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm,
88 pmd_t pmd = *pmdp; 88 pmd_t pmd = *pmdp;
89 pmd_clear(mm, address, pmdp); 89 pmd_clear(mm, address, pmdp);
90 return pmd; 90 return pmd;
91}) 91}
92#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ 92#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
93#endif 93#endif
94 94
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 9573e0ce3120..33d12f87f0e0 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -520,6 +520,8 @@ struct drm_connector {
520 uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER]; 520 uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
521 uint32_t force_encoder_id; 521 uint32_t force_encoder_id;
522 struct drm_encoder *encoder; /* currently active encoder */ 522 struct drm_encoder *encoder; /* currently active encoder */
523
524 int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */
523}; 525};
524 526
525/** 527/**
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 32d47e710661..17b5a0d80e42 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -3,6 +3,17 @@
3 3
4/* see Documentation/gpio.txt */ 4/* see Documentation/gpio.txt */
5 5
6/* make these flag values available regardless of GPIO kconfig options */
7#define GPIOF_DIR_OUT (0 << 0)
8#define GPIOF_DIR_IN (1 << 0)
9
10#define GPIOF_INIT_LOW (0 << 1)
11#define GPIOF_INIT_HIGH (1 << 1)
12
13#define GPIOF_IN (GPIOF_DIR_IN)
14#define GPIOF_OUT_INIT_LOW (GPIOF_DIR_OUT | GPIOF_INIT_LOW)
15#define GPIOF_OUT_INIT_HIGH (GPIOF_DIR_OUT | GPIOF_INIT_HIGH)
16
6#ifdef CONFIG_GENERIC_GPIO 17#ifdef CONFIG_GENERIC_GPIO
7#include <asm/gpio.h> 18#include <asm/gpio.h>
8 19
diff --git a/include/linux/i2c/adp8870.h b/include/linux/i2c/adp8870.h
new file mode 100644
index 000000000000..624dceccbd5b
--- /dev/null
+++ b/include/linux/i2c/adp8870.h
@@ -0,0 +1,153 @@
1/*
2 * Definitions and platform data for Analog Devices
3 * Backlight drivers ADP8870
4 *
5 * Copyright 2009-2010 Analog Devices Inc.
6 *
7 * Licensed under the GPL-2 or later.
8 */
9
10#ifndef __LINUX_I2C_ADP8870_H
11#define __LINUX_I2C_ADP8870_H
12
13#define ID_ADP8870 8870
14
15#define ADP8870_MAX_BRIGHTNESS 0x7F
16#define FLAG_OFFT_SHIFT 8
17
18/*
19 * LEDs subdevice platform data
20 */
21
22#define ADP8870_LED_DIS_BLINK (0 << FLAG_OFFT_SHIFT)
23#define ADP8870_LED_OFFT_600ms (1 << FLAG_OFFT_SHIFT)
24#define ADP8870_LED_OFFT_1200ms (2 << FLAG_OFFT_SHIFT)
25#define ADP8870_LED_OFFT_1800ms (3 << FLAG_OFFT_SHIFT)
26
27#define ADP8870_LED_ONT_200ms 0
28#define ADP8870_LED_ONT_600ms 1
29#define ADP8870_LED_ONT_800ms 2
30#define ADP8870_LED_ONT_1200ms 3
31
32#define ADP8870_LED_D7 (7)
33#define ADP8870_LED_D6 (6)
34#define ADP8870_LED_D5 (5)
35#define ADP8870_LED_D4 (4)
36#define ADP8870_LED_D3 (3)
37#define ADP8870_LED_D2 (2)
38#define ADP8870_LED_D1 (1)
39
40/*
41 * Backlight subdevice platform data
42 */
43
44#define ADP8870_BL_D7 (1 << 6)
45#define ADP8870_BL_D6 (1 << 5)
46#define ADP8870_BL_D5 (1 << 4)
47#define ADP8870_BL_D4 (1 << 3)
48#define ADP8870_BL_D3 (1 << 2)
49#define ADP8870_BL_D2 (1 << 1)
50#define ADP8870_BL_D1 (1 << 0)
51
52#define ADP8870_FADE_T_DIS 0 /* Fade Timer Disabled */
53#define ADP8870_FADE_T_300ms 1 /* 0.3 Sec */
54#define ADP8870_FADE_T_600ms 2
55#define ADP8870_FADE_T_900ms 3
56#define ADP8870_FADE_T_1200ms 4
57#define ADP8870_FADE_T_1500ms 5
58#define ADP8870_FADE_T_1800ms 6
59#define ADP8870_FADE_T_2100ms 7
60#define ADP8870_FADE_T_2400ms 8
61#define ADP8870_FADE_T_2700ms 9
62#define ADP8870_FADE_T_3000ms 10
63#define ADP8870_FADE_T_3500ms 11
64#define ADP8870_FADE_T_4000ms 12
65#define ADP8870_FADE_T_4500ms 13
66#define ADP8870_FADE_T_5000ms 14
67#define ADP8870_FADE_T_5500ms 15 /* 5.5 Sec */
68
69#define ADP8870_FADE_LAW_LINEAR 0
70#define ADP8870_FADE_LAW_SQUARE 1
71#define ADP8870_FADE_LAW_CUBIC1 2
72#define ADP8870_FADE_LAW_CUBIC2 3
73
74#define ADP8870_BL_AMBL_FILT_80ms 0 /* Light sensor filter time */
75#define ADP8870_BL_AMBL_FILT_160ms 1
76#define ADP8870_BL_AMBL_FILT_320ms 2
77#define ADP8870_BL_AMBL_FILT_640ms 3
78#define ADP8870_BL_AMBL_FILT_1280ms 4
79#define ADP8870_BL_AMBL_FILT_2560ms 5
80#define ADP8870_BL_AMBL_FILT_5120ms 6
81#define ADP8870_BL_AMBL_FILT_10240ms 7 /* 10.24 sec */
82
83/*
84 * Blacklight current 0..30mA
85 */
86#define ADP8870_BL_CUR_mA(I) ((I * 127) / 30)
87
88/*
89 * L2 comparator current 0..1106uA
90 */
91#define ADP8870_L2_COMP_CURR_uA(I) ((I * 255) / 1106)
92
93/*
94 * L3 comparator current 0..551uA
95 */
96#define ADP8870_L3_COMP_CURR_uA(I) ((I * 255) / 551)
97
98/*
99 * L4 comparator current 0..275uA
100 */
101#define ADP8870_L4_COMP_CURR_uA(I) ((I * 255) / 275)
102
103/*
104 * L5 comparator current 0..138uA
105 */
106#define ADP8870_L5_COMP_CURR_uA(I) ((I * 255) / 138)
107
108struct adp8870_backlight_platform_data {
109 u8 bl_led_assign; /* 1 = Backlight 0 = Individual LED */
110 u8 pwm_assign; /* 1 = Enables PWM mode */
111
112 u8 bl_fade_in; /* Backlight Fade-In Timer */
113 u8 bl_fade_out; /* Backlight Fade-Out Timer */
114 u8 bl_fade_law; /* fade-on/fade-off transfer characteristic */
115
116 u8 en_ambl_sens; /* 1 = enable ambient light sensor */
117 u8 abml_filt; /* Light sensor filter time */
118
119 u8 l1_daylight_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */
120 u8 l1_daylight_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */
121 u8 l2_bright_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */
122 u8 l2_bright_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */
123 u8 l3_office_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */
124 u8 l3_office_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */
125 u8 l4_indoor_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */
126 u8 l4_indor_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */
127 u8 l5_dark_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */
128 u8 l5_dark_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */
129
130 u8 l2_trip; /* use L2_COMP_CURR_uA(I) 0 <= I <= 1106 uA */
131 u8 l2_hyst; /* use L2_COMP_CURR_uA(I) 0 <= I <= 1106 uA */
132 u8 l3_trip; /* use L3_COMP_CURR_uA(I) 0 <= I <= 551 uA */
133 u8 l3_hyst; /* use L3_COMP_CURR_uA(I) 0 <= I <= 551 uA */
134 u8 l4_trip; /* use L4_COMP_CURR_uA(I) 0 <= I <= 275 uA */
135 u8 l4_hyst; /* use L4_COMP_CURR_uA(I) 0 <= I <= 275 uA */
136 u8 l5_trip; /* use L5_COMP_CURR_uA(I) 0 <= I <= 138 uA */
137 u8 l5_hyst; /* use L6_COMP_CURR_uA(I) 0 <= I <= 138 uA */
138
139 /**
140 * Independent Current Sinks / LEDS
141 * Sinks not assigned to the Backlight can be exposed to
142 * user space using the LEDS CLASS interface
143 */
144
145 int num_leds;
146 struct led_info *leds;
147 u8 led_fade_in; /* LED Fade-In Timer */
148 u8 led_fade_out; /* LED Fade-Out Timer */
149 u8 led_fade_law; /* fade-on/fade-off transfer characteristic */
150 u8 led_on_time;
151};
152
153#endif /* __LINUX_I2C_ADP8870_H */
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index fb0e7329fee1..953352a88336 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -671,8 +671,8 @@ struct sysinfo {
671 671
672#ifdef __CHECKER__ 672#ifdef __CHECKER__
673#define BUILD_BUG_ON_NOT_POWER_OF_2(n) 673#define BUILD_BUG_ON_NOT_POWER_OF_2(n)
674#define BUILD_BUG_ON_ZERO(e) 674#define BUILD_BUG_ON_ZERO(e) (0)
675#define BUILD_BUG_ON_NULL(e) 675#define BUILD_BUG_ON_NULL(e) ((void*)0)
676#define BUILD_BUG_ON(condition) 676#define BUILD_BUG_ON(condition)
677#else /* __CHECKER__ */ 677#else /* __CHECKER__ */
678 678
diff --git a/include/linux/kmod.h b/include/linux/kmod.h
index d4a5c84c503d..0da38cf7db7b 100644
--- a/include/linux/kmod.h
+++ b/include/linux/kmod.h
@@ -45,7 +45,7 @@ static inline int request_module_nowait(const char *name, ...) { return -ENOSYS;
45#endif 45#endif
46 46
47 47
48struct key; 48struct cred;
49struct file; 49struct file;
50 50
51enum umh_wait { 51enum umh_wait {
@@ -62,7 +62,7 @@ struct subprocess_info {
62 char **envp; 62 char **envp;
63 enum umh_wait wait; 63 enum umh_wait wait;
64 int retval; 64 int retval;
65 int (*init)(struct subprocess_info *info); 65 int (*init)(struct subprocess_info *info, struct cred *new);
66 void (*cleanup)(struct subprocess_info *info); 66 void (*cleanup)(struct subprocess_info *info);
67 void *data; 67 void *data;
68}; 68};
@@ -73,7 +73,7 @@ struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
73 73
74/* Set various pieces of state into the subprocess_info structure */ 74/* Set various pieces of state into the subprocess_info structure */
75void call_usermodehelper_setfns(struct subprocess_info *info, 75void call_usermodehelper_setfns(struct subprocess_info *info,
76 int (*init)(struct subprocess_info *info), 76 int (*init)(struct subprocess_info *info, struct cred *new),
77 void (*cleanup)(struct subprocess_info *info), 77 void (*cleanup)(struct subprocess_info *info),
78 void *data); 78 void *data);
79 79
@@ -87,7 +87,7 @@ void call_usermodehelper_freeinfo(struct subprocess_info *info);
87static inline int 87static inline int
88call_usermodehelper_fns(char *path, char **argv, char **envp, 88call_usermodehelper_fns(char *path, char **argv, char **envp,
89 enum umh_wait wait, 89 enum umh_wait wait,
90 int (*init)(struct subprocess_info *info), 90 int (*init)(struct subprocess_info *info, struct cred *new),
91 void (*cleanup)(struct subprocess_info *), void *data) 91 void (*cleanup)(struct subprocess_info *), void *data)
92{ 92{
93 struct subprocess_info *info; 93 struct subprocess_info *info;
diff --git a/include/linux/kmsg_dump.h b/include/linux/kmsg_dump.h
index 2a0d7d651dc3..ee0c952188de 100644
--- a/include/linux/kmsg_dump.h
+++ b/include/linux/kmsg_dump.h
@@ -12,6 +12,7 @@
12#ifndef _LINUX_KMSG_DUMP_H 12#ifndef _LINUX_KMSG_DUMP_H
13#define _LINUX_KMSG_DUMP_H 13#define _LINUX_KMSG_DUMP_H
14 14
15#include <linux/errno.h>
15#include <linux/list.h> 16#include <linux/list.h>
16 17
17enum kmsg_dump_reason { 18enum kmsg_dump_reason {
diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
index 82cb5bf461fb..f66b065a8b5f 100644
--- a/include/linux/kobject_ns.h
+++ b/include/linux/kobject_ns.h
@@ -32,15 +32,17 @@ enum kobj_ns_type {
32 32
33/* 33/*
34 * Callbacks so sysfs can determine namespaces 34 * Callbacks so sysfs can determine namespaces
35 * @current_ns: return calling task's namespace 35 * @grab_current_ns: return a new reference to calling task's namespace
36 * @netlink_ns: return namespace to which a sock belongs (right?) 36 * @netlink_ns: return namespace to which a sock belongs (right?)
37 * @initial_ns: return the initial namespace (i.e. init_net_ns) 37 * @initial_ns: return the initial namespace (i.e. init_net_ns)
38 * @drop_ns: drops a reference to namespace
38 */ 39 */
39struct kobj_ns_type_operations { 40struct kobj_ns_type_operations {
40 enum kobj_ns_type type; 41 enum kobj_ns_type type;
41 const void *(*current_ns)(void); 42 void *(*grab_current_ns)(void);
42 const void *(*netlink_ns)(struct sock *sk); 43 const void *(*netlink_ns)(struct sock *sk);
43 const void *(*initial_ns)(void); 44 const void *(*initial_ns)(void);
45 void (*drop_ns)(void *);
44}; 46};
45 47
46int kobj_ns_type_register(const struct kobj_ns_type_operations *ops); 48int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
@@ -48,9 +50,9 @@ int kobj_ns_type_registered(enum kobj_ns_type type);
48const struct kobj_ns_type_operations *kobj_child_ns_ops(struct kobject *parent); 50const struct kobj_ns_type_operations *kobj_child_ns_ops(struct kobject *parent);
49const struct kobj_ns_type_operations *kobj_ns_ops(struct kobject *kobj); 51const struct kobj_ns_type_operations *kobj_ns_ops(struct kobject *kobj);
50 52
51const void *kobj_ns_current(enum kobj_ns_type type); 53void *kobj_ns_grab_current(enum kobj_ns_type type);
52const void *kobj_ns_netlink(enum kobj_ns_type type, struct sock *sk); 54const void *kobj_ns_netlink(enum kobj_ns_type type, struct sock *sk);
53const void *kobj_ns_initial(enum kobj_ns_type type); 55const void *kobj_ns_initial(enum kobj_ns_type type);
54void kobj_ns_exit(enum kobj_ns_type type, const void *ns); 56void kobj_ns_drop(enum kobj_ns_type type, void *ns);
55 57
56#endif /* _LINUX_KOBJECT_NS_H */ 58#endif /* _LINUX_KOBJECT_NS_H */
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 9724a38ee69d..50940da6adf3 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -84,6 +84,7 @@ int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem);
84 84
85extern struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page); 85extern struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page);
86extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p); 86extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
87extern struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm);
87 88
88static inline 89static inline
89int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup) 90int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
@@ -246,6 +247,11 @@ static inline struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page)
246 return NULL; 247 return NULL;
247} 248}
248 249
250static inline struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
251{
252 return NULL;
253}
254
249static inline int mm_match_cgroup(struct mm_struct *mm, struct mem_cgroup *mem) 255static inline int mm_match_cgroup(struct mm_struct *mm, struct mem_cgroup *mem)
250{ 256{
251 return 1; 257 return 1;
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 384eb5fe530b..e70564647039 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -358,6 +358,7 @@ struct backing_dev_info;
358extern struct mm_struct *swap_token_mm; 358extern struct mm_struct *swap_token_mm;
359extern void grab_swap_token(struct mm_struct *); 359extern void grab_swap_token(struct mm_struct *);
360extern void __put_swap_token(struct mm_struct *); 360extern void __put_swap_token(struct mm_struct *);
361extern void disable_swap_token(struct mem_cgroup *memcg);
361 362
362static inline int has_swap_token(struct mm_struct *mm) 363static inline int has_swap_token(struct mm_struct *mm)
363{ 364{
@@ -370,11 +371,6 @@ static inline void put_swap_token(struct mm_struct *mm)
370 __put_swap_token(mm); 371 __put_swap_token(mm);
371} 372}
372 373
373static inline void disable_swap_token(void)
374{
375 put_swap_token(swap_token_mm);
376}
377
378#ifdef CONFIG_CGROUP_MEM_RES_CTLR 374#ifdef CONFIG_CGROUP_MEM_RES_CTLR
379extern void 375extern void
380mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout); 376mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout);
@@ -500,7 +496,7 @@ static inline int has_swap_token(struct mm_struct *mm)
500 return 0; 496 return 0;
501} 497}
502 498
503static inline void disable_swap_token(void) 499static inline void disable_swap_token(struct mem_cgroup *memcg)
504{ 500{
505} 501}
506 502
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index c3acda60eee0..e2696d76a599 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -177,9 +177,6 @@ struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
177struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd); 177struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd);
178void sysfs_put(struct sysfs_dirent *sd); 178void sysfs_put(struct sysfs_dirent *sd);
179 179
180/* Called to clear a ns tag when it is no longer valid */
181void sysfs_exit_ns(enum kobj_ns_type type, const void *tag);
182
183int __must_check sysfs_init(void); 180int __must_check sysfs_init(void);
184 181
185#else /* CONFIG_SYSFS */ 182#else /* CONFIG_SYSFS */
@@ -338,10 +335,6 @@ static inline void sysfs_put(struct sysfs_dirent *sd)
338{ 335{
339} 336}
340 337
341static inline void sysfs_exit_ns(int type, const void *tag)
342{
343}
344
345static inline int __must_check sysfs_init(void) 338static inline int __must_check sysfs_init(void)
346{ 339{
347 return 0; 340 return 0;
diff --git a/include/linux/topology.h b/include/linux/topology.h
index b91a40e847d2..fc839bfa7935 100644
--- a/include/linux/topology.h
+++ b/include/linux/topology.h
@@ -60,7 +60,7 @@ int arch_update_cpu_topology(void);
60 * (in whatever arch specific measurement units returned by node_distance()) 60 * (in whatever arch specific measurement units returned by node_distance())
61 * then switch on zone reclaim on boot. 61 * then switch on zone reclaim on boot.
62 */ 62 */
63#define RECLAIM_DISTANCE 20 63#define RECLAIM_DISTANCE 30
64#endif 64#endif
65#ifndef PENALTY_FOR_NODE_WITH_CPUS 65#ifndef PENALTY_FOR_NODE_WITH_CPUS
66#define PENALTY_FOR_NODE_WITH_CPUS (1) 66#define PENALTY_FOR_NODE_WITH_CPUS (1)
diff --git a/include/linux/uts.h b/include/linux/uts.h
index 73eb1ed36ec4..6ddbd86377de 100644
--- a/include/linux/uts.h
+++ b/include/linux/uts.h
@@ -9,7 +9,7 @@
9#endif 9#endif
10 10
11#ifndef UTS_NODENAME 11#ifndef UTS_NODENAME
12#define UTS_NODENAME "(none)" /* set by sethostname() */ 12#define UTS_NODENAME CONFIG_DEFAULT_HOSTNAME /* set by sethostname() */
13#endif 13#endif
14 14
15#ifndef UTS_DOMAINNAME 15#ifndef UTS_DOMAINNAME
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index 2bf9ed9ef26b..aef430d779bd 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -35,8 +35,11 @@ struct netns_ipvs;
35#define NETDEV_HASHENTRIES (1 << NETDEV_HASHBITS) 35#define NETDEV_HASHENTRIES (1 << NETDEV_HASHBITS)
36 36
37struct net { 37struct net {
38 atomic_t passive; /* To decided when the network
39 * namespace should be freed.
40 */
38 atomic_t count; /* To decided when the network 41 atomic_t count; /* To decided when the network
39 * namespace should be freed. 42 * namespace should be shut down.
40 */ 43 */
41#ifdef NETNS_REFCNT_DEBUG 44#ifdef NETNS_REFCNT_DEBUG
42 atomic_t use_count; /* To track references we 45 atomic_t use_count; /* To track references we
@@ -154,6 +157,9 @@ int net_eq(const struct net *net1, const struct net *net2)
154{ 157{
155 return net1 == net2; 158 return net1 == net2;
156} 159}
160
161extern void net_drop_ns(void *);
162
157#else 163#else
158 164
159static inline struct net *get_net(struct net *net) 165static inline struct net *get_net(struct net *net)
@@ -175,6 +181,8 @@ int net_eq(const struct net *net1, const struct net *net2)
175{ 181{
176 return 1; 182 return 1;
177} 183}
184
185#define net_drop_ns NULL
178#endif 186#endif
179 187
180 188
diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h
index ea422aaa23e1..b2c33bd955fa 100644
--- a/include/trace/events/vmscan.h
+++ b/include/trace/events/vmscan.h
@@ -6,6 +6,8 @@
6 6
7#include <linux/types.h> 7#include <linux/types.h>
8#include <linux/tracepoint.h> 8#include <linux/tracepoint.h>
9#include <linux/mm.h>
10#include <linux/memcontrol.h>
9#include "gfpflags.h" 11#include "gfpflags.h"
10 12
11#define RECLAIM_WB_ANON 0x0001u 13#define RECLAIM_WB_ANON 0x0001u
@@ -310,6 +312,87 @@ TRACE_EVENT(mm_vmscan_lru_shrink_inactive,
310 show_reclaim_flags(__entry->reclaim_flags)) 312 show_reclaim_flags(__entry->reclaim_flags))
311); 313);
312 314
315TRACE_EVENT(replace_swap_token,
316 TP_PROTO(struct mm_struct *old_mm,
317 struct mm_struct *new_mm),
318
319 TP_ARGS(old_mm, new_mm),
320
321 TP_STRUCT__entry(
322 __field(struct mm_struct*, old_mm)
323 __field(unsigned int, old_prio)
324 __field(struct mm_struct*, new_mm)
325 __field(unsigned int, new_prio)
326 ),
327
328 TP_fast_assign(
329 __entry->old_mm = old_mm;
330 __entry->old_prio = old_mm ? old_mm->token_priority : 0;
331 __entry->new_mm = new_mm;
332 __entry->new_prio = new_mm->token_priority;
333 ),
334
335 TP_printk("old_token_mm=%p old_prio=%u new_token_mm=%p new_prio=%u",
336 __entry->old_mm, __entry->old_prio,
337 __entry->new_mm, __entry->new_prio)
338);
339
340DECLARE_EVENT_CLASS(put_swap_token_template,
341 TP_PROTO(struct mm_struct *swap_token_mm),
342
343 TP_ARGS(swap_token_mm),
344
345 TP_STRUCT__entry(
346 __field(struct mm_struct*, swap_token_mm)
347 ),
348
349 TP_fast_assign(
350 __entry->swap_token_mm = swap_token_mm;
351 ),
352
353 TP_printk("token_mm=%p", __entry->swap_token_mm)
354);
355
356DEFINE_EVENT(put_swap_token_template, put_swap_token,
357 TP_PROTO(struct mm_struct *swap_token_mm),
358 TP_ARGS(swap_token_mm)
359);
360
361DEFINE_EVENT_CONDITION(put_swap_token_template, disable_swap_token,
362 TP_PROTO(struct mm_struct *swap_token_mm),
363 TP_ARGS(swap_token_mm),
364 TP_CONDITION(swap_token_mm != NULL)
365);
366
367TRACE_EVENT_CONDITION(update_swap_token_priority,
368 TP_PROTO(struct mm_struct *mm,
369 unsigned int old_prio,
370 struct mm_struct *swap_token_mm),
371
372 TP_ARGS(mm, old_prio, swap_token_mm),
373
374 TP_CONDITION(mm->token_priority != old_prio),
375
376 TP_STRUCT__entry(
377 __field(struct mm_struct*, mm)
378 __field(unsigned int, old_prio)
379 __field(unsigned int, new_prio)
380 __field(struct mm_struct*, swap_token_mm)
381 __field(unsigned int, swap_token_prio)
382 ),
383
384 TP_fast_assign(
385 __entry->mm = mm;
386 __entry->old_prio = old_prio;
387 __entry->new_prio = mm->token_priority;
388 __entry->swap_token_mm = swap_token_mm;
389 __entry->swap_token_prio = swap_token_mm ? swap_token_mm->token_priority : 0;
390 ),
391
392 TP_printk("mm=%p old_prio=%u new_prio=%u swap_token_mm=%p token_prio=%u",
393 __entry->mm, __entry->old_prio, __entry->new_prio,
394 __entry->swap_token_mm, __entry->swap_token_prio)
395);
313 396
314#endif /* _TRACE_VMSCAN_H */ 397#endif /* _TRACE_VMSCAN_H */
315 398
diff --git a/init/Kconfig b/init/Kconfig
index ebafac4231ee..412c21b00d51 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -19,7 +19,6 @@ config DEFCONFIG_LIST
19config CONSTRUCTORS 19config CONSTRUCTORS
20 bool 20 bool
21 depends on !UML 21 depends on !UML
22 default y
23 22
24config HAVE_IRQ_WORK 23config HAVE_IRQ_WORK
25 bool 24 bool
@@ -204,6 +203,15 @@ config KERNEL_LZO
204 203
205endchoice 204endchoice
206 205
206config DEFAULT_HOSTNAME
207 string "Default hostname"
208 default "(none)"
209 help
210 This option determines the default system hostname before userspace
211 calls sethostname(2). The kernel traditionally uses "(none)" here,
212 but you may wish to use a different default here to make a minimal
213 system more usable with less configuration.
214
207config SWAP 215config SWAP
208 bool "Support for paging of anonymous memory (swap)" 216 bool "Support for paging of anonymous memory (swap)"
209 depends on MMU && BLOCK 217 depends on MMU && BLOCK
diff --git a/init/calibrate.c b/init/calibrate.c
index cfd7000c9d71..2568d22a304e 100644
--- a/init/calibrate.c
+++ b/init/calibrate.c
@@ -93,9 +93,6 @@ static unsigned long __cpuinit calibrate_delay_direct(void)
93 * If the upper limit and lower limit of the timer_rate is 93 * If the upper limit and lower limit of the timer_rate is
94 * >= 12.5% apart, redo calibration. 94 * >= 12.5% apart, redo calibration.
95 */ 95 */
96 printk(KERN_DEBUG "calibrate_delay_direct() timer_rate_max=%lu "
97 "timer_rate_min=%lu pre_start=%lu pre_end=%lu\n",
98 timer_rate_max, timer_rate_min, pre_start, pre_end);
99 if (start >= post_end) 96 if (start >= post_end)
100 printk(KERN_NOTICE "calibrate_delay_direct() ignoring " 97 printk(KERN_NOTICE "calibrate_delay_direct() ignoring "
101 "timer_rate as we had a TSC wrap around" 98 "timer_rate as we had a TSC wrap around"
diff --git a/kernel/exit.c b/kernel/exit.c
index 20a406471525..f2b321bae440 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -561,29 +561,28 @@ void exit_files(struct task_struct *tsk)
561 561
562#ifdef CONFIG_MM_OWNER 562#ifdef CONFIG_MM_OWNER
563/* 563/*
564 * Task p is exiting and it owned mm, lets find a new owner for it 564 * A task is exiting. If it owned this mm, find a new owner for the mm.
565 */ 565 */
566static inline int
567mm_need_new_owner(struct mm_struct *mm, struct task_struct *p)
568{
569 /*
570 * If there are other users of the mm and the owner (us) is exiting
571 * we need to find a new owner to take on the responsibility.
572 */
573 if (atomic_read(&mm->mm_users) <= 1)
574 return 0;
575 if (mm->owner != p)
576 return 0;
577 return 1;
578}
579
580void mm_update_next_owner(struct mm_struct *mm) 566void mm_update_next_owner(struct mm_struct *mm)
581{ 567{
582 struct task_struct *c, *g, *p = current; 568 struct task_struct *c, *g, *p = current;
583 569
584retry: 570retry:
585 if (!mm_need_new_owner(mm, p)) 571 /*
572 * If the exiting or execing task is not the owner, it's
573 * someone else's problem.
574 */
575 if (mm->owner != p)
586 return; 576 return;
577 /*
578 * The current owner is exiting/execing and there are no other
579 * candidates. Do not leave the mm pointing to a possibly
580 * freed task structure.
581 */
582 if (atomic_read(&mm->mm_users) <= 1) {
583 mm->owner = NULL;
584 return;
585 }
587 586
588 read_lock(&tasklist_lock); 587 read_lock(&tasklist_lock);
589 /* 588 /*
diff --git a/kernel/gcov/Kconfig b/kernel/gcov/Kconfig
index b8cadf70b1fb..5bf924d80b5c 100644
--- a/kernel/gcov/Kconfig
+++ b/kernel/gcov/Kconfig
@@ -2,7 +2,8 @@ menu "GCOV-based kernel profiling"
2 2
3config GCOV_KERNEL 3config GCOV_KERNEL
4 bool "Enable gcov-based kernel profiling" 4 bool "Enable gcov-based kernel profiling"
5 depends on DEBUG_FS && CONSTRUCTORS 5 depends on DEBUG_FS
6 select CONSTRUCTORS
6 default n 7 default n
7 ---help--- 8 ---help---
8 This option enables gcov-based code profiling (e.g. for code coverage 9 This option enables gcov-based code profiling (e.g. for code coverage
diff --git a/kernel/kmod.c b/kernel/kmod.c
index ad6a81c58b44..47613dfb7b28 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -156,12 +156,6 @@ static int ____call_usermodehelper(void *data)
156 */ 156 */
157 set_user_nice(current, 0); 157 set_user_nice(current, 0);
158 158
159 if (sub_info->init) {
160 retval = sub_info->init(sub_info);
161 if (retval)
162 goto fail;
163 }
164
165 retval = -ENOMEM; 159 retval = -ENOMEM;
166 new = prepare_kernel_cred(current); 160 new = prepare_kernel_cred(current);
167 if (!new) 161 if (!new)
@@ -173,6 +167,14 @@ static int ____call_usermodehelper(void *data)
173 new->cap_inheritable); 167 new->cap_inheritable);
174 spin_unlock(&umh_sysctl_lock); 168 spin_unlock(&umh_sysctl_lock);
175 169
170 if (sub_info->init) {
171 retval = sub_info->init(sub_info, new);
172 if (retval) {
173 abort_creds(new);
174 goto fail;
175 }
176 }
177
176 commit_creds(new); 178 commit_creds(new);
177 179
178 retval = kernel_execve(sub_info->path, 180 retval = kernel_execve(sub_info->path,
@@ -388,7 +390,7 @@ EXPORT_SYMBOL(call_usermodehelper_setup);
388 * context in which call_usermodehelper_exec is called. 390 * context in which call_usermodehelper_exec is called.
389 */ 391 */
390void call_usermodehelper_setfns(struct subprocess_info *info, 392void call_usermodehelper_setfns(struct subprocess_info *info,
391 int (*init)(struct subprocess_info *info), 393 int (*init)(struct subprocess_info *info, struct cred *new),
392 void (*cleanup)(struct subprocess_info *info), 394 void (*cleanup)(struct subprocess_info *info),
393 void *data) 395 void *data)
394{ 396{
diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c
index 88725c939e0b..10d018212bab 100644
--- a/kernel/sched_rt.c
+++ b/kernel/sched_rt.c
@@ -1096,7 +1096,7 @@ static void check_preempt_curr_rt(struct rq *rq, struct task_struct *p, int flag
1096 * to move current somewhere else, making room for our non-migratable 1096 * to move current somewhere else, making room for our non-migratable
1097 * task. 1097 * task.
1098 */ 1098 */
1099 if (p->prio == rq->curr->prio && !need_resched()) 1099 if (p->prio == rq->curr->prio && !test_tsk_need_resched(rq->curr))
1100 check_preempt_equal_prio(rq, p); 1100 check_preempt_equal_prio(rq, p);
1101#endif 1101#endif
1102} 1102}
@@ -1239,6 +1239,10 @@ static int find_lowest_rq(struct task_struct *task)
1239 int this_cpu = smp_processor_id(); 1239 int this_cpu = smp_processor_id();
1240 int cpu = task_cpu(task); 1240 int cpu = task_cpu(task);
1241 1241
1242 /* Make sure the mask is initialized first */
1243 if (unlikely(!lowest_mask))
1244 return -1;
1245
1242 if (task->rt.nr_cpus_allowed == 1) 1246 if (task->rt.nr_cpus_allowed == 1)
1243 return -1; /* No other targets possible */ 1247 return -1; /* No other targets possible */
1244 1248
diff --git a/kernel/signal.c b/kernel/signal.c
index 86c32b884f8e..ff7678603328 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2365,7 +2365,7 @@ int sigprocmask(int how, sigset_t *set, sigset_t *oldset)
2365/** 2365/**
2366 * sys_rt_sigprocmask - change the list of currently blocked signals 2366 * sys_rt_sigprocmask - change the list of currently blocked signals
2367 * @how: whether to add, remove, or set signals 2367 * @how: whether to add, remove, or set signals
2368 * @set: stores pending signals 2368 * @nset: stores pending signals
2369 * @oset: previous value of signal mask if non-null 2369 * @oset: previous value of signal mask if non-null
2370 * @sigsetsize: size of sigset_t type 2370 * @sigsetsize: size of sigset_t type
2371 */ 2371 */
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 41baf02924e6..3f3b68199d74 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -572,7 +572,7 @@ EXPORT_SYMBOL(bitmap_scnlistprintf);
572 572
573/** 573/**
574 * __bitmap_parselist - convert list format ASCII string to bitmap 574 * __bitmap_parselist - convert list format ASCII string to bitmap
575 * @bp: read nul-terminated user string from this buffer 575 * @buf: read nul-terminated user string from this buffer
576 * @buflen: buffer size in bytes. If string is smaller than this 576 * @buflen: buffer size in bytes. If string is smaller than this
577 * then it must be terminated with a \0. 577 * then it must be terminated with a \0.
578 * @is_user: location of buffer, 0 indicates kernel space 578 * @is_user: location of buffer, 0 indicates kernel space
diff --git a/lib/kobject.c b/lib/kobject.c
index 82dc34c095c2..640bd98a4c8a 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -948,14 +948,14 @@ const struct kobj_ns_type_operations *kobj_ns_ops(struct kobject *kobj)
948} 948}
949 949
950 950
951const void *kobj_ns_current(enum kobj_ns_type type) 951void *kobj_ns_grab_current(enum kobj_ns_type type)
952{ 952{
953 const void *ns = NULL; 953 void *ns = NULL;
954 954
955 spin_lock(&kobj_ns_type_lock); 955 spin_lock(&kobj_ns_type_lock);
956 if ((type > KOBJ_NS_TYPE_NONE) && (type < KOBJ_NS_TYPES) && 956 if ((type > KOBJ_NS_TYPE_NONE) && (type < KOBJ_NS_TYPES) &&
957 kobj_ns_ops_tbl[type]) 957 kobj_ns_ops_tbl[type])
958 ns = kobj_ns_ops_tbl[type]->current_ns(); 958 ns = kobj_ns_ops_tbl[type]->grab_current_ns();
959 spin_unlock(&kobj_ns_type_lock); 959 spin_unlock(&kobj_ns_type_lock);
960 960
961 return ns; 961 return ns;
@@ -987,23 +987,15 @@ const void *kobj_ns_initial(enum kobj_ns_type type)
987 return ns; 987 return ns;
988} 988}
989 989
990/* 990void kobj_ns_drop(enum kobj_ns_type type, void *ns)
991 * kobj_ns_exit - invalidate a namespace tag
992 *
993 * @type: the namespace type (i.e. KOBJ_NS_TYPE_NET)
994 * @ns: the actual namespace being invalidated
995 *
996 * This is called when a tag is no longer valid. For instance,
997 * when a network namespace exits, it uses this helper to
998 * make sure no sb's sysfs_info points to the now-invalidated
999 * netns.
1000 */
1001void kobj_ns_exit(enum kobj_ns_type type, const void *ns)
1002{ 991{
1003 sysfs_exit_ns(type, ns); 992 spin_lock(&kobj_ns_type_lock);
993 if ((type > KOBJ_NS_TYPE_NONE) && (type < KOBJ_NS_TYPES) &&
994 kobj_ns_ops_tbl[type] && kobj_ns_ops_tbl[type]->drop_ns)
995 kobj_ns_ops_tbl[type]->drop_ns(ns);
996 spin_unlock(&kobj_ns_type_lock);
1004} 997}
1005 998
1006
1007EXPORT_SYMBOL(kobject_get); 999EXPORT_SYMBOL(kobject_get);
1008EXPORT_SYMBOL(kobject_put); 1000EXPORT_SYMBOL(kobject_put);
1009EXPORT_SYMBOL(kobject_del); 1001EXPORT_SYMBOL(kobject_del);
diff --git a/mm/compaction.c b/mm/compaction.c
index 021a2960ef9e..6cc604bd5649 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -144,9 +144,20 @@ static void isolate_freepages(struct zone *zone,
144 int nr_freepages = cc->nr_freepages; 144 int nr_freepages = cc->nr_freepages;
145 struct list_head *freelist = &cc->freepages; 145 struct list_head *freelist = &cc->freepages;
146 146
147 /*
148 * Initialise the free scanner. The starting point is where we last
149 * scanned from (or the end of the zone if starting). The low point
150 * is the end of the pageblock the migration scanner is using.
151 */
147 pfn = cc->free_pfn; 152 pfn = cc->free_pfn;
148 low_pfn = cc->migrate_pfn + pageblock_nr_pages; 153 low_pfn = cc->migrate_pfn + pageblock_nr_pages;
149 high_pfn = low_pfn; 154
155 /*
156 * Take care that if the migration scanner is at the end of the zone
157 * that the free scanner does not accidentally move to the next zone
158 * in the next isolation cycle.
159 */
160 high_pfn = min(low_pfn, pfn);
150 161
151 /* 162 /*
152 * Isolate free pages until enough are available to migrate the 163 * Isolate free pages until enough are available to migrate the
@@ -240,11 +251,18 @@ static bool too_many_isolated(struct zone *zone)
240 return isolated > (inactive + active) / 2; 251 return isolated > (inactive + active) / 2;
241} 252}
242 253
254/* possible outcome of isolate_migratepages */
255typedef enum {
256 ISOLATE_ABORT, /* Abort compaction now */
257 ISOLATE_NONE, /* No pages isolated, continue scanning */
258 ISOLATE_SUCCESS, /* Pages isolated, migrate */
259} isolate_migrate_t;
260
243/* 261/*
244 * Isolate all pages that can be migrated from the block pointed to by 262 * Isolate all pages that can be migrated from the block pointed to by
245 * the migrate scanner within compact_control. 263 * the migrate scanner within compact_control.
246 */ 264 */
247static unsigned long isolate_migratepages(struct zone *zone, 265static isolate_migrate_t isolate_migratepages(struct zone *zone,
248 struct compact_control *cc) 266 struct compact_control *cc)
249{ 267{
250 unsigned long low_pfn, end_pfn; 268 unsigned long low_pfn, end_pfn;
@@ -261,7 +279,7 @@ static unsigned long isolate_migratepages(struct zone *zone,
261 /* Do not cross the free scanner or scan within a memory hole */ 279 /* Do not cross the free scanner or scan within a memory hole */
262 if (end_pfn > cc->free_pfn || !pfn_valid(low_pfn)) { 280 if (end_pfn > cc->free_pfn || !pfn_valid(low_pfn)) {
263 cc->migrate_pfn = end_pfn; 281 cc->migrate_pfn = end_pfn;
264 return 0; 282 return ISOLATE_NONE;
265 } 283 }
266 284
267 /* 285 /*
@@ -270,10 +288,14 @@ static unsigned long isolate_migratepages(struct zone *zone,
270 * delay for some time until fewer pages are isolated 288 * delay for some time until fewer pages are isolated
271 */ 289 */
272 while (unlikely(too_many_isolated(zone))) { 290 while (unlikely(too_many_isolated(zone))) {
291 /* async migration should just abort */
292 if (!cc->sync)
293 return ISOLATE_ABORT;
294
273 congestion_wait(BLK_RW_ASYNC, HZ/10); 295 congestion_wait(BLK_RW_ASYNC, HZ/10);
274 296
275 if (fatal_signal_pending(current)) 297 if (fatal_signal_pending(current))
276 return 0; 298 return ISOLATE_ABORT;
277 } 299 }
278 300
279 /* Time to isolate some pages for migration */ 301 /* Time to isolate some pages for migration */
@@ -358,7 +380,7 @@ static unsigned long isolate_migratepages(struct zone *zone,
358 380
359 trace_mm_compaction_isolate_migratepages(nr_scanned, nr_isolated); 381 trace_mm_compaction_isolate_migratepages(nr_scanned, nr_isolated);
360 382
361 return cc->nr_migratepages; 383 return ISOLATE_SUCCESS;
362} 384}
363 385
364/* 386/*
@@ -420,13 +442,6 @@ static int compact_finished(struct zone *zone,
420 if (cc->free_pfn <= cc->migrate_pfn) 442 if (cc->free_pfn <= cc->migrate_pfn)
421 return COMPACT_COMPLETE; 443 return COMPACT_COMPLETE;
422 444
423 /* Compaction run is not finished if the watermark is not met */
424 watermark = low_wmark_pages(zone);
425 watermark += (1 << cc->order);
426
427 if (!zone_watermark_ok(zone, cc->order, watermark, 0, 0))
428 return COMPACT_CONTINUE;
429
430 /* 445 /*
431 * order == -1 is expected when compacting via 446 * order == -1 is expected when compacting via
432 * /proc/sys/vm/compact_memory 447 * /proc/sys/vm/compact_memory
@@ -434,6 +449,13 @@ static int compact_finished(struct zone *zone,
434 if (cc->order == -1) 449 if (cc->order == -1)
435 return COMPACT_CONTINUE; 450 return COMPACT_CONTINUE;
436 451
452 /* Compaction run is not finished if the watermark is not met */
453 watermark = low_wmark_pages(zone);
454 watermark += (1 << cc->order);
455
456 if (!zone_watermark_ok(zone, cc->order, watermark, 0, 0))
457 return COMPACT_CONTINUE;
458
437 /* Direct compactor: Is a suitable page free? */ 459 /* Direct compactor: Is a suitable page free? */
438 for (order = cc->order; order < MAX_ORDER; order++) { 460 for (order = cc->order; order < MAX_ORDER; order++) {
439 /* Job done if page is free of the right migratetype */ 461 /* Job done if page is free of the right migratetype */
@@ -461,6 +483,13 @@ unsigned long compaction_suitable(struct zone *zone, int order)
461 unsigned long watermark; 483 unsigned long watermark;
462 484
463 /* 485 /*
486 * order == -1 is expected when compacting via
487 * /proc/sys/vm/compact_memory
488 */
489 if (order == -1)
490 return COMPACT_CONTINUE;
491
492 /*
464 * Watermarks for order-0 must be met for compaction. Note the 2UL. 493 * Watermarks for order-0 must be met for compaction. Note the 2UL.
465 * This is because during migration, copies of pages need to be 494 * This is because during migration, copies of pages need to be
466 * allocated and for a short time, the footprint is higher 495 * allocated and for a short time, the footprint is higher
@@ -470,17 +499,11 @@ unsigned long compaction_suitable(struct zone *zone, int order)
470 return COMPACT_SKIPPED; 499 return COMPACT_SKIPPED;
471 500
472 /* 501 /*
473 * order == -1 is expected when compacting via
474 * /proc/sys/vm/compact_memory
475 */
476 if (order == -1)
477 return COMPACT_CONTINUE;
478
479 /*
480 * fragmentation index determines if allocation failures are due to 502 * fragmentation index determines if allocation failures are due to
481 * low memory or external fragmentation 503 * low memory or external fragmentation
482 * 504 *
483 * index of -1 implies allocations might succeed dependingon watermarks 505 * index of -1000 implies allocations might succeed depending on
506 * watermarks
484 * index towards 0 implies failure is due to lack of memory 507 * index towards 0 implies failure is due to lack of memory
485 * index towards 1000 implies failure is due to fragmentation 508 * index towards 1000 implies failure is due to fragmentation
486 * 509 *
@@ -490,7 +513,8 @@ unsigned long compaction_suitable(struct zone *zone, int order)
490 if (fragindex >= 0 && fragindex <= sysctl_extfrag_threshold) 513 if (fragindex >= 0 && fragindex <= sysctl_extfrag_threshold)
491 return COMPACT_SKIPPED; 514 return COMPACT_SKIPPED;
492 515
493 if (fragindex == -1 && zone_watermark_ok(zone, order, watermark, 0, 0)) 516 if (fragindex == -1000 && zone_watermark_ok(zone, order, watermark,
517 0, 0))
494 return COMPACT_PARTIAL; 518 return COMPACT_PARTIAL;
495 519
496 return COMPACT_CONTINUE; 520 return COMPACT_CONTINUE;
@@ -522,8 +546,15 @@ static int compact_zone(struct zone *zone, struct compact_control *cc)
522 unsigned long nr_migrate, nr_remaining; 546 unsigned long nr_migrate, nr_remaining;
523 int err; 547 int err;
524 548
525 if (!isolate_migratepages(zone, cc)) 549 switch (isolate_migratepages(zone, cc)) {
550 case ISOLATE_ABORT:
551 ret = COMPACT_PARTIAL;
552 goto out;
553 case ISOLATE_NONE:
526 continue; 554 continue;
555 case ISOLATE_SUCCESS:
556 ;
557 }
527 558
528 nr_migrate = cc->nr_migratepages; 559 nr_migrate = cc->nr_migratepages;
529 err = migrate_pages(&cc->migratepages, compaction_alloc, 560 err = migrate_pages(&cc->migratepages, compaction_alloc,
@@ -547,6 +578,7 @@ static int compact_zone(struct zone *zone, struct compact_control *cc)
547 578
548 } 579 }
549 580
581out:
550 /* Release free pages and check accounting */ 582 /* Release free pages and check accounting */
551 cc->nr_freepages -= release_freepages(&cc->freepages); 583 cc->nr_freepages -= release_freepages(&cc->freepages);
552 VM_BUG_ON(cc->nr_freepages != 0); 584 VM_BUG_ON(cc->nr_freepages != 0);
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 615d9743a3cb..81532f297fd2 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2234,11 +2234,8 @@ static void khugepaged_loop(void)
2234 while (likely(khugepaged_enabled())) { 2234 while (likely(khugepaged_enabled())) {
2235#ifndef CONFIG_NUMA 2235#ifndef CONFIG_NUMA
2236 hpage = khugepaged_alloc_hugepage(); 2236 hpage = khugepaged_alloc_hugepage();
2237 if (unlikely(!hpage)) { 2237 if (unlikely(!hpage))
2238 count_vm_event(THP_COLLAPSE_ALLOC_FAILED);
2239 break; 2238 break;
2240 }
2241 count_vm_event(THP_COLLAPSE_ALLOC);
2242#else 2239#else
2243 if (IS_ERR(hpage)) { 2240 if (IS_ERR(hpage)) {
2244 khugepaged_alloc_sleep(); 2241 khugepaged_alloc_sleep();
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 6402458fee38..bfcf153bc829 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1111,6 +1111,14 @@ static void __init gather_bootmem_prealloc(void)
1111 WARN_ON(page_count(page) != 1); 1111 WARN_ON(page_count(page) != 1);
1112 prep_compound_huge_page(page, h->order); 1112 prep_compound_huge_page(page, h->order);
1113 prep_new_huge_page(h, page, page_to_nid(page)); 1113 prep_new_huge_page(h, page, page_to_nid(page));
1114 /*
1115 * If we had gigantic hugepages allocated at boot time, we need
1116 * to restore the 'stolen' pages to totalram_pages in order to
1117 * fix confusing memory reports from free(1) and another
1118 * side-effects, like CommitLimit going negative.
1119 */
1120 if (h->order > (MAX_ORDER - 1))
1121 totalram_pages += 1 << h->order;
1114 } 1122 }
1115} 1123}
1116 1124
diff --git a/mm/ksm.c b/mm/ksm.c
index d708b3ef2260..9a68b0cf0a1c 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -1302,6 +1302,12 @@ static struct rmap_item *scan_get_next_rmap_item(struct page **page)
1302 slot = list_entry(slot->mm_list.next, struct mm_slot, mm_list); 1302 slot = list_entry(slot->mm_list.next, struct mm_slot, mm_list);
1303 ksm_scan.mm_slot = slot; 1303 ksm_scan.mm_slot = slot;
1304 spin_unlock(&ksm_mmlist_lock); 1304 spin_unlock(&ksm_mmlist_lock);
1305 /*
1306 * Although we tested list_empty() above, a racing __ksm_exit
1307 * of the last mm on the list may have removed it since then.
1308 */
1309 if (slot == &ksm_mm_head)
1310 return NULL;
1305next_mm: 1311next_mm:
1306 ksm_scan.address = 0; 1312 ksm_scan.address = 0;
1307 ksm_scan.rmap_list = &slot->rmap_list; 1313 ksm_scan.rmap_list = &slot->rmap_list;
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index bd9052a5d3ad..cf7d027a8844 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -359,7 +359,7 @@ enum charge_type {
359static void mem_cgroup_get(struct mem_cgroup *mem); 359static void mem_cgroup_get(struct mem_cgroup *mem);
360static void mem_cgroup_put(struct mem_cgroup *mem); 360static void mem_cgroup_put(struct mem_cgroup *mem);
361static struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *mem); 361static struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *mem);
362static void drain_all_stock_async(void); 362static void drain_all_stock_async(struct mem_cgroup *mem);
363 363
364static struct mem_cgroup_per_zone * 364static struct mem_cgroup_per_zone *
365mem_cgroup_zoneinfo(struct mem_cgroup *mem, int nid, int zid) 365mem_cgroup_zoneinfo(struct mem_cgroup *mem, int nid, int zid)
@@ -735,7 +735,7 @@ struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p)
735 struct mem_cgroup, css); 735 struct mem_cgroup, css);
736} 736}
737 737
738static struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm) 738struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
739{ 739{
740 struct mem_cgroup *mem = NULL; 740 struct mem_cgroup *mem = NULL;
741 741
@@ -1663,15 +1663,21 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem,
1663 excess = res_counter_soft_limit_excess(&root_mem->res) >> PAGE_SHIFT; 1663 excess = res_counter_soft_limit_excess(&root_mem->res) >> PAGE_SHIFT;
1664 1664
1665 /* If memsw_is_minimum==1, swap-out is of-no-use. */ 1665 /* If memsw_is_minimum==1, swap-out is of-no-use. */
1666 if (root_mem->memsw_is_minimum) 1666 if (!check_soft && root_mem->memsw_is_minimum)
1667 noswap = true; 1667 noswap = true;
1668 1668
1669 while (1) { 1669 while (1) {
1670 victim = mem_cgroup_select_victim(root_mem); 1670 victim = mem_cgroup_select_victim(root_mem);
1671 if (victim == root_mem) { 1671 if (victim == root_mem) {
1672 loop++; 1672 loop++;
1673 if (loop >= 1) 1673 /*
1674 drain_all_stock_async(); 1674 * We are not draining per cpu cached charges during
1675 * soft limit reclaim because global reclaim doesn't
1676 * care about charges. It tries to free some memory and
1677 * charges will not give any.
1678 */
1679 if (!check_soft && loop >= 1)
1680 drain_all_stock_async(root_mem);
1675 if (loop >= 2) { 1681 if (loop >= 2) {
1676 /* 1682 /*
1677 * If we have not been able to reclaim 1683 * If we have not been able to reclaim
@@ -1934,9 +1940,11 @@ struct memcg_stock_pcp {
1934 struct mem_cgroup *cached; /* this never be root cgroup */ 1940 struct mem_cgroup *cached; /* this never be root cgroup */
1935 unsigned int nr_pages; 1941 unsigned int nr_pages;
1936 struct work_struct work; 1942 struct work_struct work;
1943 unsigned long flags;
1944#define FLUSHING_CACHED_CHARGE (0)
1937}; 1945};
1938static DEFINE_PER_CPU(struct memcg_stock_pcp, memcg_stock); 1946static DEFINE_PER_CPU(struct memcg_stock_pcp, memcg_stock);
1939static atomic_t memcg_drain_count; 1947static DEFINE_MUTEX(percpu_charge_mutex);
1940 1948
1941/* 1949/*
1942 * Try to consume stocked charge on this cpu. If success, one page is consumed 1950 * Try to consume stocked charge on this cpu. If success, one page is consumed
@@ -1984,6 +1992,7 @@ static void drain_local_stock(struct work_struct *dummy)
1984{ 1992{
1985 struct memcg_stock_pcp *stock = &__get_cpu_var(memcg_stock); 1993 struct memcg_stock_pcp *stock = &__get_cpu_var(memcg_stock);
1986 drain_stock(stock); 1994 drain_stock(stock);
1995 clear_bit(FLUSHING_CACHED_CHARGE, &stock->flags);
1987} 1996}
1988 1997
1989/* 1998/*
@@ -2008,26 +2017,45 @@ static void refill_stock(struct mem_cgroup *mem, unsigned int nr_pages)
2008 * expects some charges will be back to res_counter later but cannot wait for 2017 * expects some charges will be back to res_counter later but cannot wait for
2009 * it. 2018 * it.
2010 */ 2019 */
2011static void drain_all_stock_async(void) 2020static void drain_all_stock_async(struct mem_cgroup *root_mem)
2012{ 2021{
2013 int cpu; 2022 int cpu, curcpu;
2014 /* This function is for scheduling "drain" in asynchronous way. 2023 /*
2015 * The result of "drain" is not directly handled by callers. Then, 2024 * If someone calls draining, avoid adding more kworker runs.
2016 * if someone is calling drain, we don't have to call drain more.
2017 * Anyway, WORK_STRUCT_PENDING check in queue_work_on() will catch if
2018 * there is a race. We just do loose check here.
2019 */ 2025 */
2020 if (atomic_read(&memcg_drain_count)) 2026 if (!mutex_trylock(&percpu_charge_mutex))
2021 return; 2027 return;
2022 /* Notify other cpus that system-wide "drain" is running */ 2028 /* Notify other cpus that system-wide "drain" is running */
2023 atomic_inc(&memcg_drain_count);
2024 get_online_cpus(); 2029 get_online_cpus();
2030 /*
2031 * Get a hint for avoiding draining charges on the current cpu,
2032 * which must be exhausted by our charging. It is not required that
2033 * this be a precise check, so we use raw_smp_processor_id() instead of
2034 * getcpu()/putcpu().
2035 */
2036 curcpu = raw_smp_processor_id();
2025 for_each_online_cpu(cpu) { 2037 for_each_online_cpu(cpu) {
2026 struct memcg_stock_pcp *stock = &per_cpu(memcg_stock, cpu); 2038 struct memcg_stock_pcp *stock = &per_cpu(memcg_stock, cpu);
2027 schedule_work_on(cpu, &stock->work); 2039 struct mem_cgroup *mem;
2040
2041 if (cpu == curcpu)
2042 continue;
2043
2044 mem = stock->cached;
2045 if (!mem)
2046 continue;
2047 if (mem != root_mem) {
2048 if (!root_mem->use_hierarchy)
2049 continue;
2050 /* check whether "mem" is under tree of "root_mem" */
2051 if (!css_is_ancestor(&mem->css, &root_mem->css))
2052 continue;
2053 }
2054 if (!test_and_set_bit(FLUSHING_CACHED_CHARGE, &stock->flags))
2055 schedule_work_on(cpu, &stock->work);
2028 } 2056 }
2029 put_online_cpus(); 2057 put_online_cpus();
2030 atomic_dec(&memcg_drain_count); 2058 mutex_unlock(&percpu_charge_mutex);
2031 /* We don't wait for flush_work */ 2059 /* We don't wait for flush_work */
2032} 2060}
2033 2061
@@ -2035,9 +2063,9 @@ static void drain_all_stock_async(void)
2035static void drain_all_stock_sync(void) 2063static void drain_all_stock_sync(void)
2036{ 2064{
2037 /* called when force_empty is called */ 2065 /* called when force_empty is called */
2038 atomic_inc(&memcg_drain_count); 2066 mutex_lock(&percpu_charge_mutex);
2039 schedule_on_each_cpu(drain_local_stock); 2067 schedule_on_each_cpu(drain_local_stock);
2040 atomic_dec(&memcg_drain_count); 2068 mutex_unlock(&percpu_charge_mutex);
2041} 2069}
2042 2070
2043/* 2071/*
@@ -4640,6 +4668,7 @@ static struct cftype mem_cgroup_files[] = {
4640 { 4668 {
4641 .name = "numa_stat", 4669 .name = "numa_stat",
4642 .open = mem_control_numa_stat_open, 4670 .open = mem_control_numa_stat_open,
4671 .mode = S_IRUGO,
4643 }, 4672 },
4644#endif 4673#endif
4645}; 4674};
@@ -5414,18 +5443,16 @@ static void mem_cgroup_move_task(struct cgroup_subsys *ss,
5414 struct cgroup *old_cont, 5443 struct cgroup *old_cont,
5415 struct task_struct *p) 5444 struct task_struct *p)
5416{ 5445{
5417 struct mm_struct *mm; 5446 struct mm_struct *mm = get_task_mm(p);
5418 5447
5419 if (!mc.to)
5420 /* no need to move charge */
5421 return;
5422
5423 mm = get_task_mm(p);
5424 if (mm) { 5448 if (mm) {
5425 mem_cgroup_move_charge(mm); 5449 if (mc.to)
5450 mem_cgroup_move_charge(mm);
5451 put_swap_token(mm);
5426 mmput(mm); 5452 mmput(mm);
5427 } 5453 }
5428 mem_cgroup_clear_mc(); 5454 if (mc.to)
5455 mem_cgroup_clear_mc();
5429} 5456}
5430#else /* !CONFIG_MMU */ 5457#else /* !CONFIG_MMU */
5431static int mem_cgroup_can_attach(struct cgroup_subsys *ss, 5458static int mem_cgroup_can_attach(struct cgroup_subsys *ss,
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 5c8f7e08928d..eac0ba561491 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -52,6 +52,7 @@
52#include <linux/swapops.h> 52#include <linux/swapops.h>
53#include <linux/hugetlb.h> 53#include <linux/hugetlb.h>
54#include <linux/memory_hotplug.h> 54#include <linux/memory_hotplug.h>
55#include <linux/mm_inline.h>
55#include "internal.h" 56#include "internal.h"
56 57
57int sysctl_memory_failure_early_kill __read_mostly = 0; 58int sysctl_memory_failure_early_kill __read_mostly = 0;
@@ -1468,7 +1469,8 @@ int soft_offline_page(struct page *page, int flags)
1468 put_page(page); 1469 put_page(page);
1469 if (!ret) { 1470 if (!ret) {
1470 LIST_HEAD(pagelist); 1471 LIST_HEAD(pagelist);
1471 1472 inc_zone_page_state(page, NR_ISOLATED_ANON +
1473 page_is_file_cache(page));
1472 list_add(&page->lru, &pagelist); 1474 list_add(&page->lru, &pagelist);
1473 ret = migrate_pages(&pagelist, new_page, MPOL_MF_MOVE_ALL, 1475 ret = migrate_pages(&pagelist, new_page, MPOL_MF_MOVE_ALL,
1474 0, true); 1476 0, true);
diff --git a/mm/memory.c b/mm/memory.c
index 6953d3926e01..87d935333f0d 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1112,11 +1112,13 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb,
1112 int force_flush = 0; 1112 int force_flush = 0;
1113 int rss[NR_MM_COUNTERS]; 1113 int rss[NR_MM_COUNTERS];
1114 spinlock_t *ptl; 1114 spinlock_t *ptl;
1115 pte_t *start_pte;
1115 pte_t *pte; 1116 pte_t *pte;
1116 1117
1117again: 1118again:
1118 init_rss_vec(rss); 1119 init_rss_vec(rss);
1119 pte = pte_offset_map_lock(mm, pmd, addr, &ptl); 1120 start_pte = pte_offset_map_lock(mm, pmd, addr, &ptl);
1121 pte = start_pte;
1120 arch_enter_lazy_mmu_mode(); 1122 arch_enter_lazy_mmu_mode();
1121 do { 1123 do {
1122 pte_t ptent = *pte; 1124 pte_t ptent = *pte;
@@ -1196,7 +1198,7 @@ again:
1196 1198
1197 add_mm_rss_vec(mm, rss); 1199 add_mm_rss_vec(mm, rss);
1198 arch_leave_lazy_mmu_mode(); 1200 arch_leave_lazy_mmu_mode();
1199 pte_unmap_unlock(pte - 1, ptl); 1201 pte_unmap_unlock(start_pte, ptl);
1200 1202
1201 /* 1203 /*
1202 * mmu_gather ran out of room to batch pages, we break out of 1204 * mmu_gather ran out of room to batch pages, we break out of
@@ -1296,7 +1298,7 @@ static unsigned long unmap_page_range(struct mmu_gather *tlb,
1296 1298
1297/** 1299/**
1298 * unmap_vmas - unmap a range of memory covered by a list of vma's 1300 * unmap_vmas - unmap a range of memory covered by a list of vma's
1299 * @tlbp: address of the caller's struct mmu_gather 1301 * @tlb: address of the caller's struct mmu_gather
1300 * @vma: the starting vma 1302 * @vma: the starting vma
1301 * @start_addr: virtual address at which to start unmapping 1303 * @start_addr: virtual address at which to start unmapping
1302 * @end_addr: virtual address at which to end unmapping 1304 * @end_addr: virtual address at which to end unmapping
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 9f646374e32f..02159c755136 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -494,6 +494,12 @@ static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start)
494 /* init node's zones as empty zones, we don't have any present pages.*/ 494 /* init node's zones as empty zones, we don't have any present pages.*/
495 free_area_init_node(nid, zones_size, start_pfn, zholes_size); 495 free_area_init_node(nid, zones_size, start_pfn, zholes_size);
496 496
497 /*
498 * The node we allocated has no zone fallback lists. For avoiding
499 * to access not-initialized zonelist, build here.
500 */
501 build_all_zonelists(NULL);
502
497 return pgdat; 503 return pgdat;
498} 504}
499 505
diff --git a/mm/migrate.c b/mm/migrate.c
index e4a5c912983d..666e4e677414 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -288,7 +288,7 @@ static int migrate_page_move_mapping(struct address_space *mapping,
288 */ 288 */
289 __dec_zone_page_state(page, NR_FILE_PAGES); 289 __dec_zone_page_state(page, NR_FILE_PAGES);
290 __inc_zone_page_state(newpage, NR_FILE_PAGES); 290 __inc_zone_page_state(newpage, NR_FILE_PAGES);
291 if (PageSwapBacked(page)) { 291 if (!PageSwapCache(page) && PageSwapBacked(page)) {
292 __dec_zone_page_state(page, NR_SHMEM); 292 __dec_zone_page_state(page, NR_SHMEM);
293 __inc_zone_page_state(newpage, NR_SHMEM); 293 __inc_zone_page_state(newpage, NR_SHMEM);
294 } 294 }
diff --git a/mm/mmap.c b/mm/mmap.c
index bbdc9af5e117..d49736ff8a8d 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -906,14 +906,7 @@ struct anon_vma *find_mergeable_anon_vma(struct vm_area_struct *vma)
906 if (anon_vma) 906 if (anon_vma)
907 return anon_vma; 907 return anon_vma;
908try_prev: 908try_prev:
909 /* 909 near = vma->vm_prev;
910 * It is potentially slow to have to call find_vma_prev here.
911 * But it's only on the first write fault on the vma, not
912 * every time, and we could devise a way to avoid it later
913 * (e.g. stash info in next's anon_vma_node when assigning
914 * an anon_vma, or when trying vma_merge). Another time.
915 */
916 BUG_ON(find_vma_prev(vma->vm_mm, vma->vm_start, &near) != vma);
917 if (!near) 910 if (!near)
918 goto none; 911 goto none;
919 912
@@ -2044,9 +2037,10 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
2044 return -EINVAL; 2037 return -EINVAL;
2045 2038
2046 /* Find the first overlapping VMA */ 2039 /* Find the first overlapping VMA */
2047 vma = find_vma_prev(mm, start, &prev); 2040 vma = find_vma(mm, start);
2048 if (!vma) 2041 if (!vma)
2049 return 0; 2042 return 0;
2043 prev = vma->vm_prev;
2050 /* we have start < vma->vm_end */ 2044 /* we have start < vma->vm_end */
2051 2045
2052 /* if it doesn't overlap, we have nothing.. */ 2046 /* if it doesn't overlap, we have nothing.. */
diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c
index 74ccff61d1be..53bffc6c293e 100644
--- a/mm/page_cgroup.c
+++ b/mm/page_cgroup.c
@@ -162,13 +162,13 @@ static void free_page_cgroup(void *addr)
162} 162}
163#endif 163#endif
164 164
165static int __meminit init_section_page_cgroup(unsigned long pfn) 165static int __meminit init_section_page_cgroup(unsigned long pfn, int nid)
166{ 166{
167 struct page_cgroup *base, *pc; 167 struct page_cgroup *base, *pc;
168 struct mem_section *section; 168 struct mem_section *section;
169 unsigned long table_size; 169 unsigned long table_size;
170 unsigned long nr; 170 unsigned long nr;
171 int nid, index; 171 int index;
172 172
173 nr = pfn_to_section_nr(pfn); 173 nr = pfn_to_section_nr(pfn);
174 section = __nr_to_section(nr); 174 section = __nr_to_section(nr);
@@ -176,7 +176,6 @@ static int __meminit init_section_page_cgroup(unsigned long pfn)
176 if (section->page_cgroup) 176 if (section->page_cgroup)
177 return 0; 177 return 0;
178 178
179 nid = page_to_nid(pfn_to_page(pfn));
180 table_size = sizeof(struct page_cgroup) * PAGES_PER_SECTION; 179 table_size = sizeof(struct page_cgroup) * PAGES_PER_SECTION;
181 base = alloc_page_cgroup(table_size, nid); 180 base = alloc_page_cgroup(table_size, nid);
182 181
@@ -196,7 +195,11 @@ static int __meminit init_section_page_cgroup(unsigned long pfn)
196 pc = base + index; 195 pc = base + index;
197 init_page_cgroup(pc, nr); 196 init_page_cgroup(pc, nr);
198 } 197 }
199 198 /*
199 * The passed "pfn" may not be aligned to SECTION. For the calculation
200 * we need to apply a mask.
201 */
202 pfn &= PAGE_SECTION_MASK;
200 section->page_cgroup = base - pfn; 203 section->page_cgroup = base - pfn;
201 total_usage += table_size; 204 total_usage += table_size;
202 return 0; 205 return 0;
@@ -225,10 +228,20 @@ int __meminit online_page_cgroup(unsigned long start_pfn,
225 start = start_pfn & ~(PAGES_PER_SECTION - 1); 228 start = start_pfn & ~(PAGES_PER_SECTION - 1);
226 end = ALIGN(start_pfn + nr_pages, PAGES_PER_SECTION); 229 end = ALIGN(start_pfn + nr_pages, PAGES_PER_SECTION);
227 230
231 if (nid == -1) {
232 /*
233 * In this case, "nid" already exists and contains valid memory.
234 * "start_pfn" passed to us is a pfn which is an arg for
235 * online__pages(), and start_pfn should exist.
236 */
237 nid = pfn_to_nid(start_pfn);
238 VM_BUG_ON(!node_state(nid, N_ONLINE));
239 }
240
228 for (pfn = start; !fail && pfn < end; pfn += PAGES_PER_SECTION) { 241 for (pfn = start; !fail && pfn < end; pfn += PAGES_PER_SECTION) {
229 if (!pfn_present(pfn)) 242 if (!pfn_present(pfn))
230 continue; 243 continue;
231 fail = init_section_page_cgroup(pfn); 244 fail = init_section_page_cgroup(pfn, nid);
232 } 245 }
233 if (!fail) 246 if (!fail)
234 return 0; 247 return 0;
@@ -284,25 +297,47 @@ static int __meminit page_cgroup_callback(struct notifier_block *self,
284void __init page_cgroup_init(void) 297void __init page_cgroup_init(void)
285{ 298{
286 unsigned long pfn; 299 unsigned long pfn;
287 int fail = 0; 300 int nid;
288 301
289 if (mem_cgroup_disabled()) 302 if (mem_cgroup_disabled())
290 return; 303 return;
291 304
292 for (pfn = 0; !fail && pfn < max_pfn; pfn += PAGES_PER_SECTION) { 305 for_each_node_state(nid, N_HIGH_MEMORY) {
293 if (!pfn_present(pfn)) 306 unsigned long start_pfn, end_pfn;
294 continue; 307
295 fail = init_section_page_cgroup(pfn); 308 start_pfn = node_start_pfn(nid);
296 } 309 end_pfn = node_end_pfn(nid);
297 if (fail) { 310 /*
298 printk(KERN_CRIT "try 'cgroup_disable=memory' boot option\n"); 311 * start_pfn and end_pfn may not be aligned to SECTION and the
299 panic("Out of memory"); 312 * page->flags of out of node pages are not initialized. So we
300 } else { 313 * scan [start_pfn, the biggest section's pfn < end_pfn) here.
301 hotplug_memory_notifier(page_cgroup_callback, 0); 314 */
315 for (pfn = start_pfn;
316 pfn < end_pfn;
317 pfn = ALIGN(pfn + 1, PAGES_PER_SECTION)) {
318
319 if (!pfn_valid(pfn))
320 continue;
321 /*
322 * Nodes's pfns can be overlapping.
323 * We know some arch can have a nodes layout such as
324 * -------------pfn-------------->
325 * N0 | N1 | N2 | N0 | N1 | N2|....
326 */
327 if (pfn_to_nid(pfn) != nid)
328 continue;
329 if (init_section_page_cgroup(pfn, nid))
330 goto oom;
331 }
302 } 332 }
333 hotplug_memory_notifier(page_cgroup_callback, 0);
303 printk(KERN_INFO "allocated %ld bytes of page_cgroup\n", total_usage); 334 printk(KERN_INFO "allocated %ld bytes of page_cgroup\n", total_usage);
304 printk(KERN_INFO "please try 'cgroup_disable=memory' option if you don't" 335 printk(KERN_INFO "please try 'cgroup_disable=memory' option if you "
305 " want memory cgroups\n"); 336 "don't want memory cgroups\n");
337 return;
338oom:
339 printk(KERN_CRIT "try 'cgroup_disable=memory' boot option\n");
340 panic("Out of memory");
306} 341}
307 342
308void __meminit pgdat_page_cgroup_init(struct pglist_data *pgdat) 343void __meminit pgdat_page_cgroup_init(struct pglist_data *pgdat)
diff --git a/mm/rmap.c b/mm/rmap.c
index 0eb463ea88dd..27dfd3b82b0f 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -112,9 +112,9 @@ static inline void anon_vma_free(struct anon_vma *anon_vma)
112 kmem_cache_free(anon_vma_cachep, anon_vma); 112 kmem_cache_free(anon_vma_cachep, anon_vma);
113} 113}
114 114
115static inline struct anon_vma_chain *anon_vma_chain_alloc(void) 115static inline struct anon_vma_chain *anon_vma_chain_alloc(gfp_t gfp)
116{ 116{
117 return kmem_cache_alloc(anon_vma_chain_cachep, GFP_KERNEL); 117 return kmem_cache_alloc(anon_vma_chain_cachep, gfp);
118} 118}
119 119
120static void anon_vma_chain_free(struct anon_vma_chain *anon_vma_chain) 120static void anon_vma_chain_free(struct anon_vma_chain *anon_vma_chain)
@@ -159,7 +159,7 @@ int anon_vma_prepare(struct vm_area_struct *vma)
159 struct mm_struct *mm = vma->vm_mm; 159 struct mm_struct *mm = vma->vm_mm;
160 struct anon_vma *allocated; 160 struct anon_vma *allocated;
161 161
162 avc = anon_vma_chain_alloc(); 162 avc = anon_vma_chain_alloc(GFP_KERNEL);
163 if (!avc) 163 if (!avc)
164 goto out_enomem; 164 goto out_enomem;
165 165
@@ -200,6 +200,32 @@ int anon_vma_prepare(struct vm_area_struct *vma)
200 return -ENOMEM; 200 return -ENOMEM;
201} 201}
202 202
203/*
204 * This is a useful helper function for locking the anon_vma root as
205 * we traverse the vma->anon_vma_chain, looping over anon_vma's that
206 * have the same vma.
207 *
208 * Such anon_vma's should have the same root, so you'd expect to see
209 * just a single mutex_lock for the whole traversal.
210 */
211static inline struct anon_vma *lock_anon_vma_root(struct anon_vma *root, struct anon_vma *anon_vma)
212{
213 struct anon_vma *new_root = anon_vma->root;
214 if (new_root != root) {
215 if (WARN_ON_ONCE(root))
216 mutex_unlock(&root->mutex);
217 root = new_root;
218 mutex_lock(&root->mutex);
219 }
220 return root;
221}
222
223static inline void unlock_anon_vma_root(struct anon_vma *root)
224{
225 if (root)
226 mutex_unlock(&root->mutex);
227}
228
203static void anon_vma_chain_link(struct vm_area_struct *vma, 229static void anon_vma_chain_link(struct vm_area_struct *vma,
204 struct anon_vma_chain *avc, 230 struct anon_vma_chain *avc,
205 struct anon_vma *anon_vma) 231 struct anon_vma *anon_vma)
@@ -208,13 +234,11 @@ static void anon_vma_chain_link(struct vm_area_struct *vma,
208 avc->anon_vma = anon_vma; 234 avc->anon_vma = anon_vma;
209 list_add(&avc->same_vma, &vma->anon_vma_chain); 235 list_add(&avc->same_vma, &vma->anon_vma_chain);
210 236
211 anon_vma_lock(anon_vma);
212 /* 237 /*
213 * It's critical to add new vmas to the tail of the anon_vma, 238 * It's critical to add new vmas to the tail of the anon_vma,
214 * see comment in huge_memory.c:__split_huge_page(). 239 * see comment in huge_memory.c:__split_huge_page().
215 */ 240 */
216 list_add_tail(&avc->same_anon_vma, &anon_vma->head); 241 list_add_tail(&avc->same_anon_vma, &anon_vma->head);
217 anon_vma_unlock(anon_vma);
218} 242}
219 243
220/* 244/*
@@ -224,13 +248,24 @@ static void anon_vma_chain_link(struct vm_area_struct *vma,
224int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src) 248int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
225{ 249{
226 struct anon_vma_chain *avc, *pavc; 250 struct anon_vma_chain *avc, *pavc;
251 struct anon_vma *root = NULL;
227 252
228 list_for_each_entry_reverse(pavc, &src->anon_vma_chain, same_vma) { 253 list_for_each_entry_reverse(pavc, &src->anon_vma_chain, same_vma) {
229 avc = anon_vma_chain_alloc(); 254 struct anon_vma *anon_vma;
230 if (!avc) 255
231 goto enomem_failure; 256 avc = anon_vma_chain_alloc(GFP_NOWAIT | __GFP_NOWARN);
232 anon_vma_chain_link(dst, avc, pavc->anon_vma); 257 if (unlikely(!avc)) {
258 unlock_anon_vma_root(root);
259 root = NULL;
260 avc = anon_vma_chain_alloc(GFP_KERNEL);
261 if (!avc)
262 goto enomem_failure;
263 }
264 anon_vma = pavc->anon_vma;
265 root = lock_anon_vma_root(root, anon_vma);
266 anon_vma_chain_link(dst, avc, anon_vma);
233 } 267 }
268 unlock_anon_vma_root(root);
234 return 0; 269 return 0;
235 270
236 enomem_failure: 271 enomem_failure:
@@ -263,7 +298,7 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
263 anon_vma = anon_vma_alloc(); 298 anon_vma = anon_vma_alloc();
264 if (!anon_vma) 299 if (!anon_vma)
265 goto out_error; 300 goto out_error;
266 avc = anon_vma_chain_alloc(); 301 avc = anon_vma_chain_alloc(GFP_KERNEL);
267 if (!avc) 302 if (!avc)
268 goto out_error_free_anon_vma; 303 goto out_error_free_anon_vma;
269 304
@@ -280,7 +315,9 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
280 get_anon_vma(anon_vma->root); 315 get_anon_vma(anon_vma->root);
281 /* Mark this anon_vma as the one where our new (COWed) pages go. */ 316 /* Mark this anon_vma as the one where our new (COWed) pages go. */
282 vma->anon_vma = anon_vma; 317 vma->anon_vma = anon_vma;
318 anon_vma_lock(anon_vma);
283 anon_vma_chain_link(vma, avc, anon_vma); 319 anon_vma_chain_link(vma, avc, anon_vma);
320 anon_vma_unlock(anon_vma);
284 321
285 return 0; 322 return 0;
286 323
@@ -291,36 +328,43 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
291 return -ENOMEM; 328 return -ENOMEM;
292} 329}
293 330
294static void anon_vma_unlink(struct anon_vma_chain *anon_vma_chain)
295{
296 struct anon_vma *anon_vma = anon_vma_chain->anon_vma;
297 int empty;
298
299 /* If anon_vma_fork fails, we can get an empty anon_vma_chain. */
300 if (!anon_vma)
301 return;
302
303 anon_vma_lock(anon_vma);
304 list_del(&anon_vma_chain->same_anon_vma);
305
306 /* We must garbage collect the anon_vma if it's empty */
307 empty = list_empty(&anon_vma->head);
308 anon_vma_unlock(anon_vma);
309
310 if (empty)
311 put_anon_vma(anon_vma);
312}
313
314void unlink_anon_vmas(struct vm_area_struct *vma) 331void unlink_anon_vmas(struct vm_area_struct *vma)
315{ 332{
316 struct anon_vma_chain *avc, *next; 333 struct anon_vma_chain *avc, *next;
334 struct anon_vma *root = NULL;
317 335
318 /* 336 /*
319 * Unlink each anon_vma chained to the VMA. This list is ordered 337 * Unlink each anon_vma chained to the VMA. This list is ordered
320 * from newest to oldest, ensuring the root anon_vma gets freed last. 338 * from newest to oldest, ensuring the root anon_vma gets freed last.
321 */ 339 */
322 list_for_each_entry_safe(avc, next, &vma->anon_vma_chain, same_vma) { 340 list_for_each_entry_safe(avc, next, &vma->anon_vma_chain, same_vma) {
323 anon_vma_unlink(avc); 341 struct anon_vma *anon_vma = avc->anon_vma;
342
343 root = lock_anon_vma_root(root, anon_vma);
344 list_del(&avc->same_anon_vma);
345
346 /*
347 * Leave empty anon_vmas on the list - we'll need
348 * to free them outside the lock.
349 */
350 if (list_empty(&anon_vma->head))
351 continue;
352
353 list_del(&avc->same_vma);
354 anon_vma_chain_free(avc);
355 }
356 unlock_anon_vma_root(root);
357
358 /*
359 * Iterate the list once more, it now only contains empty and unlinked
360 * anon_vmas, destroy them. Could not do before due to __put_anon_vma()
361 * needing to acquire the anon_vma->root->mutex.
362 */
363 list_for_each_entry_safe(avc, next, &vma->anon_vma_chain, same_vma) {
364 struct anon_vma *anon_vma = avc->anon_vma;
365
366 put_anon_vma(anon_vma);
367
324 list_del(&avc->same_vma); 368 list_del(&avc->same_vma);
325 anon_vma_chain_free(avc); 369 anon_vma_chain_free(avc);
326 } 370 }
diff --git a/mm/thrash.c b/mm/thrash.c
index 2372d4ed5dd8..fabf2d0f5169 100644
--- a/mm/thrash.c
+++ b/mm/thrash.c
@@ -21,14 +21,40 @@
21#include <linux/mm.h> 21#include <linux/mm.h>
22#include <linux/sched.h> 22#include <linux/sched.h>
23#include <linux/swap.h> 23#include <linux/swap.h>
24#include <linux/memcontrol.h>
25
26#include <trace/events/vmscan.h>
27
28#define TOKEN_AGING_INTERVAL (0xFF)
24 29
25static DEFINE_SPINLOCK(swap_token_lock); 30static DEFINE_SPINLOCK(swap_token_lock);
26struct mm_struct *swap_token_mm; 31struct mm_struct *swap_token_mm;
32struct mem_cgroup *swap_token_memcg;
27static unsigned int global_faults; 33static unsigned int global_faults;
34static unsigned int last_aging;
35
36#ifdef CONFIG_CGROUP_MEM_RES_CTLR
37static struct mem_cgroup *swap_token_memcg_from_mm(struct mm_struct *mm)
38{
39 struct mem_cgroup *memcg;
40
41 memcg = try_get_mem_cgroup_from_mm(mm);
42 if (memcg)
43 css_put(mem_cgroup_css(memcg));
44
45 return memcg;
46}
47#else
48static struct mem_cgroup *swap_token_memcg_from_mm(struct mm_struct *mm)
49{
50 return NULL;
51}
52#endif
28 53
29void grab_swap_token(struct mm_struct *mm) 54void grab_swap_token(struct mm_struct *mm)
30{ 55{
31 int current_interval; 56 int current_interval;
57 unsigned int old_prio = mm->token_priority;
32 58
33 global_faults++; 59 global_faults++;
34 60
@@ -38,40 +64,81 @@ void grab_swap_token(struct mm_struct *mm)
38 return; 64 return;
39 65
40 /* First come first served */ 66 /* First come first served */
41 if (swap_token_mm == NULL) { 67 if (!swap_token_mm)
42 mm->token_priority = mm->token_priority + 2; 68 goto replace_token;
43 swap_token_mm = mm; 69
44 goto out; 70 if ((global_faults - last_aging) > TOKEN_AGING_INTERVAL) {
71 swap_token_mm->token_priority /= 2;
72 last_aging = global_faults;
45 } 73 }
46 74
47 if (mm != swap_token_mm) { 75 if (mm == swap_token_mm) {
48 if (current_interval < mm->last_interval)
49 mm->token_priority++;
50 else {
51 if (likely(mm->token_priority > 0))
52 mm->token_priority--;
53 }
54 /* Check if we deserve the token */
55 if (mm->token_priority > swap_token_mm->token_priority) {
56 mm->token_priority += 2;
57 swap_token_mm = mm;
58 }
59 } else {
60 /* Token holder came in again! */
61 mm->token_priority += 2; 76 mm->token_priority += 2;
77 goto update_priority;
78 }
79
80 if (current_interval < mm->last_interval)
81 mm->token_priority++;
82 else {
83 if (likely(mm->token_priority > 0))
84 mm->token_priority--;
62 } 85 }
63 86
87 /* Check if we deserve the token */
88 if (mm->token_priority > swap_token_mm->token_priority)
89 goto replace_token;
90
91update_priority:
92 trace_update_swap_token_priority(mm, old_prio, swap_token_mm);
93
64out: 94out:
65 mm->faultstamp = global_faults; 95 mm->faultstamp = global_faults;
66 mm->last_interval = current_interval; 96 mm->last_interval = current_interval;
67 spin_unlock(&swap_token_lock); 97 spin_unlock(&swap_token_lock);
98 return;
99
100replace_token:
101 mm->token_priority += 2;
102 trace_replace_swap_token(swap_token_mm, mm);
103 swap_token_mm = mm;
104 swap_token_memcg = swap_token_memcg_from_mm(mm);
105 last_aging = global_faults;
106 goto out;
68} 107}
69 108
70/* Called on process exit. */ 109/* Called on process exit. */
71void __put_swap_token(struct mm_struct *mm) 110void __put_swap_token(struct mm_struct *mm)
72{ 111{
73 spin_lock(&swap_token_lock); 112 spin_lock(&swap_token_lock);
74 if (likely(mm == swap_token_mm)) 113 if (likely(mm == swap_token_mm)) {
114 trace_put_swap_token(swap_token_mm);
75 swap_token_mm = NULL; 115 swap_token_mm = NULL;
116 swap_token_memcg = NULL;
117 }
76 spin_unlock(&swap_token_lock); 118 spin_unlock(&swap_token_lock);
77} 119}
120
121static bool match_memcg(struct mem_cgroup *a, struct mem_cgroup *b)
122{
123 if (!a)
124 return true;
125 if (!b)
126 return true;
127 if (a == b)
128 return true;
129 return false;
130}
131
132void disable_swap_token(struct mem_cgroup *memcg)
133{
134 /* memcg reclaim don't disable unrelated mm token. */
135 if (match_memcg(memcg, swap_token_memcg)) {
136 spin_lock(&swap_token_lock);
137 if (match_memcg(memcg, swap_token_memcg)) {
138 trace_disable_swap_token(swap_token_mm);
139 swap_token_mm = NULL;
140 swap_token_memcg = NULL;
141 }
142 spin_unlock(&swap_token_lock);
143 }
144}
diff --git a/mm/vmscan.c b/mm/vmscan.c
index faa0a088f9cc..8ff834e19c24 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1124,8 +1124,20 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan,
1124 nr_lumpy_dirty++; 1124 nr_lumpy_dirty++;
1125 scan++; 1125 scan++;
1126 } else { 1126 } else {
1127 /* the page is freed already. */ 1127 /*
1128 if (!page_count(cursor_page)) 1128 * Check if the page is freed already.
1129 *
1130 * We can't use page_count() as that
1131 * requires compound_head and we don't
1132 * have a pin on the page here. If a
1133 * page is tail, we may or may not
1134 * have isolated the head, so assume
1135 * it's not free, it'd be tricky to
1136 * track the head status without a
1137 * page pin.
1138 */
1139 if (!PageTail(cursor_page) &&
1140 !atomic_read(&cursor_page->_count))
1129 continue; 1141 continue;
1130 break; 1142 break;
1131 } 1143 }
@@ -2081,7 +2093,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
2081 for (priority = DEF_PRIORITY; priority >= 0; priority--) { 2093 for (priority = DEF_PRIORITY; priority >= 0; priority--) {
2082 sc->nr_scanned = 0; 2094 sc->nr_scanned = 0;
2083 if (!priority) 2095 if (!priority)
2084 disable_swap_token(); 2096 disable_swap_token(sc->mem_cgroup);
2085 total_scanned += shrink_zones(priority, zonelist, sc); 2097 total_scanned += shrink_zones(priority, zonelist, sc);
2086 /* 2098 /*
2087 * Don't shrink slabs when reclaiming memory from 2099 * Don't shrink slabs when reclaiming memory from
@@ -2407,7 +2419,7 @@ loop_again:
2407 2419
2408 /* The swap token gets in the way of swapout... */ 2420 /* The swap token gets in the way of swapout... */
2409 if (!priority) 2421 if (!priority)
2410 disable_swap_token(); 2422 disable_swap_token(NULL);
2411 2423
2412 all_zones_ok = 1; 2424 all_zones_ok = 1;
2413 balanced = 0; 2425 balanced = 0;
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 11b98bc2aa8f..33d2a1fba131 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -1179,9 +1179,14 @@ static void remove_queue_kobjects(struct net_device *net)
1179#endif 1179#endif
1180} 1180}
1181 1181
1182static const void *net_current_ns(void) 1182static void *net_grab_current_ns(void)
1183{ 1183{
1184 return current->nsproxy->net_ns; 1184 struct net *ns = current->nsproxy->net_ns;
1185#ifdef CONFIG_NET_NS
1186 if (ns)
1187 atomic_inc(&ns->passive);
1188#endif
1189 return ns;
1185} 1190}
1186 1191
1187static const void *net_initial_ns(void) 1192static const void *net_initial_ns(void)
@@ -1196,22 +1201,13 @@ static const void *net_netlink_ns(struct sock *sk)
1196 1201
1197struct kobj_ns_type_operations net_ns_type_operations = { 1202struct kobj_ns_type_operations net_ns_type_operations = {
1198 .type = KOBJ_NS_TYPE_NET, 1203 .type = KOBJ_NS_TYPE_NET,
1199 .current_ns = net_current_ns, 1204 .grab_current_ns = net_grab_current_ns,
1200 .netlink_ns = net_netlink_ns, 1205 .netlink_ns = net_netlink_ns,
1201 .initial_ns = net_initial_ns, 1206 .initial_ns = net_initial_ns,
1207 .drop_ns = net_drop_ns,
1202}; 1208};
1203EXPORT_SYMBOL_GPL(net_ns_type_operations); 1209EXPORT_SYMBOL_GPL(net_ns_type_operations);
1204 1210
1205static void net_kobj_ns_exit(struct net *net)
1206{
1207 kobj_ns_exit(KOBJ_NS_TYPE_NET, net);
1208}
1209
1210static struct pernet_operations kobj_net_ops = {
1211 .exit = net_kobj_ns_exit,
1212};
1213
1214
1215#ifdef CONFIG_HOTPLUG 1211#ifdef CONFIG_HOTPLUG
1216static int netdev_uevent(struct device *d, struct kobj_uevent_env *env) 1212static int netdev_uevent(struct device *d, struct kobj_uevent_env *env)
1217{ 1213{
@@ -1339,6 +1335,5 @@ EXPORT_SYMBOL(netdev_class_remove_file);
1339int netdev_kobject_init(void) 1335int netdev_kobject_init(void)
1340{ 1336{
1341 kobj_ns_type_register(&net_ns_type_operations); 1337 kobj_ns_type_register(&net_ns_type_operations);
1342 register_pernet_subsys(&kobj_net_ops);
1343 return class_register(&net_class); 1338 return class_register(&net_class);
1344} 1339}
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index e41e5110c65c..ea489db1bc23 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -128,6 +128,7 @@ static __net_init int setup_net(struct net *net)
128 LIST_HEAD(net_exit_list); 128 LIST_HEAD(net_exit_list);
129 129
130 atomic_set(&net->count, 1); 130 atomic_set(&net->count, 1);
131 atomic_set(&net->passive, 1);
131 132
132#ifdef NETNS_REFCNT_DEBUG 133#ifdef NETNS_REFCNT_DEBUG
133 atomic_set(&net->use_count, 0); 134 atomic_set(&net->use_count, 0);
@@ -210,6 +211,13 @@ static void net_free(struct net *net)
210 kmem_cache_free(net_cachep, net); 211 kmem_cache_free(net_cachep, net);
211} 212}
212 213
214void net_drop_ns(void *p)
215{
216 struct net *ns = p;
217 if (ns && atomic_dec_and_test(&ns->passive))
218 net_free(ns);
219}
220
213struct net *copy_net_ns(unsigned long flags, struct net *old_net) 221struct net *copy_net_ns(unsigned long flags, struct net *old_net)
214{ 222{
215 struct net *net; 223 struct net *net;
@@ -230,7 +238,7 @@ struct net *copy_net_ns(unsigned long flags, struct net *old_net)
230 } 238 }
231 mutex_unlock(&net_mutex); 239 mutex_unlock(&net_mutex);
232 if (rv < 0) { 240 if (rv < 0) {
233 net_free(net); 241 net_drop_ns(net);
234 return ERR_PTR(rv); 242 return ERR_PTR(rv);
235 } 243 }
236 return net; 244 return net;
@@ -286,7 +294,7 @@ static void cleanup_net(struct work_struct *work)
286 /* Finally it is safe to free my network namespace structure */ 294 /* Finally it is safe to free my network namespace structure */
287 list_for_each_entry_safe(net, tmp, &net_exit_list, exit_list) { 295 list_for_each_entry_safe(net, tmp, &net_exit_list, exit_list) {
288 list_del_init(&net->exit_list); 296 list_del_init(&net->exit_list);
289 net_free(net); 297 net_drop_ns(net);
290 } 298 }
291} 299}
292static DECLARE_WORK(net_cleanup_work, cleanup_net); 300static DECLARE_WORK(net_cleanup_work, cleanup_net);
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 8657f99bfb2b..b0aa2c680593 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1943,6 +1943,11 @@ sub process {
1943 WARN("LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged\n" . $herecurr); 1943 WARN("LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged\n" . $herecurr);
1944 } 1944 }
1945 1945
1946# check for uses of printk_ratelimit
1947 if ($line =~ /\bprintk_ratelimit\s*\(/) {
1948 WARN("Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit\n" . $herecurr);
1949 }
1950
1946# printk should use KERN_* levels. Note that follow on printk's on the 1951# printk should use KERN_* levels. Note that follow on printk's on the
1947# same line do not need a level, so we use the current block context 1952# same line do not need a level, so we use the current block context
1948# to try and find and validate the current printk. In summary the current 1953# to try and find and validate the current printk. In summary the current
diff --git a/security/keys/request_key.c b/security/keys/request_key.c
index d31862e0aa1c..8e319a416eec 100644
--- a/security/keys/request_key.c
+++ b/security/keys/request_key.c
@@ -71,9 +71,8 @@ EXPORT_SYMBOL(complete_request_key);
71 * This is called in context of freshly forked kthread before kernel_execve(), 71 * This is called in context of freshly forked kthread before kernel_execve(),
72 * so we can simply install the desired session_keyring at this point. 72 * so we can simply install the desired session_keyring at this point.
73 */ 73 */
74static int umh_keys_init(struct subprocess_info *info) 74static int umh_keys_init(struct subprocess_info *info, struct cred *cred)
75{ 75{
76 struct cred *cred = (struct cred*)current_cred();
77 struct key *keyring = info->data; 76 struct key *keyring = info->data;
78 77
79 return install_session_keyring_to_cred(cred, keyring); 78 return install_session_keyring_to_cred(cred, keyring);
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index 77d44138864f..35459340019e 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -29,6 +29,7 @@
29#include <linux/audit.h> 29#include <linux/audit.h>
30#include <linux/uaccess.h> 30#include <linux/uaccess.h>
31#include <linux/kobject.h> 31#include <linux/kobject.h>
32#include <linux/ctype.h>
32 33
33/* selinuxfs pseudo filesystem for exporting the security policy API. 34/* selinuxfs pseudo filesystem for exporting the security policy API.
34 Based on the proc code and the fs/nfsd/nfsctl.c code. */ 35 Based on the proc code and the fs/nfsd/nfsctl.c code. */
@@ -751,6 +752,14 @@ out:
751 return length; 752 return length;
752} 753}
753 754
755static inline int hexcode_to_int(int code) {
756 if (code == '\0' || !isxdigit(code))
757 return -1;
758 if (isdigit(code))
759 return code - '0';
760 return tolower(code) - 'a' + 10;
761}
762
754static ssize_t sel_write_create(struct file *file, char *buf, size_t size) 763static ssize_t sel_write_create(struct file *file, char *buf, size_t size)
755{ 764{
756 char *scon = NULL, *tcon = NULL; 765 char *scon = NULL, *tcon = NULL;
@@ -785,8 +794,34 @@ static ssize_t sel_write_create(struct file *file, char *buf, size_t size)
785 nargs = sscanf(buf, "%s %s %hu %s", scon, tcon, &tclass, namebuf); 794 nargs = sscanf(buf, "%s %s %hu %s", scon, tcon, &tclass, namebuf);
786 if (nargs < 3 || nargs > 4) 795 if (nargs < 3 || nargs > 4)
787 goto out; 796 goto out;
788 if (nargs == 4) 797 if (nargs == 4) {
798 /*
799 * If and when the name of new object to be queried contains
800 * either whitespace or multibyte characters, they shall be
801 * encoded based on the percentage-encoding rule.
802 * If not encoded, the sscanf logic picks up only left-half
803 * of the supplied name; splitted by a whitespace unexpectedly.
804 */
805 char *r, *w;
806 int c1, c2;
807
808 r = w = namebuf;
809 do {
810 c1 = *r++;
811 if (c1 == '+')
812 c1 = ' ';
813 else if (c1 == '%') {
814 if ((c1 = hexcode_to_int(*r++)) < 0)
815 goto out;
816 if ((c2 = hexcode_to_int(*r++)) < 0)
817 goto out;
818 c1 = (c1 << 4) | c2;
819 }
820 *w++ = c1;
821 } while (c1 != '\0');
822
789 objname = namebuf; 823 objname = namebuf;
824 }
790 825
791 length = security_context_to_sid(scon, strlen(scon) + 1, &ssid); 826 length = security_context_to_sid(scon, strlen(scon) + 1, &ssid);
792 if (length) 827 if (length)
diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
index 102e9ec1b77a..d246aca3f4fb 100644
--- a/security/selinux/ss/policydb.c
+++ b/security/selinux/ss/policydb.c
@@ -3222,6 +3222,9 @@ static int filename_trans_write(struct policydb *p, void *fp)
3222 __le32 buf[1]; 3222 __le32 buf[1];
3223 int rc; 3223 int rc;
3224 3224
3225 if (p->policyvers < POLICYDB_VERSION_FILENAME_TRANS)
3226 return 0;
3227
3225 nel = 0; 3228 nel = 0;
3226 rc = hashtab_map(p->filename_trans, hashtab_cnt, &nel); 3229 rc = hashtab_map(p->filename_trans, hashtab_cnt, &nel);
3227 if (rc) 3230 if (rc)
diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
index 162a864dba24..9fc2e15841c9 100644
--- a/security/tomoyo/mount.c
+++ b/security/tomoyo/mount.c
@@ -138,7 +138,7 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r, char *dev_name,
138 } 138 }
139 if (need_dev) { 139 if (need_dev) {
140 /* Get mount point or device file. */ 140 /* Get mount point or device file. */
141 if (kern_path(dev_name, LOOKUP_FOLLOW, &path)) { 141 if (!dev_name || kern_path(dev_name, LOOKUP_FOLLOW, &path)) {
142 error = -ENOENT; 142 error = -ENOENT;
143 goto out; 143 goto out;
144 } 144 }
diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
index 86ee16ca365e..440030818db7 100644
--- a/sound/firewire/isight.c
+++ b/sound/firewire/isight.c
@@ -209,6 +209,7 @@ static void isight_packet(struct fw_iso_context *context, u32 cycle,
209 isight->packet_index = -1; 209 isight->packet_index = -1;
210 return; 210 return;
211 } 211 }
212 fw_iso_context_queue_flush(isight->context);
212 213
213 if (++index >= QUEUE_LENGTH) 214 if (++index >= QUEUE_LENGTH)
214 index = 0; 215 index = 0;
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index 5e619a84da06..15f0161ce4a2 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -1440,6 +1440,14 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1440 .ca0102_chip = 1, 1440 .ca0102_chip = 1,
1441 .spk71 = 1, 1441 .spk71 = 1,
1442 .emu_model = EMU_MODEL_EMU0404}, /* EMU 0404 */ 1442 .emu_model = EMU_MODEL_EMU0404}, /* EMU 0404 */
1443 /* EMU0404 PCIe */
1444 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40051102,
1445 .driver = "Audigy2", .name = "E-mu 0404 PCIe [MAEM8984]",
1446 .id = "EMU0404",
1447 .emu10k2_chip = 1,
1448 .ca0108_chip = 1,
1449 .spk71 = 1,
1450 .emu_model = EMU_MODEL_EMU0404}, /* EMU 0404 PCIe ver_03 */
1443 /* Note that all E-mu cards require kernel 2.6 or newer. */ 1451 /* Note that all E-mu cards require kernel 2.6 or newer. */
1444 {.vendor = 0x1102, .device = 0x0008, 1452 {.vendor = 0x1102, .device = 0x0008,
1445 .driver = "Audigy2", .name = "SB Audigy 2 Value [Unknown]", 1453 .driver = "Audigy2", .name = "SB Audigy 2 Value [Unknown]",
diff --git a/sound/pci/hda/hda_beep.h b/sound/pci/hda/hda_beep.h
index f1de1bac042c..55f0647458c7 100644
--- a/sound/pci/hda/hda_beep.h
+++ b/sound/pci/hda/hda_beep.h
@@ -50,7 +50,12 @@ int snd_hda_enable_beep_device(struct hda_codec *codec, int enable);
50int snd_hda_attach_beep_device(struct hda_codec *codec, int nid); 50int snd_hda_attach_beep_device(struct hda_codec *codec, int nid);
51void snd_hda_detach_beep_device(struct hda_codec *codec); 51void snd_hda_detach_beep_device(struct hda_codec *codec);
52#else 52#else
53#define snd_hda_attach_beep_device(...) 0 53static inline int snd_hda_attach_beep_device(struct hda_codec *codec, int nid)
54#define snd_hda_detach_beep_device(...) 54{
55 return 0;
56}
57static inline void snd_hda_detach_beep_device(struct hda_codec *codec)
58{
59}
55#endif 60#endif
56#endif 61#endif
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 43fcfbd32847..61a774b3d3cb 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -13316,9 +13316,8 @@ static void alc268_acer_lc_setup(struct hda_codec *codec)
13316 struct alc_spec *spec = codec->spec; 13316 struct alc_spec *spec = codec->spec;
13317 spec->autocfg.hp_pins[0] = 0x15; 13317 spec->autocfg.hp_pins[0] = 0x15;
13318 spec->autocfg.speaker_pins[0] = 0x14; 13318 spec->autocfg.speaker_pins[0] = 0x14;
13319 spec->automute_mixer_nid[0] = 0x0f;
13320 spec->automute = 1; 13319 spec->automute = 1;
13321 spec->automute_mode = ALC_AUTOMUTE_MIXER; 13320 spec->automute_mode = ALC_AUTOMUTE_AMP;
13322 spec->ext_mic.pin = 0x18; 13321 spec->ext_mic.pin = 0x18;
13323 spec->ext_mic.mux_idx = 0; 13322 spec->ext_mic.mux_idx = 0;
13324 spec->int_mic.pin = 0x12; 13323 spec->int_mic.pin = 0x12;
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index 605c99e1e520..c952582fb218 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -832,10 +832,13 @@ static int via_hp_build(struct hda_codec *codec)
832 knew->subdevice = HDA_SUBDEV_NID_FLAG | nid; 832 knew->subdevice = HDA_SUBDEV_NID_FLAG | nid;
833 knew->private_value = nid; 833 knew->private_value = nid;
834 834
835 knew = via_clone_control(spec, &via_hp_mixer[1]); 835 nid = side_mute_channel(spec);
836 if (knew == NULL) 836 if (nid) {
837 return -ENOMEM; 837 knew = via_clone_control(spec, &via_hp_mixer[1]);
838 knew->subdevice = side_mute_channel(spec); 838 if (knew == NULL)
839 return -ENOMEM;
840 knew->subdevice = nid;
841 }
839 842
840 return 0; 843 return 0;
841} 844}
diff --git a/sound/pci/lola/lola.c b/sound/pci/lola/lola.c
index 34b24286d279..2692e5ae5f2d 100644
--- a/sound/pci/lola/lola.c
+++ b/sound/pci/lola/lola.c
@@ -445,7 +445,7 @@ static void lola_reset_setups(struct lola *chip)
445 lola_setup_all_analog_gains(chip, PLAY, false); /* output, update */ 445 lola_setup_all_analog_gains(chip, PLAY, false); /* output, update */
446} 446}
447 447
448static int lola_parse_tree(struct lola *chip) 448static int __devinit lola_parse_tree(struct lola *chip)
449{ 449{
450 unsigned int val; 450 unsigned int val;
451 int nid, err; 451 int nid, err;
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index 949691a876d3..3f08afc0f0d3 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -521,6 +521,7 @@ MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}");
521#define HDSPM_DMA_AREA_KILOBYTES (HDSPM_DMA_AREA_BYTES/1024) 521#define HDSPM_DMA_AREA_KILOBYTES (HDSPM_DMA_AREA_BYTES/1024)
522 522
523/* revisions >= 230 indicate AES32 card */ 523/* revisions >= 230 indicate AES32 card */
524#define HDSPM_MADI_OLD_REV 207
524#define HDSPM_MADI_REV 210 525#define HDSPM_MADI_REV 210
525#define HDSPM_RAYDAT_REV 211 526#define HDSPM_RAYDAT_REV 211
526#define HDSPM_AIO_REV 212 527#define HDSPM_AIO_REV 212
@@ -1143,7 +1144,7 @@ static int hdspm_external_sample_rate(struct hdspm *hdspm)
1143 1144
1144 /* if wordclock has synced freq and wordclock is valid */ 1145 /* if wordclock has synced freq and wordclock is valid */
1145 if ((status2 & HDSPM_wcLock) != 0 && 1146 if ((status2 & HDSPM_wcLock) != 0 &&
1146 (status & HDSPM_SelSyncRef0) == 0) { 1147 (status2 & HDSPM_SelSyncRef0) == 0) {
1147 1148
1148 rate_bits = status2 & HDSPM_wcFreqMask; 1149 rate_bits = status2 & HDSPM_wcFreqMask;
1149 1150
@@ -1639,12 +1640,14 @@ static int snd_hdspm_midi_input_read (struct hdspm_midi *hmidi)
1639 } 1640 }
1640 } 1641 }
1641 hmidi->pending = 0; 1642 hmidi->pending = 0;
1643 spin_unlock_irqrestore(&hmidi->lock, flags);
1642 1644
1645 spin_lock_irqsave(&hmidi->hdspm->lock, flags);
1643 hmidi->hdspm->control_register |= hmidi->ie; 1646 hmidi->hdspm->control_register |= hmidi->ie;
1644 hdspm_write(hmidi->hdspm, HDSPM_controlRegister, 1647 hdspm_write(hmidi->hdspm, HDSPM_controlRegister,
1645 hmidi->hdspm->control_register); 1648 hmidi->hdspm->control_register);
1649 spin_unlock_irqrestore(&hmidi->hdspm->lock, flags);
1646 1650
1647 spin_unlock_irqrestore (&hmidi->lock, flags);
1648 return snd_hdspm_midi_output_write (hmidi); 1651 return snd_hdspm_midi_output_write (hmidi);
1649} 1652}
1650 1653
@@ -6377,6 +6380,7 @@ static int __devinit snd_hdspm_create(struct snd_card *card,
6377 6380
6378 switch (hdspm->firmware_rev) { 6381 switch (hdspm->firmware_rev) {
6379 case HDSPM_MADI_REV: 6382 case HDSPM_MADI_REV:
6383 case HDSPM_MADI_OLD_REV:
6380 hdspm->io_type = MADI; 6384 hdspm->io_type = MADI;
6381 hdspm->card_name = "RME MADI"; 6385 hdspm->card_name = "RME MADI";
6382 hdspm->midiPorts = 3; 6386 hdspm->midiPorts = 3;
diff --git a/sound/usb/6fire/firmware.c b/sound/usb/6fire/firmware.c
index a91719d5918b..1e3ae3327dd3 100644
--- a/sound/usb/6fire/firmware.c
+++ b/sound/usb/6fire/firmware.c
@@ -270,7 +270,6 @@ static int usb6fire_fw_ezusb_upload(
270 data = 0x00; /* resume ezusb cpu */ 270 data = 0x00; /* resume ezusb cpu */
271 ret = usb6fire_fw_ezusb_write(device, 0xa0, 0xe600, &data, 1); 271 ret = usb6fire_fw_ezusb_write(device, 0xa0, 0xe600, &data, 1);
272 if (ret < 0) { 272 if (ret < 0) {
273 release_firmware(fw);
274 snd_printk(KERN_ERR PREFIX "unable to upload ezusb " 273 snd_printk(KERN_ERR PREFIX "unable to upload ezusb "
275 "firmware %s: end message.\n", fwname); 274 "firmware %s: end message.\n", fwname);
276 return ret; 275 return ret;
diff --git a/sound/usb/6fire/pcm.c b/sound/usb/6fire/pcm.c
index b137b25865cc..d144cdb2f159 100644
--- a/sound/usb/6fire/pcm.c
+++ b/sound/usb/6fire/pcm.c
@@ -395,12 +395,12 @@ static int usb6fire_pcm_open(struct snd_pcm_substream *alsa_sub)
395 alsa_rt->hw = pcm_hw; 395 alsa_rt->hw = pcm_hw;
396 396
397 if (alsa_sub->stream == SNDRV_PCM_STREAM_PLAYBACK) { 397 if (alsa_sub->stream == SNDRV_PCM_STREAM_PLAYBACK) {
398 if (rt->rate >= 0) 398 if (rt->rate < ARRAY_SIZE(rates))
399 alsa_rt->hw.rates = rates_alsaid[rt->rate]; 399 alsa_rt->hw.rates = rates_alsaid[rt->rate];
400 alsa_rt->hw.channels_max = OUT_N_CHANNELS; 400 alsa_rt->hw.channels_max = OUT_N_CHANNELS;
401 sub = &rt->playback; 401 sub = &rt->playback;
402 } else if (alsa_sub->stream == SNDRV_PCM_STREAM_CAPTURE) { 402 } else if (alsa_sub->stream == SNDRV_PCM_STREAM_CAPTURE) {
403 if (rt->rate >= 0) 403 if (rt->rate < ARRAY_SIZE(rates))
404 alsa_rt->hw.rates = rates_alsaid[rt->rate]; 404 alsa_rt->hw.rates = rates_alsaid[rt->rate];
405 alsa_rt->hw.channels_max = IN_N_CHANNELS; 405 alsa_rt->hw.channels_max = IN_N_CHANNELS;
406 sub = &rt->capture; 406 sub = &rt->capture;
diff --git a/tools/perf/util/PERF-VERSION-GEN b/tools/perf/util/PERF-VERSION-GEN
index 9c5fb4d93824..ad73300f7bac 100755
--- a/tools/perf/util/PERF-VERSION-GEN
+++ b/tools/perf/util/PERF-VERSION-GEN
@@ -23,7 +23,7 @@ if test -d ../../.git -o -f ../../.git &&
23then 23then
24 VN=$(echo "$VN" | sed -e 's/-/./g'); 24 VN=$(echo "$VN" | sed -e 's/-/./g');
25else 25else
26 VN=$(make -sC ../.. kernelversion) 26 VN=$(MAKEFLAGS= make -sC ../.. kernelversion)
27fi 27fi
28 28
29VN=$(expr "$VN" : v*'\(.*\)') 29VN=$(expr "$VN" : v*'\(.*\)')