aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2014-05-21 20:38:22 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2014-05-21 20:38:22 -0400
commit94aca80897501f994c795cffc458ecd0404377c7 (patch)
tree312f96755c4e7ab4c50766aea35c9e7aa2ebe015
parent03c1b4e8e560455a2634a76998883a22f1a01207 (diff)
parent368b69a5b010cb00fc9ea04d588cff69af1a1359 (diff)
Merge remote-tracking branch 'origin/x86/urgent' into x86/vdso
Resolved Conflicts: arch/x86/vdso/vdso32-setup.c Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--Documentation/ABI/testing/sysfs-bus-pci2
-rw-r--r--Documentation/devicetree/bindings/clock/renesas,cpg-mstp-clocks.txt2
-rw-r--r--MAINTAINERS9
-rw-r--r--Makefile2
-rw-r--r--arch/arm/boot/dts/imx53-mba53.dts2
-rw-r--r--arch/arm/boot/dts/ste-ccu8540.dts1
-rw-r--r--arch/arm64/kernel/irq.c10
-rw-r--r--arch/arm64/mm/hugetlbpage.c4
-rw-r--r--arch/ia64/include/asm/unistd.h2
-rw-r--r--arch/ia64/include/uapi/asm/unistd.h1
-rw-r--r--arch/ia64/kernel/entry.S1
-rw-r--r--arch/m68k/include/asm/unistd.h2
-rw-r--r--arch/m68k/include/uapi/asm/unistd.h1
-rw-r--r--arch/m68k/kernel/syscalltable.S1
-rw-r--r--arch/metag/include/asm/barrier.h3
-rw-r--r--arch/metag/include/asm/processor.h2
-rw-r--r--arch/metag/include/uapi/asm/Kbuild2
-rw-r--r--arch/metag/include/uapi/asm/resource.h7
-rw-r--r--arch/mips/dec/ecc-berr.c1
-rw-r--r--arch/mips/dec/kn02xa-berr.c1
-rw-r--r--arch/mips/dec/prom/Makefile1
-rw-r--r--arch/mips/dec/prom/call_o32.S89
-rw-r--r--arch/mips/fw/lib/call_o32.S57
-rw-r--r--arch/mips/fw/sni/sniprom.c3
-rw-r--r--arch/mips/include/asm/dec/prom.h48
-rw-r--r--arch/mips/include/asm/rm9k-ocd.h56
-rw-r--r--arch/mips/include/asm/syscall.h2
-rw-r--r--arch/mips/include/uapi/asm/inst.h398
-rw-r--r--arch/mips/include/uapi/asm/unistd.h9
-rw-r--r--arch/mips/kernel/proc.c9
-rw-r--r--arch/mips/kernel/scall32-o32.S1
-rw-r--r--arch/mips/kernel/scall64-64.S1
-rw-r--r--arch/mips/kernel/scall64-n32.S1
-rw-r--r--arch/mips/kernel/scall64-o32.S1
-rw-r--r--arch/mips/lantiq/dts/easy50712.dts1
-rw-r--r--arch/mips/lib/csum_partial.S9
-rw-r--r--arch/mips/lib/delay.c14
-rw-r--r--arch/mips/lib/strncpy_user.S13
-rw-r--r--arch/mips/loongson/Kconfig1
-rw-r--r--arch/mips/loongson/lemote-2f/clock.c5
-rw-r--r--arch/mips/mm/tlb-funcs.S4
-rw-r--r--arch/mips/mm/tlbex.c7
-rw-r--r--arch/mips/ralink/dts/mt7620a_eval.dts1
-rw-r--r--arch/mips/ralink/dts/rt2880_eval.dts1
-rw-r--r--arch/mips/ralink/dts/rt3052_eval.dts1
-rw-r--r--arch/mips/ralink/dts/rt3883_eval.dts1
-rw-r--r--arch/parisc/Kconfig1
-rw-r--r--arch/parisc/include/asm/processor.h5
-rw-r--r--arch/parisc/include/uapi/asm/unistd.h3
-rw-r--r--arch/parisc/kernel/sys_parisc.c6
-rw-r--r--arch/parisc/kernel/syscall.S12
-rw-r--r--arch/parisc/kernel/syscall_table.S1
-rw-r--r--arch/parisc/kernel/traps.c54
-rw-r--r--arch/parisc/mm/fault.c44
-rw-r--r--arch/powerpc/kernel/time.c3
-rw-r--r--arch/powerpc/platforms/powernv/eeh-ioda.c3
-rw-r--r--arch/s390/crypto/aes_s390.c3
-rw-r--r--arch/s390/crypto/des_s390.c3
-rw-r--r--drivers/Makefile2
-rw-r--r--drivers/acpi/Kconfig17
-rw-r--r--drivers/acpi/Makefile1
-rw-r--r--drivers/acpi/ac.c117
-rw-r--r--drivers/acpi/acpi_platform.c1
-rw-r--r--drivers/acpi/acpi_processor.c1
-rw-r--r--drivers/acpi/acpica/acglobal.h4
-rw-r--r--drivers/acpi/acpica/tbutils.c7
-rw-r--r--drivers/acpi/battery.c329
-rw-r--r--drivers/acpi/blacklist.c21
-rw-r--r--drivers/acpi/cm_sbs.c105
-rw-r--r--drivers/acpi/video.c16
-rw-r--r--drivers/ata/Kconfig2
-rw-r--r--drivers/ata/ahci.c15
-rw-r--r--drivers/ata/ahci.h1
-rw-r--r--drivers/ata/ahci_imx.c179
-rw-r--r--drivers/ata/libahci.c7
-rw-r--r--drivers/ata/libata-core.c9
-rw-r--r--drivers/char/random.c7
-rw-r--r--drivers/char/tpm/tpm_ppi.c8
-rw-r--r--drivers/clk/bcm/clk-kona-setup.c33
-rw-r--r--drivers/clk/bcm/clk-kona.c64
-rw-r--r--drivers/clk/bcm/clk-kona.h28
-rw-r--r--drivers/clk/clk-divider.c37
-rw-r--r--drivers/clk/clk.c74
-rw-r--r--drivers/clk/shmobile/clk-mstp.c9
-rw-r--r--drivers/clk/socfpga/clk-pll.c7
-rw-r--r--drivers/clk/socfpga/clk.c23
-rw-r--r--drivers/clk/tegra/clk-pll.c2
-rw-r--r--drivers/cpufreq/intel_pstate.c34
-rw-r--r--drivers/cpufreq/loongson2_cpufreq.c4
-rw-r--r--drivers/crypto/caam/error.c10
-rw-r--r--drivers/firmware/iscsi_ibft.c1
-rw-r--r--drivers/gpio/gpio-ich.c4
-rw-r--r--drivers/gpio/gpio-mcp23s08.c12
-rw-r--r--drivers/gpu/drm/i915/intel_bios.c52
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c55
-rw-r--r--drivers/gpu/drm/i915/intel_fbdev.c9
-rw-r--r--drivers/gpu/drm/i915/intel_panel.c8
-rw-r--r--drivers/gpu/drm/i915/intel_pm.c40
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c4
-rw-r--r--drivers/gpu/drm/i915/intel_uncore.c2
-rw-r--r--drivers/i2c/busses/i2c-designware-core.c3
-rw-r--r--drivers/i2c/busses/i2c-nomadik.c2
-rw-r--r--drivers/i2c/busses/i2c-qup.c2
-rw-r--r--drivers/i2c/busses/i2c-rcar.c9
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c2
-rw-r--r--drivers/infiniband/ulp/isert/ib_isert.c38
-rw-r--r--drivers/infiniband/ulp/isert/ib_isert.h2
-rw-r--r--drivers/iommu/amd_iommu.c2
-rw-r--r--drivers/iommu/amd_iommu_init.c2
-rw-r--r--drivers/iommu/amd_iommu_v2.c2
-rw-r--r--drivers/md/dm-crypt.c61
-rw-r--r--drivers/md/dm-mpath.c2
-rw-r--r--drivers/md/dm-thin.c23
-rw-r--r--drivers/media/i2c/ov7670.c2
-rw-r--r--drivers/media/i2c/s5c73m3/s5c73m3-core.c2
-rw-r--r--drivers/media/media-device.c1
-rw-r--r--drivers/media/platform/davinci/vpbe_display.c16
-rw-r--r--drivers/media/platform/davinci/vpfe_capture.c2
-rw-r--r--drivers/media/platform/davinci/vpif_capture.c34
-rw-r--r--drivers/media/platform/davinci/vpif_display.c35
-rw-r--r--drivers/media/platform/exynos4-is/fimc-core.c2
-rw-r--r--drivers/media/tuners/fc2580.c6
-rw-r--r--drivers/media/tuners/fc2580_priv.h1
-rw-r--r--drivers/media/usb/dvb-usb-v2/Makefile1
-rw-r--r--drivers/media/usb/dvb-usb-v2/rtl28xxu.c48
-rw-r--r--drivers/media/usb/gspca/sonixb.c2
-rw-r--r--drivers/media/v4l2-core/v4l2-compat-ioctl32.c12
-rw-r--r--drivers/of/base.c4
-rw-r--r--drivers/pci/hotplug/shpchp_ctrl.c4
-rw-r--r--drivers/pci/pci.c5
-rw-r--r--drivers/sh/Makefile14
-rw-r--r--drivers/sh/pm_runtime.c20
-rw-r--r--drivers/spi/spi-pxa2xx-dma.c16
-rw-r--r--drivers/spi/spi-qup.c2
-rw-r--r--drivers/spi/spi.c124
-rw-r--r--drivers/staging/imx-drm/imx-drm-core.c7
-rw-r--r--drivers/staging/imx-drm/imx-tve.c2
-rw-r--r--drivers/staging/media/davinci_vpfe/vpfe_video.c13
-rw-r--r--drivers/staging/media/sn9c102/sn9c102_devtable.h2
-rw-r--r--drivers/staging/rtl8723au/os_dep/os_intfs.c2
-rw-r--r--drivers/staging/rtl8723au/os_dep/usb_ops_linux.c2
-rw-r--r--drivers/target/iscsi/iscsi_target.c4
-rw-r--r--drivers/target/iscsi/iscsi_target_core.h1
-rw-r--r--drivers/target/iscsi/iscsi_target_login.c28
-rw-r--r--drivers/target/iscsi/iscsi_target_tpg.c1
-rw-r--r--drivers/target/target_core_device.c12
-rw-r--r--drivers/target/target_core_transport.c2
-rw-r--r--drivers/target/tcm_fc/tfc_cmd.c8
-rw-r--r--fs/btrfs/ioctl.c6
-rw-r--r--fs/btrfs/send.c2
-rw-r--r--fs/exec.c6
-rw-r--r--fs/kernfs/file.c17
-rw-r--r--fs/sysfs/file.c3
-rw-r--r--fs/sysfs/mount.c3
-rw-r--r--fs/xfs/xfs_export.c2
-rw-r--r--fs/xfs/xfs_file.c8
-rw-r--r--fs/xfs/xfs_iops.c12
-rw-r--r--fs/xfs/xfs_qm.c26
-rw-r--r--fs/xfs/xfs_super.c4
-rw-r--r--include/asm-generic/resource.h2
-rw-r--r--include/linux/cgroup.h15
-rw-r--r--include/linux/kernfs.h19
-rw-r--r--include/linux/of.h2
-rw-r--r--include/uapi/asm-generic/resource.h7
-rw-r--r--include/uapi/asm-generic/unistd.h4
-rw-r--r--include/uapi/linux/audit.h12
-rw-r--r--kernel/cgroup.c2
-rw-r--r--kernel/cgroup_freezer.c116
-rw-r--r--mm/Kconfig15
-rw-r--r--net/ceph/messenger.c20
-rw-r--r--net/ceph/osdmap.c5
-rwxr-xr-xscripts/checksyscalls.sh5
-rw-r--r--sound/isa/sb/sb_mixer.c14
-rw-r--r--sound/pci/hda/hda_intel.c6
-rw-r--r--sound/pci/hda/patch_hdmi.c2
-rw-r--r--sound/pci/hda/patch_realtek.c3
-rw-r--r--sound/soc/codecs/tlv320aic31xx.c2
-rw-r--r--sound/soc/codecs/wm8962.c15
-rw-r--r--sound/soc/codecs/wm8962.h4
-rw-r--r--sound/soc/fsl/fsl_esai.c22
-rw-r--r--sound/soc/fsl/imx-audmux.c2
-rw-r--r--sound/soc/intel/sst-acpi.c1
-rw-r--r--sound/soc/intel/sst-baytrail-dsp.c2
-rw-r--r--sound/soc/intel/sst-baytrail-ipc.c8
-rw-r--r--sound/soc/intel/sst-dsp-priv.h1
-rw-r--r--sound/soc/intel/sst-dsp.c1
-rw-r--r--sound/soc/intel/sst-dsp.h1
-rw-r--r--sound/soc/intel/sst-firmware.c25
-rw-r--r--sound/soc/intel/sst-haswell-dsp.c4
-rw-r--r--sound/soc/intel/sst-haswell-ipc.c31
-rw-r--r--sound/soc/intel/sst-haswell-ipc.h4
-rw-r--r--sound/soc/intel/sst-haswell-pcm.c107
-rw-r--r--sound/soc/sh/rcar/core.c5
-rw-r--r--sound/soc/soc-dapm.c14
-rw-r--r--sound/soc/soc-pcm.c2
195 files changed, 2274 insertions, 1191 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-pci b/Documentation/ABI/testing/sysfs-bus-pci
index a3c5a6685036..ab8d76dfaa80 100644
--- a/Documentation/ABI/testing/sysfs-bus-pci
+++ b/Documentation/ABI/testing/sysfs-bus-pci
@@ -117,7 +117,7 @@ Description:
117 117
118What: /sys/bus/pci/devices/.../vpd 118What: /sys/bus/pci/devices/.../vpd
119Date: February 2008 119Date: February 2008
120Contact: Ben Hutchings <bhutchings@solarflare.com> 120Contact: Ben Hutchings <bwh@kernel.org>
121Description: 121Description:
122 A file named vpd in a device directory will be a 122 A file named vpd in a device directory will be a
123 binary file containing the Vital Product Data for the 123 binary file containing the Vital Product Data for the
diff --git a/Documentation/devicetree/bindings/clock/renesas,cpg-mstp-clocks.txt b/Documentation/devicetree/bindings/clock/renesas,cpg-mstp-clocks.txt
index 5992dceec7af..02a25d99ca61 100644
--- a/Documentation/devicetree/bindings/clock/renesas,cpg-mstp-clocks.txt
+++ b/Documentation/devicetree/bindings/clock/renesas,cpg-mstp-clocks.txt
@@ -43,7 +43,7 @@ Example
43 clock-output-names = 43 clock-output-names =
44 "tpu0", "mmcif1", "sdhi3", "sdhi2", 44 "tpu0", "mmcif1", "sdhi3", "sdhi2",
45 "sdhi1", "sdhi0", "mmcif0"; 45 "sdhi1", "sdhi0", "mmcif0";
46 renesas,clock-indices = < 46 clock-indices = <
47 R8A7790_CLK_TPU0 R8A7790_CLK_MMCIF1 R8A7790_CLK_SDHI3 47 R8A7790_CLK_TPU0 R8A7790_CLK_MMCIF1 R8A7790_CLK_SDHI3
48 R8A7790_CLK_SDHI2 R8A7790_CLK_SDHI1 R8A7790_CLK_SDHI0 48 R8A7790_CLK_SDHI2 R8A7790_CLK_SDHI1 R8A7790_CLK_SDHI0
49 R8A7790_CLK_MMCIF0 49 R8A7790_CLK_MMCIF0
diff --git a/MAINTAINERS b/MAINTAINERS
index fa1b13996bd3..6846c7c622e3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2246,12 +2246,6 @@ L: linux-usb@vger.kernel.org
2246S: Maintained 2246S: Maintained
2247F: drivers/usb/host/ohci-ep93xx.c 2247F: drivers/usb/host/ohci-ep93xx.c
2248 2248
2249CIRRUS LOGIC CS4270 SOUND DRIVER
2250M: Timur Tabi <timur@tabi.org>
2251L: alsa-devel@alsa-project.org (moderated for non-subscribers)
2252S: Odd Fixes
2253F: sound/soc/codecs/cs4270*
2254
2255CIRRUS LOGIC AUDIO CODEC DRIVERS 2249CIRRUS LOGIC AUDIO CODEC DRIVERS
2256M: Brian Austin <brian.austin@cirrus.com> 2250M: Brian Austin <brian.austin@cirrus.com>
2257M: Paul Handrigan <Paul.Handrigan@cirrus.com> 2251M: Paul Handrigan <Paul.Handrigan@cirrus.com>
@@ -9116,6 +9110,9 @@ F: arch/um/os-Linux/drivers/
9116 9110
9117TURBOCHANNEL SUBSYSTEM 9111TURBOCHANNEL SUBSYSTEM
9118M: "Maciej W. Rozycki" <macro@linux-mips.org> 9112M: "Maciej W. Rozycki" <macro@linux-mips.org>
9113M: Ralf Baechle <ralf@linux-mips.org>
9114L: linux-mips@linux-mips.org
9115Q: http://patchwork.linux-mips.org/project/linux-mips/list/
9119S: Maintained 9116S: Maintained
9120F: drivers/tc/ 9117F: drivers/tc/
9121F: include/linux/tc.h 9118F: include/linux/tc.h
diff --git a/Makefile b/Makefile
index 8a8440a3578e..9d993787afe0 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 15 2PATCHLEVEL = 15
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc5 4EXTRAVERSION = -rc6
5NAME = Shuffling Zombie Juror 5NAME = Shuffling Zombie Juror
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arm/boot/dts/imx53-mba53.dts b/arch/arm/boot/dts/imx53-mba53.dts
index 7c8c12969892..a3431d784870 100644
--- a/arch/arm/boot/dts/imx53-mba53.dts
+++ b/arch/arm/boot/dts/imx53-mba53.dts
@@ -244,7 +244,7 @@
244&tve { 244&tve {
245 pinctrl-names = "default"; 245 pinctrl-names = "default";
246 pinctrl-0 = <&pinctrl_vga_sync_1>; 246 pinctrl-0 = <&pinctrl_vga_sync_1>;
247 i2c-ddc-bus = <&i2c3>; 247 ddc-i2c-bus = <&i2c3>;
248 fsl,tve-mode = "vga"; 248 fsl,tve-mode = "vga";
249 fsl,hsync-pin = <4>; 249 fsl,hsync-pin = <4>;
250 fsl,vsync-pin = <6>; 250 fsl,vsync-pin = <6>;
diff --git a/arch/arm/boot/dts/ste-ccu8540.dts b/arch/arm/boot/dts/ste-ccu8540.dts
index 7f3baf51a3a9..32dd55e5f4e6 100644
--- a/arch/arm/boot/dts/ste-ccu8540.dts
+++ b/arch/arm/boot/dts/ste-ccu8540.dts
@@ -18,6 +18,7 @@
18 compatible = "st-ericsson,ccu8540", "st-ericsson,u8540"; 18 compatible = "st-ericsson,ccu8540", "st-ericsson,u8540";
19 19
20 memory@0 { 20 memory@0 {
21 device_type = "memory";
21 reg = <0x20000000 0x1f000000>, <0xc0000000 0x3f000000>; 22 reg = <0x20000000 0x1f000000>, <0xc0000000 0x3f000000>;
22 }; 23 };
23 24
diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c
index 473e5dbf8f39..0f08dfd69ebc 100644
--- a/arch/arm64/kernel/irq.c
+++ b/arch/arm64/kernel/irq.c
@@ -97,11 +97,15 @@ static bool migrate_one_irq(struct irq_desc *desc)
97 if (irqd_is_per_cpu(d) || !cpumask_test_cpu(smp_processor_id(), affinity)) 97 if (irqd_is_per_cpu(d) || !cpumask_test_cpu(smp_processor_id(), affinity))
98 return false; 98 return false;
99 99
100 if (cpumask_any_and(affinity, cpu_online_mask) >= nr_cpu_ids) { 100 if (cpumask_any_and(affinity, cpu_online_mask) >= nr_cpu_ids)
101 affinity = cpu_online_mask;
102 ret = true; 101 ret = true;
103 }
104 102
103 /*
104 * when using forced irq_set_affinity we must ensure that the cpu
105 * being offlined is not present in the affinity mask, it may be
106 * selected as the target CPU otherwise
107 */
108 affinity = cpu_online_mask;
105 c = irq_data_get_irq_chip(d); 109 c = irq_data_get_irq_chip(d);
106 if (!c->irq_set_affinity) 110 if (!c->irq_set_affinity)
107 pr_debug("IRQ%u: unable to set affinity\n", d->irq); 111 pr_debug("IRQ%u: unable to set affinity\n", d->irq);
diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
index 5e9aec358306..31eb959e9aa8 100644
--- a/arch/arm64/mm/hugetlbpage.c
+++ b/arch/arm64/mm/hugetlbpage.c
@@ -51,7 +51,11 @@ int pmd_huge(pmd_t pmd)
51 51
52int pud_huge(pud_t pud) 52int pud_huge(pud_t pud)
53{ 53{
54#ifndef __PAGETABLE_PMD_FOLDED
54 return !(pud_val(pud) & PUD_TABLE_BIT); 55 return !(pud_val(pud) & PUD_TABLE_BIT);
56#else
57 return 0;
58#endif
55} 59}
56 60
57int pmd_huge_support(void) 61int pmd_huge_support(void)
diff --git a/arch/ia64/include/asm/unistd.h b/arch/ia64/include/asm/unistd.h
index ae763d8bf55a..fb13dc5e8f8c 100644
--- a/arch/ia64/include/asm/unistd.h
+++ b/arch/ia64/include/asm/unistd.h
@@ -11,7 +11,7 @@
11 11
12 12
13 13
14#define NR_syscalls 314 /* length of syscall table */ 14#define NR_syscalls 315 /* length of syscall table */
15 15
16/* 16/*
17 * The following defines stop scripts/checksyscalls.sh from complaining about 17 * The following defines stop scripts/checksyscalls.sh from complaining about
diff --git a/arch/ia64/include/uapi/asm/unistd.h b/arch/ia64/include/uapi/asm/unistd.h
index 715e85f858de..7de0a2d65da4 100644
--- a/arch/ia64/include/uapi/asm/unistd.h
+++ b/arch/ia64/include/uapi/asm/unistd.h
@@ -327,5 +327,6 @@
327#define __NR_finit_module 1335 327#define __NR_finit_module 1335
328#define __NR_sched_setattr 1336 328#define __NR_sched_setattr 1336
329#define __NR_sched_getattr 1337 329#define __NR_sched_getattr 1337
330#define __NR_renameat2 1338
330 331
331#endif /* _UAPI_ASM_IA64_UNISTD_H */ 332#endif /* _UAPI_ASM_IA64_UNISTD_H */
diff --git a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S
index fa8d61a312a7..ba3d03503e84 100644
--- a/arch/ia64/kernel/entry.S
+++ b/arch/ia64/kernel/entry.S
@@ -1775,6 +1775,7 @@ sys_call_table:
1775 data8 sys_finit_module // 1335 1775 data8 sys_finit_module // 1335
1776 data8 sys_sched_setattr 1776 data8 sys_sched_setattr
1777 data8 sys_sched_getattr 1777 data8 sys_sched_getattr
1778 data8 sys_renameat2
1778 1779
1779 .org sys_call_table + 8*NR_syscalls // guard against failures to increase NR_syscalls 1780 .org sys_call_table + 8*NR_syscalls // guard against failures to increase NR_syscalls
1780#endif /* __IA64_ASM_PARAVIRTUALIZED_NATIVE */ 1781#endif /* __IA64_ASM_PARAVIRTUALIZED_NATIVE */
diff --git a/arch/m68k/include/asm/unistd.h b/arch/m68k/include/asm/unistd.h
index 9d38b73989eb..33afa56ad47a 100644
--- a/arch/m68k/include/asm/unistd.h
+++ b/arch/m68k/include/asm/unistd.h
@@ -4,7 +4,7 @@
4#include <uapi/asm/unistd.h> 4#include <uapi/asm/unistd.h>
5 5
6 6
7#define NR_syscalls 351 7#define NR_syscalls 352
8 8
9#define __ARCH_WANT_OLD_READDIR 9#define __ARCH_WANT_OLD_READDIR
10#define __ARCH_WANT_OLD_STAT 10#define __ARCH_WANT_OLD_STAT
diff --git a/arch/m68k/include/uapi/asm/unistd.h b/arch/m68k/include/uapi/asm/unistd.h
index b932dd470041..9cd82fbc7817 100644
--- a/arch/m68k/include/uapi/asm/unistd.h
+++ b/arch/m68k/include/uapi/asm/unistd.h
@@ -356,5 +356,6 @@
356#define __NR_finit_module 348 356#define __NR_finit_module 348
357#define __NR_sched_setattr 349 357#define __NR_sched_setattr 349
358#define __NR_sched_getattr 350 358#define __NR_sched_getattr 350
359#define __NR_renameat2 351
359 360
360#endif /* _UAPI_ASM_M68K_UNISTD_H_ */ 361#endif /* _UAPI_ASM_M68K_UNISTD_H_ */
diff --git a/arch/m68k/kernel/syscalltable.S b/arch/m68k/kernel/syscalltable.S
index b6223dc41d82..501e10212789 100644
--- a/arch/m68k/kernel/syscalltable.S
+++ b/arch/m68k/kernel/syscalltable.S
@@ -371,4 +371,5 @@ ENTRY(sys_call_table)
371 .long sys_finit_module 371 .long sys_finit_module
372 .long sys_sched_setattr 372 .long sys_sched_setattr
373 .long sys_sched_getattr /* 350 */ 373 .long sys_sched_getattr /* 350 */
374 .long sys_renameat2
374 375
diff --git a/arch/metag/include/asm/barrier.h b/arch/metag/include/asm/barrier.h
index 5d6b4b407dda..2d6f0de77325 100644
--- a/arch/metag/include/asm/barrier.h
+++ b/arch/metag/include/asm/barrier.h
@@ -15,6 +15,7 @@ static inline void wr_fence(void)
15 volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_FENCE; 15 volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_FENCE;
16 barrier(); 16 barrier();
17 *flushptr = 0; 17 *flushptr = 0;
18 barrier();
18} 19}
19 20
20#else /* CONFIG_METAG_META21 */ 21#else /* CONFIG_METAG_META21 */
@@ -35,6 +36,7 @@ static inline void wr_fence(void)
35 *flushptr = 0; 36 *flushptr = 0;
36 *flushptr = 0; 37 *flushptr = 0;
37 *flushptr = 0; 38 *flushptr = 0;
39 barrier();
38} 40}
39 41
40#endif /* !CONFIG_METAG_META21 */ 42#endif /* !CONFIG_METAG_META21 */
@@ -68,6 +70,7 @@ static inline void fence(void)
68 volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_ATOMIC_UNLOCK; 70 volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_ATOMIC_UNLOCK;
69 barrier(); 71 barrier();
70 *flushptr = 0; 72 *flushptr = 0;
73 barrier();
71} 74}
72#define smp_mb() fence() 75#define smp_mb() fence()
73#define smp_rmb() fence() 76#define smp_rmb() fence()
diff --git a/arch/metag/include/asm/processor.h b/arch/metag/include/asm/processor.h
index f16477d1f571..a8a37477c66e 100644
--- a/arch/metag/include/asm/processor.h
+++ b/arch/metag/include/asm/processor.h
@@ -22,6 +22,8 @@
22/* Add an extra page of padding at the top of the stack for the guard page. */ 22/* Add an extra page of padding at the top of the stack for the guard page. */
23#define STACK_TOP (TASK_SIZE - PAGE_SIZE) 23#define STACK_TOP (TASK_SIZE - PAGE_SIZE)
24#define STACK_TOP_MAX STACK_TOP 24#define STACK_TOP_MAX STACK_TOP
25/* Maximum virtual space for stack */
26#define STACK_SIZE_MAX (CONFIG_MAX_STACK_SIZE_MB*1024*1024)
25 27
26/* This decides where the kernel will search for a free chunk of vm 28/* This decides where the kernel will search for a free chunk of vm
27 * space during mmap's. 29 * space during mmap's.
diff --git a/arch/metag/include/uapi/asm/Kbuild b/arch/metag/include/uapi/asm/Kbuild
index 84e09feb4d54..ab78be2b6eb0 100644
--- a/arch/metag/include/uapi/asm/Kbuild
+++ b/arch/metag/include/uapi/asm/Kbuild
@@ -4,11 +4,11 @@ include include/uapi/asm-generic/Kbuild.asm
4header-y += byteorder.h 4header-y += byteorder.h
5header-y += ech.h 5header-y += ech.h
6header-y += ptrace.h 6header-y += ptrace.h
7header-y += resource.h
8header-y += sigcontext.h 7header-y += sigcontext.h
9header-y += siginfo.h 8header-y += siginfo.h
10header-y += swab.h 9header-y += swab.h
11header-y += unistd.h 10header-y += unistd.h
12 11
13generic-y += mman.h 12generic-y += mman.h
13generic-y += resource.h
14generic-y += setup.h 14generic-y += setup.h
diff --git a/arch/metag/include/uapi/asm/resource.h b/arch/metag/include/uapi/asm/resource.h
deleted file mode 100644
index 526d23cc3054..000000000000
--- a/arch/metag/include/uapi/asm/resource.h
+++ /dev/null
@@ -1,7 +0,0 @@
1#ifndef _UAPI_METAG_RESOURCE_H
2#define _UAPI_METAG_RESOURCE_H
3
4#define _STK_LIM_MAX (1 << 28)
5#include <asm-generic/resource.h>
6
7#endif /* _UAPI_METAG_RESOURCE_H */
diff --git a/arch/mips/dec/ecc-berr.c b/arch/mips/dec/ecc-berr.c
index 5abf4e894216..2a66e908f6a9 100644
--- a/arch/mips/dec/ecc-berr.c
+++ b/arch/mips/dec/ecc-berr.c
@@ -21,6 +21,7 @@
21#include <asm/addrspace.h> 21#include <asm/addrspace.h>
22#include <asm/bootinfo.h> 22#include <asm/bootinfo.h>
23#include <asm/cpu.h> 23#include <asm/cpu.h>
24#include <asm/cpu-type.h>
24#include <asm/irq_regs.h> 25#include <asm/irq_regs.h>
25#include <asm/processor.h> 26#include <asm/processor.h>
26#include <asm/ptrace.h> 27#include <asm/ptrace.h>
diff --git a/arch/mips/dec/kn02xa-berr.c b/arch/mips/dec/kn02xa-berr.c
index f434b759e3b9..ec606363b806 100644
--- a/arch/mips/dec/kn02xa-berr.c
+++ b/arch/mips/dec/kn02xa-berr.c
@@ -19,6 +19,7 @@
19#include <linux/types.h> 19#include <linux/types.h>
20 20
21#include <asm/addrspace.h> 21#include <asm/addrspace.h>
22#include <asm/cpu-type.h>
22#include <asm/irq_regs.h> 23#include <asm/irq_regs.h>
23#include <asm/ptrace.h> 24#include <asm/ptrace.h>
24#include <asm/traps.h> 25#include <asm/traps.h>
diff --git a/arch/mips/dec/prom/Makefile b/arch/mips/dec/prom/Makefile
index 064ae7a76bdc..ae73e42ac20b 100644
--- a/arch/mips/dec/prom/Makefile
+++ b/arch/mips/dec/prom/Makefile
@@ -6,4 +6,3 @@
6lib-y += init.o memory.o cmdline.o identify.o console.o 6lib-y += init.o memory.o cmdline.o identify.o console.o
7 7
8lib-$(CONFIG_32BIT) += locore.o 8lib-$(CONFIG_32BIT) += locore.o
9lib-$(CONFIG_64BIT) += call_o32.o
diff --git a/arch/mips/dec/prom/call_o32.S b/arch/mips/dec/prom/call_o32.S
deleted file mode 100644
index 8c8498159e43..000000000000
--- a/arch/mips/dec/prom/call_o32.S
+++ /dev/null
@@ -1,89 +0,0 @@
1/*
2 * O32 interface for the 64 (or N32) ABI.
3 *
4 * Copyright (C) 2002 Maciej W. Rozycki
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#include <asm/asm.h>
13#include <asm/regdef.h>
14
15/* Maximum number of arguments supported. Must be even! */
16#define O32_ARGC 32
17/* Number of static registers we save. */
18#define O32_STATC 11
19/* Frame size for both of the above. */
20#define O32_FRAMESZ (4 * O32_ARGC + SZREG * O32_STATC)
21
22 .text
23
24/*
25 * O32 function call dispatcher, for interfacing 32-bit ROM routines.
26 *
27 * The standard 64 (N32) calling sequence is supported, with a0
28 * holding a function pointer, a1-a7 -- its first seven arguments
29 * and the stack -- remaining ones (up to O32_ARGC, including a1-a7).
30 * Static registers, gp and fp are preserved, v0 holds a result.
31 * This code relies on the called o32 function for sp and ra
32 * restoration and thus both this dispatcher and the current stack
33 * have to be placed in a KSEGx (or KUSEG) address space. Any
34 * pointers passed have to point to addresses within one of these
35 * spaces as well.
36 */
37NESTED(call_o32, O32_FRAMESZ, ra)
38 REG_SUBU sp,O32_FRAMESZ
39
40 REG_S ra,O32_FRAMESZ-1*SZREG(sp)
41 REG_S fp,O32_FRAMESZ-2*SZREG(sp)
42 REG_S gp,O32_FRAMESZ-3*SZREG(sp)
43 REG_S s7,O32_FRAMESZ-4*SZREG(sp)
44 REG_S s6,O32_FRAMESZ-5*SZREG(sp)
45 REG_S s5,O32_FRAMESZ-6*SZREG(sp)
46 REG_S s4,O32_FRAMESZ-7*SZREG(sp)
47 REG_S s3,O32_FRAMESZ-8*SZREG(sp)
48 REG_S s2,O32_FRAMESZ-9*SZREG(sp)
49 REG_S s1,O32_FRAMESZ-10*SZREG(sp)
50 REG_S s0,O32_FRAMESZ-11*SZREG(sp)
51
52 move jp,a0
53
54 sll a0,a1,zero
55 sll a1,a2,zero
56 sll a2,a3,zero
57 sll a3,a4,zero
58 sw a5,0x10(sp)
59 sw a6,0x14(sp)
60 sw a7,0x18(sp)
61
62 PTR_LA t0,O32_FRAMESZ(sp)
63 PTR_LA t1,0x1c(sp)
64 li t2,O32_ARGC-7
651:
66 lw t3,(t0)
67 REG_ADDU t0,SZREG
68 sw t3,(t1)
69 REG_SUBU t2,1
70 REG_ADDU t1,4
71 bnez t2,1b
72
73 jalr jp
74
75 REG_L s0,O32_FRAMESZ-11*SZREG(sp)
76 REG_L s1,O32_FRAMESZ-10*SZREG(sp)
77 REG_L s2,O32_FRAMESZ-9*SZREG(sp)
78 REG_L s3,O32_FRAMESZ-8*SZREG(sp)
79 REG_L s4,O32_FRAMESZ-7*SZREG(sp)
80 REG_L s5,O32_FRAMESZ-6*SZREG(sp)
81 REG_L s6,O32_FRAMESZ-5*SZREG(sp)
82 REG_L s7,O32_FRAMESZ-4*SZREG(sp)
83 REG_L gp,O32_FRAMESZ-3*SZREG(sp)
84 REG_L fp,O32_FRAMESZ-2*SZREG(sp)
85 REG_L ra,O32_FRAMESZ-1*SZREG(sp)
86
87 REG_ADDU sp,O32_FRAMESZ
88 jr ra
89END(call_o32)
diff --git a/arch/mips/fw/lib/call_o32.S b/arch/mips/fw/lib/call_o32.S
index b308b2a0613e..4703fe4dbd9a 100644
--- a/arch/mips/fw/lib/call_o32.S
+++ b/arch/mips/fw/lib/call_o32.S
@@ -1,7 +1,7 @@
1/* 1/*
2 * O32 interface for the 64 (or N32) ABI. 2 * O32 interface for the 64 (or N32) ABI.
3 * 3 *
4 * Copyright (C) 2002 Maciej W. Rozycki 4 * Copyright (C) 2002, 2014 Maciej W. Rozycki
5 * 5 *
6 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License 7 * modify it under the terms of the GNU General Public License
@@ -12,28 +12,37 @@
12#include <asm/asm.h> 12#include <asm/asm.h>
13#include <asm/regdef.h> 13#include <asm/regdef.h>
14 14
15/* O32 register size. */
16#define O32_SZREG 4
15/* Maximum number of arguments supported. Must be even! */ 17/* Maximum number of arguments supported. Must be even! */
16#define O32_ARGC 32 18#define O32_ARGC 32
17/* Number of static registers we save. */ 19/* Number of static registers we save. */
18#define O32_STATC 11 20#define O32_STATC 11
19/* Frame size for static register */ 21/* Argument area frame size. */
20#define O32_FRAMESZ (SZREG * O32_STATC) 22#define O32_ARGSZ (O32_SZREG * O32_ARGC)
21/* Frame size on new stack */ 23/* Static register save area frame size. */
22#define O32_FRAMESZ_NEW (SZREG + 4 * O32_ARGC) 24#define O32_STATSZ (SZREG * O32_STATC)
25/* Stack pointer register save area frame size. */
26#define O32_SPSZ SZREG
27/* Combined area frame size. */
28#define O32_FRAMESZ (O32_ARGSZ + O32_SPSZ + O32_STATSZ)
29/* Switched stack frame size. */
30#define O32_NFRAMESZ (O32_ARGSZ + O32_SPSZ)
23 31
24 .text 32 .text
25 33
26/* 34/*
27 * O32 function call dispatcher, for interfacing 32-bit ROM routines. 35 * O32 function call dispatcher, for interfacing 32-bit ROM routines.
28 * 36 *
29 * The standard 64 (N32) calling sequence is supported, with a0 37 * The standard 64 (N32) calling sequence is supported, with a0 holding
30 * holding a function pointer, a1 a new stack pointer, a2-a7 -- its 38 * a function pointer, a1 a pointer to the new stack to call the
31 * first six arguments and the stack -- remaining ones (up to O32_ARGC, 39 * function with or 0 if no stack switching is requested, a2-a7 -- the
32 * including a2-a7). Static registers, gp and fp are preserved, v0 holds 40 * function call's first six arguments, and the stack -- the remaining
33 * a result. This code relies on the called o32 function for sp and ra 41 * arguments (up to O32_ARGC, including a2-a7). Static registers, gp
34 * restoration and this dispatcher has to be placed in a KSEGx (or KUSEG) 42 * and fp are preserved, v0 holds the result. This code relies on the
35 * address space. Any pointers passed have to point to addresses within 43 * called o32 function for sp and ra restoration and this dispatcher has
36 * one of these spaces as well. 44 * to be placed in a KSEGx (or KUSEG) address space. Any pointers
45 * passed have to point to addresses within one of these spaces as well.
37 */ 46 */
38NESTED(call_o32, O32_FRAMESZ, ra) 47NESTED(call_o32, O32_FRAMESZ, ra)
39 REG_SUBU sp,O32_FRAMESZ 48 REG_SUBU sp,O32_FRAMESZ
@@ -51,32 +60,36 @@ NESTED(call_o32, O32_FRAMESZ, ra)
51 REG_S s0,O32_FRAMESZ-11*SZREG(sp) 60 REG_S s0,O32_FRAMESZ-11*SZREG(sp)
52 61
53 move jp,a0 62 move jp,a0
54 REG_SUBU s0,a1,O32_FRAMESZ_NEW 63
55 REG_S sp,O32_FRAMESZ_NEW-1*SZREG(s0) 64 move fp,sp
65 beqz a1,0f
66 REG_SUBU fp,a1,O32_NFRAMESZ
670:
68 REG_S sp,O32_NFRAMESZ-1*SZREG(fp)
56 69
57 sll a0,a2,zero 70 sll a0,a2,zero
58 sll a1,a3,zero 71 sll a1,a3,zero
59 sll a2,a4,zero 72 sll a2,a4,zero
60 sll a3,a5,zero 73 sll a3,a5,zero
61 sw a6,0x10(s0) 74 sw a6,4*O32_SZREG(fp)
62 sw a7,0x14(s0) 75 sw a7,5*O32_SZREG(fp)
63 76
64 PTR_LA t0,O32_FRAMESZ(sp) 77 PTR_LA t0,O32_FRAMESZ(sp)
65 PTR_LA t1,0x18(s0) 78 PTR_LA t1,6*O32_SZREG(fp)
66 li t2,O32_ARGC-6 79 li t2,O32_ARGC-6
671: 801:
68 lw t3,(t0) 81 lw t3,(t0)
69 REG_ADDU t0,SZREG 82 REG_ADDU t0,SZREG
70 sw t3,(t1) 83 sw t3,(t1)
71 REG_SUBU t2,1 84 REG_SUBU t2,1
72 REG_ADDU t1,4 85 REG_ADDU t1,O32_SZREG
73 bnez t2,1b 86 bnez t2,1b
74 87
75 move sp,s0 88 move sp,fp
76 89
77 jalr jp 90 jalr jp
78 91
79 REG_L sp,O32_FRAMESZ_NEW-1*SZREG(sp) 92 REG_L sp,O32_NFRAMESZ-1*SZREG(sp)
80 93
81 REG_L s0,O32_FRAMESZ-11*SZREG(sp) 94 REG_L s0,O32_FRAMESZ-11*SZREG(sp)
82 REG_L s1,O32_FRAMESZ-10*SZREG(sp) 95 REG_L s1,O32_FRAMESZ-10*SZREG(sp)
diff --git a/arch/mips/fw/sni/sniprom.c b/arch/mips/fw/sni/sniprom.c
index 2c2cb182af4e..6aa264b9856a 100644
--- a/arch/mips/fw/sni/sniprom.c
+++ b/arch/mips/fw/sni/sniprom.c
@@ -40,7 +40,8 @@
40 40
41#ifdef CONFIG_64BIT 41#ifdef CONFIG_64BIT
42 42
43static u8 o32_stk[16384]; 43/* O32 stack has to be 8-byte aligned. */
44static u64 o32_stk[4096];
44#define O32_STK &o32_stk[sizeof(o32_stk)] 45#define O32_STK &o32_stk[sizeof(o32_stk)]
45 46
46#define __PROM_O32(fun, arg) fun arg __asm__(#fun); \ 47#define __PROM_O32(fun, arg) fun arg __asm__(#fun); \
diff --git a/arch/mips/include/asm/dec/prom.h b/arch/mips/include/asm/dec/prom.h
index c0ead6313845..b59a2103b61a 100644
--- a/arch/mips/include/asm/dec/prom.h
+++ b/arch/mips/include/asm/dec/prom.h
@@ -113,31 +113,31 @@ extern int (*__pmax_close)(int);
113#define __DEC_PROM_O32(fun, arg) fun arg __asm__(#fun); \ 113#define __DEC_PROM_O32(fun, arg) fun arg __asm__(#fun); \
114 __asm__(#fun " = call_o32") 114 __asm__(#fun " = call_o32")
115 115
116int __DEC_PROM_O32(_rex_bootinit, (int (*)(void))); 116int __DEC_PROM_O32(_rex_bootinit, (int (*)(void), void *));
117int __DEC_PROM_O32(_rex_bootread, (int (*)(void))); 117int __DEC_PROM_O32(_rex_bootread, (int (*)(void), void *));
118int __DEC_PROM_O32(_rex_getbitmap, (int (*)(memmap *), memmap *)); 118int __DEC_PROM_O32(_rex_getbitmap, (int (*)(memmap *), void *, memmap *));
119unsigned long *__DEC_PROM_O32(_rex_slot_address, 119unsigned long *__DEC_PROM_O32(_rex_slot_address,
120 (unsigned long *(*)(int), int)); 120 (unsigned long *(*)(int), void *, int));
121void *__DEC_PROM_O32(_rex_gettcinfo, (void *(*)(void))); 121void *__DEC_PROM_O32(_rex_gettcinfo, (void *(*)(void), void *));
122int __DEC_PROM_O32(_rex_getsysid, (int (*)(void))); 122int __DEC_PROM_O32(_rex_getsysid, (int (*)(void), void *));
123void __DEC_PROM_O32(_rex_clear_cache, (void (*)(void))); 123void __DEC_PROM_O32(_rex_clear_cache, (void (*)(void), void *));
124 124
125int __DEC_PROM_O32(_prom_getchar, (int (*)(void))); 125int __DEC_PROM_O32(_prom_getchar, (int (*)(void), void *));
126char *__DEC_PROM_O32(_prom_getenv, (char *(*)(char *), char *)); 126char *__DEC_PROM_O32(_prom_getenv, (char *(*)(char *), void *, char *));
127int __DEC_PROM_O32(_prom_printf, (int (*)(char *, ...), char *, ...)); 127int __DEC_PROM_O32(_prom_printf, (int (*)(char *, ...), void *, char *, ...));
128 128
129 129
130#define rex_bootinit() _rex_bootinit(__rex_bootinit) 130#define rex_bootinit() _rex_bootinit(__rex_bootinit, NULL)
131#define rex_bootread() _rex_bootread(__rex_bootread) 131#define rex_bootread() _rex_bootread(__rex_bootread, NULL)
132#define rex_getbitmap(x) _rex_getbitmap(__rex_getbitmap, x) 132#define rex_getbitmap(x) _rex_getbitmap(__rex_getbitmap, NULL, x)
133#define rex_slot_address(x) _rex_slot_address(__rex_slot_address, x) 133#define rex_slot_address(x) _rex_slot_address(__rex_slot_address, NULL, x)
134#define rex_gettcinfo() _rex_gettcinfo(__rex_gettcinfo) 134#define rex_gettcinfo() _rex_gettcinfo(__rex_gettcinfo, NULL)
135#define rex_getsysid() _rex_getsysid(__rex_getsysid) 135#define rex_getsysid() _rex_getsysid(__rex_getsysid, NULL)
136#define rex_clear_cache() _rex_clear_cache(__rex_clear_cache) 136#define rex_clear_cache() _rex_clear_cache(__rex_clear_cache, NULL)
137 137
138#define prom_getchar() _prom_getchar(__prom_getchar) 138#define prom_getchar() _prom_getchar(__prom_getchar, NULL)
139#define prom_getenv(x) _prom_getenv(__prom_getenv, x) 139#define prom_getenv(x) _prom_getenv(__prom_getenv, NULL, x)
140#define prom_printf(x...) _prom_printf(__prom_printf, x) 140#define prom_printf(x...) _prom_printf(__prom_printf, NULL, x)
141 141
142#else /* !CONFIG_64BIT */ 142#else /* !CONFIG_64BIT */
143 143
diff --git a/arch/mips/include/asm/rm9k-ocd.h b/arch/mips/include/asm/rm9k-ocd.h
deleted file mode 100644
index b0b80d9ecf96..000000000000
--- a/arch/mips/include/asm/rm9k-ocd.h
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * Copyright (C) 2004 by Basler Vision Technologies AG
3 * Author: Thomas Koeller <thomas.koeller@baslerweb.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#if !defined(_ASM_RM9K_OCD_H)
21#define _ASM_RM9K_OCD_H
22
23#include <linux/types.h>
24#include <linux/spinlock.h>
25#include <asm/io.h>
26
27extern volatile void __iomem * const ocd_base;
28extern volatile void __iomem * const titan_base;
29
30#define ocd_addr(__x__) (ocd_base + (__x__))
31#define titan_addr(__x__) (titan_base + (__x__))
32#define scram_addr(__x__) (scram_base + (__x__))
33
34/* OCD register access */
35#define ocd_readl(__offs__) __raw_readl(ocd_addr(__offs__))
36#define ocd_readw(__offs__) __raw_readw(ocd_addr(__offs__))
37#define ocd_readb(__offs__) __raw_readb(ocd_addr(__offs__))
38#define ocd_writel(__val__, __offs__) \
39 __raw_writel((__val__), ocd_addr(__offs__))
40#define ocd_writew(__val__, __offs__) \
41 __raw_writew((__val__), ocd_addr(__offs__))
42#define ocd_writeb(__val__, __offs__) \
43 __raw_writeb((__val__), ocd_addr(__offs__))
44
45/* TITAN register access - 32 bit-wide only */
46#define titan_readl(__offs__) __raw_readl(titan_addr(__offs__))
47#define titan_writel(__val__, __offs__) \
48 __raw_writel((__val__), titan_addr(__offs__))
49
50/* Protect access to shared TITAN registers */
51extern spinlock_t titan_lock;
52extern int titan_irqflags;
53#define lock_titan_regs() spin_lock_irqsave(&titan_lock, titan_irqflags)
54#define unlock_titan_regs() spin_unlock_irqrestore(&titan_lock, titan_irqflags)
55
56#endif /* !defined(_ASM_RM9K_OCD_H) */
diff --git a/arch/mips/include/asm/syscall.h b/arch/mips/include/asm/syscall.h
index c6e9cd2bca8d..17960fe7a8ce 100644
--- a/arch/mips/include/asm/syscall.h
+++ b/arch/mips/include/asm/syscall.h
@@ -133,6 +133,8 @@ static inline int syscall_get_arch(void)
133#ifdef CONFIG_64BIT 133#ifdef CONFIG_64BIT
134 if (!test_thread_flag(TIF_32BIT_REGS)) 134 if (!test_thread_flag(TIF_32BIT_REGS))
135 arch |= __AUDIT_ARCH_64BIT; 135 arch |= __AUDIT_ARCH_64BIT;
136 if (test_thread_flag(TIF_32BIT_ADDR))
137 arch |= __AUDIT_ARCH_CONVENTION_MIPS64_N32;
136#endif 138#endif
137#if defined(__LITTLE_ENDIAN) 139#if defined(__LITTLE_ENDIAN)
138 arch |= __AUDIT_ARCH_LE; 140 arch |= __AUDIT_ARCH_LE;
diff --git a/arch/mips/include/uapi/asm/inst.h b/arch/mips/include/uapi/asm/inst.h
index df6e775f3fef..3125797f2a88 100644
--- a/arch/mips/include/uapi/asm/inst.h
+++ b/arch/mips/include/uapi/asm/inst.h
@@ -484,13 +484,13 @@ enum MIPS6e_i8_func {
484 * Damn ... bitfields depend from byteorder :-( 484 * Damn ... bitfields depend from byteorder :-(
485 */ 485 */
486#ifdef __MIPSEB__ 486#ifdef __MIPSEB__
487#define BITFIELD_FIELD(field, more) \ 487#define __BITFIELD_FIELD(field, more) \
488 field; \ 488 field; \
489 more 489 more
490 490
491#elif defined(__MIPSEL__) 491#elif defined(__MIPSEL__)
492 492
493#define BITFIELD_FIELD(field, more) \ 493#define __BITFIELD_FIELD(field, more) \
494 more \ 494 more \
495 field; 495 field;
496 496
@@ -499,112 +499,112 @@ enum MIPS6e_i8_func {
499#endif 499#endif
500 500
501struct j_format { 501struct j_format {
502 BITFIELD_FIELD(unsigned int opcode : 6, /* Jump format */ 502 __BITFIELD_FIELD(unsigned int opcode : 6, /* Jump format */
503 BITFIELD_FIELD(unsigned int target : 26, 503 __BITFIELD_FIELD(unsigned int target : 26,
504 ;)) 504 ;))
505}; 505};
506 506
507struct i_format { /* signed immediate format */ 507struct i_format { /* signed immediate format */
508 BITFIELD_FIELD(unsigned int opcode : 6, 508 __BITFIELD_FIELD(unsigned int opcode : 6,
509 BITFIELD_FIELD(unsigned int rs : 5, 509 __BITFIELD_FIELD(unsigned int rs : 5,
510 BITFIELD_FIELD(unsigned int rt : 5, 510 __BITFIELD_FIELD(unsigned int rt : 5,
511 BITFIELD_FIELD(signed int simmediate : 16, 511 __BITFIELD_FIELD(signed int simmediate : 16,
512 ;)))) 512 ;))))
513}; 513};
514 514
515struct u_format { /* unsigned immediate format */ 515struct u_format { /* unsigned immediate format */
516 BITFIELD_FIELD(unsigned int opcode : 6, 516 __BITFIELD_FIELD(unsigned int opcode : 6,
517 BITFIELD_FIELD(unsigned int rs : 5, 517 __BITFIELD_FIELD(unsigned int rs : 5,
518 BITFIELD_FIELD(unsigned int rt : 5, 518 __BITFIELD_FIELD(unsigned int rt : 5,
519 BITFIELD_FIELD(unsigned int uimmediate : 16, 519 __BITFIELD_FIELD(unsigned int uimmediate : 16,
520 ;)))) 520 ;))))
521}; 521};
522 522
523struct c_format { /* Cache (>= R6000) format */ 523struct c_format { /* Cache (>= R6000) format */
524 BITFIELD_FIELD(unsigned int opcode : 6, 524 __BITFIELD_FIELD(unsigned int opcode : 6,
525 BITFIELD_FIELD(unsigned int rs : 5, 525 __BITFIELD_FIELD(unsigned int rs : 5,
526 BITFIELD_FIELD(unsigned int c_op : 3, 526 __BITFIELD_FIELD(unsigned int c_op : 3,
527 BITFIELD_FIELD(unsigned int cache : 2, 527 __BITFIELD_FIELD(unsigned int cache : 2,
528 BITFIELD_FIELD(unsigned int simmediate : 16, 528 __BITFIELD_FIELD(unsigned int simmediate : 16,
529 ;))))) 529 ;)))))
530}; 530};
531 531
532struct r_format { /* Register format */ 532struct r_format { /* Register format */
533 BITFIELD_FIELD(unsigned int opcode : 6, 533 __BITFIELD_FIELD(unsigned int opcode : 6,
534 BITFIELD_FIELD(unsigned int rs : 5, 534 __BITFIELD_FIELD(unsigned int rs : 5,
535 BITFIELD_FIELD(unsigned int rt : 5, 535 __BITFIELD_FIELD(unsigned int rt : 5,
536 BITFIELD_FIELD(unsigned int rd : 5, 536 __BITFIELD_FIELD(unsigned int rd : 5,
537 BITFIELD_FIELD(unsigned int re : 5, 537 __BITFIELD_FIELD(unsigned int re : 5,
538 BITFIELD_FIELD(unsigned int func : 6, 538 __BITFIELD_FIELD(unsigned int func : 6,
539 ;)))))) 539 ;))))))
540}; 540};
541 541
542struct p_format { /* Performance counter format (R10000) */ 542struct p_format { /* Performance counter format (R10000) */
543 BITFIELD_FIELD(unsigned int opcode : 6, 543 __BITFIELD_FIELD(unsigned int opcode : 6,
544 BITFIELD_FIELD(unsigned int rs : 5, 544 __BITFIELD_FIELD(unsigned int rs : 5,
545 BITFIELD_FIELD(unsigned int rt : 5, 545 __BITFIELD_FIELD(unsigned int rt : 5,
546 BITFIELD_FIELD(unsigned int rd : 5, 546 __BITFIELD_FIELD(unsigned int rd : 5,
547 BITFIELD_FIELD(unsigned int re : 5, 547 __BITFIELD_FIELD(unsigned int re : 5,
548 BITFIELD_FIELD(unsigned int func : 6, 548 __BITFIELD_FIELD(unsigned int func : 6,
549 ;)))))) 549 ;))))))
550}; 550};
551 551
552struct f_format { /* FPU register format */ 552struct f_format { /* FPU register format */
553 BITFIELD_FIELD(unsigned int opcode : 6, 553 __BITFIELD_FIELD(unsigned int opcode : 6,
554 BITFIELD_FIELD(unsigned int : 1, 554 __BITFIELD_FIELD(unsigned int : 1,
555 BITFIELD_FIELD(unsigned int fmt : 4, 555 __BITFIELD_FIELD(unsigned int fmt : 4,
556 BITFIELD_FIELD(unsigned int rt : 5, 556 __BITFIELD_FIELD(unsigned int rt : 5,
557 BITFIELD_FIELD(unsigned int rd : 5, 557 __BITFIELD_FIELD(unsigned int rd : 5,
558 BITFIELD_FIELD(unsigned int re : 5, 558 __BITFIELD_FIELD(unsigned int re : 5,
559 BITFIELD_FIELD(unsigned int func : 6, 559 __BITFIELD_FIELD(unsigned int func : 6,
560 ;))))))) 560 ;)))))))
561}; 561};
562 562
563struct ma_format { /* FPU multiply and add format (MIPS IV) */ 563struct ma_format { /* FPU multiply and add format (MIPS IV) */
564 BITFIELD_FIELD(unsigned int opcode : 6, 564 __BITFIELD_FIELD(unsigned int opcode : 6,
565 BITFIELD_FIELD(unsigned int fr : 5, 565 __BITFIELD_FIELD(unsigned int fr : 5,
566 BITFIELD_FIELD(unsigned int ft : 5, 566 __BITFIELD_FIELD(unsigned int ft : 5,
567 BITFIELD_FIELD(unsigned int fs : 5, 567 __BITFIELD_FIELD(unsigned int fs : 5,
568 BITFIELD_FIELD(unsigned int fd : 5, 568 __BITFIELD_FIELD(unsigned int fd : 5,
569 BITFIELD_FIELD(unsigned int func : 4, 569 __BITFIELD_FIELD(unsigned int func : 4,
570 BITFIELD_FIELD(unsigned int fmt : 2, 570 __BITFIELD_FIELD(unsigned int fmt : 2,
571 ;))))))) 571 ;)))))))
572}; 572};
573 573
574struct b_format { /* BREAK and SYSCALL */ 574struct b_format { /* BREAK and SYSCALL */
575 BITFIELD_FIELD(unsigned int opcode : 6, 575 __BITFIELD_FIELD(unsigned int opcode : 6,
576 BITFIELD_FIELD(unsigned int code : 20, 576 __BITFIELD_FIELD(unsigned int code : 20,
577 BITFIELD_FIELD(unsigned int func : 6, 577 __BITFIELD_FIELD(unsigned int func : 6,
578 ;))) 578 ;)))
579}; 579};
580 580
581struct ps_format { /* MIPS-3D / paired single format */ 581struct ps_format { /* MIPS-3D / paired single format */
582 BITFIELD_FIELD(unsigned int opcode : 6, 582 __BITFIELD_FIELD(unsigned int opcode : 6,
583 BITFIELD_FIELD(unsigned int rs : 5, 583 __BITFIELD_FIELD(unsigned int rs : 5,
584 BITFIELD_FIELD(unsigned int ft : 5, 584 __BITFIELD_FIELD(unsigned int ft : 5,
585 BITFIELD_FIELD(unsigned int fs : 5, 585 __BITFIELD_FIELD(unsigned int fs : 5,
586 BITFIELD_FIELD(unsigned int fd : 5, 586 __BITFIELD_FIELD(unsigned int fd : 5,
587 BITFIELD_FIELD(unsigned int func : 6, 587 __BITFIELD_FIELD(unsigned int func : 6,
588 ;)))))) 588 ;))))))
589}; 589};
590 590
591struct v_format { /* MDMX vector format */ 591struct v_format { /* MDMX vector format */
592 BITFIELD_FIELD(unsigned int opcode : 6, 592 __BITFIELD_FIELD(unsigned int opcode : 6,
593 BITFIELD_FIELD(unsigned int sel : 4, 593 __BITFIELD_FIELD(unsigned int sel : 4,
594 BITFIELD_FIELD(unsigned int fmt : 1, 594 __BITFIELD_FIELD(unsigned int fmt : 1,
595 BITFIELD_FIELD(unsigned int vt : 5, 595 __BITFIELD_FIELD(unsigned int vt : 5,
596 BITFIELD_FIELD(unsigned int vs : 5, 596 __BITFIELD_FIELD(unsigned int vs : 5,
597 BITFIELD_FIELD(unsigned int vd : 5, 597 __BITFIELD_FIELD(unsigned int vd : 5,
598 BITFIELD_FIELD(unsigned int func : 6, 598 __BITFIELD_FIELD(unsigned int func : 6,
599 ;))))))) 599 ;)))))))
600}; 600};
601 601
602struct spec3_format { /* SPEC3 */ 602struct spec3_format { /* SPEC3 */
603 BITFIELD_FIELD(unsigned int opcode:6, 603 __BITFIELD_FIELD(unsigned int opcode:6,
604 BITFIELD_FIELD(unsigned int rs:5, 604 __BITFIELD_FIELD(unsigned int rs:5,
605 BITFIELD_FIELD(unsigned int rt:5, 605 __BITFIELD_FIELD(unsigned int rt:5,
606 BITFIELD_FIELD(signed int simmediate:9, 606 __BITFIELD_FIELD(signed int simmediate:9,
607 BITFIELD_FIELD(unsigned int func:7, 607 __BITFIELD_FIELD(unsigned int func:7,
608 ;))))) 608 ;)))))
609}; 609};
610 610
@@ -616,141 +616,141 @@ struct spec3_format { /* SPEC3 */
616 * if it is MIPS32 instruction re-encoded for use in the microMIPS ASE. 616 * if it is MIPS32 instruction re-encoded for use in the microMIPS ASE.
617 */ 617 */
618struct fb_format { /* FPU branch format (MIPS32) */ 618struct fb_format { /* FPU branch format (MIPS32) */
619 BITFIELD_FIELD(unsigned int opcode : 6, 619 __BITFIELD_FIELD(unsigned int opcode : 6,
620 BITFIELD_FIELD(unsigned int bc : 5, 620 __BITFIELD_FIELD(unsigned int bc : 5,
621 BITFIELD_FIELD(unsigned int cc : 3, 621 __BITFIELD_FIELD(unsigned int cc : 3,
622 BITFIELD_FIELD(unsigned int flag : 2, 622 __BITFIELD_FIELD(unsigned int flag : 2,
623 BITFIELD_FIELD(signed int simmediate : 16, 623 __BITFIELD_FIELD(signed int simmediate : 16,
624 ;))))) 624 ;)))))
625}; 625};
626 626
627struct fp0_format { /* FPU multiply and add format (MIPS32) */ 627struct fp0_format { /* FPU multiply and add format (MIPS32) */
628 BITFIELD_FIELD(unsigned int opcode : 6, 628 __BITFIELD_FIELD(unsigned int opcode : 6,
629 BITFIELD_FIELD(unsigned int fmt : 5, 629 __BITFIELD_FIELD(unsigned int fmt : 5,
630 BITFIELD_FIELD(unsigned int ft : 5, 630 __BITFIELD_FIELD(unsigned int ft : 5,
631 BITFIELD_FIELD(unsigned int fs : 5, 631 __BITFIELD_FIELD(unsigned int fs : 5,
632 BITFIELD_FIELD(unsigned int fd : 5, 632 __BITFIELD_FIELD(unsigned int fd : 5,
633 BITFIELD_FIELD(unsigned int func : 6, 633 __BITFIELD_FIELD(unsigned int func : 6,
634 ;)))))) 634 ;))))))
635}; 635};
636 636
637struct mm_fp0_format { /* FPU multipy and add format (microMIPS) */ 637struct mm_fp0_format { /* FPU multipy and add format (microMIPS) */
638 BITFIELD_FIELD(unsigned int opcode : 6, 638 __BITFIELD_FIELD(unsigned int opcode : 6,
639 BITFIELD_FIELD(unsigned int ft : 5, 639 __BITFIELD_FIELD(unsigned int ft : 5,
640 BITFIELD_FIELD(unsigned int fs : 5, 640 __BITFIELD_FIELD(unsigned int fs : 5,
641 BITFIELD_FIELD(unsigned int fd : 5, 641 __BITFIELD_FIELD(unsigned int fd : 5,
642 BITFIELD_FIELD(unsigned int fmt : 3, 642 __BITFIELD_FIELD(unsigned int fmt : 3,
643 BITFIELD_FIELD(unsigned int op : 2, 643 __BITFIELD_FIELD(unsigned int op : 2,
644 BITFIELD_FIELD(unsigned int func : 6, 644 __BITFIELD_FIELD(unsigned int func : 6,
645 ;))))))) 645 ;)))))))
646}; 646};
647 647
648struct fp1_format { /* FPU mfc1 and cfc1 format (MIPS32) */ 648struct fp1_format { /* FPU mfc1 and cfc1 format (MIPS32) */
649 BITFIELD_FIELD(unsigned int opcode : 6, 649 __BITFIELD_FIELD(unsigned int opcode : 6,
650 BITFIELD_FIELD(unsigned int op : 5, 650 __BITFIELD_FIELD(unsigned int op : 5,
651 BITFIELD_FIELD(unsigned int rt : 5, 651 __BITFIELD_FIELD(unsigned int rt : 5,
652 BITFIELD_FIELD(unsigned int fs : 5, 652 __BITFIELD_FIELD(unsigned int fs : 5,
653 BITFIELD_FIELD(unsigned int fd : 5, 653 __BITFIELD_FIELD(unsigned int fd : 5,
654 BITFIELD_FIELD(unsigned int func : 6, 654 __BITFIELD_FIELD(unsigned int func : 6,
655 ;)))))) 655 ;))))))
656}; 656};
657 657
658struct mm_fp1_format { /* FPU mfc1 and cfc1 format (microMIPS) */ 658struct mm_fp1_format { /* FPU mfc1 and cfc1 format (microMIPS) */
659 BITFIELD_FIELD(unsigned int opcode : 6, 659 __BITFIELD_FIELD(unsigned int opcode : 6,
660 BITFIELD_FIELD(unsigned int rt : 5, 660 __BITFIELD_FIELD(unsigned int rt : 5,
661 BITFIELD_FIELD(unsigned int fs : 5, 661 __BITFIELD_FIELD(unsigned int fs : 5,
662 BITFIELD_FIELD(unsigned int fmt : 2, 662 __BITFIELD_FIELD(unsigned int fmt : 2,
663 BITFIELD_FIELD(unsigned int op : 8, 663 __BITFIELD_FIELD(unsigned int op : 8,
664 BITFIELD_FIELD(unsigned int func : 6, 664 __BITFIELD_FIELD(unsigned int func : 6,
665 ;)))))) 665 ;))))))
666}; 666};
667 667
668struct mm_fp2_format { /* FPU movt and movf format (microMIPS) */ 668struct mm_fp2_format { /* FPU movt and movf format (microMIPS) */
669 BITFIELD_FIELD(unsigned int opcode : 6, 669 __BITFIELD_FIELD(unsigned int opcode : 6,
670 BITFIELD_FIELD(unsigned int fd : 5, 670 __BITFIELD_FIELD(unsigned int fd : 5,
671 BITFIELD_FIELD(unsigned int fs : 5, 671 __BITFIELD_FIELD(unsigned int fs : 5,
672 BITFIELD_FIELD(unsigned int cc : 3, 672 __BITFIELD_FIELD(unsigned int cc : 3,
673 BITFIELD_FIELD(unsigned int zero : 2, 673 __BITFIELD_FIELD(unsigned int zero : 2,
674 BITFIELD_FIELD(unsigned int fmt : 2, 674 __BITFIELD_FIELD(unsigned int fmt : 2,
675 BITFIELD_FIELD(unsigned int op : 3, 675 __BITFIELD_FIELD(unsigned int op : 3,
676 BITFIELD_FIELD(unsigned int func : 6, 676 __BITFIELD_FIELD(unsigned int func : 6,
677 ;)))))))) 677 ;))))))))
678}; 678};
679 679
680struct mm_fp3_format { /* FPU abs and neg format (microMIPS) */ 680struct mm_fp3_format { /* FPU abs and neg format (microMIPS) */
681 BITFIELD_FIELD(unsigned int opcode : 6, 681 __BITFIELD_FIELD(unsigned int opcode : 6,
682 BITFIELD_FIELD(unsigned int rt : 5, 682 __BITFIELD_FIELD(unsigned int rt : 5,
683 BITFIELD_FIELD(unsigned int fs : 5, 683 __BITFIELD_FIELD(unsigned int fs : 5,
684 BITFIELD_FIELD(unsigned int fmt : 3, 684 __BITFIELD_FIELD(unsigned int fmt : 3,
685 BITFIELD_FIELD(unsigned int op : 7, 685 __BITFIELD_FIELD(unsigned int op : 7,
686 BITFIELD_FIELD(unsigned int func : 6, 686 __BITFIELD_FIELD(unsigned int func : 6,
687 ;)))))) 687 ;))))))
688}; 688};
689 689
690struct mm_fp4_format { /* FPU c.cond format (microMIPS) */ 690struct mm_fp4_format { /* FPU c.cond format (microMIPS) */
691 BITFIELD_FIELD(unsigned int opcode : 6, 691 __BITFIELD_FIELD(unsigned int opcode : 6,
692 BITFIELD_FIELD(unsigned int rt : 5, 692 __BITFIELD_FIELD(unsigned int rt : 5,
693 BITFIELD_FIELD(unsigned int fs : 5, 693 __BITFIELD_FIELD(unsigned int fs : 5,
694 BITFIELD_FIELD(unsigned int cc : 3, 694 __BITFIELD_FIELD(unsigned int cc : 3,
695 BITFIELD_FIELD(unsigned int fmt : 3, 695 __BITFIELD_FIELD(unsigned int fmt : 3,
696 BITFIELD_FIELD(unsigned int cond : 4, 696 __BITFIELD_FIELD(unsigned int cond : 4,
697 BITFIELD_FIELD(unsigned int func : 6, 697 __BITFIELD_FIELD(unsigned int func : 6,
698 ;))))))) 698 ;)))))))
699}; 699};
700 700
701struct mm_fp5_format { /* FPU lwxc1 and swxc1 format (microMIPS) */ 701struct mm_fp5_format { /* FPU lwxc1 and swxc1 format (microMIPS) */
702 BITFIELD_FIELD(unsigned int opcode : 6, 702 __BITFIELD_FIELD(unsigned int opcode : 6,
703 BITFIELD_FIELD(unsigned int index : 5, 703 __BITFIELD_FIELD(unsigned int index : 5,
704 BITFIELD_FIELD(unsigned int base : 5, 704 __BITFIELD_FIELD(unsigned int base : 5,
705 BITFIELD_FIELD(unsigned int fd : 5, 705 __BITFIELD_FIELD(unsigned int fd : 5,
706 BITFIELD_FIELD(unsigned int op : 5, 706 __BITFIELD_FIELD(unsigned int op : 5,
707 BITFIELD_FIELD(unsigned int func : 6, 707 __BITFIELD_FIELD(unsigned int func : 6,
708 ;)))))) 708 ;))))))
709}; 709};
710 710
711struct fp6_format { /* FPU madd and msub format (MIPS IV) */ 711struct fp6_format { /* FPU madd and msub format (MIPS IV) */
712 BITFIELD_FIELD(unsigned int opcode : 6, 712 __BITFIELD_FIELD(unsigned int opcode : 6,
713 BITFIELD_FIELD(unsigned int fr : 5, 713 __BITFIELD_FIELD(unsigned int fr : 5,
714 BITFIELD_FIELD(unsigned int ft : 5, 714 __BITFIELD_FIELD(unsigned int ft : 5,
715 BITFIELD_FIELD(unsigned int fs : 5, 715 __BITFIELD_FIELD(unsigned int fs : 5,
716 BITFIELD_FIELD(unsigned int fd : 5, 716 __BITFIELD_FIELD(unsigned int fd : 5,
717 BITFIELD_FIELD(unsigned int func : 6, 717 __BITFIELD_FIELD(unsigned int func : 6,
718 ;)))))) 718 ;))))))
719}; 719};
720 720
721struct mm_fp6_format { /* FPU madd and msub format (microMIPS) */ 721struct mm_fp6_format { /* FPU madd and msub format (microMIPS) */
722 BITFIELD_FIELD(unsigned int opcode : 6, 722 __BITFIELD_FIELD(unsigned int opcode : 6,
723 BITFIELD_FIELD(unsigned int ft : 5, 723 __BITFIELD_FIELD(unsigned int ft : 5,
724 BITFIELD_FIELD(unsigned int fs : 5, 724 __BITFIELD_FIELD(unsigned int fs : 5,
725 BITFIELD_FIELD(unsigned int fd : 5, 725 __BITFIELD_FIELD(unsigned int fd : 5,
726 BITFIELD_FIELD(unsigned int fr : 5, 726 __BITFIELD_FIELD(unsigned int fr : 5,
727 BITFIELD_FIELD(unsigned int func : 6, 727 __BITFIELD_FIELD(unsigned int func : 6,
728 ;)))))) 728 ;))))))
729}; 729};
730 730
731struct mm_i_format { /* Immediate format (microMIPS) */ 731struct mm_i_format { /* Immediate format (microMIPS) */
732 BITFIELD_FIELD(unsigned int opcode : 6, 732 __BITFIELD_FIELD(unsigned int opcode : 6,
733 BITFIELD_FIELD(unsigned int rt : 5, 733 __BITFIELD_FIELD(unsigned int rt : 5,
734 BITFIELD_FIELD(unsigned int rs : 5, 734 __BITFIELD_FIELD(unsigned int rs : 5,
735 BITFIELD_FIELD(signed int simmediate : 16, 735 __BITFIELD_FIELD(signed int simmediate : 16,
736 ;)))) 736 ;))))
737}; 737};
738 738
739struct mm_m_format { /* Multi-word load/store format (microMIPS) */ 739struct mm_m_format { /* Multi-word load/store format (microMIPS) */
740 BITFIELD_FIELD(unsigned int opcode : 6, 740 __BITFIELD_FIELD(unsigned int opcode : 6,
741 BITFIELD_FIELD(unsigned int rd : 5, 741 __BITFIELD_FIELD(unsigned int rd : 5,
742 BITFIELD_FIELD(unsigned int base : 5, 742 __BITFIELD_FIELD(unsigned int base : 5,
743 BITFIELD_FIELD(unsigned int func : 4, 743 __BITFIELD_FIELD(unsigned int func : 4,
744 BITFIELD_FIELD(signed int simmediate : 12, 744 __BITFIELD_FIELD(signed int simmediate : 12,
745 ;))))) 745 ;)))))
746}; 746};
747 747
748struct mm_x_format { /* Scaled indexed load format (microMIPS) */ 748struct mm_x_format { /* Scaled indexed load format (microMIPS) */
749 BITFIELD_FIELD(unsigned int opcode : 6, 749 __BITFIELD_FIELD(unsigned int opcode : 6,
750 BITFIELD_FIELD(unsigned int index : 5, 750 __BITFIELD_FIELD(unsigned int index : 5,
751 BITFIELD_FIELD(unsigned int base : 5, 751 __BITFIELD_FIELD(unsigned int base : 5,
752 BITFIELD_FIELD(unsigned int rd : 5, 752 __BITFIELD_FIELD(unsigned int rd : 5,
753 BITFIELD_FIELD(unsigned int func : 11, 753 __BITFIELD_FIELD(unsigned int func : 11,
754 ;))))) 754 ;)))))
755}; 755};
756 756
@@ -758,51 +758,51 @@ struct mm_x_format { /* Scaled indexed load format (microMIPS) */
758 * microMIPS instruction formats (16-bit length) 758 * microMIPS instruction formats (16-bit length)
759 */ 759 */
760struct mm_b0_format { /* Unconditional branch format (microMIPS) */ 760struct mm_b0_format { /* Unconditional branch format (microMIPS) */
761 BITFIELD_FIELD(unsigned int opcode : 6, 761 __BITFIELD_FIELD(unsigned int opcode : 6,
762 BITFIELD_FIELD(signed int simmediate : 10, 762 __BITFIELD_FIELD(signed int simmediate : 10,
763 BITFIELD_FIELD(unsigned int : 16, /* Ignored */ 763 __BITFIELD_FIELD(unsigned int : 16, /* Ignored */
764 ;))) 764 ;)))
765}; 765};
766 766
767struct mm_b1_format { /* Conditional branch format (microMIPS) */ 767struct mm_b1_format { /* Conditional branch format (microMIPS) */
768 BITFIELD_FIELD(unsigned int opcode : 6, 768 __BITFIELD_FIELD(unsigned int opcode : 6,
769 BITFIELD_FIELD(unsigned int rs : 3, 769 __BITFIELD_FIELD(unsigned int rs : 3,
770 BITFIELD_FIELD(signed int simmediate : 7, 770 __BITFIELD_FIELD(signed int simmediate : 7,
771 BITFIELD_FIELD(unsigned int : 16, /* Ignored */ 771 __BITFIELD_FIELD(unsigned int : 16, /* Ignored */
772 ;)))) 772 ;))))
773}; 773};
774 774
775struct mm16_m_format { /* Multi-word load/store format */ 775struct mm16_m_format { /* Multi-word load/store format */
776 BITFIELD_FIELD(unsigned int opcode : 6, 776 __BITFIELD_FIELD(unsigned int opcode : 6,
777 BITFIELD_FIELD(unsigned int func : 4, 777 __BITFIELD_FIELD(unsigned int func : 4,
778 BITFIELD_FIELD(unsigned int rlist : 2, 778 __BITFIELD_FIELD(unsigned int rlist : 2,
779 BITFIELD_FIELD(unsigned int imm : 4, 779 __BITFIELD_FIELD(unsigned int imm : 4,
780 BITFIELD_FIELD(unsigned int : 16, /* Ignored */ 780 __BITFIELD_FIELD(unsigned int : 16, /* Ignored */
781 ;))))) 781 ;)))))
782}; 782};
783 783
784struct mm16_rb_format { /* Signed immediate format */ 784struct mm16_rb_format { /* Signed immediate format */
785 BITFIELD_FIELD(unsigned int opcode : 6, 785 __BITFIELD_FIELD(unsigned int opcode : 6,
786 BITFIELD_FIELD(unsigned int rt : 3, 786 __BITFIELD_FIELD(unsigned int rt : 3,
787 BITFIELD_FIELD(unsigned int base : 3, 787 __BITFIELD_FIELD(unsigned int base : 3,
788 BITFIELD_FIELD(signed int simmediate : 4, 788 __BITFIELD_FIELD(signed int simmediate : 4,
789 BITFIELD_FIELD(unsigned int : 16, /* Ignored */ 789 __BITFIELD_FIELD(unsigned int : 16, /* Ignored */
790 ;))))) 790 ;)))))
791}; 791};
792 792
793struct mm16_r3_format { /* Load from global pointer format */ 793struct mm16_r3_format { /* Load from global pointer format */
794 BITFIELD_FIELD(unsigned int opcode : 6, 794 __BITFIELD_FIELD(unsigned int opcode : 6,
795 BITFIELD_FIELD(unsigned int rt : 3, 795 __BITFIELD_FIELD(unsigned int rt : 3,
796 BITFIELD_FIELD(signed int simmediate : 7, 796 __BITFIELD_FIELD(signed int simmediate : 7,
797 BITFIELD_FIELD(unsigned int : 16, /* Ignored */ 797 __BITFIELD_FIELD(unsigned int : 16, /* Ignored */
798 ;)))) 798 ;))))
799}; 799};
800 800
801struct mm16_r5_format { /* Load/store from stack pointer format */ 801struct mm16_r5_format { /* Load/store from stack pointer format */
802 BITFIELD_FIELD(unsigned int opcode : 6, 802 __BITFIELD_FIELD(unsigned int opcode : 6,
803 BITFIELD_FIELD(unsigned int rt : 5, 803 __BITFIELD_FIELD(unsigned int rt : 5,
804 BITFIELD_FIELD(signed int simmediate : 5, 804 __BITFIELD_FIELD(signed int simmediate : 5,
805 BITFIELD_FIELD(unsigned int : 16, /* Ignored */ 805 __BITFIELD_FIELD(unsigned int : 16, /* Ignored */
806 ;)))) 806 ;))))
807}; 807};
808 808
@@ -810,57 +810,57 @@ struct mm16_r5_format { /* Load/store from stack pointer format */
810 * MIPS16e instruction formats (16-bit length) 810 * MIPS16e instruction formats (16-bit length)
811 */ 811 */
812struct m16e_rr { 812struct m16e_rr {
813 BITFIELD_FIELD(unsigned int opcode : 5, 813 __BITFIELD_FIELD(unsigned int opcode : 5,
814 BITFIELD_FIELD(unsigned int rx : 3, 814 __BITFIELD_FIELD(unsigned int rx : 3,
815 BITFIELD_FIELD(unsigned int nd : 1, 815 __BITFIELD_FIELD(unsigned int nd : 1,
816 BITFIELD_FIELD(unsigned int l : 1, 816 __BITFIELD_FIELD(unsigned int l : 1,
817 BITFIELD_FIELD(unsigned int ra : 1, 817 __BITFIELD_FIELD(unsigned int ra : 1,
818 BITFIELD_FIELD(unsigned int func : 5, 818 __BITFIELD_FIELD(unsigned int func : 5,
819 ;)))))) 819 ;))))))
820}; 820};
821 821
822struct m16e_jal { 822struct m16e_jal {
823 BITFIELD_FIELD(unsigned int opcode : 5, 823 __BITFIELD_FIELD(unsigned int opcode : 5,
824 BITFIELD_FIELD(unsigned int x : 1, 824 __BITFIELD_FIELD(unsigned int x : 1,
825 BITFIELD_FIELD(unsigned int imm20_16 : 5, 825 __BITFIELD_FIELD(unsigned int imm20_16 : 5,
826 BITFIELD_FIELD(signed int imm25_21 : 5, 826 __BITFIELD_FIELD(signed int imm25_21 : 5,
827 ;)))) 827 ;))))
828}; 828};
829 829
830struct m16e_i64 { 830struct m16e_i64 {
831 BITFIELD_FIELD(unsigned int opcode : 5, 831 __BITFIELD_FIELD(unsigned int opcode : 5,
832 BITFIELD_FIELD(unsigned int func : 3, 832 __BITFIELD_FIELD(unsigned int func : 3,
833 BITFIELD_FIELD(unsigned int imm : 8, 833 __BITFIELD_FIELD(unsigned int imm : 8,
834 ;))) 834 ;)))
835}; 835};
836 836
837struct m16e_ri64 { 837struct m16e_ri64 {
838 BITFIELD_FIELD(unsigned int opcode : 5, 838 __BITFIELD_FIELD(unsigned int opcode : 5,
839 BITFIELD_FIELD(unsigned int func : 3, 839 __BITFIELD_FIELD(unsigned int func : 3,
840 BITFIELD_FIELD(unsigned int ry : 3, 840 __BITFIELD_FIELD(unsigned int ry : 3,
841 BITFIELD_FIELD(unsigned int imm : 5, 841 __BITFIELD_FIELD(unsigned int imm : 5,
842 ;)))) 842 ;))))
843}; 843};
844 844
845struct m16e_ri { 845struct m16e_ri {
846 BITFIELD_FIELD(unsigned int opcode : 5, 846 __BITFIELD_FIELD(unsigned int opcode : 5,
847 BITFIELD_FIELD(unsigned int rx : 3, 847 __BITFIELD_FIELD(unsigned int rx : 3,
848 BITFIELD_FIELD(unsigned int imm : 8, 848 __BITFIELD_FIELD(unsigned int imm : 8,
849 ;))) 849 ;)))
850}; 850};
851 851
852struct m16e_rri { 852struct m16e_rri {
853 BITFIELD_FIELD(unsigned int opcode : 5, 853 __BITFIELD_FIELD(unsigned int opcode : 5,
854 BITFIELD_FIELD(unsigned int rx : 3, 854 __BITFIELD_FIELD(unsigned int rx : 3,
855 BITFIELD_FIELD(unsigned int ry : 3, 855 __BITFIELD_FIELD(unsigned int ry : 3,
856 BITFIELD_FIELD(unsigned int imm : 5, 856 __BITFIELD_FIELD(unsigned int imm : 5,
857 ;)))) 857 ;))))
858}; 858};
859 859
860struct m16e_i8 { 860struct m16e_i8 {
861 BITFIELD_FIELD(unsigned int opcode : 5, 861 __BITFIELD_FIELD(unsigned int opcode : 5,
862 BITFIELD_FIELD(unsigned int func : 3, 862 __BITFIELD_FIELD(unsigned int func : 3,
863 BITFIELD_FIELD(unsigned int imm : 8, 863 __BITFIELD_FIELD(unsigned int imm : 8,
864 ;))) 864 ;)))
865}; 865};
866 866
diff --git a/arch/mips/include/uapi/asm/unistd.h b/arch/mips/include/uapi/asm/unistd.h
index d6e154a9e6a5..2692abb28e36 100644
--- a/arch/mips/include/uapi/asm/unistd.h
+++ b/arch/mips/include/uapi/asm/unistd.h
@@ -371,11 +371,12 @@
371#define __NR_finit_module (__NR_Linux + 348) 371#define __NR_finit_module (__NR_Linux + 348)
372#define __NR_sched_setattr (__NR_Linux + 349) 372#define __NR_sched_setattr (__NR_Linux + 349)
373#define __NR_sched_getattr (__NR_Linux + 350) 373#define __NR_sched_getattr (__NR_Linux + 350)
374#define __NR_renameat2 (__NR_Linux + 351)
374 375
375/* 376/*
376 * Offset of the last Linux o32 flavoured syscall 377 * Offset of the last Linux o32 flavoured syscall
377 */ 378 */
378#define __NR_Linux_syscalls 350 379#define __NR_Linux_syscalls 351
379 380
380#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */ 381#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
381 382
@@ -699,11 +700,12 @@
699#define __NR_getdents64 (__NR_Linux + 308) 700#define __NR_getdents64 (__NR_Linux + 308)
700#define __NR_sched_setattr (__NR_Linux + 309) 701#define __NR_sched_setattr (__NR_Linux + 309)
701#define __NR_sched_getattr (__NR_Linux + 310) 702#define __NR_sched_getattr (__NR_Linux + 310)
703#define __NR_renameat2 (__NR_Linux + 311)
702 704
703/* 705/*
704 * Offset of the last Linux 64-bit flavoured syscall 706 * Offset of the last Linux 64-bit flavoured syscall
705 */ 707 */
706#define __NR_Linux_syscalls 310 708#define __NR_Linux_syscalls 311
707 709
708#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */ 710#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
709 711
@@ -1031,11 +1033,12 @@
1031#define __NR_finit_module (__NR_Linux + 312) 1033#define __NR_finit_module (__NR_Linux + 312)
1032#define __NR_sched_setattr (__NR_Linux + 313) 1034#define __NR_sched_setattr (__NR_Linux + 313)
1033#define __NR_sched_getattr (__NR_Linux + 314) 1035#define __NR_sched_getattr (__NR_Linux + 314)
1036#define __NR_renameat2 (__NR_Linux + 315)
1034 1037
1035/* 1038/*
1036 * Offset of the last N32 flavoured syscall 1039 * Offset of the last N32 flavoured syscall
1037 */ 1040 */
1038#define __NR_Linux_syscalls 314 1041#define __NR_Linux_syscalls 315
1039 1042
1040#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */ 1043#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
1041 1044
diff --git a/arch/mips/kernel/proc.c b/arch/mips/kernel/proc.c
index e40971b51d2f..037a44d962f3 100644
--- a/arch/mips/kernel/proc.c
+++ b/arch/mips/kernel/proc.c
@@ -124,14 +124,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
124 seq_printf(m, "kscratch registers\t: %d\n", 124 seq_printf(m, "kscratch registers\t: %d\n",
125 hweight8(cpu_data[n].kscratch_mask)); 125 hweight8(cpu_data[n].kscratch_mask));
126 seq_printf(m, "core\t\t\t: %d\n", cpu_data[n].core); 126 seq_printf(m, "core\t\t\t: %d\n", cpu_data[n].core);
127#if defined(CONFIG_MIPS_MT_SMP) || defined(CONFIG_MIPS_MT_SMTC) 127
128 if (cpu_has_mipsmt) {
129 seq_printf(m, "VPE\t\t\t: %d\n", cpu_data[n].vpe_id);
130#if defined(CONFIG_MIPS_MT_SMTC)
131 seq_printf(m, "TC\t\t\t: %d\n", cpu_data[n].tc_id);
132#endif
133 }
134#endif
135 sprintf(fmt, "VCE%%c exceptions\t\t: %s\n", 128 sprintf(fmt, "VCE%%c exceptions\t\t: %s\n",
136 cpu_has_vce ? "%u" : "not available"); 129 cpu_has_vce ? "%u" : "not available");
137 seq_printf(m, fmt, 'D', vced_count); 130 seq_printf(m, fmt, 'D', vced_count);
diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
index fdc70b400442..3245474f19d5 100644
--- a/arch/mips/kernel/scall32-o32.S
+++ b/arch/mips/kernel/scall32-o32.S
@@ -577,3 +577,4 @@ EXPORT(sys_call_table)
577 PTR sys_finit_module 577 PTR sys_finit_module
578 PTR sys_sched_setattr 578 PTR sys_sched_setattr
579 PTR sys_sched_getattr /* 4350 */ 579 PTR sys_sched_getattr /* 4350 */
580 PTR sys_renameat2
diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
index dd99c3285aea..be2fedd4ae33 100644
--- a/arch/mips/kernel/scall64-64.S
+++ b/arch/mips/kernel/scall64-64.S
@@ -430,4 +430,5 @@ EXPORT(sys_call_table)
430 PTR sys_getdents64 430 PTR sys_getdents64
431 PTR sys_sched_setattr 431 PTR sys_sched_setattr
432 PTR sys_sched_getattr /* 5310 */ 432 PTR sys_sched_getattr /* 5310 */
433 PTR sys_renameat2
433 .size sys_call_table,.-sys_call_table 434 .size sys_call_table,.-sys_call_table
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index f68d2f4f0090..c1dbcda4b816 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -423,4 +423,5 @@ EXPORT(sysn32_call_table)
423 PTR sys_finit_module 423 PTR sys_finit_module
424 PTR sys_sched_setattr 424 PTR sys_sched_setattr
425 PTR sys_sched_getattr 425 PTR sys_sched_getattr
426 PTR sys_renameat2 /* 6315 */
426 .size sysn32_call_table,.-sysn32_call_table 427 .size sysn32_call_table,.-sysn32_call_table
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index 70f6acecd928..f1343ccd7ed7 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -556,4 +556,5 @@ EXPORT(sys32_call_table)
556 PTR sys_finit_module 556 PTR sys_finit_module
557 PTR sys_sched_setattr 557 PTR sys_sched_setattr
558 PTR sys_sched_getattr /* 4350 */ 558 PTR sys_sched_getattr /* 4350 */
559 PTR sys_renameat2
559 .size sys32_call_table,.-sys32_call_table 560 .size sys32_call_table,.-sys32_call_table
diff --git a/arch/mips/lantiq/dts/easy50712.dts b/arch/mips/lantiq/dts/easy50712.dts
index fac1f5b178eb..143b8a37b5e4 100644
--- a/arch/mips/lantiq/dts/easy50712.dts
+++ b/arch/mips/lantiq/dts/easy50712.dts
@@ -8,6 +8,7 @@
8 }; 8 };
9 9
10 memory@0 { 10 memory@0 {
11 device_type = "memory";
11 reg = <0x0 0x2000000>; 12 reg = <0x0 0x2000000>;
12 }; 13 };
13 14
diff --git a/arch/mips/lib/csum_partial.S b/arch/mips/lib/csum_partial.S
index 2e4825e48388..9901237563c5 100644
--- a/arch/mips/lib/csum_partial.S
+++ b/arch/mips/lib/csum_partial.S
@@ -56,14 +56,20 @@
56#define UNIT(unit) ((unit)*NBYTES) 56#define UNIT(unit) ((unit)*NBYTES)
57 57
58#define ADDC(sum,reg) \ 58#define ADDC(sum,reg) \
59 .set push; \
60 .set noat; \
59 ADD sum, reg; \ 61 ADD sum, reg; \
60 sltu v1, sum, reg; \ 62 sltu v1, sum, reg; \
61 ADD sum, v1; \ 63 ADD sum, v1; \
64 .set pop
62 65
63#define ADDC32(sum,reg) \ 66#define ADDC32(sum,reg) \
67 .set push; \
68 .set noat; \
64 addu sum, reg; \ 69 addu sum, reg; \
65 sltu v1, sum, reg; \ 70 sltu v1, sum, reg; \
66 addu sum, v1; \ 71 addu sum, v1; \
72 .set pop
67 73
68#define CSUM_BIGCHUNK1(src, offset, sum, _t0, _t1, _t2, _t3) \ 74#define CSUM_BIGCHUNK1(src, offset, sum, _t0, _t1, _t2, _t3) \
69 LOAD _t0, (offset + UNIT(0))(src); \ 75 LOAD _t0, (offset + UNIT(0))(src); \
@@ -710,6 +716,8 @@ LEAF(csum_partial)
710 ADDC(sum, t2) 716 ADDC(sum, t2)
711.Ldone\@: 717.Ldone\@:
712 /* fold checksum */ 718 /* fold checksum */
719 .set push
720 .set noat
713#ifdef USE_DOUBLE 721#ifdef USE_DOUBLE
714 dsll32 v1, sum, 0 722 dsll32 v1, sum, 0
715 daddu sum, v1 723 daddu sum, v1
@@ -732,6 +740,7 @@ LEAF(csum_partial)
732 or sum, sum, t0 740 or sum, sum, t0
7331: 7411:
734#endif 742#endif
743 .set pop
735 .set reorder 744 .set reorder
736 ADDC32(sum, psum) 745 ADDC32(sum, psum)
737 jr ra 746 jr ra
diff --git a/arch/mips/lib/delay.c b/arch/mips/lib/delay.c
index 44713af15a62..705cfb7c1a74 100644
--- a/arch/mips/lib/delay.c
+++ b/arch/mips/lib/delay.c
@@ -6,7 +6,7 @@
6 * Copyright (C) 1994 by Waldorf Electronics 6 * Copyright (C) 1994 by Waldorf Electronics
7 * Copyright (C) 1995 - 2000, 01, 03 by Ralf Baechle 7 * Copyright (C) 1995 - 2000, 01, 03 by Ralf Baechle
8 * Copyright (C) 1999, 2000 Silicon Graphics, Inc. 8 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
9 * Copyright (C) 2007 Maciej W. Rozycki 9 * Copyright (C) 2007, 2014 Maciej W. Rozycki
10 */ 10 */
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/param.h> 12#include <linux/param.h>
@@ -15,6 +15,12 @@
15#include <asm/compiler.h> 15#include <asm/compiler.h>
16#include <asm/war.h> 16#include <asm/war.h>
17 17
18#ifndef CONFIG_CPU_DADDI_WORKAROUNDS
19#define GCC_DADDI_IMM_ASM() "I"
20#else
21#define GCC_DADDI_IMM_ASM() "r"
22#endif
23
18void __delay(unsigned long loops) 24void __delay(unsigned long loops)
19{ 25{
20 __asm__ __volatile__ ( 26 __asm__ __volatile__ (
@@ -22,13 +28,13 @@ void __delay(unsigned long loops)
22 " .align 3 \n" 28 " .align 3 \n"
23 "1: bnez %0, 1b \n" 29 "1: bnez %0, 1b \n"
24#if BITS_PER_LONG == 32 30#if BITS_PER_LONG == 32
25 " subu %0, 1 \n" 31 " subu %0, %1 \n"
26#else 32#else
27 " dsubu %0, 1 \n" 33 " dsubu %0, %1 \n"
28#endif 34#endif
29 " .set reorder \n" 35 " .set reorder \n"
30 : "=r" (loops) 36 : "=r" (loops)
31 : "0" (loops)); 37 : GCC_DADDI_IMM_ASM() (1), "0" (loops));
32} 38}
33EXPORT_SYMBOL(__delay); 39EXPORT_SYMBOL(__delay);
34 40
diff --git a/arch/mips/lib/strncpy_user.S b/arch/mips/lib/strncpy_user.S
index d3301cd1e9a5..3c32baf8b494 100644
--- a/arch/mips/lib/strncpy_user.S
+++ b/arch/mips/lib/strncpy_user.S
@@ -35,7 +35,6 @@ LEAF(__strncpy_from_\func\()_asm)
35 bnez v0, .Lfault\@ 35 bnez v0, .Lfault\@
36 36
37FEXPORT(__strncpy_from_\func\()_nocheck_asm) 37FEXPORT(__strncpy_from_\func\()_nocheck_asm)
38 .set noreorder
39 move t0, zero 38 move t0, zero
40 move v1, a1 39 move v1, a1
41.ifeqs "\func","kernel" 40.ifeqs "\func","kernel"
@@ -45,21 +44,21 @@ FEXPORT(__strncpy_from_\func\()_nocheck_asm)
45.endif 44.endif
46 PTR_ADDIU v1, 1 45 PTR_ADDIU v1, 1
47 R10KCBARRIER(0(ra)) 46 R10KCBARRIER(0(ra))
47 sb v0, (a0)
48 beqz v0, 2f 48 beqz v0, 2f
49 sb v0, (a0)
50 PTR_ADDIU t0, 1 49 PTR_ADDIU t0, 1
50 PTR_ADDIU a0, 1
51 bne t0, a2, 1b 51 bne t0, a2, 1b
52 PTR_ADDIU a0, 1
532: PTR_ADDU v0, a1, t0 522: PTR_ADDU v0, a1, t0
54 xor v0, a1 53 xor v0, a1
55 bltz v0, .Lfault\@ 54 bltz v0, .Lfault\@
56 nop 55 move v0, t0
57 jr ra # return n 56 jr ra # return n
58 move v0, t0
59 END(__strncpy_from_\func\()_asm) 57 END(__strncpy_from_\func\()_asm)
60 58
61.Lfault\@: jr ra 59.Lfault\@:
62 li v0, -EFAULT 60 li v0, -EFAULT
61 jr ra
63 62
64 .section __ex_table,"a" 63 .section __ex_table,"a"
65 PTR 1b, .Lfault\@ 64 PTR 1b, .Lfault\@
diff --git a/arch/mips/loongson/Kconfig b/arch/mips/loongson/Kconfig
index 7397be226a06..603d79a95f47 100644
--- a/arch/mips/loongson/Kconfig
+++ b/arch/mips/loongson/Kconfig
@@ -64,7 +64,6 @@ config LEMOTE_MACH3A
64 bool "Lemote Loongson 3A family machines" 64 bool "Lemote Loongson 3A family machines"
65 select ARCH_SPARSEMEM_ENABLE 65 select ARCH_SPARSEMEM_ENABLE
66 select GENERIC_ISA_DMA_SUPPORT_BROKEN 66 select GENERIC_ISA_DMA_SUPPORT_BROKEN
67 select GENERIC_HARDIRQS_NO__DO_IRQ
68 select BOOT_ELF32 67 select BOOT_ELF32
69 select BOARD_SCACHE 68 select BOARD_SCACHE
70 select CSRC_R4K 69 select CSRC_R4K
diff --git a/arch/mips/loongson/lemote-2f/clock.c b/arch/mips/loongson/lemote-2f/clock.c
index e1f427f4f5f3..67dd94ef28e6 100644
--- a/arch/mips/loongson/lemote-2f/clock.c
+++ b/arch/mips/loongson/lemote-2f/clock.c
@@ -91,6 +91,7 @@ EXPORT_SYMBOL(clk_put);
91 91
92int clk_set_rate(struct clk *clk, unsigned long rate) 92int clk_set_rate(struct clk *clk, unsigned long rate)
93{ 93{
94 unsigned int rate_khz = rate / 1000;
94 int ret = 0; 95 int ret = 0;
95 int regval; 96 int regval;
96 int i; 97 int i;
@@ -111,10 +112,10 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
111 if (loongson2_clockmod_table[i].frequency == 112 if (loongson2_clockmod_table[i].frequency ==
112 CPUFREQ_ENTRY_INVALID) 113 CPUFREQ_ENTRY_INVALID)
113 continue; 114 continue;
114 if (rate == loongson2_clockmod_table[i].frequency) 115 if (rate_khz == loongson2_clockmod_table[i].frequency)
115 break; 116 break;
116 } 117 }
117 if (rate != loongson2_clockmod_table[i].frequency) 118 if (rate_khz != loongson2_clockmod_table[i].frequency)
118 return -ENOTSUPP; 119 return -ENOTSUPP;
119 120
120 clk->rate = rate; 121 clk->rate = rate;
diff --git a/arch/mips/mm/tlb-funcs.S b/arch/mips/mm/tlb-funcs.S
index 30a494db99c2..a5427c6e9757 100644
--- a/arch/mips/mm/tlb-funcs.S
+++ b/arch/mips/mm/tlb-funcs.S
@@ -16,8 +16,10 @@
16 16
17#define FASTPATH_SIZE 128 17#define FASTPATH_SIZE 128
18 18
19EXPORT(tlbmiss_handler_setup_pgd_start)
19LEAF(tlbmiss_handler_setup_pgd) 20LEAF(tlbmiss_handler_setup_pgd)
20 .space 16 * 4 211: j 1b /* Dummy, will be replaced. */
22 .space 64
21END(tlbmiss_handler_setup_pgd) 23END(tlbmiss_handler_setup_pgd)
22EXPORT(tlbmiss_handler_setup_pgd_end) 24EXPORT(tlbmiss_handler_setup_pgd_end)
23 25
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
index ee88367ab3ad..f99ec587b151 100644
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -1422,16 +1422,17 @@ static void build_r4000_tlb_refill_handler(void)
1422extern u32 handle_tlbl[], handle_tlbl_end[]; 1422extern u32 handle_tlbl[], handle_tlbl_end[];
1423extern u32 handle_tlbs[], handle_tlbs_end[]; 1423extern u32 handle_tlbs[], handle_tlbs_end[];
1424extern u32 handle_tlbm[], handle_tlbm_end[]; 1424extern u32 handle_tlbm[], handle_tlbm_end[];
1425extern u32 tlbmiss_handler_setup_pgd[], tlbmiss_handler_setup_pgd_end[]; 1425extern u32 tlbmiss_handler_setup_pgd_start[], tlbmiss_handler_setup_pgd[];
1426extern u32 tlbmiss_handler_setup_pgd_end[];
1426 1427
1427static void build_setup_pgd(void) 1428static void build_setup_pgd(void)
1428{ 1429{
1429 const int a0 = 4; 1430 const int a0 = 4;
1430 const int __maybe_unused a1 = 5; 1431 const int __maybe_unused a1 = 5;
1431 const int __maybe_unused a2 = 6; 1432 const int __maybe_unused a2 = 6;
1432 u32 *p = tlbmiss_handler_setup_pgd; 1433 u32 *p = tlbmiss_handler_setup_pgd_start;
1433 const int tlbmiss_handler_setup_pgd_size = 1434 const int tlbmiss_handler_setup_pgd_size =
1434 tlbmiss_handler_setup_pgd_end - tlbmiss_handler_setup_pgd; 1435 tlbmiss_handler_setup_pgd_end - tlbmiss_handler_setup_pgd_start;
1435#ifndef CONFIG_MIPS_PGD_C0_CONTEXT 1436#ifndef CONFIG_MIPS_PGD_C0_CONTEXT
1436 long pgdc = (long)pgd_current; 1437 long pgdc = (long)pgd_current;
1437#endif 1438#endif
diff --git a/arch/mips/ralink/dts/mt7620a_eval.dts b/arch/mips/ralink/dts/mt7620a_eval.dts
index 35eb874ab7f1..709f58132f5c 100644
--- a/arch/mips/ralink/dts/mt7620a_eval.dts
+++ b/arch/mips/ralink/dts/mt7620a_eval.dts
@@ -7,6 +7,7 @@
7 model = "Ralink MT7620A evaluation board"; 7 model = "Ralink MT7620A evaluation board";
8 8
9 memory@0 { 9 memory@0 {
10 device_type = "memory";
10 reg = <0x0 0x2000000>; 11 reg = <0x0 0x2000000>;
11 }; 12 };
12 13
diff --git a/arch/mips/ralink/dts/rt2880_eval.dts b/arch/mips/ralink/dts/rt2880_eval.dts
index 322d7002595b..0a685db093d4 100644
--- a/arch/mips/ralink/dts/rt2880_eval.dts
+++ b/arch/mips/ralink/dts/rt2880_eval.dts
@@ -7,6 +7,7 @@
7 model = "Ralink RT2880 evaluation board"; 7 model = "Ralink RT2880 evaluation board";
8 8
9 memory@0 { 9 memory@0 {
10 device_type = "memory";
10 reg = <0x8000000 0x2000000>; 11 reg = <0x8000000 0x2000000>;
11 }; 12 };
12 13
diff --git a/arch/mips/ralink/dts/rt3052_eval.dts b/arch/mips/ralink/dts/rt3052_eval.dts
index 0ac73ea28198..ec9e9a035541 100644
--- a/arch/mips/ralink/dts/rt3052_eval.dts
+++ b/arch/mips/ralink/dts/rt3052_eval.dts
@@ -7,6 +7,7 @@
7 model = "Ralink RT3052 evaluation board"; 7 model = "Ralink RT3052 evaluation board";
8 8
9 memory@0 { 9 memory@0 {
10 device_type = "memory";
10 reg = <0x0 0x2000000>; 11 reg = <0x0 0x2000000>;
11 }; 12 };
12 13
diff --git a/arch/mips/ralink/dts/rt3883_eval.dts b/arch/mips/ralink/dts/rt3883_eval.dts
index 2fa6b330bf4f..e8df21a5d10d 100644
--- a/arch/mips/ralink/dts/rt3883_eval.dts
+++ b/arch/mips/ralink/dts/rt3883_eval.dts
@@ -7,6 +7,7 @@
7 model = "Ralink RT3883 evaluation board"; 7 model = "Ralink RT3883 evaluation board";
8 8
9 memory@0 { 9 memory@0 {
10 device_type = "memory";
10 reg = <0x0 0x2000000>; 11 reg = <0x0 0x2000000>;
11 }; 12 };
12 13
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index 1faefed32749..108d48e652af 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -22,6 +22,7 @@ config PARISC
22 select GENERIC_SMP_IDLE_THREAD 22 select GENERIC_SMP_IDLE_THREAD
23 select GENERIC_STRNCPY_FROM_USER 23 select GENERIC_STRNCPY_FROM_USER
24 select SYSCTL_ARCH_UNALIGN_ALLOW 24 select SYSCTL_ARCH_UNALIGN_ALLOW
25 select SYSCTL_EXCEPTION_TRACE
25 select HAVE_MOD_ARCH_SPECIFIC 26 select HAVE_MOD_ARCH_SPECIFIC
26 select VIRT_TO_BUS 27 select VIRT_TO_BUS
27 select MODULES_USE_ELF_RELA 28 select MODULES_USE_ELF_RELA
diff --git a/arch/parisc/include/asm/processor.h b/arch/parisc/include/asm/processor.h
index 198a86feb574..d951c9681ab3 100644
--- a/arch/parisc/include/asm/processor.h
+++ b/arch/parisc/include/asm/processor.h
@@ -55,6 +55,11 @@
55#define STACK_TOP TASK_SIZE 55#define STACK_TOP TASK_SIZE
56#define STACK_TOP_MAX DEFAULT_TASK_SIZE 56#define STACK_TOP_MAX DEFAULT_TASK_SIZE
57 57
58/* Allow bigger stacks for 64-bit processes */
59#define STACK_SIZE_MAX (USER_WIDE_MODE \
60 ? (1 << 30) /* 1 GB */ \
61 : (CONFIG_MAX_STACK_SIZE_MB*1024*1024))
62
58#endif 63#endif
59 64
60#ifndef __ASSEMBLY__ 65#ifndef __ASSEMBLY__
diff --git a/arch/parisc/include/uapi/asm/unistd.h b/arch/parisc/include/uapi/asm/unistd.h
index 265ae5190b0a..47e0e21d2272 100644
--- a/arch/parisc/include/uapi/asm/unistd.h
+++ b/arch/parisc/include/uapi/asm/unistd.h
@@ -829,8 +829,9 @@
829#define __NR_sched_setattr (__NR_Linux + 334) 829#define __NR_sched_setattr (__NR_Linux + 334)
830#define __NR_sched_getattr (__NR_Linux + 335) 830#define __NR_sched_getattr (__NR_Linux + 335)
831#define __NR_utimes (__NR_Linux + 336) 831#define __NR_utimes (__NR_Linux + 336)
832#define __NR_renameat2 (__NR_Linux + 337)
832 833
833#define __NR_Linux_syscalls (__NR_utimes + 1) 834#define __NR_Linux_syscalls (__NR_renameat2 + 1)
834 835
835 836
836#define __IGNORE_select /* newselect */ 837#define __IGNORE_select /* newselect */
diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
index 31ffa9b55322..e1ffea2f9a0b 100644
--- a/arch/parisc/kernel/sys_parisc.c
+++ b/arch/parisc/kernel/sys_parisc.c
@@ -72,10 +72,10 @@ static unsigned long mmap_upper_limit(void)
72{ 72{
73 unsigned long stack_base; 73 unsigned long stack_base;
74 74
75 /* Limit stack size to 1GB - see setup_arg_pages() in fs/exec.c */ 75 /* Limit stack size - see setup_arg_pages() in fs/exec.c */
76 stack_base = rlimit_max(RLIMIT_STACK); 76 stack_base = rlimit_max(RLIMIT_STACK);
77 if (stack_base > (1 << 30)) 77 if (stack_base > STACK_SIZE_MAX)
78 stack_base = 1 << 30; 78 stack_base = STACK_SIZE_MAX;
79 79
80 return PAGE_ALIGN(STACK_TOP - stack_base); 80 return PAGE_ALIGN(STACK_TOP - stack_base);
81} 81}
diff --git a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S
index a63bb179f79a..838786011037 100644
--- a/arch/parisc/kernel/syscall.S
+++ b/arch/parisc/kernel/syscall.S
@@ -589,10 +589,13 @@ cas_nocontend:
589# endif 589# endif
590/* ENABLE_LWS_DEBUG */ 590/* ENABLE_LWS_DEBUG */
591 591
592 rsm PSW_SM_I, %r0 /* Disable interrupts */
593 /* COW breaks can cause contention on UP systems */
592 LDCW 0(%sr2,%r20), %r28 /* Try to acquire the lock */ 594 LDCW 0(%sr2,%r20), %r28 /* Try to acquire the lock */
593 cmpb,<>,n %r0, %r28, cas_action /* Did we get it? */ 595 cmpb,<>,n %r0, %r28, cas_action /* Did we get it? */
594cas_wouldblock: 596cas_wouldblock:
595 ldo 2(%r0), %r28 /* 2nd case */ 597 ldo 2(%r0), %r28 /* 2nd case */
598 ssm PSW_SM_I, %r0
596 b lws_exit /* Contended... */ 599 b lws_exit /* Contended... */
597 ldo -EAGAIN(%r0), %r21 /* Spin in userspace */ 600 ldo -EAGAIN(%r0), %r21 /* Spin in userspace */
598 601
@@ -619,15 +622,17 @@ cas_action:
619 stw %r1, 4(%sr2,%r20) 622 stw %r1, 4(%sr2,%r20)
620#endif 623#endif
621 /* The load and store could fail */ 624 /* The load and store could fail */
6221: ldw 0(%sr3,%r26), %r28 6251: ldw,ma 0(%sr3,%r26), %r28
623 sub,<> %r28, %r25, %r0 626 sub,<> %r28, %r25, %r0
6242: stw %r24, 0(%sr3,%r26) 6272: stw,ma %r24, 0(%sr3,%r26)
625 /* Free lock */ 628 /* Free lock */
626 stw %r20, 0(%sr2,%r20) 629 stw,ma %r20, 0(%sr2,%r20)
627#if ENABLE_LWS_DEBUG 630#if ENABLE_LWS_DEBUG
628 /* Clear thread register indicator */ 631 /* Clear thread register indicator */
629 stw %r0, 4(%sr2,%r20) 632 stw %r0, 4(%sr2,%r20)
630#endif 633#endif
634 /* Enable interrupts */
635 ssm PSW_SM_I, %r0
631 /* Return to userspace, set no error */ 636 /* Return to userspace, set no error */
632 b lws_exit 637 b lws_exit
633 copy %r0, %r21 638 copy %r0, %r21
@@ -639,6 +644,7 @@ cas_action:
639#if ENABLE_LWS_DEBUG 644#if ENABLE_LWS_DEBUG
640 stw %r0, 4(%sr2,%r20) 645 stw %r0, 4(%sr2,%r20)
641#endif 646#endif
647 ssm PSW_SM_I, %r0
642 b lws_exit 648 b lws_exit
643 ldo -EFAULT(%r0),%r21 /* set errno */ 649 ldo -EFAULT(%r0),%r21 /* set errno */
644 nop 650 nop
diff --git a/arch/parisc/kernel/syscall_table.S b/arch/parisc/kernel/syscall_table.S
index 83ead0ea127d..f1432da7b4c0 100644
--- a/arch/parisc/kernel/syscall_table.S
+++ b/arch/parisc/kernel/syscall_table.S
@@ -432,6 +432,7 @@
432 ENTRY_SAME(sched_setattr) 432 ENTRY_SAME(sched_setattr)
433 ENTRY_SAME(sched_getattr) /* 335 */ 433 ENTRY_SAME(sched_getattr) /* 335 */
434 ENTRY_COMP(utimes) 434 ENTRY_COMP(utimes)
435 ENTRY_COMP(renameat2)
435 436
436 /* Nothing yet */ 437 /* Nothing yet */
437 438
diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
index 1cd1d0c83b6d..47ee620d15d2 100644
--- a/arch/parisc/kernel/traps.c
+++ b/arch/parisc/kernel/traps.c
@@ -25,6 +25,7 @@
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/console.h> 26#include <linux/console.h>
27#include <linux/bug.h> 27#include <linux/bug.h>
28#include <linux/ratelimit.h>
28 29
29#include <asm/assembly.h> 30#include <asm/assembly.h>
30#include <asm/uaccess.h> 31#include <asm/uaccess.h>
@@ -42,9 +43,6 @@
42 43
43#include "../math-emu/math-emu.h" /* for handle_fpe() */ 44#include "../math-emu/math-emu.h" /* for handle_fpe() */
44 45
45#define PRINT_USER_FAULTS /* (turn this on if you want user faults to be */
46 /* dumped to the console via printk) */
47
48#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) 46#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
49DEFINE_SPINLOCK(pa_dbit_lock); 47DEFINE_SPINLOCK(pa_dbit_lock);
50#endif 48#endif
@@ -160,6 +158,17 @@ void show_regs(struct pt_regs *regs)
160 } 158 }
161} 159}
162 160
161static DEFINE_RATELIMIT_STATE(_hppa_rs,
162 DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST);
163
164#define parisc_printk_ratelimited(critical, regs, fmt, ...) { \
165 if ((critical || show_unhandled_signals) && __ratelimit(&_hppa_rs)) { \
166 printk(fmt, ##__VA_ARGS__); \
167 show_regs(regs); \
168 } \
169}
170
171
163static void do_show_stack(struct unwind_frame_info *info) 172static void do_show_stack(struct unwind_frame_info *info)
164{ 173{
165 int i = 1; 174 int i = 1;
@@ -229,12 +238,10 @@ void die_if_kernel(char *str, struct pt_regs *regs, long err)
229 if (err == 0) 238 if (err == 0)
230 return; /* STFU */ 239 return; /* STFU */
231 240
232 printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n", 241 parisc_printk_ratelimited(1, regs,
242 KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
233 current->comm, task_pid_nr(current), str, err, regs->iaoq[0]); 243 current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
234#ifdef PRINT_USER_FAULTS 244
235 /* XXX for debugging only */
236 show_regs(regs);
237#endif
238 return; 245 return;
239 } 246 }
240 247
@@ -321,14 +328,11 @@ static void handle_break(struct pt_regs *regs)
321 (tt == BUG_TRAP_TYPE_NONE) ? 9 : 0); 328 (tt == BUG_TRAP_TYPE_NONE) ? 9 : 0);
322 } 329 }
323 330
324#ifdef PRINT_USER_FAULTS 331 if (unlikely(iir != GDB_BREAK_INSN))
325 if (unlikely(iir != GDB_BREAK_INSN)) { 332 parisc_printk_ratelimited(0, regs,
326 printk(KERN_DEBUG "break %d,%d: pid=%d command='%s'\n", 333 KERN_DEBUG "break %d,%d: pid=%d command='%s'\n",
327 iir & 31, (iir>>13) & ((1<<13)-1), 334 iir & 31, (iir>>13) & ((1<<13)-1),
328 task_pid_nr(current), current->comm); 335 task_pid_nr(current), current->comm);
329 show_regs(regs);
330 }
331#endif
332 336
333 /* send standard GDB signal */ 337 /* send standard GDB signal */
334 handle_gdb_break(regs, TRAP_BRKPT); 338 handle_gdb_break(regs, TRAP_BRKPT);
@@ -758,11 +762,9 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
758 762
759 default: 763 default:
760 if (user_mode(regs)) { 764 if (user_mode(regs)) {
761#ifdef PRINT_USER_FAULTS 765 parisc_printk_ratelimited(0, regs, KERN_DEBUG
762 printk(KERN_DEBUG "\nhandle_interruption() pid=%d command='%s'\n", 766 "handle_interruption() pid=%d command='%s'\n",
763 task_pid_nr(current), current->comm); 767 task_pid_nr(current), current->comm);
764 show_regs(regs);
765#endif
766 /* SIGBUS, for lack of a better one. */ 768 /* SIGBUS, for lack of a better one. */
767 si.si_signo = SIGBUS; 769 si.si_signo = SIGBUS;
768 si.si_code = BUS_OBJERR; 770 si.si_code = BUS_OBJERR;
@@ -779,16 +781,10 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
779 781
780 if (user_mode(regs)) { 782 if (user_mode(regs)) {
781 if ((fault_space >> SPACEID_SHIFT) != (regs->sr[7] >> SPACEID_SHIFT)) { 783 if ((fault_space >> SPACEID_SHIFT) != (regs->sr[7] >> SPACEID_SHIFT)) {
782#ifdef PRINT_USER_FAULTS 784 parisc_printk_ratelimited(0, regs, KERN_DEBUG
783 if (fault_space == 0) 785 "User fault %d on space 0x%08lx, pid=%d command='%s'\n",
784 printk(KERN_DEBUG "User Fault on Kernel Space "); 786 code, fault_space,
785 else 787 task_pid_nr(current), current->comm);
786 printk(KERN_DEBUG "User Fault (long pointer) (fault %d) ",
787 code);
788 printk(KERN_CONT "pid=%d command='%s'\n",
789 task_pid_nr(current), current->comm);
790 show_regs(regs);
791#endif
792 si.si_signo = SIGSEGV; 788 si.si_signo = SIGSEGV;
793 si.si_errno = 0; 789 si.si_errno = 0;
794 si.si_code = SEGV_MAPERR; 790 si.si_code = SEGV_MAPERR;
diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
index 747550762f3c..3ca9c1131cfe 100644
--- a/arch/parisc/mm/fault.c
+++ b/arch/parisc/mm/fault.c
@@ -19,10 +19,6 @@
19#include <asm/uaccess.h> 19#include <asm/uaccess.h>
20#include <asm/traps.h> 20#include <asm/traps.h>
21 21
22#define PRINT_USER_FAULTS /* (turn this on if you want user faults to be */
23 /* dumped to the console via printk) */
24
25
26/* Various important other fields */ 22/* Various important other fields */
27#define bit22set(x) (x & 0x00000200) 23#define bit22set(x) (x & 0x00000200)
28#define bits23_25set(x) (x & 0x000001c0) 24#define bits23_25set(x) (x & 0x000001c0)
@@ -34,6 +30,8 @@
34 30
35DEFINE_PER_CPU(struct exception_data, exception_data); 31DEFINE_PER_CPU(struct exception_data, exception_data);
36 32
33int show_unhandled_signals = 1;
34
37/* 35/*
38 * parisc_acctyp(unsigned int inst) -- 36 * parisc_acctyp(unsigned int inst) --
39 * Given a PA-RISC memory access instruction, determine if the 37 * Given a PA-RISC memory access instruction, determine if the
@@ -173,6 +171,32 @@ int fixup_exception(struct pt_regs *regs)
173 return 0; 171 return 0;
174} 172}
175 173
174/*
175 * Print out info about fatal segfaults, if the show_unhandled_signals
176 * sysctl is set:
177 */
178static inline void
179show_signal_msg(struct pt_regs *regs, unsigned long code,
180 unsigned long address, struct task_struct *tsk,
181 struct vm_area_struct *vma)
182{
183 if (!unhandled_signal(tsk, SIGSEGV))
184 return;
185
186 if (!printk_ratelimit())
187 return;
188
189 pr_warn("\n");
190 pr_warn("do_page_fault() command='%s' type=%lu address=0x%08lx",
191 tsk->comm, code, address);
192 print_vma_addr(KERN_CONT " in ", regs->iaoq[0]);
193 if (vma)
194 pr_warn(" vm_start = 0x%08lx, vm_end = 0x%08lx\n",
195 vma->vm_start, vma->vm_end);
196
197 show_regs(regs);
198}
199
176void do_page_fault(struct pt_regs *regs, unsigned long code, 200void do_page_fault(struct pt_regs *regs, unsigned long code,
177 unsigned long address) 201 unsigned long address)
178{ 202{
@@ -270,16 +294,8 @@ bad_area:
270 if (user_mode(regs)) { 294 if (user_mode(regs)) {
271 struct siginfo si; 295 struct siginfo si;
272 296
273#ifdef PRINT_USER_FAULTS 297 show_signal_msg(regs, code, address, tsk, vma);
274 printk(KERN_DEBUG "\n"); 298
275 printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
276 task_pid_nr(tsk), tsk->comm, code, address);
277 if (vma) {
278 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
279 vma->vm_start, vma->vm_end);
280 }
281 show_regs(regs);
282#endif
283 switch (code) { 299 switch (code) {
284 case 15: /* Data TLB miss fault/Data page fault */ 300 case 15: /* Data TLB miss fault/Data page fault */
285 /* send SIGSEGV when outside of vma */ 301 /* send SIGSEGV when outside of vma */
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 122a580f7322..7e711bdcc6da 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -813,9 +813,6 @@ static void __init clocksource_init(void)
813static int decrementer_set_next_event(unsigned long evt, 813static int decrementer_set_next_event(unsigned long evt,
814 struct clock_event_device *dev) 814 struct clock_event_device *dev)
815{ 815{
816 /* Don't adjust the decrementer if some irq work is pending */
817 if (test_irq_work_pending())
818 return 0;
819 __get_cpu_var(decrementers_next_tb) = get_tb_or_rtc() + evt; 816 __get_cpu_var(decrementers_next_tb) = get_tb_or_rtc() + evt;
820 set_dec(evt); 817 set_dec(evt);
821 818
diff --git a/arch/powerpc/platforms/powernv/eeh-ioda.c b/arch/powerpc/platforms/powernv/eeh-ioda.c
index 253fefe3d1a0..5b51079f3e3b 100644
--- a/arch/powerpc/platforms/powernv/eeh-ioda.c
+++ b/arch/powerpc/platforms/powernv/eeh-ioda.c
@@ -549,7 +549,8 @@ static int ioda_eeh_reset(struct eeh_pe *pe, int option)
549 ret = ioda_eeh_phb_reset(hose, option); 549 ret = ioda_eeh_phb_reset(hose, option);
550 } else { 550 } else {
551 bus = eeh_pe_bus_get(pe); 551 bus = eeh_pe_bus_get(pe);
552 if (pci_is_root_bus(bus)) 552 if (pci_is_root_bus(bus) ||
553 pci_is_root_bus(bus->parent))
553 ret = ioda_eeh_root_reset(hose, option); 554 ret = ioda_eeh_root_reset(hose, option);
554 else 555 else
555 ret = ioda_eeh_bridge_reset(hose, bus->self, option); 556 ret = ioda_eeh_bridge_reset(hose, bus->self, option);
diff --git a/arch/s390/crypto/aes_s390.c b/arch/s390/crypto/aes_s390.c
index cf3c0089bef2..23223cd63e54 100644
--- a/arch/s390/crypto/aes_s390.c
+++ b/arch/s390/crypto/aes_s390.c
@@ -820,6 +820,9 @@ static int ctr_aes_crypt(struct blkcipher_desc *desc, long func,
820 else 820 else
821 memcpy(walk->iv, ctrptr, AES_BLOCK_SIZE); 821 memcpy(walk->iv, ctrptr, AES_BLOCK_SIZE);
822 spin_unlock(&ctrblk_lock); 822 spin_unlock(&ctrblk_lock);
823 } else {
824 if (!nbytes)
825 memcpy(walk->iv, ctrptr, AES_BLOCK_SIZE);
823 } 826 }
824 /* 827 /*
825 * final block may be < AES_BLOCK_SIZE, copy only nbytes 828 * final block may be < AES_BLOCK_SIZE, copy only nbytes
diff --git a/arch/s390/crypto/des_s390.c b/arch/s390/crypto/des_s390.c
index 0a5aac8a9412..7acb77f7ef1a 100644
--- a/arch/s390/crypto/des_s390.c
+++ b/arch/s390/crypto/des_s390.c
@@ -429,6 +429,9 @@ static int ctr_desall_crypt(struct blkcipher_desc *desc, long func,
429 else 429 else
430 memcpy(walk->iv, ctrptr, DES_BLOCK_SIZE); 430 memcpy(walk->iv, ctrptr, DES_BLOCK_SIZE);
431 spin_unlock(&ctrblk_lock); 431 spin_unlock(&ctrblk_lock);
432 } else {
433 if (!nbytes)
434 memcpy(walk->iv, ctrptr, DES_BLOCK_SIZE);
432 } 435 }
433 /* final block may be < DES_BLOCK_SIZE, copy only nbytes */ 436 /* final block may be < DES_BLOCK_SIZE, copy only nbytes */
434 if (nbytes) { 437 if (nbytes) {
diff --git a/drivers/Makefile b/drivers/Makefile
index d05d81b19b50..7183b6af5dac 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -119,7 +119,7 @@ obj-$(CONFIG_SGI_SN) += sn/
119obj-y += firmware/ 119obj-y += firmware/
120obj-$(CONFIG_CRYPTO) += crypto/ 120obj-$(CONFIG_CRYPTO) += crypto/
121obj-$(CONFIG_SUPERH) += sh/ 121obj-$(CONFIG_SUPERH) += sh/
122obj-$(CONFIG_ARCH_SHMOBILE_LEGACY) += sh/ 122obj-$(CONFIG_ARCH_SHMOBILE) += sh/
123ifndef CONFIG_ARCH_USES_GETTIMEOFFSET 123ifndef CONFIG_ARCH_USES_GETTIMEOFFSET
124obj-y += clocksource/ 124obj-y += clocksource/
125endif 125endif
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index ab686b310100..a34a22841002 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -47,6 +47,23 @@ config ACPI_SLEEP
47 depends on SUSPEND || HIBERNATION 47 depends on SUSPEND || HIBERNATION
48 default y 48 default y
49 49
50config ACPI_PROCFS_POWER
51 bool "Deprecated power /proc/acpi directories"
52 depends on PROC_FS
53 help
54 For backwards compatibility, this option allows
55 deprecated power /proc/acpi/ directories to exist, even when
56 they have been replaced by functions in /sys.
57 The deprecated directories (and their replacements) include:
58 /proc/acpi/battery/* (/sys/class/power_supply/*)
59 /proc/acpi/ac_adapter/* (sys/class/power_supply/*)
60 This option has no effect on /proc/acpi/ directories
61 and functions, which do not yet exist in /sys
62 This option, together with the proc directories, will be
63 deleted in the future.
64
65 Say N to delete power /proc/acpi/ directories that have moved to /sys/
66
50config ACPI_EC_DEBUGFS 67config ACPI_EC_DEBUGFS
51 tristate "EC read/write access through /sys/kernel/debug/ec" 68 tristate "EC read/write access through /sys/kernel/debug/ec"
52 default n 69 default n
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 0331f91d56e6..bce34afadcd0 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -47,6 +47,7 @@ acpi-y += sysfs.o
47acpi-$(CONFIG_X86) += acpi_cmos_rtc.o 47acpi-$(CONFIG_X86) += acpi_cmos_rtc.o
48acpi-$(CONFIG_DEBUG_FS) += debugfs.o 48acpi-$(CONFIG_DEBUG_FS) += debugfs.o
49acpi-$(CONFIG_ACPI_NUMA) += numa.o 49acpi-$(CONFIG_ACPI_NUMA) += numa.o
50acpi-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o
50ifdef CONFIG_ACPI_VIDEO 51ifdef CONFIG_ACPI_VIDEO
51acpi-y += video_detect.o 52acpi-y += video_detect.o
52endif 53endif
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index 2c01c1da29ce..c67f6f5ad611 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -52,11 +52,39 @@ MODULE_AUTHOR("Paul Diefenbaugh");
52MODULE_DESCRIPTION("ACPI AC Adapter Driver"); 52MODULE_DESCRIPTION("ACPI AC Adapter Driver");
53MODULE_LICENSE("GPL"); 53MODULE_LICENSE("GPL");
54 54
55static int acpi_ac_add(struct acpi_device *device);
56static int acpi_ac_remove(struct acpi_device *device);
57static void acpi_ac_notify(struct acpi_device *device, u32 event);
58
59static const struct acpi_device_id ac_device_ids[] = {
60 {"ACPI0003", 0},
61 {"", 0},
62};
63MODULE_DEVICE_TABLE(acpi, ac_device_ids);
64
65#ifdef CONFIG_PM_SLEEP
66static int acpi_ac_resume(struct device *dev);
67#endif
68static SIMPLE_DEV_PM_OPS(acpi_ac_pm, NULL, acpi_ac_resume);
69
55static int ac_sleep_before_get_state_ms; 70static int ac_sleep_before_get_state_ms;
56 71
72static struct acpi_driver acpi_ac_driver = {
73 .name = "ac",
74 .class = ACPI_AC_CLASS,
75 .ids = ac_device_ids,
76 .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
77 .ops = {
78 .add = acpi_ac_add,
79 .remove = acpi_ac_remove,
80 .notify = acpi_ac_notify,
81 },
82 .drv.pm = &acpi_ac_pm,
83};
84
57struct acpi_ac { 85struct acpi_ac {
58 struct power_supply charger; 86 struct power_supply charger;
59 struct platform_device *pdev; 87 struct acpi_device * device;
60 unsigned long long state; 88 unsigned long long state;
61 struct notifier_block battery_nb; 89 struct notifier_block battery_nb;
62}; 90};
@@ -69,10 +97,12 @@ struct acpi_ac {
69 97
70static int acpi_ac_get_state(struct acpi_ac *ac) 98static int acpi_ac_get_state(struct acpi_ac *ac)
71{ 99{
72 acpi_status status; 100 acpi_status status = AE_OK;
73 acpi_handle handle = ACPI_HANDLE(&ac->pdev->dev); 101
102 if (!ac)
103 return -EINVAL;
74 104
75 status = acpi_evaluate_integer(handle, "_PSR", NULL, 105 status = acpi_evaluate_integer(ac->device->handle, "_PSR", NULL,
76 &ac->state); 106 &ac->state);
77 if (ACPI_FAILURE(status)) { 107 if (ACPI_FAILURE(status)) {
78 ACPI_EXCEPTION((AE_INFO, status, 108 ACPI_EXCEPTION((AE_INFO, status,
@@ -117,10 +147,9 @@ static enum power_supply_property ac_props[] = {
117 Driver Model 147 Driver Model
118 -------------------------------------------------------------------------- */ 148 -------------------------------------------------------------------------- */
119 149
120static void acpi_ac_notify_handler(acpi_handle handle, u32 event, void *data) 150static void acpi_ac_notify(struct acpi_device *device, u32 event)
121{ 151{
122 struct acpi_ac *ac = data; 152 struct acpi_ac *ac = acpi_driver_data(device);
123 struct acpi_device *adev;
124 153
125 if (!ac) 154 if (!ac)
126 return; 155 return;
@@ -143,11 +172,10 @@ static void acpi_ac_notify_handler(acpi_handle handle, u32 event, void *data)
143 msleep(ac_sleep_before_get_state_ms); 172 msleep(ac_sleep_before_get_state_ms);
144 173
145 acpi_ac_get_state(ac); 174 acpi_ac_get_state(ac);
146 adev = ACPI_COMPANION(&ac->pdev->dev); 175 acpi_bus_generate_netlink_event(device->pnp.device_class,
147 acpi_bus_generate_netlink_event(adev->pnp.device_class, 176 dev_name(&device->dev), event,
148 dev_name(&ac->pdev->dev), 177 (u32) ac->state);
149 event, (u32) ac->state); 178 acpi_notifier_call_chain(device, event, (u32) ac->state);
150 acpi_notifier_call_chain(adev, event, (u32) ac->state);
151 kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE); 179 kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE);
152 } 180 }
153 181
@@ -192,49 +220,39 @@ static struct dmi_system_id ac_dmi_table[] = {
192 {}, 220 {},
193}; 221};
194 222
195static int acpi_ac_probe(struct platform_device *pdev) 223static int acpi_ac_add(struct acpi_device *device)
196{ 224{
197 int result = 0; 225 int result = 0;
198 struct acpi_ac *ac = NULL; 226 struct acpi_ac *ac = NULL;
199 struct acpi_device *adev;
200 227
201 if (!pdev)
202 return -EINVAL;
203 228
204 adev = ACPI_COMPANION(&pdev->dev); 229 if (!device)
205 if (!adev) 230 return -EINVAL;
206 return -ENODEV;
207 231
208 ac = kzalloc(sizeof(struct acpi_ac), GFP_KERNEL); 232 ac = kzalloc(sizeof(struct acpi_ac), GFP_KERNEL);
209 if (!ac) 233 if (!ac)
210 return -ENOMEM; 234 return -ENOMEM;
211 235
212 strcpy(acpi_device_name(adev), ACPI_AC_DEVICE_NAME); 236 ac->device = device;
213 strcpy(acpi_device_class(adev), ACPI_AC_CLASS); 237 strcpy(acpi_device_name(device), ACPI_AC_DEVICE_NAME);
214 ac->pdev = pdev; 238 strcpy(acpi_device_class(device), ACPI_AC_CLASS);
215 platform_set_drvdata(pdev, ac); 239 device->driver_data = ac;
216 240
217 result = acpi_ac_get_state(ac); 241 result = acpi_ac_get_state(ac);
218 if (result) 242 if (result)
219 goto end; 243 goto end;
220 244
221 ac->charger.name = acpi_device_bid(adev); 245 ac->charger.name = acpi_device_bid(device);
222 ac->charger.type = POWER_SUPPLY_TYPE_MAINS; 246 ac->charger.type = POWER_SUPPLY_TYPE_MAINS;
223 ac->charger.properties = ac_props; 247 ac->charger.properties = ac_props;
224 ac->charger.num_properties = ARRAY_SIZE(ac_props); 248 ac->charger.num_properties = ARRAY_SIZE(ac_props);
225 ac->charger.get_property = get_ac_property; 249 ac->charger.get_property = get_ac_property;
226 result = power_supply_register(&pdev->dev, &ac->charger); 250 result = power_supply_register(&ac->device->dev, &ac->charger);
227 if (result) 251 if (result)
228 goto end; 252 goto end;
229 253
230 result = acpi_install_notify_handler(ACPI_HANDLE(&pdev->dev),
231 ACPI_ALL_NOTIFY, acpi_ac_notify_handler, ac);
232 if (result) {
233 power_supply_unregister(&ac->charger);
234 goto end;
235 }
236 printk(KERN_INFO PREFIX "%s [%s] (%s)\n", 254 printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
237 acpi_device_name(adev), acpi_device_bid(adev), 255 acpi_device_name(device), acpi_device_bid(device),
238 ac->state ? "on-line" : "off-line"); 256 ac->state ? "on-line" : "off-line");
239 257
240 ac->battery_nb.notifier_call = acpi_ac_battery_notify; 258 ac->battery_nb.notifier_call = acpi_ac_battery_notify;
@@ -256,7 +274,7 @@ static int acpi_ac_resume(struct device *dev)
256 if (!dev) 274 if (!dev)
257 return -EINVAL; 275 return -EINVAL;
258 276
259 ac = platform_get_drvdata(to_platform_device(dev)); 277 ac = acpi_driver_data(to_acpi_device(dev));
260 if (!ac) 278 if (!ac)
261 return -EINVAL; 279 return -EINVAL;
262 280
@@ -270,19 +288,17 @@ static int acpi_ac_resume(struct device *dev)
270#else 288#else
271#define acpi_ac_resume NULL 289#define acpi_ac_resume NULL
272#endif 290#endif
273static SIMPLE_DEV_PM_OPS(acpi_ac_pm_ops, NULL, acpi_ac_resume);
274 291
275static int acpi_ac_remove(struct platform_device *pdev) 292static int acpi_ac_remove(struct acpi_device *device)
276{ 293{
277 struct acpi_ac *ac; 294 struct acpi_ac *ac = NULL;
295
278 296
279 if (!pdev) 297 if (!device || !acpi_driver_data(device))
280 return -EINVAL; 298 return -EINVAL;
281 299
282 acpi_remove_notify_handler(ACPI_HANDLE(&pdev->dev), 300 ac = acpi_driver_data(device);
283 ACPI_ALL_NOTIFY, acpi_ac_notify_handler);
284 301
285 ac = platform_get_drvdata(pdev);
286 if (ac->charger.dev) 302 if (ac->charger.dev)
287 power_supply_unregister(&ac->charger); 303 power_supply_unregister(&ac->charger);
288 unregister_acpi_notifier(&ac->battery_nb); 304 unregister_acpi_notifier(&ac->battery_nb);
@@ -292,23 +308,6 @@ static int acpi_ac_remove(struct platform_device *pdev)
292 return 0; 308 return 0;
293} 309}
294 310
295static const struct acpi_device_id acpi_ac_match[] = {
296 { "ACPI0003", 0 },
297 { }
298};
299MODULE_DEVICE_TABLE(acpi, acpi_ac_match);
300
301static struct platform_driver acpi_ac_driver = {
302 .probe = acpi_ac_probe,
303 .remove = acpi_ac_remove,
304 .driver = {
305 .name = "acpi-ac",
306 .owner = THIS_MODULE,
307 .pm = &acpi_ac_pm_ops,
308 .acpi_match_table = ACPI_PTR(acpi_ac_match),
309 },
310};
311
312static int __init acpi_ac_init(void) 311static int __init acpi_ac_init(void)
313{ 312{
314 int result; 313 int result;
@@ -316,7 +315,7 @@ static int __init acpi_ac_init(void)
316 if (acpi_disabled) 315 if (acpi_disabled)
317 return -ENODEV; 316 return -ENODEV;
318 317
319 result = platform_driver_register(&acpi_ac_driver); 318 result = acpi_bus_register_driver(&acpi_ac_driver);
320 if (result < 0) 319 if (result < 0)
321 return -ENODEV; 320 return -ENODEV;
322 321
@@ -325,7 +324,7 @@ static int __init acpi_ac_init(void)
325 324
326static void __exit acpi_ac_exit(void) 325static void __exit acpi_ac_exit(void)
327{ 326{
328 platform_driver_unregister(&acpi_ac_driver); 327 acpi_bus_unregister_driver(&acpi_ac_driver);
329} 328}
330module_init(acpi_ac_init); 329module_init(acpi_ac_init);
331module_exit(acpi_ac_exit); 330module_exit(acpi_ac_exit);
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index dbfe49e5fd63..1d4950388fa1 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -29,7 +29,6 @@ ACPI_MODULE_NAME("platform");
29static const struct acpi_device_id acpi_platform_device_ids[] = { 29static const struct acpi_device_id acpi_platform_device_ids[] = {
30 30
31 { "PNP0D40" }, 31 { "PNP0D40" },
32 { "ACPI0003" },
33 { "VPC2004" }, 32 { "VPC2004" },
34 { "BCM4752" }, 33 { "BCM4752" },
35 34
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index b06f5f55ada9..52c81c49cc7d 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -405,7 +405,6 @@ static int acpi_processor_add(struct acpi_device *device,
405 goto err; 405 goto err;
406 406
407 pr->dev = dev; 407 pr->dev = dev;
408 dev->offline = pr->flags.need_hotplug_init;
409 408
410 /* Trigger the processor driver's .probe() if present. */ 409 /* Trigger the processor driver's .probe() if present. */
411 if (device_attach(dev) >= 0) 410 if (device_attach(dev) >= 0)
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 49bbc71fad54..a08a448068dd 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -141,9 +141,9 @@ ACPI_INIT_GLOBAL(u8, acpi_gbl_do_not_use_xsdt, FALSE);
141 * address. Although ACPICA adheres to the ACPI specification which 141 * address. Although ACPICA adheres to the ACPI specification which
142 * requires the use of the corresponding 64-bit address if it is non-zero, 142 * requires the use of the corresponding 64-bit address if it is non-zero,
143 * some machines have been found to have a corrupted non-zero 64-bit 143 * some machines have been found to have a corrupted non-zero 64-bit
144 * address. Default is FALSE, do not favor the 32-bit addresses. 144 * address. Default is TRUE, favor the 32-bit addresses.
145 */ 145 */
146ACPI_INIT_GLOBAL(u8, acpi_gbl_use32_bit_fadt_addresses, FALSE); 146ACPI_INIT_GLOBAL(u8, acpi_gbl_use32_bit_fadt_addresses, TRUE);
147 147
148/* 148/*
149 * Optionally truncate I/O addresses to 16 bits. Provides compatibility 149 * Optionally truncate I/O addresses to 16 bits. Provides compatibility
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index a4702eee91a8..9fb85f38de90 100644
--- a/drivers/acpi/acpica/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -461,6 +461,7 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
461 u32 table_count; 461 u32 table_count;
462 struct acpi_table_header *table; 462 struct acpi_table_header *table;
463 acpi_physical_address address; 463 acpi_physical_address address;
464 acpi_physical_address rsdt_address;
464 u32 length; 465 u32 length;
465 u8 *table_entry; 466 u8 *table_entry;
466 acpi_status status; 467 acpi_status status;
@@ -488,11 +489,14 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
488 * as per the ACPI specification. 489 * as per the ACPI specification.
489 */ 490 */
490 address = (acpi_physical_address) rsdp->xsdt_physical_address; 491 address = (acpi_physical_address) rsdp->xsdt_physical_address;
492 rsdt_address =
493 (acpi_physical_address) rsdp->rsdt_physical_address;
491 table_entry_size = ACPI_XSDT_ENTRY_SIZE; 494 table_entry_size = ACPI_XSDT_ENTRY_SIZE;
492 } else { 495 } else {
493 /* Root table is an RSDT (32-bit physical addresses) */ 496 /* Root table is an RSDT (32-bit physical addresses) */
494 497
495 address = (acpi_physical_address) rsdp->rsdt_physical_address; 498 address = (acpi_physical_address) rsdp->rsdt_physical_address;
499 rsdt_address = address;
496 table_entry_size = ACPI_RSDT_ENTRY_SIZE; 500 table_entry_size = ACPI_RSDT_ENTRY_SIZE;
497 } 501 }
498 502
@@ -515,8 +519,7 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
515 519
516 /* Fall back to the RSDT */ 520 /* Fall back to the RSDT */
517 521
518 address = 522 address = rsdt_address;
519 (acpi_physical_address) rsdp->rsdt_physical_address;
520 table_entry_size = ACPI_RSDT_ENTRY_SIZE; 523 table_entry_size = ACPI_RSDT_ENTRY_SIZE;
521 } 524 }
522 } 525 }
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 9a2c63b20050..6e7b2a12860d 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -36,6 +36,12 @@
36#include <linux/suspend.h> 36#include <linux/suspend.h>
37#include <asm/unaligned.h> 37#include <asm/unaligned.h>
38 38
39#ifdef CONFIG_ACPI_PROCFS_POWER
40#include <linux/proc_fs.h>
41#include <linux/seq_file.h>
42#include <asm/uaccess.h>
43#endif
44
39#include <linux/acpi.h> 45#include <linux/acpi.h>
40#include <linux/power_supply.h> 46#include <linux/power_supply.h>
41 47
@@ -64,6 +70,19 @@ static unsigned int cache_time = 1000;
64module_param(cache_time, uint, 0644); 70module_param(cache_time, uint, 0644);
65MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); 71MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
66 72
73#ifdef CONFIG_ACPI_PROCFS_POWER
74extern struct proc_dir_entry *acpi_lock_battery_dir(void);
75extern void *acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir);
76
77enum acpi_battery_files {
78 info_tag = 0,
79 state_tag,
80 alarm_tag,
81 ACPI_BATTERY_NUMFILES,
82};
83
84#endif
85
67static const struct acpi_device_id battery_device_ids[] = { 86static const struct acpi_device_id battery_device_ids[] = {
68 {"PNP0C0A", 0}, 87 {"PNP0C0A", 0},
69 {"", 0}, 88 {"", 0},
@@ -299,6 +318,14 @@ static enum power_supply_property energy_battery_props[] = {
299 POWER_SUPPLY_PROP_SERIAL_NUMBER, 318 POWER_SUPPLY_PROP_SERIAL_NUMBER,
300}; 319};
301 320
321#ifdef CONFIG_ACPI_PROCFS_POWER
322inline char *acpi_battery_units(struct acpi_battery *battery)
323{
324 return (battery->power_unit == ACPI_BATTERY_POWER_UNIT_MA) ?
325 "mA" : "mW";
326}
327#endif
328
302/* -------------------------------------------------------------------------- 329/* --------------------------------------------------------------------------
303 Battery Management 330 Battery Management
304 -------------------------------------------------------------------------- */ 331 -------------------------------------------------------------------------- */
@@ -717,6 +744,279 @@ static void acpi_battery_refresh(struct acpi_battery *battery)
717} 744}
718 745
719/* -------------------------------------------------------------------------- 746/* --------------------------------------------------------------------------
747 FS Interface (/proc)
748 -------------------------------------------------------------------------- */
749
750#ifdef CONFIG_ACPI_PROCFS_POWER
751static struct proc_dir_entry *acpi_battery_dir;
752
753static int acpi_battery_print_info(struct seq_file *seq, int result)
754{
755 struct acpi_battery *battery = seq->private;
756
757 if (result)
758 goto end;
759
760 seq_printf(seq, "present: %s\n",
761 acpi_battery_present(battery) ? "yes" : "no");
762 if (!acpi_battery_present(battery))
763 goto end;
764 if (battery->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
765 seq_printf(seq, "design capacity: unknown\n");
766 else
767 seq_printf(seq, "design capacity: %d %sh\n",
768 battery->design_capacity,
769 acpi_battery_units(battery));
770
771 if (battery->full_charge_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
772 seq_printf(seq, "last full capacity: unknown\n");
773 else
774 seq_printf(seq, "last full capacity: %d %sh\n",
775 battery->full_charge_capacity,
776 acpi_battery_units(battery));
777
778 seq_printf(seq, "battery technology: %srechargeable\n",
779 (!battery->technology)?"non-":"");
780
781 if (battery->design_voltage == ACPI_BATTERY_VALUE_UNKNOWN)
782 seq_printf(seq, "design voltage: unknown\n");
783 else
784 seq_printf(seq, "design voltage: %d mV\n",
785 battery->design_voltage);
786 seq_printf(seq, "design capacity warning: %d %sh\n",
787 battery->design_capacity_warning,
788 acpi_battery_units(battery));
789 seq_printf(seq, "design capacity low: %d %sh\n",
790 battery->design_capacity_low,
791 acpi_battery_units(battery));
792 seq_printf(seq, "cycle count: %i\n", battery->cycle_count);
793 seq_printf(seq, "capacity granularity 1: %d %sh\n",
794 battery->capacity_granularity_1,
795 acpi_battery_units(battery));
796 seq_printf(seq, "capacity granularity 2: %d %sh\n",
797 battery->capacity_granularity_2,
798 acpi_battery_units(battery));
799 seq_printf(seq, "model number: %s\n", battery->model_number);
800 seq_printf(seq, "serial number: %s\n", battery->serial_number);
801 seq_printf(seq, "battery type: %s\n", battery->type);
802 seq_printf(seq, "OEM info: %s\n", battery->oem_info);
803 end:
804 if (result)
805 seq_printf(seq, "ERROR: Unable to read battery info\n");
806 return result;
807}
808
809static int acpi_battery_print_state(struct seq_file *seq, int result)
810{
811 struct acpi_battery *battery = seq->private;
812
813 if (result)
814 goto end;
815
816 seq_printf(seq, "present: %s\n",
817 acpi_battery_present(battery) ? "yes" : "no");
818 if (!acpi_battery_present(battery))
819 goto end;
820
821 seq_printf(seq, "capacity state: %s\n",
822 (battery->state & 0x04) ? "critical" : "ok");
823 if ((battery->state & 0x01) && (battery->state & 0x02))
824 seq_printf(seq,
825 "charging state: charging/discharging\n");
826 else if (battery->state & 0x01)
827 seq_printf(seq, "charging state: discharging\n");
828 else if (battery->state & 0x02)
829 seq_printf(seq, "charging state: charging\n");
830 else
831 seq_printf(seq, "charging state: charged\n");
832
833 if (battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN)
834 seq_printf(seq, "present rate: unknown\n");
835 else
836 seq_printf(seq, "present rate: %d %s\n",
837 battery->rate_now, acpi_battery_units(battery));
838
839 if (battery->capacity_now == ACPI_BATTERY_VALUE_UNKNOWN)
840 seq_printf(seq, "remaining capacity: unknown\n");
841 else
842 seq_printf(seq, "remaining capacity: %d %sh\n",
843 battery->capacity_now, acpi_battery_units(battery));
844 if (battery->voltage_now == ACPI_BATTERY_VALUE_UNKNOWN)
845 seq_printf(seq, "present voltage: unknown\n");
846 else
847 seq_printf(seq, "present voltage: %d mV\n",
848 battery->voltage_now);
849 end:
850 if (result)
851 seq_printf(seq, "ERROR: Unable to read battery state\n");
852
853 return result;
854}
855
856static int acpi_battery_print_alarm(struct seq_file *seq, int result)
857{
858 struct acpi_battery *battery = seq->private;
859
860 if (result)
861 goto end;
862
863 if (!acpi_battery_present(battery)) {
864 seq_printf(seq, "present: no\n");
865 goto end;
866 }
867 seq_printf(seq, "alarm: ");
868 if (!battery->alarm)
869 seq_printf(seq, "unsupported\n");
870 else
871 seq_printf(seq, "%u %sh\n", battery->alarm,
872 acpi_battery_units(battery));
873 end:
874 if (result)
875 seq_printf(seq, "ERROR: Unable to read battery alarm\n");
876 return result;
877}
878
879static ssize_t acpi_battery_write_alarm(struct file *file,
880 const char __user * buffer,
881 size_t count, loff_t * ppos)
882{
883 int result = 0;
884 char alarm_string[12] = { '\0' };
885 struct seq_file *m = file->private_data;
886 struct acpi_battery *battery = m->private;
887
888 if (!battery || (count > sizeof(alarm_string) - 1))
889 return -EINVAL;
890 if (!acpi_battery_present(battery)) {
891 result = -ENODEV;
892 goto end;
893 }
894 if (copy_from_user(alarm_string, buffer, count)) {
895 result = -EFAULT;
896 goto end;
897 }
898 alarm_string[count] = '\0';
899 battery->alarm = simple_strtol(alarm_string, NULL, 0);
900 result = acpi_battery_set_alarm(battery);
901 end:
902 if (!result)
903 return count;
904 return result;
905}
906
907typedef int(*print_func)(struct seq_file *seq, int result);
908
909static print_func acpi_print_funcs[ACPI_BATTERY_NUMFILES] = {
910 acpi_battery_print_info,
911 acpi_battery_print_state,
912 acpi_battery_print_alarm,
913};
914
915static int acpi_battery_read(int fid, struct seq_file *seq)
916{
917 struct acpi_battery *battery = seq->private;
918 int result = acpi_battery_update(battery);
919 return acpi_print_funcs[fid](seq, result);
920}
921
922#define DECLARE_FILE_FUNCTIONS(_name) \
923static int acpi_battery_read_##_name(struct seq_file *seq, void *offset) \
924{ \
925 return acpi_battery_read(_name##_tag, seq); \
926} \
927static int acpi_battery_##_name##_open_fs(struct inode *inode, struct file *file) \
928{ \
929 return single_open(file, acpi_battery_read_##_name, PDE_DATA(inode)); \
930}
931
932DECLARE_FILE_FUNCTIONS(info);
933DECLARE_FILE_FUNCTIONS(state);
934DECLARE_FILE_FUNCTIONS(alarm);
935
936#undef DECLARE_FILE_FUNCTIONS
937
938#define FILE_DESCRIPTION_RO(_name) \
939 { \
940 .name = __stringify(_name), \
941 .mode = S_IRUGO, \
942 .ops = { \
943 .open = acpi_battery_##_name##_open_fs, \
944 .read = seq_read, \
945 .llseek = seq_lseek, \
946 .release = single_release, \
947 .owner = THIS_MODULE, \
948 }, \
949 }
950
951#define FILE_DESCRIPTION_RW(_name) \
952 { \
953 .name = __stringify(_name), \
954 .mode = S_IFREG | S_IRUGO | S_IWUSR, \
955 .ops = { \
956 .open = acpi_battery_##_name##_open_fs, \
957 .read = seq_read, \
958 .llseek = seq_lseek, \
959 .write = acpi_battery_write_##_name, \
960 .release = single_release, \
961 .owner = THIS_MODULE, \
962 }, \
963 }
964
965static const struct battery_file {
966 struct file_operations ops;
967 umode_t mode;
968 const char *name;
969} acpi_battery_file[] = {
970 FILE_DESCRIPTION_RO(info),
971 FILE_DESCRIPTION_RO(state),
972 FILE_DESCRIPTION_RW(alarm),
973};
974
975#undef FILE_DESCRIPTION_RO
976#undef FILE_DESCRIPTION_RW
977
978static int acpi_battery_add_fs(struct acpi_device *device)
979{
980 struct proc_dir_entry *entry = NULL;
981 int i;
982
983 printk(KERN_WARNING PREFIX "Deprecated procfs I/F for battery is loaded,"
984 " please retry with CONFIG_ACPI_PROCFS_POWER cleared\n");
985 if (!acpi_device_dir(device)) {
986 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
987 acpi_battery_dir);
988 if (!acpi_device_dir(device))
989 return -ENODEV;
990 }
991
992 for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i) {
993 entry = proc_create_data(acpi_battery_file[i].name,
994 acpi_battery_file[i].mode,
995 acpi_device_dir(device),
996 &acpi_battery_file[i].ops,
997 acpi_driver_data(device));
998 if (!entry)
999 return -ENODEV;
1000 }
1001 return 0;
1002}
1003
1004static void acpi_battery_remove_fs(struct acpi_device *device)
1005{
1006 int i;
1007 if (!acpi_device_dir(device))
1008 return;
1009 for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i)
1010 remove_proc_entry(acpi_battery_file[i].name,
1011 acpi_device_dir(device));
1012
1013 remove_proc_entry(acpi_device_bid(device), acpi_battery_dir);
1014 acpi_device_dir(device) = NULL;
1015}
1016
1017#endif
1018
1019/* --------------------------------------------------------------------------
720 Driver Interface 1020 Driver Interface
721 -------------------------------------------------------------------------- */ 1021 -------------------------------------------------------------------------- */
722 1022
@@ -790,6 +1090,15 @@ static int acpi_battery_add(struct acpi_device *device)
790 result = acpi_battery_update(battery); 1090 result = acpi_battery_update(battery);
791 if (result) 1091 if (result)
792 goto fail; 1092 goto fail;
1093#ifdef CONFIG_ACPI_PROCFS_POWER
1094 result = acpi_battery_add_fs(device);
1095#endif
1096 if (result) {
1097#ifdef CONFIG_ACPI_PROCFS_POWER
1098 acpi_battery_remove_fs(device);
1099#endif
1100 goto fail;
1101 }
793 1102
794 printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n", 1103 printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n",
795 ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device), 1104 ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device),
@@ -816,6 +1125,9 @@ static int acpi_battery_remove(struct acpi_device *device)
816 return -EINVAL; 1125 return -EINVAL;
817 battery = acpi_driver_data(device); 1126 battery = acpi_driver_data(device);
818 unregister_pm_notifier(&battery->pm_nb); 1127 unregister_pm_notifier(&battery->pm_nb);
1128#ifdef CONFIG_ACPI_PROCFS_POWER
1129 acpi_battery_remove_fs(device);
1130#endif
819 sysfs_remove_battery(battery); 1131 sysfs_remove_battery(battery);
820 mutex_destroy(&battery->lock); 1132 mutex_destroy(&battery->lock);
821 mutex_destroy(&battery->sysfs_lock); 1133 mutex_destroy(&battery->sysfs_lock);
@@ -866,7 +1178,19 @@ static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie)
866 1178
867 if (dmi_check_system(bat_dmi_table)) 1179 if (dmi_check_system(bat_dmi_table))
868 battery_bix_broken_package = 1; 1180 battery_bix_broken_package = 1;
869 acpi_bus_register_driver(&acpi_battery_driver); 1181
1182#ifdef CONFIG_ACPI_PROCFS_POWER
1183 acpi_battery_dir = acpi_lock_battery_dir();
1184 if (!acpi_battery_dir)
1185 return;
1186#endif
1187 if (acpi_bus_register_driver(&acpi_battery_driver) < 0) {
1188#ifdef CONFIG_ACPI_PROCFS_POWER
1189 acpi_unlock_battery_dir(acpi_battery_dir);
1190#endif
1191 return;
1192 }
1193 return;
870} 1194}
871 1195
872static int __init acpi_battery_init(void) 1196static int __init acpi_battery_init(void)
@@ -878,6 +1202,9 @@ static int __init acpi_battery_init(void)
878static void __exit acpi_battery_exit(void) 1202static void __exit acpi_battery_exit(void)
879{ 1203{
880 acpi_bus_unregister_driver(&acpi_battery_driver); 1204 acpi_bus_unregister_driver(&acpi_battery_driver);
1205#ifdef CONFIG_ACPI_PROCFS_POWER
1206 acpi_unlock_battery_dir(acpi_battery_dir);
1207#endif
881} 1208}
882 1209
883module_init(acpi_battery_init); 1210module_init(acpi_battery_init);
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
index afec4526c48a..3d8413d02a97 100644
--- a/drivers/acpi/blacklist.c
+++ b/drivers/acpi/blacklist.c
@@ -314,6 +314,14 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
314 DMI_MATCH(DMI_PRODUCT_VERSION, "2349D15"), 314 DMI_MATCH(DMI_PRODUCT_VERSION, "2349D15"),
315 }, 315 },
316 }, 316 },
317 {
318 .callback = dmi_disable_osi_win8,
319 .ident = "Dell Inspiron 7737",
320 .matches = {
321 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
322 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7737"),
323 },
324 },
317 325
318 /* 326 /*
319 * BIOS invocation of _OSI(Linux) is almost always a BIOS bug. 327 * BIOS invocation of _OSI(Linux) is almost always a BIOS bug.
@@ -374,6 +382,19 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
374 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T500"), 382 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T500"),
375 }, 383 },
376 }, 384 },
385 /*
386 * Without this this EEEpc exports a non working WMI interface, with
387 * this it exports a working "good old" eeepc_laptop interface, fixing
388 * both brightness control, and rfkill not working.
389 */
390 {
391 .callback = dmi_enable_osi_linux,
392 .ident = "Asus EEE PC 1015PX",
393 .matches = {
394 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer INC."),
395 DMI_MATCH(DMI_PRODUCT_NAME, "1015PX"),
396 },
397 },
377 {} 398 {}
378}; 399};
379 400
diff --git a/drivers/acpi/cm_sbs.c b/drivers/acpi/cm_sbs.c
new file mode 100644
index 000000000000..6c9ee68e46fb
--- /dev/null
+++ b/drivers/acpi/cm_sbs.c
@@ -0,0 +1,105 @@
1/*
2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or (at
7 * your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17 *
18 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 */
20
21#include <linux/kernel.h>
22#include <linux/module.h>
23#include <linux/init.h>
24#include <linux/acpi.h>
25#include <linux/types.h>
26#include <linux/proc_fs.h>
27#include <linux/seq_file.h>
28#include <acpi/acpi_bus.h>
29#include <acpi/acpi_drivers.h>
30
31#define PREFIX "ACPI: "
32
33ACPI_MODULE_NAME("cm_sbs");
34#define ACPI_AC_CLASS "ac_adapter"
35#define ACPI_BATTERY_CLASS "battery"
36#define _COMPONENT ACPI_SBS_COMPONENT
37static struct proc_dir_entry *acpi_ac_dir;
38static struct proc_dir_entry *acpi_battery_dir;
39
40static DEFINE_MUTEX(cm_sbs_mutex);
41
42static int lock_ac_dir_cnt;
43static int lock_battery_dir_cnt;
44
45struct proc_dir_entry *acpi_lock_ac_dir(void)
46{
47 mutex_lock(&cm_sbs_mutex);
48 if (!acpi_ac_dir)
49 acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir);
50 if (acpi_ac_dir) {
51 lock_ac_dir_cnt++;
52 } else {
53 printk(KERN_ERR PREFIX
54 "Cannot create %s\n", ACPI_AC_CLASS);
55 }
56 mutex_unlock(&cm_sbs_mutex);
57 return acpi_ac_dir;
58}
59EXPORT_SYMBOL(acpi_lock_ac_dir);
60
61void acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir_param)
62{
63 mutex_lock(&cm_sbs_mutex);
64 if (acpi_ac_dir_param)
65 lock_ac_dir_cnt--;
66 if (lock_ac_dir_cnt == 0 && acpi_ac_dir_param && acpi_ac_dir) {
67 remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir);
68 acpi_ac_dir = NULL;
69 }
70 mutex_unlock(&cm_sbs_mutex);
71}
72EXPORT_SYMBOL(acpi_unlock_ac_dir);
73
74struct proc_dir_entry *acpi_lock_battery_dir(void)
75{
76 mutex_lock(&cm_sbs_mutex);
77 if (!acpi_battery_dir) {
78 acpi_battery_dir =
79 proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir);
80 }
81 if (acpi_battery_dir) {
82 lock_battery_dir_cnt++;
83 } else {
84 printk(KERN_ERR PREFIX
85 "Cannot create %s\n", ACPI_BATTERY_CLASS);
86 }
87 mutex_unlock(&cm_sbs_mutex);
88 return acpi_battery_dir;
89}
90EXPORT_SYMBOL(acpi_lock_battery_dir);
91
92void acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir_param)
93{
94 mutex_lock(&cm_sbs_mutex);
95 if (acpi_battery_dir_param)
96 lock_battery_dir_cnt--;
97 if (lock_battery_dir_cnt == 0 && acpi_battery_dir_param
98 && acpi_battery_dir) {
99 remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir);
100 acpi_battery_dir = NULL;
101 }
102 mutex_unlock(&cm_sbs_mutex);
103 return;
104}
105EXPORT_SYMBOL(acpi_unlock_battery_dir);
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 8b6990e417ec..f8bc5a755dda 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -457,10 +457,10 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
457 }, 457 },
458 { 458 {
459 .callback = video_set_use_native_backlight, 459 .callback = video_set_use_native_backlight,
460 .ident = "ThinkPad T430s", 460 .ident = "ThinkPad T430 and T430s",
461 .matches = { 461 .matches = {
462 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 462 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
463 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T430s"), 463 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T430"),
464 }, 464 },
465 }, 465 },
466 { 466 {
@@ -472,7 +472,7 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
472 }, 472 },
473 }, 473 },
474 { 474 {
475 .callback = video_set_use_native_backlight, 475 .callback = video_set_use_native_backlight,
476 .ident = "ThinkPad X1 Carbon", 476 .ident = "ThinkPad X1 Carbon",
477 .matches = { 477 .matches = {
478 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 478 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
@@ -500,7 +500,7 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
500 .ident = "Dell Inspiron 7520", 500 .ident = "Dell Inspiron 7520",
501 .matches = { 501 .matches = {
502 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 502 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
503 DMI_MATCH(DMI_PRODUCT_VERSION, "Inspiron 7520"), 503 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7520"),
504 }, 504 },
505 }, 505 },
506 { 506 {
@@ -513,6 +513,14 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
513 }, 513 },
514 { 514 {
515 .callback = video_set_use_native_backlight, 515 .callback = video_set_use_native_backlight,
516 .ident = "Acer Aspire 5742G",
517 .matches = {
518 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
519 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5742G"),
520 },
521 },
522 {
523 .callback = video_set_use_native_backlight,
516 .ident = "Acer Aspire V5-431", 524 .ident = "Acer Aspire V5-431",
517 .matches = { 525 .matches = {
518 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 526 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index c2706047337f..0033fafc470b 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -815,7 +815,7 @@ config PATA_AT32
815 815
816config PATA_AT91 816config PATA_AT91
817 tristate "PATA support for AT91SAM9260" 817 tristate "PATA support for AT91SAM9260"
818 depends on ARM && ARCH_AT91 818 depends on ARM && SOC_AT91SAM9
819 help 819 help
820 This option enables support for IDE devices on the Atmel AT91SAM9260 SoC. 820 This option enables support for IDE devices on the Atmel AT91SAM9260 SoC.
821 821
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 71e15b73513d..60707814a84b 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -1115,6 +1115,17 @@ static bool ahci_broken_online(struct pci_dev *pdev)
1115 return pdev->bus->number == (val >> 8) && pdev->devfn == (val & 0xff); 1115 return pdev->bus->number == (val >> 8) && pdev->devfn == (val & 0xff);
1116} 1116}
1117 1117
1118static bool ahci_broken_devslp(struct pci_dev *pdev)
1119{
1120 /* device with broken DEVSLP but still showing SDS capability */
1121 static const struct pci_device_id ids[] = {
1122 { PCI_VDEVICE(INTEL, 0x0f23)}, /* Valleyview SoC */
1123 {}
1124 };
1125
1126 return pci_match_id(ids, pdev);
1127}
1128
1118#ifdef CONFIG_ATA_ACPI 1129#ifdef CONFIG_ATA_ACPI
1119static void ahci_gtf_filter_workaround(struct ata_host *host) 1130static void ahci_gtf_filter_workaround(struct ata_host *host)
1120{ 1131{
@@ -1364,6 +1375,10 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1364 1375
1365 hpriv->mmio = pcim_iomap_table(pdev)[ahci_pci_bar]; 1376 hpriv->mmio = pcim_iomap_table(pdev)[ahci_pci_bar];
1366 1377
1378 /* must set flag prior to save config in order to take effect */
1379 if (ahci_broken_devslp(pdev))
1380 hpriv->flags |= AHCI_HFLAG_NO_DEVSLP;
1381
1367 /* save initial config */ 1382 /* save initial config */
1368 ahci_pci_save_initial_config(pdev, hpriv); 1383 ahci_pci_save_initial_config(pdev, hpriv);
1369 1384
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
index b5eb886da226..af63c75c2001 100644
--- a/drivers/ata/ahci.h
+++ b/drivers/ata/ahci.h
@@ -236,6 +236,7 @@ enum {
236 port start (wait until 236 port start (wait until
237 error-handling stage) */ 237 error-handling stage) */
238 AHCI_HFLAG_MULTI_MSI = (1 << 16), /* multiple PCI MSIs */ 238 AHCI_HFLAG_MULTI_MSI = (1 << 16), /* multiple PCI MSIs */
239 AHCI_HFLAG_NO_DEVSLP = (1 << 17), /* no device sleep */
239 240
240 /* ap->flags bits */ 241 /* ap->flags bits */
241 242
diff --git a/drivers/ata/ahci_imx.c b/drivers/ata/ahci_imx.c
index 497c7abe1c7d..8befeb69eeb1 100644
--- a/drivers/ata/ahci_imx.c
+++ b/drivers/ata/ahci_imx.c
@@ -29,9 +29,25 @@
29#include "ahci.h" 29#include "ahci.h"
30 30
31enum { 31enum {
32 PORT_PHY_CTL = 0x178, /* Port0 PHY Control */ 32 /* Timer 1-ms Register */
33 PORT_PHY_CTL_PDDQ_LOC = 0x100000, /* PORT_PHY_CTL bits */ 33 IMX_TIMER1MS = 0x00e0,
34 HOST_TIMER1MS = 0xe0, /* Timer 1-ms */ 34 /* Port0 PHY Control Register */
35 IMX_P0PHYCR = 0x0178,
36 IMX_P0PHYCR_TEST_PDDQ = 1 << 20,
37 IMX_P0PHYCR_CR_READ = 1 << 19,
38 IMX_P0PHYCR_CR_WRITE = 1 << 18,
39 IMX_P0PHYCR_CR_CAP_DATA = 1 << 17,
40 IMX_P0PHYCR_CR_CAP_ADDR = 1 << 16,
41 /* Port0 PHY Status Register */
42 IMX_P0PHYSR = 0x017c,
43 IMX_P0PHYSR_CR_ACK = 1 << 18,
44 IMX_P0PHYSR_CR_DATA_OUT = 0xffff << 0,
45 /* Lane0 Output Status Register */
46 IMX_LANE0_OUT_STAT = 0x2003,
47 IMX_LANE0_OUT_STAT_RX_PLL_STATE = 1 << 1,
48 /* Clock Reset Register */
49 IMX_CLOCK_RESET = 0x7f3f,
50 IMX_CLOCK_RESET_RESET = 1 << 0,
35}; 51};
36 52
37enum ahci_imx_type { 53enum ahci_imx_type {
@@ -54,9 +70,149 @@ MODULE_PARM_DESC(hotplug, "AHCI IMX hot-plug support (0=Don't support, 1=support
54 70
55static void ahci_imx_host_stop(struct ata_host *host); 71static void ahci_imx_host_stop(struct ata_host *host);
56 72
73static int imx_phy_crbit_assert(void __iomem *mmio, u32 bit, bool assert)
74{
75 int timeout = 10;
76 u32 crval;
77 u32 srval;
78
79 /* Assert or deassert the bit */
80 crval = readl(mmio + IMX_P0PHYCR);
81 if (assert)
82 crval |= bit;
83 else
84 crval &= ~bit;
85 writel(crval, mmio + IMX_P0PHYCR);
86
87 /* Wait for the cr_ack signal */
88 do {
89 srval = readl(mmio + IMX_P0PHYSR);
90 if ((assert ? srval : ~srval) & IMX_P0PHYSR_CR_ACK)
91 break;
92 usleep_range(100, 200);
93 } while (--timeout);
94
95 return timeout ? 0 : -ETIMEDOUT;
96}
97
98static int imx_phy_reg_addressing(u16 addr, void __iomem *mmio)
99{
100 u32 crval = addr;
101 int ret;
102
103 /* Supply the address on cr_data_in */
104 writel(crval, mmio + IMX_P0PHYCR);
105
106 /* Assert the cr_cap_addr signal */
107 ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_CAP_ADDR, true);
108 if (ret)
109 return ret;
110
111 /* Deassert cr_cap_addr */
112 ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_CAP_ADDR, false);
113 if (ret)
114 return ret;
115
116 return 0;
117}
118
119static int imx_phy_reg_write(u16 val, void __iomem *mmio)
120{
121 u32 crval = val;
122 int ret;
123
124 /* Supply the data on cr_data_in */
125 writel(crval, mmio + IMX_P0PHYCR);
126
127 /* Assert the cr_cap_data signal */
128 ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_CAP_DATA, true);
129 if (ret)
130 return ret;
131
132 /* Deassert cr_cap_data */
133 ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_CAP_DATA, false);
134 if (ret)
135 return ret;
136
137 if (val & IMX_CLOCK_RESET_RESET) {
138 /*
139 * In case we're resetting the phy, it's unable to acknowledge,
140 * so we return immediately here.
141 */
142 crval |= IMX_P0PHYCR_CR_WRITE;
143 writel(crval, mmio + IMX_P0PHYCR);
144 goto out;
145 }
146
147 /* Assert the cr_write signal */
148 ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_WRITE, true);
149 if (ret)
150 return ret;
151
152 /* Deassert cr_write */
153 ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_WRITE, false);
154 if (ret)
155 return ret;
156
157out:
158 return 0;
159}
160
161static int imx_phy_reg_read(u16 *val, void __iomem *mmio)
162{
163 int ret;
164
165 /* Assert the cr_read signal */
166 ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_READ, true);
167 if (ret)
168 return ret;
169
170 /* Capture the data from cr_data_out[] */
171 *val = readl(mmio + IMX_P0PHYSR) & IMX_P0PHYSR_CR_DATA_OUT;
172
173 /* Deassert cr_read */
174 ret = imx_phy_crbit_assert(mmio, IMX_P0PHYCR_CR_READ, false);
175 if (ret)
176 return ret;
177
178 return 0;
179}
180
181static int imx_sata_phy_reset(struct ahci_host_priv *hpriv)
182{
183 void __iomem *mmio = hpriv->mmio;
184 int timeout = 10;
185 u16 val;
186 int ret;
187
188 /* Reset SATA PHY by setting RESET bit of PHY register CLOCK_RESET */
189 ret = imx_phy_reg_addressing(IMX_CLOCK_RESET, mmio);
190 if (ret)
191 return ret;
192 ret = imx_phy_reg_write(IMX_CLOCK_RESET_RESET, mmio);
193 if (ret)
194 return ret;
195
196 /* Wait for PHY RX_PLL to be stable */
197 do {
198 usleep_range(100, 200);
199 ret = imx_phy_reg_addressing(IMX_LANE0_OUT_STAT, mmio);
200 if (ret)
201 return ret;
202 ret = imx_phy_reg_read(&val, mmio);
203 if (ret)
204 return ret;
205 if (val & IMX_LANE0_OUT_STAT_RX_PLL_STATE)
206 break;
207 } while (--timeout);
208
209 return timeout ? 0 : -ETIMEDOUT;
210}
211
57static int imx_sata_enable(struct ahci_host_priv *hpriv) 212static int imx_sata_enable(struct ahci_host_priv *hpriv)
58{ 213{
59 struct imx_ahci_priv *imxpriv = hpriv->plat_data; 214 struct imx_ahci_priv *imxpriv = hpriv->plat_data;
215 struct device *dev = &imxpriv->ahci_pdev->dev;
60 int ret; 216 int ret;
61 217
62 if (imxpriv->no_device) 218 if (imxpriv->no_device)
@@ -101,6 +257,14 @@ static int imx_sata_enable(struct ahci_host_priv *hpriv)
101 regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13, 257 regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13,
102 IMX6Q_GPR13_SATA_MPLL_CLK_EN, 258 IMX6Q_GPR13_SATA_MPLL_CLK_EN,
103 IMX6Q_GPR13_SATA_MPLL_CLK_EN); 259 IMX6Q_GPR13_SATA_MPLL_CLK_EN);
260
261 usleep_range(100, 200);
262
263 ret = imx_sata_phy_reset(hpriv);
264 if (ret) {
265 dev_err(dev, "failed to reset phy: %d\n", ret);
266 goto disable_regulator;
267 }
104 } 268 }
105 269
106 usleep_range(1000, 2000); 270 usleep_range(1000, 2000);
@@ -156,8 +320,8 @@ static void ahci_imx_error_handler(struct ata_port *ap)
156 * without full reset once the pddq mode is enabled making it 320 * without full reset once the pddq mode is enabled making it
157 * impossible to use as part of libata LPM. 321 * impossible to use as part of libata LPM.
158 */ 322 */
159 reg_val = readl(mmio + PORT_PHY_CTL); 323 reg_val = readl(mmio + IMX_P0PHYCR);
160 writel(reg_val | PORT_PHY_CTL_PDDQ_LOC, mmio + PORT_PHY_CTL); 324 writel(reg_val | IMX_P0PHYCR_TEST_PDDQ, mmio + IMX_P0PHYCR);
161 imx_sata_disable(hpriv); 325 imx_sata_disable(hpriv);
162 imxpriv->no_device = true; 326 imxpriv->no_device = true;
163} 327}
@@ -217,6 +381,7 @@ static int imx_ahci_probe(struct platform_device *pdev)
217 if (!imxpriv) 381 if (!imxpriv)
218 return -ENOMEM; 382 return -ENOMEM;
219 383
384 imxpriv->ahci_pdev = pdev;
220 imxpriv->no_device = false; 385 imxpriv->no_device = false;
221 imxpriv->first_time = true; 386 imxpriv->first_time = true;
222 imxpriv->type = (enum ahci_imx_type)of_id->data; 387 imxpriv->type = (enum ahci_imx_type)of_id->data;
@@ -248,7 +413,7 @@ static int imx_ahci_probe(struct platform_device *pdev)
248 413
249 /* 414 /*
250 * Configure the HWINIT bits of the HOST_CAP and HOST_PORTS_IMPL, 415 * Configure the HWINIT bits of the HOST_CAP and HOST_PORTS_IMPL,
251 * and IP vendor specific register HOST_TIMER1MS. 416 * and IP vendor specific register IMX_TIMER1MS.
252 * Configure CAP_SSS (support stagered spin up). 417 * Configure CAP_SSS (support stagered spin up).
253 * Implement the port0. 418 * Implement the port0.
254 * Get the ahb clock rate, and configure the TIMER1MS register. 419 * Get the ahb clock rate, and configure the TIMER1MS register.
@@ -265,7 +430,7 @@ static int imx_ahci_probe(struct platform_device *pdev)
265 } 430 }
266 431
267 reg_val = clk_get_rate(imxpriv->ahb_clk) / 1000; 432 reg_val = clk_get_rate(imxpriv->ahb_clk) / 1000;
268 writel(reg_val, hpriv->mmio + HOST_TIMER1MS); 433 writel(reg_val, hpriv->mmio + IMX_TIMER1MS);
269 434
270 ret = ahci_platform_init_host(pdev, hpriv, &ahci_imx_port_info, 0, 0); 435 ret = ahci_platform_init_host(pdev, hpriv, &ahci_imx_port_info, 0, 0);
271 if (ret) 436 if (ret)
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index 6bd4f660b4e1..b9861453fc81 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -452,6 +452,13 @@ void ahci_save_initial_config(struct device *dev,
452 cap &= ~HOST_CAP_SNTF; 452 cap &= ~HOST_CAP_SNTF;
453 } 453 }
454 454
455 if ((cap2 & HOST_CAP2_SDS) && (hpriv->flags & AHCI_HFLAG_NO_DEVSLP)) {
456 dev_info(dev,
457 "controller can't do DEVSLP, turning off\n");
458 cap2 &= ~HOST_CAP2_SDS;
459 cap2 &= ~HOST_CAP2_SADM;
460 }
461
455 if (!(cap & HOST_CAP_FBS) && (hpriv->flags & AHCI_HFLAG_YES_FBS)) { 462 if (!(cap & HOST_CAP_FBS) && (hpriv->flags & AHCI_HFLAG_YES_FBS)) {
456 dev_info(dev, "controller can do FBS, turning on CAP_FBS\n"); 463 dev_info(dev, "controller can do FBS, turning on CAP_FBS\n");
457 cap |= HOST_CAP_FBS; 464 cap |= HOST_CAP_FBS;
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 943cc8b83e59..ea83828bfea9 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -6314,6 +6314,8 @@ int ata_host_activate(struct ata_host *host, int irq,
6314static void ata_port_detach(struct ata_port *ap) 6314static void ata_port_detach(struct ata_port *ap)
6315{ 6315{
6316 unsigned long flags; 6316 unsigned long flags;
6317 struct ata_link *link;
6318 struct ata_device *dev;
6317 6319
6318 if (!ap->ops->error_handler) 6320 if (!ap->ops->error_handler)
6319 goto skip_eh; 6321 goto skip_eh;
@@ -6333,6 +6335,13 @@ static void ata_port_detach(struct ata_port *ap)
6333 cancel_delayed_work_sync(&ap->hotplug_task); 6335 cancel_delayed_work_sync(&ap->hotplug_task);
6334 6336
6335 skip_eh: 6337 skip_eh:
6338 /* clean up zpodd on port removal */
6339 ata_for_each_link(link, ap, HOST_FIRST) {
6340 ata_for_each_dev(dev, link, ALL) {
6341 if (zpodd_dev_enabled(dev))
6342 zpodd_exit(dev);
6343 }
6344 }
6336 if (ap->pmp_link) { 6345 if (ap->pmp_link) {
6337 int i; 6346 int i;
6338 for (i = 0; i < SATA_PMP_MAX_PORTS; i++) 6347 for (i = 0; i < SATA_PMP_MAX_PORTS; i++)
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 6b75713d953a..102c50d38902 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -995,8 +995,11 @@ retry:
995 ibytes = min_t(size_t, ibytes, have_bytes - reserved); 995 ibytes = min_t(size_t, ibytes, have_bytes - reserved);
996 if (ibytes < min) 996 if (ibytes < min)
997 ibytes = 0; 997 ibytes = 0;
998 entropy_count = max_t(int, 0, 998 if (have_bytes >= ibytes + reserved)
999 entropy_count - (ibytes << (ENTROPY_SHIFT + 3))); 999 entropy_count -= ibytes << (ENTROPY_SHIFT + 3);
1000 else
1001 entropy_count = reserved << (ENTROPY_SHIFT + 3);
1002
1000 if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig) 1003 if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig)
1001 goto retry; 1004 goto retry;
1002 1005
diff --git a/drivers/char/tpm/tpm_ppi.c b/drivers/char/tpm/tpm_ppi.c
index b3ea223585bd..61dcc8011ec7 100644
--- a/drivers/char/tpm/tpm_ppi.c
+++ b/drivers/char/tpm/tpm_ppi.c
@@ -328,13 +328,11 @@ int tpm_add_ppi(struct kobject *parent)
328 /* Cache TPM ACPI handle and version string */ 328 /* Cache TPM ACPI handle and version string */
329 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 329 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
330 ppi_callback, NULL, NULL, &tpm_ppi_handle); 330 ppi_callback, NULL, NULL, &tpm_ppi_handle);
331 if (tpm_ppi_handle == NULL) 331 return tpm_ppi_handle ? sysfs_create_group(parent, &ppi_attr_grp) : 0;
332 return -ENODEV;
333
334 return sysfs_create_group(parent, &ppi_attr_grp);
335} 332}
336 333
337void tpm_remove_ppi(struct kobject *parent) 334void tpm_remove_ppi(struct kobject *parent)
338{ 335{
339 sysfs_remove_group(parent, &ppi_attr_grp); 336 if (tpm_ppi_handle)
337 sysfs_remove_group(parent, &ppi_attr_grp);
340} 338}
diff --git a/drivers/clk/bcm/clk-kona-setup.c b/drivers/clk/bcm/clk-kona-setup.c
index c7607feb18dd..54a06526f64f 100644
--- a/drivers/clk/bcm/clk-kona-setup.c
+++ b/drivers/clk/bcm/clk-kona-setup.c
@@ -27,7 +27,7 @@ LIST_HEAD(ccu_list); /* The list of set up CCUs */
27 27
28static bool clk_requires_trigger(struct kona_clk *bcm_clk) 28static bool clk_requires_trigger(struct kona_clk *bcm_clk)
29{ 29{
30 struct peri_clk_data *peri = bcm_clk->peri; 30 struct peri_clk_data *peri = bcm_clk->u.peri;
31 struct bcm_clk_sel *sel; 31 struct bcm_clk_sel *sel;
32 struct bcm_clk_div *div; 32 struct bcm_clk_div *div;
33 33
@@ -63,7 +63,7 @@ static bool peri_clk_data_offsets_valid(struct kona_clk *bcm_clk)
63 u32 limit; 63 u32 limit;
64 64
65 BUG_ON(bcm_clk->type != bcm_clk_peri); 65 BUG_ON(bcm_clk->type != bcm_clk_peri);
66 peri = bcm_clk->peri; 66 peri = bcm_clk->u.peri;
67 name = bcm_clk->name; 67 name = bcm_clk->name;
68 range = bcm_clk->ccu->range; 68 range = bcm_clk->ccu->range;
69 69
@@ -81,19 +81,19 @@ static bool peri_clk_data_offsets_valid(struct kona_clk *bcm_clk)
81 81
82 div = &peri->div; 82 div = &peri->div;
83 if (divider_exists(div)) { 83 if (divider_exists(div)) {
84 if (div->offset > limit) { 84 if (div->u.s.offset > limit) {
85 pr_err("%s: bad divider offset for %s (%u > %u)\n", 85 pr_err("%s: bad divider offset for %s (%u > %u)\n",
86 __func__, name, div->offset, limit); 86 __func__, name, div->u.s.offset, limit);
87 return false; 87 return false;
88 } 88 }
89 } 89 }
90 90
91 div = &peri->pre_div; 91 div = &peri->pre_div;
92 if (divider_exists(div)) { 92 if (divider_exists(div)) {
93 if (div->offset > limit) { 93 if (div->u.s.offset > limit) {
94 pr_err("%s: bad pre-divider offset for %s " 94 pr_err("%s: bad pre-divider offset for %s "
95 "(%u > %u)\n", 95 "(%u > %u)\n",
96 __func__, name, div->offset, limit); 96 __func__, name, div->u.s.offset, limit);
97 return false; 97 return false;
98 } 98 }
99 } 99 }
@@ -249,21 +249,22 @@ static bool div_valid(struct bcm_clk_div *div, const char *field_name,
249{ 249{
250 if (divider_is_fixed(div)) { 250 if (divider_is_fixed(div)) {
251 /* Any fixed divider value but 0 is OK */ 251 /* Any fixed divider value but 0 is OK */
252 if (div->fixed == 0) { 252 if (div->u.fixed == 0) {
253 pr_err("%s: bad %s fixed value 0 for %s\n", __func__, 253 pr_err("%s: bad %s fixed value 0 for %s\n", __func__,
254 field_name, clock_name); 254 field_name, clock_name);
255 return false; 255 return false;
256 } 256 }
257 return true; 257 return true;
258 } 258 }
259 if (!bitfield_valid(div->shift, div->width, field_name, clock_name)) 259 if (!bitfield_valid(div->u.s.shift, div->u.s.width,
260 field_name, clock_name))
260 return false; 261 return false;
261 262
262 if (divider_has_fraction(div)) 263 if (divider_has_fraction(div))
263 if (div->frac_width > div->width) { 264 if (div->u.s.frac_width > div->u.s.width) {
264 pr_warn("%s: bad %s fraction width for %s (%u > %u)\n", 265 pr_warn("%s: bad %s fraction width for %s (%u > %u)\n",
265 __func__, field_name, clock_name, 266 __func__, field_name, clock_name,
266 div->frac_width, div->width); 267 div->u.s.frac_width, div->u.s.width);
267 return false; 268 return false;
268 } 269 }
269 270
@@ -278,7 +279,7 @@ static bool div_valid(struct bcm_clk_div *div, const char *field_name,
278 */ 279 */
279static bool kona_dividers_valid(struct kona_clk *bcm_clk) 280static bool kona_dividers_valid(struct kona_clk *bcm_clk)
280{ 281{
281 struct peri_clk_data *peri = bcm_clk->peri; 282 struct peri_clk_data *peri = bcm_clk->u.peri;
282 struct bcm_clk_div *div; 283 struct bcm_clk_div *div;
283 struct bcm_clk_div *pre_div; 284 struct bcm_clk_div *pre_div;
284 u32 limit; 285 u32 limit;
@@ -295,7 +296,7 @@ static bool kona_dividers_valid(struct kona_clk *bcm_clk)
295 296
296 limit = BITS_PER_BYTE * sizeof(u32); 297 limit = BITS_PER_BYTE * sizeof(u32);
297 298
298 return div->frac_width + pre_div->frac_width <= limit; 299 return div->u.s.frac_width + pre_div->u.s.frac_width <= limit;
299} 300}
300 301
301 302
@@ -328,7 +329,7 @@ peri_clk_data_valid(struct kona_clk *bcm_clk)
328 if (!peri_clk_data_offsets_valid(bcm_clk)) 329 if (!peri_clk_data_offsets_valid(bcm_clk))
329 return false; 330 return false;
330 331
331 peri = bcm_clk->peri; 332 peri = bcm_clk->u.peri;
332 name = bcm_clk->name; 333 name = bcm_clk->name;
333 gate = &peri->gate; 334 gate = &peri->gate;
334 if (gate_exists(gate) && !gate_valid(gate, "gate", name)) 335 if (gate_exists(gate) && !gate_valid(gate, "gate", name))
@@ -588,12 +589,12 @@ static void bcm_clk_teardown(struct kona_clk *bcm_clk)
588{ 589{
589 switch (bcm_clk->type) { 590 switch (bcm_clk->type) {
590 case bcm_clk_peri: 591 case bcm_clk_peri:
591 peri_clk_teardown(bcm_clk->data, &bcm_clk->init_data); 592 peri_clk_teardown(bcm_clk->u.data, &bcm_clk->init_data);
592 break; 593 break;
593 default: 594 default:
594 break; 595 break;
595 } 596 }
596 bcm_clk->data = NULL; 597 bcm_clk->u.data = NULL;
597 bcm_clk->type = bcm_clk_none; 598 bcm_clk->type = bcm_clk_none;
598} 599}
599 600
@@ -644,7 +645,7 @@ struct clk *kona_clk_setup(struct ccu_data *ccu, const char *name,
644 break; 645 break;
645 } 646 }
646 bcm_clk->type = type; 647 bcm_clk->type = type;
647 bcm_clk->data = data; 648 bcm_clk->u.data = data;
648 649
649 /* Make sure everything makes sense before we set it up */ 650 /* Make sure everything makes sense before we set it up */
650 if (!kona_clk_valid(bcm_clk)) { 651 if (!kona_clk_valid(bcm_clk)) {
diff --git a/drivers/clk/bcm/clk-kona.c b/drivers/clk/bcm/clk-kona.c
index e3d339e08309..db11a87449f2 100644
--- a/drivers/clk/bcm/clk-kona.c
+++ b/drivers/clk/bcm/clk-kona.c
@@ -61,7 +61,7 @@ u64 do_div_round_closest(u64 dividend, unsigned long divisor)
61/* Convert a divider into the scaled divisor value it represents. */ 61/* Convert a divider into the scaled divisor value it represents. */
62static inline u64 scaled_div_value(struct bcm_clk_div *div, u32 reg_div) 62static inline u64 scaled_div_value(struct bcm_clk_div *div, u32 reg_div)
63{ 63{
64 return (u64)reg_div + ((u64)1 << div->frac_width); 64 return (u64)reg_div + ((u64)1 << div->u.s.frac_width);
65} 65}
66 66
67/* 67/*
@@ -77,7 +77,7 @@ u64 scaled_div_build(struct bcm_clk_div *div, u32 div_value, u32 billionths)
77 BUG_ON(billionths >= BILLION); 77 BUG_ON(billionths >= BILLION);
78 78
79 combined = (u64)div_value * BILLION + billionths; 79 combined = (u64)div_value * BILLION + billionths;
80 combined <<= div->frac_width; 80 combined <<= div->u.s.frac_width;
81 81
82 return do_div_round_closest(combined, BILLION); 82 return do_div_round_closest(combined, BILLION);
83} 83}
@@ -87,7 +87,7 @@ static inline u64
87scaled_div_min(struct bcm_clk_div *div) 87scaled_div_min(struct bcm_clk_div *div)
88{ 88{
89 if (divider_is_fixed(div)) 89 if (divider_is_fixed(div))
90 return (u64)div->fixed; 90 return (u64)div->u.fixed;
91 91
92 return scaled_div_value(div, 0); 92 return scaled_div_value(div, 0);
93} 93}
@@ -98,9 +98,9 @@ u64 scaled_div_max(struct bcm_clk_div *div)
98 u32 reg_div; 98 u32 reg_div;
99 99
100 if (divider_is_fixed(div)) 100 if (divider_is_fixed(div))
101 return (u64)div->fixed; 101 return (u64)div->u.fixed;
102 102
103 reg_div = ((u32)1 << div->width) - 1; 103 reg_div = ((u32)1 << div->u.s.width) - 1;
104 104
105 return scaled_div_value(div, reg_div); 105 return scaled_div_value(div, reg_div);
106} 106}
@@ -115,7 +115,7 @@ divider(struct bcm_clk_div *div, u64 scaled_div)
115 BUG_ON(scaled_div < scaled_div_min(div)); 115 BUG_ON(scaled_div < scaled_div_min(div));
116 BUG_ON(scaled_div > scaled_div_max(div)); 116 BUG_ON(scaled_div > scaled_div_max(div));
117 117
118 return (u32)(scaled_div - ((u64)1 << div->frac_width)); 118 return (u32)(scaled_div - ((u64)1 << div->u.s.frac_width));
119} 119}
120 120
121/* Return a rate scaled for use when dividing by a scaled divisor. */ 121/* Return a rate scaled for use when dividing by a scaled divisor. */
@@ -125,7 +125,7 @@ scale_rate(struct bcm_clk_div *div, u32 rate)
125 if (divider_is_fixed(div)) 125 if (divider_is_fixed(div))
126 return (u64)rate; 126 return (u64)rate;
127 127
128 return (u64)rate << div->frac_width; 128 return (u64)rate << div->u.s.frac_width;
129} 129}
130 130
131/* CCU access */ 131/* CCU access */
@@ -398,14 +398,14 @@ static u64 divider_read_scaled(struct ccu_data *ccu, struct bcm_clk_div *div)
398 u32 reg_div; 398 u32 reg_div;
399 399
400 if (divider_is_fixed(div)) 400 if (divider_is_fixed(div))
401 return (u64)div->fixed; 401 return (u64)div->u.fixed;
402 402
403 flags = ccu_lock(ccu); 403 flags = ccu_lock(ccu);
404 reg_val = __ccu_read(ccu, div->offset); 404 reg_val = __ccu_read(ccu, div->u.s.offset);
405 ccu_unlock(ccu, flags); 405 ccu_unlock(ccu, flags);
406 406
407 /* Extract the full divider field from the register value */ 407 /* Extract the full divider field from the register value */
408 reg_div = bitfield_extract(reg_val, div->shift, div->width); 408 reg_div = bitfield_extract(reg_val, div->u.s.shift, div->u.s.width);
409 409
410 /* Return the scaled divisor value it represents */ 410 /* Return the scaled divisor value it represents */
411 return scaled_div_value(div, reg_div); 411 return scaled_div_value(div, reg_div);
@@ -433,16 +433,17 @@ static int __div_commit(struct ccu_data *ccu, struct bcm_clk_gate *gate,
433 * state was defined in the device tree, we just find out 433 * state was defined in the device tree, we just find out
434 * what its current value is rather than updating it. 434 * what its current value is rather than updating it.
435 */ 435 */
436 if (div->scaled_div == BAD_SCALED_DIV_VALUE) { 436 if (div->u.s.scaled_div == BAD_SCALED_DIV_VALUE) {
437 reg_val = __ccu_read(ccu, div->offset); 437 reg_val = __ccu_read(ccu, div->u.s.offset);
438 reg_div = bitfield_extract(reg_val, div->shift, div->width); 438 reg_div = bitfield_extract(reg_val, div->u.s.shift,
439 div->scaled_div = scaled_div_value(div, reg_div); 439 div->u.s.width);
440 div->u.s.scaled_div = scaled_div_value(div, reg_div);
440 441
441 return 0; 442 return 0;
442 } 443 }
443 444
444 /* Convert the scaled divisor to the value we need to record */ 445 /* Convert the scaled divisor to the value we need to record */
445 reg_div = divider(div, div->scaled_div); 446 reg_div = divider(div, div->u.s.scaled_div);
446 447
447 /* Clock needs to be enabled before changing the rate */ 448 /* Clock needs to be enabled before changing the rate */
448 enabled = __is_clk_gate_enabled(ccu, gate); 449 enabled = __is_clk_gate_enabled(ccu, gate);
@@ -452,9 +453,10 @@ static int __div_commit(struct ccu_data *ccu, struct bcm_clk_gate *gate,
452 } 453 }
453 454
454 /* Replace the divider value and record the result */ 455 /* Replace the divider value and record the result */
455 reg_val = __ccu_read(ccu, div->offset); 456 reg_val = __ccu_read(ccu, div->u.s.offset);
456 reg_val = bitfield_replace(reg_val, div->shift, div->width, reg_div); 457 reg_val = bitfield_replace(reg_val, div->u.s.shift, div->u.s.width,
457 __ccu_write(ccu, div->offset, reg_val); 458 reg_div);
459 __ccu_write(ccu, div->u.s.offset, reg_val);
458 460
459 /* If the trigger fails we still want to disable the gate */ 461 /* If the trigger fails we still want to disable the gate */
460 if (!__clk_trigger(ccu, trig)) 462 if (!__clk_trigger(ccu, trig))
@@ -490,11 +492,11 @@ static int divider_write(struct ccu_data *ccu, struct bcm_clk_gate *gate,
490 492
491 BUG_ON(divider_is_fixed(div)); 493 BUG_ON(divider_is_fixed(div));
492 494
493 previous = div->scaled_div; 495 previous = div->u.s.scaled_div;
494 if (previous == scaled_div) 496 if (previous == scaled_div)
495 return 0; /* No change */ 497 return 0; /* No change */
496 498
497 div->scaled_div = scaled_div; 499 div->u.s.scaled_div = scaled_div;
498 500
499 flags = ccu_lock(ccu); 501 flags = ccu_lock(ccu);
500 __ccu_write_enable(ccu); 502 __ccu_write_enable(ccu);
@@ -505,7 +507,7 @@ static int divider_write(struct ccu_data *ccu, struct bcm_clk_gate *gate,
505 ccu_unlock(ccu, flags); 507 ccu_unlock(ccu, flags);
506 508
507 if (ret) 509 if (ret)
508 div->scaled_div = previous; /* Revert the change */ 510 div->u.s.scaled_div = previous; /* Revert the change */
509 511
510 return ret; 512 return ret;
511 513
@@ -802,7 +804,7 @@ static int selector_write(struct ccu_data *ccu, struct bcm_clk_gate *gate,
802static int kona_peri_clk_enable(struct clk_hw *hw) 804static int kona_peri_clk_enable(struct clk_hw *hw)
803{ 805{
804 struct kona_clk *bcm_clk = to_kona_clk(hw); 806 struct kona_clk *bcm_clk = to_kona_clk(hw);
805 struct bcm_clk_gate *gate = &bcm_clk->peri->gate; 807 struct bcm_clk_gate *gate = &bcm_clk->u.peri->gate;
806 808
807 return clk_gate(bcm_clk->ccu, bcm_clk->name, gate, true); 809 return clk_gate(bcm_clk->ccu, bcm_clk->name, gate, true);
808} 810}
@@ -810,7 +812,7 @@ static int kona_peri_clk_enable(struct clk_hw *hw)
810static void kona_peri_clk_disable(struct clk_hw *hw) 812static void kona_peri_clk_disable(struct clk_hw *hw)
811{ 813{
812 struct kona_clk *bcm_clk = to_kona_clk(hw); 814 struct kona_clk *bcm_clk = to_kona_clk(hw);
813 struct bcm_clk_gate *gate = &bcm_clk->peri->gate; 815 struct bcm_clk_gate *gate = &bcm_clk->u.peri->gate;
814 816
815 (void)clk_gate(bcm_clk->ccu, bcm_clk->name, gate, false); 817 (void)clk_gate(bcm_clk->ccu, bcm_clk->name, gate, false);
816} 818}
@@ -818,7 +820,7 @@ static void kona_peri_clk_disable(struct clk_hw *hw)
818static int kona_peri_clk_is_enabled(struct clk_hw *hw) 820static int kona_peri_clk_is_enabled(struct clk_hw *hw)
819{ 821{
820 struct kona_clk *bcm_clk = to_kona_clk(hw); 822 struct kona_clk *bcm_clk = to_kona_clk(hw);
821 struct bcm_clk_gate *gate = &bcm_clk->peri->gate; 823 struct bcm_clk_gate *gate = &bcm_clk->u.peri->gate;
822 824
823 return is_clk_gate_enabled(bcm_clk->ccu, gate) ? 1 : 0; 825 return is_clk_gate_enabled(bcm_clk->ccu, gate) ? 1 : 0;
824} 826}
@@ -827,7 +829,7 @@ static unsigned long kona_peri_clk_recalc_rate(struct clk_hw *hw,
827 unsigned long parent_rate) 829 unsigned long parent_rate)
828{ 830{
829 struct kona_clk *bcm_clk = to_kona_clk(hw); 831 struct kona_clk *bcm_clk = to_kona_clk(hw);
830 struct peri_clk_data *data = bcm_clk->peri; 832 struct peri_clk_data *data = bcm_clk->u.peri;
831 833
832 return clk_recalc_rate(bcm_clk->ccu, &data->div, &data->pre_div, 834 return clk_recalc_rate(bcm_clk->ccu, &data->div, &data->pre_div,
833 parent_rate); 835 parent_rate);
@@ -837,20 +839,20 @@ static long kona_peri_clk_round_rate(struct clk_hw *hw, unsigned long rate,
837 unsigned long *parent_rate) 839 unsigned long *parent_rate)
838{ 840{
839 struct kona_clk *bcm_clk = to_kona_clk(hw); 841 struct kona_clk *bcm_clk = to_kona_clk(hw);
840 struct bcm_clk_div *div = &bcm_clk->peri->div; 842 struct bcm_clk_div *div = &bcm_clk->u.peri->div;
841 843
842 if (!divider_exists(div)) 844 if (!divider_exists(div))
843 return __clk_get_rate(hw->clk); 845 return __clk_get_rate(hw->clk);
844 846
845 /* Quietly avoid a zero rate */ 847 /* Quietly avoid a zero rate */
846 return round_rate(bcm_clk->ccu, div, &bcm_clk->peri->pre_div, 848 return round_rate(bcm_clk->ccu, div, &bcm_clk->u.peri->pre_div,
847 rate ? rate : 1, *parent_rate, NULL); 849 rate ? rate : 1, *parent_rate, NULL);
848} 850}
849 851
850static int kona_peri_clk_set_parent(struct clk_hw *hw, u8 index) 852static int kona_peri_clk_set_parent(struct clk_hw *hw, u8 index)
851{ 853{
852 struct kona_clk *bcm_clk = to_kona_clk(hw); 854 struct kona_clk *bcm_clk = to_kona_clk(hw);
853 struct peri_clk_data *data = bcm_clk->peri; 855 struct peri_clk_data *data = bcm_clk->u.peri;
854 struct bcm_clk_sel *sel = &data->sel; 856 struct bcm_clk_sel *sel = &data->sel;
855 struct bcm_clk_trig *trig; 857 struct bcm_clk_trig *trig;
856 int ret; 858 int ret;
@@ -884,7 +886,7 @@ static int kona_peri_clk_set_parent(struct clk_hw *hw, u8 index)
884static u8 kona_peri_clk_get_parent(struct clk_hw *hw) 886static u8 kona_peri_clk_get_parent(struct clk_hw *hw)
885{ 887{
886 struct kona_clk *bcm_clk = to_kona_clk(hw); 888 struct kona_clk *bcm_clk = to_kona_clk(hw);
887 struct peri_clk_data *data = bcm_clk->peri; 889 struct peri_clk_data *data = bcm_clk->u.peri;
888 u8 index; 890 u8 index;
889 891
890 index = selector_read_index(bcm_clk->ccu, &data->sel); 892 index = selector_read_index(bcm_clk->ccu, &data->sel);
@@ -897,7 +899,7 @@ static int kona_peri_clk_set_rate(struct clk_hw *hw, unsigned long rate,
897 unsigned long parent_rate) 899 unsigned long parent_rate)
898{ 900{
899 struct kona_clk *bcm_clk = to_kona_clk(hw); 901 struct kona_clk *bcm_clk = to_kona_clk(hw);
900 struct peri_clk_data *data = bcm_clk->peri; 902 struct peri_clk_data *data = bcm_clk->u.peri;
901 struct bcm_clk_div *div = &data->div; 903 struct bcm_clk_div *div = &data->div;
902 u64 scaled_div = 0; 904 u64 scaled_div = 0;
903 int ret; 905 int ret;
@@ -958,7 +960,7 @@ struct clk_ops kona_peri_clk_ops = {
958static bool __peri_clk_init(struct kona_clk *bcm_clk) 960static bool __peri_clk_init(struct kona_clk *bcm_clk)
959{ 961{
960 struct ccu_data *ccu = bcm_clk->ccu; 962 struct ccu_data *ccu = bcm_clk->ccu;
961 struct peri_clk_data *peri = bcm_clk->peri; 963 struct peri_clk_data *peri = bcm_clk->u.peri;
962 const char *name = bcm_clk->name; 964 const char *name = bcm_clk->name;
963 struct bcm_clk_trig *trig; 965 struct bcm_clk_trig *trig;
964 966
diff --git a/drivers/clk/bcm/clk-kona.h b/drivers/clk/bcm/clk-kona.h
index 5e139adc3dc5..dee690951bb6 100644
--- a/drivers/clk/bcm/clk-kona.h
+++ b/drivers/clk/bcm/clk-kona.h
@@ -57,7 +57,7 @@
57#define divider_exists(div) FLAG_TEST(div, DIV, EXISTS) 57#define divider_exists(div) FLAG_TEST(div, DIV, EXISTS)
58#define divider_is_fixed(div) FLAG_TEST(div, DIV, FIXED) 58#define divider_is_fixed(div) FLAG_TEST(div, DIV, FIXED)
59#define divider_has_fraction(div) (!divider_is_fixed(div) && \ 59#define divider_has_fraction(div) (!divider_is_fixed(div) && \
60 (div)->frac_width > 0) 60 (div)->u.s.frac_width > 0)
61 61
62#define selector_exists(sel) ((sel)->width != 0) 62#define selector_exists(sel) ((sel)->width != 0)
63#define trigger_exists(trig) FLAG_TEST(trig, TRIG, EXISTS) 63#define trigger_exists(trig) FLAG_TEST(trig, TRIG, EXISTS)
@@ -244,9 +244,9 @@ struct bcm_clk_div {
244 u32 frac_width; /* field fraction width */ 244 u32 frac_width; /* field fraction width */
245 245
246 u64 scaled_div; /* scaled divider value */ 246 u64 scaled_div; /* scaled divider value */
247 }; 247 } s;
248 u32 fixed; /* non-zero fixed divider value */ 248 u32 fixed; /* non-zero fixed divider value */
249 }; 249 } u;
250 u32 flags; /* BCM_CLK_DIV_FLAGS_* below */ 250 u32 flags; /* BCM_CLK_DIV_FLAGS_* below */
251}; 251};
252 252
@@ -263,28 +263,28 @@ struct bcm_clk_div {
263/* A fixed (non-zero) divider */ 263/* A fixed (non-zero) divider */
264#define FIXED_DIVIDER(_value) \ 264#define FIXED_DIVIDER(_value) \
265 { \ 265 { \
266 .fixed = (_value), \ 266 .u.fixed = (_value), \
267 .flags = FLAG(DIV, EXISTS)|FLAG(DIV, FIXED), \ 267 .flags = FLAG(DIV, EXISTS)|FLAG(DIV, FIXED), \
268 } 268 }
269 269
270/* A divider with an integral divisor */ 270/* A divider with an integral divisor */
271#define DIVIDER(_offset, _shift, _width) \ 271#define DIVIDER(_offset, _shift, _width) \
272 { \ 272 { \
273 .offset = (_offset), \ 273 .u.s.offset = (_offset), \
274 .shift = (_shift), \ 274 .u.s.shift = (_shift), \
275 .width = (_width), \ 275 .u.s.width = (_width), \
276 .scaled_div = BAD_SCALED_DIV_VALUE, \ 276 .u.s.scaled_div = BAD_SCALED_DIV_VALUE, \
277 .flags = FLAG(DIV, EXISTS), \ 277 .flags = FLAG(DIV, EXISTS), \
278 } 278 }
279 279
280/* A divider whose divisor has an integer and fractional part */ 280/* A divider whose divisor has an integer and fractional part */
281#define FRAC_DIVIDER(_offset, _shift, _width, _frac_width) \ 281#define FRAC_DIVIDER(_offset, _shift, _width, _frac_width) \
282 { \ 282 { \
283 .offset = (_offset), \ 283 .u.s.offset = (_offset), \
284 .shift = (_shift), \ 284 .u.s.shift = (_shift), \
285 .width = (_width), \ 285 .u.s.width = (_width), \
286 .frac_width = (_frac_width), \ 286 .u.s.frac_width = (_frac_width), \
287 .scaled_div = BAD_SCALED_DIV_VALUE, \ 287 .u.s.scaled_div = BAD_SCALED_DIV_VALUE, \
288 .flags = FLAG(DIV, EXISTS), \ 288 .flags = FLAG(DIV, EXISTS), \
289 } 289 }
290 290
@@ -380,7 +380,7 @@ struct kona_clk {
380 union { 380 union {
381 void *data; 381 void *data;
382 struct peri_clk_data *peri; 382 struct peri_clk_data *peri;
383 }; 383 } u;
384}; 384};
385#define to_kona_clk(_hw) \ 385#define to_kona_clk(_hw) \
386 container_of(_hw, struct kona_clk, hw) 386 container_of(_hw, struct kona_clk, hw)
diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index ec22112e569f..4637697c139f 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -144,6 +144,37 @@ static bool _is_valid_div(struct clk_divider *divider, unsigned int div)
144 return true; 144 return true;
145} 145}
146 146
147static int _round_up_table(const struct clk_div_table *table, int div)
148{
149 const struct clk_div_table *clkt;
150 int up = _get_table_maxdiv(table);
151
152 for (clkt = table; clkt->div; clkt++) {
153 if (clkt->div == div)
154 return clkt->div;
155 else if (clkt->div < div)
156 continue;
157
158 if ((clkt->div - div) < (up - div))
159 up = clkt->div;
160 }
161
162 return up;
163}
164
165static int _div_round_up(struct clk_divider *divider,
166 unsigned long parent_rate, unsigned long rate)
167{
168 int div = DIV_ROUND_UP(parent_rate, rate);
169
170 if (divider->flags & CLK_DIVIDER_POWER_OF_TWO)
171 div = __roundup_pow_of_two(div);
172 if (divider->table)
173 div = _round_up_table(divider->table, div);
174
175 return div;
176}
177
147static int clk_divider_bestdiv(struct clk_hw *hw, unsigned long rate, 178static int clk_divider_bestdiv(struct clk_hw *hw, unsigned long rate,
148 unsigned long *best_parent_rate) 179 unsigned long *best_parent_rate)
149{ 180{
@@ -159,7 +190,7 @@ static int clk_divider_bestdiv(struct clk_hw *hw, unsigned long rate,
159 190
160 if (!(__clk_get_flags(hw->clk) & CLK_SET_RATE_PARENT)) { 191 if (!(__clk_get_flags(hw->clk) & CLK_SET_RATE_PARENT)) {
161 parent_rate = *best_parent_rate; 192 parent_rate = *best_parent_rate;
162 bestdiv = DIV_ROUND_UP(parent_rate, rate); 193 bestdiv = _div_round_up(divider, parent_rate, rate);
163 bestdiv = bestdiv == 0 ? 1 : bestdiv; 194 bestdiv = bestdiv == 0 ? 1 : bestdiv;
164 bestdiv = bestdiv > maxdiv ? maxdiv : bestdiv; 195 bestdiv = bestdiv > maxdiv ? maxdiv : bestdiv;
165 return bestdiv; 196 return bestdiv;
@@ -219,6 +250,10 @@ static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate,
219 u32 val; 250 u32 val;
220 251
221 div = DIV_ROUND_UP(parent_rate, rate); 252 div = DIV_ROUND_UP(parent_rate, rate);
253
254 if (!_is_valid_div(divider, div))
255 return -EINVAL;
256
222 value = _get_val(divider, div); 257 value = _get_val(divider, div);
223 258
224 if (value > div_mask(divider)) 259 if (value > div_mask(divider))
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index dff0373f53c1..7cf2c093cc54 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -1984,9 +1984,28 @@ struct clk *__clk_register(struct device *dev, struct clk_hw *hw)
1984} 1984}
1985EXPORT_SYMBOL_GPL(__clk_register); 1985EXPORT_SYMBOL_GPL(__clk_register);
1986 1986
1987static int _clk_register(struct device *dev, struct clk_hw *hw, struct clk *clk) 1987/**
1988 * clk_register - allocate a new clock, register it and return an opaque cookie
1989 * @dev: device that is registering this clock
1990 * @hw: link to hardware-specific clock data
1991 *
1992 * clk_register is the primary interface for populating the clock tree with new
1993 * clock nodes. It returns a pointer to the newly allocated struct clk which
1994 * cannot be dereferenced by driver code but may be used in conjuction with the
1995 * rest of the clock API. In the event of an error clk_register will return an
1996 * error code; drivers must test for an error code after calling clk_register.
1997 */
1998struct clk *clk_register(struct device *dev, struct clk_hw *hw)
1988{ 1999{
1989 int i, ret; 2000 int i, ret;
2001 struct clk *clk;
2002
2003 clk = kzalloc(sizeof(*clk), GFP_KERNEL);
2004 if (!clk) {
2005 pr_err("%s: could not allocate clk\n", __func__);
2006 ret = -ENOMEM;
2007 goto fail_out;
2008 }
1990 2009
1991 clk->name = kstrdup(hw->init->name, GFP_KERNEL); 2010 clk->name = kstrdup(hw->init->name, GFP_KERNEL);
1992 if (!clk->name) { 2011 if (!clk->name) {
@@ -2026,7 +2045,7 @@ static int _clk_register(struct device *dev, struct clk_hw *hw, struct clk *clk)
2026 2045
2027 ret = __clk_init(dev, clk); 2046 ret = __clk_init(dev, clk);
2028 if (!ret) 2047 if (!ret)
2029 return 0; 2048 return clk;
2030 2049
2031fail_parent_names_copy: 2050fail_parent_names_copy:
2032 while (--i >= 0) 2051 while (--i >= 0)
@@ -2035,36 +2054,6 @@ fail_parent_names_copy:
2035fail_parent_names: 2054fail_parent_names:
2036 kfree(clk->name); 2055 kfree(clk->name);
2037fail_name: 2056fail_name:
2038 return ret;
2039}
2040
2041/**
2042 * clk_register - allocate a new clock, register it and return an opaque cookie
2043 * @dev: device that is registering this clock
2044 * @hw: link to hardware-specific clock data
2045 *
2046 * clk_register is the primary interface for populating the clock tree with new
2047 * clock nodes. It returns a pointer to the newly allocated struct clk which
2048 * cannot be dereferenced by driver code but may be used in conjuction with the
2049 * rest of the clock API. In the event of an error clk_register will return an
2050 * error code; drivers must test for an error code after calling clk_register.
2051 */
2052struct clk *clk_register(struct device *dev, struct clk_hw *hw)
2053{
2054 int ret;
2055 struct clk *clk;
2056
2057 clk = kzalloc(sizeof(*clk), GFP_KERNEL);
2058 if (!clk) {
2059 pr_err("%s: could not allocate clk\n", __func__);
2060 ret = -ENOMEM;
2061 goto fail_out;
2062 }
2063
2064 ret = _clk_register(dev, hw, clk);
2065 if (!ret)
2066 return clk;
2067
2068 kfree(clk); 2057 kfree(clk);
2069fail_out: 2058fail_out:
2070 return ERR_PTR(ret); 2059 return ERR_PTR(ret);
@@ -2151,9 +2140,10 @@ void clk_unregister(struct clk *clk)
2151 2140
2152 if (!hlist_empty(&clk->children)) { 2141 if (!hlist_empty(&clk->children)) {
2153 struct clk *child; 2142 struct clk *child;
2143 struct hlist_node *t;
2154 2144
2155 /* Reparent all children to the orphan list. */ 2145 /* Reparent all children to the orphan list. */
2156 hlist_for_each_entry(child, &clk->children, child_node) 2146 hlist_for_each_entry_safe(child, t, &clk->children, child_node)
2157 clk_set_parent(child, NULL); 2147 clk_set_parent(child, NULL);
2158 } 2148 }
2159 2149
@@ -2173,7 +2163,7 @@ EXPORT_SYMBOL_GPL(clk_unregister);
2173 2163
2174static void devm_clk_release(struct device *dev, void *res) 2164static void devm_clk_release(struct device *dev, void *res)
2175{ 2165{
2176 clk_unregister(res); 2166 clk_unregister(*(struct clk **)res);
2177} 2167}
2178 2168
2179/** 2169/**
@@ -2188,18 +2178,18 @@ static void devm_clk_release(struct device *dev, void *res)
2188struct clk *devm_clk_register(struct device *dev, struct clk_hw *hw) 2178struct clk *devm_clk_register(struct device *dev, struct clk_hw *hw)
2189{ 2179{
2190 struct clk *clk; 2180 struct clk *clk;
2191 int ret; 2181 struct clk **clkp;
2192 2182
2193 clk = devres_alloc(devm_clk_release, sizeof(*clk), GFP_KERNEL); 2183 clkp = devres_alloc(devm_clk_release, sizeof(*clkp), GFP_KERNEL);
2194 if (!clk) 2184 if (!clkp)
2195 return ERR_PTR(-ENOMEM); 2185 return ERR_PTR(-ENOMEM);
2196 2186
2197 ret = _clk_register(dev, hw, clk); 2187 clk = clk_register(dev, hw);
2198 if (!ret) { 2188 if (!IS_ERR(clk)) {
2199 devres_add(dev, clk); 2189 *clkp = clk;
2190 devres_add(dev, clkp);
2200 } else { 2191 } else {
2201 devres_free(clk); 2192 devres_free(clkp);
2202 clk = ERR_PTR(ret);
2203 } 2193 }
2204 2194
2205 return clk; 2195 return clk;
diff --git a/drivers/clk/shmobile/clk-mstp.c b/drivers/clk/shmobile/clk-mstp.c
index 2e5810c88d11..1f6324e29a80 100644
--- a/drivers/clk/shmobile/clk-mstp.c
+++ b/drivers/clk/shmobile/clk-mstp.c
@@ -156,6 +156,7 @@ cpg_mstp_clock_register(const char *name, const char *parent_name,
156static void __init cpg_mstp_clocks_init(struct device_node *np) 156static void __init cpg_mstp_clocks_init(struct device_node *np)
157{ 157{
158 struct mstp_clock_group *group; 158 struct mstp_clock_group *group;
159 const char *idxname;
159 struct clk **clks; 160 struct clk **clks;
160 unsigned int i; 161 unsigned int i;
161 162
@@ -184,6 +185,11 @@ static void __init cpg_mstp_clocks_init(struct device_node *np)
184 for (i = 0; i < MSTP_MAX_CLOCKS; ++i) 185 for (i = 0; i < MSTP_MAX_CLOCKS; ++i)
185 clks[i] = ERR_PTR(-ENOENT); 186 clks[i] = ERR_PTR(-ENOENT);
186 187
188 if (of_find_property(np, "clock-indices", &i))
189 idxname = "clock-indices";
190 else
191 idxname = "renesas,clock-indices";
192
187 for (i = 0; i < MSTP_MAX_CLOCKS; ++i) { 193 for (i = 0; i < MSTP_MAX_CLOCKS; ++i) {
188 const char *parent_name; 194 const char *parent_name;
189 const char *name; 195 const char *name;
@@ -197,8 +203,7 @@ static void __init cpg_mstp_clocks_init(struct device_node *np)
197 continue; 203 continue;
198 204
199 parent_name = of_clk_get_parent_name(np, i); 205 parent_name = of_clk_get_parent_name(np, i);
200 ret = of_property_read_u32_index(np, "renesas,clock-indices", i, 206 ret = of_property_read_u32_index(np, idxname, i, &clkidx);
201 &clkidx);
202 if (parent_name == NULL || ret < 0) 207 if (parent_name == NULL || ret < 0)
203 break; 208 break;
204 209
diff --git a/drivers/clk/socfpga/clk-pll.c b/drivers/clk/socfpga/clk-pll.c
index 88dafb5e9627..de6da957a09d 100644
--- a/drivers/clk/socfpga/clk-pll.c
+++ b/drivers/clk/socfpga/clk-pll.c
@@ -20,6 +20,7 @@
20#include <linux/clk-provider.h> 20#include <linux/clk-provider.h>
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/of.h> 22#include <linux/of.h>
23#include <linux/of_address.h>
23 24
24#include "clk.h" 25#include "clk.h"
25 26
@@ -43,6 +44,8 @@
43 44
44#define to_socfpga_clk(p) container_of(p, struct socfpga_pll, hw.hw) 45#define to_socfpga_clk(p) container_of(p, struct socfpga_pll, hw.hw)
45 46
47void __iomem *clk_mgr_base_addr;
48
46static unsigned long clk_pll_recalc_rate(struct clk_hw *hwclk, 49static unsigned long clk_pll_recalc_rate(struct clk_hw *hwclk,
47 unsigned long parent_rate) 50 unsigned long parent_rate)
48{ 51{
@@ -87,6 +90,7 @@ static __init struct clk *__socfpga_pll_init(struct device_node *node,
87 const char *clk_name = node->name; 90 const char *clk_name = node->name;
88 const char *parent_name[SOCFPGA_MAX_PARENTS]; 91 const char *parent_name[SOCFPGA_MAX_PARENTS];
89 struct clk_init_data init; 92 struct clk_init_data init;
93 struct device_node *clkmgr_np;
90 int rc; 94 int rc;
91 int i = 0; 95 int i = 0;
92 96
@@ -96,6 +100,9 @@ static __init struct clk *__socfpga_pll_init(struct device_node *node,
96 if (WARN_ON(!pll_clk)) 100 if (WARN_ON(!pll_clk))
97 return NULL; 101 return NULL;
98 102
103 clkmgr_np = of_find_compatible_node(NULL, NULL, "altr,clk-mgr");
104 clk_mgr_base_addr = of_iomap(clkmgr_np, 0);
105 BUG_ON(!clk_mgr_base_addr);
99 pll_clk->hw.reg = clk_mgr_base_addr + reg; 106 pll_clk->hw.reg = clk_mgr_base_addr + reg;
100 107
101 of_property_read_string(node, "clock-output-names", &clk_name); 108 of_property_read_string(node, "clock-output-names", &clk_name);
diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
index 35a960a993f9..43db947e5f0e 100644
--- a/drivers/clk/socfpga/clk.c
+++ b/drivers/clk/socfpga/clk.c
@@ -17,28 +17,11 @@
17 * You should have received a copy of the GNU General Public License 17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */ 19 */
20#include <linux/clk.h>
21#include <linux/clkdev.h>
22#include <linux/clk-provider.h>
23#include <linux/io.h>
24#include <linux/of.h> 20#include <linux/of.h>
25#include <linux/of_address.h>
26 21
27#include "clk.h" 22#include "clk.h"
28 23
29void __iomem *clk_mgr_base_addr; 24CLK_OF_DECLARE(socfpga_pll_clk, "altr,socfpga-pll-clock", socfpga_pll_init);
30 25CLK_OF_DECLARE(socfpga_perip_clk, "altr,socfpga-perip-clk", socfpga_periph_init);
31static const struct of_device_id socfpga_child_clocks[] __initconst = { 26CLK_OF_DECLARE(socfpga_gate_clk, "altr,socfpga-gate-clk", socfpga_gate_init);
32 { .compatible = "altr,socfpga-pll-clock", socfpga_pll_init, },
33 { .compatible = "altr,socfpga-perip-clk", socfpga_periph_init, },
34 { .compatible = "altr,socfpga-gate-clk", socfpga_gate_init, },
35 {},
36};
37
38static void __init socfpga_clkmgr_init(struct device_node *node)
39{
40 clk_mgr_base_addr = of_iomap(node, 0);
41 of_clk_init(socfpga_child_clocks);
42}
43CLK_OF_DECLARE(socfpga_mgr, "altr,clk-mgr", socfpga_clkmgr_init);
44 27
diff --git a/drivers/clk/tegra/clk-pll.c b/drivers/clk/tegra/clk-pll.c
index 0d20241e0770..e1769addf435 100644
--- a/drivers/clk/tegra/clk-pll.c
+++ b/drivers/clk/tegra/clk-pll.c
@@ -1718,7 +1718,7 @@ struct clk *tegra_clk_register_plle_tegra114(const char *name,
1718 "pll_re_vco"); 1718 "pll_re_vco");
1719 } else { 1719 } else {
1720 val_aux &= ~(PLLE_AUX_PLLRE_SEL | PLLE_AUX_PLLP_SEL); 1720 val_aux &= ~(PLLE_AUX_PLLRE_SEL | PLLE_AUX_PLLP_SEL);
1721 pll_writel(val, pll_params->aux_reg, pll); 1721 pll_writel(val_aux, pll_params->aux_reg, pll);
1722 } 1722 }
1723 1723
1724 clk = _tegra_clk_register_pll(pll, name, parent_name, flags, 1724 clk = _tegra_clk_register_pll(pll, name, parent_name, flags,
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 099967302bf2..eab8ccfe6beb 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -37,6 +37,7 @@
37#define BYT_RATIOS 0x66a 37#define BYT_RATIOS 0x66a
38#define BYT_VIDS 0x66b 38#define BYT_VIDS 0x66b
39#define BYT_TURBO_RATIOS 0x66c 39#define BYT_TURBO_RATIOS 0x66c
40#define BYT_TURBO_VIDS 0x66d
40 41
41 42
42#define FRAC_BITS 6 43#define FRAC_BITS 6
@@ -70,8 +71,9 @@ struct pstate_data {
70}; 71};
71 72
72struct vid_data { 73struct vid_data {
73 int32_t min; 74 int min;
74 int32_t max; 75 int max;
76 int turbo;
75 int32_t ratio; 77 int32_t ratio;
76}; 78};
77 79
@@ -359,14 +361,14 @@ static int byt_get_min_pstate(void)
359{ 361{
360 u64 value; 362 u64 value;
361 rdmsrl(BYT_RATIOS, value); 363 rdmsrl(BYT_RATIOS, value);
362 return (value >> 8) & 0xFF; 364 return (value >> 8) & 0x3F;
363} 365}
364 366
365static int byt_get_max_pstate(void) 367static int byt_get_max_pstate(void)
366{ 368{
367 u64 value; 369 u64 value;
368 rdmsrl(BYT_RATIOS, value); 370 rdmsrl(BYT_RATIOS, value);
369 return (value >> 16) & 0xFF; 371 return (value >> 16) & 0x3F;
370} 372}
371 373
372static int byt_get_turbo_pstate(void) 374static int byt_get_turbo_pstate(void)
@@ -393,6 +395,9 @@ static void byt_set_pstate(struct cpudata *cpudata, int pstate)
393 vid_fp = clamp_t(int32_t, vid_fp, cpudata->vid.min, cpudata->vid.max); 395 vid_fp = clamp_t(int32_t, vid_fp, cpudata->vid.min, cpudata->vid.max);
394 vid = fp_toint(vid_fp); 396 vid = fp_toint(vid_fp);
395 397
398 if (pstate > cpudata->pstate.max_pstate)
399 vid = cpudata->vid.turbo;
400
396 val |= vid; 401 val |= vid;
397 402
398 wrmsrl(MSR_IA32_PERF_CTL, val); 403 wrmsrl(MSR_IA32_PERF_CTL, val);
@@ -402,13 +407,17 @@ static void byt_get_vid(struct cpudata *cpudata)
402{ 407{
403 u64 value; 408 u64 value;
404 409
410
405 rdmsrl(BYT_VIDS, value); 411 rdmsrl(BYT_VIDS, value);
406 cpudata->vid.min = int_tofp((value >> 8) & 0x7f); 412 cpudata->vid.min = int_tofp((value >> 8) & 0x3f);
407 cpudata->vid.max = int_tofp((value >> 16) & 0x7f); 413 cpudata->vid.max = int_tofp((value >> 16) & 0x3f);
408 cpudata->vid.ratio = div_fp( 414 cpudata->vid.ratio = div_fp(
409 cpudata->vid.max - cpudata->vid.min, 415 cpudata->vid.max - cpudata->vid.min,
410 int_tofp(cpudata->pstate.max_pstate - 416 int_tofp(cpudata->pstate.max_pstate -
411 cpudata->pstate.min_pstate)); 417 cpudata->pstate.min_pstate));
418
419 rdmsrl(BYT_TURBO_VIDS, value);
420 cpudata->vid.turbo = value & 0x7f;
412} 421}
413 422
414 423
@@ -545,12 +554,7 @@ static void intel_pstate_get_cpu_pstates(struct cpudata *cpu)
545 554
546 if (pstate_funcs.get_vid) 555 if (pstate_funcs.get_vid)
547 pstate_funcs.get_vid(cpu); 556 pstate_funcs.get_vid(cpu);
548 557 intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate);
549 /*
550 * goto max pstate so we don't slow up boot if we are built-in if we are
551 * a module we will take care of it during normal operation
552 */
553 intel_pstate_set_pstate(cpu, cpu->pstate.max_pstate);
554} 558}
555 559
556static inline void intel_pstate_calc_busy(struct cpudata *cpu, 560static inline void intel_pstate_calc_busy(struct cpudata *cpu,
@@ -695,11 +699,6 @@ static int intel_pstate_init_cpu(unsigned int cpunum)
695 cpu = all_cpu_data[cpunum]; 699 cpu = all_cpu_data[cpunum];
696 700
697 intel_pstate_get_cpu_pstates(cpu); 701 intel_pstate_get_cpu_pstates(cpu);
698 if (!cpu->pstate.current_pstate) {
699 all_cpu_data[cpunum] = NULL;
700 kfree(cpu);
701 return -ENODATA;
702 }
703 702
704 cpu->cpu = cpunum; 703 cpu->cpu = cpunum;
705 704
@@ -710,7 +709,6 @@ static int intel_pstate_init_cpu(unsigned int cpunum)
710 cpu->timer.expires = jiffies + HZ/100; 709 cpu->timer.expires = jiffies + HZ/100;
711 intel_pstate_busy_pid_reset(cpu); 710 intel_pstate_busy_pid_reset(cpu);
712 intel_pstate_sample(cpu); 711 intel_pstate_sample(cpu);
713 intel_pstate_set_pstate(cpu, cpu->pstate.max_pstate);
714 712
715 add_timer_on(&cpu->timer, cpunum); 713 add_timer_on(&cpu->timer, cpunum);
716 714
diff --git a/drivers/cpufreq/loongson2_cpufreq.c b/drivers/cpufreq/loongson2_cpufreq.c
index f0bc31f5db27..d4add8621944 100644
--- a/drivers/cpufreq/loongson2_cpufreq.c
+++ b/drivers/cpufreq/loongson2_cpufreq.c
@@ -62,7 +62,7 @@ static int loongson2_cpufreq_target(struct cpufreq_policy *policy,
62 set_cpus_allowed_ptr(current, &cpus_allowed); 62 set_cpus_allowed_ptr(current, &cpus_allowed);
63 63
64 /* setting the cpu frequency */ 64 /* setting the cpu frequency */
65 clk_set_rate(policy->clk, freq); 65 clk_set_rate(policy->clk, freq * 1000);
66 66
67 return 0; 67 return 0;
68} 68}
@@ -92,7 +92,7 @@ static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy)
92 i++) 92 i++)
93 loongson2_clockmod_table[i].frequency = (rate * i) / 8; 93 loongson2_clockmod_table[i].frequency = (rate * i) / 8;
94 94
95 ret = clk_set_rate(cpuclk, rate); 95 ret = clk_set_rate(cpuclk, rate * 1000);
96 if (ret) { 96 if (ret) {
97 clk_put(cpuclk); 97 clk_put(cpuclk);
98 return ret; 98 return ret;
diff --git a/drivers/crypto/caam/error.c b/drivers/crypto/caam/error.c
index 9f25f5296029..0eabd81e1a90 100644
--- a/drivers/crypto/caam/error.c
+++ b/drivers/crypto/caam/error.c
@@ -16,9 +16,13 @@
16 char *tmp; \ 16 char *tmp; \
17 \ 17 \
18 tmp = kmalloc(sizeof(format) + max_alloc, GFP_ATOMIC); \ 18 tmp = kmalloc(sizeof(format) + max_alloc, GFP_ATOMIC); \
19 sprintf(tmp, format, param); \ 19 if (likely(tmp)) { \
20 strcat(str, tmp); \ 20 sprintf(tmp, format, param); \
21 kfree(tmp); \ 21 strcat(str, tmp); \
22 kfree(tmp); \
23 } else { \
24 strcat(str, "kmalloc failure in SPRINTFCAT"); \
25 } \
22} 26}
23 27
24static void report_jump_idx(u32 status, char *outstr) 28static void report_jump_idx(u32 status, char *outstr)
diff --git a/drivers/firmware/iscsi_ibft.c b/drivers/firmware/iscsi_ibft.c
index 3ee852c9925b..071c2c969eec 100644
--- a/drivers/firmware/iscsi_ibft.c
+++ b/drivers/firmware/iscsi_ibft.c
@@ -756,6 +756,7 @@ static const struct {
756 */ 756 */
757 { ACPI_SIG_IBFT }, 757 { ACPI_SIG_IBFT },
758 { "iBFT" }, 758 { "iBFT" },
759 { "BIFT" }, /* Broadcom iSCSI Offload */
759}; 760};
760 761
761static void __init acpi_find_ibft_region(void) 762static void __init acpi_find_ibft_region(void)
diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
index e73c6755a5eb..70304220a479 100644
--- a/drivers/gpio/gpio-ich.c
+++ b/drivers/gpio/gpio-ich.c
@@ -305,6 +305,8 @@ static struct ichx_desc ich6_desc = {
305 305
306 .ngpio = 50, 306 .ngpio = 50,
307 .have_blink = true, 307 .have_blink = true,
308 .regs = ichx_regs,
309 .reglen = ichx_reglen,
308}; 310};
309 311
310/* Intel 3100 */ 312/* Intel 3100 */
@@ -324,6 +326,8 @@ static struct ichx_desc i3100_desc = {
324 .uses_gpe0 = true, 326 .uses_gpe0 = true,
325 327
326 .ngpio = 50, 328 .ngpio = 50,
329 .regs = ichx_regs,
330 .reglen = ichx_reglen,
327}; 331};
328 332
329/* ICH7 and ICH8-based */ 333/* ICH7 and ICH8-based */
diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c
index 99a68310e7c0..3d53fd6880d1 100644
--- a/drivers/gpio/gpio-mcp23s08.c
+++ b/drivers/gpio/gpio-mcp23s08.c
@@ -894,9 +894,11 @@ static int mcp23s08_probe(struct spi_device *spi)
894 dev_err(&spi->dev, "invalid spi-present-mask\n"); 894 dev_err(&spi->dev, "invalid spi-present-mask\n");
895 return -ENODEV; 895 return -ENODEV;
896 } 896 }
897 897 for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++) {
898 for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++) 898 if ((spi_present_mask & (1 << addr)))
899 chips++;
899 pullups[addr] = 0; 900 pullups[addr] = 0;
901 }
900 } else { 902 } else {
901 type = spi_get_device_id(spi)->driver_data; 903 type = spi_get_device_id(spi)->driver_data;
902 pdata = dev_get_platdata(&spi->dev); 904 pdata = dev_get_platdata(&spi->dev);
@@ -919,12 +921,12 @@ static int mcp23s08_probe(struct spi_device *spi)
919 pullups[addr] = pdata->chip[addr].pullups; 921 pullups[addr] = pdata->chip[addr].pullups;
920 } 922 }
921 923
922 if (!chips)
923 return -ENODEV;
924
925 base = pdata->base; 924 base = pdata->base;
926 } 925 }
927 926
927 if (!chips)
928 return -ENODEV;
929
928 data = kzalloc(sizeof(*data) + chips * sizeof(struct mcp23s08), 930 data = kzalloc(sizeof(*data) + chips * sizeof(struct mcp23s08),
929 GFP_KERNEL); 931 GFP_KERNEL);
930 if (!data) 932 if (!data)
diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
index fa486c5fbb02..aff4a113cda3 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -560,47 +560,71 @@ parse_edp(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
560 560
561 dev_priv->vbt.edp_pps = *edp_pps; 561 dev_priv->vbt.edp_pps = *edp_pps;
562 562
563 dev_priv->vbt.edp_rate = edp_link_params->rate ? DP_LINK_BW_2_7 : 563 switch (edp_link_params->rate) {
564 DP_LINK_BW_1_62; 564 case EDP_RATE_1_62:
565 dev_priv->vbt.edp_rate = DP_LINK_BW_1_62;
566 break;
567 case EDP_RATE_2_7:
568 dev_priv->vbt.edp_rate = DP_LINK_BW_2_7;
569 break;
570 default:
571 DRM_DEBUG_KMS("VBT has unknown eDP link rate value %u\n",
572 edp_link_params->rate);
573 break;
574 }
575
565 switch (edp_link_params->lanes) { 576 switch (edp_link_params->lanes) {
566 case 0: 577 case EDP_LANE_1:
567 dev_priv->vbt.edp_lanes = 1; 578 dev_priv->vbt.edp_lanes = 1;
568 break; 579 break;
569 case 1: 580 case EDP_LANE_2:
570 dev_priv->vbt.edp_lanes = 2; 581 dev_priv->vbt.edp_lanes = 2;
571 break; 582 break;
572 case 3: 583 case EDP_LANE_4:
573 default:
574 dev_priv->vbt.edp_lanes = 4; 584 dev_priv->vbt.edp_lanes = 4;
575 break; 585 break;
586 default:
587 DRM_DEBUG_KMS("VBT has unknown eDP lane count value %u\n",
588 edp_link_params->lanes);
589 break;
576 } 590 }
591
577 switch (edp_link_params->preemphasis) { 592 switch (edp_link_params->preemphasis) {
578 case 0: 593 case EDP_PREEMPHASIS_NONE:
579 dev_priv->vbt.edp_preemphasis = DP_TRAIN_PRE_EMPHASIS_0; 594 dev_priv->vbt.edp_preemphasis = DP_TRAIN_PRE_EMPHASIS_0;
580 break; 595 break;
581 case 1: 596 case EDP_PREEMPHASIS_3_5dB:
582 dev_priv->vbt.edp_preemphasis = DP_TRAIN_PRE_EMPHASIS_3_5; 597 dev_priv->vbt.edp_preemphasis = DP_TRAIN_PRE_EMPHASIS_3_5;
583 break; 598 break;
584 case 2: 599 case EDP_PREEMPHASIS_6dB:
585 dev_priv->vbt.edp_preemphasis = DP_TRAIN_PRE_EMPHASIS_6; 600 dev_priv->vbt.edp_preemphasis = DP_TRAIN_PRE_EMPHASIS_6;
586 break; 601 break;
587 case 3: 602 case EDP_PREEMPHASIS_9_5dB:
588 dev_priv->vbt.edp_preemphasis = DP_TRAIN_PRE_EMPHASIS_9_5; 603 dev_priv->vbt.edp_preemphasis = DP_TRAIN_PRE_EMPHASIS_9_5;
589 break; 604 break;
605 default:
606 DRM_DEBUG_KMS("VBT has unknown eDP pre-emphasis value %u\n",
607 edp_link_params->preemphasis);
608 break;
590 } 609 }
610
591 switch (edp_link_params->vswing) { 611 switch (edp_link_params->vswing) {
592 case 0: 612 case EDP_VSWING_0_4V:
593 dev_priv->vbt.edp_vswing = DP_TRAIN_VOLTAGE_SWING_400; 613 dev_priv->vbt.edp_vswing = DP_TRAIN_VOLTAGE_SWING_400;
594 break; 614 break;
595 case 1: 615 case EDP_VSWING_0_6V:
596 dev_priv->vbt.edp_vswing = DP_TRAIN_VOLTAGE_SWING_600; 616 dev_priv->vbt.edp_vswing = DP_TRAIN_VOLTAGE_SWING_600;
597 break; 617 break;
598 case 2: 618 case EDP_VSWING_0_8V:
599 dev_priv->vbt.edp_vswing = DP_TRAIN_VOLTAGE_SWING_800; 619 dev_priv->vbt.edp_vswing = DP_TRAIN_VOLTAGE_SWING_800;
600 break; 620 break;
601 case 3: 621 case EDP_VSWING_1_2V:
602 dev_priv->vbt.edp_vswing = DP_TRAIN_VOLTAGE_SWING_1200; 622 dev_priv->vbt.edp_vswing = DP_TRAIN_VOLTAGE_SWING_1200;
603 break; 623 break;
624 default:
625 DRM_DEBUG_KMS("VBT has unknown eDP voltage swing value %u\n",
626 edp_link_params->vswing);
627 break;
604 } 628 }
605} 629}
606 630
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 5ca68aa9f237..2a00cb828d20 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -121,6 +121,22 @@ intel_dp_max_link_bw(struct intel_dp *intel_dp)
121 return max_link_bw; 121 return max_link_bw;
122} 122}
123 123
124static u8 intel_dp_max_lane_count(struct intel_dp *intel_dp)
125{
126 struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
127 struct drm_device *dev = intel_dig_port->base.base.dev;
128 u8 source_max, sink_max;
129
130 source_max = 4;
131 if (HAS_DDI(dev) && intel_dig_port->port == PORT_A &&
132 (intel_dig_port->saved_port_bits & DDI_A_4_LANES) == 0)
133 source_max = 2;
134
135 sink_max = drm_dp_max_lane_count(intel_dp->dpcd);
136
137 return min(source_max, sink_max);
138}
139
124/* 140/*
125 * The units on the numbers in the next two are... bizarre. Examples will 141 * The units on the numbers in the next two are... bizarre. Examples will
126 * make it clearer; this one parallels an example in the eDP spec. 142 * make it clearer; this one parallels an example in the eDP spec.
@@ -171,7 +187,7 @@ intel_dp_mode_valid(struct drm_connector *connector,
171 } 187 }
172 188
173 max_link_clock = drm_dp_bw_code_to_link_rate(intel_dp_max_link_bw(intel_dp)); 189 max_link_clock = drm_dp_bw_code_to_link_rate(intel_dp_max_link_bw(intel_dp));
174 max_lanes = drm_dp_max_lane_count(intel_dp->dpcd); 190 max_lanes = intel_dp_max_lane_count(intel_dp);
175 191
176 max_rate = intel_dp_max_data_rate(max_link_clock, max_lanes); 192 max_rate = intel_dp_max_data_rate(max_link_clock, max_lanes);
177 mode_rate = intel_dp_link_required(target_clock, 18); 193 mode_rate = intel_dp_link_required(target_clock, 18);
@@ -751,8 +767,10 @@ intel_dp_compute_config(struct intel_encoder *encoder,
751 struct intel_crtc *intel_crtc = encoder->new_crtc; 767 struct intel_crtc *intel_crtc = encoder->new_crtc;
752 struct intel_connector *intel_connector = intel_dp->attached_connector; 768 struct intel_connector *intel_connector = intel_dp->attached_connector;
753 int lane_count, clock; 769 int lane_count, clock;
754 int max_lane_count = drm_dp_max_lane_count(intel_dp->dpcd); 770 int min_lane_count = 1;
771 int max_lane_count = intel_dp_max_lane_count(intel_dp);
755 /* Conveniently, the link BW constants become indices with a shift...*/ 772 /* Conveniently, the link BW constants become indices with a shift...*/
773 int min_clock = 0;
756 int max_clock = intel_dp_max_link_bw(intel_dp) >> 3; 774 int max_clock = intel_dp_max_link_bw(intel_dp) >> 3;
757 int bpp, mode_rate; 775 int bpp, mode_rate;
758 static int bws[] = { DP_LINK_BW_1_62, DP_LINK_BW_2_7, DP_LINK_BW_5_4 }; 776 static int bws[] = { DP_LINK_BW_1_62, DP_LINK_BW_2_7, DP_LINK_BW_5_4 };
@@ -785,19 +803,38 @@ intel_dp_compute_config(struct intel_encoder *encoder,
785 /* Walk through all bpp values. Luckily they're all nicely spaced with 2 803 /* Walk through all bpp values. Luckily they're all nicely spaced with 2
786 * bpc in between. */ 804 * bpc in between. */
787 bpp = pipe_config->pipe_bpp; 805 bpp = pipe_config->pipe_bpp;
788 if (is_edp(intel_dp) && dev_priv->vbt.edp_bpp && 806 if (is_edp(intel_dp)) {
789 dev_priv->vbt.edp_bpp < bpp) { 807 if (dev_priv->vbt.edp_bpp && dev_priv->vbt.edp_bpp < bpp) {
790 DRM_DEBUG_KMS("clamping bpp for eDP panel to BIOS-provided %i\n", 808 DRM_DEBUG_KMS("clamping bpp for eDP panel to BIOS-provided %i\n",
791 dev_priv->vbt.edp_bpp); 809 dev_priv->vbt.edp_bpp);
792 bpp = dev_priv->vbt.edp_bpp; 810 bpp = dev_priv->vbt.edp_bpp;
811 }
812
813 if (IS_BROADWELL(dev)) {
814 /* Yes, it's an ugly hack. */
815 min_lane_count = max_lane_count;
816 DRM_DEBUG_KMS("forcing lane count to max (%u) on BDW\n",
817 min_lane_count);
818 } else if (dev_priv->vbt.edp_lanes) {
819 min_lane_count = min(dev_priv->vbt.edp_lanes,
820 max_lane_count);
821 DRM_DEBUG_KMS("using min %u lanes per VBT\n",
822 min_lane_count);
823 }
824
825 if (dev_priv->vbt.edp_rate) {
826 min_clock = min(dev_priv->vbt.edp_rate >> 3, max_clock);
827 DRM_DEBUG_KMS("using min %02x link bw per VBT\n",
828 bws[min_clock]);
829 }
793 } 830 }
794 831
795 for (; bpp >= 6*3; bpp -= 2*3) { 832 for (; bpp >= 6*3; bpp -= 2*3) {
796 mode_rate = intel_dp_link_required(adjusted_mode->crtc_clock, 833 mode_rate = intel_dp_link_required(adjusted_mode->crtc_clock,
797 bpp); 834 bpp);
798 835
799 for (lane_count = 1; lane_count <= max_lane_count; lane_count <<= 1) { 836 for (lane_count = min_lane_count; lane_count <= max_lane_count; lane_count <<= 1) {
800 for (clock = 0; clock <= max_clock; clock++) { 837 for (clock = min_clock; clock <= max_clock; clock++) {
801 link_clock = drm_dp_bw_code_to_link_rate(bws[clock]); 838 link_clock = drm_dp_bw_code_to_link_rate(bws[clock]);
802 link_avail = intel_dp_max_data_rate(link_clock, 839 link_avail = intel_dp_max_data_rate(link_clock,
803 lane_count); 840 lane_count);
diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
index fce4a0d93c0b..f73ba5e6b7a8 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -387,6 +387,15 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
387 height); 387 height);
388 } 388 }
389 389
390 /* No preferred mode marked by the EDID? Are there any modes? */
391 if (!modes[i] && !list_empty(&connector->modes)) {
392 DRM_DEBUG_KMS("using first mode listed on connector %s\n",
393 drm_get_connector_name(connector));
394 modes[i] = list_first_entry(&connector->modes,
395 struct drm_display_mode,
396 head);
397 }
398
390 /* last resort: use current mode */ 399 /* last resort: use current mode */
391 if (!modes[i]) { 400 if (!modes[i]) {
392 /* 401 /*
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index 0eead16aeda7..cb8cfb7e0974 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -492,6 +492,7 @@ void intel_panel_set_backlight(struct intel_connector *connector, u32 level,
492 enum pipe pipe = intel_get_pipe_from_connector(connector); 492 enum pipe pipe = intel_get_pipe_from_connector(connector);
493 u32 freq; 493 u32 freq;
494 unsigned long flags; 494 unsigned long flags;
495 u64 n;
495 496
496 if (!panel->backlight.present || pipe == INVALID_PIPE) 497 if (!panel->backlight.present || pipe == INVALID_PIPE)
497 return; 498 return;
@@ -502,10 +503,9 @@ void intel_panel_set_backlight(struct intel_connector *connector, u32 level,
502 503
503 /* scale to hardware max, but be careful to not overflow */ 504 /* scale to hardware max, but be careful to not overflow */
504 freq = panel->backlight.max; 505 freq = panel->backlight.max;
505 if (freq < max) 506 n = (u64)level * freq;
506 level = level * freq / max; 507 do_div(n, max);
507 else 508 level = n;
508 level = freq / max * level;
509 509
510 panel->backlight.level = level; 510 panel->backlight.level = level;
511 if (panel->backlight.device) 511 if (panel->backlight.device)
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index 19e94c3edc19..d93dcf683e8c 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -2095,6 +2095,43 @@ static void intel_print_wm_latency(struct drm_device *dev,
2095 } 2095 }
2096} 2096}
2097 2097
2098static bool ilk_increase_wm_latency(struct drm_i915_private *dev_priv,
2099 uint16_t wm[5], uint16_t min)
2100{
2101 int level, max_level = ilk_wm_max_level(dev_priv->dev);
2102
2103 if (wm[0] >= min)
2104 return false;
2105
2106 wm[0] = max(wm[0], min);
2107 for (level = 1; level <= max_level; level++)
2108 wm[level] = max_t(uint16_t, wm[level], DIV_ROUND_UP(min, 5));
2109
2110 return true;
2111}
2112
2113static void snb_wm_latency_quirk(struct drm_device *dev)
2114{
2115 struct drm_i915_private *dev_priv = dev->dev_private;
2116 bool changed;
2117
2118 /*
2119 * The BIOS provided WM memory latency values are often
2120 * inadequate for high resolution displays. Adjust them.
2121 */
2122 changed = ilk_increase_wm_latency(dev_priv, dev_priv->wm.pri_latency, 12) |
2123 ilk_increase_wm_latency(dev_priv, dev_priv->wm.spr_latency, 12) |
2124 ilk_increase_wm_latency(dev_priv, dev_priv->wm.cur_latency, 12);
2125
2126 if (!changed)
2127 return;
2128
2129 DRM_DEBUG_KMS("WM latency values increased to avoid potential underruns\n");
2130 intel_print_wm_latency(dev, "Primary", dev_priv->wm.pri_latency);
2131 intel_print_wm_latency(dev, "Sprite", dev_priv->wm.spr_latency);
2132 intel_print_wm_latency(dev, "Cursor", dev_priv->wm.cur_latency);
2133}
2134
2098static void ilk_setup_wm_latency(struct drm_device *dev) 2135static void ilk_setup_wm_latency(struct drm_device *dev)
2099{ 2136{
2100 struct drm_i915_private *dev_priv = dev->dev_private; 2137 struct drm_i915_private *dev_priv = dev->dev_private;
@@ -2112,6 +2149,9 @@ static void ilk_setup_wm_latency(struct drm_device *dev)
2112 intel_print_wm_latency(dev, "Primary", dev_priv->wm.pri_latency); 2149 intel_print_wm_latency(dev, "Primary", dev_priv->wm.pri_latency);
2113 intel_print_wm_latency(dev, "Sprite", dev_priv->wm.spr_latency); 2150 intel_print_wm_latency(dev, "Sprite", dev_priv->wm.spr_latency);
2114 intel_print_wm_latency(dev, "Cursor", dev_priv->wm.cur_latency); 2151 intel_print_wm_latency(dev, "Cursor", dev_priv->wm.cur_latency);
2152
2153 if (IS_GEN6(dev))
2154 snb_wm_latency_quirk(dev);
2115} 2155}
2116 2156
2117static void ilk_compute_wm_parameters(struct drm_crtc *crtc, 2157static void ilk_compute_wm_parameters(struct drm_crtc *crtc,
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index d27155adf5db..46be00d66df3 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -2424,8 +2424,8 @@ intel_sdvo_connector_init(struct intel_sdvo_connector *connector,
2424 if (ret < 0) 2424 if (ret < 0)
2425 goto err1; 2425 goto err1;
2426 2426
2427 ret = sysfs_create_link(&encoder->ddc.dev.kobj, 2427 ret = sysfs_create_link(&drm_connector->kdev->kobj,
2428 &drm_connector->kdev->kobj, 2428 &encoder->ddc.dev.kobj,
2429 encoder->ddc.dev.kobj.name); 2429 encoder->ddc.dev.kobj.name);
2430 if (ret < 0) 2430 if (ret < 0)
2431 goto err2; 2431 goto err2;
diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
index f729dc71d5be..d0c75779d3f6 100644
--- a/drivers/gpu/drm/i915/intel_uncore.c
+++ b/drivers/gpu/drm/i915/intel_uncore.c
@@ -185,6 +185,8 @@ static void vlv_force_wake_reset(struct drm_i915_private *dev_priv)
185{ 185{
186 __raw_i915_write32(dev_priv, FORCEWAKE_VLV, 186 __raw_i915_write32(dev_priv, FORCEWAKE_VLV,
187 _MASKED_BIT_DISABLE(0xffff)); 187 _MASKED_BIT_DISABLE(0xffff));
188 __raw_i915_write32(dev_priv, FORCEWAKE_MEDIA_VLV,
189 _MASKED_BIT_DISABLE(0xffff));
188 /* something from same cacheline, but !FORCEWAKE_VLV */ 190 /* something from same cacheline, but !FORCEWAKE_VLV */
189 __raw_posting_read(dev_priv, FORCEWAKE_ACK_VLV); 191 __raw_posting_read(dev_priv, FORCEWAKE_ACK_VLV);
190} 192}
diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c
index 22e92c3d3d07..3c20e4bd6dd1 100644
--- a/drivers/i2c/busses/i2c-designware-core.c
+++ b/drivers/i2c/busses/i2c-designware-core.c
@@ -422,6 +422,9 @@ static void i2c_dw_xfer_init(struct dw_i2c_dev *dev)
422 */ 422 */
423 dw_writel(dev, msgs[dev->msg_write_idx].addr | ic_tar, DW_IC_TAR); 423 dw_writel(dev, msgs[dev->msg_write_idx].addr | ic_tar, DW_IC_TAR);
424 424
425 /* enforce disabled interrupts (due to HW issues) */
426 i2c_dw_disable_int(dev);
427
425 /* Enable the adapter */ 428 /* Enable the adapter */
426 __i2c_dw_enable(dev, true); 429 __i2c_dw_enable(dev, true);
427 430
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index 28cbe1b2a2ec..32c85e9ecdae 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -999,7 +999,7 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
999 999
1000 dev->virtbase = devm_ioremap(&adev->dev, adev->res.start, 1000 dev->virtbase = devm_ioremap(&adev->dev, adev->res.start,
1001 resource_size(&adev->res)); 1001 resource_size(&adev->res));
1002 if (IS_ERR(dev->virtbase)) { 1002 if (!dev->virtbase) {
1003 ret = -ENOMEM; 1003 ret = -ENOMEM;
1004 goto err_no_mem; 1004 goto err_no_mem;
1005 } 1005 }
diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c
index 1b4cf14f1106..2a5efb5b487c 100644
--- a/drivers/i2c/busses/i2c-qup.c
+++ b/drivers/i2c/busses/i2c-qup.c
@@ -479,7 +479,7 @@ static int qup_i2c_xfer(struct i2c_adapter *adap,
479 int ret, idx; 479 int ret, idx;
480 480
481 ret = pm_runtime_get_sync(qup->dev); 481 ret = pm_runtime_get_sync(qup->dev);
482 if (ret) 482 if (ret < 0)
483 goto out; 483 goto out;
484 484
485 writel(1, qup->base + QUP_SW_RESET); 485 writel(1, qup->base + QUP_SW_RESET);
diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index d4fa8eba6e9d..06d47aafbb79 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -561,6 +561,12 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
561 561
562 ret = -EINVAL; 562 ret = -EINVAL;
563 for (i = 0; i < num; i++) { 563 for (i = 0; i < num; i++) {
564 /* This HW can't send STOP after address phase */
565 if (msgs[i].len == 0) {
566 ret = -EOPNOTSUPP;
567 break;
568 }
569
564 /*-------------- spin lock -----------------*/ 570 /*-------------- spin lock -----------------*/
565 spin_lock_irqsave(&priv->lock, flags); 571 spin_lock_irqsave(&priv->lock, flags);
566 572
@@ -625,7 +631,8 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
625 631
626static u32 rcar_i2c_func(struct i2c_adapter *adap) 632static u32 rcar_i2c_func(struct i2c_adapter *adap)
627{ 633{
628 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; 634 /* This HW can't do SMBUS_QUICK and NOSTART */
635 return I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK);
629} 636}
630 637
631static const struct i2c_algorithm rcar_i2c_algo = { 638static const struct i2c_algorithm rcar_i2c_algo = {
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index ae4491062e41..bb3a9964f7e0 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -1276,10 +1276,10 @@ static int s3c24xx_i2c_resume(struct device *dev)
1276 struct platform_device *pdev = to_platform_device(dev); 1276 struct platform_device *pdev = to_platform_device(dev);
1277 struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev); 1277 struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);
1278 1278
1279 i2c->suspended = 0;
1280 clk_prepare_enable(i2c->clk); 1279 clk_prepare_enable(i2c->clk);
1281 s3c24xx_i2c_init(i2c); 1280 s3c24xx_i2c_init(i2c);
1282 clk_disable_unprepare(i2c->clk); 1281 clk_disable_unprepare(i2c->clk);
1282 i2c->suspended = 0;
1283 1283
1284 return 0; 1284 return 0;
1285} 1285}
diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
index c98fdb185931..a1710465faaf 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.c
+++ b/drivers/infiniband/ulp/isert/ib_isert.c
@@ -28,6 +28,7 @@
28#include <target/target_core_base.h> 28#include <target/target_core_base.h>
29#include <target/target_core_fabric.h> 29#include <target/target_core_fabric.h>
30#include <target/iscsi/iscsi_transport.h> 30#include <target/iscsi/iscsi_transport.h>
31#include <linux/semaphore.h>
31 32
32#include "isert_proto.h" 33#include "isert_proto.h"
33#include "ib_isert.h" 34#include "ib_isert.h"
@@ -561,7 +562,15 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
561 struct isert_device *device; 562 struct isert_device *device;
562 struct ib_device *ib_dev = cma_id->device; 563 struct ib_device *ib_dev = cma_id->device;
563 int ret = 0; 564 int ret = 0;
564 u8 pi_support = np->tpg_np->tpg->tpg_attrib.t10_pi; 565 u8 pi_support;
566
567 spin_lock_bh(&np->np_thread_lock);
568 if (!np->enabled) {
569 spin_unlock_bh(&np->np_thread_lock);
570 pr_debug("iscsi_np is not enabled, reject connect request\n");
571 return rdma_reject(cma_id, NULL, 0);
572 }
573 spin_unlock_bh(&np->np_thread_lock);
565 574
566 pr_debug("Entering isert_connect_request cma_id: %p, context: %p\n", 575 pr_debug("Entering isert_connect_request cma_id: %p, context: %p\n",
567 cma_id, cma_id->context); 576 cma_id, cma_id->context);
@@ -652,6 +661,7 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
652 goto out_mr; 661 goto out_mr;
653 } 662 }
654 663
664 pi_support = np->tpg_np->tpg->tpg_attrib.t10_pi;
655 if (pi_support && !device->pi_capable) { 665 if (pi_support && !device->pi_capable) {
656 pr_err("Protection information requested but not supported\n"); 666 pr_err("Protection information requested but not supported\n");
657 ret = -EINVAL; 667 ret = -EINVAL;
@@ -663,11 +673,11 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
663 goto out_conn_dev; 673 goto out_conn_dev;
664 674
665 mutex_lock(&isert_np->np_accept_mutex); 675 mutex_lock(&isert_np->np_accept_mutex);
666 list_add_tail(&isert_np->np_accept_list, &isert_conn->conn_accept_node); 676 list_add_tail(&isert_conn->conn_accept_node, &isert_np->np_accept_list);
667 mutex_unlock(&isert_np->np_accept_mutex); 677 mutex_unlock(&isert_np->np_accept_mutex);
668 678
669 pr_debug("isert_connect_request() waking up np_accept_wq: %p\n", np); 679 pr_debug("isert_connect_request() up np_sem np: %p\n", np);
670 wake_up(&isert_np->np_accept_wq); 680 up(&isert_np->np_sem);
671 return 0; 681 return 0;
672 682
673out_conn_dev: 683out_conn_dev:
@@ -2999,7 +3009,7 @@ isert_setup_np(struct iscsi_np *np,
2999 pr_err("Unable to allocate struct isert_np\n"); 3009 pr_err("Unable to allocate struct isert_np\n");
3000 return -ENOMEM; 3010 return -ENOMEM;
3001 } 3011 }
3002 init_waitqueue_head(&isert_np->np_accept_wq); 3012 sema_init(&isert_np->np_sem, 0);
3003 mutex_init(&isert_np->np_accept_mutex); 3013 mutex_init(&isert_np->np_accept_mutex);
3004 INIT_LIST_HEAD(&isert_np->np_accept_list); 3014 INIT_LIST_HEAD(&isert_np->np_accept_list);
3005 init_completion(&isert_np->np_login_comp); 3015 init_completion(&isert_np->np_login_comp);
@@ -3048,18 +3058,6 @@ out:
3048} 3058}
3049 3059
3050static int 3060static int
3051isert_check_accept_queue(struct isert_np *isert_np)
3052{
3053 int empty;
3054
3055 mutex_lock(&isert_np->np_accept_mutex);
3056 empty = list_empty(&isert_np->np_accept_list);
3057 mutex_unlock(&isert_np->np_accept_mutex);
3058
3059 return empty;
3060}
3061
3062static int
3063isert_rdma_accept(struct isert_conn *isert_conn) 3061isert_rdma_accept(struct isert_conn *isert_conn)
3064{ 3062{
3065 struct rdma_cm_id *cm_id = isert_conn->conn_cm_id; 3063 struct rdma_cm_id *cm_id = isert_conn->conn_cm_id;
@@ -3151,16 +3149,14 @@ isert_accept_np(struct iscsi_np *np, struct iscsi_conn *conn)
3151 int max_accept = 0, ret; 3149 int max_accept = 0, ret;
3152 3150
3153accept_wait: 3151accept_wait:
3154 ret = wait_event_interruptible(isert_np->np_accept_wq, 3152 ret = down_interruptible(&isert_np->np_sem);
3155 !isert_check_accept_queue(isert_np) ||
3156 np->np_thread_state == ISCSI_NP_THREAD_RESET);
3157 if (max_accept > 5) 3153 if (max_accept > 5)
3158 return -ENODEV; 3154 return -ENODEV;
3159 3155
3160 spin_lock_bh(&np->np_thread_lock); 3156 spin_lock_bh(&np->np_thread_lock);
3161 if (np->np_thread_state == ISCSI_NP_THREAD_RESET) { 3157 if (np->np_thread_state == ISCSI_NP_THREAD_RESET) {
3162 spin_unlock_bh(&np->np_thread_lock); 3158 spin_unlock_bh(&np->np_thread_lock);
3163 pr_err("ISCSI_NP_THREAD_RESET for isert_accept_np\n"); 3159 pr_debug("ISCSI_NP_THREAD_RESET for isert_accept_np\n");
3164 return -ENODEV; 3160 return -ENODEV;
3165 } 3161 }
3166 spin_unlock_bh(&np->np_thread_lock); 3162 spin_unlock_bh(&np->np_thread_lock);
diff --git a/drivers/infiniband/ulp/isert/ib_isert.h b/drivers/infiniband/ulp/isert/ib_isert.h
index 4c072ae34c01..da6612e68000 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.h
+++ b/drivers/infiniband/ulp/isert/ib_isert.h
@@ -182,7 +182,7 @@ struct isert_device {
182}; 182};
183 183
184struct isert_np { 184struct isert_np {
185 wait_queue_head_t np_accept_wq; 185 struct semaphore np_sem;
186 struct rdma_cm_id *np_cm_id; 186 struct rdma_cm_id *np_cm_id;
187 struct mutex np_accept_mutex; 187 struct mutex np_accept_mutex;
188 struct list_head np_accept_list; 188 struct list_head np_accept_list;
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index c949520bd196..57068e8035b5 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -3999,7 +3999,7 @@ static struct irq_remap_table *get_irq_table(u16 devid, bool ioapic)
3999 iommu_flush_dte(iommu, devid); 3999 iommu_flush_dte(iommu, devid);
4000 if (devid != alias) { 4000 if (devid != alias) {
4001 irq_lookup_table[alias] = table; 4001 irq_lookup_table[alias] = table;
4002 set_dte_irq_entry(devid, table); 4002 set_dte_irq_entry(alias, table);
4003 iommu_flush_dte(iommu, alias); 4003 iommu_flush_dte(iommu, alias);
4004 } 4004 }
4005 4005
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index b76c58dbe30c..0e08545d7298 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -788,7 +788,7 @@ static void __init set_device_exclusion_range(u16 devid, struct ivmd_header *m)
788 * per device. But we can enable the exclusion range per 788 * per device. But we can enable the exclusion range per
789 * device. This is done here 789 * device. This is done here
790 */ 790 */
791 set_dev_entry_bit(m->devid, DEV_ENTRY_EX); 791 set_dev_entry_bit(devid, DEV_ENTRY_EX);
792 iommu->exclusion_start = m->range_start; 792 iommu->exclusion_start = m->range_start;
793 iommu->exclusion_length = m->range_length; 793 iommu->exclusion_length = m->range_length;
794 } 794 }
diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c
index 5208828792e6..203b2e6a91cf 100644
--- a/drivers/iommu/amd_iommu_v2.c
+++ b/drivers/iommu/amd_iommu_v2.c
@@ -504,8 +504,10 @@ static void do_fault(struct work_struct *work)
504 504
505 write = !!(fault->flags & PPR_FAULT_WRITE); 505 write = !!(fault->flags & PPR_FAULT_WRITE);
506 506
507 down_read(&fault->state->mm->mmap_sem);
507 npages = get_user_pages(fault->state->task, fault->state->mm, 508 npages = get_user_pages(fault->state->task, fault->state->mm,
508 fault->address, 1, write, 0, &page, NULL); 509 fault->address, 1, write, 0, &page, NULL);
510 up_read(&fault->state->mm->mmap_sem);
509 511
510 if (npages == 1) { 512 if (npages == 1) {
511 put_page(page); 513 put_page(page);
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 784695d22fde..53b213226c01 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -19,7 +19,6 @@
19#include <linux/crypto.h> 19#include <linux/crypto.h>
20#include <linux/workqueue.h> 20#include <linux/workqueue.h>
21#include <linux/backing-dev.h> 21#include <linux/backing-dev.h>
22#include <linux/percpu.h>
23#include <linux/atomic.h> 22#include <linux/atomic.h>
24#include <linux/scatterlist.h> 23#include <linux/scatterlist.h>
25#include <asm/page.h> 24#include <asm/page.h>
@@ -43,6 +42,7 @@ struct convert_context {
43 struct bvec_iter iter_out; 42 struct bvec_iter iter_out;
44 sector_t cc_sector; 43 sector_t cc_sector;
45 atomic_t cc_pending; 44 atomic_t cc_pending;
45 struct ablkcipher_request *req;
46}; 46};
47 47
48/* 48/*
@@ -111,15 +111,7 @@ struct iv_tcw_private {
111enum flags { DM_CRYPT_SUSPENDED, DM_CRYPT_KEY_VALID }; 111enum flags { DM_CRYPT_SUSPENDED, DM_CRYPT_KEY_VALID };
112 112
113/* 113/*
114 * Duplicated per-CPU state for cipher. 114 * The fields in here must be read only after initialization.
115 */
116struct crypt_cpu {
117 struct ablkcipher_request *req;
118};
119
120/*
121 * The fields in here must be read only after initialization,
122 * changing state should be in crypt_cpu.
123 */ 115 */
124struct crypt_config { 116struct crypt_config {
125 struct dm_dev *dev; 117 struct dm_dev *dev;
@@ -150,12 +142,6 @@ struct crypt_config {
150 sector_t iv_offset; 142 sector_t iv_offset;
151 unsigned int iv_size; 143 unsigned int iv_size;
152 144
153 /*
154 * Duplicated per cpu state. Access through
155 * per_cpu_ptr() only.
156 */
157 struct crypt_cpu __percpu *cpu;
158
159 /* ESSIV: struct crypto_cipher *essiv_tfm */ 145 /* ESSIV: struct crypto_cipher *essiv_tfm */
160 void *iv_private; 146 void *iv_private;
161 struct crypto_ablkcipher **tfms; 147 struct crypto_ablkcipher **tfms;
@@ -192,11 +178,6 @@ static void clone_init(struct dm_crypt_io *, struct bio *);
192static void kcryptd_queue_crypt(struct dm_crypt_io *io); 178static void kcryptd_queue_crypt(struct dm_crypt_io *io);
193static u8 *iv_of_dmreq(struct crypt_config *cc, struct dm_crypt_request *dmreq); 179static u8 *iv_of_dmreq(struct crypt_config *cc, struct dm_crypt_request *dmreq);
194 180
195static struct crypt_cpu *this_crypt_config(struct crypt_config *cc)
196{
197 return this_cpu_ptr(cc->cpu);
198}
199
200/* 181/*
201 * Use this to access cipher attributes that are the same for each CPU. 182 * Use this to access cipher attributes that are the same for each CPU.
202 */ 183 */
@@ -903,16 +884,15 @@ static void kcryptd_async_done(struct crypto_async_request *async_req,
903static void crypt_alloc_req(struct crypt_config *cc, 884static void crypt_alloc_req(struct crypt_config *cc,
904 struct convert_context *ctx) 885 struct convert_context *ctx)
905{ 886{
906 struct crypt_cpu *this_cc = this_crypt_config(cc);
907 unsigned key_index = ctx->cc_sector & (cc->tfms_count - 1); 887 unsigned key_index = ctx->cc_sector & (cc->tfms_count - 1);
908 888
909 if (!this_cc->req) 889 if (!ctx->req)
910 this_cc->req = mempool_alloc(cc->req_pool, GFP_NOIO); 890 ctx->req = mempool_alloc(cc->req_pool, GFP_NOIO);
911 891
912 ablkcipher_request_set_tfm(this_cc->req, cc->tfms[key_index]); 892 ablkcipher_request_set_tfm(ctx->req, cc->tfms[key_index]);
913 ablkcipher_request_set_callback(this_cc->req, 893 ablkcipher_request_set_callback(ctx->req,
914 CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, 894 CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP,
915 kcryptd_async_done, dmreq_of_req(cc, this_cc->req)); 895 kcryptd_async_done, dmreq_of_req(cc, ctx->req));
916} 896}
917 897
918/* 898/*
@@ -921,7 +901,6 @@ static void crypt_alloc_req(struct crypt_config *cc,
921static int crypt_convert(struct crypt_config *cc, 901static int crypt_convert(struct crypt_config *cc,
922 struct convert_context *ctx) 902 struct convert_context *ctx)
923{ 903{
924 struct crypt_cpu *this_cc = this_crypt_config(cc);
925 int r; 904 int r;
926 905
927 atomic_set(&ctx->cc_pending, 1); 906 atomic_set(&ctx->cc_pending, 1);
@@ -932,7 +911,7 @@ static int crypt_convert(struct crypt_config *cc,
932 911
933 atomic_inc(&ctx->cc_pending); 912 atomic_inc(&ctx->cc_pending);
934 913
935 r = crypt_convert_block(cc, ctx, this_cc->req); 914 r = crypt_convert_block(cc, ctx, ctx->req);
936 915
937 switch (r) { 916 switch (r) {
938 /* async */ 917 /* async */
@@ -941,7 +920,7 @@ static int crypt_convert(struct crypt_config *cc,
941 reinit_completion(&ctx->restart); 920 reinit_completion(&ctx->restart);
942 /* fall through*/ 921 /* fall through*/
943 case -EINPROGRESS: 922 case -EINPROGRESS:
944 this_cc->req = NULL; 923 ctx->req = NULL;
945 ctx->cc_sector++; 924 ctx->cc_sector++;
946 continue; 925 continue;
947 926
@@ -1040,6 +1019,7 @@ static struct dm_crypt_io *crypt_io_alloc(struct crypt_config *cc,
1040 io->sector = sector; 1019 io->sector = sector;
1041 io->error = 0; 1020 io->error = 0;
1042 io->base_io = NULL; 1021 io->base_io = NULL;
1022 io->ctx.req = NULL;
1043 atomic_set(&io->io_pending, 0); 1023 atomic_set(&io->io_pending, 0);
1044 1024
1045 return io; 1025 return io;
@@ -1065,6 +1045,8 @@ static void crypt_dec_pending(struct dm_crypt_io *io)
1065 if (!atomic_dec_and_test(&io->io_pending)) 1045 if (!atomic_dec_and_test(&io->io_pending))
1066 return; 1046 return;
1067 1047
1048 if (io->ctx.req)
1049 mempool_free(io->ctx.req, cc->req_pool);
1068 mempool_free(io, cc->io_pool); 1050 mempool_free(io, cc->io_pool);
1069 1051
1070 if (likely(!base_io)) 1052 if (likely(!base_io))
@@ -1492,8 +1474,6 @@ static int crypt_wipe_key(struct crypt_config *cc)
1492static void crypt_dtr(struct dm_target *ti) 1474static void crypt_dtr(struct dm_target *ti)
1493{ 1475{
1494 struct crypt_config *cc = ti->private; 1476 struct crypt_config *cc = ti->private;
1495 struct crypt_cpu *cpu_cc;
1496 int cpu;
1497 1477
1498 ti->private = NULL; 1478 ti->private = NULL;
1499 1479
@@ -1505,13 +1485,6 @@ static void crypt_dtr(struct dm_target *ti)
1505 if (cc->crypt_queue) 1485 if (cc->crypt_queue)
1506 destroy_workqueue(cc->crypt_queue); 1486 destroy_workqueue(cc->crypt_queue);
1507 1487
1508 if (cc->cpu)
1509 for_each_possible_cpu(cpu) {
1510 cpu_cc = per_cpu_ptr(cc->cpu, cpu);
1511 if (cpu_cc->req)
1512 mempool_free(cpu_cc->req, cc->req_pool);
1513 }
1514
1515 crypt_free_tfms(cc); 1488 crypt_free_tfms(cc);
1516 1489
1517 if (cc->bs) 1490 if (cc->bs)
@@ -1530,9 +1503,6 @@ static void crypt_dtr(struct dm_target *ti)
1530 if (cc->dev) 1503 if (cc->dev)
1531 dm_put_device(ti, cc->dev); 1504 dm_put_device(ti, cc->dev);
1532 1505
1533 if (cc->cpu)
1534 free_percpu(cc->cpu);
1535
1536 kzfree(cc->cipher); 1506 kzfree(cc->cipher);
1537 kzfree(cc->cipher_string); 1507 kzfree(cc->cipher_string);
1538 1508
@@ -1588,13 +1558,6 @@ static int crypt_ctr_cipher(struct dm_target *ti,
1588 if (tmp) 1558 if (tmp)
1589 DMWARN("Ignoring unexpected additional cipher options"); 1559 DMWARN("Ignoring unexpected additional cipher options");
1590 1560
1591 cc->cpu = __alloc_percpu(sizeof(*(cc->cpu)),
1592 __alignof__(struct crypt_cpu));
1593 if (!cc->cpu) {
1594 ti->error = "Cannot allocate per cpu state";
1595 goto bad_mem;
1596 }
1597
1598 /* 1561 /*
1599 * For compatibility with the original dm-crypt mapping format, if 1562 * For compatibility with the original dm-crypt mapping format, if
1600 * only the cipher name is supplied, use cbc-plain. 1563 * only the cipher name is supplied, use cbc-plain.
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index aa009e865871..fa0f6cbd6a41 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -1566,8 +1566,8 @@ static int multipath_ioctl(struct dm_target *ti, unsigned int cmd,
1566 } 1566 }
1567 if (m->pg_init_required) 1567 if (m->pg_init_required)
1568 __pg_init_all_paths(m); 1568 __pg_init_all_paths(m);
1569 spin_unlock_irqrestore(&m->lock, flags);
1570 dm_table_run_md_queue_async(m->ti->table); 1569 dm_table_run_md_queue_async(m->ti->table);
1570 spin_unlock_irqrestore(&m->lock, flags);
1571 } 1571 }
1572 1572
1573 return r ? : __blkdev_driver_ioctl(bdev, mode, cmd, arg); 1573 return r ? : __blkdev_driver_ioctl(bdev, mode, cmd, arg);
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index 13abade76ad9..2e71de8e0048 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -27,6 +27,7 @@
27#define MAPPING_POOL_SIZE 1024 27#define MAPPING_POOL_SIZE 1024
28#define PRISON_CELLS 1024 28#define PRISON_CELLS 1024
29#define COMMIT_PERIOD HZ 29#define COMMIT_PERIOD HZ
30#define NO_SPACE_TIMEOUT (HZ * 60)
30 31
31DECLARE_DM_KCOPYD_THROTTLE_WITH_MODULE_PARM(snapshot_copy_throttle, 32DECLARE_DM_KCOPYD_THROTTLE_WITH_MODULE_PARM(snapshot_copy_throttle,
32 "A percentage of time allocated for copy on write"); 33 "A percentage of time allocated for copy on write");
@@ -175,6 +176,7 @@ struct pool {
175 struct workqueue_struct *wq; 176 struct workqueue_struct *wq;
176 struct work_struct worker; 177 struct work_struct worker;
177 struct delayed_work waker; 178 struct delayed_work waker;
179 struct delayed_work no_space_timeout;
178 180
179 unsigned long last_commit_jiffies; 181 unsigned long last_commit_jiffies;
180 unsigned ref_count; 182 unsigned ref_count;
@@ -935,7 +937,7 @@ static int commit(struct pool *pool)
935{ 937{
936 int r; 938 int r;
937 939
938 if (get_pool_mode(pool) != PM_WRITE) 940 if (get_pool_mode(pool) >= PM_READ_ONLY)
939 return -EINVAL; 941 return -EINVAL;
940 942
941 r = dm_pool_commit_metadata(pool->pmd); 943 r = dm_pool_commit_metadata(pool->pmd);
@@ -1590,6 +1592,20 @@ static void do_waker(struct work_struct *ws)
1590 queue_delayed_work(pool->wq, &pool->waker, COMMIT_PERIOD); 1592 queue_delayed_work(pool->wq, &pool->waker, COMMIT_PERIOD);
1591} 1593}
1592 1594
1595/*
1596 * We're holding onto IO to allow userland time to react. After the
1597 * timeout either the pool will have been resized (and thus back in
1598 * PM_WRITE mode), or we degrade to PM_READ_ONLY and start erroring IO.
1599 */
1600static void do_no_space_timeout(struct work_struct *ws)
1601{
1602 struct pool *pool = container_of(to_delayed_work(ws), struct pool,
1603 no_space_timeout);
1604
1605 if (get_pool_mode(pool) == PM_OUT_OF_DATA_SPACE && !pool->pf.error_if_no_space)
1606 set_pool_mode(pool, PM_READ_ONLY);
1607}
1608
1593/*----------------------------------------------------------------*/ 1609/*----------------------------------------------------------------*/
1594 1610
1595struct noflush_work { 1611struct noflush_work {
@@ -1715,6 +1731,9 @@ static void set_pool_mode(struct pool *pool, enum pool_mode new_mode)
1715 pool->process_discard = process_discard; 1731 pool->process_discard = process_discard;
1716 pool->process_prepared_mapping = process_prepared_mapping; 1732 pool->process_prepared_mapping = process_prepared_mapping;
1717 pool->process_prepared_discard = process_prepared_discard_passdown; 1733 pool->process_prepared_discard = process_prepared_discard_passdown;
1734
1735 if (!pool->pf.error_if_no_space)
1736 queue_delayed_work(pool->wq, &pool->no_space_timeout, NO_SPACE_TIMEOUT);
1718 break; 1737 break;
1719 1738
1720 case PM_WRITE: 1739 case PM_WRITE:
@@ -2100,6 +2119,7 @@ static struct pool *pool_create(struct mapped_device *pool_md,
2100 2119
2101 INIT_WORK(&pool->worker, do_worker); 2120 INIT_WORK(&pool->worker, do_worker);
2102 INIT_DELAYED_WORK(&pool->waker, do_waker); 2121 INIT_DELAYED_WORK(&pool->waker, do_waker);
2122 INIT_DELAYED_WORK(&pool->no_space_timeout, do_no_space_timeout);
2103 spin_lock_init(&pool->lock); 2123 spin_lock_init(&pool->lock);
2104 bio_list_init(&pool->deferred_flush_bios); 2124 bio_list_init(&pool->deferred_flush_bios);
2105 INIT_LIST_HEAD(&pool->prepared_mappings); 2125 INIT_LIST_HEAD(&pool->prepared_mappings);
@@ -2662,6 +2682,7 @@ static void pool_postsuspend(struct dm_target *ti)
2662 struct pool *pool = pt->pool; 2682 struct pool *pool = pt->pool;
2663 2683
2664 cancel_delayed_work(&pool->waker); 2684 cancel_delayed_work(&pool->waker);
2685 cancel_delayed_work(&pool->no_space_timeout);
2665 flush_workqueue(pool->wq); 2686 flush_workqueue(pool->wq);
2666 (void) commit(pool); 2687 (void) commit(pool);
2667} 2688}
diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
index e8a1ce204036..cdd7c1b7259b 100644
--- a/drivers/media/i2c/ov7670.c
+++ b/drivers/media/i2c/ov7670.c
@@ -1109,7 +1109,7 @@ static int ov7670_enum_framesizes(struct v4l2_subdev *sd,
1109 * windows that fall outside that. 1109 * windows that fall outside that.
1110 */ 1110 */
1111 for (i = 0; i < n_win_sizes; i++) { 1111 for (i = 0; i < n_win_sizes; i++) {
1112 struct ov7670_win_size *win = &info->devtype->win_sizes[index]; 1112 struct ov7670_win_size *win = &info->devtype->win_sizes[i];
1113 if (info->min_width && win->width < info->min_width) 1113 if (info->min_width && win->width < info->min_width)
1114 continue; 1114 continue;
1115 if (info->min_height && win->height < info->min_height) 1115 if (info->min_height && win->height < info->min_height)
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
index a4459301b5f8..ee0f57e01b56 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
@@ -1616,7 +1616,7 @@ static int s5c73m3_get_platform_data(struct s5c73m3 *state)
1616 if (ret < 0) 1616 if (ret < 0)
1617 return -EINVAL; 1617 return -EINVAL;
1618 1618
1619 node_ep = v4l2_of_get_next_endpoint(node, NULL); 1619 node_ep = of_graph_get_next_endpoint(node, NULL);
1620 if (!node_ep) { 1620 if (!node_ep) {
1621 dev_warn(dev, "no endpoint defined for node: %s\n", 1621 dev_warn(dev, "no endpoint defined for node: %s\n",
1622 node->full_name); 1622 node->full_name);
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index d5a7a135f75d..703560fa5e73 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -93,6 +93,7 @@ static long media_device_enum_entities(struct media_device *mdev,
93 struct media_entity *ent; 93 struct media_entity *ent;
94 struct media_entity_desc u_ent; 94 struct media_entity_desc u_ent;
95 95
96 memset(&u_ent, 0, sizeof(u_ent));
96 if (copy_from_user(&u_ent.id, &uent->id, sizeof(u_ent.id))) 97 if (copy_from_user(&u_ent.id, &uent->id, sizeof(u_ent.id)))
97 return -EFAULT; 98 return -EFAULT;
98 99
diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c
index b4f12d00be05..656708252962 100644
--- a/drivers/media/platform/davinci/vpbe_display.c
+++ b/drivers/media/platform/davinci/vpbe_display.c
@@ -372,18 +372,32 @@ static int vpbe_stop_streaming(struct vb2_queue *vq)
372{ 372{
373 struct vpbe_fh *fh = vb2_get_drv_priv(vq); 373 struct vpbe_fh *fh = vb2_get_drv_priv(vq);
374 struct vpbe_layer *layer = fh->layer; 374 struct vpbe_layer *layer = fh->layer;
375 struct vpbe_display *disp = fh->disp_dev;
376 unsigned long flags;
375 377
376 if (!vb2_is_streaming(vq)) 378 if (!vb2_is_streaming(vq))
377 return 0; 379 return 0;
378 380
379 /* release all active buffers */ 381 /* release all active buffers */
382 spin_lock_irqsave(&disp->dma_queue_lock, flags);
383 if (layer->cur_frm == layer->next_frm) {
384 vb2_buffer_done(&layer->cur_frm->vb, VB2_BUF_STATE_ERROR);
385 } else {
386 if (layer->cur_frm != NULL)
387 vb2_buffer_done(&layer->cur_frm->vb,
388 VB2_BUF_STATE_ERROR);
389 if (layer->next_frm != NULL)
390 vb2_buffer_done(&layer->next_frm->vb,
391 VB2_BUF_STATE_ERROR);
392 }
393
380 while (!list_empty(&layer->dma_queue)) { 394 while (!list_empty(&layer->dma_queue)) {
381 layer->next_frm = list_entry(layer->dma_queue.next, 395 layer->next_frm = list_entry(layer->dma_queue.next,
382 struct vpbe_disp_buffer, list); 396 struct vpbe_disp_buffer, list);
383 list_del(&layer->next_frm->list); 397 list_del(&layer->next_frm->list);
384 vb2_buffer_done(&layer->next_frm->vb, VB2_BUF_STATE_ERROR); 398 vb2_buffer_done(&layer->next_frm->vb, VB2_BUF_STATE_ERROR);
385 } 399 }
386 400 spin_unlock_irqrestore(&disp->dma_queue_lock, flags);
387 return 0; 401 return 0;
388} 402}
389 403
diff --git a/drivers/media/platform/davinci/vpfe_capture.c b/drivers/media/platform/davinci/vpfe_capture.c
index d762246eabf5..0379cb9f9a9c 100644
--- a/drivers/media/platform/davinci/vpfe_capture.c
+++ b/drivers/media/platform/davinci/vpfe_capture.c
@@ -734,6 +734,8 @@ static int vpfe_release(struct file *file)
734 } 734 }
735 vpfe_dev->io_usrs = 0; 735 vpfe_dev->io_usrs = 0;
736 vpfe_dev->numbuffers = config_params.numbuffers; 736 vpfe_dev->numbuffers = config_params.numbuffers;
737 videobuf_stop(&vpfe_dev->buffer_queue);
738 videobuf_mmap_free(&vpfe_dev->buffer_queue);
737 } 739 }
738 740
739 /* Decrement device usrs counter */ 741 /* Decrement device usrs counter */
diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
index 756da78bac23..8dea0b84a3ad 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -358,8 +358,31 @@ static int vpif_stop_streaming(struct vb2_queue *vq)
358 358
359 common = &ch->common[VPIF_VIDEO_INDEX]; 359 common = &ch->common[VPIF_VIDEO_INDEX];
360 360
361 /* Disable channel as per its device type and channel id */
362 if (VPIF_CHANNEL0_VIDEO == ch->channel_id) {
363 enable_channel0(0);
364 channel0_intr_enable(0);
365 }
366 if ((VPIF_CHANNEL1_VIDEO == ch->channel_id) ||
367 (2 == common->started)) {
368 enable_channel1(0);
369 channel1_intr_enable(0);
370 }
371 common->started = 0;
372
361 /* release all active buffers */ 373 /* release all active buffers */
362 spin_lock_irqsave(&common->irqlock, flags); 374 spin_lock_irqsave(&common->irqlock, flags);
375 if (common->cur_frm == common->next_frm) {
376 vb2_buffer_done(&common->cur_frm->vb, VB2_BUF_STATE_ERROR);
377 } else {
378 if (common->cur_frm != NULL)
379 vb2_buffer_done(&common->cur_frm->vb,
380 VB2_BUF_STATE_ERROR);
381 if (common->next_frm != NULL)
382 vb2_buffer_done(&common->next_frm->vb,
383 VB2_BUF_STATE_ERROR);
384 }
385
363 while (!list_empty(&common->dma_queue)) { 386 while (!list_empty(&common->dma_queue)) {
364 common->next_frm = list_entry(common->dma_queue.next, 387 common->next_frm = list_entry(common->dma_queue.next,
365 struct vpif_cap_buffer, list); 388 struct vpif_cap_buffer, list);
@@ -933,17 +956,6 @@ static int vpif_release(struct file *filep)
933 if (fh->io_allowed[VPIF_VIDEO_INDEX]) { 956 if (fh->io_allowed[VPIF_VIDEO_INDEX]) {
934 /* Reset io_usrs member of channel object */ 957 /* Reset io_usrs member of channel object */
935 common->io_usrs = 0; 958 common->io_usrs = 0;
936 /* Disable channel as per its device type and channel id */
937 if (VPIF_CHANNEL0_VIDEO == ch->channel_id) {
938 enable_channel0(0);
939 channel0_intr_enable(0);
940 }
941 if ((VPIF_CHANNEL1_VIDEO == ch->channel_id) ||
942 (2 == common->started)) {
943 enable_channel1(0);
944 channel1_intr_enable(0);
945 }
946 common->started = 0;
947 /* Free buffers allocated */ 959 /* Free buffers allocated */
948 vb2_queue_release(&common->buffer_queue); 960 vb2_queue_release(&common->buffer_queue);
949 vb2_dma_contig_cleanup_ctx(common->alloc_ctx); 961 vb2_dma_contig_cleanup_ctx(common->alloc_ctx);
diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c
index 0ac841e35aa4..aed41edd0501 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -320,8 +320,31 @@ static int vpif_stop_streaming(struct vb2_queue *vq)
320 320
321 common = &ch->common[VPIF_VIDEO_INDEX]; 321 common = &ch->common[VPIF_VIDEO_INDEX];
322 322
323 /* Disable channel */
324 if (VPIF_CHANNEL2_VIDEO == ch->channel_id) {
325 enable_channel2(0);
326 channel2_intr_enable(0);
327 }
328 if ((VPIF_CHANNEL3_VIDEO == ch->channel_id) ||
329 (2 == common->started)) {
330 enable_channel3(0);
331 channel3_intr_enable(0);
332 }
333 common->started = 0;
334
323 /* release all active buffers */ 335 /* release all active buffers */
324 spin_lock_irqsave(&common->irqlock, flags); 336 spin_lock_irqsave(&common->irqlock, flags);
337 if (common->cur_frm == common->next_frm) {
338 vb2_buffer_done(&common->cur_frm->vb, VB2_BUF_STATE_ERROR);
339 } else {
340 if (common->cur_frm != NULL)
341 vb2_buffer_done(&common->cur_frm->vb,
342 VB2_BUF_STATE_ERROR);
343 if (common->next_frm != NULL)
344 vb2_buffer_done(&common->next_frm->vb,
345 VB2_BUF_STATE_ERROR);
346 }
347
325 while (!list_empty(&common->dma_queue)) { 348 while (!list_empty(&common->dma_queue)) {
326 common->next_frm = list_entry(common->dma_queue.next, 349 common->next_frm = list_entry(common->dma_queue.next,
327 struct vpif_disp_buffer, list); 350 struct vpif_disp_buffer, list);
@@ -773,18 +796,6 @@ static int vpif_release(struct file *filep)
773 if (fh->io_allowed[VPIF_VIDEO_INDEX]) { 796 if (fh->io_allowed[VPIF_VIDEO_INDEX]) {
774 /* Reset io_usrs member of channel object */ 797 /* Reset io_usrs member of channel object */
775 common->io_usrs = 0; 798 common->io_usrs = 0;
776 /* Disable channel */
777 if (VPIF_CHANNEL2_VIDEO == ch->channel_id) {
778 enable_channel2(0);
779 channel2_intr_enable(0);
780 }
781 if ((VPIF_CHANNEL3_VIDEO == ch->channel_id) ||
782 (2 == common->started)) {
783 enable_channel3(0);
784 channel3_intr_enable(0);
785 }
786 common->started = 0;
787
788 /* Free buffers allocated */ 799 /* Free buffers allocated */
789 vb2_queue_release(&common->buffer_queue); 800 vb2_queue_release(&common->buffer_queue);
790 vb2_dma_contig_cleanup_ctx(common->alloc_ctx); 801 vb2_dma_contig_cleanup_ctx(common->alloc_ctx);
diff --git a/drivers/media/platform/exynos4-is/fimc-core.c b/drivers/media/platform/exynos4-is/fimc-core.c
index da2fc86cc524..25dbf5b05a96 100644
--- a/drivers/media/platform/exynos4-is/fimc-core.c
+++ b/drivers/media/platform/exynos4-is/fimc-core.c
@@ -122,7 +122,7 @@ static struct fimc_fmt fimc_formats[] = {
122 }, { 122 }, {
123 .name = "YUV 4:2:2 planar, Y/Cb/Cr", 123 .name = "YUV 4:2:2 planar, Y/Cb/Cr",
124 .fourcc = V4L2_PIX_FMT_YUV422P, 124 .fourcc = V4L2_PIX_FMT_YUV422P,
125 .depth = { 12 }, 125 .depth = { 16 },
126 .color = FIMC_FMT_YCBYCR422, 126 .color = FIMC_FMT_YCBYCR422,
127 .memplanes = 1, 127 .memplanes = 1,
128 .colplanes = 3, 128 .colplanes = 3,
diff --git a/drivers/media/tuners/fc2580.c b/drivers/media/tuners/fc2580.c
index 3aecaf465094..f0c9c42867de 100644
--- a/drivers/media/tuners/fc2580.c
+++ b/drivers/media/tuners/fc2580.c
@@ -195,7 +195,7 @@ static int fc2580_set_params(struct dvb_frontend *fe)
195 195
196 f_ref = 2UL * priv->cfg->clock / r_val; 196 f_ref = 2UL * priv->cfg->clock / r_val;
197 n_val = div_u64_rem(f_vco, f_ref, &k_val); 197 n_val = div_u64_rem(f_vco, f_ref, &k_val);
198 k_val_reg = 1UL * k_val * (1 << 20) / f_ref; 198 k_val_reg = div_u64(1ULL * k_val * (1 << 20), f_ref);
199 199
200 ret = fc2580_wr_reg(priv, 0x18, r18_val | ((k_val_reg >> 16) & 0xff)); 200 ret = fc2580_wr_reg(priv, 0x18, r18_val | ((k_val_reg >> 16) & 0xff));
201 if (ret < 0) 201 if (ret < 0)
@@ -348,8 +348,8 @@ static int fc2580_set_params(struct dvb_frontend *fe)
348 if (ret < 0) 348 if (ret < 0)
349 goto err; 349 goto err;
350 350
351 ret = fc2580_wr_reg(priv, 0x37, 1UL * priv->cfg->clock * \ 351 ret = fc2580_wr_reg(priv, 0x37, div_u64(1ULL * priv->cfg->clock *
352 fc2580_if_filter_lut[i].mul / 1000000000); 352 fc2580_if_filter_lut[i].mul, 1000000000));
353 if (ret < 0) 353 if (ret < 0)
354 goto err; 354 goto err;
355 355
diff --git a/drivers/media/tuners/fc2580_priv.h b/drivers/media/tuners/fc2580_priv.h
index be38a9e637e0..646c99452136 100644
--- a/drivers/media/tuners/fc2580_priv.h
+++ b/drivers/media/tuners/fc2580_priv.h
@@ -22,6 +22,7 @@
22#define FC2580_PRIV_H 22#define FC2580_PRIV_H
23 23
24#include "fc2580.h" 24#include "fc2580.h"
25#include <linux/math64.h>
25 26
26struct fc2580_reg_val { 27struct fc2580_reg_val {
27 u8 reg; 28 u8 reg;
diff --git a/drivers/media/usb/dvb-usb-v2/Makefile b/drivers/media/usb/dvb-usb-v2/Makefile
index 7407b8338ccf..bc38f03394cd 100644
--- a/drivers/media/usb/dvb-usb-v2/Makefile
+++ b/drivers/media/usb/dvb-usb-v2/Makefile
@@ -41,4 +41,3 @@ ccflags-y += -I$(srctree)/drivers/media/dvb-core
41ccflags-y += -I$(srctree)/drivers/media/dvb-frontends 41ccflags-y += -I$(srctree)/drivers/media/dvb-frontends
42ccflags-y += -I$(srctree)/drivers/media/tuners 42ccflags-y += -I$(srctree)/drivers/media/tuners
43ccflags-y += -I$(srctree)/drivers/media/common 43ccflags-y += -I$(srctree)/drivers/media/common
44ccflags-y += -I$(srctree)/drivers/staging/media/rtl2832u_sdr
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index 61d196e8b3ab..dcbd392e6efc 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -24,7 +24,6 @@
24 24
25#include "rtl2830.h" 25#include "rtl2830.h"
26#include "rtl2832.h" 26#include "rtl2832.h"
27#include "rtl2832_sdr.h"
28 27
29#include "qt1010.h" 28#include "qt1010.h"
30#include "mt2060.h" 29#include "mt2060.h"
@@ -36,6 +35,45 @@
36#include "tua9001.h" 35#include "tua9001.h"
37#include "r820t.h" 36#include "r820t.h"
38 37
38/*
39 * RTL2832_SDR module is in staging. That logic is added in order to avoid any
40 * hard dependency to drivers/staging/ directory as we want compile mainline
41 * driver even whole staging directory is missing.
42 */
43#include <media/v4l2-subdev.h>
44
45#if IS_ENABLED(CONFIG_DVB_RTL2832_SDR)
46struct dvb_frontend *rtl2832_sdr_attach(struct dvb_frontend *fe,
47 struct i2c_adapter *i2c, const struct rtl2832_config *cfg,
48 struct v4l2_subdev *sd);
49#else
50static inline struct dvb_frontend *rtl2832_sdr_attach(struct dvb_frontend *fe,
51 struct i2c_adapter *i2c, const struct rtl2832_config *cfg,
52 struct v4l2_subdev *sd)
53{
54 return NULL;
55}
56#endif
57
58#ifdef CONFIG_MEDIA_ATTACH
59#define dvb_attach_sdr(FUNCTION, ARGS...) ({ \
60 void *__r = NULL; \
61 typeof(&FUNCTION) __a = symbol_request(FUNCTION); \
62 if (__a) { \
63 __r = (void *) __a(ARGS); \
64 if (__r == NULL) \
65 symbol_put(FUNCTION); \
66 } \
67 __r; \
68})
69
70#else
71#define dvb_attach_sdr(FUNCTION, ARGS...) ({ \
72 FUNCTION(ARGS); \
73})
74
75#endif
76
39static int rtl28xxu_disable_rc; 77static int rtl28xxu_disable_rc;
40module_param_named(disable_rc, rtl28xxu_disable_rc, int, 0644); 78module_param_named(disable_rc, rtl28xxu_disable_rc, int, 0644);
41MODULE_PARM_DESC(disable_rc, "disable RTL2832U remote controller"); 79MODULE_PARM_DESC(disable_rc, "disable RTL2832U remote controller");
@@ -908,7 +946,7 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
908 adap->fe[0]->ops.tuner_ops.get_rf_strength; 946 adap->fe[0]->ops.tuner_ops.get_rf_strength;
909 947
910 /* attach SDR */ 948 /* attach SDR */
911 dvb_attach(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap, 949 dvb_attach_sdr(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap,
912 &rtl28xxu_rtl2832_fc0012_config, NULL); 950 &rtl28xxu_rtl2832_fc0012_config, NULL);
913 break; 951 break;
914 case TUNER_RTL2832_FC0013: 952 case TUNER_RTL2832_FC0013:
@@ -920,7 +958,7 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
920 adap->fe[0]->ops.tuner_ops.get_rf_strength; 958 adap->fe[0]->ops.tuner_ops.get_rf_strength;
921 959
922 /* attach SDR */ 960 /* attach SDR */
923 dvb_attach(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap, 961 dvb_attach_sdr(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap,
924 &rtl28xxu_rtl2832_fc0013_config, NULL); 962 &rtl28xxu_rtl2832_fc0013_config, NULL);
925 break; 963 break;
926 case TUNER_RTL2832_E4000: { 964 case TUNER_RTL2832_E4000: {
@@ -951,7 +989,7 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
951 i2c_set_adapdata(i2c_adap_internal, d); 989 i2c_set_adapdata(i2c_adap_internal, d);
952 990
953 /* attach SDR */ 991 /* attach SDR */
954 dvb_attach(rtl2832_sdr_attach, adap->fe[0], 992 dvb_attach_sdr(rtl2832_sdr_attach, adap->fe[0],
955 i2c_adap_internal, 993 i2c_adap_internal,
956 &rtl28xxu_rtl2832_e4000_config, sd); 994 &rtl28xxu_rtl2832_e4000_config, sd);
957 } 995 }
@@ -982,7 +1020,7 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
982 adap->fe[0]->ops.tuner_ops.get_rf_strength; 1020 adap->fe[0]->ops.tuner_ops.get_rf_strength;
983 1021
984 /* attach SDR */ 1022 /* attach SDR */
985 dvb_attach(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap, 1023 dvb_attach_sdr(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap,
986 &rtl28xxu_rtl2832_r820t_config, NULL); 1024 &rtl28xxu_rtl2832_r820t_config, NULL);
987 break; 1025 break;
988 case TUNER_RTL2832_R828D: 1026 case TUNER_RTL2832_R828D:
diff --git a/drivers/media/usb/gspca/sonixb.c b/drivers/media/usb/gspca/sonixb.c
index 7277dbd2afcd..ecbcb39feb71 100644
--- a/drivers/media/usb/gspca/sonixb.c
+++ b/drivers/media/usb/gspca/sonixb.c
@@ -1430,10 +1430,8 @@ static const struct usb_device_id device_table[] = {
1430 {USB_DEVICE(0x0c45, 0x600d), SB(PAS106, 101)}, 1430 {USB_DEVICE(0x0c45, 0x600d), SB(PAS106, 101)},
1431 {USB_DEVICE(0x0c45, 0x6011), SB(OV6650, 101)}, 1431 {USB_DEVICE(0x0c45, 0x6011), SB(OV6650, 101)},
1432 {USB_DEVICE(0x0c45, 0x6019), SB(OV7630, 101)}, 1432 {USB_DEVICE(0x0c45, 0x6019), SB(OV7630, 101)},
1433#if !IS_ENABLED(CONFIG_USB_SN9C102)
1434 {USB_DEVICE(0x0c45, 0x6024), SB(TAS5130CXX, 102)}, 1433 {USB_DEVICE(0x0c45, 0x6024), SB(TAS5130CXX, 102)},
1435 {USB_DEVICE(0x0c45, 0x6025), SB(TAS5130CXX, 102)}, 1434 {USB_DEVICE(0x0c45, 0x6025), SB(TAS5130CXX, 102)},
1436#endif
1437 {USB_DEVICE(0x0c45, 0x6027), SB(OV7630, 101)}, /* Genius Eye 310 */ 1435 {USB_DEVICE(0x0c45, 0x6027), SB(OV7630, 101)}, /* Genius Eye 310 */
1438 {USB_DEVICE(0x0c45, 0x6028), SB(PAS202, 102)}, 1436 {USB_DEVICE(0x0c45, 0x6028), SB(PAS202, 102)},
1439 {USB_DEVICE(0x0c45, 0x6029), SB(PAS106, 102)}, 1437 {USB_DEVICE(0x0c45, 0x6029), SB(PAS106, 102)},
diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
index 04b2daf567be..7e2411c36419 100644
--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
+++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
@@ -178,6 +178,9 @@ struct v4l2_create_buffers32 {
178 178
179static int __get_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user *up) 179static int __get_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user *up)
180{ 180{
181 if (get_user(kp->type, &up->type))
182 return -EFAULT;
183
181 switch (kp->type) { 184 switch (kp->type) {
182 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 185 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
183 case V4L2_BUF_TYPE_VIDEO_OUTPUT: 186 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
@@ -204,17 +207,16 @@ static int __get_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __us
204 207
205static int get_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user *up) 208static int get_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user *up)
206{ 209{
207 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_format32)) || 210 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_format32)))
208 get_user(kp->type, &up->type)) 211 return -EFAULT;
209 return -EFAULT;
210 return __get_v4l2_format32(kp, up); 212 return __get_v4l2_format32(kp, up);
211} 213}
212 214
213static int get_v4l2_create32(struct v4l2_create_buffers *kp, struct v4l2_create_buffers32 __user *up) 215static int get_v4l2_create32(struct v4l2_create_buffers *kp, struct v4l2_create_buffers32 __user *up)
214{ 216{
215 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_create_buffers32)) || 217 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_create_buffers32)) ||
216 copy_from_user(kp, up, offsetof(struct v4l2_create_buffers32, format.fmt))) 218 copy_from_user(kp, up, offsetof(struct v4l2_create_buffers32, format)))
217 return -EFAULT; 219 return -EFAULT;
218 return __get_v4l2_format32(&kp->format, &up->format); 220 return __get_v4l2_format32(&kp->format, &up->format);
219} 221}
220 222
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 6d4ee22708c9..32e969d95319 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1831,6 +1831,10 @@ int of_update_property(struct device_node *np, struct property *newprop)
1831 if (!found) 1831 if (!found)
1832 return -ENODEV; 1832 return -ENODEV;
1833 1833
1834 /* At early boot, bail out and defer setup to of_init() */
1835 if (!of_kset)
1836 return found ? 0 : -ENODEV;
1837
1834 /* Update the sysfs attribute */ 1838 /* Update the sysfs attribute */
1835 sysfs_remove_bin_file(&np->kobj, &oldprop->attr); 1839 sysfs_remove_bin_file(&np->kobj, &oldprop->attr);
1836 __of_add_property_sysfs(np, newprop); 1840 __of_add_property_sysfs(np, newprop);
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
index 58499277903a..6efc2ec5e4db 100644
--- a/drivers/pci/hotplug/shpchp_ctrl.c
+++ b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -282,8 +282,8 @@ static int board_added(struct slot *p_slot)
282 return WRONG_BUS_FREQUENCY; 282 return WRONG_BUS_FREQUENCY;
283 } 283 }
284 284
285 bsp = ctrl->pci_dev->bus->cur_bus_speed; 285 bsp = ctrl->pci_dev->subordinate->cur_bus_speed;
286 msp = ctrl->pci_dev->bus->max_bus_speed; 286 msp = ctrl->pci_dev->subordinate->max_bus_speed;
287 287
288 /* Check if there are other slots or devices on the same bus */ 288 /* Check if there are other slots or devices on the same bus */
289 if (!list_empty(&ctrl->pci_dev->subordinate->devices)) 289 if (!list_empty(&ctrl->pci_dev->subordinate->devices))
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 7325d43bf030..759475ef6ff3 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3067,7 +3067,8 @@ int pci_wait_for_pending_transaction(struct pci_dev *dev)
3067 if (!pci_is_pcie(dev)) 3067 if (!pci_is_pcie(dev))
3068 return 1; 3068 return 1;
3069 3069
3070 return pci_wait_for_pending(dev, PCI_EXP_DEVSTA, PCI_EXP_DEVSTA_TRPND); 3070 return pci_wait_for_pending(dev, pci_pcie_cap(dev) + PCI_EXP_DEVSTA,
3071 PCI_EXP_DEVSTA_TRPND);
3071} 3072}
3072EXPORT_SYMBOL(pci_wait_for_pending_transaction); 3073EXPORT_SYMBOL(pci_wait_for_pending_transaction);
3073 3074
@@ -3109,7 +3110,7 @@ static int pci_af_flr(struct pci_dev *dev, int probe)
3109 return 0; 3110 return 0;
3110 3111
3111 /* Wait for Transaction Pending bit clean */ 3112 /* Wait for Transaction Pending bit clean */
3112 if (pci_wait_for_pending(dev, PCI_AF_STATUS, PCI_AF_STATUS_TP)) 3113 if (pci_wait_for_pending(dev, pos + PCI_AF_STATUS, PCI_AF_STATUS_TP))
3113 goto clear; 3114 goto clear;
3114 3115
3115 dev_err(&dev->dev, "transaction is not cleared; " 3116 dev_err(&dev->dev, "transaction is not cleared; "
diff --git a/drivers/sh/Makefile b/drivers/sh/Makefile
index fc67f564f02c..788ed9b59b4e 100644
--- a/drivers/sh/Makefile
+++ b/drivers/sh/Makefile
@@ -1,10 +1,12 @@
1# 1#
2# Makefile for the SuperH specific drivers. 2# Makefile for the SuperH specific drivers.
3# 3#
4obj-y := intc/ 4obj-$(CONFIG_SUPERH) += intc/
5obj-$(CONFIG_ARCH_SHMOBILE_LEGACY) += intc/
6ifneq ($(CONFIG_COMMON_CLK),y)
7obj-$(CONFIG_HAVE_CLK) += clk/
8endif
9obj-$(CONFIG_MAPLE) += maple/
10obj-$(CONFIG_SUPERHYWAY) += superhyway/
5 11
6obj-$(CONFIG_HAVE_CLK) += clk/ 12obj-y += pm_runtime.o
7obj-$(CONFIG_MAPLE) += maple/
8obj-$(CONFIG_SUPERHYWAY) += superhyway/
9
10obj-y += pm_runtime.o
diff --git a/drivers/sh/pm_runtime.c b/drivers/sh/pm_runtime.c
index 8afa5a4589f2..10c65eb51f85 100644
--- a/drivers/sh/pm_runtime.c
+++ b/drivers/sh/pm_runtime.c
@@ -50,8 +50,25 @@ static struct pm_clk_notifier_block platform_bus_notifier = {
50 .con_ids = { NULL, }, 50 .con_ids = { NULL, },
51}; 51};
52 52
53static bool default_pm_on;
54
53static int __init sh_pm_runtime_init(void) 55static int __init sh_pm_runtime_init(void)
54{ 56{
57 if (IS_ENABLED(CONFIG_ARCH_SHMOBILE_MULTI)) {
58 if (!of_machine_is_compatible("renesas,emev2") &&
59 !of_machine_is_compatible("renesas,r7s72100") &&
60 !of_machine_is_compatible("renesas,r8a73a4") &&
61 !of_machine_is_compatible("renesas,r8a7740") &&
62 !of_machine_is_compatible("renesas,r8a7778") &&
63 !of_machine_is_compatible("renesas,r8a7779") &&
64 !of_machine_is_compatible("renesas,r8a7790") &&
65 !of_machine_is_compatible("renesas,r8a7791") &&
66 !of_machine_is_compatible("renesas,sh7372") &&
67 !of_machine_is_compatible("renesas,sh73a0"))
68 return 0;
69 }
70
71 default_pm_on = true;
55 pm_clk_add_notifier(&platform_bus_type, &platform_bus_notifier); 72 pm_clk_add_notifier(&platform_bus_type, &platform_bus_notifier);
56 return 0; 73 return 0;
57} 74}
@@ -59,7 +76,8 @@ core_initcall(sh_pm_runtime_init);
59 76
60static int __init sh_pm_runtime_late_init(void) 77static int __init sh_pm_runtime_late_init(void)
61{ 78{
62 pm_genpd_poweroff_unused(); 79 if (default_pm_on)
80 pm_genpd_poweroff_unused();
63 return 0; 81 return 0;
64} 82}
65late_initcall(sh_pm_runtime_late_init); 83late_initcall(sh_pm_runtime_late_init);
diff --git a/drivers/spi/spi-pxa2xx-dma.c b/drivers/spi/spi-pxa2xx-dma.c
index 713af4806f26..f6759dc0153b 100644
--- a/drivers/spi/spi-pxa2xx-dma.c
+++ b/drivers/spi/spi-pxa2xx-dma.c
@@ -29,18 +29,6 @@ static int pxa2xx_spi_map_dma_buffer(struct driver_data *drv_data,
29 struct sg_table *sgt; 29 struct sg_table *sgt;
30 void *buf, *pbuf; 30 void *buf, *pbuf;
31 31
32 /*
33 * Some DMA controllers have problems transferring buffers that are
34 * not multiple of 4 bytes. So we truncate the transfer so that it
35 * is suitable for such controllers, and handle the trailing bytes
36 * manually after the DMA completes.
37 *
38 * REVISIT: It would be better if this information could be
39 * retrieved directly from the DMA device in a similar way than
40 * ->copy_align etc. is done.
41 */
42 len = ALIGN(drv_data->len, 4);
43
44 if (dir == DMA_TO_DEVICE) { 32 if (dir == DMA_TO_DEVICE) {
45 dmadev = drv_data->tx_chan->device->dev; 33 dmadev = drv_data->tx_chan->device->dev;
46 sgt = &drv_data->tx_sgt; 34 sgt = &drv_data->tx_sgt;
@@ -144,12 +132,8 @@ static void pxa2xx_spi_dma_transfer_complete(struct driver_data *drv_data,
144 if (!error) { 132 if (!error) {
145 pxa2xx_spi_unmap_dma_buffers(drv_data); 133 pxa2xx_spi_unmap_dma_buffers(drv_data);
146 134
147 /* Handle the last bytes of unaligned transfer */
148 drv_data->tx += drv_data->tx_map_len; 135 drv_data->tx += drv_data->tx_map_len;
149 drv_data->write(drv_data);
150
151 drv_data->rx += drv_data->rx_map_len; 136 drv_data->rx += drv_data->rx_map_len;
152 drv_data->read(drv_data);
153 137
154 msg->actual_length += drv_data->len; 138 msg->actual_length += drv_data->len;
155 msg->state = pxa2xx_spi_next_transfer(drv_data); 139 msg->state = pxa2xx_spi_next_transfer(drv_data);
diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c
index b032e8885e24..78c66e3c53ed 100644
--- a/drivers/spi/spi-qup.c
+++ b/drivers/spi/spi-qup.c
@@ -734,7 +734,7 @@ static int spi_qup_remove(struct platform_device *pdev)
734 int ret; 734 int ret;
735 735
736 ret = pm_runtime_get_sync(&pdev->dev); 736 ret = pm_runtime_get_sync(&pdev->dev);
737 if (ret) 737 if (ret < 0)
738 return ret; 738 return ret;
739 739
740 ret = spi_qup_set_state(controller, QUP_STATE_RESET); 740 ret = spi_qup_set_state(controller, QUP_STATE_RESET);
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 4eb9bf02996c..939edf473235 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -580,6 +580,7 @@ static void spi_set_cs(struct spi_device *spi, bool enable)
580 spi->master->set_cs(spi, !enable); 580 spi->master->set_cs(spi, !enable);
581} 581}
582 582
583#ifdef CONFIG_HAS_DMA
583static int spi_map_buf(struct spi_master *master, struct device *dev, 584static int spi_map_buf(struct spi_master *master, struct device *dev,
584 struct sg_table *sgt, void *buf, size_t len, 585 struct sg_table *sgt, void *buf, size_t len,
585 enum dma_data_direction dir) 586 enum dma_data_direction dir)
@@ -637,55 +638,12 @@ static void spi_unmap_buf(struct spi_master *master, struct device *dev,
637 } 638 }
638} 639}
639 640
640static int spi_map_msg(struct spi_master *master, struct spi_message *msg) 641static int __spi_map_msg(struct spi_master *master, struct spi_message *msg)
641{ 642{
642 struct device *tx_dev, *rx_dev; 643 struct device *tx_dev, *rx_dev;
643 struct spi_transfer *xfer; 644 struct spi_transfer *xfer;
644 void *tmp;
645 unsigned int max_tx, max_rx;
646 int ret; 645 int ret;
647 646
648 if (master->flags & (SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX)) {
649 max_tx = 0;
650 max_rx = 0;
651
652 list_for_each_entry(xfer, &msg->transfers, transfer_list) {
653 if ((master->flags & SPI_MASTER_MUST_TX) &&
654 !xfer->tx_buf)
655 max_tx = max(xfer->len, max_tx);
656 if ((master->flags & SPI_MASTER_MUST_RX) &&
657 !xfer->rx_buf)
658 max_rx = max(xfer->len, max_rx);
659 }
660
661 if (max_tx) {
662 tmp = krealloc(master->dummy_tx, max_tx,
663 GFP_KERNEL | GFP_DMA);
664 if (!tmp)
665 return -ENOMEM;
666 master->dummy_tx = tmp;
667 memset(tmp, 0, max_tx);
668 }
669
670 if (max_rx) {
671 tmp = krealloc(master->dummy_rx, max_rx,
672 GFP_KERNEL | GFP_DMA);
673 if (!tmp)
674 return -ENOMEM;
675 master->dummy_rx = tmp;
676 }
677
678 if (max_tx || max_rx) {
679 list_for_each_entry(xfer, &msg->transfers,
680 transfer_list) {
681 if (!xfer->tx_buf)
682 xfer->tx_buf = master->dummy_tx;
683 if (!xfer->rx_buf)
684 xfer->rx_buf = master->dummy_rx;
685 }
686 }
687 }
688
689 if (!master->can_dma) 647 if (!master->can_dma)
690 return 0; 648 return 0;
691 649
@@ -742,6 +700,69 @@ static int spi_unmap_msg(struct spi_master *master, struct spi_message *msg)
742 700
743 return 0; 701 return 0;
744} 702}
703#else /* !CONFIG_HAS_DMA */
704static inline int __spi_map_msg(struct spi_master *master,
705 struct spi_message *msg)
706{
707 return 0;
708}
709
710static inline int spi_unmap_msg(struct spi_master *master,
711 struct spi_message *msg)
712{
713 return 0;
714}
715#endif /* !CONFIG_HAS_DMA */
716
717static int spi_map_msg(struct spi_master *master, struct spi_message *msg)
718{
719 struct spi_transfer *xfer;
720 void *tmp;
721 unsigned int max_tx, max_rx;
722
723 if (master->flags & (SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX)) {
724 max_tx = 0;
725 max_rx = 0;
726
727 list_for_each_entry(xfer, &msg->transfers, transfer_list) {
728 if ((master->flags & SPI_MASTER_MUST_TX) &&
729 !xfer->tx_buf)
730 max_tx = max(xfer->len, max_tx);
731 if ((master->flags & SPI_MASTER_MUST_RX) &&
732 !xfer->rx_buf)
733 max_rx = max(xfer->len, max_rx);
734 }
735
736 if (max_tx) {
737 tmp = krealloc(master->dummy_tx, max_tx,
738 GFP_KERNEL | GFP_DMA);
739 if (!tmp)
740 return -ENOMEM;
741 master->dummy_tx = tmp;
742 memset(tmp, 0, max_tx);
743 }
744
745 if (max_rx) {
746 tmp = krealloc(master->dummy_rx, max_rx,
747 GFP_KERNEL | GFP_DMA);
748 if (!tmp)
749 return -ENOMEM;
750 master->dummy_rx = tmp;
751 }
752
753 if (max_tx || max_rx) {
754 list_for_each_entry(xfer, &msg->transfers,
755 transfer_list) {
756 if (!xfer->tx_buf)
757 xfer->tx_buf = master->dummy_tx;
758 if (!xfer->rx_buf)
759 xfer->rx_buf = master->dummy_rx;
760 }
761 }
762 }
763
764 return __spi_map_msg(master, msg);
765}
745 766
746/* 767/*
747 * spi_transfer_one_message - Default implementation of transfer_one_message() 768 * spi_transfer_one_message - Default implementation of transfer_one_message()
@@ -1151,7 +1172,6 @@ static int spi_master_initialize_queue(struct spi_master *master)
1151{ 1172{
1152 int ret; 1173 int ret;
1153 1174
1154 master->queued = true;
1155 master->transfer = spi_queued_transfer; 1175 master->transfer = spi_queued_transfer;
1156 if (!master->transfer_one_message) 1176 if (!master->transfer_one_message)
1157 master->transfer_one_message = spi_transfer_one_message; 1177 master->transfer_one_message = spi_transfer_one_message;
@@ -1162,6 +1182,7 @@ static int spi_master_initialize_queue(struct spi_master *master)
1162 dev_err(&master->dev, "problem initializing queue\n"); 1182 dev_err(&master->dev, "problem initializing queue\n");
1163 goto err_init_queue; 1183 goto err_init_queue;
1164 } 1184 }
1185 master->queued = true;
1165 ret = spi_start_queue(master); 1186 ret = spi_start_queue(master);
1166 if (ret) { 1187 if (ret) {
1167 dev_err(&master->dev, "problem starting queue\n"); 1188 dev_err(&master->dev, "problem starting queue\n");
@@ -1171,8 +1192,8 @@ static int spi_master_initialize_queue(struct spi_master *master)
1171 return 0; 1192 return 0;
1172 1193
1173err_start_queue: 1194err_start_queue:
1174err_init_queue:
1175 spi_destroy_queue(master); 1195 spi_destroy_queue(master);
1196err_init_queue:
1176 return ret; 1197 return ret;
1177} 1198}
1178 1199
@@ -1756,7 +1777,7 @@ EXPORT_SYMBOL_GPL(spi_busnum_to_master);
1756 */ 1777 */
1757int spi_setup(struct spi_device *spi) 1778int spi_setup(struct spi_device *spi)
1758{ 1779{
1759 unsigned bad_bits; 1780 unsigned bad_bits, ugly_bits;
1760 int status = 0; 1781 int status = 0;
1761 1782
1762 /* check mode to prevent that DUAL and QUAD set at the same time 1783 /* check mode to prevent that DUAL and QUAD set at the same time
@@ -1776,6 +1797,15 @@ int spi_setup(struct spi_device *spi)
1776 * that aren't supported with their current master 1797 * that aren't supported with their current master
1777 */ 1798 */
1778 bad_bits = spi->mode & ~spi->master->mode_bits; 1799 bad_bits = spi->mode & ~spi->master->mode_bits;
1800 ugly_bits = bad_bits &
1801 (SPI_TX_DUAL | SPI_TX_QUAD | SPI_RX_DUAL | SPI_RX_QUAD);
1802 if (ugly_bits) {
1803 dev_warn(&spi->dev,
1804 "setup: ignoring unsupported mode bits %x\n",
1805 ugly_bits);
1806 spi->mode &= ~ugly_bits;
1807 bad_bits &= ~ugly_bits;
1808 }
1779 if (bad_bits) { 1809 if (bad_bits) {
1780 dev_err(&spi->dev, "setup: unsupported mode bits %x\n", 1810 dev_err(&spi->dev, "setup: unsupported mode bits %x\n",
1781 bad_bits); 1811 bad_bits);
diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c
index 4144a75e5f71..c270c9ae6d27 100644
--- a/drivers/staging/imx-drm/imx-drm-core.c
+++ b/drivers/staging/imx-drm/imx-drm-core.c
@@ -517,7 +517,7 @@ int imx_drm_encoder_get_mux_id(struct device_node *node,
517 of_node_put(port); 517 of_node_put(port);
518 if (port == imx_crtc->port) { 518 if (port == imx_crtc->port) {
519 ret = of_graph_parse_endpoint(ep, &endpoint); 519 ret = of_graph_parse_endpoint(ep, &endpoint);
520 return ret ? ret : endpoint.id; 520 return ret ? ret : endpoint.port;
521 } 521 }
522 } while (ep); 522 } while (ep);
523 523
@@ -675,6 +675,11 @@ static int imx_drm_platform_probe(struct platform_device *pdev)
675 if (!remote || !of_device_is_available(remote)) { 675 if (!remote || !of_device_is_available(remote)) {
676 of_node_put(remote); 676 of_node_put(remote);
677 continue; 677 continue;
678 } else if (!of_device_is_available(remote->parent)) {
679 dev_warn(&pdev->dev, "parent device of %s is not available\n",
680 remote->full_name);
681 of_node_put(remote);
682 continue;
678 } 683 }
679 684
680 ret = imx_drm_add_component(&pdev->dev, remote); 685 ret = imx_drm_add_component(&pdev->dev, remote);
diff --git a/drivers/staging/imx-drm/imx-tve.c b/drivers/staging/imx-drm/imx-tve.c
index 575533f4fd64..a23f4f773146 100644
--- a/drivers/staging/imx-drm/imx-tve.c
+++ b/drivers/staging/imx-drm/imx-tve.c
@@ -582,7 +582,7 @@ static int imx_tve_bind(struct device *dev, struct device *master, void *data)
582 tve->dev = dev; 582 tve->dev = dev;
583 spin_lock_init(&tve->lock); 583 spin_lock_init(&tve->lock);
584 584
585 ddc_node = of_parse_phandle(np, "i2c-ddc-bus", 0); 585 ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0);
586 if (ddc_node) { 586 if (ddc_node) {
587 tve->ddc = of_find_i2c_adapter_by_node(ddc_node); 587 tve->ddc = of_find_i2c_adapter_by_node(ddc_node);
588 of_node_put(ddc_node); 588 of_node_put(ddc_node);
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c
index 8c101cbbee97..acc8184c46cd 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_video.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c
@@ -1247,9 +1247,18 @@ static int vpfe_stop_streaming(struct vb2_queue *vq)
1247 struct vpfe_fh *fh = vb2_get_drv_priv(vq); 1247 struct vpfe_fh *fh = vb2_get_drv_priv(vq);
1248 struct vpfe_video_device *video = fh->video; 1248 struct vpfe_video_device *video = fh->video;
1249 1249
1250 if (!vb2_is_streaming(vq))
1251 return 0;
1252 /* release all active buffers */ 1250 /* release all active buffers */
1251 if (video->cur_frm == video->next_frm) {
1252 vb2_buffer_done(&video->cur_frm->vb, VB2_BUF_STATE_ERROR);
1253 } else {
1254 if (video->cur_frm != NULL)
1255 vb2_buffer_done(&video->cur_frm->vb,
1256 VB2_BUF_STATE_ERROR);
1257 if (video->next_frm != NULL)
1258 vb2_buffer_done(&video->next_frm->vb,
1259 VB2_BUF_STATE_ERROR);
1260 }
1261
1253 while (!list_empty(&video->dma_queue)) { 1262 while (!list_empty(&video->dma_queue)) {
1254 video->next_frm = list_entry(video->dma_queue.next, 1263 video->next_frm = list_entry(video->dma_queue.next,
1255 struct vpfe_cap_buffer, list); 1264 struct vpfe_cap_buffer, list);
diff --git a/drivers/staging/media/sn9c102/sn9c102_devtable.h b/drivers/staging/media/sn9c102/sn9c102_devtable.h
index b3d2cc729657..4ba569258498 100644
--- a/drivers/staging/media/sn9c102/sn9c102_devtable.h
+++ b/drivers/staging/media/sn9c102/sn9c102_devtable.h
@@ -48,10 +48,8 @@ static const struct usb_device_id sn9c102_id_table[] = {
48 { SN9C102_USB_DEVICE(0x0c45, 0x600d, BRIDGE_SN9C102), }, 48 { SN9C102_USB_DEVICE(0x0c45, 0x600d, BRIDGE_SN9C102), },
49/* { SN9C102_USB_DEVICE(0x0c45, 0x6011, BRIDGE_SN9C102), }, OV6650 */ 49/* { SN9C102_USB_DEVICE(0x0c45, 0x6011, BRIDGE_SN9C102), }, OV6650 */
50 { SN9C102_USB_DEVICE(0x0c45, 0x6019, BRIDGE_SN9C102), }, 50 { SN9C102_USB_DEVICE(0x0c45, 0x6019, BRIDGE_SN9C102), },
51#endif
52 { SN9C102_USB_DEVICE(0x0c45, 0x6024, BRIDGE_SN9C102), }, 51 { SN9C102_USB_DEVICE(0x0c45, 0x6024, BRIDGE_SN9C102), },
53 { SN9C102_USB_DEVICE(0x0c45, 0x6025, BRIDGE_SN9C102), }, 52 { SN9C102_USB_DEVICE(0x0c45, 0x6025, BRIDGE_SN9C102), },
54#if !defined CONFIG_USB_GSPCA_SONIXB && !defined CONFIG_USB_GSPCA_SONIXB_MODULE
55 { SN9C102_USB_DEVICE(0x0c45, 0x6028, BRIDGE_SN9C102), }, 53 { SN9C102_USB_DEVICE(0x0c45, 0x6028, BRIDGE_SN9C102), },
56 { SN9C102_USB_DEVICE(0x0c45, 0x6029, BRIDGE_SN9C102), }, 54 { SN9C102_USB_DEVICE(0x0c45, 0x6029, BRIDGE_SN9C102), },
57 { SN9C102_USB_DEVICE(0x0c45, 0x602a, BRIDGE_SN9C102), }, 55 { SN9C102_USB_DEVICE(0x0c45, 0x602a, BRIDGE_SN9C102), },
diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c
index 57eca7a45672..4fe751f7c2bf 100644
--- a/drivers/staging/rtl8723au/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c
@@ -953,8 +953,6 @@ static int netdev_close(struct net_device *pnetdev)
953#endif /* CONFIG_8723AU_P2P */ 953#endif /* CONFIG_8723AU_P2P */
954 954
955 rtw_scan_abort23a(padapter); 955 rtw_scan_abort23a(padapter);
956 /* set this at the end */
957 padapter->rtw_wdev->iftype = NL80211_IFTYPE_MONITOR;
958 956
959 RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-871x_drv - drv_close\n")); 957 RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-871x_drv - drv_close\n"));
960 DBG_8723A("-871x_drv - drv_close, bup =%d\n", padapter->bup); 958 DBG_8723A("-871x_drv - drv_close, bup =%d\n", padapter->bup);
diff --git a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c
index c49160e477d8..07e542e5d156 100644
--- a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c
+++ b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c
@@ -26,7 +26,7 @@ unsigned int ffaddr2pipehdl23a(struct dvobj_priv *pdvobj, u32 addr)
26 if (addr == RECV_BULK_IN_ADDR) { 26 if (addr == RECV_BULK_IN_ADDR) {
27 pipe = usb_rcvbulkpipe(pusbd, pdvobj->RtInPipe[0]); 27 pipe = usb_rcvbulkpipe(pusbd, pdvobj->RtInPipe[0]);
28 } else if (addr == RECV_INT_IN_ADDR) { 28 } else if (addr == RECV_INT_IN_ADDR) {
29 pipe = usb_rcvbulkpipe(pusbd, pdvobj->RtInPipe[1]); 29 pipe = usb_rcvintpipe(pusbd, pdvobj->RtInPipe[1]);
30 } else if (addr < HW_QUEUE_ENTRY) { 30 } else if (addr < HW_QUEUE_ENTRY) {
31 ep_num = pdvobj->Queue2Pipe[addr]; 31 ep_num = pdvobj->Queue2Pipe[addr];
32 pipe = usb_sndbulkpipe(pusbd, ep_num); 32 pipe = usb_sndbulkpipe(pusbd, ep_num);
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 78cab13bbb1b..46588c85d39b 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -1593,7 +1593,9 @@ int iscsit_process_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
1593 * Initiator is expecting a NopIN ping reply.. 1593 * Initiator is expecting a NopIN ping reply..
1594 */ 1594 */
1595 if (hdr->itt != RESERVED_ITT) { 1595 if (hdr->itt != RESERVED_ITT) {
1596 BUG_ON(!cmd); 1596 if (!cmd)
1597 return iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR,
1598 (unsigned char *)hdr);
1597 1599
1598 spin_lock_bh(&conn->cmd_lock); 1600 spin_lock_bh(&conn->cmd_lock);
1599 list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list); 1601 list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list);
diff --git a/drivers/target/iscsi/iscsi_target_core.h b/drivers/target/iscsi/iscsi_target_core.h
index 6960f22909ae..302eb3b78715 100644
--- a/drivers/target/iscsi/iscsi_target_core.h
+++ b/drivers/target/iscsi/iscsi_target_core.h
@@ -775,6 +775,7 @@ struct iscsi_np {
775 int np_ip_proto; 775 int np_ip_proto;
776 int np_sock_type; 776 int np_sock_type;
777 enum np_thread_state_table np_thread_state; 777 enum np_thread_state_table np_thread_state;
778 bool enabled;
778 enum iscsi_timer_flags_table np_login_timer_flags; 779 enum iscsi_timer_flags_table np_login_timer_flags;
779 u32 np_exports; 780 u32 np_exports;
780 enum np_flags_table np_flags; 781 enum np_flags_table np_flags;
diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c
index 8739b98f6f93..ca31fa1b8a4b 100644
--- a/drivers/target/iscsi/iscsi_target_login.c
+++ b/drivers/target/iscsi/iscsi_target_login.c
@@ -436,7 +436,7 @@ static int iscsi_login_zero_tsih_s2(
436 } 436 }
437 off = mrdsl % PAGE_SIZE; 437 off = mrdsl % PAGE_SIZE;
438 if (!off) 438 if (!off)
439 return 0; 439 goto check_prot;
440 440
441 if (mrdsl < PAGE_SIZE) 441 if (mrdsl < PAGE_SIZE)
442 mrdsl = PAGE_SIZE; 442 mrdsl = PAGE_SIZE;
@@ -452,6 +452,31 @@ static int iscsi_login_zero_tsih_s2(
452 ISCSI_LOGIN_STATUS_NO_RESOURCES); 452 ISCSI_LOGIN_STATUS_NO_RESOURCES);
453 return -1; 453 return -1;
454 } 454 }
455 /*
456 * ISER currently requires that ImmediateData + Unsolicited
457 * Data be disabled when protection / signature MRs are enabled.
458 */
459check_prot:
460 if (sess->se_sess->sup_prot_ops &
461 (TARGET_PROT_DOUT_STRIP | TARGET_PROT_DOUT_PASS |
462 TARGET_PROT_DOUT_INSERT)) {
463
464 sprintf(buf, "ImmediateData=No");
465 if (iscsi_change_param_value(buf, conn->param_list, 0) < 0) {
466 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
467 ISCSI_LOGIN_STATUS_NO_RESOURCES);
468 return -1;
469 }
470
471 sprintf(buf, "InitialR2T=Yes");
472 if (iscsi_change_param_value(buf, conn->param_list, 0) < 0) {
473 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
474 ISCSI_LOGIN_STATUS_NO_RESOURCES);
475 return -1;
476 }
477 pr_debug("Forcing ImmediateData=No + InitialR2T=Yes for"
478 " T10-PI enabled ISER session\n");
479 }
455 } 480 }
456 481
457 return 0; 482 return 0;
@@ -984,6 +1009,7 @@ int iscsi_target_setup_login_socket(
984 } 1009 }
985 1010
986 np->np_transport = t; 1011 np->np_transport = t;
1012 np->enabled = true;
987 return 0; 1013 return 0;
988} 1014}
989 1015
diff --git a/drivers/target/iscsi/iscsi_target_tpg.c b/drivers/target/iscsi/iscsi_target_tpg.c
index eb96b20dc09e..ca1811858afd 100644
--- a/drivers/target/iscsi/iscsi_target_tpg.c
+++ b/drivers/target/iscsi/iscsi_target_tpg.c
@@ -184,6 +184,7 @@ static void iscsit_clear_tpg_np_login_thread(
184 return; 184 return;
185 } 185 }
186 186
187 tpg_np->tpg_np->enabled = false;
187 iscsit_reset_np_thread(tpg_np->tpg_np, tpg_np, tpg, shutdown); 188 iscsit_reset_np_thread(tpg_np->tpg_np, tpg_np, tpg, shutdown);
188} 189}
189 190
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index 65001e133670..26416c15d65c 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -798,10 +798,10 @@ int se_dev_set_emulate_write_cache(struct se_device *dev, int flag)
798 pr_err("emulate_write_cache not supported for pSCSI\n"); 798 pr_err("emulate_write_cache not supported for pSCSI\n");
799 return -EINVAL; 799 return -EINVAL;
800 } 800 }
801 if (dev->transport->get_write_cache) { 801 if (flag &&
802 pr_warn("emulate_write_cache cannot be changed when underlying" 802 dev->transport->get_write_cache) {
803 " HW reports WriteCacheEnabled, ignoring request\n"); 803 pr_err("emulate_write_cache not supported for this device\n");
804 return 0; 804 return -EINVAL;
805 } 805 }
806 806
807 dev->dev_attrib.emulate_write_cache = flag; 807 dev->dev_attrib.emulate_write_cache = flag;
@@ -936,6 +936,10 @@ int se_dev_set_pi_prot_type(struct se_device *dev, int flag)
936 return 0; 936 return 0;
937 } 937 }
938 if (!dev->transport->init_prot || !dev->transport->free_prot) { 938 if (!dev->transport->init_prot || !dev->transport->free_prot) {
939 /* 0 is only allowed value for non-supporting backends */
940 if (flag == 0)
941 return 0;
942
939 pr_err("DIF protection not supported by backend: %s\n", 943 pr_err("DIF protection not supported by backend: %s\n",
940 dev->transport->name); 944 dev->transport->name);
941 return -ENOSYS; 945 return -ENOSYS;
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index d4b98690a736..789aa9eb0a1e 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1113,6 +1113,7 @@ void transport_init_se_cmd(
1113 init_completion(&cmd->cmd_wait_comp); 1113 init_completion(&cmd->cmd_wait_comp);
1114 init_completion(&cmd->task_stop_comp); 1114 init_completion(&cmd->task_stop_comp);
1115 spin_lock_init(&cmd->t_state_lock); 1115 spin_lock_init(&cmd->t_state_lock);
1116 kref_init(&cmd->cmd_kref);
1116 cmd->transport_state = CMD_T_DEV_ACTIVE; 1117 cmd->transport_state = CMD_T_DEV_ACTIVE;
1117 1118
1118 cmd->se_tfo = tfo; 1119 cmd->se_tfo = tfo;
@@ -2357,7 +2358,6 @@ int target_get_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd,
2357 unsigned long flags; 2358 unsigned long flags;
2358 int ret = 0; 2359 int ret = 0;
2359 2360
2360 kref_init(&se_cmd->cmd_kref);
2361 /* 2361 /*
2362 * Add a second kref if the fabric caller is expecting to handle 2362 * Add a second kref if the fabric caller is expecting to handle
2363 * fabric acknowledgement that requires two target_put_sess_cmd() 2363 * fabric acknowledgement that requires two target_put_sess_cmd()
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c
index 01cf37f212c3..f5fd515b2bee 100644
--- a/drivers/target/tcm_fc/tfc_cmd.c
+++ b/drivers/target/tcm_fc/tfc_cmd.c
@@ -90,18 +90,18 @@ static void ft_free_cmd(struct ft_cmd *cmd)
90{ 90{
91 struct fc_frame *fp; 91 struct fc_frame *fp;
92 struct fc_lport *lport; 92 struct fc_lport *lport;
93 struct se_session *se_sess; 93 struct ft_sess *sess;
94 94
95 if (!cmd) 95 if (!cmd)
96 return; 96 return;
97 se_sess = cmd->sess->se_sess; 97 sess = cmd->sess;
98 fp = cmd->req_frame; 98 fp = cmd->req_frame;
99 lport = fr_dev(fp); 99 lport = fr_dev(fp);
100 if (fr_seq(fp)) 100 if (fr_seq(fp))
101 lport->tt.seq_release(fr_seq(fp)); 101 lport->tt.seq_release(fr_seq(fp));
102 fc_frame_free(fp); 102 fc_frame_free(fp);
103 percpu_ida_free(&se_sess->sess_tag_pool, cmd->se_cmd.map_tag); 103 percpu_ida_free(&sess->se_sess->sess_tag_pool, cmd->se_cmd.map_tag);
104 ft_sess_put(cmd->sess); /* undo get from lookup at recv */ 104 ft_sess_put(sess); /* undo get from lookup at recv */
105} 105}
106 106
107void ft_release_cmd(struct se_cmd *se_cmd) 107void ft_release_cmd(struct se_cmd *se_cmd)
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 2ad7de94efef..2f6d7b13b5bd 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3120,6 +3120,8 @@ process_slot:
3120 } else if (type == BTRFS_FILE_EXTENT_INLINE) { 3120 } else if (type == BTRFS_FILE_EXTENT_INLINE) {
3121 u64 skip = 0; 3121 u64 skip = 0;
3122 u64 trim = 0; 3122 u64 trim = 0;
3123 u64 aligned_end = 0;
3124
3123 if (off > key.offset) { 3125 if (off > key.offset) {
3124 skip = off - key.offset; 3126 skip = off - key.offset;
3125 new_key.offset += skip; 3127 new_key.offset += skip;
@@ -3136,9 +3138,11 @@ process_slot:
3136 size -= skip + trim; 3138 size -= skip + trim;
3137 datal -= skip + trim; 3139 datal -= skip + trim;
3138 3140
3141 aligned_end = ALIGN(new_key.offset + datal,
3142 root->sectorsize);
3139 ret = btrfs_drop_extents(trans, root, inode, 3143 ret = btrfs_drop_extents(trans, root, inode,
3140 new_key.offset, 3144 new_key.offset,
3141 new_key.offset + datal, 3145 aligned_end,
3142 1); 3146 1);
3143 if (ret) { 3147 if (ret) {
3144 if (ret != -EOPNOTSUPP) 3148 if (ret != -EOPNOTSUPP)
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index eb6537a08c1b..fd38b5053479 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -1668,7 +1668,7 @@ static int get_first_ref(struct btrfs_root *root, u64 ino,
1668 goto out; 1668 goto out;
1669 } 1669 }
1670 1670
1671 if (key.type == BTRFS_INODE_REF_KEY) { 1671 if (found_key.type == BTRFS_INODE_REF_KEY) {
1672 struct btrfs_inode_ref *iref; 1672 struct btrfs_inode_ref *iref;
1673 iref = btrfs_item_ptr(path->nodes[0], path->slots[0], 1673 iref = btrfs_item_ptr(path->nodes[0], path->slots[0],
1674 struct btrfs_inode_ref); 1674 struct btrfs_inode_ref);
diff --git a/fs/exec.c b/fs/exec.c
index 476f3ebf437e..238b7aa26f68 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -657,10 +657,10 @@ int setup_arg_pages(struct linux_binprm *bprm,
657 unsigned long rlim_stack; 657 unsigned long rlim_stack;
658 658
659#ifdef CONFIG_STACK_GROWSUP 659#ifdef CONFIG_STACK_GROWSUP
660 /* Limit stack size to 1GB */ 660 /* Limit stack size */
661 stack_base = rlimit_max(RLIMIT_STACK); 661 stack_base = rlimit_max(RLIMIT_STACK);
662 if (stack_base > (1 << 30)) 662 if (stack_base > STACK_SIZE_MAX)
663 stack_base = 1 << 30; 663 stack_base = STACK_SIZE_MAX;
664 664
665 /* Make sure we didn't let the argument array grow too large. */ 665 /* Make sure we didn't let the argument array grow too large. */
666 if (vma->vm_end - vma->vm_start > stack_base) 666 if (vma->vm_end - vma->vm_start > stack_base)
diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
index e01ea4a14a01..5e9a80cfc3d8 100644
--- a/fs/kernfs/file.c
+++ b/fs/kernfs/file.c
@@ -610,6 +610,7 @@ static void kernfs_put_open_node(struct kernfs_node *kn,
610static int kernfs_fop_open(struct inode *inode, struct file *file) 610static int kernfs_fop_open(struct inode *inode, struct file *file)
611{ 611{
612 struct kernfs_node *kn = file->f_path.dentry->d_fsdata; 612 struct kernfs_node *kn = file->f_path.dentry->d_fsdata;
613 struct kernfs_root *root = kernfs_root(kn);
613 const struct kernfs_ops *ops; 614 const struct kernfs_ops *ops;
614 struct kernfs_open_file *of; 615 struct kernfs_open_file *of;
615 bool has_read, has_write, has_mmap; 616 bool has_read, has_write, has_mmap;
@@ -624,14 +625,16 @@ static int kernfs_fop_open(struct inode *inode, struct file *file)
624 has_write = ops->write || ops->mmap; 625 has_write = ops->write || ops->mmap;
625 has_mmap = ops->mmap; 626 has_mmap = ops->mmap;
626 627
627 /* check perms and supported operations */ 628 /* see the flag definition for details */
628 if ((file->f_mode & FMODE_WRITE) && 629 if (root->flags & KERNFS_ROOT_EXTRA_OPEN_PERM_CHECK) {
629 (!(inode->i_mode & S_IWUGO) || !has_write)) 630 if ((file->f_mode & FMODE_WRITE) &&
630 goto err_out; 631 (!(inode->i_mode & S_IWUGO) || !has_write))
632 goto err_out;
631 633
632 if ((file->f_mode & FMODE_READ) && 634 if ((file->f_mode & FMODE_READ) &&
633 (!(inode->i_mode & S_IRUGO) || !has_read)) 635 (!(inode->i_mode & S_IRUGO) || !has_read))
634 goto err_out; 636 goto err_out;
637 }
635 638
636 /* allocate a kernfs_open_file for the file */ 639 /* allocate a kernfs_open_file for the file */
637 error = -ENOMEM; 640 error = -ENOMEM;
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 28cc1acd5439..e9ef59b3abb1 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -47,12 +47,13 @@ static int sysfs_kf_seq_show(struct seq_file *sf, void *v)
47 ssize_t count; 47 ssize_t count;
48 char *buf; 48 char *buf;
49 49
50 /* acquire buffer and ensure that it's >= PAGE_SIZE */ 50 /* acquire buffer and ensure that it's >= PAGE_SIZE and clear */
51 count = seq_get_buf(sf, &buf); 51 count = seq_get_buf(sf, &buf);
52 if (count < PAGE_SIZE) { 52 if (count < PAGE_SIZE) {
53 seq_commit(sf, -1); 53 seq_commit(sf, -1);
54 return 0; 54 return 0;
55 } 55 }
56 memset(buf, 0, PAGE_SIZE);
56 57
57 /* 58 /*
58 * Invoke show(). Control may reach here via seq file lseek even 59 * Invoke show(). Control may reach here via seq file lseek even
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index a66ad6196f59..8794423f7efb 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -63,7 +63,8 @@ int __init sysfs_init(void)
63{ 63{
64 int err; 64 int err;
65 65
66 sysfs_root = kernfs_create_root(NULL, 0, NULL); 66 sysfs_root = kernfs_create_root(NULL, KERNFS_ROOT_EXTRA_OPEN_PERM_CHECK,
67 NULL);
67 if (IS_ERR(sysfs_root)) 68 if (IS_ERR(sysfs_root))
68 return PTR_ERR(sysfs_root); 69 return PTR_ERR(sysfs_root);
69 70
diff --git a/fs/xfs/xfs_export.c b/fs/xfs/xfs_export.c
index 1399e187d425..753e467aa1a5 100644
--- a/fs/xfs/xfs_export.c
+++ b/fs/xfs/xfs_export.c
@@ -237,7 +237,7 @@ xfs_fs_nfs_commit_metadata(
237 237
238 if (!lsn) 238 if (!lsn)
239 return 0; 239 return 0;
240 return _xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, NULL); 240 return -_xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, NULL);
241} 241}
242 242
243const struct export_operations xfs_export_operations = { 243const struct export_operations xfs_export_operations = {
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 951a2321ee01..830c1c937b88 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -155,7 +155,7 @@ xfs_dir_fsync(
155 155
156 if (!lsn) 156 if (!lsn)
157 return 0; 157 return 0;
158 return _xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, NULL); 158 return -_xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, NULL);
159} 159}
160 160
161STATIC int 161STATIC int
@@ -295,7 +295,7 @@ xfs_file_aio_read(
295 xfs_rw_ilock(ip, XFS_IOLOCK_EXCL); 295 xfs_rw_ilock(ip, XFS_IOLOCK_EXCL);
296 296
297 if (inode->i_mapping->nrpages) { 297 if (inode->i_mapping->nrpages) {
298 ret = -filemap_write_and_wait_range( 298 ret = filemap_write_and_wait_range(
299 VFS_I(ip)->i_mapping, 299 VFS_I(ip)->i_mapping,
300 pos, -1); 300 pos, -1);
301 if (ret) { 301 if (ret) {
@@ -837,7 +837,7 @@ xfs_file_fallocate(
837 unsigned blksize_mask = (1 << inode->i_blkbits) - 1; 837 unsigned blksize_mask = (1 << inode->i_blkbits) - 1;
838 838
839 if (offset & blksize_mask || len & blksize_mask) { 839 if (offset & blksize_mask || len & blksize_mask) {
840 error = -EINVAL; 840 error = EINVAL;
841 goto out_unlock; 841 goto out_unlock;
842 } 842 }
843 843
@@ -846,7 +846,7 @@ xfs_file_fallocate(
846 * in which case it is effectively a truncate operation 846 * in which case it is effectively a truncate operation
847 */ 847 */
848 if (offset + len >= i_size_read(inode)) { 848 if (offset + len >= i_size_read(inode)) {
849 error = -EINVAL; 849 error = EINVAL;
850 goto out_unlock; 850 goto out_unlock;
851 } 851 }
852 852
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 301ecbfcc0be..36d630319a27 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -72,8 +72,8 @@ xfs_initxattrs(
72 int error = 0; 72 int error = 0;
73 73
74 for (xattr = xattr_array; xattr->name != NULL; xattr++) { 74 for (xattr = xattr_array; xattr->name != NULL; xattr++) {
75 error = xfs_attr_set(ip, xattr->name, xattr->value, 75 error = -xfs_attr_set(ip, xattr->name, xattr->value,
76 xattr->value_len, ATTR_SECURE); 76 xattr->value_len, ATTR_SECURE);
77 if (error < 0) 77 if (error < 0)
78 break; 78 break;
79 } 79 }
@@ -93,8 +93,8 @@ xfs_init_security(
93 struct inode *dir, 93 struct inode *dir,
94 const struct qstr *qstr) 94 const struct qstr *qstr)
95{ 95{
96 return security_inode_init_security(inode, dir, qstr, 96 return -security_inode_init_security(inode, dir, qstr,
97 &xfs_initxattrs, NULL); 97 &xfs_initxattrs, NULL);
98} 98}
99 99
100static void 100static void
@@ -173,12 +173,12 @@ xfs_generic_create(
173 173
174#ifdef CONFIG_XFS_POSIX_ACL 174#ifdef CONFIG_XFS_POSIX_ACL
175 if (default_acl) { 175 if (default_acl) {
176 error = xfs_set_acl(inode, default_acl, ACL_TYPE_DEFAULT); 176 error = -xfs_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
177 if (error) 177 if (error)
178 goto out_cleanup_inode; 178 goto out_cleanup_inode;
179 } 179 }
180 if (acl) { 180 if (acl) {
181 error = xfs_set_acl(inode, acl, ACL_TYPE_ACCESS); 181 error = -xfs_set_acl(inode, acl, ACL_TYPE_ACCESS);
182 if (error) 182 if (error)
183 goto out_cleanup_inode; 183 goto out_cleanup_inode;
184 } 184 }
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index 348e4d2ed6e6..dc977b6e6a36 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -843,22 +843,17 @@ xfs_qm_init_quotainfo(
843 843
844 qinf = mp->m_quotainfo = kmem_zalloc(sizeof(xfs_quotainfo_t), KM_SLEEP); 844 qinf = mp->m_quotainfo = kmem_zalloc(sizeof(xfs_quotainfo_t), KM_SLEEP);
845 845
846 if ((error = list_lru_init(&qinf->qi_lru))) { 846 error = -list_lru_init(&qinf->qi_lru);
847 kmem_free(qinf); 847 if (error)
848 mp->m_quotainfo = NULL; 848 goto out_free_qinf;
849 return error;
850 }
851 849
852 /* 850 /*
853 * See if quotainodes are setup, and if not, allocate them, 851 * See if quotainodes are setup, and if not, allocate them,
854 * and change the superblock accordingly. 852 * and change the superblock accordingly.
855 */ 853 */
856 if ((error = xfs_qm_init_quotainos(mp))) { 854 error = xfs_qm_init_quotainos(mp);
857 list_lru_destroy(&qinf->qi_lru); 855 if (error)
858 kmem_free(qinf); 856 goto out_free_lru;
859 mp->m_quotainfo = NULL;
860 return error;
861 }
862 857
863 INIT_RADIX_TREE(&qinf->qi_uquota_tree, GFP_NOFS); 858 INIT_RADIX_TREE(&qinf->qi_uquota_tree, GFP_NOFS);
864 INIT_RADIX_TREE(&qinf->qi_gquota_tree, GFP_NOFS); 859 INIT_RADIX_TREE(&qinf->qi_gquota_tree, GFP_NOFS);
@@ -918,7 +913,7 @@ xfs_qm_init_quotainfo(
918 qinf->qi_isoftlimit = be64_to_cpu(ddqp->d_ino_softlimit); 913 qinf->qi_isoftlimit = be64_to_cpu(ddqp->d_ino_softlimit);
919 qinf->qi_rtbhardlimit = be64_to_cpu(ddqp->d_rtb_hardlimit); 914 qinf->qi_rtbhardlimit = be64_to_cpu(ddqp->d_rtb_hardlimit);
920 qinf->qi_rtbsoftlimit = be64_to_cpu(ddqp->d_rtb_softlimit); 915 qinf->qi_rtbsoftlimit = be64_to_cpu(ddqp->d_rtb_softlimit);
921 916
922 xfs_qm_dqdestroy(dqp); 917 xfs_qm_dqdestroy(dqp);
923 } else { 918 } else {
924 qinf->qi_btimelimit = XFS_QM_BTIMELIMIT; 919 qinf->qi_btimelimit = XFS_QM_BTIMELIMIT;
@@ -935,6 +930,13 @@ xfs_qm_init_quotainfo(
935 qinf->qi_shrinker.flags = SHRINKER_NUMA_AWARE; 930 qinf->qi_shrinker.flags = SHRINKER_NUMA_AWARE;
936 register_shrinker(&qinf->qi_shrinker); 931 register_shrinker(&qinf->qi_shrinker);
937 return 0; 932 return 0;
933
934out_free_lru:
935 list_lru_destroy(&qinf->qi_lru);
936out_free_qinf:
937 kmem_free(qinf);
938 mp->m_quotainfo = NULL;
939 return error;
938} 940}
939 941
940 942
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 205376776377..3494eff8e4eb 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1433,11 +1433,11 @@ xfs_fs_fill_super(
1433 if (error) 1433 if (error)
1434 goto out_free_fsname; 1434 goto out_free_fsname;
1435 1435
1436 error = xfs_init_mount_workqueues(mp); 1436 error = -xfs_init_mount_workqueues(mp);
1437 if (error) 1437 if (error)
1438 goto out_close_devices; 1438 goto out_close_devices;
1439 1439
1440 error = xfs_icsb_init_counters(mp); 1440 error = -xfs_icsb_init_counters(mp);
1441 if (error) 1441 if (error)
1442 goto out_destroy_workqueues; 1442 goto out_destroy_workqueues;
1443 1443
diff --git a/include/asm-generic/resource.h b/include/asm-generic/resource.h
index b4ea8f50fc65..5e752b959054 100644
--- a/include/asm-generic/resource.h
+++ b/include/asm-generic/resource.h
@@ -12,7 +12,7 @@
12 [RLIMIT_CPU] = { RLIM_INFINITY, RLIM_INFINITY }, \ 12 [RLIMIT_CPU] = { RLIM_INFINITY, RLIM_INFINITY }, \
13 [RLIMIT_FSIZE] = { RLIM_INFINITY, RLIM_INFINITY }, \ 13 [RLIMIT_FSIZE] = { RLIM_INFINITY, RLIM_INFINITY }, \
14 [RLIMIT_DATA] = { RLIM_INFINITY, RLIM_INFINITY }, \ 14 [RLIMIT_DATA] = { RLIM_INFINITY, RLIM_INFINITY }, \
15 [RLIMIT_STACK] = { _STK_LIM, _STK_LIM_MAX }, \ 15 [RLIMIT_STACK] = { _STK_LIM, RLIM_INFINITY }, \
16 [RLIMIT_CORE] = { 0, RLIM_INFINITY }, \ 16 [RLIMIT_CORE] = { 0, RLIM_INFINITY }, \
17 [RLIMIT_RSS] = { RLIM_INFINITY, RLIM_INFINITY }, \ 17 [RLIMIT_RSS] = { RLIM_INFINITY, RLIM_INFINITY }, \
18 [RLIMIT_NPROC] = { 0, 0 }, \ 18 [RLIMIT_NPROC] = { 0, 0 }, \
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index c2515851c1aa..d60904b9e505 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -473,6 +473,7 @@ struct cftype {
473}; 473};
474 474
475extern struct cgroup_root cgrp_dfl_root; 475extern struct cgroup_root cgrp_dfl_root;
476extern struct css_set init_css_set;
476 477
477static inline bool cgroup_on_dfl(const struct cgroup *cgrp) 478static inline bool cgroup_on_dfl(const struct cgroup *cgrp)
478{ 479{
@@ -700,6 +701,20 @@ static inline struct cgroup_subsys_state *task_css(struct task_struct *task,
700 return task_css_check(task, subsys_id, false); 701 return task_css_check(task, subsys_id, false);
701} 702}
702 703
704/**
705 * task_css_is_root - test whether a task belongs to the root css
706 * @task: the target task
707 * @subsys_id: the target subsystem ID
708 *
709 * Test whether @task belongs to the root css on the specified subsystem.
710 * May be invoked in any context.
711 */
712static inline bool task_css_is_root(struct task_struct *task, int subsys_id)
713{
714 return task_css_check(task, subsys_id, true) ==
715 init_css_set.subsys[subsys_id];
716}
717
703static inline struct cgroup *task_cgroup(struct task_struct *task, 718static inline struct cgroup *task_cgroup(struct task_struct *task,
704 int subsys_id) 719 int subsys_id)
705{ 720{
diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h
index b0122dc6f96a..ca1be5c9136c 100644
--- a/include/linux/kernfs.h
+++ b/include/linux/kernfs.h
@@ -50,7 +50,24 @@ enum kernfs_node_flag {
50 50
51/* @flags for kernfs_create_root() */ 51/* @flags for kernfs_create_root() */
52enum kernfs_root_flag { 52enum kernfs_root_flag {
53 KERNFS_ROOT_CREATE_DEACTIVATED = 0x0001, 53 /*
54 * kernfs_nodes are created in the deactivated state and invisible.
55 * They require explicit kernfs_activate() to become visible. This
56 * can be used to make related nodes become visible atomically
57 * after all nodes are created successfully.
58 */
59 KERNFS_ROOT_CREATE_DEACTIVATED = 0x0001,
60
61 /*
62 * For regular flies, if the opener has CAP_DAC_OVERRIDE, open(2)
63 * succeeds regardless of the RW permissions. sysfs had an extra
64 * layer of enforcement where open(2) fails with -EACCES regardless
65 * of CAP_DAC_OVERRIDE if the permission doesn't have the
66 * respective read or write access at all (none of S_IRUGO or
67 * S_IWUGO) or the respective operation isn't implemented. The
68 * following flag enables that behavior.
69 */
70 KERNFS_ROOT_EXTRA_OPEN_PERM_CHECK = 0x0002,
54}; 71};
55 72
56/* type-specific structures for kernfs_node union members */ 73/* type-specific structures for kernfs_node union members */
diff --git a/include/linux/of.h b/include/linux/of.h
index 3bad8d106e0e..e6f0988c1c68 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -349,7 +349,7 @@ int of_device_is_stdout_path(struct device_node *dn);
349 349
350#else /* CONFIG_OF */ 350#else /* CONFIG_OF */
351 351
352static inline const char* of_node_full_name(struct device_node *np) 352static inline const char* of_node_full_name(const struct device_node *np)
353{ 353{
354 return "<no-node>"; 354 return "<no-node>";
355} 355}
diff --git a/include/uapi/asm-generic/resource.h b/include/uapi/asm-generic/resource.h
index f863428796d5..c6d10af50123 100644
--- a/include/uapi/asm-generic/resource.h
+++ b/include/uapi/asm-generic/resource.h
@@ -57,12 +57,5 @@
57# define RLIM_INFINITY (~0UL) 57# define RLIM_INFINITY (~0UL)
58#endif 58#endif
59 59
60/*
61 * RLIMIT_STACK default maximum - some architectures override it:
62 */
63#ifndef _STK_LIM_MAX
64# define _STK_LIM_MAX RLIM_INFINITY
65#endif
66
67 60
68#endif /* _UAPI_ASM_GENERIC_RESOURCE_H */ 61#endif /* _UAPI_ASM_GENERIC_RESOURCE_H */
diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h
index 6db66783d268..333640608087 100644
--- a/include/uapi/asm-generic/unistd.h
+++ b/include/uapi/asm-generic/unistd.h
@@ -697,9 +697,11 @@ __SYSCALL(__NR_finit_module, sys_finit_module)
697__SYSCALL(__NR_sched_setattr, sys_sched_setattr) 697__SYSCALL(__NR_sched_setattr, sys_sched_setattr)
698#define __NR_sched_getattr 275 698#define __NR_sched_getattr 275
699__SYSCALL(__NR_sched_getattr, sys_sched_getattr) 699__SYSCALL(__NR_sched_getattr, sys_sched_getattr)
700#define __NR_renameat2 276
701__SYSCALL(__NR_renameat2, sys_renameat2)
700 702
701#undef __NR_syscalls 703#undef __NR_syscalls
702#define __NR_syscalls 276 704#define __NR_syscalls 277
703 705
704/* 706/*
705 * All syscalls below here should go away really, 707 * All syscalls below here should go away really,
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index 11917f747cb4..1b1efddb91cd 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -331,9 +331,17 @@ enum {
331#define AUDIT_FAIL_PRINTK 1 331#define AUDIT_FAIL_PRINTK 1
332#define AUDIT_FAIL_PANIC 2 332#define AUDIT_FAIL_PANIC 2
333 333
334/*
335 * These bits disambiguate different calling conventions that share an
336 * ELF machine type, bitness, and endianness
337 */
338#define __AUDIT_ARCH_CONVENTION_MASK 0x30000000
339#define __AUDIT_ARCH_CONVENTION_MIPS64_N32 0x20000000
340
334/* distinguish syscall tables */ 341/* distinguish syscall tables */
335#define __AUDIT_ARCH_64BIT 0x80000000 342#define __AUDIT_ARCH_64BIT 0x80000000
336#define __AUDIT_ARCH_LE 0x40000000 343#define __AUDIT_ARCH_LE 0x40000000
344
337#define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) 345#define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
338#define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE) 346#define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE)
339#define AUDIT_ARCH_ARMEB (EM_ARM) 347#define AUDIT_ARCH_ARMEB (EM_ARM)
@@ -346,7 +354,11 @@ enum {
346#define AUDIT_ARCH_MIPS (EM_MIPS) 354#define AUDIT_ARCH_MIPS (EM_MIPS)
347#define AUDIT_ARCH_MIPSEL (EM_MIPS|__AUDIT_ARCH_LE) 355#define AUDIT_ARCH_MIPSEL (EM_MIPS|__AUDIT_ARCH_LE)
348#define AUDIT_ARCH_MIPS64 (EM_MIPS|__AUDIT_ARCH_64BIT) 356#define AUDIT_ARCH_MIPS64 (EM_MIPS|__AUDIT_ARCH_64BIT)
357#define AUDIT_ARCH_MIPS64N32 (EM_MIPS|__AUDIT_ARCH_64BIT|\
358 __AUDIT_ARCH_CONVENTION_MIPS64_N32)
349#define AUDIT_ARCH_MIPSEL64 (EM_MIPS|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) 359#define AUDIT_ARCH_MIPSEL64 (EM_MIPS|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
360#define AUDIT_ARCH_MIPSEL64N32 (EM_MIPS|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE\
361 __AUDIT_ARCH_CONVENTION_MIPS64_N32)
350#define AUDIT_ARCH_OPENRISC (EM_OPENRISC) 362#define AUDIT_ARCH_OPENRISC (EM_OPENRISC)
351#define AUDIT_ARCH_PARISC (EM_PARISC) 363#define AUDIT_ARCH_PARISC (EM_PARISC)
352#define AUDIT_ARCH_PARISC64 (EM_PARISC|__AUDIT_ARCH_64BIT) 364#define AUDIT_ARCH_PARISC64 (EM_PARISC|__AUDIT_ARCH_64BIT)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 11a03d67635a..3f1ca934a237 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -348,7 +348,7 @@ struct cgrp_cset_link {
348 * reference-counted, to improve performance when child cgroups 348 * reference-counted, to improve performance when child cgroups
349 * haven't been created. 349 * haven't been created.
350 */ 350 */
351static struct css_set init_css_set = { 351struct css_set init_css_set = {
352 .refcount = ATOMIC_INIT(1), 352 .refcount = ATOMIC_INIT(1),
353 .cgrp_links = LIST_HEAD_INIT(init_css_set.cgrp_links), 353 .cgrp_links = LIST_HEAD_INIT(init_css_set.cgrp_links),
354 .tasks = LIST_HEAD_INIT(init_css_set.tasks), 354 .tasks = LIST_HEAD_INIT(init_css_set.tasks),
diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c
index 2bc4a2256444..345628c78b5b 100644
--- a/kernel/cgroup_freezer.c
+++ b/kernel/cgroup_freezer.c
@@ -21,6 +21,7 @@
21#include <linux/uaccess.h> 21#include <linux/uaccess.h>
22#include <linux/freezer.h> 22#include <linux/freezer.h>
23#include <linux/seq_file.h> 23#include <linux/seq_file.h>
24#include <linux/mutex.h>
24 25
25/* 26/*
26 * A cgroup is freezing if any FREEZING flags are set. FREEZING_SELF is 27 * A cgroup is freezing if any FREEZING flags are set. FREEZING_SELF is
@@ -42,9 +43,10 @@ enum freezer_state_flags {
42struct freezer { 43struct freezer {
43 struct cgroup_subsys_state css; 44 struct cgroup_subsys_state css;
44 unsigned int state; 45 unsigned int state;
45 spinlock_t lock;
46}; 46};
47 47
48static DEFINE_MUTEX(freezer_mutex);
49
48static inline struct freezer *css_freezer(struct cgroup_subsys_state *css) 50static inline struct freezer *css_freezer(struct cgroup_subsys_state *css)
49{ 51{
50 return css ? container_of(css, struct freezer, css) : NULL; 52 return css ? container_of(css, struct freezer, css) : NULL;
@@ -93,7 +95,6 @@ freezer_css_alloc(struct cgroup_subsys_state *parent_css)
93 if (!freezer) 95 if (!freezer)
94 return ERR_PTR(-ENOMEM); 96 return ERR_PTR(-ENOMEM);
95 97
96 spin_lock_init(&freezer->lock);
97 return &freezer->css; 98 return &freezer->css;
98} 99}
99 100
@@ -110,14 +111,7 @@ static int freezer_css_online(struct cgroup_subsys_state *css)
110 struct freezer *freezer = css_freezer(css); 111 struct freezer *freezer = css_freezer(css);
111 struct freezer *parent = parent_freezer(freezer); 112 struct freezer *parent = parent_freezer(freezer);
112 113
113 /* 114 mutex_lock(&freezer_mutex);
114 * The following double locking and freezing state inheritance
115 * guarantee that @cgroup can never escape ancestors' freezing
116 * states. See css_for_each_descendant_pre() for details.
117 */
118 if (parent)
119 spin_lock_irq(&parent->lock);
120 spin_lock_nested(&freezer->lock, SINGLE_DEPTH_NESTING);
121 115
122 freezer->state |= CGROUP_FREEZER_ONLINE; 116 freezer->state |= CGROUP_FREEZER_ONLINE;
123 117
@@ -126,10 +120,7 @@ static int freezer_css_online(struct cgroup_subsys_state *css)
126 atomic_inc(&system_freezing_cnt); 120 atomic_inc(&system_freezing_cnt);
127 } 121 }
128 122
129 spin_unlock(&freezer->lock); 123 mutex_unlock(&freezer_mutex);
130 if (parent)
131 spin_unlock_irq(&parent->lock);
132
133 return 0; 124 return 0;
134} 125}
135 126
@@ -144,14 +135,14 @@ static void freezer_css_offline(struct cgroup_subsys_state *css)
144{ 135{
145 struct freezer *freezer = css_freezer(css); 136 struct freezer *freezer = css_freezer(css);
146 137
147 spin_lock_irq(&freezer->lock); 138 mutex_lock(&freezer_mutex);
148 139
149 if (freezer->state & CGROUP_FREEZING) 140 if (freezer->state & CGROUP_FREEZING)
150 atomic_dec(&system_freezing_cnt); 141 atomic_dec(&system_freezing_cnt);
151 142
152 freezer->state = 0; 143 freezer->state = 0;
153 144
154 spin_unlock_irq(&freezer->lock); 145 mutex_unlock(&freezer_mutex);
155} 146}
156 147
157static void freezer_css_free(struct cgroup_subsys_state *css) 148static void freezer_css_free(struct cgroup_subsys_state *css)
@@ -175,7 +166,7 @@ static void freezer_attach(struct cgroup_subsys_state *new_css,
175 struct task_struct *task; 166 struct task_struct *task;
176 bool clear_frozen = false; 167 bool clear_frozen = false;
177 168
178 spin_lock_irq(&freezer->lock); 169 mutex_lock(&freezer_mutex);
179 170
180 /* 171 /*
181 * Make the new tasks conform to the current state of @new_css. 172 * Make the new tasks conform to the current state of @new_css.
@@ -197,21 +188,13 @@ static void freezer_attach(struct cgroup_subsys_state *new_css,
197 } 188 }
198 } 189 }
199 190
200 spin_unlock_irq(&freezer->lock); 191 /* propagate FROZEN clearing upwards */
201
202 /*
203 * Propagate FROZEN clearing upwards. We may race with
204 * update_if_frozen(), but as long as both work bottom-up, either
205 * update_if_frozen() sees child's FROZEN cleared or we clear the
206 * parent's FROZEN later. No parent w/ !FROZEN children can be
207 * left FROZEN.
208 */
209 while (clear_frozen && (freezer = parent_freezer(freezer))) { 192 while (clear_frozen && (freezer = parent_freezer(freezer))) {
210 spin_lock_irq(&freezer->lock);
211 freezer->state &= ~CGROUP_FROZEN; 193 freezer->state &= ~CGROUP_FROZEN;
212 clear_frozen = freezer->state & CGROUP_FREEZING; 194 clear_frozen = freezer->state & CGROUP_FREEZING;
213 spin_unlock_irq(&freezer->lock);
214 } 195 }
196
197 mutex_unlock(&freezer_mutex);
215} 198}
216 199
217/** 200/**
@@ -228,9 +211,6 @@ static void freezer_fork(struct task_struct *task)
228{ 211{
229 struct freezer *freezer; 212 struct freezer *freezer;
230 213
231 rcu_read_lock();
232 freezer = task_freezer(task);
233
234 /* 214 /*
235 * The root cgroup is non-freezable, so we can skip locking the 215 * The root cgroup is non-freezable, so we can skip locking the
236 * freezer. This is safe regardless of race with task migration. 216 * freezer. This is safe regardless of race with task migration.
@@ -238,24 +218,18 @@ static void freezer_fork(struct task_struct *task)
238 * to do. If we lost and root is the new cgroup, noop is still the 218 * to do. If we lost and root is the new cgroup, noop is still the
239 * right thing to do. 219 * right thing to do.
240 */ 220 */
241 if (!parent_freezer(freezer)) 221 if (task_css_is_root(task, freezer_cgrp_id))
242 goto out; 222 return;
243 223
244 /* 224 mutex_lock(&freezer_mutex);
245 * Grab @freezer->lock and freeze @task after verifying @task still 225 rcu_read_lock();
246 * belongs to @freezer and it's freezing. The former is for the 226
247 * case where we have raced against task migration and lost and 227 freezer = task_freezer(task);
248 * @task is already in a different cgroup which may not be frozen. 228 if (freezer->state & CGROUP_FREEZING)
249 * This isn't strictly necessary as freeze_task() is allowed to be
250 * called spuriously but let's do it anyway for, if nothing else,
251 * documentation.
252 */
253 spin_lock_irq(&freezer->lock);
254 if (freezer == task_freezer(task) && (freezer->state & CGROUP_FREEZING))
255 freeze_task(task); 229 freeze_task(task);
256 spin_unlock_irq(&freezer->lock); 230
257out:
258 rcu_read_unlock(); 231 rcu_read_unlock();
232 mutex_unlock(&freezer_mutex);
259} 233}
260 234
261/** 235/**
@@ -281,22 +255,24 @@ static void update_if_frozen(struct cgroup_subsys_state *css)
281 struct css_task_iter it; 255 struct css_task_iter it;
282 struct task_struct *task; 256 struct task_struct *task;
283 257
284 WARN_ON_ONCE(!rcu_read_lock_held()); 258 lockdep_assert_held(&freezer_mutex);
285
286 spin_lock_irq(&freezer->lock);
287 259
288 if (!(freezer->state & CGROUP_FREEZING) || 260 if (!(freezer->state & CGROUP_FREEZING) ||
289 (freezer->state & CGROUP_FROZEN)) 261 (freezer->state & CGROUP_FROZEN))
290 goto out_unlock; 262 return;
291 263
292 /* are all (live) children frozen? */ 264 /* are all (live) children frozen? */
265 rcu_read_lock();
293 css_for_each_child(pos, css) { 266 css_for_each_child(pos, css) {
294 struct freezer *child = css_freezer(pos); 267 struct freezer *child = css_freezer(pos);
295 268
296 if ((child->state & CGROUP_FREEZER_ONLINE) && 269 if ((child->state & CGROUP_FREEZER_ONLINE) &&
297 !(child->state & CGROUP_FROZEN)) 270 !(child->state & CGROUP_FROZEN)) {
298 goto out_unlock; 271 rcu_read_unlock();
272 return;
273 }
299 } 274 }
275 rcu_read_unlock();
300 276
301 /* are all tasks frozen? */ 277 /* are all tasks frozen? */
302 css_task_iter_start(css, &it); 278 css_task_iter_start(css, &it);
@@ -317,21 +293,29 @@ static void update_if_frozen(struct cgroup_subsys_state *css)
317 freezer->state |= CGROUP_FROZEN; 293 freezer->state |= CGROUP_FROZEN;
318out_iter_end: 294out_iter_end:
319 css_task_iter_end(&it); 295 css_task_iter_end(&it);
320out_unlock:
321 spin_unlock_irq(&freezer->lock);
322} 296}
323 297
324static int freezer_read(struct seq_file *m, void *v) 298static int freezer_read(struct seq_file *m, void *v)
325{ 299{
326 struct cgroup_subsys_state *css = seq_css(m), *pos; 300 struct cgroup_subsys_state *css = seq_css(m), *pos;
327 301
302 mutex_lock(&freezer_mutex);
328 rcu_read_lock(); 303 rcu_read_lock();
329 304
330 /* update states bottom-up */ 305 /* update states bottom-up */
331 css_for_each_descendant_post(pos, css) 306 css_for_each_descendant_post(pos, css) {
307 if (!css_tryget(pos))
308 continue;
309 rcu_read_unlock();
310
332 update_if_frozen(pos); 311 update_if_frozen(pos);
333 312
313 rcu_read_lock();
314 css_put(pos);
315 }
316
334 rcu_read_unlock(); 317 rcu_read_unlock();
318 mutex_unlock(&freezer_mutex);
335 319
336 seq_puts(m, freezer_state_strs(css_freezer(css)->state)); 320 seq_puts(m, freezer_state_strs(css_freezer(css)->state));
337 seq_putc(m, '\n'); 321 seq_putc(m, '\n');
@@ -373,7 +357,7 @@ static void freezer_apply_state(struct freezer *freezer, bool freeze,
373 unsigned int state) 357 unsigned int state)
374{ 358{
375 /* also synchronizes against task migration, see freezer_attach() */ 359 /* also synchronizes against task migration, see freezer_attach() */
376 lockdep_assert_held(&freezer->lock); 360 lockdep_assert_held(&freezer_mutex);
377 361
378 if (!(freezer->state & CGROUP_FREEZER_ONLINE)) 362 if (!(freezer->state & CGROUP_FREEZER_ONLINE))
379 return; 363 return;
@@ -414,31 +398,29 @@ static void freezer_change_state(struct freezer *freezer, bool freeze)
414 * descendant will try to inherit its parent's FREEZING state as 398 * descendant will try to inherit its parent's FREEZING state as
415 * CGROUP_FREEZING_PARENT. 399 * CGROUP_FREEZING_PARENT.
416 */ 400 */
401 mutex_lock(&freezer_mutex);
417 rcu_read_lock(); 402 rcu_read_lock();
418 css_for_each_descendant_pre(pos, &freezer->css) { 403 css_for_each_descendant_pre(pos, &freezer->css) {
419 struct freezer *pos_f = css_freezer(pos); 404 struct freezer *pos_f = css_freezer(pos);
420 struct freezer *parent = parent_freezer(pos_f); 405 struct freezer *parent = parent_freezer(pos_f);
421 406
422 spin_lock_irq(&pos_f->lock); 407 if (!css_tryget(pos))
408 continue;
409 rcu_read_unlock();
423 410
424 if (pos_f == freezer) { 411 if (pos_f == freezer)
425 freezer_apply_state(pos_f, freeze, 412 freezer_apply_state(pos_f, freeze,
426 CGROUP_FREEZING_SELF); 413 CGROUP_FREEZING_SELF);
427 } else { 414 else
428 /*
429 * Our update to @parent->state is already visible
430 * which is all we need. No need to lock @parent.
431 * For more info on synchronization, see
432 * freezer_post_create().
433 */
434 freezer_apply_state(pos_f, 415 freezer_apply_state(pos_f,
435 parent->state & CGROUP_FREEZING, 416 parent->state & CGROUP_FREEZING,
436 CGROUP_FREEZING_PARENT); 417 CGROUP_FREEZING_PARENT);
437 }
438 418
439 spin_unlock_irq(&pos_f->lock); 419 rcu_read_lock();
420 css_put(pos);
440 } 421 }
441 rcu_read_unlock(); 422 rcu_read_unlock();
423 mutex_unlock(&freezer_mutex);
442} 424}
443 425
444static int freezer_write(struct cgroup_subsys_state *css, struct cftype *cft, 426static int freezer_write(struct cgroup_subsys_state *css, struct cftype *cft,
diff --git a/mm/Kconfig b/mm/Kconfig
index ebe5880c29d6..1b5a95f0fa01 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -581,3 +581,18 @@ config PGTABLE_MAPPING
581 581
582config GENERIC_EARLY_IOREMAP 582config GENERIC_EARLY_IOREMAP
583 bool 583 bool
584
585config MAX_STACK_SIZE_MB
586 int "Maximum user stack size for 32-bit processes (MB)"
587 default 80
588 range 8 256 if METAG
589 range 8 2048
590 depends on STACK_GROWSUP && (!64BIT || COMPAT)
591 help
592 This is the maximum stack size in Megabytes in the VM layout of 32-bit
593 user processes when the stack grows upwards (currently only on parisc
594 and metag arch). The stack will be located at the highest memory
595 address minus the given value, unless the RLIMIT_STACK hard limit is
596 changed to a smaller value in which case that is used.
597
598 A sane initial value is 80 MB.
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index dac7f9b98687..1948d592aa54 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -557,7 +557,7 @@ static int ceph_tcp_sendmsg(struct socket *sock, struct kvec *iov,
557 return r; 557 return r;
558} 558}
559 559
560static int ceph_tcp_sendpage(struct socket *sock, struct page *page, 560static int __ceph_tcp_sendpage(struct socket *sock, struct page *page,
561 int offset, size_t size, bool more) 561 int offset, size_t size, bool more)
562{ 562{
563 int flags = MSG_DONTWAIT | MSG_NOSIGNAL | (more ? MSG_MORE : MSG_EOR); 563 int flags = MSG_DONTWAIT | MSG_NOSIGNAL | (more ? MSG_MORE : MSG_EOR);
@@ -570,6 +570,24 @@ static int ceph_tcp_sendpage(struct socket *sock, struct page *page,
570 return ret; 570 return ret;
571} 571}
572 572
573static int ceph_tcp_sendpage(struct socket *sock, struct page *page,
574 int offset, size_t size, bool more)
575{
576 int ret;
577 struct kvec iov;
578
579 /* sendpage cannot properly handle pages with page_count == 0,
580 * we need to fallback to sendmsg if that's the case */
581 if (page_count(page) >= 1)
582 return __ceph_tcp_sendpage(sock, page, offset, size, more);
583
584 iov.iov_base = kmap(page) + offset;
585 iov.iov_len = size;
586 ret = ceph_tcp_sendmsg(sock, &iov, 1, size, more);
587 kunmap(page);
588
589 return ret;
590}
573 591
574/* 592/*
575 * Shutdown/close the socket for the given connection. 593 * Shutdown/close the socket for the given connection.
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
index 8b8a5a24b223..c547e46084d3 100644
--- a/net/ceph/osdmap.c
+++ b/net/ceph/osdmap.c
@@ -329,6 +329,11 @@ static struct crush_map *crush_decode(void *pbyval, void *end)
329 dout("crush decode tunable chooseleaf_descend_once = %d", 329 dout("crush decode tunable chooseleaf_descend_once = %d",
330 c->chooseleaf_descend_once); 330 c->chooseleaf_descend_once);
331 331
332 ceph_decode_need(p, end, sizeof(u8), done);
333 c->chooseleaf_vary_r = ceph_decode_8(p);
334 dout("crush decode tunable chooseleaf_vary_r = %d",
335 c->chooseleaf_vary_r);
336
332done: 337done:
333 dout("crush_decode success\n"); 338 dout("crush_decode success\n");
334 return c; 339 return c;
diff --git a/scripts/checksyscalls.sh b/scripts/checksyscalls.sh
index fd8fa9aa7c4e..5b3add31f9f1 100755
--- a/scripts/checksyscalls.sh
+++ b/scripts/checksyscalls.sh
@@ -25,7 +25,7 @@ cat << EOF
25#define __IGNORE_rmdir /* unlinkat */ 25#define __IGNORE_rmdir /* unlinkat */
26#define __IGNORE_lchown /* fchownat */ 26#define __IGNORE_lchown /* fchownat */
27#define __IGNORE_access /* faccessat */ 27#define __IGNORE_access /* faccessat */
28#define __IGNORE_rename /* renameat */ 28#define __IGNORE_rename /* renameat2 */
29#define __IGNORE_readlink /* readlinkat */ 29#define __IGNORE_readlink /* readlinkat */
30#define __IGNORE_symlink /* symlinkat */ 30#define __IGNORE_symlink /* symlinkat */
31#define __IGNORE_utimes /* futimesat */ 31#define __IGNORE_utimes /* futimesat */
@@ -37,6 +37,9 @@ cat << EOF
37#define __IGNORE_lstat64 /* fstatat64 */ 37#define __IGNORE_lstat64 /* fstatat64 */
38#endif 38#endif
39 39
40/* Missing flags argument */
41#define __IGNORE_renameat /* renameat2 */
42
40/* CLOEXEC flag */ 43/* CLOEXEC flag */
41#define __IGNORE_pipe /* pipe2 */ 44#define __IGNORE_pipe /* pipe2 */
42#define __IGNORE_dup2 /* dup3 */ 45#define __IGNORE_dup2 /* dup3 */
diff --git a/sound/isa/sb/sb_mixer.c b/sound/isa/sb/sb_mixer.c
index 6496822c1808..1ff78ec9f0ac 100644
--- a/sound/isa/sb/sb_mixer.c
+++ b/sound/isa/sb/sb_mixer.c
@@ -818,12 +818,14 @@ int snd_sbmixer_new(struct snd_sb *chip)
818 return err; 818 return err;
819 break; 819 break;
820 case SB_HW_DT019X: 820 case SB_HW_DT019X:
821 if ((err = snd_sbmixer_init(chip, 821 err = snd_sbmixer_init(chip,
822 snd_dt019x_controls, 822 snd_dt019x_controls,
823 ARRAY_SIZE(snd_dt019x_controls), 823 ARRAY_SIZE(snd_dt019x_controls),
824 snd_dt019x_init_values, 824 snd_dt019x_init_values,
825 ARRAY_SIZE(snd_dt019x_init_values), 825 ARRAY_SIZE(snd_dt019x_init_values),
826 "DT019X")) < 0) 826 "DT019X");
827 if (err < 0)
828 return err;
827 break; 829 break;
828 default: 830 default:
829 strcpy(card->mixername, "???"); 831 strcpy(card->mixername, "???");
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index b540ad71eb0d..2c54629d62d1 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1367,6 +1367,12 @@ static int azx_first_init(struct azx *chip)
1367 /* initialize streams */ 1367 /* initialize streams */
1368 azx_init_stream(chip); 1368 azx_init_stream(chip);
1369 1369
1370 /* workaround for Broadwell HDMI: the first stream is broken,
1371 * so mask it by keeping it as if opened
1372 */
1373 if (pci->vendor == 0x8086 && pci->device == 0x160c)
1374 chip->azx_dev[0].opened = 1;
1375
1370 /* initialize chip */ 1376 /* initialize chip */
1371 azx_init_pci(chip); 1377 azx_init_pci(chip);
1372 azx_init_chip(chip, (probe_only[dev] & 2) == 0); 1378 azx_init_chip(chip, (probe_only[dev] & 2) == 0);
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 1edbb9c47c2d..b4218a19df22 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -3332,6 +3332,7 @@ static const struct hda_codec_preset snd_hda_preset_hdmi[] = {
3332{ .id = 0x10de0051, .name = "GPU 51 HDMI/DP", .patch = patch_nvhdmi }, 3332{ .id = 0x10de0051, .name = "GPU 51 HDMI/DP", .patch = patch_nvhdmi },
3333{ .id = 0x10de0060, .name = "GPU 60 HDMI/DP", .patch = patch_nvhdmi }, 3333{ .id = 0x10de0060, .name = "GPU 60 HDMI/DP", .patch = patch_nvhdmi },
3334{ .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, 3334{ .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch },
3335{ .id = 0x10de0071, .name = "GPU 71 HDMI/DP", .patch = patch_nvhdmi },
3335{ .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch }, 3336{ .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch },
3336{ .id = 0x11069f80, .name = "VX900 HDMI/DP", .patch = patch_via_hdmi }, 3337{ .id = 0x11069f80, .name = "VX900 HDMI/DP", .patch = patch_via_hdmi },
3337{ .id = 0x11069f81, .name = "VX900 HDMI/DP", .patch = patch_via_hdmi }, 3338{ .id = 0x11069f81, .name = "VX900 HDMI/DP", .patch = patch_via_hdmi },
@@ -3387,6 +3388,7 @@ MODULE_ALIAS("snd-hda-codec-id:10de0044");
3387MODULE_ALIAS("snd-hda-codec-id:10de0051"); 3388MODULE_ALIAS("snd-hda-codec-id:10de0051");
3388MODULE_ALIAS("snd-hda-codec-id:10de0060"); 3389MODULE_ALIAS("snd-hda-codec-id:10de0060");
3389MODULE_ALIAS("snd-hda-codec-id:10de0067"); 3390MODULE_ALIAS("snd-hda-codec-id:10de0067");
3391MODULE_ALIAS("snd-hda-codec-id:10de0071");
3390MODULE_ALIAS("snd-hda-codec-id:10de8001"); 3392MODULE_ALIAS("snd-hda-codec-id:10de8001");
3391MODULE_ALIAS("snd-hda-codec-id:11069f80"); 3393MODULE_ALIAS("snd-hda-codec-id:11069f80");
3392MODULE_ALIAS("snd-hda-codec-id:11069f81"); 3394MODULE_ALIAS("snd-hda-codec-id:11069f81");
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 5f7c765391f1..49e884fb3e5d 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -4616,6 +4616,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4616 SND_PCI_QUIRK(0x1028, 0x0653, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), 4616 SND_PCI_QUIRK(0x1028, 0x0653, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4617 SND_PCI_QUIRK(0x1028, 0x0657, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), 4617 SND_PCI_QUIRK(0x1028, 0x0657, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4618 SND_PCI_QUIRK(0x1028, 0x0658, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4618 SND_PCI_QUIRK(0x1028, 0x0658, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4619 SND_PCI_QUIRK(0x1028, 0x065c, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4619 SND_PCI_QUIRK(0x1028, 0x065f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), 4620 SND_PCI_QUIRK(0x1028, 0x065f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4620 SND_PCI_QUIRK(0x1028, 0x0662, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), 4621 SND_PCI_QUIRK(0x1028, 0x0662, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4621 SND_PCI_QUIRK(0x1028, 0x0667, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4622 SND_PCI_QUIRK(0x1028, 0x0667, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
@@ -4624,6 +4625,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4624 SND_PCI_QUIRK(0x1028, 0x0674, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), 4625 SND_PCI_QUIRK(0x1028, 0x0674, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4625 SND_PCI_QUIRK(0x1028, 0x067e, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), 4626 SND_PCI_QUIRK(0x1028, 0x067e, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4626 SND_PCI_QUIRK(0x1028, 0x067f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), 4627 SND_PCI_QUIRK(0x1028, 0x067f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4628 SND_PCI_QUIRK(0x1028, 0x0680, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4629 SND_PCI_QUIRK(0x1028, 0x0684, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
4627 SND_PCI_QUIRK(0x1028, 0x15cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 4630 SND_PCI_QUIRK(0x1028, 0x15cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
4628 SND_PCI_QUIRK(0x1028, 0x15cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 4631 SND_PCI_QUIRK(0x1028, 0x15cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
4629 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2), 4632 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
diff --git a/sound/soc/codecs/tlv320aic31xx.c b/sound/soc/codecs/tlv320aic31xx.c
index fa158cfe9b32..d1929de641e2 100644
--- a/sound/soc/codecs/tlv320aic31xx.c
+++ b/sound/soc/codecs/tlv320aic31xx.c
@@ -376,7 +376,7 @@ static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w,
376 reg = AIC31XX_ADCFLAG; 376 reg = AIC31XX_ADCFLAG;
377 break; 377 break;
378 default: 378 default:
379 dev_err(w->codec->dev, "Unknown widget '%s' calling %s/n", 379 dev_err(w->codec->dev, "Unknown widget '%s' calling %s\n",
380 w->name, __func__); 380 w->name, __func__);
381 return -EINVAL; 381 return -EINVAL;
382 } 382 }
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index 5522d2566c67..ecd26dd2e442 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -154,6 +154,7 @@ static struct reg_default wm8962_reg[] = {
154 { 40, 0x0000 }, /* R40 - SPKOUTL volume */ 154 { 40, 0x0000 }, /* R40 - SPKOUTL volume */
155 { 41, 0x0000 }, /* R41 - SPKOUTR volume */ 155 { 41, 0x0000 }, /* R41 - SPKOUTR volume */
156 156
157 { 49, 0x0010 }, /* R49 - Class D Control 1 */
157 { 51, 0x0003 }, /* R51 - Class D Control 2 */ 158 { 51, 0x0003 }, /* R51 - Class D Control 2 */
158 159
159 { 56, 0x0506 }, /* R56 - Clocking 4 */ 160 { 56, 0x0506 }, /* R56 - Clocking 4 */
@@ -795,7 +796,6 @@ static bool wm8962_volatile_register(struct device *dev, unsigned int reg)
795 case WM8962_ALC2: 796 case WM8962_ALC2:
796 case WM8962_THERMAL_SHUTDOWN_STATUS: 797 case WM8962_THERMAL_SHUTDOWN_STATUS:
797 case WM8962_ADDITIONAL_CONTROL_4: 798 case WM8962_ADDITIONAL_CONTROL_4:
798 case WM8962_CLASS_D_CONTROL_1:
799 case WM8962_DC_SERVO_6: 799 case WM8962_DC_SERVO_6:
800 case WM8962_INTERRUPT_STATUS_1: 800 case WM8962_INTERRUPT_STATUS_1:
801 case WM8962_INTERRUPT_STATUS_2: 801 case WM8962_INTERRUPT_STATUS_2:
@@ -2929,13 +2929,22 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
2929static int wm8962_mute(struct snd_soc_dai *dai, int mute) 2929static int wm8962_mute(struct snd_soc_dai *dai, int mute)
2930{ 2930{
2931 struct snd_soc_codec *codec = dai->codec; 2931 struct snd_soc_codec *codec = dai->codec;
2932 int val; 2932 int val, ret;
2933 2933
2934 if (mute) 2934 if (mute)
2935 val = WM8962_DAC_MUTE; 2935 val = WM8962_DAC_MUTE | WM8962_DAC_MUTE_ALT;
2936 else 2936 else
2937 val = 0; 2937 val = 0;
2938 2938
2939 /**
2940 * The DAC mute bit is mirrored in two registers, update both to keep
2941 * the register cache consistent.
2942 */
2943 ret = snd_soc_update_bits(codec, WM8962_CLASS_D_CONTROL_1,
2944 WM8962_DAC_MUTE_ALT, val);
2945 if (ret < 0)
2946 return ret;
2947
2939 return snd_soc_update_bits(codec, WM8962_ADC_DAC_CONTROL_1, 2948 return snd_soc_update_bits(codec, WM8962_ADC_DAC_CONTROL_1,
2940 WM8962_DAC_MUTE, val); 2949 WM8962_DAC_MUTE, val);
2941} 2950}
diff --git a/sound/soc/codecs/wm8962.h b/sound/soc/codecs/wm8962.h
index a1a5d5294c19..910aafd09d21 100644
--- a/sound/soc/codecs/wm8962.h
+++ b/sound/soc/codecs/wm8962.h
@@ -1954,6 +1954,10 @@
1954#define WM8962_SPKOUTL_ENA_MASK 0x0040 /* SPKOUTL_ENA */ 1954#define WM8962_SPKOUTL_ENA_MASK 0x0040 /* SPKOUTL_ENA */
1955#define WM8962_SPKOUTL_ENA_SHIFT 6 /* SPKOUTL_ENA */ 1955#define WM8962_SPKOUTL_ENA_SHIFT 6 /* SPKOUTL_ENA */
1956#define WM8962_SPKOUTL_ENA_WIDTH 1 /* SPKOUTL_ENA */ 1956#define WM8962_SPKOUTL_ENA_WIDTH 1 /* SPKOUTL_ENA */
1957#define WM8962_DAC_MUTE_ALT 0x0010 /* DAC_MUTE */
1958#define WM8962_DAC_MUTE_ALT_MASK 0x0010 /* DAC_MUTE */
1959#define WM8962_DAC_MUTE_ALT_SHIFT 4 /* DAC_MUTE */
1960#define WM8962_DAC_MUTE_ALT_WIDTH 1 /* DAC_MUTE */
1957#define WM8962_SPKOUTL_PGA_MUTE 0x0002 /* SPKOUTL_PGA_MUTE */ 1961#define WM8962_SPKOUTL_PGA_MUTE 0x0002 /* SPKOUTL_PGA_MUTE */
1958#define WM8962_SPKOUTL_PGA_MUTE_MASK 0x0002 /* SPKOUTL_PGA_MUTE */ 1962#define WM8962_SPKOUTL_PGA_MUTE_MASK 0x0002 /* SPKOUTL_PGA_MUTE */
1959#define WM8962_SPKOUTL_PGA_MUTE_SHIFT 1 /* SPKOUTL_PGA_MUTE */ 1963#define WM8962_SPKOUTL_PGA_MUTE_SHIFT 1 /* SPKOUTL_PGA_MUTE */
diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c
index c8e5db1414d7..496ce2eb2f1f 100644
--- a/sound/soc/fsl/fsl_esai.c
+++ b/sound/soc/fsl/fsl_esai.c
@@ -258,10 +258,16 @@ static int fsl_esai_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
258 return -EINVAL; 258 return -EINVAL;
259 } 259 }
260 260
261 if (ratio == 1) { 261 /* Only EXTAL source can be output directly without using PSR and PM */
262 if (ratio == 1 && clksrc == esai_priv->extalclk) {
262 /* Bypass all the dividers if not being needed */ 263 /* Bypass all the dividers if not being needed */
263 ecr |= tx ? ESAI_ECR_ETO : ESAI_ECR_ERO; 264 ecr |= tx ? ESAI_ECR_ETO : ESAI_ECR_ERO;
264 goto out; 265 goto out;
266 } else if (ratio < 2) {
267 /* The ratio should be no less than 2 if using other sources */
268 dev_err(dai->dev, "failed to derive required HCK%c rate\n",
269 tx ? 'T' : 'R');
270 return -EINVAL;
265 } 271 }
266 272
267 ret = fsl_esai_divisor_cal(dai, tx, ratio, false, 0); 273 ret = fsl_esai_divisor_cal(dai, tx, ratio, false, 0);
@@ -307,7 +313,8 @@ static int fsl_esai_set_bclk(struct snd_soc_dai *dai, bool tx, u32 freq)
307 return -EINVAL; 313 return -EINVAL;
308 } 314 }
309 315
310 if (esai_priv->sck_div[tx] && (ratio > 16 || ratio == 0)) { 316 /* The ratio should be contented by FP alone if bypassing PM and PSR */
317 if (!esai_priv->sck_div[tx] && (ratio > 16 || ratio == 0)) {
311 dev_err(dai->dev, "the ratio is out of range (1 ~ 16)\n"); 318 dev_err(dai->dev, "the ratio is out of range (1 ~ 16)\n");
312 return -EINVAL; 319 return -EINVAL;
313 } 320 }
@@ -454,12 +461,6 @@ static int fsl_esai_startup(struct snd_pcm_substream *substream,
454 } 461 }
455 462
456 if (!dai->active) { 463 if (!dai->active) {
457 /* Reset Port C */
458 regmap_update_bits(esai_priv->regmap, REG_ESAI_PRRC,
459 ESAI_PRRC_PDC_MASK, ESAI_PRRC_PDC(ESAI_GPIO));
460 regmap_update_bits(esai_priv->regmap, REG_ESAI_PCRC,
461 ESAI_PCRC_PC_MASK, ESAI_PCRC_PC(ESAI_GPIO));
462
463 /* Set synchronous mode */ 464 /* Set synchronous mode */
464 regmap_update_bits(esai_priv->regmap, REG_ESAI_SAICR, 465 regmap_update_bits(esai_priv->regmap, REG_ESAI_SAICR,
465 ESAI_SAICR_SYNC, esai_priv->synchronous ? 466 ESAI_SAICR_SYNC, esai_priv->synchronous ?
@@ -519,6 +520,11 @@ static int fsl_esai_hw_params(struct snd_pcm_substream *substream,
519 520
520 regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx), mask, val); 521 regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx), mask, val);
521 522
523 /* Remove ESAI personal reset by configuring ESAI_PCRC and ESAI_PRRC */
524 regmap_update_bits(esai_priv->regmap, REG_ESAI_PRRC,
525 ESAI_PRRC_PDC_MASK, ESAI_PRRC_PDC(ESAI_GPIO));
526 regmap_update_bits(esai_priv->regmap, REG_ESAI_PCRC,
527 ESAI_PCRC_PC_MASK, ESAI_PCRC_PC(ESAI_GPIO));
522 return 0; 528 return 0;
523} 529}
524 530
diff --git a/sound/soc/fsl/imx-audmux.c b/sound/soc/fsl/imx-audmux.c
index ac869931d7f1..267717aa96c1 100644
--- a/sound/soc/fsl/imx-audmux.c
+++ b/sound/soc/fsl/imx-audmux.c
@@ -145,7 +145,7 @@ static const struct file_operations audmux_debugfs_fops = {
145 .llseek = default_llseek, 145 .llseek = default_llseek,
146}; 146};
147 147
148static void __init audmux_debugfs_init(void) 148static void audmux_debugfs_init(void)
149{ 149{
150 int i; 150 int i;
151 char buf[20]; 151 char buf[20];
diff --git a/sound/soc/intel/sst-acpi.c b/sound/soc/intel/sst-acpi.c
index 5d06eecb6198..18aee77f8d4a 100644
--- a/sound/soc/intel/sst-acpi.c
+++ b/sound/soc/intel/sst-acpi.c
@@ -138,6 +138,7 @@ static int sst_acpi_probe(struct platform_device *pdev)
138 138
139 sst_pdata = &sst_acpi->sst_pdata; 139 sst_pdata = &sst_acpi->sst_pdata;
140 sst_pdata->id = desc->sst_id; 140 sst_pdata->id = desc->sst_id;
141 sst_pdata->dma_dev = dev;
141 sst_acpi->desc = desc; 142 sst_acpi->desc = desc;
142 sst_acpi->mach = mach; 143 sst_acpi->mach = mach;
143 144
diff --git a/sound/soc/intel/sst-baytrail-dsp.c b/sound/soc/intel/sst-baytrail-dsp.c
index a50bf7fc0e3a..adf0aca5aca6 100644
--- a/sound/soc/intel/sst-baytrail-dsp.c
+++ b/sound/soc/intel/sst-baytrail-dsp.c
@@ -324,7 +324,7 @@ static int sst_byt_init(struct sst_dsp *sst, struct sst_pdata *pdata)
324 memcpy_toio(sst->addr.lpe + SST_BYT_MAILBOX_OFFSET, 324 memcpy_toio(sst->addr.lpe + SST_BYT_MAILBOX_OFFSET,
325 &pdata->fw_base, sizeof(u32)); 325 &pdata->fw_base, sizeof(u32));
326 326
327 ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32)); 327 ret = dma_coerce_mask_and_coherent(sst->dma_dev, DMA_BIT_MASK(32));
328 if (ret) 328 if (ret)
329 return ret; 329 return ret;
330 330
diff --git a/sound/soc/intel/sst-baytrail-ipc.c b/sound/soc/intel/sst-baytrail-ipc.c
index d0eaeee21be4..0d31dbbf4806 100644
--- a/sound/soc/intel/sst-baytrail-ipc.c
+++ b/sound/soc/intel/sst-baytrail-ipc.c
@@ -542,16 +542,20 @@ struct sst_byt_stream *sst_byt_stream_new(struct sst_byt *byt, int id,
542 void *data) 542 void *data)
543{ 543{
544 struct sst_byt_stream *stream; 544 struct sst_byt_stream *stream;
545 struct sst_dsp *sst = byt->dsp;
546 unsigned long flags;
545 547
546 stream = kzalloc(sizeof(*stream), GFP_KERNEL); 548 stream = kzalloc(sizeof(*stream), GFP_KERNEL);
547 if (stream == NULL) 549 if (stream == NULL)
548 return NULL; 550 return NULL;
549 551
552 spin_lock_irqsave(&sst->spinlock, flags);
550 list_add(&stream->node, &byt->stream_list); 553 list_add(&stream->node, &byt->stream_list);
551 stream->notify_position = notify_position; 554 stream->notify_position = notify_position;
552 stream->pdata = data; 555 stream->pdata = data;
553 stream->byt = byt; 556 stream->byt = byt;
554 stream->str_id = id; 557 stream->str_id = id;
558 spin_unlock_irqrestore(&sst->spinlock, flags);
555 559
556 return stream; 560 return stream;
557} 561}
@@ -630,6 +634,8 @@ int sst_byt_stream_free(struct sst_byt *byt, struct sst_byt_stream *stream)
630{ 634{
631 u64 header; 635 u64 header;
632 int ret = 0; 636 int ret = 0;
637 struct sst_dsp *sst = byt->dsp;
638 unsigned long flags;
633 639
634 if (!stream->commited) 640 if (!stream->commited)
635 goto out; 641 goto out;
@@ -644,8 +650,10 @@ int sst_byt_stream_free(struct sst_byt *byt, struct sst_byt_stream *stream)
644 650
645 stream->commited = false; 651 stream->commited = false;
646out: 652out:
653 spin_lock_irqsave(&sst->spinlock, flags);
647 list_del(&stream->node); 654 list_del(&stream->node);
648 kfree(stream); 655 kfree(stream);
656 spin_unlock_irqrestore(&sst->spinlock, flags);
649 657
650 return ret; 658 return ret;
651} 659}
diff --git a/sound/soc/intel/sst-dsp-priv.h b/sound/soc/intel/sst-dsp-priv.h
index 30ca14a6a835..401213455497 100644
--- a/sound/soc/intel/sst-dsp-priv.h
+++ b/sound/soc/intel/sst-dsp-priv.h
@@ -228,6 +228,7 @@ struct sst_dsp {
228 spinlock_t spinlock; /* IPC locking */ 228 spinlock_t spinlock; /* IPC locking */
229 struct mutex mutex; /* DSP FW lock */ 229 struct mutex mutex; /* DSP FW lock */
230 struct device *dev; 230 struct device *dev;
231 struct device *dma_dev;
231 void *thread_context; 232 void *thread_context;
232 int irq; 233 int irq;
233 u32 id; 234 u32 id;
diff --git a/sound/soc/intel/sst-dsp.c b/sound/soc/intel/sst-dsp.c
index 0c129fd85ecf..0b715b20a2d7 100644
--- a/sound/soc/intel/sst-dsp.c
+++ b/sound/soc/intel/sst-dsp.c
@@ -337,6 +337,7 @@ struct sst_dsp *sst_dsp_new(struct device *dev,
337 spin_lock_init(&sst->spinlock); 337 spin_lock_init(&sst->spinlock);
338 mutex_init(&sst->mutex); 338 mutex_init(&sst->mutex);
339 sst->dev = dev; 339 sst->dev = dev;
340 sst->dma_dev = pdata->dma_dev;
340 sst->thread_context = sst_dev->thread_context; 341 sst->thread_context = sst_dev->thread_context;
341 sst->sst_dev = sst_dev; 342 sst->sst_dev = sst_dev;
342 sst->id = pdata->id; 343 sst->id = pdata->id;
diff --git a/sound/soc/intel/sst-dsp.h b/sound/soc/intel/sst-dsp.h
index 74052b59485c..e44423be66c4 100644
--- a/sound/soc/intel/sst-dsp.h
+++ b/sound/soc/intel/sst-dsp.h
@@ -169,6 +169,7 @@ struct sst_pdata {
169 u32 dma_base; 169 u32 dma_base;
170 u32 dma_size; 170 u32 dma_size;
171 int dma_engine; 171 int dma_engine;
172 struct device *dma_dev;
172 173
173 /* DSP */ 174 /* DSP */
174 u32 id; 175 u32 id;
diff --git a/sound/soc/intel/sst-firmware.c b/sound/soc/intel/sst-firmware.c
index f7687107cf7f..928f228c38e7 100644
--- a/sound/soc/intel/sst-firmware.c
+++ b/sound/soc/intel/sst-firmware.c
@@ -57,14 +57,8 @@ struct sst_fw *sst_fw_new(struct sst_dsp *dsp,
57 sst_fw->private = private; 57 sst_fw->private = private;
58 sst_fw->size = fw->size; 58 sst_fw->size = fw->size;
59 59
60 err = dma_coerce_mask_and_coherent(dsp->dev, DMA_BIT_MASK(32));
61 if (err < 0) {
62 kfree(sst_fw);
63 return NULL;
64 }
65
66 /* allocate DMA buffer to store FW data */ 60 /* allocate DMA buffer to store FW data */
67 sst_fw->dma_buf = dma_alloc_coherent(dsp->dev, sst_fw->size, 61 sst_fw->dma_buf = dma_alloc_coherent(dsp->dma_dev, sst_fw->size,
68 &sst_fw->dmable_fw_paddr, GFP_DMA | GFP_KERNEL); 62 &sst_fw->dmable_fw_paddr, GFP_DMA | GFP_KERNEL);
69 if (!sst_fw->dma_buf) { 63 if (!sst_fw->dma_buf) {
70 dev_err(dsp->dev, "error: DMA alloc failed\n"); 64 dev_err(dsp->dev, "error: DMA alloc failed\n");
@@ -106,7 +100,7 @@ void sst_fw_free(struct sst_fw *sst_fw)
106 list_del(&sst_fw->list); 100 list_del(&sst_fw->list);
107 mutex_unlock(&dsp->mutex); 101 mutex_unlock(&dsp->mutex);
108 102
109 dma_free_coherent(dsp->dev, sst_fw->size, sst_fw->dma_buf, 103 dma_free_coherent(dsp->dma_dev, sst_fw->size, sst_fw->dma_buf,
110 sst_fw->dmable_fw_paddr); 104 sst_fw->dmable_fw_paddr);
111 kfree(sst_fw); 105 kfree(sst_fw);
112} 106}
@@ -202,6 +196,9 @@ static int block_alloc_contiguous(struct sst_module *module,
202 size -= block->size; 196 size -= block->size;
203 } 197 }
204 198
199 list_for_each_entry(block, &tmp, list)
200 list_add(&block->module_list, &module->block_list);
201
205 list_splice(&tmp, &dsp->used_block_list); 202 list_splice(&tmp, &dsp->used_block_list);
206 return 0; 203 return 0;
207} 204}
@@ -247,8 +244,7 @@ static int block_alloc(struct sst_module *module,
247 /* do we span > 1 blocks */ 244 /* do we span > 1 blocks */
248 if (data->size > block->size) { 245 if (data->size > block->size) {
249 ret = block_alloc_contiguous(module, data, 246 ret = block_alloc_contiguous(module, data,
250 block->offset + block->size, 247 block->offset, data->size);
251 data->size - block->size);
252 if (ret == 0) 248 if (ret == 0)
253 return ret; 249 return ret;
254 } 250 }
@@ -344,7 +340,7 @@ static int block_alloc_fixed(struct sst_module *module,
344 340
345 err = block_alloc_contiguous(module, data, 341 err = block_alloc_contiguous(module, data,
346 block->offset + block->size, 342 block->offset + block->size,
347 data->size - block->size + data->offset - block->offset); 343 data->size - block->size);
348 if (err < 0) 344 if (err < 0)
349 return -ENOMEM; 345 return -ENOMEM;
350 346
@@ -371,15 +367,10 @@ static int block_alloc_fixed(struct sst_module *module,
371 if (data->offset >= block->offset && data->offset < block_end) { 367 if (data->offset >= block->offset && data->offset < block_end) {
372 368
373 err = block_alloc_contiguous(module, data, 369 err = block_alloc_contiguous(module, data,
374 block->offset + block->size, 370 block->offset, data->size);
375 data->size - block->size);
376 if (err < 0) 371 if (err < 0)
377 return -ENOMEM; 372 return -ENOMEM;
378 373
379 /* add block */
380 block->data_type = data->data_type;
381 list_move(&block->list, &dsp->used_block_list);
382 list_add(&block->module_list, &module->block_list);
383 return 0; 374 return 0;
384 } 375 }
385 376
diff --git a/sound/soc/intel/sst-haswell-dsp.c b/sound/soc/intel/sst-haswell-dsp.c
index f5ebf36af889..535f517629fd 100644
--- a/sound/soc/intel/sst-haswell-dsp.c
+++ b/sound/soc/intel/sst-haswell-dsp.c
@@ -433,7 +433,7 @@ static int hsw_init(struct sst_dsp *sst, struct sst_pdata *pdata)
433 int ret = -ENODEV, i, j, region_count; 433 int ret = -ENODEV, i, j, region_count;
434 u32 offset, size; 434 u32 offset, size;
435 435
436 dev = sst->dev; 436 dev = sst->dma_dev;
437 437
438 switch (sst->id) { 438 switch (sst->id) {
439 case SST_DEV_ID_LYNX_POINT: 439 case SST_DEV_ID_LYNX_POINT:
@@ -466,7 +466,7 @@ static int hsw_init(struct sst_dsp *sst, struct sst_pdata *pdata)
466 return ret; 466 return ret;
467 } 467 }
468 468
469 ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32)); 469 ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(31));
470 if (ret) 470 if (ret)
471 return ret; 471 return ret;
472 472
diff --git a/sound/soc/intel/sst-haswell-ipc.c b/sound/soc/intel/sst-haswell-ipc.c
index 50e4246d4b57..e7996b39a484 100644
--- a/sound/soc/intel/sst-haswell-ipc.c
+++ b/sound/soc/intel/sst-haswell-ipc.c
@@ -1159,11 +1159,14 @@ struct sst_hsw_stream *sst_hsw_stream_new(struct sst_hsw *hsw, int id,
1159 void *data) 1159 void *data)
1160{ 1160{
1161 struct sst_hsw_stream *stream; 1161 struct sst_hsw_stream *stream;
1162 struct sst_dsp *sst = hsw->dsp;
1163 unsigned long flags;
1162 1164
1163 stream = kzalloc(sizeof(*stream), GFP_KERNEL); 1165 stream = kzalloc(sizeof(*stream), GFP_KERNEL);
1164 if (stream == NULL) 1166 if (stream == NULL)
1165 return NULL; 1167 return NULL;
1166 1168
1169 spin_lock_irqsave(&sst->spinlock, flags);
1167 list_add(&stream->node, &hsw->stream_list); 1170 list_add(&stream->node, &hsw->stream_list);
1168 stream->notify_position = notify_position; 1171 stream->notify_position = notify_position;
1169 stream->pdata = data; 1172 stream->pdata = data;
@@ -1172,6 +1175,7 @@ struct sst_hsw_stream *sst_hsw_stream_new(struct sst_hsw *hsw, int id,
1172 1175
1173 /* work to process notification messages */ 1176 /* work to process notification messages */
1174 INIT_WORK(&stream->notify_work, hsw_notification_work); 1177 INIT_WORK(&stream->notify_work, hsw_notification_work);
1178 spin_unlock_irqrestore(&sst->spinlock, flags);
1175 1179
1176 return stream; 1180 return stream;
1177} 1181}
@@ -1180,6 +1184,8 @@ int sst_hsw_stream_free(struct sst_hsw *hsw, struct sst_hsw_stream *stream)
1180{ 1184{
1181 u32 header; 1185 u32 header;
1182 int ret = 0; 1186 int ret = 0;
1187 struct sst_dsp *sst = hsw->dsp;
1188 unsigned long flags;
1183 1189
1184 /* dont free DSP streams that are not commited */ 1190 /* dont free DSP streams that are not commited */
1185 if (!stream->commited) 1191 if (!stream->commited)
@@ -1201,8 +1207,11 @@ int sst_hsw_stream_free(struct sst_hsw *hsw, struct sst_hsw_stream *stream)
1201 trace_hsw_stream_free_req(stream, &stream->free_req); 1207 trace_hsw_stream_free_req(stream, &stream->free_req);
1202 1208
1203out: 1209out:
1210 cancel_work_sync(&stream->notify_work);
1211 spin_lock_irqsave(&sst->spinlock, flags);
1204 list_del(&stream->node); 1212 list_del(&stream->node);
1205 kfree(stream); 1213 kfree(stream);
1214 spin_unlock_irqrestore(&sst->spinlock, flags);
1206 1215
1207 return ret; 1216 return ret;
1208} 1217}
@@ -1538,10 +1547,28 @@ int sst_hsw_stream_reset(struct sst_hsw *hsw, struct sst_hsw_stream *stream)
1538} 1547}
1539 1548
1540/* Stream pointer positions */ 1549/* Stream pointer positions */
1541int sst_hsw_get_dsp_position(struct sst_hsw *hsw, 1550u32 sst_hsw_get_dsp_position(struct sst_hsw *hsw,
1542 struct sst_hsw_stream *stream) 1551 struct sst_hsw_stream *stream)
1543{ 1552{
1544 return stream->rpos.position; 1553 u32 rpos;
1554
1555 sst_dsp_read(hsw->dsp, &rpos,
1556 stream->reply.read_position_register_address, sizeof(rpos));
1557
1558 return rpos;
1559}
1560
1561/* Stream presentation (monotonic) positions */
1562u64 sst_hsw_get_dsp_presentation_position(struct sst_hsw *hsw,
1563 struct sst_hsw_stream *stream)
1564{
1565 u64 ppos;
1566
1567 sst_dsp_read(hsw->dsp, &ppos,
1568 stream->reply.presentation_position_register_address,
1569 sizeof(ppos));
1570
1571 return ppos;
1545} 1572}
1546 1573
1547int sst_hsw_stream_set_write_position(struct sst_hsw *hsw, 1574int sst_hsw_stream_set_write_position(struct sst_hsw *hsw,
diff --git a/sound/soc/intel/sst-haswell-ipc.h b/sound/soc/intel/sst-haswell-ipc.h
index d517929ccc38..2ac194a6d04b 100644
--- a/sound/soc/intel/sst-haswell-ipc.h
+++ b/sound/soc/intel/sst-haswell-ipc.h
@@ -464,7 +464,9 @@ int sst_hsw_stream_get_write_pos(struct sst_hsw *hsw,
464 struct sst_hsw_stream *stream, u32 *position); 464 struct sst_hsw_stream *stream, u32 *position);
465int sst_hsw_stream_set_write_position(struct sst_hsw *hsw, 465int sst_hsw_stream_set_write_position(struct sst_hsw *hsw,
466 struct sst_hsw_stream *stream, u32 stage_id, u32 position); 466 struct sst_hsw_stream *stream, u32 stage_id, u32 position);
467int sst_hsw_get_dsp_position(struct sst_hsw *hsw, 467u32 sst_hsw_get_dsp_position(struct sst_hsw *hsw,
468 struct sst_hsw_stream *stream);
469u64 sst_hsw_get_dsp_presentation_position(struct sst_hsw *hsw,
468 struct sst_hsw_stream *stream); 470 struct sst_hsw_stream *stream);
469 471
470/* HW port config */ 472/* HW port config */
diff --git a/sound/soc/intel/sst-haswell-pcm.c b/sound/soc/intel/sst-haswell-pcm.c
index 0a32dd13a23d..9d5f64a583a3 100644
--- a/sound/soc/intel/sst-haswell-pcm.c
+++ b/sound/soc/intel/sst-haswell-pcm.c
@@ -99,6 +99,7 @@ struct hsw_pcm_data {
99 struct snd_compr_stream *cstream; 99 struct snd_compr_stream *cstream;
100 unsigned int wpos; 100 unsigned int wpos;
101 struct mutex mutex; 101 struct mutex mutex;
102 bool allocated;
102}; 103};
103 104
104/* private data for the driver */ 105/* private data for the driver */
@@ -107,12 +108,14 @@ struct hsw_priv_data {
107 struct sst_hsw *hsw; 108 struct sst_hsw *hsw;
108 109
109 /* page tables */ 110 /* page tables */
110 unsigned char *pcm_pg[HSW_PCM_COUNT][2]; 111 struct snd_dma_buffer dmab[HSW_PCM_COUNT][2];
111 112
112 /* DAI data */ 113 /* DAI data */
113 struct hsw_pcm_data pcm[HSW_PCM_COUNT]; 114 struct hsw_pcm_data pcm[HSW_PCM_COUNT];
114}; 115};
115 116
117static u32 hsw_notify_pointer(struct sst_hsw_stream *stream, void *data);
118
116static inline u32 hsw_mixer_to_ipc(unsigned int value) 119static inline u32 hsw_mixer_to_ipc(unsigned int value)
117{ 120{
118 if (value >= ARRAY_SIZE(volume_map)) 121 if (value >= ARRAY_SIZE(volume_map))
@@ -273,28 +276,26 @@ static const struct snd_kcontrol_new hsw_volume_controls[] = {
273}; 276};
274 277
275/* Create DMA buffer page table for DSP */ 278/* Create DMA buffer page table for DSP */
276static int create_adsp_page_table(struct hsw_priv_data *pdata, 279static int create_adsp_page_table(struct snd_pcm_substream *substream,
277 struct snd_soc_pcm_runtime *rtd, 280 struct hsw_priv_data *pdata, struct snd_soc_pcm_runtime *rtd,
278 unsigned char *dma_area, size_t size, int pcm, int stream) 281 unsigned char *dma_area, size_t size, int pcm)
279{ 282{
280 int i, pages; 283 struct snd_dma_buffer *dmab = snd_pcm_get_dma_buf(substream);
284 int i, pages, stream = substream->stream;
281 285
282 if (size % PAGE_SIZE) 286 pages = snd_sgbuf_aligned_pages(size);
283 pages = (size / PAGE_SIZE) + 1;
284 else
285 pages = size / PAGE_SIZE;
286 287
287 dev_dbg(rtd->dev, "generating page table for %p size 0x%zu pages %d\n", 288 dev_dbg(rtd->dev, "generating page table for %p size 0x%zu pages %d\n",
288 dma_area, size, pages); 289 dma_area, size, pages);
289 290
290 for (i = 0; i < pages; i++) { 291 for (i = 0; i < pages; i++) {
291 u32 idx = (((i << 2) + i)) >> 1; 292 u32 idx = (((i << 2) + i)) >> 1;
292 u32 pfn = (virt_to_phys(dma_area + i * PAGE_SIZE)) >> PAGE_SHIFT; 293 u32 pfn = snd_sgbuf_get_addr(dmab, i * PAGE_SIZE) >> PAGE_SHIFT;
293 u32 *pg_table; 294 u32 *pg_table;
294 295
295 dev_dbg(rtd->dev, "pfn i %i idx %d pfn %x\n", i, idx, pfn); 296 dev_dbg(rtd->dev, "pfn i %i idx %d pfn %x\n", i, idx, pfn);
296 297
297 pg_table = (u32*)(pdata->pcm_pg[pcm][stream] + idx); 298 pg_table = (u32 *)(pdata->dmab[pcm][stream].area + idx);
298 299
299 if (i & 1) 300 if (i & 1)
300 *pg_table |= (pfn << 4); 301 *pg_table |= (pfn << 4);
@@ -317,12 +318,36 @@ static int hsw_pcm_hw_params(struct snd_pcm_substream *substream,
317 struct sst_hsw *hsw = pdata->hsw; 318 struct sst_hsw *hsw = pdata->hsw;
318 struct sst_module *module_data; 319 struct sst_module *module_data;
319 struct sst_dsp *dsp; 320 struct sst_dsp *dsp;
321 struct snd_dma_buffer *dmab;
320 enum sst_hsw_stream_type stream_type; 322 enum sst_hsw_stream_type stream_type;
321 enum sst_hsw_stream_path_id path_id; 323 enum sst_hsw_stream_path_id path_id;
322 u32 rate, bits, map, pages, module_id; 324 u32 rate, bits, map, pages, module_id;
323 u8 channels; 325 u8 channels;
324 int ret; 326 int ret;
325 327
328 /* check if we are being called a subsequent time */
329 if (pcm_data->allocated) {
330 ret = sst_hsw_stream_reset(hsw, pcm_data->stream);
331 if (ret < 0)
332 dev_dbg(rtd->dev, "error: reset stream failed %d\n",
333 ret);
334
335 ret = sst_hsw_stream_free(hsw, pcm_data->stream);
336 if (ret < 0) {
337 dev_dbg(rtd->dev, "error: free stream failed %d\n",
338 ret);
339 return ret;
340 }
341 pcm_data->allocated = false;
342
343 pcm_data->stream = sst_hsw_stream_new(hsw, rtd->cpu_dai->id,
344 hsw_notify_pointer, pcm_data);
345 if (pcm_data->stream == NULL) {
346 dev_err(rtd->dev, "error: failed to create stream\n");
347 return -EINVAL;
348 }
349 }
350
326 /* stream direction */ 351 /* stream direction */
327 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 352 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
328 path_id = SST_HSW_STREAM_PATH_SSP0_OUT; 353 path_id = SST_HSW_STREAM_PATH_SSP0_OUT;
@@ -416,8 +441,10 @@ static int hsw_pcm_hw_params(struct snd_pcm_substream *substream,
416 return ret; 441 return ret;
417 } 442 }
418 443
419 ret = create_adsp_page_table(pdata, rtd, runtime->dma_area, 444 dmab = snd_pcm_get_dma_buf(substream);
420 runtime->dma_bytes, rtd->cpu_dai->id, substream->stream); 445
446 ret = create_adsp_page_table(substream, pdata, rtd, runtime->dma_area,
447 runtime->dma_bytes, rtd->cpu_dai->id);
421 if (ret < 0) 448 if (ret < 0)
422 return ret; 449 return ret;
423 450
@@ -430,9 +457,9 @@ static int hsw_pcm_hw_params(struct snd_pcm_substream *substream,
430 pages = runtime->dma_bytes / PAGE_SIZE; 457 pages = runtime->dma_bytes / PAGE_SIZE;
431 458
432 ret = sst_hsw_stream_buffer(hsw, pcm_data->stream, 459 ret = sst_hsw_stream_buffer(hsw, pcm_data->stream,
433 virt_to_phys(pdata->pcm_pg[rtd->cpu_dai->id][substream->stream]), 460 pdata->dmab[rtd->cpu_dai->id][substream->stream].addr,
434 pages, runtime->dma_bytes, 0, 461 pages, runtime->dma_bytes, 0,
435 (u32)(virt_to_phys(runtime->dma_area) >> PAGE_SHIFT)); 462 snd_sgbuf_get_addr(dmab, 0) >> PAGE_SHIFT);
436 if (ret < 0) { 463 if (ret < 0) {
437 dev_err(rtd->dev, "error: failed to set DMA buffer %d\n", ret); 464 dev_err(rtd->dev, "error: failed to set DMA buffer %d\n", ret);
438 return ret; 465 return ret;
@@ -474,6 +501,7 @@ static int hsw_pcm_hw_params(struct snd_pcm_substream *substream,
474 dev_err(rtd->dev, "error: failed to commit stream %d\n", ret); 501 dev_err(rtd->dev, "error: failed to commit stream %d\n", ret);
475 return ret; 502 return ret;
476 } 503 }
504 pcm_data->allocated = true;
477 505
478 ret = sst_hsw_stream_pause(hsw, pcm_data->stream, 1); 506 ret = sst_hsw_stream_pause(hsw, pcm_data->stream, 1);
479 if (ret < 0) 507 if (ret < 0)
@@ -541,12 +569,14 @@ static snd_pcm_uframes_t hsw_pcm_pointer(struct snd_pcm_substream *substream)
541 struct hsw_pcm_data *pcm_data = snd_soc_pcm_get_drvdata(rtd); 569 struct hsw_pcm_data *pcm_data = snd_soc_pcm_get_drvdata(rtd);
542 struct sst_hsw *hsw = pdata->hsw; 570 struct sst_hsw *hsw = pdata->hsw;
543 snd_pcm_uframes_t offset; 571 snd_pcm_uframes_t offset;
572 uint64_t ppos;
573 u32 position = sst_hsw_get_dsp_position(hsw, pcm_data->stream);
544 574
545 offset = bytes_to_frames(runtime, 575 offset = bytes_to_frames(runtime, position);
546 sst_hsw_get_dsp_position(hsw, pcm_data->stream)); 576 ppos = sst_hsw_get_dsp_presentation_position(hsw, pcm_data->stream);
547 577
548 dev_dbg(rtd->dev, "PCM: DMA pointer %zu bytes\n", 578 dev_dbg(rtd->dev, "PCM: DMA pointer %du bytes, pos %llu\n",
549 frames_to_bytes(runtime, (u32)offset)); 579 position, ppos);
550 return offset; 580 return offset;
551} 581}
552 582
@@ -606,6 +636,7 @@ static int hsw_pcm_close(struct snd_pcm_substream *substream)
606 dev_dbg(rtd->dev, "error: free stream failed %d\n", ret); 636 dev_dbg(rtd->dev, "error: free stream failed %d\n", ret);
607 goto out; 637 goto out;
608 } 638 }
639 pcm_data->allocated = 0;
609 pcm_data->stream = NULL; 640 pcm_data->stream = NULL;
610 641
611out: 642out:
@@ -621,7 +652,7 @@ static struct snd_pcm_ops hsw_pcm_ops = {
621 .hw_free = hsw_pcm_hw_free, 652 .hw_free = hsw_pcm_hw_free,
622 .trigger = hsw_pcm_trigger, 653 .trigger = hsw_pcm_trigger,
623 .pointer = hsw_pcm_pointer, 654 .pointer = hsw_pcm_pointer,
624 .mmap = snd_pcm_lib_default_mmap, 655 .page = snd_pcm_sgbuf_ops_page,
625}; 656};
626 657
627static void hsw_pcm_free(struct snd_pcm *pcm) 658static void hsw_pcm_free(struct snd_pcm *pcm)
@@ -632,17 +663,16 @@ static void hsw_pcm_free(struct snd_pcm *pcm)
632static int hsw_pcm_new(struct snd_soc_pcm_runtime *rtd) 663static int hsw_pcm_new(struct snd_soc_pcm_runtime *rtd)
633{ 664{
634 struct snd_pcm *pcm = rtd->pcm; 665 struct snd_pcm *pcm = rtd->pcm;
666 struct snd_soc_platform *platform = rtd->platform;
667 struct sst_pdata *pdata = dev_get_platdata(platform->dev);
668 struct device *dev = pdata->dma_dev;
635 int ret = 0; 669 int ret = 0;
636 670
637 ret = dma_coerce_mask_and_coherent(rtd->card->dev, DMA_BIT_MASK(32));
638 if (ret)
639 return ret;
640
641 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream || 671 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream ||
642 pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { 672 pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
643 ret = snd_pcm_lib_preallocate_pages_for_all(pcm, 673 ret = snd_pcm_lib_preallocate_pages_for_all(pcm,
644 SNDRV_DMA_TYPE_DEV, 674 SNDRV_DMA_TYPE_DEV_SG,
645 rtd->card->dev, 675 dev,
646 hsw_pcm_hardware.buffer_bytes_max, 676 hsw_pcm_hardware.buffer_bytes_max,
647 hsw_pcm_hardware.buffer_bytes_max); 677 hsw_pcm_hardware.buffer_bytes_max);
648 if (ret) { 678 if (ret) {
@@ -742,11 +772,14 @@ static int hsw_pcm_probe(struct snd_soc_platform *platform)
742{ 772{
743 struct sst_pdata *pdata = dev_get_platdata(platform->dev); 773 struct sst_pdata *pdata = dev_get_platdata(platform->dev);
744 struct hsw_priv_data *priv_data; 774 struct hsw_priv_data *priv_data;
745 int i; 775 struct device *dma_dev;
776 int i, ret = 0;
746 777
747 if (!pdata) 778 if (!pdata)
748 return -ENODEV; 779 return -ENODEV;
749 780
781 dma_dev = pdata->dma_dev;
782
750 priv_data = devm_kzalloc(platform->dev, sizeof(*priv_data), GFP_KERNEL); 783 priv_data = devm_kzalloc(platform->dev, sizeof(*priv_data), GFP_KERNEL);
751 priv_data->hsw = pdata->dsp; 784 priv_data->hsw = pdata->dsp;
752 snd_soc_platform_set_drvdata(platform, priv_data); 785 snd_soc_platform_set_drvdata(platform, priv_data);
@@ -758,15 +791,17 @@ static int hsw_pcm_probe(struct snd_soc_platform *platform)
758 791
759 /* playback */ 792 /* playback */
760 if (hsw_dais[i].playback.channels_min) { 793 if (hsw_dais[i].playback.channels_min) {
761 priv_data->pcm_pg[i][0] = kzalloc(PAGE_SIZE, GFP_DMA); 794 ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, dma_dev,
762 if (priv_data->pcm_pg[i][0] == NULL) 795 PAGE_SIZE, &priv_data->dmab[i][0]);
796 if (ret < 0)
763 goto err; 797 goto err;
764 } 798 }
765 799
766 /* capture */ 800 /* capture */
767 if (hsw_dais[i].capture.channels_min) { 801 if (hsw_dais[i].capture.channels_min) {
768 priv_data->pcm_pg[i][1] = kzalloc(PAGE_SIZE, GFP_DMA); 802 ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, dma_dev,
769 if (priv_data->pcm_pg[i][1] == NULL) 803 PAGE_SIZE, &priv_data->dmab[i][1]);
804 if (ret < 0)
770 goto err; 805 goto err;
771 } 806 }
772 } 807 }
@@ -776,11 +811,11 @@ static int hsw_pcm_probe(struct snd_soc_platform *platform)
776err: 811err:
777 for (;i >= 0; i--) { 812 for (;i >= 0; i--) {
778 if (hsw_dais[i].playback.channels_min) 813 if (hsw_dais[i].playback.channels_min)
779 kfree(priv_data->pcm_pg[i][0]); 814 snd_dma_free_pages(&priv_data->dmab[i][0]);
780 if (hsw_dais[i].capture.channels_min) 815 if (hsw_dais[i].capture.channels_min)
781 kfree(priv_data->pcm_pg[i][1]); 816 snd_dma_free_pages(&priv_data->dmab[i][1]);
782 } 817 }
783 return -ENOMEM; 818 return ret;
784} 819}
785 820
786static int hsw_pcm_remove(struct snd_soc_platform *platform) 821static int hsw_pcm_remove(struct snd_soc_platform *platform)
@@ -791,9 +826,9 @@ static int hsw_pcm_remove(struct snd_soc_platform *platform)
791 826
792 for (i = 0; i < ARRAY_SIZE(hsw_dais); i++) { 827 for (i = 0; i < ARRAY_SIZE(hsw_dais); i++) {
793 if (hsw_dais[i].playback.channels_min) 828 if (hsw_dais[i].playback.channels_min)
794 kfree(priv_data->pcm_pg[i][0]); 829 snd_dma_free_pages(&priv_data->dmab[i][0]);
795 if (hsw_dais[i].capture.channels_min) 830 if (hsw_dais[i].capture.channels_min)
796 kfree(priv_data->pcm_pg[i][1]); 831 snd_dma_free_pages(&priv_data->dmab[i][1]);
797 } 832 }
798 833
799 return 0; 834 return 0;
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index 215b668166be..89424470a1f3 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -197,13 +197,12 @@ static void rsnd_dma_complete(void *data)
197 * rsnd_dai_pointer_update() will be called twice, 197 * rsnd_dai_pointer_update() will be called twice,
198 * ant it will breaks io->byte_pos 198 * ant it will breaks io->byte_pos
199 */ 199 */
200
201 rsnd_dai_pointer_update(io, io->byte_per_period);
202
203 if (dma->submit_loop) 200 if (dma->submit_loop)
204 rsnd_dma_continue(dma); 201 rsnd_dma_continue(dma);
205 202
206 rsnd_unlock(priv, flags); 203 rsnd_unlock(priv, flags);
204
205 rsnd_dai_pointer_update(io, io->byte_per_period);
207} 206}
208 207
209static void __rsnd_dma_start(struct rsnd_dma *dma) 208static void __rsnd_dma_start(struct rsnd_dma *dma)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 7769b0a2bc5a..6d6ceee447d5 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1612,8 +1612,11 @@ static void dapm_pre_sequence_async(void *data, async_cookie_t cookie)
1612 "ASoC: Failed to turn on bias: %d\n", ret); 1612 "ASoC: Failed to turn on bias: %d\n", ret);
1613 } 1613 }
1614 1614
1615 /* Prepare for a STADDBY->ON or ON->STANDBY transition */ 1615 /* Prepare for a transition to ON or away from ON */
1616 if (d->bias_level != d->target_bias_level) { 1616 if ((d->target_bias_level == SND_SOC_BIAS_ON &&
1617 d->bias_level != SND_SOC_BIAS_ON) ||
1618 (d->target_bias_level != SND_SOC_BIAS_ON &&
1619 d->bias_level == SND_SOC_BIAS_ON)) {
1617 ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_PREPARE); 1620 ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_PREPARE);
1618 if (ret != 0) 1621 if (ret != 0)
1619 dev_err(d->dev, 1622 dev_err(d->dev,
@@ -3475,8 +3478,11 @@ void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card)
3475 cpu_dai = rtd->cpu_dai; 3478 cpu_dai = rtd->cpu_dai;
3476 codec_dai = rtd->codec_dai; 3479 codec_dai = rtd->codec_dai;
3477 3480
3478 /* dynamic FE links have no fixed DAI mapping */ 3481 /*
3479 if (rtd->dai_link->dynamic) 3482 * dynamic FE links have no fixed DAI mapping.
3483 * CODEC<->CODEC links have no direct connection.
3484 */
3485 if (rtd->dai_link->dynamic || rtd->dai_link->params)
3480 continue; 3486 continue;
3481 3487
3482 /* there is no point in connecting BE DAI links with dummies */ 3488 /* there is no point in connecting BE DAI links with dummies */
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 2cedf09f6d96..a391de058037 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1675,7 +1675,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
1675 be->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP; 1675 be->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP;
1676 break; 1676 break;
1677 case SNDRV_PCM_TRIGGER_SUSPEND: 1677 case SNDRV_PCM_TRIGGER_SUSPEND:
1678 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) 1678 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START)
1679 continue; 1679 continue;
1680 1680
1681 if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream)) 1681 if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream))