aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--arch/arm/Kconfig1
-rw-r--r--arch/arm/boot/compressed/head.S14
-rw-r--r--arch/arm/common/timer-sp.c2
-rw-r--r--arch/arm/mach-dove/include/mach/pm.h2
-rw-r--r--arch/arm/mach-dove/irq.c14
-rw-r--r--arch/arm/mach-ixp4xx/common-pci.c1
-rw-r--r--arch/arm/mach-ixp4xx/common.c13
-rw-r--r--arch/arm/mach-ixp4xx/goramo_mlr.c3
-rw-r--r--arch/arm/mach-ixp4xx/include/mach/debug-macro.S4
-rw-r--r--arch/arm/mach-ixp4xx/include/mach/ixp4xx-regs.h46
-rw-r--r--arch/arm/mach-ixp4xx/include/mach/qmgr.h12
-rw-r--r--arch/arm/mach-ixp4xx/ixp4xx_npe.c9
-rw-r--r--arch/arm/mach-ixp4xx/ixp4xx_qmgr.c12
-rw-r--r--arch/arm/mach-kirkwood/pcie.c11
-rw-r--r--arch/arm/mm/proc-v6.S2
-rw-r--r--arch/arm/plat-s3c24xx/dma.c9
-rw-r--r--arch/arm64/include/asm/unistd32.h2
-rw-r--r--arch/c6x/include/asm/setup.h33
-rw-r--r--arch/c6x/include/uapi/asm/Kbuild2
-rw-r--r--arch/c6x/include/uapi/asm/kvm_para.h1
-rw-r--r--arch/c6x/include/uapi/asm/setup.h33
-rw-r--r--arch/c6x/kernel/entry.S5
-rw-r--r--arch/microblaze/kernel/signal.c2
-rw-r--r--arch/mips/include/asm/hugetlb.h12
-rw-r--r--arch/mips/kernel/cpu-probe.c1
-rw-r--r--arch/mips/kernel/entry.S7
-rw-r--r--arch/mips/kernel/scall64-n32.S6
-rw-r--r--arch/mips/mm/tlb-r4k.c18
-rw-r--r--arch/openrisc/kernel/signal.c6
-rw-r--r--arch/parisc/kernel/syscall_table.S2
-rw-r--r--arch/s390/kernel/compat_wrapper.S2
-rw-r--r--arch/score/kernel/signal.c7
-rw-r--r--arch/sh/kernel/signal_64.c6
-rw-r--r--arch/sparc/boot/piggyback.c12
-rw-r--r--arch/sparc/kernel/sys32.S2
-rw-r--r--arch/sparc/kernel/syscalls.S14
-rw-r--r--arch/sparc/kernel/systbls_64.S2
-rw-r--r--arch/um/kernel/exec.c3
-rw-r--r--arch/x86/include/asm/Kbuild3
-rw-r--r--arch/x86/include/asm/fpu-internal.h15
-rw-r--r--arch/x86/kernel/head_32.S9
-rw-r--r--arch/x86/kernel/ptrace.c7
-rw-r--r--arch/x86/kernel/smpboot.c5
-rw-r--r--arch/x86/kvm/emulate.c3
-rw-r--r--drivers/atm/ambassador.c1
-rw-r--r--drivers/char/hw_random/Kconfig6
-rw-r--r--drivers/char/hw_random/ixp4xx-rng.c5
-rw-r--r--drivers/char/raw.c2
-rw-r--r--drivers/crypto/Kconfig2
-rw-r--r--drivers/crypto/ixp4xx_crypto.c12
-rw-r--r--drivers/edac/edac_mc.c14
-rw-r--r--drivers/edac/i7300_edac.c8
-rw-r--r--drivers/edac/i7core_edac.c6
-rw-r--r--drivers/edac/i82975x_edac.c11
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_encoder.c8
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fbdev.c3
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fimd.c4
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_plane.c1
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c6
-rw-r--r--drivers/gpu/drm/i915/intel_bios.c11
-rw-r--r--drivers/gpu/drm/i915/intel_display.c2
-rw-r--r--drivers/gpu/drm/i915/intel_pm.c12
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c17
-rw-r--r--drivers/gpu/drm/radeon/atombios_crtc.c48
-rw-r--r--drivers/input/matrix-keymap.c3
-rw-r--r--drivers/md/raid1.c2
-rw-r--r--drivers/md/raid10.c2
-rw-r--r--drivers/media/dvb-frontends/stv0900_core.c6
-rw-r--r--drivers/media/i2c/adv7604.c377
-rw-r--r--drivers/media/i2c/soc_camera/mt9v022.c11
-rw-r--r--drivers/media/platform/exynos-gsc/gsc-core.c6
-rw-r--r--drivers/media/platform/exynos-gsc/gsc-m2m.c4
-rw-r--r--drivers/media/platform/exynos-gsc/gsc-regs.h16
-rw-r--r--drivers/media/platform/omap3isp/ispccdc.c4
-rw-r--r--drivers/media/platform/omap3isp/ispstat.c4
-rw-r--r--drivers/media/platform/omap3isp/ispstat.h4
-rw-r--r--drivers/media/platform/omap3isp/ispvideo.c2
-rw-r--r--drivers/media/platform/s5p-fimc/Kconfig1
-rw-r--r--drivers/media/platform/s5p-fimc/fimc-capture.c14
-rw-r--r--drivers/media/platform/s5p-fimc/fimc-lite.c10
-rw-r--r--drivers/media/platform/s5p-fimc/fimc-m2m.c3
-rw-r--r--drivers/media/platform/s5p-fimc/fimc-mdevice.c41
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc.c7
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c2
-rw-r--r--drivers/media/platform/sh_vou.c3
-rw-r--r--drivers/media/platform/soc_camera/mx1_camera.c9
-rw-r--r--drivers/media/platform/soc_camera/mx2_camera.c13
-rw-r--r--drivers/media/platform/soc_camera/mx3_camera.c5
-rw-r--r--drivers/media/platform/soc_camera/omap1_camera.c4
-rw-r--r--drivers/media/platform/soc_camera/pxa_camera.c4
-rw-r--r--drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c13
-rw-r--r--drivers/media/usb/dvb-usb-v2/dvb_usb_core.c11
-rw-r--r--drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/rtl28xxu.c4
-rw-r--r--drivers/mfd/arizona-core.c14
-rw-r--r--drivers/mfd/arizona-irq.c1
-rw-r--r--drivers/mfd/twl-core.c2
-rw-r--r--drivers/mfd/twl4030-irq.c3
-rw-r--r--drivers/mfd/wm5102-tables.c519
-rw-r--r--drivers/mmc/host/sdhci-s3c.c7
-rw-r--r--drivers/mmc/host/sh_mmcif.c8
-rw-r--r--drivers/mtd/mtdcore.c6
-rw-r--r--drivers/mtd/ubi/wl.c26
-rw-r--r--drivers/net/bonding/bond_main.c93
-rw-r--r--drivers/net/bonding/bond_sysfs.c36
-rw-r--r--drivers/net/can/usb/peak_usb/pcan_usb.c8
-rw-r--r--drivers/net/can/usb/peak_usb/pcan_usb_pro.c8
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c2
-rw-r--r--drivers/net/ethernet/realtek/8139cp.c11
-rw-r--r--drivers/net/team/team.c4
-rw-r--r--drivers/net/usb/qmi_wwan.c1
-rw-r--r--drivers/net/wan/ixp4xx_hss.c2
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/rxon.c12
-rw-r--r--drivers/remoteproc/remoteproc_virtio.c18
-rw-r--r--drivers/rtc/rtc-tps65910.c6
-rw-r--r--drivers/scsi/megaraid/megaraid_sas.h2
-rw-r--r--drivers/scsi/megaraid/megaraid_sas_base.c14
-rw-r--r--drivers/target/target_core_transport.c6
-rw-r--r--drivers/tty/vt/vt.c8
-rw-r--r--drivers/vhost/vhost.c2
-rw-r--r--fs/block_dev.c166
-rw-r--r--fs/buffer.c145
-rw-r--r--fs/cifs/file.c6
-rw-r--r--fs/cifs/readdir.c5
-rw-r--r--fs/cifs/smb1ops.c3
-rw-r--r--fs/direct-io.c8
-rw-r--r--fs/file.c14
-rw-r--r--fs/fs-writeback.c2
-rw-r--r--fs/inode.c16
-rw-r--r--fs/internal.h1
-rw-r--r--fs/jbd/transaction.c2
-rw-r--r--fs/namei.c5
-rw-r--r--fs/nfs/dir.c7
-rw-r--r--fs/proc/base.c5
-rw-r--r--include/linux/bug.h1
-rw-r--r--include/linux/fs.h5
-rw-r--r--include/linux/gfp.h5
-rw-r--r--include/linux/hw_breakpoint.h31
-rw-r--r--include/linux/kernel.h7
-rw-r--r--include/linux/mempolicy.h16
-rw-r--r--include/linux/netdevice.h3
-rw-r--r--include/linux/percpu-rwsem.h4
-rw-r--r--include/media/adv7604.h21
-rw-r--r--include/net/tcp.h1
-rw-r--r--include/sound/soc-dai.h1
-rw-r--r--include/sound/soc.h1
-rw-r--r--include/trace/events/gfpflags.h1
-rw-r--r--include/uapi/linux/Kbuild1
-rw-r--r--include/uapi/linux/hw_breakpoint.h30
-rw-r--r--kernel/events/hw_breakpoint.c12
-rw-r--r--kernel/futex.c18
-rw-r--r--kernel/modsign_pubkey.c4
-rw-r--r--kernel/module_signing.c14
-rw-r--r--kernel/sched/auto_group.c4
-rw-r--r--kernel/sched/auto_group.h5
-rw-r--r--kernel/watchdog.c7
-rw-r--r--kernel/workqueue.c22
-rw-r--r--lib/Makefile2
-rw-r--r--lib/asn1_decoder.c2
-rw-r--r--mm/compaction.c10
-rw-r--r--mm/memory-failure.c8
-rw-r--r--mm/mempolicy.c22
-rw-r--r--mm/page_alloc.c9
-rw-r--r--mm/shmem.c26
-rw-r--r--mm/sparse.c10
-rw-r--r--mm/vmscan.c83
-rw-r--r--net/can/bcm.c3
-rw-r--r--net/core/dev.c2
-rw-r--r--net/core/skbuff.c6
-rw-r--r--net/ipv4/icmp.c3
-rw-r--r--net/ipv4/inet_diag.c154
-rw-r--r--net/ipv4/ip_fragment.c19
-rw-r--r--net/ipv4/ipmr.c4
-rw-r--r--net/ipv4/tcp.c15
-rw-r--r--net/ipv4/tcp_input.c6
-rw-r--r--net/ipv4/tcp_output.c15
-rw-r--r--net/irda/irttp.c1
-rw-r--r--net/mac80211/offchannel.c2
-rw-r--r--net/netfilter/ipset/ip_set_hash_netiface.c2
-rw-r--r--net/openvswitch/flow.c14
-rw-r--r--net/openvswitch/vport-netdev.c2
-rw-r--r--net/sctp/chunk.c20
-rw-r--r--net/sctp/socket.c4
-rw-r--r--net/sctp/transport.c2
-rw-r--r--scripts/headers_install.pl3
-rw-r--r--sound/soc/soc-compress.c2
-rw-r--r--sound/soc/soc-pcm.c12
-rw-r--r--tools/Makefile24
-rw-r--r--tools/perf/Makefile29
-rw-r--r--tools/perf/arch/x86/include/perf_regs.h2
-rw-r--r--tools/perf/builtin-kvm.c121
-rw-r--r--tools/perf/builtin-test.c2
-rw-r--r--tools/perf/perf.h16
-rw-r--r--tools/perf/util/evsel.c4
-rw-r--r--tools/perf/util/evsel.h3
-rw-r--r--tools/perf/util/header.c2
-rw-r--r--tools/perf/util/header.h2
-rw-r--r--tools/perf/util/parse-events-test.c2
-rw-r--r--tools/perf/util/parse-events.c2
-rw-r--r--tools/perf/util/parse-events.h2
-rw-r--r--tools/perf/util/pmu.h2
-rw-r--r--tools/perf/util/session.h2
-rw-r--r--tools/perf/util/strbuf.c8
-rw-r--r--tools/scripts/Makefile.include23
205 files changed, 1573 insertions, 1705 deletions
diff --git a/Makefile b/Makefile
index 3d2fc460b22f..540f7b240c77 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 7 2PATCHLEVEL = 7
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc7 4EXTRAVERSION =
5NAME = Terrified Chipmunk 5NAME = Terrified Chipmunk
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
@@ -1321,10 +1321,12 @@ kernelversion:
1321 1321
1322# Clear a bunch of variables before executing the submake 1322# Clear a bunch of variables before executing the submake
1323tools/: FORCE 1323tools/: FORCE
1324 $(Q)$(MAKE) LDFLAGS= MAKEFLAGS= -C $(src)/tools/ 1324 $(Q)mkdir -p $(objtree)/tools
1325 $(Q)$(MAKE) LDFLAGS= MAKEFLAGS= O=$(objtree) subdir=tools -C $(src)/tools/
1325 1326
1326tools/%: FORCE 1327tools/%: FORCE
1327 $(Q)$(MAKE) LDFLAGS= MAKEFLAGS= -C $(src)/tools/ $* 1328 $(Q)mkdir -p $(objtree)/tools
1329 $(Q)$(MAKE) LDFLAGS= MAKEFLAGS= O=$(objtree) subdir=tools -C $(src)/tools/ $*
1328 1330
1329# Single targets 1331# Single targets
1330# --------------------------------------------------------------------------- 1332# ---------------------------------------------------------------------------
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index ade7e924bef5..9759fec0b704 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -547,6 +547,7 @@ config ARCH_KIRKWOOD
547 select CPU_FEROCEON 547 select CPU_FEROCEON
548 select GENERIC_CLOCKEVENTS 548 select GENERIC_CLOCKEVENTS
549 select PCI 549 select PCI
550 select PCI_QUIRKS
550 select PLAT_ORION_LEGACY 551 select PLAT_ORION_LEGACY
551 help 552 help
552 Support for the following Marvell Kirkwood series SoCs: 553 Support for the following Marvell Kirkwood series SoCs:
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index 90275f036cd1..49ca86e37b8d 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -652,6 +652,15 @@ __setup_mmu: sub r3, r4, #16384 @ Page directory size
652 mov pc, lr 652 mov pc, lr
653ENDPROC(__setup_mmu) 653ENDPROC(__setup_mmu)
654 654
655@ Enable unaligned access on v6, to allow better code generation
656@ for the decompressor C code:
657__armv6_mmu_cache_on:
658 mrc p15, 0, r0, c1, c0, 0 @ read SCTLR
659 bic r0, r0, #2 @ A (no unaligned access fault)
660 orr r0, r0, #1 << 22 @ U (v6 unaligned access model)
661 mcr p15, 0, r0, c1, c0, 0 @ write SCTLR
662 b __armv4_mmu_cache_on
663
655__arm926ejs_mmu_cache_on: 664__arm926ejs_mmu_cache_on:
656#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH 665#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
657 mov r0, #4 @ put dcache in WT mode 666 mov r0, #4 @ put dcache in WT mode
@@ -694,6 +703,9 @@ __armv7_mmu_cache_on:
694 bic r0, r0, #1 << 28 @ clear SCTLR.TRE 703 bic r0, r0, #1 << 28 @ clear SCTLR.TRE
695 orr r0, r0, #0x5000 @ I-cache enable, RR cache replacement 704 orr r0, r0, #0x5000 @ I-cache enable, RR cache replacement
696 orr r0, r0, #0x003c @ write buffer 705 orr r0, r0, #0x003c @ write buffer
706 bic r0, r0, #2 @ A (no unaligned access fault)
707 orr r0, r0, #1 << 22 @ U (v6 unaligned access model)
708 @ (needed for ARM1176)
697#ifdef CONFIG_MMU 709#ifdef CONFIG_MMU
698#ifdef CONFIG_CPU_ENDIAN_BE8 710#ifdef CONFIG_CPU_ENDIAN_BE8
699 orr r0, r0, #1 << 25 @ big-endian page tables 711 orr r0, r0, #1 << 25 @ big-endian page tables
@@ -914,7 +926,7 @@ proc_types:
914 926
915 .word 0x0007b000 @ ARMv6 927 .word 0x0007b000 @ ARMv6
916 .word 0x000ff000 928 .word 0x000ff000
917 W(b) __armv4_mmu_cache_on 929 W(b) __armv6_mmu_cache_on
918 W(b) __armv4_mmu_cache_off 930 W(b) __armv4_mmu_cache_off
919 W(b) __armv6_mmu_cache_flush 931 W(b) __armv6_mmu_cache_flush
920 932
diff --git a/arch/arm/common/timer-sp.c b/arch/arm/common/timer-sp.c
index df13a3ffff35..9d2d3ba339ff 100644
--- a/arch/arm/common/timer-sp.c
+++ b/arch/arm/common/timer-sp.c
@@ -162,7 +162,6 @@ static struct clock_event_device sp804_clockevent = {
162 .set_mode = sp804_set_mode, 162 .set_mode = sp804_set_mode,
163 .set_next_event = sp804_set_next_event, 163 .set_next_event = sp804_set_next_event,
164 .rating = 300, 164 .rating = 300,
165 .cpumask = cpu_all_mask,
166}; 165};
167 166
168static struct irqaction sp804_timer_irq = { 167static struct irqaction sp804_timer_irq = {
@@ -185,6 +184,7 @@ void __init sp804_clockevents_init(void __iomem *base, unsigned int irq,
185 clkevt_reload = DIV_ROUND_CLOSEST(rate, HZ); 184 clkevt_reload = DIV_ROUND_CLOSEST(rate, HZ);
186 evt->name = name; 185 evt->name = name;
187 evt->irq = irq; 186 evt->irq = irq;
187 evt->cpumask = cpu_possible_mask;
188 188
189 setup_irq(irq, &sp804_timer_irq); 189 setup_irq(irq, &sp804_timer_irq);
190 clockevents_config_and_register(evt, rate, 0xf, 0xffffffff); 190 clockevents_config_and_register(evt, rate, 0xf, 0xffffffff);
diff --git a/arch/arm/mach-dove/include/mach/pm.h b/arch/arm/mach-dove/include/mach/pm.h
index 7bcd0dfce4b1..b47f75038686 100644
--- a/arch/arm/mach-dove/include/mach/pm.h
+++ b/arch/arm/mach-dove/include/mach/pm.h
@@ -63,7 +63,7 @@ static inline int pmu_to_irq(int pin)
63 63
64static inline int irq_to_pmu(int irq) 64static inline int irq_to_pmu(int irq)
65{ 65{
66 if (IRQ_DOVE_PMU_START < irq && irq < NR_IRQS) 66 if (IRQ_DOVE_PMU_START <= irq && irq < NR_IRQS)
67 return irq - IRQ_DOVE_PMU_START; 67 return irq - IRQ_DOVE_PMU_START;
68 68
69 return -EINVAL; 69 return -EINVAL;
diff --git a/arch/arm/mach-dove/irq.c b/arch/arm/mach-dove/irq.c
index 087711524e8a..bc4344aa1009 100644
--- a/arch/arm/mach-dove/irq.c
+++ b/arch/arm/mach-dove/irq.c
@@ -46,8 +46,20 @@ static void pmu_irq_ack(struct irq_data *d)
46 int pin = irq_to_pmu(d->irq); 46 int pin = irq_to_pmu(d->irq);
47 u32 u; 47 u32 u;
48 48
49 /*
50 * The PMU mask register is not RW0C: it is RW. This means that
51 * the bits take whatever value is written to them; if you write
52 * a '1', you will set the interrupt.
53 *
54 * Unfortunately this means there is NO race free way to clear
55 * these interrupts.
56 *
57 * So, let's structure the code so that the window is as small as
58 * possible.
59 */
49 u = ~(1 << (pin & 31)); 60 u = ~(1 << (pin & 31));
50 writel(u, PMU_INTERRUPT_CAUSE); 61 u &= readl_relaxed(PMU_INTERRUPT_CAUSE);
62 writel_relaxed(u, PMU_INTERRUPT_CAUSE);
51} 63}
52 64
53static struct irq_chip pmu_irq_chip = { 65static struct irq_chip pmu_irq_chip = {
diff --git a/arch/arm/mach-ixp4xx/common-pci.c b/arch/arm/mach-ixp4xx/common-pci.c
index 1694f01ce2b6..6d6bde3e15fa 100644
--- a/arch/arm/mach-ixp4xx/common-pci.c
+++ b/arch/arm/mach-ixp4xx/common-pci.c
@@ -410,6 +410,7 @@ void __init ixp4xx_pci_preinit(void)
410 * Enable the IO window to be way up high, at 0xfffffc00 410 * Enable the IO window to be way up high, at 0xfffffc00
411 */ 411 */
412 local_write_config(PCI_BASE_ADDRESS_5, 4, 0xfffffc01); 412 local_write_config(PCI_BASE_ADDRESS_5, 4, 0xfffffc01);
413 local_write_config(0x40, 4, 0x000080FF); /* No TRDY time limit */
413 } else { 414 } else {
414 printk("PCI: IXP4xx is target - No bus scan performed\n"); 415 printk("PCI: IXP4xx is target - No bus scan performed\n");
415 } 416 }
diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c
index fdf91a160884..8c0c0e2d0727 100644
--- a/arch/arm/mach-ixp4xx/common.c
+++ b/arch/arm/mach-ixp4xx/common.c
@@ -67,15 +67,12 @@ static struct map_desc ixp4xx_io_desc[] __initdata = {
67 .pfn = __phys_to_pfn(IXP4XX_PCI_CFG_BASE_PHYS), 67 .pfn = __phys_to_pfn(IXP4XX_PCI_CFG_BASE_PHYS),
68 .length = IXP4XX_PCI_CFG_REGION_SIZE, 68 .length = IXP4XX_PCI_CFG_REGION_SIZE,
69 .type = MT_DEVICE 69 .type = MT_DEVICE
70 }, 70 }, { /* Queue Manager */
71#ifdef CONFIG_DEBUG_LL 71 .virtual = (unsigned long)IXP4XX_QMGR_BASE_VIRT,
72 { /* Debug UART mapping */ 72 .pfn = __phys_to_pfn(IXP4XX_QMGR_BASE_PHYS),
73 .virtual = (unsigned long)IXP4XX_DEBUG_UART_BASE_VIRT, 73 .length = IXP4XX_QMGR_REGION_SIZE,
74 .pfn = __phys_to_pfn(IXP4XX_DEBUG_UART_BASE_PHYS),
75 .length = IXP4XX_DEBUG_UART_REGION_SIZE,
76 .type = MT_DEVICE 74 .type = MT_DEVICE
77 } 75 },
78#endif
79}; 76};
80 77
81void __init ixp4xx_map_io(void) 78void __init ixp4xx_map_io(void)
diff --git a/arch/arm/mach-ixp4xx/goramo_mlr.c b/arch/arm/mach-ixp4xx/goramo_mlr.c
index b800a031207c..53b8348dfcc2 100644
--- a/arch/arm/mach-ixp4xx/goramo_mlr.c
+++ b/arch/arm/mach-ixp4xx/goramo_mlr.c
@@ -15,6 +15,7 @@
15#include <asm/mach/arch.h> 15#include <asm/mach/arch.h>
16#include <asm/mach/flash.h> 16#include <asm/mach/flash.h>
17#include <asm/mach/pci.h> 17#include <asm/mach/pci.h>
18#include <asm/system_info.h>
18 19
19#define SLOT_ETHA 0x0B /* IDSEL = AD21 */ 20#define SLOT_ETHA 0x0B /* IDSEL = AD21 */
20#define SLOT_ETHB 0x0C /* IDSEL = AD20 */ 21#define SLOT_ETHB 0x0C /* IDSEL = AD20 */
@@ -329,7 +330,7 @@ static struct platform_device device_hss_tab[] = {
329}; 330};
330 331
331 332
332static struct platform_device *device_tab[6] __initdata = { 333static struct platform_device *device_tab[7] __initdata = {
333 &device_flash, /* index 0 */ 334 &device_flash, /* index 0 */
334}; 335};
335 336
diff --git a/arch/arm/mach-ixp4xx/include/mach/debug-macro.S b/arch/arm/mach-ixp4xx/include/mach/debug-macro.S
index 8c9f8d564492..ff686cbc5df4 100644
--- a/arch/arm/mach-ixp4xx/include/mach/debug-macro.S
+++ b/arch/arm/mach-ixp4xx/include/mach/debug-macro.S
@@ -17,8 +17,8 @@
17#else 17#else
18 mov \rp, #0 18 mov \rp, #0
19#endif 19#endif
20 orr \rv, \rp, #0xff000000 @ virtual 20 orr \rv, \rp, #0xfe000000 @ virtual
21 orr \rv, \rv, #0x00b00000 21 orr \rv, \rv, #0x00f00000
22 orr \rp, \rp, #0xc8000000 @ physical 22 orr \rp, \rp, #0xc8000000 @ physical
23 .endm 23 .endm
24 24
diff --git a/arch/arm/mach-ixp4xx/include/mach/ixp4xx-regs.h b/arch/arm/mach-ixp4xx/include/mach/ixp4xx-regs.h
index eb68b61ce975..c5bae9c035d5 100644
--- a/arch/arm/mach-ixp4xx/include/mach/ixp4xx-regs.h
+++ b/arch/arm/mach-ixp4xx/include/mach/ixp4xx-regs.h
@@ -30,51 +30,43 @@
30 * 30 *
31 * 0x50000000 0x10000000 ioremap'd EXP BUS 31 * 0x50000000 0x10000000 ioremap'd EXP BUS
32 * 32 *
33 * 0x6000000 0x00004000 ioremap'd QMgr 33 * 0xC8000000 0x00013000 0xFEF00000 On-Chip Peripherals
34 * 34 *
35 * 0xC0000000 0x00001000 0xffbff000 PCI CFG 35 * 0xC0000000 0x00001000 0xFEF13000 PCI CFG
36 * 36 *
37 * 0xC4000000 0x00001000 0xffbfe000 EXP CFG 37 * 0xC4000000 0x00001000 0xFEF14000 EXP CFG
38 * 38 *
39 * 0xC8000000 0x00013000 0xffbeb000 On-Chip Peripherals 39 * 0x60000000 0x00004000 0xFEF15000 QMgr
40 */ 40 */
41 41
42/* 42/*
43 * Queue Manager 43 * Queue Manager
44 */ 44 */
45#define IXP4XX_QMGR_BASE_PHYS (0x60000000) 45#define IXP4XX_QMGR_BASE_PHYS 0x60000000
46#define IXP4XX_QMGR_REGION_SIZE (0x00004000) 46#define IXP4XX_QMGR_BASE_VIRT IOMEM(0xFEF15000)
47#define IXP4XX_QMGR_REGION_SIZE 0x00004000
47 48
48/* 49/*
49 * Expansion BUS Configuration registers 50 * Peripheral space, including debug UART. Must be section-aligned so that
51 * it can be used with the low-level debug code.
50 */ 52 */
51#define IXP4XX_EXP_CFG_BASE_PHYS (0xC4000000) 53#define IXP4XX_PERIPHERAL_BASE_PHYS 0xC8000000
52#define IXP4XX_EXP_CFG_BASE_VIRT IOMEM(0xFFBFE000) 54#define IXP4XX_PERIPHERAL_BASE_VIRT IOMEM(0xFEF00000)
53#define IXP4XX_EXP_CFG_REGION_SIZE (0x00001000) 55#define IXP4XX_PERIPHERAL_REGION_SIZE 0x00013000
54 56
55/* 57/*
56 * PCI Config registers 58 * PCI Config registers
57 */ 59 */
58#define IXP4XX_PCI_CFG_BASE_PHYS (0xC0000000) 60#define IXP4XX_PCI_CFG_BASE_PHYS 0xC0000000
59#define IXP4XX_PCI_CFG_BASE_VIRT IOMEM(0xFFBFF000) 61#define IXP4XX_PCI_CFG_BASE_VIRT IOMEM(0xFEF13000)
60#define IXP4XX_PCI_CFG_REGION_SIZE (0x00001000) 62#define IXP4XX_PCI_CFG_REGION_SIZE 0x00001000
61
62/*
63 * Peripheral space
64 */
65#define IXP4XX_PERIPHERAL_BASE_PHYS (0xC8000000)
66#define IXP4XX_PERIPHERAL_BASE_VIRT IOMEM(0xFFBEB000)
67#define IXP4XX_PERIPHERAL_REGION_SIZE (0x00013000)
68 63
69/* 64/*
70 * Debug UART 65 * Expansion BUS Configuration registers
71 *
72 * This is basically a remap of UART1 into a region that is section
73 * aligned so that it * can be used with the low-level debug code.
74 */ 66 */
75#define IXP4XX_DEBUG_UART_BASE_PHYS (0xC8000000) 67#define IXP4XX_EXP_CFG_BASE_PHYS 0xC4000000
76#define IXP4XX_DEBUG_UART_BASE_VIRT IOMEM(0xffb00000) 68#define IXP4XX_EXP_CFG_BASE_VIRT 0xFEF14000
77#define IXP4XX_DEBUG_UART_REGION_SIZE (0x00001000) 69#define IXP4XX_EXP_CFG_REGION_SIZE 0x00001000
78 70
79#define IXP4XX_EXP_CS0_OFFSET 0x00 71#define IXP4XX_EXP_CS0_OFFSET 0x00
80#define IXP4XX_EXP_CS1_OFFSET 0x04 72#define IXP4XX_EXP_CS1_OFFSET 0x04
diff --git a/arch/arm/mach-ixp4xx/include/mach/qmgr.h b/arch/arm/mach-ixp4xx/include/mach/qmgr.h
index 9e7cad2d54cb..4de8da536dbb 100644
--- a/arch/arm/mach-ixp4xx/include/mach/qmgr.h
+++ b/arch/arm/mach-ixp4xx/include/mach/qmgr.h
@@ -86,7 +86,7 @@ void qmgr_release_queue(unsigned int queue);
86 86
87static inline void qmgr_put_entry(unsigned int queue, u32 val) 87static inline void qmgr_put_entry(unsigned int queue, u32 val)
88{ 88{
89 extern struct qmgr_regs __iomem *qmgr_regs; 89 struct qmgr_regs __iomem *qmgr_regs = IXP4XX_QMGR_BASE_VIRT;
90#if DEBUG_QMGR 90#if DEBUG_QMGR
91 BUG_ON(!qmgr_queue_descs[queue]); /* not yet requested */ 91 BUG_ON(!qmgr_queue_descs[queue]); /* not yet requested */
92 92
@@ -99,7 +99,7 @@ static inline void qmgr_put_entry(unsigned int queue, u32 val)
99static inline u32 qmgr_get_entry(unsigned int queue) 99static inline u32 qmgr_get_entry(unsigned int queue)
100{ 100{
101 u32 val; 101 u32 val;
102 extern struct qmgr_regs __iomem *qmgr_regs; 102 const struct qmgr_regs __iomem *qmgr_regs = IXP4XX_QMGR_BASE_VIRT;
103 val = __raw_readl(&qmgr_regs->acc[queue][0]); 103 val = __raw_readl(&qmgr_regs->acc[queue][0]);
104#if DEBUG_QMGR 104#if DEBUG_QMGR
105 BUG_ON(!qmgr_queue_descs[queue]); /* not yet requested */ 105 BUG_ON(!qmgr_queue_descs[queue]); /* not yet requested */
@@ -112,14 +112,14 @@ static inline u32 qmgr_get_entry(unsigned int queue)
112 112
113static inline int __qmgr_get_stat1(unsigned int queue) 113static inline int __qmgr_get_stat1(unsigned int queue)
114{ 114{
115 extern struct qmgr_regs __iomem *qmgr_regs; 115 const struct qmgr_regs __iomem *qmgr_regs = IXP4XX_QMGR_BASE_VIRT;
116 return (__raw_readl(&qmgr_regs->stat1[queue >> 3]) 116 return (__raw_readl(&qmgr_regs->stat1[queue >> 3])
117 >> ((queue & 7) << 2)) & 0xF; 117 >> ((queue & 7) << 2)) & 0xF;
118} 118}
119 119
120static inline int __qmgr_get_stat2(unsigned int queue) 120static inline int __qmgr_get_stat2(unsigned int queue)
121{ 121{
122 extern struct qmgr_regs __iomem *qmgr_regs; 122 const struct qmgr_regs __iomem *qmgr_regs = IXP4XX_QMGR_BASE_VIRT;
123 BUG_ON(queue >= HALF_QUEUES); 123 BUG_ON(queue >= HALF_QUEUES);
124 return (__raw_readl(&qmgr_regs->stat2[queue >> 4]) 124 return (__raw_readl(&qmgr_regs->stat2[queue >> 4])
125 >> ((queue & 0xF) << 1)) & 0x3; 125 >> ((queue & 0xF) << 1)) & 0x3;
@@ -145,7 +145,7 @@ static inline int qmgr_stat_empty(unsigned int queue)
145 */ 145 */
146static inline int qmgr_stat_below_low_watermark(unsigned int queue) 146static inline int qmgr_stat_below_low_watermark(unsigned int queue)
147{ 147{
148 extern struct qmgr_regs __iomem *qmgr_regs; 148 const struct qmgr_regs __iomem *qmgr_regs = IXP4XX_QMGR_BASE_VIRT;
149 if (queue >= HALF_QUEUES) 149 if (queue >= HALF_QUEUES)
150 return (__raw_readl(&qmgr_regs->statne_h) >> 150 return (__raw_readl(&qmgr_regs->statne_h) >>
151 (queue - HALF_QUEUES)) & 0x01; 151 (queue - HALF_QUEUES)) & 0x01;
@@ -172,7 +172,7 @@ static inline int qmgr_stat_above_high_watermark(unsigned int queue)
172 */ 172 */
173static inline int qmgr_stat_full(unsigned int queue) 173static inline int qmgr_stat_full(unsigned int queue)
174{ 174{
175 extern struct qmgr_regs __iomem *qmgr_regs; 175 const struct qmgr_regs __iomem *qmgr_regs = IXP4XX_QMGR_BASE_VIRT;
176 if (queue >= HALF_QUEUES) 176 if (queue >= HALF_QUEUES)
177 return (__raw_readl(&qmgr_regs->statf_h) >> 177 return (__raw_readl(&qmgr_regs->statf_h) >>
178 (queue - HALF_QUEUES)) & 0x01; 178 (queue - HALF_QUEUES)) & 0x01;
diff --git a/arch/arm/mach-ixp4xx/ixp4xx_npe.c b/arch/arm/mach-ixp4xx/ixp4xx_npe.c
index a17ed79207a4..d4eb09a62863 100644
--- a/arch/arm/mach-ixp4xx/ixp4xx_npe.c
+++ b/arch/arm/mach-ixp4xx/ixp4xx_npe.c
@@ -116,7 +116,11 @@
116/* NPE mailbox_status value for reset */ 116/* NPE mailbox_status value for reset */
117#define RESET_MBOX_STAT 0x0000F0F0 117#define RESET_MBOX_STAT 0x0000F0F0
118 118
119const char *npe_names[] = { "NPE-A", "NPE-B", "NPE-C" }; 119#define NPE_A_FIRMWARE "NPE-A"
120#define NPE_B_FIRMWARE "NPE-B"
121#define NPE_C_FIRMWARE "NPE-C"
122
123const char *npe_names[] = { NPE_A_FIRMWARE, NPE_B_FIRMWARE, NPE_C_FIRMWARE };
120 124
121#define print_npe(pri, npe, fmt, ...) \ 125#define print_npe(pri, npe, fmt, ...) \
122 printk(pri "%s: " fmt, npe_name(npe), ## __VA_ARGS__) 126 printk(pri "%s: " fmt, npe_name(npe), ## __VA_ARGS__)
@@ -724,6 +728,9 @@ module_exit(npe_cleanup_module);
724 728
725MODULE_AUTHOR("Krzysztof Halasa"); 729MODULE_AUTHOR("Krzysztof Halasa");
726MODULE_LICENSE("GPL v2"); 730MODULE_LICENSE("GPL v2");
731MODULE_FIRMWARE(NPE_A_FIRMWARE);
732MODULE_FIRMWARE(NPE_B_FIRMWARE);
733MODULE_FIRMWARE(NPE_C_FIRMWARE);
727 734
728EXPORT_SYMBOL(npe_names); 735EXPORT_SYMBOL(npe_names);
729EXPORT_SYMBOL(npe_running); 736EXPORT_SYMBOL(npe_running);
diff --git a/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c b/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c
index 852f7c9f87d0..9d1b6b7c394c 100644
--- a/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c
+++ b/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c
@@ -14,7 +14,7 @@
14#include <linux/module.h> 14#include <linux/module.h>
15#include <mach/qmgr.h> 15#include <mach/qmgr.h>
16 16
17struct qmgr_regs __iomem *qmgr_regs; 17static struct qmgr_regs __iomem *qmgr_regs = IXP4XX_QMGR_BASE_VIRT;
18static struct resource *mem_res; 18static struct resource *mem_res;
19static spinlock_t qmgr_lock; 19static spinlock_t qmgr_lock;
20static u32 used_sram_bitmap[4]; /* 128 16-dword pages */ 20static u32 used_sram_bitmap[4]; /* 128 16-dword pages */
@@ -293,12 +293,6 @@ static int qmgr_init(void)
293 if (mem_res == NULL) 293 if (mem_res == NULL)
294 return -EBUSY; 294 return -EBUSY;
295 295
296 qmgr_regs = ioremap(IXP4XX_QMGR_BASE_PHYS, IXP4XX_QMGR_REGION_SIZE);
297 if (qmgr_regs == NULL) {
298 err = -ENOMEM;
299 goto error_map;
300 }
301
302 /* reset qmgr registers */ 296 /* reset qmgr registers */
303 for (i = 0; i < 4; i++) { 297 for (i = 0; i < 4; i++) {
304 __raw_writel(0x33333333, &qmgr_regs->stat1[i]); 298 __raw_writel(0x33333333, &qmgr_regs->stat1[i]);
@@ -347,8 +341,6 @@ static int qmgr_init(void)
347error_irq2: 341error_irq2:
348 free_irq(IRQ_IXP4XX_QM1, NULL); 342 free_irq(IRQ_IXP4XX_QM1, NULL);
349error_irq: 343error_irq:
350 iounmap(qmgr_regs);
351error_map:
352 release_mem_region(IXP4XX_QMGR_BASE_PHYS, IXP4XX_QMGR_REGION_SIZE); 344 release_mem_region(IXP4XX_QMGR_BASE_PHYS, IXP4XX_QMGR_REGION_SIZE);
353 return err; 345 return err;
354} 346}
@@ -359,7 +351,6 @@ static void qmgr_remove(void)
359 free_irq(IRQ_IXP4XX_QM2, NULL); 351 free_irq(IRQ_IXP4XX_QM2, NULL);
360 synchronize_irq(IRQ_IXP4XX_QM1); 352 synchronize_irq(IRQ_IXP4XX_QM1);
361 synchronize_irq(IRQ_IXP4XX_QM2); 353 synchronize_irq(IRQ_IXP4XX_QM2);
362 iounmap(qmgr_regs);
363 release_mem_region(IXP4XX_QMGR_BASE_PHYS, IXP4XX_QMGR_REGION_SIZE); 354 release_mem_region(IXP4XX_QMGR_BASE_PHYS, IXP4XX_QMGR_REGION_SIZE);
364} 355}
365 356
@@ -369,7 +360,6 @@ module_exit(qmgr_remove);
369MODULE_LICENSE("GPL v2"); 360MODULE_LICENSE("GPL v2");
370MODULE_AUTHOR("Krzysztof Halasa"); 361MODULE_AUTHOR("Krzysztof Halasa");
371 362
372EXPORT_SYMBOL(qmgr_regs);
373EXPORT_SYMBOL(qmgr_set_irq); 363EXPORT_SYMBOL(qmgr_set_irq);
374EXPORT_SYMBOL(qmgr_enable_irq); 364EXPORT_SYMBOL(qmgr_enable_irq);
375EXPORT_SYMBOL(qmgr_disable_irq); 365EXPORT_SYMBOL(qmgr_disable_irq);
diff --git a/arch/arm/mach-kirkwood/pcie.c b/arch/arm/mach-kirkwood/pcie.c
index ec544918b12c..74fc5a074fc4 100644
--- a/arch/arm/mach-kirkwood/pcie.c
+++ b/arch/arm/mach-kirkwood/pcie.c
@@ -207,14 +207,19 @@ static int __init kirkwood_pcie_setup(int nr, struct pci_sys_data *sys)
207 return 1; 207 return 1;
208} 208}
209 209
210/*
211 * The root complex has a hardwired class of PCI_CLASS_MEMORY_OTHER, when it
212 * is operating as a root complex this needs to be switched to
213 * PCI_CLASS_BRIDGE_HOST or Linux will errantly try to process the BAR's on
214 * the device. Decoding setup is handled by the orion code.
215 */
210static void __devinit rc_pci_fixup(struct pci_dev *dev) 216static void __devinit rc_pci_fixup(struct pci_dev *dev)
211{ 217{
212 /*
213 * Prevent enumeration of root complex.
214 */
215 if (dev->bus->parent == NULL && dev->devfn == 0) { 218 if (dev->bus->parent == NULL && dev->devfn == 0) {
216 int i; 219 int i;
217 220
221 dev->class &= 0xff;
222 dev->class |= PCI_CLASS_BRIDGE_HOST << 8;
218 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 223 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
219 dev->resource[i].start = 0; 224 dev->resource[i].start = 0;
220 dev->resource[i].end = 0; 225 dev->resource[i].end = 0;
diff --git a/arch/arm/mm/proc-v6.S b/arch/arm/mm/proc-v6.S
index 86b8b480634f..09c5233f4dfc 100644
--- a/arch/arm/mm/proc-v6.S
+++ b/arch/arm/mm/proc-v6.S
@@ -89,7 +89,7 @@ ENTRY(cpu_v6_dcache_clean_area)
89 mov pc, lr 89 mov pc, lr
90 90
91/* 91/*
92 * cpu_arm926_switch_mm(pgd_phys, tsk) 92 * cpu_v6_switch_mm(pgd_phys, tsk)
93 * 93 *
94 * Set the translation table base pointer to be pgd_phys 94 * Set the translation table base pointer to be pgd_phys
95 * 95 *
diff --git a/arch/arm/plat-s3c24xx/dma.c b/arch/arm/plat-s3c24xx/dma.c
index db98e7021f0d..0abd1c469887 100644
--- a/arch/arm/plat-s3c24xx/dma.c
+++ b/arch/arm/plat-s3c24xx/dma.c
@@ -473,12 +473,13 @@ int s3c2410_dma_enqueue(enum dma_ch channel, void *id,
473 pr_debug("dma%d: %s: buffer %p queued onto non-empty channel\n", 473 pr_debug("dma%d: %s: buffer %p queued onto non-empty channel\n",
474 chan->number, __func__, buf); 474 chan->number, __func__, buf);
475 475
476 if (chan->end == NULL) 476 if (chan->end == NULL) {
477 pr_debug("dma%d: %s: %p not empty, and chan->end==NULL?\n", 477 pr_debug("dma%d: %s: %p not empty, and chan->end==NULL?\n",
478 chan->number, __func__, chan); 478 chan->number, __func__, chan);
479 479 } else {
480 chan->end->next = buf; 480 chan->end->next = buf;
481 chan->end = buf; 481 chan->end = buf;
482 }
482 } 483 }
483 484
484 /* if necessary, update the next buffer field */ 485 /* if necessary, update the next buffer field */
diff --git a/arch/arm64/include/asm/unistd32.h b/arch/arm64/include/asm/unistd32.h
index 6d909faebf28..656a6f291a35 100644
--- a/arch/arm64/include/asm/unistd32.h
+++ b/arch/arm64/include/asm/unistd32.h
@@ -392,7 +392,7 @@ __SYSCALL(367, sys_fanotify_init)
392__SYSCALL(368, compat_sys_fanotify_mark_wrapper) 392__SYSCALL(368, compat_sys_fanotify_mark_wrapper)
393__SYSCALL(369, sys_prlimit64) 393__SYSCALL(369, sys_prlimit64)
394__SYSCALL(370, sys_name_to_handle_at) 394__SYSCALL(370, sys_name_to_handle_at)
395__SYSCALL(371, sys_open_by_handle_at) 395__SYSCALL(371, compat_sys_open_by_handle_at)
396__SYSCALL(372, sys_clock_adjtime) 396__SYSCALL(372, sys_clock_adjtime)
397__SYSCALL(373, sys_syncfs) 397__SYSCALL(373, sys_syncfs)
398 398
diff --git a/arch/c6x/include/asm/setup.h b/arch/c6x/include/asm/setup.h
new file mode 100644
index 000000000000..ecead15872a6
--- /dev/null
+++ b/arch/c6x/include/asm/setup.h
@@ -0,0 +1,33 @@
1/*
2 * Port on Texas Instruments TMS320C6x architecture
3 *
4 * Copyright (C) 2004, 2009, 2010 2011 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef _ASM_C6X_SETUP_H
12#define _ASM_C6X_SETUP_H
13
14#include <uapi/asm/setup.h>
15
16#ifndef __ASSEMBLY__
17extern char c6x_command_line[COMMAND_LINE_SIZE];
18
19extern int c6x_add_memory(phys_addr_t start, unsigned long size);
20
21extern unsigned long ram_start;
22extern unsigned long ram_end;
23
24extern int c6x_num_cores;
25extern unsigned int c6x_silicon_rev;
26extern unsigned int c6x_devstat;
27extern unsigned char c6x_fuse_mac[6];
28
29extern void machine_init(unsigned long dt_ptr);
30extern void time_init(void);
31
32#endif /* !__ASSEMBLY__ */
33#endif /* _ASM_C6X_SETUP_H */
diff --git a/arch/c6x/include/uapi/asm/Kbuild b/arch/c6x/include/uapi/asm/Kbuild
index c312b424c433..e9bc2b2b8147 100644
--- a/arch/c6x/include/uapi/asm/Kbuild
+++ b/arch/c6x/include/uapi/asm/Kbuild
@@ -1,6 +1,8 @@
1# UAPI Header export list 1# UAPI Header export list
2include include/uapi/asm-generic/Kbuild.asm 2include include/uapi/asm-generic/Kbuild.asm
3 3
4generic-y += kvm_para.h
5
4header-y += byteorder.h 6header-y += byteorder.h
5header-y += kvm_para.h 7header-y += kvm_para.h
6header-y += ptrace.h 8header-y += ptrace.h
diff --git a/arch/c6x/include/uapi/asm/kvm_para.h b/arch/c6x/include/uapi/asm/kvm_para.h
deleted file mode 100644
index 14fab8f0b957..000000000000
--- a/arch/c6x/include/uapi/asm/kvm_para.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/kvm_para.h>
diff --git a/arch/c6x/include/uapi/asm/setup.h b/arch/c6x/include/uapi/asm/setup.h
index a01e31896fa9..ad9ac97a8dad 100644
--- a/arch/c6x/include/uapi/asm/setup.h
+++ b/arch/c6x/include/uapi/asm/setup.h
@@ -1,33 +1,6 @@
1/* 1#ifndef _UAPI_ASM_C6X_SETUP_H
2 * Port on Texas Instruments TMS320C6x architecture 2#define _UAPI_ASM_C6X_SETUP_H
3 *
4 * Copyright (C) 2004, 2009, 2010 2011 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef _ASM_C6X_SETUP_H
12#define _ASM_C6X_SETUP_H
13 3
14#define COMMAND_LINE_SIZE 1024 4#define COMMAND_LINE_SIZE 1024
15 5
16#ifndef __ASSEMBLY__ 6#endif /* _UAPI_ASM_C6X_SETUP_H */
17extern char c6x_command_line[COMMAND_LINE_SIZE];
18
19extern int c6x_add_memory(phys_addr_t start, unsigned long size);
20
21extern unsigned long ram_start;
22extern unsigned long ram_end;
23
24extern int c6x_num_cores;
25extern unsigned int c6x_silicon_rev;
26extern unsigned int c6x_devstat;
27extern unsigned char c6x_fuse_mac[6];
28
29extern void machine_init(unsigned long dt_ptr);
30extern void time_init(void);
31
32#endif /* !__ASSEMBLY__ */
33#endif /* _ASM_C6X_SETUP_H */
diff --git a/arch/c6x/kernel/entry.S b/arch/c6x/kernel/entry.S
index 5449c36018fe..0ed6157dd256 100644
--- a/arch/c6x/kernel/entry.S
+++ b/arch/c6x/kernel/entry.S
@@ -277,6 +277,8 @@ work_rescheduled:
277 [A1] BNOP .S1 work_resched,5 277 [A1] BNOP .S1 work_resched,5
278 278
279work_notifysig: 279work_notifysig:
280 ;; enable interrupts for do_notify_resume()
281 UNMASK_INT B2
280 B .S2 do_notify_resume 282 B .S2 do_notify_resume
281 LDW .D2T1 *+SP(REGS__END+8),A6 ; syscall flag 283 LDW .D2T1 *+SP(REGS__END+8),A6 ; syscall flag
282 ADDKPC .S2 resume_userspace,B3,1 284 ADDKPC .S2 resume_userspace,B3,1
@@ -427,8 +429,7 @@ ENTRY(ret_from_kernel_execve)
427ENDPROC(ret_from_kernel_execve) 429ENDPROC(ret_from_kernel_execve)
428 430
429 ;; 431 ;;
430 ;; These are the interrupt handlers, responsible for calling __do_IRQ() 432 ;; These are the interrupt handlers, responsible for calling c6x_do_IRQ()
431 ;; int6 is used for syscalls (see _system_call entry)
432 ;; 433 ;;
433 .macro SAVE_ALL_INT 434 .macro SAVE_ALL_INT
434 SAVE_ALL IRP,ITSR 435 SAVE_ALL IRP,ITSR
diff --git a/arch/microblaze/kernel/signal.c b/arch/microblaze/kernel/signal.c
index 3847e5b9c601..3903e3d11f5a 100644
--- a/arch/microblaze/kernel/signal.c
+++ b/arch/microblaze/kernel/signal.c
@@ -111,7 +111,7 @@ asmlinkage long sys_rt_sigreturn(struct pt_regs *regs)
111 111
112 /* It is more difficult to avoid calling this function than to 112 /* It is more difficult to avoid calling this function than to
113 call it and ignore errors. */ 113 call it and ignore errors. */
114 if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->r1)) 114 if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->r1) == -EFAULT)
115 goto badframe; 115 goto badframe;
116 116
117 return rval; 117 return rval;
diff --git a/arch/mips/include/asm/hugetlb.h b/arch/mips/include/asm/hugetlb.h
index bd94946a18f3..ef99db994c2f 100644
--- a/arch/mips/include/asm/hugetlb.h
+++ b/arch/mips/include/asm/hugetlb.h
@@ -95,7 +95,17 @@ static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
95 pte_t *ptep, pte_t pte, 95 pte_t *ptep, pte_t pte,
96 int dirty) 96 int dirty)
97{ 97{
98 return ptep_set_access_flags(vma, addr, ptep, pte, dirty); 98 int changed = !pte_same(*ptep, pte);
99
100 if (changed) {
101 set_pte_at(vma->vm_mm, addr, ptep, pte);
102 /*
103 * There could be some standard sized pages in there,
104 * get them all.
105 */
106 flush_tlb_range(vma, addr, addr + HPAGE_SIZE);
107 }
108 return changed;
99} 109}
100 110
101static inline pte_t huge_ptep_get(pte_t *ptep) 111static inline pte_t huge_ptep_get(pte_t *ptep)
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index b1fb7af3c350..cce3782c96c9 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -510,7 +510,6 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
510 c->cputype = CPU_R3000A; 510 c->cputype = CPU_R3000A;
511 __cpu_name[cpu] = "R3000A"; 511 __cpu_name[cpu] = "R3000A";
512 } 512 }
513 break;
514 } else { 513 } else {
515 c->cputype = CPU_R3000; 514 c->cputype = CPU_R3000;
516 __cpu_name[cpu] = "R3000"; 515 __cpu_name[cpu] = "R3000";
diff --git a/arch/mips/kernel/entry.S b/arch/mips/kernel/entry.S
index a6c133212003..9b00362f32f6 100644
--- a/arch/mips/kernel/entry.S
+++ b/arch/mips/kernel/entry.S
@@ -36,6 +36,11 @@ FEXPORT(ret_from_exception)
36FEXPORT(ret_from_irq) 36FEXPORT(ret_from_irq)
37 LONG_S s0, TI_REGS($28) 37 LONG_S s0, TI_REGS($28)
38FEXPORT(__ret_from_irq) 38FEXPORT(__ret_from_irq)
39/*
40 * We can be coming here from a syscall done in the kernel space,
41 * e.g. a failed kernel_execve().
42 */
43resume_userspace_check:
39 LONG_L t0, PT_STATUS(sp) # returning to kernel mode? 44 LONG_L t0, PT_STATUS(sp) # returning to kernel mode?
40 andi t0, t0, KU_USER 45 andi t0, t0, KU_USER
41 beqz t0, resume_kernel 46 beqz t0, resume_kernel
@@ -162,7 +167,7 @@ work_notifysig: # deal with pending signals and
162 move a0, sp 167 move a0, sp
163 li a1, 0 168 li a1, 0
164 jal do_notify_resume # a2 already loaded 169 jal do_notify_resume # a2 already loaded
165 j resume_userspace 170 j resume_userspace_check
166 171
167FEXPORT(syscall_exit_partial) 172FEXPORT(syscall_exit_partial)
168 local_irq_disable # make sure need_resched doesn't 173 local_irq_disable # make sure need_resched doesn't
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index f6ba8381ee01..86ec03f0e00c 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -397,14 +397,14 @@ EXPORT(sysn32_call_table)
397 PTR sys_timerfd_create 397 PTR sys_timerfd_create
398 PTR compat_sys_timerfd_gettime /* 6285 */ 398 PTR compat_sys_timerfd_gettime /* 6285 */
399 PTR compat_sys_timerfd_settime 399 PTR compat_sys_timerfd_settime
400 PTR sys_signalfd4 400 PTR compat_sys_signalfd4
401 PTR sys_eventfd2 401 PTR sys_eventfd2
402 PTR sys_epoll_create1 402 PTR sys_epoll_create1
403 PTR sys_dup3 /* 6290 */ 403 PTR sys_dup3 /* 6290 */
404 PTR sys_pipe2 404 PTR sys_pipe2
405 PTR sys_inotify_init1 405 PTR sys_inotify_init1
406 PTR sys_preadv 406 PTR compat_sys_preadv
407 PTR sys_pwritev 407 PTR compat_sys_pwritev
408 PTR compat_sys_rt_tgsigqueueinfo /* 6295 */ 408 PTR compat_sys_rt_tgsigqueueinfo /* 6295 */
409 PTR sys_perf_event_open 409 PTR sys_perf_event_open
410 PTR sys_accept4 410 PTR sys_accept4
diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c
index 4b9b935a070e..88e79ad6f811 100644
--- a/arch/mips/mm/tlb-r4k.c
+++ b/arch/mips/mm/tlb-r4k.c
@@ -120,18 +120,11 @@ void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
120 120
121 if (cpu_context(cpu, mm) != 0) { 121 if (cpu_context(cpu, mm) != 0) {
122 unsigned long size, flags; 122 unsigned long size, flags;
123 int huge = is_vm_hugetlb_page(vma);
124 123
125 ENTER_CRITICAL(flags); 124 ENTER_CRITICAL(flags);
126 if (huge) { 125 start = round_down(start, PAGE_SIZE << 1);
127 start = round_down(start, HPAGE_SIZE); 126 end = round_up(end, PAGE_SIZE << 1);
128 end = round_up(end, HPAGE_SIZE); 127 size = (end - start) >> (PAGE_SHIFT + 1);
129 size = (end - start) >> HPAGE_SHIFT;
130 } else {
131 start = round_down(start, PAGE_SIZE << 1);
132 end = round_up(end, PAGE_SIZE << 1);
133 size = (end - start) >> (PAGE_SHIFT + 1);
134 }
135 if (size <= current_cpu_data.tlbsize/2) { 128 if (size <= current_cpu_data.tlbsize/2) {
136 int oldpid = read_c0_entryhi(); 129 int oldpid = read_c0_entryhi();
137 int newpid = cpu_asid(cpu, mm); 130 int newpid = cpu_asid(cpu, mm);
@@ -140,10 +133,7 @@ void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
140 int idx; 133 int idx;
141 134
142 write_c0_entryhi(start | newpid); 135 write_c0_entryhi(start | newpid);
143 if (huge) 136 start += (PAGE_SIZE << 1);
144 start += HPAGE_SIZE;
145 else
146 start += (PAGE_SIZE << 1);
147 mtc0_tlbw_hazard(); 137 mtc0_tlbw_hazard();
148 tlb_probe(); 138 tlb_probe();
149 tlb_probe_hazard(); 139 tlb_probe_hazard();
diff --git a/arch/openrisc/kernel/signal.c b/arch/openrisc/kernel/signal.c
index 30110297f4f9..ddedc8a77861 100644
--- a/arch/openrisc/kernel/signal.c
+++ b/arch/openrisc/kernel/signal.c
@@ -84,7 +84,6 @@ asmlinkage long _sys_rt_sigreturn(struct pt_regs *regs)
84{ 84{
85 struct rt_sigframe *frame = (struct rt_sigframe __user *)regs->sp; 85 struct rt_sigframe *frame = (struct rt_sigframe __user *)regs->sp;
86 sigset_t set; 86 sigset_t set;
87 stack_t st;
88 87
89 /* 88 /*
90 * Since we stacked the signal on a dword boundary, 89 * Since we stacked the signal on a dword boundary,
@@ -104,11 +103,10 @@ asmlinkage long _sys_rt_sigreturn(struct pt_regs *regs)
104 if (restore_sigcontext(regs, &frame->uc.uc_mcontext)) 103 if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
105 goto badframe; 104 goto badframe;
106 105
107 if (__copy_from_user(&st, &frame->uc.uc_stack, sizeof(st)))
108 goto badframe;
109 /* It is more difficult to avoid calling this function than to 106 /* It is more difficult to avoid calling this function than to
110 call it and ignore errors. */ 107 call it and ignore errors. */
111 do_sigaltstack(&st, NULL, regs->sp); 108 if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->sp) == -EFAULT)
109 goto badframe;
112 110
113 return regs->gpr[11]; 111 return regs->gpr[11];
114 112
diff --git a/arch/parisc/kernel/syscall_table.S b/arch/parisc/kernel/syscall_table.S
index 3735abd7f8f6..cbf5d59d5d6a 100644
--- a/arch/parisc/kernel/syscall_table.S
+++ b/arch/parisc/kernel/syscall_table.S
@@ -60,7 +60,7 @@
60 ENTRY_SAME(fork_wrapper) 60 ENTRY_SAME(fork_wrapper)
61 ENTRY_SAME(read) 61 ENTRY_SAME(read)
62 ENTRY_SAME(write) 62 ENTRY_SAME(write)
63 ENTRY_SAME(open) /* 5 */ 63 ENTRY_COMP(open) /* 5 */
64 ENTRY_SAME(close) 64 ENTRY_SAME(close)
65 ENTRY_SAME(waitpid) 65 ENTRY_SAME(waitpid)
66 ENTRY_SAME(creat) 66 ENTRY_SAME(creat)
diff --git a/arch/s390/kernel/compat_wrapper.S b/arch/s390/kernel/compat_wrapper.S
index ad79b846535c..827e094a2f49 100644
--- a/arch/s390/kernel/compat_wrapper.S
+++ b/arch/s390/kernel/compat_wrapper.S
@@ -28,7 +28,7 @@ ENTRY(sys32_open_wrapper)
28 llgtr %r2,%r2 # const char * 28 llgtr %r2,%r2 # const char *
29 lgfr %r3,%r3 # int 29 lgfr %r3,%r3 # int
30 lgfr %r4,%r4 # int 30 lgfr %r4,%r4 # int
31 jg sys_open # branch to system call 31 jg compat_sys_open # branch to system call
32 32
33ENTRY(sys32_close_wrapper) 33ENTRY(sys32_close_wrapper)
34 llgfr %r2,%r2 # unsigned int 34 llgfr %r2,%r2 # unsigned int
diff --git a/arch/score/kernel/signal.c b/arch/score/kernel/signal.c
index c268bbf8b410..02353bde92d8 100644
--- a/arch/score/kernel/signal.c
+++ b/arch/score/kernel/signal.c
@@ -148,7 +148,6 @@ score_rt_sigreturn(struct pt_regs *regs)
148{ 148{
149 struct rt_sigframe __user *frame; 149 struct rt_sigframe __user *frame;
150 sigset_t set; 150 sigset_t set;
151 stack_t st;
152 int sig; 151 int sig;
153 152
154 /* Always make any pending restarted system calls return -EINTR */ 153 /* Always make any pending restarted system calls return -EINTR */
@@ -168,12 +167,10 @@ score_rt_sigreturn(struct pt_regs *regs)
168 else if (sig) 167 else if (sig)
169 force_sig(sig, current); 168 force_sig(sig, current);
170 169
171 if (__copy_from_user(&st, &frame->rs_uc.uc_stack, sizeof(st)))
172 goto badframe;
173
174 /* It is more difficult to avoid calling this function than to 170 /* It is more difficult to avoid calling this function than to
175 call it and ignore errors. */ 171 call it and ignore errors. */
176 do_sigaltstack((stack_t __user *)&st, NULL, regs->regs[0]); 172 if (do_sigaltstack(&frame->rs_uc.uc_stack, NULL, regs->regs[0]) == -EFAULT)
173 goto badframe;
177 regs->is_syscall = 0; 174 regs->is_syscall = 0;
178 175
179 __asm__ __volatile__( 176 __asm__ __volatile__(
diff --git a/arch/sh/kernel/signal_64.c b/arch/sh/kernel/signal_64.c
index 23853814bd17..d867cd95a622 100644
--- a/arch/sh/kernel/signal_64.c
+++ b/arch/sh/kernel/signal_64.c
@@ -347,7 +347,6 @@ asmlinkage int sys_rt_sigreturn(unsigned long r2, unsigned long r3,
347{ 347{
348 struct rt_sigframe __user *frame = (struct rt_sigframe __user *) (long) REF_REG_SP; 348 struct rt_sigframe __user *frame = (struct rt_sigframe __user *) (long) REF_REG_SP;
349 sigset_t set; 349 sigset_t set;
350 stack_t __user st;
351 long long ret; 350 long long ret;
352 351
353 /* Always make any pending restarted system calls return -EINTR */ 352 /* Always make any pending restarted system calls return -EINTR */
@@ -365,11 +364,10 @@ asmlinkage int sys_rt_sigreturn(unsigned long r2, unsigned long r3,
365 goto badframe; 364 goto badframe;
366 regs->pc -= 4; 365 regs->pc -= 4;
367 366
368 if (__copy_from_user(&st, &frame->uc.uc_stack, sizeof(st)))
369 goto badframe;
370 /* It is more difficult to avoid calling this function than to 367 /* It is more difficult to avoid calling this function than to
371 call it and ignore errors. */ 368 call it and ignore errors. */
372 do_sigaltstack(&st, NULL, REF_REG_SP); 369 if (do_sigaltstack(&frame->uc.uc_stack, NULL, REF_REG_SP) == -EFAULT)
370 goto badframe;
373 371
374 return (int) ret; 372 return (int) ret;
375 373
diff --git a/arch/sparc/boot/piggyback.c b/arch/sparc/boot/piggyback.c
index c0a798fcf030..bb7c95161d71 100644
--- a/arch/sparc/boot/piggyback.c
+++ b/arch/sparc/boot/piggyback.c
@@ -81,18 +81,18 @@ static void usage(void)
81 81
82static int start_line(const char *line) 82static int start_line(const char *line)
83{ 83{
84 if (strcmp(line + 8, " T _start\n") == 0) 84 if (strcmp(line + 10, " _start\n") == 0)
85 return 1; 85 return 1;
86 else if (strcmp(line + 16, " T _start\n") == 0) 86 else if (strcmp(line + 18, " _start\n") == 0)
87 return 1; 87 return 1;
88 return 0; 88 return 0;
89} 89}
90 90
91static int end_line(const char *line) 91static int end_line(const char *line)
92{ 92{
93 if (strcmp(line + 8, " A _end\n") == 0) 93 if (strcmp(line + 10, " _end\n") == 0)
94 return 1; 94 return 1;
95 else if (strcmp (line + 16, " A _end\n") == 0) 95 else if (strcmp (line + 18, " _end\n") == 0)
96 return 1; 96 return 1;
97 return 0; 97 return 0;
98} 98}
@@ -100,8 +100,8 @@ static int end_line(const char *line)
100/* 100/*
101 * Find address for start and end in System.map. 101 * Find address for start and end in System.map.
102 * The file looks like this: 102 * The file looks like this:
103 * f0004000 T _start 103 * f0004000 ... _start
104 * f0379f79 A _end 104 * f0379f79 ... _end
105 * 1234567890123456 105 * 1234567890123456
106 * ^coloumn 1 106 * ^coloumn 1
107 * There is support for 64 bit addresses too. 107 * There is support for 64 bit addresses too.
diff --git a/arch/sparc/kernel/sys32.S b/arch/sparc/kernel/sys32.S
index 44025f4ba41f..8475a474273a 100644
--- a/arch/sparc/kernel/sys32.S
+++ b/arch/sparc/kernel/sys32.S
@@ -47,7 +47,7 @@ STUB: sra REG1, 0, REG1; \
47 sra REG4, 0, REG4 47 sra REG4, 0, REG4
48 48
49SIGN1(sys32_exit, sparc_exit, %o0) 49SIGN1(sys32_exit, sparc_exit, %o0)
50SIGN1(sys32_exit_group, sys_exit_group, %o0) 50SIGN1(sys32_exit_group, sparc_exit_group, %o0)
51SIGN1(sys32_wait4, compat_sys_wait4, %o2) 51SIGN1(sys32_wait4, compat_sys_wait4, %o2)
52SIGN1(sys32_creat, sys_creat, %o1) 52SIGN1(sys32_creat, sys_creat, %o1)
53SIGN1(sys32_mknod, sys_mknod, %o1) 53SIGN1(sys32_mknod, sys_mknod, %o1)
diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
index 7f5f65d0b3fd..bf2347794e33 100644
--- a/arch/sparc/kernel/syscalls.S
+++ b/arch/sparc/kernel/syscalls.S
@@ -118,10 +118,20 @@ ret_from_syscall:
118 ba,pt %xcc, ret_sys_call 118 ba,pt %xcc, ret_sys_call
119 ldx [%sp + PTREGS_OFF + PT_V9_I0], %o0 119 ldx [%sp + PTREGS_OFF + PT_V9_I0], %o0
120 120
121 .globl sparc_exit_group
122 .type sparc_exit_group,#function
123sparc_exit_group:
124 sethi %hi(sys_exit_group), %g7
125 ba,pt %xcc, 1f
126 or %g7, %lo(sys_exit_group), %g7
127 .size sparc_exit_group,.-sparc_exit_group
128
121 .globl sparc_exit 129 .globl sparc_exit
122 .type sparc_exit,#function 130 .type sparc_exit,#function
123sparc_exit: 131sparc_exit:
124 rdpr %pstate, %g2 132 sethi %hi(sys_exit), %g7
133 or %g7, %lo(sys_exit), %g7
1341: rdpr %pstate, %g2
125 wrpr %g2, PSTATE_IE, %pstate 135 wrpr %g2, PSTATE_IE, %pstate
126 rdpr %otherwin, %g1 136 rdpr %otherwin, %g1
127 rdpr %cansave, %g3 137 rdpr %cansave, %g3
@@ -129,7 +139,7 @@ sparc_exit:
129 wrpr %g3, 0x0, %cansave 139 wrpr %g3, 0x0, %cansave
130 wrpr %g0, 0x0, %otherwin 140 wrpr %g0, 0x0, %otherwin
131 wrpr %g2, 0x0, %pstate 141 wrpr %g2, 0x0, %pstate
132 ba,pt %xcc, sys_exit 142 jmpl %g7, %g0
133 stb %g0, [%g6 + TI_WSAVED] 143 stb %g0, [%g6 + TI_WSAVED]
134 .size sparc_exit,.-sparc_exit 144 .size sparc_exit,.-sparc_exit
135 145
diff --git a/arch/sparc/kernel/systbls_64.S b/arch/sparc/kernel/systbls_64.S
index 1c9af9fa38e9..017b74a63dcb 100644
--- a/arch/sparc/kernel/systbls_64.S
+++ b/arch/sparc/kernel/systbls_64.S
@@ -133,7 +133,7 @@ sys_call_table:
133/*170*/ .word sys_lsetxattr, sys_fsetxattr, sys_getxattr, sys_lgetxattr, sys_getdents 133/*170*/ .word sys_lsetxattr, sys_fsetxattr, sys_getxattr, sys_lgetxattr, sys_getdents
134 .word sys_setsid, sys_fchdir, sys_fgetxattr, sys_listxattr, sys_llistxattr 134 .word sys_setsid, sys_fchdir, sys_fgetxattr, sys_listxattr, sys_llistxattr
135/*180*/ .word sys_flistxattr, sys_removexattr, sys_lremovexattr, sys_nis_syscall, sys_ni_syscall 135/*180*/ .word sys_flistxattr, sys_removexattr, sys_lremovexattr, sys_nis_syscall, sys_ni_syscall
136 .word sys_setpgid, sys_fremovexattr, sys_tkill, sys_exit_group, sys_newuname 136 .word sys_setpgid, sys_fremovexattr, sys_tkill, sparc_exit_group, sys_newuname
137/*190*/ .word sys_init_module, sys_sparc64_personality, sys_remap_file_pages, sys_epoll_create, sys_epoll_ctl 137/*190*/ .word sys_init_module, sys_sparc64_personality, sys_remap_file_pages, sys_epoll_create, sys_epoll_ctl
138 .word sys_epoll_wait, sys_ioprio_set, sys_getppid, sys_nis_syscall, sys_sgetmask 138 .word sys_epoll_wait, sys_ioprio_set, sys_getppid, sys_nis_syscall, sys_sgetmask
139/*200*/ .word sys_ssetmask, sys_nis_syscall, sys_newlstat, sys_uselib, sys_nis_syscall 139/*200*/ .word sys_ssetmask, sys_nis_syscall, sys_newlstat, sys_uselib, sys_nis_syscall
diff --git a/arch/um/kernel/exec.c b/arch/um/kernel/exec.c
index 3a8ece7d09ca..0d7103c9eff3 100644
--- a/arch/um/kernel/exec.c
+++ b/arch/um/kernel/exec.c
@@ -32,13 +32,14 @@ void flush_thread(void)
32 "err = %d\n", ret); 32 "err = %d\n", ret);
33 force_sig(SIGKILL, current); 33 force_sig(SIGKILL, current);
34 } 34 }
35 get_safe_registers(current_pt_regs()->regs.gp,
36 current_pt_regs()->regs.fp);
35 37
36 __switch_mm(&current->mm->context.id); 38 __switch_mm(&current->mm->context.id);
37} 39}
38 40
39void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp) 41void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
40{ 42{
41 get_safe_registers(regs->regs.gp, regs->regs.fp);
42 PT_REGS_IP(regs) = eip; 43 PT_REGS_IP(regs) = eip;
43 PT_REGS_SP(regs) = esp; 44 PT_REGS_SP(regs) = esp;
44 current->ptrace &= ~PT_DTRACE; 45 current->ptrace &= ~PT_DTRACE;
diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild
index 66e5f0ef0523..79fd8a3418f9 100644
--- a/arch/x86/include/asm/Kbuild
+++ b/arch/x86/include/asm/Kbuild
@@ -12,6 +12,7 @@ header-y += mce.h
12header-y += msr-index.h 12header-y += msr-index.h
13header-y += msr.h 13header-y += msr.h
14header-y += mtrr.h 14header-y += mtrr.h
15header-y += perf_regs.h
15header-y += posix_types_32.h 16header-y += posix_types_32.h
16header-y += posix_types_64.h 17header-y += posix_types_64.h
17header-y += posix_types_x32.h 18header-y += posix_types_x32.h
@@ -19,8 +20,10 @@ header-y += prctl.h
19header-y += processor-flags.h 20header-y += processor-flags.h
20header-y += ptrace-abi.h 21header-y += ptrace-abi.h
21header-y += sigcontext32.h 22header-y += sigcontext32.h
23header-y += svm.h
22header-y += ucontext.h 24header-y += ucontext.h
23header-y += vm86.h 25header-y += vm86.h
26header-y += vmx.h
24header-y += vsyscall.h 27header-y += vsyscall.h
25 28
26genhdr-y += unistd_32.h 29genhdr-y += unistd_32.h
diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
index 831dbb9c6c02..41ab26ea6564 100644
--- a/arch/x86/include/asm/fpu-internal.h
+++ b/arch/x86/include/asm/fpu-internal.h
@@ -399,14 +399,17 @@ static inline void drop_init_fpu(struct task_struct *tsk)
399typedef struct { int preload; } fpu_switch_t; 399typedef struct { int preload; } fpu_switch_t;
400 400
401/* 401/*
402 * FIXME! We could do a totally lazy restore, but we need to 402 * Must be run with preemption disabled: this clears the fpu_owner_task,
403 * add a per-cpu "this was the task that last touched the FPU 403 * on this CPU.
404 * on this CPU" variable, and the task needs to have a "I last
405 * touched the FPU on this CPU" and check them.
406 * 404 *
407 * We don't do that yet, so "fpu_lazy_restore()" always returns 405 * This will disable any lazy FPU state restore of the current FPU state,
408 * false, but some day.. 406 * but if the current thread owns the FPU, it will still be saved by.
409 */ 407 */
408static inline void __cpu_disable_lazy_restore(unsigned int cpu)
409{
410 per_cpu(fpu_owner_task, cpu) = NULL;
411}
412
410static inline int fpu_lazy_restore(struct task_struct *new, unsigned int cpu) 413static inline int fpu_lazy_restore(struct task_struct *new, unsigned int cpu)
411{ 414{
412 return new == this_cpu_read_stable(fpu_owner_task) && 415 return new == this_cpu_read_stable(fpu_owner_task) &&
diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
index 957a47aec64e..4dac2f68ed4a 100644
--- a/arch/x86/kernel/head_32.S
+++ b/arch/x86/kernel/head_32.S
@@ -292,8 +292,8 @@ default_entry:
292 * be using the global pages. 292 * be using the global pages.
293 * 293 *
294 * NOTE! If we are on a 486 we may have no cr4 at all! 294 * NOTE! If we are on a 486 we may have no cr4 at all!
295 * Specifically, cr4 exists if and only if CPUID exists, 295 * Specifically, cr4 exists if and only if CPUID exists
296 * which in turn exists if and only if EFLAGS.ID exists. 296 * and has flags other than the FPU flag set.
297 */ 297 */
298 movl $X86_EFLAGS_ID,%ecx 298 movl $X86_EFLAGS_ID,%ecx
299 pushl %ecx 299 pushl %ecx
@@ -308,6 +308,11 @@ default_entry:
308 testl %ecx,%eax 308 testl %ecx,%eax
309 jz 6f # No ID flag = no CPUID = no CR4 309 jz 6f # No ID flag = no CPUID = no CR4
310 310
311 movl $1,%eax
312 cpuid
313 andl $~1,%edx # Ignore CPUID.FPU
314 jz 6f # No flags or only CPUID.FPU = no CR4
315
311 movl pa(mmu_cr4_features),%eax 316 movl pa(mmu_cr4_features),%eax
312 movl %eax,%cr4 317 movl %eax,%cr4
313 318
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 5e0596b0632e..974b67e46dd0 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -1541,6 +1541,13 @@ void syscall_trace_leave(struct pt_regs *regs)
1541{ 1541{
1542 bool step; 1542 bool step;
1543 1543
1544 /*
1545 * We may come here right after calling schedule_user()
1546 * or do_notify_resume(), in which case we can be in RCU
1547 * user mode.
1548 */
1549 rcu_user_exit();
1550
1544 audit_syscall_exit(regs); 1551 audit_syscall_exit(regs);
1545 1552
1546 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) 1553 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index c80a33bc528b..f3e2ec878b8c 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -68,6 +68,8 @@
68#include <asm/mwait.h> 68#include <asm/mwait.h>
69#include <asm/apic.h> 69#include <asm/apic.h>
70#include <asm/io_apic.h> 70#include <asm/io_apic.h>
71#include <asm/i387.h>
72#include <asm/fpu-internal.h>
71#include <asm/setup.h> 73#include <asm/setup.h>
72#include <asm/uv/uv.h> 74#include <asm/uv/uv.h>
73#include <linux/mc146818rtc.h> 75#include <linux/mc146818rtc.h>
@@ -818,6 +820,9 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
818 820
819 per_cpu(cpu_state, cpu) = CPU_UP_PREPARE; 821 per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
820 822
823 /* the FPU context is blank, nobody can own it */
824 __cpu_disable_lazy_restore(cpu);
825
821 err = do_boot_cpu(apicid, cpu, tidle); 826 err = do_boot_cpu(apicid, cpu, tidle);
822 if (err) { 827 if (err) {
823 pr_debug("do_boot_cpu failed %d\n", err); 828 pr_debug("do_boot_cpu failed %d\n", err);
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 39171cb307ea..bba39bfa1c4b 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -426,8 +426,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
426 _ASM_EXTABLE(1b, 3b) \ 426 _ASM_EXTABLE(1b, 3b) \
427 : "=m" ((ctxt)->eflags), "=&r" (_tmp), \ 427 : "=m" ((ctxt)->eflags), "=&r" (_tmp), \
428 "+a" (*rax), "+d" (*rdx), "+qm"(_ex) \ 428 "+a" (*rax), "+d" (*rdx), "+qm"(_ex) \
429 : "i" (EFLAGS_MASK), "m" ((ctxt)->src.val), \ 429 : "i" (EFLAGS_MASK), "m" ((ctxt)->src.val)); \
430 "a" (*rax), "d" (*rdx)); \
431 } while (0) 430 } while (0)
432 431
433/* instruction has only one source operand, destination is implicit (e.g. mul, div, imul, idiv) */ 432/* instruction has only one source operand, destination is implicit (e.g. mul, div, imul, idiv) */
diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
index 89b30f32ba68..ff7bb8a42ed6 100644
--- a/drivers/atm/ambassador.c
+++ b/drivers/atm/ambassador.c
@@ -1961,6 +1961,7 @@ static int __devinit ucode_init (loader_block * lb, amb_dev * dev) {
1961 res = loader_verify(lb, dev, rec); 1961 res = loader_verify(lb, dev, rec);
1962 if (res) 1962 if (res)
1963 break; 1963 break;
1964 rec = ihex_next_binrec(rec);
1964 } 1965 }
1965 release_firmware(fw); 1966 release_firmware(fw);
1966 if (!res) 1967 if (!res)
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig
index fbd9b2b850ef..c58ea9b80b1a 100644
--- a/drivers/char/hw_random/Kconfig
+++ b/drivers/char/hw_random/Kconfig
@@ -127,12 +127,12 @@ config HW_RANDOM_VIA
127 If unsure, say Y. 127 If unsure, say Y.
128 128
129config HW_RANDOM_IXP4XX 129config HW_RANDOM_IXP4XX
130 tristate "Intel IXP4xx NPU HW Random Number Generator support" 130 tristate "Intel IXP4xx NPU HW Pseudo-Random Number Generator support"
131 depends on HW_RANDOM && ARCH_IXP4XX 131 depends on HW_RANDOM && ARCH_IXP4XX
132 default HW_RANDOM 132 default HW_RANDOM
133 ---help--- 133 ---help---
134 This driver provides kernel-side support for the Random 134 This driver provides kernel-side support for the Pseudo-Random
135 Number Generator hardware found on the Intel IXP4xx NPU. 135 Number Generator hardware found on the Intel IXP45x/46x NPU.
136 136
137 To compile this driver as a module, choose M here: the 137 To compile this driver as a module, choose M here: the
138 module will be called ixp4xx-rng. 138 module will be called ixp4xx-rng.
diff --git a/drivers/char/hw_random/ixp4xx-rng.c b/drivers/char/hw_random/ixp4xx-rng.c
index 263567f5f392..beec1627db3c 100644
--- a/drivers/char/hw_random/ixp4xx-rng.c
+++ b/drivers/char/hw_random/ixp4xx-rng.c
@@ -45,6 +45,9 @@ static int __init ixp4xx_rng_init(void)
45 void __iomem * rng_base; 45 void __iomem * rng_base;
46 int err; 46 int err;
47 47
48 if (!cpu_is_ixp46x()) /* includes IXP455 */
49 return -ENOSYS;
50
48 rng_base = ioremap(0x70002100, 4); 51 rng_base = ioremap(0x70002100, 4);
49 if (!rng_base) 52 if (!rng_base)
50 return -ENOMEM; 53 return -ENOMEM;
@@ -68,5 +71,5 @@ module_init(ixp4xx_rng_init);
68module_exit(ixp4xx_rng_exit); 71module_exit(ixp4xx_rng_exit);
69 72
70MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net>"); 73MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net>");
71MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver for IXP4xx"); 74MODULE_DESCRIPTION("H/W Pseudo-Random Number Generator (RNG) driver for IXP45x/46x");
72MODULE_LICENSE("GPL"); 75MODULE_LICENSE("GPL");
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 0bb207eaef2f..54a3a6d09819 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -285,7 +285,7 @@ static long raw_ctl_compat_ioctl(struct file *file, unsigned int cmd,
285 285
286static const struct file_operations raw_fops = { 286static const struct file_operations raw_fops = {
287 .read = do_sync_read, 287 .read = do_sync_read,
288 .aio_read = blkdev_aio_read, 288 .aio_read = generic_file_aio_read,
289 .write = do_sync_write, 289 .write = do_sync_write,
290 .aio_write = blkdev_aio_write, 290 .aio_write = blkdev_aio_write,
291 .fsync = blkdev_fsync, 291 .fsync = blkdev_fsync,
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index 308c7fb92a60..f6644f59fd9d 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -224,7 +224,7 @@ config CRYPTO_DEV_TALITOS
224 224
225config CRYPTO_DEV_IXP4XX 225config CRYPTO_DEV_IXP4XX
226 tristate "Driver for IXP4xx crypto hardware acceleration" 226 tristate "Driver for IXP4xx crypto hardware acceleration"
227 depends on ARCH_IXP4XX 227 depends on ARCH_IXP4XX && IXP4XX_QMGR && IXP4XX_NPE
228 select CRYPTO_DES 228 select CRYPTO_DES
229 select CRYPTO_ALGAPI 229 select CRYPTO_ALGAPI
230 select CRYPTO_AUTHENC 230 select CRYPTO_AUTHENC
diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c
index 8f3f74ce8c7f..21180d6cad6e 100644
--- a/drivers/crypto/ixp4xx_crypto.c
+++ b/drivers/crypto/ixp4xx_crypto.c
@@ -750,12 +750,12 @@ static int setup_cipher(struct crypto_tfm *tfm, int encrypt,
750 } 750 }
751 if (cipher_cfg & MOD_AES) { 751 if (cipher_cfg & MOD_AES) {
752 switch (key_len) { 752 switch (key_len) {
753 case 16: keylen_cfg = MOD_AES128 | KEYLEN_128; break; 753 case 16: keylen_cfg = MOD_AES128; break;
754 case 24: keylen_cfg = MOD_AES192 | KEYLEN_192; break; 754 case 24: keylen_cfg = MOD_AES192; break;
755 case 32: keylen_cfg = MOD_AES256 | KEYLEN_256; break; 755 case 32: keylen_cfg = MOD_AES256; break;
756 default: 756 default:
757 *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; 757 *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
758 return -EINVAL; 758 return -EINVAL;
759 } 759 }
760 cipher_cfg |= keylen_cfg; 760 cipher_cfg |= keylen_cfg;
761 } else if (cipher_cfg & MOD_3DES) { 761 } else if (cipher_cfg & MOD_3DES) {
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 90f0b730e9bb..75c0a1a85fc3 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -416,10 +416,18 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num,
416 dimm->cschannel = chn; 416 dimm->cschannel = chn;
417 417
418 /* Increment csrow location */ 418 /* Increment csrow location */
419 row++; 419 if (layers[0].is_virt_csrow) {
420 if (row == tot_csrows) {
421 row = 0;
422 chn++; 420 chn++;
421 if (chn == tot_channels) {
422 chn = 0;
423 row++;
424 }
425 } else {
426 row++;
427 if (row == tot_csrows) {
428 row = 0;
429 chn++;
430 }
423 } 431 }
424 432
425 /* Increment dimm location */ 433 /* Increment dimm location */
diff --git a/drivers/edac/i7300_edac.c b/drivers/edac/i7300_edac.c
index a09d0667f72a..9d669cd43618 100644
--- a/drivers/edac/i7300_edac.c
+++ b/drivers/edac/i7300_edac.c
@@ -197,8 +197,8 @@ static const char *ferr_fat_fbd_name[] = {
197 [0] = "Memory Write error on non-redundant retry or " 197 [0] = "Memory Write error on non-redundant retry or "
198 "FBD configuration Write error on retry", 198 "FBD configuration Write error on retry",
199}; 199};
200#define GET_FBD_FAT_IDX(fbderr) (fbderr & (3 << 28)) 200#define GET_FBD_FAT_IDX(fbderr) (((fbderr) >> 28) & 3)
201#define FERR_FAT_FBD_ERR_MASK ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)) 201#define FERR_FAT_FBD_ERR_MASK ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 22))
202 202
203#define FERR_NF_FBD 0xa0 203#define FERR_NF_FBD 0xa0
204static const char *ferr_nf_fbd_name[] = { 204static const char *ferr_nf_fbd_name[] = {
@@ -225,7 +225,7 @@ static const char *ferr_nf_fbd_name[] = {
225 [1] = "Aliased Uncorrectable Non-Mirrored Demand Data ECC", 225 [1] = "Aliased Uncorrectable Non-Mirrored Demand Data ECC",
226 [0] = "Uncorrectable Data ECC on Replay", 226 [0] = "Uncorrectable Data ECC on Replay",
227}; 227};
228#define GET_FBD_NF_IDX(fbderr) (fbderr & (3 << 28)) 228#define GET_FBD_NF_IDX(fbderr) (((fbderr) >> 28) & 3)
229#define FERR_NF_FBD_ERR_MASK ((1 << 24) | (1 << 23) | (1 << 22) | (1 << 21) |\ 229#define FERR_NF_FBD_ERR_MASK ((1 << 24) | (1 << 23) | (1 << 22) | (1 << 21) |\
230 (1 << 18) | (1 << 17) | (1 << 16) | (1 << 15) |\ 230 (1 << 18) | (1 << 17) | (1 << 16) | (1 << 15) |\
231 (1 << 14) | (1 << 13) | (1 << 11) | (1 << 10) |\ 231 (1 << 14) | (1 << 13) | (1 << 11) | (1 << 10) |\
@@ -464,7 +464,7 @@ static void i7300_process_fbd_error(struct mem_ctl_info *mci)
464 errnum = find_first_bit(&errors, 464 errnum = find_first_bit(&errors,
465 ARRAY_SIZE(ferr_nf_fbd_name)); 465 ARRAY_SIZE(ferr_nf_fbd_name));
466 specific = GET_ERR_FROM_TABLE(ferr_nf_fbd_name, errnum); 466 specific = GET_ERR_FROM_TABLE(ferr_nf_fbd_name, errnum);
467 branch = (GET_FBD_FAT_IDX(error_reg) == 2) ? 1 : 0; 467 branch = (GET_FBD_NF_IDX(error_reg) == 2) ? 1 : 0;
468 468
469 pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map, 469 pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map,
470 REDMEMA, &syndrome); 470 REDMEMA, &syndrome);
diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
index 3672101023bd..10c8c00d6469 100644
--- a/drivers/edac/i7core_edac.c
+++ b/drivers/edac/i7core_edac.c
@@ -816,7 +816,7 @@ static ssize_t i7core_inject_store_##param( \
816 struct device_attribute *mattr, \ 816 struct device_attribute *mattr, \
817 const char *data, size_t count) \ 817 const char *data, size_t count) \
818{ \ 818{ \
819 struct mem_ctl_info *mci = to_mci(dev); \ 819 struct mem_ctl_info *mci = dev_get_drvdata(dev); \
820 struct i7core_pvt *pvt; \ 820 struct i7core_pvt *pvt; \
821 long value; \ 821 long value; \
822 int rc; \ 822 int rc; \
@@ -845,7 +845,7 @@ static ssize_t i7core_inject_show_##param( \
845 struct device_attribute *mattr, \ 845 struct device_attribute *mattr, \
846 char *data) \ 846 char *data) \
847{ \ 847{ \
848 struct mem_ctl_info *mci = to_mci(dev); \ 848 struct mem_ctl_info *mci = dev_get_drvdata(dev); \
849 struct i7core_pvt *pvt; \ 849 struct i7core_pvt *pvt; \
850 \ 850 \
851 pvt = mci->pvt_info; \ 851 pvt = mci->pvt_info; \
@@ -1052,7 +1052,7 @@ static ssize_t i7core_show_counter_##param( \
1052 struct device_attribute *mattr, \ 1052 struct device_attribute *mattr, \
1053 char *data) \ 1053 char *data) \
1054{ \ 1054{ \
1055 struct mem_ctl_info *mci = to_mci(dev); \ 1055 struct mem_ctl_info *mci = dev_get_drvdata(dev); \
1056 struct i7core_pvt *pvt = mci->pvt_info; \ 1056 struct i7core_pvt *pvt = mci->pvt_info; \
1057 \ 1057 \
1058 edac_dbg(1, "\n"); \ 1058 edac_dbg(1, "\n"); \
diff --git a/drivers/edac/i82975x_edac.c b/drivers/edac/i82975x_edac.c
index 069e26c11c4f..a98020409fa9 100644
--- a/drivers/edac/i82975x_edac.c
+++ b/drivers/edac/i82975x_edac.c
@@ -370,10 +370,6 @@ static enum dev_type i82975x_dram_type(void __iomem *mch_window, int rank)
370static void i82975x_init_csrows(struct mem_ctl_info *mci, 370static void i82975x_init_csrows(struct mem_ctl_info *mci,
371 struct pci_dev *pdev, void __iomem *mch_window) 371 struct pci_dev *pdev, void __iomem *mch_window)
372{ 372{
373 static const char *labels[4] = {
374 "DIMM A1", "DIMM A2",
375 "DIMM B1", "DIMM B2"
376 };
377 struct csrow_info *csrow; 373 struct csrow_info *csrow;
378 unsigned long last_cumul_size; 374 unsigned long last_cumul_size;
379 u8 value; 375 u8 value;
@@ -423,9 +419,10 @@ static void i82975x_init_csrows(struct mem_ctl_info *mci,
423 dimm = mci->csrows[index]->channels[chan]->dimm; 419 dimm = mci->csrows[index]->channels[chan]->dimm;
424 420
425 dimm->nr_pages = nr_pages / csrow->nr_channels; 421 dimm->nr_pages = nr_pages / csrow->nr_channels;
426 strncpy(csrow->channels[chan]->dimm->label, 422
427 labels[(index >> 1) + (chan * 2)], 423 snprintf(csrow->channels[chan]->dimm->label, EDAC_MC_LABEL_LEN, "DIMM %c%d",
428 EDAC_MC_LABEL_LEN); 424 (chan == 0) ? 'A' : 'B',
425 index);
429 dimm->grain = 1 << 7; /* 128Byte cache-line resolution */ 426 dimm->grain = 1 << 7; /* 128Byte cache-line resolution */
430 dimm->dtype = i82975x_dram_type(mch_window, index); 427 dimm->dtype = i82975x_dram_type(mch_window, index);
431 dimm->mtype = MEM_DDR2; /* I82975x supports only DDR2 */ 428 dimm->mtype = MEM_DDR2; /* I82975x supports only DDR2 */
diff --git a/drivers/gpu/drm/exynos/exynos_drm_encoder.c b/drivers/gpu/drm/exynos/exynos_drm_encoder.c
index 241ad1eeec64..f2df06c603f7 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_encoder.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_encoder.c
@@ -226,6 +226,12 @@ static void exynos_drm_encoder_commit(struct drm_encoder *encoder)
226 * already updated or not by exynos_drm_encoder_dpms function. 226 * already updated or not by exynos_drm_encoder_dpms function.
227 */ 227 */
228 exynos_encoder->updated = true; 228 exynos_encoder->updated = true;
229
230 /*
231 * In case of setcrtc, there is no way to update encoder's dpms
232 * so update it here.
233 */
234 exynos_encoder->dpms = DRM_MODE_DPMS_ON;
229} 235}
230 236
231static void exynos_drm_encoder_disable(struct drm_encoder *encoder) 237static void exynos_drm_encoder_disable(struct drm_encoder *encoder)
@@ -507,6 +513,6 @@ void exynos_drm_encoder_plane_disable(struct drm_encoder *encoder, void *data)
507 * because the setting for disabling the overlay will be updated 513 * because the setting for disabling the overlay will be updated
508 * at vsync. 514 * at vsync.
509 */ 515 */
510 if (overlay_ops->wait_for_vblank) 516 if (overlay_ops && overlay_ops->wait_for_vblank)
511 overlay_ops->wait_for_vblank(manager->dev); 517 overlay_ops->wait_for_vblank(manager->dev);
512} 518}
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
index 67eb6ba56edf..e7466c4414cb 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
@@ -87,7 +87,8 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper *helper,
87 87
88 dev->mode_config.fb_base = (resource_size_t)buffer->dma_addr; 88 dev->mode_config.fb_base = (resource_size_t)buffer->dma_addr;
89 fbi->screen_base = buffer->kvaddr + offset; 89 fbi->screen_base = buffer->kvaddr + offset;
90 fbi->fix.smem_start = (unsigned long)(buffer->dma_addr + offset); 90 fbi->fix.smem_start = (unsigned long)(page_to_phys(buffer->pages[0]) +
91 offset);
91 fbi->screen_size = size; 92 fbi->screen_size = size;
92 fbi->fix.smem_len = size; 93 fbi->fix.smem_len = size;
93 94
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index 130a2b510d4a..e08478f19f1a 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -61,11 +61,11 @@ struct fimd_driver_data {
61 unsigned int timing_base; 61 unsigned int timing_base;
62}; 62};
63 63
64struct fimd_driver_data exynos4_fimd_driver_data = { 64static struct fimd_driver_data exynos4_fimd_driver_data = {
65 .timing_base = 0x0, 65 .timing_base = 0x0,
66}; 66};
67 67
68struct fimd_driver_data exynos5_fimd_driver_data = { 68static struct fimd_driver_data exynos5_fimd_driver_data = {
69 .timing_base = 0x20000, 69 .timing_base = 0x20000,
70}; 70};
71 71
diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c
index 60b877a388c2..862ca1eb2102 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_plane.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c
@@ -204,7 +204,6 @@ exynos_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
204 return ret; 204 return ret;
205 205
206 plane->crtc = crtc; 206 plane->crtc = crtc;
207 plane->fb = crtc->fb;
208 207
209 exynos_plane_commit(plane); 208 exynos_plane_commit(plane);
210 exynos_plane_dpms(plane, DRM_MODE_DPMS_ON); 209 exynos_plane_dpms(plane, DRM_MODE_DPMS_ON);
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 107f09befe92..9b285da4449b 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1796,7 +1796,7 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
1796 */ 1796 */
1797 mapping = obj->base.filp->f_path.dentry->d_inode->i_mapping; 1797 mapping = obj->base.filp->f_path.dentry->d_inode->i_mapping;
1798 gfp = mapping_gfp_mask(mapping); 1798 gfp = mapping_gfp_mask(mapping);
1799 gfp |= __GFP_NORETRY | __GFP_NOWARN; 1799 gfp |= __GFP_NORETRY | __GFP_NOWARN | __GFP_NO_KSWAPD;
1800 gfp &= ~(__GFP_IO | __GFP_WAIT); 1800 gfp &= ~(__GFP_IO | __GFP_WAIT);
1801 for_each_sg(st->sgl, sg, page_count, i) { 1801 for_each_sg(st->sgl, sg, page_count, i) {
1802 page = shmem_read_mapping_page_gfp(mapping, i, gfp); 1802 page = shmem_read_mapping_page_gfp(mapping, i, gfp);
@@ -1809,7 +1809,7 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
1809 * our own buffer, now let the real VM do its job and 1809 * our own buffer, now let the real VM do its job and
1810 * go down in flames if truly OOM. 1810 * go down in flames if truly OOM.
1811 */ 1811 */
1812 gfp &= ~(__GFP_NORETRY | __GFP_NOWARN); 1812 gfp &= ~(__GFP_NORETRY | __GFP_NOWARN | __GFP_NO_KSWAPD);
1813 gfp |= __GFP_IO | __GFP_WAIT; 1813 gfp |= __GFP_IO | __GFP_WAIT;
1814 1814
1815 i915_gem_shrink_all(dev_priv); 1815 i915_gem_shrink_all(dev_priv);
@@ -1817,7 +1817,7 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
1817 if (IS_ERR(page)) 1817 if (IS_ERR(page))
1818 goto err_pages; 1818 goto err_pages;
1819 1819
1820 gfp |= __GFP_NORETRY | __GFP_NOWARN; 1820 gfp |= __GFP_NORETRY | __GFP_NOWARN | __GFP_NO_KSWAPD;
1821 gfp &= ~(__GFP_IO | __GFP_WAIT); 1821 gfp &= ~(__GFP_IO | __GFP_WAIT);
1822 } 1822 }
1823 1823
diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
index 0ed6baff4b0c..56846ed5ee55 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -499,12 +499,8 @@ parse_edp(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
499 499
500 edp = find_section(bdb, BDB_EDP); 500 edp = find_section(bdb, BDB_EDP);
501 if (!edp) { 501 if (!edp) {
502 if (SUPPORTS_EDP(dev_priv->dev) && dev_priv->edp.support) { 502 if (SUPPORTS_EDP(dev_priv->dev) && dev_priv->edp.support)
503 DRM_DEBUG_KMS("No eDP BDB found but eDP panel " 503 DRM_DEBUG_KMS("No eDP BDB found but eDP panel supported.\n");
504 "supported, assume %dbpp panel color "
505 "depth.\n",
506 dev_priv->edp.bpp);
507 }
508 return; 504 return;
509 } 505 }
510 506
@@ -657,9 +653,6 @@ init_vbt_defaults(struct drm_i915_private *dev_priv)
657 dev_priv->lvds_use_ssc = 1; 653 dev_priv->lvds_use_ssc = 1;
658 dev_priv->lvds_ssc_freq = intel_bios_ssc_frequency(dev, 1); 654 dev_priv->lvds_ssc_freq = intel_bios_ssc_frequency(dev, 1);
659 DRM_DEBUG_KMS("Set default to SSC at %dMHz\n", dev_priv->lvds_ssc_freq); 655 DRM_DEBUG_KMS("Set default to SSC at %dMHz\n", dev_priv->lvds_ssc_freq);
660
661 /* eDP data */
662 dev_priv->edp.bpp = 18;
663} 656}
664 657
665static int __init intel_no_opregion_vbt_callback(const struct dmi_system_id *id) 658static int __init intel_no_opregion_vbt_callback(const struct dmi_system_id *id)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 4154bcd7a070..b426d44a2b05 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -3845,7 +3845,7 @@ static bool intel_choose_pipe_bpp_dither(struct drm_crtc *crtc,
3845 /* Use VBT settings if we have an eDP panel */ 3845 /* Use VBT settings if we have an eDP panel */
3846 unsigned int edp_bpc = dev_priv->edp.bpp / 3; 3846 unsigned int edp_bpc = dev_priv->edp.bpp / 3;
3847 3847
3848 if (edp_bpc < display_bpc) { 3848 if (edp_bpc && edp_bpc < display_bpc) {
3849 DRM_DEBUG_KMS("clamping display bpc (was %d) to eDP (%d)\n", display_bpc, edp_bpc); 3849 DRM_DEBUG_KMS("clamping display bpc (was %d) to eDP (%d)\n", display_bpc, edp_bpc);
3850 display_bpc = edp_bpc; 3850 display_bpc = edp_bpc;
3851 } 3851 }
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index 72f41aaa71ff..442968f8b201 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -2373,15 +2373,9 @@ int intel_enable_rc6(const struct drm_device *dev)
2373 if (i915_enable_rc6 >= 0) 2373 if (i915_enable_rc6 >= 0)
2374 return i915_enable_rc6; 2374 return i915_enable_rc6;
2375 2375
2376 if (INTEL_INFO(dev)->gen == 5) { 2376 /* Disable RC6 on Ironlake */
2377#ifdef CONFIG_INTEL_IOMMU 2377 if (INTEL_INFO(dev)->gen == 5)
2378 /* Disable rc6 on ilk if VT-d is on. */ 2378 return 0;
2379 if (intel_iommu_gfx_mapped)
2380 return false;
2381#endif
2382 DRM_DEBUG_DRIVER("Ironlake: only RC6 available\n");
2383 return INTEL_RC6_ENABLE;
2384 }
2385 2379
2386 if (IS_HASWELL(dev)) { 2380 if (IS_HASWELL(dev)) {
2387 DRM_DEBUG_DRIVER("Haswell: only RC6 available\n"); 2381 DRM_DEBUG_DRIVER("Haswell: only RC6 available\n");
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index c600fb06e25e..a6ac0b416964 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -2201,7 +2201,6 @@ intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device)
2201 connector->connector_type = DRM_MODE_CONNECTOR_HDMIA; 2201 connector->connector_type = DRM_MODE_CONNECTOR_HDMIA;
2202 intel_sdvo->is_hdmi = true; 2202 intel_sdvo->is_hdmi = true;
2203 } 2203 }
2204 intel_sdvo->base.cloneable = true;
2205 2204
2206 intel_sdvo_connector_init(intel_sdvo_connector, intel_sdvo); 2205 intel_sdvo_connector_init(intel_sdvo_connector, intel_sdvo);
2207 if (intel_sdvo->is_hdmi) 2206 if (intel_sdvo->is_hdmi)
@@ -2232,7 +2231,6 @@ intel_sdvo_tv_init(struct intel_sdvo *intel_sdvo, int type)
2232 2231
2233 intel_sdvo->is_tv = true; 2232 intel_sdvo->is_tv = true;
2234 intel_sdvo->base.needs_tv_clock = true; 2233 intel_sdvo->base.needs_tv_clock = true;
2235 intel_sdvo->base.cloneable = false;
2236 2234
2237 intel_sdvo_connector_init(intel_sdvo_connector, intel_sdvo); 2235 intel_sdvo_connector_init(intel_sdvo_connector, intel_sdvo);
2238 2236
@@ -2275,8 +2273,6 @@ intel_sdvo_analog_init(struct intel_sdvo *intel_sdvo, int device)
2275 intel_sdvo_connector->output_flag = SDVO_OUTPUT_RGB1; 2273 intel_sdvo_connector->output_flag = SDVO_OUTPUT_RGB1;
2276 } 2274 }
2277 2275
2278 intel_sdvo->base.cloneable = true;
2279
2280 intel_sdvo_connector_init(intel_sdvo_connector, 2276 intel_sdvo_connector_init(intel_sdvo_connector,
2281 intel_sdvo); 2277 intel_sdvo);
2282 return true; 2278 return true;
@@ -2307,9 +2303,6 @@ intel_sdvo_lvds_init(struct intel_sdvo *intel_sdvo, int device)
2307 intel_sdvo_connector->output_flag = SDVO_OUTPUT_LVDS1; 2303 intel_sdvo_connector->output_flag = SDVO_OUTPUT_LVDS1;
2308 } 2304 }
2309 2305
2310 /* SDVO LVDS is not cloneable because the input mode gets adjusted by the encoder */
2311 intel_sdvo->base.cloneable = false;
2312
2313 intel_sdvo_connector_init(intel_sdvo_connector, intel_sdvo); 2306 intel_sdvo_connector_init(intel_sdvo_connector, intel_sdvo);
2314 if (!intel_sdvo_create_enhance_property(intel_sdvo, intel_sdvo_connector)) 2307 if (!intel_sdvo_create_enhance_property(intel_sdvo, intel_sdvo_connector))
2315 goto err; 2308 goto err;
@@ -2721,6 +2714,16 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob)
2721 goto err_output; 2714 goto err_output;
2722 } 2715 }
2723 2716
2717 /*
2718 * Cloning SDVO with anything is often impossible, since the SDVO
2719 * encoder can request a special input timing mode. And even if that's
2720 * not the case we have evidence that cloning a plain unscaled mode with
2721 * VGA doesn't really work. Furthermore the cloning flags are way too
2722 * simplistic anyway to express such constraints, so just give up on
2723 * cloning for SDVO encoders.
2724 */
2725 intel_sdvo->base.cloneable = false;
2726
2724 /* Only enable the hotplug irq if we need it, to work around noisy 2727 /* Only enable the hotplug irq if we need it, to work around noisy
2725 * hotplug lines. 2728 * hotplug lines.
2726 */ 2729 */
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index 3bce0299f64a..24d932f53203 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -1696,42 +1696,22 @@ static int radeon_atom_pick_pll(struct drm_crtc *crtc)
1696 return ATOM_PPLL2; 1696 return ATOM_PPLL2;
1697 DRM_ERROR("unable to allocate a PPLL\n"); 1697 DRM_ERROR("unable to allocate a PPLL\n");
1698 return ATOM_PPLL_INVALID; 1698 return ATOM_PPLL_INVALID;
1699 } else if (ASIC_IS_AVIVO(rdev)) {
1700 /* in DP mode, the DP ref clock can come from either PPLL
1701 * depending on the asic:
1702 * DCE3: PPLL1 or PPLL2
1703 */
1704 if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(radeon_crtc->encoder))) {
1705 /* use the same PPLL for all DP monitors */
1706 pll = radeon_get_shared_dp_ppll(crtc);
1707 if (pll != ATOM_PPLL_INVALID)
1708 return pll;
1709 } else {
1710 /* use the same PPLL for all monitors with the same clock */
1711 pll = radeon_get_shared_nondp_ppll(crtc);
1712 if (pll != ATOM_PPLL_INVALID)
1713 return pll;
1714 }
1715 /* all other cases */
1716 pll_in_use = radeon_get_pll_use_mask(crtc);
1717 /* the order shouldn't matter here, but we probably
1718 * need this until we have atomic modeset
1719 */
1720 if (rdev->flags & RADEON_IS_IGP) {
1721 if (!(pll_in_use & (1 << ATOM_PPLL1)))
1722 return ATOM_PPLL1;
1723 if (!(pll_in_use & (1 << ATOM_PPLL2)))
1724 return ATOM_PPLL2;
1725 } else {
1726 if (!(pll_in_use & (1 << ATOM_PPLL2)))
1727 return ATOM_PPLL2;
1728 if (!(pll_in_use & (1 << ATOM_PPLL1)))
1729 return ATOM_PPLL1;
1730 }
1731 DRM_ERROR("unable to allocate a PPLL\n");
1732 return ATOM_PPLL_INVALID;
1733 } else { 1699 } else {
1734 /* on pre-R5xx asics, the crtc to pll mapping is hardcoded */ 1700 /* on pre-R5xx asics, the crtc to pll mapping is hardcoded */
1701 /* some atombios (observed in some DCE2/DCE3) code have a bug,
1702 * the matching btw pll and crtc is done through
1703 * PCLK_CRTC[1|2]_CNTL (0x480/0x484) but atombios code use the
1704 * pll (1 or 2) to select which register to write. ie if using
1705 * pll1 it will use PCLK_CRTC1_CNTL (0x480) and if using pll2
1706 * it will use PCLK_CRTC2_CNTL (0x484), it then use crtc id to
1707 * choose which value to write. Which is reverse order from
1708 * register logic. So only case that works is when pllid is
1709 * same as crtcid or when both pll and crtc are enabled and
1710 * both use same clock.
1711 *
1712 * So just return crtc id as if crtc and pll were hard linked
1713 * together even if they aren't
1714 */
1735 return radeon_crtc->crtc_id; 1715 return radeon_crtc->crtc_id;
1736 } 1716 }
1737} 1717}
diff --git a/drivers/input/matrix-keymap.c b/drivers/input/matrix-keymap.c
index 443ad64b7f2a..d88d9be1d1b7 100644
--- a/drivers/input/matrix-keymap.c
+++ b/drivers/input/matrix-keymap.c
@@ -23,6 +23,7 @@
23#include <linux/input.h> 23#include <linux/input.h>
24#include <linux/of.h> 24#include <linux/of.h>
25#include <linux/export.h> 25#include <linux/export.h>
26#include <linux/module.h>
26#include <linux/input/matrix_keypad.h> 27#include <linux/input/matrix_keypad.h>
27 28
28static bool matrix_keypad_map_key(struct input_dev *input_dev, 29static bool matrix_keypad_map_key(struct input_dev *input_dev,
@@ -161,3 +162,5 @@ int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data,
161 return 0; 162 return 0;
162} 163}
163EXPORT_SYMBOL(matrix_keypad_build_keymap); 164EXPORT_SYMBOL(matrix_keypad_build_keymap);
165
166MODULE_LICENSE("GPL");
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 636bae0405e8..a0f73092176e 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -963,7 +963,7 @@ static void raid1_unplug(struct blk_plug_cb *cb, bool from_schedule)
963 struct r1conf *conf = mddev->private; 963 struct r1conf *conf = mddev->private;
964 struct bio *bio; 964 struct bio *bio;
965 965
966 if (from_schedule) { 966 if (from_schedule || current->bio_list) {
967 spin_lock_irq(&conf->device_lock); 967 spin_lock_irq(&conf->device_lock);
968 bio_list_merge(&conf->pending_bio_list, &plug->pending); 968 bio_list_merge(&conf->pending_bio_list, &plug->pending);
969 conf->pending_count += plug->pending_cnt; 969 conf->pending_count += plug->pending_cnt;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 0d5d0ff2c0f7..c9acbd717131 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1069,7 +1069,7 @@ static void raid10_unplug(struct blk_plug_cb *cb, bool from_schedule)
1069 struct r10conf *conf = mddev->private; 1069 struct r10conf *conf = mddev->private;
1070 struct bio *bio; 1070 struct bio *bio;
1071 1071
1072 if (from_schedule) { 1072 if (from_schedule || current->bio_list) {
1073 spin_lock_irq(&conf->device_lock); 1073 spin_lock_irq(&conf->device_lock);
1074 bio_list_merge(&conf->pending_bio_list, &plug->pending); 1074 bio_list_merge(&conf->pending_bio_list, &plug->pending);
1075 conf->pending_count += plug->pending_cnt; 1075 conf->pending_count += plug->pending_cnt;
diff --git a/drivers/media/dvb-frontends/stv0900_core.c b/drivers/media/dvb-frontends/stv0900_core.c
index 262dfa503c2a..b551ca350e00 100644
--- a/drivers/media/dvb-frontends/stv0900_core.c
+++ b/drivers/media/dvb-frontends/stv0900_core.c
@@ -300,15 +300,15 @@ static enum fe_stv0900_error stv0900_set_mclk(struct stv0900_internal *intp, u32
300{ 300{
301 u32 m_div, clk_sel; 301 u32 m_div, clk_sel;
302 302
303 dprintk("%s: Mclk set to %d, Quartz = %d\n", __func__, mclk,
304 intp->quartz);
305
306 if (intp == NULL) 303 if (intp == NULL)
307 return STV0900_INVALID_HANDLE; 304 return STV0900_INVALID_HANDLE;
308 305
309 if (intp->errs) 306 if (intp->errs)
310 return STV0900_I2C_ERROR; 307 return STV0900_I2C_ERROR;
311 308
309 dprintk("%s: Mclk set to %d, Quartz = %d\n", __func__, mclk,
310 intp->quartz);
311
312 clk_sel = ((stv0900_get_bits(intp, F0900_SELX1RATIO) == 1) ? 4 : 6); 312 clk_sel = ((stv0900_get_bits(intp, F0900_SELX1RATIO) == 1) ? 4 : 6);
313 m_div = ((clk_sel * mclk) / intp->quartz) - 1; 313 m_div = ((clk_sel * mclk) / intp->quartz) - 1;
314 stv0900_write_bits(intp, F0900_M_DIV, m_div); 314 stv0900_write_bits(intp, F0900_M_DIV, m_div);
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 109bc9b12e74..05f8950f6f91 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -53,8 +53,7 @@ MODULE_LICENSE("GPL");
53/* ADV7604 system clock frequency */ 53/* ADV7604 system clock frequency */
54#define ADV7604_fsc (28636360) 54#define ADV7604_fsc (28636360)
55 55
56#define DIGITAL_INPUT ((state->prim_mode == ADV7604_PRIM_MODE_HDMI_COMP) || \ 56#define DIGITAL_INPUT (state->mode == ADV7604_MODE_HDMI)
57 (state->prim_mode == ADV7604_PRIM_MODE_HDMI_GR))
58 57
59/* 58/*
60 ********************************************************************** 59 **********************************************************************
@@ -68,7 +67,7 @@ struct adv7604_state {
68 struct v4l2_subdev sd; 67 struct v4l2_subdev sd;
69 struct media_pad pad; 68 struct media_pad pad;
70 struct v4l2_ctrl_handler hdl; 69 struct v4l2_ctrl_handler hdl;
71 enum adv7604_prim_mode prim_mode; 70 enum adv7604_mode mode;
72 struct v4l2_dv_timings timings; 71 struct v4l2_dv_timings timings;
73 u8 edid[256]; 72 u8 edid[256];
74 unsigned edid_blocks; 73 unsigned edid_blocks;
@@ -77,6 +76,7 @@ struct adv7604_state {
77 struct workqueue_struct *work_queues; 76 struct workqueue_struct *work_queues;
78 struct delayed_work delayed_work_enable_hotplug; 77 struct delayed_work delayed_work_enable_hotplug;
79 bool connector_hdmi; 78 bool connector_hdmi;
79 bool restart_stdi_once;
80 80
81 /* i2c clients */ 81 /* i2c clients */
82 struct i2c_client *i2c_avlink; 82 struct i2c_client *i2c_avlink;
@@ -106,7 +106,6 @@ static const struct v4l2_dv_timings adv7604_timings[] = {
106 V4L2_DV_BT_CEA_720X576P50, 106 V4L2_DV_BT_CEA_720X576P50,
107 V4L2_DV_BT_CEA_1280X720P24, 107 V4L2_DV_BT_CEA_1280X720P24,
108 V4L2_DV_BT_CEA_1280X720P25, 108 V4L2_DV_BT_CEA_1280X720P25,
109 V4L2_DV_BT_CEA_1280X720P30,
110 V4L2_DV_BT_CEA_1280X720P50, 109 V4L2_DV_BT_CEA_1280X720P50,
111 V4L2_DV_BT_CEA_1280X720P60, 110 V4L2_DV_BT_CEA_1280X720P60,
112 V4L2_DV_BT_CEA_1920X1080P24, 111 V4L2_DV_BT_CEA_1920X1080P24,
@@ -115,6 +114,7 @@ static const struct v4l2_dv_timings adv7604_timings[] = {
115 V4L2_DV_BT_CEA_1920X1080P50, 114 V4L2_DV_BT_CEA_1920X1080P50,
116 V4L2_DV_BT_CEA_1920X1080P60, 115 V4L2_DV_BT_CEA_1920X1080P60,
117 116
117 /* sorted by DMT ID */
118 V4L2_DV_BT_DMT_640X350P85, 118 V4L2_DV_BT_DMT_640X350P85,
119 V4L2_DV_BT_DMT_640X400P85, 119 V4L2_DV_BT_DMT_640X400P85,
120 V4L2_DV_BT_DMT_720X400P85, 120 V4L2_DV_BT_DMT_720X400P85,
@@ -164,6 +164,89 @@ static const struct v4l2_dv_timings adv7604_timings[] = {
164 { }, 164 { },
165}; 165};
166 166
167struct adv7604_video_standards {
168 struct v4l2_dv_timings timings;
169 u8 vid_std;
170 u8 v_freq;
171};
172
173/* sorted by number of lines */
174static const struct adv7604_video_standards adv7604_prim_mode_comp[] = {
175 /* { V4L2_DV_BT_CEA_720X480P59_94, 0x0a, 0x00 }, TODO flickering */
176 { V4L2_DV_BT_CEA_720X576P50, 0x0b, 0x00 },
177 { V4L2_DV_BT_CEA_1280X720P50, 0x19, 0x01 },
178 { V4L2_DV_BT_CEA_1280X720P60, 0x19, 0x00 },
179 { V4L2_DV_BT_CEA_1920X1080P24, 0x1e, 0x04 },
180 { V4L2_DV_BT_CEA_1920X1080P25, 0x1e, 0x03 },
181 { V4L2_DV_BT_CEA_1920X1080P30, 0x1e, 0x02 },
182 { V4L2_DV_BT_CEA_1920X1080P50, 0x1e, 0x01 },
183 { V4L2_DV_BT_CEA_1920X1080P60, 0x1e, 0x00 },
184 /* TODO add 1920x1080P60_RB (CVT timing) */
185 { },
186};
187
188/* sorted by number of lines */
189static const struct adv7604_video_standards adv7604_prim_mode_gr[] = {
190 { V4L2_DV_BT_DMT_640X480P60, 0x08, 0x00 },
191 { V4L2_DV_BT_DMT_640X480P72, 0x09, 0x00 },
192 { V4L2_DV_BT_DMT_640X480P75, 0x0a, 0x00 },
193 { V4L2_DV_BT_DMT_640X480P85, 0x0b, 0x00 },
194 { V4L2_DV_BT_DMT_800X600P56, 0x00, 0x00 },
195 { V4L2_DV_BT_DMT_800X600P60, 0x01, 0x00 },
196 { V4L2_DV_BT_DMT_800X600P72, 0x02, 0x00 },
197 { V4L2_DV_BT_DMT_800X600P75, 0x03, 0x00 },
198 { V4L2_DV_BT_DMT_800X600P85, 0x04, 0x00 },
199 { V4L2_DV_BT_DMT_1024X768P60, 0x0c, 0x00 },
200 { V4L2_DV_BT_DMT_1024X768P70, 0x0d, 0x00 },
201 { V4L2_DV_BT_DMT_1024X768P75, 0x0e, 0x00 },
202 { V4L2_DV_BT_DMT_1024X768P85, 0x0f, 0x00 },
203 { V4L2_DV_BT_DMT_1280X1024P60, 0x05, 0x00 },
204 { V4L2_DV_BT_DMT_1280X1024P75, 0x06, 0x00 },
205 { V4L2_DV_BT_DMT_1360X768P60, 0x12, 0x00 },
206 { V4L2_DV_BT_DMT_1366X768P60, 0x13, 0x00 },
207 { V4L2_DV_BT_DMT_1400X1050P60, 0x14, 0x00 },
208 { V4L2_DV_BT_DMT_1400X1050P75, 0x15, 0x00 },
209 { V4L2_DV_BT_DMT_1600X1200P60, 0x16, 0x00 }, /* TODO not tested */
210 /* TODO add 1600X1200P60_RB (not a DMT timing) */
211 { V4L2_DV_BT_DMT_1680X1050P60, 0x18, 0x00 },
212 { V4L2_DV_BT_DMT_1920X1200P60_RB, 0x19, 0x00 }, /* TODO not tested */
213 { },
214};
215
216/* sorted by number of lines */
217static const struct adv7604_video_standards adv7604_prim_mode_hdmi_comp[] = {
218 { V4L2_DV_BT_CEA_720X480P59_94, 0x0a, 0x00 },
219 { V4L2_DV_BT_CEA_720X576P50, 0x0b, 0x00 },
220 { V4L2_DV_BT_CEA_1280X720P50, 0x13, 0x01 },
221 { V4L2_DV_BT_CEA_1280X720P60, 0x13, 0x00 },
222 { V4L2_DV_BT_CEA_1920X1080P24, 0x1e, 0x04 },
223 { V4L2_DV_BT_CEA_1920X1080P25, 0x1e, 0x03 },
224 { V4L2_DV_BT_CEA_1920X1080P30, 0x1e, 0x02 },
225 { V4L2_DV_BT_CEA_1920X1080P50, 0x1e, 0x01 },
226 { V4L2_DV_BT_CEA_1920X1080P60, 0x1e, 0x00 },
227 { },
228};
229
230/* sorted by number of lines */
231static const struct adv7604_video_standards adv7604_prim_mode_hdmi_gr[] = {
232 { V4L2_DV_BT_DMT_640X480P60, 0x08, 0x00 },
233 { V4L2_DV_BT_DMT_640X480P72, 0x09, 0x00 },
234 { V4L2_DV_BT_DMT_640X480P75, 0x0a, 0x00 },
235 { V4L2_DV_BT_DMT_640X480P85, 0x0b, 0x00 },
236 { V4L2_DV_BT_DMT_800X600P56, 0x00, 0x00 },
237 { V4L2_DV_BT_DMT_800X600P60, 0x01, 0x00 },
238 { V4L2_DV_BT_DMT_800X600P72, 0x02, 0x00 },
239 { V4L2_DV_BT_DMT_800X600P75, 0x03, 0x00 },
240 { V4L2_DV_BT_DMT_800X600P85, 0x04, 0x00 },
241 { V4L2_DV_BT_DMT_1024X768P60, 0x0c, 0x00 },
242 { V4L2_DV_BT_DMT_1024X768P70, 0x0d, 0x00 },
243 { V4L2_DV_BT_DMT_1024X768P75, 0x0e, 0x00 },
244 { V4L2_DV_BT_DMT_1024X768P85, 0x0f, 0x00 },
245 { V4L2_DV_BT_DMT_1280X1024P60, 0x05, 0x00 },
246 { V4L2_DV_BT_DMT_1280X1024P75, 0x06, 0x00 },
247 { },
248};
249
167/* ----------------------------------------------------------------------- */ 250/* ----------------------------------------------------------------------- */
168 251
169static inline struct adv7604_state *to_state(struct v4l2_subdev *sd) 252static inline struct adv7604_state *to_state(struct v4l2_subdev *sd)
@@ -672,64 +755,144 @@ static int adv7604_s_detect_tx_5v_ctrl(struct v4l2_subdev *sd)
672 ((io_read(sd, 0x6f) & 0x10) >> 4)); 755 ((io_read(sd, 0x6f) & 0x10) >> 4));
673} 756}
674 757
675static void configure_free_run(struct v4l2_subdev *sd, const struct v4l2_bt_timings *timings) 758static int find_and_set_predefined_video_timings(struct v4l2_subdev *sd,
759 u8 prim_mode,
760 const struct adv7604_video_standards *predef_vid_timings,
761 const struct v4l2_dv_timings *timings)
762{
763 struct adv7604_state *state = to_state(sd);
764 int i;
765
766 for (i = 0; predef_vid_timings[i].timings.bt.width; i++) {
767 if (!v4l_match_dv_timings(timings, &predef_vid_timings[i].timings,
768 DIGITAL_INPUT ? 250000 : 1000000))
769 continue;
770 io_write(sd, 0x00, predef_vid_timings[i].vid_std); /* video std */
771 io_write(sd, 0x01, (predef_vid_timings[i].v_freq << 4) +
772 prim_mode); /* v_freq and prim mode */
773 return 0;
774 }
775
776 return -1;
777}
778
779static int configure_predefined_video_timings(struct v4l2_subdev *sd,
780 struct v4l2_dv_timings *timings)
676{ 781{
782 struct adv7604_state *state = to_state(sd);
783 int err;
784
785 v4l2_dbg(1, debug, sd, "%s", __func__);
786
787 /* reset to default values */
788 io_write(sd, 0x16, 0x43);
789 io_write(sd, 0x17, 0x5a);
790 /* disable embedded syncs for auto graphics mode */
791 cp_write_and_or(sd, 0x81, 0xef, 0x00);
792 cp_write(sd, 0x8f, 0x00);
793 cp_write(sd, 0x90, 0x00);
794 cp_write(sd, 0xa2, 0x00);
795 cp_write(sd, 0xa3, 0x00);
796 cp_write(sd, 0xa4, 0x00);
797 cp_write(sd, 0xa5, 0x00);
798 cp_write(sd, 0xa6, 0x00);
799 cp_write(sd, 0xa7, 0x00);
800 cp_write(sd, 0xab, 0x00);
801 cp_write(sd, 0xac, 0x00);
802
803 switch (state->mode) {
804 case ADV7604_MODE_COMP:
805 case ADV7604_MODE_GR:
806 err = find_and_set_predefined_video_timings(sd,
807 0x01, adv7604_prim_mode_comp, timings);
808 if (err)
809 err = find_and_set_predefined_video_timings(sd,
810 0x02, adv7604_prim_mode_gr, timings);
811 break;
812 case ADV7604_MODE_HDMI:
813 err = find_and_set_predefined_video_timings(sd,
814 0x05, adv7604_prim_mode_hdmi_comp, timings);
815 if (err)
816 err = find_and_set_predefined_video_timings(sd,
817 0x06, adv7604_prim_mode_hdmi_gr, timings);
818 break;
819 default:
820 v4l2_dbg(2, debug, sd, "%s: Unknown mode %d\n",
821 __func__, state->mode);
822 err = -1;
823 break;
824 }
825
826
827 return err;
828}
829
830static void configure_custom_video_timings(struct v4l2_subdev *sd,
831 const struct v4l2_bt_timings *bt)
832{
833 struct adv7604_state *state = to_state(sd);
677 struct i2c_client *client = v4l2_get_subdevdata(sd); 834 struct i2c_client *client = v4l2_get_subdevdata(sd);
678 u32 width = htotal(timings); 835 u32 width = htotal(bt);
679 u32 height = vtotal(timings); 836 u32 height = vtotal(bt);
680 u16 ch1_fr_ll = (((u32)timings->pixelclock / 100) > 0) ? 837 u16 cp_start_sav = bt->hsync + bt->hbackporch - 4;
681 ((width * (ADV7604_fsc / 100)) / ((u32)timings->pixelclock / 100)) : 0; 838 u16 cp_start_eav = width - bt->hfrontporch;
839 u16 cp_start_vbi = height - bt->vfrontporch;
840 u16 cp_end_vbi = bt->vsync + bt->vbackporch;
841 u16 ch1_fr_ll = (((u32)bt->pixelclock / 100) > 0) ?
842 ((width * (ADV7604_fsc / 100)) / ((u32)bt->pixelclock / 100)) : 0;
843 const u8 pll[2] = {
844 0xc0 | ((width >> 8) & 0x1f),
845 width & 0xff
846 };
682 847
683 v4l2_dbg(2, debug, sd, "%s\n", __func__); 848 v4l2_dbg(2, debug, sd, "%s\n", __func__);
684 849
685 cp_write(sd, 0x8f, (ch1_fr_ll >> 8) & 0x7); /* CH1_FR_LL */ 850 switch (state->mode) {
686 cp_write(sd, 0x90, ch1_fr_ll & 0xff); /* CH1_FR_LL */ 851 case ADV7604_MODE_COMP:
687 cp_write(sd, 0xab, (height >> 4) & 0xff); /* CP_LCOUNT_MAX */ 852 case ADV7604_MODE_GR:
688 cp_write(sd, 0xac, (height & 0x0f) << 4); /* CP_LCOUNT_MAX */ 853 /* auto graphics */
689 /* TODO support interlaced */ 854 io_write(sd, 0x00, 0x07); /* video std */
690 cp_write(sd, 0x91, 0x10); /* INTERLACED */ 855 io_write(sd, 0x01, 0x02); /* prim mode */
691 856 /* enable embedded syncs for auto graphics mode */
692 /* Should only be set in auto-graphics mode [REF_02 p. 91-92] */ 857 cp_write_and_or(sd, 0x81, 0xef, 0x10);
693 if ((io_read(sd, 0x00) == 0x07) && (io_read(sd, 0x01) == 0x02)) {
694 u16 cp_start_sav, cp_start_eav, cp_start_vbi, cp_end_vbi;
695 const u8 pll[2] = {
696 (0xc0 | ((width >> 8) & 0x1f)),
697 (width & 0xff)
698 };
699 858
859 /* Should only be set in auto-graphics mode [REF_02, p. 91-92] */
700 /* setup PLL_DIV_MAN_EN and PLL_DIV_RATIO */ 860 /* setup PLL_DIV_MAN_EN and PLL_DIV_RATIO */
701 /* IO-map reg. 0x16 and 0x17 should be written in sequence */ 861 /* IO-map reg. 0x16 and 0x17 should be written in sequence */
702 if (adv_smbus_write_i2c_block_data(client, 0x16, 2, pll)) { 862 if (adv_smbus_write_i2c_block_data(client, 0x16, 2, pll)) {
703 v4l2_err(sd, "writing to reg 0x16 and 0x17 failed\n"); 863 v4l2_err(sd, "writing to reg 0x16 and 0x17 failed\n");
704 return; 864 break;
705 } 865 }
706 866
707 /* active video - horizontal timing */ 867 /* active video - horizontal timing */
708 cp_start_sav = timings->hsync + timings->hbackporch - 4;
709 cp_start_eav = width - timings->hfrontporch;
710 cp_write(sd, 0xa2, (cp_start_sav >> 4) & 0xff); 868 cp_write(sd, 0xa2, (cp_start_sav >> 4) & 0xff);
711 cp_write(sd, 0xa3, ((cp_start_sav & 0x0f) << 4) | ((cp_start_eav >> 8) & 0x0f)); 869 cp_write(sd, 0xa3, ((cp_start_sav & 0x0f) << 4) |
870 ((cp_start_eav >> 8) & 0x0f));
712 cp_write(sd, 0xa4, cp_start_eav & 0xff); 871 cp_write(sd, 0xa4, cp_start_eav & 0xff);
713 872
714 /* active video - vertical timing */ 873 /* active video - vertical timing */
715 cp_start_vbi = height - timings->vfrontporch;
716 cp_end_vbi = timings->vsync + timings->vbackporch;
717 cp_write(sd, 0xa5, (cp_start_vbi >> 4) & 0xff); 874 cp_write(sd, 0xa5, (cp_start_vbi >> 4) & 0xff);
718 cp_write(sd, 0xa6, ((cp_start_vbi & 0xf) << 4) | ((cp_end_vbi >> 8) & 0xf)); 875 cp_write(sd, 0xa6, ((cp_start_vbi & 0xf) << 4) |
876 ((cp_end_vbi >> 8) & 0xf));
719 cp_write(sd, 0xa7, cp_end_vbi & 0xff); 877 cp_write(sd, 0xa7, cp_end_vbi & 0xff);
720 } else { 878 break;
721 /* reset to default values */ 879 case ADV7604_MODE_HDMI:
722 io_write(sd, 0x16, 0x43); 880 /* set default prim_mode/vid_std for HDMI
723 io_write(sd, 0x17, 0x5a); 881 accoring to [REF_03, c. 4.2] */
724 cp_write(sd, 0xa2, 0x00); 882 io_write(sd, 0x00, 0x02); /* video std */
725 cp_write(sd, 0xa3, 0x00); 883 io_write(sd, 0x01, 0x06); /* prim mode */
726 cp_write(sd, 0xa4, 0x00); 884 break;
727 cp_write(sd, 0xa5, 0x00); 885 default:
728 cp_write(sd, 0xa6, 0x00); 886 v4l2_dbg(2, debug, sd, "%s: Unknown mode %d\n",
729 cp_write(sd, 0xa7, 0x00); 887 __func__, state->mode);
888 break;
730 } 889 }
731}
732 890
891 cp_write(sd, 0x8f, (ch1_fr_ll >> 8) & 0x7);
892 cp_write(sd, 0x90, ch1_fr_ll & 0xff);
893 cp_write(sd, 0xab, (height >> 4) & 0xff);
894 cp_write(sd, 0xac, (height & 0x0f) << 4);
895}
733 896
734static void set_rgb_quantization_range(struct v4l2_subdev *sd) 897static void set_rgb_quantization_range(struct v4l2_subdev *sd)
735{ 898{
@@ -738,12 +901,7 @@ static void set_rgb_quantization_range(struct v4l2_subdev *sd)
738 switch (state->rgb_quantization_range) { 901 switch (state->rgb_quantization_range) {
739 case V4L2_DV_RGB_RANGE_AUTO: 902 case V4L2_DV_RGB_RANGE_AUTO:
740 /* automatic */ 903 /* automatic */
741 if ((hdmi_read(sd, 0x05) & 0x80) || 904 if (DIGITAL_INPUT && !(hdmi_read(sd, 0x05) & 0x80)) {
742 (state->prim_mode == ADV7604_PRIM_MODE_COMP) ||
743 (state->prim_mode == ADV7604_PRIM_MODE_RGB)) {
744 /* receiving HDMI or analog signal */
745 io_write_and_or(sd, 0x02, 0x0f, 0xf0);
746 } else {
747 /* receiving DVI-D signal */ 905 /* receiving DVI-D signal */
748 906
749 /* ADV7604 selects RGB limited range regardless of 907 /* ADV7604 selects RGB limited range regardless of
@@ -756,6 +914,9 @@ static void set_rgb_quantization_range(struct v4l2_subdev *sd)
756 /* RGB full range (0-255) */ 914 /* RGB full range (0-255) */
757 io_write_and_or(sd, 0x02, 0x0f, 0x10); 915 io_write_and_or(sd, 0x02, 0x0f, 0x10);
758 } 916 }
917 } else {
918 /* receiving HDMI or analog signal, set automode */
919 io_write_and_or(sd, 0x02, 0x0f, 0xf0);
759 } 920 }
760 break; 921 break;
761 case V4L2_DV_RGB_RANGE_LIMITED: 922 case V4L2_DV_RGB_RANGE_LIMITED:
@@ -967,8 +1128,10 @@ static int stdi2dv_timings(struct v4l2_subdev *sd,
967 state->aspect_ratio, timings)) 1128 state->aspect_ratio, timings))
968 return 0; 1129 return 0;
969 1130
970 v4l2_dbg(2, debug, sd, "%s: No format candidate found for lcf=%d, bl = %d\n", 1131 v4l2_dbg(2, debug, sd,
971 __func__, stdi->lcf, stdi->bl); 1132 "%s: No format candidate found for lcvs = %d, lcf=%d, bl = %d, %chsync, %cvsync\n",
1133 __func__, stdi->lcvs, stdi->lcf, stdi->bl,
1134 stdi->hs_pol, stdi->vs_pol);
972 return -1; 1135 return -1;
973} 1136}
974 1137
@@ -1123,7 +1286,7 @@ static int adv7604_query_dv_timings(struct v4l2_subdev *sd,
1123 adv7604_fill_optional_dv_timings_fields(sd, timings); 1286 adv7604_fill_optional_dv_timings_fields(sd, timings);
1124 } else { 1287 } else {
1125 /* find format 1288 /* find format
1126 * Since LCVS values are inaccurate (REF_03, page 275-276), 1289 * Since LCVS values are inaccurate [REF_03, p. 275-276],
1127 * stdi2dv_timings() is called with lcvs +-1 if the first attempt fails. 1290 * stdi2dv_timings() is called with lcvs +-1 if the first attempt fails.
1128 */ 1291 */
1129 if (!stdi2dv_timings(sd, &stdi, timings)) 1292 if (!stdi2dv_timings(sd, &stdi, timings))
@@ -1135,9 +1298,31 @@ static int adv7604_query_dv_timings(struct v4l2_subdev *sd,
1135 stdi.lcvs -= 2; 1298 stdi.lcvs -= 2;
1136 v4l2_dbg(1, debug, sd, "%s: lcvs - 1 = %d\n", __func__, stdi.lcvs); 1299 v4l2_dbg(1, debug, sd, "%s: lcvs - 1 = %d\n", __func__, stdi.lcvs);
1137 if (stdi2dv_timings(sd, &stdi, timings)) { 1300 if (stdi2dv_timings(sd, &stdi, timings)) {
1301 /*
1302 * The STDI block may measure wrong values, especially
1303 * for lcvs and lcf. If the driver can not find any
1304 * valid timing, the STDI block is restarted to measure
1305 * the video timings again. The function will return an
1306 * error, but the restart of STDI will generate a new
1307 * STDI interrupt and the format detection process will
1308 * restart.
1309 */
1310 if (state->restart_stdi_once) {
1311 v4l2_dbg(1, debug, sd, "%s: restart STDI\n", __func__);
1312 /* TODO restart STDI for Sync Channel 2 */
1313 /* enter one-shot mode */
1314 cp_write_and_or(sd, 0x86, 0xf9, 0x00);
1315 /* trigger STDI restart */
1316 cp_write_and_or(sd, 0x86, 0xf9, 0x04);
1317 /* reset to continuous mode */
1318 cp_write_and_or(sd, 0x86, 0xf9, 0x02);
1319 state->restart_stdi_once = false;
1320 return -ENOLINK;
1321 }
1138 v4l2_dbg(1, debug, sd, "%s: format not supported\n", __func__); 1322 v4l2_dbg(1, debug, sd, "%s: format not supported\n", __func__);
1139 return -ERANGE; 1323 return -ERANGE;
1140 } 1324 }
1325 state->restart_stdi_once = true;
1141 } 1326 }
1142found: 1327found:
1143 1328
@@ -1166,6 +1351,7 @@ static int adv7604_s_dv_timings(struct v4l2_subdev *sd,
1166{ 1351{
1167 struct adv7604_state *state = to_state(sd); 1352 struct adv7604_state *state = to_state(sd);
1168 struct v4l2_bt_timings *bt; 1353 struct v4l2_bt_timings *bt;
1354 int err;
1169 1355
1170 if (!timings) 1356 if (!timings)
1171 return -EINVAL; 1357 return -EINVAL;
@@ -1178,12 +1364,20 @@ static int adv7604_s_dv_timings(struct v4l2_subdev *sd,
1178 __func__, (u32)bt->pixelclock); 1364 __func__, (u32)bt->pixelclock);
1179 return -ERANGE; 1365 return -ERANGE;
1180 } 1366 }
1367
1181 adv7604_fill_optional_dv_timings_fields(sd, timings); 1368 adv7604_fill_optional_dv_timings_fields(sd, timings);
1182 1369
1183 state->timings = *timings; 1370 state->timings = *timings;
1184 1371
1185 /* freerun */ 1372 cp_write(sd, 0x91, bt->interlaced ? 0x50 : 0x10);
1186 configure_free_run(sd, bt); 1373
1374 /* Use prim_mode and vid_std when available */
1375 err = configure_predefined_video_timings(sd, timings);
1376 if (err) {
1377 /* custom settings when the video format
1378 does not have prim_mode/vid_std */
1379 configure_custom_video_timings(sd, bt);
1380 }
1187 1381
1188 set_rgb_quantization_range(sd); 1382 set_rgb_quantization_range(sd);
1189 1383
@@ -1203,24 +1397,25 @@ static int adv7604_g_dv_timings(struct v4l2_subdev *sd,
1203 return 0; 1397 return 0;
1204} 1398}
1205 1399
1206static void enable_input(struct v4l2_subdev *sd, enum adv7604_prim_mode prim_mode) 1400static void enable_input(struct v4l2_subdev *sd)
1207{ 1401{
1208 switch (prim_mode) { 1402 struct adv7604_state *state = to_state(sd);
1209 case ADV7604_PRIM_MODE_COMP: 1403
1210 case ADV7604_PRIM_MODE_RGB: 1404 switch (state->mode) {
1405 case ADV7604_MODE_COMP:
1406 case ADV7604_MODE_GR:
1211 /* enable */ 1407 /* enable */
1212 io_write(sd, 0x15, 0xb0); /* Disable Tristate of Pins (no audio) */ 1408 io_write(sd, 0x15, 0xb0); /* Disable Tristate of Pins (no audio) */
1213 break; 1409 break;
1214 case ADV7604_PRIM_MODE_HDMI_COMP: 1410 case ADV7604_MODE_HDMI:
1215 case ADV7604_PRIM_MODE_HDMI_GR:
1216 /* enable */ 1411 /* enable */
1217 hdmi_write(sd, 0x1a, 0x0a); /* Unmute audio */ 1412 hdmi_write(sd, 0x1a, 0x0a); /* Unmute audio */
1218 hdmi_write(sd, 0x01, 0x00); /* Enable HDMI clock terminators */ 1413 hdmi_write(sd, 0x01, 0x00); /* Enable HDMI clock terminators */
1219 io_write(sd, 0x15, 0xa0); /* Disable Tristate of Pins */ 1414 io_write(sd, 0x15, 0xa0); /* Disable Tristate of Pins */
1220 break; 1415 break;
1221 default: 1416 default:
1222 v4l2_err(sd, "%s: reserved primary mode 0x%0x\n", 1417 v4l2_dbg(2, debug, sd, "%s: Unknown mode %d\n",
1223 __func__, prim_mode); 1418 __func__, state->mode);
1224 break; 1419 break;
1225 } 1420 }
1226} 1421}
@@ -1233,17 +1428,13 @@ static void disable_input(struct v4l2_subdev *sd)
1233 hdmi_write(sd, 0x01, 0x78); /* Disable HDMI clock terminators */ 1428 hdmi_write(sd, 0x01, 0x78); /* Disable HDMI clock terminators */
1234} 1429}
1235 1430
1236static void select_input(struct v4l2_subdev *sd, enum adv7604_prim_mode prim_mode) 1431static void select_input(struct v4l2_subdev *sd)
1237{ 1432{
1238 switch (prim_mode) { 1433 struct adv7604_state *state = to_state(sd);
1239 case ADV7604_PRIM_MODE_COMP:
1240 case ADV7604_PRIM_MODE_RGB:
1241 /* set mode and select free run resolution */
1242 io_write(sd, 0x00, 0x07); /* video std */
1243 io_write(sd, 0x01, 0x02); /* prim mode */
1244 /* enable embedded syncs for auto graphics mode */
1245 cp_write_and_or(sd, 0x81, 0xef, 0x10);
1246 1434
1435 switch (state->mode) {
1436 case ADV7604_MODE_COMP:
1437 case ADV7604_MODE_GR:
1247 /* reset ADI recommended settings for HDMI: */ 1438 /* reset ADI recommended settings for HDMI: */
1248 /* "ADV7604 Register Settings Recommendations (rev. 2.5, June 2010)" p. 4. */ 1439 /* "ADV7604 Register Settings Recommendations (rev. 2.5, June 2010)" p. 4. */
1249 hdmi_write(sd, 0x0d, 0x04); /* HDMI filter optimization */ 1440 hdmi_write(sd, 0x0d, 0x04); /* HDMI filter optimization */
@@ -1271,16 +1462,7 @@ static void select_input(struct v4l2_subdev *sd, enum adv7604_prim_mode prim_mod
1271 cp_write(sd, 0x40, 0x5c); /* CP core pre-gain control. Graphics mode */ 1462 cp_write(sd, 0x40, 0x5c); /* CP core pre-gain control. Graphics mode */
1272 break; 1463 break;
1273 1464
1274 case ADV7604_PRIM_MODE_HDMI_COMP: 1465 case ADV7604_MODE_HDMI:
1275 case ADV7604_PRIM_MODE_HDMI_GR:
1276 /* set mode and select free run resolution */
1277 /* video std */
1278 io_write(sd, 0x00,
1279 (prim_mode == ADV7604_PRIM_MODE_HDMI_GR) ? 0x02 : 0x1e);
1280 io_write(sd, 0x01, prim_mode); /* prim mode */
1281 /* disable embedded syncs for auto graphics mode */
1282 cp_write_and_or(sd, 0x81, 0xef, 0x00);
1283
1284 /* set ADI recommended settings for HDMI: */ 1466 /* set ADI recommended settings for HDMI: */
1285 /* "ADV7604 Register Settings Recommendations (rev. 2.5, June 2010)" p. 4. */ 1467 /* "ADV7604 Register Settings Recommendations (rev. 2.5, June 2010)" p. 4. */
1286 hdmi_write(sd, 0x0d, 0x84); /* HDMI filter optimization */ 1468 hdmi_write(sd, 0x0d, 0x84); /* HDMI filter optimization */
@@ -1309,7 +1491,8 @@ static void select_input(struct v4l2_subdev *sd, enum adv7604_prim_mode prim_mod
1309 1491
1310 break; 1492 break;
1311 default: 1493 default:
1312 v4l2_err(sd, "%s: reserved primary mode 0x%0x\n", __func__, prim_mode); 1494 v4l2_dbg(2, debug, sd, "%s: Unknown mode %d\n",
1495 __func__, state->mode);
1313 break; 1496 break;
1314 } 1497 }
1315} 1498}
@@ -1321,26 +1504,13 @@ static int adv7604_s_routing(struct v4l2_subdev *sd,
1321 1504
1322 v4l2_dbg(2, debug, sd, "%s: input %d", __func__, input); 1505 v4l2_dbg(2, debug, sd, "%s: input %d", __func__, input);
1323 1506
1324 switch (input) { 1507 state->mode = input;
1325 case 0:
1326 /* TODO select HDMI_COMP or HDMI_GR */
1327 state->prim_mode = ADV7604_PRIM_MODE_HDMI_COMP;
1328 break;
1329 case 1:
1330 state->prim_mode = ADV7604_PRIM_MODE_RGB;
1331 break;
1332 case 2:
1333 state->prim_mode = ADV7604_PRIM_MODE_COMP;
1334 break;
1335 default:
1336 return -EINVAL;
1337 }
1338 1508
1339 disable_input(sd); 1509 disable_input(sd);
1340 1510
1341 select_input(sd, state->prim_mode); 1511 select_input(sd);
1342 1512
1343 enable_input(sd, state->prim_mode); 1513 enable_input(sd);
1344 1514
1345 return 0; 1515 return 0;
1346} 1516}
@@ -1549,8 +1719,9 @@ static int adv7604_log_status(struct v4l2_subdev *sd)
1549 v4l2_info(sd, "CP locked: %s\n", no_lock_cp(sd) ? "false" : "true"); 1719 v4l2_info(sd, "CP locked: %s\n", no_lock_cp(sd) ? "false" : "true");
1550 v4l2_info(sd, "CP free run: %s\n", 1720 v4l2_info(sd, "CP free run: %s\n",
1551 (!!(cp_read(sd, 0xff) & 0x10) ? "on" : "off")); 1721 (!!(cp_read(sd, 0xff) & 0x10) ? "on" : "off"));
1552 v4l2_info(sd, "Prim-mode = 0x%x, video std = 0x%x\n", 1722 v4l2_info(sd, "Prim-mode = 0x%x, video std = 0x%x, v_freq = 0x%x\n",
1553 io_read(sd, 0x01) & 0x0f, io_read(sd, 0x00) & 0x3f); 1723 io_read(sd, 0x01) & 0x0f, io_read(sd, 0x00) & 0x3f,
1724 (io_read(sd, 0x01) & 0x70) >> 4);
1554 1725
1555 v4l2_info(sd, "-----Video Timings-----\n"); 1726 v4l2_info(sd, "-----Video Timings-----\n");
1556 if (read_stdi(sd, &stdi)) 1727 if (read_stdi(sd, &stdi))
@@ -1712,9 +1883,9 @@ static int adv7604_core_init(struct v4l2_subdev *sd)
1712 cp_write(sd, 0xba, (pdata->hdmi_free_run_mode << 1) | 0x01); /* HDMI free run */ 1883 cp_write(sd, 0xba, (pdata->hdmi_free_run_mode << 1) | 0x01); /* HDMI free run */
1713 cp_write(sd, 0xf3, 0xdc); /* Low threshold to enter/exit free run mode */ 1884 cp_write(sd, 0xf3, 0xdc); /* Low threshold to enter/exit free run mode */
1714 cp_write(sd, 0xf9, 0x23); /* STDI ch. 1 - LCVS change threshold - 1885 cp_write(sd, 0xf9, 0x23); /* STDI ch. 1 - LCVS change threshold -
1715 ADI recommended setting [REF_01 c. 2.3.3] */ 1886 ADI recommended setting [REF_01, c. 2.3.3] */
1716 cp_write(sd, 0x45, 0x23); /* STDI ch. 2 - LCVS change threshold - 1887 cp_write(sd, 0x45, 0x23); /* STDI ch. 2 - LCVS change threshold -
1717 ADI recommended setting [REF_01 c. 2.3.3] */ 1888 ADI recommended setting [REF_01, c. 2.3.3] */
1718 cp_write(sd, 0xc9, 0x2d); /* use prim_mode and vid_std as free run resolution 1889 cp_write(sd, 0xc9, 0x2d); /* use prim_mode and vid_std as free run resolution
1719 for digital formats */ 1890 for digital formats */
1720 1891
@@ -1724,11 +1895,6 @@ static int adv7604_core_init(struct v4l2_subdev *sd)
1724 afe_write(sd, 0x02, pdata->ain_sel); /* Select analog input muxing mode */ 1895 afe_write(sd, 0x02, pdata->ain_sel); /* Select analog input muxing mode */
1725 io_write_and_or(sd, 0x30, ~(1 << 4), pdata->output_bus_lsb_to_msb << 4); 1896 io_write_and_or(sd, 0x30, ~(1 << 4), pdata->output_bus_lsb_to_msb << 4);
1726 1897
1727 state->prim_mode = pdata->prim_mode;
1728 select_input(sd, pdata->prim_mode);
1729
1730 enable_input(sd, pdata->prim_mode);
1731
1732 /* interrupts */ 1898 /* interrupts */
1733 io_write(sd, 0x40, 0xc2); /* Configure INT1 */ 1899 io_write(sd, 0x40, 0xc2); /* Configure INT1 */
1734 io_write(sd, 0x41, 0xd7); /* STDI irq for any change, disable INT2 */ 1900 io_write(sd, 0x41, 0xd7); /* STDI irq for any change, disable INT2 */
@@ -1883,6 +2049,7 @@ static int adv7604_probe(struct i2c_client *client,
1883 v4l2_err(sd, "failed to create all i2c clients\n"); 2049 v4l2_err(sd, "failed to create all i2c clients\n");
1884 goto err_i2c; 2050 goto err_i2c;
1885 } 2051 }
2052 state->restart_stdi_once = true;
1886 2053
1887 /* work queues */ 2054 /* work queues */
1888 state->work_queues = create_singlethread_workqueue(client->name); 2055 state->work_queues = create_singlethread_workqueue(client->name);
diff --git a/drivers/media/i2c/soc_camera/mt9v022.c b/drivers/media/i2c/soc_camera/mt9v022.c
index 13057b966ee9..333ef178d6fb 100644
--- a/drivers/media/i2c/soc_camera/mt9v022.c
+++ b/drivers/media/i2c/soc_camera/mt9v022.c
@@ -263,9 +263,14 @@ static int mt9v022_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
263 if (ret & 1) /* Autoexposure */ 263 if (ret & 1) /* Autoexposure */
264 ret = reg_write(client, mt9v022->reg->max_total_shutter_width, 264 ret = reg_write(client, mt9v022->reg->max_total_shutter_width,
265 rect.height + mt9v022->y_skip_top + 43); 265 rect.height + mt9v022->y_skip_top + 43);
266 else 266 /*
267 ret = reg_write(client, MT9V022_TOTAL_SHUTTER_WIDTH, 267 * If autoexposure is off, there is no need to set
268 rect.height + mt9v022->y_skip_top + 43); 268 * MT9V022_TOTAL_SHUTTER_WIDTH here. Autoexposure can be off
269 * only if the user has set exposure manually, using the
270 * V4L2_CID_EXPOSURE_AUTO with the value V4L2_EXPOSURE_MANUAL.
271 * In this case the register MT9V022_TOTAL_SHUTTER_WIDTH
272 * already contains the correct value.
273 */
269 } 274 }
270 /* Setup frame format: defaults apart from width and height */ 275 /* Setup frame format: defaults apart from width and height */
271 if (!ret) 276 if (!ret)
diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c b/drivers/media/platform/exynos-gsc/gsc-core.c
index bfec9e65aefb..19cbb12a12a2 100644
--- a/drivers/media/platform/exynos-gsc/gsc-core.c
+++ b/drivers/media/platform/exynos-gsc/gsc-core.c
@@ -965,8 +965,10 @@ static struct platform_device_id gsc_driver_ids[] = {
965MODULE_DEVICE_TABLE(platform, gsc_driver_ids); 965MODULE_DEVICE_TABLE(platform, gsc_driver_ids);
966 966
967static const struct of_device_id exynos_gsc_match[] = { 967static const struct of_device_id exynos_gsc_match[] = {
968 { .compatible = "samsung,exynos5250-gsc", 968 {
969 .data = &gsc_v_100_drvdata, }, 969 .compatible = "samsung,exynos5-gsc",
970 .data = &gsc_v_100_drvdata,
971 },
970 {}, 972 {},
971}; 973};
972MODULE_DEVICE_TABLE(of, exynos_gsc_match); 974MODULE_DEVICE_TABLE(of, exynos_gsc_match);
diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index 3c7f00577bd9..c065d040ed94 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -657,8 +657,7 @@ static int gsc_m2m_release(struct file *file)
657 pr_debug("pid: %d, state: 0x%lx, refcnt= %d", 657 pr_debug("pid: %d, state: 0x%lx, refcnt= %d",
658 task_pid_nr(current), gsc->state, gsc->m2m.refcnt); 658 task_pid_nr(current), gsc->state, gsc->m2m.refcnt);
659 659
660 if (mutex_lock_interruptible(&gsc->lock)) 660 mutex_lock(&gsc->lock);
661 return -ERESTARTSYS;
662 661
663 v4l2_m2m_ctx_release(ctx->m2m_ctx); 662 v4l2_m2m_ctx_release(ctx->m2m_ctx);
664 gsc_ctrls_delete(ctx); 663 gsc_ctrls_delete(ctx);
@@ -732,6 +731,7 @@ int gsc_register_m2m_device(struct gsc_dev *gsc)
732 gsc->vdev.ioctl_ops = &gsc_m2m_ioctl_ops; 731 gsc->vdev.ioctl_ops = &gsc_m2m_ioctl_ops;
733 gsc->vdev.release = video_device_release_empty; 732 gsc->vdev.release = video_device_release_empty;
734 gsc->vdev.lock = &gsc->lock; 733 gsc->vdev.lock = &gsc->lock;
734 gsc->vdev.vfl_dir = VFL_DIR_M2M;
735 snprintf(gsc->vdev.name, sizeof(gsc->vdev.name), "%s.%d:m2m", 735 snprintf(gsc->vdev.name, sizeof(gsc->vdev.name), "%s.%d:m2m",
736 GSC_MODULE_NAME, gsc->id); 736 GSC_MODULE_NAME, gsc->id);
737 737
diff --git a/drivers/media/platform/exynos-gsc/gsc-regs.h b/drivers/media/platform/exynos-gsc/gsc-regs.h
index 533e9947a925..4678f9a6a4fd 100644
--- a/drivers/media/platform/exynos-gsc/gsc-regs.h
+++ b/drivers/media/platform/exynos-gsc/gsc-regs.h
@@ -40,10 +40,10 @@
40#define GSC_IN_ROT_YFLIP (2 << 16) 40#define GSC_IN_ROT_YFLIP (2 << 16)
41#define GSC_IN_ROT_XFLIP (1 << 16) 41#define GSC_IN_ROT_XFLIP (1 << 16)
42#define GSC_IN_RGB_TYPE_MASK (3 << 14) 42#define GSC_IN_RGB_TYPE_MASK (3 << 14)
43#define GSC_IN_RGB_HD_WIDE (3 << 14) 43#define GSC_IN_RGB_HD_NARROW (3 << 14)
44#define GSC_IN_RGB_HD_NARROW (2 << 14) 44#define GSC_IN_RGB_HD_WIDE (2 << 14)
45#define GSC_IN_RGB_SD_WIDE (1 << 14) 45#define GSC_IN_RGB_SD_NARROW (1 << 14)
46#define GSC_IN_RGB_SD_NARROW (0 << 14) 46#define GSC_IN_RGB_SD_WIDE (0 << 14)
47#define GSC_IN_YUV422_1P_ORDER_MASK (1 << 13) 47#define GSC_IN_YUV422_1P_ORDER_MASK (1 << 13)
48#define GSC_IN_YUV422_1P_ORDER_LSB_Y (0 << 13) 48#define GSC_IN_YUV422_1P_ORDER_LSB_Y (0 << 13)
49#define GSC_IN_YUV422_1P_OEDER_LSB_C (1 << 13) 49#define GSC_IN_YUV422_1P_OEDER_LSB_C (1 << 13)
@@ -85,10 +85,10 @@
85#define GSC_OUT_GLOBAL_ALPHA_MASK (0xff << 24) 85#define GSC_OUT_GLOBAL_ALPHA_MASK (0xff << 24)
86#define GSC_OUT_GLOBAL_ALPHA(x) ((x) << 24) 86#define GSC_OUT_GLOBAL_ALPHA(x) ((x) << 24)
87#define GSC_OUT_RGB_TYPE_MASK (3 << 10) 87#define GSC_OUT_RGB_TYPE_MASK (3 << 10)
88#define GSC_OUT_RGB_HD_NARROW (3 << 10) 88#define GSC_OUT_RGB_HD_WIDE (3 << 10)
89#define GSC_OUT_RGB_HD_WIDE (2 << 10) 89#define GSC_OUT_RGB_HD_NARROW (2 << 10)
90#define GSC_OUT_RGB_SD_NARROW (1 << 10) 90#define GSC_OUT_RGB_SD_WIDE (1 << 10)
91#define GSC_OUT_RGB_SD_WIDE (0 << 10) 91#define GSC_OUT_RGB_SD_NARROW (0 << 10)
92#define GSC_OUT_YUV422_1P_ORDER_MASK (1 << 9) 92#define GSC_OUT_YUV422_1P_ORDER_MASK (1 << 9)
93#define GSC_OUT_YUV422_1P_ORDER_LSB_Y (0 << 9) 93#define GSC_OUT_YUV422_1P_ORDER_LSB_Y (0 << 9)
94#define GSC_OUT_YUV422_1P_OEDER_LSB_C (1 << 9) 94#define GSC_OUT_YUV422_1P_OEDER_LSB_C (1 << 9)
diff --git a/drivers/media/platform/omap3isp/ispccdc.c b/drivers/media/platform/omap3isp/ispccdc.c
index 60181ab96063..aa9df9d71a7b 100644
--- a/drivers/media/platform/omap3isp/ispccdc.c
+++ b/drivers/media/platform/omap3isp/ispccdc.c
@@ -1706,7 +1706,7 @@ static long ccdc_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
1706} 1706}
1707 1707
1708static int ccdc_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh, 1708static int ccdc_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
1709 const struct v4l2_event_subscription *sub) 1709 struct v4l2_event_subscription *sub)
1710{ 1710{
1711 if (sub->type != V4L2_EVENT_FRAME_SYNC) 1711 if (sub->type != V4L2_EVENT_FRAME_SYNC)
1712 return -EINVAL; 1712 return -EINVAL;
@@ -1719,7 +1719,7 @@ static int ccdc_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
1719} 1719}
1720 1720
1721static int ccdc_unsubscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh, 1721static int ccdc_unsubscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
1722 const struct v4l2_event_subscription *sub) 1722 struct v4l2_event_subscription *sub)
1723{ 1723{
1724 return v4l2_event_unsubscribe(fh, sub); 1724 return v4l2_event_unsubscribe(fh, sub);
1725} 1725}
diff --git a/drivers/media/platform/omap3isp/ispstat.c b/drivers/media/platform/omap3isp/ispstat.c
index d7ac76b5c2ae..b8640be692f1 100644
--- a/drivers/media/platform/omap3isp/ispstat.c
+++ b/drivers/media/platform/omap3isp/ispstat.c
@@ -1025,7 +1025,7 @@ void omap3isp_stat_dma_isr(struct ispstat *stat)
1025 1025
1026int omap3isp_stat_subscribe_event(struct v4l2_subdev *subdev, 1026int omap3isp_stat_subscribe_event(struct v4l2_subdev *subdev,
1027 struct v4l2_fh *fh, 1027 struct v4l2_fh *fh,
1028 const struct v4l2_event_subscription *sub) 1028 struct v4l2_event_subscription *sub)
1029{ 1029{
1030 struct ispstat *stat = v4l2_get_subdevdata(subdev); 1030 struct ispstat *stat = v4l2_get_subdevdata(subdev);
1031 1031
@@ -1037,7 +1037,7 @@ int omap3isp_stat_subscribe_event(struct v4l2_subdev *subdev,
1037 1037
1038int omap3isp_stat_unsubscribe_event(struct v4l2_subdev *subdev, 1038int omap3isp_stat_unsubscribe_event(struct v4l2_subdev *subdev,
1039 struct v4l2_fh *fh, 1039 struct v4l2_fh *fh,
1040 const struct v4l2_event_subscription *sub) 1040 struct v4l2_event_subscription *sub)
1041{ 1041{
1042 return v4l2_event_unsubscribe(fh, sub); 1042 return v4l2_event_unsubscribe(fh, sub);
1043} 1043}
diff --git a/drivers/media/platform/omap3isp/ispstat.h b/drivers/media/platform/omap3isp/ispstat.h
index a6fe653eb237..9b7c8654dc8a 100644
--- a/drivers/media/platform/omap3isp/ispstat.h
+++ b/drivers/media/platform/omap3isp/ispstat.h
@@ -147,10 +147,10 @@ int omap3isp_stat_init(struct ispstat *stat, const char *name,
147void omap3isp_stat_cleanup(struct ispstat *stat); 147void omap3isp_stat_cleanup(struct ispstat *stat);
148int omap3isp_stat_subscribe_event(struct v4l2_subdev *subdev, 148int omap3isp_stat_subscribe_event(struct v4l2_subdev *subdev,
149 struct v4l2_fh *fh, 149 struct v4l2_fh *fh,
150 const struct v4l2_event_subscription *sub); 150 struct v4l2_event_subscription *sub);
151int omap3isp_stat_unsubscribe_event(struct v4l2_subdev *subdev, 151int omap3isp_stat_unsubscribe_event(struct v4l2_subdev *subdev,
152 struct v4l2_fh *fh, 152 struct v4l2_fh *fh,
153 const struct v4l2_event_subscription *sub); 153 struct v4l2_event_subscription *sub);
154int omap3isp_stat_s_stream(struct v4l2_subdev *subdev, int enable); 154int omap3isp_stat_s_stream(struct v4l2_subdev *subdev, int enable);
155 155
156int omap3isp_stat_busy(struct ispstat *stat); 156int omap3isp_stat_busy(struct ispstat *stat);
diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c
index a0b737fecf13..75cd309035f9 100644
--- a/drivers/media/platform/omap3isp/ispvideo.c
+++ b/drivers/media/platform/omap3isp/ispvideo.c
@@ -792,7 +792,7 @@ isp_video_get_crop(struct file *file, void *fh, struct v4l2_crop *crop)
792} 792}
793 793
794static int 794static int
795isp_video_set_crop(struct file *file, void *fh, struct v4l2_crop *crop) 795isp_video_set_crop(struct file *file, void *fh, const struct v4l2_crop *crop)
796{ 796{
797 struct isp_video *video = video_drvdata(file); 797 struct isp_video *video = video_drvdata(file);
798 struct v4l2_subdev *subdev; 798 struct v4l2_subdev *subdev;
diff --git a/drivers/media/platform/s5p-fimc/Kconfig b/drivers/media/platform/s5p-fimc/Kconfig
index 8f090a8f270e..c16b20d86ed2 100644
--- a/drivers/media/platform/s5p-fimc/Kconfig
+++ b/drivers/media/platform/s5p-fimc/Kconfig
@@ -24,6 +24,7 @@ config VIDEO_S5P_FIMC
24config VIDEO_S5P_MIPI_CSIS 24config VIDEO_S5P_MIPI_CSIS
25 tristate "S5P/EXYNOS MIPI-CSI2 receiver (MIPI-CSIS) driver" 25 tristate "S5P/EXYNOS MIPI-CSI2 receiver (MIPI-CSIS) driver"
26 depends on REGULATOR 26 depends on REGULATOR
27 select S5P_SETUP_MIPIPHY
27 help 28 help
28 This is a V4L2 driver for Samsung S5P and EXYNOS4 SoC MIPI-CSI2 29 This is a V4L2 driver for Samsung S5P and EXYNOS4 SoC MIPI-CSI2
29 receiver (MIPI-CSIS) devices. 30 receiver (MIPI-CSIS) devices.
diff --git a/drivers/media/platform/s5p-fimc/fimc-capture.c b/drivers/media/platform/s5p-fimc/fimc-capture.c
index 367efd164d0f..891ee873c62b 100644
--- a/drivers/media/platform/s5p-fimc/fimc-capture.c
+++ b/drivers/media/platform/s5p-fimc/fimc-capture.c
@@ -556,8 +556,7 @@ static int fimc_capture_close(struct file *file)
556 556
557 dbg("pid: %d, state: 0x%lx", task_pid_nr(current), fimc->state); 557 dbg("pid: %d, state: 0x%lx", task_pid_nr(current), fimc->state);
558 558
559 if (mutex_lock_interruptible(&fimc->lock)) 559 mutex_lock(&fimc->lock);
560 return -ERESTARTSYS;
561 560
562 if (--fimc->vid_cap.refcnt == 0) { 561 if (--fimc->vid_cap.refcnt == 0) {
563 clear_bit(ST_CAPT_BUSY, &fimc->state); 562 clear_bit(ST_CAPT_BUSY, &fimc->state);
@@ -1736,7 +1735,9 @@ static int fimc_register_capture_device(struct fimc_dev *fimc,
1736 q->mem_ops = &vb2_dma_contig_memops; 1735 q->mem_ops = &vb2_dma_contig_memops;
1737 q->buf_struct_size = sizeof(struct fimc_vid_buffer); 1736 q->buf_struct_size = sizeof(struct fimc_vid_buffer);
1738 1737
1739 vb2_queue_init(q); 1738 ret = vb2_queue_init(q);
1739 if (ret)
1740 goto err_ent;
1740 1741
1741 vid_cap->vd_pad.flags = MEDIA_PAD_FL_SINK; 1742 vid_cap->vd_pad.flags = MEDIA_PAD_FL_SINK;
1742 ret = media_entity_init(&vfd->entity, 1, &vid_cap->vd_pad, 0); 1743 ret = media_entity_init(&vfd->entity, 1, &vid_cap->vd_pad, 0);
@@ -1772,9 +1773,13 @@ static int fimc_capture_subdev_registered(struct v4l2_subdev *sd)
1772 if (ret) 1773 if (ret)
1773 return ret; 1774 return ret;
1774 1775
1776 fimc->pipeline_ops = v4l2_get_subdev_hostdata(sd);
1777
1775 ret = fimc_register_capture_device(fimc, sd->v4l2_dev); 1778 ret = fimc_register_capture_device(fimc, sd->v4l2_dev);
1776 if (ret) 1779 if (ret) {
1777 fimc_unregister_m2m_device(fimc); 1780 fimc_unregister_m2m_device(fimc);
1781 fimc->pipeline_ops = NULL;
1782 }
1778 1783
1779 return ret; 1784 return ret;
1780} 1785}
@@ -1791,6 +1796,7 @@ static void fimc_capture_subdev_unregistered(struct v4l2_subdev *sd)
1791 if (video_is_registered(&fimc->vid_cap.vfd)) { 1796 if (video_is_registered(&fimc->vid_cap.vfd)) {
1792 video_unregister_device(&fimc->vid_cap.vfd); 1797 video_unregister_device(&fimc->vid_cap.vfd);
1793 media_entity_cleanup(&fimc->vid_cap.vfd.entity); 1798 media_entity_cleanup(&fimc->vid_cap.vfd.entity);
1799 fimc->pipeline_ops = NULL;
1794 } 1800 }
1795 kfree(fimc->vid_cap.ctx); 1801 kfree(fimc->vid_cap.ctx);
1796 fimc->vid_cap.ctx = NULL; 1802 fimc->vid_cap.ctx = NULL;
diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.c b/drivers/media/platform/s5p-fimc/fimc-lite.c
index 70bcf39de879..1b309a72f09f 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite.c
+++ b/drivers/media/platform/s5p-fimc/fimc-lite.c
@@ -491,8 +491,7 @@ static int fimc_lite_close(struct file *file)
491 struct fimc_lite *fimc = video_drvdata(file); 491 struct fimc_lite *fimc = video_drvdata(file);
492 int ret; 492 int ret;
493 493
494 if (mutex_lock_interruptible(&fimc->lock)) 494 mutex_lock(&fimc->lock);
495 return -ERESTARTSYS;
496 495
497 if (--fimc->ref_count == 0 && fimc->out_path == FIMC_IO_DMA) { 496 if (--fimc->ref_count == 0 && fimc->out_path == FIMC_IO_DMA) {
498 clear_bit(ST_FLITE_IN_USE, &fimc->state); 497 clear_bit(ST_FLITE_IN_USE, &fimc->state);
@@ -1253,7 +1252,9 @@ static int fimc_lite_subdev_registered(struct v4l2_subdev *sd)
1253 q->buf_struct_size = sizeof(struct flite_buffer); 1252 q->buf_struct_size = sizeof(struct flite_buffer);
1254 q->drv_priv = fimc; 1253 q->drv_priv = fimc;
1255 1254
1256 vb2_queue_init(q); 1255 ret = vb2_queue_init(q);
1256 if (ret < 0)
1257 return ret;
1257 1258
1258 fimc->vd_pad.flags = MEDIA_PAD_FL_SINK; 1259 fimc->vd_pad.flags = MEDIA_PAD_FL_SINK;
1259 ret = media_entity_init(&vfd->entity, 1, &fimc->vd_pad, 0); 1260 ret = media_entity_init(&vfd->entity, 1, &fimc->vd_pad, 0);
@@ -1261,10 +1262,12 @@ static int fimc_lite_subdev_registered(struct v4l2_subdev *sd)
1261 return ret; 1262 return ret;
1262 1263
1263 video_set_drvdata(vfd, fimc); 1264 video_set_drvdata(vfd, fimc);
1265 fimc->pipeline_ops = v4l2_get_subdev_hostdata(sd);
1264 1266
1265 ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1); 1267 ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1);
1266 if (ret < 0) { 1268 if (ret < 0) {
1267 media_entity_cleanup(&vfd->entity); 1269 media_entity_cleanup(&vfd->entity);
1270 fimc->pipeline_ops = NULL;
1268 return ret; 1271 return ret;
1269 } 1272 }
1270 1273
@@ -1283,6 +1286,7 @@ static void fimc_lite_subdev_unregistered(struct v4l2_subdev *sd)
1283 if (video_is_registered(&fimc->vfd)) { 1286 if (video_is_registered(&fimc->vfd)) {
1284 video_unregister_device(&fimc->vfd); 1287 video_unregister_device(&fimc->vfd);
1285 media_entity_cleanup(&fimc->vfd.entity); 1288 media_entity_cleanup(&fimc->vfd.entity);
1289 fimc->pipeline_ops = NULL;
1286 } 1290 }
1287} 1291}
1288 1292
diff --git a/drivers/media/platform/s5p-fimc/fimc-m2m.c b/drivers/media/platform/s5p-fimc/fimc-m2m.c
index 4500e44f6857..62afed3162ea 100644
--- a/drivers/media/platform/s5p-fimc/fimc-m2m.c
+++ b/drivers/media/platform/s5p-fimc/fimc-m2m.c
@@ -718,8 +718,7 @@ static int fimc_m2m_release(struct file *file)
718 dbg("pid: %d, state: 0x%lx, refcnt= %d", 718 dbg("pid: %d, state: 0x%lx, refcnt= %d",
719 task_pid_nr(current), fimc->state, fimc->m2m.refcnt); 719 task_pid_nr(current), fimc->state, fimc->m2m.refcnt);
720 720
721 if (mutex_lock_interruptible(&fimc->lock)) 721 mutex_lock(&fimc->lock);
722 return -ERESTARTSYS;
723 722
724 v4l2_m2m_ctx_release(ctx->m2m_ctx); 723 v4l2_m2m_ctx_release(ctx->m2m_ctx);
725 fimc_ctrls_delete(ctx); 724 fimc_ctrls_delete(ctx);
diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
index 80ada5882f62..0531ab70a94c 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
@@ -343,53 +343,50 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)
343static int fimc_register_callback(struct device *dev, void *p) 343static int fimc_register_callback(struct device *dev, void *p)
344{ 344{
345 struct fimc_dev *fimc = dev_get_drvdata(dev); 345 struct fimc_dev *fimc = dev_get_drvdata(dev);
346 struct v4l2_subdev *sd = &fimc->vid_cap.subdev; 346 struct v4l2_subdev *sd;
347 struct fimc_md *fmd = p; 347 struct fimc_md *fmd = p;
348 int ret = 0; 348 int ret;
349
350 if (!fimc || !fimc->pdev)
351 return 0;
352 349
353 if (fimc->pdev->id < 0 || fimc->pdev->id >= FIMC_MAX_DEVS) 350 if (fimc == NULL || fimc->id >= FIMC_MAX_DEVS)
354 return 0; 351 return 0;
355 352
356 fimc->pipeline_ops = &fimc_pipeline_ops; 353 sd = &fimc->vid_cap.subdev;
357 fmd->fimc[fimc->pdev->id] = fimc;
358 sd->grp_id = FIMC_GROUP_ID; 354 sd->grp_id = FIMC_GROUP_ID;
355 v4l2_set_subdev_hostdata(sd, (void *)&fimc_pipeline_ops);
359 356
360 ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); 357 ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd);
361 if (ret) { 358 if (ret) {
362 v4l2_err(&fmd->v4l2_dev, "Failed to register FIMC.%d (%d)\n", 359 v4l2_err(&fmd->v4l2_dev, "Failed to register FIMC.%d (%d)\n",
363 fimc->id, ret); 360 fimc->id, ret);
361 return ret;
364 } 362 }
365 363
366 return ret; 364 fmd->fimc[fimc->id] = fimc;
365 return 0;
367} 366}
368 367
369static int fimc_lite_register_callback(struct device *dev, void *p) 368static int fimc_lite_register_callback(struct device *dev, void *p)
370{ 369{
371 struct fimc_lite *fimc = dev_get_drvdata(dev); 370 struct fimc_lite *fimc = dev_get_drvdata(dev);
372 struct v4l2_subdev *sd = &fimc->subdev;
373 struct fimc_md *fmd = p; 371 struct fimc_md *fmd = p;
374 int ret; 372 int ret;
375 373
376 if (fimc == NULL) 374 if (fimc == NULL || fimc->index >= FIMC_LITE_MAX_DEVS)
377 return 0; 375 return 0;
378 376
379 if (fimc->index >= FIMC_LITE_MAX_DEVS) 377 fimc->subdev.grp_id = FLITE_GROUP_ID;
380 return 0; 378 v4l2_set_subdev_hostdata(&fimc->subdev, (void *)&fimc_pipeline_ops);
381
382 fimc->pipeline_ops = &fimc_pipeline_ops;
383 fmd->fimc_lite[fimc->index] = fimc;
384 sd->grp_id = FLITE_GROUP_ID;
385 379
386 ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); 380 ret = v4l2_device_register_subdev(&fmd->v4l2_dev, &fimc->subdev);
387 if (ret) { 381 if (ret) {
388 v4l2_err(&fmd->v4l2_dev, 382 v4l2_err(&fmd->v4l2_dev,
389 "Failed to register FIMC-LITE.%d (%d)\n", 383 "Failed to register FIMC-LITE.%d (%d)\n",
390 fimc->index, ret); 384 fimc->index, ret);
385 return ret;
391 } 386 }
392 return ret; 387
388 fmd->fimc_lite[fimc->index] = fimc;
389 return 0;
393} 390}
394 391
395static int csis_register_callback(struct device *dev, void *p) 392static int csis_register_callback(struct device *dev, void *p)
@@ -407,10 +404,12 @@ static int csis_register_callback(struct device *dev, void *p)
407 v4l2_info(sd, "csis%d sd: %s\n", pdev->id, sd->name); 404 v4l2_info(sd, "csis%d sd: %s\n", pdev->id, sd->name);
408 405
409 id = pdev->id < 0 ? 0 : pdev->id; 406 id = pdev->id < 0 ? 0 : pdev->id;
410 fmd->csis[id].sd = sd;
411 sd->grp_id = CSIS_GROUP_ID; 407 sd->grp_id = CSIS_GROUP_ID;
408
412 ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); 409 ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd);
413 if (ret) 410 if (!ret)
411 fmd->csis[id].sd = sd;
412 else
414 v4l2_err(&fmd->v4l2_dev, 413 v4l2_err(&fmd->v4l2_dev,
415 "Failed to register CSIS subdevice: %d\n", ret); 414 "Failed to register CSIS subdevice: %d\n", ret);
416 return ret; 415 return ret;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 130f4ac8649e..3afe879d54d7 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -381,11 +381,8 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx,
381 ctx->consumed_stream += s5p_mfc_hw_call(dev->mfc_ops, 381 ctx->consumed_stream += s5p_mfc_hw_call(dev->mfc_ops,
382 get_consumed_stream, dev); 382 get_consumed_stream, dev);
383 if (ctx->codec_mode != S5P_MFC_CODEC_H264_DEC && 383 if (ctx->codec_mode != S5P_MFC_CODEC_H264_DEC &&
384 s5p_mfc_hw_call(dev->mfc_ops, 384 ctx->consumed_stream + STUFF_BYTE <
385 get_dec_frame_type, dev) == 385 src_buf->b->v4l2_planes[0].bytesused) {
386 S5P_FIMV_DECODE_FRAME_P_FRAME
387 && ctx->consumed_stream + STUFF_BYTE <
388 src_buf->b->v4l2_planes[0].bytesused) {
389 /* Run MFC again on the same buffer */ 386 /* Run MFC again on the same buffer */
390 mfc_debug(2, "Running again the same buffer\n"); 387 mfc_debug(2, "Running again the same buffer\n");
391 ctx->after_packed_pb = 1; 388 ctx->after_packed_pb = 1;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
index 50b5bee3c44e..3a8cfd9fc1bd 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
@@ -1762,7 +1762,7 @@ int s5p_mfc_get_dspl_y_adr_v6(struct s5p_mfc_dev *dev)
1762 1762
1763int s5p_mfc_get_dec_y_adr_v6(struct s5p_mfc_dev *dev) 1763int s5p_mfc_get_dec_y_adr_v6(struct s5p_mfc_dev *dev)
1764{ 1764{
1765 return mfc_read(dev, S5P_FIMV_D_DISPLAY_LUMA_ADDR_V6); 1765 return mfc_read(dev, S5P_FIMV_D_DECODED_LUMA_ADDR_V6);
1766} 1766}
1767 1767
1768int s5p_mfc_get_dspl_status_v6(struct s5p_mfc_dev *dev) 1768int s5p_mfc_get_dspl_status_v6(struct s5p_mfc_dev *dev)
diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c
index 85fd312f0a82..a1c87f0ceaab 100644
--- a/drivers/media/platform/sh_vou.c
+++ b/drivers/media/platform/sh_vou.c
@@ -935,9 +935,10 @@ static int sh_vou_g_crop(struct file *file, void *fh, struct v4l2_crop *a)
935/* Assume a dull encoder, do all the work ourselves. */ 935/* Assume a dull encoder, do all the work ourselves. */
936static int sh_vou_s_crop(struct file *file, void *fh, const struct v4l2_crop *a) 936static int sh_vou_s_crop(struct file *file, void *fh, const struct v4l2_crop *a)
937{ 937{
938 struct v4l2_crop a_writable = *a;
938 struct video_device *vdev = video_devdata(file); 939 struct video_device *vdev = video_devdata(file);
939 struct sh_vou_device *vou_dev = video_get_drvdata(vdev); 940 struct sh_vou_device *vou_dev = video_get_drvdata(vdev);
940 struct v4l2_rect *rect = &a->c; 941 struct v4l2_rect *rect = &a_writable.c;
941 struct v4l2_crop sd_crop = {.type = V4L2_BUF_TYPE_VIDEO_OUTPUT}; 942 struct v4l2_crop sd_crop = {.type = V4L2_BUF_TYPE_VIDEO_OUTPUT};
942 struct v4l2_pix_format *pix = &vou_dev->pix; 943 struct v4l2_pix_format *pix = &vou_dev->pix;
943 struct sh_vou_geometry geo; 944 struct sh_vou_geometry geo;
diff --git a/drivers/media/platform/soc_camera/mx1_camera.c b/drivers/media/platform/soc_camera/mx1_camera.c
index bbe70991d30b..032b8c9097f9 100644
--- a/drivers/media/platform/soc_camera/mx1_camera.c
+++ b/drivers/media/platform/soc_camera/mx1_camera.c
@@ -470,14 +470,6 @@ static void mx1_camera_remove_device(struct soc_camera_device *icd)
470 pcdev->icd = NULL; 470 pcdev->icd = NULL;
471} 471}
472 472
473static int mx1_camera_set_crop(struct soc_camera_device *icd,
474 struct v4l2_crop *a)
475{
476 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
477
478 return v4l2_subdev_call(sd, video, s_crop, a);
479}
480
481static int mx1_camera_set_bus_param(struct soc_camera_device *icd) 473static int mx1_camera_set_bus_param(struct soc_camera_device *icd)
482{ 474{
483 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); 475 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
@@ -689,7 +681,6 @@ static struct soc_camera_host_ops mx1_soc_camera_host_ops = {
689 .add = mx1_camera_add_device, 681 .add = mx1_camera_add_device,
690 .remove = mx1_camera_remove_device, 682 .remove = mx1_camera_remove_device,
691 .set_bus_param = mx1_camera_set_bus_param, 683 .set_bus_param = mx1_camera_set_bus_param,
692 .set_crop = mx1_camera_set_crop,
693 .set_fmt = mx1_camera_set_fmt, 684 .set_fmt = mx1_camera_set_fmt,
694 .try_fmt = mx1_camera_try_fmt, 685 .try_fmt = mx1_camera_try_fmt,
695 .init_videobuf = mx1_camera_init_videobuf, 686 .init_videobuf = mx1_camera_init_videobuf,
diff --git a/drivers/media/platform/soc_camera/mx2_camera.c b/drivers/media/platform/soc_camera/mx2_camera.c
index 9fd9d1c5b218..9a55f4c4c7f4 100644
--- a/drivers/media/platform/soc_camera/mx2_camera.c
+++ b/drivers/media/platform/soc_camera/mx2_camera.c
@@ -864,8 +864,10 @@ static int mx2_start_streaming(struct vb2_queue *q, unsigned int count)
864 864
865 bytesperline = soc_mbus_bytes_per_line(icd->user_width, 865 bytesperline = soc_mbus_bytes_per_line(icd->user_width,
866 icd->current_fmt->host_fmt); 866 icd->current_fmt->host_fmt);
867 if (bytesperline < 0) 867 if (bytesperline < 0) {
868 spin_unlock_irqrestore(&pcdev->lock, flags);
868 return bytesperline; 869 return bytesperline;
870 }
869 871
870 /* 872 /*
871 * I didn't manage to properly enable/disable the prp 873 * I didn't manage to properly enable/disable the prp
@@ -878,8 +880,10 @@ static int mx2_start_streaming(struct vb2_queue *q, unsigned int count)
878 pcdev->discard_buffer = dma_alloc_coherent(ici->v4l2_dev.dev, 880 pcdev->discard_buffer = dma_alloc_coherent(ici->v4l2_dev.dev,
879 pcdev->discard_size, &pcdev->discard_buffer_dma, 881 pcdev->discard_size, &pcdev->discard_buffer_dma,
880 GFP_KERNEL); 882 GFP_KERNEL);
881 if (!pcdev->discard_buffer) 883 if (!pcdev->discard_buffer) {
884 spin_unlock_irqrestore(&pcdev->lock, flags);
882 return -ENOMEM; 885 return -ENOMEM;
886 }
883 887
884 pcdev->buf_discard[0].discard = true; 888 pcdev->buf_discard[0].discard = true;
885 list_add_tail(&pcdev->buf_discard[0].queue, 889 list_add_tail(&pcdev->buf_discard[0].queue,
@@ -1099,9 +1103,10 @@ static int mx2_camera_set_bus_param(struct soc_camera_device *icd)
1099} 1103}
1100 1104
1101static int mx2_camera_set_crop(struct soc_camera_device *icd, 1105static int mx2_camera_set_crop(struct soc_camera_device *icd,
1102 struct v4l2_crop *a) 1106 const struct v4l2_crop *a)
1103{ 1107{
1104 struct v4l2_rect *rect = &a->c; 1108 struct v4l2_crop a_writable = *a;
1109 struct v4l2_rect *rect = &a_writable.c;
1105 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); 1110 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
1106 struct v4l2_mbus_framefmt mf; 1111 struct v4l2_mbus_framefmt mf;
1107 int ret; 1112 int ret;
diff --git a/drivers/media/platform/soc_camera/mx3_camera.c b/drivers/media/platform/soc_camera/mx3_camera.c
index 3557ac97e430..261f6e9e1b17 100644
--- a/drivers/media/platform/soc_camera/mx3_camera.c
+++ b/drivers/media/platform/soc_camera/mx3_camera.c
@@ -799,9 +799,10 @@ static inline void stride_align(__u32 *width)
799 * default g_crop and cropcap from soc_camera.c 799 * default g_crop and cropcap from soc_camera.c
800 */ 800 */
801static int mx3_camera_set_crop(struct soc_camera_device *icd, 801static int mx3_camera_set_crop(struct soc_camera_device *icd,
802 struct v4l2_crop *a) 802 const struct v4l2_crop *a)
803{ 803{
804 struct v4l2_rect *rect = &a->c; 804 struct v4l2_crop a_writable = *a;
805 struct v4l2_rect *rect = &a_writable.c;
805 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); 806 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
806 struct mx3_camera_dev *mx3_cam = ici->priv; 807 struct mx3_camera_dev *mx3_cam = ici->priv;
807 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); 808 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
diff --git a/drivers/media/platform/soc_camera/omap1_camera.c b/drivers/media/platform/soc_camera/omap1_camera.c
index fa08c7695ccb..13636a585106 100644
--- a/drivers/media/platform/soc_camera/omap1_camera.c
+++ b/drivers/media/platform/soc_camera/omap1_camera.c
@@ -1215,9 +1215,9 @@ static int set_mbus_format(struct omap1_cam_dev *pcdev, struct device *dev,
1215} 1215}
1216 1216
1217static int omap1_cam_set_crop(struct soc_camera_device *icd, 1217static int omap1_cam_set_crop(struct soc_camera_device *icd,
1218 struct v4l2_crop *crop) 1218 const struct v4l2_crop *crop)
1219{ 1219{
1220 struct v4l2_rect *rect = &crop->c; 1220 const struct v4l2_rect *rect = &crop->c;
1221 const struct soc_camera_format_xlate *xlate = icd->current_fmt; 1221 const struct soc_camera_format_xlate *xlate = icd->current_fmt;
1222 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); 1222 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
1223 struct device *dev = icd->parent; 1223 struct device *dev = icd->parent;
diff --git a/drivers/media/platform/soc_camera/pxa_camera.c b/drivers/media/platform/soc_camera/pxa_camera.c
index 1e3776d08dac..3434ffe79c6e 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -1337,9 +1337,9 @@ static int pxa_camera_check_frame(u32 width, u32 height)
1337} 1337}
1338 1338
1339static int pxa_camera_set_crop(struct soc_camera_device *icd, 1339static int pxa_camera_set_crop(struct soc_camera_device *icd,
1340 struct v4l2_crop *a) 1340 const struct v4l2_crop *a)
1341{ 1341{
1342 struct v4l2_rect *rect = &a->c; 1342 const struct v4l2_rect *rect = &a->c;
1343 struct device *dev = icd->parent; 1343 struct device *dev = icd->parent;
1344 struct soc_camera_host *ici = to_soc_camera_host(dev); 1344 struct soc_camera_host *ici = to_soc_camera_host(dev);
1345 struct pxa_camera_dev *pcdev = ici->priv; 1345 struct pxa_camera_dev *pcdev = ici->priv;
diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
index 0a24253dcda2..2d8861c0e8f2 100644
--- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
+++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
@@ -1182,13 +1182,13 @@ static void sh_mobile_ceu_put_formats(struct soc_camera_device *icd)
1182} 1182}
1183 1183
1184/* Check if any dimension of r1 is smaller than respective one of r2 */ 1184/* Check if any dimension of r1 is smaller than respective one of r2 */
1185static bool is_smaller(struct v4l2_rect *r1, struct v4l2_rect *r2) 1185static bool is_smaller(const struct v4l2_rect *r1, const struct v4l2_rect *r2)
1186{ 1186{
1187 return r1->width < r2->width || r1->height < r2->height; 1187 return r1->width < r2->width || r1->height < r2->height;
1188} 1188}
1189 1189
1190/* Check if r1 fails to cover r2 */ 1190/* Check if r1 fails to cover r2 */
1191static bool is_inside(struct v4l2_rect *r1, struct v4l2_rect *r2) 1191static bool is_inside(const struct v4l2_rect *r1, const struct v4l2_rect *r2)
1192{ 1192{
1193 return r1->left > r2->left || r1->top > r2->top || 1193 return r1->left > r2->left || r1->top > r2->top ||
1194 r1->left + r1->width < r2->left + r2->width || 1194 r1->left + r1->width < r2->left + r2->width ||
@@ -1263,7 +1263,7 @@ static void update_subrect(struct sh_mobile_ceu_cam *cam)
1263 * 3. if (2) failed, try to request the maximum image 1263 * 3. if (2) failed, try to request the maximum image
1264 */ 1264 */
1265static int client_s_crop(struct soc_camera_device *icd, struct v4l2_crop *crop, 1265static int client_s_crop(struct soc_camera_device *icd, struct v4l2_crop *crop,
1266 const struct v4l2_crop *cam_crop) 1266 struct v4l2_crop *cam_crop)
1267{ 1267{
1268 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); 1268 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
1269 struct v4l2_rect *rect = &crop->c, *cam_rect = &cam_crop->c; 1269 struct v4l2_rect *rect = &crop->c, *cam_rect = &cam_crop->c;
@@ -1519,7 +1519,8 @@ static int client_scale(struct soc_camera_device *icd,
1519static int sh_mobile_ceu_set_crop(struct soc_camera_device *icd, 1519static int sh_mobile_ceu_set_crop(struct soc_camera_device *icd,
1520 const struct v4l2_crop *a) 1520 const struct v4l2_crop *a)
1521{ 1521{
1522 struct v4l2_rect *rect = &a->c; 1522 struct v4l2_crop a_writable = *a;
1523 const struct v4l2_rect *rect = &a_writable.c;
1523 struct device *dev = icd->parent; 1524 struct device *dev = icd->parent;
1524 struct soc_camera_host *ici = to_soc_camera_host(dev); 1525 struct soc_camera_host *ici = to_soc_camera_host(dev);
1525 struct sh_mobile_ceu_dev *pcdev = ici->priv; 1526 struct sh_mobile_ceu_dev *pcdev = ici->priv;
@@ -1545,7 +1546,7 @@ static int sh_mobile_ceu_set_crop(struct soc_camera_device *icd,
1545 * 1. - 2. Apply iterative camera S_CROP for new input window, read back 1546 * 1. - 2. Apply iterative camera S_CROP for new input window, read back
1546 * actual camera rectangle. 1547 * actual camera rectangle.
1547 */ 1548 */
1548 ret = client_s_crop(icd, a, &cam_crop); 1549 ret = client_s_crop(icd, &a_writable, &cam_crop);
1549 if (ret < 0) 1550 if (ret < 0)
1550 return ret; 1551 return ret;
1551 1552
@@ -1946,7 +1947,7 @@ static int sh_mobile_ceu_try_fmt(struct soc_camera_device *icd,
1946} 1947}
1947 1948
1948static int sh_mobile_ceu_set_livecrop(struct soc_camera_device *icd, 1949static int sh_mobile_ceu_set_livecrop(struct soc_camera_device *icd,
1949 struct v4l2_crop *a) 1950 const struct v4l2_crop *a)
1950{ 1951{
1951 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); 1952 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
1952 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); 1953 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
index 9859d2a2449b..ba51f65204de 100644
--- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
+++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
@@ -283,14 +283,13 @@ static inline int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed,
283 283
284 /* activate the pid on the device pid filter */ 284 /* activate the pid on the device pid filter */
285 if (adap->props->caps & DVB_USB_ADAP_HAS_PID_FILTER && 285 if (adap->props->caps & DVB_USB_ADAP_HAS_PID_FILTER &&
286 adap->pid_filtering && 286 adap->pid_filtering && adap->props->pid_filter) {
287 adap->props->pid_filter)
288 ret = adap->props->pid_filter(adap, dvbdmxfeed->index, 287 ret = adap->props->pid_filter(adap, dvbdmxfeed->index,
289 dvbdmxfeed->pid, (count == 1) ? 1 : 0); 288 dvbdmxfeed->pid, (count == 1) ? 1 : 0);
290 if (ret < 0) 289 if (ret < 0)
291 dev_err(&d->udev->dev, "%s: pid_filter() " \ 290 dev_err(&d->udev->dev, "%s: pid_filter() failed=%d\n",
292 "failed=%d\n", KBUILD_MODNAME, 291 KBUILD_MODNAME, ret);
293 ret); 292 }
294 293
295 /* start feeding if it is first pid */ 294 /* start feeding if it is first pid */
296 if (adap->feed_count == 1 && count == 1) { 295 if (adap->feed_count == 1 && count == 1) {
diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c
index 0431beed0ef4..5716662b4834 100644
--- a/drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c
+++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c
@@ -32,9 +32,7 @@ int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf,
32 return -EINVAL; 32 return -EINVAL;
33 } 33 }
34 34
35 ret = mutex_lock_interruptible(&d->usb_mutex); 35 mutex_lock(&d->usb_mutex);
36 if (ret < 0)
37 return ret;
38 36
39 dev_dbg(&d->udev->dev, "%s: >>> %*ph\n", __func__, wlen, wbuf); 37 dev_dbg(&d->udev->dev, "%s: >>> %*ph\n", __func__, wlen, wbuf);
40 38
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index adabba8d28bc..093f1acce403 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -1346,6 +1346,10 @@ static const struct usb_device_id rtl28xxu_id_table[] = {
1346 &rtl2832u_props, "DigitalNow Quad DVB-T Receiver", NULL) }, 1346 &rtl2832u_props, "DigitalNow Quad DVB-T Receiver", NULL) },
1347 { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00d3, 1347 { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00d3,
1348 &rtl2832u_props, "TerraTec Cinergy T Stick RC (Rev. 3)", NULL) }, 1348 &rtl2832u_props, "TerraTec Cinergy T Stick RC (Rev. 3)", NULL) },
1349 { DVB_USB_DEVICE(USB_VID_DEXATEK, 0x1102,
1350 &rtl2832u_props, "Dexatek DK mini DVB-T Dongle", NULL) },
1351 { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00d7,
1352 &rtl2832u_props, "TerraTec Cinergy T Stick+", NULL) },
1349 { } 1353 { }
1350}; 1354};
1351MODULE_DEVICE_TABLE(usb, rtl28xxu_id_table); 1355MODULE_DEVICE_TABLE(usb, rtl28xxu_id_table);
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index 75619711a9e7..dae9db0b5f78 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -98,9 +98,9 @@ static irqreturn_t arizona_underclocked(int irq, void *data)
98 98
99 if (val & ARIZONA_AIF3_UNDERCLOCKED_STS) 99 if (val & ARIZONA_AIF3_UNDERCLOCKED_STS)
100 dev_err(arizona->dev, "AIF3 underclocked\n"); 100 dev_err(arizona->dev, "AIF3 underclocked\n");
101 if (val & ARIZONA_AIF3_UNDERCLOCKED_STS)
102 dev_err(arizona->dev, "AIF3 underclocked\n");
103 if (val & ARIZONA_AIF2_UNDERCLOCKED_STS) 101 if (val & ARIZONA_AIF2_UNDERCLOCKED_STS)
102 dev_err(arizona->dev, "AIF2 underclocked\n");
103 if (val & ARIZONA_AIF1_UNDERCLOCKED_STS)
104 dev_err(arizona->dev, "AIF1 underclocked\n"); 104 dev_err(arizona->dev, "AIF1 underclocked\n");
105 if (val & ARIZONA_ISRC2_UNDERCLOCKED_STS) 105 if (val & ARIZONA_ISRC2_UNDERCLOCKED_STS)
106 dev_err(arizona->dev, "ISRC2 underclocked\n"); 106 dev_err(arizona->dev, "ISRC2 underclocked\n");
@@ -417,11 +417,19 @@ int __devinit arizona_dev_init(struct arizona *arizona)
417 417
418 /* If we have a /RESET GPIO we'll already be reset */ 418 /* If we have a /RESET GPIO we'll already be reset */
419 if (!arizona->pdata.reset) { 419 if (!arizona->pdata.reset) {
420 regcache_mark_dirty(arizona->regmap);
421
420 ret = regmap_write(arizona->regmap, ARIZONA_SOFTWARE_RESET, 0); 422 ret = regmap_write(arizona->regmap, ARIZONA_SOFTWARE_RESET, 0);
421 if (ret != 0) { 423 if (ret != 0) {
422 dev_err(dev, "Failed to reset device: %d\n", ret); 424 dev_err(dev, "Failed to reset device: %d\n", ret);
423 goto err_reset; 425 goto err_reset;
424 } 426 }
427
428 ret = regcache_sync(arizona->regmap);
429 if (ret != 0) {
430 dev_err(dev, "Failed to sync device: %d\n", ret);
431 goto err_reset;
432 }
425 } 433 }
426 434
427 ret = arizona_wait_for_boot(arizona); 435 ret = arizona_wait_for_boot(arizona);
@@ -522,7 +530,7 @@ int __devinit arizona_dev_init(struct arizona *arizona)
522 break; 530 break;
523 case WM5110: 531 case WM5110:
524 ret = mfd_add_devices(arizona->dev, -1, wm5110_devs, 532 ret = mfd_add_devices(arizona->dev, -1, wm5110_devs,
525 ARRAY_SIZE(wm5102_devs), NULL, 0, NULL); 533 ARRAY_SIZE(wm5110_devs), NULL, 0, NULL);
526 break; 534 break;
527 } 535 }
528 536
diff --git a/drivers/mfd/arizona-irq.c b/drivers/mfd/arizona-irq.c
index ef0f2d001df2..b1b009177405 100644
--- a/drivers/mfd/arizona-irq.c
+++ b/drivers/mfd/arizona-irq.c
@@ -178,6 +178,7 @@ int arizona_irq_init(struct arizona *arizona)
178 178
179 switch (arizona->rev) { 179 switch (arizona->rev) {
180 case 0: 180 case 0:
181 case 1:
181 ctrlif_error = false; 182 ctrlif_error = false;
182 break; 183 break;
183 default: 184 default:
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 4ae642320205..a071a8643a47 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -671,7 +671,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
671 } 671 }
672 672
673 if (IS_ENABLED(CONFIG_PWM_TWL6030) && twl_class_is_6030()) { 673 if (IS_ENABLED(CONFIG_PWM_TWL6030) && twl_class_is_6030()) {
674 child = add_child(TWL6030_MODULE_ID1, "twl6030-pwm", NULL, 0, 674 child = add_child(SUB_CHIP_ID1, "twl6030-pwm", NULL, 0,
675 false, 0, 0); 675 false, 0, 0);
676 if (IS_ERR(child)) 676 if (IS_ERR(child))
677 return PTR_ERR(child); 677 return PTR_ERR(child);
diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
index ad733d76207a..cdd1173ed4e9 100644
--- a/drivers/mfd/twl4030-irq.c
+++ b/drivers/mfd/twl4030-irq.c
@@ -672,7 +672,8 @@ int twl4030_sih_setup(struct device *dev, int module, int irq_base)
672 irq = sih_mod + twl4030_irq_base; 672 irq = sih_mod + twl4030_irq_base;
673 irq_set_handler_data(irq, agent); 673 irq_set_handler_data(irq, agent);
674 agent->irq_name = kasprintf(GFP_KERNEL, "twl4030_%s", sih->name); 674 agent->irq_name = kasprintf(GFP_KERNEL, "twl4030_%s", sih->name);
675 status = request_threaded_irq(irq, NULL, handle_twl4030_sih, 0, 675 status = request_threaded_irq(irq, NULL, handle_twl4030_sih,
676 IRQF_EARLY_RESUME,
676 agent->irq_name ?: sih->name, NULL); 677 agent->irq_name ?: sih->name, NULL);
677 678
678 dev_info(dev, "%s (irq %d) chaining IRQs %d..%d\n", sih->name, 679 dev_info(dev, "%s (irq %d) chaining IRQs %d..%d\n", sih->name,
diff --git a/drivers/mfd/wm5102-tables.c b/drivers/mfd/wm5102-tables.c
index 01b9255ed631..14490cc785d2 100644
--- a/drivers/mfd/wm5102-tables.c
+++ b/drivers/mfd/wm5102-tables.c
@@ -43,6 +43,7 @@ static const struct reg_default wm5102_reva_patch[] = {
43 { 0x479, 0x0A30 }, 43 { 0x479, 0x0A30 },
44 { 0x47B, 0x0810 }, 44 { 0x47B, 0x0810 },
45 { 0x47D, 0x0510 }, 45 { 0x47D, 0x0510 },
46 { 0x4D1, 0x017F },
46 { 0x500, 0x000D }, 47 { 0x500, 0x000D },
47 { 0x507, 0x1820 }, 48 { 0x507, 0x1820 },
48 { 0x508, 0x1820 }, 49 { 0x508, 0x1820 },
@@ -52,524 +53,6 @@ static const struct reg_default wm5102_reva_patch[] = {
52 { 0x580, 0x000D }, 53 { 0x580, 0x000D },
53 { 0x587, 0x1820 }, 54 { 0x587, 0x1820 },
54 { 0x588, 0x1820 }, 55 { 0x588, 0x1820 },
55 { 0x101, 0x8140 },
56 { 0x3000, 0x2225 },
57 { 0x3001, 0x3a03 },
58 { 0x3002, 0x0225 },
59 { 0x3003, 0x0801 },
60 { 0x3004, 0x6249 },
61 { 0x3005, 0x0c04 },
62 { 0x3006, 0x0225 },
63 { 0x3007, 0x5901 },
64 { 0x3008, 0xe249 },
65 { 0x3009, 0x030d },
66 { 0x300a, 0x0249 },
67 { 0x300b, 0x2c01 },
68 { 0x300c, 0xe249 },
69 { 0x300d, 0x4342 },
70 { 0x300e, 0xe249 },
71 { 0x300f, 0x73c0 },
72 { 0x3010, 0x4249 },
73 { 0x3011, 0x0c00 },
74 { 0x3012, 0x0225 },
75 { 0x3013, 0x1f01 },
76 { 0x3014, 0x0225 },
77 { 0x3015, 0x1e01 },
78 { 0x3016, 0x0225 },
79 { 0x3017, 0xfa00 },
80 { 0x3018, 0x0000 },
81 { 0x3019, 0xf000 },
82 { 0x301a, 0x0000 },
83 { 0x301b, 0xf000 },
84 { 0x301c, 0x0000 },
85 { 0x301d, 0xf000 },
86 { 0x301e, 0x0000 },
87 { 0x301f, 0xf000 },
88 { 0x3020, 0x0000 },
89 { 0x3021, 0xf000 },
90 { 0x3022, 0x0000 },
91 { 0x3023, 0xf000 },
92 { 0x3024, 0x0000 },
93 { 0x3025, 0xf000 },
94 { 0x3026, 0x0000 },
95 { 0x3027, 0xf000 },
96 { 0x3028, 0x0000 },
97 { 0x3029, 0xf000 },
98 { 0x302a, 0x0000 },
99 { 0x302b, 0xf000 },
100 { 0x302c, 0x0000 },
101 { 0x302d, 0xf000 },
102 { 0x302e, 0x0000 },
103 { 0x302f, 0xf000 },
104 { 0x3030, 0x0225 },
105 { 0x3031, 0x1a01 },
106 { 0x3032, 0x0225 },
107 { 0x3033, 0x1e00 },
108 { 0x3034, 0x0225 },
109 { 0x3035, 0x1f00 },
110 { 0x3036, 0x6225 },
111 { 0x3037, 0xf800 },
112 { 0x3038, 0x0000 },
113 { 0x3039, 0xf000 },
114 { 0x303a, 0x0000 },
115 { 0x303b, 0xf000 },
116 { 0x303c, 0x0000 },
117 { 0x303d, 0xf000 },
118 { 0x303e, 0x0000 },
119 { 0x303f, 0xf000 },
120 { 0x3040, 0x2226 },
121 { 0x3041, 0x3a03 },
122 { 0x3042, 0x0226 },
123 { 0x3043, 0x0801 },
124 { 0x3044, 0x6249 },
125 { 0x3045, 0x0c06 },
126 { 0x3046, 0x0226 },
127 { 0x3047, 0x5901 },
128 { 0x3048, 0xe249 },
129 { 0x3049, 0x030d },
130 { 0x304a, 0x0249 },
131 { 0x304b, 0x2c01 },
132 { 0x304c, 0xe249 },
133 { 0x304d, 0x4342 },
134 { 0x304e, 0xe249 },
135 { 0x304f, 0x73c0 },
136 { 0x3050, 0x4249 },
137 { 0x3051, 0x0c00 },
138 { 0x3052, 0x0226 },
139 { 0x3053, 0x1f01 },
140 { 0x3054, 0x0226 },
141 { 0x3055, 0x1e01 },
142 { 0x3056, 0x0226 },
143 { 0x3057, 0xfa00 },
144 { 0x3058, 0x0000 },
145 { 0x3059, 0xf000 },
146 { 0x305a, 0x0000 },
147 { 0x305b, 0xf000 },
148 { 0x305c, 0x0000 },
149 { 0x305d, 0xf000 },
150 { 0x305e, 0x0000 },
151 { 0x305f, 0xf000 },
152 { 0x3060, 0x0000 },
153 { 0x3061, 0xf000 },
154 { 0x3062, 0x0000 },
155 { 0x3063, 0xf000 },
156 { 0x3064, 0x0000 },
157 { 0x3065, 0xf000 },
158 { 0x3066, 0x0000 },
159 { 0x3067, 0xf000 },
160 { 0x3068, 0x0000 },
161 { 0x3069, 0xf000 },
162 { 0x306a, 0x0000 },
163 { 0x306b, 0xf000 },
164 { 0x306c, 0x0000 },
165 { 0x306d, 0xf000 },
166 { 0x306e, 0x0000 },
167 { 0x306f, 0xf000 },
168 { 0x3070, 0x0226 },
169 { 0x3071, 0x1a01 },
170 { 0x3072, 0x0226 },
171 { 0x3073, 0x1e00 },
172 { 0x3074, 0x0226 },
173 { 0x3075, 0x1f00 },
174 { 0x3076, 0x6226 },
175 { 0x3077, 0xf800 },
176 { 0x3078, 0x0000 },
177 { 0x3079, 0xf000 },
178 { 0x307a, 0x0000 },
179 { 0x307b, 0xf000 },
180 { 0x307c, 0x0000 },
181 { 0x307d, 0xf000 },
182 { 0x307e, 0x0000 },
183 { 0x307f, 0xf000 },
184 { 0x3080, 0x2227 },
185 { 0x3081, 0x3a03 },
186 { 0x3082, 0x0227 },
187 { 0x3083, 0x0801 },
188 { 0x3084, 0x6255 },
189 { 0x3085, 0x0c04 },
190 { 0x3086, 0x0227 },
191 { 0x3087, 0x5901 },
192 { 0x3088, 0xe255 },
193 { 0x3089, 0x030d },
194 { 0x308a, 0x0255 },
195 { 0x308b, 0x2c01 },
196 { 0x308c, 0xe255 },
197 { 0x308d, 0x4342 },
198 { 0x308e, 0xe255 },
199 { 0x308f, 0x73c0 },
200 { 0x3090, 0x4255 },
201 { 0x3091, 0x0c00 },
202 { 0x3092, 0x0227 },
203 { 0x3093, 0x1f01 },
204 { 0x3094, 0x0227 },
205 { 0x3095, 0x1e01 },
206 { 0x3096, 0x0227 },
207 { 0x3097, 0xfa00 },
208 { 0x3098, 0x0000 },
209 { 0x3099, 0xf000 },
210 { 0x309a, 0x0000 },
211 { 0x309b, 0xf000 },
212 { 0x309c, 0x0000 },
213 { 0x309d, 0xf000 },
214 { 0x309e, 0x0000 },
215 { 0x309f, 0xf000 },
216 { 0x30a0, 0x0000 },
217 { 0x30a1, 0xf000 },
218 { 0x30a2, 0x0000 },
219 { 0x30a3, 0xf000 },
220 { 0x30a4, 0x0000 },
221 { 0x30a5, 0xf000 },
222 { 0x30a6, 0x0000 },
223 { 0x30a7, 0xf000 },
224 { 0x30a8, 0x0000 },
225 { 0x30a9, 0xf000 },
226 { 0x30aa, 0x0000 },
227 { 0x30ab, 0xf000 },
228 { 0x30ac, 0x0000 },
229 { 0x30ad, 0xf000 },
230 { 0x30ae, 0x0000 },
231 { 0x30af, 0xf000 },
232 { 0x30b0, 0x0227 },
233 { 0x30b1, 0x1a01 },
234 { 0x30b2, 0x0227 },
235 { 0x30b3, 0x1e00 },
236 { 0x30b4, 0x0227 },
237 { 0x30b5, 0x1f00 },
238 { 0x30b6, 0x6227 },
239 { 0x30b7, 0xf800 },
240 { 0x30b8, 0x0000 },
241 { 0x30b9, 0xf000 },
242 { 0x30ba, 0x0000 },
243 { 0x30bb, 0xf000 },
244 { 0x30bc, 0x0000 },
245 { 0x30bd, 0xf000 },
246 { 0x30be, 0x0000 },
247 { 0x30bf, 0xf000 },
248 { 0x30c0, 0x2228 },
249 { 0x30c1, 0x3a03 },
250 { 0x30c2, 0x0228 },
251 { 0x30c3, 0x0801 },
252 { 0x30c4, 0x6255 },
253 { 0x30c5, 0x0c06 },
254 { 0x30c6, 0x0228 },
255 { 0x30c7, 0x5901 },
256 { 0x30c8, 0xe255 },
257 { 0x30c9, 0x030d },
258 { 0x30ca, 0x0255 },
259 { 0x30cb, 0x2c01 },
260 { 0x30cc, 0xe255 },
261 { 0x30cd, 0x4342 },
262 { 0x30ce, 0xe255 },
263 { 0x30cf, 0x73c0 },
264 { 0x30d0, 0x4255 },
265 { 0x30d1, 0x0c00 },
266 { 0x30d2, 0x0228 },
267 { 0x30d3, 0x1f01 },
268 { 0x30d4, 0x0228 },
269 { 0x30d5, 0x1e01 },
270 { 0x30d6, 0x0228 },
271 { 0x30d7, 0xfa00 },
272 { 0x30d8, 0x0000 },
273 { 0x30d9, 0xf000 },
274 { 0x30da, 0x0000 },
275 { 0x30db, 0xf000 },
276 { 0x30dc, 0x0000 },
277 { 0x30dd, 0xf000 },
278 { 0x30de, 0x0000 },
279 { 0x30df, 0xf000 },
280 { 0x30e0, 0x0000 },
281 { 0x30e1, 0xf000 },
282 { 0x30e2, 0x0000 },
283 { 0x30e3, 0xf000 },
284 { 0x30e4, 0x0000 },
285 { 0x30e5, 0xf000 },
286 { 0x30e6, 0x0000 },
287 { 0x30e7, 0xf000 },
288 { 0x30e8, 0x0000 },
289 { 0x30e9, 0xf000 },
290 { 0x30ea, 0x0000 },
291 { 0x30eb, 0xf000 },
292 { 0x30ec, 0x0000 },
293 { 0x30ed, 0xf000 },
294 { 0x30ee, 0x0000 },
295 { 0x30ef, 0xf000 },
296 { 0x30f0, 0x0228 },
297 { 0x30f1, 0x1a01 },
298 { 0x30f2, 0x0228 },
299 { 0x30f3, 0x1e00 },
300 { 0x30f4, 0x0228 },
301 { 0x30f5, 0x1f00 },
302 { 0x30f6, 0x6228 },
303 { 0x30f7, 0xf800 },
304 { 0x30f8, 0x0000 },
305 { 0x30f9, 0xf000 },
306 { 0x30fa, 0x0000 },
307 { 0x30fb, 0xf000 },
308 { 0x30fc, 0x0000 },
309 { 0x30fd, 0xf000 },
310 { 0x30fe, 0x0000 },
311 { 0x30ff, 0xf000 },
312 { 0x3100, 0x222b },
313 { 0x3101, 0x3a03 },
314 { 0x3102, 0x222b },
315 { 0x3103, 0x5803 },
316 { 0x3104, 0xe26f },
317 { 0x3105, 0x030d },
318 { 0x3106, 0x626f },
319 { 0x3107, 0x2c01 },
320 { 0x3108, 0xe26f },
321 { 0x3109, 0x4342 },
322 { 0x310a, 0xe26f },
323 { 0x310b, 0x73c0 },
324 { 0x310c, 0x026f },
325 { 0x310d, 0x0c00 },
326 { 0x310e, 0x022b },
327 { 0x310f, 0x1f01 },
328 { 0x3110, 0x022b },
329 { 0x3111, 0x1e01 },
330 { 0x3112, 0x022b },
331 { 0x3113, 0xfa00 },
332 { 0x3114, 0x0000 },
333 { 0x3115, 0xf000 },
334 { 0x3116, 0x0000 },
335 { 0x3117, 0xf000 },
336 { 0x3118, 0x0000 },
337 { 0x3119, 0xf000 },
338 { 0x311a, 0x0000 },
339 { 0x311b, 0xf000 },
340 { 0x311c, 0x0000 },
341 { 0x311d, 0xf000 },
342 { 0x311e, 0x0000 },
343 { 0x311f, 0xf000 },
344 { 0x3120, 0x022b },
345 { 0x3121, 0x0a01 },
346 { 0x3122, 0x022b },
347 { 0x3123, 0x1e00 },
348 { 0x3124, 0x022b },
349 { 0x3125, 0x1f00 },
350 { 0x3126, 0x622b },
351 { 0x3127, 0xf800 },
352 { 0x3128, 0x0000 },
353 { 0x3129, 0xf000 },
354 { 0x312a, 0x0000 },
355 { 0x312b, 0xf000 },
356 { 0x312c, 0x0000 },
357 { 0x312d, 0xf000 },
358 { 0x312e, 0x0000 },
359 { 0x312f, 0xf000 },
360 { 0x3130, 0x0000 },
361 { 0x3131, 0xf000 },
362 { 0x3132, 0x0000 },
363 { 0x3133, 0xf000 },
364 { 0x3134, 0x0000 },
365 { 0x3135, 0xf000 },
366 { 0x3136, 0x0000 },
367 { 0x3137, 0xf000 },
368 { 0x3138, 0x0000 },
369 { 0x3139, 0xf000 },
370 { 0x313a, 0x0000 },
371 { 0x313b, 0xf000 },
372 { 0x313c, 0x0000 },
373 { 0x313d, 0xf000 },
374 { 0x313e, 0x0000 },
375 { 0x313f, 0xf000 },
376 { 0x3140, 0x0000 },
377 { 0x3141, 0xf000 },
378 { 0x3142, 0x0000 },
379 { 0x3143, 0xf000 },
380 { 0x3144, 0x0000 },
381 { 0x3145, 0xf000 },
382 { 0x3146, 0x0000 },
383 { 0x3147, 0xf000 },
384 { 0x3148, 0x0000 },
385 { 0x3149, 0xf000 },
386 { 0x314a, 0x0000 },
387 { 0x314b, 0xf000 },
388 { 0x314c, 0x0000 },
389 { 0x314d, 0xf000 },
390 { 0x314e, 0x0000 },
391 { 0x314f, 0xf000 },
392 { 0x3150, 0x0000 },
393 { 0x3151, 0xf000 },
394 { 0x3152, 0x0000 },
395 { 0x3153, 0xf000 },
396 { 0x3154, 0x0000 },
397 { 0x3155, 0xf000 },
398 { 0x3156, 0x0000 },
399 { 0x3157, 0xf000 },
400 { 0x3158, 0x0000 },
401 { 0x3159, 0xf000 },
402 { 0x315a, 0x0000 },
403 { 0x315b, 0xf000 },
404 { 0x315c, 0x0000 },
405 { 0x315d, 0xf000 },
406 { 0x315e, 0x0000 },
407 { 0x315f, 0xf000 },
408 { 0x3160, 0x0000 },
409 { 0x3161, 0xf000 },
410 { 0x3162, 0x0000 },
411 { 0x3163, 0xf000 },
412 { 0x3164, 0x0000 },
413 { 0x3165, 0xf000 },
414 { 0x3166, 0x0000 },
415 { 0x3167, 0xf000 },
416 { 0x3168, 0x0000 },
417 { 0x3169, 0xf000 },
418 { 0x316a, 0x0000 },
419 { 0x316b, 0xf000 },
420 { 0x316c, 0x0000 },
421 { 0x316d, 0xf000 },
422 { 0x316e, 0x0000 },
423 { 0x316f, 0xf000 },
424 { 0x3170, 0x0000 },
425 { 0x3171, 0xf000 },
426 { 0x3172, 0x0000 },
427 { 0x3173, 0xf000 },
428 { 0x3174, 0x0000 },
429 { 0x3175, 0xf000 },
430 { 0x3176, 0x0000 },
431 { 0x3177, 0xf000 },
432 { 0x3178, 0x0000 },
433 { 0x3179, 0xf000 },
434 { 0x317a, 0x0000 },
435 { 0x317b, 0xf000 },
436 { 0x317c, 0x0000 },
437 { 0x317d, 0xf000 },
438 { 0x317e, 0x0000 },
439 { 0x317f, 0xf000 },
440 { 0x3180, 0x2001 },
441 { 0x3181, 0xf101 },
442 { 0x3182, 0x0000 },
443 { 0x3183, 0xf000 },
444 { 0x3184, 0x0000 },
445 { 0x3185, 0xf000 },
446 { 0x3186, 0x0000 },
447 { 0x3187, 0xf000 },
448 { 0x3188, 0x0000 },
449 { 0x3189, 0xf000 },
450 { 0x318a, 0x0000 },
451 { 0x318b, 0xf000 },
452 { 0x318c, 0x0000 },
453 { 0x318d, 0xf000 },
454 { 0x318e, 0x0000 },
455 { 0x318f, 0xf000 },
456 { 0x3190, 0x0000 },
457 { 0x3191, 0xf000 },
458 { 0x3192, 0x0000 },
459 { 0x3193, 0xf000 },
460 { 0x3194, 0x0000 },
461 { 0x3195, 0xf000 },
462 { 0x3196, 0x0000 },
463 { 0x3197, 0xf000 },
464 { 0x3198, 0x0000 },
465 { 0x3199, 0xf000 },
466 { 0x319a, 0x0000 },
467 { 0x319b, 0xf000 },
468 { 0x319c, 0x0000 },
469 { 0x319d, 0xf000 },
470 { 0x319e, 0x0000 },
471 { 0x319f, 0xf000 },
472 { 0x31a0, 0x0000 },
473 { 0x31a1, 0xf000 },
474 { 0x31a2, 0x0000 },
475 { 0x31a3, 0xf000 },
476 { 0x31a4, 0x0000 },
477 { 0x31a5, 0xf000 },
478 { 0x31a6, 0x0000 },
479 { 0x31a7, 0xf000 },
480 { 0x31a8, 0x0000 },
481 { 0x31a9, 0xf000 },
482 { 0x31aa, 0x0000 },
483 { 0x31ab, 0xf000 },
484 { 0x31ac, 0x0000 },
485 { 0x31ad, 0xf000 },
486 { 0x31ae, 0x0000 },
487 { 0x31af, 0xf000 },
488 { 0x31b0, 0x0000 },
489 { 0x31b1, 0xf000 },
490 { 0x31b2, 0x0000 },
491 { 0x31b3, 0xf000 },
492 { 0x31b4, 0x0000 },
493 { 0x31b5, 0xf000 },
494 { 0x31b6, 0x0000 },
495 { 0x31b7, 0xf000 },
496 { 0x31b8, 0x0000 },
497 { 0x31b9, 0xf000 },
498 { 0x31ba, 0x0000 },
499 { 0x31bb, 0xf000 },
500 { 0x31bc, 0x0000 },
501 { 0x31bd, 0xf000 },
502 { 0x31be, 0x0000 },
503 { 0x31bf, 0xf000 },
504 { 0x31c0, 0x0000 },
505 { 0x31c1, 0xf000 },
506 { 0x31c2, 0x0000 },
507 { 0x31c3, 0xf000 },
508 { 0x31c4, 0x0000 },
509 { 0x31c5, 0xf000 },
510 { 0x31c6, 0x0000 },
511 { 0x31c7, 0xf000 },
512 { 0x31c8, 0x0000 },
513 { 0x31c9, 0xf000 },
514 { 0x31ca, 0x0000 },
515 { 0x31cb, 0xf000 },
516 { 0x31cc, 0x0000 },
517 { 0x31cd, 0xf000 },
518 { 0x31ce, 0x0000 },
519 { 0x31cf, 0xf000 },
520 { 0x31d0, 0x0000 },
521 { 0x31d1, 0xf000 },
522 { 0x31d2, 0x0000 },
523 { 0x31d3, 0xf000 },
524 { 0x31d4, 0x0000 },
525 { 0x31d5, 0xf000 },
526 { 0x31d6, 0x0000 },
527 { 0x31d7, 0xf000 },
528 { 0x31d8, 0x0000 },
529 { 0x31d9, 0xf000 },
530 { 0x31da, 0x0000 },
531 { 0x31db, 0xf000 },
532 { 0x31dc, 0x0000 },
533 { 0x31dd, 0xf000 },
534 { 0x31de, 0x0000 },
535 { 0x31df, 0xf000 },
536 { 0x31e0, 0x0000 },
537 { 0x31e1, 0xf000 },
538 { 0x31e2, 0x0000 },
539 { 0x31e3, 0xf000 },
540 { 0x31e4, 0x0000 },
541 { 0x31e5, 0xf000 },
542 { 0x31e6, 0x0000 },
543 { 0x31e7, 0xf000 },
544 { 0x31e8, 0x0000 },
545 { 0x31e9, 0xf000 },
546 { 0x31ea, 0x0000 },
547 { 0x31eb, 0xf000 },
548 { 0x31ec, 0x0000 },
549 { 0x31ed, 0xf000 },
550 { 0x31ee, 0x0000 },
551 { 0x31ef, 0xf000 },
552 { 0x31f0, 0x0000 },
553 { 0x31f1, 0xf000 },
554 { 0x31f2, 0x0000 },
555 { 0x31f3, 0xf000 },
556 { 0x31f4, 0x0000 },
557 { 0x31f5, 0xf000 },
558 { 0x31f6, 0x0000 },
559 { 0x31f7, 0xf000 },
560 { 0x31f8, 0x0000 },
561 { 0x31f9, 0xf000 },
562 { 0x31fa, 0x0000 },
563 { 0x31fb, 0xf000 },
564 { 0x31fc, 0x0000 },
565 { 0x31fd, 0xf000 },
566 { 0x31fe, 0x0000 },
567 { 0x31ff, 0xf000 },
568 { 0x024d, 0xff50 },
569 { 0x0252, 0xff50 },
570 { 0x0259, 0x0112 },
571 { 0x025e, 0x0112 },
572 { 0x101, 0x0304 },
573 { 0x80, 0x0000 }, 56 { 0x80, 0x0000 },
574}; 57};
575 58
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index a54dd5d7a5f9..c9ec725884e5 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -373,18 +373,25 @@ static struct sdhci_ops sdhci_s3c_ops = {
373static void sdhci_s3c_notify_change(struct platform_device *dev, int state) 373static void sdhci_s3c_notify_change(struct platform_device *dev, int state)
374{ 374{
375 struct sdhci_host *host = platform_get_drvdata(dev); 375 struct sdhci_host *host = platform_get_drvdata(dev);
376 struct sdhci_s3c *sc = sdhci_priv(host);
376 unsigned long flags; 377 unsigned long flags;
377 378
378 if (host) { 379 if (host) {
379 spin_lock_irqsave(&host->lock, flags); 380 spin_lock_irqsave(&host->lock, flags);
380 if (state) { 381 if (state) {
381 dev_dbg(&dev->dev, "card inserted.\n"); 382 dev_dbg(&dev->dev, "card inserted.\n");
383#ifdef CONFIG_PM_RUNTIME
384 clk_prepare_enable(sc->clk_io);
385#endif
382 host->flags &= ~SDHCI_DEVICE_DEAD; 386 host->flags &= ~SDHCI_DEVICE_DEAD;
383 host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION; 387 host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION;
384 } else { 388 } else {
385 dev_dbg(&dev->dev, "card removed.\n"); 389 dev_dbg(&dev->dev, "card removed.\n");
386 host->flags |= SDHCI_DEVICE_DEAD; 390 host->flags |= SDHCI_DEVICE_DEAD;
387 host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION; 391 host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION;
392#ifdef CONFIG_PM_RUNTIME
393 clk_disable_unprepare(sc->clk_io);
394#endif
388 } 395 }
389 tasklet_schedule(&host->card_tasklet); 396 tasklet_schedule(&host->card_tasklet);
390 spin_unlock_irqrestore(&host->lock, flags); 397 spin_unlock_irqrestore(&host->lock, flags);
diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index d25bc97dc5c6..7eaee3eeb6b2 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -1104,7 +1104,6 @@ static irqreturn_t sh_mmcif_irqt(int irq, void *dev_id)
1104{ 1104{
1105 struct sh_mmcif_host *host = dev_id; 1105 struct sh_mmcif_host *host = dev_id;
1106 struct mmc_request *mrq = host->mrq; 1106 struct mmc_request *mrq = host->mrq;
1107 struct mmc_data *data = mrq->data;
1108 1107
1109 cancel_delayed_work_sync(&host->timeout_work); 1108 cancel_delayed_work_sync(&host->timeout_work);
1110 1109
@@ -1152,13 +1151,14 @@ static irqreturn_t sh_mmcif_irqt(int irq, void *dev_id)
1152 case MMCIF_WAIT_FOR_READ_END: 1151 case MMCIF_WAIT_FOR_READ_END:
1153 case MMCIF_WAIT_FOR_WRITE_END: 1152 case MMCIF_WAIT_FOR_WRITE_END:
1154 if (host->sd_error) 1153 if (host->sd_error)
1155 data->error = sh_mmcif_error_manage(host); 1154 mrq->data->error = sh_mmcif_error_manage(host);
1156 break; 1155 break;
1157 default: 1156 default:
1158 BUG(); 1157 BUG();
1159 } 1158 }
1160 1159
1161 if (host->wait_for != MMCIF_WAIT_FOR_STOP) { 1160 if (host->wait_for != MMCIF_WAIT_FOR_STOP) {
1161 struct mmc_data *data = mrq->data;
1162 if (!mrq->cmd->error && data && !data->error) 1162 if (!mrq->cmd->error && data && !data->error)
1163 data->bytes_xfered = 1163 data->bytes_xfered =
1164 data->blocks * data->blksz; 1164 data->blocks * data->blksz;
@@ -1231,10 +1231,6 @@ static irqreturn_t sh_mmcif_intr(int irq, void *dev_id)
1231 host->sd_error = true; 1231 host->sd_error = true;
1232 dev_dbg(&host->pd->dev, "int err state = %08x\n", state); 1232 dev_dbg(&host->pd->dev, "int err state = %08x\n", state);
1233 } 1233 }
1234 if (host->state == STATE_IDLE) {
1235 dev_info(&host->pd->dev, "Spurious IRQ status 0x%x", state);
1236 return IRQ_HANDLED;
1237 }
1238 if (state & ~(INT_CMD12RBE | INT_CMD12CRE)) { 1234 if (state & ~(INT_CMD12RBE | INT_CMD12CRE)) {
1239 if (!host->dma_active) 1235 if (!host->dma_active)
1240 return IRQ_WAKE_THREAD; 1236 return IRQ_WAKE_THREAD;
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 374c46dff7dd..ec794a72975d 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -1077,7 +1077,8 @@ EXPORT_SYMBOL_GPL(mtd_writev);
1077 * until the request succeeds or until the allocation size falls below 1077 * until the request succeeds or until the allocation size falls below
1078 * the system page size. This attempts to make sure it does not adversely 1078 * the system page size. This attempts to make sure it does not adversely
1079 * impact system performance, so when allocating more than one page, we 1079 * impact system performance, so when allocating more than one page, we
1080 * ask the memory allocator to avoid re-trying. 1080 * ask the memory allocator to avoid re-trying, swapping, writing back
1081 * or performing I/O.
1081 * 1082 *
1082 * Note, this function also makes sure that the allocated buffer is aligned to 1083 * Note, this function also makes sure that the allocated buffer is aligned to
1083 * the MTD device's min. I/O unit, i.e. the "mtd->writesize" value. 1084 * the MTD device's min. I/O unit, i.e. the "mtd->writesize" value.
@@ -1091,7 +1092,8 @@ EXPORT_SYMBOL_GPL(mtd_writev);
1091 */ 1092 */
1092void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size) 1093void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size)
1093{ 1094{
1094 gfp_t flags = __GFP_NOWARN | __GFP_WAIT | __GFP_NORETRY; 1095 gfp_t flags = __GFP_NOWARN | __GFP_WAIT |
1096 __GFP_NORETRY | __GFP_NO_KSWAPD;
1095 size_t min_alloc = max_t(size_t, mtd->writesize, PAGE_SIZE); 1097 size_t min_alloc = max_t(size_t, mtd->writesize, PAGE_SIZE);
1096 void *kbuf; 1098 void *kbuf;
1097 1099
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index da7b44998b40..2144f611196e 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -498,7 +498,7 @@ out:
498 * @ubi: UBI device description object 498 * @ubi: UBI device description object
499 * 499 *
500 * This function returns a physical eraseblock in case of success and a 500 * This function returns a physical eraseblock in case of success and a
501 * negative error code in case of failure. Might sleep. 501 * negative error code in case of failure.
502 */ 502 */
503static int __wl_get_peb(struct ubi_device *ubi) 503static int __wl_get_peb(struct ubi_device *ubi)
504{ 504{
@@ -540,13 +540,6 @@ retry:
540 * ubi_wl_get_peb() after removing e from the pool. */ 540 * ubi_wl_get_peb() after removing e from the pool. */
541 prot_queue_add(ubi, e); 541 prot_queue_add(ubi, e);
542#endif 542#endif
543 err = ubi_self_check_all_ff(ubi, e->pnum, ubi->vid_hdr_aloffset,
544 ubi->peb_size - ubi->vid_hdr_aloffset);
545 if (err) {
546 ubi_err("new PEB %d does not contain all 0xFF bytes", e->pnum);
547 return err;
548 }
549
550 return e->pnum; 543 return e->pnum;
551} 544}
552 545
@@ -679,17 +672,30 @@ static struct ubi_wl_entry *get_peb_for_wl(struct ubi_device *ubi)
679#else 672#else
680static struct ubi_wl_entry *get_peb_for_wl(struct ubi_device *ubi) 673static struct ubi_wl_entry *get_peb_for_wl(struct ubi_device *ubi)
681{ 674{
682 return find_wl_entry(ubi, &ubi->free, WL_FREE_MAX_DIFF); 675 struct ubi_wl_entry *e;
676
677 e = find_wl_entry(ubi, &ubi->free, WL_FREE_MAX_DIFF);
678 self_check_in_wl_tree(ubi, e, &ubi->free);
679 rb_erase(&e->u.rb, &ubi->free);
680
681 return e;
683} 682}
684 683
685int ubi_wl_get_peb(struct ubi_device *ubi) 684int ubi_wl_get_peb(struct ubi_device *ubi)
686{ 685{
687 int peb; 686 int peb, err;
688 687
689 spin_lock(&ubi->wl_lock); 688 spin_lock(&ubi->wl_lock);
690 peb = __wl_get_peb(ubi); 689 peb = __wl_get_peb(ubi);
691 spin_unlock(&ubi->wl_lock); 690 spin_unlock(&ubi->wl_lock);
692 691
692 err = ubi_self_check_all_ff(ubi, peb, ubi->vid_hdr_aloffset,
693 ubi->peb_size - ubi->vid_hdr_aloffset);
694 if (err) {
695 ubi_err("new PEB %d does not contain all 0xFF bytes", peb);
696 return err;
697 }
698
693 return peb; 699 return peb;
694} 700}
695#endif 701#endif
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 5f5b69f37d2e..a7d47350ea4b 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3459,6 +3459,28 @@ static int bond_xmit_hash_policy_l34(struct sk_buff *skb, int count)
3459 3459
3460/*-------------------------- Device entry points ----------------------------*/ 3460/*-------------------------- Device entry points ----------------------------*/
3461 3461
3462static void bond_work_init_all(struct bonding *bond)
3463{
3464 INIT_DELAYED_WORK(&bond->mcast_work,
3465 bond_resend_igmp_join_requests_delayed);
3466 INIT_DELAYED_WORK(&bond->alb_work, bond_alb_monitor);
3467 INIT_DELAYED_WORK(&bond->mii_work, bond_mii_monitor);
3468 if (bond->params.mode == BOND_MODE_ACTIVEBACKUP)
3469 INIT_DELAYED_WORK(&bond->arp_work, bond_activebackup_arp_mon);
3470 else
3471 INIT_DELAYED_WORK(&bond->arp_work, bond_loadbalance_arp_mon);
3472 INIT_DELAYED_WORK(&bond->ad_work, bond_3ad_state_machine_handler);
3473}
3474
3475static void bond_work_cancel_all(struct bonding *bond)
3476{
3477 cancel_delayed_work_sync(&bond->mii_work);
3478 cancel_delayed_work_sync(&bond->arp_work);
3479 cancel_delayed_work_sync(&bond->alb_work);
3480 cancel_delayed_work_sync(&bond->ad_work);
3481 cancel_delayed_work_sync(&bond->mcast_work);
3482}
3483
3462static int bond_open(struct net_device *bond_dev) 3484static int bond_open(struct net_device *bond_dev)
3463{ 3485{
3464 struct bonding *bond = netdev_priv(bond_dev); 3486 struct bonding *bond = netdev_priv(bond_dev);
@@ -3481,41 +3503,27 @@ static int bond_open(struct net_device *bond_dev)
3481 } 3503 }
3482 read_unlock(&bond->lock); 3504 read_unlock(&bond->lock);
3483 3505
3484 INIT_DELAYED_WORK(&bond->mcast_work, bond_resend_igmp_join_requests_delayed); 3506 bond_work_init_all(bond);
3485 3507
3486 if (bond_is_lb(bond)) { 3508 if (bond_is_lb(bond)) {
3487 /* bond_alb_initialize must be called before the timer 3509 /* bond_alb_initialize must be called before the timer
3488 * is started. 3510 * is started.
3489 */ 3511 */
3490 if (bond_alb_initialize(bond, (bond->params.mode == BOND_MODE_ALB))) { 3512 if (bond_alb_initialize(bond, (bond->params.mode == BOND_MODE_ALB)))
3491 /* something went wrong - fail the open operation */
3492 return -ENOMEM; 3513 return -ENOMEM;
3493 }
3494
3495 INIT_DELAYED_WORK(&bond->alb_work, bond_alb_monitor);
3496 queue_delayed_work(bond->wq, &bond->alb_work, 0); 3514 queue_delayed_work(bond->wq, &bond->alb_work, 0);
3497 } 3515 }
3498 3516
3499 if (bond->params.miimon) { /* link check interval, in milliseconds. */ 3517 if (bond->params.miimon) /* link check interval, in milliseconds. */
3500 INIT_DELAYED_WORK(&bond->mii_work, bond_mii_monitor);
3501 queue_delayed_work(bond->wq, &bond->mii_work, 0); 3518 queue_delayed_work(bond->wq, &bond->mii_work, 0);
3502 }
3503 3519
3504 if (bond->params.arp_interval) { /* arp interval, in milliseconds. */ 3520 if (bond->params.arp_interval) { /* arp interval, in milliseconds. */
3505 if (bond->params.mode == BOND_MODE_ACTIVEBACKUP)
3506 INIT_DELAYED_WORK(&bond->arp_work,
3507 bond_activebackup_arp_mon);
3508 else
3509 INIT_DELAYED_WORK(&bond->arp_work,
3510 bond_loadbalance_arp_mon);
3511
3512 queue_delayed_work(bond->wq, &bond->arp_work, 0); 3521 queue_delayed_work(bond->wq, &bond->arp_work, 0);
3513 if (bond->params.arp_validate) 3522 if (bond->params.arp_validate)
3514 bond->recv_probe = bond_arp_rcv; 3523 bond->recv_probe = bond_arp_rcv;
3515 } 3524 }
3516 3525
3517 if (bond->params.mode == BOND_MODE_8023AD) { 3526 if (bond->params.mode == BOND_MODE_8023AD) {
3518 INIT_DELAYED_WORK(&bond->ad_work, bond_3ad_state_machine_handler);
3519 queue_delayed_work(bond->wq, &bond->ad_work, 0); 3527 queue_delayed_work(bond->wq, &bond->ad_work, 0);
3520 /* register to receive LACPDUs */ 3528 /* register to receive LACPDUs */
3521 bond->recv_probe = bond_3ad_lacpdu_recv; 3529 bond->recv_probe = bond_3ad_lacpdu_recv;
@@ -3530,34 +3538,10 @@ static int bond_close(struct net_device *bond_dev)
3530 struct bonding *bond = netdev_priv(bond_dev); 3538 struct bonding *bond = netdev_priv(bond_dev);
3531 3539
3532 write_lock_bh(&bond->lock); 3540 write_lock_bh(&bond->lock);
3533
3534 bond->send_peer_notif = 0; 3541 bond->send_peer_notif = 0;
3535
3536 write_unlock_bh(&bond->lock); 3542 write_unlock_bh(&bond->lock);
3537 3543
3538 if (bond->params.miimon) { /* link check interval, in milliseconds. */ 3544 bond_work_cancel_all(bond);
3539 cancel_delayed_work_sync(&bond->mii_work);
3540 }
3541
3542 if (bond->params.arp_interval) { /* arp interval, in milliseconds. */
3543 cancel_delayed_work_sync(&bond->arp_work);
3544 }
3545
3546 switch (bond->params.mode) {
3547 case BOND_MODE_8023AD:
3548 cancel_delayed_work_sync(&bond->ad_work);
3549 break;
3550 case BOND_MODE_TLB:
3551 case BOND_MODE_ALB:
3552 cancel_delayed_work_sync(&bond->alb_work);
3553 break;
3554 default:
3555 break;
3556 }
3557
3558 if (delayed_work_pending(&bond->mcast_work))
3559 cancel_delayed_work_sync(&bond->mcast_work);
3560
3561 if (bond_is_lb(bond)) { 3545 if (bond_is_lb(bond)) {
3562 /* Must be called only after all 3546 /* Must be called only after all
3563 * slaves have been released 3547 * slaves have been released
@@ -4436,26 +4420,6 @@ static void bond_setup(struct net_device *bond_dev)
4436 bond_dev->features |= bond_dev->hw_features; 4420 bond_dev->features |= bond_dev->hw_features;
4437} 4421}
4438 4422
4439static void bond_work_cancel_all(struct bonding *bond)
4440{
4441 if (bond->params.miimon && delayed_work_pending(&bond->mii_work))
4442 cancel_delayed_work_sync(&bond->mii_work);
4443
4444 if (bond->params.arp_interval && delayed_work_pending(&bond->arp_work))
4445 cancel_delayed_work_sync(&bond->arp_work);
4446
4447 if (bond->params.mode == BOND_MODE_ALB &&
4448 delayed_work_pending(&bond->alb_work))
4449 cancel_delayed_work_sync(&bond->alb_work);
4450
4451 if (bond->params.mode == BOND_MODE_8023AD &&
4452 delayed_work_pending(&bond->ad_work))
4453 cancel_delayed_work_sync(&bond->ad_work);
4454
4455 if (delayed_work_pending(&bond->mcast_work))
4456 cancel_delayed_work_sync(&bond->mcast_work);
4457}
4458
4459/* 4423/*
4460* Destroy a bonding device. 4424* Destroy a bonding device.
4461* Must be under rtnl_lock when this function is called. 4425* Must be under rtnl_lock when this function is called.
@@ -4706,12 +4670,13 @@ static int bond_check_params(struct bond_params *params)
4706 arp_ip_count++) { 4670 arp_ip_count++) {
4707 /* not complete check, but should be good enough to 4671 /* not complete check, but should be good enough to
4708 catch mistakes */ 4672 catch mistakes */
4709 if (!isdigit(arp_ip_target[arp_ip_count][0])) { 4673 __be32 ip = in_aton(arp_ip_target[arp_ip_count]);
4674 if (!isdigit(arp_ip_target[arp_ip_count][0]) ||
4675 ip == 0 || ip == htonl(INADDR_BROADCAST)) {
4710 pr_warning("Warning: bad arp_ip_target module parameter (%s), ARP monitoring will not be performed\n", 4676 pr_warning("Warning: bad arp_ip_target module parameter (%s), ARP monitoring will not be performed\n",
4711 arp_ip_target[arp_ip_count]); 4677 arp_ip_target[arp_ip_count]);
4712 arp_interval = 0; 4678 arp_interval = 0;
4713 } else { 4679 } else {
4714 __be32 ip = in_aton(arp_ip_target[arp_ip_count]);
4715 arp_target[arp_ip_count] = ip; 4680 arp_target[arp_ip_count] = ip;
4716 } 4681 }
4717 } 4682 }
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index ef8d2a080d17..1877ed7ca086 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -513,6 +513,8 @@ static ssize_t bonding_store_arp_interval(struct device *d,
513 int new_value, ret = count; 513 int new_value, ret = count;
514 struct bonding *bond = to_bond(d); 514 struct bonding *bond = to_bond(d);
515 515
516 if (!rtnl_trylock())
517 return restart_syscall();
516 if (sscanf(buf, "%d", &new_value) != 1) { 518 if (sscanf(buf, "%d", &new_value) != 1) {
517 pr_err("%s: no arp_interval value specified.\n", 519 pr_err("%s: no arp_interval value specified.\n",
518 bond->dev->name); 520 bond->dev->name);
@@ -539,10 +541,6 @@ static ssize_t bonding_store_arp_interval(struct device *d,
539 pr_info("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n", 541 pr_info("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n",
540 bond->dev->name, bond->dev->name); 542 bond->dev->name, bond->dev->name);
541 bond->params.miimon = 0; 543 bond->params.miimon = 0;
542 if (delayed_work_pending(&bond->mii_work)) {
543 cancel_delayed_work(&bond->mii_work);
544 flush_workqueue(bond->wq);
545 }
546 } 544 }
547 if (!bond->params.arp_targets[0]) { 545 if (!bond->params.arp_targets[0]) {
548 pr_info("%s: ARP monitoring has been set up, but no ARP targets have been specified.\n", 546 pr_info("%s: ARP monitoring has been set up, but no ARP targets have been specified.\n",
@@ -554,19 +552,12 @@ static ssize_t bonding_store_arp_interval(struct device *d,
554 * timer will get fired off when the open function 552 * timer will get fired off when the open function
555 * is called. 553 * is called.
556 */ 554 */
557 if (!delayed_work_pending(&bond->arp_work)) { 555 cancel_delayed_work_sync(&bond->mii_work);
558 if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) 556 queue_delayed_work(bond->wq, &bond->arp_work, 0);
559 INIT_DELAYED_WORK(&bond->arp_work,
560 bond_activebackup_arp_mon);
561 else
562 INIT_DELAYED_WORK(&bond->arp_work,
563 bond_loadbalance_arp_mon);
564
565 queue_delayed_work(bond->wq, &bond->arp_work, 0);
566 }
567 } 557 }
568 558
569out: 559out:
560 rtnl_unlock();
570 return ret; 561 return ret;
571} 562}
572static DEVICE_ATTR(arp_interval, S_IRUGO | S_IWUSR, 563static DEVICE_ATTR(arp_interval, S_IRUGO | S_IWUSR,
@@ -962,6 +953,8 @@ static ssize_t bonding_store_miimon(struct device *d,
962 int new_value, ret = count; 953 int new_value, ret = count;
963 struct bonding *bond = to_bond(d); 954 struct bonding *bond = to_bond(d);
964 955
956 if (!rtnl_trylock())
957 return restart_syscall();
965 if (sscanf(buf, "%d", &new_value) != 1) { 958 if (sscanf(buf, "%d", &new_value) != 1) {
966 pr_err("%s: no miimon value specified.\n", 959 pr_err("%s: no miimon value specified.\n",
967 bond->dev->name); 960 bond->dev->name);
@@ -993,10 +986,6 @@ static ssize_t bonding_store_miimon(struct device *d,
993 bond->params.arp_validate = 986 bond->params.arp_validate =
994 BOND_ARP_VALIDATE_NONE; 987 BOND_ARP_VALIDATE_NONE;
995 } 988 }
996 if (delayed_work_pending(&bond->arp_work)) {
997 cancel_delayed_work(&bond->arp_work);
998 flush_workqueue(bond->wq);
999 }
1000 } 989 }
1001 990
1002 if (bond->dev->flags & IFF_UP) { 991 if (bond->dev->flags & IFF_UP) {
@@ -1005,15 +994,12 @@ static ssize_t bonding_store_miimon(struct device *d,
1005 * timer will get fired off when the open function 994 * timer will get fired off when the open function
1006 * is called. 995 * is called.
1007 */ 996 */
1008 if (!delayed_work_pending(&bond->mii_work)) { 997 cancel_delayed_work_sync(&bond->arp_work);
1009 INIT_DELAYED_WORK(&bond->mii_work, 998 queue_delayed_work(bond->wq, &bond->mii_work, 0);
1010 bond_mii_monitor);
1011 queue_delayed_work(bond->wq,
1012 &bond->mii_work, 0);
1013 }
1014 } 999 }
1015 } 1000 }
1016out: 1001out:
1002 rtnl_unlock();
1017 return ret; 1003 return ret;
1018} 1004}
1019static DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR, 1005static DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR,
@@ -1582,6 +1568,7 @@ static ssize_t bonding_store_slaves_active(struct device *d,
1582 goto out; 1568 goto out;
1583 } 1569 }
1584 1570
1571 read_lock(&bond->lock);
1585 bond_for_each_slave(bond, slave, i) { 1572 bond_for_each_slave(bond, slave, i) {
1586 if (!bond_is_active_slave(slave)) { 1573 if (!bond_is_active_slave(slave)) {
1587 if (new_value) 1574 if (new_value)
@@ -1590,6 +1577,7 @@ static ssize_t bonding_store_slaves_active(struct device *d,
1590 slave->inactive = 1; 1577 slave->inactive = 1;
1591 } 1578 }
1592 } 1579 }
1580 read_unlock(&bond->lock);
1593out: 1581out:
1594 return ret; 1582 return ret;
1595} 1583}
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb.c b/drivers/net/can/usb/peak_usb/pcan_usb.c
index 86f26a1ede4c..25723d8ee201 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb.c
@@ -519,8 +519,10 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,
519 mc->pdev->dev.can.state = new_state; 519 mc->pdev->dev.can.state = new_state;
520 520
521 if (status_len & PCAN_USB_STATUSLEN_TIMESTAMP) { 521 if (status_len & PCAN_USB_STATUSLEN_TIMESTAMP) {
522 struct skb_shared_hwtstamps *hwts = skb_hwtstamps(skb);
523
522 peak_usb_get_ts_tv(&mc->pdev->time_ref, mc->ts16, &tv); 524 peak_usb_get_ts_tv(&mc->pdev->time_ref, mc->ts16, &tv);
523 skb->tstamp = timeval_to_ktime(tv); 525 hwts->hwtstamp = timeval_to_ktime(tv);
524 } 526 }
525 527
526 netif_rx(skb); 528 netif_rx(skb);
@@ -605,6 +607,7 @@ static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len)
605 struct sk_buff *skb; 607 struct sk_buff *skb;
606 struct can_frame *cf; 608 struct can_frame *cf;
607 struct timeval tv; 609 struct timeval tv;
610 struct skb_shared_hwtstamps *hwts;
608 611
609 skb = alloc_can_skb(mc->netdev, &cf); 612 skb = alloc_can_skb(mc->netdev, &cf);
610 if (!skb) 613 if (!skb)
@@ -652,7 +655,8 @@ static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len)
652 655
653 /* convert timestamp into kernel time */ 656 /* convert timestamp into kernel time */
654 peak_usb_get_ts_tv(&mc->pdev->time_ref, mc->ts16, &tv); 657 peak_usb_get_ts_tv(&mc->pdev->time_ref, mc->ts16, &tv);
655 skb->tstamp = timeval_to_ktime(tv); 658 hwts = skb_hwtstamps(skb);
659 hwts->hwtstamp = timeval_to_ktime(tv);
656 660
657 /* push the skb */ 661 /* push the skb */
658 netif_rx(skb); 662 netif_rx(skb);
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
index e1626d92511a..30d79bfa5b10 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
@@ -532,6 +532,7 @@ static int pcan_usb_pro_handle_canmsg(struct pcan_usb_pro_interface *usb_if,
532 struct can_frame *can_frame; 532 struct can_frame *can_frame;
533 struct sk_buff *skb; 533 struct sk_buff *skb;
534 struct timeval tv; 534 struct timeval tv;
535 struct skb_shared_hwtstamps *hwts;
535 536
536 skb = alloc_can_skb(netdev, &can_frame); 537 skb = alloc_can_skb(netdev, &can_frame);
537 if (!skb) 538 if (!skb)
@@ -549,7 +550,8 @@ static int pcan_usb_pro_handle_canmsg(struct pcan_usb_pro_interface *usb_if,
549 memcpy(can_frame->data, rx->data, can_frame->can_dlc); 550 memcpy(can_frame->data, rx->data, can_frame->can_dlc);
550 551
551 peak_usb_get_ts_tv(&usb_if->time_ref, le32_to_cpu(rx->ts32), &tv); 552 peak_usb_get_ts_tv(&usb_if->time_ref, le32_to_cpu(rx->ts32), &tv);
552 skb->tstamp = timeval_to_ktime(tv); 553 hwts = skb_hwtstamps(skb);
554 hwts->hwtstamp = timeval_to_ktime(tv);
553 555
554 netif_rx(skb); 556 netif_rx(skb);
555 netdev->stats.rx_packets++; 557 netdev->stats.rx_packets++;
@@ -570,6 +572,7 @@ static int pcan_usb_pro_handle_error(struct pcan_usb_pro_interface *usb_if,
570 u8 err_mask = 0; 572 u8 err_mask = 0;
571 struct sk_buff *skb; 573 struct sk_buff *skb;
572 struct timeval tv; 574 struct timeval tv;
575 struct skb_shared_hwtstamps *hwts;
573 576
574 /* nothing should be sent while in BUS_OFF state */ 577 /* nothing should be sent while in BUS_OFF state */
575 if (dev->can.state == CAN_STATE_BUS_OFF) 578 if (dev->can.state == CAN_STATE_BUS_OFF)
@@ -664,7 +667,8 @@ static int pcan_usb_pro_handle_error(struct pcan_usb_pro_interface *usb_if,
664 dev->can.state = new_state; 667 dev->can.state = new_state;
665 668
666 peak_usb_get_ts_tv(&usb_if->time_ref, le32_to_cpu(er->ts32), &tv); 669 peak_usb_get_ts_tv(&usb_if->time_ref, le32_to_cpu(er->ts32), &tv);
667 skb->tstamp = timeval_to_ktime(tv); 670 hwts = skb_hwtstamps(skb);
671 hwts->hwtstamp = timeval_to_ktime(tv);
668 netif_rx(skb); 672 netif_rx(skb);
669 netdev->stats.rx_packets++; 673 netdev->stats.rx_packets++;
670 netdev->stats.rx_bytes += can_frame->can_dlc; 674 netdev->stats.rx_bytes += can_frame->can_dlc;
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c b/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c
index 5d36795877cb..b799ab12a291 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c
@@ -237,7 +237,7 @@ static int mlx4_en_dcbnl_ieee_setmaxrate(struct net_device *dev,
237 if (err) 237 if (err)
238 return err; 238 return err;
239 239
240 memcpy(priv->maxrate, tmp, sizeof(*priv->maxrate)); 240 memcpy(priv->maxrate, tmp, sizeof(priv->maxrate));
241 241
242 return 0; 242 return 0;
243} 243}
diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c
index b01f83a044c4..609125a249d9 100644
--- a/drivers/net/ethernet/realtek/8139cp.c
+++ b/drivers/net/ethernet/realtek/8139cp.c
@@ -1060,17 +1060,22 @@ static int cp_init_rings (struct cp_private *cp)
1060 1060
1061static int cp_alloc_rings (struct cp_private *cp) 1061static int cp_alloc_rings (struct cp_private *cp)
1062{ 1062{
1063 struct device *d = &cp->pdev->dev;
1063 void *mem; 1064 void *mem;
1065 int rc;
1064 1066
1065 mem = dma_alloc_coherent(&cp->pdev->dev, CP_RING_BYTES, 1067 mem = dma_alloc_coherent(d, CP_RING_BYTES, &cp->ring_dma, GFP_KERNEL);
1066 &cp->ring_dma, GFP_KERNEL);
1067 if (!mem) 1068 if (!mem)
1068 return -ENOMEM; 1069 return -ENOMEM;
1069 1070
1070 cp->rx_ring = mem; 1071 cp->rx_ring = mem;
1071 cp->tx_ring = &cp->rx_ring[CP_RX_RING_SIZE]; 1072 cp->tx_ring = &cp->rx_ring[CP_RX_RING_SIZE];
1072 1073
1073 return cp_init_rings(cp); 1074 rc = cp_init_rings(cp);
1075 if (rc < 0)
1076 dma_free_coherent(d, CP_RING_BYTES, cp->rx_ring, cp->ring_dma);
1077
1078 return rc;
1074} 1079}
1075 1080
1076static void cp_clean_rings (struct cp_private *cp) 1081static void cp_clean_rings (struct cp_private *cp)
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index d44cca327588..ad86660fb8f9 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -1794,10 +1794,12 @@ static void team_setup(struct net_device *dev)
1794 1794
1795 dev->features |= NETIF_F_LLTX; 1795 dev->features |= NETIF_F_LLTX;
1796 dev->features |= NETIF_F_GRO; 1796 dev->features |= NETIF_F_GRO;
1797 dev->hw_features = NETIF_F_HW_VLAN_TX | 1797 dev->hw_features = TEAM_VLAN_FEATURES |
1798 NETIF_F_HW_VLAN_TX |
1798 NETIF_F_HW_VLAN_RX | 1799 NETIF_F_HW_VLAN_RX |
1799 NETIF_F_HW_VLAN_FILTER; 1800 NETIF_F_HW_VLAN_FILTER;
1800 1801
1802 dev->hw_features &= ~(NETIF_F_ALL_CSUM & ~NETIF_F_HW_CSUM);
1801 dev->features |= dev->hw_features; 1803 dev->features |= dev->hw_features;
1802} 1804}
1803 1805
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 3b566fa0f8e6..1ea91f4237f0 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -385,6 +385,7 @@ static const struct usb_device_id products[] = {
385 }, 385 },
386 386
387 /* 3. Combined interface devices matching on interface number */ 387 /* 3. Combined interface devices matching on interface number */
388 {QMI_FIXED_INTF(0x12d1, 0x140c, 1)}, /* Huawei E173 */
388 {QMI_FIXED_INTF(0x19d2, 0x0002, 1)}, 389 {QMI_FIXED_INTF(0x19d2, 0x0002, 1)},
389 {QMI_FIXED_INTF(0x19d2, 0x0012, 1)}, 390 {QMI_FIXED_INTF(0x19d2, 0x0012, 1)},
390 {QMI_FIXED_INTF(0x19d2, 0x0017, 3)}, 391 {QMI_FIXED_INTF(0x19d2, 0x0017, 3)},
diff --git a/drivers/net/wan/ixp4xx_hss.c b/drivers/net/wan/ixp4xx_hss.c
index e9a3da588e95..760776b3d66c 100644
--- a/drivers/net/wan/ixp4xx_hss.c
+++ b/drivers/net/wan/ixp4xx_hss.c
@@ -1365,7 +1365,7 @@ static int __devinit hss_init_one(struct platform_device *pdev)
1365 1365
1366 platform_set_drvdata(pdev, port); 1366 platform_set_drvdata(pdev, port);
1367 1367
1368 netdev_info(dev, "HSS-%i\n", port->id); 1368 netdev_info(dev, "initialized\n");
1369 return 0; 1369 return 0;
1370 1370
1371err_free_netdev: 1371err_free_netdev:
diff --git a/drivers/net/wireless/iwlwifi/dvm/rxon.c b/drivers/net/wireless/iwlwifi/dvm/rxon.c
index 10896393e5a0..2830ea290502 100644
--- a/drivers/net/wireless/iwlwifi/dvm/rxon.c
+++ b/drivers/net/wireless/iwlwifi/dvm/rxon.c
@@ -1012,12 +1012,12 @@ static void iwl_calc_basic_rates(struct iwl_priv *priv,
1012 * As a consequence, it's not as complicated as it sounds, just add 1012 * As a consequence, it's not as complicated as it sounds, just add
1013 * any lower rates to the ACK rate bitmap. 1013 * any lower rates to the ACK rate bitmap.
1014 */ 1014 */
1015 if (IWL_RATE_11M_INDEX < lowest_present_ofdm) 1015 if (IWL_RATE_11M_INDEX < lowest_present_cck)
1016 ofdm |= IWL_RATE_11M_MASK >> IWL_FIRST_CCK_RATE; 1016 cck |= IWL_RATE_11M_MASK >> IWL_FIRST_CCK_RATE;
1017 if (IWL_RATE_5M_INDEX < lowest_present_ofdm) 1017 if (IWL_RATE_5M_INDEX < lowest_present_cck)
1018 ofdm |= IWL_RATE_5M_MASK >> IWL_FIRST_CCK_RATE; 1018 cck |= IWL_RATE_5M_MASK >> IWL_FIRST_CCK_RATE;
1019 if (IWL_RATE_2M_INDEX < lowest_present_ofdm) 1019 if (IWL_RATE_2M_INDEX < lowest_present_cck)
1020 ofdm |= IWL_RATE_2M_MASK >> IWL_FIRST_CCK_RATE; 1020 cck |= IWL_RATE_2M_MASK >> IWL_FIRST_CCK_RATE;
1021 /* 1M already there or needed so always add */ 1021 /* 1M already there or needed so always add */
1022 cck |= IWL_RATE_1M_MASK >> IWL_FIRST_CCK_RATE; 1022 cck |= IWL_RATE_1M_MASK >> IWL_FIRST_CCK_RATE;
1023 1023
diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c
index e7a4780e93db..9e198e590675 100644
--- a/drivers/remoteproc/remoteproc_virtio.c
+++ b/drivers/remoteproc/remoteproc_virtio.c
@@ -120,15 +120,11 @@ static struct virtqueue *rp_find_vq(struct virtio_device *vdev,
120 return vq; 120 return vq;
121} 121}
122 122
123static void rproc_virtio_del_vqs(struct virtio_device *vdev) 123static void __rproc_virtio_del_vqs(struct virtio_device *vdev)
124{ 124{
125 struct virtqueue *vq, *n; 125 struct virtqueue *vq, *n;
126 struct rproc *rproc = vdev_to_rproc(vdev);
127 struct rproc_vring *rvring; 126 struct rproc_vring *rvring;
128 127
129 /* power down the remote processor before deleting vqs */
130 rproc_shutdown(rproc);
131
132 list_for_each_entry_safe(vq, n, &vdev->vqs, list) { 128 list_for_each_entry_safe(vq, n, &vdev->vqs, list) {
133 rvring = vq->priv; 129 rvring = vq->priv;
134 rvring->vq = NULL; 130 rvring->vq = NULL;
@@ -137,6 +133,16 @@ static void rproc_virtio_del_vqs(struct virtio_device *vdev)
137 } 133 }
138} 134}
139 135
136static void rproc_virtio_del_vqs(struct virtio_device *vdev)
137{
138 struct rproc *rproc = vdev_to_rproc(vdev);
139
140 /* power down the remote processor before deleting vqs */
141 rproc_shutdown(rproc);
142
143 __rproc_virtio_del_vqs(vdev);
144}
145
140static int rproc_virtio_find_vqs(struct virtio_device *vdev, unsigned nvqs, 146static int rproc_virtio_find_vqs(struct virtio_device *vdev, unsigned nvqs,
141 struct virtqueue *vqs[], 147 struct virtqueue *vqs[],
142 vq_callback_t *callbacks[], 148 vq_callback_t *callbacks[],
@@ -163,7 +169,7 @@ static int rproc_virtio_find_vqs(struct virtio_device *vdev, unsigned nvqs,
163 return 0; 169 return 0;
164 170
165error: 171error:
166 rproc_virtio_del_vqs(vdev); 172 __rproc_virtio_del_vqs(vdev);
167 return ret; 173 return ret;
168} 174}
169 175
diff --git a/drivers/rtc/rtc-tps65910.c b/drivers/rtc/rtc-tps65910.c
index 7a82337e4dee..073108dcf9e7 100644
--- a/drivers/rtc/rtc-tps65910.c
+++ b/drivers/rtc/rtc-tps65910.c
@@ -288,11 +288,11 @@ static int __devinit tps65910_rtc_probe(struct platform_device *pdev)
288static int __devexit tps65910_rtc_remove(struct platform_device *pdev) 288static int __devexit tps65910_rtc_remove(struct platform_device *pdev)
289{ 289{
290 /* leave rtc running, but disable irqs */ 290 /* leave rtc running, but disable irqs */
291 struct rtc_device *rtc = platform_get_drvdata(pdev); 291 struct tps65910_rtc *tps_rtc = platform_get_drvdata(pdev);
292 292
293 tps65910_rtc_alarm_irq_enable(&rtc->dev, 0); 293 tps65910_rtc_alarm_irq_enable(&pdev->dev, 0);
294 294
295 rtc_device_unregister(rtc); 295 rtc_device_unregister(tps_rtc->rtc);
296 return 0; 296 return 0;
297} 297}
298 298
diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
index 16b7a72a70c4..3b2365c8eab2 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -1276,7 +1276,7 @@ struct megasas_evt_detail {
1276} __attribute__ ((packed)); 1276} __attribute__ ((packed));
1277 1277
1278struct megasas_aen_event { 1278struct megasas_aen_event {
1279 struct work_struct hotplug_work; 1279 struct delayed_work hotplug_work;
1280 struct megasas_instance *instance; 1280 struct megasas_instance *instance;
1281}; 1281};
1282 1282
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index d2c5366aff7f..e4f2baacf1e1 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -2060,9 +2060,9 @@ megasas_service_aen(struct megasas_instance *instance, struct megasas_cmd *cmd)
2060 } else { 2060 } else {
2061 ev->instance = instance; 2061 ev->instance = instance;
2062 instance->ev = ev; 2062 instance->ev = ev;
2063 INIT_WORK(&ev->hotplug_work, megasas_aen_polling); 2063 INIT_DELAYED_WORK(&ev->hotplug_work,
2064 schedule_delayed_work( 2064 megasas_aen_polling);
2065 (struct delayed_work *)&ev->hotplug_work, 0); 2065 schedule_delayed_work(&ev->hotplug_work, 0);
2066 } 2066 }
2067 } 2067 }
2068} 2068}
@@ -4352,8 +4352,7 @@ megasas_suspend(struct pci_dev *pdev, pm_message_t state)
4352 /* cancel the delayed work if this work still in queue */ 4352 /* cancel the delayed work if this work still in queue */
4353 if (instance->ev != NULL) { 4353 if (instance->ev != NULL) {
4354 struct megasas_aen_event *ev = instance->ev; 4354 struct megasas_aen_event *ev = instance->ev;
4355 cancel_delayed_work_sync( 4355 cancel_delayed_work_sync(&ev->hotplug_work);
4356 (struct delayed_work *)&ev->hotplug_work);
4357 instance->ev = NULL; 4356 instance->ev = NULL;
4358 } 4357 }
4359 4358
@@ -4545,8 +4544,7 @@ static void __devexit megasas_detach_one(struct pci_dev *pdev)
4545 /* cancel the delayed work if this work still in queue*/ 4544 /* cancel the delayed work if this work still in queue*/
4546 if (instance->ev != NULL) { 4545 if (instance->ev != NULL) {
4547 struct megasas_aen_event *ev = instance->ev; 4546 struct megasas_aen_event *ev = instance->ev;
4548 cancel_delayed_work_sync( 4547 cancel_delayed_work_sync(&ev->hotplug_work);
4549 (struct delayed_work *)&ev->hotplug_work);
4550 instance->ev = NULL; 4548 instance->ev = NULL;
4551 } 4549 }
4552 4550
@@ -5190,7 +5188,7 @@ static void
5190megasas_aen_polling(struct work_struct *work) 5188megasas_aen_polling(struct work_struct *work)
5191{ 5189{
5192 struct megasas_aen_event *ev = 5190 struct megasas_aen_event *ev =
5193 container_of(work, struct megasas_aen_event, hotplug_work); 5191 container_of(work, struct megasas_aen_event, hotplug_work.work);
5194 struct megasas_instance *instance = ev->instance; 5192 struct megasas_instance *instance = ev->instance;
5195 union megasas_evt_class_locale class_locale; 5193 union megasas_evt_class_locale class_locale;
5196 struct Scsi_Host *host; 5194 struct Scsi_Host *host;
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 9097155e9ebe..dcecbfb17243 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1819,8 +1819,10 @@ void target_execute_cmd(struct se_cmd *cmd)
1819 /* 1819 /*
1820 * If the received CDB has aleady been aborted stop processing it here. 1820 * If the received CDB has aleady been aborted stop processing it here.
1821 */ 1821 */
1822 if (transport_check_aborted_status(cmd, 1)) 1822 if (transport_check_aborted_status(cmd, 1)) {
1823 complete(&cmd->t_transport_stop_comp);
1823 return; 1824 return;
1825 }
1824 1826
1825 /* 1827 /*
1826 * Determine if IOCTL context caller in requesting the stopping of this 1828 * Determine if IOCTL context caller in requesting the stopping of this
@@ -3067,7 +3069,7 @@ void transport_send_task_abort(struct se_cmd *cmd)
3067 unsigned long flags; 3069 unsigned long flags;
3068 3070
3069 spin_lock_irqsave(&cmd->t_state_lock, flags); 3071 spin_lock_irqsave(&cmd->t_state_lock, flags);
3070 if (cmd->se_cmd_flags & SCF_SENT_CHECK_CONDITION) { 3072 if (cmd->se_cmd_flags & (SCF_SENT_CHECK_CONDITION | SCF_SENT_DELAYED_TAS)) {
3071 spin_unlock_irqrestore(&cmd->t_state_lock, flags); 3073 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
3072 return; 3074 return;
3073 } 3075 }
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index f87d7e8964bf..4e0d0c3734b3 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -539,25 +539,25 @@ static void insert_char(struct vc_data *vc, unsigned int nr)
539{ 539{
540 unsigned short *p = (unsigned short *) vc->vc_pos; 540 unsigned short *p = (unsigned short *) vc->vc_pos;
541 541
542 scr_memmovew(p + nr, p, vc->vc_cols - vc->vc_x); 542 scr_memmovew(p + nr, p, (vc->vc_cols - vc->vc_x) * 2);
543 scr_memsetw(p, vc->vc_video_erase_char, nr * 2); 543 scr_memsetw(p, vc->vc_video_erase_char, nr * 2);
544 vc->vc_need_wrap = 0; 544 vc->vc_need_wrap = 0;
545 if (DO_UPDATE(vc)) 545 if (DO_UPDATE(vc))
546 do_update_region(vc, (unsigned long) p, 546 do_update_region(vc, (unsigned long) p,
547 (vc->vc_cols - vc->vc_x) / 2 + 1); 547 vc->vc_cols - vc->vc_x);
548} 548}
549 549
550static void delete_char(struct vc_data *vc, unsigned int nr) 550static void delete_char(struct vc_data *vc, unsigned int nr)
551{ 551{
552 unsigned short *p = (unsigned short *) vc->vc_pos; 552 unsigned short *p = (unsigned short *) vc->vc_pos;
553 553
554 scr_memcpyw(p, p + nr, vc->vc_cols - vc->vc_x - nr); 554 scr_memcpyw(p, p + nr, (vc->vc_cols - vc->vc_x - nr) * 2);
555 scr_memsetw(p + vc->vc_cols - vc->vc_x - nr, vc->vc_video_erase_char, 555 scr_memsetw(p + vc->vc_cols - vc->vc_x - nr, vc->vc_video_erase_char,
556 nr * 2); 556 nr * 2);
557 vc->vc_need_wrap = 0; 557 vc->vc_need_wrap = 0;
558 if (DO_UPDATE(vc)) 558 if (DO_UPDATE(vc))
559 do_update_region(vc, (unsigned long) p, 559 do_update_region(vc, (unsigned long) p,
560 (vc->vc_cols - vc->vc_x) / 2); 560 vc->vc_cols - vc->vc_x);
561} 561}
562 562
563static int softcursor_original; 563static int softcursor_original;
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 99ac2cb08b43..dedaf81d8f36 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -1076,7 +1076,7 @@ static int translate_desc(struct vhost_dev *dev, u64 addr, u32 len,
1076 } 1076 }
1077 _iov = iov + ret; 1077 _iov = iov + ret;
1078 size = reg->memory_size - addr + reg->guest_phys_addr; 1078 size = reg->memory_size - addr + reg->guest_phys_addr;
1079 _iov->iov_len = min((u64)len, size); 1079 _iov->iov_len = min((u64)len - s, size);
1080 _iov->iov_base = (void __user *)(unsigned long) 1080 _iov->iov_base = (void __user *)(unsigned long)
1081 (reg->userspace_addr + addr - reg->guest_phys_addr); 1081 (reg->userspace_addr + addr - reg->guest_phys_addr);
1082 s += size; 1082 s += size;
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 1a1e5e3b1eaf..ab3a456f6650 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -70,19 +70,6 @@ static void bdev_inode_switch_bdi(struct inode *inode,
70 spin_unlock(&dst->wb.list_lock); 70 spin_unlock(&dst->wb.list_lock);
71} 71}
72 72
73sector_t blkdev_max_block(struct block_device *bdev)
74{
75 sector_t retval = ~((sector_t)0);
76 loff_t sz = i_size_read(bdev->bd_inode);
77
78 if (sz) {
79 unsigned int size = block_size(bdev);
80 unsigned int sizebits = blksize_bits(size);
81 retval = (sz >> sizebits);
82 }
83 return retval;
84}
85
86/* Kill _all_ buffers and pagecache , dirty or not.. */ 73/* Kill _all_ buffers and pagecache , dirty or not.. */
87void kill_bdev(struct block_device *bdev) 74void kill_bdev(struct block_device *bdev)
88{ 75{
@@ -116,8 +103,6 @@ EXPORT_SYMBOL(invalidate_bdev);
116 103
117int set_blocksize(struct block_device *bdev, int size) 104int set_blocksize(struct block_device *bdev, int size)
118{ 105{
119 struct address_space *mapping;
120
121 /* Size must be a power of two, and between 512 and PAGE_SIZE */ 106 /* Size must be a power of two, and between 512 and PAGE_SIZE */
122 if (size > PAGE_SIZE || size < 512 || !is_power_of_2(size)) 107 if (size > PAGE_SIZE || size < 512 || !is_power_of_2(size))
123 return -EINVAL; 108 return -EINVAL;
@@ -126,19 +111,6 @@ int set_blocksize(struct block_device *bdev, int size)
126 if (size < bdev_logical_block_size(bdev)) 111 if (size < bdev_logical_block_size(bdev))
127 return -EINVAL; 112 return -EINVAL;
128 113
129 /* Prevent starting I/O or mapping the device */
130 percpu_down_write(&bdev->bd_block_size_semaphore);
131
132 /* Check that the block device is not memory mapped */
133 mapping = bdev->bd_inode->i_mapping;
134 mutex_lock(&mapping->i_mmap_mutex);
135 if (mapping_mapped(mapping)) {
136 mutex_unlock(&mapping->i_mmap_mutex);
137 percpu_up_write(&bdev->bd_block_size_semaphore);
138 return -EBUSY;
139 }
140 mutex_unlock(&mapping->i_mmap_mutex);
141
142 /* Don't change the size if it is same as current */ 114 /* Don't change the size if it is same as current */
143 if (bdev->bd_block_size != size) { 115 if (bdev->bd_block_size != size) {
144 sync_blockdev(bdev); 116 sync_blockdev(bdev);
@@ -146,9 +118,6 @@ int set_blocksize(struct block_device *bdev, int size)
146 bdev->bd_inode->i_blkbits = blksize_bits(size); 118 bdev->bd_inode->i_blkbits = blksize_bits(size);
147 kill_bdev(bdev); 119 kill_bdev(bdev);
148 } 120 }
149
150 percpu_up_write(&bdev->bd_block_size_semaphore);
151
152 return 0; 121 return 0;
153} 122}
154 123
@@ -181,52 +150,12 @@ static int
181blkdev_get_block(struct inode *inode, sector_t iblock, 150blkdev_get_block(struct inode *inode, sector_t iblock,
182 struct buffer_head *bh, int create) 151 struct buffer_head *bh, int create)
183{ 152{
184 if (iblock >= blkdev_max_block(I_BDEV(inode))) {
185 if (create)
186 return -EIO;
187
188 /*
189 * for reads, we're just trying to fill a partial page.
190 * return a hole, they will have to call get_block again
191 * before they can fill it, and they will get -EIO at that
192 * time
193 */
194 return 0;
195 }
196 bh->b_bdev = I_BDEV(inode); 153 bh->b_bdev = I_BDEV(inode);
197 bh->b_blocknr = iblock; 154 bh->b_blocknr = iblock;
198 set_buffer_mapped(bh); 155 set_buffer_mapped(bh);
199 return 0; 156 return 0;
200} 157}
201 158
202static int
203blkdev_get_blocks(struct inode *inode, sector_t iblock,
204 struct buffer_head *bh, int create)
205{
206 sector_t end_block = blkdev_max_block(I_BDEV(inode));
207 unsigned long max_blocks = bh->b_size >> inode->i_blkbits;
208
209 if ((iblock + max_blocks) > end_block) {
210 max_blocks = end_block - iblock;
211 if ((long)max_blocks <= 0) {
212 if (create)
213 return -EIO; /* write fully beyond EOF */
214 /*
215 * It is a read which is fully beyond EOF. We return
216 * a !buffer_mapped buffer
217 */
218 max_blocks = 0;
219 }
220 }
221
222 bh->b_bdev = I_BDEV(inode);
223 bh->b_blocknr = iblock;
224 bh->b_size = max_blocks << inode->i_blkbits;
225 if (max_blocks)
226 set_buffer_mapped(bh);
227 return 0;
228}
229
230static ssize_t 159static ssize_t
231blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, 160blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
232 loff_t offset, unsigned long nr_segs) 161 loff_t offset, unsigned long nr_segs)
@@ -235,7 +164,7 @@ blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
235 struct inode *inode = file->f_mapping->host; 164 struct inode *inode = file->f_mapping->host;
236 165
237 return __blockdev_direct_IO(rw, iocb, inode, I_BDEV(inode), iov, offset, 166 return __blockdev_direct_IO(rw, iocb, inode, I_BDEV(inode), iov, offset,
238 nr_segs, blkdev_get_blocks, NULL, NULL, 0); 167 nr_segs, blkdev_get_block, NULL, NULL, 0);
239} 168}
240 169
241int __sync_blockdev(struct block_device *bdev, int wait) 170int __sync_blockdev(struct block_device *bdev, int wait)
@@ -459,12 +388,6 @@ static struct inode *bdev_alloc_inode(struct super_block *sb)
459 struct bdev_inode *ei = kmem_cache_alloc(bdev_cachep, GFP_KERNEL); 388 struct bdev_inode *ei = kmem_cache_alloc(bdev_cachep, GFP_KERNEL);
460 if (!ei) 389 if (!ei)
461 return NULL; 390 return NULL;
462
463 if (unlikely(percpu_init_rwsem(&ei->bdev.bd_block_size_semaphore))) {
464 kmem_cache_free(bdev_cachep, ei);
465 return NULL;
466 }
467
468 return &ei->vfs_inode; 391 return &ei->vfs_inode;
469} 392}
470 393
@@ -473,8 +396,6 @@ static void bdev_i_callback(struct rcu_head *head)
473 struct inode *inode = container_of(head, struct inode, i_rcu); 396 struct inode *inode = container_of(head, struct inode, i_rcu);
474 struct bdev_inode *bdi = BDEV_I(inode); 397 struct bdev_inode *bdi = BDEV_I(inode);
475 398
476 percpu_free_rwsem(&bdi->bdev.bd_block_size_semaphore);
477
478 kmem_cache_free(bdev_cachep, bdi); 399 kmem_cache_free(bdev_cachep, bdi);
479} 400}
480 401
@@ -1593,22 +1514,6 @@ static long block_ioctl(struct file *file, unsigned cmd, unsigned long arg)
1593 return blkdev_ioctl(bdev, mode, cmd, arg); 1514 return blkdev_ioctl(bdev, mode, cmd, arg);
1594} 1515}
1595 1516
1596ssize_t blkdev_aio_read(struct kiocb *iocb, const struct iovec *iov,
1597 unsigned long nr_segs, loff_t pos)
1598{
1599 ssize_t ret;
1600 struct block_device *bdev = I_BDEV(iocb->ki_filp->f_mapping->host);
1601
1602 percpu_down_read(&bdev->bd_block_size_semaphore);
1603
1604 ret = generic_file_aio_read(iocb, iov, nr_segs, pos);
1605
1606 percpu_up_read(&bdev->bd_block_size_semaphore);
1607
1608 return ret;
1609}
1610EXPORT_SYMBOL_GPL(blkdev_aio_read);
1611
1612/* 1517/*
1613 * Write data to the block device. Only intended for the block device itself 1518 * Write data to the block device. Only intended for the block device itself
1614 * and the raw driver which basically is a fake block device. 1519 * and the raw driver which basically is a fake block device.
@@ -1620,16 +1525,12 @@ ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov,
1620 unsigned long nr_segs, loff_t pos) 1525 unsigned long nr_segs, loff_t pos)
1621{ 1526{
1622 struct file *file = iocb->ki_filp; 1527 struct file *file = iocb->ki_filp;
1623 struct block_device *bdev = I_BDEV(file->f_mapping->host);
1624 struct blk_plug plug; 1528 struct blk_plug plug;
1625 ssize_t ret; 1529 ssize_t ret;
1626 1530
1627 BUG_ON(iocb->ki_pos != pos); 1531 BUG_ON(iocb->ki_pos != pos);
1628 1532
1629 blk_start_plug(&plug); 1533 blk_start_plug(&plug);
1630
1631 percpu_down_read(&bdev->bd_block_size_semaphore);
1632
1633 ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos); 1534 ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos);
1634 if (ret > 0 || ret == -EIOCBQUEUED) { 1535 if (ret > 0 || ret == -EIOCBQUEUED) {
1635 ssize_t err; 1536 ssize_t err;
@@ -1638,62 +1539,27 @@ ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov,
1638 if (err < 0 && ret > 0) 1539 if (err < 0 && ret > 0)
1639 ret = err; 1540 ret = err;
1640 } 1541 }
1641
1642 percpu_up_read(&bdev->bd_block_size_semaphore);
1643
1644 blk_finish_plug(&plug); 1542 blk_finish_plug(&plug);
1645
1646 return ret; 1543 return ret;
1647} 1544}
1648EXPORT_SYMBOL_GPL(blkdev_aio_write); 1545EXPORT_SYMBOL_GPL(blkdev_aio_write);
1649 1546
1650static int blkdev_mmap(struct file *file, struct vm_area_struct *vma) 1547static ssize_t blkdev_aio_read(struct kiocb *iocb, const struct iovec *iov,
1651{ 1548 unsigned long nr_segs, loff_t pos)
1652 int ret;
1653 struct block_device *bdev = I_BDEV(file->f_mapping->host);
1654
1655 percpu_down_read(&bdev->bd_block_size_semaphore);
1656
1657 ret = generic_file_mmap(file, vma);
1658
1659 percpu_up_read(&bdev->bd_block_size_semaphore);
1660
1661 return ret;
1662}
1663
1664static ssize_t blkdev_splice_read(struct file *file, loff_t *ppos,
1665 struct pipe_inode_info *pipe, size_t len,
1666 unsigned int flags)
1667{
1668 ssize_t ret;
1669 struct block_device *bdev = I_BDEV(file->f_mapping->host);
1670
1671 percpu_down_read(&bdev->bd_block_size_semaphore);
1672
1673 ret = generic_file_splice_read(file, ppos, pipe, len, flags);
1674
1675 percpu_up_read(&bdev->bd_block_size_semaphore);
1676
1677 return ret;
1678}
1679
1680static ssize_t blkdev_splice_write(struct pipe_inode_info *pipe,
1681 struct file *file, loff_t *ppos, size_t len,
1682 unsigned int flags)
1683{ 1549{
1684 ssize_t ret; 1550 struct file *file = iocb->ki_filp;
1685 struct block_device *bdev = I_BDEV(file->f_mapping->host); 1551 struct inode *bd_inode = file->f_mapping->host;
1686 1552 loff_t size = i_size_read(bd_inode);
1687 percpu_down_read(&bdev->bd_block_size_semaphore);
1688
1689 ret = generic_file_splice_write(pipe, file, ppos, len, flags);
1690 1553
1691 percpu_up_read(&bdev->bd_block_size_semaphore); 1554 if (pos >= size)
1555 return 0;
1692 1556
1693 return ret; 1557 size -= pos;
1558 if (size < INT_MAX)
1559 nr_segs = iov_shorten((struct iovec *)iov, nr_segs, size);
1560 return generic_file_aio_read(iocb, iov, nr_segs, pos);
1694} 1561}
1695 1562
1696
1697/* 1563/*
1698 * Try to release a page associated with block device when the system 1564 * Try to release a page associated with block device when the system
1699 * is under memory pressure. 1565 * is under memory pressure.
@@ -1724,16 +1590,16 @@ const struct file_operations def_blk_fops = {
1724 .llseek = block_llseek, 1590 .llseek = block_llseek,
1725 .read = do_sync_read, 1591 .read = do_sync_read,
1726 .write = do_sync_write, 1592 .write = do_sync_write,
1727 .aio_read = blkdev_aio_read, 1593 .aio_read = blkdev_aio_read,
1728 .aio_write = blkdev_aio_write, 1594 .aio_write = blkdev_aio_write,
1729 .mmap = blkdev_mmap, 1595 .mmap = generic_file_mmap,
1730 .fsync = blkdev_fsync, 1596 .fsync = blkdev_fsync,
1731 .unlocked_ioctl = block_ioctl, 1597 .unlocked_ioctl = block_ioctl,
1732#ifdef CONFIG_COMPAT 1598#ifdef CONFIG_COMPAT
1733 .compat_ioctl = compat_blkdev_ioctl, 1599 .compat_ioctl = compat_blkdev_ioctl,
1734#endif 1600#endif
1735 .splice_read = blkdev_splice_read, 1601 .splice_read = generic_file_splice_read,
1736 .splice_write = blkdev_splice_write, 1602 .splice_write = generic_file_splice_write,
1737}; 1603};
1738 1604
1739int ioctl_by_bdev(struct block_device *bdev, unsigned cmd, unsigned long arg) 1605int ioctl_by_bdev(struct block_device *bdev, unsigned cmd, unsigned long arg)
diff --git a/fs/buffer.c b/fs/buffer.c
index b5f044283edb..ec0aca8ba6bf 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -911,6 +911,18 @@ link_dev_buffers(struct page *page, struct buffer_head *head)
911 attach_page_buffers(page, head); 911 attach_page_buffers(page, head);
912} 912}
913 913
914static sector_t blkdev_max_block(struct block_device *bdev, unsigned int size)
915{
916 sector_t retval = ~((sector_t)0);
917 loff_t sz = i_size_read(bdev->bd_inode);
918
919 if (sz) {
920 unsigned int sizebits = blksize_bits(size);
921 retval = (sz >> sizebits);
922 }
923 return retval;
924}
925
914/* 926/*
915 * Initialise the state of a blockdev page's buffers. 927 * Initialise the state of a blockdev page's buffers.
916 */ 928 */
@@ -921,7 +933,7 @@ init_page_buffers(struct page *page, struct block_device *bdev,
921 struct buffer_head *head = page_buffers(page); 933 struct buffer_head *head = page_buffers(page);
922 struct buffer_head *bh = head; 934 struct buffer_head *bh = head;
923 int uptodate = PageUptodate(page); 935 int uptodate = PageUptodate(page);
924 sector_t end_block = blkdev_max_block(I_BDEV(bdev->bd_inode)); 936 sector_t end_block = blkdev_max_block(I_BDEV(bdev->bd_inode), size);
925 937
926 do { 938 do {
927 if (!buffer_mapped(bh)) { 939 if (!buffer_mapped(bh)) {
@@ -1553,6 +1565,28 @@ void unmap_underlying_metadata(struct block_device *bdev, sector_t block)
1553EXPORT_SYMBOL(unmap_underlying_metadata); 1565EXPORT_SYMBOL(unmap_underlying_metadata);
1554 1566
1555/* 1567/*
1568 * Size is a power-of-two in the range 512..PAGE_SIZE,
1569 * and the case we care about most is PAGE_SIZE.
1570 *
1571 * So this *could* possibly be written with those
1572 * constraints in mind (relevant mostly if some
1573 * architecture has a slow bit-scan instruction)
1574 */
1575static inline int block_size_bits(unsigned int blocksize)
1576{
1577 return ilog2(blocksize);
1578}
1579
1580static struct buffer_head *create_page_buffers(struct page *page, struct inode *inode, unsigned int b_state)
1581{
1582 BUG_ON(!PageLocked(page));
1583
1584 if (!page_has_buffers(page))
1585 create_empty_buffers(page, 1 << ACCESS_ONCE(inode->i_blkbits), b_state);
1586 return page_buffers(page);
1587}
1588
1589/*
1556 * NOTE! All mapped/uptodate combinations are valid: 1590 * NOTE! All mapped/uptodate combinations are valid:
1557 * 1591 *
1558 * Mapped Uptodate Meaning 1592 * Mapped Uptodate Meaning
@@ -1589,19 +1623,13 @@ static int __block_write_full_page(struct inode *inode, struct page *page,
1589 sector_t block; 1623 sector_t block;
1590 sector_t last_block; 1624 sector_t last_block;
1591 struct buffer_head *bh, *head; 1625 struct buffer_head *bh, *head;
1592 const unsigned blocksize = 1 << inode->i_blkbits; 1626 unsigned int blocksize, bbits;
1593 int nr_underway = 0; 1627 int nr_underway = 0;
1594 int write_op = (wbc->sync_mode == WB_SYNC_ALL ? 1628 int write_op = (wbc->sync_mode == WB_SYNC_ALL ?
1595 WRITE_SYNC : WRITE); 1629 WRITE_SYNC : WRITE);
1596 1630
1597 BUG_ON(!PageLocked(page)); 1631 head = create_page_buffers(page, inode,
1598
1599 last_block = (i_size_read(inode) - 1) >> inode->i_blkbits;
1600
1601 if (!page_has_buffers(page)) {
1602 create_empty_buffers(page, blocksize,
1603 (1 << BH_Dirty)|(1 << BH_Uptodate)); 1632 (1 << BH_Dirty)|(1 << BH_Uptodate));
1604 }
1605 1633
1606 /* 1634 /*
1607 * Be very careful. We have no exclusion from __set_page_dirty_buffers 1635 * Be very careful. We have no exclusion from __set_page_dirty_buffers
@@ -1613,9 +1641,12 @@ static int __block_write_full_page(struct inode *inode, struct page *page,
1613 * handle that here by just cleaning them. 1641 * handle that here by just cleaning them.
1614 */ 1642 */
1615 1643
1616 block = (sector_t)page->index << (PAGE_CACHE_SHIFT - inode->i_blkbits);
1617 head = page_buffers(page);
1618 bh = head; 1644 bh = head;
1645 blocksize = bh->b_size;
1646 bbits = block_size_bits(blocksize);
1647
1648 block = (sector_t)page->index << (PAGE_CACHE_SHIFT - bbits);
1649 last_block = (i_size_read(inode) - 1) >> bbits;
1619 1650
1620 /* 1651 /*
1621 * Get all the dirty buffers mapped to disk addresses and 1652 * Get all the dirty buffers mapped to disk addresses and
@@ -1806,12 +1837,10 @@ int __block_write_begin(struct page *page, loff_t pos, unsigned len,
1806 BUG_ON(to > PAGE_CACHE_SIZE); 1837 BUG_ON(to > PAGE_CACHE_SIZE);
1807 BUG_ON(from > to); 1838 BUG_ON(from > to);
1808 1839
1809 blocksize = 1 << inode->i_blkbits; 1840 head = create_page_buffers(page, inode, 0);
1810 if (!page_has_buffers(page)) 1841 blocksize = head->b_size;
1811 create_empty_buffers(page, blocksize, 0); 1842 bbits = block_size_bits(blocksize);
1812 head = page_buffers(page);
1813 1843
1814 bbits = inode->i_blkbits;
1815 block = (sector_t)page->index << (PAGE_CACHE_SHIFT - bbits); 1844 block = (sector_t)page->index << (PAGE_CACHE_SHIFT - bbits);
1816 1845
1817 for(bh = head, block_start = 0; bh != head || !block_start; 1846 for(bh = head, block_start = 0; bh != head || !block_start;
@@ -1881,11 +1910,11 @@ static int __block_commit_write(struct inode *inode, struct page *page,
1881 unsigned blocksize; 1910 unsigned blocksize;
1882 struct buffer_head *bh, *head; 1911 struct buffer_head *bh, *head;
1883 1912
1884 blocksize = 1 << inode->i_blkbits; 1913 bh = head = page_buffers(page);
1914 blocksize = bh->b_size;
1885 1915
1886 for(bh = head = page_buffers(page), block_start = 0; 1916 block_start = 0;
1887 bh != head || !block_start; 1917 do {
1888 block_start=block_end, bh = bh->b_this_page) {
1889 block_end = block_start + blocksize; 1918 block_end = block_start + blocksize;
1890 if (block_end <= from || block_start >= to) { 1919 if (block_end <= from || block_start >= to) {
1891 if (!buffer_uptodate(bh)) 1920 if (!buffer_uptodate(bh))
@@ -1895,7 +1924,10 @@ static int __block_commit_write(struct inode *inode, struct page *page,
1895 mark_buffer_dirty(bh); 1924 mark_buffer_dirty(bh);
1896 } 1925 }
1897 clear_buffer_new(bh); 1926 clear_buffer_new(bh);
1898 } 1927
1928 block_start = block_end;
1929 bh = bh->b_this_page;
1930 } while (bh != head);
1899 1931
1900 /* 1932 /*
1901 * If this is a partial write which happened to make all buffers 1933 * If this is a partial write which happened to make all buffers
@@ -2020,7 +2052,6 @@ EXPORT_SYMBOL(generic_write_end);
2020int block_is_partially_uptodate(struct page *page, read_descriptor_t *desc, 2052int block_is_partially_uptodate(struct page *page, read_descriptor_t *desc,
2021 unsigned long from) 2053 unsigned long from)
2022{ 2054{
2023 struct inode *inode = page->mapping->host;
2024 unsigned block_start, block_end, blocksize; 2055 unsigned block_start, block_end, blocksize;
2025 unsigned to; 2056 unsigned to;
2026 struct buffer_head *bh, *head; 2057 struct buffer_head *bh, *head;
@@ -2029,13 +2060,13 @@ int block_is_partially_uptodate(struct page *page, read_descriptor_t *desc,
2029 if (!page_has_buffers(page)) 2060 if (!page_has_buffers(page))
2030 return 0; 2061 return 0;
2031 2062
2032 blocksize = 1 << inode->i_blkbits; 2063 head = page_buffers(page);
2064 blocksize = head->b_size;
2033 to = min_t(unsigned, PAGE_CACHE_SIZE - from, desc->count); 2065 to = min_t(unsigned, PAGE_CACHE_SIZE - from, desc->count);
2034 to = from + to; 2066 to = from + to;
2035 if (from < blocksize && to > PAGE_CACHE_SIZE - blocksize) 2067 if (from < blocksize && to > PAGE_CACHE_SIZE - blocksize)
2036 return 0; 2068 return 0;
2037 2069
2038 head = page_buffers(page);
2039 bh = head; 2070 bh = head;
2040 block_start = 0; 2071 block_start = 0;
2041 do { 2072 do {
@@ -2068,18 +2099,16 @@ int block_read_full_page(struct page *page, get_block_t *get_block)
2068 struct inode *inode = page->mapping->host; 2099 struct inode *inode = page->mapping->host;
2069 sector_t iblock, lblock; 2100 sector_t iblock, lblock;
2070 struct buffer_head *bh, *head, *arr[MAX_BUF_PER_PAGE]; 2101 struct buffer_head *bh, *head, *arr[MAX_BUF_PER_PAGE];
2071 unsigned int blocksize; 2102 unsigned int blocksize, bbits;
2072 int nr, i; 2103 int nr, i;
2073 int fully_mapped = 1; 2104 int fully_mapped = 1;
2074 2105
2075 BUG_ON(!PageLocked(page)); 2106 head = create_page_buffers(page, inode, 0);
2076 blocksize = 1 << inode->i_blkbits; 2107 blocksize = head->b_size;
2077 if (!page_has_buffers(page)) 2108 bbits = block_size_bits(blocksize);
2078 create_empty_buffers(page, blocksize, 0);
2079 head = page_buffers(page);
2080 2109
2081 iblock = (sector_t)page->index << (PAGE_CACHE_SHIFT - inode->i_blkbits); 2110 iblock = (sector_t)page->index << (PAGE_CACHE_SHIFT - bbits);
2082 lblock = (i_size_read(inode)+blocksize-1) >> inode->i_blkbits; 2111 lblock = (i_size_read(inode)+blocksize-1) >> bbits;
2083 bh = head; 2112 bh = head;
2084 nr = 0; 2113 nr = 0;
2085 i = 0; 2114 i = 0;
@@ -2864,6 +2893,55 @@ static void end_bio_bh_io_sync(struct bio *bio, int err)
2864 bio_put(bio); 2893 bio_put(bio);
2865} 2894}
2866 2895
2896/*
2897 * This allows us to do IO even on the odd last sectors
2898 * of a device, even if the bh block size is some multiple
2899 * of the physical sector size.
2900 *
2901 * We'll just truncate the bio to the size of the device,
2902 * and clear the end of the buffer head manually.
2903 *
2904 * Truly out-of-range accesses will turn into actual IO
2905 * errors, this only handles the "we need to be able to
2906 * do IO at the final sector" case.
2907 */
2908static void guard_bh_eod(int rw, struct bio *bio, struct buffer_head *bh)
2909{
2910 sector_t maxsector;
2911 unsigned bytes;
2912
2913 maxsector = i_size_read(bio->bi_bdev->bd_inode) >> 9;
2914 if (!maxsector)
2915 return;
2916
2917 /*
2918 * If the *whole* IO is past the end of the device,
2919 * let it through, and the IO layer will turn it into
2920 * an EIO.
2921 */
2922 if (unlikely(bio->bi_sector >= maxsector))
2923 return;
2924
2925 maxsector -= bio->bi_sector;
2926 bytes = bio->bi_size;
2927 if (likely((bytes >> 9) <= maxsector))
2928 return;
2929
2930 /* Uhhuh. We've got a bh that straddles the device size! */
2931 bytes = maxsector << 9;
2932
2933 /* Truncate the bio.. */
2934 bio->bi_size = bytes;
2935 bio->bi_io_vec[0].bv_len = bytes;
2936
2937 /* ..and clear the end of the buffer for reads */
2938 if ((rw & RW_MASK) == READ) {
2939 void *kaddr = kmap_atomic(bh->b_page);
2940 memset(kaddr + bh_offset(bh) + bytes, 0, bh->b_size - bytes);
2941 kunmap_atomic(kaddr);
2942 }
2943}
2944
2867int submit_bh(int rw, struct buffer_head * bh) 2945int submit_bh(int rw, struct buffer_head * bh)
2868{ 2946{
2869 struct bio *bio; 2947 struct bio *bio;
@@ -2900,6 +2978,9 @@ int submit_bh(int rw, struct buffer_head * bh)
2900 bio->bi_end_io = end_bio_bh_io_sync; 2978 bio->bi_end_io = end_bio_bh_io_sync;
2901 bio->bi_private = bh; 2979 bio->bi_private = bh;
2902 2980
2981 /* Take care of bh's that straddle the end of the device */
2982 guard_bh_eod(rw, bio, bh);
2983
2903 bio_get(bio); 2984 bio_get(bio);
2904 submit_bio(rw, bio); 2985 submit_bio(rw, bio);
2905 2986
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index edb25b4bbb95..70b6f4c3a0c1 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -1794,7 +1794,6 @@ static int cifs_writepages(struct address_space *mapping,
1794 struct TCP_Server_Info *server; 1794 struct TCP_Server_Info *server;
1795 struct page *page; 1795 struct page *page;
1796 int rc = 0; 1796 int rc = 0;
1797 loff_t isize = i_size_read(mapping->host);
1798 1797
1799 /* 1798 /*
1800 * If wsize is smaller than the page cache size, default to writing 1799 * If wsize is smaller than the page cache size, default to writing
@@ -1899,7 +1898,7 @@ retry:
1899 */ 1898 */
1900 set_page_writeback(page); 1899 set_page_writeback(page);
1901 1900
1902 if (page_offset(page) >= isize) { 1901 if (page_offset(page) >= i_size_read(mapping->host)) {
1903 done = true; 1902 done = true;
1904 unlock_page(page); 1903 unlock_page(page);
1905 end_page_writeback(page); 1904 end_page_writeback(page);
@@ -1932,7 +1931,8 @@ retry:
1932 wdata->offset = page_offset(wdata->pages[0]); 1931 wdata->offset = page_offset(wdata->pages[0]);
1933 wdata->pagesz = PAGE_CACHE_SIZE; 1932 wdata->pagesz = PAGE_CACHE_SIZE;
1934 wdata->tailsz = 1933 wdata->tailsz =
1935 min(isize - page_offset(wdata->pages[nr_pages - 1]), 1934 min(i_size_read(mapping->host) -
1935 page_offset(wdata->pages[nr_pages - 1]),
1936 (loff_t)PAGE_CACHE_SIZE); 1936 (loff_t)PAGE_CACHE_SIZE);
1937 wdata->bytes = ((nr_pages - 1) * PAGE_CACHE_SIZE) + 1937 wdata->bytes = ((nr_pages - 1) * PAGE_CACHE_SIZE) +
1938 wdata->tailsz; 1938 wdata->tailsz;
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index f9b5d3d6cf33..1c576e871366 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -86,14 +86,17 @@ cifs_readdir_lookup(struct dentry *parent, struct qstr *name,
86 86
87 dentry = d_lookup(parent, name); 87 dentry = d_lookup(parent, name);
88 if (dentry) { 88 if (dentry) {
89 int err;
89 inode = dentry->d_inode; 90 inode = dentry->d_inode;
90 /* update inode in place if i_ino didn't change */ 91 /* update inode in place if i_ino didn't change */
91 if (inode && CIFS_I(inode)->uniqueid == fattr->cf_uniqueid) { 92 if (inode && CIFS_I(inode)->uniqueid == fattr->cf_uniqueid) {
92 cifs_fattr_to_inode(inode, fattr); 93 cifs_fattr_to_inode(inode, fattr);
93 return dentry; 94 return dentry;
94 } 95 }
95 d_drop(dentry); 96 err = d_invalidate(dentry);
96 dput(dentry); 97 dput(dentry);
98 if (err)
99 return NULL;
97 } 100 }
98 101
99 dentry = d_alloc(parent, name); 102 dentry = d_alloc(parent, name);
diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
index 56cc4be87807..34cea2798333 100644
--- a/fs/cifs/smb1ops.c
+++ b/fs/cifs/smb1ops.c
@@ -766,7 +766,6 @@ smb_set_file_info(struct inode *inode, const char *full_path,
766 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 766 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
767 struct tcon_link *tlink = NULL; 767 struct tcon_link *tlink = NULL;
768 struct cifs_tcon *tcon; 768 struct cifs_tcon *tcon;
769 FILE_BASIC_INFO info_buf;
770 769
771 /* if the file is already open for write, just use that fileid */ 770 /* if the file is already open for write, just use that fileid */
772 open_file = find_writable_file(cinode, true); 771 open_file = find_writable_file(cinode, true);
@@ -817,7 +816,7 @@ smb_set_file_info(struct inode *inode, const char *full_path,
817 netpid = current->tgid; 816 netpid = current->tgid;
818 817
819set_via_filehandle: 818set_via_filehandle:
820 rc = CIFSSMBSetFileInfo(xid, tcon, &info_buf, netfid, netpid); 819 rc = CIFSSMBSetFileInfo(xid, tcon, buf, netfid, netpid);
821 if (!rc) 820 if (!rc)
822 cinode->cifsAttrs = le32_to_cpu(buf->Attributes); 821 cinode->cifsAttrs = le32_to_cpu(buf->Attributes);
823 822
diff --git a/fs/direct-io.c b/fs/direct-io.c
index f86c720dba0e..cf5b44b10c67 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -540,6 +540,7 @@ static int get_more_blocks(struct dio *dio, struct dio_submit *sdio,
540 sector_t fs_endblk; /* Into file, in filesystem-sized blocks */ 540 sector_t fs_endblk; /* Into file, in filesystem-sized blocks */
541 unsigned long fs_count; /* Number of filesystem-sized blocks */ 541 unsigned long fs_count; /* Number of filesystem-sized blocks */
542 int create; 542 int create;
543 unsigned int i_blkbits = sdio->blkbits + sdio->blkfactor;
543 544
544 /* 545 /*
545 * If there was a memory error and we've overwritten all the 546 * If there was a memory error and we've overwritten all the
@@ -554,7 +555,7 @@ static int get_more_blocks(struct dio *dio, struct dio_submit *sdio,
554 fs_count = fs_endblk - fs_startblk + 1; 555 fs_count = fs_endblk - fs_startblk + 1;
555 556
556 map_bh->b_state = 0; 557 map_bh->b_state = 0;
557 map_bh->b_size = fs_count << dio->inode->i_blkbits; 558 map_bh->b_size = fs_count << i_blkbits;
558 559
559 /* 560 /*
560 * For writes inside i_size on a DIO_SKIP_HOLES filesystem we 561 * For writes inside i_size on a DIO_SKIP_HOLES filesystem we
@@ -1053,7 +1054,8 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
1053 int seg; 1054 int seg;
1054 size_t size; 1055 size_t size;
1055 unsigned long addr; 1056 unsigned long addr;
1056 unsigned blkbits = inode->i_blkbits; 1057 unsigned i_blkbits = ACCESS_ONCE(inode->i_blkbits);
1058 unsigned blkbits = i_blkbits;
1057 unsigned blocksize_mask = (1 << blkbits) - 1; 1059 unsigned blocksize_mask = (1 << blkbits) - 1;
1058 ssize_t retval = -EINVAL; 1060 ssize_t retval = -EINVAL;
1059 loff_t end = offset; 1061 loff_t end = offset;
@@ -1149,7 +1151,7 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
1149 dio->inode = inode; 1151 dio->inode = inode;
1150 dio->rw = rw; 1152 dio->rw = rw;
1151 sdio.blkbits = blkbits; 1153 sdio.blkbits = blkbits;
1152 sdio.blkfactor = inode->i_blkbits - blkbits; 1154 sdio.blkfactor = i_blkbits - blkbits;
1153 sdio.block_in_file = offset >> blkbits; 1155 sdio.block_in_file = offset >> blkbits;
1154 1156
1155 sdio.get_block = get_block; 1157 sdio.get_block = get_block;
diff --git a/fs/file.c b/fs/file.c
index 7cb71b992603..eff23162485f 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -994,16 +994,18 @@ int iterate_fd(struct files_struct *files, unsigned n,
994 const void *p) 994 const void *p)
995{ 995{
996 struct fdtable *fdt; 996 struct fdtable *fdt;
997 struct file *file;
998 int res = 0; 997 int res = 0;
999 if (!files) 998 if (!files)
1000 return 0; 999 return 0;
1001 spin_lock(&files->file_lock); 1000 spin_lock(&files->file_lock);
1002 fdt = files_fdtable(files); 1001 for (fdt = files_fdtable(files); n < fdt->max_fds; n++) {
1003 while (!res && n < fdt->max_fds) { 1002 struct file *file;
1004 file = rcu_dereference_check_fdtable(files, fdt->fd[n++]); 1003 file = rcu_dereference_check_fdtable(files, fdt->fd[n]);
1005 if (file) 1004 if (!file)
1006 res = f(p, file, n); 1005 continue;
1006 res = f(p, file, n);
1007 if (res)
1008 break;
1007 } 1009 }
1008 spin_unlock(&files->file_lock); 1010 spin_unlock(&files->file_lock);
1009 return res; 1011 return res;
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 51ea267d444c..3e3422f7f0a4 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -228,6 +228,8 @@ static void requeue_io(struct inode *inode, struct bdi_writeback *wb)
228static void inode_sync_complete(struct inode *inode) 228static void inode_sync_complete(struct inode *inode)
229{ 229{
230 inode->i_state &= ~I_SYNC; 230 inode->i_state &= ~I_SYNC;
231 /* If inode is clean an unused, put it into LRU now... */
232 inode_add_lru(inode);
231 /* Waiters must see I_SYNC cleared before being woken up */ 233 /* Waiters must see I_SYNC cleared before being woken up */
232 smp_mb(); 234 smp_mb();
233 wake_up_bit(&inode->i_state, __I_SYNC); 235 wake_up_bit(&inode->i_state, __I_SYNC);
diff --git a/fs/inode.c b/fs/inode.c
index b03c71957246..64999f144153 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -408,6 +408,19 @@ static void inode_lru_list_add(struct inode *inode)
408 spin_unlock(&inode->i_sb->s_inode_lru_lock); 408 spin_unlock(&inode->i_sb->s_inode_lru_lock);
409} 409}
410 410
411/*
412 * Add inode to LRU if needed (inode is unused and clean).
413 *
414 * Needs inode->i_lock held.
415 */
416void inode_add_lru(struct inode *inode)
417{
418 if (!(inode->i_state & (I_DIRTY | I_SYNC | I_FREEING | I_WILL_FREE)) &&
419 !atomic_read(&inode->i_count) && inode->i_sb->s_flags & MS_ACTIVE)
420 inode_lru_list_add(inode);
421}
422
423
411static void inode_lru_list_del(struct inode *inode) 424static void inode_lru_list_del(struct inode *inode)
412{ 425{
413 spin_lock(&inode->i_sb->s_inode_lru_lock); 426 spin_lock(&inode->i_sb->s_inode_lru_lock);
@@ -1390,8 +1403,7 @@ static void iput_final(struct inode *inode)
1390 1403
1391 if (!drop && (sb->s_flags & MS_ACTIVE)) { 1404 if (!drop && (sb->s_flags & MS_ACTIVE)) {
1392 inode->i_state |= I_REFERENCED; 1405 inode->i_state |= I_REFERENCED;
1393 if (!(inode->i_state & (I_DIRTY|I_SYNC))) 1406 inode_add_lru(inode);
1394 inode_lru_list_add(inode);
1395 spin_unlock(&inode->i_lock); 1407 spin_unlock(&inode->i_lock);
1396 return; 1408 return;
1397 } 1409 }
diff --git a/fs/internal.h b/fs/internal.h
index 916b7cbf3e3e..2f6af7f645eb 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -110,6 +110,7 @@ extern int open_check_o_direct(struct file *f);
110 * inode.c 110 * inode.c
111 */ 111 */
112extern spinlock_t inode_sb_list_lock; 112extern spinlock_t inode_sb_list_lock;
113extern void inode_add_lru(struct inode *inode);
113 114
114/* 115/*
115 * fs-writeback.c 116 * fs-writeback.c
diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c
index 78b7f84241d4..7f5120bf0ec2 100644
--- a/fs/jbd/transaction.c
+++ b/fs/jbd/transaction.c
@@ -1961,7 +1961,9 @@ retry:
1961 spin_unlock(&journal->j_list_lock); 1961 spin_unlock(&journal->j_list_lock);
1962 jbd_unlock_bh_state(bh); 1962 jbd_unlock_bh_state(bh);
1963 spin_unlock(&journal->j_state_lock); 1963 spin_unlock(&journal->j_state_lock);
1964 unlock_buffer(bh);
1964 log_wait_commit(journal, tid); 1965 log_wait_commit(journal, tid);
1966 lock_buffer(bh);
1965 goto retry; 1967 goto retry;
1966 } 1968 }
1967 /* 1969 /*
diff --git a/fs/namei.c b/fs/namei.c
index 937f9d50c84b..5f4cdf3ad913 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2131,6 +2131,11 @@ struct dentry *lookup_one_len(const char *name, struct dentry *base, int len)
2131 if (!len) 2131 if (!len)
2132 return ERR_PTR(-EACCES); 2132 return ERR_PTR(-EACCES);
2133 2133
2134 if (unlikely(name[0] == '.')) {
2135 if (len < 2 || (len == 2 && name[1] == '.'))
2136 return ERR_PTR(-EACCES);
2137 }
2138
2134 while (len--) { 2139 while (len--) {
2135 c = *(const unsigned char *)name++; 2140 c = *(const unsigned char *)name++;
2136 if (c == '/' || c == '\0') 2141 if (c == '/' || c == '\0')
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index ce8cb926526b..b9e66b7e0c14 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -450,7 +450,8 @@ void nfs_prime_dcache(struct dentry *parent, struct nfs_entry *entry)
450 nfs_refresh_inode(dentry->d_inode, entry->fattr); 450 nfs_refresh_inode(dentry->d_inode, entry->fattr);
451 goto out; 451 goto out;
452 } else { 452 } else {
453 d_drop(dentry); 453 if (d_invalidate(dentry) != 0)
454 goto out;
454 dput(dentry); 455 dput(dentry);
455 } 456 }
456 } 457 }
@@ -1100,6 +1101,8 @@ out_set_verifier:
1100out_zap_parent: 1101out_zap_parent:
1101 nfs_zap_caches(dir); 1102 nfs_zap_caches(dir);
1102 out_bad: 1103 out_bad:
1104 nfs_free_fattr(fattr);
1105 nfs_free_fhandle(fhandle);
1103 nfs_mark_for_revalidate(dir); 1106 nfs_mark_for_revalidate(dir);
1104 if (inode && S_ISDIR(inode->i_mode)) { 1107 if (inode && S_ISDIR(inode->i_mode)) {
1105 /* Purge readdir caches. */ 1108 /* Purge readdir caches. */
@@ -1112,8 +1115,6 @@ out_zap_parent:
1112 shrink_dcache_parent(dentry); 1115 shrink_dcache_parent(dentry);
1113 } 1116 }
1114 d_drop(dentry); 1117 d_drop(dentry);
1115 nfs_free_fattr(fattr);
1116 nfs_free_fhandle(fhandle);
1117 dput(parent); 1118 dput(parent);
1118 dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is invalid\n", 1119 dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is invalid\n",
1119 __func__, dentry->d_parent->d_name.name, 1120 __func__, dentry->d_parent->d_name.name,
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 3c231adf8450..9e28356a959a 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1877,8 +1877,9 @@ static struct dentry *proc_map_files_lookup(struct inode *dir,
1877 if (!vma) 1877 if (!vma)
1878 goto out_no_vma; 1878 goto out_no_vma;
1879 1879
1880 result = proc_map_files_instantiate(dir, dentry, task, 1880 if (vma->vm_file)
1881 (void *)(unsigned long)vma->vm_file->f_mode); 1881 result = proc_map_files_instantiate(dir, dentry, task,
1882 (void *)(unsigned long)vma->vm_file->f_mode);
1882 1883
1883out_no_vma: 1884out_no_vma:
1884 up_read(&mm->mmap_sem); 1885 up_read(&mm->mmap_sem);
diff --git a/include/linux/bug.h b/include/linux/bug.h
index aaac4bba6f5c..b1cf40de847e 100644
--- a/include/linux/bug.h
+++ b/include/linux/bug.h
@@ -15,6 +15,7 @@ struct pt_regs;
15#define BUILD_BUG_ON_NOT_POWER_OF_2(n) 15#define BUILD_BUG_ON_NOT_POWER_OF_2(n)
16#define BUILD_BUG_ON_ZERO(e) (0) 16#define BUILD_BUG_ON_ZERO(e) (0)
17#define BUILD_BUG_ON_NULL(e) ((void*)0) 17#define BUILD_BUG_ON_NULL(e) ((void*)0)
18#define BUILD_BUG_ON_INVALID(e) (0)
18#define BUILD_BUG_ON(condition) 19#define BUILD_BUG_ON(condition)
19#define BUILD_BUG() (0) 20#define BUILD_BUG() (0)
20#else /* __CHECKER__ */ 21#else /* __CHECKER__ */
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b33cfc97b9ca..75fe9a134803 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -462,8 +462,6 @@ struct block_device {
462 int bd_fsfreeze_count; 462 int bd_fsfreeze_count;
463 /* Mutex for freeze */ 463 /* Mutex for freeze */
464 struct mutex bd_fsfreeze_mutex; 464 struct mutex bd_fsfreeze_mutex;
465 /* A semaphore that prevents I/O while block size is being changed */
466 struct percpu_rw_semaphore bd_block_size_semaphore;
467}; 465};
468 466
469/* 467/*
@@ -2049,7 +2047,6 @@ extern void unregister_blkdev(unsigned int, const char *);
2049extern struct block_device *bdget(dev_t); 2047extern struct block_device *bdget(dev_t);
2050extern struct block_device *bdgrab(struct block_device *bdev); 2048extern struct block_device *bdgrab(struct block_device *bdev);
2051extern void bd_set_size(struct block_device *, loff_t size); 2049extern void bd_set_size(struct block_device *, loff_t size);
2052extern sector_t blkdev_max_block(struct block_device *bdev);
2053extern void bd_forget(struct inode *inode); 2050extern void bd_forget(struct inode *inode);
2054extern void bdput(struct block_device *); 2051extern void bdput(struct block_device *);
2055extern void invalidate_bdev(struct block_device *); 2052extern void invalidate_bdev(struct block_device *);
@@ -2379,8 +2376,6 @@ extern int generic_segment_checks(const struct iovec *iov,
2379 unsigned long *nr_segs, size_t *count, int access_flags); 2376 unsigned long *nr_segs, size_t *count, int access_flags);
2380 2377
2381/* fs/block_dev.c */ 2378/* fs/block_dev.c */
2382extern ssize_t blkdev_aio_read(struct kiocb *iocb, const struct iovec *iov,
2383 unsigned long nr_segs, loff_t pos);
2384extern ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov, 2379extern ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov,
2385 unsigned long nr_segs, loff_t pos); 2380 unsigned long nr_segs, loff_t pos);
2386extern int blkdev_fsync(struct file *filp, loff_t start, loff_t end, 2381extern int blkdev_fsync(struct file *filp, loff_t start, loff_t end,
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 02c1c9710be0..d0a79678f169 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -31,6 +31,7 @@ struct vm_area_struct;
31#define ___GFP_THISNODE 0x40000u 31#define ___GFP_THISNODE 0x40000u
32#define ___GFP_RECLAIMABLE 0x80000u 32#define ___GFP_RECLAIMABLE 0x80000u
33#define ___GFP_NOTRACK 0x200000u 33#define ___GFP_NOTRACK 0x200000u
34#define ___GFP_NO_KSWAPD 0x400000u
34#define ___GFP_OTHER_NODE 0x800000u 35#define ___GFP_OTHER_NODE 0x800000u
35#define ___GFP_WRITE 0x1000000u 36#define ___GFP_WRITE 0x1000000u
36 37
@@ -85,6 +86,7 @@ struct vm_area_struct;
85#define __GFP_RECLAIMABLE ((__force gfp_t)___GFP_RECLAIMABLE) /* Page is reclaimable */ 86#define __GFP_RECLAIMABLE ((__force gfp_t)___GFP_RECLAIMABLE) /* Page is reclaimable */
86#define __GFP_NOTRACK ((__force gfp_t)___GFP_NOTRACK) /* Don't track with kmemcheck */ 87#define __GFP_NOTRACK ((__force gfp_t)___GFP_NOTRACK) /* Don't track with kmemcheck */
87 88
89#define __GFP_NO_KSWAPD ((__force gfp_t)___GFP_NO_KSWAPD)
88#define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */ 90#define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
89#define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */ 91#define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
90 92
@@ -114,7 +116,8 @@ struct vm_area_struct;
114 __GFP_MOVABLE) 116 __GFP_MOVABLE)
115#define GFP_IOFS (__GFP_IO | __GFP_FS) 117#define GFP_IOFS (__GFP_IO | __GFP_FS)
116#define GFP_TRANSHUGE (GFP_HIGHUSER_MOVABLE | __GFP_COMP | \ 118#define GFP_TRANSHUGE (GFP_HIGHUSER_MOVABLE | __GFP_COMP | \
117 __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_NOWARN) 119 __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_NOWARN | \
120 __GFP_NO_KSWAPD)
118 121
119#ifdef CONFIG_NUMA 122#ifdef CONFIG_NUMA
120#define GFP_THISNODE (__GFP_THISNODE | __GFP_NOWARN | __GFP_NORETRY) 123#define GFP_THISNODE (__GFP_THISNODE | __GFP_NOWARN | __GFP_NORETRY)
diff --git a/include/linux/hw_breakpoint.h b/include/linux/hw_breakpoint.h
index 6ae9c631a1be..0464c85e63fd 100644
--- a/include/linux/hw_breakpoint.h
+++ b/include/linux/hw_breakpoint.h
@@ -1,35 +1,8 @@
1#ifndef _LINUX_HW_BREAKPOINT_H 1#ifndef _LINUX_HW_BREAKPOINT_H
2#define _LINUX_HW_BREAKPOINT_H 2#define _LINUX_HW_BREAKPOINT_H
3 3
4enum {
5 HW_BREAKPOINT_LEN_1 = 1,
6 HW_BREAKPOINT_LEN_2 = 2,
7 HW_BREAKPOINT_LEN_4 = 4,
8 HW_BREAKPOINT_LEN_8 = 8,
9};
10
11enum {
12 HW_BREAKPOINT_EMPTY = 0,
13 HW_BREAKPOINT_R = 1,
14 HW_BREAKPOINT_W = 2,
15 HW_BREAKPOINT_RW = HW_BREAKPOINT_R | HW_BREAKPOINT_W,
16 HW_BREAKPOINT_X = 4,
17 HW_BREAKPOINT_INVALID = HW_BREAKPOINT_RW | HW_BREAKPOINT_X,
18};
19
20enum bp_type_idx {
21 TYPE_INST = 0,
22#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
23 TYPE_DATA = 0,
24#else
25 TYPE_DATA = 1,
26#endif
27 TYPE_MAX
28};
29
30#ifdef __KERNEL__
31
32#include <linux/perf_event.h> 4#include <linux/perf_event.h>
5#include <uapi/linux/hw_breakpoint.h>
33 6
34#ifdef CONFIG_HAVE_HW_BREAKPOINT 7#ifdef CONFIG_HAVE_HW_BREAKPOINT
35 8
@@ -151,6 +124,4 @@ static inline struct arch_hw_breakpoint *counter_arch_bp(struct perf_event *bp)
151} 124}
152 125
153#endif /* CONFIG_HAVE_HW_BREAKPOINT */ 126#endif /* CONFIG_HAVE_HW_BREAKPOINT */
154#endif /* __KERNEL__ */
155
156#endif /* _LINUX_HW_BREAKPOINT_H */ 127#endif /* _LINUX_HW_BREAKPOINT_H */
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index a123b13b70fd..7d8dfc7392f1 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -701,6 +701,13 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
701#define COMPACTION_BUILD 0 701#define COMPACTION_BUILD 0
702#endif 702#endif
703 703
704/* This helps us to avoid #ifdef CONFIG_SYMBOL_PREFIX */
705#ifdef CONFIG_SYMBOL_PREFIX
706#define SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX
707#else
708#define SYMBOL_PREFIX ""
709#endif
710
704/* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ 711/* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */
705#ifdef CONFIG_FTRACE_MCOUNT_RECORD 712#ifdef CONFIG_FTRACE_MCOUNT_RECORD
706# define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD 713# define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD
diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
index e5ccb9ddd90e..dbd212723b74 100644
--- a/include/linux/mempolicy.h
+++ b/include/linux/mempolicy.h
@@ -82,16 +82,6 @@ static inline void mpol_cond_put(struct mempolicy *pol)
82 __mpol_put(pol); 82 __mpol_put(pol);
83} 83}
84 84
85extern struct mempolicy *__mpol_cond_copy(struct mempolicy *tompol,
86 struct mempolicy *frompol);
87static inline struct mempolicy *mpol_cond_copy(struct mempolicy *tompol,
88 struct mempolicy *frompol)
89{
90 if (!frompol)
91 return frompol;
92 return __mpol_cond_copy(tompol, frompol);
93}
94
95extern struct mempolicy *__mpol_dup(struct mempolicy *pol); 85extern struct mempolicy *__mpol_dup(struct mempolicy *pol);
96static inline struct mempolicy *mpol_dup(struct mempolicy *pol) 86static inline struct mempolicy *mpol_dup(struct mempolicy *pol)
97{ 87{
@@ -215,12 +205,6 @@ static inline void mpol_cond_put(struct mempolicy *pol)
215{ 205{
216} 206}
217 207
218static inline struct mempolicy *mpol_cond_copy(struct mempolicy *to,
219 struct mempolicy *from)
220{
221 return from;
222}
223
224static inline void mpol_get(struct mempolicy *pol) 208static inline void mpol_get(struct mempolicy *pol)
225{ 209{
226} 210}
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index f8eda0276f03..a848ffc327f4 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1488,6 +1488,9 @@ struct napi_gro_cb {
1488 1488
1489 /* Used in ipv6_gro_receive() */ 1489 /* Used in ipv6_gro_receive() */
1490 int proto; 1490 int proto;
1491
1492 /* used in skb_gro_receive() slow path */
1493 struct sk_buff *last;
1491}; 1494};
1492 1495
1493#define NAPI_GRO_CB(skb) ((struct napi_gro_cb *)(skb)->cb) 1496#define NAPI_GRO_CB(skb) ((struct napi_gro_cb *)(skb)->cb)
diff --git a/include/linux/percpu-rwsem.h b/include/linux/percpu-rwsem.h
index 250a4acddb2b..bd1e86071e57 100644
--- a/include/linux/percpu-rwsem.h
+++ b/include/linux/percpu-rwsem.h
@@ -13,7 +13,7 @@ struct percpu_rw_semaphore {
13}; 13};
14 14
15#define light_mb() barrier() 15#define light_mb() barrier()
16#define heavy_mb() synchronize_sched() 16#define heavy_mb() synchronize_sched_expedited()
17 17
18static inline void percpu_down_read(struct percpu_rw_semaphore *p) 18static inline void percpu_down_read(struct percpu_rw_semaphore *p)
19{ 19{
@@ -51,7 +51,7 @@ static inline void percpu_down_write(struct percpu_rw_semaphore *p)
51{ 51{
52 mutex_lock(&p->mtx); 52 mutex_lock(&p->mtx);
53 p->locked = true; 53 p->locked = true;
54 synchronize_sched(); /* make sure that all readers exit the rcu_read_lock_sched region */ 54 synchronize_sched_expedited(); /* make sure that all readers exit the rcu_read_lock_sched region */
55 while (__percpu_count(p->counters)) 55 while (__percpu_count(p->counters))
56 msleep(1); 56 msleep(1);
57 heavy_mb(); /* C, between read of p->counter and write to data, paired with B */ 57 heavy_mb(); /* C, between read of p->counter and write to data, paired with B */
diff --git a/include/media/adv7604.h b/include/media/adv7604.h
index 171b957db743..dc004bc926c9 100644
--- a/include/media/adv7604.h
+++ b/include/media/adv7604.h
@@ -40,14 +40,6 @@ enum adv7604_op_ch_sel {
40 ADV7604_OP_CH_SEL_RBG = 5, 40 ADV7604_OP_CH_SEL_RBG = 5,
41}; 41};
42 42
43/* Primary mode (IO register 0x01, [3:0]) */
44enum adv7604_prim_mode {
45 ADV7604_PRIM_MODE_COMP = 1,
46 ADV7604_PRIM_MODE_RGB = 2,
47 ADV7604_PRIM_MODE_HDMI_COMP = 5,
48 ADV7604_PRIM_MODE_HDMI_GR = 6,
49};
50
51/* Input Color Space (IO register 0x02, [7:4]) */ 43/* Input Color Space (IO register 0x02, [7:4]) */
52enum adv7604_inp_color_space { 44enum adv7604_inp_color_space {
53 ADV7604_INP_COLOR_SPACE_LIM_RGB = 0, 45 ADV7604_INP_COLOR_SPACE_LIM_RGB = 0,
@@ -103,9 +95,6 @@ struct adv7604_platform_data {
103 /* Bus rotation and reordering */ 95 /* Bus rotation and reordering */
104 enum adv7604_op_ch_sel op_ch_sel; 96 enum adv7604_op_ch_sel op_ch_sel;
105 97
106 /* Primary mode */
107 enum adv7604_prim_mode prim_mode;
108
109 /* Select output format */ 98 /* Select output format */
110 enum adv7604_op_format_sel op_format_sel; 99 enum adv7604_op_format_sel op_format_sel;
111 100
@@ -142,6 +131,16 @@ struct adv7604_platform_data {
142 u8 i2c_vdp; 131 u8 i2c_vdp;
143}; 132};
144 133
134/*
135 * Mode of operation.
136 * This is used as the input argument of the s_routing video op.
137 */
138enum adv7604_mode {
139 ADV7604_MODE_COMP,
140 ADV7604_MODE_GR,
141 ADV7604_MODE_HDMI,
142};
143
145#define V4L2_CID_ADV_RX_ANALOG_SAMPLING_PHASE (V4L2_CID_DV_CLASS_BASE + 0x1000) 144#define V4L2_CID_ADV_RX_ANALOG_SAMPLING_PHASE (V4L2_CID_DV_CLASS_BASE + 0x1000)
146#define V4L2_CID_ADV_RX_FREE_RUN_COLOR_MANUAL (V4L2_CID_DV_CLASS_BASE + 0x1001) 145#define V4L2_CID_ADV_RX_FREE_RUN_COLOR_MANUAL (V4L2_CID_DV_CLASS_BASE + 0x1001)
147#define V4L2_CID_ADV_RX_FREE_RUN_COLOR (V4L2_CID_DV_CLASS_BASE + 0x1002) 146#define V4L2_CID_ADV_RX_FREE_RUN_COLOR (V4L2_CID_DV_CLASS_BASE + 0x1002)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 6feeccd83dd7..4af45e33105d 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -525,6 +525,7 @@ static inline __u32 cookie_v6_init_sequence(struct sock *sk,
525extern void __tcp_push_pending_frames(struct sock *sk, unsigned int cur_mss, 525extern void __tcp_push_pending_frames(struct sock *sk, unsigned int cur_mss,
526 int nonagle); 526 int nonagle);
527extern bool tcp_may_send_now(struct sock *sk); 527extern bool tcp_may_send_now(struct sock *sk);
528extern int __tcp_retransmit_skb(struct sock *, struct sk_buff *);
528extern int tcp_retransmit_skb(struct sock *, struct sk_buff *); 529extern int tcp_retransmit_skb(struct sock *, struct sk_buff *);
529extern void tcp_retransmit_timer(struct sock *sk); 530extern void tcp_retransmit_timer(struct sock *sk);
530extern void tcp_xmit_retransmit_queue(struct sock *); 531extern void tcp_xmit_retransmit_queue(struct sock *);
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 628db7bca4fd..3953cea0ecfb 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -242,7 +242,6 @@ struct snd_soc_dai {
242 unsigned int symmetric_rates:1; 242 unsigned int symmetric_rates:1;
243 struct snd_pcm_runtime *runtime; 243 struct snd_pcm_runtime *runtime;
244 unsigned int active; 244 unsigned int active;
245 unsigned char pop_wait:1;
246 unsigned char probed:1; 245 unsigned char probed:1;
247 246
248 struct snd_soc_dapm_widget *playback_widget; 247 struct snd_soc_dapm_widget *playback_widget;
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 91244a096c19..769e27c774a3 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1039,6 +1039,7 @@ struct snd_soc_pcm_runtime {
1039 struct snd_soc_dpcm_runtime dpcm[2]; 1039 struct snd_soc_dpcm_runtime dpcm[2];
1040 1040
1041 long pmdown_time; 1041 long pmdown_time;
1042 unsigned char pop_wait:1;
1042 1043
1043 /* runtime devices */ 1044 /* runtime devices */
1044 struct snd_pcm *pcm; 1045 struct snd_pcm *pcm;
diff --git a/include/trace/events/gfpflags.h b/include/trace/events/gfpflags.h
index 9391706e9254..d6fd8e5b14b7 100644
--- a/include/trace/events/gfpflags.h
+++ b/include/trace/events/gfpflags.h
@@ -36,6 +36,7 @@
36 {(unsigned long)__GFP_RECLAIMABLE, "GFP_RECLAIMABLE"}, \ 36 {(unsigned long)__GFP_RECLAIMABLE, "GFP_RECLAIMABLE"}, \
37 {(unsigned long)__GFP_MOVABLE, "GFP_MOVABLE"}, \ 37 {(unsigned long)__GFP_MOVABLE, "GFP_MOVABLE"}, \
38 {(unsigned long)__GFP_NOTRACK, "GFP_NOTRACK"}, \ 38 {(unsigned long)__GFP_NOTRACK, "GFP_NOTRACK"}, \
39 {(unsigned long)__GFP_NO_KSWAPD, "GFP_NO_KSWAPD"}, \
39 {(unsigned long)__GFP_OTHER_NODE, "GFP_OTHER_NODE"} \ 40 {(unsigned long)__GFP_OTHER_NODE, "GFP_OTHER_NODE"} \
40 ) : "GFP_NOWAIT" 41 ) : "GFP_NOWAIT"
41 42
diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index e194387ef784..19e765fbfef7 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -415,3 +415,4 @@ header-y += wireless.h
415header-y += x25.h 415header-y += x25.h
416header-y += xattr.h 416header-y += xattr.h
417header-y += xfrm.h 417header-y += xfrm.h
418header-y += hw_breakpoint.h
diff --git a/include/uapi/linux/hw_breakpoint.h b/include/uapi/linux/hw_breakpoint.h
new file mode 100644
index 000000000000..b04000a2296a
--- /dev/null
+++ b/include/uapi/linux/hw_breakpoint.h
@@ -0,0 +1,30 @@
1#ifndef _UAPI_LINUX_HW_BREAKPOINT_H
2#define _UAPI_LINUX_HW_BREAKPOINT_H
3
4enum {
5 HW_BREAKPOINT_LEN_1 = 1,
6 HW_BREAKPOINT_LEN_2 = 2,
7 HW_BREAKPOINT_LEN_4 = 4,
8 HW_BREAKPOINT_LEN_8 = 8,
9};
10
11enum {
12 HW_BREAKPOINT_EMPTY = 0,
13 HW_BREAKPOINT_R = 1,
14 HW_BREAKPOINT_W = 2,
15 HW_BREAKPOINT_RW = HW_BREAKPOINT_R | HW_BREAKPOINT_W,
16 HW_BREAKPOINT_X = 4,
17 HW_BREAKPOINT_INVALID = HW_BREAKPOINT_RW | HW_BREAKPOINT_X,
18};
19
20enum bp_type_idx {
21 TYPE_INST = 0,
22#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
23 TYPE_DATA = 0,
24#else
25 TYPE_DATA = 1,
26#endif
27 TYPE_MAX
28};
29
30#endif /* _UAPI_LINUX_HW_BREAKPOINT_H */
diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c
index 9a7b487c6fe2..fe8a916507ed 100644
--- a/kernel/events/hw_breakpoint.c
+++ b/kernel/events/hw_breakpoint.c
@@ -111,14 +111,16 @@ static unsigned int max_task_bp_pinned(int cpu, enum bp_type_idx type)
111 * Count the number of breakpoints of the same type and same task. 111 * Count the number of breakpoints of the same type and same task.
112 * The given event must be not on the list. 112 * The given event must be not on the list.
113 */ 113 */
114static int task_bp_pinned(struct perf_event *bp, enum bp_type_idx type) 114static int task_bp_pinned(int cpu, struct perf_event *bp, enum bp_type_idx type)
115{ 115{
116 struct task_struct *tsk = bp->hw.bp_target; 116 struct task_struct *tsk = bp->hw.bp_target;
117 struct perf_event *iter; 117 struct perf_event *iter;
118 int count = 0; 118 int count = 0;
119 119
120 list_for_each_entry(iter, &bp_task_head, hw.bp_list) { 120 list_for_each_entry(iter, &bp_task_head, hw.bp_list) {
121 if (iter->hw.bp_target == tsk && find_slot_idx(iter) == type) 121 if (iter->hw.bp_target == tsk &&
122 find_slot_idx(iter) == type &&
123 cpu == iter->cpu)
122 count += hw_breakpoint_weight(iter); 124 count += hw_breakpoint_weight(iter);
123 } 125 }
124 126
@@ -141,7 +143,7 @@ fetch_bp_busy_slots(struct bp_busy_slots *slots, struct perf_event *bp,
141 if (!tsk) 143 if (!tsk)
142 slots->pinned += max_task_bp_pinned(cpu, type); 144 slots->pinned += max_task_bp_pinned(cpu, type);
143 else 145 else
144 slots->pinned += task_bp_pinned(bp, type); 146 slots->pinned += task_bp_pinned(cpu, bp, type);
145 slots->flexible = per_cpu(nr_bp_flexible[type], cpu); 147 slots->flexible = per_cpu(nr_bp_flexible[type], cpu);
146 148
147 return; 149 return;
@@ -154,7 +156,7 @@ fetch_bp_busy_slots(struct bp_busy_slots *slots, struct perf_event *bp,
154 if (!tsk) 156 if (!tsk)
155 nr += max_task_bp_pinned(cpu, type); 157 nr += max_task_bp_pinned(cpu, type);
156 else 158 else
157 nr += task_bp_pinned(bp, type); 159 nr += task_bp_pinned(cpu, bp, type);
158 160
159 if (nr > slots->pinned) 161 if (nr > slots->pinned)
160 slots->pinned = nr; 162 slots->pinned = nr;
@@ -188,7 +190,7 @@ static void toggle_bp_task_slot(struct perf_event *bp, int cpu, bool enable,
188 int old_idx = 0; 190 int old_idx = 0;
189 int idx = 0; 191 int idx = 0;
190 192
191 old_count = task_bp_pinned(bp, type); 193 old_count = task_bp_pinned(cpu, bp, type);
192 old_idx = old_count - 1; 194 old_idx = old_count - 1;
193 idx = old_idx + weight; 195 idx = old_idx + weight;
194 196
diff --git a/kernel/futex.c b/kernel/futex.c
index 20ef219bbe9b..19eb089ca003 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -843,6 +843,9 @@ static void wake_futex(struct futex_q *q)
843{ 843{
844 struct task_struct *p = q->task; 844 struct task_struct *p = q->task;
845 845
846 if (WARN(q->pi_state || q->rt_waiter, "refusing to wake PI futex\n"))
847 return;
848
846 /* 849 /*
847 * We set q->lock_ptr = NULL _before_ we wake up the task. If 850 * We set q->lock_ptr = NULL _before_ we wake up the task. If
848 * a non-futex wake up happens on another CPU then the task 851 * a non-futex wake up happens on another CPU then the task
@@ -1078,6 +1081,10 @@ retry_private:
1078 1081
1079 plist_for_each_entry_safe(this, next, head, list) { 1082 plist_for_each_entry_safe(this, next, head, list) {
1080 if (match_futex (&this->key, &key1)) { 1083 if (match_futex (&this->key, &key1)) {
1084 if (this->pi_state || this->rt_waiter) {
1085 ret = -EINVAL;
1086 goto out_unlock;
1087 }
1081 wake_futex(this); 1088 wake_futex(this);
1082 if (++ret >= nr_wake) 1089 if (++ret >= nr_wake)
1083 break; 1090 break;
@@ -1090,6 +1097,10 @@ retry_private:
1090 op_ret = 0; 1097 op_ret = 0;
1091 plist_for_each_entry_safe(this, next, head, list) { 1098 plist_for_each_entry_safe(this, next, head, list) {
1092 if (match_futex (&this->key, &key2)) { 1099 if (match_futex (&this->key, &key2)) {
1100 if (this->pi_state || this->rt_waiter) {
1101 ret = -EINVAL;
1102 goto out_unlock;
1103 }
1093 wake_futex(this); 1104 wake_futex(this);
1094 if (++op_ret >= nr_wake2) 1105 if (++op_ret >= nr_wake2)
1095 break; 1106 break;
@@ -1098,6 +1109,7 @@ retry_private:
1098 ret += op_ret; 1109 ret += op_ret;
1099 } 1110 }
1100 1111
1112out_unlock:
1101 double_unlock_hb(hb1, hb2); 1113 double_unlock_hb(hb1, hb2);
1102out_put_keys: 1114out_put_keys:
1103 put_futex_key(&key2); 1115 put_futex_key(&key2);
@@ -1387,9 +1399,13 @@ retry_private:
1387 /* 1399 /*
1388 * FUTEX_WAIT_REQEUE_PI and FUTEX_CMP_REQUEUE_PI should always 1400 * FUTEX_WAIT_REQEUE_PI and FUTEX_CMP_REQUEUE_PI should always
1389 * be paired with each other and no other futex ops. 1401 * be paired with each other and no other futex ops.
1402 *
1403 * We should never be requeueing a futex_q with a pi_state,
1404 * which is awaiting a futex_unlock_pi().
1390 */ 1405 */
1391 if ((requeue_pi && !this->rt_waiter) || 1406 if ((requeue_pi && !this->rt_waiter) ||
1392 (!requeue_pi && this->rt_waiter)) { 1407 (!requeue_pi && this->rt_waiter) ||
1408 this->pi_state) {
1393 ret = -EINVAL; 1409 ret = -EINVAL;
1394 break; 1410 break;
1395 } 1411 }
diff --git a/kernel/modsign_pubkey.c b/kernel/modsign_pubkey.c
index 4646eb2c3820..767e559dfb10 100644
--- a/kernel/modsign_pubkey.c
+++ b/kernel/modsign_pubkey.c
@@ -21,10 +21,10 @@ struct key *modsign_keyring;
21extern __initdata const u8 modsign_certificate_list[]; 21extern __initdata const u8 modsign_certificate_list[];
22extern __initdata const u8 modsign_certificate_list_end[]; 22extern __initdata const u8 modsign_certificate_list_end[];
23asm(".section .init.data,\"aw\"\n" 23asm(".section .init.data,\"aw\"\n"
24 "modsign_certificate_list:\n" 24 SYMBOL_PREFIX "modsign_certificate_list:\n"
25 ".incbin \"signing_key.x509\"\n" 25 ".incbin \"signing_key.x509\"\n"
26 ".incbin \"extra_certificates\"\n" 26 ".incbin \"extra_certificates\"\n"
27 "modsign_certificate_list_end:" 27 SYMBOL_PREFIX "modsign_certificate_list_end:"
28 ); 28 );
29 29
30/* 30/*
diff --git a/kernel/module_signing.c b/kernel/module_signing.c
index ea1b1df5dbb0..f2970bddc5ea 100644
--- a/kernel/module_signing.c
+++ b/kernel/module_signing.c
@@ -27,13 +27,13 @@
27 * - Information block 27 * - Information block
28 */ 28 */
29struct module_signature { 29struct module_signature {
30 enum pkey_algo algo : 8; /* Public-key crypto algorithm */ 30 u8 algo; /* Public-key crypto algorithm [enum pkey_algo] */
31 enum pkey_hash_algo hash : 8; /* Digest algorithm */ 31 u8 hash; /* Digest algorithm [enum pkey_hash_algo] */
32 enum pkey_id_type id_type : 8; /* Key identifier type */ 32 u8 id_type; /* Key identifier type [enum pkey_id_type] */
33 u8 signer_len; /* Length of signer's name */ 33 u8 signer_len; /* Length of signer's name */
34 u8 key_id_len; /* Length of key identifier */ 34 u8 key_id_len; /* Length of key identifier */
35 u8 __pad[3]; 35 u8 __pad[3];
36 __be32 sig_len; /* Length of signature data */ 36 __be32 sig_len; /* Length of signature data */
37}; 37};
38 38
39/* 39/*
diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
index 0984a21076a3..15f60d01198b 100644
--- a/kernel/sched/auto_group.c
+++ b/kernel/sched/auto_group.c
@@ -143,15 +143,11 @@ autogroup_move_group(struct task_struct *p, struct autogroup *ag)
143 143
144 p->signal->autogroup = autogroup_kref_get(ag); 144 p->signal->autogroup = autogroup_kref_get(ag);
145 145
146 if (!ACCESS_ONCE(sysctl_sched_autogroup_enabled))
147 goto out;
148
149 t = p; 146 t = p;
150 do { 147 do {
151 sched_move_task(t); 148 sched_move_task(t);
152 } while_each_thread(p, t); 149 } while_each_thread(p, t);
153 150
154out:
155 unlock_task_sighand(p, &flags); 151 unlock_task_sighand(p, &flags);
156 autogroup_kref_put(prev); 152 autogroup_kref_put(prev);
157} 153}
diff --git a/kernel/sched/auto_group.h b/kernel/sched/auto_group.h
index 8bd047142816..443232ebbb53 100644
--- a/kernel/sched/auto_group.h
+++ b/kernel/sched/auto_group.h
@@ -4,11 +4,6 @@
4#include <linux/rwsem.h> 4#include <linux/rwsem.h>
5 5
6struct autogroup { 6struct autogroup {
7 /*
8 * reference doesn't mean how many thread attach to this
9 * autogroup now. It just stands for the number of task
10 * could use this autogroup.
11 */
12 struct kref kref; 7 struct kref kref;
13 struct task_group *tg; 8 struct task_group *tg;
14 struct rw_semaphore lock; 9 struct rw_semaphore lock;
diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index 9d4c8d5a1f53..c8c21be11ab4 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -116,7 +116,7 @@ static unsigned long get_timestamp(int this_cpu)
116 return cpu_clock(this_cpu) >> 30LL; /* 2^30 ~= 10^9 */ 116 return cpu_clock(this_cpu) >> 30LL; /* 2^30 ~= 10^9 */
117} 117}
118 118
119static unsigned long get_sample_period(void) 119static u64 get_sample_period(void)
120{ 120{
121 /* 121 /*
122 * convert watchdog_thresh from seconds to ns 122 * convert watchdog_thresh from seconds to ns
@@ -125,7 +125,7 @@ static unsigned long get_sample_period(void)
125 * and hard thresholds) to increment before the 125 * and hard thresholds) to increment before the
126 * hardlockup detector generates a warning 126 * hardlockup detector generates a warning
127 */ 127 */
128 return get_softlockup_thresh() * (NSEC_PER_SEC / 5); 128 return get_softlockup_thresh() * ((u64)NSEC_PER_SEC / 5);
129} 129}
130 130
131/* Commands for resetting the watchdog */ 131/* Commands for resetting the watchdog */
@@ -368,6 +368,9 @@ static void watchdog_disable(unsigned int cpu)
368{ 368{
369 struct hrtimer *hrtimer = &__raw_get_cpu_var(watchdog_hrtimer); 369 struct hrtimer *hrtimer = &__raw_get_cpu_var(watchdog_hrtimer);
370 370
371 if (!watchdog_enabled)
372 return;
373
371 watchdog_set_prio(SCHED_NORMAL, 0); 374 watchdog_set_prio(SCHED_NORMAL, 0);
372 hrtimer_cancel(hrtimer); 375 hrtimer_cancel(hrtimer);
373 /* disable the perf event */ 376 /* disable the perf event */
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 042d221d33cc..1dae900df798 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1361,8 +1361,19 @@ static void __queue_delayed_work(int cpu, struct workqueue_struct *wq,
1361 1361
1362 WARN_ON_ONCE(timer->function != delayed_work_timer_fn || 1362 WARN_ON_ONCE(timer->function != delayed_work_timer_fn ||
1363 timer->data != (unsigned long)dwork); 1363 timer->data != (unsigned long)dwork);
1364 BUG_ON(timer_pending(timer)); 1364 WARN_ON_ONCE(timer_pending(timer));
1365 BUG_ON(!list_empty(&work->entry)); 1365 WARN_ON_ONCE(!list_empty(&work->entry));
1366
1367 /*
1368 * If @delay is 0, queue @dwork->work immediately. This is for
1369 * both optimization and correctness. The earliest @timer can
1370 * expire is on the closest next tick and delayed_work users depend
1371 * on that there's no such delay when @delay is 0.
1372 */
1373 if (!delay) {
1374 __queue_work(cpu, wq, &dwork->work);
1375 return;
1376 }
1366 1377
1367 timer_stats_timer_set_start_info(&dwork->timer); 1378 timer_stats_timer_set_start_info(&dwork->timer);
1368 1379
@@ -1417,9 +1428,6 @@ bool queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
1417 bool ret = false; 1428 bool ret = false;
1418 unsigned long flags; 1429 unsigned long flags;
1419 1430
1420 if (!delay)
1421 return queue_work_on(cpu, wq, &dwork->work);
1422
1423 /* read the comment in __queue_work() */ 1431 /* read the comment in __queue_work() */
1424 local_irq_save(flags); 1432 local_irq_save(flags);
1425 1433
@@ -2407,8 +2415,10 @@ static int rescuer_thread(void *__wq)
2407repeat: 2415repeat:
2408 set_current_state(TASK_INTERRUPTIBLE); 2416 set_current_state(TASK_INTERRUPTIBLE);
2409 2417
2410 if (kthread_should_stop()) 2418 if (kthread_should_stop()) {
2419 __set_current_state(TASK_RUNNING);
2411 return 0; 2420 return 0;
2421 }
2412 2422
2413 /* 2423 /*
2414 * See whether any cpu is asking for help. Unbounded 2424 * See whether any cpu is asking for help. Unbounded
diff --git a/lib/Makefile b/lib/Makefile
index 821a16229111..a08b791200f3 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -163,7 +163,7 @@ $(obj)/crc32table.h: $(obj)/gen_crc32table
163# 163#
164obj-$(CONFIG_OID_REGISTRY) += oid_registry.o 164obj-$(CONFIG_OID_REGISTRY) += oid_registry.o
165 165
166$(obj)/oid_registry.c: $(obj)/oid_registry_data.c 166$(obj)/oid_registry.o: $(obj)/oid_registry_data.c
167 167
168$(obj)/oid_registry_data.c: $(srctree)/include/linux/oid_registry.h \ 168$(obj)/oid_registry_data.c: $(srctree)/include/linux/oid_registry.h \
169 $(src)/build_OID_registry 169 $(src)/build_OID_registry
diff --git a/lib/asn1_decoder.c b/lib/asn1_decoder.c
index de2c8b5a715b..5293d2433029 100644
--- a/lib/asn1_decoder.c
+++ b/lib/asn1_decoder.c
@@ -91,7 +91,7 @@ next_tag:
91 91
92 /* Extract the length */ 92 /* Extract the length */
93 len = data[dp++]; 93 len = data[dp++];
94 if (len < 0x7f) { 94 if (len <= 0x7f) {
95 dp += len; 95 dp += len;
96 goto next_tag; 96 goto next_tag;
97 } 97 }
diff --git a/mm/compaction.c b/mm/compaction.c
index 9eef55838fca..694eaabaaebd 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -713,7 +713,15 @@ static void isolate_freepages(struct zone *zone,
713 713
714 /* Found a block suitable for isolating free pages from */ 714 /* Found a block suitable for isolating free pages from */
715 isolated = 0; 715 isolated = 0;
716 end_pfn = min(pfn + pageblock_nr_pages, zone_end_pfn); 716
717 /*
718 * As pfn may not start aligned, pfn+pageblock_nr_page
719 * may cross a MAX_ORDER_NR_PAGES boundary and miss
720 * a pfn_valid check. Ensure isolate_freepages_block()
721 * only scans within a pageblock
722 */
723 end_pfn = ALIGN(pfn + 1, pageblock_nr_pages);
724 end_pfn = min(end_pfn, zone_end_pfn);
717 isolated = isolate_freepages_block(cc, pfn, end_pfn, 725 isolated = isolate_freepages_block(cc, pfn, end_pfn,
718 freelist, false); 726 freelist, false);
719 nr_freepages += isolated; 727 nr_freepages += isolated;
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 6c5899b9034a..8b20278be6a6 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1476,9 +1476,17 @@ int soft_offline_page(struct page *page, int flags)
1476{ 1476{
1477 int ret; 1477 int ret;
1478 unsigned long pfn = page_to_pfn(page); 1478 unsigned long pfn = page_to_pfn(page);
1479 struct page *hpage = compound_trans_head(page);
1479 1480
1480 if (PageHuge(page)) 1481 if (PageHuge(page))
1481 return soft_offline_huge_page(page, flags); 1482 return soft_offline_huge_page(page, flags);
1483 if (PageTransHuge(hpage)) {
1484 if (PageAnon(hpage) && unlikely(split_huge_page(hpage))) {
1485 pr_info("soft offline: %#lx: failed to split THP\n",
1486 pfn);
1487 return -EBUSY;
1488 }
1489 }
1482 1490
1483 ret = get_any_page(page, pfn, flags); 1491 ret = get_any_page(page, pfn, flags);
1484 if (ret < 0) 1492 if (ret < 0)
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index d04a8a54c294..4ea600da8940 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -2037,28 +2037,6 @@ struct mempolicy *__mpol_dup(struct mempolicy *old)
2037 return new; 2037 return new;
2038} 2038}
2039 2039
2040/*
2041 * If *frompol needs [has] an extra ref, copy *frompol to *tompol ,
2042 * eliminate the * MPOL_F_* flags that require conditional ref and
2043 * [NOTE!!!] drop the extra ref. Not safe to reference *frompol directly
2044 * after return. Use the returned value.
2045 *
2046 * Allows use of a mempolicy for, e.g., multiple allocations with a single
2047 * policy lookup, even if the policy needs/has extra ref on lookup.
2048 * shmem_readahead needs this.
2049 */
2050struct mempolicy *__mpol_cond_copy(struct mempolicy *tompol,
2051 struct mempolicy *frompol)
2052{
2053 if (!mpol_needs_cond_ref(frompol))
2054 return frompol;
2055
2056 *tompol = *frompol;
2057 tompol->flags &= ~MPOL_F_SHARED; /* copy doesn't need unref */
2058 __mpol_put(frompol);
2059 return tompol;
2060}
2061
2062/* Slow path of a mempolicy comparison */ 2040/* Slow path of a mempolicy comparison */
2063bool __mpol_equal(struct mempolicy *a, struct mempolicy *b) 2041bool __mpol_equal(struct mempolicy *a, struct mempolicy *b)
2064{ 2042{
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index bcb72c6e2b2d..7e208f0ad68c 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1422,7 +1422,7 @@ int capture_free_page(struct page *page, int alloc_order, int migratetype)
1422 } 1422 }
1423 } 1423 }
1424 1424
1425 return 1UL << order; 1425 return 1UL << alloc_order;
1426} 1426}
1427 1427
1428/* 1428/*
@@ -2416,8 +2416,9 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
2416 goto nopage; 2416 goto nopage;
2417 2417
2418restart: 2418restart:
2419 wake_all_kswapd(order, zonelist, high_zoneidx, 2419 if (!(gfp_mask & __GFP_NO_KSWAPD))
2420 zone_idx(preferred_zone)); 2420 wake_all_kswapd(order, zonelist, high_zoneidx,
2421 zone_idx(preferred_zone));
2421 2422
2422 /* 2423 /*
2423 * OK, we're below the kswapd watermark and have kicked background 2424 * OK, we're below the kswapd watermark and have kicked background
@@ -2494,7 +2495,7 @@ rebalance:
2494 * system then fail the allocation instead of entering direct reclaim. 2495 * system then fail the allocation instead of entering direct reclaim.
2495 */ 2496 */
2496 if ((deferred_compaction || contended_compaction) && 2497 if ((deferred_compaction || contended_compaction) &&
2497 (gfp_mask & (__GFP_MOVABLE|__GFP_REPEAT)) == __GFP_MOVABLE) 2498 (gfp_mask & __GFP_NO_KSWAPD))
2498 goto nopage; 2499 goto nopage;
2499 2500
2500 /* Try direct reclaim and then allocating */ 2501 /* Try direct reclaim and then allocating */
diff --git a/mm/shmem.c b/mm/shmem.c
index 89341b658bd0..50c5b8f3a359 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -910,25 +910,29 @@ static struct mempolicy *shmem_get_sbmpol(struct shmem_sb_info *sbinfo)
910static struct page *shmem_swapin(swp_entry_t swap, gfp_t gfp, 910static struct page *shmem_swapin(swp_entry_t swap, gfp_t gfp,
911 struct shmem_inode_info *info, pgoff_t index) 911 struct shmem_inode_info *info, pgoff_t index)
912{ 912{
913 struct mempolicy mpol, *spol;
914 struct vm_area_struct pvma; 913 struct vm_area_struct pvma;
915 914 struct page *page;
916 spol = mpol_cond_copy(&mpol,
917 mpol_shared_policy_lookup(&info->policy, index));
918 915
919 /* Create a pseudo vma that just contains the policy */ 916 /* Create a pseudo vma that just contains the policy */
920 pvma.vm_start = 0; 917 pvma.vm_start = 0;
921 /* Bias interleave by inode number to distribute better across nodes */ 918 /* Bias interleave by inode number to distribute better across nodes */
922 pvma.vm_pgoff = index + info->vfs_inode.i_ino; 919 pvma.vm_pgoff = index + info->vfs_inode.i_ino;
923 pvma.vm_ops = NULL; 920 pvma.vm_ops = NULL;
924 pvma.vm_policy = spol; 921 pvma.vm_policy = mpol_shared_policy_lookup(&info->policy, index);
925 return swapin_readahead(swap, gfp, &pvma, 0); 922
923 page = swapin_readahead(swap, gfp, &pvma, 0);
924
925 /* Drop reference taken by mpol_shared_policy_lookup() */
926 mpol_cond_put(pvma.vm_policy);
927
928 return page;
926} 929}
927 930
928static struct page *shmem_alloc_page(gfp_t gfp, 931static struct page *shmem_alloc_page(gfp_t gfp,
929 struct shmem_inode_info *info, pgoff_t index) 932 struct shmem_inode_info *info, pgoff_t index)
930{ 933{
931 struct vm_area_struct pvma; 934 struct vm_area_struct pvma;
935 struct page *page;
932 936
933 /* Create a pseudo vma that just contains the policy */ 937 /* Create a pseudo vma that just contains the policy */
934 pvma.vm_start = 0; 938 pvma.vm_start = 0;
@@ -937,10 +941,12 @@ static struct page *shmem_alloc_page(gfp_t gfp,
937 pvma.vm_ops = NULL; 941 pvma.vm_ops = NULL;
938 pvma.vm_policy = mpol_shared_policy_lookup(&info->policy, index); 942 pvma.vm_policy = mpol_shared_policy_lookup(&info->policy, index);
939 943
940 /* 944 page = alloc_page_vma(gfp, &pvma, 0);
941 * alloc_page_vma() will drop the shared policy reference 945
942 */ 946 /* Drop reference taken by mpol_shared_policy_lookup() */
943 return alloc_page_vma(gfp, &pvma, 0); 947 mpol_cond_put(pvma.vm_policy);
948
949 return page;
944} 950}
945#else /* !CONFIG_NUMA */ 951#else /* !CONFIG_NUMA */
946#ifdef CONFIG_TMPFS 952#ifdef CONFIG_TMPFS
diff --git a/mm/sparse.c b/mm/sparse.c
index fac95f2888f2..a83de2f72b30 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -617,7 +617,7 @@ static void __kfree_section_memmap(struct page *memmap, unsigned long nr_pages)
617{ 617{
618 return; /* XXX: Not implemented yet */ 618 return; /* XXX: Not implemented yet */
619} 619}
620static void free_map_bootmem(struct page *page, unsigned long nr_pages) 620static void free_map_bootmem(struct page *memmap, unsigned long nr_pages)
621{ 621{
622} 622}
623#else 623#else
@@ -658,10 +658,11 @@ static void __kfree_section_memmap(struct page *memmap, unsigned long nr_pages)
658 get_order(sizeof(struct page) * nr_pages)); 658 get_order(sizeof(struct page) * nr_pages));
659} 659}
660 660
661static void free_map_bootmem(struct page *page, unsigned long nr_pages) 661static void free_map_bootmem(struct page *memmap, unsigned long nr_pages)
662{ 662{
663 unsigned long maps_section_nr, removing_section_nr, i; 663 unsigned long maps_section_nr, removing_section_nr, i;
664 unsigned long magic; 664 unsigned long magic;
665 struct page *page = virt_to_page(memmap);
665 666
666 for (i = 0; i < nr_pages; i++, page++) { 667 for (i = 0; i < nr_pages; i++, page++) {
667 magic = (unsigned long) page->lru.next; 668 magic = (unsigned long) page->lru.next;
@@ -710,13 +711,10 @@ static void free_section_usemap(struct page *memmap, unsigned long *usemap)
710 */ 711 */
711 712
712 if (memmap) { 713 if (memmap) {
713 struct page *memmap_page;
714 memmap_page = virt_to_page(memmap);
715
716 nr_pages = PAGE_ALIGN(PAGES_PER_SECTION * sizeof(struct page)) 714 nr_pages = PAGE_ALIGN(PAGES_PER_SECTION * sizeof(struct page))
717 >> PAGE_SHIFT; 715 >> PAGE_SHIFT;
718 716
719 free_map_bootmem(memmap_page, nr_pages); 717 free_map_bootmem(memmap, nr_pages);
720 } 718 }
721} 719}
722 720
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 48550c66f1f2..b7ed37675644 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2207,9 +2207,12 @@ static bool pfmemalloc_watermark_ok(pg_data_t *pgdat)
2207 * Throttle direct reclaimers if backing storage is backed by the network 2207 * Throttle direct reclaimers if backing storage is backed by the network
2208 * and the PFMEMALLOC reserve for the preferred node is getting dangerously 2208 * and the PFMEMALLOC reserve for the preferred node is getting dangerously
2209 * depleted. kswapd will continue to make progress and wake the processes 2209 * depleted. kswapd will continue to make progress and wake the processes
2210 * when the low watermark is reached 2210 * when the low watermark is reached.
2211 *
2212 * Returns true if a fatal signal was delivered during throttling. If this
2213 * happens, the page allocator should not consider triggering the OOM killer.
2211 */ 2214 */
2212static void throttle_direct_reclaim(gfp_t gfp_mask, struct zonelist *zonelist, 2215static bool throttle_direct_reclaim(gfp_t gfp_mask, struct zonelist *zonelist,
2213 nodemask_t *nodemask) 2216 nodemask_t *nodemask)
2214{ 2217{
2215 struct zone *zone; 2218 struct zone *zone;
@@ -2224,13 +2227,20 @@ static void throttle_direct_reclaim(gfp_t gfp_mask, struct zonelist *zonelist,
2224 * processes to block on log_wait_commit(). 2227 * processes to block on log_wait_commit().
2225 */ 2228 */
2226 if (current->flags & PF_KTHREAD) 2229 if (current->flags & PF_KTHREAD)
2227 return; 2230 goto out;
2231
2232 /*
2233 * If a fatal signal is pending, this process should not throttle.
2234 * It should return quickly so it can exit and free its memory
2235 */
2236 if (fatal_signal_pending(current))
2237 goto out;
2228 2238
2229 /* Check if the pfmemalloc reserves are ok */ 2239 /* Check if the pfmemalloc reserves are ok */
2230 first_zones_zonelist(zonelist, high_zoneidx, NULL, &zone); 2240 first_zones_zonelist(zonelist, high_zoneidx, NULL, &zone);
2231 pgdat = zone->zone_pgdat; 2241 pgdat = zone->zone_pgdat;
2232 if (pfmemalloc_watermark_ok(pgdat)) 2242 if (pfmemalloc_watermark_ok(pgdat))
2233 return; 2243 goto out;
2234 2244
2235 /* Account for the throttling */ 2245 /* Account for the throttling */
2236 count_vm_event(PGSCAN_DIRECT_THROTTLE); 2246 count_vm_event(PGSCAN_DIRECT_THROTTLE);
@@ -2246,12 +2256,20 @@ static void throttle_direct_reclaim(gfp_t gfp_mask, struct zonelist *zonelist,
2246 if (!(gfp_mask & __GFP_FS)) { 2256 if (!(gfp_mask & __GFP_FS)) {
2247 wait_event_interruptible_timeout(pgdat->pfmemalloc_wait, 2257 wait_event_interruptible_timeout(pgdat->pfmemalloc_wait,
2248 pfmemalloc_watermark_ok(pgdat), HZ); 2258 pfmemalloc_watermark_ok(pgdat), HZ);
2249 return; 2259
2260 goto check_pending;
2250 } 2261 }
2251 2262
2252 /* Throttle until kswapd wakes the process */ 2263 /* Throttle until kswapd wakes the process */
2253 wait_event_killable(zone->zone_pgdat->pfmemalloc_wait, 2264 wait_event_killable(zone->zone_pgdat->pfmemalloc_wait,
2254 pfmemalloc_watermark_ok(pgdat)); 2265 pfmemalloc_watermark_ok(pgdat));
2266
2267check_pending:
2268 if (fatal_signal_pending(current))
2269 return true;
2270
2271out:
2272 return false;
2255} 2273}
2256 2274
2257unsigned long try_to_free_pages(struct zonelist *zonelist, int order, 2275unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
@@ -2273,13 +2291,12 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
2273 .gfp_mask = sc.gfp_mask, 2291 .gfp_mask = sc.gfp_mask,
2274 }; 2292 };
2275 2293
2276 throttle_direct_reclaim(gfp_mask, zonelist, nodemask);
2277
2278 /* 2294 /*
2279 * Do not enter reclaim if fatal signal is pending. 1 is returned so 2295 * Do not enter reclaim if fatal signal was delivered while throttled.
2280 * that the page allocator does not consider triggering OOM 2296 * 1 is returned so that the page allocator does not OOM kill at this
2297 * point.
2281 */ 2298 */
2282 if (fatal_signal_pending(current)) 2299 if (throttle_direct_reclaim(gfp_mask, zonelist, nodemask))
2283 return 1; 2300 return 1;
2284 2301
2285 trace_mm_vmscan_direct_reclaim_begin(order, 2302 trace_mm_vmscan_direct_reclaim_begin(order,
@@ -2397,6 +2414,19 @@ static void age_active_anon(struct zone *zone, struct scan_control *sc)
2397 } while (memcg); 2414 } while (memcg);
2398} 2415}
2399 2416
2417static bool zone_balanced(struct zone *zone, int order,
2418 unsigned long balance_gap, int classzone_idx)
2419{
2420 if (!zone_watermark_ok_safe(zone, order, high_wmark_pages(zone) +
2421 balance_gap, classzone_idx, 0))
2422 return false;
2423
2424 if (COMPACTION_BUILD && order && !compaction_suitable(zone, order))
2425 return false;
2426
2427 return true;
2428}
2429
2400/* 2430/*
2401 * pgdat_balanced is used when checking if a node is balanced for high-order 2431 * pgdat_balanced is used when checking if a node is balanced for high-order
2402 * allocations. Only zones that meet watermarks and are in a zone allowed 2432 * allocations. Only zones that meet watermarks and are in a zone allowed
@@ -2475,8 +2505,7 @@ static bool prepare_kswapd_sleep(pg_data_t *pgdat, int order, long remaining,
2475 continue; 2505 continue;
2476 } 2506 }
2477 2507
2478 if (!zone_watermark_ok_safe(zone, order, high_wmark_pages(zone), 2508 if (!zone_balanced(zone, order, 0, i))
2479 i, 0))
2480 all_zones_ok = false; 2509 all_zones_ok = false;
2481 else 2510 else
2482 balanced += zone->present_pages; 2511 balanced += zone->present_pages;
@@ -2585,8 +2614,7 @@ loop_again:
2585 break; 2614 break;
2586 } 2615 }
2587 2616
2588 if (!zone_watermark_ok_safe(zone, order, 2617 if (!zone_balanced(zone, order, 0, 0)) {
2589 high_wmark_pages(zone), 0, 0)) {
2590 end_zone = i; 2618 end_zone = i;
2591 break; 2619 break;
2592 } else { 2620 } else {
@@ -2662,9 +2690,8 @@ loop_again:
2662 testorder = 0; 2690 testorder = 0;
2663 2691
2664 if ((buffer_heads_over_limit && is_highmem_idx(i)) || 2692 if ((buffer_heads_over_limit && is_highmem_idx(i)) ||
2665 !zone_watermark_ok_safe(zone, testorder, 2693 !zone_balanced(zone, testorder,
2666 high_wmark_pages(zone) + balance_gap, 2694 balance_gap, end_zone)) {
2667 end_zone, 0)) {
2668 shrink_zone(zone, &sc); 2695 shrink_zone(zone, &sc);
2669 2696
2670 reclaim_state->reclaimed_slab = 0; 2697 reclaim_state->reclaimed_slab = 0;
@@ -2691,8 +2718,7 @@ loop_again:
2691 continue; 2718 continue;
2692 } 2719 }
2693 2720
2694 if (!zone_watermark_ok_safe(zone, testorder, 2721 if (!zone_balanced(zone, testorder, 0, end_zone)) {
2695 high_wmark_pages(zone), end_zone, 0)) {
2696 all_zones_ok = 0; 2722 all_zones_ok = 0;
2697 /* 2723 /*
2698 * We are still under min water mark. This 2724 * We are still under min water mark. This
@@ -2797,29 +2823,10 @@ out:
2797 if (!populated_zone(zone)) 2823 if (!populated_zone(zone))
2798 continue; 2824 continue;
2799 2825
2800 if (zone->all_unreclaimable &&
2801 sc.priority != DEF_PRIORITY)
2802 continue;
2803
2804 /* Would compaction fail due to lack of free memory? */
2805 if (COMPACTION_BUILD &&
2806 compaction_suitable(zone, order) == COMPACT_SKIPPED)
2807 goto loop_again;
2808
2809 /* Confirm the zone is balanced for order-0 */
2810 if (!zone_watermark_ok(zone, 0,
2811 high_wmark_pages(zone), 0, 0)) {
2812 order = sc.order = 0;
2813 goto loop_again;
2814 }
2815
2816 /* Check if the memory needs to be defragmented. */ 2826 /* Check if the memory needs to be defragmented. */
2817 if (zone_watermark_ok(zone, order, 2827 if (zone_watermark_ok(zone, order,
2818 low_wmark_pages(zone), *classzone_idx, 0)) 2828 low_wmark_pages(zone), *classzone_idx, 0))
2819 zones_need_compaction = 0; 2829 zones_need_compaction = 0;
2820
2821 /* If balanced, clear the congested flag */
2822 zone_clear_flag(zone, ZONE_CONGESTED);
2823 } 2830 }
2824 2831
2825 if (zones_need_compaction) 2832 if (zones_need_compaction)
diff --git a/net/can/bcm.c b/net/can/bcm.c
index 6f747582718e..969b7cdff59d 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -1084,6 +1084,9 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
1084 op->sk = sk; 1084 op->sk = sk;
1085 op->ifindex = ifindex; 1085 op->ifindex = ifindex;
1086 1086
1087 /* ifindex for timeout events w/o previous frame reception */
1088 op->rx_ifindex = ifindex;
1089
1087 /* initialize uninitialized (kzalloc) structure */ 1090 /* initialize uninitialized (kzalloc) structure */
1088 hrtimer_init(&op->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 1091 hrtimer_init(&op->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
1089 op->timer.function = bcm_rx_timeout_handler; 1092 op->timer.function = bcm_rx_timeout_handler;
diff --git a/net/core/dev.c b/net/core/dev.c
index c0946cb2b354..e5942bf45a6d 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3451,6 +3451,8 @@ static int napi_gro_complete(struct sk_buff *skb)
3451 struct list_head *head = &ptype_base[ntohs(type) & PTYPE_HASH_MASK]; 3451 struct list_head *head = &ptype_base[ntohs(type) & PTYPE_HASH_MASK];
3452 int err = -ENOENT; 3452 int err = -ENOENT;
3453 3453
3454 BUILD_BUG_ON(sizeof(struct napi_gro_cb) > sizeof(skb->cb));
3455
3454 if (NAPI_GRO_CB(skb)->count == 1) { 3456 if (NAPI_GRO_CB(skb)->count == 1) {
3455 skb_shinfo(skb)->gso_size = 0; 3457 skb_shinfo(skb)->gso_size = 0;
3456 goto out; 3458 goto out;
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 4007c1437fda..3f0636cd76cd 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3004,7 +3004,7 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb)
3004 skb_shinfo(nskb)->gso_size = pinfo->gso_size; 3004 skb_shinfo(nskb)->gso_size = pinfo->gso_size;
3005 pinfo->gso_size = 0; 3005 pinfo->gso_size = 0;
3006 skb_header_release(p); 3006 skb_header_release(p);
3007 nskb->prev = p; 3007 NAPI_GRO_CB(nskb)->last = p;
3008 3008
3009 nskb->data_len += p->len; 3009 nskb->data_len += p->len;
3010 nskb->truesize += p->truesize; 3010 nskb->truesize += p->truesize;
@@ -3030,8 +3030,8 @@ merge:
3030 3030
3031 __skb_pull(skb, offset); 3031 __skb_pull(skb, offset);
3032 3032
3033 p->prev->next = skb; 3033 NAPI_GRO_CB(p)->last->next = skb;
3034 p->prev = skb; 3034 NAPI_GRO_CB(p)->last = skb;
3035 skb_header_release(skb); 3035 skb_header_release(skb);
3036 3036
3037done: 3037done:
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index f2eccd531746..17ff9fd7cdda 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -257,7 +257,8 @@ static inline bool icmpv4_xrlim_allow(struct net *net, struct rtable *rt,
257 struct inet_peer *peer = inet_getpeer_v4(net->ipv4.peers, fl4->daddr, 1); 257 struct inet_peer *peer = inet_getpeer_v4(net->ipv4.peers, fl4->daddr, 1);
258 rc = inet_peer_xrlim_allow(peer, 258 rc = inet_peer_xrlim_allow(peer,
259 net->ipv4.sysctl_icmp_ratelimit); 259 net->ipv4.sysctl_icmp_ratelimit);
260 inet_putpeer(peer); 260 if (peer)
261 inet_putpeer(peer);
261 } 262 }
262out: 263out:
263 return rc; 264 return rc;
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 0c34bfabc11f..e23e16dc501d 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -44,6 +44,10 @@ struct inet_diag_entry {
44 u16 dport; 44 u16 dport;
45 u16 family; 45 u16 family;
46 u16 userlocks; 46 u16 userlocks;
47#if IS_ENABLED(CONFIG_IPV6)
48 struct in6_addr saddr_storage; /* for IPv4-mapped-IPv6 addresses */
49 struct in6_addr daddr_storage; /* for IPv4-mapped-IPv6 addresses */
50#endif
47}; 51};
48 52
49static DEFINE_MUTEX(inet_diag_table_mutex); 53static DEFINE_MUTEX(inet_diag_table_mutex);
@@ -428,25 +432,31 @@ static int inet_diag_bc_run(const struct nlattr *_bc,
428 break; 432 break;
429 } 433 }
430 434
431 if (cond->prefix_len == 0)
432 break;
433
434 if (op->code == INET_DIAG_BC_S_COND) 435 if (op->code == INET_DIAG_BC_S_COND)
435 addr = entry->saddr; 436 addr = entry->saddr;
436 else 437 else
437 addr = entry->daddr; 438 addr = entry->daddr;
438 439
440 if (cond->family != AF_UNSPEC &&
441 cond->family != entry->family) {
442 if (entry->family == AF_INET6 &&
443 cond->family == AF_INET) {
444 if (addr[0] == 0 && addr[1] == 0 &&
445 addr[2] == htonl(0xffff) &&
446 bitstring_match(addr + 3,
447 cond->addr,
448 cond->prefix_len))
449 break;
450 }
451 yes = 0;
452 break;
453 }
454
455 if (cond->prefix_len == 0)
456 break;
439 if (bitstring_match(addr, cond->addr, 457 if (bitstring_match(addr, cond->addr,
440 cond->prefix_len)) 458 cond->prefix_len))
441 break; 459 break;
442 if (entry->family == AF_INET6 &&
443 cond->family == AF_INET) {
444 if (addr[0] == 0 && addr[1] == 0 &&
445 addr[2] == htonl(0xffff) &&
446 bitstring_match(addr + 3, cond->addr,
447 cond->prefix_len))
448 break;
449 }
450 yes = 0; 460 yes = 0;
451 break; 461 break;
452 } 462 }
@@ -509,6 +519,55 @@ static int valid_cc(const void *bc, int len, int cc)
509 return 0; 519 return 0;
510} 520}
511 521
522/* Validate an inet_diag_hostcond. */
523static bool valid_hostcond(const struct inet_diag_bc_op *op, int len,
524 int *min_len)
525{
526 int addr_len;
527 struct inet_diag_hostcond *cond;
528
529 /* Check hostcond space. */
530 *min_len += sizeof(struct inet_diag_hostcond);
531 if (len < *min_len)
532 return false;
533 cond = (struct inet_diag_hostcond *)(op + 1);
534
535 /* Check address family and address length. */
536 switch (cond->family) {
537 case AF_UNSPEC:
538 addr_len = 0;
539 break;
540 case AF_INET:
541 addr_len = sizeof(struct in_addr);
542 break;
543 case AF_INET6:
544 addr_len = sizeof(struct in6_addr);
545 break;
546 default:
547 return false;
548 }
549 *min_len += addr_len;
550 if (len < *min_len)
551 return false;
552
553 /* Check prefix length (in bits) vs address length (in bytes). */
554 if (cond->prefix_len > 8 * addr_len)
555 return false;
556
557 return true;
558}
559
560/* Validate a port comparison operator. */
561static inline bool valid_port_comparison(const struct inet_diag_bc_op *op,
562 int len, int *min_len)
563{
564 /* Port comparisons put the port in a follow-on inet_diag_bc_op. */
565 *min_len += sizeof(struct inet_diag_bc_op);
566 if (len < *min_len)
567 return false;
568 return true;
569}
570
512static int inet_diag_bc_audit(const void *bytecode, int bytecode_len) 571static int inet_diag_bc_audit(const void *bytecode, int bytecode_len)
513{ 572{
514 const void *bc = bytecode; 573 const void *bc = bytecode;
@@ -516,29 +575,39 @@ static int inet_diag_bc_audit(const void *bytecode, int bytecode_len)
516 575
517 while (len > 0) { 576 while (len > 0) {
518 const struct inet_diag_bc_op *op = bc; 577 const struct inet_diag_bc_op *op = bc;
578 int min_len = sizeof(struct inet_diag_bc_op);
519 579
520//printk("BC: %d %d %d {%d} / %d\n", op->code, op->yes, op->no, op[1].no, len); 580//printk("BC: %d %d %d {%d} / %d\n", op->code, op->yes, op->no, op[1].no, len);
521 switch (op->code) { 581 switch (op->code) {
522 case INET_DIAG_BC_AUTO:
523 case INET_DIAG_BC_S_COND: 582 case INET_DIAG_BC_S_COND:
524 case INET_DIAG_BC_D_COND: 583 case INET_DIAG_BC_D_COND:
584 if (!valid_hostcond(bc, len, &min_len))
585 return -EINVAL;
586 break;
525 case INET_DIAG_BC_S_GE: 587 case INET_DIAG_BC_S_GE:
526 case INET_DIAG_BC_S_LE: 588 case INET_DIAG_BC_S_LE:
527 case INET_DIAG_BC_D_GE: 589 case INET_DIAG_BC_D_GE:
528 case INET_DIAG_BC_D_LE: 590 case INET_DIAG_BC_D_LE:
529 case INET_DIAG_BC_JMP: 591 if (!valid_port_comparison(bc, len, &min_len))
530 if (op->no < 4 || op->no > len + 4 || op->no & 3)
531 return -EINVAL;
532 if (op->no < len &&
533 !valid_cc(bytecode, bytecode_len, len - op->no))
534 return -EINVAL; 592 return -EINVAL;
535 break; 593 break;
594 case INET_DIAG_BC_AUTO:
595 case INET_DIAG_BC_JMP:
536 case INET_DIAG_BC_NOP: 596 case INET_DIAG_BC_NOP:
537 break; 597 break;
538 default: 598 default:
539 return -EINVAL; 599 return -EINVAL;
540 } 600 }
541 if (op->yes < 4 || op->yes > len + 4 || op->yes & 3) 601
602 if (op->code != INET_DIAG_BC_NOP) {
603 if (op->no < min_len || op->no > len + 4 || op->no & 3)
604 return -EINVAL;
605 if (op->no < len &&
606 !valid_cc(bytecode, bytecode_len, len - op->no))
607 return -EINVAL;
608 }
609
610 if (op->yes < min_len || op->yes > len + 4 || op->yes & 3)
542 return -EINVAL; 611 return -EINVAL;
543 bc += op->yes; 612 bc += op->yes;
544 len -= op->yes; 613 len -= op->yes;
@@ -596,6 +665,36 @@ static int inet_twsk_diag_dump(struct inet_timewait_sock *tw,
596 cb->nlh->nlmsg_seq, NLM_F_MULTI, cb->nlh); 665 cb->nlh->nlmsg_seq, NLM_F_MULTI, cb->nlh);
597} 666}
598 667
668/* Get the IPv4, IPv6, or IPv4-mapped-IPv6 local and remote addresses
669 * from a request_sock. For IPv4-mapped-IPv6 we must map IPv4 to IPv6.
670 */
671static inline void inet_diag_req_addrs(const struct sock *sk,
672 const struct request_sock *req,
673 struct inet_diag_entry *entry)
674{
675 struct inet_request_sock *ireq = inet_rsk(req);
676
677#if IS_ENABLED(CONFIG_IPV6)
678 if (sk->sk_family == AF_INET6) {
679 if (req->rsk_ops->family == AF_INET6) {
680 entry->saddr = inet6_rsk(req)->loc_addr.s6_addr32;
681 entry->daddr = inet6_rsk(req)->rmt_addr.s6_addr32;
682 } else if (req->rsk_ops->family == AF_INET) {
683 ipv6_addr_set_v4mapped(ireq->loc_addr,
684 &entry->saddr_storage);
685 ipv6_addr_set_v4mapped(ireq->rmt_addr,
686 &entry->daddr_storage);
687 entry->saddr = entry->saddr_storage.s6_addr32;
688 entry->daddr = entry->daddr_storage.s6_addr32;
689 }
690 } else
691#endif
692 {
693 entry->saddr = &ireq->loc_addr;
694 entry->daddr = &ireq->rmt_addr;
695 }
696}
697
599static int inet_diag_fill_req(struct sk_buff *skb, struct sock *sk, 698static int inet_diag_fill_req(struct sk_buff *skb, struct sock *sk,
600 struct request_sock *req, 699 struct request_sock *req,
601 struct user_namespace *user_ns, 700 struct user_namespace *user_ns,
@@ -637,8 +736,10 @@ static int inet_diag_fill_req(struct sk_buff *skb, struct sock *sk,
637 r->idiag_inode = 0; 736 r->idiag_inode = 0;
638#if IS_ENABLED(CONFIG_IPV6) 737#if IS_ENABLED(CONFIG_IPV6)
639 if (r->idiag_family == AF_INET6) { 738 if (r->idiag_family == AF_INET6) {
640 *(struct in6_addr *)r->id.idiag_src = inet6_rsk(req)->loc_addr; 739 struct inet_diag_entry entry;
641 *(struct in6_addr *)r->id.idiag_dst = inet6_rsk(req)->rmt_addr; 740 inet_diag_req_addrs(sk, req, &entry);
741 memcpy(r->id.idiag_src, entry.saddr, sizeof(struct in6_addr));
742 memcpy(r->id.idiag_dst, entry.daddr, sizeof(struct in6_addr));
642 } 743 }
643#endif 744#endif
644 745
@@ -691,18 +792,7 @@ static int inet_diag_dump_reqs(struct sk_buff *skb, struct sock *sk,
691 continue; 792 continue;
692 793
693 if (bc) { 794 if (bc) {
694 entry.saddr = 795 inet_diag_req_addrs(sk, req, &entry);
695#if IS_ENABLED(CONFIG_IPV6)
696 (entry.family == AF_INET6) ?
697 inet6_rsk(req)->loc_addr.s6_addr32 :
698#endif
699 &ireq->loc_addr;
700 entry.daddr =
701#if IS_ENABLED(CONFIG_IPV6)
702 (entry.family == AF_INET6) ?
703 inet6_rsk(req)->rmt_addr.s6_addr32 :
704#endif
705 &ireq->rmt_addr;
706 entry.dport = ntohs(ireq->rmt_port); 796 entry.dport = ntohs(ireq->rmt_port);
707 797
708 if (!inet_diag_bc_run(bc, &entry)) 798 if (!inet_diag_bc_run(bc, &entry))
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 448e68546827..8d5cc75dac88 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -707,28 +707,27 @@ EXPORT_SYMBOL(ip_defrag);
707 707
708struct sk_buff *ip_check_defrag(struct sk_buff *skb, u32 user) 708struct sk_buff *ip_check_defrag(struct sk_buff *skb, u32 user)
709{ 709{
710 const struct iphdr *iph; 710 struct iphdr iph;
711 u32 len; 711 u32 len;
712 712
713 if (skb->protocol != htons(ETH_P_IP)) 713 if (skb->protocol != htons(ETH_P_IP))
714 return skb; 714 return skb;
715 715
716 if (!pskb_may_pull(skb, sizeof(struct iphdr))) 716 if (!skb_copy_bits(skb, 0, &iph, sizeof(iph)))
717 return skb; 717 return skb;
718 718
719 iph = ip_hdr(skb); 719 if (iph.ihl < 5 || iph.version != 4)
720 if (iph->ihl < 5 || iph->version != 4)
721 return skb; 720 return skb;
722 if (!pskb_may_pull(skb, iph->ihl*4)) 721
723 return skb; 722 len = ntohs(iph.tot_len);
724 iph = ip_hdr(skb); 723 if (skb->len < len || len < (iph.ihl * 4))
725 len = ntohs(iph->tot_len);
726 if (skb->len < len || len < (iph->ihl * 4))
727 return skb; 724 return skb;
728 725
729 if (ip_is_fragment(ip_hdr(skb))) { 726 if (ip_is_fragment(&iph)) {
730 skb = skb_share_check(skb, GFP_ATOMIC); 727 skb = skb_share_check(skb, GFP_ATOMIC);
731 if (skb) { 728 if (skb) {
729 if (!pskb_may_pull(skb, iph.ihl*4))
730 return skb;
732 if (pskb_trim_rcsum(skb, len)) 731 if (pskb_trim_rcsum(skb, len))
733 return skb; 732 return skb;
734 memset(IPCB(skb), 0, sizeof(struct inet_skb_parm)); 733 memset(IPCB(skb), 0, sizeof(struct inet_skb_parm));
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 6168c4dc58b1..3eab2b2ffd34 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1318,6 +1318,10 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, unsi
1318 if (get_user(v, (u32 __user *)optval)) 1318 if (get_user(v, (u32 __user *)optval))
1319 return -EFAULT; 1319 return -EFAULT;
1320 1320
1321 /* "pimreg%u" should not exceed 16 bytes (IFNAMSIZ) */
1322 if (v != RT_TABLE_DEFAULT && v >= 1000000000)
1323 return -EINVAL;
1324
1321 rtnl_lock(); 1325 rtnl_lock();
1322 ret = 0; 1326 ret = 0;
1323 if (sk == rtnl_dereference(mrt->mroute_sk)) { 1327 if (sk == rtnl_dereference(mrt->mroute_sk)) {
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 083092e3aed6..e457c7ab2e28 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -830,8 +830,8 @@ static int tcp_send_mss(struct sock *sk, int *size_goal, int flags)
830 return mss_now; 830 return mss_now;
831} 831}
832 832
833static ssize_t do_tcp_sendpages(struct sock *sk, struct page **pages, int poffset, 833static ssize_t do_tcp_sendpages(struct sock *sk, struct page *page, int offset,
834 size_t psize, int flags) 834 size_t size, int flags)
835{ 835{
836 struct tcp_sock *tp = tcp_sk(sk); 836 struct tcp_sock *tp = tcp_sk(sk);
837 int mss_now, size_goal; 837 int mss_now, size_goal;
@@ -858,12 +858,9 @@ static ssize_t do_tcp_sendpages(struct sock *sk, struct page **pages, int poffse
858 if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN)) 858 if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN))
859 goto out_err; 859 goto out_err;
860 860
861 while (psize > 0) { 861 while (size > 0) {
862 struct sk_buff *skb = tcp_write_queue_tail(sk); 862 struct sk_buff *skb = tcp_write_queue_tail(sk);
863 struct page *page = pages[poffset / PAGE_SIZE];
864 int copy, i; 863 int copy, i;
865 int offset = poffset % PAGE_SIZE;
866 int size = min_t(size_t, psize, PAGE_SIZE - offset);
867 bool can_coalesce; 864 bool can_coalesce;
868 865
869 if (!tcp_send_head(sk) || (copy = size_goal - skb->len) <= 0) { 866 if (!tcp_send_head(sk) || (copy = size_goal - skb->len) <= 0) {
@@ -912,8 +909,8 @@ new_segment:
912 TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_PSH; 909 TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_PSH;
913 910
914 copied += copy; 911 copied += copy;
915 poffset += copy; 912 offset += copy;
916 if (!(psize -= copy)) 913 if (!(size -= copy))
917 goto out; 914 goto out;
918 915
919 if (skb->len < size_goal || (flags & MSG_OOB)) 916 if (skb->len < size_goal || (flags & MSG_OOB))
@@ -960,7 +957,7 @@ int tcp_sendpage(struct sock *sk, struct page *page, int offset,
960 flags); 957 flags);
961 958
962 lock_sock(sk); 959 lock_sock(sk);
963 res = do_tcp_sendpages(sk, &page, offset, size, flags); 960 res = do_tcp_sendpages(sk, page, offset, size, flags);
964 release_sock(sk); 961 release_sock(sk);
965 return res; 962 return res;
966} 963}
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 609ff98aeb47..181fc8234a52 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -5645,7 +5645,11 @@ static bool tcp_rcv_fastopen_synack(struct sock *sk, struct sk_buff *synack,
5645 tcp_fastopen_cache_set(sk, mss, cookie, syn_drop); 5645 tcp_fastopen_cache_set(sk, mss, cookie, syn_drop);
5646 5646
5647 if (data) { /* Retransmit unacked data in SYN */ 5647 if (data) { /* Retransmit unacked data in SYN */
5648 tcp_retransmit_skb(sk, data); 5648 tcp_for_write_queue_from(data, sk) {
5649 if (data == tcp_send_head(sk) ||
5650 __tcp_retransmit_skb(sk, data))
5651 break;
5652 }
5649 tcp_rearm_rto(sk); 5653 tcp_rearm_rto(sk);
5650 return true; 5654 return true;
5651 } 5655 }
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 2798706cb063..948ac275b9b5 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2309,12 +2309,11 @@ static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *to,
2309 * state updates are done by the caller. Returns non-zero if an 2309 * state updates are done by the caller. Returns non-zero if an
2310 * error occurred which prevented the send. 2310 * error occurred which prevented the send.
2311 */ 2311 */
2312int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb) 2312int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
2313{ 2313{
2314 struct tcp_sock *tp = tcp_sk(sk); 2314 struct tcp_sock *tp = tcp_sk(sk);
2315 struct inet_connection_sock *icsk = inet_csk(sk); 2315 struct inet_connection_sock *icsk = inet_csk(sk);
2316 unsigned int cur_mss; 2316 unsigned int cur_mss;
2317 int err;
2318 2317
2319 /* Inconslusive MTU probe */ 2318 /* Inconslusive MTU probe */
2320 if (icsk->icsk_mtup.probe_size) { 2319 if (icsk->icsk_mtup.probe_size) {
@@ -2387,11 +2386,17 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
2387 if (unlikely(NET_IP_ALIGN && ((unsigned long)skb->data & 3))) { 2386 if (unlikely(NET_IP_ALIGN && ((unsigned long)skb->data & 3))) {
2388 struct sk_buff *nskb = __pskb_copy(skb, MAX_TCP_HEADER, 2387 struct sk_buff *nskb = __pskb_copy(skb, MAX_TCP_HEADER,
2389 GFP_ATOMIC); 2388 GFP_ATOMIC);
2390 err = nskb ? tcp_transmit_skb(sk, nskb, 0, GFP_ATOMIC) : 2389 return nskb ? tcp_transmit_skb(sk, nskb, 0, GFP_ATOMIC) :
2391 -ENOBUFS; 2390 -ENOBUFS;
2392 } else { 2391 } else {
2393 err = tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC); 2392 return tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC);
2394 } 2393 }
2394}
2395
2396int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
2397{
2398 struct tcp_sock *tp = tcp_sk(sk);
2399 int err = __tcp_retransmit_skb(sk, skb);
2395 2400
2396 if (err == 0) { 2401 if (err == 0) {
2397 /* Update global TCP statistics. */ 2402 /* Update global TCP statistics. */
diff --git a/net/irda/irttp.c b/net/irda/irttp.c
index 1002e3396f72..ae43c62f9045 100644
--- a/net/irda/irttp.c
+++ b/net/irda/irttp.c
@@ -441,6 +441,7 @@ struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify)
441 lsap = irlmp_open_lsap(stsap_sel, &ttp_notify, 0); 441 lsap = irlmp_open_lsap(stsap_sel, &ttp_notify, 0);
442 if (lsap == NULL) { 442 if (lsap == NULL) {
443 IRDA_DEBUG(0, "%s: unable to allocate LSAP!!\n", __func__); 443 IRDA_DEBUG(0, "%s: unable to allocate LSAP!!\n", __func__);
444 __irttp_close_tsap(self);
444 return NULL; 445 return NULL;
445 } 446 }
446 447
diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c
index 83608ac16780..2c84185dfdb0 100644
--- a/net/mac80211/offchannel.c
+++ b/net/mac80211/offchannel.c
@@ -458,8 +458,6 @@ void ieee80211_roc_purge(struct ieee80211_sub_if_data *sdata)
458 list_move_tail(&roc->list, &tmp_list); 458 list_move_tail(&roc->list, &tmp_list);
459 roc->abort = true; 459 roc->abort = true;
460 } 460 }
461
462 ieee80211_start_next_roc(local);
463 mutex_unlock(&local->mtx); 461 mutex_unlock(&local->mtx);
464 462
465 list_for_each_entry_safe(roc, tmp, &tmp_list, list) { 463 list_for_each_entry_safe(roc, tmp, &tmp_list, list) {
diff --git a/net/netfilter/ipset/ip_set_hash_netiface.c b/net/netfilter/ipset/ip_set_hash_netiface.c
index b9a63381e349..45a101439bc5 100644
--- a/net/netfilter/ipset/ip_set_hash_netiface.c
+++ b/net/netfilter/ipset/ip_set_hash_netiface.c
@@ -793,7 +793,7 @@ static struct ip_set_type hash_netiface_type __read_mostly = {
793 [IPSET_ATTR_IP] = { .type = NLA_NESTED }, 793 [IPSET_ATTR_IP] = { .type = NLA_NESTED },
794 [IPSET_ATTR_IP_TO] = { .type = NLA_NESTED }, 794 [IPSET_ATTR_IP_TO] = { .type = NLA_NESTED },
795 [IPSET_ATTR_IFACE] = { .type = NLA_NUL_STRING, 795 [IPSET_ATTR_IFACE] = { .type = NLA_NUL_STRING,
796 .len = IPSET_MAXNAMELEN - 1 }, 796 .len = IFNAMSIZ - 1 },
797 [IPSET_ATTR_CADT_FLAGS] = { .type = NLA_U32 }, 797 [IPSET_ATTR_CADT_FLAGS] = { .type = NLA_U32 },
798 [IPSET_ATTR_CIDR] = { .type = NLA_U8 }, 798 [IPSET_ATTR_CIDR] = { .type = NLA_U8 },
799 [IPSET_ATTR_TIMEOUT] = { .type = NLA_U32 }, 799 [IPSET_ATTR_TIMEOUT] = { .type = NLA_U32 },
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index 98c70630ad06..733cbf49ed1f 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -702,15 +702,11 @@ int ovs_flow_extract(struct sk_buff *skb, u16 in_port, struct sw_flow_key *key,
702 /* We only match on the lower 8 bits of the opcode. */ 702 /* We only match on the lower 8 bits of the opcode. */
703 if (ntohs(arp->ar_op) <= 0xff) 703 if (ntohs(arp->ar_op) <= 0xff)
704 key->ip.proto = ntohs(arp->ar_op); 704 key->ip.proto = ntohs(arp->ar_op);
705 705 memcpy(&key->ipv4.addr.src, arp->ar_sip, sizeof(key->ipv4.addr.src));
706 if (key->ip.proto == ARPOP_REQUEST 706 memcpy(&key->ipv4.addr.dst, arp->ar_tip, sizeof(key->ipv4.addr.dst));
707 || key->ip.proto == ARPOP_REPLY) { 707 memcpy(key->ipv4.arp.sha, arp->ar_sha, ETH_ALEN);
708 memcpy(&key->ipv4.addr.src, arp->ar_sip, sizeof(key->ipv4.addr.src)); 708 memcpy(key->ipv4.arp.tha, arp->ar_tha, ETH_ALEN);
709 memcpy(&key->ipv4.addr.dst, arp->ar_tip, sizeof(key->ipv4.addr.dst)); 709 key_len = SW_FLOW_KEY_OFFSET(ipv4.arp);
710 memcpy(key->ipv4.arp.sha, arp->ar_sha, ETH_ALEN);
711 memcpy(key->ipv4.arp.tha, arp->ar_tha, ETH_ALEN);
712 key_len = SW_FLOW_KEY_OFFSET(ipv4.arp);
713 }
714 } 710 }
715 } else if (key->eth.type == htons(ETH_P_IPV6)) { 711 } else if (key->eth.type == htons(ETH_P_IPV6)) {
716 int nh_len; /* IPv6 Header + Extensions */ 712 int nh_len; /* IPv6 Header + Extensions */
diff --git a/net/openvswitch/vport-netdev.c b/net/openvswitch/vport-netdev.c
index 3c1e58ba714b..a9033481fa5e 100644
--- a/net/openvswitch/vport-netdev.c
+++ b/net/openvswitch/vport-netdev.c
@@ -158,7 +158,7 @@ static int netdev_send(struct vport *vport, struct sk_buff *skb)
158 158
159 if (unlikely(packet_length(skb) > mtu && !skb_is_gso(skb))) { 159 if (unlikely(packet_length(skb) > mtu && !skb_is_gso(skb))) {
160 net_warn_ratelimited("%s: dropped over-mtu packet: %d > %d\n", 160 net_warn_ratelimited("%s: dropped over-mtu packet: %d > %d\n",
161 ovs_dp_name(vport->dp), 161 netdev_vport->dev->name,
162 packet_length(skb), mtu); 162 packet_length(skb), mtu);
163 goto error; 163 goto error;
164 } 164 }
diff --git a/net/sctp/chunk.c b/net/sctp/chunk.c
index 7c2df9c33df3..69ce21e3716f 100644
--- a/net/sctp/chunk.c
+++ b/net/sctp/chunk.c
@@ -183,7 +183,7 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
183 183
184 msg = sctp_datamsg_new(GFP_KERNEL); 184 msg = sctp_datamsg_new(GFP_KERNEL);
185 if (!msg) 185 if (!msg)
186 return NULL; 186 return ERR_PTR(-ENOMEM);
187 187
188 /* Note: Calculate this outside of the loop, so that all fragments 188 /* Note: Calculate this outside of the loop, so that all fragments
189 * have the same expiration. 189 * have the same expiration.
@@ -280,11 +280,14 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
280 280
281 chunk = sctp_make_datafrag_empty(asoc, sinfo, len, frag, 0); 281 chunk = sctp_make_datafrag_empty(asoc, sinfo, len, frag, 0);
282 282
283 if (!chunk) 283 if (!chunk) {
284 err = -ENOMEM;
284 goto errout; 285 goto errout;
286 }
287
285 err = sctp_user_addto_chunk(chunk, offset, len, msgh->msg_iov); 288 err = sctp_user_addto_chunk(chunk, offset, len, msgh->msg_iov);
286 if (err < 0) 289 if (err < 0)
287 goto errout; 290 goto errout_chunk_free;
288 291
289 offset += len; 292 offset += len;
290 293
@@ -315,8 +318,10 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
315 318
316 chunk = sctp_make_datafrag_empty(asoc, sinfo, over, frag, 0); 319 chunk = sctp_make_datafrag_empty(asoc, sinfo, over, frag, 0);
317 320
318 if (!chunk) 321 if (!chunk) {
322 err = -ENOMEM;
319 goto errout; 323 goto errout;
324 }
320 325
321 err = sctp_user_addto_chunk(chunk, offset, over,msgh->msg_iov); 326 err = sctp_user_addto_chunk(chunk, offset, over,msgh->msg_iov);
322 327
@@ -324,7 +329,7 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
324 __skb_pull(chunk->skb, (__u8 *)chunk->chunk_hdr 329 __skb_pull(chunk->skb, (__u8 *)chunk->chunk_hdr
325 - (__u8 *)chunk->skb->data); 330 - (__u8 *)chunk->skb->data);
326 if (err < 0) 331 if (err < 0)
327 goto errout; 332 goto errout_chunk_free;
328 333
329 sctp_datamsg_assign(msg, chunk); 334 sctp_datamsg_assign(msg, chunk);
330 list_add_tail(&chunk->frag_list, &msg->chunks); 335 list_add_tail(&chunk->frag_list, &msg->chunks);
@@ -332,6 +337,9 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
332 337
333 return msg; 338 return msg;
334 339
340errout_chunk_free:
341 sctp_chunk_free(chunk);
342
335errout: 343errout:
336 list_for_each_safe(pos, temp, &msg->chunks) { 344 list_for_each_safe(pos, temp, &msg->chunks) {
337 list_del_init(pos); 345 list_del_init(pos);
@@ -339,7 +347,7 @@ errout:
339 sctp_chunk_free(chunk); 347 sctp_chunk_free(chunk);
340 } 348 }
341 sctp_datamsg_put(msg); 349 sctp_datamsg_put(msg);
342 return NULL; 350 return ERR_PTR(err);
343} 351}
344 352
345/* Check whether this message has expired. */ 353/* Check whether this message has expired. */
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index a60d1f8b41c5..406d957d08fb 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1915,8 +1915,8 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
1915 1915
1916 /* Break the message into multiple chunks of maximum size. */ 1916 /* Break the message into multiple chunks of maximum size. */
1917 datamsg = sctp_datamsg_from_user(asoc, sinfo, msg, msg_len); 1917 datamsg = sctp_datamsg_from_user(asoc, sinfo, msg, msg_len);
1918 if (!datamsg) { 1918 if (IS_ERR(datamsg)) {
1919 err = -ENOMEM; 1919 err = PTR_ERR(datamsg);
1920 goto out_free; 1920 goto out_free;
1921 } 1921 }
1922 1922
diff --git a/net/sctp/transport.c b/net/sctp/transport.c
index 953c21e4af97..206cf5238fd3 100644
--- a/net/sctp/transport.c
+++ b/net/sctp/transport.c
@@ -331,7 +331,7 @@ void sctp_transport_update_rto(struct sctp_transport *tp, __u32 rtt)
331 * 1/8, rto_alpha would be expressed as 3. 331 * 1/8, rto_alpha would be expressed as 3.
332 */ 332 */
333 tp->rttvar = tp->rttvar - (tp->rttvar >> net->sctp.rto_beta) 333 tp->rttvar = tp->rttvar - (tp->rttvar >> net->sctp.rto_beta)
334 + ((abs(tp->srtt - rtt)) >> net->sctp.rto_beta); 334 + (((__u32)abs64((__s64)tp->srtt - (__s64)rtt)) >> net->sctp.rto_beta);
335 tp->srtt = tp->srtt - (tp->srtt >> net->sctp.rto_alpha) 335 tp->srtt = tp->srtt - (tp->srtt >> net->sctp.rto_alpha)
336 + (rtt >> net->sctp.rto_alpha); 336 + (rtt >> net->sctp.rto_alpha);
337 } else { 337 } else {
diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
index 239d22d4207b..6c353ae8a451 100644
--- a/scripts/headers_install.pl
+++ b/scripts/headers_install.pl
@@ -42,6 +42,9 @@ foreach my $filename (@files) {
42 $line =~ s/(^|\s)(inline)\b/$1__$2__/g; 42 $line =~ s/(^|\s)(inline)\b/$1__$2__/g;
43 $line =~ s/(^|\s)(asm)\b(\s|[(]|$)/$1__$2__$3/g; 43 $line =~ s/(^|\s)(asm)\b(\s|[(]|$)/$1__$2__$3/g;
44 $line =~ s/(^|\s|[(])(volatile)\b(\s|[(]|$)/$1__$2__$3/g; 44 $line =~ s/(^|\s|[(])(volatile)\b(\s|[(]|$)/$1__$2__$3/g;
45 $line =~ s/#ifndef _UAPI/#ifndef /;
46 $line =~ s/#define _UAPI/#define /;
47 $line =~ s!#endif /[*] _UAPI!#endif /* !;
45 printf {$out} "%s", $line; 48 printf {$out} "%s", $line;
46 } 49 }
47 close $out; 50 close $out;
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 967d0e173e1b..5fbfb06e8083 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -113,7 +113,7 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
113 SNDRV_PCM_STREAM_PLAYBACK, 113 SNDRV_PCM_STREAM_PLAYBACK,
114 SND_SOC_DAPM_STREAM_STOP); 114 SND_SOC_DAPM_STREAM_STOP);
115 } else 115 } else
116 codec_dai->pop_wait = 1; 116 rtd->pop_wait = 1;
117 schedule_delayed_work(&rtd->delayed_work, 117 schedule_delayed_work(&rtd->delayed_work,
118 msecs_to_jiffies(rtd->pmdown_time)); 118 msecs_to_jiffies(rtd->pmdown_time));
119 } else { 119 } else {
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 5c3ca2a34661..d7711fce119b 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -334,11 +334,11 @@ static void close_delayed_work(struct work_struct *work)
334 dev_dbg(rtd->dev, "ASoC: pop wq checking: %s status: %s waiting: %s\n", 334 dev_dbg(rtd->dev, "ASoC: pop wq checking: %s status: %s waiting: %s\n",
335 codec_dai->driver->playback.stream_name, 335 codec_dai->driver->playback.stream_name,
336 codec_dai->playback_active ? "active" : "inactive", 336 codec_dai->playback_active ? "active" : "inactive",
337 codec_dai->pop_wait ? "yes" : "no"); 337 rtd->pop_wait ? "yes" : "no");
338 338
339 /* are we waiting on this codec DAI stream */ 339 /* are we waiting on this codec DAI stream */
340 if (codec_dai->pop_wait == 1) { 340 if (rtd->pop_wait == 1) {
341 codec_dai->pop_wait = 0; 341 rtd->pop_wait = 0;
342 snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_PLAYBACK, 342 snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_PLAYBACK,
343 SND_SOC_DAPM_STREAM_STOP); 343 SND_SOC_DAPM_STREAM_STOP);
344 } 344 }
@@ -408,7 +408,7 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
408 SND_SOC_DAPM_STREAM_STOP); 408 SND_SOC_DAPM_STREAM_STOP);
409 } else { 409 } else {
410 /* start delayed pop wq here for playback streams */ 410 /* start delayed pop wq here for playback streams */
411 codec_dai->pop_wait = 1; 411 rtd->pop_wait = 1;
412 schedule_delayed_work(&rtd->delayed_work, 412 schedule_delayed_work(&rtd->delayed_work,
413 msecs_to_jiffies(rtd->pmdown_time)); 413 msecs_to_jiffies(rtd->pmdown_time));
414 } 414 }
@@ -480,8 +480,8 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
480 480
481 /* cancel any delayed stream shutdown that is pending */ 481 /* cancel any delayed stream shutdown that is pending */
482 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && 482 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
483 codec_dai->pop_wait) { 483 rtd->pop_wait) {
484 codec_dai->pop_wait = 0; 484 rtd->pop_wait = 0;
485 cancel_delayed_work(&rtd->delayed_work); 485 cancel_delayed_work(&rtd->delayed_work);
486 } 486 }
487 487
diff --git a/tools/Makefile b/tools/Makefile
index 3ae43947a171..1f9a529fe544 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -31,44 +31,44 @@ help:
31 @echo ' clean: a summary clean target to clean _all_ folders' 31 @echo ' clean: a summary clean target to clean _all_ folders'
32 32
33cpupower: FORCE 33cpupower: FORCE
34 $(QUIET_SUBDIR0)power/$@/ $(QUIET_SUBDIR1) 34 $(call descend,power/$@)
35 35
36firewire lguest perf usb virtio vm: FORCE 36firewire lguest perf usb virtio vm: FORCE
37 $(QUIET_SUBDIR0)$@/ $(QUIET_SUBDIR1) 37 $(call descend,$@)
38 38
39selftests: FORCE 39selftests: FORCE
40 $(QUIET_SUBDIR0)testing/$@/ $(QUIET_SUBDIR1) 40 $(call descend,testing/$@)
41 41
42turbostat x86_energy_perf_policy: FORCE 42turbostat x86_energy_perf_policy: FORCE
43 $(QUIET_SUBDIR0)power/x86/$@/ $(QUIET_SUBDIR1) 43 $(call descend,power/x86/$@)
44 44
45cpupower_install: 45cpupower_install:
46 $(QUIET_SUBDIR0)power/$(@:_install=)/ $(QUIET_SUBDIR1) install 46 $(call descend,power/$(@:_install=),install)
47 47
48firewire_install lguest_install perf_install usb_install virtio_install vm_install: 48firewire_install lguest_install perf_install usb_install virtio_install vm_install:
49 $(QUIET_SUBDIR0)$(@:_install=)/ $(QUIET_SUBDIR1) install 49 $(call descend,$(@:_install=),install)
50 50
51selftests_install: 51selftests_install:
52 $(QUIET_SUBDIR0)testing/$(@:_clean=)/ $(QUIET_SUBDIR1) install 52 $(call descend,testing/$(@:_clean=),install)
53 53
54turbostat_install x86_energy_perf_policy_install: 54turbostat_install x86_energy_perf_policy_install:
55 $(QUIET_SUBDIR0)power/x86/$(@:_install=)/ $(QUIET_SUBDIR1) install 55 $(call descend,power/x86/$(@:_install=),install)
56 56
57install: cpupower_install firewire_install lguest_install perf_install \ 57install: cpupower_install firewire_install lguest_install perf_install \
58 selftests_install turbostat_install usb_install virtio_install \ 58 selftests_install turbostat_install usb_install virtio_install \
59 vm_install x86_energy_perf_policy_install 59 vm_install x86_energy_perf_policy_install
60 60
61cpupower_clean: 61cpupower_clean:
62 $(QUIET_SUBDIR0)power/cpupower/ $(QUIET_SUBDIR1) clean 62 $(call descend,power/cpupower,clean)
63 63
64firewire_clean lguest_clean perf_clean usb_clean virtio_clean vm_clean: 64firewire_clean lguest_clean perf_clean usb_clean virtio_clean vm_clean:
65 $(QUIET_SUBDIR0)$(@:_clean=)/ $(QUIET_SUBDIR1) clean 65 $(call descend,$(@:_clean=),clean)
66 66
67selftests_clean: 67selftests_clean:
68 $(QUIET_SUBDIR0)testing/$(@:_clean=)/ $(QUIET_SUBDIR1) clean 68 $(call descend,testing/$(@:_clean=),clean)
69 69
70turbostat_clean x86_energy_perf_policy_clean: 70turbostat_clean x86_energy_perf_policy_clean:
71 $(QUIET_SUBDIR0)power/x86/$(@:_clean=)/ $(QUIET_SUBDIR1) clean 71 $(call descend,power/x86/$(@:_clean=),clean)
72 72
73clean: cpupower_clean firewire_clean lguest_clean perf_clean selftests_clean \ 73clean: cpupower_clean firewire_clean lguest_clean perf_clean selftests_clean \
74 turbostat_clean usb_clean virtio_clean vm_clean \ 74 turbostat_clean usb_clean virtio_clean vm_clean \
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 00deed4d6159..0a619af5be43 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -169,7 +169,34 @@ endif
169 169
170### --- END CONFIGURATION SECTION --- 170### --- END CONFIGURATION SECTION ---
171 171
172BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include -I$(OUTPUT)util -I$(TRACE_EVENT_DIR) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 172ifeq ($(srctree),)
173srctree := $(patsubst %/,%,$(dir $(shell pwd)))
174srctree := $(patsubst %/,%,$(dir $(srctree)))
175#$(info Determined 'srctree' to be $(srctree))
176endif
177
178ifneq ($(objtree),)
179#$(info Determined 'objtree' to be $(objtree))
180endif
181
182ifneq ($(OUTPUT),)
183#$(info Determined 'OUTPUT' to be $(OUTPUT))
184endif
185
186BASIC_CFLAGS = \
187 -Iutil/include \
188 -Iarch/$(ARCH)/include \
189 $(if $(objtree),-I$(objtree)/arch/$(ARCH)/include/generated/uapi) \
190 -I$(srctree)/arch/$(ARCH)/include/uapi \
191 -I$(srctree)/arch/$(ARCH)/include \
192 $(if $(objtree),-I$(objtree)/include/generated/uapi) \
193 -I$(srctree)/include/uapi \
194 -I$(srctree)/include \
195 -I$(OUTPUT)util \
196 -Iutil \
197 -I. \
198 -I$(TRACE_EVENT_DIR) \
199 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
173BASIC_LDFLAGS = 200BASIC_LDFLAGS =
174 201
175# Guard against environment variables 202# Guard against environment variables
diff --git a/tools/perf/arch/x86/include/perf_regs.h b/tools/perf/arch/x86/include/perf_regs.h
index 46fc9f15c6b3..7fcdcdbee917 100644
--- a/tools/perf/arch/x86/include/perf_regs.h
+++ b/tools/perf/arch/x86/include/perf_regs.h
@@ -3,7 +3,7 @@
3 3
4#include <stdlib.h> 4#include <stdlib.h>
5#include "../../util/types.h" 5#include "../../util/types.h"
6#include "../../../../../arch/x86/include/asm/perf_regs.h" 6#include <asm/perf_regs.h>
7 7
8#ifndef ARCH_X86_64 8#ifndef ARCH_X86_64
9#define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1) 9#define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1)
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 260abc535b5b..283b4397e397 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -22,9 +22,10 @@
22#include <pthread.h> 22#include <pthread.h>
23#include <math.h> 23#include <math.h>
24 24
25#include "../../arch/x86/include/asm/svm.h" 25#if defined(__i386__) || defined(__x86_64__)
26#include "../../arch/x86/include/asm/vmx.h" 26#include <asm/svm.h>
27#include "../../arch/x86/include/asm/kvm.h" 27#include <asm/vmx.h>
28#include <asm/kvm.h>
28 29
29struct event_key { 30struct event_key {
30 #define INVALID_KEY (~0ULL) 31 #define INVALID_KEY (~0ULL)
@@ -58,7 +59,7 @@ struct kvm_event_key {
58}; 59};
59 60
60 61
61struct perf_kvm; 62struct perf_kvm_stat;
62 63
63struct kvm_events_ops { 64struct kvm_events_ops {
64 bool (*is_begin_event)(struct perf_evsel *evsel, 65 bool (*is_begin_event)(struct perf_evsel *evsel,
@@ -66,7 +67,7 @@ struct kvm_events_ops {
66 struct event_key *key); 67 struct event_key *key);
67 bool (*is_end_event)(struct perf_evsel *evsel, 68 bool (*is_end_event)(struct perf_evsel *evsel,
68 struct perf_sample *sample, struct event_key *key); 69 struct perf_sample *sample, struct event_key *key);
69 void (*decode_key)(struct perf_kvm *kvm, struct event_key *key, 70 void (*decode_key)(struct perf_kvm_stat *kvm, struct event_key *key,
70 char decode[20]); 71 char decode[20]);
71 const char *name; 72 const char *name;
72}; 73};
@@ -79,7 +80,7 @@ struct exit_reasons_table {
79#define EVENTS_BITS 12 80#define EVENTS_BITS 12
80#define EVENTS_CACHE_SIZE (1UL << EVENTS_BITS) 81#define EVENTS_CACHE_SIZE (1UL << EVENTS_BITS)
81 82
82struct perf_kvm { 83struct perf_kvm_stat {
83 struct perf_tool tool; 84 struct perf_tool tool;
84 struct perf_session *session; 85 struct perf_session *session;
85 86
@@ -146,7 +147,7 @@ static struct exit_reasons_table svm_exit_reasons[] = {
146 SVM_EXIT_REASONS 147 SVM_EXIT_REASONS
147}; 148};
148 149
149static const char *get_exit_reason(struct perf_kvm *kvm, u64 exit_code) 150static const char *get_exit_reason(struct perf_kvm_stat *kvm, u64 exit_code)
150{ 151{
151 int i = kvm->exit_reasons_size; 152 int i = kvm->exit_reasons_size;
152 struct exit_reasons_table *tbl = kvm->exit_reasons; 153 struct exit_reasons_table *tbl = kvm->exit_reasons;
@@ -162,7 +163,7 @@ static const char *get_exit_reason(struct perf_kvm *kvm, u64 exit_code)
162 return "UNKNOWN"; 163 return "UNKNOWN";
163} 164}
164 165
165static void exit_event_decode_key(struct perf_kvm *kvm, 166static void exit_event_decode_key(struct perf_kvm_stat *kvm,
166 struct event_key *key, 167 struct event_key *key,
167 char decode[20]) 168 char decode[20])
168{ 169{
@@ -228,7 +229,7 @@ static bool mmio_event_end(struct perf_evsel *evsel, struct perf_sample *sample,
228 return false; 229 return false;
229} 230}
230 231
231static void mmio_event_decode_key(struct perf_kvm *kvm __maybe_unused, 232static void mmio_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused,
232 struct event_key *key, 233 struct event_key *key,
233 char decode[20]) 234 char decode[20])
234{ 235{
@@ -271,7 +272,7 @@ static bool ioport_event_end(struct perf_evsel *evsel,
271 return kvm_entry_event(evsel); 272 return kvm_entry_event(evsel);
272} 273}
273 274
274static void ioport_event_decode_key(struct perf_kvm *kvm __maybe_unused, 275static void ioport_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused,
275 struct event_key *key, 276 struct event_key *key,
276 char decode[20]) 277 char decode[20])
277{ 278{
@@ -286,7 +287,7 @@ static struct kvm_events_ops ioport_events = {
286 .name = "IO Port Access" 287 .name = "IO Port Access"
287}; 288};
288 289
289static bool register_kvm_events_ops(struct perf_kvm *kvm) 290static bool register_kvm_events_ops(struct perf_kvm_stat *kvm)
290{ 291{
291 bool ret = true; 292 bool ret = true;
292 293
@@ -311,7 +312,7 @@ struct vcpu_event_record {
311}; 312};
312 313
313 314
314static void init_kvm_event_record(struct perf_kvm *kvm) 315static void init_kvm_event_record(struct perf_kvm_stat *kvm)
315{ 316{
316 int i; 317 int i;
317 318
@@ -360,7 +361,7 @@ static struct kvm_event *kvm_alloc_init_event(struct event_key *key)
360 return event; 361 return event;
361} 362}
362 363
363static struct kvm_event *find_create_kvm_event(struct perf_kvm *kvm, 364static struct kvm_event *find_create_kvm_event(struct perf_kvm_stat *kvm,
364 struct event_key *key) 365 struct event_key *key)
365{ 366{
366 struct kvm_event *event; 367 struct kvm_event *event;
@@ -381,7 +382,7 @@ static struct kvm_event *find_create_kvm_event(struct perf_kvm *kvm,
381 return event; 382 return event;
382} 383}
383 384
384static bool handle_begin_event(struct perf_kvm *kvm, 385static bool handle_begin_event(struct perf_kvm_stat *kvm,
385 struct vcpu_event_record *vcpu_record, 386 struct vcpu_event_record *vcpu_record,
386 struct event_key *key, u64 timestamp) 387 struct event_key *key, u64 timestamp)
387{ 388{
@@ -425,7 +426,7 @@ static bool update_kvm_event(struct kvm_event *event, int vcpu_id,
425 return true; 426 return true;
426} 427}
427 428
428static bool handle_end_event(struct perf_kvm *kvm, 429static bool handle_end_event(struct perf_kvm_stat *kvm,
429 struct vcpu_event_record *vcpu_record, 430 struct vcpu_event_record *vcpu_record,
430 struct event_key *key, 431 struct event_key *key,
431 u64 timestamp) 432 u64 timestamp)
@@ -486,7 +487,7 @@ struct vcpu_event_record *per_vcpu_record(struct thread *thread,
486 return thread->priv; 487 return thread->priv;
487} 488}
488 489
489static bool handle_kvm_event(struct perf_kvm *kvm, 490static bool handle_kvm_event(struct perf_kvm_stat *kvm,
490 struct thread *thread, 491 struct thread *thread,
491 struct perf_evsel *evsel, 492 struct perf_evsel *evsel,
492 struct perf_sample *sample) 493 struct perf_sample *sample)
@@ -541,7 +542,7 @@ static struct kvm_event_key keys[] = {
541 { NULL, NULL } 542 { NULL, NULL }
542}; 543};
543 544
544static bool select_key(struct perf_kvm *kvm) 545static bool select_key(struct perf_kvm_stat *kvm)
545{ 546{
546 int i; 547 int i;
547 548
@@ -577,7 +578,8 @@ static void insert_to_result(struct rb_root *result, struct kvm_event *event,
577 rb_insert_color(&event->rb, result); 578 rb_insert_color(&event->rb, result);
578} 579}
579 580
580static void update_total_count(struct perf_kvm *kvm, struct kvm_event *event) 581static void
582update_total_count(struct perf_kvm_stat *kvm, struct kvm_event *event)
581{ 583{
582 int vcpu = kvm->trace_vcpu; 584 int vcpu = kvm->trace_vcpu;
583 585
@@ -590,7 +592,7 @@ static bool event_is_valid(struct kvm_event *event, int vcpu)
590 return !!get_event_count(event, vcpu); 592 return !!get_event_count(event, vcpu);
591} 593}
592 594
593static void sort_result(struct perf_kvm *kvm) 595static void sort_result(struct perf_kvm_stat *kvm)
594{ 596{
595 unsigned int i; 597 unsigned int i;
596 int vcpu = kvm->trace_vcpu; 598 int vcpu = kvm->trace_vcpu;
@@ -627,7 +629,7 @@ static void print_vcpu_info(int vcpu)
627 pr_info("VCPU %d:\n\n", vcpu); 629 pr_info("VCPU %d:\n\n", vcpu);
628} 630}
629 631
630static void print_result(struct perf_kvm *kvm) 632static void print_result(struct perf_kvm_stat *kvm)
631{ 633{
632 char decode[20]; 634 char decode[20];
633 struct kvm_event *event; 635 struct kvm_event *event;
@@ -670,7 +672,8 @@ static int process_sample_event(struct perf_tool *tool,
670 struct machine *machine) 672 struct machine *machine)
671{ 673{
672 struct thread *thread = machine__findnew_thread(machine, sample->tid); 674 struct thread *thread = machine__findnew_thread(machine, sample->tid);
673 struct perf_kvm *kvm = container_of(tool, struct perf_kvm, tool); 675 struct perf_kvm_stat *kvm = container_of(tool, struct perf_kvm_stat,
676 tool);
674 677
675 if (thread == NULL) { 678 if (thread == NULL) {
676 pr_debug("problem processing %d event, skipping it.\n", 679 pr_debug("problem processing %d event, skipping it.\n",
@@ -701,7 +704,7 @@ static int get_cpu_isa(struct perf_session *session)
701 return isa; 704 return isa;
702} 705}
703 706
704static int read_events(struct perf_kvm *kvm) 707static int read_events(struct perf_kvm_stat *kvm)
705{ 708{
706 int ret; 709 int ret;
707 710
@@ -750,7 +753,7 @@ static bool verify_vcpu(int vcpu)
750 return true; 753 return true;
751} 754}
752 755
753static int kvm_events_report_vcpu(struct perf_kvm *kvm) 756static int kvm_events_report_vcpu(struct perf_kvm_stat *kvm)
754{ 757{
755 int ret = -EINVAL; 758 int ret = -EINVAL;
756 int vcpu = kvm->trace_vcpu; 759 int vcpu = kvm->trace_vcpu;
@@ -798,7 +801,8 @@ static const char * const record_args[] = {
798 _p; \ 801 _p; \
799 }) 802 })
800 803
801static int kvm_events_record(struct perf_kvm *kvm, int argc, const char **argv) 804static int
805kvm_events_record(struct perf_kvm_stat *kvm, int argc, const char **argv)
802{ 806{
803 unsigned int rec_argc, i, j; 807 unsigned int rec_argc, i, j;
804 const char **rec_argv; 808 const char **rec_argv;
@@ -821,7 +825,8 @@ static int kvm_events_record(struct perf_kvm *kvm, int argc, const char **argv)
821 return cmd_record(i, rec_argv, NULL); 825 return cmd_record(i, rec_argv, NULL);
822} 826}
823 827
824static int kvm_events_report(struct perf_kvm *kvm, int argc, const char **argv) 828static int
829kvm_events_report(struct perf_kvm_stat *kvm, int argc, const char **argv)
825{ 830{
826 const struct option kvm_events_report_options[] = { 831 const struct option kvm_events_report_options[] = {
827 OPT_STRING(0, "event", &kvm->report_event, "report event", 832 OPT_STRING(0, "event", &kvm->report_event, "report event",
@@ -864,24 +869,37 @@ static void print_kvm_stat_usage(void)
864 printf("\nOtherwise, it is the alias of 'perf stat':\n"); 869 printf("\nOtherwise, it is the alias of 'perf stat':\n");
865} 870}
866 871
867static int kvm_cmd_stat(struct perf_kvm *kvm, int argc, const char **argv) 872static int kvm_cmd_stat(const char *file_name, int argc, const char **argv)
868{ 873{
874 struct perf_kvm_stat kvm = {
875 .file_name = file_name,
876
877 .trace_vcpu = -1,
878 .report_event = "vmexit",
879 .sort_key = "sample",
880
881 .exit_reasons = svm_exit_reasons,
882 .exit_reasons_size = ARRAY_SIZE(svm_exit_reasons),
883 .exit_reasons_isa = "SVM",
884 };
885
869 if (argc == 1) { 886 if (argc == 1) {
870 print_kvm_stat_usage(); 887 print_kvm_stat_usage();
871 goto perf_stat; 888 goto perf_stat;
872 } 889 }
873 890
874 if (!strncmp(argv[1], "rec", 3)) 891 if (!strncmp(argv[1], "rec", 3))
875 return kvm_events_record(kvm, argc - 1, argv + 1); 892 return kvm_events_record(&kvm, argc - 1, argv + 1);
876 893
877 if (!strncmp(argv[1], "rep", 3)) 894 if (!strncmp(argv[1], "rep", 3))
878 return kvm_events_report(kvm, argc - 1 , argv + 1); 895 return kvm_events_report(&kvm, argc - 1 , argv + 1);
879 896
880perf_stat: 897perf_stat:
881 return cmd_stat(argc, argv, NULL); 898 return cmd_stat(argc, argv, NULL);
882} 899}
900#endif
883 901
884static int __cmd_record(struct perf_kvm *kvm, int argc, const char **argv) 902static int __cmd_record(const char *file_name, int argc, const char **argv)
885{ 903{
886 int rec_argc, i = 0, j; 904 int rec_argc, i = 0, j;
887 const char **rec_argv; 905 const char **rec_argv;
@@ -890,7 +908,7 @@ static int __cmd_record(struct perf_kvm *kvm, int argc, const char **argv)
890 rec_argv = calloc(rec_argc + 1, sizeof(char *)); 908 rec_argv = calloc(rec_argc + 1, sizeof(char *));
891 rec_argv[i++] = strdup("record"); 909 rec_argv[i++] = strdup("record");
892 rec_argv[i++] = strdup("-o"); 910 rec_argv[i++] = strdup("-o");
893 rec_argv[i++] = strdup(kvm->file_name); 911 rec_argv[i++] = strdup(file_name);
894 for (j = 1; j < argc; j++, i++) 912 for (j = 1; j < argc; j++, i++)
895 rec_argv[i] = argv[j]; 913 rec_argv[i] = argv[j];
896 914
@@ -899,7 +917,7 @@ static int __cmd_record(struct perf_kvm *kvm, int argc, const char **argv)
899 return cmd_record(i, rec_argv, NULL); 917 return cmd_record(i, rec_argv, NULL);
900} 918}
901 919
902static int __cmd_report(struct perf_kvm *kvm, int argc, const char **argv) 920static int __cmd_report(const char *file_name, int argc, const char **argv)
903{ 921{
904 int rec_argc, i = 0, j; 922 int rec_argc, i = 0, j;
905 const char **rec_argv; 923 const char **rec_argv;
@@ -908,7 +926,7 @@ static int __cmd_report(struct perf_kvm *kvm, int argc, const char **argv)
908 rec_argv = calloc(rec_argc + 1, sizeof(char *)); 926 rec_argv = calloc(rec_argc + 1, sizeof(char *));
909 rec_argv[i++] = strdup("report"); 927 rec_argv[i++] = strdup("report");
910 rec_argv[i++] = strdup("-i"); 928 rec_argv[i++] = strdup("-i");
911 rec_argv[i++] = strdup(kvm->file_name); 929 rec_argv[i++] = strdup(file_name);
912 for (j = 1; j < argc; j++, i++) 930 for (j = 1; j < argc; j++, i++)
913 rec_argv[i] = argv[j]; 931 rec_argv[i] = argv[j];
914 932
@@ -917,7 +935,8 @@ static int __cmd_report(struct perf_kvm *kvm, int argc, const char **argv)
917 return cmd_report(i, rec_argv, NULL); 935 return cmd_report(i, rec_argv, NULL);
918} 936}
919 937
920static int __cmd_buildid_list(struct perf_kvm *kvm, int argc, const char **argv) 938static int
939__cmd_buildid_list(const char *file_name, int argc, const char **argv)
921{ 940{
922 int rec_argc, i = 0, j; 941 int rec_argc, i = 0, j;
923 const char **rec_argv; 942 const char **rec_argv;
@@ -926,7 +945,7 @@ static int __cmd_buildid_list(struct perf_kvm *kvm, int argc, const char **argv)
926 rec_argv = calloc(rec_argc + 1, sizeof(char *)); 945 rec_argv = calloc(rec_argc + 1, sizeof(char *));
927 rec_argv[i++] = strdup("buildid-list"); 946 rec_argv[i++] = strdup("buildid-list");
928 rec_argv[i++] = strdup("-i"); 947 rec_argv[i++] = strdup("-i");
929 rec_argv[i++] = strdup(kvm->file_name); 948 rec_argv[i++] = strdup(file_name);
930 for (j = 1; j < argc; j++, i++) 949 for (j = 1; j < argc; j++, i++)
931 rec_argv[i] = argv[j]; 950 rec_argv[i] = argv[j];
932 951
@@ -937,20 +956,12 @@ static int __cmd_buildid_list(struct perf_kvm *kvm, int argc, const char **argv)
937 956
938int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused) 957int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused)
939{ 958{
940 struct perf_kvm kvm = { 959 const char *file_name;
941 .trace_vcpu = -1,
942 .report_event = "vmexit",
943 .sort_key = "sample",
944
945 .exit_reasons = svm_exit_reasons,
946 .exit_reasons_size = ARRAY_SIZE(svm_exit_reasons),
947 .exit_reasons_isa = "SVM",
948 };
949 960
950 const struct option kvm_options[] = { 961 const struct option kvm_options[] = {
951 OPT_STRING('i', "input", &kvm.file_name, "file", 962 OPT_STRING('i', "input", &file_name, "file",
952 "Input file name"), 963 "Input file name"),
953 OPT_STRING('o', "output", &kvm.file_name, "file", 964 OPT_STRING('o', "output", &file_name, "file",
954 "Output file name"), 965 "Output file name"),
955 OPT_BOOLEAN(0, "guest", &perf_guest, 966 OPT_BOOLEAN(0, "guest", &perf_guest,
956 "Collect guest os data"), 967 "Collect guest os data"),
@@ -985,32 +996,34 @@ int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused)
985 if (!perf_host) 996 if (!perf_host)
986 perf_guest = 1; 997 perf_guest = 1;
987 998
988 if (!kvm.file_name) { 999 if (!file_name) {
989 if (perf_host && !perf_guest) 1000 if (perf_host && !perf_guest)
990 kvm.file_name = strdup("perf.data.host"); 1001 file_name = strdup("perf.data.host");
991 else if (!perf_host && perf_guest) 1002 else if (!perf_host && perf_guest)
992 kvm.file_name = strdup("perf.data.guest"); 1003 file_name = strdup("perf.data.guest");
993 else 1004 else
994 kvm.file_name = strdup("perf.data.kvm"); 1005 file_name = strdup("perf.data.kvm");
995 1006
996 if (!kvm.file_name) { 1007 if (!file_name) {
997 pr_err("Failed to allocate memory for filename\n"); 1008 pr_err("Failed to allocate memory for filename\n");
998 return -ENOMEM; 1009 return -ENOMEM;
999 } 1010 }
1000 } 1011 }
1001 1012
1002 if (!strncmp(argv[0], "rec", 3)) 1013 if (!strncmp(argv[0], "rec", 3))
1003 return __cmd_record(&kvm, argc, argv); 1014 return __cmd_record(file_name, argc, argv);
1004 else if (!strncmp(argv[0], "rep", 3)) 1015 else if (!strncmp(argv[0], "rep", 3))
1005 return __cmd_report(&kvm, argc, argv); 1016 return __cmd_report(file_name, argc, argv);
1006 else if (!strncmp(argv[0], "diff", 4)) 1017 else if (!strncmp(argv[0], "diff", 4))
1007 return cmd_diff(argc, argv, NULL); 1018 return cmd_diff(argc, argv, NULL);
1008 else if (!strncmp(argv[0], "top", 3)) 1019 else if (!strncmp(argv[0], "top", 3))
1009 return cmd_top(argc, argv, NULL); 1020 return cmd_top(argc, argv, NULL);
1010 else if (!strncmp(argv[0], "buildid-list", 12)) 1021 else if (!strncmp(argv[0], "buildid-list", 12))
1011 return __cmd_buildid_list(&kvm, argc, argv); 1022 return __cmd_buildid_list(file_name, argc, argv);
1023#if defined(__i386__) || defined(__x86_64__)
1012 else if (!strncmp(argv[0], "stat", 4)) 1024 else if (!strncmp(argv[0], "stat", 4))
1013 return kvm_cmd_stat(&kvm, argc, argv); 1025 return kvm_cmd_stat(file_name, argc, argv);
1026#endif
1014 else 1027 else
1015 usage_with_options(kvm_usage, kvm_options); 1028 usage_with_options(kvm_usage, kvm_options);
1016 1029
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c
index 484f26cc0c00..5acd6e8e658b 100644
--- a/tools/perf/builtin-test.c
+++ b/tools/perf/builtin-test.c
@@ -15,7 +15,7 @@
15#include "util/thread_map.h" 15#include "util/thread_map.h"
16#include "util/pmu.h" 16#include "util/pmu.h"
17#include "event-parse.h" 17#include "event-parse.h"
18#include "../../include/linux/hw_breakpoint.h" 18#include <linux/hw_breakpoint.h>
19 19
20#include <sys/mman.h> 20#include <sys/mman.h>
21 21
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index c50985eaec41..238f923f2218 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -5,8 +5,9 @@ struct winsize;
5 5
6void get_term_dimensions(struct winsize *ws); 6void get_term_dimensions(struct winsize *ws);
7 7
8#include <asm/unistd.h>
9
8#if defined(__i386__) 10#if defined(__i386__)
9#include "../../arch/x86/include/asm/unistd.h"
10#define rmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory") 11#define rmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory")
11#define cpu_relax() asm volatile("rep; nop" ::: "memory"); 12#define cpu_relax() asm volatile("rep; nop" ::: "memory");
12#define CPUINFO_PROC "model name" 13#define CPUINFO_PROC "model name"
@@ -16,7 +17,6 @@ void get_term_dimensions(struct winsize *ws);
16#endif 17#endif
17 18
18#if defined(__x86_64__) 19#if defined(__x86_64__)
19#include "../../arch/x86/include/asm/unistd.h"
20#define rmb() asm volatile("lfence" ::: "memory") 20#define rmb() asm volatile("lfence" ::: "memory")
21#define cpu_relax() asm volatile("rep; nop" ::: "memory"); 21#define cpu_relax() asm volatile("rep; nop" ::: "memory");
22#define CPUINFO_PROC "model name" 22#define CPUINFO_PROC "model name"
@@ -26,20 +26,17 @@ void get_term_dimensions(struct winsize *ws);
26#endif 26#endif
27 27
28#ifdef __powerpc__ 28#ifdef __powerpc__
29#include "../../arch/powerpc/include/asm/unistd.h"
30#define rmb() asm volatile ("sync" ::: "memory") 29#define rmb() asm volatile ("sync" ::: "memory")
31#define cpu_relax() asm volatile ("" ::: "memory"); 30#define cpu_relax() asm volatile ("" ::: "memory");
32#define CPUINFO_PROC "cpu" 31#define CPUINFO_PROC "cpu"
33#endif 32#endif
34 33
35#ifdef __s390__ 34#ifdef __s390__
36#include "../../arch/s390/include/asm/unistd.h"
37#define rmb() asm volatile("bcr 15,0" ::: "memory") 35#define rmb() asm volatile("bcr 15,0" ::: "memory")
38#define cpu_relax() asm volatile("" ::: "memory"); 36#define cpu_relax() asm volatile("" ::: "memory");
39#endif 37#endif
40 38
41#ifdef __sh__ 39#ifdef __sh__
42#include "../../arch/sh/include/asm/unistd.h"
43#if defined(__SH4A__) || defined(__SH5__) 40#if defined(__SH4A__) || defined(__SH5__)
44# define rmb() asm volatile("synco" ::: "memory") 41# define rmb() asm volatile("synco" ::: "memory")
45#else 42#else
@@ -50,35 +47,30 @@ void get_term_dimensions(struct winsize *ws);
50#endif 47#endif
51 48
52#ifdef __hppa__ 49#ifdef __hppa__
53#include "../../arch/parisc/include/asm/unistd.h"
54#define rmb() asm volatile("" ::: "memory") 50#define rmb() asm volatile("" ::: "memory")
55#define cpu_relax() asm volatile("" ::: "memory"); 51#define cpu_relax() asm volatile("" ::: "memory");
56#define CPUINFO_PROC "cpu" 52#define CPUINFO_PROC "cpu"
57#endif 53#endif
58 54
59#ifdef __sparc__ 55#ifdef __sparc__
60#include "../../arch/sparc/include/uapi/asm/unistd.h"
61#define rmb() asm volatile("":::"memory") 56#define rmb() asm volatile("":::"memory")
62#define cpu_relax() asm volatile("":::"memory") 57#define cpu_relax() asm volatile("":::"memory")
63#define CPUINFO_PROC "cpu" 58#define CPUINFO_PROC "cpu"
64#endif 59#endif
65 60
66#ifdef __alpha__ 61#ifdef __alpha__
67#include "../../arch/alpha/include/asm/unistd.h"
68#define rmb() asm volatile("mb" ::: "memory") 62#define rmb() asm volatile("mb" ::: "memory")
69#define cpu_relax() asm volatile("" ::: "memory") 63#define cpu_relax() asm volatile("" ::: "memory")
70#define CPUINFO_PROC "cpu model" 64#define CPUINFO_PROC "cpu model"
71#endif 65#endif
72 66
73#ifdef __ia64__ 67#ifdef __ia64__
74#include "../../arch/ia64/include/asm/unistd.h"
75#define rmb() asm volatile ("mf" ::: "memory") 68#define rmb() asm volatile ("mf" ::: "memory")
76#define cpu_relax() asm volatile ("hint @pause" ::: "memory") 69#define cpu_relax() asm volatile ("hint @pause" ::: "memory")
77#define CPUINFO_PROC "model name" 70#define CPUINFO_PROC "model name"
78#endif 71#endif
79 72
80#ifdef __arm__ 73#ifdef __arm__
81#include "../../arch/arm/include/asm/unistd.h"
82/* 74/*
83 * Use the __kuser_memory_barrier helper in the CPU helper page. See 75 * Use the __kuser_memory_barrier helper in the CPU helper page. See
84 * arch/arm/kernel/entry-armv.S in the kernel source for details. 76 * arch/arm/kernel/entry-armv.S in the kernel source for details.
@@ -89,13 +81,11 @@ void get_term_dimensions(struct winsize *ws);
89#endif 81#endif
90 82
91#ifdef __aarch64__ 83#ifdef __aarch64__
92#include "../../arch/arm64/include/asm/unistd.h"
93#define rmb() asm volatile("dmb ld" ::: "memory") 84#define rmb() asm volatile("dmb ld" ::: "memory")
94#define cpu_relax() asm volatile("yield" ::: "memory") 85#define cpu_relax() asm volatile("yield" ::: "memory")
95#endif 86#endif
96 87
97#ifdef __mips__ 88#ifdef __mips__
98#include "../../arch/mips/include/asm/unistd.h"
99#define rmb() asm volatile( \ 89#define rmb() asm volatile( \
100 ".set mips2\n\t" \ 90 ".set mips2\n\t" \
101 "sync\n\t" \ 91 "sync\n\t" \
@@ -112,7 +102,7 @@ void get_term_dimensions(struct winsize *ws);
112#include <sys/types.h> 102#include <sys/types.h>
113#include <sys/syscall.h> 103#include <sys/syscall.h>
114 104
115#include "../../include/uapi/linux/perf_event.h" 105#include <linux/perf_event.h>
116#include "util/types.h" 106#include "util/types.h"
117#include <stdbool.h> 107#include <stdbool.h>
118 108
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 618d41140abd..d144d464ce39 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -18,8 +18,8 @@
18#include "cpumap.h" 18#include "cpumap.h"
19#include "thread_map.h" 19#include "thread_map.h"
20#include "target.h" 20#include "target.h"
21#include "../../../include/linux/hw_breakpoint.h" 21#include <linux/hw_breakpoint.h>
22#include "../../../include/uapi/linux/perf_event.h" 22#include <linux/perf_event.h>
23#include "perf_regs.h" 23#include "perf_regs.h"
24 24
25#define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) 25#define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y))
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 6f94d6dea00f..d99b476ef37c 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -3,7 +3,8 @@
3 3
4#include <linux/list.h> 4#include <linux/list.h>
5#include <stdbool.h> 5#include <stdbool.h>
6#include "../../../include/uapi/linux/perf_event.h" 6#include <stddef.h>
7#include <linux/perf_event.h>
7#include "types.h" 8#include "types.h"
8#include "xyarray.h" 9#include "xyarray.h"
9#include "cgroup.h" 10#include "cgroup.h"
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 7daad237dea5..566b84c695c8 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1378,6 +1378,8 @@ static void print_numa_topology(struct perf_header *ph, int fd __maybe_unused,
1378 1378
1379 str = tmp + 1; 1379 str = tmp + 1;
1380 fprintf(fp, "# node%u cpu list : %s\n", c, str); 1380 fprintf(fp, "# node%u cpu list : %s\n", c, str);
1381
1382 str += strlen(str) + 1;
1381 } 1383 }
1382 return; 1384 return;
1383error: 1385error:
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h
index 879d215cdac9..9bc00783f24f 100644
--- a/tools/perf/util/header.h
+++ b/tools/perf/util/header.h
@@ -1,7 +1,7 @@
1#ifndef __PERF_HEADER_H 1#ifndef __PERF_HEADER_H
2#define __PERF_HEADER_H 2#define __PERF_HEADER_H
3 3
4#include "../../../include/uapi/linux/perf_event.h" 4#include <linux/perf_event.h>
5#include <sys/types.h> 5#include <sys/types.h>
6#include <stdbool.h> 6#include <stdbool.h>
7#include "types.h" 7#include "types.h"
diff --git a/tools/perf/util/parse-events-test.c b/tools/perf/util/parse-events-test.c
index 516ecd9ddd6e..6ef213b35ecd 100644
--- a/tools/perf/util/parse-events-test.c
+++ b/tools/perf/util/parse-events-test.c
@@ -3,7 +3,7 @@
3#include "evsel.h" 3#include "evsel.h"
4#include "evlist.h" 4#include "evlist.h"
5#include "sysfs.h" 5#include "sysfs.h"
6#include "../../../include/linux/hw_breakpoint.h" 6#include <linux/hw_breakpoint.h>
7 7
8#define TEST_ASSERT_VAL(text, cond) \ 8#define TEST_ASSERT_VAL(text, cond) \
9do { \ 9do { \
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 75c7b0fca6d9..6b6d03e93c3d 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1,4 +1,4 @@
1#include "../../../include/linux/hw_breakpoint.h" 1#include <linux/hw_breakpoint.h>
2#include "util.h" 2#include "util.h"
3#include "../perf.h" 3#include "../perf.h"
4#include "evlist.h" 4#include "evlist.h"
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index 839230ceb18b..2820c407adb2 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -7,7 +7,7 @@
7#include <linux/list.h> 7#include <linux/list.h>
8#include <stdbool.h> 8#include <stdbool.h>
9#include "types.h" 9#include "types.h"
10#include "../../../include/uapi/linux/perf_event.h" 10#include <linux/perf_event.h>
11#include "types.h" 11#include "types.h"
12 12
13struct list_head; 13struct list_head;
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index 39f3abac7744..fdeb8ac7c5d2 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -2,7 +2,7 @@
2#define __PMU_H 2#define __PMU_H
3 3
4#include <linux/bitops.h> 4#include <linux/bitops.h>
5#include "../../../include/uapi/linux/perf_event.h" 5#include <linux/perf_event.h>
6 6
7enum { 7enum {
8 PERF_PMU_FORMAT_VALUE_CONFIG, 8 PERF_PMU_FORMAT_VALUE_CONFIG,
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index dd6426163ba6..0eae00ad5fe7 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -7,7 +7,7 @@
7#include "symbol.h" 7#include "symbol.h"
8#include "thread.h" 8#include "thread.h"
9#include <linux/rbtree.h> 9#include <linux/rbtree.h>
10#include "../../../include/uapi/linux/perf_event.h" 10#include <linux/perf_event.h>
11 11
12struct sample_queue; 12struct sample_queue;
13struct ip_callchain; 13struct ip_callchain;
diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c
index 2eeb51baf077..cfa906882e2c 100644
--- a/tools/perf/util/strbuf.c
+++ b/tools/perf/util/strbuf.c
@@ -90,17 +90,17 @@ void strbuf_addf(struct strbuf *sb, const char *fmt, ...)
90 if (!strbuf_avail(sb)) 90 if (!strbuf_avail(sb))
91 strbuf_grow(sb, 64); 91 strbuf_grow(sb, 64);
92 va_start(ap, fmt); 92 va_start(ap, fmt);
93 len = vscnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap); 93 len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap);
94 va_end(ap); 94 va_end(ap);
95 if (len < 0) 95 if (len < 0)
96 die("your vscnprintf is broken"); 96 die("your vsnprintf is broken");
97 if (len > strbuf_avail(sb)) { 97 if (len > strbuf_avail(sb)) {
98 strbuf_grow(sb, len); 98 strbuf_grow(sb, len);
99 va_start(ap, fmt); 99 va_start(ap, fmt);
100 len = vscnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap); 100 len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap);
101 va_end(ap); 101 va_end(ap);
102 if (len > strbuf_avail(sb)) { 102 if (len > strbuf_avail(sb)) {
103 die("this should not happen, your snprintf is broken"); 103 die("this should not happen, your vsnprintf is broken");
104 } 104 }
105 } 105 }
106 strbuf_setlen(sb, sb->len + len); 106 strbuf_setlen(sb, sb->len + len);
diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
index 96ce80a3743b..2964b96aa55f 100644
--- a/tools/scripts/Makefile.include
+++ b/tools/scripts/Makefile.include
@@ -1,8 +1,11 @@
1ifeq ("$(origin O)", "command line") 1ifeq ($(origin O), command line)
2 dummy := $(if $(shell test -d $(O) || echo $(O)),$(error O=$(O) does not exist),) 2 dummy := $(if $(shell test -d $(O) || echo $(O)),$(error O=$(O) does not exist),)
3 ABSOLUTE_O := $(shell cd $(O) ; pwd) 3 ABSOLUTE_O := $(shell cd $(O) ; pwd)
4 OUTPUT := $(ABSOLUTE_O)/ 4 OUTPUT := $(ABSOLUTE_O)/$(if $(subdir),$(subdir)/)
5 COMMAND_O := O=$(ABSOLUTE_O) 5 COMMAND_O := O=$(ABSOLUTE_O)
6ifeq ($(objtree),)
7 objtree := $(O)
8endif
6endif 9endif
7 10
8ifneq ($(OUTPUT),) 11ifneq ($(OUTPUT),)
@@ -41,7 +44,16 @@ else
41NO_SUBDIR = : 44NO_SUBDIR = :
42endif 45endif
43 46
44QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir 47#
48# Define a callable command for descending to a new directory
49#
50# Call by doing: $(call descend,directory[,target])
51#
52descend = \
53 +mkdir -p $(OUTPUT)$(1) && \
54 $(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2)
55
56QUIET_SUBDIR0 = +$(MAKE) $(COMMAND_O) -C # space to separate -C and subdir
45QUIET_SUBDIR1 = 57QUIET_SUBDIR1 =
46 58
47ifneq ($(findstring $(MAKEFLAGS),s),s) 59ifneq ($(findstring $(MAKEFLAGS),s),s)
@@ -56,5 +68,10 @@ ifndef V
56 $(MAKE) $(PRINT_DIR) -C $$subdir 68 $(MAKE) $(PRINT_DIR) -C $$subdir
57 QUIET_FLEX = @echo ' ' FLEX $@; 69 QUIET_FLEX = @echo ' ' FLEX $@;
58 QUIET_BISON = @echo ' ' BISON $@; 70 QUIET_BISON = @echo ' ' BISON $@;
71
72 descend = \
73 @echo ' ' DESCEND $(1); \
74 mkdir -p $(OUTPUT)$(1) && \
75 $(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2)
59endif 76endif
60endif 77endif