aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/DocBook/media/v4l/dev-codec.xml35
-rw-r--r--Documentation/DocBook/media/v4l/v4l2.xml2
-rw-r--r--Documentation/bcache.txt12
-rw-r--r--Documentation/devices.txt8
-rw-r--r--Documentation/devicetree/bindings/media/exynos-fimc-lite.txt2
-rw-r--r--Documentation/devicetree/bindings/rtc/atmel,at91rm9200-rtc.txt2
-rw-r--r--Documentation/kernel-parameters.txt3
-rw-r--r--Documentation/m68k/kernel-options.txt2
-rw-r--r--Documentation/sound/alsa/HD-Audio-Models.txt3
-rw-r--r--MAINTAINERS5
-rw-r--r--Makefile2
-rw-r--r--arch/arm/Kconfig12
-rw-r--r--arch/arm/boot/compressed/Makefile3
-rw-r--r--arch/arm/boot/dts/am33xx.dtsi4
-rw-r--r--arch/arm/boot/dts/armada-xp-gp.dts5
-rw-r--r--arch/arm/boot/dts/armada-xp-openblocks-ax3-4.dts5
-rw-r--r--arch/arm/boot/dts/omap4-panda-common.dtsi20
-rw-r--r--arch/arm/boot/dts/omap4-sdp.dts20
-rw-r--r--arch/arm/boot/dts/omap5.dtsi3
-rw-r--r--arch/arm/include/asm/cacheflush.h4
-rw-r--r--arch/arm/kernel/machine_kexec.c4
-rw-r--r--arch/arm/kernel/process.c43
-rw-r--r--arch/arm/kernel/smp.c13
-rw-r--r--arch/arm/mach-kirkwood/mpp.c5
-rw-r--r--arch/arm/mach-omap2/clock36xx.c18
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_33xx_data.c9
-rw-r--r--arch/arm/mach-omap2/pm34xx.c6
-rw-r--r--arch/arm/mach-prima2/pm.c6
-rw-r--r--arch/arm/mach-prima2/rstc.c6
-rw-r--r--arch/arm/mm/cache-v7.S8
-rw-r--r--arch/arm/mm/flush.c33
-rw-r--r--arch/arm/mm/mmu.c8
-rw-r--r--arch/arm/mm/proc-v7.S4
-rw-r--r--arch/arm/plat-samsung/pm.c18
-rw-r--r--arch/arm64/kernel/perf_event.c1
-rw-r--r--arch/ia64/include/asm/irqflags.h1
-rw-r--r--arch/metag/include/asm/hugetlb.h1
-rw-r--r--arch/mips/include/asm/mmu_context.h2
-rw-r--r--arch/mips/include/uapi/asm/kvm.h81
-rw-r--r--arch/mips/kernel/ftrace.c4
-rw-r--r--arch/mips/kernel/idle.c13
-rw-r--r--arch/mips/kvm/kvm_mips.c83
-rw-r--r--arch/mn10300/include/asm/irqflags.h5
-rw-r--r--arch/mn10300/include/asm/smp.h4
-rw-r--r--arch/parisc/include/asm/mmzone.h4
-rw-r--r--arch/parisc/include/asm/pci.h5
-rw-r--r--arch/parisc/kernel/hardware.c1
-rw-r--r--arch/parisc/kernel/pacache.S76
-rw-r--r--arch/parisc/kernel/pci.c27
-rw-r--r--arch/parisc/mm/init.c2
-rw-r--r--arch/powerpc/include/asm/exception-64s.h2
-rw-r--r--arch/powerpc/include/asm/kvm_asm.h16
-rw-r--r--arch/powerpc/kernel/exceptions-64s.S2
-rw-r--r--arch/powerpc/kernel/irq.c2
-rw-r--r--arch/powerpc/kernel/process.c4
-rw-r--r--arch/powerpc/kernel/traps.c10
-rw-r--r--arch/powerpc/kvm/44x_tlb.c5
-rw-r--r--arch/powerpc/kvm/booke.c21
-rw-r--r--arch/powerpc/kvm/e500_mmu.c5
-rw-r--r--arch/powerpc/kvm/e500mc.c2
-rw-r--r--arch/powerpc/mm/hugetlbpage.c8
-rw-r--r--arch/s390/include/asm/pgtable.h32
-rw-r--r--arch/s390/kernel/dumpstack.c12
-rw-r--r--arch/s390/kernel/irq.c64
-rw-r--r--arch/s390/kernel/sclp.S2
-rw-r--r--arch/s390/pci/pci.c33
-rw-r--r--arch/sparc/include/asm/Kbuild1
-rw-r--r--arch/sparc/include/asm/leon.h2
-rw-r--r--arch/sparc/include/asm/leon_amba.h1
-rw-r--r--arch/sparc/include/asm/linkage.h6
-rw-r--r--arch/sparc/kernel/ds.c3
-rw-r--r--arch/sparc/kernel/leon_kernel.c54
-rw-r--r--arch/sparc/kernel/leon_pci_grpci1.c8
-rw-r--r--arch/sparc/kernel/leon_pmc.c7
-rw-r--r--arch/sparc/kernel/prom_common.c5
-rw-r--r--arch/sparc/kernel/setup_32.c2
-rw-r--r--arch/sparc/kernel/setup_64.c2
-rw-r--r--arch/sparc/mm/init_64.c9
-rw-r--r--arch/sparc/mm/tlb.c2
-rw-r--r--arch/sparc/prom/bootstr_32.c12
-rw-r--r--arch/sparc/prom/tree_64.c16
-rw-r--r--arch/tile/lib/exports.c2
-rw-r--r--arch/x86/boot/compressed/eboot.c47
-rw-r--r--arch/x86/crypto/aesni-intel_asm.S48
-rw-r--r--arch/x86/include/asm/efi.h7
-rw-r--r--arch/x86/include/uapi/asm/bootparam.h1
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel.c2
-rw-r--r--arch/x86/kernel/kvmclock.c1
-rw-r--r--arch/x86/kernel/process.c12
-rw-r--r--arch/x86/kernel/relocate_kernel_64.S2
-rw-r--r--arch/x86/kernel/smpboot.c8
-rw-r--r--arch/x86/kvm/x86.c5
-rw-r--r--arch/x86/mm/init.c6
-rw-r--r--arch/x86/platform/efi/efi.c188
-rw-r--r--arch/x86/tools/relocs.c4
-rw-r--r--block/blk-core.c2
-rw-r--r--drivers/acpi/acpi_lpss.c21
-rw-r--r--drivers/acpi/device_pm.c20
-rw-r--r--drivers/acpi/dock.c2
-rw-r--r--drivers/acpi/power.c1
-rw-r--r--drivers/acpi/resource.c16
-rw-r--r--drivers/acpi/scan.c5
-rw-r--r--drivers/acpi/video.c3
-rw-r--r--drivers/block/cciss.c32
-rw-r--r--drivers/block/mtip32xx/mtip32xx.c8
-rw-r--r--drivers/block/nvme-core.c62
-rw-r--r--drivers/block/nvme-scsi.c3
-rw-r--r--drivers/block/pktcdvd.c3
-rw-r--r--drivers/block/rbd.c39
-rw-r--r--drivers/bluetooth/Kconfig4
-rw-r--r--drivers/bluetooth/btmrvl_sdio.c28
-rw-r--r--drivers/clk/clk.c1
-rw-r--r--drivers/clk/samsung/clk-exynos5250.c10
-rw-r--r--drivers/clk/samsung/clk-pll.c5
-rw-r--r--drivers/clk/spear/spear3xx_clock.c2
-rw-r--r--drivers/clk/tegra/clk-tegra30.c11
-rw-r--r--drivers/hid/hid-multitouch.c11
-rw-r--r--drivers/md/bcache/Kconfig1
-rw-r--r--drivers/md/bcache/bcache.h2
-rw-r--r--drivers/md/bcache/stats.c34
-rw-r--r--drivers/md/bcache/super.c185
-rw-r--r--drivers/md/bcache/writeback.c2
-rw-r--r--drivers/md/md.c2
-rw-r--r--drivers/md/raid1.c38
-rw-r--r--drivers/md/raid10.c29
-rw-r--r--drivers/md/raid5.c6
-rw-r--r--drivers/media/i2c/s5c73m3/s5c73m3-core.c2
-rw-r--r--drivers/media/pci/cx88/cx88-alsa.c7
-rw-r--r--drivers/media/pci/cx88/cx88-video.c8
-rw-r--r--drivers/media/platform/coda.c9
-rw-r--r--drivers/media/platform/davinci/vpbe_display.c15
-rw-r--r--drivers/media/platform/davinci/vpfe_capture.c3
-rw-r--r--drivers/media/platform/exynos4-is/fimc-is-regs.c2
-rw-r--r--drivers/media/platform/exynos4-is/fimc-is.c22
-rw-r--r--drivers/media/platform/exynos4-is/fimc-is.h1
-rw-r--r--drivers/media/platform/exynos4-is/fimc-isp.c4
-rw-r--r--drivers/media/platform/exynos4-is/mipi-csis.c2
-rw-r--r--drivers/media/platform/s3c-camif/camif-core.h2
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc.c8
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_common.h6
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c2
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_debug.h4
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_dec.c20
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_enc.c82
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c4
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c53
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_pm.c23
-rw-r--r--drivers/media/platform/sh_veu.c15
-rw-r--r--drivers/media/platform/soc_camera/soc_camera.c4
-rw-r--r--drivers/media/radio/Kconfig1
-rw-r--r--drivers/media/radio/radio-si476x.c2
-rw-r--r--drivers/media/usb/gspca/sonixb.c7
-rw-r--r--drivers/media/usb/pwc/pwc.h2
-rw-r--r--drivers/media/v4l2-core/v4l2-ctrls.c2
-rw-r--r--drivers/media/v4l2-core/v4l2-ioctl.c47
-rw-r--r--drivers/media/v4l2-core/v4l2-mem2mem.c39
-rw-r--r--drivers/media/v4l2-core/videobuf2-core.c3
-rw-r--r--drivers/misc/mei/init.c4
-rw-r--r--drivers/misc/mei/nfc.c2
-rw-r--r--drivers/misc/mei/pci-me.c1
-rw-r--r--drivers/misc/sgi-gru/grufile.c1
-rw-r--r--drivers/net/bonding/bond_main.c19
-rw-r--r--drivers/net/bonding/bonding.h2
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c10
-rw-r--r--drivers/net/ethernet/brocade/bna/bnad_debugfs.c2
-rw-r--r--drivers/net/ethernet/dec/tulip/interrupt.c6
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c3
-rw-r--r--drivers/net/ethernet/renesas/sh_eth.c19
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c2
-rw-r--r--drivers/net/ethernet/ti/davinci_mdio.c14
-rw-r--r--drivers/net/macvlan.c20
-rw-r--r--drivers/net/team/team.c2
-rw-r--r--drivers/net/team/team_mode_random.c2
-rw-r--r--drivers/net/team/team_mode_roundrobin.c2
-rw-r--r--drivers/net/tun.c4
-rw-r--r--drivers/net/usb/cdc_ether.c6
-rw-r--r--drivers/net/usb/qmi_wwan.c1
-rw-r--r--drivers/net/wireless/ath/ath9k/Kconfig10
-rw-r--r--drivers/net/wireless/ath/ath9k/Makefile2
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h10
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c7
-rw-r--r--drivers/net/wireless/ath/ath9k/rc.h2
-rw-r--r--drivers/net/wireless/b43/main.c2
-rw-r--r--drivers/net/wireless/iwlegacy/common.h6
-rw-r--r--drivers/net/wireless/mwifiex/debugfs.c22
-rw-r--r--drivers/net/wireless/rtlwifi/pci.c1
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/hw.c134
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/hw.h4
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/mac.c18
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/sw.c4
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/sw.h3
-rw-r--r--drivers/net/wireless/rtlwifi/usb.c13
-rw-r--r--drivers/net/wireless/rtlwifi/wifi.h4
-rw-r--r--drivers/net/wireless/ti/wl12xx/scan.c2
-rw-r--r--drivers/net/wireless/ti/wl12xx/wl12xx.h6
-rw-r--r--drivers/net/wireless/ti/wl18xx/scan.c2
-rw-r--r--drivers/net/xen-netback/netback.c11
-rw-r--r--drivers/of/base.c15
-rw-r--r--drivers/parisc/iosapic.c66
-rw-r--r--drivers/rtc/rtc-at91rm9200.c131
-rw-r--r--drivers/rtc/rtc-cmos.c4
-rw-r--r--drivers/rtc/rtc-tps6586x.c3
-rw-r--r--drivers/rtc/rtc-twl.c1
-rw-r--r--drivers/s390/net/netiucv.c6
-rw-r--r--drivers/scsi/bfa/bfad_debugfs.c2
-rw-r--r--drivers/scsi/fnic/fnic_debugfs.c2
-rw-r--r--drivers/scsi/lpfc/lpfc_debugfs.c2
-rw-r--r--drivers/staging/media/davinci_vpfe/Kconfig2
-rw-r--r--drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c6
-rw-r--r--drivers/staging/media/solo6x10/Kconfig1
-rw-r--r--drivers/tty/serial/8250/8250_gsc.c10
-rw-r--r--drivers/usb/chipidea/core.c3
-rw-r--r--drivers/usb/chipidea/udc.c13
-rw-r--r--drivers/usb/serial/f81232.c8
-rw-r--r--drivers/usb/serial/pl2303.c10
-rw-r--r--drivers/usb/serial/spcp8x5.c10
-rw-r--r--drivers/vhost/net.c29
-rw-r--r--drivers/vhost/vhost.c8
-rw-r--r--drivers/vhost/vhost.h1
-rw-r--r--fs/aio.c36
-rw-r--r--fs/btrfs/disk-io.c10
-rw-r--r--fs/btrfs/inode.c3
-rw-r--r--fs/btrfs/relocation.c9
-rw-r--r--fs/ceph/locks.c73
-rw-r--r--fs/ceph/mds_client.c65
-rw-r--r--fs/ceph/super.h9
-rw-r--r--fs/file_table.c19
-rw-r--r--fs/namei.c4
-rw-r--r--fs/ncpfs/dir.c9
-rw-r--r--fs/ocfs2/dlm/dlmrecovery.c1
-rw-r--r--fs/ocfs2/namei.c4
-rw-r--r--fs/proc/kmsg.c10
-rw-r--r--fs/xfs/xfs_attr_leaf.h1
-rw-r--r--fs/xfs/xfs_btree.c10
-rw-r--r--fs/xfs/xfs_dir2_format.h5
-rw-r--r--fs/xfs/xfs_log_recover.c19
-rw-r--r--fs/xfs/xfs_mount.c18
-rw-r--r--include/acpi/acpi_bus.h1
-rw-r--r--include/asm-generic/kvm_para.h5
-rw-r--r--include/linux/context_tracking.h35
-rw-r--r--include/linux/cpu.h4
-rw-r--r--include/linux/filter.h1
-rw-r--r--include/linux/if_team.h4
-rw-r--r--include/linux/kvm_host.h37
-rw-r--r--include/linux/math64.h6
-rw-r--r--include/linux/perf_event.h3
-rw-r--r--include/linux/preempt.h18
-rw-r--r--include/linux/scatterlist.h3
-rw-r--r--include/linux/smp.h19
-rw-r--r--include/linux/swapops.h3
-rw-r--r--include/linux/syslog.h4
-rw-r--r--include/linux/tracepoint.h4
-rw-r--r--include/linux/vtime.h4
-rw-r--r--include/media/v4l2-mem2mem.h2
-rw-r--r--include/net/bluetooth/hci_core.h1
-rw-r--r--include/net/bluetooth/mgmt.h1
-rw-r--r--include/net/ip_tunnels.h6
-rw-r--r--include/sound/soc-dapm.h3
-rw-r--r--include/uapi/linux/kvm.h1
-rw-r--r--init/Kconfig1
-rw-r--r--kernel/audit.c2
-rw-r--r--kernel/audit_tree.c1
-rw-r--r--kernel/context_tracking.c41
-rw-r--r--kernel/cpu.c55
-rw-r--r--kernel/cpu/idle.c17
-rw-r--r--kernel/events/core.c233
-rw-r--r--kernel/events/internal.h4
-rw-r--r--kernel/exit.c2
-rw-r--r--kernel/kprobes.c30
-rw-r--r--kernel/printk.c91
-rw-r--r--kernel/rcutree.c21
-rw-r--r--kernel/rcutree.h2
-rw-r--r--kernel/sched/core.c23
-rw-r--r--kernel/sched/cputime.c6
-rw-r--r--kernel/softirq.c13
-rw-r--r--kernel/sys.c29
-rw-r--r--kernel/time/tick-broadcast.c4
-rw-r--r--kernel/time/tick-sched.c2
-rw-r--r--kernel/trace/trace.c8
-rw-r--r--kernel/trace/trace.h2
-rw-r--r--lib/mpi/mpicoder.c2
-rw-r--r--mm/frontswap.c2
-rw-r--r--mm/hugetlb.c2
-rw-r--r--mm/memcontrol.c14
-rw-r--r--mm/migrate.c23
-rw-r--r--mm/page_alloc.c6
-rw-r--r--mm/slab_common.c4
-rw-r--r--mm/swap_state.c18
-rw-r--r--mm/swapfile.c2
-rw-r--r--net/9p/client.c55
-rw-r--r--net/batman-adv/bat_iv_ogm.c86
-rw-r--r--net/batman-adv/bridge_loop_avoidance.c4
-rw-r--r--net/batman-adv/sysfs.c5
-rw-r--r--net/bluetooth/hci_core.c6
-rw-r--r--net/bluetooth/l2cap_core.c70
-rw-r--r--net/bluetooth/mgmt.c23
-rw-r--r--net/bluetooth/smp.c4
-rw-r--r--net/ceph/osd_client.c2
-rw-r--r--net/core/filter.c2
-rw-r--r--net/core/sock_diag.c9
-rw-r--r--net/ipv4/ip_tunnel.c4
-rw-r--r--net/ipv4/ip_vti.c3
-rw-r--r--net/l2tp/l2tp_ppp.c6
-rw-r--r--net/netfilter/ipvs/ip_vs_ctl.c1
-rw-r--r--net/netfilter/nfnetlink_acct.c7
-rw-r--r--net/netfilter/nfnetlink_cttimeout.c7
-rw-r--r--net/netfilter/nfnetlink_queue_core.c6
-rw-r--r--net/netfilter/xt_TCPMSS.c6
-rw-r--r--net/netlink/af_netlink.c2
-rw-r--r--net/packet/af_packet.c5
-rw-r--r--net/sched/sch_api.c11
-rw-r--r--net/sctp/outqueue.c6
-rw-r--r--net/sctp/socket.c6
-rw-r--r--scripts/Makefile.lib8
-rw-r--r--scripts/dtc/dtc-lexer.l2
-rw-r--r--scripts/dtc/dtc-lexer.lex.c_shipped232
-rw-r--r--scripts/dtc/dtc-parser.tab.c_shipped715
-rw-r--r--scripts/dtc/dtc-parser.tab.h_shipped14
-rw-r--r--sound/core/pcm_native.c4
-rw-r--r--sound/pci/hda/patch_cirrus.c23
-rw-r--r--sound/pci/hda/patch_realtek.c6
-rw-r--r--sound/soc/codecs/cs42l52.c6
-rw-r--r--sound/soc/codecs/tlv320aic3x.c10
-rw-r--r--sound/soc/codecs/wm5102.c3
-rw-r--r--sound/soc/codecs/wm5110.c3
-rw-r--r--sound/soc/codecs/wm8994.c3
-rw-r--r--sound/soc/soc-dapm.c49
-rw-r--r--sound/soc/soc-pcm.c13
-rw-r--r--sound/usb/card.c22
-rw-r--r--sound/usb/mixer.c1
-rw-r--r--tools/power/x86/turbostat/turbostat.c2
331 files changed, 3416 insertions, 2199 deletions
diff --git a/Documentation/DocBook/media/v4l/dev-codec.xml b/Documentation/DocBook/media/v4l/dev-codec.xml
index dca0ecd54dc6..ff44c16fc080 100644
--- a/Documentation/DocBook/media/v4l/dev-codec.xml
+++ b/Documentation/DocBook/media/v4l/dev-codec.xml
@@ -1,18 +1,27 @@
1 <title>Codec Interface</title> 1 <title>Codec Interface</title>
2 2
3 <note> 3 <para>A V4L2 codec can compress, decompress, transform, or otherwise
4 <title>Suspended</title> 4convert video data from one format into another format, in memory. Typically
5such devices are memory-to-memory devices (i.e. devices with the
6<constant>V4L2_CAP_VIDEO_M2M</constant> or <constant>V4L2_CAP_VIDEO_M2M_MPLANE</constant>
7capability set).
8</para>
5 9
6 <para>This interface has been be suspended from the V4L2 API 10 <para>A memory-to-memory video node acts just like a normal video node, but it
7implemented in Linux 2.6 until we have more experience with codec 11supports both output (sending frames from memory to the codec hardware) and
8device interfaces.</para> 12capture (receiving the processed frames from the codec hardware into memory)
9 </note> 13stream I/O. An application will have to setup the stream
14I/O for both sides and finally call &VIDIOC-STREAMON; for both capture and output
15to start the codec.</para>
10 16
11 <para>A V4L2 codec can compress, decompress, transform, or otherwise 17 <para>Video compression codecs use the MPEG controls to setup their codec parameters
12convert video data from one format into another format, in memory. 18(note that the MPEG controls actually support many more codecs than just MPEG).
13Applications send data to be converted to the driver through a 19See <xref linkend="mpeg-controls"></xref>.</para>
14&func-write; call, and receive the converted data through a
15&func-read; call. For efficiency a driver may also support streaming
16I/O.</para>
17 20
18 <para>[to do]</para> 21 <para>Memory-to-memory devices can often be used as a shared resource: you can
22open the video node multiple times, each application setting up their own codec properties
23that are local to the file handle, and each can use it independently from the others.
24The driver will arbitrate access to the codec and reprogram it whenever another file
25handler gets access. This is different from the usual video node behavior where the video properties
26are global to the device (i.e. changing something through one file handle is visible
27through another file handle).</para>
diff --git a/Documentation/DocBook/media/v4l/v4l2.xml b/Documentation/DocBook/media/v4l/v4l2.xml
index bfc93cdcf696..bfe823dd0f31 100644
--- a/Documentation/DocBook/media/v4l/v4l2.xml
+++ b/Documentation/DocBook/media/v4l/v4l2.xml
@@ -493,7 +493,7 @@ and discussions on the V4L mailing list.</revremark>
493</partinfo> 493</partinfo>
494 494
495<title>Video for Linux Two API Specification</title> 495<title>Video for Linux Two API Specification</title>
496 <subtitle>Revision 3.9</subtitle> 496 <subtitle>Revision 3.10</subtitle>
497 497
498 <chapter id="common"> 498 <chapter id="common">
499 &sub-common; 499 &sub-common;
diff --git a/Documentation/bcache.txt b/Documentation/bcache.txt
index 77db8809bd96..b3a7e7d384f6 100644
--- a/Documentation/bcache.txt
+++ b/Documentation/bcache.txt
@@ -319,7 +319,10 @@ cache<0..n>
319 Symlink to each of the cache devices comprising this cache set. 319 Symlink to each of the cache devices comprising this cache set.
320 320
321cache_available_percent 321cache_available_percent
322 Percentage of cache device free. 322 Percentage of cache device which doesn't contain dirty data, and could
323 potentially be used for writeback. This doesn't mean this space isn't used
324 for clean cached data; the unused statistic (in priority_stats) is typically
325 much lower.
323 326
324clear_stats 327clear_stats
325 Clears the statistics associated with this cache 328 Clears the statistics associated with this cache
@@ -423,8 +426,11 @@ nbuckets
423 Total buckets in this cache 426 Total buckets in this cache
424 427
425priority_stats 428priority_stats
426 Statistics about how recently data in the cache has been accessed. This can 429 Statistics about how recently data in the cache has been accessed.
427 reveal your working set size. 430 This can reveal your working set size. Unused is the percentage of
431 the cache that doesn't contain any data. Metadata is bcache's
432 metadata overhead. Average is the average priority of cache buckets.
433 Next is a list of quantiles with the priority threshold of each.
428 434
429written 435written
430 Sum of all data that has been written to the cache; comparison with 436 Sum of all data that has been written to the cache; comparison with
diff --git a/Documentation/devices.txt b/Documentation/devices.txt
index 08f01e79c41a..b9015912bca6 100644
--- a/Documentation/devices.txt
+++ b/Documentation/devices.txt
@@ -498,12 +498,8 @@ Your cooperation is appreciated.
498 498
499 Each device type has 5 bits (32 minors). 499 Each device type has 5 bits (32 minors).
500 500
501 13 block 8-bit MFM/RLL/IDE controller 501 13 block Previously used for the XT disk (/dev/xdN)
502 0 = /dev/xda First XT disk whole disk 502 Deleted in kernel v3.9.
503 64 = /dev/xdb Second XT disk whole disk
504
505 Partitions are handled in the same way as IDE disks
506 (see major number 3).
507 503
508 14 char Open Sound System (OSS) 504 14 char Open Sound System (OSS)
509 0 = /dev/mixer Mixer control 505 0 = /dev/mixer Mixer control
diff --git a/Documentation/devicetree/bindings/media/exynos-fimc-lite.txt b/Documentation/devicetree/bindings/media/exynos-fimc-lite.txt
index 3f62adfb3e0b..de9f6b78ee51 100644
--- a/Documentation/devicetree/bindings/media/exynos-fimc-lite.txt
+++ b/Documentation/devicetree/bindings/media/exynos-fimc-lite.txt
@@ -2,7 +2,7 @@ Exynos4x12/Exynos5 SoC series camera host interface (FIMC-LITE)
2 2
3Required properties: 3Required properties:
4 4
5- compatible : should be "samsung,exynos4212-fimc" for Exynos4212 and 5- compatible : should be "samsung,exynos4212-fimc-lite" for Exynos4212 and
6 Exynos4412 SoCs; 6 Exynos4412 SoCs;
7- reg : physical base address and size of the device memory mapped 7- reg : physical base address and size of the device memory mapped
8 registers; 8 registers;
diff --git a/Documentation/devicetree/bindings/rtc/atmel,at91rm9200-rtc.txt b/Documentation/devicetree/bindings/rtc/atmel,at91rm9200-rtc.txt
index 2a3feabd3b22..34c1505774bf 100644
--- a/Documentation/devicetree/bindings/rtc/atmel,at91rm9200-rtc.txt
+++ b/Documentation/devicetree/bindings/rtc/atmel,at91rm9200-rtc.txt
@@ -1,7 +1,7 @@
1Atmel AT91RM9200 Real Time Clock 1Atmel AT91RM9200 Real Time Clock
2 2
3Required properties: 3Required properties:
4- compatible: should be: "atmel,at91rm9200-rtc" 4- compatible: should be: "atmel,at91rm9200-rtc" or "atmel,at91sam9x5-rtc"
5- reg: physical base address of the controller and length of memory mapped 5- reg: physical base address of the controller and length of memory mapped
6 region. 6 region.
7- interrupts: rtc alarm/event interrupt 7- interrupts: rtc alarm/event interrupt
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 6e3b18a8afc6..2fe6e767b3d6 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -3351,9 +3351,6 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
3351 plus one apbt timer for broadcast timer. 3351 plus one apbt timer for broadcast timer.
3352 x86_mrst_timer=apbt_only | lapic_and_apbt 3352 x86_mrst_timer=apbt_only | lapic_and_apbt
3353 3353
3354 xd= [HW,XT] Original XT pre-IDE (RLL encoded) disks.
3355 xd_geo= See header of drivers/block/xd.c.
3356
3357 xen_emul_unplug= [HW,X86,XEN] 3354 xen_emul_unplug= [HW,X86,XEN]
3358 Unplug Xen emulated devices 3355 Unplug Xen emulated devices
3359 Format: [unplug0,][unplug1] 3356 Format: [unplug0,][unplug1]
diff --git a/Documentation/m68k/kernel-options.txt b/Documentation/m68k/kernel-options.txt
index 97d45f276fe6..eaf32a1fd0b1 100644
--- a/Documentation/m68k/kernel-options.txt
+++ b/Documentation/m68k/kernel-options.txt
@@ -80,8 +80,6 @@ Valid names are:
80 /dev/sdd: -> 0x0830 (forth SCSI disk) 80 /dev/sdd: -> 0x0830 (forth SCSI disk)
81 /dev/sde: -> 0x0840 (fifth SCSI disk) 81 /dev/sde: -> 0x0840 (fifth SCSI disk)
82 /dev/fd : -> 0x0200 (floppy disk) 82 /dev/fd : -> 0x0200 (floppy disk)
83 /dev/xda: -> 0x0c00 (first XT disk, unused in Linux/m68k)
84 /dev/xdb: -> 0x0c40 (second XT disk, unused in Linux/m68k)
85 83
86 The name must be followed by a decimal number, that stands for the 84 The name must be followed by a decimal number, that stands for the
87partition number. Internally, the value of the number is just 85partition number. Internally, the value of the number is just
diff --git a/Documentation/sound/alsa/HD-Audio-Models.txt b/Documentation/sound/alsa/HD-Audio-Models.txt
index bb8b0dc532b8..77d68e23b247 100644
--- a/Documentation/sound/alsa/HD-Audio-Models.txt
+++ b/Documentation/sound/alsa/HD-Audio-Models.txt
@@ -29,6 +29,8 @@ ALC269/270/275/276/280/282
29 alc271-dmic Enable ALC271X digital mic workaround 29 alc271-dmic Enable ALC271X digital mic workaround
30 inv-dmic Inverted internal mic workaround 30 inv-dmic Inverted internal mic workaround
31 lenovo-dock Enables docking station I/O for some Lenovos 31 lenovo-dock Enables docking station I/O for some Lenovos
32 dell-headset-multi Headset jack, which can also be used as mic-in
33 dell-headset-dock Headset jack (without mic-in), and also dock I/O
32 34
33ALC662/663/272 35ALC662/663/272
34============== 36==============
@@ -42,6 +44,7 @@ ALC662/663/272
42 asus-mode7 ASUS 44 asus-mode7 ASUS
43 asus-mode8 ASUS 45 asus-mode8 ASUS
44 inv-dmic Inverted internal mic workaround 46 inv-dmic Inverted internal mic workaround
47 dell-headset-multi Headset jack, which can also be used as mic-in
45 48
46ALC680 49ALC680
47====== 50======
diff --git a/MAINTAINERS b/MAINTAINERS
index 0fda00f39849..5be702cc8449 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5766,7 +5766,7 @@ M: Matthew Wilcox <willy@linux.intel.com>
5766L: linux-nvme@lists.infradead.org 5766L: linux-nvme@lists.infradead.org
5767T: git git://git.infradead.org/users/willy/linux-nvme.git 5767T: git git://git.infradead.org/users/willy/linux-nvme.git
5768S: Supported 5768S: Supported
5769F: drivers/block/nvme.c 5769F: drivers/block/nvme*
5770F: include/linux/nvme.h 5770F: include/linux/nvme.h
5771 5771
5772OMAP SUPPORT 5772OMAP SUPPORT
@@ -9004,7 +9004,7 @@ S: Maintained
9004F: drivers/net/wireless/wl3501* 9004F: drivers/net/wireless/wl3501*
9005 9005
9006WM97XX TOUCHSCREEN DRIVERS 9006WM97XX TOUCHSCREEN DRIVERS
9007M: Mark Brown <broonie@opensource.wolfsonmicro.com> 9007M: Mark Brown <broonie@kernel.org>
9008M: Liam Girdwood <lrg@slimlogic.co.uk> 9008M: Liam Girdwood <lrg@slimlogic.co.uk>
9009L: linux-input@vger.kernel.org 9009L: linux-input@vger.kernel.org
9010T: git git://opensource.wolfsonmicro.com/linux-2.6-touch 9010T: git git://opensource.wolfsonmicro.com/linux-2.6-touch
@@ -9014,7 +9014,6 @@ F: drivers/input/touchscreen/*wm97*
9014F: include/linux/wm97xx.h 9014F: include/linux/wm97xx.h
9015 9015
9016WOLFSON MICROELECTRONICS DRIVERS 9016WOLFSON MICROELECTRONICS DRIVERS
9017M: Mark Brown <broonie@opensource.wolfsonmicro.com>
9018L: patches@opensource.wolfsonmicro.com 9017L: patches@opensource.wolfsonmicro.com
9019T: git git://opensource.wolfsonmicro.com/linux-2.6-asoc 9018T: git git://opensource.wolfsonmicro.com/linux-2.6-asoc
9020T: git git://opensource.wolfsonmicro.com/linux-2.6-audioplus 9019T: git git://opensource.wolfsonmicro.com/linux-2.6-audioplus
diff --git a/Makefile b/Makefile
index 90400165125e..c6863b55f7c7 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 10 2PATCHLEVEL = 10
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc5 4EXTRAVERSION = -rc6
5NAME = Unicycling Gorilla 5NAME = Unicycling Gorilla
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 49d993cee512..2651b1da1c56 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1189,6 +1189,16 @@ config PL310_ERRATA_588369
1189 is not correctly implemented in PL310 as clean lines are not 1189 is not correctly implemented in PL310 as clean lines are not
1190 invalidated as a result of these operations. 1190 invalidated as a result of these operations.
1191 1191
1192config ARM_ERRATA_643719
1193 bool "ARM errata: LoUIS bit field in CLIDR register is incorrect"
1194 depends on CPU_V7 && SMP
1195 help
1196 This option enables the workaround for the 643719 Cortex-A9 (prior to
1197 r1p0) erratum. On affected cores the LoUIS bit field of the CLIDR
1198 register returns zero when it should return one. The workaround
1199 corrects this value, ensuring cache maintenance operations which use
1200 it behave as intended and avoiding data corruption.
1201
1192config ARM_ERRATA_720789 1202config ARM_ERRATA_720789
1193 bool "ARM errata: TLBIASIDIS and TLBIMVAIS operations can broadcast a faulty ASID" 1203 bool "ARM errata: TLBIASIDIS and TLBIMVAIS operations can broadcast a faulty ASID"
1194 depends on CPU_V7 1204 depends on CPU_V7
@@ -2006,7 +2016,7 @@ config XIP_PHYS_ADDR
2006 2016
2007config KEXEC 2017config KEXEC
2008 bool "Kexec system call (EXPERIMENTAL)" 2018 bool "Kexec system call (EXPERIMENTAL)"
2009 depends on (!SMP || HOTPLUG_CPU) 2019 depends on (!SMP || PM_SLEEP_SMP)
2010 help 2020 help
2011 kexec is a system call that implements the ability to shutdown your 2021 kexec is a system call that implements the ability to shutdown your
2012 current kernel, and to start another kernel. It is like a reboot 2022 current kernel, and to start another kernel. It is like a reboot
diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index 79e9bdbfc491..120b83bfde20 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -116,7 +116,8 @@ targets := vmlinux vmlinux.lds \
116 116
117# Make sure files are removed during clean 117# Make sure files are removed during clean
118extra-y += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern \ 118extra-y += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern \
119 lib1funcs.S ashldi3.S $(libfdt) $(libfdt_hdrs) 119 lib1funcs.S ashldi3.S $(libfdt) $(libfdt_hdrs) \
120 hyp-stub.S
120 121
121ifeq ($(CONFIG_FUNCTION_TRACER),y) 122ifeq ($(CONFIG_FUNCTION_TRACER),y)
122ORIG_CFLAGS := $(KBUILD_CFLAGS) 123ORIG_CFLAGS := $(KBUILD_CFLAGS)
diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi
index 1460d9b88adf..8e1248f01fab 100644
--- a/arch/arm/boot/dts/am33xx.dtsi
+++ b/arch/arm/boot/dts/am33xx.dtsi
@@ -409,8 +409,8 @@
409 ti,hwmods = "gpmc"; 409 ti,hwmods = "gpmc";
410 reg = <0x50000000 0x2000>; 410 reg = <0x50000000 0x2000>;
411 interrupts = <100>; 411 interrupts = <100>;
412 num-cs = <7>; 412 gpmc,num-cs = <7>;
413 num-waitpins = <2>; 413 gpmc,num-waitpins = <2>;
414 #address-cells = <2>; 414 #address-cells = <2>;
415 #size-cells = <1>; 415 #size-cells = <1>;
416 status = "disabled"; 416 status = "disabled";
diff --git a/arch/arm/boot/dts/armada-xp-gp.dts b/arch/arm/boot/dts/armada-xp-gp.dts
index 3ee63d128e27..76db557adbe7 100644
--- a/arch/arm/boot/dts/armada-xp-gp.dts
+++ b/arch/arm/boot/dts/armada-xp-gp.dts
@@ -39,8 +39,9 @@
39 }; 39 };
40 40
41 soc { 41 soc {
42 ranges = <0 0 0xd0000000 0x100000 42 ranges = <0 0 0xd0000000 0x100000 /* Internal registers 1MiB */
43 0xf0000000 0 0xf0000000 0x1000000>; 43 0xe0000000 0 0xe0000000 0x8100000 /* PCIe */
44 0xf0000000 0 0xf0000000 0x1000000 /* Device Bus, NOR 16MiB */>;
44 45
45 internal-regs { 46 internal-regs {
46 serial@12000 { 47 serial@12000 {
diff --git a/arch/arm/boot/dts/armada-xp-openblocks-ax3-4.dts b/arch/arm/boot/dts/armada-xp-openblocks-ax3-4.dts
index 46b785064dd8..fdea75c73411 100644
--- a/arch/arm/boot/dts/armada-xp-openblocks-ax3-4.dts
+++ b/arch/arm/boot/dts/armada-xp-openblocks-ax3-4.dts
@@ -27,8 +27,9 @@
27 }; 27 };
28 28
29 soc { 29 soc {
30 ranges = <0 0 0xd0000000 0x100000 30 ranges = <0 0 0xd0000000 0x100000 /* Internal registers 1MiB */
31 0xf0000000 0 0xf0000000 0x8000000>; 31 0xe0000000 0 0xe0000000 0x8100000 /* PCIe */
32 0xf0000000 0 0xf0000000 0x8000000 /* Device Bus, NOR 128MiB */>;
32 33
33 internal-regs { 34 internal-regs {
34 serial@12000 { 35 serial@12000 {
diff --git a/arch/arm/boot/dts/omap4-panda-common.dtsi b/arch/arm/boot/dts/omap4-panda-common.dtsi
index 03bd60deb52b..eeb734e25709 100644
--- a/arch/arm/boot/dts/omap4-panda-common.dtsi
+++ b/arch/arm/boot/dts/omap4-panda-common.dtsi
@@ -56,9 +56,23 @@
56 }; 56 };
57}; 57};
58 58
59&omap4_pmx_wkup {
60 pinctrl-names = "default";
61 pinctrl-0 = <
62 &twl6030_wkup_pins
63 >;
64
65 twl6030_wkup_pins: pinmux_twl6030_wkup_pins {
66 pinctrl-single,pins = <
67 0x14 0x2 /* fref_clk0_out.sys_drm_msecure OUTPUT | MODE2 */
68 >;
69 };
70};
71
59&omap4_pmx_core { 72&omap4_pmx_core {
60 pinctrl-names = "default"; 73 pinctrl-names = "default";
61 pinctrl-0 = < 74 pinctrl-0 = <
75 &twl6030_pins
62 &twl6040_pins 76 &twl6040_pins
63 &mcpdm_pins 77 &mcpdm_pins
64 &mcbsp1_pins 78 &mcbsp1_pins
@@ -66,6 +80,12 @@
66 &tpd12s015_pins 80 &tpd12s015_pins
67 >; 81 >;
68 82
83 twl6030_pins: pinmux_twl6030_pins {
84 pinctrl-single,pins = <
85 0x15e 0x4118 /* sys_nirq1.sys_nirq1 OMAP_WAKEUP_EN | INPUT_PULLUP | MODE0 */
86 >;
87 };
88
69 twl6040_pins: pinmux_twl6040_pins { 89 twl6040_pins: pinmux_twl6040_pins {
70 pinctrl-single,pins = < 90 pinctrl-single,pins = <
71 0xe0 0x3 /* hdq_sio.gpio_127 OUTPUT | MODE3 */ 91 0xe0 0x3 /* hdq_sio.gpio_127 OUTPUT | MODE3 */
diff --git a/arch/arm/boot/dts/omap4-sdp.dts b/arch/arm/boot/dts/omap4-sdp.dts
index a35d9cd58063..98505a2ef162 100644
--- a/arch/arm/boot/dts/omap4-sdp.dts
+++ b/arch/arm/boot/dts/omap4-sdp.dts
@@ -142,9 +142,23 @@
142 }; 142 };
143}; 143};
144 144
145&omap4_pmx_wkup {
146 pinctrl-names = "default";
147 pinctrl-0 = <
148 &twl6030_wkup_pins
149 >;
150
151 twl6030_wkup_pins: pinmux_twl6030_wkup_pins {
152 pinctrl-single,pins = <
153 0x14 0x2 /* fref_clk0_out.sys_drm_msecure OUTPUT | MODE2 */
154 >;
155 };
156};
157
145&omap4_pmx_core { 158&omap4_pmx_core {
146 pinctrl-names = "default"; 159 pinctrl-names = "default";
147 pinctrl-0 = < 160 pinctrl-0 = <
161 &twl6030_pins
148 &twl6040_pins 162 &twl6040_pins
149 &mcpdm_pins 163 &mcpdm_pins
150 &dmic_pins 164 &dmic_pins
@@ -179,6 +193,12 @@
179 >; 193 >;
180 }; 194 };
181 195
196 twl6030_pins: pinmux_twl6030_pins {
197 pinctrl-single,pins = <
198 0x15e 0x4118 /* sys_nirq1.sys_nirq1 OMAP_WAKEUP_EN | INPUT_PULLUP | MODE0 */
199 >;
200 };
201
182 twl6040_pins: pinmux_twl6040_pins { 202 twl6040_pins: pinmux_twl6040_pins {
183 pinctrl-single,pins = < 203 pinctrl-single,pins = <
184 0xe0 0x3 /* hdq_sio.gpio_127 OUTPUT | MODE3 */ 204 0xe0 0x3 /* hdq_sio.gpio_127 OUTPUT | MODE3 */
diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
index 3dd7ff825828..635cae283011 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -538,6 +538,7 @@
538 interrupts = <0 41 0x4>; 538 interrupts = <0 41 0x4>;
539 ti,hwmods = "timer5"; 539 ti,hwmods = "timer5";
540 ti,timer-dsp; 540 ti,timer-dsp;
541 ti,timer-pwm;
541 }; 542 };
542 543
543 timer6: timer@4013a000 { 544 timer6: timer@4013a000 {
@@ -574,6 +575,7 @@
574 reg = <0x4803e000 0x80>; 575 reg = <0x4803e000 0x80>;
575 interrupts = <0 45 0x4>; 576 interrupts = <0 45 0x4>;
576 ti,hwmods = "timer9"; 577 ti,hwmods = "timer9";
578 ti,timer-pwm;
577 }; 579 };
578 580
579 timer10: timer@48086000 { 581 timer10: timer@48086000 {
@@ -581,6 +583,7 @@
581 reg = <0x48086000 0x80>; 583 reg = <0x48086000 0x80>;
582 interrupts = <0 46 0x4>; 584 interrupts = <0 46 0x4>;
583 ti,hwmods = "timer10"; 585 ti,hwmods = "timer10";
586 ti,timer-pwm;
584 }; 587 };
585 588
586 timer11: timer@48088000 { 589 timer11: timer@48088000 {
diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
index bff71388e72a..17d0ae8672fa 100644
--- a/arch/arm/include/asm/cacheflush.h
+++ b/arch/arm/include/asm/cacheflush.h
@@ -320,9 +320,7 @@ static inline void flush_anon_page(struct vm_area_struct *vma,
320} 320}
321 321
322#define ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE 322#define ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE
323static inline void flush_kernel_dcache_page(struct page *page) 323extern void flush_kernel_dcache_page(struct page *);
324{
325}
326 324
327#define flush_dcache_mmap_lock(mapping) \ 325#define flush_dcache_mmap_lock(mapping) \
328 spin_lock_irq(&(mapping)->tree_lock) 326 spin_lock_irq(&(mapping)->tree_lock)
diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c
index 8ef8c9337809..4fb074c446bf 100644
--- a/arch/arm/kernel/machine_kexec.c
+++ b/arch/arm/kernel/machine_kexec.c
@@ -134,6 +134,10 @@ void machine_kexec(struct kimage *image)
134 unsigned long reboot_code_buffer_phys; 134 unsigned long reboot_code_buffer_phys;
135 void *reboot_code_buffer; 135 void *reboot_code_buffer;
136 136
137 if (num_online_cpus() > 1) {
138 pr_err("kexec: error: multiple CPUs still online\n");
139 return;
140 }
137 141
138 page_list = image->head & PAGE_MASK; 142 page_list = image->head & PAGE_MASK;
139 143
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 282de4826abb..6e8931ccf13e 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -184,30 +184,61 @@ int __init reboot_setup(char *str)
184 184
185__setup("reboot=", reboot_setup); 185__setup("reboot=", reboot_setup);
186 186
187/*
188 * Called by kexec, immediately prior to machine_kexec().
189 *
190 * This must completely disable all secondary CPUs; simply causing those CPUs
191 * to execute e.g. a RAM-based pin loop is not sufficient. This allows the
192 * kexec'd kernel to use any and all RAM as it sees fit, without having to
193 * avoid any code or data used by any SW CPU pin loop. The CPU hotplug
194 * functionality embodied in disable_nonboot_cpus() to achieve this.
195 */
187void machine_shutdown(void) 196void machine_shutdown(void)
188{ 197{
189#ifdef CONFIG_SMP 198 disable_nonboot_cpus();
190 smp_send_stop();
191#endif
192} 199}
193 200
201/*
202 * Halting simply requires that the secondary CPUs stop performing any
203 * activity (executing tasks, handling interrupts). smp_send_stop()
204 * achieves this.
205 */
194void machine_halt(void) 206void machine_halt(void)
195{ 207{
196 machine_shutdown(); 208 smp_send_stop();
209
197 local_irq_disable(); 210 local_irq_disable();
198 while (1); 211 while (1);
199} 212}
200 213
214/*
215 * Power-off simply requires that the secondary CPUs stop performing any
216 * activity (executing tasks, handling interrupts). smp_send_stop()
217 * achieves this. When the system power is turned off, it will take all CPUs
218 * with it.
219 */
201void machine_power_off(void) 220void machine_power_off(void)
202{ 221{
203 machine_shutdown(); 222 smp_send_stop();
223
204 if (pm_power_off) 224 if (pm_power_off)
205 pm_power_off(); 225 pm_power_off();
206} 226}
207 227
228/*
229 * Restart requires that the secondary CPUs stop performing any activity
230 * while the primary CPU resets the system. Systems with a single CPU can
231 * use soft_restart() as their machine descriptor's .restart hook, since that
232 * will cause the only available CPU to reset. Systems with multiple CPUs must
233 * provide a HW restart implementation, to ensure that all CPUs reset at once.
234 * This is required so that any code running after reset on the primary CPU
235 * doesn't have to co-ordinate with other CPUs to ensure they aren't still
236 * executing pre-reset code, and using RAM that the primary CPU's code wishes
237 * to use. Implementing such co-ordination would be essentially impossible.
238 */
208void machine_restart(char *cmd) 239void machine_restart(char *cmd)
209{ 240{
210 machine_shutdown(); 241 smp_send_stop();
211 242
212 arm_pm_restart(reboot_mode, cmd); 243 arm_pm_restart(reboot_mode, cmd);
213 244
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 550d63cef68e..5919eb451bb9 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -651,17 +651,6 @@ void smp_send_reschedule(int cpu)
651 smp_cross_call(cpumask_of(cpu), IPI_RESCHEDULE); 651 smp_cross_call(cpumask_of(cpu), IPI_RESCHEDULE);
652} 652}
653 653
654#ifdef CONFIG_HOTPLUG_CPU
655static void smp_kill_cpus(cpumask_t *mask)
656{
657 unsigned int cpu;
658 for_each_cpu(cpu, mask)
659 platform_cpu_kill(cpu);
660}
661#else
662static void smp_kill_cpus(cpumask_t *mask) { }
663#endif
664
665void smp_send_stop(void) 654void smp_send_stop(void)
666{ 655{
667 unsigned long timeout; 656 unsigned long timeout;
@@ -679,8 +668,6 @@ void smp_send_stop(void)
679 668
680 if (num_online_cpus() > 1) 669 if (num_online_cpus() > 1)
681 pr_warning("SMP: failed to stop secondary CPUs\n"); 670 pr_warning("SMP: failed to stop secondary CPUs\n");
682
683 smp_kill_cpus(&mask);
684} 671}
685 672
686/* 673/*
diff --git a/arch/arm/mach-kirkwood/mpp.c b/arch/arm/mach-kirkwood/mpp.c
index 827cde42414f..e96fd71abd76 100644
--- a/arch/arm/mach-kirkwood/mpp.c
+++ b/arch/arm/mach-kirkwood/mpp.c
@@ -22,9 +22,10 @@ static unsigned int __init kirkwood_variant(void)
22 22
23 kirkwood_pcie_id(&dev, &rev); 23 kirkwood_pcie_id(&dev, &rev);
24 24
25 if ((dev == MV88F6281_DEV_ID && rev >= MV88F6281_REV_A0) || 25 if (dev == MV88F6281_DEV_ID && rev >= MV88F6281_REV_A0)
26 (dev == MV88F6282_DEV_ID))
27 return MPP_F6281_MASK; 26 return MPP_F6281_MASK;
27 if (dev == MV88F6282_DEV_ID)
28 return MPP_F6282_MASK;
28 if (dev == MV88F6192_DEV_ID && rev >= MV88F6192_REV_A0) 29 if (dev == MV88F6192_DEV_ID && rev >= MV88F6192_REV_A0)
29 return MPP_F6192_MASK; 30 return MPP_F6192_MASK;
30 if (dev == MV88F6180_DEV_ID) 31 if (dev == MV88F6180_DEV_ID)
diff --git a/arch/arm/mach-omap2/clock36xx.c b/arch/arm/mach-omap2/clock36xx.c
index 8f3bf4e50908..bbd6a3f717e6 100644
--- a/arch/arm/mach-omap2/clock36xx.c
+++ b/arch/arm/mach-omap2/clock36xx.c
@@ -20,11 +20,12 @@
20 20
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/clk.h> 22#include <linux/clk.h>
23#include <linux/clk-provider.h>
23#include <linux/io.h> 24#include <linux/io.h>
24 25
25#include "clock.h" 26#include "clock.h"
26#include "clock36xx.h" 27#include "clock36xx.h"
27 28#define to_clk_divider(_hw) container_of(_hw, struct clk_divider, hw)
28 29
29/** 30/**
30 * omap36xx_pwrdn_clk_enable_with_hsdiv_restore - enable clocks suffering 31 * omap36xx_pwrdn_clk_enable_with_hsdiv_restore - enable clocks suffering
@@ -39,29 +40,28 @@
39 */ 40 */
40int omap36xx_pwrdn_clk_enable_with_hsdiv_restore(struct clk_hw *clk) 41int omap36xx_pwrdn_clk_enable_with_hsdiv_restore(struct clk_hw *clk)
41{ 42{
42 struct clk_hw_omap *parent; 43 struct clk_divider *parent;
43 struct clk_hw *parent_hw; 44 struct clk_hw *parent_hw;
44 u32 dummy_v, orig_v, clksel_shift; 45 u32 dummy_v, orig_v;
45 int ret; 46 int ret;
46 47
47 /* Clear PWRDN bit of HSDIVIDER */ 48 /* Clear PWRDN bit of HSDIVIDER */
48 ret = omap2_dflt_clk_enable(clk); 49 ret = omap2_dflt_clk_enable(clk);
49 50
50 parent_hw = __clk_get_hw(__clk_get_parent(clk->clk)); 51 parent_hw = __clk_get_hw(__clk_get_parent(clk->clk));
51 parent = to_clk_hw_omap(parent_hw); 52 parent = to_clk_divider(parent_hw);
52 53
53 /* Restore the dividers */ 54 /* Restore the dividers */
54 if (!ret) { 55 if (!ret) {
55 clksel_shift = __ffs(parent->clksel_mask); 56 orig_v = __raw_readl(parent->reg);
56 orig_v = __raw_readl(parent->clksel_reg);
57 dummy_v = orig_v; 57 dummy_v = orig_v;
58 58
59 /* Write any other value different from the Read value */ 59 /* Write any other value different from the Read value */
60 dummy_v ^= (1 << clksel_shift); 60 dummy_v ^= (1 << parent->shift);
61 __raw_writel(dummy_v, parent->clksel_reg); 61 __raw_writel(dummy_v, parent->reg);
62 62
63 /* Write the original divider */ 63 /* Write the original divider */
64 __raw_writel(orig_v, parent->clksel_reg); 64 __raw_writel(orig_v, parent->reg);
65 } 65 }
66 66
67 return ret; 67 return ret;
diff --git a/arch/arm/mach-omap2/omap_hwmod_33xx_data.c b/arch/arm/mach-omap2/omap_hwmod_33xx_data.c
index 075f7cc51026..69337af748cc 100644
--- a/arch/arm/mach-omap2/omap_hwmod_33xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_33xx_data.c
@@ -2007,6 +2007,13 @@ static struct omap_hwmod am33xx_uart1_hwmod = {
2007 }, 2007 },
2008}; 2008};
2009 2009
2010/* uart2 */
2011static struct omap_hwmod_dma_info uart2_edma_reqs[] = {
2012 { .name = "tx", .dma_req = 28, },
2013 { .name = "rx", .dma_req = 29, },
2014 { .dma_req = -1 }
2015};
2016
2010static struct omap_hwmod_irq_info am33xx_uart2_irqs[] = { 2017static struct omap_hwmod_irq_info am33xx_uart2_irqs[] = {
2011 { .irq = 73 + OMAP_INTC_START, }, 2018 { .irq = 73 + OMAP_INTC_START, },
2012 { .irq = -1 }, 2019 { .irq = -1 },
@@ -2018,7 +2025,7 @@ static struct omap_hwmod am33xx_uart2_hwmod = {
2018 .clkdm_name = "l4ls_clkdm", 2025 .clkdm_name = "l4ls_clkdm",
2019 .flags = HWMOD_SWSUP_SIDLE_ACT, 2026 .flags = HWMOD_SWSUP_SIDLE_ACT,
2020 .mpu_irqs = am33xx_uart2_irqs, 2027 .mpu_irqs = am33xx_uart2_irqs,
2021 .sdma_reqs = uart1_edma_reqs, 2028 .sdma_reqs = uart2_edma_reqs,
2022 .main_clk = "dpll_per_m2_div4_ck", 2029 .main_clk = "dpll_per_m2_div4_ck",
2023 .prcm = { 2030 .prcm = {
2024 .omap4 = { 2031 .omap4 = {
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index c01859398b54..5a2d8034c8de 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -546,8 +546,10 @@ static void __init prcm_setup_regs(void)
546 /* Clear any pending PRCM interrupts */ 546 /* Clear any pending PRCM interrupts */
547 omap2_prm_write_mod_reg(0, OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET); 547 omap2_prm_write_mod_reg(0, OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET);
548 548
549 if (omap3_has_iva()) 549 /*
550 omap3_iva_idle(); 550 * We need to idle iva2_pwrdm even on am3703 with no iva2.
551 */
552 omap3_iva_idle();
551 553
552 omap3_d2d_idle(); 554 omap3_d2d_idle();
553} 555}
diff --git a/arch/arm/mach-prima2/pm.c b/arch/arm/mach-prima2/pm.c
index 9936c180bf01..8f595c0cc8d9 100644
--- a/arch/arm/mach-prima2/pm.c
+++ b/arch/arm/mach-prima2/pm.c
@@ -101,8 +101,10 @@ static int __init sirfsoc_of_pwrc_init(void)
101 struct device_node *np; 101 struct device_node *np;
102 102
103 np = of_find_matching_node(NULL, pwrc_ids); 103 np = of_find_matching_node(NULL, pwrc_ids);
104 if (!np) 104 if (!np) {
105 panic("unable to find compatible pwrc node in dtb\n"); 105 pr_err("unable to find compatible sirf pwrc node in dtb\n");
106 return -ENOENT;
107 }
106 108
107 /* 109 /*
108 * pwrc behind rtciobrg is not located in memory space 110 * pwrc behind rtciobrg is not located in memory space
diff --git a/arch/arm/mach-prima2/rstc.c b/arch/arm/mach-prima2/rstc.c
index 435019ca0a48..d5e0cbc934c0 100644
--- a/arch/arm/mach-prima2/rstc.c
+++ b/arch/arm/mach-prima2/rstc.c
@@ -28,8 +28,10 @@ static int __init sirfsoc_of_rstc_init(void)
28 struct device_node *np; 28 struct device_node *np;
29 29
30 np = of_find_matching_node(NULL, rstc_ids); 30 np = of_find_matching_node(NULL, rstc_ids);
31 if (!np) 31 if (!np) {
32 panic("unable to find compatible rstc node in dtb\n"); 32 pr_err("unable to find compatible sirf rstc node in dtb\n");
33 return -ENOENT;
34 }
33 35
34 sirfsoc_rstc_base = of_iomap(np, 0); 36 sirfsoc_rstc_base = of_iomap(np, 0);
35 if (!sirfsoc_rstc_base) 37 if (!sirfsoc_rstc_base)
diff --git a/arch/arm/mm/cache-v7.S b/arch/arm/mm/cache-v7.S
index 15451ee4acc8..515b00064da8 100644
--- a/arch/arm/mm/cache-v7.S
+++ b/arch/arm/mm/cache-v7.S
@@ -92,6 +92,14 @@ ENTRY(v7_flush_dcache_louis)
92 mrc p15, 1, r0, c0, c0, 1 @ read clidr, r0 = clidr 92 mrc p15, 1, r0, c0, c0, 1 @ read clidr, r0 = clidr
93 ALT_SMP(ands r3, r0, #(7 << 21)) @ extract LoUIS from clidr 93 ALT_SMP(ands r3, r0, #(7 << 21)) @ extract LoUIS from clidr
94 ALT_UP(ands r3, r0, #(7 << 27)) @ extract LoUU from clidr 94 ALT_UP(ands r3, r0, #(7 << 27)) @ extract LoUU from clidr
95#ifdef CONFIG_ARM_ERRATA_643719
96 ALT_SMP(mrceq p15, 0, r2, c0, c0, 0) @ read main ID register
97 ALT_UP(moveq pc, lr) @ LoUU is zero, so nothing to do
98 ldreq r1, =0x410fc090 @ ID of ARM Cortex A9 r0p?
99 biceq r2, r2, #0x0000000f @ clear minor revision number
100 teqeq r2, r1 @ test for errata affected core and if so...
101 orreqs r3, #(1 << 21) @ fix LoUIS value (and set flags state to 'ne')
102#endif
95 ALT_SMP(mov r3, r3, lsr #20) @ r3 = LoUIS * 2 103 ALT_SMP(mov r3, r3, lsr #20) @ r3 = LoUIS * 2
96 ALT_UP(mov r3, r3, lsr #26) @ r3 = LoUU * 2 104 ALT_UP(mov r3, r3, lsr #26) @ r3 = LoUU * 2
97 moveq pc, lr @ return if level == 0 105 moveq pc, lr @ return if level == 0
diff --git a/arch/arm/mm/flush.c b/arch/arm/mm/flush.c
index 0d473cce501c..32aa5861119f 100644
--- a/arch/arm/mm/flush.c
+++ b/arch/arm/mm/flush.c
@@ -301,6 +301,39 @@ void flush_dcache_page(struct page *page)
301EXPORT_SYMBOL(flush_dcache_page); 301EXPORT_SYMBOL(flush_dcache_page);
302 302
303/* 303/*
304 * Ensure cache coherency for the kernel mapping of this page. We can
305 * assume that the page is pinned via kmap.
306 *
307 * If the page only exists in the page cache and there are no user
308 * space mappings, this is a no-op since the page was already marked
309 * dirty at creation. Otherwise, we need to flush the dirty kernel
310 * cache lines directly.
311 */
312void flush_kernel_dcache_page(struct page *page)
313{
314 if (cache_is_vivt() || cache_is_vipt_aliasing()) {
315 struct address_space *mapping;
316
317 mapping = page_mapping(page);
318
319 if (!mapping || mapping_mapped(mapping)) {
320 void *addr;
321
322 addr = page_address(page);
323 /*
324 * kmap_atomic() doesn't set the page virtual
325 * address for highmem pages, and
326 * kunmap_atomic() takes care of cache
327 * flushing already.
328 */
329 if (!IS_ENABLED(CONFIG_HIGHMEM) || addr)
330 __cpuc_flush_dcache_area(addr, PAGE_SIZE);
331 }
332 }
333}
334EXPORT_SYMBOL(flush_kernel_dcache_page);
335
336/*
304 * Flush an anonymous page so that users of get_user_pages() 337 * Flush an anonymous page so that users of get_user_pages()
305 * can safely access the data. The expected sequence is: 338 * can safely access the data. The expected sequence is:
306 * 339 *
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index e0d8565671a6..4d409e6a552d 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -616,10 +616,12 @@ static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr,
616 } while (pte++, addr += PAGE_SIZE, addr != end); 616 } while (pte++, addr += PAGE_SIZE, addr != end);
617} 617}
618 618
619static void __init map_init_section(pmd_t *pmd, unsigned long addr, 619static void __init __map_init_section(pmd_t *pmd, unsigned long addr,
620 unsigned long end, phys_addr_t phys, 620 unsigned long end, phys_addr_t phys,
621 const struct mem_type *type) 621 const struct mem_type *type)
622{ 622{
623 pmd_t *p = pmd;
624
623#ifndef CONFIG_ARM_LPAE 625#ifndef CONFIG_ARM_LPAE
624 /* 626 /*
625 * In classic MMU format, puds and pmds are folded in to 627 * In classic MMU format, puds and pmds are folded in to
@@ -638,7 +640,7 @@ static void __init map_init_section(pmd_t *pmd, unsigned long addr,
638 phys += SECTION_SIZE; 640 phys += SECTION_SIZE;
639 } while (pmd++, addr += SECTION_SIZE, addr != end); 641 } while (pmd++, addr += SECTION_SIZE, addr != end);
640 642
641 flush_pmd_entry(pmd); 643 flush_pmd_entry(p);
642} 644}
643 645
644static void __init alloc_init_pmd(pud_t *pud, unsigned long addr, 646static void __init alloc_init_pmd(pud_t *pud, unsigned long addr,
@@ -661,7 +663,7 @@ static void __init alloc_init_pmd(pud_t *pud, unsigned long addr,
661 */ 663 */
662 if (type->prot_sect && 664 if (type->prot_sect &&
663 ((addr | next | phys) & ~SECTION_MASK) == 0) { 665 ((addr | next | phys) & ~SECTION_MASK) == 0) {
664 map_init_section(pmd, addr, next, phys, type); 666 __map_init_section(pmd, addr, next, phys, type);
665 } else { 667 } else {
666 alloc_init_pte(pmd, addr, next, 668 alloc_init_pte(pmd, addr, next,
667 __phys_to_pfn(phys), type); 669 __phys_to_pfn(phys), type);
diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S
index 2c73a7301ff7..4c8c9c10a388 100644
--- a/arch/arm/mm/proc-v7.S
+++ b/arch/arm/mm/proc-v7.S
@@ -409,8 +409,8 @@ __v7_ca9mp_proc_info:
409 */ 409 */
410 .type __v7_pj4b_proc_info, #object 410 .type __v7_pj4b_proc_info, #object
411__v7_pj4b_proc_info: 411__v7_pj4b_proc_info:
412 .long 0x562f5840 412 .long 0x560f5800
413 .long 0xfffffff0 413 .long 0xff0fff00
414 __v7_proc __v7_pj4b_setup 414 __v7_proc __v7_pj4b_setup
415 .size __v7_pj4b_proc_info, . - __v7_pj4b_proc_info 415 .size __v7_pj4b_proc_info, . - __v7_pj4b_proc_info
416 416
diff --git a/arch/arm/plat-samsung/pm.c b/arch/arm/plat-samsung/pm.c
index 53210ec4e8ec..bd7124c87fea 100644
--- a/arch/arm/plat-samsung/pm.c
+++ b/arch/arm/plat-samsung/pm.c
@@ -16,6 +16,7 @@
16#include <linux/suspend.h> 16#include <linux/suspend.h>
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/of.h>
19#include <linux/serial_core.h> 20#include <linux/serial_core.h>
20#include <linux/io.h> 21#include <linux/io.h>
21 22
@@ -261,7 +262,8 @@ static int s3c_pm_enter(suspend_state_t state)
261 * require a full power-cycle) 262 * require a full power-cycle)
262 */ 263 */
263 264
264 if (!any_allowed(s3c_irqwake_intmask, s3c_irqwake_intallow) && 265 if (!of_have_populated_dt() &&
266 !any_allowed(s3c_irqwake_intmask, s3c_irqwake_intallow) &&
265 !any_allowed(s3c_irqwake_eintmask, s3c_irqwake_eintallow)) { 267 !any_allowed(s3c_irqwake_eintmask, s3c_irqwake_eintallow)) {
266 printk(KERN_ERR "%s: No wake-up sources!\n", __func__); 268 printk(KERN_ERR "%s: No wake-up sources!\n", __func__);
267 printk(KERN_ERR "%s: Aborting sleep\n", __func__); 269 printk(KERN_ERR "%s: Aborting sleep\n", __func__);
@@ -270,8 +272,11 @@ static int s3c_pm_enter(suspend_state_t state)
270 272
271 /* save all necessary core registers not covered by the drivers */ 273 /* save all necessary core registers not covered by the drivers */
272 274
273 samsung_pm_save_gpios(); 275 if (!of_have_populated_dt()) {
274 samsung_pm_saved_gpios(); 276 samsung_pm_save_gpios();
277 samsung_pm_saved_gpios();
278 }
279
275 s3c_pm_save_uarts(); 280 s3c_pm_save_uarts();
276 s3c_pm_save_core(); 281 s3c_pm_save_core();
277 282
@@ -310,8 +315,11 @@ static int s3c_pm_enter(suspend_state_t state)
310 315
311 s3c_pm_restore_core(); 316 s3c_pm_restore_core();
312 s3c_pm_restore_uarts(); 317 s3c_pm_restore_uarts();
313 samsung_pm_restore_gpios(); 318
314 s3c_pm_restored_gpios(); 319 if (!of_have_populated_dt()) {
320 samsung_pm_restore_gpios();
321 s3c_pm_restored_gpios();
322 }
315 323
316 s3c_pm_debug_init(); 324 s3c_pm_debug_init();
317 325
diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c
index 1e49e5eb81e9..9ba33c40cdf8 100644
--- a/arch/arm64/kernel/perf_event.c
+++ b/arch/arm64/kernel/perf_event.c
@@ -1336,6 +1336,7 @@ void perf_callchain_user(struct perf_callchain_entry *entry,
1336 return; 1336 return;
1337 } 1337 }
1338 1338
1339 perf_callchain_store(entry, regs->pc);
1339 tail = (struct frame_tail __user *)regs->regs[29]; 1340 tail = (struct frame_tail __user *)regs->regs[29];
1340 1341
1341 while (entry->nr < PERF_MAX_STACK_DEPTH && 1342 while (entry->nr < PERF_MAX_STACK_DEPTH &&
diff --git a/arch/ia64/include/asm/irqflags.h b/arch/ia64/include/asm/irqflags.h
index 1bf2cf2f4ab4..cec6c06b52c0 100644
--- a/arch/ia64/include/asm/irqflags.h
+++ b/arch/ia64/include/asm/irqflags.h
@@ -11,6 +11,7 @@
11#define _ASM_IA64_IRQFLAGS_H 11#define _ASM_IA64_IRQFLAGS_H
12 12
13#include <asm/pal.h> 13#include <asm/pal.h>
14#include <asm/kregs.h>
14 15
15#ifdef CONFIG_IA64_DEBUG_IRQ 16#ifdef CONFIG_IA64_DEBUG_IRQ
16extern unsigned long last_cli_ip; 17extern unsigned long last_cli_ip;
diff --git a/arch/metag/include/asm/hugetlb.h b/arch/metag/include/asm/hugetlb.h
index f545477e61f3..471f481e67f3 100644
--- a/arch/metag/include/asm/hugetlb.h
+++ b/arch/metag/include/asm/hugetlb.h
@@ -2,6 +2,7 @@
2#define _ASM_METAG_HUGETLB_H 2#define _ASM_METAG_HUGETLB_H
3 3
4#include <asm/page.h> 4#include <asm/page.h>
5#include <asm-generic/hugetlb.h>
5 6
6 7
7static inline int is_hugepage_only_range(struct mm_struct *mm, 8static inline int is_hugepage_only_range(struct mm_struct *mm,
diff --git a/arch/mips/include/asm/mmu_context.h b/arch/mips/include/asm/mmu_context.h
index 820116067c10..516e6e9a5594 100644
--- a/arch/mips/include/asm/mmu_context.h
+++ b/arch/mips/include/asm/mmu_context.h
@@ -117,7 +117,7 @@ get_new_mmu_context(struct mm_struct *mm, unsigned long cpu)
117 if (! ((asid += ASID_INC) & ASID_MASK) ) { 117 if (! ((asid += ASID_INC) & ASID_MASK) ) {
118 if (cpu_has_vtag_icache) 118 if (cpu_has_vtag_icache)
119 flush_icache_all(); 119 flush_icache_all();
120#ifdef CONFIG_VIRTUALIZATION 120#ifdef CONFIG_KVM
121 kvm_local_flush_tlb_all(); /* start new asid cycle */ 121 kvm_local_flush_tlb_all(); /* start new asid cycle */
122#else 122#else
123 local_flush_tlb_all(); /* start new asid cycle */ 123 local_flush_tlb_all(); /* start new asid cycle */
diff --git a/arch/mips/include/uapi/asm/kvm.h b/arch/mips/include/uapi/asm/kvm.h
index 3f424f5217da..f09ff5ae2059 100644
--- a/arch/mips/include/uapi/asm/kvm.h
+++ b/arch/mips/include/uapi/asm/kvm.h
@@ -58,56 +58,53 @@ struct kvm_fpu {
58 * bits[2..0] - Register 'sel' index. 58 * bits[2..0] - Register 'sel' index.
59 * bits[7..3] - Register 'rd' index. 59 * bits[7..3] - Register 'rd' index.
60 * bits[15..8] - Must be zero. 60 * bits[15..8] - Must be zero.
61 * bits[63..16] - 1 -> CP0 registers. 61 * bits[31..16] - 1 -> CP0 registers.
62 * bits[51..32] - Must be zero.
63 * bits[63..52] - As per linux/kvm.h
62 * 64 *
63 * Other sets registers may be added in the future. Each set would 65 * Other sets registers may be added in the future. Each set would
64 * have its own identifier in bits[63..16]. 66 * have its own identifier in bits[31..16].
65 *
66 * The addr field of struct kvm_one_reg must point to an aligned
67 * 64-bit wide location. For registers that are narrower than
68 * 64-bits, the value is stored in the low order bits of the location,
69 * and sign extended to 64-bits.
70 * 67 *
71 * The registers defined in struct kvm_regs are also accessible, the 68 * The registers defined in struct kvm_regs are also accessible, the
72 * id values for these are below. 69 * id values for these are below.
73 */ 70 */
74 71
75#define KVM_REG_MIPS_R0 0 72#define KVM_REG_MIPS_R0 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 0)
76#define KVM_REG_MIPS_R1 1 73#define KVM_REG_MIPS_R1 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 1)
77#define KVM_REG_MIPS_R2 2 74#define KVM_REG_MIPS_R2 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 2)
78#define KVM_REG_MIPS_R3 3 75#define KVM_REG_MIPS_R3 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 3)
79#define KVM_REG_MIPS_R4 4 76#define KVM_REG_MIPS_R4 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 4)
80#define KVM_REG_MIPS_R5 5 77#define KVM_REG_MIPS_R5 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 5)
81#define KVM_REG_MIPS_R6 6 78#define KVM_REG_MIPS_R6 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 6)
82#define KVM_REG_MIPS_R7 7 79#define KVM_REG_MIPS_R7 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 7)
83#define KVM_REG_MIPS_R8 8 80#define KVM_REG_MIPS_R8 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 8)
84#define KVM_REG_MIPS_R9 9 81#define KVM_REG_MIPS_R9 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 9)
85#define KVM_REG_MIPS_R10 10 82#define KVM_REG_MIPS_R10 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 10)
86#define KVM_REG_MIPS_R11 11 83#define KVM_REG_MIPS_R11 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 11)
87#define KVM_REG_MIPS_R12 12 84#define KVM_REG_MIPS_R12 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 12)
88#define KVM_REG_MIPS_R13 13 85#define KVM_REG_MIPS_R13 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 13)
89#define KVM_REG_MIPS_R14 14 86#define KVM_REG_MIPS_R14 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 14)
90#define KVM_REG_MIPS_R15 15 87#define KVM_REG_MIPS_R15 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 15)
91#define KVM_REG_MIPS_R16 16 88#define KVM_REG_MIPS_R16 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 16)
92#define KVM_REG_MIPS_R17 17 89#define KVM_REG_MIPS_R17 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 17)
93#define KVM_REG_MIPS_R18 18 90#define KVM_REG_MIPS_R18 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 18)
94#define KVM_REG_MIPS_R19 19 91#define KVM_REG_MIPS_R19 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 19)
95#define KVM_REG_MIPS_R20 20 92#define KVM_REG_MIPS_R20 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 20)
96#define KVM_REG_MIPS_R21 21 93#define KVM_REG_MIPS_R21 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 21)
97#define KVM_REG_MIPS_R22 22 94#define KVM_REG_MIPS_R22 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 22)
98#define KVM_REG_MIPS_R23 23 95#define KVM_REG_MIPS_R23 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 23)
99#define KVM_REG_MIPS_R24 24 96#define KVM_REG_MIPS_R24 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 24)
100#define KVM_REG_MIPS_R25 25 97#define KVM_REG_MIPS_R25 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 25)
101#define KVM_REG_MIPS_R26 26 98#define KVM_REG_MIPS_R26 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 26)
102#define KVM_REG_MIPS_R27 27 99#define KVM_REG_MIPS_R27 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 27)
103#define KVM_REG_MIPS_R28 28 100#define KVM_REG_MIPS_R28 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 28)
104#define KVM_REG_MIPS_R29 29 101#define KVM_REG_MIPS_R29 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 29)
105#define KVM_REG_MIPS_R30 30 102#define KVM_REG_MIPS_R30 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 30)
106#define KVM_REG_MIPS_R31 31 103#define KVM_REG_MIPS_R31 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 31)
107 104
108#define KVM_REG_MIPS_HI 32 105#define KVM_REG_MIPS_HI (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 32)
109#define KVM_REG_MIPS_LO 33 106#define KVM_REG_MIPS_LO (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 33)
110#define KVM_REG_MIPS_PC 34 107#define KVM_REG_MIPS_PC (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 34)
111 108
112/* 109/*
113 * KVM MIPS specific structures and definitions 110 * KVM MIPS specific structures and definitions
diff --git a/arch/mips/kernel/ftrace.c b/arch/mips/kernel/ftrace.c
index cf5509f13dd5..dba90ec0dc38 100644
--- a/arch/mips/kernel/ftrace.c
+++ b/arch/mips/kernel/ftrace.c
@@ -25,12 +25,16 @@
25#define MCOUNT_OFFSET_INSNS 4 25#define MCOUNT_OFFSET_INSNS 4
26#endif 26#endif
27 27
28#ifdef CONFIG_DYNAMIC_FTRACE
29
28/* Arch override because MIPS doesn't need to run this from stop_machine() */ 30/* Arch override because MIPS doesn't need to run this from stop_machine() */
29void arch_ftrace_update_code(int command) 31void arch_ftrace_update_code(int command)
30{ 32{
31 ftrace_modify_all_code(command); 33 ftrace_modify_all_code(command);
32} 34}
33 35
36#endif
37
34/* 38/*
35 * Check if the address is in kernel space 39 * Check if the address is in kernel space
36 * 40 *
diff --git a/arch/mips/kernel/idle.c b/arch/mips/kernel/idle.c
index 3b09b888afa9..0c655deeea4a 100644
--- a/arch/mips/kernel/idle.c
+++ b/arch/mips/kernel/idle.c
@@ -93,26 +93,27 @@ static void rm7k_wait_irqoff(void)
93} 93}
94 94
95/* 95/*
96 * The Au1xxx wait is available only if using 32khz counter or 96 * Au1 'wait' is only useful when the 32kHz counter is used as timer,
97 * external timer source, but specifically not CP0 Counter. 97 * since coreclock (and the cp0 counter) stops upon executing it. Only an
98 * alchemy/common/time.c may override cpu_wait! 98 * interrupt can wake it, so they must be enabled before entering idle modes.
99 */ 99 */
100static void au1k_wait(void) 100static void au1k_wait(void)
101{ 101{
102 unsigned long c0status = read_c0_status() | 1; /* irqs on */
103
102 __asm__( 104 __asm__(
103 " .set mips3 \n" 105 " .set mips3 \n"
104 " cache 0x14, 0(%0) \n" 106 " cache 0x14, 0(%0) \n"
105 " cache 0x14, 32(%0) \n" 107 " cache 0x14, 32(%0) \n"
106 " sync \n" 108 " sync \n"
107 " nop \n" 109 " mtc0 %1, $12 \n" /* wr c0status */
108 " wait \n" 110 " wait \n"
109 " nop \n" 111 " nop \n"
110 " nop \n" 112 " nop \n"
111 " nop \n" 113 " nop \n"
112 " nop \n" 114 " nop \n"
113 " .set mips0 \n" 115 " .set mips0 \n"
114 : : "r" (au1k_wait)); 116 : : "r" (au1k_wait), "r" (c0status));
115 local_irq_enable();
116} 117}
117 118
118static int __initdata nowait; 119static int __initdata nowait;
diff --git a/arch/mips/kvm/kvm_mips.c b/arch/mips/kvm/kvm_mips.c
index d934b017f479..dd203e59e6fd 100644
--- a/arch/mips/kvm/kvm_mips.c
+++ b/arch/mips/kvm/kvm_mips.c
@@ -485,29 +485,35 @@ kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
485 return -ENOIOCTLCMD; 485 return -ENOIOCTLCMD;
486} 486}
487 487
488#define KVM_REG_MIPS_CP0_INDEX (0x10000 + 8 * 0 + 0) 488#define MIPS_CP0_32(_R, _S) \
489#define KVM_REG_MIPS_CP0_ENTRYLO0 (0x10000 + 8 * 2 + 0) 489 (KVM_REG_MIPS | KVM_REG_SIZE_U32 | 0x10000 | (8 * (_R) + (_S)))
490#define KVM_REG_MIPS_CP0_ENTRYLO1 (0x10000 + 8 * 3 + 0) 490
491#define KVM_REG_MIPS_CP0_CONTEXT (0x10000 + 8 * 4 + 0) 491#define MIPS_CP0_64(_R, _S) \
492#define KVM_REG_MIPS_CP0_USERLOCAL (0x10000 + 8 * 4 + 2) 492 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 0x10000 | (8 * (_R) + (_S)))
493#define KVM_REG_MIPS_CP0_PAGEMASK (0x10000 + 8 * 5 + 0) 493
494#define KVM_REG_MIPS_CP0_PAGEGRAIN (0x10000 + 8 * 5 + 1) 494#define KVM_REG_MIPS_CP0_INDEX MIPS_CP0_32(0, 0)
495#define KVM_REG_MIPS_CP0_WIRED (0x10000 + 8 * 6 + 0) 495#define KVM_REG_MIPS_CP0_ENTRYLO0 MIPS_CP0_64(2, 0)
496#define KVM_REG_MIPS_CP0_HWRENA (0x10000 + 8 * 7 + 0) 496#define KVM_REG_MIPS_CP0_ENTRYLO1 MIPS_CP0_64(3, 0)
497#define KVM_REG_MIPS_CP0_BADVADDR (0x10000 + 8 * 8 + 0) 497#define KVM_REG_MIPS_CP0_CONTEXT MIPS_CP0_64(4, 0)
498#define KVM_REG_MIPS_CP0_COUNT (0x10000 + 8 * 9 + 0) 498#define KVM_REG_MIPS_CP0_USERLOCAL MIPS_CP0_64(4, 2)
499#define KVM_REG_MIPS_CP0_ENTRYHI (0x10000 + 8 * 10 + 0) 499#define KVM_REG_MIPS_CP0_PAGEMASK MIPS_CP0_32(5, 0)
500#define KVM_REG_MIPS_CP0_COMPARE (0x10000 + 8 * 11 + 0) 500#define KVM_REG_MIPS_CP0_PAGEGRAIN MIPS_CP0_32(5, 1)
501#define KVM_REG_MIPS_CP0_STATUS (0x10000 + 8 * 12 + 0) 501#define KVM_REG_MIPS_CP0_WIRED MIPS_CP0_32(6, 0)
502#define KVM_REG_MIPS_CP0_CAUSE (0x10000 + 8 * 13 + 0) 502#define KVM_REG_MIPS_CP0_HWRENA MIPS_CP0_32(7, 0)
503#define KVM_REG_MIPS_CP0_EBASE (0x10000 + 8 * 15 + 1) 503#define KVM_REG_MIPS_CP0_BADVADDR MIPS_CP0_64(8, 0)
504#define KVM_REG_MIPS_CP0_CONFIG (0x10000 + 8 * 16 + 0) 504#define KVM_REG_MIPS_CP0_COUNT MIPS_CP0_32(9, 0)
505#define KVM_REG_MIPS_CP0_CONFIG1 (0x10000 + 8 * 16 + 1) 505#define KVM_REG_MIPS_CP0_ENTRYHI MIPS_CP0_64(10, 0)
506#define KVM_REG_MIPS_CP0_CONFIG2 (0x10000 + 8 * 16 + 2) 506#define KVM_REG_MIPS_CP0_COMPARE MIPS_CP0_32(11, 0)
507#define KVM_REG_MIPS_CP0_CONFIG3 (0x10000 + 8 * 16 + 3) 507#define KVM_REG_MIPS_CP0_STATUS MIPS_CP0_32(12, 0)
508#define KVM_REG_MIPS_CP0_CONFIG7 (0x10000 + 8 * 16 + 7) 508#define KVM_REG_MIPS_CP0_CAUSE MIPS_CP0_32(13, 0)
509#define KVM_REG_MIPS_CP0_XCONTEXT (0x10000 + 8 * 20 + 0) 509#define KVM_REG_MIPS_CP0_EBASE MIPS_CP0_64(15, 1)
510#define KVM_REG_MIPS_CP0_ERROREPC (0x10000 + 8 * 30 + 0) 510#define KVM_REG_MIPS_CP0_CONFIG MIPS_CP0_32(16, 0)
511#define KVM_REG_MIPS_CP0_CONFIG1 MIPS_CP0_32(16, 1)
512#define KVM_REG_MIPS_CP0_CONFIG2 MIPS_CP0_32(16, 2)
513#define KVM_REG_MIPS_CP0_CONFIG3 MIPS_CP0_32(16, 3)
514#define KVM_REG_MIPS_CP0_CONFIG7 MIPS_CP0_32(16, 7)
515#define KVM_REG_MIPS_CP0_XCONTEXT MIPS_CP0_64(20, 0)
516#define KVM_REG_MIPS_CP0_ERROREPC MIPS_CP0_64(30, 0)
511 517
512static u64 kvm_mips_get_one_regs[] = { 518static u64 kvm_mips_get_one_regs[] = {
513 KVM_REG_MIPS_R0, 519 KVM_REG_MIPS_R0,
@@ -567,8 +573,6 @@ static u64 kvm_mips_get_one_regs[] = {
567static int kvm_mips_get_reg(struct kvm_vcpu *vcpu, 573static int kvm_mips_get_reg(struct kvm_vcpu *vcpu,
568 const struct kvm_one_reg *reg) 574 const struct kvm_one_reg *reg)
569{ 575{
570 u64 __user *uaddr = (u64 __user *)(long)reg->addr;
571
572 struct mips_coproc *cop0 = vcpu->arch.cop0; 576 struct mips_coproc *cop0 = vcpu->arch.cop0;
573 s64 v; 577 s64 v;
574 578
@@ -631,18 +635,39 @@ static int kvm_mips_get_reg(struct kvm_vcpu *vcpu,
631 default: 635 default:
632 return -EINVAL; 636 return -EINVAL;
633 } 637 }
634 return put_user(v, uaddr); 638 if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U64) {
639 u64 __user *uaddr64 = (u64 __user *)(long)reg->addr;
640 return put_user(v, uaddr64);
641 } else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U32) {
642 u32 __user *uaddr32 = (u32 __user *)(long)reg->addr;
643 u32 v32 = (u32)v;
644 return put_user(v32, uaddr32);
645 } else {
646 return -EINVAL;
647 }
635} 648}
636 649
637static int kvm_mips_set_reg(struct kvm_vcpu *vcpu, 650static int kvm_mips_set_reg(struct kvm_vcpu *vcpu,
638 const struct kvm_one_reg *reg) 651 const struct kvm_one_reg *reg)
639{ 652{
640 u64 __user *uaddr = (u64 __user *)(long)reg->addr;
641 struct mips_coproc *cop0 = vcpu->arch.cop0; 653 struct mips_coproc *cop0 = vcpu->arch.cop0;
642 u64 v; 654 u64 v;
643 655
644 if (get_user(v, uaddr) != 0) 656 if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U64) {
645 return -EFAULT; 657 u64 __user *uaddr64 = (u64 __user *)(long)reg->addr;
658
659 if (get_user(v, uaddr64) != 0)
660 return -EFAULT;
661 } else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U32) {
662 u32 __user *uaddr32 = (u32 __user *)(long)reg->addr;
663 s32 v32;
664
665 if (get_user(v32, uaddr32) != 0)
666 return -EFAULT;
667 v = (s64)v32;
668 } else {
669 return -EINVAL;
670 }
646 671
647 switch (reg->id) { 672 switch (reg->id) {
648 case KVM_REG_MIPS_R0: 673 case KVM_REG_MIPS_R0:
diff --git a/arch/mn10300/include/asm/irqflags.h b/arch/mn10300/include/asm/irqflags.h
index 678f68d5f37b..8730c0a3c37d 100644
--- a/arch/mn10300/include/asm/irqflags.h
+++ b/arch/mn10300/include/asm/irqflags.h
@@ -13,9 +13,8 @@
13#define _ASM_IRQFLAGS_H 13#define _ASM_IRQFLAGS_H
14 14
15#include <asm/cpu-regs.h> 15#include <asm/cpu-regs.h>
16#ifndef __ASSEMBLY__ 16/* linux/smp.h <- linux/irqflags.h needs asm/smp.h first */
17#include <linux/smp.h> 17#include <asm/smp.h>
18#endif
19 18
20/* 19/*
21 * interrupt control 20 * interrupt control
diff --git a/arch/mn10300/include/asm/smp.h b/arch/mn10300/include/asm/smp.h
index 6745dbe64944..56c42417d428 100644
--- a/arch/mn10300/include/asm/smp.h
+++ b/arch/mn10300/include/asm/smp.h
@@ -24,6 +24,7 @@
24#ifndef __ASSEMBLY__ 24#ifndef __ASSEMBLY__
25#include <linux/threads.h> 25#include <linux/threads.h>
26#include <linux/cpumask.h> 26#include <linux/cpumask.h>
27#include <linux/thread_info.h>
27#endif 28#endif
28 29
29#ifdef CONFIG_SMP 30#ifdef CONFIG_SMP
@@ -85,7 +86,7 @@ extern cpumask_t cpu_boot_map;
85extern void smp_init_cpus(void); 86extern void smp_init_cpus(void);
86extern void smp_cache_interrupt(void); 87extern void smp_cache_interrupt(void);
87extern void send_IPI_allbutself(int irq); 88extern void send_IPI_allbutself(int irq);
88extern int smp_nmi_call_function(smp_call_func_t func, void *info, int wait); 89extern int smp_nmi_call_function(void (*func)(void *), void *info, int wait);
89 90
90extern void arch_send_call_function_single_ipi(int cpu); 91extern void arch_send_call_function_single_ipi(int cpu);
91extern void arch_send_call_function_ipi_mask(const struct cpumask *mask); 92extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
@@ -100,6 +101,7 @@ extern void __cpu_die(unsigned int cpu);
100#ifndef __ASSEMBLY__ 101#ifndef __ASSEMBLY__
101 102
102static inline void smp_init_cpus(void) {} 103static inline void smp_init_cpus(void) {}
104#define raw_smp_processor_id() 0
103 105
104#endif /* __ASSEMBLY__ */ 106#endif /* __ASSEMBLY__ */
105#endif /* CONFIG_SMP */ 107#endif /* CONFIG_SMP */
diff --git a/arch/parisc/include/asm/mmzone.h b/arch/parisc/include/asm/mmzone.h
index cc50d33b7b88..b6b34a0987e7 100644
--- a/arch/parisc/include/asm/mmzone.h
+++ b/arch/parisc/include/asm/mmzone.h
@@ -27,7 +27,7 @@ extern struct node_map_data node_data[];
27 27
28#define PFNNID_SHIFT (30 - PAGE_SHIFT) 28#define PFNNID_SHIFT (30 - PAGE_SHIFT)
29#define PFNNID_MAP_MAX 512 /* support 512GB */ 29#define PFNNID_MAP_MAX 512 /* support 512GB */
30extern unsigned char pfnnid_map[PFNNID_MAP_MAX]; 30extern signed char pfnnid_map[PFNNID_MAP_MAX];
31 31
32#ifndef CONFIG_64BIT 32#ifndef CONFIG_64BIT
33#define pfn_is_io(pfn) ((pfn & (0xf0000000UL >> PAGE_SHIFT)) == (0xf0000000UL >> PAGE_SHIFT)) 33#define pfn_is_io(pfn) ((pfn & (0xf0000000UL >> PAGE_SHIFT)) == (0xf0000000UL >> PAGE_SHIFT))
@@ -46,7 +46,7 @@ static inline int pfn_to_nid(unsigned long pfn)
46 i = pfn >> PFNNID_SHIFT; 46 i = pfn >> PFNNID_SHIFT;
47 BUG_ON(i >= ARRAY_SIZE(pfnnid_map)); 47 BUG_ON(i >= ARRAY_SIZE(pfnnid_map));
48 48
49 return (int)pfnnid_map[i]; 49 return pfnnid_map[i];
50} 50}
51 51
52static inline int pfn_valid(int pfn) 52static inline int pfn_valid(int pfn)
diff --git a/arch/parisc/include/asm/pci.h b/arch/parisc/include/asm/pci.h
index 3234f492d575..465154076d23 100644
--- a/arch/parisc/include/asm/pci.h
+++ b/arch/parisc/include/asm/pci.h
@@ -225,4 +225,9 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
225 return channel ? 15 : 14; 225 return channel ? 15 : 14;
226} 226}
227 227
228#define HAVE_PCI_MMAP
229
230extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
231 enum pci_mmap_state mmap_state, int write_combine);
232
228#endif /* __ASM_PARISC_PCI_H */ 233#endif /* __ASM_PARISC_PCI_H */
diff --git a/arch/parisc/kernel/hardware.c b/arch/parisc/kernel/hardware.c
index 9e2d2e408529..872275659d98 100644
--- a/arch/parisc/kernel/hardware.c
+++ b/arch/parisc/kernel/hardware.c
@@ -1205,6 +1205,7 @@ static struct hp_hardware hp_hardware_list[] = {
1205 {HPHW_FIO, 0x004, 0x00320, 0x0, "Metheus Frame Buffer"}, 1205 {HPHW_FIO, 0x004, 0x00320, 0x0, "Metheus Frame Buffer"},
1206 {HPHW_FIO, 0x004, 0x00340, 0x0, "BARCO CX4500 VME Grphx Cnsl"}, 1206 {HPHW_FIO, 0x004, 0x00340, 0x0, "BARCO CX4500 VME Grphx Cnsl"},
1207 {HPHW_FIO, 0x004, 0x00360, 0x0, "Hughes TOG VME FDDI"}, 1207 {HPHW_FIO, 0x004, 0x00360, 0x0, "Hughes TOG VME FDDI"},
1208 {HPHW_FIO, 0x076, 0x000AD, 0x00, "Crestone Peak RS-232"},
1208 {HPHW_IOA, 0x185, 0x0000B, 0x00, "Java BC Summit Port"}, 1209 {HPHW_IOA, 0x185, 0x0000B, 0x00, "Java BC Summit Port"},
1209 {HPHW_IOA, 0x1FF, 0x0000B, 0x00, "Hitachi Ghostview Summit Port"}, 1210 {HPHW_IOA, 0x1FF, 0x0000B, 0x00, "Hitachi Ghostview Summit Port"},
1210 {HPHW_IOA, 0x580, 0x0000B, 0x10, "U2-IOA BC Runway Port"}, 1211 {HPHW_IOA, 0x580, 0x0000B, 0x10, "U2-IOA BC Runway Port"},
diff --git a/arch/parisc/kernel/pacache.S b/arch/parisc/kernel/pacache.S
index 36d7f402e48e..b743a80eaba0 100644
--- a/arch/parisc/kernel/pacache.S
+++ b/arch/parisc/kernel/pacache.S
@@ -860,7 +860,7 @@ ENTRY(flush_dcache_page_asm)
860#endif 860#endif
861 861
862 ldil L%dcache_stride, %r1 862 ldil L%dcache_stride, %r1
863 ldw R%dcache_stride(%r1), %r1 863 ldw R%dcache_stride(%r1), r31
864 864
865#ifdef CONFIG_64BIT 865#ifdef CONFIG_64BIT
866 depdi,z 1, 63-PAGE_SHIFT,1, %r25 866 depdi,z 1, 63-PAGE_SHIFT,1, %r25
@@ -868,26 +868,26 @@ ENTRY(flush_dcache_page_asm)
868 depwi,z 1, 31-PAGE_SHIFT,1, %r25 868 depwi,z 1, 31-PAGE_SHIFT,1, %r25
869#endif 869#endif
870 add %r28, %r25, %r25 870 add %r28, %r25, %r25
871 sub %r25, %r1, %r25 871 sub %r25, r31, %r25
872 872
873 873
8741: fdc,m %r1(%r28) 8741: fdc,m r31(%r28)
875 fdc,m %r1(%r28) 875 fdc,m r31(%r28)
876 fdc,m %r1(%r28) 876 fdc,m r31(%r28)
877 fdc,m %r1(%r28) 877 fdc,m r31(%r28)
878 fdc,m %r1(%r28) 878 fdc,m r31(%r28)
879 fdc,m %r1(%r28) 879 fdc,m r31(%r28)
880 fdc,m %r1(%r28) 880 fdc,m r31(%r28)
881 fdc,m %r1(%r28) 881 fdc,m r31(%r28)
882 fdc,m %r1(%r28) 882 fdc,m r31(%r28)
883 fdc,m %r1(%r28) 883 fdc,m r31(%r28)
884 fdc,m %r1(%r28) 884 fdc,m r31(%r28)
885 fdc,m %r1(%r28) 885 fdc,m r31(%r28)
886 fdc,m %r1(%r28) 886 fdc,m r31(%r28)
887 fdc,m %r1(%r28) 887 fdc,m r31(%r28)
888 fdc,m %r1(%r28) 888 fdc,m r31(%r28)
889 cmpb,COND(<<) %r28, %r25,1b 889 cmpb,COND(<<) %r28, %r25,1b
890 fdc,m %r1(%r28) 890 fdc,m r31(%r28)
891 891
892 sync 892 sync
893 893
@@ -936,7 +936,7 @@ ENTRY(flush_icache_page_asm)
936#endif 936#endif
937 937
938 ldil L%icache_stride, %r1 938 ldil L%icache_stride, %r1
939 ldw R%icache_stride(%r1), %r1 939 ldw R%icache_stride(%r1), %r31
940 940
941#ifdef CONFIG_64BIT 941#ifdef CONFIG_64BIT
942 depdi,z 1, 63-PAGE_SHIFT,1, %r25 942 depdi,z 1, 63-PAGE_SHIFT,1, %r25
@@ -944,28 +944,28 @@ ENTRY(flush_icache_page_asm)
944 depwi,z 1, 31-PAGE_SHIFT,1, %r25 944 depwi,z 1, 31-PAGE_SHIFT,1, %r25
945#endif 945#endif
946 add %r28, %r25, %r25 946 add %r28, %r25, %r25
947 sub %r25, %r1, %r25 947 sub %r25, %r31, %r25
948 948
949 949
950 /* fic only has the type 26 form on PA1.1, requiring an 950 /* fic only has the type 26 form on PA1.1, requiring an
951 * explicit space specification, so use %sr4 */ 951 * explicit space specification, so use %sr4 */
9521: fic,m %r1(%sr4,%r28) 9521: fic,m %r31(%sr4,%r28)
953 fic,m %r1(%sr4,%r28) 953 fic,m %r31(%sr4,%r28)
954 fic,m %r1(%sr4,%r28) 954 fic,m %r31(%sr4,%r28)
955 fic,m %r1(%sr4,%r28) 955 fic,m %r31(%sr4,%r28)
956 fic,m %r1(%sr4,%r28) 956 fic,m %r31(%sr4,%r28)
957 fic,m %r1(%sr4,%r28) 957 fic,m %r31(%sr4,%r28)
958 fic,m %r1(%sr4,%r28) 958 fic,m %r31(%sr4,%r28)
959 fic,m %r1(%sr4,%r28) 959 fic,m %r31(%sr4,%r28)
960 fic,m %r1(%sr4,%r28) 960 fic,m %r31(%sr4,%r28)
961 fic,m %r1(%sr4,%r28) 961 fic,m %r31(%sr4,%r28)
962 fic,m %r1(%sr4,%r28) 962 fic,m %r31(%sr4,%r28)
963 fic,m %r1(%sr4,%r28) 963 fic,m %r31(%sr4,%r28)
964 fic,m %r1(%sr4,%r28) 964 fic,m %r31(%sr4,%r28)
965 fic,m %r1(%sr4,%r28) 965 fic,m %r31(%sr4,%r28)
966 fic,m %r1(%sr4,%r28) 966 fic,m %r31(%sr4,%r28)
967 cmpb,COND(<<) %r28, %r25,1b 967 cmpb,COND(<<) %r28, %r25,1b
968 fic,m %r1(%sr4,%r28) 968 fic,m %r31(%sr4,%r28)
969 969
970 sync 970 sync
971 971
diff --git a/arch/parisc/kernel/pci.c b/arch/parisc/kernel/pci.c
index 60309051875e..64f2764a8cef 100644
--- a/arch/parisc/kernel/pci.c
+++ b/arch/parisc/kernel/pci.c
@@ -220,6 +220,33 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res,
220} 220}
221 221
222 222
223int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
224 enum pci_mmap_state mmap_state, int write_combine)
225{
226 unsigned long prot;
227
228 /*
229 * I/O space can be accessed via normal processor loads and stores on
230 * this platform but for now we elect not to do this and portable
231 * drivers should not do this anyway.
232 */
233 if (mmap_state == pci_mmap_io)
234 return -EINVAL;
235
236 if (write_combine)
237 return -EINVAL;
238
239 /*
240 * Ignore write-combine; for now only return uncached mappings.
241 */
242 prot = pgprot_val(vma->vm_page_prot);
243 prot |= _PAGE_NO_CACHE;
244 vma->vm_page_prot = __pgprot(prot);
245
246 return remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
247 vma->vm_end - vma->vm_start, vma->vm_page_prot);
248}
249
223/* 250/*
224 * A driver is enabling the device. We make sure that all the appropriate 251 * A driver is enabling the device. We make sure that all the appropriate
225 * bits are set to allow the device to operate as the driver is expecting. 252 * bits are set to allow the device to operate as the driver is expecting.
diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
index 1c965642068b..505b56c6b9b9 100644
--- a/arch/parisc/mm/init.c
+++ b/arch/parisc/mm/init.c
@@ -47,7 +47,7 @@ pte_t pg0[PT_INITIAL * PTRS_PER_PTE] __attribute__ ((__section__ (".data..vm0.pt
47 47
48#ifdef CONFIG_DISCONTIGMEM 48#ifdef CONFIG_DISCONTIGMEM
49struct node_map_data node_data[MAX_NUMNODES] __read_mostly; 49struct node_map_data node_data[MAX_NUMNODES] __read_mostly;
50unsigned char pfnnid_map[PFNNID_MAP_MAX] __read_mostly; 50signed char pfnnid_map[PFNNID_MAP_MAX] __read_mostly;
51#endif 51#endif
52 52
53static struct resource data_resource = { 53static struct resource data_resource = {
diff --git a/arch/powerpc/include/asm/exception-64s.h b/arch/powerpc/include/asm/exception-64s.h
index 8e5fae8beaf6..46793b58a761 100644
--- a/arch/powerpc/include/asm/exception-64s.h
+++ b/arch/powerpc/include/asm/exception-64s.h
@@ -513,7 +513,7 @@ label##_common: \
513 */ 513 */
514#define STD_EXCEPTION_COMMON_ASYNC(trap, label, hdlr) \ 514#define STD_EXCEPTION_COMMON_ASYNC(trap, label, hdlr) \
515 EXCEPTION_COMMON(trap, label, hdlr, ret_from_except_lite, \ 515 EXCEPTION_COMMON(trap, label, hdlr, ret_from_except_lite, \
516 FINISH_NAP;RUNLATCH_ON;DISABLE_INTS) 516 FINISH_NAP;DISABLE_INTS;RUNLATCH_ON)
517 517
518/* 518/*
519 * When the idle code in power4_idle puts the CPU into NAP mode, 519 * When the idle code in power4_idle puts the CPU into NAP mode,
diff --git a/arch/powerpc/include/asm/kvm_asm.h b/arch/powerpc/include/asm/kvm_asm.h
index b9dd382cb349..851bac7afa4b 100644
--- a/arch/powerpc/include/asm/kvm_asm.h
+++ b/arch/powerpc/include/asm/kvm_asm.h
@@ -54,8 +54,16 @@
54#define BOOKE_INTERRUPT_DEBUG 15 54#define BOOKE_INTERRUPT_DEBUG 15
55 55
56/* E500 */ 56/* E500 */
57#define BOOKE_INTERRUPT_SPE_UNAVAIL 32 57#define BOOKE_INTERRUPT_SPE_ALTIVEC_UNAVAIL 32
58#define BOOKE_INTERRUPT_SPE_FP_DATA 33 58#define BOOKE_INTERRUPT_SPE_FP_DATA_ALTIVEC_ASSIST 33
59/*
60 * TODO: Unify 32-bit and 64-bit kernel exception handlers to use same defines
61 */
62#define BOOKE_INTERRUPT_SPE_UNAVAIL BOOKE_INTERRUPT_SPE_ALTIVEC_UNAVAIL
63#define BOOKE_INTERRUPT_SPE_FP_DATA BOOKE_INTERRUPT_SPE_FP_DATA_ALTIVEC_ASSIST
64#define BOOKE_INTERRUPT_ALTIVEC_UNAVAIL BOOKE_INTERRUPT_SPE_ALTIVEC_UNAVAIL
65#define BOOKE_INTERRUPT_ALTIVEC_ASSIST \
66 BOOKE_INTERRUPT_SPE_FP_DATA_ALTIVEC_ASSIST
59#define BOOKE_INTERRUPT_SPE_FP_ROUND 34 67#define BOOKE_INTERRUPT_SPE_FP_ROUND 34
60#define BOOKE_INTERRUPT_PERFORMANCE_MONITOR 35 68#define BOOKE_INTERRUPT_PERFORMANCE_MONITOR 35
61#define BOOKE_INTERRUPT_DOORBELL 36 69#define BOOKE_INTERRUPT_DOORBELL 36
@@ -67,10 +75,6 @@
67#define BOOKE_INTERRUPT_HV_SYSCALL 40 75#define BOOKE_INTERRUPT_HV_SYSCALL 40
68#define BOOKE_INTERRUPT_HV_PRIV 41 76#define BOOKE_INTERRUPT_HV_PRIV 41
69 77
70/* altivec */
71#define BOOKE_INTERRUPT_ALTIVEC_UNAVAIL 42
72#define BOOKE_INTERRUPT_ALTIVEC_ASSIST 43
73
74/* book3s */ 78/* book3s */
75 79
76#define BOOK3S_INTERRUPT_SYSTEM_RESET 0x100 80#define BOOK3S_INTERRUPT_SYSTEM_RESET 0x100
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index e783453f910d..40e4a17c8ba0 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -683,7 +683,7 @@ machine_check_common:
683 STD_EXCEPTION_COMMON(0xb00, trap_0b, .unknown_exception) 683 STD_EXCEPTION_COMMON(0xb00, trap_0b, .unknown_exception)
684 STD_EXCEPTION_COMMON(0xd00, single_step, .single_step_exception) 684 STD_EXCEPTION_COMMON(0xd00, single_step, .single_step_exception)
685 STD_EXCEPTION_COMMON(0xe00, trap_0e, .unknown_exception) 685 STD_EXCEPTION_COMMON(0xe00, trap_0e, .unknown_exception)
686 STD_EXCEPTION_COMMON(0xe40, emulation_assist, .program_check_exception) 686 STD_EXCEPTION_COMMON(0xe40, emulation_assist, .emulation_assist_interrupt)
687 STD_EXCEPTION_COMMON(0xe60, hmi_exception, .unknown_exception) 687 STD_EXCEPTION_COMMON(0xe60, hmi_exception, .unknown_exception)
688#ifdef CONFIG_PPC_DOORBELL 688#ifdef CONFIG_PPC_DOORBELL
689 STD_EXCEPTION_COMMON_ASYNC(0xe80, h_doorbell, .doorbell_exception) 689 STD_EXCEPTION_COMMON_ASYNC(0xe80, h_doorbell, .doorbell_exception)
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 5cbcf4d5a808..ea185e0b3cae 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -162,7 +162,7 @@ notrace unsigned int __check_irq_replay(void)
162 * in case we also had a rollover while hard disabled 162 * in case we also had a rollover while hard disabled
163 */ 163 */
164 local_paca->irq_happened &= ~PACA_IRQ_DEC; 164 local_paca->irq_happened &= ~PACA_IRQ_DEC;
165 if (decrementer_check_overflow()) 165 if ((happened & PACA_IRQ_DEC) || decrementer_check_overflow())
166 return 0x900; 166 return 0x900;
167 167
168 /* Finally check if an external interrupt happened */ 168 /* Finally check if an external interrupt happened */
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index b0f3e3f77e72..076d1242507a 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1369,7 +1369,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
1369 1369
1370#ifdef CONFIG_PPC64 1370#ifdef CONFIG_PPC64
1371/* Called with hard IRQs off */ 1371/* Called with hard IRQs off */
1372void __ppc64_runlatch_on(void) 1372void notrace __ppc64_runlatch_on(void)
1373{ 1373{
1374 struct thread_info *ti = current_thread_info(); 1374 struct thread_info *ti = current_thread_info();
1375 unsigned long ctrl; 1375 unsigned long ctrl;
@@ -1382,7 +1382,7 @@ void __ppc64_runlatch_on(void)
1382} 1382}
1383 1383
1384/* Called with hard IRQs off */ 1384/* Called with hard IRQs off */
1385void __ppc64_runlatch_off(void) 1385void notrace __ppc64_runlatch_off(void)
1386{ 1386{
1387 struct thread_info *ti = current_thread_info(); 1387 struct thread_info *ti = current_thread_info();
1388 unsigned long ctrl; 1388 unsigned long ctrl;
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index f18c79c324ef..c0e5caf8ccc7 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -1165,6 +1165,16 @@ bail:
1165 exception_exit(prev_state); 1165 exception_exit(prev_state);
1166} 1166}
1167 1167
1168/*
1169 * This occurs when running in hypervisor mode on POWER6 or later
1170 * and an illegal instruction is encountered.
1171 */
1172void __kprobes emulation_assist_interrupt(struct pt_regs *regs)
1173{
1174 regs->msr |= REASON_ILLEGAL;
1175 program_check_exception(regs);
1176}
1177
1168void alignment_exception(struct pt_regs *regs) 1178void alignment_exception(struct pt_regs *regs)
1169{ 1179{
1170 enum ctx_state prev_state = exception_enter(); 1180 enum ctx_state prev_state = exception_enter();
diff --git a/arch/powerpc/kvm/44x_tlb.c b/arch/powerpc/kvm/44x_tlb.c
index 5dd3ab469976..ed0385448148 100644
--- a/arch/powerpc/kvm/44x_tlb.c
+++ b/arch/powerpc/kvm/44x_tlb.c
@@ -441,6 +441,7 @@ int kvmppc_44x_emul_tlbwe(struct kvm_vcpu *vcpu, u8 ra, u8 rs, u8 ws)
441 struct kvmppc_vcpu_44x *vcpu_44x = to_44x(vcpu); 441 struct kvmppc_vcpu_44x *vcpu_44x = to_44x(vcpu);
442 struct kvmppc_44x_tlbe *tlbe; 442 struct kvmppc_44x_tlbe *tlbe;
443 unsigned int gtlb_index; 443 unsigned int gtlb_index;
444 int idx;
444 445
445 gtlb_index = kvmppc_get_gpr(vcpu, ra); 446 gtlb_index = kvmppc_get_gpr(vcpu, ra);
446 if (gtlb_index >= KVM44x_GUEST_TLB_SIZE) { 447 if (gtlb_index >= KVM44x_GUEST_TLB_SIZE) {
@@ -473,6 +474,8 @@ int kvmppc_44x_emul_tlbwe(struct kvm_vcpu *vcpu, u8 ra, u8 rs, u8 ws)
473 return EMULATE_FAIL; 474 return EMULATE_FAIL;
474 } 475 }
475 476
477 idx = srcu_read_lock(&vcpu->kvm->srcu);
478
476 if (tlbe_is_host_safe(vcpu, tlbe)) { 479 if (tlbe_is_host_safe(vcpu, tlbe)) {
477 gva_t eaddr; 480 gva_t eaddr;
478 gpa_t gpaddr; 481 gpa_t gpaddr;
@@ -489,6 +492,8 @@ int kvmppc_44x_emul_tlbwe(struct kvm_vcpu *vcpu, u8 ra, u8 rs, u8 ws)
489 kvmppc_mmu_map(vcpu, eaddr, gpaddr, gtlb_index); 492 kvmppc_mmu_map(vcpu, eaddr, gpaddr, gtlb_index);
490 } 493 }
491 494
495 srcu_read_unlock(&vcpu->kvm->srcu, idx);
496
492 trace_kvm_gtlb_write(gtlb_index, tlbe->tid, tlbe->word0, tlbe->word1, 497 trace_kvm_gtlb_write(gtlb_index, tlbe->tid, tlbe->word0, tlbe->word1,
493 tlbe->word2); 498 tlbe->word2);
494 499
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index 1020119226db..1a1b51189773 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -673,7 +673,6 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
673 ret = s; 673 ret = s;
674 goto out; 674 goto out;
675 } 675 }
676 kvmppc_lazy_ee_enable();
677 676
678 kvm_guest_enter(); 677 kvm_guest_enter();
679 678
@@ -699,6 +698,8 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
699 kvmppc_load_guest_fp(vcpu); 698 kvmppc_load_guest_fp(vcpu);
700#endif 699#endif
701 700
701 kvmppc_lazy_ee_enable();
702
702 ret = __kvmppc_vcpu_run(kvm_run, vcpu); 703 ret = __kvmppc_vcpu_run(kvm_run, vcpu);
703 704
704 /* No need for kvm_guest_exit. It's done in handle_exit. 705 /* No need for kvm_guest_exit. It's done in handle_exit.
@@ -832,6 +833,18 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
832{ 833{
833 int r = RESUME_HOST; 834 int r = RESUME_HOST;
834 int s; 835 int s;
836 int idx;
837
838#ifdef CONFIG_PPC64
839 WARN_ON(local_paca->irq_happened != 0);
840#endif
841
842 /*
843 * We enter with interrupts disabled in hardware, but
844 * we need to call hard_irq_disable anyway to ensure that
845 * the software state is kept in sync.
846 */
847 hard_irq_disable();
835 848
836 /* update before a new last_exit_type is rewritten */ 849 /* update before a new last_exit_type is rewritten */
837 kvmppc_update_timing_stats(vcpu); 850 kvmppc_update_timing_stats(vcpu);
@@ -1053,6 +1066,8 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
1053 break; 1066 break;
1054 } 1067 }
1055 1068
1069 idx = srcu_read_lock(&vcpu->kvm->srcu);
1070
1056 gpaddr = kvmppc_mmu_xlate(vcpu, gtlb_index, eaddr); 1071 gpaddr = kvmppc_mmu_xlate(vcpu, gtlb_index, eaddr);
1057 gfn = gpaddr >> PAGE_SHIFT; 1072 gfn = gpaddr >> PAGE_SHIFT;
1058 1073
@@ -1075,6 +1090,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
1075 kvmppc_account_exit(vcpu, MMIO_EXITS); 1090 kvmppc_account_exit(vcpu, MMIO_EXITS);
1076 } 1091 }
1077 1092
1093 srcu_read_unlock(&vcpu->kvm->srcu, idx);
1078 break; 1094 break;
1079 } 1095 }
1080 1096
@@ -1098,6 +1114,8 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
1098 1114
1099 kvmppc_account_exit(vcpu, ITLB_VIRT_MISS_EXITS); 1115 kvmppc_account_exit(vcpu, ITLB_VIRT_MISS_EXITS);
1100 1116
1117 idx = srcu_read_lock(&vcpu->kvm->srcu);
1118
1101 gpaddr = kvmppc_mmu_xlate(vcpu, gtlb_index, eaddr); 1119 gpaddr = kvmppc_mmu_xlate(vcpu, gtlb_index, eaddr);
1102 gfn = gpaddr >> PAGE_SHIFT; 1120 gfn = gpaddr >> PAGE_SHIFT;
1103 1121
@@ -1114,6 +1132,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
1114 kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_MACHINE_CHECK); 1132 kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_MACHINE_CHECK);
1115 } 1133 }
1116 1134
1135 srcu_read_unlock(&vcpu->kvm->srcu, idx);
1117 break; 1136 break;
1118 } 1137 }
1119 1138
diff --git a/arch/powerpc/kvm/e500_mmu.c b/arch/powerpc/kvm/e500_mmu.c
index c41a5a96b558..6d6f153b6c1d 100644
--- a/arch/powerpc/kvm/e500_mmu.c
+++ b/arch/powerpc/kvm/e500_mmu.c
@@ -396,6 +396,7 @@ int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu)
396 struct kvm_book3e_206_tlb_entry *gtlbe; 396 struct kvm_book3e_206_tlb_entry *gtlbe;
397 int tlbsel, esel; 397 int tlbsel, esel;
398 int recal = 0; 398 int recal = 0;
399 int idx;
399 400
400 tlbsel = get_tlb_tlbsel(vcpu); 401 tlbsel = get_tlb_tlbsel(vcpu);
401 esel = get_tlb_esel(vcpu, tlbsel); 402 esel = get_tlb_esel(vcpu, tlbsel);
@@ -430,6 +431,8 @@ int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu)
430 kvmppc_set_tlb1map_range(vcpu, gtlbe); 431 kvmppc_set_tlb1map_range(vcpu, gtlbe);
431 } 432 }
432 433
434 idx = srcu_read_lock(&vcpu->kvm->srcu);
435
433 /* Invalidate shadow mappings for the about-to-be-clobbered TLBE. */ 436 /* Invalidate shadow mappings for the about-to-be-clobbered TLBE. */
434 if (tlbe_is_host_safe(vcpu, gtlbe)) { 437 if (tlbe_is_host_safe(vcpu, gtlbe)) {
435 u64 eaddr = get_tlb_eaddr(gtlbe); 438 u64 eaddr = get_tlb_eaddr(gtlbe);
@@ -444,6 +447,8 @@ int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu)
444 kvmppc_mmu_map(vcpu, eaddr, raddr, index_of(tlbsel, esel)); 447 kvmppc_mmu_map(vcpu, eaddr, raddr, index_of(tlbsel, esel));
445 } 448 }
446 449
450 srcu_read_unlock(&vcpu->kvm->srcu, idx);
451
447 kvmppc_set_exit_type(vcpu, EMULATED_TLBWE_EXITS); 452 kvmppc_set_exit_type(vcpu, EMULATED_TLBWE_EXITS);
448 return EMULATE_DONE; 453 return EMULATE_DONE;
449} 454}
diff --git a/arch/powerpc/kvm/e500mc.c b/arch/powerpc/kvm/e500mc.c
index 753cc99eff2b..19c8379575f7 100644
--- a/arch/powerpc/kvm/e500mc.c
+++ b/arch/powerpc/kvm/e500mc.c
@@ -177,8 +177,6 @@ int kvmppc_core_check_processor_compat(void)
177 r = 0; 177 r = 0;
178 else if (strcmp(cur_cpu_spec->cpu_name, "e5500") == 0) 178 else if (strcmp(cur_cpu_spec->cpu_name, "e5500") == 0)
179 r = 0; 179 r = 0;
180 else if (strcmp(cur_cpu_spec->cpu_name, "e6500") == 0)
181 r = 0;
182 else 180 else
183 r = -ENOTSUPP; 181 r = -ENOTSUPP;
184 182
diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index 237c8e5f2640..77fdd2cef33b 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -592,8 +592,14 @@ static void hugetlb_free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
592 do { 592 do {
593 pmd = pmd_offset(pud, addr); 593 pmd = pmd_offset(pud, addr);
594 next = pmd_addr_end(addr, end); 594 next = pmd_addr_end(addr, end);
595 if (pmd_none_or_clear_bad(pmd)) 595 if (!is_hugepd(pmd)) {
596 /*
597 * if it is not hugepd pointer, we should already find
598 * it cleared.
599 */
600 WARN_ON(!pmd_none_or_clear_bad(pmd));
596 continue; 601 continue;
602 }
597#ifdef CONFIG_PPC_FSL_BOOK3E 603#ifdef CONFIG_PPC_FSL_BOOK3E
598 /* 604 /*
599 * Increment next by the size of the huge mapping since 605 * Increment next by the size of the huge mapping since
diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
index ac01463038f1..e8b6e5b8932c 100644
--- a/arch/s390/include/asm/pgtable.h
+++ b/arch/s390/include/asm/pgtable.h
@@ -623,7 +623,7 @@ static inline pgste_t pgste_get_lock(pte_t *ptep)
623 " csg %0,%1,%2\n" 623 " csg %0,%1,%2\n"
624 " jl 0b\n" 624 " jl 0b\n"
625 : "=&d" (old), "=&d" (new), "=Q" (ptep[PTRS_PER_PTE]) 625 : "=&d" (old), "=&d" (new), "=Q" (ptep[PTRS_PER_PTE])
626 : "Q" (ptep[PTRS_PER_PTE]) : "cc"); 626 : "Q" (ptep[PTRS_PER_PTE]) : "cc", "memory");
627#endif 627#endif
628 return __pgste(new); 628 return __pgste(new);
629} 629}
@@ -635,11 +635,19 @@ static inline void pgste_set_unlock(pte_t *ptep, pgste_t pgste)
635 " nihh %1,0xff7f\n" /* clear RCP_PCL_BIT */ 635 " nihh %1,0xff7f\n" /* clear RCP_PCL_BIT */
636 " stg %1,%0\n" 636 " stg %1,%0\n"
637 : "=Q" (ptep[PTRS_PER_PTE]) 637 : "=Q" (ptep[PTRS_PER_PTE])
638 : "d" (pgste_val(pgste)), "Q" (ptep[PTRS_PER_PTE]) : "cc"); 638 : "d" (pgste_val(pgste)), "Q" (ptep[PTRS_PER_PTE])
639 : "cc", "memory");
639 preempt_enable(); 640 preempt_enable();
640#endif 641#endif
641} 642}
642 643
644static inline void pgste_set(pte_t *ptep, pgste_t pgste)
645{
646#ifdef CONFIG_PGSTE
647 *(pgste_t *)(ptep + PTRS_PER_PTE) = pgste;
648#endif
649}
650
643static inline pgste_t pgste_update_all(pte_t *ptep, pgste_t pgste) 651static inline pgste_t pgste_update_all(pte_t *ptep, pgste_t pgste)
644{ 652{
645#ifdef CONFIG_PGSTE 653#ifdef CONFIG_PGSTE
@@ -704,17 +712,19 @@ static inline void pgste_set_key(pte_t *ptep, pgste_t pgste, pte_t entry)
704{ 712{
705#ifdef CONFIG_PGSTE 713#ifdef CONFIG_PGSTE
706 unsigned long address; 714 unsigned long address;
707 unsigned long okey, nkey; 715 unsigned long nkey;
708 716
709 if (pte_val(entry) & _PAGE_INVALID) 717 if (pte_val(entry) & _PAGE_INVALID)
710 return; 718 return;
719 VM_BUG_ON(!(pte_val(*ptep) & _PAGE_INVALID));
711 address = pte_val(entry) & PAGE_MASK; 720 address = pte_val(entry) & PAGE_MASK;
712 okey = nkey = page_get_storage_key(address); 721 /*
713 nkey &= ~(_PAGE_ACC_BITS | _PAGE_FP_BIT); 722 * Set page access key and fetch protection bit from pgste.
714 /* Set page access key and fetch protection bit from pgste */ 723 * The guest C/R information is still in the PGSTE, set real
715 nkey |= (pgste_val(pgste) & (RCP_ACC_BITS | RCP_FP_BIT)) >> 56; 724 * key C/R to 0.
716 if (okey != nkey) 725 */
717 page_set_storage_key(address, nkey, 0); 726 nkey = (pgste_val(pgste) & (RCP_ACC_BITS | RCP_FP_BIT)) >> 56;
727 page_set_storage_key(address, nkey, 0);
718#endif 728#endif
719} 729}
720 730
@@ -1099,8 +1109,10 @@ static inline pte_t ptep_modify_prot_start(struct mm_struct *mm,
1099 if (!mm_exclusive(mm)) 1109 if (!mm_exclusive(mm))
1100 __ptep_ipte(address, ptep); 1110 __ptep_ipte(address, ptep);
1101 1111
1102 if (mm_has_pgste(mm)) 1112 if (mm_has_pgste(mm)) {
1103 pgste = pgste_update_all(&pte, pgste); 1113 pgste = pgste_update_all(&pte, pgste);
1114 pgste_set(ptep, pgste);
1115 }
1104 return pte; 1116 return pte;
1105} 1117}
1106 1118
diff --git a/arch/s390/kernel/dumpstack.c b/arch/s390/kernel/dumpstack.c
index 298297477257..87acc38f73c6 100644
--- a/arch/s390/kernel/dumpstack.c
+++ b/arch/s390/kernel/dumpstack.c
@@ -74,6 +74,8 @@ __show_trace(unsigned long sp, unsigned long low, unsigned long high)
74 74
75static void show_trace(struct task_struct *task, unsigned long *stack) 75static void show_trace(struct task_struct *task, unsigned long *stack)
76{ 76{
77 const unsigned long frame_size =
78 STACK_FRAME_OVERHEAD + sizeof(struct pt_regs);
77 register unsigned long __r15 asm ("15"); 79 register unsigned long __r15 asm ("15");
78 unsigned long sp; 80 unsigned long sp;
79 81
@@ -82,11 +84,13 @@ static void show_trace(struct task_struct *task, unsigned long *stack)
82 sp = task ? task->thread.ksp : __r15; 84 sp = task ? task->thread.ksp : __r15;
83 printk("Call Trace:\n"); 85 printk("Call Trace:\n");
84#ifdef CONFIG_CHECK_STACK 86#ifdef CONFIG_CHECK_STACK
85 sp = __show_trace(sp, S390_lowcore.panic_stack - 4096, 87 sp = __show_trace(sp,
86 S390_lowcore.panic_stack); 88 S390_lowcore.panic_stack + frame_size - 4096,
89 S390_lowcore.panic_stack + frame_size);
87#endif 90#endif
88 sp = __show_trace(sp, S390_lowcore.async_stack - ASYNC_SIZE, 91 sp = __show_trace(sp,
89 S390_lowcore.async_stack); 92 S390_lowcore.async_stack + frame_size - ASYNC_SIZE,
93 S390_lowcore.async_stack + frame_size);
90 if (task) 94 if (task)
91 __show_trace(sp, (unsigned long) task_stack_page(task), 95 __show_trace(sp, (unsigned long) task_stack_page(task),
92 (unsigned long) task_stack_page(task) + THREAD_SIZE); 96 (unsigned long) task_stack_page(task) + THREAD_SIZE);
diff --git a/arch/s390/kernel/irq.c b/arch/s390/kernel/irq.c
index f7fb58903f6a..408e866ae548 100644
--- a/arch/s390/kernel/irq.c
+++ b/arch/s390/kernel/irq.c
@@ -311,3 +311,67 @@ void measurement_alert_subclass_unregister(void)
311 spin_unlock(&ma_subclass_lock); 311 spin_unlock(&ma_subclass_lock);
312} 312}
313EXPORT_SYMBOL(measurement_alert_subclass_unregister); 313EXPORT_SYMBOL(measurement_alert_subclass_unregister);
314
315void synchronize_irq(unsigned int irq)
316{
317 /*
318 * Not needed, the handler is protected by a lock and IRQs that occur
319 * after the handler is deleted are just NOPs.
320 */
321}
322EXPORT_SYMBOL_GPL(synchronize_irq);
323
324#ifndef CONFIG_PCI
325
326/* Only PCI devices have dynamically-defined IRQ handlers */
327
328int request_irq(unsigned int irq, irq_handler_t handler,
329 unsigned long irqflags, const char *devname, void *dev_id)
330{
331 return -EINVAL;
332}
333EXPORT_SYMBOL_GPL(request_irq);
334
335void free_irq(unsigned int irq, void *dev_id)
336{
337 WARN_ON(1);
338}
339EXPORT_SYMBOL_GPL(free_irq);
340
341void enable_irq(unsigned int irq)
342{
343 WARN_ON(1);
344}
345EXPORT_SYMBOL_GPL(enable_irq);
346
347void disable_irq(unsigned int irq)
348{
349 WARN_ON(1);
350}
351EXPORT_SYMBOL_GPL(disable_irq);
352
353#endif /* !CONFIG_PCI */
354
355void disable_irq_nosync(unsigned int irq)
356{
357 disable_irq(irq);
358}
359EXPORT_SYMBOL_GPL(disable_irq_nosync);
360
361unsigned long probe_irq_on(void)
362{
363 return 0;
364}
365EXPORT_SYMBOL_GPL(probe_irq_on);
366
367int probe_irq_off(unsigned long val)
368{
369 return 0;
370}
371EXPORT_SYMBOL_GPL(probe_irq_off);
372
373unsigned int probe_irq_mask(unsigned long val)
374{
375 return val;
376}
377EXPORT_SYMBOL_GPL(probe_irq_mask);
diff --git a/arch/s390/kernel/sclp.S b/arch/s390/kernel/sclp.S
index b6506ee32a36..29bd7bec4176 100644
--- a/arch/s390/kernel/sclp.S
+++ b/arch/s390/kernel/sclp.S
@@ -225,7 +225,7 @@ _sclp_print:
225 ahi %r2,1 225 ahi %r2,1
226 ltr %r0,%r0 # end of string? 226 ltr %r0,%r0 # end of string?
227 jz .LfinalizemtoS4 227 jz .LfinalizemtoS4
228 chi %r0,0x15 # end of line (NL)? 228 chi %r0,0x0a # end of line (NL)?
229 jz .LfinalizemtoS4 229 jz .LfinalizemtoS4
230 stc %r0,0(%r6,%r7) # copy to mto 230 stc %r0,0(%r6,%r7) # copy to mto
231 la %r11,0(%r6,%r7) 231 la %r11,0(%r6,%r7)
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index e6f15b5d8b7d..f1e5be85d592 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -302,15 +302,6 @@ static int zpci_cfg_store(struct zpci_dev *zdev, int offset, u32 val, u8 len)
302 return rc; 302 return rc;
303} 303}
304 304
305void synchronize_irq(unsigned int irq)
306{
307 /*
308 * Not needed, the handler is protected by a lock and IRQs that occur
309 * after the handler is deleted are just NOPs.
310 */
311}
312EXPORT_SYMBOL_GPL(synchronize_irq);
313
314void enable_irq(unsigned int irq) 305void enable_irq(unsigned int irq)
315{ 306{
316 struct msi_desc *msi = irq_get_msi_desc(irq); 307 struct msi_desc *msi = irq_get_msi_desc(irq);
@@ -327,30 +318,6 @@ void disable_irq(unsigned int irq)
327} 318}
328EXPORT_SYMBOL_GPL(disable_irq); 319EXPORT_SYMBOL_GPL(disable_irq);
329 320
330void disable_irq_nosync(unsigned int irq)
331{
332 disable_irq(irq);
333}
334EXPORT_SYMBOL_GPL(disable_irq_nosync);
335
336unsigned long probe_irq_on(void)
337{
338 return 0;
339}
340EXPORT_SYMBOL_GPL(probe_irq_on);
341
342int probe_irq_off(unsigned long val)
343{
344 return 0;
345}
346EXPORT_SYMBOL_GPL(probe_irq_off);
347
348unsigned int probe_irq_mask(unsigned long val)
349{
350 return val;
351}
352EXPORT_SYMBOL_GPL(probe_irq_mask);
353
354void pcibios_fixup_bus(struct pci_bus *bus) 321void pcibios_fixup_bus(struct pci_bus *bus)
355{ 322{
356} 323}
diff --git a/arch/sparc/include/asm/Kbuild b/arch/sparc/include/asm/Kbuild
index ff18e3cfb6b1..7e4a97fbded4 100644
--- a/arch/sparc/include/asm/Kbuild
+++ b/arch/sparc/include/asm/Kbuild
@@ -6,6 +6,7 @@ generic-y += cputime.h
6generic-y += div64.h 6generic-y += div64.h
7generic-y += emergency-restart.h 7generic-y += emergency-restart.h
8generic-y += exec.h 8generic-y += exec.h
9generic-y += linkage.h
9generic-y += local64.h 10generic-y += local64.h
10generic-y += mutex.h 11generic-y += mutex.h
11generic-y += irq_regs.h 12generic-y += irq_regs.h
diff --git a/arch/sparc/include/asm/leon.h b/arch/sparc/include/asm/leon.h
index 15a716934e4d..b836e9297f2a 100644
--- a/arch/sparc/include/asm/leon.h
+++ b/arch/sparc/include/asm/leon.h
@@ -135,7 +135,7 @@ static inline int sparc_leon3_cpuid(void)
135 135
136#ifdef CONFIG_SMP 136#ifdef CONFIG_SMP
137# define LEON3_IRQ_IPI_DEFAULT 13 137# define LEON3_IRQ_IPI_DEFAULT 13
138# define LEON3_IRQ_TICKER (leon3_ticker_irq) 138# define LEON3_IRQ_TICKER (leon3_gptimer_irq)
139# define LEON3_IRQ_CROSS_CALL 15 139# define LEON3_IRQ_CROSS_CALL 15
140#endif 140#endif
141 141
diff --git a/arch/sparc/include/asm/leon_amba.h b/arch/sparc/include/asm/leon_amba.h
index f3034eddf468..24ec48c3ff90 100644
--- a/arch/sparc/include/asm/leon_amba.h
+++ b/arch/sparc/include/asm/leon_amba.h
@@ -47,6 +47,7 @@ struct amba_prom_registers {
47#define LEON3_GPTIMER_LD 4 47#define LEON3_GPTIMER_LD 4
48#define LEON3_GPTIMER_IRQEN 8 48#define LEON3_GPTIMER_IRQEN 8
49#define LEON3_GPTIMER_SEPIRQ 8 49#define LEON3_GPTIMER_SEPIRQ 8
50#define LEON3_GPTIMER_TIMERS 0x7
50 51
51#define LEON23_REG_TIMER_CONTROL_EN 0x00000001 /* 1 = enable counting */ 52#define LEON23_REG_TIMER_CONTROL_EN 0x00000001 /* 1 = enable counting */
52/* 0 = hold scalar and counter */ 53/* 0 = hold scalar and counter */
diff --git a/arch/sparc/include/asm/linkage.h b/arch/sparc/include/asm/linkage.h
deleted file mode 100644
index 291c2d01c44f..000000000000
--- a/arch/sparc/include/asm/linkage.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __ASM_LINKAGE_H
2#define __ASM_LINKAGE_H
3
4/* Nothing to see here... */
5
6#endif
diff --git a/arch/sparc/kernel/ds.c b/arch/sparc/kernel/ds.c
index 75bb608c423e..5ef48dab5636 100644
--- a/arch/sparc/kernel/ds.c
+++ b/arch/sparc/kernel/ds.c
@@ -843,7 +843,8 @@ void ldom_reboot(const char *boot_command)
843 unsigned long len; 843 unsigned long len;
844 844
845 strcpy(full_boot_str, "boot "); 845 strcpy(full_boot_str, "boot ");
846 strcpy(full_boot_str + strlen("boot "), boot_command); 846 strlcpy(full_boot_str + strlen("boot "), boot_command,
847 sizeof(full_boot_str + strlen("boot ")));
847 len = strlen(full_boot_str); 848 len = strlen(full_boot_str);
848 849
849 if (reboot_data_supported) { 850 if (reboot_data_supported) {
diff --git a/arch/sparc/kernel/leon_kernel.c b/arch/sparc/kernel/leon_kernel.c
index 7c0231dabe44..b7c68976cbc7 100644
--- a/arch/sparc/kernel/leon_kernel.c
+++ b/arch/sparc/kernel/leon_kernel.c
@@ -38,7 +38,6 @@ static DEFINE_SPINLOCK(leon_irq_lock);
38 38
39unsigned long leon3_gptimer_irq; /* interrupt controller irq number */ 39unsigned long leon3_gptimer_irq; /* interrupt controller irq number */
40unsigned long leon3_gptimer_idx; /* Timer Index (0..6) within Timer Core */ 40unsigned long leon3_gptimer_idx; /* Timer Index (0..6) within Timer Core */
41int leon3_ticker_irq; /* Timer ticker IRQ */
42unsigned int sparc_leon_eirq; 41unsigned int sparc_leon_eirq;
43#define LEON_IMASK(cpu) (&leon3_irqctrl_regs->mask[cpu]) 42#define LEON_IMASK(cpu) (&leon3_irqctrl_regs->mask[cpu])
44#define LEON_IACK (&leon3_irqctrl_regs->iclear) 43#define LEON_IACK (&leon3_irqctrl_regs->iclear)
@@ -278,6 +277,9 @@ irqreturn_t leon_percpu_timer_ce_interrupt(int irq, void *unused)
278 277
279 leon_clear_profile_irq(cpu); 278 leon_clear_profile_irq(cpu);
280 279
280 if (cpu == boot_cpu_id)
281 timer_interrupt(irq, NULL);
282
281 ce = &per_cpu(sparc32_clockevent, cpu); 283 ce = &per_cpu(sparc32_clockevent, cpu);
282 284
283 irq_enter(); 285 irq_enter();
@@ -299,6 +301,7 @@ void __init leon_init_timers(void)
299 int icsel; 301 int icsel;
300 int ampopts; 302 int ampopts;
301 int err; 303 int err;
304 u32 config;
302 305
303 sparc_config.get_cycles_offset = leon_cycles_offset; 306 sparc_config.get_cycles_offset = leon_cycles_offset;
304 sparc_config.cs_period = 1000000 / HZ; 307 sparc_config.cs_period = 1000000 / HZ;
@@ -377,23 +380,6 @@ void __init leon_init_timers(void)
377 LEON3_BYPASS_STORE_PA( 380 LEON3_BYPASS_STORE_PA(
378 &leon3_gptimer_regs->e[leon3_gptimer_idx].ctrl, 0); 381 &leon3_gptimer_regs->e[leon3_gptimer_idx].ctrl, 0);
379 382
380#ifdef CONFIG_SMP
381 leon3_ticker_irq = leon3_gptimer_irq + 1 + leon3_gptimer_idx;
382
383 if (!(LEON3_BYPASS_LOAD_PA(&leon3_gptimer_regs->config) &
384 (1<<LEON3_GPTIMER_SEPIRQ))) {
385 printk(KERN_ERR "timer not configured with separate irqs\n");
386 BUG();
387 }
388
389 LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx+1].val,
390 0);
391 LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx+1].rld,
392 (((1000000/HZ) - 1)));
393 LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx+1].ctrl,
394 0);
395#endif
396
397 /* 383 /*
398 * The IRQ controller may (if implemented) consist of multiple 384 * The IRQ controller may (if implemented) consist of multiple
399 * IRQ controllers, each mapped on a 4Kb boundary. 385 * IRQ controllers, each mapped on a 4Kb boundary.
@@ -416,13 +402,6 @@ void __init leon_init_timers(void)
416 if (eirq != 0) 402 if (eirq != 0)
417 leon_eirq_setup(eirq); 403 leon_eirq_setup(eirq);
418 404
419 irq = _leon_build_device_irq(NULL, leon3_gptimer_irq+leon3_gptimer_idx);
420 err = request_irq(irq, timer_interrupt, IRQF_TIMER, "timer", NULL);
421 if (err) {
422 printk(KERN_ERR "unable to attach timer IRQ%d\n", irq);
423 prom_halt();
424 }
425
426#ifdef CONFIG_SMP 405#ifdef CONFIG_SMP
427 { 406 {
428 unsigned long flags; 407 unsigned long flags;
@@ -439,30 +418,31 @@ void __init leon_init_timers(void)
439 } 418 }
440#endif 419#endif
441 420
442 LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx].ctrl, 421 config = LEON3_BYPASS_LOAD_PA(&leon3_gptimer_regs->config);
443 LEON3_GPTIMER_EN | 422 if (config & (1 << LEON3_GPTIMER_SEPIRQ))
444 LEON3_GPTIMER_RL | 423 leon3_gptimer_irq += leon3_gptimer_idx;
445 LEON3_GPTIMER_LD | 424 else if ((config & LEON3_GPTIMER_TIMERS) > 1)
446 LEON3_GPTIMER_IRQEN); 425 pr_warn("GPTIMER uses shared irqs, using other timers of the same core will fail.\n");
447 426
448#ifdef CONFIG_SMP 427#ifdef CONFIG_SMP
449 /* Install per-cpu IRQ handler for broadcasted ticker */ 428 /* Install per-cpu IRQ handler for broadcasted ticker */
450 irq = leon_build_device_irq(leon3_ticker_irq, handle_percpu_irq, 429 irq = leon_build_device_irq(leon3_gptimer_irq, handle_percpu_irq,
451 "per-cpu", 0); 430 "per-cpu", 0);
452 err = request_irq(irq, leon_percpu_timer_ce_interrupt, 431 err = request_irq(irq, leon_percpu_timer_ce_interrupt,
453 IRQF_PERCPU | IRQF_TIMER, "ticker", 432 IRQF_PERCPU | IRQF_TIMER, "timer", NULL);
454 NULL); 433#else
434 irq = _leon_build_device_irq(NULL, leon3_gptimer_irq);
435 err = request_irq(irq, timer_interrupt, IRQF_TIMER, "timer", NULL);
436#endif
455 if (err) { 437 if (err) {
456 printk(KERN_ERR "unable to attach ticker IRQ%d\n", irq); 438 pr_err("Unable to attach timer IRQ%d\n", irq);
457 prom_halt(); 439 prom_halt();
458 } 440 }
459 441 LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx].ctrl,
460 LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx+1].ctrl,
461 LEON3_GPTIMER_EN | 442 LEON3_GPTIMER_EN |
462 LEON3_GPTIMER_RL | 443 LEON3_GPTIMER_RL |
463 LEON3_GPTIMER_LD | 444 LEON3_GPTIMER_LD |
464 LEON3_GPTIMER_IRQEN); 445 LEON3_GPTIMER_IRQEN);
465#endif
466 return; 446 return;
467bad: 447bad:
468 printk(KERN_ERR "No Timer/irqctrl found\n"); 448 printk(KERN_ERR "No Timer/irqctrl found\n");
diff --git a/arch/sparc/kernel/leon_pci_grpci1.c b/arch/sparc/kernel/leon_pci_grpci1.c
index 7739a54315e2..6df26e37f879 100644
--- a/arch/sparc/kernel/leon_pci_grpci1.c
+++ b/arch/sparc/kernel/leon_pci_grpci1.c
@@ -536,11 +536,9 @@ static int grpci1_of_probe(struct platform_device *ofdev)
536 536
537 /* find device register base address */ 537 /* find device register base address */
538 res = platform_get_resource(ofdev, IORESOURCE_MEM, 0); 538 res = platform_get_resource(ofdev, IORESOURCE_MEM, 0);
539 regs = devm_request_and_ioremap(&ofdev->dev, res); 539 regs = devm_ioremap_resource(&ofdev->dev, res);
540 if (!regs) { 540 if (IS_ERR(regs))
541 dev_err(&ofdev->dev, "io-regs mapping failed\n"); 541 return PTR_ERR(regs);
542 return -EADDRNOTAVAIL;
543 }
544 542
545 /* 543 /*
546 * check that we're in Host Slot and that we can act as a Host Bridge 544 * check that we're in Host Slot and that we can act as a Host Bridge
diff --git a/arch/sparc/kernel/leon_pmc.c b/arch/sparc/kernel/leon_pmc.c
index bdf53d9a8d46..b0b3967a2dd2 100644
--- a/arch/sparc/kernel/leon_pmc.c
+++ b/arch/sparc/kernel/leon_pmc.c
@@ -47,6 +47,10 @@ void pmc_leon_idle_fixup(void)
47 * MMU does not get a TLB miss here by using the MMU BYPASS ASI. 47 * MMU does not get a TLB miss here by using the MMU BYPASS ASI.
48 */ 48 */
49 register unsigned int address = (unsigned int)leon3_irqctrl_regs; 49 register unsigned int address = (unsigned int)leon3_irqctrl_regs;
50
51 /* Interrupts need to be enabled to not hang the CPU */
52 local_irq_enable();
53
50 __asm__ __volatile__ ( 54 __asm__ __volatile__ (
51 "wr %%g0, %%asr19\n" 55 "wr %%g0, %%asr19\n"
52 "lda [%0] %1, %%g0\n" 56 "lda [%0] %1, %%g0\n"
@@ -60,6 +64,9 @@ void pmc_leon_idle_fixup(void)
60 */ 64 */
61void pmc_leon_idle(void) 65void pmc_leon_idle(void)
62{ 66{
67 /* Interrupts need to be enabled to not hang the CPU */
68 local_irq_enable();
69
63 /* For systems without power-down, this will be no-op */ 70 /* For systems without power-down, this will be no-op */
64 __asm__ __volatile__ ("wr %g0, %asr19\n\t"); 71 __asm__ __volatile__ ("wr %g0, %asr19\n\t");
65} 72}
diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
index 9f20566b0773..79cc0d1a477d 100644
--- a/arch/sparc/kernel/prom_common.c
+++ b/arch/sparc/kernel/prom_common.c
@@ -54,6 +54,7 @@ EXPORT_SYMBOL(of_set_property_mutex);
54int of_set_property(struct device_node *dp, const char *name, void *val, int len) 54int of_set_property(struct device_node *dp, const char *name, void *val, int len)
55{ 55{
56 struct property **prevp; 56 struct property **prevp;
57 unsigned long flags;
57 void *new_val; 58 void *new_val;
58 int err; 59 int err;
59 60
@@ -64,7 +65,7 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len
64 err = -ENODEV; 65 err = -ENODEV;
65 66
66 mutex_lock(&of_set_property_mutex); 67 mutex_lock(&of_set_property_mutex);
67 raw_spin_lock(&devtree_lock); 68 raw_spin_lock_irqsave(&devtree_lock, flags);
68 prevp = &dp->properties; 69 prevp = &dp->properties;
69 while (*prevp) { 70 while (*prevp) {
70 struct property *prop = *prevp; 71 struct property *prop = *prevp;
@@ -91,7 +92,7 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len
91 } 92 }
92 prevp = &(*prevp)->next; 93 prevp = &(*prevp)->next;
93 } 94 }
94 raw_spin_unlock(&devtree_lock); 95 raw_spin_unlock_irqrestore(&devtree_lock, flags);
95 mutex_unlock(&of_set_property_mutex); 96 mutex_unlock(&of_set_property_mutex);
96 97
97 /* XXX Upate procfs if necessary... */ 98 /* XXX Upate procfs if necessary... */
diff --git a/arch/sparc/kernel/setup_32.c b/arch/sparc/kernel/setup_32.c
index 38bf80a22f02..1434526970a6 100644
--- a/arch/sparc/kernel/setup_32.c
+++ b/arch/sparc/kernel/setup_32.c
@@ -304,7 +304,7 @@ void __init setup_arch(char **cmdline_p)
304 304
305 /* Initialize PROM console and command line. */ 305 /* Initialize PROM console and command line. */
306 *cmdline_p = prom_getbootargs(); 306 *cmdline_p = prom_getbootargs();
307 strcpy(boot_command_line, *cmdline_p); 307 strlcpy(boot_command_line, *cmdline_p, COMMAND_LINE_SIZE);
308 parse_early_param(); 308 parse_early_param();
309 309
310 boot_flags_init(*cmdline_p); 310 boot_flags_init(*cmdline_p);
diff --git a/arch/sparc/kernel/setup_64.c b/arch/sparc/kernel/setup_64.c
index 88a127b9c69e..13785547e435 100644
--- a/arch/sparc/kernel/setup_64.c
+++ b/arch/sparc/kernel/setup_64.c
@@ -555,7 +555,7 @@ void __init setup_arch(char **cmdline_p)
555{ 555{
556 /* Initialize PROM console and command line. */ 556 /* Initialize PROM console and command line. */
557 *cmdline_p = prom_getbootargs(); 557 *cmdline_p = prom_getbootargs();
558 strcpy(boot_command_line, *cmdline_p); 558 strlcpy(boot_command_line, *cmdline_p, COMMAND_LINE_SIZE);
559 parse_early_param(); 559 parse_early_param();
560 560
561 boot_flags_init(*cmdline_p); 561 boot_flags_init(*cmdline_p);
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index a7171997adfd..04fd55a6e461 100644
--- a/arch/sparc/mm/init_64.c
+++ b/arch/sparc/mm/init_64.c
@@ -1098,7 +1098,14 @@ static int __init grab_mblocks(struct mdesc_handle *md)
1098 m->size = *val; 1098 m->size = *val;
1099 val = mdesc_get_property(md, node, 1099 val = mdesc_get_property(md, node,
1100 "address-congruence-offset", NULL); 1100 "address-congruence-offset", NULL);
1101 m->offset = *val; 1101
1102 /* The address-congruence-offset property is optional.
1103 * Explicity zero it be identifty this.
1104 */
1105 if (val)
1106 m->offset = *val;
1107 else
1108 m->offset = 0UL;
1102 1109
1103 numadbg("MBLOCK[%d]: base[%llx] size[%llx] offset[%llx]\n", 1110 numadbg("MBLOCK[%d]: base[%llx] size[%llx] offset[%llx]\n",
1104 count - 1, m->base, m->size, m->offset); 1111 count - 1, m->base, m->size, m->offset);
diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c
index 83d89bcb44af..37e7bc4c95b3 100644
--- a/arch/sparc/mm/tlb.c
+++ b/arch/sparc/mm/tlb.c
@@ -85,8 +85,8 @@ static void tlb_batch_add_one(struct mm_struct *mm, unsigned long vaddr,
85 } 85 }
86 86
87 if (!tb->active) { 87 if (!tb->active) {
88 global_flush_tlb_page(mm, vaddr);
89 flush_tsb_user_page(mm, vaddr); 88 flush_tsb_user_page(mm, vaddr);
89 global_flush_tlb_page(mm, vaddr);
90 goto out; 90 goto out;
91 } 91 }
92 92
diff --git a/arch/sparc/prom/bootstr_32.c b/arch/sparc/prom/bootstr_32.c
index f5ec32e0d419..d2b49d2365e7 100644
--- a/arch/sparc/prom/bootstr_32.c
+++ b/arch/sparc/prom/bootstr_32.c
@@ -23,23 +23,25 @@ prom_getbootargs(void)
23 return barg_buf; 23 return barg_buf;
24 } 24 }
25 25
26 switch(prom_vers) { 26 switch (prom_vers) {
27 case PROM_V0: 27 case PROM_V0:
28 cp = barg_buf; 28 cp = barg_buf;
29 /* Start from 1 and go over fd(0,0,0)kernel */ 29 /* Start from 1 and go over fd(0,0,0)kernel */
30 for(iter = 1; iter < 8; iter++) { 30 for (iter = 1; iter < 8; iter++) {
31 arg = (*(romvec->pv_v0bootargs))->argv[iter]; 31 arg = (*(romvec->pv_v0bootargs))->argv[iter];
32 if (arg == NULL) 32 if (arg == NULL)
33 break; 33 break;
34 while(*arg != 0) { 34 while (*arg != 0) {
35 /* Leave place for space and null. */ 35 /* Leave place for space and null. */
36 if(cp >= barg_buf + BARG_LEN-2){ 36 if (cp >= barg_buf + BARG_LEN - 2)
37 /* We might issue a warning here. */ 37 /* We might issue a warning here. */
38 break; 38 break;
39 }
40 *cp++ = *arg++; 39 *cp++ = *arg++;
41 } 40 }
42 *cp++ = ' '; 41 *cp++ = ' ';
42 if (cp >= barg_buf + BARG_LEN - 1)
43 /* We might issue a warning here. */
44 break;
43 } 45 }
44 *cp = 0; 46 *cp = 0;
45 break; 47 break;
diff --git a/arch/sparc/prom/tree_64.c b/arch/sparc/prom/tree_64.c
index 92204c3800b5..bd1b2a3ac34e 100644
--- a/arch/sparc/prom/tree_64.c
+++ b/arch/sparc/prom/tree_64.c
@@ -39,7 +39,7 @@ inline phandle __prom_getchild(phandle node)
39 return prom_node_to_node("child", node); 39 return prom_node_to_node("child", node);
40} 40}
41 41
42inline phandle prom_getchild(phandle node) 42phandle prom_getchild(phandle node)
43{ 43{
44 phandle cnode; 44 phandle cnode;
45 45
@@ -72,7 +72,7 @@ inline phandle __prom_getsibling(phandle node)
72 return prom_node_to_node(prom_peer_name, node); 72 return prom_node_to_node(prom_peer_name, node);
73} 73}
74 74
75inline phandle prom_getsibling(phandle node) 75phandle prom_getsibling(phandle node)
76{ 76{
77 phandle sibnode; 77 phandle sibnode;
78 78
@@ -89,7 +89,7 @@ EXPORT_SYMBOL(prom_getsibling);
89/* Return the length in bytes of property 'prop' at node 'node'. 89/* Return the length in bytes of property 'prop' at node 'node'.
90 * Return -1 on error. 90 * Return -1 on error.
91 */ 91 */
92inline int prom_getproplen(phandle node, const char *prop) 92int prom_getproplen(phandle node, const char *prop)
93{ 93{
94 unsigned long args[6]; 94 unsigned long args[6];
95 95
@@ -113,8 +113,8 @@ EXPORT_SYMBOL(prom_getproplen);
113 * 'buffer' which has a size of 'bufsize'. If the acquisition 113 * 'buffer' which has a size of 'bufsize'. If the acquisition
114 * was successful the length will be returned, else -1 is returned. 114 * was successful the length will be returned, else -1 is returned.
115 */ 115 */
116inline int prom_getproperty(phandle node, const char *prop, 116int prom_getproperty(phandle node, const char *prop,
117 char *buffer, int bufsize) 117 char *buffer, int bufsize)
118{ 118{
119 unsigned long args[8]; 119 unsigned long args[8];
120 int plen; 120 int plen;
@@ -141,7 +141,7 @@ EXPORT_SYMBOL(prom_getproperty);
141/* Acquire an integer property and return its value. Returns -1 141/* Acquire an integer property and return its value. Returns -1
142 * on failure. 142 * on failure.
143 */ 143 */
144inline int prom_getint(phandle node, const char *prop) 144int prom_getint(phandle node, const char *prop)
145{ 145{
146 int intprop; 146 int intprop;
147 147
@@ -235,7 +235,7 @@ static const char *prom_nextprop_name = "nextprop";
235/* Return the first property type for node 'node'. 235/* Return the first property type for node 'node'.
236 * buffer should be at least 32B in length 236 * buffer should be at least 32B in length
237 */ 237 */
238inline char *prom_firstprop(phandle node, char *buffer) 238char *prom_firstprop(phandle node, char *buffer)
239{ 239{
240 unsigned long args[7]; 240 unsigned long args[7];
241 241
@@ -261,7 +261,7 @@ EXPORT_SYMBOL(prom_firstprop);
261 * at node 'node' . Returns NULL string if no more 261 * at node 'node' . Returns NULL string if no more
262 * property types for this node. 262 * property types for this node.
263 */ 263 */
264inline char *prom_nextprop(phandle node, const char *oprop, char *buffer) 264char *prom_nextprop(phandle node, const char *oprop, char *buffer)
265{ 265{
266 unsigned long args[7]; 266 unsigned long args[7];
267 char buf[32]; 267 char buf[32];
diff --git a/arch/tile/lib/exports.c b/arch/tile/lib/exports.c
index 4385cb6fa00a..a93b02a25222 100644
--- a/arch/tile/lib/exports.c
+++ b/arch/tile/lib/exports.c
@@ -84,4 +84,6 @@ uint64_t __ashrdi3(uint64_t, unsigned int);
84EXPORT_SYMBOL(__ashrdi3); 84EXPORT_SYMBOL(__ashrdi3);
85uint64_t __ashldi3(uint64_t, unsigned int); 85uint64_t __ashldi3(uint64_t, unsigned int);
86EXPORT_SYMBOL(__ashldi3); 86EXPORT_SYMBOL(__ashldi3);
87int __ffsdi2(uint64_t);
88EXPORT_SYMBOL(__ffsdi2);
87#endif 89#endif
diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
index 35ee62fccf98..c205035a6b96 100644
--- a/arch/x86/boot/compressed/eboot.c
+++ b/arch/x86/boot/compressed/eboot.c
@@ -251,51 +251,6 @@ static void find_bits(unsigned long mask, u8 *pos, u8 *size)
251 *size = len; 251 *size = len;
252} 252}
253 253
254static efi_status_t setup_efi_vars(struct boot_params *params)
255{
256 struct setup_data *data;
257 struct efi_var_bootdata *efidata;
258 u64 store_size, remaining_size, var_size;
259 efi_status_t status;
260
261 if (sys_table->runtime->hdr.revision < EFI_2_00_SYSTEM_TABLE_REVISION)
262 return EFI_UNSUPPORTED;
263
264 data = (struct setup_data *)(unsigned long)params->hdr.setup_data;
265
266 while (data && data->next)
267 data = (struct setup_data *)(unsigned long)data->next;
268
269 status = efi_call_phys4((void *)sys_table->runtime->query_variable_info,
270 EFI_VARIABLE_NON_VOLATILE |
271 EFI_VARIABLE_BOOTSERVICE_ACCESS |
272 EFI_VARIABLE_RUNTIME_ACCESS, &store_size,
273 &remaining_size, &var_size);
274
275 if (status != EFI_SUCCESS)
276 return status;
277
278 status = efi_call_phys3(sys_table->boottime->allocate_pool,
279 EFI_LOADER_DATA, sizeof(*efidata), &efidata);
280
281 if (status != EFI_SUCCESS)
282 return status;
283
284 efidata->data.type = SETUP_EFI_VARS;
285 efidata->data.len = sizeof(struct efi_var_bootdata) -
286 sizeof(struct setup_data);
287 efidata->data.next = 0;
288 efidata->store_size = store_size;
289 efidata->remaining_size = remaining_size;
290 efidata->max_var_size = var_size;
291
292 if (data)
293 data->next = (unsigned long)efidata;
294 else
295 params->hdr.setup_data = (unsigned long)efidata;
296
297}
298
299static efi_status_t setup_efi_pci(struct boot_params *params) 254static efi_status_t setup_efi_pci(struct boot_params *params)
300{ 255{
301 efi_pci_io_protocol *pci; 256 efi_pci_io_protocol *pci;
@@ -1202,8 +1157,6 @@ struct boot_params *efi_main(void *handle, efi_system_table_t *_table,
1202 1157
1203 setup_graphics(boot_params); 1158 setup_graphics(boot_params);
1204 1159
1205 setup_efi_vars(boot_params);
1206
1207 setup_efi_pci(boot_params); 1160 setup_efi_pci(boot_params);
1208 1161
1209 status = efi_call_phys3(sys_table->boottime->allocate_pool, 1162 status = efi_call_phys3(sys_table->boottime->allocate_pool,
diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
index 62fe22cd4cba..477e9d75149b 100644
--- a/arch/x86/crypto/aesni-intel_asm.S
+++ b/arch/x86/crypto/aesni-intel_asm.S
@@ -2681,56 +2681,68 @@ ENTRY(aesni_xts_crypt8)
2681 addq %rcx, KEYP 2681 addq %rcx, KEYP
2682 2682
2683 movdqa IV, STATE1 2683 movdqa IV, STATE1
2684 pxor 0x00(INP), STATE1 2684 movdqu 0x00(INP), INC
2685 pxor INC, STATE1
2685 movdqu IV, 0x00(OUTP) 2686 movdqu IV, 0x00(OUTP)
2686 2687
2687 _aesni_gf128mul_x_ble() 2688 _aesni_gf128mul_x_ble()
2688 movdqa IV, STATE2 2689 movdqa IV, STATE2
2689 pxor 0x10(INP), STATE2 2690 movdqu 0x10(INP), INC
2691 pxor INC, STATE2
2690 movdqu IV, 0x10(OUTP) 2692 movdqu IV, 0x10(OUTP)
2691 2693
2692 _aesni_gf128mul_x_ble() 2694 _aesni_gf128mul_x_ble()
2693 movdqa IV, STATE3 2695 movdqa IV, STATE3
2694 pxor 0x20(INP), STATE3 2696 movdqu 0x20(INP), INC
2697 pxor INC, STATE3
2695 movdqu IV, 0x20(OUTP) 2698 movdqu IV, 0x20(OUTP)
2696 2699
2697 _aesni_gf128mul_x_ble() 2700 _aesni_gf128mul_x_ble()
2698 movdqa IV, STATE4 2701 movdqa IV, STATE4
2699 pxor 0x30(INP), STATE4 2702 movdqu 0x30(INP), INC
2703 pxor INC, STATE4
2700 movdqu IV, 0x30(OUTP) 2704 movdqu IV, 0x30(OUTP)
2701 2705
2702 call *%r11 2706 call *%r11
2703 2707
2704 pxor 0x00(OUTP), STATE1 2708 movdqu 0x00(OUTP), INC
2709 pxor INC, STATE1
2705 movdqu STATE1, 0x00(OUTP) 2710 movdqu STATE1, 0x00(OUTP)
2706 2711
2707 _aesni_gf128mul_x_ble() 2712 _aesni_gf128mul_x_ble()
2708 movdqa IV, STATE1 2713 movdqa IV, STATE1
2709 pxor 0x40(INP), STATE1 2714 movdqu 0x40(INP), INC
2715 pxor INC, STATE1
2710 movdqu IV, 0x40(OUTP) 2716 movdqu IV, 0x40(OUTP)
2711 2717
2712 pxor 0x10(OUTP), STATE2 2718 movdqu 0x10(OUTP), INC
2719 pxor INC, STATE2
2713 movdqu STATE2, 0x10(OUTP) 2720 movdqu STATE2, 0x10(OUTP)
2714 2721
2715 _aesni_gf128mul_x_ble() 2722 _aesni_gf128mul_x_ble()
2716 movdqa IV, STATE2 2723 movdqa IV, STATE2
2717 pxor 0x50(INP), STATE2 2724 movdqu 0x50(INP), INC
2725 pxor INC, STATE2
2718 movdqu IV, 0x50(OUTP) 2726 movdqu IV, 0x50(OUTP)
2719 2727
2720 pxor 0x20(OUTP), STATE3 2728 movdqu 0x20(OUTP), INC
2729 pxor INC, STATE3
2721 movdqu STATE3, 0x20(OUTP) 2730 movdqu STATE3, 0x20(OUTP)
2722 2731
2723 _aesni_gf128mul_x_ble() 2732 _aesni_gf128mul_x_ble()
2724 movdqa IV, STATE3 2733 movdqa IV, STATE3
2725 pxor 0x60(INP), STATE3 2734 movdqu 0x60(INP), INC
2735 pxor INC, STATE3
2726 movdqu IV, 0x60(OUTP) 2736 movdqu IV, 0x60(OUTP)
2727 2737
2728 pxor 0x30(OUTP), STATE4 2738 movdqu 0x30(OUTP), INC
2739 pxor INC, STATE4
2729 movdqu STATE4, 0x30(OUTP) 2740 movdqu STATE4, 0x30(OUTP)
2730 2741
2731 _aesni_gf128mul_x_ble() 2742 _aesni_gf128mul_x_ble()
2732 movdqa IV, STATE4 2743 movdqa IV, STATE4
2733 pxor 0x70(INP), STATE4 2744 movdqu 0x70(INP), INC
2745 pxor INC, STATE4
2734 movdqu IV, 0x70(OUTP) 2746 movdqu IV, 0x70(OUTP)
2735 2747
2736 _aesni_gf128mul_x_ble() 2748 _aesni_gf128mul_x_ble()
@@ -2738,16 +2750,20 @@ ENTRY(aesni_xts_crypt8)
2738 2750
2739 call *%r11 2751 call *%r11
2740 2752
2741 pxor 0x40(OUTP), STATE1 2753 movdqu 0x40(OUTP), INC
2754 pxor INC, STATE1
2742 movdqu STATE1, 0x40(OUTP) 2755 movdqu STATE1, 0x40(OUTP)
2743 2756
2744 pxor 0x50(OUTP), STATE2 2757 movdqu 0x50(OUTP), INC
2758 pxor INC, STATE2
2745 movdqu STATE2, 0x50(OUTP) 2759 movdqu STATE2, 0x50(OUTP)
2746 2760
2747 pxor 0x60(OUTP), STATE3 2761 movdqu 0x60(OUTP), INC
2762 pxor INC, STATE3
2748 movdqu STATE3, 0x60(OUTP) 2763 movdqu STATE3, 0x60(OUTP)
2749 2764
2750 pxor 0x70(OUTP), STATE4 2765 movdqu 0x70(OUTP), INC
2766 pxor INC, STATE4
2751 movdqu STATE4, 0x70(OUTP) 2767 movdqu STATE4, 0x70(OUTP)
2752 2768
2753 ret 2769 ret
diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h
index 2fb5d5884e23..60c89f30c727 100644
--- a/arch/x86/include/asm/efi.h
+++ b/arch/x86/include/asm/efi.h
@@ -102,13 +102,6 @@ extern void efi_call_phys_epilog(void);
102extern void efi_unmap_memmap(void); 102extern void efi_unmap_memmap(void);
103extern void efi_memory_uc(u64 addr, unsigned long size); 103extern void efi_memory_uc(u64 addr, unsigned long size);
104 104
105struct efi_var_bootdata {
106 struct setup_data data;
107 u64 store_size;
108 u64 remaining_size;
109 u64 max_var_size;
110};
111
112#ifdef CONFIG_EFI 105#ifdef CONFIG_EFI
113 106
114static inline bool efi_is_native(void) 107static inline bool efi_is_native(void)
diff --git a/arch/x86/include/uapi/asm/bootparam.h b/arch/x86/include/uapi/asm/bootparam.h
index 08744242b8d2..c15ddaf90710 100644
--- a/arch/x86/include/uapi/asm/bootparam.h
+++ b/arch/x86/include/uapi/asm/bootparam.h
@@ -6,7 +6,6 @@
6#define SETUP_E820_EXT 1 6#define SETUP_E820_EXT 1
7#define SETUP_DTB 2 7#define SETUP_DTB 2
8#define SETUP_PCI 3 8#define SETUP_PCI 3
9#define SETUP_EFI_VARS 4
10 9
11/* ram_size flags */ 10/* ram_size flags */
12#define RAMDISK_IMAGE_START_MASK 0x07FF 11#define RAMDISK_IMAGE_START_MASK 0x07FF
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index f60d41ff9a97..a9e22073bd56 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -165,13 +165,13 @@ static struct extra_reg intel_snb_extra_regs[] __read_mostly = {
165 INTEL_EVENT_EXTRA_REG(0xb7, MSR_OFFCORE_RSP_0, 0x3f807f8fffull, RSP_0), 165 INTEL_EVENT_EXTRA_REG(0xb7, MSR_OFFCORE_RSP_0, 0x3f807f8fffull, RSP_0),
166 INTEL_EVENT_EXTRA_REG(0xbb, MSR_OFFCORE_RSP_1, 0x3f807f8fffull, RSP_1), 166 INTEL_EVENT_EXTRA_REG(0xbb, MSR_OFFCORE_RSP_1, 0x3f807f8fffull, RSP_1),
167 INTEL_UEVENT_PEBS_LDLAT_EXTRA_REG(0x01cd), 167 INTEL_UEVENT_PEBS_LDLAT_EXTRA_REG(0x01cd),
168 INTEL_UEVENT_PEBS_LDLAT_EXTRA_REG(0x01cd),
169 EVENT_EXTRA_END 168 EVENT_EXTRA_END
170}; 169};
171 170
172static struct extra_reg intel_snbep_extra_regs[] __read_mostly = { 171static struct extra_reg intel_snbep_extra_regs[] __read_mostly = {
173 INTEL_EVENT_EXTRA_REG(0xb7, MSR_OFFCORE_RSP_0, 0x3fffff8fffull, RSP_0), 172 INTEL_EVENT_EXTRA_REG(0xb7, MSR_OFFCORE_RSP_0, 0x3fffff8fffull, RSP_0),
174 INTEL_EVENT_EXTRA_REG(0xbb, MSR_OFFCORE_RSP_1, 0x3fffff8fffull, RSP_1), 173 INTEL_EVENT_EXTRA_REG(0xbb, MSR_OFFCORE_RSP_1, 0x3fffff8fffull, RSP_1),
174 INTEL_UEVENT_PEBS_LDLAT_EXTRA_REG(0x01cd),
175 EVENT_EXTRA_END 175 EVENT_EXTRA_END
176}; 176};
177 177
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index d2c381280e3c..3dd37ebd591b 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -242,6 +242,7 @@ void __init kvmclock_init(void)
242 if (!mem) 242 if (!mem)
243 return; 243 return;
244 hv_clock = __va(mem); 244 hv_clock = __va(mem);
245 memset(hv_clock, 0, size);
245 246
246 if (kvm_register_clock("boot clock")) { 247 if (kvm_register_clock("boot clock")) {
247 hv_clock = NULL; 248 hv_clock = NULL;
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 4e7a37ff03ab..81a5f5e8f142 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -277,18 +277,6 @@ void exit_idle(void)
277} 277}
278#endif 278#endif
279 279
280void arch_cpu_idle_prepare(void)
281{
282 /*
283 * If we're the non-boot CPU, nothing set the stack canary up
284 * for us. CPU0 already has it initialized but no harm in
285 * doing it again. This is a good place for updating it, as
286 * we wont ever return from this function (so the invalid
287 * canaries already on the stack wont ever trigger).
288 */
289 boot_init_stack_canary();
290}
291
292void arch_cpu_idle_enter(void) 280void arch_cpu_idle_enter(void)
293{ 281{
294 local_touch_nmi(); 282 local_touch_nmi();
diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
index 7a6f3b3be3cf..f2bb9c96720a 100644
--- a/arch/x86/kernel/relocate_kernel_64.S
+++ b/arch/x86/kernel/relocate_kernel_64.S
@@ -160,7 +160,7 @@ identity_mapped:
160 xorq %rbp, %rbp 160 xorq %rbp, %rbp
161 xorq %r8, %r8 161 xorq %r8, %r8
162 xorq %r9, %r9 162 xorq %r9, %r9
163 xorq %r10, %r9 163 xorq %r10, %r10
164 xorq %r11, %r11 164 xorq %r11, %r11
165 xorq %r12, %r12 165 xorq %r12, %r12
166 xorq %r13, %r13 166 xorq %r13, %r13
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 9c73b51817e4..bfd348e99369 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -372,15 +372,15 @@ static bool __cpuinit match_mc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
372 372
373void __cpuinit set_cpu_sibling_map(int cpu) 373void __cpuinit set_cpu_sibling_map(int cpu)
374{ 374{
375 bool has_mc = boot_cpu_data.x86_max_cores > 1;
376 bool has_smt = smp_num_siblings > 1; 375 bool has_smt = smp_num_siblings > 1;
376 bool has_mp = has_smt || boot_cpu_data.x86_max_cores > 1;
377 struct cpuinfo_x86 *c = &cpu_data(cpu); 377 struct cpuinfo_x86 *c = &cpu_data(cpu);
378 struct cpuinfo_x86 *o; 378 struct cpuinfo_x86 *o;
379 int i; 379 int i;
380 380
381 cpumask_set_cpu(cpu, cpu_sibling_setup_mask); 381 cpumask_set_cpu(cpu, cpu_sibling_setup_mask);
382 382
383 if (!has_smt && !has_mc) { 383 if (!has_mp) {
384 cpumask_set_cpu(cpu, cpu_sibling_mask(cpu)); 384 cpumask_set_cpu(cpu, cpu_sibling_mask(cpu));
385 cpumask_set_cpu(cpu, cpu_llc_shared_mask(cpu)); 385 cpumask_set_cpu(cpu, cpu_llc_shared_mask(cpu));
386 cpumask_set_cpu(cpu, cpu_core_mask(cpu)); 386 cpumask_set_cpu(cpu, cpu_core_mask(cpu));
@@ -394,7 +394,7 @@ void __cpuinit set_cpu_sibling_map(int cpu)
394 if ((i == cpu) || (has_smt && match_smt(c, o))) 394 if ((i == cpu) || (has_smt && match_smt(c, o)))
395 link_mask(sibling, cpu, i); 395 link_mask(sibling, cpu, i);
396 396
397 if ((i == cpu) || (has_mc && match_llc(c, o))) 397 if ((i == cpu) || (has_mp && match_llc(c, o)))
398 link_mask(llc_shared, cpu, i); 398 link_mask(llc_shared, cpu, i);
399 399
400 } 400 }
@@ -406,7 +406,7 @@ void __cpuinit set_cpu_sibling_map(int cpu)
406 for_each_cpu(i, cpu_sibling_setup_mask) { 406 for_each_cpu(i, cpu_sibling_setup_mask) {
407 o = &cpu_data(i); 407 o = &cpu_data(i);
408 408
409 if ((i == cpu) || (has_mc && match_mc(c, o))) { 409 if ((i == cpu) || (has_mp && match_mc(c, o))) {
410 link_mask(core, cpu, i); 410 link_mask(core, cpu, i);
411 411
412 /* 412 /*
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 094b5d96ab14..e8ba99c34180 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -582,8 +582,6 @@ int __kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr)
582 if (index != XCR_XFEATURE_ENABLED_MASK) 582 if (index != XCR_XFEATURE_ENABLED_MASK)
583 return 1; 583 return 1;
584 xcr0 = xcr; 584 xcr0 = xcr;
585 if (kvm_x86_ops->get_cpl(vcpu) != 0)
586 return 1;
587 if (!(xcr0 & XSTATE_FP)) 585 if (!(xcr0 & XSTATE_FP))
588 return 1; 586 return 1;
589 if ((xcr0 & XSTATE_YMM) && !(xcr0 & XSTATE_SSE)) 587 if ((xcr0 & XSTATE_YMM) && !(xcr0 & XSTATE_SSE))
@@ -597,7 +595,8 @@ int __kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr)
597 595
598int kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr) 596int kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr)
599{ 597{
600 if (__kvm_set_xcr(vcpu, index, xcr)) { 598 if (kvm_x86_ops->get_cpl(vcpu) != 0 ||
599 __kvm_set_xcr(vcpu, index, xcr)) {
601 kvm_inject_gp(vcpu, 0); 600 kvm_inject_gp(vcpu, 0);
602 return 1; 601 return 1;
603 } 602 }
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index eaac1743def7..1f34e9219775 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -277,6 +277,9 @@ static int __meminit split_mem_range(struct map_range *mr, int nr_range,
277 end_pfn = limit_pfn; 277 end_pfn = limit_pfn;
278 nr_range = save_mr(mr, nr_range, start_pfn, end_pfn, 0); 278 nr_range = save_mr(mr, nr_range, start_pfn, end_pfn, 0);
279 279
280 if (!after_bootmem)
281 adjust_range_page_size_mask(mr, nr_range);
282
280 /* try to merge same page size and continuous */ 283 /* try to merge same page size and continuous */
281 for (i = 0; nr_range > 1 && i < nr_range - 1; i++) { 284 for (i = 0; nr_range > 1 && i < nr_range - 1; i++) {
282 unsigned long old_start; 285 unsigned long old_start;
@@ -291,9 +294,6 @@ static int __meminit split_mem_range(struct map_range *mr, int nr_range,
291 nr_range--; 294 nr_range--;
292 } 295 }
293 296
294 if (!after_bootmem)
295 adjust_range_page_size_mask(mr, nr_range);
296
297 for (i = 0; i < nr_range; i++) 297 for (i = 0; i < nr_range; i++)
298 printk(KERN_DEBUG " [mem %#010lx-%#010lx] page %s\n", 298 printk(KERN_DEBUG " [mem %#010lx-%#010lx] page %s\n",
299 mr[i].start, mr[i].end - 1, 299 mr[i].start, mr[i].end - 1,
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 82089d8b1954..5ae2eb09419e 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -42,7 +42,6 @@
42#include <linux/io.h> 42#include <linux/io.h>
43#include <linux/reboot.h> 43#include <linux/reboot.h>
44#include <linux/bcd.h> 44#include <linux/bcd.h>
45#include <linux/ucs2_string.h>
46 45
47#include <asm/setup.h> 46#include <asm/setup.h>
48#include <asm/efi.h> 47#include <asm/efi.h>
@@ -54,12 +53,12 @@
54 53
55#define EFI_DEBUG 1 54#define EFI_DEBUG 1
56 55
57/* 56#define EFI_MIN_RESERVE 5120
58 * There's some additional metadata associated with each 57
59 * variable. Intel's reference implementation is 60 bytes - bump that 58#define EFI_DUMMY_GUID \
60 * to account for potential alignment constraints 59 EFI_GUID(0x4424ac57, 0xbe4b, 0x47dd, 0x9e, 0x97, 0xed, 0x50, 0xf0, 0x9f, 0x92, 0xa9)
61 */ 60
62#define VAR_METADATA_SIZE 64 61static efi_char16_t efi_dummy_name[6] = { 'D', 'U', 'M', 'M', 'Y', 0 };
63 62
64struct efi __read_mostly efi = { 63struct efi __read_mostly efi = {
65 .mps = EFI_INVALID_TABLE_ADDR, 64 .mps = EFI_INVALID_TABLE_ADDR,
@@ -79,13 +78,6 @@ struct efi_memory_map memmap;
79static struct efi efi_phys __initdata; 78static struct efi efi_phys __initdata;
80static efi_system_table_t efi_systab __initdata; 79static efi_system_table_t efi_systab __initdata;
81 80
82static u64 efi_var_store_size;
83static u64 efi_var_remaining_size;
84static u64 efi_var_max_var_size;
85static u64 boot_used_size;
86static u64 boot_var_size;
87static u64 active_size;
88
89unsigned long x86_efi_facility; 81unsigned long x86_efi_facility;
90 82
91/* 83/*
@@ -188,53 +180,8 @@ static efi_status_t virt_efi_get_next_variable(unsigned long *name_size,
188 efi_char16_t *name, 180 efi_char16_t *name,
189 efi_guid_t *vendor) 181 efi_guid_t *vendor)
190{ 182{
191 efi_status_t status; 183 return efi_call_virt3(get_next_variable,
192 static bool finished = false; 184 name_size, name, vendor);
193 static u64 var_size;
194
195 status = efi_call_virt3(get_next_variable,
196 name_size, name, vendor);
197
198 if (status == EFI_NOT_FOUND) {
199 finished = true;
200 if (var_size < boot_used_size) {
201 boot_var_size = boot_used_size - var_size;
202 active_size += boot_var_size;
203 } else {
204 printk(KERN_WARNING FW_BUG "efi: Inconsistent initial sizes\n");
205 }
206 }
207
208 if (boot_used_size && !finished) {
209 unsigned long size = 0;
210 u32 attr;
211 efi_status_t s;
212 void *tmp;
213
214 s = virt_efi_get_variable(name, vendor, &attr, &size, NULL);
215
216 if (s != EFI_BUFFER_TOO_SMALL || !size)
217 return status;
218
219 tmp = kmalloc(size, GFP_ATOMIC);
220
221 if (!tmp)
222 return status;
223
224 s = virt_efi_get_variable(name, vendor, &attr, &size, tmp);
225
226 if (s == EFI_SUCCESS && (attr & EFI_VARIABLE_NON_VOLATILE)) {
227 var_size += size;
228 var_size += ucs2_strsize(name, 1024);
229 active_size += size;
230 active_size += VAR_METADATA_SIZE;
231 active_size += ucs2_strsize(name, 1024);
232 }
233
234 kfree(tmp);
235 }
236
237 return status;
238} 185}
239 186
240static efi_status_t virt_efi_set_variable(efi_char16_t *name, 187static efi_status_t virt_efi_set_variable(efi_char16_t *name,
@@ -243,34 +190,9 @@ static efi_status_t virt_efi_set_variable(efi_char16_t *name,
243 unsigned long data_size, 190 unsigned long data_size,
244 void *data) 191 void *data)
245{ 192{
246 efi_status_t status; 193 return efi_call_virt5(set_variable,
247 u32 orig_attr = 0; 194 name, vendor, attr,
248 unsigned long orig_size = 0; 195 data_size, data);
249
250 status = virt_efi_get_variable(name, vendor, &orig_attr, &orig_size,
251 NULL);
252
253 if (status != EFI_BUFFER_TOO_SMALL)
254 orig_size = 0;
255
256 status = efi_call_virt5(set_variable,
257 name, vendor, attr,
258 data_size, data);
259
260 if (status == EFI_SUCCESS) {
261 if (orig_size) {
262 active_size -= orig_size;
263 active_size -= ucs2_strsize(name, 1024);
264 active_size -= VAR_METADATA_SIZE;
265 }
266 if (data_size) {
267 active_size += data_size;
268 active_size += ucs2_strsize(name, 1024);
269 active_size += VAR_METADATA_SIZE;
270 }
271 }
272
273 return status;
274} 196}
275 197
276static efi_status_t virt_efi_query_variable_info(u32 attr, 198static efi_status_t virt_efi_query_variable_info(u32 attr,
@@ -786,9 +708,6 @@ void __init efi_init(void)
786 char vendor[100] = "unknown"; 708 char vendor[100] = "unknown";
787 int i = 0; 709 int i = 0;
788 void *tmp; 710 void *tmp;
789 struct setup_data *data;
790 struct efi_var_bootdata *efi_var_data;
791 u64 pa_data;
792 711
793#ifdef CONFIG_X86_32 712#ifdef CONFIG_X86_32
794 if (boot_params.efi_info.efi_systab_hi || 713 if (boot_params.efi_info.efi_systab_hi ||
@@ -806,22 +725,6 @@ void __init efi_init(void)
806 if (efi_systab_init(efi_phys.systab)) 725 if (efi_systab_init(efi_phys.systab))
807 return; 726 return;
808 727
809 pa_data = boot_params.hdr.setup_data;
810 while (pa_data) {
811 data = early_ioremap(pa_data, sizeof(*efi_var_data));
812 if (data->type == SETUP_EFI_VARS) {
813 efi_var_data = (struct efi_var_bootdata *)data;
814
815 efi_var_store_size = efi_var_data->store_size;
816 efi_var_remaining_size = efi_var_data->remaining_size;
817 efi_var_max_var_size = efi_var_data->max_var_size;
818 }
819 pa_data = data->next;
820 early_iounmap(data, sizeof(*efi_var_data));
821 }
822
823 boot_used_size = efi_var_store_size - efi_var_remaining_size;
824
825 set_bit(EFI_SYSTEM_TABLES, &x86_efi_facility); 728 set_bit(EFI_SYSTEM_TABLES, &x86_efi_facility);
826 729
827 /* 730 /*
@@ -1085,6 +988,13 @@ void __init efi_enter_virtual_mode(void)
1085 runtime_code_page_mkexec(); 988 runtime_code_page_mkexec();
1086 989
1087 kfree(new_memmap); 990 kfree(new_memmap);
991
992 /* clean DUMMY object */
993 efi.set_variable(efi_dummy_name, &EFI_DUMMY_GUID,
994 EFI_VARIABLE_NON_VOLATILE |
995 EFI_VARIABLE_BOOTSERVICE_ACCESS |
996 EFI_VARIABLE_RUNTIME_ACCESS,
997 0, NULL);
1088} 998}
1089 999
1090/* 1000/*
@@ -1136,33 +1046,65 @@ efi_status_t efi_query_variable_store(u32 attributes, unsigned long size)
1136 efi_status_t status; 1046 efi_status_t status;
1137 u64 storage_size, remaining_size, max_size; 1047 u64 storage_size, remaining_size, max_size;
1138 1048
1049 if (!(attributes & EFI_VARIABLE_NON_VOLATILE))
1050 return 0;
1051
1139 status = efi.query_variable_info(attributes, &storage_size, 1052 status = efi.query_variable_info(attributes, &storage_size,
1140 &remaining_size, &max_size); 1053 &remaining_size, &max_size);
1141 if (status != EFI_SUCCESS) 1054 if (status != EFI_SUCCESS)
1142 return status; 1055 return status;
1143 1056
1144 if (!max_size && remaining_size > size)
1145 printk_once(KERN_ERR FW_BUG "Broken EFI implementation"
1146 " is returning MaxVariableSize=0\n");
1147 /* 1057 /*
1148 * Some firmware implementations refuse to boot if there's insufficient 1058 * Some firmware implementations refuse to boot if there's insufficient
1149 * space in the variable store. We account for that by refusing the 1059 * space in the variable store. We account for that by refusing the
1150 * write if permitting it would reduce the available space to under 1060 * write if permitting it would reduce the available space to under
1151 * 50%. However, some firmware won't reclaim variable space until 1061 * 5KB. This figure was provided by Samsung, so should be safe.
1152 * after the used (not merely the actively used) space drops below
1153 * a threshold. We can approximate that case with the value calculated
1154 * above. If both the firmware and our calculations indicate that the
1155 * available space would drop below 50%, refuse the write.
1156 */ 1062 */
1063 if ((remaining_size - size < EFI_MIN_RESERVE) &&
1064 !efi_no_storage_paranoia) {
1065
1066 /*
1067 * Triggering garbage collection may require that the firmware
1068 * generate a real EFI_OUT_OF_RESOURCES error. We can force
1069 * that by attempting to use more space than is available.
1070 */
1071 unsigned long dummy_size = remaining_size + 1024;
1072 void *dummy = kmalloc(dummy_size, GFP_ATOMIC);
1073
1074 status = efi.set_variable(efi_dummy_name, &EFI_DUMMY_GUID,
1075 EFI_VARIABLE_NON_VOLATILE |
1076 EFI_VARIABLE_BOOTSERVICE_ACCESS |
1077 EFI_VARIABLE_RUNTIME_ACCESS,
1078 dummy_size, dummy);
1079
1080 if (status == EFI_SUCCESS) {
1081 /*
1082 * This should have failed, so if it didn't make sure
1083 * that we delete it...
1084 */
1085 efi.set_variable(efi_dummy_name, &EFI_DUMMY_GUID,
1086 EFI_VARIABLE_NON_VOLATILE |
1087 EFI_VARIABLE_BOOTSERVICE_ACCESS |
1088 EFI_VARIABLE_RUNTIME_ACCESS,
1089 0, dummy);
1090 }
1157 1091
1158 if (!storage_size || size > remaining_size || 1092 /*
1159 (max_size && size > max_size)) 1093 * The runtime code may now have triggered a garbage collection
1160 return EFI_OUT_OF_RESOURCES; 1094 * run, so check the variable info again
1095 */
1096 status = efi.query_variable_info(attributes, &storage_size,
1097 &remaining_size, &max_size);
1161 1098
1162 if (!efi_no_storage_paranoia && 1099 if (status != EFI_SUCCESS)
1163 ((active_size + size + VAR_METADATA_SIZE > storage_size / 2) && 1100 return status;
1164 (remaining_size - size < storage_size / 2))) 1101
1165 return EFI_OUT_OF_RESOURCES; 1102 /*
1103 * There still isn't enough room, so return an error
1104 */
1105 if (remaining_size - size < EFI_MIN_RESERVE)
1106 return EFI_OUT_OF_RESOURCES;
1107 }
1166 1108
1167 return EFI_SUCCESS; 1109 return EFI_SUCCESS;
1168} 1110}
diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
index 590be1090892..f7bab68a4b83 100644
--- a/arch/x86/tools/relocs.c
+++ b/arch/x86/tools/relocs.c
@@ -42,9 +42,6 @@ static const char * const sym_regex_kernel[S_NSYMTYPES] = {
42 "^(xen_irq_disable_direct_reloc$|" 42 "^(xen_irq_disable_direct_reloc$|"
43 "xen_save_fl_direct_reloc$|" 43 "xen_save_fl_direct_reloc$|"
44 "VDSO|" 44 "VDSO|"
45#if ELF_BITS == 64
46 "__vvar_page|"
47#endif
48 "__crc_)", 45 "__crc_)",
49 46
50/* 47/*
@@ -72,6 +69,7 @@ static const char * const sym_regex_kernel[S_NSYMTYPES] = {
72 "__per_cpu_load|" 69 "__per_cpu_load|"
73 "init_per_cpu__.*|" 70 "init_per_cpu__.*|"
74 "__end_rodata_hpage_align|" 71 "__end_rodata_hpage_align|"
72 "__vvar_page|"
75#endif 73#endif
76 "_end)$" 74 "_end)$"
77}; 75};
diff --git a/block/blk-core.c b/block/blk-core.c
index 33c33bc99ddd..d5745b5833c9 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -3164,7 +3164,7 @@ void blk_post_runtime_resume(struct request_queue *q, int err)
3164 q->rpm_status = RPM_ACTIVE; 3164 q->rpm_status = RPM_ACTIVE;
3165 __blk_run_queue(q); 3165 __blk_run_queue(q);
3166 pm_runtime_mark_last_busy(q->dev); 3166 pm_runtime_mark_last_busy(q->dev);
3167 pm_runtime_autosuspend(q->dev); 3167 pm_request_autosuspend(q->dev);
3168 } else { 3168 } else {
3169 q->rpm_status = RPM_SUSPENDED; 3169 q->rpm_status = RPM_SUSPENDED;
3170 } 3170 }
diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index 652fd5ce303c..cab13f2fc28e 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -164,15 +164,24 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
164 if (dev_desc->clk_required) { 164 if (dev_desc->clk_required) {
165 ret = register_device_clock(adev, pdata); 165 ret = register_device_clock(adev, pdata);
166 if (ret) { 166 if (ret) {
167 /* 167 /* Skip the device, but continue the namespace scan. */
168 * Skip the device, but don't terminate the namespace 168 ret = 0;
169 * scan. 169 goto err_out;
170 */
171 kfree(pdata);
172 return 0;
173 } 170 }
174 } 171 }
175 172
173 /*
174 * This works around a known issue in ACPI tables where LPSS devices
175 * have _PS0 and _PS3 without _PSC (and no power resources), so
176 * acpi_bus_init_power() will assume that the BIOS has put them into D0.
177 */
178 ret = acpi_device_fix_up_power(adev);
179 if (ret) {
180 /* Skip the device, but continue the namespace scan. */
181 ret = 0;
182 goto err_out;
183 }
184
176 adev->driver_data = pdata; 185 adev->driver_data = pdata;
177 ret = acpi_create_platform_device(adev, id); 186 ret = acpi_create_platform_device(adev, id);
178 if (ret > 0) 187 if (ret > 0)
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index 318fa32a141e..31c217a42839 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -290,6 +290,26 @@ int acpi_bus_init_power(struct acpi_device *device)
290 return 0; 290 return 0;
291} 291}
292 292
293/**
294 * acpi_device_fix_up_power - Force device with missing _PSC into D0.
295 * @device: Device object whose power state is to be fixed up.
296 *
297 * Devices without power resources and _PSC, but having _PS0 and _PS3 defined,
298 * are assumed to be put into D0 by the BIOS. However, in some cases that may
299 * not be the case and this function should be used then.
300 */
301int acpi_device_fix_up_power(struct acpi_device *device)
302{
303 int ret = 0;
304
305 if (!device->power.flags.power_resources
306 && !device->power.flags.explicit_get
307 && device->power.state == ACPI_STATE_D0)
308 ret = acpi_dev_pm_explicit_set(device, ACPI_STATE_D0);
309
310 return ret;
311}
312
293int acpi_bus_update_power(acpi_handle handle, int *state_p) 313int acpi_bus_update_power(acpi_handle handle, int *state_p)
294{ 314{
295 struct acpi_device *device; 315 struct acpi_device *device;
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 4fdea381ef21..ec117c6c996c 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -868,8 +868,10 @@ static ssize_t write_undock(struct device *dev, struct device_attribute *attr,
868 if (!count) 868 if (!count)
869 return -EINVAL; 869 return -EINVAL;
870 870
871 acpi_scan_lock_acquire();
871 begin_undock(dock_station); 872 begin_undock(dock_station);
872 ret = handle_eject_request(dock_station, ACPI_NOTIFY_EJECT_REQUEST); 873 ret = handle_eject_request(dock_station, ACPI_NOTIFY_EJECT_REQUEST);
874 acpi_scan_lock_release();
873 return ret ? ret: count; 875 return ret ? ret: count;
874} 876}
875static DEVICE_ATTR(undock, S_IWUSR, NULL, write_undock); 877static DEVICE_ATTR(undock, S_IWUSR, NULL, write_undock);
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index f962047c6c85..288bb270f8ed 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -885,6 +885,7 @@ int acpi_add_power_resource(acpi_handle handle)
885 ACPI_STA_DEFAULT); 885 ACPI_STA_DEFAULT);
886 mutex_init(&resource->resource_lock); 886 mutex_init(&resource->resource_lock);
887 INIT_LIST_HEAD(&resource->dependent); 887 INIT_LIST_HEAD(&resource->dependent);
888 INIT_LIST_HEAD(&resource->list_node);
888 resource->name = device->pnp.bus_id; 889 resource->name = device->pnp.bus_id;
889 strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME); 890 strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME);
890 strcpy(acpi_device_class(device), ACPI_POWER_CLASS); 891 strcpy(acpi_device_class(device), ACPI_POWER_CLASS);
diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
index a3868f6c222a..3322b47ab7ca 100644
--- a/drivers/acpi/resource.c
+++ b/drivers/acpi/resource.c
@@ -304,7 +304,8 @@ static void acpi_dev_irqresource_disabled(struct resource *res, u32 gsi)
304} 304}
305 305
306static void acpi_dev_get_irqresource(struct resource *res, u32 gsi, 306static void acpi_dev_get_irqresource(struct resource *res, u32 gsi,
307 u8 triggering, u8 polarity, u8 shareable) 307 u8 triggering, u8 polarity, u8 shareable,
308 bool legacy)
308{ 309{
309 int irq, p, t; 310 int irq, p, t;
310 311
@@ -317,14 +318,19 @@ static void acpi_dev_get_irqresource(struct resource *res, u32 gsi,
317 * In IO-APIC mode, use overrided attribute. Two reasons: 318 * In IO-APIC mode, use overrided attribute. Two reasons:
318 * 1. BIOS bug in DSDT 319 * 1. BIOS bug in DSDT
319 * 2. BIOS uses IO-APIC mode Interrupt Source Override 320 * 2. BIOS uses IO-APIC mode Interrupt Source Override
321 *
322 * We do this only if we are dealing with IRQ() or IRQNoFlags()
323 * resource (the legacy ISA resources). With modern ACPI 5 devices
324 * using extended IRQ descriptors we take the IRQ configuration
325 * from _CRS directly.
320 */ 326 */
321 if (!acpi_get_override_irq(gsi, &t, &p)) { 327 if (legacy && !acpi_get_override_irq(gsi, &t, &p)) {
322 u8 trig = t ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE; 328 u8 trig = t ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE;
323 u8 pol = p ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH; 329 u8 pol = p ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH;
324 330
325 if (triggering != trig || polarity != pol) { 331 if (triggering != trig || polarity != pol) {
326 pr_warning("ACPI: IRQ %d override to %s, %s\n", gsi, 332 pr_warning("ACPI: IRQ %d override to %s, %s\n", gsi,
327 t ? "edge" : "level", p ? "low" : "high"); 333 t ? "level" : "edge", p ? "low" : "high");
328 triggering = trig; 334 triggering = trig;
329 polarity = pol; 335 polarity = pol;
330 } 336 }
@@ -373,7 +379,7 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,
373 } 379 }
374 acpi_dev_get_irqresource(res, irq->interrupts[index], 380 acpi_dev_get_irqresource(res, irq->interrupts[index],
375 irq->triggering, irq->polarity, 381 irq->triggering, irq->polarity,
376 irq->sharable); 382 irq->sharable, true);
377 break; 383 break;
378 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: 384 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
379 ext_irq = &ares->data.extended_irq; 385 ext_irq = &ares->data.extended_irq;
@@ -383,7 +389,7 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,
383 } 389 }
384 acpi_dev_get_irqresource(res, ext_irq->interrupts[index], 390 acpi_dev_get_irqresource(res, ext_irq->interrupts[index],
385 ext_irq->triggering, ext_irq->polarity, 391 ext_irq->triggering, ext_irq->polarity,
386 ext_irq->sharable); 392 ext_irq->sharable, false);
387 break; 393 break;
388 default: 394 default:
389 return false; 395 return false;
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 44225cb15f3a..b14ac46948c9 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1017,11 +1017,8 @@ acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver)
1017 return -ENOSYS; 1017 return -ENOSYS;
1018 1018
1019 result = driver->ops.add(device); 1019 result = driver->ops.add(device);
1020 if (result) { 1020 if (result)
1021 device->driver = NULL;
1022 device->driver_data = NULL;
1023 return result; 1021 return result;
1024 }
1025 1022
1026 device->driver = driver; 1023 device->driver = driver;
1027 1024
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 5d7075d25700..440eadf2d32c 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -1722,6 +1722,9 @@ static int acpi_video_bus_add(struct acpi_device *device)
1722 int error; 1722 int error;
1723 acpi_status status; 1723 acpi_status status;
1724 1724
1725 if (device->handler)
1726 return -EINVAL;
1727
1725 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, 1728 status = acpi_walk_namespace(ACPI_TYPE_DEVICE,
1726 device->parent->handle, 1, 1729 device->parent->handle, 1,
1727 acpi_video_bus_match, NULL, 1730 acpi_video_bus_match, NULL,
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 6374dc103521..62b6c2cc80b5 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -168,8 +168,6 @@ static irqreturn_t do_cciss_msix_intr(int irq, void *dev_id);
168static int cciss_open(struct block_device *bdev, fmode_t mode); 168static int cciss_open(struct block_device *bdev, fmode_t mode);
169static int cciss_unlocked_open(struct block_device *bdev, fmode_t mode); 169static int cciss_unlocked_open(struct block_device *bdev, fmode_t mode);
170static void cciss_release(struct gendisk *disk, fmode_t mode); 170static void cciss_release(struct gendisk *disk, fmode_t mode);
171static int do_ioctl(struct block_device *bdev, fmode_t mode,
172 unsigned int cmd, unsigned long arg);
173static int cciss_ioctl(struct block_device *bdev, fmode_t mode, 171static int cciss_ioctl(struct block_device *bdev, fmode_t mode,
174 unsigned int cmd, unsigned long arg); 172 unsigned int cmd, unsigned long arg);
175static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo); 173static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo);
@@ -235,7 +233,7 @@ static const struct block_device_operations cciss_fops = {
235 .owner = THIS_MODULE, 233 .owner = THIS_MODULE,
236 .open = cciss_unlocked_open, 234 .open = cciss_unlocked_open,
237 .release = cciss_release, 235 .release = cciss_release,
238 .ioctl = do_ioctl, 236 .ioctl = cciss_ioctl,
239 .getgeo = cciss_getgeo, 237 .getgeo = cciss_getgeo,
240#ifdef CONFIG_COMPAT 238#ifdef CONFIG_COMPAT
241 .compat_ioctl = cciss_compat_ioctl, 239 .compat_ioctl = cciss_compat_ioctl,
@@ -1143,16 +1141,6 @@ static void cciss_release(struct gendisk *disk, fmode_t mode)
1143 mutex_unlock(&cciss_mutex); 1141 mutex_unlock(&cciss_mutex);
1144} 1142}
1145 1143
1146static int do_ioctl(struct block_device *bdev, fmode_t mode,
1147 unsigned cmd, unsigned long arg)
1148{
1149 int ret;
1150 mutex_lock(&cciss_mutex);
1151 ret = cciss_ioctl(bdev, mode, cmd, arg);
1152 mutex_unlock(&cciss_mutex);
1153 return ret;
1154}
1155
1156#ifdef CONFIG_COMPAT 1144#ifdef CONFIG_COMPAT
1157 1145
1158static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode, 1146static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
@@ -1179,7 +1167,7 @@ static int cciss_compat_ioctl(struct block_device *bdev, fmode_t mode,
1179 case CCISS_REGNEWD: 1167 case CCISS_REGNEWD:
1180 case CCISS_RESCANDISK: 1168 case CCISS_RESCANDISK:
1181 case CCISS_GETLUNINFO: 1169 case CCISS_GETLUNINFO:
1182 return do_ioctl(bdev, mode, cmd, arg); 1170 return cciss_ioctl(bdev, mode, cmd, arg);
1183 1171
1184 case CCISS_PASSTHRU32: 1172 case CCISS_PASSTHRU32:
1185 return cciss_ioctl32_passthru(bdev, mode, cmd, arg); 1173 return cciss_ioctl32_passthru(bdev, mode, cmd, arg);
@@ -1219,7 +1207,7 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
1219 if (err) 1207 if (err)
1220 return -EFAULT; 1208 return -EFAULT;
1221 1209
1222 err = do_ioctl(bdev, mode, CCISS_PASSTHRU, (unsigned long)p); 1210 err = cciss_ioctl(bdev, mode, CCISS_PASSTHRU, (unsigned long)p);
1223 if (err) 1211 if (err)
1224 return err; 1212 return err;
1225 err |= 1213 err |=
@@ -1261,7 +1249,7 @@ static int cciss_ioctl32_big_passthru(struct block_device *bdev, fmode_t mode,
1261 if (err) 1249 if (err)
1262 return -EFAULT; 1250 return -EFAULT;
1263 1251
1264 err = do_ioctl(bdev, mode, CCISS_BIG_PASSTHRU, (unsigned long)p); 1252 err = cciss_ioctl(bdev, mode, CCISS_BIG_PASSTHRU, (unsigned long)p);
1265 if (err) 1253 if (err)
1266 return err; 1254 return err;
1267 err |= 1255 err |=
@@ -1311,11 +1299,14 @@ static int cciss_getpciinfo(ctlr_info_t *h, void __user *argp)
1311static int cciss_getintinfo(ctlr_info_t *h, void __user *argp) 1299static int cciss_getintinfo(ctlr_info_t *h, void __user *argp)
1312{ 1300{
1313 cciss_coalint_struct intinfo; 1301 cciss_coalint_struct intinfo;
1302 unsigned long flags;
1314 1303
1315 if (!argp) 1304 if (!argp)
1316 return -EINVAL; 1305 return -EINVAL;
1306 spin_lock_irqsave(&h->lock, flags);
1317 intinfo.delay = readl(&h->cfgtable->HostWrite.CoalIntDelay); 1307 intinfo.delay = readl(&h->cfgtable->HostWrite.CoalIntDelay);
1318 intinfo.count = readl(&h->cfgtable->HostWrite.CoalIntCount); 1308 intinfo.count = readl(&h->cfgtable->HostWrite.CoalIntCount);
1309 spin_unlock_irqrestore(&h->lock, flags);
1319 if (copy_to_user 1310 if (copy_to_user
1320 (argp, &intinfo, sizeof(cciss_coalint_struct))) 1311 (argp, &intinfo, sizeof(cciss_coalint_struct)))
1321 return -EFAULT; 1312 return -EFAULT;
@@ -1356,12 +1347,15 @@ static int cciss_setintinfo(ctlr_info_t *h, void __user *argp)
1356static int cciss_getnodename(ctlr_info_t *h, void __user *argp) 1347static int cciss_getnodename(ctlr_info_t *h, void __user *argp)
1357{ 1348{
1358 NodeName_type NodeName; 1349 NodeName_type NodeName;
1350 unsigned long flags;
1359 int i; 1351 int i;
1360 1352
1361 if (!argp) 1353 if (!argp)
1362 return -EINVAL; 1354 return -EINVAL;
1355 spin_lock_irqsave(&h->lock, flags);
1363 for (i = 0; i < 16; i++) 1356 for (i = 0; i < 16; i++)
1364 NodeName[i] = readb(&h->cfgtable->ServerName[i]); 1357 NodeName[i] = readb(&h->cfgtable->ServerName[i]);
1358 spin_unlock_irqrestore(&h->lock, flags);
1365 if (copy_to_user(argp, NodeName, sizeof(NodeName_type))) 1359 if (copy_to_user(argp, NodeName, sizeof(NodeName_type)))
1366 return -EFAULT; 1360 return -EFAULT;
1367 return 0; 1361 return 0;
@@ -1398,10 +1392,13 @@ static int cciss_setnodename(ctlr_info_t *h, void __user *argp)
1398static int cciss_getheartbeat(ctlr_info_t *h, void __user *argp) 1392static int cciss_getheartbeat(ctlr_info_t *h, void __user *argp)
1399{ 1393{
1400 Heartbeat_type heartbeat; 1394 Heartbeat_type heartbeat;
1395 unsigned long flags;
1401 1396
1402 if (!argp) 1397 if (!argp)
1403 return -EINVAL; 1398 return -EINVAL;
1399 spin_lock_irqsave(&h->lock, flags);
1404 heartbeat = readl(&h->cfgtable->HeartBeat); 1400 heartbeat = readl(&h->cfgtable->HeartBeat);
1401 spin_unlock_irqrestore(&h->lock, flags);
1405 if (copy_to_user(argp, &heartbeat, sizeof(Heartbeat_type))) 1402 if (copy_to_user(argp, &heartbeat, sizeof(Heartbeat_type)))
1406 return -EFAULT; 1403 return -EFAULT;
1407 return 0; 1404 return 0;
@@ -1410,10 +1407,13 @@ static int cciss_getheartbeat(ctlr_info_t *h, void __user *argp)
1410static int cciss_getbustypes(ctlr_info_t *h, void __user *argp) 1407static int cciss_getbustypes(ctlr_info_t *h, void __user *argp)
1411{ 1408{
1412 BusTypes_type BusTypes; 1409 BusTypes_type BusTypes;
1410 unsigned long flags;
1413 1411
1414 if (!argp) 1412 if (!argp)
1415 return -EINVAL; 1413 return -EINVAL;
1414 spin_lock_irqsave(&h->lock, flags);
1416 BusTypes = readl(&h->cfgtable->BusTypes); 1415 BusTypes = readl(&h->cfgtable->BusTypes);
1416 spin_unlock_irqrestore(&h->lock, flags);
1417 if (copy_to_user(argp, &BusTypes, sizeof(BusTypes_type))) 1417 if (copy_to_user(argp, &BusTypes, sizeof(BusTypes_type)))
1418 return -EFAULT; 1418 return -EFAULT;
1419 return 0; 1419 return 0;
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 847107ef0cce..20dd52a2f92f 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -3002,7 +3002,8 @@ static int mtip_hw_debugfs_init(struct driver_data *dd)
3002 3002
3003static void mtip_hw_debugfs_exit(struct driver_data *dd) 3003static void mtip_hw_debugfs_exit(struct driver_data *dd)
3004{ 3004{
3005 debugfs_remove_recursive(dd->dfs_node); 3005 if (dd->dfs_node)
3006 debugfs_remove_recursive(dd->dfs_node);
3006} 3007}
3007 3008
3008 3009
@@ -3863,7 +3864,7 @@ static void mtip_make_request(struct request_queue *queue, struct bio *bio)
3863 struct driver_data *dd = queue->queuedata; 3864 struct driver_data *dd = queue->queuedata;
3864 struct scatterlist *sg; 3865 struct scatterlist *sg;
3865 struct bio_vec *bvec; 3866 struct bio_vec *bvec;
3866 int nents = 0; 3867 int i, nents = 0;
3867 int tag = 0, unaligned = 0; 3868 int tag = 0, unaligned = 0;
3868 3869
3869 if (unlikely(dd->dd_flag & MTIP_DDF_STOP_IO)) { 3870 if (unlikely(dd->dd_flag & MTIP_DDF_STOP_IO)) {
@@ -3921,11 +3922,12 @@ static void mtip_make_request(struct request_queue *queue, struct bio *bio)
3921 } 3922 }
3922 3923
3923 /* Create the scatter list for this bio. */ 3924 /* Create the scatter list for this bio. */
3924 bio_for_each_segment(bvec, bio, nents) { 3925 bio_for_each_segment(bvec, bio, i) {
3925 sg_set_page(&sg[nents], 3926 sg_set_page(&sg[nents],
3926 bvec->bv_page, 3927 bvec->bv_page,
3927 bvec->bv_len, 3928 bvec->bv_len,
3928 bvec->bv_offset); 3929 bvec->bv_offset);
3930 nents++;
3929 } 3931 }
3930 3932
3931 /* Issue the read/write. */ 3933 /* Issue the read/write. */
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
index 8efdfaa44a59..ce79a590b45b 100644
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@ -629,7 +629,7 @@ static int nvme_submit_bio_queue(struct nvme_queue *nvmeq, struct nvme_ns *ns,
629 struct nvme_command *cmnd; 629 struct nvme_command *cmnd;
630 struct nvme_iod *iod; 630 struct nvme_iod *iod;
631 enum dma_data_direction dma_dir; 631 enum dma_data_direction dma_dir;
632 int cmdid, length, result = -ENOMEM; 632 int cmdid, length, result;
633 u16 control; 633 u16 control;
634 u32 dsmgmt; 634 u32 dsmgmt;
635 int psegs = bio_phys_segments(ns->queue, bio); 635 int psegs = bio_phys_segments(ns->queue, bio);
@@ -640,6 +640,7 @@ static int nvme_submit_bio_queue(struct nvme_queue *nvmeq, struct nvme_ns *ns,
640 return result; 640 return result;
641 } 641 }
642 642
643 result = -ENOMEM;
643 iod = nvme_alloc_iod(psegs, bio->bi_size, GFP_ATOMIC); 644 iod = nvme_alloc_iod(psegs, bio->bi_size, GFP_ATOMIC);
644 if (!iod) 645 if (!iod)
645 goto nomem; 646 goto nomem;
@@ -977,6 +978,8 @@ static void nvme_cancel_ios(struct nvme_queue *nvmeq, bool timeout)
977 978
978 if (timeout && !time_after(now, info[cmdid].timeout)) 979 if (timeout && !time_after(now, info[cmdid].timeout))
979 continue; 980 continue;
981 if (info[cmdid].ctx == CMD_CTX_CANCELLED)
982 continue;
980 dev_warn(nvmeq->q_dmadev, "Cancelling I/O %d\n", cmdid); 983 dev_warn(nvmeq->q_dmadev, "Cancelling I/O %d\n", cmdid);
981 ctx = cancel_cmdid(nvmeq, cmdid, &fn); 984 ctx = cancel_cmdid(nvmeq, cmdid, &fn);
982 fn(nvmeq->dev, ctx, &cqe); 985 fn(nvmeq->dev, ctx, &cqe);
@@ -1206,7 +1209,7 @@ struct nvme_iod *nvme_map_user_pages(struct nvme_dev *dev, int write,
1206 1209
1207 if (addr & 3) 1210 if (addr & 3)
1208 return ERR_PTR(-EINVAL); 1211 return ERR_PTR(-EINVAL);
1209 if (!length) 1212 if (!length || length > INT_MAX - PAGE_SIZE)
1210 return ERR_PTR(-EINVAL); 1213 return ERR_PTR(-EINVAL);
1211 1214
1212 offset = offset_in_page(addr); 1215 offset = offset_in_page(addr);
@@ -1227,7 +1230,8 @@ struct nvme_iod *nvme_map_user_pages(struct nvme_dev *dev, int write,
1227 sg_init_table(sg, count); 1230 sg_init_table(sg, count);
1228 for (i = 0; i < count; i++) { 1231 for (i = 0; i < count; i++) {
1229 sg_set_page(&sg[i], pages[i], 1232 sg_set_page(&sg[i], pages[i],
1230 min_t(int, length, PAGE_SIZE - offset), offset); 1233 min_t(unsigned, length, PAGE_SIZE - offset),
1234 offset);
1231 length -= (PAGE_SIZE - offset); 1235 length -= (PAGE_SIZE - offset);
1232 offset = 0; 1236 offset = 0;
1233 } 1237 }
@@ -1435,7 +1439,7 @@ static int nvme_user_admin_cmd(struct nvme_dev *dev,
1435 nvme_free_iod(dev, iod); 1439 nvme_free_iod(dev, iod);
1436 } 1440 }
1437 1441
1438 if (!status && copy_to_user(&ucmd->result, &cmd.result, 1442 if ((status >= 0) && copy_to_user(&ucmd->result, &cmd.result,
1439 sizeof(cmd.result))) 1443 sizeof(cmd.result)))
1440 status = -EFAULT; 1444 status = -EFAULT;
1441 1445
@@ -1633,7 +1637,8 @@ static int set_queue_count(struct nvme_dev *dev, int count)
1633 1637
1634static int nvme_setup_io_queues(struct nvme_dev *dev) 1638static int nvme_setup_io_queues(struct nvme_dev *dev)
1635{ 1639{
1636 int result, cpu, i, nr_io_queues, db_bar_size, q_depth; 1640 struct pci_dev *pdev = dev->pci_dev;
1641 int result, cpu, i, nr_io_queues, db_bar_size, q_depth, q_count;
1637 1642
1638 nr_io_queues = num_online_cpus(); 1643 nr_io_queues = num_online_cpus();
1639 result = set_queue_count(dev, nr_io_queues); 1644 result = set_queue_count(dev, nr_io_queues);
@@ -1642,14 +1647,14 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
1642 if (result < nr_io_queues) 1647 if (result < nr_io_queues)
1643 nr_io_queues = result; 1648 nr_io_queues = result;
1644 1649
1650 q_count = nr_io_queues;
1645 /* Deregister the admin queue's interrupt */ 1651 /* Deregister the admin queue's interrupt */
1646 free_irq(dev->entry[0].vector, dev->queues[0]); 1652 free_irq(dev->entry[0].vector, dev->queues[0]);
1647 1653
1648 db_bar_size = 4096 + ((nr_io_queues + 1) << (dev->db_stride + 3)); 1654 db_bar_size = 4096 + ((nr_io_queues + 1) << (dev->db_stride + 3));
1649 if (db_bar_size > 8192) { 1655 if (db_bar_size > 8192) {
1650 iounmap(dev->bar); 1656 iounmap(dev->bar);
1651 dev->bar = ioremap(pci_resource_start(dev->pci_dev, 0), 1657 dev->bar = ioremap(pci_resource_start(pdev, 0), db_bar_size);
1652 db_bar_size);
1653 dev->dbs = ((void __iomem *)dev->bar) + 4096; 1658 dev->dbs = ((void __iomem *)dev->bar) + 4096;
1654 dev->queues[0]->q_db = dev->dbs; 1659 dev->queues[0]->q_db = dev->dbs;
1655 } 1660 }
@@ -1657,19 +1662,36 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
1657 for (i = 0; i < nr_io_queues; i++) 1662 for (i = 0; i < nr_io_queues; i++)
1658 dev->entry[i].entry = i; 1663 dev->entry[i].entry = i;
1659 for (;;) { 1664 for (;;) {
1660 result = pci_enable_msix(dev->pci_dev, dev->entry, 1665 result = pci_enable_msix(pdev, dev->entry, nr_io_queues);
1661 nr_io_queues);
1662 if (result == 0) { 1666 if (result == 0) {
1663 break; 1667 break;
1664 } else if (result > 0) { 1668 } else if (result > 0) {
1665 nr_io_queues = result; 1669 nr_io_queues = result;
1666 continue; 1670 continue;
1667 } else { 1671 } else {
1668 nr_io_queues = 1; 1672 nr_io_queues = 0;
1669 break; 1673 break;
1670 } 1674 }
1671 } 1675 }
1672 1676
1677 if (nr_io_queues == 0) {
1678 nr_io_queues = q_count;
1679 for (;;) {
1680 result = pci_enable_msi_block(pdev, nr_io_queues);
1681 if (result == 0) {
1682 for (i = 0; i < nr_io_queues; i++)
1683 dev->entry[i].vector = i + pdev->irq;
1684 break;
1685 } else if (result > 0) {
1686 nr_io_queues = result;
1687 continue;
1688 } else {
1689 nr_io_queues = 1;
1690 break;
1691 }
1692 }
1693 }
1694
1673 result = queue_request_irq(dev, dev->queues[0], "nvme admin"); 1695 result = queue_request_irq(dev, dev->queues[0], "nvme admin");
1674 /* XXX: handle failure here */ 1696 /* XXX: handle failure here */
1675 1697
@@ -1850,7 +1872,10 @@ static void nvme_free_dev(struct kref *kref)
1850{ 1872{
1851 struct nvme_dev *dev = container_of(kref, struct nvme_dev, kref); 1873 struct nvme_dev *dev = container_of(kref, struct nvme_dev, kref);
1852 nvme_dev_remove(dev); 1874 nvme_dev_remove(dev);
1853 pci_disable_msix(dev->pci_dev); 1875 if (dev->pci_dev->msi_enabled)
1876 pci_disable_msi(dev->pci_dev);
1877 else if (dev->pci_dev->msix_enabled)
1878 pci_disable_msix(dev->pci_dev);
1854 iounmap(dev->bar); 1879 iounmap(dev->bar);
1855 nvme_release_instance(dev); 1880 nvme_release_instance(dev);
1856 nvme_release_prp_pools(dev); 1881 nvme_release_prp_pools(dev);
@@ -1923,8 +1948,14 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1923 INIT_LIST_HEAD(&dev->namespaces); 1948 INIT_LIST_HEAD(&dev->namespaces);
1924 dev->pci_dev = pdev; 1949 dev->pci_dev = pdev;
1925 pci_set_drvdata(pdev, dev); 1950 pci_set_drvdata(pdev, dev);
1926 dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)); 1951
1927 dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64)); 1952 if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)))
1953 dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
1954 else if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)))
1955 dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
1956 else
1957 goto disable;
1958
1928 result = nvme_set_instance(dev); 1959 result = nvme_set_instance(dev);
1929 if (result) 1960 if (result)
1930 goto disable; 1961 goto disable;
@@ -1977,7 +2008,10 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1977 unmap: 2008 unmap:
1978 iounmap(dev->bar); 2009 iounmap(dev->bar);
1979 disable_msix: 2010 disable_msix:
1980 pci_disable_msix(pdev); 2011 if (dev->pci_dev->msi_enabled)
2012 pci_disable_msi(dev->pci_dev);
2013 else if (dev->pci_dev->msix_enabled)
2014 pci_disable_msix(dev->pci_dev);
1981 nvme_release_instance(dev); 2015 nvme_release_instance(dev);
1982 nvme_release_prp_pools(dev); 2016 nvme_release_prp_pools(dev);
1983 disable: 2017 disable:
diff --git a/drivers/block/nvme-scsi.c b/drivers/block/nvme-scsi.c
index fed54b039893..102de2f52b5c 100644
--- a/drivers/block/nvme-scsi.c
+++ b/drivers/block/nvme-scsi.c
@@ -44,7 +44,6 @@
44#include <linux/sched.h> 44#include <linux/sched.h>
45#include <linux/slab.h> 45#include <linux/slab.h>
46#include <linux/types.h> 46#include <linux/types.h>
47#include <linux/version.h>
48#include <scsi/sg.h> 47#include <scsi/sg.h>
49#include <scsi/scsi.h> 48#include <scsi/scsi.h>
50 49
@@ -1654,7 +1653,7 @@ static void nvme_trans_modesel_save_bd(struct nvme_ns *ns, u8 *parm_list,
1654 } 1653 }
1655} 1654}
1656 1655
1657static u16 nvme_trans_modesel_get_mp(struct nvme_ns *ns, struct sg_io_hdr *hdr, 1656static int nvme_trans_modesel_get_mp(struct nvme_ns *ns, struct sg_io_hdr *hdr,
1658 u8 *mode_page, u8 page_code) 1657 u8 *mode_page, u8 page_code)
1659{ 1658{
1660 int res = SNTI_TRANSLATION_SUCCESS; 1659 int res = SNTI_TRANSLATION_SUCCESS;
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 3c08983e600a..f5d0ea11d9fd 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -83,7 +83,8 @@
83 83
84#define MAX_SPEED 0xffff 84#define MAX_SPEED 0xffff
85 85
86#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1)) 86#define ZONE(sector, pd) (((sector) + (pd)->offset) & \
87 ~(sector_t)((pd)->settings.size - 1))
87 88
88static DEFINE_MUTEX(pktcdvd_mutex); 89static DEFINE_MUTEX(pktcdvd_mutex);
89static struct pktcdvd_device *pkt_devs[MAX_WRITERS]; 90static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index d6d314027b5d..49394e3f31bc 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -519,8 +519,8 @@ static const struct block_device_operations rbd_bd_ops = {
519}; 519};
520 520
521/* 521/*
522 * Initialize an rbd client instance. 522 * Initialize an rbd client instance. Success or not, this function
523 * We own *ceph_opts. 523 * consumes ceph_opts.
524 */ 524 */
525static struct rbd_client *rbd_client_create(struct ceph_options *ceph_opts) 525static struct rbd_client *rbd_client_create(struct ceph_options *ceph_opts)
526{ 526{
@@ -675,7 +675,8 @@ static int parse_rbd_opts_token(char *c, void *private)
675 675
676/* 676/*
677 * Get a ceph client with specific addr and configuration, if one does 677 * Get a ceph client with specific addr and configuration, if one does
678 * not exist create it. 678 * not exist create it. Either way, ceph_opts is consumed by this
679 * function.
679 */ 680 */
680static struct rbd_client *rbd_get_client(struct ceph_options *ceph_opts) 681static struct rbd_client *rbd_get_client(struct ceph_options *ceph_opts)
681{ 682{
@@ -1035,12 +1036,16 @@ static const char *rbd_segment_name(struct rbd_device *rbd_dev, u64 offset)
1035 char *name; 1036 char *name;
1036 u64 segment; 1037 u64 segment;
1037 int ret; 1038 int ret;
1039 char *name_format;
1038 1040
1039 name = kmem_cache_alloc(rbd_segment_name_cache, GFP_NOIO); 1041 name = kmem_cache_alloc(rbd_segment_name_cache, GFP_NOIO);
1040 if (!name) 1042 if (!name)
1041 return NULL; 1043 return NULL;
1042 segment = offset >> rbd_dev->header.obj_order; 1044 segment = offset >> rbd_dev->header.obj_order;
1043 ret = snprintf(name, MAX_OBJ_NAME_SIZE + 1, "%s.%012llx", 1045 name_format = "%s.%012llx";
1046 if (rbd_dev->image_format == 2)
1047 name_format = "%s.%016llx";
1048 ret = snprintf(name, MAX_OBJ_NAME_SIZE + 1, name_format,
1044 rbd_dev->header.object_prefix, segment); 1049 rbd_dev->header.object_prefix, segment);
1045 if (ret < 0 || ret > MAX_OBJ_NAME_SIZE) { 1050 if (ret < 0 || ret > MAX_OBJ_NAME_SIZE) {
1046 pr_err("error formatting segment name for #%llu (%d)\n", 1051 pr_err("error formatting segment name for #%llu (%d)\n",
@@ -4697,8 +4702,10 @@ out:
4697 return ret; 4702 return ret;
4698} 4703}
4699 4704
4700/* Undo whatever state changes are made by v1 or v2 image probe */ 4705/*
4701 4706 * Undo whatever state changes are made by v1 or v2 header info
4707 * call.
4708 */
4702static void rbd_dev_unprobe(struct rbd_device *rbd_dev) 4709static void rbd_dev_unprobe(struct rbd_device *rbd_dev)
4703{ 4710{
4704 struct rbd_image_header *header; 4711 struct rbd_image_header *header;
@@ -4902,9 +4909,10 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool mapping)
4902 int tmp; 4909 int tmp;
4903 4910
4904 /* 4911 /*
4905 * Get the id from the image id object. If it's not a 4912 * Get the id from the image id object. Unless there's an
4906 * format 2 image, we'll get ENOENT back, and we'll assume 4913 * error, rbd_dev->spec->image_id will be filled in with
4907 * it's a format 1 image. 4914 * a dynamically-allocated string, and rbd_dev->image_format
4915 * will be set to either 1 or 2.
4908 */ 4916 */
4909 ret = rbd_dev_image_id(rbd_dev); 4917 ret = rbd_dev_image_id(rbd_dev);
4910 if (ret) 4918 if (ret)
@@ -4992,7 +5000,6 @@ static ssize_t rbd_add(struct bus_type *bus,
4992 rc = PTR_ERR(rbdc); 5000 rc = PTR_ERR(rbdc);
4993 goto err_out_args; 5001 goto err_out_args;
4994 } 5002 }
4995 ceph_opts = NULL; /* rbd_dev client now owns this */
4996 5003
4997 /* pick the pool */ 5004 /* pick the pool */
4998 osdc = &rbdc->client->osdc; 5005 osdc = &rbdc->client->osdc;
@@ -5027,18 +5034,18 @@ static ssize_t rbd_add(struct bus_type *bus,
5027 rbd_dev->mapping.read_only = read_only; 5034 rbd_dev->mapping.read_only = read_only;
5028 5035
5029 rc = rbd_dev_device_setup(rbd_dev); 5036 rc = rbd_dev_device_setup(rbd_dev);
5030 if (!rc) 5037 if (rc) {
5031 return count; 5038 rbd_dev_image_release(rbd_dev);
5039 goto err_out_module;
5040 }
5041
5042 return count;
5032 5043
5033 rbd_dev_image_release(rbd_dev);
5034err_out_rbd_dev: 5044err_out_rbd_dev:
5035 rbd_dev_destroy(rbd_dev); 5045 rbd_dev_destroy(rbd_dev);
5036err_out_client: 5046err_out_client:
5037 rbd_put_client(rbdc); 5047 rbd_put_client(rbdc);
5038err_out_args: 5048err_out_args:
5039 if (ceph_opts)
5040 ceph_destroy_options(ceph_opts);
5041 kfree(rbd_opts);
5042 rbd_spec_put(spec); 5049 rbd_spec_put(spec);
5043err_out_module: 5050err_out_module:
5044 module_put(THIS_MODULE); 5051 module_put(THIS_MODULE);
diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
index fdfd61a2d523..11a6104a1e4f 100644
--- a/drivers/bluetooth/Kconfig
+++ b/drivers/bluetooth/Kconfig
@@ -201,7 +201,7 @@ config BT_MRVL
201 The core driver to support Marvell Bluetooth devices. 201 The core driver to support Marvell Bluetooth devices.
202 202
203 This driver is required if you want to support 203 This driver is required if you want to support
204 Marvell Bluetooth devices, such as 8688/8787/8797. 204 Marvell Bluetooth devices, such as 8688/8787/8797/8897.
205 205
206 Say Y here to compile Marvell Bluetooth driver 206 Say Y here to compile Marvell Bluetooth driver
207 into the kernel or say M to compile it as module. 207 into the kernel or say M to compile it as module.
@@ -214,7 +214,7 @@ config BT_MRVL_SDIO
214 The driver for Marvell Bluetooth chipsets with SDIO interface. 214 The driver for Marvell Bluetooth chipsets with SDIO interface.
215 215
216 This driver is required if you want to use Marvell Bluetooth 216 This driver is required if you want to use Marvell Bluetooth
217 devices with SDIO interface. Currently SD8688/SD8787/SD8797 217 devices with SDIO interface. Currently SD8688/SD8787/SD8797/SD8897
218 chipsets are supported. 218 chipsets are supported.
219 219
220 Say Y here to compile support for Marvell BT-over-SDIO driver 220 Say Y here to compile support for Marvell BT-over-SDIO driver
diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c
index c63488c54f4a..13693b7a0d5c 100644
--- a/drivers/bluetooth/btmrvl_sdio.c
+++ b/drivers/bluetooth/btmrvl_sdio.c
@@ -82,6 +82,23 @@ static const struct btmrvl_sdio_card_reg btmrvl_reg_87xx = {
82 .io_port_2 = 0x7a, 82 .io_port_2 = 0x7a,
83}; 83};
84 84
85static const struct btmrvl_sdio_card_reg btmrvl_reg_88xx = {
86 .cfg = 0x00,
87 .host_int_mask = 0x02,
88 .host_intstatus = 0x03,
89 .card_status = 0x50,
90 .sq_read_base_addr_a0 = 0x60,
91 .sq_read_base_addr_a1 = 0x61,
92 .card_revision = 0xbc,
93 .card_fw_status0 = 0xc0,
94 .card_fw_status1 = 0xc1,
95 .card_rx_len = 0xc2,
96 .card_rx_unit = 0xc3,
97 .io_port_0 = 0xd8,
98 .io_port_1 = 0xd9,
99 .io_port_2 = 0xda,
100};
101
85static const struct btmrvl_sdio_device btmrvl_sdio_sd8688 = { 102static const struct btmrvl_sdio_device btmrvl_sdio_sd8688 = {
86 .helper = "mrvl/sd8688_helper.bin", 103 .helper = "mrvl/sd8688_helper.bin",
87 .firmware = "mrvl/sd8688.bin", 104 .firmware = "mrvl/sd8688.bin",
@@ -103,6 +120,13 @@ static const struct btmrvl_sdio_device btmrvl_sdio_sd8797 = {
103 .sd_blksz_fw_dl = 256, 120 .sd_blksz_fw_dl = 256,
104}; 121};
105 122
123static const struct btmrvl_sdio_device btmrvl_sdio_sd8897 = {
124 .helper = NULL,
125 .firmware = "mrvl/sd8897_uapsta.bin",
126 .reg = &btmrvl_reg_88xx,
127 .sd_blksz_fw_dl = 256,
128};
129
106static const struct sdio_device_id btmrvl_sdio_ids[] = { 130static const struct sdio_device_id btmrvl_sdio_ids[] = {
107 /* Marvell SD8688 Bluetooth device */ 131 /* Marvell SD8688 Bluetooth device */
108 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, 0x9105), 132 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, 0x9105),
@@ -116,6 +140,9 @@ static const struct sdio_device_id btmrvl_sdio_ids[] = {
116 /* Marvell SD8797 Bluetooth device */ 140 /* Marvell SD8797 Bluetooth device */
117 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, 0x912A), 141 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, 0x912A),
118 .driver_data = (unsigned long) &btmrvl_sdio_sd8797 }, 142 .driver_data = (unsigned long) &btmrvl_sdio_sd8797 },
143 /* Marvell SD8897 Bluetooth device */
144 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, 0x912E),
145 .driver_data = (unsigned long) &btmrvl_sdio_sd8897 },
119 146
120 { } /* Terminating entry */ 147 { } /* Terminating entry */
121}; 148};
@@ -1194,3 +1221,4 @@ MODULE_FIRMWARE("mrvl/sd8688_helper.bin");
1194MODULE_FIRMWARE("mrvl/sd8688.bin"); 1221MODULE_FIRMWARE("mrvl/sd8688.bin");
1195MODULE_FIRMWARE("mrvl/sd8787_uapsta.bin"); 1222MODULE_FIRMWARE("mrvl/sd8787_uapsta.bin");
1196MODULE_FIRMWARE("mrvl/sd8797_uapsta.bin"); 1223MODULE_FIRMWARE("mrvl/sd8797_uapsta.bin");
1224MODULE_FIRMWARE("mrvl/sd8897_uapsta.bin");
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 934cfd18f72d..1144e8c7579d 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -1955,6 +1955,7 @@ int clk_notifier_unregister(struct clk *clk, struct notifier_block *nb)
1955 /* XXX the notifier code should handle this better */ 1955 /* XXX the notifier code should handle this better */
1956 if (!cn->notifier_head.head) { 1956 if (!cn->notifier_head.head) {
1957 srcu_cleanup_notifier_head(&cn->notifier_head); 1957 srcu_cleanup_notifier_head(&cn->notifier_head);
1958 list_del(&cn->node);
1958 kfree(cn); 1959 kfree(cn);
1959 } 1960 }
1960 1961
diff --git a/drivers/clk/samsung/clk-exynos5250.c b/drivers/clk/samsung/clk-exynos5250.c
index 5c97e75924a8..22d7699e7ced 100644
--- a/drivers/clk/samsung/clk-exynos5250.c
+++ b/drivers/clk/samsung/clk-exynos5250.c
@@ -155,7 +155,7 @@ static __initdata unsigned long exynos5250_clk_regs[] = {
155 155
156/* list of all parent clock list */ 156/* list of all parent clock list */
157PNAME(mout_apll_p) = { "fin_pll", "fout_apll", }; 157PNAME(mout_apll_p) = { "fin_pll", "fout_apll", };
158PNAME(mout_cpu_p) = { "mout_apll", "mout_mpll", }; 158PNAME(mout_cpu_p) = { "mout_apll", "sclk_mpll", };
159PNAME(mout_mpll_fout_p) = { "fout_mplldiv2", "fout_mpll" }; 159PNAME(mout_mpll_fout_p) = { "fout_mplldiv2", "fout_mpll" };
160PNAME(mout_mpll_p) = { "fin_pll", "mout_mpll_fout" }; 160PNAME(mout_mpll_p) = { "fin_pll", "mout_mpll_fout" };
161PNAME(mout_bpll_fout_p) = { "fout_bplldiv2", "fout_bpll" }; 161PNAME(mout_bpll_fout_p) = { "fout_bplldiv2", "fout_bpll" };
@@ -208,10 +208,10 @@ struct samsung_fixed_factor_clock exynos5250_fixed_factor_clks[] __initdata = {
208}; 208};
209 209
210struct samsung_mux_clock exynos5250_mux_clks[] __initdata = { 210struct samsung_mux_clock exynos5250_mux_clks[] __initdata = {
211 MUX(none, "mout_apll", mout_apll_p, SRC_CPU, 0, 1), 211 MUX_A(none, "mout_apll", mout_apll_p, SRC_CPU, 0, 1, "mout_apll"),
212 MUX(none, "mout_cpu", mout_cpu_p, SRC_CPU, 16, 1), 212 MUX_A(none, "mout_cpu", mout_cpu_p, SRC_CPU, 16, 1, "mout_cpu"),
213 MUX(none, "mout_mpll_fout", mout_mpll_fout_p, PLL_DIV2_SEL, 4, 1), 213 MUX(none, "mout_mpll_fout", mout_mpll_fout_p, PLL_DIV2_SEL, 4, 1),
214 MUX(none, "sclk_mpll", mout_mpll_p, SRC_CORE1, 8, 1), 214 MUX_A(none, "sclk_mpll", mout_mpll_p, SRC_CORE1, 8, 1, "mout_mpll"),
215 MUX(none, "mout_bpll_fout", mout_bpll_fout_p, PLL_DIV2_SEL, 0, 1), 215 MUX(none, "mout_bpll_fout", mout_bpll_fout_p, PLL_DIV2_SEL, 0, 1),
216 MUX(none, "sclk_bpll", mout_bpll_p, SRC_CDREX, 0, 1), 216 MUX(none, "sclk_bpll", mout_bpll_p, SRC_CDREX, 0, 1),
217 MUX(none, "mout_vpllsrc", mout_vpllsrc_p, SRC_TOP2, 0, 1), 217 MUX(none, "mout_vpllsrc", mout_vpllsrc_p, SRC_TOP2, 0, 1),
@@ -378,7 +378,7 @@ struct samsung_gate_clock exynos5250_gate_clks[] __initdata = {
378 GATE(hsi2c3, "hsi2c3", "aclk66", GATE_IP_PERIC, 31, 0, 0), 378 GATE(hsi2c3, "hsi2c3", "aclk66", GATE_IP_PERIC, 31, 0, 0),
379 GATE(chipid, "chipid", "aclk66", GATE_IP_PERIS, 0, 0, 0), 379 GATE(chipid, "chipid", "aclk66", GATE_IP_PERIS, 0, 0, 0),
380 GATE(sysreg, "sysreg", "aclk66", GATE_IP_PERIS, 1, 0, 0), 380 GATE(sysreg, "sysreg", "aclk66", GATE_IP_PERIS, 1, 0, 0),
381 GATE(pmu, "pmu", "aclk66", GATE_IP_PERIS, 2, 0, 0), 381 GATE(pmu, "pmu", "aclk66", GATE_IP_PERIS, 2, CLK_IGNORE_UNUSED, 0),
382 GATE(tzpc0, "tzpc0", "aclk66", GATE_IP_PERIS, 6, 0, 0), 382 GATE(tzpc0, "tzpc0", "aclk66", GATE_IP_PERIS, 6, 0, 0),
383 GATE(tzpc1, "tzpc1", "aclk66", GATE_IP_PERIS, 7, 0, 0), 383 GATE(tzpc1, "tzpc1", "aclk66", GATE_IP_PERIS, 7, 0, 0),
384 GATE(tzpc2, "tzpc2", "aclk66", GATE_IP_PERIS, 8, 0, 0), 384 GATE(tzpc2, "tzpc2", "aclk66", GATE_IP_PERIS, 8, 0, 0),
diff --git a/drivers/clk/samsung/clk-pll.c b/drivers/clk/samsung/clk-pll.c
index 89135f6be116..362f12dcd944 100644
--- a/drivers/clk/samsung/clk-pll.c
+++ b/drivers/clk/samsung/clk-pll.c
@@ -111,7 +111,8 @@ static unsigned long samsung_pll36xx_recalc_rate(struct clk_hw *hw,
111 unsigned long parent_rate) 111 unsigned long parent_rate)
112{ 112{
113 struct samsung_clk_pll36xx *pll = to_clk_pll36xx(hw); 113 struct samsung_clk_pll36xx *pll = to_clk_pll36xx(hw);
114 u32 mdiv, pdiv, sdiv, kdiv, pll_con0, pll_con1; 114 u32 mdiv, pdiv, sdiv, pll_con0, pll_con1;
115 s16 kdiv;
115 u64 fvco = parent_rate; 116 u64 fvco = parent_rate;
116 117
117 pll_con0 = __raw_readl(pll->con_reg); 118 pll_con0 = __raw_readl(pll->con_reg);
@@ -119,7 +120,7 @@ static unsigned long samsung_pll36xx_recalc_rate(struct clk_hw *hw,
119 mdiv = (pll_con0 >> PLL36XX_MDIV_SHIFT) & PLL36XX_MDIV_MASK; 120 mdiv = (pll_con0 >> PLL36XX_MDIV_SHIFT) & PLL36XX_MDIV_MASK;
120 pdiv = (pll_con0 >> PLL36XX_PDIV_SHIFT) & PLL36XX_PDIV_MASK; 121 pdiv = (pll_con0 >> PLL36XX_PDIV_SHIFT) & PLL36XX_PDIV_MASK;
121 sdiv = (pll_con0 >> PLL36XX_SDIV_SHIFT) & PLL36XX_SDIV_MASK; 122 sdiv = (pll_con0 >> PLL36XX_SDIV_SHIFT) & PLL36XX_SDIV_MASK;
122 kdiv = pll_con1 & PLL36XX_KDIV_MASK; 123 kdiv = (s16)(pll_con1 & PLL36XX_KDIV_MASK);
123 124
124 fvco *= (mdiv << 16) + kdiv; 125 fvco *= (mdiv << 16) + kdiv;
125 do_div(fvco, (pdiv << sdiv)); 126 do_div(fvco, (pdiv << sdiv));
diff --git a/drivers/clk/spear/spear3xx_clock.c b/drivers/clk/spear/spear3xx_clock.c
index f9ec43fd1320..080c3c5e33f6 100644
--- a/drivers/clk/spear/spear3xx_clock.c
+++ b/drivers/clk/spear/spear3xx_clock.c
@@ -369,7 +369,7 @@ static void __init spear320_clk_init(void __iomem *soc_config_base)
369 clk_register_clkdev(clk, NULL, "60100000.serial"); 369 clk_register_clkdev(clk, NULL, "60100000.serial");
370} 370}
371#else 371#else
372static inline void spear320_clk_init(void) { } 372static inline void spear320_clk_init(void __iomem *soc_config_base) { }
373#endif 373#endif
374 374
375void __init spear3xx_clk_init(void __iomem *misc_base, void __iomem *soc_config_base) 375void __init spear3xx_clk_init(void __iomem *misc_base, void __iomem *soc_config_base)
diff --git a/drivers/clk/tegra/clk-tegra30.c b/drivers/clk/tegra/clk-tegra30.c
index c6921f538e28..ba99e3844106 100644
--- a/drivers/clk/tegra/clk-tegra30.c
+++ b/drivers/clk/tegra/clk-tegra30.c
@@ -1598,6 +1598,12 @@ static void __init tegra30_periph_clk_init(void)
1598 clk_register_clkdev(clk, "afi", "tegra-pcie"); 1598 clk_register_clkdev(clk, "afi", "tegra-pcie");
1599 clks[afi] = clk; 1599 clks[afi] = clk;
1600 1600
1601 /* pciex */
1602 clk = tegra_clk_register_periph_gate("pciex", "pll_e", 0, clk_base, 0,
1603 74, &periph_u_regs, periph_clk_enb_refcnt);
1604 clk_register_clkdev(clk, "pciex", "tegra-pcie");
1605 clks[pciex] = clk;
1606
1601 /* kfuse */ 1607 /* kfuse */
1602 clk = tegra_clk_register_periph_gate("kfuse", "clk_m", 1608 clk = tegra_clk_register_periph_gate("kfuse", "clk_m",
1603 TEGRA_PERIPH_ON_APB, 1609 TEGRA_PERIPH_ON_APB,
@@ -1716,11 +1722,6 @@ static void __init tegra30_fixed_clk_init(void)
1716 1, 0, &cml_lock); 1722 1, 0, &cml_lock);
1717 clk_register_clkdev(clk, "cml1", NULL); 1723 clk_register_clkdev(clk, "cml1", NULL);
1718 clks[cml1] = clk; 1724 clks[cml1] = clk;
1719
1720 /* pciex */
1721 clk = clk_register_fixed_rate(NULL, "pciex", "pll_e", 0, 100000000);
1722 clk_register_clkdev(clk, "pciex", NULL);
1723 clks[pciex] = clk;
1724} 1725}
1725 1726
1726static void __init tegra30_osc_clk_init(void) 1727static void __init tegra30_osc_clk_init(void)
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index dc3ae5c56f56..d39a5cede0b0 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -264,9 +264,12 @@ static struct mt_class mt_classes[] = {
264static void mt_free_input_name(struct hid_input *hi) 264static void mt_free_input_name(struct hid_input *hi)
265{ 265{
266 struct hid_device *hdev = hi->report->device; 266 struct hid_device *hdev = hi->report->device;
267 const char *name = hi->input->name;
267 268
268 if (hi->input->name != hdev->name) 269 if (name != hdev->name) {
269 kfree(hi->input->name); 270 hi->input->name = hdev->name;
271 kfree(name);
272 }
270} 273}
271 274
272static ssize_t mt_show_quirks(struct device *dev, 275static ssize_t mt_show_quirks(struct device *dev,
@@ -1040,11 +1043,11 @@ static void mt_remove(struct hid_device *hdev)
1040 struct hid_input *hi; 1043 struct hid_input *hi;
1041 1044
1042 sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group); 1045 sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group);
1043 hid_hw_stop(hdev);
1044
1045 list_for_each_entry(hi, &hdev->inputs, list) 1046 list_for_each_entry(hi, &hdev->inputs, list)
1046 mt_free_input_name(hi); 1047 mt_free_input_name(hi);
1047 1048
1049 hid_hw_stop(hdev);
1050
1048 kfree(td); 1051 kfree(td);
1049 hid_set_drvdata(hdev, NULL); 1052 hid_set_drvdata(hdev, NULL);
1050} 1053}
diff --git a/drivers/md/bcache/Kconfig b/drivers/md/bcache/Kconfig
index 05c220d05e23..f950c9d29f3e 100644
--- a/drivers/md/bcache/Kconfig
+++ b/drivers/md/bcache/Kconfig
@@ -1,7 +1,6 @@
1 1
2config BCACHE 2config BCACHE
3 tristate "Block device as cache" 3 tristate "Block device as cache"
4 select CLOSURES
5 ---help--- 4 ---help---
6 Allows a block device to be used as cache for other devices; uses 5 Allows a block device to be used as cache for other devices; uses
7 a btree for indexing and the layout is optimized for SSDs. 6 a btree for indexing and the layout is optimized for SSDs.
diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
index 340146d7c17f..d3e15b42a4ab 100644
--- a/drivers/md/bcache/bcache.h
+++ b/drivers/md/bcache/bcache.h
@@ -1241,7 +1241,7 @@ void bch_cache_set_stop(struct cache_set *);
1241struct cache_set *bch_cache_set_alloc(struct cache_sb *); 1241struct cache_set *bch_cache_set_alloc(struct cache_sb *);
1242void bch_btree_cache_free(struct cache_set *); 1242void bch_btree_cache_free(struct cache_set *);
1243int bch_btree_cache_alloc(struct cache_set *); 1243int bch_btree_cache_alloc(struct cache_set *);
1244void bch_writeback_init_cached_dev(struct cached_dev *); 1244void bch_cached_dev_writeback_init(struct cached_dev *);
1245void bch_moving_init_cache_set(struct cache_set *); 1245void bch_moving_init_cache_set(struct cache_set *);
1246 1246
1247void bch_cache_allocator_exit(struct cache *ca); 1247void bch_cache_allocator_exit(struct cache *ca);
diff --git a/drivers/md/bcache/stats.c b/drivers/md/bcache/stats.c
index 64e679449c2a..b8730e714d69 100644
--- a/drivers/md/bcache/stats.c
+++ b/drivers/md/bcache/stats.c
@@ -93,24 +93,6 @@ static struct attribute *bch_stats_files[] = {
93}; 93};
94static KTYPE(bch_stats); 94static KTYPE(bch_stats);
95 95
96static void scale_accounting(unsigned long data);
97
98void bch_cache_accounting_init(struct cache_accounting *acc,
99 struct closure *parent)
100{
101 kobject_init(&acc->total.kobj, &bch_stats_ktype);
102 kobject_init(&acc->five_minute.kobj, &bch_stats_ktype);
103 kobject_init(&acc->hour.kobj, &bch_stats_ktype);
104 kobject_init(&acc->day.kobj, &bch_stats_ktype);
105
106 closure_init(&acc->cl, parent);
107 init_timer(&acc->timer);
108 acc->timer.expires = jiffies + accounting_delay;
109 acc->timer.data = (unsigned long) acc;
110 acc->timer.function = scale_accounting;
111 add_timer(&acc->timer);
112}
113
114int bch_cache_accounting_add_kobjs(struct cache_accounting *acc, 96int bch_cache_accounting_add_kobjs(struct cache_accounting *acc,
115 struct kobject *parent) 97 struct kobject *parent)
116{ 98{
@@ -244,3 +226,19 @@ void bch_mark_sectors_bypassed(struct search *s, int sectors)
244 atomic_add(sectors, &dc->accounting.collector.sectors_bypassed); 226 atomic_add(sectors, &dc->accounting.collector.sectors_bypassed);
245 atomic_add(sectors, &s->op.c->accounting.collector.sectors_bypassed); 227 atomic_add(sectors, &s->op.c->accounting.collector.sectors_bypassed);
246} 228}
229
230void bch_cache_accounting_init(struct cache_accounting *acc,
231 struct closure *parent)
232{
233 kobject_init(&acc->total.kobj, &bch_stats_ktype);
234 kobject_init(&acc->five_minute.kobj, &bch_stats_ktype);
235 kobject_init(&acc->hour.kobj, &bch_stats_ktype);
236 kobject_init(&acc->day.kobj, &bch_stats_ktype);
237
238 closure_init(&acc->cl, parent);
239 init_timer(&acc->timer);
240 acc->timer.expires = jiffies + accounting_delay;
241 acc->timer.data = (unsigned long) acc;
242 acc->timer.function = scale_accounting;
243 add_timer(&acc->timer);
244}
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index c8046bc4aa57..f88e2b653a3f 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -634,11 +634,10 @@ static int open_dev(struct block_device *b, fmode_t mode)
634 return 0; 634 return 0;
635} 635}
636 636
637static int release_dev(struct gendisk *b, fmode_t mode) 637static void release_dev(struct gendisk *b, fmode_t mode)
638{ 638{
639 struct bcache_device *d = b->private_data; 639 struct bcache_device *d = b->private_data;
640 closure_put(&d->cl); 640 closure_put(&d->cl);
641 return 0;
642} 641}
643 642
644static int ioctl_dev(struct block_device *b, fmode_t mode, 643static int ioctl_dev(struct block_device *b, fmode_t mode,
@@ -732,8 +731,7 @@ static void bcache_device_free(struct bcache_device *d)
732 731
733 if (d->c) 732 if (d->c)
734 bcache_device_detach(d); 733 bcache_device_detach(d);
735 734 if (d->disk && d->disk->flags & GENHD_FL_UP)
736 if (d->disk)
737 del_gendisk(d->disk); 735 del_gendisk(d->disk);
738 if (d->disk && d->disk->queue) 736 if (d->disk && d->disk->queue)
739 blk_cleanup_queue(d->disk->queue); 737 blk_cleanup_queue(d->disk->queue);
@@ -756,12 +754,9 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size)
756 if (!(d->bio_split = bioset_create(4, offsetof(struct bbio, bio))) || 754 if (!(d->bio_split = bioset_create(4, offsetof(struct bbio, bio))) ||
757 !(d->unaligned_bvec = mempool_create_kmalloc_pool(1, 755 !(d->unaligned_bvec = mempool_create_kmalloc_pool(1,
758 sizeof(struct bio_vec) * BIO_MAX_PAGES)) || 756 sizeof(struct bio_vec) * BIO_MAX_PAGES)) ||
759 bio_split_pool_init(&d->bio_split_hook)) 757 bio_split_pool_init(&d->bio_split_hook) ||
760 758 !(d->disk = alloc_disk(1)) ||
761 return -ENOMEM; 759 !(q = blk_alloc_queue(GFP_KERNEL)))
762
763 d->disk = alloc_disk(1);
764 if (!d->disk)
765 return -ENOMEM; 760 return -ENOMEM;
766 761
767 snprintf(d->disk->disk_name, DISK_NAME_LEN, "bcache%i", bcache_minor); 762 snprintf(d->disk->disk_name, DISK_NAME_LEN, "bcache%i", bcache_minor);
@@ -771,10 +766,6 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size)
771 d->disk->fops = &bcache_ops; 766 d->disk->fops = &bcache_ops;
772 d->disk->private_data = d; 767 d->disk->private_data = d;
773 768
774 q = blk_alloc_queue(GFP_KERNEL);
775 if (!q)
776 return -ENOMEM;
777
778 blk_queue_make_request(q, NULL); 769 blk_queue_make_request(q, NULL);
779 d->disk->queue = q; 770 d->disk->queue = q;
780 q->queuedata = d; 771 q->queuedata = d;
@@ -999,14 +990,17 @@ static void cached_dev_free(struct closure *cl)
999 990
1000 mutex_lock(&bch_register_lock); 991 mutex_lock(&bch_register_lock);
1001 992
1002 bd_unlink_disk_holder(dc->bdev, dc->disk.disk); 993 if (atomic_read(&dc->running))
994 bd_unlink_disk_holder(dc->bdev, dc->disk.disk);
1003 bcache_device_free(&dc->disk); 995 bcache_device_free(&dc->disk);
1004 list_del(&dc->list); 996 list_del(&dc->list);
1005 997
1006 mutex_unlock(&bch_register_lock); 998 mutex_unlock(&bch_register_lock);
1007 999
1008 if (!IS_ERR_OR_NULL(dc->bdev)) { 1000 if (!IS_ERR_OR_NULL(dc->bdev)) {
1009 blk_sync_queue(bdev_get_queue(dc->bdev)); 1001 if (dc->bdev->bd_disk)
1002 blk_sync_queue(bdev_get_queue(dc->bdev));
1003
1010 blkdev_put(dc->bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL); 1004 blkdev_put(dc->bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL);
1011 } 1005 }
1012 1006
@@ -1028,73 +1022,67 @@ static void cached_dev_flush(struct closure *cl)
1028 1022
1029static int cached_dev_init(struct cached_dev *dc, unsigned block_size) 1023static int cached_dev_init(struct cached_dev *dc, unsigned block_size)
1030{ 1024{
1031 int err; 1025 int ret;
1032 struct io *io; 1026 struct io *io;
1033 1027 struct request_queue *q = bdev_get_queue(dc->bdev);
1034 closure_init(&dc->disk.cl, NULL);
1035 set_closure_fn(&dc->disk.cl, cached_dev_flush, system_wq);
1036 1028
1037 __module_get(THIS_MODULE); 1029 __module_get(THIS_MODULE);
1038 INIT_LIST_HEAD(&dc->list); 1030 INIT_LIST_HEAD(&dc->list);
1031 closure_init(&dc->disk.cl, NULL);
1032 set_closure_fn(&dc->disk.cl, cached_dev_flush, system_wq);
1039 kobject_init(&dc->disk.kobj, &bch_cached_dev_ktype); 1033 kobject_init(&dc->disk.kobj, &bch_cached_dev_ktype);
1040
1041 bch_cache_accounting_init(&dc->accounting, &dc->disk.cl);
1042
1043 err = bcache_device_init(&dc->disk, block_size);
1044 if (err)
1045 goto err;
1046
1047 spin_lock_init(&dc->io_lock);
1048 closure_init_unlocked(&dc->sb_write);
1049 INIT_WORK(&dc->detach, cached_dev_detach_finish); 1034 INIT_WORK(&dc->detach, cached_dev_detach_finish);
1035 closure_init_unlocked(&dc->sb_write);
1036 INIT_LIST_HEAD(&dc->io_lru);
1037 spin_lock_init(&dc->io_lock);
1038 bch_cache_accounting_init(&dc->accounting, &dc->disk.cl);
1050 1039
1051 dc->sequential_merge = true; 1040 dc->sequential_merge = true;
1052 dc->sequential_cutoff = 4 << 20; 1041 dc->sequential_cutoff = 4 << 20;
1053 1042
1054 INIT_LIST_HEAD(&dc->io_lru);
1055 dc->sb_bio.bi_max_vecs = 1;
1056 dc->sb_bio.bi_io_vec = dc->sb_bio.bi_inline_vecs;
1057
1058 for (io = dc->io; io < dc->io + RECENT_IO; io++) { 1043 for (io = dc->io; io < dc->io + RECENT_IO; io++) {
1059 list_add(&io->lru, &dc->io_lru); 1044 list_add(&io->lru, &dc->io_lru);
1060 hlist_add_head(&io->hash, dc->io_hash + RECENT_IO); 1045 hlist_add_head(&io->hash, dc->io_hash + RECENT_IO);
1061 } 1046 }
1062 1047
1063 bch_writeback_init_cached_dev(dc); 1048 ret = bcache_device_init(&dc->disk, block_size);
1049 if (ret)
1050 return ret;
1051
1052 set_capacity(dc->disk.disk,
1053 dc->bdev->bd_part->nr_sects - dc->sb.data_offset);
1054
1055 dc->disk.disk->queue->backing_dev_info.ra_pages =
1056 max(dc->disk.disk->queue->backing_dev_info.ra_pages,
1057 q->backing_dev_info.ra_pages);
1058
1059 bch_cached_dev_request_init(dc);
1060 bch_cached_dev_writeback_init(dc);
1064 return 0; 1061 return 0;
1065err:
1066 bcache_device_stop(&dc->disk);
1067 return err;
1068} 1062}
1069 1063
1070/* Cached device - bcache superblock */ 1064/* Cached device - bcache superblock */
1071 1065
1072static const char *register_bdev(struct cache_sb *sb, struct page *sb_page, 1066static void register_bdev(struct cache_sb *sb, struct page *sb_page,
1073 struct block_device *bdev, 1067 struct block_device *bdev,
1074 struct cached_dev *dc) 1068 struct cached_dev *dc)
1075{ 1069{
1076 char name[BDEVNAME_SIZE]; 1070 char name[BDEVNAME_SIZE];
1077 const char *err = "cannot allocate memory"; 1071 const char *err = "cannot allocate memory";
1078 struct gendisk *g;
1079 struct cache_set *c; 1072 struct cache_set *c;
1080 1073
1081 if (!dc || cached_dev_init(dc, sb->block_size << 9) != 0)
1082 return err;
1083
1084 memcpy(&dc->sb, sb, sizeof(struct cache_sb)); 1074 memcpy(&dc->sb, sb, sizeof(struct cache_sb));
1085 dc->sb_bio.bi_io_vec[0].bv_page = sb_page;
1086 dc->bdev = bdev; 1075 dc->bdev = bdev;
1087 dc->bdev->bd_holder = dc; 1076 dc->bdev->bd_holder = dc;
1088 1077
1089 g = dc->disk.disk; 1078 bio_init(&dc->sb_bio);
1090 1079 dc->sb_bio.bi_max_vecs = 1;
1091 set_capacity(g, dc->bdev->bd_part->nr_sects - dc->sb.data_offset); 1080 dc->sb_bio.bi_io_vec = dc->sb_bio.bi_inline_vecs;
1092 1081 dc->sb_bio.bi_io_vec[0].bv_page = sb_page;
1093 g->queue->backing_dev_info.ra_pages = 1082 get_page(sb_page);
1094 max(g->queue->backing_dev_info.ra_pages,
1095 bdev->bd_queue->backing_dev_info.ra_pages);
1096 1083
1097 bch_cached_dev_request_init(dc); 1084 if (cached_dev_init(dc, sb->block_size << 9))
1085 goto err;
1098 1086
1099 err = "error creating kobject"; 1087 err = "error creating kobject";
1100 if (kobject_add(&dc->disk.kobj, &part_to_dev(bdev->bd_part)->kobj, 1088 if (kobject_add(&dc->disk.kobj, &part_to_dev(bdev->bd_part)->kobj,
@@ -1103,6 +1091,8 @@ static const char *register_bdev(struct cache_sb *sb, struct page *sb_page,
1103 if (bch_cache_accounting_add_kobjs(&dc->accounting, &dc->disk.kobj)) 1091 if (bch_cache_accounting_add_kobjs(&dc->accounting, &dc->disk.kobj))
1104 goto err; 1092 goto err;
1105 1093
1094 pr_info("registered backing device %s", bdevname(bdev, name));
1095
1106 list_add(&dc->list, &uncached_devices); 1096 list_add(&dc->list, &uncached_devices);
1107 list_for_each_entry(c, &bch_cache_sets, list) 1097 list_for_each_entry(c, &bch_cache_sets, list)
1108 bch_cached_dev_attach(dc, c); 1098 bch_cached_dev_attach(dc, c);
@@ -1111,15 +1101,10 @@ static const char *register_bdev(struct cache_sb *sb, struct page *sb_page,
1111 BDEV_STATE(&dc->sb) == BDEV_STATE_STALE) 1101 BDEV_STATE(&dc->sb) == BDEV_STATE_STALE)
1112 bch_cached_dev_run(dc); 1102 bch_cached_dev_run(dc);
1113 1103
1114 return NULL; 1104 return;
1115err: 1105err:
1116 kobject_put(&dc->disk.kobj);
1117 pr_notice("error opening %s: %s", bdevname(bdev, name), err); 1106 pr_notice("error opening %s: %s", bdevname(bdev, name), err);
1118 /* 1107 bcache_device_stop(&dc->disk);
1119 * Return NULL instead of an error because kobject_put() cleans
1120 * everything up
1121 */
1122 return NULL;
1123} 1108}
1124 1109
1125/* Flash only volumes */ 1110/* Flash only volumes */
@@ -1717,20 +1702,11 @@ static int cache_alloc(struct cache_sb *sb, struct cache *ca)
1717 size_t free; 1702 size_t free;
1718 struct bucket *b; 1703 struct bucket *b;
1719 1704
1720 if (!ca)
1721 return -ENOMEM;
1722
1723 __module_get(THIS_MODULE); 1705 __module_get(THIS_MODULE);
1724 kobject_init(&ca->kobj, &bch_cache_ktype); 1706 kobject_init(&ca->kobj, &bch_cache_ktype);
1725 1707
1726 memcpy(&ca->sb, sb, sizeof(struct cache_sb));
1727
1728 INIT_LIST_HEAD(&ca->discards); 1708 INIT_LIST_HEAD(&ca->discards);
1729 1709
1730 bio_init(&ca->sb_bio);
1731 ca->sb_bio.bi_max_vecs = 1;
1732 ca->sb_bio.bi_io_vec = ca->sb_bio.bi_inline_vecs;
1733
1734 bio_init(&ca->journal.bio); 1710 bio_init(&ca->journal.bio);
1735 ca->journal.bio.bi_max_vecs = 8; 1711 ca->journal.bio.bi_max_vecs = 8;
1736 ca->journal.bio.bi_io_vec = ca->journal.bio.bi_inline_vecs; 1712 ca->journal.bio.bi_io_vec = ca->journal.bio.bi_inline_vecs;
@@ -1742,18 +1718,17 @@ static int cache_alloc(struct cache_sb *sb, struct cache *ca)
1742 !init_fifo(&ca->free_inc, free << 2, GFP_KERNEL) || 1718 !init_fifo(&ca->free_inc, free << 2, GFP_KERNEL) ||
1743 !init_fifo(&ca->unused, free << 2, GFP_KERNEL) || 1719 !init_fifo(&ca->unused, free << 2, GFP_KERNEL) ||
1744 !init_heap(&ca->heap, free << 3, GFP_KERNEL) || 1720 !init_heap(&ca->heap, free << 3, GFP_KERNEL) ||
1745 !(ca->buckets = vmalloc(sizeof(struct bucket) * 1721 !(ca->buckets = vzalloc(sizeof(struct bucket) *
1746 ca->sb.nbuckets)) || 1722 ca->sb.nbuckets)) ||
1747 !(ca->prio_buckets = kzalloc(sizeof(uint64_t) * prio_buckets(ca) * 1723 !(ca->prio_buckets = kzalloc(sizeof(uint64_t) * prio_buckets(ca) *
1748 2, GFP_KERNEL)) || 1724 2, GFP_KERNEL)) ||
1749 !(ca->disk_buckets = alloc_bucket_pages(GFP_KERNEL, ca)) || 1725 !(ca->disk_buckets = alloc_bucket_pages(GFP_KERNEL, ca)) ||
1750 !(ca->alloc_workqueue = alloc_workqueue("bch_allocator", 0, 1)) || 1726 !(ca->alloc_workqueue = alloc_workqueue("bch_allocator", 0, 1)) ||
1751 bio_split_pool_init(&ca->bio_split_hook)) 1727 bio_split_pool_init(&ca->bio_split_hook))
1752 goto err; 1728 return -ENOMEM;
1753 1729
1754 ca->prio_last_buckets = ca->prio_buckets + prio_buckets(ca); 1730 ca->prio_last_buckets = ca->prio_buckets + prio_buckets(ca);
1755 1731
1756 memset(ca->buckets, 0, ca->sb.nbuckets * sizeof(struct bucket));
1757 for_each_bucket(b, ca) 1732 for_each_bucket(b, ca)
1758 atomic_set(&b->pin, 0); 1733 atomic_set(&b->pin, 0);
1759 1734
@@ -1766,22 +1741,28 @@ err:
1766 return -ENOMEM; 1741 return -ENOMEM;
1767} 1742}
1768 1743
1769static const char *register_cache(struct cache_sb *sb, struct page *sb_page, 1744static void register_cache(struct cache_sb *sb, struct page *sb_page,
1770 struct block_device *bdev, struct cache *ca) 1745 struct block_device *bdev, struct cache *ca)
1771{ 1746{
1772 char name[BDEVNAME_SIZE]; 1747 char name[BDEVNAME_SIZE];
1773 const char *err = "cannot allocate memory"; 1748 const char *err = "cannot allocate memory";
1774 1749
1775 if (cache_alloc(sb, ca) != 0) 1750 memcpy(&ca->sb, sb, sizeof(struct cache_sb));
1776 return err;
1777
1778 ca->sb_bio.bi_io_vec[0].bv_page = sb_page;
1779 ca->bdev = bdev; 1751 ca->bdev = bdev;
1780 ca->bdev->bd_holder = ca; 1752 ca->bdev->bd_holder = ca;
1781 1753
1754 bio_init(&ca->sb_bio);
1755 ca->sb_bio.bi_max_vecs = 1;
1756 ca->sb_bio.bi_io_vec = ca->sb_bio.bi_inline_vecs;
1757 ca->sb_bio.bi_io_vec[0].bv_page = sb_page;
1758 get_page(sb_page);
1759
1782 if (blk_queue_discard(bdev_get_queue(ca->bdev))) 1760 if (blk_queue_discard(bdev_get_queue(ca->bdev)))
1783 ca->discard = CACHE_DISCARD(&ca->sb); 1761 ca->discard = CACHE_DISCARD(&ca->sb);
1784 1762
1763 if (cache_alloc(sb, ca) != 0)
1764 goto err;
1765
1785 err = "error creating kobject"; 1766 err = "error creating kobject";
1786 if (kobject_add(&ca->kobj, &part_to_dev(bdev->bd_part)->kobj, "bcache")) 1767 if (kobject_add(&ca->kobj, &part_to_dev(bdev->bd_part)->kobj, "bcache"))
1787 goto err; 1768 goto err;
@@ -1791,15 +1772,10 @@ static const char *register_cache(struct cache_sb *sb, struct page *sb_page,
1791 goto err; 1772 goto err;
1792 1773
1793 pr_info("registered cache device %s", bdevname(bdev, name)); 1774 pr_info("registered cache device %s", bdevname(bdev, name));
1794 1775 return;
1795 return NULL;
1796err: 1776err:
1777 pr_notice("error opening %s: %s", bdevname(bdev, name), err);
1797 kobject_put(&ca->kobj); 1778 kobject_put(&ca->kobj);
1798 pr_info("error opening %s: %s", bdevname(bdev, name), err);
1799 /* Return NULL instead of an error because kobject_put() cleans
1800 * everything up
1801 */
1802 return NULL;
1803} 1779}
1804 1780
1805/* Global interfaces/init */ 1781/* Global interfaces/init */
@@ -1833,12 +1809,15 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
1833 bdev = blkdev_get_by_path(strim(path), 1809 bdev = blkdev_get_by_path(strim(path),
1834 FMODE_READ|FMODE_WRITE|FMODE_EXCL, 1810 FMODE_READ|FMODE_WRITE|FMODE_EXCL,
1835 sb); 1811 sb);
1836 if (bdev == ERR_PTR(-EBUSY)) 1812 if (IS_ERR(bdev)) {
1837 err = "device busy"; 1813 if (bdev == ERR_PTR(-EBUSY))
1838 1814 err = "device busy";
1839 if (IS_ERR(bdev) ||
1840 set_blocksize(bdev, 4096))
1841 goto err; 1815 goto err;
1816 }
1817
1818 err = "failed to set blocksize";
1819 if (set_blocksize(bdev, 4096))
1820 goto err_close;
1842 1821
1843 err = read_super(sb, bdev, &sb_page); 1822 err = read_super(sb, bdev, &sb_page);
1844 if (err) 1823 if (err)
@@ -1846,33 +1825,33 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
1846 1825
1847 if (SB_IS_BDEV(sb)) { 1826 if (SB_IS_BDEV(sb)) {
1848 struct cached_dev *dc = kzalloc(sizeof(*dc), GFP_KERNEL); 1827 struct cached_dev *dc = kzalloc(sizeof(*dc), GFP_KERNEL);
1828 if (!dc)
1829 goto err_close;
1849 1830
1850 err = register_bdev(sb, sb_page, bdev, dc); 1831 register_bdev(sb, sb_page, bdev, dc);
1851 } else { 1832 } else {
1852 struct cache *ca = kzalloc(sizeof(*ca), GFP_KERNEL); 1833 struct cache *ca = kzalloc(sizeof(*ca), GFP_KERNEL);
1834 if (!ca)
1835 goto err_close;
1853 1836
1854 err = register_cache(sb, sb_page, bdev, ca); 1837 register_cache(sb, sb_page, bdev, ca);
1855 } 1838 }
1856 1839out:
1857 if (err) { 1840 if (sb_page)
1858 /* register_(bdev|cache) will only return an error if they
1859 * didn't get far enough to create the kobject - if they did,
1860 * the kobject destructor will do this cleanup.
1861 */
1862 put_page(sb_page); 1841 put_page(sb_page);
1863err_close:
1864 blkdev_put(bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL);
1865err:
1866 if (attr != &ksysfs_register_quiet)
1867 pr_info("error opening %s: %s", path, err);
1868 ret = -EINVAL;
1869 }
1870
1871 kfree(sb); 1842 kfree(sb);
1872 kfree(path); 1843 kfree(path);
1873 mutex_unlock(&bch_register_lock); 1844 mutex_unlock(&bch_register_lock);
1874 module_put(THIS_MODULE); 1845 module_put(THIS_MODULE);
1875 return ret; 1846 return ret;
1847
1848err_close:
1849 blkdev_put(bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL);
1850err:
1851 if (attr != &ksysfs_register_quiet)
1852 pr_info("error opening %s: %s", path, err);
1853 ret = -EINVAL;
1854 goto out;
1876} 1855}
1877 1856
1878static int bcache_reboot(struct notifier_block *n, unsigned long code, void *x) 1857static int bcache_reboot(struct notifier_block *n, unsigned long code, void *x)
diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c
index 93e7e31a4bd3..2714ed3991d1 100644
--- a/drivers/md/bcache/writeback.c
+++ b/drivers/md/bcache/writeback.c
@@ -375,7 +375,7 @@ err:
375 refill_dirty(cl); 375 refill_dirty(cl);
376} 376}
377 377
378void bch_writeback_init_cached_dev(struct cached_dev *dc) 378void bch_cached_dev_writeback_init(struct cached_dev *dc)
379{ 379{
380 closure_init_unlocked(&dc->writeback); 380 closure_init_unlocked(&dc->writeback);
381 init_rwsem(&dc->writeback_lock); 381 init_rwsem(&dc->writeback_lock);
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 681d1099a2d5..9b82377a833b 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -5268,8 +5268,8 @@ static void md_clean(struct mddev *mddev)
5268 5268
5269static void __md_stop_writes(struct mddev *mddev) 5269static void __md_stop_writes(struct mddev *mddev)
5270{ 5270{
5271 set_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
5271 if (mddev->sync_thread) { 5272 if (mddev->sync_thread) {
5272 set_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
5273 set_bit(MD_RECOVERY_INTR, &mddev->recovery); 5273 set_bit(MD_RECOVERY_INTR, &mddev->recovery);
5274 md_reap_sync_thread(mddev); 5274 md_reap_sync_thread(mddev);
5275 } 5275 }
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 55951182af73..6e17f8181c4b 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -417,7 +417,17 @@ static void raid1_end_write_request(struct bio *bio, int error)
417 417
418 r1_bio->bios[mirror] = NULL; 418 r1_bio->bios[mirror] = NULL;
419 to_put = bio; 419 to_put = bio;
420 set_bit(R1BIO_Uptodate, &r1_bio->state); 420 /*
421 * Do not set R1BIO_Uptodate if the current device is
422 * rebuilding or Faulty. This is because we cannot use
423 * such device for properly reading the data back (we could
424 * potentially use it, if the current write would have felt
425 * before rdev->recovery_offset, but for simplicity we don't
426 * check this here.
427 */
428 if (test_bit(In_sync, &conf->mirrors[mirror].rdev->flags) &&
429 !test_bit(Faulty, &conf->mirrors[mirror].rdev->flags))
430 set_bit(R1BIO_Uptodate, &r1_bio->state);
421 431
422 /* Maybe we can clear some bad blocks. */ 432 /* Maybe we can clear some bad blocks. */
423 if (is_badblock(conf->mirrors[mirror].rdev, 433 if (is_badblock(conf->mirrors[mirror].rdev,
@@ -870,17 +880,17 @@ static void allow_barrier(struct r1conf *conf)
870 wake_up(&conf->wait_barrier); 880 wake_up(&conf->wait_barrier);
871} 881}
872 882
873static void freeze_array(struct r1conf *conf) 883static void freeze_array(struct r1conf *conf, int extra)
874{ 884{
875 /* stop syncio and normal IO and wait for everything to 885 /* stop syncio and normal IO and wait for everything to
876 * go quite. 886 * go quite.
877 * We increment barrier and nr_waiting, and then 887 * We increment barrier and nr_waiting, and then
878 * wait until nr_pending match nr_queued+1 888 * wait until nr_pending match nr_queued+extra
879 * This is called in the context of one normal IO request 889 * This is called in the context of one normal IO request
880 * that has failed. Thus any sync request that might be pending 890 * that has failed. Thus any sync request that might be pending
881 * will be blocked by nr_pending, and we need to wait for 891 * will be blocked by nr_pending, and we need to wait for
882 * pending IO requests to complete or be queued for re-try. 892 * pending IO requests to complete or be queued for re-try.
883 * Thus the number queued (nr_queued) plus this request (1) 893 * Thus the number queued (nr_queued) plus this request (extra)
884 * must match the number of pending IOs (nr_pending) before 894 * must match the number of pending IOs (nr_pending) before
885 * we continue. 895 * we continue.
886 */ 896 */
@@ -888,7 +898,7 @@ static void freeze_array(struct r1conf *conf)
888 conf->barrier++; 898 conf->barrier++;
889 conf->nr_waiting++; 899 conf->nr_waiting++;
890 wait_event_lock_irq_cmd(conf->wait_barrier, 900 wait_event_lock_irq_cmd(conf->wait_barrier,
891 conf->nr_pending == conf->nr_queued+1, 901 conf->nr_pending == conf->nr_queued+extra,
892 conf->resync_lock, 902 conf->resync_lock,
893 flush_pending_writes(conf)); 903 flush_pending_writes(conf));
894 spin_unlock_irq(&conf->resync_lock); 904 spin_unlock_irq(&conf->resync_lock);
@@ -1544,8 +1554,8 @@ static int raid1_add_disk(struct mddev *mddev, struct md_rdev *rdev)
1544 * we wait for all outstanding requests to complete. 1554 * we wait for all outstanding requests to complete.
1545 */ 1555 */
1546 synchronize_sched(); 1556 synchronize_sched();
1547 raise_barrier(conf); 1557 freeze_array(conf, 0);
1548 lower_barrier(conf); 1558 unfreeze_array(conf);
1549 clear_bit(Unmerged, &rdev->flags); 1559 clear_bit(Unmerged, &rdev->flags);
1550 } 1560 }
1551 md_integrity_add_rdev(rdev, mddev); 1561 md_integrity_add_rdev(rdev, mddev);
@@ -1595,11 +1605,11 @@ static int raid1_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
1595 */ 1605 */
1596 struct md_rdev *repl = 1606 struct md_rdev *repl =
1597 conf->mirrors[conf->raid_disks + number].rdev; 1607 conf->mirrors[conf->raid_disks + number].rdev;
1598 raise_barrier(conf); 1608 freeze_array(conf, 0);
1599 clear_bit(Replacement, &repl->flags); 1609 clear_bit(Replacement, &repl->flags);
1600 p->rdev = repl; 1610 p->rdev = repl;
1601 conf->mirrors[conf->raid_disks + number].rdev = NULL; 1611 conf->mirrors[conf->raid_disks + number].rdev = NULL;
1602 lower_barrier(conf); 1612 unfreeze_array(conf);
1603 clear_bit(WantReplacement, &rdev->flags); 1613 clear_bit(WantReplacement, &rdev->flags);
1604 } else 1614 } else
1605 clear_bit(WantReplacement, &rdev->flags); 1615 clear_bit(WantReplacement, &rdev->flags);
@@ -2195,7 +2205,7 @@ static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio)
2195 * frozen 2205 * frozen
2196 */ 2206 */
2197 if (mddev->ro == 0) { 2207 if (mddev->ro == 0) {
2198 freeze_array(conf); 2208 freeze_array(conf, 1);
2199 fix_read_error(conf, r1_bio->read_disk, 2209 fix_read_error(conf, r1_bio->read_disk,
2200 r1_bio->sector, r1_bio->sectors); 2210 r1_bio->sector, r1_bio->sectors);
2201 unfreeze_array(conf); 2211 unfreeze_array(conf);
@@ -2780,8 +2790,8 @@ static int run(struct mddev *mddev)
2780 return PTR_ERR(conf); 2790 return PTR_ERR(conf);
2781 2791
2782 if (mddev->queue) 2792 if (mddev->queue)
2783 blk_queue_max_write_same_sectors(mddev->queue, 2793 blk_queue_max_write_same_sectors(mddev->queue, 0);
2784 mddev->chunk_sectors); 2794
2785 rdev_for_each(rdev, mddev) { 2795 rdev_for_each(rdev, mddev) {
2786 if (!mddev->gendisk) 2796 if (!mddev->gendisk)
2787 continue; 2797 continue;
@@ -2963,7 +2973,7 @@ static int raid1_reshape(struct mddev *mddev)
2963 return -ENOMEM; 2973 return -ENOMEM;
2964 } 2974 }
2965 2975
2966 raise_barrier(conf); 2976 freeze_array(conf, 0);
2967 2977
2968 /* ok, everything is stopped */ 2978 /* ok, everything is stopped */
2969 oldpool = conf->r1bio_pool; 2979 oldpool = conf->r1bio_pool;
@@ -2994,7 +3004,7 @@ static int raid1_reshape(struct mddev *mddev)
2994 conf->raid_disks = mddev->raid_disks = raid_disks; 3004 conf->raid_disks = mddev->raid_disks = raid_disks;
2995 mddev->delta_disks = 0; 3005 mddev->delta_disks = 0;
2996 3006
2997 lower_barrier(conf); 3007 unfreeze_array(conf);
2998 3008
2999 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 3009 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
3000 md_wakeup_thread(mddev->thread); 3010 md_wakeup_thread(mddev->thread);
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 59d4daa5f4c7..6ddae2501b9a 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -490,7 +490,17 @@ static void raid10_end_write_request(struct bio *bio, int error)
490 sector_t first_bad; 490 sector_t first_bad;
491 int bad_sectors; 491 int bad_sectors;
492 492
493 set_bit(R10BIO_Uptodate, &r10_bio->state); 493 /*
494 * Do not set R10BIO_Uptodate if the current device is
495 * rebuilding or Faulty. This is because we cannot use
496 * such device for properly reading the data back (we could
497 * potentially use it, if the current write would have felt
498 * before rdev->recovery_offset, but for simplicity we don't
499 * check this here.
500 */
501 if (test_bit(In_sync, &rdev->flags) &&
502 !test_bit(Faulty, &rdev->flags))
503 set_bit(R10BIO_Uptodate, &r10_bio->state);
494 504
495 /* Maybe we can clear some bad blocks. */ 505 /* Maybe we can clear some bad blocks. */
496 if (is_badblock(rdev, 506 if (is_badblock(rdev,
@@ -1055,17 +1065,17 @@ static void allow_barrier(struct r10conf *conf)
1055 wake_up(&conf->wait_barrier); 1065 wake_up(&conf->wait_barrier);
1056} 1066}
1057 1067
1058static void freeze_array(struct r10conf *conf) 1068static void freeze_array(struct r10conf *conf, int extra)
1059{ 1069{
1060 /* stop syncio and normal IO and wait for everything to 1070 /* stop syncio and normal IO and wait for everything to
1061 * go quiet. 1071 * go quiet.
1062 * We increment barrier and nr_waiting, and then 1072 * We increment barrier and nr_waiting, and then
1063 * wait until nr_pending match nr_queued+1 1073 * wait until nr_pending match nr_queued+extra
1064 * This is called in the context of one normal IO request 1074 * This is called in the context of one normal IO request
1065 * that has failed. Thus any sync request that might be pending 1075 * that has failed. Thus any sync request that might be pending
1066 * will be blocked by nr_pending, and we need to wait for 1076 * will be blocked by nr_pending, and we need to wait for
1067 * pending IO requests to complete or be queued for re-try. 1077 * pending IO requests to complete or be queued for re-try.
1068 * Thus the number queued (nr_queued) plus this request (1) 1078 * Thus the number queued (nr_queued) plus this request (extra)
1069 * must match the number of pending IOs (nr_pending) before 1079 * must match the number of pending IOs (nr_pending) before
1070 * we continue. 1080 * we continue.
1071 */ 1081 */
@@ -1073,7 +1083,7 @@ static void freeze_array(struct r10conf *conf)
1073 conf->barrier++; 1083 conf->barrier++;
1074 conf->nr_waiting++; 1084 conf->nr_waiting++;
1075 wait_event_lock_irq_cmd(conf->wait_barrier, 1085 wait_event_lock_irq_cmd(conf->wait_barrier,
1076 conf->nr_pending == conf->nr_queued+1, 1086 conf->nr_pending == conf->nr_queued+extra,
1077 conf->resync_lock, 1087 conf->resync_lock,
1078 flush_pending_writes(conf)); 1088 flush_pending_writes(conf));
1079 1089
@@ -1837,8 +1847,8 @@ static int raid10_add_disk(struct mddev *mddev, struct md_rdev *rdev)
1837 * we wait for all outstanding requests to complete. 1847 * we wait for all outstanding requests to complete.
1838 */ 1848 */
1839 synchronize_sched(); 1849 synchronize_sched();
1840 raise_barrier(conf, 0); 1850 freeze_array(conf, 0);
1841 lower_barrier(conf); 1851 unfreeze_array(conf);
1842 clear_bit(Unmerged, &rdev->flags); 1852 clear_bit(Unmerged, &rdev->flags);
1843 } 1853 }
1844 md_integrity_add_rdev(rdev, mddev); 1854 md_integrity_add_rdev(rdev, mddev);
@@ -2612,7 +2622,7 @@ static void handle_read_error(struct mddev *mddev, struct r10bio *r10_bio)
2612 r10_bio->devs[slot].bio = NULL; 2622 r10_bio->devs[slot].bio = NULL;
2613 2623
2614 if (mddev->ro == 0) { 2624 if (mddev->ro == 0) {
2615 freeze_array(conf); 2625 freeze_array(conf, 1);
2616 fix_read_error(conf, mddev, r10_bio); 2626 fix_read_error(conf, mddev, r10_bio);
2617 unfreeze_array(conf); 2627 unfreeze_array(conf);
2618 } else 2628 } else
@@ -3609,8 +3619,7 @@ static int run(struct mddev *mddev)
3609 if (mddev->queue) { 3619 if (mddev->queue) {
3610 blk_queue_max_discard_sectors(mddev->queue, 3620 blk_queue_max_discard_sectors(mddev->queue,
3611 mddev->chunk_sectors); 3621 mddev->chunk_sectors);
3612 blk_queue_max_write_same_sectors(mddev->queue, 3622 blk_queue_max_write_same_sectors(mddev->queue, 0);
3613 mddev->chunk_sectors);
3614 blk_queue_io_min(mddev->queue, chunk_size); 3623 blk_queue_io_min(mddev->queue, chunk_size);
3615 if (conf->geo.raid_disks % conf->geo.near_copies) 3624 if (conf->geo.raid_disks % conf->geo.near_copies)
3616 blk_queue_io_opt(mddev->queue, chunk_size * conf->geo.raid_disks); 3625 blk_queue_io_opt(mddev->queue, chunk_size * conf->geo.raid_disks);
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 9359828ffe26..05e4a105b9c7 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -664,6 +664,7 @@ static void ops_run_io(struct stripe_head *sh, struct stripe_head_state *s)
664 if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags)) 664 if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
665 bi->bi_rw |= REQ_FLUSH; 665 bi->bi_rw |= REQ_FLUSH;
666 666
667 bi->bi_vcnt = 1;
667 bi->bi_io_vec[0].bv_len = STRIPE_SIZE; 668 bi->bi_io_vec[0].bv_len = STRIPE_SIZE;
668 bi->bi_io_vec[0].bv_offset = 0; 669 bi->bi_io_vec[0].bv_offset = 0;
669 bi->bi_size = STRIPE_SIZE; 670 bi->bi_size = STRIPE_SIZE;
@@ -701,6 +702,7 @@ static void ops_run_io(struct stripe_head *sh, struct stripe_head_state *s)
701 else 702 else
702 rbi->bi_sector = (sh->sector 703 rbi->bi_sector = (sh->sector
703 + rrdev->data_offset); 704 + rrdev->data_offset);
705 rbi->bi_vcnt = 1;
704 rbi->bi_io_vec[0].bv_len = STRIPE_SIZE; 706 rbi->bi_io_vec[0].bv_len = STRIPE_SIZE;
705 rbi->bi_io_vec[0].bv_offset = 0; 707 rbi->bi_io_vec[0].bv_offset = 0;
706 rbi->bi_size = STRIPE_SIZE; 708 rbi->bi_size = STRIPE_SIZE;
@@ -5464,7 +5466,7 @@ static int run(struct mddev *mddev)
5464 if (mddev->major_version == 0 && 5466 if (mddev->major_version == 0 &&
5465 mddev->minor_version > 90) 5467 mddev->minor_version > 90)
5466 rdev->recovery_offset = reshape_offset; 5468 rdev->recovery_offset = reshape_offset;
5467 5469
5468 if (rdev->recovery_offset < reshape_offset) { 5470 if (rdev->recovery_offset < reshape_offset) {
5469 /* We need to check old and new layout */ 5471 /* We need to check old and new layout */
5470 if (!only_parity(rdev->raid_disk, 5472 if (!only_parity(rdev->raid_disk,
@@ -5587,6 +5589,8 @@ static int run(struct mddev *mddev)
5587 */ 5589 */
5588 mddev->queue->limits.discard_zeroes_data = 0; 5590 mddev->queue->limits.discard_zeroes_data = 0;
5589 5591
5592 blk_queue_max_write_same_sectors(mddev->queue, 0);
5593
5590 rdev_for_each(rdev, mddev) { 5594 rdev_for_each(rdev, mddev) {
5591 disk_stack_limits(mddev->gendisk, rdev->bdev, 5595 disk_stack_limits(mddev->gendisk, rdev->bdev,
5592 rdev->data_offset << 9); 5596 rdev->data_offset << 9);
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
index cb52438e53ac..9eac5310942f 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
@@ -956,7 +956,7 @@ static int s5c73m3_oif_enum_frame_interval(struct v4l2_subdev *sd,
956 956
957 if (fie->pad != OIF_SOURCE_PAD) 957 if (fie->pad != OIF_SOURCE_PAD)
958 return -EINVAL; 958 return -EINVAL;
959 if (fie->index > ARRAY_SIZE(s5c73m3_intervals)) 959 if (fie->index >= ARRAY_SIZE(s5c73m3_intervals))
960 return -EINVAL; 960 return -EINVAL;
961 961
962 mutex_lock(&state->lock); 962 mutex_lock(&state->lock);
diff --git a/drivers/media/pci/cx88/cx88-alsa.c b/drivers/media/pci/cx88/cx88-alsa.c
index 27d62623274b..aba5b1c649e6 100644
--- a/drivers/media/pci/cx88/cx88-alsa.c
+++ b/drivers/media/pci/cx88/cx88-alsa.c
@@ -615,7 +615,7 @@ static int snd_cx88_volume_put(struct snd_kcontrol *kcontrol,
615 int changed = 0; 615 int changed = 0;
616 u32 old; 616 u32 old;
617 617
618 if (core->board.audio_chip == V4L2_IDENT_WM8775) 618 if (core->sd_wm8775)
619 snd_cx88_wm8775_volume_put(kcontrol, value); 619 snd_cx88_wm8775_volume_put(kcontrol, value);
620 620
621 left = value->value.integer.value[0] & 0x3f; 621 left = value->value.integer.value[0] & 0x3f;
@@ -682,8 +682,7 @@ static int snd_cx88_switch_put(struct snd_kcontrol *kcontrol,
682 vol ^= bit; 682 vol ^= bit;
683 cx_swrite(SHADOW_AUD_VOL_CTL, AUD_VOL_CTL, vol); 683 cx_swrite(SHADOW_AUD_VOL_CTL, AUD_VOL_CTL, vol);
684 /* Pass mute onto any WM8775 */ 684 /* Pass mute onto any WM8775 */
685 if ((core->board.audio_chip == V4L2_IDENT_WM8775) && 685 if (core->sd_wm8775 && ((1<<6) == bit))
686 ((1<<6) == bit))
687 wm8775_s_ctrl(core, V4L2_CID_AUDIO_MUTE, 0 != (vol & bit)); 686 wm8775_s_ctrl(core, V4L2_CID_AUDIO_MUTE, 0 != (vol & bit));
688 ret = 1; 687 ret = 1;
689 } 688 }
@@ -903,7 +902,7 @@ static int cx88_audio_initdev(struct pci_dev *pci,
903 goto error; 902 goto error;
904 903
905 /* If there's a wm8775 then add a Line-In ALC switch */ 904 /* If there's a wm8775 then add a Line-In ALC switch */
906 if (core->board.audio_chip == V4L2_IDENT_WM8775) 905 if (core->sd_wm8775)
907 snd_ctl_add(card, snd_ctl_new1(&snd_cx88_alc_switch, chip)); 906 snd_ctl_add(card, snd_ctl_new1(&snd_cx88_alc_switch, chip));
908 907
909 strcpy (card->driver, "CX88x"); 908 strcpy (card->driver, "CX88x");
diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
index 1b00615fd395..c7a9be1065c0 100644
--- a/drivers/media/pci/cx88/cx88-video.c
+++ b/drivers/media/pci/cx88/cx88-video.c
@@ -385,8 +385,7 @@ int cx88_video_mux(struct cx88_core *core, unsigned int input)
385 /* The wm8775 module has the "2" route hardwired into 385 /* The wm8775 module has the "2" route hardwired into
386 the initialization. Some boards may use different 386 the initialization. Some boards may use different
387 routes for different inputs. HVR-1300 surely does */ 387 routes for different inputs. HVR-1300 surely does */
388 if (core->board.audio_chip && 388 if (core->sd_wm8775) {
389 core->board.audio_chip == V4L2_IDENT_WM8775) {
390 call_all(core, audio, s_routing, 389 call_all(core, audio, s_routing,
391 INPUT(input).audioroute, 0, 0); 390 INPUT(input).audioroute, 0, 0);
392 } 391 }
@@ -771,8 +770,7 @@ static int video_open(struct file *file)
771 cx_write(MO_GP1_IO, core->board.radio.gpio1); 770 cx_write(MO_GP1_IO, core->board.radio.gpio1);
772 cx_write(MO_GP2_IO, core->board.radio.gpio2); 771 cx_write(MO_GP2_IO, core->board.radio.gpio2);
773 if (core->board.radio.audioroute) { 772 if (core->board.radio.audioroute) {
774 if(core->board.audio_chip && 773 if (core->sd_wm8775) {
775 core->board.audio_chip == V4L2_IDENT_WM8775) {
776 call_all(core, audio, s_routing, 774 call_all(core, audio, s_routing,
777 core->board.radio.audioroute, 0, 0); 775 core->board.radio.audioroute, 0, 0);
778 } 776 }
@@ -959,7 +957,7 @@ static int cx8800_s_aud_ctrl(struct v4l2_ctrl *ctrl)
959 u32 value,mask; 957 u32 value,mask;
960 958
961 /* Pass changes onto any WM8775 */ 959 /* Pass changes onto any WM8775 */
962 if (core->board.audio_chip == V4L2_IDENT_WM8775) { 960 if (core->sd_wm8775) {
963 switch (ctrl->id) { 961 switch (ctrl->id) {
964 case V4L2_CID_AUDIO_MUTE: 962 case V4L2_CID_AUDIO_MUTE:
965 wm8775_s_ctrl(core, ctrl->id, ctrl->val); 963 wm8775_s_ctrl(core, ctrl->id, ctrl->val);
diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
index 48b8d7af386d..9d1481a60bd9 100644
--- a/drivers/media/platform/coda.c
+++ b/drivers/media/platform/coda.c
@@ -576,6 +576,14 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
576 return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf); 576 return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf);
577} 577}
578 578
579static int vidioc_create_bufs(struct file *file, void *priv,
580 struct v4l2_create_buffers *create)
581{
582 struct coda_ctx *ctx = fh_to_ctx(priv);
583
584 return v4l2_m2m_create_bufs(file, ctx->m2m_ctx, create);
585}
586
579static int vidioc_streamon(struct file *file, void *priv, 587static int vidioc_streamon(struct file *file, void *priv,
580 enum v4l2_buf_type type) 588 enum v4l2_buf_type type)
581{ 589{
@@ -610,6 +618,7 @@ static const struct v4l2_ioctl_ops coda_ioctl_ops = {
610 618
611 .vidioc_qbuf = vidioc_qbuf, 619 .vidioc_qbuf = vidioc_qbuf,
612 .vidioc_dqbuf = vidioc_dqbuf, 620 .vidioc_dqbuf = vidioc_dqbuf,
621 .vidioc_create_bufs = vidioc_create_bufs,
613 622
614 .vidioc_streamon = vidioc_streamon, 623 .vidioc_streamon = vidioc_streamon,
615 .vidioc_streamoff = vidioc_streamoff, 624 .vidioc_streamoff = vidioc_streamoff,
diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c
index 1802f11e939f..d0b375cf565f 100644
--- a/drivers/media/platform/davinci/vpbe_display.c
+++ b/drivers/media/platform/davinci/vpbe_display.c
@@ -916,6 +916,21 @@ static int vpbe_display_s_fmt(struct file *file, void *priv,
916 other video window */ 916 other video window */
917 917
918 layer->pix_fmt = *pixfmt; 918 layer->pix_fmt = *pixfmt;
919 if (pixfmt->pixelformat == V4L2_PIX_FMT_NV12) {
920 struct vpbe_layer *otherlayer;
921
922 otherlayer = _vpbe_display_get_other_win_layer(disp_dev, layer);
923 /* if other layer is available, only
924 * claim it, do not configure it
925 */
926 ret = osd_device->ops.request_layer(osd_device,
927 otherlayer->layer_info.id);
928 if (ret < 0) {
929 v4l2_err(&vpbe_dev->v4l2_dev,
930 "Display Manager failed to allocate layer\n");
931 return -EBUSY;
932 }
933 }
919 934
920 /* Get osd layer config */ 935 /* Get osd layer config */
921 osd_device->ops.get_layer_config(osd_device, 936 osd_device->ops.get_layer_config(osd_device,
diff --git a/drivers/media/platform/davinci/vpfe_capture.c b/drivers/media/platform/davinci/vpfe_capture.c
index 8c50d3074866..93609091cb23 100644
--- a/drivers/media/platform/davinci/vpfe_capture.c
+++ b/drivers/media/platform/davinci/vpfe_capture.c
@@ -1837,7 +1837,7 @@ static int vpfe_probe(struct platform_device *pdev)
1837 if (NULL == ccdc_cfg) { 1837 if (NULL == ccdc_cfg) {
1838 v4l2_err(pdev->dev.driver, 1838 v4l2_err(pdev->dev.driver,
1839 "Memory allocation failed for ccdc_cfg\n"); 1839 "Memory allocation failed for ccdc_cfg\n");
1840 goto probe_free_lock; 1840 goto probe_free_dev_mem;
1841 } 1841 }
1842 1842
1843 mutex_lock(&ccdc_lock); 1843 mutex_lock(&ccdc_lock);
@@ -1991,7 +1991,6 @@ probe_out_release_irq:
1991 free_irq(vpfe_dev->ccdc_irq0, vpfe_dev); 1991 free_irq(vpfe_dev->ccdc_irq0, vpfe_dev);
1992probe_free_ccdc_cfg_mem: 1992probe_free_ccdc_cfg_mem:
1993 kfree(ccdc_cfg); 1993 kfree(ccdc_cfg);
1994probe_free_lock:
1995 mutex_unlock(&ccdc_lock); 1994 mutex_unlock(&ccdc_lock);
1996probe_free_dev_mem: 1995probe_free_dev_mem:
1997 kfree(vpfe_dev); 1996 kfree(vpfe_dev);
diff --git a/drivers/media/platform/exynos4-is/fimc-is-regs.c b/drivers/media/platform/exynos4-is/fimc-is-regs.c
index b0ff67bc1b05..d05eaa2c8490 100644
--- a/drivers/media/platform/exynos4-is/fimc-is-regs.c
+++ b/drivers/media/platform/exynos4-is/fimc-is-regs.c
@@ -174,7 +174,7 @@ int fimc_is_hw_change_mode(struct fimc_is *is)
174 HIC_CAPTURE_STILL, HIC_CAPTURE_VIDEO, 174 HIC_CAPTURE_STILL, HIC_CAPTURE_VIDEO,
175 }; 175 };
176 176
177 if (WARN_ON(is->config_index > ARRAY_SIZE(cmd))) 177 if (WARN_ON(is->config_index >= ARRAY_SIZE(cmd)))
178 return -EINVAL; 178 return -EINVAL;
179 179
180 mcuctl_write(cmd[is->config_index], is, MCUCTL_REG_ISSR(0)); 180 mcuctl_write(cmd[is->config_index], is, MCUCTL_REG_ISSR(0));
diff --git a/drivers/media/platform/exynos4-is/fimc-is.c b/drivers/media/platform/exynos4-is/fimc-is.c
index 47c6363d04e2..520e4398b69c 100644
--- a/drivers/media/platform/exynos4-is/fimc-is.c
+++ b/drivers/media/platform/exynos4-is/fimc-is.c
@@ -48,7 +48,6 @@ static char *fimc_is_clocks[ISS_CLKS_MAX] = {
48 [ISS_CLK_LITE0] = "lite0", 48 [ISS_CLK_LITE0] = "lite0",
49 [ISS_CLK_LITE1] = "lite1", 49 [ISS_CLK_LITE1] = "lite1",
50 [ISS_CLK_MPLL] = "mpll", 50 [ISS_CLK_MPLL] = "mpll",
51 [ISS_CLK_SYSREG] = "sysreg",
52 [ISS_CLK_ISP] = "isp", 51 [ISS_CLK_ISP] = "isp",
53 [ISS_CLK_DRC] = "drc", 52 [ISS_CLK_DRC] = "drc",
54 [ISS_CLK_FD] = "fd", 53 [ISS_CLK_FD] = "fd",
@@ -71,7 +70,6 @@ static void fimc_is_put_clocks(struct fimc_is *is)
71 for (i = 0; i < ISS_CLKS_MAX; i++) { 70 for (i = 0; i < ISS_CLKS_MAX; i++) {
72 if (IS_ERR(is->clocks[i])) 71 if (IS_ERR(is->clocks[i]))
73 continue; 72 continue;
74 clk_unprepare(is->clocks[i]);
75 clk_put(is->clocks[i]); 73 clk_put(is->clocks[i]);
76 is->clocks[i] = ERR_PTR(-EINVAL); 74 is->clocks[i] = ERR_PTR(-EINVAL);
77 } 75 }
@@ -90,12 +88,6 @@ static int fimc_is_get_clocks(struct fimc_is *is)
90 ret = PTR_ERR(is->clocks[i]); 88 ret = PTR_ERR(is->clocks[i]);
91 goto err; 89 goto err;
92 } 90 }
93 ret = clk_prepare(is->clocks[i]);
94 if (ret < 0) {
95 clk_put(is->clocks[i]);
96 is->clocks[i] = ERR_PTR(-EINVAL);
97 goto err;
98 }
99 } 91 }
100 92
101 return 0; 93 return 0;
@@ -103,7 +95,7 @@ err:
103 fimc_is_put_clocks(is); 95 fimc_is_put_clocks(is);
104 dev_err(&is->pdev->dev, "failed to get clock: %s\n", 96 dev_err(&is->pdev->dev, "failed to get clock: %s\n",
105 fimc_is_clocks[i]); 97 fimc_is_clocks[i]);
106 return -ENXIO; 98 return ret;
107} 99}
108 100
109static int fimc_is_setup_clocks(struct fimc_is *is) 101static int fimc_is_setup_clocks(struct fimc_is *is)
@@ -144,7 +136,7 @@ int fimc_is_enable_clocks(struct fimc_is *is)
144 for (i = 0; i < ISS_GATE_CLKS_MAX; i++) { 136 for (i = 0; i < ISS_GATE_CLKS_MAX; i++) {
145 if (IS_ERR(is->clocks[i])) 137 if (IS_ERR(is->clocks[i]))
146 continue; 138 continue;
147 ret = clk_enable(is->clocks[i]); 139 ret = clk_prepare_enable(is->clocks[i]);
148 if (ret < 0) { 140 if (ret < 0) {
149 dev_err(&is->pdev->dev, "clock %s enable failed\n", 141 dev_err(&is->pdev->dev, "clock %s enable failed\n",
150 fimc_is_clocks[i]); 142 fimc_is_clocks[i]);
@@ -163,7 +155,7 @@ void fimc_is_disable_clocks(struct fimc_is *is)
163 155
164 for (i = 0; i < ISS_GATE_CLKS_MAX; i++) { 156 for (i = 0; i < ISS_GATE_CLKS_MAX; i++) {
165 if (!IS_ERR(is->clocks[i])) { 157 if (!IS_ERR(is->clocks[i])) {
166 clk_disable(is->clocks[i]); 158 clk_disable_unprepare(is->clocks[i]);
167 pr_debug("disabled clock: %s\n", fimc_is_clocks[i]); 159 pr_debug("disabled clock: %s\n", fimc_is_clocks[i]);
168 } 160 }
169 } 161 }
@@ -326,6 +318,11 @@ int fimc_is_start_firmware(struct fimc_is *is)
326 struct device *dev = &is->pdev->dev; 318 struct device *dev = &is->pdev->dev;
327 int ret; 319 int ret;
328 320
321 if (is->fw.f_w == NULL) {
322 dev_err(dev, "firmware is not loaded\n");
323 return -EINVAL;
324 }
325
329 memcpy(is->memory.vaddr, is->fw.f_w->data, is->fw.f_w->size); 326 memcpy(is->memory.vaddr, is->fw.f_w->data, is->fw.f_w->size);
330 wmb(); 327 wmb();
331 328
@@ -941,7 +938,8 @@ static int fimc_is_remove(struct platform_device *pdev)
941 vb2_dma_contig_cleanup_ctx(is->alloc_ctx); 938 vb2_dma_contig_cleanup_ctx(is->alloc_ctx);
942 fimc_is_put_clocks(is); 939 fimc_is_put_clocks(is);
943 fimc_is_debugfs_remove(is); 940 fimc_is_debugfs_remove(is);
944 release_firmware(is->fw.f_w); 941 if (is->fw.f_w)
942 release_firmware(is->fw.f_w);
945 fimc_is_free_cpu_memory(is); 943 fimc_is_free_cpu_memory(is);
946 944
947 return 0; 945 return 0;
diff --git a/drivers/media/platform/exynos4-is/fimc-is.h b/drivers/media/platform/exynos4-is/fimc-is.h
index f5275a5b0156..606a7c9fe526 100644
--- a/drivers/media/platform/exynos4-is/fimc-is.h
+++ b/drivers/media/platform/exynos4-is/fimc-is.h
@@ -73,7 +73,6 @@ enum {
73 ISS_CLK_LITE0, 73 ISS_CLK_LITE0,
74 ISS_CLK_LITE1, 74 ISS_CLK_LITE1,
75 ISS_CLK_MPLL, 75 ISS_CLK_MPLL,
76 ISS_CLK_SYSREG,
77 ISS_CLK_ISP, 76 ISS_CLK_ISP,
78 ISS_CLK_DRC, 77 ISS_CLK_DRC,
79 ISS_CLK_FD, 78 ISS_CLK_FD,
diff --git a/drivers/media/platform/exynos4-is/fimc-isp.c b/drivers/media/platform/exynos4-is/fimc-isp.c
index d63947f7b302..7ede30b5910f 100644
--- a/drivers/media/platform/exynos4-is/fimc-isp.c
+++ b/drivers/media/platform/exynos4-is/fimc-isp.c
@@ -138,7 +138,7 @@ static int fimc_isp_subdev_get_fmt(struct v4l2_subdev *sd,
138 return 0; 138 return 0;
139 } 139 }
140 140
141 mf->colorspace = V4L2_COLORSPACE_JPEG; 141 mf->colorspace = V4L2_COLORSPACE_SRGB;
142 142
143 mutex_lock(&isp->subdev_lock); 143 mutex_lock(&isp->subdev_lock);
144 __is_get_frame_size(is, &cur_fmt); 144 __is_get_frame_size(is, &cur_fmt);
@@ -194,7 +194,7 @@ static int fimc_isp_subdev_set_fmt(struct v4l2_subdev *sd,
194 v4l2_dbg(1, debug, sd, "%s: pad%d: code: 0x%x, %dx%d\n", 194 v4l2_dbg(1, debug, sd, "%s: pad%d: code: 0x%x, %dx%d\n",
195 __func__, fmt->pad, mf->code, mf->width, mf->height); 195 __func__, fmt->pad, mf->code, mf->width, mf->height);
196 196
197 mf->colorspace = V4L2_COLORSPACE_JPEG; 197 mf->colorspace = V4L2_COLORSPACE_SRGB;
198 198
199 mutex_lock(&isp->subdev_lock); 199 mutex_lock(&isp->subdev_lock);
200 __isp_subdev_try_format(isp, fmt); 200 __isp_subdev_try_format(isp, fmt);
diff --git a/drivers/media/platform/exynos4-is/mipi-csis.c b/drivers/media/platform/exynos4-is/mipi-csis.c
index a2eda9d5ac87..254d70fe762a 100644
--- a/drivers/media/platform/exynos4-is/mipi-csis.c
+++ b/drivers/media/platform/exynos4-is/mipi-csis.c
@@ -746,7 +746,7 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
746 node = v4l2_of_get_next_endpoint(node, NULL); 746 node = v4l2_of_get_next_endpoint(node, NULL);
747 if (!node) { 747 if (!node) {
748 dev_err(&pdev->dev, "No port node at %s\n", 748 dev_err(&pdev->dev, "No port node at %s\n",
749 node->full_name); 749 pdev->dev.of_node->full_name);
750 return -EINVAL; 750 return -EINVAL;
751 } 751 }
752 /* Get port node and validate MIPI-CSI channel id. */ 752 /* Get port node and validate MIPI-CSI channel id. */
diff --git a/drivers/media/platform/s3c-camif/camif-core.h b/drivers/media/platform/s3c-camif/camif-core.h
index 261134baa655..35d2fcdc0036 100644
--- a/drivers/media/platform/s3c-camif/camif-core.h
+++ b/drivers/media/platform/s3c-camif/camif-core.h
@@ -229,7 +229,7 @@ struct camif_vp {
229 unsigned int state; 229 unsigned int state;
230 u16 fmt_flags; 230 u16 fmt_flags;
231 u8 id; 231 u8 id;
232 u8 rotation; 232 u16 rotation;
233 u8 hflip; 233 u8 hflip;
234 u8 vflip; 234 u8 vflip;
235 unsigned int offset; 235 unsigned int offset;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 01f9ae0dadb0..d12faa691af8 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -397,7 +397,7 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx,
397leave_handle_frame: 397leave_handle_frame:
398 spin_unlock_irqrestore(&dev->irqlock, flags); 398 spin_unlock_irqrestore(&dev->irqlock, flags);
399 if ((ctx->src_queue_cnt == 0 && ctx->state != MFCINST_FINISHING) 399 if ((ctx->src_queue_cnt == 0 && ctx->state != MFCINST_FINISHING)
400 || ctx->dst_queue_cnt < ctx->dpb_count) 400 || ctx->dst_queue_cnt < ctx->pb_count)
401 clear_work_bit(ctx); 401 clear_work_bit(ctx);
402 s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev); 402 s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev);
403 wake_up_ctx(ctx, reason, err); 403 wake_up_ctx(ctx, reason, err);
@@ -473,7 +473,7 @@ static void s5p_mfc_handle_seq_done(struct s5p_mfc_ctx *ctx,
473 473
474 s5p_mfc_hw_call(dev->mfc_ops, dec_calc_dpb_size, ctx); 474 s5p_mfc_hw_call(dev->mfc_ops, dec_calc_dpb_size, ctx);
475 475
476 ctx->dpb_count = s5p_mfc_hw_call(dev->mfc_ops, get_dpb_count, 476 ctx->pb_count = s5p_mfc_hw_call(dev->mfc_ops, get_dpb_count,
477 dev); 477 dev);
478 ctx->mv_count = s5p_mfc_hw_call(dev->mfc_ops, get_mv_count, 478 ctx->mv_count = s5p_mfc_hw_call(dev->mfc_ops, get_mv_count,
479 dev); 479 dev);
@@ -562,7 +562,7 @@ static void s5p_mfc_handle_stream_complete(struct s5p_mfc_ctx *ctx,
562 struct s5p_mfc_dev *dev = ctx->dev; 562 struct s5p_mfc_dev *dev = ctx->dev;
563 struct s5p_mfc_buf *mb_entry; 563 struct s5p_mfc_buf *mb_entry;
564 564
565 mfc_debug(2, "Stream completed"); 565 mfc_debug(2, "Stream completed\n");
566 566
567 s5p_mfc_clear_int_flags(dev); 567 s5p_mfc_clear_int_flags(dev);
568 ctx->int_type = reason; 568 ctx->int_type = reason;
@@ -1362,7 +1362,6 @@ static struct s5p_mfc_variant mfc_drvdata_v5 = {
1362 .port_num = MFC_NUM_PORTS, 1362 .port_num = MFC_NUM_PORTS,
1363 .buf_size = &buf_size_v5, 1363 .buf_size = &buf_size_v5,
1364 .buf_align = &mfc_buf_align_v5, 1364 .buf_align = &mfc_buf_align_v5,
1365 .mclk_name = "sclk_mfc",
1366 .fw_name = "s5p-mfc.fw", 1365 .fw_name = "s5p-mfc.fw",
1367}; 1366};
1368 1367
@@ -1389,7 +1388,6 @@ static struct s5p_mfc_variant mfc_drvdata_v6 = {
1389 .port_num = MFC_NUM_PORTS_V6, 1388 .port_num = MFC_NUM_PORTS_V6,
1390 .buf_size = &buf_size_v6, 1389 .buf_size = &buf_size_v6,
1391 .buf_align = &mfc_buf_align_v6, 1390 .buf_align = &mfc_buf_align_v6,
1392 .mclk_name = "aclk_333",
1393 .fw_name = "s5p-mfc-v6.fw", 1391 .fw_name = "s5p-mfc-v6.fw",
1394}; 1392};
1395 1393
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index 202d1d7a37a8..ef4074cd5316 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -138,6 +138,7 @@ enum s5p_mfc_inst_state {
138 MFCINST_INIT = 100, 138 MFCINST_INIT = 100,
139 MFCINST_GOT_INST, 139 MFCINST_GOT_INST,
140 MFCINST_HEAD_PARSED, 140 MFCINST_HEAD_PARSED,
141 MFCINST_HEAD_PRODUCED,
141 MFCINST_BUFS_SET, 142 MFCINST_BUFS_SET,
142 MFCINST_RUNNING, 143 MFCINST_RUNNING,
143 MFCINST_FINISHING, 144 MFCINST_FINISHING,
@@ -231,7 +232,6 @@ struct s5p_mfc_variant {
231 unsigned int port_num; 232 unsigned int port_num;
232 struct s5p_mfc_buf_size *buf_size; 233 struct s5p_mfc_buf_size *buf_size;
233 struct s5p_mfc_buf_align *buf_align; 234 struct s5p_mfc_buf_align *buf_align;
234 char *mclk_name;
235 char *fw_name; 235 char *fw_name;
236}; 236};
237 237
@@ -438,7 +438,7 @@ struct s5p_mfc_enc_params {
438 u32 rc_framerate_num; 438 u32 rc_framerate_num;
439 u32 rc_framerate_denom; 439 u32 rc_framerate_denom;
440 440
441 union { 441 struct {
442 struct s5p_mfc_h264_enc_params h264; 442 struct s5p_mfc_h264_enc_params h264;
443 struct s5p_mfc_mpeg4_enc_params mpeg4; 443 struct s5p_mfc_mpeg4_enc_params mpeg4;
444 } codec; 444 } codec;
@@ -602,7 +602,7 @@ struct s5p_mfc_ctx {
602 int after_packed_pb; 602 int after_packed_pb;
603 int sei_fp_parse; 603 int sei_fp_parse;
604 604
605 int dpb_count; 605 int pb_count;
606 int total_dpb_count; 606 int total_dpb_count;
607 int mv_count; 607 int mv_count;
608 /* Buffers */ 608 /* Buffers */
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
index 2e5f30b40dea..dc1fc94a488d 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
@@ -38,7 +38,7 @@ int s5p_mfc_alloc_firmware(struct s5p_mfc_dev *dev)
38 dev->fw_virt_addr = dma_alloc_coherent(dev->mem_dev_l, dev->fw_size, 38 dev->fw_virt_addr = dma_alloc_coherent(dev->mem_dev_l, dev->fw_size,
39 &dev->bank1, GFP_KERNEL); 39 &dev->bank1, GFP_KERNEL);
40 40
41 if (IS_ERR(dev->fw_virt_addr)) { 41 if (IS_ERR_OR_NULL(dev->fw_virt_addr)) {
42 dev->fw_virt_addr = NULL; 42 dev->fw_virt_addr = NULL;
43 mfc_err("Allocating bitprocessor buffer failed\n"); 43 mfc_err("Allocating bitprocessor buffer failed\n");
44 return -ENOMEM; 44 return -ENOMEM;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_debug.h b/drivers/media/platform/s5p-mfc/s5p_mfc_debug.h
index bd5cd4ae993c..8e608f5aa0d7 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_debug.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_debug.h
@@ -30,8 +30,8 @@ extern int debug;
30#define mfc_debug(level, fmt, args...) 30#define mfc_debug(level, fmt, args...)
31#endif 31#endif
32 32
33#define mfc_debug_enter() mfc_debug(5, "enter") 33#define mfc_debug_enter() mfc_debug(5, "enter\n")
34#define mfc_debug_leave() mfc_debug(5, "leave") 34#define mfc_debug_leave() mfc_debug(5, "leave\n")
35 35
36#define mfc_err(fmt, args...) \ 36#define mfc_err(fmt, args...) \
37 do { \ 37 do { \
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index 4af53bd2f182..00b07032f4f0 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -210,11 +210,11 @@ static int s5p_mfc_ctx_ready(struct s5p_mfc_ctx *ctx)
210 /* Context is to decode a frame */ 210 /* Context is to decode a frame */
211 if (ctx->src_queue_cnt >= 1 && 211 if (ctx->src_queue_cnt >= 1 &&
212 ctx->state == MFCINST_RUNNING && 212 ctx->state == MFCINST_RUNNING &&
213 ctx->dst_queue_cnt >= ctx->dpb_count) 213 ctx->dst_queue_cnt >= ctx->pb_count)
214 return 1; 214 return 1;
215 /* Context is to return last frame */ 215 /* Context is to return last frame */
216 if (ctx->state == MFCINST_FINISHING && 216 if (ctx->state == MFCINST_FINISHING &&
217 ctx->dst_queue_cnt >= ctx->dpb_count) 217 ctx->dst_queue_cnt >= ctx->pb_count)
218 return 1; 218 return 1;
219 /* Context is to set buffers */ 219 /* Context is to set buffers */
220 if (ctx->src_queue_cnt >= 1 && 220 if (ctx->src_queue_cnt >= 1 &&
@@ -224,7 +224,7 @@ static int s5p_mfc_ctx_ready(struct s5p_mfc_ctx *ctx)
224 /* Resolution change */ 224 /* Resolution change */
225 if ((ctx->state == MFCINST_RES_CHANGE_INIT || 225 if ((ctx->state == MFCINST_RES_CHANGE_INIT ||
226 ctx->state == MFCINST_RES_CHANGE_FLUSH) && 226 ctx->state == MFCINST_RES_CHANGE_FLUSH) &&
227 ctx->dst_queue_cnt >= ctx->dpb_count) 227 ctx->dst_queue_cnt >= ctx->pb_count)
228 return 1; 228 return 1;
229 if (ctx->state == MFCINST_RES_CHANGE_END && 229 if (ctx->state == MFCINST_RES_CHANGE_END &&
230 ctx->src_queue_cnt >= 1) 230 ctx->src_queue_cnt >= 1)
@@ -537,7 +537,7 @@ static int vidioc_reqbufs(struct file *file, void *priv,
537 mfc_err("vb2_reqbufs on capture failed\n"); 537 mfc_err("vb2_reqbufs on capture failed\n");
538 return ret; 538 return ret;
539 } 539 }
540 if (reqbufs->count < ctx->dpb_count) { 540 if (reqbufs->count < ctx->pb_count) {
541 mfc_err("Not enough buffers allocated\n"); 541 mfc_err("Not enough buffers allocated\n");
542 reqbufs->count = 0; 542 reqbufs->count = 0;
543 s5p_mfc_clock_on(); 543 s5p_mfc_clock_on();
@@ -751,7 +751,7 @@ static int s5p_mfc_dec_g_v_ctrl(struct v4l2_ctrl *ctrl)
751 case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE: 751 case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE:
752 if (ctx->state >= MFCINST_HEAD_PARSED && 752 if (ctx->state >= MFCINST_HEAD_PARSED &&
753 ctx->state < MFCINST_ABORT) { 753 ctx->state < MFCINST_ABORT) {
754 ctrl->val = ctx->dpb_count; 754 ctrl->val = ctx->pb_count;
755 break; 755 break;
756 } else if (ctx->state != MFCINST_INIT) { 756 } else if (ctx->state != MFCINST_INIT) {
757 v4l2_err(&dev->v4l2_dev, "Decoding not initialised\n"); 757 v4l2_err(&dev->v4l2_dev, "Decoding not initialised\n");
@@ -763,7 +763,7 @@ static int s5p_mfc_dec_g_v_ctrl(struct v4l2_ctrl *ctrl)
763 S5P_MFC_R2H_CMD_SEQ_DONE_RET, 0); 763 S5P_MFC_R2H_CMD_SEQ_DONE_RET, 0);
764 if (ctx->state >= MFCINST_HEAD_PARSED && 764 if (ctx->state >= MFCINST_HEAD_PARSED &&
765 ctx->state < MFCINST_ABORT) { 765 ctx->state < MFCINST_ABORT) {
766 ctrl->val = ctx->dpb_count; 766 ctrl->val = ctx->pb_count;
767 } else { 767 } else {
768 v4l2_err(&dev->v4l2_dev, "Decoding not initialised\n"); 768 v4l2_err(&dev->v4l2_dev, "Decoding not initialised\n");
769 return -EINVAL; 769 return -EINVAL;
@@ -924,10 +924,10 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq,
924 /* Output plane count is 2 - one for Y and one for CbCr */ 924 /* Output plane count is 2 - one for Y and one for CbCr */
925 *plane_count = 2; 925 *plane_count = 2;
926 /* Setup buffer count */ 926 /* Setup buffer count */
927 if (*buf_count < ctx->dpb_count) 927 if (*buf_count < ctx->pb_count)
928 *buf_count = ctx->dpb_count; 928 *buf_count = ctx->pb_count;
929 if (*buf_count > ctx->dpb_count + MFC_MAX_EXTRA_DPB) 929 if (*buf_count > ctx->pb_count + MFC_MAX_EXTRA_DPB)
930 *buf_count = ctx->dpb_count + MFC_MAX_EXTRA_DPB; 930 *buf_count = ctx->pb_count + MFC_MAX_EXTRA_DPB;
931 if (*buf_count > MFC_MAX_BUFFERS) 931 if (*buf_count > MFC_MAX_BUFFERS)
932 *buf_count = MFC_MAX_BUFFERS; 932 *buf_count = MFC_MAX_BUFFERS;
933 } else { 933 } else {
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index 4f6b553c4b2d..2549967b2f85 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -592,7 +592,7 @@ static int s5p_mfc_ctx_ready(struct s5p_mfc_ctx *ctx)
592 return 1; 592 return 1;
593 /* context is ready to encode a frame */ 593 /* context is ready to encode a frame */
594 if ((ctx->state == MFCINST_RUNNING || 594 if ((ctx->state == MFCINST_RUNNING ||
595 ctx->state == MFCINST_HEAD_PARSED) && 595 ctx->state == MFCINST_HEAD_PRODUCED) &&
596 ctx->src_queue_cnt >= 1 && ctx->dst_queue_cnt >= 1) 596 ctx->src_queue_cnt >= 1 && ctx->dst_queue_cnt >= 1)
597 return 1; 597 return 1;
598 /* context is ready to encode remaining frames */ 598 /* context is ready to encode remaining frames */
@@ -649,6 +649,7 @@ static int enc_post_seq_start(struct s5p_mfc_ctx *ctx)
649 struct s5p_mfc_enc_params *p = &ctx->enc_params; 649 struct s5p_mfc_enc_params *p = &ctx->enc_params;
650 struct s5p_mfc_buf *dst_mb; 650 struct s5p_mfc_buf *dst_mb;
651 unsigned long flags; 651 unsigned long flags;
652 unsigned int enc_pb_count;
652 653
653 if (p->seq_hdr_mode == V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE) { 654 if (p->seq_hdr_mode == V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE) {
654 spin_lock_irqsave(&dev->irqlock, flags); 655 spin_lock_irqsave(&dev->irqlock, flags);
@@ -661,18 +662,19 @@ static int enc_post_seq_start(struct s5p_mfc_ctx *ctx)
661 vb2_buffer_done(dst_mb->b, VB2_BUF_STATE_DONE); 662 vb2_buffer_done(dst_mb->b, VB2_BUF_STATE_DONE);
662 spin_unlock_irqrestore(&dev->irqlock, flags); 663 spin_unlock_irqrestore(&dev->irqlock, flags);
663 } 664 }
664 if (IS_MFCV6(dev)) { 665
665 ctx->state = MFCINST_HEAD_PARSED; /* for INIT_BUFFER cmd */ 666 if (!IS_MFCV6(dev)) {
666 } else {
667 ctx->state = MFCINST_RUNNING; 667 ctx->state = MFCINST_RUNNING;
668 if (s5p_mfc_ctx_ready(ctx)) 668 if (s5p_mfc_ctx_ready(ctx))
669 set_work_bit_irqsave(ctx); 669 set_work_bit_irqsave(ctx);
670 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev); 670 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
671 } 671 } else {
672 672 enc_pb_count = s5p_mfc_hw_call(dev->mfc_ops,
673 if (IS_MFCV6(dev))
674 ctx->dpb_count = s5p_mfc_hw_call(dev->mfc_ops,
675 get_enc_dpb_count, dev); 673 get_enc_dpb_count, dev);
674 if (ctx->pb_count < enc_pb_count)
675 ctx->pb_count = enc_pb_count;
676 ctx->state = MFCINST_HEAD_PRODUCED;
677 }
676 678
677 return 0; 679 return 0;
678} 680}
@@ -717,9 +719,9 @@ static int enc_post_frame_start(struct s5p_mfc_ctx *ctx)
717 719
718 slice_type = s5p_mfc_hw_call(dev->mfc_ops, get_enc_slice_type, dev); 720 slice_type = s5p_mfc_hw_call(dev->mfc_ops, get_enc_slice_type, dev);
719 strm_size = s5p_mfc_hw_call(dev->mfc_ops, get_enc_strm_size, dev); 721 strm_size = s5p_mfc_hw_call(dev->mfc_ops, get_enc_strm_size, dev);
720 mfc_debug(2, "Encoded slice type: %d", slice_type); 722 mfc_debug(2, "Encoded slice type: %d\n", slice_type);
721 mfc_debug(2, "Encoded stream size: %d", strm_size); 723 mfc_debug(2, "Encoded stream size: %d\n", strm_size);
722 mfc_debug(2, "Display order: %d", 724 mfc_debug(2, "Display order: %d\n",
723 mfc_read(dev, S5P_FIMV_ENC_SI_PIC_CNT)); 725 mfc_read(dev, S5P_FIMV_ENC_SI_PIC_CNT));
724 spin_lock_irqsave(&dev->irqlock, flags); 726 spin_lock_irqsave(&dev->irqlock, flags);
725 if (slice_type >= 0) { 727 if (slice_type >= 0) {
@@ -1055,15 +1057,13 @@ static int vidioc_reqbufs(struct file *file, void *priv,
1055 } 1057 }
1056 ctx->capture_state = QUEUE_BUFS_REQUESTED; 1058 ctx->capture_state = QUEUE_BUFS_REQUESTED;
1057 1059
1058 if (!IS_MFCV6(dev)) { 1060 ret = s5p_mfc_hw_call(ctx->dev->mfc_ops,
1059 ret = s5p_mfc_hw_call(ctx->dev->mfc_ops, 1061 alloc_codec_buffers, ctx);
1060 alloc_codec_buffers, ctx); 1062 if (ret) {
1061 if (ret) { 1063 mfc_err("Failed to allocate encoding buffers\n");
1062 mfc_err("Failed to allocate encoding buffers\n"); 1064 reqbufs->count = 0;
1063 reqbufs->count = 0; 1065 ret = vb2_reqbufs(&ctx->vq_dst, reqbufs);
1064 ret = vb2_reqbufs(&ctx->vq_dst, reqbufs); 1066 return -ENOMEM;
1065 return -ENOMEM;
1066 }
1067 } 1067 }
1068 } else if (reqbufs->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { 1068 } else if (reqbufs->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
1069 if (ctx->output_state != QUEUE_FREE) { 1069 if (ctx->output_state != QUEUE_FREE) {
@@ -1071,6 +1071,19 @@ static int vidioc_reqbufs(struct file *file, void *priv,
1071 ctx->output_state); 1071 ctx->output_state);
1072 return -EINVAL; 1072 return -EINVAL;
1073 } 1073 }
1074
1075 if (IS_MFCV6(dev)) {
1076 /* Check for min encoder buffers */
1077 if (ctx->pb_count &&
1078 (reqbufs->count < ctx->pb_count)) {
1079 reqbufs->count = ctx->pb_count;
1080 mfc_debug(2, "Minimum %d output buffers needed\n",
1081 ctx->pb_count);
1082 } else {
1083 ctx->pb_count = reqbufs->count;
1084 }
1085 }
1086
1074 ret = vb2_reqbufs(&ctx->vq_src, reqbufs); 1087 ret = vb2_reqbufs(&ctx->vq_src, reqbufs);
1075 if (ret != 0) { 1088 if (ret != 0) {
1076 mfc_err("error in vb2_reqbufs() for E(S)\n"); 1089 mfc_err("error in vb2_reqbufs() for E(S)\n");
@@ -1533,14 +1546,14 @@ int vidioc_encoder_cmd(struct file *file, void *priv,
1533 1546
1534 spin_lock_irqsave(&dev->irqlock, flags); 1547 spin_lock_irqsave(&dev->irqlock, flags);
1535 if (list_empty(&ctx->src_queue)) { 1548 if (list_empty(&ctx->src_queue)) {
1536 mfc_debug(2, "EOS: empty src queue, entering finishing state"); 1549 mfc_debug(2, "EOS: empty src queue, entering finishing state\n");
1537 ctx->state = MFCINST_FINISHING; 1550 ctx->state = MFCINST_FINISHING;
1538 if (s5p_mfc_ctx_ready(ctx)) 1551 if (s5p_mfc_ctx_ready(ctx))
1539 set_work_bit_irqsave(ctx); 1552 set_work_bit_irqsave(ctx);
1540 spin_unlock_irqrestore(&dev->irqlock, flags); 1553 spin_unlock_irqrestore(&dev->irqlock, flags);
1541 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev); 1554 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
1542 } else { 1555 } else {
1543 mfc_debug(2, "EOS: marking last buffer of stream"); 1556 mfc_debug(2, "EOS: marking last buffer of stream\n");
1544 buf = list_entry(ctx->src_queue.prev, 1557 buf = list_entry(ctx->src_queue.prev,
1545 struct s5p_mfc_buf, list); 1558 struct s5p_mfc_buf, list);
1546 if (buf->flags & MFC_BUF_FLAG_USED) 1559 if (buf->flags & MFC_BUF_FLAG_USED)
@@ -1609,9 +1622,9 @@ static int check_vb_with_fmt(struct s5p_mfc_fmt *fmt, struct vb2_buffer *vb)
1609 mfc_err("failed to get plane cookie\n"); 1622 mfc_err("failed to get plane cookie\n");
1610 return -EINVAL; 1623 return -EINVAL;
1611 } 1624 }
1612 mfc_debug(2, "index: %d, plane[%d] cookie: 0x%08zx", 1625 mfc_debug(2, "index: %d, plane[%d] cookie: 0x%08zx\n",
1613 vb->v4l2_buf.index, i, 1626 vb->v4l2_buf.index, i,
1614 vb2_dma_contig_plane_dma_addr(vb, i)); 1627 vb2_dma_contig_plane_dma_addr(vb, i));
1615 } 1628 }
1616 return 0; 1629 return 0;
1617} 1630}
@@ -1760,11 +1773,27 @@ static int s5p_mfc_start_streaming(struct vb2_queue *q, unsigned int count)
1760 struct s5p_mfc_ctx *ctx = fh_to_ctx(q->drv_priv); 1773 struct s5p_mfc_ctx *ctx = fh_to_ctx(q->drv_priv);
1761 struct s5p_mfc_dev *dev = ctx->dev; 1774 struct s5p_mfc_dev *dev = ctx->dev;
1762 1775
1763 v4l2_ctrl_handler_setup(&ctx->ctrl_handler); 1776 if (IS_MFCV6(dev) && (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)) {
1777
1778 if ((ctx->state == MFCINST_GOT_INST) &&
1779 (dev->curr_ctx == ctx->num) && dev->hw_lock) {
1780 s5p_mfc_wait_for_done_ctx(ctx,
1781 S5P_MFC_R2H_CMD_SEQ_DONE_RET,
1782 0);
1783 }
1784
1785 if (ctx->src_bufs_cnt < ctx->pb_count) {
1786 mfc_err("Need minimum %d OUTPUT buffers\n",
1787 ctx->pb_count);
1788 return -EINVAL;
1789 }
1790 }
1791
1764 /* If context is ready then dev = work->data;schedule it to run */ 1792 /* If context is ready then dev = work->data;schedule it to run */
1765 if (s5p_mfc_ctx_ready(ctx)) 1793 if (s5p_mfc_ctx_ready(ctx))
1766 set_work_bit_irqsave(ctx); 1794 set_work_bit_irqsave(ctx);
1767 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev); 1795 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
1796
1768 return 0; 1797 return 0;
1769} 1798}
1770 1799
@@ -1920,6 +1949,7 @@ int s5p_mfc_enc_ctrls_setup(struct s5p_mfc_ctx *ctx)
1920 if (controls[i].is_volatile && ctx->ctrls[i]) 1949 if (controls[i].is_volatile && ctx->ctrls[i])
1921 ctx->ctrls[i]->flags |= V4L2_CTRL_FLAG_VOLATILE; 1950 ctx->ctrls[i]->flags |= V4L2_CTRL_FLAG_VOLATILE;
1922 } 1951 }
1952 v4l2_ctrl_handler_setup(&ctx->ctrl_handler);
1923 return 0; 1953 return 0;
1924} 1954}
1925 1955
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
index 0af05a2d1cd4..368582b091bf 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
@@ -1275,8 +1275,8 @@ static int s5p_mfc_run_enc_frame(struct s5p_mfc_ctx *ctx)
1275 spin_unlock_irqrestore(&dev->irqlock, flags); 1275 spin_unlock_irqrestore(&dev->irqlock, flags);
1276 dev->curr_ctx = ctx->num; 1276 dev->curr_ctx = ctx->num;
1277 s5p_mfc_clean_ctx_int_flags(ctx); 1277 s5p_mfc_clean_ctx_int_flags(ctx);
1278 mfc_debug(2, "encoding buffer with index=%d state=%d", 1278 mfc_debug(2, "encoding buffer with index=%d state=%d\n",
1279 src_mb ? src_mb->b->v4l2_buf.index : -1, ctx->state); 1279 src_mb ? src_mb->b->v4l2_buf.index : -1, ctx->state);
1280 s5p_mfc_encode_one_frame_v5(ctx); 1280 s5p_mfc_encode_one_frame_v5(ctx);
1281 return 0; 1281 return 0;
1282} 1282}
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 7e76fce2e524..66f0d042357f 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
@@ -62,12 +62,6 @@ static void s5p_mfc_release_dec_desc_buffer_v6(struct s5p_mfc_ctx *ctx)
62 /* NOP */ 62 /* NOP */
63} 63}
64 64
65static int s5p_mfc_get_dec_status_v6(struct s5p_mfc_dev *dev)
66{
67 /* NOP */
68 return -1;
69}
70
71/* Allocate codec buffers */ 65/* Allocate codec buffers */
72static int s5p_mfc_alloc_codec_buffers_v6(struct s5p_mfc_ctx *ctx) 66static int s5p_mfc_alloc_codec_buffers_v6(struct s5p_mfc_ctx *ctx)
73{ 67{
@@ -167,7 +161,7 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct s5p_mfc_ctx *ctx)
167 S5P_FIMV_SCRATCH_BUFFER_ALIGN_V6); 161 S5P_FIMV_SCRATCH_BUFFER_ALIGN_V6);
168 ctx->bank1.size = 162 ctx->bank1.size =
169 ctx->scratch_buf_size + ctx->tmv_buffer_size + 163 ctx->scratch_buf_size + ctx->tmv_buffer_size +
170 (ctx->dpb_count * (ctx->luma_dpb_size + 164 (ctx->pb_count * (ctx->luma_dpb_size +
171 ctx->chroma_dpb_size + ctx->me_buffer_size)); 165 ctx->chroma_dpb_size + ctx->me_buffer_size));
172 ctx->bank2.size = 0; 166 ctx->bank2.size = 0;
173 break; 167 break;
@@ -181,7 +175,7 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct s5p_mfc_ctx *ctx)
181 S5P_FIMV_SCRATCH_BUFFER_ALIGN_V6); 175 S5P_FIMV_SCRATCH_BUFFER_ALIGN_V6);
182 ctx->bank1.size = 176 ctx->bank1.size =
183 ctx->scratch_buf_size + ctx->tmv_buffer_size + 177 ctx->scratch_buf_size + ctx->tmv_buffer_size +
184 (ctx->dpb_count * (ctx->luma_dpb_size + 178 (ctx->pb_count * (ctx->luma_dpb_size +
185 ctx->chroma_dpb_size + ctx->me_buffer_size)); 179 ctx->chroma_dpb_size + ctx->me_buffer_size));
186 ctx->bank2.size = 0; 180 ctx->bank2.size = 0;
187 break; 181 break;
@@ -198,7 +192,6 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct s5p_mfc_ctx *ctx)
198 } 192 }
199 BUG_ON(ctx->bank1.dma & ((1 << MFC_BANK1_ALIGN_ORDER) - 1)); 193 BUG_ON(ctx->bank1.dma & ((1 << MFC_BANK1_ALIGN_ORDER) - 1));
200 } 194 }
201
202 return 0; 195 return 0;
203} 196}
204 197
@@ -449,8 +442,8 @@ static int s5p_mfc_set_enc_stream_buffer_v6(struct s5p_mfc_ctx *ctx,
449 WRITEL(addr, S5P_FIMV_E_STREAM_BUFFER_ADDR_V6); /* 16B align */ 442 WRITEL(addr, S5P_FIMV_E_STREAM_BUFFER_ADDR_V6); /* 16B align */
450 WRITEL(size, S5P_FIMV_E_STREAM_BUFFER_SIZE_V6); 443 WRITEL(size, S5P_FIMV_E_STREAM_BUFFER_SIZE_V6);
451 444
452 mfc_debug(2, "stream buf addr: 0x%08lx, size: 0x%d", 445 mfc_debug(2, "stream buf addr: 0x%08lx, size: 0x%d\n",
453 addr, size); 446 addr, size);
454 447
455 return 0; 448 return 0;
456} 449}
@@ -463,8 +456,8 @@ static void s5p_mfc_set_enc_frame_buffer_v6(struct s5p_mfc_ctx *ctx,
463 WRITEL(y_addr, S5P_FIMV_E_SOURCE_LUMA_ADDR_V6); /* 256B align */ 456 WRITEL(y_addr, S5P_FIMV_E_SOURCE_LUMA_ADDR_V6); /* 256B align */
464 WRITEL(c_addr, S5P_FIMV_E_SOURCE_CHROMA_ADDR_V6); 457 WRITEL(c_addr, S5P_FIMV_E_SOURCE_CHROMA_ADDR_V6);
465 458
466 mfc_debug(2, "enc src y buf addr: 0x%08lx", y_addr); 459 mfc_debug(2, "enc src y buf addr: 0x%08lx\n", y_addr);
467 mfc_debug(2, "enc src c buf addr: 0x%08lx", c_addr); 460 mfc_debug(2, "enc src c buf addr: 0x%08lx\n", c_addr);
468} 461}
469 462
470static void s5p_mfc_get_enc_frame_buffer_v6(struct s5p_mfc_ctx *ctx, 463static void s5p_mfc_get_enc_frame_buffer_v6(struct s5p_mfc_ctx *ctx,
@@ -479,8 +472,8 @@ static void s5p_mfc_get_enc_frame_buffer_v6(struct s5p_mfc_ctx *ctx,
479 enc_recon_y_addr = READL(S5P_FIMV_E_RECON_LUMA_DPB_ADDR_V6); 472 enc_recon_y_addr = READL(S5P_FIMV_E_RECON_LUMA_DPB_ADDR_V6);
480 enc_recon_c_addr = READL(S5P_FIMV_E_RECON_CHROMA_DPB_ADDR_V6); 473 enc_recon_c_addr = READL(S5P_FIMV_E_RECON_CHROMA_DPB_ADDR_V6);
481 474
482 mfc_debug(2, "recon y addr: 0x%08lx", enc_recon_y_addr); 475 mfc_debug(2, "recon y addr: 0x%08lx\n", enc_recon_y_addr);
483 mfc_debug(2, "recon c addr: 0x%08lx", enc_recon_c_addr); 476 mfc_debug(2, "recon c addr: 0x%08lx\n", enc_recon_c_addr);
484} 477}
485 478
486/* Set encoding ref & codec buffer */ 479/* Set encoding ref & codec buffer */
@@ -497,7 +490,7 @@ static int s5p_mfc_set_enc_ref_buffer_v6(struct s5p_mfc_ctx *ctx)
497 490
498 mfc_debug(2, "Buf1: %p (%d)\n", (void *)buf_addr1, buf_size1); 491 mfc_debug(2, "Buf1: %p (%d)\n", (void *)buf_addr1, buf_size1);
499 492
500 for (i = 0; i < ctx->dpb_count; i++) { 493 for (i = 0; i < ctx->pb_count; i++) {
501 WRITEL(buf_addr1, S5P_FIMV_E_LUMA_DPB_V6 + (4 * i)); 494 WRITEL(buf_addr1, S5P_FIMV_E_LUMA_DPB_V6 + (4 * i));
502 buf_addr1 += ctx->luma_dpb_size; 495 buf_addr1 += ctx->luma_dpb_size;
503 WRITEL(buf_addr1, S5P_FIMV_E_CHROMA_DPB_V6 + (4 * i)); 496 WRITEL(buf_addr1, S5P_FIMV_E_CHROMA_DPB_V6 + (4 * i));
@@ -520,7 +513,7 @@ static int s5p_mfc_set_enc_ref_buffer_v6(struct s5p_mfc_ctx *ctx)
520 buf_size1 -= ctx->tmv_buffer_size; 513 buf_size1 -= ctx->tmv_buffer_size;
521 514
522 mfc_debug(2, "Buf1: %u, buf_size1: %d (ref frames %d)\n", 515 mfc_debug(2, "Buf1: %u, buf_size1: %d (ref frames %d)\n",
523 buf_addr1, buf_size1, ctx->dpb_count); 516 buf_addr1, buf_size1, ctx->pb_count);
524 if (buf_size1 < 0) { 517 if (buf_size1 < 0) {
525 mfc_debug(2, "Not enough memory has been allocated.\n"); 518 mfc_debug(2, "Not enough memory has been allocated.\n");
526 return -ENOMEM; 519 return -ENOMEM;
@@ -1431,8 +1424,8 @@ static inline int s5p_mfc_run_enc_frame(struct s5p_mfc_ctx *ctx)
1431 src_y_addr = vb2_dma_contig_plane_dma_addr(src_mb->b, 0); 1424 src_y_addr = vb2_dma_contig_plane_dma_addr(src_mb->b, 0);
1432 src_c_addr = vb2_dma_contig_plane_dma_addr(src_mb->b, 1); 1425 src_c_addr = vb2_dma_contig_plane_dma_addr(src_mb->b, 1);
1433 1426
1434 mfc_debug(2, "enc src y addr: 0x%08lx", src_y_addr); 1427 mfc_debug(2, "enc src y addr: 0x%08lx\n", src_y_addr);
1435 mfc_debug(2, "enc src c addr: 0x%08lx", src_c_addr); 1428 mfc_debug(2, "enc src c addr: 0x%08lx\n", src_c_addr);
1436 1429
1437 s5p_mfc_set_enc_frame_buffer_v6(ctx, src_y_addr, src_c_addr); 1430 s5p_mfc_set_enc_frame_buffer_v6(ctx, src_y_addr, src_c_addr);
1438 1431
@@ -1522,22 +1515,6 @@ static inline int s5p_mfc_run_init_enc_buffers(struct s5p_mfc_ctx *ctx)
1522 struct s5p_mfc_dev *dev = ctx->dev; 1515 struct s5p_mfc_dev *dev = ctx->dev;
1523 int ret; 1516 int ret;
1524 1517
1525 ret = s5p_mfc_alloc_codec_buffers_v6(ctx);
1526 if (ret) {
1527 mfc_err("Failed to allocate encoding buffers.\n");
1528 return -ENOMEM;
1529 }
1530
1531 /* Header was generated now starting processing
1532 * First set the reference frame buffers
1533 */
1534 if (ctx->capture_state != QUEUE_BUFS_REQUESTED) {
1535 mfc_err("It seems that destionation buffers were not\n"
1536 "requested.MFC requires that header should be generated\n"
1537 "before allocating codec buffer.\n");
1538 return -EAGAIN;
1539 }
1540
1541 dev->curr_ctx = ctx->num; 1518 dev->curr_ctx = ctx->num;
1542 s5p_mfc_clean_ctx_int_flags(ctx); 1519 s5p_mfc_clean_ctx_int_flags(ctx);
1543 ret = s5p_mfc_set_enc_ref_buffer_v6(ctx); 1520 ret = s5p_mfc_set_enc_ref_buffer_v6(ctx);
@@ -1582,7 +1559,7 @@ static void s5p_mfc_try_run_v6(struct s5p_mfc_dev *dev)
1582 mfc_debug(1, "Seting new context to %p\n", ctx); 1559 mfc_debug(1, "Seting new context to %p\n", ctx);
1583 /* Got context to run in ctx */ 1560 /* Got context to run in ctx */
1584 mfc_debug(1, "ctx->dst_queue_cnt=%d ctx->dpb_count=%d ctx->src_queue_cnt=%d\n", 1561 mfc_debug(1, "ctx->dst_queue_cnt=%d ctx->dpb_count=%d ctx->src_queue_cnt=%d\n",
1585 ctx->dst_queue_cnt, ctx->dpb_count, ctx->src_queue_cnt); 1562 ctx->dst_queue_cnt, ctx->pb_count, ctx->src_queue_cnt);
1586 mfc_debug(1, "ctx->state=%d\n", ctx->state); 1563 mfc_debug(1, "ctx->state=%d\n", ctx->state);
1587 /* Last frame has already been sent to MFC 1564 /* Last frame has already been sent to MFC
1588 * Now obtaining frames from MFC buffer */ 1565 * Now obtaining frames from MFC buffer */
@@ -1647,7 +1624,7 @@ static void s5p_mfc_try_run_v6(struct s5p_mfc_dev *dev)
1647 case MFCINST_GOT_INST: 1624 case MFCINST_GOT_INST:
1648 s5p_mfc_run_init_enc(ctx); 1625 s5p_mfc_run_init_enc(ctx);
1649 break; 1626 break;
1650 case MFCINST_HEAD_PARSED: /* Only for MFC6.x */ 1627 case MFCINST_HEAD_PRODUCED:
1651 ret = s5p_mfc_run_init_enc_buffers(ctx); 1628 ret = s5p_mfc_run_init_enc_buffers(ctx);
1652 break; 1629 break;
1653 default: 1630 default:
@@ -1730,7 +1707,7 @@ static int s5p_mfc_get_dspl_status_v6(struct s5p_mfc_dev *dev)
1730 return mfc_read(dev, S5P_FIMV_D_DISPLAY_STATUS_V6); 1707 return mfc_read(dev, S5P_FIMV_D_DISPLAY_STATUS_V6);
1731} 1708}
1732 1709
1733static int s5p_mfc_get_decoded_status_v6(struct s5p_mfc_dev *dev) 1710static int s5p_mfc_get_dec_status_v6(struct s5p_mfc_dev *dev)
1734{ 1711{
1735 return mfc_read(dev, S5P_FIMV_D_DECODED_STATUS_V6); 1712 return mfc_read(dev, S5P_FIMV_D_DECODED_STATUS_V6);
1736} 1713}
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
index 6aa38a56aaf2..11d5f1dada32 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
@@ -50,19 +50,6 @@ int s5p_mfc_init_pm(struct s5p_mfc_dev *dev)
50 goto err_p_ip_clk; 50 goto err_p_ip_clk;
51 } 51 }
52 52
53 pm->clock = clk_get(&dev->plat_dev->dev, dev->variant->mclk_name);
54 if (IS_ERR(pm->clock)) {
55 mfc_err("Failed to get MFC clock\n");
56 ret = PTR_ERR(pm->clock);
57 goto err_g_ip_clk_2;
58 }
59
60 ret = clk_prepare(pm->clock);
61 if (ret) {
62 mfc_err("Failed to prepare MFC clock\n");
63 goto err_p_ip_clk_2;
64 }
65
66 atomic_set(&pm->power, 0); 53 atomic_set(&pm->power, 0);
67#ifdef CONFIG_PM_RUNTIME 54#ifdef CONFIG_PM_RUNTIME
68 pm->device = &dev->plat_dev->dev; 55 pm->device = &dev->plat_dev->dev;
@@ -72,10 +59,6 @@ int s5p_mfc_init_pm(struct s5p_mfc_dev *dev)
72 atomic_set(&clk_ref, 0); 59 atomic_set(&clk_ref, 0);
73#endif 60#endif
74 return 0; 61 return 0;
75err_p_ip_clk_2:
76 clk_put(pm->clock);
77err_g_ip_clk_2:
78 clk_unprepare(pm->clock_gate);
79err_p_ip_clk: 62err_p_ip_clk:
80 clk_put(pm->clock_gate); 63 clk_put(pm->clock_gate);
81err_g_ip_clk: 64err_g_ip_clk:
@@ -86,8 +69,6 @@ void s5p_mfc_final_pm(struct s5p_mfc_dev *dev)
86{ 69{
87 clk_unprepare(pm->clock_gate); 70 clk_unprepare(pm->clock_gate);
88 clk_put(pm->clock_gate); 71 clk_put(pm->clock_gate);
89 clk_unprepare(pm->clock);
90 clk_put(pm->clock);
91#ifdef CONFIG_PM_RUNTIME 72#ifdef CONFIG_PM_RUNTIME
92 pm_runtime_disable(pm->device); 73 pm_runtime_disable(pm->device);
93#endif 74#endif
@@ -98,7 +79,7 @@ int s5p_mfc_clock_on(void)
98 int ret; 79 int ret;
99#ifdef CLK_DEBUG 80#ifdef CLK_DEBUG
100 atomic_inc(&clk_ref); 81 atomic_inc(&clk_ref);
101 mfc_debug(3, "+ %d", atomic_read(&clk_ref)); 82 mfc_debug(3, "+ %d\n", atomic_read(&clk_ref));
102#endif 83#endif
103 ret = clk_enable(pm->clock_gate); 84 ret = clk_enable(pm->clock_gate);
104 return ret; 85 return ret;
@@ -108,7 +89,7 @@ void s5p_mfc_clock_off(void)
108{ 89{
109#ifdef CLK_DEBUG 90#ifdef CLK_DEBUG
110 atomic_dec(&clk_ref); 91 atomic_dec(&clk_ref);
111 mfc_debug(3, "- %d", atomic_read(&clk_ref)); 92 mfc_debug(3, "- %d\n", atomic_read(&clk_ref));
112#endif 93#endif
113 clk_disable(pm->clock_gate); 94 clk_disable(pm->clock_gate);
114} 95}
diff --git a/drivers/media/platform/sh_veu.c b/drivers/media/platform/sh_veu.c
index 0b32cc3f6a47..59a9deefb242 100644
--- a/drivers/media/platform/sh_veu.c
+++ b/drivers/media/platform/sh_veu.c
@@ -905,11 +905,11 @@ static int sh_veu_queue_setup(struct vb2_queue *vq,
905 if (ftmp.fmt.pix.width != pix->width || 905 if (ftmp.fmt.pix.width != pix->width ||
906 ftmp.fmt.pix.height != pix->height) 906 ftmp.fmt.pix.height != pix->height)
907 return -EINVAL; 907 return -EINVAL;
908 size = pix->bytesperline ? pix->bytesperline * pix->height : 908 size = pix->bytesperline ? pix->bytesperline * pix->height * fmt->depth / fmt->ydepth :
909 pix->width * pix->height * fmt->depth >> 3; 909 pix->width * pix->height * fmt->depth / fmt->ydepth;
910 } else { 910 } else {
911 vfmt = sh_veu_get_vfmt(veu, vq->type); 911 vfmt = sh_veu_get_vfmt(veu, vq->type);
912 size = vfmt->bytesperline * vfmt->frame.height; 912 size = vfmt->bytesperline * vfmt->frame.height * vfmt->fmt->depth / vfmt->fmt->ydepth;
913 } 913 }
914 914
915 if (count < 2) 915 if (count < 2)
@@ -1033,8 +1033,6 @@ static int sh_veu_release(struct file *file)
1033 1033
1034 dev_dbg(veu->dev, "Releasing instance %p\n", veu_file); 1034 dev_dbg(veu->dev, "Releasing instance %p\n", veu_file);
1035 1035
1036 pm_runtime_put(veu->dev);
1037
1038 if (veu_file == veu->capture) { 1036 if (veu_file == veu->capture) {
1039 veu->capture = NULL; 1037 veu->capture = NULL;
1040 vb2_queue_release(v4l2_m2m_get_vq(veu->m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE)); 1038 vb2_queue_release(v4l2_m2m_get_vq(veu->m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE));
@@ -1050,6 +1048,8 @@ static int sh_veu_release(struct file *file)
1050 veu->m2m_ctx = NULL; 1048 veu->m2m_ctx = NULL;
1051 } 1049 }
1052 1050
1051 pm_runtime_put(veu->dev);
1052
1053 kfree(veu_file); 1053 kfree(veu_file);
1054 1054
1055 return 0; 1055 return 0;
@@ -1138,10 +1138,7 @@ static irqreturn_t sh_veu_isr(int irq, void *dev_id)
1138 1138
1139 veu->xaction++; 1139 veu->xaction++;
1140 1140
1141 if (!veu->aborting) 1141 return IRQ_WAKE_THREAD;
1142 return IRQ_WAKE_THREAD;
1143
1144 return IRQ_HANDLED;
1145} 1142}
1146 1143
1147static int sh_veu_probe(struct platform_device *pdev) 1144static int sh_veu_probe(struct platform_device *pdev)
diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index eea832c5fd01..3a4efbdc7668 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -643,9 +643,9 @@ static int soc_camera_close(struct file *file)
643 643
644 if (ici->ops->init_videobuf2) 644 if (ici->ops->init_videobuf2)
645 vb2_queue_release(&icd->vb2_vidq); 645 vb2_queue_release(&icd->vb2_vidq);
646 ici->ops->remove(icd);
647
648 __soc_camera_power_off(icd); 646 __soc_camera_power_off(icd);
647
648 ici->ops->remove(icd);
649 } 649 }
650 650
651 if (icd->streamer == file) 651 if (icd->streamer == file)
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index c0beee2fa37c..d529ba788f41 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -22,6 +22,7 @@ config RADIO_SI476X
22 tristate "Silicon Laboratories Si476x I2C FM Radio" 22 tristate "Silicon Laboratories Si476x I2C FM Radio"
23 depends on I2C && VIDEO_V4L2 23 depends on I2C && VIDEO_V4L2
24 depends on MFD_SI476X_CORE 24 depends on MFD_SI476X_CORE
25 depends on SND_SOC
25 select SND_SOC_SI476X 26 select SND_SOC_SI476X
26 ---help--- 27 ---help---
27 Choose Y here if you have this FM radio chip. 28 Choose Y here if you have this FM radio chip.
diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
index 9430c6a29937..9dc8bafe6486 100644
--- a/drivers/media/radio/radio-si476x.c
+++ b/drivers/media/radio/radio-si476x.c
@@ -44,7 +44,7 @@
44 44
45#define FREQ_MUL (10000000 / 625) 45#define FREQ_MUL (10000000 / 625)
46 46
47#define SI476X_PHDIV_STATUS_LINK_LOCKED(status) (0b10000000 & (status)) 47#define SI476X_PHDIV_STATUS_LINK_LOCKED(status) (0x80 & (status))
48 48
49#define DRIVER_NAME "si476x-radio" 49#define DRIVER_NAME "si476x-radio"
50#define DRIVER_CARD "SI476x AM/FM Receiver" 50#define DRIVER_CARD "SI476x AM/FM Receiver"
diff --git a/drivers/media/usb/gspca/sonixb.c b/drivers/media/usb/gspca/sonixb.c
index 3fe207e038c7..d7ff3b9687c5 100644
--- a/drivers/media/usb/gspca/sonixb.c
+++ b/drivers/media/usb/gspca/sonixb.c
@@ -1159,6 +1159,13 @@ static int sd_start(struct gspca_dev *gspca_dev)
1159 regs[0x01] = 0x44; /* Select 24 Mhz clock */ 1159 regs[0x01] = 0x44; /* Select 24 Mhz clock */
1160 regs[0x12] = 0x02; /* Set hstart to 2 */ 1160 regs[0x12] = 0x02; /* Set hstart to 2 */
1161 } 1161 }
1162 break;
1163 case SENSOR_PAS202:
1164 /* For some unknown reason we need to increase hstart by 1 on
1165 the sn9c103, otherwise we get wrong colors (bayer shift). */
1166 if (sd->bridge == BRIDGE_103)
1167 regs[0x12] += 1;
1168 break;
1162 } 1169 }
1163 /* Disable compression when the raw bayer format has been selected */ 1170 /* Disable compression when the raw bayer format has been selected */
1164 if (cam->cam_mode[gspca_dev->curr_mode].priv & MODE_RAW) 1171 if (cam->cam_mode[gspca_dev->curr_mode].priv & MODE_RAW)
diff --git a/drivers/media/usb/pwc/pwc.h b/drivers/media/usb/pwc/pwc.h
index 7a6a0d39c2c6..81b017a554bc 100644
--- a/drivers/media/usb/pwc/pwc.h
+++ b/drivers/media/usb/pwc/pwc.h
@@ -226,7 +226,7 @@ struct pwc_device
226 struct list_head queued_bufs; 226 struct list_head queued_bufs;
227 spinlock_t queued_bufs_lock; /* Protects queued_bufs */ 227 spinlock_t queued_bufs_lock; /* Protects queued_bufs */
228 228
229 /* Note if taking both locks v4l2_lock must always be locked first! */ 229 /* If taking both locks vb_queue_lock must always be locked first! */
230 struct mutex v4l2_lock; /* Protects everything else */ 230 struct mutex v4l2_lock; /* Protects everything else */
231 struct mutex vb_queue_lock; /* Protects vb_queue and capt_file */ 231 struct mutex vb_queue_lock; /* Protects vb_queue and capt_file */
232 232
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index ebb8e48619a2..fccd08b66d1a 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1835,6 +1835,8 @@ bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl)
1835{ 1835{
1836 if (V4L2_CTRL_ID2CLASS(ctrl->id) == V4L2_CTRL_CLASS_FM_TX) 1836 if (V4L2_CTRL_ID2CLASS(ctrl->id) == V4L2_CTRL_CLASS_FM_TX)
1837 return true; 1837 return true;
1838 if (V4L2_CTRL_ID2CLASS(ctrl->id) == V4L2_CTRL_CLASS_FM_RX)
1839 return true;
1838 switch (ctrl->id) { 1840 switch (ctrl->id) {
1839 case V4L2_CID_AUDIO_MUTE: 1841 case V4L2_CID_AUDIO_MUTE:
1840 case V4L2_CID_AUDIO_VOLUME: 1842 case V4L2_CID_AUDIO_VOLUME:
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index f81bda1a48ec..7658586fe5f4 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -243,7 +243,6 @@ static void v4l_print_format(const void *arg, bool write_only)
243 const struct v4l2_vbi_format *vbi; 243 const struct v4l2_vbi_format *vbi;
244 const struct v4l2_sliced_vbi_format *sliced; 244 const struct v4l2_sliced_vbi_format *sliced;
245 const struct v4l2_window *win; 245 const struct v4l2_window *win;
246 const struct v4l2_clip *clip;
247 unsigned i; 246 unsigned i;
248 247
249 pr_cont("type=%s", prt_names(p->type, v4l2_type_names)); 248 pr_cont("type=%s", prt_names(p->type, v4l2_type_names));
@@ -253,7 +252,7 @@ static void v4l_print_format(const void *arg, bool write_only)
253 pix = &p->fmt.pix; 252 pix = &p->fmt.pix;
254 pr_cont(", width=%u, height=%u, " 253 pr_cont(", width=%u, height=%u, "
255 "pixelformat=%c%c%c%c, field=%s, " 254 "pixelformat=%c%c%c%c, field=%s, "
256 "bytesperline=%u sizeimage=%u, colorspace=%d\n", 255 "bytesperline=%u, sizeimage=%u, colorspace=%d\n",
257 pix->width, pix->height, 256 pix->width, pix->height,
258 (pix->pixelformat & 0xff), 257 (pix->pixelformat & 0xff),
259 (pix->pixelformat >> 8) & 0xff, 258 (pix->pixelformat >> 8) & 0xff,
@@ -284,20 +283,14 @@ static void v4l_print_format(const void *arg, bool write_only)
284 case V4L2_BUF_TYPE_VIDEO_OVERLAY: 283 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
285 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: 284 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
286 win = &p->fmt.win; 285 win = &p->fmt.win;
287 pr_cont(", wxh=%dx%d, x,y=%d,%d, field=%s, " 286 /* Note: we can't print the clip list here since the clips
288 "chromakey=0x%08x, bitmap=%p, " 287 * pointer is a userspace pointer, not a kernelspace
289 "global_alpha=0x%02x\n", 288 * pointer. */
290 win->w.width, win->w.height, 289 pr_cont(", wxh=%dx%d, x,y=%d,%d, field=%s, chromakey=0x%08x, clipcount=%u, clips=%p, bitmap=%p, global_alpha=0x%02x\n",
291 win->w.left, win->w.top, 290 win->w.width, win->w.height, win->w.left, win->w.top,
292 prt_names(win->field, v4l2_field_names), 291 prt_names(win->field, v4l2_field_names),
293 win->chromakey, win->bitmap, win->global_alpha); 292 win->chromakey, win->clipcount, win->clips,
294 clip = win->clips; 293 win->bitmap, win->global_alpha);
295 for (i = 0; i < win->clipcount; i++) {
296 printk(KERN_DEBUG "clip %u: wxh=%dx%d, x,y=%d,%d\n",
297 i, clip->c.width, clip->c.height,
298 clip->c.left, clip->c.top);
299 clip = clip->next;
300 }
301 break; 294 break;
302 case V4L2_BUF_TYPE_VBI_CAPTURE: 295 case V4L2_BUF_TYPE_VBI_CAPTURE:
303 case V4L2_BUF_TYPE_VBI_OUTPUT: 296 case V4L2_BUF_TYPE_VBI_OUTPUT:
@@ -332,7 +325,7 @@ static void v4l_print_framebuffer(const void *arg, bool write_only)
332 325
333 pr_cont("capability=0x%x, flags=0x%x, base=0x%p, width=%u, " 326 pr_cont("capability=0x%x, flags=0x%x, base=0x%p, width=%u, "
334 "height=%u, pixelformat=%c%c%c%c, " 327 "height=%u, pixelformat=%c%c%c%c, "
335 "bytesperline=%u sizeimage=%u, colorspace=%d\n", 328 "bytesperline=%u, sizeimage=%u, colorspace=%d\n",
336 p->capability, p->flags, p->base, 329 p->capability, p->flags, p->base,
337 p->fmt.width, p->fmt.height, 330 p->fmt.width, p->fmt.height,
338 (p->fmt.pixelformat & 0xff), 331 (p->fmt.pixelformat & 0xff),
@@ -353,7 +346,7 @@ static void v4l_print_modulator(const void *arg, bool write_only)
353 const struct v4l2_modulator *p = arg; 346 const struct v4l2_modulator *p = arg;
354 347
355 if (write_only) 348 if (write_only)
356 pr_cont("index=%u, txsubchans=0x%x", p->index, p->txsubchans); 349 pr_cont("index=%u, txsubchans=0x%x\n", p->index, p->txsubchans);
357 else 350 else
358 pr_cont("index=%u, name=%.*s, capability=0x%x, " 351 pr_cont("index=%u, name=%.*s, capability=0x%x, "
359 "rangelow=%u, rangehigh=%u, txsubchans=0x%x\n", 352 "rangelow=%u, rangehigh=%u, txsubchans=0x%x\n",
@@ -445,13 +438,13 @@ static void v4l_print_buffer(const void *arg, bool write_only)
445 for (i = 0; i < p->length; ++i) { 438 for (i = 0; i < p->length; ++i) {
446 plane = &p->m.planes[i]; 439 plane = &p->m.planes[i];
447 printk(KERN_DEBUG 440 printk(KERN_DEBUG
448 "plane %d: bytesused=%d, data_offset=0x%08x " 441 "plane %d: bytesused=%d, data_offset=0x%08x, "
449 "offset/userptr=0x%lx, length=%d\n", 442 "offset/userptr=0x%lx, length=%d\n",
450 i, plane->bytesused, plane->data_offset, 443 i, plane->bytesused, plane->data_offset,
451 plane->m.userptr, plane->length); 444 plane->m.userptr, plane->length);
452 } 445 }
453 } else { 446 } else {
454 pr_cont("bytesused=%d, offset/userptr=0x%lx, length=%d\n", 447 pr_cont(", bytesused=%d, offset/userptr=0x%lx, length=%d\n",
455 p->bytesused, p->m.userptr, p->length); 448 p->bytesused, p->m.userptr, p->length);
456 } 449 }
457 450
@@ -504,6 +497,8 @@ static void v4l_print_streamparm(const void *arg, bool write_only)
504 c->capability, c->outputmode, 497 c->capability, c->outputmode,
505 c->timeperframe.numerator, c->timeperframe.denominator, 498 c->timeperframe.numerator, c->timeperframe.denominator,
506 c->extendedmode, c->writebuffers); 499 c->extendedmode, c->writebuffers);
500 } else {
501 pr_cont("\n");
507 } 502 }
508} 503}
509 504
@@ -734,11 +729,11 @@ static void v4l_print_frmsizeenum(const void *arg, bool write_only)
734 p->type); 729 p->type);
735 switch (p->type) { 730 switch (p->type) {
736 case V4L2_FRMSIZE_TYPE_DISCRETE: 731 case V4L2_FRMSIZE_TYPE_DISCRETE:
737 pr_cont(" wxh=%ux%u\n", 732 pr_cont(", wxh=%ux%u\n",
738 p->discrete.width, p->discrete.height); 733 p->discrete.width, p->discrete.height);
739 break; 734 break;
740 case V4L2_FRMSIZE_TYPE_STEPWISE: 735 case V4L2_FRMSIZE_TYPE_STEPWISE:
741 pr_cont(" min=%ux%u, max=%ux%u, step=%ux%u\n", 736 pr_cont(", min=%ux%u, max=%ux%u, step=%ux%u\n",
742 p->stepwise.min_width, p->stepwise.min_height, 737 p->stepwise.min_width, p->stepwise.min_height,
743 p->stepwise.step_width, p->stepwise.step_height, 738 p->stepwise.step_width, p->stepwise.step_height,
744 p->stepwise.max_width, p->stepwise.max_height); 739 p->stepwise.max_width, p->stepwise.max_height);
@@ -764,12 +759,12 @@ static void v4l_print_frmivalenum(const void *arg, bool write_only)
764 p->width, p->height, p->type); 759 p->width, p->height, p->type);
765 switch (p->type) { 760 switch (p->type) {
766 case V4L2_FRMIVAL_TYPE_DISCRETE: 761 case V4L2_FRMIVAL_TYPE_DISCRETE:
767 pr_cont(" fps=%d/%d\n", 762 pr_cont(", fps=%d/%d\n",
768 p->discrete.numerator, 763 p->discrete.numerator,
769 p->discrete.denominator); 764 p->discrete.denominator);
770 break; 765 break;
771 case V4L2_FRMIVAL_TYPE_STEPWISE: 766 case V4L2_FRMIVAL_TYPE_STEPWISE:
772 pr_cont(" min=%d/%d, max=%d/%d, step=%d/%d\n", 767 pr_cont(", min=%d/%d, max=%d/%d, step=%d/%d\n",
773 p->stepwise.min.numerator, 768 p->stepwise.min.numerator,
774 p->stepwise.min.denominator, 769 p->stepwise.min.denominator,
775 p->stepwise.max.numerator, 770 p->stepwise.max.numerator,
@@ -807,8 +802,8 @@ static void v4l_print_event(const void *arg, bool write_only)
807 pr_cont("value64=%lld, ", c->value64); 802 pr_cont("value64=%lld, ", c->value64);
808 else 803 else
809 pr_cont("value=%d, ", c->value); 804 pr_cont("value=%d, ", c->value);
810 pr_cont("flags=0x%x, minimum=%d, maximum=%d, step=%d," 805 pr_cont("flags=0x%x, minimum=%d, maximum=%d, step=%d, "
811 " default_value=%d\n", 806 "default_value=%d\n",
812 c->flags, c->minimum, c->maximum, 807 c->flags, c->minimum, c->maximum,
813 c->step, c->default_value); 808 c->step, c->default_value);
814 break; 809 break;
@@ -845,7 +840,7 @@ static void v4l_print_freq_band(const void *arg, bool write_only)
845 const struct v4l2_frequency_band *p = arg; 840 const struct v4l2_frequency_band *p = arg;
846 841
847 pr_cont("tuner=%u, type=%u, index=%u, capability=0x%x, " 842 pr_cont("tuner=%u, type=%u, index=%u, capability=0x%x, "
848 "rangelow=%u, rangehigh=%u, modulation=0x%x\n", 843 "rangelow=%u, rangehigh=%u, modulation=0x%x\n",
849 p->tuner, p->type, p->index, 844 p->tuner, p->type, p->index,
850 p->capability, p->rangelow, 845 p->capability, p->rangelow,
851 p->rangehigh, p->modulation); 846 p->rangehigh, p->modulation);
diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c
index 66f599fcb829..e96497f7c3ed 100644
--- a/drivers/media/v4l2-core/v4l2-mem2mem.c
+++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
@@ -205,7 +205,7 @@ static void v4l2_m2m_try_run(struct v4l2_m2m_dev *m2m_dev)
205static void v4l2_m2m_try_schedule(struct v4l2_m2m_ctx *m2m_ctx) 205static void v4l2_m2m_try_schedule(struct v4l2_m2m_ctx *m2m_ctx)
206{ 206{
207 struct v4l2_m2m_dev *m2m_dev; 207 struct v4l2_m2m_dev *m2m_dev;
208 unsigned long flags_job, flags; 208 unsigned long flags_job, flags_out, flags_cap;
209 209
210 m2m_dev = m2m_ctx->m2m_dev; 210 m2m_dev = m2m_ctx->m2m_dev;
211 dprintk("Trying to schedule a job for m2m_ctx: %p\n", m2m_ctx); 211 dprintk("Trying to schedule a job for m2m_ctx: %p\n", m2m_ctx);
@@ -223,23 +223,26 @@ static void v4l2_m2m_try_schedule(struct v4l2_m2m_ctx *m2m_ctx)
223 return; 223 return;
224 } 224 }
225 225
226 spin_lock_irqsave(&m2m_ctx->out_q_ctx.rdy_spinlock, flags); 226 spin_lock_irqsave(&m2m_ctx->out_q_ctx.rdy_spinlock, flags_out);
227 if (list_empty(&m2m_ctx->out_q_ctx.rdy_queue)) { 227 if (list_empty(&m2m_ctx->out_q_ctx.rdy_queue)) {
228 spin_unlock_irqrestore(&m2m_ctx->out_q_ctx.rdy_spinlock, flags); 228 spin_unlock_irqrestore(&m2m_ctx->out_q_ctx.rdy_spinlock,
229 flags_out);
229 spin_unlock_irqrestore(&m2m_dev->job_spinlock, flags_job); 230 spin_unlock_irqrestore(&m2m_dev->job_spinlock, flags_job);
230 dprintk("No input buffers available\n"); 231 dprintk("No input buffers available\n");
231 return; 232 return;
232 } 233 }
233 spin_lock_irqsave(&m2m_ctx->cap_q_ctx.rdy_spinlock, flags); 234 spin_lock_irqsave(&m2m_ctx->cap_q_ctx.rdy_spinlock, flags_cap);
234 if (list_empty(&m2m_ctx->cap_q_ctx.rdy_queue)) { 235 if (list_empty(&m2m_ctx->cap_q_ctx.rdy_queue)) {
235 spin_unlock_irqrestore(&m2m_ctx->cap_q_ctx.rdy_spinlock, flags); 236 spin_unlock_irqrestore(&m2m_ctx->cap_q_ctx.rdy_spinlock,
236 spin_unlock_irqrestore(&m2m_ctx->out_q_ctx.rdy_spinlock, flags); 237 flags_cap);
238 spin_unlock_irqrestore(&m2m_ctx->out_q_ctx.rdy_spinlock,
239 flags_out);
237 spin_unlock_irqrestore(&m2m_dev->job_spinlock, flags_job); 240 spin_unlock_irqrestore(&m2m_dev->job_spinlock, flags_job);
238 dprintk("No output buffers available\n"); 241 dprintk("No output buffers available\n");
239 return; 242 return;
240 } 243 }
241 spin_unlock_irqrestore(&m2m_ctx->cap_q_ctx.rdy_spinlock, flags); 244 spin_unlock_irqrestore(&m2m_ctx->cap_q_ctx.rdy_spinlock, flags_cap);
242 spin_unlock_irqrestore(&m2m_ctx->out_q_ctx.rdy_spinlock, flags); 245 spin_unlock_irqrestore(&m2m_ctx->out_q_ctx.rdy_spinlock, flags_out);
243 246
244 if (m2m_dev->m2m_ops->job_ready 247 if (m2m_dev->m2m_ops->job_ready
245 && (!m2m_dev->m2m_ops->job_ready(m2m_ctx->priv))) { 248 && (!m2m_dev->m2m_ops->job_ready(m2m_ctx->priv))) {
@@ -372,6 +375,20 @@ int v4l2_m2m_dqbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
372EXPORT_SYMBOL_GPL(v4l2_m2m_dqbuf); 375EXPORT_SYMBOL_GPL(v4l2_m2m_dqbuf);
373 376
374/** 377/**
378 * v4l2_m2m_create_bufs() - create a source or destination buffer, depending
379 * on the type
380 */
381int v4l2_m2m_create_bufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
382 struct v4l2_create_buffers *create)
383{
384 struct vb2_queue *vq;
385
386 vq = v4l2_m2m_get_vq(m2m_ctx, create->format.type);
387 return vb2_create_bufs(vq, create);
388}
389EXPORT_SYMBOL_GPL(v4l2_m2m_create_bufs);
390
391/**
375 * v4l2_m2m_expbuf() - export a source or destination buffer, depending on 392 * v4l2_m2m_expbuf() - export a source or destination buffer, depending on
376 * the type 393 * the type
377 */ 394 */
@@ -486,8 +503,10 @@ unsigned int v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
486 if (m2m_ctx->m2m_dev->m2m_ops->unlock) 503 if (m2m_ctx->m2m_dev->m2m_ops->unlock)
487 m2m_ctx->m2m_dev->m2m_ops->unlock(m2m_ctx->priv); 504 m2m_ctx->m2m_dev->m2m_ops->unlock(m2m_ctx->priv);
488 505
489 poll_wait(file, &src_q->done_wq, wait); 506 if (list_empty(&src_q->done_list))
490 poll_wait(file, &dst_q->done_wq, wait); 507 poll_wait(file, &src_q->done_wq, wait);
508 if (list_empty(&dst_q->done_list))
509 poll_wait(file, &dst_q->done_wq, wait);
491 510
492 if (m2m_ctx->m2m_dev->m2m_ops->lock) 511 if (m2m_ctx->m2m_dev->m2m_ops->lock)
493 m2m_ctx->m2m_dev->m2m_ops->lock(m2m_ctx->priv); 512 m2m_ctx->m2m_dev->m2m_ops->lock(m2m_ctx->priv);
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index 7d833eefaf4e..e3bdc3be91e1 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -2014,7 +2014,8 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
2014 if (list_empty(&q->queued_list)) 2014 if (list_empty(&q->queued_list))
2015 return res | POLLERR; 2015 return res | POLLERR;
2016 2016
2017 poll_wait(file, &q->done_wq, wait); 2017 if (list_empty(&q->done_list))
2018 poll_wait(file, &q->done_wq, wait);
2018 2019
2019 /* 2020 /*
2020 * Take first buffer available for dequeuing. 2021 * Take first buffer available for dequeuing.
diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c
index 713d89fedc46..f580d30bb784 100644
--- a/drivers/misc/mei/init.c
+++ b/drivers/misc/mei/init.c
@@ -197,6 +197,8 @@ void mei_stop(struct mei_device *dev)
197{ 197{
198 dev_dbg(&dev->pdev->dev, "stopping the device.\n"); 198 dev_dbg(&dev->pdev->dev, "stopping the device.\n");
199 199
200 flush_scheduled_work();
201
200 mutex_lock(&dev->device_lock); 202 mutex_lock(&dev->device_lock);
201 203
202 cancel_delayed_work(&dev->timer_work); 204 cancel_delayed_work(&dev->timer_work);
@@ -210,8 +212,6 @@ void mei_stop(struct mei_device *dev)
210 212
211 mutex_unlock(&dev->device_lock); 213 mutex_unlock(&dev->device_lock);
212 214
213 flush_scheduled_work();
214
215 mei_watchdog_unregister(dev); 215 mei_watchdog_unregister(dev);
216} 216}
217EXPORT_SYMBOL_GPL(mei_stop); 217EXPORT_SYMBOL_GPL(mei_stop);
diff --git a/drivers/misc/mei/nfc.c b/drivers/misc/mei/nfc.c
index 3adf8a70f26e..d0c6907dfd92 100644
--- a/drivers/misc/mei/nfc.c
+++ b/drivers/misc/mei/nfc.c
@@ -142,6 +142,8 @@ static void mei_nfc_free(struct mei_nfc_dev *ndev)
142 mei_cl_unlink(ndev->cl_info); 142 mei_cl_unlink(ndev->cl_info);
143 kfree(ndev->cl_info); 143 kfree(ndev->cl_info);
144 } 144 }
145
146 memset(ndev, 0, sizeof(struct mei_nfc_dev));
145} 147}
146 148
147static int mei_nfc_build_bus_name(struct mei_nfc_dev *ndev) 149static int mei_nfc_build_bus_name(struct mei_nfc_dev *ndev)
diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c
index a727464e9c3f..0f268329bd3a 100644
--- a/drivers/misc/mei/pci-me.c
+++ b/drivers/misc/mei/pci-me.c
@@ -325,6 +325,7 @@ static int mei_me_pci_resume(struct device *device)
325 325
326 mutex_lock(&dev->device_lock); 326 mutex_lock(&dev->device_lock);
327 dev->dev_state = MEI_DEV_POWER_UP; 327 dev->dev_state = MEI_DEV_POWER_UP;
328 mei_clear_interrupts(dev);
328 mei_reset(dev, 1); 329 mei_reset(dev, 1);
329 mutex_unlock(&dev->device_lock); 330 mutex_unlock(&dev->device_lock);
330 331
diff --git a/drivers/misc/sgi-gru/grufile.c b/drivers/misc/sgi-gru/grufile.c
index 44d273c5e19d..0535d1e0bc78 100644
--- a/drivers/misc/sgi-gru/grufile.c
+++ b/drivers/misc/sgi-gru/grufile.c
@@ -172,6 +172,7 @@ static long gru_get_config_info(unsigned long arg)
172 nodesperblade = 2; 172 nodesperblade = 2;
173 else 173 else
174 nodesperblade = 1; 174 nodesperblade = 1;
175 memset(&info, 0, sizeof(info));
175 info.cpus = num_online_cpus(); 176 info.cpus = num_online_cpus();
176 info.nodes = num_online_nodes(); 177 info.nodes = num_online_nodes();
177 info.blades = info.nodes / nodesperblade; 178 info.blades = info.nodes / nodesperblade;
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 29b846cbfb48..02d9ae7d527e 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -764,8 +764,8 @@ static void bond_resend_igmp_join_requests(struct bonding *bond)
764 struct net_device *bond_dev, *vlan_dev, *upper_dev; 764 struct net_device *bond_dev, *vlan_dev, *upper_dev;
765 struct vlan_entry *vlan; 765 struct vlan_entry *vlan;
766 766
767 rcu_read_lock();
768 read_lock(&bond->lock); 767 read_lock(&bond->lock);
768 rcu_read_lock();
769 769
770 bond_dev = bond->dev; 770 bond_dev = bond->dev;
771 771
@@ -787,12 +787,19 @@ static void bond_resend_igmp_join_requests(struct bonding *bond)
787 if (vlan_dev) 787 if (vlan_dev)
788 __bond_resend_igmp_join_requests(vlan_dev); 788 __bond_resend_igmp_join_requests(vlan_dev);
789 } 789 }
790 rcu_read_unlock();
790 791
791 if (--bond->igmp_retrans > 0) 792 /* We use curr_slave_lock to protect against concurrent access to
793 * igmp_retrans from multiple running instances of this function and
794 * bond_change_active_slave
795 */
796 write_lock_bh(&bond->curr_slave_lock);
797 if (bond->igmp_retrans > 1) {
798 bond->igmp_retrans--;
792 queue_delayed_work(bond->wq, &bond->mcast_work, HZ/5); 799 queue_delayed_work(bond->wq, &bond->mcast_work, HZ/5);
793 800 }
801 write_unlock_bh(&bond->curr_slave_lock);
794 read_unlock(&bond->lock); 802 read_unlock(&bond->lock);
795 rcu_read_unlock();
796} 803}
797 804
798static void bond_resend_igmp_join_requests_delayed(struct work_struct *work) 805static void bond_resend_igmp_join_requests_delayed(struct work_struct *work)
@@ -1957,6 +1964,10 @@ err_free:
1957 1964
1958err_undo_flags: 1965err_undo_flags:
1959 bond_compute_features(bond); 1966 bond_compute_features(bond);
1967 /* Enslave of first slave has failed and we need to fix master's mac */
1968 if (bond->slave_cnt == 0 &&
1969 ether_addr_equal(bond_dev->dev_addr, slave_dev->dev_addr))
1970 eth_hw_addr_random(bond_dev);
1960 1971
1961 return res; 1972 return res;
1962} 1973}
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 2baec24388b1..f989e1529a29 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -225,7 +225,7 @@ struct bonding {
225 rwlock_t curr_slave_lock; 225 rwlock_t curr_slave_lock;
226 u8 send_peer_notif; 226 u8 send_peer_notif;
227 s8 setup_by_slave; 227 s8 setup_by_slave;
228 s8 igmp_retrans; 228 u8 igmp_retrans;
229#ifdef CONFIG_PROC_FS 229#ifdef CONFIG_PROC_FS
230 struct proc_dir_entry *proc_entry; 230 struct proc_dir_entry *proc_entry;
231 char proc_file_name[IFNAMSIZ]; 231 char proc_file_name[IFNAMSIZ];
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 0f493c8dc28b..c777b9013164 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -1800,6 +1800,9 @@ static int tg3_poll_fw(struct tg3 *tp)
1800 int i; 1800 int i;
1801 u32 val; 1801 u32 val;
1802 1802
1803 if (tg3_flag(tp, NO_FWARE_REPORTED))
1804 return 0;
1805
1803 if (tg3_flag(tp, IS_SSB_CORE)) { 1806 if (tg3_flag(tp, IS_SSB_CORE)) {
1804 /* We don't use firmware. */ 1807 /* We don't use firmware. */
1805 return 0; 1808 return 0;
@@ -10404,6 +10407,13 @@ static int tg3_reset_hw(struct tg3 *tp, bool reset_phy)
10404 */ 10407 */
10405static int tg3_init_hw(struct tg3 *tp, bool reset_phy) 10408static int tg3_init_hw(struct tg3 *tp, bool reset_phy)
10406{ 10409{
10410 /* Chip may have been just powered on. If so, the boot code may still
10411 * be running initialization. Wait for it to finish to avoid races in
10412 * accessing the hardware.
10413 */
10414 tg3_enable_register_access(tp);
10415 tg3_poll_fw(tp);
10416
10407 tg3_switch_clocks(tp); 10417 tg3_switch_clocks(tp);
10408 10418
10409 tw32(TG3PCI_MEM_WIN_BASE_ADDR, 0); 10419 tw32(TG3PCI_MEM_WIN_BASE_ADDR, 0);
diff --git a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
index 6e8bc9d88c41..94d957d203a6 100644
--- a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
+++ b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
@@ -244,7 +244,7 @@ bnad_debugfs_lseek(struct file *file, loff_t offset, int orig)
244 file->f_pos += offset; 244 file->f_pos += offset;
245 break; 245 break;
246 case 2: 246 case 2:
247 file->f_pos = debug->buffer_len - offset; 247 file->f_pos = debug->buffer_len + offset;
248 break; 248 break;
249 default: 249 default:
250 return -EINVAL; 250 return -EINVAL;
diff --git a/drivers/net/ethernet/dec/tulip/interrupt.c b/drivers/net/ethernet/dec/tulip/interrupt.c
index 28a5e425fecf..92306b320840 100644
--- a/drivers/net/ethernet/dec/tulip/interrupt.c
+++ b/drivers/net/ethernet/dec/tulip/interrupt.c
@@ -76,6 +76,12 @@ int tulip_refill_rx(struct net_device *dev)
76 76
77 mapping = pci_map_single(tp->pdev, skb->data, PKT_BUF_SZ, 77 mapping = pci_map_single(tp->pdev, skb->data, PKT_BUF_SZ,
78 PCI_DMA_FROMDEVICE); 78 PCI_DMA_FROMDEVICE);
79 if (dma_mapping_error(&tp->pdev->dev, mapping)) {
80 dev_kfree_skb(skb);
81 tp->rx_buffers[entry].skb = NULL;
82 break;
83 }
84
79 tp->rx_buffers[entry].mapping = mapping; 85 tp->rx_buffers[entry].mapping = mapping;
80 86
81 tp->rx_ring[entry].buffer1 = cpu_to_le32(mapping); 87 tp->rx_ring[entry].buffer1 = cpu_to_le32(mapping);
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 8bc1b21b1c79..a0b4be51f0d1 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -4262,6 +4262,9 @@ static int be_probe(struct pci_dev *pdev, const struct pci_device_id *pdev_id)
4262 netdev->features |= NETIF_F_HIGHDMA; 4262 netdev->features |= NETIF_F_HIGHDMA;
4263 } else { 4263 } else {
4264 status = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); 4264 status = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
4265 if (!status)
4266 status = dma_set_coherent_mask(&pdev->dev,
4267 DMA_BIT_MASK(32));
4265 if (status) { 4268 if (status) {
4266 dev_err(&pdev->dev, "Could not set PCI DMA Mask\n"); 4269 dev_err(&pdev->dev, "Could not set PCI DMA Mask\n");
4267 goto free_netdev; 4270 goto free_netdev;
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 42e9dd05c936..5e3982fc5398 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -897,8 +897,8 @@ static int sh_eth_check_reset(struct net_device *ndev)
897 mdelay(1); 897 mdelay(1);
898 cnt--; 898 cnt--;
899 } 899 }
900 if (cnt < 0) { 900 if (cnt <= 0) {
901 pr_err("Device reset fail\n"); 901 pr_err("Device reset failed\n");
902 ret = -ETIMEDOUT; 902 ret = -ETIMEDOUT;
903 } 903 }
904 return ret; 904 return ret;
@@ -1401,16 +1401,23 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status)
1401 desc_status = edmac_to_cpu(mdp, rxdesc->status); 1401 desc_status = edmac_to_cpu(mdp, rxdesc->status);
1402 pkt_len = rxdesc->frame_length; 1402 pkt_len = rxdesc->frame_length;
1403 1403
1404#if defined(CONFIG_ARCH_R8A7740)
1405 desc_status >>= 16;
1406#endif
1407
1408 if (--boguscnt < 0) 1404 if (--boguscnt < 0)
1409 break; 1405 break;
1410 1406
1411 if (!(desc_status & RDFEND)) 1407 if (!(desc_status & RDFEND))
1412 ndev->stats.rx_length_errors++; 1408 ndev->stats.rx_length_errors++;
1413 1409
1410#if defined(CONFIG_ARCH_R8A7740)
1411 /*
1412 * In case of almost all GETHER/ETHERs, the Receive Frame State
1413 * (RFS) bits in the Receive Descriptor 0 are from bit 9 to
1414 * bit 0. However, in case of the R8A7740's GETHER, the RFS
1415 * bits are from bit 25 to bit 16. So, the driver needs right
1416 * shifting by 16.
1417 */
1418 desc_status >>= 16;
1419#endif
1420
1414 if (desc_status & (RD_RFS1 | RD_RFS2 | RD_RFS3 | RD_RFS4 | 1421 if (desc_status & (RD_RFS1 | RD_RFS2 | RD_RFS3 | RD_RFS4 |
1415 RD_RFS5 | RD_RFS6 | RD_RFS10)) { 1422 RD_RFS5 | RD_RFS6 | RD_RFS10)) {
1416 ndev->stats.rx_errors++; 1423 ndev->stats.rx_errors++;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 618446ae1ec1..ee919ca8b8a0 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1899,7 +1899,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
1899 1899
1900#ifdef STMMAC_XMIT_DEBUG 1900#ifdef STMMAC_XMIT_DEBUG
1901 if (netif_msg_pktdata(priv)) { 1901 if (netif_msg_pktdata(priv)) {
1902 pr_info("%s: curr %d dirty=%d entry=%d, first=%p, nfrags=%d" 1902 pr_info("%s: curr %d dirty=%d entry=%d, first=%p, nfrags=%d",
1903 __func__, (priv->cur_tx % txsize), 1903 __func__, (priv->cur_tx % txsize),
1904 (priv->dirty_tx % txsize), entry, first, nfrags); 1904 (priv->dirty_tx % txsize), entry, first, nfrags);
1905 if (priv->extend_desc) 1905 if (priv->extend_desc)
diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
index 12aec173564c..c47f0dbcebb5 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -449,10 +449,9 @@ static int davinci_mdio_suspend(struct device *dev)
449 __raw_writel(ctrl, &data->regs->control); 449 __raw_writel(ctrl, &data->regs->control);
450 wait_for_idle(data); 450 wait_for_idle(data);
451 451
452 pm_runtime_put_sync(data->dev);
453
454 data->suspended = true; 452 data->suspended = true;
455 spin_unlock(&data->lock); 453 spin_unlock(&data->lock);
454 pm_runtime_put_sync(data->dev);
456 455
457 return 0; 456 return 0;
458} 457}
@@ -460,15 +459,12 @@ static int davinci_mdio_suspend(struct device *dev)
460static int davinci_mdio_resume(struct device *dev) 459static int davinci_mdio_resume(struct device *dev)
461{ 460{
462 struct davinci_mdio_data *data = dev_get_drvdata(dev); 461 struct davinci_mdio_data *data = dev_get_drvdata(dev);
463 u32 ctrl;
464 462
465 spin_lock(&data->lock);
466 pm_runtime_get_sync(data->dev); 463 pm_runtime_get_sync(data->dev);
467 464
465 spin_lock(&data->lock);
468 /* restart the scan state machine */ 466 /* restart the scan state machine */
469 ctrl = __raw_readl(&data->regs->control); 467 __davinci_mdio_reset(data);
470 ctrl |= CONTROL_ENABLE;
471 __raw_writel(ctrl, &data->regs->control);
472 468
473 data->suspended = false; 469 data->suspended = false;
474 spin_unlock(&data->lock); 470 spin_unlock(&data->lock);
@@ -477,8 +473,8 @@ static int davinci_mdio_resume(struct device *dev)
477} 473}
478 474
479static const struct dev_pm_ops davinci_mdio_pm_ops = { 475static const struct dev_pm_ops davinci_mdio_pm_ops = {
480 .suspend = davinci_mdio_suspend, 476 .suspend_late = davinci_mdio_suspend,
481 .resume = davinci_mdio_resume, 477 .resume_early = davinci_mdio_resume,
482}; 478};
483 479
484static const struct of_device_id davinci_mdio_of_mtable[] = { 480static const struct of_device_id davinci_mdio_of_mtable[] = {
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 1c502bb0c916..6e91931a1c2c 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -853,18 +853,24 @@ static int macvlan_changelink(struct net_device *dev,
853 struct nlattr *tb[], struct nlattr *data[]) 853 struct nlattr *tb[], struct nlattr *data[])
854{ 854{
855 struct macvlan_dev *vlan = netdev_priv(dev); 855 struct macvlan_dev *vlan = netdev_priv(dev);
856 if (data && data[IFLA_MACVLAN_MODE]) 856
857 vlan->mode = nla_get_u32(data[IFLA_MACVLAN_MODE]);
858 if (data && data[IFLA_MACVLAN_FLAGS]) { 857 if (data && data[IFLA_MACVLAN_FLAGS]) {
859 __u16 flags = nla_get_u16(data[IFLA_MACVLAN_FLAGS]); 858 __u16 flags = nla_get_u16(data[IFLA_MACVLAN_FLAGS]);
860 bool promisc = (flags ^ vlan->flags) & MACVLAN_FLAG_NOPROMISC; 859 bool promisc = (flags ^ vlan->flags) & MACVLAN_FLAG_NOPROMISC;
861 860 if (vlan->port->passthru && promisc) {
862 if (promisc && (flags & MACVLAN_FLAG_NOPROMISC)) 861 int err;
863 dev_set_promiscuity(vlan->lowerdev, -1); 862
864 else if (promisc && !(flags & MACVLAN_FLAG_NOPROMISC)) 863 if (flags & MACVLAN_FLAG_NOPROMISC)
865 dev_set_promiscuity(vlan->lowerdev, 1); 864 err = dev_set_promiscuity(vlan->lowerdev, -1);
865 else
866 err = dev_set_promiscuity(vlan->lowerdev, 1);
867 if (err < 0)
868 return err;
869 }
866 vlan->flags = flags; 870 vlan->flags = flags;
867 } 871 }
872 if (data && data[IFLA_MACVLAN_MODE])
873 vlan->mode = nla_get_u32(data[IFLA_MACVLAN_MODE]);
868 return 0; 874 return 0;
869} 875}
870 876
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index d016a76ad44b..b3051052f3ad 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -1092,8 +1092,8 @@ static int team_port_add(struct team *team, struct net_device *port_dev)
1092 } 1092 }
1093 1093
1094 port->index = -1; 1094 port->index = -1;
1095 team_port_enable(team, port);
1096 list_add_tail_rcu(&port->list, &team->port_list); 1095 list_add_tail_rcu(&port->list, &team->port_list);
1096 team_port_enable(team, port);
1097 __team_compute_features(team); 1097 __team_compute_features(team);
1098 __team_port_change_port_added(port, !!netif_carrier_ok(port_dev)); 1098 __team_port_change_port_added(port, !!netif_carrier_ok(port_dev));
1099 __team_options_change_check(team); 1099 __team_options_change_check(team);
diff --git a/drivers/net/team/team_mode_random.c b/drivers/net/team/team_mode_random.c
index 5ca14d463ba7..7f032e211343 100644
--- a/drivers/net/team/team_mode_random.c
+++ b/drivers/net/team/team_mode_random.c
@@ -28,6 +28,8 @@ static bool rnd_transmit(struct team *team, struct sk_buff *skb)
28 28
29 port_index = random_N(team->en_port_count); 29 port_index = random_N(team->en_port_count);
30 port = team_get_port_by_index_rcu(team, port_index); 30 port = team_get_port_by_index_rcu(team, port_index);
31 if (unlikely(!port))
32 goto drop;
31 port = team_get_first_port_txable_rcu(team, port); 33 port = team_get_first_port_txable_rcu(team, port);
32 if (unlikely(!port)) 34 if (unlikely(!port))
33 goto drop; 35 goto drop;
diff --git a/drivers/net/team/team_mode_roundrobin.c b/drivers/net/team/team_mode_roundrobin.c
index d268e4de781b..472623f8ce3d 100644
--- a/drivers/net/team/team_mode_roundrobin.c
+++ b/drivers/net/team/team_mode_roundrobin.c
@@ -32,6 +32,8 @@ static bool rr_transmit(struct team *team, struct sk_buff *skb)
32 32
33 port_index = rr_priv(team)->sent_packets++ % team->en_port_count; 33 port_index = rr_priv(team)->sent_packets++ % team->en_port_count;
34 port = team_get_port_by_index_rcu(team, port_index); 34 port = team_get_port_by_index_rcu(team, port_index);
35 if (unlikely(!port))
36 goto drop;
35 port = team_get_first_port_txable_rcu(team, port); 37 port = team_get_first_port_txable_rcu(team, port);
36 if (unlikely(!port)) 38 if (unlikely(!port))
37 goto drop; 39 goto drop;
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 89776c592151..bfa9bb48e42d 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -352,7 +352,7 @@ static u16 tun_select_queue(struct net_device *dev, struct sk_buff *skb)
352 u32 numqueues = 0; 352 u32 numqueues = 0;
353 353
354 rcu_read_lock(); 354 rcu_read_lock();
355 numqueues = tun->numqueues; 355 numqueues = ACCESS_ONCE(tun->numqueues);
356 356
357 txq = skb_get_rxhash(skb); 357 txq = skb_get_rxhash(skb);
358 if (txq) { 358 if (txq) {
@@ -2159,6 +2159,8 @@ static int tun_chr_open(struct inode *inode, struct file * file)
2159 set_bit(SOCK_EXTERNALLY_ALLOCATED, &tfile->socket.flags); 2159 set_bit(SOCK_EXTERNALLY_ALLOCATED, &tfile->socket.flags);
2160 INIT_LIST_HEAD(&tfile->next); 2160 INIT_LIST_HEAD(&tfile->next);
2161 2161
2162 sock_set_flag(&tfile->sk, SOCK_ZEROCOPY);
2163
2162 return 0; 2164 return 0;
2163} 2165}
2164 2166
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index 078795fe6e31..04ee044dde51 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -627,6 +627,12 @@ static const struct usb_device_id products [] = {
627 .driver_info = 0, 627 .driver_info = 0,
628}, 628},
629 629
630/* Huawei E1820 - handled by qmi_wwan */
631{
632 USB_DEVICE_INTERFACE_NUMBER(HUAWEI_VENDOR_ID, 0x14ac, 1),
633 .driver_info = 0,
634},
635
630/* Realtek RTL8152 Based USB 2.0 Ethernet Adapters */ 636/* Realtek RTL8152 Based USB 2.0 Ethernet Adapters */
631#if defined(CONFIG_USB_RTL8152) || defined(CONFIG_USB_RTL8152_MODULE) 637#if defined(CONFIG_USB_RTL8152) || defined(CONFIG_USB_RTL8152_MODULE)
632{ 638{
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 86adfa0a912e..d095d0d3056b 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -519,6 +519,7 @@ static const struct usb_device_id products[] = {
519 /* 3. Combined interface devices matching on interface number */ 519 /* 3. Combined interface devices matching on interface number */
520 {QMI_FIXED_INTF(0x0408, 0xea42, 4)}, /* Yota / Megafon M100-1 */ 520 {QMI_FIXED_INTF(0x0408, 0xea42, 4)}, /* Yota / Megafon M100-1 */
521 {QMI_FIXED_INTF(0x12d1, 0x140c, 1)}, /* Huawei E173 */ 521 {QMI_FIXED_INTF(0x12d1, 0x140c, 1)}, /* Huawei E173 */
522 {QMI_FIXED_INTF(0x12d1, 0x14ac, 1)}, /* Huawei E1820 */
522 {QMI_FIXED_INTF(0x19d2, 0x0002, 1)}, 523 {QMI_FIXED_INTF(0x19d2, 0x0002, 1)},
523 {QMI_FIXED_INTF(0x19d2, 0x0012, 1)}, 524 {QMI_FIXED_INTF(0x19d2, 0x0012, 1)},
524 {QMI_FIXED_INTF(0x19d2, 0x0017, 3)}, 525 {QMI_FIXED_INTF(0x19d2, 0x0017, 3)},
diff --git a/drivers/net/wireless/ath/ath9k/Kconfig b/drivers/net/wireless/ath/ath9k/Kconfig
index f3dc124c60c7..3c2cbc9d6295 100644
--- a/drivers/net/wireless/ath/ath9k/Kconfig
+++ b/drivers/net/wireless/ath/ath9k/Kconfig
@@ -92,13 +92,17 @@ config ATH9K_MAC_DEBUG
92 This option enables collection of statistics for Rx/Tx status 92 This option enables collection of statistics for Rx/Tx status
93 data and some other MAC related statistics 93 data and some other MAC related statistics
94 94
95config ATH9K_RATE_CONTROL 95config ATH9K_LEGACY_RATE_CONTROL
96 bool "Atheros ath9k rate control" 96 bool "Atheros ath9k rate control"
97 depends on ATH9K 97 depends on ATH9K
98 default y 98 default n
99 ---help--- 99 ---help---
100 Say Y, if you want to use the ath9k specific rate control 100 Say Y, if you want to use the ath9k specific rate control
101 module instead of minstrel_ht. 101 module instead of minstrel_ht. Be warned that there are various
102 issues with the ath9k RC and minstrel is a more robust algorithm.
103 Note that even if this option is selected, "ath9k_rate_control"
104 has to be passed to mac80211 using the module parameter,
105 ieee80211_default_rc_algo.
102 106
103config ATH9K_HTC 107config ATH9K_HTC
104 tristate "Atheros HTC based wireless cards support" 108 tristate "Atheros HTC based wireless cards support"
diff --git a/drivers/net/wireless/ath/ath9k/Makefile b/drivers/net/wireless/ath/ath9k/Makefile
index 2ad8f9474ba1..75ee9e7704ce 100644
--- a/drivers/net/wireless/ath/ath9k/Makefile
+++ b/drivers/net/wireless/ath/ath9k/Makefile
@@ -8,7 +8,7 @@ ath9k-y += beacon.o \
8 antenna.o 8 antenna.o
9 9
10ath9k-$(CONFIG_ATH9K_BTCOEX_SUPPORT) += mci.o 10ath9k-$(CONFIG_ATH9K_BTCOEX_SUPPORT) += mci.o
11ath9k-$(CONFIG_ATH9K_RATE_CONTROL) += rc.o 11ath9k-$(CONFIG_ATH9K_LEGACY_RATE_CONTROL) += rc.o
12ath9k-$(CONFIG_ATH9K_PCI) += pci.o 12ath9k-$(CONFIG_ATH9K_PCI) += pci.o
13ath9k-$(CONFIG_ATH9K_AHB) += ahb.o 13ath9k-$(CONFIG_ATH9K_AHB) += ahb.o
14ath9k-$(CONFIG_ATH9K_DEBUGFS) += debug.o 14ath9k-$(CONFIG_ATH9K_DEBUGFS) += debug.o
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
index db5ffada2217..7546b9a7dcbf 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
@@ -958,11 +958,11 @@ static const u32 ar9300Common_rx_gain_table_2p2[][2] = {
958 {0x0000a074, 0x00000000}, 958 {0x0000a074, 0x00000000},
959 {0x0000a078, 0x00000000}, 959 {0x0000a078, 0x00000000},
960 {0x0000a07c, 0x00000000}, 960 {0x0000a07c, 0x00000000},
961 {0x0000a080, 0x1a1a1a1a}, 961 {0x0000a080, 0x22222229},
962 {0x0000a084, 0x1a1a1a1a}, 962 {0x0000a084, 0x1d1d1d1d},
963 {0x0000a088, 0x1a1a1a1a}, 963 {0x0000a088, 0x1d1d1d1d},
964 {0x0000a08c, 0x1a1a1a1a}, 964 {0x0000a08c, 0x1d1d1d1d},
965 {0x0000a090, 0x171a1a1a}, 965 {0x0000a090, 0x171d1d1d},
966 {0x0000a094, 0x11111717}, 966 {0x0000a094, 0x11111717},
967 {0x0000a098, 0x00030311}, 967 {0x0000a098, 0x00030311},
968 {0x0000a09c, 0x00000000}, 968 {0x0000a09c, 0x00000000},
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index aba415103f94..2ba494567777 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -787,8 +787,7 @@ void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
787 hw->wiphy->iface_combinations = if_comb; 787 hw->wiphy->iface_combinations = if_comb;
788 hw->wiphy->n_iface_combinations = ARRAY_SIZE(if_comb); 788 hw->wiphy->n_iface_combinations = ARRAY_SIZE(if_comb);
789 789
790 if (AR_SREV_5416(sc->sc_ah)) 790 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
791 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
792 791
793 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; 792 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
794 hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS; 793 hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS;
@@ -830,10 +829,6 @@ void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
830 sc->ant_rx = hw->wiphy->available_antennas_rx; 829 sc->ant_rx = hw->wiphy->available_antennas_rx;
831 sc->ant_tx = hw->wiphy->available_antennas_tx; 830 sc->ant_tx = hw->wiphy->available_antennas_tx;
832 831
833#ifdef CONFIG_ATH9K_RATE_CONTROL
834 hw->rate_control_algorithm = "ath9k_rate_control";
835#endif
836
837 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) 832 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ)
838 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = 833 hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
839 &sc->sbands[IEEE80211_BAND_2GHZ]; 834 &sc->sbands[IEEE80211_BAND_2GHZ];
diff --git a/drivers/net/wireless/ath/ath9k/rc.h b/drivers/net/wireless/ath/ath9k/rc.h
index 267dbfcfaa96..b9a87383cb43 100644
--- a/drivers/net/wireless/ath/ath9k/rc.h
+++ b/drivers/net/wireless/ath/ath9k/rc.h
@@ -231,7 +231,7 @@ static inline void ath_debug_stat_retries(struct ath_rate_priv *rc, int rix,
231} 231}
232#endif 232#endif
233 233
234#ifdef CONFIG_ATH9K_RATE_CONTROL 234#ifdef CONFIG_ATH9K_LEGACY_RATE_CONTROL
235int ath_rate_control_register(void); 235int ath_rate_control_register(void);
236void ath_rate_control_unregister(void); 236void ath_rate_control_unregister(void);
237#else 237#else
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 6dd07e2ec595..a95b77ab360e 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -2458,7 +2458,7 @@ static void b43_request_firmware(struct work_struct *work)
2458 for (i = 0; i < B43_NR_FWTYPES; i++) { 2458 for (i = 0; i < B43_NR_FWTYPES; i++) {
2459 errmsg = ctx->errors[i]; 2459 errmsg = ctx->errors[i];
2460 if (strlen(errmsg)) 2460 if (strlen(errmsg))
2461 b43err(dev->wl, errmsg); 2461 b43err(dev->wl, "%s", errmsg);
2462 } 2462 }
2463 b43_print_fw_helptext(dev->wl, 1); 2463 b43_print_fw_helptext(dev->wl, 1);
2464 goto out; 2464 goto out;
diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h
index f8246f2d88f9..4caaf52986a4 100644
--- a/drivers/net/wireless/iwlegacy/common.h
+++ b/drivers/net/wireless/iwlegacy/common.h
@@ -1832,16 +1832,16 @@ u32 il_usecs_to_beacons(struct il_priv *il, u32 usec, u32 beacon_interval);
1832__le32 il_add_beacon_time(struct il_priv *il, u32 base, u32 addon, 1832__le32 il_add_beacon_time(struct il_priv *il, u32 base, u32 addon,
1833 u32 beacon_interval); 1833 u32 beacon_interval);
1834 1834
1835#ifdef CONFIG_PM 1835#ifdef CONFIG_PM_SLEEP
1836extern const struct dev_pm_ops il_pm_ops; 1836extern const struct dev_pm_ops il_pm_ops;
1837 1837
1838#define IL_LEGACY_PM_OPS (&il_pm_ops) 1838#define IL_LEGACY_PM_OPS (&il_pm_ops)
1839 1839
1840#else /* !CONFIG_PM */ 1840#else /* !CONFIG_PM_SLEEP */
1841 1841
1842#define IL_LEGACY_PM_OPS NULL 1842#define IL_LEGACY_PM_OPS NULL
1843 1843
1844#endif /* !CONFIG_PM */ 1844#endif /* !CONFIG_PM_SLEEP */
1845 1845
1846/***************************************************** 1846/*****************************************************
1847* Error Handling Debugging 1847* Error Handling Debugging
diff --git a/drivers/net/wireless/mwifiex/debugfs.c b/drivers/net/wireless/mwifiex/debugfs.c
index 753b5682d53f..a5f9875cfd6e 100644
--- a/drivers/net/wireless/mwifiex/debugfs.c
+++ b/drivers/net/wireless/mwifiex/debugfs.c
@@ -26,10 +26,17 @@
26static struct dentry *mwifiex_dfs_dir; 26static struct dentry *mwifiex_dfs_dir;
27 27
28static char *bss_modes[] = { 28static char *bss_modes[] = {
29 "Unknown", 29 "UNSPECIFIED",
30 "Ad-hoc", 30 "ADHOC",
31 "Managed", 31 "STATION",
32 "Auto" 32 "AP",
33 "AP_VLAN",
34 "WDS",
35 "MONITOR",
36 "MESH_POINT",
37 "P2P_CLIENT",
38 "P2P_GO",
39 "P2P_DEVICE",
33}; 40};
34 41
35/* size/addr for mwifiex_debug_info */ 42/* size/addr for mwifiex_debug_info */
@@ -200,7 +207,12 @@ mwifiex_info_read(struct file *file, char __user *ubuf,
200 p += sprintf(p, "driver_version = %s", fmt); 207 p += sprintf(p, "driver_version = %s", fmt);
201 p += sprintf(p, "\nverext = %s", priv->version_str); 208 p += sprintf(p, "\nverext = %s", priv->version_str);
202 p += sprintf(p, "\ninterface_name=\"%s\"\n", netdev->name); 209 p += sprintf(p, "\ninterface_name=\"%s\"\n", netdev->name);
203 p += sprintf(p, "bss_mode=\"%s\"\n", bss_modes[info.bss_mode]); 210
211 if (info.bss_mode >= ARRAY_SIZE(bss_modes))
212 p += sprintf(p, "bss_mode=\"%d\"\n", info.bss_mode);
213 else
214 p += sprintf(p, "bss_mode=\"%s\"\n", bss_modes[info.bss_mode]);
215
204 p += sprintf(p, "media_state=\"%s\"\n", 216 p += sprintf(p, "media_state=\"%s\"\n",
205 (!priv->media_connected ? "Disconnected" : "Connected")); 217 (!priv->media_connected ? "Disconnected" : "Connected"));
206 p += sprintf(p, "mac_address=\"%pM\"\n", netdev->dev_addr); 218 p += sprintf(p, "mac_address=\"%pM\"\n", netdev->dev_addr);
diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
index 999ffc12578b..c97e9d327331 100644
--- a/drivers/net/wireless/rtlwifi/pci.c
+++ b/drivers/net/wireless/rtlwifi/pci.c
@@ -764,6 +764,7 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
764 "can't alloc skb for rx\n"); 764 "can't alloc skb for rx\n");
765 goto done; 765 goto done;
766 } 766 }
767 kmemleak_not_leak(new_skb);
767 768
768 pci_unmap_single(rtlpci->pdev, 769 pci_unmap_single(rtlpci->pdev,
769 *((dma_addr_t *) skb->cb), 770 *((dma_addr_t *) skb->cb),
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
index 3d0498e69c8c..189ba124a8c6 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
@@ -1973,26 +1973,35 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
1973 } 1973 }
1974} 1974}
1975 1975
1976void rtl92cu_update_hal_rate_table(struct ieee80211_hw *hw, 1976static void rtl92cu_update_hal_rate_table(struct ieee80211_hw *hw,
1977 struct ieee80211_sta *sta, 1977 struct ieee80211_sta *sta)
1978 u8 rssi_level)
1979{ 1978{
1980 struct rtl_priv *rtlpriv = rtl_priv(hw); 1979 struct rtl_priv *rtlpriv = rtl_priv(hw);
1981 struct rtl_phy *rtlphy = &(rtlpriv->phy); 1980 struct rtl_phy *rtlphy = &(rtlpriv->phy);
1982 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 1981 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1983 u32 ratr_value = (u32) mac->basic_rates; 1982 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
1984 u8 *mcsrate = mac->mcs; 1983 u32 ratr_value;
1985 u8 ratr_index = 0; 1984 u8 ratr_index = 0;
1986 u8 nmode = mac->ht_enable; 1985 u8 nmode = mac->ht_enable;
1987 u8 mimo_ps = 1; 1986 u8 mimo_ps = IEEE80211_SMPS_OFF;
1988 u16 shortgi_rate = 0; 1987 u16 shortgi_rate;
1989 u32 tmp_ratr_value = 0; 1988 u32 tmp_ratr_value;
1990 u8 curtxbw_40mhz = mac->bw_40; 1989 u8 curtxbw_40mhz = mac->bw_40;
1991 u8 curshortgi_40mhz = mac->sgi_40; 1990 u8 curshortgi_40mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) ?
1992 u8 curshortgi_20mhz = mac->sgi_20; 1991 1 : 0;
1992 u8 curshortgi_20mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20) ?
1993 1 : 0;
1993 enum wireless_mode wirelessmode = mac->mode; 1994 enum wireless_mode wirelessmode = mac->mode;
1994 1995
1995 ratr_value |= ((*(u16 *) (mcsrate))) << 12; 1996 if (rtlhal->current_bandtype == BAND_ON_5G)
1997 ratr_value = sta->supp_rates[1] << 4;
1998 else
1999 ratr_value = sta->supp_rates[0];
2000 if (mac->opmode == NL80211_IFTYPE_ADHOC)
2001 ratr_value = 0xfff;
2002
2003 ratr_value |= (sta->ht_cap.mcs.rx_mask[1] << 20 |
2004 sta->ht_cap.mcs.rx_mask[0] << 12);
1996 switch (wirelessmode) { 2005 switch (wirelessmode) {
1997 case WIRELESS_MODE_B: 2006 case WIRELESS_MODE_B:
1998 if (ratr_value & 0x0000000c) 2007 if (ratr_value & 0x0000000c)
@@ -2006,7 +2015,7 @@ void rtl92cu_update_hal_rate_table(struct ieee80211_hw *hw,
2006 case WIRELESS_MODE_N_24G: 2015 case WIRELESS_MODE_N_24G:
2007 case WIRELESS_MODE_N_5G: 2016 case WIRELESS_MODE_N_5G:
2008 nmode = 1; 2017 nmode = 1;
2009 if (mimo_ps == 0) { 2018 if (mimo_ps == IEEE80211_SMPS_STATIC) {
2010 ratr_value &= 0x0007F005; 2019 ratr_value &= 0x0007F005;
2011 } else { 2020 } else {
2012 u32 ratr_mask; 2021 u32 ratr_mask;
@@ -2016,8 +2025,7 @@ void rtl92cu_update_hal_rate_table(struct ieee80211_hw *hw,
2016 ratr_mask = 0x000ff005; 2025 ratr_mask = 0x000ff005;
2017 else 2026 else
2018 ratr_mask = 0x0f0ff005; 2027 ratr_mask = 0x0f0ff005;
2019 if (curtxbw_40mhz) 2028
2020 ratr_mask |= 0x00000010;
2021 ratr_value &= ratr_mask; 2029 ratr_value &= ratr_mask;
2022 } 2030 }
2023 break; 2031 break;
@@ -2026,41 +2034,74 @@ void rtl92cu_update_hal_rate_table(struct ieee80211_hw *hw,
2026 ratr_value &= 0x000ff0ff; 2034 ratr_value &= 0x000ff0ff;
2027 else 2035 else
2028 ratr_value &= 0x0f0ff0ff; 2036 ratr_value &= 0x0f0ff0ff;
2037
2029 break; 2038 break;
2030 } 2039 }
2040
2031 ratr_value &= 0x0FFFFFFF; 2041 ratr_value &= 0x0FFFFFFF;
2032 if (nmode && ((curtxbw_40mhz && curshortgi_40mhz) || 2042
2033 (!curtxbw_40mhz && curshortgi_20mhz))) { 2043 if (nmode && ((curtxbw_40mhz &&
2044 curshortgi_40mhz) || (!curtxbw_40mhz &&
2045 curshortgi_20mhz))) {
2046
2034 ratr_value |= 0x10000000; 2047 ratr_value |= 0x10000000;
2035 tmp_ratr_value = (ratr_value >> 12); 2048 tmp_ratr_value = (ratr_value >> 12);
2049
2036 for (shortgi_rate = 15; shortgi_rate > 0; shortgi_rate--) { 2050 for (shortgi_rate = 15; shortgi_rate > 0; shortgi_rate--) {
2037 if ((1 << shortgi_rate) & tmp_ratr_value) 2051 if ((1 << shortgi_rate) & tmp_ratr_value)
2038 break; 2052 break;
2039 } 2053 }
2054
2040 shortgi_rate = (shortgi_rate << 12) | (shortgi_rate << 8) | 2055 shortgi_rate = (shortgi_rate << 12) | (shortgi_rate << 8) |
2041 (shortgi_rate << 4) | (shortgi_rate); 2056 (shortgi_rate << 4) | (shortgi_rate);
2042 } 2057 }
2058
2043 rtl_write_dword(rtlpriv, REG_ARFR0 + ratr_index * 4, ratr_value); 2059 rtl_write_dword(rtlpriv, REG_ARFR0 + ratr_index * 4, ratr_value);
2060
2061 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, "%x\n",
2062 rtl_read_dword(rtlpriv, REG_ARFR0));
2044} 2063}
2045 2064
2046void rtl92cu_update_hal_rate_mask(struct ieee80211_hw *hw, u8 rssi_level) 2065static void rtl92cu_update_hal_rate_mask(struct ieee80211_hw *hw,
2066 struct ieee80211_sta *sta,
2067 u8 rssi_level)
2047{ 2068{
2048 struct rtl_priv *rtlpriv = rtl_priv(hw); 2069 struct rtl_priv *rtlpriv = rtl_priv(hw);
2049 struct rtl_phy *rtlphy = &(rtlpriv->phy); 2070 struct rtl_phy *rtlphy = &(rtlpriv->phy);
2050 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 2071 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
2051 u32 ratr_bitmap = (u32) mac->basic_rates; 2072 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
2052 u8 *p_mcsrate = mac->mcs; 2073 struct rtl_sta_info *sta_entry = NULL;
2053 u8 ratr_index = 0; 2074 u32 ratr_bitmap;
2054 u8 curtxbw_40mhz = mac->bw_40; 2075 u8 ratr_index;
2055 u8 curshortgi_40mhz = mac->sgi_40; 2076 u8 curtxbw_40mhz = (sta->bandwidth >= IEEE80211_STA_RX_BW_40) ? 1 : 0;
2056 u8 curshortgi_20mhz = mac->sgi_20; 2077 u8 curshortgi_40mhz = curtxbw_40mhz &&
2057 enum wireless_mode wirelessmode = mac->mode; 2078 (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) ?
2079 1 : 0;
2080 u8 curshortgi_20mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20) ?
2081 1 : 0;
2082 enum wireless_mode wirelessmode = 0;
2058 bool shortgi = false; 2083 bool shortgi = false;
2059 u8 rate_mask[5]; 2084 u8 rate_mask[5];
2060 u8 macid = 0; 2085 u8 macid = 0;
2061 u8 mimops = 1; 2086 u8 mimo_ps = IEEE80211_SMPS_OFF;
2062 2087
2063 ratr_bitmap |= (p_mcsrate[1] << 20) | (p_mcsrate[0] << 12); 2088 sta_entry = (struct rtl_sta_info *) sta->drv_priv;
2089 wirelessmode = sta_entry->wireless_mode;
2090 if (mac->opmode == NL80211_IFTYPE_STATION ||
2091 mac->opmode == NL80211_IFTYPE_MESH_POINT)
2092 curtxbw_40mhz = mac->bw_40;
2093 else if (mac->opmode == NL80211_IFTYPE_AP ||
2094 mac->opmode == NL80211_IFTYPE_ADHOC)
2095 macid = sta->aid + 1;
2096
2097 if (rtlhal->current_bandtype == BAND_ON_5G)
2098 ratr_bitmap = sta->supp_rates[1] << 4;
2099 else
2100 ratr_bitmap = sta->supp_rates[0];
2101 if (mac->opmode == NL80211_IFTYPE_ADHOC)
2102 ratr_bitmap = 0xfff;
2103 ratr_bitmap |= (sta->ht_cap.mcs.rx_mask[1] << 20 |
2104 sta->ht_cap.mcs.rx_mask[0] << 12);
2064 switch (wirelessmode) { 2105 switch (wirelessmode) {
2065 case WIRELESS_MODE_B: 2106 case WIRELESS_MODE_B:
2066 ratr_index = RATR_INX_WIRELESS_B; 2107 ratr_index = RATR_INX_WIRELESS_B;
@@ -2071,6 +2112,7 @@ void rtl92cu_update_hal_rate_mask(struct ieee80211_hw *hw, u8 rssi_level)
2071 break; 2112 break;
2072 case WIRELESS_MODE_G: 2113 case WIRELESS_MODE_G:
2073 ratr_index = RATR_INX_WIRELESS_GB; 2114 ratr_index = RATR_INX_WIRELESS_GB;
2115
2074 if (rssi_level == 1) 2116 if (rssi_level == 1)
2075 ratr_bitmap &= 0x00000f00; 2117 ratr_bitmap &= 0x00000f00;
2076 else if (rssi_level == 2) 2118 else if (rssi_level == 2)
@@ -2085,7 +2127,8 @@ void rtl92cu_update_hal_rate_mask(struct ieee80211_hw *hw, u8 rssi_level)
2085 case WIRELESS_MODE_N_24G: 2127 case WIRELESS_MODE_N_24G:
2086 case WIRELESS_MODE_N_5G: 2128 case WIRELESS_MODE_N_5G:
2087 ratr_index = RATR_INX_WIRELESS_NGB; 2129 ratr_index = RATR_INX_WIRELESS_NGB;
2088 if (mimops == 0) { 2130
2131 if (mimo_ps == IEEE80211_SMPS_STATIC) {
2089 if (rssi_level == 1) 2132 if (rssi_level == 1)
2090 ratr_bitmap &= 0x00070000; 2133 ratr_bitmap &= 0x00070000;
2091 else if (rssi_level == 2) 2134 else if (rssi_level == 2)
@@ -2128,8 +2171,10 @@ void rtl92cu_update_hal_rate_mask(struct ieee80211_hw *hw, u8 rssi_level)
2128 } 2171 }
2129 } 2172 }
2130 } 2173 }
2174
2131 if ((curtxbw_40mhz && curshortgi_40mhz) || 2175 if ((curtxbw_40mhz && curshortgi_40mhz) ||
2132 (!curtxbw_40mhz && curshortgi_20mhz)) { 2176 (!curtxbw_40mhz && curshortgi_20mhz)) {
2177
2133 if (macid == 0) 2178 if (macid == 0)
2134 shortgi = true; 2179 shortgi = true;
2135 else if (macid == 1) 2180 else if (macid == 1)
@@ -2138,21 +2183,42 @@ void rtl92cu_update_hal_rate_mask(struct ieee80211_hw *hw, u8 rssi_level)
2138 break; 2183 break;
2139 default: 2184 default:
2140 ratr_index = RATR_INX_WIRELESS_NGB; 2185 ratr_index = RATR_INX_WIRELESS_NGB;
2186
2141 if (rtlphy->rf_type == RF_1T2R) 2187 if (rtlphy->rf_type == RF_1T2R)
2142 ratr_bitmap &= 0x000ff0ff; 2188 ratr_bitmap &= 0x000ff0ff;
2143 else 2189 else
2144 ratr_bitmap &= 0x0f0ff0ff; 2190 ratr_bitmap &= 0x0f0ff0ff;
2145 break; 2191 break;
2146 } 2192 }
2147 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, "ratr_bitmap :%x\n", 2193 sta_entry->ratr_index = ratr_index;
2148 ratr_bitmap); 2194
2149 *(u32 *)&rate_mask = ((ratr_bitmap & 0x0fffffff) | 2195 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG,
2150 ratr_index << 28); 2196 "ratr_bitmap :%x\n", ratr_bitmap);
2197 *(u32 *)&rate_mask = (ratr_bitmap & 0x0fffffff) |
2198 (ratr_index << 28);
2151 rate_mask[4] = macid | (shortgi ? 0x20 : 0x00) | 0x80; 2199 rate_mask[4] = macid | (shortgi ? 0x20 : 0x00) | 0x80;
2152 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, 2200 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG,
2153 "Rate_index:%x, ratr_val:%x, %5phC\n", 2201 "Rate_index:%x, ratr_val:%x, %5phC\n",
2154 ratr_index, ratr_bitmap, rate_mask); 2202 ratr_index, ratr_bitmap, rate_mask);
2155 rtl92c_fill_h2c_cmd(hw, H2C_RA_MASK, 5, rate_mask); 2203 memcpy(rtlpriv->rate_mask, rate_mask, 5);
2204 /* rtl92c_fill_h2c_cmd() does USB I/O and will result in a
2205 * "scheduled while atomic" if called directly */
2206 schedule_work(&rtlpriv->works.fill_h2c_cmd);
2207
2208 if (macid != 0)
2209 sta_entry->ratr_index = ratr_index;
2210}
2211
2212void rtl92cu_update_hal_rate_tbl(struct ieee80211_hw *hw,
2213 struct ieee80211_sta *sta,
2214 u8 rssi_level)
2215{
2216 struct rtl_priv *rtlpriv = rtl_priv(hw);
2217
2218 if (rtlpriv->dm.useramask)
2219 rtl92cu_update_hal_rate_mask(hw, sta, rssi_level);
2220 else
2221 rtl92cu_update_hal_rate_table(hw, sta);
2156} 2222}
2157 2223
2158void rtl92cu_update_channel_access_setting(struct ieee80211_hw *hw) 2224void rtl92cu_update_channel_access_setting(struct ieee80211_hw *hw)
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.h b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.h
index f41a3aa4a26f..8e3ec1e25644 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.h
@@ -98,10 +98,6 @@ void rtl92cu_update_interrupt_mask(struct ieee80211_hw *hw,
98 u32 add_msr, u32 rm_msr); 98 u32 add_msr, u32 rm_msr);
99void rtl92cu_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val); 99void rtl92cu_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val);
100void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val); 100void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val);
101void rtl92cu_update_hal_rate_table(struct ieee80211_hw *hw,
102 struct ieee80211_sta *sta,
103 u8 rssi_level);
104void rtl92cu_update_hal_rate_mask(struct ieee80211_hw *hw, u8 rssi_level);
105 101
106void rtl92cu_update_channel_access_setting(struct ieee80211_hw *hw); 102void rtl92cu_update_channel_access_setting(struct ieee80211_hw *hw);
107bool rtl92cu_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 * valid); 103bool rtl92cu_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 * valid);
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
index 85b6bdb163c0..da4f587199ee 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
@@ -289,14 +289,30 @@ void rtl92c_set_key(struct ieee80211_hw *hw, u32 key_index,
289 macaddr = cam_const_broad; 289 macaddr = cam_const_broad;
290 entry_id = key_index; 290 entry_id = key_index;
291 } else { 291 } else {
292 if (mac->opmode == NL80211_IFTYPE_AP ||
293 mac->opmode == NL80211_IFTYPE_MESH_POINT) {
294 entry_id = rtl_cam_get_free_entry(hw,
295 p_macaddr);
296 if (entry_id >= TOTAL_CAM_ENTRY) {
297 RT_TRACE(rtlpriv, COMP_SEC,
298 DBG_EMERG,
299 "Can not find free hw security cam entry\n");
300 return;
301 }
302 } else {
303 entry_id = CAM_PAIRWISE_KEY_POSITION;
304 }
305
292 key_index = PAIRWISE_KEYIDX; 306 key_index = PAIRWISE_KEYIDX;
293 entry_id = CAM_PAIRWISE_KEY_POSITION;
294 is_pairwise = true; 307 is_pairwise = true;
295 } 308 }
296 } 309 }
297 if (rtlpriv->sec.key_len[key_index] == 0) { 310 if (rtlpriv->sec.key_len[key_index] == 0) {
298 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 311 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
299 "delete one entry\n"); 312 "delete one entry\n");
313 if (mac->opmode == NL80211_IFTYPE_AP ||
314 mac->opmode == NL80211_IFTYPE_MESH_POINT)
315 rtl_cam_del_entry(hw, p_macaddr);
300 rtl_cam_delete_one_entry(hw, p_macaddr, entry_id); 316 rtl_cam_delete_one_entry(hw, p_macaddr, entry_id);
301 } else { 317 } else {
302 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, 318 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
index 938b1e670b93..826f085c29dd 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
@@ -106,8 +106,7 @@ static struct rtl_hal_ops rtl8192cu_hal_ops = {
106 .update_interrupt_mask = rtl92cu_update_interrupt_mask, 106 .update_interrupt_mask = rtl92cu_update_interrupt_mask,
107 .get_hw_reg = rtl92cu_get_hw_reg, 107 .get_hw_reg = rtl92cu_get_hw_reg,
108 .set_hw_reg = rtl92cu_set_hw_reg, 108 .set_hw_reg = rtl92cu_set_hw_reg,
109 .update_rate_tbl = rtl92cu_update_hal_rate_table, 109 .update_rate_tbl = rtl92cu_update_hal_rate_tbl,
110 .update_rate_mask = rtl92cu_update_hal_rate_mask,
111 .fill_tx_desc = rtl92cu_tx_fill_desc, 110 .fill_tx_desc = rtl92cu_tx_fill_desc,
112 .fill_fake_txdesc = rtl92cu_fill_fake_txdesc, 111 .fill_fake_txdesc = rtl92cu_fill_fake_txdesc,
113 .fill_tx_cmddesc = rtl92cu_tx_fill_cmddesc, 112 .fill_tx_cmddesc = rtl92cu_tx_fill_cmddesc,
@@ -137,6 +136,7 @@ static struct rtl_hal_ops rtl8192cu_hal_ops = {
137 .phy_lc_calibrate = _rtl92cu_phy_lc_calibrate, 136 .phy_lc_calibrate = _rtl92cu_phy_lc_calibrate,
138 .phy_set_bw_mode_callback = rtl92cu_phy_set_bw_mode_callback, 137 .phy_set_bw_mode_callback = rtl92cu_phy_set_bw_mode_callback,
139 .dm_dynamic_txpower = rtl92cu_dm_dynamic_txpower, 138 .dm_dynamic_txpower = rtl92cu_dm_dynamic_txpower,
139 .fill_h2c_cmd = rtl92c_fill_h2c_cmd,
140}; 140};
141 141
142static struct rtl_mod_params rtl92cu_mod_params = { 142static struct rtl_mod_params rtl92cu_mod_params = {
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.h b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.h
index a1310abd0d54..262e1e4c6e5b 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.h
@@ -49,5 +49,8 @@ bool rtl92cu_phy_set_rf_power_state(struct ieee80211_hw *hw,
49u32 rtl92cu_phy_query_rf_reg(struct ieee80211_hw *hw, 49u32 rtl92cu_phy_query_rf_reg(struct ieee80211_hw *hw,
50 enum radio_path rfpath, u32 regaddr, u32 bitmask); 50 enum radio_path rfpath, u32 regaddr, u32 bitmask);
51void rtl92cu_phy_set_bw_mode_callback(struct ieee80211_hw *hw); 51void rtl92cu_phy_set_bw_mode_callback(struct ieee80211_hw *hw);
52void rtl92cu_update_hal_rate_tbl(struct ieee80211_hw *hw,
53 struct ieee80211_sta *sta,
54 u8 rssi_level);
52 55
53#endif 56#endif
diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
index 76732b0cd221..a3532e077871 100644
--- a/drivers/net/wireless/rtlwifi/usb.c
+++ b/drivers/net/wireless/rtlwifi/usb.c
@@ -824,6 +824,7 @@ static void rtl_usb_stop(struct ieee80211_hw *hw)
824 824
825 /* should after adapter start and interrupt enable. */ 825 /* should after adapter start and interrupt enable. */
826 set_hal_stop(rtlhal); 826 set_hal_stop(rtlhal);
827 cancel_work_sync(&rtlpriv->works.fill_h2c_cmd);
827 /* Enable software */ 828 /* Enable software */
828 SET_USB_STOP(rtlusb); 829 SET_USB_STOP(rtlusb);
829 rtl_usb_deinit(hw); 830 rtl_usb_deinit(hw);
@@ -1026,6 +1027,16 @@ static bool rtl_usb_tx_chk_waitq_insert(struct ieee80211_hw *hw,
1026 return false; 1027 return false;
1027} 1028}
1028 1029
1030static void rtl_fill_h2c_cmd_work_callback(struct work_struct *work)
1031{
1032 struct rtl_works *rtlworks =
1033 container_of(work, struct rtl_works, fill_h2c_cmd);
1034 struct ieee80211_hw *hw = rtlworks->hw;
1035 struct rtl_priv *rtlpriv = rtl_priv(hw);
1036
1037 rtlpriv->cfg->ops->fill_h2c_cmd(hw, H2C_RA_MASK, 5, rtlpriv->rate_mask);
1038}
1039
1029static struct rtl_intf_ops rtl_usb_ops = { 1040static struct rtl_intf_ops rtl_usb_ops = {
1030 .adapter_start = rtl_usb_start, 1041 .adapter_start = rtl_usb_start,
1031 .adapter_stop = rtl_usb_stop, 1042 .adapter_stop = rtl_usb_stop,
@@ -1057,6 +1068,8 @@ int rtl_usb_probe(struct usb_interface *intf,
1057 1068
1058 /* this spin lock must be initialized early */ 1069 /* this spin lock must be initialized early */
1059 spin_lock_init(&rtlpriv->locks.usb_lock); 1070 spin_lock_init(&rtlpriv->locks.usb_lock);
1071 INIT_WORK(&rtlpriv->works.fill_h2c_cmd,
1072 rtl_fill_h2c_cmd_work_callback);
1060 1073
1061 rtlpriv->usb_data_index = 0; 1074 rtlpriv->usb_data_index = 0;
1062 init_completion(&rtlpriv->firmware_loading_complete); 1075 init_completion(&rtlpriv->firmware_loading_complete);
diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
index 44328baa6389..cc03e7c87cbe 100644
--- a/drivers/net/wireless/rtlwifi/wifi.h
+++ b/drivers/net/wireless/rtlwifi/wifi.h
@@ -1736,6 +1736,8 @@ struct rtl_hal_ops {
1736 void (*bt_wifi_media_status_notify) (struct ieee80211_hw *hw, 1736 void (*bt_wifi_media_status_notify) (struct ieee80211_hw *hw,
1737 bool mstate); 1737 bool mstate);
1738 void (*bt_coex_off_before_lps) (struct ieee80211_hw *hw); 1738 void (*bt_coex_off_before_lps) (struct ieee80211_hw *hw);
1739 void (*fill_h2c_cmd) (struct ieee80211_hw *hw, u8 element_id,
1740 u32 cmd_len, u8 *p_cmdbuffer);
1739}; 1741};
1740 1742
1741struct rtl_intf_ops { 1743struct rtl_intf_ops {
@@ -1869,6 +1871,7 @@ struct rtl_works {
1869 struct delayed_work fwevt_wq; 1871 struct delayed_work fwevt_wq;
1870 1872
1871 struct work_struct lps_change_work; 1873 struct work_struct lps_change_work;
1874 struct work_struct fill_h2c_cmd;
1872}; 1875};
1873 1876
1874struct rtl_debug { 1877struct rtl_debug {
@@ -2048,6 +2051,7 @@ struct rtl_priv {
2048 }; 2051 };
2049 }; 2052 };
2050 bool enter_ps; /* true when entering PS */ 2053 bool enter_ps; /* true when entering PS */
2054 u8 rate_mask[5];
2051 2055
2052 /*This must be the last item so 2056 /*This must be the last item so
2053 that it points to the data allocated 2057 that it points to the data allocated
diff --git a/drivers/net/wireless/ti/wl12xx/scan.c b/drivers/net/wireless/ti/wl12xx/scan.c
index affdb3ec6225..4a0bbb13806b 100644
--- a/drivers/net/wireless/ti/wl12xx/scan.c
+++ b/drivers/net/wireless/ti/wl12xx/scan.c
@@ -310,7 +310,7 @@ static void wl12xx_adjust_channels(struct wl1271_cmd_sched_scan_config *cmd,
310 memcpy(cmd->channels_2, cmd_channels->channels_2, 310 memcpy(cmd->channels_2, cmd_channels->channels_2,
311 sizeof(cmd->channels_2)); 311 sizeof(cmd->channels_2));
312 memcpy(cmd->channels_5, cmd_channels->channels_5, 312 memcpy(cmd->channels_5, cmd_channels->channels_5,
313 sizeof(cmd->channels_2)); 313 sizeof(cmd->channels_5));
314 /* channels_4 are not supported, so no need to copy them */ 314 /* channels_4 are not supported, so no need to copy them */
315} 315}
316 316
diff --git a/drivers/net/wireless/ti/wl12xx/wl12xx.h b/drivers/net/wireless/ti/wl12xx/wl12xx.h
index 222d03540200..9e5484a73667 100644
--- a/drivers/net/wireless/ti/wl12xx/wl12xx.h
+++ b/drivers/net/wireless/ti/wl12xx/wl12xx.h
@@ -36,12 +36,12 @@
36#define WL127X_IFTYPE_SR_VER 3 36#define WL127X_IFTYPE_SR_VER 3
37#define WL127X_MAJOR_SR_VER 10 37#define WL127X_MAJOR_SR_VER 10
38#define WL127X_SUBTYPE_SR_VER WLCORE_FW_VER_IGNORE 38#define WL127X_SUBTYPE_SR_VER WLCORE_FW_VER_IGNORE
39#define WL127X_MINOR_SR_VER 115 39#define WL127X_MINOR_SR_VER 133
40/* minimum multi-role FW version for wl127x */ 40/* minimum multi-role FW version for wl127x */
41#define WL127X_IFTYPE_MR_VER 5 41#define WL127X_IFTYPE_MR_VER 5
42#define WL127X_MAJOR_MR_VER 7 42#define WL127X_MAJOR_MR_VER 7
43#define WL127X_SUBTYPE_MR_VER WLCORE_FW_VER_IGNORE 43#define WL127X_SUBTYPE_MR_VER WLCORE_FW_VER_IGNORE
44#define WL127X_MINOR_MR_VER 115 44#define WL127X_MINOR_MR_VER 42
45 45
46/* FW chip version for wl128x */ 46/* FW chip version for wl128x */
47#define WL128X_CHIP_VER 7 47#define WL128X_CHIP_VER 7
@@ -49,7 +49,7 @@
49#define WL128X_IFTYPE_SR_VER 3 49#define WL128X_IFTYPE_SR_VER 3
50#define WL128X_MAJOR_SR_VER 10 50#define WL128X_MAJOR_SR_VER 10
51#define WL128X_SUBTYPE_SR_VER WLCORE_FW_VER_IGNORE 51#define WL128X_SUBTYPE_SR_VER WLCORE_FW_VER_IGNORE
52#define WL128X_MINOR_SR_VER 115 52#define WL128X_MINOR_SR_VER 133
53/* minimum multi-role FW version for wl128x */ 53/* minimum multi-role FW version for wl128x */
54#define WL128X_IFTYPE_MR_VER 5 54#define WL128X_IFTYPE_MR_VER 5
55#define WL128X_MAJOR_MR_VER 7 55#define WL128X_MAJOR_MR_VER 7
diff --git a/drivers/net/wireless/ti/wl18xx/scan.c b/drivers/net/wireless/ti/wl18xx/scan.c
index 09d944505ac0..2b642f8c9266 100644
--- a/drivers/net/wireless/ti/wl18xx/scan.c
+++ b/drivers/net/wireless/ti/wl18xx/scan.c
@@ -34,7 +34,7 @@ static void wl18xx_adjust_channels(struct wl18xx_cmd_scan_params *cmd,
34 memcpy(cmd->channels_2, cmd_channels->channels_2, 34 memcpy(cmd->channels_2, cmd_channels->channels_2,
35 sizeof(cmd->channels_2)); 35 sizeof(cmd->channels_2));
36 memcpy(cmd->channels_5, cmd_channels->channels_5, 36 memcpy(cmd->channels_5, cmd_channels->channels_5,
37 sizeof(cmd->channels_2)); 37 sizeof(cmd->channels_5));
38 /* channels_4 are not supported, so no need to copy them */ 38 /* channels_4 are not supported, so no need to copy them */
39} 39}
40 40
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index 37984e6d4e99..8c20935d72c9 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -662,7 +662,7 @@ static void xen_netbk_rx_action(struct xen_netbk *netbk)
662{ 662{
663 struct xenvif *vif = NULL, *tmp; 663 struct xenvif *vif = NULL, *tmp;
664 s8 status; 664 s8 status;
665 u16 irq, flags; 665 u16 flags;
666 struct xen_netif_rx_response *resp; 666 struct xen_netif_rx_response *resp;
667 struct sk_buff_head rxq; 667 struct sk_buff_head rxq;
668 struct sk_buff *skb; 668 struct sk_buff *skb;
@@ -771,13 +771,13 @@ static void xen_netbk_rx_action(struct xen_netbk *netbk)
771 sco->meta_slots_used); 771 sco->meta_slots_used);
772 772
773 RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&vif->rx, ret); 773 RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&vif->rx, ret);
774 irq = vif->irq;
775 if (ret && list_empty(&vif->notify_list))
776 list_add_tail(&vif->notify_list, &notify);
777 774
778 xenvif_notify_tx_completion(vif); 775 xenvif_notify_tx_completion(vif);
779 776
780 xenvif_put(vif); 777 if (ret && list_empty(&vif->notify_list))
778 list_add_tail(&vif->notify_list, &notify);
779 else
780 xenvif_put(vif);
781 npo.meta_cons += sco->meta_slots_used; 781 npo.meta_cons += sco->meta_slots_used;
782 dev_kfree_skb(skb); 782 dev_kfree_skb(skb);
783 } 783 }
@@ -785,6 +785,7 @@ static void xen_netbk_rx_action(struct xen_netbk *netbk)
785 list_for_each_entry_safe(vif, tmp, &notify, notify_list) { 785 list_for_each_entry_safe(vif, tmp, &notify, notify_list) {
786 notify_remote_via_irq(vif->irq); 786 notify_remote_via_irq(vif->irq);
787 list_del_init(&vif->notify_list); 787 list_del_init(&vif->notify_list);
788 xenvif_put(vif);
788 } 789 }
789 790
790 /* More work to do? */ 791 /* More work to do? */
diff --git a/drivers/of/base.c b/drivers/of/base.c
index f53b992f060a..a6f584a7f4a1 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -192,14 +192,15 @@ EXPORT_SYMBOL(of_find_property);
192struct device_node *of_find_all_nodes(struct device_node *prev) 192struct device_node *of_find_all_nodes(struct device_node *prev)
193{ 193{
194 struct device_node *np; 194 struct device_node *np;
195 unsigned long flags;
195 196
196 raw_spin_lock(&devtree_lock); 197 raw_spin_lock_irqsave(&devtree_lock, flags);
197 np = prev ? prev->allnext : of_allnodes; 198 np = prev ? prev->allnext : of_allnodes;
198 for (; np != NULL; np = np->allnext) 199 for (; np != NULL; np = np->allnext)
199 if (of_node_get(np)) 200 if (of_node_get(np))
200 break; 201 break;
201 of_node_put(prev); 202 of_node_put(prev);
202 raw_spin_unlock(&devtree_lock); 203 raw_spin_unlock_irqrestore(&devtree_lock, flags);
203 return np; 204 return np;
204} 205}
205EXPORT_SYMBOL(of_find_all_nodes); 206EXPORT_SYMBOL(of_find_all_nodes);
@@ -421,8 +422,9 @@ struct device_node *of_get_next_available_child(const struct device_node *node,
421 struct device_node *prev) 422 struct device_node *prev)
422{ 423{
423 struct device_node *next; 424 struct device_node *next;
425 unsigned long flags;
424 426
425 raw_spin_lock(&devtree_lock); 427 raw_spin_lock_irqsave(&devtree_lock, flags);
426 next = prev ? prev->sibling : node->child; 428 next = prev ? prev->sibling : node->child;
427 for (; next; next = next->sibling) { 429 for (; next; next = next->sibling) {
428 if (!__of_device_is_available(next)) 430 if (!__of_device_is_available(next))
@@ -431,7 +433,7 @@ struct device_node *of_get_next_available_child(const struct device_node *node,
431 break; 433 break;
432 } 434 }
433 of_node_put(prev); 435 of_node_put(prev);
434 raw_spin_unlock(&devtree_lock); 436 raw_spin_unlock_irqrestore(&devtree_lock, flags);
435 return next; 437 return next;
436} 438}
437EXPORT_SYMBOL(of_get_next_available_child); 439EXPORT_SYMBOL(of_get_next_available_child);
@@ -735,13 +737,14 @@ EXPORT_SYMBOL_GPL(of_modalias_node);
735struct device_node *of_find_node_by_phandle(phandle handle) 737struct device_node *of_find_node_by_phandle(phandle handle)
736{ 738{
737 struct device_node *np; 739 struct device_node *np;
740 unsigned long flags;
738 741
739 raw_spin_lock(&devtree_lock); 742 raw_spin_lock_irqsave(&devtree_lock, flags);
740 for (np = of_allnodes; np; np = np->allnext) 743 for (np = of_allnodes; np; np = np->allnext)
741 if (np->phandle == handle) 744 if (np->phandle == handle)
742 break; 745 break;
743 of_node_get(np); 746 of_node_get(np);
744 raw_spin_unlock(&devtree_lock); 747 raw_spin_unlock_irqrestore(&devtree_lock, flags);
745 return np; 748 return np;
746} 749}
747EXPORT_SYMBOL(of_find_node_by_phandle); 750EXPORT_SYMBOL(of_find_node_by_phandle);
diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c
index 9544cdc0d1af..e79e006eb9ab 100644
--- a/drivers/parisc/iosapic.c
+++ b/drivers/parisc/iosapic.c
@@ -811,6 +811,70 @@ int iosapic_fixup_irq(void *isi_obj, struct pci_dev *pcidev)
811 return pcidev->irq; 811 return pcidev->irq;
812} 812}
813 813
814static struct iosapic_info *first_isi = NULL;
815
816#ifdef CONFIG_64BIT
817int iosapic_serial_irq(int num)
818{
819 struct iosapic_info *isi = first_isi;
820 struct irt_entry *irte = NULL; /* only used if PAT PDC */
821 struct vector_info *vi;
822 int isi_line; /* line used by device */
823
824 /* lookup IRT entry for isi/slot/pin set */
825 irte = &irt_cell[num];
826
827 DBG_IRT("iosapic_serial_irq(): irte %p %x %x %x %x %x %x %x %x\n",
828 irte,
829 irte->entry_type,
830 irte->entry_length,
831 irte->polarity_trigger,
832 irte->src_bus_irq_devno,
833 irte->src_bus_id,
834 irte->src_seg_id,
835 irte->dest_iosapic_intin,
836 (u32) irte->dest_iosapic_addr);
837 isi_line = irte->dest_iosapic_intin;
838
839 /* get vector info for this input line */
840 vi = isi->isi_vector + isi_line;
841 DBG_IRT("iosapic_serial_irq: line %d vi 0x%p\n", isi_line, vi);
842
843 /* If this IRQ line has already been setup, skip it */
844 if (vi->irte)
845 goto out;
846
847 vi->irte = irte;
848
849 /*
850 * Allocate processor IRQ
851 *
852 * XXX/FIXME The txn_alloc_irq() code and related code should be
853 * moved to enable_irq(). That way we only allocate processor IRQ
854 * bits for devices that actually have drivers claiming them.
855 * Right now we assign an IRQ to every PCI device present,
856 * regardless of whether it's used or not.
857 */
858 vi->txn_irq = txn_alloc_irq(8);
859
860 if (vi->txn_irq < 0)
861 panic("I/O sapic: couldn't get TXN IRQ\n");
862
863 /* enable_irq() will use txn_* to program IRdT */
864 vi->txn_addr = txn_alloc_addr(vi->txn_irq);
865 vi->txn_data = txn_alloc_data(vi->txn_irq);
866
867 vi->eoi_addr = isi->addr + IOSAPIC_REG_EOI;
868 vi->eoi_data = cpu_to_le32(vi->txn_data);
869
870 cpu_claim_irq(vi->txn_irq, &iosapic_interrupt_type, vi);
871
872 out:
873
874 return vi->txn_irq;
875}
876#endif
877
814 878
815/* 879/*
816** squirrel away the I/O Sapic Version 880** squirrel away the I/O Sapic Version
@@ -877,6 +941,8 @@ void *iosapic_register(unsigned long hpa)
877 vip->irqline = (unsigned char) cnt; 941 vip->irqline = (unsigned char) cnt;
878 vip->iosapic = isi; 942 vip->iosapic = isi;
879 } 943 }
944 if (!first_isi)
945 first_isi = isi;
880 return isi; 946 return isi;
881} 947}
882 948
diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c
index 0eab77b22340..f296f3f7db9b 100644
--- a/drivers/rtc/rtc-at91rm9200.c
+++ b/drivers/rtc/rtc-at91rm9200.c
@@ -25,6 +25,7 @@
25#include <linux/rtc.h> 25#include <linux/rtc.h>
26#include <linux/bcd.h> 26#include <linux/bcd.h>
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/spinlock.h>
28#include <linux/ioctl.h> 29#include <linux/ioctl.h>
29#include <linux/completion.h> 30#include <linux/completion.h>
30#include <linux/io.h> 31#include <linux/io.h>
@@ -42,10 +43,65 @@
42 43
43#define AT91_RTC_EPOCH 1900UL /* just like arch/arm/common/rtctime.c */ 44#define AT91_RTC_EPOCH 1900UL /* just like arch/arm/common/rtctime.c */
44 45
46struct at91_rtc_config {
47 bool use_shadow_imr;
48};
49
50static const struct at91_rtc_config *at91_rtc_config;
45static DECLARE_COMPLETION(at91_rtc_updated); 51static DECLARE_COMPLETION(at91_rtc_updated);
46static unsigned int at91_alarm_year = AT91_RTC_EPOCH; 52static unsigned int at91_alarm_year = AT91_RTC_EPOCH;
47static void __iomem *at91_rtc_regs; 53static void __iomem *at91_rtc_regs;
48static int irq; 54static int irq;
55static DEFINE_SPINLOCK(at91_rtc_lock);
56static u32 at91_rtc_shadow_imr;
57
58static void at91_rtc_write_ier(u32 mask)
59{
60 unsigned long flags;
61
62 spin_lock_irqsave(&at91_rtc_lock, flags);
63 at91_rtc_shadow_imr |= mask;
64 at91_rtc_write(AT91_RTC_IER, mask);
65 spin_unlock_irqrestore(&at91_rtc_lock, flags);
66}
67
68static void at91_rtc_write_idr(u32 mask)
69{
70 unsigned long flags;
71
72 spin_lock_irqsave(&at91_rtc_lock, flags);
73 at91_rtc_write(AT91_RTC_IDR, mask);
74 /*
75 * Register read back (of any RTC-register) needed to make sure
76 * IDR-register write has reached the peripheral before updating
77 * shadow mask.
78 *
79 * Note that there is still a possibility that the mask is updated
80 * before interrupts have actually been disabled in hardware. The only
81 * way to be certain would be to poll the IMR-register, which is is
82 * the very register we are trying to emulate. The register read back
83 * is a reasonable heuristic.
84 */
85 at91_rtc_read(AT91_RTC_SR);
86 at91_rtc_shadow_imr &= ~mask;
87 spin_unlock_irqrestore(&at91_rtc_lock, flags);
88}
89
90static u32 at91_rtc_read_imr(void)
91{
92 unsigned long flags;
93 u32 mask;
94
95 if (at91_rtc_config->use_shadow_imr) {
96 spin_lock_irqsave(&at91_rtc_lock, flags);
97 mask = at91_rtc_shadow_imr;
98 spin_unlock_irqrestore(&at91_rtc_lock, flags);
99 } else {
100 mask = at91_rtc_read(AT91_RTC_IMR);
101 }
102
103 return mask;
104}
49 105
50/* 106/*
51 * Decode time/date into rtc_time structure 107 * Decode time/date into rtc_time structure
@@ -110,9 +166,9 @@ static int at91_rtc_settime(struct device *dev, struct rtc_time *tm)
110 cr = at91_rtc_read(AT91_RTC_CR); 166 cr = at91_rtc_read(AT91_RTC_CR);
111 at91_rtc_write(AT91_RTC_CR, cr | AT91_RTC_UPDCAL | AT91_RTC_UPDTIM); 167 at91_rtc_write(AT91_RTC_CR, cr | AT91_RTC_UPDCAL | AT91_RTC_UPDTIM);
112 168
113 at91_rtc_write(AT91_RTC_IER, AT91_RTC_ACKUPD); 169 at91_rtc_write_ier(AT91_RTC_ACKUPD);
114 wait_for_completion(&at91_rtc_updated); /* wait for ACKUPD interrupt */ 170 wait_for_completion(&at91_rtc_updated); /* wait for ACKUPD interrupt */
115 at91_rtc_write(AT91_RTC_IDR, AT91_RTC_ACKUPD); 171 at91_rtc_write_idr(AT91_RTC_ACKUPD);
116 172
117 at91_rtc_write(AT91_RTC_TIMR, 173 at91_rtc_write(AT91_RTC_TIMR,
118 bin2bcd(tm->tm_sec) << 0 174 bin2bcd(tm->tm_sec) << 0
@@ -144,7 +200,7 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
144 tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year); 200 tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year);
145 tm->tm_year = at91_alarm_year - 1900; 201 tm->tm_year = at91_alarm_year - 1900;
146 202
147 alrm->enabled = (at91_rtc_read(AT91_RTC_IMR) & AT91_RTC_ALARM) 203 alrm->enabled = (at91_rtc_read_imr() & AT91_RTC_ALARM)
148 ? 1 : 0; 204 ? 1 : 0;
149 205
150 dev_dbg(dev, "%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__, 206 dev_dbg(dev, "%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__,
@@ -169,7 +225,7 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
169 tm.tm_min = alrm->time.tm_min; 225 tm.tm_min = alrm->time.tm_min;
170 tm.tm_sec = alrm->time.tm_sec; 226 tm.tm_sec = alrm->time.tm_sec;
171 227
172 at91_rtc_write(AT91_RTC_IDR, AT91_RTC_ALARM); 228 at91_rtc_write_idr(AT91_RTC_ALARM);
173 at91_rtc_write(AT91_RTC_TIMALR, 229 at91_rtc_write(AT91_RTC_TIMALR,
174 bin2bcd(tm.tm_sec) << 0 230 bin2bcd(tm.tm_sec) << 0
175 | bin2bcd(tm.tm_min) << 8 231 | bin2bcd(tm.tm_min) << 8
@@ -182,7 +238,7 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
182 238
183 if (alrm->enabled) { 239 if (alrm->enabled) {
184 at91_rtc_write(AT91_RTC_SCCR, AT91_RTC_ALARM); 240 at91_rtc_write(AT91_RTC_SCCR, AT91_RTC_ALARM);
185 at91_rtc_write(AT91_RTC_IER, AT91_RTC_ALARM); 241 at91_rtc_write_ier(AT91_RTC_ALARM);
186 } 242 }
187 243
188 dev_dbg(dev, "%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__, 244 dev_dbg(dev, "%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__,
@@ -198,9 +254,9 @@ static int at91_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
198 254
199 if (enabled) { 255 if (enabled) {
200 at91_rtc_write(AT91_RTC_SCCR, AT91_RTC_ALARM); 256 at91_rtc_write(AT91_RTC_SCCR, AT91_RTC_ALARM);
201 at91_rtc_write(AT91_RTC_IER, AT91_RTC_ALARM); 257 at91_rtc_write_ier(AT91_RTC_ALARM);
202 } else 258 } else
203 at91_rtc_write(AT91_RTC_IDR, AT91_RTC_ALARM); 259 at91_rtc_write_idr(AT91_RTC_ALARM);
204 260
205 return 0; 261 return 0;
206} 262}
@@ -209,7 +265,7 @@ static int at91_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
209 */ 265 */
210static int at91_rtc_proc(struct device *dev, struct seq_file *seq) 266static int at91_rtc_proc(struct device *dev, struct seq_file *seq)
211{ 267{
212 unsigned long imr = at91_rtc_read(AT91_RTC_IMR); 268 unsigned long imr = at91_rtc_read_imr();
213 269
214 seq_printf(seq, "update_IRQ\t: %s\n", 270 seq_printf(seq, "update_IRQ\t: %s\n",
215 (imr & AT91_RTC_ACKUPD) ? "yes" : "no"); 271 (imr & AT91_RTC_ACKUPD) ? "yes" : "no");
@@ -229,7 +285,7 @@ static irqreturn_t at91_rtc_interrupt(int irq, void *dev_id)
229 unsigned int rtsr; 285 unsigned int rtsr;
230 unsigned long events = 0; 286 unsigned long events = 0;
231 287
232 rtsr = at91_rtc_read(AT91_RTC_SR) & at91_rtc_read(AT91_RTC_IMR); 288 rtsr = at91_rtc_read(AT91_RTC_SR) & at91_rtc_read_imr();
233 if (rtsr) { /* this interrupt is shared! Is it ours? */ 289 if (rtsr) { /* this interrupt is shared! Is it ours? */
234 if (rtsr & AT91_RTC_ALARM) 290 if (rtsr & AT91_RTC_ALARM)
235 events |= (RTC_AF | RTC_IRQF); 291 events |= (RTC_AF | RTC_IRQF);
@@ -250,6 +306,43 @@ static irqreturn_t at91_rtc_interrupt(int irq, void *dev_id)
250 return IRQ_NONE; /* not handled */ 306 return IRQ_NONE; /* not handled */
251} 307}
252 308
309static const struct at91_rtc_config at91rm9200_config = {
310};
311
312static const struct at91_rtc_config at91sam9x5_config = {
313 .use_shadow_imr = true,
314};
315
316#ifdef CONFIG_OF
317static const struct of_device_id at91_rtc_dt_ids[] = {
318 {
319 .compatible = "atmel,at91rm9200-rtc",
320 .data = &at91rm9200_config,
321 }, {
322 .compatible = "atmel,at91sam9x5-rtc",
323 .data = &at91sam9x5_config,
324 }, {
325 /* sentinel */
326 }
327};
328MODULE_DEVICE_TABLE(of, at91_rtc_dt_ids);
329#endif
330
331static const struct at91_rtc_config *
332at91_rtc_get_config(struct platform_device *pdev)
333{
334 const struct of_device_id *match;
335
336 if (pdev->dev.of_node) {
337 match = of_match_node(at91_rtc_dt_ids, pdev->dev.of_node);
338 if (!match)
339 return NULL;
340 return (const struct at91_rtc_config *)match->data;
341 }
342
343 return &at91rm9200_config;
344}
345
253static const struct rtc_class_ops at91_rtc_ops = { 346static const struct rtc_class_ops at91_rtc_ops = {
254 .read_time = at91_rtc_readtime, 347 .read_time = at91_rtc_readtime,
255 .set_time = at91_rtc_settime, 348 .set_time = at91_rtc_settime,
@@ -268,6 +361,10 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
268 struct resource *regs; 361 struct resource *regs;
269 int ret = 0; 362 int ret = 0;
270 363
364 at91_rtc_config = at91_rtc_get_config(pdev);
365 if (!at91_rtc_config)
366 return -ENODEV;
367
271 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 368 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
272 if (!regs) { 369 if (!regs) {
273 dev_err(&pdev->dev, "no mmio resource defined\n"); 370 dev_err(&pdev->dev, "no mmio resource defined\n");
@@ -290,7 +387,7 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
290 at91_rtc_write(AT91_RTC_MR, 0); /* 24 hour mode */ 387 at91_rtc_write(AT91_RTC_MR, 0); /* 24 hour mode */
291 388
292 /* Disable all interrupts */ 389 /* Disable all interrupts */
293 at91_rtc_write(AT91_RTC_IDR, AT91_RTC_ACKUPD | AT91_RTC_ALARM | 390 at91_rtc_write_idr(AT91_RTC_ACKUPD | AT91_RTC_ALARM |
294 AT91_RTC_SECEV | AT91_RTC_TIMEV | 391 AT91_RTC_SECEV | AT91_RTC_TIMEV |
295 AT91_RTC_CALEV); 392 AT91_RTC_CALEV);
296 393
@@ -335,7 +432,7 @@ static int __exit at91_rtc_remove(struct platform_device *pdev)
335 struct rtc_device *rtc = platform_get_drvdata(pdev); 432 struct rtc_device *rtc = platform_get_drvdata(pdev);
336 433
337 /* Disable all interrupts */ 434 /* Disable all interrupts */
338 at91_rtc_write(AT91_RTC_IDR, AT91_RTC_ACKUPD | AT91_RTC_ALARM | 435 at91_rtc_write_idr(AT91_RTC_ACKUPD | AT91_RTC_ALARM |
339 AT91_RTC_SECEV | AT91_RTC_TIMEV | 436 AT91_RTC_SECEV | AT91_RTC_TIMEV |
340 AT91_RTC_CALEV); 437 AT91_RTC_CALEV);
341 free_irq(irq, pdev); 438 free_irq(irq, pdev);
@@ -358,13 +455,13 @@ static int at91_rtc_suspend(struct device *dev)
358 /* this IRQ is shared with DBGU and other hardware which isn't 455 /* this IRQ is shared with DBGU and other hardware which isn't
359 * necessarily doing PM like we are... 456 * necessarily doing PM like we are...
360 */ 457 */
361 at91_rtc_imr = at91_rtc_read(AT91_RTC_IMR) 458 at91_rtc_imr = at91_rtc_read_imr()
362 & (AT91_RTC_ALARM|AT91_RTC_SECEV); 459 & (AT91_RTC_ALARM|AT91_RTC_SECEV);
363 if (at91_rtc_imr) { 460 if (at91_rtc_imr) {
364 if (device_may_wakeup(dev)) 461 if (device_may_wakeup(dev))
365 enable_irq_wake(irq); 462 enable_irq_wake(irq);
366 else 463 else
367 at91_rtc_write(AT91_RTC_IDR, at91_rtc_imr); 464 at91_rtc_write_idr(at91_rtc_imr);
368 } 465 }
369 return 0; 466 return 0;
370} 467}
@@ -375,7 +472,7 @@ static int at91_rtc_resume(struct device *dev)
375 if (device_may_wakeup(dev)) 472 if (device_may_wakeup(dev))
376 disable_irq_wake(irq); 473 disable_irq_wake(irq);
377 else 474 else
378 at91_rtc_write(AT91_RTC_IER, at91_rtc_imr); 475 at91_rtc_write_ier(at91_rtc_imr);
379 } 476 }
380 return 0; 477 return 0;
381} 478}
@@ -383,12 +480,6 @@ static int at91_rtc_resume(struct device *dev)
383 480
384static SIMPLE_DEV_PM_OPS(at91_rtc_pm_ops, at91_rtc_suspend, at91_rtc_resume); 481static SIMPLE_DEV_PM_OPS(at91_rtc_pm_ops, at91_rtc_suspend, at91_rtc_resume);
385 482
386static const struct of_device_id at91_rtc_dt_ids[] = {
387 { .compatible = "atmel,at91rm9200-rtc" },
388 { /* sentinel */ }
389};
390MODULE_DEVICE_TABLE(of, at91_rtc_dt_ids);
391
392static struct platform_driver at91_rtc_driver = { 483static struct platform_driver at91_rtc_driver = {
393 .remove = __exit_p(at91_rtc_remove), 484 .remove = __exit_p(at91_rtc_remove),
394 .driver = { 485 .driver = {
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index cc5bea9c4b1c..f1cb706445c7 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -854,6 +854,9 @@ static int cmos_resume(struct device *dev)
854 } 854 }
855 855
856 spin_lock_irq(&rtc_lock); 856 spin_lock_irq(&rtc_lock);
857 if (device_may_wakeup(dev))
858 hpet_rtc_timer_init();
859
857 do { 860 do {
858 CMOS_WRITE(tmp, RTC_CONTROL); 861 CMOS_WRITE(tmp, RTC_CONTROL);
859 hpet_set_rtc_irq_bit(tmp & RTC_IRQMASK); 862 hpet_set_rtc_irq_bit(tmp & RTC_IRQMASK);
@@ -869,7 +872,6 @@ static int cmos_resume(struct device *dev)
869 rtc_update_irq(cmos->rtc, 1, mask); 872 rtc_update_irq(cmos->rtc, 1, mask);
870 tmp &= ~RTC_AIE; 873 tmp &= ~RTC_AIE;
871 hpet_mask_rtc_irq_bit(RTC_AIE); 874 hpet_mask_rtc_irq_bit(RTC_AIE);
872 hpet_rtc_timer_init();
873 } while (mask & RTC_AIE); 875 } while (mask & RTC_AIE);
874 spin_unlock_irq(&rtc_lock); 876 spin_unlock_irq(&rtc_lock);
875 } 877 }
diff --git a/drivers/rtc/rtc-tps6586x.c b/drivers/rtc/rtc-tps6586x.c
index 459c2ffc95a6..426901cef14f 100644
--- a/drivers/rtc/rtc-tps6586x.c
+++ b/drivers/rtc/rtc-tps6586x.c
@@ -273,6 +273,8 @@ static int tps6586x_rtc_probe(struct platform_device *pdev)
273 return ret; 273 return ret;
274 } 274 }
275 275
276 device_init_wakeup(&pdev->dev, 1);
277
276 platform_set_drvdata(pdev, rtc); 278 platform_set_drvdata(pdev, rtc);
277 rtc->rtc = devm_rtc_device_register(&pdev->dev, dev_name(&pdev->dev), 279 rtc->rtc = devm_rtc_device_register(&pdev->dev, dev_name(&pdev->dev),
278 &tps6586x_rtc_ops, THIS_MODULE); 280 &tps6586x_rtc_ops, THIS_MODULE);
@@ -292,7 +294,6 @@ static int tps6586x_rtc_probe(struct platform_device *pdev)
292 goto fail_rtc_register; 294 goto fail_rtc_register;
293 } 295 }
294 disable_irq(rtc->irq); 296 disable_irq(rtc->irq);
295 device_set_wakeup_capable(&pdev->dev, 1);
296 return 0; 297 return 0;
297 298
298fail_rtc_register: 299fail_rtc_register:
diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c
index 8751a5240c99..b2eab34f38d9 100644
--- a/drivers/rtc/rtc-twl.c
+++ b/drivers/rtc/rtc-twl.c
@@ -524,6 +524,7 @@ static int twl_rtc_probe(struct platform_device *pdev)
524 } 524 }
525 525
526 platform_set_drvdata(pdev, rtc); 526 platform_set_drvdata(pdev, rtc);
527 device_init_wakeup(&pdev->dev, 1);
527 return 0; 528 return 0;
528 529
529out2: 530out2:
diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
index 4ffa66c87ea5..9ca3996f65b2 100644
--- a/drivers/s390/net/netiucv.c
+++ b/drivers/s390/net/netiucv.c
@@ -2040,6 +2040,7 @@ static struct net_device *netiucv_init_netdevice(char *username, char *userdata)
2040 netiucv_setup_netdevice); 2040 netiucv_setup_netdevice);
2041 if (!dev) 2041 if (!dev)
2042 return NULL; 2042 return NULL;
2043 rtnl_lock();
2043 if (dev_alloc_name(dev, dev->name) < 0) 2044 if (dev_alloc_name(dev, dev->name) < 0)
2044 goto out_netdev; 2045 goto out_netdev;
2045 2046
@@ -2061,6 +2062,7 @@ static struct net_device *netiucv_init_netdevice(char *username, char *userdata)
2061out_fsm: 2062out_fsm:
2062 kfree_fsm(privptr->fsm); 2063 kfree_fsm(privptr->fsm);
2063out_netdev: 2064out_netdev:
2065 rtnl_unlock();
2064 free_netdev(dev); 2066 free_netdev(dev);
2065 return NULL; 2067 return NULL;
2066} 2068}
@@ -2100,6 +2102,7 @@ static ssize_t conn_write(struct device_driver *drv,
2100 2102
2101 rc = netiucv_register_device(dev); 2103 rc = netiucv_register_device(dev);
2102 if (rc) { 2104 if (rc) {
2105 rtnl_unlock();
2103 IUCV_DBF_TEXT_(setup, 2, 2106 IUCV_DBF_TEXT_(setup, 2,
2104 "ret %d from netiucv_register_device\n", rc); 2107 "ret %d from netiucv_register_device\n", rc);
2105 goto out_free_ndev; 2108 goto out_free_ndev;
@@ -2109,7 +2112,8 @@ static ssize_t conn_write(struct device_driver *drv,
2109 priv = netdev_priv(dev); 2112 priv = netdev_priv(dev);
2110 SET_NETDEV_DEV(dev, priv->dev); 2113 SET_NETDEV_DEV(dev, priv->dev);
2111 2114
2112 rc = register_netdev(dev); 2115 rc = register_netdevice(dev);
2116 rtnl_unlock();
2113 if (rc) 2117 if (rc)
2114 goto out_unreg; 2118 goto out_unreg;
2115 2119
diff --git a/drivers/scsi/bfa/bfad_debugfs.c b/drivers/scsi/bfa/bfad_debugfs.c
index 439c012be763..b63d534192e3 100644
--- a/drivers/scsi/bfa/bfad_debugfs.c
+++ b/drivers/scsi/bfa/bfad_debugfs.c
@@ -186,7 +186,7 @@ bfad_debugfs_lseek(struct file *file, loff_t offset, int orig)
186 file->f_pos += offset; 186 file->f_pos += offset;
187 break; 187 break;
188 case 2: 188 case 2:
189 file->f_pos = debug->buffer_len - offset; 189 file->f_pos = debug->buffer_len + offset;
190 break; 190 break;
191 default: 191 default:
192 return -EINVAL; 192 return -EINVAL;
diff --git a/drivers/scsi/fnic/fnic_debugfs.c b/drivers/scsi/fnic/fnic_debugfs.c
index adc1f7f471f5..85e1ffd0e5c5 100644
--- a/drivers/scsi/fnic/fnic_debugfs.c
+++ b/drivers/scsi/fnic/fnic_debugfs.c
@@ -174,7 +174,7 @@ static loff_t fnic_trace_debugfs_lseek(struct file *file,
174 pos = file->f_pos + offset; 174 pos = file->f_pos + offset;
175 break; 175 break;
176 case 2: 176 case 2:
177 pos = fnic_dbg_prt->buffer_len - offset; 177 pos = fnic_dbg_prt->buffer_len + offset;
178 } 178 }
179 return (pos < 0 || pos > fnic_dbg_prt->buffer_len) ? 179 return (pos < 0 || pos > fnic_dbg_prt->buffer_len) ?
180 -EINVAL : (file->f_pos = pos); 180 -EINVAL : (file->f_pos = pos);
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index f63f5ff7f274..f525ecb7a9c6 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -1178,7 +1178,7 @@ lpfc_debugfs_lseek(struct file *file, loff_t off, int whence)
1178 pos = file->f_pos + off; 1178 pos = file->f_pos + off;
1179 break; 1179 break;
1180 case 2: 1180 case 2:
1181 pos = debug->len - off; 1181 pos = debug->len + off;
1182 } 1182 }
1183 return (pos < 0 || pos > debug->len) ? -EINVAL : (file->f_pos = pos); 1183 return (pos < 0 || pos > debug->len) ? -EINVAL : (file->f_pos = pos);
1184} 1184}
diff --git a/drivers/staging/media/davinci_vpfe/Kconfig b/drivers/staging/media/davinci_vpfe/Kconfig
index 2e4a28b018e8..12f321dd2399 100644
--- a/drivers/staging/media/davinci_vpfe/Kconfig
+++ b/drivers/staging/media/davinci_vpfe/Kconfig
@@ -1,6 +1,6 @@
1config VIDEO_DM365_VPFE 1config VIDEO_DM365_VPFE
2 tristate "DM365 VPFE Media Controller Capture Driver" 2 tristate "DM365 VPFE Media Controller Capture Driver"
3 depends on VIDEO_V4L2 && ARCH_DAVINCI_DM365 && !VIDEO_VPFE_CAPTURE 3 depends on VIDEO_V4L2 && ARCH_DAVINCI_DM365 && !VIDEO_DM365_ISIF
4 select VIDEOBUF2_DMA_CONTIG 4 select VIDEOBUF2_DMA_CONTIG
5 help 5 help
6 Support for DM365 VPFE based Media Controller Capture driver. 6 Support for DM365 VPFE based Media Controller Capture driver.
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
index b88e1ddce229..d8ce20d2fbda 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
@@ -639,7 +639,8 @@ static int vpfe_probe(struct platform_device *pdev)
639 if (ret) 639 if (ret)
640 goto probe_free_dev_mem; 640 goto probe_free_dev_mem;
641 641
642 if (vpfe_initialize_modules(vpfe_dev, pdev)) 642 ret = vpfe_initialize_modules(vpfe_dev, pdev);
643 if (ret)
643 goto probe_disable_clock; 644 goto probe_disable_clock;
644 645
645 vpfe_dev->media_dev.dev = vpfe_dev->pdev; 646 vpfe_dev->media_dev.dev = vpfe_dev->pdev;
@@ -663,7 +664,8 @@ static int vpfe_probe(struct platform_device *pdev)
663 /* set the driver data in platform device */ 664 /* set the driver data in platform device */
664 platform_set_drvdata(pdev, vpfe_dev); 665 platform_set_drvdata(pdev, vpfe_dev);
665 /* register subdevs/entities */ 666 /* register subdevs/entities */
666 if (vpfe_register_entities(vpfe_dev)) 667 ret = vpfe_register_entities(vpfe_dev);
668 if (ret)
667 goto probe_out_v4l2_unregister; 669 goto probe_out_v4l2_unregister;
668 670
669 ret = vpfe_attach_irq(vpfe_dev); 671 ret = vpfe_attach_irq(vpfe_dev);
diff --git a/drivers/staging/media/solo6x10/Kconfig b/drivers/staging/media/solo6x10/Kconfig
index df6569b997b8..34f3b6d02d2a 100644
--- a/drivers/staging/media/solo6x10/Kconfig
+++ b/drivers/staging/media/solo6x10/Kconfig
@@ -5,6 +5,7 @@ config SOLO6X10
5 select VIDEOBUF2_DMA_SG 5 select VIDEOBUF2_DMA_SG
6 select VIDEOBUF2_DMA_CONTIG 6 select VIDEOBUF2_DMA_CONTIG
7 select SND_PCM 7 select SND_PCM
8 select FONT_8x16
8 ---help--- 9 ---help---
9 This driver supports the Softlogic based MPEG-4 and h.264 codec 10 This driver supports the Softlogic based MPEG-4 and h.264 codec
10 cards. 11 cards.
diff --git a/drivers/tty/serial/8250/8250_gsc.c b/drivers/tty/serial/8250/8250_gsc.c
index 097dff9c08ad..bb91b4713ebd 100644
--- a/drivers/tty/serial/8250/8250_gsc.c
+++ b/drivers/tty/serial/8250/8250_gsc.c
@@ -30,6 +30,12 @@ static int __init serial_init_chip(struct parisc_device *dev)
30 unsigned long address; 30 unsigned long address;
31 int err; 31 int err;
32 32
33#ifdef CONFIG_64BIT
34 extern int iosapic_serial_irq(int cellnum);
35 if (!dev->irq && (dev->id.sversion == 0xad))
36 dev->irq = iosapic_serial_irq(dev->mod_index-1);
37#endif
38
33 if (!dev->irq) { 39 if (!dev->irq) {
34 /* We find some unattached serial ports by walking native 40 /* We find some unattached serial ports by walking native
35 * busses. These should be silently ignored. Otherwise, 41 * busses. These should be silently ignored. Otherwise,
@@ -51,7 +57,8 @@ static int __init serial_init_chip(struct parisc_device *dev)
51 memset(&uart, 0, sizeof(uart)); 57 memset(&uart, 0, sizeof(uart));
52 uart.port.iotype = UPIO_MEM; 58 uart.port.iotype = UPIO_MEM;
53 /* 7.272727MHz on Lasi. Assumed the same for Dino, Wax and Timi. */ 59 /* 7.272727MHz on Lasi. Assumed the same for Dino, Wax and Timi. */
54 uart.port.uartclk = 7272727; 60 uart.port.uartclk = (dev->id.sversion != 0xad) ?
61 7272727 : 1843200;
55 uart.port.mapbase = address; 62 uart.port.mapbase = address;
56 uart.port.membase = ioremap_nocache(address, 16); 63 uart.port.membase = ioremap_nocache(address, 16);
57 uart.port.irq = dev->irq; 64 uart.port.irq = dev->irq;
@@ -73,6 +80,7 @@ static struct parisc_device_id serial_tbl[] = {
73 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00075 }, 80 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00075 },
74 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008c }, 81 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008c },
75 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008d }, 82 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008d },
83 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x000ad },
76 { 0 } 84 { 0 }
77}; 85};
78 86
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 49b098bedf9b..475c9c114689 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -276,8 +276,9 @@ static void ci_role_work(struct work_struct *work)
276 276
277 ci_role_stop(ci); 277 ci_role_stop(ci);
278 ci_role_start(ci, role); 278 ci_role_start(ci, role);
279 enable_irq(ci->irq);
280 } 279 }
280
281 enable_irq(ci->irq);
281} 282}
282 283
283static irqreturn_t ci_irq(int irq, void *data) 284static irqreturn_t ci_irq(int irq, void *data)
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 519ead2443c5..b501346484ae 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1678,8 +1678,11 @@ static int udc_start(struct ci13xxx *ci)
1678 1678
1679 ci->gadget.ep0 = &ci->ep0in->ep; 1679 ci->gadget.ep0 = &ci->ep0in->ep;
1680 1680
1681 if (ci->global_phy) 1681 if (ci->global_phy) {
1682 ci->transceiver = usb_get_phy(USB_PHY_TYPE_USB2); 1682 ci->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
1683 if (IS_ERR(ci->transceiver))
1684 ci->transceiver = NULL;
1685 }
1683 1686
1684 if (ci->platdata->flags & CI13XXX_REQUIRE_TRANSCEIVER) { 1687 if (ci->platdata->flags & CI13XXX_REQUIRE_TRANSCEIVER) {
1685 if (ci->transceiver == NULL) { 1688 if (ci->transceiver == NULL) {
@@ -1694,7 +1697,7 @@ static int udc_start(struct ci13xxx *ci)
1694 goto put_transceiver; 1697 goto put_transceiver;
1695 } 1698 }
1696 1699
1697 if (!IS_ERR_OR_NULL(ci->transceiver)) { 1700 if (ci->transceiver) {
1698 retval = otg_set_peripheral(ci->transceiver->otg, 1701 retval = otg_set_peripheral(ci->transceiver->otg,
1699 &ci->gadget); 1702 &ci->gadget);
1700 if (retval) 1703 if (retval)
@@ -1711,7 +1714,7 @@ static int udc_start(struct ci13xxx *ci)
1711 return retval; 1714 return retval;
1712 1715
1713remove_trans: 1716remove_trans:
1714 if (!IS_ERR_OR_NULL(ci->transceiver)) { 1717 if (ci->transceiver) {
1715 otg_set_peripheral(ci->transceiver->otg, NULL); 1718 otg_set_peripheral(ci->transceiver->otg, NULL);
1716 if (ci->global_phy) 1719 if (ci->global_phy)
1717 usb_put_phy(ci->transceiver); 1720 usb_put_phy(ci->transceiver);
@@ -1719,7 +1722,7 @@ remove_trans:
1719 1722
1720 dev_err(dev, "error = %i\n", retval); 1723 dev_err(dev, "error = %i\n", retval);
1721put_transceiver: 1724put_transceiver:
1722 if (!IS_ERR_OR_NULL(ci->transceiver) && ci->global_phy) 1725 if (ci->transceiver && ci->global_phy)
1723 usb_put_phy(ci->transceiver); 1726 usb_put_phy(ci->transceiver);
1724destroy_eps: 1727destroy_eps:
1725 destroy_eps(ci); 1728 destroy_eps(ci);
@@ -1747,7 +1750,7 @@ static void udc_stop(struct ci13xxx *ci)
1747 dma_pool_destroy(ci->td_pool); 1750 dma_pool_destroy(ci->td_pool);
1748 dma_pool_destroy(ci->qh_pool); 1751 dma_pool_destroy(ci->qh_pool);
1749 1752
1750 if (!IS_ERR_OR_NULL(ci->transceiver)) { 1753 if (ci->transceiver) {
1751 otg_set_peripheral(ci->transceiver->otg, NULL); 1754 otg_set_peripheral(ci->transceiver->otg, NULL);
1752 if (ci->global_phy) 1755 if (ci->global_phy)
1753 usb_put_phy(ci->transceiver); 1756 usb_put_phy(ci->transceiver);
diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c
index 090b411d893f..7d8dd5aad236 100644
--- a/drivers/usb/serial/f81232.c
+++ b/drivers/usb/serial/f81232.c
@@ -165,11 +165,12 @@ static void f81232_set_termios(struct tty_struct *tty,
165 /* FIXME - Stubbed out for now */ 165 /* FIXME - Stubbed out for now */
166 166
167 /* Don't change anything if nothing has changed */ 167 /* Don't change anything if nothing has changed */
168 if (!tty_termios_hw_change(&tty->termios, old_termios)) 168 if (old_termios && !tty_termios_hw_change(&tty->termios, old_termios))
169 return; 169 return;
170 170
171 /* Do the real work here... */ 171 /* Do the real work here... */
172 tty_termios_copy_hw(&tty->termios, old_termios); 172 if (old_termios)
173 tty_termios_copy_hw(&tty->termios, old_termios);
173} 174}
174 175
175static int f81232_tiocmget(struct tty_struct *tty) 176static int f81232_tiocmget(struct tty_struct *tty)
@@ -187,12 +188,11 @@ static int f81232_tiocmset(struct tty_struct *tty,
187 188
188static int f81232_open(struct tty_struct *tty, struct usb_serial_port *port) 189static int f81232_open(struct tty_struct *tty, struct usb_serial_port *port)
189{ 190{
190 struct ktermios tmp_termios;
191 int result; 191 int result;
192 192
193 /* Setup termios */ 193 /* Setup termios */
194 if (tty) 194 if (tty)
195 f81232_set_termios(tty, port, &tmp_termios); 195 f81232_set_termios(tty, port, NULL);
196 196
197 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 197 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
198 if (result) { 198 if (result) {
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 7151659367a0..048cd44d51b1 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -284,7 +284,7 @@ static void pl2303_set_termios(struct tty_struct *tty,
284 serial settings even to the same values as before. Thus 284 serial settings even to the same values as before. Thus
285 we actually need to filter in this specific case */ 285 we actually need to filter in this specific case */
286 286
287 if (!tty_termios_hw_change(&tty->termios, old_termios)) 287 if (old_termios && !tty_termios_hw_change(&tty->termios, old_termios))
288 return; 288 return;
289 289
290 cflag = tty->termios.c_cflag; 290 cflag = tty->termios.c_cflag;
@@ -293,7 +293,8 @@ static void pl2303_set_termios(struct tty_struct *tty,
293 if (!buf) { 293 if (!buf) {
294 dev_err(&port->dev, "%s - out of memory.\n", __func__); 294 dev_err(&port->dev, "%s - out of memory.\n", __func__);
295 /* Report back no change occurred */ 295 /* Report back no change occurred */
296 tty->termios = *old_termios; 296 if (old_termios)
297 tty->termios = *old_termios;
297 return; 298 return;
298 } 299 }
299 300
@@ -433,7 +434,7 @@ static void pl2303_set_termios(struct tty_struct *tty,
433 control = priv->line_control; 434 control = priv->line_control;
434 if ((cflag & CBAUD) == B0) 435 if ((cflag & CBAUD) == B0)
435 priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS); 436 priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS);
436 else if ((old_termios->c_cflag & CBAUD) == B0) 437 else if (old_termios && (old_termios->c_cflag & CBAUD) == B0)
437 priv->line_control |= (CONTROL_DTR | CONTROL_RTS); 438 priv->line_control |= (CONTROL_DTR | CONTROL_RTS);
438 if (control != priv->line_control) { 439 if (control != priv->line_control) {
439 control = priv->line_control; 440 control = priv->line_control;
@@ -492,7 +493,6 @@ static void pl2303_close(struct usb_serial_port *port)
492 493
493static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port) 494static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port)
494{ 495{
495 struct ktermios tmp_termios;
496 struct usb_serial *serial = port->serial; 496 struct usb_serial *serial = port->serial;
497 struct pl2303_serial_private *spriv = usb_get_serial_data(serial); 497 struct pl2303_serial_private *spriv = usb_get_serial_data(serial);
498 int result; 498 int result;
@@ -508,7 +508,7 @@ static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port)
508 508
509 /* Setup termios */ 509 /* Setup termios */
510 if (tty) 510 if (tty)
511 pl2303_set_termios(tty, port, &tmp_termios); 511 pl2303_set_termios(tty, port, NULL);
512 512
513 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 513 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
514 if (result) { 514 if (result) {
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c
index cf3df793c2b7..ddf6c47137dc 100644
--- a/drivers/usb/serial/spcp8x5.c
+++ b/drivers/usb/serial/spcp8x5.c
@@ -291,7 +291,6 @@ static void spcp8x5_set_termios(struct tty_struct *tty,
291 struct spcp8x5_private *priv = usb_get_serial_port_data(port); 291 struct spcp8x5_private *priv = usb_get_serial_port_data(port);
292 unsigned long flags; 292 unsigned long flags;
293 unsigned int cflag = tty->termios.c_cflag; 293 unsigned int cflag = tty->termios.c_cflag;
294 unsigned int old_cflag = old_termios->c_cflag;
295 unsigned short uartdata; 294 unsigned short uartdata;
296 unsigned char buf[2] = {0, 0}; 295 unsigned char buf[2] = {0, 0};
297 int baud; 296 int baud;
@@ -299,15 +298,15 @@ static void spcp8x5_set_termios(struct tty_struct *tty,
299 u8 control; 298 u8 control;
300 299
301 /* check that they really want us to change something */ 300 /* check that they really want us to change something */
302 if (!tty_termios_hw_change(&tty->termios, old_termios)) 301 if (old_termios && !tty_termios_hw_change(&tty->termios, old_termios))
303 return; 302 return;
304 303
305 /* set DTR/RTS active */ 304 /* set DTR/RTS active */
306 spin_lock_irqsave(&priv->lock, flags); 305 spin_lock_irqsave(&priv->lock, flags);
307 control = priv->line_control; 306 control = priv->line_control;
308 if ((old_cflag & CBAUD) == B0) { 307 if (old_termios && (old_termios->c_cflag & CBAUD) == B0) {
309 priv->line_control |= MCR_DTR; 308 priv->line_control |= MCR_DTR;
310 if (!(old_cflag & CRTSCTS)) 309 if (!(old_termios->c_cflag & CRTSCTS))
311 priv->line_control |= MCR_RTS; 310 priv->line_control |= MCR_RTS;
312 } 311 }
313 if (control != priv->line_control) { 312 if (control != priv->line_control) {
@@ -394,7 +393,6 @@ static void spcp8x5_set_termios(struct tty_struct *tty,
394 393
395static int spcp8x5_open(struct tty_struct *tty, struct usb_serial_port *port) 394static int spcp8x5_open(struct tty_struct *tty, struct usb_serial_port *port)
396{ 395{
397 struct ktermios tmp_termios;
398 struct usb_serial *serial = port->serial; 396 struct usb_serial *serial = port->serial;
399 struct spcp8x5_private *priv = usb_get_serial_port_data(port); 397 struct spcp8x5_private *priv = usb_get_serial_port_data(port);
400 int ret; 398 int ret;
@@ -411,7 +409,7 @@ static int spcp8x5_open(struct tty_struct *tty, struct usb_serial_port *port)
411 spcp8x5_set_ctrl_line(port, priv->line_control); 409 spcp8x5_set_ctrl_line(port, priv->line_control);
412 410
413 if (tty) 411 if (tty)
414 spcp8x5_set_termios(tty, port, &tmp_termios); 412 spcp8x5_set_termios(tty, port, NULL);
415 413
416 port->port.drain_delay = 256; 414 port->port.drain_delay = 256;
417 415
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 2b51e2336aa2..f80d3dd41d8c 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -155,14 +155,11 @@ static void vhost_net_ubuf_put_and_wait(struct vhost_net_ubuf_ref *ubufs)
155 155
156static void vhost_net_clear_ubuf_info(struct vhost_net *n) 156static void vhost_net_clear_ubuf_info(struct vhost_net *n)
157{ 157{
158
159 bool zcopy;
160 int i; 158 int i;
161 159
162 for (i = 0; i < n->dev.nvqs; ++i) { 160 for (i = 0; i < VHOST_NET_VQ_MAX; ++i) {
163 zcopy = vhost_net_zcopy_mask & (0x1 << i); 161 kfree(n->vqs[i].ubuf_info);
164 if (zcopy) 162 n->vqs[i].ubuf_info = NULL;
165 kfree(n->vqs[i].ubuf_info);
166 } 163 }
167} 164}
168 165
@@ -171,7 +168,7 @@ int vhost_net_set_ubuf_info(struct vhost_net *n)
171 bool zcopy; 168 bool zcopy;
172 int i; 169 int i;
173 170
174 for (i = 0; i < n->dev.nvqs; ++i) { 171 for (i = 0; i < VHOST_NET_VQ_MAX; ++i) {
175 zcopy = vhost_net_zcopy_mask & (0x1 << i); 172 zcopy = vhost_net_zcopy_mask & (0x1 << i);
176 if (!zcopy) 173 if (!zcopy)
177 continue; 174 continue;
@@ -183,12 +180,7 @@ int vhost_net_set_ubuf_info(struct vhost_net *n)
183 return 0; 180 return 0;
184 181
185err: 182err:
186 while (i--) { 183 vhost_net_clear_ubuf_info(n);
187 zcopy = vhost_net_zcopy_mask & (0x1 << i);
188 if (!zcopy)
189 continue;
190 kfree(n->vqs[i].ubuf_info);
191 }
192 return -ENOMEM; 184 return -ENOMEM;
193} 185}
194 186
@@ -196,12 +188,12 @@ void vhost_net_vq_reset(struct vhost_net *n)
196{ 188{
197 int i; 189 int i;
198 190
191 vhost_net_clear_ubuf_info(n);
192
199 for (i = 0; i < VHOST_NET_VQ_MAX; i++) { 193 for (i = 0; i < VHOST_NET_VQ_MAX; i++) {
200 n->vqs[i].done_idx = 0; 194 n->vqs[i].done_idx = 0;
201 n->vqs[i].upend_idx = 0; 195 n->vqs[i].upend_idx = 0;
202 n->vqs[i].ubufs = NULL; 196 n->vqs[i].ubufs = NULL;
203 kfree(n->vqs[i].ubuf_info);
204 n->vqs[i].ubuf_info = NULL;
205 n->vqs[i].vhost_hlen = 0; 197 n->vqs[i].vhost_hlen = 0;
206 n->vqs[i].sock_hlen = 0; 198 n->vqs[i].sock_hlen = 0;
207 } 199 }
@@ -436,7 +428,8 @@ static void handle_tx(struct vhost_net *net)
436 kref_get(&ubufs->kref); 428 kref_get(&ubufs->kref);
437 } 429 }
438 nvq->upend_idx = (nvq->upend_idx + 1) % UIO_MAXIOV; 430 nvq->upend_idx = (nvq->upend_idx + 1) % UIO_MAXIOV;
439 } 431 } else
432 msg.msg_control = NULL;
440 /* TODO: Check specific error and bomb out unless ENOBUFS? */ 433 /* TODO: Check specific error and bomb out unless ENOBUFS? */
441 err = sock->ops->sendmsg(NULL, sock, &msg, len); 434 err = sock->ops->sendmsg(NULL, sock, &msg, len);
442 if (unlikely(err < 0)) { 435 if (unlikely(err < 0)) {
@@ -1053,6 +1046,10 @@ static long vhost_net_set_owner(struct vhost_net *n)
1053 int r; 1046 int r;
1054 1047
1055 mutex_lock(&n->dev.mutex); 1048 mutex_lock(&n->dev.mutex);
1049 if (vhost_dev_has_owner(&n->dev)) {
1050 r = -EBUSY;
1051 goto out;
1052 }
1056 r = vhost_net_set_ubuf_info(n); 1053 r = vhost_net_set_ubuf_info(n);
1057 if (r) 1054 if (r)
1058 goto out; 1055 goto out;
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index beee7f5787e6..60aa5ad09a2f 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -344,13 +344,19 @@ static int vhost_attach_cgroups(struct vhost_dev *dev)
344} 344}
345 345
346/* Caller should have device mutex */ 346/* Caller should have device mutex */
347bool vhost_dev_has_owner(struct vhost_dev *dev)
348{
349 return dev->mm;
350}
351
352/* Caller should have device mutex */
347long vhost_dev_set_owner(struct vhost_dev *dev) 353long vhost_dev_set_owner(struct vhost_dev *dev)
348{ 354{
349 struct task_struct *worker; 355 struct task_struct *worker;
350 int err; 356 int err;
351 357
352 /* Is there an owner already? */ 358 /* Is there an owner already? */
353 if (dev->mm) { 359 if (vhost_dev_has_owner(dev)) {
354 err = -EBUSY; 360 err = -EBUSY;
355 goto err_mm; 361 goto err_mm;
356 } 362 }
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index a7ad63592987..64adcf99ff33 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -133,6 +133,7 @@ struct vhost_dev {
133 133
134long vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue **vqs, int nvqs); 134long vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue **vqs, int nvqs);
135long vhost_dev_set_owner(struct vhost_dev *dev); 135long vhost_dev_set_owner(struct vhost_dev *dev);
136bool vhost_dev_has_owner(struct vhost_dev *dev);
136long vhost_dev_check_owner(struct vhost_dev *); 137long vhost_dev_check_owner(struct vhost_dev *);
137struct vhost_memory *vhost_dev_reset_owner_prepare(void); 138struct vhost_memory *vhost_dev_reset_owner_prepare(void);
138void vhost_dev_reset_owner(struct vhost_dev *, struct vhost_memory *); 139void vhost_dev_reset_owner(struct vhost_dev *, struct vhost_memory *);
diff --git a/fs/aio.c b/fs/aio.c
index 7fe5bdee1630..2bbcacf74d0c 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -141,9 +141,6 @@ static void aio_free_ring(struct kioctx *ctx)
141 for (i = 0; i < ctx->nr_pages; i++) 141 for (i = 0; i < ctx->nr_pages; i++)
142 put_page(ctx->ring_pages[i]); 142 put_page(ctx->ring_pages[i]);
143 143
144 if (ctx->mmap_size)
145 vm_munmap(ctx->mmap_base, ctx->mmap_size);
146
147 if (ctx->ring_pages && ctx->ring_pages != ctx->internal_pages) 144 if (ctx->ring_pages && ctx->ring_pages != ctx->internal_pages)
148 kfree(ctx->ring_pages); 145 kfree(ctx->ring_pages);
149} 146}
@@ -322,11 +319,6 @@ static void free_ioctx(struct kioctx *ctx)
322 319
323 aio_free_ring(ctx); 320 aio_free_ring(ctx);
324 321
325 spin_lock(&aio_nr_lock);
326 BUG_ON(aio_nr - ctx->max_reqs > aio_nr);
327 aio_nr -= ctx->max_reqs;
328 spin_unlock(&aio_nr_lock);
329
330 pr_debug("freeing %p\n", ctx); 322 pr_debug("freeing %p\n", ctx);
331 323
332 /* 324 /*
@@ -435,17 +427,24 @@ static void kill_ioctx(struct kioctx *ctx)
435{ 427{
436 if (!atomic_xchg(&ctx->dead, 1)) { 428 if (!atomic_xchg(&ctx->dead, 1)) {
437 hlist_del_rcu(&ctx->list); 429 hlist_del_rcu(&ctx->list);
438 /* Between hlist_del_rcu() and dropping the initial ref */
439 synchronize_rcu();
440 430
441 /* 431 /*
442 * We can't punt to workqueue here because put_ioctx() -> 432 * It'd be more correct to do this in free_ioctx(), after all
443 * free_ioctx() will unmap the ringbuffer, and that has to be 433 * the outstanding kiocbs have finished - but by then io_destroy
444 * done in the original process's context. kill_ioctx_rcu/work() 434 * has already returned, so io_setup() could potentially return
445 * exist for exit_aio(), as in that path free_ioctx() won't do 435 * -EAGAIN with no ioctxs actually in use (as far as userspace
446 * the unmap. 436 * could tell).
447 */ 437 */
448 kill_ioctx_work(&ctx->rcu_work); 438 spin_lock(&aio_nr_lock);
439 BUG_ON(aio_nr - ctx->max_reqs > aio_nr);
440 aio_nr -= ctx->max_reqs;
441 spin_unlock(&aio_nr_lock);
442
443 if (ctx->mmap_size)
444 vm_munmap(ctx->mmap_base, ctx->mmap_size);
445
446 /* Between hlist_del_rcu() and dropping the initial ref */
447 call_rcu(&ctx->rcu_head, kill_ioctx_rcu);
449 } 448 }
450} 449}
451 450
@@ -495,10 +494,7 @@ void exit_aio(struct mm_struct *mm)
495 */ 494 */
496 ctx->mmap_size = 0; 495 ctx->mmap_size = 0;
497 496
498 if (!atomic_xchg(&ctx->dead, 1)) { 497 kill_ioctx(ctx);
499 hlist_del_rcu(&ctx->list);
500 call_rcu(&ctx->rcu_head, kill_ioctx_rcu);
501 }
502 } 498 }
503} 499}
504 500
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index e7b3cb5286a5..b8b60b660c8f 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2859,8 +2859,8 @@ fail_qgroup:
2859 btrfs_free_qgroup_config(fs_info); 2859 btrfs_free_qgroup_config(fs_info);
2860fail_trans_kthread: 2860fail_trans_kthread:
2861 kthread_stop(fs_info->transaction_kthread); 2861 kthread_stop(fs_info->transaction_kthread);
2862 del_fs_roots(fs_info);
2863 btrfs_cleanup_transaction(fs_info->tree_root); 2862 btrfs_cleanup_transaction(fs_info->tree_root);
2863 del_fs_roots(fs_info);
2864fail_cleaner: 2864fail_cleaner:
2865 kthread_stop(fs_info->cleaner_kthread); 2865 kthread_stop(fs_info->cleaner_kthread);
2866 2866
@@ -3512,15 +3512,15 @@ int close_ctree(struct btrfs_root *root)
3512 percpu_counter_sum(&fs_info->delalloc_bytes)); 3512 percpu_counter_sum(&fs_info->delalloc_bytes));
3513 } 3513 }
3514 3514
3515 free_root_pointers(fs_info, 1);
3516
3517 btrfs_free_block_groups(fs_info); 3515 btrfs_free_block_groups(fs_info);
3518 3516
3517 btrfs_stop_all_workers(fs_info);
3518
3519 del_fs_roots(fs_info); 3519 del_fs_roots(fs_info);
3520 3520
3521 iput(fs_info->btree_inode); 3521 free_root_pointers(fs_info, 1);
3522 3522
3523 btrfs_stop_all_workers(fs_info); 3523 iput(fs_info->btree_inode);
3524 3524
3525#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY 3525#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
3526 if (btrfs_test_opt(root, CHECK_INTEGRITY)) 3526 if (btrfs_test_opt(root, CHECK_INTEGRITY))
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index af978f7682b3..17f3064b4a3e 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8012,6 +8012,9 @@ int btrfs_drop_inode(struct inode *inode)
8012{ 8012{
8013 struct btrfs_root *root = BTRFS_I(inode)->root; 8013 struct btrfs_root *root = BTRFS_I(inode)->root;
8014 8014
8015 if (root == NULL)
8016 return 1;
8017
8015 /* the snap/subvol tree is on deleting */ 8018 /* the snap/subvol tree is on deleting */
8016 if (btrfs_root_refs(&root->root_item) == 0 && 8019 if (btrfs_root_refs(&root->root_item) == 0 &&
8017 root != root->fs_info->tree_root) 8020 root != root->fs_info->tree_root)
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 395b82031a42..4febca4fc2de 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -4082,7 +4082,7 @@ out:
4082 return inode; 4082 return inode;
4083} 4083}
4084 4084
4085static struct reloc_control *alloc_reloc_control(void) 4085static struct reloc_control *alloc_reloc_control(struct btrfs_fs_info *fs_info)
4086{ 4086{
4087 struct reloc_control *rc; 4087 struct reloc_control *rc;
4088 4088
@@ -4093,7 +4093,8 @@ static struct reloc_control *alloc_reloc_control(void)
4093 INIT_LIST_HEAD(&rc->reloc_roots); 4093 INIT_LIST_HEAD(&rc->reloc_roots);
4094 backref_cache_init(&rc->backref_cache); 4094 backref_cache_init(&rc->backref_cache);
4095 mapping_tree_init(&rc->reloc_root_tree); 4095 mapping_tree_init(&rc->reloc_root_tree);
4096 extent_io_tree_init(&rc->processed_blocks, NULL); 4096 extent_io_tree_init(&rc->processed_blocks,
4097 fs_info->btree_inode->i_mapping);
4097 return rc; 4098 return rc;
4098} 4099}
4099 4100
@@ -4110,7 +4111,7 @@ int btrfs_relocate_block_group(struct btrfs_root *extent_root, u64 group_start)
4110 int rw = 0; 4111 int rw = 0;
4111 int err = 0; 4112 int err = 0;
4112 4113
4113 rc = alloc_reloc_control(); 4114 rc = alloc_reloc_control(fs_info);
4114 if (!rc) 4115 if (!rc)
4115 return -ENOMEM; 4116 return -ENOMEM;
4116 4117
@@ -4311,7 +4312,7 @@ int btrfs_recover_relocation(struct btrfs_root *root)
4311 if (list_empty(&reloc_roots)) 4312 if (list_empty(&reloc_roots))
4312 goto out; 4313 goto out;
4313 4314
4314 rc = alloc_reloc_control(); 4315 rc = alloc_reloc_control(root->fs_info);
4315 if (!rc) { 4316 if (!rc) {
4316 err = -ENOMEM; 4317 err = -ENOMEM;
4317 goto out; 4318 goto out;
diff --git a/fs/ceph/locks.c b/fs/ceph/locks.c
index 202dd3d68be0..ebbf680378e2 100644
--- a/fs/ceph/locks.c
+++ b/fs/ceph/locks.c
@@ -191,27 +191,23 @@ void ceph_count_locks(struct inode *inode, int *fcntl_count, int *flock_count)
191} 191}
192 192
193/** 193/**
194 * Encode the flock and fcntl locks for the given inode into the pagelist. 194 * Encode the flock and fcntl locks for the given inode into the ceph_filelock
195 * Format is: #fcntl locks, sequential fcntl locks, #flock locks, 195 * array. Must be called with lock_flocks() already held.
196 * sequential flock locks. 196 * If we encounter more of a specific lock type than expected, return -ENOSPC.
197 * Must be called with lock_flocks() already held.
198 * If we encounter more of a specific lock type than expected,
199 * we return the value 1.
200 */ 197 */
201int ceph_encode_locks(struct inode *inode, struct ceph_pagelist *pagelist, 198int ceph_encode_locks_to_buffer(struct inode *inode,
202 int num_fcntl_locks, int num_flock_locks) 199 struct ceph_filelock *flocks,
200 int num_fcntl_locks, int num_flock_locks)
203{ 201{
204 struct file_lock *lock; 202 struct file_lock *lock;
205 struct ceph_filelock cephlock;
206 int err = 0; 203 int err = 0;
207 int seen_fcntl = 0; 204 int seen_fcntl = 0;
208 int seen_flock = 0; 205 int seen_flock = 0;
206 int l = 0;
209 207
210 dout("encoding %d flock and %d fcntl locks", num_flock_locks, 208 dout("encoding %d flock and %d fcntl locks", num_flock_locks,
211 num_fcntl_locks); 209 num_fcntl_locks);
212 err = ceph_pagelist_append(pagelist, &num_fcntl_locks, sizeof(u32)); 210
213 if (err)
214 goto fail;
215 for (lock = inode->i_flock; lock != NULL; lock = lock->fl_next) { 211 for (lock = inode->i_flock; lock != NULL; lock = lock->fl_next) {
216 if (lock->fl_flags & FL_POSIX) { 212 if (lock->fl_flags & FL_POSIX) {
217 ++seen_fcntl; 213 ++seen_fcntl;
@@ -219,19 +215,12 @@ int ceph_encode_locks(struct inode *inode, struct ceph_pagelist *pagelist,
219 err = -ENOSPC; 215 err = -ENOSPC;
220 goto fail; 216 goto fail;
221 } 217 }
222 err = lock_to_ceph_filelock(lock, &cephlock); 218 err = lock_to_ceph_filelock(lock, &flocks[l]);
223 if (err) 219 if (err)
224 goto fail; 220 goto fail;
225 err = ceph_pagelist_append(pagelist, &cephlock, 221 ++l;
226 sizeof(struct ceph_filelock));
227 } 222 }
228 if (err)
229 goto fail;
230 } 223 }
231
232 err = ceph_pagelist_append(pagelist, &num_flock_locks, sizeof(u32));
233 if (err)
234 goto fail;
235 for (lock = inode->i_flock; lock != NULL; lock = lock->fl_next) { 224 for (lock = inode->i_flock; lock != NULL; lock = lock->fl_next) {
236 if (lock->fl_flags & FL_FLOCK) { 225 if (lock->fl_flags & FL_FLOCK) {
237 ++seen_flock; 226 ++seen_flock;
@@ -239,19 +228,51 @@ int ceph_encode_locks(struct inode *inode, struct ceph_pagelist *pagelist,
239 err = -ENOSPC; 228 err = -ENOSPC;
240 goto fail; 229 goto fail;
241 } 230 }
242 err = lock_to_ceph_filelock(lock, &cephlock); 231 err = lock_to_ceph_filelock(lock, &flocks[l]);
243 if (err) 232 if (err)
244 goto fail; 233 goto fail;
245 err = ceph_pagelist_append(pagelist, &cephlock, 234 ++l;
246 sizeof(struct ceph_filelock));
247 } 235 }
248 if (err)
249 goto fail;
250 } 236 }
251fail: 237fail:
252 return err; 238 return err;
253} 239}
254 240
241/**
242 * Copy the encoded flock and fcntl locks into the pagelist.
243 * Format is: #fcntl locks, sequential fcntl locks, #flock locks,
244 * sequential flock locks.
245 * Returns zero on success.
246 */
247int ceph_locks_to_pagelist(struct ceph_filelock *flocks,
248 struct ceph_pagelist *pagelist,
249 int num_fcntl_locks, int num_flock_locks)
250{
251 int err = 0;
252 __le32 nlocks;
253
254 nlocks = cpu_to_le32(num_fcntl_locks);
255 err = ceph_pagelist_append(pagelist, &nlocks, sizeof(nlocks));
256 if (err)
257 goto out_fail;
258
259 err = ceph_pagelist_append(pagelist, flocks,
260 num_fcntl_locks * sizeof(*flocks));
261 if (err)
262 goto out_fail;
263
264 nlocks = cpu_to_le32(num_flock_locks);
265 err = ceph_pagelist_append(pagelist, &nlocks, sizeof(nlocks));
266 if (err)
267 goto out_fail;
268
269 err = ceph_pagelist_append(pagelist,
270 &flocks[num_fcntl_locks],
271 num_flock_locks * sizeof(*flocks));
272out_fail:
273 return err;
274}
275
255/* 276/*
256 * Given a pointer to a lock, convert it to a ceph filelock 277 * Given a pointer to a lock, convert it to a ceph filelock
257 */ 278 */
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 4f22671a5bd4..4d2920304be8 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -2478,39 +2478,44 @@ static int encode_caps_cb(struct inode *inode, struct ceph_cap *cap,
2478 2478
2479 if (recon_state->flock) { 2479 if (recon_state->flock) {
2480 int num_fcntl_locks, num_flock_locks; 2480 int num_fcntl_locks, num_flock_locks;
2481 struct ceph_pagelist_cursor trunc_point; 2481 struct ceph_filelock *flocks;
2482 2482
2483 ceph_pagelist_set_cursor(pagelist, &trunc_point); 2483encode_again:
2484 do { 2484 lock_flocks();
2485 lock_flocks(); 2485 ceph_count_locks(inode, &num_fcntl_locks, &num_flock_locks);
2486 ceph_count_locks(inode, &num_fcntl_locks, 2486 unlock_flocks();
2487 &num_flock_locks); 2487 flocks = kmalloc((num_fcntl_locks+num_flock_locks) *
2488 rec.v2.flock_len = (2*sizeof(u32) + 2488 sizeof(struct ceph_filelock), GFP_NOFS);
2489 (num_fcntl_locks+num_flock_locks) * 2489 if (!flocks) {
2490 sizeof(struct ceph_filelock)); 2490 err = -ENOMEM;
2491 unlock_flocks(); 2491 goto out_free;
2492 2492 }
2493 /* pre-alloc pagelist */ 2493 lock_flocks();
2494 ceph_pagelist_truncate(pagelist, &trunc_point); 2494 err = ceph_encode_locks_to_buffer(inode, flocks,
2495 err = ceph_pagelist_append(pagelist, &rec, reclen); 2495 num_fcntl_locks,
2496 if (!err) 2496 num_flock_locks);
2497 err = ceph_pagelist_reserve(pagelist, 2497 unlock_flocks();
2498 rec.v2.flock_len); 2498 if (err) {
2499 2499 kfree(flocks);
2500 /* encode locks */ 2500 if (err == -ENOSPC)
2501 if (!err) { 2501 goto encode_again;
2502 lock_flocks(); 2502 goto out_free;
2503 err = ceph_encode_locks(inode, 2503 }
2504 pagelist, 2504 /*
2505 num_fcntl_locks, 2505 * number of encoded locks is stable, so copy to pagelist
2506 num_flock_locks); 2506 */
2507 unlock_flocks(); 2507 rec.v2.flock_len = cpu_to_le32(2*sizeof(u32) +
2508 } 2508 (num_fcntl_locks+num_flock_locks) *
2509 } while (err == -ENOSPC); 2509 sizeof(struct ceph_filelock));
2510 err = ceph_pagelist_append(pagelist, &rec, reclen);
2511 if (!err)
2512 err = ceph_locks_to_pagelist(flocks, pagelist,
2513 num_fcntl_locks,
2514 num_flock_locks);
2515 kfree(flocks);
2510 } else { 2516 } else {
2511 err = ceph_pagelist_append(pagelist, &rec, reclen); 2517 err = ceph_pagelist_append(pagelist, &rec, reclen);
2512 } 2518 }
2513
2514out_free: 2519out_free:
2515 kfree(path); 2520 kfree(path);
2516out_dput: 2521out_dput:
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index 8696be2ff679..7ccfdb4aea2e 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -822,8 +822,13 @@ extern const struct export_operations ceph_export_ops;
822extern int ceph_lock(struct file *file, int cmd, struct file_lock *fl); 822extern int ceph_lock(struct file *file, int cmd, struct file_lock *fl);
823extern int ceph_flock(struct file *file, int cmd, struct file_lock *fl); 823extern int ceph_flock(struct file *file, int cmd, struct file_lock *fl);
824extern void ceph_count_locks(struct inode *inode, int *p_num, int *f_num); 824extern void ceph_count_locks(struct inode *inode, int *p_num, int *f_num);
825extern int ceph_encode_locks(struct inode *i, struct ceph_pagelist *p, 825extern int ceph_encode_locks_to_buffer(struct inode *inode,
826 int p_locks, int f_locks); 826 struct ceph_filelock *flocks,
827 int num_fcntl_locks,
828 int num_flock_locks);
829extern int ceph_locks_to_pagelist(struct ceph_filelock *flocks,
830 struct ceph_pagelist *pagelist,
831 int num_fcntl_locks, int num_flock_locks);
827extern int lock_to_ceph_filelock(struct file_lock *fl, struct ceph_filelock *c); 832extern int lock_to_ceph_filelock(struct file_lock *fl, struct ceph_filelock *c);
828 833
829/* debugfs.c */ 834/* debugfs.c */
diff --git a/fs/file_table.c b/fs/file_table.c
index cd4d87a82951..485dc0eddd67 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -306,17 +306,18 @@ void fput(struct file *file)
306{ 306{
307 if (atomic_long_dec_and_test(&file->f_count)) { 307 if (atomic_long_dec_and_test(&file->f_count)) {
308 struct task_struct *task = current; 308 struct task_struct *task = current;
309 unsigned long flags;
310
309 file_sb_list_del(file); 311 file_sb_list_del(file);
310 if (unlikely(in_interrupt() || task->flags & PF_KTHREAD)) { 312 if (likely(!in_interrupt() && !(task->flags & PF_KTHREAD))) {
311 unsigned long flags; 313 init_task_work(&file->f_u.fu_rcuhead, ____fput);
312 spin_lock_irqsave(&delayed_fput_lock, flags); 314 if (!task_work_add(task, &file->f_u.fu_rcuhead, true))
313 list_add(&file->f_u.fu_list, &delayed_fput_list); 315 return;
314 schedule_work(&delayed_fput_work);
315 spin_unlock_irqrestore(&delayed_fput_lock, flags);
316 return;
317 } 316 }
318 init_task_work(&file->f_u.fu_rcuhead, ____fput); 317 spin_lock_irqsave(&delayed_fput_lock, flags);
319 task_work_add(task, &file->f_u.fu_rcuhead, true); 318 list_add(&file->f_u.fu_list, &delayed_fput_list);
319 schedule_work(&delayed_fput_work);
320 spin_unlock_irqrestore(&delayed_fput_lock, flags);
320 } 321 }
321} 322}
322 323
diff --git a/fs/namei.c b/fs/namei.c
index 85e40d1c0a8f..9ed9361223c0 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1976,7 +1976,7 @@ static int path_lookupat(int dfd, const char *name,
1976 err = complete_walk(nd); 1976 err = complete_walk(nd);
1977 1977
1978 if (!err && nd->flags & LOOKUP_DIRECTORY) { 1978 if (!err && nd->flags & LOOKUP_DIRECTORY) {
1979 if (!nd->inode->i_op->lookup) { 1979 if (!can_lookup(nd->inode)) {
1980 path_put(&nd->path); 1980 path_put(&nd->path);
1981 err = -ENOTDIR; 1981 err = -ENOTDIR;
1982 } 1982 }
@@ -2850,7 +2850,7 @@ finish_lookup:
2850 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode)) 2850 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
2851 goto out; 2851 goto out;
2852 error = -ENOTDIR; 2852 error = -ENOTDIR;
2853 if ((nd->flags & LOOKUP_DIRECTORY) && !nd->inode->i_op->lookup) 2853 if ((nd->flags & LOOKUP_DIRECTORY) && !can_lookup(nd->inode))
2854 goto out; 2854 goto out;
2855 audit_inode(name, nd->path.dentry, 0); 2855 audit_inode(name, nd->path.dentry, 0);
2856finish_open: 2856finish_open:
diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c
index 816326093656..6792ce11f2bf 100644
--- a/fs/ncpfs/dir.c
+++ b/fs/ncpfs/dir.c
@@ -1029,15 +1029,6 @@ static int ncp_rmdir(struct inode *dir, struct dentry *dentry)
1029 DPRINTK("ncp_rmdir: removing %s/%s\n", 1029 DPRINTK("ncp_rmdir: removing %s/%s\n",
1030 dentry->d_parent->d_name.name, dentry->d_name.name); 1030 dentry->d_parent->d_name.name, dentry->d_name.name);
1031 1031
1032 /*
1033 * fail with EBUSY if there are still references to this
1034 * directory.
1035 */
1036 dentry_unhash(dentry);
1037 error = -EBUSY;
1038 if (!d_unhashed(dentry))
1039 goto out;
1040
1041 len = sizeof(__name); 1032 len = sizeof(__name);
1042 error = ncp_io2vol(server, __name, &len, dentry->d_name.name, 1033 error = ncp_io2vol(server, __name, &len, dentry->d_name.name,
1043 dentry->d_name.len, !ncp_preserve_case(dir)); 1034 dentry->d_name.len, !ncp_preserve_case(dir));
diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index b3fdd1a323d6..e68588e6b1e8 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -1408,6 +1408,7 @@ int dlm_mig_lockres_handler(struct o2net_msg *msg, u32 len, void *data,
1408 mres->lockname_len, mres->lockname); 1408 mres->lockname_len, mres->lockname);
1409 ret = -EFAULT; 1409 ret = -EFAULT;
1410 spin_unlock(&res->spinlock); 1410 spin_unlock(&res->spinlock);
1411 dlm_lockres_put(res);
1411 goto leave; 1412 goto leave;
1412 } 1413 }
1413 res->state |= DLM_LOCK_RES_MIGRATING; 1414 res->state |= DLM_LOCK_RES_MIGRATING;
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 04ee1b57c243..b4a5cdf9dbc5 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -947,7 +947,7 @@ leave:
947 ocfs2_free_dir_lookup_result(&orphan_insert); 947 ocfs2_free_dir_lookup_result(&orphan_insert);
948 ocfs2_free_dir_lookup_result(&lookup); 948 ocfs2_free_dir_lookup_result(&lookup);
949 949
950 if (status) 950 if (status && (status != -ENOTEMPTY))
951 mlog_errno(status); 951 mlog_errno(status);
952 952
953 return status; 953 return status;
@@ -2216,7 +2216,7 @@ out:
2216 2216
2217 brelse(orphan_dir_bh); 2217 brelse(orphan_dir_bh);
2218 2218
2219 return 0; 2219 return ret;
2220} 2220}
2221 2221
2222int ocfs2_create_inode_in_orphan(struct inode *dir, 2222int ocfs2_create_inode_in_orphan(struct inode *dir,
diff --git a/fs/proc/kmsg.c b/fs/proc/kmsg.c
index bd4b5a740ff1..bdfabdaefdce 100644
--- a/fs/proc/kmsg.c
+++ b/fs/proc/kmsg.c
@@ -21,12 +21,12 @@ extern wait_queue_head_t log_wait;
21 21
22static int kmsg_open(struct inode * inode, struct file * file) 22static int kmsg_open(struct inode * inode, struct file * file)
23{ 23{
24 return do_syslog(SYSLOG_ACTION_OPEN, NULL, 0, SYSLOG_FROM_FILE); 24 return do_syslog(SYSLOG_ACTION_OPEN, NULL, 0, SYSLOG_FROM_PROC);
25} 25}
26 26
27static int kmsg_release(struct inode * inode, struct file * file) 27static int kmsg_release(struct inode * inode, struct file * file)
28{ 28{
29 (void) do_syslog(SYSLOG_ACTION_CLOSE, NULL, 0, SYSLOG_FROM_FILE); 29 (void) do_syslog(SYSLOG_ACTION_CLOSE, NULL, 0, SYSLOG_FROM_PROC);
30 return 0; 30 return 0;
31} 31}
32 32
@@ -34,15 +34,15 @@ static ssize_t kmsg_read(struct file *file, char __user *buf,
34 size_t count, loff_t *ppos) 34 size_t count, loff_t *ppos)
35{ 35{
36 if ((file->f_flags & O_NONBLOCK) && 36 if ((file->f_flags & O_NONBLOCK) &&
37 !do_syslog(SYSLOG_ACTION_SIZE_UNREAD, NULL, 0, SYSLOG_FROM_FILE)) 37 !do_syslog(SYSLOG_ACTION_SIZE_UNREAD, NULL, 0, SYSLOG_FROM_PROC))
38 return -EAGAIN; 38 return -EAGAIN;
39 return do_syslog(SYSLOG_ACTION_READ, buf, count, SYSLOG_FROM_FILE); 39 return do_syslog(SYSLOG_ACTION_READ, buf, count, SYSLOG_FROM_PROC);
40} 40}
41 41
42static unsigned int kmsg_poll(struct file *file, poll_table *wait) 42static unsigned int kmsg_poll(struct file *file, poll_table *wait)
43{ 43{
44 poll_wait(file, &log_wait, wait); 44 poll_wait(file, &log_wait, wait);
45 if (do_syslog(SYSLOG_ACTION_SIZE_UNREAD, NULL, 0, SYSLOG_FROM_FILE)) 45 if (do_syslog(SYSLOG_ACTION_SIZE_UNREAD, NULL, 0, SYSLOG_FROM_PROC))
46 return POLLIN | POLLRDNORM; 46 return POLLIN | POLLRDNORM;
47 return 0; 47 return 0;
48} 48}
diff --git a/fs/xfs/xfs_attr_leaf.h b/fs/xfs/xfs_attr_leaf.h
index f9d7846097e2..444a7704596c 100644
--- a/fs/xfs/xfs_attr_leaf.h
+++ b/fs/xfs/xfs_attr_leaf.h
@@ -128,6 +128,7 @@ struct xfs_attr3_leaf_hdr {
128 __u8 holes; 128 __u8 holes;
129 __u8 pad1; 129 __u8 pad1;
130 struct xfs_attr_leaf_map freemap[XFS_ATTR_LEAF_MAPSIZE]; 130 struct xfs_attr_leaf_map freemap[XFS_ATTR_LEAF_MAPSIZE];
131 __be32 pad2; /* 64 bit alignment */
131}; 132};
132 133
133#define XFS_ATTR3_LEAF_CRC_OFF (offsetof(struct xfs_attr3_leaf_hdr, info.crc)) 134#define XFS_ATTR3_LEAF_CRC_OFF (offsetof(struct xfs_attr3_leaf_hdr, info.crc))
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c
index 8804b8a3c310..0903960410a2 100644
--- a/fs/xfs/xfs_btree.c
+++ b/fs/xfs/xfs_btree.c
@@ -2544,7 +2544,17 @@ xfs_btree_new_iroot(
2544 if (error) 2544 if (error)
2545 goto error0; 2545 goto error0;
2546 2546
2547 /*
2548 * we can't just memcpy() the root in for CRC enabled btree blocks.
2549 * In that case have to also ensure the blkno remains correct
2550 */
2547 memcpy(cblock, block, xfs_btree_block_len(cur)); 2551 memcpy(cblock, block, xfs_btree_block_len(cur));
2552 if (cur->bc_flags & XFS_BTREE_CRC_BLOCKS) {
2553 if (cur->bc_flags & XFS_BTREE_LONG_PTRS)
2554 cblock->bb_u.l.bb_blkno = cpu_to_be64(cbp->b_bn);
2555 else
2556 cblock->bb_u.s.bb_blkno = cpu_to_be64(cbp->b_bn);
2557 }
2548 2558
2549 be16_add_cpu(&block->bb_level, 1); 2559 be16_add_cpu(&block->bb_level, 1);
2550 xfs_btree_set_numrecs(block, 1); 2560 xfs_btree_set_numrecs(block, 1);
diff --git a/fs/xfs/xfs_dir2_format.h b/fs/xfs/xfs_dir2_format.h
index 995f1f505a52..7826782b8d78 100644
--- a/fs/xfs/xfs_dir2_format.h
+++ b/fs/xfs/xfs_dir2_format.h
@@ -266,6 +266,7 @@ struct xfs_dir3_blk_hdr {
266struct xfs_dir3_data_hdr { 266struct xfs_dir3_data_hdr {
267 struct xfs_dir3_blk_hdr hdr; 267 struct xfs_dir3_blk_hdr hdr;
268 xfs_dir2_data_free_t best_free[XFS_DIR2_DATA_FD_COUNT]; 268 xfs_dir2_data_free_t best_free[XFS_DIR2_DATA_FD_COUNT];
269 __be32 pad; /* 64 bit alignment */
269}; 270};
270 271
271#define XFS_DIR3_DATA_CRC_OFF offsetof(struct xfs_dir3_data_hdr, hdr.crc) 272#define XFS_DIR3_DATA_CRC_OFF offsetof(struct xfs_dir3_data_hdr, hdr.crc)
@@ -477,7 +478,7 @@ struct xfs_dir3_leaf_hdr {
477 struct xfs_da3_blkinfo info; /* header for da routines */ 478 struct xfs_da3_blkinfo info; /* header for da routines */
478 __be16 count; /* count of entries */ 479 __be16 count; /* count of entries */
479 __be16 stale; /* count of stale entries */ 480 __be16 stale; /* count of stale entries */
480 __be32 pad; 481 __be32 pad; /* 64 bit alignment */
481}; 482};
482 483
483struct xfs_dir3_icleaf_hdr { 484struct xfs_dir3_icleaf_hdr {
@@ -715,7 +716,7 @@ struct xfs_dir3_free_hdr {
715 __be32 firstdb; /* db of first entry */ 716 __be32 firstdb; /* db of first entry */
716 __be32 nvalid; /* count of valid entries */ 717 __be32 nvalid; /* count of valid entries */
717 __be32 nused; /* count of used entries */ 718 __be32 nused; /* count of used entries */
718 __be32 pad; /* 64 bit alignment. */ 719 __be32 pad; /* 64 bit alignment */
719}; 720};
720 721
721struct xfs_dir3_free { 722struct xfs_dir3_free {
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 45a85ff84da1..7cf5e4eafe28 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -1845,7 +1845,13 @@ xlog_recover_do_inode_buffer(
1845 xfs_agino_t *buffer_nextp; 1845 xfs_agino_t *buffer_nextp;
1846 1846
1847 trace_xfs_log_recover_buf_inode_buf(mp->m_log, buf_f); 1847 trace_xfs_log_recover_buf_inode_buf(mp->m_log, buf_f);
1848 bp->b_ops = &xfs_inode_buf_ops; 1848
1849 /*
1850 * Post recovery validation only works properly on CRC enabled
1851 * filesystems.
1852 */
1853 if (xfs_sb_version_hascrc(&mp->m_sb))
1854 bp->b_ops = &xfs_inode_buf_ops;
1849 1855
1850 inodes_per_buf = BBTOB(bp->b_io_length) >> mp->m_sb.sb_inodelog; 1856 inodes_per_buf = BBTOB(bp->b_io_length) >> mp->m_sb.sb_inodelog;
1851 for (i = 0; i < inodes_per_buf; i++) { 1857 for (i = 0; i < inodes_per_buf; i++) {
@@ -2205,7 +2211,16 @@ xlog_recover_do_reg_buffer(
2205 /* Shouldn't be any more regions */ 2211 /* Shouldn't be any more regions */
2206 ASSERT(i == item->ri_total); 2212 ASSERT(i == item->ri_total);
2207 2213
2208 xlog_recovery_validate_buf_type(mp, bp, buf_f); 2214 /*
2215 * We can only do post recovery validation on items on CRC enabled
2216 * fielsystems as we need to know when the buffer was written to be able
2217 * to determine if we should have replayed the item. If we replay old
2218 * metadata over a newer buffer, then it will enter a temporarily
2219 * inconsistent state resulting in verification failures. Hence for now
2220 * just avoid the verification stage for non-crc filesystems
2221 */
2222 if (xfs_sb_version_hascrc(&mp->m_sb))
2223 xlog_recovery_validate_buf_type(mp, bp, buf_f);
2209} 2224}
2210 2225
2211/* 2226/*
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index f6bfbd734669..e8e310c05097 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -314,7 +314,8 @@ STATIC int
314xfs_mount_validate_sb( 314xfs_mount_validate_sb(
315 xfs_mount_t *mp, 315 xfs_mount_t *mp,
316 xfs_sb_t *sbp, 316 xfs_sb_t *sbp,
317 bool check_inprogress) 317 bool check_inprogress,
318 bool check_version)
318{ 319{
319 320
320 /* 321 /*
@@ -337,9 +338,10 @@ xfs_mount_validate_sb(
337 338
338 /* 339 /*
339 * Version 5 superblock feature mask validation. Reject combinations the 340 * Version 5 superblock feature mask validation. Reject combinations the
340 * kernel cannot support up front before checking anything else. 341 * kernel cannot support up front before checking anything else. For
342 * write validation, we don't need to check feature masks.
341 */ 343 */
342 if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) { 344 if (check_version && XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) {
343 xfs_alert(mp, 345 xfs_alert(mp,
344"Version 5 superblock detected. This kernel has EXPERIMENTAL support enabled!\n" 346"Version 5 superblock detected. This kernel has EXPERIMENTAL support enabled!\n"
345"Use of these features in this kernel is at your own risk!"); 347"Use of these features in this kernel is at your own risk!");
@@ -675,7 +677,8 @@ xfs_sb_to_disk(
675 677
676static int 678static int
677xfs_sb_verify( 679xfs_sb_verify(
678 struct xfs_buf *bp) 680 struct xfs_buf *bp,
681 bool check_version)
679{ 682{
680 struct xfs_mount *mp = bp->b_target->bt_mount; 683 struct xfs_mount *mp = bp->b_target->bt_mount;
681 struct xfs_sb sb; 684 struct xfs_sb sb;
@@ -686,7 +689,8 @@ xfs_sb_verify(
686 * Only check the in progress field for the primary superblock as 689 * Only check the in progress field for the primary superblock as
687 * mkfs.xfs doesn't clear it from secondary superblocks. 690 * mkfs.xfs doesn't clear it from secondary superblocks.
688 */ 691 */
689 return xfs_mount_validate_sb(mp, &sb, bp->b_bn == XFS_SB_DADDR); 692 return xfs_mount_validate_sb(mp, &sb, bp->b_bn == XFS_SB_DADDR,
693 check_version);
690} 694}
691 695
692/* 696/*
@@ -719,7 +723,7 @@ xfs_sb_read_verify(
719 goto out_error; 723 goto out_error;
720 } 724 }
721 } 725 }
722 error = xfs_sb_verify(bp); 726 error = xfs_sb_verify(bp, true);
723 727
724out_error: 728out_error:
725 if (error) { 729 if (error) {
@@ -758,7 +762,7 @@ xfs_sb_write_verify(
758 struct xfs_buf_log_item *bip = bp->b_fspriv; 762 struct xfs_buf_log_item *bip = bp->b_fspriv;
759 int error; 763 int error;
760 764
761 error = xfs_sb_verify(bp); 765 error = xfs_sb_verify(bp, false);
762 if (error) { 766 if (error) {
763 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, bp->b_addr); 767 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, bp->b_addr);
764 xfs_buf_ioerror(bp, error); 768 xfs_buf_ioerror(bp, error);
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 636c59f2003a..c13c919ab99e 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -382,6 +382,7 @@ const char *acpi_power_state_string(int state);
382int acpi_device_get_power(struct acpi_device *device, int *state); 382int acpi_device_get_power(struct acpi_device *device, int *state);
383int acpi_device_set_power(struct acpi_device *device, int state); 383int acpi_device_set_power(struct acpi_device *device, int state);
384int acpi_bus_init_power(struct acpi_device *device); 384int acpi_bus_init_power(struct acpi_device *device);
385int acpi_device_fix_up_power(struct acpi_device *device);
385int acpi_bus_update_power(acpi_handle handle, int *state_p); 386int acpi_bus_update_power(acpi_handle handle, int *state_p);
386bool acpi_bus_power_manageable(acpi_handle handle); 387bool acpi_bus_power_manageable(acpi_handle handle);
387 388
diff --git a/include/asm-generic/kvm_para.h b/include/asm-generic/kvm_para.h
index 9d96605f160a..fa25becbdcaf 100644
--- a/include/asm-generic/kvm_para.h
+++ b/include/asm-generic/kvm_para.h
@@ -18,4 +18,9 @@ static inline unsigned int kvm_arch_para_features(void)
18 return 0; 18 return 0;
19} 19}
20 20
21static inline bool kvm_para_available(void)
22{
23 return false;
24}
25
21#endif 26#endif
diff --git a/include/linux/context_tracking.h b/include/linux/context_tracking.h
index 365f4a61bf04..fc09d7b0dacf 100644
--- a/include/linux/context_tracking.h
+++ b/include/linux/context_tracking.h
@@ -3,6 +3,7 @@
3 3
4#include <linux/sched.h> 4#include <linux/sched.h>
5#include <linux/percpu.h> 5#include <linux/percpu.h>
6#include <linux/vtime.h>
6#include <asm/ptrace.h> 7#include <asm/ptrace.h>
7 8
8struct context_tracking { 9struct context_tracking {
@@ -19,6 +20,26 @@ struct context_tracking {
19 } state; 20 } state;
20}; 21};
21 22
23static inline void __guest_enter(void)
24{
25 /*
26 * This is running in ioctl context so we can avoid
27 * the call to vtime_account() with its unnecessary idle check.
28 */
29 vtime_account_system(current);
30 current->flags |= PF_VCPU;
31}
32
33static inline void __guest_exit(void)
34{
35 /*
36 * This is running in ioctl context so we can avoid
37 * the call to vtime_account() with its unnecessary idle check.
38 */
39 vtime_account_system(current);
40 current->flags &= ~PF_VCPU;
41}
42
22#ifdef CONFIG_CONTEXT_TRACKING 43#ifdef CONFIG_CONTEXT_TRACKING
23DECLARE_PER_CPU(struct context_tracking, context_tracking); 44DECLARE_PER_CPU(struct context_tracking, context_tracking);
24 45
@@ -35,6 +56,9 @@ static inline bool context_tracking_active(void)
35extern void user_enter(void); 56extern void user_enter(void);
36extern void user_exit(void); 57extern void user_exit(void);
37 58
59extern void guest_enter(void);
60extern void guest_exit(void);
61
38static inline enum ctx_state exception_enter(void) 62static inline enum ctx_state exception_enter(void)
39{ 63{
40 enum ctx_state prev_ctx; 64 enum ctx_state prev_ctx;
@@ -57,6 +81,17 @@ extern void context_tracking_task_switch(struct task_struct *prev,
57static inline bool context_tracking_in_user(void) { return false; } 81static inline bool context_tracking_in_user(void) { return false; }
58static inline void user_enter(void) { } 82static inline void user_enter(void) { }
59static inline void user_exit(void) { } 83static inline void user_exit(void) { }
84
85static inline void guest_enter(void)
86{
87 __guest_enter();
88}
89
90static inline void guest_exit(void)
91{
92 __guest_exit();
93}
94
60static inline enum ctx_state exception_enter(void) { return 0; } 95static inline enum ctx_state exception_enter(void) { return 0; }
61static inline void exception_exit(enum ctx_state prev_ctx) { } 96static inline void exception_exit(enum ctx_state prev_ctx) { }
62static inline void context_tracking_task_switch(struct task_struct *prev, 97static inline void context_tracking_task_switch(struct task_struct *prev,
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index c6f6e0839b61..9f3c7e81270a 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -175,6 +175,8 @@ extern struct bus_type cpu_subsys;
175 175
176extern void get_online_cpus(void); 176extern void get_online_cpus(void);
177extern void put_online_cpus(void); 177extern void put_online_cpus(void);
178extern void cpu_hotplug_disable(void);
179extern void cpu_hotplug_enable(void);
178#define hotcpu_notifier(fn, pri) cpu_notifier(fn, pri) 180#define hotcpu_notifier(fn, pri) cpu_notifier(fn, pri)
179#define register_hotcpu_notifier(nb) register_cpu_notifier(nb) 181#define register_hotcpu_notifier(nb) register_cpu_notifier(nb)
180#define unregister_hotcpu_notifier(nb) unregister_cpu_notifier(nb) 182#define unregister_hotcpu_notifier(nb) unregister_cpu_notifier(nb)
@@ -198,6 +200,8 @@ static inline void cpu_hotplug_driver_unlock(void)
198 200
199#define get_online_cpus() do { } while (0) 201#define get_online_cpus() do { } while (0)
200#define put_online_cpus() do { } while (0) 202#define put_online_cpus() do { } while (0)
203#define cpu_hotplug_disable() do { } while (0)
204#define cpu_hotplug_enable() do { } while (0)
201#define hotcpu_notifier(fn, pri) do { (void)(fn); } while (0) 205#define hotcpu_notifier(fn, pri) do { (void)(fn); } while (0)
202/* These aren't inline functions due to a GCC bug. */ 206/* These aren't inline functions due to a GCC bug. */
203#define register_hotcpu_notifier(nb) ({ (void)(nb); 0; }) 207#define register_hotcpu_notifier(nb) ({ (void)(nb); 0; })
diff --git a/include/linux/filter.h b/include/linux/filter.h
index c050dcc322a4..f65f5a69db8f 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -46,6 +46,7 @@ extern int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk);
46extern int sk_detach_filter(struct sock *sk); 46extern int sk_detach_filter(struct sock *sk);
47extern int sk_chk_filter(struct sock_filter *filter, unsigned int flen); 47extern int sk_chk_filter(struct sock_filter *filter, unsigned int flen);
48extern int sk_get_filter(struct sock *sk, struct sock_filter __user *filter, unsigned len); 48extern int sk_get_filter(struct sock *sk, struct sock_filter __user *filter, unsigned len);
49extern void sk_decode_filter(struct sock_filter *filt, struct sock_filter *to);
49 50
50#ifdef CONFIG_BPF_JIT 51#ifdef CONFIG_BPF_JIT
51#include <stdarg.h> 52#include <stdarg.h>
diff --git a/include/linux/if_team.h b/include/linux/if_team.h
index 4474557904f6..16fae6436d0e 100644
--- a/include/linux/if_team.h
+++ b/include/linux/if_team.h
@@ -249,12 +249,12 @@ team_get_first_port_txable_rcu(struct team *team, struct team_port *port)
249 return port; 249 return port;
250 cur = port; 250 cur = port;
251 list_for_each_entry_continue_rcu(cur, &team->port_list, list) 251 list_for_each_entry_continue_rcu(cur, &team->port_list, list)
252 if (team_port_txable(port)) 252 if (team_port_txable(cur))
253 return cur; 253 return cur;
254 list_for_each_entry_rcu(cur, &team->port_list, list) { 254 list_for_each_entry_rcu(cur, &team->port_list, list) {
255 if (cur == port) 255 if (cur == port)
256 break; 256 break;
257 if (team_port_txable(port)) 257 if (team_port_txable(cur))
258 return cur; 258 return cur;
259 } 259 }
260 return NULL; 260 return NULL;
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index f0eea07d2c2b..8db53cfaccdb 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -23,6 +23,7 @@
23#include <linux/ratelimit.h> 23#include <linux/ratelimit.h>
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/irqflags.h> 25#include <linux/irqflags.h>
26#include <linux/context_tracking.h>
26#include <asm/signal.h> 27#include <asm/signal.h>
27 28
28#include <linux/kvm.h> 29#include <linux/kvm.h>
@@ -760,42 +761,6 @@ static inline int kvm_iommu_unmap_guest(struct kvm *kvm)
760} 761}
761#endif 762#endif
762 763
763static inline void __guest_enter(void)
764{
765 /*
766 * This is running in ioctl context so we can avoid
767 * the call to vtime_account() with its unnecessary idle check.
768 */
769 vtime_account_system(current);
770 current->flags |= PF_VCPU;
771}
772
773static inline void __guest_exit(void)
774{
775 /*
776 * This is running in ioctl context so we can avoid
777 * the call to vtime_account() with its unnecessary idle check.
778 */
779 vtime_account_system(current);
780 current->flags &= ~PF_VCPU;
781}
782
783#ifdef CONFIG_CONTEXT_TRACKING
784extern void guest_enter(void);
785extern void guest_exit(void);
786
787#else /* !CONFIG_CONTEXT_TRACKING */
788static inline void guest_enter(void)
789{
790 __guest_enter();
791}
792
793static inline void guest_exit(void)
794{
795 __guest_exit();
796}
797#endif /* !CONFIG_CONTEXT_TRACKING */
798
799static inline void kvm_guest_enter(void) 764static inline void kvm_guest_enter(void)
800{ 765{
801 unsigned long flags; 766 unsigned long flags;
diff --git a/include/linux/math64.h b/include/linux/math64.h
index b8ba85544721..2913b86eb12a 100644
--- a/include/linux/math64.h
+++ b/include/linux/math64.h
@@ -6,7 +6,8 @@
6 6
7#if BITS_PER_LONG == 64 7#if BITS_PER_LONG == 64
8 8
9#define div64_long(x,y) div64_s64((x),(y)) 9#define div64_long(x, y) div64_s64((x), (y))
10#define div64_ul(x, y) div64_u64((x), (y))
10 11
11/** 12/**
12 * div_u64_rem - unsigned 64bit divide with 32bit divisor with remainder 13 * div_u64_rem - unsigned 64bit divide with 32bit divisor with remainder
@@ -47,7 +48,8 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
47 48
48#elif BITS_PER_LONG == 32 49#elif BITS_PER_LONG == 32
49 50
50#define div64_long(x,y) div_s64((x),(y)) 51#define div64_long(x, y) div_s64((x), (y))
52#define div64_ul(x, y) div_u64((x), (y))
51 53
52#ifndef div_u64_rem 54#ifndef div_u64_rem
53static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder) 55static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index f463a46424e2..c5b6dbf9c2fc 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -389,8 +389,7 @@ struct perf_event {
389 /* mmap bits */ 389 /* mmap bits */
390 struct mutex mmap_mutex; 390 struct mutex mmap_mutex;
391 atomic_t mmap_count; 391 atomic_t mmap_count;
392 int mmap_locked; 392
393 struct user_struct *mmap_user;
394 struct ring_buffer *rb; 393 struct ring_buffer *rb;
395 struct list_head rb_entry; 394 struct list_head rb_entry;
396 395
diff --git a/include/linux/preempt.h b/include/linux/preempt.h
index 87a03c746f17..f5d4723cdb3d 100644
--- a/include/linux/preempt.h
+++ b/include/linux/preempt.h
@@ -33,9 +33,25 @@ do { \
33 preempt_schedule(); \ 33 preempt_schedule(); \
34} while (0) 34} while (0)
35 35
36#ifdef CONFIG_CONTEXT_TRACKING
37
38void preempt_schedule_context(void);
39
40#define preempt_check_resched_context() \
41do { \
42 if (unlikely(test_thread_flag(TIF_NEED_RESCHED))) \
43 preempt_schedule_context(); \
44} while (0)
45#else
46
47#define preempt_check_resched_context() preempt_check_resched()
48
49#endif /* CONFIG_CONTEXT_TRACKING */
50
36#else /* !CONFIG_PREEMPT */ 51#else /* !CONFIG_PREEMPT */
37 52
38#define preempt_check_resched() do { } while (0) 53#define preempt_check_resched() do { } while (0)
54#define preempt_check_resched_context() do { } while (0)
39 55
40#endif /* CONFIG_PREEMPT */ 56#endif /* CONFIG_PREEMPT */
41 57
@@ -88,7 +104,7 @@ do { \
88do { \ 104do { \
89 preempt_enable_no_resched_notrace(); \ 105 preempt_enable_no_resched_notrace(); \
90 barrier(); \ 106 barrier(); \
91 preempt_check_resched(); \ 107 preempt_check_resched_context(); \
92} while (0) 108} while (0)
93 109
94#else /* !CONFIG_PREEMPT_COUNT */ 110#else /* !CONFIG_PREEMPT_COUNT */
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index 5951e3f38878..26806775b11b 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -111,6 +111,9 @@ static inline struct page *sg_page(struct scatterlist *sg)
111static inline void sg_set_buf(struct scatterlist *sg, const void *buf, 111static inline void sg_set_buf(struct scatterlist *sg, const void *buf,
112 unsigned int buflen) 112 unsigned int buflen)
113{ 113{
114#ifdef CONFIG_DEBUG_SG
115 BUG_ON(!virt_addr_valid(buf));
116#endif
114 sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf)); 117 sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf));
115} 118}
116 119
diff --git a/include/linux/smp.h b/include/linux/smp.h
index e6564c1dc552..c8488763277f 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -11,6 +11,7 @@
11#include <linux/list.h> 11#include <linux/list.h>
12#include <linux/cpumask.h> 12#include <linux/cpumask.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/irqflags.h>
14 15
15extern void cpu_idle(void); 16extern void cpu_idle(void);
16 17
@@ -139,13 +140,17 @@ static inline int up_smp_call_function(smp_call_func_t func, void *info)
139} 140}
140#define smp_call_function(func, info, wait) \ 141#define smp_call_function(func, info, wait) \
141 (up_smp_call_function(func, info)) 142 (up_smp_call_function(func, info))
142#define on_each_cpu(func,info,wait) \ 143
143 ({ \ 144static inline int on_each_cpu(smp_call_func_t func, void *info, int wait)
144 local_irq_disable(); \ 145{
145 func(info); \ 146 unsigned long flags;
146 local_irq_enable(); \ 147
147 0; \ 148 local_irq_save(flags);
148 }) 149 func(info);
150 local_irq_restore(flags);
151 return 0;
152}
153
149/* 154/*
150 * Note we still need to test the mask even for UP 155 * Note we still need to test the mask even for UP
151 * because we actually can get an empty mask from 156 * because we actually can get an empty mask from
diff --git a/include/linux/swapops.h b/include/linux/swapops.h
index 47ead515c811..c5fd30d2a415 100644
--- a/include/linux/swapops.h
+++ b/include/linux/swapops.h
@@ -137,6 +137,7 @@ static inline void make_migration_entry_read(swp_entry_t *entry)
137 137
138extern void migration_entry_wait(struct mm_struct *mm, pmd_t *pmd, 138extern void migration_entry_wait(struct mm_struct *mm, pmd_t *pmd,
139 unsigned long address); 139 unsigned long address);
140extern void migration_entry_wait_huge(struct mm_struct *mm, pte_t *pte);
140#else 141#else
141 142
142#define make_migration_entry(page, write) swp_entry(0, 0) 143#define make_migration_entry(page, write) swp_entry(0, 0)
@@ -148,6 +149,8 @@ static inline int is_migration_entry(swp_entry_t swp)
148static inline void make_migration_entry_read(swp_entry_t *entryp) { } 149static inline void make_migration_entry_read(swp_entry_t *entryp) { }
149static inline void migration_entry_wait(struct mm_struct *mm, pmd_t *pmd, 150static inline void migration_entry_wait(struct mm_struct *mm, pmd_t *pmd,
150 unsigned long address) { } 151 unsigned long address) { }
152static inline void migration_entry_wait_huge(struct mm_struct *mm,
153 pte_t *pte) { }
151static inline int is_write_migration_entry(swp_entry_t entry) 154static inline int is_write_migration_entry(swp_entry_t entry)
152{ 155{
153 return 0; 156 return 0;
diff --git a/include/linux/syslog.h b/include/linux/syslog.h
index 38911391a139..98a3153c0f96 100644
--- a/include/linux/syslog.h
+++ b/include/linux/syslog.h
@@ -44,8 +44,8 @@
44/* Return size of the log buffer */ 44/* Return size of the log buffer */
45#define SYSLOG_ACTION_SIZE_BUFFER 10 45#define SYSLOG_ACTION_SIZE_BUFFER 10
46 46
47#define SYSLOG_FROM_CALL 0 47#define SYSLOG_FROM_READER 0
48#define SYSLOG_FROM_FILE 1 48#define SYSLOG_FROM_PROC 1
49 49
50int do_syslog(int type, char __user *buf, int count, bool from_file); 50int do_syslog(int type, char __user *buf, int count, bool from_file);
51 51
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 2f322c38bd4d..f8e084d0fc77 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -145,8 +145,8 @@ static inline void tracepoint_synchronize_unregister(void)
145 TP_PROTO(data_proto), \ 145 TP_PROTO(data_proto), \
146 TP_ARGS(data_args), \ 146 TP_ARGS(data_args), \
147 TP_CONDITION(cond), \ 147 TP_CONDITION(cond), \
148 rcu_idle_exit(), \ 148 rcu_irq_enter(), \
149 rcu_idle_enter()); \ 149 rcu_irq_exit()); \
150 } 150 }
151#else 151#else
152#define __DECLARE_TRACE_RCU(name, proto, args, cond, data_proto, data_args) 152#define __DECLARE_TRACE_RCU(name, proto, args, cond, data_proto, data_args)
diff --git a/include/linux/vtime.h b/include/linux/vtime.h
index 71a5782d8c59..b1dd2db80076 100644
--- a/include/linux/vtime.h
+++ b/include/linux/vtime.h
@@ -34,7 +34,7 @@ static inline void vtime_user_exit(struct task_struct *tsk)
34} 34}
35extern void vtime_guest_enter(struct task_struct *tsk); 35extern void vtime_guest_enter(struct task_struct *tsk);
36extern void vtime_guest_exit(struct task_struct *tsk); 36extern void vtime_guest_exit(struct task_struct *tsk);
37extern void vtime_init_idle(struct task_struct *tsk); 37extern void vtime_init_idle(struct task_struct *tsk, int cpu);
38#else 38#else
39static inline void vtime_account_irq_exit(struct task_struct *tsk) 39static inline void vtime_account_irq_exit(struct task_struct *tsk)
40{ 40{
@@ -45,7 +45,7 @@ static inline void vtime_user_enter(struct task_struct *tsk) { }
45static inline void vtime_user_exit(struct task_struct *tsk) { } 45static inline void vtime_user_exit(struct task_struct *tsk) { }
46static inline void vtime_guest_enter(struct task_struct *tsk) { } 46static inline void vtime_guest_enter(struct task_struct *tsk) { }
47static inline void vtime_guest_exit(struct task_struct *tsk) { } 47static inline void vtime_guest_exit(struct task_struct *tsk) { }
48static inline void vtime_init_idle(struct task_struct *tsk) { } 48static inline void vtime_init_idle(struct task_struct *tsk, int cpu) { }
49#endif 49#endif
50 50
51#ifdef CONFIG_IRQ_TIME_ACCOUNTING 51#ifdef CONFIG_IRQ_TIME_ACCOUNTING
diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h
index d3eef01da648..0f4555b2a31b 100644
--- a/include/media/v4l2-mem2mem.h
+++ b/include/media/v4l2-mem2mem.h
@@ -110,6 +110,8 @@ int v4l2_m2m_qbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
110 struct v4l2_buffer *buf); 110 struct v4l2_buffer *buf);
111int v4l2_m2m_dqbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, 111int v4l2_m2m_dqbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
112 struct v4l2_buffer *buf); 112 struct v4l2_buffer *buf);
113int v4l2_m2m_create_bufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
114 struct v4l2_create_buffers *create);
113 115
114int v4l2_m2m_expbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, 116int v4l2_m2m_expbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
115 struct v4l2_exportbuffer *eb); 117 struct v4l2_exportbuffer *eb);
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 35a57cd1704c..7cb6d360d147 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -1117,6 +1117,7 @@ void hci_sock_dev_event(struct hci_dev *hdev, int event);
1117int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len); 1117int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len);
1118int mgmt_index_added(struct hci_dev *hdev); 1118int mgmt_index_added(struct hci_dev *hdev);
1119int mgmt_index_removed(struct hci_dev *hdev); 1119int mgmt_index_removed(struct hci_dev *hdev);
1120int mgmt_set_powered_failed(struct hci_dev *hdev, int err);
1120int mgmt_powered(struct hci_dev *hdev, u8 powered); 1121int mgmt_powered(struct hci_dev *hdev, u8 powered);
1121int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable); 1122int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable);
1122int mgmt_connectable(struct hci_dev *hdev, u8 connectable); 1123int mgmt_connectable(struct hci_dev *hdev, u8 connectable);
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index 22980a7c3873..9944c3e68c5d 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -42,6 +42,7 @@
42#define MGMT_STATUS_NOT_POWERED 0x0f 42#define MGMT_STATUS_NOT_POWERED 0x0f
43#define MGMT_STATUS_CANCELLED 0x10 43#define MGMT_STATUS_CANCELLED 0x10
44#define MGMT_STATUS_INVALID_INDEX 0x11 44#define MGMT_STATUS_INVALID_INDEX 0x11
45#define MGMT_STATUS_RFKILLED 0x12
45 46
46struct mgmt_hdr { 47struct mgmt_hdr {
47 __le16 opcode; 48 __le16 opcode;
diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
index 4b6f0b28f41f..09b1360e10bf 100644
--- a/include/net/ip_tunnels.h
+++ b/include/net/ip_tunnels.h
@@ -95,10 +95,10 @@ struct ip_tunnel_net {
95int ip_tunnel_init(struct net_device *dev); 95int ip_tunnel_init(struct net_device *dev);
96void ip_tunnel_uninit(struct net_device *dev); 96void ip_tunnel_uninit(struct net_device *dev);
97void ip_tunnel_dellink(struct net_device *dev, struct list_head *head); 97void ip_tunnel_dellink(struct net_device *dev, struct list_head *head);
98int __net_init ip_tunnel_init_net(struct net *net, int ip_tnl_net_id, 98int ip_tunnel_init_net(struct net *net, int ip_tnl_net_id,
99 struct rtnl_link_ops *ops, char *devname); 99 struct rtnl_link_ops *ops, char *devname);
100 100
101void __net_exit ip_tunnel_delete_net(struct ip_tunnel_net *itn); 101void ip_tunnel_delete_net(struct ip_tunnel_net *itn);
102 102
103void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, 103void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
104 const struct iphdr *tnl_params); 104 const struct iphdr *tnl_params);
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index d4609029f014..385c6329a967 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -450,7 +450,8 @@ enum snd_soc_dapm_type {
450 snd_soc_dapm_aif_in, /* audio interface input */ 450 snd_soc_dapm_aif_in, /* audio interface input */
451 snd_soc_dapm_aif_out, /* audio interface output */ 451 snd_soc_dapm_aif_out, /* audio interface output */
452 snd_soc_dapm_siggen, /* signal generator */ 452 snd_soc_dapm_siggen, /* signal generator */
453 snd_soc_dapm_dai, /* link to DAI structure */ 453 snd_soc_dapm_dai_in, /* link to DAI structure */
454 snd_soc_dapm_dai_out,
454 snd_soc_dapm_dai_link, /* link between two DAI structures */ 455 snd_soc_dapm_dai_link, /* link between two DAI structures */
455}; 456};
456 457
diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
index a5c86fc34a37..d88c8ee00c8b 100644
--- a/include/uapi/linux/kvm.h
+++ b/include/uapi/linux/kvm.h
@@ -783,6 +783,7 @@ struct kvm_dirty_tlb {
783#define KVM_REG_IA64 0x3000000000000000ULL 783#define KVM_REG_IA64 0x3000000000000000ULL
784#define KVM_REG_ARM 0x4000000000000000ULL 784#define KVM_REG_ARM 0x4000000000000000ULL
785#define KVM_REG_S390 0x5000000000000000ULL 785#define KVM_REG_S390 0x5000000000000000ULL
786#define KVM_REG_MIPS 0x7000000000000000ULL
786 787
787#define KVM_REG_SIZE_SHIFT 52 788#define KVM_REG_SIZE_SHIFT 52
788#define KVM_REG_SIZE_MASK 0x00f0000000000000ULL 789#define KVM_REG_SIZE_MASK 0x00f0000000000000ULL
diff --git a/init/Kconfig b/init/Kconfig
index 9d3a7887a6d3..2d9b83104dcf 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -431,6 +431,7 @@ choice
431config TREE_RCU 431config TREE_RCU
432 bool "Tree-based hierarchical RCU" 432 bool "Tree-based hierarchical RCU"
433 depends on !PREEMPT && SMP 433 depends on !PREEMPT && SMP
434 select IRQ_WORK
434 help 435 help
435 This option selects the RCU implementation that is 436 This option selects the RCU implementation that is
436 designed for very large SMP system with hundreds or 437 designed for very large SMP system with hundreds or
diff --git a/kernel/audit.c b/kernel/audit.c
index 21c7fa615bd3..91e53d04b6a9 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1056,7 +1056,7 @@ static inline void audit_get_stamp(struct audit_context *ctx,
1056static void wait_for_auditd(unsigned long sleep_time) 1056static void wait_for_auditd(unsigned long sleep_time)
1057{ 1057{
1058 DECLARE_WAITQUEUE(wait, current); 1058 DECLARE_WAITQUEUE(wait, current);
1059 set_current_state(TASK_INTERRUPTIBLE); 1059 set_current_state(TASK_UNINTERRUPTIBLE);
1060 add_wait_queue(&audit_backlog_wait, &wait); 1060 add_wait_queue(&audit_backlog_wait, &wait);
1061 1061
1062 if (audit_backlog_limit && 1062 if (audit_backlog_limit &&
diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
index a291aa23fb3f..43c307dc9453 100644
--- a/kernel/audit_tree.c
+++ b/kernel/audit_tree.c
@@ -658,6 +658,7 @@ int audit_add_tree_rule(struct audit_krule *rule)
658 struct vfsmount *mnt; 658 struct vfsmount *mnt;
659 int err; 659 int err;
660 660
661 rule->tree = NULL;
661 list_for_each_entry(tree, &tree_list, list) { 662 list_for_each_entry(tree, &tree_list, list) {
662 if (!strcmp(seed->pathname, tree->pathname)) { 663 if (!strcmp(seed->pathname, tree->pathname)) {
663 put_tree(seed); 664 put_tree(seed);
diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c
index 65349f07b878..383f8231e436 100644
--- a/kernel/context_tracking.c
+++ b/kernel/context_tracking.c
@@ -15,7 +15,6 @@
15 */ 15 */
16 16
17#include <linux/context_tracking.h> 17#include <linux/context_tracking.h>
18#include <linux/kvm_host.h>
19#include <linux/rcupdate.h> 18#include <linux/rcupdate.h>
20#include <linux/sched.h> 19#include <linux/sched.h>
21#include <linux/hardirq.h> 20#include <linux/hardirq.h>
@@ -71,6 +70,46 @@ void user_enter(void)
71 local_irq_restore(flags); 70 local_irq_restore(flags);
72} 71}
73 72
73#ifdef CONFIG_PREEMPT
74/**
75 * preempt_schedule_context - preempt_schedule called by tracing
76 *
77 * The tracing infrastructure uses preempt_enable_notrace to prevent
78 * recursion and tracing preempt enabling caused by the tracing
79 * infrastructure itself. But as tracing can happen in areas coming
80 * from userspace or just about to enter userspace, a preempt enable
81 * can occur before user_exit() is called. This will cause the scheduler
82 * to be called when the system is still in usermode.
83 *
84 * To prevent this, the preempt_enable_notrace will use this function
85 * instead of preempt_schedule() to exit user context if needed before
86 * calling the scheduler.
87 */
88void __sched notrace preempt_schedule_context(void)
89{
90 struct thread_info *ti = current_thread_info();
91 enum ctx_state prev_ctx;
92
93 if (likely(ti->preempt_count || irqs_disabled()))
94 return;
95
96 /*
97 * Need to disable preemption in case user_exit() is traced
98 * and the tracer calls preempt_enable_notrace() causing
99 * an infinite recursion.
100 */
101 preempt_disable_notrace();
102 prev_ctx = exception_enter();
103 preempt_enable_no_resched_notrace();
104
105 preempt_schedule();
106
107 preempt_disable_notrace();
108 exception_exit(prev_ctx);
109 preempt_enable_notrace();
110}
111EXPORT_SYMBOL_GPL(preempt_schedule_context);
112#endif /* CONFIG_PREEMPT */
74 113
75/** 114/**
76 * user_exit - Inform the context tracking that the CPU is 115 * user_exit - Inform the context tracking that the CPU is
diff --git a/kernel/cpu.c b/kernel/cpu.c
index b5e4ab2d427e..198a38883e64 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -133,6 +133,27 @@ static void cpu_hotplug_done(void)
133 mutex_unlock(&cpu_hotplug.lock); 133 mutex_unlock(&cpu_hotplug.lock);
134} 134}
135 135
136/*
137 * Wait for currently running CPU hotplug operations to complete (if any) and
138 * disable future CPU hotplug (from sysfs). The 'cpu_add_remove_lock' protects
139 * the 'cpu_hotplug_disabled' flag. The same lock is also acquired by the
140 * hotplug path before performing hotplug operations. So acquiring that lock
141 * guarantees mutual exclusion from any currently running hotplug operations.
142 */
143void cpu_hotplug_disable(void)
144{
145 cpu_maps_update_begin();
146 cpu_hotplug_disabled = 1;
147 cpu_maps_update_done();
148}
149
150void cpu_hotplug_enable(void)
151{
152 cpu_maps_update_begin();
153 cpu_hotplug_disabled = 0;
154 cpu_maps_update_done();
155}
156
136#else /* #if CONFIG_HOTPLUG_CPU */ 157#else /* #if CONFIG_HOTPLUG_CPU */
137static void cpu_hotplug_begin(void) {} 158static void cpu_hotplug_begin(void) {}
138static void cpu_hotplug_done(void) {} 159static void cpu_hotplug_done(void) {}
@@ -541,36 +562,6 @@ static int __init alloc_frozen_cpus(void)
541core_initcall(alloc_frozen_cpus); 562core_initcall(alloc_frozen_cpus);
542 563
543/* 564/*
544 * Prevent regular CPU hotplug from racing with the freezer, by disabling CPU
545 * hotplug when tasks are about to be frozen. Also, don't allow the freezer
546 * to continue until any currently running CPU hotplug operation gets
547 * completed.
548 * To modify the 'cpu_hotplug_disabled' flag, we need to acquire the
549 * 'cpu_add_remove_lock'. And this same lock is also taken by the regular
550 * CPU hotplug path and released only after it is complete. Thus, we
551 * (and hence the freezer) will block here until any currently running CPU
552 * hotplug operation gets completed.
553 */
554void cpu_hotplug_disable_before_freeze(void)
555{
556 cpu_maps_update_begin();
557 cpu_hotplug_disabled = 1;
558 cpu_maps_update_done();
559}
560
561
562/*
563 * When tasks have been thawed, re-enable regular CPU hotplug (which had been
564 * disabled while beginning to freeze tasks).
565 */
566void cpu_hotplug_enable_after_thaw(void)
567{
568 cpu_maps_update_begin();
569 cpu_hotplug_disabled = 0;
570 cpu_maps_update_done();
571}
572
573/*
574 * When callbacks for CPU hotplug notifications are being executed, we must 565 * When callbacks for CPU hotplug notifications are being executed, we must
575 * ensure that the state of the system with respect to the tasks being frozen 566 * ensure that the state of the system with respect to the tasks being frozen
576 * or not, as reported by the notification, remains unchanged *throughout the 567 * or not, as reported by the notification, remains unchanged *throughout the
@@ -589,12 +580,12 @@ cpu_hotplug_pm_callback(struct notifier_block *nb,
589 580
590 case PM_SUSPEND_PREPARE: 581 case PM_SUSPEND_PREPARE:
591 case PM_HIBERNATION_PREPARE: 582 case PM_HIBERNATION_PREPARE:
592 cpu_hotplug_disable_before_freeze(); 583 cpu_hotplug_disable();
593 break; 584 break;
594 585
595 case PM_POST_SUSPEND: 586 case PM_POST_SUSPEND:
596 case PM_POST_HIBERNATION: 587 case PM_POST_HIBERNATION:
597 cpu_hotplug_enable_after_thaw(); 588 cpu_hotplug_enable();
598 break; 589 break;
599 590
600 default: 591 default:
diff --git a/kernel/cpu/idle.c b/kernel/cpu/idle.c
index d5585f5e038e..e695c0a0bcb5 100644
--- a/kernel/cpu/idle.c
+++ b/kernel/cpu/idle.c
@@ -5,6 +5,7 @@
5#include <linux/cpu.h> 5#include <linux/cpu.h>
6#include <linux/tick.h> 6#include <linux/tick.h>
7#include <linux/mm.h> 7#include <linux/mm.h>
8#include <linux/stackprotector.h>
8 9
9#include <asm/tlb.h> 10#include <asm/tlb.h>
10 11
@@ -58,6 +59,7 @@ void __weak arch_cpu_idle_dead(void) { }
58void __weak arch_cpu_idle(void) 59void __weak arch_cpu_idle(void)
59{ 60{
60 cpu_idle_force_poll = 1; 61 cpu_idle_force_poll = 1;
62 local_irq_enable();
61} 63}
62 64
63/* 65/*
@@ -112,6 +114,21 @@ static void cpu_idle_loop(void)
112 114
113void cpu_startup_entry(enum cpuhp_state state) 115void cpu_startup_entry(enum cpuhp_state state)
114{ 116{
117 /*
118 * This #ifdef needs to die, but it's too late in the cycle to
119 * make this generic (arm and sh have never invoked the canary
120 * init for the non boot cpus!). Will be fixed in 3.11
121 */
122#ifdef CONFIG_X86
123 /*
124 * If we're the non-boot CPU, nothing set the stack canary up
125 * for us. The boot CPU already has it initialized but no harm
126 * in doing it again. This is a good place for updating it, as
127 * we wont ever return from this function (so the invalid
128 * canaries already on the stack wont ever trigger).
129 */
130 boot_init_stack_canary();
131#endif
115 current_set_polling(); 132 current_set_polling();
116 arch_cpu_idle_prepare(); 133 arch_cpu_idle_prepare();
117 cpu_idle_loop(); 134 cpu_idle_loop();
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 9dc297faf7c0..b391907d5352 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -196,9 +196,6 @@ static void cpu_ctx_sched_in(struct perf_cpu_context *cpuctx,
196static void update_context_time(struct perf_event_context *ctx); 196static void update_context_time(struct perf_event_context *ctx);
197static u64 perf_event_time(struct perf_event *event); 197static u64 perf_event_time(struct perf_event *event);
198 198
199static void ring_buffer_attach(struct perf_event *event,
200 struct ring_buffer *rb);
201
202void __weak perf_event_print_debug(void) { } 199void __weak perf_event_print_debug(void) { }
203 200
204extern __weak const char *perf_pmu_name(void) 201extern __weak const char *perf_pmu_name(void)
@@ -2918,6 +2915,7 @@ static void free_event_rcu(struct rcu_head *head)
2918} 2915}
2919 2916
2920static void ring_buffer_put(struct ring_buffer *rb); 2917static void ring_buffer_put(struct ring_buffer *rb);
2918static void ring_buffer_detach(struct perf_event *event, struct ring_buffer *rb);
2921 2919
2922static void free_event(struct perf_event *event) 2920static void free_event(struct perf_event *event)
2923{ 2921{
@@ -2942,15 +2940,30 @@ static void free_event(struct perf_event *event)
2942 if (has_branch_stack(event)) { 2940 if (has_branch_stack(event)) {
2943 static_key_slow_dec_deferred(&perf_sched_events); 2941 static_key_slow_dec_deferred(&perf_sched_events);
2944 /* is system-wide event */ 2942 /* is system-wide event */
2945 if (!(event->attach_state & PERF_ATTACH_TASK)) 2943 if (!(event->attach_state & PERF_ATTACH_TASK)) {
2946 atomic_dec(&per_cpu(perf_branch_stack_events, 2944 atomic_dec(&per_cpu(perf_branch_stack_events,
2947 event->cpu)); 2945 event->cpu));
2946 }
2948 } 2947 }
2949 } 2948 }
2950 2949
2951 if (event->rb) { 2950 if (event->rb) {
2952 ring_buffer_put(event->rb); 2951 struct ring_buffer *rb;
2953 event->rb = NULL; 2952
2953 /*
2954 * Can happen when we close an event with re-directed output.
2955 *
2956 * Since we have a 0 refcount, perf_mmap_close() will skip
2957 * over us; possibly making our ring_buffer_put() the last.
2958 */
2959 mutex_lock(&event->mmap_mutex);
2960 rb = event->rb;
2961 if (rb) {
2962 rcu_assign_pointer(event->rb, NULL);
2963 ring_buffer_detach(event, rb);
2964 ring_buffer_put(rb); /* could be last */
2965 }
2966 mutex_unlock(&event->mmap_mutex);
2954 } 2967 }
2955 2968
2956 if (is_cgroup_event(event)) 2969 if (is_cgroup_event(event))
@@ -3188,30 +3201,13 @@ static unsigned int perf_poll(struct file *file, poll_table *wait)
3188 unsigned int events = POLL_HUP; 3201 unsigned int events = POLL_HUP;
3189 3202
3190 /* 3203 /*
3191 * Race between perf_event_set_output() and perf_poll(): perf_poll() 3204 * Pin the event->rb by taking event->mmap_mutex; otherwise
3192 * grabs the rb reference but perf_event_set_output() overrides it. 3205 * perf_event_set_output() can swizzle our rb and make us miss wakeups.
3193 * Here is the timeline for two threads T1, T2:
3194 * t0: T1, rb = rcu_dereference(event->rb)
3195 * t1: T2, old_rb = event->rb
3196 * t2: T2, event->rb = new rb
3197 * t3: T2, ring_buffer_detach(old_rb)
3198 * t4: T1, ring_buffer_attach(rb1)
3199 * t5: T1, poll_wait(event->waitq)
3200 *
3201 * To avoid this problem, we grab mmap_mutex in perf_poll()
3202 * thereby ensuring that the assignment of the new ring buffer
3203 * and the detachment of the old buffer appear atomic to perf_poll()
3204 */ 3206 */
3205 mutex_lock(&event->mmap_mutex); 3207 mutex_lock(&event->mmap_mutex);
3206 3208 rb = event->rb;
3207 rcu_read_lock(); 3209 if (rb)
3208 rb = rcu_dereference(event->rb);
3209 if (rb) {
3210 ring_buffer_attach(event, rb);
3211 events = atomic_xchg(&rb->poll, 0); 3210 events = atomic_xchg(&rb->poll, 0);
3212 }
3213 rcu_read_unlock();
3214
3215 mutex_unlock(&event->mmap_mutex); 3211 mutex_unlock(&event->mmap_mutex);
3216 3212
3217 poll_wait(file, &event->waitq, wait); 3213 poll_wait(file, &event->waitq, wait);
@@ -3521,16 +3517,12 @@ static void ring_buffer_attach(struct perf_event *event,
3521 return; 3517 return;
3522 3518
3523 spin_lock_irqsave(&rb->event_lock, flags); 3519 spin_lock_irqsave(&rb->event_lock, flags);
3524 if (!list_empty(&event->rb_entry)) 3520 if (list_empty(&event->rb_entry))
3525 goto unlock; 3521 list_add(&event->rb_entry, &rb->event_list);
3526
3527 list_add(&event->rb_entry, &rb->event_list);
3528unlock:
3529 spin_unlock_irqrestore(&rb->event_lock, flags); 3522 spin_unlock_irqrestore(&rb->event_lock, flags);
3530} 3523}
3531 3524
3532static void ring_buffer_detach(struct perf_event *event, 3525static void ring_buffer_detach(struct perf_event *event, struct ring_buffer *rb)
3533 struct ring_buffer *rb)
3534{ 3526{
3535 unsigned long flags; 3527 unsigned long flags;
3536 3528
@@ -3549,13 +3541,10 @@ static void ring_buffer_wakeup(struct perf_event *event)
3549 3541
3550 rcu_read_lock(); 3542 rcu_read_lock();
3551 rb = rcu_dereference(event->rb); 3543 rb = rcu_dereference(event->rb);
3552 if (!rb) 3544 if (rb) {
3553 goto unlock; 3545 list_for_each_entry_rcu(event, &rb->event_list, rb_entry)
3554 3546 wake_up_all(&event->waitq);
3555 list_for_each_entry_rcu(event, &rb->event_list, rb_entry) 3547 }
3556 wake_up_all(&event->waitq);
3557
3558unlock:
3559 rcu_read_unlock(); 3548 rcu_read_unlock();
3560} 3549}
3561 3550
@@ -3584,18 +3573,10 @@ static struct ring_buffer *ring_buffer_get(struct perf_event *event)
3584 3573
3585static void ring_buffer_put(struct ring_buffer *rb) 3574static void ring_buffer_put(struct ring_buffer *rb)
3586{ 3575{
3587 struct perf_event *event, *n;
3588 unsigned long flags;
3589
3590 if (!atomic_dec_and_test(&rb->refcount)) 3576 if (!atomic_dec_and_test(&rb->refcount))
3591 return; 3577 return;
3592 3578
3593 spin_lock_irqsave(&rb->event_lock, flags); 3579 WARN_ON_ONCE(!list_empty(&rb->event_list));
3594 list_for_each_entry_safe(event, n, &rb->event_list, rb_entry) {
3595 list_del_init(&event->rb_entry);
3596 wake_up_all(&event->waitq);
3597 }
3598 spin_unlock_irqrestore(&rb->event_lock, flags);
3599 3580
3600 call_rcu(&rb->rcu_head, rb_free_rcu); 3581 call_rcu(&rb->rcu_head, rb_free_rcu);
3601} 3582}
@@ -3605,26 +3586,100 @@ static void perf_mmap_open(struct vm_area_struct *vma)
3605 struct perf_event *event = vma->vm_file->private_data; 3586 struct perf_event *event = vma->vm_file->private_data;
3606 3587
3607 atomic_inc(&event->mmap_count); 3588 atomic_inc(&event->mmap_count);
3589 atomic_inc(&event->rb->mmap_count);
3608} 3590}
3609 3591
3592/*
3593 * A buffer can be mmap()ed multiple times; either directly through the same
3594 * event, or through other events by use of perf_event_set_output().
3595 *
3596 * In order to undo the VM accounting done by perf_mmap() we need to destroy
3597 * the buffer here, where we still have a VM context. This means we need
3598 * to detach all events redirecting to us.
3599 */
3610static void perf_mmap_close(struct vm_area_struct *vma) 3600static void perf_mmap_close(struct vm_area_struct *vma)
3611{ 3601{
3612 struct perf_event *event = vma->vm_file->private_data; 3602 struct perf_event *event = vma->vm_file->private_data;
3613 3603
3614 if (atomic_dec_and_mutex_lock(&event->mmap_count, &event->mmap_mutex)) { 3604 struct ring_buffer *rb = event->rb;
3615 unsigned long size = perf_data_size(event->rb); 3605 struct user_struct *mmap_user = rb->mmap_user;
3616 struct user_struct *user = event->mmap_user; 3606 int mmap_locked = rb->mmap_locked;
3617 struct ring_buffer *rb = event->rb; 3607 unsigned long size = perf_data_size(rb);
3608
3609 atomic_dec(&rb->mmap_count);
3610
3611 if (!atomic_dec_and_mutex_lock(&event->mmap_count, &event->mmap_mutex))
3612 return;
3618 3613
3619 atomic_long_sub((size >> PAGE_SHIFT) + 1, &user->locked_vm); 3614 /* Detach current event from the buffer. */
3620 vma->vm_mm->pinned_vm -= event->mmap_locked; 3615 rcu_assign_pointer(event->rb, NULL);
3621 rcu_assign_pointer(event->rb, NULL); 3616 ring_buffer_detach(event, rb);
3622 ring_buffer_detach(event, rb); 3617 mutex_unlock(&event->mmap_mutex);
3618
3619 /* If there's still other mmap()s of this buffer, we're done. */
3620 if (atomic_read(&rb->mmap_count)) {
3621 ring_buffer_put(rb); /* can't be last */
3622 return;
3623 }
3624
3625 /*
3626 * No other mmap()s, detach from all other events that might redirect
3627 * into the now unreachable buffer. Somewhat complicated by the
3628 * fact that rb::event_lock otherwise nests inside mmap_mutex.
3629 */
3630again:
3631 rcu_read_lock();
3632 list_for_each_entry_rcu(event, &rb->event_list, rb_entry) {
3633 if (!atomic_long_inc_not_zero(&event->refcount)) {
3634 /*
3635 * This event is en-route to free_event() which will
3636 * detach it and remove it from the list.
3637 */
3638 continue;
3639 }
3640 rcu_read_unlock();
3641
3642 mutex_lock(&event->mmap_mutex);
3643 /*
3644 * Check we didn't race with perf_event_set_output() which can
3645 * swizzle the rb from under us while we were waiting to
3646 * acquire mmap_mutex.
3647 *
3648 * If we find a different rb; ignore this event, a next
3649 * iteration will no longer find it on the list. We have to
3650 * still restart the iteration to make sure we're not now
3651 * iterating the wrong list.
3652 */
3653 if (event->rb == rb) {
3654 rcu_assign_pointer(event->rb, NULL);
3655 ring_buffer_detach(event, rb);
3656 ring_buffer_put(rb); /* can't be last, we still have one */
3657 }
3623 mutex_unlock(&event->mmap_mutex); 3658 mutex_unlock(&event->mmap_mutex);
3659 put_event(event);
3624 3660
3625 ring_buffer_put(rb); 3661 /*
3626 free_uid(user); 3662 * Restart the iteration; either we're on the wrong list or
3663 * destroyed its integrity by doing a deletion.
3664 */
3665 goto again;
3627 } 3666 }
3667 rcu_read_unlock();
3668
3669 /*
3670 * It could be there's still a few 0-ref events on the list; they'll
3671 * get cleaned up by free_event() -- they'll also still have their
3672 * ref on the rb and will free it whenever they are done with it.
3673 *
3674 * Aside from that, this buffer is 'fully' detached and unmapped,
3675 * undo the VM accounting.
3676 */
3677
3678 atomic_long_sub((size >> PAGE_SHIFT) + 1, &mmap_user->locked_vm);
3679 vma->vm_mm->pinned_vm -= mmap_locked;
3680 free_uid(mmap_user);
3681
3682 ring_buffer_put(rb); /* could be last */
3628} 3683}
3629 3684
3630static const struct vm_operations_struct perf_mmap_vmops = { 3685static const struct vm_operations_struct perf_mmap_vmops = {
@@ -3674,12 +3729,24 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
3674 return -EINVAL; 3729 return -EINVAL;
3675 3730
3676 WARN_ON_ONCE(event->ctx->parent_ctx); 3731 WARN_ON_ONCE(event->ctx->parent_ctx);
3732again:
3677 mutex_lock(&event->mmap_mutex); 3733 mutex_lock(&event->mmap_mutex);
3678 if (event->rb) { 3734 if (event->rb) {
3679 if (event->rb->nr_pages == nr_pages) 3735 if (event->rb->nr_pages != nr_pages) {
3680 atomic_inc(&event->rb->refcount);
3681 else
3682 ret = -EINVAL; 3736 ret = -EINVAL;
3737 goto unlock;
3738 }
3739
3740 if (!atomic_inc_not_zero(&event->rb->mmap_count)) {
3741 /*
3742 * Raced against perf_mmap_close() through
3743 * perf_event_set_output(). Try again, hope for better
3744 * luck.
3745 */
3746 mutex_unlock(&event->mmap_mutex);
3747 goto again;
3748 }
3749
3683 goto unlock; 3750 goto unlock;
3684 } 3751 }
3685 3752
@@ -3720,12 +3787,16 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
3720 ret = -ENOMEM; 3787 ret = -ENOMEM;
3721 goto unlock; 3788 goto unlock;
3722 } 3789 }
3723 rcu_assign_pointer(event->rb, rb); 3790
3791 atomic_set(&rb->mmap_count, 1);
3792 rb->mmap_locked = extra;
3793 rb->mmap_user = get_current_user();
3724 3794
3725 atomic_long_add(user_extra, &user->locked_vm); 3795 atomic_long_add(user_extra, &user->locked_vm);
3726 event->mmap_locked = extra; 3796 vma->vm_mm->pinned_vm += extra;
3727 event->mmap_user = get_current_user(); 3797
3728 vma->vm_mm->pinned_vm += event->mmap_locked; 3798 ring_buffer_attach(event, rb);
3799 rcu_assign_pointer(event->rb, rb);
3729 3800
3730 perf_event_update_userpage(event); 3801 perf_event_update_userpage(event);
3731 3802
@@ -3734,7 +3805,11 @@ unlock:
3734 atomic_inc(&event->mmap_count); 3805 atomic_inc(&event->mmap_count);
3735 mutex_unlock(&event->mmap_mutex); 3806 mutex_unlock(&event->mmap_mutex);
3736 3807
3737 vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; 3808 /*
3809 * Since pinned accounting is per vm we cannot allow fork() to copy our
3810 * vma.
3811 */
3812 vma->vm_flags |= VM_DONTCOPY | VM_DONTEXPAND | VM_DONTDUMP;
3738 vma->vm_ops = &perf_mmap_vmops; 3813 vma->vm_ops = &perf_mmap_vmops;
3739 3814
3740 return ret; 3815 return ret;
@@ -6412,6 +6487,8 @@ set:
6412 if (atomic_read(&event->mmap_count)) 6487 if (atomic_read(&event->mmap_count))
6413 goto unlock; 6488 goto unlock;
6414 6489
6490 old_rb = event->rb;
6491
6415 if (output_event) { 6492 if (output_event) {
6416 /* get the rb we want to redirect to */ 6493 /* get the rb we want to redirect to */
6417 rb = ring_buffer_get(output_event); 6494 rb = ring_buffer_get(output_event);
@@ -6419,16 +6496,28 @@ set:
6419 goto unlock; 6496 goto unlock;
6420 } 6497 }
6421 6498
6422 old_rb = event->rb;
6423 rcu_assign_pointer(event->rb, rb);
6424 if (old_rb) 6499 if (old_rb)
6425 ring_buffer_detach(event, old_rb); 6500 ring_buffer_detach(event, old_rb);
6501
6502 if (rb)
6503 ring_buffer_attach(event, rb);
6504
6505 rcu_assign_pointer(event->rb, rb);
6506
6507 if (old_rb) {
6508 ring_buffer_put(old_rb);
6509 /*
6510 * Since we detached before setting the new rb, so that we
6511 * could attach the new rb, we could have missed a wakeup.
6512 * Provide it now.
6513 */
6514 wake_up_all(&event->waitq);
6515 }
6516
6426 ret = 0; 6517 ret = 0;
6427unlock: 6518unlock:
6428 mutex_unlock(&event->mmap_mutex); 6519 mutex_unlock(&event->mmap_mutex);
6429 6520
6430 if (old_rb)
6431 ring_buffer_put(old_rb);
6432out: 6521out:
6433 return ret; 6522 return ret;
6434} 6523}
diff --git a/kernel/events/internal.h b/kernel/events/internal.h
index eb675c4d59df..ca6599723be5 100644
--- a/kernel/events/internal.h
+++ b/kernel/events/internal.h
@@ -31,6 +31,10 @@ struct ring_buffer {
31 spinlock_t event_lock; 31 spinlock_t event_lock;
32 struct list_head event_list; 32 struct list_head event_list;
33 33
34 atomic_t mmap_count;
35 unsigned long mmap_locked;
36 struct user_struct *mmap_user;
37
34 struct perf_event_mmap_page *user_page; 38 struct perf_event_mmap_page *user_page;
35 void *data_pages[0]; 39 void *data_pages[0];
36}; 40};
diff --git a/kernel/exit.c b/kernel/exit.c
index af2eb3cbd499..7bb73f9d09db 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -649,7 +649,6 @@ static void exit_notify(struct task_struct *tsk, int group_dead)
649 * jobs, send them a SIGHUP and then a SIGCONT. (POSIX 3.2.2.2) 649 * jobs, send them a SIGHUP and then a SIGCONT. (POSIX 3.2.2.2)
650 */ 650 */
651 forget_original_parent(tsk); 651 forget_original_parent(tsk);
652 exit_task_namespaces(tsk);
653 652
654 write_lock_irq(&tasklist_lock); 653 write_lock_irq(&tasklist_lock);
655 if (group_dead) 654 if (group_dead)
@@ -795,6 +794,7 @@ void do_exit(long code)
795 exit_shm(tsk); 794 exit_shm(tsk);
796 exit_files(tsk); 795 exit_files(tsk);
797 exit_fs(tsk); 796 exit_fs(tsk);
797 exit_task_namespaces(tsk);
798 exit_task_work(tsk); 798 exit_task_work(tsk);
799 check_stack_usage(); 799 check_stack_usage();
800 exit_thread(); 800 exit_thread();
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 3fed7f0cbcdf..bddf3b201a48 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -467,6 +467,7 @@ static struct kprobe *__kprobes get_optimized_kprobe(unsigned long addr)
467/* Optimization staging list, protected by kprobe_mutex */ 467/* Optimization staging list, protected by kprobe_mutex */
468static LIST_HEAD(optimizing_list); 468static LIST_HEAD(optimizing_list);
469static LIST_HEAD(unoptimizing_list); 469static LIST_HEAD(unoptimizing_list);
470static LIST_HEAD(freeing_list);
470 471
471static void kprobe_optimizer(struct work_struct *work); 472static void kprobe_optimizer(struct work_struct *work);
472static DECLARE_DELAYED_WORK(optimizing_work, kprobe_optimizer); 473static DECLARE_DELAYED_WORK(optimizing_work, kprobe_optimizer);
@@ -504,7 +505,7 @@ static __kprobes void do_optimize_kprobes(void)
504 * Unoptimize (replace a jump with a breakpoint and remove the breakpoint 505 * Unoptimize (replace a jump with a breakpoint and remove the breakpoint
505 * if need) kprobes listed on unoptimizing_list. 506 * if need) kprobes listed on unoptimizing_list.
506 */ 507 */
507static __kprobes void do_unoptimize_kprobes(struct list_head *free_list) 508static __kprobes void do_unoptimize_kprobes(void)
508{ 509{
509 struct optimized_kprobe *op, *tmp; 510 struct optimized_kprobe *op, *tmp;
510 511
@@ -515,9 +516,9 @@ static __kprobes void do_unoptimize_kprobes(struct list_head *free_list)
515 /* Ditto to do_optimize_kprobes */ 516 /* Ditto to do_optimize_kprobes */
516 get_online_cpus(); 517 get_online_cpus();
517 mutex_lock(&text_mutex); 518 mutex_lock(&text_mutex);
518 arch_unoptimize_kprobes(&unoptimizing_list, free_list); 519 arch_unoptimize_kprobes(&unoptimizing_list, &freeing_list);
519 /* Loop free_list for disarming */ 520 /* Loop free_list for disarming */
520 list_for_each_entry_safe(op, tmp, free_list, list) { 521 list_for_each_entry_safe(op, tmp, &freeing_list, list) {
521 /* Disarm probes if marked disabled */ 522 /* Disarm probes if marked disabled */
522 if (kprobe_disabled(&op->kp)) 523 if (kprobe_disabled(&op->kp))
523 arch_disarm_kprobe(&op->kp); 524 arch_disarm_kprobe(&op->kp);
@@ -536,11 +537,11 @@ static __kprobes void do_unoptimize_kprobes(struct list_head *free_list)
536} 537}
537 538
538/* Reclaim all kprobes on the free_list */ 539/* Reclaim all kprobes on the free_list */
539static __kprobes void do_free_cleaned_kprobes(struct list_head *free_list) 540static __kprobes void do_free_cleaned_kprobes(void)
540{ 541{
541 struct optimized_kprobe *op, *tmp; 542 struct optimized_kprobe *op, *tmp;
542 543
543 list_for_each_entry_safe(op, tmp, free_list, list) { 544 list_for_each_entry_safe(op, tmp, &freeing_list, list) {
544 BUG_ON(!kprobe_unused(&op->kp)); 545 BUG_ON(!kprobe_unused(&op->kp));
545 list_del_init(&op->list); 546 list_del_init(&op->list);
546 free_aggr_kprobe(&op->kp); 547 free_aggr_kprobe(&op->kp);
@@ -556,8 +557,6 @@ static __kprobes void kick_kprobe_optimizer(void)
556/* Kprobe jump optimizer */ 557/* Kprobe jump optimizer */
557static __kprobes void kprobe_optimizer(struct work_struct *work) 558static __kprobes void kprobe_optimizer(struct work_struct *work)
558{ 559{
559 LIST_HEAD(free_list);
560
561 mutex_lock(&kprobe_mutex); 560 mutex_lock(&kprobe_mutex);
562 /* Lock modules while optimizing kprobes */ 561 /* Lock modules while optimizing kprobes */
563 mutex_lock(&module_mutex); 562 mutex_lock(&module_mutex);
@@ -566,7 +565,7 @@ static __kprobes void kprobe_optimizer(struct work_struct *work)
566 * Step 1: Unoptimize kprobes and collect cleaned (unused and disarmed) 565 * Step 1: Unoptimize kprobes and collect cleaned (unused and disarmed)
567 * kprobes before waiting for quiesence period. 566 * kprobes before waiting for quiesence period.
568 */ 567 */
569 do_unoptimize_kprobes(&free_list); 568 do_unoptimize_kprobes();
570 569
571 /* 570 /*
572 * Step 2: Wait for quiesence period to ensure all running interrupts 571 * Step 2: Wait for quiesence period to ensure all running interrupts
@@ -581,7 +580,7 @@ static __kprobes void kprobe_optimizer(struct work_struct *work)
581 do_optimize_kprobes(); 580 do_optimize_kprobes();
582 581
583 /* Step 4: Free cleaned kprobes after quiesence period */ 582 /* Step 4: Free cleaned kprobes after quiesence period */
584 do_free_cleaned_kprobes(&free_list); 583 do_free_cleaned_kprobes();
585 584
586 mutex_unlock(&module_mutex); 585 mutex_unlock(&module_mutex);
587 mutex_unlock(&kprobe_mutex); 586 mutex_unlock(&kprobe_mutex);
@@ -723,8 +722,19 @@ static void __kprobes kill_optimized_kprobe(struct kprobe *p)
723 if (!list_empty(&op->list)) 722 if (!list_empty(&op->list))
724 /* Dequeue from the (un)optimization queue */ 723 /* Dequeue from the (un)optimization queue */
725 list_del_init(&op->list); 724 list_del_init(&op->list);
726
727 op->kp.flags &= ~KPROBE_FLAG_OPTIMIZED; 725 op->kp.flags &= ~KPROBE_FLAG_OPTIMIZED;
726
727 if (kprobe_unused(p)) {
728 /* Enqueue if it is unused */
729 list_add(&op->list, &freeing_list);
730 /*
731 * Remove unused probes from the hash list. After waiting
732 * for synchronization, this probe is reclaimed.
733 * (reclaiming is done by do_free_cleaned_kprobes().)
734 */
735 hlist_del_rcu(&op->kp.hlist);
736 }
737
728 /* Don't touch the code, because it is already freed. */ 738 /* Don't touch the code, because it is already freed. */
729 arch_remove_optimized_kprobe(op); 739 arch_remove_optimized_kprobe(op);
730} 740}
diff --git a/kernel/printk.c b/kernel/printk.c
index fa36e1494420..8212c1aef125 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -363,6 +363,53 @@ static void log_store(int facility, int level,
363 log_next_seq++; 363 log_next_seq++;
364} 364}
365 365
366#ifdef CONFIG_SECURITY_DMESG_RESTRICT
367int dmesg_restrict = 1;
368#else
369int dmesg_restrict;
370#endif
371
372static int syslog_action_restricted(int type)
373{
374 if (dmesg_restrict)
375 return 1;
376 /*
377 * Unless restricted, we allow "read all" and "get buffer size"
378 * for everybody.
379 */
380 return type != SYSLOG_ACTION_READ_ALL &&
381 type != SYSLOG_ACTION_SIZE_BUFFER;
382}
383
384static int check_syslog_permissions(int type, bool from_file)
385{
386 /*
387 * If this is from /proc/kmsg and we've already opened it, then we've
388 * already done the capabilities checks at open time.
389 */
390 if (from_file && type != SYSLOG_ACTION_OPEN)
391 return 0;
392
393 if (syslog_action_restricted(type)) {
394 if (capable(CAP_SYSLOG))
395 return 0;
396 /*
397 * For historical reasons, accept CAP_SYS_ADMIN too, with
398 * a warning.
399 */
400 if (capable(CAP_SYS_ADMIN)) {
401 pr_warn_once("%s (%d): Attempt to access syslog with "
402 "CAP_SYS_ADMIN but no CAP_SYSLOG "
403 "(deprecated).\n",
404 current->comm, task_pid_nr(current));
405 return 0;
406 }
407 return -EPERM;
408 }
409 return security_syslog(type);
410}
411
412
366/* /dev/kmsg - userspace message inject/listen interface */ 413/* /dev/kmsg - userspace message inject/listen interface */
367struct devkmsg_user { 414struct devkmsg_user {
368 u64 seq; 415 u64 seq;
@@ -620,7 +667,8 @@ static int devkmsg_open(struct inode *inode, struct file *file)
620 if ((file->f_flags & O_ACCMODE) == O_WRONLY) 667 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
621 return 0; 668 return 0;
622 669
623 err = security_syslog(SYSLOG_ACTION_READ_ALL); 670 err = check_syslog_permissions(SYSLOG_ACTION_READ_ALL,
671 SYSLOG_FROM_READER);
624 if (err) 672 if (err)
625 return err; 673 return err;
626 674
@@ -813,45 +861,6 @@ static inline void boot_delay_msec(int level)
813} 861}
814#endif 862#endif
815 863
816#ifdef CONFIG_SECURITY_DMESG_RESTRICT
817int dmesg_restrict = 1;
818#else
819int dmesg_restrict;
820#endif
821
822static int syslog_action_restricted(int type)
823{
824 if (dmesg_restrict)
825 return 1;
826 /* Unless restricted, we allow "read all" and "get buffer size" for everybody */
827 return type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
828}
829
830static int check_syslog_permissions(int type, bool from_file)
831{
832 /*
833 * If this is from /proc/kmsg and we've already opened it, then we've
834 * already done the capabilities checks at open time.
835 */
836 if (from_file && type != SYSLOG_ACTION_OPEN)
837 return 0;
838
839 if (syslog_action_restricted(type)) {
840 if (capable(CAP_SYSLOG))
841 return 0;
842 /* For historical reasons, accept CAP_SYS_ADMIN too, with a warning */
843 if (capable(CAP_SYS_ADMIN)) {
844 printk_once(KERN_WARNING "%s (%d): "
845 "Attempt to access syslog with CAP_SYS_ADMIN "
846 "but no CAP_SYSLOG (deprecated).\n",
847 current->comm, task_pid_nr(current));
848 return 0;
849 }
850 return -EPERM;
851 }
852 return 0;
853}
854
855#if defined(CONFIG_PRINTK_TIME) 864#if defined(CONFIG_PRINTK_TIME)
856static bool printk_time = 1; 865static bool printk_time = 1;
857#else 866#else
@@ -1249,7 +1258,7 @@ out:
1249 1258
1250SYSCALL_DEFINE3(syslog, int, type, char __user *, buf, int, len) 1259SYSCALL_DEFINE3(syslog, int, type, char __user *, buf, int, len)
1251{ 1260{
1252 return do_syslog(type, buf, len, SYSLOG_FROM_CALL); 1261 return do_syslog(type, buf, len, SYSLOG_FROM_READER);
1253} 1262}
1254 1263
1255/* 1264/*
diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index 16ea67925015..35380019f0fc 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -1451,9 +1451,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
1451 rnp->grphi, rnp->qsmask); 1451 rnp->grphi, rnp->qsmask);
1452 raw_spin_unlock_irq(&rnp->lock); 1452 raw_spin_unlock_irq(&rnp->lock);
1453#ifdef CONFIG_PROVE_RCU_DELAY 1453#ifdef CONFIG_PROVE_RCU_DELAY
1454 if ((prandom_u32() % (rcu_num_nodes * 8)) == 0 && 1454 if ((prandom_u32() % (rcu_num_nodes + 1)) == 0 &&
1455 system_state == SYSTEM_RUNNING) 1455 system_state == SYSTEM_RUNNING)
1456 schedule_timeout_uninterruptible(2); 1456 udelay(200);
1457#endif /* #ifdef CONFIG_PROVE_RCU_DELAY */ 1457#endif /* #ifdef CONFIG_PROVE_RCU_DELAY */
1458 cond_resched(); 1458 cond_resched();
1459 } 1459 }
@@ -1613,6 +1613,14 @@ static int __noreturn rcu_gp_kthread(void *arg)
1613 } 1613 }
1614} 1614}
1615 1615
1616static void rsp_wakeup(struct irq_work *work)
1617{
1618 struct rcu_state *rsp = container_of(work, struct rcu_state, wakeup_work);
1619
1620 /* Wake up rcu_gp_kthread() to start the grace period. */
1621 wake_up(&rsp->gp_wq);
1622}
1623
1616/* 1624/*
1617 * Start a new RCU grace period if warranted, re-initializing the hierarchy 1625 * Start a new RCU grace period if warranted, re-initializing the hierarchy
1618 * in preparation for detecting the next grace period. The caller must hold 1626 * in preparation for detecting the next grace period. The caller must hold
@@ -1637,8 +1645,12 @@ rcu_start_gp_advanced(struct rcu_state *rsp, struct rcu_node *rnp,
1637 } 1645 }
1638 rsp->gp_flags = RCU_GP_FLAG_INIT; 1646 rsp->gp_flags = RCU_GP_FLAG_INIT;
1639 1647
1640 /* Wake up rcu_gp_kthread() to start the grace period. */ 1648 /*
1641 wake_up(&rsp->gp_wq); 1649 * We can't do wakeups while holding the rnp->lock, as that
1650 * could cause possible deadlocks with the rq->lock. Deter
1651 * the wakeup to interrupt context.
1652 */
1653 irq_work_queue(&rsp->wakeup_work);
1642} 1654}
1643 1655
1644/* 1656/*
@@ -3235,6 +3247,7 @@ static void __init rcu_init_one(struct rcu_state *rsp,
3235 3247
3236 rsp->rda = rda; 3248 rsp->rda = rda;
3237 init_waitqueue_head(&rsp->gp_wq); 3249 init_waitqueue_head(&rsp->gp_wq);
3250 init_irq_work(&rsp->wakeup_work, rsp_wakeup);
3238 rnp = rsp->level[rcu_num_lvls - 1]; 3251 rnp = rsp->level[rcu_num_lvls - 1];
3239 for_each_possible_cpu(i) { 3252 for_each_possible_cpu(i) {
3240 while (i > rnp->grphi) 3253 while (i > rnp->grphi)
diff --git a/kernel/rcutree.h b/kernel/rcutree.h
index da77a8f57ff9..4df503470e42 100644
--- a/kernel/rcutree.h
+++ b/kernel/rcutree.h
@@ -27,6 +27,7 @@
27#include <linux/threads.h> 27#include <linux/threads.h>
28#include <linux/cpumask.h> 28#include <linux/cpumask.h>
29#include <linux/seqlock.h> 29#include <linux/seqlock.h>
30#include <linux/irq_work.h>
30 31
31/* 32/*
32 * Define shape of hierarchy based on NR_CPUS, CONFIG_RCU_FANOUT, and 33 * Define shape of hierarchy based on NR_CPUS, CONFIG_RCU_FANOUT, and
@@ -442,6 +443,7 @@ struct rcu_state {
442 char *name; /* Name of structure. */ 443 char *name; /* Name of structure. */
443 char abbr; /* Abbreviated name. */ 444 char abbr; /* Abbreviated name. */
444 struct list_head flavors; /* List of RCU flavors. */ 445 struct list_head flavors; /* List of RCU flavors. */
446 struct irq_work wakeup_work; /* Postponed wakeups */
445}; 447};
446 448
447/* Values for rcu_state structure's gp_flags field. */ 449/* Values for rcu_state structure's gp_flags field. */
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 58453b8272fd..e8b335016c52 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -633,7 +633,19 @@ void wake_up_nohz_cpu(int cpu)
633static inline bool got_nohz_idle_kick(void) 633static inline bool got_nohz_idle_kick(void)
634{ 634{
635 int cpu = smp_processor_id(); 635 int cpu = smp_processor_id();
636 return idle_cpu(cpu) && test_bit(NOHZ_BALANCE_KICK, nohz_flags(cpu)); 636
637 if (!test_bit(NOHZ_BALANCE_KICK, nohz_flags(cpu)))
638 return false;
639
640 if (idle_cpu(cpu) && !need_resched())
641 return true;
642
643 /*
644 * We can't run Idle Load Balance on this CPU for this time so we
645 * cancel it and clear NOHZ_BALANCE_KICK
646 */
647 clear_bit(NOHZ_BALANCE_KICK, nohz_flags(cpu));
648 return false;
637} 649}
638 650
639#else /* CONFIG_NO_HZ_COMMON */ 651#else /* CONFIG_NO_HZ_COMMON */
@@ -1393,8 +1405,9 @@ static void sched_ttwu_pending(void)
1393 1405
1394void scheduler_ipi(void) 1406void scheduler_ipi(void)
1395{ 1407{
1396 if (llist_empty(&this_rq()->wake_list) && !got_nohz_idle_kick() 1408 if (llist_empty(&this_rq()->wake_list)
1397 && !tick_nohz_full_cpu(smp_processor_id())) 1409 && !tick_nohz_full_cpu(smp_processor_id())
1410 && !got_nohz_idle_kick())
1398 return; 1411 return;
1399 1412
1400 /* 1413 /*
@@ -1417,7 +1430,7 @@ void scheduler_ipi(void)
1417 /* 1430 /*
1418 * Check if someone kicked us for doing the nohz idle load balance. 1431 * Check if someone kicked us for doing the nohz idle load balance.
1419 */ 1432 */
1420 if (unlikely(got_nohz_idle_kick() && !need_resched())) { 1433 if (unlikely(got_nohz_idle_kick())) {
1421 this_rq()->idle_balance = 1; 1434 this_rq()->idle_balance = 1;
1422 raise_softirq_irqoff(SCHED_SOFTIRQ); 1435 raise_softirq_irqoff(SCHED_SOFTIRQ);
1423 } 1436 }
@@ -4745,7 +4758,7 @@ void __cpuinit init_idle(struct task_struct *idle, int cpu)
4745 */ 4758 */
4746 idle->sched_class = &idle_sched_class; 4759 idle->sched_class = &idle_sched_class;
4747 ftrace_graph_init_idle_task(idle, cpu); 4760 ftrace_graph_init_idle_task(idle, cpu);
4748 vtime_init_idle(idle); 4761 vtime_init_idle(idle, cpu);
4749#if defined(CONFIG_SMP) 4762#if defined(CONFIG_SMP)
4750 sprintf(idle->comm, "%s/%d", INIT_TASK_COMM, cpu); 4763 sprintf(idle->comm, "%s/%d", INIT_TASK_COMM, cpu);
4751#endif 4764#endif
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index cc2dc3eea8a3..b5ccba22603b 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -747,17 +747,17 @@ void arch_vtime_task_switch(struct task_struct *prev)
747 747
748 write_seqlock(&current->vtime_seqlock); 748 write_seqlock(&current->vtime_seqlock);
749 current->vtime_snap_whence = VTIME_SYS; 749 current->vtime_snap_whence = VTIME_SYS;
750 current->vtime_snap = sched_clock(); 750 current->vtime_snap = sched_clock_cpu(smp_processor_id());
751 write_sequnlock(&current->vtime_seqlock); 751 write_sequnlock(&current->vtime_seqlock);
752} 752}
753 753
754void vtime_init_idle(struct task_struct *t) 754void vtime_init_idle(struct task_struct *t, int cpu)
755{ 755{
756 unsigned long flags; 756 unsigned long flags;
757 757
758 write_seqlock_irqsave(&t->vtime_seqlock, flags); 758 write_seqlock_irqsave(&t->vtime_seqlock, flags);
759 t->vtime_snap_whence = VTIME_SYS; 759 t->vtime_snap_whence = VTIME_SYS;
760 t->vtime_snap = sched_clock(); 760 t->vtime_snap = sched_clock_cpu(cpu);
761 write_sequnlock_irqrestore(&t->vtime_seqlock, flags); 761 write_sequnlock_irqrestore(&t->vtime_seqlock, flags);
762} 762}
763 763
diff --git a/kernel/softirq.c b/kernel/softirq.c
index b5197dcb0dad..3d6833f125d3 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -195,8 +195,12 @@ void local_bh_enable_ip(unsigned long ip)
195EXPORT_SYMBOL(local_bh_enable_ip); 195EXPORT_SYMBOL(local_bh_enable_ip);
196 196
197/* 197/*
198 * We restart softirq processing for at most 2 ms, 198 * We restart softirq processing for at most MAX_SOFTIRQ_RESTART times,
199 * and if need_resched() is not set. 199 * but break the loop if need_resched() is set or after 2 ms.
200 * The MAX_SOFTIRQ_TIME provides a nice upper bound in most cases, but in
201 * certain cases, such as stop_machine(), jiffies may cease to
202 * increment and so we need the MAX_SOFTIRQ_RESTART limit as
203 * well to make sure we eventually return from this method.
200 * 204 *
201 * These limits have been established via experimentation. 205 * These limits have been established via experimentation.
202 * The two things to balance is latency against fairness - 206 * The two things to balance is latency against fairness -
@@ -204,6 +208,7 @@ EXPORT_SYMBOL(local_bh_enable_ip);
204 * should not be able to lock up the box. 208 * should not be able to lock up the box.
205 */ 209 */
206#define MAX_SOFTIRQ_TIME msecs_to_jiffies(2) 210#define MAX_SOFTIRQ_TIME msecs_to_jiffies(2)
211#define MAX_SOFTIRQ_RESTART 10
207 212
208asmlinkage void __do_softirq(void) 213asmlinkage void __do_softirq(void)
209{ 214{
@@ -212,6 +217,7 @@ asmlinkage void __do_softirq(void)
212 unsigned long end = jiffies + MAX_SOFTIRQ_TIME; 217 unsigned long end = jiffies + MAX_SOFTIRQ_TIME;
213 int cpu; 218 int cpu;
214 unsigned long old_flags = current->flags; 219 unsigned long old_flags = current->flags;
220 int max_restart = MAX_SOFTIRQ_RESTART;
215 221
216 /* 222 /*
217 * Mask out PF_MEMALLOC s current task context is borrowed for the 223 * Mask out PF_MEMALLOC s current task context is borrowed for the
@@ -265,7 +271,8 @@ restart:
265 271
266 pending = local_softirq_pending(); 272 pending = local_softirq_pending();
267 if (pending) { 273 if (pending) {
268 if (time_before(jiffies, end) && !need_resched()) 274 if (time_before(jiffies, end) && !need_resched() &&
275 --max_restart)
269 goto restart; 276 goto restart;
270 277
271 wakeup_softirqd(); 278 wakeup_softirqd();
diff --git a/kernel/sys.c b/kernel/sys.c
index b95d3c72ba21..2bbd9a73b54c 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -362,6 +362,29 @@ int unregister_reboot_notifier(struct notifier_block *nb)
362} 362}
363EXPORT_SYMBOL(unregister_reboot_notifier); 363EXPORT_SYMBOL(unregister_reboot_notifier);
364 364
365/* Add backwards compatibility for stable trees. */
366#ifndef PF_NO_SETAFFINITY
367#define PF_NO_SETAFFINITY PF_THREAD_BOUND
368#endif
369
370static void migrate_to_reboot_cpu(void)
371{
372 /* The boot cpu is always logical cpu 0 */
373 int cpu = 0;
374
375 cpu_hotplug_disable();
376
377 /* Make certain the cpu I'm about to reboot on is online */
378 if (!cpu_online(cpu))
379 cpu = cpumask_first(cpu_online_mask);
380
381 /* Prevent races with other tasks migrating this task */
382 current->flags |= PF_NO_SETAFFINITY;
383
384 /* Make certain I only run on the appropriate processor */
385 set_cpus_allowed_ptr(current, cpumask_of(cpu));
386}
387
365/** 388/**
366 * kernel_restart - reboot the system 389 * kernel_restart - reboot the system
367 * @cmd: pointer to buffer containing command to execute for restart 390 * @cmd: pointer to buffer containing command to execute for restart
@@ -373,7 +396,7 @@ EXPORT_SYMBOL(unregister_reboot_notifier);
373void kernel_restart(char *cmd) 396void kernel_restart(char *cmd)
374{ 397{
375 kernel_restart_prepare(cmd); 398 kernel_restart_prepare(cmd);
376 disable_nonboot_cpus(); 399 migrate_to_reboot_cpu();
377 syscore_shutdown(); 400 syscore_shutdown();
378 if (!cmd) 401 if (!cmd)
379 printk(KERN_EMERG "Restarting system.\n"); 402 printk(KERN_EMERG "Restarting system.\n");
@@ -400,7 +423,7 @@ static void kernel_shutdown_prepare(enum system_states state)
400void kernel_halt(void) 423void kernel_halt(void)
401{ 424{
402 kernel_shutdown_prepare(SYSTEM_HALT); 425 kernel_shutdown_prepare(SYSTEM_HALT);
403 disable_nonboot_cpus(); 426 migrate_to_reboot_cpu();
404 syscore_shutdown(); 427 syscore_shutdown();
405 printk(KERN_EMERG "System halted.\n"); 428 printk(KERN_EMERG "System halted.\n");
406 kmsg_dump(KMSG_DUMP_HALT); 429 kmsg_dump(KMSG_DUMP_HALT);
@@ -419,7 +442,7 @@ void kernel_power_off(void)
419 kernel_shutdown_prepare(SYSTEM_POWER_OFF); 442 kernel_shutdown_prepare(SYSTEM_POWER_OFF);
420 if (pm_power_off_prepare) 443 if (pm_power_off_prepare)
421 pm_power_off_prepare(); 444 pm_power_off_prepare();
422 disable_nonboot_cpus(); 445 migrate_to_reboot_cpu();
423 syscore_shutdown(); 446 syscore_shutdown();
424 printk(KERN_EMERG "Power down.\n"); 447 printk(KERN_EMERG "Power down.\n");
425 kmsg_dump(KMSG_DUMP_POWEROFF); 448 kmsg_dump(KMSG_DUMP_POWEROFF);
diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
index 0c739423b0f9..b4c245580b79 100644
--- a/kernel/time/tick-broadcast.c
+++ b/kernel/time/tick-broadcast.c
@@ -698,10 +698,6 @@ void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
698 698
699 bc->event_handler = tick_handle_oneshot_broadcast; 699 bc->event_handler = tick_handle_oneshot_broadcast;
700 700
701 /* Take the do_timer update */
702 if (!tick_nohz_full_cpu(cpu))
703 tick_do_timer_cpu = cpu;
704
705 /* 701 /*
706 * We must be careful here. There might be other CPUs 702 * We must be careful here. There might be other CPUs
707 * waiting for periodic broadcast. We need to set the 703 * waiting for periodic broadcast. We need to set the
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index f4208138fbf4..0cf1c1453181 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -306,7 +306,7 @@ static int __cpuinit tick_nohz_cpu_down_callback(struct notifier_block *nfb,
306 * we can't safely shutdown that CPU. 306 * we can't safely shutdown that CPU.
307 */ 307 */
308 if (have_nohz_full_mask && tick_do_timer_cpu == cpu) 308 if (have_nohz_full_mask && tick_do_timer_cpu == cpu)
309 return -EINVAL; 309 return NOTIFY_BAD;
310 break; 310 break;
311 } 311 }
312 return NOTIFY_OK; 312 return NOTIFY_OK;
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 1a41023a1f88..e71a8be4a6ee 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -652,8 +652,6 @@ static struct {
652 ARCH_TRACE_CLOCKS 652 ARCH_TRACE_CLOCKS
653}; 653};
654 654
655int trace_clock_id;
656
657/* 655/*
658 * trace_parser_get_init - gets the buffer for trace parser 656 * trace_parser_get_init - gets the buffer for trace parser
659 */ 657 */
@@ -2826,7 +2824,7 @@ __tracing_open(struct inode *inode, struct file *file, bool snapshot)
2826 iter->iter_flags |= TRACE_FILE_ANNOTATE; 2824 iter->iter_flags |= TRACE_FILE_ANNOTATE;
2827 2825
2828 /* Output in nanoseconds only if we are using a clock in nanoseconds. */ 2826 /* Output in nanoseconds only if we are using a clock in nanoseconds. */
2829 if (trace_clocks[trace_clock_id].in_ns) 2827 if (trace_clocks[tr->clock_id].in_ns)
2830 iter->iter_flags |= TRACE_FILE_TIME_IN_NS; 2828 iter->iter_flags |= TRACE_FILE_TIME_IN_NS;
2831 2829
2832 /* stop the trace while dumping if we are not opening "snapshot" */ 2830 /* stop the trace while dumping if we are not opening "snapshot" */
@@ -3825,7 +3823,7 @@ static int tracing_open_pipe(struct inode *inode, struct file *filp)
3825 iter->iter_flags |= TRACE_FILE_LAT_FMT; 3823 iter->iter_flags |= TRACE_FILE_LAT_FMT;
3826 3824
3827 /* Output in nanoseconds only if we are using a clock in nanoseconds. */ 3825 /* Output in nanoseconds only if we are using a clock in nanoseconds. */
3828 if (trace_clocks[trace_clock_id].in_ns) 3826 if (trace_clocks[tr->clock_id].in_ns)
3829 iter->iter_flags |= TRACE_FILE_TIME_IN_NS; 3827 iter->iter_flags |= TRACE_FILE_TIME_IN_NS;
3830 3828
3831 iter->cpu_file = tc->cpu; 3829 iter->cpu_file = tc->cpu;
@@ -5095,7 +5093,7 @@ tracing_stats_read(struct file *filp, char __user *ubuf,
5095 cnt = ring_buffer_bytes_cpu(trace_buf->buffer, cpu); 5093 cnt = ring_buffer_bytes_cpu(trace_buf->buffer, cpu);
5096 trace_seq_printf(s, "bytes: %ld\n", cnt); 5094 trace_seq_printf(s, "bytes: %ld\n", cnt);
5097 5095
5098 if (trace_clocks[trace_clock_id].in_ns) { 5096 if (trace_clocks[tr->clock_id].in_ns) {
5099 /* local or global for trace_clock */ 5097 /* local or global for trace_clock */
5100 t = ns2usecs(ring_buffer_oldest_event_ts(trace_buf->buffer, cpu)); 5098 t = ns2usecs(ring_buffer_oldest_event_ts(trace_buf->buffer, cpu));
5101 usec_rem = do_div(t, USEC_PER_SEC); 5099 usec_rem = do_div(t, USEC_PER_SEC);
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 711ca7d3e7f1..20572ed88c5c 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -700,8 +700,6 @@ enum print_line_t print_trace_line(struct trace_iterator *iter);
700 700
701extern unsigned long trace_flags; 701extern unsigned long trace_flags;
702 702
703extern int trace_clock_id;
704
705/* Standard output formatting function used for function return traces */ 703/* Standard output formatting function used for function return traces */
706#ifdef CONFIG_FUNCTION_GRAPH_TRACER 704#ifdef CONFIG_FUNCTION_GRAPH_TRACER
707 705
diff --git a/lib/mpi/mpicoder.c b/lib/mpi/mpicoder.c
index 5f9c44cdf1f5..4cc6442733f4 100644
--- a/lib/mpi/mpicoder.c
+++ b/lib/mpi/mpicoder.c
@@ -37,7 +37,7 @@ MPI mpi_read_raw_data(const void *xbuffer, size_t nbytes)
37 mpi_limb_t a; 37 mpi_limb_t a;
38 MPI val = NULL; 38 MPI val = NULL;
39 39
40 while (nbytes >= 0 && buffer[0] == 0) { 40 while (nbytes > 0 && buffer[0] == 0) {
41 buffer++; 41 buffer++;
42 nbytes--; 42 nbytes--;
43 } 43 }
diff --git a/mm/frontswap.c b/mm/frontswap.c
index 538367ef1372..1b24bdcb3197 100644
--- a/mm/frontswap.c
+++ b/mm/frontswap.c
@@ -319,7 +319,7 @@ void __frontswap_invalidate_area(unsigned type)
319 return; 319 return;
320 frontswap_ops->invalidate_area(type); 320 frontswap_ops->invalidate_area(type);
321 atomic_set(&sis->frontswap_pages, 0); 321 atomic_set(&sis->frontswap_pages, 0);
322 memset(sis->frontswap_map, 0, sis->max / sizeof(long)); 322 bitmap_zero(sis->frontswap_map, sis->max);
323 } 323 }
324 clear_bit(type, need_init); 324 clear_bit(type, need_init);
325} 325}
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index f8feeeca6686..e2bfbf73a551 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -2839,7 +2839,7 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
2839 if (ptep) { 2839 if (ptep) {
2840 entry = huge_ptep_get(ptep); 2840 entry = huge_ptep_get(ptep);
2841 if (unlikely(is_hugetlb_entry_migration(entry))) { 2841 if (unlikely(is_hugetlb_entry_migration(entry))) {
2842 migration_entry_wait(mm, (pmd_t *)ptep, address); 2842 migration_entry_wait_huge(mm, ptep);
2843 return 0; 2843 return 0;
2844 } else if (unlikely(is_hugetlb_entry_hwpoisoned(entry))) 2844 } else if (unlikely(is_hugetlb_entry_hwpoisoned(entry)))
2845 return VM_FAULT_HWPOISON_LARGE | 2845 return VM_FAULT_HWPOISON_LARGE |
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 010d6c14129a..194721839cf5 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1199,7 +1199,6 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root,
1199 1199
1200 mz = mem_cgroup_zoneinfo(root, nid, zid); 1200 mz = mem_cgroup_zoneinfo(root, nid, zid);
1201 iter = &mz->reclaim_iter[reclaim->priority]; 1201 iter = &mz->reclaim_iter[reclaim->priority];
1202 last_visited = iter->last_visited;
1203 if (prev && reclaim->generation != iter->generation) { 1202 if (prev && reclaim->generation != iter->generation) {
1204 iter->last_visited = NULL; 1203 iter->last_visited = NULL;
1205 goto out_unlock; 1204 goto out_unlock;
@@ -1218,13 +1217,12 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root,
1218 * is alive. 1217 * is alive.
1219 */ 1218 */
1220 dead_count = atomic_read(&root->dead_count); 1219 dead_count = atomic_read(&root->dead_count);
1221 smp_rmb(); 1220 if (dead_count == iter->last_dead_count) {
1222 last_visited = iter->last_visited; 1221 smp_rmb();
1223 if (last_visited) { 1222 last_visited = iter->last_visited;
1224 if ((dead_count != iter->last_dead_count) || 1223 if (last_visited &&
1225 !css_tryget(&last_visited->css)) { 1224 !css_tryget(&last_visited->css))
1226 last_visited = NULL; 1225 last_visited = NULL;
1227 }
1228 } 1226 }
1229 } 1227 }
1230 1228
@@ -3141,8 +3139,6 @@ int memcg_update_cache_size(struct kmem_cache *s, int num_groups)
3141 return -ENOMEM; 3139 return -ENOMEM;
3142 } 3140 }
3143 3141
3144 INIT_WORK(&s->memcg_params->destroy,
3145 kmem_cache_destroy_work_func);
3146 s->memcg_params->is_root_cache = true; 3142 s->memcg_params->is_root_cache = true;
3147 3143
3148 /* 3144 /*
diff --git a/mm/migrate.c b/mm/migrate.c
index b1f57501de9c..6f0c24438bba 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -200,15 +200,14 @@ static void remove_migration_ptes(struct page *old, struct page *new)
200 * get to the page and wait until migration is finished. 200 * get to the page and wait until migration is finished.
201 * When we return from this function the fault will be retried. 201 * When we return from this function the fault will be retried.
202 */ 202 */
203void migration_entry_wait(struct mm_struct *mm, pmd_t *pmd, 203static void __migration_entry_wait(struct mm_struct *mm, pte_t *ptep,
204 unsigned long address) 204 spinlock_t *ptl)
205{ 205{
206 pte_t *ptep, pte; 206 pte_t pte;
207 spinlock_t *ptl;
208 swp_entry_t entry; 207 swp_entry_t entry;
209 struct page *page; 208 struct page *page;
210 209
211 ptep = pte_offset_map_lock(mm, pmd, address, &ptl); 210 spin_lock(ptl);
212 pte = *ptep; 211 pte = *ptep;
213 if (!is_swap_pte(pte)) 212 if (!is_swap_pte(pte))
214 goto out; 213 goto out;
@@ -236,6 +235,20 @@ out:
236 pte_unmap_unlock(ptep, ptl); 235 pte_unmap_unlock(ptep, ptl);
237} 236}
238 237
238void migration_entry_wait(struct mm_struct *mm, pmd_t *pmd,
239 unsigned long address)
240{
241 spinlock_t *ptl = pte_lockptr(mm, pmd);
242 pte_t *ptep = pte_offset_map(pmd, address);
243 __migration_entry_wait(mm, ptep, ptl);
244}
245
246void migration_entry_wait_huge(struct mm_struct *mm, pte_t *pte)
247{
248 spinlock_t *ptl = &(mm)->page_table_lock;
249 __migration_entry_wait(mm, pte, ptl);
250}
251
239#ifdef CONFIG_BLOCK 252#ifdef CONFIG_BLOCK
240/* Returns true if all buffers are successfully locked */ 253/* Returns true if all buffers are successfully locked */
241static bool buffer_migrate_lock_buffers(struct buffer_head *head, 254static bool buffer_migrate_lock_buffers(struct buffer_head *head,
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 378a15bcd649..c3edb624fccf 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1628,6 +1628,7 @@ static bool __zone_watermark_ok(struct zone *z, int order, unsigned long mark,
1628 long min = mark; 1628 long min = mark;
1629 long lowmem_reserve = z->lowmem_reserve[classzone_idx]; 1629 long lowmem_reserve = z->lowmem_reserve[classzone_idx];
1630 int o; 1630 int o;
1631 long free_cma = 0;
1631 1632
1632 free_pages -= (1 << order) - 1; 1633 free_pages -= (1 << order) - 1;
1633 if (alloc_flags & ALLOC_HIGH) 1634 if (alloc_flags & ALLOC_HIGH)
@@ -1637,9 +1638,10 @@ static bool __zone_watermark_ok(struct zone *z, int order, unsigned long mark,
1637#ifdef CONFIG_CMA 1638#ifdef CONFIG_CMA
1638 /* If allocation can't use CMA areas don't use free CMA pages */ 1639 /* If allocation can't use CMA areas don't use free CMA pages */
1639 if (!(alloc_flags & ALLOC_CMA)) 1640 if (!(alloc_flags & ALLOC_CMA))
1640 free_pages -= zone_page_state(z, NR_FREE_CMA_PAGES); 1641 free_cma = zone_page_state(z, NR_FREE_CMA_PAGES);
1641#endif 1642#endif
1642 if (free_pages <= min + lowmem_reserve) 1643
1644 if (free_pages - free_cma <= min + lowmem_reserve)
1643 return false; 1645 return false;
1644 for (o = 0; o < order; o++) { 1646 for (o = 0; o < order; o++) {
1645 /* At the next order, this order's pages become unavailable */ 1647 /* At the next order, this order's pages become unavailable */
diff --git a/mm/slab_common.c b/mm/slab_common.c
index ff3218a0f5e1..2d414508e9ec 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -373,8 +373,10 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
373{ 373{
374 int index; 374 int index;
375 375
376 if (WARN_ON_ONCE(size > KMALLOC_MAX_SIZE)) 376 if (size > KMALLOC_MAX_SIZE) {
377 WARN_ON_ONCE(!(flags & __GFP_NOWARN));
377 return NULL; 378 return NULL;
379 }
378 380
379 if (size <= 192) { 381 if (size <= 192) {
380 if (!size) 382 if (!size)
diff --git a/mm/swap_state.c b/mm/swap_state.c
index b3d40dcf3624..f24ab0dff554 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -336,8 +336,24 @@ struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
336 * Swap entry may have been freed since our caller observed it. 336 * Swap entry may have been freed since our caller observed it.
337 */ 337 */
338 err = swapcache_prepare(entry); 338 err = swapcache_prepare(entry);
339 if (err == -EEXIST) { /* seems racy */ 339 if (err == -EEXIST) {
340 radix_tree_preload_end(); 340 radix_tree_preload_end();
341 /*
342 * We might race against get_swap_page() and stumble
343 * across a SWAP_HAS_CACHE swap_map entry whose page
344 * has not been brought into the swapcache yet, while
345 * the other end is scheduled away waiting on discard
346 * I/O completion at scan_swap_map().
347 *
348 * In order to avoid turning this transitory state
349 * into a permanent loop around this -EEXIST case
350 * if !CONFIG_PREEMPT and the I/O completion happens
351 * to be waiting on the CPU waitqueue where we are now
352 * busy looping, we just conditionally invoke the
353 * scheduler here, if there are some more important
354 * tasks to run.
355 */
356 cond_resched();
341 continue; 357 continue;
342 } 358 }
343 if (err) { /* swp entry is obsolete ? */ 359 if (err) { /* swp entry is obsolete ? */
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 6c340d908b27..746af55b8455 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2116,7 +2116,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
2116 } 2116 }
2117 /* frontswap enabled? set up bit-per-page map for frontswap */ 2117 /* frontswap enabled? set up bit-per-page map for frontswap */
2118 if (frontswap_enabled) 2118 if (frontswap_enabled)
2119 frontswap_map = vzalloc(maxpages / sizeof(long)); 2119 frontswap_map = vzalloc(BITS_TO_LONGS(maxpages) * sizeof(long));
2120 2120
2121 if (p->bdev) { 2121 if (p->bdev) {
2122 if (blk_queue_nonrot(bdev_get_queue(p->bdev))) { 2122 if (blk_queue_nonrot(bdev_get_queue(p->bdev))) {
diff --git a/net/9p/client.c b/net/9p/client.c
index 8eb75425e6e6..addc116cecf0 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -562,36 +562,19 @@ static int p9_check_zc_errors(struct p9_client *c, struct p9_req_t *req,
562 562
563 if (!p9_is_proto_dotl(c)) { 563 if (!p9_is_proto_dotl(c)) {
564 /* Error is reported in string format */ 564 /* Error is reported in string format */
565 uint16_t len; 565 int len;
566 /* 7 = header size for RERROR, 2 is the size of string len; */ 566 /* 7 = header size for RERROR; */
567 int inline_len = in_hdrlen - (7 + 2); 567 int inline_len = in_hdrlen - 7;
568 568
569 /* Read the size of error string */ 569 len = req->rc->size - req->rc->offset;
570 err = p9pdu_readf(req->rc, c->proto_version, "w", &len); 570 if (len > (P9_ZC_HDR_SZ - 7)) {
571 if (err) 571 err = -EFAULT;
572 goto out_err;
573
574 ename = kmalloc(len + 1, GFP_NOFS);
575 if (!ename) {
576 err = -ENOMEM;
577 goto out_err; 572 goto out_err;
578 } 573 }
579 if (len <= inline_len) {
580 /* We have error in protocol buffer itself */
581 if (pdu_read(req->rc, ename, len)) {
582 err = -EFAULT;
583 goto out_free;
584 574
585 } 575 ename = &req->rc->sdata[req->rc->offset];
586 } else { 576 if (len > inline_len) {
587 /* 577 /* We have error in external buffer */
588 * Part of the data is in user space buffer.
589 */
590 if (pdu_read(req->rc, ename, inline_len)) {
591 err = -EFAULT;
592 goto out_free;
593
594 }
595 if (kern_buf) { 578 if (kern_buf) {
596 memcpy(ename + inline_len, uidata, 579 memcpy(ename + inline_len, uidata,
597 len - inline_len); 580 len - inline_len);
@@ -600,19 +583,19 @@ static int p9_check_zc_errors(struct p9_client *c, struct p9_req_t *req,
600 uidata, len - inline_len); 583 uidata, len - inline_len);
601 if (err) { 584 if (err) {
602 err = -EFAULT; 585 err = -EFAULT;
603 goto out_free; 586 goto out_err;
604 } 587 }
605 } 588 }
606 } 589 }
607 ename[len] = 0; 590 ename = NULL;
608 if (p9_is_proto_dotu(c)) { 591 err = p9pdu_readf(req->rc, c->proto_version, "s?d",
609 /* For dotu we also have error code */ 592 &ename, &ecode);
610 err = p9pdu_readf(req->rc, 593 if (err)
611 c->proto_version, "d", &ecode); 594 goto out_err;
612 if (err) 595
613 goto out_free; 596 if (p9_is_proto_dotu(c))
614 err = -ecode; 597 err = -ecode;
615 } 598
616 if (!err || !IS_ERR_VALUE(err)) { 599 if (!err || !IS_ERR_VALUE(err)) {
617 err = p9_errstr2errno(ename, strlen(ename)); 600 err = p9_errstr2errno(ename, strlen(ename));
618 601
@@ -628,8 +611,6 @@ static int p9_check_zc_errors(struct p9_client *c, struct p9_req_t *req,
628 } 611 }
629 return err; 612 return err;
630 613
631out_free:
632 kfree(ename);
633out_err: 614out_err:
634 p9_debug(P9_DEBUG_ERROR, "couldn't parse error%d\n", err); 615 p9_debug(P9_DEBUG_ERROR, "couldn't parse error%d\n", err);
635 return err; 616 return err;
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 071f288b77a8..f680ee101878 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -29,6 +29,21 @@
29#include "bat_algo.h" 29#include "bat_algo.h"
30#include "network-coding.h" 30#include "network-coding.h"
31 31
32/**
33 * batadv_dup_status - duplicate status
34 * @BATADV_NO_DUP: the packet is a duplicate
35 * @BATADV_ORIG_DUP: OGM is a duplicate in the originator (but not for the
36 * neighbor)
37 * @BATADV_NEIGH_DUP: OGM is a duplicate for the neighbor
38 * @BATADV_PROTECTED: originator is currently protected (after reboot)
39 */
40enum batadv_dup_status {
41 BATADV_NO_DUP = 0,
42 BATADV_ORIG_DUP,
43 BATADV_NEIGH_DUP,
44 BATADV_PROTECTED,
45};
46
32static struct batadv_neigh_node * 47static struct batadv_neigh_node *
33batadv_iv_ogm_neigh_new(struct batadv_hard_iface *hard_iface, 48batadv_iv_ogm_neigh_new(struct batadv_hard_iface *hard_iface,
34 const uint8_t *neigh_addr, 49 const uint8_t *neigh_addr,
@@ -650,7 +665,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
650 const struct batadv_ogm_packet *batadv_ogm_packet, 665 const struct batadv_ogm_packet *batadv_ogm_packet,
651 struct batadv_hard_iface *if_incoming, 666 struct batadv_hard_iface *if_incoming,
652 const unsigned char *tt_buff, 667 const unsigned char *tt_buff,
653 int is_duplicate) 668 enum batadv_dup_status dup_status)
654{ 669{
655 struct batadv_neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL; 670 struct batadv_neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL;
656 struct batadv_neigh_node *router = NULL; 671 struct batadv_neigh_node *router = NULL;
@@ -676,7 +691,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
676 continue; 691 continue;
677 } 692 }
678 693
679 if (is_duplicate) 694 if (dup_status != BATADV_NO_DUP)
680 continue; 695 continue;
681 696
682 spin_lock_bh(&tmp_neigh_node->lq_update_lock); 697 spin_lock_bh(&tmp_neigh_node->lq_update_lock);
@@ -718,7 +733,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
718 neigh_node->tq_avg = batadv_ring_buffer_avg(neigh_node->tq_recv); 733 neigh_node->tq_avg = batadv_ring_buffer_avg(neigh_node->tq_recv);
719 spin_unlock_bh(&neigh_node->lq_update_lock); 734 spin_unlock_bh(&neigh_node->lq_update_lock);
720 735
721 if (!is_duplicate) { 736 if (dup_status == BATADV_NO_DUP) {
722 orig_node->last_ttl = batadv_ogm_packet->header.ttl; 737 orig_node->last_ttl = batadv_ogm_packet->header.ttl;
723 neigh_node->last_ttl = batadv_ogm_packet->header.ttl; 738 neigh_node->last_ttl = batadv_ogm_packet->header.ttl;
724 } 739 }
@@ -902,15 +917,16 @@ out:
902 return ret; 917 return ret;
903} 918}
904 919
905/* processes a batman packet for all interfaces, adjusts the sequence number and 920/**
906 * finds out whether it is a duplicate. 921 * batadv_iv_ogm_update_seqnos - process a batman packet for all interfaces,
907 * returns: 922 * adjust the sequence number and find out whether it is a duplicate
908 * 1 the packet is a duplicate 923 * @ethhdr: ethernet header of the packet
909 * 0 the packet has not yet been received 924 * @batadv_ogm_packet: OGM packet to be considered
910 * -1 the packet is old and has been received while the seqno window 925 * @if_incoming: interface on which the OGM packet was received
911 * was protected. Caller should drop it. 926 *
927 * Returns duplicate status as enum batadv_dup_status
912 */ 928 */
913static int 929static enum batadv_dup_status
914batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, 930batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
915 const struct batadv_ogm_packet *batadv_ogm_packet, 931 const struct batadv_ogm_packet *batadv_ogm_packet,
916 const struct batadv_hard_iface *if_incoming) 932 const struct batadv_hard_iface *if_incoming)
@@ -918,17 +934,18 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
918 struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 934 struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
919 struct batadv_orig_node *orig_node; 935 struct batadv_orig_node *orig_node;
920 struct batadv_neigh_node *tmp_neigh_node; 936 struct batadv_neigh_node *tmp_neigh_node;
921 int is_duplicate = 0; 937 int is_dup;
922 int32_t seq_diff; 938 int32_t seq_diff;
923 int need_update = 0; 939 int need_update = 0;
924 int set_mark, ret = -1; 940 int set_mark;
941 enum batadv_dup_status ret = BATADV_NO_DUP;
925 uint32_t seqno = ntohl(batadv_ogm_packet->seqno); 942 uint32_t seqno = ntohl(batadv_ogm_packet->seqno);
926 uint8_t *neigh_addr; 943 uint8_t *neigh_addr;
927 uint8_t packet_count; 944 uint8_t packet_count;
928 945
929 orig_node = batadv_get_orig_node(bat_priv, batadv_ogm_packet->orig); 946 orig_node = batadv_get_orig_node(bat_priv, batadv_ogm_packet->orig);
930 if (!orig_node) 947 if (!orig_node)
931 return 0; 948 return BATADV_NO_DUP;
932 949
933 spin_lock_bh(&orig_node->ogm_cnt_lock); 950 spin_lock_bh(&orig_node->ogm_cnt_lock);
934 seq_diff = seqno - orig_node->last_real_seqno; 951 seq_diff = seqno - orig_node->last_real_seqno;
@@ -936,22 +953,29 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
936 /* signalize caller that the packet is to be dropped. */ 953 /* signalize caller that the packet is to be dropped. */
937 if (!hlist_empty(&orig_node->neigh_list) && 954 if (!hlist_empty(&orig_node->neigh_list) &&
938 batadv_window_protected(bat_priv, seq_diff, 955 batadv_window_protected(bat_priv, seq_diff,
939 &orig_node->batman_seqno_reset)) 956 &orig_node->batman_seqno_reset)) {
957 ret = BATADV_PROTECTED;
940 goto out; 958 goto out;
959 }
941 960
942 rcu_read_lock(); 961 rcu_read_lock();
943 hlist_for_each_entry_rcu(tmp_neigh_node, 962 hlist_for_each_entry_rcu(tmp_neigh_node,
944 &orig_node->neigh_list, list) { 963 &orig_node->neigh_list, list) {
945 is_duplicate |= batadv_test_bit(tmp_neigh_node->real_bits,
946 orig_node->last_real_seqno,
947 seqno);
948
949 neigh_addr = tmp_neigh_node->addr; 964 neigh_addr = tmp_neigh_node->addr;
965 is_dup = batadv_test_bit(tmp_neigh_node->real_bits,
966 orig_node->last_real_seqno,
967 seqno);
968
950 if (batadv_compare_eth(neigh_addr, ethhdr->h_source) && 969 if (batadv_compare_eth(neigh_addr, ethhdr->h_source) &&
951 tmp_neigh_node->if_incoming == if_incoming) 970 tmp_neigh_node->if_incoming == if_incoming) {
952 set_mark = 1; 971 set_mark = 1;
953 else 972 if (is_dup)
973 ret = BATADV_NEIGH_DUP;
974 } else {
954 set_mark = 0; 975 set_mark = 0;
976 if (is_dup && (ret != BATADV_NEIGH_DUP))
977 ret = BATADV_ORIG_DUP;
978 }
955 979
956 /* if the window moved, set the update flag. */ 980 /* if the window moved, set the update flag. */
957 need_update |= batadv_bit_get_packet(bat_priv, 981 need_update |= batadv_bit_get_packet(bat_priv,
@@ -971,8 +995,6 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
971 orig_node->last_real_seqno = seqno; 995 orig_node->last_real_seqno = seqno;
972 } 996 }
973 997
974 ret = is_duplicate;
975
976out: 998out:
977 spin_unlock_bh(&orig_node->ogm_cnt_lock); 999 spin_unlock_bh(&orig_node->ogm_cnt_lock);
978 batadv_orig_node_free_ref(orig_node); 1000 batadv_orig_node_free_ref(orig_node);
@@ -994,7 +1016,8 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
994 int is_broadcast = 0, is_bidirect; 1016 int is_broadcast = 0, is_bidirect;
995 bool is_single_hop_neigh = false; 1017 bool is_single_hop_neigh = false;
996 bool is_from_best_next_hop = false; 1018 bool is_from_best_next_hop = false;
997 int is_duplicate, sameseq, simlar_ttl; 1019 int sameseq, similar_ttl;
1020 enum batadv_dup_status dup_status;
998 uint32_t if_incoming_seqno; 1021 uint32_t if_incoming_seqno;
999 uint8_t *prev_sender; 1022 uint8_t *prev_sender;
1000 1023
@@ -1138,10 +1161,10 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
1138 if (!orig_node) 1161 if (!orig_node)
1139 return; 1162 return;
1140 1163
1141 is_duplicate = batadv_iv_ogm_update_seqnos(ethhdr, batadv_ogm_packet, 1164 dup_status = batadv_iv_ogm_update_seqnos(ethhdr, batadv_ogm_packet,
1142 if_incoming); 1165 if_incoming);
1143 1166
1144 if (is_duplicate == -1) { 1167 if (dup_status == BATADV_PROTECTED) {
1145 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1168 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1146 "Drop packet: packet within seqno protection time (sender: %pM)\n", 1169 "Drop packet: packet within seqno protection time (sender: %pM)\n",
1147 ethhdr->h_source); 1170 ethhdr->h_source);
@@ -1211,11 +1234,12 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
1211 * seqno and similar ttl as the non-duplicate 1234 * seqno and similar ttl as the non-duplicate
1212 */ 1235 */
1213 sameseq = orig_node->last_real_seqno == ntohl(batadv_ogm_packet->seqno); 1236 sameseq = orig_node->last_real_seqno == ntohl(batadv_ogm_packet->seqno);
1214 simlar_ttl = orig_node->last_ttl - 3 <= batadv_ogm_packet->header.ttl; 1237 similar_ttl = orig_node->last_ttl - 3 <= batadv_ogm_packet->header.ttl;
1215 if (is_bidirect && (!is_duplicate || (sameseq && simlar_ttl))) 1238 if (is_bidirect && ((dup_status == BATADV_NO_DUP) ||
1239 (sameseq && similar_ttl)))
1216 batadv_iv_ogm_orig_update(bat_priv, orig_node, ethhdr, 1240 batadv_iv_ogm_orig_update(bat_priv, orig_node, ethhdr,
1217 batadv_ogm_packet, if_incoming, 1241 batadv_ogm_packet, if_incoming,
1218 tt_buff, is_duplicate); 1242 tt_buff, dup_status);
1219 1243
1220 /* is single hop (direct) neighbor */ 1244 /* is single hop (direct) neighbor */
1221 if (is_single_hop_neigh) { 1245 if (is_single_hop_neigh) {
@@ -1236,7 +1260,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
1236 goto out_neigh; 1260 goto out_neigh;
1237 } 1261 }
1238 1262
1239 if (is_duplicate) { 1263 if (dup_status == BATADV_NEIGH_DUP) {
1240 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1264 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1241 "Drop packet: duplicate packet received\n"); 1265 "Drop packet: duplicate packet received\n");
1242 goto out_neigh; 1266 goto out_neigh;
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index 379061c72549..de27b3175cfd 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -1067,6 +1067,10 @@ void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
1067 group = htons(crc16(0, primary_if->net_dev->dev_addr, ETH_ALEN)); 1067 group = htons(crc16(0, primary_if->net_dev->dev_addr, ETH_ALEN));
1068 bat_priv->bla.claim_dest.group = group; 1068 bat_priv->bla.claim_dest.group = group;
1069 1069
1070 /* purge everything when bridge loop avoidance is turned off */
1071 if (!atomic_read(&bat_priv->bridge_loop_avoidance))
1072 oldif = NULL;
1073
1070 if (!oldif) { 1074 if (!oldif) {
1071 batadv_bla_purge_claims(bat_priv, NULL, 1); 1075 batadv_bla_purge_claims(bat_priv, NULL, 1);
1072 batadv_bla_purge_backbone_gw(bat_priv, 1); 1076 batadv_bla_purge_backbone_gw(bat_priv, 1);
diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c
index 15a22efa9a67..929e304dacb2 100644
--- a/net/batman-adv/sysfs.c
+++ b/net/batman-adv/sysfs.c
@@ -582,10 +582,7 @@ static ssize_t batadv_store_mesh_iface(struct kobject *kobj,
582 (strncmp(hard_iface->soft_iface->name, buff, IFNAMSIZ) == 0)) 582 (strncmp(hard_iface->soft_iface->name, buff, IFNAMSIZ) == 0))
583 goto out; 583 goto out;
584 584
585 if (!rtnl_trylock()) { 585 rtnl_lock();
586 ret = -ERESTARTSYS;
587 goto out;
588 }
589 586
590 if (status_tmp == BATADV_IF_NOT_IN_USE) { 587 if (status_tmp == BATADV_IF_NOT_IN_USE) {
591 batadv_hardif_disable_interface(hard_iface, 588 batadv_hardif_disable_interface(hard_iface,
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 33843c5c4939..d817c932d634 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1555,11 +1555,15 @@ static const struct rfkill_ops hci_rfkill_ops = {
1555static void hci_power_on(struct work_struct *work) 1555static void hci_power_on(struct work_struct *work)
1556{ 1556{
1557 struct hci_dev *hdev = container_of(work, struct hci_dev, power_on); 1557 struct hci_dev *hdev = container_of(work, struct hci_dev, power_on);
1558 int err;
1558 1559
1559 BT_DBG("%s", hdev->name); 1560 BT_DBG("%s", hdev->name);
1560 1561
1561 if (hci_dev_open(hdev->id) < 0) 1562 err = hci_dev_open(hdev->id);
1563 if (err < 0) {
1564 mgmt_set_powered_failed(hdev, err);
1562 return; 1565 return;
1566 }
1563 1567
1564 if (test_bit(HCI_AUTO_OFF, &hdev->dev_flags)) 1568 if (test_bit(HCI_AUTO_OFF, &hdev->dev_flags))
1565 queue_delayed_work(hdev->req_workqueue, &hdev->power_off, 1569 queue_delayed_work(hdev->req_workqueue, &hdev->power_off,
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index a76d1ac0321b..24bee07ee4ce 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3677,10 +3677,14 @@ static void l2cap_conf_rfc_get(struct l2cap_chan *chan, void *rsp, int len)
3677} 3677}
3678 3678
3679static inline int l2cap_command_rej(struct l2cap_conn *conn, 3679static inline int l2cap_command_rej(struct l2cap_conn *conn,
3680 struct l2cap_cmd_hdr *cmd, u8 *data) 3680 struct l2cap_cmd_hdr *cmd, u16 cmd_len,
3681 u8 *data)
3681{ 3682{
3682 struct l2cap_cmd_rej_unk *rej = (struct l2cap_cmd_rej_unk *) data; 3683 struct l2cap_cmd_rej_unk *rej = (struct l2cap_cmd_rej_unk *) data;
3683 3684
3685 if (cmd_len < sizeof(*rej))
3686 return -EPROTO;
3687
3684 if (rej->reason != L2CAP_REJ_NOT_UNDERSTOOD) 3688 if (rej->reason != L2CAP_REJ_NOT_UNDERSTOOD)
3685 return 0; 3689 return 0;
3686 3690
@@ -3829,11 +3833,14 @@ sendresp:
3829} 3833}
3830 3834
3831static int l2cap_connect_req(struct l2cap_conn *conn, 3835static int l2cap_connect_req(struct l2cap_conn *conn,
3832 struct l2cap_cmd_hdr *cmd, u8 *data) 3836 struct l2cap_cmd_hdr *cmd, u16 cmd_len, u8 *data)
3833{ 3837{
3834 struct hci_dev *hdev = conn->hcon->hdev; 3838 struct hci_dev *hdev = conn->hcon->hdev;
3835 struct hci_conn *hcon = conn->hcon; 3839 struct hci_conn *hcon = conn->hcon;
3836 3840
3841 if (cmd_len < sizeof(struct l2cap_conn_req))
3842 return -EPROTO;
3843
3837 hci_dev_lock(hdev); 3844 hci_dev_lock(hdev);
3838 if (test_bit(HCI_MGMT, &hdev->dev_flags) && 3845 if (test_bit(HCI_MGMT, &hdev->dev_flags) &&
3839 !test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &hcon->flags)) 3846 !test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &hcon->flags))
@@ -3847,7 +3854,8 @@ static int l2cap_connect_req(struct l2cap_conn *conn,
3847} 3854}
3848 3855
3849static int l2cap_connect_create_rsp(struct l2cap_conn *conn, 3856static int l2cap_connect_create_rsp(struct l2cap_conn *conn,
3850 struct l2cap_cmd_hdr *cmd, u8 *data) 3857 struct l2cap_cmd_hdr *cmd, u16 cmd_len,
3858 u8 *data)
3851{ 3859{
3852 struct l2cap_conn_rsp *rsp = (struct l2cap_conn_rsp *) data; 3860 struct l2cap_conn_rsp *rsp = (struct l2cap_conn_rsp *) data;
3853 u16 scid, dcid, result, status; 3861 u16 scid, dcid, result, status;
@@ -3855,6 +3863,9 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn,
3855 u8 req[128]; 3863 u8 req[128];
3856 int err; 3864 int err;
3857 3865
3866 if (cmd_len < sizeof(*rsp))
3867 return -EPROTO;
3868
3858 scid = __le16_to_cpu(rsp->scid); 3869 scid = __le16_to_cpu(rsp->scid);
3859 dcid = __le16_to_cpu(rsp->dcid); 3870 dcid = __le16_to_cpu(rsp->dcid);
3860 result = __le16_to_cpu(rsp->result); 3871 result = __le16_to_cpu(rsp->result);
@@ -3952,6 +3963,9 @@ static inline int l2cap_config_req(struct l2cap_conn *conn,
3952 struct l2cap_chan *chan; 3963 struct l2cap_chan *chan;
3953 int len, err = 0; 3964 int len, err = 0;
3954 3965
3966 if (cmd_len < sizeof(*req))
3967 return -EPROTO;
3968
3955 dcid = __le16_to_cpu(req->dcid); 3969 dcid = __le16_to_cpu(req->dcid);
3956 flags = __le16_to_cpu(req->flags); 3970 flags = __le16_to_cpu(req->flags);
3957 3971
@@ -3975,7 +3989,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn,
3975 3989
3976 /* Reject if config buffer is too small. */ 3990 /* Reject if config buffer is too small. */
3977 len = cmd_len - sizeof(*req); 3991 len = cmd_len - sizeof(*req);
3978 if (len < 0 || chan->conf_len + len > sizeof(chan->conf_req)) { 3992 if (chan->conf_len + len > sizeof(chan->conf_req)) {
3979 l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP, 3993 l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP,
3980 l2cap_build_conf_rsp(chan, rsp, 3994 l2cap_build_conf_rsp(chan, rsp,
3981 L2CAP_CONF_REJECT, flags), rsp); 3995 L2CAP_CONF_REJECT, flags), rsp);
@@ -4053,14 +4067,18 @@ unlock:
4053} 4067}
4054 4068
4055static inline int l2cap_config_rsp(struct l2cap_conn *conn, 4069static inline int l2cap_config_rsp(struct l2cap_conn *conn,
4056 struct l2cap_cmd_hdr *cmd, u8 *data) 4070 struct l2cap_cmd_hdr *cmd, u16 cmd_len,
4071 u8 *data)
4057{ 4072{
4058 struct l2cap_conf_rsp *rsp = (struct l2cap_conf_rsp *)data; 4073 struct l2cap_conf_rsp *rsp = (struct l2cap_conf_rsp *)data;
4059 u16 scid, flags, result; 4074 u16 scid, flags, result;
4060 struct l2cap_chan *chan; 4075 struct l2cap_chan *chan;
4061 int len = le16_to_cpu(cmd->len) - sizeof(*rsp); 4076 int len = cmd_len - sizeof(*rsp);
4062 int err = 0; 4077 int err = 0;
4063 4078
4079 if (cmd_len < sizeof(*rsp))
4080 return -EPROTO;
4081
4064 scid = __le16_to_cpu(rsp->scid); 4082 scid = __le16_to_cpu(rsp->scid);
4065 flags = __le16_to_cpu(rsp->flags); 4083 flags = __le16_to_cpu(rsp->flags);
4066 result = __le16_to_cpu(rsp->result); 4084 result = __le16_to_cpu(rsp->result);
@@ -4161,7 +4179,8 @@ done:
4161} 4179}
4162 4180
4163static inline int l2cap_disconnect_req(struct l2cap_conn *conn, 4181static inline int l2cap_disconnect_req(struct l2cap_conn *conn,
4164 struct l2cap_cmd_hdr *cmd, u8 *data) 4182 struct l2cap_cmd_hdr *cmd, u16 cmd_len,
4183 u8 *data)
4165{ 4184{
4166 struct l2cap_disconn_req *req = (struct l2cap_disconn_req *) data; 4185 struct l2cap_disconn_req *req = (struct l2cap_disconn_req *) data;
4167 struct l2cap_disconn_rsp rsp; 4186 struct l2cap_disconn_rsp rsp;
@@ -4169,6 +4188,9 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn,
4169 struct l2cap_chan *chan; 4188 struct l2cap_chan *chan;
4170 struct sock *sk; 4189 struct sock *sk;
4171 4190
4191 if (cmd_len != sizeof(*req))
4192 return -EPROTO;
4193
4172 scid = __le16_to_cpu(req->scid); 4194 scid = __le16_to_cpu(req->scid);
4173 dcid = __le16_to_cpu(req->dcid); 4195 dcid = __le16_to_cpu(req->dcid);
4174 4196
@@ -4208,12 +4230,16 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn,
4208} 4230}
4209 4231
4210static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, 4232static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn,
4211 struct l2cap_cmd_hdr *cmd, u8 *data) 4233 struct l2cap_cmd_hdr *cmd, u16 cmd_len,
4234 u8 *data)
4212{ 4235{
4213 struct l2cap_disconn_rsp *rsp = (struct l2cap_disconn_rsp *) data; 4236 struct l2cap_disconn_rsp *rsp = (struct l2cap_disconn_rsp *) data;
4214 u16 dcid, scid; 4237 u16 dcid, scid;
4215 struct l2cap_chan *chan; 4238 struct l2cap_chan *chan;
4216 4239
4240 if (cmd_len != sizeof(*rsp))
4241 return -EPROTO;
4242
4217 scid = __le16_to_cpu(rsp->scid); 4243 scid = __le16_to_cpu(rsp->scid);
4218 dcid = __le16_to_cpu(rsp->dcid); 4244 dcid = __le16_to_cpu(rsp->dcid);
4219 4245
@@ -4243,11 +4269,15 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn,
4243} 4269}
4244 4270
4245static inline int l2cap_information_req(struct l2cap_conn *conn, 4271static inline int l2cap_information_req(struct l2cap_conn *conn,
4246 struct l2cap_cmd_hdr *cmd, u8 *data) 4272 struct l2cap_cmd_hdr *cmd, u16 cmd_len,
4273 u8 *data)
4247{ 4274{
4248 struct l2cap_info_req *req = (struct l2cap_info_req *) data; 4275 struct l2cap_info_req *req = (struct l2cap_info_req *) data;
4249 u16 type; 4276 u16 type;
4250 4277
4278 if (cmd_len != sizeof(*req))
4279 return -EPROTO;
4280
4251 type = __le16_to_cpu(req->type); 4281 type = __le16_to_cpu(req->type);
4252 4282
4253 BT_DBG("type 0x%4.4x", type); 4283 BT_DBG("type 0x%4.4x", type);
@@ -4294,11 +4324,15 @@ static inline int l2cap_information_req(struct l2cap_conn *conn,
4294} 4324}
4295 4325
4296static inline int l2cap_information_rsp(struct l2cap_conn *conn, 4326static inline int l2cap_information_rsp(struct l2cap_conn *conn,
4297 struct l2cap_cmd_hdr *cmd, u8 *data) 4327 struct l2cap_cmd_hdr *cmd, u16 cmd_len,
4328 u8 *data)
4298{ 4329{
4299 struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) data; 4330 struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) data;
4300 u16 type, result; 4331 u16 type, result;
4301 4332
4333 if (cmd_len != sizeof(*rsp))
4334 return -EPROTO;
4335
4302 type = __le16_to_cpu(rsp->type); 4336 type = __le16_to_cpu(rsp->type);
4303 result = __le16_to_cpu(rsp->result); 4337 result = __le16_to_cpu(rsp->result);
4304 4338
@@ -5164,16 +5198,16 @@ static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn,
5164 5198
5165 switch (cmd->code) { 5199 switch (cmd->code) {
5166 case L2CAP_COMMAND_REJ: 5200 case L2CAP_COMMAND_REJ:
5167 l2cap_command_rej(conn, cmd, data); 5201 l2cap_command_rej(conn, cmd, cmd_len, data);
5168 break; 5202 break;
5169 5203
5170 case L2CAP_CONN_REQ: 5204 case L2CAP_CONN_REQ:
5171 err = l2cap_connect_req(conn, cmd, data); 5205 err = l2cap_connect_req(conn, cmd, cmd_len, data);
5172 break; 5206 break;
5173 5207
5174 case L2CAP_CONN_RSP: 5208 case L2CAP_CONN_RSP:
5175 case L2CAP_CREATE_CHAN_RSP: 5209 case L2CAP_CREATE_CHAN_RSP:
5176 err = l2cap_connect_create_rsp(conn, cmd, data); 5210 err = l2cap_connect_create_rsp(conn, cmd, cmd_len, data);
5177 break; 5211 break;
5178 5212
5179 case L2CAP_CONF_REQ: 5213 case L2CAP_CONF_REQ:
@@ -5181,15 +5215,15 @@ static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn,
5181 break; 5215 break;
5182 5216
5183 case L2CAP_CONF_RSP: 5217 case L2CAP_CONF_RSP:
5184 err = l2cap_config_rsp(conn, cmd, data); 5218 err = l2cap_config_rsp(conn, cmd, cmd_len, data);
5185 break; 5219 break;
5186 5220
5187 case L2CAP_DISCONN_REQ: 5221 case L2CAP_DISCONN_REQ:
5188 err = l2cap_disconnect_req(conn, cmd, data); 5222 err = l2cap_disconnect_req(conn, cmd, cmd_len, data);
5189 break; 5223 break;
5190 5224
5191 case L2CAP_DISCONN_RSP: 5225 case L2CAP_DISCONN_RSP:
5192 err = l2cap_disconnect_rsp(conn, cmd, data); 5226 err = l2cap_disconnect_rsp(conn, cmd, cmd_len, data);
5193 break; 5227 break;
5194 5228
5195 case L2CAP_ECHO_REQ: 5229 case L2CAP_ECHO_REQ:
@@ -5200,11 +5234,11 @@ static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn,
5200 break; 5234 break;
5201 5235
5202 case L2CAP_INFO_REQ: 5236 case L2CAP_INFO_REQ:
5203 err = l2cap_information_req(conn, cmd, data); 5237 err = l2cap_information_req(conn, cmd, cmd_len, data);
5204 break; 5238 break;
5205 5239
5206 case L2CAP_INFO_RSP: 5240 case L2CAP_INFO_RSP:
5207 err = l2cap_information_rsp(conn, cmd, data); 5241 err = l2cap_information_rsp(conn, cmd, cmd_len, data);
5208 break; 5242 break;
5209 5243
5210 case L2CAP_CREATE_CHAN_REQ: 5244 case L2CAP_CREATE_CHAN_REQ:
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 35fef22703e9..f8ecbc70293d 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2700,7 +2700,7 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
2700 break; 2700 break;
2701 2701
2702 case DISCOV_TYPE_LE: 2702 case DISCOV_TYPE_LE:
2703 if (!lmp_host_le_capable(hdev)) { 2703 if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) {
2704 err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY, 2704 err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY,
2705 MGMT_STATUS_NOT_SUPPORTED); 2705 MGMT_STATUS_NOT_SUPPORTED);
2706 mgmt_pending_remove(cmd); 2706 mgmt_pending_remove(cmd);
@@ -3418,6 +3418,27 @@ new_settings:
3418 return err; 3418 return err;
3419} 3419}
3420 3420
3421int mgmt_set_powered_failed(struct hci_dev *hdev, int err)
3422{
3423 struct pending_cmd *cmd;
3424 u8 status;
3425
3426 cmd = mgmt_pending_find(MGMT_OP_SET_POWERED, hdev);
3427 if (!cmd)
3428 return -ENOENT;
3429
3430 if (err == -ERFKILL)
3431 status = MGMT_STATUS_RFKILLED;
3432 else
3433 status = MGMT_STATUS_FAILED;
3434
3435 err = cmd_status(cmd->sk, hdev->id, MGMT_OP_SET_POWERED, status);
3436
3437 mgmt_pending_remove(cmd);
3438
3439 return err;
3440}
3441
3421int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable) 3442int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable)
3422{ 3443{
3423 struct cmd_lookup match = { NULL, hdev }; 3444 struct cmd_lookup match = { NULL, hdev };
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index b2296d3857a0..b5562abdd6e0 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -770,7 +770,7 @@ int smp_conn_security(struct hci_conn *hcon, __u8 sec_level)
770 770
771 BT_DBG("conn %p hcon %p level 0x%2.2x", conn, hcon, sec_level); 771 BT_DBG("conn %p hcon %p level 0x%2.2x", conn, hcon, sec_level);
772 772
773 if (!lmp_host_le_capable(hcon->hdev)) 773 if (!test_bit(HCI_LE_ENABLED, &hcon->hdev->dev_flags))
774 return 1; 774 return 1;
775 775
776 if (sec_level == BT_SECURITY_LOW) 776 if (sec_level == BT_SECURITY_LOW)
@@ -851,7 +851,7 @@ int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb)
851 __u8 reason; 851 __u8 reason;
852 int err = 0; 852 int err = 0;
853 853
854 if (!lmp_host_le_capable(conn->hcon->hdev)) { 854 if (!test_bit(HCI_LE_ENABLED, &conn->hcon->hdev->dev_flags)) {
855 err = -ENOTSUPP; 855 err = -ENOTSUPP;
856 reason = SMP_PAIRING_NOTSUPP; 856 reason = SMP_PAIRING_NOTSUPP;
857 goto done; 857 goto done;
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index d5953b87918c..3a246a6cab47 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -1675,13 +1675,13 @@ static void kick_requests(struct ceph_osd_client *osdc, int force_resend)
1675 __register_request(osdc, req); 1675 __register_request(osdc, req);
1676 __unregister_linger_request(osdc, req); 1676 __unregister_linger_request(osdc, req);
1677 } 1677 }
1678 reset_changed_osds(osdc);
1678 mutex_unlock(&osdc->request_mutex); 1679 mutex_unlock(&osdc->request_mutex);
1679 1680
1680 if (needmap) { 1681 if (needmap) {
1681 dout("%d requests for down osds, need new map\n", needmap); 1682 dout("%d requests for down osds, need new map\n", needmap);
1682 ceph_monc_request_next_osdmap(&osdc->client->monc); 1683 ceph_monc_request_next_osdmap(&osdc->client->monc);
1683 } 1684 }
1684 reset_changed_osds(osdc);
1685} 1685}
1686 1686
1687 1687
diff --git a/net/core/filter.c b/net/core/filter.c
index dad2a178f9f8..6438f29ff266 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -778,7 +778,7 @@ int sk_detach_filter(struct sock *sk)
778} 778}
779EXPORT_SYMBOL_GPL(sk_detach_filter); 779EXPORT_SYMBOL_GPL(sk_detach_filter);
780 780
781static void sk_decode_filter(struct sock_filter *filt, struct sock_filter *to) 781void sk_decode_filter(struct sock_filter *filt, struct sock_filter *to)
782{ 782{
783 static const u16 decodes[] = { 783 static const u16 decodes[] = {
784 [BPF_S_ALU_ADD_K] = BPF_ALU|BPF_ADD|BPF_K, 784 [BPF_S_ALU_ADD_K] = BPF_ALU|BPF_ADD|BPF_K,
diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
index d5bef0b0f639..a0e9cf6379de 100644
--- a/net/core/sock_diag.c
+++ b/net/core/sock_diag.c
@@ -73,8 +73,13 @@ int sock_diag_put_filterinfo(struct user_namespace *user_ns, struct sock *sk,
73 goto out; 73 goto out;
74 } 74 }
75 75
76 if (filter) 76 if (filter) {
77 memcpy(nla_data(attr), filter->insns, len); 77 struct sock_filter *fb = (struct sock_filter *)nla_data(attr);
78 int i;
79
80 for (i = 0; i < filter->len; i++, fb++)
81 sk_decode_filter(&filter->insns[i], fb);
82 }
78 83
79out: 84out:
80 rcu_read_unlock(); 85 rcu_read_unlock();
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index be2f8da0ae8e..7fa8f08fa7ae 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -853,7 +853,7 @@ void ip_tunnel_dellink(struct net_device *dev, struct list_head *head)
853} 853}
854EXPORT_SYMBOL_GPL(ip_tunnel_dellink); 854EXPORT_SYMBOL_GPL(ip_tunnel_dellink);
855 855
856int __net_init ip_tunnel_init_net(struct net *net, int ip_tnl_net_id, 856int ip_tunnel_init_net(struct net *net, int ip_tnl_net_id,
857 struct rtnl_link_ops *ops, char *devname) 857 struct rtnl_link_ops *ops, char *devname)
858{ 858{
859 struct ip_tunnel_net *itn = net_generic(net, ip_tnl_net_id); 859 struct ip_tunnel_net *itn = net_generic(net, ip_tnl_net_id);
@@ -899,7 +899,7 @@ static void ip_tunnel_destroy(struct ip_tunnel_net *itn, struct list_head *head)
899 unregister_netdevice_queue(itn->fb_tunnel_dev, head); 899 unregister_netdevice_queue(itn->fb_tunnel_dev, head);
900} 900}
901 901
902void __net_exit ip_tunnel_delete_net(struct ip_tunnel_net *itn) 902void ip_tunnel_delete_net(struct ip_tunnel_net *itn)
903{ 903{
904 LIST_HEAD(list); 904 LIST_HEAD(list);
905 905
diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
index 9d2bdb2c1d3f..c118f6b576bb 100644
--- a/net/ipv4/ip_vti.c
+++ b/net/ipv4/ip_vti.c
@@ -361,8 +361,7 @@ static netdev_tx_t vti_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
361 tunnel->err_count = 0; 361 tunnel->err_count = 0;
362 } 362 }
363 363
364 IPCB(skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED | 364 memset(IPCB(skb), 0, sizeof(*IPCB(skb)));
365 IPSKB_REROUTED);
366 skb_dst_drop(skb); 365 skb_dst_drop(skb);
367 skb_dst_set(skb, &rt->dst); 366 skb_dst_set(skb, &rt->dst);
368 nf_reset(skb); 367 nf_reset(skb);
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index 637a341c1e2d..8dec6876dc50 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -346,19 +346,19 @@ static int pppol2tp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msgh
346 skb_put(skb, 2); 346 skb_put(skb, 2);
347 347
348 /* Copy user data into skb */ 348 /* Copy user data into skb */
349 error = memcpy_fromiovec(skb->data, m->msg_iov, total_len); 349 error = memcpy_fromiovec(skb_put(skb, total_len), m->msg_iov,
350 total_len);
350 if (error < 0) { 351 if (error < 0) {
351 kfree_skb(skb); 352 kfree_skb(skb);
352 goto error_put_sess_tun; 353 goto error_put_sess_tun;
353 } 354 }
354 skb_put(skb, total_len);
355 355
356 l2tp_xmit_skb(session, skb, session->hdr_len); 356 l2tp_xmit_skb(session, skb, session->hdr_len);
357 357
358 sock_put(ps->tunnel_sock); 358 sock_put(ps->tunnel_sock);
359 sock_put(sk); 359 sock_put(sk);
360 360
361 return error; 361 return total_len;
362 362
363error_put_sess_tun: 363error_put_sess_tun:
364 sock_put(ps->tunnel_sock); 364 sock_put(ps->tunnel_sock);
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index 5b142fb16480..9e6c2a075a4c 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -2542,6 +2542,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
2542 struct ip_vs_dest *dest; 2542 struct ip_vs_dest *dest;
2543 struct ip_vs_dest_entry entry; 2543 struct ip_vs_dest_entry entry;
2544 2544
2545 memset(&entry, 0, sizeof(entry));
2545 list_for_each_entry(dest, &svc->destinations, n_list) { 2546 list_for_each_entry(dest, &svc->destinations, n_list) {
2546 if (count >= get->num_dests) 2547 if (count >= get->num_dests)
2547 break; 2548 break;
diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c
index dc3fd5d44464..c7b6d466a662 100644
--- a/net/netfilter/nfnetlink_acct.c
+++ b/net/netfilter/nfnetlink_acct.c
@@ -149,9 +149,12 @@ nfnl_acct_dump(struct sk_buff *skb, struct netlink_callback *cb)
149 149
150 rcu_read_lock(); 150 rcu_read_lock();
151 list_for_each_entry_rcu(cur, &nfnl_acct_list, head) { 151 list_for_each_entry_rcu(cur, &nfnl_acct_list, head) {
152 if (last && cur != last) 152 if (last) {
153 continue; 153 if (cur != last)
154 continue;
154 155
156 last = NULL;
157 }
155 if (nfnl_acct_fill_info(skb, NETLINK_CB(cb->skb).portid, 158 if (nfnl_acct_fill_info(skb, NETLINK_CB(cb->skb).portid,
156 cb->nlh->nlmsg_seq, 159 cb->nlh->nlmsg_seq,
157 NFNL_MSG_TYPE(cb->nlh->nlmsg_type), 160 NFNL_MSG_TYPE(cb->nlh->nlmsg_type),
diff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c
index 701c88a20fea..65074dfb9383 100644
--- a/net/netfilter/nfnetlink_cttimeout.c
+++ b/net/netfilter/nfnetlink_cttimeout.c
@@ -220,9 +220,12 @@ ctnl_timeout_dump(struct sk_buff *skb, struct netlink_callback *cb)
220 220
221 rcu_read_lock(); 221 rcu_read_lock();
222 list_for_each_entry_rcu(cur, &cttimeout_list, head) { 222 list_for_each_entry_rcu(cur, &cttimeout_list, head) {
223 if (last && cur != last) 223 if (last) {
224 continue; 224 if (cur != last)
225 continue;
225 226
227 last = NULL;
228 }
226 if (ctnl_timeout_fill_info(skb, NETLINK_CB(cb->skb).portid, 229 if (ctnl_timeout_fill_info(skb, NETLINK_CB(cb->skb).portid,
227 cb->nlh->nlmsg_seq, 230 cb->nlh->nlmsg_seq,
228 NFNL_MSG_TYPE(cb->nlh->nlmsg_type), 231 NFNL_MSG_TYPE(cb->nlh->nlmsg_type),
diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c
index 4e27fa035814..5352b2d2d5bf 100644
--- a/net/netfilter/nfnetlink_queue_core.c
+++ b/net/netfilter/nfnetlink_queue_core.c
@@ -637,9 +637,6 @@ nfqnl_enqueue_packet(struct nf_queue_entry *entry, unsigned int queuenum)
637 if (queue->copy_mode == NFQNL_COPY_NONE) 637 if (queue->copy_mode == NFQNL_COPY_NONE)
638 return -EINVAL; 638 return -EINVAL;
639 639
640 if ((queue->flags & NFQA_CFG_F_GSO) || !skb_is_gso(entry->skb))
641 return __nfqnl_enqueue_packet(net, queue, entry);
642
643 skb = entry->skb; 640 skb = entry->skb;
644 641
645 switch (entry->pf) { 642 switch (entry->pf) {
@@ -651,6 +648,9 @@ nfqnl_enqueue_packet(struct nf_queue_entry *entry, unsigned int queuenum)
651 break; 648 break;
652 } 649 }
653 650
651 if ((queue->flags & NFQA_CFG_F_GSO) || !skb_is_gso(skb))
652 return __nfqnl_enqueue_packet(net, queue, entry);
653
654 nf_bridge_adjust_skb_data(skb); 654 nf_bridge_adjust_skb_data(skb);
655 segs = skb_gso_segment(skb, 0); 655 segs = skb_gso_segment(skb, 0);
656 /* Does not use PTR_ERR to limit the number of error codes that can be 656 /* Does not use PTR_ERR to limit the number of error codes that can be
diff --git a/net/netfilter/xt_TCPMSS.c b/net/netfilter/xt_TCPMSS.c
index a75240f0d42b..afaebc766933 100644
--- a/net/netfilter/xt_TCPMSS.c
+++ b/net/netfilter/xt_TCPMSS.c
@@ -125,6 +125,12 @@ tcpmss_mangle_packet(struct sk_buff *skb,
125 125
126 skb_put(skb, TCPOLEN_MSS); 126 skb_put(skb, TCPOLEN_MSS);
127 127
128 /* RFC 879 states that the default MSS is 536 without specific
129 * knowledge that the destination host is prepared to accept larger.
130 * Since no MSS was provided, we MUST NOT set a value > 536.
131 */
132 newmss = min(newmss, (u16)536);
133
128 opt = (u_int8_t *)tcph + sizeof(struct tcphdr); 134 opt = (u_int8_t *)tcph + sizeof(struct tcphdr);
129 memmove(opt + TCPOLEN_MSS, opt, tcplen - sizeof(struct tcphdr)); 135 memmove(opt + TCPOLEN_MSS, opt, tcplen - sizeof(struct tcphdr));
130 136
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index d0b3dd60d386..57ee84d21470 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -371,7 +371,7 @@ static int netlink_mmap(struct file *file, struct socket *sock,
371 err = 0; 371 err = 0;
372out: 372out:
373 mutex_unlock(&nlk->pg_vec_lock); 373 mutex_unlock(&nlk->pg_vec_lock);
374 return 0; 374 return err;
375} 375}
376 376
377static void netlink_frame_flush_dcache(const struct nl_mmap_hdr *hdr) 377static void netlink_frame_flush_dcache(const struct nl_mmap_hdr *hdr)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 8ec1bca7f859..20a1bd0e6549 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2851,12 +2851,11 @@ static int packet_getname_spkt(struct socket *sock, struct sockaddr *uaddr,
2851 return -EOPNOTSUPP; 2851 return -EOPNOTSUPP;
2852 2852
2853 uaddr->sa_family = AF_PACKET; 2853 uaddr->sa_family = AF_PACKET;
2854 memset(uaddr->sa_data, 0, sizeof(uaddr->sa_data));
2854 rcu_read_lock(); 2855 rcu_read_lock();
2855 dev = dev_get_by_index_rcu(sock_net(sk), pkt_sk(sk)->ifindex); 2856 dev = dev_get_by_index_rcu(sock_net(sk), pkt_sk(sk)->ifindex);
2856 if (dev) 2857 if (dev)
2857 strncpy(uaddr->sa_data, dev->name, 14); 2858 strlcpy(uaddr->sa_data, dev->name, sizeof(uaddr->sa_data));
2858 else
2859 memset(uaddr->sa_data, 0, 14);
2860 rcu_read_unlock(); 2859 rcu_read_unlock();
2861 *uaddr_len = sizeof(*uaddr); 2860 *uaddr_len = sizeof(*uaddr);
2862 2861
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 2b935e7cfe7b..281c1bded1f6 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -291,17 +291,18 @@ struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, struct nlattr *ta
291{ 291{
292 struct qdisc_rate_table *rtab; 292 struct qdisc_rate_table *rtab;
293 293
294 if (tab == NULL || r->rate == 0 || r->cell_log == 0 ||
295 nla_len(tab) != TC_RTAB_SIZE)
296 return NULL;
297
294 for (rtab = qdisc_rtab_list; rtab; rtab = rtab->next) { 298 for (rtab = qdisc_rtab_list; rtab; rtab = rtab->next) {
295 if (memcmp(&rtab->rate, r, sizeof(struct tc_ratespec)) == 0) { 299 if (!memcmp(&rtab->rate, r, sizeof(struct tc_ratespec)) &&
300 !memcmp(&rtab->data, nla_data(tab), 1024)) {
296 rtab->refcnt++; 301 rtab->refcnt++;
297 return rtab; 302 return rtab;
298 } 303 }
299 } 304 }
300 305
301 if (tab == NULL || r->rate == 0 || r->cell_log == 0 ||
302 nla_len(tab) != TC_RTAB_SIZE)
303 return NULL;
304
305 rtab = kmalloc(sizeof(*rtab), GFP_KERNEL); 306 rtab = kmalloc(sizeof(*rtab), GFP_KERNEL);
306 if (rtab) { 307 if (rtab) {
307 rtab->rate = *r; 308 rtab->rate = *r;
diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c
index 32a4625fef77..be35e2dbcc9a 100644
--- a/net/sctp/outqueue.c
+++ b/net/sctp/outqueue.c
@@ -206,6 +206,8 @@ static inline int sctp_cacc_skip(struct sctp_transport *primary,
206 */ 206 */
207void sctp_outq_init(struct sctp_association *asoc, struct sctp_outq *q) 207void sctp_outq_init(struct sctp_association *asoc, struct sctp_outq *q)
208{ 208{
209 memset(q, 0, sizeof(struct sctp_outq));
210
209 q->asoc = asoc; 211 q->asoc = asoc;
210 INIT_LIST_HEAD(&q->out_chunk_list); 212 INIT_LIST_HEAD(&q->out_chunk_list);
211 INIT_LIST_HEAD(&q->control_chunk_list); 213 INIT_LIST_HEAD(&q->control_chunk_list);
@@ -213,11 +215,7 @@ void sctp_outq_init(struct sctp_association *asoc, struct sctp_outq *q)
213 INIT_LIST_HEAD(&q->sacked); 215 INIT_LIST_HEAD(&q->sacked);
214 INIT_LIST_HEAD(&q->abandoned); 216 INIT_LIST_HEAD(&q->abandoned);
215 217
216 q->fast_rtx = 0;
217 q->outstanding_bytes = 0;
218 q->empty = 1; 218 q->empty = 1;
219 q->cork = 0;
220 q->out_qlen = 0;
221} 219}
222 220
223/* Free the outqueue structure and any related pending chunks. 221/* Free the outqueue structure and any related pending chunks.
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index f631c5ff4dbf..6abb1caf9836 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -4003,6 +4003,12 @@ SCTP_STATIC void sctp_destroy_sock(struct sock *sk)
4003 4003
4004 /* Release our hold on the endpoint. */ 4004 /* Release our hold on the endpoint. */
4005 sp = sctp_sk(sk); 4005 sp = sctp_sk(sk);
4006 /* This could happen during socket init, thus we bail out
4007 * early, since the rest of the below is not setup either.
4008 */
4009 if (sp->ep == NULL)
4010 return;
4011
4006 if (sp->do_auto_asconf) { 4012 if (sp->do_auto_asconf) {
4007 sp->do_auto_asconf = 0; 4013 sp->do_auto_asconf = 0;
4008 list_del(&sp->auto_asconf_list); 4014 list_del(&sp->auto_asconf_list);
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 8337663aa298..f97869f1f09b 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -149,7 +149,7 @@ cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
149 149
150ld_flags = $(LDFLAGS) $(ldflags-y) 150ld_flags = $(LDFLAGS) $(ldflags-y)
151 151
152dtc_cpp_flags = -Wp,-MD,$(depfile).pre -nostdinc \ 152dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \
153 -I$(srctree)/arch/$(SRCARCH)/boot/dts \ 153 -I$(srctree)/arch/$(SRCARCH)/boot/dts \
154 -I$(srctree)/arch/$(SRCARCH)/boot/dts/include \ 154 -I$(srctree)/arch/$(SRCARCH)/boot/dts/include \
155 -undef -D__DTS__ 155 -undef -D__DTS__
@@ -265,13 +265,13 @@ quiet_cmd_dtc = DTC $@
265cmd_dtc = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ 265cmd_dtc = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
266 $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 \ 266 $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 \
267 -i $(dir $<) $(DTC_FLAGS) \ 267 -i $(dir $<) $(DTC_FLAGS) \
268 -d $(depfile).dtc $(dtc-tmp) ; \ 268 -d $(depfile).dtc.tmp $(dtc-tmp) ; \
269 cat $(depfile).pre $(depfile).dtc > $(depfile) 269 cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
270 270
271$(obj)/%.dtb: $(src)/%.dts FORCE 271$(obj)/%.dtb: $(src)/%.dts FORCE
272 $(call if_changed_dep,dtc) 272 $(call if_changed_dep,dtc)
273 273
274dtc-tmp = $(subst $(comma),_,$(dot-target).dts) 274dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
275 275
276# Bzip2 276# Bzip2
277# --------------------------------------------------------------------------- 277# ---------------------------------------------------------------------------
diff --git a/scripts/dtc/dtc-lexer.l b/scripts/dtc/dtc-lexer.l
index 254d5af88956..3b41bfca636c 100644
--- a/scripts/dtc/dtc-lexer.l
+++ b/scripts/dtc/dtc-lexer.l
@@ -71,7 +71,7 @@ static int pop_input_file(void);
71 push_input_file(name); 71 push_input_file(name);
72 } 72 }
73 73
74<*>^"#"(line)?{WS}+[0-9]+{WS}+{STRING}({WS}+[0-9]+)? { 74<*>^"#"(line)?[ \t]+[0-9]+[ \t]+{STRING}([ \t]+[0-9]+)? {
75 char *line, *tmp, *fn; 75 char *line, *tmp, *fn;
76 /* skip text before line # */ 76 /* skip text before line # */
77 line = yytext; 77 line = yytext;
diff --git a/scripts/dtc/dtc-lexer.lex.c_shipped b/scripts/dtc/dtc-lexer.lex.c_shipped
index a6c5fcdfc032..2d30f41778b7 100644
--- a/scripts/dtc/dtc-lexer.lex.c_shipped
+++ b/scripts/dtc/dtc-lexer.lex.c_shipped
@@ -405,19 +405,19 @@ static yyconst flex_int16_t yy_accept[161] =
405static yyconst flex_int32_t yy_ec[256] = 405static yyconst flex_int32_t yy_ec[256] =
406 { 0, 406 { 0,
407 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 407 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
408 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 408 4, 4, 4, 1, 1, 1, 1, 1, 1, 1,
409 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 409 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
410 1, 2, 4, 5, 6, 1, 1, 7, 8, 1, 410 1, 2, 5, 6, 7, 1, 1, 8, 9, 1,
411 1, 9, 10, 10, 11, 10, 12, 13, 14, 15, 411 1, 10, 11, 11, 12, 11, 13, 14, 15, 16,
412 15, 15, 15, 15, 15, 15, 15, 16, 1, 17, 412 16, 16, 16, 16, 16, 16, 16, 17, 1, 18,
413 18, 19, 10, 10, 20, 20, 20, 20, 20, 20, 413 19, 20, 11, 11, 21, 21, 21, 21, 21, 21,
414 21, 21, 21, 21, 21, 22, 21, 21, 21, 21, 414 22, 22, 22, 22, 22, 23, 22, 22, 22, 22,
415 21, 21, 21, 21, 23, 21, 21, 24, 21, 21, 415 22, 22, 22, 22, 24, 22, 22, 25, 22, 22,
416 1, 25, 26, 1, 21, 1, 20, 27, 28, 29, 416 1, 26, 27, 1, 22, 1, 21, 28, 29, 30,
417 417
418 30, 20, 21, 21, 31, 21, 21, 32, 33, 34, 418 31, 21, 22, 22, 32, 22, 22, 33, 34, 35,
419 35, 36, 21, 37, 38, 39, 40, 41, 21, 24, 419 36, 37, 22, 38, 39, 40, 41, 42, 22, 25,
420 42, 21, 43, 44, 45, 1, 1, 1, 1, 1, 420 43, 22, 44, 45, 46, 1, 1, 1, 1, 1,
421 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 421 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
422 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 422 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
423 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 423 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -434,36 +434,36 @@ static yyconst flex_int32_t yy_ec[256] =
434 1, 1, 1, 1, 1 434 1, 1, 1, 1, 1
435 } ; 435 } ;
436 436
437static yyconst flex_int32_t yy_meta[46] = 437static yyconst flex_int32_t yy_meta[47] =
438 { 0, 438 { 0,
439 1, 1, 1, 1, 1, 2, 3, 1, 2, 2, 439 1, 1, 1, 1, 1, 1, 2, 3, 1, 2,
440 2, 4, 5, 5, 5, 6, 1, 1, 1, 7, 440 2, 2, 4, 5, 5, 5, 6, 1, 1, 1,
441 8, 8, 8, 8, 1, 1, 7, 7, 7, 7, 441 7, 8, 8, 8, 8, 1, 1, 7, 7, 7,
442 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 442 7, 8, 8, 8, 8, 8, 8, 8, 8, 8,
443 8, 8, 3, 1, 1 443 8, 8, 8, 3, 1, 1
444 } ; 444 } ;
445 445
446static yyconst flex_int16_t yy_base[175] = 446static yyconst flex_int16_t yy_base[175] =
447 { 0, 447 { 0,
448 0, 388, 381, 40, 41, 386, 71, 385, 34, 44, 448 0, 385, 378, 40, 41, 383, 72, 382, 34, 44,
449 390, 395, 60, 62, 371, 112, 111, 111, 111, 104, 449 388, 393, 61, 117, 368, 116, 115, 115, 115, 48,
450 370, 106, 371, 342, 124, 119, 0, 144, 395, 0, 450 367, 107, 368, 339, 127, 120, 0, 147, 393, 0,
451 123, 0, 159, 153, 165, 167, 395, 130, 395, 382, 451 127, 0, 133, 156, 168, 153, 393, 125, 393, 380,
452 395, 0, 372, 122, 395, 157, 374, 379, 350, 21, 452 393, 0, 369, 127, 393, 160, 371, 377, 347, 21,
453 346, 349, 395, 395, 395, 395, 395, 362, 395, 395, 453 343, 346, 393, 393, 393, 393, 393, 359, 393, 393,
454 181, 346, 342, 395, 359, 0, 191, 343, 190, 351, 454 183, 343, 339, 393, 356, 0, 183, 340, 187, 348,
455 350, 0, 0, 0, 173, 362, 177, 367, 357, 329, 455 347, 0, 0, 0, 178, 359, 195, 365, 354, 326,
456 335, 328, 337, 331, 206, 329, 334, 327, 395, 338, 456 332, 325, 334, 328, 204, 326, 331, 324, 393, 335,
457 170, 314, 346, 345, 318, 325, 343, 158, 316, 212, 457 150, 311, 343, 342, 315, 322, 340, 179, 313, 207,
458 458
459 322, 319, 320, 395, 340, 336, 308, 305, 314, 304, 459 319, 316, 317, 393, 337, 333, 305, 302, 311, 301,
460 295, 138, 208, 220, 395, 292, 305, 265, 264, 254, 460 310, 190, 338, 337, 393, 307, 322, 301, 305, 277,
461 201, 222, 285, 275, 273, 270, 236, 235, 225, 115, 461 208, 311, 307, 278, 271, 270, 248, 246, 213, 130,
462 395, 395, 252, 216, 216, 217, 214, 230, 209, 220, 462 393, 393, 263, 235, 207, 221, 218, 229, 213, 213,
463 213, 239, 211, 217, 216, 209, 229, 395, 240, 225, 463 206, 234, 218, 210, 208, 193, 219, 393, 223, 204,
464 206, 169, 395, 395, 116, 106, 99, 54, 395, 395, 464 176, 157, 393, 393, 120, 106, 97, 119, 393, 393,
465 254, 260, 268, 272, 276, 282, 289, 293, 301, 309, 465 245, 251, 259, 263, 267, 273, 280, 284, 292, 300,
466 313, 319, 327, 335 466 304, 310, 318, 326
467 } ; 467 } ;
468 468
469static yyconst flex_int16_t yy_def[175] = 469static yyconst flex_int16_t yy_def[175] =
@@ -489,108 +489,108 @@ static yyconst flex_int16_t yy_def[175] =
489 160, 160, 160, 160 489 160, 160, 160, 160
490 } ; 490 } ;
491 491
492static yyconst flex_int16_t yy_nxt[441] = 492static yyconst flex_int16_t yy_nxt[440] =
493 { 0, 493 { 0,
494 12, 13, 14, 15, 16, 12, 17, 18, 12, 12, 494 12, 13, 14, 13, 15, 16, 12, 17, 18, 12,
495 12, 19, 12, 12, 12, 12, 20, 21, 22, 23, 495 12, 12, 19, 12, 12, 12, 12, 20, 21, 22,
496 23, 23, 23, 23, 12, 12, 23, 23, 23, 23, 496 23, 23, 23, 23, 23, 12, 12, 23, 23, 23,
497 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 497 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
498 23, 23, 12, 24, 12, 25, 34, 35, 35, 25, 498 23, 23, 23, 12, 24, 12, 25, 34, 35, 35,
499 81, 26, 26, 27, 27, 27, 34, 35, 35, 82, 499 25, 81, 26, 26, 27, 27, 27, 34, 35, 35,
500 28, 36, 36, 36, 36, 159, 29, 28, 28, 28, 500 82, 28, 36, 36, 36, 53, 54, 29, 28, 28,
501 28, 12, 13, 14, 15, 16, 30, 17, 18, 30, 501 28, 28, 12, 13, 14, 13, 15, 16, 30, 17,
502 30, 30, 26, 30, 30, 30, 12, 20, 21, 22, 502 18, 30, 30, 30, 26, 30, 30, 30, 12, 20,
503 31, 31, 31, 31, 31, 32, 12, 31, 31, 31, 503 21, 22, 31, 31, 31, 31, 31, 32, 12, 31,
504 504
505 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 505 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
506 31, 31, 31, 12, 24, 12, 39, 41, 45, 47, 506 31, 31, 31, 31, 31, 12, 24, 12, 36, 36,
507 53, 54, 48, 56, 57, 61, 61, 47, 66, 45, 507 36, 39, 41, 45, 47, 56, 57, 48, 61, 47,
508 48, 66, 66, 66, 39, 46, 40, 49, 59, 50, 508 39, 159, 48, 66, 61, 45, 66, 66, 66, 158,
509 158, 51, 122, 52, 157, 49, 46, 50, 136, 63, 509 46, 40, 49, 59, 50, 157, 51, 49, 52, 50,
510 137, 52, 156, 43, 40, 62, 65, 65, 65, 59, 510 40, 63, 46, 52, 36, 36, 36, 156, 43, 62,
511 61, 61, 123, 65, 75, 69, 69, 69, 36, 36, 511 65, 65, 65, 59, 136, 68, 137, 65, 75, 69,
512 65, 65, 65, 65, 70, 71, 72, 69, 69, 69, 512 69, 69, 70, 71, 65, 65, 65, 65, 70, 71,
513 45, 46, 61, 61, 109, 77, 70, 71, 93, 110, 513 72, 69, 69, 69, 61, 46, 45, 155, 154, 66,
514 68, 70, 71, 85, 85, 85, 66, 46, 155, 66, 514 70, 71, 66, 66, 66, 122, 85, 85, 85, 59,
515 515
516 66, 66, 69, 69, 69, 122, 59, 100, 100, 61, 516 69, 69, 69, 46, 77, 100, 109, 93, 100, 70,
517 61, 70, 71, 100, 100, 148, 112, 154, 85, 85, 517 71, 110, 112, 122, 129, 123, 153, 85, 85, 85,
518 85, 61, 61, 129, 129, 123, 129, 129, 135, 135, 518 135, 135, 135, 148, 148, 160, 135, 135, 135, 152,
519 135, 142, 142, 148, 143, 149, 153, 135, 135, 135, 519 142, 142, 142, 123, 143, 142, 142, 142, 151, 143,
520 142, 142, 160, 143, 152, 151, 150, 146, 145, 144, 520 150, 146, 145, 149, 149, 38, 38, 38, 38, 38,
521 141, 140, 139, 149, 38, 38, 38, 38, 38, 38, 521 38, 38, 38, 42, 144, 141, 140, 42, 42, 44,
522 38, 38, 42, 138, 134, 133, 42, 42, 44, 44, 522 44, 44, 44, 44, 44, 44, 44, 58, 58, 58,
523 44, 44, 44, 44, 44, 44, 58, 58, 58, 58, 523 58, 64, 139, 64, 66, 138, 134, 66, 133, 66,
524 64, 132, 64, 66, 131, 130, 66, 160, 66, 66, 524 66, 67, 132, 131, 67, 67, 67, 67, 73, 130,
525 67, 128, 127, 67, 67, 67, 67, 73, 126, 73, 525 73, 73, 76, 76, 76, 76, 76, 76, 76, 76,
526 526
527 73, 76, 76, 76, 76, 76, 76, 76, 76, 78, 527 78, 78, 78, 78, 78, 78, 78, 78, 91, 160,
528 78, 78, 78, 78, 78, 78, 78, 91, 125, 91, 528 91, 92, 129, 92, 92, 128, 92, 92, 121, 121,
529 92, 124, 92, 92, 120, 92, 92, 121, 121, 121, 529 121, 121, 121, 121, 121, 121, 147, 147, 147, 147,
530 121, 121, 121, 121, 121, 147, 147, 147, 147, 147, 530 147, 147, 147, 147, 127, 126, 125, 124, 61, 61,
531 147, 147, 147, 119, 118, 117, 116, 115, 47, 114, 531 120, 119, 118, 117, 116, 115, 47, 114, 110, 113,
532 110, 113, 111, 108, 107, 106, 48, 105, 104, 89, 532 111, 108, 107, 106, 48, 105, 104, 89, 103, 102,
533 103, 102, 101, 99, 98, 97, 96, 95, 94, 79, 533 101, 99, 98, 97, 96, 95, 94, 79, 77, 90,
534 77, 90, 89, 88, 59, 87, 86, 59, 84, 83, 534 89, 88, 59, 87, 86, 59, 84, 83, 80, 79,
535 80, 79, 77, 74, 160, 60, 59, 55, 37, 160, 535 77, 74, 160, 60, 59, 55, 37, 160, 33, 25,
536 33, 25, 26, 25, 11, 160, 160, 160, 160, 160, 536 26, 25, 11, 160, 160, 160, 160, 160, 160, 160,
537 537
538 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 538 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
539 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 539 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
540 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 540 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
541 160, 160, 160, 160, 160, 160, 160, 160, 160, 160 541 160, 160, 160, 160, 160, 160, 160, 160, 160
542 } ; 542 } ;
543 543
544static yyconst flex_int16_t yy_chk[441] = 544static yyconst flex_int16_t yy_chk[440] =
545 { 0, 545 { 0,
546 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 546 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
547 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 547 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
548 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 548 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
549 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 549 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
550 1, 1, 1, 1, 1, 4, 9, 9, 9, 10, 550 1, 1, 1, 1, 1, 1, 4, 9, 9, 9,
551 50, 4, 5, 5, 5, 5, 10, 10, 10, 50, 551 10, 50, 4, 5, 5, 5, 5, 10, 10, 10,
552 5, 13, 13, 14, 14, 158, 5, 5, 5, 5, 552 50, 5, 13, 13, 13, 20, 20, 5, 5, 5,
553 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 553 5, 5, 7, 7, 7, 7, 7, 7, 7, 7,
554 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 554 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
555 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 555 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
556 556
557 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 557 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
558 7, 7, 7, 7, 7, 7, 16, 17, 18, 19, 558 7, 7, 7, 7, 7, 7, 7, 7, 14, 14,
559 20, 20, 19, 22, 22, 25, 25, 26, 31, 44, 559 14, 16, 17, 18, 19, 22, 22, 19, 25, 26,
560 26, 31, 31, 31, 38, 18, 16, 19, 31, 19, 560 38, 158, 26, 31, 33, 44, 31, 31, 31, 157,
561 157, 19, 112, 19, 156, 26, 44, 26, 130, 26, 561 18, 16, 19, 31, 19, 156, 19, 26, 19, 26,
562 130, 26, 155, 17, 38, 25, 28, 28, 28, 28, 562 38, 26, 44, 26, 36, 36, 36, 155, 17, 25,
563 33, 33, 112, 28, 46, 34, 34, 34, 36, 36, 563 28, 28, 28, 28, 130, 33, 130, 28, 46, 34,
564 28, 28, 28, 28, 34, 34, 34, 35, 35, 35, 564 34, 34, 91, 91, 28, 28, 28, 28, 34, 34,
565 75, 46, 61, 61, 98, 77, 35, 35, 77, 98, 565 34, 35, 35, 35, 61, 46, 75, 152, 151, 67,
566 33, 91, 91, 61, 61, 61, 67, 75, 152, 67, 566 35, 35, 67, 67, 67, 112, 61, 61, 61, 67,
567 567
568 67, 67, 69, 69, 69, 121, 67, 85, 85, 113, 568 69, 69, 69, 75, 77, 85, 98, 77, 100, 69,
569 113, 69, 69, 100, 100, 143, 100, 151, 85, 85, 569 69, 98, 100, 121, 129, 112, 150, 85, 85, 85,
570 85, 114, 114, 122, 122, 121, 129, 129, 135, 135, 570 135, 135, 135, 143, 147, 149, 129, 129, 129, 146,
571 135, 138, 138, 147, 138, 143, 150, 129, 129, 129, 571 138, 138, 138, 121, 138, 142, 142, 142, 145, 142,
572 142, 142, 149, 142, 146, 145, 144, 141, 140, 139, 572 144, 141, 140, 143, 147, 161, 161, 161, 161, 161,
573 137, 136, 134, 147, 161, 161, 161, 161, 161, 161, 573 161, 161, 161, 162, 139, 137, 136, 162, 162, 163,
574 161, 161, 162, 133, 128, 127, 162, 162, 163, 163, 574 163, 163, 163, 163, 163, 163, 163, 164, 164, 164,
575 163, 163, 163, 163, 163, 163, 164, 164, 164, 164, 575 164, 165, 134, 165, 166, 133, 128, 166, 127, 166,
576 165, 126, 165, 166, 125, 124, 166, 123, 166, 166, 576 166, 167, 126, 125, 167, 167, 167, 167, 168, 124,
577 167, 120, 119, 167, 167, 167, 167, 168, 118, 168, 577 168, 168, 169, 169, 169, 169, 169, 169, 169, 169,
578 578
579 168, 169, 169, 169, 169, 169, 169, 169, 169, 170, 579 170, 170, 170, 170, 170, 170, 170, 170, 171, 123,
580 170, 170, 170, 170, 170, 170, 170, 171, 117, 171, 580 171, 172, 122, 172, 172, 120, 172, 172, 173, 173,
581 172, 116, 172, 172, 111, 172, 172, 173, 173, 173, 581 173, 173, 173, 173, 173, 173, 174, 174, 174, 174,
582 173, 173, 173, 173, 173, 174, 174, 174, 174, 174, 582 174, 174, 174, 174, 119, 118, 117, 116, 114, 113,
583 174, 174, 174, 110, 109, 108, 107, 106, 105, 103, 583 111, 110, 109, 108, 107, 106, 105, 103, 102, 101,
584 102, 101, 99, 97, 96, 95, 94, 93, 92, 90, 584 99, 97, 96, 95, 94, 93, 92, 90, 88, 87,
585 88, 87, 86, 84, 83, 82, 81, 80, 79, 78, 585 86, 84, 83, 82, 81, 80, 79, 78, 76, 71,
586 76, 71, 70, 68, 65, 63, 62, 58, 52, 51, 586 70, 68, 65, 63, 62, 58, 52, 51, 49, 48,
587 49, 48, 47, 43, 40, 24, 23, 21, 15, 11, 587 47, 43, 40, 24, 23, 21, 15, 11, 8, 6,
588 8, 6, 3, 2, 160, 160, 160, 160, 160, 160, 588 3, 2, 160, 160, 160, 160, 160, 160, 160, 160,
589 589
590 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 590 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
591 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 591 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
592 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 592 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
593 160, 160, 160, 160, 160, 160, 160, 160, 160, 160 593 160, 160, 160, 160, 160, 160, 160, 160, 160
594 } ; 594 } ;
595 595
596static yy_state_type yy_last_accepting_state; 596static yy_state_type yy_last_accepting_state;
diff --git a/scripts/dtc/dtc-parser.tab.c_shipped b/scripts/dtc/dtc-parser.tab.c_shipped
index 4af55900a15b..ee1d8c3042fb 100644
--- a/scripts/dtc/dtc-parser.tab.c_shipped
+++ b/scripts/dtc/dtc-parser.tab.c_shipped
@@ -1,10 +1,8 @@
1/* A Bison parser, made by GNU Bison 2.5. */
1 2
2/* A Bison parser, made by GNU Bison 2.4.1. */ 3/* Bison implementation for Yacc-like parsers in C
3
4/* Skeleton implementation for Bison's Yacc-like parsers in C
5 4
6 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 5 Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
7 Free Software Foundation, Inc.
8 6
9 This program is free software: you can redistribute it and/or modify 7 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
@@ -46,7 +44,7 @@
46#define YYBISON 1 44#define YYBISON 1
47 45
48/* Bison version. */ 46/* Bison version. */
49#define YYBISON_VERSION "2.4.1" 47#define YYBISON_VERSION "2.5"
50 48
51/* Skeleton name. */ 49/* Skeleton name. */
52#define YYSKELETON_NAME "yacc.c" 50#define YYSKELETON_NAME "yacc.c"
@@ -67,7 +65,7 @@
67 65
68/* Copy the first part of user declarations. */ 66/* Copy the first part of user declarations. */
69 67
70/* Line 189 of yacc.c */ 68/* Line 268 of yacc.c */
71#line 21 "dtc-parser.y" 69#line 21 "dtc-parser.y"
72 70
73#include <stdio.h> 71#include <stdio.h>
@@ -88,8 +86,8 @@ static unsigned long long eval_literal(const char *s, int base, int bits);
88static unsigned char eval_char_literal(const char *s); 86static unsigned char eval_char_literal(const char *s);
89 87
90 88
91/* Line 189 of yacc.c */ 89/* Line 268 of yacc.c */
92#line 93 "dtc-parser.tab.c" 90#line 91 "dtc-parser.tab.c"
93 91
94/* Enabling traces. */ 92/* Enabling traces. */
95#ifndef YYDEBUG 93#ifndef YYDEBUG
@@ -147,7 +145,7 @@ static unsigned char eval_char_literal(const char *s);
147typedef union YYSTYPE 145typedef union YYSTYPE
148{ 146{
149 147
150/* Line 214 of yacc.c */ 148/* Line 293 of yacc.c */
151#line 40 "dtc-parser.y" 149#line 40 "dtc-parser.y"
152 150
153 char *propnodename; 151 char *propnodename;
@@ -171,8 +169,8 @@ typedef union YYSTYPE
171 169
172 170
173 171
174/* Line 214 of yacc.c */ 172/* Line 293 of yacc.c */
175#line 176 "dtc-parser.tab.c" 173#line 174 "dtc-parser.tab.c"
176} YYSTYPE; 174} YYSTYPE;
177# define YYSTYPE_IS_TRIVIAL 1 175# define YYSTYPE_IS_TRIVIAL 1
178# define yystype YYSTYPE /* obsolescent; will be withdrawn */ 176# define yystype YYSTYPE /* obsolescent; will be withdrawn */
@@ -183,8 +181,8 @@ typedef union YYSTYPE
183/* Copy the second part of user declarations. */ 181/* Copy the second part of user declarations. */
184 182
185 183
186/* Line 264 of yacc.c */ 184/* Line 343 of yacc.c */
187#line 188 "dtc-parser.tab.c" 185#line 186 "dtc-parser.tab.c"
188 186
189#ifdef short 187#ifdef short
190# undef short 188# undef short
@@ -234,7 +232,7 @@ typedef short int yytype_int16;
234#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) 232#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
235 233
236#ifndef YY_ 234#ifndef YY_
237# if YYENABLE_NLS 235# if defined YYENABLE_NLS && YYENABLE_NLS
238# if ENABLE_NLS 236# if ENABLE_NLS
239# include <libintl.h> /* INFRINGES ON USER NAME SPACE */ 237# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
240# define YY_(msgid) dgettext ("bison-runtime", msgid) 238# define YY_(msgid) dgettext ("bison-runtime", msgid)
@@ -287,11 +285,11 @@ YYID (yyi)
287# define alloca _alloca 285# define alloca _alloca
288# else 286# else
289# define YYSTACK_ALLOC alloca 287# define YYSTACK_ALLOC alloca
290# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ 288# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
291 || defined __cplusplus || defined _MSC_VER) 289 || defined __cplusplus || defined _MSC_VER)
292# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 290# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
293# ifndef _STDLIB_H 291# ifndef EXIT_SUCCESS
294# define _STDLIB_H 1 292# define EXIT_SUCCESS 0
295# endif 293# endif
296# endif 294# endif
297# endif 295# endif
@@ -314,24 +312,24 @@ YYID (yyi)
314# ifndef YYSTACK_ALLOC_MAXIMUM 312# ifndef YYSTACK_ALLOC_MAXIMUM
315# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM 313# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
316# endif 314# endif
317# if (defined __cplusplus && ! defined _STDLIB_H \ 315# if (defined __cplusplus && ! defined EXIT_SUCCESS \
318 && ! ((defined YYMALLOC || defined malloc) \ 316 && ! ((defined YYMALLOC || defined malloc) \
319 && (defined YYFREE || defined free))) 317 && (defined YYFREE || defined free)))
320# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 318# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
321# ifndef _STDLIB_H 319# ifndef EXIT_SUCCESS
322# define _STDLIB_H 1 320# define EXIT_SUCCESS 0
323# endif 321# endif
324# endif 322# endif
325# ifndef YYMALLOC 323# ifndef YYMALLOC
326# define YYMALLOC malloc 324# define YYMALLOC malloc
327# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ 325# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
328 || defined __cplusplus || defined _MSC_VER) 326 || defined __cplusplus || defined _MSC_VER)
329void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ 327void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
330# endif 328# endif
331# endif 329# endif
332# ifndef YYFREE 330# ifndef YYFREE
333# define YYFREE free 331# define YYFREE free
334# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ 332# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
335 || defined __cplusplus || defined _MSC_VER) 333 || defined __cplusplus || defined _MSC_VER)
336void free (void *); /* INFRINGES ON USER NAME SPACE */ 334void free (void *); /* INFRINGES ON USER NAME SPACE */
337# endif 335# endif
@@ -360,23 +358,7 @@ union yyalloc
360 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ 358 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
361 + YYSTACK_GAP_MAXIMUM) 359 + YYSTACK_GAP_MAXIMUM)
362 360
363/* Copy COUNT objects from FROM to TO. The source and destination do 361# define YYCOPY_NEEDED 1
364 not overlap. */
365# ifndef YYCOPY
366# if defined __GNUC__ && 1 < __GNUC__
367# define YYCOPY(To, From, Count) \
368 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
369# else
370# define YYCOPY(To, From, Count) \
371 do \
372 { \
373 YYSIZE_T yyi; \
374 for (yyi = 0; yyi < (Count); yyi++) \
375 (To)[yyi] = (From)[yyi]; \
376 } \
377 while (YYID (0))
378# endif
379# endif
380 362
381/* Relocate STACK from its old location to the new one. The 363/* Relocate STACK from its old location to the new one. The
382 local variables YYSIZE and YYSTACKSIZE give the old and new number of 364 local variables YYSIZE and YYSTACKSIZE give the old and new number of
@@ -396,6 +378,26 @@ union yyalloc
396 378
397#endif 379#endif
398 380
381#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
382/* Copy COUNT objects from FROM to TO. The source and destination do
383 not overlap. */
384# ifndef YYCOPY
385# if defined __GNUC__ && 1 < __GNUC__
386# define YYCOPY(To, From, Count) \
387 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
388# else
389# define YYCOPY(To, From, Count) \
390 do \
391 { \
392 YYSIZE_T yyi; \
393 for (yyi = 0; yyi < (Count); yyi++) \
394 (To)[yyi] = (From)[yyi]; \
395 } \
396 while (YYID (0))
397# endif
398# endif
399#endif /* !YYCOPY_NEEDED */
400
399/* YYFINAL -- State number of the termination state. */ 401/* YYFINAL -- State number of the termination state. */
400#define YYFINAL 4 402#define YYFINAL 4
401/* YYLAST -- Last index in YYTABLE. */ 403/* YYLAST -- Last index in YYTABLE. */
@@ -571,8 +573,8 @@ static const yytype_uint8 yyr2[] =
571 2, 0, 2, 2, 0, 2, 2, 2, 3, 2 573 2, 0, 2, 2, 0, 2, 2, 2, 3, 2
572}; 574};
573 575
574/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state 576/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
575 STATE-NUM when YYTABLE doesn't specify something else to do. Zero 577 Performed when YYTABLE doesn't specify something else to do. Zero
576 means the default is an error. */ 578 means the default is an error. */
577static const yytype_uint8 yydefact[] = 579static const yytype_uint8 yydefact[] =
578{ 580{
@@ -633,8 +635,7 @@ static const yytype_int8 yypgoto[] =
633 635
634/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If 636/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
635 positive, shift that token. If negative, reduce the rule which 637 positive, shift that token. If negative, reduce the rule which
636 number is the opposite. If zero, do what YYDEFACT says. 638 number is the opposite. If YYTABLE_NINF, syntax error. */
637 If YYTABLE_NINF, syntax error. */
638#define YYTABLE_NINF -1 639#define YYTABLE_NINF -1
639static const yytype_uint8 yytable[] = 640static const yytype_uint8 yytable[] =
640{ 641{
@@ -654,6 +655,12 @@ static const yytype_uint8 yytable[] =
654 137, 0, 73, 139 655 137, 0, 73, 139
655}; 656};
656 657
658#define yypact_value_is_default(yystate) \
659 ((yystate) == (-78))
660
661#define yytable_value_is_error(yytable_value) \
662 YYID (0)
663
657static const yytype_int16 yycheck[] = 664static const yytype_int16 yycheck[] =
658{ 665{
659 5, 38, 39, 17, 18, 19, 12, 12, 17, 18, 666 5, 38, 39, 17, 18, 19, 12, 12, 17, 18,
@@ -705,9 +712,18 @@ static const yytype_uint8 yystos[] =
705 712
706/* Like YYERROR except do call yyerror. This remains here temporarily 713/* Like YYERROR except do call yyerror. This remains here temporarily
707 to ease the transition to the new meaning of YYERROR, for GCC. 714 to ease the transition to the new meaning of YYERROR, for GCC.
708 Once GCC version 2 has supplanted version 1, this can go. */ 715 Once GCC version 2 has supplanted version 1, this can go. However,
716 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
717 in Bison 2.4.2's NEWS entry, where a plan to phase it out is
718 discussed. */
709 719
710#define YYFAIL goto yyerrlab 720#define YYFAIL goto yyerrlab
721#if defined YYFAIL
722 /* This is here to suppress warnings from the GCC cpp's
723 -Wunused-macros. Normally we don't worry about that warning, but
724 some users do, and we want to make it easy for users to remove
725 YYFAIL uses, which will produce warnings from Bison 2.5. */
726#endif
711 727
712#define YYRECOVERING() (!!yyerrstatus) 728#define YYRECOVERING() (!!yyerrstatus)
713 729
@@ -717,7 +733,6 @@ do \
717 { \ 733 { \
718 yychar = (Token); \ 734 yychar = (Token); \
719 yylval = (Value); \ 735 yylval = (Value); \
720 yytoken = YYTRANSLATE (yychar); \
721 YYPOPSTACK (1); \ 736 YYPOPSTACK (1); \
722 goto yybackup; \ 737 goto yybackup; \
723 } \ 738 } \
@@ -759,19 +774,10 @@ while (YYID (0))
759#endif 774#endif
760 775
761 776
762/* YY_LOCATION_PRINT -- Print the location on the stream. 777/* This macro is provided for backward compatibility. */
763 This macro was not mandated originally: define only if we know
764 we won't break user code: when these are the locations we know. */
765 778
766#ifndef YY_LOCATION_PRINT 779#ifndef YY_LOCATION_PRINT
767# if YYLTYPE_IS_TRIVIAL 780# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
768# define YY_LOCATION_PRINT(File, Loc) \
769 fprintf (File, "%d.%d-%d.%d", \
770 (Loc).first_line, (Loc).first_column, \
771 (Loc).last_line, (Loc).last_column)
772# else
773# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
774# endif
775#endif 781#endif
776 782
777 783
@@ -963,7 +969,6 @@ int yydebug;
963# define YYMAXDEPTH 10000 969# define YYMAXDEPTH 10000
964#endif 970#endif
965 971
966
967 972
968#if YYERROR_VERBOSE 973#if YYERROR_VERBOSE
969 974
@@ -1066,115 +1071,142 @@ yytnamerr (char *yyres, const char *yystr)
1066} 1071}
1067# endif 1072# endif
1068 1073
1069/* Copy into YYRESULT an error message about the unexpected token 1074/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1070 YYCHAR while in state YYSTATE. Return the number of bytes copied, 1075 about the unexpected token YYTOKEN for the state stack whose top is
1071 including the terminating null byte. If YYRESULT is null, do not 1076 YYSSP.
1072 copy anything; just return the number of bytes that would be
1073 copied. As a special case, return 0 if an ordinary "syntax error"
1074 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1075 size calculation. */
1076static YYSIZE_T
1077yysyntax_error (char *yyresult, int yystate, int yychar)
1078{
1079 int yyn = yypact[yystate];
1080 1077
1081 if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) 1078 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1082 return 0; 1079 not large enough to hold the message. In that case, also set
1083 else 1080 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1081 required number of bytes is too large to store. */
1082static int
1083yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1084 yytype_int16 *yyssp, int yytoken)
1085{
1086 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
1087 YYSIZE_T yysize = yysize0;
1088 YYSIZE_T yysize1;
1089 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1090 /* Internationalized format string. */
1091 const char *yyformat = 0;
1092 /* Arguments of yyformat. */
1093 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1094 /* Number of reported tokens (one for the "unexpected", one per
1095 "expected"). */
1096 int yycount = 0;
1097
1098 /* There are many possibilities here to consider:
1099 - Assume YYFAIL is not used. It's too flawed to consider. See
1100 <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1101 for details. YYERROR is fine as it does not invoke this
1102 function.
1103 - If this state is a consistent state with a default action, then
1104 the only way this function was invoked is if the default action
1105 is an error action. In that case, don't check for expected
1106 tokens because there are none.
1107 - The only way there can be no lookahead present (in yychar) is if
1108 this state is a consistent state with a default action. Thus,
1109 detecting the absence of a lookahead is sufficient to determine
1110 that there is no unexpected or expected token to report. In that
1111 case, just report a simple "syntax error".
1112 - Don't assume there isn't a lookahead just because this state is a
1113 consistent state with a default action. There might have been a
1114 previous inconsistent state, consistent state with a non-default
1115 action, or user semantic action that manipulated yychar.
1116 - Of course, the expected token list depends on states to have
1117 correct lookahead information, and it depends on the parser not
1118 to perform extra reductions after fetching a lookahead from the
1119 scanner and before detecting a syntax error. Thus, state merging
1120 (from LALR or IELR) and default reductions corrupt the expected
1121 token list. However, the list is correct for canonical LR with
1122 one exception: it will still contain any token that will not be
1123 accepted due to an error action in a later state.
1124 */
1125 if (yytoken != YYEMPTY)
1084 { 1126 {
1085 int yytype = YYTRANSLATE (yychar); 1127 int yyn = yypact[*yyssp];
1086 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); 1128 yyarg[yycount++] = yytname[yytoken];
1087 YYSIZE_T yysize = yysize0; 1129 if (!yypact_value_is_default (yyn))
1088 YYSIZE_T yysize1; 1130 {
1089 int yysize_overflow = 0; 1131 /* Start YYX at -YYN if negative to avoid negative indexes in
1090 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; 1132 YYCHECK. In other words, skip the first -YYN actions for
1091 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; 1133 this state because they are default actions. */
1092 int yyx; 1134 int yyxbegin = yyn < 0 ? -yyn : 0;
1093 1135 /* Stay within bounds of both yycheck and yytname. */
1094# if 0 1136 int yychecklim = YYLAST - yyn + 1;
1095 /* This is so xgettext sees the translatable formats that are 1137 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1096 constructed on the fly. */ 1138 int yyx;
1097 YY_("syntax error, unexpected %s"); 1139
1098 YY_("syntax error, unexpected %s, expecting %s"); 1140 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1099 YY_("syntax error, unexpected %s, expecting %s or %s"); 1141 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1100 YY_("syntax error, unexpected %s, expecting %s or %s or %s"); 1142 && !yytable_value_is_error (yytable[yyx + yyn]))
1101 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); 1143 {
1102# endif 1144 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1103 char *yyfmt; 1145 {
1104 char const *yyf; 1146 yycount = 1;
1105 static char const yyunexpected[] = "syntax error, unexpected %s"; 1147 yysize = yysize0;
1106 static char const yyexpecting[] = ", expecting %s"; 1148 break;
1107 static char const yyor[] = " or %s"; 1149 }
1108 char yyformat[sizeof yyunexpected 1150 yyarg[yycount++] = yytname[yyx];
1109 + sizeof yyexpecting - 1 1151 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1110 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) 1152 if (! (yysize <= yysize1
1111 * (sizeof yyor - 1))]; 1153 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1112 char const *yyprefix = yyexpecting; 1154 return 2;
1113 1155 yysize = yysize1;
1114 /* Start YYX at -YYN if negative to avoid negative indexes in 1156 }
1115 YYCHECK. */ 1157 }
1116 int yyxbegin = yyn < 0 ? -yyn : 0; 1158 }
1117
1118 /* Stay within bounds of both yycheck and yytname. */
1119 int yychecklim = YYLAST - yyn + 1;
1120 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1121 int yycount = 1;
1122
1123 yyarg[0] = yytname[yytype];
1124 yyfmt = yystpcpy (yyformat, yyunexpected);
1125
1126 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1127 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1128 {
1129 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1130 {
1131 yycount = 1;
1132 yysize = yysize0;
1133 yyformat[sizeof yyunexpected - 1] = '\0';
1134 break;
1135 }
1136 yyarg[yycount++] = yytname[yyx];
1137 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1138 yysize_overflow |= (yysize1 < yysize);
1139 yysize = yysize1;
1140 yyfmt = yystpcpy (yyfmt, yyprefix);
1141 yyprefix = yyor;
1142 }
1143 1159
1144 yyf = YY_(yyformat); 1160 switch (yycount)
1145 yysize1 = yysize + yystrlen (yyf); 1161 {
1146 yysize_overflow |= (yysize1 < yysize); 1162# define YYCASE_(N, S) \
1147 yysize = yysize1; 1163 case N: \
1164 yyformat = S; \
1165 break
1166 YYCASE_(0, YY_("syntax error"));
1167 YYCASE_(1, YY_("syntax error, unexpected %s"));
1168 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1169 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1170 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1171 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1172# undef YYCASE_
1173 }
1148 1174
1149 if (yysize_overflow) 1175 yysize1 = yysize + yystrlen (yyformat);
1150 return YYSIZE_MAXIMUM; 1176 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1177 return 2;
1178 yysize = yysize1;
1151 1179
1152 if (yyresult) 1180 if (*yymsg_alloc < yysize)
1153 { 1181 {
1154 /* Avoid sprintf, as that infringes on the user's name space. 1182 *yymsg_alloc = 2 * yysize;
1155 Don't have undefined behavior even if the translation 1183 if (! (yysize <= *yymsg_alloc
1156 produced a string with the wrong number of "%s"s. */ 1184 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1157 char *yyp = yyresult; 1185 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1158 int yyi = 0; 1186 return 1;
1159 while ((*yyp = *yyf) != '\0')
1160 {
1161 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1162 {
1163 yyp += yytnamerr (yyp, yyarg[yyi++]);
1164 yyf += 2;
1165 }
1166 else
1167 {
1168 yyp++;
1169 yyf++;
1170 }
1171 }
1172 }
1173 return yysize;
1174 } 1187 }
1188
1189 /* Avoid sprintf, as that infringes on the user's name space.
1190 Don't have undefined behavior even if the translation
1191 produced a string with the wrong number of "%s"s. */
1192 {
1193 char *yyp = *yymsg;
1194 int yyi = 0;
1195 while ((*yyp = *yyformat) != '\0')
1196 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1197 {
1198 yyp += yytnamerr (yyp, yyarg[yyi++]);
1199 yyformat += 2;
1200 }
1201 else
1202 {
1203 yyp++;
1204 yyformat++;
1205 }
1206 }
1207 return 0;
1175} 1208}
1176#endif /* YYERROR_VERBOSE */ 1209#endif /* YYERROR_VERBOSE */
1177
1178 1210
1179/*-----------------------------------------------. 1211/*-----------------------------------------------.
1180| Release the memory associated to this symbol. | 1212| Release the memory associated to this symbol. |
@@ -1207,6 +1239,7 @@ yydestruct (yymsg, yytype, yyvaluep)
1207 } 1239 }
1208} 1240}
1209 1241
1242
1210/* Prevent warnings from -Wmissing-prototypes. */ 1243/* Prevent warnings from -Wmissing-prototypes. */
1211#ifdef YYPARSE_PARAM 1244#ifdef YYPARSE_PARAM
1212#if defined __STDC__ || defined __cplusplus 1245#if defined __STDC__ || defined __cplusplus
@@ -1233,10 +1266,9 @@ YYSTYPE yylval;
1233int yynerrs; 1266int yynerrs;
1234 1267
1235 1268
1236 1269/*----------.
1237/*-------------------------. 1270| yyparse. |
1238| yyparse or yypush_parse. | 1271`----------*/
1239`-------------------------*/
1240 1272
1241#ifdef YYPARSE_PARAM 1273#ifdef YYPARSE_PARAM
1242#if (defined __STDC__ || defined __C99__FUNC__ \ 1274#if (defined __STDC__ || defined __C99__FUNC__ \
@@ -1260,8 +1292,6 @@ yyparse ()
1260#endif 1292#endif
1261#endif 1293#endif
1262{ 1294{
1263
1264
1265 int yystate; 1295 int yystate;
1266 /* Number of tokens to shift before error messages enabled. */ 1296 /* Number of tokens to shift before error messages enabled. */
1267 int yyerrstatus; 1297 int yyerrstatus;
@@ -1416,7 +1446,7 @@ yybackup:
1416 1446
1417 /* First try to decide what to do without reference to lookahead token. */ 1447 /* First try to decide what to do without reference to lookahead token. */
1418 yyn = yypact[yystate]; 1448 yyn = yypact[yystate];
1419 if (yyn == YYPACT_NINF) 1449 if (yypact_value_is_default (yyn))
1420 goto yydefault; 1450 goto yydefault;
1421 1451
1422 /* Not known => get a lookahead token if don't already have one. */ 1452 /* Not known => get a lookahead token if don't already have one. */
@@ -1447,8 +1477,8 @@ yybackup:
1447 yyn = yytable[yyn]; 1477 yyn = yytable[yyn];
1448 if (yyn <= 0) 1478 if (yyn <= 0)
1449 { 1479 {
1450 if (yyn == 0 || yyn == YYTABLE_NINF) 1480 if (yytable_value_is_error (yyn))
1451 goto yyerrlab; 1481 goto yyerrlab;
1452 yyn = -yyn; 1482 yyn = -yyn;
1453 goto yyreduce; 1483 goto yyreduce;
1454 } 1484 }
@@ -1503,72 +1533,72 @@ yyreduce:
1503 { 1533 {
1504 case 2: 1534 case 2:
1505 1535
1506/* Line 1455 of yacc.c */ 1536/* Line 1806 of yacc.c */
1507#line 110 "dtc-parser.y" 1537#line 110 "dtc-parser.y"
1508 { 1538 {
1509 the_boot_info = build_boot_info((yyvsp[(3) - (4)].re), (yyvsp[(4) - (4)].node), 1539 the_boot_info = build_boot_info((yyvsp[(3) - (4)].re), (yyvsp[(4) - (4)].node),
1510 guess_boot_cpuid((yyvsp[(4) - (4)].node))); 1540 guess_boot_cpuid((yyvsp[(4) - (4)].node)));
1511 ;} 1541 }
1512 break; 1542 break;
1513 1543
1514 case 3: 1544 case 3:
1515 1545
1516/* Line 1455 of yacc.c */ 1546/* Line 1806 of yacc.c */
1517#line 118 "dtc-parser.y" 1547#line 118 "dtc-parser.y"
1518 { 1548 {
1519 (yyval.re) = NULL; 1549 (yyval.re) = NULL;
1520 ;} 1550 }
1521 break; 1551 break;
1522 1552
1523 case 4: 1553 case 4:
1524 1554
1525/* Line 1455 of yacc.c */ 1555/* Line 1806 of yacc.c */
1526#line 122 "dtc-parser.y" 1556#line 122 "dtc-parser.y"
1527 { 1557 {
1528 (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re)); 1558 (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re));
1529 ;} 1559 }
1530 break; 1560 break;
1531 1561
1532 case 5: 1562 case 5:
1533 1563
1534/* Line 1455 of yacc.c */ 1564/* Line 1806 of yacc.c */
1535#line 129 "dtc-parser.y" 1565#line 129 "dtc-parser.y"
1536 { 1566 {
1537 (yyval.re) = build_reserve_entry((yyvsp[(2) - (4)].integer), (yyvsp[(3) - (4)].integer)); 1567 (yyval.re) = build_reserve_entry((yyvsp[(2) - (4)].integer), (yyvsp[(3) - (4)].integer));
1538 ;} 1568 }
1539 break; 1569 break;
1540 1570
1541 case 6: 1571 case 6:
1542 1572
1543/* Line 1455 of yacc.c */ 1573/* Line 1806 of yacc.c */
1544#line 133 "dtc-parser.y" 1574#line 133 "dtc-parser.y"
1545 { 1575 {
1546 add_label(&(yyvsp[(2) - (2)].re)->labels, (yyvsp[(1) - (2)].labelref)); 1576 add_label(&(yyvsp[(2) - (2)].re)->labels, (yyvsp[(1) - (2)].labelref));
1547 (yyval.re) = (yyvsp[(2) - (2)].re); 1577 (yyval.re) = (yyvsp[(2) - (2)].re);
1548 ;} 1578 }
1549 break; 1579 break;
1550 1580
1551 case 7: 1581 case 7:
1552 1582
1553/* Line 1455 of yacc.c */ 1583/* Line 1806 of yacc.c */
1554#line 141 "dtc-parser.y" 1584#line 141 "dtc-parser.y"
1555 { 1585 {
1556 (yyval.node) = name_node((yyvsp[(2) - (2)].node), ""); 1586 (yyval.node) = name_node((yyvsp[(2) - (2)].node), "");
1557 ;} 1587 }
1558 break; 1588 break;
1559 1589
1560 case 8: 1590 case 8:
1561 1591
1562/* Line 1455 of yacc.c */ 1592/* Line 1806 of yacc.c */
1563#line 145 "dtc-parser.y" 1593#line 145 "dtc-parser.y"
1564 { 1594 {
1565 (yyval.node) = merge_nodes((yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); 1595 (yyval.node) = merge_nodes((yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
1566 ;} 1596 }
1567 break; 1597 break;
1568 1598
1569 case 9: 1599 case 9:
1570 1600
1571/* Line 1455 of yacc.c */ 1601/* Line 1806 of yacc.c */
1572#line 149 "dtc-parser.y" 1602#line 149 "dtc-parser.y"
1573 { 1603 {
1574 struct node *target = get_node_by_ref((yyvsp[(1) - (3)].node), (yyvsp[(2) - (3)].labelref)); 1604 struct node *target = get_node_by_ref((yyvsp[(1) - (3)].node), (yyvsp[(2) - (3)].labelref));
@@ -1578,12 +1608,12 @@ yyreduce:
1578 else 1608 else
1579 print_error("label or path, '%s', not found", (yyvsp[(2) - (3)].labelref)); 1609 print_error("label or path, '%s', not found", (yyvsp[(2) - (3)].labelref));
1580 (yyval.node) = (yyvsp[(1) - (3)].node); 1610 (yyval.node) = (yyvsp[(1) - (3)].node);
1581 ;} 1611 }
1582 break; 1612 break;
1583 1613
1584 case 10: 1614 case 10:
1585 1615
1586/* Line 1455 of yacc.c */ 1616/* Line 1806 of yacc.c */
1587#line 159 "dtc-parser.y" 1617#line 159 "dtc-parser.y"
1588 { 1618 {
1589 struct node *target = get_node_by_ref((yyvsp[(1) - (4)].node), (yyvsp[(3) - (4)].labelref)); 1619 struct node *target = get_node_by_ref((yyvsp[(1) - (4)].node), (yyvsp[(3) - (4)].labelref));
@@ -1594,112 +1624,112 @@ yyreduce:
1594 delete_node(target); 1624 delete_node(target);
1595 1625
1596 (yyval.node) = (yyvsp[(1) - (4)].node); 1626 (yyval.node) = (yyvsp[(1) - (4)].node);
1597 ;} 1627 }
1598 break; 1628 break;
1599 1629
1600 case 11: 1630 case 11:
1601 1631
1602/* Line 1455 of yacc.c */ 1632/* Line 1806 of yacc.c */
1603#line 173 "dtc-parser.y" 1633#line 173 "dtc-parser.y"
1604 { 1634 {
1605 (yyval.node) = build_node((yyvsp[(2) - (5)].proplist), (yyvsp[(3) - (5)].nodelist)); 1635 (yyval.node) = build_node((yyvsp[(2) - (5)].proplist), (yyvsp[(3) - (5)].nodelist));
1606 ;} 1636 }
1607 break; 1637 break;
1608 1638
1609 case 12: 1639 case 12:
1610 1640
1611/* Line 1455 of yacc.c */ 1641/* Line 1806 of yacc.c */
1612#line 180 "dtc-parser.y" 1642#line 180 "dtc-parser.y"
1613 { 1643 {
1614 (yyval.proplist) = NULL; 1644 (yyval.proplist) = NULL;
1615 ;} 1645 }
1616 break; 1646 break;
1617 1647
1618 case 13: 1648 case 13:
1619 1649
1620/* Line 1455 of yacc.c */ 1650/* Line 1806 of yacc.c */
1621#line 184 "dtc-parser.y" 1651#line 184 "dtc-parser.y"
1622 { 1652 {
1623 (yyval.proplist) = chain_property((yyvsp[(2) - (2)].prop), (yyvsp[(1) - (2)].proplist)); 1653 (yyval.proplist) = chain_property((yyvsp[(2) - (2)].prop), (yyvsp[(1) - (2)].proplist));
1624 ;} 1654 }
1625 break; 1655 break;
1626 1656
1627 case 14: 1657 case 14:
1628 1658
1629/* Line 1455 of yacc.c */ 1659/* Line 1806 of yacc.c */
1630#line 191 "dtc-parser.y" 1660#line 191 "dtc-parser.y"
1631 { 1661 {
1632 (yyval.prop) = build_property((yyvsp[(1) - (4)].propnodename), (yyvsp[(3) - (4)].data)); 1662 (yyval.prop) = build_property((yyvsp[(1) - (4)].propnodename), (yyvsp[(3) - (4)].data));
1633 ;} 1663 }
1634 break; 1664 break;
1635 1665
1636 case 15: 1666 case 15:
1637 1667
1638/* Line 1455 of yacc.c */ 1668/* Line 1806 of yacc.c */
1639#line 195 "dtc-parser.y" 1669#line 195 "dtc-parser.y"
1640 { 1670 {
1641 (yyval.prop) = build_property((yyvsp[(1) - (2)].propnodename), empty_data); 1671 (yyval.prop) = build_property((yyvsp[(1) - (2)].propnodename), empty_data);
1642 ;} 1672 }
1643 break; 1673 break;
1644 1674
1645 case 16: 1675 case 16:
1646 1676
1647/* Line 1455 of yacc.c */ 1677/* Line 1806 of yacc.c */
1648#line 199 "dtc-parser.y" 1678#line 199 "dtc-parser.y"
1649 { 1679 {
1650 (yyval.prop) = build_property_delete((yyvsp[(2) - (3)].propnodename)); 1680 (yyval.prop) = build_property_delete((yyvsp[(2) - (3)].propnodename));
1651 ;} 1681 }
1652 break; 1682 break;
1653 1683
1654 case 17: 1684 case 17:
1655 1685
1656/* Line 1455 of yacc.c */ 1686/* Line 1806 of yacc.c */
1657#line 203 "dtc-parser.y" 1687#line 203 "dtc-parser.y"
1658 { 1688 {
1659 add_label(&(yyvsp[(2) - (2)].prop)->labels, (yyvsp[(1) - (2)].labelref)); 1689 add_label(&(yyvsp[(2) - (2)].prop)->labels, (yyvsp[(1) - (2)].labelref));
1660 (yyval.prop) = (yyvsp[(2) - (2)].prop); 1690 (yyval.prop) = (yyvsp[(2) - (2)].prop);
1661 ;} 1691 }
1662 break; 1692 break;
1663 1693
1664 case 18: 1694 case 18:
1665 1695
1666/* Line 1455 of yacc.c */ 1696/* Line 1806 of yacc.c */
1667#line 211 "dtc-parser.y" 1697#line 211 "dtc-parser.y"
1668 { 1698 {
1669 (yyval.data) = data_merge((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].data)); 1699 (yyval.data) = data_merge((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].data));
1670 ;} 1700 }
1671 break; 1701 break;
1672 1702
1673 case 19: 1703 case 19:
1674 1704
1675/* Line 1455 of yacc.c */ 1705/* Line 1806 of yacc.c */
1676#line 215 "dtc-parser.y" 1706#line 215 "dtc-parser.y"
1677 { 1707 {
1678 (yyval.data) = data_merge((yyvsp[(1) - (3)].data), (yyvsp[(2) - (3)].array).data); 1708 (yyval.data) = data_merge((yyvsp[(1) - (3)].data), (yyvsp[(2) - (3)].array).data);
1679 ;} 1709 }
1680 break; 1710 break;
1681 1711
1682 case 20: 1712 case 20:
1683 1713
1684/* Line 1455 of yacc.c */ 1714/* Line 1806 of yacc.c */
1685#line 219 "dtc-parser.y" 1715#line 219 "dtc-parser.y"
1686 { 1716 {
1687 (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data)); 1717 (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data));
1688 ;} 1718 }
1689 break; 1719 break;
1690 1720
1691 case 21: 1721 case 21:
1692 1722
1693/* Line 1455 of yacc.c */ 1723/* Line 1806 of yacc.c */
1694#line 223 "dtc-parser.y" 1724#line 223 "dtc-parser.y"
1695 { 1725 {
1696 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), REF_PATH, (yyvsp[(2) - (2)].labelref)); 1726 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), REF_PATH, (yyvsp[(2) - (2)].labelref));
1697 ;} 1727 }
1698 break; 1728 break;
1699 1729
1700 case 22: 1730 case 22:
1701 1731
1702/* Line 1455 of yacc.c */ 1732/* Line 1806 of yacc.c */
1703#line 227 "dtc-parser.y" 1733#line 227 "dtc-parser.y"
1704 { 1734 {
1705 FILE *f = srcfile_relative_open((yyvsp[(4) - (9)].data).val, NULL); 1735 FILE *f = srcfile_relative_open((yyvsp[(4) - (9)].data).val, NULL);
@@ -1716,12 +1746,12 @@ yyreduce:
1716 1746
1717 (yyval.data) = data_merge((yyvsp[(1) - (9)].data), d); 1747 (yyval.data) = data_merge((yyvsp[(1) - (9)].data), d);
1718 fclose(f); 1748 fclose(f);
1719 ;} 1749 }
1720 break; 1750 break;
1721 1751
1722 case 23: 1752 case 23:
1723 1753
1724/* Line 1455 of yacc.c */ 1754/* Line 1806 of yacc.c */
1725#line 244 "dtc-parser.y" 1755#line 244 "dtc-parser.y"
1726 { 1756 {
1727 FILE *f = srcfile_relative_open((yyvsp[(4) - (5)].data).val, NULL); 1757 FILE *f = srcfile_relative_open((yyvsp[(4) - (5)].data).val, NULL);
@@ -1731,48 +1761,48 @@ yyreduce:
1731 1761
1732 (yyval.data) = data_merge((yyvsp[(1) - (5)].data), d); 1762 (yyval.data) = data_merge((yyvsp[(1) - (5)].data), d);
1733 fclose(f); 1763 fclose(f);
1734 ;} 1764 }
1735 break; 1765 break;
1736 1766
1737 case 24: 1767 case 24:
1738 1768
1739/* Line 1455 of yacc.c */ 1769/* Line 1806 of yacc.c */
1740#line 254 "dtc-parser.y" 1770#line 254 "dtc-parser.y"
1741 { 1771 {
1742 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); 1772 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
1743 ;} 1773 }
1744 break; 1774 break;
1745 1775
1746 case 25: 1776 case 25:
1747 1777
1748/* Line 1455 of yacc.c */ 1778/* Line 1806 of yacc.c */
1749#line 261 "dtc-parser.y" 1779#line 261 "dtc-parser.y"
1750 { 1780 {
1751 (yyval.data) = empty_data; 1781 (yyval.data) = empty_data;
1752 ;} 1782 }
1753 break; 1783 break;
1754 1784
1755 case 26: 1785 case 26:
1756 1786
1757/* Line 1455 of yacc.c */ 1787/* Line 1806 of yacc.c */
1758#line 265 "dtc-parser.y" 1788#line 265 "dtc-parser.y"
1759 { 1789 {
1760 (yyval.data) = (yyvsp[(1) - (2)].data); 1790 (yyval.data) = (yyvsp[(1) - (2)].data);
1761 ;} 1791 }
1762 break; 1792 break;
1763 1793
1764 case 27: 1794 case 27:
1765 1795
1766/* Line 1455 of yacc.c */ 1796/* Line 1806 of yacc.c */
1767#line 269 "dtc-parser.y" 1797#line 269 "dtc-parser.y"
1768 { 1798 {
1769 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); 1799 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
1770 ;} 1800 }
1771 break; 1801 break;
1772 1802
1773 case 28: 1803 case 28:
1774 1804
1775/* Line 1455 of yacc.c */ 1805/* Line 1806 of yacc.c */
1776#line 276 "dtc-parser.y" 1806#line 276 "dtc-parser.y"
1777 { 1807 {
1778 (yyval.array).data = empty_data; 1808 (yyval.array).data = empty_data;
@@ -1787,22 +1817,22 @@ yyreduce:
1787 " are currently supported"); 1817 " are currently supported");
1788 (yyval.array).bits = 32; 1818 (yyval.array).bits = 32;
1789 } 1819 }
1790 ;} 1820 }
1791 break; 1821 break;
1792 1822
1793 case 29: 1823 case 29:
1794 1824
1795/* Line 1455 of yacc.c */ 1825/* Line 1806 of yacc.c */
1796#line 291 "dtc-parser.y" 1826#line 291 "dtc-parser.y"
1797 { 1827 {
1798 (yyval.array).data = empty_data; 1828 (yyval.array).data = empty_data;
1799 (yyval.array).bits = 32; 1829 (yyval.array).bits = 32;
1800 ;} 1830 }
1801 break; 1831 break;
1802 1832
1803 case 30: 1833 case 30:
1804 1834
1805/* Line 1455 of yacc.c */ 1835/* Line 1806 of yacc.c */
1806#line 296 "dtc-parser.y" 1836#line 296 "dtc-parser.y"
1807 { 1837 {
1808 if ((yyvsp[(1) - (2)].array).bits < 64) { 1838 if ((yyvsp[(1) - (2)].array).bits < 64) {
@@ -1822,12 +1852,12 @@ yyreduce:
1822 } 1852 }
1823 1853
1824 (yyval.array).data = data_append_integer((yyvsp[(1) - (2)].array).data, (yyvsp[(2) - (2)].integer), (yyvsp[(1) - (2)].array).bits); 1854 (yyval.array).data = data_append_integer((yyvsp[(1) - (2)].array).data, (yyvsp[(2) - (2)].integer), (yyvsp[(1) - (2)].array).bits);
1825 ;} 1855 }
1826 break; 1856 break;
1827 1857
1828 case 31: 1858 case 31:
1829 1859
1830/* Line 1455 of yacc.c */ 1860/* Line 1806 of yacc.c */
1831#line 316 "dtc-parser.y" 1861#line 316 "dtc-parser.y"
1832 { 1862 {
1833 uint64_t val = ~0ULL >> (64 - (yyvsp[(1) - (2)].array).bits); 1863 uint64_t val = ~0ULL >> (64 - (yyvsp[(1) - (2)].array).bits);
@@ -1841,288 +1871,299 @@ yyreduce:
1841 "arrays with 32-bit elements."); 1871 "arrays with 32-bit elements.");
1842 1872
1843 (yyval.array).data = data_append_integer((yyvsp[(1) - (2)].array).data, val, (yyvsp[(1) - (2)].array).bits); 1873 (yyval.array).data = data_append_integer((yyvsp[(1) - (2)].array).data, val, (yyvsp[(1) - (2)].array).bits);
1844 ;} 1874 }
1845 break; 1875 break;
1846 1876
1847 case 32: 1877 case 32:
1848 1878
1849/* Line 1455 of yacc.c */ 1879/* Line 1806 of yacc.c */
1850#line 330 "dtc-parser.y" 1880#line 330 "dtc-parser.y"
1851 { 1881 {
1852 (yyval.array).data = data_add_marker((yyvsp[(1) - (2)].array).data, LABEL, (yyvsp[(2) - (2)].labelref)); 1882 (yyval.array).data = data_add_marker((yyvsp[(1) - (2)].array).data, LABEL, (yyvsp[(2) - (2)].labelref));
1853 ;} 1883 }
1854 break; 1884 break;
1855 1885
1856 case 33: 1886 case 33:
1857 1887
1858/* Line 1455 of yacc.c */ 1888/* Line 1806 of yacc.c */
1859#line 337 "dtc-parser.y" 1889#line 337 "dtc-parser.y"
1860 { 1890 {
1861 (yyval.integer) = eval_literal((yyvsp[(1) - (1)].literal), 0, 64); 1891 (yyval.integer) = eval_literal((yyvsp[(1) - (1)].literal), 0, 64);
1862 ;} 1892 }
1863 break; 1893 break;
1864 1894
1865 case 34: 1895 case 34:
1866 1896
1867/* Line 1455 of yacc.c */ 1897/* Line 1806 of yacc.c */
1868#line 341 "dtc-parser.y" 1898#line 341 "dtc-parser.y"
1869 { 1899 {
1870 (yyval.integer) = eval_char_literal((yyvsp[(1) - (1)].literal)); 1900 (yyval.integer) = eval_char_literal((yyvsp[(1) - (1)].literal));
1871 ;} 1901 }
1872 break; 1902 break;
1873 1903
1874 case 35: 1904 case 35:
1875 1905
1876/* Line 1455 of yacc.c */ 1906/* Line 1806 of yacc.c */
1877#line 345 "dtc-parser.y" 1907#line 345 "dtc-parser.y"
1878 { 1908 {
1879 (yyval.integer) = (yyvsp[(2) - (3)].integer); 1909 (yyval.integer) = (yyvsp[(2) - (3)].integer);
1880 ;} 1910 }
1881 break; 1911 break;
1882 1912
1883 case 38: 1913 case 38:
1884 1914
1885/* Line 1455 of yacc.c */ 1915/* Line 1806 of yacc.c */
1886#line 356 "dtc-parser.y" 1916#line 356 "dtc-parser.y"
1887 { (yyval.integer) = (yyvsp[(1) - (5)].integer) ? (yyvsp[(3) - (5)].integer) : (yyvsp[(5) - (5)].integer); ;} 1917 { (yyval.integer) = (yyvsp[(1) - (5)].integer) ? (yyvsp[(3) - (5)].integer) : (yyvsp[(5) - (5)].integer); }
1888 break; 1918 break;
1889 1919
1890 case 40: 1920 case 40:
1891 1921
1892/* Line 1455 of yacc.c */ 1922/* Line 1806 of yacc.c */
1893#line 361 "dtc-parser.y" 1923#line 361 "dtc-parser.y"
1894 { (yyval.integer) = (yyvsp[(1) - (3)].integer) || (yyvsp[(3) - (3)].integer); ;} 1924 { (yyval.integer) = (yyvsp[(1) - (3)].integer) || (yyvsp[(3) - (3)].integer); }
1895 break; 1925 break;
1896 1926
1897 case 42: 1927 case 42:
1898 1928
1899/* Line 1455 of yacc.c */ 1929/* Line 1806 of yacc.c */
1900#line 366 "dtc-parser.y" 1930#line 366 "dtc-parser.y"
1901 { (yyval.integer) = (yyvsp[(1) - (3)].integer) && (yyvsp[(3) - (3)].integer); ;} 1931 { (yyval.integer) = (yyvsp[(1) - (3)].integer) && (yyvsp[(3) - (3)].integer); }
1902 break; 1932 break;
1903 1933
1904 case 44: 1934 case 44:
1905 1935
1906/* Line 1455 of yacc.c */ 1936/* Line 1806 of yacc.c */
1907#line 371 "dtc-parser.y" 1937#line 371 "dtc-parser.y"
1908 { (yyval.integer) = (yyvsp[(1) - (3)].integer) | (yyvsp[(3) - (3)].integer); ;} 1938 { (yyval.integer) = (yyvsp[(1) - (3)].integer) | (yyvsp[(3) - (3)].integer); }
1909 break; 1939 break;
1910 1940
1911 case 46: 1941 case 46:
1912 1942
1913/* Line 1455 of yacc.c */ 1943/* Line 1806 of yacc.c */
1914#line 376 "dtc-parser.y" 1944#line 376 "dtc-parser.y"
1915 { (yyval.integer) = (yyvsp[(1) - (3)].integer) ^ (yyvsp[(3) - (3)].integer); ;} 1945 { (yyval.integer) = (yyvsp[(1) - (3)].integer) ^ (yyvsp[(3) - (3)].integer); }
1916 break; 1946 break;
1917 1947
1918 case 48: 1948 case 48:
1919 1949
1920/* Line 1455 of yacc.c */ 1950/* Line 1806 of yacc.c */
1921#line 381 "dtc-parser.y" 1951#line 381 "dtc-parser.y"
1922 { (yyval.integer) = (yyvsp[(1) - (3)].integer) & (yyvsp[(3) - (3)].integer); ;} 1952 { (yyval.integer) = (yyvsp[(1) - (3)].integer) & (yyvsp[(3) - (3)].integer); }
1923 break; 1953 break;
1924 1954
1925 case 50: 1955 case 50:
1926 1956
1927/* Line 1455 of yacc.c */ 1957/* Line 1806 of yacc.c */
1928#line 386 "dtc-parser.y" 1958#line 386 "dtc-parser.y"
1929 { (yyval.integer) = (yyvsp[(1) - (3)].integer) == (yyvsp[(3) - (3)].integer); ;} 1959 { (yyval.integer) = (yyvsp[(1) - (3)].integer) == (yyvsp[(3) - (3)].integer); }
1930 break; 1960 break;
1931 1961
1932 case 51: 1962 case 51:
1933 1963
1934/* Line 1455 of yacc.c */ 1964/* Line 1806 of yacc.c */
1935#line 387 "dtc-parser.y" 1965#line 387 "dtc-parser.y"
1936 { (yyval.integer) = (yyvsp[(1) - (3)].integer) != (yyvsp[(3) - (3)].integer); ;} 1966 { (yyval.integer) = (yyvsp[(1) - (3)].integer) != (yyvsp[(3) - (3)].integer); }
1937 break; 1967 break;
1938 1968
1939 case 53: 1969 case 53:
1940 1970
1941/* Line 1455 of yacc.c */ 1971/* Line 1806 of yacc.c */
1942#line 392 "dtc-parser.y" 1972#line 392 "dtc-parser.y"
1943 { (yyval.integer) = (yyvsp[(1) - (3)].integer) < (yyvsp[(3) - (3)].integer); ;} 1973 { (yyval.integer) = (yyvsp[(1) - (3)].integer) < (yyvsp[(3) - (3)].integer); }
1944 break; 1974 break;
1945 1975
1946 case 54: 1976 case 54:
1947 1977
1948/* Line 1455 of yacc.c */ 1978/* Line 1806 of yacc.c */
1949#line 393 "dtc-parser.y" 1979#line 393 "dtc-parser.y"
1950 { (yyval.integer) = (yyvsp[(1) - (3)].integer) > (yyvsp[(3) - (3)].integer); ;} 1980 { (yyval.integer) = (yyvsp[(1) - (3)].integer) > (yyvsp[(3) - (3)].integer); }
1951 break; 1981 break;
1952 1982
1953 case 55: 1983 case 55:
1954 1984
1955/* Line 1455 of yacc.c */ 1985/* Line 1806 of yacc.c */
1956#line 394 "dtc-parser.y" 1986#line 394 "dtc-parser.y"
1957 { (yyval.integer) = (yyvsp[(1) - (3)].integer) <= (yyvsp[(3) - (3)].integer); ;} 1987 { (yyval.integer) = (yyvsp[(1) - (3)].integer) <= (yyvsp[(3) - (3)].integer); }
1958 break; 1988 break;
1959 1989
1960 case 56: 1990 case 56:
1961 1991
1962/* Line 1455 of yacc.c */ 1992/* Line 1806 of yacc.c */
1963#line 395 "dtc-parser.y" 1993#line 395 "dtc-parser.y"
1964 { (yyval.integer) = (yyvsp[(1) - (3)].integer) >= (yyvsp[(3) - (3)].integer); ;} 1994 { (yyval.integer) = (yyvsp[(1) - (3)].integer) >= (yyvsp[(3) - (3)].integer); }
1965 break; 1995 break;
1966 1996
1967 case 57: 1997 case 57:
1968 1998
1969/* Line 1455 of yacc.c */ 1999/* Line 1806 of yacc.c */
1970#line 399 "dtc-parser.y" 2000#line 399 "dtc-parser.y"
1971 { (yyval.integer) = (yyvsp[(1) - (3)].integer) << (yyvsp[(3) - (3)].integer); ;} 2001 { (yyval.integer) = (yyvsp[(1) - (3)].integer) << (yyvsp[(3) - (3)].integer); }
1972 break; 2002 break;
1973 2003
1974 case 58: 2004 case 58:
1975 2005
1976/* Line 1455 of yacc.c */ 2006/* Line 1806 of yacc.c */
1977#line 400 "dtc-parser.y" 2007#line 400 "dtc-parser.y"
1978 { (yyval.integer) = (yyvsp[(1) - (3)].integer) >> (yyvsp[(3) - (3)].integer); ;} 2008 { (yyval.integer) = (yyvsp[(1) - (3)].integer) >> (yyvsp[(3) - (3)].integer); }
1979 break; 2009 break;
1980 2010
1981 case 60: 2011 case 60:
1982 2012
1983/* Line 1455 of yacc.c */ 2013/* Line 1806 of yacc.c */
1984#line 405 "dtc-parser.y" 2014#line 405 "dtc-parser.y"
1985 { (yyval.integer) = (yyvsp[(1) - (3)].integer) + (yyvsp[(3) - (3)].integer); ;} 2015 { (yyval.integer) = (yyvsp[(1) - (3)].integer) + (yyvsp[(3) - (3)].integer); }
1986 break; 2016 break;
1987 2017
1988 case 61: 2018 case 61:
1989 2019
1990/* Line 1455 of yacc.c */ 2020/* Line 1806 of yacc.c */
1991#line 406 "dtc-parser.y" 2021#line 406 "dtc-parser.y"
1992 { (yyval.integer) = (yyvsp[(1) - (3)].integer) - (yyvsp[(3) - (3)].integer); ;} 2022 { (yyval.integer) = (yyvsp[(1) - (3)].integer) - (yyvsp[(3) - (3)].integer); }
1993 break; 2023 break;
1994 2024
1995 case 63: 2025 case 63:
1996 2026
1997/* Line 1455 of yacc.c */ 2027/* Line 1806 of yacc.c */
1998#line 411 "dtc-parser.y" 2028#line 411 "dtc-parser.y"
1999 { (yyval.integer) = (yyvsp[(1) - (3)].integer) * (yyvsp[(3) - (3)].integer); ;} 2029 { (yyval.integer) = (yyvsp[(1) - (3)].integer) * (yyvsp[(3) - (3)].integer); }
2000 break; 2030 break;
2001 2031
2002 case 64: 2032 case 64:
2003 2033
2004/* Line 1455 of yacc.c */ 2034/* Line 1806 of yacc.c */
2005#line 412 "dtc-parser.y" 2035#line 412 "dtc-parser.y"
2006 { (yyval.integer) = (yyvsp[(1) - (3)].integer) / (yyvsp[(3) - (3)].integer); ;} 2036 { (yyval.integer) = (yyvsp[(1) - (3)].integer) / (yyvsp[(3) - (3)].integer); }
2007 break; 2037 break;
2008 2038
2009 case 65: 2039 case 65:
2010 2040
2011/* Line 1455 of yacc.c */ 2041/* Line 1806 of yacc.c */
2012#line 413 "dtc-parser.y" 2042#line 413 "dtc-parser.y"
2013 { (yyval.integer) = (yyvsp[(1) - (3)].integer) % (yyvsp[(3) - (3)].integer); ;} 2043 { (yyval.integer) = (yyvsp[(1) - (3)].integer) % (yyvsp[(3) - (3)].integer); }
2014 break; 2044 break;
2015 2045
2016 case 68: 2046 case 68:
2017 2047
2018/* Line 1455 of yacc.c */ 2048/* Line 1806 of yacc.c */
2019#line 419 "dtc-parser.y" 2049#line 419 "dtc-parser.y"
2020 { (yyval.integer) = -(yyvsp[(2) - (2)].integer); ;} 2050 { (yyval.integer) = -(yyvsp[(2) - (2)].integer); }
2021 break; 2051 break;
2022 2052
2023 case 69: 2053 case 69:
2024 2054
2025/* Line 1455 of yacc.c */ 2055/* Line 1806 of yacc.c */
2026#line 420 "dtc-parser.y" 2056#line 420 "dtc-parser.y"
2027 { (yyval.integer) = ~(yyvsp[(2) - (2)].integer); ;} 2057 { (yyval.integer) = ~(yyvsp[(2) - (2)].integer); }
2028 break; 2058 break;
2029 2059
2030 case 70: 2060 case 70:
2031 2061
2032/* Line 1455 of yacc.c */ 2062/* Line 1806 of yacc.c */
2033#line 421 "dtc-parser.y" 2063#line 421 "dtc-parser.y"
2034 { (yyval.integer) = !(yyvsp[(2) - (2)].integer); ;} 2064 { (yyval.integer) = !(yyvsp[(2) - (2)].integer); }
2035 break; 2065 break;
2036 2066
2037 case 71: 2067 case 71:
2038 2068
2039/* Line 1455 of yacc.c */ 2069/* Line 1806 of yacc.c */
2040#line 426 "dtc-parser.y" 2070#line 426 "dtc-parser.y"
2041 { 2071 {
2042 (yyval.data) = empty_data; 2072 (yyval.data) = empty_data;
2043 ;} 2073 }
2044 break; 2074 break;
2045 2075
2046 case 72: 2076 case 72:
2047 2077
2048/* Line 1455 of yacc.c */ 2078/* Line 1806 of yacc.c */
2049#line 430 "dtc-parser.y" 2079#line 430 "dtc-parser.y"
2050 { 2080 {
2051 (yyval.data) = data_append_byte((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].byte)); 2081 (yyval.data) = data_append_byte((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].byte));
2052 ;} 2082 }
2053 break; 2083 break;
2054 2084
2055 case 73: 2085 case 73:
2056 2086
2057/* Line 1455 of yacc.c */ 2087/* Line 1806 of yacc.c */
2058#line 434 "dtc-parser.y" 2088#line 434 "dtc-parser.y"
2059 { 2089 {
2060 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); 2090 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
2061 ;} 2091 }
2062 break; 2092 break;
2063 2093
2064 case 74: 2094 case 74:
2065 2095
2066/* Line 1455 of yacc.c */ 2096/* Line 1806 of yacc.c */
2067#line 441 "dtc-parser.y" 2097#line 441 "dtc-parser.y"
2068 { 2098 {
2069 (yyval.nodelist) = NULL; 2099 (yyval.nodelist) = NULL;
2070 ;} 2100 }
2071 break; 2101 break;
2072 2102
2073 case 75: 2103 case 75:
2074 2104
2075/* Line 1455 of yacc.c */ 2105/* Line 1806 of yacc.c */
2076#line 445 "dtc-parser.y" 2106#line 445 "dtc-parser.y"
2077 { 2107 {
2078 (yyval.nodelist) = chain_node((yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].nodelist)); 2108 (yyval.nodelist) = chain_node((yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].nodelist));
2079 ;} 2109 }
2080 break; 2110 break;
2081 2111
2082 case 76: 2112 case 76:
2083 2113
2084/* Line 1455 of yacc.c */ 2114/* Line 1806 of yacc.c */
2085#line 449 "dtc-parser.y" 2115#line 449 "dtc-parser.y"
2086 { 2116 {
2087 print_error("syntax error: properties must precede subnodes"); 2117 print_error("syntax error: properties must precede subnodes");
2088 YYERROR; 2118 YYERROR;
2089 ;} 2119 }
2090 break; 2120 break;
2091 2121
2092 case 77: 2122 case 77:
2093 2123
2094/* Line 1455 of yacc.c */ 2124/* Line 1806 of yacc.c */
2095#line 457 "dtc-parser.y" 2125#line 457 "dtc-parser.y"
2096 { 2126 {
2097 (yyval.node) = name_node((yyvsp[(2) - (2)].node), (yyvsp[(1) - (2)].propnodename)); 2127 (yyval.node) = name_node((yyvsp[(2) - (2)].node), (yyvsp[(1) - (2)].propnodename));
2098 ;} 2128 }
2099 break; 2129 break;
2100 2130
2101 case 78: 2131 case 78:
2102 2132
2103/* Line 1455 of yacc.c */ 2133/* Line 1806 of yacc.c */
2104#line 461 "dtc-parser.y" 2134#line 461 "dtc-parser.y"
2105 { 2135 {
2106 (yyval.node) = name_node(build_node_delete(), (yyvsp[(2) - (3)].propnodename)); 2136 (yyval.node) = name_node(build_node_delete(), (yyvsp[(2) - (3)].propnodename));
2107 ;} 2137 }
2108 break; 2138 break;
2109 2139
2110 case 79: 2140 case 79:
2111 2141
2112/* Line 1455 of yacc.c */ 2142/* Line 1806 of yacc.c */
2113#line 465 "dtc-parser.y" 2143#line 465 "dtc-parser.y"
2114 { 2144 {
2115 add_label(&(yyvsp[(2) - (2)].node)->labels, (yyvsp[(1) - (2)].labelref)); 2145 add_label(&(yyvsp[(2) - (2)].node)->labels, (yyvsp[(1) - (2)].labelref));
2116 (yyval.node) = (yyvsp[(2) - (2)].node); 2146 (yyval.node) = (yyvsp[(2) - (2)].node);
2117 ;} 2147 }
2118 break; 2148 break;
2119 2149
2120 2150
2121 2151
2122/* Line 1455 of yacc.c */ 2152/* Line 1806 of yacc.c */
2123#line 2124 "dtc-parser.tab.c" 2153#line 2154 "dtc-parser.tab.c"
2124 default: break; 2154 default: break;
2125 } 2155 }
2156 /* User semantic actions sometimes alter yychar, and that requires
2157 that yytoken be updated with the new translation. We take the
2158 approach of translating immediately before every use of yytoken.
2159 One alternative is translating here after every semantic action,
2160 but that translation would be missed if the semantic action invokes
2161 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
2162 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
2163 incorrect destructor might then be invoked immediately. In the
2164 case of YYERROR or YYBACKUP, subsequent parser actions might lead
2165 to an incorrect destructor call or verbose syntax error message
2166 before the lookahead is translated. */
2126 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); 2167 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2127 2168
2128 YYPOPSTACK (yylen); 2169 YYPOPSTACK (yylen);
@@ -2150,6 +2191,10 @@ yyreduce:
2150| yyerrlab -- here on detecting error | 2191| yyerrlab -- here on detecting error |
2151`------------------------------------*/ 2192`------------------------------------*/
2152yyerrlab: 2193yyerrlab:
2194 /* Make sure we have latest lookahead translation. See comments at
2195 user semantic actions for why this is necessary. */
2196 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
2197
2153 /* If not already recovering from an error, report this error. */ 2198 /* If not already recovering from an error, report this error. */
2154 if (!yyerrstatus) 2199 if (!yyerrstatus)
2155 { 2200 {
@@ -2157,37 +2202,36 @@ yyerrlab:
2157#if ! YYERROR_VERBOSE 2202#if ! YYERROR_VERBOSE
2158 yyerror (YY_("syntax error")); 2203 yyerror (YY_("syntax error"));
2159#else 2204#else
2205# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
2206 yyssp, yytoken)
2160 { 2207 {
2161 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); 2208 char const *yymsgp = YY_("syntax error");
2162 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) 2209 int yysyntax_error_status;
2163 { 2210 yysyntax_error_status = YYSYNTAX_ERROR;
2164 YYSIZE_T yyalloc = 2 * yysize; 2211 if (yysyntax_error_status == 0)
2165 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) 2212 yymsgp = yymsg;
2166 yyalloc = YYSTACK_ALLOC_MAXIMUM; 2213 else if (yysyntax_error_status == 1)
2167 if (yymsg != yymsgbuf) 2214 {
2168 YYSTACK_FREE (yymsg); 2215 if (yymsg != yymsgbuf)
2169 yymsg = (char *) YYSTACK_ALLOC (yyalloc); 2216 YYSTACK_FREE (yymsg);
2170 if (yymsg) 2217 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
2171 yymsg_alloc = yyalloc; 2218 if (!yymsg)
2172 else 2219 {
2173 { 2220 yymsg = yymsgbuf;
2174 yymsg = yymsgbuf; 2221 yymsg_alloc = sizeof yymsgbuf;
2175 yymsg_alloc = sizeof yymsgbuf; 2222 yysyntax_error_status = 2;
2176 } 2223 }
2177 } 2224 else
2178 2225 {
2179 if (0 < yysize && yysize <= yymsg_alloc) 2226 yysyntax_error_status = YYSYNTAX_ERROR;
2180 { 2227 yymsgp = yymsg;
2181 (void) yysyntax_error (yymsg, yystate, yychar); 2228 }
2182 yyerror (yymsg); 2229 }
2183 } 2230 yyerror (yymsgp);
2184 else 2231 if (yysyntax_error_status == 2)
2185 { 2232 goto yyexhaustedlab;
2186 yyerror (YY_("syntax error"));
2187 if (yysize != 0)
2188 goto yyexhaustedlab;
2189 }
2190 } 2233 }
2234# undef YYSYNTAX_ERROR
2191#endif 2235#endif
2192 } 2236 }
2193 2237
@@ -2246,7 +2290,7 @@ yyerrlab1:
2246 for (;;) 2290 for (;;)
2247 { 2291 {
2248 yyn = yypact[yystate]; 2292 yyn = yypact[yystate];
2249 if (yyn != YYPACT_NINF) 2293 if (!yypact_value_is_default (yyn))
2250 { 2294 {
2251 yyn += YYTERROR; 2295 yyn += YYTERROR;
2252 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) 2296 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
@@ -2305,8 +2349,13 @@ yyexhaustedlab:
2305 2349
2306yyreturn: 2350yyreturn:
2307 if (yychar != YYEMPTY) 2351 if (yychar != YYEMPTY)
2308 yydestruct ("Cleanup: discarding lookahead", 2352 {
2309 yytoken, &yylval); 2353 /* Make sure we have latest lookahead translation. See comments at
2354 user semantic actions for why this is necessary. */
2355 yytoken = YYTRANSLATE (yychar);
2356 yydestruct ("Cleanup: discarding lookahead",
2357 yytoken, &yylval);
2358 }
2310 /* Do not reclaim the symbols of the rule which action triggered 2359 /* Do not reclaim the symbols of the rule which action triggered
2311 this YYABORT or YYACCEPT. */ 2360 this YYABORT or YYACCEPT. */
2312 YYPOPSTACK (yylen); 2361 YYPOPSTACK (yylen);
@@ -2331,7 +2380,7 @@ yyreturn:
2331 2380
2332 2381
2333 2382
2334/* Line 1675 of yacc.c */ 2383/* Line 2067 of yacc.c */
2335#line 471 "dtc-parser.y" 2384#line 471 "dtc-parser.y"
2336 2385
2337 2386
diff --git a/scripts/dtc/dtc-parser.tab.h_shipped b/scripts/dtc/dtc-parser.tab.h_shipped
index 9d2dce41211f..25d3b88c6132 100644
--- a/scripts/dtc/dtc-parser.tab.h_shipped
+++ b/scripts/dtc/dtc-parser.tab.h_shipped
@@ -1,10 +1,8 @@
1/* A Bison parser, made by GNU Bison 2.5. */
1 2
2/* A Bison parser, made by GNU Bison 2.4.1. */ 3/* Bison interface for Yacc-like parsers in C
3
4/* Skeleton interface for Bison's Yacc-like parsers in C
5 4
6 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 5 Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
7 Free Software Foundation, Inc.
8 6
9 This program is free software: you can redistribute it and/or modify 7 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
@@ -70,7 +68,7 @@
70typedef union YYSTYPE 68typedef union YYSTYPE
71{ 69{
72 70
73/* Line 1676 of yacc.c */ 71/* Line 2068 of yacc.c */
74#line 40 "dtc-parser.y" 72#line 40 "dtc-parser.y"
75 73
76 char *propnodename; 74 char *propnodename;
@@ -94,8 +92,8 @@ typedef union YYSTYPE
94 92
95 93
96 94
97/* Line 1676 of yacc.c */ 95/* Line 2068 of yacc.c */
98#line 99 "dtc-parser.tab.h" 96#line 97 "dtc-parser.tab.h"
99} YYSTYPE; 97} YYSTYPE;
100# define YYSTYPE_IS_TRIVIAL 1 98# define YYSTYPE_IS_TRIVIAL 1
101# define yystype YYSTYPE /* obsolescent; will be withdrawn */ 99# define yystype YYSTYPE /* obsolescent; will be withdrawn */
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index ccfa383f1fda..f92818155958 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -1649,6 +1649,7 @@ static int snd_pcm_link(struct snd_pcm_substream *substream, int fd)
1649 } 1649 }
1650 if (!snd_pcm_stream_linked(substream)) { 1650 if (!snd_pcm_stream_linked(substream)) {
1651 substream->group = group; 1651 substream->group = group;
1652 group = NULL;
1652 spin_lock_init(&substream->group->lock); 1653 spin_lock_init(&substream->group->lock);
1653 INIT_LIST_HEAD(&substream->group->substreams); 1654 INIT_LIST_HEAD(&substream->group->substreams);
1654 list_add_tail(&substream->link_list, &substream->group->substreams); 1655 list_add_tail(&substream->link_list, &substream->group->substreams);
@@ -1663,8 +1664,7 @@ static int snd_pcm_link(struct snd_pcm_substream *substream, int fd)
1663 _nolock: 1664 _nolock:
1664 snd_card_unref(substream1->pcm->card); 1665 snd_card_unref(substream1->pcm->card);
1665 fput_light(file, fput_needed); 1666 fput_light(file, fput_needed);
1666 if (res < 0) 1667 kfree(group);
1667 kfree(group);
1668 return res; 1668 return res;
1669} 1669}
1670 1670
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c
index bd8d46cca2b3..cccaf9c7a7bb 100644
--- a/sound/pci/hda/patch_cirrus.c
+++ b/sound/pci/hda/patch_cirrus.c
@@ -58,6 +58,7 @@ enum {
58 CS420X_GPIO_23, 58 CS420X_GPIO_23,
59 CS420X_MBP101, 59 CS420X_MBP101,
60 CS420X_MBP81, 60 CS420X_MBP81,
61 CS420X_MBA42,
61 CS420X_AUTO, 62 CS420X_AUTO,
62 /* aliases */ 63 /* aliases */
63 CS420X_IMAC27_122 = CS420X_GPIO_23, 64 CS420X_IMAC27_122 = CS420X_GPIO_23,
@@ -346,6 +347,7 @@ static const struct hda_model_fixup cs420x_models[] = {
346 { .id = CS420X_APPLE, .name = "apple" }, 347 { .id = CS420X_APPLE, .name = "apple" },
347 { .id = CS420X_MBP101, .name = "mbp101" }, 348 { .id = CS420X_MBP101, .name = "mbp101" },
348 { .id = CS420X_MBP81, .name = "mbp81" }, 349 { .id = CS420X_MBP81, .name = "mbp81" },
350 { .id = CS420X_MBA42, .name = "mba42" },
349 {} 351 {}
350}; 352};
351 353
@@ -361,6 +363,7 @@ static const struct snd_pci_quirk cs420x_fixup_tbl[] = {
361 SND_PCI_QUIRK(0x106b, 0x1c00, "MacBookPro 8,1", CS420X_MBP81), 363 SND_PCI_QUIRK(0x106b, 0x1c00, "MacBookPro 8,1", CS420X_MBP81),
362 SND_PCI_QUIRK(0x106b, 0x2000, "iMac 12,2", CS420X_IMAC27_122), 364 SND_PCI_QUIRK(0x106b, 0x2000, "iMac 12,2", CS420X_IMAC27_122),
363 SND_PCI_QUIRK(0x106b, 0x2800, "MacBookPro 10,1", CS420X_MBP101), 365 SND_PCI_QUIRK(0x106b, 0x2800, "MacBookPro 10,1", CS420X_MBP101),
366 SND_PCI_QUIRK(0x106b, 0x5b00, "MacBookAir 4,2", CS420X_MBA42),
364 SND_PCI_QUIRK_VENDOR(0x106b, "Apple", CS420X_APPLE), 367 SND_PCI_QUIRK_VENDOR(0x106b, "Apple", CS420X_APPLE),
365 {} /* terminator */ 368 {} /* terminator */
366}; 369};
@@ -414,6 +417,20 @@ static const struct hda_pintbl mbp101_pincfgs[] = {
414 {} /* terminator */ 417 {} /* terminator */
415}; 418};
416 419
420static const struct hda_pintbl mba42_pincfgs[] = {
421 { 0x09, 0x012b4030 }, /* HP */
422 { 0x0a, 0x400000f0 },
423 { 0x0b, 0x90100120 }, /* speaker */
424 { 0x0c, 0x400000f0 },
425 { 0x0d, 0x90a00110 }, /* mic */
426 { 0x0e, 0x400000f0 },
427 { 0x0f, 0x400000f0 },
428 { 0x10, 0x400000f0 },
429 { 0x12, 0x400000f0 },
430 { 0x15, 0x400000f0 },
431 {} /* terminator */
432};
433
417static void cs420x_fixup_gpio_13(struct hda_codec *codec, 434static void cs420x_fixup_gpio_13(struct hda_codec *codec,
418 const struct hda_fixup *fix, int action) 435 const struct hda_fixup *fix, int action)
419{ 436{
@@ -482,6 +499,12 @@ static const struct hda_fixup cs420x_fixups[] = {
482 .chained = true, 499 .chained = true,
483 .chain_id = CS420X_GPIO_13, 500 .chain_id = CS420X_GPIO_13,
484 }, 501 },
502 [CS420X_MBA42] = {
503 .type = HDA_FIXUP_PINS,
504 .v.pins = mba42_pincfgs,
505 .chained = true,
506 .chain_id = CS420X_GPIO_13,
507 },
485}; 508};
486 509
487static struct cs_spec *cs_alloc_spec(struct hda_codec *codec, int vendor_nid) 510static struct cs_spec *cs_alloc_spec(struct hda_codec *codec, int vendor_nid)
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 02e22b4458d2..403010c9e82e 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -3483,6 +3483,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
3483 SND_PCI_QUIRK(0x1028, 0x05ca, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 3483 SND_PCI_QUIRK(0x1028, 0x05ca, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
3484 SND_PCI_QUIRK(0x1028, 0x05cb, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 3484 SND_PCI_QUIRK(0x1028, 0x05cb, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
3485 SND_PCI_QUIRK(0x1028, 0x05de, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 3485 SND_PCI_QUIRK(0x1028, 0x05de, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
3486 SND_PCI_QUIRK(0x1028, 0x05e0, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
3486 SND_PCI_QUIRK(0x1028, 0x05e9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 3487 SND_PCI_QUIRK(0x1028, 0x05e9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3487 SND_PCI_QUIRK(0x1028, 0x05ea, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 3488 SND_PCI_QUIRK(0x1028, 0x05ea, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3488 SND_PCI_QUIRK(0x1028, 0x05eb, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 3489 SND_PCI_QUIRK(0x1028, 0x05eb, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
@@ -3494,6 +3495,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
3494 SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 3495 SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3495 SND_PCI_QUIRK(0x1028, 0x05f6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 3496 SND_PCI_QUIRK(0x1028, 0x05f6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3496 SND_PCI_QUIRK(0x1028, 0x05f8, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 3497 SND_PCI_QUIRK(0x1028, 0x05f8, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3498 SND_PCI_QUIRK(0x1028, 0x0606, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3499 SND_PCI_QUIRK(0x1028, 0x0608, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3497 SND_PCI_QUIRK(0x1028, 0x0609, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 3500 SND_PCI_QUIRK(0x1028, 0x0609, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3498 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2), 3501 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
3499 SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED), 3502 SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED),
@@ -3596,6 +3599,8 @@ static const struct hda_model_fixup alc269_fixup_models[] = {
3596 {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"}, 3599 {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"},
3597 {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"}, 3600 {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
3598 {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"}, 3601 {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
3602 {.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
3603 {.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"},
3599 {} 3604 {}
3600}; 3605};
3601 3606
@@ -4275,6 +4280,7 @@ static const struct hda_model_fixup alc662_fixup_models[] = {
4275 {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"}, 4280 {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
4276 {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"}, 4281 {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
4277 {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"}, 4282 {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"},
4283 {.id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
4278 {} 4284 {}
4279}; 4285};
4280 4286
diff --git a/sound/soc/codecs/cs42l52.c b/sound/soc/codecs/cs42l52.c
index 030f53c96ec0..987f728718c5 100644
--- a/sound/soc/codecs/cs42l52.c
+++ b/sound/soc/codecs/cs42l52.c
@@ -193,6 +193,8 @@ static DECLARE_TLV_DB_SCALE(mic_tlv, 1600, 100, 0);
193 193
194static DECLARE_TLV_DB_SCALE(pga_tlv, -600, 50, 0); 194static DECLARE_TLV_DB_SCALE(pga_tlv, -600, 50, 0);
195 195
196static DECLARE_TLV_DB_SCALE(mix_tlv, -50, 50, 0);
197
196static const unsigned int limiter_tlv[] = { 198static const unsigned int limiter_tlv[] = {
197 TLV_DB_RANGE_HEAD(2), 199 TLV_DB_RANGE_HEAD(2),
198 0, 2, TLV_DB_SCALE_ITEM(-3000, 600, 0), 200 0, 2, TLV_DB_SCALE_ITEM(-3000, 600, 0),
@@ -260,7 +262,7 @@ static const char * const hp_gain_num_text[] = {
260}; 262};
261 263
262static const struct soc_enum hp_gain_enum = 264static const struct soc_enum hp_gain_enum =
263 SOC_ENUM_SINGLE(CS42L52_PB_CTL1, 4, 265 SOC_ENUM_SINGLE(CS42L52_PB_CTL1, 5,
264 ARRAY_SIZE(hp_gain_num_text), hp_gain_num_text); 266 ARRAY_SIZE(hp_gain_num_text), hp_gain_num_text);
265 267
266static const char * const beep_pitch_text[] = { 268static const char * const beep_pitch_text[] = {
@@ -441,7 +443,7 @@ static const struct snd_kcontrol_new cs42l52_snd_controls[] = {
441 443
442 SOC_DOUBLE_R_SX_TLV("PCM Mixer Volume", 444 SOC_DOUBLE_R_SX_TLV("PCM Mixer Volume",
443 CS42L52_PCMA_MIXER_VOL, CS42L52_PCMB_MIXER_VOL, 445 CS42L52_PCMA_MIXER_VOL, CS42L52_PCMB_MIXER_VOL,
444 0, 0x7f, 0x19, hl_tlv), 446 0, 0x7f, 0x19, mix_tlv),
445 SOC_DOUBLE_R("PCM Mixer Switch", 447 SOC_DOUBLE_R("PCM Mixer Switch",
446 CS42L52_PCMA_MIXER_VOL, CS42L52_PCMB_MIXER_VOL, 7, 1, 1), 448 CS42L52_PCMA_MIXER_VOL, CS42L52_PCMB_MIXER_VOL, 7, 1, 1),
447 449
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 65d09d60b7c6..1514bf845e4b 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -187,14 +187,14 @@ static int snd_soc_dapm_put_volsw_aic3x(struct snd_kcontrol *kcontrol,
187 187
188 break; 188 break;
189 } 189 }
190
191 if (found)
192 snd_soc_dapm_sync(widget->dapm);
193 } 190 }
194 191
195 ret = snd_soc_update_bits(widget->codec, reg, val_mask, val);
196
197 mutex_unlock(&widget->codec->mutex); 192 mutex_unlock(&widget->codec->mutex);
193
194 if (found)
195 snd_soc_dapm_sync(widget->dapm);
196
197 ret = snd_soc_update_bits_locked(widget->codec, reg, val_mask, val);
198 return ret; 198 return ret;
199} 199}
200 200
diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c
index e895d3939eef..100fdadda56a 100644
--- a/sound/soc/codecs/wm5102.c
+++ b/sound/soc/codecs/wm5102.c
@@ -1120,7 +1120,8 @@ SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 0,
1120ARIZONA_DSP_WIDGETS(DSP1, "DSP1"), 1120ARIZONA_DSP_WIDGETS(DSP1, "DSP1"),
1121 1121
1122SND_SOC_DAPM_VALUE_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, 1122SND_SOC_DAPM_VALUE_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1,
1123 ARIZONA_AEC_LOOPBACK_ENA, 0, &wm5102_aec_loopback_mux), 1123 ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0,
1124 &wm5102_aec_loopback_mux),
1124 1125
1125SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM, 1126SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM,
1126 ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, 1127 ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev,
diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c
index ba38f0679662..88ad7db52dde 100644
--- a/sound/soc/codecs/wm5110.c
+++ b/sound/soc/codecs/wm5110.c
@@ -503,7 +503,8 @@ SND_SOC_DAPM_PGA("ASRC2R", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC2R_ENA_SHIFT, 0,
503 NULL, 0), 503 NULL, 0),
504 504
505SND_SOC_DAPM_VALUE_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, 505SND_SOC_DAPM_VALUE_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1,
506 ARIZONA_AEC_LOOPBACK_ENA, 0, &wm5110_aec_loopback_mux), 506 ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0,
507 &wm5110_aec_loopback_mux),
507 508
508SND_SOC_DAPM_AIF_OUT("AIF1TX1", NULL, 0, 509SND_SOC_DAPM_AIF_OUT("AIF1TX1", NULL, 0,
509 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX1_ENA_SHIFT, 0), 510 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX1_ENA_SHIFT, 0),
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index dfd997aaadfc..29e95f93d482 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -3836,12 +3836,13 @@ static irqreturn_t wm8958_mic_irq(int irq, void *data)
3836 ret); 3836 ret);
3837 } else if (!(ret & WM1811_JACKDET_LVL)) { 3837 } else if (!(ret & WM1811_JACKDET_LVL)) {
3838 dev_dbg(codec->dev, "Ignoring removed jack\n"); 3838 dev_dbg(codec->dev, "Ignoring removed jack\n");
3839 return IRQ_HANDLED; 3839 goto out;
3840 } 3840 }
3841 } else if (!(reg & WM8958_MICD_STS)) { 3841 } else if (!(reg & WM8958_MICD_STS)) {
3842 snd_soc_jack_report(wm8994->micdet[0].jack, 0, 3842 snd_soc_jack_report(wm8994->micdet[0].jack, 0,
3843 SND_JACK_MECHANICAL | SND_JACK_HEADSET | 3843 SND_JACK_MECHANICAL | SND_JACK_HEADSET |
3844 wm8994->btn_mask); 3844 wm8994->btn_mask);
3845 wm8994->mic_detecting = true;
3845 goto out; 3846 goto out;
3846 } 3847 }
3847 3848
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index a80c883bb8be..c7051c457b75 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -55,7 +55,8 @@ static int dapm_up_seq[] = {
55 [snd_soc_dapm_clock_supply] = 1, 55 [snd_soc_dapm_clock_supply] = 1,
56 [snd_soc_dapm_micbias] = 2, 56 [snd_soc_dapm_micbias] = 2,
57 [snd_soc_dapm_dai_link] = 2, 57 [snd_soc_dapm_dai_link] = 2,
58 [snd_soc_dapm_dai] = 3, 58 [snd_soc_dapm_dai_in] = 3,
59 [snd_soc_dapm_dai_out] = 3,
59 [snd_soc_dapm_aif_in] = 3, 60 [snd_soc_dapm_aif_in] = 3,
60 [snd_soc_dapm_aif_out] = 3, 61 [snd_soc_dapm_aif_out] = 3,
61 [snd_soc_dapm_mic] = 4, 62 [snd_soc_dapm_mic] = 4,
@@ -92,7 +93,8 @@ static int dapm_down_seq[] = {
92 [snd_soc_dapm_value_mux] = 9, 93 [snd_soc_dapm_value_mux] = 9,
93 [snd_soc_dapm_aif_in] = 10, 94 [snd_soc_dapm_aif_in] = 10,
94 [snd_soc_dapm_aif_out] = 10, 95 [snd_soc_dapm_aif_out] = 10,
95 [snd_soc_dapm_dai] = 10, 96 [snd_soc_dapm_dai_in] = 10,
97 [snd_soc_dapm_dai_out] = 10,
96 [snd_soc_dapm_dai_link] = 11, 98 [snd_soc_dapm_dai_link] = 11,
97 [snd_soc_dapm_clock_supply] = 12, 99 [snd_soc_dapm_clock_supply] = 12,
98 [snd_soc_dapm_regulator_supply] = 12, 100 [snd_soc_dapm_regulator_supply] = 12,
@@ -419,7 +421,8 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
419 case snd_soc_dapm_clock_supply: 421 case snd_soc_dapm_clock_supply:
420 case snd_soc_dapm_aif_in: 422 case snd_soc_dapm_aif_in:
421 case snd_soc_dapm_aif_out: 423 case snd_soc_dapm_aif_out:
422 case snd_soc_dapm_dai: 424 case snd_soc_dapm_dai_in:
425 case snd_soc_dapm_dai_out:
423 case snd_soc_dapm_hp: 426 case snd_soc_dapm_hp:
424 case snd_soc_dapm_mic: 427 case snd_soc_dapm_mic:
425 case snd_soc_dapm_spk: 428 case snd_soc_dapm_spk:
@@ -820,7 +823,7 @@ static int is_connected_output_ep(struct snd_soc_dapm_widget *widget,
820 switch (widget->id) { 823 switch (widget->id) {
821 case snd_soc_dapm_adc: 824 case snd_soc_dapm_adc:
822 case snd_soc_dapm_aif_out: 825 case snd_soc_dapm_aif_out:
823 case snd_soc_dapm_dai: 826 case snd_soc_dapm_dai_out:
824 if (widget->active) { 827 if (widget->active) {
825 widget->outputs = snd_soc_dapm_suspend_check(widget); 828 widget->outputs = snd_soc_dapm_suspend_check(widget);
826 return widget->outputs; 829 return widget->outputs;
@@ -916,7 +919,7 @@ static int is_connected_input_ep(struct snd_soc_dapm_widget *widget,
916 switch (widget->id) { 919 switch (widget->id) {
917 case snd_soc_dapm_dac: 920 case snd_soc_dapm_dac:
918 case snd_soc_dapm_aif_in: 921 case snd_soc_dapm_aif_in:
919 case snd_soc_dapm_dai: 922 case snd_soc_dapm_dai_in:
920 if (widget->active) { 923 if (widget->active) {
921 widget->inputs = snd_soc_dapm_suspend_check(widget); 924 widget->inputs = snd_soc_dapm_suspend_check(widget);
922 return widget->inputs; 925 return widget->inputs;
@@ -1135,16 +1138,6 @@ static int dapm_generic_check_power(struct snd_soc_dapm_widget *w)
1135 return out != 0 && in != 0; 1138 return out != 0 && in != 0;
1136} 1139}
1137 1140
1138static int dapm_dai_check_power(struct snd_soc_dapm_widget *w)
1139{
1140 DAPM_UPDATE_STAT(w, power_checks);
1141
1142 if (w->active)
1143 return w->active;
1144
1145 return dapm_generic_check_power(w);
1146}
1147
1148/* Check to see if an ADC has power */ 1141/* Check to see if an ADC has power */
1149static int dapm_adc_check_power(struct snd_soc_dapm_widget *w) 1142static int dapm_adc_check_power(struct snd_soc_dapm_widget *w)
1150{ 1143{
@@ -2318,7 +2311,8 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm,
2318 case snd_soc_dapm_clock_supply: 2311 case snd_soc_dapm_clock_supply:
2319 case snd_soc_dapm_aif_in: 2312 case snd_soc_dapm_aif_in:
2320 case snd_soc_dapm_aif_out: 2313 case snd_soc_dapm_aif_out:
2321 case snd_soc_dapm_dai: 2314 case snd_soc_dapm_dai_in:
2315 case snd_soc_dapm_dai_out:
2322 case snd_soc_dapm_dai_link: 2316 case snd_soc_dapm_dai_link:
2323 list_add(&path->list, &dapm->card->paths); 2317 list_add(&path->list, &dapm->card->paths);
2324 list_add(&path->list_sink, &wsink->sources); 2318 list_add(&path->list_sink, &wsink->sources);
@@ -3129,10 +3123,12 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
3129 break; 3123 break;
3130 case snd_soc_dapm_adc: 3124 case snd_soc_dapm_adc:
3131 case snd_soc_dapm_aif_out: 3125 case snd_soc_dapm_aif_out:
3126 case snd_soc_dapm_dai_out:
3132 w->power_check = dapm_adc_check_power; 3127 w->power_check = dapm_adc_check_power;
3133 break; 3128 break;
3134 case snd_soc_dapm_dac: 3129 case snd_soc_dapm_dac:
3135 case snd_soc_dapm_aif_in: 3130 case snd_soc_dapm_aif_in:
3131 case snd_soc_dapm_dai_in:
3136 w->power_check = dapm_dac_check_power; 3132 w->power_check = dapm_dac_check_power;
3137 break; 3133 break;
3138 case snd_soc_dapm_pga: 3134 case snd_soc_dapm_pga:
@@ -3152,9 +3148,6 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
3152 case snd_soc_dapm_clock_supply: 3148 case snd_soc_dapm_clock_supply:
3153 w->power_check = dapm_supply_check_power; 3149 w->power_check = dapm_supply_check_power;
3154 break; 3150 break;
3155 case snd_soc_dapm_dai:
3156 w->power_check = dapm_dai_check_power;
3157 break;
3158 default: 3151 default:
3159 w->power_check = dapm_always_on_check_power; 3152 w->power_check = dapm_always_on_check_power;
3160 break; 3153 break;
@@ -3375,7 +3368,7 @@ int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm,
3375 template.reg = SND_SOC_NOPM; 3368 template.reg = SND_SOC_NOPM;
3376 3369
3377 if (dai->driver->playback.stream_name) { 3370 if (dai->driver->playback.stream_name) {
3378 template.id = snd_soc_dapm_dai; 3371 template.id = snd_soc_dapm_dai_in;
3379 template.name = dai->driver->playback.stream_name; 3372 template.name = dai->driver->playback.stream_name;
3380 template.sname = dai->driver->playback.stream_name; 3373 template.sname = dai->driver->playback.stream_name;
3381 3374
@@ -3393,7 +3386,7 @@ int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm,
3393 } 3386 }
3394 3387
3395 if (dai->driver->capture.stream_name) { 3388 if (dai->driver->capture.stream_name) {
3396 template.id = snd_soc_dapm_dai; 3389 template.id = snd_soc_dapm_dai_out;
3397 template.name = dai->driver->capture.stream_name; 3390 template.name = dai->driver->capture.stream_name;
3398 template.sname = dai->driver->capture.stream_name; 3391 template.sname = dai->driver->capture.stream_name;
3399 3392
@@ -3423,8 +3416,13 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
3423 3416
3424 /* For each DAI widget... */ 3417 /* For each DAI widget... */
3425 list_for_each_entry(dai_w, &card->widgets, list) { 3418 list_for_each_entry(dai_w, &card->widgets, list) {
3426 if (dai_w->id != snd_soc_dapm_dai) 3419 switch (dai_w->id) {
3420 case snd_soc_dapm_dai_in:
3421 case snd_soc_dapm_dai_out:
3422 break;
3423 default:
3427 continue; 3424 continue;
3425 }
3428 3426
3429 dai = dai_w->priv; 3427 dai = dai_w->priv;
3430 3428
@@ -3433,8 +3431,13 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
3433 if (w->dapm != dai_w->dapm) 3431 if (w->dapm != dai_w->dapm)
3434 continue; 3432 continue;
3435 3433
3436 if (w->id == snd_soc_dapm_dai) 3434 switch (w->id) {
3435 case snd_soc_dapm_dai_in:
3436 case snd_soc_dapm_dai_out:
3437 continue; 3437 continue;
3438 default:
3439 break;
3440 }
3438 3441
3439 if (!w->sname) 3442 if (!w->sname)
3440 continue; 3443 continue;
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 73bb8eefa491..ccb6be4d658d 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -928,8 +928,13 @@ static int dpcm_add_paths(struct snd_soc_pcm_runtime *fe, int stream,
928 /* Create any new FE <--> BE connections */ 928 /* Create any new FE <--> BE connections */
929 for (i = 0; i < list->num_widgets; i++) { 929 for (i = 0; i < list->num_widgets; i++) {
930 930
931 if (list->widgets[i]->id != snd_soc_dapm_dai) 931 switch (list->widgets[i]->id) {
932 case snd_soc_dapm_dai_in:
933 case snd_soc_dapm_dai_out:
934 break;
935 default:
932 continue; 936 continue;
937 }
933 938
934 /* is there a valid BE rtd for this widget */ 939 /* is there a valid BE rtd for this widget */
935 be = dpcm_get_be(card, list->widgets[i], stream); 940 be = dpcm_get_be(card, list->widgets[i], stream);
@@ -2011,9 +2016,11 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
2011 if (cpu_dai->driver->capture.channels_min) 2016 if (cpu_dai->driver->capture.channels_min)
2012 capture = 1; 2017 capture = 1;
2013 } else { 2018 } else {
2014 if (codec_dai->driver->playback.channels_min) 2019 if (codec_dai->driver->playback.channels_min &&
2020 cpu_dai->driver->playback.channels_min)
2015 playback = 1; 2021 playback = 1;
2016 if (codec_dai->driver->capture.channels_min) 2022 if (codec_dai->driver->capture.channels_min &&
2023 cpu_dai->driver->capture.channels_min)
2017 capture = 1; 2024 capture = 1;
2018 } 2025 }
2019 2026
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 1a033177b83f..64952e2d3ed1 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -147,14 +147,32 @@ static int snd_usb_create_stream(struct snd_usb_audio *chip, int ctrlif, int int
147 return -EINVAL; 147 return -EINVAL;
148 } 148 }
149 149
150 alts = &iface->altsetting[0];
151 altsd = get_iface_desc(alts);
152
153 /*
154 * Android with both accessory and audio interfaces enabled gets the
155 * interface numbers wrong.
156 */
157 if ((chip->usb_id == USB_ID(0x18d1, 0x2d04) ||
158 chip->usb_id == USB_ID(0x18d1, 0x2d05)) &&
159 interface == 0 &&
160 altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC &&
161 altsd->bInterfaceSubClass == USB_SUBCLASS_VENDOR_SPEC) {
162 interface = 2;
163 iface = usb_ifnum_to_if(dev, interface);
164 if (!iface)
165 return -EINVAL;
166 alts = &iface->altsetting[0];
167 altsd = get_iface_desc(alts);
168 }
169
150 if (usb_interface_claimed(iface)) { 170 if (usb_interface_claimed(iface)) {
151 snd_printdd(KERN_INFO "%d:%d:%d: skipping, already claimed\n", 171 snd_printdd(KERN_INFO "%d:%d:%d: skipping, already claimed\n",
152 dev->devnum, ctrlif, interface); 172 dev->devnum, ctrlif, interface);
153 return -EINVAL; 173 return -EINVAL;
154 } 174 }
155 175
156 alts = &iface->altsetting[0];
157 altsd = get_iface_desc(alts);
158 if ((altsd->bInterfaceClass == USB_CLASS_AUDIO || 176 if ((altsd->bInterfaceClass == USB_CLASS_AUDIO ||
159 altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC) && 177 altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC) &&
160 altsd->bInterfaceSubClass == USB_SUBCLASS_MIDISTREAMING) { 178 altsd->bInterfaceSubClass == USB_SUBCLASS_MIDISTREAMING) {
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index e5c7f9f20fdd..d5438083fd6a 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -885,6 +885,7 @@ static void volume_control_quirks(struct usb_mixer_elem_info *cval,
885 885
886 case USB_ID(0x046d, 0x0808): 886 case USB_ID(0x046d, 0x0808):
887 case USB_ID(0x046d, 0x0809): 887 case USB_ID(0x046d, 0x0809):
888 case USB_ID(0x046d, 0x081b): /* HD Webcam c310 */
888 case USB_ID(0x046d, 0x081d): /* HD Webcam c510 */ 889 case USB_ID(0x046d, 0x081d): /* HD Webcam c510 */
889 case USB_ID(0x046d, 0x0825): /* HD Webcam c270 */ 890 case USB_ID(0x046d, 0x0825): /* HD Webcam c270 */
890 case USB_ID(0x046d, 0x0991): 891 case USB_ID(0x046d, 0x0991):
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 9e9d34871195..fe702076ca46 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -2191,7 +2191,7 @@ int initialize_counters(int cpu_id)
2191 2191
2192void allocate_output_buffer() 2192void allocate_output_buffer()
2193{ 2193{
2194 output_buffer = calloc(1, (1 + topo.num_cpus) * 128); 2194 output_buffer = calloc(1, (1 + topo.num_cpus) * 256);
2195 outp = output_buffer; 2195 outp = output_buffer;
2196 if (outp == NULL) { 2196 if (outp == NULL) {
2197 perror("calloc"); 2197 perror("calloc");