aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/DocBook/media_api.tmpl4
-rw-r--r--Documentation/devicetree/bindings/regulator/palmas-pmic.txt4
-rw-r--r--MAINTAINERS12
-rw-r--r--arch/arm/boot/dts/msm8960-cdp.dts4
-rw-r--r--arch/arm/boot/dts/omap5-uevm.dts78
-rw-r--r--arch/arm/boot/dts/stih41x.dtsi2
-rw-r--r--arch/arm/boot/dts/tegra20-colibri-512.dtsi1
-rw-r--r--arch/arm/mach-msm/Kconfig3
-rw-r--r--arch/arm/mach-msm/gpiomux-v1.c33
-rw-r--r--arch/arm/mach-msm/gpiomux.h10
-rw-r--r--arch/arm/mach-omap2/dss-common.c2
-rw-r--r--arch/arm/mach-omap2/omap_device.c18
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c2
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.h50
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c6
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_33xx_data.c3
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_3xxx_data.c9
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_44xx_data.c5
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_54xx_data.c3
-rw-r--r--arch/arm/mach-omap2/serial.c11
-rw-r--r--arch/arm/mach-shmobile/board-armadillo800eva.c3
-rw-r--r--arch/arm/mach-shmobile/board-bockw.c8
-rw-r--r--arch/arm/mach-shmobile/board-lager.c2
-rw-r--r--arch/arm/mach-sti/headsmp.S2
-rw-r--r--arch/avr32/boards/atngw100/mrmt.c1
-rw-r--r--arch/mips/include/asm/cpu-features.h2
-rw-r--r--arch/mips/kernel/smp-bmips.c10
-rw-r--r--arch/mips/oprofile/op_model_mipsxx.c2
-rw-r--r--arch/mips/pnx833x/common/platform.c2
-rw-r--r--arch/s390/Kconfig9
-rw-r--r--arch/s390/boot/compressed/Makefile9
-rw-r--r--arch/s390/boot/compressed/misc.c4
-rw-r--r--arch/s390/include/asm/bitops.h2
-rw-r--r--arch/s390/kernel/perf_event.c9
-rw-r--r--arch/s390/kernel/setup.c1
-rw-r--r--arch/s390/mm/init.c1
-rw-r--r--arch/s390/oprofile/init.c2
-rw-r--r--arch/x86/boot/compressed/eboot.c2
-rw-r--r--arch/x86/kernel/early-quirks.c14
-rw-r--r--arch/x86/kernel/i387.c2
-rw-r--r--arch/x86/kernel/microcode_amd.c9
-rw-r--r--drivers/acpi/acpi_processor.c3
-rw-r--r--drivers/acpi/glue.c133
-rw-r--r--drivers/acpi/proc.c8
-rw-r--r--drivers/acpi/video.c2
-rw-r--r--drivers/ata/pata_imx.c1
-rw-r--r--drivers/base/regmap/regcache.c3
-rw-r--r--drivers/char/virtio_console.c70
-rw-r--r--drivers/cpufreq/cpufreq_conservative.c20
-rw-r--r--drivers/cpufreq/cpufreq_governor.c8
-rw-r--r--drivers/cpufreq/cpufreq_governor.h4
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c20
-rw-r--r--drivers/cpufreq/loongson2_cpufreq.c11
-rw-r--r--drivers/dma/sh/shdma.c4
-rw-r--r--drivers/gpu/drm/ast/ast_ttm.c1
-rw-r--r--drivers/gpu/drm/cirrus/cirrus_ttm.c1
-rw-r--r--drivers/gpu/drm/drm_irq.c5
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h12
-rw-r--r--drivers/gpu/drm/i915/intel_display.c4
-rw-r--r--drivers/gpu/drm/i915/intel_panel.c18
-rw-r--r--drivers/gpu/drm/i915/intel_pm.c18
-rw-r--r--drivers/gpu/drm/mgag200/mgag200_ttm.c1
-rw-r--r--drivers/gpu/drm/radeon/btc_dpm.c17
-rw-r--r--drivers/gpu/drm/radeon/cik.c18
-rw-r--r--drivers/gpu/drm/radeon/cypress_dpm.c17
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c6
-rw-r--r--drivers/gpu/drm/radeon/evergreen_hdmi.c26
-rw-r--r--drivers/gpu/drm/radeon/evergreend.h3
-rw-r--r--drivers/gpu/drm/radeon/ni.c16
-rw-r--r--drivers/gpu/drm/radeon/ni_dpm.c17
-rw-r--r--drivers/gpu/drm/radeon/r600.c41
-rw-r--r--drivers/gpu/drm/radeon/r600_hdmi.c37
-rw-r--r--drivers/gpu/drm/radeon/r600d.h3
-rw-r--r--drivers/gpu/drm/radeon/radeon.h4
-rw-r--r--drivers/gpu/drm/radeon/radeon_asic.h2
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c3
-rw-r--r--drivers/gpu/drm/radeon/radeon_fence.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_gart.c1
-rw-r--r--drivers/gpu/drm/radeon/radeon_pm.c9
-rw-r--r--drivers/gpu/drm/radeon/radeon_uvd.c93
-rw-r--r--drivers/gpu/drm/radeon/rv6xx_dpm.c22
-rw-r--r--drivers/gpu/drm/radeon/rv770.c7
-rw-r--r--drivers/gpu/drm/radeon/rv770_dpm.c33
-rw-r--r--drivers/gpu/drm/radeon/rv770_dpm.h1
-rw-r--r--drivers/gpu/drm/radeon/si.c19
-rw-r--r--drivers/gpu/drm/radeon/si_dpm.c61
-rw-r--r--drivers/hid/hid-logitech-dj.c2
-rw-r--r--drivers/hwmon/adt7470.c2
-rw-r--r--drivers/iio/adc/ti_am335x_adc.c30
-rw-r--r--drivers/iio/industrialio-trigger.c34
-rw-r--r--drivers/media/i2c/ml86v7667.c4
-rw-r--r--drivers/media/platform/coda.c2
-rw-r--r--drivers/media/platform/s5p-g2d/g2d.c1
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_dec.c79
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_enc.c46
-rw-r--r--drivers/media/usb/em28xx/em28xx-i2c.c2
-rw-r--r--drivers/media/usb/hdpvr/hdpvr-core.c11
-rw-r--r--drivers/media/usb/usbtv/Kconfig2
-rw-r--r--drivers/media/usb/usbtv/usbtv.c51
-rw-r--r--drivers/pci/pci-acpi.c15
-rw-r--r--drivers/s390/block/dasd.c6
-rw-r--r--drivers/scsi/virtio_scsi.c2
-rw-r--r--drivers/spi/spi-davinci.c2
-rw-r--r--drivers/staging/zcache/zcache-main.c6
-rw-r--r--drivers/usb/core/hub.c5
-rw-r--r--drivers/usb/host/xhci-mem.c1
-rw-r--r--drivers/usb/host/xhci.c1
-rw-r--r--drivers/video/mxsfb.c26
-rw-r--r--drivers/video/omap2/displays-new/connector-analog-tv.c18
-rw-r--r--fs/debugfs/inode.c69
-rw-r--r--fs/dlm/user.c1
-rw-r--r--fs/ext4/extents.c2
-rw-r--r--fs/ext4/ialloc.c10
-rw-r--r--fs/ext4/inode.c39
-rw-r--r--fs/ext4/super.c1
-rw-r--r--fs/fcntl.c4
-rw-r--r--fs/namei.c10
-rw-r--r--fs/nfsd/nfs4proc.c2
-rw-r--r--fs/nfsd/nfs4state.c2
-rw-r--r--fs/nfsd/nfs4xdr.c5
-rw-r--r--fs/open.c2
-rw-r--r--fs/reiserfs/procfs.c99
-rw-r--r--fs/reiserfs/super.c3
-rw-r--r--include/acpi/acpi_bus.h14
-rw-r--r--include/linux/ftrace_event.h12
-rw-r--r--include/linux/iio/trigger.h3
-rw-r--r--include/linux/kernel.h2
-rw-r--r--include/linux/mfd/ti_am335x_tscadc.h16
-rw-r--r--include/linux/regmap.h1
-rw-r--r--include/linux/user_namespace.h1
-rw-r--r--include/media/v4l2-ctrls.h1
-rw-r--r--kernel/cgroup.c4
-rw-r--r--kernel/printk/braille.c3
-rw-r--r--kernel/ptrace.c1
-rw-r--r--kernel/trace/ftrace.c87
-rw-r--r--kernel/trace/trace.c27
-rw-r--r--kernel/trace/trace_events.c200
-rw-r--r--kernel/trace/trace_events_filter.c17
-rw-r--r--kernel/trace/trace_kprobe.c21
-rw-r--r--kernel/trace/trace_uprobe.c51
-rw-r--r--kernel/user_namespace.c17
-rw-r--r--kernel/workqueue.c44
-rw-r--r--mm/slub.c3
-rw-r--r--security/smack/smack_lsm.c24
-rw-r--r--sound/usb/6fire/comm.c38
-rw-r--r--sound/usb/6fire/comm.h2
-rw-r--r--sound/usb/endpoint.c13
147 files changed, 1444 insertions, 916 deletions
diff --git a/Documentation/DocBook/media_api.tmpl b/Documentation/DocBook/media_api.tmpl
index 6a8b7158697f..9c92bb879b6d 100644
--- a/Documentation/DocBook/media_api.tmpl
+++ b/Documentation/DocBook/media_api.tmpl
@@ -1,6 +1,6 @@
1<?xml version="1.0"?> 1<?xml version="1.0"?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" 2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [ 3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
4<!ENTITY % media-entities SYSTEM "./media-entities.tmpl"> %media-entities; 4<!ENTITY % media-entities SYSTEM "./media-entities.tmpl"> %media-entities;
5<!ENTITY media-indices SYSTEM "./media-indices.tmpl"> 5<!ENTITY media-indices SYSTEM "./media-indices.tmpl">
6 6
diff --git a/Documentation/devicetree/bindings/regulator/palmas-pmic.txt b/Documentation/devicetree/bindings/regulator/palmas-pmic.txt
index d5a308629c57..30b0581bb1ce 100644
--- a/Documentation/devicetree/bindings/regulator/palmas-pmic.txt
+++ b/Documentation/devicetree/bindings/regulator/palmas-pmic.txt
@@ -31,9 +31,8 @@ Optional nodes:
31 Optional sub-node properties: 31 Optional sub-node properties:
32 ti,warm-reset - maintain voltage during warm reset(boolean) 32 ti,warm-reset - maintain voltage during warm reset(boolean)
33 ti,roof-floor - control voltage selection by pin(boolean) 33 ti,roof-floor - control voltage selection by pin(boolean)
34 ti,sleep-mode - mode to adopt in pmic sleep 0 - off, 1 - auto, 34 ti,mode-sleep - mode to adopt in pmic sleep 0 - off, 1 - auto,
35 2 - eco, 3 - forced pwm 35 2 - eco, 3 - forced pwm
36 ti,tstep - slope control 0 - Jump, 1 10mV/us, 2 5mV/us, 3 2.5mV/us
37 ti,smps-range - OTP has the wrong range set for the hardware so override 36 ti,smps-range - OTP has the wrong range set for the hardware so override
38 0 - low range, 1 - high range. 37 0 - low range, 1 - high range.
39 38
@@ -59,7 +58,6 @@ pmic {
59 ti,warm-reset; 58 ti,warm-reset;
60 ti,roof-floor; 59 ti,roof-floor;
61 ti,mode-sleep = <0>; 60 ti,mode-sleep = <0>;
62 ti,tstep = <0>;
63 ti,smps-range = <1>; 61 ti,smps-range = <1>;
64 }; 62 };
65 63
diff --git a/MAINTAINERS b/MAINTAINERS
index defc05383f83..7cacc88dc79c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -965,6 +965,12 @@ M: Lennert Buytenhek <kernel@wantstofly.org>
965L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 965L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
966S: Maintained 966S: Maintained
967 967
968ARM/TEXAS INSTRUMENT KEYSTONE ARCHITECTURE
969M: Santosh Shilimkar <santosh.shilimkar@ti.com>
970L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
971S: Maintained
972F: arch/arm/mach-keystone/
973
968ARM/LOGICPD PXA270 MACHINE SUPPORT 974ARM/LOGICPD PXA270 MACHINE SUPPORT
969M: Lennert Buytenhek <kernel@wantstofly.org> 975M: Lennert Buytenhek <kernel@wantstofly.org>
970L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 976L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
@@ -1259,7 +1265,6 @@ F: drivers/rtc/rtc-coh901331.c
1259T: git git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-stericsson.git 1265T: git git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-stericsson.git
1260 1266
1261ARM/Ux500 ARM ARCHITECTURE 1267ARM/Ux500 ARM ARCHITECTURE
1262M: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
1263M: Linus Walleij <linus.walleij@linaro.org> 1268M: Linus Walleij <linus.walleij@linaro.org>
1264L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 1269L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
1265S: Maintained 1270S: Maintained
@@ -8664,6 +8669,11 @@ T: git git://git.alsa-project.org/alsa-kernel.git
8664S: Maintained 8669S: Maintained
8665F: sound/usb/midi.* 8670F: sound/usb/midi.*
8666 8671
8672USB NETWORKING DRIVERS
8673L: linux-usb@vger.kernel.org
8674S: Odd Fixes
8675F: drivers/net/usb/
8676
8667USB OHCI DRIVER 8677USB OHCI DRIVER
8668M: Alan Stern <stern@rowland.harvard.edu> 8678M: Alan Stern <stern@rowland.harvard.edu>
8669L: linux-usb@vger.kernel.org 8679L: linux-usb@vger.kernel.org
diff --git a/arch/arm/boot/dts/msm8960-cdp.dts b/arch/arm/boot/dts/msm8960-cdp.dts
index db2060c46540..9c1167b0459b 100644
--- a/arch/arm/boot/dts/msm8960-cdp.dts
+++ b/arch/arm/boot/dts/msm8960-cdp.dts
@@ -26,7 +26,7 @@
26 cpu-offset = <0x80000>; 26 cpu-offset = <0x80000>;
27 }; 27 };
28 28
29 msmgpio: gpio@fd510000 { 29 msmgpio: gpio@800000 {
30 compatible = "qcom,msm-gpio"; 30 compatible = "qcom,msm-gpio";
31 gpio-controller; 31 gpio-controller;
32 #gpio-cells = <2>; 32 #gpio-cells = <2>;
@@ -34,7 +34,7 @@
34 interrupts = <0 32 0x4>; 34 interrupts = <0 32 0x4>;
35 interrupt-controller; 35 interrupt-controller;
36 #interrupt-cells = <2>; 36 #interrupt-cells = <2>;
37 reg = <0xfd510000 0x4000>; 37 reg = <0x800000 0x4000>;
38 }; 38 };
39 39
40 serial@16440000 { 40 serial@16440000 {
diff --git a/arch/arm/boot/dts/omap5-uevm.dts b/arch/arm/boot/dts/omap5-uevm.dts
index 08b72678abff..65d7b601651c 100644
--- a/arch/arm/boot/dts/omap5-uevm.dts
+++ b/arch/arm/boot/dts/omap5-uevm.dts
@@ -235,7 +235,7 @@
235}; 235};
236 236
237&mmc1 { 237&mmc1 {
238 vmmc-supply = <&vmmcsd_fixed>; 238 vmmc-supply = <&ldo9_reg>;
239 bus-width = <4>; 239 bus-width = <4>;
240}; 240};
241 241
@@ -282,6 +282,7 @@
282 282
283 regulators { 283 regulators {
284 smps123_reg: smps123 { 284 smps123_reg: smps123 {
285 /* VDD_OPP_MPU */
285 regulator-name = "smps123"; 286 regulator-name = "smps123";
286 regulator-min-microvolt = < 600000>; 287 regulator-min-microvolt = < 600000>;
287 regulator-max-microvolt = <1500000>; 288 regulator-max-microvolt = <1500000>;
@@ -290,6 +291,7 @@
290 }; 291 };
291 292
292 smps45_reg: smps45 { 293 smps45_reg: smps45 {
294 /* VDD_OPP_MM */
293 regulator-name = "smps45"; 295 regulator-name = "smps45";
294 regulator-min-microvolt = < 600000>; 296 regulator-min-microvolt = < 600000>;
295 regulator-max-microvolt = <1310000>; 297 regulator-max-microvolt = <1310000>;
@@ -298,6 +300,7 @@
298 }; 300 };
299 301
300 smps6_reg: smps6 { 302 smps6_reg: smps6 {
303 /* VDD_DDR3 - over VDD_SMPS6 */
301 regulator-name = "smps6"; 304 regulator-name = "smps6";
302 regulator-min-microvolt = <1200000>; 305 regulator-min-microvolt = <1200000>;
303 regulator-max-microvolt = <1200000>; 306 regulator-max-microvolt = <1200000>;
@@ -306,6 +309,7 @@
306 }; 309 };
307 310
308 smps7_reg: smps7 { 311 smps7_reg: smps7 {
312 /* VDDS_1v8_OMAP over VDDS_1v8_MAIN */
309 regulator-name = "smps7"; 313 regulator-name = "smps7";
310 regulator-min-microvolt = <1800000>; 314 regulator-min-microvolt = <1800000>;
311 regulator-max-microvolt = <1800000>; 315 regulator-max-microvolt = <1800000>;
@@ -314,6 +318,7 @@
314 }; 318 };
315 319
316 smps8_reg: smps8 { 320 smps8_reg: smps8 {
321 /* VDD_OPP_CORE */
317 regulator-name = "smps8"; 322 regulator-name = "smps8";
318 regulator-min-microvolt = < 600000>; 323 regulator-min-microvolt = < 600000>;
319 regulator-max-microvolt = <1310000>; 324 regulator-max-microvolt = <1310000>;
@@ -322,15 +327,15 @@
322 }; 327 };
323 328
324 smps9_reg: smps9 { 329 smps9_reg: smps9 {
330 /* VDDA_2v1_AUD over VDD_2v1 */
325 regulator-name = "smps9"; 331 regulator-name = "smps9";
326 regulator-min-microvolt = <2100000>; 332 regulator-min-microvolt = <2100000>;
327 regulator-max-microvolt = <2100000>; 333 regulator-max-microvolt = <2100000>;
328 regulator-always-on;
329 regulator-boot-on;
330 ti,smps-range = <0x80>; 334 ti,smps-range = <0x80>;
331 }; 335 };
332 336
333 smps10_reg: smps10 { 337 smps10_reg: smps10 {
338 /* VBUS_5V_OTG */
334 regulator-name = "smps10"; 339 regulator-name = "smps10";
335 regulator-min-microvolt = <5000000>; 340 regulator-min-microvolt = <5000000>;
336 regulator-max-microvolt = <5000000>; 341 regulator-max-microvolt = <5000000>;
@@ -339,38 +344,40 @@
339 }; 344 };
340 345
341 ldo1_reg: ldo1 { 346 ldo1_reg: ldo1 {
347 /* VDDAPHY_CAM: vdda_csiport */
342 regulator-name = "ldo1"; 348 regulator-name = "ldo1";
343 regulator-min-microvolt = <2800000>; 349 regulator-min-microvolt = <1500000>;
344 regulator-max-microvolt = <2800000>; 350 regulator-max-microvolt = <1800000>;
345 regulator-always-on;
346 regulator-boot-on;
347 }; 351 };
348 352
349 ldo2_reg: ldo2 { 353 ldo2_reg: ldo2 {
354 /* VCC_2V8_DISP: Does not go anywhere */
350 regulator-name = "ldo2"; 355 regulator-name = "ldo2";
351 regulator-min-microvolt = <2900000>; 356 regulator-min-microvolt = <2800000>;
352 regulator-max-microvolt = <2900000>; 357 regulator-max-microvolt = <2800000>;
353 regulator-always-on; 358 /* Unused */
354 regulator-boot-on; 359 status = "disabled";
355 }; 360 };
356 361
357 ldo3_reg: ldo3 { 362 ldo3_reg: ldo3 {
363 /* VDDAPHY_MDM: vdda_lli */
358 regulator-name = "ldo3"; 364 regulator-name = "ldo3";
359 regulator-min-microvolt = <3000000>; 365 regulator-min-microvolt = <1500000>;
360 regulator-max-microvolt = <3000000>; 366 regulator-max-microvolt = <1500000>;
361 regulator-always-on;
362 regulator-boot-on; 367 regulator-boot-on;
368 /* Only if Modem is used */
369 status = "disabled";
363 }; 370 };
364 371
365 ldo4_reg: ldo4 { 372 ldo4_reg: ldo4 {
373 /* VDDAPHY_DISP: vdda_dsiport/hdmi */
366 regulator-name = "ldo4"; 374 regulator-name = "ldo4";
367 regulator-min-microvolt = <2200000>; 375 regulator-min-microvolt = <1500000>;
368 regulator-max-microvolt = <2200000>; 376 regulator-max-microvolt = <1800000>;
369 regulator-always-on;
370 regulator-boot-on;
371 }; 377 };
372 378
373 ldo5_reg: ldo5 { 379 ldo5_reg: ldo5 {
380 /* VDDA_1V8_PHY: usb/sata/hdmi.. */
374 regulator-name = "ldo5"; 381 regulator-name = "ldo5";
375 regulator-min-microvolt = <1800000>; 382 regulator-min-microvolt = <1800000>;
376 regulator-max-microvolt = <1800000>; 383 regulator-max-microvolt = <1800000>;
@@ -379,38 +386,43 @@
379 }; 386 };
380 387
381 ldo6_reg: ldo6 { 388 ldo6_reg: ldo6 {
389 /* VDDS_1V2_WKUP: hsic/ldo_emu_wkup */
382 regulator-name = "ldo6"; 390 regulator-name = "ldo6";
383 regulator-min-microvolt = <1500000>; 391 regulator-min-microvolt = <1200000>;
384 regulator-max-microvolt = <1500000>; 392 regulator-max-microvolt = <1200000>;
385 regulator-always-on; 393 regulator-always-on;
386 regulator-boot-on; 394 regulator-boot-on;
387 }; 395 };
388 396
389 ldo7_reg: ldo7 { 397 ldo7_reg: ldo7 {
398 /* VDD_VPP: vpp1 */
390 regulator-name = "ldo7"; 399 regulator-name = "ldo7";
391 regulator-min-microvolt = <1500000>; 400 regulator-min-microvolt = <2000000>;
392 regulator-max-microvolt = <1500000>; 401 regulator-max-microvolt = <2000000>;
393 regulator-always-on; 402 /* Only for efuse reprograming! */
394 regulator-boot-on; 403 status = "disabled";
395 }; 404 };
396 405
397 ldo8_reg: ldo8 { 406 ldo8_reg: ldo8 {
407 /* VDD_3v0: Does not go anywhere */
398 regulator-name = "ldo8"; 408 regulator-name = "ldo8";
399 regulator-min-microvolt = <1500000>; 409 regulator-min-microvolt = <3000000>;
400 regulator-max-microvolt = <1500000>; 410 regulator-max-microvolt = <3000000>;
401 regulator-always-on;
402 regulator-boot-on; 411 regulator-boot-on;
412 /* Unused */
413 status = "disabled";
403 }; 414 };
404 415
405 ldo9_reg: ldo9 { 416 ldo9_reg: ldo9 {
417 /* VCC_DV_SDIO: vdds_sdcard */
406 regulator-name = "ldo9"; 418 regulator-name = "ldo9";
407 regulator-min-microvolt = <1800000>; 419 regulator-min-microvolt = <1800000>;
408 regulator-max-microvolt = <3300000>; 420 regulator-max-microvolt = <3000000>;
409 regulator-always-on;
410 regulator-boot-on; 421 regulator-boot-on;
411 }; 422 };
412 423
413 ldoln_reg: ldoln { 424 ldoln_reg: ldoln {
425 /* VDDA_1v8_REF: vdds_osc/mm_l4per.. */
414 regulator-name = "ldoln"; 426 regulator-name = "ldoln";
415 regulator-min-microvolt = <1800000>; 427 regulator-min-microvolt = <1800000>;
416 regulator-max-microvolt = <1800000>; 428 regulator-max-microvolt = <1800000>;
@@ -419,12 +431,20 @@
419 }; 431 };
420 432
421 ldousb_reg: ldousb { 433 ldousb_reg: ldousb {
434 /* VDDA_3V_USB: VDDA_USBHS33 */
422 regulator-name = "ldousb"; 435 regulator-name = "ldousb";
423 regulator-min-microvolt = <3250000>; 436 regulator-min-microvolt = <3250000>;
424 regulator-max-microvolt = <3250000>; 437 regulator-max-microvolt = <3250000>;
425 regulator-always-on; 438 regulator-always-on;
426 regulator-boot-on; 439 regulator-boot-on;
427 }; 440 };
441
442 regen3_reg: regen3 {
443 /* REGEN3 controls LDO9 supply to card */
444 regulator-name = "regen3";
445 regulator-always-on;
446 regulator-boot-on;
447 };
428 }; 448 };
429 }; 449 };
430 }; 450 };
diff --git a/arch/arm/boot/dts/stih41x.dtsi b/arch/arm/boot/dts/stih41x.dtsi
index 7321403cab8a..f5b9898d9c6e 100644
--- a/arch/arm/boot/dts/stih41x.dtsi
+++ b/arch/arm/boot/dts/stih41x.dtsi
@@ -6,10 +6,12 @@
6 #address-cells = <1>; 6 #address-cells = <1>;
7 #size-cells = <0>; 7 #size-cells = <0>;
8 cpu@0 { 8 cpu@0 {
9 device_type = "cpu";
9 compatible = "arm,cortex-a9"; 10 compatible = "arm,cortex-a9";
10 reg = <0>; 11 reg = <0>;
11 }; 12 };
12 cpu@1 { 13 cpu@1 {
14 device_type = "cpu";
13 compatible = "arm,cortex-a9"; 15 compatible = "arm,cortex-a9";
14 reg = <1>; 16 reg = <1>;
15 }; 17 };
diff --git a/arch/arm/boot/dts/tegra20-colibri-512.dtsi b/arch/arm/boot/dts/tegra20-colibri-512.dtsi
index 2fcb3f2ca160..5592be6f2f7a 100644
--- a/arch/arm/boot/dts/tegra20-colibri-512.dtsi
+++ b/arch/arm/boot/dts/tegra20-colibri-512.dtsi
@@ -457,6 +457,7 @@
457 }; 457 };
458 458
459 usb-phy@c5004000 { 459 usb-phy@c5004000 {
460 status = "okay";
460 nvidia,phy-reset-gpio = <&gpio TEGRA_GPIO(V, 1) 461 nvidia,phy-reset-gpio = <&gpio TEGRA_GPIO(V, 1)
461 GPIO_ACTIVE_LOW>; 462 GPIO_ACTIVE_LOW>;
462 }; 463 };
diff --git a/arch/arm/mach-msm/Kconfig b/arch/arm/mach-msm/Kconfig
index 614e41e7881b..905efc8cac79 100644
--- a/arch/arm/mach-msm/Kconfig
+++ b/arch/arm/mach-msm/Kconfig
@@ -121,8 +121,7 @@ config MSM_SMD
121 bool 121 bool
122 122
123config MSM_GPIOMUX 123config MSM_GPIOMUX
124 depends on !(ARCH_MSM8X60 || ARCH_MSM8960) 124 bool
125 bool "MSM V1 TLMM GPIOMUX architecture"
126 help 125 help
127 Support for MSM V1 TLMM GPIOMUX architecture. 126 Support for MSM V1 TLMM GPIOMUX architecture.
128 127
diff --git a/arch/arm/mach-msm/gpiomux-v1.c b/arch/arm/mach-msm/gpiomux-v1.c
deleted file mode 100644
index 27de2abd7144..000000000000
--- a/arch/arm/mach-msm/gpiomux-v1.c
+++ /dev/null
@@ -1,33 +0,0 @@
1/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17#include <linux/kernel.h>
18#include "gpiomux.h"
19#include "proc_comm.h"
20
21void __msm_gpiomux_write(unsigned gpio, gpiomux_config_t val)
22{
23 unsigned tlmm_config = (val & ~GPIOMUX_CTL_MASK) |
24 ((gpio & 0x3ff) << 4);
25 unsigned tlmm_disable = 0;
26 int rc;
27
28 rc = msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX,
29 &tlmm_config, &tlmm_disable);
30 if (rc)
31 pr_err("%s: unexpected proc_comm failure %d: %08x %08x\n",
32 __func__, rc, tlmm_config, tlmm_disable);
33}
diff --git a/arch/arm/mach-msm/gpiomux.h b/arch/arm/mach-msm/gpiomux.h
index 8e82f41a8923..4410d7766f93 100644
--- a/arch/arm/mach-msm/gpiomux.h
+++ b/arch/arm/mach-msm/gpiomux.h
@@ -73,16 +73,6 @@ extern struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS];
73int msm_gpiomux_write(unsigned gpio, 73int msm_gpiomux_write(unsigned gpio,
74 gpiomux_config_t active, 74 gpiomux_config_t active,
75 gpiomux_config_t suspended); 75 gpiomux_config_t suspended);
76
77/* Architecture-internal function for use by the framework only.
78 * This function can assume the following:
79 * - the gpio value has passed a bounds-check
80 * - the gpiomux spinlock has been obtained
81 *
82 * This function is not for public consumption. External users
83 * should use msm_gpiomux_write.
84 */
85void __msm_gpiomux_write(unsigned gpio, gpiomux_config_t val);
86#else 76#else
87static inline int msm_gpiomux_write(unsigned gpio, 77static inline int msm_gpiomux_write(unsigned gpio,
88 gpiomux_config_t active, 78 gpiomux_config_t active,
diff --git a/arch/arm/mach-omap2/dss-common.c b/arch/arm/mach-omap2/dss-common.c
index 393aeefaebb0..043e5705f2a6 100644
--- a/arch/arm/mach-omap2/dss-common.c
+++ b/arch/arm/mach-omap2/dss-common.c
@@ -42,7 +42,7 @@
42 42
43/* Using generic display panel */ 43/* Using generic display panel */
44static struct tfp410_platform_data omap4_dvi_panel = { 44static struct tfp410_platform_data omap4_dvi_panel = {
45 .i2c_bus_num = 3, 45 .i2c_bus_num = 2,
46 .power_down_gpio = PANDA_DVI_TFP410_POWER_DOWN_GPIO, 46 .power_down_gpio = PANDA_DVI_TFP410_POWER_DOWN_GPIO,
47}; 47};
48 48
diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
index 5cc92874be7e..f99f68e1e85b 100644
--- a/arch/arm/mach-omap2/omap_device.c
+++ b/arch/arm/mach-omap2/omap_device.c
@@ -129,6 +129,7 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
129 struct device_node *node = pdev->dev.of_node; 129 struct device_node *node = pdev->dev.of_node;
130 const char *oh_name; 130 const char *oh_name;
131 int oh_cnt, i, ret = 0; 131 int oh_cnt, i, ret = 0;
132 bool device_active = false;
132 133
133 oh_cnt = of_property_count_strings(node, "ti,hwmods"); 134 oh_cnt = of_property_count_strings(node, "ti,hwmods");
134 if (oh_cnt <= 0) { 135 if (oh_cnt <= 0) {
@@ -152,6 +153,8 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
152 goto odbfd_exit1; 153 goto odbfd_exit1;
153 } 154 }
154 hwmods[i] = oh; 155 hwmods[i] = oh;
156 if (oh->flags & HWMOD_INIT_NO_IDLE)
157 device_active = true;
155 } 158 }
156 159
157 od = omap_device_alloc(pdev, hwmods, oh_cnt); 160 od = omap_device_alloc(pdev, hwmods, oh_cnt);
@@ -172,6 +175,11 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
172 175
173 pdev->dev.pm_domain = &omap_device_pm_domain; 176 pdev->dev.pm_domain = &omap_device_pm_domain;
174 177
178 if (device_active) {
179 omap_device_enable(pdev);
180 pm_runtime_set_active(&pdev->dev);
181 }
182
175odbfd_exit1: 183odbfd_exit1:
176 kfree(hwmods); 184 kfree(hwmods);
177odbfd_exit: 185odbfd_exit:
@@ -842,6 +850,7 @@ static int __init omap_device_late_idle(struct device *dev, void *data)
842{ 850{
843 struct platform_device *pdev = to_platform_device(dev); 851 struct platform_device *pdev = to_platform_device(dev);
844 struct omap_device *od = to_omap_device(pdev); 852 struct omap_device *od = to_omap_device(pdev);
853 int i;
845 854
846 if (!od) 855 if (!od)
847 return 0; 856 return 0;
@@ -850,6 +859,15 @@ static int __init omap_device_late_idle(struct device *dev, void *data)
850 * If omap_device state is enabled, but has no driver bound, 859 * If omap_device state is enabled, but has no driver bound,
851 * idle it. 860 * idle it.
852 */ 861 */
862
863 /*
864 * Some devices (like memory controllers) are always kept
865 * enabled, and should not be idled even with no drivers.
866 */
867 for (i = 0; i < od->hwmods_cnt; i++)
868 if (od->hwmods[i]->flags & HWMOD_INIT_NO_IDLE)
869 return 0;
870
853 if (od->_driver_status != BUS_NOTIFY_BOUND_DRIVER) { 871 if (od->_driver_status != BUS_NOTIFY_BOUND_DRIVER) {
854 if (od->_state == OMAP_DEVICE_STATE_ENABLED) { 872 if (od->_state == OMAP_DEVICE_STATE_ENABLED) {
855 dev_warn(dev, "%s: enabled but no driver. Idling\n", 873 dev_warn(dev, "%s: enabled but no driver. Idling\n",
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 7341eff63f56..7f4db12b1459 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -2386,7 +2386,7 @@ static void __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data)
2386 2386
2387 np = of_dev_hwmod_lookup(of_find_node_by_name(NULL, "ocp"), oh); 2387 np = of_dev_hwmod_lookup(of_find_node_by_name(NULL, "ocp"), oh);
2388 if (np) 2388 if (np)
2389 va_start = of_iomap(np, 0); 2389 va_start = of_iomap(np, oh->mpu_rt_idx);
2390 } else { 2390 } else {
2391 va_start = ioremap(mem->pa_start, mem->pa_end - mem->pa_start); 2391 va_start = ioremap(mem->pa_start, mem->pa_end - mem->pa_start);
2392 } 2392 }
diff --git a/arch/arm/mach-omap2/omap_hwmod.h b/arch/arm/mach-omap2/omap_hwmod.h
index aab33fd814c0..e1482a9b3bc2 100644
--- a/arch/arm/mach-omap2/omap_hwmod.h
+++ b/arch/arm/mach-omap2/omap_hwmod.h
@@ -95,6 +95,54 @@ extern struct omap_hwmod_sysc_fields omap_hwmod_sysc_type3;
95#define MODULEMODE_HWCTRL 1 95#define MODULEMODE_HWCTRL 1
96#define MODULEMODE_SWCTRL 2 96#define MODULEMODE_SWCTRL 2
97 97
98#define DEBUG_OMAP2UART1_FLAGS 0
99#define DEBUG_OMAP2UART2_FLAGS 0
100#define DEBUG_OMAP2UART3_FLAGS 0
101#define DEBUG_OMAP3UART3_FLAGS 0
102#define DEBUG_OMAP3UART4_FLAGS 0
103#define DEBUG_OMAP4UART3_FLAGS 0
104#define DEBUG_OMAP4UART4_FLAGS 0
105#define DEBUG_TI81XXUART1_FLAGS 0
106#define DEBUG_TI81XXUART2_FLAGS 0
107#define DEBUG_TI81XXUART3_FLAGS 0
108#define DEBUG_AM33XXUART1_FLAGS 0
109
110#define DEBUG_OMAPUART_FLAGS (HWMOD_INIT_NO_IDLE | HWMOD_INIT_NO_RESET)
111
112#if defined(CONFIG_DEBUG_OMAP2UART1)
113#undef DEBUG_OMAP2UART1_FLAGS
114#define DEBUG_OMAP2UART1_FLAGS DEBUG_OMAPUART_FLAGS
115#elif defined(CONFIG_DEBUG_OMAP2UART2)
116#undef DEBUG_OMAP2UART2_FLAGS
117#define DEBUG_OMAP2UART2_FLAGS DEBUG_OMAPUART_FLAGS
118#elif defined(CONFIG_DEBUG_OMAP2UART3)
119#undef DEBUG_OMAP2UART3_FLAGS
120#define DEBUG_OMAP2UART3_FLAGS DEBUG_OMAPUART_FLAGS
121#elif defined(CONFIG_DEBUG_OMAP3UART3)
122#undef DEBUG_OMAP3UART3_FLAGS
123#define DEBUG_OMAP3UART3_FLAGS DEBUG_OMAPUART_FLAGS
124#elif defined(CONFIG_DEBUG_OMAP3UART4)
125#undef DEBUG_OMAP3UART4_FLAGS
126#define DEBUG_OMAP3UART4_FLAGS DEBUG_OMAPUART_FLAGS
127#elif defined(CONFIG_DEBUG_OMAP4UART3)
128#undef DEBUG_OMAP4UART3_FLAGS
129#define DEBUG_OMAP4UART3_FLAGS DEBUG_OMAPUART_FLAGS
130#elif defined(CONFIG_DEBUG_OMAP4UART4)
131#undef DEBUG_OMAP4UART4_FLAGS
132#define DEBUG_OMAP4UART4_FLAGS DEBUG_OMAPUART_FLAGS
133#elif defined(CONFIG_DEBUG_TI81XXUART1)
134#undef DEBUG_TI81XXUART1_FLAGS
135#define DEBUG_TI81XXUART1_FLAGS DEBUG_OMAPUART_FLAGS
136#elif defined(CONFIG_DEBUG_TI81XXUART2)
137#undef DEBUG_TI81XXUART2_FLAGS
138#define DEBUG_TI81XXUART2_FLAGS DEBUG_OMAPUART_FLAGS
139#elif defined(CONFIG_DEBUG_TI81XXUART3)
140#undef DEBUG_TI81XXUART3_FLAGS
141#define DEBUG_TI81XXUART3_FLAGS DEBUG_OMAPUART_FLAGS
142#elif defined(CONFIG_DEBUG_AM33XXUART1)
143#undef DEBUG_AM33XXUART1_FLAGS
144#define DEBUG_AM33XXUART1_FLAGS DEBUG_OMAPUART_FLAGS
145#endif
98 146
99/** 147/**
100 * struct omap_hwmod_mux_info - hwmod specific mux configuration 148 * struct omap_hwmod_mux_info - hwmod specific mux configuration
@@ -568,6 +616,7 @@ struct omap_hwmod_link {
568 * @voltdm: pointer to voltage domain (filled in at runtime) 616 * @voltdm: pointer to voltage domain (filled in at runtime)
569 * @dev_attr: arbitrary device attributes that can be passed to the driver 617 * @dev_attr: arbitrary device attributes that can be passed to the driver
570 * @_sysc_cache: internal-use hwmod flags 618 * @_sysc_cache: internal-use hwmod flags
619 * @mpu_rt_idx: index of device address space for register target (for DT boot)
571 * @_mpu_rt_va: cached register target start address (internal use) 620 * @_mpu_rt_va: cached register target start address (internal use)
572 * @_mpu_port: cached MPU register target slave (internal use) 621 * @_mpu_port: cached MPU register target slave (internal use)
573 * @opt_clks_cnt: number of @opt_clks 622 * @opt_clks_cnt: number of @opt_clks
@@ -617,6 +666,7 @@ struct omap_hwmod {
617 struct list_head node; 666 struct list_head node;
618 struct omap_hwmod_ocp_if *_mpu_port; 667 struct omap_hwmod_ocp_if *_mpu_port;
619 u16 flags; 668 u16 flags;
669 u8 mpu_rt_idx;
620 u8 response_lat; 670 u8 response_lat;
621 u8 rst_lines_cnt; 671 u8 rst_lines_cnt;
622 u8 opt_clks_cnt; 672 u8 opt_clks_cnt;
diff --git a/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c b/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c
index d05fc7b54567..56cebb05509e 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c
@@ -512,7 +512,7 @@ struct omap_hwmod omap2xxx_uart1_hwmod = {
512 .mpu_irqs = omap2_uart1_mpu_irqs, 512 .mpu_irqs = omap2_uart1_mpu_irqs,
513 .sdma_reqs = omap2_uart1_sdma_reqs, 513 .sdma_reqs = omap2_uart1_sdma_reqs,
514 .main_clk = "uart1_fck", 514 .main_clk = "uart1_fck",
515 .flags = HWMOD_SWSUP_SIDLE_ACT, 515 .flags = DEBUG_OMAP2UART1_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
516 .prcm = { 516 .prcm = {
517 .omap2 = { 517 .omap2 = {
518 .module_offs = CORE_MOD, 518 .module_offs = CORE_MOD,
@@ -532,7 +532,7 @@ struct omap_hwmod omap2xxx_uart2_hwmod = {
532 .mpu_irqs = omap2_uart2_mpu_irqs, 532 .mpu_irqs = omap2_uart2_mpu_irqs,
533 .sdma_reqs = omap2_uart2_sdma_reqs, 533 .sdma_reqs = omap2_uart2_sdma_reqs,
534 .main_clk = "uart2_fck", 534 .main_clk = "uart2_fck",
535 .flags = HWMOD_SWSUP_SIDLE_ACT, 535 .flags = DEBUG_OMAP2UART2_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
536 .prcm = { 536 .prcm = {
537 .omap2 = { 537 .omap2 = {
538 .module_offs = CORE_MOD, 538 .module_offs = CORE_MOD,
@@ -552,7 +552,7 @@ struct omap_hwmod omap2xxx_uart3_hwmod = {
552 .mpu_irqs = omap2_uart3_mpu_irqs, 552 .mpu_irqs = omap2_uart3_mpu_irqs,
553 .sdma_reqs = omap2_uart3_sdma_reqs, 553 .sdma_reqs = omap2_uart3_sdma_reqs,
554 .main_clk = "uart3_fck", 554 .main_clk = "uart3_fck",
555 .flags = HWMOD_SWSUP_SIDLE_ACT, 555 .flags = DEBUG_OMAP2UART3_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
556 .prcm = { 556 .prcm = {
557 .omap2 = { 557 .omap2 = {
558 .module_offs = CORE_MOD, 558 .module_offs = CORE_MOD,
diff --git a/arch/arm/mach-omap2/omap_hwmod_33xx_data.c b/arch/arm/mach-omap2/omap_hwmod_33xx_data.c
index 28bbd56346a9..eb2f3b93b51c 100644
--- a/arch/arm/mach-omap2/omap_hwmod_33xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_33xx_data.c
@@ -562,6 +562,7 @@ static struct omap_hwmod am33xx_cpgmac0_hwmod = {
562 .clkdm_name = "cpsw_125mhz_clkdm", 562 .clkdm_name = "cpsw_125mhz_clkdm",
563 .flags = (HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY), 563 .flags = (HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY),
564 .main_clk = "cpsw_125mhz_gclk", 564 .main_clk = "cpsw_125mhz_gclk",
565 .mpu_rt_idx = 1,
565 .prcm = { 566 .prcm = {
566 .omap4 = { 567 .omap4 = {
567 .clkctrl_offs = AM33XX_CM_PER_CPGMAC0_CLKCTRL_OFFSET, 568 .clkctrl_offs = AM33XX_CM_PER_CPGMAC0_CLKCTRL_OFFSET,
@@ -1512,7 +1513,7 @@ static struct omap_hwmod am33xx_uart1_hwmod = {
1512 .name = "uart1", 1513 .name = "uart1",
1513 .class = &uart_class, 1514 .class = &uart_class,
1514 .clkdm_name = "l4_wkup_clkdm", 1515 .clkdm_name = "l4_wkup_clkdm",
1515 .flags = HWMOD_SWSUP_SIDLE_ACT, 1516 .flags = DEBUG_AM33XXUART1_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
1516 .main_clk = "dpll_per_m2_div4_wkupdm_ck", 1517 .main_clk = "dpll_per_m2_div4_wkupdm_ck",
1517 .prcm = { 1518 .prcm = {
1518 .omap4 = { 1519 .omap4 = {
diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
index f7a3df2fb579..0c3a427da544 100644
--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -490,7 +490,7 @@ static struct omap_hwmod omap3xxx_uart1_hwmod = {
490 .mpu_irqs = omap2_uart1_mpu_irqs, 490 .mpu_irqs = omap2_uart1_mpu_irqs,
491 .sdma_reqs = omap2_uart1_sdma_reqs, 491 .sdma_reqs = omap2_uart1_sdma_reqs,
492 .main_clk = "uart1_fck", 492 .main_clk = "uart1_fck",
493 .flags = HWMOD_SWSUP_SIDLE_ACT, 493 .flags = DEBUG_TI81XXUART1_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
494 .prcm = { 494 .prcm = {
495 .omap2 = { 495 .omap2 = {
496 .module_offs = CORE_MOD, 496 .module_offs = CORE_MOD,
@@ -509,7 +509,7 @@ static struct omap_hwmod omap3xxx_uart2_hwmod = {
509 .mpu_irqs = omap2_uart2_mpu_irqs, 509 .mpu_irqs = omap2_uart2_mpu_irqs,
510 .sdma_reqs = omap2_uart2_sdma_reqs, 510 .sdma_reqs = omap2_uart2_sdma_reqs,
511 .main_clk = "uart2_fck", 511 .main_clk = "uart2_fck",
512 .flags = HWMOD_SWSUP_SIDLE_ACT, 512 .flags = DEBUG_TI81XXUART2_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
513 .prcm = { 513 .prcm = {
514 .omap2 = { 514 .omap2 = {
515 .module_offs = CORE_MOD, 515 .module_offs = CORE_MOD,
@@ -528,7 +528,8 @@ static struct omap_hwmod omap3xxx_uart3_hwmod = {
528 .mpu_irqs = omap2_uart3_mpu_irqs, 528 .mpu_irqs = omap2_uart3_mpu_irqs,
529 .sdma_reqs = omap2_uart3_sdma_reqs, 529 .sdma_reqs = omap2_uart3_sdma_reqs,
530 .main_clk = "uart3_fck", 530 .main_clk = "uart3_fck",
531 .flags = HWMOD_SWSUP_SIDLE_ACT, 531 .flags = DEBUG_OMAP3UART3_FLAGS | DEBUG_TI81XXUART3_FLAGS |
532 HWMOD_SWSUP_SIDLE_ACT,
532 .prcm = { 533 .prcm = {
533 .omap2 = { 534 .omap2 = {
534 .module_offs = OMAP3430_PER_MOD, 535 .module_offs = OMAP3430_PER_MOD,
@@ -558,7 +559,7 @@ static struct omap_hwmod omap36xx_uart4_hwmod = {
558 .mpu_irqs = uart4_mpu_irqs, 559 .mpu_irqs = uart4_mpu_irqs,
559 .sdma_reqs = uart4_sdma_reqs, 560 .sdma_reqs = uart4_sdma_reqs,
560 .main_clk = "uart4_fck", 561 .main_clk = "uart4_fck",
561 .flags = HWMOD_SWSUP_SIDLE_ACT, 562 .flags = DEBUG_OMAP3UART4_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
562 .prcm = { 563 .prcm = {
563 .omap2 = { 564 .omap2 = {
564 .module_offs = OMAP3430_PER_MOD, 565 .module_offs = OMAP3430_PER_MOD,
diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
index d04b5e60fdbe..9c3b504477d7 100644
--- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -2858,8 +2858,7 @@ static struct omap_hwmod omap44xx_uart3_hwmod = {
2858 .name = "uart3", 2858 .name = "uart3",
2859 .class = &omap44xx_uart_hwmod_class, 2859 .class = &omap44xx_uart_hwmod_class,
2860 .clkdm_name = "l4_per_clkdm", 2860 .clkdm_name = "l4_per_clkdm",
2861 .flags = HWMOD_INIT_NO_IDLE | HWMOD_INIT_NO_RESET | 2861 .flags = DEBUG_OMAP4UART3_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
2862 HWMOD_SWSUP_SIDLE_ACT,
2863 .main_clk = "func_48m_fclk", 2862 .main_clk = "func_48m_fclk",
2864 .prcm = { 2863 .prcm = {
2865 .omap4 = { 2864 .omap4 = {
@@ -2875,7 +2874,7 @@ static struct omap_hwmod omap44xx_uart4_hwmod = {
2875 .name = "uart4", 2874 .name = "uart4",
2876 .class = &omap44xx_uart_hwmod_class, 2875 .class = &omap44xx_uart_hwmod_class,
2877 .clkdm_name = "l4_per_clkdm", 2876 .clkdm_name = "l4_per_clkdm",
2878 .flags = HWMOD_SWSUP_SIDLE_ACT, 2877 .flags = DEBUG_OMAP4UART4_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
2879 .main_clk = "func_48m_fclk", 2878 .main_clk = "func_48m_fclk",
2880 .prcm = { 2879 .prcm = {
2881 .omap4 = { 2880 .omap4 = {
diff --git a/arch/arm/mach-omap2/omap_hwmod_54xx_data.c b/arch/arm/mach-omap2/omap_hwmod_54xx_data.c
index f37ae96b70a1..3c70f5c1860f 100644
--- a/arch/arm/mach-omap2/omap_hwmod_54xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_54xx_data.c
@@ -1375,7 +1375,7 @@ static struct omap_hwmod omap54xx_uart3_hwmod = {
1375 .name = "uart3", 1375 .name = "uart3",
1376 .class = &omap54xx_uart_hwmod_class, 1376 .class = &omap54xx_uart_hwmod_class,
1377 .clkdm_name = "l4per_clkdm", 1377 .clkdm_name = "l4per_clkdm",
1378 .flags = HWMOD_INIT_NO_IDLE | HWMOD_INIT_NO_RESET, 1378 .flags = DEBUG_OMAP4UART3_FLAGS,
1379 .main_clk = "func_48m_fclk", 1379 .main_clk = "func_48m_fclk",
1380 .prcm = { 1380 .prcm = {
1381 .omap4 = { 1381 .omap4 = {
@@ -1391,6 +1391,7 @@ static struct omap_hwmod omap54xx_uart4_hwmod = {
1391 .name = "uart4", 1391 .name = "uart4",
1392 .class = &omap54xx_uart_hwmod_class, 1392 .class = &omap54xx_uart_hwmod_class,
1393 .clkdm_name = "l4per_clkdm", 1393 .clkdm_name = "l4per_clkdm",
1394 .flags = DEBUG_OMAP4UART4_FLAGS,
1394 .main_clk = "func_48m_fclk", 1395 .main_clk = "func_48m_fclk",
1395 .prcm = { 1396 .prcm = {
1396 .omap4 = { 1397 .omap4 = {
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 3a674de6cb63..a388f8c1bcb3 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -208,17 +208,6 @@ static int __init omap_serial_early_init(void)
208 pr_info("%s used as console in debug mode: uart%d clocks will not be gated", 208 pr_info("%s used as console in debug mode: uart%d clocks will not be gated",
209 uart_name, uart->num); 209 uart_name, uart->num);
210 } 210 }
211
212 /*
213 * omap-uart can be used for earlyprintk logs
214 * So if omap-uart is used as console then prevent
215 * uart reset and idle to get logs from omap-uart
216 * until uart console driver is available to take
217 * care for console messages.
218 * Idling or resetting omap-uart while printing logs
219 * early boot logs can stall the boot-up.
220 */
221 oh->flags |= HWMOD_INIT_NO_IDLE | HWMOD_INIT_NO_RESET;
222 } 211 }
223 } while (1); 212 } while (1);
224 213
diff --git a/arch/arm/mach-shmobile/board-armadillo800eva.c b/arch/arm/mach-shmobile/board-armadillo800eva.c
index e115f6742107..c5be60d85e4b 100644
--- a/arch/arm/mach-shmobile/board-armadillo800eva.c
+++ b/arch/arm/mach-shmobile/board-armadillo800eva.c
@@ -1162,9 +1162,6 @@ static void __init eva_init(void)
1162 gpio_request_one(61, GPIOF_OUT_INIT_HIGH, NULL); /* LCDDON */ 1162 gpio_request_one(61, GPIOF_OUT_INIT_HIGH, NULL); /* LCDDON */
1163 gpio_request_one(202, GPIOF_OUT_INIT_LOW, NULL); /* LCD0_LED_CONT */ 1163 gpio_request_one(202, GPIOF_OUT_INIT_LOW, NULL); /* LCD0_LED_CONT */
1164 1164
1165 /* Touchscreen */
1166 gpio_request_one(166, GPIOF_OUT_INIT_HIGH, NULL); /* TP_RST_B */
1167
1168 /* GETHER */ 1165 /* GETHER */
1169 gpio_request_one(18, GPIOF_OUT_INIT_HIGH, NULL); /* PHY_RST */ 1166 gpio_request_one(18, GPIOF_OUT_INIT_HIGH, NULL); /* PHY_RST */
1170 1167
diff --git a/arch/arm/mach-shmobile/board-bockw.c b/arch/arm/mach-shmobile/board-bockw.c
index d5554646916c..3354a85c90f7 100644
--- a/arch/arm/mach-shmobile/board-bockw.c
+++ b/arch/arm/mach-shmobile/board-bockw.c
@@ -167,7 +167,13 @@ static const struct pinctrl_map bockw_pinctrl_map[] = {
167 "usb1", "usb1"), 167 "usb1", "usb1"),
168 /* SDHI0 */ 168 /* SDHI0 */
169 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778", 169 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778",
170 "sdhi0", "sdhi0"), 170 "sdhi0_data4", "sdhi0"),
171 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778",
172 "sdhi0_ctrl", "sdhi0"),
173 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778",
174 "sdhi0_cd", "sdhi0"),
175 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778",
176 "sdhi0_wp", "sdhi0"),
171}; 177};
172 178
173#define FPGA 0x18200000 179#define FPGA 0x18200000
diff --git a/arch/arm/mach-shmobile/board-lager.c b/arch/arm/mach-shmobile/board-lager.c
index d73e21d3ea8a..8d6bd5c5efb9 100644
--- a/arch/arm/mach-shmobile/board-lager.c
+++ b/arch/arm/mach-shmobile/board-lager.c
@@ -59,7 +59,7 @@ static __initdata struct gpio_led_platform_data lager_leds_pdata = {
59#define GPIO_KEY(c, g, d, ...) \ 59#define GPIO_KEY(c, g, d, ...) \
60 { .code = c, .gpio = g, .desc = d, .active_low = 1 } 60 { .code = c, .gpio = g, .desc = d, .active_low = 1 }
61 61
62static __initdata struct gpio_keys_button gpio_buttons[] = { 62static struct gpio_keys_button gpio_buttons[] = {
63 GPIO_KEY(KEY_4, RCAR_GP_PIN(1, 28), "SW2-pin4"), 63 GPIO_KEY(KEY_4, RCAR_GP_PIN(1, 28), "SW2-pin4"),
64 GPIO_KEY(KEY_3, RCAR_GP_PIN(1, 26), "SW2-pin3"), 64 GPIO_KEY(KEY_3, RCAR_GP_PIN(1, 26), "SW2-pin3"),
65 GPIO_KEY(KEY_2, RCAR_GP_PIN(1, 24), "SW2-pin2"), 65 GPIO_KEY(KEY_2, RCAR_GP_PIN(1, 24), "SW2-pin2"),
diff --git a/arch/arm/mach-sti/headsmp.S b/arch/arm/mach-sti/headsmp.S
index 78ebc7559f53..4c09bae86edf 100644
--- a/arch/arm/mach-sti/headsmp.S
+++ b/arch/arm/mach-sti/headsmp.S
@@ -16,8 +16,6 @@
16#include <linux/linkage.h> 16#include <linux/linkage.h>
17#include <linux/init.h> 17#include <linux/init.h>
18 18
19 __INIT
20
21/* 19/*
22 * ST specific entry point for secondary CPUs. This provides 20 * ST specific entry point for secondary CPUs. This provides
23 * a "holding pen" into which all secondary cores are held until we're 21 * a "holding pen" into which all secondary cores are held until we're
diff --git a/arch/avr32/boards/atngw100/mrmt.c b/arch/avr32/boards/atngw100/mrmt.c
index f91431963452..7de083d19b7e 100644
--- a/arch/avr32/boards/atngw100/mrmt.c
+++ b/arch/avr32/boards/atngw100/mrmt.c
@@ -150,7 +150,6 @@ static struct ac97c_platform_data __initdata ac97c0_data = {
150static struct platform_device rmt_ts_device = { 150static struct platform_device rmt_ts_device = {
151 .name = "ucb1400_ts", 151 .name = "ucb1400_ts",
152 .id = -1, 152 .id = -1,
153 }
154}; 153};
155#endif 154#endif
156 155
diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h
index 1dc086087a72..fa44f3ec5302 100644
--- a/arch/mips/include/asm/cpu-features.h
+++ b/arch/mips/include/asm/cpu-features.h
@@ -17,6 +17,8 @@
17#define current_cpu_type() current_cpu_data.cputype 17#define current_cpu_type() current_cpu_data.cputype
18#endif 18#endif
19 19
20#define boot_cpu_type() cpu_data[0].cputype
21
20/* 22/*
21 * SMP assumption: Options of CPU 0 are a superset of all processors. 23 * SMP assumption: Options of CPU 0 are a superset of all processors.
22 * This is true for all known MIPS systems. 24 * This is true for all known MIPS systems.
diff --git a/arch/mips/kernel/smp-bmips.c b/arch/mips/kernel/smp-bmips.c
index 159abc8842d2..126da74d4c55 100644
--- a/arch/mips/kernel/smp-bmips.c
+++ b/arch/mips/kernel/smp-bmips.c
@@ -66,6 +66,8 @@ static void __init bmips_smp_setup(void)
66 int i, cpu = 1, boot_cpu = 0; 66 int i, cpu = 1, boot_cpu = 0;
67 67
68#if defined(CONFIG_CPU_BMIPS4350) || defined(CONFIG_CPU_BMIPS4380) 68#if defined(CONFIG_CPU_BMIPS4350) || defined(CONFIG_CPU_BMIPS4380)
69 int cpu_hw_intr;
70
69 /* arbitration priority */ 71 /* arbitration priority */
70 clear_c0_brcm_cmt_ctrl(0x30); 72 clear_c0_brcm_cmt_ctrl(0x30);
71 73
@@ -80,8 +82,12 @@ static void __init bmips_smp_setup(void)
80 * MIPS interrupt 2 (HW INT 0) is the CPU0 L1 controller output 82 * MIPS interrupt 2 (HW INT 0) is the CPU0 L1 controller output
81 * MIPS interrupt 3 (HW INT 1) is the CPU1 L1 controller output 83 * MIPS interrupt 3 (HW INT 1) is the CPU1 L1 controller output
82 */ 84 */
83 change_c0_brcm_cmt_intr(0xf8018000, 85 if (boot_cpu == 0)
84 (0x02 << 27) | (0x03 << 15)); 86 cpu_hw_intr = 0x02;
87 else
88 cpu_hw_intr = 0x1d;
89
90 change_c0_brcm_cmt_intr(0xf8018000, (cpu_hw_intr << 27) | (0x03 << 15));
85 91
86 /* single core, 2 threads (2 pipelines) */ 92 /* single core, 2 threads (2 pipelines) */
87 max_cpus = 2; 93 max_cpus = 2;
diff --git a/arch/mips/oprofile/op_model_mipsxx.c b/arch/mips/oprofile/op_model_mipsxx.c
index e4b1140cdae0..3a2b6e9f25cf 100644
--- a/arch/mips/oprofile/op_model_mipsxx.c
+++ b/arch/mips/oprofile/op_model_mipsxx.c
@@ -166,7 +166,7 @@ static void mipsxx_reg_setup(struct op_counter_config *ctr)
166 reg.control[i] |= M_PERFCTL_USER; 166 reg.control[i] |= M_PERFCTL_USER;
167 if (ctr[i].exl) 167 if (ctr[i].exl)
168 reg.control[i] |= M_PERFCTL_EXL; 168 reg.control[i] |= M_PERFCTL_EXL;
169 if (current_cpu_type() == CPU_XLR) 169 if (boot_cpu_type() == CPU_XLR)
170 reg.control[i] |= M_PERFCTL_COUNT_ALL_THREADS; 170 reg.control[i] |= M_PERFCTL_COUNT_ALL_THREADS;
171 reg.counter[i] = 0x80000000 - ctr[i].count; 171 reg.counter[i] = 0x80000000 - ctr[i].count;
172 } 172 }
diff --git a/arch/mips/pnx833x/common/platform.c b/arch/mips/pnx833x/common/platform.c
index d22dc0d6f289..2b7e837dc2e2 100644
--- a/arch/mips/pnx833x/common/platform.c
+++ b/arch/mips/pnx833x/common/platform.c
@@ -206,11 +206,13 @@ static struct resource pnx833x_ethernet_resources[] = {
206 .end = PNX8335_IP3902_PORTS_END, 206 .end = PNX8335_IP3902_PORTS_END,
207 .flags = IORESOURCE_MEM, 207 .flags = IORESOURCE_MEM,
208 }, 208 },
209#ifdef CONFIG_SOC_PNX8335
209 [1] = { 210 [1] = {
210 .start = PNX8335_PIC_ETHERNET_INT, 211 .start = PNX8335_PIC_ETHERNET_INT,
211 .end = PNX8335_PIC_ETHERNET_INT, 212 .end = PNX8335_PIC_ETHERNET_INT,
212 .flags = IORESOURCE_IRQ, 213 .flags = IORESOURCE_IRQ,
213 }, 214 },
215#endif
214}; 216};
215 217
216static struct platform_device pnx833x_ethernet_device = { 218static struct platform_device pnx833x_ethernet_device = {
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 22f75b504f7f..8a4cae78f03c 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -118,6 +118,7 @@ config S390
118 select HAVE_FUNCTION_TRACE_MCOUNT_TEST 118 select HAVE_FUNCTION_TRACE_MCOUNT_TEST
119 select HAVE_KERNEL_BZIP2 119 select HAVE_KERNEL_BZIP2
120 select HAVE_KERNEL_GZIP 120 select HAVE_KERNEL_GZIP
121 select HAVE_KERNEL_LZ4
121 select HAVE_KERNEL_LZMA 122 select HAVE_KERNEL_LZMA
122 select HAVE_KERNEL_LZO 123 select HAVE_KERNEL_LZO
123 select HAVE_KERNEL_XZ 124 select HAVE_KERNEL_XZ
@@ -227,11 +228,12 @@ config MARCH_Z196
227 not work on older machines. 228 not work on older machines.
228 229
229config MARCH_ZEC12 230config MARCH_ZEC12
230 bool "IBM zEC12" 231 bool "IBM zBC12 and zEC12"
231 select HAVE_MARCH_ZEC12_FEATURES if 64BIT 232 select HAVE_MARCH_ZEC12_FEATURES if 64BIT
232 help 233 help
233 Select this to enable optimizations for IBM zEC12 (2827 series). The 234 Select this to enable optimizations for IBM zBC12 and zEC12 (2828 and
234 kernel will be slightly faster but will not work on older machines. 235 2827 series). The kernel will be slightly faster but will not work on
236 older machines.
235 237
236endchoice 238endchoice
237 239
@@ -709,6 +711,7 @@ config S390_GUEST
709 def_bool y 711 def_bool y
710 prompt "s390 support for virtio devices" 712 prompt "s390 support for virtio devices"
711 depends on 64BIT 713 depends on 64BIT
714 select TTY
712 select VIRTUALIZATION 715 select VIRTUALIZATION
713 select VIRTIO 716 select VIRTIO
714 select VIRTIO_CONSOLE 717 select VIRTIO_CONSOLE
diff --git a/arch/s390/boot/compressed/Makefile b/arch/s390/boot/compressed/Makefile
index 3ad8f61c9985..866ecbe670e4 100644
--- a/arch/s390/boot/compressed/Makefile
+++ b/arch/s390/boot/compressed/Makefile
@@ -6,9 +6,9 @@
6 6
7BITS := $(if $(CONFIG_64BIT),64,31) 7BITS := $(if $(CONFIG_64BIT),64,31)
8 8
9targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 \ 9targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
10 vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo misc.o piggy.o \ 10targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
11 sizes.h head$(BITS).o 11targets += misc.o piggy.o sizes.h head$(BITS).o
12 12
13KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2 13KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2
14KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING 14KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
@@ -48,6 +48,7 @@ vmlinux.bin.all-y := $(obj)/vmlinux.bin
48 48
49suffix-$(CONFIG_KERNEL_GZIP) := gz 49suffix-$(CONFIG_KERNEL_GZIP) := gz
50suffix-$(CONFIG_KERNEL_BZIP2) := bz2 50suffix-$(CONFIG_KERNEL_BZIP2) := bz2
51suffix-$(CONFIG_KERNEL_LZ4) := lz4
51suffix-$(CONFIG_KERNEL_LZMA) := lzma 52suffix-$(CONFIG_KERNEL_LZMA) := lzma
52suffix-$(CONFIG_KERNEL_LZO) := lzo 53suffix-$(CONFIG_KERNEL_LZO) := lzo
53suffix-$(CONFIG_KERNEL_XZ) := xz 54suffix-$(CONFIG_KERNEL_XZ) := xz
@@ -56,6 +57,8 @@ $(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y)
56 $(call if_changed,gzip) 57 $(call if_changed,gzip)
57$(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) 58$(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y)
58 $(call if_changed,bzip2) 59 $(call if_changed,bzip2)
60$(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y)
61 $(call if_changed,lz4)
59$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) 62$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y)
60 $(call if_changed,lzma) 63 $(call if_changed,lzma)
61$(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) 64$(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y)
diff --git a/arch/s390/boot/compressed/misc.c b/arch/s390/boot/compressed/misc.c
index c4c6a1cf221b..57cbaff1f397 100644
--- a/arch/s390/boot/compressed/misc.c
+++ b/arch/s390/boot/compressed/misc.c
@@ -47,6 +47,10 @@ static unsigned long free_mem_end_ptr;
47#include "../../../../lib/decompress_bunzip2.c" 47#include "../../../../lib/decompress_bunzip2.c"
48#endif 48#endif
49 49
50#ifdef CONFIG_KERNEL_LZ4
51#include "../../../../lib/decompress_unlz4.c"
52#endif
53
50#ifdef CONFIG_KERNEL_LZMA 54#ifdef CONFIG_KERNEL_LZMA
51#include "../../../../lib/decompress_unlzma.c" 55#include "../../../../lib/decompress_unlzma.c"
52#endif 56#endif
diff --git a/arch/s390/include/asm/bitops.h b/arch/s390/include/asm/bitops.h
index 4d8604e311f3..7d4676758733 100644
--- a/arch/s390/include/asm/bitops.h
+++ b/arch/s390/include/asm/bitops.h
@@ -693,7 +693,7 @@ static inline int find_next_bit_left(const unsigned long *addr,
693 size -= offset; 693 size -= offset;
694 p = addr + offset / BITS_PER_LONG; 694 p = addr + offset / BITS_PER_LONG;
695 if (bit) { 695 if (bit) {
696 set = __flo_word(0, *p & (~0UL << bit)); 696 set = __flo_word(0, *p & (~0UL >> bit));
697 if (set >= size) 697 if (set >= size)
698 return size + offset; 698 return size + offset;
699 if (set < BITS_PER_LONG) 699 if (set < BITS_PER_LONG)
diff --git a/arch/s390/kernel/perf_event.c b/arch/s390/kernel/perf_event.c
index a6fc037671b1..500aa1029bcb 100644
--- a/arch/s390/kernel/perf_event.c
+++ b/arch/s390/kernel/perf_event.c
@@ -52,12 +52,13 @@ static struct kvm_s390_sie_block *sie_block(struct pt_regs *regs)
52 52
53static bool is_in_guest(struct pt_regs *regs) 53static bool is_in_guest(struct pt_regs *regs)
54{ 54{
55 unsigned long ip = instruction_pointer(regs);
56
57 if (user_mode(regs)) 55 if (user_mode(regs))
58 return false; 56 return false;
59 57#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
60 return ip == (unsigned long) &sie_exit; 58 return instruction_pointer(regs) == (unsigned long) &sie_exit;
59#else
60 return false;
61#endif
61} 62}
62 63
63static unsigned long guest_is_user_mode(struct pt_regs *regs) 64static unsigned long guest_is_user_mode(struct pt_regs *regs)
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index 497451ec5e26..aeed8a61fa0d 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -994,6 +994,7 @@ static void __init setup_hwcaps(void)
994 strcpy(elf_platform, "z196"); 994 strcpy(elf_platform, "z196");
995 break; 995 break;
996 case 0x2827: 996 case 0x2827:
997 case 0x2828:
997 strcpy(elf_platform, "zEC12"); 998 strcpy(elf_platform, "zEC12");
998 break; 999 break;
999 } 1000 }
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index ce36ea80e4f9..ad446b0c55b6 100644
--- a/arch/s390/mm/init.c
+++ b/arch/s390/mm/init.c
@@ -69,6 +69,7 @@ static void __init setup_zero_pages(void)
69 order = 2; 69 order = 2;
70 break; 70 break;
71 case 0x2827: /* zEC12 */ 71 case 0x2827: /* zEC12 */
72 case 0x2828: /* zEC12 */
72 default: 73 default:
73 order = 5; 74 order = 5;
74 break; 75 break;
diff --git a/arch/s390/oprofile/init.c b/arch/s390/oprofile/init.c
index ffeb17ce7f31..930783d2c99b 100644
--- a/arch/s390/oprofile/init.c
+++ b/arch/s390/oprofile/init.c
@@ -440,7 +440,7 @@ static int oprofile_hwsampler_init(struct oprofile_operations *ops)
440 switch (id.machine) { 440 switch (id.machine) {
441 case 0x2097: case 0x2098: ops->cpu_type = "s390/z10"; break; 441 case 0x2097: case 0x2098: ops->cpu_type = "s390/z10"; break;
442 case 0x2817: case 0x2818: ops->cpu_type = "s390/z196"; break; 442 case 0x2817: case 0x2818: ops->cpu_type = "s390/z196"; break;
443 case 0x2827: ops->cpu_type = "s390/zEC12"; break; 443 case 0x2827: case 0x2828: ops->cpu_type = "s390/zEC12"; break;
444 default: return -ENODEV; 444 default: return -ENODEV;
445 } 445 }
446 } 446 }
diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
index d606463aa6d6..b7388a425f09 100644
--- a/arch/x86/boot/compressed/eboot.c
+++ b/arch/x86/boot/compressed/eboot.c
@@ -225,7 +225,7 @@ static void low_free(unsigned long size, unsigned long addr)
225 unsigned long nr_pages; 225 unsigned long nr_pages;
226 226
227 nr_pages = round_up(size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE; 227 nr_pages = round_up(size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE;
228 efi_call_phys2(sys_table->boottime->free_pages, addr, size); 228 efi_call_phys2(sys_table->boottime->free_pages, addr, nr_pages);
229} 229}
230 230
231static void find_bits(unsigned long mask, u8 *pos, u8 *size) 231static void find_bits(unsigned long mask, u8 *pos, u8 *size)
diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c
index 94ab6b90dd3f..63bdb29b2549 100644
--- a/arch/x86/kernel/early-quirks.c
+++ b/arch/x86/kernel/early-quirks.c
@@ -196,15 +196,23 @@ static void __init ati_bugs_contd(int num, int slot, int func)
196static void __init intel_remapping_check(int num, int slot, int func) 196static void __init intel_remapping_check(int num, int slot, int func)
197{ 197{
198 u8 revision; 198 u8 revision;
199 u16 device;
199 200
201 device = read_pci_config_16(num, slot, func, PCI_DEVICE_ID);
200 revision = read_pci_config_byte(num, slot, func, PCI_REVISION_ID); 202 revision = read_pci_config_byte(num, slot, func, PCI_REVISION_ID);
201 203
202 /* 204 /*
203 * Revision 0x13 of this chipset supports irq remapping 205 * Revision 13 of all triggering devices id in this quirk have
204 * but has an erratum that breaks its behavior, flag it as such 206 * a problem draining interrupts when irq remapping is enabled,
207 * and should be flagged as broken. Additionally revisions 0x12
208 * and 0x22 of device id 0x3405 has this problem.
205 */ 209 */
206 if (revision == 0x13) 210 if (revision == 0x13)
207 set_irq_remapping_broken(); 211 set_irq_remapping_broken();
212 else if ((device == 0x3405) &&
213 ((revision == 0x12) ||
214 (revision == 0x22)))
215 set_irq_remapping_broken();
208 216
209} 217}
210 218
@@ -239,6 +247,8 @@ static struct chipset early_qrk[] __initdata = {
239 PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs_contd }, 247 PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs_contd },
240 { PCI_VENDOR_ID_INTEL, 0x3403, PCI_CLASS_BRIDGE_HOST, 248 { PCI_VENDOR_ID_INTEL, 0x3403, PCI_CLASS_BRIDGE_HOST,
241 PCI_BASE_CLASS_BRIDGE, 0, intel_remapping_check }, 249 PCI_BASE_CLASS_BRIDGE, 0, intel_remapping_check },
250 { PCI_VENDOR_ID_INTEL, 0x3405, PCI_CLASS_BRIDGE_HOST,
251 PCI_BASE_CLASS_BRIDGE, 0, intel_remapping_check },
242 { PCI_VENDOR_ID_INTEL, 0x3406, PCI_CLASS_BRIDGE_HOST, 252 { PCI_VENDOR_ID_INTEL, 0x3406, PCI_CLASS_BRIDGE_HOST,
243 PCI_BASE_CLASS_BRIDGE, 0, intel_remapping_check }, 253 PCI_BASE_CLASS_BRIDGE, 0, intel_remapping_check },
244 {} 254 {}
diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
index 202d24f0f7e7..5d576ab34403 100644
--- a/arch/x86/kernel/i387.c
+++ b/arch/x86/kernel/i387.c
@@ -116,7 +116,7 @@ static void mxcsr_feature_mask_init(void)
116 116
117 if (cpu_has_fxsr) { 117 if (cpu_has_fxsr) {
118 memset(&fx_scratch, 0, sizeof(struct i387_fxsave_struct)); 118 memset(&fx_scratch, 0, sizeof(struct i387_fxsave_struct));
119 asm volatile("fxsave %0" : : "m" (fx_scratch)); 119 asm volatile("fxsave %0" : "+m" (fx_scratch));
120 mask = fx_scratch.mxcsr_mask; 120 mask = fx_scratch.mxcsr_mask;
121 if (mask == 0) 121 if (mask == 0)
122 mask = 0x0000ffbf; 122 mask = 0x0000ffbf;
diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c
index 47ebb1dbfbcb..7a0adb7ee433 100644
--- a/arch/x86/kernel/microcode_amd.c
+++ b/arch/x86/kernel/microcode_amd.c
@@ -220,12 +220,13 @@ int apply_microcode_amd(int cpu)
220 return 0; 220 return 0;
221 } 221 }
222 222
223 if (__apply_microcode_amd(mc_amd)) 223 if (__apply_microcode_amd(mc_amd)) {
224 pr_err("CPU%d: update failed for patch_level=0x%08x\n", 224 pr_err("CPU%d: update failed for patch_level=0x%08x\n",
225 cpu, mc_amd->hdr.patch_id); 225 cpu, mc_amd->hdr.patch_id);
226 else 226 return -1;
227 pr_info("CPU%d: new patch_level=0x%08x\n", cpu, 227 }
228 mc_amd->hdr.patch_id); 228 pr_info("CPU%d: new patch_level=0x%08x\n", cpu,
229 mc_amd->hdr.patch_id);
229 230
230 uci->cpu_sig.rev = mc_amd->hdr.patch_id; 231 uci->cpu_sig.rev = mc_amd->hdr.patch_id;
231 c->microcode = mc_amd->hdr.patch_id; 232 c->microcode = mc_amd->hdr.patch_id;
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index fd6c51cc3acb..5a74a9c1e42c 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -451,7 +451,6 @@ static void acpi_processor_remove(struct acpi_device *device)
451 /* Clean up. */ 451 /* Clean up. */
452 per_cpu(processor_device_array, pr->id) = NULL; 452 per_cpu(processor_device_array, pr->id) = NULL;
453 per_cpu(processors, pr->id) = NULL; 453 per_cpu(processors, pr->id) = NULL;
454 try_offline_node(cpu_to_node(pr->id));
455 454
456 /* Remove the CPU. */ 455 /* Remove the CPU. */
457 get_online_cpus(); 456 get_online_cpus();
@@ -459,6 +458,8 @@ static void acpi_processor_remove(struct acpi_device *device)
459 acpi_unmap_lsapic(pr->id); 458 acpi_unmap_lsapic(pr->id);
460 put_online_cpus(); 459 put_online_cpus();
461 460
461 try_offline_node(cpu_to_node(pr->id));
462
462 out: 463 out:
463 free_cpumask_var(pr->throttling.shared_cpu_map); 464 free_cpumask_var(pr->throttling.shared_cpu_map);
464 kfree(pr); 465 kfree(pr);
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index f68095756fb7..408f6b2a5fa8 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -31,6 +31,7 @@ static LIST_HEAD(bus_type_list);
31static DECLARE_RWSEM(bus_type_sem); 31static DECLARE_RWSEM(bus_type_sem);
32 32
33#define PHYSICAL_NODE_STRING "physical_node" 33#define PHYSICAL_NODE_STRING "physical_node"
34#define PHYSICAL_NODE_NAME_SIZE (sizeof(PHYSICAL_NODE_STRING) + 10)
34 35
35int register_acpi_bus_type(struct acpi_bus_type *type) 36int register_acpi_bus_type(struct acpi_bus_type *type)
36{ 37{
@@ -78,41 +79,108 @@ static struct acpi_bus_type *acpi_get_bus_type(struct device *dev)
78 return ret; 79 return ret;
79} 80}
80 81
81static acpi_status do_acpi_find_child(acpi_handle handle, u32 lvl_not_used, 82static acpi_status acpi_dev_present(acpi_handle handle, u32 lvl_not_used,
82 void *addr_p, void **ret_p) 83 void *not_used, void **ret_p)
83{ 84{
84 unsigned long long addr, sta; 85 struct acpi_device *adev = NULL;
85 acpi_status status;
86 86
87 status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &addr); 87 acpi_bus_get_device(handle, &adev);
88 if (ACPI_SUCCESS(status) && addr == *((u64 *)addr_p)) { 88 if (adev) {
89 *ret_p = handle; 89 *ret_p = handle;
90 status = acpi_bus_get_status_handle(handle, &sta); 90 return AE_CTRL_TERMINATE;
91 if (ACPI_SUCCESS(status) && (sta & ACPI_STA_DEVICE_ENABLED))
92 return AE_CTRL_TERMINATE;
93 } 91 }
94 return AE_OK; 92 return AE_OK;
95} 93}
96 94
97acpi_handle acpi_get_child(acpi_handle parent, u64 address) 95static bool acpi_extra_checks_passed(acpi_handle handle, bool is_bridge)
98{ 96{
99 void *ret = NULL; 97 unsigned long long sta;
98 acpi_status status;
99
100 status = acpi_bus_get_status_handle(handle, &sta);
101 if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_ENABLED))
102 return false;
103
104 if (is_bridge) {
105 void *test = NULL;
106
107 /* Check if this object has at least one child device. */
108 acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1,
109 acpi_dev_present, NULL, NULL, &test);
110 return !!test;
111 }
112 return true;
113}
114
115struct find_child_context {
116 u64 addr;
117 bool is_bridge;
118 acpi_handle ret;
119 bool ret_checked;
120};
121
122static acpi_status do_find_child(acpi_handle handle, u32 lvl_not_used,
123 void *data, void **not_used)
124{
125 struct find_child_context *context = data;
126 unsigned long long addr;
127 acpi_status status;
100 128
101 if (!parent) 129 status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &addr);
102 return NULL; 130 if (ACPI_FAILURE(status) || addr != context->addr)
131 return AE_OK;
103 132
104 acpi_walk_namespace(ACPI_TYPE_DEVICE, parent, 1, NULL, 133 if (!context->ret) {
105 do_acpi_find_child, &address, &ret); 134 /* This is the first matching object. Save its handle. */
106 return (acpi_handle)ret; 135 context->ret = handle;
136 return AE_OK;
137 }
138 /*
139 * There is more than one matching object with the same _ADR value.
140 * That really is unexpected, so we are kind of beyond the scope of the
141 * spec here. We have to choose which one to return, though.
142 *
143 * First, check if the previously found object is good enough and return
144 * its handle if so. Second, check the same for the object that we've
145 * just found.
146 */
147 if (!context->ret_checked) {
148 if (acpi_extra_checks_passed(context->ret, context->is_bridge))
149 return AE_CTRL_TERMINATE;
150 else
151 context->ret_checked = true;
152 }
153 if (acpi_extra_checks_passed(handle, context->is_bridge)) {
154 context->ret = handle;
155 return AE_CTRL_TERMINATE;
156 }
157 return AE_OK;
107} 158}
108EXPORT_SYMBOL(acpi_get_child); 159
160acpi_handle acpi_find_child(acpi_handle parent, u64 addr, bool is_bridge)
161{
162 if (parent) {
163 struct find_child_context context = {
164 .addr = addr,
165 .is_bridge = is_bridge,
166 };
167
168 acpi_walk_namespace(ACPI_TYPE_DEVICE, parent, 1, do_find_child,
169 NULL, &context, NULL);
170 return context.ret;
171 }
172 return NULL;
173}
174EXPORT_SYMBOL_GPL(acpi_find_child);
109 175
110int acpi_bind_one(struct device *dev, acpi_handle handle) 176int acpi_bind_one(struct device *dev, acpi_handle handle)
111{ 177{
112 struct acpi_device *acpi_dev; 178 struct acpi_device *acpi_dev;
113 acpi_status status; 179 acpi_status status;
114 struct acpi_device_physical_node *physical_node, *pn; 180 struct acpi_device_physical_node *physical_node, *pn;
115 char physical_node_name[sizeof(PHYSICAL_NODE_STRING) + 2]; 181 char physical_node_name[PHYSICAL_NODE_NAME_SIZE];
182 struct list_head *physnode_list;
183 unsigned int node_id;
116 int retval = -EINVAL; 184 int retval = -EINVAL;
117 185
118 if (ACPI_HANDLE(dev)) { 186 if (ACPI_HANDLE(dev)) {
@@ -139,25 +207,27 @@ int acpi_bind_one(struct device *dev, acpi_handle handle)
139 207
140 mutex_lock(&acpi_dev->physical_node_lock); 208 mutex_lock(&acpi_dev->physical_node_lock);
141 209
142 /* Sanity check. */ 210 /*
143 list_for_each_entry(pn, &acpi_dev->physical_node_list, node) 211 * Keep the list sorted by node_id so that the IDs of removed nodes can
212 * be recycled easily.
213 */
214 physnode_list = &acpi_dev->physical_node_list;
215 node_id = 0;
216 list_for_each_entry(pn, &acpi_dev->physical_node_list, node) {
217 /* Sanity check. */
144 if (pn->dev == dev) { 218 if (pn->dev == dev) {
145 dev_warn(dev, "Already associated with ACPI node\n"); 219 dev_warn(dev, "Already associated with ACPI node\n");
146 goto err_free; 220 goto err_free;
147 } 221 }
148 222 if (pn->node_id == node_id) {
149 /* allocate physical node id according to physical_node_id_bitmap */ 223 physnode_list = &pn->node;
150 physical_node->node_id = 224 node_id++;
151 find_first_zero_bit(acpi_dev->physical_node_id_bitmap, 225 }
152 ACPI_MAX_PHYSICAL_NODE);
153 if (physical_node->node_id >= ACPI_MAX_PHYSICAL_NODE) {
154 retval = -ENOSPC;
155 goto err_free;
156 } 226 }
157 227
158 set_bit(physical_node->node_id, acpi_dev->physical_node_id_bitmap); 228 physical_node->node_id = node_id;
159 physical_node->dev = dev; 229 physical_node->dev = dev;
160 list_add_tail(&physical_node->node, &acpi_dev->physical_node_list); 230 list_add(&physical_node->node, physnode_list);
161 acpi_dev->physical_node_count++; 231 acpi_dev->physical_node_count++;
162 232
163 mutex_unlock(&acpi_dev->physical_node_lock); 233 mutex_unlock(&acpi_dev->physical_node_lock);
@@ -208,7 +278,7 @@ int acpi_unbind_one(struct device *dev)
208 278
209 mutex_lock(&acpi_dev->physical_node_lock); 279 mutex_lock(&acpi_dev->physical_node_lock);
210 list_for_each_safe(node, next, &acpi_dev->physical_node_list) { 280 list_for_each_safe(node, next, &acpi_dev->physical_node_list) {
211 char physical_node_name[sizeof(PHYSICAL_NODE_STRING) + 2]; 281 char physical_node_name[PHYSICAL_NODE_NAME_SIZE];
212 282
213 entry = list_entry(node, struct acpi_device_physical_node, 283 entry = list_entry(node, struct acpi_device_physical_node,
214 node); 284 node);
@@ -216,7 +286,6 @@ int acpi_unbind_one(struct device *dev)
216 continue; 286 continue;
217 287
218 list_del(node); 288 list_del(node);
219 clear_bit(entry->node_id, acpi_dev->physical_node_id_bitmap);
220 289
221 acpi_dev->physical_node_count--; 290 acpi_dev->physical_node_count--;
222 291
diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c
index aa1227a7e3f2..04a13784dd20 100644
--- a/drivers/acpi/proc.c
+++ b/drivers/acpi/proc.c
@@ -311,6 +311,8 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
311 dev->pnp.bus_id, 311 dev->pnp.bus_id,
312 (u32) dev->wakeup.sleep_state); 312 (u32) dev->wakeup.sleep_state);
313 313
314 mutex_lock(&dev->physical_node_lock);
315
314 if (!dev->physical_node_count) { 316 if (!dev->physical_node_count) {
315 seq_printf(seq, "%c%-8s\n", 317 seq_printf(seq, "%c%-8s\n",
316 dev->wakeup.flags.run_wake ? '*' : ' ', 318 dev->wakeup.flags.run_wake ? '*' : ' ',
@@ -338,6 +340,8 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
338 put_device(ldev); 340 put_device(ldev);
339 } 341 }
340 } 342 }
343
344 mutex_unlock(&dev->physical_node_lock);
341 } 345 }
342 mutex_unlock(&acpi_device_lock); 346 mutex_unlock(&acpi_device_lock);
343 return 0; 347 return 0;
@@ -347,12 +351,16 @@ static void physical_device_enable_wakeup(struct acpi_device *adev)
347{ 351{
348 struct acpi_device_physical_node *entry; 352 struct acpi_device_physical_node *entry;
349 353
354 mutex_lock(&adev->physical_node_lock);
355
350 list_for_each_entry(entry, 356 list_for_each_entry(entry,
351 &adev->physical_node_list, node) 357 &adev->physical_node_list, node)
352 if (entry->dev && device_can_wakeup(entry->dev)) { 358 if (entry->dev && device_can_wakeup(entry->dev)) {
353 bool enable = !device_may_wakeup(entry->dev); 359 bool enable = !device_may_wakeup(entry->dev);
354 device_set_wakeup_enable(entry->dev, enable); 360 device_set_wakeup_enable(entry->dev, enable);
355 } 361 }
362
363 mutex_unlock(&adev->physical_node_lock);
356} 364}
357 365
358static ssize_t 366static ssize_t
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 0ec434d2586d..e1284b8dc6ee 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -689,7 +689,7 @@ static int acpi_video_bqc_quirk(struct acpi_video_device *device,
689 * Some systems always report current brightness level as maximum 689 * Some systems always report current brightness level as maximum
690 * through _BQC, we need to test another value for them. 690 * through _BQC, we need to test another value for them.
691 */ 691 */
692 test_level = current_level == max_level ? br->levels[2] : max_level; 692 test_level = current_level == max_level ? br->levels[3] : max_level;
693 693
694 result = acpi_video_device_lcd_set_level(device, test_level); 694 result = acpi_video_device_lcd_set_level(device, test_level);
695 if (result) 695 if (result)
diff --git a/drivers/ata/pata_imx.c b/drivers/ata/pata_imx.c
index 4ec7c04b3f82..26386f0b89a8 100644
--- a/drivers/ata/pata_imx.c
+++ b/drivers/ata/pata_imx.c
@@ -237,6 +237,7 @@ static const struct of_device_id imx_pata_dt_ids[] = {
237 /* sentinel */ 237 /* sentinel */
238 } 238 }
239}; 239};
240MODULE_DEVICE_TABLE(of, imx_pata_dt_ids);
240 241
241static struct platform_driver pata_imx_driver = { 242static struct platform_driver pata_imx_driver = {
242 .probe = pata_imx_probe, 243 .probe = pata_imx_probe,
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index e69102696533..3455f833e473 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -719,7 +719,8 @@ static int regcache_sync_block_raw(struct regmap *map, void *block,
719 } 719 }
720 } 720 }
721 721
722 return regcache_sync_block_raw_flush(map, &data, base, regtmp); 722 return regcache_sync_block_raw_flush(map, &data, base, regtmp +
723 map->reg_stride);
723} 724}
724 725
725int regcache_sync_block(struct regmap *map, void *block, 726int regcache_sync_block(struct regmap *map, void *block,
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 1b456fe9b87a..fc45567ad3ac 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -272,9 +272,12 @@ static struct port *find_port_by_devt_in_portdev(struct ports_device *portdev,
272 unsigned long flags; 272 unsigned long flags;
273 273
274 spin_lock_irqsave(&portdev->ports_lock, flags); 274 spin_lock_irqsave(&portdev->ports_lock, flags);
275 list_for_each_entry(port, &portdev->ports, list) 275 list_for_each_entry(port, &portdev->ports, list) {
276 if (port->cdev->dev == dev) 276 if (port->cdev->dev == dev) {
277 kref_get(&port->kref);
277 goto out; 278 goto out;
279 }
280 }
278 port = NULL; 281 port = NULL;
279out: 282out:
280 spin_unlock_irqrestore(&portdev->ports_lock, flags); 283 spin_unlock_irqrestore(&portdev->ports_lock, flags);
@@ -746,6 +749,10 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
746 749
747 port = filp->private_data; 750 port = filp->private_data;
748 751
752 /* Port is hot-unplugged. */
753 if (!port->guest_connected)
754 return -ENODEV;
755
749 if (!port_has_data(port)) { 756 if (!port_has_data(port)) {
750 /* 757 /*
751 * If nothing's connected on the host just return 0 in 758 * If nothing's connected on the host just return 0 in
@@ -762,7 +769,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
762 if (ret < 0) 769 if (ret < 0)
763 return ret; 770 return ret;
764 } 771 }
765 /* Port got hot-unplugged. */ 772 /* Port got hot-unplugged while we were waiting above. */
766 if (!port->guest_connected) 773 if (!port->guest_connected)
767 return -ENODEV; 774 return -ENODEV;
768 /* 775 /*
@@ -932,13 +939,25 @@ static ssize_t port_fops_splice_write(struct pipe_inode_info *pipe,
932 if (is_rproc_serial(port->out_vq->vdev)) 939 if (is_rproc_serial(port->out_vq->vdev))
933 return -EINVAL; 940 return -EINVAL;
934 941
942 /*
943 * pipe->nrbufs == 0 means there are no data to transfer,
944 * so this returns just 0 for no data.
945 */
946 pipe_lock(pipe);
947 if (!pipe->nrbufs) {
948 ret = 0;
949 goto error_out;
950 }
951
935 ret = wait_port_writable(port, filp->f_flags & O_NONBLOCK); 952 ret = wait_port_writable(port, filp->f_flags & O_NONBLOCK);
936 if (ret < 0) 953 if (ret < 0)
937 return ret; 954 goto error_out;
938 955
939 buf = alloc_buf(port->out_vq, 0, pipe->nrbufs); 956 buf = alloc_buf(port->out_vq, 0, pipe->nrbufs);
940 if (!buf) 957 if (!buf) {
941 return -ENOMEM; 958 ret = -ENOMEM;
959 goto error_out;
960 }
942 961
943 sgl.n = 0; 962 sgl.n = 0;
944 sgl.len = 0; 963 sgl.len = 0;
@@ -946,12 +965,17 @@ static ssize_t port_fops_splice_write(struct pipe_inode_info *pipe,
946 sgl.sg = buf->sg; 965 sgl.sg = buf->sg;
947 sg_init_table(sgl.sg, sgl.size); 966 sg_init_table(sgl.sg, sgl.size);
948 ret = __splice_from_pipe(pipe, &sd, pipe_to_sg); 967 ret = __splice_from_pipe(pipe, &sd, pipe_to_sg);
968 pipe_unlock(pipe);
949 if (likely(ret > 0)) 969 if (likely(ret > 0))
950 ret = __send_to_port(port, buf->sg, sgl.n, sgl.len, buf, true); 970 ret = __send_to_port(port, buf->sg, sgl.n, sgl.len, buf, true);
951 971
952 if (unlikely(ret <= 0)) 972 if (unlikely(ret <= 0))
953 free_buf(buf, true); 973 free_buf(buf, true);
954 return ret; 974 return ret;
975
976error_out:
977 pipe_unlock(pipe);
978 return ret;
955} 979}
956 980
957static unsigned int port_fops_poll(struct file *filp, poll_table *wait) 981static unsigned int port_fops_poll(struct file *filp, poll_table *wait)
@@ -1019,14 +1043,14 @@ static int port_fops_open(struct inode *inode, struct file *filp)
1019 struct port *port; 1043 struct port *port;
1020 int ret; 1044 int ret;
1021 1045
1046 /* We get the port with a kref here */
1022 port = find_port_by_devt(cdev->dev); 1047 port = find_port_by_devt(cdev->dev);
1048 if (!port) {
1049 /* Port was unplugged before we could proceed */
1050 return -ENXIO;
1051 }
1023 filp->private_data = port; 1052 filp->private_data = port;
1024 1053
1025 /* Prevent against a port getting hot-unplugged at the same time */
1026 spin_lock_irq(&port->portdev->ports_lock);
1027 kref_get(&port->kref);
1028 spin_unlock_irq(&port->portdev->ports_lock);
1029
1030 /* 1054 /*
1031 * Don't allow opening of console port devices -- that's done 1055 * Don't allow opening of console port devices -- that's done
1032 * via /dev/hvc 1056 * via /dev/hvc
@@ -1498,14 +1522,6 @@ static void remove_port(struct kref *kref)
1498 1522
1499 port = container_of(kref, struct port, kref); 1523 port = container_of(kref, struct port, kref);
1500 1524
1501 sysfs_remove_group(&port->dev->kobj, &port_attribute_group);
1502 device_destroy(pdrvdata.class, port->dev->devt);
1503 cdev_del(port->cdev);
1504
1505 kfree(port->name);
1506
1507 debugfs_remove(port->debugfs_file);
1508
1509 kfree(port); 1525 kfree(port);
1510} 1526}
1511 1527
@@ -1539,12 +1555,14 @@ static void unplug_port(struct port *port)
1539 spin_unlock_irq(&port->portdev->ports_lock); 1555 spin_unlock_irq(&port->portdev->ports_lock);
1540 1556
1541 if (port->guest_connected) { 1557 if (port->guest_connected) {
1558 /* Let the app know the port is going down. */
1559 send_sigio_to_port(port);
1560
1561 /* Do this after sigio is actually sent */
1542 port->guest_connected = false; 1562 port->guest_connected = false;
1543 port->host_connected = false; 1563 port->host_connected = false;
1544 wake_up_interruptible(&port->waitqueue);
1545 1564
1546 /* Let the app know the port is going down. */ 1565 wake_up_interruptible(&port->waitqueue);
1547 send_sigio_to_port(port);
1548 } 1566 }
1549 1567
1550 if (is_console_port(port)) { 1568 if (is_console_port(port)) {
@@ -1563,6 +1581,14 @@ static void unplug_port(struct port *port)
1563 */ 1581 */
1564 port->portdev = NULL; 1582 port->portdev = NULL;
1565 1583
1584 sysfs_remove_group(&port->dev->kobj, &port_attribute_group);
1585 device_destroy(pdrvdata.class, port->dev->devt);
1586 cdev_del(port->cdev);
1587
1588 kfree(port->name);
1589
1590 debugfs_remove(port->debugfs_file);
1591
1566 /* 1592 /*
1567 * Locks around here are not necessary - a port can't be 1593 * Locks around here are not necessary - a port can't be
1568 * opened after we removed the port struct from ports_list 1594 * opened after we removed the port struct from ports_list
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
index 0ceb2eff5a7e..f97cb3d8c5a2 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -221,8 +221,8 @@ static ssize_t store_down_threshold(struct dbs_data *dbs_data, const char *buf,
221 return count; 221 return count;
222} 222}
223 223
224static ssize_t store_ignore_nice(struct dbs_data *dbs_data, const char *buf, 224static ssize_t store_ignore_nice_load(struct dbs_data *dbs_data,
225 size_t count) 225 const char *buf, size_t count)
226{ 226{
227 struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; 227 struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
228 unsigned int input, j; 228 unsigned int input, j;
@@ -235,10 +235,10 @@ static ssize_t store_ignore_nice(struct dbs_data *dbs_data, const char *buf,
235 if (input > 1) 235 if (input > 1)
236 input = 1; 236 input = 1;
237 237
238 if (input == cs_tuners->ignore_nice) /* nothing to do */ 238 if (input == cs_tuners->ignore_nice_load) /* nothing to do */
239 return count; 239 return count;
240 240
241 cs_tuners->ignore_nice = input; 241 cs_tuners->ignore_nice_load = input;
242 242
243 /* we need to re-evaluate prev_cpu_idle */ 243 /* we need to re-evaluate prev_cpu_idle */
244 for_each_online_cpu(j) { 244 for_each_online_cpu(j) {
@@ -246,7 +246,7 @@ static ssize_t store_ignore_nice(struct dbs_data *dbs_data, const char *buf,
246 dbs_info = &per_cpu(cs_cpu_dbs_info, j); 246 dbs_info = &per_cpu(cs_cpu_dbs_info, j);
247 dbs_info->cdbs.prev_cpu_idle = get_cpu_idle_time(j, 247 dbs_info->cdbs.prev_cpu_idle = get_cpu_idle_time(j,
248 &dbs_info->cdbs.prev_cpu_wall, 0); 248 &dbs_info->cdbs.prev_cpu_wall, 0);
249 if (cs_tuners->ignore_nice) 249 if (cs_tuners->ignore_nice_load)
250 dbs_info->cdbs.prev_cpu_nice = 250 dbs_info->cdbs.prev_cpu_nice =
251 kcpustat_cpu(j).cpustat[CPUTIME_NICE]; 251 kcpustat_cpu(j).cpustat[CPUTIME_NICE];
252 } 252 }
@@ -279,7 +279,7 @@ show_store_one(cs, sampling_rate);
279show_store_one(cs, sampling_down_factor); 279show_store_one(cs, sampling_down_factor);
280show_store_one(cs, up_threshold); 280show_store_one(cs, up_threshold);
281show_store_one(cs, down_threshold); 281show_store_one(cs, down_threshold);
282show_store_one(cs, ignore_nice); 282show_store_one(cs, ignore_nice_load);
283show_store_one(cs, freq_step); 283show_store_one(cs, freq_step);
284declare_show_sampling_rate_min(cs); 284declare_show_sampling_rate_min(cs);
285 285
@@ -287,7 +287,7 @@ gov_sys_pol_attr_rw(sampling_rate);
287gov_sys_pol_attr_rw(sampling_down_factor); 287gov_sys_pol_attr_rw(sampling_down_factor);
288gov_sys_pol_attr_rw(up_threshold); 288gov_sys_pol_attr_rw(up_threshold);
289gov_sys_pol_attr_rw(down_threshold); 289gov_sys_pol_attr_rw(down_threshold);
290gov_sys_pol_attr_rw(ignore_nice); 290gov_sys_pol_attr_rw(ignore_nice_load);
291gov_sys_pol_attr_rw(freq_step); 291gov_sys_pol_attr_rw(freq_step);
292gov_sys_pol_attr_ro(sampling_rate_min); 292gov_sys_pol_attr_ro(sampling_rate_min);
293 293
@@ -297,7 +297,7 @@ static struct attribute *dbs_attributes_gov_sys[] = {
297 &sampling_down_factor_gov_sys.attr, 297 &sampling_down_factor_gov_sys.attr,
298 &up_threshold_gov_sys.attr, 298 &up_threshold_gov_sys.attr,
299 &down_threshold_gov_sys.attr, 299 &down_threshold_gov_sys.attr,
300 &ignore_nice_gov_sys.attr, 300 &ignore_nice_load_gov_sys.attr,
301 &freq_step_gov_sys.attr, 301 &freq_step_gov_sys.attr,
302 NULL 302 NULL
303}; 303};
@@ -313,7 +313,7 @@ static struct attribute *dbs_attributes_gov_pol[] = {
313 &sampling_down_factor_gov_pol.attr, 313 &sampling_down_factor_gov_pol.attr,
314 &up_threshold_gov_pol.attr, 314 &up_threshold_gov_pol.attr,
315 &down_threshold_gov_pol.attr, 315 &down_threshold_gov_pol.attr,
316 &ignore_nice_gov_pol.attr, 316 &ignore_nice_load_gov_pol.attr,
317 &freq_step_gov_pol.attr, 317 &freq_step_gov_pol.attr,
318 NULL 318 NULL
319}; 319};
@@ -338,7 +338,7 @@ static int cs_init(struct dbs_data *dbs_data)
338 tuners->up_threshold = DEF_FREQUENCY_UP_THRESHOLD; 338 tuners->up_threshold = DEF_FREQUENCY_UP_THRESHOLD;
339 tuners->down_threshold = DEF_FREQUENCY_DOWN_THRESHOLD; 339 tuners->down_threshold = DEF_FREQUENCY_DOWN_THRESHOLD;
340 tuners->sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR; 340 tuners->sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR;
341 tuners->ignore_nice = 0; 341 tuners->ignore_nice_load = 0;
342 tuners->freq_step = DEF_FREQUENCY_STEP; 342 tuners->freq_step = DEF_FREQUENCY_STEP;
343 343
344 dbs_data->tuners = tuners; 344 dbs_data->tuners = tuners;
diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
index 7b839a8db2a7..e59afaa9da23 100644
--- a/drivers/cpufreq/cpufreq_governor.c
+++ b/drivers/cpufreq/cpufreq_governor.c
@@ -47,9 +47,9 @@ void dbs_check_cpu(struct dbs_data *dbs_data, int cpu)
47 unsigned int j; 47 unsigned int j;
48 48
49 if (dbs_data->cdata->governor == GOV_ONDEMAND) 49 if (dbs_data->cdata->governor == GOV_ONDEMAND)
50 ignore_nice = od_tuners->ignore_nice; 50 ignore_nice = od_tuners->ignore_nice_load;
51 else 51 else
52 ignore_nice = cs_tuners->ignore_nice; 52 ignore_nice = cs_tuners->ignore_nice_load;
53 53
54 policy = cdbs->cur_policy; 54 policy = cdbs->cur_policy;
55 55
@@ -298,12 +298,12 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
298 cs_tuners = dbs_data->tuners; 298 cs_tuners = dbs_data->tuners;
299 cs_dbs_info = dbs_data->cdata->get_cpu_dbs_info_s(cpu); 299 cs_dbs_info = dbs_data->cdata->get_cpu_dbs_info_s(cpu);
300 sampling_rate = cs_tuners->sampling_rate; 300 sampling_rate = cs_tuners->sampling_rate;
301 ignore_nice = cs_tuners->ignore_nice; 301 ignore_nice = cs_tuners->ignore_nice_load;
302 } else { 302 } else {
303 od_tuners = dbs_data->tuners; 303 od_tuners = dbs_data->tuners;
304 od_dbs_info = dbs_data->cdata->get_cpu_dbs_info_s(cpu); 304 od_dbs_info = dbs_data->cdata->get_cpu_dbs_info_s(cpu);
305 sampling_rate = od_tuners->sampling_rate; 305 sampling_rate = od_tuners->sampling_rate;
306 ignore_nice = od_tuners->ignore_nice; 306 ignore_nice = od_tuners->ignore_nice_load;
307 od_ops = dbs_data->cdata->gov_ops; 307 od_ops = dbs_data->cdata->gov_ops;
308 io_busy = od_tuners->io_is_busy; 308 io_busy = od_tuners->io_is_busy;
309 } 309 }
diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
index 6663ec3b3056..d5f12b4b11b8 100644
--- a/drivers/cpufreq/cpufreq_governor.h
+++ b/drivers/cpufreq/cpufreq_governor.h
@@ -165,7 +165,7 @@ struct cs_cpu_dbs_info_s {
165 165
166/* Per policy Governers sysfs tunables */ 166/* Per policy Governers sysfs tunables */
167struct od_dbs_tuners { 167struct od_dbs_tuners {
168 unsigned int ignore_nice; 168 unsigned int ignore_nice_load;
169 unsigned int sampling_rate; 169 unsigned int sampling_rate;
170 unsigned int sampling_down_factor; 170 unsigned int sampling_down_factor;
171 unsigned int up_threshold; 171 unsigned int up_threshold;
@@ -175,7 +175,7 @@ struct od_dbs_tuners {
175}; 175};
176 176
177struct cs_dbs_tuners { 177struct cs_dbs_tuners {
178 unsigned int ignore_nice; 178 unsigned int ignore_nice_load;
179 unsigned int sampling_rate; 179 unsigned int sampling_rate;
180 unsigned int sampling_down_factor; 180 unsigned int sampling_down_factor;
181 unsigned int up_threshold; 181 unsigned int up_threshold;
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index 93eb5cbcc1f6..c087347d6688 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -403,8 +403,8 @@ static ssize_t store_sampling_down_factor(struct dbs_data *dbs_data,
403 return count; 403 return count;
404} 404}
405 405
406static ssize_t store_ignore_nice(struct dbs_data *dbs_data, const char *buf, 406static ssize_t store_ignore_nice_load(struct dbs_data *dbs_data,
407 size_t count) 407 const char *buf, size_t count)
408{ 408{
409 struct od_dbs_tuners *od_tuners = dbs_data->tuners; 409 struct od_dbs_tuners *od_tuners = dbs_data->tuners;
410 unsigned int input; 410 unsigned int input;
@@ -419,10 +419,10 @@ static ssize_t store_ignore_nice(struct dbs_data *dbs_data, const char *buf,
419 if (input > 1) 419 if (input > 1)
420 input = 1; 420 input = 1;
421 421
422 if (input == od_tuners->ignore_nice) { /* nothing to do */ 422 if (input == od_tuners->ignore_nice_load) { /* nothing to do */
423 return count; 423 return count;
424 } 424 }
425 od_tuners->ignore_nice = input; 425 od_tuners->ignore_nice_load = input;
426 426
427 /* we need to re-evaluate prev_cpu_idle */ 427 /* we need to re-evaluate prev_cpu_idle */
428 for_each_online_cpu(j) { 428 for_each_online_cpu(j) {
@@ -430,7 +430,7 @@ static ssize_t store_ignore_nice(struct dbs_data *dbs_data, const char *buf,
430 dbs_info = &per_cpu(od_cpu_dbs_info, j); 430 dbs_info = &per_cpu(od_cpu_dbs_info, j);
431 dbs_info->cdbs.prev_cpu_idle = get_cpu_idle_time(j, 431 dbs_info->cdbs.prev_cpu_idle = get_cpu_idle_time(j,
432 &dbs_info->cdbs.prev_cpu_wall, od_tuners->io_is_busy); 432 &dbs_info->cdbs.prev_cpu_wall, od_tuners->io_is_busy);
433 if (od_tuners->ignore_nice) 433 if (od_tuners->ignore_nice_load)
434 dbs_info->cdbs.prev_cpu_nice = 434 dbs_info->cdbs.prev_cpu_nice =
435 kcpustat_cpu(j).cpustat[CPUTIME_NICE]; 435 kcpustat_cpu(j).cpustat[CPUTIME_NICE];
436 436
@@ -461,7 +461,7 @@ show_store_one(od, sampling_rate);
461show_store_one(od, io_is_busy); 461show_store_one(od, io_is_busy);
462show_store_one(od, up_threshold); 462show_store_one(od, up_threshold);
463show_store_one(od, sampling_down_factor); 463show_store_one(od, sampling_down_factor);
464show_store_one(od, ignore_nice); 464show_store_one(od, ignore_nice_load);
465show_store_one(od, powersave_bias); 465show_store_one(od, powersave_bias);
466declare_show_sampling_rate_min(od); 466declare_show_sampling_rate_min(od);
467 467
@@ -469,7 +469,7 @@ gov_sys_pol_attr_rw(sampling_rate);
469gov_sys_pol_attr_rw(io_is_busy); 469gov_sys_pol_attr_rw(io_is_busy);
470gov_sys_pol_attr_rw(up_threshold); 470gov_sys_pol_attr_rw(up_threshold);
471gov_sys_pol_attr_rw(sampling_down_factor); 471gov_sys_pol_attr_rw(sampling_down_factor);
472gov_sys_pol_attr_rw(ignore_nice); 472gov_sys_pol_attr_rw(ignore_nice_load);
473gov_sys_pol_attr_rw(powersave_bias); 473gov_sys_pol_attr_rw(powersave_bias);
474gov_sys_pol_attr_ro(sampling_rate_min); 474gov_sys_pol_attr_ro(sampling_rate_min);
475 475
@@ -478,7 +478,7 @@ static struct attribute *dbs_attributes_gov_sys[] = {
478 &sampling_rate_gov_sys.attr, 478 &sampling_rate_gov_sys.attr,
479 &up_threshold_gov_sys.attr, 479 &up_threshold_gov_sys.attr,
480 &sampling_down_factor_gov_sys.attr, 480 &sampling_down_factor_gov_sys.attr,
481 &ignore_nice_gov_sys.attr, 481 &ignore_nice_load_gov_sys.attr,
482 &powersave_bias_gov_sys.attr, 482 &powersave_bias_gov_sys.attr,
483 &io_is_busy_gov_sys.attr, 483 &io_is_busy_gov_sys.attr,
484 NULL 484 NULL
@@ -494,7 +494,7 @@ static struct attribute *dbs_attributes_gov_pol[] = {
494 &sampling_rate_gov_pol.attr, 494 &sampling_rate_gov_pol.attr,
495 &up_threshold_gov_pol.attr, 495 &up_threshold_gov_pol.attr,
496 &sampling_down_factor_gov_pol.attr, 496 &sampling_down_factor_gov_pol.attr,
497 &ignore_nice_gov_pol.attr, 497 &ignore_nice_load_gov_pol.attr,
498 &powersave_bias_gov_pol.attr, 498 &powersave_bias_gov_pol.attr,
499 &io_is_busy_gov_pol.attr, 499 &io_is_busy_gov_pol.attr,
500 NULL 500 NULL
@@ -544,7 +544,7 @@ static int od_init(struct dbs_data *dbs_data)
544 } 544 }
545 545
546 tuners->sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR; 546 tuners->sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR;
547 tuners->ignore_nice = 0; 547 tuners->ignore_nice_load = 0;
548 tuners->powersave_bias = default_powersave_bias; 548 tuners->powersave_bias = default_powersave_bias;
549 tuners->io_is_busy = should_io_be_busy(); 549 tuners->io_is_busy = should_io_be_busy();
550 550
diff --git a/drivers/cpufreq/loongson2_cpufreq.c b/drivers/cpufreq/loongson2_cpufreq.c
index bb838b985077..9536852c504a 100644
--- a/drivers/cpufreq/loongson2_cpufreq.c
+++ b/drivers/cpufreq/loongson2_cpufreq.c
@@ -118,11 +118,6 @@ static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy)
118 clk_put(cpuclk); 118 clk_put(cpuclk);
119 return -EINVAL; 119 return -EINVAL;
120 } 120 }
121 ret = clk_set_rate(cpuclk, rate);
122 if (ret) {
123 clk_put(cpuclk);
124 return ret;
125 }
126 121
127 /* clock table init */ 122 /* clock table init */
128 for (i = 2; 123 for (i = 2;
@@ -130,6 +125,12 @@ static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy)
130 i++) 125 i++)
131 loongson2_clockmod_table[i].frequency = (rate * i) / 8; 126 loongson2_clockmod_table[i].frequency = (rate * i) / 8;
132 127
128 ret = clk_set_rate(cpuclk, rate);
129 if (ret) {
130 clk_put(cpuclk);
131 return ret;
132 }
133
133 policy->cur = loongson2_cpufreq_get(policy->cpu); 134 policy->cur = loongson2_cpufreq_get(policy->cpu);
134 135
135 cpufreq_frequency_table_get_attr(&loongson2_clockmod_table[0], 136 cpufreq_frequency_table_get_attr(&loongson2_clockmod_table[0],
diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
index b67f45f5c271..5039fbc88254 100644
--- a/drivers/dma/sh/shdma.c
+++ b/drivers/dma/sh/shdma.c
@@ -400,8 +400,8 @@ static size_t sh_dmae_get_partial(struct shdma_chan *schan,
400 shdma_chan); 400 shdma_chan);
401 struct sh_dmae_desc *sh_desc = container_of(sdesc, 401 struct sh_dmae_desc *sh_desc = container_of(sdesc,
402 struct sh_dmae_desc, shdma_desc); 402 struct sh_dmae_desc, shdma_desc);
403 return (sh_desc->hw.tcr - sh_dmae_readl(sh_chan, TCR)) << 403 return sh_desc->hw.tcr -
404 sh_chan->xmit_shift; 404 (sh_dmae_readl(sh_chan, TCR) << sh_chan->xmit_shift);
405} 405}
406 406
407/* Called from error IRQ or NMI */ 407/* Called from error IRQ or NMI */
diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c
index 98d670825a1a..6e8887fe6c1b 100644
--- a/drivers/gpu/drm/ast/ast_ttm.c
+++ b/drivers/gpu/drm/ast/ast_ttm.c
@@ -323,6 +323,7 @@ int ast_bo_create(struct drm_device *dev, int size, int align,
323 323
324 astbo->gem.driver_private = NULL; 324 astbo->gem.driver_private = NULL;
325 astbo->bo.bdev = &ast->ttm.bdev; 325 astbo->bo.bdev = &ast->ttm.bdev;
326 astbo->bo.bdev->dev_mapping = dev->dev_mapping;
326 327
327 ast_ttm_placement(astbo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM); 328 ast_ttm_placement(astbo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM);
328 329
diff --git a/drivers/gpu/drm/cirrus/cirrus_ttm.c b/drivers/gpu/drm/cirrus/cirrus_ttm.c
index 0047012045c2..69fd8f1ac8df 100644
--- a/drivers/gpu/drm/cirrus/cirrus_ttm.c
+++ b/drivers/gpu/drm/cirrus/cirrus_ttm.c
@@ -328,6 +328,7 @@ int cirrus_bo_create(struct drm_device *dev, int size, int align,
328 328
329 cirrusbo->gem.driver_private = NULL; 329 cirrusbo->gem.driver_private = NULL;
330 cirrusbo->bo.bdev = &cirrus->ttm.bdev; 330 cirrusbo->bo.bdev = &cirrus->ttm.bdev;
331 cirrusbo->bo.bdev->dev_mapping = dev->dev_mapping;
331 332
332 cirrus_ttm_placement(cirrusbo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM); 333 cirrus_ttm_placement(cirrusbo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM);
333 334
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 8bcce7866d36..f92da0a32f0d 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -708,7 +708,10 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, int crtc,
708 /* Subtract time delta from raw timestamp to get final 708 /* Subtract time delta from raw timestamp to get final
709 * vblank_time timestamp for end of vblank. 709 * vblank_time timestamp for end of vblank.
710 */ 710 */
711 etime = ktime_sub_ns(etime, delta_ns); 711 if (delta_ns < 0)
712 etime = ktime_add_ns(etime, -delta_ns);
713 else
714 etime = ktime_sub_ns(etime, delta_ns);
712 *vblank_time = ktime_to_timeval(etime); 715 *vblank_time = ktime_to_timeval(etime);
713 716
714 DRM_DEBUG("crtc %d : v %d p(%d,%d)@ %ld.%ld -> %ld.%ld [e %d us, %d rep]\n", 717 DRM_DEBUG("crtc %d : v %d p(%d,%d)@ %ld.%ld -> %ld.%ld [e %d us, %d rep]\n",
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index f2326fc60ac9..6f514297c483 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -1856,10 +1856,16 @@
1856#define CRT_HOTPLUG_DETECT_VOLTAGE_475MV (1 << 2) 1856#define CRT_HOTPLUG_DETECT_VOLTAGE_475MV (1 << 2)
1857 1857
1858#define PORT_HOTPLUG_STAT (dev_priv->info->display_mmio_offset + 0x61114) 1858#define PORT_HOTPLUG_STAT (dev_priv->info->display_mmio_offset + 0x61114)
1859/* HDMI/DP bits are gen4+ */ 1859/*
1860#define PORTB_HOTPLUG_LIVE_STATUS (1 << 29) 1860 * HDMI/DP bits are gen4+
1861 *
1862 * WARNING: Bspec for hpd status bits on gen4 seems to be completely confused.
1863 * Please check the detailed lore in the commit message for for experimental
1864 * evidence.
1865 */
1866#define PORTD_HOTPLUG_LIVE_STATUS (1 << 29)
1861#define PORTC_HOTPLUG_LIVE_STATUS (1 << 28) 1867#define PORTC_HOTPLUG_LIVE_STATUS (1 << 28)
1862#define PORTD_HOTPLUG_LIVE_STATUS (1 << 27) 1868#define PORTB_HOTPLUG_LIVE_STATUS (1 << 27)
1863#define PORTD_HOTPLUG_INT_STATUS (3 << 21) 1869#define PORTD_HOTPLUG_INT_STATUS (3 << 21)
1864#define PORTC_HOTPLUG_INT_STATUS (3 << 19) 1870#define PORTC_HOTPLUG_INT_STATUS (3 << 19)
1865#define PORTB_HOTPLUG_INT_STATUS (3 << 17) 1871#define PORTB_HOTPLUG_INT_STATUS (3 << 17)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 5fb305840db8..e38b45786653 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -8269,9 +8269,11 @@ check_crtc_state(struct drm_device *dev)
8269 8269
8270 list_for_each_entry(encoder, &dev->mode_config.encoder_list, 8270 list_for_each_entry(encoder, &dev->mode_config.encoder_list,
8271 base.head) { 8271 base.head) {
8272 enum pipe pipe;
8272 if (encoder->base.crtc != &crtc->base) 8273 if (encoder->base.crtc != &crtc->base)
8273 continue; 8274 continue;
8274 if (encoder->get_config) 8275 if (encoder->get_config &&
8276 encoder->get_hw_state(encoder, &pipe))
8275 encoder->get_config(encoder, &pipe_config); 8277 encoder->get_config(encoder, &pipe_config);
8276 } 8278 }
8277 8279
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index 67e2c1f1c9a8..5950888ae1d0 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -497,8 +497,11 @@ void intel_panel_set_backlight(struct drm_device *dev, u32 level, u32 max)
497 goto out; 497 goto out;
498 } 498 }
499 499
500 /* scale to hardware */ 500 /* scale to hardware, but be careful to not overflow */
501 level = level * freq / max; 501 if (freq < max)
502 level = level * freq / max;
503 else
504 level = freq / max * level;
502 505
503 dev_priv->backlight.level = level; 506 dev_priv->backlight.level = level;
504 if (dev_priv->backlight.device) 507 if (dev_priv->backlight.device)
@@ -515,6 +518,17 @@ void intel_panel_disable_backlight(struct drm_device *dev)
515 struct drm_i915_private *dev_priv = dev->dev_private; 518 struct drm_i915_private *dev_priv = dev->dev_private;
516 unsigned long flags; 519 unsigned long flags;
517 520
521 /*
522 * Do not disable backlight on the vgaswitcheroo path. When switching
523 * away from i915, the other client may depend on i915 to handle the
524 * backlight. This will leave the backlight on unnecessarily when
525 * another client is not activated.
526 */
527 if (dev->switch_power_state == DRM_SWITCH_POWER_CHANGING) {
528 DRM_DEBUG_DRIVER("Skipping backlight disable on vga switch\n");
529 return;
530 }
531
518 spin_lock_irqsave(&dev_priv->backlight.lock, flags); 532 spin_lock_irqsave(&dev_priv->backlight.lock, flags);
519 533
520 dev_priv->backlight.enabled = false; 534 dev_priv->backlight.enabled = false;
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index f895d1508df8..b0e4a0bd1313 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -5063,8 +5063,26 @@ static void __intel_set_power_well(struct drm_device *dev, bool enable)
5063 } 5063 }
5064 } else { 5064 } else {
5065 if (enable_requested) { 5065 if (enable_requested) {
5066 unsigned long irqflags;
5067 enum pipe p;
5068
5066 I915_WRITE(HSW_PWR_WELL_DRIVER, 0); 5069 I915_WRITE(HSW_PWR_WELL_DRIVER, 0);
5070 POSTING_READ(HSW_PWR_WELL_DRIVER);
5067 DRM_DEBUG_KMS("Requesting to disable the power well\n"); 5071 DRM_DEBUG_KMS("Requesting to disable the power well\n");
5072
5073 /*
5074 * After this, the registers on the pipes that are part
5075 * of the power well will become zero, so we have to
5076 * adjust our counters according to that.
5077 *
5078 * FIXME: Should we do this in general in
5079 * drm_vblank_post_modeset?
5080 */
5081 spin_lock_irqsave(&dev->vbl_lock, irqflags);
5082 for_each_pipe(p)
5083 if (p != PIPE_A)
5084 dev->last_vblank[p] = 0;
5085 spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
5068 } 5086 }
5069 } 5087 }
5070} 5088}
diff --git a/drivers/gpu/drm/mgag200/mgag200_ttm.c b/drivers/gpu/drm/mgag200/mgag200_ttm.c
index 13878d5de063..d70e4a92773b 100644
--- a/drivers/gpu/drm/mgag200/mgag200_ttm.c
+++ b/drivers/gpu/drm/mgag200/mgag200_ttm.c
@@ -323,6 +323,7 @@ int mgag200_bo_create(struct drm_device *dev, int size, int align,
323 323
324 mgabo->gem.driver_private = NULL; 324 mgabo->gem.driver_private = NULL;
325 mgabo->bo.bdev = &mdev->ttm.bdev; 325 mgabo->bo.bdev = &mdev->ttm.bdev;
326 mgabo->bo.bdev->dev_mapping = dev->dev_mapping;
326 327
327 mgag200_ttm_placement(mgabo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM); 328 mgag200_ttm_placement(mgabo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM);
328 329
diff --git a/drivers/gpu/drm/radeon/btc_dpm.c b/drivers/gpu/drm/radeon/btc_dpm.c
index 0bfd55e08820..9953e1fbc46d 100644
--- a/drivers/gpu/drm/radeon/btc_dpm.c
+++ b/drivers/gpu/drm/radeon/btc_dpm.c
@@ -2548,9 +2548,6 @@ int btc_dpm_init(struct radeon_device *rdev)
2548{ 2548{
2549 struct rv7xx_power_info *pi; 2549 struct rv7xx_power_info *pi;
2550 struct evergreen_power_info *eg_pi; 2550 struct evergreen_power_info *eg_pi;
2551 int index = GetIndexIntoMasterTable(DATA, ASIC_InternalSS_Info);
2552 u16 data_offset, size;
2553 u8 frev, crev;
2554 struct atom_clock_dividers dividers; 2551 struct atom_clock_dividers dividers;
2555 int ret; 2552 int ret;
2556 2553
@@ -2633,16 +2630,7 @@ int btc_dpm_init(struct radeon_device *rdev)
2633 eg_pi->vddci_control = 2630 eg_pi->vddci_control =
2634 radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDCI, 0); 2631 radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDCI, 0);
2635 2632
2636 if (atom_parse_data_header(rdev->mode_info.atom_context, index, &size, 2633 rv770_get_engine_memory_ss(rdev);
2637 &frev, &crev, &data_offset)) {
2638 pi->sclk_ss = true;
2639 pi->mclk_ss = true;
2640 pi->dynamic_ss = true;
2641 } else {
2642 pi->sclk_ss = false;
2643 pi->mclk_ss = false;
2644 pi->dynamic_ss = true;
2645 }
2646 2634
2647 pi->asi = RV770_ASI_DFLT; 2635 pi->asi = RV770_ASI_DFLT;
2648 pi->pasi = CYPRESS_HASI_DFLT; 2636 pi->pasi = CYPRESS_HASI_DFLT;
@@ -2659,8 +2647,7 @@ int btc_dpm_init(struct radeon_device *rdev)
2659 2647
2660 pi->dynamic_pcie_gen2 = true; 2648 pi->dynamic_pcie_gen2 = true;
2661 2649
2662 if (pi->gfx_clock_gating && 2650 if (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE)
2663 (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE))
2664 pi->thermal_protection = true; 2651 pi->thermal_protection = true;
2665 else 2652 else
2666 pi->thermal_protection = false; 2653 pi->thermal_protection = false;
diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
index 6dacec4e2090..8928bd109c16 100644
--- a/drivers/gpu/drm/radeon/cik.c
+++ b/drivers/gpu/drm/radeon/cik.c
@@ -2587,9 +2587,11 @@ u32 cik_compute_ring_get_rptr(struct radeon_device *rdev,
2587 if (rdev->wb.enabled) { 2587 if (rdev->wb.enabled) {
2588 rptr = le32_to_cpu(rdev->wb.wb[ring->rptr_offs/4]); 2588 rptr = le32_to_cpu(rdev->wb.wb[ring->rptr_offs/4]);
2589 } else { 2589 } else {
2590 mutex_lock(&rdev->srbm_mutex);
2590 cik_srbm_select(rdev, ring->me, ring->pipe, ring->queue, 0); 2591 cik_srbm_select(rdev, ring->me, ring->pipe, ring->queue, 0);
2591 rptr = RREG32(CP_HQD_PQ_RPTR); 2592 rptr = RREG32(CP_HQD_PQ_RPTR);
2592 cik_srbm_select(rdev, 0, 0, 0, 0); 2593 cik_srbm_select(rdev, 0, 0, 0, 0);
2594 mutex_unlock(&rdev->srbm_mutex);
2593 } 2595 }
2594 rptr = (rptr & ring->ptr_reg_mask) >> ring->ptr_reg_shift; 2596 rptr = (rptr & ring->ptr_reg_mask) >> ring->ptr_reg_shift;
2595 2597
@@ -2604,9 +2606,11 @@ u32 cik_compute_ring_get_wptr(struct radeon_device *rdev,
2604 if (rdev->wb.enabled) { 2606 if (rdev->wb.enabled) {
2605 wptr = le32_to_cpu(rdev->wb.wb[ring->wptr_offs/4]); 2607 wptr = le32_to_cpu(rdev->wb.wb[ring->wptr_offs/4]);
2606 } else { 2608 } else {
2609 mutex_lock(&rdev->srbm_mutex);
2607 cik_srbm_select(rdev, ring->me, ring->pipe, ring->queue, 0); 2610 cik_srbm_select(rdev, ring->me, ring->pipe, ring->queue, 0);
2608 wptr = RREG32(CP_HQD_PQ_WPTR); 2611 wptr = RREG32(CP_HQD_PQ_WPTR);
2609 cik_srbm_select(rdev, 0, 0, 0, 0); 2612 cik_srbm_select(rdev, 0, 0, 0, 0);
2613 mutex_unlock(&rdev->srbm_mutex);
2610 } 2614 }
2611 wptr = (wptr & ring->ptr_reg_mask) >> ring->ptr_reg_shift; 2615 wptr = (wptr & ring->ptr_reg_mask) >> ring->ptr_reg_shift;
2612 2616
@@ -2897,6 +2901,7 @@ static int cik_cp_compute_resume(struct radeon_device *rdev)
2897 WREG32(CP_CPF_DEBUG, tmp); 2901 WREG32(CP_CPF_DEBUG, tmp);
2898 2902
2899 /* init the pipes */ 2903 /* init the pipes */
2904 mutex_lock(&rdev->srbm_mutex);
2900 for (i = 0; i < (rdev->mec.num_pipe * rdev->mec.num_mec); i++) { 2905 for (i = 0; i < (rdev->mec.num_pipe * rdev->mec.num_mec); i++) {
2901 int me = (i < 4) ? 1 : 2; 2906 int me = (i < 4) ? 1 : 2;
2902 int pipe = (i < 4) ? i : (i - 4); 2907 int pipe = (i < 4) ? i : (i - 4);
@@ -2919,6 +2924,7 @@ static int cik_cp_compute_resume(struct radeon_device *rdev)
2919 WREG32(CP_HPD_EOP_CONTROL, tmp); 2924 WREG32(CP_HPD_EOP_CONTROL, tmp);
2920 } 2925 }
2921 cik_srbm_select(rdev, 0, 0, 0, 0); 2926 cik_srbm_select(rdev, 0, 0, 0, 0);
2927 mutex_unlock(&rdev->srbm_mutex);
2922 2928
2923 /* init the queues. Just two for now. */ 2929 /* init the queues. Just two for now. */
2924 for (i = 0; i < 2; i++) { 2930 for (i = 0; i < 2; i++) {
@@ -2972,6 +2978,7 @@ static int cik_cp_compute_resume(struct radeon_device *rdev)
2972 mqd->static_thread_mgmt23[0] = 0xffffffff; 2978 mqd->static_thread_mgmt23[0] = 0xffffffff;
2973 mqd->static_thread_mgmt23[1] = 0xffffffff; 2979 mqd->static_thread_mgmt23[1] = 0xffffffff;
2974 2980
2981 mutex_lock(&rdev->srbm_mutex);
2975 cik_srbm_select(rdev, rdev->ring[idx].me, 2982 cik_srbm_select(rdev, rdev->ring[idx].me,
2976 rdev->ring[idx].pipe, 2983 rdev->ring[idx].pipe,
2977 rdev->ring[idx].queue, 0); 2984 rdev->ring[idx].queue, 0);
@@ -3099,6 +3106,7 @@ static int cik_cp_compute_resume(struct radeon_device *rdev)
3099 WREG32(CP_HQD_ACTIVE, mqd->queue_state.cp_hqd_active); 3106 WREG32(CP_HQD_ACTIVE, mqd->queue_state.cp_hqd_active);
3100 3107
3101 cik_srbm_select(rdev, 0, 0, 0, 0); 3108 cik_srbm_select(rdev, 0, 0, 0, 0);
3109 mutex_unlock(&rdev->srbm_mutex);
3102 3110
3103 radeon_bo_kunmap(rdev->ring[idx].mqd_obj); 3111 radeon_bo_kunmap(rdev->ring[idx].mqd_obj);
3104 radeon_bo_unreserve(rdev->ring[idx].mqd_obj); 3112 radeon_bo_unreserve(rdev->ring[idx].mqd_obj);
@@ -4320,6 +4328,7 @@ static int cik_pcie_gart_enable(struct radeon_device *rdev)
4320 4328
4321 /* XXX SH_MEM regs */ 4329 /* XXX SH_MEM regs */
4322 /* where to put LDS, scratch, GPUVM in FSA64 space */ 4330 /* where to put LDS, scratch, GPUVM in FSA64 space */
4331 mutex_lock(&rdev->srbm_mutex);
4323 for (i = 0; i < 16; i++) { 4332 for (i = 0; i < 16; i++) {
4324 cik_srbm_select(rdev, 0, 0, 0, i); 4333 cik_srbm_select(rdev, 0, 0, 0, i);
4325 /* CP and shaders */ 4334 /* CP and shaders */
@@ -4335,6 +4344,7 @@ static int cik_pcie_gart_enable(struct radeon_device *rdev)
4335 /* XXX SDMA RLC - todo */ 4344 /* XXX SDMA RLC - todo */
4336 } 4345 }
4337 cik_srbm_select(rdev, 0, 0, 0, 0); 4346 cik_srbm_select(rdev, 0, 0, 0, 0);
4347 mutex_unlock(&rdev->srbm_mutex);
4338 4348
4339 cik_pcie_gart_tlb_flush(rdev); 4349 cik_pcie_gart_tlb_flush(rdev);
4340 DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n", 4350 DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
@@ -5954,6 +5964,8 @@ static int cik_startup(struct radeon_device *rdev)
5954 struct radeon_ring *ring; 5964 struct radeon_ring *ring;
5955 int r; 5965 int r;
5956 5966
5967 cik_mc_program(rdev);
5968
5957 if (rdev->flags & RADEON_IS_IGP) { 5969 if (rdev->flags & RADEON_IS_IGP) {
5958 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->ce_fw || 5970 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->ce_fw ||
5959 !rdev->mec_fw || !rdev->sdma_fw || !rdev->rlc_fw) { 5971 !rdev->mec_fw || !rdev->sdma_fw || !rdev->rlc_fw) {
@@ -5985,7 +5997,6 @@ static int cik_startup(struct radeon_device *rdev)
5985 if (r) 5997 if (r)
5986 return r; 5998 return r;
5987 5999
5988 cik_mc_program(rdev);
5989 r = cik_pcie_gart_enable(rdev); 6000 r = cik_pcie_gart_enable(rdev);
5990 if (r) 6001 if (r)
5991 return r; 6002 return r;
@@ -6194,7 +6205,7 @@ int cik_suspend(struct radeon_device *rdev)
6194 radeon_vm_manager_fini(rdev); 6205 radeon_vm_manager_fini(rdev);
6195 cik_cp_enable(rdev, false); 6206 cik_cp_enable(rdev, false);
6196 cik_sdma_enable(rdev, false); 6207 cik_sdma_enable(rdev, false);
6197 r600_uvd_rbc_stop(rdev); 6208 r600_uvd_stop(rdev);
6198 radeon_uvd_suspend(rdev); 6209 radeon_uvd_suspend(rdev);
6199 cik_irq_suspend(rdev); 6210 cik_irq_suspend(rdev);
6200 radeon_wb_disable(rdev); 6211 radeon_wb_disable(rdev);
@@ -6358,6 +6369,7 @@ void cik_fini(struct radeon_device *rdev)
6358 radeon_vm_manager_fini(rdev); 6369 radeon_vm_manager_fini(rdev);
6359 radeon_ib_pool_fini(rdev); 6370 radeon_ib_pool_fini(rdev);
6360 radeon_irq_kms_fini(rdev); 6371 radeon_irq_kms_fini(rdev);
6372 r600_uvd_stop(rdev);
6361 radeon_uvd_fini(rdev); 6373 radeon_uvd_fini(rdev);
6362 cik_pcie_gart_fini(rdev); 6374 cik_pcie_gart_fini(rdev);
6363 r600_vram_scratch_fini(rdev); 6375 r600_vram_scratch_fini(rdev);
@@ -6978,7 +6990,7 @@ int cik_uvd_resume(struct radeon_device *rdev)
6978 6990
6979 /* programm the VCPU memory controller bits 0-27 */ 6991 /* programm the VCPU memory controller bits 0-27 */
6980 addr = rdev->uvd.gpu_addr >> 3; 6992 addr = rdev->uvd.gpu_addr >> 3;
6981 size = RADEON_GPU_PAGE_ALIGN(rdev->uvd.fw_size + 4) >> 3; 6993 size = RADEON_GPU_PAGE_ALIGN(rdev->uvd_fw->size + 4) >> 3;
6982 WREG32(UVD_VCPU_CACHE_OFFSET0, addr); 6994 WREG32(UVD_VCPU_CACHE_OFFSET0, addr);
6983 WREG32(UVD_VCPU_CACHE_SIZE0, size); 6995 WREG32(UVD_VCPU_CACHE_SIZE0, size);
6984 6996
diff --git a/drivers/gpu/drm/radeon/cypress_dpm.c b/drivers/gpu/drm/radeon/cypress_dpm.c
index 9bcdd174780f..7e5d0b570a30 100644
--- a/drivers/gpu/drm/radeon/cypress_dpm.c
+++ b/drivers/gpu/drm/radeon/cypress_dpm.c
@@ -2038,9 +2038,6 @@ int cypress_dpm_init(struct radeon_device *rdev)
2038{ 2038{
2039 struct rv7xx_power_info *pi; 2039 struct rv7xx_power_info *pi;
2040 struct evergreen_power_info *eg_pi; 2040 struct evergreen_power_info *eg_pi;
2041 int index = GetIndexIntoMasterTable(DATA, ASIC_InternalSS_Info);
2042 uint16_t data_offset, size;
2043 uint8_t frev, crev;
2044 struct atom_clock_dividers dividers; 2041 struct atom_clock_dividers dividers;
2045 int ret; 2042 int ret;
2046 2043
@@ -2092,16 +2089,7 @@ int cypress_dpm_init(struct radeon_device *rdev)
2092 eg_pi->vddci_control = 2089 eg_pi->vddci_control =
2093 radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDCI, 0); 2090 radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDCI, 0);
2094 2091
2095 if (atom_parse_data_header(rdev->mode_info.atom_context, index, &size, 2092 rv770_get_engine_memory_ss(rdev);
2096 &frev, &crev, &data_offset)) {
2097 pi->sclk_ss = true;
2098 pi->mclk_ss = true;
2099 pi->dynamic_ss = true;
2100 } else {
2101 pi->sclk_ss = false;
2102 pi->mclk_ss = false;
2103 pi->dynamic_ss = true;
2104 }
2105 2093
2106 pi->asi = RV770_ASI_DFLT; 2094 pi->asi = RV770_ASI_DFLT;
2107 pi->pasi = CYPRESS_HASI_DFLT; 2095 pi->pasi = CYPRESS_HASI_DFLT;
@@ -2122,8 +2110,7 @@ int cypress_dpm_init(struct radeon_device *rdev)
2122 2110
2123 pi->dynamic_pcie_gen2 = true; 2111 pi->dynamic_pcie_gen2 = true;
2124 2112
2125 if (pi->gfx_clock_gating && 2113 if (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE)
2126 (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE))
2127 pi->thermal_protection = true; 2114 pi->thermal_protection = true;
2128 else 2115 else
2129 pi->thermal_protection = false; 2116 pi->thermal_protection = false;
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index 038dcac7670c..d5b49e33315e 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -5106,6 +5106,8 @@ static int evergreen_startup(struct radeon_device *rdev)
5106 /* enable aspm */ 5106 /* enable aspm */
5107 evergreen_program_aspm(rdev); 5107 evergreen_program_aspm(rdev);
5108 5108
5109 evergreen_mc_program(rdev);
5110
5109 if (ASIC_IS_DCE5(rdev)) { 5111 if (ASIC_IS_DCE5(rdev)) {
5110 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw || !rdev->mc_fw) { 5112 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw || !rdev->mc_fw) {
5111 r = ni_init_microcode(rdev); 5113 r = ni_init_microcode(rdev);
@@ -5133,7 +5135,6 @@ static int evergreen_startup(struct radeon_device *rdev)
5133 if (r) 5135 if (r)
5134 return r; 5136 return r;
5135 5137
5136 evergreen_mc_program(rdev);
5137 if (rdev->flags & RADEON_IS_AGP) { 5138 if (rdev->flags & RADEON_IS_AGP) {
5138 evergreen_agp_enable(rdev); 5139 evergreen_agp_enable(rdev);
5139 } else { 5140 } else {
@@ -5291,10 +5292,10 @@ int evergreen_resume(struct radeon_device *rdev)
5291int evergreen_suspend(struct radeon_device *rdev) 5292int evergreen_suspend(struct radeon_device *rdev)
5292{ 5293{
5293 r600_audio_fini(rdev); 5294 r600_audio_fini(rdev);
5295 r600_uvd_stop(rdev);
5294 radeon_uvd_suspend(rdev); 5296 radeon_uvd_suspend(rdev);
5295 r700_cp_stop(rdev); 5297 r700_cp_stop(rdev);
5296 r600_dma_stop(rdev); 5298 r600_dma_stop(rdev);
5297 r600_uvd_rbc_stop(rdev);
5298 evergreen_irq_suspend(rdev); 5299 evergreen_irq_suspend(rdev);
5299 radeon_wb_disable(rdev); 5300 radeon_wb_disable(rdev);
5300 evergreen_pcie_gart_disable(rdev); 5301 evergreen_pcie_gart_disable(rdev);
@@ -5429,6 +5430,7 @@ void evergreen_fini(struct radeon_device *rdev)
5429 radeon_ib_pool_fini(rdev); 5430 radeon_ib_pool_fini(rdev);
5430 radeon_irq_kms_fini(rdev); 5431 radeon_irq_kms_fini(rdev);
5431 evergreen_pcie_gart_fini(rdev); 5432 evergreen_pcie_gart_fini(rdev);
5433 r600_uvd_stop(rdev);
5432 radeon_uvd_fini(rdev); 5434 radeon_uvd_fini(rdev);
5433 r600_vram_scratch_fini(rdev); 5435 r600_vram_scratch_fini(rdev);
5434 radeon_gem_fini(rdev); 5436 radeon_gem_fini(rdev);
diff --git a/drivers/gpu/drm/radeon/evergreen_hdmi.c b/drivers/gpu/drm/radeon/evergreen_hdmi.c
index bb9ea3641312..b0e280058b9b 100644
--- a/drivers/gpu/drm/radeon/evergreen_hdmi.c
+++ b/drivers/gpu/drm/radeon/evergreen_hdmi.c
@@ -148,18 +148,40 @@ static void evergreen_audio_set_dto(struct drm_encoder *encoder, u32 clock)
148 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; 148 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
149 struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc); 149 struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc);
150 u32 base_rate = 24000; 150 u32 base_rate = 24000;
151 u32 max_ratio = clock / base_rate;
152 u32 dto_phase;
153 u32 dto_modulo = clock;
154 u32 wallclock_ratio;
155 u32 dto_cntl;
151 156
152 if (!dig || !dig->afmt) 157 if (!dig || !dig->afmt)
153 return; 158 return;
154 159
160 if (max_ratio >= 8) {
161 dto_phase = 192 * 1000;
162 wallclock_ratio = 3;
163 } else if (max_ratio >= 4) {
164 dto_phase = 96 * 1000;
165 wallclock_ratio = 2;
166 } else if (max_ratio >= 2) {
167 dto_phase = 48 * 1000;
168 wallclock_ratio = 1;
169 } else {
170 dto_phase = 24 * 1000;
171 wallclock_ratio = 0;
172 }
173 dto_cntl = RREG32(DCCG_AUDIO_DTO0_CNTL) & ~DCCG_AUDIO_DTO_WALLCLOCK_RATIO_MASK;
174 dto_cntl |= DCCG_AUDIO_DTO_WALLCLOCK_RATIO(wallclock_ratio);
175 WREG32(DCCG_AUDIO_DTO0_CNTL, dto_cntl);
176
155 /* XXX two dtos; generally use dto0 for hdmi */ 177 /* XXX two dtos; generally use dto0 for hdmi */
156 /* Express [24MHz / target pixel clock] as an exact rational 178 /* Express [24MHz / target pixel clock] as an exact rational
157 * number (coefficient of two integer numbers. DCCG_AUDIO_DTOx_PHASE 179 * number (coefficient of two integer numbers. DCCG_AUDIO_DTOx_PHASE
158 * is the numerator, DCCG_AUDIO_DTOx_MODULE is the denominator 180 * is the numerator, DCCG_AUDIO_DTOx_MODULE is the denominator
159 */ 181 */
160 WREG32(DCCG_AUDIO_DTO_SOURCE, DCCG_AUDIO_DTO0_SOURCE_SEL(radeon_crtc->crtc_id)); 182 WREG32(DCCG_AUDIO_DTO_SOURCE, DCCG_AUDIO_DTO0_SOURCE_SEL(radeon_crtc->crtc_id));
161 WREG32(DCCG_AUDIO_DTO0_PHASE, base_rate * 100); 183 WREG32(DCCG_AUDIO_DTO0_PHASE, dto_phase);
162 WREG32(DCCG_AUDIO_DTO0_MODULE, clock * 100); 184 WREG32(DCCG_AUDIO_DTO0_MODULE, dto_modulo);
163} 185}
164 186
165 187
diff --git a/drivers/gpu/drm/radeon/evergreend.h b/drivers/gpu/drm/radeon/evergreend.h
index a7baf67aef6c..0d582ac1dc31 100644
--- a/drivers/gpu/drm/radeon/evergreend.h
+++ b/drivers/gpu/drm/radeon/evergreend.h
@@ -497,6 +497,9 @@
497#define DCCG_AUDIO_DTO0_MODULE 0x05b4 497#define DCCG_AUDIO_DTO0_MODULE 0x05b4
498#define DCCG_AUDIO_DTO0_LOAD 0x05b8 498#define DCCG_AUDIO_DTO0_LOAD 0x05b8
499#define DCCG_AUDIO_DTO0_CNTL 0x05bc 499#define DCCG_AUDIO_DTO0_CNTL 0x05bc
500# define DCCG_AUDIO_DTO_WALLCLOCK_RATIO(x) (((x) & 7) << 0)
501# define DCCG_AUDIO_DTO_WALLCLOCK_RATIO_MASK 7
502# define DCCG_AUDIO_DTO_WALLCLOCK_RATIO_SHIFT 0
500 503
501#define DCCG_AUDIO_DTO1_PHASE 0x05c0 504#define DCCG_AUDIO_DTO1_PHASE 0x05c0
502#define DCCG_AUDIO_DTO1_MODULE 0x05c4 505#define DCCG_AUDIO_DTO1_MODULE 0x05c4
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index 56bd4f3be4fe..ccb4f8b54852 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -794,9 +794,13 @@ int ni_init_microcode(struct radeon_device *rdev)
794 if ((rdev->family >= CHIP_BARTS) && (rdev->family <= CHIP_CAYMAN)) { 794 if ((rdev->family >= CHIP_BARTS) && (rdev->family <= CHIP_CAYMAN)) {
795 snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name); 795 snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name);
796 err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev); 796 err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev);
797 if (err) 797 if (err) {
798 goto out; 798 printk(KERN_ERR
799 if (rdev->smc_fw->size != smc_req_size) { 799 "smc: error loading firmware \"%s\"\n",
800 fw_name);
801 release_firmware(rdev->smc_fw);
802 rdev->smc_fw = NULL;
803 } else if (rdev->smc_fw->size != smc_req_size) {
800 printk(KERN_ERR 804 printk(KERN_ERR
801 "ni_mc: Bogus length %zu in firmware \"%s\"\n", 805 "ni_mc: Bogus length %zu in firmware \"%s\"\n",
802 rdev->mc_fw->size, fw_name); 806 rdev->mc_fw->size, fw_name);
@@ -2079,6 +2083,8 @@ static int cayman_startup(struct radeon_device *rdev)
2079 /* enable aspm */ 2083 /* enable aspm */
2080 evergreen_program_aspm(rdev); 2084 evergreen_program_aspm(rdev);
2081 2085
2086 evergreen_mc_program(rdev);
2087
2082 if (rdev->flags & RADEON_IS_IGP) { 2088 if (rdev->flags & RADEON_IS_IGP) {
2083 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) { 2089 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) {
2084 r = ni_init_microcode(rdev); 2090 r = ni_init_microcode(rdev);
@@ -2107,7 +2113,6 @@ static int cayman_startup(struct radeon_device *rdev)
2107 if (r) 2113 if (r)
2108 return r; 2114 return r;
2109 2115
2110 evergreen_mc_program(rdev);
2111 r = cayman_pcie_gart_enable(rdev); 2116 r = cayman_pcie_gart_enable(rdev);
2112 if (r) 2117 if (r)
2113 return r; 2118 return r;
@@ -2286,7 +2291,7 @@ int cayman_suspend(struct radeon_device *rdev)
2286 radeon_vm_manager_fini(rdev); 2291 radeon_vm_manager_fini(rdev);
2287 cayman_cp_enable(rdev, false); 2292 cayman_cp_enable(rdev, false);
2288 cayman_dma_stop(rdev); 2293 cayman_dma_stop(rdev);
2289 r600_uvd_rbc_stop(rdev); 2294 r600_uvd_stop(rdev);
2290 radeon_uvd_suspend(rdev); 2295 radeon_uvd_suspend(rdev);
2291 evergreen_irq_suspend(rdev); 2296 evergreen_irq_suspend(rdev);
2292 radeon_wb_disable(rdev); 2297 radeon_wb_disable(rdev);
@@ -2418,6 +2423,7 @@ void cayman_fini(struct radeon_device *rdev)
2418 radeon_vm_manager_fini(rdev); 2423 radeon_vm_manager_fini(rdev);
2419 radeon_ib_pool_fini(rdev); 2424 radeon_ib_pool_fini(rdev);
2420 radeon_irq_kms_fini(rdev); 2425 radeon_irq_kms_fini(rdev);
2426 r600_uvd_stop(rdev);
2421 radeon_uvd_fini(rdev); 2427 radeon_uvd_fini(rdev);
2422 cayman_pcie_gart_fini(rdev); 2428 cayman_pcie_gart_fini(rdev);
2423 r600_vram_scratch_fini(rdev); 2429 r600_vram_scratch_fini(rdev);
diff --git a/drivers/gpu/drm/radeon/ni_dpm.c b/drivers/gpu/drm/radeon/ni_dpm.c
index 4f9b9bc20daa..f0f5f748938a 100644
--- a/drivers/gpu/drm/radeon/ni_dpm.c
+++ b/drivers/gpu/drm/radeon/ni_dpm.c
@@ -4067,9 +4067,6 @@ int ni_dpm_init(struct radeon_device *rdev)
4067 struct rv7xx_power_info *pi; 4067 struct rv7xx_power_info *pi;
4068 struct evergreen_power_info *eg_pi; 4068 struct evergreen_power_info *eg_pi;
4069 struct ni_power_info *ni_pi; 4069 struct ni_power_info *ni_pi;
4070 int index = GetIndexIntoMasterTable(DATA, ASIC_InternalSS_Info);
4071 u16 data_offset, size;
4072 u8 frev, crev;
4073 struct atom_clock_dividers dividers; 4070 struct atom_clock_dividers dividers;
4074 int ret; 4071 int ret;
4075 4072
@@ -4162,16 +4159,7 @@ int ni_dpm_init(struct radeon_device *rdev)
4162 eg_pi->vddci_control = 4159 eg_pi->vddci_control =
4163 radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDCI, 0); 4160 radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDCI, 0);
4164 4161
4165 if (atom_parse_data_header(rdev->mode_info.atom_context, index, &size, 4162 rv770_get_engine_memory_ss(rdev);
4166 &frev, &crev, &data_offset)) {
4167 pi->sclk_ss = true;
4168 pi->mclk_ss = true;
4169 pi->dynamic_ss = true;
4170 } else {
4171 pi->sclk_ss = false;
4172 pi->mclk_ss = false;
4173 pi->dynamic_ss = true;
4174 }
4175 4163
4176 pi->asi = RV770_ASI_DFLT; 4164 pi->asi = RV770_ASI_DFLT;
4177 pi->pasi = CYPRESS_HASI_DFLT; 4165 pi->pasi = CYPRESS_HASI_DFLT;
@@ -4188,8 +4176,7 @@ int ni_dpm_init(struct radeon_device *rdev)
4188 4176
4189 pi->dynamic_pcie_gen2 = true; 4177 pi->dynamic_pcie_gen2 = true;
4190 4178
4191 if (pi->gfx_clock_gating && 4179 if (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE)
4192 (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE))
4193 pi->thermal_protection = true; 4180 pi->thermal_protection = true;
4194 else 4181 else
4195 pi->thermal_protection = false; 4182 pi->thermal_protection = false;
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 10f712e37003..e66e72077350 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -2299,9 +2299,13 @@ int r600_init_microcode(struct radeon_device *rdev)
2299 if ((rdev->family >= CHIP_RV770) && (rdev->family <= CHIP_HEMLOCK)) { 2299 if ((rdev->family >= CHIP_RV770) && (rdev->family <= CHIP_HEMLOCK)) {
2300 snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", smc_chip_name); 2300 snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", smc_chip_name);
2301 err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev); 2301 err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev);
2302 if (err) 2302 if (err) {
2303 goto out; 2303 printk(KERN_ERR
2304 if (rdev->smc_fw->size != smc_req_size) { 2304 "smc: error loading firmware \"%s\"\n",
2305 fw_name);
2306 release_firmware(rdev->smc_fw);
2307 rdev->smc_fw = NULL;
2308 } else if (rdev->smc_fw->size != smc_req_size) {
2305 printk(KERN_ERR 2309 printk(KERN_ERR
2306 "smc: Bogus length %zu in firmware \"%s\"\n", 2310 "smc: Bogus length %zu in firmware \"%s\"\n",
2307 rdev->smc_fw->size, fw_name); 2311 rdev->smc_fw->size, fw_name);
@@ -2697,12 +2701,29 @@ int r600_uvd_rbc_start(struct radeon_device *rdev)
2697 return 0; 2701 return 0;
2698} 2702}
2699 2703
2700void r600_uvd_rbc_stop(struct radeon_device *rdev) 2704void r600_uvd_stop(struct radeon_device *rdev)
2701{ 2705{
2702 struct radeon_ring *ring = &rdev->ring[R600_RING_TYPE_UVD_INDEX]; 2706 struct radeon_ring *ring = &rdev->ring[R600_RING_TYPE_UVD_INDEX];
2703 2707
2704 /* force RBC into idle state */ 2708 /* force RBC into idle state */
2705 WREG32(UVD_RBC_RB_CNTL, 0x11010101); 2709 WREG32(UVD_RBC_RB_CNTL, 0x11010101);
2710
2711 /* Stall UMC and register bus before resetting VCPU */
2712 WREG32_P(UVD_LMI_CTRL2, 1 << 8, ~(1 << 8));
2713 WREG32_P(UVD_RB_ARB_CTRL, 1 << 3, ~(1 << 3));
2714 mdelay(1);
2715
2716 /* put VCPU into reset */
2717 WREG32(UVD_SOFT_RESET, VCPU_SOFT_RESET);
2718 mdelay(5);
2719
2720 /* disable VCPU clock */
2721 WREG32(UVD_VCPU_CNTL, 0x0);
2722
2723 /* Unstall UMC and register bus */
2724 WREG32_P(UVD_LMI_CTRL2, 0, ~(1 << 8));
2725 WREG32_P(UVD_RB_ARB_CTRL, 0, ~(1 << 3));
2726
2706 ring->ready = false; 2727 ring->ready = false;
2707} 2728}
2708 2729
@@ -2722,6 +2743,11 @@ int r600_uvd_init(struct radeon_device *rdev)
2722 /* disable interupt */ 2743 /* disable interupt */
2723 WREG32_P(UVD_MASTINT_EN, 0, ~(1 << 1)); 2744 WREG32_P(UVD_MASTINT_EN, 0, ~(1 << 1));
2724 2745
2746 /* Stall UMC and register bus before resetting VCPU */
2747 WREG32_P(UVD_LMI_CTRL2, 1 << 8, ~(1 << 8));
2748 WREG32_P(UVD_RB_ARB_CTRL, 1 << 3, ~(1 << 3));
2749 mdelay(1);
2750
2725 /* put LMI, VCPU, RBC etc... into reset */ 2751 /* put LMI, VCPU, RBC etc... into reset */
2726 WREG32(UVD_SOFT_RESET, LMI_SOFT_RESET | VCPU_SOFT_RESET | 2752 WREG32(UVD_SOFT_RESET, LMI_SOFT_RESET | VCPU_SOFT_RESET |
2727 LBSI_SOFT_RESET | RBC_SOFT_RESET | CSM_SOFT_RESET | 2753 LBSI_SOFT_RESET | RBC_SOFT_RESET | CSM_SOFT_RESET |
@@ -2751,10 +2777,6 @@ int r600_uvd_init(struct radeon_device *rdev)
2751 WREG32(UVD_MPC_SET_ALU, 0); 2777 WREG32(UVD_MPC_SET_ALU, 0);
2752 WREG32(UVD_MPC_SET_MUX, 0x88); 2778 WREG32(UVD_MPC_SET_MUX, 0x88);
2753 2779
2754 /* Stall UMC */
2755 WREG32_P(UVD_LMI_CTRL2, 1 << 8, ~(1 << 8));
2756 WREG32_P(UVD_RB_ARB_CTRL, 1 << 3, ~(1 << 3));
2757
2758 /* take all subblocks out of reset, except VCPU */ 2780 /* take all subblocks out of reset, except VCPU */
2759 WREG32(UVD_SOFT_RESET, VCPU_SOFT_RESET); 2781 WREG32(UVD_SOFT_RESET, VCPU_SOFT_RESET);
2760 mdelay(5); 2782 mdelay(5);
@@ -3312,6 +3334,8 @@ static int r600_startup(struct radeon_device *rdev)
3312 /* enable pcie gen2 link */ 3334 /* enable pcie gen2 link */
3313 r600_pcie_gen2_enable(rdev); 3335 r600_pcie_gen2_enable(rdev);
3314 3336
3337 r600_mc_program(rdev);
3338
3315 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) { 3339 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) {
3316 r = r600_init_microcode(rdev); 3340 r = r600_init_microcode(rdev);
3317 if (r) { 3341 if (r) {
@@ -3324,7 +3348,6 @@ static int r600_startup(struct radeon_device *rdev)
3324 if (r) 3348 if (r)
3325 return r; 3349 return r;
3326 3350
3327 r600_mc_program(rdev);
3328 if (rdev->flags & RADEON_IS_AGP) { 3351 if (rdev->flags & RADEON_IS_AGP) {
3329 r600_agp_enable(rdev); 3352 r600_agp_enable(rdev);
3330 } else { 3353 } else {
diff --git a/drivers/gpu/drm/radeon/r600_hdmi.c b/drivers/gpu/drm/radeon/r600_hdmi.c
index f48240bb8c56..f264df5470f7 100644
--- a/drivers/gpu/drm/radeon/r600_hdmi.c
+++ b/drivers/gpu/drm/radeon/r600_hdmi.c
@@ -226,10 +226,29 @@ void r600_audio_set_dto(struct drm_encoder *encoder, u32 clock)
226 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 226 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
227 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; 227 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
228 u32 base_rate = 24000; 228 u32 base_rate = 24000;
229 u32 max_ratio = clock / base_rate;
230 u32 dto_phase;
231 u32 dto_modulo = clock;
232 u32 wallclock_ratio;
233 u32 dto_cntl;
229 234
230 if (!dig || !dig->afmt) 235 if (!dig || !dig->afmt)
231 return; 236 return;
232 237
238 if (max_ratio >= 8) {
239 dto_phase = 192 * 1000;
240 wallclock_ratio = 3;
241 } else if (max_ratio >= 4) {
242 dto_phase = 96 * 1000;
243 wallclock_ratio = 2;
244 } else if (max_ratio >= 2) {
245 dto_phase = 48 * 1000;
246 wallclock_ratio = 1;
247 } else {
248 dto_phase = 24 * 1000;
249 wallclock_ratio = 0;
250 }
251
233 /* there are two DTOs selected by DCCG_AUDIO_DTO_SELECT. 252 /* there are two DTOs selected by DCCG_AUDIO_DTO_SELECT.
234 * doesn't matter which one you use. Just use the first one. 253 * doesn't matter which one you use. Just use the first one.
235 */ 254 */
@@ -242,9 +261,21 @@ void r600_audio_set_dto(struct drm_encoder *encoder, u32 clock)
242 /* according to the reg specs, this should DCE3.2 only, but in 261 /* according to the reg specs, this should DCE3.2 only, but in
243 * practice it seems to cover DCE3.0 as well. 262 * practice it seems to cover DCE3.0 as well.
244 */ 263 */
245 WREG32(DCCG_AUDIO_DTO0_PHASE, base_rate * 100); 264 if (dig->dig_encoder == 0) {
246 WREG32(DCCG_AUDIO_DTO0_MODULE, clock * 100); 265 dto_cntl = RREG32(DCCG_AUDIO_DTO0_CNTL) & ~DCCG_AUDIO_DTO_WALLCLOCK_RATIO_MASK;
247 WREG32(DCCG_AUDIO_DTO_SELECT, 0); /* select DTO0 */ 266 dto_cntl |= DCCG_AUDIO_DTO_WALLCLOCK_RATIO(wallclock_ratio);
267 WREG32(DCCG_AUDIO_DTO0_CNTL, dto_cntl);
268 WREG32(DCCG_AUDIO_DTO0_PHASE, dto_phase);
269 WREG32(DCCG_AUDIO_DTO0_MODULE, dto_modulo);
270 WREG32(DCCG_AUDIO_DTO_SELECT, 0); /* select DTO0 */
271 } else {
272 dto_cntl = RREG32(DCCG_AUDIO_DTO1_CNTL) & ~DCCG_AUDIO_DTO_WALLCLOCK_RATIO_MASK;
273 dto_cntl |= DCCG_AUDIO_DTO_WALLCLOCK_RATIO(wallclock_ratio);
274 WREG32(DCCG_AUDIO_DTO1_CNTL, dto_cntl);
275 WREG32(DCCG_AUDIO_DTO1_PHASE, dto_phase);
276 WREG32(DCCG_AUDIO_DTO1_MODULE, dto_modulo);
277 WREG32(DCCG_AUDIO_DTO_SELECT, 1); /* select DTO1 */
278 }
248 } else { 279 } else {
249 /* according to the reg specs, this should be DCE2.0 and DCE3.0 */ 280 /* according to the reg specs, this should be DCE2.0 and DCE3.0 */
250 WREG32(AUDIO_DTO, AUDIO_DTO_PHASE(base_rate / 10) | 281 WREG32(AUDIO_DTO, AUDIO_DTO_PHASE(base_rate / 10) |
diff --git a/drivers/gpu/drm/radeon/r600d.h b/drivers/gpu/drm/radeon/r600d.h
index 8e3fe815edab..7c780839a7f4 100644
--- a/drivers/gpu/drm/radeon/r600d.h
+++ b/drivers/gpu/drm/radeon/r600d.h
@@ -933,6 +933,9 @@
933#define DCCG_AUDIO_DTO0_LOAD 0x051c 933#define DCCG_AUDIO_DTO0_LOAD 0x051c
934# define DTO_LOAD (1 << 31) 934# define DTO_LOAD (1 << 31)
935#define DCCG_AUDIO_DTO0_CNTL 0x0520 935#define DCCG_AUDIO_DTO0_CNTL 0x0520
936# define DCCG_AUDIO_DTO_WALLCLOCK_RATIO(x) (((x) & 7) << 0)
937# define DCCG_AUDIO_DTO_WALLCLOCK_RATIO_MASK 7
938# define DCCG_AUDIO_DTO_WALLCLOCK_RATIO_SHIFT 0
936 939
937#define DCCG_AUDIO_DTO1_PHASE 0x0524 940#define DCCG_AUDIO_DTO1_PHASE 0x0524
938#define DCCG_AUDIO_DTO1_MODULE 0x0528 941#define DCCG_AUDIO_DTO1_MODULE 0x0528
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 2f08219c39b6..274b8e1b889f 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1468,7 +1468,6 @@ struct radeon_uvd {
1468 void *cpu_addr; 1468 void *cpu_addr;
1469 uint64_t gpu_addr; 1469 uint64_t gpu_addr;
1470 void *saved_bo; 1470 void *saved_bo;
1471 unsigned fw_size;
1472 atomic_t handles[RADEON_MAX_UVD_HANDLES]; 1471 atomic_t handles[RADEON_MAX_UVD_HANDLES];
1473 struct drm_file *filp[RADEON_MAX_UVD_HANDLES]; 1472 struct drm_file *filp[RADEON_MAX_UVD_HANDLES];
1474 struct delayed_work idle_work; 1473 struct delayed_work idle_work;
@@ -2066,6 +2065,7 @@ struct radeon_device {
2066 const struct firmware *mec_fw; /* CIK MEC firmware */ 2065 const struct firmware *mec_fw; /* CIK MEC firmware */
2067 const struct firmware *sdma_fw; /* CIK SDMA firmware */ 2066 const struct firmware *sdma_fw; /* CIK SDMA firmware */
2068 const struct firmware *smc_fw; /* SMC firmware */ 2067 const struct firmware *smc_fw; /* SMC firmware */
2068 const struct firmware *uvd_fw; /* UVD firmware */
2069 struct r600_blit r600_blit; 2069 struct r600_blit r600_blit;
2070 struct r600_vram_scratch vram_scratch; 2070 struct r600_vram_scratch vram_scratch;
2071 int msi_enabled; /* msi enabled */ 2071 int msi_enabled; /* msi enabled */
@@ -2095,6 +2095,8 @@ struct radeon_device {
2095 /* ACPI interface */ 2095 /* ACPI interface */
2096 struct radeon_atif atif; 2096 struct radeon_atif atif;
2097 struct radeon_atcs atcs; 2097 struct radeon_atcs atcs;
2098 /* srbm instance registers */
2099 struct mutex srbm_mutex;
2098}; 2100};
2099 2101
2100int radeon_device_init(struct radeon_device *rdev, 2102int radeon_device_init(struct radeon_device *rdev,
diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h
index 902479fa737f..3d61d5aac18f 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.h
+++ b/drivers/gpu/drm/radeon/radeon_asic.h
@@ -441,7 +441,7 @@ void rs780_dpm_debugfs_print_current_performance_level(struct radeon_device *rde
441/* uvd */ 441/* uvd */
442int r600_uvd_init(struct radeon_device *rdev); 442int r600_uvd_init(struct radeon_device *rdev);
443int r600_uvd_rbc_start(struct radeon_device *rdev); 443int r600_uvd_rbc_start(struct radeon_device *rdev);
444void r600_uvd_rbc_stop(struct radeon_device *rdev); 444void r600_uvd_stop(struct radeon_device *rdev);
445int r600_uvd_ib_test(struct radeon_device *rdev, struct radeon_ring *ring); 445int r600_uvd_ib_test(struct radeon_device *rdev, struct radeon_ring *ring);
446void r600_uvd_fence_emit(struct radeon_device *rdev, 446void r600_uvd_fence_emit(struct radeon_device *rdev,
447 struct radeon_fence *fence); 447 struct radeon_fence *fence);
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 82335e38ec4f..63398ae1dbf5 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -1163,6 +1163,7 @@ int radeon_device_init(struct radeon_device *rdev,
1163 mutex_init(&rdev->gem.mutex); 1163 mutex_init(&rdev->gem.mutex);
1164 mutex_init(&rdev->pm.mutex); 1164 mutex_init(&rdev->pm.mutex);
1165 mutex_init(&rdev->gpu_clock_mutex); 1165 mutex_init(&rdev->gpu_clock_mutex);
1166 mutex_init(&rdev->srbm_mutex);
1166 init_rwsem(&rdev->pm.mclk_lock); 1167 init_rwsem(&rdev->pm.mclk_lock);
1167 init_rwsem(&rdev->exclusive_lock); 1168 init_rwsem(&rdev->exclusive_lock);
1168 init_waitqueue_head(&rdev->irq.vblank_queue); 1169 init_waitqueue_head(&rdev->irq.vblank_queue);
@@ -1519,6 +1520,7 @@ int radeon_gpu_reset(struct radeon_device *rdev)
1519 radeon_save_bios_scratch_regs(rdev); 1520 radeon_save_bios_scratch_regs(rdev);
1520 /* block TTM */ 1521 /* block TTM */
1521 resched = ttm_bo_lock_delayed_workqueue(&rdev->mman.bdev); 1522 resched = ttm_bo_lock_delayed_workqueue(&rdev->mman.bdev);
1523 radeon_pm_suspend(rdev);
1522 radeon_suspend(rdev); 1524 radeon_suspend(rdev);
1523 1525
1524 for (i = 0; i < RADEON_NUM_RINGS; ++i) { 1526 for (i = 0; i < RADEON_NUM_RINGS; ++i) {
@@ -1564,6 +1566,7 @@ retry:
1564 } 1566 }
1565 } 1567 }
1566 1568
1569 radeon_pm_resume(rdev);
1567 drm_helper_resume_force_mode(rdev->ddev); 1570 drm_helper_resume_force_mode(rdev->ddev);
1568 1571
1569 ttm_bo_unlock_delayed_workqueue(&rdev->mman.bdev, resched); 1572 ttm_bo_unlock_delayed_workqueue(&rdev->mman.bdev, resched);
diff --git a/drivers/gpu/drm/radeon/radeon_fence.c b/drivers/gpu/drm/radeon/radeon_fence.c
index 7ddb0efe2408..ddb8f8e04eb5 100644
--- a/drivers/gpu/drm/radeon/radeon_fence.c
+++ b/drivers/gpu/drm/radeon/radeon_fence.c
@@ -782,7 +782,7 @@ int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring)
782 782
783 } else { 783 } else {
784 /* put fence directly behind firmware */ 784 /* put fence directly behind firmware */
785 index = ALIGN(rdev->uvd.fw_size, 8); 785 index = ALIGN(rdev->uvd_fw->size, 8);
786 rdev->fence_drv[ring].cpu_addr = rdev->uvd.cpu_addr + index; 786 rdev->fence_drv[ring].cpu_addr = rdev->uvd.cpu_addr + index;
787 rdev->fence_drv[ring].gpu_addr = rdev->uvd.gpu_addr + index; 787 rdev->fence_drv[ring].gpu_addr = rdev->uvd.gpu_addr + index;
788 } 788 }
diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c
index 6a51d943ccf4..b990b1a2bd50 100644
--- a/drivers/gpu/drm/radeon/radeon_gart.c
+++ b/drivers/gpu/drm/radeon/radeon_gart.c
@@ -207,7 +207,6 @@ void radeon_gart_table_vram_free(struct radeon_device *rdev)
207 if (rdev->gart.robj == NULL) { 207 if (rdev->gart.robj == NULL) {
208 return; 208 return;
209 } 209 }
210 radeon_gart_table_vram_unpin(rdev);
211 radeon_bo_unref(&rdev->gart.robj); 210 radeon_bo_unref(&rdev->gart.robj);
212} 211}
213 212
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
index f374c467aaca..c557850cd345 100644
--- a/drivers/gpu/drm/radeon/radeon_pm.c
+++ b/drivers/gpu/drm/radeon/radeon_pm.c
@@ -1176,7 +1176,14 @@ int radeon_pm_init(struct radeon_device *rdev)
1176 case CHIP_VERDE: 1176 case CHIP_VERDE:
1177 case CHIP_OLAND: 1177 case CHIP_OLAND:
1178 case CHIP_HAINAN: 1178 case CHIP_HAINAN:
1179 if (radeon_dpm == 1) 1179 /* DPM requires the RLC, RV770+ dGPU requires SMC */
1180 if (!rdev->rlc_fw)
1181 rdev->pm.pm_method = PM_METHOD_PROFILE;
1182 else if ((rdev->family >= CHIP_RV770) &&
1183 (!(rdev->flags & RADEON_IS_IGP)) &&
1184 (!rdev->smc_fw))
1185 rdev->pm.pm_method = PM_METHOD_PROFILE;
1186 else if (radeon_dpm == 1)
1180 rdev->pm.pm_method = PM_METHOD_DPM; 1187 rdev->pm.pm_method = PM_METHOD_DPM;
1181 else 1188 else
1182 rdev->pm.pm_method = PM_METHOD_PROFILE; 1189 rdev->pm.pm_method = PM_METHOD_PROFILE;
diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c
index 414fd145d20e..f1c15754e73c 100644
--- a/drivers/gpu/drm/radeon/radeon_uvd.c
+++ b/drivers/gpu/drm/radeon/radeon_uvd.c
@@ -56,7 +56,6 @@ static void radeon_uvd_idle_work_handler(struct work_struct *work);
56 56
57int radeon_uvd_init(struct radeon_device *rdev) 57int radeon_uvd_init(struct radeon_device *rdev)
58{ 58{
59 const struct firmware *fw;
60 unsigned long bo_size; 59 unsigned long bo_size;
61 const char *fw_name; 60 const char *fw_name;
62 int i, r; 61 int i, r;
@@ -105,14 +104,14 @@ int radeon_uvd_init(struct radeon_device *rdev)
105 return -EINVAL; 104 return -EINVAL;
106 } 105 }
107 106
108 r = request_firmware(&fw, fw_name, rdev->dev); 107 r = request_firmware(&rdev->uvd_fw, fw_name, rdev->dev);
109 if (r) { 108 if (r) {
110 dev_err(rdev->dev, "radeon_uvd: Can't load firmware \"%s\"\n", 109 dev_err(rdev->dev, "radeon_uvd: Can't load firmware \"%s\"\n",
111 fw_name); 110 fw_name);
112 return r; 111 return r;
113 } 112 }
114 113
115 bo_size = RADEON_GPU_PAGE_ALIGN(fw->size + 8) + 114 bo_size = RADEON_GPU_PAGE_ALIGN(rdev->uvd_fw->size + 8) +
116 RADEON_UVD_STACK_SIZE + RADEON_UVD_HEAP_SIZE; 115 RADEON_UVD_STACK_SIZE + RADEON_UVD_HEAP_SIZE;
117 r = radeon_bo_create(rdev, bo_size, PAGE_SIZE, true, 116 r = radeon_bo_create(rdev, bo_size, PAGE_SIZE, true,
118 RADEON_GEM_DOMAIN_VRAM, NULL, &rdev->uvd.vcpu_bo); 117 RADEON_GEM_DOMAIN_VRAM, NULL, &rdev->uvd.vcpu_bo);
@@ -145,12 +144,6 @@ int radeon_uvd_init(struct radeon_device *rdev)
145 144
146 radeon_bo_unreserve(rdev->uvd.vcpu_bo); 145 radeon_bo_unreserve(rdev->uvd.vcpu_bo);
147 146
148 rdev->uvd.fw_size = fw->size;
149 memset(rdev->uvd.cpu_addr, 0, bo_size);
150 memcpy(rdev->uvd.cpu_addr, fw->data, fw->size);
151
152 release_firmware(fw);
153
154 for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) { 147 for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) {
155 atomic_set(&rdev->uvd.handles[i], 0); 148 atomic_set(&rdev->uvd.handles[i], 0);
156 rdev->uvd.filp[i] = NULL; 149 rdev->uvd.filp[i] = NULL;
@@ -174,33 +167,60 @@ void radeon_uvd_fini(struct radeon_device *rdev)
174 } 167 }
175 168
176 radeon_bo_unref(&rdev->uvd.vcpu_bo); 169 radeon_bo_unref(&rdev->uvd.vcpu_bo);
170
171 release_firmware(rdev->uvd_fw);
177} 172}
178 173
179int radeon_uvd_suspend(struct radeon_device *rdev) 174int radeon_uvd_suspend(struct radeon_device *rdev)
180{ 175{
181 unsigned size; 176 unsigned size;
177 void *ptr;
178 int i;
182 179
183 if (rdev->uvd.vcpu_bo == NULL) 180 if (rdev->uvd.vcpu_bo == NULL)
184 return 0; 181 return 0;
185 182
183 for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i)
184 if (atomic_read(&rdev->uvd.handles[i]))
185 break;
186
187 if (i == RADEON_MAX_UVD_HANDLES)
188 return 0;
189
186 size = radeon_bo_size(rdev->uvd.vcpu_bo); 190 size = radeon_bo_size(rdev->uvd.vcpu_bo);
191 size -= rdev->uvd_fw->size;
192
193 ptr = rdev->uvd.cpu_addr;
194 ptr += rdev->uvd_fw->size;
195
187 rdev->uvd.saved_bo = kmalloc(size, GFP_KERNEL); 196 rdev->uvd.saved_bo = kmalloc(size, GFP_KERNEL);
188 memcpy(rdev->uvd.saved_bo, rdev->uvd.cpu_addr, size); 197 memcpy(rdev->uvd.saved_bo, ptr, size);
189 198
190 return 0; 199 return 0;
191} 200}
192 201
193int radeon_uvd_resume(struct radeon_device *rdev) 202int radeon_uvd_resume(struct radeon_device *rdev)
194{ 203{
204 unsigned size;
205 void *ptr;
206
195 if (rdev->uvd.vcpu_bo == NULL) 207 if (rdev->uvd.vcpu_bo == NULL)
196 return -EINVAL; 208 return -EINVAL;
197 209
210 memcpy(rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size);
211
212 size = radeon_bo_size(rdev->uvd.vcpu_bo);
213 size -= rdev->uvd_fw->size;
214
215 ptr = rdev->uvd.cpu_addr;
216 ptr += rdev->uvd_fw->size;
217
198 if (rdev->uvd.saved_bo != NULL) { 218 if (rdev->uvd.saved_bo != NULL) {
199 unsigned size = radeon_bo_size(rdev->uvd.vcpu_bo); 219 memcpy(ptr, rdev->uvd.saved_bo, size);
200 memcpy(rdev->uvd.cpu_addr, rdev->uvd.saved_bo, size);
201 kfree(rdev->uvd.saved_bo); 220 kfree(rdev->uvd.saved_bo);
202 rdev->uvd.saved_bo = NULL; 221 rdev->uvd.saved_bo = NULL;
203 } 222 } else
223 memset(ptr, 0, size);
204 224
205 return 0; 225 return 0;
206} 226}
@@ -215,8 +235,8 @@ void radeon_uvd_free_handles(struct radeon_device *rdev, struct drm_file *filp)
215{ 235{
216 int i, r; 236 int i, r;
217 for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) { 237 for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) {
218 if (rdev->uvd.filp[i] == filp) { 238 uint32_t handle = atomic_read(&rdev->uvd.handles[i]);
219 uint32_t handle = atomic_read(&rdev->uvd.handles[i]); 239 if (handle != 0 && rdev->uvd.filp[i] == filp) {
220 struct radeon_fence *fence; 240 struct radeon_fence *fence;
221 241
222 r = radeon_uvd_get_destroy_msg(rdev, 242 r = radeon_uvd_get_destroy_msg(rdev,
@@ -337,8 +357,10 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
337 } 357 }
338 358
339 r = radeon_bo_kmap(bo, &ptr); 359 r = radeon_bo_kmap(bo, &ptr);
340 if (r) 360 if (r) {
361 DRM_ERROR("Failed mapping the UVD message (%d)!\n", r);
341 return r; 362 return r;
363 }
342 364
343 msg = ptr + offset; 365 msg = ptr + offset;
344 366
@@ -364,8 +386,14 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
364 radeon_bo_kunmap(bo); 386 radeon_bo_kunmap(bo);
365 return 0; 387 return 0;
366 } else { 388 } else {
367 /* it's a create msg, no special handling needed */
368 radeon_bo_kunmap(bo); 389 radeon_bo_kunmap(bo);
390
391 if (msg_type != 0) {
392 DRM_ERROR("Illegal UVD message type (%d)!\n", msg_type);
393 return -EINVAL;
394 }
395
396 /* it's a create msg, no special handling needed */
369 } 397 }
370 398
371 /* create or decode, validate the handle */ 399 /* create or decode, validate the handle */
@@ -388,7 +416,7 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
388 416
389static int radeon_uvd_cs_reloc(struct radeon_cs_parser *p, 417static int radeon_uvd_cs_reloc(struct radeon_cs_parser *p,
390 int data0, int data1, 418 int data0, int data1,
391 unsigned buf_sizes[]) 419 unsigned buf_sizes[], bool *has_msg_cmd)
392{ 420{
393 struct radeon_cs_chunk *relocs_chunk; 421 struct radeon_cs_chunk *relocs_chunk;
394 struct radeon_cs_reloc *reloc; 422 struct radeon_cs_reloc *reloc;
@@ -417,7 +445,7 @@ static int radeon_uvd_cs_reloc(struct radeon_cs_parser *p,
417 445
418 if (cmd < 0x4) { 446 if (cmd < 0x4) {
419 if ((end - start) < buf_sizes[cmd]) { 447 if ((end - start) < buf_sizes[cmd]) {
420 DRM_ERROR("buffer to small (%d / %d)!\n", 448 DRM_ERROR("buffer (%d) to small (%d / %d)!\n", cmd,
421 (unsigned)(end - start), buf_sizes[cmd]); 449 (unsigned)(end - start), buf_sizes[cmd]);
422 return -EINVAL; 450 return -EINVAL;
423 } 451 }
@@ -442,9 +470,17 @@ static int radeon_uvd_cs_reloc(struct radeon_cs_parser *p,
442 } 470 }
443 471
444 if (cmd == 0) { 472 if (cmd == 0) {
473 if (*has_msg_cmd) {
474 DRM_ERROR("More than one message in a UVD-IB!\n");
475 return -EINVAL;
476 }
477 *has_msg_cmd = true;
445 r = radeon_uvd_cs_msg(p, reloc->robj, offset, buf_sizes); 478 r = radeon_uvd_cs_msg(p, reloc->robj, offset, buf_sizes);
446 if (r) 479 if (r)
447 return r; 480 return r;
481 } else if (!*has_msg_cmd) {
482 DRM_ERROR("Message needed before other commands are send!\n");
483 return -EINVAL;
448 } 484 }
449 485
450 return 0; 486 return 0;
@@ -453,7 +489,8 @@ static int radeon_uvd_cs_reloc(struct radeon_cs_parser *p,
453static int radeon_uvd_cs_reg(struct radeon_cs_parser *p, 489static int radeon_uvd_cs_reg(struct radeon_cs_parser *p,
454 struct radeon_cs_packet *pkt, 490 struct radeon_cs_packet *pkt,
455 int *data0, int *data1, 491 int *data0, int *data1,
456 unsigned buf_sizes[]) 492 unsigned buf_sizes[],
493 bool *has_msg_cmd)
457{ 494{
458 int i, r; 495 int i, r;
459 496
@@ -467,7 +504,8 @@ static int radeon_uvd_cs_reg(struct radeon_cs_parser *p,
467 *data1 = p->idx; 504 *data1 = p->idx;
468 break; 505 break;
469 case UVD_GPCOM_VCPU_CMD: 506 case UVD_GPCOM_VCPU_CMD:
470 r = radeon_uvd_cs_reloc(p, *data0, *data1, buf_sizes); 507 r = radeon_uvd_cs_reloc(p, *data0, *data1,
508 buf_sizes, has_msg_cmd);
471 if (r) 509 if (r)
472 return r; 510 return r;
473 break; 511 break;
@@ -488,6 +526,9 @@ int radeon_uvd_cs_parse(struct radeon_cs_parser *p)
488 struct radeon_cs_packet pkt; 526 struct radeon_cs_packet pkt;
489 int r, data0 = 0, data1 = 0; 527 int r, data0 = 0, data1 = 0;
490 528
529 /* does the IB has a msg command */
530 bool has_msg_cmd = false;
531
491 /* minimum buffer sizes */ 532 /* minimum buffer sizes */
492 unsigned buf_sizes[] = { 533 unsigned buf_sizes[] = {
493 [0x00000000] = 2048, 534 [0x00000000] = 2048,
@@ -514,8 +555,8 @@ int radeon_uvd_cs_parse(struct radeon_cs_parser *p)
514 return r; 555 return r;
515 switch (pkt.type) { 556 switch (pkt.type) {
516 case RADEON_PACKET_TYPE0: 557 case RADEON_PACKET_TYPE0:
517 r = radeon_uvd_cs_reg(p, &pkt, &data0, 558 r = radeon_uvd_cs_reg(p, &pkt, &data0, &data1,
518 &data1, buf_sizes); 559 buf_sizes, &has_msg_cmd);
519 if (r) 560 if (r)
520 return r; 561 return r;
521 break; 562 break;
@@ -527,6 +568,12 @@ int radeon_uvd_cs_parse(struct radeon_cs_parser *p)
527 return -EINVAL; 568 return -EINVAL;
528 } 569 }
529 } while (p->idx < p->chunks[p->chunk_ib_idx].length_dw); 570 } while (p->idx < p->chunks[p->chunk_ib_idx].length_dw);
571
572 if (!has_msg_cmd) {
573 DRM_ERROR("UVD-IBs need a msg command!\n");
574 return -EINVAL;
575 }
576
530 return 0; 577 return 0;
531} 578}
532 579
diff --git a/drivers/gpu/drm/radeon/rv6xx_dpm.c b/drivers/gpu/drm/radeon/rv6xx_dpm.c
index 363018c60412..bdd888b4db2b 100644
--- a/drivers/gpu/drm/radeon/rv6xx_dpm.c
+++ b/drivers/gpu/drm/radeon/rv6xx_dpm.c
@@ -1944,9 +1944,7 @@ static int rv6xx_parse_power_table(struct radeon_device *rdev)
1944 1944
1945int rv6xx_dpm_init(struct radeon_device *rdev) 1945int rv6xx_dpm_init(struct radeon_device *rdev)
1946{ 1946{
1947 int index = GetIndexIntoMasterTable(DATA, ASIC_InternalSS_Info); 1947 struct radeon_atom_ss ss;
1948 uint16_t data_offset, size;
1949 uint8_t frev, crev;
1950 struct atom_clock_dividers dividers; 1948 struct atom_clock_dividers dividers;
1951 struct rv6xx_power_info *pi; 1949 struct rv6xx_power_info *pi;
1952 int ret; 1950 int ret;
@@ -1989,16 +1987,18 @@ int rv6xx_dpm_init(struct radeon_device *rdev)
1989 1987
1990 pi->gfx_clock_gating = true; 1988 pi->gfx_clock_gating = true;
1991 1989
1992 if (atom_parse_data_header(rdev->mode_info.atom_context, index, &size, 1990 pi->sclk_ss = radeon_atombios_get_asic_ss_info(rdev, &ss,
1993 &frev, &crev, &data_offset)) { 1991 ASIC_INTERNAL_ENGINE_SS, 0);
1994 pi->sclk_ss = true; 1992 pi->mclk_ss = radeon_atombios_get_asic_ss_info(rdev, &ss,
1995 pi->mclk_ss = true; 1993 ASIC_INTERNAL_MEMORY_SS, 0);
1994
1995 /* Disable sclk ss, causes hangs on a lot of systems */
1996 pi->sclk_ss = false;
1997
1998 if (pi->sclk_ss || pi->mclk_ss)
1996 pi->dynamic_ss = true; 1999 pi->dynamic_ss = true;
1997 } else { 2000 else
1998 pi->sclk_ss = false;
1999 pi->mclk_ss = false;
2000 pi->dynamic_ss = false; 2001 pi->dynamic_ss = false;
2001 }
2002 2002
2003 pi->dynamic_pcie_gen2 = true; 2003 pi->dynamic_pcie_gen2 = true;
2004 2004
diff --git a/drivers/gpu/drm/radeon/rv770.c b/drivers/gpu/drm/radeon/rv770.c
index 30ea14e8854c..bcc68ec204ad 100644
--- a/drivers/gpu/drm/radeon/rv770.c
+++ b/drivers/gpu/drm/radeon/rv770.c
@@ -813,7 +813,7 @@ int rv770_uvd_resume(struct radeon_device *rdev)
813 813
814 /* programm the VCPU memory controller bits 0-27 */ 814 /* programm the VCPU memory controller bits 0-27 */
815 addr = rdev->uvd.gpu_addr >> 3; 815 addr = rdev->uvd.gpu_addr >> 3;
816 size = RADEON_GPU_PAGE_ALIGN(rdev->uvd.fw_size + 4) >> 3; 816 size = RADEON_GPU_PAGE_ALIGN(rdev->uvd_fw->size + 4) >> 3;
817 WREG32(UVD_VCPU_CACHE_OFFSET0, addr); 817 WREG32(UVD_VCPU_CACHE_OFFSET0, addr);
818 WREG32(UVD_VCPU_CACHE_SIZE0, size); 818 WREG32(UVD_VCPU_CACHE_SIZE0, size);
819 819
@@ -1829,6 +1829,8 @@ static int rv770_startup(struct radeon_device *rdev)
1829 /* enable pcie gen2 link */ 1829 /* enable pcie gen2 link */
1830 rv770_pcie_gen2_enable(rdev); 1830 rv770_pcie_gen2_enable(rdev);
1831 1831
1832 rv770_mc_program(rdev);
1833
1832 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) { 1834 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) {
1833 r = r600_init_microcode(rdev); 1835 r = r600_init_microcode(rdev);
1834 if (r) { 1836 if (r) {
@@ -1841,7 +1843,6 @@ static int rv770_startup(struct radeon_device *rdev)
1841 if (r) 1843 if (r)
1842 return r; 1844 return r;
1843 1845
1844 rv770_mc_program(rdev);
1845 if (rdev->flags & RADEON_IS_AGP) { 1846 if (rdev->flags & RADEON_IS_AGP) {
1846 rv770_agp_enable(rdev); 1847 rv770_agp_enable(rdev);
1847 } else { 1848 } else {
@@ -1983,6 +1984,7 @@ int rv770_resume(struct radeon_device *rdev)
1983int rv770_suspend(struct radeon_device *rdev) 1984int rv770_suspend(struct radeon_device *rdev)
1984{ 1985{
1985 r600_audio_fini(rdev); 1986 r600_audio_fini(rdev);
1987 r600_uvd_stop(rdev);
1986 radeon_uvd_suspend(rdev); 1988 radeon_uvd_suspend(rdev);
1987 r700_cp_stop(rdev); 1989 r700_cp_stop(rdev);
1988 r600_dma_stop(rdev); 1990 r600_dma_stop(rdev);
@@ -2098,6 +2100,7 @@ void rv770_fini(struct radeon_device *rdev)
2098 radeon_ib_pool_fini(rdev); 2100 radeon_ib_pool_fini(rdev);
2099 radeon_irq_kms_fini(rdev); 2101 radeon_irq_kms_fini(rdev);
2100 rv770_pcie_gart_fini(rdev); 2102 rv770_pcie_gart_fini(rdev);
2103 r600_uvd_stop(rdev);
2101 radeon_uvd_fini(rdev); 2104 radeon_uvd_fini(rdev);
2102 r600_vram_scratch_fini(rdev); 2105 r600_vram_scratch_fini(rdev);
2103 radeon_gem_fini(rdev); 2106 radeon_gem_fini(rdev);
diff --git a/drivers/gpu/drm/radeon/rv770_dpm.c b/drivers/gpu/drm/radeon/rv770_dpm.c
index 2d347925f77d..094c67a29d0d 100644
--- a/drivers/gpu/drm/radeon/rv770_dpm.c
+++ b/drivers/gpu/drm/radeon/rv770_dpm.c
@@ -2319,12 +2319,25 @@ int rv7xx_parse_power_table(struct radeon_device *rdev)
2319 return 0; 2319 return 0;
2320} 2320}
2321 2321
2322void rv770_get_engine_memory_ss(struct radeon_device *rdev)
2323{
2324 struct rv7xx_power_info *pi = rv770_get_pi(rdev);
2325 struct radeon_atom_ss ss;
2326
2327 pi->sclk_ss = radeon_atombios_get_asic_ss_info(rdev, &ss,
2328 ASIC_INTERNAL_ENGINE_SS, 0);
2329 pi->mclk_ss = radeon_atombios_get_asic_ss_info(rdev, &ss,
2330 ASIC_INTERNAL_MEMORY_SS, 0);
2331
2332 if (pi->sclk_ss || pi->mclk_ss)
2333 pi->dynamic_ss = true;
2334 else
2335 pi->dynamic_ss = false;
2336}
2337
2322int rv770_dpm_init(struct radeon_device *rdev) 2338int rv770_dpm_init(struct radeon_device *rdev)
2323{ 2339{
2324 struct rv7xx_power_info *pi; 2340 struct rv7xx_power_info *pi;
2325 int index = GetIndexIntoMasterTable(DATA, ASIC_InternalSS_Info);
2326 uint16_t data_offset, size;
2327 uint8_t frev, crev;
2328 struct atom_clock_dividers dividers; 2341 struct atom_clock_dividers dividers;
2329 int ret; 2342 int ret;
2330 2343
@@ -2369,16 +2382,7 @@ int rv770_dpm_init(struct radeon_device *rdev)
2369 pi->mvdd_control = 2382 pi->mvdd_control =
2370 radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_MVDDC, 0); 2383 radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_MVDDC, 0);
2371 2384
2372 if (atom_parse_data_header(rdev->mode_info.atom_context, index, &size, 2385 rv770_get_engine_memory_ss(rdev);
2373 &frev, &crev, &data_offset)) {
2374 pi->sclk_ss = true;
2375 pi->mclk_ss = true;
2376 pi->dynamic_ss = true;
2377 } else {
2378 pi->sclk_ss = false;
2379 pi->mclk_ss = false;
2380 pi->dynamic_ss = false;
2381 }
2382 2386
2383 pi->asi = RV770_ASI_DFLT; 2387 pi->asi = RV770_ASI_DFLT;
2384 pi->pasi = RV770_HASI_DFLT; 2388 pi->pasi = RV770_HASI_DFLT;
@@ -2393,8 +2397,7 @@ int rv770_dpm_init(struct radeon_device *rdev)
2393 2397
2394 pi->dynamic_pcie_gen2 = true; 2398 pi->dynamic_pcie_gen2 = true;
2395 2399
2396 if (pi->gfx_clock_gating && 2400 if (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE)
2397 (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE))
2398 pi->thermal_protection = true; 2401 pi->thermal_protection = true;
2399 else 2402 else
2400 pi->thermal_protection = false; 2403 pi->thermal_protection = false;
diff --git a/drivers/gpu/drm/radeon/rv770_dpm.h b/drivers/gpu/drm/radeon/rv770_dpm.h
index 96b1b2a62a8a..9244effc6b59 100644
--- a/drivers/gpu/drm/radeon/rv770_dpm.h
+++ b/drivers/gpu/drm/radeon/rv770_dpm.h
@@ -275,6 +275,7 @@ void rv770_set_uvd_clock_before_set_eng_clock(struct radeon_device *rdev,
275void rv770_set_uvd_clock_after_set_eng_clock(struct radeon_device *rdev, 275void rv770_set_uvd_clock_after_set_eng_clock(struct radeon_device *rdev,
276 struct radeon_ps *new_ps, 276 struct radeon_ps *new_ps,
277 struct radeon_ps *old_ps); 277 struct radeon_ps *old_ps);
278void rv770_get_engine_memory_ss(struct radeon_device *rdev);
278 279
279/* smc */ 280/* smc */
280int rv770_read_smc_soft_register(struct radeon_device *rdev, 281int rv770_read_smc_soft_register(struct radeon_device *rdev,
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
index 6ca904673a4f..daa8d2df8ec5 100644
--- a/drivers/gpu/drm/radeon/si.c
+++ b/drivers/gpu/drm/radeon/si.c
@@ -1663,9 +1663,13 @@ static int si_init_microcode(struct radeon_device *rdev)
1663 1663
1664 snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name); 1664 snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name);
1665 err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev); 1665 err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev);
1666 if (err) 1666 if (err) {
1667 goto out; 1667 printk(KERN_ERR
1668 if (rdev->smc_fw->size != smc_req_size) { 1668 "smc: error loading firmware \"%s\"\n",
1669 fw_name);
1670 release_firmware(rdev->smc_fw);
1671 rdev->smc_fw = NULL;
1672 } else if (rdev->smc_fw->size != smc_req_size) {
1669 printk(KERN_ERR 1673 printk(KERN_ERR
1670 "si_smc: Bogus length %zu in firmware \"%s\"\n", 1674 "si_smc: Bogus length %zu in firmware \"%s\"\n",
1671 rdev->smc_fw->size, fw_name); 1675 rdev->smc_fw->size, fw_name);
@@ -6418,6 +6422,8 @@ static int si_startup(struct radeon_device *rdev)
6418 /* enable aspm */ 6422 /* enable aspm */
6419 si_program_aspm(rdev); 6423 si_program_aspm(rdev);
6420 6424
6425 si_mc_program(rdev);
6426
6421 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->ce_fw || 6427 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->ce_fw ||
6422 !rdev->rlc_fw || !rdev->mc_fw) { 6428 !rdev->rlc_fw || !rdev->mc_fw) {
6423 r = si_init_microcode(rdev); 6429 r = si_init_microcode(rdev);
@@ -6437,7 +6443,6 @@ static int si_startup(struct radeon_device *rdev)
6437 if (r) 6443 if (r)
6438 return r; 6444 return r;
6439 6445
6440 si_mc_program(rdev);
6441 r = si_pcie_gart_enable(rdev); 6446 r = si_pcie_gart_enable(rdev);
6442 if (r) 6447 if (r)
6443 return r; 6448 return r;
@@ -6621,7 +6626,7 @@ int si_suspend(struct radeon_device *rdev)
6621 si_cp_enable(rdev, false); 6626 si_cp_enable(rdev, false);
6622 cayman_dma_stop(rdev); 6627 cayman_dma_stop(rdev);
6623 if (rdev->has_uvd) { 6628 if (rdev->has_uvd) {
6624 r600_uvd_rbc_stop(rdev); 6629 r600_uvd_stop(rdev);
6625 radeon_uvd_suspend(rdev); 6630 radeon_uvd_suspend(rdev);
6626 } 6631 }
6627 si_irq_suspend(rdev); 6632 si_irq_suspend(rdev);
@@ -6763,8 +6768,10 @@ void si_fini(struct radeon_device *rdev)
6763 radeon_vm_manager_fini(rdev); 6768 radeon_vm_manager_fini(rdev);
6764 radeon_ib_pool_fini(rdev); 6769 radeon_ib_pool_fini(rdev);
6765 radeon_irq_kms_fini(rdev); 6770 radeon_irq_kms_fini(rdev);
6766 if (rdev->has_uvd) 6771 if (rdev->has_uvd) {
6772 r600_uvd_stop(rdev);
6767 radeon_uvd_fini(rdev); 6773 radeon_uvd_fini(rdev);
6774 }
6768 si_pcie_gart_fini(rdev); 6775 si_pcie_gart_fini(rdev);
6769 r600_vram_scratch_fini(rdev); 6776 r600_vram_scratch_fini(rdev);
6770 radeon_gem_fini(rdev); 6777 radeon_gem_fini(rdev);
diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c
index 41825575b403..88699e3cd868 100644
--- a/drivers/gpu/drm/radeon/si_dpm.c
+++ b/drivers/gpu/drm/radeon/si_dpm.c
@@ -2903,7 +2903,8 @@ static void si_apply_state_adjust_rules(struct radeon_device *rdev,
2903{ 2903{
2904 struct ni_ps *ps = ni_get_ps(rps); 2904 struct ni_ps *ps = ni_get_ps(rps);
2905 struct radeon_clock_and_voltage_limits *max_limits; 2905 struct radeon_clock_and_voltage_limits *max_limits;
2906 bool disable_mclk_switching; 2906 bool disable_mclk_switching = false;
2907 bool disable_sclk_switching = false;
2907 u32 mclk, sclk; 2908 u32 mclk, sclk;
2908 u16 vddc, vddci; 2909 u16 vddc, vddci;
2909 int i; 2910 int i;
@@ -2911,8 +2912,11 @@ static void si_apply_state_adjust_rules(struct radeon_device *rdev,
2911 if ((rdev->pm.dpm.new_active_crtc_count > 1) || 2912 if ((rdev->pm.dpm.new_active_crtc_count > 1) ||
2912 ni_dpm_vblank_too_short(rdev)) 2913 ni_dpm_vblank_too_short(rdev))
2913 disable_mclk_switching = true; 2914 disable_mclk_switching = true;
2914 else 2915
2915 disable_mclk_switching = false; 2916 if (rps->vclk || rps->dclk) {
2917 disable_mclk_switching = true;
2918 disable_sclk_switching = true;
2919 }
2916 2920
2917 if (rdev->pm.dpm.ac_power) 2921 if (rdev->pm.dpm.ac_power)
2918 max_limits = &rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac; 2922 max_limits = &rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac;
@@ -2940,27 +2944,43 @@ static void si_apply_state_adjust_rules(struct radeon_device *rdev,
2940 2944
2941 if (disable_mclk_switching) { 2945 if (disable_mclk_switching) {
2942 mclk = ps->performance_levels[ps->performance_level_count - 1].mclk; 2946 mclk = ps->performance_levels[ps->performance_level_count - 1].mclk;
2943 sclk = ps->performance_levels[0].sclk;
2944 vddc = ps->performance_levels[0].vddc;
2945 vddci = ps->performance_levels[ps->performance_level_count - 1].vddci; 2947 vddci = ps->performance_levels[ps->performance_level_count - 1].vddci;
2946 } else { 2948 } else {
2947 sclk = ps->performance_levels[0].sclk;
2948 mclk = ps->performance_levels[0].mclk; 2949 mclk = ps->performance_levels[0].mclk;
2949 vddc = ps->performance_levels[0].vddc;
2950 vddci = ps->performance_levels[0].vddci; 2950 vddci = ps->performance_levels[0].vddci;
2951 } 2951 }
2952 2952
2953 if (disable_sclk_switching) {
2954 sclk = ps->performance_levels[ps->performance_level_count - 1].sclk;
2955 vddc = ps->performance_levels[ps->performance_level_count - 1].vddc;
2956 } else {
2957 sclk = ps->performance_levels[0].sclk;
2958 vddc = ps->performance_levels[0].vddc;
2959 }
2960
2953 /* adjusted low state */ 2961 /* adjusted low state */
2954 ps->performance_levels[0].sclk = sclk; 2962 ps->performance_levels[0].sclk = sclk;
2955 ps->performance_levels[0].mclk = mclk; 2963 ps->performance_levels[0].mclk = mclk;
2956 ps->performance_levels[0].vddc = vddc; 2964 ps->performance_levels[0].vddc = vddc;
2957 ps->performance_levels[0].vddci = vddci; 2965 ps->performance_levels[0].vddci = vddci;
2958 2966
2959 for (i = 1; i < ps->performance_level_count; i++) { 2967 if (disable_sclk_switching) {
2960 if (ps->performance_levels[i].sclk < ps->performance_levels[i - 1].sclk) 2968 sclk = ps->performance_levels[0].sclk;
2961 ps->performance_levels[i].sclk = ps->performance_levels[i - 1].sclk; 2969 for (i = 1; i < ps->performance_level_count; i++) {
2962 if (ps->performance_levels[i].vddc < ps->performance_levels[i - 1].vddc) 2970 if (sclk < ps->performance_levels[i].sclk)
2963 ps->performance_levels[i].vddc = ps->performance_levels[i - 1].vddc; 2971 sclk = ps->performance_levels[i].sclk;
2972 }
2973 for (i = 0; i < ps->performance_level_count; i++) {
2974 ps->performance_levels[i].sclk = sclk;
2975 ps->performance_levels[i].vddc = vddc;
2976 }
2977 } else {
2978 for (i = 1; i < ps->performance_level_count; i++) {
2979 if (ps->performance_levels[i].sclk < ps->performance_levels[i - 1].sclk)
2980 ps->performance_levels[i].sclk = ps->performance_levels[i - 1].sclk;
2981 if (ps->performance_levels[i].vddc < ps->performance_levels[i - 1].vddc)
2982 ps->performance_levels[i].vddc = ps->performance_levels[i - 1].vddc;
2983 }
2964 } 2984 }
2965 2985
2966 if (disable_mclk_switching) { 2986 if (disable_mclk_switching) {
@@ -6253,9 +6273,6 @@ int si_dpm_init(struct radeon_device *rdev)
6253 struct evergreen_power_info *eg_pi; 6273 struct evergreen_power_info *eg_pi;
6254 struct ni_power_info *ni_pi; 6274 struct ni_power_info *ni_pi;
6255 struct si_power_info *si_pi; 6275 struct si_power_info *si_pi;
6256 int index = GetIndexIntoMasterTable(DATA, ASIC_InternalSS_Info);
6257 u16 data_offset, size;
6258 u8 frev, crev;
6259 struct atom_clock_dividers dividers; 6276 struct atom_clock_dividers dividers;
6260 int ret; 6277 int ret;
6261 u32 mask; 6278 u32 mask;
@@ -6346,16 +6363,7 @@ int si_dpm_init(struct radeon_device *rdev)
6346 si_pi->vddc_phase_shed_control = 6363 si_pi->vddc_phase_shed_control =
6347 radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDC, VOLTAGE_OBJ_PHASE_LUT); 6364 radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDC, VOLTAGE_OBJ_PHASE_LUT);
6348 6365
6349 if (atom_parse_data_header(rdev->mode_info.atom_context, index, &size, 6366 rv770_get_engine_memory_ss(rdev);
6350 &frev, &crev, &data_offset)) {
6351 pi->sclk_ss = true;
6352 pi->mclk_ss = true;
6353 pi->dynamic_ss = true;
6354 } else {
6355 pi->sclk_ss = false;
6356 pi->mclk_ss = false;
6357 pi->dynamic_ss = true;
6358 }
6359 6367
6360 pi->asi = RV770_ASI_DFLT; 6368 pi->asi = RV770_ASI_DFLT;
6361 pi->pasi = CYPRESS_HASI_DFLT; 6369 pi->pasi = CYPRESS_HASI_DFLT;
@@ -6366,8 +6374,7 @@ int si_dpm_init(struct radeon_device *rdev)
6366 eg_pi->sclk_deep_sleep = true; 6374 eg_pi->sclk_deep_sleep = true;
6367 si_pi->sclk_deep_sleep_above_low = false; 6375 si_pi->sclk_deep_sleep_above_low = false;
6368 6376
6369 if (pi->gfx_clock_gating && 6377 if (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE)
6370 (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE))
6371 pi->thermal_protection = true; 6378 pi->thermal_protection = true;
6372 else 6379 else
6373 pi->thermal_protection = false; 6380 pi->thermal_protection = false;
diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
index 7a5764843bfb..cd33084c7860 100644
--- a/drivers/hid/hid-logitech-dj.c
+++ b/drivers/hid/hid-logitech-dj.c
@@ -488,8 +488,6 @@ static int logi_dj_recv_query_paired_devices(struct dj_receiver_dev *djrcv_dev)
488 if (djrcv_dev->querying_devices) 488 if (djrcv_dev->querying_devices)
489 return 0; 489 return 0;
490 490
491 djrcv_dev->querying_devices = true;
492
493 dj_report = kzalloc(sizeof(struct dj_report), GFP_KERNEL); 491 dj_report = kzalloc(sizeof(struct dj_report), GFP_KERNEL);
494 if (!dj_report) 492 if (!dj_report)
495 return -ENOMEM; 493 return -ENOMEM;
diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c
index 0f34bca9f5e5..6099f50b28aa 100644
--- a/drivers/hwmon/adt7470.c
+++ b/drivers/hwmon/adt7470.c
@@ -215,7 +215,7 @@ static inline int adt7470_write_word_data(struct i2c_client *client, u8 reg,
215 u16 value) 215 u16 value)
216{ 216{
217 return i2c_smbus_write_byte_data(client, reg, value & 0xFF) 217 return i2c_smbus_write_byte_data(client, reg, value & 0xFF)
218 && i2c_smbus_write_byte_data(client, reg + 1, value >> 8); 218 || i2c_smbus_write_byte_data(client, reg + 1, value >> 8);
219} 219}
220 220
221static void adt7470_init_client(struct i2c_client *client) 221static void adt7470_init_client(struct i2c_client *client)
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index 0ad208a69c29..3ceac3e91dde 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -60,7 +60,6 @@ static void tiadc_step_config(struct tiadc_device *adc_dev)
60{ 60{
61 unsigned int stepconfig; 61 unsigned int stepconfig;
62 int i, steps; 62 int i, steps;
63 u32 step_en;
64 63
65 /* 64 /*
66 * There are 16 configurable steps and 8 analog input 65 * There are 16 configurable steps and 8 analog input
@@ -86,8 +85,7 @@ static void tiadc_step_config(struct tiadc_device *adc_dev)
86 adc_dev->channel_step[i] = steps; 85 adc_dev->channel_step[i] = steps;
87 steps++; 86 steps++;
88 } 87 }
89 step_en = get_adc_step_mask(adc_dev); 88
90 am335x_tsc_se_set(adc_dev->mfd_tscadc, step_en);
91} 89}
92 90
93static const char * const chan_name_ain[] = { 91static const char * const chan_name_ain[] = {
@@ -142,10 +140,22 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
142 int *val, int *val2, long mask) 140 int *val, int *val2, long mask)
143{ 141{
144 struct tiadc_device *adc_dev = iio_priv(indio_dev); 142 struct tiadc_device *adc_dev = iio_priv(indio_dev);
145 int i; 143 int i, map_val;
146 unsigned int fifo1count, read; 144 unsigned int fifo1count, read, stepid;
147 u32 step = UINT_MAX; 145 u32 step = UINT_MAX;
148 bool found = false; 146 bool found = false;
147 u32 step_en;
148 unsigned long timeout = jiffies + usecs_to_jiffies
149 (IDLE_TIMEOUT * adc_dev->channels);
150 step_en = get_adc_step_mask(adc_dev);
151 am335x_tsc_se_set(adc_dev->mfd_tscadc, step_en);
152
153 /* Wait for ADC sequencer to complete sampling */
154 while (tiadc_readl(adc_dev, REG_ADCFSM) & SEQ_STATUS) {
155 if (time_after(jiffies, timeout))
156 return -EAGAIN;
157 }
158 map_val = chan->channel + TOTAL_CHANNELS;
149 159
150 /* 160 /*
151 * When the sub-system is first enabled, 161 * When the sub-system is first enabled,
@@ -170,12 +180,16 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
170 fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT); 180 fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT);
171 for (i = 0; i < fifo1count; i++) { 181 for (i = 0; i < fifo1count; i++) {
172 read = tiadc_readl(adc_dev, REG_FIFO1); 182 read = tiadc_readl(adc_dev, REG_FIFO1);
173 if (read >> 16 == step) { 183 stepid = read & FIFOREAD_CHNLID_MASK;
174 *val = read & 0xfff; 184 stepid = stepid >> 0x10;
185
186 if (stepid == map_val) {
187 read = read & FIFOREAD_DATA_MASK;
175 found = true; 188 found = true;
189 *val = read;
176 } 190 }
177 } 191 }
178 am335x_tsc_se_update(adc_dev->mfd_tscadc); 192
179 if (found == false) 193 if (found == false)
180 return -EBUSY; 194 return -EBUSY;
181 return IIO_VAL_INT; 195 return IIO_VAL_INT;
diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
index ea8a4146620d..0dd9bb873130 100644
--- a/drivers/iio/industrialio-trigger.c
+++ b/drivers/iio/industrialio-trigger.c
@@ -127,12 +127,17 @@ static struct iio_trigger *iio_trigger_find_by_name(const char *name,
127void iio_trigger_poll(struct iio_trigger *trig, s64 time) 127void iio_trigger_poll(struct iio_trigger *trig, s64 time)
128{ 128{
129 int i; 129 int i;
130 if (!trig->use_count) 130
131 for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) 131 if (!atomic_read(&trig->use_count)) {
132 if (trig->subirqs[i].enabled) { 132 atomic_set(&trig->use_count, CONFIG_IIO_CONSUMERS_PER_TRIGGER);
133 trig->use_count++; 133
134 for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) {
135 if (trig->subirqs[i].enabled)
134 generic_handle_irq(trig->subirq_base + i); 136 generic_handle_irq(trig->subirq_base + i);
135 } 137 else
138 iio_trigger_notify_done(trig);
139 }
140 }
136} 141}
137EXPORT_SYMBOL(iio_trigger_poll); 142EXPORT_SYMBOL(iio_trigger_poll);
138 143
@@ -146,19 +151,24 @@ EXPORT_SYMBOL(iio_trigger_generic_data_rdy_poll);
146void iio_trigger_poll_chained(struct iio_trigger *trig, s64 time) 151void iio_trigger_poll_chained(struct iio_trigger *trig, s64 time)
147{ 152{
148 int i; 153 int i;
149 if (!trig->use_count) 154
150 for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) 155 if (!atomic_read(&trig->use_count)) {
151 if (trig->subirqs[i].enabled) { 156 atomic_set(&trig->use_count, CONFIG_IIO_CONSUMERS_PER_TRIGGER);
152 trig->use_count++; 157
158 for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) {
159 if (trig->subirqs[i].enabled)
153 handle_nested_irq(trig->subirq_base + i); 160 handle_nested_irq(trig->subirq_base + i);
154 } 161 else
162 iio_trigger_notify_done(trig);
163 }
164 }
155} 165}
156EXPORT_SYMBOL(iio_trigger_poll_chained); 166EXPORT_SYMBOL(iio_trigger_poll_chained);
157 167
158void iio_trigger_notify_done(struct iio_trigger *trig) 168void iio_trigger_notify_done(struct iio_trigger *trig)
159{ 169{
160 trig->use_count--; 170 if (atomic_dec_and_test(&trig->use_count) && trig->ops &&
161 if (trig->use_count == 0 && trig->ops && trig->ops->try_reenable) 171 trig->ops->try_reenable)
162 if (trig->ops->try_reenable(trig)) 172 if (trig->ops->try_reenable(trig))
163 /* Missed an interrupt so launch new poll now */ 173 /* Missed an interrupt so launch new poll now */
164 iio_trigger_poll(trig, 0); 174 iio_trigger_poll(trig, 0);
diff --git a/drivers/media/i2c/ml86v7667.c b/drivers/media/i2c/ml86v7667.c
index efdc873e58d1..a9857022f71d 100644
--- a/drivers/media/i2c/ml86v7667.c
+++ b/drivers/media/i2c/ml86v7667.c
@@ -117,7 +117,7 @@ static int ml86v7667_s_ctrl(struct v4l2_ctrl *ctrl)
117{ 117{
118 struct v4l2_subdev *sd = to_sd(ctrl); 118 struct v4l2_subdev *sd = to_sd(ctrl);
119 struct i2c_client *client = v4l2_get_subdevdata(sd); 119 struct i2c_client *client = v4l2_get_subdevdata(sd);
120 int ret; 120 int ret = -EINVAL;
121 121
122 switch (ctrl->id) { 122 switch (ctrl->id) {
123 case V4L2_CID_BRIGHTNESS: 123 case V4L2_CID_BRIGHTNESS:
@@ -157,7 +157,7 @@ static int ml86v7667_s_ctrl(struct v4l2_ctrl *ctrl)
157 break; 157 break;
158 } 158 }
159 159
160 return 0; 160 return ret;
161} 161}
162 162
163static int ml86v7667_querystd(struct v4l2_subdev *sd, v4l2_std_id *std) 163static int ml86v7667_querystd(struct v4l2_subdev *sd, v4l2_std_id *std)
diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
index df4ada880e42..bd9405df1bd6 100644
--- a/drivers/media/platform/coda.c
+++ b/drivers/media/platform/coda.c
@@ -1987,7 +1987,7 @@ MODULE_DEVICE_TABLE(platform, coda_platform_ids);
1987 1987
1988#ifdef CONFIG_OF 1988#ifdef CONFIG_OF
1989static const struct of_device_id coda_dt_ids[] = { 1989static const struct of_device_id coda_dt_ids[] = {
1990 { .compatible = "fsl,imx27-vpu", .data = &coda_platform_ids[CODA_IMX27] }, 1990 { .compatible = "fsl,imx27-vpu", .data = &coda_devdata[CODA_IMX27] },
1991 { .compatible = "fsl,imx53-vpu", .data = &coda_devdata[CODA_IMX53] }, 1991 { .compatible = "fsl,imx53-vpu", .data = &coda_devdata[CODA_IMX53] },
1992 { /* sentinel */ } 1992 { /* sentinel */ }
1993}; 1993};
diff --git a/drivers/media/platform/s5p-g2d/g2d.c b/drivers/media/platform/s5p-g2d/g2d.c
index 553d87e5ceab..fd6289d60cde 100644
--- a/drivers/media/platform/s5p-g2d/g2d.c
+++ b/drivers/media/platform/s5p-g2d/g2d.c
@@ -784,6 +784,7 @@ static int g2d_probe(struct platform_device *pdev)
784 } 784 }
785 *vfd = g2d_videodev; 785 *vfd = g2d_videodev;
786 vfd->lock = &dev->mutex; 786 vfd->lock = &dev->mutex;
787 vfd->v4l2_dev = &dev->v4l2_dev;
787 ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0); 788 ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0);
788 if (ret) { 789 if (ret) {
789 v4l2_err(&dev->v4l2_dev, "Failed to register video device\n"); 790 v4l2_err(&dev->v4l2_dev, "Failed to register video device\n");
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index 5296385153d5..4f6dd42c9adb 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -344,7 +344,7 @@ static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
344 pix_mp->num_planes = 2; 344 pix_mp->num_planes = 2;
345 /* Set pixelformat to the format in which MFC 345 /* Set pixelformat to the format in which MFC
346 outputs the decoded frame */ 346 outputs the decoded frame */
347 pix_mp->pixelformat = V4L2_PIX_FMT_NV12MT; 347 pix_mp->pixelformat = ctx->dst_fmt->fourcc;
348 pix_mp->plane_fmt[0].bytesperline = ctx->buf_width; 348 pix_mp->plane_fmt[0].bytesperline = ctx->buf_width;
349 pix_mp->plane_fmt[0].sizeimage = ctx->luma_size; 349 pix_mp->plane_fmt[0].sizeimage = ctx->luma_size;
350 pix_mp->plane_fmt[1].bytesperline = ctx->buf_width; 350 pix_mp->plane_fmt[1].bytesperline = ctx->buf_width;
@@ -382,10 +382,16 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
382 mfc_err("Unsupported format for source.\n"); 382 mfc_err("Unsupported format for source.\n");
383 return -EINVAL; 383 return -EINVAL;
384 } 384 }
385 if (!IS_MFCV6(dev) && (fmt->fourcc == V4L2_PIX_FMT_VP8)) { 385 if (fmt->codec_mode == S5P_FIMV_CODEC_NONE) {
386 mfc_err("Not supported format.\n"); 386 mfc_err("Unknown codec\n");
387 return -EINVAL; 387 return -EINVAL;
388 } 388 }
389 if (!IS_MFCV6(dev)) {
390 if (fmt->fourcc == V4L2_PIX_FMT_VP8) {
391 mfc_err("Not supported format.\n");
392 return -EINVAL;
393 }
394 }
389 } else if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { 395 } else if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
390 fmt = find_format(f, MFC_FMT_RAW); 396 fmt = find_format(f, MFC_FMT_RAW);
391 if (!fmt) { 397 if (!fmt) {
@@ -411,7 +417,6 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
411 struct s5p_mfc_dev *dev = video_drvdata(file); 417 struct s5p_mfc_dev *dev = video_drvdata(file);
412 struct s5p_mfc_ctx *ctx = fh_to_ctx(priv); 418 struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
413 int ret = 0; 419 int ret = 0;
414 struct s5p_mfc_fmt *fmt;
415 struct v4l2_pix_format_mplane *pix_mp; 420 struct v4l2_pix_format_mplane *pix_mp;
416 421
417 mfc_debug_enter(); 422 mfc_debug_enter();
@@ -425,54 +430,32 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
425 goto out; 430 goto out;
426 } 431 }
427 if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { 432 if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
428 fmt = find_format(f, MFC_FMT_RAW); 433 /* dst_fmt is validated by call to vidioc_try_fmt */
429 if (!fmt) { 434 ctx->dst_fmt = find_format(f, MFC_FMT_RAW);
430 mfc_err("Unsupported format for source.\n"); 435 ret = 0;
431 return -EINVAL;
432 }
433 if (!IS_MFCV6(dev) && (fmt->fourcc != V4L2_PIX_FMT_NV12MT)) {
434 mfc_err("Not supported format.\n");
435 return -EINVAL;
436 } else if (IS_MFCV6(dev) &&
437 (fmt->fourcc == V4L2_PIX_FMT_NV12MT)) {
438 mfc_err("Not supported format.\n");
439 return -EINVAL;
440 }
441 ctx->dst_fmt = fmt;
442 mfc_debug_leave();
443 return ret;
444 } else if (f->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
445 mfc_err("Wrong type error for S_FMT : %d", f->type);
446 return -EINVAL;
447 }
448 fmt = find_format(f, MFC_FMT_DEC);
449 if (!fmt || fmt->codec_mode == S5P_MFC_CODEC_NONE) {
450 mfc_err("Unknown codec\n");
451 ret = -EINVAL;
452 goto out; 436 goto out;
453 } 437 } else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
454 if (fmt->type != MFC_FMT_DEC) { 438 /* src_fmt is validated by call to vidioc_try_fmt */
455 mfc_err("Wrong format selected, you should choose " 439 ctx->src_fmt = find_format(f, MFC_FMT_DEC);
456 "format for decoding\n"); 440 ctx->codec_mode = ctx->src_fmt->codec_mode;
441 mfc_debug(2, "The codec number is: %d\n", ctx->codec_mode);
442 pix_mp->height = 0;
443 pix_mp->width = 0;
444 if (pix_mp->plane_fmt[0].sizeimage)
445 ctx->dec_src_buf_size = pix_mp->plane_fmt[0].sizeimage;
446 else
447 pix_mp->plane_fmt[0].sizeimage = ctx->dec_src_buf_size =
448 DEF_CPB_SIZE;
449 pix_mp->plane_fmt[0].bytesperline = 0;
450 ctx->state = MFCINST_INIT;
451 ret = 0;
452 goto out;
453 } else {
454 mfc_err("Wrong type error for S_FMT : %d", f->type);
457 ret = -EINVAL; 455 ret = -EINVAL;
458 goto out; 456 goto out;
459 } 457 }
460 if (!IS_MFCV6(dev) && (fmt->fourcc == V4L2_PIX_FMT_VP8)) { 458
461 mfc_err("Not supported format.\n");
462 return -EINVAL;
463 }
464 ctx->src_fmt = fmt;
465 ctx->codec_mode = fmt->codec_mode;
466 mfc_debug(2, "The codec number is: %d\n", ctx->codec_mode);
467 pix_mp->height = 0;
468 pix_mp->width = 0;
469 if (pix_mp->plane_fmt[0].sizeimage)
470 ctx->dec_src_buf_size = pix_mp->plane_fmt[0].sizeimage;
471 else
472 pix_mp->plane_fmt[0].sizeimage = ctx->dec_src_buf_size =
473 DEF_CPB_SIZE;
474 pix_mp->plane_fmt[0].bytesperline = 0;
475 ctx->state = MFCINST_INIT;
476out: 459out:
477 mfc_debug_leave(); 460 mfc_debug_leave();
478 return ret; 461 return ret;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index 2549967b2f85..59e56f4c8ce3 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -906,6 +906,7 @@ static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
906 906
907static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f) 907static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
908{ 908{
909 struct s5p_mfc_dev *dev = video_drvdata(file);
909 struct s5p_mfc_fmt *fmt; 910 struct s5p_mfc_fmt *fmt;
910 struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp; 911 struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
911 912
@@ -930,6 +931,18 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
930 return -EINVAL; 931 return -EINVAL;
931 } 932 }
932 933
934 if (!IS_MFCV6(dev)) {
935 if (fmt->fourcc == V4L2_PIX_FMT_NV12MT_16X16) {
936 mfc_err("Not supported format.\n");
937 return -EINVAL;
938 }
939 } else if (IS_MFCV6(dev)) {
940 if (fmt->fourcc == V4L2_PIX_FMT_NV12MT) {
941 mfc_err("Not supported format.\n");
942 return -EINVAL;
943 }
944 }
945
933 if (fmt->num_planes != pix_fmt_mp->num_planes) { 946 if (fmt->num_planes != pix_fmt_mp->num_planes) {
934 mfc_err("failed to try output format\n"); 947 mfc_err("failed to try output format\n");
935 return -EINVAL; 948 return -EINVAL;
@@ -947,7 +960,6 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
947{ 960{
948 struct s5p_mfc_dev *dev = video_drvdata(file); 961 struct s5p_mfc_dev *dev = video_drvdata(file);
949 struct s5p_mfc_ctx *ctx = fh_to_ctx(priv); 962 struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
950 struct s5p_mfc_fmt *fmt;
951 struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp; 963 struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
952 int ret = 0; 964 int ret = 0;
953 965
@@ -960,13 +972,9 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
960 goto out; 972 goto out;
961 } 973 }
962 if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { 974 if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
963 fmt = find_format(f, MFC_FMT_ENC); 975 /* dst_fmt is validated by call to vidioc_try_fmt */
964 if (!fmt) { 976 ctx->dst_fmt = find_format(f, MFC_FMT_ENC);
965 mfc_err("failed to set capture format\n");
966 return -EINVAL;
967 }
968 ctx->state = MFCINST_INIT; 977 ctx->state = MFCINST_INIT;
969 ctx->dst_fmt = fmt;
970 ctx->codec_mode = ctx->dst_fmt->codec_mode; 978 ctx->codec_mode = ctx->dst_fmt->codec_mode;
971 ctx->enc_dst_buf_size = pix_fmt_mp->plane_fmt[0].sizeimage; 979 ctx->enc_dst_buf_size = pix_fmt_mp->plane_fmt[0].sizeimage;
972 pix_fmt_mp->plane_fmt[0].bytesperline = 0; 980 pix_fmt_mp->plane_fmt[0].bytesperline = 0;
@@ -987,28 +995,8 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
987 } 995 }
988 mfc_debug(2, "Got instance number: %d\n", ctx->inst_no); 996 mfc_debug(2, "Got instance number: %d\n", ctx->inst_no);
989 } else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { 997 } else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
990 fmt = find_format(f, MFC_FMT_RAW); 998 /* src_fmt is validated by call to vidioc_try_fmt */
991 if (!fmt) { 999 ctx->src_fmt = find_format(f, MFC_FMT_RAW);
992 mfc_err("failed to set output format\n");
993 return -EINVAL;
994 }
995
996 if (!IS_MFCV6(dev) &&
997 (fmt->fourcc == V4L2_PIX_FMT_NV12MT_16X16)) {
998 mfc_err("Not supported format.\n");
999 return -EINVAL;
1000 } else if (IS_MFCV6(dev) &&
1001 (fmt->fourcc == V4L2_PIX_FMT_NV12MT)) {
1002 mfc_err("Not supported format.\n");
1003 return -EINVAL;
1004 }
1005
1006 if (fmt->num_planes != pix_fmt_mp->num_planes) {
1007 mfc_err("failed to set output format\n");
1008 ret = -EINVAL;
1009 goto out;
1010 }
1011 ctx->src_fmt = fmt;
1012 ctx->img_width = pix_fmt_mp->width; 1000 ctx->img_width = pix_fmt_mp->width;
1013 ctx->img_height = pix_fmt_mp->height; 1001 ctx->img_height = pix_fmt_mp->height;
1014 mfc_debug(2, "codec number: %d\n", ctx->src_fmt->codec_mode); 1002 mfc_debug(2, "codec number: %d\n", ctx->src_fmt->codec_mode);
diff --git a/drivers/media/usb/em28xx/em28xx-i2c.c b/drivers/media/usb/em28xx/em28xx-i2c.c
index 4851cc2e4a4d..c4ff9739a7ae 100644
--- a/drivers/media/usb/em28xx/em28xx-i2c.c
+++ b/drivers/media/usb/em28xx/em28xx-i2c.c
@@ -726,7 +726,7 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned bus,
726 726
727 *eedata = data; 727 *eedata = data;
728 *eedata_len = len; 728 *eedata_len = len;
729 dev_config = (void *)eedata; 729 dev_config = (void *)*eedata;
730 730
731 switch (le16_to_cpu(dev_config->chip_conf) >> 4 & 0x3) { 731 switch (le16_to_cpu(dev_config->chip_conf) >> 4 & 0x3) {
732 case 0: 732 case 0:
diff --git a/drivers/media/usb/hdpvr/hdpvr-core.c b/drivers/media/usb/hdpvr/hdpvr-core.c
index cb694055ba7d..6e5070774dc2 100644
--- a/drivers/media/usb/hdpvr/hdpvr-core.c
+++ b/drivers/media/usb/hdpvr/hdpvr-core.c
@@ -303,6 +303,11 @@ static int hdpvr_probe(struct usb_interface *interface,
303 303
304 dev->workqueue = 0; 304 dev->workqueue = 0;
305 305
306 /* init video transfer queues first of all */
307 /* to prevent oops in hdpvr_delete() on error paths */
308 INIT_LIST_HEAD(&dev->free_buff_list);
309 INIT_LIST_HEAD(&dev->rec_buff_list);
310
306 /* register v4l2_device early so it can be used for printks */ 311 /* register v4l2_device early so it can be used for printks */
307 if (v4l2_device_register(&interface->dev, &dev->v4l2_dev)) { 312 if (v4l2_device_register(&interface->dev, &dev->v4l2_dev)) {
308 dev_err(&interface->dev, "v4l2_device_register failed\n"); 313 dev_err(&interface->dev, "v4l2_device_register failed\n");
@@ -325,10 +330,6 @@ static int hdpvr_probe(struct usb_interface *interface,
325 if (!dev->workqueue) 330 if (!dev->workqueue)
326 goto error; 331 goto error;
327 332
328 /* init video transfer queues */
329 INIT_LIST_HEAD(&dev->free_buff_list);
330 INIT_LIST_HEAD(&dev->rec_buff_list);
331
332 dev->options = hdpvr_default_options; 333 dev->options = hdpvr_default_options;
333 334
334 if (default_video_input < HDPVR_VIDEO_INPUTS) 335 if (default_video_input < HDPVR_VIDEO_INPUTS)
@@ -405,7 +406,7 @@ static int hdpvr_probe(struct usb_interface *interface,
405 video_nr[atomic_inc_return(&dev_nr)]); 406 video_nr[atomic_inc_return(&dev_nr)]);
406 if (retval < 0) { 407 if (retval < 0) {
407 v4l2_err(&dev->v4l2_dev, "registering videodev failed\n"); 408 v4l2_err(&dev->v4l2_dev, "registering videodev failed\n");
408 goto error; 409 goto reg_fail;
409 } 410 }
410 411
411 /* let the user know what node this device is now attached to */ 412 /* let the user know what node this device is now attached to */
diff --git a/drivers/media/usb/usbtv/Kconfig b/drivers/media/usb/usbtv/Kconfig
index 8864436464bf..7c5b86006ee6 100644
--- a/drivers/media/usb/usbtv/Kconfig
+++ b/drivers/media/usb/usbtv/Kconfig
@@ -1,6 +1,6 @@
1config VIDEO_USBTV 1config VIDEO_USBTV
2 tristate "USBTV007 video capture support" 2 tristate "USBTV007 video capture support"
3 depends on VIDEO_DEV 3 depends on VIDEO_V4L2
4 select VIDEOBUF2_VMALLOC 4 select VIDEOBUF2_VMALLOC
5 5
6 ---help--- 6 ---help---
diff --git a/drivers/media/usb/usbtv/usbtv.c b/drivers/media/usb/usbtv/usbtv.c
index bf43f874685e..91650173941a 100644
--- a/drivers/media/usb/usbtv/usbtv.c
+++ b/drivers/media/usb/usbtv/usbtv.c
@@ -57,7 +57,7 @@
57#define USBTV_CHUNK_SIZE 256 57#define USBTV_CHUNK_SIZE 256
58#define USBTV_CHUNK 240 58#define USBTV_CHUNK 240
59#define USBTV_CHUNKS (USBTV_WIDTH * USBTV_HEIGHT \ 59#define USBTV_CHUNKS (USBTV_WIDTH * USBTV_HEIGHT \
60 / 2 / USBTV_CHUNK) 60 / 4 / USBTV_CHUNK)
61 61
62/* Chunk header. */ 62/* Chunk header. */
63#define USBTV_MAGIC_OK(chunk) ((be32_to_cpu(chunk[0]) & 0xff000000) \ 63#define USBTV_MAGIC_OK(chunk) ((be32_to_cpu(chunk[0]) & 0xff000000) \
@@ -89,6 +89,7 @@ struct usbtv {
89 /* Number of currently processed frame, useful find 89 /* Number of currently processed frame, useful find
90 * out when a new one begins. */ 90 * out when a new one begins. */
91 u32 frame_id; 91 u32 frame_id;
92 int chunks_done;
92 93
93 int iso_size; 94 int iso_size;
94 unsigned int sequence; 95 unsigned int sequence;
@@ -202,6 +203,26 @@ static int usbtv_setup_capture(struct usbtv *usbtv)
202 return 0; 203 return 0;
203} 204}
204 205
206/* Copy data from chunk into a frame buffer, deinterlacing the data
207 * into every second line. Unfortunately, they don't align nicely into
208 * 720 pixel lines, as the chunk is 240 words long, which is 480 pixels.
209 * Therefore, we break down the chunk into two halves before copyting,
210 * so that we can interleave a line if needed. */
211static void usbtv_chunk_to_vbuf(u32 *frame, u32 *src, int chunk_no, int odd)
212{
213 int half;
214
215 for (half = 0; half < 2; half++) {
216 int part_no = chunk_no * 2 + half;
217 int line = part_no / 3;
218 int part_index = (line * 2 + !odd) * 3 + (part_no % 3);
219
220 u32 *dst = &frame[part_index * USBTV_CHUNK/2];
221 memcpy(dst, src, USBTV_CHUNK/2 * sizeof(*src));
222 src += USBTV_CHUNK/2;
223 }
224}
225
205/* Called for each 256-byte image chunk. 226/* Called for each 256-byte image chunk.
206 * First word identifies the chunk, followed by 240 words of image 227 * First word identifies the chunk, followed by 240 words of image
207 * data and padding. */ 228 * data and padding. */
@@ -218,17 +239,17 @@ static void usbtv_image_chunk(struct usbtv *usbtv, u32 *chunk)
218 frame_id = USBTV_FRAME_ID(chunk); 239 frame_id = USBTV_FRAME_ID(chunk);
219 odd = USBTV_ODD(chunk); 240 odd = USBTV_ODD(chunk);
220 chunk_no = USBTV_CHUNK_NO(chunk); 241 chunk_no = USBTV_CHUNK_NO(chunk);
221
222 /* Deinterlace. TODO: Use interlaced frame format. */
223 chunk_no = (chunk_no - chunk_no % 3) * 2 + chunk_no % 3;
224 chunk_no += !odd * 3;
225
226 if (chunk_no >= USBTV_CHUNKS) 242 if (chunk_no >= USBTV_CHUNKS)
227 return; 243 return;
228 244
229 /* Beginning of a frame. */ 245 /* Beginning of a frame. */
230 if (chunk_no == 0) 246 if (chunk_no == 0) {
231 usbtv->frame_id = frame_id; 247 usbtv->frame_id = frame_id;
248 usbtv->chunks_done = 0;
249 }
250
251 if (usbtv->frame_id != frame_id)
252 return;
232 253
233 spin_lock_irqsave(&usbtv->buflock, flags); 254 spin_lock_irqsave(&usbtv->buflock, flags);
234 if (list_empty(&usbtv->bufs)) { 255 if (list_empty(&usbtv->bufs)) {
@@ -241,19 +262,23 @@ static void usbtv_image_chunk(struct usbtv *usbtv, u32 *chunk)
241 buf = list_first_entry(&usbtv->bufs, struct usbtv_buf, list); 262 buf = list_first_entry(&usbtv->bufs, struct usbtv_buf, list);
242 frame = vb2_plane_vaddr(&buf->vb, 0); 263 frame = vb2_plane_vaddr(&buf->vb, 0);
243 264
244 /* Copy the chunk. */ 265 /* Copy the chunk data. */
245 memcpy(&frame[chunk_no * USBTV_CHUNK], &chunk[1], 266 usbtv_chunk_to_vbuf(frame, &chunk[1], chunk_no, odd);
246 USBTV_CHUNK * sizeof(chunk[1])); 267 usbtv->chunks_done++;
247 268
248 /* Last chunk in a frame, signalling an end */ 269 /* Last chunk in a frame, signalling an end */
249 if (usbtv->frame_id && chunk_no == USBTV_CHUNKS-1) { 270 if (odd && chunk_no == USBTV_CHUNKS-1) {
250 int size = vb2_plane_size(&buf->vb, 0); 271 int size = vb2_plane_size(&buf->vb, 0);
272 enum vb2_buffer_state state = usbtv->chunks_done ==
273 USBTV_CHUNKS ?
274 VB2_BUF_STATE_DONE :
275 VB2_BUF_STATE_ERROR;
251 276
252 buf->vb.v4l2_buf.field = V4L2_FIELD_INTERLACED; 277 buf->vb.v4l2_buf.field = V4L2_FIELD_INTERLACED;
253 buf->vb.v4l2_buf.sequence = usbtv->sequence++; 278 buf->vb.v4l2_buf.sequence = usbtv->sequence++;
254 v4l2_get_timestamp(&buf->vb.v4l2_buf.timestamp); 279 v4l2_get_timestamp(&buf->vb.v4l2_buf.timestamp);
255 vb2_set_plane_payload(&buf->vb, 0, size); 280 vb2_set_plane_payload(&buf->vb, 0, size);
256 vb2_buffer_done(&buf->vb, VB2_BUF_STATE_DONE); 281 vb2_buffer_done(&buf->vb, state);
257 list_del(&buf->list); 282 list_del(&buf->list);
258 } 283 }
259 284
@@ -518,7 +543,7 @@ static int usbtv_queue_setup(struct vb2_queue *vq,
518 if (*nbuffers < 2) 543 if (*nbuffers < 2)
519 *nbuffers = 2; 544 *nbuffers = 2;
520 *nplanes = 1; 545 *nplanes = 1;
521 sizes[0] = USBTV_CHUNK * USBTV_CHUNKS * sizeof(u32); 546 sizes[0] = USBTV_WIDTH * USBTV_HEIGHT / 2 * sizeof(u32);
522 547
523 return 0; 548 return 0;
524} 549}
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index dbdc5f7e2b29..01e264fb50e0 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -317,13 +317,20 @@ void acpi_pci_remove_bus(struct pci_bus *bus)
317/* ACPI bus type */ 317/* ACPI bus type */
318static int acpi_pci_find_device(struct device *dev, acpi_handle *handle) 318static int acpi_pci_find_device(struct device *dev, acpi_handle *handle)
319{ 319{
320 struct pci_dev * pci_dev; 320 struct pci_dev *pci_dev = to_pci_dev(dev);
321 u64 addr; 321 bool is_bridge;
322 u64 addr;
322 323
323 pci_dev = to_pci_dev(dev); 324 /*
325 * pci_is_bridge() is not suitable here, because pci_dev->subordinate
326 * is set only after acpi_pci_find_device() has been called for the
327 * given device.
328 */
329 is_bridge = pci_dev->hdr_type == PCI_HEADER_TYPE_BRIDGE
330 || pci_dev->hdr_type == PCI_HEADER_TYPE_CARDBUS;
324 /* Please ref to ACPI spec for the syntax of _ADR */ 331 /* Please ref to ACPI spec for the syntax of _ADR */
325 addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn); 332 addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn);
326 *handle = acpi_get_child(DEVICE_ACPI_HANDLE(dev->parent), addr); 333 *handle = acpi_find_child(ACPI_HANDLE(dev->parent), addr, is_bridge);
327 if (!*handle) 334 if (!*handle)
328 return -ENODEV; 335 return -ENODEV;
329 return 0; 336 return 0;
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 17150a778984..451bf99582ff 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -2392,6 +2392,12 @@ int dasd_sleep_on_immediatly(struct dasd_ccw_req *cqr)
2392 rc = cqr->intrc; 2392 rc = cqr->intrc;
2393 else 2393 else
2394 rc = -EIO; 2394 rc = -EIO;
2395
2396 /* kick tasklets */
2397 dasd_schedule_device_bh(device);
2398 if (device->block)
2399 dasd_schedule_block_bh(device->block);
2400
2395 return rc; 2401 return rc;
2396} 2402}
2397 2403
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 2168258fb2c3..74b88efde6ad 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -751,7 +751,7 @@ static void __virtscsi_set_affinity(struct virtio_scsi *vscsi, bool affinity)
751 751
752 vscsi->affinity_hint_set = true; 752 vscsi->affinity_hint_set = true;
753 } else { 753 } else {
754 for (i = 0; i < vscsi->num_queues - VIRTIO_SCSI_VQ_BASE; i++) 754 for (i = 0; i < vscsi->num_queues; i++)
755 virtqueue_set_affinity(vscsi->req_vqs[i].vq, -1); 755 virtqueue_set_affinity(vscsi->req_vqs[i].vq, -1);
756 756
757 vscsi->affinity_hint_set = false; 757 vscsi->affinity_hint_set = false;
diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c
index 222d3e37fc28..707966bd5610 100644
--- a/drivers/spi/spi-davinci.c
+++ b/drivers/spi/spi-davinci.c
@@ -609,7 +609,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
609 else 609 else
610 buf = (void *)t->tx_buf; 610 buf = (void *)t->tx_buf;
611 t->tx_dma = dma_map_single(&spi->dev, buf, 611 t->tx_dma = dma_map_single(&spi->dev, buf,
612 t->len, DMA_FROM_DEVICE); 612 t->len, DMA_TO_DEVICE);
613 if (!t->tx_dma) { 613 if (!t->tx_dma) {
614 ret = -EFAULT; 614 ret = -EFAULT;
615 goto err_tx_map; 615 goto err_tx_map;
diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c
index dcceed29d31a..81972fa47beb 100644
--- a/drivers/staging/zcache/zcache-main.c
+++ b/drivers/staging/zcache/zcache-main.c
@@ -1811,10 +1811,12 @@ static int zcache_comp_init(void)
1811#else 1811#else
1812 if (*zcache_comp_name != '\0') { 1812 if (*zcache_comp_name != '\0') {
1813 ret = crypto_has_comp(zcache_comp_name, 0, 0); 1813 ret = crypto_has_comp(zcache_comp_name, 0, 0);
1814 if (!ret) 1814 if (!ret) {
1815 pr_info("zcache: %s not supported\n", 1815 pr_info("zcache: %s not supported\n",
1816 zcache_comp_name); 1816 zcache_comp_name);
1817 goto out; 1817 ret = 1;
1818 goto out;
1819 }
1818 } 1820 }
1819 if (!ret) 1821 if (!ret)
1820 strcpy(zcache_comp_name, "lzo"); 1822 strcpy(zcache_comp_name, "lzo");
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 4a8a1d68002c..558313de4911 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -4798,7 +4798,8 @@ static void hub_events(void)
4798 hub->ports[i - 1]->child; 4798 hub->ports[i - 1]->child;
4799 4799
4800 dev_dbg(hub_dev, "warm reset port %d\n", i); 4800 dev_dbg(hub_dev, "warm reset port %d\n", i);
4801 if (!udev) { 4801 if (!udev || !(portstatus &
4802 USB_PORT_STAT_CONNECTION)) {
4802 status = hub_port_reset(hub, i, 4803 status = hub_port_reset(hub, i,
4803 NULL, HUB_BH_RESET_TIME, 4804 NULL, HUB_BH_RESET_TIME,
4804 true); 4805 true);
@@ -4808,8 +4809,8 @@ static void hub_events(void)
4808 usb_lock_device(udev); 4809 usb_lock_device(udev);
4809 status = usb_reset_device(udev); 4810 status = usb_reset_device(udev);
4810 usb_unlock_device(udev); 4811 usb_unlock_device(udev);
4812 connect_change = 0;
4811 } 4813 }
4812 connect_change = 0;
4813 } 4814 }
4814 4815
4815 if (connect_change) 4816 if (connect_change)
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index df6978abd7e6..6f8c2fd47675 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -24,6 +24,7 @@
24#include <linux/pci.h> 24#include <linux/pci.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/dmapool.h> 26#include <linux/dmapool.h>
27#include <linux/dma-mapping.h>
27 28
28#include "xhci.h" 29#include "xhci.h"
29 30
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 41eb4fc33453..9478caa2f71f 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -27,6 +27,7 @@
27#include <linux/moduleparam.h> 27#include <linux/moduleparam.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/dmi.h> 29#include <linux/dmi.h>
30#include <linux/dma-mapping.h>
30 31
31#include "xhci.h" 32#include "xhci.h"
32 33
diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index 3ba37713b1f9..dc09ebe4aba5 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -239,24 +239,6 @@ static const struct fb_bitfield def_rgb565[] = {
239 } 239 }
240}; 240};
241 241
242static const struct fb_bitfield def_rgb666[] = {
243 [RED] = {
244 .offset = 16,
245 .length = 6,
246 },
247 [GREEN] = {
248 .offset = 8,
249 .length = 6,
250 },
251 [BLUE] = {
252 .offset = 0,
253 .length = 6,
254 },
255 [TRANSP] = { /* no support for transparency */
256 .length = 0,
257 }
258};
259
260static const struct fb_bitfield def_rgb888[] = { 242static const struct fb_bitfield def_rgb888[] = {
261 [RED] = { 243 [RED] = {
262 .offset = 16, 244 .offset = 16,
@@ -309,9 +291,6 @@ static int mxsfb_check_var(struct fb_var_screeninfo *var,
309 break; 291 break;
310 case STMLCDIF_16BIT: 292 case STMLCDIF_16BIT:
311 case STMLCDIF_18BIT: 293 case STMLCDIF_18BIT:
312 /* 24 bit to 18 bit mapping */
313 rgb = def_rgb666;
314 break;
315 case STMLCDIF_24BIT: 294 case STMLCDIF_24BIT:
316 /* real 24 bit */ 295 /* real 24 bit */
317 rgb = def_rgb888; 296 rgb = def_rgb888;
@@ -453,11 +432,6 @@ static int mxsfb_set_par(struct fb_info *fb_info)
453 return -EINVAL; 432 return -EINVAL;
454 case STMLCDIF_16BIT: 433 case STMLCDIF_16BIT:
455 case STMLCDIF_18BIT: 434 case STMLCDIF_18BIT:
456 /* 24 bit to 18 bit mapping */
457 ctrl |= CTRL_DF24; /* ignore the upper 2 bits in
458 * each colour component
459 */
460 break;
461 case STMLCDIF_24BIT: 435 case STMLCDIF_24BIT:
462 /* real 24 bit */ 436 /* real 24 bit */
463 break; 437 break;
diff --git a/drivers/video/omap2/displays-new/connector-analog-tv.c b/drivers/video/omap2/displays-new/connector-analog-tv.c
index 5338f362293b..1b60698f141e 100644
--- a/drivers/video/omap2/displays-new/connector-analog-tv.c
+++ b/drivers/video/omap2/displays-new/connector-analog-tv.c
@@ -28,6 +28,20 @@ struct panel_drv_data {
28 bool invert_polarity; 28 bool invert_polarity;
29}; 29};
30 30
31static const struct omap_video_timings tvc_pal_timings = {
32 .x_res = 720,
33 .y_res = 574,
34 .pixel_clock = 13500,
35 .hsw = 64,
36 .hfp = 12,
37 .hbp = 68,
38 .vsw = 5,
39 .vfp = 5,
40 .vbp = 41,
41
42 .interlace = true,
43};
44
31#define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev) 45#define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev)
32 46
33static int tvc_connect(struct omap_dss_device *dssdev) 47static int tvc_connect(struct omap_dss_device *dssdev)
@@ -212,14 +226,14 @@ static int tvc_probe(struct platform_device *pdev)
212 return -ENODEV; 226 return -ENODEV;
213 } 227 }
214 228
215 ddata->timings = omap_dss_pal_timings; 229 ddata->timings = tvc_pal_timings;
216 230
217 dssdev = &ddata->dssdev; 231 dssdev = &ddata->dssdev;
218 dssdev->driver = &tvc_driver; 232 dssdev->driver = &tvc_driver;
219 dssdev->dev = &pdev->dev; 233 dssdev->dev = &pdev->dev;
220 dssdev->type = OMAP_DISPLAY_TYPE_VENC; 234 dssdev->type = OMAP_DISPLAY_TYPE_VENC;
221 dssdev->owner = THIS_MODULE; 235 dssdev->owner = THIS_MODULE;
222 dssdev->panel.timings = omap_dss_pal_timings; 236 dssdev->panel.timings = tvc_pal_timings;
223 237
224 r = omapdss_register_display(dssdev); 238 r = omapdss_register_display(dssdev);
225 if (r) { 239 if (r) {
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 4888cb3fdef7..c7c83ff0f752 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -533,8 +533,7 @@ EXPORT_SYMBOL_GPL(debugfs_remove);
533 */ 533 */
534void debugfs_remove_recursive(struct dentry *dentry) 534void debugfs_remove_recursive(struct dentry *dentry)
535{ 535{
536 struct dentry *child; 536 struct dentry *child, *next, *parent;
537 struct dentry *parent;
538 537
539 if (IS_ERR_OR_NULL(dentry)) 538 if (IS_ERR_OR_NULL(dentry))
540 return; 539 return;
@@ -544,61 +543,37 @@ void debugfs_remove_recursive(struct dentry *dentry)
544 return; 543 return;
545 544
546 parent = dentry; 545 parent = dentry;
546 down:
547 mutex_lock(&parent->d_inode->i_mutex); 547 mutex_lock(&parent->d_inode->i_mutex);
548 list_for_each_entry_safe(child, next, &parent->d_subdirs, d_u.d_child) {
549 if (!debugfs_positive(child))
550 continue;
548 551
549 while (1) { 552 /* perhaps simple_empty(child) makes more sense */
550 /*
551 * When all dentries under "parent" has been removed,
552 * walk up the tree until we reach our starting point.
553 */
554 if (list_empty(&parent->d_subdirs)) {
555 mutex_unlock(&parent->d_inode->i_mutex);
556 if (parent == dentry)
557 break;
558 parent = parent->d_parent;
559 mutex_lock(&parent->d_inode->i_mutex);
560 }
561 child = list_entry(parent->d_subdirs.next, struct dentry,
562 d_u.d_child);
563 next_sibling:
564
565 /*
566 * If "child" isn't empty, walk down the tree and
567 * remove all its descendants first.
568 */
569 if (!list_empty(&child->d_subdirs)) { 553 if (!list_empty(&child->d_subdirs)) {
570 mutex_unlock(&parent->d_inode->i_mutex); 554 mutex_unlock(&parent->d_inode->i_mutex);
571 parent = child; 555 parent = child;
572 mutex_lock(&parent->d_inode->i_mutex); 556 goto down;
573 continue;
574 } 557 }
575 __debugfs_remove(child, parent); 558 up:
576 if (parent->d_subdirs.next == &child->d_u.d_child) { 559 if (!__debugfs_remove(child, parent))
577 /* 560 simple_release_fs(&debugfs_mount, &debugfs_mount_count);
578 * Try the next sibling.
579 */
580 if (child->d_u.d_child.next != &parent->d_subdirs) {
581 child = list_entry(child->d_u.d_child.next,
582 struct dentry,
583 d_u.d_child);
584 goto next_sibling;
585 }
586
587 /*
588 * Avoid infinite loop if we fail to remove
589 * one dentry.
590 */
591 mutex_unlock(&parent->d_inode->i_mutex);
592 break;
593 }
594 simple_release_fs(&debugfs_mount, &debugfs_mount_count);
595 } 561 }
596 562
597 parent = dentry->d_parent; 563 mutex_unlock(&parent->d_inode->i_mutex);
564 child = parent;
565 parent = parent->d_parent;
598 mutex_lock(&parent->d_inode->i_mutex); 566 mutex_lock(&parent->d_inode->i_mutex);
599 __debugfs_remove(dentry, parent); 567
568 if (child != dentry) {
569 next = list_entry(child->d_u.d_child.next, struct dentry,
570 d_u.d_child);
571 goto up;
572 }
573
574 if (!__debugfs_remove(child, parent))
575 simple_release_fs(&debugfs_mount, &debugfs_mount_count);
600 mutex_unlock(&parent->d_inode->i_mutex); 576 mutex_unlock(&parent->d_inode->i_mutex);
601 simple_release_fs(&debugfs_mount, &debugfs_mount_count);
602} 577}
603EXPORT_SYMBOL_GPL(debugfs_remove_recursive); 578EXPORT_SYMBOL_GPL(debugfs_remove_recursive);
604 579
diff --git a/fs/dlm/user.c b/fs/dlm/user.c
index 911649a47dd5..812149119fa3 100644
--- a/fs/dlm/user.c
+++ b/fs/dlm/user.c
@@ -686,7 +686,6 @@ static int device_close(struct inode *inode, struct file *file)
686 device_remove_lockspace() */ 686 device_remove_lockspace() */
687 687
688 sigprocmask(SIG_SETMASK, &tmpsig, NULL); 688 sigprocmask(SIG_SETMASK, &tmpsig, NULL);
689 recalc_sigpending();
690 689
691 return 0; 690 return 0;
692} 691}
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index a61873808f76..72ba4705d4fa 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4412,7 +4412,7 @@ void ext4_ext_truncate(handle_t *handle, struct inode *inode)
4412retry: 4412retry:
4413 err = ext4_es_remove_extent(inode, last_block, 4413 err = ext4_es_remove_extent(inode, last_block,
4414 EXT_MAX_BLOCKS - last_block); 4414 EXT_MAX_BLOCKS - last_block);
4415 if (err == ENOMEM) { 4415 if (err == -ENOMEM) {
4416 cond_resched(); 4416 cond_resched();
4417 congestion_wait(BLK_RW_ASYNC, HZ/50); 4417 congestion_wait(BLK_RW_ASYNC, HZ/50);
4418 goto retry; 4418 goto retry;
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index f03598c6ffd3..8bf5999875ee 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -734,11 +734,8 @@ repeat_in_this_group:
734 ino = ext4_find_next_zero_bit((unsigned long *) 734 ino = ext4_find_next_zero_bit((unsigned long *)
735 inode_bitmap_bh->b_data, 735 inode_bitmap_bh->b_data,
736 EXT4_INODES_PER_GROUP(sb), ino); 736 EXT4_INODES_PER_GROUP(sb), ino);
737 if (ino >= EXT4_INODES_PER_GROUP(sb)) { 737 if (ino >= EXT4_INODES_PER_GROUP(sb))
738 if (++group == ngroups) 738 goto next_group;
739 group = 0;
740 continue;
741 }
742 if (group == 0 && (ino+1) < EXT4_FIRST_INO(sb)) { 739 if (group == 0 && (ino+1) < EXT4_FIRST_INO(sb)) {
743 ext4_error(sb, "reserved inode found cleared - " 740 ext4_error(sb, "reserved inode found cleared - "
744 "inode=%lu", ino + 1); 741 "inode=%lu", ino + 1);
@@ -769,6 +766,9 @@ repeat_in_this_group:
769 goto got; /* we grabbed the inode! */ 766 goto got; /* we grabbed the inode! */
770 if (ino < EXT4_INODES_PER_GROUP(sb)) 767 if (ino < EXT4_INODES_PER_GROUP(sb))
771 goto repeat_in_this_group; 768 goto repeat_in_this_group;
769next_group:
770 if (++group == ngroups)
771 group = 0;
772 } 772 }
773 err = -ENOSPC; 773 err = -ENOSPC;
774 goto out; 774 goto out;
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index ba33c67d6e48..dd32a2eacd0d 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -555,14 +555,13 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
555 int ret; 555 int ret;
556 unsigned long long status; 556 unsigned long long status;
557 557
558#ifdef ES_AGGRESSIVE_TEST 558 if (unlikely(retval != map->m_len)) {
559 if (retval != map->m_len) { 559 ext4_warning(inode->i_sb,
560 printk("ES len assertion failed for inode: %lu " 560 "ES len assertion failed for inode "
561 "retval %d != map->m_len %d " 561 "%lu: retval %d != map->m_len %d",
562 "in %s (lookup)\n", inode->i_ino, retval, 562 inode->i_ino, retval, map->m_len);
563 map->m_len, __func__); 563 WARN_ON(1);
564 } 564 }
565#endif
566 565
567 status = map->m_flags & EXT4_MAP_UNWRITTEN ? 566 status = map->m_flags & EXT4_MAP_UNWRITTEN ?
568 EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN; 567 EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN;
@@ -656,14 +655,13 @@ found:
656 int ret; 655 int ret;
657 unsigned long long status; 656 unsigned long long status;
658 657
659#ifdef ES_AGGRESSIVE_TEST 658 if (unlikely(retval != map->m_len)) {
660 if (retval != map->m_len) { 659 ext4_warning(inode->i_sb,
661 printk("ES len assertion failed for inode: %lu " 660 "ES len assertion failed for inode "
662 "retval %d != map->m_len %d " 661 "%lu: retval %d != map->m_len %d",
663 "in %s (allocation)\n", inode->i_ino, retval, 662 inode->i_ino, retval, map->m_len);
664 map->m_len, __func__); 663 WARN_ON(1);
665 } 664 }
666#endif
667 665
668 /* 666 /*
669 * If the extent has been zeroed out, we don't need to update 667 * If the extent has been zeroed out, we don't need to update
@@ -1637,14 +1635,13 @@ add_delayed:
1637 int ret; 1635 int ret;
1638 unsigned long long status; 1636 unsigned long long status;
1639 1637
1640#ifdef ES_AGGRESSIVE_TEST 1638 if (unlikely(retval != map->m_len)) {
1641 if (retval != map->m_len) { 1639 ext4_warning(inode->i_sb,
1642 printk("ES len assertion failed for inode: %lu " 1640 "ES len assertion failed for inode "
1643 "retval %d != map->m_len %d " 1641 "%lu: retval %d != map->m_len %d",
1644 "in %s (lookup)\n", inode->i_ino, retval, 1642 inode->i_ino, retval, map->m_len);
1645 map->m_len, __func__); 1643 WARN_ON(1);
1646 } 1644 }
1647#endif
1648 1645
1649 status = map->m_flags & EXT4_MAP_UNWRITTEN ? 1646 status = map->m_flags & EXT4_MAP_UNWRITTEN ?
1650 EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN; 1647 EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN;
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index bca26f34edf4..36b141e420b7 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5481,6 +5481,7 @@ static void __exit ext4_exit_fs(void)
5481 kset_unregister(ext4_kset); 5481 kset_unregister(ext4_kset);
5482 ext4_exit_system_zone(); 5482 ext4_exit_system_zone();
5483 ext4_exit_pageio(); 5483 ext4_exit_pageio();
5484 ext4_exit_es();
5484} 5485}
5485 5486
5486MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others"); 5487MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
diff --git a/fs/fcntl.c b/fs/fcntl.c
index 6599222536eb..65343c3741ff 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -730,14 +730,14 @@ static int __init fcntl_init(void)
730 * Exceptions: O_NONBLOCK is a two bit define on parisc; O_NDELAY 730 * Exceptions: O_NONBLOCK is a two bit define on parisc; O_NDELAY
731 * is defined as O_NONBLOCK on some platforms and not on others. 731 * is defined as O_NONBLOCK on some platforms and not on others.
732 */ 732 */
733 BUILD_BUG_ON(19 - 1 /* for O_RDONLY being 0 */ != HWEIGHT32( 733 BUILD_BUG_ON(20 - 1 /* for O_RDONLY being 0 */ != HWEIGHT32(
734 O_RDONLY | O_WRONLY | O_RDWR | 734 O_RDONLY | O_WRONLY | O_RDWR |
735 O_CREAT | O_EXCL | O_NOCTTY | 735 O_CREAT | O_EXCL | O_NOCTTY |
736 O_TRUNC | O_APPEND | /* O_NONBLOCK | */ 736 O_TRUNC | O_APPEND | /* O_NONBLOCK | */
737 __O_SYNC | O_DSYNC | FASYNC | 737 __O_SYNC | O_DSYNC | FASYNC |
738 O_DIRECT | O_LARGEFILE | O_DIRECTORY | 738 O_DIRECT | O_LARGEFILE | O_DIRECTORY |
739 O_NOFOLLOW | O_NOATIME | O_CLOEXEC | 739 O_NOFOLLOW | O_NOATIME | O_CLOEXEC |
740 __FMODE_EXEC | O_PATH 740 __FMODE_EXEC | O_PATH | __O_TMPFILE
741 )); 741 ));
742 742
743 fasync_cache = kmem_cache_create("fasync_cache", 743 fasync_cache = kmem_cache_create("fasync_cache",
diff --git a/fs/namei.c b/fs/namei.c
index 8b61d103a8a7..89a612e392eb 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3671,15 +3671,11 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
3671 if ((flags & ~(AT_SYMLINK_FOLLOW | AT_EMPTY_PATH)) != 0) 3671 if ((flags & ~(AT_SYMLINK_FOLLOW | AT_EMPTY_PATH)) != 0)
3672 return -EINVAL; 3672 return -EINVAL;
3673 /* 3673 /*
3674 * To use null names we require CAP_DAC_READ_SEARCH 3674 * Using empty names is equivalent to using AT_SYMLINK_FOLLOW
3675 * This ensures that not everyone will be able to create 3675 * on /proc/self/fd/<fd>.
3676 * handlink using the passed filedescriptor.
3677 */ 3676 */
3678 if (flags & AT_EMPTY_PATH) { 3677 if (flags & AT_EMPTY_PATH)
3679 if (!capable(CAP_DAC_READ_SEARCH))
3680 return -ENOENT;
3681 how = LOOKUP_EMPTY; 3678 how = LOOKUP_EMPTY;
3682 }
3683 3679
3684 if (flags & AT_SYMLINK_FOLLOW) 3680 if (flags & AT_SYMLINK_FOLLOW)
3685 how |= LOOKUP_FOLLOW; 3681 how |= LOOKUP_FOLLOW;
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 0d4c410e4589..419572f33b72 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -1524,7 +1524,7 @@ static inline u32 nfsd4_write_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
1524static inline u32 nfsd4_exchange_id_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 1524static inline u32 nfsd4_exchange_id_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
1525{ 1525{
1526 return (op_encode_hdr_size + 2 + 1 + /* eir_clientid, eir_sequenceid */\ 1526 return (op_encode_hdr_size + 2 + 1 + /* eir_clientid, eir_sequenceid */\
1527 1 + 1 + 0 + /* eir_flags, spr_how, SP4_NONE (for now) */\ 1527 1 + 1 + 2 + /* eir_flags, spr_how, spo_must_enforce & _allow */\
1528 2 + /*eir_server_owner.so_minor_id */\ 1528 2 + /*eir_server_owner.so_minor_id */\
1529 /* eir_server_owner.so_major_id<> */\ 1529 /* eir_server_owner.so_major_id<> */\
1530 XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 +\ 1530 XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 +\
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 280acef6f0dc..43f42290e5df 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -1264,6 +1264,8 @@ static bool svc_rqst_integrity_protected(struct svc_rqst *rqstp)
1264 struct svc_cred *cr = &rqstp->rq_cred; 1264 struct svc_cred *cr = &rqstp->rq_cred;
1265 u32 service; 1265 u32 service;
1266 1266
1267 if (!cr->cr_gss_mech)
1268 return false;
1267 service = gss_pseudoflavor_to_service(cr->cr_gss_mech, cr->cr_flavor); 1269 service = gss_pseudoflavor_to_service(cr->cr_gss_mech, cr->cr_flavor);
1268 return service == RPC_GSS_SVC_INTEGRITY || 1270 return service == RPC_GSS_SVC_INTEGRITY ||
1269 service == RPC_GSS_SVC_PRIVACY; 1271 service == RPC_GSS_SVC_PRIVACY;
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 0c0f3ea90de5..c2a4701d7286 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -3360,7 +3360,8 @@ nfsd4_encode_exchange_id(struct nfsd4_compoundres *resp, __be32 nfserr,
3360 8 /* eir_clientid */ + 3360 8 /* eir_clientid */ +
3361 4 /* eir_sequenceid */ + 3361 4 /* eir_sequenceid */ +
3362 4 /* eir_flags */ + 3362 4 /* eir_flags */ +
3363 4 /* spr_how (SP4_NONE) */ + 3363 4 /* spr_how */ +
3364 8 /* spo_must_enforce, spo_must_allow */ +
3364 8 /* so_minor_id */ + 3365 8 /* so_minor_id */ +
3365 4 /* so_major_id.len */ + 3366 4 /* so_major_id.len */ +
3366 (XDR_QUADLEN(major_id_sz) * 4) + 3367 (XDR_QUADLEN(major_id_sz) * 4) +
@@ -3372,8 +3373,6 @@ nfsd4_encode_exchange_id(struct nfsd4_compoundres *resp, __be32 nfserr,
3372 WRITE32(exid->seqid); 3373 WRITE32(exid->seqid);
3373 WRITE32(exid->flags); 3374 WRITE32(exid->flags);
3374 3375
3375 /* state_protect4_r. Currently only support SP4_NONE */
3376 BUG_ON(exid->spa_how != SP4_NONE);
3377 WRITE32(exid->spa_how); 3376 WRITE32(exid->spa_how);
3378 switch (exid->spa_how) { 3377 switch (exid->spa_how) {
3379 case SP4_NONE: 3378 case SP4_NONE:
diff --git a/fs/open.c b/fs/open.c
index d53e29895082..7931f76acc2b 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -823,7 +823,7 @@ static inline int build_open_flags(int flags, umode_t mode, struct open_flags *o
823 int lookup_flags = 0; 823 int lookup_flags = 0;
824 int acc_mode; 824 int acc_mode;
825 825
826 if (flags & O_CREAT) 826 if (flags & (O_CREAT | __O_TMPFILE))
827 op->mode = (mode & S_IALLUGO) | S_IFREG; 827 op->mode = (mode & S_IALLUGO) | S_IFREG;
828 else 828 else
829 op->mode = 0; 829 op->mode = 0;
diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
index 33532f79b4f7..a958444a75fc 100644
--- a/fs/reiserfs/procfs.c
+++ b/fs/reiserfs/procfs.c
@@ -19,12 +19,13 @@
19/* 19/*
20 * LOCKING: 20 * LOCKING:
21 * 21 *
22 * We rely on new Alexander Viro's super-block locking. 22 * These guys are evicted from procfs as the very first step in ->kill_sb().
23 * 23 *
24 */ 24 */
25 25
26static int show_version(struct seq_file *m, struct super_block *sb) 26static int show_version(struct seq_file *m, void *unused)
27{ 27{
28 struct super_block *sb = m->private;
28 char *format; 29 char *format;
29 30
30 if (REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_6)) { 31 if (REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_6)) {
@@ -66,8 +67,9 @@ static int show_version(struct seq_file *m, struct super_block *sb)
66#define DJP( x ) le32_to_cpu( jp -> x ) 67#define DJP( x ) le32_to_cpu( jp -> x )
67#define JF( x ) ( r -> s_journal -> x ) 68#define JF( x ) ( r -> s_journal -> x )
68 69
69static int show_super(struct seq_file *m, struct super_block *sb) 70static int show_super(struct seq_file *m, void *unused)
70{ 71{
72 struct super_block *sb = m->private;
71 struct reiserfs_sb_info *r = REISERFS_SB(sb); 73 struct reiserfs_sb_info *r = REISERFS_SB(sb);
72 74
73 seq_printf(m, "state: \t%s\n" 75 seq_printf(m, "state: \t%s\n"
@@ -128,8 +130,9 @@ static int show_super(struct seq_file *m, struct super_block *sb)
128 return 0; 130 return 0;
129} 131}
130 132
131static int show_per_level(struct seq_file *m, struct super_block *sb) 133static int show_per_level(struct seq_file *m, void *unused)
132{ 134{
135 struct super_block *sb = m->private;
133 struct reiserfs_sb_info *r = REISERFS_SB(sb); 136 struct reiserfs_sb_info *r = REISERFS_SB(sb);
134 int level; 137 int level;
135 138
@@ -186,8 +189,9 @@ static int show_per_level(struct seq_file *m, struct super_block *sb)
186 return 0; 189 return 0;
187} 190}
188 191
189static int show_bitmap(struct seq_file *m, struct super_block *sb) 192static int show_bitmap(struct seq_file *m, void *unused)
190{ 193{
194 struct super_block *sb = m->private;
191 struct reiserfs_sb_info *r = REISERFS_SB(sb); 195 struct reiserfs_sb_info *r = REISERFS_SB(sb);
192 196
193 seq_printf(m, "free_block: %lu\n" 197 seq_printf(m, "free_block: %lu\n"
@@ -218,8 +222,9 @@ static int show_bitmap(struct seq_file *m, struct super_block *sb)
218 return 0; 222 return 0;
219} 223}
220 224
221static int show_on_disk_super(struct seq_file *m, struct super_block *sb) 225static int show_on_disk_super(struct seq_file *m, void *unused)
222{ 226{
227 struct super_block *sb = m->private;
223 struct reiserfs_sb_info *sb_info = REISERFS_SB(sb); 228 struct reiserfs_sb_info *sb_info = REISERFS_SB(sb);
224 struct reiserfs_super_block *rs = sb_info->s_rs; 229 struct reiserfs_super_block *rs = sb_info->s_rs;
225 int hash_code = DFL(s_hash_function_code); 230 int hash_code = DFL(s_hash_function_code);
@@ -261,8 +266,9 @@ static int show_on_disk_super(struct seq_file *m, struct super_block *sb)
261 return 0; 266 return 0;
262} 267}
263 268
264static int show_oidmap(struct seq_file *m, struct super_block *sb) 269static int show_oidmap(struct seq_file *m, void *unused)
265{ 270{
271 struct super_block *sb = m->private;
266 struct reiserfs_sb_info *sb_info = REISERFS_SB(sb); 272 struct reiserfs_sb_info *sb_info = REISERFS_SB(sb);
267 struct reiserfs_super_block *rs = sb_info->s_rs; 273 struct reiserfs_super_block *rs = sb_info->s_rs;
268 unsigned int mapsize = le16_to_cpu(rs->s_v1.s_oid_cursize); 274 unsigned int mapsize = le16_to_cpu(rs->s_v1.s_oid_cursize);
@@ -291,8 +297,9 @@ static int show_oidmap(struct seq_file *m, struct super_block *sb)
291 return 0; 297 return 0;
292} 298}
293 299
294static int show_journal(struct seq_file *m, struct super_block *sb) 300static int show_journal(struct seq_file *m, void *unused)
295{ 301{
302 struct super_block *sb = m->private;
296 struct reiserfs_sb_info *r = REISERFS_SB(sb); 303 struct reiserfs_sb_info *r = REISERFS_SB(sb);
297 struct reiserfs_super_block *rs = r->s_rs; 304 struct reiserfs_super_block *rs = r->s_rs;
298 struct journal_params *jp = &rs->s_v1.s_journal; 305 struct journal_params *jp = &rs->s_v1.s_journal;
@@ -383,92 +390,24 @@ static int show_journal(struct seq_file *m, struct super_block *sb)
383 return 0; 390 return 0;
384} 391}
385 392
386/* iterator */
387static int test_sb(struct super_block *sb, void *data)
388{
389 return data == sb;
390}
391
392static int set_sb(struct super_block *sb, void *data)
393{
394 return -ENOENT;
395}
396
397struct reiserfs_seq_private {
398 struct super_block *sb;
399 int (*show) (struct seq_file *, struct super_block *);
400};
401
402static void *r_start(struct seq_file *m, loff_t * pos)
403{
404 struct reiserfs_seq_private *priv = m->private;
405 loff_t l = *pos;
406
407 if (l)
408 return NULL;
409
410 if (IS_ERR(sget(&reiserfs_fs_type, test_sb, set_sb, 0, priv->sb)))
411 return NULL;
412
413 up_write(&priv->sb->s_umount);
414 return priv->sb;
415}
416
417static void *r_next(struct seq_file *m, void *v, loff_t * pos)
418{
419 ++*pos;
420 if (v)
421 deactivate_super(v);
422 return NULL;
423}
424
425static void r_stop(struct seq_file *m, void *v)
426{
427 if (v)
428 deactivate_super(v);
429}
430
431static int r_show(struct seq_file *m, void *v)
432{
433 struct reiserfs_seq_private *priv = m->private;
434 return priv->show(m, v);
435}
436
437static const struct seq_operations r_ops = {
438 .start = r_start,
439 .next = r_next,
440 .stop = r_stop,
441 .show = r_show,
442};
443
444static int r_open(struct inode *inode, struct file *file) 393static int r_open(struct inode *inode, struct file *file)
445{ 394{
446 struct reiserfs_seq_private *priv; 395 return single_open(file, PDE_DATA(inode),
447 int ret = seq_open_private(file, &r_ops, 396 proc_get_parent_data(inode));
448 sizeof(struct reiserfs_seq_private));
449
450 if (!ret) {
451 struct seq_file *m = file->private_data;
452 priv = m->private;
453 priv->sb = proc_get_parent_data(inode);
454 priv->show = PDE_DATA(inode);
455 }
456 return ret;
457} 397}
458 398
459static const struct file_operations r_file_operations = { 399static const struct file_operations r_file_operations = {
460 .open = r_open, 400 .open = r_open,
461 .read = seq_read, 401 .read = seq_read,
462 .llseek = seq_lseek, 402 .llseek = seq_lseek,
463 .release = seq_release_private, 403 .release = single_release,
464 .owner = THIS_MODULE,
465}; 404};
466 405
467static struct proc_dir_entry *proc_info_root = NULL; 406static struct proc_dir_entry *proc_info_root = NULL;
468static const char proc_info_root_name[] = "fs/reiserfs"; 407static const char proc_info_root_name[] = "fs/reiserfs";
469 408
470static void add_file(struct super_block *sb, char *name, 409static void add_file(struct super_block *sb, char *name,
471 int (*func) (struct seq_file *, struct super_block *)) 410 int (*func) (struct seq_file *, void *))
472{ 411{
473 proc_create_data(name, 0, REISERFS_SB(sb)->procdir, 412 proc_create_data(name, 0, REISERFS_SB(sb)->procdir,
474 &r_file_operations, func); 413 &r_file_operations, func);
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index f8a23c3078f8..e2e202a07b31 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -499,6 +499,7 @@ int remove_save_link(struct inode *inode, int truncate)
499static void reiserfs_kill_sb(struct super_block *s) 499static void reiserfs_kill_sb(struct super_block *s)
500{ 500{
501 if (REISERFS_SB(s)) { 501 if (REISERFS_SB(s)) {
502 reiserfs_proc_info_done(s);
502 /* 503 /*
503 * Force any pending inode evictions to occur now. Any 504 * Force any pending inode evictions to occur now. Any
504 * inodes to be removed that have extended attributes 505 * inodes to be removed that have extended attributes
@@ -554,8 +555,6 @@ static void reiserfs_put_super(struct super_block *s)
554 REISERFS_SB(s)->reserved_blocks); 555 REISERFS_SB(s)->reserved_blocks);
555 } 556 }
556 557
557 reiserfs_proc_info_done(s);
558
559 reiserfs_write_unlock(s); 558 reiserfs_write_unlock(s);
560 mutex_destroy(&REISERFS_SB(s)->lock); 559 mutex_destroy(&REISERFS_SB(s)->lock);
561 kfree(s->s_fs_info); 560 kfree(s->s_fs_info);
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 56e6b68c8d2f..94383a70c1a3 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -274,15 +274,12 @@ struct acpi_device_wakeup {
274}; 274};
275 275
276struct acpi_device_physical_node { 276struct acpi_device_physical_node {
277 u8 node_id; 277 unsigned int node_id;
278 struct list_head node; 278 struct list_head node;
279 struct device *dev; 279 struct device *dev;
280 bool put_online:1; 280 bool put_online:1;
281}; 281};
282 282
283/* set maximum of physical nodes to 32 for expansibility */
284#define ACPI_MAX_PHYSICAL_NODE 32
285
286/* Device */ 283/* Device */
287struct acpi_device { 284struct acpi_device {
288 int device_type; 285 int device_type;
@@ -302,10 +299,9 @@ struct acpi_device {
302 struct acpi_driver *driver; 299 struct acpi_driver *driver;
303 void *driver_data; 300 void *driver_data;
304 struct device dev; 301 struct device dev;
305 u8 physical_node_count; 302 unsigned int physical_node_count;
306 struct list_head physical_node_list; 303 struct list_head physical_node_list;
307 struct mutex physical_node_lock; 304 struct mutex physical_node_lock;
308 DECLARE_BITMAP(physical_node_id_bitmap, ACPI_MAX_PHYSICAL_NODE);
309 struct list_head power_dependent; 305 struct list_head power_dependent;
310 void (*remove)(struct acpi_device *); 306 void (*remove)(struct acpi_device *);
311}; 307};
@@ -445,7 +441,11 @@ struct acpi_pci_root {
445}; 441};
446 442
447/* helper */ 443/* helper */
448acpi_handle acpi_get_child(acpi_handle, u64); 444acpi_handle acpi_find_child(acpi_handle, u64, bool);
445static inline acpi_handle acpi_get_child(acpi_handle handle, u64 addr)
446{
447 return acpi_find_child(handle, addr, false);
448}
449int acpi_is_root_bridge(acpi_handle); 449int acpi_is_root_bridge(acpi_handle);
450struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle); 450struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle);
451#define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)ACPI_HANDLE(dev)) 451#define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)ACPI_HANDLE(dev))
diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
index 4372658c73ae..120d57a1c3a5 100644
--- a/include/linux/ftrace_event.h
+++ b/include/linux/ftrace_event.h
@@ -78,6 +78,11 @@ struct trace_iterator {
78 /* trace_seq for __print_flags() and __print_symbolic() etc. */ 78 /* trace_seq for __print_flags() and __print_symbolic() etc. */
79 struct trace_seq tmp_seq; 79 struct trace_seq tmp_seq;
80 80
81 cpumask_var_t started;
82
83 /* it's true when current open file is snapshot */
84 bool snapshot;
85
81 /* The below is zeroed out in pipe_read */ 86 /* The below is zeroed out in pipe_read */
82 struct trace_seq seq; 87 struct trace_seq seq;
83 struct trace_entry *ent; 88 struct trace_entry *ent;
@@ -90,10 +95,7 @@ struct trace_iterator {
90 loff_t pos; 95 loff_t pos;
91 long idx; 96 long idx;
92 97
93 cpumask_var_t started; 98 /* All new field here will be zeroed out in pipe_read */
94
95 /* it's true when current open file is snapshot */
96 bool snapshot;
97}; 99};
98 100
99enum trace_iter_flags { 101enum trace_iter_flags {
@@ -332,7 +334,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
332 const char *name, int offset, int size, 334 const char *name, int offset, int size,
333 int is_signed, int filter_type); 335 int is_signed, int filter_type);
334extern int trace_add_event_call(struct ftrace_event_call *call); 336extern int trace_add_event_call(struct ftrace_event_call *call);
335extern void trace_remove_event_call(struct ftrace_event_call *call); 337extern int trace_remove_event_call(struct ftrace_event_call *call);
336 338
337#define is_signed_type(type) (((type)(-1)) < (type)1) 339#define is_signed_type(type) (((type)(-1)) < (type)1)
338 340
diff --git a/include/linux/iio/trigger.h b/include/linux/iio/trigger.h
index 3869c525b052..369cf2cd5144 100644
--- a/include/linux/iio/trigger.h
+++ b/include/linux/iio/trigger.h
@@ -8,6 +8,7 @@
8 */ 8 */
9#include <linux/irq.h> 9#include <linux/irq.h>
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/atomic.h>
11 12
12#ifndef _IIO_TRIGGER_H_ 13#ifndef _IIO_TRIGGER_H_
13#define _IIO_TRIGGER_H_ 14#define _IIO_TRIGGER_H_
@@ -61,7 +62,7 @@ struct iio_trigger {
61 62
62 struct list_head list; 63 struct list_head list;
63 struct list_head alloc_list; 64 struct list_head alloc_list;
64 int use_count; 65 atomic_t use_count;
65 66
66 struct irq_chip subirq_chip; 67 struct irq_chip subirq_chip;
67 int subirq_base; 68 int subirq_base;
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 3bef14c6586b..482ad2d84a32 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -629,7 +629,7 @@ extern void ftrace_dump(enum ftrace_dump_mode oops_dump_mode);
629static inline void tracing_start(void) { } 629static inline void tracing_start(void) { }
630static inline void tracing_stop(void) { } 630static inline void tracing_stop(void) { }
631static inline void ftrace_off_permanent(void) { } 631static inline void ftrace_off_permanent(void) { }
632static inline void trace_dump_stack(void) { } 632static inline void trace_dump_stack(int skip) { }
633 633
634static inline void tracing_on(void) { } 634static inline void tracing_on(void) { }
635static inline void tracing_off(void) { } 635static inline void tracing_off(void) { }
diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
index 8d73fe29796a..db1791bb997a 100644
--- a/include/linux/mfd/ti_am335x_tscadc.h
+++ b/include/linux/mfd/ti_am335x_tscadc.h
@@ -113,11 +113,27 @@
113#define CNTRLREG_8WIRE CNTRLREG_AFE_CTRL(3) 113#define CNTRLREG_8WIRE CNTRLREG_AFE_CTRL(3)
114#define CNTRLREG_TSCENB BIT(7) 114#define CNTRLREG_TSCENB BIT(7)
115 115
116/* FIFO READ Register */
117#define FIFOREAD_DATA_MASK (0xfff << 0)
118#define FIFOREAD_CHNLID_MASK (0xf << 16)
119
120/* Sequencer Status */
121#define SEQ_STATUS BIT(5)
122
116#define ADC_CLK 3000000 123#define ADC_CLK 3000000
117#define MAX_CLK_DIV 7 124#define MAX_CLK_DIV 7
118#define TOTAL_STEPS 16 125#define TOTAL_STEPS 16
119#define TOTAL_CHANNELS 8 126#define TOTAL_CHANNELS 8
120 127
128/*
129* ADC runs at 3MHz, and it takes
130* 15 cycles to latch one data output.
131* Hence the idle time for ADC to
132* process one sample data would be
133* around 5 micro seconds.
134*/
135#define IDLE_TIMEOUT 5 /* microsec */
136
121#define TSCADC_CELLS 2 137#define TSCADC_CELLS 2
122 138
123struct ti_tscadc_dev { 139struct ti_tscadc_dev {
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 75981d0b57dc..580a5320cc96 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -15,6 +15,7 @@
15 15
16#include <linux/list.h> 16#include <linux/list.h>
17#include <linux/rbtree.h> 17#include <linux/rbtree.h>
18#include <linux/err.h>
18 19
19struct module; 20struct module;
20struct device; 21struct device;
diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
index b6b215f13b45..14105c26a836 100644
--- a/include/linux/user_namespace.h
+++ b/include/linux/user_namespace.h
@@ -23,6 +23,7 @@ struct user_namespace {
23 struct uid_gid_map projid_map; 23 struct uid_gid_map projid_map;
24 atomic_t count; 24 atomic_t count;
25 struct user_namespace *parent; 25 struct user_namespace *parent;
26 int level;
26 kuid_t owner; 27 kuid_t owner;
27 kgid_t group; 28 kgid_t group;
28 unsigned int proc_inum; 29 unsigned int proc_inum;
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index 7343a27fe819..47ada23345a1 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -22,6 +22,7 @@
22#define _V4L2_CTRLS_H 22#define _V4L2_CTRLS_H
23 23
24#include <linux/list.h> 24#include <linux/list.h>
25#include <linux/mutex.h>
25#include <linux/videodev2.h> 26#include <linux/videodev2.h>
26 27
27/* forward references */ 28/* forward references */
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 789ec4683db3..781845a013ab 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -4335,8 +4335,10 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
4335 } 4335 }
4336 4336
4337 err = percpu_ref_init(&css->refcnt, css_release); 4337 err = percpu_ref_init(&css->refcnt, css_release);
4338 if (err) 4338 if (err) {
4339 ss->css_free(cgrp);
4339 goto err_free_all; 4340 goto err_free_all;
4341 }
4340 4342
4341 init_cgroup_css(css, ss, cgrp); 4343 init_cgroup_css(css, ss, cgrp);
4342 4344
diff --git a/kernel/printk/braille.c b/kernel/printk/braille.c
index b51087fb9ace..276762f3a460 100644
--- a/kernel/printk/braille.c
+++ b/kernel/printk/braille.c
@@ -19,7 +19,8 @@ char *_braille_console_setup(char **str, char **brl_options)
19 pr_err("need port name after brl=\n"); 19 pr_err("need port name after brl=\n");
20 else 20 else
21 *((*str)++) = 0; 21 *((*str)++) = 0;
22 } 22 } else
23 return NULL;
23 24
24 return *str; 25 return *str;
25} 26}
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 4041f5747e73..a146ee327f6a 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -469,7 +469,6 @@ static int ptrace_detach(struct task_struct *child, unsigned int data)
469 /* Architecture-specific hardware disable .. */ 469 /* Architecture-specific hardware disable .. */
470 ptrace_disable(child); 470 ptrace_disable(child);
471 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 471 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
472 flush_ptrace_hw_breakpoint(child);
473 472
474 write_lock_irq(&tasklist_lock); 473 write_lock_irq(&tasklist_lock);
475 /* 474 /*
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 8ce9eefc5bb4..a6d098c6df3f 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -2169,12 +2169,57 @@ static cycle_t ftrace_update_time;
2169static unsigned long ftrace_update_cnt; 2169static unsigned long ftrace_update_cnt;
2170unsigned long ftrace_update_tot_cnt; 2170unsigned long ftrace_update_tot_cnt;
2171 2171
2172static int ops_traces_mod(struct ftrace_ops *ops) 2172static inline int ops_traces_mod(struct ftrace_ops *ops)
2173{ 2173{
2174 struct ftrace_hash *hash; 2174 /*
2175 * Filter_hash being empty will default to trace module.
2176 * But notrace hash requires a test of individual module functions.
2177 */
2178 return ftrace_hash_empty(ops->filter_hash) &&
2179 ftrace_hash_empty(ops->notrace_hash);
2180}
2181
2182/*
2183 * Check if the current ops references the record.
2184 *
2185 * If the ops traces all functions, then it was already accounted for.
2186 * If the ops does not trace the current record function, skip it.
2187 * If the ops ignores the function via notrace filter, skip it.
2188 */
2189static inline bool
2190ops_references_rec(struct ftrace_ops *ops, struct dyn_ftrace *rec)
2191{
2192 /* If ops isn't enabled, ignore it */
2193 if (!(ops->flags & FTRACE_OPS_FL_ENABLED))
2194 return 0;
2195
2196 /* If ops traces all mods, we already accounted for it */
2197 if (ops_traces_mod(ops))
2198 return 0;
2199
2200 /* The function must be in the filter */
2201 if (!ftrace_hash_empty(ops->filter_hash) &&
2202 !ftrace_lookup_ip(ops->filter_hash, rec->ip))
2203 return 0;
2204
2205 /* If in notrace hash, we ignore it too */
2206 if (ftrace_lookup_ip(ops->notrace_hash, rec->ip))
2207 return 0;
2208
2209 return 1;
2210}
2211
2212static int referenced_filters(struct dyn_ftrace *rec)
2213{
2214 struct ftrace_ops *ops;
2215 int cnt = 0;
2175 2216
2176 hash = ops->filter_hash; 2217 for (ops = ftrace_ops_list; ops != &ftrace_list_end; ops = ops->next) {
2177 return ftrace_hash_empty(hash); 2218 if (ops_references_rec(ops, rec))
2219 cnt++;
2220 }
2221
2222 return cnt;
2178} 2223}
2179 2224
2180static int ftrace_update_code(struct module *mod) 2225static int ftrace_update_code(struct module *mod)
@@ -2183,6 +2228,7 @@ static int ftrace_update_code(struct module *mod)
2183 struct dyn_ftrace *p; 2228 struct dyn_ftrace *p;
2184 cycle_t start, stop; 2229 cycle_t start, stop;
2185 unsigned long ref = 0; 2230 unsigned long ref = 0;
2231 bool test = false;
2186 int i; 2232 int i;
2187 2233
2188 /* 2234 /*
@@ -2196,9 +2242,12 @@ static int ftrace_update_code(struct module *mod)
2196 2242
2197 for (ops = ftrace_ops_list; 2243 for (ops = ftrace_ops_list;
2198 ops != &ftrace_list_end; ops = ops->next) { 2244 ops != &ftrace_list_end; ops = ops->next) {
2199 if (ops->flags & FTRACE_OPS_FL_ENABLED && 2245 if (ops->flags & FTRACE_OPS_FL_ENABLED) {
2200 ops_traces_mod(ops)) 2246 if (ops_traces_mod(ops))
2201 ref++; 2247 ref++;
2248 else
2249 test = true;
2250 }
2202 } 2251 }
2203 } 2252 }
2204 2253
@@ -2208,12 +2257,16 @@ static int ftrace_update_code(struct module *mod)
2208 for (pg = ftrace_new_pgs; pg; pg = pg->next) { 2257 for (pg = ftrace_new_pgs; pg; pg = pg->next) {
2209 2258
2210 for (i = 0; i < pg->index; i++) { 2259 for (i = 0; i < pg->index; i++) {
2260 int cnt = ref;
2261
2211 /* If something went wrong, bail without enabling anything */ 2262 /* If something went wrong, bail without enabling anything */
2212 if (unlikely(ftrace_disabled)) 2263 if (unlikely(ftrace_disabled))
2213 return -1; 2264 return -1;
2214 2265
2215 p = &pg->records[i]; 2266 p = &pg->records[i];
2216 p->flags = ref; 2267 if (test)
2268 cnt += referenced_filters(p);
2269 p->flags = cnt;
2217 2270
2218 /* 2271 /*
2219 * Do the initial record conversion from mcount jump 2272 * Do the initial record conversion from mcount jump
@@ -2233,7 +2286,7 @@ static int ftrace_update_code(struct module *mod)
2233 * conversion puts the module to the correct state, thus 2286 * conversion puts the module to the correct state, thus
2234 * passing the ftrace_make_call check. 2287 * passing the ftrace_make_call check.
2235 */ 2288 */
2236 if (ftrace_start_up && ref) { 2289 if (ftrace_start_up && cnt) {
2237 int failed = __ftrace_replace_code(p, 1); 2290 int failed = __ftrace_replace_code(p, 1);
2238 if (failed) 2291 if (failed)
2239 ftrace_bug(failed, p->ip); 2292 ftrace_bug(failed, p->ip);
@@ -3384,6 +3437,12 @@ ftrace_match_addr(struct ftrace_hash *hash, unsigned long ip, int remove)
3384 return add_hash_entry(hash, ip); 3437 return add_hash_entry(hash, ip);
3385} 3438}
3386 3439
3440static void ftrace_ops_update_code(struct ftrace_ops *ops)
3441{
3442 if (ops->flags & FTRACE_OPS_FL_ENABLED && ftrace_enabled)
3443 ftrace_run_update_code(FTRACE_UPDATE_CALLS);
3444}
3445
3387static int 3446static int
3388ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len, 3447ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len,
3389 unsigned long ip, int remove, int reset, int enable) 3448 unsigned long ip, int remove, int reset, int enable)
@@ -3426,9 +3485,8 @@ ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len,
3426 3485
3427 mutex_lock(&ftrace_lock); 3486 mutex_lock(&ftrace_lock);
3428 ret = ftrace_hash_move(ops, enable, orig_hash, hash); 3487 ret = ftrace_hash_move(ops, enable, orig_hash, hash);
3429 if (!ret && ops->flags & FTRACE_OPS_FL_ENABLED 3488 if (!ret)
3430 && ftrace_enabled) 3489 ftrace_ops_update_code(ops);
3431 ftrace_run_update_code(FTRACE_UPDATE_CALLS);
3432 3490
3433 mutex_unlock(&ftrace_lock); 3491 mutex_unlock(&ftrace_lock);
3434 3492
@@ -3655,9 +3713,8 @@ int ftrace_regex_release(struct inode *inode, struct file *file)
3655 mutex_lock(&ftrace_lock); 3713 mutex_lock(&ftrace_lock);
3656 ret = ftrace_hash_move(iter->ops, filter_hash, 3714 ret = ftrace_hash_move(iter->ops, filter_hash,
3657 orig_hash, iter->hash); 3715 orig_hash, iter->hash);
3658 if (!ret && (iter->ops->flags & FTRACE_OPS_FL_ENABLED) 3716 if (!ret)
3659 && ftrace_enabled) 3717 ftrace_ops_update_code(iter->ops);
3660 ftrace_run_update_code(FTRACE_UPDATE_CALLS);
3661 3718
3662 mutex_unlock(&ftrace_lock); 3719 mutex_unlock(&ftrace_lock);
3663 } 3720 }
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 882ec1dd1515..496f94d57698 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -243,20 +243,25 @@ int filter_current_check_discard(struct ring_buffer *buffer,
243} 243}
244EXPORT_SYMBOL_GPL(filter_current_check_discard); 244EXPORT_SYMBOL_GPL(filter_current_check_discard);
245 245
246cycle_t ftrace_now(int cpu) 246cycle_t buffer_ftrace_now(struct trace_buffer *buf, int cpu)
247{ 247{
248 u64 ts; 248 u64 ts;
249 249
250 /* Early boot up does not have a buffer yet */ 250 /* Early boot up does not have a buffer yet */
251 if (!global_trace.trace_buffer.buffer) 251 if (!buf->buffer)
252 return trace_clock_local(); 252 return trace_clock_local();
253 253
254 ts = ring_buffer_time_stamp(global_trace.trace_buffer.buffer, cpu); 254 ts = ring_buffer_time_stamp(buf->buffer, cpu);
255 ring_buffer_normalize_time_stamp(global_trace.trace_buffer.buffer, cpu, &ts); 255 ring_buffer_normalize_time_stamp(buf->buffer, cpu, &ts);
256 256
257 return ts; 257 return ts;
258} 258}
259 259
260cycle_t ftrace_now(int cpu)
261{
262 return buffer_ftrace_now(&global_trace.trace_buffer, cpu);
263}
264
260/** 265/**
261 * tracing_is_enabled - Show if global_trace has been disabled 266 * tracing_is_enabled - Show if global_trace has been disabled
262 * 267 *
@@ -1211,7 +1216,7 @@ void tracing_reset_online_cpus(struct trace_buffer *buf)
1211 /* Make sure all commits have finished */ 1216 /* Make sure all commits have finished */
1212 synchronize_sched(); 1217 synchronize_sched();
1213 1218
1214 buf->time_start = ftrace_now(buf->cpu); 1219 buf->time_start = buffer_ftrace_now(buf, buf->cpu);
1215 1220
1216 for_each_online_cpu(cpu) 1221 for_each_online_cpu(cpu)
1217 ring_buffer_reset_cpu(buffer, cpu); 1222 ring_buffer_reset_cpu(buffer, cpu);
@@ -1219,11 +1224,6 @@ void tracing_reset_online_cpus(struct trace_buffer *buf)
1219 ring_buffer_record_enable(buffer); 1224 ring_buffer_record_enable(buffer);
1220} 1225}
1221 1226
1222void tracing_reset_current(int cpu)
1223{
1224 tracing_reset(&global_trace.trace_buffer, cpu);
1225}
1226
1227/* Must have trace_types_lock held */ 1227/* Must have trace_types_lock held */
1228void tracing_reset_all_online_cpus(void) 1228void tracing_reset_all_online_cpus(void)
1229{ 1229{
@@ -4151,6 +4151,7 @@ waitagain:
4151 memset(&iter->seq, 0, 4151 memset(&iter->seq, 0,
4152 sizeof(struct trace_iterator) - 4152 sizeof(struct trace_iterator) -
4153 offsetof(struct trace_iterator, seq)); 4153 offsetof(struct trace_iterator, seq));
4154 cpumask_clear(iter->started);
4154 iter->pos = -1; 4155 iter->pos = -1;
4155 4156
4156 trace_event_read_lock(); 4157 trace_event_read_lock();
@@ -4468,7 +4469,7 @@ tracing_free_buffer_release(struct inode *inode, struct file *filp)
4468 4469
4469 /* disable tracing ? */ 4470 /* disable tracing ? */
4470 if (trace_flags & TRACE_ITER_STOP_ON_FREE) 4471 if (trace_flags & TRACE_ITER_STOP_ON_FREE)
4471 tracing_off(); 4472 tracer_tracing_off(tr);
4472 /* resize the ring buffer to 0 */ 4473 /* resize the ring buffer to 0 */
4473 tracing_resize_ring_buffer(tr, 0, RING_BUFFER_ALL_CPUS); 4474 tracing_resize_ring_buffer(tr, 0, RING_BUFFER_ALL_CPUS);
4474 4475
@@ -4633,12 +4634,12 @@ static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf,
4633 * New clock may not be consistent with the previous clock. 4634 * New clock may not be consistent with the previous clock.
4634 * Reset the buffer so that it doesn't have incomparable timestamps. 4635 * Reset the buffer so that it doesn't have incomparable timestamps.
4635 */ 4636 */
4636 tracing_reset_online_cpus(&global_trace.trace_buffer); 4637 tracing_reset_online_cpus(&tr->trace_buffer);
4637 4638
4638#ifdef CONFIG_TRACER_MAX_TRACE 4639#ifdef CONFIG_TRACER_MAX_TRACE
4639 if (tr->flags & TRACE_ARRAY_FL_GLOBAL && tr->max_buffer.buffer) 4640 if (tr->flags & TRACE_ARRAY_FL_GLOBAL && tr->max_buffer.buffer)
4640 ring_buffer_set_clock(tr->max_buffer.buffer, trace_clocks[i].func); 4641 ring_buffer_set_clock(tr->max_buffer.buffer, trace_clocks[i].func);
4641 tracing_reset_online_cpus(&global_trace.max_buffer); 4642 tracing_reset_online_cpus(&tr->max_buffer);
4642#endif 4643#endif
4643 4644
4644 mutex_unlock(&trace_types_lock); 4645 mutex_unlock(&trace_types_lock);
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 898f868833f2..29a7ebcfb426 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -409,33 +409,42 @@ static void put_system(struct ftrace_subsystem_dir *dir)
409 mutex_unlock(&event_mutex); 409 mutex_unlock(&event_mutex);
410} 410}
411 411
412/* 412static void remove_subsystem(struct ftrace_subsystem_dir *dir)
413 * Open and update trace_array ref count.
414 * Must have the current trace_array passed to it.
415 */
416static int tracing_open_generic_file(struct inode *inode, struct file *filp)
417{ 413{
418 struct ftrace_event_file *file = inode->i_private; 414 if (!dir)
419 struct trace_array *tr = file->tr; 415 return;
420 int ret;
421 416
422 if (trace_array_get(tr) < 0) 417 if (!--dir->nr_events) {
423 return -ENODEV; 418 debugfs_remove_recursive(dir->entry);
419 list_del(&dir->list);
420 __put_system_dir(dir);
421 }
422}
424 423
425 ret = tracing_open_generic(inode, filp); 424static void *event_file_data(struct file *filp)
426 if (ret < 0) 425{
427 trace_array_put(tr); 426 return ACCESS_ONCE(file_inode(filp)->i_private);
428 return ret;
429} 427}
430 428
431static int tracing_release_generic_file(struct inode *inode, struct file *filp) 429static void remove_event_file_dir(struct ftrace_event_file *file)
432{ 430{
433 struct ftrace_event_file *file = inode->i_private; 431 struct dentry *dir = file->dir;
434 struct trace_array *tr = file->tr; 432 struct dentry *child;
435 433
436 trace_array_put(tr); 434 if (dir) {
435 spin_lock(&dir->d_lock); /* probably unneeded */
436 list_for_each_entry(child, &dir->d_subdirs, d_u.d_child) {
437 if (child->d_inode) /* probably unneeded */
438 child->d_inode->i_private = NULL;
439 }
440 spin_unlock(&dir->d_lock);
437 441
438 return 0; 442 debugfs_remove_recursive(dir);
443 }
444
445 list_del(&file->list);
446 remove_subsystem(file->system);
447 kmem_cache_free(file_cachep, file);
439} 448}
440 449
441/* 450/*
@@ -679,15 +688,25 @@ static ssize_t
679event_enable_read(struct file *filp, char __user *ubuf, size_t cnt, 688event_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
680 loff_t *ppos) 689 loff_t *ppos)
681{ 690{
682 struct ftrace_event_file *file = filp->private_data; 691 struct ftrace_event_file *file;
692 unsigned long flags;
683 char buf[4] = "0"; 693 char buf[4] = "0";
684 694
685 if (file->flags & FTRACE_EVENT_FL_ENABLED && 695 mutex_lock(&event_mutex);
686 !(file->flags & FTRACE_EVENT_FL_SOFT_DISABLED)) 696 file = event_file_data(filp);
697 if (likely(file))
698 flags = file->flags;
699 mutex_unlock(&event_mutex);
700
701 if (!file)
702 return -ENODEV;
703
704 if (flags & FTRACE_EVENT_FL_ENABLED &&
705 !(flags & FTRACE_EVENT_FL_SOFT_DISABLED))
687 strcpy(buf, "1"); 706 strcpy(buf, "1");
688 707
689 if (file->flags & FTRACE_EVENT_FL_SOFT_DISABLED || 708 if (flags & FTRACE_EVENT_FL_SOFT_DISABLED ||
690 file->flags & FTRACE_EVENT_FL_SOFT_MODE) 709 flags & FTRACE_EVENT_FL_SOFT_MODE)
691 strcat(buf, "*"); 710 strcat(buf, "*");
692 711
693 strcat(buf, "\n"); 712 strcat(buf, "\n");
@@ -699,13 +718,10 @@ static ssize_t
699event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt, 718event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
700 loff_t *ppos) 719 loff_t *ppos)
701{ 720{
702 struct ftrace_event_file *file = filp->private_data; 721 struct ftrace_event_file *file;
703 unsigned long val; 722 unsigned long val;
704 int ret; 723 int ret;
705 724
706 if (!file)
707 return -EINVAL;
708
709 ret = kstrtoul_from_user(ubuf, cnt, 10, &val); 725 ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
710 if (ret) 726 if (ret)
711 return ret; 727 return ret;
@@ -717,8 +733,11 @@ event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
717 switch (val) { 733 switch (val) {
718 case 0: 734 case 0:
719 case 1: 735 case 1:
736 ret = -ENODEV;
720 mutex_lock(&event_mutex); 737 mutex_lock(&event_mutex);
721 ret = ftrace_event_enable_disable(file, val); 738 file = event_file_data(filp);
739 if (likely(file))
740 ret = ftrace_event_enable_disable(file, val);
722 mutex_unlock(&event_mutex); 741 mutex_unlock(&event_mutex);
723 break; 742 break;
724 743
@@ -825,7 +844,7 @@ enum {
825 844
826static void *f_next(struct seq_file *m, void *v, loff_t *pos) 845static void *f_next(struct seq_file *m, void *v, loff_t *pos)
827{ 846{
828 struct ftrace_event_call *call = m->private; 847 struct ftrace_event_call *call = event_file_data(m->private);
829 struct list_head *common_head = &ftrace_common_fields; 848 struct list_head *common_head = &ftrace_common_fields;
830 struct list_head *head = trace_get_fields(call); 849 struct list_head *head = trace_get_fields(call);
831 struct list_head *node = v; 850 struct list_head *node = v;
@@ -857,7 +876,7 @@ static void *f_next(struct seq_file *m, void *v, loff_t *pos)
857 876
858static int f_show(struct seq_file *m, void *v) 877static int f_show(struct seq_file *m, void *v)
859{ 878{
860 struct ftrace_event_call *call = m->private; 879 struct ftrace_event_call *call = event_file_data(m->private);
861 struct ftrace_event_field *field; 880 struct ftrace_event_field *field;
862 const char *array_descriptor; 881 const char *array_descriptor;
863 882
@@ -910,6 +929,11 @@ static void *f_start(struct seq_file *m, loff_t *pos)
910 void *p = (void *)FORMAT_HEADER; 929 void *p = (void *)FORMAT_HEADER;
911 loff_t l = 0; 930 loff_t l = 0;
912 931
932 /* ->stop() is called even if ->start() fails */
933 mutex_lock(&event_mutex);
934 if (!event_file_data(m->private))
935 return ERR_PTR(-ENODEV);
936
913 while (l < *pos && p) 937 while (l < *pos && p)
914 p = f_next(m, p, &l); 938 p = f_next(m, p, &l);
915 939
@@ -918,6 +942,7 @@ static void *f_start(struct seq_file *m, loff_t *pos)
918 942
919static void f_stop(struct seq_file *m, void *p) 943static void f_stop(struct seq_file *m, void *p)
920{ 944{
945 mutex_unlock(&event_mutex);
921} 946}
922 947
923static const struct seq_operations trace_format_seq_ops = { 948static const struct seq_operations trace_format_seq_ops = {
@@ -929,7 +954,6 @@ static const struct seq_operations trace_format_seq_ops = {
929 954
930static int trace_format_open(struct inode *inode, struct file *file) 955static int trace_format_open(struct inode *inode, struct file *file)
931{ 956{
932 struct ftrace_event_call *call = inode->i_private;
933 struct seq_file *m; 957 struct seq_file *m;
934 int ret; 958 int ret;
935 959
@@ -938,7 +962,7 @@ static int trace_format_open(struct inode *inode, struct file *file)
938 return ret; 962 return ret;
939 963
940 m = file->private_data; 964 m = file->private_data;
941 m->private = call; 965 m->private = file;
942 966
943 return 0; 967 return 0;
944} 968}
@@ -946,14 +970,18 @@ static int trace_format_open(struct inode *inode, struct file *file)
946static ssize_t 970static ssize_t
947event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos) 971event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
948{ 972{
949 struct ftrace_event_call *call = filp->private_data; 973 int id = (long)event_file_data(filp);
950 char buf[32]; 974 char buf[32];
951 int len; 975 int len;
952 976
953 if (*ppos) 977 if (*ppos)
954 return 0; 978 return 0;
955 979
956 len = sprintf(buf, "%d\n", call->event.type); 980 if (unlikely(!id))
981 return -ENODEV;
982
983 len = sprintf(buf, "%d\n", id);
984
957 return simple_read_from_buffer(ubuf, cnt, ppos, buf, len); 985 return simple_read_from_buffer(ubuf, cnt, ppos, buf, len);
958} 986}
959 987
@@ -961,21 +989,28 @@ static ssize_t
961event_filter_read(struct file *filp, char __user *ubuf, size_t cnt, 989event_filter_read(struct file *filp, char __user *ubuf, size_t cnt,
962 loff_t *ppos) 990 loff_t *ppos)
963{ 991{
964 struct ftrace_event_call *call = filp->private_data; 992 struct ftrace_event_call *call;
965 struct trace_seq *s; 993 struct trace_seq *s;
966 int r; 994 int r = -ENODEV;
967 995
968 if (*ppos) 996 if (*ppos)
969 return 0; 997 return 0;
970 998
971 s = kmalloc(sizeof(*s), GFP_KERNEL); 999 s = kmalloc(sizeof(*s), GFP_KERNEL);
1000
972 if (!s) 1001 if (!s)
973 return -ENOMEM; 1002 return -ENOMEM;
974 1003
975 trace_seq_init(s); 1004 trace_seq_init(s);
976 1005
977 print_event_filter(call, s); 1006 mutex_lock(&event_mutex);
978 r = simple_read_from_buffer(ubuf, cnt, ppos, s->buffer, s->len); 1007 call = event_file_data(filp);
1008 if (call)
1009 print_event_filter(call, s);
1010 mutex_unlock(&event_mutex);
1011
1012 if (call)
1013 r = simple_read_from_buffer(ubuf, cnt, ppos, s->buffer, s->len);
979 1014
980 kfree(s); 1015 kfree(s);
981 1016
@@ -986,9 +1021,9 @@ static ssize_t
986event_filter_write(struct file *filp, const char __user *ubuf, size_t cnt, 1021event_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
987 loff_t *ppos) 1022 loff_t *ppos)
988{ 1023{
989 struct ftrace_event_call *call = filp->private_data; 1024 struct ftrace_event_call *call;
990 char *buf; 1025 char *buf;
991 int err; 1026 int err = -ENODEV;
992 1027
993 if (cnt >= PAGE_SIZE) 1028 if (cnt >= PAGE_SIZE)
994 return -EINVAL; 1029 return -EINVAL;
@@ -1003,7 +1038,12 @@ event_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
1003 } 1038 }
1004 buf[cnt] = '\0'; 1039 buf[cnt] = '\0';
1005 1040
1006 err = apply_event_filter(call, buf); 1041 mutex_lock(&event_mutex);
1042 call = event_file_data(filp);
1043 if (call)
1044 err = apply_event_filter(call, buf);
1045 mutex_unlock(&event_mutex);
1046
1007 free_page((unsigned long) buf); 1047 free_page((unsigned long) buf);
1008 if (err < 0) 1048 if (err < 0)
1009 return err; 1049 return err;
@@ -1225,10 +1265,9 @@ static const struct file_operations ftrace_set_event_fops = {
1225}; 1265};
1226 1266
1227static const struct file_operations ftrace_enable_fops = { 1267static const struct file_operations ftrace_enable_fops = {
1228 .open = tracing_open_generic_file, 1268 .open = tracing_open_generic,
1229 .read = event_enable_read, 1269 .read = event_enable_read,
1230 .write = event_enable_write, 1270 .write = event_enable_write,
1231 .release = tracing_release_generic_file,
1232 .llseek = default_llseek, 1271 .llseek = default_llseek,
1233}; 1272};
1234 1273
@@ -1240,7 +1279,6 @@ static const struct file_operations ftrace_event_format_fops = {
1240}; 1279};
1241 1280
1242static const struct file_operations ftrace_event_id_fops = { 1281static const struct file_operations ftrace_event_id_fops = {
1243 .open = tracing_open_generic,
1244 .read = event_id_read, 1282 .read = event_id_read,
1245 .llseek = default_llseek, 1283 .llseek = default_llseek,
1246}; 1284};
@@ -1488,8 +1526,8 @@ event_create_dir(struct dentry *parent,
1488 1526
1489#ifdef CONFIG_PERF_EVENTS 1527#ifdef CONFIG_PERF_EVENTS
1490 if (call->event.type && call->class->reg) 1528 if (call->event.type && call->class->reg)
1491 trace_create_file("id", 0444, file->dir, call, 1529 trace_create_file("id", 0444, file->dir,
1492 id); 1530 (void *)(long)call->event.type, id);
1493#endif 1531#endif
1494 1532
1495 /* 1533 /*
@@ -1514,33 +1552,16 @@ event_create_dir(struct dentry *parent,
1514 return 0; 1552 return 0;
1515} 1553}
1516 1554
1517static void remove_subsystem(struct ftrace_subsystem_dir *dir)
1518{
1519 if (!dir)
1520 return;
1521
1522 if (!--dir->nr_events) {
1523 debugfs_remove_recursive(dir->entry);
1524 list_del(&dir->list);
1525 __put_system_dir(dir);
1526 }
1527}
1528
1529static void remove_event_from_tracers(struct ftrace_event_call *call) 1555static void remove_event_from_tracers(struct ftrace_event_call *call)
1530{ 1556{
1531 struct ftrace_event_file *file; 1557 struct ftrace_event_file *file;
1532 struct trace_array *tr; 1558 struct trace_array *tr;
1533 1559
1534 do_for_each_event_file_safe(tr, file) { 1560 do_for_each_event_file_safe(tr, file) {
1535
1536 if (file->event_call != call) 1561 if (file->event_call != call)
1537 continue; 1562 continue;
1538 1563
1539 list_del(&file->list); 1564 remove_event_file_dir(file);
1540 debugfs_remove_recursive(file->dir);
1541 remove_subsystem(file->system);
1542 kmem_cache_free(file_cachep, file);
1543
1544 /* 1565 /*
1545 * The do_for_each_event_file_safe() is 1566 * The do_for_each_event_file_safe() is
1546 * a double loop. After finding the call for this 1567 * a double loop. After finding the call for this
@@ -1692,16 +1713,53 @@ static void __trace_remove_event_call(struct ftrace_event_call *call)
1692 destroy_preds(call); 1713 destroy_preds(call);
1693} 1714}
1694 1715
1716static int probe_remove_event_call(struct ftrace_event_call *call)
1717{
1718 struct trace_array *tr;
1719 struct ftrace_event_file *file;
1720
1721#ifdef CONFIG_PERF_EVENTS
1722 if (call->perf_refcount)
1723 return -EBUSY;
1724#endif
1725 do_for_each_event_file(tr, file) {
1726 if (file->event_call != call)
1727 continue;
1728 /*
1729 * We can't rely on ftrace_event_enable_disable(enable => 0)
1730 * we are going to do, FTRACE_EVENT_FL_SOFT_MODE can suppress
1731 * TRACE_REG_UNREGISTER.
1732 */
1733 if (file->flags & FTRACE_EVENT_FL_ENABLED)
1734 return -EBUSY;
1735 /*
1736 * The do_for_each_event_file_safe() is
1737 * a double loop. After finding the call for this
1738 * trace_array, we use break to jump to the next
1739 * trace_array.
1740 */
1741 break;
1742 } while_for_each_event_file();
1743
1744 __trace_remove_event_call(call);
1745
1746 return 0;
1747}
1748
1695/* Remove an event_call */ 1749/* Remove an event_call */
1696void trace_remove_event_call(struct ftrace_event_call *call) 1750int trace_remove_event_call(struct ftrace_event_call *call)
1697{ 1751{
1752 int ret;
1753
1698 mutex_lock(&trace_types_lock); 1754 mutex_lock(&trace_types_lock);
1699 mutex_lock(&event_mutex); 1755 mutex_lock(&event_mutex);
1700 down_write(&trace_event_sem); 1756 down_write(&trace_event_sem);
1701 __trace_remove_event_call(call); 1757 ret = probe_remove_event_call(call);
1702 up_write(&trace_event_sem); 1758 up_write(&trace_event_sem);
1703 mutex_unlock(&event_mutex); 1759 mutex_unlock(&event_mutex);
1704 mutex_unlock(&trace_types_lock); 1760 mutex_unlock(&trace_types_lock);
1761
1762 return ret;
1705} 1763}
1706 1764
1707#define for_each_event(event, start, end) \ 1765#define for_each_event(event, start, end) \
@@ -2270,12 +2328,8 @@ __trace_remove_event_dirs(struct trace_array *tr)
2270{ 2328{
2271 struct ftrace_event_file *file, *next; 2329 struct ftrace_event_file *file, *next;
2272 2330
2273 list_for_each_entry_safe(file, next, &tr->events, list) { 2331 list_for_each_entry_safe(file, next, &tr->events, list)
2274 list_del(&file->list); 2332 remove_event_file_dir(file);
2275 debugfs_remove_recursive(file->dir);
2276 remove_subsystem(file->system);
2277 kmem_cache_free(file_cachep, file);
2278 }
2279} 2333}
2280 2334
2281static void 2335static void
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 0c7b75a8acc8..97daa8cf958d 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -637,17 +637,15 @@ static void append_filter_err(struct filter_parse_state *ps,
637 free_page((unsigned long) buf); 637 free_page((unsigned long) buf);
638} 638}
639 639
640/* caller must hold event_mutex */
640void print_event_filter(struct ftrace_event_call *call, struct trace_seq *s) 641void print_event_filter(struct ftrace_event_call *call, struct trace_seq *s)
641{ 642{
642 struct event_filter *filter; 643 struct event_filter *filter = call->filter;
643 644
644 mutex_lock(&event_mutex);
645 filter = call->filter;
646 if (filter && filter->filter_string) 645 if (filter && filter->filter_string)
647 trace_seq_printf(s, "%s\n", filter->filter_string); 646 trace_seq_printf(s, "%s\n", filter->filter_string);
648 else 647 else
649 trace_seq_puts(s, "none\n"); 648 trace_seq_puts(s, "none\n");
650 mutex_unlock(&event_mutex);
651} 649}
652 650
653void print_subsystem_event_filter(struct event_subsystem *system, 651void print_subsystem_event_filter(struct event_subsystem *system,
@@ -1841,23 +1839,22 @@ static int create_system_filter(struct event_subsystem *system,
1841 return err; 1839 return err;
1842} 1840}
1843 1841
1842/* caller must hold event_mutex */
1844int apply_event_filter(struct ftrace_event_call *call, char *filter_string) 1843int apply_event_filter(struct ftrace_event_call *call, char *filter_string)
1845{ 1844{
1846 struct event_filter *filter; 1845 struct event_filter *filter;
1847 int err = 0; 1846 int err;
1848
1849 mutex_lock(&event_mutex);
1850 1847
1851 if (!strcmp(strstrip(filter_string), "0")) { 1848 if (!strcmp(strstrip(filter_string), "0")) {
1852 filter_disable(call); 1849 filter_disable(call);
1853 filter = call->filter; 1850 filter = call->filter;
1854 if (!filter) 1851 if (!filter)
1855 goto out_unlock; 1852 return 0;
1856 RCU_INIT_POINTER(call->filter, NULL); 1853 RCU_INIT_POINTER(call->filter, NULL);
1857 /* Make sure the filter is not being used */ 1854 /* Make sure the filter is not being used */
1858 synchronize_sched(); 1855 synchronize_sched();
1859 __free_filter(filter); 1856 __free_filter(filter);
1860 goto out_unlock; 1857 return 0;
1861 } 1858 }
1862 1859
1863 err = create_filter(call, filter_string, true, &filter); 1860 err = create_filter(call, filter_string, true, &filter);
@@ -1884,8 +1881,6 @@ int apply_event_filter(struct ftrace_event_call *call, char *filter_string)
1884 __free_filter(tmp); 1881 __free_filter(tmp);
1885 } 1882 }
1886 } 1883 }
1887out_unlock:
1888 mutex_unlock(&event_mutex);
1889 1884
1890 return err; 1885 return err;
1891} 1886}
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 3811487e7a7a..243f6834d026 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -95,7 +95,7 @@ static __kprobes bool trace_probe_is_on_module(struct trace_probe *tp)
95} 95}
96 96
97static int register_probe_event(struct trace_probe *tp); 97static int register_probe_event(struct trace_probe *tp);
98static void unregister_probe_event(struct trace_probe *tp); 98static int unregister_probe_event(struct trace_probe *tp);
99 99
100static DEFINE_MUTEX(probe_lock); 100static DEFINE_MUTEX(probe_lock);
101static LIST_HEAD(probe_list); 101static LIST_HEAD(probe_list);
@@ -351,9 +351,12 @@ static int unregister_trace_probe(struct trace_probe *tp)
351 if (trace_probe_is_enabled(tp)) 351 if (trace_probe_is_enabled(tp))
352 return -EBUSY; 352 return -EBUSY;
353 353
354 /* Will fail if probe is being used by ftrace or perf */
355 if (unregister_probe_event(tp))
356 return -EBUSY;
357
354 __unregister_trace_probe(tp); 358 __unregister_trace_probe(tp);
355 list_del(&tp->list); 359 list_del(&tp->list);
356 unregister_probe_event(tp);
357 360
358 return 0; 361 return 0;
359} 362}
@@ -632,7 +635,9 @@ static int release_all_trace_probes(void)
632 /* TODO: Use batch unregistration */ 635 /* TODO: Use batch unregistration */
633 while (!list_empty(&probe_list)) { 636 while (!list_empty(&probe_list)) {
634 tp = list_entry(probe_list.next, struct trace_probe, list); 637 tp = list_entry(probe_list.next, struct trace_probe, list);
635 unregister_trace_probe(tp); 638 ret = unregister_trace_probe(tp);
639 if (ret)
640 goto end;
636 free_trace_probe(tp); 641 free_trace_probe(tp);
637 } 642 }
638 643
@@ -1247,11 +1252,15 @@ static int register_probe_event(struct trace_probe *tp)
1247 return ret; 1252 return ret;
1248} 1253}
1249 1254
1250static void unregister_probe_event(struct trace_probe *tp) 1255static int unregister_probe_event(struct trace_probe *tp)
1251{ 1256{
1257 int ret;
1258
1252 /* tp->event is unregistered in trace_remove_event_call() */ 1259 /* tp->event is unregistered in trace_remove_event_call() */
1253 trace_remove_event_call(&tp->call); 1260 ret = trace_remove_event_call(&tp->call);
1254 kfree(tp->call.print_fmt); 1261 if (!ret)
1262 kfree(tp->call.print_fmt);
1263 return ret;
1255} 1264}
1256 1265
1257/* Make a debugfs interface for controlling probe points */ 1266/* Make a debugfs interface for controlling probe points */
diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index a23d2d71188e..272261b5f94f 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -70,7 +70,7 @@ struct trace_uprobe {
70 (sizeof(struct probe_arg) * (n))) 70 (sizeof(struct probe_arg) * (n)))
71 71
72static int register_uprobe_event(struct trace_uprobe *tu); 72static int register_uprobe_event(struct trace_uprobe *tu);
73static void unregister_uprobe_event(struct trace_uprobe *tu); 73static int unregister_uprobe_event(struct trace_uprobe *tu);
74 74
75static DEFINE_MUTEX(uprobe_lock); 75static DEFINE_MUTEX(uprobe_lock);
76static LIST_HEAD(uprobe_list); 76static LIST_HEAD(uprobe_list);
@@ -164,11 +164,17 @@ static struct trace_uprobe *find_probe_event(const char *event, const char *grou
164} 164}
165 165
166/* Unregister a trace_uprobe and probe_event: call with locking uprobe_lock */ 166/* Unregister a trace_uprobe and probe_event: call with locking uprobe_lock */
167static void unregister_trace_uprobe(struct trace_uprobe *tu) 167static int unregister_trace_uprobe(struct trace_uprobe *tu)
168{ 168{
169 int ret;
170
171 ret = unregister_uprobe_event(tu);
172 if (ret)
173 return ret;
174
169 list_del(&tu->list); 175 list_del(&tu->list);
170 unregister_uprobe_event(tu);
171 free_trace_uprobe(tu); 176 free_trace_uprobe(tu);
177 return 0;
172} 178}
173 179
174/* Register a trace_uprobe and probe_event */ 180/* Register a trace_uprobe and probe_event */
@@ -181,9 +187,12 @@ static int register_trace_uprobe(struct trace_uprobe *tu)
181 187
182 /* register as an event */ 188 /* register as an event */
183 old_tp = find_probe_event(tu->call.name, tu->call.class->system); 189 old_tp = find_probe_event(tu->call.name, tu->call.class->system);
184 if (old_tp) 190 if (old_tp) {
185 /* delete old event */ 191 /* delete old event */
186 unregister_trace_uprobe(old_tp); 192 ret = unregister_trace_uprobe(old_tp);
193 if (ret)
194 goto end;
195 }
187 196
188 ret = register_uprobe_event(tu); 197 ret = register_uprobe_event(tu);
189 if (ret) { 198 if (ret) {
@@ -256,6 +265,8 @@ static int create_trace_uprobe(int argc, char **argv)
256 group = UPROBE_EVENT_SYSTEM; 265 group = UPROBE_EVENT_SYSTEM;
257 266
258 if (is_delete) { 267 if (is_delete) {
268 int ret;
269
259 if (!event) { 270 if (!event) {
260 pr_info("Delete command needs an event name.\n"); 271 pr_info("Delete command needs an event name.\n");
261 return -EINVAL; 272 return -EINVAL;
@@ -269,9 +280,9 @@ static int create_trace_uprobe(int argc, char **argv)
269 return -ENOENT; 280 return -ENOENT;
270 } 281 }
271 /* delete an event */ 282 /* delete an event */
272 unregister_trace_uprobe(tu); 283 ret = unregister_trace_uprobe(tu);
273 mutex_unlock(&uprobe_lock); 284 mutex_unlock(&uprobe_lock);
274 return 0; 285 return ret;
275 } 286 }
276 287
277 if (argc < 2) { 288 if (argc < 2) {
@@ -408,16 +419,20 @@ fail_address_parse:
408 return ret; 419 return ret;
409} 420}
410 421
411static void cleanup_all_probes(void) 422static int cleanup_all_probes(void)
412{ 423{
413 struct trace_uprobe *tu; 424 struct trace_uprobe *tu;
425 int ret = 0;
414 426
415 mutex_lock(&uprobe_lock); 427 mutex_lock(&uprobe_lock);
416 while (!list_empty(&uprobe_list)) { 428 while (!list_empty(&uprobe_list)) {
417 tu = list_entry(uprobe_list.next, struct trace_uprobe, list); 429 tu = list_entry(uprobe_list.next, struct trace_uprobe, list);
418 unregister_trace_uprobe(tu); 430 ret = unregister_trace_uprobe(tu);
431 if (ret)
432 break;
419 } 433 }
420 mutex_unlock(&uprobe_lock); 434 mutex_unlock(&uprobe_lock);
435 return ret;
421} 436}
422 437
423/* Probes listing interfaces */ 438/* Probes listing interfaces */
@@ -462,8 +477,13 @@ static const struct seq_operations probes_seq_op = {
462 477
463static int probes_open(struct inode *inode, struct file *file) 478static int probes_open(struct inode *inode, struct file *file)
464{ 479{
465 if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_TRUNC)) 480 int ret;
466 cleanup_all_probes(); 481
482 if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_TRUNC)) {
483 ret = cleanup_all_probes();
484 if (ret)
485 return ret;
486 }
467 487
468 return seq_open(file, &probes_seq_op); 488 return seq_open(file, &probes_seq_op);
469} 489}
@@ -968,12 +988,17 @@ static int register_uprobe_event(struct trace_uprobe *tu)
968 return ret; 988 return ret;
969} 989}
970 990
971static void unregister_uprobe_event(struct trace_uprobe *tu) 991static int unregister_uprobe_event(struct trace_uprobe *tu)
972{ 992{
993 int ret;
994
973 /* tu->event is unregistered in trace_remove_event_call() */ 995 /* tu->event is unregistered in trace_remove_event_call() */
974 trace_remove_event_call(&tu->call); 996 ret = trace_remove_event_call(&tu->call);
997 if (ret)
998 return ret;
975 kfree(tu->call.print_fmt); 999 kfree(tu->call.print_fmt);
976 tu->call.print_fmt = NULL; 1000 tu->call.print_fmt = NULL;
1001 return 0;
977} 1002}
978 1003
979/* Make a trace interface for controling probe points */ 1004/* Make a trace interface for controling probe points */
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index d8c30db06c5b..9064b919a406 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -62,6 +62,9 @@ int create_user_ns(struct cred *new)
62 kgid_t group = new->egid; 62 kgid_t group = new->egid;
63 int ret; 63 int ret;
64 64
65 if (parent_ns->level > 32)
66 return -EUSERS;
67
65 /* 68 /*
66 * Verify that we can not violate the policy of which files 69 * Verify that we can not violate the policy of which files
67 * may be accessed that is specified by the root directory, 70 * may be accessed that is specified by the root directory,
@@ -92,6 +95,7 @@ int create_user_ns(struct cred *new)
92 atomic_set(&ns->count, 1); 95 atomic_set(&ns->count, 1);
93 /* Leave the new->user_ns reference with the new user namespace. */ 96 /* Leave the new->user_ns reference with the new user namespace. */
94 ns->parent = parent_ns; 97 ns->parent = parent_ns;
98 ns->level = parent_ns->level + 1;
95 ns->owner = owner; 99 ns->owner = owner;
96 ns->group = group; 100 ns->group = group;
97 101
@@ -105,16 +109,21 @@ int create_user_ns(struct cred *new)
105int unshare_userns(unsigned long unshare_flags, struct cred **new_cred) 109int unshare_userns(unsigned long unshare_flags, struct cred **new_cred)
106{ 110{
107 struct cred *cred; 111 struct cred *cred;
112 int err = -ENOMEM;
108 113
109 if (!(unshare_flags & CLONE_NEWUSER)) 114 if (!(unshare_flags & CLONE_NEWUSER))
110 return 0; 115 return 0;
111 116
112 cred = prepare_creds(); 117 cred = prepare_creds();
113 if (!cred) 118 if (cred) {
114 return -ENOMEM; 119 err = create_user_ns(cred);
120 if (err)
121 put_cred(cred);
122 else
123 *new_cred = cred;
124 }
115 125
116 *new_cred = cred; 126 return err;
117 return create_user_ns(cred);
118} 127}
119 128
120void free_user_ns(struct user_namespace *ns) 129void free_user_ns(struct user_namespace *ns)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 0b72e816b8d0..7f5d4be22034 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2817,6 +2817,19 @@ already_gone:
2817 return false; 2817 return false;
2818} 2818}
2819 2819
2820static bool __flush_work(struct work_struct *work)
2821{
2822 struct wq_barrier barr;
2823
2824 if (start_flush_work(work, &barr)) {
2825 wait_for_completion(&barr.done);
2826 destroy_work_on_stack(&barr.work);
2827 return true;
2828 } else {
2829 return false;
2830 }
2831}
2832
2820/** 2833/**
2821 * flush_work - wait for a work to finish executing the last queueing instance 2834 * flush_work - wait for a work to finish executing the last queueing instance
2822 * @work: the work to flush 2835 * @work: the work to flush
@@ -2830,18 +2843,10 @@ already_gone:
2830 */ 2843 */
2831bool flush_work(struct work_struct *work) 2844bool flush_work(struct work_struct *work)
2832{ 2845{
2833 struct wq_barrier barr;
2834
2835 lock_map_acquire(&work->lockdep_map); 2846 lock_map_acquire(&work->lockdep_map);
2836 lock_map_release(&work->lockdep_map); 2847 lock_map_release(&work->lockdep_map);
2837 2848
2838 if (start_flush_work(work, &barr)) { 2849 return __flush_work(work);
2839 wait_for_completion(&barr.done);
2840 destroy_work_on_stack(&barr.work);
2841 return true;
2842 } else {
2843 return false;
2844 }
2845} 2850}
2846EXPORT_SYMBOL_GPL(flush_work); 2851EXPORT_SYMBOL_GPL(flush_work);
2847 2852
@@ -3411,6 +3416,12 @@ static void copy_workqueue_attrs(struct workqueue_attrs *to,
3411{ 3416{
3412 to->nice = from->nice; 3417 to->nice = from->nice;
3413 cpumask_copy(to->cpumask, from->cpumask); 3418 cpumask_copy(to->cpumask, from->cpumask);
3419 /*
3420 * Unlike hash and equality test, this function doesn't ignore
3421 * ->no_numa as it is used for both pool and wq attrs. Instead,
3422 * get_unbound_pool() explicitly clears ->no_numa after copying.
3423 */
3424 to->no_numa = from->no_numa;
3414} 3425}
3415 3426
3416/* hash value of the content of @attr */ 3427/* hash value of the content of @attr */
@@ -3578,6 +3589,12 @@ static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs)
3578 lockdep_set_subclass(&pool->lock, 1); /* see put_pwq() */ 3589 lockdep_set_subclass(&pool->lock, 1); /* see put_pwq() */
3579 copy_workqueue_attrs(pool->attrs, attrs); 3590 copy_workqueue_attrs(pool->attrs, attrs);
3580 3591
3592 /*
3593 * no_numa isn't a worker_pool attribute, always clear it. See
3594 * 'struct workqueue_attrs' comments for detail.
3595 */
3596 pool->attrs->no_numa = false;
3597
3581 /* if cpumask is contained inside a NUMA node, we belong to that node */ 3598 /* if cpumask is contained inside a NUMA node, we belong to that node */
3582 if (wq_numa_enabled) { 3599 if (wq_numa_enabled) {
3583 for_each_node(node) { 3600 for_each_node(node) {
@@ -4756,7 +4773,14 @@ long work_on_cpu(int cpu, long (*fn)(void *), void *arg)
4756 4773
4757 INIT_WORK_ONSTACK(&wfc.work, work_for_cpu_fn); 4774 INIT_WORK_ONSTACK(&wfc.work, work_for_cpu_fn);
4758 schedule_work_on(cpu, &wfc.work); 4775 schedule_work_on(cpu, &wfc.work);
4759 flush_work(&wfc.work); 4776
4777 /*
4778 * The work item is on-stack and can't lead to deadlock through
4779 * flushing. Use __flush_work() to avoid spurious lockdep warnings
4780 * when work_on_cpu()s are nested.
4781 */
4782 __flush_work(&wfc.work);
4783
4760 return wfc.ret; 4784 return wfc.ret;
4761} 4785}
4762EXPORT_SYMBOL_GPL(work_on_cpu); 4786EXPORT_SYMBOL_GPL(work_on_cpu);
diff --git a/mm/slub.c b/mm/slub.c
index 2b02d666bf63..e3ba1f2cf60c 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1968,9 +1968,6 @@ static void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain)
1968 int pages; 1968 int pages;
1969 int pobjects; 1969 int pobjects;
1970 1970
1971 if (!s->cpu_partial)
1972 return;
1973
1974 do { 1971 do {
1975 pages = 0; 1972 pages = 0;
1976 pobjects = 0; 1973 pobjects = 0;
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 3f7682a387b7..eefbd10e408f 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -1998,12 +1998,11 @@ static void smk_ipv6_port_label(struct socket *sock, struct sockaddr *address)
1998 * 1998 *
1999 * Create or update the port list entry 1999 * Create or update the port list entry
2000 */ 2000 */
2001static int smk_ipv6_port_check(struct sock *sk, struct sockaddr *address, 2001static int smk_ipv6_port_check(struct sock *sk, struct sockaddr_in6 *address,
2002 int act) 2002 int act)
2003{ 2003{
2004 __be16 *bep; 2004 __be16 *bep;
2005 __be32 *be32p; 2005 __be32 *be32p;
2006 struct sockaddr_in6 *addr6;
2007 struct smk_port_label *spp; 2006 struct smk_port_label *spp;
2008 struct socket_smack *ssp = sk->sk_security; 2007 struct socket_smack *ssp = sk->sk_security;
2009 struct smack_known *skp; 2008 struct smack_known *skp;
@@ -2025,10 +2024,9 @@ static int smk_ipv6_port_check(struct sock *sk, struct sockaddr *address,
2025 /* 2024 /*
2026 * Get the IP address and port from the address. 2025 * Get the IP address and port from the address.
2027 */ 2026 */
2028 addr6 = (struct sockaddr_in6 *)address; 2027 port = ntohs(address->sin6_port);
2029 port = ntohs(addr6->sin6_port); 2028 bep = (__be16 *)(&address->sin6_addr);
2030 bep = (__be16 *)(&addr6->sin6_addr); 2029 be32p = (__be32 *)(&address->sin6_addr);
2031 be32p = (__be32 *)(&addr6->sin6_addr);
2032 2030
2033 /* 2031 /*
2034 * It's remote, so port lookup does no good. 2032 * It's remote, so port lookup does no good.
@@ -2060,9 +2058,9 @@ auditout:
2060 ad.a.u.net->family = sk->sk_family; 2058 ad.a.u.net->family = sk->sk_family;
2061 ad.a.u.net->dport = port; 2059 ad.a.u.net->dport = port;
2062 if (act == SMK_RECEIVING) 2060 if (act == SMK_RECEIVING)
2063 ad.a.u.net->v6info.saddr = addr6->sin6_addr; 2061 ad.a.u.net->v6info.saddr = address->sin6_addr;
2064 else 2062 else
2065 ad.a.u.net->v6info.daddr = addr6->sin6_addr; 2063 ad.a.u.net->v6info.daddr = address->sin6_addr;
2066#endif 2064#endif
2067 return smk_access(skp, object, MAY_WRITE, &ad); 2065 return smk_access(skp, object, MAY_WRITE, &ad);
2068} 2066}
@@ -2201,7 +2199,8 @@ static int smack_socket_connect(struct socket *sock, struct sockaddr *sap,
2201 case PF_INET6: 2199 case PF_INET6:
2202 if (addrlen < sizeof(struct sockaddr_in6)) 2200 if (addrlen < sizeof(struct sockaddr_in6))
2203 return -EINVAL; 2201 return -EINVAL;
2204 rc = smk_ipv6_port_check(sock->sk, sap, SMK_CONNECTING); 2202 rc = smk_ipv6_port_check(sock->sk, (struct sockaddr_in6 *)sap,
2203 SMK_CONNECTING);
2205 break; 2204 break;
2206 } 2205 }
2207 return rc; 2206 return rc;
@@ -3034,7 +3033,7 @@ static int smack_socket_sendmsg(struct socket *sock, struct msghdr *msg,
3034 int size) 3033 int size)
3035{ 3034{
3036 struct sockaddr_in *sip = (struct sockaddr_in *) msg->msg_name; 3035 struct sockaddr_in *sip = (struct sockaddr_in *) msg->msg_name;
3037 struct sockaddr *sap = (struct sockaddr *) msg->msg_name; 3036 struct sockaddr_in6 *sap = (struct sockaddr_in6 *) msg->msg_name;
3038 int rc = 0; 3037 int rc = 0;
3039 3038
3040 /* 3039 /*
@@ -3121,9 +3120,8 @@ static struct smack_known *smack_from_secattr(struct netlbl_lsm_secattr *sap,
3121 return smack_net_ambient; 3120 return smack_net_ambient;
3122} 3121}
3123 3122
3124static int smk_skb_to_addr_ipv6(struct sk_buff *skb, struct sockaddr *sap) 3123static int smk_skb_to_addr_ipv6(struct sk_buff *skb, struct sockaddr_in6 *sip)
3125{ 3124{
3126 struct sockaddr_in6 *sip = (struct sockaddr_in6 *)sap;
3127 u8 nexthdr; 3125 u8 nexthdr;
3128 int offset; 3126 int offset;
3129 int proto = -EINVAL; 3127 int proto = -EINVAL;
@@ -3181,7 +3179,7 @@ static int smack_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb)
3181 struct netlbl_lsm_secattr secattr; 3179 struct netlbl_lsm_secattr secattr;
3182 struct socket_smack *ssp = sk->sk_security; 3180 struct socket_smack *ssp = sk->sk_security;
3183 struct smack_known *skp; 3181 struct smack_known *skp;
3184 struct sockaddr sadd; 3182 struct sockaddr_in6 sadd;
3185 int rc = 0; 3183 int rc = 0;
3186 struct smk_audit_info ad; 3184 struct smk_audit_info ad;
3187#ifdef CONFIG_AUDIT 3185#ifdef CONFIG_AUDIT
diff --git a/sound/usb/6fire/comm.c b/sound/usb/6fire/comm.c
index 9e6e3ffd86bb..23452ee617e1 100644
--- a/sound/usb/6fire/comm.c
+++ b/sound/usb/6fire/comm.c
@@ -110,19 +110,37 @@ static int usb6fire_comm_send_buffer(u8 *buffer, struct usb_device *dev)
110static int usb6fire_comm_write8(struct comm_runtime *rt, u8 request, 110static int usb6fire_comm_write8(struct comm_runtime *rt, u8 request,
111 u8 reg, u8 value) 111 u8 reg, u8 value)
112{ 112{
113 u8 buffer[13]; /* 13: maximum length of message */ 113 u8 *buffer;
114 int ret;
115
116 /* 13: maximum length of message */
117 buffer = kmalloc(13, GFP_KERNEL);
118 if (!buffer)
119 return -ENOMEM;
114 120
115 usb6fire_comm_init_buffer(buffer, 0x00, request, reg, value, 0x00); 121 usb6fire_comm_init_buffer(buffer, 0x00, request, reg, value, 0x00);
116 return usb6fire_comm_send_buffer(buffer, rt->chip->dev); 122 ret = usb6fire_comm_send_buffer(buffer, rt->chip->dev);
123
124 kfree(buffer);
125 return ret;
117} 126}
118 127
119static int usb6fire_comm_write16(struct comm_runtime *rt, u8 request, 128static int usb6fire_comm_write16(struct comm_runtime *rt, u8 request,
120 u8 reg, u8 vl, u8 vh) 129 u8 reg, u8 vl, u8 vh)
121{ 130{
122 u8 buffer[13]; /* 13: maximum length of message */ 131 u8 *buffer;
132 int ret;
133
134 /* 13: maximum length of message */
135 buffer = kmalloc(13, GFP_KERNEL);
136 if (!buffer)
137 return -ENOMEM;
123 138
124 usb6fire_comm_init_buffer(buffer, 0x00, request, reg, vl, vh); 139 usb6fire_comm_init_buffer(buffer, 0x00, request, reg, vl, vh);
125 return usb6fire_comm_send_buffer(buffer, rt->chip->dev); 140 ret = usb6fire_comm_send_buffer(buffer, rt->chip->dev);
141
142 kfree(buffer);
143 return ret;
126} 144}
127 145
128int usb6fire_comm_init(struct sfire_chip *chip) 146int usb6fire_comm_init(struct sfire_chip *chip)
@@ -135,6 +153,12 @@ int usb6fire_comm_init(struct sfire_chip *chip)
135 if (!rt) 153 if (!rt)
136 return -ENOMEM; 154 return -ENOMEM;
137 155
156 rt->receiver_buffer = kzalloc(COMM_RECEIVER_BUFSIZE, GFP_KERNEL);
157 if (!rt->receiver_buffer) {
158 kfree(rt);
159 return -ENOMEM;
160 }
161
138 urb = &rt->receiver; 162 urb = &rt->receiver;
139 rt->serial = 1; 163 rt->serial = 1;
140 rt->chip = chip; 164 rt->chip = chip;
@@ -153,6 +177,7 @@ int usb6fire_comm_init(struct sfire_chip *chip)
153 urb->interval = 1; 177 urb->interval = 1;
154 ret = usb_submit_urb(urb, GFP_KERNEL); 178 ret = usb_submit_urb(urb, GFP_KERNEL);
155 if (ret < 0) { 179 if (ret < 0) {
180 kfree(rt->receiver_buffer);
156 kfree(rt); 181 kfree(rt);
157 snd_printk(KERN_ERR PREFIX "cannot create comm data receiver."); 182 snd_printk(KERN_ERR PREFIX "cannot create comm data receiver.");
158 return ret; 183 return ret;
@@ -171,6 +196,9 @@ void usb6fire_comm_abort(struct sfire_chip *chip)
171 196
172void usb6fire_comm_destroy(struct sfire_chip *chip) 197void usb6fire_comm_destroy(struct sfire_chip *chip)
173{ 198{
174 kfree(chip->comm); 199 struct comm_runtime *rt = chip->comm;
200
201 kfree(rt->receiver_buffer);
202 kfree(rt);
175 chip->comm = NULL; 203 chip->comm = NULL;
176} 204}
diff --git a/sound/usb/6fire/comm.h b/sound/usb/6fire/comm.h
index 6a0840b0dcff..780d5ed8e5d8 100644
--- a/sound/usb/6fire/comm.h
+++ b/sound/usb/6fire/comm.h
@@ -24,7 +24,7 @@ struct comm_runtime {
24 struct sfire_chip *chip; 24 struct sfire_chip *chip;
25 25
26 struct urb receiver; 26 struct urb receiver;
27 u8 receiver_buffer[COMM_RECEIVER_BUFSIZE]; 27 u8 *receiver_buffer;
28 28
29 u8 serial; /* urb serial */ 29 u8 serial; /* urb serial */
30 30
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index 7a444b5501d9..659950e5b94f 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -591,17 +591,16 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep,
591 ep->stride = frame_bits >> 3; 591 ep->stride = frame_bits >> 3;
592 ep->silence_value = pcm_format == SNDRV_PCM_FORMAT_U8 ? 0x80 : 0; 592 ep->silence_value = pcm_format == SNDRV_PCM_FORMAT_U8 ? 0x80 : 0;
593 593
594 /* calculate max. frequency */ 594 /* assume max. frequency is 25% higher than nominal */
595 if (ep->maxpacksize) { 595 ep->freqmax = ep->freqn + (ep->freqn >> 2);
596 maxsize = ((ep->freqmax + 0xffff) * (frame_bits >> 3))
597 >> (16 - ep->datainterval);
598 /* but wMaxPacketSize might reduce this */
599 if (ep->maxpacksize && ep->maxpacksize < maxsize) {
596 /* whatever fits into a max. size packet */ 600 /* whatever fits into a max. size packet */
597 maxsize = ep->maxpacksize; 601 maxsize = ep->maxpacksize;
598 ep->freqmax = (maxsize / (frame_bits >> 3)) 602 ep->freqmax = (maxsize / (frame_bits >> 3))
599 << (16 - ep->datainterval); 603 << (16 - ep->datainterval);
600 } else {
601 /* no max. packet size: just take 25% higher than nominal */
602 ep->freqmax = ep->freqn + (ep->freqn >> 2);
603 maxsize = ((ep->freqmax + 0xffff) * (frame_bits >> 3))
604 >> (16 - ep->datainterval);
605 } 604 }
606 605
607 if (ep->fill_max) 606 if (ep->fill_max)